Add new mobs, bug fixes, improved behavior

This commit is contained in:
ElCeejo 2021-08-20 13:08:17 -07:00 committed by GitHub
parent ce8fd5935f
commit 7e240b5bd8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
23 changed files with 3328 additions and 870 deletions

329
mobs/cat.lua Normal file
View file

@ -0,0 +1,329 @@
---------
-- Cat --
---------
local clamp_bone_rot = animalia.clamp_bone_rot
local interp = animalia.interp
local follow = {
"animalia:poultry_raw"
}
if minetest.registered_items["ethereal:fish_raw"] then
follow = {
"ethereal:fish_raw",
"animalia:poultry_raw"
}
end
local function cat_logic(self)
if self.hp <= 0 then
mob_core.on_die(self)
return
end
if self._anim == "run" then
local pos = self.object:get_pos()
minetest.add_particlespawner({
amount = 1,
time = 0.25,
minpos = pos,
maxpos = pos,
minvel = vector.new(-1, 1, -1),
maxvel = vector.new(1, 2, 1),
minacc = vector.new(0, -9.81, 0),
maxacc = vector.new(0, -9.81, 0),
minsize = 0.25,
maxsize = 0.5,
collisiondetection = true,
texture = "default_dirt.png",
})
end
animalia.head_tracking(self, 0.25, 0.25)
if mobkit.timer(self, 1) then
local prty = mobkit.get_queue_priority(self)
local player = mobkit.get_nearby_player(self)
local trust = 0
mob_core.random_sound(self, 30)
mob_core.growth(self)
if player then
if not self.trust[player:get_player_name()] then
self.trust[player:get_player_name()] = 0
mobkit.remember(self, "trust", self.trust)
else
trust = self.trust[player:get_player_name()]
end
end
if self.trust_cooldown > 0 then
self.trust_cooldown = mobkit.remember(self, "trust_cooldown", self.trust_cooldown - 1)
end
if self.interact_sound_cooldown > 0 then
self.interact_sound_cooldown = self.interact_sound_cooldown - 1
end
if self.owner
and self.trust[self.owner] > 7 then
if prty < 22
and self.order == "sit" then
if not mobkit.is_queue_empty_high(self) then
mobkit.clear_queue_high(self)
end
mobkit.animate(self, "sit")
return
end
if prty < 21
and self.owner_target then
if not mob_core.shared_owner(self, self.owner_target) then
animalia.hq_attack(self, 21, self.owner_target)
end
end
if prty < 20
and self.order == "follow"
and minetest.get_player_by_name(self.owner) then
local owner = minetest.get_player_by_name(self.owner)
animalia.hq_follow_player(self, 20, owner, true)
end
if prty < 4
and self.breeding then
animalia.hq_breed(self, 3)
end
end
if prty < 5
and self.isinliquid then
animalia.hq_go_to_land(self, 5)
end
if prty < 3
and player then
if player:get_velocity()
and vector.length(player:get_velocity()) < 2 then
if mob_core.follow_holding(self, player)
and trust >= 4 then
animalia.hq_follow_player(self, 3, player)
end
elseif player:get_wielded_item():get_name() == "animalia:cat_toy" then
animalia.hq_follow_player(self, 3, player, true)
return
end
end
if player
and prty == 3
and not mob_core.follow_holding(self, player)
and player:get_wielded_item():get_name() ~= "animalia:cat_toy" then
mobkit.clear_queue_high(self)
end
if prty < 2
and player
and trust > 4 then
local r = math.random(48)
if r < 2 then
animalia.hq_walk_in_front_of_player(self, 2, player)
elseif r < 3 then
animalia.hq_find_and_break_glass(self, 2)
end
end
if mobkit.is_queue_empty_high(self) then
animalia.hq_wander_ranged(self, 0)
end
end
end
animalia.register_mob("cat", {
-- Stats
health = 10,
fleshy = 100,
view_range = 32,
lung_capacity = 10,
-- Visual
collisionbox = {-0.2, 0, -0.2, 0.2, 0.4, 0.2},
visual_size = {x = 6, y = 6},
scale_stage1 = 0.5,
scale_stage2 = 0.65,
scale_stage3 = 0.80,
mesh = "animalia_cat.b3d",
textures = {
"animalia_cat_1.png",
"animalia_cat_2.png",
"animalia_cat_3.png",
"animalia_cat_4.png"
},
animations = {
stand = {range = {x = 1, y = 39}, speed = 10, frame_blend = 0.3, loop = true},
walk = {range = {x = 50, y = 90}, speed = 45, frame_blend = 0.3, loop = true},
run = {range = {x = 100, y = 130}, speed = 50, frame_blend = 0.3, loop = true},
sit = {range = {x = 140, y = 180}, speed = 10, frame_blend = 0.3, loop = true},
smack = {range = {x = 190, y = 210}, speed = 40, frame_blend = 0.1, loop = true},
},
-- Physics
speed = 8,
max_fall = 4,
-- Attributes
sounds = {
alter_child_pitch = true,
random = {
name = "animalia_cat_idle",
gain = 0.25,
distance = 8
},
purr = {
name = "animalia_cat_purr",
gain = 0.6,
distance = 8
},
hurt = {
name = "animalia_cat_hurt",
gain = 0.25,
distance = 8
},
death = {
name = "animalia_cat_hurt",
gain = 0.25,
distance = 8
}
},
reach = 2,
damage = 3,
knockback = 2,
punch_cooldown = 1,
-- Behavior
defend_owner = true,
follow = follow,
-- Functions
head_data = {
offset = {x = 0, y = 0.17, z = 0},
pitch_correction = -20,
pivot_h = 0.35,
pivot_v = 0.2
},
logic = cat_logic,
get_staticdata = mobkit.statfunc,
on_step = animalia.on_step,
on_activate = function(self, staticdata, dtime_s)
animalia.on_activate(self, staticdata, dtime_s)
self.trust = mobkit.recall(self, "trust") or {}
self.trust_cooldown = mobkit.recall(self, "trust_cooldown") or 0
self.interact_sound_cooldown = 0
end,
on_rightclick = function(self, clicker)
local item = clicker:get_wielded_item():get_name()
if item == "animalia:net" then return end
if not self.trust[clicker:get_player_name()] then
self.trust[clicker:get_player_name()] = 0
mobkit.remember(self, "trust", self.trust)
end
local trust = self.trust[clicker:get_player_name()]
local pos = self.object:get_pos()
local prt_pos = vector.new(pos.x, pos.y + 0.5, pos.z)
local minppos = vector.add(prt_pos, 1)
local maxppos = vector.subtract(prt_pos, 1)
if animalia.feed_tame(self, clicker, math.random(3, 5), trust >= 10, trust >= 10) then
if self.trust_cooldown <= 0
and trust < 10 then
self.trust[clicker:get_player_name()] = trust + 1
self.trust_cooldown = mobkit.remember(self, "trust_cooldown", 60)
mobkit.remember(self, "trust", self.trust)
animalia.particle_spawner(prt_pos, "mob_core_green_particle.png", "float", minppos, maxppos)
end
return
end
mob_core.protect(self, clicker, true)
mob_core.nametag(self, clicker, true)
if mobkit.get_queue_priority(self) == 3
and clicker:get_wielded_item():get_name() == "animalia:cat_toy" then
if trust < 10 then
self.trust[clicker:get_player_name()] = trust + 1
mobkit.remember(self, "trust", self.trust)
animalia.particle_spawner(prt_pos, "mob_core_green_particle.png", "float", minppos, maxppos)
if self.interact_sound_cooldown <= 0 then
self.sounds["purr"].gain = 1
self.interact_sound_cooldown = 3
mobkit.make_sound(self, "purr")
end
end
end
if not self.owner
or clicker:get_player_name() ~= self.owner then
return
end
if clicker:get_player_control().sneak then
if self.interact_sound_cooldown <= 0 then
self.sounds["purr"].gain = 0.15 * self.trust[self.owner]
self.interact_sound_cooldown = 3
mobkit.make_sound(self, "purr")
end
end
if trust <= 7 then
if self.interact_sound_cooldown <= 0 then
self.interact_sound_cooldown = 3
mobkit.make_sound(self, "random")
end
return
end
if self.order == "wander" then
self.order = "follow"
elseif self.order == "follow" then
self.order = "sit"
else
self.order = "wander"
end
mobkit.remember(self, "order", self.order)
end,
on_punch = function(self, puncher, _, tool_capabilities, dir)
mob_core.on_punch_basic(self, puncher, tool_capabilities, dir)
animalia.hq_sporadic_flee(self, 10)
if not self.trust[puncher:get_player_name()] then
self.trust[puncher:get_player_name()] = 0
else
local trust = self.trust[puncher:get_player_name()]
self.trust[puncher:get_player_name()] = trust - 1
end
local pos = self.object:get_pos()
local prt_pos = vector.new(pos.x, pos.y + 0.5, pos.z)
local minppos = vector.add(prt_pos, 1)
local maxppos = vector.subtract(prt_pos, 1)
animalia.particle_spawner(prt_pos, "mob_core_red_particle.png", "float", minppos, maxppos)
mobkit.remember(self, "trust", self.trust)
end
})
mob_core.register_spawn_egg("animalia:cat", "db9764" ,"cf8d5a")
local house_nodes = {}
minetest.register_on_mods_loaded(function()
for name in pairs(minetest.registered_nodes) do
if minetest.get_item_group(name, "stairs") > 0
or minetest.get_item_group(name, "wood") > 0 then
table.insert(house_nodes, name)
end
end
end)
mob_core.register_spawn({
name = "animalia:cat",
nodes = house_nodes,
min_light = 0,
max_light = 15,
min_height = -31000,
max_height = 31000,
min_rad = 24,
max_rad = 256,
group = 0,
}, animalia.spawn_interval, 1)

View file

@ -2,134 +2,167 @@
-- Chicken --
-------------
local blend = better_fauna.frame_blend
local clamp_bone_rot = animalia.clamp_bone_rot
local interp = animalia.interp
local random = math.random
local function chicken_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
if self.status ~= "following" then
if self.attention_span > 1 then
self.attention_span = self.attention_span - self.dtime
mobkit.remember(self, "attention_span", self.attention_span)
end
else
self.attention_span = self.attention_span + self.dtime
mobkit.remember(self, "attention_span", self.attention_span)
end
mob_core.vitals(self)
mob_core.random_drop(self, 10, 1800, "better_fauna:chicken_egg")
mob_core.random_sound(self, 8)
if self.fall_start
and self.fall_start - mobkit.get_stand_pos(self).y > 2 then
mobkit.animate(self, "flap")
self.object:set_acceleration({x = 0, y = -3.1, z = 0})
end
animalia.head_tracking(self, 0.45, 0.25)
if mobkit.timer(self, 4) then
local prty = mobkit.get_queue_priority(self)
local player = mobkit.get_nearby_player(self)
mob_core.random_sound(self, 14)
mob_core.random_drop(self, 10, 1800, "animalia:chicken_egg")
if prty < 4
and self.isinliquid then
animalia.hq_go_to_land(self, 4)
end
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
animalia.hq_fowl_breed(self, 3)
end
if prty == 2
and not self.lasso_player
and (not player
or not mob_core.follow_holding(self, player)) then
mobkit.clear_queue_high(self)
end
if prty < 2 then
if self.caught_with_lasso
and self.lasso_player then
animalia.hq_follow_player(self, 2, self.lasso_player, true)
elseif player then
if self.attention_span < 5 then
if mob_core.follow_holding(self, player) then
animalia.hq_follow_player(self, 2, player)
self.attention_span = self.attention_span + 1
end
end
end
end
if mobkit.is_queue_empty_high(self) then
mob_core.hq_roam(self, 0)
animalia.hq_wander_group(self, 0, 8)
end
end
end
minetest.register_entity("better_fauna:chicken",{
max_hp = 10,
view_range = 16,
armor_groups = {fleshy = 100},
physical = true,
collide_with_objects = true,
animalia.register_mob("chicken", {
-- Stats
health = 10,
fleshy = 100,
view_range = 8,
lung_capacity = 10,
-- Visual
collisionbox = {-0.2, -0.15, -0.2, 0.2, 0.3, 0.2},
visual_size = {x = 6, y = 6},
scale_stage1 = 0.25,
scale_stage2 = 0.5,
scale_stage3 = 0.75,
visual = "mesh",
mesh = "better_fauna_chicken.b3d",
mesh = "animalia_chicken.b3d",
female_textures = {
"better_fauna_chicken_1.png",
"better_fauna_chicken_2.png",
"better_fauna_chicken_3.png"
"animalia_chicken_1.png",
"animalia_chicken_2.png",
"animalia_chicken_3.png"
},
male_textures = {
"better_fauna_rooster_1.png",
"better_fauna_rooster_2.png",
"better_fauna_rooster_3.png"
"animalia_rooster_1.png",
"animalia_rooster_2.png",
"animalia_rooster_3.png"
},
child_textures = {"better_fauna_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},
child_textures = {"animalia_chick.png"},
animations = {
stand = {range = {x = 0, y = 0}, speed = 1, frame_blend = 0.3, loop = true},
walk = {range = {x = 10, y = 30}, speed = 30, frame_blend = 0.3, loop = true},
run = {range = {x = 10, y = 30}, speed = 45, frame_blend = 0.3, loop = true},
fall = {range = {x = 40, y = 60}, speed = 30, frame_blend = 0.3, loop = true},
},
-- Physics
speed = 5,
max_fall = 6,
-- Attributes
sounds = {
alter_child_pitch = true,
random = {
name = "better_fauna_chicken_idle",
gain = 1.0,
name = "animalia_chicken_idle",
gain = 0.5,
distance = 8
},
hurt = {
name = "better_fauna_chicken_hurt",
gain = 1.0,
name = "animalia_chicken_hurt",
gain = 0.5,
distance = 8
},
death = {
name = "better_fauna_chicken_death",
gain = 1.0,
name = "animalia_chicken_death",
gain = 0.5,
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,
fall_damage = false,
-- Behavior
defend_owner = false,
follow = {
"farming:seed_cotton",
"farming:seed_wheat"
},
drops = {
{name = "better_fauna:feather", chance = 1, min = 1, max = 2},
{name = "better_fauna:chicken_raw", chance = 1, min = 1, max = 4}
{name = "animalia:feather", chance = 1, min = 1, max = 2},
{name = "animalia:chicken_raw", chance = 1, min = 1, max = 4}
},
-- Functions
head_data = {
offset = {x = 0, y = 0.15, z = 0},
pitch_correction = 55,
pivot_h = 0.25,
pivot_v = 0.55
},
on_step = better_fauna.on_step,
on_activate = better_fauna.on_activate,
get_staticdata = mobkit.statfunc,
phsyics = better_fauna.lightweight_physics,
logic = chicken_logic,
get_staticdata = mobkit.statfunc,
on_step = animalia.on_step,
on_activate = animalia.on_activate,
on_rightclick = function(self, clicker)
if better_fauna.feed_tame(self, clicker, 1, false, true) then return end
mob_core.protect(self, clicker, false)
if animalia.feed_tame(self, clicker, 1, false, true) then return end
mob_core.protect(self, clicker, true)
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)
animalia.hq_sporadic_flee(self, 10)
end,
})
mob_core.register_spawn_egg("better_fauna:chicken", "c6c6c6", "d22222")
mob_core.register_spawn_egg("animalia:chicken", "c6c6c6", "d22222")
mob_core.register_spawn({
name = "better_fauna:chicken",
nodes = {"default:dry_dirt_with_dry_grass", "default:dirt_with_grass"},
name = "animalia:chicken",
min_light = 0,
max_light = 15,
min_height = -31000,
@ -139,41 +172,39 @@ mob_core.register_spawn({
group = 6,
optional = {
biomes = {
"grassland",
"savanna",
"rainforest"
unpack(animalia.grassland_biomes),
unpack(animalia.tropical_biomes)
}
}
}, 16, 6)
}, animalia.spawn_interval, 4)
minetest.register_craftitem("better_fauna:chicken_raw", {
description = "Raw Chicken",
inventory_image = "better_fauna_chicken_raw.png",
minetest.register_craftitem("animalia:poultry_raw", {
description = "Raw Poultry",
inventory_image = "animalia_poultry_raw.png",
on_use = minetest.item_eat(1),
groups = {flammable = 2},
})
minetest.register_craftitem("better_fauna:chicken_cooked", {
description = "Cooked Chicken",
inventory_image = "better_fauna_chicken_cooked.png",
minetest.register_craftitem("animalia:poultry_cooked", {
description = "Cooked Poultry",
inventory_image = "animalia_poultry_cooked.png",
on_use = minetest.item_eat(6),
groups = {flammable = 2},
})
minetest.register_craft({
type = "cooking",
recipe = "better_fauna:chicken_raw",
output = "better_fauna:chicken_cooked",
recipe = "animalia:poultry_raw",
output = "animalia:poultry_cooked",
})
minetest.register_entity("better_fauna:chicken_egg_sprite", {
minetest.register_entity("animalia:chicken_egg_sprite", {
hp_max = 1,
physical = true,
collisionbox = {0, 0, 0, 0, 0, 0},
visual = "sprite",
visual_size = {x = 0.5, y = 0.5},
textures = {"better_fauna_egg.png"},
textures = {"animalia_egg.png"},
initial_sprite_basepos = {x = 0, y = 0},
is_visible = true,
on_step = function(self, dtime)
@ -182,7 +213,7 @@ minetest.register_entity("better_fauna:chicken_egg_sprite", {
local cube = minetest.find_nodes_in_area(
vector.new(pos.x - 0.5, pos.y - 0.5, pos.z - 0.5),
vector.new(pos.x + 0.5, pos.y + 0.5, pos.z + 0.5),
better_fauna.walkable_nodes)
animalia.walkable_nodes)
if #objects >= 2 then
if objects[2]:get_armor_groups().fleshy then
objects[2]:punch(self.object, 2.0, {full_punch_interval = 0.1, damage_groups = {fleshy = 1}}, nil)
@ -199,10 +230,10 @@ minetest.register_entity("better_fauna:chicken_egg_sprite", {
minacc = vector.new(0, -9.81, 0),
maxacc = vector.new(0, -9.81, 0),
collisiondetection = true,
texture = "better_fauna_egg_fragment.png",
texture = "animalia_egg_fragment.png",
})
if random(1, 3) == 1 then
mob_core.spawn_child(pos, "better_fauna:chicken")
if random(1, 3) < 2 then
mob_core.spawn_child(pos, "animalia:chicken")
self.object:remove()
else
self.object:remove()
@ -227,7 +258,7 @@ local mobs_shoot_egg = function (item, player, pointed_thing)
x = pos.x,
y = pos.y +1.5,
z = pos.z
}, "better_fauna:chicken_egg_sprite")
}, "animalia:chicken_egg_sprite")
local ent = obj:get_luaentity()
local dir = player:get_look_dir()
@ -256,9 +287,28 @@ local mobs_shoot_egg = function (item, player, pointed_thing)
return item
end
minetest.register_craftitem("better_fauna:chicken_egg", {
minetest.register_craftitem("animalia:chicken_egg", {
description = "Chicken Egg",
inventory_image = "better_fauna_egg.png",
inventory_image = "animalia_egg.png",
on_use = mobs_shoot_egg,
groups = {flammable = 2},
})
minetest.register_craftitem("animalia:chicken_egg_fried", {
description = "Fried Chicken Egg",
inventory_image = "animalia_egg_fried.png",
on_use = minetest.item_eat(4),
groups = {flammable = 2},
})
minetest.register_craft({
type = "cooking",
recipe = "animalia:chicken_egg",
output = "animalia:chicken_egg_fried",
})
minetest.register_craftitem("animalia:feather", {
description = "Feather",
inventory_image = "animalia_feather.png",
groups = {flammable = 2, feather = 1},
})

View file

@ -2,7 +2,12 @@
-- Cow --
---------
local blend = better_fauna.frame_blend
local clamp_bone_rot = animalia.clamp_bone_rot
local interp = animalia.interp
local random = math.random
local blend = animalia.frame_blend
local function cow_logic(self)
@ -11,126 +16,161 @@ local function cow_logic(self)
return
end
local pos = mobkit.get_stand_pos(self)
local prty = mobkit.get_queue_priority(self)
local player = mobkit.get_nearby_player(self)
if self.status ~= "following" then
if self.attention_span > 1 then
self.attention_span = self.attention_span - self.dtime
mobkit.remember(self, "attention_span", self.attention_span)
end
else
self.attention_span = self.attention_span + self.dtime
mobkit.remember(self, "attention_span", self.attention_span)
end
mob_core.random_sound(self, 16/self.dtime)
animalia.head_tracking(self, 0.75, 0.75)
if mobkit.timer(self,1) then
if mobkit.timer(self, 3) then
mob_core.vitals(self)
local prty = mobkit.get_queue_priority(self)
local player = mobkit.get_nearby_player(self)
mob_core.random_sound(self, 14)
mob_core.growth(self)
if math.random(1, 64) == 1 then
if random(1, 64) < 2 then
self.gotten = mobkit.remember(self, "gotten", false)
end
if self.status ~= "following" then
if self.attention_span > 1 then
self.attention_span = self.attention_span - 1
mobkit.remember(self, "attention_span", self.attention_span)
end
else
self.attention_span = self.attention_span + 1
mobkit.remember(self, "attention_span", self.attention_span)
if prty < 5
and self.isinliquid then
animalia.hq_go_to_land(self, 5)
end
if prty < 4
and self.breeding then
better_fauna.hq_breed(self, 4)
animalia.hq_breed(self, 4)
end
if prty < 3
and self.gotten
and math.random(1, 16) == 1 then
better_fauna.hq_eat(self, 3)
and random(1, 16) < 2 then
animalia.hq_eat(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
if prty == 2
and not self.lasso_player
and (not player
or not mob_core.follow_holding(self, player)) then
mobkit.clear_queue_high(self)
end
if prty < 2 then
if self.caught_with_lasso
and self.lasso_player then
animalia.hq_follow_player(self, 2, self.lasso_player, true)
elseif player then
if self.attention_span < 5 then
if mob_core.follow_holding(self, player) then
animalia.hq_follow_player(self, 2, player)
self.attention_span = self.attention_span + 1
end
end
end
end
if mobkit.is_queue_empty_high(self) then
mob_core.hq_roam(self, 0)
animalia.hq_wander_group(self, 0, 10)
end
end
end
local random = math.random
minetest.register_entity("better_fauna:cow",{
max_hp = 20,
view_range = 16,
armor_groups = {fleshy = 100},
physical = true,
collide_with_objects = true,
collisionbox = {-0.45, -0.55, -0.45, 0.45, 0.4, 0.45},
visual_size = {x = 13, y = 13},
scale_stage1 = 0.5,
scale_stage2 = 0.65,
scale_stage3 = 0.80,
visual = "mesh",
mesh = "better_fauna_cow.b3d",
textures = {
"better_fauna_cow_1.png",
"better_fauna_cow_2.png",
"better_fauna_cow_3.png",
"better_fauna_cow_4.png"
animalia.register_mob("cow", {
-- Stats
health = 20,
fleshy = 100,
view_range = 32,
lung_capacity = 10,
-- Visual
collisionbox = {-0.45, 0, -0.45, 0.45, 0.9, 0.45},
visual_size = {x = 10, y = 10},
mesh = "animalia_cow.b3d",
female_textures = {
"animalia_cow_1.png^animalia_cow_udder.png",
"animalia_cow_2.png^animalia_cow_udder.png",
"animalia_cow_3.png^animalia_cow_udder.png",
"animalia_cow_4.png^animalia_cow_udder.png"
},
animation = {
stand = {range = {x = 30, y = 50}, speed = 10, frame_blend = blend, loop = true},
walk = {range = {x = 1, y = 20}, speed = 20, frame_blend = blend, loop = true},
run = {range = {x = 1, y = 20}, speed = 30, frame_blend = blend, loop = true},
male_textures = {
"animalia_cow_1.png",
"animalia_cow_2.png",
"animalia_cow_3.png",
"animalia_cow_4.png"
},
child_textures = {
"animalia_cow_1.png",
"animalia_cow_2.png",
"animalia_cow_3.png",
"animalia_cow_4.png"
},
animations = {
stand = {range = {x = 1, y = 60}, speed = 10, frame_blend = 0.3, loop = true},
walk = {range = {x = 70, y = 110}, speed = 40, frame_blend = 0.3, loop = true},
run = {range = {x = 70, y = 110}, speed = 50, frame_blend = 0.3, loop = true},
},
-- Physics
speed = 4,
max_fall = 3,
-- Attributes
sounds = {
alter_child_pitch = true,
random = {
name = "better_fauna_cow_idle",
name = "animalia_cow_idle",
gain = 1.0,
distance = 8
},
hurt = {
name = "better_fauna_cow_hurt",
name = "animalia_cow_hurt",
gain = 1.0,
distance = 8
},
death = {
name = "better_fauna_cow_death",
name = "animalia_cow_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,
-- Behavior
defend_owner = false,
follow = {
"farming:wheat",
},
drops = {
{name = "mobs:leather", chance = 1, min = 1, max = 2},
{name = "better_fauna:beef_raw", chance = 1, min = 1, max = 4}
consumable_nodes = {
{
name = "default:dirt_with_grass",
replacement = "default:dirt"
},
{
name = "default:dry_dirt_with_dry_grass",
replacement = "default:dry_dirt"
}
},
on_step = better_fauna.on_step,
on_activate = better_fauna.on_activate,
get_staticdata = mobkit.statfunc,
logic = cow_logic,
drops = {
{name = "animalia:leather", chance = 2, min = 1, max = 2},
{name = "animalia:beef_raw", chance = 1, min = 1, max = 4}
},
-- Functions
head_data = {
offset = {x = 0, y = 0.5, z = 0},
pitch_correction = -45,
pivot_h = 0.75,
pivot_v = 1
},
logic = cow_logic,
get_staticdata = mobkit.statfunc,
on_step = animalia.on_step,
on_activate = animalia.on_activate,
on_rightclick = function(self, clicker)
if better_fauna.feed_tame(self, clicker, 1, false, true) then return end
mob_core.protect(self, clicker, false)
if animalia.feed_tame(self, clicker, 1, false, true) then return end
mob_core.protect(self, clicker, true)
mob_core.nametag(self, clicker, true)
local tool = clicker:get_wielded_item()
@ -152,12 +192,12 @@ minetest.register_entity("better_fauna:cow",{
tool:take_item()
clicker:set_wielded_item(tool)
if inv:room_for_item("main", {name = "better_fauna:bucket_milk"}) then
clicker:get_inventory():add_item("main", "better_fauna:bucket_milk")
if inv:room_for_item("main", {name = "animalia:bucket_milk"}) then
clicker:get_inventory():add_item("main", "animalia:bucket_milk")
else
local pos = self.object:get_pos()
pos.y = pos.y + 0.5
minetest.add_item(pos, {name = "better_fauna:bucket_milk"})
minetest.add_item(pos, {name = "animalia:bucket_milk"})
end
self.gotten = mobkit.remember(self, "gotten", true)
@ -165,58 +205,55 @@ minetest.register_entity("better_fauna:cow",{
end
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, 20, puncher)
animalia.hq_sporadic_flee(self, 10)
end
})
minetest.register_craftitem("better_fauna:bucket_milk", {
minetest.register_craftitem("animalia:leather", {
description = "Leather",
inventory_image = "animalia_leather.png"
})
minetest.register_craftitem("animalia:bucket_milk", {
description = "Bucket of Milk",
inventory_image = "better_fauna_milk_bucket.png",
inventory_image = "animalia_milk_bucket.png",
stack_max = 1,
on_use = minetest.item_eat(8, "bucket:bucket_empty"),
groups = {food_milk = 1, flammable = 3},
})
minetest.register_craftitem("better_fauna:beef_raw", {
minetest.register_craftitem("animalia:beef_raw", {
description = "Raw Beef",
inventory_image = "better_fauna_beef_raw.png",
inventory_image = "animalia_beef_raw.png",
on_use = minetest.item_eat(1),
groups = {flammable = 2},
})
minetest.register_craftitem("better_fauna:beef_cooked", {
minetest.register_craftitem("animalia:beef_cooked", {
description = "Steak",
inventory_image = "better_fauna_beef_cooked.png",
inventory_image = "animalia_beef_cooked.png",
on_use = minetest.item_eat(8),
groups = {flammable = 2},
})
minetest.register_craft({
type = "cooking",
recipe = "better_fauna:beef_raw",
output = "better_fauna:beef_cooked",
recipe = "animalia:beef_raw",
output = "animalia:beef_cooked",
})
mob_core.register_spawn_egg("better_fauna:cow", "cac3a1" ,"464438")
mob_core.register_spawn_egg("animalia:cow", "cac3a1" ,"464438")
mob_core.register_spawn({
name = "better_fauna:cow",
nodes = {
"default:dirt_with_grass",
"default:dry_dirt_with_dry_grass"
},
name = "animalia:cow",
min_light = 0,
max_light = 15,
min_height = -31000,
max_height = 31000,
group = 3,
optional = {
biomes = {
"grassland",
"savanna"
}
biomes = animalia.grassland_biomes
}
}, 4, 6)
}, animalia.spawn_interval, 2)

295
mobs/horse.lua Normal file
View file

@ -0,0 +1,295 @@
-----------
-- Horse --
-----------
local random = math.random
local function set_pattern(self)
local types = {
"spots",
"patches"
}
if mobkit.recall(self, "pattern")
and not mobkit.recall(self, "pattern"):find("better_fauna") then
local pattern = mobkit.recall(self, "pattern")
local texture = self.object:get_properties().textures[1]
self.object:set_properties({
textures = {texture .. "^" .. pattern}
})
else
local type = types[random(#types)]
local overlay = "(animalia_horse_".. type ..".png)"
if type == "patches" then
local colors = {
"brown",
"white"
}
if self.texture_no < 1 then
table.insert(colors, "black")
else
table.remove(colors, 1)
end
overlay = "(animalia_horse_".. colors[random(#colors)] .."_patches.png)"
end
if random(100) > 50 then
overlay = "transparency.png"
end
local texture = self.object:get_properties().textures[1]
self.object:set_properties({
textures = {texture .. "^" .. overlay}
})
mobkit.remember(self, "pattern", overlay)
end
end
local function horse_logic(self)
if self.hp <= 0 then
mob_core.on_die(self)
return
end
if self.status ~= "following" then
if self.attention_span > 1 then
self.attention_span = self.attention_span - self.dtime
mobkit.remember(self, "attention_span", self.attention_span)
end
else
self.attention_span = self.attention_span + self.dtime
mobkit.remember(self, "attention_span", self.attention_span)
end
animalia.head_tracking(self)
if mobkit.timer(self, 1) then
local prty = mobkit.get_queue_priority(self)
local player = mobkit.get_nearby_player(self)
local pos = self.object:get_pos()
mob_core.random_sound(self, 14)
mob_core.growth(self)
if self.breaking then
if not minetest.get_player_by_name(self.breaker)
or not self.driver then
self.breaking = nil
self.breaker = nil
else
local yaw = self.object:get_yaw()
local yaw2 = minetest.get_player_by_name(self.breaker):get_look_horizontal()
if math.abs(yaw - yaw2) > 5.8
or math.abs(yaw - yaw2) < 0.5 then
self.breaking_progress = self.breaking_progress + 1
else
self.breaking_progress = self.breaking_progress - 1
end
animalia.hq_sporadic_flee(self, 10)
if self.breaking_progress < -5
or minetest.get_player_by_name(self.breaker):get_player_control().sneak then
mob_core.detach(self.driver, {x = 1, y = 0, z = 1})
mobkit.lq_idle(self, 0.5, "rear")
self.breaking = nil
self.breaker = nil
self.breaking_progress = nil
elseif self.breaking_progress > 5 then
mob_core.set_owner(self, self.breaker)
self.breaking = nil
self.breaker = nil
self.breaking_progress = nil
local prt_pos = vector.new(pos.x, pos.y + 2, pos.z)
local minppos = vector.add(prt_pos, 1)
local maxppos = vector.subtract(prt_pos, 1)
animalia.particle_spawner(prt_pos, "mob_core_green_particle.png", "float", minppos, maxppos)
mobkit.clear_queue_high(self)
end
end
return
end
if prty < 20
and self.driver
and not self.breaking then
animalia.hq_mount_logic(self, 20)
end
if prty < 5
and self.isinliquid then
animalia.hq_go_to_land(self, 5)
end
if prty < 4
and self.breeding then
animalia.hq_horse_breed(self, 4)
end
if prty == 2
and not self.lasso_player
and (not player
or not mob_core.follow_holding(self, player)) then
mobkit.clear_queue_high(self)
end
if prty < 2 then
if self.caught_with_lasso
and self.lasso_player then
animalia.hq_follow_player(self, 2, self.lasso_player, true)
elseif player then
if self.attention_span < 5 then
if mob_core.follow_holding(self, player) then
animalia.hq_follow_player(self, 2, player)
self.attention_span = self.attention_span + 1
end
end
end
end
if mobkit.is_queue_empty_high(self) then
animalia.hq_wander_group(self, 0, 12)
end
end
end
animalia.register_mob("horse", {
-- Stats
health = 40,
fleshy = 100,
view_range = 32,
lung_capacity = 10,
-- Visual
collisionbox = {-0.65, 0, -0.65, 0.65, 1.95, 0.65},
visual_size = {x = 10, y = 10},
mesh = "animalia_horse.b3d",
textures = {
"animalia_horse_1.png",
"animalia_horse_2.png",
"animalia_horse_3.png",
"animalia_horse_4.png",
"animalia_horse_5.png",
"animalia_horse_6.png"
},
animations = {
stand = {range = {x = 1, y = 60}, speed = 10, frame_blend = 0.3, loop = true},
walk = {range = {x = 70, y = 110}, speed = 25, frame_blend = 0.3, loop = true},
run = {range = {x = 70, y = 110}, speed = 45, frame_blend = 0.3, loop = true},
rear = {range = {x = 120, y = 150}, speed = 27, frame_blend = 0.2, loop = false},
rear_constant = {range = {x = 130, y = 140}, speed = 20, frame_blend = 0.3, loop = true}
},
-- Physics
speed = 10,
max_fall = 8,
-- Attributes
sounds = {
alter_child_pitch = true,
random = {
{
name = "animalia_horse_idle_1",
gain = 1.0,
distance = 8
},
{
name = "animalia_horse_idle_2",
gain = 1.0,
distance = 8
},
{
name = "animalia_horse_idle_3",
gain = 1.0,
distance = 8
}
},
hurt = {
name = "animalia_horse_hurt",
gain = 1.0,
distance = 8
},
death = {
name = "animalia_horse_death",
gain = 1.0,
distance = 8
}
},
-- Behavior
defend_owner = false,
follow = {
"farming:wheat",
},
drops = {
{name = "animalia:leather", chance = 2, min = 1, max = 4},
},
player_rotation = {x = -60, y = 180, z = 0},
driver_scale = {x = 0.1, y = 0.1},
driver_attach_at = {x = 0, y = 1.1, z = 0.5},
driver_attach_bone = "Torso",
driver_eye_offset = {{x = 0, y = 15, z = 0}, {x = 0, y = 15, z = 15}},
-- Functions
head_data = {
bone = "Neck.CTRL",
offset = {x = 0, y = 1.98, z = 0},
pitch_correction = 35,
pivot_h = 1,
pivot_v = 1.5
},
logic = horse_logic,
get_staticdata = mobkit.statfunc,
on_step = animalia.on_step,
on_activate = function(self, staticdata, dtime_s)
animalia.on_activate(self, staticdata, dtime_s)
set_pattern(self)
self.saddled = mobkit.recall(self, "saddled") or false
self.max_hp = mobkit.recall(self, "max_hp") or random(30, 45)
self.speed = mobkit.recall(self, "speed") or random(5, 10)
self.jump_power = mobkit.recall(self, "speed") or random(2, 5)
if self.saddled then
local texture = self.object:get_properties().textures[1]
self.object:set_properties({
textures = {texture .. "^animalia_horse_saddle.png"}
})
end
end,
on_rightclick = function(self, clicker)
if animalia.feed_tame(self, clicker, 1, false, true) then return end
mob_core.protect(self, clicker, false)
mob_core.nametag(self, clicker, true)
local tool = clicker:get_wielded_item()
if self.tamed
and self.owner == clicker:get_player_name() then
if self.saddled
and tool:get_name() == "" then
mob_core.mount(self, clicker)
elseif tool:get_name() == "animalia:saddle" then
self.saddled = mobkit.remember(self, "saddled", true)
local texture = self.object:get_properties().textures[1]
self.object:set_properties({
textures = {texture .. "^animalia_horse_saddle.png"}
})
tool:take_item()
clicker:set_wielded_item(tool)
end
elseif not self.tamed
and tool:get_name() == "" then
mob_core.mount(self, clicker)
self.breaking = true
self.breaker = clicker:get_player_name()
self.breaking_progress = 0
end
end,
on_punch = function(self, puncher, _, tool_capabilities, dir)
mob_core.on_punch_basic(self, puncher, tool_capabilities, dir)
animalia.hq_sporadic_flee(self, 10)
end
})
mob_core.register_spawn_egg("animalia:horse", "ebdfd8" ,"653818")
mob_core.register_spawn({
name = "animalia:horse",
min_light = 0,
max_light = 15,
min_height = -31000,
max_height = 31000,
group = 6,
optional = {
biomes = animalia.grassland_biomes
}
}, animalia.spawn_interval, 8)

View file

@ -2,8 +2,6 @@
-- Pig --
---------
local blend = better_fauna.frame_blend
local function pig_logic(self)
if self.hp <= 0 then
@ -11,148 +9,162 @@ local function pig_logic(self)
return
end
local pos = mobkit.get_stand_pos(self)
local prty = mobkit.get_queue_priority(self)
local player = mobkit.get_nearby_player(self)
if self.status ~= "following" then
if self.attention_span > 1 then
self.attention_span = self.attention_span - self.dtime
mobkit.remember(self, "attention_span", self.attention_span)
end
else
self.attention_span = self.attention_span + self.dtime
mobkit.remember(self, "attention_span", self.attention_span)
end
mob_core.random_sound(self, 16/self.dtime)
if mobkit.timer(self, 3) then
if mobkit.timer(self,1) then
local prty = mobkit.get_queue_priority(self)
local player = mobkit.get_nearby_player(self)
mob_core.vitals(self)
mob_core.random_sound(self, 14)
mob_core.growth(self)
if self.status ~= "following" then
if self.attention_span > 1 then
self.attention_span = self.attention_span - 1
mobkit.remember(self, "attention_span", self.attention_span)
end
else
self.attention_span = self.attention_span + 1
mobkit.remember(self, "attention_span", self.attention_span)
if prty < 4
and self.isinliquid then
animalia.hq_go_to_land(self, 4)
end
if prty < 3
and self.breeding then
better_fauna.hq_breed(self, 3)
animalia.hq_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
if prty == 2
and not self.lasso_player
and (not player
or not mob_core.follow_holding(self, player)) then
mobkit.clear_queue_high(self)
end
if prty < 2 then
if self.caught_with_lasso
and self.lasso_player then
animalia.hq_follow_player(self, 2, self.lasso_player, true)
elseif player then
if self.attention_span < 5 then
if mob_core.follow_holding(self, player) then
animalia.hq_follow_player(self, 2, player)
self.attention_span = self.attention_span + 3
end
end
end
end
if mobkit.is_queue_empty_high(self) then
mob_core.hq_roam(self, 0)
animalia.hq_wander_group(self, 0, 8)
end
end
end
local random = math.random
minetest.register_entity("better_fauna:pig",{
max_hp = 20,
view_range = 16,
armor_groups = {fleshy = 100},
physical = true,
collide_with_objects = true,
animalia.register_mob("pig", {
-- Stats
health = 20,
fleshy = 100,
view_range = 32,
lung_capacity = 10,
-- Visual
collisionbox = {-0.35, -0.45, -0.35, 0.35, 0.4, 0.35},
visual_size = {x = 11, y = 11},
scale_stage1 = 0.5,
scale_stage2 = 0.65,
scale_stage3 = 0.80,
visual = "mesh",
mesh = "better_fauna_pig.b3d",
textures = {
"better_fauna_pig_1.png",
"better_fauna_pig_2.png",
"better_fauna_pig_3.png"
mesh = "animalia_pig.b3d",
female_textures = {
"animalia_pig_1.png",
"animalia_pig_2.png",
"animalia_pig_3.png"
},
animation = {
stand = {range = {x = 30, y = 50}, speed = 10, frame_blend = blend, loop = true},
walk = {range = {x = 1, y = 20}, speed = 30, frame_blend = blend, loop = true},
run = {range = {x = 1, y = 20}, speed = 45, frame_blend = blend, loop = true},
male_textures = {
"animalia_pig_1.png^animalia_pig_tusks.png",
"animalia_pig_2.png^animalia_pig_tusks.png",
"animalia_pig_3.png^animalia_pig_tusks.png"
},
child_textures = {
"animalia_pig_1.png",
"animalia_pig_2.png",
"animalia_pig_3.png"
},
animations = {
stand = {range = {x = 30, y = 50}, speed = 10, frame_blend = 0.3, loop = true},
walk = {range = {x = 1, y = 20}, speed = 30, frame_blend = 0.3, loop = true},
run = {range = {x = 1, y = 20}, speed = 45, frame_blend = 0.3, loop = true},
},
-- Physics
speed = 4,
max_fall = 3,
-- Attributes
sounds = {
alter_child_pitch = true,
random = {
name = "better_fauna_pig_idle",
name = "animalia_pig_idle",
gain = 1.0,
distance = 8
},
hurt = {
name = "better_fauna_pig_idle",
name = "animalia_pig_idle",
gain = 1.0,
pitch = 0.5,
distance = 8
},
death = {
name = "better_fauna_pig_death",
name = "animalia_pig_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,
-- Behavior
defend_owner = false,
follow = {
"farming:carrot"
},
drops = {
{name = "better_fauna:porkchop_raw", chance = 1, min = 1, max = 4}
{name = "animalia:porkchop_raw", chance = 1, min = 1, max = 4}
},
on_step = better_fauna.on_step,
on_activate = better_fauna.on_activate,
get_staticdata = mobkit.statfunc,
logic = pig_logic,
-- Functions
logic = pig_logic,
get_staticdata = mobkit.statfunc,
on_step = animalia.on_step,
on_activate = animalia.on_activate,
on_rightclick = function(self, clicker)
if better_fauna.feed_tame(self, clicker, 1, false, true) then return end
mob_core.protect(self, clicker, false)
if animalia.feed_tame(self, clicker, 1, false, true) then return end
mob_core.protect(self, clicker, true)
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, 20, puncher)
animalia.hq_sporadic_flee(self, 10)
end
})
minetest.register_craftitem("better_fauna:porkchop_raw", {
minetest.register_craftitem("animalia:porkchop_raw", {
description = "Raw Porkchop",
inventory_image = "better_fauna_porkchop_raw.png",
inventory_image = "animalia_porkchop_raw.png",
on_use = minetest.item_eat(1),
groups = {flammable = 2},
})
minetest.register_craftitem("better_fauna:porkchop_cooked", {
minetest.register_craftitem("animalia:porkchop_cooked", {
description = "Cooked Porkchop",
inventory_image = "better_fauna_porkchop_cooked.png",
inventory_image = "animalia_porkchop_cooked.png",
on_use = minetest.item_eat(7),
groups = {flammable = 2},
})
minetest.register_craft({
type = "cooking",
recipe = "better_fauna:porkchop_raw",
output = "better_fauna:porkchop_cooked",
recipe = "animalia:porkchop_raw",
output = "animalia:porkchop_cooked",
})
mob_core.register_spawn_egg("better_fauna:pig", "e0b1a7" ,"cc9485")
mob_core.register_spawn_egg("animalia:pig", "e0b1a7" ,"cc9485")
mob_core.register_spawn({
name = "better_fauna:pig",
name = "animalia:pig",
nodes = {"default:dirt_with_grass"},
min_light = 0,
max_light = 15,
@ -161,8 +173,9 @@ mob_core.register_spawn({
group = 3,
optional = {
biomes = {
"grassland",
"deciduous_forest"
unpack(animalia.grassland_biomes),
unpack(animalia.temperate_biomes),
unpack(animalia.boreal_biomes)
}
}
}, 16, 1)
}, animalia.spawn_interval, 4)

View file

@ -2,7 +2,7 @@
-- Sheep --
-----------
local blend = better_fauna.frame_blend
local creative = minetest.settings:get_bool("creative_mode")
local palette = {
{"black", "Black", "#000000b0"},
@ -22,6 +22,10 @@ local palette = {
{"yellow", "Yellow", "#e3ff0070"},
}
local clamp_bone_rot = animalia.clamp_bone_rot
local interp = animalia.interp
local min = math.min
local abs = math.abs
local random = math.random
@ -33,109 +37,113 @@ local function sheep_logic(self)
return
end
local pos = mobkit.get_stand_pos(self)
local prty = mobkit.get_queue_priority(self)
local player = mobkit.get_nearby_player(self)
if self.status ~= "following" then
if self.attention_span > 1 then
self.attention_span = self.attention_span - self.dtime
mobkit.remember(self, "attention_span", self.attention_span)
end
else
self.attention_span = self.attention_span + self.dtime
mobkit.remember(self, "attention_span", self.attention_span)
end
mob_core.random_sound(self, 16/self.dtime)
animalia.head_tracking(self, 0.5, 0.5)
if mobkit.timer(self,1) then
if mobkit.timer(self, 3) then
mob_core.vitals(self)
local pos = mobkit.get_stand_pos(self)
local prty = mobkit.get_queue_priority(self)
local player = mobkit.get_nearby_player(self)
mob_core.random_sound(self, 14)
mob_core.growth(self)
if self.status ~= "following" then
if self.attention_span > 1 then
self.attention_span = self.attention_span - 1
mobkit.remember(self, "attention_span", self.attention_span)
end
else
self.attention_span = self.attention_span + 1
mobkit.remember(self, "attention_span", self.attention_span)
if prty < 5
and self.isinliquid then
animalia.hq_go_to_land(self, 5)
end
if prty < 4
and self.breeding then
better_fauna.hq_breed(self, 4)
animalia.hq_breed(self, 4)
end
if prty < 3
and self.gotten
and math.random(1, 16) == 1 then
better_fauna.hq_eat(self, 3)
animalia.hq_eat(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
if prty == 2
and not self.lasso_player
and (not player
or not mob_core.follow_holding(self, player)) then
mobkit.clear_queue_high(self)
end
if prty < 2 then
if self.caught_with_lasso
and self.lasso_player then
animalia.hq_follow_player(self, 2, self.lasso_player, true)
elseif player then
if self.attention_span < 5 then
if mob_core.follow_holding(self, player) then
animalia.hq_follow_player(self, 2, player)
self.attention_span = self.attention_span + 3
end
end
end
end
if mobkit.is_queue_empty_high(self) then
mob_core.hq_roam(self, 0)
animalia.hq_wander_group(self, 0, 12)
end
end
end
minetest.register_entity("better_fauna:sheep",{
max_hp = 20,
view_range = 16,
armor_groups = {fleshy = 100},
physical = true,
collide_with_objects = true,
collisionbox = {-0.4, -0.4, -0.4, 0.4, 0.4, 0.4},
animalia.register_mob("sheep", {
-- Stats
health = 20,
fleshy = 100,
view_range = 32,
lung_capacity = 10,
-- Visual
collisionbox = {-0.4, 0, -0.4, 0.4, 0.8, 0.4},
visual_size = {x = 10, y = 10},
scale_stage1 = 0.5,
scale_stage2 = 0.65,
scale_stage3 = 0.80,
visual = "mesh",
mesh = "better_fauna_sheep.b3d",
textures = {"better_fauna_sheep.png^better_fauna_sheep_wool.png"},
child_textures = {"better_fauna_sheep.png"},
animation = {
stand = {range = {x = 30, y = 50}, speed = 10, frame_blend = blend, loop = true},
walk = {range = {x = 1, y = 20}, speed = 30, frame_blend = blend, loop = true},
run = {range = {x = 1, y = 20}, speed = 45, frame_blend = blend, loop = true},
mesh = "animalia_sheep.b3d",
textures = {"animalia_sheep.png^animalia_sheep_wool.png"},
child_textures = {"animalia_sheep.png"},
animations = {
stand = {range = {x = 1, y = 60}, speed = 10, frame_blend = 0.3, loop = true},
walk = {range = {x = 70, y = 110}, speed = 40, frame_blend = 0.3, loop = true},
run = {range = {x = 70, y = 110}, speed = 50, frame_blend = 0.3, loop = true},
},
-- Physics
speed = 4,
max_fall = 3,
-- Attributes
sounds = {
alter_child_pitch = true,
random = {
name = "better_fauna_sheep_idle",
name = "animalia_sheep_idle",
gain = 1.0,
distance = 8
},
hurt = {
name = "better_fauna_sheep_idle",
name = "animalia_sheep_hurt",
gain = 1.0,
pitch = 0.5,
distance = 8
},
death = {
name = "better_fauna_sheep_idle",
name = "animalia_sheep_death",
gain = 1.0,
pitch = 0.25,
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,
-- Behavior
defend_owner = false,
follow = {
"farming:wheat"
},
drops = {
{name = "better_fauna:mutton_raw", chance = 1, min = 1, max = 4}
"farming:wheat",
},
consumable_nodes = {
{
@ -147,43 +155,53 @@ minetest.register_entity("better_fauna:sheep",{
replacement = "default:dry_dirt"
}
},
get_staticdata = mobkit.statfunc,
logic = sheep_logic,
drops = {
{name = "animalia:mutton_raw", chance = 1, min = 1, max = 4}
},
-- Functions
head_data = {
offset = {x = 0, y = 0.41, z = 0},
pitch_correction = -45,
pivot_h = 0.75,
pivot_v = 0.85
},
logic = sheep_logic,
get_staticdata = mobkit.statfunc,
on_step = function(self, dtime, moveresult)
better_fauna.on_step(self, dtime, moveresult)
animalia.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] == "animalia_sheep.png"
and not self.gotten then
self.object:set_properties({
textures = {"better_fauna_sheep.png^better_fauna_sheep_wool.png"},
textures = {"animalia_sheep.png^animalia_sheep_wool.png"},
})
end
end
end,
on_activate = function(self, staticdata, dtime_s)
better_fauna.on_activate(self, staticdata, dtime_s)
animalia.on_activate(self, staticdata, dtime_s)
self.dye_color = mobkit.recall(self, "dye_color") or "white"
self.dye_hex = mobkit.recall(self, "dye_hex") or ""
if self.dye_color ~= "white"
and not self.gotten then
self.object:set_properties({
textures = {"better_fauna_sheep.png^(better_fauna_sheep_wool.png^[colorize:" .. self.dye_hex .. ")"},
textures = {"animalia_sheep.png^(animalia_sheep_wool.png^[colorize:" .. self.dye_hex .. ")"},
})
end
if self.gotten then
self.object:set_properties({
textures = {"better_fauna_sheep.png"},
textures = {"animalia_sheep.png"},
})
end
end,
on_rightclick = function(self, clicker)
if better_fauna.feed_tame(self, clicker, 1, false, true) then return end
mob_core.protect(self, clicker, false)
if animalia.feed_tame(self, clicker, 1, false, true) then return end
mob_core.protect(self, clicker, true)
mob_core.nametag(self, clicker, true)
local item = clicker:get_wielded_item()
local itemname = item:get_name()
local name = clicker:get_player_name()
if itemname == "mobs:shears"
if itemname == "animalia:shears"
and not self.gotten
and not self.child then
if not minetest.get_modpath("wool") then
@ -204,7 +222,7 @@ minetest.register_entity("better_fauna:sheep",{
clicker:set_wielded_item(item)
self.object:set_properties({
textures = {"better_fauna_sheep.png"},
textures = {"animalia_sheep.png"},
})
end
for _, color in ipairs(palette) do
@ -218,15 +236,15 @@ minetest.register_entity("better_fauna:sheep",{
self.dye_hex = mobkit.remember(self, "dye_hex", color[3])
self.drops = {
{name = "better_fauna:mutton_raw", chance = 1, min = 1, max = 4},
{name = "animalia:mutton_raw", chance = 1, min = 1, max = 4},
{name = "wool:"..self.dye_color, chance = 2, min = 1, max = 2},
}
self.object:set_properties({
textures = {"better_fauna_sheep.png^(better_fauna_sheep_wool.png^[colorize:" .. color[3] .. ")"},
textures = {"animalia_sheep.png^(animalia_sheep_wool.png^[colorize:" .. color[3] .. ")"},
})
if not mobs.is_creative(clicker:get_player_name()) then
if not creative then
item:take_item()
clicker:set_wielded_item(item)
end
@ -235,44 +253,44 @@ minetest.register_entity("better_fauna:sheep",{
end
end
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,
animalia.hq_sporadic_flee(self, 10)
end
})
mob_core.register_spawn_egg("better_fauna:sheep", "f4e6cf", "e1ca9b")
mob_core.register_spawn_egg("animalia:sheep", "f4e6cf", "e1ca9b")
mob_core.register_spawn({
name = "better_fauna:sheep",
nodes = {"default:dirt_with_grass"},
name = "animalia:sheep",
min_light = 0,
max_light = 15,
min_height = -31000,
max_height = 31000,
min_rad = 24,
max_rad = 256,
group = 6
}, 2, 8)
group = 6,
optional = {
biomes = animalia.grassland_biomes
}
}, animalia.spawn_interval, 4)
minetest.register_craftitem("better_fauna:mutton_raw", {
minetest.register_craftitem("animalia:mutton_raw", {
description = "Raw Mutton",
inventory_image = "better_fauna_mutton_raw.png",
inventory_image = "animalia_mutton_raw.png",
on_use = minetest.item_eat(1),
groups = {flammable = 2},
})
minetest.register_craftitem("better_fauna:mutton_cooked", {
minetest.register_craftitem("animalia:mutton_cooked", {
description = "Cooked Mutton",
inventory_image = "better_fauna_mutton_cooked.png",
inventory_image = "animalia_mutton_cooked.png",
on_use = minetest.item_eat(6),
groups = {flammable = 2},
})
minetest.register_craft({
type = "cooking",
recipe = "better_fauna:mutton_raw",
output = "better_fauna:mutton_cooked",
recipe = "animalia:mutton_raw",
output = "animalia:mutton_cooked",
})

View file

@ -2,7 +2,9 @@
-- Turkey --
------------
local blend = better_fauna.frame_blend
local clamp_bone_rot = animalia.clamp_bone_rot
local interp = animalia.interp
local function turkey_logic(self)
@ -10,115 +12,141 @@ local function turkey_logic(self)
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
if self.status ~= "following" then
if self.attention_span > 1 then
self.attention_span = self.attention_span - self.dtime
mobkit.remember(self, "attention_span", self.attention_span)
end
else
self.attention_span = self.attention_span + self.dtime
mobkit.remember(self, "attention_span", self.attention_span)
end
mob_core.vitals(self)
mob_core.random_sound(self, 12)
animalia.head_tracking(self, 0.45, 0.25)
if mobkit.timer(self, 3) then
local prty = mobkit.get_queue_priority(self)
local player = mobkit.get_nearby_player(self)
mob_core.random_sound(self, 14)
if prty < 4
and self.isinliquid then
animalia.hq_go_to_land(self, 4)
end
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
animalia.hq_fowl_breed(self, 3)
end
if prty == 2
and not self.lasso_player
and (not player
or not mob_core.follow_holding(self, player)) then
mobkit.clear_queue_high(self)
end
if prty < 2 then
if self.caught_with_lasso
and self.lasso_player then
animalia.hq_follow_player(self, 2, self.lasso_player, true)
elseif player then
if self.attention_span < 5 then
if mob_core.follow_holding(self, player) then
animalia.hq_follow_player(self, 2, player)
self.attention_span = self.attention_span + 3
end
end
end
end
if mobkit.is_queue_empty_high(self) then
mob_core.hq_roam(self, 0)
animalia.hq_wander_group(self, 0, 8)
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,
animalia.register_mob("turkey", {
-- Stats
health = 15,
fleshy = 100,
view_range = 26,
lung_capacity = 10,
-- Visual
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},
mesh = "animalia_turkey.b3d",
female_textures = {"animalia_turkey_hen.png"},
male_textures = {"animalia_turkey_tom.png"},
child_textures = {"animalia_turkey_chick.png"},
animations = {
stand = {range = {x = 0, y = 0}, speed = 1, frame_blend = 0.3, loop = true},
walk = {range = {x = 10, y = 30}, speed = 30, frame_blend = 0.3, loop = true},
run = {range = {x = 40, y = 60}, speed = 45, frame_blend = 0.3, loop = true},
fall = {range = {x = 70, y = 90}, speed = 30, frame_blend = 0.3, loop = true},
},
-- Physics
speed = 5,
max_fall = 6,
-- Attributes
sounds = {
alter_child_pitch = true,
random = {
name = "better_fauna_turkey_idle",
name = "animalia_turkey_idle",
gain = 1.0,
distance = 8
},
hurt = {
name = "better_fauna_turkey_hurt",
name = "animalia_turkey_hurt",
gain = 1.0,
distance = 8
},
death = {
name = "better_fauna_turkey_death",
name = "animalia_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,
-- Behavior
defend_owner = false,
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}
{name = "animalia:feather", chance = 1, min = 1, max = 2},
{name = "animalia:poultry_raw", chance = 1, min = 2, max = 5}
},
on_step = better_fauna.on_step,
on_activate = better_fauna.on_activate,
get_staticdata = mobkit.statfunc,
phsyics = better_fauna.lightweight_physics,
-- Functions
head_data = {
offset = {x = 0, y = 0.15, z = 0},
pitch_correction = 45,
pivot_h = 0.45,
pivot_v = 0.65
},
physics = animalia.lightweight_physics,
logic = turkey_logic,
get_staticdata = mobkit.statfunc,
on_step = animalia.on_step,
on_activate = animalia.on_activate,
on_rightclick = function(self, clicker)
if better_fauna.feed_tame(self, clicker, 1, false, true) then return end
mob_core.protect(self, clicker, false)
if animalia.feed_tame(self, clicker, 1, false, true) then return end
mob_core.protect(self, clicker, true)
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)
animalia.hq_sporadic_flee(self, 10)
end,
})
mob_core.register_spawn_egg("better_fauna:turkey", "352b22", "2f2721")
mob_core.register_spawn_egg("animalia:turkey", "352b22", "2f2721")
mob_core.register_spawn({
name = "better_fauna:turkey",
nodes = {"default:dry_dirt_with_dry_grass", "default:dirt_with_grass"},
name = "animalia:turkey",
min_light = 0,
max_light = 15,
min_height = -31000,
@ -127,30 +155,6 @@ mob_core.register_spawn({
max_rad = 256,
group = 6,
optional = {
biomes = {
"deciduous_forest",
"taiga"
}
biomes = animalia.temperate_biomes
}
}, 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",
})
}, animalia.spawn_interval, 6)

237
mobs/wolf.lua Normal file
View file

@ -0,0 +1,237 @@
----------
-- Wolf --
----------
local clamp_bone_rot = animalia.clamp_bone_rot
local interp = animalia.interp
local follow = {
"animalia:mutton_raw",
"animalia:beef_raw",
"animalia:porkchop_raw",
"animalia:poultry_raw"
}
if minetest.registered_items["bonemeal:bone"] then
follow = {
"bonemeal:bone",
"animalia:beef_raw",
"animalia:porkchop_raw",
"animalia:mutton_raw",
"animalia:poultry_raw"
}
end
function animalia.bh_attack(self, prty, target)
if mobkit.is_alive(target) then
if target:is_player() then
if not self.tamed
or target:get_player_name() ~= self.owner then
animalia.hq_attack(self, prty, target)
end
elseif target:get_luaentity() then
if not self.tamed
or not mob_core.shared_owner(self, target) then
animalia.hq_attack(self, prty, target)
end
end
end
end
local function wolf_logic(self)
if self.hp <= 0 then
mob_core.on_die(self)
return
end
animalia.head_tracking(self, 0.5, 0.75)
if mobkit.timer(self, 1) then
local prty = mobkit.get_queue_priority(self)
local player = mobkit.get_nearby_player(self)
mob_core.random_sound(self, 22)
mob_core.growth(self)
if self.status ~= "following" then
if self.attention_span > 1 then
self.attention_span = self.attention_span - 1
mobkit.remember(self, "attention_span", self.attention_span)
end
else
self.attention_span = self.attention_span + 1
mobkit.remember(self, "attention_span", self.attention_span)
end
if prty < 22
and self.order == "sit" then
if not mobkit.is_queue_empty_high(self) then
mobkit.clear_queue_high(self)
end
mobkit.animate(self, "sit")
return
end
if prty < 21
and self.owner_target then
if not mob_core.shared_owner(self, self.owner_target) then
animalia.hq_attack(self, 21, self.owner_target)
end
end
if prty < 20
and self.order == "follow"
and self.owner
and minetest.get_player_by_name(self.owner) then
local owner = minetest.get_player_by_name(self.owner)
animalia.hq_follow_player(self, 20, owner, true)
end
if prty < 5
and self.isinliquid then
animalia.hq_go_to_land(self, 5)
end
if prty < 4
and self.breeding then
animalia.hq_breed(self, 4)
end
if prty == 3
and not self.lasso_player
and (not player
or not mob_core.follow_holding(self, player)) then
mobkit.clear_queue_high(self)
end
if prty < 3 then
if self.caught_with_lasso
and self.lasso_player then
animalia.hq_follow_player(self, 3, self.lasso_player, true)
elseif player then
if self.attention_span < 5 then
if mob_core.follow_holding(self, player) then
animalia.hq_follow_player(self, 3, player)
self.attention_span = self.attention_span + 3
end
end
end
end
if prty < 2 then
local target = mobkit.get_closest_entity(self, "animalia:sheep")
if target then
animalia.bh_attack(self, 2, target)
end
end
if mobkit.is_queue_empty_high(self) then
animalia.hq_wander_group(self, 0, 8)
end
end
end
animalia.register_mob("wolf", {
-- Stats
health = 25,
fleshy = 100,
view_range = 32,
lung_capacity = 10,
-- Visual
collisionbox = {-0.35, -0.375, -0.35, 0.35, 0.4, 0.35},
visual_size = {x = 9, y = 9},
scale_stage1 = 0.5,
scale_stage2 = 0.65,
scale_stage3 = 0.80,
mesh = "animalia_wolf.b3d",
textures = {"animalia_wolf.png"},
animations = {
stand = {range = {x = 30, y = 49}, speed = 10, frame_blend = 0.3, loop = true},
sit = {range = {x = 60, y = 90}, speed = 20, frame_blend = 0.3, loop = true},
walk = {range = {x = 1, y = 20}, speed = 30, frame_blend = 0.3, loop = true},
run = {range = {x = 1, y = 20}, speed = 45, frame_blend = 0.3, loop = true},
},
-- Physics
speed = 8,
max_fall = 4,
-- Attributes
sounds = {
alter_child_pitch = true,
random = {
name = "animalia_wolf_idle",
gain = 1.0,
distance = 8
},
hurt = {
name = "animalia_wolf_hurt",
gain = 1.0,
pitch = 0.5,
distance = 8
},
death = {
name = "animalia_wolf_death",
gain = 1.0,
distance = 8
}
},
reach = 2,
damage = 3,
knockback = 2,
punch_cooldown = 1,
-- Behavior
defend_owner = true,
follow = {
"bonemeal:bone",
"animalia:beef_raw",
"animalia:porkchop_raw",
"animalia:mutton_raw",
"animalia:poultry_raw"
},
-- Functions
head_data = {
offset = {x = 0, y = 0.22, z = 0},
pitch_correction = -20,
pivot_h = 0.65,
pivot_v = 0.65
},
logic = wolf_logic,
get_staticdata = mobkit.statfunc,
on_step = animalia.on_step,
on_activate = animalia.on_activate,
on_rightclick = function(self, clicker)
if animalia.feed_tame(self, clicker, math.random(3, 5), true, true) then return end
mob_core.protect(self, clicker, false)
mob_core.nametag(self, clicker, true)
if not self.owner
or clicker:get_player_name() ~= self.owner then return end
if self.order == "wander" then
self.order = "follow"
elseif self.order == "follow" then
self.order = "sit"
else
self.order = "wander"
end
mobkit.remember(self, "order", self.order)
end,
on_punch = function(self, puncher, _, tool_capabilities, dir)
mob_core.on_punch_basic(self, puncher, tool_capabilities, dir)
animalia.bh_attack(self, 10, puncher)
end
})
mob_core.register_spawn_egg("animalia:wolf", "a19678" ,"231b13")
mob_core.register_spawn({
name = "animalia:wolf",
min_light = 0,
max_light = 15,
min_height = -31000,
max_height = 31000,
group = 4,
optional = {
biomes = animalia.temperate_biomes
}
}, animalia.spawn_interval, 4)