Files
Paradise/code/game/objects/items/food.dm
elly1989@rocketmail.com 48088b79d9 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
2012-06-23 21:24:45 +00:00

149 lines
3.8 KiB
Plaintext

/*
CONTAINS:
DONUT BOX
EGG BOX
MONKEY CUBE BOX
*/
/mob/living/carbon/var/last_eating = 0
/obj/item/kitchen/donut_box
var/amount = 6
icon = 'food.dmi'
icon_state = "donutbox"
name = "donut box"
/obj/item/kitchen/egg_box
var/amount = 12
icon = 'food.dmi'
icon_state = "eggbox"
name = "egg box"
/obj/item/kitchen/donut_box/proc/update()
src.icon_state = text("donutbox[]", src.amount)
return
/*
/obj/item/kitchen/donut_box/attackby(obj/item/weapon/W as obj, mob/user as mob)
if (istype(W, /obj/item/weapon/reagent_containers/food/snacks/donut) && (amount < 6))
user.drop_item()
W.loc = src
usr << "You place a donut back into the box."
src.update()
return
*/
/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.get_active_hand() )
src.attack_hand(usr, usr.hand, 1)
return
/obj/item/kitchen/donut_box/attack_paw(mob/user as mob)
return src.attack_hand(user)
/obj/item/kitchen/donut_box/attack_hand(mob/user as mob, unused, flag)
if (flag)
return ..()
src.add_fingerprint(user)
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()
set src in oview(1)
src.amount = round(src.amount)
var/n = src.amount
for(var/obj/item/weapon/reagent_containers/food/snacks/donut/P in src)
n++
if (n <= 0)
n = 0
usr << "There are no donuts left in the box."
else
if (n == 1)
usr << "There is one donut left in the box."
else
usr << text("There are [] donuts in the box.", n)
return
/obj/item/kitchen/egg_box/proc/update()
src.icon_state = text("eggbox[]", src.amount)
return
/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.get_active_hand() )
attack_hand(usr, usr.hand, 1)
return
return
/obj/item/kitchen/egg_box/attack_paw(mob/user as mob)
return src.attack_hand(user)
/obj/item/kitchen/egg_box/attack_hand(mob/user as mob, unused, flag)
if (flag)
return ..()
src.add_fingerprint(user)
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)
src.amount = round(src.amount)
var/n = src.amount
for(var/obj/item/weapon/reagent_containers/food/snacks/egg/P in src)
n++
if (n <= 0)
n = 0
usr << "There are no eggs left in the box."
else
if (n == 1)
usr << "There is one egg left in the box."
else
usr << text("There are [] eggs in the box.", n)
return
/obj/item/weapon/monkeycube_box
name = "monkey cube box"
desc = "Drymate brand monkey cubes. Just add water!"
icon = 'food.dmi'
icon_state = "monkeycubebox"
var/amount = 2
attack_hand(mob/user as mob, unused, flag)
add_fingerprint(user)
if(user.r_hand == src || user.l_hand == src)
if(amount)
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
user << "There are no monkey cubes left in the box."
else
..()
return
attack_paw(mob/user as mob)
return attack_hand(user)