mirror of
https://codeberg.org/tenplus1/mobs_redo.git
synced 2025-01-11 10:20:21 +01:00
tweaked jumping and turning when blocked in front
This commit is contained in:
parent
8b25ab4988
commit
f11b774c95
46
api.lua
46
api.lua
@ -6,7 +6,7 @@ local use_cmi = minetest.global_exists("cmi")
|
|||||||
|
|
||||||
mobs = {
|
mobs = {
|
||||||
mod = "redo",
|
mod = "redo",
|
||||||
version = "20200429",
|
version = "20200430",
|
||||||
intllib = S,
|
intllib = S,
|
||||||
invis = minetest.global_exists("invisibility") and invisibility or {}
|
invis = minetest.global_exists("invisibility") and invisibility or {}
|
||||||
}
|
}
|
||||||
@ -1086,20 +1086,14 @@ function mob_class:do_jump()
|
|||||||
z = pos.z + dir_z
|
z = pos.z + dir_z
|
||||||
})
|
})
|
||||||
|
|
||||||
-- is there space to jump up?
|
|
||||||
if minetest.registered_nodes[nodt.name].walkable == true then
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
|
|
||||||
-- thin blocks that do not need to be jumped
|
|
||||||
if nod.name == node_snow then
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
|
|
||||||
--print ("in front:", nod.name, pos.y + 0.5)
|
--print ("in front:", nod.name, pos.y + 0.5)
|
||||||
|
--print ("in front above:", nodt.name, pos.y + 1.5)
|
||||||
|
|
||||||
if self.walk_chance == 0
|
-- jump if standing on solid node (not snow) and not blocked above
|
||||||
or minetest.registered_items[nod.name].walkable then
|
if (self.walk_chance == 0
|
||||||
|
or minetest.registered_items[nod.name].walkable)
|
||||||
|
and minetest.registered_nodes[nodt.name].walkable ~= true
|
||||||
|
and nod.name ~= node_snow then
|
||||||
|
|
||||||
if not nod.name:find("fence")
|
if not nod.name:find("fence")
|
||||||
and not nod.name:find("gate")
|
and not nod.name:find("gate")
|
||||||
@ -1129,27 +1123,29 @@ function mob_class:do_jump()
|
|||||||
if self:get_velocity() > 0 then
|
if self:get_velocity() > 0 then
|
||||||
self:mob_sound(self.sounds.jump)
|
self:mob_sound(self.sounds.jump)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
return true
|
||||||
else
|
else
|
||||||
self.facing_fence = true
|
self.facing_fence = true
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
-- if we jumped against a block/wall 4 times then turn
|
-- if blocked against a block/wall for 5 counts then turn
|
||||||
if self.object:get_velocity().x ~= 0
|
if not self.following
|
||||||
or self.object:get_velocity().z ~= 0 then
|
and (self.object:get_velocity().x == 0
|
||||||
|
or self.object:get_velocity().z == 0) then
|
||||||
|
|
||||||
self.jump_count = (self.jump_count or 0) + 1
|
self.jump_count = (self.jump_count or 0) + 1
|
||||||
--print ("----", self.jump_count)
|
--print ("----", self.jump_count)
|
||||||
if self.jump_count == 4 then
|
if self.jump_count > 4 then
|
||||||
|
|
||||||
local yaw = self.object:get_yaw() or 0
|
local yaw = self.object:get_yaw() or 0
|
||||||
|
local turn = random(0, 2) + 1.35
|
||||||
|
|
||||||
yaw = self:set_yaw(yaw + 1.35, 8)
|
yaw = self:set_yaw(yaw + turn, 12)
|
||||||
--print ("---- turn")
|
--print ("---- turn", turn)
|
||||||
self.jump_count = 0
|
self.jump_count = 0
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
return true
|
|
||||||
end
|
end
|
||||||
|
|
||||||
return false
|
return false
|
||||||
|
@ -23,7 +23,7 @@ Lucky Blocks: 9
|
|||||||
|
|
||||||
|
|
||||||
Changelog:
|
Changelog:
|
||||||
- 1.51 - Added some node checks for dangerous nodes, jumping and falling (thx for idea wuzzy)
|
- 1.51 - Added some node checks for dangerous nodes, jumping and falling tweaks (thx for idea wuzzy)
|
||||||
- 1.50 - Added new line_of_sight function that uses raycasting if mt5.0 is found, (thanks Astrobe), dont spawn mobs if world anchor nearby (technic or simple_anchor mods), chinese local added
|
- 1.50 - Added new line_of_sight function that uses raycasting if mt5.0 is found, (thanks Astrobe), dont spawn mobs if world anchor nearby (technic or simple_anchor mods), chinese local added
|
||||||
- 1.49- Added mobs:force_capture(self, player) function, api functions now use metatables thanks to bell07
|
- 1.49- Added mobs:force_capture(self, player) function, api functions now use metatables thanks to bell07
|
||||||
- 1.48- Add mobs:set_velocity(self, velocity) global function
|
- 1.48- Add mobs:set_velocity(self, velocity) global function
|
||||||
|
Loading…
Reference in New Issue
Block a user