Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions api/behaviors.lua
Original file line number Diff line number Diff line change
Expand Up @@ -704,22 +704,34 @@ creatura.register_utility("animalia:boid_wander", function(self, group)
self:set_utility(func)
end)

creatura.register_utility("animalia:wander_water_surface", function(self)
creatura.register_utility("animalia:wander_water_surface", function(self, float_speed, float_end)
local idle_time = 3
local move_probability = 3
local floating_up = false
local function func(self)
if not self.in_liquid then return true end
local pos = self.object:get_pos()
local random_goal = get_wander_pos_3d(self, 2)
if floating_up then
local float_check_pos = vector.round(vector.offset(pos, 0, -float_end, 0))
if minetest.get_item_group(minetest.get_node(float_check_pos).name, "liquid") > 0 then
self:set_vertical_velocity(float_speed)
else
self:set_vertical_velocity(0)
floating_up = false
end
end
if not self:get_action() then
local random_goal = get_wander_pos_3d(self, 2)
if self.lasso_pos
and vec_dist(pos, self.lasso_pos) > 10 then
random_goal = self.lasso_pos
end
if random(move_probability) < 2
and random_goal then
floating_up = false
animalia.action_swim(self, random_goal)
else
floating_up = float_speed ~= nil and float_end ~= nil
creatura.action_idle(self, idle_time, "float")
end
end
Expand Down
2 changes: 1 addition & 1 deletion mobs/frog.lua
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ creatura.register_mob("animalia:frog", {
utility = "animalia:wander_water_surface",
get_score = function(self)
if self.in_liquid then
return 0.11, {self}
return 0.11, {self, 0.1, -0.22}
end
return 0
end
Expand Down