mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-21 20:19:44 +00:00
better spider attacks
This commit is contained in:
parent
7a1bf49ca0
commit
0f84d692b7
5 changed files with 27 additions and 12 deletions
|
|
@ -57,11 +57,12 @@ class Creeper extends Monster{
|
|||
$this->timeUntilExplode = self::EXPL_TIME;
|
||||
}
|
||||
|
||||
public function attackEntity($entity){
|
||||
public function attackEntity($entity, $distance){
|
||||
if(Utils::distance_noroot($entity, $this) <= 49 && !$this->isIgnited()){
|
||||
$this->ignite();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
public function update($now){
|
||||
if($this->isIgnited() && $this->target instanceof Entity && Utils::distance_noroot($this->target, $this) > 49){ //TODO move somewhere else
|
||||
|
|
|
|||
|
|
@ -12,7 +12,23 @@ class Spider extends Monster{
|
|||
$this->ai->addTask(new TaskSwimming());
|
||||
$this->ai->addTask(new TaskAttackPlayer(1.0, 16)); //TODO fix range?
|
||||
}
|
||||
|
||||
public function attackEntity($entity, $distance){
|
||||
if($distance > 2.0 && $distance < 6.0){
|
||||
if($this->onGround){
|
||||
$diffX = $entity->x - $this->x;
|
||||
$diffZ = $entity->z - $this->z;
|
||||
$dist = sqrt($diffX*$diffX + $diffZ*$diffZ);
|
||||
|
||||
$this->speedX = $diffX / $dist*0.5*0.8 + $this->speedX*0.2;
|
||||
$this->speedZ = $diffZ / $dist*0.5*0.8 + $this->speedZ*0.2;
|
||||
$this->speedY = 0.4;
|
||||
}
|
||||
return false;
|
||||
}else{
|
||||
return parent::attackEntity($entity, $distance);
|
||||
}
|
||||
|
||||
}
|
||||
public function getDrops(){
|
||||
return [
|
||||
[STRING, 0, mt_rand(0,2)]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue