Wondering if someone can give me some advice… I have several enemies in one level, when you kill those enemies there is the chance that they will drop 1 of 3 items… In an XML document I have a max limit to how many of each of those items they can drop per level… Then how would you make sure that the enemies randomly drop 1 of the 3 items but also make sure that the player has the chance to get the maximum amount of pickups per item?
For instance I have defined…
100 Max Coins, 1 Max Health Boost, 1 Max Speed Boost…
When you kill an enemy how can I randomly drop one of the three items above and also make sure that 100 Coins are dropped, 1 Health boos and 1 Speed boost are all dropped.
Right now I am using a hack job probability script:
[lua]local prob = math.random(4); – 25% chance;
if(prob == 4)then
local prob_item = math.random(3); – will choose 1,2,or 3
if(prob_item == 1)then
if(totalsofar < maxallowed)then
dropMoney();
end
elseif(prob_item == 2)then
if(totalsofar < maxallowed)then
dropHealth();
end
elseif(prob_item == 3)then
if(totalsofar < maxallowed)then
dropBoost();
end
end
end[/lua]
All that does is randomly drop an item 25% of the time and ensures that it enemies do not drop more than the max allowed amount… It doesn’t make sure that it drops the max number and randomly… [import]uid: 63800 topic_id: 21294 reply_id: 321294[/import]