mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-21 20:19:44 +00:00
code style fix
This commit is contained in:
parent
fc5c5625cb
commit
5e8e9330e2
361 changed files with 4766 additions and 4650 deletions
|
|
@ -7,10 +7,10 @@ class TaskRangedAttack extends \TaskBase
|
|||
public $seenTicks = 0;
|
||||
public function __construct($speed, $range){
|
||||
$this->speedMultiplier = $speed;
|
||||
$this->rangeSquared = $range*$range;
|
||||
$this->rangeSquared = $range * $range;
|
||||
$this->server = ServerAPI::request();
|
||||
}
|
||||
|
||||
|
||||
public function onStart(EntityAI $ai)
|
||||
{
|
||||
$this->selfCounter = 1;
|
||||
|
|
@ -20,7 +20,7 @@ class TaskRangedAttack extends \TaskBase
|
|||
public function onEnd(EntityAI $ai)
|
||||
{
|
||||
$ai->entity->target = false;
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function onUpdate(EntityAI $ai)
|
||||
|
|
@ -36,24 +36,23 @@ class TaskRangedAttack extends \TaskBase
|
|||
}else{
|
||||
$this->seenTicks = 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
$dist = $ai->entity->distanceSquared($ai->entity->target);
|
||||
|
||||
|
||||
if($dist > 100 || $this->seenTicks < 20){
|
||||
$ai->mobController->setMovingTarget($ai->entity->target->x, $ai->entity->target->y, $ai->entity->target->z, $this->speedMultiplier);
|
||||
}else{
|
||||
$ai->mobController->headYawIsYaw = true;
|
||||
}
|
||||
|
||||
|
||||
$ai->mobController->setLookPosition($ai->entity->target->x, $ai->entity->target->y + 0.12, $ai->entity->target->z, 10, $ai->entity->getVerticalFaceSpeed());
|
||||
|
||||
|
||||
if($this->attackCounter <= 0 && $this->seenTicks > 0){
|
||||
$this->rangedAttack($ai->entity, $ai->entity->target);
|
||||
$this->attackCounter = 60;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function rangedAttack($selfEntity, $target){
|
||||
$d = [
|
||||
"x" => $selfEntity->x,
|
||||
|
|
@ -88,8 +87,7 @@ class TaskRangedAttack extends \TaskBase
|
|||
$this->server->api->entity->spawnToAll($arrow);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function isTargetValid(EntityAI $ai){
|
||||
$e = $ai->entity;
|
||||
if($e->target instanceof Entity && !$e->target->closed && !$e->target->dead){
|
||||
|
|
@ -97,11 +95,11 @@ class TaskRangedAttack extends \TaskBase
|
|||
$xDiff = ($t->x - $e->x);
|
||||
$yDiff = ($t->y - $e->y);
|
||||
$zDiff = ($t->z - $e->z);
|
||||
return ($xDiff*$xDiff + $yDiff*$yDiff + $zDiff*$zDiff) <= $this->rangeSquared;
|
||||
return ($xDiff * $xDiff + $yDiff * $yDiff + $zDiff * $zDiff) <= $this->rangeSquared;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public function tryTargeting(EntityAI $ai){
|
||||
$e = $ai->entity;
|
||||
if($e->target instanceof Entity){
|
||||
|
|
@ -109,21 +107,20 @@ class TaskRangedAttack extends \TaskBase
|
|||
$xDiff = ($t->x - $e->x);
|
||||
$yDiff = ($t->y - $e->y);
|
||||
$zDiff = ($t->z - $e->z);
|
||||
if(($xDiff*$xDiff + $yDiff*$yDiff + $zDiff*$zDiff) <= $this->rangeSquared){
|
||||
if(($xDiff * $xDiff + $yDiff * $yDiff + $zDiff * $zDiff) <= $this->rangeSquared){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
$closestTarget = $e->closestPlayerToAttackDist <= $this->rangeSquared ? $e->level->entityList[$e->closestPlayerToAttackEID] : null;
|
||||
|
||||
|
||||
if($closestTarget != null){
|
||||
$e->target = $closestTarget; //TODO dont save entity object ?
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function canBeExecuted(EntityAI $ai)
|
||||
{
|
||||
return $this->tryTargeting($ai);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue