Gun overlays 2: Electric boogaloo. (#38003)

* Reduces selfcharge gun processing/icon work

* More efficient gun overlays, adds old_ratio var

* oh my god it was calling the egun's update_icon?

* percent proc

* Attachment overlay overhaul

* Cut overlays in egun update

* ebow 1000% better overlay management

* Update gun.dm

* Pointless check

* Giving KA and children consistent icon behavior

* Update kinetic_accelerator.dm

* Fixed

* ..() readded

* ..() readded

* ..() readded

* Antur didnt catch this one heck

* Because confusing vars are apparently more maintainable

* Gun overlays 2: Electric boogaloo

* another one

* Chameleon guns are removed

* tentacles everywhere
This commit is contained in:
Dax Dupont
2018-05-26 20:45:02 +02:00
committed by letterjay
parent fb0c6a9158
commit 74932ddce0
9 changed files with 46 additions and 211 deletions
+12 -9
View File
@@ -13,7 +13,8 @@
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
var/shaded_charge = FALSE //if this gun uses a stateful charge bar for more detail
var/old_ratio = 0 // stores the gun's previous ammo "ratio" to see if it needs an updated icon
var/selfcharge = 0
var/charge_tick = 0
var/charge_delay = 4
@@ -38,7 +39,7 @@
if(!dead_cell)
cell.give(cell.maxcharge)
update_ammo_types()
recharge_newshot(1)
recharge_newshot(TRUE)
if(selfcharge)
START_PROCESSING(SSobj, src)
update_icon()
@@ -59,16 +60,14 @@
return ..()
/obj/item/gun/energy/process()
if(selfcharge)
if(selfcharge && cell && cell.percent() < 100)
charge_tick++
if(charge_tick < charge_delay)
return
charge_tick = 0
if(!cell)
return
cell.give(100)
if(!chambered) //if empty chamber we try to charge a new shot
recharge_newshot(1)
recharge_newshot(TRUE)
update_icon()
/obj/item/gun/energy/attack_self(mob/living/user as mob)
@@ -124,15 +123,19 @@
if (shot.select_name)
to_chat(user, "<span class='notice'>[src] is now set to [shot.select_name].</span>")
chambered = null
recharge_newshot(1)
update_icon()
recharge_newshot(TRUE)
update_icon(TRUE)
return
/obj/item/gun/energy/update_icon()
/obj/item/gun/energy/update_icon(force_update)
..()
if(!automatic_charge_overlays)
return
var/ratio = CEILING((cell.charge / cell.maxcharge) * charge_sections, 1)
if(ratio == old_ratio && !force_update)
return
old_ratio = ratio
cut_overlays()
var/obj/item/ammo_casing/energy/shot = ammo_type[select]
var/iconState = "[icon_state]_charge"
var/itemState = null
@@ -11,6 +11,7 @@
can_flashlight = 1
flight_x_offset = 15
flight_y_offset = 9
automatic_charge_overlays = FALSE
var/overheat_time = 16
var/holds_charge = FALSE
var/unique_frequency = FALSE // modified by KA modkits
@@ -21,8 +22,7 @@
var/max_mod_capacity = 100
var/list/modkits = list()
var/empty_state = "kineticgun_empty"
var/recharge_timerid
/obj/item/gun/energy/kinetic_accelerator/examine(mob/user)
@@ -145,9 +145,10 @@
/obj/item/gun/energy/kinetic_accelerator/update_icon()
..()
if(empty_state && !can_shoot())
add_overlay(empty_state)
if(!can_shoot())
add_overlay("[icon_state]_empty")
else
cut_overlays()
//Casing
/obj/item/ammo_casing/energy/kinetic
@@ -95,7 +95,6 @@
unique_frequency = TRUE
can_flashlight = 0
max_mod_capacity = 0
empty_state = null
/obj/item/gun/energy/kinetic_accelerator/crossbow/halloween
name = "candy corn crossbow"