Non-threaded

Forums » Advanced Editor Forum » Read Thread

Get help from the experts on variables, scripts, items, and other scary things.

Randomly lose an item?

6 years ago

Looking for how to lose a random item on a certain page. I'm making it for a random event kind of thing. There is a small chance to be taken to a page. Once on the page, it says a thief has stolen an item of yours. I'm not sure how to lose a random carried item without knowing what items the user is carrying

Randomly lose an item?

6 years ago
Since there's no arrays available here, this can get super complex really fast. It depends how you want to do this.

If there are a lot of items, this would quickly get insane. If there are a few items, you could just use a stack of IF statements to find out if a user has an item, then if they do, remove it. I can't think of a simple way to do this because there's no variable variables that really work here, either.

Maybe you flip through the list of items, and when you find one, then you randomly decide if that is the item that is lost? Say, a 10% chance each time an item is found and once you lose one item, you stop looking for more would work.

Randomly lose an item?

6 years ago

That works, thanks!

Randomly lose an item?

6 years ago
In order to truly be random you'd have to make a ton of if statements

I think it's important to note that the "randomness" doesn't necessarily have to be random. You can simply make a list of if statements checking what items the player has, and dropping the first one it finds.

Randomly lose an item?

6 years ago
So do you have a lot of items not vital to the game? Because I'm not sure being unable to complete it over a random event is something anyone is going to enjoy.

Randomly lose an item?

6 years ago

The game has a variety of items, so they're easily replaceable. At least, in this rough plan.