mirror of
https://codeberg.org/tenplus1/mobs_redo.git
synced 2024-12-26 10:40:22 +01:00
add 'can_leap' setting to mob def, update api.txt
This commit is contained in:
parent
8e6fa64f2d
commit
25ab9591e4
23
api.lua
23
api.lua
@ -28,7 +28,7 @@ local use_cmi = minetest.global_exists("cmi")
|
|||||||
|
|
||||||
mobs = {
|
mobs = {
|
||||||
mod = "redo",
|
mod = "redo",
|
||||||
version = "20220707",
|
version = "20220712",
|
||||||
intllib = S,
|
intllib = S,
|
||||||
invis = minetest.global_exists("invisibility") and invisibility or {}
|
invis = minetest.global_exists("invisibility") and invisibility or {}
|
||||||
}
|
}
|
||||||
@ -1256,15 +1256,9 @@ function mob_class:do_jump()
|
|||||||
-- set y_pos to base of mob
|
-- set y_pos to base of mob
|
||||||
pos.y = pos.y + self.collisionbox[2]
|
pos.y = pos.y + self.collisionbox[2]
|
||||||
|
|
||||||
-- what is in front of mob?
|
-- what is in front of mob and above?
|
||||||
local nod = node_ok({
|
local nod = node_ok({x = pos.x + dir_x, y = pos.y + 0.5, z = pos.z + dir_z})
|
||||||
x = pos.x + dir_x, y = pos.y + 0.5, z = pos.z + dir_z
|
local nodt = node_ok({x = pos.x + dir_x, y = pos.y + 1.5, z = pos.z + dir_z})
|
||||||
})
|
|
||||||
|
|
||||||
-- what is above and in front?
|
|
||||||
local nodt = node_ok({
|
|
||||||
x = pos.x + dir_x, y = pos.y + 1.5, z = pos.z + dir_z
|
|
||||||
})
|
|
||||||
|
|
||||||
local blocked = minetest.registered_nodes[nodt.name].walkable
|
local blocked = minetest.registered_nodes[nodt.name].walkable
|
||||||
|
|
||||||
@ -1272,6 +1266,7 @@ function mob_class:do_jump()
|
|||||||
if nod.name:find("fence") or nod.name:find("gate") or nod.name:find("wall") then
|
if nod.name:find("fence") or nod.name:find("gate") or nod.name:find("wall") then
|
||||||
self.facing_fence = true
|
self.facing_fence = true
|
||||||
end
|
end
|
||||||
|
|
||||||
--[[
|
--[[
|
||||||
print("on: " .. self.standing_on
|
print("on: " .. self.standing_on
|
||||||
.. ", front: " .. nod.name
|
.. ", front: " .. nod.name
|
||||||
@ -1280,6 +1275,13 @@ print("on: " .. self.standing_on
|
|||||||
.. ", fence: " .. (self.facing_fence and "yes" or "no")
|
.. ", fence: " .. (self.facing_fence and "yes" or "no")
|
||||||
)
|
)
|
||||||
]]
|
]]
|
||||||
|
|
||||||
|
-- if mob can leap then remove blockages and let them try
|
||||||
|
if self.can_leap == true then
|
||||||
|
blocked = false
|
||||||
|
self.facing_fence = false
|
||||||
|
end
|
||||||
|
|
||||||
-- jump if standing on solid node (not snow) and not blocked
|
-- jump if standing on solid node (not snow) and not blocked
|
||||||
if (self.walk_chance == 0 or minetest.registered_items[nod.name].walkable)
|
if (self.walk_chance == 0 or minetest.registered_items[nod.name].walkable)
|
||||||
and not blocked and not self.facing_fence and nod.name ~= node_snow then
|
and not blocked and not self.facing_fence and nod.name ~= node_snow then
|
||||||
@ -3587,6 +3589,7 @@ minetest.register_entity(name, setmetatable({
|
|||||||
on_flop = def.on_flop,
|
on_flop = def.on_flop,
|
||||||
do_custom = def.do_custom,
|
do_custom = def.do_custom,
|
||||||
jump_height = def.jump_height,
|
jump_height = def.jump_height,
|
||||||
|
can_leap = def.can_leap,
|
||||||
drawtype = def.drawtype, -- DEPRECATED, use rotate instead
|
drawtype = def.drawtype, -- DEPRECATED, use rotate instead
|
||||||
rotate = rad(def.rotate or 0), -- 0=front 90=side 180=back 270=side2
|
rotate = rad(def.rotate or 0), -- 0=front 90=side 180=back 270=side2
|
||||||
glow = def.glow,
|
glow = def.glow,
|
||||||
|
5
api.txt
5
api.txt
@ -42,6 +42,8 @@ functions needed for the mob to work properly which contains the following:
|
|||||||
randomly turn while walking or standing.
|
randomly turn while walking or standing.
|
||||||
'jump' when true allows your mob to jump updwards.
|
'jump' when true allows your mob to jump updwards.
|
||||||
'jump_height' holds the height your mob can jump, 0 to disable jumping.
|
'jump_height' holds the height your mob can jump, 0 to disable jumping.
|
||||||
|
'can_leap' when true obstacles like fences or pits wont stop a mob
|
||||||
|
from trying to jump out.
|
||||||
'stepheight' height of a block that your mob can easily walk up onto,
|
'stepheight' height of a block that your mob can easily walk up onto,
|
||||||
defaults to 1.1.
|
defaults to 1.1.
|
||||||
'fly' when true allows your mob to fly around instead of walking.
|
'fly' when true allows your mob to fly around instead of walking.
|
||||||
@ -223,6 +225,9 @@ functions needed for the mob to work properly which contains the following:
|
|||||||
'fly_start' when a mob is flying.
|
'fly_start' when a mob is flying.
|
||||||
'fly_end'
|
'fly_end'
|
||||||
'fly_speed'
|
'fly_speed'
|
||||||
|
'jump_start' when a mob is jumping
|
||||||
|
'jump_end'
|
||||||
|
'jump_speed'
|
||||||
'punch_start' when a mob melee attacks.
|
'punch_start' when a mob melee attacks.
|
||||||
'punch_end'
|
'punch_end'
|
||||||
'punch_speed'
|
'punch_speed'
|
||||||
|
Loading…
Reference in New Issue
Block a user