getAmplifier() public method

public getAmplifier ( ) : integer
return integer
コード例 #1
0
ファイル: Entity.php プロジェクト: RedstoneAlmeida/Steadfast2
 public function addEffect(Effect $effect)
 {
     if (isset($this->effects[$effect->getId()])) {
         $oldEffect = $this->effects[$effect->getId()];
         if (abs($effect->getAmplifier()) <= $oldEffect->getAmplifier() or abs($effect->getAmplifier()) === abs($oldEffect->getAmplifier()) and $effect->getDuration() < $oldEffect->getDuration()) {
             return;
         }
         $effect->add($this, true);
     } else {
         $effect->add($this, false);
     }
     $this->effects[$effect->getId()] = $effect;
     $this->recalculateEffectColor();
     if ($effect->getId() === Effect::HEALTH_BOOST) {
         $this->setHealth($this->getHealth() + 4 * ($effect->getAmplifier() + 1));
     }
 }
コード例 #2
0
ファイル: Entity.php プロジェクト: Cecil107/PocketMine-0.13.0
 public function addEffect(Effect $effect)
 {
     if (isset($this->effects[$effect->getId()])) {
         $oldEffect = $this->effects[$effect->getId()];
         if (abs($effect->getAmplifier()) <= $oldEffect->getAmplifier() or abs($effect->getAmplifier()) === abs($oldEffect->getAmplifier()) and $effect->getDuration() < $oldEffect->getDuration()) {
             return;
         }
         $effect->add($this, true);
     } else {
         $effect->add($this, false);
     }
     $this->effects[$effect->getId()] = $effect;
     $this->recalculateEffectColor();
     if ($effect->getId() === Effect::HEALTH_BOOST) {
         $this->setHealth($this->getHealth() + 4 * ($effect->getAmplifier() + 1));
     }
     if ($effect->getId() === Effect::HEALING) {
         if ($this->getHealth() + 2 * ($effect->getAmplifier() + 1) > $this->getMaxHealth()) {
             $ev = new EntityRegainHealthEvent($this, $this->getMaxHealth() - $this->getHealth(), EntityRegainHealthEvent::CAUSE_MAGIC);
             $this->heal($ev->getAmount(), $ev);
         } else {
             $ev = new EntityRegainHealthEvent($this, 2 * ($effect->getAmplifier() + 1), EntityRegainHealthEvent::CAUSE_MAGIC);
             $this->heal($ev->getAmount(), $ev);
         }
     }
     if ($effect->getId() === Effect::HARMING) {
         if ($this->getHealth() - 3 * ($effect->getAmplifier() + 1) < 0) {
             $ev = new EntityDamageEvent($this, EntityDamageEvent::CAUSE_MAGIC, $this->getHealth());
             $this->attack($ev->getFinalDamage(), $ev);
         } else {
             $ev = new EntityDamageEvent($this, EntityDamageEvent::CAUSE_MAGIC, 3 * ($effect->getAmplifier() + 1));
             $this->attack($ev->getFinalDamage(), $ev);
         }
     }
 }
コード例 #3
0
ファイル: Effect.php プロジェクト: xxFlare/PocketMine-MP
 public function add(Entity $entity, $modify = false, Effect $oldEffect = null)
 {
     if ($entity instanceof Player) {
         $pk = new MobEffectPacket();
         $pk->eid = 0;
         $pk->effectId = $this->getId();
         $pk->amplifier = $this->getAmplifier();
         $pk->particles = $this->isVisible();
         $pk->duration = $this->getDuration();
         if ($modify) {
             $pk->eventId = MobEffectPacket::EVENT_MODIFY;
         } else {
             $pk->eventId = MobEffectPacket::EVENT_ADD;
         }
         $entity->dataPacket($pk);
     }
     if ($this->id === Effect::INVISIBILITY) {
         $entity->setDataFlag(Entity::DATA_FLAGS, Entity::DATA_FLAG_INVISIBLE, true);
         $entity->setNameTagVisible(false);
     } elseif ($this->id === Effect::SPEED) {
         $attr = $entity->getAttributeMap()->getAttribute(Attribute::MOVEMENT_SPEED);
         if ($modify and $oldEffect !== null) {
             $speed = $attr->getValue() / (1 + 0.2 * $oldEffect->getAmplifier());
         } else {
             $speed = $attr->getValue();
         }
         $speed *= 1 + 0.2 * $this->amplifier;
         $attr->setValue($speed);
     } elseif ($this->id === Effect::SLOWNESS) {
         $attr = $entity->getAttributeMap()->getAttribute(Attribute::MOVEMENT_SPEED);
         if ($modify and $oldEffect !== null) {
             $speed = $attr->getValue() / (1 - 0.15 * $oldEffect->getAmplifier());
         } else {
             $speed = $attr->getValue();
         }
         $speed *= 1 - 0.15 * $this->amplifier;
         $attr->setValue($speed);
     }
 }
コード例 #4
0
ファイル: Loader.php プロジェクト: mwvent/WattzEssentialsPE
 /**
  * Allow to switch between levels Vanished!
  * You need to teleport the player to a different level in order to call this event
  *
  * @param Player $player
  * @param Level $origin
  * @param Level $target
  */
 public function switchLevelVanish(Player $player, Level $origin, Level $target)
 {
     if ($origin->getName() !== $target->getName() && $this->isVanished($player)) {
         // This will be used if the specified player has "noPacket" enabled.
         // A temporal check will be used for "the other players".
         $noPacket = $this->hasNoPacket($player);
         // Just as prevention if any player has "noPacket" disabled...
         $pk = new MobEffectPacket();
         $pk->effectId = $this->invisibilityEffect->getId();
         $pk->amplifier = $this->invisibilityEffect->getAmplifier();
         $pk->particles = $this->invisibilityEffect->isVisible();
         $pk->duration = $this->invisibilityEffect->getDuration();
         // Show to origin's players
         $pk->eventId = MobEffectPacket::EVENT_REMOVE;
         foreach ($origin->getPlayers() as $p) {
             if ($p !== $player) {
                 if ($this->isVanished($player)) {
                     if (!$noPacket) {
                         $pk->eid = $player->getId();
                         $p->dataPacket($pk);
                     } else {
                         $p->showPlayer($player);
                     }
                 }
                 if ($this->isVanished($p)) {
                     if (!$this->hasNoPacket($p)) {
                         $pk->eid = $p->getId();
                         $player->dataPacket($pk);
                     } else {
                         $player->showPlayer($p);
                     }
                 }
             }
         }
         // Hide to target's players
         $pk->eventId = MobEffectPacket::EVENT_ADD;
         foreach ($target->getPlayers() as $p) {
             if ($p !== $player) {
                 if ($this->isVanished($player)) {
                     if (!$noPacket) {
                         $pk->eid = $player->getId();
                         $p->dataPacket($pk);
                     } else {
                         $p->hidePlayer($player);
                     }
                 }
                 if ($this->isVanished($p)) {
                     if (!$this->hasNoPacket($p)) {
                         $pk->eid = $p->getId();
                         $player->dataPacket($pk);
                     } else {
                         $player->hidePlayer($p);
                     }
                 }
             }
         }
     }
 }
コード例 #5
0
ファイル: Entity.php プロジェクト: kniffo80/Genisys
 public function addEffect(Effect $effect)
 {
     Server::getInstance()->getPluginManager()->callEvent($ev = new EntityEffectAddEvent($this, $effect));
     if ($ev->isCancelled()) {
         return false;
     }
     if ($effect->getId() === Effect::HEALTH_BOOST) {
         $this->setHealth($this->getHealth() + 4 * ($effect->getAmplifier() + 1));
     }
     if ($effect->getId() === Effect::ABSORPTION and $this instanceof Human) {
         $this->setAbsorption(4 * ($effect->getAmplifier() + 1));
     }
     if (isset($this->effects[$effect->getId()])) {
         $oldEffect = $this->effects[$effect->getId()];
         if ($effect->getAmplifier() <= $oldEffect->getAmplifier() and $effect->getDuration() < $oldEffect->getDuration()) {
             return;
         }
         $effect->add($this, true, $oldEffect);
     } else {
         $effect->add($this, false);
     }
     $this->effects[$effect->getId()] = $effect;
     $this->recalculateEffectColor();
     return true;
 }
コード例 #6
0
ファイル: Entity.php プロジェクト: yungtechboy1/Genisys
 public function addEffect(Effect $effect)
 {
     if ($effect->getId() === Effect::HEALTH_BOOST) {
         $this->setHealth($this->getHealth() + 4 * ($effect->getAmplifier() + 1));
     }
     if ($effect->getId() === Effect::ABSORPTION and $this instanceof Human) {
         $this->setAbsorption(4 * ($effect->getAmplifier() + 1));
     }
     if (isset($this->effects[$effect->getId()])) {
         $oldEffect = $this->effects[$effect->getId()];
         if ($effect->getAmplifier() <= $oldEffect->getAmplifier() and $effect->getDuration() < $oldEffect->getDuration()) {
             return;
         }
         $effect->add($this, true, $oldEffect);
     } else {
         $effect->add($this, false);
     }
     $this->effects[$effect->getId()] = $effect;
     $this->recalculateEffectColor();
 }