diff --git a/code/game/objects/items.dm b/code/game/objects/items.dm index 77181a1eb64..4053dc13baf 100644 --- a/code/game/objects/items.dm +++ b/code/game/objects/items.dm @@ -3,7 +3,6 @@ icon = 'icons/obj/items.dmi' var/image/blood_overlay = null //this saves our blood splatter overlay, which will be processed not to go over the edges of the sprite var/abstract = 0 - var/item_state = null var/r_speed = 1.0 var/health = null var/burn_point = null @@ -39,6 +38,9 @@ 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. + var/item_state = null // Used to specify the item state for the on-mob overlays. + var/item_state_slots = null //overrides the default item_state for particular slots. + // 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. diff --git a/code/game/objects/items/weapons/storage/backpack.dm b/code/game/objects/items/weapons/storage/backpack.dm index 40937ea61ca..4072e49eb91 100644 --- a/code/game/objects/items/weapons/storage/backpack.dm +++ b/code/game/objects/items/weapons/storage/backpack.dm @@ -6,8 +6,17 @@ /obj/item/weapon/storage/backpack name = "backpack" desc = "You wear this on your back and put items into it." + item_icons = list( + slot_l_hand_key = 'icons/mob/items/lefthand_backpacks.dmi', + slot_r_hand_key = 'icons/mob/items/righthand_backpacks.dmi', + ) icon_state = "backpack" - item_state = "backpack" + item_state = null + //most backpacks use the default backpack state for inhand overlays + item_state_slots = list( + slot_l_hand_key = "backpack", + slot_r_hand_key = "backpack", + ) w_class = 4 slot_flags = SLOT_BACK max_w_class = 3 @@ -95,6 +104,7 @@ storage_slots = 20 max_w_class = 3 max_storage_space = 400 // can store a ton of shit! + item_state_slots = null /obj/item/weapon/storage/backpack/cultpack name = "trophy rack" @@ -105,61 +115,56 @@ name = "Giggles von Honkerton" desc = "It's a backpack made by Honk! Co." icon_state = "clownpack" - item_state = "clownpack" + item_state_slots = null /obj/item/weapon/storage/backpack/medic name = "medical backpack" desc = "It's a backpack especially designed for use in a sterile environment." icon_state = "medicalpack" - item_state = "medicalpack" + item_state_slots = null /obj/item/weapon/storage/backpack/security name = "security backpack" desc = "It's a very robust backpack." icon_state = "securitypack" - item_state = "securitypack" + item_state_slots = null /obj/item/weapon/storage/backpack/captain name = "captain's backpack" desc = "It's a special backpack made exclusively for Nanotrasen officers." icon_state = "captainpack" - item_state = "captainpack" + item_state_slots = null /obj/item/weapon/storage/backpack/industrial name = "industrial backpack" desc = "It's a tough backpack for the daily grind of station life." icon_state = "engiepack" - item_state = "engiepack" + item_state_slots = null /obj/item/weapon/storage/backpack/toxins name = "laboratory backpack" desc = "It's a light backpack modeled for use in laboratories and other scientific institutions." icon_state = "toxpack" - item_state = "toxpack" /obj/item/weapon/storage/backpack/hydroponics name = "herbalist's backpack" desc = "It's a green backpack with many pockets to store plants and tools in." icon_state = "hydpack" - item_state = "hydpack" /obj/item/weapon/storage/backpack/genetics name = "geneticist backpack" desc = "It's a backpack fitted with slots for diskettes and other workplace tools." icon_state = "genpack" - item_state = "genpack" /obj/item/weapon/storage/backpack/virology name = "sterile backpack" desc = "It's a sterile backpack able to withstand different pathogens from entering its fabric." icon_state = "viropack" - item_state = "viropack" /obj/item/weapon/storage/backpack/chemistry name = "chemistry backpack" desc = "It's an orange backpack which was designed to hold beakers, pill bottles and bottles." icon_state = "chempack" - item_state = "chempack" /* * Satchel Types @@ -184,13 +189,19 @@ name = "industrial satchel" desc = "A tough satchel with extra pockets." icon_state = "satchel-eng" - item_state = "engiepack" + item_state_slots = list( + slot_l_hand_key = "engiepack", + slot_r_hand_key = "engiepack", + ) /obj/item/weapon/storage/backpack/satchel_med name = "medical satchel" desc = "A sterile satchel used in medical departments." icon_state = "satchel-med" - item_state = "medicalpack" + item_state_slots = list( + slot_l_hand_key = "medicalpack", + slot_r_hand_key = "medicalpack", + ) /obj/item/weapon/storage/backpack/satchel_vir name = "virologist satchel" @@ -216,7 +227,10 @@ name = "security satchel" desc = "A robust satchel for security related needs." icon_state = "satchel-sec" - item_state = "securitypack" + item_state_slots = list( + slot_l_hand_key = "securitypack", + slot_r_hand_key = "securitypack", + ) /obj/item/weapon/storage/backpack/satchel_hyd name = "hydroponics satchel" @@ -228,13 +242,17 @@ desc = "An exclusive satchel for Nanotrasen officers." icon_state = "satchel-cap" item_state = "captainpack" + item_state_slots = null //ERT backpacks. /obj/item/weapon/storage/backpack/ert name = "emergency response team backpack" desc = "A spacious backpack with lots of pockets, used by members of the Nanotrasen Emergency Response Team." icon_state = "ert_commander" - item_state = "backpack" + item_state_slots = list( + slot_l_hand_key = "securitypack", + slot_r_hand_key = "securitypack", + ) //Commander /obj/item/weapon/storage/backpack/ert/commander diff --git a/code/modules/mob/living/carbon/human/update_icons.dm b/code/modules/mob/living/carbon/human/update_icons.dm index 4d6f1e2a7d8..6433c9d9438 100644 --- a/code/modules/mob/living/carbon/human/update_icons.dm +++ b/code/modules/mob/living/carbon/human/update_icons.dm @@ -741,19 +741,36 @@ var/global/list/damage_icon_parts = list() /mob/living/carbon/human/update_inv_back(var/update_icons=1) if(back) back.screen_loc = ui_back //TODO - var/obj/item/weapon/rig/rig = back + + //determine the icon to use + var/icon/overlay_icon if(back.icon_override) - overlays_standing[BACK_LAYER] = image("icon" = back.icon_override, "icon_state" = "[back.icon_state]") - //If this is a rig and a mob_icon is set, it will take species into account in the rig update_icon() proc. - else if(istype(rig) && rig.mob_icon) - overlays_standing[BACK_LAYER] = rig.mob_icon + overlay_icon = back.icon_override + else if(istype(back, /obj/item/weapon/rig)) + //If this is a rig and a mob_icon is set, it will take species into account in the rig update_icon() proc. + var/obj/item/weapon/rig/rig = back + overlay_icon = rig.mob_icon else if(back.sprite_sheets && back.sprite_sheets[species.name]) - overlays_standing[BACK_LAYER] = image("icon" = back.sprite_sheets[species.name], "icon_state" = "[back.icon_state]") + overlay_icon = back.sprite_sheets[species.name] else - overlays_standing[BACK_LAYER] = image("icon" = 'icons/mob/back.dmi', "icon_state" = "[back.icon_state]") + overlay_icon = INV_BACK_DEF_ICON + + //determine state to use + var/overlay_state + if(back.item_state_slots && back.item_state_slots[slot_back_key]) + overlay_state = back.item_state_slots[slot_back_key] + else if(back.item_state) + overlay_state = back.item_state + else + overlay_state = back.icon_state + + //create the image + overlays_standing[BACK_LAYER] = image(icon = overlay_icon, icon_state = overlay_state) else - overlays_standing[BACK_LAYER] = null - if(update_icons) update_icons() + overlays_standing[BACK_LAYER] = null + + if(update_icons) + update_icons() /mob/living/carbon/human/update_hud() //TODO: do away with this if possible @@ -790,19 +807,27 @@ var/global/list/damage_icon_parts = list() 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 + //determine icon to use + var/icon/t_icon 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]") + t_icon = r_hand.icon_override + else if(r_hand.item_icons && (slot_r_hand_key in r_hand.item_icons)) + t_icon = r_hand.item_icons[slot_r_hand_key] else - overlays_standing[R_HAND_LAYER] = image("icon" = t_icon, "icon_state" = "[t_state]") + t_icon = INV_R_HAND_DEF_ICON - if (handcuffed) drop_r_hand() + //determine icon state to use + var/t_state + if(r_hand.item_state_slots && r_hand.item_state_slots[slot_r_hand_key]) + t_state = r_hand.item_state_slots[slot_r_hand_key] + else if(r_hand.item_state) + t_state = r_hand.item_state + else + t_state = r_hand.icon_state + + overlays_standing[R_HAND_LAYER] = image(icon = t_icon, icon_state = t_state) + + if (handcuffed) drop_r_hand() //this should be moved out of icon code else overlays_standing[R_HAND_LAYER] = null @@ -813,19 +838,27 @@ var/global/list/damage_icon_parts = list() 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 + //determine icon to use + var/icon/t_icon 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]") + t_icon = l_hand.icon_override + else if(l_hand.item_icons && (slot_l_hand_key in l_hand.item_icons)) + t_icon = l_hand.item_icons[slot_l_hand_key] else - overlays_standing[L_HAND_LAYER] = image("icon" = t_icon, "icon_state" = "[t_state]") + t_icon = INV_L_HAND_DEF_ICON - if (handcuffed) drop_l_hand() + //determine icon state to use + var/t_state + if(l_hand.item_state_slots && l_hand.item_state_slots[slot_l_hand_key]) + t_state = l_hand.item_state_slots[slot_l_hand_key] + else if(l_hand.item_state) + t_state = l_hand.item_state + else + t_state = l_hand.icon_state + + overlays_standing[L_HAND_LAYER] = image(icon = t_icon, icon_state = t_state) + + if (handcuffed) drop_l_hand() //This probably should not be here else overlays_standing[L_HAND_LAYER] = null diff --git a/code/modules/mob/update_icons.dm b/code/modules/mob/update_icons.dm index 480c4be3223..394281c394d 100644 --- a/code/modules/mob/update_icons.dm +++ b/code/modules/mob/update_icons.dm @@ -2,6 +2,7 @@ //Having them here also makes for a nice reference list of the various overlay-updating procs available //default item on-mob icons +#define INV_BACK_DEF_ICON 'icons/mob/back.dmi' #define INV_L_HAND_DEF_ICON 'icons/mob/items/lefthand.dmi' #define INV_R_HAND_DEF_ICON 'icons/mob/items/righthand.dmi' diff --git a/code/modules/projectiles/gun.dm b/code/modules/projectiles/gun.dm index 77693417dfd..6d1861822ff 100644 --- a/code/modules/projectiles/gun.dm +++ b/code/modules/projectiles/gun.dm @@ -4,8 +4,8 @@ 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', + slot_l_hand_key = 'icons/mob/items/lefthand_guns.dmi', + slot_r_hand_key = 'icons/mob/items/righthand_guns.dmi', ) icon_state = "detective" item_state = "gun" diff --git a/code/setup.dm b/code/setup.dm index 38836d54d52..eedd8c70c0c 100644 --- a/code/setup.dm +++ b/code/setup.dm @@ -255,10 +255,12 @@ #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" +// Inventory slot strings. +// since numbers cannot be used as associative list keys. +#define slot_l_hand_key "slot_l_hand" +#define slot_r_hand_key "slot_r_hand" +#define slot_w_uniform_key "w_uniform" +#define slot_back_key "back" // Bitflags for clothing parts. #define HEAD 1 diff --git a/icons/mob/back.dmi b/icons/mob/back.dmi index 8322b7b4f58..38fbd5a2e84 100644 Binary files a/icons/mob/back.dmi and b/icons/mob/back.dmi differ diff --git a/icons/mob/items/lefthand.dmi b/icons/mob/items/lefthand.dmi index fca687513ab..7f4ea4acb3b 100644 Binary files a/icons/mob/items/lefthand.dmi and b/icons/mob/items/lefthand.dmi differ diff --git a/icons/mob/items/lefthand_backpacks.dmi b/icons/mob/items/lefthand_backpacks.dmi new file mode 100644 index 00000000000..28d898ef017 Binary files /dev/null and b/icons/mob/items/lefthand_backpacks.dmi differ diff --git a/icons/mob/items/righthand.dmi b/icons/mob/items/righthand.dmi index 87b3eea46b0..a53ac0d5ad0 100644 Binary files a/icons/mob/items/righthand.dmi and b/icons/mob/items/righthand.dmi differ diff --git a/icons/mob/items/righthand_backpacks.dmi b/icons/mob/items/righthand_backpacks.dmi new file mode 100644 index 00000000000..b3153b15336 Binary files /dev/null and b/icons/mob/items/righthand_backpacks.dmi differ