Human Armor On-Hit Walkthrough #57
SigDoesCode
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Since there have been a lot of questions about how the armor proc is handled, this is going to walk through the armor calculations for a human wearing armor being hit by a mob.
The procs that I'm using come from code/modules/mob/living/living_defense.dm.
The proc begins on line 19 with STEP ONE: TOTAL DAMAGE FROM ATTACK:
This first check checks to see if the damage is defined, and is added to a list called
dmg_types
. It then debugs for armor_divisor, to make sure that we're not dividing by 0 later on. We then assign a pair of tracker variables,total_dmg
anddealt_damage
. We then run through the damage indmg_types
and add it tototal_dmg
, and check to see if it's empty with an early return.This leads us to STEP TWO: THE ARMOR CHECK
The first part of Step Two involves finding the armor.
Once we have our
remaining_armor
andremaining_ablative
, we need to check the armor pen. this is STEP FOUR: ARMOR PEN.For each type of damage, it runs through this part. For example, if the attack did brute and burn, it would run this twice. When it runs this, it checks to see if it's a type that actually pens armor. If it is, it runs the pair of
if
statements. Let's assume that first hit that ends up dealing 10 brute and 10 burn. Assume that the armor has 5 armor remaining after thearmor_divisor
check earlier and no ablative armor. This means that we check the first damage type, brute.Remaining_armor
is 5, sodmg_armor_difference
is going to be 5 (10 dmg - 5 armor). The difference is going to be positive. This increasesused_armor
by 5, and thenremaining_armor
will be 0 (5 total - 5 used). Since there is no remaining armor,dmg
is going to be 5. The ablative armor check is the same as the above, just using the ablative armor. If there was any armor left, it would take it off of this resulting 5 damage, but there isn't any, so we just move on.We repeat this process for the burn damage. Again, assuming the armor has 5 BRUTE armor and 5 BURN armor, this leaves us with the following: 5 Brute damage, 5 burn damage, 5 brute armor used, 5 burn armor used. It also gives us a
dmg_dealt
value of 10, made from 5 BRUTE and 5 BURN. This comes in handy later.Now we have STEP FIVE - A: MOB HALLOSS
This block, right after the previous block, checks to see if we're a simple mob. If so, we take halloss instead of a bunch of damage types. It checks the armor's agony defense, gives us a guaranteed 10% damage reduction, and then gives us our
effective_damage
. If the damage type is HALLOSS, it then either uses 0 or the damage - the mob's agony armor, whichever is bigger. If it's not, it adjusts it to halloss depending on the mob's armor, the projectile's wounding multiplier (or 1 if it doesn't have one) and the mob's organ efficiency where it's hit.Taking that same 5 damage from earlier, it would see that it's BRUTE, not HALLOSS, so we need to use the last block. Then, we would call the following after substituting values : `adjustHalLoss(5 * (1) * ARMOR_HALLOSS_COEFFICIENT * (1)) (The last 1 assumes perfect 100% efficiency in the nerves in the targeted location. Deadened nerves mean less pain! It also means more pain for heightened nerve efficiency.)
We can now move on to STEP FIVE - B: HALLOSS ON HUMANS
Now we do that same HALLOSS thing, but for humans. If there is any damage remaining (which there is, we have 5 BRUTE and 5 BURN from earlier) we add it to the
dealt_dmg
tracker. We then do the HALLOSS calculation from STEP FIVE - A, except we have guaranteed 15% of the attack's damage as pain if it's HALOSS, or the attack's damage - armor's pain armor, whichever is higher. Then, if the hit mob is a human, it has a 25% + (2*dmg) chance for a stun. Here, we don't reach that check because we have BRUTE and BURN damage, but if we did, it would be about a 35% chance assuming the same 5 damage but in HALLOSS form this time.However, since we don't have HALLOSS, we're going to ignore this for the check from earlier. Just remember that this is how it works.
This brings us to STEP SIX: EMBED CHECK.
If we have a brute damage attack, it might be able to embed or pen. Here's where we check that. Remember, we have a 5 BRUTE damage hit left over that still hasn't been applied. Let's assume it has both the SHARP and EDGED flags, like if it came from a knife. We check a % chance to block based on the amount of damage absorbed. The more damage absorbed, the less likely a pen or embed is. Here, remember that
dmg
is 5 BRUTE, flags SHARP and EDGE, with admg_types[dmg_type]
of 10, because the initial hit was 10 damage and 5 has been eaten by armor. Therefore, this means the % check ends up as 50% ((1-(5/10)) * 100). Let's assume we win the coinflip and it doesn't get blocked. We ignore the rest of this proc and move on. However, if we lost... then, if there's a wounding multiplier, we double the wounding. If no multiplier, it's 1. Then, it removes the SHARP and EDGE flags from the attack and says "Their armor deflects the strike!" letting us know that out pen was foiled.We now move on to STEP SEVEN: ACTUALLY APPLYING THE GODDAMN DAMANGE ALREADY HOLY SHIT-
In STEP SEVEN, we finally apply the damage of the attack. Here, we take the
dmg
, thedmg_type
, thedef_zone
, thearmor_divisor
, thewounding multiplier
,SHARP
,EDGE
, andused_weapon
. (As a reminder, our attack would look like this if we passed the coinflip in step 6:apply_damage(5, BRUTE, ?, 2, 2, TRUE, TRUE, knife)
. I'm assuming a wounding multi of 2 and an armor divisor of 2 for consistency. Also, the location of the damage doesn't matter for understanding this proc, it just takes wherever the attack hit.)This means we have to step into
apply_damage
, which comes from here:Here, it means we just apply the damage with the following arguments:
(5, BRUTE, ?, 2, 2, TRUE, TRUE, knife)
. Our attack damage is BRUTE. Therefore, we'd do a wound check with the following: (?, 2, TRUE, TRUE). (The proc for wound checks is here. Regardless, we get a wounding multiplier of 1.5.) We get a Wounding Multiplier of 1.5 from the wound check, and then we call adjustBruteLoss(5*1.5), FINALLY damaging our target for a whopping 7.5 damage.Once we apply our
apply_damage
proc, if there's more damage than 20 AND the target is a human AND we have adef_zone
(i.e. target of the attack), we hit an external organ in thedef_zone
and potentially knock its splint off. Neat!Now we're on to the BUR- NOPE. MORE NUMBERS.
On to STEP NINE: ARMOR COMMUNICATION.
Don't ask me why there's so many spaces there. It's just how Soj does it.
Regardless, we check to see the effectiveness of the armor. Here, we have a value for
dealt_damage
of 10 and a value fortotal_dmg
of 20. therefore, effective armor is (1-(10/20)*100) or 50. We then see that it'll give us the message "Your armor protects you from the impact! Great, it did something. Can we be done now? I have things to g-NO. ON TO STEP TEN: MISCELLANEOUS.
The last part of the proc handles subtracting damage from ablative armor, checking to see if a grab has been de-leveled on hit, and projectile penetration. The code is here, but we don't need to go over it.
There, a workdown of the damage_through_armor proc!
Beta Was this translation helpful? Give feedback.
All reactions