|
-
Who needs pants?
Percent Chance of something happening.
Hey guys/gals, just wondering the best way to make something happen at a percentage chance. I am currently making a game where their a few different areas where chance of things happening i want set as a percentage.
Ill give you an example of one instance. When a battle happens in the game if the user defeats the monster their is a chance that the monster drops certain items. eg there could be 5 different items he could drop and there are some rare items that theres a 5% chance of him dropping and their is a 54% chance of him droping another item and so on.
so
Item1 = 84%
Item2 = 32%
Item3 = 5%
Item4 = 43%
Item5 = 88%
What i was wondering is what would be the best way to calculate chance. I figured just produce a random number between 1 - 100 and then if its less then 54 get the normal item and if its less then 5 get the other item.
What i want to be able to do is set every item in the games rarity property to a number out of 100. And any character can drop any number of different items.
Just let me know if it doesnt make sense. I just figured there would be a way better way to go about it then what i was about to do.
-
Isn't it better to first calculate if a monster drops an item at all?
and if it does, make another calculation what kind of item it dropped.
So a 54% chance that it drops an item, -> then a 5% chance it drops a rare item -> then a calculation on what rare item it dropped
I know that treasure tables in my D&D Dungeon Master Guide work that way
-
Who needs pants?
Im not sure i understand, i dont mean all rare items have a 5% chance of being dropped. Each item will have its own percentage chance. Like this
http://community.dofus.com/game/encyclo-monster.php
check out the DROPS: section under the monsters description
-
you mean that he can drop several items?
But if he drops a 5% chance item he will also drop all other items?
Now I'm confused :s
-
Hmmm, in the example link you provided I think the idea is that the Game Master (or computer program) checks for each item individually.
So in that case your script would be something like
creature_array[["item1",5],["item2",32],["item3",43],["item4",83],];
for each item in creature_array{
if (Math.floor(Math.Random()*100) <= creature_array[i][1]) drop item
}
is that what you mean?
-
Senior Member
Maybe something like this:
*give each item a percent from 1 to 100
*pick randomly 1 item
*now generate random number between 0 and 100
*if random number is smaller then percent set for the picked item, drop it
*continue doing this for 5 steps
-
Who needs pants?
Sounds good that way atleast the monster will be able to drop more then one item. Thanks guys appretiate the help.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|