]> git.lizzy.rs Git - Crafter.git/commitdiff
Add in chicken and chicken eggs
authoroilboi <47129783+oilboi@users.noreply.github.com>
Sun, 24 May 2020 05:31:02 +0000 (01:31 -0400)
committeroilboi <47129783+oilboi@users.noreply.github.com>
Sun, 24 May 2020 05:31:02 +0000 (01:31 -0400)
16 files changed:
mods/mob/api/animation.lua
mods/mob/api/api_hook.lua
mods/mob/api/head_code.lua
mods/mob/api/timers.lua
mods/mob/init.lua
mods/mob/items.lua
mods/mob/models/chicken.b3d [new file with mode: 0644]
mods/mob/sounds/attributes.txt
mods/mob/sounds/chicken_die.1.ogg [new file with mode: 0644]
mods/mob/sounds/chicken_die.2.ogg [new file with mode: 0644]
mods/mob/sounds/chicken_hurt.1.ogg [new file with mode: 0644]
mods/mob/sounds/chicken_hurt.2.ogg [new file with mode: 0644]
mods/mob/sounds/chicken_hurt.3.ogg [new file with mode: 0644]
mods/mob/textures/attributes.txt
mods/mob/textures/chicken.png [new file with mode: 0644]
mods/mob/textures/egg.png [new file with mode: 0644]

index 1140d9b3deb50d26e856c4d46698b377ba8c2c13..6f3929333db7abdbab4c42804d2ab59e2c7634b1 100644 (file)
@@ -43,7 +43,7 @@ mobs.create_animation_functions = function(def,mob_register)
                        local acceleration = vector.new(goal.x-currentvel.x,0,goal.z-currentvel.z)
                        acceleration = vector.multiply(acceleration, 0.05)
                        self.object:add_velocity(acceleration)
-                       self.object:set_animation({x=0,y=0}, 15, 0, true)
+                       self.object:set_animation(def.standing_frame, 15, 0, true)
                end
        end
        return(mob_register)
index 7ddadf1207507717faa4006aa5de1efc009656c8..7f85373a27e410dbb2475489ec9578280fecc39e 100644 (file)
@@ -46,6 +46,7 @@ if def.head_bone then
        mob_register.head_rotation_offset = def.head_rotation_offset
        mob_register.head_position_correction = def.head_position_correction
        mob_register.head_coord = def.head_coord
+       mob_register.flip_pitch = def.flip_pitch
 else
        print("create some other functions to turn mob " .. def.mobname)
 end
index 863f81affaf40fe52162523f920d2286a2cc7623..6fe07e1423e6ae9547f70129b0f241ef879e21f4 100644 (file)
@@ -108,6 +108,9 @@ mobs.create_head_functions = function(def,mob_register)
                                                ---begin pitch calculation
                                                --feed a 2D coordinate flipped into dir to yaw to calculate pitch
                                                head_rotation.x = degrees(minetest.dir_to_yaw(vector.new(vector.distance(vector.new(pos.x,0,pos.z),vector.new(pos2.x,0,pos2.z)),0,pos.y-pos2.y))+(math.pi/2))
+                                               if self.flip_pitch then
+                                                       head_rotation.x = head_rotation.x * -1
+                                               end
                                                head_rotation.z = head_yaw
                                                self.object:set_bone_position(self.head_bone, head_position, head_rotation)
                                                return(true)
@@ -194,6 +197,9 @@ mobs.create_head_functions = function(def,mob_register)
                                                ---begin pitch calculation
                                                --feed a 2D coordinate flipped into dir to yaw to calculate pitch
                                                head_rotation.x = degrees(minetest.dir_to_yaw(vector.new(vector.distance(vector.new(pos.x,0,pos.z),vector.new(pos2.x,0,pos2.z)),0,pos.y-pos2.y))+(math.pi/2))
+                                               if self.flip_pitch then
+                                                       head_rotation.x = head_rotation.x * -1
+                                               end
                                                head_rotation.y = -head_yaw
                                                self.object:set_bone_position(self.head_bone, head_position, head_rotation)
                                                return(true)
index da1d5331ecc826545dccada1e803dbb554587b55..82ad6c892bf4b2ad485081edc1152ebc825b94da 100644 (file)
@@ -79,7 +79,8 @@ mobs.create_timer_functions = function(def,mob_register)
                        if self.friendly_in_daylight_timer >= 2 then
                                self.friendly_in_daylight_timer = 0
                                local pos = self.object:get_pos()
-                               if pos and minetest.get_node_light(pos) >= 13 then --1 greater than torch light
+                               local light = minetest.get_node_light(pos)
+                               if pos and light and light >= 13 then --1 greater than torch light
                                        if self.following == false then
                                                self.hostile = false
                                        end
index 2076cf3ea27b58e16bcb99d871aad0c51b1d789f..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",
@@ -391,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(
index 656f9d72208d39286b7dd767f074a6dd16936fb2..a47f66b526e4411ace91326dd916a37f9403cde5 100644 (file)
@@ -15,6 +15,13 @@ minetest.register_food("mob:cooked_porkchop",{
 })
 
 
+minetest.register_food("mob:egg",{
+       description = "Egg",
+       texture = "egg.png",
+       satiation=1,
+       hunger=3,
+})
+
 minetest.register_craftitem("mob:slimeball", {
        description = "Slimeball",
        inventory_image = "slimeball.png",
diff --git a/mods/mob/models/chicken.b3d b/mods/mob/models/chicken.b3d
new file mode 100644 (file)
index 0000000..8d4ccca
Binary files /dev/null and b/mods/mob/models/chicken.b3d differ
index 70870f98a565c7fc56a2bd5d38d7bea0abff93e8..ae21d899254b1d97153eb677b4da68389a303589 100644 (file)
@@ -6,4 +6,5 @@ slimedie1 https://freesound.org/people/ipaghost/sounds/335796/
 slimedie2 https://freesound.org/people/Breviceps/sounds/445118/
 critical https://freesound.org/people/FunWithSound/sounds/361482/
 creeper hurt - https://freesound.org/people/adcbicycle/sounds/14199/
-spider - https://freesound.org/people/columbia23/sounds/395395/ Attribution 3.0 Unported (CC BY 3.0)
\ No newline at end of file
+spider - https://freesound.org/people/columbia23/sounds/395395/ Attribution 3.0 Unported (CC BY 3.0)
+chicken - https://freesound.org/people/Breviceps/sounds/456803/ cc0
\ No newline at end of file
diff --git a/mods/mob/sounds/chicken_die.1.ogg b/mods/mob/sounds/chicken_die.1.ogg
new file mode 100644 (file)
index 0000000..e922dce
Binary files /dev/null and b/mods/mob/sounds/chicken_die.1.ogg differ
diff --git a/mods/mob/sounds/chicken_die.2.ogg b/mods/mob/sounds/chicken_die.2.ogg
new file mode 100644 (file)
index 0000000..450f01c
Binary files /dev/null and b/mods/mob/sounds/chicken_die.2.ogg differ
diff --git a/mods/mob/sounds/chicken_hurt.1.ogg b/mods/mob/sounds/chicken_hurt.1.ogg
new file mode 100644 (file)
index 0000000..1bd82e5
Binary files /dev/null and b/mods/mob/sounds/chicken_hurt.1.ogg differ
diff --git a/mods/mob/sounds/chicken_hurt.2.ogg b/mods/mob/sounds/chicken_hurt.2.ogg
new file mode 100644 (file)
index 0000000..df09f81
Binary files /dev/null and b/mods/mob/sounds/chicken_hurt.2.ogg differ
diff --git a/mods/mob/sounds/chicken_hurt.3.ogg b/mods/mob/sounds/chicken_hurt.3.ogg
new file mode 100644 (file)
index 0000000..c53c2ae
Binary files /dev/null and b/mods/mob/sounds/chicken_hurt.3.ogg differ
index 9ee428e53c1035c21cc3cb114f1e40c7aa60f88b..3ef248ca529f19c3273c4a1932b4f8e2e99be555 100644 (file)
@@ -1,3 +1,4 @@
 mob skins - 22i https://github.com/22i
 gunpowder, porkchop - https://github.com/minetest-texture-packs/Pixel-Perfection
-string, slimeball - oil_boi
\ No newline at end of file
+string, slimeball - oil_boi
+egg - Mineclone
\ No newline at end of file
diff --git a/mods/mob/textures/chicken.png b/mods/mob/textures/chicken.png
new file mode 100644 (file)
index 0000000..b9d6927
Binary files /dev/null and b/mods/mob/textures/chicken.png differ
diff --git a/mods/mob/textures/egg.png b/mods/mob/textures/egg.png
new file mode 100644 (file)
index 0000000..bbf1f3e
Binary files /dev/null and b/mods/mob/textures/egg.png differ