Make villager stand still if there is near player
[MineClone/MineClone2.git] / mods / ENTITIES / mobs_mc / slime+magma_cube.lua
blobe0c9d58a98462362e2099f6ded890716f84e111c
1 --License for code WTFPL and otherwise stated in readmes
3 -- intllib
4 local MP = minetest.get_modpath(minetest.get_current_modname())
5 local S, NS = dofile(MP.."/intllib.lua")
7 -- Slime
8 local slime_big = {
9 type = "monster",
10 pathfinding = 1,
11 group_attack = true,
12 hp_min = 16,
13 hp_max = 16,
14 collisionbox = {-1.02, -0.01, -1.02, 1.02, 2.03, 1.02},
15 visual_size = {x=12.5, y=12.5},
16 textures = {{"mobs_mc_slime.png"}},
17 visual = "mesh",
18 mesh = "mobs_mc_slime.b3d",
19 blood_texture ="mobs_mc_slime_blood.png",
20 makes_footstep_sound = true,
21 sounds = {
22 jump = "green_slime_jump",
23 death = "green_slime_death",
24 damage = "green_slime_damage",
25 attack = "green_slime_attack",
26 distance = 16,
28 damage = 4,
29 reach = 3,
30 armor = 100,
31 drops = {},
32 -- TODO: Fix animations
33 animation = {
34 speed_normal = 24,
35 speed_run = 48,
36 stand_start = 0,
37 stand_end = 23,
38 walk_start = 24,
39 walk_end = 47,
40 run_start = 48,
41 run_end = 62,
42 hurt_start = 64,
43 hurt_end = 86,
44 death_start = 88,
45 death_end = 118,
47 water_damage = 0,
48 lava_damage = 4,
49 light_damage = 0,
50 fall_damage = 0,
51 view_range = 16,
52 attack_type = "dogfight",
53 passive = false,
54 jump = true,
55 walk_velocity = 2.5,
56 run_velocity = 2.5,
57 walk_chance = 0,
58 jump_height = 5.2,
59 jump_chance = 100,
60 fear_height = 60,
61 on_die = function(self, pos)
62 local angle, posadd
63 angle = math.random(0, math.pi*2)
64 for i=1,4 do
65 posadd = {x=math.cos(angle),y=0,z=math.sin(angle)}
66 posadd = vector.normalize(posadd)
67 local slime = minetest.add_entity(vector.add(pos, posadd), "mobs_mc:slime_small")
68 slime:setvelocity(vector.multiply(posadd, 1.5))
69 slime:setyaw(angle-math.pi/2)
70 angle = angle + math.pi/2
71 end
72 end,
74 mobs:register_mob("mobs_mc:slime_big", slime_big)
76 local slime_small = table.copy(slime_big)
77 slime_small.hp_min = 4
78 slime_small.hp_max = 4
79 slime_small.collisionbox = {-0.51, -0.01, -0.51, 0.51, 1.00, 0.51}
80 slime_small.visual_size = {x=6.25, y=6.25}
81 slime_small.damage = 3
82 slime_small.reach = 2.75
83 slime_small.walk_velocity = 1.3
84 slime_small.run_velocity = 1.3
85 slime_small.jump_height = 4.3
86 slime_small.on_die = function(self, pos)
87 local angle, posadd, dir
88 angle = math.random(0, math.pi*2)
89 for i=1,4 do
90 dir = {x=math.cos(angle),y=0,z=math.sin(angle)}
91 posadd = vector.multiply(vector.normalize(dir), 0.6)
92 local slime = minetest.add_entity(vector.add(pos, posadd), "mobs_mc:slime_tiny")
93 slime:setvelocity(dir)
94 slime:setyaw(angle-math.pi/2)
95 angle = angle + math.pi/2
96 end
97 end
98 mobs:register_mob("mobs_mc:slime_small", slime_small)
100 local slime_tiny = table.copy(slime_big)
101 slime_tiny.hp_min = 1
102 slime_tiny.hp_max = 1
103 slime_tiny.collisionbox = {-0.2505, -0.01, -0.2505, 0.2505, 0.50, 0.2505}
104 slime_tiny.visual_size = {x=3.125, y=3.125}
105 slime_tiny.damage = 0
106 slime_tiny.reach = 2.5
107 slime_tiny.drops = {
108 -- slimeball
109 {name = mobs_mc.items.slimeball,
110 chance = 1,
111 min = 0,
112 max = 2,},
114 slime_tiny.walk_velocity = 0.7
115 slime_tiny.run_velocity = 0.7
116 slime_tiny.jump_height = 3
117 slime_tiny.on_die = nil
119 mobs:register_mob("mobs_mc:slime_tiny", slime_tiny)
121 local smin = mobs_mc.spawn_height.overworld_min
122 local smax = mobs_mc.spawn_height.water - 23
124 mobs:spawn_specific("mobs_mc:slime_tiny", mobs_mc.spawn.solid, {"air"}, 0, minetest.LIGHT_MAX+1, 30, 12000, 4, smin, smax)
125 mobs:spawn_specific("mobs_mc:slime_small", mobs_mc.spawn.solid, {"air"}, 0, minetest.LIGHT_MAX+1, 30, 8500, 4, smin, smax)
126 mobs:spawn_specific("mobs_mc:slime_big", mobs_mc.spawn.solid, {"air"}, 0, minetest.LIGHT_MAX+1, 30, 10000, 4, smin, smax)
128 -- Magma cube
129 local magma_cube_big = {
130 type = "monster",
131 hp_min = 16,
132 hp_max = 16,
133 collisionbox = {-1.02, -0.01, -1.02, 1.02, 2.03, 1.02},
134 visual_size = {x=12.5, y=12.5},
135 textures = {{ "mobs_mc_magmacube.png" }},
136 visual = "mesh",
137 mesh = "mobs_mc_magmacube.b3d",
138 blood_texture = "mobs_mc_magmacube_blood.png",
139 makes_footstep_sound = true,
140 sounds = {
141 jump = "green_slime_jump",
142 death = "green_slime_death",
143 damage = "green_slime_damage",
144 attack = "green_slime_attack",
145 distance = 16,
147 walk_velocity = 4,
148 run_velocity = 4,
149 damage = 6,
150 reach = 3,
151 armor = 40,
152 drops = {
153 {name = mobs_mc.items.magma_cream,
154 chance = 4,
155 min = 1,
156 max = 1,},
158 -- TODO: Fix animations
159 animation = {
160 speed_normal = 24,
161 speed_run = 48,
162 stand_start = 0,
163 stand_end = 23,
164 walk_start = 24,
165 walk_end = 47,
166 run_start = 48,
167 run_end = 62,
168 hurt_start = 64,
169 hurt_end = 86,
170 death_start = 88,
171 death_end = 118,
173 water_damage = 0,
174 lava_damage = 0,
175 light_damage = 0,
176 fall_damage = 0,
177 view_range = 16,
178 attack_type = "dogfight",
179 passive = false,
180 jump = true,
181 jump_height = 8,
182 walk_chance = 0,
183 jump_chance = 100,
184 fear_height = 100000,
185 on_die = function(self, pos)
186 local angle, posadd
187 angle = math.random(0, math.pi*2)
188 for i=1,3 do
189 posadd = {x=math.cos(angle),y=0,z=math.sin(angle)}
190 posadd = vector.normalize(posadd)
191 local mob = minetest.add_entity(vector.add(pos, posadd), "mobs_mc:magma_cube_small")
192 mob:setvelocity(vector.multiply(posadd, 1.5))
193 mob:setyaw(angle-math.pi/2)
194 angle = angle + (math.pi*2) / 3
196 end,
198 mobs:register_mob("mobs_mc:magma_cube_big", magma_cube_big)
200 local magma_cube_small = table.copy(magma_cube_big)
201 magma_cube_small.hp_min = 4
202 magma_cube_small.hp_max = 4
203 magma_cube_small.collisionbox = {-0.51, -0.01, -0.51, 0.51, 1.00, 0.51}
204 magma_cube_small.visual_size = {x=6.25, y=6.25}
205 magma_cube_small.damage = 3
206 magma_cube_small.reach = 2.75
207 magma_cube_small.walk_velocity = .8
208 magma_cube_small.run_velocity = 2.6
209 magma_cube_small.jump_height = 6
210 magma_cube_small.damage = 4
211 magma_cube_small.reach = 2.75
212 magma_cube_small.armor = 70
213 magma_cube_small.on_die = function(self, pos)
214 local angle, posadd, dir
215 angle = math.random(0, math.pi*2)
216 for i=1,4 do
217 dir = vector.normalize({x=math.cos(angle),y=0,z=math.sin(angle)})
218 posadd = vector.multiply(dir, 0.6)
219 local mob = minetest.add_entity(vector.add(pos, posadd), "mobs_mc:magma_cube_tiny")
220 mob:setvelocity(dir)
221 mob:setyaw(angle-math.pi/2)
222 angle = angle + math.pi/2
225 mobs:register_mob("mobs_mc:magma_cube_small", magma_cube_small)
227 local magma_cube_tiny = table.copy(magma_cube_big)
228 magma_cube_tiny.hp_min = 1
229 magma_cube_tiny.hp_max = 1
230 magma_cube_tiny.collisionbox = {-0.2505, -0.01, -0.2505, 0.2505, 0.50, 0.2505}
231 magma_cube_tiny.visual_size = {x=3.125, y=3.125}
232 magma_cube_tiny.walk_velocity = 1.02
233 magma_cube_tiny.run_velocity = 1.02
234 magma_cube_tiny.jump_height = 4
235 magma_cube_tiny.damage = 3
236 magma_cube_tiny.reach = 2.5
237 magma_cube_tiny.armor = 85
238 magma_cube_tiny.drops = {}
239 magma_cube_tiny.on_die = nil
241 mobs:register_mob("mobs_mc:magma_cube_tiny", magma_cube_tiny)
244 local mmin = mobs_mc.spawn_height.nether_min
245 local mmax = mobs_mc.spawn_height.nether_max
247 mobs:spawn_specific("mobs_mc:magma_cube_tiny", mobs_mc.spawn.nether, {"air"}, 0, minetest.LIGHT_MAX+1, 30, 15000, 4, mmin, mmax)
248 mobs:spawn_specific("mobs_mc:magma_cube_small", mobs_mc.spawn.nether, {"air"}, 0, minetest.LIGHT_MAX+1, 30, 15500, 4, mmin, mmax)
249 mobs:spawn_specific("mobs_mc:magma_cube_big", mobs_mc.spawn.nether, {"air"}, 0, minetest.LIGHT_MAX+1, 30, 16000, 4, mmin, mmax)
251 mobs:spawn_specific("mobs_mc:magma_cube_tiny", mobs_mc.spawn.nether_fortress, {"air"}, 0, minetest.LIGHT_MAX+1, 30, 11000, 4, mmin, mmax)
252 mobs:spawn_specific("mobs_mc:magma_cube_small", mobs_mc.spawn.nether_fortress, {"air"}, 0, minetest.LIGHT_MAX+1, 30, 11100, 4, mmin, mmax)
253 mobs:spawn_specific("mobs_mc:magma_cube_big", mobs_mc.spawn.nether_fortress, {"air"}, 0, minetest.LIGHT_MAX+1, 30, 11200, 4, mmin, mmax)
256 -- Compability
257 mobs:alias_mob("mobs_mc:greensmall", "mobs_mc:slime_tiny")
258 mobs:alias_mob("mobs_mc:greenmedium", "mobs_mc:slime_small")
259 mobs:alias_mob("mobs_mc:greenbig", "mobs_mc:slime_big")
260 mobs:alias_mob("mobs_mc:lavasmall", "mobs_mc:magma_cube_tiny")
261 mobs:alias_mob("mobs_mc:lavamedium", "mobs_mc:magma_cube_small")
262 mobs:alias_mob("mobs_mc:lavabig", "mobs_mc:magma_cube_big")
264 -- spawn eggs
265 mobs:register_egg("mobs_mc:magma_cube_big", S("Magma Cube"), "mobs_mc_spawn_icon_magmacube.png")
266 mobs:register_egg("mobs_mc:slime_big", S("Slime"), "mobs_mc_spawn_icon_slime.png")
269 if minetest.settings:get_bool("log_mods") then
270 minetest.log("action", "MC Slimes loaded")