Just found a related topic but I have different/extended questions
I was wondering how the implement the drop system. I have to start designing the DB model for this so I was wondering whether what I am thinking is a good practice or not.
My game is like "City building" kind of browser based game (Flex/Flash app) with PHP and MySQL in the backend. In my game, like in any other games, there are chance based drop rate. I want to design the drop system such a way that I can easily configure
- What item(s) can be dropped from which game element
- What is the percent chance (probability) of getting a drop (a 100% meaning there will be some drop always)
- What percent chance of getting a specific drop. Here I define for each item (if can drop various items) what is the chace of drop, 90% to very frequent, 5% to very rare
I am wondering how the probability is determined? It might sound very noobish but just want to confirm does it mean roll a random number and compare with the odds we defined? If I am not wrong this is good for determining "how much to drop" but not for "what to drop"
Example: If we say drop 1-10 coins or 20-50 coins. I will simply call a random() function and generate a random numbed from the desired range.
Now for other example: Drop one of Bullets (95%), Empty Gun (4%), Loaded Gun (1%)
If I roll a random number range from 1-100 and compare with probability I defined
so, a number between 1-95 drops bullet, and a number between 96-99 drops empty gun and a loaded gun when it generates 100?
Is this how it has to be done? or is there a better way?
Update:
Removed 2nd question about hack safety