mirror of
https://github.com/yogstation13/Yogstation.git
synced 2025-02-26 09:04:50 +00:00
Refactor using slot_equipment_priority
This commit is contained in:
@@ -102,6 +102,25 @@ var/global/image/fire_overlay = image("icon" = 'icons/effects/fire.dmi', "icon_s
|
|||||||
var/block_chance = 0
|
var/block_chance = 0
|
||||||
var/hit_reaction_chance = 0 //If you want to have something unrelated to blocking/armour piercing etc. Maybe not needed, but trying to think ahead/allow more freedom
|
var/hit_reaction_chance = 0 //If you want to have something unrelated to blocking/armour piercing etc. Maybe not needed, but trying to think ahead/allow more freedom
|
||||||
|
|
||||||
|
//The list of slots by priority. equip_to_appropriate_slot() uses this list. Doesn't matter if a mob type doesn't have a slot.
|
||||||
|
var/list/slot_equipment_priority = list( \
|
||||||
|
slot_back,\
|
||||||
|
slot_wear_id,\
|
||||||
|
slot_w_uniform,\
|
||||||
|
slot_wear_suit,\
|
||||||
|
slot_wear_mask,\
|
||||||
|
slot_head,\
|
||||||
|
slot_shoes,\
|
||||||
|
slot_gloves,\
|
||||||
|
slot_ears,\
|
||||||
|
slot_glasses,\
|
||||||
|
slot_belt,\
|
||||||
|
slot_s_store,\
|
||||||
|
slot_l_store,\
|
||||||
|
slot_r_store,\
|
||||||
|
slot_drone_storage\
|
||||||
|
)
|
||||||
|
|
||||||
/obj/item/proc/check_allowed_items(atom/target, not_inside, target_self)
|
/obj/item/proc/check_allowed_items(atom/target, not_inside, target_self)
|
||||||
if(((src in target) && !target_self) || ((!istype(target.loc, /turf)) && (!istype(target, /turf)) && (not_inside)) || is_type_in_list(target, can_be_placed_into))
|
if(((src in target) && !target_self) || ((!istype(target.loc, /turf)) && (!istype(target, /turf)) && (not_inside)) || is_type_in_list(target, can_be_placed_into))
|
||||||
return 0
|
return 0
|
||||||
|
|||||||
@@ -191,16 +191,6 @@
|
|||||||
M.s_active.handle_item_insertion(src)
|
M.s_active.handle_item_insertion(src)
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
if(istype(M, /mob/living/simple_animal/drone))
|
|
||||||
var/mob/living/simple_animal/drone/D = M
|
|
||||||
var/obj/item/weapon/storage/T = D.internal_storage
|
|
||||||
if (!T)
|
|
||||||
if (D.equip_to_slot_if_possible(src, slot_drone_storage, 0, 1, 1))
|
|
||||||
return 1
|
|
||||||
else if (istype(T) && T.can_be_inserted(src,1)) //If carrying storage item like toolbox
|
|
||||||
T.handle_item_insertion(src)
|
|
||||||
return 1
|
|
||||||
|
|
||||||
var/obj/item/weapon/storage/S = M.get_inactive_hand()
|
var/obj/item/weapon/storage/S = M.get_inactive_hand()
|
||||||
if(istype(S) && S.can_be_inserted(src,1)) //see if we have box in other hand
|
if(istype(S) && S.can_be_inserted(src,1)) //see if we have box in other hand
|
||||||
S.handle_item_insertion(src)
|
S.handle_item_insertion(src)
|
||||||
@@ -211,6 +201,10 @@
|
|||||||
S.handle_item_insertion(src)
|
S.handle_item_insertion(src)
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
|
S = M.get_item_by_slot(slot_drone_storage) //else we put in whatever is in drone storage
|
||||||
|
if(istype(S) && S.can_be_inserted(src,1))
|
||||||
|
S.handle_item_insertion(src)
|
||||||
|
|
||||||
S = M.get_item_by_slot(slot_back) //else we put in backpack
|
S = M.get_item_by_slot(slot_back) //else we put in backpack
|
||||||
if(istype(S) && S.can_be_inserted(src,1))
|
if(istype(S) && S.can_be_inserted(src,1))
|
||||||
S.handle_item_insertion(src)
|
S.handle_item_insertion(src)
|
||||||
|
|||||||
@@ -278,30 +278,12 @@ var/next_mob_id = 0
|
|||||||
/mob/proc/equip_to_slot_or_del(obj/item/W, slot)
|
/mob/proc/equip_to_slot_or_del(obj/item/W, slot)
|
||||||
equip_to_slot_if_possible(W, slot, 1, 1, 0)
|
equip_to_slot_if_possible(W, slot, 1, 1, 0)
|
||||||
|
|
||||||
//The list of slots by priority. equip_to_appropriate_slot() uses this list. Doesn't matter if a mob type doesn't have a slot.
|
|
||||||
var/list/slot_equipment_priority = list( \
|
|
||||||
slot_back,\
|
|
||||||
slot_wear_id,\
|
|
||||||
slot_w_uniform,\
|
|
||||||
slot_wear_suit,\
|
|
||||||
slot_wear_mask,\
|
|
||||||
slot_head,\
|
|
||||||
slot_shoes,\
|
|
||||||
slot_gloves,\
|
|
||||||
slot_ears,\
|
|
||||||
slot_glasses,\
|
|
||||||
slot_belt,\
|
|
||||||
slot_s_store,\
|
|
||||||
slot_l_store,\
|
|
||||||
slot_r_store\
|
|
||||||
)
|
|
||||||
|
|
||||||
//puts the item "W" into an appropriate slot in a human's inventory
|
//puts the item "W" into an appropriate slot in a human's inventory
|
||||||
//returns 0 if it cannot, 1 if successful
|
//returns 0 if it cannot, 1 if successful
|
||||||
/mob/proc/equip_to_appropriate_slot(obj/item/W)
|
/mob/proc/equip_to_appropriate_slot(obj/item/W)
|
||||||
if(!istype(W)) return 0
|
if(!istype(W)) return 0
|
||||||
|
|
||||||
for(var/slot in slot_equipment_priority)
|
for(var/slot in W.slot_equipment_priority)
|
||||||
if(equip_to_slot_if_possible(W, slot, 0, 1, 1)) //qdel_on_fail = 0; disable_warning = 0; redraw_mob = 1
|
if(equip_to_slot_if_possible(W, slot, 0, 1, 1)) //qdel_on_fail = 0; disable_warning = 0; redraw_mob = 1
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
|
|||||||
@@ -284,36 +284,14 @@
|
|||||||
reagents.clear_reagents()
|
reagents.clear_reagents()
|
||||||
|
|
||||||
/obj/item/weapon/reagent_containers/glass/bucket/equip_to_best_slot(var/mob/M)
|
/obj/item/weapon/reagent_containers/glass/bucket/equip_to_best_slot(var/mob/M)
|
||||||
if(reagents.total_volume)
|
if(reagents.total_volume) //If there is water in a bucket, don't quick equip it to the head
|
||||||
if(src != M.get_active_hand())
|
var/count = 0
|
||||||
M << "<span class='warning'>You are not holding anything to equip!</span>"
|
for (var/slot in slot_equipment_priority)
|
||||||
return 0
|
count++
|
||||||
|
if (slot == slot_head)
|
||||||
if(M.s_active && M.s_active.can_be_inserted(src,1)) //if storage active insert there
|
slot[count] = null
|
||||||
M.s_active.handle_item_insertion(src)
|
break
|
||||||
return 1
|
. = ..()
|
||||||
|
slot_equipment_priority[count] = slot_head
|
||||||
if(istype(M, /mob/living/simple_animal/drone))
|
return
|
||||||
var/mob/living/simple_animal/drone/D = M
|
return ..()
|
||||||
var/obj/item/weapon/storage/T = D.internal_storage
|
|
||||||
if (!T)
|
|
||||||
if (D.equip_to_slot_if_possible(src, slot_drone_storage, 0, 1, 1))
|
|
||||||
return 1
|
|
||||||
else if (istype(T) && T.can_be_inserted(src,1)) //If carrying storage item like toolbox
|
|
||||||
T.handle_item_insertion(src)
|
|
||||||
return 1
|
|
||||||
|
|
||||||
var/obj/item/weapon/storage/S = M.get_inactive_hand()
|
|
||||||
if(istype(S) && S.can_be_inserted(src,1)) //see if we have box in other hand
|
|
||||||
S.handle_item_insertion(src)
|
|
||||||
return 1
|
|
||||||
|
|
||||||
S = M.get_item_by_slot(slot_back) //else we put in backpack
|
|
||||||
if(istype(S) && S.can_be_inserted(src,1))
|
|
||||||
S.handle_item_insertion(src)
|
|
||||||
playsound(src.loc, "rustle", 50, 1, -5)
|
|
||||||
return 1
|
|
||||||
|
|
||||||
M << "<span class='warning'>You are unable to equip that!</span>"
|
|
||||||
return 0
|
|
||||||
else return ..()
|
|
||||||
Reference in New Issue
Block a user