From bd265161a94acdebf13ee7bd73e724bde448cc8d Mon Sep 17 00:00:00 2001 From: SkyratBot <59378654+SkyratBot@users.noreply.github.com> Date: Tue, 27 Sep 2022 20:28:22 +0200 Subject: [PATCH] [MIRROR] Replaces obj flag `being_shocked` and flag_1 `shocked_1` with `TRAIT_BEING_SHOCKED` [MDB IGNORE] (#16379) * Replaces obj flag `being_shocked` and flag_1 `shocked_1` with `TRAIT_BEING_SHOCKED` (#69978) * Replaces `being_shocked` and `shocked_1` with `TRAIT_BEING_SHOCKED`, removing a flag_1, taking us away from the possibility of hitting the flag limit. * Replaces obj flag `being_shocked` and flag_1 `shocked_1` with `TRAIT_BEING_SHOCKED` Co-authored-by: MrMelbert <51863163+MrMelbert@users.noreply.github.com> --- code/__DEFINES/clothing.dm | 5 ++++ code/__DEFINES/flags.dm | 30 +++++++++---------- code/__DEFINES/obj_flags.dm | 17 +++++------ code/__DEFINES/traits.dm | 6 ++++ code/_globalvars/bitfields.dm | 2 -- code/game/objects/obj_defense.dm | 7 ++--- code/modules/clothing/clothing.dm | 5 ++-- .../modules/clothing/suits/reactive_armour.dm | 18 ++++------- code/modules/mob/living/status_procs.dm | 12 -------- code/modules/power/supermatter/supermatter.dm | 19 ++++++------ code/modules/power/tesla/coil.dm | 4 +-- code/modules/power/tesla/energy_ball.dm | 28 ++++++++--------- 12 files changed, 67 insertions(+), 86 deletions(-) diff --git a/code/__DEFINES/clothing.dm b/code/__DEFINES/clothing.dm index be3e4ec9a4d..77d2bced447 100644 --- a/code/__DEFINES/clothing.dm +++ b/code/__DEFINES/clothing.dm @@ -25,3 +25,8 @@ #define HAS_SENSORS 1 /// Suit sensor is present and is forced to display information (used on prisoner jumpsuits) #define LOCKED_SENSORS 2 + +/// Wrapper for adding clothing based traits +#define ADD_CLOTHING_TRAIT(mob, trait) ADD_TRAIT(mob, trait, "[CLOTHING_TRAIT]_[REF(src)]") +/// Wrapper for removing clothing based traits +#define REMOVE_CLOTHING_TRAIT(mob, trait) REMOVE_TRAIT(mob, trait, "[CLOTHING_TRAIT]_[REF(src)]") diff --git a/code/__DEFINES/flags.dm b/code/__DEFINES/flags.dm index 8a8c0f86ff9..8c0d6fe1a84 100644 --- a/code/__DEFINES/flags.dm +++ b/code/__DEFINES/flags.dm @@ -34,32 +34,32 @@ GLOBAL_LIST_INIT(bitflags, list(1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 204 #define PREVENT_CLICK_UNDER_1 (1<<6) ///specifies that this atom is a hologram that isnt real #define HOLOGRAM_1 (1<<7) -/// Prevents mobs from getting chainshocked by teslas and the supermatter -#define SHOCKED_1 (1<<8) ///Whether /atom/Initialize() has already run for the object -#define INITIALIZED_1 (1<<9) +#define INITIALIZED_1 (1<<8) /// was this spawned by an admin? used for stat tracking stuff. -#define ADMIN_SPAWNED_1 (1<<10) +#define ADMIN_SPAWNED_1 (1<<9) /// should not get harmed if this gets caught by an explosion? -#define PREVENT_CONTENTS_EXPLOSION_1 (1<<11) +#define PREVENT_CONTENTS_EXPLOSION_1 (1<<10) /// Should this object be paintable with very dark colors? -#define ALLOW_DARK_PAINTS_1 (1<<14) +#define ALLOW_DARK_PAINTS_1 (1<<11) /// Should this object be unpaintable? -#define UNPAINTABLE_1 (1<<15) +#define UNPAINTABLE_1 (1<<12) /// Is the thing currently spinning? -#define IS_SPINNING_1 (1<<16) -#define IS_ONTOP_1 (1<<17) -#define SUPERMATTER_IGNORES_1 (1<<18) +#define IS_SPINNING_1 (1<<13) +/// Is this atom on top of another atom, and as such has click priority? +#define IS_ONTOP_1 (1<<14) +/// Is this atom immune to being dusted by the supermatter? +#define SUPERMATTER_IGNORES_1 (1<<15) /// If a turf can be made dirty at roundstart. This is also used in areas. -#define CAN_BE_DIRTY_1 (1<<19) +#define CAN_BE_DIRTY_1 (1<<16) /// Should we use the initial icon for display? Mostly used by overlay only objects -#define HTML_USE_INITAL_ICON_1 (1<<20) +#define HTML_USE_INITAL_ICON_1 (1<<17) /// Can players recolor this in-game via vendors (and maybe more if support is added)? -#define IS_PLAYER_COLORABLE_1 (1<<21) +#define IS_PLAYER_COLORABLE_1 (1<<18) /// Whether or not this atom has contextual screentips when hovered OVER -#define HAS_CONTEXTUAL_SCREENTIPS_1 (1<<22) +#define HAS_CONTEXTUAL_SCREENTIPS_1 (1<<19) // Whether or not this atom is storing contents for a disassociated storage object -#define HAS_DISASSOCIATED_STORAGE_1 (1<<23) +#define HAS_DISASSOCIATED_STORAGE_1 (1<<20) // Update flags for [/atom/proc/update_appearance] /// Update the atom's name diff --git a/code/__DEFINES/obj_flags.dm b/code/__DEFINES/obj_flags.dm index ef88911980a..91d5b72d5a3 100644 --- a/code/__DEFINES/obj_flags.dm +++ b/code/__DEFINES/obj_flags.dm @@ -4,15 +4,14 @@ #define EMAGGED (1<<0) #define IN_USE (1<<1) // If we have a user using us, this will be set on. We will check if the user has stopped using us, and thus stop updating and LAGGING EVERYTHING! #define CAN_BE_HIT (1<<2) //can this be bludgeoned by items? -#define BEING_SHOCKED (1<<3) // Whether this thing is currently (already) being shocked by a tesla -#define DANGEROUS_POSSESSION (1<<4) //Admin possession yes/no -#define UNIQUE_RENAME (1<<5) // can you customize the description/name of the thing? -#define USES_TGUI (1<<6) //put on things that use tgui on ui_interact instead of custom/old UI. -#define BLOCK_Z_OUT_DOWN (1<<7) // Should this object block z falling from loc? -#define BLOCK_Z_OUT_UP (1<<8) // Should this object block z uprise from loc? -#define BLOCK_Z_IN_DOWN (1<<9) // Should this object block z falling from above? -#define BLOCK_Z_IN_UP (1<<10) // Should this object block z uprise from below? -#define NO_BUILD (1<<11) // Can we build on this object? +#define DANGEROUS_POSSESSION (1<<3) //Admin possession yes/no +#define UNIQUE_RENAME (1<<4) // can you customize the description/name of the thing? +#define USES_TGUI (1<<5) //put on things that use tgui on ui_interact instead of custom/old UI. +#define BLOCK_Z_OUT_DOWN (1<<6) // Should this object block z falling from loc? +#define BLOCK_Z_OUT_UP (1<<7) // Should this object block z uprise from loc? +#define BLOCK_Z_IN_DOWN (1<<8) // Should this object block z falling from above? +#define BLOCK_Z_IN_UP (1<<9) // Should this object block z uprise from below? +#define NO_BUILD (1<<10) // Can we build on this object? // If you add new ones, be sure to add them to /obj/Initialize as well for complete mapping support diff --git a/code/__DEFINES/traits.dm b/code/__DEFINES/traits.dm index 3a04a8817cd..7288e48a28a 100644 --- a/code/__DEFINES/traits.dm +++ b/code/__DEFINES/traits.dm @@ -180,8 +180,12 @@ Remember to update _globalvars/traits.dm if you're adding/removing/renaming trai #define TRAIT_IWASBATONED "iwasbatoned" #define TRAIT_SLEEPIMMUNE "sleep_immunity" #define TRAIT_PUSHIMMUNE "push_immunity" +/// Are we immune to shocks? #define TRAIT_SHOCKIMMUNE "shock_immunity" +/// Are we immune to specifically tesla / SM shocks? #define TRAIT_TESLA_SHOCKIMMUNE "tesla_shock_immunity" +/// Is this atom being actively shocked? Used to prevent repeated shocks. +#define TRAIT_BEING_SHOCKED "shocked" #define TRAIT_STABLEHEART "stable_heart" /// Prevents you from leaving your corpse #define TRAIT_CORPSELOCKED "corpselocked" @@ -703,6 +707,8 @@ Remember to update _globalvars/traits.dm if you're adding/removing/renaming trai #define INNATE_TRAIT "innate" #define CRIT_HEALTH_TRAIT "crit_health" #define OXYLOSS_TRAIT "oxyloss" +/// Trait sorce for "was recently shocked by something" +#define WAS_SHOCKED "was_shocked" #define TURF_TRAIT "turf" /// trait associated to being buckled #define BUCKLED_TRAIT "buckled" diff --git a/code/_globalvars/bitfields.dm b/code/_globalvars/bitfields.dm index dd7cbb5bd1e..73f59e91fbd 100644 --- a/code/_globalvars/bitfields.dm +++ b/code/_globalvars/bitfields.dm @@ -129,7 +129,6 @@ DEFINE_BITFIELD(flags_1, list( "OVERLAY_QUEUED_1" = OVERLAY_QUEUED_1, "PREVENT_CLICK_UNDER_1" = PREVENT_CLICK_UNDER_1, "PREVENT_CONTENTS_EXPLOSION_1" = PREVENT_CONTENTS_EXPLOSION_1, - "SHOCKED_1" = SHOCKED_1, "SUPERMATTER_IGNORES_1" = SUPERMATTER_IGNORES_1, "UNPAINTABLE_1" = UNPAINTABLE_1, )) @@ -269,7 +268,6 @@ DEFINE_BITFIELD(movement_type, list( )) DEFINE_BITFIELD(obj_flags, list( - "BEING_SHOCKED" = BEING_SHOCKED, "BLOCK_Z_IN_DOWN" = BLOCK_Z_IN_DOWN, "BLOCK_Z_IN_UP" = BLOCK_Z_IN_UP, "BLOCK_Z_OUT_DOWN" = BLOCK_Z_OUT_DOWN, diff --git a/code/game/objects/obj_defense.dm b/code/game/objects/obj_defense.dm index ef91270a710..ab74950e420 100644 --- a/code/game/objects/obj_defense.dm +++ b/code/game/objects/obj_defense.dm @@ -158,8 +158,8 @@ GLOBAL_DATUM_INIT(acid_overlay, /mutable_appearance, mutable_appearance('icons/e /obj/zap_act(power, zap_flags) if(QDELETED(src)) return 0 - obj_flags |= BEING_SHOCKED - addtimer(CALLBACK(src, .proc/reset_shocked), 1 SECONDS) + ADD_TRAIT(src, TRAIT_BEING_SHOCKED, WAS_SHOCKED) + addtimer(TRAIT_CALLBACK_REMOVE(src, TRAIT_BEING_SHOCKED, WAS_SHOCKED), 1 SECONDS) return power / 2 //The surgeon general warns that being buckled to certain objects receiving powerful shocks is greatly hazardous to your health @@ -170,9 +170,6 @@ GLOBAL_DATUM_INIT(acid_overlay, /mutable_appearance, mutable_appearance('icons/e var/mob/living/buckled_mob = m buckled_mob.electrocute_act((clamp(round(strength/400), 10, 90) + rand(-5, 5)), src, flags = SHOCK_TESLA) -/obj/proc/reset_shocked() - obj_flags &= ~BEING_SHOCKED - ///the obj is deconstructed into pieces, whether through careful disassembly or when destroyed. /obj/proc/deconstruct(disassembled = TRUE) SEND_SIGNAL(src, COMSIG_OBJ_DECONSTRUCT, disassembled) diff --git a/code/modules/clothing/clothing.dm b/code/modules/clothing/clothing.dm index 5d371e8e82e..a27fac7880d 100644 --- a/code/modules/clothing/clothing.dm +++ b/code/modules/clothing/clothing.dm @@ -232,8 +232,7 @@ return UnregisterSignal(user, COMSIG_MOVABLE_MOVED) for(var/trait in clothing_traits) - REMOVE_TRAIT(user, trait, "[CLOTHING_TRAIT]_[REF(src)]") - + REMOVE_CLOTHING_TRAIT(user, trait) if(LAZYLEN(user_vars_remembered)) for(var/variable in user_vars_remembered) @@ -250,7 +249,7 @@ if(iscarbon(user) && LAZYLEN(zones_disabled)) RegisterSignal(user, COMSIG_MOVABLE_MOVED, .proc/bristle, override = TRUE) for(var/trait in clothing_traits) - ADD_TRAIT(user, trait, "[CLOTHING_TRAIT]_[REF(src)]") + ADD_CLOTHING_TRAIT(user, trait) if (LAZYLEN(user_vars_to_edit)) for(var/variable in user_vars_to_edit) if(variable in user.vars) diff --git a/code/modules/clothing/suits/reactive_armour.dm b/code/modules/clothing/suits/reactive_armour.dm index de4fbde3c26..9b27f192f46 100644 --- a/code/modules/clothing/suits/reactive_armour.dm +++ b/code/modules/clothing/suits/reactive_armour.dm @@ -225,20 +225,14 @@ siemens_coefficient = -1 cooldown_message = span_danger("The tesla capacitors on the reactive tesla armor are still recharging! The armor merely emits some sparks.") emp_message = span_warning("The tesla capacitors beep ominously for a moment.") + clothing_traits = list(TRAIT_TESLA_SHOCKIMMUNE) + /// How strong are the zaps we give off? var/zap_power = 25000 + /// How far to the zaps we give off go? var/zap_range = 20 + /// What flags do we pass to the zaps we give off? var/zap_flags = ZAP_MOB_DAMAGE | ZAP_OBJ_DAMAGE -/obj/item/clothing/suit/armor/reactive/tesla/dropped(mob/user) - ..() - if(istype(user)) - REMOVE_TRAIT(user, TRAIT_TESLA_SHOCKIMMUNE, "reactive_tesla_armor") - -/obj/item/clothing/suit/armor/reactive/tesla/equipped(mob/user, slot) - ..() - if(slot_flags & slot) //Was equipped to a valid slot for this item? - ADD_TRAIT(user, TRAIT_TESLA_SHOCKIMMUNE, "reactive_tesla_armor") - /obj/item/clothing/suit/armor/reactive/tesla/cooldown_activation(mob/living/carbon/human/owner) var/datum/effect_system/spark_spread/sparks = new /datum/effect_system/spark_spread sparks.set_up(1, 1, src) @@ -253,9 +247,9 @@ /obj/item/clothing/suit/armor/reactive/tesla/emp_activation(mob/living/carbon/human/owner, atom/movable/hitby, attack_text = "the attack", final_block_chance = 0, damage = 0, attack_type = MELEE_ATTACK) owner.visible_message(span_danger("[src] blocks [attack_text], but pulls a massive charge of energy into [owner] from the surrounding environment!")) - REMOVE_TRAIT(owner, TRAIT_TESLA_SHOCKIMMUNE, "reactive_tesla_armor") //oops! can't shock without this! + REMOVE_CLOTHING_TRAIT(owner, TRAIT_TESLA_SHOCKIMMUNE) //oops! can't shock without this! electrocute_mob(owner, get_area(src), src, 1) - ADD_TRAIT(owner, TRAIT_TESLA_SHOCKIMMUNE, "reactive_tesla_armor") + ADD_CLOTHING_TRAIT(owner, TRAIT_TESLA_SHOCKIMMUNE) reactivearmor_cooldown = world.time + reactivearmor_cooldown_duration return TRUE diff --git a/code/modules/mob/living/status_procs.dm b/code/modules/mob/living/status_procs.dm index bc186c61d76..c14a3e274d5 100644 --- a/code/modules/mob/living/status_procs.dm +++ b/code/modules/mob/living/status_procs.dm @@ -605,18 +605,6 @@ if(update) update_movespeed() -/** - * Sets the [SHOCKED_1] flag on this mob. - */ -/mob/living/proc/set_shocked() - flags_1 |= SHOCKED_1 - -/** - * Unsets the [SHOCKED_1] flag on this mob. - */ -/mob/living/proc/reset_shocked() - flags_1 &= ~ SHOCKED_1 - /** * Adjusts a timed status effect on the mob,taking into account any existing timed status effects. * This can be any status effect that takes into account "duration" with their initialize arguments. diff --git a/code/modules/power/supermatter/supermatter.dm b/code/modules/power/supermatter/supermatter.dm index 1cb01f65e37..4956032895d 100644 --- a/code/modules/power/supermatter/supermatter.dm +++ b/code/modules/power/supermatter/supermatter.dm @@ -430,13 +430,13 @@ GLOBAL_DATUM(main_supermatter_engine, /obj/machinery/power/supermatter_crystal) var/list/arc_targets = list() //Making a new copy so additons further down the recursion do not mess with other arcs //Lets put this ourself into the do not hit list, so we don't curve back to hit the same thing twice with one arc - for(var/test in oview(zapstart, range)) + for(var/atom/test as anything in oview(zapstart, range)) if(!(zap_flags & ZAP_ALLOW_DUPLICATES) && LAZYACCESS(targets_hit, test)) continue if(istype(test, /obj/vehicle/ridden/bicycle/)) var/obj/vehicle/ridden/bicycle/bike = test - if(!(bike.obj_flags & BEING_SHOCKED) && bike.can_buckle)//God's not on our side cause he hates idiots. + if(!HAS_TRAIT(bike, TRAIT_BEING_SHOCKED) && bike.can_buckle)//God's not on our side cause he hates idiots. if(target_type != BIKE) arc_targets = list() arc_targets += test @@ -447,7 +447,7 @@ GLOBAL_DATUM(main_supermatter_engine, /obj/machinery/power/supermatter_crystal) if(istype(test, /obj/machinery/power/energy_accumulator/tesla_coil/)) var/obj/machinery/power/energy_accumulator/tesla_coil/coil = test - if(coil.anchored && !(coil.obj_flags & BEING_SHOCKED) && !coil.panel_open && prob(70))//Diversity of death + if(!HAS_TRAIT(coil, TRAIT_BEING_SHOCKED) && coil.anchored && !coil.panel_open && prob(70))//Diversity of death if(target_type != COIL) arc_targets = list() arc_targets += test @@ -470,7 +470,7 @@ GLOBAL_DATUM(main_supermatter_engine, /obj/machinery/power/supermatter_crystal) if(isliving(test)) var/mob/living/alive = test - if(!(HAS_TRAIT(alive, TRAIT_TESLA_SHOCKIMMUNE)) && !(alive.flags_1 & SHOCKED_1) && alive.stat != DEAD && prob(20))//let's not hit all the engineers with every beam and/or segment of the arc + if(!HAS_TRAIT(alive, TRAIT_TESLA_SHOCKIMMUNE) && !HAS_TRAIT(alive, TRAIT_BEING_SHOCKED) && alive.stat != DEAD && prob(20))//let's not hit all the engineers with every beam and/or segment of the arc if(target_type != LIVING) arc_targets = list() arc_targets += test @@ -480,8 +480,7 @@ GLOBAL_DATUM(main_supermatter_engine, /obj/machinery/power/supermatter_crystal) continue if(ismachinery(test)) - var/obj/machinery/machine = test - if(!(machine.obj_flags & BEING_SHOCKED) && prob(40)) + if(!HAS_TRAIT(test, TRAIT_BEING_SHOCKED) && prob(40)) if(target_type != MACHINERY) arc_targets = list() arc_targets += test @@ -491,8 +490,7 @@ GLOBAL_DATUM(main_supermatter_engine, /obj/machinery/power/supermatter_crystal) continue if(isobj(test)) - var/obj/object = test - if(!(object.obj_flags & BEING_SHOCKED)) + if(!HAS_TRAIT(test, TRAIT_BEING_SHOCKED)) if(target_type != OBJECT) arc_targets = list() arc_targets += test @@ -530,8 +528,8 @@ GLOBAL_DATUM(main_supermatter_engine, /obj/machinery/power/supermatter_crystal) else if(isliving(target))//If we got a fleshbag on our hands var/mob/living/creature = target - creature.set_shocked() - addtimer(CALLBACK(creature, /mob/living/proc/reset_shocked), 1 SECONDS) + ADD_TRAIT(creature, TRAIT_BEING_SHOCKED, WAS_SHOCKED) + addtimer(TRAIT_CALLBACK_REMOVE(creature, TRAIT_BEING_SHOCKED, WAS_SHOCKED), 1 SECONDS) //3 shots a human with no resistance. 2 to crit, one to death. This is at at least 10000 power. //There's no increase after that because the input power is effectivly capped at 10k //Does 1.5 damage at the least @@ -541,6 +539,7 @@ GLOBAL_DATUM(main_supermatter_engine, /obj/machinery/power/supermatter_crystal) else zap_str = target.zap_act(zap_str, zap_flags) + //This gotdamn variable is a boomer and keeps giving me problems var/turf/target_turf = get_turf(target) var/pressure = 1 diff --git a/code/modules/power/tesla/coil.dm b/code/modules/power/tesla/coil.dm index 63c69d5bc69..ff4e3bec14c 100644 --- a/code/modules/power/tesla/coil.dm +++ b/code/modules/power/tesla/coil.dm @@ -91,8 +91,8 @@ /obj/machinery/power/energy_accumulator/tesla_coil/zap_act(power, zap_flags) if(!anchored || panel_open) return ..() - obj_flags |= BEING_SHOCKED - addtimer(CALLBACK(src, .proc/reset_shocked), 1 SECONDS) + ADD_TRAIT(src, TRAIT_BEING_SHOCKED, WAS_SHOCKED) + addtimer(TRAIT_CALLBACK_REMOVE(src, TRAIT_BEING_SHOCKED, WAS_SHOCKED), 1 SECONDS) flick("coilhit", src) if(!(zap_flags & ZAP_GENERATES_POWER)) //Prevent infinite recursive power return 0 diff --git a/code/modules/power/tesla/energy_ball.dm b/code/modules/power/tesla/energy_ball.dm index e1f52fe12e8..69aba17336f 100644 --- a/code/modules/power/tesla/energy_ball.dm +++ b/code/modules/power/tesla/energy_ball.dm @@ -252,8 +252,7 @@ //Darkness fucks oview up hard. I've tried dview() but it doesn't seem to work //I hate existance - for(var/a in typecache_filter_list(oview(zap_range+2, source), things_to_shock)) - var/atom/A = a + for(var/atom/A as anything in typecache_filter_list(oview(zap_range+2, source), things_to_shock)) if(!(zap_flags & ZAP_ALLOW_DUPLICATES) && LAZYACCESS(shocked_targets, A)) continue // NOTE: these type checks are safe because CURRENTLY the range family of procs returns turfs in least to greatest distance order @@ -263,7 +262,7 @@ else if(istype(A, /obj/vehicle/ridden/bicycle))//God's not on our side cause he hates idiots. var/obj/vehicle/ridden/bicycle/B = A - if(!(B.obj_flags & BEING_SHOCKED) && B.can_buckle)//Gee goof thanks for the boolean + if(!HAS_TRAIT(B, TRAIT_BEING_SHOCKED) && B.can_buckle)//Gee goof thanks for the boolean //we use both of these to save on istype and typecasting overhead later on //while still allowing common code to run before hand closest_type = BIKE @@ -273,10 +272,9 @@ continue //no need checking these other things else if(istype(A, /obj/machinery/power/energy_accumulator/tesla_coil)) - var/obj/machinery/power/energy_accumulator/tesla_coil/C = A - if(!(C.obj_flags & BEING_SHOCKED)) + if(!HAS_TRAIT(A, TRAIT_BEING_SHOCKED)) closest_type = COIL - closest_atom = C + closest_atom = A else if(closest_type >= ROD) continue @@ -290,7 +288,7 @@ else if(istype(A,/obj/vehicle/ridden)) var/obj/vehicle/ridden/R = A - if(R.can_buckle && !(R.obj_flags & BEING_SHOCKED)) + if(R.can_buckle && !HAS_TRAIT(R, TRAIT_BEING_SHOCKED)) closest_type = RIDE closest_atom = A @@ -299,7 +297,7 @@ else if(isliving(A)) var/mob/living/L = A - if(L.stat != DEAD && !(HAS_TRAIT(L, TRAIT_TESLA_SHOCKIMMUNE)) && !(L.flags_1 & SHOCKED_1)) + if(L.stat != DEAD && !HAS_TRAIT(L, TRAIT_TESLA_SHOCKIMMUNE) && !HAS_TRAIT(L, TRAIT_BEING_SHOCKED)) closest_type = LIVING closest_atom = A @@ -307,8 +305,7 @@ continue else if(ismachinery(A)) - var/obj/machinery/M = A - if(!(M.obj_flags & BEING_SHOCKED)) + if(!HAS_TRAIT(A, TRAIT_BEING_SHOCKED)) closest_type = MACHINERY closest_atom = A @@ -316,8 +313,7 @@ continue else if(istype(A, /obj/structure/blob)) - var/obj/structure/blob/B = A - if(!(B.obj_flags & BEING_SHOCKED)) + if(!HAS_TRAIT(A, TRAIT_BEING_SHOCKED)) closest_type = BLOB closest_atom = A @@ -325,8 +321,7 @@ continue else if(isstructure(A)) - var/obj/structure/S = A - if(!(S.obj_flags & BEING_SHOCKED)) + if(!HAS_TRAIT(A, TRAIT_BEING_SHOCKED)) closest_type = STRUCTURE closest_atom = A @@ -345,8 +340,8 @@ if(closest_type == LIVING) var/mob/living/closest_mob = closest_atom - closest_mob.set_shocked() - addtimer(CALLBACK(closest_mob, /mob/living/proc/reset_shocked), 10) + ADD_TRAIT(closest_mob, TRAIT_BEING_SHOCKED, WAS_SHOCKED) + addtimer(TRAIT_CALLBACK_REMOVE(closest_mob, TRAIT_BEING_SHOCKED, WAS_SHOCKED), 1 SECONDS) var/shock_damage = (zap_flags & ZAP_MOB_DAMAGE) ? (min(round(power/600), 90) + rand(-5, 5)) : 0 closest_mob.electrocute_act(shock_damage, source, 1, SHOCK_TESLA | ((zap_flags & ZAP_MOB_STUN) ? NONE : SHOCK_NOSTUN)) if(issilicon(closest_mob)) @@ -360,6 +355,7 @@ else power = closest_atom.zap_act(power, zap_flags) + if(prob(20))//I know I know var/list/shocked_copy = shocked_targets.Copy() tesla_zap(closest_atom, next_range, power * 0.5, zap_flags, shocked_copy)//Normally I'd copy here so grounding rods work properly, but it fucks with movement