fixed more tasks

This commit is contained in:
GameHerobrine 2024-01-09 10:18:22 +03:00
parent bcf7ef7c79
commit 2636aa985d
15 changed files with 64 additions and 20 deletions

View file

@ -2,7 +2,11 @@
class TaskLookAtPlayer extends TaskBase{
public $target = false;
private $state, $yaw, $pitch;
public $distance;
public function __construct($distance){
$this->distance = $distance;
}
public function canBeExecuted(EntityAI $ai){
return !$ai->entity->inPanic && lcg_value() < 0.02 && !$ai->entity->isMovingHorizontally() && !$ai->isStarted("TaskMate") && !$ai->isStarted("TaskLookAround") && !$ai->isStarted("TaskTempt") && !$ai->isStarted("TaskPanic") && !$ai->entity->hasPath();
}
@ -37,14 +41,13 @@ class TaskLookAtPlayer extends TaskBase{
}
public function onStart(EntityAI $ai){
$this->target = $this->findTarget($ai->entity, 6); //TODO max distance for different mobs
$this->target = $this->findTarget($ai->entity, $this->distance);
if(!($this->target instanceof Entity) || !$this->target->isPlayer()){
$this->reset();
$this->onEnd($ai);
return;
}
$this->yaw = $ai->entity->yaw;
$this->pitch = $ai->entity->pitch;
$this->selfCounter = mt_rand(20, 60);
}
@ -54,6 +57,7 @@ class TaskLookAtPlayer extends TaskBase{
$this->onEnd($ai);
return;
}
$ai->mobController->setLookPosition($this->target->x, $this->target->y + $this->target->getEyeHeight(), $this->target->z, 10, $ai->entity->getVerticalFaceSpeed());
$ai->mobController->lookOn($this->target);
$this->selfCounter--;
}