From b2d3711c11a84d67bd39d89c251f0cea448b4c4b Mon Sep 17 00:00:00 2001 From: mwerezak Date: Fri, 3 Jul 2015 21:58:11 -0400 Subject: [PATCH 1/3] Fixes knife inhand states --- code/game/objects/items/weapons/material/knives.dm | 2 ++ 1 file changed, 2 insertions(+) diff --git a/code/game/objects/items/weapons/material/knives.dm b/code/game/objects/items/weapons/material/knives.dm index 3271650d31..fd06b93adf 100644 --- a/code/game/objects/items/weapons/material/knives.dm +++ b/code/game/objects/items/weapons/material/knives.dm @@ -52,6 +52,7 @@ name = "kitchen knife" icon = 'icons/obj/kitchen.dmi' icon_state = "knife" + item_state = "knife" desc = "A general purpose Chef's Knife made by SpaceCook Incorporated. Guaranteed to stay sharp for years to come." flags = CONDUCT sharp = 1 @@ -85,6 +86,7 @@ name = "butcher's cleaver" icon = 'icons/obj/kitchen.dmi' icon_state = "butch" + item_state = "butcher_knife" desc = "A huge thing used for chopping and chopping up meat. This includes clowns and clown-by-products." force_divisor = 0.25 // 15 when wielded with hardness 60 (steel) attack_verb = list("cleaved", "slashed", "stabbed", "sliced", "torn", "ripped", "diced", "cut") From b7ee6e11fc61e77fbd1671dc394a9c8f2ec8cda3 Mon Sep 17 00:00:00 2001 From: mwerezak Date: Fri, 3 Jul 2015 22:02:28 -0400 Subject: [PATCH 2/3] Swaps force divisors between kitchen knives and utensil knives. Because why does the utensil deal more damage than a chopping knife? --- code/game/objects/items/weapons/material/kitchen.dm | 2 +- code/game/objects/items/weapons/material/knives.dm | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/code/game/objects/items/weapons/material/kitchen.dm b/code/game/objects/items/weapons/material/kitchen.dm index 597affcd35..4cfb1123f8 100644 --- a/code/game/objects/items/weapons/material/kitchen.dm +++ b/code/game/objects/items/weapons/material/kitchen.dm @@ -73,7 +73,7 @@ name = "knife" desc = "Can cut through any food." icon_state = "knife" - force_divisor = 0.2 // 12 when wielded with hardness 60 (steel) + force_divisor = 0.15 // 9 when wielded with hardness 60 (steel) /obj/item/weapon/material/kitchen/utensil/knife/attack(target as mob, mob/living/user as mob) if ((CLUMSY in user.mutations) && prob(50)) diff --git a/code/game/objects/items/weapons/material/knives.dm b/code/game/objects/items/weapons/material/knives.dm index fd06b93adf..d15ac40e95 100644 --- a/code/game/objects/items/weapons/material/knives.dm +++ b/code/game/objects/items/weapons/material/knives.dm @@ -57,7 +57,7 @@ flags = CONDUCT sharp = 1 edge = 1 - force_divisor = 0.15 // 9 when wielded with hardness 60 (steel) + force_divisor = 0.2 // 12 when wielded with hardness 60 (steel) matter = list(DEFAULT_WALL_MATERIAL = 12000) origin_tech = "materials=1" attack_verb = list("slashed", "stabbed", "sliced", "torn", "ripped", "diced", "cut") From 7af63ede5a5bf8f5f6008b9fcc6cc2d3eb71b5ca Mon Sep 17 00:00:00 2001 From: mwerezak Date: Fri, 3 Jul 2015 22:10:46 -0400 Subject: [PATCH 3/3] Custom items default to the inhands of the parent Makes custom items use the inhand states and icons of the parent item type if inhand states are not present in CUSTOM_ITEM_MOB. --- code/modules/customitems/item_spawning.dm | 64 +++++++++++++++++++++-- 1 file changed, 61 insertions(+), 3 deletions(-) diff --git a/code/modules/customitems/item_spawning.dm b/code/modules/customitems/item_spawning.dm index e81c33626e..6ccbcd43c4 100644 --- a/code/modules/customitems/item_spawning.dm +++ b/code/modules/customitems/item_spawning.dm @@ -20,6 +20,7 @@ /datum/custom_item var/assoc_key var/character_name + var/inherit_inhands = 1 //if unset, and inhands are not provided, then the inhand overlays will be invisible. var/item_icon var/item_desc var/name @@ -44,10 +45,19 @@ if(item_desc) item.desc = item_desc if(item_icon) - item.icon = CUSTOM_ITEM_OBJ - item.icon_state = item_icon - if(istype(item, /obj/item)) + if(!istype(item)) + item.icon = CUSTOM_ITEM_OBJ + item.icon_state = item_icon + return + else if(!inherit_inhands) + item.icon = CUSTOM_ITEM_OBJ + item.icon_state = item_icon + item.item_state = null + item.item_state_slots = null + item.item_icons = null item.icon_override = CUSTOM_ITEM_MOB + else + apply_icons(item) // Kits are dumb so this is going to have to be hardcoded/snowflake. if(istype(item, /obj/item/device/kit)) @@ -66,6 +76,52 @@ return item +/datum/custom_item/proc/apply_icons(var/obj/item/item) + var/list/new_item_icons = list() + var/list/new_item_state_slots = list() + + var/list/available_states = icon_states(CUSTOM_ITEM_MOB) + + //If l_hand or r_hand are not present, preserve them using item_icons/item_state_slots + //Then use icon_override to make every other slot use the custom sprites by default. + //This has to be done before we touch any of item's vars + if(!("[item_icon]_l" in available_states)) + new_item_state_slots[slot_l_hand_str] = get_state(item, slot_l_hand_str, "_l") + new_item_icons[slot_l_hand_str] = get_icon(item, slot_l_hand_str, 'icons/mob/items/lefthand.dmi') + if(!("[item_icon]_r" in available_states)) + new_item_state_slots[slot_r_hand_str] = get_state(item, slot_r_hand_str, "_r") + new_item_icons[slot_r_hand_str] = get_icon(item, slot_r_hand_str, 'icons/mob/items/righthand.dmi') + + item.icon = CUSTOM_ITEM_OBJ + item.icon_state = item_icon + item.item_state = null + item.item_state_slots = new_item_state_slots + item.item_icons = new_item_icons + item.icon_override = CUSTOM_ITEM_MOB + +//this has to mirror the way update_inv_*_hand() selects the state +/datum/custom_item/proc/get_state(var/obj/item/item, var/slot_str, var/hand_str) + var/t_state + if(item.item_state_slots && item.item_state_slots[slot_str]) + t_state = item.item_state_slots[slot_str] + else if(item.item_state) + t_state = item.item_state + else + t_state = item.icon_state + if(item.icon_override) + t_state += hand_str + return t_state + +//this has to mirror the way update_inv_*_hand() selects the icon +/datum/custom_item/proc/get_icon(var/obj/item/item, var/slot_str, var/icon/hand_icon) + var/icon/t_icon + if(item.icon_override) + t_icon = item.icon_override + else if(item.item_icons && (slot_str in item.item_icons)) + t_icon = item.item_icons[slot_str] + else + t_icon = hand_icon + return t_icon // Parses the config file into the custom_items list. /hook/startup/proc/load_custom_items() @@ -107,6 +163,8 @@ current_data.name = field_data if("item_icon") current_data.item_icon = field_data + if("inherit_inhands") + current_data.inherit_inhands = text2num(field_data) if("item_desc") current_data.item_desc = field_data if("req_access")