Exemple #1
0
  protected void doRegeneration() {
    final CharStat charstat = getActiveChar().getStat();

    // Modify the current HP of the L2Character.
    if (getCurrentHp() < charstat.getMaxHp())
      setCurrentHp(getCurrentHp() + Formulas.calcHpRegen(getActiveChar()), false);

    // Modify the current MP of the L2Character.
    if (getCurrentMp() < charstat.getMaxMp())
      setCurrentMp(getCurrentMp() + Formulas.calcMpRegen(getActiveChar()), false);

    // Send the StatusUpdate packet.
    getActiveChar().broadcastStatusUpdate();
  }
Exemple #2
0
  @Override
  public void useSkill(L2Character activeChar, L2Skill skill, L2Object[] targets) {
    if (!(activeChar instanceof L2PcInstance)) return;

    if (targets == null) return;

    for (L2Object tgt : targets) {
      if (!(tgt instanceof L2MonsterInstance)) continue;

      final L2MonsterInstance target = (L2MonsterInstance) tgt;
      if (target.isDead()) continue;

      if (target.getSpoilerId() != 0) {
        activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.ALREADY_SPOILED));
        continue;
      }

      if (Formulas.calcMagicSuccess(activeChar, (L2Character) tgt, skill)) {
        target.setSpoilerId(activeChar.getObjectId());
        activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.SPOIL_SUCCESS));
      } else
        activeChar.sendPacket(
            SystemMessage.getSystemMessage(SystemMessageId.S1_RESISTED_YOUR_S2)
                .addCharName(target)
                .addSkillName(skill.getId()));

      target.getAI().notifyEvent(CtrlEvent.EVT_ATTACKED, activeChar);
    }
  }
Exemple #3
0
  /** Start the HP/MP/CP Regeneration task. */
  public final synchronized void startHpMpRegeneration() {
    if (_regTask == null && !getActiveChar().isDead()) {
      // Get the regeneration period.
      final int period = Formulas.getRegeneratePeriod(getActiveChar());

      // Create the HP/MP/CP regeneration task.
      _regTask =
          ThreadPoolManager.getInstance()
              .scheduleEffectAtFixedRate(new RegenTask(), period, period);
    }
  }