]> git.lizzy.rs Git - Crafter.git/blobdiff - mods/mob/init.lua
Make chickens spawn
[Crafter.git] / mods / mob / init.lua
index 7f1be22e8f4fcf43371cc926e5e8c363757e4505..d788d405f55b9e910448c9ed9e8e158c4c557bb0 100644 (file)
@@ -75,6 +75,70 @@ mobs.register_mob(
 )
 
 
+mobs.register_mob(
+       {
+        mobname = "chicken",
+        physical = true,
+        collide_with_objects = false,
+        collisionbox = {-0.225, 0, -0.225, 0.225, 0.675, 0.225},
+        visual = "mesh",
+        visual_size = {x = 3, y = 3},
+        mesh = "chicken.b3d",
+        textures = {
+                --blank out the first two to create adult pig
+               "chicken.png"
+        },
+        
+        --these are used to anchor a point to the head position
+
+
+        -----
+        head_bone = "head",
+        debug_head_pos = false,
+        rotational_correction = -math.pi/2,
+        head_directional_offset = 0.2, --used in vector.multiply(minetest.yaw_to_dir(body_yaw),head_offset)
+        head_height_offset = 0.82, --added to the base y position
+        --use this to correct the head position initially because it becomes severly offset - look at your blender model to get this perfect
+        head_position_correction = vector.new(0,1.8,-0.89),
+        --this is used to tell the game the orientation of the bone (swaps x to and y, then z and y)
+        head_coord = "vertical",
+        flip_pitch = true,
+        -----
+        
+        is_visible = true,
+        pointable = true,
+        automatic_face_movement_dir = 90,
+        automatic_face_movement_max_rotation_per_sec = 300,
+        makes_footstep_sound = false,
+        hp = 10,
+        gravity = {x = 0, y = -9.81, z = 0},
+        movement_type = "walk",
+        max_speed = 5,
+        state = 0,
+        view_distance = 15,
+        
+        item_drop = "mob:egg", 
+        standing_frame = {x=20,y=20},
+        moving_frame = {x=0,y=20},
+        animation_multiplier = 20,
+        ----
+        ----
+        death_rotation = "z",
+        
+        hurt_sound = "chicken_hurt",
+        die_sound = "chicken_die",
+        
+        
+        hostile = false,
+        attacked_hostile = false,
+        attack_type = "punch",
+        group_attack = true,
+        --explosion_radius = 4, -- how far away the mob has to be to initialize the explosion
+        --explosion_power = 7, -- how big the explosion has to be
+        --explosion_time = 3, -- how long it takes for a mob to explode
+       }
+)
+
 mobs.register_mob(
        {
         mobname = "snowman",
@@ -92,7 +156,7 @@ mobs.register_mob(
 
 
         -----
-        --head_bone = "head",
+        --head_bone = "Bone",
         debug_head_pos = false,
         head_directional_offset = 0, --used in vector.multiply(minetest.yaw_to_dir(body_yaw),head_offset)
         head_height_offset = 1.625, --added to the base y position
@@ -105,7 +169,7 @@ mobs.register_mob(
         
         is_visible = true,
         pointable = true,
-        automatic_face_movement_dir = 0,
+        automatic_face_movement_dir = -90,
         automatic_face_movement_max_rotation_per_sec = 300,
         makes_footstep_sound = false,
         hp = 10,
@@ -121,7 +185,7 @@ mobs.register_mob(
         animation_multiplier = 10,
         ----
         ----
-        death_rotation = "x",
+        death_rotation = "z",
         
         hurt_sound = "wool",
         die_sound = "wool",
@@ -132,6 +196,29 @@ mobs.register_mob(
         projectile_type = "weather:snowball",
         projectile_timer_cooldown = 1,
 
+        custom_function = function(self,dtime,moveresult)
+               if moveresult and moveresult.touching_ground then
+                       local pos = vector.floor(vector.add(self.object:get_pos(),0.5))
+
+                       if self.custom_old_pos and not vector.equals(pos,self.custom_old_pos) then
+                               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
+                                       minetest.set_node(pos,{name="weather:snow"})
+                               end
+                       end
+                       self.custom_old_pos = pos
+               end
+        end,
+
+        custom_timer = 0.75,
+        custom_timer_function = function(self,dtime)
+               if weather_type and weather_type ~= 1 then
+                       self.object:punch(self.object, 2, 
+                               {
+                               full_punch_interval=1.5,
+                               damage_groups = {damage=2},
+                               })
+               end
+        end,
        }
 )
 
@@ -268,17 +355,18 @@ mobs.register_mob(
        textures = {
                "slime.png"
        },
+       collision_boundary = 2.5,
        is_visible = true,
        pointable = true,
        automatic_face_movement_dir = 90,
        automatic_face_movement_max_rotation_per_sec = 300,
        makes_footstep_sound = false,
-       hp = 40,
+       hp = 32,
        gravity = {x = 0, y = -9.81, z = 0},
        movement_type = "jump",
        make_jump_noise = true,
        max_speed = 5,
-       hostile = true,
+       hostile = false,
        state = 0,
        view_distance = 20,
        death_rotation = "z",
@@ -311,7 +399,7 @@ mobs.register_mob(
        automatic_face_movement_dir = 90,
        automatic_face_movement_max_rotation_per_sec = 300,
        makes_footstep_sound = false,
-       hp = 20,
+       hp = 10,
        gravity = {x = 0, y = -9.81, z = 0},
        movement_type = "jump",
        make_jump_noise = true,
@@ -350,7 +438,7 @@ mobs.register_mob(
        automatic_face_movement_dir = 90,
        automatic_face_movement_max_rotation_per_sec = 300,
        makes_footstep_sound = false,
-       hp = 5,
+       hp = 4,
        gravity = {x = 0, y = -9.81, z = 0},
        movement_type = "jump",
        make_jump_noise = true,
@@ -367,61 +455,6 @@ mobs.register_mob(
 )
 
 --[[
-mobs.register_mob(
-       {
-        mobname = "flying_pig",
-        physical = true,
-        collide_with_objects = false,
-        collisionbox = {-0.37, -0.4, -0.37, 0.37, 0.5, 0.37},
-        visual = "mesh",
-        visual_size = {x = 3, y = 3},
-        mesh = "pig.x",
-        textures = {
-               "flying_pig_body.png","flying_pig_leg.png","flying_pig_leg.png","flying_pig_leg.png","flying_pig_leg.png"
-       },
-        is_visible = true,
-        pointable = true,
-        automatic_face_movement_dir = -90.0,
-        automatic_face_movement_max_rotation_per_sec = 300,
-        makes_footstep_sound = false,
-        hp = 10,
-        gravity = {x = 0, y = -1, z = 0},
-        movement_type = "jump",
-        max_speed = 5,
-        hostile = true,
-        state = 0,
-        view_distance = 50,
-        item_drop = "main:gold",
-        item_minimum = 4,
-        item_amount = 5,
-         
-        standing_frame = {x=0,y=0},
-        moving_frame = {x=5,y=15},
-        animation_multiplier = 5,
-        ----
-         
-        has_head = true, --remove this when mesh based head rotation is implemented
-        head_visual = "mesh",
-        head_visual_size = {x = 1.1, y = 1.1},
-        head_mesh = "pig_head.x",
-        head_textures ={"flying_pig_head.png","flying_pig_nose.png"},
-        head_mount = vector.new(0,1.2,1.9),
-        
-        death_rotation = "z",
-        
-        hurt_sound = "pig",
-        die_sound = "pig_die",
-        
-        attack_type = "projectile",
-        projectile_timer_cooldown = 5,
-        projectile_type = "tnt:tnt",
-        
-        --explosion_radius = 4, -- how far away the mob has to be to initialize the explosion
-        --explosion_power = 7, -- how big the explosion has to be
-        --explosion_time = 3, -- how long it takes for a mob to explode
-       }
-)
-
 
 
 mobs.register_mob(
@@ -498,10 +531,10 @@ mobs.register_mob(
         pointable = true,
         automatic_face_movement_max_rotation_per_sec = 300,
         makes_footstep_sound = false,
-        hp = 40,
+        hp = 27,
         gravity = {x = 0, y = -9.81, z = 0},
         movement_type = "walk",
-        max_speed = 4,
+        max_speed = 5.5,
         hostile = true,
         hostile_cooldown = false,
         state = 0,
@@ -564,7 +597,7 @@ mobs.register_mob(
         pointable = true,
         automatic_face_movement_max_rotation_per_sec = 300,
         makes_footstep_sound = false,
-        hp = 70,
+        hp = 40,
         gravity = {x = 0, y = -9.81, z = 0},
         movement_type = "walk",
         max_speed = 9,
@@ -630,8 +663,6 @@ mobs.register_mob(
         },
         
         --these are used to anchor a point to the head position
-
-
         -----
         head_bone = "body.head",
         debug_head_pos = false,
@@ -649,10 +680,10 @@ mobs.register_mob(
         automatic_face_movement_dir = 90,
         automatic_face_movement_max_rotation_per_sec = 300,
         makes_footstep_sound = false,
-        hp = 40,
+        hp = 30,
         gravity = {x = 0, y = -9.81, z = 0},
         movement_type = "walk",
-        max_speed = 5,
+        max_speed = 6,
         state = 0,
         view_distance = 15,
         
@@ -668,12 +699,33 @@ mobs.register_mob(
         die_sound = "spider_die",
         
         
+        pathfinds = true,
+
         hostile = true,
-        attacked_hostile = false,
+        friendly_in_daylight = true,
+        attacked_hostile = true,
         attack_type = "punch",
         group_attack = true,
+
+        custom_on_activate = function(self)
+               if math.random() > 0.998 then
+                       local obj = minetest.add_entity(self.object:get_pos(),"mob:pig")
+                       local obj2 = minetest.add_entity(self.object:get_pos(),"tnt:tnt")
+                       local obj3 = minetest.add_entity(self.object:get_pos(),"boat:boat")
+
+                       obj2:get_luaentity().timer = 7
+                       obj2:get_luaentity().radius = 7
+
+                       obj:set_attach(self.object,"",vector.new(0,3,0),vector.new(0,90,0))
+                       obj2:set_attach(obj,"",vector.new(0,4.5,0),vector.new(0,90,0))
+                       obj3:set_attach(obj2,"",vector.new(0,6.5,0),vector.new(0,0,0))
+
+                       obj:set_properties({visual_size={x=1,y=1}})
+                       obj2:set_properties({visual_size={x=1/3,y=1/3}})
+               end
+        end
         --explosion_radius = 4, -- how far away the mob has to be to initialize the explosion
         --explosion_power = 7, -- how big the explosion has to be
         --explosion_time = 3, -- how long it takes for a mob to explode
        }
-)
\ No newline at end of file
+)