From 5834c940e685cbad9258332c9d1e01e3ffb75a6a Mon Sep 17 00:00:00 2001 From: "baloh.matevz" Date: Mon, 12 Sep 2011 05:25:55 +0000 Subject: [PATCH] - Ian now chases food and eats it if he can. - isanimal() and iscorgi() procs have been added - attack_animal() added for all atoms, called when an animal attacks (clicks on) an object within range. - attack_animal() proc added to food. Simple animals don't process reagents, meaning they can eat anything whatsoever. Corgis can take 5 bites out of any type of food. Ian will chase the food himself, regular corgis won't due to lag concerns. git-svn-id: http://tgstation13.googlecode.com/svn/trunk@2183 316c924e-a436-60f5-8080-3fe189b3f50e --- code/defines/mob/simple_animal/life.dm | 55 ++++++++++++++++++++++++-- code/game/atom_procs.dm | 8 +++- code/modules/food/food.dm | 12 ++++++ code/modules/mob/mob.dm | 10 +++++ 4 files changed, 80 insertions(+), 5 deletions(-) diff --git a/code/defines/mob/simple_animal/life.dm b/code/defines/mob/simple_animal/life.dm index d0e62301880..7e03e63b84a 100644 --- a/code/defines/mob/simple_animal/life.dm +++ b/code/defines/mob/simple_animal/life.dm @@ -15,6 +15,7 @@ universal_speak = 1 var/meat_amount = 0 var/meat_type + var/stop_automated_movement = 0 //Use this to temporarely stop random movement or to if you write special movement code for animals. //Interaction var/response_help = "You try to help" @@ -47,7 +48,7 @@ icon_state = "corgi" icon_living = "corgi" icon_dead = "corgi_dead" - speak = list("YAP","Woof!","Hoot!","AUUUUUU") + speak = list("YAP","Woof!","Bark!","AUUUUUU") speak_emote = list("barks", "woofs") emote_hear = list("barks","woofs","yaps") emote_see = list("shakes it's head", "shivers") @@ -56,15 +57,61 @@ meat_type = /obj/item/weapon/reagent_containers/food/snacks/meat/corgi meat_amount = 3 response_help = "pets the" - response_disarm = "getnly pushes aside the" + response_disarm = "gently pushes aside the" response_harm = "kicks the" /mob/living/simple_animal/corgi/Ian name = "Ian" desc = "It's Ian, what else do you need to know?" response_help = "pets" - response_disarm = "getnly pushes aside" + response_disarm = "gently pushes aside" response_harm = "kicks" + var/turns_since_scan = 0 + var/obj/movement_target + +/mob/living/simple_animal/corgi/Ian/Life() + ..() + + //Feeding, chasing food, FOOOOODDDD + if(alive && !resting && !buckled) + turns_since_scan++ + if(turns_since_scan > 5) + turns_since_scan = 0 + if((movement_target) && !(isturf(movement_target.loc) || ishuman(movement_target.loc) )) + movement_target = null + stop_automated_movement = 0 + if( !movement_target || !(movement_target.loc in oview(src, 3)) ) + movement_target = null + stop_automated_movement = 0 + for(var/obj/item/weapon/reagent_containers/food/snacks/S in oview(src,3)) + if(isturf(S.loc) || ishuman(S.loc)) + movement_target = S + break + if(movement_target) + stop_automated_movement = 1 + step_to(src,movement_target,1) + sleep(3) + step_to(src,movement_target,1) + sleep(3) + step_to(src,movement_target,1) + + if(movement_target) //Not redundant due to sleeps, Item can be gone in 6 decisecomds + if (movement_target.loc.x < src.x) + dir = WEST + else if (movement_target.loc.x > src.x) + dir = EAST + else if (movement_target.loc.y < src.y) + dir = SOUTH + else if (movement_target.loc.y > src.y) + dir = NORTH + else + dir = SOUTH + + if(isturf(movement_target.loc) ) + movement_target.attack_animal(src) + else if(ishuman(movement_target.loc) ) + if(prob(20)) + emote("stares at the [movement_target] that [movement_target.loc] has with a sad puppy-face") /mob/living/simple_animal/New() ..() @@ -96,7 +143,7 @@ health = max_health //Movement - if(!ckey) + if(!ckey && !stop_automated_movement) if(isturf(src.loc) && !resting && !buckled) //This is so it only moves if it's not inside a closet, gentics machine, etc. turns_since_move++ if(turns_since_move >= turns_per_move) diff --git a/code/game/atom_procs.dm b/code/game/atom_procs.dm index 35bfdcec06c..d5e920b2c4b 100644 --- a/code/game/atom_procs.dm +++ b/code/game/atom_procs.dm @@ -12,6 +12,9 @@ /atom/proc/attack_ai(mob/user as mob) return +/atom/proc/attack_animal(mob/user as mob) + return + //for aliens, it works the same as monkeys except for alien-> mob interactions which will be defined in the //appropiate mob files /atom/proc/attack_alien(mob/user as mob) @@ -218,7 +221,7 @@ /atom/DblClick() //TODO: DEFERRED: REWRITE // world << "checking if this shit gets called at all" - if (world.time <= usr:lastDblClick+2) + if (world.time <= usr:lastDblClick+1) // world << "BLOCKED atom.DblClick() on [src] by [usr] : src.type is [src.type]" return else @@ -447,6 +450,9 @@ else if(istype(usr, /mob/living/carbon/metroid)) src.attack_metroid(usr) + else + if(istype(usr, /mob/living/simple_animal)) + src.attack_animal(usr) else if (istype(usr, /mob/living/carbon/human)) src.hand_h(usr, usr.hand) diff --git a/code/modules/food/food.dm b/code/modules/food/food.dm index 588ea31d58e..095e46e5301 100644 --- a/code/modules/food/food.dm +++ b/code/modules/food/food.dm @@ -26,6 +26,18 @@ // reagents.add_reagent("nutriment", 2) // this line of code for all the contents. // bitesize = 3 //This is the amount each bite consumes. +/obj/item/weapon/reagent_containers/food/snacks/attack_animal(var/mob/M) + if(isanimal(M)) + if(iscorgi(M)) + if(bitecount == 0 || prob(50)) + M.emote("nibbles away at the [src]") + bitecount++ + if(bitecount >= 5) + var/sattisfaction_text = pick("burps from enjoyment", "yaps for more", "woofs twice", "looks at the area where the [src] was") + if(sattisfaction_text) + M.emote("[sattisfaction_text]") + del(src) + /obj/item/weapon/reagent_containers/food/snacks/candy name = "candy" desc = "Nougat love it or hate it." diff --git a/code/modules/mob/mob.dm b/code/modules/mob/mob.dm index d85addaf1b1..3063e90983f 100644 --- a/code/modules/mob/mob.dm +++ b/code/modules/mob/mob.dm @@ -57,6 +57,16 @@ return 1 return 0 +/proc/isanimal(A) + if(istype(A, /mob/living/simple_animal)) + return 1 + return 0 + +/proc/iscorgi(A) + if(istype(A, /mob/living/simple_animal/corgi)) + return 1 + return 0 + /*proc/ishivebot(A) if(A && istype(A, /mob/living/silicon/hivebot)) return 1