ugh...this was horrible. I'm really sorry if I fucked anything up, I was literally going braindead towards the end.

Replaced every l_hand = and r_hand = and all that if(hand) crap to use standardised procs. This means we can use procs like Dropped() reliably as they will always be called when things are dropped.

Thorough documentation to come. But generally, if you want a mob's icons to update after deleting something in the inventory...use drop_from_inventory(the_thing_you_wanna_drop) just before deleting it. If you wanna put something in a mob's hands use put_in_hands() (or one of the variants). It'll try putting it in active hand first, then inactive, then the floor. They handle layers, overlays, screenlocs calling various procs such as dropped() etc for you. Easy

mob.equipped() is now mob.get_active_hand() because there was another totally unrelated proc named equipped() and stuff was confusing.

Weakening was made instantaneous.

Minor optimisations for human/handle_regular_status_updates(). I'll port these changes over to the other mobs next. Basically it should stop it constantly incrementing every status effect even after death.

umm... bunch of overlays related fixes... I think that's everything. :/

git-svn-id: http://tgstation13.googlecode.com/svn/trunk@3900 316c924e-a436-60f5-8080-3fe189b3f50e
This commit is contained in:
elly1989@rocketmail.com
2012-06-23 21:24:45 +00:00
parent ce21bded5f
commit 48088b79d9
136 changed files with 972 additions and 1522 deletions
+1 -1
View File
@@ -23,7 +23,7 @@
/obj/item/blueprints/Topic(href, href_list)
..()
if ((usr.restrained() || usr.stat || usr.equipped() != src))
if ((usr.restrained() || usr.stat || usr.get_active_hand() != src))
return
if (!href_list["action"])
return
+1 -8
View File
@@ -119,14 +119,7 @@
return
else
src.candlecount--
var/obj/item/candle/W = new /obj/item/candle(user)
if(user.hand)
user.l_hand = W
user.update_inv_l_hand()
else
user.r_hand = W
user.update_inv_r_hand()
W.layer = 20
user.put_in_hands(new /obj/item/candle(user))
else
return ..()
src.update_icon()
+23 -82
View File
@@ -37,16 +37,8 @@ MONKEY CUBE BOX
/obj/item/kitchen/donut_box/MouseDrop(mob/user as mob)
if ((user == usr && (!( usr.restrained() ) && (!( usr.stat ) && (usr.contents.Find(src) || in_range(src, usr))))))
if(!istype(user, /mob/living/carbon/metroid))
if (usr.hand)
if (!( usr.l_hand ))
spawn( 0 )
src.attack_hand(usr, 1, 1)
return
else
if (!( usr.r_hand ))
spawn( 0 )
src.attack_hand(usr, 0, 1)
return
if( !usr.get_active_hand() )
src.attack_hand(usr, usr.hand, 1)
return
/obj/item/kitchen/donut_box/attack_paw(mob/user as mob)
@@ -56,36 +48,15 @@ MONKEY CUBE BOX
if (flag)
return ..()
src.add_fingerprint(user)
if (locate(/obj/item/weapon/reagent_containers/food/snacks/donut, src))
for(var/obj/item/weapon/reagent_containers/food/snacks/donut/P in src)
if (!usr.l_hand)
P.loc = usr
P.layer = 20
usr.l_hand = P
usr.update_inv_l_hand()
usr << "You take a donut out of the box."
break
else if (!usr.r_hand)
P.loc = usr
P.layer = 20
usr.r_hand = P
usr.update_inv_r_hand()
usr << "You take a donut out of the box."
break
else
if (src.amount >= 1)
src.amount--
var/obj/item/weapon/reagent_containers/food/snacks/donut/D = new /obj/item/weapon/reagent_containers/food/snacks/donut
D.loc = usr.loc
if(ishuman(usr))
if(!usr.get_active_hand())
usr.put_in_hand(D)
usr << "You take a donut out of the box."
else
D.loc = get_turf_loc(src)
usr << "You take a donut out of the box."
src.update()
var/obj/item/weapon/reagent_containers/food/snacks/donut/P = locate() in src
if(!P && (amount >= 1))
P = new /obj/item/weapon/reagent_containers/food/snacks/donut( src )
if(P)
usr.put_in_hands(P)
usr << "You take a donut out of the box."
src.amount--
src.update()
return
/obj/item/kitchen/donut_box/examine()
@@ -112,16 +83,9 @@ MONKEY CUBE BOX
/obj/item/kitchen/egg_box/MouseDrop(mob/user as mob)
if ((user == usr && (!( usr.restrained() ) && (!( usr.stat ) && (usr.contents.Find(src) || in_range(src, usr))))))
if (usr.hand)
if (!( usr.l_hand ))
spawn( 0 )
src.attack_hand(usr, 1, 1)
return
else
if (!( usr.r_hand ))
spawn( 0 )
src.attack_hand(usr, 0, 1)
return
if( !usr.get_active_hand() )
attack_hand(usr, usr.hand, 1)
return
return
/obj/item/kitchen/egg_box/attack_paw(mob/user as mob)
@@ -131,32 +95,17 @@ MONKEY CUBE BOX
if (flag)
return ..()
src.add_fingerprint(user)
if (locate(/obj/item/weapon/reagent_containers/food/snacks/egg, src))
for(var/obj/item/weapon/reagent_containers/food/snacks/egg/P in src)
if (!usr.l_hand)
P.loc = usr.loc
P.layer = 20
usr.l_hand = P
P = null
usr.update_inv_l_hand()
usr << "You take an egg out of the box."
break
else if (!usr.r_hand)
P.loc = usr.loc
P.layer = 20
usr.r_hand = P
P = null
usr.update_inv_r_hand()
usr << "You take an egg out of the box."
break
else
if (src.amount >= 1)
src.amount--
new /obj/item/weapon/reagent_containers/food/snacks/egg( src.loc )
usr << "You take an egg out of the box."
src.update()
var/obj/item/weapon/reagent_containers/food/snacks/egg/P = locate() in src
if(!P && (amount >= 1))
P = new /obj/item/weapon/reagent_containers/food/snacks/egg( src )
if(P)
usr.put_in_hands(P)
usr << "You take an egg out of the box."
src.amount--
src.update()
return
/obj/item/kitchen/egg_box/examine()
set src in oview(1)
@@ -186,15 +135,7 @@ MONKEY CUBE BOX
if(user.r_hand == src || user.l_hand == src)
if(amount)
var/obj/item/weapon/reagent_containers/food/snacks/monkeycube/wrapped/M = new /obj/item/weapon/reagent_containers/food/snacks/monkeycube/wrapped(src)
if (user.hand)
user.l_hand = M
user.update_inv_l_hand()
else
user.r_hand = M
user.update_inv_r_hand()
M.loc = user
M.layer = 20
user.put_in_hands(new /obj/item/weapon/reagent_containers/food/snacks/monkeycube/wrapped(user))
user << "You take a monkey cube out of the box."
amount--
else
+4 -17
View File
@@ -23,7 +23,7 @@
/obj/item/proc/equipped(var/mob/user, var/slot)
return
//
// ***TODO: implement unequipped()
// ***TODO: implement unget_active_hand()
//
/obj/item/proc/afterattack()
@@ -119,15 +119,8 @@
src.pickup(user)
user.lastDblClick = world.time + 2
user.next_move = world.time + 2
src.loc = user
src.layer = 20
add_fingerprint(user)
if (user.hand)
user.l_hand = src
user.update_inv_l_hand()
else
user.r_hand = src
user.update_inv_r_hand()
user.put_in_active_hand(src)
return
@@ -158,14 +151,8 @@
src.pickup(user)
user.lastDblClick = world.time + 2
user.next_move = world.time + 2
src.loc = user
src.layer = 20
if (user.hand)
user.l_hand = src
user.update_inv_l_hand()
else
user.r_hand = src
user.update_inv_r_hand()
user.put_in_active_hand(src)
return
/obj/item/attackby(obj/item/weapon/W as obj, mob/user as mob)
+4 -8
View File
@@ -20,7 +20,9 @@
return
//stops TK grabs being equipped anywhere but into hands
equipped(var/mob/user, var/slot)
if( (slot=="l_hand") || (slot=="r_hand") ) return
del(src)
return
@@ -29,13 +31,7 @@
if(!istype(focus,/obj/item)) return
if(!check_path()) return//No clear path
if(user.hand == src)
user.l_hand = focus
else
user.r_hand = focus
focus.loc = user
focus.layer = 20
user.put_in_hands(focus)
add_fingerprint(user)
user.update_inv_l_hand(0)
user.update_inv_r_hand()
@@ -117,7 +113,7 @@
/*
if(istype(user, /mob/living/carbon))
if(user:mutations & TK && get_dist(source, user) <= 7)
if(user:equipped()) return 0
if(user:get_active_hand()) return 0
var/X = source:x
var/Y = source:y
var/Z = source:z
+6 -10
View File
@@ -13,17 +13,13 @@
return ..()
playsound(src.loc, "rustle", 50, 1, -5)
if ((!( M.restrained() ) && !( M.stat ) && M.back == src))
if (over_object.name == "r_hand")
if (!( M.r_hand ))
switch(over_object.name)
if("r_hand")
M.u_equip(src)
M.r_hand = src
M.update_inv_r_hand()
else
if (over_object.name == "l_hand")
if (!( M.l_hand ))
M.u_equip(src)
M.l_hand = src
M.update_inv_l_hand()
M.put_in_r_hand(src)
if("l_hand")
M.u_equip(src)
M.put_in_l_hand(src)
src.add_fingerprint(usr)
return
if(over_object == usr && in_range(src, usr) || usr.contents.Find(src))
+4 -18
View File
@@ -92,17 +92,7 @@ FINGERPRINT CARD
if (href_list["remove"])
var/obj/item/P = locate(href_list["remove"])
if ((P && P.loc == src))
if ((usr.hand && !( usr.l_hand )))
usr.l_hand = P
P.loc = usr
P.layer = 20
usr.update_inv_l_hand()
else
if (!( usr.r_hand ))
usr.r_hand = P
P.loc = usr
P.layer = 20
usr.update_inv_r_hand()
usr.put_in_hands(P)
src.add_fingerprint(usr)
P.add_fingerprint(usr)
src.update()
@@ -150,7 +140,7 @@ FINGERPRINT CARD
else
if (istype(P, /obj/item/weapon/pen))
var/t = input(user, "Holder Label:", text("[]", src.name), null) as text
if (user.equipped() != P)
if (user.get_active_hand() != P)
return
if ((!in_range(src, usr) && src.loc != user))
return
@@ -209,11 +199,7 @@ FINGERPRINT CARD
var/obj/item/weapon/f_card/F = new /obj/item/weapon/f_card( user )
F.amount = 1
src.amount--
if (user.hand)
user.l_hand = F
else
user.r_hand = F
F.layer = 20
user.put_in_hands(F)
F.add_fingerprint(user)
if (src.amount < 1)
//SN src = null
@@ -244,7 +230,7 @@ FINGERPRINT CARD
else
if (istype(W, /obj/item/weapon/pen))
var/t = input(user, "Card Label:", text("[]", src.name), null) as text
if (user.equipped() != W)
if (user.get_active_hand() != W)
return
if ((!in_range(src, usr) && src.loc != user))
return
@@ -71,14 +71,7 @@ ZIPPO
return
else
src.matchcount--
var/obj/item/weapon/match/W = new /obj/item/weapon/match(user)
if(user.hand)
user.l_hand = W
user.update_inv_l_hand()
else
user.r_hand = W
user.update_inv_r_hand()
W.layer = 20
user.put_in_active_hand(new /obj/item/weapon/match(user))
else
return ..()
if(src.matchcount <= 0)
@@ -430,13 +423,7 @@ ZIPPO
cigcount--
var/obj/item/clothing/mask/cigarette/W = new /obj/item/clothing/mask/cigarette(user)
reagents.trans_to(W, reagents.total_volume)
if(user.hand)
user.l_hand = W
user.update_inv_l_hand()
else
user.r_hand = W
user.update_inv_r_hand()
W.layer = 20
user.put_in_active_hand(W)
else
return ..()
update_icon()
+4 -4
View File
@@ -30,7 +30,7 @@ CRITTER GRENADE
afterattack(atom/target as mob|obj|turf|area, mob/user as mob)
if (istype(target, /obj/item/weapon/storage)) return ..() // Trying to put it in a full container
if (istype(target, /obj/item/weapon/gun/grenadelauncher)) return ..()
if((user.equipped() == src)&&(!active)&&(clown_check(user)))
if((user.get_active_hand() == src)&&(!active)&&(clown_check(user)))
user << "\red You prime the emp grenade! [det_time/10] seconds!"
src.active = 1
src.icon_state = "empar"
@@ -130,7 +130,7 @@ CRITTER GRENADE
afterattack(atom/target as mob|obj|turf|area, mob/user as mob)
if (istype(target, /obj/item/weapon/storage)) return ..() // Trying to put it in a full container
if (istype(target, /obj/item/weapon/gun/grenadelauncher)) return ..()
if((user.equipped() == src)&&(!active)&&(clown_check(user)))
if((user.get_active_hand() == src)&&(!active)&&(clown_check(user)))
user << "\red You prime the flashbang! [det_time/10] seconds!"
src.active = 1
src.icon_state = "flashbang1"
@@ -302,7 +302,7 @@ CRITTER GRENADE
afterattack(atom/target as mob|obj|turf|area, mob/user as mob)
if (istype(target, /obj/item/weapon/storage)) return ..() // Trying to put it in a full container
if (istype(target, /obj/item/weapon/gun/grenadelauncher)) return ..()
if((user.equipped() == src)&&(!active))
if((user.get_active_hand() == src)&&(!active))
//world << "cluster after attack"
arm(user)
user.dir = get_dir(user, target)
@@ -409,7 +409,7 @@ CRITTER GRENADE
afterattack(atom/target as mob|obj|turf|area, mob/user as mob)
if (istype(target, /obj/item/weapon/storage)) return ..() // Trying to put it in a full container
if (istype(target, /obj/item/weapon/gun/grenadelauncher)) return ..()
if((user.equipped() == src)&&(!active)&&(clown_check(user)))
if((user.get_active_hand() == src)&&(!active)&&(clown_check(user)))
user << "\red You prime the delivery grenade! [det_time/10] seconds!"
src.active = 1
src.icon_state = "delivery1"
@@ -25,7 +25,7 @@
..()
if (istype(I, /obj/item/weapon/pen))
var/t = input(user, "What would you like the label to be?", text("[]", src.name), null) as text
if (user.equipped() != I)
if (user.get_active_hand() != I)
return
if((!in_range(src, usr) && src.loc != user))
return
@@ -71,7 +71,7 @@
var/obj/item/weapon/melee/energy/blade/swordspawn = new /obj/item/weapon/melee/energy/blade
if(!source.get_active_hand())
source.put_in_hand(swordspawn)
source.put_in_hands(swordspawn)
var/datum/effect/effect/system/spark_spread/spark_system = new /datum/effect/effect/system/spark_spread()
spark_system.set_up(5, 0, source.loc)
@@ -26,18 +26,11 @@
attack_hand(mob/user as mob)
if ((src.case && (user.l_hand == src || user.r_hand == src)))
if (user.hand)
user.l_hand = src.case
user.update_inv_l_hand()
else
user.r_hand = src.case
user.update_inv_r_hand()
src.case.loc = user
src.case.layer = 20
user.put_in_active_hand(case)
src.case.add_fingerprint(user)
src.case = null
user.update_inv_l_hand(0)
user.update_inv_r_hand()
src.add_fingerprint(user)
update()
else
+1 -1
View File
@@ -53,7 +53,7 @@ var/global/list/cached_icons = list()
attack_self(mob/user as mob)
var/t1 = input(user, "Please select a color:", "Locking Computer", null) in list( "red", "blue", "green", "yellow", "black", "white")
if ((user.equipped() != src || user.stat || user.restrained()))
if ((user.get_active_hand() != src || user.stat || user.restrained()))
return
switch(t1)
if("red")
@@ -26,8 +26,8 @@ RACK PARTS
user << "\red You need at least four rods to do this."
/obj/item/weapon/table_parts/attack_self(mob/user as mob)
var/obj/structure/table/T = new /obj/structure/table( user.loc )
T.add_fingerprint(usr)
new /obj/structure/table( user.loc )
user.drop_item()
del(src)
return
@@ -35,11 +35,11 @@ RACK PARTS
/obj/item/weapon/table_parts/wood/attackby(obj/item/weapon/W as obj, mob/user as mob)
if (istype(W, /obj/item/weapon/wrench))
new /obj/item/stack/sheet/wood( src.loc )
//SN src = null
del(src)
/obj/item/weapon/table_parts/wood/attack_self(mob/user as mob)
new /obj/structure/table/woodentable( user.loc )
user.drop_item()
del(src)
return
@@ -49,11 +49,11 @@ RACK PARTS
if (istype(W, /obj/item/weapon/wrench))
new /obj/item/stack/sheet/metal( src.loc )
new /obj/item/stack/rods( src.loc )
//SN src = null
del(src)
/obj/item/weapon/table_parts/reinforced/attack_self(mob/user as mob)
new /obj/structure/table/reinforced( user.loc )
user.drop_item()
del(src)
return
@@ -73,5 +73,6 @@ RACK PARTS
/obj/item/weapon/rack_parts/attack_self(mob/user as mob)
var/obj/structure/rack/R = new /obj/structure/rack( user.loc )
R.add_fingerprint(user)
user.drop_item()
del(src)
return
@@ -122,7 +122,7 @@ Frequency:
if(turfs.len)
L["None (Dangerous)"] = pick(turfs)
var/t1 = input(user, "Please select a teleporter to lock in on.", "Hand Teleporter") in L
if ((user.equipped() != src || user.stat || user.restrained()))
if ((user.get_active_hand() != src || user.stat || user.restrained()))
return
var/count = 0 //num of portals from this teleport in world
for(var/obj/effect/portal/PO in world)
+3 -12
View File
@@ -25,14 +25,9 @@
/obj/item/weapon/twohanded/dropped(mob/user as mob)
//handles unwielding a twohanded weapon when dropped as well as clearing up the offhand
//bit of a hack but it keeps other code pretty neat and with fewer conditionals
var/obj/item/weapon/twohanded/O
if(user)
if(user.l_hand)
O = user.l_hand
else
O = user.r_hand
if(O && istype(O))
var/obj/item/weapon/twohanded/O = user.get_inactive_hand()
if(istype(O))
O.unwield()
return unwield()
@@ -67,11 +62,7 @@
var/obj/item/weapon/twohanded/offhand/O = new(user) ////Let's reserve his other hand~
O.name = "[initial(name)] - offhand"
O.desc = "Your second grip on the [initial(name)]"
if(user.hand)
user.r_hand = O ///Place dat offhand in the opposite hand
else
user.l_hand = O
O.layer = 20
user.put_in_inactive_hand(O)
return
///////////OFFHAND///////////////
@@ -32,7 +32,6 @@ PHOTOGRAPHS
src.add_fingerprint(user)
if (src.amount <= 0)
new /obj/item/weapon/c_tube( src.loc )
//SN src = null
del(src)
return
else
@@ -67,7 +66,7 @@ PHOTOGRAPHS
log_attack("<font color='red'>[user.name] ([user.ckey]) used the [src.name] to wrap [target.name] ([target.ckey])</font>")
else
user << "/blue You need more paper."
user << "\blue You need more paper."
else
user << "Theyre moving around too much. a Straitjacket would help."
@@ -78,18 +77,12 @@ PHOTOGRAPHS
// GIFTS
/obj/item/weapon/gift/attack_self(mob/user as mob)
if(!src.gift)
user << "\blue The gift was empty!"
del(src)
src.gift.loc = user
if (user.hand)
user.l_hand = src.gift
user.update_inv_l_hand()
user.drop_item()
if(src.gift)
user.put_in_active_hand(gift)
src.gift.add_fingerprint(user)
else
user.r_hand = src.gift
user.update_inv_r_hand()
src.gift.layer = 20
src.gift.add_fingerprint(user)
user << "\blue The gift was empty!"
del(src)
return
@@ -107,7 +100,7 @@ PHOTOGRAPHS
..()
if (!istype(W, /obj/item/weapon/wirecutters))
user << "/blue I need wirecutters for that."
user << "\blue I need wirecutters for that."
return
user << "\blue You cut open the present."
@@ -125,67 +118,32 @@ PHOTOGRAPHS
switch(pick("flash", "t_gun", "l_gun", "shield", "sword", "axe"))
if("flash")
var/obj/item/device/flash/W = new /obj/item/device/flash( M )
if (M.hand)
M.l_hand = W
M.update_inv_l_hand()
else
M.r_hand = W
M.update_inv_r_hand()
W.layer = 20
M.put_in_active_hand(W)
W.add_fingerprint(M)
//SN src = null
del(src)
return
if("l_gun")
var/obj/item/weapon/gun/energy/laser/W = new /obj/item/weapon/gun/energy/laser( M )
if (M.hand)
M.l_hand = W
M.update_inv_l_hand()
else
M.r_hand = W
M.update_inv_r_hand()
W.layer = 20
M.put_in_active_hand(W)
W.add_fingerprint(M)
//SN src = null
del(src)
return
if("t_gun")
var/obj/item/weapon/gun/energy/taser/W = new /obj/item/weapon/gun/energy/taser( M )
if (M.hand)
M.l_hand = W
M.update_inv_l_hand()
else
M.r_hand = W
M.update_inv_r_hand()
W.layer = 20
M.put_in_active_hand(W)
W.add_fingerprint(M)
//SN src = null
del(src)
return
if("sword")
var/obj/item/weapon/melee/energy/sword/W = new /obj/item/weapon/melee/energy/sword( M )
if (M.hand)
M.l_hand = W
M.update_inv_l_hand()
else
M.r_hand = W
M.update_inv_r_hand()
W.layer = 20
M.put_in_active_hand(W)
W.add_fingerprint(M)
//SN src = null
del(src)
return
if("axe")
var/obj/item/weapon/melee/energy/axe/W = new /obj/item/weapon/melee/energy/axe( M )
if (M.hand)
M.l_hand = W
M.update_inv_l_hand()
else
M.r_hand = W
M.update_inv_r_hand()
W.layer = 20
M.put_in_active_hand(W)
W.add_fingerprint(M)
//SN src = null
del(src)
return
else
@@ -195,7 +153,6 @@ PHOTOGRAPHS
/obj/structure/bedsheetbin/attackby(obj/item/weapon/W as obj, mob/user as mob)
if (istype(W, /obj/item/weapon/bedsheet))
//W = null
del(W)
src.amount++
return