mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-20 19:49:44 +00:00
better spider attacks
This commit is contained in:
parent
7a1bf49ca0
commit
0f84d692b7
5 changed files with 27 additions and 12 deletions
|
|
@ -195,8 +195,8 @@ class Entity extends Position
|
|||
return in_array($this->type, func_get_args());
|
||||
}
|
||||
|
||||
public function attackEntity($entity){
|
||||
|
||||
public function attackEntity($entity, $distance){
|
||||
return false;
|
||||
}
|
||||
|
||||
public function setInWeb(){
|
||||
|
|
@ -654,7 +654,7 @@ class Entity extends Position
|
|||
|
||||
$aaBBs = $this->level->getCubes($this, $this->boundingBox->addCoord($dx, $dy, $dz));
|
||||
|
||||
foreach($aaBBs as $bb){ //TODO optimize
|
||||
foreach($aaBBs as $bb){
|
||||
$dy = $bb->calculateYOffset($this->boundingBox, $dy);
|
||||
}
|
||||
$this->boundingBox->offset(0, $dy, 0);
|
||||
|
|
|
|||
|
|
@ -9,7 +9,8 @@ class Monster extends Creature{
|
|||
return 2;
|
||||
}
|
||||
|
||||
public function attackEntity($entity){
|
||||
public function attackEntity($entity, $distance){
|
||||
$entity->harm($this->getAttackDamage(), $this->eid);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@ class TaskAttackPlayer extends TaskBase
|
|||
$ai->mobController->setLookPosition($ai->entity->target->x, $ai->entity->target->y + 0.12, $ai->entity->target->z, 10, $ai->entity->getVerticalFaceSpeed());
|
||||
|
||||
--$this->attackCounter;
|
||||
$mult = $ai->entity instanceof Spider ? 1 : 2;
|
||||
$v1 = $ai->entity->width * $ai->entity->width * $mult*$mult;
|
||||
$v1 = $ai->entity->width * $ai->entity->width * 4;
|
||||
|
||||
$e = $ai->entity;
|
||||
$t = $e->target;
|
||||
|
|
@ -39,9 +38,7 @@ class TaskAttackPlayer extends TaskBase
|
|||
$dist = ($xDiff*$xDiff + $yDiff*$yDiff + $zDiff*$zDiff);
|
||||
if($dist <= $v1){
|
||||
if($this->attackCounter <= 0){
|
||||
$this->attackCounter = 20;
|
||||
|
||||
$e->attackEntity($t);
|
||||
$this->attackCounter = $e->attackEntity($t, sqrt($dist)) ? 20 : 0;
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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