mirror of
https://github.com/ParadiseSS13/Paradise.git
synced 2026-08-29 15:08:02 +01:00
I started with the desire to fix issue 634. It sounded like a simple issue, right? Well one complete rewrite of how equipping and stripping works later, this commit fixes issue 645
Code-wide changes: /mob -level procs: equip_if_possible() is now known as equip_to_slot_or_del() to prevent confusion with equip_to_slot_if_possible() and to better describe what it does. equip_to_slot_if_possible(item, slot, del_on_fail, disable_warning, redraw_mob) equip_to_appropriate_slot() is now a /mob - level proc. equip_to_slot() is an unsafe proc, which just handles the final step of actually getting an item onto the mob. It has no checks of whether it can or can't do that. Use equip_to_slot_if_possible() for that purpose. New /obj/item -level proc: /obj/item/proc/mob_can_equip(M as mob, slot, disable_warning = 0) This proc can be used to determine whehter a mob can pick up an item from the item's side. Carn, I'll need you to review code/modules/mob/living/carbon/human/inventory.dm to ensure that I'm not redrawing the mob too many times. git-svn-id: http://tgstation13.googlecode.com/svn/trunk@4423 316c924e-a436-60f5-8080-3fe189b3f50e
This commit is contained in:
@@ -21,7 +21,7 @@
|
||||
l_hand = W
|
||||
W.layer = 20 //TODO: move to equipped?
|
||||
// l_hand.screen_loc = ui_lhand
|
||||
W.equipped(src,"l_hand")
|
||||
W.equipped(src,slot_l_hand)
|
||||
if(client) client.screen |= W
|
||||
update_inv_l_hand()
|
||||
return 1
|
||||
@@ -36,7 +36,7 @@
|
||||
r_hand = W
|
||||
W.layer = 20
|
||||
// r_hand.screen_loc = ui_rhand
|
||||
W.equipped(src,"r_hand")
|
||||
W.equipped(src,slot_r_hand)
|
||||
if(client) client.screen |= W
|
||||
update_inv_r_hand()
|
||||
return 1
|
||||
|
||||
@@ -116,6 +116,7 @@
|
||||
using.icon = 'icons/mob/screen1_alien.dmi'
|
||||
using.icon_state = "equip"
|
||||
using.screen_loc = ui_alien_oclothing
|
||||
using.slot_id = slot_wear_suit
|
||||
using.layer = 19
|
||||
src.adding += using
|
||||
|
||||
@@ -129,6 +130,7 @@
|
||||
using.screen_loc = ui_rhand
|
||||
using.layer = 19
|
||||
src.r_hand_hud_object = using
|
||||
using.slot_id = slot_r_hand
|
||||
src.adding += using
|
||||
|
||||
using = new src.h_type( src )
|
||||
@@ -140,6 +142,7 @@
|
||||
using.icon_state = "hand_active"
|
||||
using.screen_loc = ui_lhand
|
||||
using.layer = 19
|
||||
using.slot_id = slot_l_hand
|
||||
src.l_hand_hud_object = using
|
||||
src.adding += using
|
||||
|
||||
@@ -149,6 +152,7 @@
|
||||
using.icon = 'icons/mob/screen1_alien.dmi'
|
||||
using.icon_state = "pocket"
|
||||
using.screen_loc = ui_storage1
|
||||
using.slot_id = slot_l_store
|
||||
using.layer = 19
|
||||
src.adding += using
|
||||
|
||||
@@ -158,6 +162,7 @@
|
||||
using.icon = 'icons/mob/screen1_alien.dmi'
|
||||
using.icon_state = "pocket"
|
||||
using.screen_loc = ui_storage2
|
||||
using.slot_id = slot_r_store
|
||||
using.layer = 19
|
||||
src.adding += using
|
||||
|
||||
@@ -167,6 +172,7 @@
|
||||
using.icon = 'icons/mob/screen1_alien.dmi'
|
||||
using.icon_state = "hair"
|
||||
using.screen_loc = ui_alien_head
|
||||
using.slot_id = slot_head
|
||||
using.layer = 19
|
||||
src.adding += using
|
||||
//end of equippable shit
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
l_hand = null
|
||||
update_inv_l_hand(0)
|
||||
|
||||
/mob/living/carbon/alien/humanoid/db_click(text, t1)
|
||||
/mob/living/carbon/alien/humanoid/attack_ui(slot_id)
|
||||
var/obj/item/W = get_active_hand()
|
||||
if(W)
|
||||
if(!istype(W)) return
|
||||
|
||||
@@ -130,7 +130,7 @@
|
||||
|
||||
|
||||
//can't equip anything
|
||||
/mob/living/carbon/alien/larva/db_click(text, t1)
|
||||
/mob/living/carbon/alien/larva/attack_ui(slot_id)
|
||||
return
|
||||
|
||||
/mob/living/carbon/alien/larva/meteorhit(O as obj)
|
||||
|
||||
@@ -113,6 +113,7 @@
|
||||
using.name = "i_clothing"
|
||||
using.dir = SOUTH
|
||||
using.icon = ui_style
|
||||
using.slot_id = slot_w_uniform
|
||||
using.icon_state = "center"
|
||||
using.screen_loc = ui_iclothing
|
||||
using.layer = 19
|
||||
@@ -122,6 +123,7 @@
|
||||
using.name = "o_clothing"
|
||||
using.dir = SOUTH
|
||||
using.icon = ui_style
|
||||
using.slot_id = slot_wear_suit
|
||||
using.icon_state = "equip"
|
||||
using.screen_loc = ui_oclothing
|
||||
using.layer = 19
|
||||
@@ -144,6 +146,7 @@
|
||||
if(mymob && !mymob.hand) //This being 0 or null means the right hand is in use
|
||||
using.icon_state = "hand_active"
|
||||
using.screen_loc = ui_rhand
|
||||
using.slot_id = slot_r_hand
|
||||
using.layer = 19
|
||||
src.r_hand_hud_object = using
|
||||
src.adding += using
|
||||
@@ -156,6 +159,7 @@
|
||||
if(mymob && mymob.hand) //This being 1 means the left hand is in use
|
||||
using.icon_state = "hand_active"
|
||||
using.screen_loc = ui_lhand
|
||||
using.slot_id = slot_l_hand
|
||||
using.layer = 19
|
||||
src.l_hand_hud_object = using
|
||||
src.adding += using
|
||||
@@ -184,6 +188,7 @@
|
||||
using.icon = ui_style
|
||||
using.icon_state = "id"
|
||||
using.screen_loc = ui_id
|
||||
using.slot_id = slot_wear_id
|
||||
using.layer = 19
|
||||
src.adding += using
|
||||
|
||||
@@ -193,6 +198,7 @@
|
||||
using.icon = ui_style
|
||||
using.icon_state = "equip"
|
||||
using.screen_loc = ui_mask
|
||||
using.slot_id = slot_wear_mask
|
||||
using.layer = 19
|
||||
src.other += using
|
||||
|
||||
@@ -202,6 +208,7 @@
|
||||
using.icon = ui_style
|
||||
using.icon_state = "back"
|
||||
using.screen_loc = ui_back
|
||||
using.slot_id = slot_back
|
||||
using.layer = 19
|
||||
src.adding += using
|
||||
|
||||
@@ -210,6 +217,7 @@
|
||||
using.icon = ui_style
|
||||
using.icon_state = "pocket"
|
||||
using.screen_loc = ui_storage1
|
||||
using.slot_id = slot_l_store
|
||||
using.layer = 19
|
||||
src.adding += using
|
||||
|
||||
@@ -218,6 +226,7 @@
|
||||
using.icon = ui_style
|
||||
using.icon_state = "pocket"
|
||||
using.screen_loc = ui_storage2
|
||||
using.slot_id = slot_r_store
|
||||
using.layer = 19
|
||||
src.adding += using
|
||||
|
||||
@@ -227,6 +236,7 @@
|
||||
using.dir = 8 //The sprite at dir=8 has the background whereas the others don't.
|
||||
using.icon_state = "belt"
|
||||
using.screen_loc = ui_sstore1
|
||||
using.slot_id = slot_s_store
|
||||
using.layer = 19
|
||||
src.adding += using
|
||||
|
||||
@@ -275,6 +285,7 @@
|
||||
using.icon = ui_style
|
||||
using.icon_state = "gloves"
|
||||
using.screen_loc = ui_gloves
|
||||
using.slot_id = slot_gloves
|
||||
using.layer = 19
|
||||
src.other += using
|
||||
|
||||
@@ -283,6 +294,7 @@
|
||||
using.icon = ui_style
|
||||
using.icon_state = "glasses"
|
||||
using.screen_loc = ui_glasses
|
||||
using.slot_id = slot_glasses
|
||||
using.layer = 19
|
||||
src.other += using
|
||||
|
||||
@@ -291,6 +303,7 @@
|
||||
using.icon = ui_style
|
||||
using.icon_state = "ears"
|
||||
using.screen_loc = ui_ears
|
||||
using.slot_id = slot_ears
|
||||
using.layer = 19
|
||||
src.other += using
|
||||
|
||||
@@ -299,6 +312,7 @@
|
||||
using.icon = ui_style
|
||||
using.icon_state = "hair"
|
||||
using.screen_loc = ui_head
|
||||
using.slot_id = slot_head
|
||||
using.layer = 19
|
||||
src.other += using
|
||||
|
||||
@@ -307,6 +321,7 @@
|
||||
using.icon = ui_style
|
||||
using.icon_state = "shoes"
|
||||
using.screen_loc = ui_shoes
|
||||
using.slot_id = slot_shoes
|
||||
using.layer = 19
|
||||
src.other += using
|
||||
|
||||
@@ -315,6 +330,7 @@
|
||||
using.icon = ui_style
|
||||
using.icon_state = "belt"
|
||||
using.screen_loc = ui_belt
|
||||
using.slot_id = slot_belt
|
||||
using.layer = 19
|
||||
src.adding += using
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -202,7 +202,7 @@
|
||||
return
|
||||
|
||||
|
||||
/mob/living/carbon/metroid/db_click(text, t1)
|
||||
/mob/living/carbon/metroid/attack_ui(slot)
|
||||
return
|
||||
|
||||
/mob/living/carbon/metroid/meteorhit(O as obj)
|
||||
|
||||
@@ -171,6 +171,7 @@
|
||||
using.icon_state = "hand1"
|
||||
using.screen_loc = ui_swaphand1
|
||||
using.layer = 19
|
||||
using.slot_id = slot_l_hand
|
||||
src.adding += using
|
||||
|
||||
using = new src.h_type( src )
|
||||
@@ -179,6 +180,7 @@
|
||||
using.icon = ui_style
|
||||
using.icon_state = "hand2"
|
||||
using.screen_loc = ui_swaphand2
|
||||
using.slot_id = slot_r_hand
|
||||
using.layer = 19
|
||||
src.adding += using
|
||||
/*
|
||||
@@ -199,6 +201,7 @@
|
||||
using.icon = ui_style
|
||||
using.icon_state = "equip"
|
||||
using.screen_loc = ui_monkey_mask
|
||||
using.slot_id = slot_wear_mask
|
||||
using.layer = 19
|
||||
src.adding += using
|
||||
|
||||
@@ -208,6 +211,7 @@
|
||||
using.icon = ui_style
|
||||
using.icon_state = "equip"
|
||||
using.screen_loc = ui_back
|
||||
using.slot_id = slot_back
|
||||
using.layer = 19
|
||||
src.adding += using
|
||||
/*
|
||||
|
||||
@@ -184,4 +184,49 @@
|
||||
source.regenerate_icons()
|
||||
target.regenerate_icons()
|
||||
del(src)
|
||||
return
|
||||
|
||||
|
||||
|
||||
//This is an UNSAFE proc. Use mob_can_equip() before calling this one! Or rather use equip_to_slot_if_possible() or advanced_equip_to_slot_if_possible()
|
||||
//set redraw_mob to 0 if you don't wish the hud to be updated - if you're doing it manually in your own proc.
|
||||
/mob/living/carbon/monkey/equip_to_slot(obj/item/W as obj, slot, redraw_mob = 1)
|
||||
if(!slot) return
|
||||
if(!istype(W)) return
|
||||
|
||||
if(W == get_active_hand())
|
||||
u_equip(W)
|
||||
|
||||
switch(slot)
|
||||
if(slot_back)
|
||||
src.back = W
|
||||
W.equipped(src, slot)
|
||||
update_inv_back(redraw_mob)
|
||||
if(slot_wear_mask)
|
||||
src.wear_mask = W
|
||||
W.equipped(src, slot)
|
||||
update_inv_wear_mask(redraw_mob)
|
||||
if(slot_handcuffed)
|
||||
src.handcuffed = W
|
||||
update_inv_handcuffed(redraw_mob)
|
||||
if(slot_legcuffed)
|
||||
src.legcuffed = W
|
||||
W.equipped(src, slot)
|
||||
update_inv_legcuffed(redraw_mob)
|
||||
if(slot_l_hand)
|
||||
src.l_hand = W
|
||||
W.equipped(src, slot)
|
||||
update_inv_l_hand(redraw_mob)
|
||||
if(slot_r_hand)
|
||||
src.r_hand = W
|
||||
W.equipped(src, slot)
|
||||
update_inv_r_hand(redraw_mob)
|
||||
if(slot_in_backpack)
|
||||
W.loc = src.back
|
||||
else
|
||||
usr << "\red You are trying to eqip this item to an unsupported inventory slot. How the heck did you manage that? Stop it..."
|
||||
return
|
||||
|
||||
W.layer = 20
|
||||
|
||||
return
|
||||
+60
-42
@@ -29,22 +29,6 @@
|
||||
/atom/proc/relaymove()
|
||||
return
|
||||
|
||||
/obj/effect/equip_e/process()
|
||||
return
|
||||
|
||||
/obj/effect/equip_e/proc/done()
|
||||
return
|
||||
|
||||
/obj/effect/equip_e/New()
|
||||
if (!ticker)
|
||||
del(src)
|
||||
return
|
||||
spawn(100)
|
||||
del(src)
|
||||
return
|
||||
..()
|
||||
return
|
||||
|
||||
/mob/proc/show_message(msg, type, alt, alt_type)//Message, type of message (1 or 2), alternative message, alt message type (1 or 2)
|
||||
if(!client) return
|
||||
if (type)
|
||||
@@ -111,35 +95,69 @@
|
||||
return 1
|
||||
return
|
||||
|
||||
//Used by monkeys, *chimpers* //TODO: eliminate this convoluted proc it's incredibly shitty. ~Carn
|
||||
/mob/proc/db_click(text, t1)
|
||||
//This proc is called whenever someone clicks an inventory ui slot.
|
||||
/mob/proc/attack_ui(slot)
|
||||
var/obj/item/W = get_active_hand()
|
||||
if(W)
|
||||
if(!istype(W)) return
|
||||
switch(text)
|
||||
if("mask")
|
||||
if(wear_mask)
|
||||
return
|
||||
if( !(W.slot_flags & SLOT_MASK) )
|
||||
return
|
||||
u_equip(W)
|
||||
wear_mask = W
|
||||
W.equipped(src, text)
|
||||
update_inv_wear_mask()
|
||||
if("back")
|
||||
if(back)
|
||||
return
|
||||
if( !(W.slot_flags & SLOT_BACK) )
|
||||
return
|
||||
if( istype(W,/obj/item/weapon/twohanded) && W:wielded ) //TODO: Carn
|
||||
usr << "<span class='warning'>Unwield the [initial(W.name)] first!</span>"
|
||||
return
|
||||
u_equip(W)
|
||||
back = W
|
||||
W.equipped(src, text)
|
||||
update_inv_back()
|
||||
|
||||
if(istype(W))
|
||||
equip_to_slot_if_possible(W, slot)
|
||||
|
||||
//This is a SAFE proc. Use this instead of equip_to_splot()!
|
||||
//set del_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 as obj, slot, del_on_fail = 0, disable_warning = 0, redraw_mob = 1)
|
||||
if(!istype(W)) return 0
|
||||
|
||||
if(!W.mob_can_equip(src, slot, disable_warning))
|
||||
if(del_on_fail)
|
||||
del(W)
|
||||
else
|
||||
if(!disable_warning)
|
||||
src << "\red You are unable to equip that." //Only print if del_on_fail is false
|
||||
return 0
|
||||
|
||||
equip_to_slot(W, slot, redraw_mob) //This proc should not ever fail.
|
||||
return 1
|
||||
|
||||
//This is an UNSAFE proc. It merely handles the actual job of equipping. All the checks on whether you can or can't eqip need to be done before! Use mob_can_equip() for that task.
|
||||
//In most cases you will want to use equip_to_slot_if_possible()
|
||||
/mob/proc/equip_to_slot(obj/item/W as obj, slot)
|
||||
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.
|
||||
/mob/proc/equip_to_slot_or_del(obj/item/W as obj, 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)
|
||||
if(equip_to_slot_if_possible(W, slot, 0, 1, 1)) //del_on_fail = 0; disable_warning = 0; redraw_mob = 1
|
||||
return 1
|
||||
|
||||
return 0
|
||||
|
||||
/mob/proc/reset_view(atom/A)
|
||||
if (client)
|
||||
if (istype(A, /atom/movable))
|
||||
|
||||
@@ -108,8 +108,8 @@ Put (mob/proc)s here that are in dire need of a code cleanup.
|
||||
Cl = H.wear_suit
|
||||
passed = prob(Cl.permeability_coefficient*100*virus.permeability_mod)
|
||||
// world << "Suit pass [passed]"
|
||||
if(passed && isobj(H.slot_w_uniform))
|
||||
Cl = H.slot_w_uniform
|
||||
if(passed && isobj(slot_w_uniform))
|
||||
Cl = slot_w_uniform
|
||||
passed = prob(Cl.permeability_coefficient*100*virus.permeability_mod)
|
||||
// world << "Uniform pass [passed]"
|
||||
if(3)
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
unacidable = 1
|
||||
var/id = 0.0
|
||||
var/obj/master
|
||||
var/slot_id
|
||||
|
||||
/obj/screen/close
|
||||
name = "close"
|
||||
@@ -537,12 +538,12 @@
|
||||
DblClick()
|
||||
return
|
||||
|
||||
/obj/screen/attack_hand(mob/user as mob, using)
|
||||
user.db_click(name, using)
|
||||
/obj/screen/attack_hand(mob/user as mob)
|
||||
user.attack_ui(slot_id)
|
||||
return
|
||||
|
||||
/obj/screen/attack_paw(mob/user as mob, using)
|
||||
user.db_click(name, using)
|
||||
/obj/screen/attack_paw(mob/user as mob)
|
||||
user.attack_ui(slot_id)
|
||||
return
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user