Fixes Robots putting things in rechargers

This commit is contained in:
Nalarac
2019-07-27 14:53:08 -05:00
parent f6ae1dc4e1
commit 5cda8072b7
4 changed files with 72 additions and 59 deletions

View File

@@ -42,9 +42,9 @@
if(!..(user, 5))
return
user << "There's [charging ? "a" : "no"] cell in the charger."
to_chat(user, "[charging ? "[charging]" : "Nothing"] is in [src].")
if(charging)
user << "Current charge: [charging.charge]"
to_chat(user, "Current charge: [charging.charge] / [charging.maxcharge]")
/obj/machinery/cell_charger/attackby(obj/item/weapon/W, mob/user)
if(stat & BROKEN)
@@ -52,32 +52,32 @@
if(istype(W, /obj/item/weapon/cell) && anchored)
if(istype(W, /obj/item/weapon/cell/device))
user << "<span class='warning'> The charger isn't fitted for that type of cell.</span>"
to_chat(user, "<span class='warning'>\The [src] isn't fitted for that type of cell.</span>")
return
if(charging)
user << "<span class='warning'>There is already a cell in the charger.</span>"
to_chat(user, "<span class='warning'>There is already [charging] in [src].</span>")
return
else
var/area/a = loc.loc // Gets our locations location, like a dream within a dream
if(!isarea(a))
return
if(a.power_equip == 0) // There's no APC in this area, don't try to cheat power!
user << "<span class='warning'>The [name] blinks red as you try to insert the cell!</span>"
to_chat(user, "<span class='warning'>\The [src] blinks red as you try to insert [W]!</span>")
return
user.drop_item()
W.loc = src
charging = W
user.visible_message("[user] inserts a cell into the charger.", "You insert a cell into the charger.")
user.visible_message("[user] inserts [charging] into [src].", "You insert [charging] into [src].")
chargelevel = -1
update_icon()
else if(W.is_wrench())
if(charging)
user << "<span class='warning'>Remove the cell first!</span>"
to_chat(user, "<span class='warning'>Remove [charging] first!</span>")
return
anchored = !anchored
user << "You [anchored ? "attach" : "detach"] the cell charger [anchored ? "to" : "from"] the ground"
to_chat(user, "You [anchored ? "attach" : "detach"] [src] [anchored ? "to" : "from"] the ground")
playsound(src, W.usesound, 75, 1)
else if(default_deconstruction_screwdriver(user, W))
return
@@ -87,27 +87,25 @@
return
/obj/machinery/cell_charger/attack_hand(mob/user)
add_fingerprint(user)
if(charging)
usr.put_in_hands(charging)
charging.add_fingerprint(user)
user.put_in_hands(charging)
charging.update_icon()
user.visible_message("[user] removes [charging] from [src].", "You remove [charging] from [src].")
charging = null
user.visible_message("[user] removes the cell from the charger.", "You remove the cell from the charger.")
chargelevel = -1
update_icon()
/obj/machinery/cell_charger/attack_ai(mob/user)
if(istype(user, /mob/living/silicon/robot) && Adjacent(user)) // Borgs can remove the cell if they are near enough
if(!charging)
return
charging.loc = src.loc
charging.update_icon()
charging = null
update_icon()
user.visible_message("[user] removes the cell from the charger.", "You remove the cell from the charger.")
if(charging)
user.visible_message("[user] removes [charging] from [src].", "You remove [charging] from [src].")
charging.loc = src.loc
charging.update_icon()
charging = null
update_icon()
/obj/machinery/cell_charger/emp_act(severity)
if(stat & (BROKEN|NOPOWER))

View File

@@ -1,6 +1,7 @@
//This file was auto-corrected by findeclaration.exe on 25.5.2012 20:42:31
/obj/machinery/recharger
name = "recharger"
desc = "A standard recharger for all devices that use power."
icon = 'icons/obj/stationobjs.dmi'
icon_state = "recharger0"
anchored = 1
@@ -24,6 +25,15 @@
..()
return
/obj/machinery/recharger/examine(mob/user)
if(!..(user, 5))
return
to_chat(user, "[charging ? "[charging]" : "Nothing"] is in [src].")
if(charging)
var/obj/item/weapon/cell/C = charging.get_cell()
to_chat(user, "Current charge: [C.charge] / [C.maxcharge]")
/obj/machinery/recharger/attackby(obj/item/weapon/G as obj, mob/user as mob)
var/allowed = 0
for (var/allowed_type in allowed_devices)
@@ -35,32 +45,49 @@
return
// Checks to make sure he's not in space doing it, and that the area got proper power.
if(!powered())
to_chat(user, "<span class='warning'>The [name] blinks red as you try to insert the item!</span>")
to_chat(user, "<span class='warning'>\The [src] blinks red as you try to insert [G]!</span>")
return
if(istype(G, /obj/item/weapon/gun/energy))
var/obj/item/weapon/gun/energy/E = G
if(E.self_recharge)
to_chat(user, "<span class='notice'>Your gun has no recharge port.</span>")
to_chat(user, "<span class='notice'>\The [E] has no recharge port.</span>")
return
if(istype(G, /obj/item/modular_computer))
var/obj/item/modular_computer/C = G
if(!C.battery_module)
to_chat(user, "This device does not have a battery installed.")
to_chat(user, "<span class='notice'>\The [C] does not have a battery installed. </span>")
return
if(istype(G, /obj/item/weapon/melee/baton))
var/obj/item/weapon/melee/baton/B = G
if(B.use_external_power)
to_chat(user, "<span class='notice'>\The [B] has no recharge port.</span>")
return
if(istype(G, /obj/item/device/flash))
var/obj/item/device/flash/F = G
if(F.use_external_power)
to_chat(user, "<span class='notice'>\The [F] has no recharge port.</span>")
return
if(istype(G, /obj/item/weapon/weldingtool/electric))
var/obj/item/weapon/weldingtool/electric/EW = G
if(EW.use_external_power)
to_chat(user, "<span class='notice'>\The [EW] has no recharge port.</span>")
return
else if(!G.get_cell())
to_chat(user, "This device does not have a battery installed.")
to_chat(user, "\The [G] does not have a battery installed.")
return
user.drop_item()
G.loc = src
charging = G
update_icon()
user.visible_message("[user] inserts [charging] into [src].", "You insert [charging] into [src].")
else if(portable && G.is_wrench())
if(charging)
to_chat(user, "<span class='warning'>Remove [charging] first!</span>")
return
anchored = !anchored
to_chat(user, "You [anchored ? "attached" : "detached"] the recharger.")
to_chat(user, "You [anchored ? "attached" : "detached"] [src].")
playsound(loc, G.usesound, 75, 1)
else if(default_deconstruction_screwdriver(user, G))
return
@@ -70,17 +97,24 @@
return
/obj/machinery/recharger/attack_hand(mob/user as mob)
if(istype(user,/mob/living/silicon))
return
add_fingerprint(user)
if(charging)
user.visible_message("[user] removes [charging] from [src].", "You remove [charging] from [src].")
charging.update_icon()
user.put_in_hands(charging)
charging = null
update_icon()
/obj/machinery/cell_charger/attack_ai(mob/user)
if(istype(user, /mob/living/silicon/robot) && Adjacent(user)) // Borgs can remove the cell if they are near enough
if(charging)
user.visible_message("[user] removes [charging] from [src].", "You remove [charging] from [src].")
charging.update_icon()
charging.loc = src.loc
charging = null
update_icon()
/obj/machinery/recharger/process()
if(stat & (NOPOWER|BROKEN) || !anchored)
update_use_power(0)
@@ -148,6 +182,7 @@
/obj/machinery/recharger/wallcharger
name = "wall recharger"
desc = "A more powerful recharger designed for energy weapons."
icon = 'icons/obj/stationobjs.dmi'
icon_state = "wrecharger0"
plane = TURF_PLANE

View File

@@ -18,6 +18,7 @@
var/status = 0 //whether the thing is on or not
var/obj/item/weapon/cell/bcell = null
var/hitcost = 240
var/use_external_power = FALSE //only used to determine if it's a cyborg baton
/obj/item/weapon/melee/baton/New()
..()
@@ -108,6 +109,8 @@
user <<"<span class='warning'>The baton does not have a power source installed.</span>"
/obj/item/weapon/melee/baton/attackby(obj/item/weapon/W, mob/user)
if(use_external_power)
return
if(istype(W, /obj/item/weapon/cell))
if(istype(W, /obj/item/weapon/cell/device))
if(!bcell)
@@ -136,6 +139,11 @@
return ..()
/obj/item/weapon/melee/baton/attack_self(mob/user)
if(use_external_power)
//try to find our power cell
var/mob/living/silicon/robot/R = loc
if (istype(R))
bcell = R.cell
if(bcell && bcell.charge > hitcost)
status = !status
user << "<span class='notice'>[src] is now [status ? "on" : "off"].</span>"
@@ -204,16 +212,7 @@
//secborg stun baton module
/obj/item/weapon/melee/baton/robot
hitcost = 500
/obj/item/weapon/melee/baton/robot/attack_self(mob/user)
//try to find our power cell
var/mob/living/silicon/robot/R = loc
if (istype(R))
bcell = R.cell
return ..()
/obj/item/weapon/melee/baton/robot/attackby(obj/item/weapon/W, mob/user)
return
use_external_power = TRUE
//Makeshift stun baton. Replacement for stun gloves.
/obj/item/weapon/melee/baton/cattleprod
@@ -274,13 +273,4 @@
// Borg version, for the lost module.
/obj/item/weapon/melee/baton/shocker/robot
/obj/item/weapon/melee/baton/shocker/robot/attack_self(mob/user)
//try to find our power cell
var/mob/living/silicon/robot/R = loc
if (istype(R))
bcell = R.cell
return ..()
/obj/item/weapon/melee/baton/shocker/robot/attackby(obj/item/weapon/W, mob/user)
return
use_external_power = TRUE

View File

@@ -38,17 +38,7 @@
// Research borg's version
/obj/item/weapon/melee/baton/slime/robot
hitcost = 200
/obj/item/weapon/melee/baton/slime/robot/attack_self(mob/user)
//try to find our power cell
var/mob/living/silicon/robot/R = loc
if (istype(R))
bcell = R.cell
return ..()
/obj/item/weapon/melee/baton/slime/robot/attackby(obj/item/weapon/W, mob/user)
return
use_external_power = TRUE
// Xeno stun gun + projectile
/obj/item/weapon/gun/energy/taser/xeno