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

134 lines
4.9 KiB
Plaintext

#define WASH_PERIOD 3 SECONDS
/mob/living/basic/bot/hygienebot
name = "\improper Hygienebot"
desc = "A flying cleaning robot, he'll chase down people who can't shower properly!"
icon = 'icons/mob/silicon/aibots.dmi'
icon_state = "hygienebot"
base_icon_state = "hygienebot"
pass_flags = parent_type::pass_flags | PASSTABLE
layer = MOB_UPPER_LAYER
gender = MALE
density = FALSE
anchored = FALSE
health = 100
maxHealth = 100
path_image_color = "#80dae7"
req_one_access = list(ACCESS_ROBOTICS, ACCESS_JANITOR)
radio_key = /obj/item/encryptionkey/headset_service
radio_channel = RADIO_CHANNEL_SERVICE
bot_type = HYGIENE_BOT
additional_access = /datum/id_trim/job/janitor
hackables = "cleaning service protocols"
ai_controller = /datum/ai_controller/basic_controller/bot/hygienebot
custom_materials = list(/datum/material/iron = SHEET_MATERIAL_AMOUNT * 3.3, /datum/material/glass = SMALL_MATERIAL_AMOUNT * 2)
///are we currently washing someone?
var/washing = FALSE
///Visual overlay of the bot spraying water.
var/static/mutable_appearance/water_overlay = mutable_appearance('icons/mob/silicon/aibots.dmi', "hygienebot-water")
///Visual overlay of the bot commiting warcrimes.
var/static/mutable_appearance/fire_overlay = mutable_appearance('icons/mob/silicon/aibots.dmi', "hygienebot-fire")
///announcements we say when we find a target
var/static/list/found_announcements = list(
HYGIENEBOT_VOICED_UNHYGIENIC = 'sound/mobs/non-humanoids/hygienebot/unhygienicclient.ogg',
)
///announcements we say when the target keeps moving away
var/static/list/threat_announcements = list(
HYGIENEBOT_VOICED_THREAT_AIRLOCK = 'sound/mobs/non-humanoids/hygienebot/dragyouout.ogg',
HYGIENEBOT_VOICED_FOUL_SMELL = 'sound/mobs/non-humanoids/hygienebot/foulsmelling.ogg',
HYGIENEBOT_VOICED_TROGLODYTE = 'sound/mobs/non-humanoids/hygienebot/troglodyte.ogg',
HYGIENEBOT_VOICED_GREEN_CLOUD = 'sound/mobs/non-humanoids/hygienebot/greencloud.ogg',
HYGIENEBOT_VOICED_ARSEHOLE = 'sound/mobs/non-humanoids/hygienebot/letmeclean.ogg',
HYGIENEBOT_VOICED_THREAT_ARTERIES = 'sound/mobs/non-humanoids/hygienebot/cutarteries.ogg',
HYGIENEBOT_VOICED_STOP_RUNNING = 'sound/mobs/non-humanoids/hygienebot/stoprunning.ogg',
)
///announcements we say after we have cleaned our target
var/static/list/cleaned_announcements = list(
HYGIENEBOT_VOICED_FUCKING_FINALLY = 'sound/mobs/non-humanoids/hygienebot/finally.ogg',
HYGIENEBOT_VOICED_THANK_GOD = 'sound/mobs/non-humanoids/hygienebot/thankgod.ogg',
HYGIENEBOT_VOICED_DEGENERATE = 'sound/mobs/non-humanoids/hygienebot/degenerate.ogg',
)
/mob/living/basic/bot/hygienebot/Initialize(mapload)
. = ..()
update_appearance(UPDATE_ICON)
generate_ai_speech()
var/static/list/loc_connections = list(
COMSIG_ATOM_ENTERED = PROC_REF(on_entered),
)
AddElement(/datum/element/connect_loc, loc_connections)
var/static/list/hat_offsets = list(1, 1)
AddElement(/datum/element/hat_wearer, offsets = hat_offsets)
ADD_TRAIT(src, TRAIT_SPRAY_PAINTABLE, INNATE_TRAIT)
RegisterSignal(src, COMSIG_HOSTILE_PRE_ATTACKINGTARGET, PROC_REF(on_attack))
/mob/living/basic/bot/hygienebot/explode()
do_foam(2, src, loc)
return ..()
/mob/living/basic/bot/hygienebot/generate_speak_list()
var/static/list/finalized_speak_list = (found_announcements + threat_announcements + cleaned_announcements)
return finalized_speak_list
/mob/living/basic/bot/hygienebot/update_icon_state()
. = ..()
icon_state = "[base_icon_state][bot_mode_flags & BOT_MODE_ON ? "-on" : ""]"
/mob/living/basic/bot/hygienebot/update_overlays()
. = ..()
if(bot_mode_flags & BOT_MODE_ON)
. += mutable_appearance(icon, "hygienebot-flame")
if(!washing)
return
. += (bot_access_flags & BOT_COVER_EMAGGED) ? fire_overlay : water_overlay
/mob/living/basic/bot/hygienebot/proc/on_entered(datum/source, atom/movable/movable)
SIGNAL_HANDLER
if(!washing)
return
commence_wash(movable)
/mob/living/basic/bot/hygienebot/proc/on_attack(datum/source, atom/target)
SIGNAL_HANDLER
. = COMPONENT_HOSTILE_NO_ATTACK
if(washing)
return
set_washing_mode(new_mode = TRUE)
for(var/atom/to_wash in loc)
commence_wash(to_wash)
addtimer(CALLBACK(src, PROC_REF(set_washing_mode), FALSE), WASH_PERIOD)
/mob/living/basic/bot/hygienebot/proc/set_washing_mode(new_mode)
washing = new_mode
update_appearance(UPDATE_OVERLAYS)
/mob/living/basic/bot/hygienebot/proc/commence_wash(atom/target)
if(bot_access_flags & BOT_COVER_EMAGGED)
target.fire_act()
return
target.wash(CLEAN_WASH)
target.extinguish()
/mob/living/basic/bot/hygienebot/on_bot_movement(atom/movable/source, atom/oldloc, dir, forced)
if(!washing || !isturf(loc))
return
for(var/mob/living/carbon/human in loc)
commence_wash(human)
/mob/living/basic/bot/hygienebot/proc/generate_ai_speech()
ai_controller.set_blackboard_key(BB_WASH_FOUND, found_announcements)
ai_controller.set_blackboard_key(BB_WASH_THREATS, threat_announcements)
ai_controller.set_blackboard_key(BB_WASH_DONE, cleaned_announcements)
#undef WASH_PERIOD