From 2a31e44d952595cba9cd4e65fb2deea01f31a499 Mon Sep 17 00:00:00 2001 From: Xhuis Date: Sun, 18 Jun 2017 23:24:39 -0400 Subject: [PATCH] Adds framework for equip delays --- code/game/objects/items.dm | 5 ++-- code/modules/clothing/suits/miscellaneous.dm | 1 + code/modules/mob/inventory.dm | 3 ++ .../mob/living/carbon/human/inventory.dm | 4 +-- .../mob/living/carbon/human/species.dm | 30 +++++++++++-------- code/modules/mob/mob.dm | 7 +++-- 6 files changed, 31 insertions(+), 19 deletions(-) diff --git a/code/game/objects/items.dm b/code/game/objects/items.dm index 6dec85e795e..10ca2cedff6 100644 --- a/code/game/objects/items.dm +++ b/code/game/objects/items.dm @@ -59,6 +59,7 @@ GLOBAL_VAR_INIT(rpg_loot_items, FALSE) var/armour_penetration = 0 //percentage of armour effectiveness to remove var/list/allowed = null //suit storage stuff. var/obj/item/device/uplink/hidden_uplink = null + var/equip_delay = 0 //In deciseconds, how long an item takes to equip; counts only for normal clothing slots, not pockets etc. var/strip_delay = 40 var/put_on_delay = 20 var/breakouttime = 0 @@ -407,11 +408,11 @@ GLOBAL_VAR_INIT(rpg_loot_items, FALSE) //if this is being done by a mob other than M, it will include the mob equipper, who is trying to equip the item to mob M. equipper will be null otherwise. //If you are making custom procs but would like to retain partial or complete functionality of this one, include a 'return ..()' to where you want this to happen. //Set disable_warning to 1 if you wish it to not give you outputs. -/obj/item/proc/mob_can_equip(mob/M, mob/equipper, slot, disable_warning = 0) +/obj/item/proc/mob_can_equip(mob/M, mob/equipper, slot, disable_warning = 0, bypass_equip_delay) if(!M) return 0 - return M.can_equip(src, slot, disable_warning) + return M.can_equip(src, slot, disable_warning, bypass_equip_delay) /obj/item/verb/verb_pickup() set src in oview(1) diff --git a/code/modules/clothing/suits/miscellaneous.dm b/code/modules/clothing/suits/miscellaneous.dm index 4f875f96cd9..8e54a28f107 100644 --- a/code/modules/clothing/suits/miscellaneous.dm +++ b/code/modules/clothing/suits/miscellaneous.dm @@ -318,6 +318,7 @@ item_state = "straight_jacket" body_parts_covered = CHEST|GROIN|LEGS|ARMS|HANDS flags_inv = HIDEGLOVES|HIDESHOES|HIDEJUMPSUIT + equip_delay = 50 strip_delay = 60 breakouttime = 3000 diff --git a/code/modules/mob/inventory.dm b/code/modules/mob/inventory.dm index 27e5a776d89..51b46fc9436 100644 --- a/code/modules/mob/inventory.dm +++ b/code/modules/mob/inventory.dm @@ -362,6 +362,9 @@ if(M.equip_to_appropriate_slot(src)) M.update_inv_hands() return TRUE + else + if(equip_delay) + return if(M.s_active && M.s_active.can_be_inserted(src,1)) //if storage active insert there M.s_active.handle_item_insertion(src) diff --git a/code/modules/mob/living/carbon/human/inventory.dm b/code/modules/mob/living/carbon/human/inventory.dm index 1b5518008e5..62e63277f5c 100644 --- a/code/modules/mob/living/carbon/human/inventory.dm +++ b/code/modules/mob/living/carbon/human/inventory.dm @@ -1,5 +1,5 @@ -/mob/living/carbon/human/can_equip(obj/item/I, slot, disable_warning = 0) - return dna.species.can_equip(I, slot, disable_warning, src) +/mob/living/carbon/human/can_equip(obj/item/I, slot, disable_warning = 0, bypass_equip_delay) + return dna.species.can_equip(I, slot, disable_warning, src, bypass_equip_delay) // Return the item currently in the slot ID /mob/living/carbon/human/get_item_by_slot(slot_id) diff --git a/code/modules/mob/living/carbon/human/species.dm b/code/modules/mob/living/carbon/human/species.dm index 1a5182a5636..4ba45f192ff 100644 --- a/code/modules/mob/living/carbon/human/species.dm +++ b/code/modules/mob/living/carbon/human/species.dm @@ -603,7 +603,7 @@ // handles the equipping of species-specific gear return -/datum/species/proc/can_equip(obj/item/I, slot, disable_warning, mob/living/carbon/human/H) +/datum/species/proc/can_equip(obj/item/I, slot, disable_warning, mob/living/carbon/human/H, bypass_equip_delay) if(slot in no_equip) if(!I.species_exception || !is_type_in_list(src, I.species_exception)) return 0 @@ -623,7 +623,7 @@ return 0 if(!H.get_bodypart("head")) return 0 - return 1 + return equip_delay_check(I, H, bypass_equip_delay) if(slot_neck) if(H.wear_neck) return 0 @@ -635,13 +635,13 @@ return 0 if( !(I.slot_flags & SLOT_BACK) ) return 0 - return 1 + return equip_delay_check(I, H, bypass_equip_delay) if(slot_wear_suit) if(H.wear_suit) return 0 if( !(I.slot_flags & SLOT_OCLOTHING) ) return 0 - return 1 + return equip_delay_check(I, H, bypass_equip_delay) if(slot_gloves) if(H.gloves) return 0 @@ -649,7 +649,7 @@ return 0 if(num_arms < 2) return 0 - return 1 + return equip_delay_check(I, H, bypass_equip_delay) if(slot_shoes) if(H.shoes) return 0 @@ -661,7 +661,7 @@ if(!disable_warning) to_chat(H, "The footwear around here isn't compatible with your feet!") return 0 - return 1 + return equip_delay_check(I, H, bypass_equip_delay) if(slot_belt) if(H.belt) return 0 @@ -671,7 +671,7 @@ return 0 if( !(I.slot_flags & SLOT_BELT) ) return - return 1 + return equip_delay_check(I, H, bypass_equip_delay) if(slot_glasses) if(H.glasses) return 0 @@ -679,7 +679,7 @@ return 0 if(!H.get_bodypart("head")) return 0 - return 1 + return equip_delay_check(I, H, bypass_equip_delay) if(slot_head) if(H.head) return 0 @@ -687,7 +687,7 @@ return 0 if(!H.get_bodypart("head")) return 0 - return 1 + return equip_delay_check(I, H, bypass_equip_delay) if(slot_ears) if(H.ears) return 0 @@ -695,13 +695,13 @@ return 0 if(!H.get_bodypart("head")) return 0 - return 1 + return equip_delay_check(I, H, bypass_equip_delay) if(slot_w_uniform) if(H.w_uniform) return 0 if( !(I.slot_flags & SLOT_ICLOTHING) ) return 0 - return 1 + return equip_delay_check(I, H, bypass_equip_delay) if(slot_wear_id) if(H.wear_id) return 0 @@ -711,7 +711,7 @@ return 0 if( !(I.slot_flags & SLOT_ID) ) return 0 - return 1 + return equip_delay_check(I, H, bypass_equip_delay) if(slot_l_store) if(I.flags & NODROP) //Pockets aren't visible, so you can't move NODROP items into them. return 0 @@ -783,6 +783,12 @@ return 0 return 0 //Unsupported slot +/datum/species/proc/equip_delay_check(obj/item/I, mob/living/carbon/human/H, bypass_equip_delay) + if(!I.equip_delay || bypass_equip_delay) + return TRUE + H.visible_message("[H] start putting on [I]...", "You start putting on [I]...") + return do_after(H, I.equip_delay, target = H) + /datum/species/proc/before_equip_job(datum/job/J, mob/living/carbon/human/H) return diff --git a/code/modules/mob/mob.dm b/code/modules/mob/mob.dm index 89b8a18e6a5..5f7e9c7fe50 100644 --- a/code/modules/mob/mob.dm +++ b/code/modules/mob/mob.dm @@ -198,9 +198,9 @@ //set qdel_on_fail to have it delete W if it fails to equip //set disable_warning to disable the 'you are unable to equip that' warning. //unset redraw_mob to prevent the mob from being redrawn at the end. -/mob/proc/equip_to_slot_if_possible(obj/item/W, slot, qdel_on_fail = 0, disable_warning = 0, redraw_mob = 1) +/mob/proc/equip_to_slot_if_possible(obj/item/W, slot, qdel_on_fail = 0, disable_warning = 0, redraw_mob = 1, bypass_equip_delay) if(!istype(W)) return 0 - if(!W.mob_can_equip(src, null, slot, disable_warning)) + if(!W.mob_can_equip(src, null, slot, disable_warning, bypass_equip_delay)) if(qdel_on_fail) qdel(W) else @@ -216,8 +216,9 @@ return //This is just a commonly used configuration for the equip_to_slot_if_possible() proc, used to equip people when the rounds tarts and when events happen and such. +//Also bypasses equip delay checks, since the mob isn't actually putting it on. /mob/proc/equip_to_slot_or_del(obj/item/W, slot) - return equip_to_slot_if_possible(W, slot, 1, 1, 0) + return equip_to_slot_if_possible(W, slot, 1, 1, 0, 1) //puts the item "W" into an appropriate slot in a human's inventory //returns 0 if it cannot, 1 if successful