Files
Bubberstation/code/game/objects/items/devices/radio/electropack.dm
SkyratBot 6250754697 [MIRROR] At first i thought that i was being forced to add a feature 🤮 but then i realized i was being encouraged to refactor 😄. Electrified chair is now a component instead of a failure (#3801)
* At first i thought that i was being forced to add a feature 🤮 but then i realized i was being encouraged to refactor 😄. Electrified chair is now a component instead of a failure (#57117)

* At first i thought that i was being forced to add a feature 🤮 but then i realized i was being encouraged to refactor 😄. Electrified chair is now a component instead of a failure

Co-authored-by: Kylerace <kylerlumpkin1@gmail.com>
2021-03-03 14:19:19 +00:00

136 lines
3.6 KiB
Plaintext

/obj/item/electropack
name = "electropack"
desc = "Dance my monkeys! DANCE!!!"
icon = 'icons/obj/radio.dmi'
icon_state = "electropack0"
inhand_icon_state = "electropack"
lefthand_file = 'icons/mob/inhands/misc/devices_lefthand.dmi'
righthand_file = 'icons/mob/inhands/misc/devices_righthand.dmi'
flags_1 = CONDUCT_1
slot_flags = ITEM_SLOT_BACK
w_class = WEIGHT_CLASS_HUGE
custom_materials = list(/datum/material/iron=10000, /datum/material/glass=2500)
var/on = TRUE
var/code = 2
var/frequency = FREQ_ELECTROPACK
var/shock_cooldown = FALSE
/obj/item/electropack/Initialize()
. = ..()
set_frequency(frequency)
/obj/item/electropack/Destroy()
SSradio.remove_object(src, frequency)
return ..()
/obj/item/electropack/suicide_act(mob/user)
user.visible_message("<span class='suicide'>[user] hooks [user.p_them()]self to the electropack and spams the trigger! It looks like [user.p_theyre()] trying to commit suicide!</span>")
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 class='warning'>You need help taking this off!</span>")
return
return ..()
/obj/item/electropack/attackby(obj/item/W, mob/user, params)
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/assemblies.dmi'
if(!user.transferItemToLoc(W, A))
to_chat(user, "<span class='warning'>[W] is stuck to your hand, you cannot attach it to [src]!</span>")
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), 100)
var/mob/living/L = loc
step(L, pick(GLOB.cardinals))
to_chat(L, "<span class='danger'>You feel a sharp shock!</span>")
var/datum/effect_system/spark_spread/s = new /datum/effect_system/spark_spread
s.set_up(3, 1, L)
s.start()
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, params)
. = ..()
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