diff --git a/code/_helpers/icons.dm b/code/_helpers/icons.dm index 02a0ce1989..651e6af83c 100644 --- a/code/_helpers/icons.dm +++ b/code/_helpers/icons.dm @@ -873,3 +873,22 @@ proc/sort_atoms_by_layer(var/list/atoms) result.Swap(i, gap + i) swapped = 1 return result + +// Mutable appearances are an inbuilt byond datastructure. Read the documentation on them by hitting F1 in DM. +// Basically use them instead of images for overlays/underlays and when changing an object's appearance if you're doing so with any regularity. +// Unless you need the overlay/underlay to have a different direction than the base object. Then you have to use an image due to a bug. + +// Mutable appearances are children of images, just so you know. + +/mutable_appearance/New() + ..() + plane = FLOAT_PLANE // No clue why this is 0 by default yet images are on FLOAT_PLANE + // And yes this does have to be in the constructor, BYOND ignores it if you set it as a normal var + +// Helper similar to image() +/proc/mutable_appearance(icon, icon_state = "", layer = FLOAT_LAYER) + var/mutable_appearance/MA = new() + MA.icon = icon + MA.icon_state = icon_state + MA.layer = layer + return MA diff --git a/code/modules/projectiles/gun.dm b/code/modules/projectiles/gun.dm index 9cb7292baf..8ff2828cc0 100644 --- a/code/modules/projectiles/gun.dm +++ b/code/modules/projectiles/gun.dm @@ -87,6 +87,36 @@ var/last_shot = 0 //records the last shot fired +//VOREStation Add - /tg/ icon system + var/charge_sections = 4 + var/shaded_charge = FALSE + var/ammo_x_offset = 2 + var/ammo_y_offset = 0 + var/can_flashlight = FALSE + var/gun_light = FALSE + var/light_state = "flight" + var/light_brightness = 4 + var/flight_x_offset = 0 + var/flight_y_offset = 0 + +/obj/item/weapon/gun/CtrlClick(mob/user) + if(can_flashlight && ishuman(user) && src.loc == usr && !user.incapacitated(INCAPACITATION_ALL)) + toggle_flashlight() + else + return ..() + +/obj/item/weapon/gun/proc/toggle_flashlight() + if(gun_light) + set_light(0) + gun_light = FALSE + else + set_light(light_brightness) + gun_light = TRUE + + playsound(src, 'sound/machines/button.ogg', 25) + update_icon() +//VOREStation Add End + /obj/item/weapon/gun/New() ..() for(var/i in 1 to firemodes.len) @@ -333,7 +363,12 @@ accuracy = initial(accuracy) //Reset the gun's accuracy if(muzzle_flash) - set_light(0) + //VOREStation Edit - Flashlights + if(gun_light) + set_light(light_brightness) + else + set_light(0) + //VOREStation Edit End // Similar to the above proc, but does not require a user, which is ideal for things like turrets. /obj/item/weapon/gun/proc/Fire_userless(atom/target) diff --git a/code/modules/vore/fluffstuff/guns/protector.dm b/code/modules/vore/fluffstuff/guns/protector.dm index 1abec7b27a..16bc56ee59 100644 --- a/code/modules/vore/fluffstuff/guns/protector.dm +++ b/code/modules/vore/fluffstuff/guns/protector.dm @@ -1,11 +1,12 @@ // -------------- Protector ------------- -/obj/item/weapon/gun/energy/gun/protector +/obj/item/weapon/gun/energy/protector name = "\improper KHI-98a \'Protector\'" desc = "The KHI-98a is the first firearm custom-designed for Nanotrasen by KHI. It features a powerful stun mode, and \ - an alert-level-locked lethal mode, only usable on code blue and higher. It also features a DNA lock mechanism." + an alert-level-locked lethal mode, only usable on code blue and higher. It also features an integrated flashlight! \ + (CtrlClick to toggle flashlight)" icon = 'icons/vore/custom_guns_vr.dmi' - icon_state = "protstun100" + icon_state = "prot" icon_override = 'icons/vore/custom_guns_vr.dmi' item_state = "gun" @@ -13,20 +14,26 @@ fire_sound = 'sound/weapons/Taser.ogg' projectile_type = /obj/item/projectile/beam/stun - modifystate = "protstun" - - dna_lock = 1 + modifystate = "stun" origin_tech = list(TECH_COMBAT = 5, TECH_MATERIAL = 3, TECH_MAGNET = 2) + charge_sections = 3 //For the icon + ammo_x_offset = 2 + ammo_y_offset = 0 + can_flashlight = TRUE + light_state = "prot_light" + flight_x_offset = 0 + flight_y_offset = 0 + firemodes = list( - list(mode_name="stun", projectile_type=/obj/item/projectile/beam/stun/protector, modifystate="protstun", fire_sound='sound/weapons/Taser.ogg'), - list(mode_name="lethal", projectile_type=/obj/item/projectile/beam, modifystate="protkill", fire_sound='sound/weapons/gauss_shoot.ogg'), + list(mode_name="stun", projectile_type=/obj/item/projectile/beam/stun/protector, modifystate="stun", fire_sound='sound/weapons/Taser.ogg'), + list(mode_name="lethal", projectile_type=/obj/item/projectile/beam, modifystate="kill", fire_sound='sound/weapons/gauss_shoot.ogg'), ) var/emagged = FALSE -/obj/item/weapon/gun/energy/gun/protector/special_check(mob/user) +/obj/item/weapon/gun/energy/protector/special_check(mob/user) if(!emagged && mode_name == "lethal" && get_security_level() == "green") to_chat(user,"The trigger refuses to depress while on the lethal setting under security level green!") return FALSE @@ -34,7 +41,7 @@ return ..() -/obj/item/weapon/gun/energy/gun/protector/emag_act(var/remaining_charges,var/mob/user) +/obj/item/weapon/gun/energy/protector/emag_act(var/remaining_charges,var/mob/user) ..() if(!emagged) emagged = TRUE @@ -42,6 +49,52 @@ return TRUE +//Update icons from /tg/, so fancy! Use this more! +/obj/item/weapon/gun/energy/protector/update_icon() + overlays.Cut() + var/ratio = 0 + + /* Don't have one for this gun + var/itemState = null + if(!initial(item_state)) + itemState = icon_state + */ + + var/iconState = "[icon_state]_charge" + if (modifystate) + overlays += "[icon_state]_[modifystate]" + iconState += "_[modifystate]" + /* Don't have one for this gun + if(itemState) + itemState += "[modifystate]" + */ + if(power_supply) + ratio = Ceiling((power_supply.charge / power_supply.maxcharge) * charge_sections) + + if(power_supply.charge < charge_cost) + overlays += "[icon_state]_empty" + else + if(!shaded_charge) + 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) + overlays += charge_overlay + else + overlays += "[icon_state]_[modifystate][ratio]" + + if(can_flashlight & gun_light) + var/mutable_appearance/flashlight_overlay = mutable_appearance(icon, light_state) + flashlight_overlay.pixel_x = flight_x_offset + flashlight_overlay.pixel_y = flight_y_offset + overlays += flashlight_overlay + + /* Don't have one for this gun + if(itemState) + itemState += "[ratio]" + item_state = itemState + */ + + // Protector beams /obj/item/projectile/beam/stun/protector name = "protector stun beam" @@ -58,5 +111,5 @@ id = "protector" req_tech = list(TECH_COMBAT = 5, TECH_MATERIAL = 3, TECH_MAGNET = 2) materials = list(DEFAULT_WALL_MATERIAL = 4000, "glass" = 2000, "silver" = 1000) - build_path = /obj/item/weapon/gun/energy/gun/protector + build_path = /obj/item/weapon/gun/energy/protector sort_string = "TAADA" diff --git a/icons/vore/custom_guns_vr.dmi b/icons/vore/custom_guns_vr.dmi index a89dca4076..6b59709463 100644 Binary files a/icons/vore/custom_guns_vr.dmi and b/icons/vore/custom_guns_vr.dmi differ