mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-10 02:09:41 +00:00
Recharger refactor
This commit is contained in:
@@ -28,6 +28,9 @@
|
|||||||
|
|
||||||
var/obj/machinery/computer3/laptop/stored_computer = null
|
var/obj/machinery/computer3/laptop/stored_computer = null
|
||||||
|
|
||||||
|
/obj/item/device/laptop/get_cell()
|
||||||
|
return stored_computer.battery
|
||||||
|
|
||||||
/obj/item/device/laptop/verb/open_computer()
|
/obj/item/device/laptop/verb/open_computer()
|
||||||
set name = "Open Laptop"
|
set name = "Open Laptop"
|
||||||
set category = "Object"
|
set category = "Object"
|
||||||
|
|||||||
@@ -41,34 +41,11 @@ obj/machinery/recharger
|
|||||||
return
|
return
|
||||||
if(istype(G, /obj/item/weapon/gun/energy))
|
if(istype(G, /obj/item/weapon/gun/energy))
|
||||||
var/obj/item/weapon/gun/energy/E = G
|
var/obj/item/weapon/gun/energy/E = G
|
||||||
if(!E.power_supply)
|
|
||||||
to_chat(user, "<span class='notice'>Your gun has no power cell.</span>")
|
|
||||||
return
|
|
||||||
if(E.self_recharge)
|
if(E.self_recharge)
|
||||||
to_chat(user, "<span class='notice'>Your gun has no recharge port.</span>")
|
to_chat(user, "<span class='notice'>Your gun has no recharge port.</span>")
|
||||||
return
|
return
|
||||||
if(istype(G, /obj/item/weapon/gun/energy/staff))
|
if(!G.get_cell())
|
||||||
return
|
to_chat(user, "This device does not have a battery installed.")
|
||||||
if(istype(G, /obj/item/device/flashlight))
|
|
||||||
var/obj/item/device/flashlight/F = G
|
|
||||||
if(!F.power_use)
|
|
||||||
return
|
|
||||||
if(!F.cell)
|
|
||||||
return
|
|
||||||
if(istype(G, /obj/item/device/laptop))
|
|
||||||
var/obj/item/device/laptop/L = G
|
|
||||||
if(!L.stored_computer.battery)
|
|
||||||
user << "There's no battery in it!"
|
|
||||||
return
|
|
||||||
if(istype(G, /obj/item/device/electronic_assembly))
|
|
||||||
var/obj/item/device/electronic_assembly/assembly = G
|
|
||||||
if(!assembly.battery)
|
|
||||||
to_chat(user, "<span class='warning'>The assembly doesn't have a power cell.</span>")
|
|
||||||
return
|
|
||||||
if(istype(G, /obj/item/weapon/weldingtool/electric))
|
|
||||||
var/obj/item/weapon/weldingtool/electric/welder = G
|
|
||||||
if(!welder.power_supply)
|
|
||||||
to_chat(user, "<span class='notice'>Your welder has no power cell.</span>")
|
|
||||||
return
|
return
|
||||||
|
|
||||||
user.drop_item()
|
user.drop_item()
|
||||||
@@ -109,71 +86,8 @@ obj/machinery/recharger
|
|||||||
update_use_power(1)
|
update_use_power(1)
|
||||||
icon_state = icon_state_idle
|
icon_state = icon_state_idle
|
||||||
else
|
else
|
||||||
if(istype(charging, /obj/item/weapon/gun/energy))
|
var/obj/item/weapon/cell/C = charging.get_cell()
|
||||||
var/obj/item/weapon/gun/energy/E = charging
|
if(istype(C))
|
||||||
if(!E.power_supply.fully_charged())
|
|
||||||
icon_state = icon_state_charging
|
|
||||||
E.power_supply.give(active_power_usage*CELLRATE)
|
|
||||||
update_use_power(2)
|
|
||||||
else
|
|
||||||
icon_state = icon_state_charged
|
|
||||||
update_use_power(1)
|
|
||||||
return
|
|
||||||
|
|
||||||
if(istype(charging, /obj/item/weapon/gun/magnetic))
|
|
||||||
var/obj/item/weapon/gun/magnetic/M = charging
|
|
||||||
if(!M.cell.fully_charged())
|
|
||||||
icon_state = icon_state_charging
|
|
||||||
M.cell.give(active_power_usage*CELLRATE)
|
|
||||||
update_use_power(2)
|
|
||||||
else
|
|
||||||
icon_state = icon_state_charged
|
|
||||||
update_use_power(1)
|
|
||||||
return
|
|
||||||
|
|
||||||
if(istype(charging, /obj/item/weapon/melee/baton))
|
|
||||||
var/obj/item/weapon/melee/baton/B = charging
|
|
||||||
if(B.bcell)
|
|
||||||
if(!B.bcell.fully_charged())
|
|
||||||
icon_state = icon_state_charging
|
|
||||||
B.bcell.give(active_power_usage*CELLRATE)
|
|
||||||
update_use_power(2)
|
|
||||||
else
|
|
||||||
icon_state = icon_state_charged
|
|
||||||
update_use_power(1)
|
|
||||||
else
|
|
||||||
icon_state = icon_state_idle
|
|
||||||
update_use_power(1)
|
|
||||||
return
|
|
||||||
|
|
||||||
if(istype(charging, /obj/item/device/laptop))
|
|
||||||
var/obj/item/device/laptop/L = charging
|
|
||||||
if(!L.stored_computer.battery.fully_charged())
|
|
||||||
icon_state = icon_state_charging
|
|
||||||
L.stored_computer.battery.give(active_power_usage*CELLRATE)
|
|
||||||
update_use_power(2)
|
|
||||||
else
|
|
||||||
icon_state = icon_state_charged
|
|
||||||
update_use_power(1)
|
|
||||||
return
|
|
||||||
|
|
||||||
if(istype(charging, /obj/item/device/flashlight))
|
|
||||||
var/obj/item/device/flashlight/F = charging
|
|
||||||
if(F.cell)
|
|
||||||
if(!F.cell.fully_charged())
|
|
||||||
icon_state = icon_state_charging
|
|
||||||
F.cell.give(active_power_usage*CELLRATE)
|
|
||||||
update_use_power(2)
|
|
||||||
else
|
|
||||||
icon_state = icon_state_charged
|
|
||||||
update_use_power(1)
|
|
||||||
else
|
|
||||||
icon_state = icon_state_idle
|
|
||||||
update_use_power(1)
|
|
||||||
return
|
|
||||||
|
|
||||||
if(istype(charging, /obj/item/weapon/cell))
|
|
||||||
var/obj/item/weapon/cell/C = charging
|
|
||||||
if(!C.fully_charged())
|
if(!C.fully_charged())
|
||||||
icon_state = icon_state_charging
|
icon_state = icon_state_charging
|
||||||
C.give(active_power_usage*CELLRATE)
|
C.give(active_power_usage*CELLRATE)
|
||||||
@@ -181,6 +95,7 @@ obj/machinery/recharger
|
|||||||
else
|
else
|
||||||
icon_state = icon_state_charged
|
icon_state = icon_state_charged
|
||||||
update_use_power(1)
|
update_use_power(1)
|
||||||
|
<<<<<<< HEAD
|
||||||
return
|
return
|
||||||
|
|
||||||
if(istype(charging, /obj/item/device/electronic_assembly))
|
if(istype(charging, /obj/item/device/electronic_assembly))
|
||||||
@@ -221,21 +136,19 @@ obj/machinery/recharger
|
|||||||
icon_state = icon_state_charged
|
icon_state = icon_state_charged
|
||||||
update_use_power(1)
|
update_use_power(1)
|
||||||
return
|
return
|
||||||
|
=======
|
||||||
|
>>>>>>> 32557da... Merge pull request #5356 from Anewbe/recharger_refactor
|
||||||
|
|
||||||
/obj/machinery/recharger/emp_act(severity)
|
/obj/machinery/recharger/emp_act(severity)
|
||||||
if(stat & (NOPOWER|BROKEN) || !anchored)
|
if(stat & (NOPOWER|BROKEN) || !anchored)
|
||||||
..(severity)
|
..(severity)
|
||||||
return
|
return
|
||||||
|
|
||||||
if(istype(charging, /obj/item/weapon/gun/energy))
|
if(charging)
|
||||||
var/obj/item/weapon/gun/energy/E = charging
|
var/obj/item/weapon/cell/C = charging.get_cell()
|
||||||
if(E.power_supply)
|
if(istype(C))
|
||||||
E.power_supply.emp_act(severity)
|
C.emp_act(severity)
|
||||||
|
|
||||||
else if(istype(charging, /obj/item/weapon/melee/baton))
|
|
||||||
var/obj/item/weapon/melee/baton/B = charging
|
|
||||||
if(B.bcell)
|
|
||||||
B.bcell.charge = 0
|
|
||||||
..(severity)
|
..(severity)
|
||||||
|
|
||||||
/obj/machinery/recharger/update_icon() //we have an update_icon() in addition to the stuff in process to make it feel a tiny bit snappier.
|
/obj/machinery/recharger/update_icon() //we have an update_icon() in addition to the stuff in process to make it feel a tiny bit snappier.
|
||||||
@@ -244,7 +157,6 @@ obj/machinery/recharger
|
|||||||
else
|
else
|
||||||
icon_state = icon_state_idle
|
icon_state = icon_state_idle
|
||||||
|
|
||||||
|
|
||||||
/obj/machinery/recharger/wallcharger
|
/obj/machinery/recharger/wallcharger
|
||||||
name = "wall recharger"
|
name = "wall recharger"
|
||||||
icon = 'icons/obj/stationobjs.dmi'
|
icon = 'icons/obj/stationobjs.dmi'
|
||||||
|
|||||||
@@ -41,6 +41,9 @@
|
|||||||
processing_objects -= src
|
processing_objects -= src
|
||||||
return ..()
|
return ..()
|
||||||
|
|
||||||
|
/obj/item/device/flashlight/get_cell()
|
||||||
|
return cell
|
||||||
|
|
||||||
/obj/item/device/flashlight/verb/toggle()
|
/obj/item/device/flashlight/verb/toggle()
|
||||||
set name = "Toggle Flashlight Brightness"
|
set name = "Toggle Flashlight Brightness"
|
||||||
set category = "Object"
|
set category = "Object"
|
||||||
|
|||||||
@@ -38,6 +38,9 @@ var/global/list/active_radio_jammers = list()
|
|||||||
qdel_null(power_source)
|
qdel_null(power_source)
|
||||||
return ..()
|
return ..()
|
||||||
|
|
||||||
|
/obj/item/device/radio_jammer/get_cell()
|
||||||
|
return power_source
|
||||||
|
|
||||||
/obj/item/device/radio_jammer/proc/turn_off(mob/user)
|
/obj/item/device/radio_jammer/proc/turn_off(mob/user)
|
||||||
if(user)
|
if(user)
|
||||||
to_chat(user,"<span class='warning'>\The [src] deactivates.</span>")
|
to_chat(user,"<span class='warning'>\The [src] deactivates.</span>")
|
||||||
|
|||||||
@@ -19,16 +19,19 @@
|
|||||||
var/obj/item/weapon/cell/bcell = null
|
var/obj/item/weapon/cell/bcell = null
|
||||||
var/hitcost = 240
|
var/hitcost = 240
|
||||||
|
|
||||||
/obj/item/weapon/melee/baton/suicide_act(mob/user)
|
|
||||||
var/datum/gender/TU = gender_datums[user.get_visible_gender()]
|
|
||||||
user.visible_message("<span class='suicide'>\The [user] is putting the live [name] in [TU.his] mouth! It looks like [TU.he] [TU.is] trying to commit suicide.</span>")
|
|
||||||
return (FIRELOSS)
|
|
||||||
|
|
||||||
/obj/item/weapon/melee/baton/New()
|
/obj/item/weapon/melee/baton/New()
|
||||||
..()
|
..()
|
||||||
update_icon()
|
update_icon()
|
||||||
return
|
return
|
||||||
|
|
||||||
|
/obj/item/weapon/melee/baton/get_cell()
|
||||||
|
return bcell
|
||||||
|
|
||||||
|
/obj/item/weapon/melee/baton/suicide_act(mob/user)
|
||||||
|
var/datum/gender/TU = gender_datums[user.get_visible_gender()]
|
||||||
|
user.visible_message("<span class='suicide'>\The [user] is putting the live [name] in [TU.his] mouth! It looks like [TU.he] [TU.is] trying to commit suicide.</span>")
|
||||||
|
return (FIRELOSS)
|
||||||
|
|
||||||
/obj/item/weapon/melee/baton/MouseDrop(obj/over_object as obj)
|
/obj/item/weapon/melee/baton/MouseDrop(obj/over_object as obj)
|
||||||
if(!canremove)
|
if(!canremove)
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -776,6 +776,9 @@
|
|||||||
acti_sound = 'sound/effects/sparks4.ogg'
|
acti_sound = 'sound/effects/sparks4.ogg'
|
||||||
deac_sound = 'sound/effects/sparks4.ogg'
|
deac_sound = 'sound/effects/sparks4.ogg'
|
||||||
|
|
||||||
|
/obj/item/weapon/weldingtool/electric/unloaded/New()
|
||||||
|
cell_type = null
|
||||||
|
|
||||||
/obj/item/weapon/weldingtool/electric/New()
|
/obj/item/weapon/weldingtool/electric/New()
|
||||||
..()
|
..()
|
||||||
if(cell_type == null)
|
if(cell_type == null)
|
||||||
@@ -786,8 +789,8 @@
|
|||||||
power_supply = new /obj/item/weapon/cell/device(src)
|
power_supply = new /obj/item/weapon/cell/device(src)
|
||||||
update_icon()
|
update_icon()
|
||||||
|
|
||||||
/obj/item/weapon/weldingtool/electric/unloaded/New()
|
/obj/item/weapon/weldingtool/electric/get_cell()
|
||||||
cell_type = null
|
return power_supply
|
||||||
|
|
||||||
/obj/item/weapon/weldingtool/electric/examine(mob/user)
|
/obj/item/weapon/weldingtool/electric/examine(mob/user)
|
||||||
if(get_dist(src, user) > 1)
|
if(get_dist(src, user) > 1)
|
||||||
|
|||||||
@@ -163,3 +163,6 @@
|
|||||||
|
|
||||||
/obj/proc/show_message(msg, type, alt, alt_type)//Message, type of message (1 or 2), alternative message, alt message type (1 or 2)
|
/obj/proc/show_message(msg, type, alt, alt_type)//Message, type of message (1 or 2), alternative message, alt message type (1 or 2)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
/obj/proc/get_cell()
|
||||||
|
return
|
||||||
@@ -19,6 +19,9 @@
|
|||||||
else
|
else
|
||||||
..()
|
..()
|
||||||
|
|
||||||
|
/obj/item/device/electronic_assembly/get_cell()
|
||||||
|
return battery
|
||||||
|
|
||||||
/obj/item/device/assembly/electronic_assembly/proc/toggle_open(mob/user)
|
/obj/item/device/assembly/electronic_assembly/proc/toggle_open(mob/user)
|
||||||
playsound(get_turf(src), 'sound/items/Crowbar.ogg', 50, 1)
|
playsound(get_turf(src), 'sound/items/Crowbar.ogg', 50, 1)
|
||||||
opened = !opened
|
opened = !opened
|
||||||
|
|||||||
@@ -41,6 +41,9 @@
|
|||||||
processing_objects -= src
|
processing_objects -= src
|
||||||
return ..()
|
return ..()
|
||||||
|
|
||||||
|
/obj/item/weapon/cell/get_cell()
|
||||||
|
return src
|
||||||
|
|
||||||
/obj/item/weapon/cell/process()
|
/obj/item/weapon/cell/process()
|
||||||
if(self_recharge)
|
if(self_recharge)
|
||||||
if(world.time >= last_use + charge_delay)
|
if(world.time >= last_use + charge_delay)
|
||||||
|
|||||||
@@ -23,17 +23,6 @@
|
|||||||
|
|
||||||
var/battery_lock = 0 //If set, weapon cannot switch batteries
|
var/battery_lock = 0 //If set, weapon cannot switch batteries
|
||||||
|
|
||||||
/obj/item/weapon/gun/energy/attackby(var/obj/item/A as obj, mob/user as mob)
|
|
||||||
..()
|
|
||||||
|
|
||||||
/obj/item/weapon/gun/energy/switch_firemodes(mob/user)
|
|
||||||
if(..())
|
|
||||||
update_icon()
|
|
||||||
|
|
||||||
/obj/item/weapon/gun/energy/emp_act(severity)
|
|
||||||
..()
|
|
||||||
update_icon()
|
|
||||||
|
|
||||||
/obj/item/weapon/gun/energy/New()
|
/obj/item/weapon/gun/energy/New()
|
||||||
..()
|
..()
|
||||||
if(self_recharge)
|
if(self_recharge)
|
||||||
@@ -52,6 +41,9 @@
|
|||||||
processing_objects.Remove(src)
|
processing_objects.Remove(src)
|
||||||
return ..()
|
return ..()
|
||||||
|
|
||||||
|
/obj/item/weapon/gun/energy/get_cell()
|
||||||
|
return power_supply
|
||||||
|
|
||||||
/obj/item/weapon/gun/energy/process()
|
/obj/item/weapon/gun/energy/process()
|
||||||
if(self_recharge) //Every [recharge_time] ticks, recharge a shot for the battery
|
if(self_recharge) //Every [recharge_time] ticks, recharge a shot for the battery
|
||||||
if(world.time > last_shot + charge_delay) //Doesn't work if you've fired recently
|
if(world.time > last_shot + charge_delay) //Doesn't work if you've fired recently
|
||||||
@@ -75,6 +67,17 @@
|
|||||||
charge_tick = 0
|
charge_tick = 0
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
|
/obj/item/weapon/gun/energy/attackby(var/obj/item/A as obj, mob/user as mob)
|
||||||
|
..()
|
||||||
|
|
||||||
|
/obj/item/weapon/gun/energy/switch_firemodes(mob/user)
|
||||||
|
if(..())
|
||||||
|
update_icon()
|
||||||
|
|
||||||
|
/obj/item/weapon/gun/energy/emp_act(severity)
|
||||||
|
..()
|
||||||
|
update_icon()
|
||||||
|
|
||||||
/obj/item/weapon/gun/energy/consume_next_projectile()
|
/obj/item/weapon/gun/energy/consume_next_projectile()
|
||||||
if(!power_supply) return null
|
if(!power_supply) return null
|
||||||
if(!ispath(projectile_type)) return null
|
if(!ispath(projectile_type)) return null
|
||||||
|
|||||||
@@ -36,6 +36,9 @@
|
|||||||
qdel_null(capacitor)
|
qdel_null(capacitor)
|
||||||
. = ..()
|
. = ..()
|
||||||
|
|
||||||
|
/obj/item/weapon/gun/magnetic/get_cell()
|
||||||
|
return cell
|
||||||
|
|
||||||
/obj/item/weapon/gun/magnetic/process()
|
/obj/item/weapon/gun/magnetic/process()
|
||||||
if(capacitor)
|
if(capacitor)
|
||||||
if(cell)
|
if(cell)
|
||||||
|
|||||||
@@ -7,11 +7,6 @@
|
|||||||
var/obj/item/weapon/cell/device/cell
|
var/obj/item/weapon/cell/device/cell
|
||||||
var/enabled = 0
|
var/enabled = 0
|
||||||
|
|
||||||
/obj/item/weapon/shield_diffuser/update_icon()
|
|
||||||
if(enabled)
|
|
||||||
icon_state = "hdiffuser_on"
|
|
||||||
else
|
|
||||||
icon_state = "hdiffuser_off"
|
|
||||||
|
|
||||||
/obj/item/weapon/shield_diffuser/New()
|
/obj/item/weapon/shield_diffuser/New()
|
||||||
cell = new(src)
|
cell = new(src)
|
||||||
@@ -24,6 +19,9 @@
|
|||||||
processing_objects.Remove(src)
|
processing_objects.Remove(src)
|
||||||
. = ..()
|
. = ..()
|
||||||
|
|
||||||
|
/obj/item/weapon/shield_diffuser/get_cell()
|
||||||
|
return cell
|
||||||
|
|
||||||
/obj/item/weapon/shield_diffuser/process()
|
/obj/item/weapon/shield_diffuser/process()
|
||||||
if(!enabled)
|
if(!enabled)
|
||||||
return
|
return
|
||||||
@@ -34,6 +32,12 @@
|
|||||||
if(istype(S) && cell.checked_use(10 KILOWATTS * CELLRATE))
|
if(istype(S) && cell.checked_use(10 KILOWATTS * CELLRATE))
|
||||||
qdel(S)
|
qdel(S)
|
||||||
|
|
||||||
|
/obj/item/weapon/shield_diffuser/update_icon()
|
||||||
|
if(enabled)
|
||||||
|
icon_state = "hdiffuser_on"
|
||||||
|
else
|
||||||
|
icon_state = "hdiffuser_off"
|
||||||
|
|
||||||
/obj/item/weapon/shield_diffuser/attack_self()
|
/obj/item/weapon/shield_diffuser/attack_self()
|
||||||
enabled = !enabled
|
enabled = !enabled
|
||||||
update_icon()
|
update_icon()
|
||||||
|
|||||||
Reference in New Issue
Block a user