本文整理汇总了PHP中pocketmine\event\entity\EntityDamageByEntityEvent::getFinalDamage方法的典型用法代码示例。如果您正苦于以下问题:PHP EntityDamageByEntityEvent::getFinalDamage方法的具体用法?PHP EntityDamageByEntityEvent::getFinalDamage怎么用?PHP EntityDamageByEntityEvent::getFinalDamage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pocketmine\event\entity\EntityDamageByEntityEvent
的用法示例。
在下文中一共展示了EntityDamageByEntityEvent::getFinalDamage方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: onHit
public function onHit(\pocketmine\event\entity\EntityDamageByEntityEvent $ev)
{
if (!$ev->getEntity() instanceof Player or !$ev->getDamager() instanceof Player) {
return;
}
if ($this->status !== 2) {
$ev->setCancelled();
$ev->getDamager()->sendMessage("[CrashBang] 정숙");
return;
}
if ($this->skill[$ev->getDamager()->getName()] === Skills::INVINCIBLE and $this->ps[$ev->getDamager()->getName()] > microtime(true) or $this->skill[$ev->getEntity()->getName()] === Skills::INVINCIBLE and $this->ps[$ev->getEntity()->getName()] > microtime(true)) {
$ev->setCancelled();
$ev->getDamager()->sendMessage("[CrashBang] 당신 또는 대상이 무적 상태이므로 공격이 무시됩니다.");
return;
}
if (in_array($this->skill[$ev->getDamager()->getName()], [Skills::BERSERKER, Skills::VAMPIRE, Skills::STEALTH, Skills::UPGRADE, Skills::POISONED_DAGGER])) {
switch ($this->skill[$ev->getDamager()->getName()]) {
case Skills::BERSERKER:
$ev->setDamage(floor((20 - $ev->getDamager()->getHealth()) / 4) * 2, 5);
break;
case Skills::VAMPIRE:
$e = new EntityRegainHealthEvent($ev->getDamager(), 2, EntityRegainHealthEvent::CAUSE_MAGIC);
$ev->getDamager()->heal(2, $e);
break;
case Skills::STEALTH:
$ev->getDamager()->removeEffect(Effect::INVISIBILITY);
break;
case Skills::UPGRADE:
$ev->setDamage($this->ps[$ev->getDamager()->getName()], 5);
break;
case Skills::POISONED_DAGGER:
$this->startCooldown($this->getDamager());
$ev->setDamage(5, 5);
break;
}
} else {
if ($this->skill[$ev->getEntity()->getName()] === Skills::EYE_FOR_EYE and $this->ps[$ev->getEntity()->getName()]-- > 0) {
if ($this->skill[$ev->getDamager()->getName()] === Skills::EYE_FOR_EYE) {
return;
}
$e = new EntityDamageByEntityEvent($ev->getEntity(), $ev->getDamager(), EntityDamageEvent::CAUSE_ENTITY_ATTACK, floor($ev->getFinalDamage() * 0.7));
$ev->getDamager()->attack($e->getFinalDamage(), $e);
} else {
if ($ev->getDamager()->getInventory()->getItemInHand()->getID() === Item::BLAZE_ROD and in_array($this->skill[$ev->getDamager()->getName()], [Skills::ASSASSIN, Skills::TRACE])) {
$ev->setCancelled();
if ($this->cooldown[$ev->getDamager()->getName()] > 0) {
$ev->getDamager()->sendMessage("[CrashBang] 아직 스킬을 사용할 수 없습니다.");
$ev->setCancelled(false);
return;
}
switch ($this->skill[$ev->getDamager()->getName()]) {
case Skills::ASSASSIN:
$n = mt_rand(0, 99);
$ev->setCancelled(false);
if ($n < 30) {
$ev->setDamage(9999);
} else {
$e = new EntityDamageByEntityEvent($ev->getEntity(), $ev->getDamager(), EntityDamageEvent::CAUSE_ENTITY_ATTACK, 15);
$ev->getDamager()->attack($ev->getFinalDamage(), $e);
$ev->setDamage(15);
}
break;
case Skills::TRACE:
$this->getServer()->getScheduler()->scheduleDelayedTask(new TraceTask($this, $ev->getDamager(), $ev->getEntity()), 7 * 20);
$ev->getDamager()->sendMessage("[CrashBang] 7초 후 추적 대상" . $ev->getEntity()->getName() . "에게 이동합니다.");
break;
}
$this->startCooldown($ev->getDamager());
}
}
}
}