Updated Cell charger and recharger

Cell charger and Recharger are now wrenchable to make them moveable
Cleaned up autolathe code, removed the delay when inserting sheets, using any item on it while maintence cover is open will result in cable window opening.

git-svn-id: http://tgstation13.googlecode.com/svn/trunk@3406 316c924e-a436-60f5-8080-3fe189b3f50e
This commit is contained in:
daniel.cf.hultgren@gmail.com
2012-04-06 10:11:50 +00:00
parent 11a30e09b4
commit 219565eac6
4 changed files with 433 additions and 388 deletions
-12
View File
@@ -361,18 +361,6 @@
idle_power_usage = 20
active_power_usage = 80
/obj/machinery/cell_charger
name = "cell charger"
desc = "It charges power cells."
icon = 'power.dmi'
icon_state = "ccharger0"
var/obj/item/weapon/cell/charging = null
var/chargelevel = -1
anchored = 1
use_power = 1
idle_power_usage = 5
active_power_usage = 60
/obj/machinery/light_switch
name = "light switch"
desc = "It turns lights on and off. What are you, simple?"
+275 -271
View File
@@ -1,226 +1,3 @@
/obj/machinery/autolathe
var/busy = 0
var/max_m_amount = 150000.0
var/max_g_amount = 75000.0
/obj/machinery/autolathe/attackby(var/obj/item/O as obj, var/mob/user as mob)
if (stat)
return 1
if (busy)
user << "\red The autolathe is busy. Please wait for completion of previous operation."
return 1
if (istype(O, /obj/item/weapon/screwdriver))
if (!opened)
src.opened = 1
src.icon_state = "autolathe_t"
user << "You open the maintenance hatch of [src]."
else
src.opened = 0
src.icon_state = "autolathe"
user << "You close the maintenance hatch of [src]."
return 1
if (opened)
if(istype(O, /obj/item/weapon/crowbar))
playsound(src.loc, 'Crowbar.ogg', 50, 1)
var/obj/machinery/constructable_frame/machine_frame/M = new /obj/machinery/constructable_frame/machine_frame(src.loc)
M.state = 2
M.icon_state = "box_1"
for(var/obj/I in component_parts)
if(I.reliability != 100 && crit_fail)
I.crit_fail = 1
I.loc = src.loc
if(m_amount >= 3750)
var/obj/item/stack/sheet/metal/G = new /obj/item/stack/sheet/metal(src.loc)
G.amount = round(m_amount / 3750)
if(g_amount >= 3750)
var/obj/item/stack/sheet/glass/G = new /obj/item/stack/sheet/glass(src.loc)
G.amount = round(g_amount / 3750)
del(src)
return 1
else
user << "\red You can't load the autolathe while it's opened."
return 1
if (src.m_amount + O.m_amt > max_m_amount)
user << "\red The autolathe is full. Please remove metal from the autolathe in order to insert more."
return 1
if (src.g_amount + O.g_amt > max_g_amount)
user << "\red The autolathe is full. Please remove glass from the autolathe in order to insert more."
return 1
if (O.m_amt == 0 && O.g_amt == 0)
user << "\red This object does not contain significant amounts of metal or glass, or cannot be accepted by the autolathe due to size or hazardous materials."
return 1
/*
if (istype(O, /obj/item/weapon/grab) && src.hacked)
var/obj/item/weapon/grab/G = O
if (prob(25) && G.affecting)
G.affecting.gib()
m_amount += 50000
return
*/
var/amount = 1
var/obj/item/stack/stack
var/m_amt = O.m_amt
var/g_amt = O.g_amt
if (istype(O, /obj/item/stack))
stack = O
amount = stack.amount
if (m_amt)
amount = min(amount, round((max_m_amount-src.m_amount)/m_amt))
flick("autolathe_o",src)//plays metal insertion animation
if (g_amt)
amount = min(amount, round((max_g_amount-src.g_amount)/g_amt))
flick("autolathe_r",src)//plays glass insertion animation
stack.use(amount)
else
usr.before_take_item(O)
O.loc = src
icon_state = "autolathe"
busy = 1
use_power(max(1000, (m_amt+g_amt)*amount/10))
spawn(16)
icon_state = "autolathe"
flick("autolathe_o",src)
src.m_amount += m_amt * amount
src.g_amount += g_amt * amount
if (O && O.loc == src)
del(O)
busy = 0
src.updateUsrDialog()
/obj/machinery/autolathe/attack_paw(mob/user as mob)
return src.attack_hand(user)
/obj/machinery/autolathe/attack_hand(mob/user as mob)
user.machine = src
interact(user)
/obj/machinery/autolathe/proc/wires_win(mob/user as mob)
var/dat as text
dat += "Autolathe Wires:<BR>"
for(var/wire in src.wires)
dat += text("[wire] Wire: <A href='?src=\ref[src];wire=[wire];act=wire'>[src.wires[wire] ? "Mend" : "Cut"]</A> <A href='?src=\ref[src];wire=[wire];act=pulse'>Pulse</A><BR>")
dat += text("The red light is [src.disabled ? "off" : "on"].<BR>")
dat += text("The green light is [src.shocked ? "off" : "on"].<BR>")
dat += text("The blue light is [src.hacked ? "off" : "on"].<BR>")
user << browse("<HTML><HEAD><TITLE>Autolathe Hacking</TITLE></HEAD><BODY>[dat]</BODY></HTML>","window=autolathe_hack")
onclose(user, "autolathe_hack")
/obj/machinery/autolathe/proc/regular_win(mob/user as mob)
var/dat as text
dat = text("<B>Metal Amount:</B> [src.m_amount] cm<sup>3</sup> (MAX: [max_m_amount])<BR>\n<FONT color=blue><B>Glass Amount:</B></FONT> [src.g_amount] cm<sup>3</sup> (MAX: [max_g_amount])<HR>")
var/list/objs = list()
objs += src.L
if (src.hacked)
objs += src.LL
for(var/obj/t in objs)
var/title = "[t.name] ([t.m_amt] m /[t.g_amt] g)"
if (m_amount<t.m_amt || g_amount<t.g_amt)
dat += title + "<br>"
continue
dat += "<A href='?src=\ref[src];make=\ref[t]'>[title]</A>"
if (istype(t, /obj/item/stack))
var/obj/item/stack/S = t
var/max_multiplier = min(S.max_amount, S.m_amt?round(m_amount/S.m_amt):INFINITY, S.g_amt?round(g_amount/S.g_amt):INFINITY)
if (max_multiplier>1)
dat += " |"
if (max_multiplier>10)
dat += " <A href='?src=\ref[src];make=\ref[t];multiplier=[10]'>x[10]</A>"
if (max_multiplier>25)
dat += " <A href='?src=\ref[src];make=\ref[t];multiplier=[25]'>x[25]</A>"
if (max_multiplier>1)
dat += " <A href='?src=\ref[src];make=\ref[t];multiplier=[max_multiplier]'>x[max_multiplier]</A>"
dat += "<br>"
user << browse("<HTML><HEAD><TITLE>Autolathe Control Panel</TITLE></HEAD><BODY><TT>[dat]</TT></BODY></HTML>", "window=autolathe_regular")
onclose(user, "autolathe_regular")
/obj/machinery/autolathe/proc/interact(mob/user as mob)
if(..())
return
if (src.shocked)
src.shock(user,50)
if (src.opened)
wires_win(user,50)
return
if (src.disabled)
user << "\red You press the button, but nothing happens."
return
regular_win(user)
return
/obj/machinery/autolathe/Topic(href, href_list)
if(..())
return
usr.machine = src
src.add_fingerprint(usr)
if (!busy)
if(href_list["make"])
var/turf/T = get_step(src.loc, get_dir(src,usr))
var/obj/template = locate(href_list["make"])
var/multiplier = text2num(href_list["multiplier"])
if (!multiplier) multiplier = 1
var/power = max(2000, (template.m_amt+template.g_amt)*multiplier/5)
if(src.m_amount >= template.m_amt*multiplier && src.g_amount >= template.g_amt*multiplier)
busy = 1
use_power(power)
icon_state = "autolathe"
flick("autolathe_n",src)
spawn(16)
use_power(power)
spawn(16)
use_power(power)
spawn(16)
src.m_amount -= template.m_amt*multiplier
src.g_amount -= template.g_amt*multiplier
if(src.m_amount < 0)
src.m_amount = 0
if(src.g_amount < 0)
src.g_amount = 0
var/obj/new_item = new template.type(T)
if (multiplier>1)
var/obj/item/stack/S = new_item
S.amount = multiplier
busy = 0
src.updateUsrDialog()
if(href_list["act"])
var/temp_wire = href_list["wire"]
if(href_list["act"] == "pulse")
if (!istype(usr.equipped(), /obj/item/device/multitool))
usr << "You need a multitool!"
else
if(src.wires[temp_wire])
usr << "You can't pulse a cut wire."
else
if(src.hack_wire == temp_wire)
src.hacked = !src.hacked
spawn(100) src.hacked = !src.hacked
if(src.disable_wire == temp_wire)
src.disabled = !src.disabled
src.shock(usr,50)
spawn(100) src.disabled = !src.disabled
if(src.shock_wire == temp_wire)
src.shocked = !src.shocked
src.shock(usr,50)
spawn(100) src.shocked = !src.shocked
if(href_list["act"] == "wire")
if (!istype(usr.equipped(), /obj/item/weapon/wirecutters))
usr << "You need wirecutters!"
else
wires[temp_wire] = !wires[temp_wire]
if(src.hack_wire == temp_wire)
src.hacked = !src.hacked
if(src.disable_wire == temp_wire)
src.disabled = !src.disabled
src.shock(usr,50)
if(src.shock_wire == temp_wire)
src.shocked = !src.shocked
src.shock(usr,50)
else
usr << "\red The autolathe is busy. Please wait for completion of previous operation."
src.updateUsrDialog()
return
var/global/list/autolathe_recipes = list( \
/* screwdriver removed*/ \
new /obj/item/weapon/reagent_containers/glass/bucket(), \
@@ -271,55 +48,282 @@ var/global/list/autolathe_recipes_hidden = list( \
/* new /obj/item/weapon/shield/riot(), */ \
)
/obj/machinery/autolathe/RefreshParts()
..()
var/tot_rating = 0
for(var/obj/item/weapon/stock_parts/matter_bin/MB in component_parts)
tot_rating += MB.rating
tot_rating *= 25000
max_m_amount = tot_rating * 2
max_g_amount = tot_rating
/obj/machinery/autolathe
var
busy = 0
max_m_amount = 150000.0
max_g_amount = 75000.0
proc
wires_win(mob/user as mob)
var/dat as text
dat += "Autolathe Wires:<BR>"
for(var/wire in src.wires)
dat += text("[wire] Wire: <A href='?src=\ref[src];wire=[wire];act=wire'>[src.wires[wire] ? "Mend" : "Cut"]</A> <A href='?src=\ref[src];wire=[wire];act=pulse'>Pulse</A><BR>")
dat += text("The red light is [src.disabled ? "off" : "on"].<BR>")
dat += text("The green light is [src.shocked ? "off" : "on"].<BR>")
dat += text("The blue light is [src.hacked ? "off" : "on"].<BR>")
user << browse("<HTML><HEAD><TITLE>Autolathe Hacking</TITLE></HEAD><BODY>[dat]</BODY></HTML>","window=autolathe_hack")
onclose(user, "autolathe_hack")
regular_win(mob/user as mob)
var/dat as text
dat = text("<B>Metal Amount:</B> [src.m_amount] cm<sup>3</sup> (MAX: [max_m_amount])<BR>\n<FONT color=blue><B>Glass Amount:</B></FONT> [src.g_amount] cm<sup>3</sup> (MAX: [max_g_amount])<HR>")
var/list/objs = list()
objs += src.L
if (src.hacked)
objs += src.LL
for(var/obj/t in objs)
var/title = "[t.name] ([t.m_amt] m /[t.g_amt] g)"
if (m_amount<t.m_amt || g_amount<t.g_amt)
dat += title + "<br>"
continue
dat += "<A href='?src=\ref[src];make=\ref[t]'>[title]</A>"
if (istype(t, /obj/item/stack))
var/obj/item/stack/S = t
var/max_multiplier = min(S.max_amount, S.m_amt?round(m_amount/S.m_amt):INFINITY, S.g_amt?round(g_amount/S.g_amt):INFINITY)
if (max_multiplier>1)
dat += " |"
if (max_multiplier>10)
dat += " <A href='?src=\ref[src];make=\ref[t];multiplier=[10]'>x[10]</A>"
if (max_multiplier>25)
dat += " <A href='?src=\ref[src];make=\ref[t];multiplier=[25]'>x[25]</A>"
if (max_multiplier>1)
dat += " <A href='?src=\ref[src];make=\ref[t];multiplier=[max_multiplier]'>x[max_multiplier]</A>"
dat += "<br>"
user << browse("<HTML><HEAD><TITLE>Autolathe Control Panel</TITLE></HEAD><BODY><TT>[dat]</TT></BODY></HTML>", "window=autolathe_regular")
onclose(user, "autolathe_regular")
interact(mob/user as mob)
if(..())
return
if (src.shocked)
src.shock(user,50)
if (src.opened)
wires_win(user,50)
return
if (src.disabled)
user << "\red You press the button, but nothing happens."
return
regular_win(user)
return
shock(mob/user, prb)
if(stat & (BROKEN|NOPOWER)) // unpowered, no shock
return 0
if(!prob(prb))
return 0
var/datum/effect/effect/system/spark_spread/s = new /datum/effect/effect/system/spark_spread
s.set_up(5, 1, src)
s.start()
if (electrocute_mob(user, get_area(src), src, 0.7))
return 1
else
return 0
attackby(var/obj/item/O as obj, var/mob/user as mob)
if (stat)
return 1
if (busy)
user << "\red The autolathe is busy. Please wait for completion of previous operation."
return 1
if (istype(O, /obj/item/weapon/screwdriver))
if (!opened)
src.opened = 1
src.icon_state = "autolathe_t"
user << "You open the maintenance hatch of [src]."
else
src.opened = 0
src.icon_state = "autolathe"
user << "You close the maintenance hatch of [src]."
return 1
if (opened)
if(istype(O, /obj/item/weapon/crowbar))
playsound(src.loc, 'Crowbar.ogg', 50, 1)
var/obj/machinery/constructable_frame/machine_frame/M = new /obj/machinery/constructable_frame/machine_frame(src.loc)
M.state = 2
M.icon_state = "box_1"
for(var/obj/I in component_parts)
if(I.reliability != 100 && crit_fail)
I.crit_fail = 1
I.loc = src.loc
if(m_amount >= 3750)
var/obj/item/stack/sheet/metal/G = new /obj/item/stack/sheet/metal(src.loc)
G.amount = round(m_amount / 3750)
if(g_amount >= 3750)
var/obj/item/stack/sheet/glass/G = new /obj/item/stack/sheet/glass(src.loc)
G.amount = round(g_amount / 3750)
del(src)
return 1
else
user.machine = src
interact(user)
return 1
if (src.m_amount + O.m_amt > max_m_amount)
user << "\red The autolathe is full. Please remove metal from the autolathe in order to insert more."
return 1
if (src.g_amount + O.g_amt > max_g_amount)
user << "\red The autolathe is full. Please remove glass from the autolathe in order to insert more."
return 1
if (O.m_amt == 0 && O.g_amt == 0)
user << "\red This object does not contain significant amounts of metal or glass, or cannot be accepted by the autolathe due to size or hazardous materials."
return 1
/*
if (istype(O, /obj/item/weapon/grab) && src.hacked)
var/obj/item/weapon/grab/G = O
if (prob(25) && G.affecting)
G.affecting.gib()
m_amount += 50000
return
*/
var/amount = 1
var/obj/item/stack/stack
var/m_amt = O.m_amt
var/g_amt = O.g_amt
if (istype(O, /obj/item/stack))
stack = O
amount = stack.amount
if (m_amt)
amount = min(amount, round((max_m_amount-src.m_amount)/m_amt))
flick("autolathe_o",src)//plays metal insertion animation
if (g_amt)
amount = min(amount, round((max_g_amount-src.g_amount)/g_amt))
flick("autolathe_r",src)//plays glass insertion animation
stack.use(amount)
else
usr.before_take_item(O)
O.loc = src
icon_state = "autolathe"
busy = 1
use_power(max(1000, (m_amt+g_amt)*amount/10))
src.m_amount += m_amt * amount
src.g_amount += g_amt * amount
user << "You insert [amount] sheet[amount>1 ? "s" : ""] to the autolathe."
if (O && O.loc == src)
del(O)
busy = 0
src.updateUsrDialog()
attack_paw(mob/user as mob)
return src.attack_hand(user)
attack_hand(mob/user as mob)
user.machine = src
interact(user)
Topic(href, href_list)
if(..())
return
usr.machine = src
src.add_fingerprint(usr)
if (!busy)
if(href_list["make"])
var/turf/T = get_step(src.loc, get_dir(src,usr))
var/obj/template = locate(href_list["make"])
var/multiplier = text2num(href_list["multiplier"])
if (!multiplier) multiplier = 1
var/power = max(2000, (template.m_amt+template.g_amt)*multiplier/5)
if(src.m_amount >= template.m_amt*multiplier && src.g_amount >= template.g_amt*multiplier)
busy = 1
use_power(power)
icon_state = "autolathe"
flick("autolathe_n",src)
spawn(16)
use_power(power)
spawn(16)
use_power(power)
spawn(16)
src.m_amount -= template.m_amt*multiplier
src.g_amount -= template.g_amt*multiplier
if(src.m_amount < 0)
src.m_amount = 0
if(src.g_amount < 0)
src.g_amount = 0
var/obj/new_item = new template.type(T)
if (multiplier>1)
var/obj/item/stack/S = new_item
S.amount = multiplier
busy = 0
src.updateUsrDialog()
if(href_list["act"])
var/temp_wire = href_list["wire"]
if(href_list["act"] == "pulse")
if (!istype(usr.equipped(), /obj/item/device/multitool))
usr << "You need a multitool!"
else
if(src.wires[temp_wire])
usr << "You can't pulse a cut wire."
else
if(src.hack_wire == temp_wire)
src.hacked = !src.hacked
spawn(100) src.hacked = !src.hacked
if(src.disable_wire == temp_wire)
src.disabled = !src.disabled
src.shock(usr,50)
spawn(100) src.disabled = !src.disabled
if(src.shock_wire == temp_wire)
src.shocked = !src.shocked
src.shock(usr,50)
spawn(100) src.shocked = !src.shocked
if(href_list["act"] == "wire")
if (!istype(usr.equipped(), /obj/item/weapon/wirecutters))
usr << "You need wirecutters!"
else
wires[temp_wire] = !wires[temp_wire]
if(src.hack_wire == temp_wire)
src.hacked = !src.hacked
if(src.disable_wire == temp_wire)
src.disabled = !src.disabled
src.shock(usr,50)
if(src.shock_wire == temp_wire)
src.shocked = !src.shocked
src.shock(usr,50)
else
usr << "\red The autolathe is busy. Please wait for completion of previous operation."
src.updateUsrDialog()
return
/obj/machinery/autolathe/New()
..()
component_parts = list()
component_parts += new /obj/item/weapon/circuitboard/autolathe(src)
component_parts += new /obj/item/weapon/stock_parts/matter_bin(src)
component_parts += new /obj/item/weapon/stock_parts/matter_bin(src)
component_parts += new /obj/item/weapon/stock_parts/matter_bin(src)
component_parts += new /obj/item/weapon/stock_parts/manipulator(src)
component_parts += new /obj/item/weapon/stock_parts/console_screen(src)
RefreshParts()
..()
var/tot_rating = 0
for(var/obj/item/weapon/stock_parts/matter_bin/MB in component_parts)
tot_rating += MB.rating
tot_rating *= 25000
max_m_amount = tot_rating * 2
max_g_amount = tot_rating
src.L = autolathe_recipes
src.LL = autolathe_recipes_hidden
src.wires["Light Red"] = 0
src.wires["Dark Red"] = 0
src.wires["Blue"] = 0
src.wires["Green"] = 0
src.wires["Yellow"] = 0
src.wires["Black"] = 0
src.wires["White"] = 0
src.wires["Gray"] = 0
src.wires["Orange"] = 0
src.wires["Pink"] = 0
var/list/w = list("Light Red","Dark Red","Blue","Green","Yellow","Black","White","Gray","Orange","Pink")
src.hack_wire = pick(w)
w -= src.hack_wire
src.shock_wire = pick(w)
w -= src.shock_wire
src.disable_wire = pick(w)
w -= src.disable_wire
New()
..()
component_parts = list()
component_parts += new /obj/item/weapon/circuitboard/autolathe(src)
component_parts += new /obj/item/weapon/stock_parts/matter_bin(src)
component_parts += new /obj/item/weapon/stock_parts/matter_bin(src)
component_parts += new /obj/item/weapon/stock_parts/matter_bin(src)
component_parts += new /obj/item/weapon/stock_parts/manipulator(src)
component_parts += new /obj/item/weapon/stock_parts/console_screen(src)
RefreshParts()
/obj/machinery/autolathe/proc/shock(mob/user, prb)
if(stat & (BROKEN|NOPOWER)) // unpowered, no shock
return 0
if(!prob(prb))
return 0
var/datum/effect/effect/system/spark_spread/s = new /datum/effect/effect/system/spark_spread
s.set_up(5, 1, src)
s.start()
if (electrocute_mob(user, get_area(src), src, 0.7))
return 1
else
return 0
src.L = autolathe_recipes
src.LL = autolathe_recipes_hidden
src.wires["Light Red"] = 0
src.wires["Dark Red"] = 0
src.wires["Blue"] = 0
src.wires["Green"] = 0
src.wires["Yellow"] = 0
src.wires["Black"] = 0
src.wires["White"] = 0
src.wires["Gray"] = 0
src.wires["Orange"] = 0
src.wires["Pink"] = 0
var/list/w = list("Light Red","Dark Red","Blue","Green","Yellow","Black","White","Gray","Orange","Pink")
src.hack_wire = pick(w)
w -= src.hack_wire
src.shock_wire = pick(w)
w -= src.shock_wire
src.disable_wire = pick(w)
w -= src.disable_wire
+84 -49
View File
@@ -1,57 +1,92 @@
/obj/machinery/cell_charger/attackby(obj/item/weapon/W, mob/user)
if(stat & BROKEN)
return
if(istype(W, /obj/item/weapon/cell))
if(charging)
user << "There is already a cell in the charger."
return
else
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.")
chargelevel = -1
updateicon()
/obj/machinery/cell_charger/proc/updateicon()
icon_state = "ccharger[charging ? 1 : 0]"
if(charging && !(stat & (BROKEN|NOPOWER)) )
var/newlevel = round( charging.percent() * 4.0 / 99 )
//world << "nl: [newlevel]"
if(chargelevel != newlevel)
overlays = null
overlays += image('power.dmi', "ccharger-o[newlevel]")
chargelevel = newlevel
else
overlays = null
/obj/machinery/cell_charger/attack_hand(mob/user)
if(charging)
usr.put_in_hand(charging)
charging.add_fingerprint(user)
charging.updateicon()
src.charging = null
user.visible_message("[user] removes the cell from the charger.", "You remove the cell from the charger.")
/obj/machinery/cell_charger
name = "cell charger"
desc = "It charges power cells."
icon = 'power.dmi'
icon_state = "ccharger0"
anchored = 1
use_power = 1
idle_power_usage = 5
active_power_usage = 60
power_channel = EQUIP
var
obj/item/weapon/cell/charging = null
chargelevel = -1
proc
updateicon()
icon_state = "ccharger[charging ? 1 : 0]"
/obj/machinery/cell_charger/attack_ai(mob/user)
return
if(charging && !(stat & (BROKEN|NOPOWER)) )
/obj/machinery/cell_charger/process()
//world << "ccpt [charging] [stat]"
if(!charging || (stat & (BROKEN|NOPOWER)) )
var/newlevel = round( charging.percent() * 4.0 / 99 )
//world << "nl: [newlevel]"
if(chargelevel != newlevel)
overlays = null
overlays += image('power.dmi', "ccharger-o[newlevel]")
chargelevel = newlevel
else
overlays = null
examine()
set src in oview(5)
..()
usr << "There's [charging ? "a" : "no"] cell in the charger."
if(charging)
usr << "Current charge: [charging.charge]"
attackby(obj/item/weapon/W, mob/user)
if(stat & BROKEN)
return
if(istype(W, /obj/item/weapon/cell) && anchored)
if(charging)
user << "\red There is already a cell in the charger."
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 << "\red The charger rejects the cell!"
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.")
chargelevel = -1
updateicon()
else if(istype(W, /obj/item/weapon/wrench))
if(charging)
user << "\red Remove the cell first!"
return
anchored = !anchored
user << "You [anchored ? "attach" : "detach"] the cell charger [anchored ? "to" : "from"] the ground"
playsound(src.loc, 'Ratchet.ogg', 75, 1)
attack_hand(mob/user)
if(charging)
usr.put_in_hand(charging)
charging.add_fingerprint(user)
charging.updateicon()
src.charging = null
user.visible_message("[user] removes the cell from the charger.", "You remove the cell from the charger.")
chargelevel = -1
updateicon()
attack_ai(mob/user)
return
var/added = charging.give(75)
use_power(added / CELLRATE)
process()
//world << "ccpt [charging] [stat]"
if(!charging || (stat & (BROKEN|NOPOWER)) || !anchored)
return
updateicon()
var/added = charging.give(75)
use_power(added / CELLRATE)
updateicon()
+74 -56
View File
@@ -1,5 +1,5 @@
obj/machinery/recharger
anchored = 1.0
anchored = 1
icon = 'stationobjs.dmi'
icon_state = "recharger0"
name = "recharger"
@@ -11,62 +11,80 @@ obj/machinery/recharger
obj/item/weapon/gun/energy/charging = null
obj/item/weapon/melee/baton/charging2 = null
/obj/machinery/recharger/attackby(obj/item/weapon/G as obj, mob/user as mob)
if (src.charging || src.charging2)
return
if (istype(G, /obj/item/weapon/gun/energy))
if (istype(G, /obj/item/weapon/gun/energy/gun/nuclear) || istype(G, /obj/item/weapon/gun/energy/crossbow))
user << "Your gun's recharge port was removed to make room for a miniaturized reactor."
return
if (istype(G, /obj/item/weapon/gun/energy/staff))
user << "It's a wooden staff, not a gun!"
return
user.drop_item()
G.loc = src
src.charging = G
use_power = 2
if (istype(G, /obj/item/weapon/melee/baton))
user.drop_item()
G.loc = src
src.charging2 = G
use_power = 2
attackby(obj/item/weapon/G as obj, mob/user as mob)
if (istype(G, /obj/item/weapon/gun/energy))
if (src.charging || src.charging2)
return
if (istype(G, /obj/item/weapon/gun/energy/gun/nuclear) || istype(G, /obj/item/weapon/gun/energy/crossbow))
user << "Your gun's recharge port was removed to make room for a miniaturized reactor."
return
if (istype(G, /obj/item/weapon/gun/energy/staff))
user << "It's a wooden staff, not a gun!"
return
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 << "\red The recharger rejects the weapon!"
return
user.drop_item()
G.loc = src
src.charging = G
use_power = 2
else if (istype(G, /obj/item/weapon/melee/baton))
if (src.charging || src.charging2)
return
user.drop_item()
G.loc = src
src.charging2 = G
use_power = 2
else if(istype(G, /obj/item/weapon/wrench))
if (src.charging || src.charging2)
user << "\red Remove the weapon first!"
return
anchored = !anchored
user << "You [anchored ? "attach" : "detach"] the recharger [anchored ? "to" : "from"] the ground"
playsound(src.loc, 'Ratchet.ogg', 75, 1)
/obj/machinery/recharger/attack_hand(mob/user as mob)
src.add_fingerprint(user)
if(ishuman(user))
if(istype(user:gloves, /obj/item/clothing/gloves/space_ninja)&&user:gloves:candrain&&!user:gloves:draining)
call(/obj/item/clothing/gloves/space_ninja/proc/drain)("MACHINERY",src,user:wear_suit)
attack_hand(mob/user as mob)
src.add_fingerprint(user)
if(ishuman(user))
if(istype(user:gloves, /obj/item/clothing/gloves/space_ninja)&&user:gloves:candrain&&!user:gloves:draining)
call(/obj/item/clothing/gloves/space_ninja/proc/drain)("MACHINERY",src,user:wear_suit)
return
if (src.charging)
src.charging.update_icon()
src.charging.loc = src.loc
src.charging = null
use_power = 1
if(src.charging2)
src.charging2.update_icon()
src.charging2.loc = src.loc
src.charging2 = null
use_power = 1
attack_paw(mob/user as mob)
if ((ticker && ticker.mode.name == "monkey"))
return src.attack_hand(user)
process()
if(stat & (NOPOWER|BROKEN) || !anchored)
return
if (src.charging)
src.charging.update_icon()
src.charging.loc = src.loc
src.charging = null
use_power = 1
if(src.charging2)
src.charging2.update_icon()
src.charging2.loc = src.loc
src.charging2 = null
use_power = 1
/obj/machinery/recharger/attack_paw(mob/user as mob)
if ((ticker && ticker.mode.name == "monkey"))
return src.attack_hand(user)
/obj/machinery/recharger/process()
if ((src.charging) && ! (stat & NOPOWER) )
if (src.charging.power_supply.charge < src.charging.power_supply.maxcharge)
src.charging.power_supply.give(100)
src.icon_state = "recharger1"
use_power(250)
if (src.charging)
if (src.charging.power_supply.charge < src.charging.power_supply.maxcharge)
src.charging.power_supply.give(100)
src.icon_state = "recharger1"
use_power(250)
else
src.icon_state = "recharger2"
else if (src.charging2)
if (src.charging2.charges < src.charging2.maximum_charges)
src.charging2.charges++
src.icon_state = "recharger1"
use_power(250)
else
src.icon_state = "recharger2"
else
src.icon_state = "recharger2"
if ((src.charging2) && ! (stat & NOPOWER) )
if (src.charging2.charges < src.charging2.maximum_charges)
src.charging2.charges++
src.icon_state = "recharger1"
use_power(250)
else
src.icon_state = "recharger2"
else if (!(src.charging || src.charging2))
src.icon_state = "recharger0"
src.icon_state = "recharger0"