Files
SmArtKarandGitHub 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

119 lines
4.5 KiB
Plaintext

/obj/structure/toiletbong
name = "toilet bong"
desc = "A repurposed toilet with re-arranged piping and an attached flamethrower. Why would anyone build this?"
icon = 'icons/obj/watercloset.dmi'
icon_state = "toiletbong"
base_icon_state = "toiletbong"
density = FALSE
anchored = TRUE
custom_materials = list(/datum/material/iron = SHEET_MATERIAL_AMOUNT * 2.05, /datum/material/glass = SMALL_MATERIAL_AMOUNT * 0.8)
var/smokeradius = 1
var/mutable_appearance/weed_overlay
/obj/structure/toiletbong/Initialize(mapload)
. = ..()
AddElement(/datum/element/simple_rotation, post_rotation_proccall = PROC_REF(post_rotation))
create_storage(storage_type = /datum/storage/toiletbong)
weed_overlay = mutable_appearance('icons/obj/watercloset.dmi', "[base_icon_state]_overlay")
START_PROCESSING(SSobj, src)
/obj/structure/toiletbong/on_craft_completion(list/components, datum/crafting_recipe/current_recipe, atom/crafter)
var/obj/structure/toilet/toilet = locate(/obj/structure/toilet) in components
if(toilet)
for(var/obj/item/cistern_item in toilet.contents)
cistern_item.forceMove(crafter.drop_location())
to_chat(crafter, span_warning("[cistern_item] falls out of the toilet!"))
setDir(toilet.dir)
forceMove(toilet.loc)
crafter.visible_message(
span_notice("[crafter] attaches the flamethrower to the repurposed toilet."),
span_notice("You attach the flamethrower to the repurposed toilet."),
)
return ..()
/obj/structure/toiletbong/update_overlays()
. = ..()
if (LAZYLEN(contents))
. += weed_overlay
/obj/structure/toiletbong/attack_hand(mob/living/carbon/user)
. = ..()
if (!anchored)
user.balloon_alert(user, "secure it first!")
return
if (!LAZYLEN(contents))
user.balloon_alert(user, "it's empty!")
return
user.visible_message(span_boldnotice("[user] takes a huge drag on the [src]."))
if (!do_after(user, 2 SECONDS, target = src))
return
var/turf/toiletbong_location = loc
toiletbong_location.hotspot_expose(1000, 5)
for (var/obj/item/item in contents)
if (item.resistance_flags & INDESTRUCTIBLE)
user.balloon_alert(user, "[item.name] is blocking the pipes!")
continue
playsound(src, 'sound/items/modsuit/flamethrower.ogg', 50)
var/smoke_amount = DIAMOND_AREA(smokeradius)
do_chem_smoke(amount = smoke_amount, holder = src, location = loc, carry = reagents, carry_limit = 20, smoke_type = /datum/effect_system/fluid_spread/smoke/chem/smoke_machine)
reagents.remove_all(smoke_amount / 20)
if (prob(5) && !(obj_flags & EMAGGED))
if(user.get_liked_foodtypes() & GORE)
user.balloon_alert(user, "a hidden treat!")
user.visible_message(span_danger("[user] fishes a mouse out of the pipes."))
else
to_chat(user, span_userdanger("There was something disgusting in the pipes!"))
user.visible_message(span_danger("[user] spits out a mouse."))
user.adjust_disgust(50)
user.vomit(VOMIT_CATEGORY_DEFAULT)
var/mob/living/spawned_mob = new /mob/living/basic/mouse(get_turf(user))
spawned_mob.add_faction("[REF(user)]")
if(prob(50))
for(var/j in 1 to rand(1, 3))
step(spawned_mob, pick(NORTH,SOUTH,EAST,WEST))
qdel(item)
if(!(obj_flags & EMAGGED))
break
update_appearance(UPDATE_ICON)
/obj/structure/toiletbong/wrench_act(mob/living/user, obj/item/tool)
default_unfasten_wrench(user, tool)
return ITEM_INTERACT_SUCCESS
///Called in the simple rotation's post_rotation callback, playing a sound cue to players.
/obj/structure/toiletbong/proc/post_rotation(mob/user, degrees)
playsound(src, 'sound/items/deconstruct.ogg', 50)
/obj/structure/toiletbong/crowbar_act(mob/living/user, obj/item/tool)
if(anchored)
return FALSE
tool.play_tool_sound(src)
to_chat(user, span_notice("You begin taking apart the [src]."))
if (!do_after(user, 10 SECONDS, target = src))
return FALSE
new /obj/item/flamethrower(get_turf(src))
var/obj/item/tank/internals/plasma/ptank = new /obj/item/tank/internals/plasma(get_turf(src))
ptank.air_contents.gases[/datum/gas/plasma][MOLES] = (0)
drop_costum_materials()
qdel(src)
return TRUE
/obj/structure/toiletbong/emag_act(mob/user, obj/item/card/emag/emag_card)
if(obj_flags & EMAGGED)
return FALSE
obj_flags |= EMAGGED
smokeradius = 2
playsound(src, 'sound/effects/fish_splash.ogg', 50)
balloon_alert(user, "toilet broke")
if (emag_card)
to_chat(user, span_boldwarning("The [emag_card] falls into the toilet. You fish it back out. Looks like you broke the toilet."))
return TRUE
/obj/structure/toiletbong/attackby(obj/item/attacking_item, mob/user, list/modifiers, list/attack_modifiers)
if(istype(attacking_item, /obj/item/card/emag))
return
return ..()