本文整理汇总了PHP中pocketmine\event\entity\EntityDamageByEntityEvent::getDamager方法的典型用法代码示例。如果您正苦于以下问题:PHP EntityDamageByEntityEvent::getDamager方法的具体用法?PHP EntityDamageByEntityEvent::getDamager怎么用?PHP EntityDamageByEntityEvent::getDamager使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pocketmine\event\entity\EntityDamageByEntityEvent
的用法示例。
在下文中一共展示了EntityDamageByEntityEvent::getDamager方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: onFight
/**
* @param EntityDamageByEntityEvent $event
* @priority HIGH
* @ignoreCancelled true
*/
public function onFight(EntityDamageByEntityEvent $event)
{
if (!$this->isFactionWorld($event->getEntity()->getLevel()->getName())) {
return;
}
$victim = $event->getEntity();
$attacker = $event->getDamager();
if (!$attacker instanceof Player or !$victim instanceof Player) {
return;
}
/** @noinspection PhpUnusedLocalVariableInspection */
$at = $this->getFList()->getFaction(Chunk::fromObject($victim));
$attackf = $this->getFList()->getFaction($attacker);
$victimf = $this->getFList()->getFaction($victim);
/** @noinspection PhpUnusedLocalVariableInspection */
$state = $this->getFList()->getFactionsState($attackf, $victimf);
// TODO
}
示例2: onEntityDamageByEntity
/**
* @param EntityDamageByEntityEvent $event
*
* @priority HIGH
* @ignoreCancelled true
*/
public function onEntityDamageByEntity(EntityDamageByEntityEvent $event)
{
$damager = $event->getDamager();
$damaged = $event->getEntity();
if ($damager instanceof Player && !$damager->isOp() && $damaged instanceof Player) {
foreach ($this->plugin->getAllZones() as $zone) {
if ($zone->isIn($damaged)) {
if ($zone->pvpAvailable) {
break;
}
$event->setCancelled(true);
$damager->sendMessage("[iZone] You are trying to attack in a private zone");
break;
}
}
}
}
示例3: onEntityDamageByEntity
public function onEntityDamageByEntity(EntityDamageByEntityEvent $event)
{
$attacker = $event->getDamager();
$victim = $event->getEntity();
if ($attacker instanceof Player and $victim instanceof Player) {
if ($attacker === $this->potato) {
$this->potato->sendMessage(TextFormat::GOLD . "You gave up the potato to " . $victim->getName() . "!");
$this->potato = $victim;
$this->alertToPotato();
$event->setCancelled(true);
}
}
}
示例4: onPlayerDamagedByEntity
public function onPlayerDamagedByEntity(EntityDamageByEntityEvent $event)
{
$attacker = $event->getDamager();
$victim = $event->getEntity();
if (!$victim instanceof Player) {
return;
}
if (($vipVictim = $this->getVip($victim)) !== null and $vipVictim->refuseToPvp() or ($vipAttacker = $this->getVip($attacker)) !== null and $vipAttacker->refuseToPvp()) {
$event->setDamage(0);
$event->setCancelled(true);
return;
}
if ($attacker instanceof Arrow and ($arrowIndex = array_search($attacker->getId(), $this->arrowQueue)) !== false) {
$victim->setOnFire(10);
unset($this->arrowQueue[$arrowIndex]);
}
}
示例5: onPlayerDamageByPlayerEvent
public function onPlayerDamageByPlayerEvent(EntityDamageByEntityEvent $event)
{
$attacker = $event->getDamager();
$victim = $event->getEntity();
if (!($this->enabled and $attacker instanceof Player and $victim instanceof Player)) {
return;
}
if (!($attacker->hasPermission("minigames.play") and $victim->hasPermission("minigames.play"))) {
return;
}
}
示例6: 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());
}
}
}
}