Merge pull request #284 from Tastyfish/master

added orderable chickens and cows
This commit is contained in:
SkyMarshal
2012-01-16 23:17:36 -08:00
10 changed files with 338 additions and 44 deletions
+185
View File
@@ -0,0 +1,185 @@
// Base Class
/mob/living/simple_animal/livestock
desc = "Tasty!"
icon = 'livestock.dmi'
emote_see = list("shakes its head", "kicks the ground")
speak_chance = 1
turns_per_move = 15
meat_type = /obj/item/weapon/reagent_containers/food/snacks/meat
response_help = "pets the"
response_disarm = "gently pushes aside the"
response_harm = "kicks the"
var/max_nutrition = 100 // different animals get hungry faster, basically number of 5-second steps from full to starving (60 == 5 minutes)
var/nutrition_step // cycle step in nutrition system
var/obj/movement_target // eating-ing target
New()
if(!nutrition)
nutrition = max_nutrition * 0.33 // at 1/3 nutrition
Life()
..()
if(alive)
meat_amount = round(nutrition / 50)
nutrition_step--
if(nutrition_step <= 0)
// handle animal digesting
if(nutrition > 0)
nutrition--
else
health--
nutrition_step = 50 // only tick this every 5 seconds
// handle animal eating (borrowed from Ian code)
// not hungry if full
if(nutrition >= max_nutrition)
return
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)
if(istype(movement_target, /obj/item/weapon/reagent_containers/food/snacks))
var/obj/item/I = movement_target
I.attack(src, src, "mouth") // eat it, if it's food
if(a_intent == "hurt") // to make raging critter harm, then disarm, then stop
a_intent = "disarm"
else if(a_intent == "disarm")
a_intent = "help"
movement_target = null
turns_per_move = initial(turns_per_move)
else if(ishuman(movement_target.loc))
if(prob(20))
emote("stares at the [movement_target] that [movement_target.loc] has with a longing expression.")
proc/rage_at(mob/living/M)
movement_target = M // pretty simple
turns_per_move = 1
emote("becomes enraged")
a_intent = "hurt"
attackby(var/obj/item/O as obj, var/mob/user as mob)
if(nutrition < max_nutrition && istype(O,/obj/item/weapon/reagent_containers/food/snacks))
O.attack_animal(src)
else
..(O, user)
// Cow
/mob/living/simple_animal/livestock/cow
name = "cow"
icon_state = "cow"
icon_living = "cow"
icon_dead = "cow_d"
meat_type = /obj/item/weapon/reagent_containers/food/snacks/meat/cow
meat_amount = 10
max_nutrition = 1000
speak = list("Moo.","Moooo!","Snort.")
speak_emote = list("moos")
emote_hear = list("moos", "snorts")
attackby(var/obj/item/O as obj, var/mob/user as mob)
if(istype(O,/obj/item/weapon/reagent_containers/glass))
var/datum/reagents/R = O:reagents
R.add_reagent("milk", 50)
nutrition -= 50
usr << "\blue You milk the cow."
else if(O.force > 0 && O.w_class >= 2)
rage_at(user)
else
..(O, user)
attack_hand(var/mob/user as mob)
..()
if(user.a_intent == "hurt")
rage_at(user)
/obj/item/weapon/reagent_containers/food/snacks/meat/cow
name = "Beef"
desc = "It's what's for dinner!"
// Chicken
/mob/living/simple_animal/livestock/chicken
name = "chicken"
icon_state = "chick"
icon_living = "chick"
icon_dead = "chick_d"
meat_type = /obj/item/weapon/reagent_containers/food/snacks/meat/chicken
meat_amount = 3
max_nutrition = 200
speak = list("Bock bock!","Cl-cluck.","Click.")
speak_emote = list("bocks","clucks")
emote_hear = list("bocks", "clucks", "squacks")
/mob/living/simple_animal/livestock/chicken/Life()
..()
// go right before cycle elapses, and if animal isn't starving
if(alive && nutrition_step == 1 && nutrition > max_nutrition / 2)
// lay an egg with probability of 5% in 5 second time period
if(prob(33))
new/obj/item/weapon/reagent_containers/food/snacks/egg(src.loc) // lay an egg
nutrition -= 5
/obj/item/weapon/reagent_containers/food/snacks/meat/chicken
name = "Chicken"
desc = "Tasty!"
/obj/structure/closet/critter
desc = "A critter crate."
name = "Critter Crate"
icon = 'storage.dmi'
icon_state = "critter"
density = 1
icon_opened = "critteropen"
icon_closed = "critter"
/datum/supply_packs/chicken
name = "Chicken crate"
contains = list("/mob/living/simple_animal/livestock/chicken",
"/obj/item/weapon/reagent_containers/food/snacks/grown/corn")
cost = 10
containertype = "/obj/structure/closet/critter"
containername = "Chicken crate"
group = "Hydroponics"
/datum/supply_packs/cow
name = "Cow crate"
contains = list("/mob/living/simple_animal/livestock/cow",
"/obj/item/weapon/reagent_containers/food/snacks/grown/corn")
cost = 50
containertype = "/obj/structure/closet/critter"
containername = "Cow crate"
group = "Hydroponics"
+3 -3
View File
@@ -1,4 +1,4 @@
/obj/filingcabinet
/obj/structure/filingcabinet
name = "Filing Cabinet"
desc = "A large cabinet with drawers."
icon = 'computer.dmi'
@@ -6,7 +6,7 @@
density = 1
anchored = 1
/obj/filingcabinet/attackby(obj/item/weapon/paper/P,mob/M)
/obj/structure/filingcabinet/attackby(obj/item/weapon/paper/P,mob/M)
if(istype(P))
M << "You put the [P] in the [src]."
M.drop_item()
@@ -14,7 +14,7 @@
else
M << "You can't put a [P] in the [src]!"
/obj/filingcabinet/attack_hand(mob/user)
/obj/structure/filingcabinet/attack_hand(mob/user)
if(src.contents.len <= 0)
user << "The [src] is empty."
return