forked from VoxeLibre/VoxeLibre
Fix mobs getting stuck in water, fix mobs falling off cliffs, and lower spider speed so cliff_danger check is properly applied.
This commit is contained in:
parent
bf38131520
commit
56958ab0c9
|
@ -298,11 +298,6 @@ end
|
|||
-- Returns true is node can deal damage to self
|
||||
local is_node_dangerous = function(self, nodename)
|
||||
local nn = nodename
|
||||
if self.water_damage > 0 then
|
||||
if minetest.get_item_group(nn, "water") ~= 0 then
|
||||
return true
|
||||
end
|
||||
end
|
||||
if self.lava_damage > 0 then
|
||||
if minetest.get_item_group(nn, "lava") ~= 0 then
|
||||
return true
|
||||
|
@ -313,6 +308,21 @@ local is_node_dangerous = function(self, nodename)
|
|||
return true
|
||||
end
|
||||
end
|
||||
if minetest.registered_nodes[nn].damage_per_second > 0 then
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
|
||||
-- Returns true if node is a water hazard
|
||||
local is_node_waterhazard = function(self, nodename)
|
||||
local nn = nodename
|
||||
if self.water_damage > 0 then
|
||||
if minetest.get_item_group(nn, "water") ~= 0 then
|
||||
return true
|
||||
end
|
||||
end
|
||||
if minetest.registered_nodes[nn].drowning > 0 then
|
||||
if self.breath_max ~= -1 then
|
||||
-- check if the mob is water-breathing _and_ the block is water; only return true if neither is the case
|
||||
|
@ -322,9 +332,6 @@ local is_node_dangerous = function(self, nodename)
|
|||
end
|
||||
end
|
||||
end
|
||||
if minetest.registered_nodes[nn].damage_per_second > 0 then
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
|
@ -2049,7 +2056,7 @@ local do_states = function(self, dtime)
|
|||
if flight_check(self) then
|
||||
is_in_danger = is_node_dangerous(self, self.standing_in)
|
||||
elseif (is_node_dangerous(self, self.standing_in) or
|
||||
is_node_dangerous(self, self.standing_on)) then
|
||||
is_node_dangerous(self, self.standing_on)) or (is_node_waterhazard(self, self.standing_in) or is_node_waterhazard(self, self.standing_on)) then
|
||||
is_in_danger = true
|
||||
end
|
||||
|
||||
|
@ -3221,6 +3228,12 @@ local mob_step = function(self, dtime)
|
|||
|
||||
runaway_from(self)
|
||||
|
||||
if is_at_cliff_or_danger(self) then
|
||||
set_velocity(self, 0)
|
||||
self.state = "stand"
|
||||
set_animation(self, "stand")
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
|
|
@ -37,7 +37,8 @@ local spider = {
|
|||
-- TODO: sounds: walk, death
|
||||
distance = 16,
|
||||
},
|
||||
walk_velocity = 3.9,
|
||||
walk_velocity = 1.3,
|
||||
run_velocity = 2.8,
|
||||
jump = true,
|
||||
jump_height = 4,
|
||||
view_range = 16,
|
||||
|
@ -72,7 +73,8 @@ cave_spider.hp_min = 1
|
|||
cave_spider.hp_max = 12
|
||||
cave_spider.collisionbox = {-0.35, -0.01, -0.35, 0.35, 0.49, 0.35}
|
||||
cave_spider.visual_size = {x=1.66666, y=1.5}
|
||||
cave_spider.walk_velocity = 4.1
|
||||
cave_spider.walk_velocity = 1.3
|
||||
cave_spider.run_velocity = 3.2
|
||||
mobs:register_mob("mobs_mc:cave_spider", cave_spider)
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue