forked from VoxeLibre/VoxeLibre
Remove wandering from ai
This commit is contained in:
parent
491ef6c8f8
commit
008d670ed9
|
@ -311,7 +311,6 @@ function mobs:register_mob(name, def)
|
||||||
backface_culling = true,
|
backface_culling = true,
|
||||||
walk_timer = 0,
|
walk_timer = 0,
|
||||||
stand_timer = 0,
|
stand_timer = 0,
|
||||||
wandering = true,
|
|
||||||
current_animation = "",
|
current_animation = "",
|
||||||
gravity = GRAVITY,
|
gravity = GRAVITY,
|
||||||
swim = def.swim,
|
swim = def.swim,
|
||||||
|
|
|
@ -92,8 +92,17 @@ end
|
||||||
local land_state_list_wandering = {"stand", "walk"}
|
local land_state_list_wandering = {"stand", "walk"}
|
||||||
|
|
||||||
local land_state_switch = function(self, dtime)
|
local land_state_switch = function(self, dtime)
|
||||||
|
|
||||||
|
|
||||||
|
if self.hostile and attack then
|
||||||
|
self.state =
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
--do math after sure not attacking
|
||||||
self.state_timer = self.state_timer - dtime
|
self.state_timer = self.state_timer - dtime
|
||||||
if self.wandering and self.state_timer <= 0 then
|
|
||||||
|
if self.state_timer <= 0 then
|
||||||
self.state_timer = math.random(4,10) + math.random()
|
self.state_timer = math.random(4,10) + math.random()
|
||||||
self.state = land_state_list_wandering[math.random(1,#land_state_list_wandering)]
|
self.state = land_state_list_wandering[math.random(1,#land_state_list_wandering)]
|
||||||
end
|
end
|
||||||
|
@ -203,7 +212,7 @@ local swim_state_list_wandering = {"stand", "swim"}
|
||||||
|
|
||||||
local swim_state_switch = function(self, dtime)
|
local swim_state_switch = function(self, dtime)
|
||||||
self.state_timer = self.state_timer - dtime
|
self.state_timer = self.state_timer - dtime
|
||||||
if self.wandering and self.state_timer <= 0 then
|
if self.state_timer <= 0 then
|
||||||
self.state_timer = math.random(4,10) + math.random()
|
self.state_timer = math.random(4,10) + math.random()
|
||||||
self.state = swim_state_list_wandering[math.random(1,#swim_state_list_wandering)]
|
self.state = swim_state_list_wandering[math.random(1,#swim_state_list_wandering)]
|
||||||
end
|
end
|
||||||
|
@ -335,7 +344,7 @@ local fly_state_list_wandering = {"stand", "fly"}
|
||||||
|
|
||||||
local fly_state_switch = function(self, dtime)
|
local fly_state_switch = function(self, dtime)
|
||||||
self.state_timer = self.state_timer - dtime
|
self.state_timer = self.state_timer - dtime
|
||||||
if self.wandering and self.state_timer <= 0 then
|
if self.state_timer <= 0 then
|
||||||
self.state_timer = math.random(4,10) + math.random()
|
self.state_timer = math.random(4,10) + math.random()
|
||||||
self.state = fly_state_list_wandering[math.random(1,#fly_state_list_wandering)]
|
self.state = fly_state_list_wandering[math.random(1,#fly_state_list_wandering)]
|
||||||
end
|
end
|
||||||
|
@ -482,7 +491,7 @@ local jump_state_list_wandering = {"stand", "jump"}
|
||||||
|
|
||||||
local jump_state_switch = function(self, dtime)
|
local jump_state_switch = function(self, dtime)
|
||||||
self.state_timer = self.state_timer - dtime
|
self.state_timer = self.state_timer - dtime
|
||||||
if self.wandering and self.state_timer <= 0 then
|
if self.state_timer <= 0 then
|
||||||
self.state_timer = math.random(4,10) + math.random()
|
self.state_timer = math.random(4,10) + math.random()
|
||||||
self.state = jump_state_list_wandering[math.random(1,#jump_state_list_wandering)]
|
self.state = jump_state_list_wandering[math.random(1,#jump_state_list_wandering)]
|
||||||
end
|
end
|
||||||
|
@ -603,8 +612,13 @@ mobs.mob_step = function(self, dtime)
|
||||||
--1 for eye height adjust is debug
|
--1 for eye height adjust is debug
|
||||||
local attacking = mobs.detect_closest_player_within_radius(self,true,10,1)
|
local attacking = mobs.detect_closest_player_within_radius(self,true,10,1)
|
||||||
|
|
||||||
|
--go get the closest player ROAR >:O
|
||||||
if attacking then
|
if attacking then
|
||||||
print(attacking:get_player_name())
|
self.attack = attacking
|
||||||
|
|
||||||
|
--no player in area
|
||||||
|
else
|
||||||
|
self.attack = nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue