Ejemplo n.º 1
0
  /**
   * Restore player conditions
   *
   * @param abnormalDuelEnd true if the duel was the duel canceled
   */
  public void restorePlayerConditions(boolean abnormalDuelEnd) {
    // update isInDuel() state for all players
    if (_partyDuel) {
      for (L2PcInstance temp : _playerA.getParty().getMembers()) {
        temp.setIsInDuel(0);
        temp.setTeam(Team.NONE);
        temp.broadcastUserInfo();
      }
      for (L2PcInstance temp : _playerB.getParty().getMembers()) {
        temp.setIsInDuel(0);
        temp.setTeam(Team.NONE);
        temp.broadcastUserInfo();
      }
    } else {
      _playerA.setIsInDuel(0);
      _playerA.setTeam(Team.NONE);
      _playerA.broadcastUserInfo();
      _playerB.setIsInDuel(0);
      _playerB.setTeam(Team.NONE);
      _playerB.broadcastUserInfo();
    }

    // if it is an abnormal DuelEnd do not restore hp, mp, cp
    if (abnormalDuelEnd) {
      return;
    }

    // restore player conditions
    _playerConditions.values().forEach(c -> c.restoreCondition());
  }
Ejemplo n.º 2
0
  /**
   * Claims the hero status for the given player.
   *
   * @param player the player to become hero
   */
  public void claimHero(L2PcInstance player) {
    _heroes.get(player.getObjectId()).set(CLAIMED, true);

    final L2Clan clan = player.getClan();
    if ((clan != null) && (clan.getLevel() >= 5)) {
      clan.addReputationScore(Config.HERO_POINTS, true);
      final SystemMessage sm =
          SystemMessage.getSystemMessage(
              SystemMessageId.CLAN_MEMBER_C1_BECAME_HERO_AND_GAINED_S2_REPUTATION_POINTS);
      sm.addString(CharNameTable.getInstance().getNameById(player.getObjectId()));
      sm.addInt(Config.HERO_POINTS);
      clan.broadcastToOnlineMembers(sm);
    }

    player.setHero(true);
    player.broadcastPacket(new SocialAction(player.getObjectId(), 20016)); // Hero Animation
    player.sendPacket(new UserInfo(player));
    player.sendPacket(new ExBrExtraUserInfo(player));
    player.broadcastUserInfo();
    // Set Gained hero and reload data
    setHeroGained(player.getObjectId());
    loadFights(player.getObjectId());
    loadDiary(player.getObjectId());
    _heroMessage.put(player.getObjectId(), "");

    updateHeroes(false);
  }
  @Override
  public String onAdvEvent(String event, L2Npc npc, L2PcInstance player) {
    QuestState st = getQuestState(player, false);
    if (st == null) {
      return getNoQuestMsg(player);
    }

    if (Util.isDigit(event)) {
      int i = Integer.valueOf(event);
      final ClassId cid = player.getClassId();
      if ((cid.getRace() == Race.DARK_ELF) && (cid.getId() == CLASSES[i][1])) {
        int suffix;
        final boolean item = st.hasQuestItems(CLASSES[i][6]);
        if (player.getLevel() < 20) {
          suffix = (!item) ? CLASSES[i][2] : CLASSES[i][3];
        } else {
          if (!item) {
            suffix = CLASSES[i][4];
          } else {
            suffix = CLASSES[i][5];
            st.giveItems(SHADOW_WEAPON_COUPON_DGRADE, 15);
            st.takeItems(CLASSES[i][6], -1);
            player.setClassId(CLASSES[i][0]);
            player.setBaseClass(CLASSES[i][0]);
            st.playSound(QuestSound.ITEMSOUND_QUEST_FANFARE_2);
            player.broadcastUserInfo();
            st.exitQuest(false);
          }
        }
        event = npc.getId() + "-" + suffix + ".html";
      }
    }
    return event;
  }
Ejemplo n.º 4
0
  public void deleteRoom(int id) {
    for (L2PcInstance _member : getRoom(id).getPartyMembers()) {
      if (_member == null) {
        continue;
      }

      _member.sendPacket(new ExClosePartyRoom());
      _member.sendPacket(SystemMessageId.PARTY_ROOM_DISBANDED);

      _member.setPartyRoom(0);
      // _member.setPartyMatching(0);
      _member.broadcastUserInfo();
    }
    _rooms.remove(id);
  }
  @Override
  protected void runImpl() {
    final L2PcInstance activeChar = getClient().getActiveChar();
    if (activeChar == null) return;

    if (_colorNum < 0 || _colorNum >= COLORS.length) return;

    final L2ItemInstance item = activeChar.getInventory().getItemByObjectId(_itemObjectId);
    if (item == null
        || item.getEtcItem() == null
        || item.getEtcItem().getHandlerName() == null
        || !item.getEtcItem().getHandlerName().equalsIgnoreCase("NicknameColor")) return;

    if (activeChar.destroyItem("Consume", item, 1, null, true)) {
      activeChar.setTitle(_title);
      activeChar.getAppearance().setTitleColor(COLORS[_colorNum]);
      activeChar.broadcastUserInfo();
    }
  }
  @Override
  protected void runImpl() {
    L2PcInstance _activeChar = getClient().getActiveChar();

    if (_activeChar == null) return;

    if (!_activeChar.isInPartyMatchRoom()
        && _activeChar.getParty() != null
        && _activeChar.getParty().getLeader() != _activeChar) {
      _activeChar.sendPacket(new SystemMessage(SystemMessageId.CANT_VIEW_PARTY_ROOMS));
      _activeChar.sendPacket(ActionFailed.STATIC_PACKET);
      return;
    }

    if (_activeChar.isInPartyMatchRoom()) {
      // If Player is in Room show him room, not list
      PartyMatchRoomList _list = PartyMatchRoomList.getInstance();
      if (_list == null) return;

      PartyMatchRoom _room = _list.getPlayerRoom(_activeChar);
      if (_room == null) return;

      _activeChar.sendPacket(new PartyMatchDetail(_activeChar, _room));
      _activeChar.sendPacket(new ExPartyRoomMember(_activeChar, _room, 2));

      _activeChar.setPartyRoom(_room.getId());
      // _activeChar.setPartyMatching(1);
      _activeChar.broadcastUserInfo();
    } else {
      // Add to waiting list
      PartyMatchWaitingList.getInstance().addPlayer(_activeChar);

      // Send Room list
      ListPartyWating matchList = new ListPartyWating(_activeChar, _auto, _loc, _lvl);

      _activeChar.sendPacket(matchList);
    }
  }
Ejemplo n.º 7
0
  @Override
  protected void runImpl() {
    final L2PcInstance activeChar = getActiveChar();
    if (activeChar == null) {
      return;
    }

    if (Config.DEBUG) {
      _log.info(
          getType()
              + ": "
              + activeChar
              + " requested action use ID: "
              + _actionId
              + " Ctrl pressed:"
              + _ctrlPressed
              + " Shift pressed:"
              + _shiftPressed);
    }

    // Don't do anything if player is dead or confused
    if ((activeChar.isFakeDeath() && (_actionId != 0))
        || activeChar.isDead()
        || activeChar.isOutOfControl()) {
      sendPacket(ActionFailed.STATIC_PACKET);
      return;
    }

    final BuffInfo info =
        activeChar.getEffectList().getBuffInfoByAbnormalType(AbnormalType.BOT_PENALTY);
    if (info != null) {
      for (AbstractEffect effect : info.getEffects()) {
        if (!effect.checkCondition(_actionId)) {
          activeChar.sendPacket(
              SystemMessageId
                  .YOU_HAVE_BEEN_REPORTED_AS_AN_ILLEGAL_PROGRAM_USER_SO_YOUR_ACTIONS_HAVE_BEEN_RESTRICTED);
          activeChar.sendPacket(ActionFailed.STATIC_PACKET);
          return;
        }
      }
    }

    // Don't allow to do some action if player is transformed
    if (activeChar.isTransformed()) {
      int[] allowedActions =
          activeChar.isTransformed()
              ? ExBasicActionList.ACTIONS_ON_TRANSFORM
              : ExBasicActionList.DEFAULT_ACTION_LIST;
      if (!(Arrays.binarySearch(allowedActions, _actionId) >= 0)) {
        sendPacket(ActionFailed.STATIC_PACKET);
        _log.warning(
            "Player "
                + activeChar
                + " used action which he does not have! Id = "
                + _actionId
                + " transform: "
                + activeChar.getTransformation());
        return;
      }
    }

    final L2Summon pet = activeChar.getPet();
    final L2Summon servitor = activeChar.getAnyServitor();
    final L2Object target = activeChar.getTarget();
    switch (_actionId) {
      case 0: // Sit/Stand
        if (activeChar.isSitting() || !activeChar.isMoving() || activeChar.isFakeDeath()) {
          useSit(activeChar, target);
        } else {
          // Sit when arrive using next action.
          // Creating next action class.
          final NextAction nextAction =
              new NextAction(
                  CtrlEvent.EVT_ARRIVED,
                  CtrlIntention.AI_INTENTION_MOVE_TO,
                  () -> useSit(activeChar, target));

          // Binding next action to AI.
          activeChar.getAI().setNextAction(nextAction);
        }
        break;
      case 1: // Walk/Run
        if (activeChar.isRunning()) {
          activeChar.setWalking();
        } else {
          activeChar.setRunning();
        }
        break;
      case 10: // Private Store - Sell
        activeChar.tryOpenPrivateSellStore(false);
        break;
      case 15: // Change Movement Mode (Pets)
        if (validateSummon(pet, true)) {
          ((L2SummonAI) pet.getAI()).notifyFollowStatusChange();
        }
        break;
      case 16: // Attack (Pets)
        if (validateSummon(pet, true)) {
          if (pet.canAttack(_ctrlPressed)) {
            pet.doAttack();
          }
        }
        break;
      case 17: // Stop (Pets)
        if (validateSummon(pet, true)) {
          pet.cancelAction();
        }
        break;
      case 19: // Unsummon Pet
        if (!validateSummon(pet, true)) {
          break;
        }

        if (pet.isDead()) {
          sendPacket(SystemMessageId.DEAD_PETS_CANNOT_BE_RETURNED_TO_THEIR_SUMMONING_ITEM);
          break;
        }

        if (pet.isAttackingNow() || pet.isInCombat() || pet.isMovementDisabled()) {
          sendPacket(SystemMessageId.A_PET_CANNOT_BE_UNSUMMONED_DURING_BATTLE);
          break;
        }

        if (pet.isHungry()) {
          if (!((L2PetInstance) pet).getPetData().getFood().isEmpty()) {
            sendPacket(SystemMessageId.YOU_MAY_NOT_RESTORE_A_HUNGRY_PET);
          } else {
            sendPacket(
                SystemMessageId
                    .THE_MINION_PET_CANNOT_BE_RETURNED_BECAUSE_THERE_IS_NOT_MUCH_TIME_REMAINING_UNTIL_IT_LEAVES);
          }
          break;
        }

        pet.unSummon(activeChar);
        break;
      case 21: // Change Movement Mode (Servitors)
        if (validateSummon(servitor, false)) {
          ((L2SummonAI) servitor.getAI()).notifyFollowStatusChange();
        }
        break;
      case 22: // Attack (Servitors)
        if (validateSummon(servitor, false)) {
          if (servitor.canAttack(_ctrlPressed)) {
            servitor.doAttack();
          }
        }
        break;
      case 23: // Stop (Servitors)
        if (validateSummon(servitor, false)) {
          servitor.cancelAction();
        }
        break;
      case 28: // Private Store - Buy
        activeChar.tryOpenPrivateBuyStore();
        break;
      case 32: // Wild Hog Cannon - Wild Cannon
        useSkill("DDMagic", false);
        break;
      case 36: // Soulless - Toxic Smoke
        useSkill("RangeDebuff", false);
        break;
      case 37: // Dwarven Manufacture
        if (activeChar.isAlikeDead()) {
          sendPacket(ActionFailed.STATIC_PACKET);
          return;
        }
        if (activeChar.getPrivateStoreType() != PrivateStoreType.NONE) {
          activeChar.setPrivateStoreType(PrivateStoreType.NONE);
          activeChar.broadcastUserInfo();
        }
        if (activeChar.isSitting()) {
          activeChar.standUp();
        }

        sendPacket(new RecipeShopManageList(activeChar, true));
        break;
      case 38: // Mount/Dismount
        activeChar.mountPlayer(pet);
        break;
      case 39: // Soulless - Parasite Burst
        useSkill("RangeDD", false);
        break;
      case 41: // Wild Hog Cannon - Attack
        if (validateSummon(servitor, false)) {
          if ((target != null) && (target.isDoor() || (target instanceof L2SiegeFlagInstance))) {
            useSkill(4230, false);
          } else {
            sendPacket(SystemMessageId.INVALID_TARGET);
          }
        }
        break;
      case 42: // Kai the Cat - Self Damage Shield
        useSkill("HealMagic", false);
        break;
      case 43: // Merrow the Unicorn - Hydro Screw
        useSkill("DDMagic", false);
        break;
      case 44: // Big Boom - Boom Attack
        useSkill("DDMagic", false);
        break;
      case 45: // Boxer the Unicorn - Master Recharge
        useSkill("HealMagic", activeChar, false);
        break;
      case 46: // Mew the Cat - Mega Storm Strike
        useSkill("DDMagic", false);
        break;
      case 47: // Silhouette - Steal Blood
        useSkill("DDMagic", false);
        break;
      case 48: // Mechanic Golem - Mech. Cannon
        useSkill("DDMagic", false);
        break;
      case 51: // General Manufacture
        // Player shouldn't be able to set stores if he/she is alike dead (dead or fake death)
        if (activeChar.isAlikeDead()) {
          sendPacket(ActionFailed.STATIC_PACKET);
          return;
        }
        if (activeChar.getPrivateStoreType() != PrivateStoreType.NONE) {
          activeChar.setPrivateStoreType(PrivateStoreType.NONE);
          activeChar.broadcastUserInfo();
        }
        if (activeChar.isSitting()) {
          activeChar.standUp();
        }

        sendPacket(new RecipeShopManageList(activeChar, false));
        break;
      case 52: // Unsummon Servitor
        if (validateSummon(servitor, false)) {
          if (servitor.isAttackingNow() || servitor.isInCombat()) {
            sendPacket(SystemMessageId.A_SERVITOR_WHOM_IS_ENGAGED_IN_BATTLE_CANNOT_BE_DE_ACTIVATED);
            break;
          }
          servitor.unSummon(activeChar);
        }
        break;
      case 53: // Move to target (Servitors)
        if (validateSummon(servitor, false)) {
          if ((target != null) && (servitor != target) && !servitor.isMovementDisabled()) {
            servitor.setFollowStatus(false);
            servitor.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, target.getLocation());
          }
        }
        break;
      case 54: // Move to target (Pets)
        if (validateSummon(pet, true)) {
          if ((target != null) && (pet != target) && !pet.isMovementDisabled()) {
            pet.setFollowStatus(false);
            pet.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, target.getLocation());
          }
        }
        break;
      case 61: // Private Store Package Sell
        activeChar.tryOpenPrivateSellStore(true);
        break;
      case 65: // Bot Report Button
        if (Config.BOTREPORT_ENABLE) {
          BotReportTable.getInstance().reportBot(activeChar);
        } else {
          activeChar.sendMessage("This feature is disabled.");
        }
        break;
      case 67: // Steer
        if (activeChar.isInAirShip()) {
          if (activeChar.getAirShip().setCaptain(activeChar)) {
            activeChar.broadcastUserInfo();
          }
        }
        break;
      case 68: // Cancel Control
        if (activeChar.isInAirShip() && activeChar.getAirShip().isCaptain(activeChar)) {
          if (activeChar.getAirShip().setCaptain(null)) {
            activeChar.broadcastUserInfo();
          }
        }
        break;
      case 69: // Destination Map
        AirShipManager.getInstance().sendAirShipTeleportList(activeChar);
        break;
      case 70: // Exit Airship
        if (activeChar.isInAirShip()) {
          if (activeChar.getAirShip().isCaptain(activeChar)) {
            if (activeChar.getAirShip().setCaptain(null)) {
              activeChar.broadcastUserInfo();
            }
          } else if (activeChar.getAirShip().isInDock()) {
            activeChar.getAirShip().oustPlayer(activeChar);
          }
        }
        break;
      case 71:
      case 72:
      case 73:
        useCoupleSocial(_actionId - 55);
        break;
      case 78:
      case 79:
      case 80:
      case 81:
        if ((activeChar.getParty() != null)
            && (activeChar.getTarget() != null)
            && (activeChar.getTarget().isCharacter())) {
          activeChar
              .getParty()
              .addTacticalSign(_actionId - 77, (L2Character) activeChar.getTarget());
        } else {
          sendPacket(ActionFailed.STATIC_PACKET);
        }
        break;
      case 82:
      case 83:
      case 84:
      case 85:
        if (activeChar.getParty() != null) {
          activeChar.getParty().setTargetBasedOnTacticalSignId(activeChar, _actionId - 81);
        } else {
          sendPacket(ActionFailed.STATIC_PACKET);
        }
        break;
      case 90: // /instancedzone action since Lindvior
        activeChar.sendPacket(new ExInzoneWaiting(activeChar));
        break;
      case 1000: // Siege Golem - Siege Hammer
        if ((target != null) && target.isDoor()) {
          useSkill(4079, false);
        }
        break;
      case 1001: // Sin Eater - Ultimate Bombastic Buster
        if (validateSummon(pet, true) && (pet.getId() == SIN_EATER_ID)) {
          pet.broadcastPacket(
              new NpcSay(
                  pet.getObjectId(),
                  ChatType.NPC_GENERAL,
                  pet.getId(),
                  NPC_STRINGS[Rnd.get(NPC_STRINGS.length)]));
        }
        break;
      case 1003: // Wind Hatchling/Strider - Wild Stun
        useSkill("PhysicalSpecial", true);
        break;
      case 1004: // Wind Hatchling/Strider - Wild Defense
        useSkill("Buff", activeChar, true);
        break;
      case 1005: // Star Hatchling/Strider - Bright Burst
        useSkill("DDMagic", true);
        break;
      case 1006: // Star Hatchling/Strider - Bright Heal
        useSkill("Heal", activeChar, true);
        break;
      case 1007: // Feline Queen - Blessing of Queen
        useSkill("Buff1", activeChar, false);
        break;
      case 1008: // Feline Queen - Gift of Queen
        useSkill("Buff2", activeChar, false);
        break;
      case 1009: // Feline Queen - Cure of Queen
        useSkill("DDMagic", false);
        break;
      case 1010: // Unicorn Seraphim - Blessing of Seraphim
        useSkill("Buff1", activeChar, false);
        break;
      case 1011: // Unicorn Seraphim - Gift of Seraphim
        useSkill("Buff2", activeChar, false);
        break;
      case 1012: // Unicorn Seraphim - Cure of Seraphim
        useSkill("DDMagic", false);
        break;
      case 1013: // Nightshade - Curse of Shade
        useSkill("DeBuff1", false);
        break;
      case 1014: // Nightshade - Mass Curse of Shade
        useSkill("DeBuff2", false);
        break;
      case 1015: // Nightshade - Shade Sacrifice
        useSkill("Heal", false);
        break;
      case 1016: // Cursed Man - Cursed Blow
        useSkill("PhysicalSpecial1", false);
        break;
      case 1017: // Cursed Man - Cursed Strike
        useSkill("PhysicalSpecial2", false);
        break;
      case 1031: // Feline King - Slash
        useSkill("PhysicalSpecial1", false);
        break;
      case 1032: // Feline King - Spinning Slash
        useSkill("PhysicalSpecial2", false);
        break;
      case 1033: // Feline King - Hold of King
        useSkill("PhysicalSpecial3", false);
        break;
      case 1034: // Magnus the Unicorn - Whiplash
        useSkill("PhysicalSpecial1", false);
        break;
      case 1035: // Magnus the Unicorn - Tridal Wave
        useSkill("PhysicalSpecial2", false);
        break;
      case 1036: // Spectral Lord - Corpse Kaboom
        useSkill("PhysicalSpecial1", false);
        break;
      case 1037: // Spectral Lord - Dicing Death
        useSkill("PhysicalSpecial2", false);
        break;
      case 1038: // Spectral Lord - Dark Curse
        useSkill("PhysicalSpecial3", false);
        break;
      case 1039: // Swoop Cannon - Cannon Fodder
        useSkill(5110, false);
        break;
      case 1040: // Swoop Cannon - Big Bang
        useSkill(5111, false);
        break;
      case 1041: // Great Wolf - Bite Attack
        useSkill("Skill01", true);
        break;
      case 1042: // Great Wolf - Maul
        useSkill("Skill03", true);
        break;
      case 1043: // Great Wolf - Cry of the Wolf
        useSkill("Skill02", true);
        break;
      case 1044: // Great Wolf - Awakening
        useSkill("Skill04", true);
        break;
      case 1045: // Great Wolf - Howl
        useSkill(5584, true);
        break;
      case 1046: // Strider - Roar
        useSkill(5585, true);
        break;
      case 1047: // Divine Beast - Bite
        useSkill(5580, false);
        break;
      case 1048: // Divine Beast - Stun Attack
        useSkill(5581, false);
        break;
      case 1049: // Divine Beast - Fire Breath
        useSkill(5582, false);
        break;
      case 1050: // Divine Beast - Roar
        useSkill(5583, false);
        break;
      case 1051: // Feline Queen - Bless The Body
        useSkill("buff3", false);
        break;
      case 1052: // Feline Queen - Bless The Soul
        useSkill("buff4", false);
        break;
      case 1053: // Feline Queen - Haste
        useSkill("buff5", false);
        break;
      case 1054: // Unicorn Seraphim - Acumen
        useSkill("buff3", false);
        break;
      case 1055: // Unicorn Seraphim - Clarity
        useSkill("buff4", false);
        break;
      case 1056: // Unicorn Seraphim - Empower
        useSkill("buff5", false);
        break;
      case 1057: // Unicorn Seraphim - Wild Magic
        useSkill("buff6", false);
        break;
      case 1058: // Nightshade - Death Whisper
        useSkill("buff3", false);
        break;
      case 1059: // Nightshade - Focus
        useSkill("buff4", false);
        break;
      case 1060: // Nightshade - Guidance
        useSkill("buff5", false);
        break;
      case 1061: // Wild Beast Fighter, White Weasel - Death blow
        useSkill(5745, true);
        break;
      case 1062: // Wild Beast Fighter - Double attack
        useSkill(5746, true);
        break;
      case 1063: // Wild Beast Fighter - Spin attack
        useSkill(5747, true);
        break;
      case 1064: // Wild Beast Fighter - Meteor Shower
        useSkill(5748, true);
        break;
      case 1065: // Fox Shaman, Wild Beast Fighter, White Weasel, Fairy Princess - Awakening
        useSkill(5753, true);
        break;
      case 1066: // Fox Shaman, Spirit Shaman - Thunder Bolt
        useSkill(5749, true);
        break;
      case 1067: // Fox Shaman, Spirit Shaman - Flash
        useSkill(5750, true);
        break;
      case 1068: // Fox Shaman, Spirit Shaman - Lightning Wave
        useSkill(5751, true);
        break;
      case 1069: // Fox Shaman, Fairy Princess - Flare
        useSkill(5752, true);
        break;
      case 1070: // White Weasel, Fairy Princess, Improved Baby Buffalo, Improved Baby Kookaburra,
        // Improved Baby Cougar, Spirit Shaman, Toy Knight, Turtle Ascetic - Buff control
        useSkill(5771, true);
        break;
      case 1071: // Tigress - Power Strike
        useSkill("DDMagic", true);
        break;
      case 1072: // Toy Knight - Piercing attack
        useSkill(6046, true);
        break;
      case 1073: // Toy Knight - Whirlwind
        useSkill(6047, true);
        break;
      case 1074: // Toy Knight - Lance Smash
        useSkill(6048, true);
        break;
      case 1075: // Toy Knight - Battle Cry
        useSkill(6049, true);
        break;
      case 1076: // Turtle Ascetic - Power Smash
        useSkill(6050, true);
        break;
      case 1077: // Turtle Ascetic - Energy Burst
        useSkill(6051, true);
        break;
      case 1078: // Turtle Ascetic - Shockwave
        useSkill(6052, true);
        break;
      case 1079: // Turtle Ascetic - Howl
        useSkill(6053, true);
        break;
      case 1080: // Phoenix Rush
        useSkill(6041, false);
        break;
      case 1081: // Phoenix Cleanse
        useSkill(6042, false);
        break;
      case 1082: // Phoenix Flame Feather
        useSkill(6043, false);
        break;
      case 1083: // Phoenix Flame Beak
        useSkill(6044, false);
        break;
      case 1084: // Switch State
        if (pet instanceof L2BabyPetInstance) {
          useSkill(SWITCH_STANCE_ID, true);
        }
        break;
      case 1086: // Panther Cancel
        useSkill(6094, false);
        break;
      case 1087: // Panther Dark Claw
        useSkill(6095, false);
        break;
      case 1088: // Panther Fatal Claw
        useSkill(6096, false);
        break;
      case 1089: // Deinonychus - Tail Strike
        useSkill(6199, true);
        break;
      case 1090: // Guardian's Strider - Strider Bite
        useSkill(6205, true);
        break;
      case 1091: // Guardian's Strider - Strider Fear
        useSkill(6206, true);
        break;
      case 1092: // Guardian's Strider - Strider Dash
        useSkill(6207, true);
        break;
      case 1093: // Maguen - Maguen Strike
        useSkill(6618, true);
        break;
      case 1094: // Maguen - Maguen Wind Walk
        useSkill(6681, true);
        break;
      case 1095: // Elite Maguen - Maguen Power Strike
        useSkill(6619, true);
        break;
      case 1096: // Elite Maguen - Elite Maguen Wind Walk
        useSkill(6682, true);
        break;
      case 1097: // Maguen - Maguen Return
        useSkill(6683, true);
        break;
      case 1098: // Elite Maguen - Maguen Party Return
        useSkill(6684, true);
        break;
      case 1099: // All servitor attack
        activeChar
            .getServitors()
            .values()
            .forEach(
                s -> {
                  if (validateSummon(s, false)) {
                    if (s.canAttack(_ctrlPressed)) {
                      s.doAttack();
                    }
                  }
                });
        break;
      case 1100: // All servitor move to
        activeChar
            .getServitors()
            .values()
            .forEach(
                s -> {
                  if (validateSummon(s, false)) {
                    if ((target != null) && (s != target) && !s.isMovementDisabled()) {
                      s.setFollowStatus(false);
                      s.getAI()
                          .setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, target.getLocation());
                    }
                  }
                });
        break;
      case 1101: // All servitor stop
        activeChar
            .getServitors()
            .values()
            .forEach(
                summon -> {
                  if (validateSummon(summon, false)) {
                    summon.cancelAction();
                  }
                });
        break;
      case 1102: // Unsummon all servitors
        boolean canUnsummon = true;
        OUT:
        for (L2Summon s : activeChar.getServitors().values()) {
          if (validateSummon(s, false)) {
            if (s.isAttackingNow() || s.isInCombat()) {
              sendPacket(
                  SystemMessageId.A_SERVITOR_WHOM_IS_ENGAGED_IN_BATTLE_CANNOT_BE_DE_ACTIVATED);
              canUnsummon = false;
              break OUT;
            }
            s.unSummon(activeChar);
          }
        }
        if (canUnsummon) {
          activeChar
              .getServitors()
              .values()
              .stream()
              .forEach(
                  s -> {
                    s.unSummon(activeChar);
                  });
        }
        break;
      case 1103: // seems to be passive mode
        break;
      case 1104: // seems to be defend mode
        break;
      case 1106: // Cute Bear - Bear Claw
        useServitorsSkill(11278);
        break;
      case 1107: // Cute Bear - Bear Tumbling
        useServitorsSkill(11279);
        break;
      case 1108: // Saber Tooth Cougar- Cougar Bite
        useServitorsSkill(11280);
        break;
      case 1109: // Saber Tooth Cougar - Cougar Pounce
        useServitorsSkill(11281);
        break;
      case 1110: // Grim Reaper - Reaper Touch
        useServitorsSkill(11282);
        break;
      case 1111: // Grim Reaper - Reaper Power
        useServitorsSkill(11283);
        break;
      case 1113: // Golden Lion - Lion Roar
        useSkill(10051, false);
        break;
      case 1114: // Golden Lion - Lion Claw
        useSkill(10052, false);
        break;
      case 1115: // Golden Lion - Lion Dash
        useSkill(10053, false);
        break;
      case 1116: // Golden Lion - Lion Flame
        useSkill(10054, false);
        break;
      case 1117: // Thunder Hawk - Thunder Flight
        useSkill(10794, false);
        break;
      case 1118: // Thunder Hawk - Thunder Purity
        useSkill(10795, false);
        break;
      case 1120: // Thunder Hawk - Thunder Feather Blast
        useSkill(10797, false);
        break;
      case 1121: // Thunder Hawk - Thunder Sharp Claw
        useSkill(10798, false);
        break;
      case 1122: // Tree of Life - Blessing of Tree
        useServitorsSkill(11806);
        break;
      case 1124: // Wynn Kai the Cat - Feline Aggression
        useServitorsSkill(11323);
        break;
      case 1125: // Wynn Kai the Cat - Feline Stun
        useServitorsSkill(11324);
        break;
      case 1126: // Wynn Feline King - Feline Bite
        useServitorsSkill(11325);
        break;
      case 1127: // Wynn Feline King - Feline Pounce
        useServitorsSkill(11326);
        break;
      case 1128: // Wynn Feline Queen - Feline Touch
        useServitorsSkill(11327);
        break;
      case 1129: // Wynn Feline Queen - Feline Power
        useServitorsSkill(11328);
        break;
      case 1130: // Wynn Merrow - Unicorn's Aggression
        useServitorsSkill(11332);
        break;
      case 1131: // Wynn Merrow - Unicorn's Stun
        useServitorsSkill(11333);
        break;
      case 1132: // Wynn Magnus - Unicorn's Bite
        useServitorsSkill(11334);
        break;
      case 1133: // Wynn Magnus - Unicorn's Pounce
        useServitorsSkill(11335);
        break;
      case 1134: // Wynn Seraphim - Unicorn's Touch
        useServitorsSkill(11336);
        break;
      case 1135: // Wynn Seraphim - Unicorn's Power
        useServitorsSkill(11337);
        break;
      case 1136: // Wynn Nightshade - Phantom Aggression
        useServitorsSkill(11341);
        break;
      case 1137: // Wynn Nightshade - Phantom Stun
        useServitorsSkill(11342);
        break;
      case 1138: // Wynn Spectral Lord - Phantom Bite
        useServitorsSkill(11343);
        break;
      case 1139: // Wynn Spectral Lord - Phantom Pounce
        useServitorsSkill(11344);
        break;
      case 1140: // Wynn Soulless - Phantom Touch
        useServitorsSkill(11345);
        break;
      case 1141: // Wynn Soulless - Phantom Power
        useServitorsSkill(11346);
        break;
      case 1142: // Blood Panther - Panther Roar
        useServitorsSkill(10087);
        break;
      case 1143: // Blood Panther - Panther Rush
        useServitorsSkill(10088);
        break;
      case 5000: // Baby Rudolph - Reindeer Scratch
        useSkill(23155, true);
        break;
      case 5001: // Deseloph, Hyum, Rekang, Lilias, Lapham, Mafum - Rosy Seduction
        useSkill(23167, true);
        break;
      case 5002: // Deseloph, Hyum, Rekang, Lilias, Lapham, Mafum - Critical Seduction
        useSkill(23168, true);
        break;
      case 5003: // Hyum, Lapham, Hyum, Lapham - Thunder Bolt
        useSkill(5749, true);
        break;
      case 5004: // Hyum, Lapham, Hyum, Lapham - Flash
        useSkill(5750, true);
        break;
      case 5005: // Hyum, Lapham, Hyum, Lapham - Lightning Wave
        useSkill(5751, true);
        break;
      case 5006: // Deseloph, Hyum, Rekang, Lilias, Lapham, Mafum, Deseloph, Hyum, Rekang, Lilias,
        // Lapham, Mafum - Buff Control
        useSkill(5771, true);
        break;
      case 5007: // Deseloph, Lilias, Deseloph, Lilias - Piercing Attack
        useSkill(6046, true);
        break;
      case 5008: // Deseloph, Lilias, Deseloph, Lilias - Spin Attack
        useSkill(6047, true);
        break;
      case 5009: // Deseloph, Lilias, Deseloph, Lilias - Smash
        useSkill(6048, true);
        break;
      case 5010: // Deseloph, Lilias, Deseloph, Lilias - Ignite
        useSkill(6049, true);
        break;
      case 5011: // Rekang, Mafum, Rekang, Mafum - Power Smash
        useSkill(6050, true);
        break;
      case 5012: // Rekang, Mafum, Rekang, Mafum - Energy Burst
        useSkill(6051, true);
        break;
      case 5013: // Rekang, Mafum, Rekang, Mafum - Shockwave
        useSkill(6052, true);
        break;
      case 5014: // Rekang, Mafum, Rekang, Mafum - Ignite
        useSkill(6053, true);
        break;
      case 5015: // Deseloph, Hyum, Rekang, Lilias, Lapham, Mafum, Deseloph, Hyum, Rekang, Lilias,
        // Lapham, Mafum - Switch Stance
        useSkill(6054, true);
        break;
        // Social Packets
      case 12: // Greeting
        tryBroadcastSocial(2);
        break;
      case 13: // Victory
        tryBroadcastSocial(3);
        break;
      case 14: // Advance
        tryBroadcastSocial(4);
        break;
      case 24: // Yes
        tryBroadcastSocial(6);
        break;
      case 25: // No
        tryBroadcastSocial(5);
        break;
      case 26: // Bow
        tryBroadcastSocial(7);
        break;
      case 29: // Unaware
        tryBroadcastSocial(8);
        break;
      case 30: // Social Waiting
        tryBroadcastSocial(9);
        break;
      case 31: // Laugh
        tryBroadcastSocial(10);
        break;
      case 33: // Applaud
        tryBroadcastSocial(11);
        break;
      case 34: // Dance
        tryBroadcastSocial(12);
        break;
      case 35: // Sorrow
        tryBroadcastSocial(13);
        break;
      case 62: // Charm
        tryBroadcastSocial(14);
        break;
      case 66: // Shyness
        tryBroadcastSocial(15);
        break;
      case 87: // Propose
        tryBroadcastSocial(28);
        break;
      case 88: // Provoke
        tryBroadcastSocial(29);
        break;
      case 89: // Beauty Shop
        tryBroadcastSocial(30);
        activeChar.broadcastInfo();
        break;
      default:
        _log.warning(activeChar.getName() + ": unhandled action type " + _actionId);
        break;
    }
  }
Ejemplo n.º 8
0
  @Override
  protected void runImpl() {
    L2PcInstance player = getClient().getActiveChar();
    if (player == null) {
      return;
    }

    if (_items == null) {
      player.setPrivateStoreType(PrivateStoreType.NONE);
      player.broadcastUserInfo();
      return;
    }

    if (!player.getAccessLevel().allowTransaction()) {
      player.sendPacket(SystemMessageId.YOU_ARE_NOT_AUTHORIZED_TO_DO_THAT);
      return;
    }

    if (AttackStanceTaskManager.getInstance().hasAttackStanceTask(player) || player.isInDuel()) {
      player.sendPacket(
          SystemMessageId
              .WHILE_YOU_ARE_ENGAGED_IN_COMBAT_YOU_CANNOT_OPERATE_A_PRIVATE_STORE_OR_PRIVATE_WORKSHOP);
      player.sendPacket(new PrivateStoreManageListBuy(player));
      player.sendPacket(ActionFailed.STATIC_PACKET);
      return;
    }

    if (player.isInsideZone(ZoneId.NO_STORE)) {
      player.sendPacket(new PrivateStoreManageListBuy(player));
      player.sendPacket(SystemMessageId.YOU_CANNOT_OPEN_A_PRIVATE_STORE_HERE);
      player.sendPacket(ActionFailed.STATIC_PACKET);
      return;
    }

    if (!player.canOpenPrivateStore()) {
      player.sendPacket(new PrivateStoreManageListBuy(player));
      player.sendPacket(ActionFailed.STATIC_PACKET);
      return;
    }

    TradeList tradeList = player.getBuyList();
    tradeList.clear();

    // Check maximum number of allowed slots for pvt shops
    if (_items.length > player.getPrivateBuyStoreLimit()) {
      player.sendPacket(new PrivateStoreManageListBuy(player));
      player.sendPacket(SystemMessageId.YOU_HAVE_EXCEEDED_THE_QUANTITY_THAT_CAN_BE_INPUTTED);
      return;
    }

    long totalCost = 0;
    for (Item i : _items) {
      if (!i.addToTradeList(tradeList)) {
        Util.handleIllegalPlayerAction(
            player,
            "Warning!! Character "
                + player.getName()
                + " of account "
                + player.getAccountName()
                + " tried to set price more than "
                + MAX_ADENA
                + " adena in Private Store - Buy.",
            Config.DEFAULT_PUNISH);
        return;
      }

      totalCost += i.getCost();
      if (totalCost > MAX_ADENA) {
        Util.handleIllegalPlayerAction(
            player,
            "Warning!! Character "
                + player.getName()
                + " of account "
                + player.getAccountName()
                + " tried to set total price more than "
                + MAX_ADENA
                + " adena in Private Store - Buy.",
            Config.DEFAULT_PUNISH);
        return;
      }
    }

    // Check for available funds
    if (totalCost > player.getAdena()) {
      player.sendPacket(new PrivateStoreManageListBuy(player));
      player.sendPacket(
          SystemMessageId
              .THE_PURCHASE_PRICE_IS_HIGHER_THAN_THE_AMOUNT_OF_MONEY_THAT_YOU_HAVE_AND_SO_YOU_CANNOT_OPEN_A_PERSONAL_STORE);
      return;
    }

    player.sitDown();
    player.setPrivateStoreType(PrivateStoreType.BUY);
    player.broadcastUserInfo();
    player.broadcastPacket(new PrivateStoreMsgBuy(player));
  }
Ejemplo n.º 9
0
  /** Starts the duel */
  public void startDuel() {
    if ((_playerA == null) || (_playerB == null) || _playerA.isInDuel() || _playerB.isInDuel()) {
      _playerConditions.clear();
      DuelManager.getInstance().removeDuel(this);
      return;
    }

    if (_partyDuel) {
      // Set duel state and team
      for (L2PcInstance temp : _playerA.getParty().getMembers()) {
        temp.cancelActiveTrade();
        temp.setIsInDuel(_duelId);
        temp.setTeam(Team.BLUE);
        temp.broadcastUserInfo();
        broadcastToTeam2(new ExDuelUpdateUserInfo(temp));
      }
      for (L2PcInstance temp : _playerB.getParty().getMembers()) {
        temp.cancelActiveTrade();
        temp.setIsInDuel(_duelId);
        temp.setTeam(Team.RED);
        temp.broadcastUserInfo();
        broadcastToTeam1(new ExDuelUpdateUserInfo(temp));
      }

      // Send duel packets
      broadcastToTeam1(ExDuelReady.PARTY_DUEL);
      broadcastToTeam2(ExDuelReady.PARTY_DUEL);
      broadcastToTeam1(ExDuelStart.PARTY_DUEL);
      broadcastToTeam2(ExDuelStart.PARTY_DUEL);

      // Open arena doors
      for (L2DoorInstance door :
          InstanceManager.getInstance().getInstance(getDueldInstanceId()).getDoors()) {
        if ((door != null) && !door.getOpen()) {
          door.openMe();
        }
      }
    } else {
      // Set duel state and team
      _playerA.setIsInDuel(_duelId);
      _playerA.setTeam(Team.BLUE);
      _playerB.setIsInDuel(_duelId);
      _playerB.setTeam(Team.RED);

      // Send duel Start packets
      // Send duel packets
      broadcastToTeam1(ExDuelReady.PLAYER_DUEL);
      broadcastToTeam2(ExDuelReady.PLAYER_DUEL);
      broadcastToTeam1(ExDuelStart.PLAYER_DUEL);
      broadcastToTeam2(ExDuelStart.PLAYER_DUEL);

      broadcastToTeam1(new ExDuelUpdateUserInfo(_playerB));
      broadcastToTeam2(new ExDuelUpdateUserInfo(_playerA));

      _playerA.broadcastUserInfo();
      _playerB.broadcastUserInfo();
    }

    // play sound
    broadcastToTeam1(B04_S01);
    broadcastToTeam2(B04_S01);

    // start dueling task
    ThreadPoolManager.getInstance().scheduleGeneral(new ScheduleDuelTask(this), 1000);
  }
Ejemplo n.º 10
0
  public synchronized void computeNewHeroes(List<StatsSet> newHeroes) {
    updateHeroes(true);

    for (Integer objectId : _heroes.keySet()) {
      final L2PcInstance player = L2World.getInstance().getPlayer(objectId);
      if (player == null) {
        continue;
      }

      player.setHero(false);

      for (int i = 0; i < Inventory.PAPERDOLL_TOTALSLOTS; i++) {
        L2ItemInstance equippedItem = player.getInventory().getPaperdollItem(i);
        if ((equippedItem != null) && equippedItem.isHeroItem()) {
          player.getInventory().unEquipItemInSlot(i);
        }
      }

      final InventoryUpdate iu = new InventoryUpdate();
      for (L2ItemInstance item : player.getInventory().getAvailableItems(false, false, false)) {
        if ((item != null) && item.isHeroItem()) {
          player.destroyItem("Hero", item, null, true);
          iu.addRemovedItem(item);
        }
      }

      if (!iu.getItems().isEmpty()) {
        player.sendPacket(iu);
      }

      player.broadcastUserInfo();
    }

    if (newHeroes.isEmpty()) {
      _heroes.clear();
      return;
    }

    Map<Integer, StatsSet> heroes = new FastMap<>();

    for (StatsSet hero : newHeroes) {
      int charId = hero.getInt(Olympiad.CHAR_ID);

      if ((_completeHeroes != null) && _completeHeroes.containsKey(charId)) {
        StatsSet oldHero = _completeHeroes.get(charId);
        int count = oldHero.getInt(COUNT);
        oldHero.set(COUNT, count + 1);
        oldHero.set(PLAYED, 1);
        oldHero.set(CLAIMED, false);
        heroes.put(charId, oldHero);
      } else {
        StatsSet newHero = new StatsSet();
        newHero.set(Olympiad.CHAR_NAME, hero.getString(Olympiad.CHAR_NAME));
        newHero.set(Olympiad.CLASS_ID, hero.getInt(Olympiad.CLASS_ID));
        newHero.set(COUNT, 1);
        newHero.set(PLAYED, 1);
        newHero.set(CLAIMED, false);
        heroes.put(charId, newHero);
      }
    }

    deleteItemsInDb();

    _heroes.clear();
    _heroes.putAll(heroes);

    heroes.clear();

    updateHeroes(false);
  }
 private String ClassChangeRequested(L2PcInstance player, int classId) {
   String htmltext = null;
   if (player.isInCategory(CategoryType.THIRD_CLASS_GROUP)) {
     htmltext = "30115-21.htm"; // fnYouAreThirdClass
   } else if ((classId == SORCERER) && (player.getClassId() == ClassId.wizard)) {
     if (player.getLevel() < 40) {
       if (hasQuestItems(player, MARK_OF_SCHOLAR, MARK_OF_TRUST, MARK_OF_MAGUS)) {
         htmltext = "30115-22.htm"; // fnLowLevel11
       } else {
         htmltext = "30115-23.htm"; // fnLowLevelNoProof11
       }
     } else if (hasQuestItems(player, MARK_OF_SCHOLAR, MARK_OF_TRUST, MARK_OF_MAGUS)) {
       takeItems(player, -1, MARK_OF_SCHOLAR, MARK_OF_TRUST, MARK_OF_MAGUS);
       player.setClassId(SORCERER);
       player.setBaseClass(SORCERER);
       // SystemMessage and cast skill is done by setClassId
       player.broadcastUserInfo();
       giveItems(player, SHADOW_ITEM_EXCHANGE_COUPON_C_GRADE, 15);
       htmltext = "30115-24.htm"; // fnAfterClassChange11
     } else {
       htmltext = "30115-25.htm"; // fnNoProof11
     }
   } else if ((classId == NECROMANCER) && (player.getClassId() == ClassId.wizard)) {
     if (player.getLevel() < 40) {
       if (hasQuestItems(player, MARK_OF_SCHOLAR, MARK_OF_TRUST, MARK_OF_WITCHCRAFT)) {
         htmltext = "30115-26.htm"; // fnLowLevel12
       } else {
         htmltext = "30115-27.htm"; // fnLowLevelNoProof12
       }
     } else if (hasQuestItems(player, MARK_OF_SCHOLAR, MARK_OF_TRUST, MARK_OF_WITCHCRAFT)) {
       takeItems(player, -1, MARK_OF_SCHOLAR, MARK_OF_TRUST, MARK_OF_WITCHCRAFT);
       player.setClassId(NECROMANCER);
       player.setBaseClass(NECROMANCER);
       // SystemMessage and cast skill is done by setClassId
       player.broadcastUserInfo();
       giveItems(player, SHADOW_ITEM_EXCHANGE_COUPON_C_GRADE, 15);
       htmltext = "30115-28.htm"; // fnAfterClassChange12
     } else {
       htmltext = "30115-29.htm"; // fnNoProof12
     }
   } else if ((classId == WARLOCK) && (player.getClassId() == ClassId.wizard)) {
     if (player.getLevel() < 40) {
       if (hasQuestItems(player, MARK_OF_SCHOLAR, MARK_OF_TRUST, MARK_OF_SUMMONER)) {
         htmltext = "30115-30.htm"; // fnLowLevel13
       } else {
         htmltext = "30115-31.htm"; // fnLowLevelNoProof13
       }
     } else if (hasQuestItems(player, MARK_OF_SCHOLAR, MARK_OF_TRUST, MARK_OF_SUMMONER)) {
       takeItems(player, -1, MARK_OF_SCHOLAR, MARK_OF_TRUST, MARK_OF_SUMMONER);
       player.setClassId(WARLOCK);
       player.setBaseClass(WARLOCK);
       // SystemMessage and cast skill is done by setClassId
       player.broadcastUserInfo();
       giveItems(player, SHADOW_ITEM_EXCHANGE_COUPON_C_GRADE, 15);
       htmltext = "30115-32.htm"; // fnAfterClassChange13
     } else {
       htmltext = "30115-33.htm"; // fnNoProof13
     }
   } else if ((classId == SPELLSINGER) && (player.getClassId() == ClassId.elvenWizard)) {
     if (player.getLevel() < 40) {
       if (hasQuestItems(player, MARK_OF_SCHOLAR, MARK_OF_LIFE, MARK_OF_MAGUS)) {
         htmltext = "30115-34.htm"; // fnLowLevel21
       } else {
         htmltext = "30115-35.htm"; // fnLowLevelNoProof21
       }
     } else if (hasQuestItems(player, MARK_OF_SCHOLAR, MARK_OF_LIFE, MARK_OF_MAGUS)) {
       takeItems(player, -1, MARK_OF_SCHOLAR, MARK_OF_LIFE, MARK_OF_MAGUS);
       player.setClassId(SPELLSINGER);
       player.setBaseClass(SPELLSINGER);
       // SystemMessage and cast skill is done by setClassId
       player.broadcastUserInfo();
       giveItems(player, SHADOW_ITEM_EXCHANGE_COUPON_C_GRADE, 15);
       htmltext = "30115-36.htm"; // fnAfterClassChange21
     } else {
       htmltext = "30115-37.htm"; // fnNoProof21
     }
   } else if ((classId == ELEMENTAL_SUMMONER) && (player.getClassId() == ClassId.elvenWizard)) {
     if (player.getLevel() < 40) {
       if (hasQuestItems(player, MARK_OF_SCHOLAR, MARK_OF_LIFE, MARK_OF_SUMMONER)) {
         htmltext = "30115-38.htm"; // fnLowLevel22
       } else {
         htmltext = "30115-39.htm"; // fnLowLevelNoProof22
       }
     } else if (hasQuestItems(player, MARK_OF_SCHOLAR, MARK_OF_LIFE, MARK_OF_SUMMONER)) {
       takeItems(player, -1, MARK_OF_SCHOLAR, MARK_OF_LIFE, MARK_OF_SUMMONER);
       player.setClassId(ELEMENTAL_SUMMONER);
       player.setBaseClass(ELEMENTAL_SUMMONER);
       // SystemMessage and cast skill is done by setClassId
       player.broadcastUserInfo();
       giveItems(player, SHADOW_ITEM_EXCHANGE_COUPON_C_GRADE, 15);
       htmltext = "30115-40.htm"; // fnAfterClassChange22
     } else {
       htmltext = "30115-41.htm"; // fnNoProof22
     }
   }
   return htmltext;
 }
Ejemplo n.º 12
0
  @Override
  protected void runImpl() {
    L2PcInstance activeChar = getClient().getActiveChar();

    if (activeChar == null) {
      _log.fine("RequestCrystalizeItem: activeChar was null");
      return;
    }

    if (!getClient().getFloodProtectors().getTransaction().tryPerformAction("crystallize")) {
      activeChar.sendMessage("You are crystallizing too fast.");
      return;
    }

    if (_count <= 0) {
      Util.handleIllegalPlayerAction(
          activeChar,
          "[RequestCrystallizeItem] count <= 0! ban! oid: "
              + _objectId
              + " owner: "
              + activeChar.getName(),
          Config.DEFAULT_PUNISH);
      return;
    }

    if ((activeChar.getPrivateStoreType() != PrivateStoreType.NONE)
        || !activeChar.isInCrystallize()) {
      activeChar.sendPacket(
          SystemMessageId
              .WHILE_OPERATING_A_PRIVATE_STORE_OR_WORKSHOP_YOU_CANNOT_DISCARD_DESTROY_OR_TRADE_AN_ITEM);
      return;
    }

    int skillLevel = activeChar.getSkillLevel(CommonSkill.CRYSTALLIZE.getId());
    if (skillLevel <= 0) {
      activeChar.sendPacket(
          SystemMessageId
              .YOU_MAY_NOT_CRYSTALLIZE_THIS_ITEM_YOUR_CRYSTALLIZATION_SKILL_LEVEL_IS_TOO_LOW);
      activeChar.sendPacket(ActionFailed.STATIC_PACKET);
      if ((activeChar.getRace() != Race.DWARF)
          && (activeChar.getClassId().ordinal() != 117)
          && (activeChar.getClassId().ordinal() != 55)) {
        _log.info(
            "Player "
                + activeChar.getClient()
                + " used crystalize with classid: "
                + activeChar.getClassId().ordinal());
      }
      return;
    }

    PcInventory inventory = activeChar.getInventory();
    if (inventory != null) {
      L2ItemInstance item = inventory.getItemByObjectId(_objectId);
      if (item == null) {
        activeChar.sendPacket(ActionFailed.STATIC_PACKET);
        return;
      }

      if (item.isHeroItem()) {
        return;
      }

      if (_count > item.getCount()) {
        _count = activeChar.getInventory().getItemByObjectId(_objectId).getCount();
      }
    }

    final L2ItemInstance itemToRemove = activeChar.getInventory().getItemByObjectId(_objectId);
    if ((itemToRemove == null) || itemToRemove.isShadowItem() || itemToRemove.isTimeLimitedItem()) {
      return;
    }

    if (!itemToRemove.getItem().isCrystallizable()
        || (itemToRemove.getItem().getCrystalCount() <= 0)
        || (itemToRemove.getItem().getCrystalType() == CrystalType.NONE)) {
      _log.warning(
          activeChar.getName()
              + " ("
              + activeChar.getObjectId()
              + ") tried to crystallize "
              + itemToRemove.getItem().getId());
      return;
    }

    if (!activeChar.getInventory().canManipulateWithItemId(itemToRemove.getId())) {
      activeChar.sendMessage("You cannot use this item.");
      return;
    }

    // Check if the char can crystallize items and return if false;
    boolean canCrystallize = true;

    switch (itemToRemove.getItem().getCrystalTypePlus()) {
      case D:
        {
          if (skillLevel < 1) {
            canCrystallize = false;
          }
          break;
        }
      case C:
        {
          if (skillLevel < 2) {
            canCrystallize = false;
          }
          break;
        }
      case B:
        {
          if (skillLevel < 3) {
            canCrystallize = false;
          }
          break;
        }
      case A:
        {
          if (skillLevel < 4) {
            canCrystallize = false;
          }
          break;
        }
      case S:
        {
          if (skillLevel < 5) {
            canCrystallize = false;
          }
          break;
        }
      case R:
        {
          if (skillLevel < 6) {
            canCrystallize = false;
          }
          break;
        }
    }

    if (!canCrystallize) {
      activeChar.sendPacket(
          SystemMessageId
              .YOU_MAY_NOT_CRYSTALLIZE_THIS_ITEM_YOUR_CRYSTALLIZATION_SKILL_LEVEL_IS_TOO_LOW);
      activeChar.sendPacket(ActionFailed.STATIC_PACKET);
      return;
    }

    // activeChar.setInCrystallize(true);

    // unequip if needed
    SystemMessage sm;
    if (itemToRemove.isEquipped()) {
      L2ItemInstance[] unequiped =
          activeChar.getInventory().unEquipItemInSlotAndRecord(itemToRemove.getLocationSlot());
      InventoryUpdate iu = new InventoryUpdate();
      for (L2ItemInstance item : unequiped) {
        iu.addModifiedItem(item);
      }
      activeChar.sendPacket(iu);

      if (itemToRemove.getEnchantLevel() > 0) {
        sm = SystemMessage.getSystemMessage(SystemMessageId.THE_EQUIPMENT_S1_S2_HAS_BEEN_REMOVED);
        sm.addInt(itemToRemove.getEnchantLevel());
        sm.addItemName(itemToRemove);
      } else {
        sm = SystemMessage.getSystemMessage(SystemMessageId.S1_HAS_BEEN_UNEQUIPPED);
        sm.addItemName(itemToRemove);
      }
      activeChar.sendPacket(sm);
    }

    // remove from inventory
    final L2ItemInstance removedItem =
        activeChar.getInventory().destroyItem("Crystalize", _objectId, _count, activeChar, null);

    final InventoryUpdate iu = new InventoryUpdate();
    iu.addRemovedItem(removedItem);
    activeChar.sendPacket(iu);

    final int crystalId = itemToRemove.getItem().getCrystalItemId();
    final int crystalAmount = itemToRemove.getCrystalCount();

    final List<ItemChanceHolder> items = new ArrayList<>();
    items.add(new ItemChanceHolder(crystalId, 100, crystalAmount));

    final CrystalizationData data =
        ItemCrystalizationData.getInstance().getCrystalization(itemToRemove.getId());
    if (data != null) {
      data.getItems().stream().filter(holder -> (holder.getId() != crystalId)).forEach(items::add);
    }

    for (ItemChanceHolder holder : items) {
      final double rand = Rnd.nextDouble() * 100;
      if (rand < holder.getChance()) {
        // add crystals
        final L2ItemInstance createdItem =
            activeChar
                .getInventory()
                .addItem("Crystalize", holder.getId(), holder.getCount(), activeChar, activeChar);

        sm = SystemMessage.getSystemMessage(SystemMessageId.YOU_HAVE_EARNED_S2_S1_S);
        sm.addItemName(createdItem);
        sm.addLong(holder.getCount());
        activeChar.sendPacket(sm);
      }
    }

    sm = SystemMessage.getSystemMessage(SystemMessageId.S1_HAS_BEEN_CRYSTALLIZED);
    sm.addItemName(removedItem);
    activeChar.sendPacket(sm);

    activeChar.broadcastUserInfo();

    L2World.getInstance().removeObject(removedItem);

    activeChar.setInCrystallize(false);
  }
  @Override
  protected void runImpl() {
    L2PcInstance player = getClient().getActiveChar();
    if (player == null) return;

    if (_items == null) {
      player.setPrivateStoreType(L2PcInstance.STORE_PRIVATE_NONE);
      player.broadcastUserInfo();
      return;
    }

    if (AttackStanceTaskManager.getInstance().getAttackStanceTask(player) || player.isInDuel()) {
      player.sendPacket(
          SystemMessage.getSystemMessage(SystemMessageId.CANT_OPERATE_PRIVATE_STORE_DURING_COMBAT));
      player.sendPacket(ActionFailed.STATIC_PACKET);
      return;
    }

    if (player.isInsideZone(L2Character.ZONE_NOSTORE)) {
      player.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.NO_PRIVATE_WORKSHOP_HERE));
      player.sendPacket(ActionFailed.STATIC_PACKET);
      return;
    }

    L2ManufactureList createList = new L2ManufactureList();

    List<L2RecipeList> dwarfRecipes = Arrays.asList(player.getDwarvenRecipeBook());
    List<L2RecipeList> commonRecipes = Arrays.asList(player.getCommonRecipeBook());

    for (Recipe i : _items) {
      L2RecipeList list = RecipeController.getInstance().getRecipeList(i.getRecipeId());

      if (!dwarfRecipes.contains(list) && !commonRecipes.contains(list)) {
        Util.handleIllegalPlayerAction(
            player,
            "Warning!! Player "
                + player.getName()
                + " of account "
                + player.getAccountName()
                + " tried to set recipe which he dont have.",
            Config.DEFAULT_PUNISH);
        return;
      }

      if (!i.addToList(createList)) {
        Util.handleIllegalPlayerAction(
            player,
            "Warning!! Character "
                + player.getName()
                + " of account "
                + player.getAccountName()
                + " tried to set price more than "
                + MAX_ADENA
                + " adena in Private Manufacture.",
            Config.DEFAULT_PUNISH);
        return;
      }
    }

    createList.setStoreName(
        player.getCreateList() != null ? player.getCreateList().getStoreName() : "");
    player.setCreateList(createList);

    player.setPrivateStoreType(L2PcInstance.STORE_PRIVATE_MANUFACTURE);
    player.sitDown();
    player.broadcastUserInfo();
    player.sendPacket(new RecipeShopMsg(player));
    player.broadcastPacket(new RecipeShopMsg(player));
  }