Jump to content
  • Advertisement
Sign in to follow this  
Kuraido

Miss Dodge Hit Calculation Problem

This topic is 3975 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

So I've been using this kind of system for my Miss or Dodge or Hit calculations: You take the perception of the attacker and the agility of the target, sum them up and then divide each of them from the sum to deliver the chance, example: ATK PER: 20 TAR AGI: 11 TOTAL: 31 Success of attacker: 20/31 = 0.64 = 64% Success of defender: 11/31 = 0.35 = 35% After the calculations the mechanic goes in this order: 1.Miss Calculation: If Random(1,100) > 64% Outcome: Miss If Random(1,100) < 64% Outcome: Attack proceeds. 2.Dodge Calculation: If Random(1,100) < 35% Outcome: Dodge if Random(1,100) > 35% Outcome: Attack hits the target. Now as you can see, even though the defender has the lower score(AGI) he still has more chances to succeed. Because for the attack to actually land it has to succeed in 2 steps(Didn't missed? Wasn't Dodged?) and for the attack to fail it merely has to fail in one(Dodged! Missed!). First of all I'm asking for your opinion wether you would like this sort of "difficult" setting or not? Would you like to miss all the time instead of your hit slashing the dude's head off? Second of all IF NOT, could you suggest a way of tweaking this thing a little? I tried to divide the target's AGI before the calculation by 4, because the chance of landing an attack is (4:1) and that ofcourse turned out to attacker hitting the target more often than missing. Maybe all of these calculations make no sense at all, but I cannot currently come up with a new formula, so I'm asking for a little help from people who are good at maths.

Share this post


Link to post
Share on other sites
Advertisement
I make a specific suggestion for your problem lower down, here is some general advice about making a combat system:

Whenever I construct a combat system (I've made a few) the first thing I do is make a python script that represents it. I use the script to plot a graph (it may have several dimensions) that represents what the probabilities of the outcomes are for all the possible combinations of inputs. Then I say, do I like how this looks? will strong defenders be too powerful? will strong attackers be too powerful?

I sometimes also compute average DPS and compare that to expected health values so I have an idea how long any particular fight will last & what the outcomes will be.

Now about your example:

Make some places to tweak, right now you have something like this:

A = attacker's perception
G = defender's agility

chance to hit

c = (A/(A+G))*(1-(G/(A+G)))

you may not have noticed, but 1-(G/(A+G)) == (A/(A+G)) so your equation is actually

c = (A/(A+G))^2

Fair nuff, this is only relevant if there is no functional difference between the attacker missing and the defender dodging (you haven't told us). But it also brings to light an excellent tool, the exponent, I suggest you play with the exponent to see what sorts of results you get, if you make it larger than one, then it is harder for the attacker to hit, if you make it smaller than 1 (but not smaller than zero) it is easier for the attacker to hit.

Consider this

Attack Bias: B = 0.5 easy to hit
Dodge Bias: D = 1.5 hard to dodge

then using something like this:

c = (A/(A+G))^B * (1-(G/(A+G)))^D

then play with B and D and plot the graphs so that you get outcome probabilities you like.

Share this post


Link to post
Share on other sites
Personally, I think it would be annoying to have such high miss rates (you cited a 64% chance just to *not miss*). For an occasional high-risk high-reward "desperation" type attack, such an unreliable accuracy might be okay, but if every other attack in the game misses, it's a different story. It makes the battles more dependent on chance, and makes them longer. But it depends on what you are shooting for. If you want a game that is deeply strategic, it would be best to minimize the role of luck by having higher hit rates. Notice that games like Chess or Starcraft don't involve hitting/missing at all, while Final Fantasy tactics generally has hit rates at 75-90%. Strategy usually involves thinking a few moves ahead, and you can't do that unless you can count on your attacks to actually hit. But if you want more of a fun and unpredictable game, you might want to set it up so nobody really knows when an attack is going to land. Still, I would rather use "critical hits" to increase the luck factor in games, as missing lots of attacks simply leads to frustration for the player.

That aside, I think the system you have is fine with proper tweaking. Some modifications could be to not have both a "miss" and a "dodge" roll and just combine them, with something like this:
%miss = ((enemy agility)/(your perception+enemy agility))^2
Note that using this system, evenly matched units will have a 75% chance of hitting each other, as opposed to the 25% chance that would result from your system.

[Edited by - snarles on December 30, 2007 5:09:33 PM]

Share this post


Link to post
Share on other sites
Thank you very much both of you for the replies.

I've did just as Symphonic proposed and made a process which calculates the amount of Misses/Dodges and Hits with the given formula, gave it a queue of 1000000 and the outcome of equally challlenged opponents(10 AGI, 10 PER) was ~51% Success and ~49% Fail. Pretty fair IMHO. I've didn't actually tweaked much. I just multiplied the AGI of attacked by 0.405 and this seeemed to yeld in balance. Now this is my problem: I've made the balance and the combat seemes to flow in quite a reasonable way, but I doubt that my formula makes any sense with the AGI*0.405 screwing. I like the formulas you proposed and they seem to make much more sense to me, but I care most about equallity and fairness(whereas 75%Hit 25%Miss Equation does not seem to be fair enough).Taken Final fantasy in to account it's a very easy game(higher chance to hit mentioned above) and mine is not though I agree that it makes the game interesting none the less(FF).

I think I must have mentioned that an attack has several hits and the output of the attack is something like this:
Wolf bites Bear (Dodge!) (Miss!) (52) (52 total!)
As you cann see this attack had 3 hits, one of the missed and one was dodged, 52 damage was dealt.

Share this post


Link to post
Share on other sites
Ah! I expected as much, given the low probabilities you were happy with it makes sense to strike multiple times in an attack.

Don't worry about using a coefficient instead of an exponent, this is also a perfectly good method!

Right now you have formulated it like this (If I have correctly understood):

gx = 0.405 (agility scale)

A = Attacker Perception
G = Defender Agility * gx

c = (A/(A+G)) * (1-(G/(A+G)))

And that's fine too, once again you're making it more complicated than it needs to be, unless you're going to exponentiate the terms separately, you might as well use this:

c = (A/(A+G))^2

As a separate note, if you're happy with A=10 and G=10, don't forget to check A=100 and G=100, to make sure your hit chances scale in a way that you like.

Don't worry about having to tweak coefficients and exponents to get a hit chance that you like, mess with it! it's your game :)

Share this post


Link to post
Share on other sites
I prefer to use something close to this :

Net chance to hit = (1 + Accuracy%) * (50 - Defense%) .

with no additional accuracy or defense involved the basic chance to hit is 50%. Chance to hit should likely be capped at 95% and floored at 5%. You can calculate accuracy and defense %s any way you like.

Share this post


Link to post
Share on other sites
Okay then, thanks Symphonic for the encouragment, I'll keep this mechanic for a while and later on check if it fits the game system. And to the post above, I really hate to Ground or Floor values, again, it disbalances the system from my view of point if a player with an rpg stands in front of a 1 square km solid brick wall why should he have a 5% chance to miss? Really that makes no sense all, nevertheless, thank you for the reply.

Share this post


Link to post
Share on other sites
Quote:
Original post by vaneger
I prefer to use something close to this :

Net chance to hit = (1 + Accuracy%) * (50 - Defense%) .

with no additional accuracy or defense involved the basic chance to hit is 50%. Chance to hit should likely be capped at 95% and floored at 5%. You can calculate accuracy and defense %s any way you like.


I object to the cap, but not for the reason Kuraido gives. If the cap is close to 100%, then when I reach the cap I read it as "100%". I feel cheated when I miss. It's even worse when the probability is normally that high, because you come to expect hits. I think it's best for the chance to hit to normally be around, say, 80%. This way, misses are common enough that you realize you have to plan for them, but not so common as to make it feel like a crapshoot. It also makes caps less necessary (and less noticeable when they exist) because you're not hitting the cap as often.

Share this post


Link to post
Share on other sites
An alternative idea might be to use that Hit% and Evade% as a damage reduction factor. Since HP is regarded as an abstract meter, with every Hit Point representing an ability to deflect a blow from being fatal (with the last HP being the end of that ability). What this means is that every attack would be considered a guaranteed hit, but using Hit and Evade values to determine where the floor parameter of the randomize-damage function lies. (The Offense-Defense values determining the ceiling).

My version of this calculation would be something like this.

DamagePotential = AttackerOffense - VictimDefense
DodgeRate = VictimEvade / AttackerHit
DamageActual = Random( DamagePotential * DodgeRate, DamagePotential )

In practice, this formula would probably need a lot of tweaking.

Share this post


Link to post
Share on other sites
Quote:
Original post by Inmate2993
In practice, this formula would probably need a lot of tweaking.


I like your idea, it is a very elegant rethinking of the entire combat paradigm. I would call it stamina though, so when attacking and being attacked you expend stamina to succeed. With low stamina you run the risk of being actually wounded, this allows for more glorious wounding mechanics like having arms chopped off and legs made unusable.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!