2021-08-20 13:08:17 -07:00
|
|
|
----------
|
|
|
|
-- Wolf --
|
|
|
|
----------
|
|
|
|
|
2024-01-04 11:15:02 -08:00
|
|
|
|
2021-08-20 13:08:17 -07:00
|
|
|
|
|
|
|
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
|
|
|
|
|
2022-02-10 18:00:06 -08:00
|
|
|
local function is_value_in_table(tbl, val)
|
2022-08-27 20:15:57 -07:00
|
|
|
for _, v in pairs(tbl) do
|
|
|
|
if v == val then
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
end
|
|
|
|
return false
|
2021-08-20 13:08:17 -07:00
|
|
|
end
|
|
|
|
|
2022-02-10 18:00:06 -08:00
|
|
|
creatura.register_mob("animalia:wolf", {
|
2023-03-15 14:27:40 -07:00
|
|
|
-- Engine Props
|
2022-10-17 17:23:26 -07:00
|
|
|
visual_size = {x = 10, y = 10},
|
2023-03-15 14:27:40 -07:00
|
|
|
mesh = "animalia_wolf.b3d",
|
2022-08-12 22:17:42 -07:00
|
|
|
textures = {
|
|
|
|
"animalia_wolf_1.png",
|
|
|
|
"animalia_wolf_2.png",
|
|
|
|
"animalia_wolf_3.png",
|
|
|
|
"animalia_wolf_4.png"
|
|
|
|
},
|
2023-03-15 14:27:40 -07:00
|
|
|
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
|
|
|
|
},
|
2021-08-20 13:08:17 -07:00
|
|
|
animations = {
|
2023-03-15 14:27:40 -07:00
|
|
|
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},
|
2021-08-20 13:08:17 -07:00
|
|
|
},
|
2023-03-15 14:27:40 -07:00
|
|
|
follow = follow,
|
|
|
|
|
2023-12-28 21:28:05 -08:00
|
|
|
-- Behavior Parameters
|
|
|
|
is_skittish_mob = true,
|
|
|
|
is_herding_mob = true,
|
|
|
|
|
2023-03-15 14:27:40 -07:00
|
|
|
-- Animalia Props
|
|
|
|
assist_owner = true,
|
|
|
|
flee_puncher = false,
|
2022-02-10 18:00:06 -08:00
|
|
|
catch_with_net = true,
|
2022-02-20 11:45:25 -08:00
|
|
|
catch_with_lasso = true,
|
2023-03-15 14:27:40 -07:00
|
|
|
consumable_nodes = {},
|
2021-08-20 13:08:17 -07:00
|
|
|
head_data = {
|
2023-03-15 14:27:40 -07:00
|
|
|
offset = {x = 0, y = 0.22, z = 0},
|
|
|
|
pitch_correction = -35,
|
|
|
|
pivot_h = 0.45,
|
|
|
|
pivot_v = 0.45
|
2021-08-20 13:08:17 -07:00
|
|
|
},
|
2023-03-15 14:27:40 -07:00
|
|
|
|
|
|
|
-- Functions
|
2022-02-10 18:00:06 -08:00
|
|
|
utility_stack = {
|
2024-01-04 11:15:02 -08:00
|
|
|
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
|
2022-02-10 18:00:06 -08:00
|
|
|
},
|
2023-03-15 14:27:40 -07:00
|
|
|
|
2022-08-27 20:15:57 -07:00
|
|
|
activate_func = function(self)
|
2022-02-10 18:00:06 -08:00
|
|
|
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
|
2022-08-27 20:15:57 -07:00
|
|
|
end,
|
2023-03-15 14:27:40 -07:00
|
|
|
|
2022-08-27 20:15:57 -07:00
|
|
|
step_func = function(self)
|
2022-02-10 18:00:06 -08:00
|
|
|
animalia.step_timers(self)
|
2023-03-15 14:27:40 -07:00
|
|
|
animalia.head_tracking(self)
|
2022-02-10 18:00:06 -08:00
|
|
|
animalia.do_growth(self, 60)
|
|
|
|
animalia.update_lasso_effects(self)
|
2022-08-27 20:15:57 -07:00
|
|
|
end,
|
2023-03-15 14:27:40 -07:00
|
|
|
|
2022-08-27 20:15:57 -07:00
|
|
|
death_func = function(self)
|
2022-02-10 18:00:06 -08:00
|
|
|
if self:get_utility() ~= "animalia:die" then
|
|
|
|
self:initiate_utility("animalia:die", self)
|
|
|
|
end
|
2022-08-27 20:15:57 -07:00
|
|
|
end,
|
2023-03-15 14:27:40 -07:00
|
|
|
|
|
|
|
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,
|
|
|
|
|
2021-08-20 13:08:17 -07:00
|
|
|
on_rightclick = function(self, clicker)
|
2022-02-10 18:00:06 -08:00
|
|
|
if not clicker:is_player() then return end
|
2022-08-12 22:17:42 -07:00
|
|
|
local name = clicker:get_player_name()
|
2022-02-10 18:00:06 -08:00
|
|
|
local passive = true
|
2022-08-12 22:17:42 -07:00
|
|
|
if is_value_in_table(self.enemies, name) then passive = false end
|
2022-02-10 18:00:06 -08:00
|
|
|
if animalia.feed(self, clicker, passive, passive) then
|
|
|
|
return
|
2021-08-20 13:08:17 -07:00
|
|
|
end
|
2022-03-31 19:18:56 -07:00
|
|
|
if animalia.set_nametag(self, clicker) then
|
|
|
|
return
|
|
|
|
end
|
2022-02-10 18:00:06 -08:00
|
|
|
if self.owner
|
2022-08-12 22:17:42 -07:00
|
|
|
and name == self.owner
|
2022-02-10 18:00:06 -08:00
|
|
|
and clicker:get_player_control().sneak then
|
|
|
|
local order = self.order
|
|
|
|
if order == "wander" then
|
2022-08-12 22:17:42 -07:00
|
|
|
minetest.chat_send_player(name, "Wolf is following")
|
2022-02-10 18:00:06 -08:00
|
|
|
self.order = "follow"
|
|
|
|
self:initiate_utility("animalia:follow_player", self, clicker, true)
|
2022-08-12 22:17:42 -07:00
|
|
|
self:set_utility_score(0.7)
|
2022-02-10 18:00:06 -08:00
|
|
|
elseif order == "follow" then
|
2022-08-12 22:17:42 -07:00
|
|
|
minetest.chat_send_player(name, "Wolf is sitting")
|
2022-02-10 18:00:06 -08:00
|
|
|
self.order = "sit"
|
2022-08-12 22:17:42 -07:00
|
|
|
self:initiate_utility("animalia:stay", self)
|
|
|
|
self:set_utility_score(0.5)
|
2022-02-10 18:00:06 -08:00
|
|
|
else
|
2022-08-12 22:17:42 -07:00
|
|
|
minetest.chat_send_player(name, "Wolf is wandering")
|
2022-02-10 18:00:06 -08:00
|
|
|
self.order = "wander"
|
|
|
|
self:set_utility_score(0)
|
|
|
|
end
|
|
|
|
self:memorize("order", self.order)
|
|
|
|
end
|
|
|
|
end,
|
2023-03-15 14:27:40 -07:00
|
|
|
|
2022-02-10 18:00:06 -08:00
|
|
|
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)
|
2022-08-12 22:17:42 -07:00
|
|
|
local name = puncher:is_player() and puncher:get_player_name()
|
|
|
|
if name then
|
2022-02-10 18:00:06 -08:00
|
|
|
if self.owner
|
2022-08-12 22:17:42 -07:00
|
|
|
and name == self.owner then
|
2022-02-10 18:00:06 -08:00
|
|
|
return
|
2022-08-12 22:17:42 -07:00
|
|
|
elseif not is_value_in_table(self.enemies, name) then
|
|
|
|
table.insert(self.enemies, name)
|
2022-02-10 18:00:06 -08:00
|
|
|
if #self.enemies > 15 then
|
|
|
|
table.remove(self.enemies, 1)
|
|
|
|
end
|
|
|
|
self.enemies = self:memorize("enemies", self.enemies)
|
|
|
|
else
|
|
|
|
table.remove(self.enemies, 1)
|
2022-08-12 22:17:42 -07:00
|
|
|
table.insert(self.enemies, name)
|
2022-02-10 18:00:06 -08:00
|
|
|
self.enemies = self:memorize("enemies", self.enemies)
|
|
|
|
end
|
|
|
|
end
|
2022-08-12 22:17:42 -07:00
|
|
|
self._target = puncher
|
2021-08-20 13:08:17 -07:00
|
|
|
end,
|
|
|
|
})
|
|
|
|
|
2023-03-15 14:27:40 -07:00
|
|
|
creatura.register_spawn_item("animalia:wolf", {
|
|
|
|
col1 = "a19678",
|
|
|
|
col2 = "231b13"
|
|
|
|
})
|