forked from MineClone5/MineClone5
Stop creeper explosion sequence if target leaves line of sight
This commit is contained in:
parent
7be9a8a574
commit
6002057839
|
@ -26,6 +26,8 @@ local math_random = math.random
|
||||||
|_|
|
|_|
|
||||||
]]--
|
]]--
|
||||||
|
|
||||||
|
local minetest_line_of_sight = minetest.line_of_sight
|
||||||
|
|
||||||
mobs.explode_attack_walk = function(self,dtime)
|
mobs.explode_attack_walk = function(self,dtime)
|
||||||
|
|
||||||
--this needs an exception
|
--this needs an exception
|
||||||
|
@ -36,17 +38,27 @@ mobs.explode_attack_walk = function(self,dtime)
|
||||||
|
|
||||||
mobs.set_yaw_while_attacking(self)
|
mobs.set_yaw_while_attacking(self)
|
||||||
|
|
||||||
local distance_from_attacking = vector_distance(self.object:get_pos(), self.attacking:get_pos())
|
local pos = self.object:get_pos()
|
||||||
|
local attack_pos = self.attacking:get_pos()
|
||||||
|
local distance_from_attacking = vector_distance(pos, attack_pos)
|
||||||
|
|
||||||
--make mob walk up to player within 2 nodes distance then start exploding
|
--make mob walk up to player within 2 nodes distance then start exploding
|
||||||
if distance_from_attacking >= self.reach and
|
if (
|
||||||
--don't allow explosion to cancel unless out of the reach boundary
|
distance_from_attacking >= self.reach and
|
||||||
not (self.explosion_animation and self.explosion_animation > 0 and distance_from_attacking <= self.defuse_reach) then
|
|
||||||
|
|
||||||
|
--don't allow explosion to cancel unless out of the reach boundary
|
||||||
|
not (self.explosion_animation and self.explosion_animation > 0 and distance_from_attacking <= self.defuse_reach) or
|
||||||
|
--don't allow creeper to finish exploding animation if can't see target
|
||||||
|
not minetest_line_of_sight(
|
||||||
|
{x = pos.x, y = pos.y + self.eye_height, z = pos.z},
|
||||||
|
{x = attack_pos.x, y = attack_pos.y + (self.attacking.eye_height or 0), z = attack_pos.z}
|
||||||
|
)
|
||||||
|
) then
|
||||||
mobs.set_velocity(self, self.run_velocity)
|
mobs.set_velocity(self, self.run_velocity)
|
||||||
mobs.set_mob_animation(self,"run")
|
mobs.set_mob_animation(self,"run")
|
||||||
|
|
||||||
mobs.reverse_explosion_animation(self,dtime)
|
mobs.reverse_explosion_animation(self,dtime)
|
||||||
|
|
||||||
else
|
else
|
||||||
mobs.set_velocity(self,0)
|
mobs.set_velocity(self,0)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue