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


Messages:1781
Registered:March 2006 Location: Jerusalem 


It is recommended to read "Part 4: ChancetoHit" before reading this article, but not required.

The Melee ChanceToHit 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 ChancetoHit formula (MCTH, 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
ChancetoHit = 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 hungover. 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 5054 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 23 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 7084, Breath_Penalty is 10
At 5069, Breath_Penalty is 25
At 3049, Breath_Penalty is 50
At 1529, 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 (computercontrolled 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 computercontrolled 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?

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 ChancetoHit. 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 MeleeCombat skills can help the attacker's ChancetoHit.
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 punchweapon (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 HANDTOHAND skill, then
Attacker_Chance is increased by 15 points per level of the HANDTOHAND 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

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
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 HANDTOHAND skill, then
Defender_Chance is increased by 15 for each level of the HANDTOHAND skill
Martial Arts and HandtoHand skills help, but only if both combatants are unarmed. They also help when stealing. Note that Martial Arts is far more helpful than HandtoHand when defending. When attacking, the HandtoHand 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% chancetohit. If Attacker_Chance is higher than Defender_Chance, we'll get more than 67% chancetohit. 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
[*]Good morale
{*]Extra Aiming APs
[*]KNIFING skill
Very helpful when attacking with a knife.
[*]HANDTOHAND and MARTIALARTS skill
Very helpful when attacking unarmed, with blunt weapons, or when stealing. Martial Arts is twice as effective as HandtoHand.
[/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
 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 bluntweapon attacks, if you're holding a knife. Not helpful against stealing.
 MARTIALARTS 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.
 HANDTOHAND 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
 Claustrophobic episode while underground
 Low morale
 Injury
Always harmful. Bandaged damage is half as harmful as bleeding damage.
 Low stamina (fatigue)
 Being "Gassed"
 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
 Low morale
 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"
 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



       
Re: "How does it work?" Part 5: Melee Combat ChancetoHit[message #196994] 
Tue, 23 September 2008 07:39  
Hitcher


Messages:12
Registered:January 2000 Location: Vienna, Austria 


Quote:If Attacker is Unarmed or using a punchweapon (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 HANDTOHAND skill, then
Attacker_Chance is increased by 15 points per level of the HANDTOHAND 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?)



     
Goto Forum:
Current Time: Fri Jan 18 03:51:23 EET 2019
Total time taken to generate the page: 0.00847 seconds
