-
Notifications
You must be signed in to change notification settings - Fork 2
/
sheep.lua
191 lines (183 loc) · 3.71 KB
/
sheep.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
--[[
Copyright (c) 2016-2019 - Auke Kok <sofar@foo-projects.org>
* entity_ai is licensed as follows:
- All code is: LGPL-2.1
- All artwork is: CC-BY-SA-4.0
--]]
--
-- sheep entity AI script
--
local sheep_script = {
-- the start driver. Should be able to spawn a monster with a different driver!
driver = "roam",
-- default properties
properties = {
speed = 2.0,
hp_max = 20,
foodnodes = {
"group:grass",
"default:dirt_with_grass",
"default:dirt_with_dry_grass",
"default:grass_1",
"default:grass_2",
"default:grass_3",
"default:grass_4",
"default:grass_5",
"default:dry_grass_1",
"default:dry_grass_2",
"default:dry_grass_3",
"default:dry_grass_4",
"default:dry_grass_5",
},
habitatnodes = {
"group:flora",
"group:snappy",
"group:dirt",
"group:soil",
"group:crumbly",
"group:grass",
"default:dirt_with_grass",
"default:dirt_with_dry_grass",
"default:sand"
,}
},
-- defined animation sets:
-- "name" = { animationspec1, animationspec2, animationspec3 .. }
-- each must be present -> 'nil' required
-- last animation should have 'frame_loop = true'
--FIXME handle repeats (running animation 5x ?)
animations = {
move = {
{{x = 0, y = 40}, frame_speed = 60, frame_loop = true},
},
run = {
{{x = 0, y = 40}, frame_speed = 90, frame_loop = true},
},
idle = {
{{x = 111, y = 129}, frame_speed = 10, frame_loop = true},
},
eat = {
{{x = 41, y = 47}, frame_speed = 15, frame_loop = false},
{{x = 47, y = 75}, frame_speed = 15, frame_loop = true},
},
eat_end = {
{{x = 75, y = 81}, frame_speed = 15, frame_loop = false},
},
startle = {
{{x = 100, y = 110}, frame_speed = 30, frame_loop = false},
{{x = 111, y = 119}, frame_speed = 30, frame_loop = true},
},
death = {
{{x = 82, y = 90}, frame_speed = 15, frame_loop = false},
{{x = 90, y = 99}, frame_speed = 15, frame_loop = true},
},
},
-- sound samples
sounds = {
chatter = {{name = "sheep_chatter", gain = 0.2}, {max_hear_distance = 12}},
footsteps = {{name = "sheep_steps", gain = 0.2}, {max_hear_distance = 12}},
hurt = {{name = "sheep_hurt", gain = 0.5}, {max_hear_distance = 18}},
},
-- monster script states:
roam = {
finders = {
"find_habitat",
},
factors = {
got_hit = "startle",
became_fertile = "fertile",
attractor_nearby = "attracted",
},
sounds = {
random = "footsteps",
},
},
idle = {
factors = {
got_hit = "startle",
became_fertile = "fertile",
attractor_nearby = "attracted",
too_far_from_home = "homing",
near_foodnode = "eat",
},
sounds = {
random = "chatter",
},
},
eat = {
factors = {
got_hit = "startle",
became_fertile = "fertile",
attractor_nearby = "attracted",
},
sounds = {
random = "chatter",
},
},
eat_end = {
factors = {
anim_end = "idle",
}
},
startle = {
factors = {
anim_end = "flee",
},
sounds = {
start = "hurt",
},
},
flee = {
finders = {
"flee_attacker",
},
properties = {
speed = 4.0,
},
factors = {
got_hit = "startle",
},
sounds = {
random = "footsteps",
},
},
attracted = {
factors = {
got_hit = "startle",
became_fertile = "fertile",
approached_too_long = "roam",
},
sounds = {
random = "chatter",
},
},
fertile = {
factors = {
got_hit = "startle",
},
sounds = {
random = "chatter",
},
},
homing = {
factors = {
near_home = "roam",
got_hit = "startle",
},
sounds = {
random = "chatter",
},
},
death = {
sounds = {
start = "hurt",
},
},
}
entity_ai.register_entity("entity_ai:sheep", {
script = sheep_script,
mesh = "sheep.b3d",
textures = {"sheep_fur.png"},
makes_footstep_sound = true,
collisionbox = {-5/16, -1/2, -5/16, 5/16, 4/16, 5/16},
})