Home » MODDING HQ 1.13 » v1.13 Modding, Customising, Editing » v1.13 Time Capsule (How-to Library) » "How does it work?" Part 5: Melee Combat Chance-to-Hit
"How does it work?" Part 5: Melee Combat Chance-to-Hit[message #196206] Wed, 10 September 2008 20:54 Go to next message
Headrock

 
Messages:1760
Registered:March 2006
Location: Jerusalem
It is recommended to read "Part 4: Chance-to-Hit" before reading this article, but not required.

----------------------------------------

The Melee Chance-To-Hit formula is responsible for calculating an attacker's chance in melee combat. All melee combat takes place in close proximity, meaning a range of just one tile. Therefore, range doesn't come into play here, and neither does worn equipment. It's mostly a battle of physical prowess and skills between the attacker and the defender.

Note that the Melee Chance-to-Hit formula (M-CTH, for short) handles unarmed combat, blunt weapons, knives, as well as, believe it or not, STEALING! There will be various points in the formula where a calculation will only take place for one of these modes, or in a different way for each mode.

Melee combat relies on two separate sets of calculations - the Attacker's abilities, versus the Defender's abilities. After calculating both values, they will be compared to determine the final chance to hit.

----------------------------------------

The calculation starts out with a simple check to see if the target can even possibly evade the hit.

If Target's Life is less than 15, or Target's Stamina is less than 10, and we're not using BugQueen's Tentacles, then
   Chance-to-Hit = 100! A sure hit. Stop the formula here.


If the target's in bad shape, or passed out, it doesn't even stand a chance. The attack is a sure hit. Also note that for some reason, this doesn't apply to the bug queen's tentacles. Hmmm.

----------------------------------------

We begin with the attacker's ability check. Throughout this part, we will be modifying a value called "Attacker_Chance". If we're attacking, we want to end up with as high a value as possible here.

As with the CTH for guns, this formula is also going to begin by assessing the attacker's numeric abilities.

If we're stealing, then
   Attacker_Chance = Attacker's_Effective_Dexterity + Attacker's_Effective_Agility + (3 * Attacker's_Strength) + (10 * Attacker's_Effective_Level)

Else (Armed and Unarmed combat)
   Attacker_Chance = (3 * Attacker's_Effective_Dexterity) + Attacker's_Effective_Agility + Attacker's_Strength + (10 * Attacker's_Effective_Level )


Basically, all of the attacker's relevant skills are added up, plus ten times the attacker's experience level. When stealing, strength is 3 times as important. When fighting, Dexterity is three times as important. We're not looking for damage, just chance to succeed, so strength doesn't play a very important role in combat, but in stealing it determines how likely you are to be able to wrest a piece of equipment from your enemy's hand, I guess.

The word "Effective" here means that we're not looking at the character's skills as we see them in his profile, they are actually mitigated by the character's Drunkness level. As explained in the Gun CTH article, drunkness goes from 0 (sober) to 3 (drunk as a bat), with 4 being hung-over. Extreme Drunkness (drunkness level 3) will remove 50% of the actual skill. Effective Experience Level also takes into account Claustrophobic characters - when these characters are underground, they suffer -1 to their experience level. Effective_Agility based both on drunkness level and on the amount of weight you are carrying.

Also note that strength is unmodified - the value used is the real value which can be seen in the character's profile.

Attacker_Chance is divided by 6


This is sort of like averaging out the skills we've just added up. We want to end up with a number between 1 and 100.

-----------------------------------

If attacker has the PSYCHO trait, then
   Attacker_Chance is increased by 15


Psychos get a flat bonus to their attack chance. Very nice.

-----------------------------------

Attacker_Chance is increased by Morale_Modifier


The morale modifier is based on the attacker's current morale. At around 50-54 morale ("stable" morale) the modifier equals 0. At 55 morale, we get +1 morale modifier, and +1 every 10 points of morale over that, for a maximum of +5. We get -1 morale modifier for about every 2-3 points below 50, for a maximum of -20.

-----------------------------------

Fatigue_Modifier = Attacker_Chance * Breath_Penalty  / 100 / 2
Attacker_Chance is reduced by Fatigue_Modifier


Breath_Penalty here depends on the character's current stamina, and it works in stages as we've seen some things do before:

At 85 or above, Breath_Penalty is 0
At 70-84, Breath_Penalty is 10
At 50-69, Breath_Penalty is 25
At 30-49, Breath_Penalty is 50
At 15-29, Breath_Penalty is 75
At 14 or less, Breath_Penatly is 90

When we figure this into the formula above, we see that we can't lose more than 45% of our Attacker_Chance, and that's only if we're about to pass out. Normally, we'd only lose about 5% of our Attacker_Chance due to fatigue. With Melee Combat and stealing, fatigue will influence the final chance again later in the formula.

-----------------------------------

If we've spent some AP on extra aiming, then
   Aiming_Bonus = 10 * APs_spent_on_Aiming / 2
   Attacker_Chance is increased by Aiming_Bonus


Much much simpler than the Aiming_Bonus calculation with guns, here we get exactly 5 points to our CTH for each AP we spent on extra aiming.

-----------------------------------

If Shooter is an NPC (computer-controlled character), then
   If difficulty_level is EASY, then
      Actual_Chance is reduced by 5.
   If difficulty_level is EXPERT, then
      Actual_Chance is increased by 5.
   If difficulty_level is INSANE, then
      Actual_Chance is increased by 10.


Like with guns, a computer-controlled character also gets either a bonus or a penalty, depending on the difficulty level. At "EXPERIENCED" level, we get neither.

-----------------------------------

If attacker is affected by gas, then
   Attacker_Chance is reduced by 50!


Being "gassed" means you suffered some damage from gas this turn. The "gassed" attribute will only pass at the start of the next turn, so putting on a gas mask or stepping out of the cloud AFTER being hit by the gas won't help, until the next turn starts.

-----------------------------------

If Attacker is being bandaged by another soldier, then
   Attacker_Chance is reduced by 20


But seriously, how often does a character get to stab someone while he's being bandaged? Smile

-----------------------------------

If attacker is in shock, then
   Attacker_Chance is reduced by 5 points per level of shock


Shock happens when a character is wounded. It equals about 10% of the damage taken. Each turn, shock is cut by half and rounded down, so eventually it goes away. But CTH suffers bigtime immediately after any injury.

-----------------------------------

If Attacker_Chance is still more than 0, and Attacker is Injured or Bandaged, then
   Bandage_Value = Amount of Attacker's health that is currently bandaged (pink)
   Injury_Penalty = Attacker_Chance * 2 * ( Attacker's_Health_Below_Maximum + (Bandage_Value / 2) ) / (Attacker's_Maximum_Health * 3)
   Attacker_Chance is reduced by Injury_Penalty


This is a complex formula that I'm not going to explain, but just like with the gun CTH calculation, injury is going to decrease the attacker's Chance-to-Hit. Bandaged wounds only half half the effect of bleeding wounds. Unlike the Gun CTH formula, we don't get a compensation from the attacker's Effective_Level.

--------------------------------------

For some strange reason, fatigue takes effect yet again:

If Attacker's Breath is less than 100%, then
   Fatigue_Penalty = (Attacker_Chance * (100 - Attacker's_Breath)) / 200;
   Attacker_Chance is reduced by Fatigue_Penalty


So basically, we get a 1 point penalty for every 2 points of breath less than the maximum. It's odd because we've already taken fatigue into account at the top of the formula.

--------------------------------------

Lastly, we're going to see how the various Melee-Combat skills can help the attacker's Chance-to-Hit.

If Attacker is using a Knife, then
   If Attacker has the KNIFING skill, then
      Attacker_Chance is increased by 30 points for each level of the KNIFING skill!


That's quite some bonus, especially because it isn't mitigated by anything else, as it comes in the last portion of the calculation. 60 points for an expert of knifing!

If Attacker is Unarmed or using a punch-weapon (like Crowbar, brass knuckles), or is trying to steal, then
   If Attacker has the MARTIAL_ARTS skill, then
      Attacker_Chance is increased by 30 points per level of the MARTIAL_ARTS skill!
   If Attacker has the HAND-TO-HAND skill, then
      Attacker_Chance is increased by 15 points per level of the HAND-TO-HAND skill!


Again, great bonuses for skilled attackers. An expert Martial Artist gets a whole lot of CTH bonus here.

-------------------------------------

If Attacker_Chance < 1, then
   Attacker_Chance = 1


And so we're done with the Attacker_Chance, which is now put aside and saved for later.

-------------------------------------

Now, we're going to calculate the abilities of the defender. Later we'll compare the two, and see if the attack succeeded or not.

The majority of the Defenser_Chance calculation is exactly the same as the Attacker_Chance, with several differences:

  • Agility is more important for the defender than dexterity. When defending against an attack, Agility is multiplied by three, instead of Dexterity. Against stealing attempts, the attacker and defender both use the same formula (strength * 3, all others normal).
  • The PSYCHO trait doesn't help the defender.
  • Beyond the second fatigue modifier, the Defender_Chance calculation is a bit more complicated, but not much more.


Let's look at the defender's calculations after the second fatigue modifier has been computed.

-------------------------------------

If Attacker is using Bug Queen Tentacles, and the Defender is either an Infant_Creature or Larvae_Creature, then
   Defender_Chance is increased by 10000


In other words, if the Queen is attacking one of its babies for some reason, the attack will always be dodged. I guess the JA2 programmers figured they should put some "motherly love" in there Smile

-------------------------------------

If Defender is CROUCHED or PRONE, then
   If attacker is the Bug Queen, then
      If Defender is PRONE, then
         Defender_Chance is increased by 1000
      If Defender is CROUCHED, then
         Defender_Chance is increased by 40


The Bug Queen finds it hard to attack anyone who is lying prone or crouched. If the target is prone, the Bug Queen can't hit him. If he's crouched, he gets a 40 point bonus, making him harder to hit. Of course, the Queen can always spit at you, which probably means that crawling towards her is a bad idea. But I bet someone will figure out how to exploit this little bit of knowledge Smile

If Defender is CROUCHED of PRONE, then
   If attacker is NOT the Bug Queen, then
      If Defender is CROUCHED, then
         Defender_Chance is reduced by 20
      If Defender is PRONE, then
         Defender_Chance is reduced by 40


When the attacker isn't the bug queen, the defender suffers from being prone or crouched. It is much harder to dodge in these stances, so the defender loses some of his ability to dodge the blow.

--------------------------------------

And here is the skill check for the Defender's Special Skills. Note that it is a bit more complicated than the attacker's skill check.

If Attacker is using a Knife, then
   If Defender is also holding a Knife, then
      If Defender has the KNIFING skill, then
         Defender_Chance is increased by 30 for each level of the KNIFING skill
      If Defender has the MARTIAL ARTS skill, then
         Defender_Chance is increased by 10 for each level of the MARTIAL ARTS skill
   else (if Defender is not holding a knife)
      If Defender has the KNIFING skill, then
         Defender_Chance is increased by 10 for each level of the KNIFING skill
      If Defender has the MARTIAL ARTS skill, then
         Defender_Chance is increased by 15 for each level of the MARTIAL ARTS skill


You can see that in the case of the defender, it's important to know what he is holding in his hand. If he has the KNIFING skill, he is better off holding a knife in his hand, as he receives 3 times more chance to parry the attack. A martial artist can also work well with a knife in his hand, but will get a better chance when unarmed.

If Attacker is Unarmed or using a Blunt Weapon, then
   If Defender is holding a knife, then
      Defender_Chance is increased by 15 for each level of the KNIFING skill


A knifing expert can defend well against unarmed and blunt attacks too. Not against stealing attempts, though.

If Attacker is Unarmed, using a Blunt Weapon, or Stealing, then
   If Defender is unarmed, then
      If Defender has the MARTIAL ARTS skill, then
         Defender_Chance is increased by 30 for each level of the MARTIAL ARTS skill
      If Defender has the HAND-TO-HAND skill, then
         Defender_Chance is increased by 15 for each level of the HAND-TO-HAND skill


Martial Arts and Hand-to-Hand skills help, but only if both combatants are unarmed. They also help when stealing. Note that Martial Arts is far more helpful than Hand-to-Hand when defending. When attacking, the Hand-to-Hand skill is a bit more useful because it causes 3 times as much damage...

-------------------------------------

If Defender_Chance < 1, then
   Defender_Chance = 1


And we're done! We now have two values, the Attacker_Chance and the Defender_Chance. Now, we're going to compare the two values and find out whether the attack has been successfully dodged.

-------------------------------------

If Attacker is trying to steal, then
   Actual_Chance = 50 * Attacker_Chance / Defender_Chance


Easy. For a 100% (ok, 99%) chance to steal, the attacker has to be twice as good as the defender. If both are matched, the chance is 50%. If the defender is FIFTY times as good as the attacker, the chance is 1%. So stealing isn't very hard to do, really.

If Attacker is stabbing or punching, then
   Actual_Chance = ((Attacker_Chance - Defender_Chance) / 3) + 67
   If Attacker is aiming at the Defender's Head, then
      Actual_Chance is reduced by 20


When it's an actual attack, instead of a ratio between the Attacker_Chance and Defender_Chance, we look at the difference between them. We divide that difference by 3 and add 67. If the defender_Chance is higher than the Attacker_Chance, then obviously we're going to get less than 67% chance-to-hit. If Attacker_Chance is higher than Defender_Chance, we'll get more than 67% chance-to-hit. Aiming at the head will reduce CTH by 20 points.

---------------------------------------

Finally, the program makes sure that CTH never drops below 1% and never rises above 99%, so there are never sure hits and never sure misses.




[*]Agility, Desxterity, Strength, and Experience Level


    For actual attacks, Dexterity is three times more important than the others. For stealing attempts, Strength is three times more important.

[*]Psycho trait


    Always useful

[*]Good morale


    Always useful

{*]Extra Aiming APs


    Always useful

[*]KNIFING skill


    Very helpful when attacking with a knife.

[*]HAND-TO-HAND and MARTIAL-ARTS skill


    Very helpful when attacking unarmed, with blunt weapons, or when stealing. Martial Arts is twice as effective as Hand-to-Hand.
[/list]


Things that help our chance to dodge


  • Agility, Desxterity, Strength, and Experience Level


      For defending against actual attacks, Agility is three times more important than the others. For stealing attempts, Strength is three times more important.
  • Good morale


      Always useful
  • EASY difficulty level


      Makes the enemy less likely to hit you.
  • KNIFING skill


      Very helpful when being attacked with a knife, and even more helpful if you're holding a knife yourself. Also helpful against unarmed and blunt-weapon attacks, if you're holding a knife. Not helpful against stealing.
  • MARTIAL-ARTS skill


      Helpful when being attacked with a knife, and even moreso if you're NOT holding a knife. Much more helpful against unarmed, blunt, and stealing attacks.
  • HAND-TO-HAND skill


      Helpful against unarmed, blunt, and stealing attacks, but only when not holding a knife.


Things that hurt our CTH when attacking


  • Drunkness


      Reduces our skill levels.
  • Lots of weight


      Hinders us a little.
  • Claustrophobic episode while underground


      Hinders us a little.
  • Low morale


      Always harmful.
  • Injury


      Always harmful. Bandaged damage is half as harmful as bleeding damage.
  • Low stamina (fatigue)


      Always very harmful.
  • Being "Gassed"


      Always very harmful.
  • Being bandaged


      Always harmful. Is it even possible to attack anyone while being bandaged? Doesn't it stop the bandaging process?
  • Shock


      The more damage you've recently received, the worse your shock will be. Shock passes with time.


<font size="]Things that hurt our chance to dodge



  • Drunkness


      Reduces our skill levels.
  • Lots of weight


      Hinders us greatly when defending against an actual attack. Les hurtful against stealing attempts.
  • Claustrophobic episode while underground


      Hinders us a little.
  • Low morale


      Always harmful.
  • Injury


      Always harmful. Bandaged damage is half as harmful as bleeding damage.
  • Low stamina (fatigue)


      Always very harmful. If it's low enough, you may not even get a chance to defend at all.
  • Being "Gassed"


      Always very harmful.
  • Being bandaged


      Always harmful. Is it even possible to attack anyone while being bandaged? Doesn't it stop the bandaging process?
  • Shock


      The more damage you've recently received, the worse your shock will be. Shock passes with time.
  • EXPERT or INSANE difficulty levels


      Makes the enemy more likely to hit you.


[Updated on: Mon, 27 April 2015 23:43] by Moderator

Report message to a moderator

Sergeant Major

Re: "How does it work?" Part 5: Melee Combat Chance-to-Hit[message #196207] Wed, 10 September 2008 21:29 Go to previous messageGo to next message
w0dka is currently offline w0dka

 
Messages:15
Registered:June 2007
Thank you. Well done Smile
Martial Arts helps stealing... mhm thats bad news for me.

But is their really no difference with aiming at neck/torso/legs?

Report message to a moderator

Private
Re: "How does it work?" Part 5: Melee Combat Chance-to-Hit[message #196213] Wed, 10 September 2008 23:19 Go to previous messageGo to next message
Headrock

 
Messages:1760
Registered:March 2006
Location: Jerusalem
Quote:
Martial Arts helps stealing... mhm thats bad news for me.


Why?

Quote:
But is their really no difference with aiming at neck/torso/legs?


Aiming at the neck ("head") gives -20 to chance-to-hit. I assume that damage is also affected in some way or another. I'll have a look at that and let you know what I find.

Report message to a moderator

Sergeant Major

Re: "How does it work?" Part 5: Melee Combat Chance-to-Hit[message #196214] Wed, 10 September 2008 23:25 Go to previous messageGo to next message
Headrock

 
Messages:1760
Registered:March 2006
Location: Jerusalem
If I understand correctly, then head damage is 50% more powerful than torso damage. However, leg damage is 75% less powerful than torso damage. I'm not sure you can attack the legs in melee combat (never tried it). In any case, critical hits are impossible.

Report message to a moderator

Sergeant Major

Re: "How does it work?" Part 5: Melee Combat Chance-to-Hit[message #196218] Thu, 11 September 2008 00:24 Go to previous messageGo to next message
w0dka is currently offline w0dka

 
Messages:15
Registered:June 2007
Headrock
Why?

'cause I usually take knifing. I like the big bodytype *g* And with the muscular one you can't take marital arts. There's nothing better then cutting throught a elite with 3 knifehits who survived 12 armorpiercing rounds in the previos save.

Report message to a moderator

Private
Re: "How does it work?" Part 5: Melee Combat Chance-to-Hit[message #196219] Thu, 11 September 2008 00:42 Go to previous messageGo to next message
Headrock

 
Messages:1760
Registered:March 2006
Location: Jerusalem
Yeah that's what happens due to knives being able to ignore armor... I don't like it.

Report message to a moderator

Sergeant Major

Re: "How does it work?" Part 5: Melee Combat Chance-to-Hit[message #196223] Thu, 11 September 2008 05:05 Go to previous messageGo to next message
Action is currently offline Action

 
Messages:11
Registered:February 2001
So does this mean that a merc with hand to hand or martial arts is always better off using a blunt weapon than bare fists?

Report message to a moderator

Private
Re: "How does it work?" Part 5: Melee Combat Chance-to-Hit[message #196228] Thu, 11 September 2008 06:33 Go to previous messageGo to next message
Headrock

 
Messages:1760
Registered:March 2006
Location: Jerusalem
No, why?

Report message to a moderator

Sergeant Major

Re: "How does it work?" Part 5: Melee Combat Chance-to-Hit[message #196994] Tue, 23 September 2008 07:39 Go to previous messageGo to next message
Hitcher is currently offline Hitcher

 
Messages:12
Registered:January 2000
Location: Vienna, Austria
Quote:
If Attacker is Unarmed or using a punch-weapon (like Crowbar, brass knuckles), or is trying to steal, then
If Attacker has the MARTIAL_ARTS skill, then
Attacker_Chance is increased by 30 points per level of the MARTIAL_ARTS skill!
If Attacker has the HAND-TO-HAND skill, then
Attacker_Chance is increased by 15 points per level of the HAND-TO-HAND skill!


Wait a moment. I thought punch weapons only benefit from HtH, not MA. Was that a wrong assumption on my part, or have you changed that in 1.13? Or am I mixing it up with the damage bonus? (I. e. punch weapons only receive a damage bonus from HtH, not MA?)

Report message to a moderator

Private
Re: "How does it work?" Part 5: Melee Combat Chance-to-Hit[message #197000] Tue, 23 September 2008 09:10 Go to previous messageGo to next message
Headrock

 
Messages:1760
Registered:March 2006
Location: Jerusalem
Option #2. Wink Only damage is affected. For Chance-to-Hit calculations, they both benefit.

Report message to a moderator

Sergeant Major

Re: "How does it work?" Part 5: Melee Combat Chance-to-Hit[message #197134] Wed, 24 September 2008 07:47 Go to previous messageGo to next message
threewings is currently offline threewings

 
Messages:16
Registered:September 2006
Location: Hong Kong
Dear Headrock, I would like to know how our mercs' stamina being deducted when receiving damage? It seems we suffer a larger degree of stamina loss comparing to AI for the same hit.

Most of time my merc is heavily armored so even being hit by bursts won't be life threatening but soon passed out due to stamina depletion. Lay there and let the enemy shot to dead...

However the enemy seems tough(especially black shirts)enough to withstand several direct hits without any "shaking"...how strong. They are hard to knock out and with getup right the next turn.

threewings

**************************
BTW May I suggest the next essay topic would be the "combat behavior of militia and enemy?" I always wonder how do they make decision during the battle.

Why some will charge fearlessly and some will not?
Why does not shoot enemy directly but picking up my rifles from the ground...? (with full attachments...OMG)
Why one single enemy can always try to hide correctly at a single tile which is unseen among all visable areas?
And so...
Great thanks for wrting those good works to us. :bluecool:

[Updated on: Wed, 24 September 2008 08:03] by Moderator

Report message to a moderator

Private
Re: "How does it work?" Part 5: Melee Combat Chance-to-Hit[message #197156] Wed, 24 September 2008 13:23 Go to previous messageGo to next message
Headrock

 
Messages:1760
Registered:March 2006
Location: Jerusalem
Quote:
I would like to know how our mercs' stamina being deducted when receiving damage? It seems we suffer a larger degree of stamina loss comparing to AI for the same hit.


Stamina loss is a very hard thing to gauge, for two reasons:

A) There's a variable in the calculation that is very vague, something called "BreathRed", and I just don't understand how it works.
B) The main factor in the calculation is damage, which is handled several times in different ways and different places before it is actually deducated from your stamina. Therefore, explaining the end result could be extremely complicated.

I might end up doing it some day, but I fear it's more complicated than I want to handle right now.

Quote:
BTW May I suggest the next essay topic would be the "combat behavior of militia and enemy?"


You may. But AI analysis is going to be much more difficult than what I've been doing so far. So don't hold your breath... Sorry.

Report message to a moderator

Sergeant Major

Re: "How does it work?" Part 5: Melee Combat Chance-to-Hit[message #197175] Wed, 24 September 2008 17:16 Go to previous messageGo to next message
Starwalker is currently offline Starwalker

 
Messages:759
Registered:October 2005
Location: Hannover, Germany
First there's a breath reduction for already being wounded (it compares how much of your health bar is pink or red).

Then you simply loose breath points for being actually wounded/hit, but the values I saw are quite high, so internally the code may use higher values for breath than 100(%).

Report message to a moderator

First Sergeant

Re: "How does it work?" Part 5: Melee Combat Chance-to-Hit[message #218840] Wed, 03 June 2009 07:04 Go to previous message
usrbid is currently offline usrbid

 
Messages:1506
Registered:December 2008
Hi Headrock, any info on melee damage? Kaerar and I are working on a mod and we tested various HtH weapons. I noticed that punching weapons do less damage than guns with same ubImpact. Kaerar noticed some kind cap on punching weapons in the XML editor, apparently ubImpact 120 got reduced to 80. Do you know anything about HtH damage?

Report message to a moderator

Sergeant Major

Previous Topic: "How does it work?" Part 8: Skill Checks
Next Topic: "How does it work?" Part 9: Relationships
Goto Forum:
  


Current Time: Fri Mar 29 07:24:55 GMT+2 2024

Total time taken to generate the page: 0.01233 seconds