Skip to content

Commit

Permalink
bugfix: Tesla Zap Fix (#5601)
Browse files Browse the repository at this point in the history
Tesla Zap Fix
  • Loading branch information
Gottfrei authored Jul 28, 2024
1 parent 3c6fe9e commit f56a80c
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 2 deletions.
2 changes: 2 additions & 0 deletions code/__DEFINES/traits/declarations.dm
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ Remember to update _globalvars/traits.dm if you're adding/removing/renaming trai
//atom traits
/// Trait used to prevent an atom from component radiation emission (see radioactivity.dm)
#define TRAIT_BLOCK_RADIATION "block_radiation"
/// Is this atom being actively shocked? Used to prevent repeated shocks.
#define TRAIT_BEING_SHOCKED "being_shocked"

/// Weather immunities, also protect mobs inside them.
#define TRAIT_LAVA_IMMUNE "lava_immune" //Used by lava turfs and The Floor Is Lava.
Expand Down
3 changes: 3 additions & 0 deletions code/__DEFINES/traits/sources.dm
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
#define EAR_DAMAGE "ear_damage"
#define EYE_DAMAGE "eye_damage"

/// Trait sorce for "was recently shocked by something"
#define WAS_SHOCKED "was_shocked"

/// cannot be removed without admin intervention
#define ROUNDSTART_TRAIT "roundstart"

Expand Down
1 change: 1 addition & 0 deletions code/_globalvars/traits.dm
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
*/
GLOBAL_LIST_INIT(traits_by_type, list(
/atom = list(
"TRAIT_BEING_SHOCKED" = TRAIT_BEING_SHOCKED,
"TRAIT_BLOCK_RADIATION" = TRAIT_BLOCK_RADIATION,
"TRAIT_CMAGGED" = TRAIT_CMAGGED,
),
Expand Down
6 changes: 4 additions & 2 deletions code/modules/power/tesla/energy_ball.dm
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@
else if(isliving(A))
var/dist = get_dist(source, A)
var/mob/living/L = A
if(dist <= zap_range && (dist < closest_dist || !closest_mob) && L.stat != DEAD && !HAS_TRAIT(L, TRAIT_TESLA_SHOCKIMMUNE))
if(dist <= zap_range && (dist < closest_dist || !closest_mob) && L.stat != DEAD && !HAS_TRAIT(L, TRAIT_TESLA_SHOCKIMMUNE) && !HAS_TRAIT(L, TRAIT_BEING_SHOCKED))
closest_mob = L
closest_atom = A
closest_dist = dist
Expand Down Expand Up @@ -279,8 +279,10 @@
closest_grounding_rod.tesla_act(power, explosive)

else if(closest_mob)
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 = clamp(round(power/400), 10, 90) + rand(-5, 5)
closest_mob.electrocute_act(shock_damage, "шара тесла", flags = SHOCK_TESLA)
closest_mob.electrocute_act(shock_damage, "шара тесла", flags = SHOCK_TESLA | (stun_mobs ? NONE : SHOCK_NOSTUN))
if(issilicon(closest_mob))
var/mob/living/silicon/S = closest_mob
if(stun_mobs)
Expand Down

0 comments on commit f56a80c

Please sign in to comment.