attackEntity method was added

This commit is contained in:
GameHerobrine 2023-01-23 11:38:40 +03:00
parent 89ee29a30a
commit 45b36cb034
4 changed files with 50 additions and 40 deletions

View file

@ -189,6 +189,10 @@ class Entity extends Position
return in_array($this->type, func_get_args()); return in_array($this->type, func_get_args());
} }
public function attackEntity($entity){
}
public function addVelocity($vX, $vY = 0, $vZ = 0) public function addVelocity($vX, $vY = 0, $vZ = 0)
{ {
if($vX instanceof Vector3){ if($vX instanceof Vector3){

View file

@ -8,4 +8,8 @@ class Monster extends Creature{
public function getAttackDamage(){ public function getAttackDamage(){
return 2; return 2;
} }
public function attackEntity($entity){
$entity->harm($this->getAttackDamage(), $this->eid);
}
} }

View file

@ -19,8 +19,8 @@ class TaskAttackPlayer extends TaskTempt
$ai->mobController->moveTo($this->target->x, floor($ai->entity->y), $this->target->z); $ai->mobController->moveTo($this->target->x, floor($ai->entity->y), $this->target->z);
$ai->mobController->lookOn($this->target); $ai->mobController->lookOn($this->target);
if($ai->entity->boundingBox->intersectsWith($this->target->boundingBox) && $this->attackTime <= 0){ if($ai->entity->boundingBox->intersectsWith($this->target->boundingBox) && $this->attackTime <= 0){
$ai->entity->attackEntity($this->target);
$this->attackTime = 20; $this->attackTime = 20;
$this->target->harm($ai->entity->getAttackDamage(), $ai->entity->eid);
} }
--$this->attackTime; --$this->attackTime;

View file

@ -22,6 +22,8 @@ class Creeper extends Monster{
$this->setState($v === null ? !$this->getState() : $v); $this->setState($v === null ? !$this->getState() : $v);
} }
/** /**
* @return boolean * @return boolean
*/ */