12 key_target =
'chicken_target'
13 key_food =
'chicken_food'
14 key_attacked =
'chicken_attacked'
15 stay_on_floor =
'small_stones'
17 eat = {
'orc\'s livers' : 5,
'orc\'s hearts' : 6,
'goblin\'s livers' : 1,
'goblin\'s hearts' : 2 }
21 obj = Crossfire.WhoAmI().Map.ObjectAt(x, y)
23 if obj.Floor == 1
and obj.ArchName == name:
30 obj = chicken.Map.ObjectAt(x, y)
40 chicken = Crossfire.WhoAmI()
41 if chicken.Enemy !=
None:
43 chicken.WriteKey(key_attacked,
'1', 1)
45 if chicken.ReadKey(key_attacked) !=
'':
48 Crossfire.SetReturnValue(1)
49 if chicken.Map.Darkness >= 3:
53 target = chicken.ReadKey(key_target)
55 x =
int(target.split(
'|')[0])
56 y =
int(target.split(
'|')[1])
61 chicken.WriteKey(key_target,
'', 1)
63 chicken.Map.Print(
'The %s eats the %s!'%(chicken.Name, food.Name))
64 got = chicken.ReadKey(key_food)
69 got = got + eat[food.NamePl]
71 if random.randint(1, 100) <= ( got * 2 ):
72 egg = chicken.Map.CreateObject(
'chicken_egg', chicken.X, chicken.Y)
73 egg.Name =
'Combat Chicken egg'
74 egg.NamePl =
'Combat Chicken eggs'
76 chicken.Map.Print(
'The %s lays an egg!'%chicken.Name)
78 chicken.WriteKey(key_food,
str(got), 1)
79 food.Quantity = food.Quantity - 1
85 for x
in range(-3, 4):
86 for y
in range(-3, 4):
87 food =
find_food(chicken, chicken.X + x, chicken.Y + y)
90 target =
'%d|%d'%(food.X, food.Y)
91 chicken.WriteKey(key_target, target, 1)
99 dir = random.randint(1, 8)
100 if (
has_floor(chicken.X + CFMove.dir_x[dir], chicken.Y + CFMove.dir_y[dir], stay_on_floor)):
102 Crossfire.SetReturnValue(1)