Package net.sf.l2j.gameserver.templates

Examples of net.sf.l2j.gameserver.templates.L2Weapon


        activeChar.abortAttack();
        activeChar.broadcastUserInfo();
      }
      else
      {
                L2Weapon weaponItem = activeChar.getActiveWeaponItem();
                int itemid = item.getItemId();
        //_log.finest("item not equipable id:"+ item.getItemId());
                if (itemid == 4393)
                {
                        activeChar.sendPacket(new ShowCalculator(4393));
                }
                else if ((weaponItem != null && weaponItem.getItemType() == L2WeaponType.ROD)
                    && ((itemid >= 6519 && itemid <= 6527) || (itemid >= 7610 && itemid <= 7613) || (itemid >= 7807 && itemid <= 7809) || (itemid >= 8484 && itemid <= 8486) || (itemid >= 8505 && itemid <= 8513)))
                {
                    activeChar.getInventory().setPaperdollItem(Inventory.PAPERDOLL_LHAND, item);
                    activeChar.broadcastUserInfo();
                    // Send a Server->Client packet ItemList to this L2PcINstance to update left hand equipement
View Full Code Here


  {
        if (!(playable instanceof L2PcInstance)) return;

        L2PcInstance activeChar = (L2PcInstance)playable;
        L2ItemInstance weaponInst = activeChar.getActiveWeaponInstance();
        L2Weapon weaponItem = activeChar.getActiveWeaponItem();
        int itemId = item.getItemId();

        if (activeChar.isInOlympiadMode()){
          SystemMessage sm = new SystemMessage(SystemMessageId.THIS_ITEM_IS_NOT_AVAILABLE_FOR_THE_OLYMPIAD_EVENT);
      sm.addString(item.getItemName());
      activeChar.sendPacket(sm);
      sm = null;
          return;
        }

        // Check if Blessed Spiritshot can be used
        if (weaponInst == null || weaponItem.getSpiritShotCount() == 0)
        {
            if(!activeChar.getAutoSoulShot().containsKey(itemId))
                activeChar.sendPacket(new SystemMessage(SystemMessageId.CANNOT_USE_SPIRITSHOTS));
            return;
        }

        // Check if Blessed Spiritshot is already active (it can be charged over Spiritshot)
        if (weaponInst.getChargedSpiritshot() != L2ItemInstance.CHARGED_NONE) return;

        // Check for correct grade
        int weaponGrade = weaponItem.getCrystalType();
    if ((weaponGrade == L2Item.CRYSTAL_NONE && itemId != 3947) ||
        (weaponGrade == L2Item.CRYSTAL_D && itemId != 3948) ||
        (weaponGrade == L2Item.CRYSTAL_C && itemId != 3949) ||
        (weaponGrade == L2Item.CRYSTAL_B && itemId != 3950) ||
        (weaponGrade == L2Item.CRYSTAL_A && itemId != 3951) ||
        (weaponGrade == L2Item.CRYSTAL_S && itemId != 3952))
        {
            if(!activeChar.getAutoSoulShot().containsKey(itemId))
                activeChar.sendPacket(new SystemMessage(SystemMessageId.SPIRITSHOTS_GRADE_MISMATCH));
            return;
        }

        // Consume Blessed Spiritshot if player has enough of them
        if (!activeChar.destroyItemWithoutTrace("Consume", item.getObjectId(), weaponItem.getSpiritShotCount(), null, false))
        {
            if(activeChar.getAutoSoulShot().containsKey(itemId))
            {
                activeChar.removeAutoSoulShot(itemId);
                activeChar.sendPacket(new ExAutoSoulShot(itemId, 0));
View Full Code Here

  {
    if (!(playable instanceof L2PcInstance)) return;

    L2PcInstance activeChar = (L2PcInstance)playable;
    L2ItemInstance weaponInst = activeChar.getActiveWeaponInstance();
    L2Weapon weaponItem = activeChar.getActiveWeaponItem();
        int itemId = item.getItemId();

        // Check if Spiritshot can be used
        if (weaponInst == null || weaponItem.getSpiritShotCount() == 0)
        {
            if(!activeChar.getAutoSoulShot().containsKey(itemId))
                activeChar.sendPacket(new SystemMessage(SystemMessageId.CANNOT_USE_SPIRITSHOTS));
      return;
    }

        // Check if Spiritshot is already active
        if (weaponInst.getChargedSpiritshot() != L2ItemInstance.CHARGED_NONE) return;

        // Check for correct grade
        int weaponGrade = weaponItem.getCrystalType();
    if ((weaponGrade == L2Item.CRYSTAL_NONE && itemId != 5790 && itemId != 2509) ||
        (weaponGrade == L2Item.CRYSTAL_D && itemId != 2510) ||
        (weaponGrade == L2Item.CRYSTAL_C && itemId != 2511) ||
        (weaponGrade == L2Item.CRYSTAL_B && itemId != 2512) ||
        (weaponGrade == L2Item.CRYSTAL_A && itemId != 2513) ||
        (weaponGrade == L2Item.CRYSTAL_S && itemId != 2514))
    {
            if(!activeChar.getAutoSoulShot().containsKey(itemId))
                activeChar.sendPacket(new SystemMessage(SystemMessageId.SPIRITSHOTS_GRADE_MISMATCH));
      return;
    }

        // Consume Spiritshot if player has enough of them
        if (!activeChar.destroyItemWithoutTrace("Consume", item.getObjectId(), weaponItem.getSpiritShotCount(), null, false))
    {
            if(activeChar.getAutoSoulShot().containsKey(itemId))
            {
                activeChar.removeAutoSoulShot(itemId);
                activeChar.sendPacket(new ExAutoSoulShot(itemId, 0));
View Full Code Here

    if (!(playable instanceof L2PcInstance))
      return;

    L2PcInstance activeChar = (L2PcInstance)playable;
    L2ItemInstance weaponInst = activeChar.getActiveWeaponInstance();
    L2Weapon weaponItem = activeChar.getActiveWeaponItem();

    if (weaponInst == null || weaponItem.getItemType() != L2WeaponType.ROD)
    {
      return;
    }

    if (weaponInst.getChargedFishshot())
    {
      // spiritshot is already active
      return;
    }

    int FishshotId = item.getItemId();
    int grade = weaponItem.getCrystalType();
    int count = item.getCount();

    if ((grade == L2Item.CRYSTAL_NONE && FishshotId != 6535) ||
    (grade == L2Item.CRYSTAL_D && FishshotId != 6536) ||
    (grade == L2Item.CRYSTAL_C && FishshotId != 6537) ||
View Full Code Here

        }

        int itemId = 6645;
        int shotConsumption = 1;
        L2ItemInstance weaponInst = null;
        L2Weapon weaponItem = null;

        if ((activePet instanceof L2PetInstance) && !(activePet instanceof L2BabyPetInstance))
        {
            weaponInst = ((L2PetInstance)activePet).getActiveWeaponInstance();
            weaponItem = ((L2PetInstance)activePet).getActiveWeaponItem();

            if (weaponInst == null)
            {
                activeOwner.sendPacket(new SystemMessage(SystemMessageId.CANNOT_USE_SOULSHOTS));
                return;
            }

            if (weaponInst.getChargedSoulshot() != L2ItemInstance.CHARGED_NONE)
            {
                // SoulShots are already active.
                return;
            }

            int shotCount = item.getCount();
            shotConsumption = weaponItem.getSoulShotCount();

            if (shotConsumption == 0)
            {
                activeOwner.sendPacket(new SystemMessage(SystemMessageId.CANNOT_USE_SOULSHOTS));
                return;
View Full Code Here

        int itemId = item.getItemId();
        boolean isBlessed = (itemId == 6647);
        int shotConsumption = 1;

        L2ItemInstance weaponInst = null;
        L2Weapon weaponItem = null;

        if ((activePet instanceof L2PetInstance) && !(activePet instanceof L2BabyPetInstance))
        {
            weaponInst = ((L2PetInstance)activePet).getActiveWeaponInstance();
            weaponItem = ((L2PetInstance)activePet).getActiveWeaponItem();

            if (weaponInst == null)
            {
                activeOwner.sendPacket(new SystemMessage(SystemMessageId.CANNOT_USE_SPIRITSHOTS));
                return;
            }

            if (weaponInst.getChargedSpiritshot() != L2ItemInstance.CHARGED_NONE)
            {
                // SpiritShots are already active.
                return;
            }

            int shotCount = item.getCount();
             shotConsumption = weaponItem.getSpiritShotCount();

            if (shotConsumption == 0)
            {
                activeOwner.sendPacket(new SystemMessage(SystemMessageId.CANNOT_USE_SPIRITSHOTS));
                return;
View Full Code Here

  {
    if (!(playable instanceof L2PcInstance)) return;

    L2PcInstance activeChar = (L2PcInstance)playable;
    L2ItemInstance weaponInst = activeChar.getActiveWeaponInstance();
    L2Weapon weaponItem = activeChar.getActiveWeaponItem();
        int itemId = item.getItemId();

        // Check if Soulshot can be used
    if (weaponInst == null || weaponItem.getSoulShotCount() == 0)
    {
            if(!activeChar.getAutoSoulShot().containsKey(itemId))
                activeChar.sendPacket(new SystemMessage(SystemMessageId.CANNOT_USE_SOULSHOTS));
      return;
    }

    // Check for correct grade
        int weaponGrade = weaponItem.getCrystalType();
        if ((weaponGrade == L2Item.CRYSTAL_NONE && itemId != 5789 && itemId != 1835) ||
      (weaponGrade == L2Item.CRYSTAL_D && itemId != 1463) ||
      (weaponGrade == L2Item.CRYSTAL_C && itemId != 1464) ||
      (weaponGrade == L2Item.CRYSTAL_B && itemId != 1465) ||
      (weaponGrade == L2Item.CRYSTAL_A && itemId != 1466) ||
      (weaponGrade == L2Item.CRYSTAL_S && itemId != 1467))
    {
            if(!activeChar.getAutoSoulShot().containsKey(itemId))
                activeChar.sendPacket(new SystemMessage(SystemMessageId.SOULSHOTS_GRADE_MISMATCH));
      return;
    }

        activeChar.soulShotLock.lock();
        try
        {
          // Check if Soulshot is already active
          if (weaponInst.getChargedSoulshot() != L2ItemInstance.CHARGED_NONE)
            return;

          // Consume Soulshots if player has enough of them
          int saSSCount = (int)activeChar.getStat().calcStat(Stats.SOULSHOT_COUNT, 0, null, null);
          int SSCount = saSSCount == 0 ? weaponItem.getSoulShotCount() : saSSCount;

          if (!activeChar.destroyItemWithoutTrace("Consume", item.getObjectId(), SSCount, null, false))
          {
            if(activeChar.getAutoSoulShot().containsKey(itemId))
            {
View Full Code Here

    }
    for (Iterator<Integer> iter = _weapons.keySet().iterator(); iter.hasNext();)
    {

      Integer id = iter.next();
      L2Weapon item = _weapons.get(id);
      if (item.getItemId() > highestId)
      {
        highestId = item.getItemId();
      }
    }
    for (Iterator<Integer> iter = _etcItems.keySet().iterator(); iter.hasNext();)
    {
      Integer id = iter.next();
      L2EtcItem item = _etcItems.get(id);
      if (item.getItemId() > highestId)
      {
        highestId = item.getItemId();
      }
    }

    // Create a FastLookUp Table called _allTemplates of size : value of the highest item ID
    if (Config.DEBUG) _log.fine("highest item id used:" + highestId);
    _allTemplates = new L2Item[highestId +1];

    // Insert armor item in Fast Look Up Table
    for (Iterator<Integer> iter = _armors.keySet().iterator(); iter.hasNext();)
    {
      Integer id = iter.next();
      L2Armor item = _armors.get(id);
      assert _allTemplates[id.intValue()] == null;
      _allTemplates[id.intValue()] = item;
    }

    // Insert weapon item in Fast Look Up Table
    for (Iterator<Integer> iter = _weapons.keySet().iterator(); iter.hasNext();)
    {
      Integer id = iter.next();
      L2Weapon item = _weapons.get(id);
      assert _allTemplates[id.intValue()] == null;
      _allTemplates[id.intValue()] = item;
    }

    // Insert etcItem item in Fast Look Up Table
View Full Code Here

                //_log.warning("AttackableAI: Attack target is NULL.");
                setIntention(AI_INTENTION_ACTIVE);
                return;
            }

            L2Weapon weapon = _actor.getActiveWeaponItem();
            if (weapon != null && weapon.getItemType() == L2WeaponType.BOW)
            {
                // Micht: kepping this one otherwise we should do 2 sqrt
                double distance2 = _actor.getPlanDistanceSq(getAttackTarget().getX(), getAttackTarget().getY());
                if (distance2 <= 10000)
                {
View Full Code Here

   
    // Get the active weapon instance (always equiped in the right hand)
    L2ItemInstance weaponInst = getActiveWeaponInstance();
   
    // Get the active weapon item corresponding to the active weapon instance (always equiped in the right hand)
    L2Weapon weaponItem = getActiveWeaponItem();
   
    if ((weaponItem != null) && (weaponItem.getItemType() == L2WeaponType.ROD))
    {
      // You can't make an attack with a fishing pole.
      ((L2PcInstance) this).sendPacket(new SystemMessage(SystemMessageId.CANNOT_ATTACK_WITH_FISHING_POLE));
      getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
     
      ActionFailed af = new ActionFailed();
      sendPacket(af);
      return;
    }
   
    // GeoData Los Check here (or dz > 1000)
    if (!GeoData.getInstance().canSeeTarget(this, target))
    {
      sendPacket(new SystemMessage(SystemMessageId.CANT_SEE_TARGET));
      getAI().setIntention(CtrlIntention.AI_INTENTION_ACTIVE);
      sendPacket(new ActionFailed());
      return;
    }
   
    // Check for a bow
    if (((weaponItem != null) && (weaponItem.getItemType() == L2WeaponType.BOW)))
    {
      // Check for arrows and MP
      if (this instanceof L2PcInstance)
      {
        // Checking if target has moved to peace zone - only for player-bow attacks at the moment
        // Other melee is checked in movement code and for offensive spells a check is done every time
        if (target.isInsidePeaceZone((L2PcInstance) this))
        {
          getAI().setIntention(CtrlIntention.AI_INTENTION_ACTIVE);
          sendPacket(new ActionFailed());
          return;
        }
       
        // Verify if the bow can be use
        if (_disableBowAttackEndTime <= GameTimeController.getGameTicks())
        {
          // Verify if L2PcInstance owns enough MP
          int saMpConsume = (int) getStat().calcStat(Stats.MP_CONSUME, 0, null, null);
          int mpConsume = saMpConsume == 0 ? weaponItem.getMpConsume() : saMpConsume;
         
          if (getCurrentMp() < mpConsume)
          {
            // If L2PcInstance doesn't have enough MP, stop the attack
           
            ThreadPoolManager.getInstance().scheduleAi(new NotifyAITask(CtrlEvent.EVT_READY_TO_ACT), 1000);
           
            sendPacket(new SystemMessage(SystemMessageId.NOT_ENOUGH_MP));
            sendPacket(new ActionFailed());
            return;
          }
          // If L2PcInstance have enough MP, the bow consummes it
          getStatus().reduceMp(mpConsume);
         
          // Set the period of bow non re-use
          _disableBowAttackEndTime = (5 * GameTimeController.TICKS_PER_SECOND) + GameTimeController.getGameTicks();
        }
        else
        {
          // Cancel the action because the bow can't be re-use at this moment
          ThreadPoolManager.getInstance().scheduleAi(new NotifyAITask(CtrlEvent.EVT_READY_TO_ACT), 1000);
         
          sendPacket(new ActionFailed());
          return;
        }
       
        // Equip arrows needed in left hand and send a Server->Client packet ItemList to the L2PcINstance then return True
        if (!checkAndEquipArrows())
        {
          // Cancel the action because the L2PcInstance have no arrow
          getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
         
          sendPacket(new ActionFailed());
          sendPacket(new SystemMessage(SystemMessageId.NOT_ENOUGH_ARROWS));
          return;
        }
      }
      else if (this instanceof L2NpcInstance)
      {
        if (_disableBowAttackEndTime > GameTimeController.getGameTicks())
        {
          return;
        }
      }
    }
   
    // Add the L2PcInstance to _knownObjects and _knownPlayer of the target
    target.getKnownList().addKnownObject(this);
   
    // Reduce the current CP if TIREDNESS configuration is activated
    if (Config.ALT_GAME_TIREDNESS)
    {
      setCurrentCp(getCurrentCp() - 10);
    }
   
    // Recharge any active auto soulshot tasks for player (or player's summon if one exists).
    if (this instanceof L2PcInstance)
    {
      ((L2PcInstance) this).rechargeAutoSoulShot(true, false, false);
    }
    else if (this instanceof L2Summon)
    {
      ((L2Summon) this).getOwner().rechargeAutoSoulShot(true, false, true);
    }
   
    // Verify if soulshots are charged.
    boolean wasSSCharged;
   
    if ((this instanceof L2Summon) && !(this instanceof L2PetInstance))
    {
      wasSSCharged = (((L2Summon) this).getChargedSoulShot() != L2ItemInstance.CHARGED_NONE);
    }
    else
    {
      wasSSCharged = ((weaponInst != null) && (weaponInst.getChargedSoulshot() != L2ItemInstance.CHARGED_NONE));
    }
   
    // Get the Attack Speed of the L2Character (delay (in milliseconds) before next attack)
    int timeAtk = calculateTimeBetweenAttacks(target, weaponItem);
    // the hit is calculated to happen halfway to the animation - might need further tuning e.g. in bow case
    int timeToHit = timeAtk / 2;
    _attackEndTime = GameTimeController.getGameTicks();
    _attackEndTime += (timeAtk / GameTimeController.MILLIS_IN_TICK);
    _attackEndTime -= 1;
   
    int ssGrade = 0;
   
    if (weaponItem != null)
    {
      ssGrade = weaponItem.getCrystalType();
    }
   
    // Create a Server->Client packet Attack
    Attack attack = new Attack(this, wasSSCharged, ssGrade);
   
    boolean hitted;
   
    // Set the Attacking Body part to CHEST
    setAttackingBodypart();
   
    // Get the Attack Reuse Delay of the L2Weapon
    int reuse = calculateReuseTime(target, weaponItem);
   
    // Select the type of attack to start
    if (weaponItem == null)
    {
      hitted = doAttackHitSimple(attack, target, timeToHit);
    }
    else if (weaponItem.getItemType() == L2WeaponType.BOW)
    {
      hitted = doAttackHitByBow(attack, target, timeAtk, reuse);
    }
    else if (weaponItem.getItemType() == L2WeaponType.POLE)
    {
      hitted = doAttackHitByPole(attack, timeToHit);
    }
    else if (isUsingDualWeapon())
    {
View Full Code Here

TOP

Related Classes of net.sf.l2j.gameserver.templates.L2Weapon

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.