Esempio n. 1
0
  protected L2Effect(Env env, EffectTemplate template) {
    _state = EffectState.CREATED;
    _skill = env.skill;
    _template = template;
    _effected = env.target;
    _effector = env.player;
    if (env.object != null && env.object instanceof IEffector)
      _effectorObject = (IEffector) env.object;
    else _effectorObject = env.player;
    _count = template.count;
    _triggeredId = template.triggeredId;
    _triggeredLevel = template.triggeredLevel;

    int id = _skill.getId();
    int temp = template.period;
    if ((id > 2277 && id < 2286) || (id >= 2512 && id <= 2514)) {
      if (_effected instanceof L2SummonInstance
          || (_effected.isPlayer() && _effected.getPet() instanceof L2SummonInstance)) temp /= 2;
    }

    if (env.skillMastery) temp *= 2;

    _period = temp;
    _periodStartTicks = GameTimeController.getGameTicks();
    _periodfirsttime = 0;
    scheduleEffect();
  }
Esempio n. 2
0
  private synchronized void startEffectTask(int duration) {
    stopEffectTask();
    _currentTask = new EffectTask(duration, -1);
    _currentFuture = ThreadPoolManager.getInstance().scheduleEffect(_currentTask, duration);

    if (_state == EffectState.ACTING) _effected.addEffect(this);
  }
Esempio n. 3
0
 public void stopEffectTask() {
   if (_currentFuture != null) {
     _currentFuture.cancel(false);
     _currentFuture = null;
     _currentTask = null;
     _effected.removeEffect(this);
   }
 }
Esempio n. 4
0
  private synchronized void startEffectTaskAtFixedRate(int delay, int rate) {
    stopEffectTask();
    _currentTask = new EffectTask(delay, rate);
    _currentFuture =
        ThreadPoolManager.getInstance().scheduleEffectAtFixedRate(_currentTask, delay, rate);

    if (_state == EffectState.ACTING) _effected.addEffect(this);
  }
Esempio n. 5
0
  public final void setInUse(boolean inUse) {
    _inUse = inUse;
    if (_inUse) {
      _startConditionsCorrect = onStart();

      if (_template.abnormalEffect != 0)
        getEffected().startAbnormalEffect(_template.abnormalEffect);
    } else {
      if (_template.abnormalEffect != 0) getEffected().stopAbnormalEffect(_template.abnormalEffect);

      if (_startConditionsCorrect) {
        onExit();
        if (_skill.isItemSkill() && _skill.isActive()) _effected._itemActiveSkill = null;
      }
    }
  }
Esempio n. 6
0
  public final void scheduleEffect() {
    if (_state == EffectState.CREATED) {
      if (_skill.isActive() && _skill.getName().startsWith("Item Skill")) {
        if (_effected._itemActiveSkill != null) _effected._itemActiveSkill.exit();
        _effected._itemActiveSkill = this;
      }

      _state = EffectState.ACTING;

      if (_skill.isPvpSkill()) {
        SystemMessage smsg = new SystemMessage(SystemMessageId.YOU_FEEL_S1_EFFECT);
        smsg.addSkillName(_skill);
        getEffected().sendPacket(smsg);
      }

      if (_count > 1) {
        startEffectTaskAtFixedRate(5, _period * 1000);
        return;
      }

      if (_period > 0) {
        startEffectTask(_period * 1000);
        return;
      }
      // effects not having count or period should start
      setInUse(true);
    }

    if (_state == EffectState.ACTING) {
      if (_count-- > 0) {
        if (getInUse()) // effect has to be in use
        {
          if (onActionTime() && _startConditionsCorrect)
            return; // false causes effect to finish right away
        } else if (_count > 0) // do not finish it yet, in case reactivated
        return;
      }
      _state = EffectState.FINISHING;
    }

    if (_state == EffectState.FINISHING) {
      if (getInUse() || !(_count > 1 || _period > 0)) setInUse(false);
      stopEffectTask();
      if (_effectorObject != null) _effectorObject.onEffectFinished(_effected, getSkill());
    }
  }