write something there

This commit is contained in:
N-Nachtigal 2025-05-04 16:01:41 +02:00
commit b4b6c08f4f
8546 changed files with 309825 additions and 0 deletions

178
mods/animalia/mobs/bat.lua Normal file
View file

@ -0,0 +1,178 @@
---------
-- Bat --
---------
local vec_dist = vector.distance
local function get_home_pos(self)
local pos = self.object:get_pos()
if not pos then return end
local nodes = minetest.find_nodes_in_area(
vector.subtract(pos, 16),
vector.add(pos, 16),
{"group:leaves", "group:stone"}
)
local home_dist
local new_home
for _, n_pos in ipairs(nodes or {}) do
local dist = vec_dist(pos, n_pos)
if not home_dist
or dist < home_dist then
n_pos.y = n_pos.y - 1
if creatura.get_node_def(n_pos).name == "air" then
home_dist = dist
new_home = n_pos
end
end
end
if new_home then
self.home_position = self:memorize("home_position", new_home)
end
end
creatura.register_mob("animalia:bat", {
-- Engine Props
visual_size = {x = 10, y = 10},
mesh = "animalia_bat.b3d",
textures = {
"animalia_bat_1.png",
"animalia_bat_2.png",
"animalia_bat_3.png",
},
makes_footstep_sound = false,
-- Creatura Props
max_health = 2,
armor_groups = {fleshy = 100},
damage = 0,
speed = 4,
tracking_range = 12,
max_boids = 3,
despawn_after = 200,
max_fall = 0,
sounds = {
random = {
name = "animalia_bat",
gain = 0.5,
distance = 16
}
},
hitbox = {
width = 0.15,
height = 0.3
},
animations = {
stand = {range = {x = 1, y = 40}, speed = 10, frame_blend = 0.3, loop = true},
walk = {range = {x = 51, y = 69}, speed = 30, frame_blend = 0.3, loop = true},
fly = {range = {x = 81, y = 99}, speed = 80, frame_blend = 0.3, loop = true},
latch_ceiling = {range = {x = 110, y = 110}, speed = 1, frame_blend = 0, loop = false}
},
follow = {
"butterflies:butterfly_red",
"butterflies:butterfly_white",
"butterflies:butterfly_violet"
},
-- Animalia Props
flee_puncher = true,
catch_with_net = true,
catch_with_lasso = false,
roost_action = animalia.action_latch,
-- Functions
utility_stack = {
animalia.mob_ai.fly_wander,
animalia.mob_ai.swim_seek_land,
animalia.mob_ai.bat_seek_home
},
is_home = function(pos, home_pos)
local dist = vec_dist(pos, home_pos)
if dist < 4 then
local above = {x = pos.x, y = pos.y + 1, z = pos.z}
if creatura.get_node_def(above).walkable
or dist < 1 then
return true
end
end
return false
end,
activate_func = function(self)
animalia.initialize_api(self)
self.home_position = self:recall("home_position") or nil
local home_pos = self.home_position
self.is_landed = self:recall("is_landed") or false
self.trust = self:recall("trust") or {}
if not home_pos
or not creatura.get_node_def(home_pos).walkable then
get_home_pos(self)
end
end,
step_func = function(self)
animalia.step_timers(self)
animalia.do_growth(self, 60)
animalia.rotate_to_pitch(self)
animalia.random_sound(self)
if not self.is_landed
or not self.touching_ground then
self.speed = 4
else
self.speed = 1
end
if self:timer(10)
and math.random(10) < 2 then
local anim = self._anim or ""
if anim == "cling" then
local colony = creatura.get_nearby_objects(self, self.name)
local pos = self.object:get_pos()
if not pos then return end
local center = pos
if #colony > 0 then
local pos_sum = center
local pos_ttl = 1
for _, object in ipairs(colony) do
local obj_pos = object and object:get_pos()
if obj_pos then
pos_sum = vector.add(pos_sum, obj_pos)
pos_ttl = pos_ttl + 1
end
end
center = vector.divide(pos_sum, pos_ttl)
end
center = creatura.get_ground_level(center, 8)
if center.y < pos.y then
local under = {x = center.x, y = center.y - 1, z = center.z}
if creatura.get_node_def(under).walkable
and not minetest.is_protected(center, "") then
minetest.set_node(center, {name = "animalia:guano"})
end
end
end
end
end,
death_func = function(self)
if self:get_utility() ~= "animalia:die" then
self:initiate_utility("animalia:die", self)
end
end,
on_rightclick = function(self, clicker)
if animalia.feed(self, clicker, false, false) then
animalia.add_trust(self, clicker, 1)
return
end
if animalia.set_nametag(self, clicker) then
return
end
end,
on_punch = animalia.punch
})
creatura.register_spawn_item("animalia:bat", {
col1 = "392517",
col2 = "321b0b"
})

123
mods/animalia/mobs/bear.lua Normal file
View file

@ -0,0 +1,123 @@
----------
-- Bear --
----------
creatura.register_mob("animalia:grizzly_bear", {
-- Engine Props
visual_size = {x = 10, y = 10},
mesh = "animalia_bear.b3d",
textures = {
"animalia_bear_grizzly.png"
},
makes_footstep_sound = true,
-- Creatura Props
max_health = 20,
armor_groups = {fleshy = 100},
damage = 6,
speed = 4,
tracking_range = 10,
despawn_after = 1000,
max_fall = 3,
stepheight = 1.1,
sounds = {
random = {
name = "animalia_bear",
gain = 0.5,
distance = 8
},
hurt = {
name = "animalia_bear_hurt",
gain = 0.5,
distance = 8
},
death = {
name = "animalia_bear_death",
gain = 0.5,
distance = 8
}
},
hitbox = {
width = 0.5,
height = 1
},
animations = {
stand = {range = {x = 1, y = 59}, speed = 10, frame_blend = 0.3, loop = true},
walk = {range = {x = 61, y = 79}, speed = 10, frame_blend = 0.3, loop = true},
run = {range = {x = 81, y = 99}, speed = 20, frame_blend = 0.3, loop = true},
melee = {range = {x = 101, y = 120}, speed = 30, frame_blend = 0.3, loop = false}
},
follow = animalia.food_bear,
drops = {
{name = "animalia:pelt_bear", min = 1, max = 3, chance = 1},
animalia.bones,
},
fancy_collide = false,
-- Behavior Parameters
attacks_players = true,
-- Animalia Parameters
catch_with_net = true,
catch_with_lasso = true,
head_data = {
offset = {x = 0, y = 0.35, z = 0.0},
pitch_correction = -45,
pivot_h = 0.75,
pivot_v = 1
},
-- Functions
utility_stack = {
animalia.mob_ai.basic_wander,
animalia.mob_ai.swim_seek_land,
animalia.mob_ai.basic_seek_food,
animalia.mob_ai.basic_attack,
animalia.mob_ai.basic_breed
},
on_eat_drop = function(self)
local feed_no = (self.feed_no or 0) + 1
if feed_no >= 5 then
feed_no = 0
if self.breeding then return false end
if self.breeding_cooldown <= 0 then
self.breeding = true
self.breeding_cooldown = 60
animalia.particle_spawner(self.stand_pos, "heart.png", "float")
end
self._despawn = self:memorize("_despawn", false)
self.despawn_after = self:memorize("despawn_after", false)
end
self.feed_no = feed_no
end,
activate_func = function(self)
animalia.initialize_api(self)
animalia.initialize_lasso(self)
end,
step_func = function(self)
animalia.step_timers(self)
animalia.head_tracking(self, 0.75, 0.75)
animalia.do_growth(self, 60)
animalia.update_lasso_effects(self)
animalia.random_sound(self)
end,
death_func = function(self)
if self:get_utility() ~= "animalia:die" then
self:initiate_utility("animalia:die", self)
end
end,
on_punch = animalia.punch
})
creatura.register_spawn_item("animalia:grizzly_bear", {
col1 = "64361d",
col2 = "2c0d03"
})

227
mods/animalia/mobs/cat.lua Normal file
View file

@ -0,0 +1,227 @@
---------
-- Cat --
---------
local follow = {
"animalia:poultry_raw"
}
if minetest.registered_items["ethereal:fish_raw"] then
follow = {
"ethereal:fish_raw",
"animalia:poultry_raw"
}
end
creatura.register_mob("animalia:cat", {
-- Engine Props
visual_size = {x = 10, y = 10},
mesh = "animalia_cat.b3d",
textures = {
"animalia_cat_1.png",
"animalia_cat_2.png",
"animalia_cat_3.png",
"animalia_cat_4.png",
"animalia_cat_5.png",
"animalia_cat_6.png",
"animalia_cat_7.png",
"animalia_cat_8.png",
"animalia_cat_9.png",
"animalia_cat_ash.png",
"animalia_cat_birch.png",
},
use_texture_alpha = false,
makes_footstep_sound = false,
backface_culling = true,
glow = 0,
-- Creatura Props
max_health = 10,
damage = 1,
speed = 3,
tracking_range = 16,
max_boids = 0,
despawn_after = 500,
max_fall = 0,
stepheight = 1.1,
sounds = {
random = {
name = "animalia_cat",
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
}
},
hitbox = {
width = 0.2,
height = 0.4
},
animations = {
stand = {range = {x = 1, y = 60}, speed = 20, frame_blend = 0.3, loop = true},
walk = {range = {x = 70, y = 89}, speed = 30, frame_blend = 0.3, loop = true},
run = {range = {x = 100, y = 119}, speed = 40, frame_blend = 0.3, loop = true},
sit = {range = {x = 130, y = 139}, speed = 10, frame_blend = 0.3, loop = true},
},
follow = follow,
drops = {},
-- Behavior Parameters
is_skittish_mob = true,
-- Animalia Props
flee_puncher = true,
catch_with_net = true,
catch_with_lasso = true,
head_data = {
offset = {x = 0, y = 0.14, z = 0},
pitch_correction = -25,
pivot_h = 0.4,
pivot_v = 0.4
},
-- Functions
utility_stack = {
animalia.mob_ai.basic_wander,
animalia.mob_ai.swim_seek_land,
animalia.mob_ai.cat_seek_vessel,
animalia.mob_ai.cat_stay,
animalia.mob_ai.cat_play_with_owner,
animalia.mob_ai.cat_follow_owner,
animalia.mob_ai.basic_attack,
animalia.mob_ai.basic_breed
},
activate_func = function(self)
animalia.initialize_api(self)
animalia.initialize_lasso(self)
self.interact_sound_cooldown = 0
self.trust_cooldown = self:recall("trust_cooldown") or 0
self.order = self:recall("order") or "wander"
self.owner = self:recall("owner") or nil
self.trust = self:recall("trust") or {}
if self.owner
and minetest.get_player_by_name(self.owner) then
if not animalia.pets[self.owner][self.object] then
table.insert(animalia.pets[self.owner], self.object)
end
end
end,
step_func = function(self)
animalia.step_timers(self)
animalia.head_tracking(self, 0.75, 0.75)
animalia.do_growth(self, 60)
animalia.update_lasso_effects(self)
animalia.random_sound(self)
if self:timer(1) then
if self.interact_sound_cooldown > 0 then
self.interact_sound_cooldown = self.interact_sound_cooldown - 1
end
end
end,
death_func = animalia.death_func,
deactivate_func = function(self)
if self.owner then
for i, object in ipairs(animalia.pets[self.owner] or {}) do
if object == self.object then
animalia.pets[self.owner][i] = nil
end
end
end
if self.enemies
and self.enemies[1]
and self.memorize then
self.enemies[1] = nil
self.enemies = self:memorize("enemies", self.enemies)
end
end,
on_rightclick = function(self, clicker)
local item_name = clicker:get_wielded_item():get_name()
if item_name == "animalia:net" then return end
local trust = self.trust[clicker:get_player_name()] or 0
local pos = self.object:get_pos()
if not pos then return end
if animalia.feed(self, clicker, true, true) then
animalia.add_trust(self, clicker, 1)
animalia.particle_spawner(pos, "creatura_particle_green.png", "float")
return
end
if animalia.set_nametag(self, clicker) then
return
end
-- Purr to indicate trust level (louder = more trust)
if clicker:get_player_control().sneak then
if self.interact_sound_cooldown <= 0 then
self.sounds["purr"].gain = 0.15 * trust
self.interact_sound_cooldown = 3
self:play_sound("purr")
end
end
if not self.owner
or clicker:get_player_name() ~= self.owner then
return
end
if trust <= 5 then
if self.interact_sound_cooldown <= 0 then
self.interact_sound_cooldown = 3
self:play_sound("random")
end
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
self:play_sound("purr")
end
local order = self.order
if order == "wander" then
minetest.chat_send_player(clicker:get_player_name(), "Cat is following")
self.order = "follow"
self:initiate_utility("animalia:follow_player", self, clicker, true)
self:set_utility_score(0.7)
elseif order == "follow" then
minetest.chat_send_player(clicker:get_player_name(), "Cat is sitting")
self.order = "sit"
self:initiate_utility("animalia:stay", self)
self:set_utility_score(0.5)
else
minetest.chat_send_player(clicker:get_player_name(), "Cat is wandering")
self.order = "wander"
self:set_utility_score(0)
end
self:memorize("order", self.order)
end
end,
on_punch = function(self, puncher, time_from_last_punch, tool_capabilities, direction, damage)
creatura.basic_punch_func(self, puncher, time_from_last_punch, tool_capabilities, direction, damage)
self:initiate_utility("animalia:flee_from_player", self, puncher)
self:set_utility_score(1)
animalia.add_trust(self, puncher, -1)
local pos = self.object:get_pos()
animalia.particle_spawner(pos, "creatura_particle_red.png", "float")
end
})
creatura.register_spawn_item("animalia:cat", {
col1 = "db9764",
col2 = "cf8d5a"
})

View file

@ -0,0 +1,143 @@
-------------
-- Chicken --
-------------
creatura.register_mob("animalia:chicken", {
-- Engine Props
visual_size = {x = 10, y = 10},
mesh = "animalia_chicken.b3d",
female_textures = {
"animalia_chicken_1.png",
"animalia_chicken_2.png",
"animalia_chicken_3.png"
},
male_textures = {
"animalia_rooster_1.png",
"animalia_rooster_2.png",
"animalia_rooster_3.png"
},
child_textures = {"animalia_chicken_child.png"},
makes_footstep_sound = true,
-- Creatura Props
max_health = 5,
armor_groups = {fleshy = 100},
damage = 0,
speed = 2,
tracking_range = 8,
max_boids = 3,
despawn_after = 500,
max_fall = 0,
stepheight = 1.1,
sounds = {
random = {
name = "animalia_chicken",
gain = 0.5,
distance = 8
},
hurt = {
name = "animalia_chicken_hurt",
gain = 0.5,
distance = 8
},
death = {
name = "animalia_chicken_death",
gain = 0.5,
distance = 8
}
},
hitbox = {
width = 0.25,
height = 0.5
},
animations = {
stand = {range = {x = 1, y = 39}, speed = 20, frame_blend = 0.3, loop = true},
walk = {range = {x = 41, y = 59}, speed = 30, frame_blend = 0.3, loop = true},
run = {range = {x = 41, y = 59}, speed = 45, frame_blend = 0.3, loop = true},
eat = {range = {x = 61, y = 89}, speed = 45, frame_blend = 0.3, loop = true},
fall = {range = {x = 91, y = 99}, speed = 70, frame_blend = 0.3, loop = true}
},
follow = animalia.food_seeds,
drops = {
{name = "animalia:poultry_raw", min = 1, max = 3, chance = 1},
{name = "animalia:feather", min = 1, max = 3, chance = 2}
},
-- Behavior Parameters
is_herding_mob = true,
-- Animalia Props
flee_puncher = true,
catch_with_net = true,
catch_with_lasso = true,
head_data = {
offset = {x = 0, y = 0.45, z = 0},
pitch_correction = 40,
pivot_h = 0.25,
pivot_v = 0.55
},
move_chance = 2,
idle_time = 1,
-- Functions
utility_stack = {
animalia.mob_ai.basic_wander,
animalia.mob_ai.swim_seek_land,
animalia.mob_ai.tamed_follow_owner,
animalia.mob_ai.basic_breed,
animalia.mob_ai.basic_flee
},
add_child = function(self)
local pos = self.object:get_pos()
if not pos then return end
animalia.particle_spawner(pos, "animalia_egg_fragment.png", "splash", pos, pos)
local object = minetest.add_entity(pos, self.name)
local ent = object:get_luaentity()
ent.growth_scale = 0.7
animalia.initialize_api(ent)
animalia.protect_from_despawn(ent)
end,
activate_func = function(self)
animalia.initialize_api(self)
animalia.initialize_lasso(self)
end,
step_func = function(self)
animalia.step_timers(self)
animalia.head_tracking(self, 0.75, 0.75)
animalia.do_growth(self, 60)
animalia.update_lasso_effects(self)
animalia.random_sound(self)
if self.fall_start then
self:set_gravity(-4.9)
self:animate("fall")
end
if (self.growth_scale or 1) > 0.8
and self.gender == "female"
and self:timer(60) then
animalia.random_drop_item(self, "animalia:chicken_egg", 10)
end
end,
death_func = function(self)
if self:get_utility() ~= "animalia:die" then
self:initiate_utility("animalia:die", self)
end
end,
on_rightclick = function(self, clicker)
if animalia.feed(self, clicker, false, true) then
return
end
animalia.set_nametag(self, clicker)
end,
on_punch = animalia.punch
})
creatura.register_spawn_item("animalia:chicken", {
col1 = "c6c6c6",
col2 = "d22222"
})

169
mods/animalia/mobs/cow.lua Normal file
View file

@ -0,0 +1,169 @@
---------
-- Cow --
---------
creatura.register_mob("animalia:cow", {
-- Engine Props
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",
"animalia_cow_5.png^animalia_cow_udder.png"
},
male_textures = {
"animalia_cow_1.png",
"animalia_cow_2.png",
"animalia_cow_3.png",
"animalia_cow_4.png",
"animalia_cow_5.png"
},
child_textures = {
"animalia_cow_1.png",
"animalia_cow_2.png",
"animalia_cow_3.png",
"animalia_cow_4.png",
"animalia_cow_5.png"
},
makes_footstep_sound = true,
-- Creatura Props
max_health = 20,
armor_groups = {fleshy = 100},
damage = 0,
speed = 2,
tracking_range = 10,
max_boids = 0,
despawn_after = 500,
max_fall = 3,
stepheight = 1.1,
sounds = {
random = {
name = "animalia_cow",
gain = 0.5,
distance = 8
},
hurt = {
name = "animalia_cow_hurt",
gain = 0.5,
distance = 8
},
death = {
name = "animalia_cow_death",
gain = 0.5,
distance = 8
}
},
hitbox = {
width = 0.5,
height = 1
},
animations = {
stand = {range = {x = 1, y = 59}, speed = 10, frame_blend = 0.3, loop = true},
walk = {range = {x = 71, y = 89}, speed = 15, frame_blend = 0.3, loop = true},
run = {range = {x = 71, y = 89}, speed = 30, frame_blend = 0.3, loop = true},
},
follow = animalia.food_wheat,
drops = {
{name = "animalia:beef_raw", min = 1, max = 3, chance = 1},
{name = "animalia:leather", min = 1, max = 3, chance = 2},
animalia.bones,
},
fancy_collide = false,
-- Behavior Parameters
is_grazing_mob = true,
is_herding_mob = true,
-- Animalia Props
flee_puncher = true,
catch_with_net = true,
catch_with_lasso = true,
consumable_nodes = {
["default:dirt_with_grass"] = "default:dirt",
["default:dry_dirt_with_dry_grass"] = "default:dry_dirt"
},
head_data = {
offset = {x = 0, y = 0.5, z = 0.0},
pitch_correction = -40,
pivot_h = 0.75,
pivot_v = 1
},
wander_action = animalia.action_boid_move,
-- Functions
utility_stack = {
animalia.mob_ai.basic_wander,
animalia.mob_ai.swim_seek_land,
animalia.mob_ai.tamed_follow_owner,
animalia.mob_ai.basic_breed,
animalia.mob_ai.basic_flee
},
activate_func = function(self)
animalia.initialize_api(self)
animalia.initialize_lasso(self)
self.collected = self:recall("collected") or false
end,
step_func = function(self)
animalia.step_timers(self)
animalia.head_tracking(self, 0.75, 0.75)
animalia.do_growth(self, 60)
animalia.update_lasso_effects(self)
animalia.random_sound(self)
end,
death_func = function(self)
if self:get_utility() ~= "animalia:die" then
self:initiate_utility("animalia:die", self)
end
end,
on_rightclick = function(self, clicker)
if animalia.feed(self, clicker, false, true)
or animalia.set_nametag(self, clicker) then
return
end
local tool = clicker:get_wielded_item()
local name = clicker:get_player_name()
if tool:get_name() == "bucket:bucket_empty" then
if self.growth_scale < 1 then
return
end
if self.collected then
minetest.chat_send_player(name, "This Cow has already been milked.")
return
end
local inv = clicker:get_inventory()
tool:take_item()
clicker:set_wielded_item(tool)
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 = "animalia:bucket_milk"})
end
self.collected = self:memorize("collected", true)
return
end
end,
on_punch = animalia.punch
})
creatura.register_spawn_item("animalia:cow", {
col1 = "cac3a1",
col2 = "464438"
})

106
mods/animalia/mobs/fox.lua Normal file
View file

@ -0,0 +1,106 @@
---------
-- Fox --
---------
creatura.register_mob("animalia:fox", {
-- Engine Props
visual_size = {x = 10, y = 10},
mesh = "animalia_fox.b3d",
textures = {
"animalia_fox_1.png"
},
makes_footstep_sound = false,
-- Creatura Props
max_health = 10,
armor_groups = {fleshy = 100},
damage = 2,
speed = 4,
tracking_range = 16,
max_boids = 0,
despawn_after = 500,
stepheight = 1.1,
sound = {},
hitbox = {
width = 0.35,
height = 0.5
},
animations = {
stand = {range = {x = 1, y = 39}, speed = 10, frame_blend = 0.3, loop = true},
walk = {range = {x = 41, y = 59}, speed = 30, frame_blend = 0.3, loop = true},
run = {range = {x = 41, y = 59}, speed = 45, frame_blend = 0.3, loop = true},
},
follow = {
"animalia:rat_raw",
"animalia:mutton_raw",
"animalia:beef_raw",
"animalia:porkchop_raw",
"animalia:poultry_raw"
},
drops = {
animalia.bones,
},
-- Behavior Parameters
is_skittish_mob = true,
attack_list = {
"animalia:chicken",
"animalia:rat"
},
-- Animalia Props
flee_puncher = true,
catch_with_net = true,
catch_with_lasso = true,
head_data = {
offset = {x = 0, y = 0.18, z = 0},
pitch_correction = -67,
pivot_h = 0.65,
pivot_v = 0.65
},
-- Functions
utility_stack = {
animalia.mob_ai.basic_wander,
animalia.mob_ai.swim_seek_land,
animalia.mob_ai.basic_attack,
animalia.mob_ai.fox_flee,
animalia.mob_ai.basic_seek_food,
animalia.mob_ai.tamed_follow_owner,
animalia.mob_ai.basic_breed
},
on_eat_drop = function(self)
animalia.protect_from_despawn(self)
end,
activate_func = function(self)
animalia.initialize_api(self)
animalia.initialize_lasso(self)
end,
step_func = function(self)
animalia.step_timers(self)
animalia.head_tracking(self, 0.5, 0.75)
animalia.do_growth(self, 60)
animalia.update_lasso_effects(self)
end,
death_func = animalia.death_func,
on_rightclick = function(self, clicker)
if animalia.feed(self, clicker, true, true) then
return
end
if animalia.set_nametag(self, clicker) then
return
end
end,
on_punch = animalia.punch
})
creatura.register_spawn_item("animalia:fox", {
col1 = "d0602d",
col2 = "c9c9c9"
})

257
mods/animalia/mobs/frog.lua Normal file
View file

@ -0,0 +1,257 @@
----------
-- Frog --
----------
local random = math.random
local function poison_effect(object)
object:punch(object, 1.0, {
full_punch_interval = 1.0,
damage_groups = {fleshy = 1},
})
end
local hitboxes = {
{-0.25, 0, -0.25, 0.2, 0.4, 0.25},
{-0.4, 0, -0.4, 0.4, 0.5, 0.4},
{-0.15, 0, -0.15, 0.15, 0.3, 0.15}
}
local animations = {
{
stand = {range = {x = 1, y = 40}, speed = 10, frame_blend = 0.3, loop = true},
float = {range = {x = 90, y = 90}, speed = 1, frame_blend = 0.3, loop = true},
swim = {range = {x = 90, y = 110}, speed = 50, frame_blend = 0.3, loop = true},
walk = {range = {x = 50, y = 80}, speed = 50, frame_blend = 0.3, loop = true},
run = {range = {x = 50, y = 80}, speed = 60, frame_blend = 0.3, loop = true}
},
{
stand = {range = {x = 1, y = 40}, speed = 10, frame_blend = 0.3, loop = true},
walk = {range = {x = 50, y = 79}, speed = 20, frame_blend = 0.3, loop = true},
run = {range = {x = 50, y = 79}, speed = 30, frame_blend = 0.3, loop = true},
warn = {range = {x = 90, y = 129}, speed = 30, frame_blend = 0.3, loop = true},
punch = {range = {x = 140, y = 160}, speed = 30, frame_blend = 0.1, loop = false},
float = {range = {x = 170, y = 209}, speed = 10, frame_blend = 0.3, loop = true},
swim = {range = {x = 220, y = 239}, speed = 20, frame_blend = 0.3, loop = true}
},
{
stand = {range = {x = 1, y = 40}, speed = 10, frame_blend = 0.3, loop = true},
walk = {range = {x = 50, y = 69}, speed = 30, frame_blend = 0.3, loop = true},
run = {range = {x = 50, y = 69}, speed = 40, frame_blend = 0.3, loop = true},
float = {range = {x = 80, y = 119}, speed = 10, frame_blend = 0.3, loop = true},
swim = {range = {x = 130, y = 149}, speed = 20, frame_blend = 0.3, loop = true}
}
}
local utility_stacks = {
{ -- Tree Frog
animalia.mob_ai.basic_wander,
animalia.mob_ai.swim_wander,
animalia.mob_ai.frog_seek_bug,
animalia.mob_ai.frog_breed,
animalia.mob_ai.basic_flee,
animalia.mob_ai.frog_flop,
animalia.mob_ai.frog_seek_water
},
{ -- Bull Frog
animalia.mob_ai.basic_wander,
animalia.mob_ai.swim_wander,
animalia.mob_ai.basic_seek_food,
animalia.mob_ai.basic_attack,
animalia.mob_ai.frog_breed,
animalia.mob_ai.frog_flop,
animalia.mob_ai.frog_seek_water
},
{ -- Poison Dart Frog
animalia.mob_ai.basic_wander,
animalia.mob_ai.swim_wander,
animalia.mob_ai.frog_breed,
animalia.mob_ai.basic_flee,
animalia.mob_ai.frog_flop,
animalia.mob_ai.frog_seek_water
}
}
local head_data = {
{
offset = {x = 0, y = 0.43, z = 0},
pitch_correction = -15,
pivot_h = 0.3,
pivot_v = 0.3
},
{
offset = {x = 0, y = 0.50, z = 0},
pitch_correction = -20,
pivot_h = 0.3,
pivot_v = 0.3
},
{
offset = {x = 0, y = 0.25, z = 0},
pitch_correction = -20,
pivot_h = 0.3,
pivot_v = 0.3
}
}
local follow = {
{
"butterflies:butterfly_white",
"butterflies:butterfly_violet",
"butterflies:butterfly_red"
},
{
"animalia:rat_raw"
},
{}
}
creatura.register_mob("animalia:frog", {
-- Engine Props
visual_size = {x = 10, y = 10},
meshes = {
"animalia_frog.b3d",
"animalia_bull_frog.b3d",
"animalia_dart_frog.b3d"
},
child_mesh = "animalia_tadpole.b3d",
mesh_textures = {
{
"animalia_tree_frog.png"
},
{
"animalia_bull_frog.png"
},
{
"animalia_dart_frog_1.png",
"animalia_dart_frog_2.png",
"animalia_dart_frog_3.png"
}
},
child_textures = {
"animalia_tadpole.png"
},
makes_footstep_sound = true,
-- Creatura Props
max_health = 5,
armor_groups = {fleshy = 100},
damage = 2,
max_breath = 0,
speed = 2,
tracking_range = 8,
max_boids = 0,
despawn_after = 300,
max_fall = 0,
stepheight = 1.1,
sound = {},
hitbox = {
width = 0.15,
height = 0.3
},
animations = {},
follow = {},
drops = {},
fancy_collide = false,
bouyancy_multiplier = 0,
hydrodynamics_multiplier = 0.3,
-- Animalia Props
flee_puncher = true,
catch_with_net = true,
catch_with_lasso = false,
head_data = {},
-- Functions
utility_stack = {},
on_grown = function(self)
local mesh_no = self.mesh_no
self.animations = animations[mesh_no]
self.utility_stack = utility_stacks[mesh_no]
self.head_data = head_data[mesh_no]
self.object:set_properties({
collisionbox = hitboxes[mesh_no]
})
end,
activate_func = function(self)
animalia.initialize_api(self)
self.trust = self:recall("trust") or {}
local mesh_no = self.mesh_no
-- Set Species Properties
if self.growth_scale >= 0.8 then
self.animations = animations[mesh_no]
self.utility_stack = utility_stacks[mesh_no]
self.object:set_properties({
collisionbox = hitboxes[mesh_no]
})
else
self.animations = {
swim = {range = {x = 1, y = 19}, speed = 20, frame_blend = 0.1, loop = true}
}
self.utility_stack = utility_stacks[1]
end
self.head_data = head_data[mesh_no]
if mesh_no == 1 then
for i = 1, 15 do
local frame = 120 + i
local anim = {range = {x = frame, y = frame}, speed = 1, frame_blend = 0.3, loop = false}
self.animations["tongue_" .. i] = anim
end
elseif mesh_no == 2 then
self.object:set_armor_groups({fleshy = 50})
self.warn_before_attack = true
end
end,
step_func = function(self)
animalia.step_timers(self)
animalia.head_tracking(self, 0.2, 0.2)
animalia.do_growth(self, 60)
if self:timer(random(5, 15)) then
self:play_sound("random")
end
if not self.mesh_vars_set then
self.follow = follow[self.mesh_no]
end
end,
death_func = function(self)
if self:get_utility() ~= "animalia:die" then
self:initiate_utility("animalia:die", self)
end
end,
on_rightclick = function(self, clicker)
if self.mesh_no ~= 2 then return end
if animalia.feed(self, clicker, false, true) then
animalia.add_trust(self, clicker, 1)
return
end
if animalia.set_nametag(self, clicker) then
return
end
end,
on_punch = function(self, puncher, time_from_last_punch, tool_capabilities, direction, damage)
creatura.basic_punch_func(self, puncher, time_from_last_punch, tool_capabilities, direction, damage)
local name = puncher:is_player() and puncher:get_player_name()
if name then
self.trust[name] = 0
self:memorize("trust", self.trust)
if self.mesh_no == 3 then
animalia.set_player_effect(name, poison_effect, 3)
end
end
end
})
creatura.register_spawn_item("animalia:frog", {
col1 = "67942e",
col2 = "294811"
})

View file

@ -0,0 +1,426 @@
-----------
-- Horse --
-----------
local random = math.random
-- Horse Inventory
local form_obj = {}
local function create_horse_inventory(self)
if not self.owner then return end
local inv_name = "animalia:horse_" .. self.owner
local inv = minetest.create_detached_inventory(inv_name, {
allow_move = function(_, _, _, _, _, count)
return count
end,
allow_put = function(_, _, _, stack)
return stack:get_count()
end,
allow_take = function(_, _, _, stack)
return stack:get_count()
end
})
inv:set_size("main", 12)
inv:set_width("main", 4)
return inv
end
local function serialize_horse_inventory(self)
if not self.owner then return end
local inv_name = "animalia:horse_" .. self.owner
local inv = minetest.get_inventory({type = "detached", name = inv_name})
if not inv then return end
local list = inv:get_list("main")
local stored = {}
for k, item in ipairs(list) do
local itemstr = item:to_string()
if itemstr ~= "" then
stored[k] = itemstr
end
end
self._inventory = self:memorize("_inventory", minetest.serialize(stored))
end
local function get_form(self, player_name)
local inv = create_horse_inventory(self)
if inv
and self._inventory then
inv:set_list("main", minetest.deserialize(self._inventory))
end
local frame_range = self.animations["stand"].range
local frame_loop = frame_range.x .. "," .. frame_range.y
local texture = self:get_props().textures[1]
local form = {
"formspec_version[3]",
"size[10.5,10]",
"image[0,0;10.5,5.25;animalia_form_horse_bg.png]",
"model[0,0.5;5,3.5;mob_mesh;animalia_horse.b3d;" .. texture .. ";-10,-130;false;false;" .. frame_loop .. ";15]",
"list[detached:animalia:horse_" .. player_name .. ";main;5.4,0.5;4,3;]",
"list[current_player;main;0.4,4.9;8,4;]",
"listring[current_player;main]"
}
return table.concat(form, "")
end
local function close_form(player)
local name = player:get_player_name()
if form_obj[name] then
form_obj[name] = nil
minetest.remove_detached_inventory("animalia:horse_" .. name)
end
end
minetest.register_on_player_receive_fields(function(player, formname, fields)
local name = player:get_player_name()
if not form_obj[name] or not form_obj[name]:get_yaw() then
return
end
local obj = form_obj[name]
if formname == "animalia:horse_forms" then
local ent = obj and obj:get_luaentity()
if not ent then return end
if fields.quit or fields.key_enter then
form_obj[name] = nil
serialize_horse_inventory(ent)
minetest.remove_detached_inventory("animlaia:horse_" .. name)
end
end
if formname == "animalia:horse_inv" then
local ent = obj and obj:get_luaentity()
if not ent then return end
if fields.quit or fields.key_enter then
form_obj[name] = nil
serialize_horse_inventory(ent)
minetest.remove_detached_inventory("animalia:horse_" .. name)
end
end
end)
minetest.register_on_leaveplayer(close_form)
-- Pattern
local patterns = {
"animalia_horse_pattern_1.png",
"animalia_horse_pattern_2.png",
"animalia_horse_pattern_3.png"
}
local avlbl_colors = {
[1] = {
"animalia_horse_2.png",
"animalia_horse_3.png",
"animalia_horse_5.png"
},
[2] = {
"animalia_horse_1.png",
"animalia_horse_5.png"
},
[3] = {
"animalia_horse_2.png",
"animalia_horse_1.png"
},
[4] = {
"animalia_horse_2.png",
"animalia_horse_1.png"
},
[5] = {
"animalia_horse_2.png",
"animalia_horse_1.png"
}
}
local function set_pattern(self)
local pattern_no = self:recall("pattern_no")
if pattern_no and pattern_no < 1 then return end
if not pattern_no then
if random(3) < 2 then
pattern_no = self:memorize("pattern_no", random(#patterns))
else
self:memorize("pattern_no", 0)
return
end
end
local colors = avlbl_colors[self.texture_no]
local color_no = self:recall("color_no") or self:memorize("color_no", random(#colors))
if not colors[color_no] then return end
local pattern = "(" .. patterns[pattern_no] .. "^[mask:" .. colors[color_no] .. ")"
local texture = self.textures[self.texture_no]
self.object:set_properties({
textures = {texture .. "^" .. pattern}
})
end
-- Definition
creatura.register_mob("animalia:horse", {
-- Engine Props
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"
},
makes_footstep_sound = true,
-- Creatura Props
max_health = 40,
armor_groups = {fleshy = 100},
damage = 8,
speed = 10,
tracking_range = 16,
max_boids = 7,
despawn_after = 1000,
max_fall = 4,
stepheight = 1.2,
sounds = {
alter_child_pitch = true,
random = {
name = "animalia_horse_idle",
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
}
},
hitbox = {
width = 0.65,
height = 1.95
},
animations = {
stand = {range = {x = 1, y = 59}, speed = 10, frame_blend = 0.3, loop = true},
walk = {range = {x = 70, y = 89}, speed = 20, frame_blend = 0.3, loop = true},
run = {range = {x = 101, y = 119}, speed = 40, frame_blend = 0.3, loop = true},
punch_aoe = {range = {x = 170, y = 205}, speed = 30, frame_blend = 0.2, loop = false},
rear = {range = {x = 130, y = 160}, speed = 20, frame_blend = 0.1, loop = false},
eat = {range = {x = 210, y = 240}, speed = 30, frame_blend = 0.3, loop = false}
},
follow = animalia.food_wheat,
drops = {
{name = "animalia:leather", min = 1, max = 4, chance = 2},
animalia.bones,
},
fancy_collide = false,
-- Behavior Parameters
is_grazing_mob = true,
is_herding_mob = true,
-- Animalia Props
catch_with_net = true,
catch_with_lasso = true,
consumable_nodes = {
["default:dirt_with_grass"] = "default:dirt",
["default:dry_dirt_with_dry_grass"] = "default:dry_dirt"
},
head_data = {
bone = "Neck.CTRL",
offset = {x = 0, y = 1.4, z = 0.0},
pitch_correction = 15,
pivot_h = 1,
pivot_v = 1.75
},
utility_stack = {
animalia.mob_ai.basic_wander,
animalia.mob_ai.swim_seek_land,
animalia.mob_ai.tamed_follow_owner,
animalia.mob_ai.basic_breed,
animalia.mob_ai.basic_flee,
{
utility = "animalia:horse_tame",
get_score = function(self)
local rider = not self.owner and self.rider
if rider
and rider:get_pos() then
return 0.7, {self}
end
return 0
end
},
{
utility = "animalia:horse_ride",
get_score = function(self)
if not self.owner then return 0 end
local owner = self.owner and minetest.get_player_by_name(self.owner)
local rider = owner == self.rider and self.rider
if rider
and rider:get_pos() then
return 0.8, {self, rider}
end
return 0
end
}
},
-- Functions
set_saddle = function(self, saddle)
if saddle then
self.saddled = self:memorize("saddled", true)
local texture = self.object:get_properties().textures[1]
self.object:set_properties({
textures = {texture .. "^animalia_horse_saddle.png"}
})
self.drops = {
{name = "animalia:leather", chance = 2, min = 1, max = 4},
{name = "animalia:saddle", chance = 1, min = 1, max = 1}
}
else
local pos = self.object:get_pos()
if not pos then return end
self.saddled = self:memorize("saddled", false)
set_pattern(self)
self.drops = {
{name = "animalia:leather", chance = 2, min = 1, max = 4}
}
minetest.add_item(pos, "animalia:saddle")
end
end,
add_child = function(self, mate)
local pos = self.object:get_pos()
if not pos then return end
local obj = minetest.add_entity(pos, self.name)
local ent = obj and obj:get_luaentity()
if not ent then return end
ent.growth_scale = 0.7
local tex_no = self.texture_no
local mate_ent = mate and mate:get_luaentity()
if mate_ent
or not mate_ent.speed
or not mate_ent.jump_power
or not mate_ent.max_health then
return
end
if random(2) < 2 then
tex_no = mate_ent.texture_no
end
ent:memorize("texture_no", tex_no)
ent:memorize("speed", random(mate_ent.speed, self.speed))
ent:memorize("jump_power", random(mate_ent.jump_power, self.jump_power))
ent:memorize("max_health", random(mate_ent.max_health, self.max_health))
ent.speed = ent:recall("speed")
ent.jump_power = ent:recall("jump_power")
ent.max_health = ent:recall("max_health")
animalia.initialize_api(ent)
animalia.protect_from_despawn(ent)
end,
activate_func = function(self)
animalia.initialize_api(self)
animalia.initialize_lasso(self)
set_pattern(self)
self.owner = self:recall("owner") or nil
if self.owner then
self._inventory = self:recall("_inventory")
end
self.rider = nil
self.saddled = self:recall("saddled") or false
self.max_health = self:recall("max_health") or random(30, 45)
self.speed = self:recall("speed") or random(5, 10)
self.jump_power = self:recall("jump_power") or random(2, 5)
self:memorize("max_health", self.max_health)
self:memorize("speed", self.speed)
self:memorize("jump_power", self.jump_power)
if self.saddled then
self:set_saddle(true)
end
end,
step_func = function(self)
animalia.step_timers(self)
animalia.head_tracking(self)
animalia.do_growth(self, 60)
animalia.update_lasso_effects(self)
animalia.random_sound(self)
end,
death_func = function(self)
if self.rider then
animalia.mount(self, self.rider)
end
if self:get_utility() ~= "animalia:die" then
self:initiate_utility("animalia:die", self)
end
end,
on_rightclick = function(self, clicker)
if animalia.feed(self, clicker, false, true) then
return
end
local owner = self.owner
local name = clicker and clicker:get_player_name()
if owner and name ~= owner then return end
if animalia.set_nametag(self, clicker) then
return
end
local wielded_name = clicker:get_wielded_item():get_name()
if wielded_name == "animalia:saddle" then
self:set_saddle(true)
return
end
if clicker:get_player_control().sneak
and owner then
minetest.show_formspec(name, "animalia:horse_forms", get_form(self, name))
form_obj[name] = self.object
elseif wielded_name == "" then
animalia.mount(self, clicker, {rot = {x = -65, y = 180, z = 0}, pos = {x = 0, y = 0.75, z = 0.6}})
if self.saddled then
self:initiate_utility("animalia:mount", self, clicker)
end
end
end,
on_punch = function(self, puncher, ...)
if self.rider and puncher == self.rider then return end
local name = puncher:is_player() and puncher:get_player_name()
if name
and name == self.owner
and puncher:get_player_control().sneak then
self:set_saddle(false)
return
end
animalia.punch(self, puncher, ...)
end,
on_detach_child = function(self, child)
if child
and self.rider == child then
self.rider = nil
child:set_eye_offset({x = 0, y = 0, z = 0}, {x = 0, y = 0, z = 0})
child:set_properties({visual_size = {x = 1, y = 1}})
animalia.animate_player(child, "stand", 30)
end
end
})
creatura.register_spawn_item("animalia:horse", {
col1 = "ebdfd8",
col2 = "653818"
})

View file

@ -0,0 +1,105 @@
-------------
-- Opossum --
-------------
creatura.register_mob("animalia:opossum", {
-- Engine Props
visual_size = {x = 10, y = 10},
mesh = "animalia_opossum.b3d",
textures = {
"animalia_opossum.png"
},
makes_footstep_sound = false,
-- Creatura Props
max_health = 5,
armor_groups = {fleshy = 100},
damage = 2,
speed = 4,
tracking_range = 16,
max_boids = 0,
despawn_after = 500,
stepheight = 1.1,
max_fall = 8,
sound = {},
hitbox = {
width = 0.25,
height = 0.4
},
animations = {
stand = {range = {x = 1, y = 59}, speed = 10, frame_blend = 0.3, loop = true},
walk = {range = {x = 70, y = 89}, speed = 30, frame_blend = 0.3, loop = true},
run = {range = {x = 100, y = 119}, speed = 45, frame_blend = 0.3, loop = true},
feint = {range = {x = 130, y = 130}, speed = 45, frame_blend = 0.3, loop = false},
clean_crop = {range = {x = 171, y = 200}, speed = 15, frame_blend = 0.2, loop = false}
},
follow = {
"animalia:song_bird_egg",
"animalia:rat_raw",
"animalia:mutton_raw",
"animalia:beef_raw",
"animalia:porkchop_raw",
"animalia:poultry_raw"
},
-- Behavior Parameters
is_skittish_mob = true,
attack_list = {"animalia:rat"},
-- Animalia Props
flee_puncher = true,
catch_with_net = true,
catch_with_lasso = true,
head_data = {
offset = {x = 0, y = 0.18, z = 0},
pitch_correction = -67,
pivot_h = 0.65,
pivot_v = 0.65
},
-- Functions
utility_stack = {
animalia.mob_ai.basic_wander,
animalia.mob_ai.swim_seek_land,
animalia.mob_ai.basic_attack,
animalia.mob_ai.opossum_feint,
animalia.mob_ai.opossum_seek_crop,
animalia.mob_ai.basic_seek_food,
animalia.mob_ai.tamed_follow_owner,
animalia.mob_ai.basic_breed
},
on_eat_drop = function(self)
animalia.protect_from_despawn(self)
end,
activate_func = function(self)
animalia.initialize_api(self)
animalia.initialize_lasso(self)
end,
step_func = function(self)
animalia.step_timers(self)
animalia.head_tracking(self, 0.5, 0.75)
animalia.do_growth(self, 60)
animalia.update_lasso_effects(self)
end,
death_func = animalia.death_func,
on_rightclick = function(self, clicker)
if animalia.feed(self, clicker, true, true) then
return
end
if animalia.set_nametag(self, clicker) then
return
end
end,
on_punch = animalia.punch
})
creatura.register_spawn_item("animalia:opossum", {
col1 = "75665f",
col2 = "ccbfb8"
})

169
mods/animalia/mobs/owl.lua Normal file
View file

@ -0,0 +1,169 @@
---------
-- Owl --
---------
local abs = math.abs
local vec_dist = vector.distance
local function get_home_pos(self)
local pos = self.object:get_pos()
if not pos then return end
local leaves = minetest.find_nodes_in_area_under_air(
vector.subtract(pos, 16),
vector.add(pos, 16),
"group:leaves"
)
local home_dist
local new_home
for _, leaf_pos in ipairs(leaves or {}) do
local dist = vec_dist(pos, leaf_pos)
if not home_dist
or dist < home_dist then
home_dist = dist
new_home = leaf_pos
end
end
if new_home then
new_home.y = new_home.y + 1
self.home_position = self:memorize("home_position", new_home)
end
end
creatura.register_mob("animalia:owl", {
-- Engine Props
visual_size = {x = 10, y = 10},
mesh = "animalia_owl.b3d",
textures = {
"animalia_owl.png"
},
makes_footstep_sound = false,
-- Creatura Props
max_health = 10,
damage = 2,
speed = 4,
tracking_range = 16,
max_boids = 0,
despawn_after = 500,
max_fall = 0,
sound = {}, -- TODO
hitbox = {
width = 0.15,
height = 0.3
},
animations = {
stand = {range = {x = 1, y = 60}, speed = 20, frame_blend = 0.3, loop = true},
fly = {range = {x = 71, y = 89}, speed = 30, frame_blend = 0.3, loop = true},
glide = {range = {x = 101, y = 119}, speed = 20, frame_blend = 0.2, loop = true},
fly_punch = {range = {x = 131, y = 149}, speed = 20, frame_blend = 0.1, loop = false},
eat = {range = {x = 161, y = 179}, speed = 20, frame_blend = 0.1, loop = false}
},
follow = {"animalia:rat_raw"},
drops = {
{name = "animalia:feather", min = 1, max = 2, chance = 1}
},
-- Animalia Props
flee_puncher = true, -- TODO
catch_with_net = true,
catch_with_lasso = false,
roost_action = animalia.action_roost,
-- Functions
on_eat_drop = function(self)
animalia.protect_from_despawn(self)
get_home_pos(self)
end,
is_home = function(pos, home_pos)
if abs(pos.x - home_pos.x) < 0.5
and abs(pos.z - home_pos.z) < 0.5 then
if abs(pos.y - home_pos.y) < 0.75 then
return true
else
local under = {x = home_pos.x, y = home_pos.y, z = home_pos.z}
local name = minetest.get_node(under).name
if minetest.get_node_group(name, "leaves") > 0 then
return true
end
end
end
return false
end,
wander_action = creatura.action_move,
utility_stack = {
animalia.mob_ai.fly_wander,
animalia.mob_ai.swim_seek_land,
animalia.mob_ai.bat_seek_home,
animalia.mob_ai.fly_seek_food,
animalia.mob_ai.eagle_attack
},
activate_func = function(self)
animalia.initialize_api(self)
animalia.initialize_lasso(self)
self._tp2home = self:recall("_tp2home") or nil
self.home_position = self:recall("home_position") or nil
local home_pos = self.home_position
if self._tp2home
and home_pos then
self.object:set_pos(home_pos)
end
self.is_landed = self:recall("is_landed") or false
if not home_pos
or creatura.get_node_def(home_pos).walkable then
get_home_pos(self)
end
end,
step_func = function(self)
animalia.step_timers(self)
animalia.do_growth(self, 60)
animalia.update_lasso_effects(self)
animalia.rotate_to_pitch(self)
if not self.is_landed
or not self.touching_ground then
self.speed = 5
else
self.speed = 1
end
end,
death_func = function(self)
if self:get_utility() ~= "animalia:die" then
self:initiate_utility("animalia:die", self)
end
end,
deactivate_func = function(self)
if self:get_utility()
and self:get_utility() == "animalia:fly_to_roost" then
local pos = self.home_position
local node = minetest.get_node_or_nil(pos)
if node
and not creatura.get_node_def(node.name).walkable
and minetest.get_natural_light(pos) > 0 then
self:memorize("_tp2home", true)
end
end
end,
on_rightclick = function(self, clicker)
if animalia.feed(self, clicker, false, false) then
return
end
if animalia.set_nametag(self, clicker) then
return
end
end,
on_punch = animalia.punch
})
creatura.register_spawn_item("animalia:owl", {
col1 = "412918",
col2 = "735b46"
})

120
mods/animalia/mobs/pig.lua Normal file
View file

@ -0,0 +1,120 @@
---------
-- Pig --
---------
creatura.register_mob("animalia:pig", {
-- Engine Props
visual_size = {x = 10, y = 10},
mesh = "animalia_pig.b3d",
female_textures = {
"animalia_pig_1.png",
"animalia_pig_2.png",
"animalia_pig_3.png"
},
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"
},
makes_footstep_sound = true,
-- Creatura Props
max_health = 20,
damage = 2,
speed = 3,
tracking_range = 12,
despawn_after = 500,
stepheight = 1.1,
sounds = {
random = {
name = "animalia_pig",
gain = 1.0,
distance = 8
},
hurt = {
name = "animalia_pig_hurt",
gain = 1.0,
distance = 8
},
death = {
name = "animalia_pig_death",
gain = 1.0,
distance = 8
}
},
hitbox = {
width = 0.35,
height = 0.7
},
animations = {
stand = {range = {x = 1, y = 60}, speed = 20, frame_blend = 0.3, loop = true},
walk = {range = {x = 70, y = 89}, speed = 30, frame_blend = 0.3, loop = true},
run = {range = {x = 100, y = 119}, speed = 40, frame_blend = 0.3, loop = true},
},
follow = animalia.food_crops,
drops = {
{name = "animalia:porkchop_raw", min = 1, max = 3, chance = 1},
animalia.bones,
},
-- Behavior Parameters
is_herding_mob = true,
-- Animalia Props
flee_puncher = true,
catch_with_net = true,
catch_with_lasso = true,
birth_count = 2,
head_data = {
offset = {x = 0, y = 0.7, z = 0},
pitch_correction = 0,
pivot_h = 0.5,
pivot_v = 0.3
},
-- Functions
utility_stack = {
animalia.mob_ai.basic_wander,
animalia.mob_ai.swim_seek_land,
animalia.mob_ai.basic_seek_crop,
animalia.mob_ai.tamed_follow_owner,
animalia.mob_ai.basic_breed,
animalia.mob_ai.basic_flee
},
activate_func = function(self)
animalia.initialize_api(self)
animalia.initialize_lasso(self)
end,
step_func = function(self)
animalia.step_timers(self)
animalia.do_growth(self, 60)
animalia.head_tracking(self)
animalia.update_lasso_effects(self)
animalia.random_sound(self)
end,
death_func = animalia.death_func,
on_rightclick = function(self, clicker)
if animalia.feed(self, clicker, false, true) then
return
end
if animalia.set_nametag(self, clicker) then
return
end
end,
on_punch = animalia.punch
})
creatura.register_spawn_item("animalia:pig", {
col1 = "e0b1a7",
col2 = "cc9485"
})

View file

@ -0,0 +1,82 @@
----------
-- Mice --
----------
creatura.register_mob("animalia:rat", {
-- Engine Props
visual_size = {x = 10, y = 10},
mesh = "animalia_rat.b3d",
textures = {
"animalia_rat_1.png",
"animalia_rat_2.png",
"animalia_rat_3.png"
},
-- Creatura Props
max_health = 5,
damage = 0,
speed = 1,
tracking_range = 8,
despawn_after = 200,
stepheight = 1.1,
--sound = {},
hitbox = {
width = 0.15,
height = 0.3
},
animations = {
stand = {range = {x = 1, y = 39}, speed = 20, frame_blend = 0.3, loop = true},
walk = {range = {x = 51, y = 69}, speed = 20, frame_blend = 0.3, loop = true},
run = {range = {x = 81, y = 99}, speed = 45, frame_blend = 0.3, loop = true},
eat = {range = {x = 111, y = 119}, speed = 20, frame_blend = 0.1, loop = false}
},
drops = {
{name = "animalia:rat_raw", min = 1, max = 1, chance = 1}
},
-- Behavior Parameters
is_skittish_mob = true,
-- Animalia Props
flee_puncher = true,
catch_with_net = true,
catch_with_lasso = false,
-- Functions
utility_stack = {
animalia.mob_ai.basic_wander,
animalia.mob_ai.swim_seek_land,
animalia.mob_ai.basic_seek_crop,
animalia.mob_ai.rat_seek_chest,
animalia.mob_ai.basic_flee
},
activate_func = function(self)
animalia.initialize_api(self)
animalia.initialize_lasso(self)
end,
step_func = function(self)
animalia.step_timers(self)
animalia.do_growth(self, 60)
end,
death_func = function(self)
if self:get_utility() ~= "animalia:die" then
self:initiate_utility("animalia:die", self)
end
end,
on_rightclick = function(self, clicker)
if animalia.set_nametag(self, clicker) then
return
end
end,
on_punch = animalia.punch
})
creatura.register_spawn_item("animalia:rat", {
col1 = "605a55",
col2 = "ff936f"
})

View file

@ -0,0 +1,119 @@
--------------
-- Reindeer --
--------------
creatura.register_mob("animalia:reindeer", {
-- Engine Props
visual_size = {x = 10, y = 10},
mesh = "animalia_reindeer.b3d",
textures = {"animalia_reindeer.png"},
child_textures = {"animalia_reindeer_calf.png"},
makes_footstep_sound = true,
-- Creatura Props
max_health = 15,
damage = 0,
speed = 3,
tracking_range = 12,
max_boids = 4,
despawn_after = 500,
stepheight = 1.1,
sounds = {
random = {
name = "animalia_reindeer",
gain = 0.5,
distance = 8
},
hurt = {
name = "animalia_reindeer_hurt",
gain = 0.5,
distance = 8
},
death = {
name = "animalia_reindeer_death",
gain = 0.5,
distance = 8
}
},
hitbox = {
width = 0.45,
height = 0.9
},
animations = {
stand = {range = {x = 1, y = 59}, speed = 10, frame_blend = 0.3, loop = true},
walk = {range = {x = 70, y = 89}, speed = 30, frame_blend = 0.3, loop = true},
run = {range = {x = 100, y = 119}, speed = 40, frame_blend = 0.3, loop = true},
eat = {range = {x = 130, y = 150}, speed = 20, frame_blend = 0.3, loop = false}
},
follow = animalia.food_wheat,
drops = {
{name = "animalia:venison_raw", min = 1, max = 3, chance = 1},
{name = "animalia:leather", min = 1, max = 3, chance = 2},
animalia.bones,
},
-- Behavior Parameters
is_grazing_mob = true,
is_herding_mob = true,
-- Animalia Props
flee_puncher = true,
catch_with_net = true,
catch_with_lasso = true,
consumable_nodes = {
{
name = "default:dirt_with_grass",
replacement = "default:dirt"
},
{
name = "default:dry_dirt_with_dry_grass",
replacement = "default:dry_dirt"
}
},
head_data = {
offset = {x = 0, y = 0.55, z = 0},
pitch_correction = -45,
pivot_h = 1,
pivot_v = 1
},
-- Functions
utility_stack = {
animalia.mob_ai.basic_wander,
animalia.mob_ai.swim_seek_land,
animalia.mob_ai.tamed_follow_owner,
animalia.mob_ai.basic_breed,
animalia.mob_ai.basic_flee
},
activate_func = function(self)
animalia.initialize_api(self)
animalia.initialize_lasso(self)
end,
step_func = function(self)
animalia.step_timers(self)
animalia.head_tracking(self)
animalia.do_growth(self, 60)
animalia.update_lasso_effects(self)
animalia.random_sound(self)
end,
death_func = animalia.death_func,
on_rightclick = function(self, clicker)
if animalia.feed(self, clicker, false, true) then
return
end
if animalia.set_nametag(self, clicker) then
return
end
end,
on_punch = animalia.punch
})
creatura.register_spawn_item("animalia:reindeer", {
col1 = "413022",
col2 = "d5c0a3"
})

View file

@ -0,0 +1,199 @@
-----------
-- Sheep --
-----------
local random = math.random
local palette = {
black = {"Black", "#000000b0"},
blue = {"Blue", "#015dbb70"},
brown = {"Brown", "#663300a0"},
cyan = {"Cyan", "#01ffd870"},
dark_green = {"Dark Green", "#005b0770"},
dark_grey = {"Dark Grey", "#303030b0"},
green = {"Green", "#61ff0170"},
grey = {"Grey", "#5b5b5bb0"},
magenta = {"Magenta", "#ff05bb70"},
orange = {"Orange", "#ff840170"},
pink = {"Pink", "#ff65b570"},
red = {"Red", "#ff0000a0"},
violet = {"Violet", "#2000c970"},
white = {"White", "#ababab00"},
yellow = {"Yellow", "#e3ff0070"},
}
creatura.register_mob("animalia:sheep", {
-- Engine Props
visual_size = {x = 10, y = 10},
mesh = "animalia_sheep.b3d",
textures = {
"animalia_sheep.png^animalia_sheep_wool.png"
},
child_textures = {
"animalia_sheep.png"
},
makes_footstep_sound = true,
-- Creatura Props
max_health = 15,
armor_groups = {fleshy = 100},
damage = 0,
speed = 3,
tracking_range = 12,
max_boids = 4,
despawn_after = 500,
stepheight = 1.1,
sounds = {
random = {
name = "animalia_sheep",
gain = 1.0,
distance = 8
},
hurt = {
name = "animalia_sheep_hurt",
gain = 1.0,
distance = 8
},
death = {
name = "animalia_sheep_death",
gain = 1.0,
distance = 8
}
},
hitbox = {
width = 0.4,
height = 0.8
},
animations = {
stand = {range = {x = 1, y = 59}, speed = 10, frame_blend = 0.3, loop = true},
walk = {range = {x = 70, y = 89}, speed = 20, frame_blend = 0.3, loop = true},
run = {range = {x = 100, y = 119}, speed = 30, frame_blend = 0.3, loop = true},
eat = {range = {x = 130, y = 150}, speed = 20, frame_blend = 0.3, loop = false}
},
follow = animalia.food_wheat,
drops = {
{name = "animalia:mutton_raw", min = 1, max = 3, chance = 1},
minetest.get_modpath("wool") and {name = "wool:white", min = 1, max = 3, chance = 2} or nil,
animalia.bones,
},
-- Behavior Parameters
is_grazing_mob = true,
is_herding_mob = true,
-- Animalia Props
flee_puncher = true,
catch_with_net = true,
catch_with_lasso = true,
consumable_nodes = {
["default:dirt_with_grass"] = "default:dirt",
["default:dry_dirt_with_dry_grass"] = "default:dry_dirt"
},
head_data = {
offset = {x = 0, y = 0.41, z = 0},
pitch_correction = -45,
pivot_h = 0.75,
pivot_v = 0.85
},
-- Functions
utility_stack = {
animalia.mob_ai.basic_wander,
animalia.mob_ai.swim_seek_land,
animalia.mob_ai.tamed_follow_owner,
animalia.mob_ai.basic_breed,
animalia.mob_ai.basic_flee
},
activate_func = function(self)
animalia.initialize_api(self)
animalia.initialize_lasso(self)
self.collected = self:recall("collected") or false
self.dye_color = self:recall("dye_color") or "white"
if self.collected then
self.object:set_properties({
textures = {"animalia_sheep.png"},
})
elseif self.dye_color ~= "white" then
self.object:set_properties({
textures = {"animalia_sheep.png^(animalia_sheep_wool.png^[multiply:" .. palette[self.dye_color][2] .. ")"},
})
end
end,
step_func = function(self)
animalia.step_timers(self)
animalia.head_tracking(self)
animalia.do_growth(self, 60)
animalia.update_lasso_effects(self)
animalia.random_sound(self)
end,
death_func = animalia.death_func,
on_rightclick = function(self, clicker)
if animalia.feed(self, clicker, false, true) then
return
end
if animalia.set_nametag(self, clicker) then
return
end
if self.collected
or self.growth_scale < 1 then
return
end
local tool = clicker:get_wielded_item()
local tool_name = tool:get_name()
local creative = minetest.is_creative_enabled(clicker:get_player_name())
if tool_name == "animalia:shears" then
if not minetest.get_modpath("wool") then
return
end
minetest.add_item(
self.object:get_pos(),
ItemStack("wool:" .. self.dye_color .. " " .. random(1, 3))
)
self.collected = self:memorize("collected", true)
self.dye_color = self:memorize("dye_color", "white")
self.object:set_properties({
textures = {"animalia_sheep.png"},
})
if not creative then
tool:add_wear(650)
clicker:set_wielded_item(tool)
end
end
if tool_name:match("^dye:") then
local dye_color = tool_name:split(":")[2]
if palette[dye_color] then
self.dye_color = self:memorize("dye_color", dye_color)
self.drops = {
{name = "animalia:mutton_raw", chance = 1, min = 1, max = 4},
{name = "wool:" .. dye_color, chance = 2, min = 1, max = 2},
}
self.object:set_properties({
textures = {"animalia_sheep.png^(animalia_sheep_wool.png^[multiply:" .. palette[dye_color][2] .. ")"},
})
if not creative then
tool:take_item()
clicker:set_wielded_item(tool)
end
end
end
end,
on_punch = animalia.punch
})
creatura.register_spawn_item("animalia:sheep", {
col1 = "f4e6cf",
col2 = "e1ca9b"
})

View file

@ -0,0 +1,138 @@
---------------
-- Song Bird --
---------------
local random = math.random
creatura.register_mob("animalia:song_bird", {
-- Engine Props
visual_size = {x = 10, y = 10},
mesh = "animalia_bird.b3d",
textures = {
"animalia_cardinal.png",
"animalia_bluebird.png",
"animalia_goldfinch.png"
},
-- Creatura Props
max_health = 2,
speed = 4,
tracking_range = 8,
max_boids = 6,
boid_seperation = 0.3,
despawn_after = 200,
max_fall = 0,
stepheight = 1.1,
sounds = {
cardinal = {
name = "animalia_cardinal",
gain = 0.5,
distance = 63
},
eastern_blue = {
name = "animalia_bluebird",
gain = 0.5,
distance = 63
},
goldfinch = {
name = "animalia_goldfinch",
gain = 0.5,
distance = 63
},
},
hitbox = {
width = 0.2,
height = 0.4
},
animations = {
stand = {range = {x = 1, y = 100}, speed = 30, frame_blend = 0.3, loop = true},
walk = {range = {x = 110, y = 130}, speed = 40, frame_blend = 0.3, loop = true},
fly = {range = {x = 140, y = 160}, speed = 40, frame_blend = 0.3, loop = true}
},
--follow = {},
drops = {
{name = "animalia:feather", min = 1, max = 1, chance = 2}
},
-- Behavior Parameters
uses_boids = true,
-- Animalia Props
flee_puncher = true,
catch_with_net = true,
catch_with_lasso = false,
wander_action = animalia.action_boid_move,
--roost_action = animalia.action_roost,
-- Functions
utility_stack = {
animalia.mob_ai.basic_wander,
animalia.mob_ai.fly_landing_wander,
animalia.mob_ai.fly_seek_land
},
activate_func = function(self)
if animalia.despawn_inactive_mob(self) then return end
animalia.initialize_api(self)
animalia.initialize_lasso(self)
self.is_landed = (random(2) < 2 and true) or false
end,
step_func = function(self)
animalia.step_timers(self)
animalia.do_growth(self, 60)
--animalia.update_lasso_effects(self)
animalia.rotate_to_pitch(self)
if self:timer(random(6, 12)) then
if animalia.is_day then
if self.texture_no == 1 then
self:play_sound("cardinal")
elseif self.texture_no == 2 then
self:play_sound("eastern_blue")
else
self:play_sound("goldfinch")
end
end
end
if not self.is_landed
or not self.touching_ground then
self.speed = 4
else
self.speed = 3
end
end,
death_func = animalia.death_func,
on_rightclick = function(self, clicker)
--[[if animalia.feed(self, clicker, false, false) then
return
end]]
if animalia.set_nametag(self, clicker) then
return
end
end,
on_punch = animalia.punch
})
creatura.register_spawn_item("animalia:song_bird", {
col1 = "ae2f2f",
col2 = "f3ac1c"
})
minetest.register_entity("animalia:bird", {
static_save = false,
on_activate = function(self)
self.object:remove()
end
})
minetest.register_abm({
label = "animalia:nest_cleanup",
nodenames = "animalia:nest_song_bird",
interval = 900,
action = function(pos)
minetest.remove_node(pos)
end
})

View file

@ -0,0 +1,91 @@
----------
-- Fish --
----------
creatura.register_mob("animalia:tropical_fish", {
-- Engine Props
visual_size = {x = 10, y = 10},
meshes = {
"animalia_clownfish.b3d",
"animalia_angelfish.b3d"
},
mesh_textures = {
{
"animalia_clownfish.png",
"animalia_blue_tang.png"
},
{
"animalia_angelfish.png"
}
},
-- Creatura Props
max_health = 5,
armor_groups = {fleshy = 150},
damage = 0,
max_breath = 0,
speed = 2,
tracking_range = 6,
max_boids = 6,
boid_seperation = 0.3,
despawn_after = 200,
max_fall = 0,
stepheight = 1.1,
hitbox = {
width = 0.15,
height = 0.3
},
animations = {
swim = {range = {x = 1, y = 20}, speed = 20, frame_blend = 0.3, loop = true},
flop = {range = {x = 30, y = 40}, speed = 20, frame_blend = 0.3, loop = true},
},
liquid_submergence = 1,
liquid_drag = 0,
-- Animalia Behaviors
is_aquatic_mob = true,
-- Animalia Props
flee_puncher = false,
catch_with_net = true,
catch_with_lasso = false,
-- Functions
utility_stack = {
animalia.mob_ai.swim_wander
},
activate_func = function(self)
animalia.initialize_api(self)
animalia.initialize_lasso(self)
end,
step_func = function(self)
animalia.step_timers(self)
animalia.do_growth(self, 60)
animalia.update_lasso_effects(self)
end,
death_func = function(self)
if self:get_utility() ~= "animalia:die" then
self:initiate_utility("animalia:die", self)
end
end,
on_rightclick = function(self, clicker)
if animalia.set_nametag(self, clicker) then
return
end
end,
on_punch = animalia.punch
})
creatura.register_spawn_item("animalia:tropical_fish", {
col1 = "e28821",
col2 = "f6e5d2"
})
animalia.alias_mob("animalia:clownfish", "animalia:tropical_fish")
animalia.alias_mob("animalia:blue_tang", "animalia:tropical_fish")
animalia.alias_mob("animalia:angelfish", "animalia:tropical_fish")

View file

@ -0,0 +1,133 @@
------------
-- Turkey --
------------
creatura.register_mob("animalia:turkey", {
-- Engine Props
visual_size = {x = 10, y = 10},
mesh = "animalia_turkey.b3d",
female_textures = {"animalia_turkey_hen.png"},
male_textures = {"animalia_turkey_tom.png"},
child_textures = {"animalia_turkey_chick.png"},
makes_footstep_sound = true,
-- Creatura Props
max_health = 8,
armor_groups = {fleshy = 100},
damage = 0,
speed = 2,
tracking_range = 8,
max_boids = 3,
despawn_after = 500,
max_fall = 0,
stepheight = 1.1,
sounds = {
random = {
name = "animalia_turkey",
gain = 0.5,
distance = 8
},
hurt = {
name = "animalia_turkey_hurt",
gain = 0.5,
distance = 8
},
death = {
name = "animalia_turkey_death",
gain = 0.5,
distance = 8
}
},
hitbox = {
width = 0.3,
height = 0.6
},
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},
},
follow = animalia.food_seeds,
drops = {
{name = "animalia:poultry_raw", min = 1, max = 4, chance = 1},
{name = "animalia:feather", min = 1, max = 3, chance = 2},
animalia.bones,
},
-- Animalia Props
group_wander = true,
flee_puncher = true,
catch_with_net = true,
catch_with_lasso = true,
head_data = {
offset = {x = 0, y = 0.15, z = 0},
pitch_correction = 45,
pivot_h = 0.45,
pivot_v = 0.65
},
move_chance = 2,
idle_time = 1,
-- Functions
utility_stack = {
animalia.mob_ai.basic_wander,
animalia.mob_ai.swim_seek_land,
animalia.mob_ai.tamed_follow_owner,
animalia.mob_ai.basic_breed,
animalia.mob_ai.basic_flee
},
add_child = function(self)
local pos = self.object:get_pos()
if not pos then return end
animalia.particle_spawner(pos, "animalia_egg_fragment.png", "splash", pos, pos)
local object = minetest.add_entity(pos, self.name)
local ent = object:get_luaentity()
ent.growth_scale = 0.7
animalia.initialize_api(ent)
animalia.protect_from_despawn(ent)
end,
activate_func = function(self)
animalia.initialize_api(self)
animalia.initialize_lasso(self)
end,
step_func = function(self)
animalia.step_timers(self)
animalia.head_tracking(self, 0.75, 0.75)
animalia.do_growth(self, 60)
animalia.update_lasso_effects(self)
animalia.random_sound(self)
if self.fall_start then
self:set_gravity(-4.9)
self:animate("fall")
end
if (self.growth_scale or 1) > 0.8
and self.gender == "female"
and self:timer(60) then
animalia.random_drop_item(self, "animalia:turkey_egg", 10)
end
end,
death_func = function(self)
if self:get_utility() ~= "animalia:die" then
self:initiate_utility("animalia:die", self)
end
end,
on_rightclick = function(self, clicker)
if animalia.feed(self, clicker, false, true) then
return
end
animalia.set_nametag(self, clicker)
end,
on_punch = animalia.punch
})
creatura.register_spawn_item("animalia:turkey", {
col1 = "352b22",
col2 = "2f2721"
})

198
mods/animalia/mobs/wolf.lua Normal file
View file

@ -0,0 +1,198 @@
----------
-- Wolf --
----------
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
local function is_value_in_table(tbl, val)
for _, v in pairs(tbl) do
if v == val then
return true
end
end
return false
end
creatura.register_mob("animalia:wolf", {
-- Engine Props
visual_size = {x = 10, y = 10},
mesh = "animalia_wolf.b3d",
textures = {
"animalia_wolf_1.png",
"animalia_wolf_2.png",
"animalia_wolf_3.png",
"animalia_wolf_4.png"
},
makes_footstep_sound = true,
-- Creatura Props
max_health = 20,
damage = 4,
speed = 4,
tracking_range = 24,
despawn_after = 500,
stepheight = 1.1,
sound = {},
hitbox = {
width = 0.35,
height = 0.7
},
animations = {
stand = {range = {x = 1, y = 60}, speed = 20, frame_blend = 0.3, loop = true},
walk = {range = {x = 70, y = 89}, speed = 30, frame_blend = 0.3, loop = true},
run = {range = {x = 100, y = 119}, speed = 40, frame_blend = 0.3, loop = true},
sit = {range = {x = 130, y = 139}, speed = 10, frame_blend = 0.3, loop = true},
},
follow = follow,
drops = {
animalia.bones,
},
-- Behavior Parameters
is_skittish_mob = true,
is_herding_mob = true,
-- Animalia Props
assist_owner = true,
flee_puncher = false,
catch_with_net = true,
catch_with_lasso = true,
consumable_nodes = {},
head_data = {
offset = {x = 0, y = 0.22, z = 0},
pitch_correction = -35,
pivot_h = 0.45,
pivot_v = 0.45
},
-- Functions
utility_stack = {
animalia.mob_ai.basic_wander,
animalia.mob_ai.swim_seek_land,
animalia.mob_ai.tamed_stay,
animalia.mob_ai.tamed_follow_owner,
animalia.mob_ai.basic_attack,
animalia.mob_ai.basic_breed
},
activate_func = function(self)
animalia.initialize_api(self)
animalia.initialize_lasso(self)
self.order = self:recall("order") or "wander"
self.owner = self:recall("owner") or nil
self.enemies = self:recall("enemies") or {}
if self.owner
and minetest.get_player_by_name(self.owner) then
if not is_value_in_table(animalia.pets[self.owner], self.object) then
table.insert(animalia.pets[self.owner], self.object)
end
end
end,
step_func = function(self)
animalia.step_timers(self)
animalia.head_tracking(self)
animalia.do_growth(self, 60)
animalia.update_lasso_effects(self)
end,
death_func = function(self)
if self:get_utility() ~= "animalia:die" then
self:initiate_utility("animalia:die", self)
end
end,
deactivate_func = function(self)
if self.owner then
for i, object in ipairs(animalia.pets[self.owner] or {}) do
if object == self.object then
animalia.pets[self.owner][i] = nil
end
end
end
if self.enemies
and self.enemies[1]
and self.memorize then
self.enemies[1] = nil
self.enemies = self:memorize("enemies", self.enemies)
end
end,
on_rightclick = function(self, clicker)
if not clicker:is_player() then return end
local name = clicker:get_player_name()
local passive = true
if is_value_in_table(self.enemies, name) then passive = false end
if animalia.feed(self, clicker, passive, passive) then
return
end
if animalia.set_nametag(self, clicker) then
return
end
if self.owner
and name == self.owner
and clicker:get_player_control().sneak then
local order = self.order
if order == "wander" then
minetest.chat_send_player(name, "Wolf is following")
self.order = "follow"
self:initiate_utility("animalia:follow_player", self, clicker, true)
self:set_utility_score(0.7)
elseif order == "follow" then
minetest.chat_send_player(name, "Wolf is sitting")
self.order = "sit"
self:initiate_utility("animalia:stay", self)
self:set_utility_score(0.5)
else
minetest.chat_send_player(name, "Wolf is wandering")
self.order = "wander"
self:set_utility_score(0)
end
self:memorize("order", self.order)
end
end,
on_punch = function(self, puncher, time_from_last_punch, tool_capabilities, direction, damage)
creatura.basic_punch_func(self, puncher, time_from_last_punch, tool_capabilities, direction, damage)
local name = puncher:is_player() and puncher:get_player_name()
if name then
if self.owner
and name == self.owner then
return
elseif not is_value_in_table(self.enemies, name) then
table.insert(self.enemies, name)
if #self.enemies > 15 then
table.remove(self.enemies, 1)
end
self.enemies = self:memorize("enemies", self.enemies)
else
table.remove(self.enemies, 1)
table.insert(self.enemies, name)
self.enemies = self:memorize("enemies", self.enemies)
end
end
self._target = puncher
end,
})
creatura.register_spawn_item("animalia:wolf", {
col1 = "a19678",
col2 = "231b13"
})