mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-07-14 09:35:30 +01:00
f58b8511f0
## 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. /🆑
136 lines
3.8 KiB
Plaintext
136 lines
3.8 KiB
Plaintext
/obj/item/electropack
|
|
name = "electropack"
|
|
desc = "Dance my monkeys! DANCE!!!"
|
|
icon = 'icons/obj/devices/tool.dmi'
|
|
icon_state = "electropack0"
|
|
inhand_icon_state = "electropack"
|
|
lefthand_file = 'icons/mob/inhands/items/devices_lefthand.dmi'
|
|
righthand_file = 'icons/mob/inhands/items/devices_righthand.dmi'
|
|
obj_flags = CONDUCTS_ELECTRICITY
|
|
slot_flags = ITEM_SLOT_BACK
|
|
w_class = WEIGHT_CLASS_HUGE
|
|
sound_vary = TRUE
|
|
pickup_sound = SFX_GENERIC_DEVICE_PICKUP
|
|
drop_sound = SFX_GENERIC_DEVICE_DROP
|
|
custom_materials = list(/datum/material/iron=SHEET_MATERIAL_AMOUNT *5, /datum/material/glass=SHEET_MATERIAL_AMOUNT * 1.25)
|
|
|
|
var/on = TRUE
|
|
var/code = 2
|
|
var/frequency = FREQ_ELECTROPACK
|
|
var/shock_cooldown = FALSE
|
|
|
|
/obj/item/electropack/Initialize(mapload)
|
|
. = ..()
|
|
set_frequency(frequency)
|
|
|
|
/obj/item/electropack/Destroy()
|
|
SSradio.remove_object(src, frequency)
|
|
return ..()
|
|
|
|
/obj/item/electropack/suicide_act(mob/living/user)
|
|
user.visible_message(span_suicide("[user] hooks [user.p_them()]self to the electropack and spams the trigger! It looks like [user.p_theyre()] trying to commit suicide!"))
|
|
return FIRELOSS
|
|
|
|
//ATTACK HAND IGNORING PARENT RETURN VALUE
|
|
/obj/item/electropack/attack_hand(mob/user, list/modifiers)
|
|
if(iscarbon(user))
|
|
var/mob/living/carbon/C = user
|
|
if(src == C.back)
|
|
to_chat(user, span_warning("You need help taking this off!"))
|
|
return
|
|
return ..()
|
|
|
|
/obj/item/electropack/attackby(obj/item/W, mob/user, list/modifiers, list/attack_modifiers)
|
|
if(istype(W, /obj/item/clothing/head/helmet))
|
|
var/obj/item/assembly/shock_kit/A = new /obj/item/assembly/shock_kit(user)
|
|
A.icon = 'icons/obj/devices/assemblies.dmi'
|
|
|
|
if(!user.transferItemToLoc(W, A))
|
|
to_chat(user, span_warning("[W] is stuck to your hand, you cannot attach it to [src]!"))
|
|
return
|
|
W.master = A
|
|
A.helmet_part = W
|
|
|
|
user.transferItemToLoc(src, A, TRUE)
|
|
master = A
|
|
A.electropack_part = src
|
|
|
|
user.put_in_hands(A)
|
|
A.add_fingerprint(user)
|
|
else
|
|
return ..()
|
|
|
|
/obj/item/electropack/receive_signal(datum/signal/signal)
|
|
if(!signal || signal.data["code"] != code)
|
|
return
|
|
if(isliving(loc) && on)
|
|
if(shock_cooldown)
|
|
return
|
|
shock_cooldown = TRUE
|
|
addtimer(VARSET_CALLBACK(src, shock_cooldown, FALSE), 10 SECONDS)
|
|
var/mob/living/L = loc
|
|
step(L, pick(GLOB.cardinals))
|
|
|
|
to_chat(L, span_danger("You feel a sharp shock!"))
|
|
do_sparks(3, TRUE, L)
|
|
L.Paralyze(100)
|
|
|
|
if(master)
|
|
if(isassembly(master))
|
|
var/obj/item/assembly/master_as_assembly = master
|
|
master_as_assembly.pulsed()
|
|
master.receive_signal()
|
|
|
|
/obj/item/electropack/proc/set_frequency(new_frequency)
|
|
SSradio.remove_object(src, frequency)
|
|
frequency = new_frequency
|
|
SSradio.add_object(src, frequency, RADIO_SIGNALER)
|
|
|
|
/obj/item/electropack/ui_state(mob/user)
|
|
return GLOB.hands_state
|
|
|
|
/obj/item/electropack/ui_interact(mob/user, datum/tgui/ui)
|
|
ui = SStgui.try_update_ui(user, src, ui)
|
|
if(!ui)
|
|
ui = new(user, src, "Electropack", name)
|
|
ui.open()
|
|
|
|
/obj/item/electropack/ui_data(mob/user)
|
|
var/list/data = list()
|
|
data["power"] = on
|
|
data["frequency"] = frequency
|
|
data["code"] = code
|
|
data["minFrequency"] = MIN_FREE_FREQ
|
|
data["maxFrequency"] = MAX_FREE_FREQ
|
|
return data
|
|
|
|
/obj/item/electropack/ui_act(action, list/params, datum/tgui/ui, datum/ui_state/state)
|
|
. = ..()
|
|
if(.)
|
|
return
|
|
|
|
switch(action)
|
|
if("power")
|
|
on = !on
|
|
icon_state = "electropack[on]"
|
|
. = TRUE
|
|
if("freq")
|
|
var/value = unformat_frequency(params["freq"])
|
|
if(value)
|
|
frequency = sanitize_frequency(value, TRUE)
|
|
set_frequency(frequency)
|
|
. = TRUE
|
|
if("code")
|
|
var/value = text2num(params["code"])
|
|
if(value)
|
|
value = round(value)
|
|
code = clamp(value, 1, 100)
|
|
. = TRUE
|
|
if("reset")
|
|
if(params["reset"] == "freq")
|
|
frequency = initial(frequency)
|
|
. = TRUE
|
|
else if(params["reset"] == "code")
|
|
code = initial(code)
|
|
. = TRUE
|