mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-30 00:29:02 +01:00
[MIRROR] [NO GBP] Fixes the larva "hide" ability not properly hiding larvas under tables. (#26879)
* [NO GBP] Fixes the larva "hide" ability not properly hiding larvas under tables. (#81921) ## About The Pull Request This PR fixes yet another small issue with elevation. ## Why It's Good For The Game This PR fixes yet another small issue with elevation. ## Changelog 🆑 fix: Fixed the larva "hide" ability not properly hiding larvas under tables. /🆑 * [NO GBP] Fixes the larva "hide" ability not properly hiding larvas under tables. --------- Co-authored-by: Ghom <42542238+Ghommie@users.noreply.github.com>
This commit is contained in:
@@ -509,6 +509,8 @@ Remember to update _globalvars/traits.dm if you're adding/removing/renaming trai
|
||||
|
||||
/// 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"
|
||||
/// Does the mob ignore elevation? (e.g. xeno larvas on hiding)
|
||||
#define TRAIT_IGNORE_ELEVATION "ignore_elevation"
|
||||
|
||||
/// Prevents you from twohanding weapons.
|
||||
#define TRAIT_NO_TWOHANDING "no_twohanding"
|
||||
|
||||
@@ -252,6 +252,7 @@ GLOBAL_LIST_INIT(traits_by_type, list(
|
||||
"TRAIT_HULK" = TRAIT_HULK,
|
||||
"TRAIT_HUSK" = TRAIT_HUSK,
|
||||
"TRAIT_ID_APPRAISER" = TRAIT_ID_APPRAISER,
|
||||
"TRAIT_IGNORE_ELEVATION" = TRAIT_IGNORE_ELEVATION,
|
||||
"TRAIT_IGNOREDAMAGESLOWDOWN" = TRAIT_IGNOREDAMAGESLOWDOWN,
|
||||
"TRAIT_IGNORESLOWDOWN" = TRAIT_IGNORESLOWDOWN,
|
||||
"TRAIT_IGNORING_GRAVITY" = TRAIT_IGNORING_GRAVITY,
|
||||
|
||||
@@ -95,6 +95,7 @@ GLOBAL_LIST_INIT(admin_visible_traits, list(
|
||||
"TRAIT_HIDE_EXTERNAL_ORGANS" = TRAIT_HIDE_EXTERNAL_ORGANS,
|
||||
"TRAIT_HOLY" = TRAIT_HOLY,
|
||||
"TRAIT_HUSK" = TRAIT_HUSK,
|
||||
"TRAIT_IGNORE_ELEVATION" = TRAIT_IGNORE_ELEVATION,
|
||||
"TRAIT_IGNOREDAMAGESLOWDOWN" = TRAIT_IGNOREDAMAGESLOWDOWN,
|
||||
"TRAIT_IGNORESLOWDOWN" = TRAIT_IGNORESLOWDOWN,
|
||||
"TRAIT_ILLITERATE" = TRAIT_ILLITERATE,
|
||||
|
||||
@@ -113,6 +113,8 @@
|
||||
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))
|
||||
RegisterSignal(living, SIGNAL_ADDTRAIT(TRAIT_IGNORE_ELEVATION), PROC_REF(on_ignore_elevation_add))
|
||||
RegisterSignal(living, SIGNAL_REMOVETRAIT(TRAIT_IGNORE_ELEVATION), PROC_REF(on_ignore_elevation_remove))
|
||||
elevate_mob(living)
|
||||
|
||||
/datum/element/elevation_core/Detach(datum/source)
|
||||
@@ -133,7 +135,7 @@
|
||||
continue
|
||||
REMOVE_TRAIT(living, TRAIT_ON_ELEVATED_SURFACE, REF(src))
|
||||
elevate_mob(living, -pixel_shift)
|
||||
UnregisterSignal(living, COMSIG_LIVING_SET_BUCKLED)
|
||||
UnregisterSignal(living, list(COMSIG_LIVING_SET_BUCKLED, SIGNAL_ADDTRAIT(TRAIT_IGNORE_ELEVATION), SIGNAL_REMOVETRAIT(TRAIT_IGNORE_ELEVATION)))
|
||||
return ..()
|
||||
|
||||
/datum/element/elevation_core/proc/on_entered(turf/source, atom/movable/entered, atom/old_loc)
|
||||
@@ -143,6 +145,8 @@
|
||||
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))
|
||||
RegisterSignal(entered, SIGNAL_ADDTRAIT(TRAIT_IGNORE_ELEVATION), PROC_REF(on_ignore_elevation_add))
|
||||
RegisterSignal(entered, SIGNAL_REMOVETRAIT(TRAIT_IGNORE_ELEVATION), PROC_REF(on_ignore_elevation_remove))
|
||||
|
||||
/datum/element/elevation_core/proc/on_initialized_on(turf/source, atom/movable/spawned)
|
||||
SIGNAL_HANDLER
|
||||
@@ -152,15 +156,17 @@
|
||||
/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))
|
||||
// Always unregister the signal, we're still leaving even if already shifted down.
|
||||
UnregisterSignal(gone, COMSIG_LIVING_SET_BUCKLED)
|
||||
// Always unregister the signals, we're still leaving even if not affected by elevation.
|
||||
UnregisterSignal(gone, list(COMSIG_LIVING_SET_BUCKLED, SIGNAL_ADDTRAIT(TRAIT_IGNORE_ELEVATION), SIGNAL_REMOVETRAIT(TRAIT_IGNORE_ELEVATION)))
|
||||
if(!HAS_TRAIT_FROM(gone, TRAIT_ON_ELEVATED_SURFACE, REF(src)))
|
||||
return
|
||||
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)
|
||||
|
||||
/datum/element/elevation_core/proc/elevate_mob(mob/living/target, z_shift = pixel_shift, elevate_time = ELEVATE_TIME)
|
||||
/datum/element/elevation_core/proc/elevate_mob(mob/living/target, z_shift = pixel_shift, elevate_time = ELEVATE_TIME, force = FALSE)
|
||||
if(HAS_TRAIT(target, TRAIT_IGNORE_ELEVATION) && !force)
|
||||
return
|
||||
var/buckled_to_vehicle = FALSE
|
||||
if(target.buckled)
|
||||
if(isvehicle(target.buckled))
|
||||
@@ -181,6 +187,8 @@
|
||||
*/
|
||||
/datum/element/elevation_core/proc/on_set_buckled(mob/living/source, atom/movable/new_buckled)
|
||||
SIGNAL_HANDLER
|
||||
if(HAS_TRAIT(source, TRAIT_IGNORE_ELEVATION))
|
||||
return
|
||||
if(source.buckled)
|
||||
if(isvehicle(source.buckled))
|
||||
animate(source.buckled, pixel_z = -pixel_shift, time = ELEVATE_TIME, flags = ANIMATION_RELATIVE|ANIMATION_PARALLEL)
|
||||
@@ -193,6 +201,14 @@
|
||||
else if(!isliving(new_buckled))
|
||||
animate(source, pixel_z = -pixel_shift, time = ELEVATE_TIME, flags = ANIMATION_RELATIVE|ANIMATION_PARALLEL)
|
||||
|
||||
/datum/element/elevation_core/proc/on_ignore_elevation_add(mob/living/source, trait)
|
||||
SIGNAL_HANDLER
|
||||
elevate_mob(source, -pixel_shift, force = TRUE)
|
||||
|
||||
/datum/element/elevation_core/proc/on_ignore_elevation_remove(mob/living/source, trait)
|
||||
SIGNAL_HANDLER
|
||||
elevate_mob(source, pixel_shift)
|
||||
|
||||
/datum/element/elevation_core/proc/on_reset_elevation(turf/source, list/current_values)
|
||||
SIGNAL_HANDLER
|
||||
current_values[ELEVATION_CURRENT_PIXEL_SHIFT] = pixel_shift
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
span_notice("[owner] slowly peeks up from the ground..."),
|
||||
span_noticealien("You stop hiding."),
|
||||
)
|
||||
ADD_TRAIT(owner, TRAIT_IGNORE_ELEVATION, ACTION_TRAIT)
|
||||
|
||||
else
|
||||
owner.layer = hide_layer
|
||||
@@ -20,6 +21,7 @@
|
||||
span_name("[owner] scurries to the ground!"),
|
||||
span_noticealien("You are now hiding."),
|
||||
)
|
||||
REMOVE_TRAIT(owner, TRAIT_IGNORE_ELEVATION, ACTION_TRAIT)
|
||||
|
||||
return TRUE
|
||||
|
||||
|
||||
Reference in New Issue
Block a user