mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-09 16:12:17 +00:00
[MIRROR] Tethered Item Component (#11723)
Co-authored-by: Will <7099514+Willburd@users.noreply.github.com> Co-authored-by: Cameron Lennox <killer65311@gmail.com>
This commit is contained in:
committed by
GitHub
parent
cc6ed17407
commit
ef9f5f2499
@@ -15,9 +15,8 @@
|
||||
w_class = ITEMSIZE_LARGE
|
||||
unacidable = TRUE
|
||||
origin_tech = list(TECH_BIO = 4, TECH_POWER = 2)
|
||||
actions_types = list(/datum/action/item_action/remove_replace_paddles)
|
||||
|
||||
var/obj/item/shockpaddles/linked/paddles
|
||||
var/obj/item/shockpaddles/linked/paddle_path = /obj/item/shockpaddles/linked
|
||||
var/obj/item/cell/bcell = null
|
||||
pickup_sound = 'sound/items/pickup/device.ogg'
|
||||
drop_sound = 'sound/items/drop/device.ogg'
|
||||
@@ -26,29 +25,28 @@
|
||||
return bcell
|
||||
|
||||
/obj/item/defib_kit/Initialize(mapload) //starts without a cell for rnd
|
||||
AddComponent(/datum/component/tethered_item, paddle_path)
|
||||
. = ..()
|
||||
if(ispath(paddles))
|
||||
paddles = new paddles(src, src)
|
||||
else
|
||||
paddles = new(src, src)
|
||||
|
||||
if(ispath(bcell))
|
||||
bcell = new bcell(src)
|
||||
update_icon()
|
||||
|
||||
/obj/item/defib_kit/Destroy()
|
||||
. = ..()
|
||||
QDEL_NULL(paddles)
|
||||
QDEL_NULL(bcell)
|
||||
|
||||
/obj/item/defib_kit/loaded //starts with a cell
|
||||
bcell = /obj/item/cell/apc
|
||||
|
||||
/obj/item/defib_kit/proc/get_paddles()
|
||||
var/datum/component/tethered_item/TI = GetComponent(/datum/component/tethered_item)
|
||||
return TI.get_handheld()
|
||||
|
||||
/obj/item/defib_kit/update_icon()
|
||||
cut_overlays()
|
||||
|
||||
if(paddles && paddles.loc == src) //in case paddles got destroyed somehow.
|
||||
var/obj/item/shockpaddles/linked/paddles = get_paddles()
|
||||
if(paddles && paddles.loc == src)
|
||||
add_overlay("[initial(icon_state)]-paddles")
|
||||
if(bcell && paddles)
|
||||
if(bcell.check_charge(paddles.chargecost))
|
||||
@@ -64,14 +62,11 @@
|
||||
else
|
||||
add_overlay("[initial(icon_state)]-nocell")
|
||||
|
||||
/obj/item/defib_kit/ui_action_click(mob/user, actiontype)
|
||||
toggle_paddles()
|
||||
|
||||
/obj/item/defib_kit/attack_hand(mob/user)
|
||||
if(loc == user)
|
||||
toggle_paddles()
|
||||
else
|
||||
..()
|
||||
/obj/item/defib_kit/attack_hand(mob/living/user)
|
||||
// See important note in tethered_item.dm
|
||||
if(SEND_SIGNAL(src,COMSIG_ITEM_ATTACK_SELF,user) & COMPONENT_NO_INTERACT)
|
||||
return TRUE
|
||||
. = ..()
|
||||
|
||||
/obj/item/defib_kit/MouseDrop()
|
||||
if(ismob(src.loc))
|
||||
@@ -85,9 +80,7 @@
|
||||
|
||||
|
||||
/obj/item/defib_kit/attackby(obj/item/W, mob/user, params)
|
||||
if(W == paddles)
|
||||
reattach_paddles(user)
|
||||
else if(istype(W, /obj/item/cell))
|
||||
if(istype(W, /obj/item/cell))
|
||||
if(bcell)
|
||||
to_chat(user, span_notice("\The [src] already has a cell."))
|
||||
else
|
||||
@@ -102,6 +95,7 @@
|
||||
if(bcell)
|
||||
bcell.update_icon()
|
||||
bcell.forceMove(get_turf(src.loc))
|
||||
user.put_in_any_hand_if_possible(bcell)
|
||||
bcell = null
|
||||
to_chat(user, span_notice("You remove the cell from \the [src]."))
|
||||
update_icon()
|
||||
@@ -109,33 +103,12 @@
|
||||
return ..()
|
||||
|
||||
/obj/item/defib_kit/emag_act(var/remaining_charges, var/mob/user)
|
||||
var/obj/item/shockpaddles/linked/paddles = get_paddles()
|
||||
if(paddles)
|
||||
. = paddles.emag_act(user)
|
||||
update_icon()
|
||||
return
|
||||
|
||||
//Paddle stuff
|
||||
|
||||
/obj/item/defib_kit/verb/toggle_paddles()
|
||||
set name = "Toggle Paddles"
|
||||
set category = "Object"
|
||||
|
||||
var/mob/living/carbon/human/user = usr
|
||||
if(!paddles)
|
||||
to_chat(user, span_warning("The paddles are missing!"))
|
||||
return
|
||||
|
||||
if(paddles.loc != src)
|
||||
reattach_paddles(user) //Remove from their hands and back onto the defib unit
|
||||
return
|
||||
|
||||
if(!slot_check())
|
||||
to_chat(user, span_warning("You need to equip [src] before taking out [paddles]."))
|
||||
else
|
||||
if(!user.put_in_hands(paddles)) //Detach the paddles into the user's hands
|
||||
to_chat(user, span_warning("You need a free hand to hold the paddles!"))
|
||||
update_icon() //success
|
||||
|
||||
//checks that the base unit is in the correct slot to be used
|
||||
/obj/item/defib_kit/proc/slot_check()
|
||||
var/mob/M = loc
|
||||
@@ -146,31 +119,13 @@
|
||||
return 1
|
||||
if((slot_flags & SLOT_BELT) && M.get_equipped_item(slot_belt) == src)
|
||||
return 1
|
||||
//VOREStation Add Start - RIGSuit compatability
|
||||
if((slot_flags & SLOT_BACK) && M.get_equipped_item(slot_s_store) == src)
|
||||
return 1
|
||||
if((slot_flags & SLOT_BELT) && M.get_equipped_item(slot_s_store) == src)
|
||||
return 1
|
||||
//VOREStation Add End
|
||||
|
||||
return 0
|
||||
|
||||
/obj/item/defib_kit/dropped(mob/user)
|
||||
..()
|
||||
reattach_paddles(user) //paddles attached to a base unit should never exist outside of their base unit or the mob equipping the base unit
|
||||
|
||||
/obj/item/defib_kit/proc/reattach_paddles(mob/user)
|
||||
if(!paddles) return
|
||||
|
||||
if(ismob(paddles.loc))
|
||||
var/mob/M = paddles.loc
|
||||
if(M.drop_from_inventory(paddles, src))
|
||||
to_chat(user, span_notice("\The [paddles] snap back into the main unit."))
|
||||
else
|
||||
paddles.forceMove(src)
|
||||
|
||||
update_icon()
|
||||
|
||||
/*
|
||||
Base Unit Subtypes
|
||||
*/
|
||||
@@ -191,7 +146,7 @@
|
||||
/obj/item/defib_kit/compact/combat
|
||||
name = "combat defibrillator"
|
||||
desc = "A belt-equipped blood-red defibrillator that can be rapidly deployed. Does not have the restrictions or safeties of conventional defibrillators and can revive through space suits."
|
||||
paddles = /obj/item/shockpaddles/linked/combat
|
||||
paddle_path = /obj/item/shockpaddles/linked/combat
|
||||
|
||||
/obj/item/defib_kit/compact/combat/loaded
|
||||
bcell = /obj/item/cell/high
|
||||
@@ -214,6 +169,7 @@
|
||||
force = 2
|
||||
throwforce = 6
|
||||
w_class = ITEMSIZE_LARGE
|
||||
item_flags = NOSTRIP
|
||||
|
||||
var/safety = 1 //if you can zap people with the paddles on harm mode
|
||||
var/combat = 0 //If it can be used to revive people wearing thick clothing (e.g. spacesuits)
|
||||
@@ -595,34 +551,16 @@
|
||||
/*
|
||||
Shockpaddles that are linked to a base unit
|
||||
*/
|
||||
/obj/item/shockpaddles/linked
|
||||
var/obj/item/defib_kit/base_unit
|
||||
|
||||
/obj/item/shockpaddles/linked/Initialize(mapload, obj/item/defib_kit/defib)
|
||||
. = ..()
|
||||
base_unit = defib
|
||||
|
||||
/obj/item/shockpaddles/linked/Destroy()
|
||||
if(base_unit)
|
||||
//ensure the base unit's icon updates
|
||||
if(base_unit.paddles == src)
|
||||
base_unit.paddles = null
|
||||
base_unit.update_icon()
|
||||
base_unit = null
|
||||
return ..()
|
||||
|
||||
/obj/item/shockpaddles/linked/dropped(mob/user)
|
||||
..() //update twohanding
|
||||
if(base_unit)
|
||||
base_unit.reattach_paddles(user) //paddles attached to a base unit should never exist outside of their base unit or the mob equipping the base unit
|
||||
|
||||
/obj/item/shockpaddles/linked/check_charge(var/charge_amt)
|
||||
var/obj/item/defib_kit/base_unit = tethered_host_item
|
||||
return (base_unit.bcell && base_unit.bcell.check_charge(charge_amt))
|
||||
|
||||
/obj/item/shockpaddles/linked/checked_use(var/charge_amt)
|
||||
var/obj/item/defib_kit/base_unit = tethered_host_item
|
||||
return (base_unit.bcell && base_unit.bcell.checked_use(charge_amt))
|
||||
|
||||
/obj/item/shockpaddles/linked/make_announcement(var/message, var/msg_class)
|
||||
var/obj/item/defib_kit/base_unit = tethered_host_item
|
||||
base_unit.audible_message(span_infoplain(span_bold("\The [base_unit]") + " [message]"), span_info("\The [base_unit] vibrates slightly."))
|
||||
|
||||
/*
|
||||
@@ -686,7 +624,7 @@
|
||||
icon_state = "jumperunit"
|
||||
item_state = "defibunit"
|
||||
// item_state = "jumperunit"
|
||||
paddles = /obj/item/shockpaddles/linked/jumper
|
||||
paddle_path = /obj/item/shockpaddles/linked/jumper
|
||||
|
||||
/obj/item/defib_kit/jumper_kit/loaded
|
||||
bcell = /obj/item/cell/high
|
||||
|
||||
@@ -814,7 +814,7 @@ GLOBAL_DATUM(autospeaker, /mob/living/silicon/ai/announcer)
|
||||
//* Bluespace Radio *//
|
||||
/obj/item/bluespaceradio/southerncross_prelinked
|
||||
name = "bluespace radio (southerncross)"
|
||||
handset = /obj/item/radio/bluespacehandset/linked/southerncross_prelinked
|
||||
handset_path = /obj/item/radio/bluespacehandset/linked/southerncross_prelinked
|
||||
|
||||
/obj/item/radio/bluespacehandset/linked/southerncross_prelinked
|
||||
bs_tx_preload_id = "Receiver A" //Transmit to a receiver
|
||||
@@ -840,7 +840,7 @@ GLOBAL_DATUM(autospeaker, /mob/living/silicon/ai/announcer)
|
||||
|
||||
/obj/item/bluespaceradio/tether_prelinked
|
||||
name = "bluespace radio (tether)"
|
||||
handset = /obj/item/radio/bluespacehandset/linked/tether_prelinked
|
||||
handset_path = /obj/item/radio/bluespacehandset/linked/tether_prelinked
|
||||
|
||||
/obj/item/radio/bluespacehandset/linked/tether_prelinked
|
||||
bs_tx_preload_id = "tether_rx" //Transmit to a receiver
|
||||
@@ -848,7 +848,7 @@ GLOBAL_DATUM(autospeaker, /mob/living/silicon/ai/announcer)
|
||||
|
||||
/obj/item/bluespaceradio/talon_prelinked
|
||||
name = "bluespace radio (talon)"
|
||||
handset = /obj/item/radio/bluespacehandset/linked/talon_prelinked
|
||||
handset_path = /obj/item/radio/bluespacehandset/linked/talon_prelinked
|
||||
|
||||
/obj/item/radio/bluespacehandset/linked/talon_prelinked
|
||||
bs_tx_preload_id = "talon_aio" //Transmit to a receiver
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/obj/item/bluespaceradio/cryogaia_prelinked
|
||||
name = "bluespace radio (Cryogaia)"
|
||||
handset = /obj/item/radio/bluespacehandset/linked/cryogaia_prelinked
|
||||
handset_path = /obj/item/radio/bluespacehandset/linked/cryogaia_prelinked
|
||||
|
||||
/obj/item/radio/bluespacehandset/linked/cryogaia_prelinked
|
||||
bs_tx_preload_id = "cryogaia_rx" //Transmit to a receiver
|
||||
|
||||
@@ -10,27 +10,17 @@
|
||||
throwforce = 6
|
||||
preserve_item = 1
|
||||
w_class = ITEMSIZE_LARGE
|
||||
actions_types = list(/datum/action/item_action/remove_replace_handset)
|
||||
|
||||
var/obj/item/radio/bluespacehandset/linked/handset = /obj/item/radio/bluespacehandset/linked
|
||||
var/obj/item/radio/bluespacehandset/linked/handset_path = /obj/item/radio/bluespacehandset/linked
|
||||
|
||||
/obj/item/bluespaceradio/Initialize(mapload)
|
||||
AddComponent(/datum/component/tethered_item, handset_path)
|
||||
. = ..()
|
||||
if(ispath(handset))
|
||||
handset = new handset(src, src)
|
||||
|
||||
/obj/item/bluespaceradio/Destroy()
|
||||
/obj/item/bluespaceradio/attack_hand(mob/living/user)
|
||||
// See important note in tethered_item.dm
|
||||
if(SEND_SIGNAL(src,COMSIG_ITEM_ATTACK_SELF,user) & COMPONENT_NO_INTERACT)
|
||||
return TRUE
|
||||
. = ..()
|
||||
QDEL_NULL(handset)
|
||||
|
||||
/obj/item/bluespaceradio/ui_action_click(mob/user, actiontype)
|
||||
toggle_handset()
|
||||
|
||||
/obj/item/bluespaceradio/attack_hand(var/mob/user)
|
||||
if(loc == user)
|
||||
toggle_handset()
|
||||
else
|
||||
..()
|
||||
|
||||
/obj/item/bluespaceradio/MouseDrop()
|
||||
if(ismob(loc))
|
||||
@@ -42,59 +32,6 @@
|
||||
add_fingerprint(usr)
|
||||
M.put_in_any_hand_if_possible(src)
|
||||
|
||||
/obj/item/bluespaceradio/attackby(var/obj/item/W, var/mob/user, var/params)
|
||||
if(W == handset)
|
||||
reattach_handset(user)
|
||||
else
|
||||
return ..()
|
||||
|
||||
/obj/item/bluespaceradio/verb/toggle_handset()
|
||||
set name = "Toggle Handset"
|
||||
set category = "Object"
|
||||
|
||||
var/mob/living/carbon/human/user = usr
|
||||
if(!handset)
|
||||
to_chat(user, span_warning("The handset is missing!"))
|
||||
return
|
||||
|
||||
if(handset.loc != src)
|
||||
reattach_handset(user) //Remove from their hands and back onto the defib unit
|
||||
return
|
||||
|
||||
if(!slot_check())
|
||||
to_chat(user, span_warning("You need to equip [src] before taking out [handset]."))
|
||||
else
|
||||
if(!user.put_in_hands(handset)) //Detach the handset into the user's hands
|
||||
to_chat(user, span_warning("You need a free hand to hold the handset!"))
|
||||
update_icon() //success
|
||||
|
||||
//checks that the base unit is in the correct slot to be used
|
||||
/obj/item/bluespaceradio/proc/slot_check()
|
||||
var/mob/M = loc
|
||||
if(!istype(M))
|
||||
return 0 //not equipped
|
||||
|
||||
if((slot_flags & SLOT_BACK) && M.get_equipped_item(slot_back) == src)
|
||||
return 1
|
||||
if((slot_flags & SLOT_BACK) && M.get_equipped_item(slot_s_store) == src)
|
||||
return 1
|
||||
|
||||
return 0
|
||||
|
||||
/obj/item/bluespaceradio/dropped(var/mob/user)
|
||||
..()
|
||||
reattach_handset(user) //handset attached to a base unit should never exist outside of their base unit or the mob equipping the base unit
|
||||
|
||||
/obj/item/bluespaceradio/proc/reattach_handset(var/mob/user)
|
||||
if(!handset) return
|
||||
|
||||
if(ismob(handset.loc))
|
||||
var/mob/M = handset.loc
|
||||
if(M.drop_from_inventory(handset, src))
|
||||
to_chat(user, span_notice("\The [handset] snaps back into the main unit."))
|
||||
else
|
||||
handset.forceMove(src)
|
||||
|
||||
//Subspace Radio Handset
|
||||
/obj/item/radio/bluespacehandset
|
||||
name = "bluespace radio handset"
|
||||
@@ -105,26 +42,7 @@
|
||||
slot_flags = null
|
||||
w_class = ITEMSIZE_LARGE
|
||||
canhear_range = 1
|
||||
|
||||
/obj/item/radio/bluespacehandset/linked
|
||||
var/obj/item/bluespaceradio/base_unit
|
||||
|
||||
/obj/item/radio/bluespacehandset/linked/Initialize(mapload, var/obj/item/bluespaceradio/radio)
|
||||
base_unit = radio
|
||||
. = ..()
|
||||
|
||||
/obj/item/radio/bluespacehandset/linked/Destroy()
|
||||
if(base_unit)
|
||||
//ensure the base unit's icon updates
|
||||
if(base_unit.handset == src)
|
||||
base_unit.handset = null
|
||||
base_unit = null
|
||||
return ..()
|
||||
|
||||
/obj/item/radio/bluespacehandset/linked/dropped(var/mob/user)
|
||||
..() //update twohanding
|
||||
if(base_unit)
|
||||
base_unit.reattach_handset(user) //handset attached to a base unit should never exist outside of their base unit or the mob equipping the base unit
|
||||
item_flags = NOSTRIP
|
||||
|
||||
/obj/item/radio/bluespacehandset/linked/receive_range(var/freq, var/list/level)
|
||||
//Only care about megabroadcasts or things that are targeted at us
|
||||
|
||||
Reference in New Issue
Block a user