From 6a0be672c4dad95578b464d50ffee6743ece6c2f Mon Sep 17 00:00:00 2001 From: Iajret Creature <122297233+Steals-The-PRs@users.noreply.github.com> Date: Wed, 13 Dec 2023 02:20:21 +0300 Subject: [PATCH] [MIRROR] Prevents something fucky with elevation and glass tables [MDB IGNORE] (#1083) * Prevents something fucky with elevation and glass tables (#80187) --------- Co-authored-by: SkyratBot <59378654+SkyratBot@users.noreply.github.com> Co-authored-by: Ghom <42542238+Ghommie@users.noreply.github.com> Co-authored-by: san7890 --- code/__DEFINES/traits/declarations.dm | 3 +++ code/_globalvars/traits/_traits.dm | 1 + code/datums/elements/elevation.dm | 6 ++++++ 3 files changed, 10 insertions(+) diff --git a/code/__DEFINES/traits/declarations.dm b/code/__DEFINES/traits/declarations.dm index e49c7e56c9e..3ed5e18bee6 100644 --- a/code/__DEFINES/traits/declarations.dm +++ b/code/__DEFINES/traits/declarations.dm @@ -484,6 +484,9 @@ Remember to update _globalvars/traits.dm if you're adding/removing/renaming trai /// Whether or not the user is in a MODlink call, prevents making more calls #define TRAIT_IN_CALL "in_call" +/// Is the mob standing on an elevated surface? This prevents them from dropping down if not elevated first. +#define TRAIT_ON_ELEVATED_SURFACE "on_elevated_surface" + // METABOLISMS // Various jobs on the station have historically had better reactions // to various drinks and foodstuffs. Security liking donuts is a classic diff --git a/code/_globalvars/traits/_traits.dm b/code/_globalvars/traits/_traits.dm index 6feab49cc9f..f5fff224c9a 100644 --- a/code/_globalvars/traits/_traits.dm +++ b/code/_globalvars/traits/_traits.dm @@ -327,6 +327,7 @@ GLOBAL_LIST_INIT(traits_by_type, list( "TRAIT_NOSOFTCRIT" = TRAIT_NOSOFTCRIT, "TRAIT_NUKEIMMUNE" = TRAIT_NUKEIMMUNE, "TRAIT_OIL_FRIED" = TRAIT_OIL_FRIED, + "TRAIT_ON_ELEVATED_SURFACE" = TRAIT_ON_ELEVATED_SURFACE, "TRAIT_ORBITING_FORBIDDEN" = TRAIT_ORBITING_FORBIDDEN, "TRAIT_OVERDOSEIMMUNE" = TRAIT_OVERDOSEIMMUNE, "TRAIT_OVERWATCH_IMMUNE" = TRAIT_OVERWATCH_IMMUNE, diff --git a/code/datums/elements/elevation.dm b/code/datums/elements/elevation.dm index 3a80e642b18..8a21edbd2e1 100644 --- a/code/datums/elements/elevation.dm +++ b/code/datums/elements/elevation.dm @@ -110,6 +110,7 @@ ADD_TRAIT(target, TRAIT_ELEVATED_TURF, REF(src)) for(var/mob/living/living in target) + ADD_TRAIT(living, TRAIT_ON_ELEVATED_SURFACE, REF(src)) RegisterSignal(living, COMSIG_LIVING_SET_BUCKLED, PROC_REF(on_set_buckled)) elevate_mob(living) @@ -127,6 +128,9 @@ )) REMOVE_TRAIT(source, TRAIT_ELEVATED_TURF, REF(src)) for(var/mob/living/living in source) + if(!HAS_TRAIT_FROM(living, TRAIT_ON_ELEVATED_SURFACE, REF(src))) + continue + REMOVE_TRAIT(living, TRAIT_ON_ELEVATED_SURFACE, REF(src)) elevate_mob(living, -pixel_shift) UnregisterSignal(living, COMSIG_LIVING_SET_BUCKLED) return ..() @@ -134,6 +138,7 @@ /datum/element/elevation_core/proc/on_entered(turf/source, atom/movable/entered, atom/old_loc) SIGNAL_HANDLER if((isnull(old_loc) || !HAS_TRAIT_FROM(old_loc, TRAIT_ELEVATED_TURF, REF(src))) && isliving(entered)) + ADD_TRAIT(entered, TRAIT_ON_ELEVATED_SURFACE, REF(src)) var/elevate_time = isturf(old_loc) && source.Adjacent(old_loc) ? ELEVATE_TIME : 0 elevate_mob(entered, elevate_time = elevate_time) RegisterSignal(entered, COMSIG_LIVING_SET_BUCKLED, PROC_REF(on_set_buckled)) @@ -146,6 +151,7 @@ /datum/element/elevation_core/proc/on_exited(turf/source, atom/movable/gone) SIGNAL_HANDLER if((isnull(gone.loc) || !HAS_TRAIT_FROM(gone.loc, TRAIT_ELEVATED_TURF, REF(src))) && isliving(gone)) + REMOVE_TRAIT(gone, TRAIT_ON_ELEVATED_SURFACE, REF(src)) var/elevate_time = isturf(gone.loc) && source.Adjacent(gone.loc) ? ELEVATE_TIME : 0 elevate_mob(gone, -pixel_shift, elevate_time) UnregisterSignal(gone, COMSIG_LIVING_SET_BUCKLED)