Files
Bubberstation/code/datums/elements/tool_flash.dm
SkyratBot 126c293dff [MIRROR] Fixes tool-based flashes being stuck at intensity 1 (#28018)
* Fixes tool-based flashes being stuck at intensity 1 (#83703)

## About The Pull Request
A long-old bug due to the use of `min(flash_strength, 1)`. The intention
was clearly to have the flash be *at least* level 1, because
flash_strength defaults to nothing but can be set to 2. However,
`min(x,y)` uses the lowest value, making it always return 1. So we
change it to `max()`.
## Why It's Good For The Game
Bugfix. Sunglasses users cope.
## Changelog
🆑
fix: Tool-based flashes (read: from welders) are no longer incorrectly
locked at flash level 1. Wear proper PPE!
/🆑

* Fixes tool-based flashes being stuck at intensity 1

---------

Co-authored-by: zxaber <37497534+zxaber@users.noreply.github.com>
2024-06-07 08:05:54 +02:00

38 lines
966 B
Plaintext

/**
* Tool flash bespoke element
*
* Flashes the user when using this tool
*/
/datum/element/tool_flash
element_flags = ELEMENT_BESPOKE
argument_hash_start_idx = 2
/// Strength of the flash
var/flash_strength
/datum/element/tool_flash/Attach(datum/target, flash_strength)
. = ..()
if(!isitem(target))
return ELEMENT_INCOMPATIBLE
src.flash_strength = flash_strength
RegisterSignal(target, COMSIG_TOOL_IN_USE, PROC_REF(prob_flash))
RegisterSignal(target, COMSIG_TOOL_START_USE, PROC_REF(flash))
/datum/element/tool_flash/Detach(datum/source)
. = ..()
UnregisterSignal(source, list(COMSIG_TOOL_IN_USE, COMSIG_TOOL_START_USE))
/datum/element/tool_flash/proc/prob_flash(datum/source, mob/living/user)
SIGNAL_HANDLER
if(prob(90))
return
flash(source, user)
/datum/element/tool_flash/proc/flash(datum/source, mob/living/user)
SIGNAL_HANDLER
if(user && get_dist(get_turf(source), get_turf(user)) <= 1)
user.flash_act(max(flash_strength,1))