Package net.sf.l2j.gameserver.model

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


        for (int index = 0; index < targets.length; index++)
        {
            L2Character target = (L2Character) targets[index];
            Formulas f = Formulas.getInstance();
            L2ItemInstance weapon = activeChar.getActiveWeaponInstance();
            if (activeChar instanceof L2PcInstance && target instanceof L2PcInstance
                && target.isAlikeDead() && target.isFakeDeath())
            {
                target.stopFakeDeath(null);
            }
            else if (target.isAlikeDead()) continue;

            boolean dual = activeChar.isUsingDualWeapon();
            boolean shld = f.calcShldUse(activeChar, target);
            // PDAM critical chance not affected by buffs, only by STR. Only some skills are meant to crit.
            boolean crit = false;
            if (skill.getBaseCritRate() > 0)
              crit = f.calcCrit(skill.getBaseCritRate() * 10 * f.getSTRBonus(activeChar));

            boolean soul = (weapon != null
                && weapon.getChargedSoulshot() == L2ItemInstance.CHARGED_SOULSHOT && weapon.getItemType() != L2WeaponType.DAGGER);

            if (!crit && (skill.getCondition() & L2Skill.COND_CRIT) != 0) damage = 0;
            else damage = (int) f.calcPhysDam(activeChar, target, skill, shld, false, dual, soul);
            if (crit) damage *= 2; // PDAM Critical damage always 2x and not affected by buffs

            if (damage > 5000 && activeChar instanceof L2PcInstance)
            {
                String name = "";
                if (target instanceof L2RaidBossInstance) name = "RaidBoss ";
                if (target instanceof L2NpcInstance)
                    name += target.getName() + "(" + ((L2NpcInstance) target).getTemplate().npcId
                        + ")";
                if (target instanceof L2PcInstance)
                    name = target.getName() + "(" + target.getObjectId() + ") ";
                name += target.getLevel() + " lvl";
                Log.add(activeChar.getName() + "(" + activeChar.getObjectId() + ") "
                    + activeChar.getLevel() + " lvl did damage " + damage + " with skill "
                    + skill.getName() + "(" + skill.getId() + ") to " + name, "damage_pdam");
            }

            if (soul && weapon != null) weapon.setChargedSoulshot(L2ItemInstance.CHARGED_NONE);

            if (damage > 0)
            {
                activeChar.sendDamageMessage(target, damage, false, crit, false);

View Full Code Here


            SystemMessage sm = new SystemMessage(SystemMessageId.YOU_FEEL_S1_EFFECT);
            sm.addSkillName(skill.getId());
            activeChar.sendPacket(sm);
          }
        }
              L2ItemInstance weapon = activeChar.getActiveWeaponInstance();
              boolean soul = (weapon != null && weapon.getChargedSoulshot() == L2ItemInstance.CHARGED_SOULSHOT && weapon.getItemType() == L2WeaponType.DAGGER);
              boolean shld = Formulas.getInstance().calcShldUse(activeChar, target);

              // Crit rate base crit rate for skill, modified with STR bonus
              boolean crit = false;
        if(Formulas.getInstance().calcCrit(skill.getBaseCritRate()*10*Formulas.getInstance().getSTRBonus(activeChar)))
          crit = true;
        double damage = (int)Formulas.getInstance().calcBlowDamage(activeChar, target, skill, shld, soul);
        if (crit)
        {
          damage *= 2;
          // Vicious Stance is special after C5, and only for BLOW skills
          // Adds directly to damage
          L2Effect vicious = activeChar.getFirstEffect(312);
          if(vicious != null && damage > 1)
          {
            for(Func func: vicious.getStatFuncs())
            {
              Env env = new Env();
              env.player = activeChar;
              env.target = target;
              env.skill = skill;
              env.value = damage;
              func.calc(env);
              damage = (int)env.value;
            }
          }
        }

        if (soul && weapon != null)
                weapon.setChargedSoulshot(L2ItemInstance.CHARGED_NONE);
        if(skill.getDmgDirectlyToHP() && target instanceof L2PcInstance)
            {
          L2PcInstance player = (L2PcInstance)target;
              if (!player.isInvul())
          {
View Full Code Here

            InventoryUpdate iu;
            StatusUpdate su;
            String path;
            int cabal = SevenSigns.CABAL_NULL;
            int stoneType = 0;
            L2ItemInstance ancientAdena = player.getInventory().getItemByItemId(
                                                                                SevenSigns.ANCIENT_ADENA_ID);
            int ancientAdenaAmount = ancientAdena == null ? 0 : ancientAdena.getCount();
            int val = Integer.parseInt(command.substring(11, 12).trim());

            if (command.length() > 12) // SevenSigns x[x] x [x..x]
                val = Integer.parseInt(command.substring(11, 13).trim());

            if (command.length() > 13)
            {
                try
                {
                    cabal = Integer.parseInt(command.substring(14, 15).trim());
                }
                catch (Exception e)
                {
                    try
                    {
                        cabal = Integer.parseInt(command.substring(13, 14).trim());
                    }
                    catch (Exception e2)
                    {
                      try
                      {
                        StringTokenizer st = new StringTokenizer(command.trim());
                        st.nextToken();
                        cabal = Integer.parseInt(st.nextToken());
                      }
                      catch (Exception e3)
                      {
                        _log.warning("Failed to retrieve cabal from bypass command. NpcId: " + getNpcId() + "; Command: " + command);
                      }
                    }
                }
            }

            switch (val)
            {
                case 2: // Purchase Record of the Seven Signs
                    if (!player.getInventory().validateCapacity(1))
                    {
                        player.sendPacket(new SystemMessage(SystemMessageId.SLOTS_FULL));
                        break;
                    }

                    L2ItemInstance adenaItem = player.getInventory().getAdenaInstance();
                    if (!player.reduceAdena("SevenSigns", SevenSigns.RECORD_SEVEN_SIGNS_COST, this, true))
                    {
                        player.sendPacket(new SystemMessage(SystemMessageId.YOU_NOT_ENOUGH_ADENA));
                        break;
                    }
                    L2ItemInstance recordSevenSigns = player.getInventory().addItem(
                                                                                    "SevenSigns",
                                                                                    SevenSigns.RECORD_SEVEN_SIGNS_ID,
                                                                                    1, player, this);

                    // Send inventory update packet
                    iu = new InventoryUpdate();
                    iu.addNewItem(recordSevenSigns);
                    iu.addItem(adenaItem);
                    sendPacket(iu);

                    // Update current load as well
                    su = new StatusUpdate(player.getObjectId());
                    su.addAttribute(StatusUpdate.CUR_LOAD, player.getCurrentLoad());
                    sendPacket(su);

                    sm = new SystemMessage(SystemMessageId.EARNED_ITEM);
                    sm.addItemName(SevenSigns.RECORD_SEVEN_SIGNS_ID);
                    player.sendPacket(sm);
                    break;
                case 3: // Join Cabal Intro 1
                case 8: // Festival of Darkness Intro - SevenSigns x [0]1
                case 10: // Teleport Locations List
                    showChatWindow(player, val, SevenSigns.getCabalShortName(cabal), false);
                    break;
                case 4: // Join a Cabal - SevenSigns 4 [0]1 x
                    int newSeal = Integer.parseInt(command.substring(15));
                    int oldCabal = SevenSigns.getInstance().getPlayerCabal(player);

                    if (oldCabal != SevenSigns.CABAL_NULL)
                    {
                        player.sendMessage("You are already a member of the "
                            + SevenSigns.getCabalName(cabal) + ".");
                        return;
                    }

                    if (player.getClassId().level() == 0)
                    {
                        player.sendMessage("You must have already completed your first class transfer.");
                        break;
                    }
                    else if (player.getClassId().level() >= 2)
                    {
                        if (Config.ALT_GAME_REQUIRE_CASTLE_DAWN)
                        {
                            if (getPlayerAllyHasCastle(player))
                            {
                                if (cabal == SevenSigns.CABAL_DUSK)
                                {
                                    player.sendMessage("You must not be a member of a castle-owning clan to join the Revolutionaries of Dusk.");
                                    return;
                                }
                            }
                            /*if (!getPlayerAllyHasCastle(player))
                            {
                              if (cabal == SevenSigns.CABAL_DAWN)
                              {
                                player.sendMessage("You must be a member of a castle-owning clan to join the Lords Of Dawn.");
                                return;
                              }
                            }
*/
                            else
                            {
                                /*
                                 * If the player is trying to join the Lords of Dawn, check if they are
                                 * carrying a Lord's certificate.
                                 *
                                 * If not then try to take the required amount of adena instead.
                                 */
                                if (cabal == SevenSigns.CABAL_DAWN)
                                {
                                    boolean allowJoinDawn = false;

                                    if (player.destroyItemByItemId(
                                                                   "SevenSigns",
                                                                   SevenSigns.CERTIFICATE_OF_APPROVAL_ID,
                                                                   1, this, false))
                                    {
                                        sm = new SystemMessage(SystemMessageId.DISSAPEARED_ITEM);
                                        sm.addNumber(1);
                                        sm.addItemName(SevenSigns.CERTIFICATE_OF_APPROVAL_ID);
                                        player.sendPacket(sm);
                                        allowJoinDawn = true;
                                    }
                                    else if (player.reduceAdena("SevenSigns",
                                                                SevenSigns.ADENA_JOIN_DAWN_COST, this,
                                                                false))
                                    {
                                        sm = new SystemMessage(SystemMessageId.DISSAPEARED_ADENA);
                                        sm.addNumber(SevenSigns.ADENA_JOIN_DAWN_COST);
                                        player.sendPacket(sm);
                                        allowJoinDawn = true;
                                    }

                                    if (!allowJoinDawn)
                                    {
                                        player.sendMessage("You must be a member of a castle-owning clan, have a Certificate of Lord's Approval, or pay 50000 adena to join the Lords of Dawn.");
                                        return;
                                    }
                                }
                            }
                        }
                    }

                    SevenSigns.getInstance().setPlayerInfo(player, cabal, newSeal);

                    if (cabal == SevenSigns.CABAL_DAWN) player.sendPacket(new SystemMessage(
                                                                                            SystemMessageId.SEVENSIGNS_PARTECIPATION_DAWN)); // Joined Dawn
                    else player.sendPacket(new SystemMessage(SystemMessageId.SEVENSIGNS_PARTECIPATION_DUSK)); // Joined Dusk

                    // Show a confirmation message to the user, indicating which seal they chose.
                    switch (newSeal)
                    {
                        case SevenSigns.SEAL_AVARICE:
                            player.sendPacket(new SystemMessage(SystemMessageId.FIGHT_FOR_AVARICE));
                            break;
                        case SevenSigns.SEAL_GNOSIS:
                            player.sendPacket(new SystemMessage(SystemMessageId.FIGHT_FOR_GNOSIS));
                            break;
                        case SevenSigns.SEAL_STRIFE:
                            player.sendPacket(new SystemMessage(SystemMessageId.FIGHT_FOR_STRIFE));
                            break;
                    }

                    showChatWindow(player, 4, SevenSigns.getCabalShortName(cabal), false);
                    break;
                case 6: // Contribute Seal Stones - SevenSigns 6 x
                    stoneType = Integer.parseInt(command.substring(13));
                    L2ItemInstance redStones = player.getInventory().getItemByItemId(
                                                                                     SevenSigns.SEAL_STONE_RED_ID);
                    int redStoneCount = redStones == null ? 0 : redStones.getCount();
                    L2ItemInstance greenStones = player.getInventory().getItemByItemId(
                                                                                       SevenSigns.SEAL_STONE_GREEN_ID);
                    int greenStoneCount = greenStones == null ? 0 : greenStones.getCount();
                    L2ItemInstance blueStones = player.getInventory().getItemByItemId(
                                                                                      SevenSigns.SEAL_STONE_BLUE_ID);
                    int blueStoneCount = blueStones == null ? 0 : blueStones.getCount();
                    int contribScore = SevenSigns.getInstance().getPlayerContribScore(player);
                    boolean stonesFound = false;

                    if (contribScore == Config.ALT_MAXIMUM_PLAYER_CONTRIB)
                    {
                        player.sendPacket(new SystemMessage(SystemMessageId.CONTRIB_SCORE_EXCEEDED));
                        break;
                  }
          int redContribCount = 0;
          int greenContribCount = 0;
          int blueContribCount = 0;
 
          switch (stoneType)
          {
              case 1:
                  blueContribCount = (Config.ALT_MAXIMUM_PLAYER_CONTRIB - contribScore)
                      / SevenSigns.BLUE_CONTRIB_POINTS;
                  if (blueContribCount > blueStoneCount)
                      blueContribCount = blueStoneCount;
                  break;
              case 2:
                  greenContribCount = (Config.ALT_MAXIMUM_PLAYER_CONTRIB - contribScore)
                      / SevenSigns.GREEN_CONTRIB_POINTS;
                  if (greenContribCount > greenStoneCount)
                      greenContribCount = greenStoneCount;
                  break;
              case 3:
                  redContribCount = (Config.ALT_MAXIMUM_PLAYER_CONTRIB - contribScore)
                      / SevenSigns.RED_CONTRIB_POINTS;
                  if (redContribCount > redStoneCount) redContribCount = redStoneCount;
                  break;
              case 4:
                  int tempContribScore = contribScore;
                  redContribCount = (Config.ALT_MAXIMUM_PLAYER_CONTRIB - tempContribScore)
                      / SevenSigns.RED_CONTRIB_POINTS;
                  if (redContribCount > redStoneCount) redContribCount = redStoneCount;
                  tempContribScore += redContribCount * SevenSigns.RED_CONTRIB_POINTS;
                  greenContribCount = (Config.ALT_MAXIMUM_PLAYER_CONTRIB - tempContribScore)
                      / SevenSigns.GREEN_CONTRIB_POINTS;
                  if (greenContribCount > greenStoneCount)
                      greenContribCount = greenStoneCount;
                  tempContribScore += greenContribCount * SevenSigns.GREEN_CONTRIB_POINTS;
                  blueContribCount = (Config.ALT_MAXIMUM_PLAYER_CONTRIB - tempContribScore)
                      / SevenSigns.BLUE_CONTRIB_POINTS;
                  if (blueContribCount > blueStoneCount)
                      blueContribCount = blueStoneCount;
                  break;
          }
          if (redContribCount > 0)
          {
              if (player.destroyItemByItemId("SevenSigns", SevenSigns.SEAL_STONE_RED_ID,
                                             redContribCount, this, false))
                  stonesFound = true;
          }
          if (greenContribCount > 0)
          {
              if (player.destroyItemByItemId("SevenSigns", SevenSigns.SEAL_STONE_GREEN_ID,
                                             greenContribCount, this, false))
                  stonesFound = true;
          }
          if (blueContribCount > 0)
          {
              if (player.destroyItemByItemId("SevenSigns", SevenSigns.SEAL_STONE_BLUE_ID,
                                             blueContribCount, this, false))
                  stonesFound = true;
          }
 
          if (!stonesFound)
          {
              player.sendMessage("You do not have any seal stones of that type.");
              break;
          }
         
          contribScore = SevenSigns.getInstance().addPlayerStoneContrib(
                                                                             player,
                                                                             blueContribCount,
                                                                             greenContribCount,
                                                                             redContribCount);
 
          sm = new SystemMessage(SystemMessageId.CONTRIB_SCORE_INCREASED);
          sm.addNumber(contribScore);
          player.sendPacket(sm);
 
          showChatWindow(player, 6, null, false);
                    break;
                case 7: // Exchange Ancient Adena for Adena - SevenSigns 7 xxxxxxx
                    int ancientAdenaConvert = 0;

                    try
                    {
                        ancientAdenaConvert = Integer.parseInt(command.substring(13).trim());
                    }
                    catch (NumberFormatException e)
                    {
                        player.sendMessage("You must enter an integer amount.");
                        break;
                    }
                    catch (StringIndexOutOfBoundsException e)
                    {
                        player.sendMessage("You must enter an amount.");
                        break;
                    }

                    if (ancientAdenaAmount < ancientAdenaConvert || ancientAdenaConvert < 1)
                    {
                        player.sendPacket(new SystemMessage(SystemMessageId.YOU_NOT_ENOUGH_ADENA));
                        break;
                    }

                    player.reduceAncientAdena("SevenSigns", ancientAdenaConvert, this, true);
                    player.addAdena("SevenSigns", ancientAdenaConvert, this, true);

                    iu = new InventoryUpdate();
                    iu.addModifiedItem(player.getInventory().getAncientAdenaInstance());
                    iu.addModifiedItem(player.getInventory().getAdenaInstance());
                    player.sendPacket(iu);
                    break;
                case 9: // Receive Contribution Rewards
                    int playerCabal = SevenSigns.getInstance().getPlayerCabal(player);
                    int winningCabal = SevenSigns.getInstance().getCabalHighestScore();

                    if (SevenSigns.getInstance().isSealValidationPeriod() && playerCabal == winningCabal)
                    {
                        int ancientAdenaReward = SevenSigns.getInstance().getAncientAdenaReward(player,
                                                                                                true);

                        if (ancientAdenaReward < 3)
                        {
                            showChatWindow(player, 9, "b", false);
                            break;
                        }

                        player.addAncientAdena("SevenSigns", ancientAdenaReward, this, true);

                        // Send inventory update packet
                        iu = new InventoryUpdate();
                        iu.addModifiedItem(player.getInventory().getAncientAdenaInstance());
                        sendPacket(iu);

                        // Update current load as well
                        su = new StatusUpdate(player.getObjectId());
                        su.addAttribute(StatusUpdate.CUR_LOAD, player.getCurrentLoad());
                        sendPacket(su);

                        showChatWindow(player, 9, "a", false);
                    }
                    break;
                case 11: // Teleport to Hunting Grounds
                    try
                    {
                        String portInfo = command.substring(14).trim();

                        StringTokenizer st = new StringTokenizer(portInfo);
                        int x = Integer.parseInt(st.nextToken());
                        int y = Integer.parseInt(st.nextToken());
                        int z = Integer.parseInt(st.nextToken());
                        int ancientAdenaCost = Integer.parseInt(st.nextToken());

                        if (ancientAdenaCost > 0)
                        {
                            if (!player.reduceAncientAdena("SevenSigns", ancientAdenaCost, this, true))
                                break;
                        }

                        player.teleToLocation(x, y, z, true);
                    }
                    catch (Exception e)
                    {
                        _log.warning("SevenSigns: Error occurred while teleporting player: " + e);
                    }
                    break;
                case 17: // Exchange Seal Stones for Ancient Adena (Type Choice) - SevenSigns 17 x
                    stoneType = Integer.parseInt(command.substring(14));
                    int stoneId = 0;
                    int stoneCount = 0;
                    int stoneValue = 0;
                    String stoneColor = null;
                    String content;

                    switch (stoneType)
                    {
                        case 1:
                            stoneColor = "blue";
                            stoneId = SevenSigns.SEAL_STONE_BLUE_ID;
                            stoneValue = SevenSigns.SEAL_STONE_BLUE_VALUE;
                            break;
                        case 2:
                            stoneColor = "green";
                            stoneId = SevenSigns.SEAL_STONE_GREEN_ID;
                            stoneValue = SevenSigns.SEAL_STONE_GREEN_VALUE;
                            break;
                        case 3:
                            stoneColor = "red";
                            stoneId = SevenSigns.SEAL_STONE_RED_ID;
                            stoneValue = SevenSigns.SEAL_STONE_RED_VALUE;
                            break;
                    }

                    L2ItemInstance stoneInstance = player.getInventory().getItemByItemId(stoneId);

                    if (stoneInstance != null) stoneCount = stoneInstance.getCount();

                    path = SevenSigns.SEVEN_SIGNS_HTML_PATH + "signs_17.htm";
                    content = HtmCache.getInstance().getHtm(path);

                    if (content != null)
                    {
                        content = content.replaceAll("%stoneColor%", stoneColor);
                        content = content.replaceAll("%stoneValue%", String.valueOf(stoneValue));
                        content = content.replaceAll("%stoneCount%", String.valueOf(stoneCount));
                        content = content.replaceAll("%stoneItemId%", String.valueOf(stoneId));
                        content = content.replaceAll("%objectId%", String.valueOf(getObjectId()));

                        NpcHtmlMessage html = new NpcHtmlMessage(getObjectId());
                        html.setHtml(content);
                        player.sendPacket(html);
                    }
                    else
                    {
                        _log.warning("Problem with HTML text " + SevenSigns.SEVEN_SIGNS_HTML_PATH
                            + "signs_17.htm: " + path);
                    }
                    break;
                case 18: // Exchange Seal Stones for Ancient Adena - SevenSigns 18 xxxx xxxxxx
                    int convertStoneId = Integer.parseInt(command.substring(14, 18));
                    int convertCount = 0;

                    try
                    {
                        convertCount = Integer.parseInt(command.substring(19).trim());
                    }
                    catch (Exception NumberFormatException)
                    {
                        player.sendMessage("You must enter an integer amount.");
                        break;
                    }

                    L2ItemInstance convertItem = player.getInventory().getItemByItemId(convertStoneId);

                    if (convertItem == null)
                    {
                        player.sendMessage("You do not have any seal stones of that type.");
                        break;
                    }

                    int totalCount = convertItem.getCount();
                    int ancientAdenaReward = 0;

                    if (convertCount <= totalCount && convertCount > 0)
                    {
                        switch (convertStoneId)
View Full Code Here

      int rewradItemCount = 1; //L2Manor.getInstance().getRewardAmount(itemId, manor.getCastle().getCropReward(itemId));

      rewradItemCount = count / rewradItemCount;

      // Add item to Inventory and adjust update packet
      L2ItemInstance item = player.getInventory().addItem("Manor",rewradItemId,rewradItemCount,player,manor);
      L2ItemInstance iteme = player.getInventory().destroyItemByItemId("Manor",itemId,count,player,manor);

      if (item == null || iteme == null)
        continue;

      playerIU.addRemovedItem(iteme);
View Full Code Here

    }

    // NOTE: disabled due to deadlocks
//        synchronized (activeChar.getInventory())
//    {
      L2ItemInstance item = activeChar.getInventory().getItemByObjectId(_objectId);

      if (item == null)
                return;

      if (item.isWear())
      {
        // No unequipping wear-items
        return;
      }

      int itemId = item.getItemId();
      /*
       * Alt game - Karma punishment // SOE
       * 736    Scroll of Escape
       * 1538    Blessed Scroll of Escape
       * 1829    Scroll of Escape: Clan Hall
       * 1830    Scroll of Escape: Castle
       * 3958    L2Day - Blessed Scroll of Escape
       * 5858    Blessed Scroll of Escape: Clan Hall
       * 5859    Blessed Scroll of Escape: Castle
       * 6663    Scroll of Escape: Orc Village
       * 6664    Scroll of Escape: Silenos Village
       * 7117    Scroll of Escape to Talking Island
       * 7118    Scroll of Escape to Elven Village
       * 7119    Scroll of Escape to Dark Elf Village
       * 7120    Scroll of Escape to Orc Village
       * 7121    Scroll of Escape to Dwarven Village
       * 7122    Scroll of Escape to Gludin Village
       * 7123    Scroll of Escape to the Town of Gludio
       * 7124    Scroll of Escape to the Town of Dion
       * 7125    Scroll of Escape to Floran
       * 7126    Scroll of Escape to Giran Castle Town
       * 7127    Scroll of Escape to Hardin's Private Academy
       * 7128    Scroll of Escape to Heine
       * 7129    Scroll of Escape to the Town of Oren
       * 7130    Scroll of Escape to Ivory Tower
       * 7131    Scroll of Escape to Hunters Village
       * 7132    Scroll of Escape to Aden Castle Town
       * 7133    Scroll of Escape to the Town of Goddard
       * 7134    Scroll of Escape to the Rune Township
       * 7135    Scroll of Escape to the Town of Schuttgart.
       * 7554    Scroll of Escape to Talking Island
       * 7555    Scroll of Escape to Elven Village
       * 7556    Scroll of Escape to Dark Elf Village
       * 7557    Scroll of Escape to Orc Village
       * 7558    Scroll of Escape to Dwarven Village
       * 7559    Scroll of Escape to Giran Castle Town
       * 7618    Scroll of Escape - Ketra Orc Village
       * 7619    Scroll of Escape - Varka Silenos Village
       */
      if (!Config.ALT_GAME_KARMA_PLAYER_CAN_TELEPORT && activeChar.getKarma() > 0
        && (itemId == 736 || itemId == 1538 || itemId == 1829 || itemId == 1830
        || itemId == 3958 || itemId == 5858 || itemId == 5859 || itemId == 6663
        || itemId == 6664 || (itemId >= 7117 && itemId <= 7135)
        || (itemId >= 7554 && itemId <= 7559) || itemId == 7618 || itemId == 7619))
        return;

      // Items that cannot be used
      if (itemId == 57)
                return;

            if (activeChar.isFishing() && (itemId < 6535 || itemId > 6540))
            {
                // You cannot do anything else while fishing
                SystemMessage sm = new SystemMessage(SystemMessageId.CANNOT_DO_WHILE_FISHING_3);
                getClient().getActiveChar().sendPacket(sm);
                sm = null;
                return;
            }

      // Char cannot use item when dead
      if (activeChar.isDead())
      {
        SystemMessage sm = new SystemMessage(SystemMessageId.S1_CANNOT_BE_USED);
        sm.addItemName(itemId);
        getClient().getActiveChar().sendPacket(sm);
        sm = null;
        return;
      }

      // Char cannot use pet items
      if (item.getItem().isForWolf() || item.getItem().isForHatchling()
        || item.getItem().isForStrider() || item.getItem().isForBabyPet())
      {
        SystemMessage sm = new SystemMessage(SystemMessageId.CANNOT_EQUIP_PET_ITEM); // You cannot equip a pet item.
        sm.addItemName(itemId);
        getClient().getActiveChar().sendPacket(sm);
        sm = null;
        return;
      }

      if (Config.DEBUG)
                _log.finest(activeChar.getObjectId() + ": use item " + _objectId);

      if (item.isEquipable())
      {
        // No unequipping/equipping while the player is in special conditions
        if (activeChar.isStunned() || activeChar.isSleeping() || activeChar.isParalyzed()
            || activeChar.isAlikeDead())
        {
          activeChar.sendMessage("Your status does not allow you to do that.");
          return;
        }

        int bodyPart = item.getItem().getBodyPart();
                // Prevent player to remove the weapon on special conditions
                if ((activeChar.isAttackingNow() || activeChar.isCastingNow() || activeChar.isMounted())
                        && (bodyPart == L2Item.SLOT_LR_HAND
                            || bodyPart == L2Item.SLOT_L_HAND
                            || bodyPart == L2Item.SLOT_R_HAND))
                {
                    return;
                }
                /* Since c5 you can equip weapon again
                // Don't allow weapon/shield equipment if wearing formal wear
                if (activeChar.isWearingFormalWear()
                  && (bodyPart == L2Item.SLOT_LR_HAND
                            || bodyPart == L2Item.SLOT_L_HAND
                            || bodyPart == L2Item.SLOT_R_HAND))
                {
                SystemMessage sm = new SystemMessage(SystemMessageId.CANNOT_USE_ITEMS_SKILLS_WITH_FORMALWEAR);
                activeChar.sendPacket(sm);
                        return;
                } */

                // Don't allow weapon/shield equipment if a cursed weapon is equiped
                if (activeChar.isCursedWeaponEquiped()
                    && ((bodyPart == L2Item.SLOT_LR_HAND
                        || bodyPart == L2Item.SLOT_L_HAND
                        || bodyPart == L2Item.SLOT_R_HAND)
                    || itemId == 6408)) // Don't allow to put formal wear
                {
                  return;
                }

                // Don't allow weapon/shield hero equipment during Olympiads
                if (activeChar.isInOlympiadMode()
                    && (
                        bodyPart == L2Item.SLOT_LR_HAND
                        || bodyPart == L2Item.SLOT_L_HAND
                        || bodyPart == L2Item.SLOT_R_HAND
                      )
                    && (
                        (item.getItemId() >= 6611 && item.getItemId() <= 6621) ||
                        item.getItemId() == 6842
                      )
                  )
                {
                  return;
                }

                // Don't allow weapon/shield hero equipment during Olympiads
                if (activeChar.isInOlympiadMode()
                    && (
                        bodyPart == L2Item.SLOT_LR_HAND
                        || bodyPart == L2Item.SLOT_L_HAND
                        || bodyPart == L2Item.SLOT_R_HAND
                      )
                    && (
                        (item.getItemId() >= 6611 && item.getItemId() <= 6621) ||
                        item.getItemId() == 6842
                      )
                  )
                {
                  return;
                }

                // Equip or unEquip
                L2ItemInstance[] items = null;
                boolean isEquiped = item.isEquipped();
              SystemMessage sm = null;
              L2ItemInstance old = activeChar.getInventory().getPaperdollItem(Inventory.PAPERDOLL_LRHAND);
              if (old == null)
                old = activeChar.getInventory().getPaperdollItem(Inventory.PAPERDOLL_RHAND);

              activeChar.checkSSMatch(item, old);

              if (isEquiped)
                {
                if (item.getEnchantLevel() > 0)
                {
                  sm = new SystemMessage(SystemMessageId.EQUIPMENT_S1_S2_REMOVED);
                  sm.addNumber(item.getEnchantLevel());
                  sm.addItemName(itemId);
                }
                else
                {
                  sm = new SystemMessage(SystemMessageId.S1_DISARMED);
                  sm.addItemName(itemId);
                }
                activeChar.sendPacket(sm);

                // Remove augementation boni on unequip
                if (item.isAugmented())
                  item.getAugmentation().removeBoni(activeChar);

                int slot = activeChar.getInventory().getSlotFromItem(item);
                  items = activeChar.getInventory().unEquipItemInBodySlotAndRecord(slot);
                }
                else
                {
                  int tempBodyPart = item.getItem().getBodyPart();
                  L2ItemInstance tempItem = activeChar.getInventory().getPaperdollItemByL2ItemId(tempBodyPart);

                  // remove augmentation stats for replaced items
                  // currently weapons only..
                  if (tempItem != null && tempItem.isAugmented())
                    tempItem.getAugmentation().removeBoni(activeChar);
                  else if (tempBodyPart == 0x4000)
                  {
                    L2ItemInstance tempItem2 = activeChar.getInventory().getPaperdollItem(7);
                    if (tempItem2 != null && tempItem2.isAugmented())
                      tempItem2.getAugmentation().removeBoni(activeChar);
                    tempItem2 = activeChar.getInventory().getPaperdollItem(8);
                      if (tempItem2 != null && tempItem2.isAugmented())
                        tempItem2.getAugmentation().removeBoni(activeChar);
                  }

                  //check if the item replaces a wear-item
                  if (tempItem != null && tempItem.isWear())
                  {
View Full Code Here

        boolean ss = false;
        boolean sps = false;
        boolean bss = false;

        L2ItemInstance weaponInst = activeChar.getActiveWeaponInstance();

        if (activeChar instanceof L2PcInstance)
        {
            if (weaponInst == null && skill.isOffensive())
            {
                SystemMessage sm2 = new SystemMessage(SystemMessageId.S1_S2);
                sm2.addString("You must equip a weapon before casting a spell.");
                activeChar.sendPacket(sm2);
                return;
            }
        }

        if (weaponInst != null)
        {
          if (skill.isMagic())
          {
              if (weaponInst.getChargedSpiritshot() == L2ItemInstance.CHARGED_BLESSED_SPIRITSHOT)
              {
                  bss = true;
                  if (skill.getId() != 1020) // vitalize
                    weaponInst.setChargedSpiritshot(L2ItemInstance.CHARGED_NONE);
              }
              else if (weaponInst.getChargedSpiritshot() == L2ItemInstance.CHARGED_SPIRITSHOT)
              {
                  sps = true;
                  if (skill.getId() != 1020) // vitalize
                    weaponInst.setChargedSpiritshot(L2ItemInstance.CHARGED_NONE);
              }
          }
            else
              if (weaponInst.getChargedSoulshot() == L2ItemInstance.CHARGED_SOULSHOT)
              {
                  ss = true;
                  if (skill.getId() != 1020) // vitalize
                    weaponInst.setChargedSoulshot(L2ItemInstance.CHARGED_NONE);
              }
        }
        // If there is no weapon equipped, check for an active summon.
        else if (activeChar instanceof L2Summon)
        {
View Full Code Here

                !activeChar.isDead())
        {
            if (Config.DEBUG)
                _log.fine("AutoSoulShot:" + _itemId);

            L2ItemInstance item = activeChar.getInventory().getItemByItemId(_itemId);

            if (item != null)
            {
                if (_type == 1)
                {
                  //Fishingshots are not automatic on retail
                  if (_itemId < 6535 || _itemId > 6540) {
                      // Attempt to charge first shot on activation
                      if (_itemId == 6645 || _itemId == 6646 || _itemId == 6647)
                      {
                          activeChar.addAutoSoulShot(_itemId);
                          ExAutoSoulShot atk = new ExAutoSoulShot(_itemId, _type);
                          activeChar.sendPacket(atk);

                          //start the auto soulshot use
                          SystemMessage sm = new SystemMessage(SystemMessageId.USE_OF_S1_WILL_BE_AUTO);
                          sm.addString(item.getItemName());
                          activeChar.sendPacket(sm);
                          sm = null;

                          activeChar.rechargeAutoSoulShot(true, true, true);
                      }
                      else {
                        if (activeChar.getActiveWeaponItem() != activeChar.getFistsWeaponItem()
                            && item.getItem().getCrystalType() == activeChar.getActiveWeaponItem().getCrystalType())
                        {
                          if (_itemId>=3947 && _itemId<=3952 && 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;
                          }else{
                            activeChar.addAutoSoulShot(_itemId);
                            ExAutoSoulShot atk = new ExAutoSoulShot(_itemId, _type);
                            activeChar.sendPacket(atk);

                            // start the auto soulshot use
                            SystemMessage sm = new SystemMessage(SystemMessageId.USE_OF_S1_WILL_BE_AUTO);
                            sm.addString(item.getItemName());
                            activeChar.sendPacket(sm);
                            sm = null;

                            activeChar.rechargeAutoSoulShot(true, true, false);
                          }
                        }
                        else {
                          if ((_itemId >= 2509 && _itemId <= 2514) || (_itemId >= 3947 && _itemId <= 3952) || _itemId == 5790)
                            activeChar.sendPacket(new SystemMessage(SystemMessageId.SPIRITSHOTS_GRADE_MISMATCH));
                          else
                            activeChar.sendPacket(new SystemMessage(SystemMessageId.SOULSHOTS_GRADE_MISMATCH));
                        }
                      }
                    }
                }
                else if (_type == 0)
                {
                    activeChar.removeAutoSoulShot(_itemId);
                    ExAutoSoulShot atk = new ExAutoSoulShot(_itemId, _type);
                    activeChar.sendPacket(atk);

                    //cancel the auto soulshot use
                    SystemMessage sm = new SystemMessage(SystemMessageId.AUTO_USE_OF_S1_CANCELLED);
                    sm.addString(item.getItemName());
                    activeChar.sendPacket(sm);
                    sm = null;
                }
            }
        }
View Full Code Here

        } else {
          L2TradeList tradeList = new L2TradeList(0);
          FastList<SeedProduction> seeds = getCastle().getSeedProduction(CastleManorManager.PERIOD_CURRENT);

          for (SeedProduction s : seeds) {
            L2ItemInstance item = ItemTable.getInstance().createDummyItem(s.getId());
            item.setPriceToSell(s.getPrice());
            item.setCount(s.getCanProduce());
            if ((item.getCount() > 0) && (item.getPriceToSell() > 0))
              tradeList.addItem(item);
          }

          BuyListSeed bl = new BuyListSeed(tradeList, castleId, player.getAdena());
          player.sendPacket(bl);
View Full Code Here

            ResultSet result;
            int count=0;
            result = s.executeQuery("select object_id,item_id,count,enchant_level,x,y,z,drop_time,equipable from itemsonground");
            while (result.next())
            {
                L2ItemInstance item = new L2ItemInstance(result.getInt(1), result.getInt(2));
                L2World.getInstance().storeObject(item);
                if (item.isStackable() && result.getInt(3) > 1) //this check and..
                  item.setCount(result.getInt(3));
                if (result.getInt(4) > 0)      // this, are really necessary?
                  item.setEnchantLevel(result.getInt(4));
                item.getPosition().setWorldPosition(result.getInt(5), result.getInt(6) ,result.getInt(7));
                item.getPosition().setWorldRegion(L2World.getInstance().getRegion(item.getPosition().getWorldPosition()));
                item.getPosition().getWorldRegion().addVisibleObject(item);
                item.setDropTime(result.getLong(8));
                if (result.getLong(8) == -1)
                  item.setProtected(true);
                else
                  item.setProtected(false);
                item.setIsVisible(true);
                L2World.getInstance().addVisibleObject(item, item.getPosition().getWorldRegion(), null);
                _items.add(item);
                count++;
                // add to ItemsAutoDestroy only items not protected
                if (!Config.LIST_PROTECTED_ITEMS.contains(item.getItemId())){
                  if(result.getLong(8) > -1)
                  {
                    if((Config.AUTODESTROY_ITEM_AFTER > 0 && item.getItemType() != L2EtcItemType.HERB)
                       ||(Config.HERB_AUTO_DESTROY_TIME > 0 && item.getItemType() == L2EtcItemType.HERB))
                      ItemsAutoDestroy.getInstance().addItem(item);
                  }
                }
            }
            result.close();
View Full Code Here

  public synchronized void useItem(L2PlayableInstance playable, L2ItemInstance item)
  {
        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));

                SystemMessage sm = new SystemMessage(SystemMessageId.AUTO_USE_OF_S1_CANCELLED);
                sm.addString(item.getItem().getName());
                activeChar.sendPacket(sm);
            }
            else activeChar.sendPacket(new SystemMessage(SystemMessageId.NOT_ENOUGH_SPIRITSHOTS));
            return;
        }

        // Charge Blessed Spiritshot
        weaponInst.setChargedSpiritshot(L2ItemInstance.CHARGED_BLESSED_SPIRITSHOT);

        // Send message to client
        activeChar.sendPacket(new SystemMessage(SystemMessageId.ENABLED_SPIRITSHOT));
        Broadcast.toSelfAndKnownPlayersInRadius(activeChar, new MagicSkillUser(activeChar, activeChar, SKILL_IDS[weaponGrade], 1, 0, 0), 360000/*600*/);
  }
 
View Full Code Here

TOP

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

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.