mirror of
https://github.com/yogstation13/Yogstation.git
synced 2025-02-26 09:04:50 +00:00
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:
committed by
yogstation13-bot
parent
147a27be82
commit
3dfcf76959
@@ -280,7 +280,6 @@
|
||||
new /obj/item/radio/headset/chameleon(src)
|
||||
new /obj/item/stamp/chameleon(src)
|
||||
new /obj/item/pda/chameleon(src)
|
||||
//new /obj/item/gun/energy/laser/chameleon(src) //crashes the server right now. please fix it!
|
||||
|
||||
//5*(2*4) = 5*8 = 45, 45 damage if you hit one person with all 5 stars.
|
||||
//Not counting the damage it will do while embedded (2*4 = 8, at 15% chance)
|
||||
|
||||
@@ -202,9 +202,6 @@
|
||||
update_item(chameleon_list[picked_name])
|
||||
|
||||
/datum/action/item_action/chameleon/change/proc/update_look(mob/user, obj/item/picked_item)
|
||||
if(istype(target, /obj/item/gun/energy/laser/chameleon))
|
||||
var/obj/item/gun/energy/laser/chameleon/CG = target
|
||||
CG.get_chameleon_projectile(picked_item)
|
||||
if(isliving(user))
|
||||
var/mob/living/C = user
|
||||
if(C.stat != CONSCIOUS)
|
||||
@@ -237,8 +234,6 @@
|
||||
return 1
|
||||
|
||||
/datum/action/item_action/chameleon/change/proc/emp_randomise(var/amount = EMP_RANDOMISE_TIME)
|
||||
if(istype(target, /obj/item/gun/energy/laser/chameleon))
|
||||
return //Please no crash!
|
||||
START_PROCESSING(SSprocessing, src)
|
||||
random_look(owner)
|
||||
|
||||
@@ -517,150 +512,6 @@
|
||||
. = ..()
|
||||
chameleon_action.emp_randomise(INFINITY)
|
||||
|
||||
/obj/item/gun/energy/laser/chameleon
|
||||
name = "practice laser gun"
|
||||
desc = "A modified version of the basic laser gun, this one fires less concentrated energy bolts designed for target practice."
|
||||
ammo_type = list(/obj/item/ammo_casing/energy/chameleon)
|
||||
clumsy_check = 0
|
||||
item_flags = NONE
|
||||
pin = /obj/item/firing_pin
|
||||
cell_type = /obj/item/stock_parts/cell/bluespace
|
||||
|
||||
var/datum/action/item_action/chameleon/change/chameleon_action
|
||||
var/list/chameleon_projectile_vars
|
||||
var/list/chameleon_ammo_vars
|
||||
var/list/chameleon_gun_vars
|
||||
var/list/projectile_copy_vars
|
||||
var/list/ammo_copy_vars
|
||||
var/list/gun_copy_vars
|
||||
var/badmin_mode = FALSE
|
||||
var/can_hitscan = FALSE
|
||||
var/hitscan_mode = FALSE
|
||||
var/static/list/blacklisted_vars = list("locs", "loc", "contents", "x", "y", "z")
|
||||
|
||||
/obj/item/gun/energy/laser/chameleon/Initialize()
|
||||
. = ..()
|
||||
chameleon_action = new(src)
|
||||
chameleon_action.chameleon_type = /obj/item/gun
|
||||
chameleon_action.chameleon_name = "Gun"
|
||||
chameleon_action.chameleon_blacklist = typecacheof(/obj/item/gun/magic, ignore_root_path = FALSE)
|
||||
chameleon_action.initialize_disguises()
|
||||
|
||||
projectile_copy_vars = list("name", "icon", "icon_state", "item_state", "speed", "color", "hitsound", "forcedodge", "impact_effect_type", "range", "suppressed", "hitsound_wall", "impact_effect_type", "pass_flags", "tracer_type", "muzzle_type", "impact_type")
|
||||
chameleon_projectile_vars = list("name" = "practice laser", "icon" = 'icons/obj/projectiles.dmi', "icon_state" = "laser")
|
||||
gun_copy_vars = list("fire_sound", "burst_size", "fire_delay")
|
||||
chameleon_gun_vars = list()
|
||||
ammo_copy_vars = list("firing_effect_type")
|
||||
chameleon_ammo_vars = list()
|
||||
recharge_newshot()
|
||||
get_chameleon_projectile(/obj/item/gun/energy/laser)
|
||||
|
||||
/obj/item/gun/energy/laser/chameleon/emp_act(severity)
|
||||
return
|
||||
|
||||
/obj/item/gun/energy/laser/chameleon/proc/reset_chameleon_vars()
|
||||
chameleon_ammo_vars = list()
|
||||
chameleon_gun_vars = list()
|
||||
chameleon_projectile_vars = list()
|
||||
if(chambered)
|
||||
for(var/v in ammo_copy_vars)
|
||||
if(v in blacklisted_vars) //Just in case admins go crazy.
|
||||
continue
|
||||
chambered.vars[v] = initial(chambered.vars[v])
|
||||
for(var/v in gun_copy_vars)
|
||||
if(v in blacklisted_vars)
|
||||
continue
|
||||
vars[v] = initial(vars[v])
|
||||
QDEL_NULL(chambered.BB)
|
||||
chambered.newshot()
|
||||
|
||||
/obj/item/gun/energy/laser/chameleon/proc/set_chameleon_ammo(obj/item/ammo_casing/AC, passthrough = TRUE, reset = FALSE)
|
||||
if(!istype(AC))
|
||||
CRASH("[AC] is not /obj/item/ammo_casing!")
|
||||
return FALSE
|
||||
for(var/V in ammo_copy_vars)
|
||||
if(AC.vars[V])
|
||||
chameleon_ammo_vars[V] = AC.vars[V]
|
||||
if(chambered && chambered.vars[V])
|
||||
chambered.vars[V] = AC.vars[V]
|
||||
if(passthrough)
|
||||
var/obj/item/projectile/P = AC.BB
|
||||
set_chameleon_projectile(P)
|
||||
|
||||
/obj/item/gun/energy/laser/chameleon/proc/set_chameleon_projectile(obj/item/projectile/P)
|
||||
if(!istype(P))
|
||||
CRASH("[P] is not /obj/item/projectile!")
|
||||
return FALSE
|
||||
chameleon_projectile_vars = list("name" = "practice laser", "icon" = 'icons/obj/projectiles.dmi', "icon_state" = "laser", "nodamage" = TRUE)
|
||||
for(var/V in projectile_copy_vars)
|
||||
if(P.vars[V])
|
||||
chameleon_projectile_vars[V] = P.vars[V]
|
||||
if(istype(chambered, /obj/item/ammo_casing/energy/chameleon))
|
||||
var/obj/item/ammo_casing/energy/chameleon/AC = chambered
|
||||
AC.projectile_vars = chameleon_projectile_vars.Copy()
|
||||
if(!P.tracer_type)
|
||||
can_hitscan = FALSE
|
||||
set_hitscan(FALSE)
|
||||
else
|
||||
can_hitscan = TRUE
|
||||
if(badmin_mode)
|
||||
qdel(chambered.BB)
|
||||
chambered.projectile_type = P.type
|
||||
chambered.newshot()
|
||||
|
||||
/obj/item/gun/energy/laser/chameleon/proc/set_chameleon_gun(obj/item/gun/G , passthrough = TRUE)
|
||||
if(!istype(G))
|
||||
CRASH("[G] is not /obj/item/gun!")
|
||||
return FALSE
|
||||
for(var/V in gun_copy_vars)
|
||||
if(vars[V] && G.vars[V])
|
||||
chameleon_gun_vars[V] = G.vars[V]
|
||||
vars[V] = G.vars[V]
|
||||
if(passthrough)
|
||||
if(istype(G, /obj/item/gun/ballistic))
|
||||
var/obj/item/gun/ballistic/BG = G
|
||||
var/obj/item/ammo_box/AB = new BG.mag_type(G)
|
||||
qdel(BG)
|
||||
if(!istype(AB)||!AB.ammo_type)
|
||||
qdel(AB)
|
||||
return FALSE
|
||||
var/obj/item/ammo_casing/AC = new AB.ammo_type(G)
|
||||
set_chameleon_ammo(AC)
|
||||
else if(istype(G, /obj/item/gun/magic))
|
||||
var/obj/item/gun/magic/MG = G
|
||||
var/obj/item/ammo_casing/AC = new MG.ammo_type(G)
|
||||
set_chameleon_ammo(AC)
|
||||
else if(istype(G, /obj/item/gun/energy))
|
||||
var/obj/item/gun/energy/EG = G
|
||||
if(islist(EG.ammo_type) && EG.ammo_type.len)
|
||||
var/obj/item/ammo_casing/AC = EG.ammo_type[1]
|
||||
set_chameleon_ammo(AC)
|
||||
else if(istype(G, /obj/item/gun/syringe))
|
||||
var/obj/item/ammo_casing/AC = new /obj/item/ammo_casing/syringegun(src)
|
||||
set_chameleon_ammo(AC)
|
||||
|
||||
/obj/item/gun/energy/laser/chameleon/attack_self(mob/user)
|
||||
. = ..()
|
||||
if(!can_hitscan)
|
||||
to_chat(user, "<span class='warning'>[src]'s current disguised gun does not allow it to enable high velocity mode!</span>")
|
||||
return
|
||||
if(!chambered)
|
||||
to_chat(user, "<span class='warning'>Unknown error in energy lens: Please reset chameleon disguise and try again.</span>")
|
||||
return
|
||||
set_hitscan(!hitscan_mode)
|
||||
to_chat(user, "<span class='notice'>You toggle [src]'s high velocity beam mode to [hitscan_mode? "on" : "off"].</span>")
|
||||
|
||||
/obj/item/gun/energy/laser/chameleon/proc/set_hitscan(hitscan)
|
||||
var/obj/item/ammo_casing/energy/chameleon/AC = chambered
|
||||
AC.hitscan_mode = hitscan
|
||||
hitscan_mode = hitscan
|
||||
|
||||
/obj/item/gun/energy/laser/chameleon/proc/get_chameleon_projectile(guntype)
|
||||
reset_chameleon_vars()
|
||||
var/obj/item/gun/G = new guntype(src)
|
||||
set_chameleon_gun(G)
|
||||
qdel(G)
|
||||
|
||||
/obj/item/storage/backpack/chameleon
|
||||
name = "backpack"
|
||||
var/datum/action/item_action/chameleon/change/chameleon_action
|
||||
|
||||
@@ -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
|
||||
@@ -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()
|
||||
|
||||
@@ -287,28 +289,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
|
||||
@@ -340,7 +326,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)
|
||||
@@ -354,7 +339,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
|
||||
@@ -363,13 +355,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 ..()
|
||||
|
||||
@@ -391,14 +384,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)
|
||||
|
||||
@@ -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
|
||||
@@ -40,7 +41,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()
|
||||
@@ -61,16 +62,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)
|
||||
@@ -126,15 +125,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
|
||||
@@ -22,7 +23,6 @@
|
||||
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
|
||||
|
||||
@@ -2217,7 +2217,6 @@
|
||||
#include "code\modules\projectiles\ammunition\caseless\misc.dm"
|
||||
#include "code\modules\projectiles\ammunition\caseless\rocket.dm"
|
||||
#include "code\modules\projectiles\ammunition\energy\_energy.dm"
|
||||
#include "code\modules\projectiles\ammunition\energy\chameleon.dm"
|
||||
#include "code\modules\projectiles\ammunition\energy\ebow.dm"
|
||||
#include "code\modules\projectiles\ammunition\energy\gravity.dm"
|
||||
#include "code\modules\projectiles\ammunition\energy\laser.dm"
|
||||
@@ -2288,7 +2287,6 @@
|
||||
#include "code\modules\projectiles\projectile\bullets\sniper.dm"
|
||||
#include "code\modules\projectiles\projectile\bullets\special.dm"
|
||||
#include "code\modules\projectiles\projectile\energy\_energy.dm"
|
||||
#include "code\modules\projectiles\projectile\energy\chameleon.dm"
|
||||
#include "code\modules\projectiles\projectile\energy\ebow.dm"
|
||||
#include "code\modules\projectiles\projectile\energy\misc.dm"
|
||||
#include "code\modules\projectiles\projectile\energy\net_snare.dm"
|
||||
|
||||
Reference in New Issue
Block a user