Merge pull request #8684 from mwerezak/inventoryfix

Fixes bad layer on dropped items
This commit is contained in:
Zuhayr
2015-03-31 17:30:04 +10:30
47 changed files with 224 additions and 449 deletions
+8 -7
View File
@@ -379,7 +379,8 @@
if(!usr.stat && isturf(usr.loc) && !usr.restrained())
usr:toggle_throw_mode()
if("drop")
usr.drop_item_v()
if(usr.client)
usr.client.drop_item()
if("module")
if(isrobot(usr))
@@ -429,7 +430,7 @@
if("Allow Walking")
if(gun_click_time > world.time - 30) //give them 3 seconds between mode changes.
return
if(!istype(usr.equipped(),/obj/item/weapon/gun))
if(!istype(usr.get_active_hand(),/obj/item/weapon/gun))
usr << "You need your gun in your active hand to do that!"
return
usr.client.AllowTargetMove()
@@ -438,7 +439,7 @@
if("Disallow Walking")
if(gun_click_time > world.time - 30) //give them 3 seconds between mode changes.
return
if(!istype(usr.equipped(),/obj/item/weapon/gun))
if(!istype(usr.get_active_hand(),/obj/item/weapon/gun))
usr << "You need your gun in your active hand to do that!"
return
usr.client.AllowTargetMove()
@@ -447,7 +448,7 @@
if("Allow Running")
if(gun_click_time > world.time - 30) //give them 3 seconds between mode changes.
return
if(!istype(usr.equipped(),/obj/item/weapon/gun))
if(!istype(usr.get_active_hand(),/obj/item/weapon/gun))
usr << "You need your gun in your active hand to do that!"
return
usr.client.AllowTargetRun()
@@ -456,7 +457,7 @@
if("Disallow Running")
if(gun_click_time > world.time - 30) //give them 3 seconds between mode changes.
return
if(!istype(usr.equipped(),/obj/item/weapon/gun))
if(!istype(usr.get_active_hand(),/obj/item/weapon/gun))
usr << "You need your gun in your active hand to do that!"
return
usr.client.AllowTargetRun()
@@ -465,7 +466,7 @@
if("Allow Item Use")
if(gun_click_time > world.time - 30) //give them 3 seconds between mode changes.
return
if(!istype(usr.equipped(),/obj/item/weapon/gun))
if(!istype(usr.get_active_hand(),/obj/item/weapon/gun))
usr << "You need your gun in your active hand to do that!"
return
usr.client.AllowTargetClick()
@@ -475,7 +476,7 @@
if("Disallow Item Use")
if(gun_click_time > world.time - 30) //give them 3 seconds between mode changes.
return
if(!istype(usr.equipped(),/obj/item/weapon/gun))
if(!istype(usr.get_active_hand(),/obj/item/weapon/gun))
usr << "You need your gun in your active hand to do that!"
return
usr.client.AllowTargetClick()
@@ -388,13 +388,7 @@ var/global/list/possible_changeling_IDs = list("Alpha","Beta","Gamma","Delta","E
del(animation)
for(var/obj/item/W in src)
C.u_equip(W)
if (C.client)
C.client.screen -= W
if (W)
W.loc = C.loc
W.dropped(C)
W.layer = initial(W.layer)
C.drop_from_inventory(W)
var/mob/living/carbon/human/O = new /mob/living/carbon/human( src )
if (C.dna.GetUIState(DNA_UI_GENDER))
+1 -1
View File
@@ -796,7 +796,7 @@ var/list/sacrificed = list()
if (cultist.legcuffed)
cultist.drop_from_inventory(cultist.legcuffed)
if (istype(cultist.wear_mask, /obj/item/clothing/mask/muzzle))
cultist.u_equip(cultist.wear_mask)
cultist.drop_from_inventory(cultist.wear_mask)
if(istype(cultist.loc, /obj/structure/closet)&&cultist.loc:welded)
cultist.loc:welded = 0
if(istype(cultist.loc, /obj/structure/closet/secure_closet)&&cultist.loc:locked)
+3 -2
View File
@@ -52,7 +52,7 @@
if(beaker)
user << "<span class='notice'>]The [src] is already loaded.</span>"
else
user.before_take_item(O)
user.remove_from_mob(O)
O.loc = src
beaker = O
updateUsrDialog()
@@ -74,6 +74,7 @@
if(i < 10)
user << "<span class='notice'>You empty \the [O] into \the [src].</span>"
else if(!istype(O, /obj/item/weapon/reagent_containers/food/snacks/grown))
user << "<span class='notice'>You cannot put this in \the [src].</span>"
else
@@ -83,7 +84,7 @@
if(i >= 10)
user << "<span class='notice'>\The [src] is full! Activate it.</span>"
else
user.before_take_item(O)
user.remove_from_mob(O)
O.loc = src
user << "<span class='notice'>You put \the [O] in \the [src]</span>"
update_icon()
+5 -5
View File
@@ -542,7 +542,7 @@
A.loc = src.loc
user << "You add the robot arm to the [src]"
src.loc = A //Place the water tank into the assembly, it will be needed for the finished bot
user.u_equip(S)
user.remove_from_mob(S)
del(S)
/obj/item/weapon/farmbot_arm_assembly/attackby(obj/item/weapon/W as obj, mob/user as mob)
@@ -551,21 +551,21 @@
src.build_step++
user << "You add the plant analyzer to [src]!"
src.name = "farmbot assembly"
user.u_equip(W)
user.remove_from_mob(W)
del(W)
else if(( istype(W, /obj/item/weapon/reagent_containers/glass/bucket)) && (src.build_step == 1))
src.build_step++
user << "You add a bucket to [src]!"
src.name = "farmbot assembly with bucket"
user.u_equip(W)
user.remove_from_mob(W)
del(W)
else if(( istype(W, /obj/item/weapon/minihoe)) && (src.build_step == 2))
src.build_step++
user << "You add a minihoe to [src]!"
src.name = "farmbot assembly with bucket and minihoe"
user.u_equip(W)
user.remove_from_mob(W)
del(W)
else if((isprox(W)) && (src.build_step == 3))
@@ -577,7 +577,7 @@
S.tank = wTank
S.loc = get_turf(src)
S.name = src.created_name
user.u_equip(W)
user.remove_from_mob(W)
del(W)
del(src)
@@ -154,7 +154,7 @@
if(isobj(obj))
var/mob/M = obj.loc
if(ismob(M))
M.u_equip(obj)
M.remove_from_mob(obj)
M.update_icons() //so their overlays update
if(!silent)
+1 -1
View File
@@ -112,7 +112,7 @@
"\blue [user] has added one of [O] to \the [src].", \
"\blue You add one of [O] to \the [src].")
else
// user.before_take_item(O) //This just causes problems so far as I can tell. -Pete
// user.remove_from_mob(O) //This just causes problems so far as I can tell. -Pete
user.drop_item()
O.loc = src
user.visible_message( \
+1 -1
View File
@@ -197,7 +197,7 @@
user << "<span class='notice'>\The [src] is full.</span>"
return 1
else
user.before_take_item(O)
user.remove_from_mob(O)
O.loc = src
if(item_quants[O.name])
item_quants[O.name]++
+1 -1
View File
@@ -21,7 +21,7 @@
if (contents.len >= max_butts)
user << "This ashtray is full."
return
user.u_equip(W)
user.remove_from_mob(W)
W.loc = src
if (istype(W,/obj/item/clothing/mask/smokable/cigarette))
+1 -1
View File
@@ -132,7 +132,7 @@
B.loc = get_turf(src)
user << "<span class='notice'>You armed the robot frame.</span>"
if (user.get_inactive_hand()==src)
user.before_take_item(src)
user.remove_from_mob(src)
user.put_in_inactive_hand(B)
del(src)
else
+1 -1
View File
@@ -186,7 +186,7 @@
spawn(0) //delete the empty stack once the current context yields
if (amount <= 0) //check again in case someone transferred stuff to us
if(usr)
usr.before_take_item(src)
usr.remove_from_mob(src)
del(src)
return 1
else
@@ -157,7 +157,7 @@ CIGARETTE PACKETS ARE IN FANCY.DM
var/mob/living/M = loc
if (!nomessage)
M << "<span class='notice'>Your [name] goes out.</span>"
M.u_equip(src) //un-equip it so the overlays can update
M.remove_from_mob(src) //un-equip it so the overlays can update
M.update_inv_wear_mask(0)
M.update_inv_l_hand(0)
M.update_inv_r_hand(1)
@@ -109,7 +109,7 @@
if(!ispath(gift_type,/obj/item)) return
var/obj/item/I = new gift_type(M)
M.u_equip(src)
M.remove_from_mob(src)
M.put_in_hands(I)
I.add_fingerprint(M)
del(src)
@@ -123,7 +123,7 @@
c.scanned = A
if(istype(A.loc,/mob/living/carbon/human))
var/mob/living/carbon/human/H = A.loc
H.u_equip(A)
H.remove_from_mob(A)
else if(istype(A.loc,/obj/item/weapon/storage))
var/obj/item/weapon/storage/S = A.loc
S.remove_from_storage(A)
@@ -156,7 +156,7 @@
break
if(!inserted || !S.amount)
usr.u_equip(S)
usr.remove_from_mob(S)
usr.update_icons() //update our overlays
if (usr.client && usr.s_active != src)
usr.client.screen -= S
@@ -247,7 +247,7 @@
/obj/item/weapon/storage/proc/handle_item_insertion(obj/item/W as obj, prevent_warning = 0)
if(!istype(W)) return 0
if(usr)
usr.u_equip(W)
usr.remove_from_mob(W)
usr.update_icons() //update our overlays
W.loc = src
W.on_enter_storage(src)
@@ -463,4 +463,4 @@
return depth
/obj/item/proc/get_storage_cost()
return 2**(w_class-1) //1,2,4,8,16,...
return 2**(w_class-1) //1,2,4,8,16,...
@@ -103,7 +103,7 @@
if ((!F.status)||(F.ptank)) return
src.master = F
F.ptank = src
user.before_take_item(src)
user.remove_from_mob(src)
src.loc = F
return
+3 -3
View File
@@ -190,12 +190,12 @@
if (user.client)
user.client.screen -= src
if (user.r_hand == src)
user.u_equip(src)
user.remove_from_mob(src)
else
user.u_equip(src)
user.remove_from_mob(src)
src.master = F
src.layer = initial(src.layer)
user.u_equip(src)
user.remove_from_mob(src)
if (user.client)
user.client.screen -= src
src.loc = F
+1 -1
View File
@@ -17,7 +17,7 @@
return
if(istype(O, /obj/item/weapon/extinguisher))
if(!has_extinguisher && opened)
user.drop_item(O)
user.remove_from_mob(O)
contents += O
has_extinguisher = O
user << "<span class='notice'>You place [O] in [src].</span>"
@@ -10,7 +10,7 @@
/obj/item/weapon/stool/attack(mob/M as mob, mob/user as mob)
if (prob(5) && istype(M,/mob/living))
user.visible_message("\red [user] breaks [src] over [M]'s back!")
user.u_equip(src)
user.remove_from_mob(src)
var/obj/item/stack/sheet/metal/m = new/obj/item/stack/sheet/metal
m.loc = get_turf(src)
del src
@@ -43,5 +43,5 @@
if(istype(W, /obj/item/weapon/wrench))
playsound(src.loc, 'sound/items/Ratchet.ogg', 50, 1)
new /obj/item/stack/sheet/metal(src.loc)
del(src)
del(src)
..()
+1 -1
View File
@@ -26,7 +26,7 @@
if(istype(W, /obj/item/target))
density = 0
W.density = 1
user.drop_item(src)
user.remove_from_mob(W)
W.loc = loc
W.layer = 3.1
pinned_target = W
+1 -1
View File
@@ -456,7 +456,7 @@ turf/simulated/floor/proc/update_icon()
if(istype(C,/obj/item/weapon/light/bulb)) //only for light tiles
if(is_light_floor())
if(get_lightfloor_state())
user.drop_item(C)
user.remove_from_mob(C)
del(C)
set_lightfloor_state(0) //fixing it by bashing it with a light bulb, fun eh?
update_icon()
+5 -27
View File
@@ -968,11 +968,7 @@
//strip their stuff and stick it in the crate
for(var/obj/item/I in M)
M.u_equip(I)
if(I)
I.loc = locker
I.layer = initial(I.layer)
I.dropped(M)
M.drop_from_inventory(I, locker)
M.update_icons()
//so they black out before warping
@@ -1005,11 +1001,7 @@
return
for(var/obj/item/I in M)
M.u_equip(I)
if(I)
I.loc = M.loc
I.layer = initial(I.layer)
I.dropped(M)
M.drop_from_inventory(I)
M.Paralyse(5)
sleep(5)
@@ -1034,11 +1026,7 @@
return
for(var/obj/item/I in M)
M.u_equip(I)
if(I)
I.loc = M.loc
I.layer = initial(I.layer)
I.dropped(M)
M.drop_from_inventory(I)
M.Paralyse(5)
sleep(5)
@@ -1085,11 +1073,7 @@
return
for(var/obj/item/I in M)
M.u_equip(I)
if(I)
I.loc = M.loc
I.layer = initial(I.layer)
I.dropped(M)
M.drop_from_inventory(I)
if(istype(M, /mob/living/carbon/human))
var/mob/living/carbon/human/observer = M
@@ -1838,13 +1822,7 @@
if(istype(W, /obj/item/organ/external))
continue
//don't strip organs
H.u_equip(W)
if (H.client)
H.client.screen -= W
if (W)
W.loc = H.loc
W.dropped(H)
W.layer = initial(W.layer)
H.drop_from_inventory(W)
//teleport person to cell
H.loc = pick(prisonwarp)
H.equip_to_slot_or_del(new /obj/item/clothing/under/color/orange(H), slot_w_uniform)
+26 -26
View File
@@ -735,19 +735,19 @@ But you can call procs that are of type /mob/living/carbon/human/proc/ for that
commandos.equip(M)
if("nanotrasen representative")
M.equip_if_possible(new /obj/item/clothing/under/rank/centcom(M), slot_w_uniform)
M.equip_if_possible(new /obj/item/clothing/shoes/laceup(M), slot_shoes)
M.equip_if_possible(new /obj/item/clothing/gloves/white(M), slot_gloves)
M.equip_if_possible(new /obj/item/device/radio/headset/heads/hop(M), slot_l_ear)
M.equip_to_slot_or_del(new /obj/item/clothing/under/rank/centcom(M), slot_w_uniform)
M.equip_to_slot_or_del(new /obj/item/clothing/shoes/laceup(M), slot_shoes)
M.equip_to_slot_or_del(new /obj/item/clothing/gloves/white(M), slot_gloves)
M.equip_to_slot_or_del(new /obj/item/device/radio/headset/heads/hop(M), slot_l_ear)
var/obj/item/device/pda/heads/pda = new(M)
pda.owner = M.real_name
pda.ownjob = "NanoTrasen Navy Representative"
pda.name = "PDA-[M.real_name] ([pda.ownjob])"
M.equip_if_possible(pda, slot_r_store)
M.equip_if_possible(new /obj/item/clothing/glasses/sunglasses(M), slot_l_store)
M.equip_if_possible(new /obj/item/weapon/clipboard(M), slot_belt)
M.equip_to_slot_or_del(pda, slot_r_store)
M.equip_to_slot_or_del(new /obj/item/clothing/glasses/sunglasses(M), slot_l_store)
M.equip_to_slot_or_del(new /obj/item/weapon/clipboard(M), slot_belt)
var/obj/item/weapon/card/id/W = new(M)
W.name = "[M.real_name]'s ID Card"
@@ -757,23 +757,23 @@ But you can call procs that are of type /mob/living/carbon/human/proc/ for that
W.access += list("VIP Guest","Custodian","Thunderdome Overseer","Intel Officer","Medical Officer","Death Commando","Research Officer")
W.assignment = "NanoTrasen Navy Representative"
W.registered_name = M.real_name
M.equip_if_possible(W, slot_wear_id)
M.equip_to_slot_or_del(W, slot_wear_id)
if("nanotrasen officer")
M.equip_if_possible(new /obj/item/clothing/under/rank/centcom_officer(M), slot_w_uniform)
M.equip_if_possible(new /obj/item/clothing/shoes/laceup(M), slot_shoes)
M.equip_if_possible(new /obj/item/clothing/gloves/white(M), slot_gloves)
M.equip_if_possible(new /obj/item/device/radio/headset/heads/captain(M), slot_l_ear)
M.equip_if_possible(new /obj/item/clothing/head/beret/centcom/officer(M), slot_head)
M.equip_to_slot_or_del(new /obj/item/clothing/under/rank/centcom_officer(M), slot_w_uniform)
M.equip_to_slot_or_del(new /obj/item/clothing/shoes/laceup(M), slot_shoes)
M.equip_to_slot_or_del(new /obj/item/clothing/gloves/white(M), slot_gloves)
M.equip_to_slot_or_del(new /obj/item/device/radio/headset/heads/captain(M), slot_l_ear)
M.equip_to_slot_or_del(new /obj/item/clothing/head/beret/centcom/officer(M), slot_head)
var/obj/item/device/pda/heads/pda = new(M)
pda.owner = M.real_name
pda.ownjob = "NanoTrasen Navy Officer"
pda.name = "PDA-[M.real_name] ([pda.ownjob])"
M.equip_if_possible(pda, slot_r_store)
M.equip_if_possible(new /obj/item/clothing/glasses/sunglasses(M), slot_l_store)
M.equip_if_possible(new /obj/item/weapon/gun/energy(M), slot_belt)
M.equip_to_slot_or_del(pda, slot_r_store)
M.equip_to_slot_or_del(new /obj/item/clothing/glasses/sunglasses(M), slot_l_store)
M.equip_to_slot_or_del(new /obj/item/weapon/gun/energy(M), slot_belt)
var/obj/item/weapon/card/id/centcom/W = new(M)
W.name = "[M.real_name]'s ID Card"
@@ -781,24 +781,24 @@ But you can call procs that are of type /mob/living/carbon/human/proc/ for that
W.access += get_all_centcom_access()
W.assignment = "NanoTrasen Navy Officer"
W.registered_name = M.real_name
M.equip_if_possible(W, slot_wear_id)
M.equip_to_slot_or_del(W, slot_wear_id)
if("nanotrasen captain")
M.equip_if_possible(new /obj/item/clothing/under/rank/centcom_captain(M), slot_w_uniform)
M.equip_if_possible(new /obj/item/clothing/shoes/laceup(M), slot_shoes)
M.equip_if_possible(new /obj/item/clothing/gloves/white(M), slot_gloves)
M.equip_if_possible(new /obj/item/device/radio/headset/heads/captain(M), slot_l_ear)
M.equip_if_possible(new /obj/item/clothing/head/beret/centcom/captain(M), slot_head)
M.equip_to_slot_or_del(new /obj/item/clothing/under/rank/centcom_captain(M), slot_w_uniform)
M.equip_to_slot_or_del(new /obj/item/clothing/shoes/laceup(M), slot_shoes)
M.equip_to_slot_or_del(new /obj/item/clothing/gloves/white(M), slot_gloves)
M.equip_to_slot_or_del(new /obj/item/device/radio/headset/heads/captain(M), slot_l_ear)
M.equip_to_slot_or_del(new /obj/item/clothing/head/beret/centcom/captain(M), slot_head)
var/obj/item/device/pda/heads/pda = new(M)
pda.owner = M.real_name
pda.ownjob = "NanoTrasen Navy Captain"
pda.name = "PDA-[M.real_name] ([pda.ownjob])"
M.equip_if_possible(pda, slot_r_store)
M.equip_if_possible(new /obj/item/clothing/glasses/sunglasses(M), slot_l_store)
M.equip_if_possible(new /obj/item/weapon/gun/energy(M), slot_belt)
M.equip_to_slot_or_del(pda, slot_r_store)
M.equip_to_slot_or_del(new /obj/item/clothing/glasses/sunglasses(M), slot_l_store)
M.equip_to_slot_or_del(new /obj/item/weapon/gun/energy(M), slot_belt)
var/obj/item/weapon/card/id/centcom/W = new(M)
W.name = "[M.real_name]'s ID Card"
@@ -806,7 +806,7 @@ But you can call procs that are of type /mob/living/carbon/human/proc/ for that
W.access += get_all_centcom_access()
W.assignment = "NanoTrasen Navy Captain"
W.registered_name = M.real_name
M.equip_if_possible(W, slot_wear_id)
M.equip_to_slot_or_del(W, slot_wear_id)
if("emergency response team")
M.equip_to_slot_or_del(new /obj/item/clothing/under/rank/centcom_officer(M), slot_w_uniform)
+4 -4
View File
@@ -60,7 +60,7 @@
//replace old ID
del(C)
ok = M.equip_if_possible(I, slot_wear_id, 0) //if 1, last argument deletes on fail
ok = M.equip_to_slot_if_possible(I, slot_wear_id, 0) //if 1, last argument deletes on fail
break
else if(istype(Item,/obj/item/weapon/storage/belt))
if(M.ckey == "jakksergal" && M.real_name == "Nashi Ra'hal" && M.mind.role_alt_title && M.mind.role_alt_title != "Nurse" && M.mind.role_alt_title != "Chemist")
@@ -72,13 +72,13 @@
for(var/obj/item/weapon/storage/belt/B in M)
del(B)
M.belt=null
ok = M.equip_if_possible(I, slot_belt, 0)
ok = M.equip_to_slot_if_possible(I, slot_belt, 0)
break
if(istype(M.belt,/obj/item/device/pda))
for(var/obj/item/device/pda/Pda in M)
M.belt=null
M.equip_if_possible(Pda, slot_l_store, 0)
ok = M.equip_if_possible(I, slot_belt, 0)
M.equip_to_slot_if_possible(Pda, slot_l_store, 0)
ok = M.equip_to_slot_if_possible(I, slot_belt, 0)
else if(istype(M.back,/obj/item/weapon/storage) && M.back:contents.len < M.back:storage_slots) // Try to place it in something on the mob's back
Item.loc = M.back
ok = 1
+2 -2
View File
@@ -251,7 +251,7 @@ var/global/list/holodeck_programs = list(
if(isobj(obj))
var/mob/M = obj.loc
if(ismob(M))
M.u_equip(obj)
M.remove_from_mob(obj)
M.update_icons() //so their overlays update
if(!silent)
@@ -384,4 +384,4 @@ var/global/list/holodeck_programs = list(
var/area/targetsource = locate(/area/holodeck/source_plating)
targetsource.copy_contents_to(linkedholodeck , 1)
active = 0
use_power = 1
use_power = 1
+2 -2
View File
@@ -88,7 +88,7 @@
if(S.seed && S.seed.get_trait(TRAIT_IMMUTABLE) > 0)
user << "That seed is not compatible with our genetics technology."
else
user.drop_item(W)
user.remove_from_mob(W)
W.loc = src
seed = W
user << "You load [W] into [src]."
@@ -120,7 +120,7 @@
user << "That disk does not have any gene data loaded."
return
user.drop_item(W)
user.remove_from_mob(W)
W.loc = src
loaded_disk = W
user << "You load [W] into [src]."
+2 -2
View File
@@ -453,7 +453,7 @@
if(!seed)
var/obj/item/seeds/S = O
user.drop_item(O)
user.remove_from_mob(O)
if(!S.seed)
user << "The packet seems to be empty. You throw it away."
@@ -497,7 +497,7 @@
else if ( istype(O, /obj/item/weapon/plantspray) )
var/obj/item/weapon/plantspray/spray = O
user.drop_item(O)
user.remove_from_mob(O)
toxins += spray.toxicity
pestlevel -= spray.pest_kill_str
weedlevel -= spray.weed_kill_str
+1 -1
View File
@@ -12,7 +12,7 @@
/obj/structure/ore_box/attackby(obj/item/weapon/W as obj, mob/user as mob)
if (istype(W, /obj/item/weapon/ore))
user.u_equip(W)
user.remove_from_mob(W)
src.contents += W
if (istype(W, /obj/item/weapon/storage))
var/obj/item/weapon/storage/S = W
+97 -191
View File
@@ -1,15 +1,81 @@
//This proc is called whenever someone clicks an inventory ui slot.
/mob/proc/attack_ui(slot)
var/obj/item/W = get_active_hand()
if(istype(W))
equip_to_slot_if_possible(W, slot)
/mob/proc/put_in_any_hand_if_possible(obj/item/W as obj, del_on_fail = 0, disable_warning = 1, redraw_mob = 1)
if(equip_to_slot_if_possible(W, slot_l_hand, del_on_fail, disable_warning, redraw_mob))
return 1
else if(equip_to_slot_if_possible(W, slot_r_hand, del_on_fail, disable_warning, redraw_mob))
return 1
return 0
//This is a SAFE proc. Use this instead of equip_to_slot()!
//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))
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)
return 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_l_ear,\
slot_r_ear,\
slot_glasses,\
slot_belt,\
slot_s_store,\
slot_tie,\
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, del_on_fail=0, disable_warning=1, redraw_mob=1))
return 1
return 0
//These procs handle putting s tuff in your hand. It's probably best to use these rather than setting l_hand = ...etc
//as they handle all relevant stuff like adding it to the player's screen and updating their overlays.
//Returns the thing in our active hand
/mob/proc/get_active_hand()
if(issilicon(src))
if(isrobot(src))
if(src:module_active)
return src:module_active
else
if(hand) return l_hand
else return r_hand
if(hand) return l_hand
else return r_hand
//Returns the thing in our inactive hand
/mob/proc/get_inactive_hand()
@@ -77,96 +143,45 @@
W.dropped()
return 0
/mob/proc/drop_item_v() //this is dumb.
if(stat == CONSCIOUS && isturf(loc))
return drop_item()
return 0
// Removes an item from inventory and places it in the target atom
/mob/proc/drop_from_inventory(var/obj/item/W, var/atom/Target = null)
if(W)
if(!Target)
Target = loc
if(client) client.screen -= W
u_equip(W)
remove_from_mob(W)
if(!W) return 1 // self destroying objects (tk, grabs)
W.layer = initial(W.layer)
W.loc = Target
var/turf/T = get_turf(Target)
if(isturf(T))
T.Entered(W)
W.dropped(src)
W.forceMove(Target)
update_icons()
return 1
return 0
//Drops the item in our left hand
/mob/proc/drop_l_hand(var/atom/Target)
if(l_hand)
if(client) client.screen -= l_hand
l_hand.layer = initial(l_hand.layer)
if(Target) l_hand.loc = Target.loc
else l_hand.loc = loc
var/turf/T = get_turf(loc)
if(isturf(T))
T.Entered(l_hand)
l_hand.dropped(src)
l_hand = null
update_inv_l_hand()
return 1
return 0
return drop_from_inventory(l_hand, Target)
//Drops the item in our right hand
/mob/proc/drop_r_hand(var/atom/Target)
if(r_hand)
if(client) client.screen -= r_hand
r_hand.layer = initial(r_hand.layer)
if(Target) r_hand.loc = Target.loc
else r_hand.loc = loc
var/turf/T = get_turf(Target)
if(istype(T))
T.Entered(r_hand)
r_hand.dropped(src)
r_hand = null
update_inv_r_hand()
return 1
return 0
return drop_from_inventory(r_hand, Target)
//Drops the item in our active hand.
/mob/proc/drop_item(var/atom/Target)
if(hand) return drop_l_hand(Target)
else return drop_r_hand(Target)
//TODO: phase out this proc
/mob/proc/before_take_item(var/obj/item/W) //TODO: what is this?
W.loc = null
W.layer = initial(W.layer)
u_equip(W)
update_icons()
return
/mob/proc/u_equip(W as obj)
/*
Removes the object from any slots the mob might have, calling the appropriate icon update proc.
Does nothing else.
DO NOT CALL THIS PROC DIRECTLY. It is meant to be called only by other inventory procs.
It's probably okay to use it if you are transferring the item between slots on the same mob,
but chances are you're safer calling remove_from_mob() or drop_from_inventory() anyways.
As far as I can tell the proc exists so that mobs with different inventory slots can override
the search through all the slots, without having to duplicate the rest of the item dropping.
*/
/mob/proc/u_equip(obj/W as obj)
if (W == r_hand)
r_hand = null
update_inv_r_hand(0)
@@ -181,40 +196,27 @@
update_inv_wear_mask(0)
return
//This differs from remove_from_mob() in that it checks canremove first.
/mob/proc/unEquip(obj/item/I, force = 0) //Force overrides NODROP for things like wizarditis and admin undress.
if(!I) //If there's nothing to drop, the drop is automatically successful. If(unEquip) should generally be used to check for NODROP.
if(!I) //If there's nothing to drop, the drop is automatically successful.
return 1
/*if((I.flags & NODROP) && !force)
return 0*/
if(!I.canremove && !force)
return 0
if(I == r_hand)
r_hand = null
update_inv_r_hand()
else if(I == l_hand)
l_hand = null
update_inv_l_hand()
if(I)
if(client)
client.screen -= I
I.loc = loc
I.dropped(src)
if(I)
I.layer = initial(I.layer)
remove_from_mob(I)
return 1
//Attemps to remove an object on a mob. Will not move it to another area or such, just removes from the mob.
//It does call u_equip() though. So it can drop items to the floor but only if src is human.
/mob/proc/remove_from_mob(var/obj/O)
src.u_equip(O)
if (src.client)
src.client.screen -= O
O.layer = initial(O.layer)
O.screen_loc = null
if(istype(O, /obj/item))
var/obj/item/I = O
I.dropped()
return 1
@@ -240,99 +242,3 @@
//if(hasvar(src,"r_hand")) if(src:r_hand) items += src:r_hand
return items
/** BS12's proc to get the item in the active hand. Couldn't find the /tg/ equivalent. **/
/mob/proc/equipped()
return get_active_hand() //TODO: get rid of this proc
/mob/living/carbon/human/proc/equip_if_possible(obj/item/W, slot, del_on_fail = 1) // since byond doesn't seem to have pointers, this seems like the best way to do this :/
//warning: icky code
var/equipped = 0
switch(slot)
if(slot_back)
if(!src.back)
src.back = W
equipped = 1
if(slot_wear_mask)
if(!src.wear_mask)
src.wear_mask = W
equipped = 1
if(slot_handcuffed)
if(!src.handcuffed)
src.handcuffed = W
equipped = 1
if(slot_l_hand)
if(!src.l_hand)
src.l_hand = W
equipped = 1
if(slot_r_hand)
if(!src.r_hand)
src.r_hand = W
equipped = 1
if(slot_belt)
if(!src.belt && src.w_uniform)
src.belt = W
equipped = 1
if(slot_wear_id)
if(!src.wear_id && src.w_uniform)
src.wear_id = W
equipped = 1
if(slot_l_ear)
if(!src.l_ear)
src.l_ear = W
equipped = 1
if(slot_r_ear)
if(!src.r_ear)
src.r_ear = W
equipped = 1
if(slot_glasses)
if(!src.glasses)
src.glasses = W
equipped = 1
if(slot_gloves)
if(!src.gloves)
src.gloves = W
equipped = 1
if(slot_head)
if(!src.head)
src.head = W
equipped = 1
if(slot_shoes)
if(!src.shoes)
src.shoes = W
equipped = 1
if(slot_wear_suit)
if(!src.wear_suit)
src.wear_suit = W
equipped = 1
if(slot_w_uniform)
if(!src.w_uniform)
src.w_uniform = W
equipped = 1
if(slot_l_store)
if(!src.l_store && src.w_uniform)
src.l_store = W
equipped = 1
if(slot_r_store)
if(!src.r_store && src.w_uniform)
src.r_store = W
equipped = 1
if(slot_s_store)
if(!src.s_store && src.wear_suit)
src.s_store = W
equipped = 1
if(slot_in_backpack)
if (src.back && istype(src.back, /obj/item/weapon/storage/backpack))
var/obj/item/weapon/storage/backpack/B = src.back
if(B.contents.len < B.storage_slots && W.w_class <= B.max_w_class)
W.loc = B
equipped = 1
if(equipped)
W.layer = 20
if(src.back && W.loc != src.back)
W.loc = src
else
if (del_on_fail)
del(W)
return equipped
+3 -10
View File
@@ -328,16 +328,9 @@
if(!item) return //Grab processing has a chance of returning null
item.layer = initial(item.layer)
u_equip(item)
update_icons()
if (istype(usr, /mob/living/carbon)) //Check if a carbon mob is throwing. Modify/remove this line as required.
item.loc = src.loc
if(src.client)
src.client.screen -= item
if(istype(item, /obj/item))
item:dropped(src) // let it know it's been dropped
src.remove_from_mob(item)
item.loc = src.loc
//actually throw it!
if (item)
@@ -70,7 +70,7 @@ emp_act
if(c_hand && (stun_amount || agony_amount > 10))
msg_admin_attack("[src.name] ([src.ckey]) was disarmed by a stun effect")
u_equip(c_hand)
drop_from_inventory(c_hand)
if (affected.status & ORGAN_ROBOT)
emote("me", 1, "drops what they were holding, their [affected.name] malfunctioning!")
else
@@ -104,9 +104,9 @@
if(E.is_broken())
if(E.body_part == HAND_LEFT)
u_equip(l_hand)
drop_from_inventory(l_hand)
else
u_equip(r_hand)
drop_from_inventory(r_hand)
var/emote_scream = pick("screams in pain and ", "lets out a sharp cry and ", "cries out and ")
emote("me", 1, "[(species.flags & NO_PAIN) ? "" : emote_scream ]drops what they were holding in their [E.name]!")
@@ -114,9 +114,9 @@
else if(E.is_malfunctioning())
if(E.body_part == HAND_LEFT)
u_equip(l_hand)
drop_from_inventory(l_hand)
else
u_equip(r_hand)
drop_from_inventory(r_hand)
emote("me", 1, "drops what they were holding, their [E.name] malfunctioning!")
@@ -69,11 +69,11 @@ This saves us from having to call add_fingerprint() any time something is put in
if(slot_glasses)
return has_organ("head")
if(slot_gloves)
return has_organ("l_hand") && has_organ("r_hand")
return has_organ("l_hand") || has_organ("r_hand")
if(slot_head)
return has_organ("head")
if(slot_shoes)
return has_organ("r_foot") && has_organ("l_foot")
return has_organ("r_foot") || has_organ("l_foot")
if(slot_wear_suit)
return has_organ("chest")
if(slot_w_uniform)
@@ -89,19 +89,13 @@ This saves us from having to call add_fingerprint() any time something is put in
if(slot_tie)
return 1
/mob/living/carbon/human/u_equip(obj/item/W as obj)
/mob/living/carbon/human/u_equip(obj/W as obj)
if(!W) return 0
var/success
if (W == wear_suit)
if(s_store)
drop_from_inventory(s_store)
if(W)
success = 1
wear_suit = null
if(W.flags_inv & HIDESHOES)
update_inv_shoes(0)
update_inv_wear_suit()
else if (W == w_uniform)
if (r_store)
@@ -113,43 +107,43 @@ This saves us from having to call add_fingerprint() any time something is put in
if (belt)
drop_from_inventory(belt)
w_uniform = null
success = 1
update_inv_w_uniform()
else if (W == gloves)
gloves = null
success = 1
update_inv_gloves()
else if (W == glasses)
glasses = null
success = 1
update_inv_glasses()
else if (W == head)
head = null
if((W.flags & BLOCKHAIR) || (W.flags & BLOCKHEADHAIR)|| (W.flags_inv & HIDEMASK))
var/update_hair = 0
if((W.flags & BLOCKHAIR) || (W.flags & BLOCKHEADHAIR))
update_hair = 1
else if(istype(W, /obj/item))
var/obj/item/I = W
if(I.flags_inv & HIDEMASK)
update_hair = 1
if(update_hair)
update_hair(0) //rebuild hair
update_inv_ears(0)
update_inv_wear_mask(0)
success = 1
update_inv_head()
else if (W == l_ear)
l_ear = null
success = 1
update_inv_ears()
else if (W == r_ear)
r_ear = null
success = 1
update_inv_ears()
else if (W == shoes)
shoes = null
success = 1
update_inv_shoes()
else if (W == belt)
belt = null
success = 1
update_inv_belt()
else if (W == wear_mask)
wear_mask = null
success = 1
if((W.flags & BLOCKHAIR) || (W.flags & BLOCKHEADHAIR))
update_hair(0) //rebuild hair
update_inv_ears(0)
@@ -160,53 +154,36 @@ This saves us from having to call add_fingerprint() any time something is put in
update_inv_wear_mask()
else if (W == wear_id)
wear_id = null
success = 1
update_inv_wear_id()
else if (W == r_store)
r_store = null
success = 1
update_inv_pockets()
else if (W == l_store)
l_store = null
success = 1
update_inv_pockets()
else if (W == s_store)
s_store = null
success = 1
update_inv_s_store()
else if (W == back)
back = null
success = 1
update_inv_back()
else if (W == handcuffed)
handcuffed = null
handcuffed = null
if(buckled && buckled.buckle_require_restraints)
buckled.unbuckle_mob()
success = 1
buckled.unbuckle_mob()
update_inv_handcuffed()
else if (W == legcuffed)
legcuffed = null
success = 1
update_inv_legcuffed()
else if (W == r_hand)
r_hand = null
success = 1
update_inv_r_hand()
else if (W == l_hand)
l_hand = null
success = 1
update_inv_l_hand()
else
return 0
if(success)
if (W)
if (client)
client.screen -= W
W.loc = loc
W.dropped(src)
//if(W)
//W.layer = initial(W.layer)
update_action_buttons()
return 1
@@ -319,7 +296,7 @@ This saves us from having to call add_fingerprint() any time something is put in
update_inv_s_store(redraw_mob)
if(slot_in_backpack)
if(src.get_active_hand() == W)
src.u_equip(W)
src.remove_from_mob(W)
W.loc = src.back
if(slot_tie)
var/obj/item/clothing/under/uniform = src.w_uniform
@@ -339,6 +316,10 @@ This saves us from having to call add_fingerprint() any time something is put in
return
/*
MouseDrop human inventory menu
*/
/obj/effect/equip_e
name = "equip e"
var/mob/source = null
@@ -771,15 +752,12 @@ It can still be worn/put on as normal.
W.add_fingerprint(source)
if(slot_to_process == slot_l_store) //pockets! Needs to process the other one too. Snowflake code, wooo! It's not like anyone will rewrite this anytime soon. If I'm wrong then... CONGRATULATIONS! ;)
if(target.r_store)
target.u_equip(target.r_store) //At this stage l_store is already processed by the code above, we only need to process r_store.
target.remove_from_mob(target.r_store) //At this stage l_store is already processed by the code above, we only need to process r_store.
else
if(item && target.has_organ_for_slot(slot_to_process)) //Placing an item on the mob
if(item.mob_can_equip(target, slot_to_process, 0))
source.u_equip(item)
source.remove_from_mob(item)
target.equip_to_slot_if_possible(item, slot_to_process, 0, 1, 1)
item.dropped(source)
source.update_icons()
target.update_icons()
if(source && target)
if(source.machine == target)
+1 -1
View File
@@ -237,7 +237,7 @@
src << "\red It becomes hard to see for some reason."
eye_blurry = 10
if(getBrainLoss() >= 35)
if(7 <= rn && rn <= 9) if(hand && equipped())
if(7 <= rn && rn <= 9) if(get_active_hand())
src << "\red Your hand won't respond properly, you drop what you're holding."
drop_item()
if(getBrainLoss() >= 50)
@@ -694,13 +694,12 @@ var/global/list/damage_icon_parts = list()
standing.overlays += bloodsies
overlays_standing[SUIT_LAYER] = standing
update_tail_showing(0)
else
overlays_standing[SUIT_LAYER] = null
update_tail_showing(0)
update_inv_shoes(0)
update_collar(0)
+2 -2
View File
@@ -49,8 +49,8 @@
Stun(2)
//Being hit while using a deadman switch
if(istype(equipped(),/obj/item/device/assembly/signaler))
var/obj/item/device/assembly/signaler/signaler = equipped()
if(istype(get_active_hand(),/obj/item/device/assembly/signaler))
var/obj/item/device/assembly/signaler/signaler = get_active_hand()
if(signaler.deadman && prob(80))
src.visible_message("\red [src] triggers their deadman's switch!")
signaler.signal()
@@ -607,7 +607,7 @@
stolen_item = C.r_hand
if(stolen_item)
C.u_equip(stolen_item)
C.remove_from_mob(stolen_item)
held_item = stolen_item
stolen_item.loc = src
visible_message("[src] grabs the [held_item] out of [C]'s hand!", "\blue You snag the [held_item] out of [C]'s hand!", "You hear the sounds of wings flapping furiously.")
-71
View File
@@ -117,77 +117,6 @@
/mob/proc/restrained()
return
//This proc is called whenever someone clicks an inventory ui slot.
/mob/proc/attack_ui(slot)
var/obj/item/W = get_active_hand()
if(istype(W))
equip_to_slot_if_possible(W, slot)
/mob/proc/put_in_any_hand_if_possible(obj/item/W as obj, del_on_fail = 0, disable_warning = 1, redraw_mob = 1)
if(equip_to_slot_if_possible(W, slot_l_hand, del_on_fail, disable_warning, redraw_mob))
return 1
else if(equip_to_slot_if_possible(W, slot_r_hand, del_on_fail, disable_warning, redraw_mob))
return 1
return 0
//This is a SAFE proc. Use this instead of equip_to_slot()!
//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))
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)
return 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_l_ear,\
slot_r_ear,\
slot_glasses,\
slot_belt,\
slot_s_store,\
slot_tie,\
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, del_on_fail=0, disable_warning=1, redraw_mob=1))
return 1
return 0
/mob/proc/reset_view(atom/A)
if (client)
if (istype(A, /atom/movable))
+2 -2
View File
@@ -96,8 +96,8 @@
/client/verb/drop_item()
set hidden = 1
if(!isrobot(mob))
mob.drop_item_v()
if(!isrobot(mob) && mob.stat == CONSCIOUS && isturf(mob.loc))
return mob.drop_item()
return
+1 -1
View File
@@ -45,7 +45,7 @@
src.state = STATE_DEFAULT
if("login")
var/mob/M = usr
var/obj/item/weapon/card/id/I = M.equipped()
var/obj/item/weapon/card/id/I = M.get_active_hand()
if (I && istype(I))
if(src.check_access(I))
authenticated = 1
+1 -3
View File
@@ -171,10 +171,8 @@
user << "\red There is already a [fueljar] inside!"
return
fueljar = W
user.remove_from_mob(W)
W.loc = src
if(user.client)
user.client.screen -= W
user.u_equip(W)
user.update_icons()
user.visible_message("[user.name] loads an [W.name] into the [src.name].", \
"You load an [W.name].", \
@@ -66,7 +66,7 @@
for(var/obj/item/O in src.contents)
total_stored += O.get_storage_cost()
if(total_stored + W.get_storage_cost() <= max_storage_space)
user.drop_item(W)
user.remove_from_mob(W)
W.loc = src
user << "You shove [W] into the hopper."
else
+1 -1
View File
@@ -80,7 +80,7 @@
var/mob/living/M = loc
if(M == T) return
if(!istype(M)) return
if(src != M.equipped())
if(src != M.get_active_hand())
stop_aim()
return
+2 -2
View File
@@ -655,7 +655,7 @@
user << "\The [O] is not suitable for blending."
return 1
user.before_take_item(O)
user.remove_from_mob(O)
O.loc = src
holdingitems += O
src.updateUsrDialog()
@@ -794,4 +794,4 @@
if (beaker.reagents.total_volume >= beaker.reagents.maximum_volume)
break
#undef REAGENTS_PER_SHEET
#undef REAGENTS_PER_SHEET
@@ -165,9 +165,7 @@
return
user << "\red You slip [W] inside [src]."
user.u_equip(W)
if ((user.client && user.s_active != src))
user.client.screen -= W
user.remove_from_mob(W)
W.dropped(user)
add_fingerprint(user)
contents += W
@@ -250,7 +250,7 @@
if (target != user && target.getarmor(target_zone, "melee") > 5 && prob(50))
for(var/mob/O in viewers(world.view, user))
O.show_message(text("\red <B>[user] tries to stab [target] in \the [hit_area] with [src.name], but the attack is deflected by armor!</B>"), 1)
user.u_equip(src)
user.remove_from_mob(src)
del(src)
return