Package net.sf.l2j.gameserver.model

Examples of net.sf.l2j.gameserver.model.L2Object


        }
      }
    }
   
    // Get the current target
    L2Object oldTarget = getTarget();
   
    if (oldTarget != null)
    {
      if (oldTarget.equals(newTarget))
      {
        return; // no target change
      }
     
      // Remove the L2PcInstance from the _statusListener of the old target if it was a L2Character
View Full Code Here


    }
   
    // ************************************* 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:
      case TARGET_PARTY:
      case TARGET_ALLY:
      case TARGET_CLAN:
      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(new ActionFailed());
      return;
    }
    // Are the target and the player in the same duel?
    if (isInDuel())
    {
      if (!((target instanceof L2PcInstance) && (((L2PcInstance) target).getDuelId() == getDuelId())))
      {
        sendMessage("You cannot do this while duelling.");
        sendPacket(new ActionFailed());
        return;
      }
    }
   
    // ************************************* Check skill availability *******************************************
   
    // Check if this skill is enabled (ex : reuse time)
    if (isSkillDisabled(skill.getId()) && (getAccessLevel() < Config.GM_PEACEATTACK))
    {
      SystemMessage sm = new SystemMessage(SystemMessageId.SKILL_NOT_AVAILABLE);
      sm.addString(skill.getName());
      sendPacket(sm);
     
      // Send a Server->Client packet ActionFailed to the L2PcInstance
      sendPacket(new ActionFailed());
      return;
    }
   
    // Check if all skills are disabled
    if (isAllSkillsDisabled() && (getAccessLevel() < Config.GM_PEACEATTACK))
    {
      // Send a Server->Client packet ActionFailed to the L2PcInstance
      sendPacket(new ActionFailed());
      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(new ActionFailed());
      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(new ActionFailed());
      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;
      }
    }
   
    // ************************************* Check Casting Conditions *******************************************
   
    // Check if the caster own the weapon needed
    if (!skill.getWeaponDependancy(this))
    {
      // Send a Server->Client packet ActionFailed to the L2PcInstance
      sendPacket(new ActionFailed());
      return;
    }
   
    // Check if all casting conditions are completed
    if (!skill.checkCondition(this, target, false))
    {
      // Send a Server->Client packet ActionFailed to the L2PcInstance
      sendPacket(new ActionFailed());
      return;
    }
   
    // ************************************* Check Player State *******************************************
   
    // Abnormal effects(ex : Stun, Sleep...) are checked in L2Character useMagic()
   
    // Check if the player use "Fake Death" skill
    if (isAlikeDead())
    {
      // Send a Server->Client packet ActionFailed to the L2PcInstance
      sendPacket(new ActionFailed());
      return;
    }
   
    // Check if the caster is sitting
    if (isSitting() && !skill.isPotion())
    {
      // Send a System Message to the caster
      sendPacket(new SystemMessage(SystemMessageId.CANT_MOVE_SITTING));
     
      // Send a Server->Client packet ActionFailed to the L2PcInstance
      sendPacket(new ActionFailed());
      return;
    }
   
    if (isFishing() && ((sklType != SkillType.PUMPING) && (sklType != SkillType.REELING) && (sklType != SkillType.FISHING)))
    {
      // Only fishing skills are available
      sendPacket(new SystemMessage(SystemMessageId.ONLY_FISHING_SKILLS_NOW));
      return;
    }
   
    // ************************************* Check Skill Type *******************************************
   
    // Check if this is offensive magic skill
    if (skill.isOffensive())
    {
      if ((isInsidePeaceZone(this, target)) && (getAccessLevel() < Config.GM_PEACEATTACK))
      {
        // If L2Character or target is in a peace zone, send a system message TARGET_IN_PEACEZONE a Server->Client packet ActionFailed
        sendPacket(new SystemMessage(SystemMessageId.TARGET_IN_PEACEZONE));
        sendPacket(new ActionFailed());
        return;
      }
     
      if (isInOlympiadMode() && !isOlympiadStart())
      {
        // if L2PcInstance is in Olympia and the match isn't already start, send a Server->Client packet ActionFailed
        sendPacket(new ActionFailed());
        return;
      }
     
      // Check if the target is attackable
      if (!target.isAttackable() && (getAccessLevel() < Config.GM_PEACEATTACK))
      {
        // If target is not attackable, send a Server->Client packet ActionFailed
        sendPacket(new ActionFailed());
        return;
      }
     
      // Check if a Forced ATTACK is in progress on non-attackable target
      if (!target.isAutoAttackable(this) && !forceUse && (sklTargetType != SkillTargetType.TARGET_AURA) && (sklTargetType != SkillTargetType.TARGET_CLAN) && (sklTargetType != SkillTargetType.TARGET_ALLY) && (sklTargetType != SkillTargetType.TARGET_PARTY) && (sklTargetType != SkillTargetType.TARGET_SELF))
      {
        // Send a Server->Client packet ActionFailed to the L2PcInstance
        sendPacket(new ActionFailed());
        return;
      }
View Full Code Here

      }
      if (!skill.isOffensive())
      {
        return;
      }
      L2Object mainTarget = skill.getFirstOfTargetList(L2PcInstance.this);
      // the code doesn't now support multiple targets
      if ((mainTarget == null) || !(mainTarget instanceof L2Character))
      {
        return;
      }
View Full Code Here

          item = owner.getInventory().getItemByItemId(6644);

        // if the owner has enough food, call the item handler (use the food and triffer all necessary actions)
        if (item != null && item.getCount() >= 1)
        {
          L2Object oldTarget = owner.getTarget();
          owner.setTarget(_tamedBeast);
          L2Object[] targets = {_tamedBeast};

          // emulate a call to the owner using food, but bypass all checks for range, etc
          // this also causes a call to the AI tasks handling feeding, which may call onReceiveFood as required.
View Full Code Here

TOP

Related Classes of net.sf.l2j.gameserver.model.L2Object

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.