Ejemplo n.º 1
0
  @Override
  public void onStart(BuffInfo info) {
    final L2Character target = info.getEffected();
    if ((target == null) || target.isDead() || target.isDoor()) {
      return;
    }

    double amount = 0;
    final double power = _power;
    final boolean full = (power == 100.0);

    amount = full ? target.getMaxMp() : (target.getMaxMp() * power) / 100.0;
    // Prevents overheal and negative amount
    amount = Math.max(Math.min(amount, target.getMaxRecoverableMp() - target.getCurrentMp()), 0);
    if (amount != 0) {
      target.setCurrentMp(amount + target.getCurrentMp());
    }
    SystemMessage sm;
    if (info.getEffector().getObjectId() != target.getObjectId()) {
      sm = SystemMessage.getSystemMessage(SystemMessageId.S2_MP_HAS_BEEN_RESTORED_BY_C1);
      sm.addCharName(info.getEffector());
    } else {
      sm = SystemMessage.getSystemMessage(SystemMessageId.S1_MP_HAS_BEEN_RESTORED);
    }
    sm.addInt((int) amount);
    target.sendPacket(sm);
  }
Ejemplo n.º 2
0
 @Override
 public void onStart(BuffInfo info) {
   if (info.getEffected().isPlayer()
       && (getTicks() > 0)
       && (info.getSkill().getAbnormalType() == AbnormalType.HP_RECOVER)) {
     info.getEffected().sendPacket(new ExRegenMax(info.getAbnormalTime(), getTicks(), _power));
   }
 }
Ejemplo n.º 3
0
 @Override
 public void onStart(BuffInfo info) {
   info.getEffected()
       .addListener(
           new ConsumerEventListener(
               info.getEffected(),
               EventType.ON_CREATURE_SKILL_USE,
               (OnCreatureSkillUse event) -> onSkillUseEvent(event),
               this));
 }
Ejemplo n.º 4
0
  @Override
  public void onStart(BuffInfo info) {
    if ((info.getEffected() == null)
        || (info.getEffected() == info.getEffector())
        || info.getEffected().isRaid()) {
      return;
    }

    info.getEffected().breakCast();
  }
Ejemplo n.º 5
0
  @Override
  public void onStart(BuffInfo info) {
    if (_escapeType == null) {
      return;
    }

    if (info.getEffected() instanceof L2GuardInstance) {
      info.getEffected().teleToLocation(((L2Npc) info.getEffected()).getSpawn());
      info.getEffected().setHeading(((L2Npc) info.getEffected()).getSpawn().getHeading());
    } else {
      info.getEffected()
          .teleToLocation(
              MapRegionManager.getInstance().getTeleToLocation(info.getEffected(), _escapeType),
              true);
      info.getEffected().setInstanceId(0);
    }
  }
Ejemplo n.º 6
0
  @Override
  public boolean onActionTime(BuffInfo info) {
    if (info.getEffected().isDead() || info.getEffected().isDoor()) {
      return false;
    }

    double hp = info.getEffected().getCurrentHp();
    final double maxhp = info.getEffected().getMaxRecoverableHp();

    // Not needed to set the HP and send update packet if player is already at max HP
    if (hp >= maxhp) {
      return false;
    }

    hp += _power * getTicksMultiplier();
    hp = Math.min(hp, maxhp);
    info.getEffected().setCurrentHp(hp);
    return info.getSkill().isToggle();
  }
Ejemplo n.º 7
0
 @Override
 public void onExit(BuffInfo info) {
   info.getEffected()
       .removeListenerIf(EventType.ON_CREATURE_SKILL_USE, listener -> listener.getOwner() == this);
 }
Ejemplo n.º 8
0
 @Override
 public boolean calcSuccess(BuffInfo info) {
   return Formulas.calcProbability(
       _chance, info.getEffector(), info.getEffected(), info.getSkill());
 }