Package net.sf.l2j.gameserver.model.actor.instance

Examples of net.sf.l2j.gameserver.model.actor.instance.L2PcInstance$JailTask


        boolean doLevelup = true;
        boolean isBossMob = maxAbsorbLevel > 10 ? true : false;

        L2NpcTemplate.AbsorbCrystalType absorbType = getTemplate().absorbType;

        L2PcInstance killer = (attacker instanceof L2Summon)? ((L2Summon)attacker).getOwner() : (L2PcInstance)attacker;

        // If this mob is a boss, then skip some checking
        if (!isBossMob)
        {
            // Fail if this L2Attackable isn't absorbed or there's no one in its _absorbersList
            if (!isAbsorbed() /*|| _absorbersList == null*/)
            {
                resetAbsorbList();
                return;
            }

            // Fail if the killer isn't in the _absorbersList of this L2Attackable and mob is not boss
            AbsorberInfo ai = _absorbersList.get(killer);
            if (ai == null || ai._absorber.getObjectId() != killer.getObjectId())
                isSuccess = false;

            // Check if the soul crystal was used when HP of this L2Attackable wasn't higher than half of it
            if (ai != null && ai._absorbedHP > (getMaxHp()/2.0))
                isSuccess = false;

            if (!isSuccess) {
                resetAbsorbList();
                return;
            }
        }

        // ********
        String[] crystalNFO = null;
        String   crystalNME = "";

        int dice = Rnd.get(100);
        int crystalQTY = 0;
        int crystalLVL = 0;
        int crystalOLD = 0;
        int crystalNEW = 0;

        // ********
        // Now we have four choices:
        // 1- The Monster level is too low for the crystal. Nothing happens.
        // 2- Everything is correct, but it failed. Nothing happens. (57.5%)
        // 3- Everything is correct, but it failed. The crystal scatters. A sound event is played. (10%)
        // 4- Everything is correct, the crystal level up. A sound event is played. (32.5%)

        List<L2PcInstance> players = new FastList<L2PcInstance>();

        if (absorbType == L2NpcTemplate.AbsorbCrystalType.FULL_PARTY && killer.isInParty())
            players = killer.getParty().getPartyMembers();
        else if (absorbType == L2NpcTemplate.AbsorbCrystalType.PARTY_ONE_RANDOM && killer.isInParty())
        {
          // This is a naive method for selecting a random member.  It gets any random party member and
          // then checks if the member has a valid crystal.  It does not select the random party member
          // among those who have crystals, only.  However, this might actually be correct (same as retail).
            players.add(killer.getParty().getPartyMembers().get(Rnd.get(killer.getParty().getMemberCount())));
        }
        else
            players.add(killer);

        for (L2PcInstance player : players)
View Full Code Here


   }

   String getMaxLeveledPlayer(){
       Iterator<String> it = L2Event.participatingPlayers.iterator();
       L2PcInstance pc = null;
       int max = 0;
       String name = "";
       while(it.hasNext()){
           try{tempName2 =it.next().toString();
           pc = L2World.getInstance().getPlayer(tempName2);
           if( max < pc.getLevel() ) {
               max = pc.getLevel();
               name = pc.getName();
           }}catch(Exception e){try{L2Event.participatingPlayers.remove(tempName2);} catch(Exception e2){}}
       }
       L2Event.participatingPlayers.remove(name);
       return name;
View Full Code Here

   }
   void teleportTeam(L2PcInstance activeChar, int team){
       LinkedList<String> linked = L2Event.players.get(team);
       Iterator<String> it = linked.iterator();
       while(it.hasNext()){
           try{L2PcInstance pc = L2World.getInstance().getPlayer(it.next().toString());
           pc.setTitle(L2Event.names.get(team));
           pc.teleToLocation(activeChar.getX(), activeChar.getY(), activeChar.getZ(), true);}catch(Exception e){}
       }

   }
View Full Code Here

        for(int index = 0;index < targets.length;index++)
        {
          if (!(targets[index] instanceof L2PcInstance))
            continue;
      L2PcInstance target = (L2PcInstance)targets[index];
          skill.getEffects(activeChar, target);
    }
        // self Effect :]
        L2Effect effect = activeChar.getFirstEffect(skill.getId());
        if (effect != null && effect.isSelfEffect())
View Full Code Here

   }
   void sitTeam(int team){
       LinkedList<String> linked = L2Event.players.get(team);
       Iterator<String> it = linked.iterator();
       while(it.hasNext()){
           try{L2PcInstance pc = L2World.getInstance().getPlayer(it.next().toString());
           pc.eventSitForced = !pc.eventSitForced;
           if(pc.eventSitForced) pc.sitDown();
           else pc.standUp();}catch(Exception e){}
       }

   }
View Full Code Here

   }
   void killTeam(L2PcInstance activeChar, int team){
       LinkedList<String> linked = L2Event.players.get(team);
       Iterator<String> it = linked.iterator();
       while(it.hasNext()){
           try{L2PcInstance target = L2World.getInstance().getPlayer(it.next().toString());
           target.reduceCurrentHp(target.getMaxHp() + target.getMaxCp() + 1, activeChar);}catch(Exception e){}
       }

   }
View Full Code Here

   }
   void resTeam(int team){
       LinkedList<String> linked = L2Event.players.get(team);
       Iterator<String> it = linked.iterator();
       while(it.hasNext()){
           try{L2PcInstance character = L2World.getInstance().getPlayer(it.next().toString());
           character.setCurrentHpMp(character.getMaxHp(), character.getMaxMp());
           character.setCurrentCp(character.getMaxCp());
           Revive revive = new Revive(character);
           SocialAction sa = new SocialAction(character.getObjectId(), 15);
           character.broadcastPacket(sa);
           character.sendPacket(sa);
           character.sendPacket(revive);
           character.broadcastPacket(revive);}catch(Exception e){}
       }

   }
View Full Code Here

   void polyTeam(int team, String id){
       LinkedList<String> linked = L2Event.players.get(team);
       Iterator<String> it = linked.iterator();
       while(it.hasNext()){
        try{   L2PcInstance target = L2World.getInstance().getPlayer(it.next().toString());
        target.getPoly().setPolyInfo("npc", id);
        target.teleToLocation(target.getX(), target.getY(), target.getZ(), true);
        CharInfo info1 = new CharInfo(target);
        target.broadcastPacket(info1);
            UserInfo info2 = new UserInfo(target);
            target.sendPacket(info2);}catch(Exception e){}
       }

   }
View Full Code Here

  @Override
  protected void runImpl()
  {

    L2PcInstance activeChar = getClient().getActiveChar();

    if (activeChar == null)
            return;

    // Flood protect UseItem
    if (!FloodProtector.getInstance().tryPerformAction(activeChar.getObjectId(), FloodProtector.PROTECTED_USEITEM))
      return;

    if (activeChar.getPrivateStoreType() != 0)
    {
      activeChar.sendPacket(new SystemMessage(SystemMessageId.CANNOT_TRADE_DISCARD_DROP_ITEM_WHILE_IN_SHOPMODE));
      activeChar.sendPacket(new ActionFailed());
      return;
    }

    // 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())
                  {
                    // dont allow an item to replace a wear-item
                    return;
                  }
                  else if (tempBodyPart == 0x4000) // left+right hand equipment
                  {
                    // this may not remove left OR right hand equipment
                    tempItem = activeChar.getInventory().getPaperdollItem(7);
                    if (tempItem != null && tempItem.isWear()) return;

                    tempItem = activeChar.getInventory().getPaperdollItem(8);
                    if (tempItem != null && tempItem.isWear()) return;
                  }
                  else if (tempBodyPart == 0x8000) // fullbody armor
                  {
                    // this may not remove chest or leggins
                    tempItem = activeChar.getInventory().getPaperdollItem(10);
                    if (tempItem != null && tempItem.isWear()) return;

                    tempItem = activeChar.getInventory().getPaperdollItem(11);
                    if (tempItem != null && tempItem.isWear()) return;
                  }

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

                // Apply augementation boni on equip
                if (item.isAugmented())
                  item.getAugmentation().applyBoni(activeChar);

          items = activeChar.getInventory().equipItemAndRecord(item);

                // Consume mana - will start a task if required; returns if item is not a shadow item
                item.decreaseMana(false);
                }
                sm = null;

                activeChar.refreshExpertisePenalty();

        if (item.getItem().getType2() == L2Item.TYPE2_WEAPON)
          activeChar.checkIfWeaponIsAllowed();

        InventoryUpdate iu = new InventoryUpdate();
        iu.addItems(Arrays.asList(items));
        activeChar.sendPacket(iu);
        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
                    ItemList il = new ItemList(activeChar, false);
                    sendPacket(il);
                    return;
                }
View Full Code Here

   }
   void unpolyTeam(int team){
       LinkedList<String> linked = L2Event.players.get(team);
       Iterator<String> it = linked.iterator();
       while(it.hasNext()){
          try{ L2PcInstance target = L2World.getInstance().getPlayer(it.next().toString());

           target.getPoly().setPolyInfo(null, "1");
        target.decayMe();
        target.spawnMe(target.getX(),target.getY(),target.getZ());
        CharInfo info1 = new CharInfo(target);
        target.broadcastPacket(info1);
            UserInfo info2 = new UserInfo(target);
            target.sendPacket(info2);}catch(Exception e){}
       }

   }
View Full Code Here

TOP

Related Classes of net.sf.l2j.gameserver.model.actor.instance.L2PcInstance$JailTask

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.