Skip to content

Commit 11962e1

Browse files
authored
Fix armor penetration increasing negative object's and mob silicon's armor (ParadiseSS13#30105)
* fix * no src allowed
1 parent 8851f9b commit 11962e1

File tree

2 files changed

+11
-12
lines changed

2 files changed

+11
-12
lines changed

code/game/objects/obj_defense.dm

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,12 @@
2525
return 0
2626
if(damage_type != BRUTE && damage_type != BURN)
2727
return 0
28-
var/armor_protection = 0
28+
var/armor_protection
2929
if(damage_flag)
3030
armor_protection = armor.getRating(damage_flag)
31-
if(armor_protection) //Only apply weak-against-armor/hollowpoint effects if there actually IS armor.
32-
armor_protection = clamp((armor_protection * ((100 - armor_penetration_percentage) / 100)) - armor_penetration_flat, min(armor_protection, 0), 100)
33-
var/damage_multiplier = (100 - armor_protection) / 100
34-
return round(damage_amount * damage_multiplier, DAMAGE_PRECISION)
31+
if(armor_protection > 0) //Only apply weak-against-armor/hollowpoint effects if there actually IS armor.
32+
armor_protection = clamp(armor_protection * (100 - armor_penetration_percentage) / 100 - armor_penetration_flat, 0, 100)
33+
return round(damage_amount * (100 - armor_protection) / 100, DAMAGE_PRECISION)
3534

3635
/// returns the amount of damage required to destroy this object in a single hit.
3736
/obj/proc/calculate_oneshot_damage(damage_type, damage_flag = 0, attack_dir, armor_penetration_flat = 0, armor_penetration_percentage = 0)
@@ -42,11 +41,11 @@
4241
if(damage_type != BRUTE && damage_type != BURN)
4342
return INFINITY
4443

45-
var/armor_protection = 0
44+
var/armor_protection
4645
if(damage_flag)
4746
armor_protection = armor.getRating(damage_flag)
48-
if(armor_protection) // Only apply weak-against-armor/hollowpoint effects if there actually IS armor.
49-
armor_protection = clamp((armor_protection * ((100 - armor_penetration_percentage) / 100)) - armor_penetration_flat, min(armor_protection, 0), 100)
47+
if(armor_protection > 0) // Only apply weak-against-armor/hollowpoint effects if there actually IS armor.
48+
armor_protection = clamp(armor_protection * (100 - armor_penetration_percentage) / 100 - armor_penetration_flat, 0, 100)
5049

5150
var/damage_multiplier = (100 - armor_protection) / 100
5251
if(damage_multiplier <= 0)

code/modules/mob/living/silicon/silicon_mob.dm

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -312,12 +312,12 @@
312312
/mob/living/silicon/proc/run_armor(damage_amount, damage_type, damage_flag = 0, attack_dir, armor_penetration_flat = 0, armor_penetration_percentage = 0)
313313
if(damage_type != BRUTE && damage_type != BURN)
314314
return 0
315-
var/armor_protection = 0
315+
var/armor_protection
316316
if(damage_flag)
317317
armor_protection = armor.getRating(damage_flag)
318-
if(armor_protection) //Only apply weak-against-armor/hollowpoint effects if there actually IS armor.
319-
armor_protection = clamp((armor_protection * ((100 - armor_penetration_percentage) / 100)) - armor_penetration_flat, min(armor_protection, 0), 100)
320-
return round(damage_amount * (100 - armor_protection) * 0.01, DAMAGE_PRECISION)
318+
if(armor_protection > 0) //Only apply weak-against-armor/hollowpoint effects if there actually IS armor.
319+
armor_protection = clamp(armor_protection * (100 - armor_penetration_percentage) / 100 - armor_penetration_flat, 0, 100)
320+
return round(damage_amount * (100 - armor_protection) / 100, DAMAGE_PRECISION)
321321

322322
/mob/living/silicon/apply_effect(effect = 0, effecttype = STUN, blocked = 0)
323323
return FALSE //The only effect that can hit them atm is flashes and they still directly edit so this works for now

0 commit comments

Comments
 (0)