Files
SmArtKar f58b8511f0 Refactors effect_system (#94999)
## About The Pull Request

This PR refactors ``effect_system``s to be a bit easier to use by
getting rid of ``set_up``, allowing ``attach()`` to be chained into
``start()`` and refactoring most direct system usages in our code to use
helper procs.

``set_up`` was unnecessary and only existed to allow ``New``'s behavior
to be fully overriden, which is not required if we split
sparks/lightning/steam into a new ``/datum/effect_system/basic`` subtype
which houses the effect spreading behavior. This allows us to roll all
logic from ``set_up`` into ``New`` and cut down on code complexity.
Chaining setup as ``system.attach(src).start()`` also helps a bit in
case no helper method exists

I've added ``do_chem_smoke`` and ``do_foam`` helpers, which respectively
allow chemical smoke or foam to be spawned easily without having to
manually create effect datums and reagent holders.

Also turns out we've had some nonfunctional effect systems which either
never set themselves up, or never started, so I fixed those while I was
at it (mostly by moving them to aforementioned helper procs)

## Why It's Good For The Game

Cleaner code, makes it significantly easier for users to work with. Also
most of our effect system usage was copypasta which was passing booleans
as numbers, while perfectly fine helper procs existed in our code.

## Changelog
🆑
refactor: Refactored sparks, foam, smoke, and other miscellaneous effect
systems.
refactor: Vapes now have consistent rigging with cigs using the new
system.
fix: Fixed some effects never working.
/🆑
2026-02-03 22:23:09 -05:00

77 lines
2.4 KiB
Plaintext

#define EXPOSED_VOLUME 1000
#define ROOM_TEMP 293
#define MIN_FREEZE_TEMP 50
#define MAX_FREEZE_TEMP 1000000
/obj/item/assembly/igniter
name = "igniter"
desc = "A small electronic device able to ignite combustible substances."
icon_state = "igniter"
custom_materials = list(/datum/material/iron=SMALL_MATERIAL_AMOUNT*5, /datum/material/glass=SMALL_MATERIAL_AMOUNT*0.5)
var/datum/effect_system/basic/spark_spread/sparks
heat = 1000
drop_sound = 'sound/items/handling/component_drop.ogg'
pickup_sound = 'sound/items/handling/component_pickup.ogg'
assembly_flags = ASSEMBLY_NO_DUPLICATES
/obj/item/assembly/igniter/suicide_act(mob/living/carbon/user)
user.visible_message(span_suicide("[user] is trying to ignite [user.p_them()]self with \the [src]! It looks like [user.p_theyre()] trying to commit suicide!"))
user.ignite_mob()
return FIRELOSS
/obj/item/assembly/igniter/Initialize(mapload)
. = ..()
sparks = new(src, 2, FALSE)
sparks.attach(src)
/obj/item/assembly/igniter/Destroy()
QDEL_NULL(sparks)
return ..()
/obj/item/assembly/igniter/activate()
if(!..())
return FALSE//Cooldown check
var/turf/location = get_turf(loc)
if(location)
location.hotspot_expose(heat, EXPOSED_VOLUME)
if(holder)
SEND_SIGNAL(holder.loc, COMSIG_IGNITER_ACTIVATE, src)
if(QDELETED(src))
return TRUE
sparks.start()
return TRUE
/obj/item/assembly/igniter/attack_self(mob/user)
// Don't trigger when interacting with assemblies
if (!holder)
activate()
add_fingerprint(user)
/obj/item/assembly/igniter/ignition_effect(atom/A, mob/user)
. = span_notice("[user] fiddles with [src], and manages to light [A].")
activate()
add_fingerprint(user)
//For the Condenser, which functions like the igniter but makes things colder.
/obj/item/assembly/igniter/condenser
name = "condenser"
desc = "A small electronic device able to chill their surroundings."
icon_state = "freezer"
custom_materials = list(/datum/material/iron=SMALL_MATERIAL_AMOUNT*2.5, /datum/material/glass=SMALL_MATERIAL_AMOUNT * 3)
heat = MIN_FREEZE_TEMP
/obj/item/assembly/igniter/condenser/activate()
. = ..()
if(!.)
return //Cooldown check
var/turf/location = get_turf(loc)
if(location)
var/datum/gas_mixture/enviro = location.return_air()
enviro.temperature = clamp(min(ROOM_TEMP, enviro.temperature * 0.85), MIN_FREEZE_TEMP, MAX_FREEZE_TEMP)
location.air_update_turf(FALSE, FALSE)
#undef EXPOSED_VOLUME
#undef ROOM_TEMP
#undef MIN_FREEZE_TEMP
#undef MAX_FREEZE_TEMP