Standing on structures such as crates, tables and bed will now look like it. (#79797)

## About The Pull Request
From the creator of 'cosmetic' elements such as footstep_override and
immerse...

I've made an element called elevation that nudges mobs a few pixels up
while standing on things like tables, crates and beds.

Screenshots of many clones of the same character standing on different
objects:
![the clone
army](https://github.com/tgstation/tgstation/assets/42542238/43ecdc25-f0d2-47fd-96dc-acafcf63483c)

## Why It's Good For The Game
It makes it look like the mob is actually standing on an elevated
surface.

## Changelog

🆑
add: Standing on structures such as crates, tables and bed will now look
like it.
/🆑
This commit is contained in:
Ghom
2023-11-28 23:44:54 +01:00
committed by GitHub
parent 60cf2629e5
commit 837ddf7d00
24 changed files with 301 additions and 34 deletions
@@ -13,6 +13,7 @@
canSmoothWith = SMOOTH_GROUP_ALIEN_NEST
build_stack_type = null
flags_1 = NODECONSTRUCT_1
elevation = 0
var/static/mutable_appearance/nest_overlay = mutable_appearance('icons/mob/nonhuman-player/alien.dmi', "nestoverlay", LYING_MOB_LAYER)
/obj/structure/bed/nest/user_unbuckle_mob(mob/living/buckled_mob, mob/living/user)
@@ -22,10 +22,14 @@
var/build_stack_type = /obj/item/stack/sheet/iron
/// How many mats to drop when deconstructed
var/build_stack_amount = 2
/// Mobs standing on it are nudged up by this amount. Also used to align the person back when buckled to it after init.
var/elevation = 8
/obj/structure/bed/Initialize(mapload)
. = ..()
AddElement(/datum/element/soft_landing)
if(elevation)
AddElement(/datum/element/elevation, pixel_shift = elevation)
register_context()
/obj/structure/bed/examine(mob/user)
@@ -63,6 +67,16 @@
deconstruct(disassembled = TRUE)
return TRUE
/obj/structure/bed/post_buckle_mob(mob/living/buckled)
. = ..()
buckled.base_pixel_y -= elevation
buckled.pixel_y -= elevation
/obj/structure/bed/post_unbuckle_mob(mob/living/buckled)
. = ..()
buckled.base_pixel_y += elevation
buckled.pixel_y += elevation
/// Medical beds
/obj/structure/bed/medical
name = "medical bed"
@@ -74,6 +88,7 @@
resistance_flags = NONE
build_stack_type = /obj/item/stack/sheet/mineral/titanium
build_stack_amount = 1
elevation = 0
/// The item it spawns when it's folded up.
var/foldable_type
@@ -117,11 +132,13 @@
balloon_alert(user, "brakes [anchored ? "applied" : "released"]")
update_appearance()
/obj/structure/bed/medical/post_buckle_mob(mob/living/patient)
/obj/structure/bed/medical/post_buckle_mob(mob/living/buckled)
. = ..()
set_density(TRUE)
update_appearance()
/obj/structure/bed/medical/post_unbuckle_mob(mob/living/patient)
/obj/structure/bed/medical/post_unbuckle_mob(mob/living/buckled)
. = ..()
set_density(FALSE)
update_appearance()
@@ -135,7 +152,6 @@
patient.pixel_y = patient.base_pixel_y
else
buckled_mobs[1].pixel_y = buckled_mobs[1].base_pixel_y
else
icon_state = "[base_icon_state]_down"
@@ -257,6 +273,7 @@
anchored = FALSE
build_stack_type = /obj/item/stack/sheet/mineral/wood
build_stack_amount = 10
elevation = 0
var/owned = FALSE
/obj/structure/bed/dogbed/ian
@@ -306,6 +323,7 @@
name = "dirty mattress"
desc = "An old grubby mattress. You try to not think about what could be the cause of those stains."
icon_state = "dirty_mattress"
elevation = 7
/obj/structure/bed/maint/Initialize(mapload)
. = ..()
@@ -322,11 +340,15 @@
var/mob/living/goldilocks
/obj/structure/bed/double/post_buckle_mob(mob/living/target)
. = ..()
if(buckled_mobs.len > 1 && !goldilocks) // Push the second buckled mob a bit higher from the normal lying position
target.pixel_y = target.base_pixel_y + 6
target.base_pixel_y += 12
target.pixel_y += 12
goldilocks = target
/obj/structure/bed/double/post_unbuckle_mob(mob/living/target)
target.pixel_y = target.base_pixel_y + target.body_position_pixel_y_offset
. = ..()
if(target == goldilocks)
target.base_pixel_y -= 12
target.pixel_y -= 12
goldilocks = null
@@ -18,7 +18,13 @@
drag_slowdown = 0
door_anim_time = 0 // no animation
pass_flags_self = PASSSTRUCTURE | LETPASSTHROW
var/crate_climb_time = 20
/// Mobs standing on it are nudged up by this amount.
var/elevation = 14
/// The same, but when the crate is open
var/elevation_open = 14
/// The time spent to climb this crate.
var/crate_climb_time = 2 SECONDS
/// The reference of the manifest paper attached to the cargo crate.
var/obj/item/paper/fluff/jobs/cargo/manifest/manifest
/// Where the Icons for lids are located.
var/lid_icon = 'icons/obj/storage/crates.dmi'
@@ -31,6 +37,8 @@
/obj/structure/closet/crate/Initialize(mapload)
AddElement(/datum/element/climbable, climb_time = crate_climb_time, climb_stun = 0) //add element in closed state before parent init opens it(if it does)
if(elevation)
AddElement(/datum/element/elevation, pixel_shift = elevation)
. = ..()
var/static/list/crate_paint_jobs
@@ -102,6 +110,11 @@
. = ..()
RemoveElement(/datum/element/climbable, climb_time = crate_climb_time, climb_stun = 0)
AddElement(/datum/element/climbable, climb_time = crate_climb_time * 0.5, climb_stun = 0)
if(elevation != elevation_open)
if(elevation)
RemoveElement(/datum/element/elevation, pixel_shift = elevation)
if(elevation_open)
AddElement(/datum/element/elevation, pixel_shift = elevation_open)
if(!QDELETED(manifest))
playsound(src, 'sound/items/poster_ripped.ogg', 75, TRUE)
manifest.forceMove(get_turf(src))
@@ -112,6 +125,11 @@
. = ..()
RemoveElement(/datum/element/climbable, climb_time = crate_climb_time * 0.5, climb_stun = 0)
AddElement(/datum/element/climbable, climb_time = crate_climb_time, climb_stun = 0)
if(elevation != elevation_open)
if(elevation_open)
RemoveElement(/datum/element/elevation, pixel_shift = elevation_open)
if(elevation)
AddElement(/datum/element/elevation, pixel_shift = elevation)
/obj/structure/closet/crate/proc/tear_manifest(mob/user)
to_chat(user, span_notice("You tear the manifest off of [src]."))
@@ -142,6 +160,7 @@
close_sound_volume = 50
can_install_electronics = FALSE
paint_jobs = null
elevation_open = 0
/obj/structure/closet/crate/maint
@@ -177,6 +196,8 @@
desc = "A large cart for hauling around large amounts of laundry."
icon_state = "laundry"
base_icon_state = "laundry"
elevation = 14
elevation_open = 14
/obj/structure/closet/crate/trashcart/Initialize(mapload)
. = ..()
@@ -10,6 +10,8 @@
delivery_icon = null
can_install_electronics = FALSE
paint_jobs = null
elevation = 17
elevation_open = 17
/obj/structure/closet/crate/bin/LateInitialize()
. = ..()
@@ -15,6 +15,8 @@
close_sound_volume = 50
contents_pressure_protection = 0.8
can_install_electronics = FALSE
elevation = 21
elevation_open = 0
var/obj/item/tank/internals/emergency_oxygen/tank
@@ -14,6 +14,7 @@
open_sound_volume = 25
close_sound_volume = 50
can_install_electronics = FALSE
elevation = 22
// Stops people from "diving into" a crate you can't open normally
divable = FALSE
+22 -8
View File
@@ -29,8 +29,6 @@
smoothing_flags = SMOOTH_BITMASK
smoothing_groups = SMOOTH_GROUP_TABLES
canSmoothWith = SMOOTH_GROUP_TABLES
///TRUE if the table can be climbed on and have living mobs placed on it normally, FALSE otherwise
var/climbable = TRUE
var/frame = /obj/structure/table_frame
var/framestack = /obj/item/stack/rods
var/glass_shard_type = /obj/item/shard
@@ -46,8 +44,7 @@
buildstack = _buildstack
AddElement(/datum/element/footstep_override, priority = STEP_SOUND_TABLE_PRIORITY)
if (climbable)
AddElement(/datum/element/climbable)
make_climbable()
var/static/list/loc_connections = list(
COMSIG_CARBON_DISARM_COLLIDE = PROC_REF(table_carbon),
@@ -58,6 +55,11 @@
AddElement(/datum/element/give_turf_traits, give_turf_traits)
register_context()
///Adds the element used to make the object climbable, and also the one that shift the mob buckled to it up.
/obj/structure/table/proc/make_climbable()
AddElement(/datum/element/climbable)
AddElement(/datum/element/elevation, pixel_shift = 12)
/obj/structure/table/add_context(atom/source, list/context, obj/item/held_item, mob/living/user)
. = ..()
@@ -730,9 +732,8 @@
smoothing_flags = NONE
smoothing_groups = null
canSmoothWith = null
can_buckle = 1
can_buckle = TRUE
buckle_lying = 90
climbable = FALSE
custom_materials = list(/datum/material/silver =SHEET_MATERIAL_AMOUNT)
var/mob/living/carbon/patient = null
var/obj/machinery/computer/operating/computer = null
@@ -756,11 +757,26 @@
UnregisterSignal(loc, COMSIG_ATOM_EXITED)
return ..()
/obj/structure/table/optable/make_climbable()
AddElement(/datum/element/elevation, pixel_shift = 12)
/obj/structure/table/optable/tablepush(mob/living/user, mob/living/pushed_mob)
pushed_mob.forceMove(loc)
pushed_mob.set_resting(TRUE, TRUE)
visible_message(span_notice("[user] lays [pushed_mob] on [src]."))
///Align the mob with the table when buckled.
/obj/structure/bed/post_buckle_mob(mob/living/buckled)
. = ..()
buckled.base_pixel_y -= 6
buckled.pixel_y -= 6
///Disalign the mob with the table when unbuckled.
/obj/structure/bed/post_unbuckle_mob(mob/living/buckled)
. = ..()
buckled.base_pixel_y += 6
buckled.pixel_y += 6
/// Any mob that enters our tile will be marked as a potential patient. They will be turned into a patient if they lie down.
/obj/structure/table/optable/proc/mark_patient(datum/source, mob/living/carbon/potential_patient)
SIGNAL_HANDLER
@@ -768,7 +784,6 @@
return
RegisterSignal(potential_patient, COMSIG_LIVING_SET_BODY_POSITION, PROC_REF(recheck_patient))
recheck_patient(potential_patient) // In case the mob is already lying down before they entered.
potential_patient.pixel_y = potential_patient.base_pixel_y
/// Unmark the potential patient.
/obj/structure/table/optable/proc/unmark_patient(datum/source, mob/living/carbon/potential_patient)
@@ -778,7 +793,6 @@
if(potential_patient == patient)
recheck_patient(patient) // Can just set patient to null, but doing the recheck lets us find a replacement patient.
UnregisterSignal(potential_patient, COMSIG_LIVING_SET_BODY_POSITION)
potential_patient.pixel_y = potential_patient.base_pixel_y + potential_patient.body_position_pixel_y_offset
/// Someone on our tile just lied down, got up, moved in, or moved out.
/// potential_patient is the mob that had one of those four things change.
@@ -20,6 +20,7 @@
init_tube_dirs()
update_appearance()
AddElement(/datum/element/climbable)
AddElement(/datum/element/elevation, pixel_shift = 12)
/obj/structure/transit_tube/Destroy()
for(var/obj/structure/transit_tube_pod/P in loc)