diff --git a/code/game/objects/items.dm b/code/game/objects/items.dm index 8879eeb2b7..ccef76c0f1 100644 --- a/code/game/objects/items.dm +++ b/code/game/objects/items.dm @@ -40,6 +40,11 @@ var/zoomdevicename = null //name used for message when binoculars/scope is used var/zoom = 0 //1 if item is actively being used to zoom. For scoped guns and binoculars. + // Used to specify the icon file to be used when the item is worn. If not set the default icon for that slot will be used. + // If icon_override or sprite_sheets are set they will take precendence over this, assuming they apply to the slot in question. + // Only slot_l_hand/slot_r_hand are implemented at the moment. Others to be implemented as needed. + var/list/item_icons = null + /* Species-specific sprites, concept stolen from Paradise//vg/. ex: sprite_sheets = list( @@ -58,6 +63,15 @@ /obj/item/device icon = 'icons/obj/device.dmi' +//Checks if the item is being held by a mob, and if so, updates the held icons +/obj/item/proc/update_held_icon() + if(ismob(src.loc)) + var/mob/M = src.loc + if(M.l_hand == src) + M.update_inv_l_hand() + if(M.r_hand == src) + M.update_inv_r_hand() + /obj/item/ex_act(severity) switch(severity) if(1.0) diff --git a/code/modules/admin/verbs/BrokenInhands.dm b/code/modules/admin/verbs/BrokenInhands.dm index 43f6d0b793..914ba1b5df 100644 --- a/code/modules/admin/verbs/BrokenInhands.dm +++ b/code/modules/admin/verbs/BrokenInhands.dm @@ -1,7 +1,7 @@ /proc/getbrokeninhands() - var/icon/IL = new('icons/mob/items_lefthand.dmi') + var/icon/IL = new('icons/mob/items/lefthand.dmi') var/list/Lstates = IL.IconStates() - var/icon/IR = new('icons/mob/items_righthand.dmi') + var/icon/IR = new('icons/mob/items/righthand.dmi') var/list/Rstates = IR.IconStates() diff --git a/code/modules/mob/living/carbon/human/update_icons.dm b/code/modules/mob/living/carbon/human/update_icons.dm index 15ad0b6bfd..cc9814b7fd 100644 --- a/code/modules/mob/living/carbon/human/update_icons.dm +++ b/code/modules/mob/living/carbon/human/update_icons.dm @@ -856,37 +856,47 @@ proc/get_damage_icon_part(damage_state, body_part) /mob/living/carbon/human/update_inv_r_hand(var/update_icons=1) if(r_hand) r_hand.screen_loc = ui_rhand //TODO + + var/t_icon = INV_R_HAND_DEF_ICON + if(r_hand.item_icons && (icon_r_hand in r_hand.item_icons)) + t_icon = r_hand.item_icons[icon_r_hand] + var/t_state = r_hand.item_state //useful for clothing that changes icon_state but retains the same sprite on the mob when held in hand if(!t_state) t_state = r_hand.icon_state - if(r_hand.icon_override) t_state = "[t_state]_r" overlays_standing[R_HAND_LAYER] = image("icon" = r_hand.icon_override, "icon_state" = "[t_state]") else - overlays_standing[R_HAND_LAYER] = image("icon" = 'icons/mob/items_righthand.dmi', "icon_state" = "[t_state]") + overlays_standing[R_HAND_LAYER] = image("icon" = t_icon, "icon_state" = "[t_state]") if (handcuffed) drop_r_hand() else overlays_standing[R_HAND_LAYER] = null - if(update_icons) update_icons() + + if(update_icons) update_icons() /mob/living/carbon/human/update_inv_l_hand(var/update_icons=1) if(l_hand) l_hand.screen_loc = ui_lhand //TODO + + var/t_icon = INV_L_HAND_DEF_ICON + if(l_hand.item_icons && (icon_l_hand in l_hand.item_icons)) + t_icon = l_hand.item_icons[icon_l_hand] + var/t_state = l_hand.item_state //useful for clothing that changes icon_state but retains the same sprite on the mob when held in hand if(!t_state) t_state = l_hand.icon_state - if(l_hand.icon_override) t_state = "[t_state]_l" overlays_standing[L_HAND_LAYER] = image("icon" = l_hand.icon_override, "icon_state" = "[t_state]") else - overlays_standing[L_HAND_LAYER] = image("icon" = 'icons/mob/items_lefthand.dmi', "icon_state" = "[t_state]") + overlays_standing[L_HAND_LAYER] = image("icon" = t_icon, "icon_state" = "[t_state]") if (handcuffed) drop_l_hand() else overlays_standing[L_HAND_LAYER] = null - if(update_icons) update_icons() + + if(update_icons) update_icons() /mob/living/carbon/human/proc/update_tail_showing(var/update_icons=1) overlays_standing[TAIL_LAYER] = null diff --git a/code/modules/mob/living/carbon/monkey/update_icons.dm b/code/modules/mob/living/carbon/monkey/update_icons.dm index ec69d454f6..1b3da8f49a 100644 --- a/code/modules/mob/living/carbon/monkey/update_icons.dm +++ b/code/modules/mob/living/carbon/monkey/update_icons.dm @@ -55,26 +55,38 @@ /mob/living/carbon/monkey/update_inv_r_hand(var/update_icons=1) if(r_hand) + var/t_icon = INV_R_HAND_DEF_ICON + if(r_hand.item_icons && (icon_r_hand in r_hand.item_icons)) + t_icon = r_hand.item_icons[icon_r_hand] + var/t_state = r_hand.item_state if(!t_state) t_state = r_hand.icon_state - overlays_standing[M_R_HAND_LAYER] = image("icon" = 'icons/mob/items_righthand.dmi', "icon_state" = t_state) + + overlays_standing[M_R_HAND_LAYER] = image("icon" = t_icon, "icon_state" = t_state) r_hand.screen_loc = ui_rhand if (handcuffed) drop_r_hand() else overlays_standing[M_R_HAND_LAYER] = null - if(update_icons) update_icons() + + if(update_icons) update_icons() /mob/living/carbon/monkey/update_inv_l_hand(var/update_icons=1) if(l_hand) + var/t_icon = INV_L_HAND_DEF_ICON + if(l_hand.item_icons && (icon_l_hand in l_hand.item_icons)) + t_icon = l_hand.item_icons[icon_l_hand] + var/t_state = l_hand.item_state if(!t_state) t_state = l_hand.icon_state - overlays_standing[M_L_HAND_LAYER] = image("icon" = 'icons/mob/items_lefthand.dmi', "icon_state" = t_state) + + overlays_standing[M_L_HAND_LAYER] = image("icon" = t_icon, "icon_state" = t_state) l_hand.screen_loc = ui_lhand if (handcuffed) drop_l_hand() else overlays_standing[M_L_HAND_LAYER] = null - if(update_icons) update_icons() + + if(update_icons) update_icons() /mob/living/carbon/monkey/update_inv_back(var/update_icons=1) diff --git a/code/modules/mob/new_player/preferences_setup.dm b/code/modules/mob/new_player/preferences_setup.dm index d25b66210e..bc17680e0c 100644 --- a/code/modules/mob/new_player/preferences_setup.dm +++ b/code/modules/mob/new_player/preferences_setup.dm @@ -375,7 +375,7 @@ datum/preferences if(LAWYER) clothes_s = new /icon('icons/mob/uniform.dmi', "internalaffairs_s") clothes_s.Blend(new /icon('icons/mob/feet.dmi', "brown"), ICON_UNDERLAY) - clothes_s.Blend(new /icon('icons/mob/items_righthand.dmi', "briefcase"), ICON_UNDERLAY) + clothes_s.Blend(new /icon(INV_R_HAND_DEF_ICON, "briefcase"), ICON_UNDERLAY) if(prob(1)) clothes_s.Blend(new /icon('icons/mob/suit.dmi', "suitjacket_blue"), ICON_OVERLAY) switch(backbag) @@ -534,7 +534,7 @@ datum/preferences clothes_s.Blend(new /icon('icons/mob/hands.dmi', "bgloves"), ICON_UNDERLAY) clothes_s.Blend(new /icon('icons/mob/suit.dmi', "labcoat_open"), ICON_OVERLAY) if(prob(1)) - clothes_s.Blend(new /icon('icons/mob/items_righthand.dmi', "toolbox_blue"), ICON_OVERLAY) + clothes_s.Blend(new /icon(INV_R_HAND_DEF_ICON, "toolbox_blue"), ICON_OVERLAY) switch(backbag) if(2) clothes_s.Blend(new /icon('icons/mob/back.dmi', "backpack"), ICON_OVERLAY) @@ -620,7 +620,7 @@ datum/preferences clothes_s.Blend(new /icon('icons/mob/belt.dmi', "utility"), ICON_OVERLAY) clothes_s.Blend(new /icon('icons/mob/head.dmi', "hardhat0_white"), ICON_OVERLAY) if(prob(1)) - clothes_s.Blend(new /icon('icons/mob/items_righthand.dmi', "blueprints"), ICON_OVERLAY) + clothes_s.Blend(new /icon(INV_R_HAND_DEF_ICON, "blueprints"), ICON_OVERLAY) switch(backbag) if(2) clothes_s.Blend(new /icon('icons/mob/back.dmi', "engiepack"), ICON_OVERLAY) diff --git a/code/modules/mob/update_icons.dm b/code/modules/mob/update_icons.dm index a6ae6dc4a0..480c4be322 100644 --- a/code/modules/mob/update_icons.dm +++ b/code/modules/mob/update_icons.dm @@ -1,6 +1,11 @@ //Most of these are defined at this level to reduce on checks elsewhere in the code. //Having them here also makes for a nice reference list of the various overlay-updating procs available +//default item on-mob icons +#define INV_L_HAND_DEF_ICON 'icons/mob/items/lefthand.dmi' +#define INV_R_HAND_DEF_ICON 'icons/mob/items/righthand.dmi' + + /mob/proc/regenerate_icons() //TODO: phase this out completely if possible return diff --git a/code/modules/projectiles/gun.dm b/code/modules/projectiles/gun.dm index 05b877f87e..ce85604752 100644 --- a/code/modules/projectiles/gun.dm +++ b/code/modules/projectiles/gun.dm @@ -3,6 +3,10 @@ name = "gun" desc = "Its a gun. It's pretty terrible, though." icon = 'icons/obj/gun.dmi' + item_icons = list( + icon_l_hand = 'icons/mob/items/lefthand_guns.dmi', + icon_r_hand = 'icons/mob/items/righthand_guns.dmi', + ) icon_state = "detective" item_state = "gun" flags = CONDUCT @@ -134,10 +138,7 @@ handle_post_fire(user, target, pointblank, reflex) update_icon() - if(user.hand) - user.update_inv_l_hand() - else - user.update_inv_r_hand() + update_held_icon() //obtains the next projectile to fire diff --git a/code/modules/projectiles/guns/energy.dm b/code/modules/projectiles/guns/energy.dm index 19f1157371..994256b12a 100644 --- a/code/modules/projectiles/guns/energy.dm +++ b/code/modules/projectiles/guns/energy.dm @@ -29,6 +29,7 @@ power_supply.give(power_supply.maxcharge) if(self_recharge) processing_objects.Add(src) + update_icon() /obj/item/weapon/gun/energy/Del() if(self_recharge) @@ -87,3 +88,4 @@ icon_state = "[modifystate][ratio]" else icon_state = "[initial(icon_state)][ratio]" + diff --git a/code/modules/projectiles/guns/energy/laser.dm b/code/modules/projectiles/guns/energy/laser.dm index 156db44c44..dffc012998 100644 --- a/code/modules/projectiles/guns/energy/laser.dm +++ b/code/modules/projectiles/guns/energy/laser.dm @@ -24,16 +24,18 @@ obj/item/weapon/gun/energy/retro name = "retro laser" icon_state = "retro" + item_state = "retro" desc = "An older model of the basic lasergun, no longer used by Nanotrasen's security or military forces. Nevertheless, it is still quite deadly and easy to maintain, making it a favorite amongst pirates and other outlaws." fire_sound = 'sound/weapons/Laser.ogg' slot_flags = SLOT_BELT w_class = 3 projectile_type = /obj/item/projectile/beam - fire_delay = 10 + fire_delay = 10 //old technology /obj/item/weapon/gun/energy/captain name = "antique laser gun" icon_state = "caplaser" + item_state = "caplaser" desc = "This is an antique laser gun. All craftsmanship is of the highest quality. It is decorated with assistant leather and chrome. The object menaces with spikes of energy. On the item is an image of Space Station 13. The station is exploding." force = 5 fire_sound = 'sound/weapons/Laser.ogg' @@ -48,7 +50,7 @@ obj/item/weapon/gun/energy/retro name = "laser cannon" desc = "With the laser cannon, the lasing medium is enclosed in a tube lined with uranium-235 and subjected to high neutron flux in a nuclear reactor core. This incredible technology may help YOU achieve high excitation rates with small laser volumes!" icon_state = "lasercannon" - item_state = "laser" + item_state = null fire_sound = 'sound/weapons/lasercannonfire.ogg' origin_tech = "combat=4;materials=3;powerstorage=3" slot_flags = SLOT_BELT|SLOT_BACK @@ -66,6 +68,7 @@ obj/item/weapon/gun/energy/retro name = "xray laser gun" desc = "A high-power laser gun capable of expelling concentrated xray blasts." icon_state = "xray" + item_state = "xray" fire_sound = 'sound/weapons/laser3.ogg' origin_tech = "combat=5;materials=3;magnets=2;syndicate=2" projectile_type = /obj/item/projectile/beam/xray @@ -117,10 +120,12 @@ obj/item/weapon/gun/energy/retro /obj/item/weapon/gun/energy/lasertag/blue icon_state = "bluetag" + item_state = "bluetag" projectile_type = /obj/item/projectile/beam/lastertag/blue required_vest = /obj/item/clothing/suit/bluetag /obj/item/weapon/gun/energy/lasertag/red icon_state = "redtag" + item_state = "redtag" projectile_type = /obj/item/projectile/beam/lastertag/red required_vest = /obj/item/clothing/suit/redtag diff --git a/code/modules/projectiles/guns/energy/nuclear.dm b/code/modules/projectiles/guns/energy/nuclear.dm index dc503388ed..6b9f6f0d51 100644 --- a/code/modules/projectiles/guns/energy/nuclear.dm +++ b/code/modules/projectiles/guns/energy/nuclear.dm @@ -29,10 +29,7 @@ projectile_type = /obj/item/projectile/beam/stun modifystate = "energystun" update_icon() - if(user.l_hand == src) - user.update_inv_l_hand() - else - user.update_inv_r_hand() + update_held_icon() /obj/item/weapon/gun/energy/gun/mounted name = "mounted energy gun" diff --git a/code/modules/projectiles/guns/energy/special.dm b/code/modules/projectiles/guns/energy/special.dm index 31480de9c8..0b25c82af1 100644 --- a/code/modules/projectiles/guns/energy/special.dm +++ b/code/modules/projectiles/guns/energy/special.dm @@ -26,6 +26,7 @@ name = "biological demolecularisor" desc = "A gun that discharges high amounts of controlled radiation to slowly break a target into component elements." icon_state = "decloner" + item_state = "decloner" fire_sound = 'sound/weapons/pulse3.ogg' origin_tech = "combat=5;materials=4;powerstorage=3" charge_cost = 100 @@ -35,7 +36,7 @@ name = "floral somatoray" desc = "A tool that discharges controlled radiation which induces mutation in plant cells." icon_state = "floramut100" - item_state = "obj/item/gun.dmi" + item_state = "floramut" fire_sound = 'sound/effects/stealthoff.ogg' charge_cost = 100 projectile_type = /obj/item/projectile/energy/floramut @@ -59,7 +60,7 @@ projectile_type = /obj/item/projectile/energy/floramut modifystate = "floramut" update_icon() - return + update_held_icon() /obj/item/weapon/gun/energy/floragun/afterattack(obj/target, mob/user, adjacent_flag) //allow shooting into adjacent hydrotrays regardless of intent @@ -115,6 +116,7 @@ name = "staff of change" desc = "An artefact that spits bolts of coruscating energy which cause the target's very form to reshape itself" icon = 'icons/obj/gun.dmi' + item_icons = null icon_state = "staffofchange" item_state = "staffofchange" fire_sound = 'sound/weapons/emitter.ogg' @@ -168,6 +170,7 @@ obj/item/weapon/gun/energy/staff/focus desc = "It's a cute rubber duck. With an evil gleam in it's eye." projectile_type = /obj/item/projectile/icarus/pointdefense icon = 'icons/obj/watercloset.dmi' + item_icons = null icon_state = "rubberducky" item_state = "rubberducky" charge_cost = 0 diff --git a/code/modules/projectiles/guns/energy/stun.dm b/code/modules/projectiles/guns/energy/stun.dm index b0d2dc4c0f..1d51f7957e 100644 --- a/code/modules/projectiles/guns/energy/stun.dm +++ b/code/modules/projectiles/guns/energy/stun.dm @@ -23,6 +23,7 @@ name = "stun revolver" desc = "A high-tech revolver that fires stun cartridges. The stun cartridges can be recharged using a conventional energy weapon recharger." icon_state = "stunrevolver" + item_state = "stunrevolver" fire_sound = 'sound/weapons/Gunshot.ogg' origin_tech = "combat=3;materials=3;powerstorage=2" charge_cost = 125 diff --git a/code/modules/projectiles/guns/launcher/syringe_gun.dm b/code/modules/projectiles/guns/launcher/syringe_gun.dm index 75c015d579..099f8687a3 100644 --- a/code/modules/projectiles/guns/launcher/syringe_gun.dm +++ b/code/modules/projectiles/guns/launcher/syringe_gun.dm @@ -133,4 +133,5 @@ name = "syringe gun revolver" desc = "A modification of the syringe gun design, using a rotating cylinder to store up to five syringes. The spring still needs to be drawn between shots." icon_state = "rapidsyringegun" + item_state = "rapidsyringegun" max_darts = 5 diff --git a/code/modules/projectiles/guns/projectile/automatic.dm b/code/modules/projectiles/guns/projectile/automatic.dm index 5778b3febe..75bbf810a8 100644 --- a/code/modules/projectiles/guns/projectile/automatic.dm +++ b/code/modules/projectiles/guns/projectile/automatic.dm @@ -51,7 +51,7 @@ name = "\improper STS-35 automatic rifle" desc = "A durable, rugged looking automatic weapon of a make popular on the frontier worlds. Uses 7.62mm rounds. It is unmarked." icon_state = "arifle" - item_state = "l6closednomag" //placeholder + item_state = null w_class = 4 force = 10 caliber = "a762" @@ -63,12 +63,13 @@ /obj/item/weapon/gun/projectile/automatic/sts35/update_icon() ..() icon_state = (ammo_magazine)? "arifle-0" : "arifle" + update_held_icon() /obj/item/weapon/gun/projectile/automatic/wt550 name = "\improper W-T 550 Saber" desc = "A cheap, mass produced Ward-Takahashi PDW. Uses 9mm rounds." icon_state = "wt550" - item_state = "c20r" //placeholder + item_state = "wt550" w_class = 3 caliber = "9mm" origin_tech = "combat=5;materials=2" @@ -90,7 +91,7 @@ name = "\improper Z8 Bulldog" desc = "An older model bullpup carbine, made by the now defunct Zendai Foundries. Uses armor piercing 5.56mm rounds. Makes you feel like a space marine when you hold it." icon_state = "carbine" - item_state = "l6closednomag" //placeholder + item_state = "z8carbine" w_class = 4 force = 10 caliber = "a556" diff --git a/code/modules/projectiles/guns/projectile/dartgun.dm b/code/modules/projectiles/guns/projectile/dartgun.dm index afb1f33874..d7dc5824eb 100644 --- a/code/modules/projectiles/guns/projectile/dartgun.dm +++ b/code/modules/projectiles/guns/projectile/dartgun.dm @@ -43,6 +43,7 @@ name = "dart gun" desc = "A small gas-powered dartgun, capable of delivering chemical cocktails swiftly across short distances." icon_state = "dartgun-empty" + item_state = null caliber = "dart" fire_sound = 'sound/weapons/empty.ogg' diff --git a/code/modules/projectiles/guns/projectile/pistol.dm b/code/modules/projectiles/guns/projectile/pistol.dm index f2155fa669..b2b98dd316 100644 --- a/code/modules/projectiles/guns/projectile/pistol.dm +++ b/code/modules/projectiles/guns/projectile/pistol.dm @@ -63,6 +63,7 @@ name = "desert eagle" desc = "A robust handgun that uses .50 AE ammo" icon_state = "deagle" + item_state = "deagle" force = 14.0 caliber = ".50" load_method = MAGAZINE @@ -107,6 +108,7 @@ name = "\improper Stechtkin pistol" desc = "A small, easily concealable gun. Uses 9mm rounds." icon_state = "pistol" + item_state = null w_class = 2 caliber = "9mm" silenced = 0 diff --git a/code/modules/projectiles/guns/projectile/revolver.dm b/code/modules/projectiles/guns/projectile/revolver.dm index 9bef0c40d3..a3156cdf17 100644 --- a/code/modules/projectiles/guns/projectile/revolver.dm +++ b/code/modules/projectiles/guns/projectile/revolver.dm @@ -2,6 +2,7 @@ name = "revolver" desc = "A classic revolver. Uses .357 ammo" icon_state = "revolver" + item_state = "revolver" caliber = "357" origin_tech = "combat=2;materials=2" handle_casings = CYCLE_CASINGS diff --git a/code/modules/projectiles/guns/projectile/shotgun.dm b/code/modules/projectiles/guns/projectile/shotgun.dm index fd85bc28be..fa29d7e8ba 100644 --- a/code/modules/projectiles/guns/projectile/shotgun.dm +++ b/code/modules/projectiles/guns/projectile/shotgun.dm @@ -42,6 +42,7 @@ /obj/item/weapon/gun/projectile/shotgun/pump/combat name = "combat shotgun" icon_state = "cshotgun" + item_state = "cshotgun" origin_tech = "combat=5;materials=2" max_shells = 7 //match the ammo box capacity, also it can hold a round in the chamber anyways, for a total of 8. ammo_type = /obj/item/ammo_casing/shotgun @@ -51,7 +52,7 @@ name = "double-barreled shotgun" desc = "A true classic." icon_state = "dshotgun" - item_state = "shotgun" + item_state = "dshotgun" //SPEEDLOADER because rapid unloading. //In principle someone could make a speedloader for it, so it makes sense. load_method = SINGLE_CASING|SPEEDLOADER diff --git a/code/setup.dm b/code/setup.dm index 0a09af0cd4..e127925632 100644 --- a/code/setup.dm +++ b/code/setup.dm @@ -243,6 +243,11 @@ #define slot_legs 21 #define slot_tie 22 +// Mob sprite sheets. These need to be strings as numbers +// cannot be used as associative list keys. +#define icon_l_hand "slot_l_hand" +#define icon_r_hand "slot_r_hand" + // Bitflags for clothing parts. #define HEAD 1 #define FACE 2 diff --git a/icons/mob/items/lefthand.dmi b/icons/mob/items/lefthand.dmi new file mode 100644 index 0000000000..fca687513a Binary files /dev/null and b/icons/mob/items/lefthand.dmi differ diff --git a/icons/mob/items/lefthand_guns.dmi b/icons/mob/items/lefthand_guns.dmi new file mode 100644 index 0000000000..d564d9bafe Binary files /dev/null and b/icons/mob/items/lefthand_guns.dmi differ diff --git a/icons/mob/items/righthand.dmi b/icons/mob/items/righthand.dmi new file mode 100644 index 0000000000..87b3eea46b Binary files /dev/null and b/icons/mob/items/righthand.dmi differ diff --git a/icons/mob/items/righthand_guns.dmi b/icons/mob/items/righthand_guns.dmi new file mode 100644 index 0000000000..63c5c0ae01 Binary files /dev/null and b/icons/mob/items/righthand_guns.dmi differ diff --git a/icons/mob/items_lefthand.dmi b/icons/mob/items_lefthand.dmi deleted file mode 100644 index d200726c6a..0000000000 Binary files a/icons/mob/items_lefthand.dmi and /dev/null differ diff --git a/icons/mob/items_righthand.dmi b/icons/mob/items_righthand.dmi deleted file mode 100644 index 7408e47eb4..0000000000 Binary files a/icons/mob/items_righthand.dmi and /dev/null differ diff --git a/icons/obj/gun.dmi b/icons/obj/gun.dmi index ce8762d6e1..7c823421d3 100644 Binary files a/icons/obj/gun.dmi and b/icons/obj/gun.dmi differ