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/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)
|
||||
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
|
||||
|
||||
@@ -191,16 +191,6 @@
|
||||
M.s_active.handle_item_insertion(src)
|
||||
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()
|
||||
if(istype(S) && S.can_be_inserted(src,1)) //see if we have box in other hand
|
||||
S.handle_item_insertion(src)
|
||||
@@ -211,6 +201,10 @@
|
||||
S.handle_item_insertion(src)
|
||||
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
|
||||
if(istype(S) && S.can_be_inserted(src,1))
|
||||
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)
|
||||
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
|
||||
//returns 0 if it cannot, 1 if successful
|
||||
/mob/proc/equip_to_appropriate_slot(obj/item/W)
|
||||
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
|
||||
return 1
|
||||
|
||||
|
||||
@@ -284,36 +284,14 @@
|
||||
reagents.clear_reagents()
|
||||
|
||||
/obj/item/weapon/reagent_containers/glass/bucket/equip_to_best_slot(var/mob/M)
|
||||
if(reagents.total_volume)
|
||||
if(src != M.get_active_hand())
|
||||
M << "<span class='warning'>You are not holding anything to equip!</span>"
|
||||
return 0
|
||||
|
||||
if(M.s_active && M.s_active.can_be_inserted(src,1)) //if storage active insert there
|
||||
M.s_active.handle_item_insertion(src)
|
||||
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()
|
||||
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 ..()
|
||||
if(reagents.total_volume) //If there is water in a bucket, don't quick equip it to the head
|
||||
var/count = 0
|
||||
for (var/slot in slot_equipment_priority)
|
||||
count++
|
||||
if (slot == slot_head)
|
||||
slot[count] = null
|
||||
break
|
||||
. = ..()
|
||||
slot_equipment_priority[count] = slot_head
|
||||
return
|
||||
return ..()
|
||||
Reference in New Issue
Block a user