Skip to content

Commit

Permalink
[MIRROR] Fixes riding vehicles on tables and lying on beds [MDB IGNOR…
Browse files Browse the repository at this point in the history
…E] (#25374) (#920)

* Fixes riding vehicles on tables and lying on beds (#80053)

## About The Pull Request
Fixes #80027. My bad.
EDIT: Also fixes #80050.

## Why It's Good For The Game
See the issues above.

## Changelog
:cl:
fix: Fixed an issue with the offsets of ridden vehicles on tables, and
another when buckled to a bed.
/:cl:

* Fixes riding vehicles on tables and lying on beds

---------

Co-authored-by: SkyratBot <[email protected]>
Co-authored-by: Ghom <[email protected]>
  • Loading branch information
3 people authored Dec 2, 2023
1 parent 78a9403 commit 6526db5
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 35 deletions.
32 changes: 26 additions & 6 deletions code/datums/elements/elevation.dm
Original file line number Diff line number Diff line change
Expand Up @@ -150,17 +150,37 @@
UnregisterSignal(gone, COMSIG_LIVING_SET_BUCKLED)

/datum/element/elevation_core/proc/elevate_mob(mob/living/target, z_shift = pixel_shift, elevate_time = ELEVATE_TIME)
var/buckled_to_vehicle = FALSE
if(target.buckled)
if(isvehicle(target.buckled))
buckled_to_vehicle = TRUE
else if(!isliving(target.buckled))
return
animate(target, pixel_z = z_shift, time = elevate_time, flags = ANIMATION_RELATIVE|ANIMATION_PARALLEL)
if(target.buckled && isvehicle(target.buckled))
if(buckled_to_vehicle)
animate(target.buckled, pixel_z = z_shift, time = elevate_time, flags = ANIMATION_RELATIVE|ANIMATION_PARALLEL)

///Vehicles or other things the mob is buckled too also are shifted.
/**
* If the mob is buckled or unbuckled to/from a vehicle, shift it up/down
*.
* Null the pixel shift if the mob is buckled to something different that's not a mob or vehicle
*
* The reason is that it's more important for a mob to look like they're actually buckled to a bed
* or something anchored to the floor than atop of whatever else is on the same turf.
*/
/datum/element/elevation_core/proc/on_set_buckled(mob/living/source, atom/movable/new_buckled)
SIGNAL_HANDLER
if(source.buckled && isvehicle(source.buckled))
animate(source.buckled, pixel_z = -pixel_shift, time = ELEVATE_TIME, flags = ANIMATION_RELATIVE|ANIMATION_PARALLEL)
if(new_buckled && isvehicle(new_buckled))
animate(source.buckled, pixel_z = pixel_shift, time = ELEVATE_TIME, flags = ANIMATION_RELATIVE|ANIMATION_PARALLEL)
if(source.buckled)
if(isvehicle(source.buckled))
animate(source.buckled, pixel_z = -pixel_shift, time = ELEVATE_TIME, flags = ANIMATION_RELATIVE|ANIMATION_PARALLEL)
else if(!isliving(source.buckled))
animate(source, pixel_z = -pixel_shift, time = ELEVATE_TIME, flags = ANIMATION_RELATIVE|ANIMATION_PARALLEL)
if(!new_buckled)
return
if(isvehicle(new_buckled))
animate(new_buckled, pixel_z = pixel_shift, time = ELEVATE_TIME, flags = ANIMATION_RELATIVE|ANIMATION_PARALLEL)
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_reset_elevation(turf/source, list/current_values)
SIGNAL_HANDLER
Expand Down
9 changes: 0 additions & 9 deletions code/game/machinery/stasis.dm
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,6 @@
/obj/machinery/stasis/Destroy()
. = ..()

///Just like beds, the elevation looks good while standing, but not when buckled to the bed.
/obj/machinery/stasis/post_buckle_mob(mob/living/buckled)
. = ..()
buckled.pixel_y -= 6

/obj/machinery/stasis/post_unbuckle_mob(mob/living/buckled)
. = ..()
buckled.pixel_y += 6

/obj/machinery/stasis/examine(mob/user)
. = ..()
. += span_notice("Alt-click to [stasis_enabled ? "turn off" : "turn on"] the machine.")
Expand Down
16 changes: 2 additions & 14 deletions code/game/objects/structures/beds_chairs/bed.dm
Original file line number Diff line number Diff line change
Expand Up @@ -67,16 +67,6 @@
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"
Expand Down Expand Up @@ -342,13 +332,11 @@
/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.base_pixel_y += 12
target.pixel_y += 12
target.pixel_y += 6
goldilocks = target

/obj/structure/bed/double/post_unbuckle_mob(mob/living/target)
. = ..()
if(target == goldilocks)
target.base_pixel_y -= 12
target.pixel_y -= 12
target.pixel_y -= 6
goldilocks = null
10 changes: 4 additions & 6 deletions code/game/objects/structures/tables_racks.dm
Original file line number Diff line number Diff line change
Expand Up @@ -766,16 +766,14 @@
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)
/obj/structure/table/optable/post_buckle_mob(mob/living/buckled)
. = ..()
buckled.base_pixel_y -= 6
buckled.pixel_y -= 6
buckled.pixel_y += 6

///Disalign the mob with the table when unbuckled.
/obj/structure/bed/post_unbuckle_mob(mob/living/buckled)
/obj/structure/table/optable/post_unbuckle_mob(mob/living/buckled)
. = ..()
buckled.base_pixel_y += 6
buckled.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)
Expand Down

0 comments on commit 6526db5

Please sign in to comment.