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."