mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-10 18:22:39 +00:00
193 lines
5.5 KiB
Plaintext
193 lines
5.5 KiB
Plaintext
/obj/item/weapon/rig/attackby(obj/item/W as obj, mob/user as mob)
|
|
|
|
if(!istype(user,/mob/living)) return 0
|
|
|
|
if(electrified != 0)
|
|
if(cell && cell.charge >= 100)
|
|
cell.use(100)
|
|
if(shock(user, 100))
|
|
return
|
|
|
|
// Pass repair items on to the chestpiece.
|
|
if(chest && (istype(W,/obj/item/stack/sheet/mineral/plastic) || istype(W,/obj/item/stack/sheet/metal) || istype(W, /obj/item/weapon/weldingtool)))
|
|
return chest.attackby(W,user)
|
|
|
|
// Lock or unlock the access panel.
|
|
if(istype(W, /obj/item/weapon/card) || istype(W, /obj/item/device/pda))
|
|
|
|
if(subverted)
|
|
locked = 0
|
|
user << "<span class='danger'>It looks like the locking system has been shorted out.</span>"
|
|
return
|
|
else if(istype(W, /obj/item/weapon/card/emag))
|
|
req_access = null
|
|
req_one_access = null
|
|
locked = 0
|
|
subverted = 1
|
|
user << "<span class='danger'>You short out the access protocol for the suit.</span>"
|
|
return
|
|
|
|
if((!req_access || !req_access.len) && (!req_one_access || !req_one_access.len))
|
|
locked = 0
|
|
user << "<span class='danger'>\The [src] doesn't seem to have a locking mechanism.</span>"
|
|
return
|
|
|
|
if(security_check_enabled && !src.allowed(user))
|
|
user << "<span class='danger'>Access denied.</span>"
|
|
return
|
|
|
|
locked = !locked
|
|
user << "You [locked ? "lock" : "unlock"] \the [src] access panel."
|
|
return
|
|
|
|
else if(istype(W,/obj/item/weapon/crowbar))
|
|
|
|
if(!open && locked)
|
|
user << "The access panel is locked shut."
|
|
return
|
|
|
|
open = !open
|
|
user << "You [open ? "open" : "close"] the access panel."
|
|
return
|
|
|
|
if(open)
|
|
|
|
// Hacking.
|
|
if(istype(W,/obj/item/weapon/wirecutters) || istype(W,/obj/item/device/multitool))
|
|
if(open)
|
|
wires.Interact(user)
|
|
else
|
|
user << "You can't reach the wiring."
|
|
return
|
|
// Air tank.
|
|
if(istype(W,/obj/item/weapon/tank)) //Todo, some kind of check for suits without integrated air supplies.
|
|
|
|
if(air_supply)
|
|
user << "\The [src] already has a tank installed."
|
|
return
|
|
|
|
user.drop_from_inventory(W)
|
|
air_supply = W
|
|
W.loc = src
|
|
user << "You slot [W] into [src] and tighten the connecting valve."
|
|
return
|
|
|
|
// Check if this is a hardsuit upgrade or a modification.
|
|
else if(istype(W,/obj/item/rig_module))
|
|
|
|
if(istype(src.loc,/mob/living/carbon/human))
|
|
var/mob/living/carbon/human/H = src.loc
|
|
if(H.back == src)
|
|
user << "<span class='danger'>You can't install a hardsuit module while the suit is being worn.</span>"
|
|
return 1
|
|
|
|
if(!installed_modules) installed_modules = list()
|
|
if(installed_modules.len)
|
|
for(var/obj/item/rig_module/installed_mod in installed_modules)
|
|
if(!installed_mod.redundant && istype(installed_mod,W))
|
|
user << "The hardsuit already has a module of that class installed."
|
|
return 1
|
|
|
|
var/obj/item/rig_module/mod = W
|
|
user << "You begin installing \the [mod] into \the [src]."
|
|
if(!do_after(user,40))
|
|
return
|
|
if(!user || !W)
|
|
return
|
|
user << "You install \the [mod] into \the [src]."
|
|
user.drop_from_inventory(mod)
|
|
installed_modules |= mod
|
|
mod.loc = src
|
|
mod.installed(src)
|
|
update_icon()
|
|
return 1
|
|
|
|
else if(!cell && istype(W,/obj/item/weapon/cell))
|
|
|
|
user << "You jack \the [W] into \the [src]'s battery mount."
|
|
user.drop_from_inventory(W)
|
|
W.loc = src
|
|
src.cell = W
|
|
return
|
|
|
|
else if(istype(W,/obj/item/weapon/wrench))
|
|
|
|
if(!air_supply)
|
|
user << "There is not tank to remove."
|
|
return
|
|
|
|
user.put_in_hands(air_supply)
|
|
user << "You detach and remove \the [air_supply]."
|
|
air_supply = null
|
|
return
|
|
|
|
else if(istype(W,/obj/item/weapon/screwdriver))
|
|
|
|
var/list/current_mounts = list()
|
|
if(cell) current_mounts += "cell"
|
|
if(installed_modules && installed_modules.len) current_mounts += "system module"
|
|
|
|
var/to_remove = input("Which would you like to modify?") as null|anything in current_mounts
|
|
if(!to_remove)
|
|
return
|
|
|
|
if(istype(src.loc,/mob/living/carbon/human) && to_remove != "cell")
|
|
var/mob/living/carbon/human/H = src.loc
|
|
if(H.back == src)
|
|
user << "You can't remove an installed device while the hardsuit is being worn."
|
|
return
|
|
|
|
switch(to_remove)
|
|
|
|
if("cell")
|
|
|
|
if(cell)
|
|
user << "You detatch \the [cell] from \the [src]'s battery mount."
|
|
for(var/obj/item/rig_module/module in installed_modules)
|
|
module.deactivate()
|
|
cell.loc = user.put_in_hands(cell)
|
|
cell = null
|
|
else
|
|
user << "There is nothing loaded in that mount."
|
|
|
|
if("system module")
|
|
|
|
var/list/possible_removals = list()
|
|
for(var/obj/item/rig_module/module in installed_modules)
|
|
if(module.permanent)
|
|
continue
|
|
possible_removals[module.name] = module
|
|
|
|
if(!possible_removals.len)
|
|
user << "There are no installed modules to remove."
|
|
return
|
|
|
|
var/removal_choice = input("Which module would you like to remove?") as null|anything in possible_removals
|
|
if(!removal_choice)
|
|
return
|
|
|
|
var/obj/item/rig_module/removed = possible_removals[removal_choice]
|
|
user << "You detatch \the [removed] from \the [src]."
|
|
removed.loc = get_turf(src)
|
|
removed.removed()
|
|
installed_modules -= removed
|
|
update_icon()
|
|
|
|
return
|
|
|
|
// If we've gotten this far, all we have left to do before we pass off to root procs
|
|
// is check if any of the loaded modules want to use the item we've been given.
|
|
for(var/obj/item/rig_module/module in installed_modules)
|
|
if(module.accepts_item(W,user)) //Item is handled in this proc
|
|
return
|
|
..()
|
|
|
|
|
|
/obj/item/weapon/rig/attack_hand(var/mob/user)
|
|
|
|
if(electrified != 0)
|
|
if(cell && cell.charge >= 100)
|
|
cell.use(100)
|
|
if(shock(user, 100))
|
|
return
|
|
..() |