]> git.lizzy.rs Git - Crafter.git/blob - mods/mob/init.lua
10cc5fb57f54db3f499d1e6fbc8f0e963a8dff4e
[Crafter.git] / mods / mob / init.lua
1 --this is where mobs are defined
2
3 --this is going to be used to set an active mob limit
4 global_mob_amount = 0
5 mob_limit = 100
6
7 local path = minetest.get_modpath(minetest.get_current_modname())
8
9 dofile(path.."/spawning.lua")
10 dofile(path.."/api/api_hook.lua")
11 dofile(path.."/items.lua")
12 dofile(path.."/chatcommands.lua")
13
14
15 mobs.register_mob(
16         {
17          mobname = "pig",
18          physical = true,
19          collide_with_objects = false,
20          collisionbox = {-0.37, 0, -0.37, 0.37, 0.85, 0.37},
21          visual = "mesh",
22          visual_size = {x = 3, y = 3},
23          mesh = "pig.b3d",
24          textures = {
25                  --blank out the first two to create adult pig
26                 "pig.png"
27          },
28          
29          --these are used to anchor a point to the head position
30
31
32          -----
33          head_bone = "head",
34          debug_head_pos = false,
35          head_directional_offset = 0.5, --used in vector.multiply(minetest.yaw_to_dir(body_yaw),head_offset)
36          head_height_offset = 0.8, --added to the base y position
37          --use this to correct the head position initially because it becomes severly offset - look at your blender model to get this perfect
38          head_position_correction = vector.new(0,3,-0.5),
39          --this is used to tell the game the orientation of the bone (swaps x to and y, then z and y)
40          head_coord = "horizontal",
41          -----
42          
43          is_visible = true,
44          pointable = true,
45          automatic_face_movement_dir = 0,
46          automatic_face_movement_max_rotation_per_sec = 300,
47          makes_footstep_sound = false,
48          hp = 10,
49          gravity = {x = 0, y = -9.81, z = 0},
50          movement_type = "walk",
51          max_speed = 5,
52          state = 0,
53          view_distance = 15,
54          
55          item_drop = "mob:raw_porkchop", 
56          standing_frame = {x=0,y=0},
57          moving_frame = {x=0,y=40},
58          animation_multiplier = 20,
59          ----
60          ----
61          death_rotation = "x",
62          
63          hurt_sound = "pig",
64          die_sound = "pig_die",
65          
66          
67          hostile = false,
68          attacked_hostile = false,
69          attack_type = "punch",
70          group_attack = true,
71          --explosion_radius = 4, -- how far away the mob has to be to initialize the explosion
72          --explosion_power = 7, -- how big the explosion has to be
73          --explosion_time = 3, -- how long it takes for a mob to explode
74         }
75 )
76
77
78 mobs.register_mob(
79         {
80          mobname = "chicken",
81          physical = true,
82          collide_with_objects = false,
83          collisionbox = {-0.225, 0, -0.225, 0.225, 0.675, 0.225},
84          visual = "mesh",
85          visual_size = {x = 3, y = 3},
86          mesh = "chicken.b3d",
87          textures = {
88                  --blank out the first two to create adult pig
89                 "chicken.png"
90          },
91          
92          --these are used to anchor a point to the head position
93
94
95          -----
96          head_bone = "head",
97          debug_head_pos = false,
98          rotational_correction = -math.pi/2,
99          head_directional_offset = 0.2, --used in vector.multiply(minetest.yaw_to_dir(body_yaw),head_offset)
100          head_height_offset = 0.82, --added to the base y position
101          --use this to correct the head position initially because it becomes severly offset - look at your blender model to get this perfect
102          head_position_correction = vector.new(0,1.8,-0.89),
103          --this is used to tell the game the orientation of the bone (swaps x to and y, then z and y)
104          head_coord = "vertical",
105          flip_pitch = true,
106          -----
107          
108          is_visible = true,
109          pointable = true,
110          automatic_face_movement_dir = 90,
111          automatic_face_movement_max_rotation_per_sec = 300,
112          makes_footstep_sound = false,
113          hp = 10,
114          gravity = {x = 0, y = -9.81, z = 0},
115          movement_type = "walk",
116          max_speed = 5,
117          state = 0,
118          view_distance = 15,
119          
120          item_drop = "mob:egg", 
121          standing_frame = {x=20,y=20},
122          moving_frame = {x=0,y=20},
123          animation_multiplier = 15,
124          ----
125          ----
126          death_rotation = "z",
127          
128          hurt_sound = "chicken_hurt",
129          die_sound = "chicken_die",
130          
131          
132          hostile = false,
133          attacked_hostile = false,
134          attack_type = "punch",
135          group_attack = true,
136          --explosion_radius = 4, -- how far away the mob has to be to initialize the explosion
137          --explosion_power = 7, -- how big the explosion has to be
138          --explosion_time = 3, -- how long it takes for a mob to explode
139         }
140 )
141
142 mobs.register_mob(
143         {
144          mobname = "snowman",
145          physical = true,
146          collide_with_objects = false,
147          collisionbox = {-0.37, 0, -0.37, 0.37, 1.75, 0.37},
148          visual = "mesh",
149          visual_size = {x = 3, y = 3},
150          mesh = "snowman.b3d",
151          textures = {
152                 "snowman.png","snowman.png","snowman.png","snowman.png","snowman.png","snowman.png",
153          },
154          
155          --these are used to anchor a point to the head position
156
157
158          -----
159          --head_bone = "Bone",
160          debug_head_pos = false,
161          head_directional_offset = 0, --used in vector.multiply(minetest.yaw_to_dir(body_yaw),head_offset)
162          head_height_offset = 1.625, --added to the base y position
163          --use this to correct the head position initially because it becomes severly offset - look at your blender model to get this perfect
164          head_position_correction = vector.new(0,4.6,0),
165          --this is used to tell the game the orientation of the bone (swaps x to and y, then z and y)
166          head_coord = "vertical",
167          --rotational_correction = math.pi/2,
168          -----
169          
170          is_visible = true,
171          pointable = true,
172          automatic_face_movement_dir = -90,
173          automatic_face_movement_max_rotation_per_sec = 300,
174          makes_footstep_sound = false,
175          hp = 10,
176          gravity = {x = 0, y = -9.81, z = 0},
177          movement_type = "walk",
178          max_speed = 5,
179          state = 0,
180          view_distance = 15,
181          
182          item_drop = "weather:snowball", 
183          standing_frame = {x=0,y=0},
184          moving_frame = {x=0,y=0},
185          animation_multiplier = 10,
186          ----
187          ----
188          death_rotation = "z",
189          
190          hurt_sound = "wool",
191          die_sound = "wool",
192          
193          
194          hostile = true,
195          attack_type = "projectile",
196          projectile_type = "weather:snowball",
197          projectile_timer_cooldown = 1,
198
199          custom_function = function(self,dtime,moveresult)
200                 if moveresult and moveresult.touching_ground then
201                         local pos = vector.floor(vector.add(self.object:get_pos(),0.5))
202
203                         if self.custom_old_pos and not vector.equals(pos,self.custom_old_pos) then
204                                 if minetest.get_nodedef(minetest.get_node(pos).name,"buildable_to") == true and minetest.get_nodedef(minetest.get_node(vector.new(pos.x,pos.y-1,pos.z)).name,"buildable_to") == false then
205                                         minetest.set_node(pos,{name="weather:snow"})
206                                 end
207                         end
208                         self.custom_old_pos = pos
209                 end
210          end,
211
212          custom_timer = 0.75,
213          custom_timer_function = function(self,dtime)
214                 if weather_type and weather_type ~= 1 then
215                         self.object:punch(self.object, 2, 
216                                 {
217                                 full_punch_interval=1.5,
218                                 damage_groups = {damage=2},
219                                 })
220                 end
221          end,
222         }
223 )
224
225 mobs.register_mob(
226         {
227          mobname = "phyg",
228          physical = true,
229          collide_with_objects = false,
230          collisionbox = {-0.37, 0, -0.37, 0.37, 0.85, 0.37},
231          visual = "mesh",
232          visual_size = {x = 3, y = 3},
233          mesh = "phyg.b3d",
234          textures = {
235                  --blank out the first two to create adult pig
236                 "phyg.png","wings.png"
237          },
238          
239          --these are used to anchor a point to the head position
240
241
242          -----
243          head_bone = "head",
244          debug_head_pos = false,
245          head_directional_offset = 0.5, --used in vector.multiply(minetest.yaw_to_dir(body_yaw),head_offset)
246          head_height_offset = 0.8, --added to the base y position
247          --use this to correct the head position initially because it becomes severly offset - look at your blender model to get this perfect
248          head_position_correction = vector.new(0,3,-0.5),
249          --this is used to tell the game the orientation of the bone (swaps x to and y, then z and y)
250          head_coord = "horizontal",
251          -----
252          
253          is_visible = true,
254          pointable = true,
255          automatic_face_movement_dir = 0,
256          automatic_face_movement_max_rotation_per_sec = 300,
257          makes_footstep_sound = false,
258          takes_fall_damage = false,
259          make_jump_noise = false,
260          hp = 10,
261          gravity = {x = 0, y = -1, z = 0},
262          movement_type = "walk",
263          max_speed = 5,
264          state = 0,
265          view_distance = 15,
266          
267          item_drop = "main:gold", 
268          item_minimum = 4,
269          item_max = 5,
270
271          standing_frame = {x=0,y=0},
272          moving_frame = {x=0,y=40},
273          animation_multiplier = 20,
274          ----
275          ----
276          death_rotation = "x",
277          
278          hurt_sound = "pig",
279          die_sound = "pig_die",
280          
281          
282          hostile = false,
283          attacked_hostile = false,
284          attack_type = "punch",
285          group_attack = true,
286          --explosion_radius = 4, -- how far away the mob has to be to initialize the explosion
287          --explosion_power = 7, -- how big the explosion has to be
288          --explosion_time = 3, -- how long it takes for a mob to explode
289         }
290 )
291
292
293 mobs.register_mob(
294         {
295         mobname = "big_slime",
296         physical = true,
297         collide_with_objects = false,
298         collisionbox = {-1.25, 0, -1.25, 1.25, 2.5, 1.25},
299         visual = "mesh",
300         visual_size = {x = 15, y = 15},
301         mesh = "slime.b3d",
302         textures = {
303                 "slime.png"
304         },
305         collision_boundary = 2.5,
306         is_visible = true,
307         pointable = true,
308         automatic_face_movement_dir = 90,
309         automatic_face_movement_max_rotation_per_sec = 300,
310         makes_footstep_sound = false,
311         hp = 32,
312         gravity = {x = 0, y = -9.81, z = 0},
313         movement_type = "jump",
314         make_jump_noise = true,
315         max_speed = 5,
316         hostile = true,
317         state = 0,
318         view_distance = 20,
319         death_rotation = "z",
320         hurt_sound = "slime_die",
321         die_sound = "slime_die",
322         attack_type = "punch",
323         custom_on_death = function(self)
324                 local pos = self.object:get_pos()
325                 for i = 1,4 do
326                         minetest.add_entity(pos,"mob:medium_slime")
327                 end
328         end,
329         }
330 )
331
332 mobs.register_mob(
333         {
334         mobname = "medium_slime",
335         physical = true,
336         collide_with_objects = false,
337         collisionbox = {-0.625, 0, -0.625, 0.625, 1.25, 0.625},
338         visual = "mesh",
339         visual_size = {x = 7.5, y = 7.5},
340         mesh = "slime.b3d",
341         textures = {
342                 "slime.png"
343         },
344         is_visible = true,
345         pointable = true,
346         automatic_face_movement_dir = 90,
347         automatic_face_movement_max_rotation_per_sec = 300,
348         makes_footstep_sound = false,
349         hp = 10,
350         gravity = {x = 0, y = -9.81, z = 0},
351         movement_type = "jump",
352         make_jump_noise = true,
353         max_speed = 5,
354         hostile = true,
355         state = 0,
356         view_distance = 20,
357         death_rotation = "z",
358         hurt_sound = "slime_die",
359         die_sound = "slime_die",
360         attack_type = "punch",
361         custom_on_death = function(self)
362                 local pos = self.object:get_pos()
363                 pos.y = pos.y + 0.2
364                 for i = 1,4 do
365                         minetest.add_entity(pos,"mob:small_slime")
366                 end
367         end,
368         }
369 )
370
371 mobs.register_mob(
372         {
373         mobname = "small_slime",
374         physical = true,
375         collide_with_objects = false,
376         collisionbox = {-0.3, 0, -0.3, 0.3, 0.6, 0.3},
377         visual = "mesh",
378         visual_size = {x = 3.7, y = 3.7},
379         mesh = "slime.b3d",
380         textures = {
381                 "slime.png"
382         },
383         is_visible = true,
384         pointable = true,
385         automatic_face_movement_dir = 90,
386         automatic_face_movement_max_rotation_per_sec = 300,
387         makes_footstep_sound = false,
388         hp = 4,
389         gravity = {x = 0, y = -9.81, z = 0},
390         movement_type = "jump",
391         make_jump_noise = true,
392         max_speed = 5,
393         hostile = true,
394         state = 0,
395         view_distance = 20,
396         death_rotation = "z",
397         hurt_sound = "slime_die",
398         die_sound = "slime_die",
399         attack_type = "punch",
400         item_drop = "mob:slimeball"
401         }
402 )
403
404 --[[
405
406
407 mobs.register_mob(
408         {
409          mobname = "creepig",
410          physical = true,
411          collide_with_objects = false,
412          collisionbox = {-0.37, -0.4, -0.37, 0.37, 0.5, 0.37},
413          visual = "mesh",
414          visual_size = {x = 3, y = 3},
415          mesh = "pig.x",
416          textures = {
417                 "creepig_body.png","creepig_leg.png","creepig_leg.png","creepig_leg.png","creepig_leg.png"
418         },
419          is_visible = true,
420          pointable = true,
421          automatic_face_movement_dir = -90.0,
422          automatic_face_movement_max_rotation_per_sec = 300,
423          makes_footstep_sound = false,
424          hp = 10,
425          gravity = {x = 0, y = -9.81, z = 0},
426          movement_type = "walk",
427          max_speed = 4,
428          hostile = true,
429          state = 0,
430          view_distance = 20,
431          item_drop = "mob:cooked_porkchop",
432           
433          standing_frame = {x=0,y=0},
434          moving_frame = {x=5,y=15},
435          animation_multiplier = 5,
436          ----
437           
438          has_head = true, --remove this when mesh based head rotation is implemented
439          head_visual = "mesh",
440          head_visual_size = {x = 1.1, y = 1.1},
441          head_mesh = "pig_head.x",
442          head_textures ={"creepig_head.png","creepig_nose.png"},
443          head_mount = vector.new(0,1.2,1.9),
444          
445          death_rotation = "z",
446          
447          hurt_sound = "pig",
448          die_sound = "pig_die",
449          
450          attack_type = "explode",
451          --projectile_timer_cooldown = 5,
452          --projectile_type = "tnt:tnt",
453          
454          explosion_radius = 2, -- how far away the mob has to be to initialize the explosion
455          explosion_power = 7, -- how big the explosion has to be
456          explosion_time = 5, -- how long it takes for a mob to explode
457          
458          die_in_light = true,
459          die_in_light_level = 12,
460         }
461 )
462
463 ]]--
464
465 mobs.register_mob(
466         {
467          mobname = "creeper",
468          physical = true,
469          collide_with_objects = false,
470          collisionbox = {-0.37,0, -0.37, 0.37, 1.5, 0.37},
471          visual = "mesh",
472          visual_size = {x = 3.2, y = 3.2},
473          mesh = "creeper.b3d",
474          textures = {
475                 "creeper.png"
476         },
477          is_visible = true,
478          pointable = true,
479          automatic_face_movement_max_rotation_per_sec = 300,
480          makes_footstep_sound = false,
481          hp = 27,
482          gravity = {x = 0, y = -9.81, z = 0},
483          movement_type = "walk",
484          max_speed = 5.5,
485          hostile = true,
486          hostile_cooldown = false,
487          state = 0,
488          view_distance = 32,
489          item_drop = "mob:gunpowder",
490           
491          standing_frame = {x=0,y=0},
492          moving_frame = {x=0,y=40},
493          animation_multiplier = 20,
494          ----
495          pathfinds = true,
496          
497          --these are used to anchor a point to the head position
498          -----
499          automatic_face_movement_dir = 0,
500          head_bone = "head",
501          debug_head_pos = false,
502          --this always has to be slightly positive
503          head_directional_offset = 0.01,
504          head_height_offset = 1.45, --added to the base y position
505          --use this to correct the head position initially because it becomes severly offset - look at your blender model to get this perfect
506          head_position_correction = vector.new(0,2.4,0),
507          head_coord = "vertical",
508          -----
509           
510          
511          death_rotation = "x",
512          
513          hurt_sound = "creeper_hurt",
514          die_sound = "creeper_hurt",
515          
516          attack_type = "explode",
517          --projectile_timer_cooldown = 5,
518          --projectile_type = "tnt:tnt",
519          
520          explosion_radius = 4, -- how far away the mob has to be to initialize the explosion
521          explosion_power = 4, -- how big the explosion has to be
522          explosion_time = 3, -- how long it takes for a mob to explode
523          
524          die_in_light = false,
525          --die_in_light_level = 12,
526         }
527 )
528
529
530
531 mobs.register_mob(
532         {
533          mobname = "nitro_creeper",
534          physical = true,
535          collide_with_objects = false,
536          collisionbox = {-0.37,0, -0.37, 0.37, 1.5, 0.37},
537          visual = "mesh",
538          visual_size = {x = 3.2, y = 3.2},
539          mesh = "creeper.b3d",
540          textures = {
541                 "nitro_creeper.png"
542         },
543          is_visible = true,
544          pointable = true,
545          automatic_face_movement_max_rotation_per_sec = 300,
546          makes_footstep_sound = false,
547          hp = 40,
548          gravity = {x = 0, y = -9.81, z = 0},
549          movement_type = "walk",
550          max_speed = 9,
551          hostile = true,
552          hostile_cooldown = false,
553          state = 0,
554          view_distance = 40,
555          item_drop = "mob:gunpowder",
556
557          damage_color = "blue",
558           
559          standing_frame = {x=0,y=0},
560          moving_frame = {x=0,y=40},
561          animation_multiplier = 20,
562          ----
563          pathfinds = true,
564          
565          --these are used to anchor a point to the head position
566          -----
567          automatic_face_movement_dir = 0,
568          head_bone = "head",
569          debug_head_pos = false,
570          --this always has to be slightly positive
571          head_directional_offset = 0.01,
572          head_height_offset = 1.45, --added to the base y position
573          --use this to correct the head position initially because it becomes severly offset - look at your blender model to get this perfect
574          head_position_correction = vector.new(0,2.4,0),
575          head_coord = "vertical",
576          -----
577           
578          
579          death_rotation = "x",
580          
581          hurt_sound = "creeper_hurt",
582          die_sound = "creeper_hurt",
583          
584          attack_type = "explode",
585          --projectile_timer_cooldown = 5,
586          --projectile_type = "tnt:tnt",
587          
588          explosion_radius = 6, -- how far away the mob has to be to initialize the explosion
589          explosion_power = 14, -- how big the explosion is (radius)
590          explosion_time = 3, -- how long it takes for a mob to explode
591          explosion_blink_timer = 0.1, -- how fast the blinking happens
592          
593          die_in_light = false,
594          --die_in_light_level = 12,
595         }
596 )
597
598
599 mobs.register_mob(
600         {
601          mobname = "spider",
602          physical = true,
603          collide_with_objects = false,
604          collisionbox = {-0.37, 0, -0.37, 0.37, 0.85, 0.37},
605          visual = "mesh",
606          visual_size = {x = 3, y = 3},
607          mesh = "spider.b3d",
608          textures = {
609                 "spider.png"
610          },
611          
612          --these are used to anchor a point to the head position
613          -----
614          head_bone = "body.head",
615          debug_head_pos = false,
616          rotational_correction = -math.pi/2,
617          head_directional_offset = 0.3, --used in vector.multiply(minetest.yaw_to_dir(body_yaw),head_offset)
618          head_height_offset = 0.63, --added to the base y position
619          --use this to correct the head position initially because it becomes severly offset - look at your blender model to get this perfect
620          head_position_correction = vector.new(0,1.24,0),
621          --this is used to tell the game the orientation of the bone (swaps x to and y, then z and y)
622          head_coord = "horizontal",
623          -----
624          
625          is_visible = true,
626          pointable = true,
627          automatic_face_movement_dir = 90,
628          automatic_face_movement_max_rotation_per_sec = 300,
629          makes_footstep_sound = false,
630          hp = 30,
631          gravity = {x = 0, y = -9.81, z = 0},
632          movement_type = "walk",
633          max_speed = 6,
634          state = 0,
635          view_distance = 32,
636          
637          item_drop = "mob:string", 
638          standing_frame = {x=21,y=21},
639          moving_frame = {x=0,y=20},
640          animation_multiplier = 20,
641          ----
642          ----
643          death_rotation = "z",
644          
645          hurt_sound = "spider",
646          die_sound = "spider_die",
647          
648          
649          pathfinds = true,
650
651          hostile = true,
652          friendly_in_daylight = true,
653          attacked_hostile = true,
654          attack_type = "punch",
655          group_attack = true,
656
657          custom_on_activate = function(self)
658                 if math.random() > 0.998 then
659                         local obj = minetest.add_entity(self.object:get_pos(),"mob:pig")
660                         local obj2 = minetest.add_entity(self.object:get_pos(),"tnt:tnt")
661                         local obj3 = minetest.add_entity(self.object:get_pos(),"boat:boat")
662
663                         obj2:get_luaentity().timer = 7
664                         obj2:get_luaentity().radius = 7
665
666                         obj:set_attach(self.object,"",vector.new(0,3,0),vector.new(0,90,0))
667                         obj2:set_attach(obj,"",vector.new(0,4.5,0),vector.new(0,90,0))
668                         obj3:set_attach(obj2,"",vector.new(0,6.5,0),vector.new(0,0,0))
669
670                         obj:set_properties({visual_size={x=1,y=1}})
671                         obj2:set_properties({visual_size={x=1/3,y=1/3}})
672                 end
673          end
674          --explosion_radius = 4, -- how far away the mob has to be to initialize the explosion
675          --explosion_power = 7, -- how big the explosion has to be
676          --explosion_time = 3, -- how long it takes for a mob to explode
677         }
678 )