Package com.l2jfrozen.gameserver.model

Examples of com.l2jfrozen.gameserver.model.L2Effect


   
    if (ss)
      caster.removeSs();
   
    // effect self :]
    L2Effect seffect = caster.getFirstEffect(getId());
    if (seffect != null && seffect.isSelfEffect())
    {
      // Replace old effect with new one.
      seffect.exit(false);
    }
    // cast self effect if any
    getEffectsSelf(caster);
  }
View Full Code Here


      {
        for(int seed : _seeds)
        {
          if(seed != 0)
          {
            L2Effect e = target.getFirstEffect(seed);
            if(e == null || !e.getInUse())
            {
              charged = false;
              break;
            }
          }
        }
      }
      else
      {
        charged = false;
        for(int seed : _seeds)
        {
          if(seed != 0)
          {
            L2Effect e = target.getFirstEffect(seed);
            if(e != null && e.getInUse())
            {
              charged = true;
              break;
            }
          }
View Full Code Here

              {
                L2Effect[] effects = _actor.getAllEffects();

                for(int i = 0; effects != null && i < effects.length; i++)
                {
                  L2Effect effect = effects[i];

                  if(effect.getSkill() == sk)
                  {
                    useSkillSelf = false;
                    break;
                  }
                }

                effects = null;
              }
              if(useSkillSelf)
              {
                _actor.setTarget(_actor);
              }
            }

            L2Object OldTarget = _actor.getTarget();

            clientStopMoving(null);
           
            _accessor.doCast(sk);
            _actor.setTarget(OldTarget);
            OldTarget = null;

            return;
          }
        }
      }

      // Move the actor to Pawn server side AND client side by sending Server->Client packet MoveToPawn (broadcast)
      if(hated.isMoving())
      {
        range -= 100;
      }
      if(range < 5)
      {
        range = 5;
      }

      moveToPawn(originalAttackTarget, range);

      return;
    }
    // Else, if this is close enough to attack
    _attackTimeout = MAX_ATTACK_TIMEOUT + GameTimeController.getGameTicks();

    // check for close combat skills && heal/buff skills
    if(!_actor.isMuted() /*&& _rnd.nextInt(100) <= 5*/)
    {
      boolean useSkillSelf = true;

      for(L2Skill sk : skills)
      {
        if(/*sk.getCastRange() >= dist && sk.getCastRange() <= 70 && */!sk.isPassive() && _actor.getCurrentMp() >= _actor.getStat().getMpConsume(sk) && !_actor.isSkillDisabled(sk.getId()) && (Rnd.nextInt(100) <= 8 || _actor instanceof L2PenaltyMonsterInstance && Rnd.nextInt(100) <= 20))
        {
          if(sk.getSkillType() == L2Skill.SkillType.BUFF || sk.getSkillType() == L2Skill.SkillType.HEAL)
          {
            useSkillSelf = true;

            if(sk.getSkillType() == L2Skill.SkillType.HEAL && _actor.getCurrentHp() > (int) (_actor.getMaxHp() / 1.5))
            {
              useSkillSelf = false;
              break;
            }

            if(sk.getSkillType() == L2Skill.SkillType.BUFF)
            {
              L2Effect[] effects = _actor.getAllEffects();

              for(int i = 0; effects != null && i < effects.length; i++)
              {
                L2Effect effect = effects[i];

                if(effect.getSkill() == sk)
                {
                  useSkillSelf = false;
                  break;
                }
              }
View Full Code Here

  {
    if (attachCond != null && !attachCond.test(env))
      return null;
    try
    {
      L2Effect effect = (L2Effect) _constructor.newInstance(env, this);
      // if (_applayCond != null)
      // effect.setCondition(_applayCond);
      return effect;
    }
    catch (IllegalAccessException e)
View Full Code Here

            if(sk.getSkillType() == SkillType.BUFF)
            {
              L2Effect[] effects = _actor.getAllEffects();
              for(int i = 0; effects != null && i < effects.length; i++)
              {
                L2Effect effect = effects[i];
                if(effect.getSkill() == sk)
                {
                  useSkillSelf = false;
                  break;
                }
              }
            }
            if(useSkillSelf)
            {
              _actor.setTarget(_actor);
            }
          }

          clientStopMoving(null);
          _accessor.doCast(sk);
          _actor.setTarget(OldTarget);
          return;
        }
      }

      // Check if the L2SiegeGuardInstance is attacking, knows the target and can't run
      if(!_actor.isAttackingNow() && _actor.getRunSpeed() == 0 && _actor.getKnownList().knowsObject(attackTarget))
      {
        // Cancel the target
        _actor.getKnownList().removeKnownObject(attackTarget);
        _actor.setTarget(null);
        setIntention(AI_INTENTION_IDLE, null, null);
      }
      else
      {
        double dx = _actor.getX() - attackTarget.getX();
        double dy = _actor.getY() - attackTarget.getY();
        double dz = _actor.getZ() - attackTarget.getZ();
        double homeX = attackTarget.getX() - sGuard.getSpawn().getLocx();
        double homeY = attackTarget.getY() - sGuard.getSpawn().getLocy();

        // Check if the L2SiegeGuardInstance isn't too far from it's home location
        if(dx * dx + dy * dy > 10000 && homeX * homeX + homeY * homeY > 3240000 && _actor.getKnownList().knowsObject(attackTarget))
        {
          // Cancel the target
          _actor.getKnownList().removeKnownObject(attackTarget);
          _actor.setTarget(null);
          setIntention(AI_INTENTION_IDLE, null, null);
        }
        else
        // Move the actor to Pawn server side AND client side by sending Server->Client packet MoveToPawn (broadcast)
        {
          // Temporary hack for preventing guards jumping off towers,
          // before replacing this with effective GeoClient checks and AI modification
          if(dz * dz < 170 * 170) // normally 130 if guard z coordinates correct
          {
            //if (_selfAnalysis.isMage)
            //  range = _selfAnalysis.maxCastRange - 50;
            if(_actor.getWalkSpeed() <= 0)
              return;
            if(attackTarget.isMoving())
            {
              moveToPawn(attackTarget, range - 70);
            }
            else
            {
              moveToPawn(attackTarget, range);
            }
          }
        }
      }

      return;

    }
    // Else, if the actor is muted and far from target, just "move to pawn"
    else if(_actor.isMuted() && dist_2 > range * range)
    {
      // Temporary hack for preventing guards jumping off towers,
      // before replacing this with effective GeoClient checks and AI modification
      double dz = _actor.getZ() - attackTarget.getZ();
      if(dz * dz < 170 * 170) // normally 130 if guard z coordinates correct
      {
        //if (_selfAnalysis.isMage)
        //  range = _selfAnalysis.maxCastRange - 50;
        if(_actor.getWalkSpeed() <= 0)
          return;
        if(attackTarget.isMoving())
        {
          moveToPawn(attackTarget, range - 70);
        }
        else
        {
          moveToPawn(attackTarget, range);
        }
      }
      return;
    }
    // Else, if this is close enough to attack
    else if(dist_2 <= range * range)
    {
      // Force mobs to attack anybody if confused
      L2Character hated = null;
      if(_actor.isConfused())
      {
        hated = attackTarget;
      }
      else
      {
        hated = ((L2Attackable) _actor).getMostHated();
      }

      if(hated == null)
      {
        setIntention(AI_INTENTION_ACTIVE, null, null);
        return;
      }
      if(hated != attackTarget)
      {
        attackTarget = hated;
      }

      _attackTimeout = MAX_ATTACK_TIMEOUT + GameTimeController.getGameTicks();

      // check for close combat skills && heal/buff skills
      if(!_actor.isMuted() && Rnd.nextInt(100) <= 5)
      {
        for(L2Skill sk : skills)
        {
          int castRange = sk.getCastRange();

          if(castRange * castRange >= dist_2 && !sk.isPassive() && _actor.getCurrentMp() >= _actor.getStat().getMpConsume(sk) && !_actor.isSkillDisabled(sk.getId()))
          {
            L2Object OldTarget = _actor.getTarget();
            if(sk.getSkillType() == SkillType.BUFF || sk.getSkillType() == SkillType.HEAL)
            {
              boolean useSkillSelf = true;
              if(sk.getSkillType() == SkillType.HEAL && _actor.getCurrentHp() > (int) (_actor.getMaxHp() / 1.5))
              {
                useSkillSelf = false;
                break;
              }
              if(sk.getSkillType() == SkillType.BUFF)
              {
                L2Effect[] effects = _actor.getAllEffects();
                for(int i = 0; effects != null && i < effects.length; i++)
                {
                  L2Effect effect = effects[i];
                  if(effect.getSkill() == sk)
                  {
                    useSkillSelf = false;
                    break;
                  }
                }
View Full Code Here

          continue;

        // fix when learning toggle skills
        if(sk.isToggle())
        {
          L2Effect toggleEffect = getFirstEffect(sk.getId());
          if(toggleEffect != null)
          {
            // stop old toggle skill effect, and give new toggle skill effect back
            toggleEffect.exit(false);
            sk.getEffects(this, this,false,false,false);
          }
        }

        addSkill(sk, true);
View Full Code Here

      // Like L2OFF you can't use fake death if you are mounted
      if (skill.getId() == 60 && isMounted())
      return;
     
      // Get effects of the skill
      L2Effect effect = getFirstEffect(skill);

      // Like L2OFF toogle skills have little delay
      if (TOGGLE_USE + 400 > System.currentTimeMillis())
      {
        return;
      }
     
      if(effect != null)
      {
        //fake death exception
        if (skill.getId() != 60)
          effect.exit(false);

        // Send a Server->Client packet ActionFailed to the L2PcInstance
        sendPacket(ActionFailed.STATIC_PACKET);
        return;
      }
      TOGGLE_USE = System.currentTimeMillis();
    }

    // Check if the skill is active
    if(skill.isPassive())
    {
      // just ignore the passive skill request. why does the client send it anyway ??
      // Send a Server->Client packet ActionFailed to the L2PcInstance
      sendPacket(ActionFailed.STATIC_PACKET);
      return;
    }

    if(_disabledSkills != null && _disabledSkills.contains(skill_id))
    {
      SystemMessage sm = new SystemMessage(SystemMessageId.S1_PREPARED_FOR_REUSE);
      sm.addSkillName(skill_id, skill.getLevel());
      sendPacket(sm);
      sm = null;
      return;
    }

    // Check if it's ok to summon
    // siege golem (13), Wild Hog Cannon (299), Swoop Cannon (448)
    if((skill_id == 13 || skill_id == 299 || skill_id == 448) && !SiegeManager.getInstance().checkIfOkToSummon(this, false) && !FortSiegeManager.getInstance().checkIfOkToSummon(this, false))
      return;

    //************************************* Check Casting in Progress *******************************************

    // If a skill is currently being used, queue this one if this is not the same
    // Note that this check is currently imperfect: getCurrentSkill() isn't always null when a skill has
    // failed to cast, or the casting is not yet in progress when this is rechecked
    if(curr_skill_id != -1 && (isCastingNow() || isCastingPotionNow()))
    {
      SkillDat currentSkill = getCurrentSkill();
      // Check if new skill different from current skill in progress
      if (currentSkill != null && skill.getId() == currentSkill.getSkillId())
      {
        sendPacket(ActionFailed.STATIC_PACKET);
        return;
      }

      if(Config.DEBUG && getQueuedSkill() != null)
      {
        _log.info(getQueuedSkill().getSkill().getName() + " is already queued for " + getName() + ".");
      }

      // Create a new SkillDat object and queue it in the player _queuedSkill
      setQueuedSkill(skill, forceUse, dontMove);
      sendPacket(ActionFailed.STATIC_PACKET);
      return;
    }
   
    // Create a new SkillDat object and set the player _currentSkill
    // This is used mainly to save & queue the button presses, since L2Character has
    // _lastSkillCast which could otherwise replace it
    setCurrentSkill(skill, forceUse, dontMove);
   
    if (getQueuedSkill() != null) // wiping out previous values, after casting has been aborted
      setQueuedSkill(null, false, false);
   

    //triggered skills cannot be used directly
    if(_triggeredSkills.size()>0){
     
      if(Config.DEBUG){
        System.out.println("Checking if Triggherable Skill: "+skill.getId());
        System.out.println("Saved Triggherable Skills");
       
        for(Integer skillId:_triggeredSkills.keySet()){
          System.out.println(skillId);
        }
       
      }
     
     
      if(_triggeredSkills.get(skill.getId()) != null){
        sendPacket(ActionFailed.STATIC_PACKET);
        return;
      }
    }
   
    //************************************* Check Target *******************************************
    // Create and set a L2Object containing the target of the skill
    L2Object target = null;
    SkillTargetType sklTargetType = skill.getTargetType();
    SkillType sklType = skill.getSkillType();

    switch(sklTargetType)
    {
      // Target the player if skill type is AURA, PARTY, CLAN or SELF
      case TARGET_AURA:
        if(isInOlympiadMode() && !isOlympiadStart())
          setTarget(this);
      case TARGET_PARTY:
      case TARGET_ALLY:
      case TARGET_CLAN:
      case TARGET_GROUND:
      case TARGET_SELF:
        target = this;
        break;
      case TARGET_PET:
        target = getPet();
        break;
      default:
        target = getTarget();
        break;
    }

    // Check the validity of the target
    if(target == null)
    {
      sendPacket(new SystemMessage(SystemMessageId.TARGET_CANT_FOUND));
      sendPacket(ActionFailed.STATIC_PACKET);
      return;
    }
   
    // skills can be used on Walls and Doors only durring siege
    // Ignore skill UNLOCK
    if(skill.isOffensive() && target instanceof L2DoorInstance )
    {
      boolean isCastle = (((L2DoorInstance) target).getCastle() != null
          && ((L2DoorInstance) target).getCastle().getCastleId() > 0
          && ((L2DoorInstance) target).getCastle().getSiege().getIsInProgress());
      boolean isFort = (((L2DoorInstance) target).getFort() != null
          && ((L2DoorInstance) target).getFort().getFortId() > 0
          && ((L2DoorInstance) target).getFort().getSiege().getIsInProgress());
      if ((!isCastle && !isFort))
        return;
    }
   
    // Like L2OFF you can't heal random purple people without using CTRL
    SkillDat skilldat = getCurrentSkill();
    if (skilldat != null && skill.getSkillType() == SkillType.HEAL && !skilldat.isCtrlPressed() && target instanceof L2PcInstance && ((L2PcInstance) target).getPvpFlag() == 1 && this != target)
    {
      if ((getClanId() == 0 || ((L2PcInstance) target).getClanId() == 0) || (getClanId() != ((L2PcInstance) target).getClanId()))
      {
        if ((getAllyId() == 0 || ((L2PcInstance) target).getAllyId() == 0) || (getAllyId() != ((L2PcInstance) target).getAllyId()))
        {
          if ((getParty() == null || ((L2PcInstance) target).getParty() == null) || (!getParty().equals(((L2PcInstance) target).getParty())))
          {
            sendPacket(new SystemMessage(SystemMessageId.INCORRECT_TARGET));
            sendPacket(ActionFailed.STATIC_PACKET);
            return;     
          }
        }
      }
    }
   
    // Are the target and the player in the same duel?
    if(isInDuel())
    {
      if(!(target instanceof L2PcInstance && ((L2PcInstance) target).getDuelId() == getDuelId()) && !(target instanceof L2SummonInstance && ((L2Summon) target).getOwner().getDuelId() == getDuelId()))
      {
        sendMessage("You cannot do this while duelling.");
        sendPacket(ActionFailed.STATIC_PACKET);
        return;
      }
    }

    //************************************* Check skill availability *******************************************

    // Check if this skill is enabled (ex : reuse time)
    if(isSkillDisabled(skill_id) /* && !getAccessLevel().allowPeaceAttack() */)
    {
      // SystemMessage sm = new SystemMessage(SystemMessageId.SKILL_NOT_AVAILABLE);
      // sm.addString(skill.getName());
      // sendPacket(sm);

      // Send a Server->Client packet ActionFailed to the L2PcInstance
      sendPacket(ActionFailed.STATIC_PACKET);
      return;
    }

    // Check if all skills are disabled
    if(isAllSkillsDisabled() && !getAccessLevel().allowPeaceAttack())
    {
      // Send a Server->Client packet ActionFailed to the L2PcInstance
      sendPacket(ActionFailed.STATIC_PACKET);
      return;
    }

    // prevent casting signets to peace zone
    if(skill.getSkillType() == SkillType.SIGNET || skill.getSkillType() == SkillType.SIGNET_CASTTIME)
    {
      if(isInsidePeaceZone(this))
      {
        SystemMessage sm = new SystemMessage(SystemMessageId.S1_CANNOT_BE_USED);
        sm.addSkillName(skill_id);
        sendPacket(sm);
        return;
      }
    }
    //************************************* Check Consumables *******************************************

    // Check if the caster has enough MP
    if(getCurrentMp() < getStat().getMpConsume(skill) + getStat().getMpInitialConsume(skill))
    {
      // Send a System Message to the caster
      sendPacket(new SystemMessage(SystemMessageId.NOT_ENOUGH_MP));

      // Send a Server->Client packet ActionFailed to the L2PcInstance
      sendPacket(ActionFailed.STATIC_PACKET);
      return;
    }

    // Check if the caster has enough HP
    if(getCurrentHp() <= skill.getHpConsume())
    {
      // Send a System Message to the caster
      sendPacket(new SystemMessage(SystemMessageId.NOT_ENOUGH_HP));

      // Send a Server->Client packet ActionFailed to the L2PcInstance
      sendPacket(ActionFailed.STATIC_PACKET);
      return;
    }

    // Check if the spell consummes an Item
    if(skill.getItemConsume() > 0)
    {
      // Get the L2ItemInstance consummed by the spell
      L2ItemInstance requiredItems = getInventory().getItemByItemId(skill.getItemConsumeId());

      // Check if the caster owns enought consummed Item to cast
      if(requiredItems == null || requiredItems.getCount() < skill.getItemConsume())
      {
        // Checked: when a summon skill failed, server show required consume item count
        if(sklType == L2Skill.SkillType.SUMMON)
        {
          SystemMessage sm = new SystemMessage(SystemMessageId.SUMMONING_SERVITOR_COSTS_S2_S1);
          sm.addItemName(skill.getItemConsumeId());
          sm.addNumber(skill.getItemConsume());
          sendPacket(sm);
        }
        else
        {
          // Send a System Message to the caster
          sendPacket(new SystemMessage(SystemMessageId.NOT_ENOUGH_ITEMS));
        }
        return;
      }
    }
   
    // Like L2OFF if you are mounted on wyvern you can't use own skills
    if (isFlying())
    {
      if (skill_id != 327 && skill_id != 4289 && !skill.isPotion())
      {
        sendMessage("You cannot use skills while riding a wyvern.");
        return;
      }
    }
   
    // Like L2OFF if you have a summon you can't summon another one (ignore cubics)
    if(sklType == L2Skill.SkillType.SUMMON && skill instanceof L2SkillSummon && !((L2SkillSummon) skill).isCubic())
    {
      if (getPet() != null || isMounted())
      {
        sendPacket(new SystemMessage(SystemMessageId.YOU_ALREADY_HAVE_A_PET));
        return;
      }
    }

    if(skill.getNumCharges() > 0
      && skill.getSkillType() != SkillType.CHARGE
      && skill.getSkillType() != SkillType.CHARGEDAM
      && skill.getSkillType() != SkillType.CHARGE_EFFECT
      && skill.getSkillType() != SkillType.PDAM)
    {
      EffectCharge effect = (EffectCharge) getFirstEffect(L2Effect.EffectType.CHARGE);
      if(effect == null || effect.numCharges < skill.getNumCharges())
      {
        sendPacket(new SystemMessage(SystemMessageId.SKILL_NOT_AVAILABLE));
        return;
      }
     
      effect.numCharges -= skill.getNumCharges();
      sendPacket(new EtcStatusUpdate(this));

      if(effect.numCharges == 0)
      {
        effect.exit(false);
      }
    }
    //************************************* Check Casting Conditions *******************************************

    // Check if the caster own the weapon needed
View Full Code Here

    {
      Env env = new Env();
      env.player = player;
      env.target = player;
      env.item = instance;
      L2Effect e = et.getEffect(env);
      if(e != null)
      {
        effects.add(e);
      }
    }
View Full Code Here

TOP

Related Classes of com.l2jfrozen.gameserver.model.L2Effect

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.