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
@@ -1,15 +0,0 @@
/obj/item/ammo_casing/energy/chameleon
projectile_type = /obj/item/projectile/energy/chameleon
e_cost = 0
var/hitscan_mode = FALSE
var/list/projectile_vars = list()
/obj/item/ammo_casing/energy/chameleon/ready_proj(atom/target, mob/living/user, quiet, zone_override = "")
. = ..()
if(!BB)
newshot()
for(var/V in projectile_vars)
if(BB.vars.Find(V))
BB.vv_edit_var(V, projectile_vars[V])
if(hitscan_mode)
BB.hitscan = TRUE
+28 -26
View File
@@ -44,8 +44,10 @@
var/obj/item/flashlight/gun_light
var/can_flashlight = 0
var/obj/item/kitchen/knife/bayonet
var/mutable_appearance/knife_overlay
var/can_bayonet = FALSE
var/datum/action/item_action/toggle_gunlight/alight
var/mutable_appearance/flashlight_overlay
var/list/upgrades = list()
@@ -292,28 +294,12 @@
SSblackbox.record_feedback("tally", "gun_fired", 1, type)
return TRUE
/obj/item/gun/proc/reset_semicd()
semicd = FALSE
/obj/item/gun/update_icon()
..()
cut_overlays()
if(gun_light && can_flashlight)
var/state = "flight[gun_light.on? "_on":""]" //Generic state.
if(gun_light.icon_state in icon_states('icons/obj/guns/flashlights.dmi')) //Snowflake state?
state = gun_light.icon_state
var/mutable_appearance/flashlight_overlay = mutable_appearance('icons/obj/guns/flashlights.dmi', state)
flashlight_overlay.pixel_x = flight_x_offset
flashlight_overlay.pixel_y = flight_y_offset
add_overlay(flashlight_overlay)
if(bayonet && can_bayonet)
var/state = "bayonet" //Generic state.
if(bayonet.icon_state in icon_states('icons/obj/guns/bayonets.dmi')) //Snowflake state?
state = bayonet.icon_state
var/mutable_appearance/knife_overlay = mutable_appearance('icons/obj/guns/bayonets.dmi', state)
knife_overlay.pixel_x = knife_x_offset
knife_overlay.pixel_y = knife_y_offset
add_overlay(knife_overlay)
/obj/item/gun/proc/reset_semicd()
semicd = FALSE
/obj/item/gun/attack(mob/M as mob, mob/user)
if(user.a_intent == INTENT_HARM) //Flogging
@@ -345,7 +331,6 @@
if(S.on)
set_light(0)
gun_light = S
update_icon()
update_gunlight(user)
alight = new /datum/action/item_action/toggle_gunlight(src)
if(loc == user)
@@ -359,7 +344,14 @@
return
to_chat(user, "<span class='notice'>You attach \the [K] to the front of \the [src].</span>")
bayonet = K
update_icon()
var/state = "bayonet" //Generic state.
if(bayonet.icon_state in icon_states('icons/obj/guns/bayonets.dmi')) //Snowflake state?
state = bayonet.icon_state
var/icon/bayonet_icons = 'icons/obj/guns/bayonets.dmi'
knife_overlay = mutable_appearance(bayonet_icons, state)
knife_overlay.pixel_x = knife_x_offset
knife_overlay.pixel_y = knife_y_offset
add_overlay(knife_overlay, TRUE)
else if(istype(I, /obj/item/screwdriver))
if(gun_light)
var/obj/item/flashlight/seclite/S = gun_light
@@ -368,13 +360,14 @@
S.forceMove(get_turf(user))
update_gunlight(user)
S.update_brightness(user)
update_icon()
QDEL_NULL(alight)
if(bayonet)
to_chat(user, "<span class='notice'>You unscrew the bayonet from \the [src].</span>")
var/obj/item/kitchen/knife/K = bayonet
K.forceMove(get_turf(user))
bayonet = null
update_icon()
cut_overlay(knife_overlay, TRUE)
knife_overlay = null
else
return ..()
@@ -396,14 +389,23 @@
set_light(gun_light.brightness_on)
else
set_light(0)
update_icon()
cut_overlays(flashlight_overlay, TRUE)
var/state = "flight[gun_light.on? "_on":""]" //Generic state.
if(gun_light.icon_state in icon_states('icons/obj/guns/flashlights.dmi')) //Snowflake state?
state = gun_light.icon_state
flashlight_overlay = mutable_appearance('icons/obj/guns/flashlights.dmi', state)
flashlight_overlay.pixel_x = flight_x_offset
flashlight_overlay.pixel_y = flight_y_offset
add_overlay(flashlight_overlay, TRUE)
else
set_light(0)
cut_overlays(flashlight_overlay, TRUE)
flashlight_overlay = null
update_icon(TRUE)
for(var/X in actions)
var/datum/action/A = X
A.UpdateButtonIcon()
/obj/item/gun/pickup(mob/user)
..()
if(azoom)
+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"
@@ -1,3 +0,0 @@
/obj/item/projectile/energy/chameleon
nodamage = TRUE