本文整理汇总了PHP中pocketmine\event\player\PlayerInteractEvent::getFinalDamage方法的典型用法代码示例。如果您正苦于以下问题:PHP PlayerInteractEvent::getFinalDamage方法的具体用法?PHP PlayerInteractEvent::getFinalDamage怎么用?PHP PlayerInteractEvent::getFinalDamage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pocketmine\event\player\PlayerInteractEvent
的用法示例。
在下文中一共展示了PlayerInteractEvent::getFinalDamage方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: onTouch
public function onTouch(\pocketmine\event\player\PlayerInteractEvent $ev)
{
if ($ev->getBlock()->getID() === Block::CAKE_BLOCK) {
if (!isset($this->lastEat[$ev->getPlayer()->getName()])) {
$this->lastEat[$ev->getPlayer()->getName()] = 0;
}
if ($this->lastEat[$ev->getPlayer()->getName()] <= microtime(true)) {
$e = new EntityRegainHealthEvent($ev->getPlayer(), 4, EntityRegainHealthEvent::CAUSE_EATING);
$ev->getPlayer()->heal(4, $e);
$this->lastEat[$ev->getPlayer()->getName()] = microtime(true) + ($this->skill[$ev->getPlayer()->getName()] === Skills::BIG_EATER ? 1.5 : 5);
$ev->getPlayer()->sendMessage("[CrashBang] 체력이 회복되었습니다.");
} else {
$ev->getPlayer()->sendMessage("[CrashBang] 체력은 5초에 한 번만 회복이 가능합니다(식신은 1.5초)");
}
}
if ($this->status !== 2 or $ev->getItem()->getID() !== Item::BLAZE_ROD) {
return;
}
$ev->setCancelled();
if ($this->cooldown[$ev->getPlayer()->getName()] > 0) {
$ev->getPlayer()->sendMessage("[CrashBang] 아직 스킬을 사용할 수 없습니다.");
return;
}
switch ($this->skill[$ev->getPlayer()->getName()]) {
case Skills::ZOMBIE:
$ev->getPlayer()->addEffect(Effect::getEffect(Effect::SLOWNESS)->setAmplifier(2)->setDuration(15 * 20));
$ev->getPlayer()->addEffect(Effect::getEffect(Effect::REGENERATION)->setAmplifier(4)->setDuration(10 * 20));
break;
case Skills::EARTHQUAKE:
$dirs = array();
foreach ($this->getServer()->getOnlinePlayers() as $p) {
if ($p->getName() === $ev->getPlayer()->getName()) {
continue;
}
$dirs[$p->getName()] = $p->distance($ev->getPlayer());
}
asort($dirs);
$i = 0;
foreach ($dirs as $p => $d) {
if (++$i >= 2) {
break;
}
$p = $this->getServer()->getPlayerExact($p);
$e = new EntityDamageByEntityEvent($ev->getPlayer(), $p, EntityDamageEvent::CAUSE_ENTITY_ATTACK, 12);
$p->attack($ev->getFinalDamage(), $e);
}
break;
case Skills::PLAGUE:
foreach ($this->getServer()->getOnlinePlayers() as $p) {
if ($p->getName() !== $ev->getPlayer()->getName()) {
$p->addEffect(Effect::getEffect(Effect::NAUSEA)->setAmplifier(1)->setDuration(15 * 20));
$p->addEffect(Effect::getEffect(Effect::SLOWNESS)->setAmplifier(1)->setDuration(7 * 20));
}
}
break;
case Skills::CREEPER:
foreach ($this->getServer()->getOnlinePlayers() as $p) {
if ($ev->getPlayer()->distanceSquared($p) > 25) {
continue;
}
$e = new EntityDamageByEntityEvent($ev->getPlayer(), $p, EntityDamageEvent::CAUSE_ENTITY_ATTACK, 15);
$p->attack($e->getFinalDamage(), $e);
}
break;
case Skills::HEAL:
$ev->getPlayer()->addEffect(Effect::getEffect(Effect::REGENERATION)->setAmplifier(5)->setDuration(3 * 20));
break;
case Skills::STEALTH:
$ev->getPlayer()->addEffect(Effect::getEffect(Effect::INVISIBILITY)->setAmplifier(1)->setDuration(5 * 20));
break;
case Skills::EYE_FOR_EYE:
$this->ps[$ev->getEntity()->getName()] += 3;
break;
case Skills::IGNITE:
foreach ($this->getServer()->getOnlinePlayers() as $p) {
$p->setOnFire(7);
}
break;
case Skills::STORM:
foreach ($this->getServer()->getOnlinePlayers() as $p) {
if ($p->getName() === $ev->getPlayer()->getName() or $ev->getPlayer()->distanceSquared($p) > 22 ** 2) {
continue;
}
$e = new EntityDamageByEntityEvent($ev->getPlayer(), $p, EntityDamageEvent::CAUSE_ENTITY_ATTACK, 4);
$p->attack($e->getFinalDamage(), $e);
$p->sendMessage("[CrashBang] 야 쓰레기! 폭풍저그 콩진호가 간다!");
$p->sendMessage("[CrashBang] 야 쓰레기! 폭풍저그 콩진호가 간다!");
}
break;
case Skills::EQUALITY:
foreach ($this->getServer()->getOnlinePlayers() as $p) {
$p->setHealth(8);
}
$this->getServer()->broadcastMessage("[CrashBang] 평등 스킬이 사용되었습니다.");
break;
case Skills::REBORN:
$this->ps[$ev->getPlayer()->getName()] = 1;
$ev->getPlayer()->kill();
$ev->getPlayer()->sendMessage("[CrashBang] 환생 시 추가 체력을 지급받습니다.");
break;
//.........这里部分代码省略.........