forked from MineClone5/MineClone5
Make pitch movement for fly/swim mobs more dynamic and make ghasts randomly fly around when attacking
This commit is contained in:
parent
b401b50c04
commit
a73e5b57c0
|
@ -329,6 +329,7 @@ function mobs:register_mob(name, def)
|
|||
minimum_follow_distance = def.minimum_follow_distance or 0.5, --make mobs not freak out when underneath
|
||||
|
||||
memory = 0, -- memory timer if chasing/following
|
||||
fly_random_while_attack = def.fly_random_while_attack,
|
||||
|
||||
--for spiders
|
||||
always_climb = def.always_climb,
|
||||
|
|
|
@ -481,7 +481,7 @@ local swim_state_execution = function(self,dtime)
|
|||
self.yaw = (math_random() * (math.pi * 2))
|
||||
|
||||
--create a truly random pitch, since there is no easy access to pitch math that I can find
|
||||
self.pitch = math_random() * random_pitch_multiplier[math_random(1,2)]
|
||||
self.pitch = math_random() * math.random(1,3) * random_pitch_multiplier[math_random(1,2)]
|
||||
end
|
||||
|
||||
--do animation
|
||||
|
@ -626,7 +626,7 @@ local fly_state_execution = function(self,dtime)
|
|||
self.yaw = (math_random() * (math.pi * 2))
|
||||
|
||||
--create a truly random pitch, since there is no easy access to pitch math that I can find
|
||||
self.pitch = math_random() * random_pitch_multiplier[math_random(1,2)]
|
||||
self.pitch = math_random() * math.random(1,3) * random_pitch_multiplier[math_random(1,2)]
|
||||
end
|
||||
|
||||
--do animation
|
||||
|
|
|
@ -279,6 +279,8 @@ ______ _ _ _ _
|
|||
|__/
|
||||
]]--
|
||||
|
||||
local random_pitch_multiplier = {-1,1}
|
||||
|
||||
mobs.projectile_attack_fly = function(self, dtime)
|
||||
|
||||
--this needs an exception
|
||||
|
@ -287,18 +289,41 @@ mobs.projectile_attack_fly = function(self, dtime)
|
|||
return
|
||||
end
|
||||
|
||||
local distance_from_attacking = vector_distance(self.object:get_pos(), self.attacking:get_pos())
|
||||
--this is specifically for random ghast movement
|
||||
if self.fly_random_while_attack then
|
||||
|
||||
--enable rotation locking
|
||||
mobs.movement_rotation_lock(self)
|
||||
|
||||
self.walk_timer = self.walk_timer - dtime
|
||||
|
||||
--reset the walk timer
|
||||
if self.walk_timer <= 0 then
|
||||
--re-randomize the walk timer
|
||||
self.walk_timer = math.random(1,6) + math.random()
|
||||
--set the mob into a random direction
|
||||
self.yaw = (math_random() * (math.pi * 2))
|
||||
--create a truly random pitch, since there is no easy access to pitch math that I can find
|
||||
self.pitch = math_random() * math.random(1,3) * random_pitch_multiplier[math_random(1,2)]
|
||||
end
|
||||
|
||||
if distance_from_attacking >= self.reach then
|
||||
mobs.set_yaw_while_attacking(self)
|
||||
mobs.set_pitch_while_attacking(self)
|
||||
mobs.set_fly_velocity(self, self.run_velocity)
|
||||
mobs.set_mob_animation(self,"run")
|
||||
|
||||
else
|
||||
|
||||
mobs.set_yaw_while_attacking(self)
|
||||
mobs.set_pitch_while_attacking(self)
|
||||
mobs.set_fly_velocity(self, 0)
|
||||
mobs.set_mob_animation(self,"stand")
|
||||
|
||||
local distance_from_attacking = vector_distance(self.object:get_pos(), self.attacking:get_pos())
|
||||
|
||||
if distance_from_attacking >= self.reach then
|
||||
mobs.set_pitch_while_attacking(self)
|
||||
mobs.set_fly_velocity(self, self.run_velocity)
|
||||
mobs.set_mob_animation(self,"run")
|
||||
else
|
||||
mobs.set_pitch_while_attacking(self)
|
||||
mobs.set_fly_velocity(self, 0)
|
||||
mobs.set_mob_animation(self,"stand")
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
@ -313,6 +338,11 @@ mobs.projectile_attack_fly = function(self, dtime)
|
|||
|
||||
--shoot
|
||||
if self.projectile_timer <= 0 then
|
||||
|
||||
if self.fly_random_while_attack then
|
||||
mobs.set_yaw_while_attacking(self)
|
||||
self.walk_timer = 0
|
||||
end
|
||||
--reset timer
|
||||
self.projectile_timer = math_random(self.projectile_cooldown_min, self.projectile_cooldown_max)
|
||||
mobs.shoot_projectile(self)
|
||||
|
|
|
@ -15,6 +15,7 @@ mobs:register_mob("mobs_mc:ghast", {
|
|||
spawn_class = "hostile",
|
||||
group_attack = true,
|
||||
hostile = true,
|
||||
fly_random_while_attack = true,
|
||||
hp_min = 10,
|
||||
hp_max = 10,
|
||||
rotate = 270,
|
||||
|
|
Loading…
Reference in New Issue