mirror of
https://git.minetest.land/MineClone2/MineClone2.git
synced 2024-11-28 05:43:43 +01:00
Creeper should not walk to player if it does not have line of sight. Mob shouldn't look at player it does not have line of sight to.
This commit is contained in:
parent
23711950c1
commit
658f244ae4
@ -873,10 +873,13 @@ function mob_class:do_states_attack (dtime)
|
|||||||
local dist = vector.distance(p, s)
|
local dist = vector.distance(p, s)
|
||||||
|
|
||||||
if self.attack_type == "explode" then
|
if self.attack_type == "explode" then
|
||||||
local vec = { x = p.x - s.x, z = p.z - s.z }
|
|
||||||
yaw = (atan(vec.z / vec.x) +math.pi/ 2) - self.rotate
|
if target_line_of_sight then
|
||||||
if p.x > s.x then yaw = yaw +math.pi end
|
local vec = { x = p.x - s.x, z = p.z - s.z }
|
||||||
yaw = self:set_yaw( yaw, 0, dtime)
|
yaw = (atan(vec.z / vec.x) +math.pi/ 2) - self.rotate
|
||||||
|
if p.x > s.x then yaw = yaw +math.pi end
|
||||||
|
yaw = self:set_yaw( yaw, 0, dtime)
|
||||||
|
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
|
||||||
@ -900,10 +903,10 @@ function mob_class:do_states_attack (dtime)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- walk right up to player unless the timer is active
|
-- walk right up to player unless the timer is active
|
||||||
if self.v_start and (self.stop_to_explode or dist < self.reach) then
|
if self.v_start and (self.stop_to_explode or dist < self.reach) or not target_line_of_sight then
|
||||||
self:set_velocity( 0)
|
self:set_velocity(0)
|
||||||
else
|
else
|
||||||
self:set_velocity( self.run_velocity)
|
self:set_velocity(self.run_velocity)
|
||||||
end
|
end
|
||||||
|
|
||||||
if self.animation and self.animation.run_start then
|
if self.animation and self.animation.run_start then
|
||||||
|
@ -316,8 +316,14 @@ local function who_are_you_looking_at (self, dtime)
|
|||||||
|
|
||||||
local stop_look_at_player = stop_look_at_player_chance == 1
|
local stop_look_at_player = stop_look_at_player_chance == 1
|
||||||
|
|
||||||
if self.attack or self.following then
|
if self.attack then
|
||||||
self._locked_object = self.attack or self.following
|
if not self.target_time_lost then
|
||||||
|
self._locked_object = self.attack
|
||||||
|
else
|
||||||
|
self._locked_object = nil
|
||||||
|
end
|
||||||
|
elseif self.following then
|
||||||
|
self._locked_object = self.following
|
||||||
elseif self._locked_object then
|
elseif self._locked_object then
|
||||||
if stop_look_at_player then
|
if stop_look_at_player then
|
||||||
--minetest.log("Stop look: ".. self.name)
|
--minetest.log("Stop look: ".. self.name)
|
||||||
|
Loading…
Reference in New Issue
Block a user