mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-21 20:19:44 +00:00
i hate git
This commit is contained in:
commit
d66ee05ae3
43 changed files with 140 additions and 53 deletions
|
|
@ -2,16 +2,19 @@
|
|||
/**
|
||||
* A Tempt but for Monsters
|
||||
*/
|
||||
class TaskAttackPlayer extends TaskTempt
|
||||
{
|
||||
class TaskAttackPlayer extends TaskTempt{
|
||||
public $attackTime = 0;
|
||||
public function onStart(EntityAI $ai)
|
||||
{
|
||||
|
||||
public function onStart(EntityAI $ai){
|
||||
$this->selfCounter = 1;
|
||||
}
|
||||
public function onUpdate(EntityAI $ai)
|
||||
{
|
||||
if(!($this->target instanceof Entity) || ($ai->entity instanceof Spider && $ai->entity->level->isDay()) || ($this->target instanceof Entity && !$this->target->isPlayer()) || (Utils::distance_noroot($this->target, $ai->entity) > 256) || $this->target->level->getName() != $ai->entity->level->getName()){
|
||||
|
||||
public function onUpdate(EntityAI $ai){
|
||||
if(!($this->target instanceof Entity)
|
||||
|| ($ai->entity instanceof Spider && $ai->entity->level->isDay())
|
||||
|| ($this->target instanceof Entity && !$this->target->isPlayer())
|
||||
|| (Utils::distance_noroot($this->target, $ai->entity) > 256)
|
||||
|| $this->target->level->getName() != $ai->entity->level->getName()){
|
||||
$this->reset();
|
||||
if($ai->entity instanceof Enderman){
|
||||
$ai->entity->setAngry(false);
|
||||
|
|
@ -24,11 +27,15 @@ class TaskAttackPlayer extends TaskTempt
|
|||
$mult = $ai->entity instanceof Spider ? 1 : 2;
|
||||
$radius = ($ai->entity->width * $mult)*($ai->entity->width * $mult);
|
||||
if(Utils::distance_noroot($this->target, $ai->entity) <= $radius && $this->attackTime <= 0){
|
||||
$ai->entity->attackEntity($this->target);
|
||||
$this->attackTime = 20;
|
||||
if($ai->entity instanceof Slime && $ai->entity->getSlimeSize() == 1){
|
||||
$this->attackTime = 20;
|
||||
}
|
||||
else{
|
||||
$ai->entity->attackEntity($this->target);
|
||||
$this->attackTime = 20;
|
||||
}
|
||||
}
|
||||
--$this->attackTime;
|
||||
|
||||
}
|
||||
public function onEnd(EntityAI $ai){
|
||||
parent::onEnd($ai);
|
||||
|
|
@ -36,10 +43,13 @@ class TaskAttackPlayer extends TaskTempt
|
|||
$ai->entity->setAngry(false);
|
||||
}
|
||||
}
|
||||
public function canBeExecuted(EntityAI $ai)
|
||||
{
|
||||
|
||||
public function canBeExecuted(EntityAI $ai){
|
||||
$target = $this->findTarget($ai->entity, 16);
|
||||
if(($ai->entity instanceof Spider && !$ai->entity->level->isDay()) || $target instanceof Entity && $target->class === ENTITY_PLAYER && $target->isPlayer()){
|
||||
if(($ai->entity instanceof Spider && !$ai->entity->level->isDay())
|
||||
|| $target instanceof Entity
|
||||
&& $target->class === ENTITY_PLAYER
|
||||
&& $target->isPlayer()){
|
||||
$this->target = $target; //TODO get rid of it
|
||||
$ai->entity->target = $target;
|
||||
if($ai->entity instanceof Enderman){ //TODO find a better way
|
||||
|
|
@ -47,7 +57,6 @@ class TaskAttackPlayer extends TaskTempt
|
|||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue