mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-21 03:59:43 +00:00
fixed tasklookaround
This commit is contained in:
parent
b7f9d3f1c5
commit
3d1dba6b86
14 changed files with 58 additions and 24 deletions
|
|
@ -2,31 +2,29 @@
|
|||
|
||||
class TaskLookAround extends TaskBase
|
||||
{
|
||||
private $rotation;
|
||||
public $lookOffsetX, $lookOffsetZ;
|
||||
|
||||
public function onStart(EntityAI $ai)
|
||||
{
|
||||
$this->selfCounter = 1;
|
||||
$this->rotation = mt_rand(-120, 120);
|
||||
$this->selfCounter = 20 + lcg_value();
|
||||
$v = (M_PI * 2) * lcg_value();
|
||||
$this->lookOffsetX = cos($v);
|
||||
$this->lookOffsetZ = sin($v);
|
||||
}
|
||||
|
||||
public function onEnd(EntityAI $ai)
|
||||
{
|
||||
$ai->entity->idleTime = mt_rand(20, 40);
|
||||
//$ai->entity->idleTime = mt_rand(20, 40);
|
||||
}
|
||||
|
||||
public function canBeExecuted(EntityAI $ai)
|
||||
{
|
||||
return !$ai->entity->inPanic && !$ai->entity->isMoving() && lcg_value() < 0.02 && !$ai->isStarted("TaskLookAtPlayer") && !$ai->isStarted("TaskMate") && !$ai->isStarted("TaskTempt") && !$ai->entity->hasPath(); /*Vanilla value*/
|
||||
}
|
||||
|
||||
|
||||
public function onUpdate(EntityAI $ai)
|
||||
{
|
||||
if($this->rotation === 0){
|
||||
$this->selfCounter = 0;
|
||||
}
|
||||
$v = min(Utils::getSign($this->rotation) * 10, $this->rotation);
|
||||
$ai->entity->headYaw += $v;
|
||||
$this->rotation -= $v;
|
||||
|
||||
--$this->selfCounter;
|
||||
$ai->mobController->setLookPosition($ai->entity->x + $this->lookOffsetX, $ai->entity->y + $ai->entity->getEyeHeight(), $ai->entity->z + $this->lookOffsetZ, 10, $ai->entity->getVerticalFaceSpeed());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue