-
Percent Occurance?
I am making a game in which a character has to avoid danger by dodging attacks from enemies. When the player presses down, the character plays her hiding animation and is given a percent chance to dodge an attack. How do I make it so a bad guy has a 100% chance of hitting minus the players dodge %? Let me know if I need to make this a little clearer.
-
Re: Percent Occurance?
Here is one way to do it.
* upon pressing down
: set counter to random(100)
: play animation hiding
* upon beeing attacked
+ counter <= % chance to dodge
: dodge the attack
-
Re: Percent Occurance?
Well, I am not sure if this is what I want or not. I see that you have a counter that is >= to chance of dodge. That is what I want to find. Should I just give an alterable value to the bad guys that is randomized from 1-99 when they attack and if it is lower or equal to the dodge counter it misses? I want to know if that is a decent way to give a dodge rate. It would work, but I just don't know if this is a good enough way to express it.
-
Re: Percent Occurance?
That's pretty much what is in Popcorn's events. However, you may also want to put a modifier on the enemy characters as well depending on their chance of hitting in the first place.
-
Re: Percent Occurance?
OK.I Think I understand. Sort of. Here is what I am thinking of now. There are two characters: Player and Bad Guy.
Player has a dodge of 75 for whatever reason.
Bad guy has a hit of 80 because he is moderately accurate.
When the hit comes in contact with the player, should I do something like subtract 75 from 80 and mess with random numbers or just do what Popcorn was talking about?
-
Re: Percent Occurance?
It's possible to do it all in one formula, but it's probably easier to understand in stages...
I'd "roll" (pick a random number out of 100) for the enemy's chance to hit, and if the result of the random pick is below the enemy's hit %, then set a flag/indicate somehow that the player is about to be hit and move on to doing another random comparison against the player's "dodge" statistic to see whether the player should actually take damage or not.
-
Re: Percent Occurance?
Hm. I think this is what I'll do. A bad guy could always have a hit % Lower than or greater than 100. When the Good guy dodges, the Good Guy's dodge rating will be subtracted from the Enemy's hit rating. With the number that remains, there will be a random number generated. If this generated number is lower or equal to the remainder of the subtraction, the blow will connect.
I am open to other approaches.