mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-06 09:56:06 +00:00
Critical arrows, fixed arrow interception calculation
This commit is contained in:
@ -37,7 +37,7 @@ abstract class Projectile extends Entity{
|
||||
public $shootingEntity = null;
|
||||
protected $damage = 0;
|
||||
|
||||
private $hadCollision = false;
|
||||
public $hadCollision = false;
|
||||
|
||||
protected function initEntity(){
|
||||
parent::initEntity();
|
||||
@ -78,8 +78,6 @@ abstract class Projectile extends Entity{
|
||||
$this->motionY -= $this->gravity;
|
||||
}
|
||||
|
||||
$this->keepMovement = $this->checkObstruction($this->x, ($this->boundingBox->minY + $this->boundingBox->maxY) / 2, $this->z);
|
||||
|
||||
$moveVector = new Vector3($this->x + $this->motionX, $this->y + $this->motionY, $this->z + $this->motionZ);
|
||||
|
||||
$list = $this->getLevel()->getCollidingEntities($this->boundingBox->addCoord($this->motionX, $this->motionY, $this->motionZ)->expand(1, 1, 1), $this);
|
||||
@ -121,6 +119,10 @@ abstract class Projectile extends Entity{
|
||||
$motion = sqrt($this->motionX ** 2 + $this->motionY ** 2 + $this->motionZ ** 2);
|
||||
$damage = ceil($motion * $this->damage);
|
||||
|
||||
if($this instanceof Arrow and $this->isCritical){
|
||||
$damage += mt_rand(0, (int) ($damage / 2) + 1);
|
||||
}
|
||||
|
||||
if($this->shootingEntity === null){
|
||||
$ev = new EntityDamageByEntityEvent($this, $movingObjectPosition->entityHit, EntityDamageEvent::CAUSE_PROJECTILE, $damage);
|
||||
}else{
|
||||
@ -129,6 +131,7 @@ abstract class Projectile extends Entity{
|
||||
|
||||
$movingObjectPosition->entityHit->attack($ev->getFinalDamage(), $ev);
|
||||
|
||||
$this->hadCollision = true;
|
||||
|
||||
if($this->fireTicks > 0){
|
||||
$ev = new EntityCombustByEntityEvent($this, $movingObjectPosition->entityHit, 5);
|
||||
@ -153,7 +156,7 @@ abstract class Projectile extends Entity{
|
||||
$this->motionZ = 0;
|
||||
|
||||
$this->server->getPluginManager()->callEvent(new ProjectileHitEvent($this));
|
||||
}elseif(!$this->isCollided and !$this->hadCollision){
|
||||
}elseif(!$this->isCollided and $this->hadCollision){
|
||||
$this->hadCollision = false;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user