1
0
mirror of https://codeberg.org/tenplus1/mobs_redo.git synced 2025-07-20 01:00:22 +02:00

Compare commits

...

2 Commits

Author SHA1 Message Date
34b06df758 add ability to follow group: items 2021-03-23 17:09:26 +00:00
0f1f3b4fb3 simplify mobs floating in water 2021-03-18 20:23:55 +00:00
2 changed files with 17 additions and 26 deletions

41
api.lua
View File

@ -8,7 +8,7 @@ local use_cmi = minetest.global_exists("cmi")
mobs = {
mod = "redo",
version = "20210310",
version = "20210323",
intllib = S,
invis = minetest.global_exists("invisibility") and invisibility or {}
}
@ -251,9 +251,17 @@ local check_for = function(look_for, look_inside)
for _, str in pairs(look_inside) do
if str == look_for then
return true
end
if str:find("group:") then
local group = str:split(":")[2]
if minetest.get_item_group(look_for, group) ~= 0 then
return true
end
end
end
end
@ -2697,34 +2705,17 @@ function mob_class:falling(pos)
-- sanity check
if not v then return end
local fall_speed = -10 -- gravity
-- don't exceed mob fall speed
if v.y < self.fall_speed then
fall_speed = self.fall_speed
end
local fall_speed = self.fall_speed
-- in water then use liquid viscosity for float/sink speed
if (self.standing_in
and minetest.registered_nodes[self.standing_in].groups.liquid)
or (self.standing_on
and minetest.registered_nodes[self.standing_in].groups.liquid) then
if self.floats == 1 and self.standing_in
and minetest.registered_nodes[self.standing_in].groups.liquid then
local visc = min(
minetest.registered_nodes[self.standing_in].liquid_viscosity, 7)
minetest.registered_nodes[self.standing_in].liquid_viscosity, 7) + 1
if self.floats == 1 then
-- floating up
if visc > 0 then
fall_speed = max(1, v.y) / (visc + 1)
end
else
-- sinking down
if visc > 0 then
fall_speed = -(max(1, v.y) / (visc + 1))
end
end
self.object:set_velocity({x = v.x, y = 0.6, z = v.z})
fall_speed = -1.2 / visc
else
-- fall damage onto solid ground

View File

@ -76,7 +76,7 @@ functions needed for the mob to work properly which contains the following:
'floats' when set to 1 mob will float in water, 0 has them sink.
'follow' mobs follow player when holding any of the items which appear
on this table, the same items can be fed to a mob to tame or
breed e.g. {"farming:wheat", "default:apple"}
breed e.g. {"farming:wheat", "default:apple", "group:fish"}
'reach' is how far the mob can attack player when standing
nearby, default is 3 nodes.