ai changes

This commit is contained in:
GameHerobrine 2022-12-26 08:15:13 +03:00
parent 11b1a09599
commit 0f72601891
9 changed files with 52 additions and 29 deletions

View file

@ -6,7 +6,7 @@ class TaskLookAtPlayer extends TaskBase{
public $target = false;
private $state, $yaw, $pitch;
public function canBeExecuted(EntityAI $ai){
return Utils::randomFloat() < 0.02 && !$ai->entity->isMoving() && !$ai->isStarted("TaskLookAround") && !$ai->isStarted("TaskTempt");
return Utils::randomFloat() < 0.02 && !$ai->entity->isMoving() && !$ai->isStarted("TaskLookAround") && !$ai->isStarted("TaskTempt") && !$ai->entity->hasPath();
}
protected function findTarget($e, $r){
@ -42,7 +42,7 @@ class TaskLookAtPlayer extends TaskBase{
}
public function onUpdate(EntityAI $ai){
if(!($this->target instanceof Entity) || Utils::distance($ai->entity, $this->target) > 6){ //TODO max distance for different mobs
if(!($this->target instanceof Entity) || Utils::distance($ai->entity, $this->target) > 6 || $this->target->level->getName() != $ai->entity->level->getName()){ //TODO max distance for different mobs
$this->reset();
return;
}