From d5e38f9fc0a420ee73b151ff9a3247982ff34ec2 Mon Sep 17 00:00:00 2001 From: FenodyreeAv Date: Wed, 19 Aug 2026 18:10:42 +0000 Subject: [PATCH] EMPs check armour and drain less cell power (#23053) Any ion currently oneshots a mech, by draining it's power cell to zero. The amount of cell power drained is now random, up to the max charge of the cell for a heavy EMP. Up to half the max charge of the cell for a light EMP. This PR makes EMPs respect energy armour, as the description of energy armour says they should. Energy armour is averaged across the mob, weighted for limb size. This is then the chance to downgrade the EMP. A heavy EMP can be downgraded into a light EMP, but no further. A light EMP can either be negated completely, or only affect the mob's contents. Eg. A human wearing Ablative armour, (Energy 40), gives a 33% chance to downgrade a heavy EMP to a light, as it leaves the hands and feet uncovered. The same mob struck by a light EMP has a 33% chance to have the EMP only affect it and not it's contents (internal organs), if that is successful, there is a further 33% chance to negate the EMP completely. This means a mech with EM armour is guaranteed to downgrade a heavy EMP to light, and to ignore light EMPs completely. All other types of mech armour have Energy 10. Almost all EMPs are heavy, with the edge of EMP grenades being the only source of a light EMP. Ion rifles EMP the target twice, 8 heavy EMP's downgraded to light, will still seriously damage an unpowered EM armoured mech. --------- Signed-off-by: FenodyreeAv --- code/modules/mob/living/living_defense.dm | 25 +++++++++++++++++++ code/modules/power/cell.dm | 4 ++- .../Fenodyree-EMPArmourChecksAndNerf.yml | 7 ++++++ 3 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 html/changelogs/Fenodyree-EMPArmourChecksAndNerf.yml diff --git a/code/modules/mob/living/living_defense.dm b/code/modules/mob/living/living_defense.dm index caa9a676cb2..a7af152daa9 100644 --- a/code/modules/mob/living/living_defense.dm +++ b/code/modules/mob/living/living_defense.dm @@ -202,8 +202,33 @@ /mob/living/proc/electrocute_act(var/shock_damage, var/obj/source, var/siemens_coeff = 1.0, var/def_zone = null, var/tesla_shock = 0, var/ground_zero) return 0 //only carbon liveforms have this proc +/** + * Called a living mob is hit with an EMP effect. Returns the blocked result. + * Energy armor can downgrade or negate the effects of an EMP, and is checked here. + * The chance to reduce the effect is based on the average energy armor of the mob. + * A heavy EMP can only be downgraded to a light EMP. + * A light EMP can either be negated entirely, or only affect the mob's contents. + * Each step down is another chance equal to the average energy armor. + */ /mob/living/emp_act(severity) . = ..() + var/total_energy_armor = 0 + var/limb_size_weight = 0 + + for (var/def_zone in BP_ALL_LIMBS) + var/list/armors = get_armors_by_zone(def_zone, DAMAGE_BURN, null) + for(var/datum/component/armor/armor_datum in armors) + total_energy_armor += armor_datum.get_value(ENERGY) * GLOB.organ_rel_size[def_zone] + limb_size_weight += GLOB.organ_rel_size[def_zone] + + var/average_energy_armor = total_energy_armor / limb_size_weight + + if(severity == EMP_LIGHT && prob(average_energy_armor)) + if(prob(average_energy_armor)) + return EMP_PROTECT_ALL + return EMP_PROTECT_CONTENTS + if(severity == EMP_HEAVY && prob(average_energy_armor)) + severity = EMP_LIGHT //If no protection of the contents, apply the EMP effect to the contents if(!(. & EMP_PROTECT_CONTENTS)) diff --git a/code/modules/power/cell.dm b/code/modules/power/cell.dm index b03b8fae665..bda3cf513d7 100644 --- a/code/modules/power/cell.dm +++ b/code/modules/power/cell.dm @@ -192,6 +192,7 @@ if (prob(10)) rigged = 1 //broken batterys are dangerous +///A cell loses a random amount of charge, up to it's maxcharge, when it takes a heavy EMP, up to half it's maxcharge if hit by a light EMP. /obj/item/cell/emp_act(severity) . = ..() @@ -200,7 +201,8 @@ var/mob/living/silicon/robot/R = loc severity *= R.cell_emp_mult - charge -= maxcharge / severity + if(severity) + charge -= rand(0, (maxcharge / severity)) if (charge < 0) charge = 0 SEND_SIGNAL(src, COMSIG_CELL_CHARGE, charge) diff --git a/html/changelogs/Fenodyree-EMPArmourChecksAndNerf.yml b/html/changelogs/Fenodyree-EMPArmourChecksAndNerf.yml new file mode 100644 index 00000000000..f43c32815b0 --- /dev/null +++ b/html/changelogs/Fenodyree-EMPArmourChecksAndNerf.yml @@ -0,0 +1,7 @@ +author: Fenodyree + +delete-after: True + +changes: + - rscadd: "EMPs once again check energy armour. A heavy EMP can be downgraded to a light EMP, and a light EMP can be negated entirely or only affect the mob's contents. This chance is based on the average energy armour of the mob, weighted by limb size." + - balance: "The effect of an EMP on a power cell is now random. A light EMP can drain up to half the max charge, and a heavy EMP can drain up to the full max charge. Previously heavy would always drain the full max charge, and light would always drain half the max charge."