# Miss Dodge Hit Calculation Problem

## 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 on other sites
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.

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 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 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 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 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 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 on other sites
Quote:
 Original post by vanegerI 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 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
DamageActual = Random( DamagePotential * DodgeRate, DamagePotential )

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

##### Share on other sites
Quote:
 Original post by Inmate2993In 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 on other sites
Well all this thread is going to be a pile of %Tohit formulas, thank you all very much, but I think we've solved that. Nevertheless I'd like another question to ask, when the Defender and Attacker are equal, what should their chances of success be %ToHit and %ToDodge? Currently it's a 50% for both. But I mean in reality, what is a chance for a Blind Guy to hit a Tree? Given no exact coordinates and just putting him in front of a tree would he really have a 50% chance to hit it? I know that this gives way to a lot of other factors (Sword length, arm length, etc.) But I tend to think that the guy's chance to hit should increase over time, that is, the guy who'll keep swingin on forever should hit the tree eventually. So since my attack sometimes has several hits, I think the %tohit chance should be modified by something like %TOHIT = %TOHIT + %HitsMissed. What do you guys think?

EDIT: Hmm.. Now I think I realised that it's a bit idiotic, because in combat none of the participants are Immobile and giving an attacker a higher chance to hit because he missed a few hits does not make much sense, well anyway, I'm waiting for someone else's opinion.

##### Share on other sites
There are ways of having something like that make sense. I would do it like this:
%base_hit * (5 + #misses since last hit)/5
And display the information on the screen as a "rage meter."

Alternatively, you could have a "fatigue" mechanic that does the opposite.

Note that these sorts of mechanics will lead to counterintuitive strategies. This may be a good thing or a bad thing.

##### Share on other sites
My game's text based :>

##### Share on other sites
The suggestion to cap the values comes mainly from the side of the attacker and as a benefit to them. In melee range, you shouldn't miss much. But if the values for the equation I gave aren't capped/floored then really high defense values or really high accuracy values will make missing 100% of the time possible and hitting 100% of the time possible.

Capping/flooring it would mean that you can't completely negate defense and accuracy of opposing players / foes.

Of course if a target has no defense, then a 100% hit chance is understandable with high enough accuracy.

In practice, with that equation capped at 95% chance to hit, you rarely get hit as the defender if you can have 45% defense.

The cap/floor may not even be an issue if you keep accuracy and defense values moderate. You could probably manage to keep it 80/20 in either direction.

Also if, as you said, range makes a difference to you ; just add some kind of range modifier to the basic equation.

Instead of (1+acc%) * (50-def%) add in a range factor like :

(1+acc) * ((50* (1+range mod)) - def)

have range mod be a % of the range, so if a ranged attack has a range of 10 feet and you are 1 foot away, you get a 90% bonus to your chance to hit (1.9 * 50 will mean you almost never miss)

That would make melee attacks far more accurate than ranged attacks, but also means a defender has very little in the way of safety in most cases.

##### Share on other sites
Well as far as if the attacker and defender are equal, then yes a 50% chance to hit is fine, if you add some defense debuffs or accuracy buffs to some attacks. This means that once a hit lands, more will start to land soon thereafter.

As for constant missing,just decide how many misses in a row are 'too many' and force the next hit to automatically land.

##### Share on other sites
Quote:
 Original post by snarles... 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.

This sentence is very important, many people do not even consider frustration in game making, it is one of the main reasons why people stop playing any game.
Critical hits would definitely be a better choice, I would completely avoid misses if possible and instead introduce glancing blows(50% damage or similar).
Only if you really need these events though.

Better still would be to try and use special charasteristics of weapons/units/items to make effective ranges and make those scale depending on the range. In a semi-complex game the end result is the same but the player may put the odds in their favor by playing their own way. A huge difference to just hoping to crit or not miss, or any defensive chance based event.

Example:

Ranged - 100m 200m 300m 400m 500m
Weapon Uzi: 100% 80% 60% 20% no reach
Weapon Ak47: 100% 100% 100% 100% 80%

Melee - 1m 2m 3m 4m 5m 6m
Weapon Sword 100% 100% no reach
Weapon Spear 0% 50% 100% 100% 100% no reach

Add in different shape,ammunition,alloys etc to somewhat change the ranges and characteristics. Weaknesses vs some alloys, thresholds of tolerance, breakpoints.. there are alot of variables to be considered, and are much more intuitive than a straight up % chance.
Minimize or eliminate the amount of and magnitude in the chance based events, such as crit, miss, dodge, parry. Nobody likes to roll the dice in games really if they could rather plan ahead and customize for themselves. There are other aspects of this but bottom line is what it is.
Chance based events should never be preferred IMO, IMHO very bad. Versatility and variety is key.

##### Share on other sites
Well my equations have again been reformed, now I'm using the exponent instead, now chances of success are something like this beetween even players:

Unarmed Attacker
~95% To Hit
~15% To Be Dodged
Melee(With something in hand, you can call it Armed, I guess.) Attacker
~85% To Hit
~20% To Be Dodged
Ranged Attacker
~60% To Hit
~10% To Be Dodged
I've tested this a few times and I rarely see a Dodge and almost no Misses this made battles a bit quicker,but currently their low-hp-newbie-cat-fights so they sort of have to be quick.
I've also taken in to account that although Ranged(Bow,Gun) attacks are harder to land they are also harder to dodge.

To ColeFreeman: I like the idea of 'effective range', but currently my combat system does not support any landscape, environment, thus making range values impossible, I cannot say I will not implement movement in combat, but currently it's picking out what to do(defend,evade,collide,use that,throw that, etc..) in the given situation, sort of thing.
Also I've already started thinking about something like Weapon Material vs Armor Material = Damage Effectiveness, currently though I have no Idea what alloys should be better/worse when opposed to others. Ideas like different techniques vs different armor also come to mind, like Sword-Slashing vs Metal Platemail < Hammer-Crushing vs Metal Platemail.

##### Share on other sites
When you think about it, there is only one difference between an attack string going "miss-miss-miss-miss-miss-killing blow hit" and "hit-hit-hit-hit-hit-monster dies". And the difference is that in the second example, player can actually feel/see the progress he is making in the battle - it's a hit, so it must mean the monster is down a few HP, which means the player is one step closer to a victory. If he keeps missing, the player feels he isn't making any progress - in fact, he's just waiting for that one decisive lucky roll.

That said, I still dislike having battles in which a player keeps hacking an enemy with a battleaxe, damaging him over and over again until the HP drops to 0. It's still very linear, and you can never fully ignore the fact that no humanoid is likely to (ever) get up after being hit by a battleaxe once.

What you could do (and I did :p) is implement a "concentration" category. There are no actual misses, attacks are parried and dodged by the defenders instead, and concentration level is used to determine the defender's ability to dodge and parry attacks.

Every single attack damages the defender's concentration - the defender dodges or parries the attack and suffers no physical damage, but his concentration drops. So the player still makes notable progress with every roll. As the defender's concentration drops, attacker's chances for landing a "critical" blow that physically damages the defender increase. One such blow with a heavy/blunt weapon would usually be enough to kill or disable an average human.

It allows you to balance the duration, fun factor -and- realism of the battle in a way that would be logical given the characteristics of combatants and their weapons, with rather simple base rules.

(You can decide yourself the rules for concentration damage, and if / how fast the concentration regenerates during battle. Both these things depend on the rest of your game's mechanics - character abilities, classes, skills and the like)

##### Share on other sites
That's an interesting idea. What you could do is let each unit have a "concentration" value starting at 100%. Attacks may have low hit rates like 20%, but if they miss, you subtract the attacker's base hit rate from the defender's concentration.
The hit formula would be:
%hit = attacker's %base_hit/(defender's %concentration * defender's %evasion)
Concentration resets to 100% whenever a unit takes damage.

What this system effectively does is replace "critical hits" with normal hits (which can be quite powerful, sometimes on the order of one-hit or two-hit kills depending on accuracy.) And even though most of your attacks will miss, the random factor is reduced because you can always get a guaranteed hit after multiple attacks.

It also encourages having a team with varying accuracies of attacks. For example a team with several 100% hit archers and one 10% hit axeman would not be very synergistic, since the archer would always reset the other units' concentration to 100%, making it hard for the axeman to hit. However, a team with a 100% hit archer, 30% hit spearman, a 40% hit horseman, some 20% hit swordsmen, and a 10% hit axeman could distribute their attacks to allow the axeman to hit frequently.

With this system it's also easy to implement special attacks that only reduce concentration, or that don't reduce concentration, or that modify your own units' concentration. For example a Mage might have an ability called "Charge" that costs 50% concentration, but that doubles the damage he deals the next turn. Soldiers might have a "Focus" ability that restores +10% concentration.

[Edited by - snarles on January 3, 2008 9:37:59 AM]

##### Share on other sites
The number crunching and formula tweaking is really a matter of personal preference. It's basically fine-tuning battles to get what -you- really want them to be like - more luck based, less luck based, longer, shorter, etc. and fit them into your setting.

What the feature essentially does is substitute the classic "healthbar" concept and its importance. Health is pretty much a last barrier between life and death - not a resource to be expended. Whereas concentration* takes over the role of determining advantage in battle.

It also adds another dimension to the otherwise linear battles. When the concentration reaches low levels, any next hit could be fatal - maybe it will happen next turn, maybe not for another 3 turns. It adds risk and tension in closely matched battles, while still being predictable enough and allowing the combatant to withdraw from a dangerous situation on time.

Finally, it reduces unnecessary abstraction and some rather absurd situations like having to hack at some poor creature over and over again, slowly reducing its health, or rely on pure luck to hit a critical.

* - come to think of it, "concentration" might not be the best name for this. "Fatigue" or "Guard" might be more suitable, but english isn't my first language so I'm not sure which term describes it the best.

##### Share on other sites
If "concentration" is going to replace health, it should probably conform to our usual expectations of HP. Make it DP - defense points - and it should be pretty self-explanatory to any RPG player.

My current game is just a text prototype, so my DP is reliant only on level and "burden", which is currently just the weight of worn armor. In this case, a highly-skilled ninja wearing an infiltration costume would have huge DP, but takes full damage from any direct hit. A fully-armored knight has poor DP, but can resist lighter weapons through his armor. However, he is too slow (too low DP) to avoid any attacks, meaning a weapon with high armor penetration (like a warhammer) is bad news for him.

The trouble here is that I've already got HP, MP and SP (stamina points), and an additional DP meter sounds like a bit much. You could roll DP and SP into the same meter, but that would make your normally-skilled defenders (like the ninja) incredibly vulnerable if they use SP/DP for anything like running, attacking, etc.

If you're fine with four meters, it's a good way to go, but I haven't figured out a way to simplify it.

##### Share on other sites
For the sake of realism I could rename HP to DP/AP or whatever, but that won't make much of a difference, for some more dramatic changes i would have to refine the combat system which is already sort of complicated, it's not simply:

Wolf's Turn - He chooses Hit.

Although the concentration points or whatever seem to add more strategic thinking, there is a lot of development ahead of me, and for the things I have in store, tactics are enough.

Again I would ask of someone about the Material vs Material system.
Like Steel-Dagger would be less effective on a Metal-Plate than on an Alluminum-Plate(then again what weapon wouldn't..) these are 100% guesess, I have no knowledge about metallurgy...

##### Share on other sites
If realism isnt needed, I'd just make up your own metals and retrofit them into a system where A beats B , B beats C and C beats A. Each metal would beat one thing and lose to one thing.

One thing I'd look into however is how plate / chain mails handle different types of attack, such as slicing, smashing and piercing.

##### Share on other sites

Quote:
 Original post by templewulfThe trouble here is that I've already got HP, MP and SP (stamina points), and an additional DP meter sounds like a bit much. You could roll DP and SP into the same meter, but that would make your normally-skilled defenders (like the ninja) incredibly vulnerable if they use SP/DP for anything like running, attacking, etc.If you're fine with four meters, it's a good way to go, but I haven't figured out a way to simplify it.

Do your characters really need both an SP and an MP meter? Perhaps you could have magic classes only have MP, and warriors SP, and a few exceptions (like heroes/bosses) have both MP and SP.

##### Share on other sites
Hahahaha... No big deal snarles, I too have both HP/MP and SP. The reason why I seperate them is that in my game there are no walls between so called magic and melee characters, a player can take both Fire-Magic expertise as well as Unarmed-Combat, thus why he needs a bit of MP and a bit of SP, I do use SP for common tasks like attacking,defending,etc. why? so that battles don't go endless, when their stamina is down, their down.

## Create an account

Register a new account

• ### Forum Statistics

• Total Topics
628346
• Total Posts
2982203

• 10
• 9
• 24
• 11
• 9