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.
/🆑
This commit is contained in:
SmArtKar
2026-02-03 22:23:09 -05:00
committed by GitHub
parent b1e6830ec5
commit f58b8511f0
134 changed files with 621 additions and 904 deletions
+7 -39
View File
@@ -233,9 +233,7 @@
use_energy(750 JOULES)
/obj/machinery/rnd/experimentor/proc/throwSmoke(turf/where)
var/datum/effect_system/fluid_spread/smoke/smoke = new
smoke.set_up(0, holder = src, location = where)
smoke.start()
do_smoke(0, src, where)
/obj/machinery/rnd/experimentor/proc/experiment(exp,obj/item/exp_on)
recentlyExperimented = 1
@@ -307,27 +305,15 @@
else if(prob(EFFECT_PROB_VERYLOW * (100 - malfunction_probability_coeff) * 0.01))
visible_message(span_danger("[src] destroys [exp_on], leaking dangerous gas!"))
chosenchem = pick(/datum/reagent/carbon,/datum/reagent/uranium/radium,/datum/reagent/toxin,/datum/reagent/consumable/condensedcapsaicin,/datum/reagent/drug/mushroomhallucinogen,/datum/reagent/drug/space_drugs,/datum/reagent/consumable/ethanol,/datum/reagent/consumable/ethanol/beepsky_smash)
var/datum/reagents/tmp_holder = new/datum/reagents(50)
tmp_holder.my_atom = src
tmp_holder.add_reagent(chosenchem , 50)
do_chem_smoke(0, src, loc, chosenchem, 50)
investigate_log("Experimentor has released [chosenchem] smoke.", INVESTIGATE_EXPERIMENTOR)
var/datum/effect_system/fluid_spread/smoke/chem/smoke = new
smoke.set_up(0, holder = src, location = src, carry = tmp_holder, silent = TRUE)
playsound(src, 'sound/effects/smoke.ogg', 50, TRUE, -3)
smoke.start()
qdel(tmp_holder)
ejectItem(TRUE)
else if(prob(EFFECT_PROB_VERYLOW * (100 - malfunction_probability_coeff) * 0.01))
visible_message(span_danger("[src]'s chemical chamber has sprung a leak!"))
chosenchem = pick(/datum/reagent/mutationtoxin/classic,/datum/reagent/cyborg_mutation_nanomachines,/datum/reagent/toxin/acid)
var/datum/reagents/tmp_holder = new/datum/reagents(50)
tmp_holder.my_atom = src
tmp_holder.add_reagent(chosenchem , 50)
var/datum/effect_system/fluid_spread/smoke/chem/smoke = new
smoke.set_up(0, holder = src, location = src, carry = tmp_holder, silent = TRUE)
do_chem_smoke(0, src, loc, chosenchem, 50)
playsound(src, 'sound/effects/smoke.ogg', 50, TRUE, -3)
smoke.start()
qdel(tmp_holder)
ejectItem(TRUE)
warn_admins(usr, "[chosenchem] smoke")
investigate_log("Experimentor has released <font color='red'>[chosenchem]</font> smoke!", INVESTIGATE_EXPERIMENTOR)
@@ -398,15 +384,9 @@
investigate_log("Experimentor has made a cup of [chosenchem] coffee.", INVESTIGATE_EXPERIMENTOR)
else if(prob(EFFECT_PROB_VERYLOW * (100 - malfunction_probability_coeff) * 0.01))
visible_message(span_danger("[src] malfunctions, shattering [exp_on] and releasing a dangerous cloud of coolant!"))
var/datum/reagents/tmp_holder = new/datum/reagents(50)
tmp_holder.my_atom = src
tmp_holder.add_reagent(/datum/reagent/consumable/frostoil, 50)
do_chem_smoke(0, src, loc, /datum/reagent/consumable/frostoil, 50)
investigate_log("Experimentor has released frostoil gas.", INVESTIGATE_EXPERIMENTOR)
var/datum/effect_system/fluid_spread/smoke/chem/smoke = new
smoke.set_up(0, holder = src, location = src, carry = tmp_holder, silent = TRUE)
playsound(src, 'sound/effects/smoke.ogg', 50, TRUE, -3)
smoke.start()
qdel(tmp_holder)
ejectItem(TRUE)
else if(prob(EFFECT_PROB_LOW * (100 - malfunction_probability_coeff) * 0.01))
visible_message(span_warning("[src] malfunctions, shattering [exp_on] and leaking cold air!"))
@@ -419,9 +399,7 @@
ejectItem(TRUE)
else if(prob(EFFECT_PROB_MEDIUM * (100 - malfunction_probability_coeff) * 0.01))
visible_message(span_warning("[src] malfunctions, releasing a flurry of chilly air as [exp_on] pops out!"))
var/datum/effect_system/fluid_spread/smoke/smoke = new
smoke.set_up(0, holder = src, location = loc)
smoke.start()
do_smoke(0, src, loc)
ejectItem()
////////////////////////////////////////////////////////////////////////////////////////////////
if(exp == SCANTYPE_OBLITERATE)
@@ -571,19 +549,11 @@
COOLDOWN_DECLARE(cooldown)
//What visual theme this artefact has. Current possible choices: "prototype", "necrotech"
var/artifact_theme = "prototype"
var/datum/effect_system/spark_spread/sparks
/obj/item/relic/Initialize(mapload)
. = ..()
sparks = new()
sparks.set_up(5, 1, src)
sparks.attach(src)
random_themed_appearance()
/obj/item/relic/Destroy(force)
QDEL_NULL(sparks)
. = ..()
/obj/item/relic/proc/random_themed_appearance()
var/themed_name_prefix
var/themed_name_suffix
@@ -642,9 +612,7 @@
call(src, hidden_power)(user)
/obj/item/relic/proc/throw_smoke(turf/where)
var/datum/effect_system/fluid_spread/smoke/smoke = new
smoke.set_up(0, holder = src, location = get_turf(where))
smoke.start()
do_smoke(0, src, get_turf(where))
// Artefact Powers \\
@@ -740,7 +708,7 @@
/obj/item/relic/proc/drink_dispenser(mob/user)
var/obj/item/reagent_containers/cup/glass/drinkingglass/freebie = new(get_step_rand(user))
playsound(freebie, SFX_SPARKS, rand(25,50), TRUE, SHORT_RANGE_SOUND_EXTRARANGE)
sparks.start()
do_sparks(5, TRUE, src, src)
addtimer(CALLBACK(src, PROC_REF(dispense_drink), freebie), 0.5 SECONDS)
/obj/item/relic/proc/dispense_drink(obj/item/reagent_containers/cup/glass/glasser)
@@ -45,12 +45,7 @@ Burning extracts:
/obj/item/slimecross/burning/orange/do_effect(mob/user)
user.visible_message(span_danger("[src] boils over with a caustic gas!"))
var/datum/reagents/tmp_holder = new/datum/reagents(100)
tmp_holder.add_reagent(/datum/reagent/consumable/condensedcapsaicin, 100)
var/datum/effect_system/fluid_spread/smoke/chem/smoke = new
smoke.set_up(7, holder = src, location = get_turf(user), carry = tmp_holder)
smoke.start(log = TRUE)
do_chem_smoke(7, user, get_turf(user), /datum/reagent/consumable/condensedcapsaicin, 100, log = TRUE)
..()
/obj/item/slimecross/burning/purple
@@ -120,12 +115,8 @@ Burning extracts:
/obj/item/slimecross/burning/darkblue/do_effect(mob/user)
user.visible_message(span_danger("[src] releases a burst of chilling smoke!"))
var/datum/reagents/tmp_holder = new/datum/reagents(100)
tmp_holder.add_reagent(/datum/reagent/consumable/frostoil, 40)
user.reagents.add_reagent(/datum/reagent/medicine/regen_jelly, 10)
var/datum/effect_system/fluid_spread/smoke/chem/smoke = new
smoke.set_up(7, holder = src, location = get_turf(user), carry = tmp_holder)
smoke.start(log = TRUE)
do_chem_smoke(7, user, get_turf(user), /datum/reagent/consumable/frostoil, 40, log = TRUE)
..()
/obj/item/slimecross/burning/silver
@@ -97,9 +97,7 @@
new /obj/effect/gibspawner/generic(get_turf(vat)) //Spawn some gibs.
/datum/micro_organism/cell_line/proc/succeed_growing(obj/machinery/vatgrower/vat)
var/datum/effect_system/fluid_spread/smoke/smoke = new
smoke.set_up(0, holder = vat, location = vat.loc)
smoke.start()
do_smoke(0, vat, vat.loc)
for(var/x in 1 to resulting_atom_count)
var/atom/thing = new resulting_atom(get_turf(vat))
ADD_TRAIT(thing, TRAIT_VATGROWN, "vatgrowing")