Non-threaded

Forums » Advanced Editor Forum » Read Thread

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

Prevention of duplicate rolls and drop tables

7 years ago

Is it possible to use advanced scripting to build drop tables that avoid rolling repeats / re-roll when they land on an entry that has been rolled before?
E.g. 
If 1d3 = 1 "Helmet", = 2 "Spear" = 3 "Sword". Say you've already rolled a 3 last time and got a sword and you want the system to no longer consider Swords as a drop item (so the next one has to be a Helmet or a Spear, how would that be coded?

Three ways that come to mind are to somehow replace the entry linked to rolling a 3 (Sword) from the consideration list (either replace it with another item from a larger item list that say also includes hammers. When a 3 "Sword" is rolled, the variable Itemon3 is changed to "Hammer", so rolling a 3 now gives a "Hammer". (Though how to prevent an item from being double injected from the master list becomes the next problem, don't want rolling a 1, 2, and 3 to all give hammers accidentally)

Second way is to add a manual if/else, if 3 has been rolled before, 'Hammer' would be hardcoded as the outcome, Else Sword, but this is laborious and fairly restrictive in scope.

Third way is a counter Times3roll = 0, if 3 rolled Times3roll = 1. Based on the value of that counter, I'd set a lookup via if else to pull back a value (e.g. 3roll at 0 gives Sword, at 1 gives Hammer, >1 gives Warhammer, so I'm covered if 3 is rolled >2 times).

How would you recommend as the best way to do this. 3 items are indicative, I'll probably be running drop tables of 1d100, wherein rare drops would be on a 99 or 100, and more common ones would have more slots

Trying to bake this into my game mechanics,
Thanks in advance,
StrykerL

Prevention of duplicate rolls and drop tables

7 years ago
That's somewhat tough. I'd say to make the check before rolling, and then roll according to what's still avaliable, since otherwise you may be rerolling multiple times.

Is there a reason duplicates are bad?

Prevention of duplicate rolls and drop tables

7 years ago

Yep, I'm allowing the player to reach various story 'quests' through their actions till that point. 

I'll use skills as an example

There are rare skills which can give unique story options. They're given out at a 1d100 chance, and you'd have to be really lucky to get em. However, once you've got them, it'd be senseless to find them again in a re-roll. Need a way to lock them out from the consideration set.

Preventing the roll beforehand sounds like a viable option, it'll prevent re-rolls in the first place, but then the challenge is how to dynamically inflate the probablities of the remaining options. Scripting will rely on flags again in this setup, I suppose

Prevention of duplicate rolls and drop tables

7 years ago
Could always just not roll. Create a list of them, randomize the list, then the order of that list is the order they find items in.

Probability and everything remains about the same, it's just on your end of things it's only randomized once.

Prevention of duplicate rolls and drop tables

7 years ago

Interesting, basically pre-generate seeded lists. I'll think about this

Prevention of duplicate rolls and drop tables

7 years ago
If you really wanted to do it this way, I suppose you could use true/false variables to check each time, but yes, it would take quite a bit of work. I could see it in an until loop, repeating until something not selected is selected, but ugh. The simplest way would be using an array, but I don't see a good way to slap that kind of code in a story here.

Prevention of duplicate rolls and drop tables

7 years ago
I had to do something like this to shuffle the deck in Cows vs. Aliens. It's a big script, but it won't break the system.

I can post the general idea later tonight maybe.