mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-21 20:19:44 +00:00
fixed more tasks
This commit is contained in:
parent
bcf7ef7c79
commit
2636aa985d
15 changed files with 64 additions and 20 deletions
|
|
@ -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--;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,12 @@
|
|||
class TaskPanic extends TaskBase
|
||||
{
|
||||
protected $randX = 2, $randZ = 2;
|
||||
|
||||
public $moveSpeed;
|
||||
public function __construct($moveSpeed){
|
||||
$this->moveSpeed = $moveSpeed;
|
||||
}
|
||||
|
||||
public function onStart(EntityAI $ai)
|
||||
{
|
||||
$this->selfCounter = 60;
|
||||
|
|
@ -16,8 +22,8 @@ class TaskPanic extends TaskBase
|
|||
}
|
||||
|
||||
public function regenerateRandXZ(){
|
||||
$this->randX = (mt_rand(0, 1) ? -1 : 1) * 2;
|
||||
$this->randZ = (mt_rand(0, 1) ? -1 : 1) * 2;
|
||||
$this->randX = (mt_rand(0, 1) ? -1 : 1);
|
||||
$this->randZ = (mt_rand(0, 1) ? -1 : 1);
|
||||
}
|
||||
|
||||
public function reset(){
|
||||
|
|
@ -28,7 +34,7 @@ class TaskPanic extends TaskBase
|
|||
{
|
||||
--$this->selfCounter;
|
||||
if($this->selfCounter % 20 === 0) $this->regenerateRandXZ();
|
||||
//TODO fix $ai->mobController->moveNonInstant($this->randX, 0, $this->randZ);
|
||||
$ai->mobController->setMovingOffset($this->randX, 0, $this->randZ, $this->moveSpeed);
|
||||
}
|
||||
|
||||
public function canBeExecuted(EntityAI $ai)
|
||||
|
|
|
|||
|
|
@ -37,11 +37,10 @@ class TaskRandomWalk extends TaskBase
|
|||
|
||||
public function canBeExecuted(EntityAI $ai)
|
||||
{
|
||||
return true;
|
||||
//if(($ai->entity instanceof Creeper && $ai->entity->isIgnited()) || $ai->entity->hasPath() || $ai->isStarted("TaskTempt") ||$ai->isStarted("TaskAttackPlayer")) {
|
||||
// return false;
|
||||
//} // i really need mutexBits
|
||||
//return !$ai->entity->inPanic && !$ai->isStarted("TaskMate") && !$ai->isStarted("TaskEatTileGoal") && !$ai->isStarted("TaskLookAround") && !$ai->isStarted("TaskLookAtPlayer") && mt_rand(0, 120) == 0;
|
||||
if(($ai->entity instanceof Creeper && $ai->entity->isIgnited()) || $ai->entity->hasPath() || $ai->isStarted("TaskTempt") ||$ai->isStarted("TaskAttackPlayer")) {
|
||||
return false;
|
||||
} // i really need mutexBits
|
||||
return !$ai->entity->inPanic && !$ai->isStarted("TaskMate") && !$ai->isStarted("TaskEatTileGoal") && !$ai->isStarted("TaskLookAround") && !$ai->isStarted("TaskLookAtPlayer") && mt_rand(0, 120) == 0;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue