Adds framework for equip delays

This commit is contained in:
Xhuis
2017-06-18 23:24:39 -04:00
parent 2672d88800
commit 2a31e44d95
6 changed files with 31 additions and 19 deletions
+3 -2
View File
@@ -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)
@@ -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
+3
View File
@@ -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)
@@ -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)
+18 -12
View File
@@ -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, "<span class='warning'>The footwear around here isn't compatible with your feet!</span>")
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("<span class='notice'>[H] start putting on [I]...</span>", "<span class='notice'>You start putting on [I]...</span>")
return do_after(H, I.equip_delay, target = H)
/datum/species/proc/before_equip_job(datum/job/J, mob/living/carbon/human/H)
return
+4 -3
View File
@@ -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