Files
Bubberstation/code/datums/elements/footstep_override.dm
Jacquerel 7146a6bb10 Platforms (#91559)
## About The Pull Request


![image](https://github.com/user-attachments/assets/32a5f39a-59b8-46c3-8418-1a089379d6a4)

This PR adds "platforms" to the game, a port of the window frames from
the Wallening branch but with no windows attached.
You can craft them with two stacks of many kinds of materials.
Functionally they're basically just tables for standing on and act as a
decorative tool allowing you to make raised areas like stages.
Largely as far as I can tell I _think_ these were sprited by @Krysonism
although it's a little hard to check if there's any that were done by
someone else.

You can walk directly from tables to platforms (and crates) and vice
versa. You can also tableslam people onto them.

This PR also comes with "steps" (AKA small stairs)
You can use steps to walk onto platforms (or tables, or crates) without
needing to do the climbing action first.

![dreamseeker_umhbakZ4lE](https://github.com/user-attachments/assets/675e815b-8901-49d2-81b1-64ef7a56cd31)
If you try to run through them the wrong way you will trip.
Right now they only come in "Iron" flavour. Maybe one day someone will
sprite some wooden ones, or other varieties.

Basically the intention is to use them to build a little stage or altar
or maze or something. They don't have a lot of non-decorative purpose.

Don't be alarmed by the touched files list. It's mostly sprites and
there's barely even any code in this PR. It's almost entirely elements
and boilerplate.

## Why It's Good For The Game

Mappers keep asking me to add these.
Salvages some sprites from the Wallening project which we can still use.
You can make a really really big multitile pizza.

## Changelog

🆑 Jacquerel, Smartkar, sprites by Kryson
add: Added "platforms", or "half-walls" which are a kind of decorative
block similar to tables which you can walk around on.
add: You can walk freely between tables, platforms, and crates that
happen to be near tables or platforms.
add: You can construct iron steps to traverse tables and platforms
without needing to climb on, but try not to trip over them.
/🆑

---------

Co-authored-by: Time-Green <7501474+Time-Green@users.noreply.github.com>
2025-07-11 07:21:02 +00:00

83 lines
3.2 KiB
Plaintext

///When attached, the footstep sound played by the footstep element will be replaced by this one's
/datum/element/footstep_override
element_flags = ELEMENT_BESPOKE|ELEMENT_DETACH_ON_HOST_DESTROY
argument_hash_start_idx = 2
///The sound played for movables with claw step sound type.
var/clawfootstep
///The sound played for movables with barefoot step sound type.
var/barefootstep
///The sound played for movables with heavy step sound type.
var/heavyfootstep
///The sound played for movables with shoed step sound type.
var/footstep
///The priority this element has in relation to other elements of the same type attached to other movables on the same turf.
var/priority
/**
* A list of turfs occupied by the movables this element is attached to.
* Needed so it stops listening the turf's signals ONLY when it has no movable with the element.
*/
var/list/occupied_turfs = list()
/datum/element/footstep_override/Attach(atom/movable/target, clawfootstep = FOOTSTEP_HARD_CLAW, barefootstep = FOOTSTEP_HARD_BAREFOOT, heavyfootstep = FOOTSTEP_GENERIC_HEAVY, footstep = FOOTSTEP_FLOOR, priority = STEP_SOUND_NO_PRIORITY)
. = ..()
if(!ismovable(target))
return ELEMENT_INCOMPATIBLE
src.clawfootstep = clawfootstep
src.barefootstep = barefootstep
src.heavyfootstep = heavyfootstep
src.footstep = footstep
src.priority = priority
RegisterSignal(target, COMSIG_MOVABLE_MOVED, PROC_REF(on_moved))
if(isturf(target.loc))
occupy_turf(target, target.loc)
/datum/element/footstep_override/Detach(atom/movable/source)
UnregisterSignal(source, COMSIG_MOVABLE_MOVED)
if(isturf(source.loc))
vacate_turf(source, source.loc)
return ..()
/datum/element/footstep_override/proc/on_moved(atom/movable/source, atom/oldloc)
SIGNAL_HANDLER
if(isturf(oldloc))
vacate_turf(source, oldloc)
if(isturf(source.loc))
occupy_turf(source, source.loc)
/**
* Adds the movable to the list of movables with the element occupying the turf.
* If the turf was not on the list of occupied turfs before, a signal will be registered
* to it.
*/
/datum/element/footstep_override/proc/occupy_turf(atom/movable/movable, turf/location)
if(occupied_turfs[location])
occupied_turfs[location] |= movable
return
occupied_turfs[location] = list(movable)
RegisterSignal(location, COMSIG_TURF_PREPARE_STEP_SOUND, PROC_REF(prepare_steps))
/**
* Removes the movable from the list of movables with the element occupying the turf.
* If the turf is no longer occupied, it'll be removed from the list, and the signal
* unregistered from it
*/
/datum/element/footstep_override/proc/vacate_turf(atom/movable/movable, turf/location)
LAZYREMOVE(occupied_turfs[location], movable)
if(!occupied_turfs[location])
occupied_turfs -= location
UnregisterSignal(location, COMSIG_TURF_PREPARE_STEP_SOUND)
///Changes the sound types to be played if the element priority is higher than the one in the steps list.
/datum/element/footstep_override/proc/prepare_steps(turf/source, list/steps)
SIGNAL_HANDLER
if(steps[STEP_SOUND_PRIORITY] > priority)
return
steps[FOOTSTEP_MOB_SHOE] = footstep
steps[FOOTSTEP_MOB_BAREFOOT] = barefootstep
steps[FOOTSTEP_MOB_HEAVY] = heavyfootstep
steps[FOOTSTEP_MOB_CLAW] = clawfootstep
steps[STEP_SOUND_PRIORITY] = priority
return FOOTSTEP_OVERRIDEN