当前位置: 首页>>代码示例>>PHP>>正文


PHP EntityDamageByEntityEvent::getFinalDamage方法代码示例

本文整理汇总了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());
             }
         }
     }
 }
开发者ID:cr0sh,项目名称:CrashBang,代码行数:72,代码来源:CrashBang.php


注:本文中的pocketmine\event\entity\EntityDamageByEntityEvent::getFinalDamage方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。