From 79e59077ebc026000b0496656ad3bb7baea2e1cf Mon Sep 17 00:00:00 2001
From: zxaber <37497534+zxaber@users.noreply.github.com>
Date: Sun, 2 Feb 2020 19:08:40 -0800
Subject: [PATCH] Allows defib units to be used as medical borg upgrades, adds
message to borgs when they recieve an upgrade, re-organizes borg attackby().
(#48805)
* Delete stale.yml
* Create stale.yml
* clear
* Can now replace the defib pack with an upgrade card to get the pack back.
* less redundant checks
* borg > cyborg text changes
---
.../objects/items/robot/robot_upgrades.dm | 12 +
.../modules/mob/living/silicon/robot/robot.dm | 183 --------------
.../mob/living/silicon/robot/robot_defense.dm | 233 +++++++++++++++++-
3 files changed, 237 insertions(+), 191 deletions(-)
diff --git a/code/game/objects/items/robot/robot_upgrades.dm b/code/game/objects/items/robot/robot_upgrades.dm
index c14b0193954..7905cb0963f 100644
--- a/code/game/objects/items/robot/robot_upgrades.dm
+++ b/code/game/objects/items/robot/robot_upgrades.dm
@@ -428,10 +428,18 @@
icon_state = "cyborg_upgrade3"
require_module = 1
module_type = list(/obj/item/robot_module/medical)
+ var/backpack = FALSE //True if we get the defib from a physical backpack unit rather than an upgrade card, so that we can return that upon deactivate()
+
+/obj/item/borg/upgrade/defib/backpack
+ backpack = TRUE
/obj/item/borg/upgrade/defib/action(mob/living/silicon/robot/R, user = usr)
. = ..()
if(.)
+ var/obj/item/borg/upgrade/defib/backpack/BP = locate() in R //If a full defib unit was used to upgrade prior, we can just pop it out now and replace
+ if(BP)
+ BP.deactivate(R, user)
+ to_chat(user, "You remove the defibrillator unit to make room for the compact upgrade.")
var/obj/item/twohanded/shockpaddles/cyborg/S = new(R.module)
R.module.basic_modules += S
R.module.add_module(S, FALSE, TRUE)
@@ -441,6 +449,10 @@
if (.)
var/obj/item/twohanded/shockpaddles/cyborg/S = locate() in R.module
R.module.remove_module(S, TRUE)
+ if(backpack)
+ new /obj/item/defibrillator(get_turf(R))
+ qdel(src)
+
/obj/item/borg/upgrade/processor
name = "medical cyborg surgical processor"
diff --git a/code/modules/mob/living/silicon/robot/robot.dm b/code/modules/mob/living/silicon/robot/robot.dm
index d9878026cff..781b94a7c3a 100644
--- a/code/modules/mob/living/silicon/robot/robot.dm
+++ b/code/modules/mob/living/silicon/robot/robot.dm
@@ -358,189 +358,6 @@
return FALSE
return ISINRANGE(T1.x, T0.x - interaction_range, T0.x + interaction_range) && ISINRANGE(T1.y, T0.y - interaction_range, T0.y + interaction_range)
-/mob/living/silicon/robot/attackby(obj/item/W, mob/user, params)
- if(W.tool_behaviour == TOOL_WELDER && (user.a_intent != INTENT_HARM || user == src))
- user.changeNext_move(CLICK_CD_MELEE)
- if (!getBruteLoss())
- to_chat(user, "[src] is already in good condition!")
- return
- if (!W.tool_start_check(user, amount=0)) //The welder has 1u of fuel consumed by it's afterattack, so we don't need to worry about taking any away.
- return
- if(src == user)
- to_chat(user, "You start fixing yourself...")
- if(!W.use_tool(src, user, 50))
- return
-
- adjustBruteLoss(-30)
- updatehealth()
- add_fingerprint(user)
- visible_message("[user] has fixed some of the dents on [src].")
- return
-
- else if(istype(W, /obj/item/stack/cable_coil) && wiresexposed)
- user.changeNext_move(CLICK_CD_MELEE)
- var/obj/item/stack/cable_coil/coil = W
- if (getFireLoss() > 0 || getToxLoss() > 0)
- if(src == user)
- to_chat(user, "You start fixing yourself...")
- if(!do_after(user, 50, target = src))
- return
- if (coil.use(1))
- adjustFireLoss(-30)
- adjustToxLoss(-30)
- updatehealth()
- user.visible_message("[user] has fixed some of the burnt wires on [src].", "You fix some of the burnt wires on [src].")
- else
- to_chat(user, "You need more cable to repair [src]!")
- else
- to_chat(user, "The wires seem fine, there's no need to fix them.")
-
- else if(W.tool_behaviour == TOOL_CROWBAR) // crowbar means open or close the cover
- if(opened)
- to_chat(user, "You close the cover.")
- opened = 0
- update_icons()
- else
- if(locked)
- to_chat(user, "The cover is locked and cannot be opened!")
- else
- to_chat(user, "You open the cover.")
- opened = 1
- update_icons()
-
- else if(istype(W, /obj/item/stock_parts/cell) && opened) // trying to put a cell inside
- if(wiresexposed)
- to_chat(user, "Close the cover first!")
- else if(cell)
- to_chat(user, "There is a power cell already installed!")
- else
- if(!user.transferItemToLoc(W, src))
- return
- cell = W
- to_chat(user, "You insert the power cell.")
- update_icons()
- diag_hud_set_borgcell()
-
- else if(is_wire_tool(W))
- if (wiresexposed)
- wires.interact(user)
- else
- to_chat(user, "You can't reach the wiring!")
-
- else if(W.tool_behaviour == TOOL_SCREWDRIVER && opened && !cell) // haxing
- wiresexposed = !wiresexposed
- to_chat(user, "The wires have been [wiresexposed ? "exposed" : "unexposed"].")
- update_icons()
-
- else if(W.tool_behaviour == TOOL_SCREWDRIVER && opened && cell) // radio
- if(shell)
- to_chat(user, "You cannot seem to open the radio compartment!") //Prevent AI radio key theft
- else if(radio)
- radio.attackby(W,user)//Push it to the radio to let it handle everything
- else
- to_chat(user, "Unable to locate a radio!")
- update_icons()
-
- else if(W.tool_behaviour == TOOL_WRENCH && opened && !cell) //Deconstruction. The flashes break from the fall, to prevent this from being a ghetto reset module.
- if(!lockcharge)
- to_chat(user, "[src]'s bolts spark! Maybe you should lock them down first!")
- spark_system.start()
- return
- else
- to_chat(user, "You start to unfasten [src]'s securing bolts...")
- if(W.use_tool(src, user, 50, volume=50) && !cell)
- user.visible_message("[user] deconstructs [src]!", "You unfasten the securing bolts, and [src] falls to pieces!")
- deconstruct()
-
- else if(istype(W, /obj/item/aiModule))
- var/obj/item/aiModule/MOD = W
- if(!opened)
- to_chat(user, "You need access to the robot's insides to do that!")
- return
- if(wiresexposed)
- to_chat(user, "You need to close the wire panel to do that!")
- return
- if(!cell)
- to_chat(user, "You need to install a power cell to do that!")
- return
- if(shell) //AI shells always have the laws of the AI
- to_chat(user, "[src] is controlled remotely! You cannot upload new laws this way!")
- return
- if(emagged || (connected_ai && lawupdate)) //Can't be sure which, metagamers
- emote("buzz-[user.name]")
- return
- if(!mind) //A player mind is required for law procs to run antag checks.
- to_chat(user, "[src] is entirely unresponsive!")
- return
- MOD.install(laws, user) //Proc includes a success mesage so we don't need another one
- return
-
- else if(istype(W, /obj/item/encryptionkey/) && opened)
- if(radio)//sanityyyyyy
- radio.attackby(W,user)//GTFO, you have your own procs
- else
- to_chat(user, "Unable to locate a radio!")
-
- else if (istype(W, /obj/item/card/id)||istype(W, /obj/item/pda)) // trying to unlock the interface with an ID card
- if(opened)
- to_chat(user, "You must close the cover to swipe an ID card!")
- else
- if(allowed(usr))
- locked = !locked
- to_chat(user, "You [ locked ? "lock" : "unlock"] [src]'s cover.")
- update_icons()
- if(emagged)
- to_chat(user, "The cover interface glitches out for a split second.")
- else
- to_chat(user, "Access denied.")
-
- else if(istype(W, /obj/item/borg/upgrade/))
- var/obj/item/borg/upgrade/U = W
- if(!opened)
- to_chat(user, "You must access the borg's internals!")
- else if(!src.module && U.require_module)
- to_chat(user, "The borg must choose a module before it can be upgraded!")
- else if(U.locked)
- to_chat(user, "The upgrade is locked and cannot be used yet!")
- else
- if(!user.temporarilyRemoveItemFromInventory(U))
- return
- if(U.action(src))
- to_chat(user, "You apply the upgrade to [src].")
- if(U.one_use)
- qdel(U)
- else
- U.forceMove(src)
- upgrades += U
- else
- to_chat(user, "Upgrade error.")
- U.forceMove(drop_location())
-
- else if(istype(W, /obj/item/toner))
- if(toner >= tonermax)
- to_chat(user, "The toner level of [src] is at its highest level possible!")
- else
- if(!user.temporarilyRemoveItemFromInventory(W))
- return
- toner = tonermax
- qdel(W)
- to_chat(user, "You fill the toner level of [src] to its max capacity.")
-
- else if(istype(W, /obj/item/flashlight))
- if(!opened)
- to_chat(user, "You need to open the panel to repair the headlamp!")
- else if(lamp_cooldown <= world.time)
- to_chat(user, "The headlamp is already functional!")
- else
- if(!user.temporarilyRemoveItemFromInventory(W))
- to_chat(user, "[W] seems to be stuck to your hand. You'll have to find a different light.")
- return
- lamp_cooldown = 0
- qdel(W)
- to_chat(user, "You replace the headlamp bulbs.")
- else
- return ..()
-
/mob/living/silicon/robot/verb/unlock_own_cover()
set category = "Robot Commands"
set name = "Unlock Cover"
diff --git a/code/modules/mob/living/silicon/robot/robot_defense.dm b/code/modules/mob/living/silicon/robot/robot_defense.dm
index 594b7ee6e60..6250193bdb5 100644
--- a/code/modules/mob/living/silicon/robot/robot_defense.dm
+++ b/code/modules/mob/living/silicon/robot/robot_defense.dm
@@ -12,15 +12,232 @@ GLOBAL_LIST_INIT(blacklisted_borg_hats, typecacheof(list( //Hats that don't real
var/mob/buckmob = i
unbuckle_mob(buckmob)
-/mob/living/silicon/robot/attackby(obj/item/I, mob/living/user)
- if(I.slot_flags & ITEM_SLOT_HEAD && hat_offset != INFINITY && user.a_intent == INTENT_HELP && !is_type_in_typecache(I, GLOB.blacklisted_borg_hats))
- to_chat(user, "You begin to place [I] on [src]'s head...")
- to_chat(src, "[user] is placing [I] on your head...")
- if(do_after(user, 30, target = src))
- if (user.temporarilyRemoveItemFromInventory(I, TRUE))
- place_on_head(I)
+
+/mob/living/silicon/robot/attackby(obj/item/W, mob/user, params)
+ if(W.tool_behaviour == TOOL_WELDER && (user.a_intent != INTENT_HARM || user == src))
+ user.changeNext_move(CLICK_CD_MELEE)
+ if (!getBruteLoss())
+ to_chat(user, "[src] is already in good condition!")
+ return
+ if (!W.tool_start_check(user, amount=0)) //The welder has 1u of fuel consumed by it's afterattack, so we don't need to worry about taking any away.
+ return
+ if(src == user)
+ to_chat(user, "You start fixing yourself...")
+ if(!W.use_tool(src, user, 50))
+ return
+
+ adjustBruteLoss(-30)
+ updatehealth()
+ add_fingerprint(user)
+ visible_message("[user] has fixed some of the dents on [src].")
return
- if(I.force && I.damtype != STAMINA && stat != DEAD) //only sparks if real damage is dealt.
+
+ if(istype(W, /obj/item/stack/cable_coil) && wiresexposed)
+ user.changeNext_move(CLICK_CD_MELEE)
+ var/obj/item/stack/cable_coil/coil = W
+ if (getFireLoss() > 0 || getToxLoss() > 0)
+ if(src == user)
+ to_chat(user, "You start fixing yourself...")
+ if(!do_after(user, 50, target = src))
+ return
+ if (coil.use(1))
+ adjustFireLoss(-30)
+ adjustToxLoss(-30)
+ updatehealth()
+ user.visible_message("[user] has fixed some of the burnt wires on [src].", "You fix some of the burnt wires on [src].")
+ else
+ to_chat(user, "You need more cable to repair [src]!")
+ else
+ to_chat(user, "The wires seem fine, there's no need to fix them.")
+ return
+
+ if(W.tool_behaviour == TOOL_CROWBAR) // crowbar means open or close the cover
+ if(opened)
+ to_chat(user, "You close the cover.")
+ opened = 0
+ update_icons()
+ else
+ if(locked)
+ to_chat(user, "The cover is locked and cannot be opened!")
+ else
+ to_chat(user, "You open the cover.")
+ opened = 1
+ update_icons()
+ return
+
+ if(istype(W, /obj/item/stock_parts/cell) && opened) // trying to put a cell inside
+ if(wiresexposed)
+ to_chat(user, "Close the cover first!")
+ else if(cell)
+ to_chat(user, "There is a power cell already installed!")
+ else
+ if(!user.transferItemToLoc(W, src))
+ return
+ cell = W
+ to_chat(user, "You insert the power cell.")
+ update_icons()
+ diag_hud_set_borgcell()
+ return
+
+ if(is_wire_tool(W))
+ if (wiresexposed)
+ wires.interact(user)
+ else
+ to_chat(user, "You can't reach the wiring!")
+ return
+
+ if(W.tool_behaviour == TOOL_SCREWDRIVER && opened) // wire hacking or radio management
+ if(!cell) //haxing
+ wiresexposed = !wiresexposed
+ to_chat(user, "The wires have been [wiresexposed ? "exposed" : "unexposed"].")
+ else //radio
+ if(shell)
+ to_chat(user, "You cannot seem to open the radio compartment!") //Prevent AI radio key theft
+ else if(radio)
+ radio.attackby(W,user)//Push it to the radio to let it handle everything
+ else
+ to_chat(user, "Unable to locate a radio!")
+ update_icons()
+ return
+
+ if(W.tool_behaviour == TOOL_WRENCH && opened && !cell) //Deconstruction. The flashes break from the fall, to prevent this from being a ghetto reset module.
+ if(!lockcharge)
+ to_chat(user, "[src]'s bolts spark! Maybe you should lock them down first!")
+ spark_system.start()
+ return
+ to_chat(user, "You start to unfasten [src]'s securing bolts...")
+ if(W.use_tool(src, user, 50, volume=50) && !cell)
+ user.visible_message("[user] deconstructs [src]!", "You unfasten the securing bolts, and [src] falls to pieces!")
+ deconstruct()
+ return
+
+ if(W.slot_flags & ITEM_SLOT_HEAD && hat_offset != INFINITY && user.a_intent == INTENT_HELP && !is_type_in_typecache(W, GLOB.blacklisted_borg_hats))
+ to_chat(user, "You begin to place [W] on [src]'s head...")
+ to_chat(src, "[user] is placing [W] on your head...")
+ if(do_after(user, 30, target = src))
+ if (user.temporarilyRemoveItemFromInventory(W, TRUE))
+ place_on_head(W)
+ return
+ if(istype(W, /obj/item/defibrillator) && user.a_intent == "help")
+ if(!opened)
+ to_chat(user, "You must access the cyborg's internals!")
+ return
+ if(!istype(module, /obj/item/robot_module/medical))
+ to_chat(user, "[src] does not have correct mounting points for a defibrillator!")
+ return
+ var/obj/item/defibrillator/D = W
+ if(D.slot_flags != ITEM_SLOT_BACK) //belt defibs need not apply
+ to_chat(user, "This defibrillator unit doesn't seem to fit correctly!")
+ return
+ if(D.cell)
+ to_chat(user, "You cannot connect the defibrillator to the cyborg power supply with the defibrillator's cell in the way!")
+ return
+ if(locate(/obj/item/borg/upgrade/defib) in src || locate(/obj/item/borg/upgrade/defib/backpack) in src)
+ to_chat(user, "[src] already has a defibrillator!")
+ return
+ var/obj/item/borg/upgrade/defib/backpack/B = new /obj/item/borg/upgrade/defib/backpack(src)
+ B.action(src, user)
+ to_chat(user, "You apply the upgrade to [src].")
+ to_chat(src, "----------------\nNew hardware detected...Identified as \"[D]\"...Setup complete.\n----------------")
+ upgrades += B
+ qdel(D)
+ return
+
+ if(istype(W, /obj/item/aiModule))
+ var/obj/item/aiModule/MOD = W
+ if(!opened)
+ to_chat(user, "You need access to the robot's insides to do that!")
+ return
+ if(wiresexposed)
+ to_chat(user, "You need to close the wire panel to do that!")
+ return
+ if(!cell)
+ to_chat(user, "You need to install a power cell to do that!")
+ return
+ if(shell) //AI shells always have the laws of the AI
+ to_chat(user, "[src] is controlled remotely! You cannot upload new laws this way!")
+ return
+ if(emagged || (connected_ai && lawupdate)) //Can't be sure which, metagamers
+ emote("buzz-[user.name]")
+ return
+ if(!mind) //A player mind is required for law procs to run antag checks.
+ to_chat(user, "[src] is entirely unresponsive!")
+ return
+ MOD.install(laws, user) //Proc includes a success mesage so we don't need another one
+ return
+
+ if(istype(W, /obj/item/encryptionkey/) && opened)
+ if(radio)//sanityyyyyy
+ radio.attackby(W,user)//GTFO, you have your own procs
+ else
+ to_chat(user, "Unable to locate a radio!")
+ return
+
+ if (istype(W, /obj/item/card/id)||istype(W, /obj/item/pda)) // trying to unlock the interface with an ID card
+ if(opened)
+ to_chat(user, "You must close the cover to swipe an ID card!")
+ else
+ if(allowed(usr))
+ locked = !locked
+ to_chat(user, "You [ locked ? "lock" : "unlock"] [src]'s cover.")
+ update_icons()
+ if(emagged)
+ to_chat(user, "The cover interface glitches out for a split second.")
+ else
+ to_chat(user, "Access denied.")
+ return
+
+ if(istype(W, /obj/item/borg/upgrade/))
+ var/obj/item/borg/upgrade/U = W
+ if(!opened)
+ to_chat(user, "You must access the cyborg's internals!")
+ else if(!src.module && U.require_module)
+ to_chat(user, "The cyborg must choose a module before it can be upgraded!")
+ else if(U.locked)
+ to_chat(user, "The upgrade is locked and cannot be used yet!")
+ else
+ if(!user.temporarilyRemoveItemFromInventory(U))
+ return
+ if(U.action(src))
+ to_chat(user, "You apply the upgrade to [src].")
+ to_chat(src, "----------------\nNew hardware detected...Identified as \"[U]\"...Setup complete.\n----------------")
+ if(U.one_use)
+ qdel(U)
+ else
+ U.forceMove(src)
+ upgrades += U
+ else
+ to_chat(user, "Upgrade error.")
+ U.forceMove(drop_location())
+ return
+
+ if(istype(W, /obj/item/toner))
+ if(toner >= tonermax)
+ to_chat(user, "The toner level of [src] is at its highest level possible!")
+ return
+ if(!user.temporarilyRemoveItemFromInventory(W))
+ return
+ toner = tonermax
+ qdel(W)
+ to_chat(user, "You fill the toner level of [src] to its max capacity.")
+ return
+
+ if(istype(W, /obj/item/flashlight))
+ if(!opened)
+ to_chat(user, "You need to open the panel to repair the headlamp!")
+ return
+ if(lamp_cooldown <= world.time)
+ to_chat(user, "The headlamp is already functional!")
+ return
+ if(!user.temporarilyRemoveItemFromInventory(W))
+ to_chat(user, "[W] seems to be stuck to your hand. You'll have to find a different light.")
+ return
+ lamp_cooldown = 0
+ qdel(W)
+ to_chat(user, "You replace the headlamp bulbs.")
+ return
+
+ if(W.force && W.damtype != STAMINA && stat != DEAD) //only sparks if real damage is dealt.
spark_system.start()
return ..()