mirror of
https://github.com/ElCeejo/animalia.git
synced 2025-04-30 13:31:39 -04:00
Add Turkey and frame_blend support
This commit is contained in:
parent
07b80251e1
commit
fc8d9a6fc6
5 changed files with 190 additions and 79 deletions
|
@ -2,63 +2,10 @@
|
||||||
-- Chicken --
|
-- Chicken --
|
||||||
-------------
|
-------------
|
||||||
|
|
||||||
local min = math.min
|
local blend = better_fauna.frame_blend
|
||||||
local abs = math.abs
|
|
||||||
local random = math.random
|
local random = math.random
|
||||||
|
|
||||||
|
|
||||||
local function chicken_physics(self)
|
|
||||||
local vel = self.object:get_velocity()
|
|
||||||
if self.isonground and not self.isinliquid then
|
|
||||||
self.object:set_velocity({x= vel.x> 0.2 and vel.x*mobkit.friction or 0,
|
|
||||||
y=vel.y,
|
|
||||||
z=vel.z > 0.2 and vel.z*mobkit.friction or 0})
|
|
||||||
end
|
|
||||||
if self.springiness and self.springiness > 0 then
|
|
||||||
local vnew = vector.new(vel)
|
|
||||||
|
|
||||||
if not self.collided then
|
|
||||||
for _,k in ipairs({'y','z','x'}) do
|
|
||||||
if vel[k]==0 and abs(self.lastvelocity[k])> 0.1 then
|
|
||||||
vnew[k]=-self.lastvelocity[k]*self.springiness
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
if not vector.equals(vel,vnew) then
|
|
||||||
self.collided = true
|
|
||||||
else
|
|
||||||
if self.collided then
|
|
||||||
vnew = vector.new(self.lastvelocity)
|
|
||||||
end
|
|
||||||
self.collided = false
|
|
||||||
end
|
|
||||||
|
|
||||||
self.object:set_velocity(vnew)
|
|
||||||
end
|
|
||||||
local surface = nil
|
|
||||||
local surfnodename = nil
|
|
||||||
local spos = mobkit.get_stand_pos(self)
|
|
||||||
spos.y = spos.y+0.01
|
|
||||||
local snodepos = mobkit.get_node_pos(spos)
|
|
||||||
local surfnode = mobkit.nodeatpos(spos)
|
|
||||||
while surfnode and surfnode.drawtype == 'liquid' do
|
|
||||||
surfnodename = surfnode.name
|
|
||||||
surface = snodepos.y+0.5
|
|
||||||
if surface > spos.y+self.height then break end
|
|
||||||
snodepos.y = snodepos.y+1
|
|
||||||
surfnode = mobkit.nodeatpos(snodepos)
|
|
||||||
end
|
|
||||||
self.isinliquid = surfnodename
|
|
||||||
if surface then
|
|
||||||
local submergence = min(surface-spos.y,self.height)/self.height
|
|
||||||
local buoyacc = mobkit.gravity*(self.buoyancy-submergence)
|
|
||||||
mobkit.set_acceleration(self.object,
|
|
||||||
{x=-vel.x*self.water_drag,y=buoyacc-vel.y*abs(vel.y)*0.4,z=-vel.z*self.water_drag})
|
|
||||||
else
|
|
||||||
self.object:set_acceleration({x=0,y=-2.8,z=0})
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local function chicken_logic(self)
|
local function chicken_logic(self)
|
||||||
|
|
||||||
if self.hp <= 0 then
|
if self.hp <= 0 then
|
||||||
|
@ -120,10 +67,10 @@ minetest.register_entity("better_fauna:chicken",{
|
||||||
},
|
},
|
||||||
child_textures = {"better_fauna_chick.png"},
|
child_textures = {"better_fauna_chick.png"},
|
||||||
animation = {
|
animation = {
|
||||||
stand = {range = {x = 0, y = 0}, speed = 1, loop = true},
|
stand = {range = {x = 0, y = 0}, speed = 1, frame_blend = blend, loop = true},
|
||||||
walk = {range = {x = 10, y = 30}, speed = 30, loop = true},
|
walk = {range = {x = 10, y = 30}, speed = 30, frame_blend = blend, loop = true},
|
||||||
run = {range = {x = 10, y = 30}, speed = 45, loop = true},
|
run = {range = {x = 10, y = 30}, speed = 45, frame_blend = blend, loop = true},
|
||||||
fall = {range = {x = 40, y = 60}, speed = 30, loop = true},
|
fall = {range = {x = 40, y = 60}, speed = 30, frame_blend = blend, loop = true},
|
||||||
},
|
},
|
||||||
sounds = {
|
sounds = {
|
||||||
alter_child_pitch = true,
|
alter_child_pitch = true,
|
||||||
|
@ -164,7 +111,7 @@ minetest.register_entity("better_fauna:chicken",{
|
||||||
on_step = better_fauna.on_step,
|
on_step = better_fauna.on_step,
|
||||||
on_activate = better_fauna.on_activate,
|
on_activate = better_fauna.on_activate,
|
||||||
get_staticdata = mobkit.statfunc,
|
get_staticdata = mobkit.statfunc,
|
||||||
phsyics = chicken_physics,
|
phsyics = better_fauna.lightweight_physics,
|
||||||
logic = chicken_logic,
|
logic = chicken_logic,
|
||||||
on_rightclick = function(self, clicker)
|
on_rightclick = function(self, clicker)
|
||||||
if better_fauna.feed_tame(self, clicker, 1, false, true) then return end
|
if better_fauna.feed_tame(self, clicker, 1, false, true) then return end
|
||||||
|
@ -178,7 +125,7 @@ minetest.register_entity("better_fauna:chicken",{
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
mob_core.register_spawn_egg("better_fauna:chicken", "753b1f", "5f341f")
|
mob_core.register_spawn_egg("better_fauna:chicken", "c6c6c6", "d22222")
|
||||||
|
|
||||||
mob_core.register_spawn({
|
mob_core.register_spawn({
|
||||||
name = "better_fauna:chicken",
|
name = "better_fauna:chicken",
|
||||||
|
@ -254,7 +201,7 @@ minetest.register_entity("better_fauna:chicken_egg_sprite", {
|
||||||
collisiondetection = true,
|
collisiondetection = true,
|
||||||
texture = "better_fauna_egg_fragment.png",
|
texture = "better_fauna_egg_fragment.png",
|
||||||
})
|
})
|
||||||
if math.random(1, 3) == 1 then
|
if random(1, 3) == 1 then
|
||||||
mob_core.spawn_child(pos, "better_fauna:chicken")
|
mob_core.spawn_child(pos, "better_fauna:chicken")
|
||||||
self.object:remove()
|
self.object:remove()
|
||||||
else
|
else
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
-- Cow --
|
-- Cow --
|
||||||
---------
|
---------
|
||||||
|
|
||||||
|
local blend = better_fauna.frame_blend
|
||||||
|
|
||||||
local function cow_logic(self)
|
local function cow_logic(self)
|
||||||
|
|
||||||
if self.hp <= 0 then
|
if self.hp <= 0 then
|
||||||
|
@ -83,9 +85,9 @@ minetest.register_entity("better_fauna:cow",{
|
||||||
"better_fauna_cow_4.png"
|
"better_fauna_cow_4.png"
|
||||||
},
|
},
|
||||||
animation = {
|
animation = {
|
||||||
stand = {range = {x = 30, y = 50}, speed = 10, loop = true},
|
stand = {range = {x = 30, y = 50}, speed = 10, frame_blend = blend, loop = true},
|
||||||
walk = {range = {x = 1, y = 20}, speed = 20, loop = true},
|
walk = {range = {x = 1, y = 20}, speed = 20, frame_blend = blend, loop = true},
|
||||||
run = {range = {x = 1, y = 20}, speed = 30, loop = true},
|
run = {range = {x = 1, y = 20}, speed = 30, frame_blend = blend, loop = true},
|
||||||
},
|
},
|
||||||
sounds = {
|
sounds = {
|
||||||
alter_child_pitch = true,
|
alter_child_pitch = true,
|
||||||
|
|
14
mobs/pig.lua
14
mobs/pig.lua
|
@ -2,6 +2,8 @@
|
||||||
-- Pig --
|
-- Pig --
|
||||||
---------
|
---------
|
||||||
|
|
||||||
|
local blend = better_fauna.frame_blend
|
||||||
|
|
||||||
local function pig_logic(self)
|
local function pig_logic(self)
|
||||||
|
|
||||||
if self.hp <= 0 then
|
if self.hp <= 0 then
|
||||||
|
@ -59,8 +61,8 @@ minetest.register_entity("better_fauna:pig",{
|
||||||
armor_groups = {fleshy = 100},
|
armor_groups = {fleshy = 100},
|
||||||
physical = true,
|
physical = true,
|
||||||
collide_with_objects = true,
|
collide_with_objects = true,
|
||||||
collisionbox = {-0.45, -0.55, -0.45, 0.45, 0.4, 0.45},
|
collisionbox = {-0.35, -0.45, -0.35, 0.35, 0.4, 0.35},
|
||||||
visual_size = {x = 13, y = 13},
|
visual_size = {x = 11, y = 11},
|
||||||
scale_stage1 = 0.5,
|
scale_stage1 = 0.5,
|
||||||
scale_stage2 = 0.65,
|
scale_stage2 = 0.65,
|
||||||
scale_stage3 = 0.80,
|
scale_stage3 = 0.80,
|
||||||
|
@ -72,9 +74,9 @@ minetest.register_entity("better_fauna:pig",{
|
||||||
"better_fauna_pig_3.png"
|
"better_fauna_pig_3.png"
|
||||||
},
|
},
|
||||||
animation = {
|
animation = {
|
||||||
stand = {range = {x = 30, y = 50}, speed = 10, loop = true},
|
stand = {range = {x = 30, y = 50}, speed = 10, frame_blend = blend, loop = true},
|
||||||
walk = {range = {x = 1, y = 20}, speed = 30, loop = true},
|
walk = {range = {x = 1, y = 20}, speed = 30, frame_blend = blend, loop = true},
|
||||||
run = {range = {x = 1, y = 20}, speed = 45, loop = true},
|
run = {range = {x = 1, y = 20}, speed = 45, frame_blend = blend, loop = true},
|
||||||
},
|
},
|
||||||
sounds = {
|
sounds = {
|
||||||
alter_child_pitch = true,
|
alter_child_pitch = true,
|
||||||
|
@ -147,7 +149,7 @@ minetest.register_craft({
|
||||||
output = "better_fauna:porkchop_cooked",
|
output = "better_fauna:porkchop_cooked",
|
||||||
})
|
})
|
||||||
|
|
||||||
mob_core.register_spawn_egg("better_fauna:pig", "cac3a1" ,"464438")
|
mob_core.register_spawn_egg("better_fauna:pig", "e0b1a7" ,"cc9485")
|
||||||
|
|
||||||
mob_core.register_spawn({
|
mob_core.register_spawn({
|
||||||
name = "better_fauna:pig",
|
name = "better_fauna:pig",
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
-- Sheep --
|
-- Sheep --
|
||||||
-----------
|
-----------
|
||||||
|
|
||||||
|
local blend = better_fauna.frame_blend
|
||||||
|
|
||||||
local palette = {
|
local palette = {
|
||||||
{"black", "Black", "#000000b0"},
|
{"black", "Black", "#000000b0"},
|
||||||
{"blue", "Blue", "#015dbb70"},
|
{"blue", "Blue", "#015dbb70"},
|
||||||
|
@ -95,9 +97,9 @@ minetest.register_entity("better_fauna:sheep",{
|
||||||
textures = {"better_fauna_sheep.png^better_fauna_sheep_wool.png"},
|
textures = {"better_fauna_sheep.png^better_fauna_sheep_wool.png"},
|
||||||
child_textures = {"better_fauna_sheep.png"},
|
child_textures = {"better_fauna_sheep.png"},
|
||||||
animation = {
|
animation = {
|
||||||
stand = {range = {x = 30, y = 50}, speed = 10, loop = true},
|
stand = {range = {x = 30, y = 50}, speed = 10, frame_blend = blend, loop = true},
|
||||||
walk = {range = {x = 1, y = 20}, speed = 30, loop = true},
|
walk = {range = {x = 1, y = 20}, speed = 30, frame_blend = blend, loop = true},
|
||||||
run = {range = {x = 1, y = 20}, speed = 45, loop = true},
|
run = {range = {x = 1, y = 20}, speed = 45, frame_blend = blend, loop = true},
|
||||||
},
|
},
|
||||||
sounds = {
|
sounds = {
|
||||||
alter_child_pitch = true,
|
alter_child_pitch = true,
|
||||||
|
@ -149,12 +151,14 @@ minetest.register_entity("better_fauna:sheep",{
|
||||||
logic = sheep_logic,
|
logic = sheep_logic,
|
||||||
on_step = function(self, dtime, moveresult)
|
on_step = function(self, dtime, moveresult)
|
||||||
better_fauna.on_step(self, dtime, moveresult)
|
better_fauna.on_step(self, dtime, moveresult)
|
||||||
|
if mobkit.is_alive(self) then
|
||||||
if self.object:get_properties().textures[1] == "better_fauna_sheep.png"
|
if self.object:get_properties().textures[1] == "better_fauna_sheep.png"
|
||||||
and not self.gotten then
|
and not self.gotten then
|
||||||
self.object:set_properties({
|
self.object:set_properties({
|
||||||
textures = {"better_fauna_sheep.png^better_fauna_sheep_wool.png"},
|
textures = {"better_fauna_sheep.png^better_fauna_sheep_wool.png"},
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end,
|
end,
|
||||||
on_activate = function(self, staticdata, dtime_s)
|
on_activate = function(self, staticdata, dtime_s)
|
||||||
better_fauna.on_activate(self, staticdata, dtime_s)
|
better_fauna.on_activate(self, staticdata, dtime_s)
|
||||||
|
|
156
mobs/turkey.lua
Normal file
156
mobs/turkey.lua
Normal file
|
@ -0,0 +1,156 @@
|
||||||
|
------------
|
||||||
|
-- Turkey --
|
||||||
|
------------
|
||||||
|
|
||||||
|
local blend = better_fauna.frame_blend
|
||||||
|
|
||||||
|
local function turkey_logic(self)
|
||||||
|
|
||||||
|
if self.hp <= 0 then
|
||||||
|
mob_core.on_die(self)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
local prty = mobkit.get_queue_priority(self)
|
||||||
|
local player = mobkit.get_nearby_player(self)
|
||||||
|
|
||||||
|
if mobkit.timer(self,1) then
|
||||||
|
|
||||||
|
mob_core.vitals(self)
|
||||||
|
mob_core.random_sound(self, 12)
|
||||||
|
|
||||||
|
if prty < 3
|
||||||
|
and self.breeding then
|
||||||
|
better_fauna.hq_fowl_breed(self, 3)
|
||||||
|
end
|
||||||
|
|
||||||
|
if prty < 2
|
||||||
|
and player then
|
||||||
|
if self.attention_span < 5 then
|
||||||
|
if mob_core.follow_holding(self, player) then
|
||||||
|
better_fauna.hq_follow_player(self, 2, player)
|
||||||
|
self.attention_span = self.attention_span + 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if mobkit.is_queue_empty_high(self) then
|
||||||
|
mob_core.hq_roam(self, 0)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
minetest.register_entity("better_fauna:turkey",{
|
||||||
|
max_hp = 10,
|
||||||
|
view_range = 16,
|
||||||
|
armor_groups = {fleshy = 100},
|
||||||
|
physical = true,
|
||||||
|
collide_with_objects = true,
|
||||||
|
collisionbox = {-0.3, -0.2, -0.3, 0.3, 0.4, 0.3},
|
||||||
|
visual_size = {x = 7, y = 7},
|
||||||
|
scale_stage1 = 0.25,
|
||||||
|
scale_stage2 = 0.5,
|
||||||
|
scale_stage3 = 0.75,
|
||||||
|
visual = "mesh",
|
||||||
|
mesh = "better_fauna_turkey.b3d",
|
||||||
|
female_textures = {"better_fauna_turkey_hen.png"},
|
||||||
|
male_textures = {"better_fauna_turkey_tom.png"},
|
||||||
|
child_textures = {"better_fauna_turkey_chick.png"},
|
||||||
|
animation = {
|
||||||
|
stand = {range = {x = 0, y = 0}, speed = 1, frame_blend = blend, loop = true},
|
||||||
|
walk = {range = {x = 10, y = 30}, speed = 30, frame_blend = blend, loop = true},
|
||||||
|
run = {range = {x = 10, y = 30}, speed = 45, frame_blend = blend, loop = true},
|
||||||
|
fall = {range = {x = 40, y = 60}, speed = 30, frame_blend = blend, loop = true},
|
||||||
|
},
|
||||||
|
sounds = {
|
||||||
|
alter_child_pitch = true,
|
||||||
|
random = {
|
||||||
|
name = "better_fauna_turkey_idle",
|
||||||
|
gain = 1.0,
|
||||||
|
distance = 8
|
||||||
|
},
|
||||||
|
hurt = {
|
||||||
|
name = "better_fauna_turkey_hurt",
|
||||||
|
gain = 1.0,
|
||||||
|
distance = 8
|
||||||
|
},
|
||||||
|
death = {
|
||||||
|
name = "better_fauna_turkey_death",
|
||||||
|
gain = 1.0,
|
||||||
|
distance = 8
|
||||||
|
}
|
||||||
|
},
|
||||||
|
max_speed = 4,
|
||||||
|
stepheight = 1.1,
|
||||||
|
jump_height = 1.1,
|
||||||
|
buoyancy = 0.25,
|
||||||
|
lung_capacity = 10,
|
||||||
|
timeout = 1200,
|
||||||
|
ignore_liquidflag = false,
|
||||||
|
core_growth = false,
|
||||||
|
push_on_collide = true,
|
||||||
|
catch_with_net = true,
|
||||||
|
follow = {
|
||||||
|
"farming:seed_cotton",
|
||||||
|
"farming:seed_wheat"
|
||||||
|
},
|
||||||
|
drops = {
|
||||||
|
{name = "better_fauna:feather", chance = 1, min = 1, max = 2},
|
||||||
|
{name = "better_fauna:turkey_raw", chance = 1, min = 3, max = 5}
|
||||||
|
},
|
||||||
|
on_step = better_fauna.on_step,
|
||||||
|
on_activate = better_fauna.on_activate,
|
||||||
|
get_staticdata = mobkit.statfunc,
|
||||||
|
phsyics = better_fauna.lightweight_physics,
|
||||||
|
logic = turkey_logic,
|
||||||
|
on_rightclick = function(self, clicker)
|
||||||
|
if better_fauna.feed_tame(self, clicker, 1, false, true) then return end
|
||||||
|
mob_core.protect(self, clicker, false)
|
||||||
|
mob_core.nametag(self, clicker, true)
|
||||||
|
end,
|
||||||
|
on_punch = function(self, puncher, _, tool_capabilities, dir)
|
||||||
|
mobkit.clear_queue_high(self)
|
||||||
|
mob_core.on_punch_basic(self, puncher, tool_capabilities, dir)
|
||||||
|
better_fauna.hq_sporadic_flee(self, 10, puncher)
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
|
mob_core.register_spawn_egg("better_fauna:turkey", "352b22", "2f2721")
|
||||||
|
|
||||||
|
mob_core.register_spawn({
|
||||||
|
name = "better_fauna:turkey",
|
||||||
|
nodes = {"default:dry_dirt_with_dry_grass", "default:dirt_with_grass"},
|
||||||
|
min_light = 0,
|
||||||
|
max_light = 15,
|
||||||
|
min_height = -31000,
|
||||||
|
max_height = 31000,
|
||||||
|
min_rad = 24,
|
||||||
|
max_rad = 256,
|
||||||
|
group = 6,
|
||||||
|
optional = {
|
||||||
|
biomes = {
|
||||||
|
"deciduous_forest",
|
||||||
|
"taiga"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, 16, 6)
|
||||||
|
|
||||||
|
|
||||||
|
minetest.register_craftitem("better_fauna:turkey_raw", {
|
||||||
|
description = "Raw Turkey",
|
||||||
|
inventory_image = "better_fauna_turkey_raw.png",
|
||||||
|
on_use = minetest.item_eat(1),
|
||||||
|
groups = {flammable = 2},
|
||||||
|
})
|
||||||
|
|
||||||
|
minetest.register_craftitem("better_fauna:turkey_cooked", {
|
||||||
|
description = "Cooked Turkey",
|
||||||
|
inventory_image = "better_fauna_turkey_cooked.png",
|
||||||
|
on_use = minetest.item_eat(6),
|
||||||
|
groups = {flammable = 2},
|
||||||
|
})
|
||||||
|
|
||||||
|
minetest.register_craft({
|
||||||
|
type = "cooking",
|
||||||
|
recipe = "better_fauna:turkey_raw",
|
||||||
|
output = "better_fauna:turkey_cooked",
|
||||||
|
})
|
Loading…
Add table
Reference in a new issue