Files
Bubberstation/code/datums/components/direct_explosive_trap.dm
Alexis 21b4095dfd [MDB IGNORE] [IDB IGNORE] Upstream Sync - 04/17/2026 (#5453)
Upstream 04/17/2026

fixes https://github.com/Bubberstation/Bubberstation/issues/5549

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: tgstation-ci[bot] <179393467+tgstation-ci[bot]@users.noreply.github.com>
Co-authored-by: ArcaneMusic <41715314+ArcaneMusic@users.noreply.github.com>
Co-authored-by: MrMelbert <51863163+MrMelbert@users.noreply.github.com>
Co-authored-by: Rhials <28870487+Rhials@users.noreply.github.com>
Co-authored-by: rageguy505 <54517726+rageguy505@users.noreply.github.com>
Co-authored-by: LemonInTheDark <58055496+LemonInTheDark@users.noreply.github.com>
Co-authored-by: John Willard <53777086+JohnFulpWillard@users.noreply.github.com>
Co-authored-by: Aliceee2ch <160794176+Aliceee2ch@users.noreply.github.com>
Co-authored-by: Time-Green <7501474+Time-Green@users.noreply.github.com>
Co-authored-by: Tsar-Salat <62388554+Tsar-Salat@users.noreply.github.com>
Co-authored-by: SmArtKar <44720187+SmArtKar@users.noreply.github.com>
Co-authored-by: Maxipat <108554989+Maxipat112@users.noreply.github.com>
Co-authored-by: SyncIt21 <110812394+SyncIt21@users.noreply.github.com>
Co-authored-by: deltanedas <39013340+deltanedas@users.noreply.github.com>
Co-authored-by: SimplyLogan <47579821+loganuk@users.noreply.github.com>
Co-authored-by: loganuk <fakeemail123@aol.com>
Co-authored-by: Leland Kemble <70413276+lelandkemble@users.noreply.github.com>
Co-authored-by: FalloutFalcon <86381784+FalloutFalcon@users.noreply.github.com>
Co-authored-by: Roxy <75404941+TealSeer@users.noreply.github.com>
Co-authored-by: Lucy <lucy@absolucy.moe>
Co-authored-by: siliconOpossum <138069572+siliconOpossum@users.noreply.github.com>
Co-authored-by: Isratosh <Isratosh@hotmail.com>
Co-authored-by: TheRyeGuyWhoWillNowDie <70169560+TheRyeGuyWhoWillNowDie@users.noreply.github.com>
Co-authored-by: Neocloudy <88008002+Neocloudy@users.noreply.github.com>
Co-authored-by: Alexander V. <volas@ya.ru>
Co-authored-by: ElGitificador <168473461+ElGitificador@users.noreply.github.com>
Co-authored-by: Twaticus <46540570+Twaticus@users.noreply.github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Bloop <13398309+vinylspiders@users.noreply.github.com>
Co-authored-by: Cameron Lennox <killer65311@gmail.com>
Co-authored-by: Tim <timothymtorres@gmail.com>
Co-authored-by: Iamgoofball <iamgoofball@gmail.com>
Co-authored-by: Layzu666 <121319428+Layzu666@users.noreply.github.com>
Co-authored-by: Arturlang <24881678+Arturlang@users.noreply.github.com>
Co-authored-by: _0Steven <42909981+00-Steven@users.noreply.github.com>
Co-authored-by: mrmanlikesbt <99309552+mrmanlikesbt@users.noreply.github.com>
Co-authored-by: Ben10Omintrix <138636438+Ben10Omintrix@users.noreply.github.com>
Co-authored-by: John F. Kennedy <54908920+MacaroniCritter@users.noreply.github.com>
Co-authored-by: Cursor <102828457+theselfish@users.noreply.github.com>
Co-authored-by: Josh <josh.adam.powell@gmail.com>
Co-authored-by: Josh Powell <josh.powell@softwire.com>
Co-authored-by: Yobrocharlie <Charliemiller5617@gmail.com>
Co-authored-by: Hardly3D <66234359+Hardly3D@users.noreply.github.com>
Co-authored-by: shayoki <96078776+shayoki@users.noreply.github.com>
Co-authored-by: LT3 <83487515+lessthnthree@users.noreply.github.com>
2026-05-16 00:56:00 +02:00

90 lines
3.8 KiB
Plaintext

/**
* Responds to certain signals and 'explodes' on the person using the item.
* Differs from `interaction_booby_trap` in that this doesn't actually explode, it just directly calls ex_act on one person.
*/
/datum/component/direct_explosive_trap
/// An optional mob to inform about explosions
var/mob/living/saboteur
/// Amount of force to apply
var/explosive_force
/// Colour for examine notification
var/glow_colour
/// Optional additional target checks before we go off
var/datum/callback/explosive_checks
/// Signals which set off the bomb, must pass a mob as the first non-source argument
var/list/triggering_signals
/datum/component/direct_explosive_trap/Initialize(
mob/living/saboteur,
explosive_force = EXPLODE_HEAVY,
expire_time = 1 MINUTES,
glow_colour = COLOR_RED,
datum/callback/explosive_checks,
list/triggering_signals = list(COMSIG_ATOM_ATTACKBY, COMSIG_ATOM_ATTACK_HAND, COMSIG_ATOM_BUMPED)
)
. = ..()
if (!isatom(parent))
return COMPONENT_INCOMPATIBLE
src.saboteur = saboteur
src.explosive_force = explosive_force
src.glow_colour = glow_colour
src.explosive_checks = explosive_checks
src.triggering_signals = triggering_signals
if (expire_time > 0)
addtimer(CALLBACK(src, PROC_REF(bomb_expired)), expire_time, TIMER_DELETE_ME)
/datum/component/direct_explosive_trap/RegisterWithParent()
if (!(COMSIG_ATOM_EXAMINE in triggering_signals)) // Maybe you're being extra mean with this one
RegisterSignal(parent, COMSIG_ATOM_EXAMINE, PROC_REF(on_examined))
RegisterSignals(parent, triggering_signals, PROC_REF(explode))
if (!isnull(saboteur))
RegisterSignal(saboteur, COMSIG_QDELETING, PROC_REF(on_bomber_deleted))
log_bomber(saboteur, "has set a direct_explosive_trap with severity [explosive_force] on", parent, "to detonate on the signals [english_list(triggering_signals)]", message_admins = (!isnull(saboteur)))
/datum/component/direct_explosive_trap/UnregisterFromParent()
UnregisterSignal(parent, list(COMSIG_ATOM_EXAMINE) + triggering_signals)
if (!isnull(saboteur))
UnregisterSignal(saboteur, COMSIG_QDELETING)
/datum/component/direct_explosive_trap/Destroy(force)
if (isnull(saboteur))
return ..()
UnregisterSignal(saboteur, COMSIG_QDELETING)
saboteur = null
return ..()
/// Called if we sit too long without going off
/datum/component/direct_explosive_trap/proc/bomb_expired()
if (!isnull(saboteur))
to_chat(saboteur, span_bolddanger("Failure! Your trap didn't catch anyone this time..."))
qdel(src)
/// Let people know something is up
/datum/component/direct_explosive_trap/proc/on_examined(datum/source, mob/user, text)
SIGNAL_HANDLER
text += span_holoparasite("It glows with a strange <font color=\"[glow_colour]\">light</font>...")
/// Blow up
/datum/component/direct_explosive_trap/proc/explode(atom/source, mob/living/victim)
SIGNAL_HANDLER
if (!isliving(victim))
return
if (!isnull(explosive_checks) && !explosive_checks.Invoke(victim))
return
to_chat(victim, span_bolddanger("[source] was boobytrapped!"))
if (!isnull(saboteur))
to_chat(saboteur, span_bolddanger("Success! Your trap on [source] caught [victim.name]!"))
var/atom/parent_atom = parent
message_admins("Direct EX_ACT explosion with severity [explosive_force] on [ADMIN_LOOKUPFLW(victim)]. Caused by direct_explosive_trap on: [ADMIN_VERBOSEJMP(parent_atom)]. Set by: [key_name(saboteur)].")
log_game("Direct EX_ACT explosion with severity [explosive_force] on [key_name(victim)]. Caused by direct_explosive_trap on: [parent_atom.name] at [AREACOORD(parent_atom)]. Set by: [key_name(saboteur)].")
playsound(source, 'sound/effects/explosion/explosion2.ogg', 200, TRUE)
new /obj/effect/temp_visual/explosion(get_turf(source))
EX_ACT(victim, explosive_force)
qdel(src)
/// Don't hang a reference to the person who placed the bomb
/datum/component/direct_explosive_trap/proc/on_bomber_deleted()
SIGNAL_HANDLER
saboteur = null