up to upstream-merge-27868
This commit is contained in:
@@ -4,13 +4,13 @@
|
||||
desc = "A basic energy-based gun."
|
||||
icon = 'icons/obj/guns/energy.dmi'
|
||||
|
||||
var/obj/item/weapon/stock_parts/cell/power_supply //What type of power cell this uses
|
||||
var/obj/item/weapon/stock_parts/cell/cell //What type of power cell this uses
|
||||
var/cell_type = /obj/item/weapon/stock_parts/cell
|
||||
var/modifystate = 0
|
||||
var/list/ammo_type = list(/obj/item/ammo_casing/energy)
|
||||
var/select = 1 //The state of the select fire switch. Determines from the ammo_type list what kind of shot is fired next.
|
||||
var/can_charge = 1 //Can it be charged in a recharger?
|
||||
var/automatic_charge_overlays = TRUE //Do we handle overlays with base update_icon()?
|
||||
var/automatic_charge_overlays = TRUE //Do we handle overlays with base update_icon()?
|
||||
var/charge_sections = 4
|
||||
ammo_x_offset = 2
|
||||
var/shaded_charge = 0 //if this gun uses a stateful charge bar for more detail
|
||||
@@ -20,19 +20,22 @@
|
||||
var/use_cyborg_cell = 0 //whether the gun's cell drains the cyborg user's cell to recharge
|
||||
|
||||
/obj/item/weapon/gun/energy/emp_act(severity)
|
||||
power_supply.use(round(power_supply.charge / severity))
|
||||
cell.use(round(cell.charge / severity))
|
||||
chambered = null //we empty the chamber
|
||||
recharge_newshot() //and try to charge a new shot
|
||||
update_icon()
|
||||
|
||||
/obj/item/weapon/gun/energy/get_cell()
|
||||
return cell
|
||||
|
||||
/obj/item/weapon/gun/energy/Initialize()
|
||||
. = ..()
|
||||
|
||||
/obj/item/weapon/gun/energy/Initialize()
|
||||
. = ..()
|
||||
if(cell_type)
|
||||
power_supply = new cell_type(src)
|
||||
cell = new cell_type(src)
|
||||
else
|
||||
power_supply = new(src)
|
||||
power_supply.give(power_supply.maxcharge)
|
||||
cell = new(src)
|
||||
cell.give(cell.maxcharge)
|
||||
update_ammo_types()
|
||||
recharge_newshot(1)
|
||||
if(selfcharge)
|
||||
@@ -50,9 +53,7 @@
|
||||
fire_delay = shot.delay
|
||||
|
||||
/obj/item/weapon/gun/energy/Destroy()
|
||||
if(power_supply)
|
||||
qdel(power_supply)
|
||||
power_supply = null
|
||||
QDEL_NULL(cell)
|
||||
STOP_PROCESSING(SSobj, src)
|
||||
return ..()
|
||||
|
||||
@@ -62,9 +63,9 @@
|
||||
if(charge_tick < charge_delay)
|
||||
return
|
||||
charge_tick = 0
|
||||
if(!power_supply)
|
||||
if(!cell)
|
||||
return
|
||||
power_supply.give(100)
|
||||
cell.give(100)
|
||||
if(!chambered) //if empty chamber we try to charge a new shot
|
||||
recharge_newshot(1)
|
||||
update_icon()
|
||||
@@ -76,10 +77,10 @@
|
||||
|
||||
/obj/item/weapon/gun/energy/can_shoot()
|
||||
var/obj/item/ammo_casing/energy/shot = ammo_type[select]
|
||||
return power_supply.charge >= shot.e_cost
|
||||
return cell.charge >= shot.e_cost
|
||||
|
||||
/obj/item/weapon/gun/energy/recharge_newshot(no_cyborg_drain)
|
||||
if (!ammo_type || !power_supply)
|
||||
if (!ammo_type || !cell)
|
||||
return
|
||||
if(use_cyborg_cell && !no_cyborg_drain)
|
||||
if(iscyborg(loc))
|
||||
@@ -87,10 +88,10 @@
|
||||
if(R.cell)
|
||||
var/obj/item/ammo_casing/energy/shot = ammo_type[select] //Necessary to find cost of shot
|
||||
if(R.cell.use(shot.e_cost)) //Take power from the borg...
|
||||
power_supply.give(shot.e_cost) //... to recharge the shot
|
||||
cell.give(shot.e_cost) //... to recharge the shot
|
||||
if(!chambered)
|
||||
var/obj/item/ammo_casing/energy/AC = ammo_type[select]
|
||||
if(power_supply.charge >= AC.e_cost) //if there's enough power in the power_supply cell...
|
||||
if(cell.charge >= AC.e_cost) //if there's enough power in the cell cell...
|
||||
chambered = AC //...prepare a new shot based on the current ammo type selected
|
||||
if(!chambered.BB)
|
||||
chambered.newshot()
|
||||
@@ -98,7 +99,7 @@
|
||||
/obj/item/weapon/gun/energy/process_chamber()
|
||||
if(chambered && !chambered.BB) //if BB is null, i.e the shot has been fired...
|
||||
var/obj/item/ammo_casing/energy/shot = chambered
|
||||
power_supply.use(shot.e_cost)//... drain the power_supply cell
|
||||
cell.use(shot.e_cost)//... drain the cell cell
|
||||
chambered = null //either way, released the prepared shot
|
||||
recharge_newshot() //try to charge a new shot
|
||||
|
||||
@@ -117,10 +118,10 @@
|
||||
return
|
||||
|
||||
/obj/item/weapon/gun/energy/update_icon()
|
||||
..()
|
||||
if(!automatic_charge_overlays)
|
||||
return
|
||||
var/ratio = Ceiling((power_supply.charge / power_supply.maxcharge) * charge_sections)
|
||||
..()
|
||||
if(!automatic_charge_overlays)
|
||||
return
|
||||
var/ratio = Ceiling((cell.charge / cell.maxcharge) * charge_sections)
|
||||
var/obj/item/ammo_casing/energy/shot = ammo_type[select]
|
||||
var/iconState = "[icon_state]_charge"
|
||||
var/itemState = null
|
||||
@@ -131,16 +132,16 @@
|
||||
iconState += "_[shot.select_name]"
|
||||
if(itemState)
|
||||
itemState += "[shot.select_name]"
|
||||
if(power_supply.charge < shot.e_cost)
|
||||
if(cell.charge < shot.e_cost)
|
||||
add_overlay("[icon_state]_empty")
|
||||
else
|
||||
if(!shaded_charge)
|
||||
var/mutable_appearance/charge_overlay = mutable_appearance(icon, iconState)
|
||||
var/mutable_appearance/charge_overlay = mutable_appearance(icon, iconState)
|
||||
for(var/i = ratio, i >= 1, i--)
|
||||
charge_overlay.pixel_x = ammo_x_offset * (i - 1)
|
||||
add_overlay(charge_overlay)
|
||||
charge_overlay.pixel_x = ammo_x_offset * (i - 1)
|
||||
add_overlay(charge_overlay)
|
||||
else
|
||||
add_overlay("[icon_state]_charge[ratio]")
|
||||
add_overlay("[icon_state]_charge[ratio]")
|
||||
if(itemState)
|
||||
itemState += "[ratio]"
|
||||
item_state = itemState
|
||||
@@ -156,7 +157,7 @@
|
||||
user.visible_message("<span class='suicide'>[user] melts [user.p_their()] face off with [src]!</span>")
|
||||
playsound(loc, fire_sound, 50, 1, -1)
|
||||
var/obj/item/ammo_casing/energy/shot = ammo_type[select]
|
||||
power_supply.use(shot.e_cost)
|
||||
cell.use(shot.e_cost)
|
||||
update_icon()
|
||||
return(FIRELOSS)
|
||||
else
|
||||
@@ -191,17 +192,17 @@
|
||||
user.visible_message("<span class='danger'>[user] tries to light their [A.name] with [src], but it doesn't do anything. Dumbass.</span>")
|
||||
playsound(user, E.fire_sound, 50, 1)
|
||||
playsound(user, BB.hitsound, 50, 1)
|
||||
power_supply.use(E.e_cost)
|
||||
cell.use(E.e_cost)
|
||||
. = ""
|
||||
else if(BB.damage_type != BURN)
|
||||
user.visible_message("<span class='danger'>[user] tries to light their [A.name] with [src], but only succeeds in utterly destroying it. Dumbass.</span>")
|
||||
playsound(user, E.fire_sound, 50, 1)
|
||||
playsound(user, BB.hitsound, 50, 1)
|
||||
power_supply.use(E.e_cost)
|
||||
cell.use(E.e_cost)
|
||||
qdel(A)
|
||||
. = ""
|
||||
else
|
||||
playsound(user, E.fire_sound, 50, 1)
|
||||
playsound(user, BB.hitsound, 50, 1)
|
||||
power_supply.use(E.e_cost)
|
||||
cell.use(E.e_cost)
|
||||
. = "<span class='danger'>[user] casually lights their [A.name] with [src]. Damn.</span>"
|
||||
|
||||
@@ -98,7 +98,7 @@
|
||||
empty()
|
||||
|
||||
/obj/item/weapon/gun/energy/kinetic_accelerator/proc/empty()
|
||||
power_supply.use(500)
|
||||
cell.use(500)
|
||||
update_icon()
|
||||
|
||||
/obj/item/weapon/gun/energy/kinetic_accelerator/proc/attempt_reload(recharge_time)
|
||||
@@ -125,7 +125,7 @@
|
||||
return
|
||||
|
||||
/obj/item/weapon/gun/energy/kinetic_accelerator/proc/reload()
|
||||
power_supply.give(500)
|
||||
cell.give(500)
|
||||
recharge_newshot(1)
|
||||
if(!suppressed)
|
||||
playsound(src.loc, 'sound/weapons/kenetic_reload.ogg', 60, 1)
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
/obj/item/weapon/gun/energy/decloner/update_icon()
|
||||
..()
|
||||
var/obj/item/ammo_casing/energy/shot = ammo_type[select]
|
||||
if(power_supply.charge > shot.e_cost)
|
||||
if(cell.charge > shot.e_cost)
|
||||
add_overlay("decloner_spin")
|
||||
|
||||
/obj/item/weapon/gun/energy/floragun
|
||||
@@ -137,19 +137,19 @@
|
||||
|
||||
/obj/item/weapon/gun/energy/plasmacutter/examine(mob/user)
|
||||
..()
|
||||
if(power_supply)
|
||||
to_chat(user, "<span class='notice'>[src] is [round(power_supply.percent())]% charged.</span>")
|
||||
if(cell)
|
||||
to_chat(user, "<span class='notice'>[src] is [round(cell.percent())]% charged.</span>")
|
||||
|
||||
/obj/item/weapon/gun/energy/plasmacutter/attackby(obj/item/A, mob/user)
|
||||
if(istype(A, /obj/item/stack/sheet/mineral/plasma))
|
||||
var/obj/item/stack/sheet/S = A
|
||||
S.use(1)
|
||||
power_supply.give(1000)
|
||||
cell.give(1000)
|
||||
recharge_newshot(1)
|
||||
to_chat(user, "<span class='notice'>You insert [A] in [src], recharging it.</span>")
|
||||
else if(istype(A, /obj/item/weapon/ore/plasma))
|
||||
qdel(A)
|
||||
power_supply.give(500)
|
||||
cell.give(500)
|
||||
recharge_newshot(1)
|
||||
to_chat(user, "<span class='notice'>You insert [A] in [src], recharging it.</span>")
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user