I've googled quite a bit and can't wrap my head around it. My goal is to have the probability of an item generated that is dependent on player score. How would I even begin this? Does anyone have experience with this in their game?
Edit: Apologies for the delay and being vague. I had a family emergency I tried to code through but just couldn't. I would like a max probability. I'll see if i can use LuminousNutria's code with what i already have and see if it works. I am currently spawning an object that is randomly picking an object amongst an array. I want the probability to be between an array of items. The probability is specific to whether one item spawns or another. So the higher score would be more likely to spawn a negative item. That said now it is equal between a good or a bad item meaning the baseline is a coin flip. I'd like to keep that the odds at a baseline that is even between the array of items but as the player gains points that changes.
Edit: 2
I've gotten further along. The following below works for a coin flip situation
randomize()
var rand_index = randi() % options.size()
if randi()%101+1 <= prob:
return options[1]
else:
return options[rand_index]
pass
In this example a case statement in which prob
is set to relative to the player's score will be simple enough in selecting between 2 items so far only good and bad. However using that logic for a player chest for instance in which a wide array of items can be selected. I'm not sure how to implement.