mods - mobs - fix nil when stop mob attacking if player isnt seen when explote
* the positionits not set cos the mobs is not attacking in such time seems there is a small amount of time that the actionis not true * the stop is only after double check , but must be after first also
This commit is contained in:
parent
e80a4596d8
commit
e82e0fa9cc
31
api.lua
31
api.lua
@ -2560,39 +2560,44 @@ function mob_class:do_states(dtime)
|
|||||||
if not self.attack:get_pos() or self.attack:get_hp() <= 0 and is_invisible(self, self.attack:get_player_name()) then
|
if not self.attack:get_pos() or self.attack:get_hp() <= 0 and is_invisible(self, self.attack:get_player_name()) then
|
||||||
--print(" ** stop attacking **", self.name, self.health, dist, self.view_range)
|
--print(" ** stop attacking **", self.name, self.health, dist, self.view_range)
|
||||||
self:stop_attack()
|
self:stop_attack()
|
||||||
|
return
|
||||||
end
|
end
|
||||||
if not p then
|
if not p then
|
||||||
self:stop_attack()
|
self:stop_attack()
|
||||||
return
|
return
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- check enemy is in sight
|
-- check enemy is in sight
|
||||||
local in_sight = self:line_of_sight(
|
local in_sight
|
||||||
{x = s.x, y = s.y + 0.5, z = s.z},
|
if p then
|
||||||
{x = p.x, y = p.y + 0.5, z = p.z})
|
in_sight = self:line_of_sight(
|
||||||
|
{x = s.x, y = s.y + 0.5, z = s.z},
|
||||||
|
{x = p.x, y = p.y + 0.5, z = p.z})
|
||||||
|
|
||||||
-- stop attacking when enemy not seen for 11 seconds
|
-- stop attacking when enemy not seen for 11 seconds
|
||||||
if not in_sight then
|
if not in_sight then
|
||||||
|
|
||||||
self.target_time_lost = (self.target_time_lost or 0) + dtime
|
self.target_time_lost = (self.target_time_lost or 0) + dtime
|
||||||
|
|
||||||
if self.target_time_lost > self.attack_patience then
|
if self.target_time_lost > self.attack_patience then
|
||||||
self:stop_attack()
|
self:stop_attack()
|
||||||
|
end
|
||||||
|
else
|
||||||
|
self.target_time_lost = 0
|
||||||
end
|
end
|
||||||
else
|
|
||||||
self.target_time_lost = 0
|
|
||||||
end
|
end
|
||||||
|
|
||||||
if self.attack_type == "explode" then
|
if self.attack_type == "explode" then
|
||||||
|
|
||||||
self:yaw_to_pos(p)
|
if p then self:yaw_to_pos(p) end
|
||||||
|
|
||||||
local node_break_radius = self.explosion_radius or 1
|
local node_break_radius = self.explosion_radius or 1
|
||||||
local entity_damage_radius = self.explosion_damage_radius
|
local entity_damage_radius = self.explosion_damage_radius
|
||||||
or (node_break_radius * 2)
|
or (node_break_radius * 2)
|
||||||
|
|
||||||
-- look a little higher to fix raycast
|
-- look a little higher to fix raycast
|
||||||
s.y = s.y + 0.5 ; p.y = p.y + 0.5
|
if p then s.y = s.y + 0.5 ; p.y = p.y + 0.5 end
|
||||||
|
|
||||||
-- start timer when in reach and line of sight
|
-- start timer when in reach and line of sight
|
||||||
if not self.v_start
|
if not self.v_start
|
||||||
|
Loading…
x
Reference in New Issue
Block a user