Files
SmArtKar 9e8dd8b991 Fixes swimming not draining stamina or wetting/extinguishing players (#94013)
## About The Pull Request
Closes #93973

## Changelog
🆑
fix: Fixed swimming not draining stamina or wetting/extinguishing
players
/🆑
2025-11-20 01:22:15 +01:00

80 lines
2.7 KiB
Plaintext

/datum/element/watery_tile
element_flags = ELEMENT_DETACH_ON_HOST_DESTROY
/// List of atoms that are present in this element's turfs
var/list/atom/movable/wet_dogs = list()
/datum/element/watery_tile/Destroy(force)
wet_dogs = null
return ..()
/datum/element/watery_tile/Attach(turf/target)
. = ..()
if(!isturf(target))
return ELEMENT_INCOMPATIBLE
RegisterSignals(target, list(COMSIG_ATOM_ENTERED, COMSIG_ATOM_AFTER_SUCCESSFUL_INITIALIZED_ON), PROC_REF(enter_water))
RegisterSignal(target, COMSIG_ATOM_EXITED, PROC_REF(out_of_water))
for(var/atom/movable/movable as anything in target.contents)
if(!(movable.flags_1 & INITIALIZED_1) || movable.invisibility >= INVISIBILITY_OBSERVER) //turfs initialize before movables
continue
enter_water(target, movable)
/datum/element/watery_tile/Detach(turf/source)
UnregisterSignal(source, list(COMSIG_ATOM_ENTERED, COMSIG_ATOM_AFTER_SUCCESSFUL_INITIALIZED_ON, COMSIG_ATOM_EXITED))
for(var/atom/movable/movable as anything in source.contents)
out_of_water(source, movable)
return ..()
/datum/element/watery_tile/proc/enter_water(atom/source, atom/movable/entered)
SIGNAL_HANDLER
if(QDELETED(entered) || HAS_TRAIT(entered, TRAIT_WALLMOUNTED))
return
if(HAS_TRAIT(entered, TRAIT_IMMERSED))
dip_in(entered)
if(entered in wet_dogs)
return
RegisterSignal(entered, SIGNAL_ADDTRAIT(TRAIT_IMMERSED), PROC_REF(dip_in))
RegisterSignal(entered, COMSIG_QDELETING, PROC_REF(on_content_del))
if(isliving(entered))
RegisterSignal(entered, SIGNAL_REMOVETRAIT(TRAIT_IMMERSED), PROC_REF(dip_out))
wet_dogs |= entered
/datum/element/watery_tile/proc/dip_in(atom/movable/source)
SIGNAL_HANDLER
source.extinguish()
if(!isliving(source))
return
var/mob/living/our_mob = source
our_mob.adjust_wet_stacks(3)
our_mob.apply_status_effect(/datum/status_effect/watery_tile_wetness)
/datum/element/watery_tile/proc/out_of_water(atom/source, atom/movable/gone)
SIGNAL_HANDLER
on_content_del(gone)
if(isliving(gone))
dip_out(gone)
/datum/element/watery_tile/proc/on_content_del(atom/movable/source)
SIGNAL_HANDLER
UnregisterSignal(source, list(SIGNAL_ADDTRAIT(TRAIT_IMMERSED), SIGNAL_REMOVETRAIT(TRAIT_IMMERSED), COMSIG_QDELETING))
wet_dogs -= source
/datum/element/watery_tile/proc/dip_out(mob/living/source)
SIGNAL_HANDLER
source.remove_status_effect(/datum/status_effect/watery_tile_wetness)
///Added by the watery_tile element. Keep adding wet stacks over time until removed from the watery turf.
/datum/status_effect/watery_tile_wetness
id = "watery_tile_wetness"
alert_type = null
duration = STATUS_EFFECT_PERMANENT
status_type = STATUS_EFFECT_UNIQUE
/datum/status_effect/watery_tile_wetness/tick(seconds_between_ticks)
. = ..()
owner.adjust_wet_stacks(1)