Skip to content

Commit

Permalink
[MIRROR] Prevents something fucky with elevation and glass tables [MD…
Browse files Browse the repository at this point in the history
…B IGNORE] (#25567)

* Prevents something fucky with elevation and glass tables (#80187)

## About The Pull Request
Objects can be destroyed during a movement loop before the abstract
entered signal can be sent, so we need to make sure only mobs that have
been elevated are dropped down.

## Why It's Good For The Game
Fixes #80169

## Changelog

:cl:
fix: climbing or being shoved into a glass table won't cause elevation
issues.
/:cl:

---------

Co-authored-by: san7890 <the@ san7890.com>

* Prevents something fucky with elevation and glass tables

---------

Co-authored-by: Ghom <[email protected]>
Co-authored-by: san7890 <the@ san7890.com>
  • Loading branch information
3 people authored and FFMirrorBot committed Dec 12, 2023
1 parent 7c4c91f commit 8e0d4e3
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
3 changes: 3 additions & 0 deletions code/__DEFINES/traits/declarations.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions code/_globalvars/traits/_traits.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 6 additions & 0 deletions code/datums/elements/elevation.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -127,13 +128,17 @@
))
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 ..()

/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))
Expand All @@ -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)
Expand Down

0 comments on commit 8e0d4e3

Please sign in to comment.