@Override
 public String onTalk(L2Npc npc, L2PcInstance player) {
   String htmltext = null;
   if (player.isInCategory(CategoryType.WIZARD_GROUP)
       && player.isInCategory(CategoryType.FOURTH_CLASS_GROUP)
       && (player.isInCategory(CategoryType.HUMAN_MALL_CLASS)
           || player.isInCategory(CategoryType.ELF_MALL_CLASS))) {
     htmltext = "30115-01.htm"; // fnYouAreFourthClass
   } else if (player.isInCategory(CategoryType.WIZARD_GROUP)
       && (player.isInCategory(CategoryType.HUMAN_MALL_CLASS)
           || player.isInCategory(CategoryType.ELF_MALL_CLASS))) {
     final ClassId classId = player.getClassId();
     if ((classId == ClassId.wizard)
         || (classId == ClassId.sorceror)
         || (classId == ClassId.necromancer)
         || (classId == ClassId.warlock)) {
       htmltext = "30115-02.htm"; // fnClassList1
     } else if ((classId == ClassId.elvenWizard)
         || (classId == ClassId.spellsinger)
         || (classId == ClassId.elementalSummoner)) {
       htmltext = "30115-12.htm"; // fnClassList2
     } else {
       htmltext = "30115-19.htm"; // fnYouAreFirstClass
     }
   } else {
     htmltext = "30115-20.htm"; // fnClassMismatch
   }
   return htmltext;
 }
  @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;
  }
  private static void makeSupportMagic(L2PcInstance player, L2Npc npc, boolean isSummon) {
    final int level = player.getLevel();
    if (isSummon && !player.hasServitor()) {
      npc.showChatWindow(player, "data/html/default/SupportMagicNoSummon.htm");
      return;
    } else if (level > HIGHEST_LEVEL) {
      npc.showChatWindow(player, "data/html/default/SupportMagicHighLevel.htm");
      return;
    } else if (level < LOWEST_LEVEL) {
      npc.showChatWindow(player, "data/html/default/SupportMagicLowLevel.htm");
      return;
    } else if (player.getClassId().level() == 3) {
      player.sendMessage(
          "Only adventurers who have not completed their 3rd class transfer may receive these buffs."); // Custom message
      return;
    }

    if (isSummon) {
      npc.setTarget(player.getSummon());
      for (SkillHolder skill : SUMMON_BUFFS) {
        npc.doCast(skill.getSkill());
      }

      if (level >= HASTE_LEVEL_2) {
        npc.doCast(HASTE_2.getSkill());
      } else {
        npc.doCast(HASTE_1.getSkill());
      }
    } else {
      npc.setTarget(player);
      if (player.isInCategory(CategoryType.BEGINNER_MAGE)) {
        for (SkillHolder skill : MAGE_BUFFS) {
          npc.doCast(skill.getSkill());
        }
      } else {
        for (SkillHolder skill : FIGHTER_BUFFS) {
          npc.doCast(skill.getSkill());
        }

        if (level >= HASTE_LEVEL_2) {
          npc.doCast(HASTE_2.getSkill());
        } else {
          npc.doCast(HASTE_1.getSkill());
        }
      }

      if ((level >= CUBIC_LOWEST) && (level <= CUBIC_HIGHEST)) {
        player.doSimultaneousCast(CUBIC.getSkill());
      }
    }
  }
  private static boolean rewardDimensionalDiamonds(L2PcInstance player) {
    final PlayerVariables vars = player.getVariables();

    if (vars.getInt("2ND_CLASS_DIAMOND_REWARD", 0) == 0) {
      if (player.getClassId() == ClassId.knight) {
        rewardItems(player, DIMENSIONAL_DIAMOND, 45);
      } else {
        rewardItems(player, DIMENSIONAL_DIAMOND, 61);
      }

      vars.set("2ND_CLASS_DIAMOND_REWARD", 1);
      return true;
    }
    return false;
  }
  @Override
  public String onTalk(L2Npc npc, L2PcInstance player) {
    String htmltext = getNoQuestMsg(player);
    getQuestState(player, true);
    if (player.isSubClassActive()) {
      return htmltext;
    }

    final ClassId cid = player.getClassId();
    if (cid.getRace() == Race.DARK_ELF) {
      switch (cid) {
        case darkFighter:
          {
            htmltext = npc.getId() + "-01.html";
            break;
          }
        case darkMage:
          {
            htmltext = npc.getId() + "-08.html";
            break;
          }
        default:
          {
            if (cid.level() == 1) {
              // first occupation change already made
              return npc.getId() + "-32.html";
            } else if (cid.level() >= 2) {
              // second/third occupation change already made
              return npc.getId() + "-31.html";
            }
          }
      }
    } else {
      htmltext = npc.getId() + "-33.html"; // other races
    }
    return htmltext;
  }
示例#6
0
 @Override
 public String onTalk(L2Npc npc, L2PcInstance player) {
   final QuestState qs = getQuestState(player, true);
   String htmltext = getNoQuestMsg(player);
   if (qs.isCreated()) {
     if (npc.getId() == MAGISTER_MIRIEN) {
       if ((player.getClassId() == ClassId.WIZARD)
           || (player.getClassId() == ClassId.ELVEN_WIZARD)
           || ((player.getClassId() == ClassId.DARK_WIZARD))) {
         if (player.getLevel() < MIN_LVL) {
           htmltext = "30461-02.html";
         } else {
           htmltext = "30461-03.htm";
         }
       } else {
         htmltext = "30461-01.html";
       }
     }
   } else if (qs.isStarted()) {
     switch (npc.getId()) {
       case MAGISTER_MIRIEN:
         {
           if (hasQuestItems(player, MIRIENS_1ST_SIGIL)) {
             if (!hasQuestItems(player, SYMBOL_OF_SYLVAIN)) {
               htmltext = "30461-05.html";
             } else {
               takeItems(player, MIRIENS_1ST_SIGIL, 1);
               giveItems(player, MIRIENS_2ND_SIGIL, 1);
               takeItems(player, SYMBOL_OF_SYLVAIN, 1);
               qs.setCond(15, true);
               htmltext = "30461-06.html";
             }
           } else if (hasQuestItems(player, MIRIENS_2ND_SIGIL)) {
             if (!hasQuestItems(player, SYMBOL_OF_JUREK)) {
               htmltext = "30461-07.html";
             } else {
               htmltext = "30461-08.html";
             }
           } else if (hasQuestItems(player, MIRIENS_INSTRUCTION)) {
             if (player.getLevel() < LEVEL) {
               htmltext = "30461-11.html";
             } else {
               takeItems(player, MIRIENS_INSTRUCTION, 1);
               giveItems(player, MIRIENS_3RD_SIGIL, 1);
               qs.setCond(19, true);
               htmltext = "30461-12.html";
             }
           } else if (hasQuestItems(player, MIRIENS_3RD_SIGIL)) {
             if (!hasQuestItems(player, SYMBOL_OF_CRONOS)) {
               htmltext = "30461-13.html";
             } else {
               giveAdena(player, 319628, true);
               giveItems(player, MARK_OF_SCHOLAR, 1);
               addExpAndSp(player, 1753926, 113754);
               qs.exitQuest(false, true);
               player.sendPacket(new SocialAction(player.getObjectId(), 3));
               htmltext = "30461-14.html";
             }
           }
           break;
         }
       case HIGH_PRIEST_SYLVAIN:
         {
           if (hasQuestItems(player, MIRIENS_1ST_SIGIL)
               && !hasAtLeastOneQuestItem(player, HIGH_PRIESTS_SIGIL, SYMBOL_OF_SYLVAIN)) {
             htmltext = "30070-01.html";
           } else if (!hasQuestItems(player, CRYSTAL_OF_PURITY1)
               && hasQuestItems(player, HIGH_PRIESTS_SIGIL, MIRIENS_1ST_SIGIL)) {
             htmltext = "30070-03.html";
           } else if (hasQuestItems(
               player, HIGH_PRIESTS_SIGIL, MIRIENS_1ST_SIGIL, CRYSTAL_OF_PURITY1)) {
             takeItems(player, CRYSTAL_OF_PURITY1, 1);
             takeItems(player, HIGH_PRIESTS_SIGIL, 1);
             giveItems(player, SYMBOL_OF_SYLVAIN, 1);
             qs.setCond(14, true);
             htmltext = "30070-04.html";
           } else if (hasQuestItems(player, MIRIENS_1ST_SIGIL, SYMBOL_OF_SYLVAIN)
               && !hasQuestItems(player, HIGH_PRIESTS_SIGIL)) {
             htmltext = "30070-05.html";
           } else if (hasAtLeastOneQuestItem(player, MIRIENS_2ND_SIGIL, MIRIENS_3RD_SIGIL)) {
             htmltext = "30070-06.html";
           }
           break;
         }
       case CAPTAIN_LUCAS:
         {
           if (hasQuestItems(player, MIRIENS_1ST_SIGIL, HIGH_PRIESTS_SIGIL)) {
             if (hasQuestItems(player, MARIAS_1ST_LETTER)) {
               takeItems(player, MARIAS_1ST_LETTER, 1);
               giveItems(player, LUCASS_LETTER, 1);
               qs.setCond(4, true);
               htmltext = "30071-01.html";
             } else if (hasAtLeastOneQuestItem(
                 player,
                 MARIAS_2ND_LETTER,
                 CRETAS_1ST_LETTER,
                 LUCILLAS_HANDBAG,
                 CRERAS_PAINTING1,
                 LUCASS_LETTER)) {
               htmltext = "30071-02.html";
             } else if (hasQuestItems(player, CRERAS_PAINTING2)) {
               htmltext = "30071-03.html";
             } else if (hasQuestItems(player, CRERAS_PAINTING3)) {
               if (getQuestItemsCount(player, BROWN_SCROLL_SCRAP) < 5) {
                 htmltext = "30071-05.html";
               } else {
                 htmltext = "30071-06.html";
               }
             }
           } else if (hasAtLeastOneQuestItem(
               player,
               SYMBOL_OF_SYLVAIN,
               MIRIENS_2ND_SIGIL,
               MIRIENS_3RD_SIGIL,
               CRYSTAL_OF_PURITY1)) {
             htmltext = "30071-07.html";
           }
           break;
         }
       case WAREHOUSE_KEEPER_VALKON:
         {
           if (hasQuestItems(player, TRIFFS_RING)) {
             if (!hasAtLeastOneQuestItem(
                 player, VALKONS_REQUEST, CRYSTAL_OF_PURITY2, SCRIPTURE_CHAPTER_2)) {
               htmltext = "30103-01.html";
             } else if (hasQuestItems(player, VALKONS_REQUEST)
                 && !hasAtLeastOneQuestItem(player, CRYSTAL_OF_PURITY2, SCRIPTURE_CHAPTER_2)) {
               htmltext = "30103-05.html";
             } else if (hasQuestItems(player, CRYSTAL_OF_PURITY2)
                 && !hasAtLeastOneQuestItem(player, VALKONS_REQUEST, SCRIPTURE_CHAPTER_2)) {
               giveItems(player, SCRIPTURE_CHAPTER_2, 1);
               takeItems(player, CRYSTAL_OF_PURITY2, 1);
               htmltext = "30103-06.html";
             } else if (hasQuestItems(player, SCRIPTURE_CHAPTER_2)
                 && !hasAtLeastOneQuestItem(player, VALKONS_REQUEST, CRYSTAL_OF_PURITY2)) {
               htmltext = "30103-07.html";
             }
           }
           break;
         }
       case MAGISTER_DIETER:
         {
           if (hasQuestItems(player, MIRIENS_3RD_SIGIL, CRONOS_SIGIL)) {
             if (hasQuestItems(player, CRONOS_LETTER)) {
               htmltext = "30111-01.html";
             } else if (hasQuestItems(player, DIETERS_KEY)) {
               htmltext = "30111-06.html";
             } else if (hasQuestItems(player, CRETAS_2ND_LETTER)) {
               htmltext = "30111-07.html";
             } else if (hasQuestItems(player, DIETERS_DIARY, DIETERS_LETTER)) {
               htmltext = "30111-10.html";
             } else if (hasQuestItems(player, DIETERS_DIARY, RAUTS_LETTER_ENVELOPE)) {
               htmltext = "30111-11.html";
             } else if (hasQuestItems(player, DIETERS_DIARY)
                 && !hasAtLeastOneQuestItem(player, DIETERS_LETTER, RAUTS_LETTER_ENVELOPE)) {
               if (hasQuestItems(
                   player,
                   SCRIPTURE_CHAPTER_1,
                   SCRIPTURE_CHAPTER_2,
                   SCRIPTURE_CHAPTER_3,
                   SCRIPTURE_CHAPTER_4)) {
                 htmltext = "30111-13.html";
               } else {
                 htmltext = "30111-12.html";
               }
             }
           } else if (hasQuestItems(player, SYMBOL_OF_CRONOS)) {
             htmltext = "30111-15.html";
           }
           break;
         }
       case GRAND_MAGISTER_JUREK:
         {
           if (hasQuestItems(player, MIRIENS_2ND_SIGIL)) {
             if (!hasAtLeastOneQuestItem(player, GRAND_MAGISTER_SIGIL, SYMBOL_OF_JUREK)) {
               htmltext = "30115-01.html";
             } else if (hasQuestItems(player, JUREKS_LIST)) {
               if ((getQuestItemsCount(player, MONSTER_EYE_DESTROYER_SKIN)
                       + getQuestItemsCount(player, SHAMANS_NECKLACE)
                       + getQuestItemsCount(player, SHACKLES_SCALP))
                   < 12) {
                 htmltext = "30115-04.html";
               } else {
                 takeItems(player, GRAND_MAGISTER_SIGIL, 1);
                 takeItems(player, JUREKS_LIST, 1);
                 takeItems(player, MONSTER_EYE_DESTROYER_SKIN, -1);
                 takeItems(player, SHAMANS_NECKLACE, -1);
                 takeItems(player, SHACKLES_SCALP, -1);
                 giveItems(player, SYMBOL_OF_JUREK, 1);
                 qs.setCond(18, true);
                 htmltext = "30115-05.html";
               }
             } else if (hasQuestItems(player, SYMBOL_OF_JUREK)
                 && !hasQuestItems(player, GRAND_MAGISTER_SIGIL)) {
               htmltext = "30115-06.html";
             }
           } else if (hasAtLeastOneQuestItem(player, MIRIENS_1ST_SIGIL, MIRIENS_3RD_SIGIL)) {
             htmltext = "30115-07.html";
           }
           break;
         }
       case TRADER_EDROC:
         {
           if (hasQuestItems(player, DIETERS_DIARY)) {
             if (hasQuestItems(player, DIETERS_LETTER)) {
               htmltext = "30230-01.html";
             } else if (hasQuestItems(player, RAUTS_LETTER_ENVELOPE)) {
               htmltext = "30230-03.html";
             } else if (hasAtLeastOneQuestItem(player, STRONG_LIGUOR, TRIFFS_RING)) {
               htmltext = "30230-04.html";
             }
           }
           break;
         }
       case WAREHOUSE_KEEPER_RAUT:
         {
           if (hasQuestItems(player, DIETERS_DIARY)) {
             if (hasQuestItems(player, RAUTS_LETTER_ENVELOPE)) {
               htmltext = "30316-01.html";
             } else if (hasQuestItems(player, SCRIPTURE_CHAPTER_1, STRONG_LIGUOR)) {
               htmltext = "30316-04.html";
             } else if (hasQuestItems(player, SCRIPTURE_CHAPTER_1, TRIFFS_RING)) {
               htmltext = "30316-05.html";
             }
           }
           break;
         }
       case BLACKSMITH_POITAN:
         {
           if (hasQuestItems(player, TRIFFS_RING)) {
             if (!hasAtLeastOneQuestItem(
                 player, POITANS_NOTES, CASIANS_LIST, SCRIPTURE_CHAPTER_4)) {
               giveItems(player, POITANS_NOTES, 1);
               htmltext = "30458-01.html";
             } else if (hasQuestItems(player, POITANS_NOTES)
                 && !hasAtLeastOneQuestItem(player, CASIANS_LIST, SCRIPTURE_CHAPTER_4)) {
               htmltext = "30458-02.html";
             } else if (hasQuestItems(player, POITANS_NOTES, CASIANS_LIST)
                 && !hasQuestItems(player, SCRIPTURE_CHAPTER_4)) {
               htmltext = "30458-03.html";
             } else if (hasQuestItems(player, SCRIPTURE_CHAPTER_4)
                 && !hasAtLeastOneQuestItem(player, POITANS_NOTES, CASIANS_LIST)) {
               htmltext = "30458-04.html";
             }
           }
           break;
         }
       case MARIA:
         {
           if (hasQuestItems(player, MIRIENS_1ST_SIGIL, HIGH_PRIESTS_SIGIL)) {
             if (hasQuestItems(player, SYLVAINS_LETTER)) {
               htmltext = "30608-01.html";
             } else if (hasQuestItems(player, MARIAS_1ST_LETTER)) {
               htmltext = "30608-03.html";
             } else if (hasQuestItems(player, LUCASS_LETTER)) {
               giveItems(player, MARIAS_2ND_LETTER, 1);
               takeItems(player, LUCASS_LETTER, 1);
               qs.setCond(5, true);
               htmltext = "30608-04.html";
             } else if (hasQuestItems(player, MARIAS_2ND_LETTER)) {
               htmltext = "30608-05.html";
             } else if (hasQuestItems(player, CRETAS_1ST_LETTER)) {
               htmltext = "30608-06.html";
             } else if (hasQuestItems(player, LUCILLAS_HANDBAG)) {
               htmltext = "30608-09.html";
             } else if (hasQuestItems(player, CRERAS_PAINTING1)) {
               takeItems(player, CRERAS_PAINTING1, 1);
               giveItems(player, CRERAS_PAINTING2, 1);
               qs.setCond(9, true);
               htmltext = "30608-10.html";
             } else if (hasQuestItems(player, CRERAS_PAINTING2)) {
               htmltext = "30608-11.html";
             } else if (hasQuestItems(player, CRERAS_PAINTING3)) {
               if (getQuestItemsCount(player, BROWN_SCROLL_SCRAP) < 5) {
                 qs.setCond(11, true);
                 htmltext = "30608-12.html";
               } else {
                 htmltext = "30608-13.html";
               }
             } else if (hasQuestItems(player, CRYSTAL_OF_PURITY1)) {
               htmltext = "30608-15.html";
             }
           } else if (hasAtLeastOneQuestItem(player, SYMBOL_OF_SYLVAIN, MIRIENS_2ND_SIGIL)) {
             htmltext = "30608-16.html";
           } else if (hasQuestItems(player, MIRIENS_3RD_SIGIL)) {
             if (!hasQuestItems(player, VALKONS_REQUEST)) {
               htmltext = "30608-17.html";
             } else {
               takeItems(player, VALKONS_REQUEST, 1);
               giveItems(player, CRYSTAL_OF_PURITY2, 1);
               htmltext = "30608-18.html";
             }
           }
           break;
         }
       case ASTROLOGER_CRETA:
         {
           if (hasQuestItems(player, MIRIENS_1ST_SIGIL, HIGH_PRIESTS_SIGIL)) {
             if (hasQuestItems(player, MARIAS_2ND_LETTER)) {
               htmltext = "30609-01.html";
             } else if (hasQuestItems(player, CRETAS_1ST_LETTER)) {
               htmltext = "30609-06.html";
             } else if (hasQuestItems(player, LUCILLAS_HANDBAG)) {
               htmltext = "30609-07.html";
             } else if (hasAtLeastOneQuestItem(
                 player, CRERAS_PAINTING1, CRERAS_PAINTING2, CRERAS_PAINTING3)) {
               htmltext = "30609-10.html";
             }
           } else if (hasAtLeastOneQuestItem(
               player, CRYSTAL_OF_PURITY1, SYMBOL_OF_SYLVAIN, MIRIENS_2ND_SIGIL)) {
             htmltext = "30609-11.html";
           } else if (hasQuestItems(player, MIRIENS_3RD_SIGIL)) {
             if (hasQuestItems(player, DIETERS_KEY)) {
               htmltext = "30609-12.html";
             } else {
               htmltext = "30609-15.html";
             }
           }
           break;
         }
       case ELDER_CRONOS:
         {
           if (hasQuestItems(player, MIRIENS_3RD_SIGIL)) {
             if (!hasAtLeastOneQuestItem(player, CRONOS_SIGIL, SYMBOL_OF_CRONOS)) {
               htmltext = "30610-01.html";
             } else if (hasQuestItems(player, CRONOS_SIGIL)) {
               if (hasQuestItems(
                   player,
                   SCRIPTURE_CHAPTER_1,
                   SCRIPTURE_CHAPTER_2,
                   SCRIPTURE_CHAPTER_3,
                   SCRIPTURE_CHAPTER_4)) {
                 htmltext = "30610-12.html";
               } else {
                 htmltext = "30610-11.html";
               }
             } else if (hasQuestItems(player, SYMBOL_OF_CRONOS)
                 && !hasQuestItems(player, CRONOS_SIGIL)) {
               htmltext = "30610-15.html";
             }
           }
           break;
         }
       case DRUNKARD_TRIFF:
         {
           if (hasQuestItems(player, DIETERS_DIARY, SCRIPTURE_CHAPTER_1, STRONG_LIGUOR)) {
             htmltext = "30611-01.html";
           } else if (hasAtLeastOneQuestItem(player, TRIFFS_RING, SYMBOL_OF_CRONOS)) {
             htmltext = "30611-05.html";
           }
           break;
         }
       case ELDER_CASIAN:
         {
           if (hasQuestItems(player, TRIFFS_RING, POITANS_NOTES)) {
             if (!hasQuestItems(player, CASIANS_LIST)) {
               if (hasQuestItems(
                   player, SCRIPTURE_CHAPTER_1, SCRIPTURE_CHAPTER_2, SCRIPTURE_CHAPTER_3)) {
                 htmltext = "30612-02.html";
               } else {
                 htmltext = "30612-01.html";
               }
             } else {
               if ((getQuestItemsCount(player, GHOULS_SKIN)
                       + getQuestItemsCount(player, MEDUSAS_BLOOD)
                       + getQuestItemsCount(player, FETTERED_SOULS_ICHOR)
                       + getQuestItemsCount(player, ENCHANTED_GARGOYLES_NAIL))
                   < 32) {
                 htmltext = "30612-05.html";
               } else {
                 htmltext = "30612-06.html";
               }
             }
           } else if (hasQuestItems(
                   player,
                   TRIFFS_RING,
                   SCRIPTURE_CHAPTER_1,
                   SCRIPTURE_CHAPTER_2,
                   SCRIPTURE_CHAPTER_3,
                   SCRIPTURE_CHAPTER_4)
               && !hasAtLeastOneQuestItem(player, POITANS_NOTES, CASIANS_LIST)) {
             htmltext = "30612-08.html";
           }
           break;
         }
     }
   } else if (qs.isCompleted()) {
     if (npc.getId() == MAGISTER_MIRIEN) {
       htmltext = getAlreadyCompletedMsg(player);
     }
   }
   return htmltext;
 }
 @Override
 public String onTalk(L2Npc npc, L2PcInstance player) {
   final QuestState qs = getQuestState(player, true);
   final int memoState = qs.getMemoState();
   String htmltext = getNoQuestMsg(player);
   if (qs.isCreated()) {
     if (npc.getId() == IRON_GATES_LOCKIRIN) {
       if (player.getClassId() == ClassId.artisan) {
         if (player.getLevel() >= MIN_LEVEL) {
           htmltext = "30531-03.htm";
         } else {
           htmltext = "30531-01.html";
         }
       } else {
         htmltext = "30531-02.html";
       }
     }
   } else if (qs.isStarted()) {
     switch (npc.getId()) {
       case IRON_GATES_LOCKIRIN:
         {
           if ((memoState >= 1)
               && !hasQuestItems(
                   player,
                   RECOMMENDATION_OF_BALANKI,
                   RECOMMENDATION_OF_FILAUR,
                   RECOMMENDATION_OF_ARIN)) {
             htmltext = "30531-05.html";
           } else if (hasQuestItems(
               player,
               RECOMMENDATION_OF_BALANKI,
               RECOMMENDATION_OF_FILAUR,
               RECOMMENDATION_OF_ARIN)) {
             giveAdena(player, 372154, true);
             giveItems(player, MARK_OF_MAESTRO, 1);
             addExpAndSp(player, 2085244, 141240);
             qs.exitQuest(false, true);
             player.sendPacket(new SocialAction(player.getObjectId(), 3));
             htmltext = "30531-06.html";
           }
           break;
         }
       case GOLDEN_WHEELS_SPIRON:
         {
           htmltext = "30532-01.html";
           break;
         }
       case SILVER_SCALES_BALANKI:
         {
           if ((memoState == 1) && !hasQuestItems(player, RECOMMENDATION_OF_BALANKI)) {
             htmltext = "30533-01.html";
           } else if (memoState == 2) {
             if (!hasQuestItems(player, LETTER_OF_SOLDER_DERACHMENT)) {
               htmltext = "30533-03.html";
             } else {
               giveItems(player, RECOMMENDATION_OF_BALANKI, 1);
               takeItems(player, LETTER_OF_SOLDER_DERACHMENT, 1);
               qs.setMemoState(1);
               if (hasQuestItems(player, RECOMMENDATION_OF_ARIN, RECOMMENDATION_OF_FILAUR)) {
                 qs.setCond(2, true);
               }
               htmltext = "30533-04.html";
             }
           } else if (hasQuestItems(player, RECOMMENDATION_OF_BALANKI)) {
             htmltext = "30533-05.html";
           }
           break;
         }
       case BRONZE_KEYS_KEEF:
         {
           htmltext = "30534-01.html";
           break;
         }
       case GRAY_PILLAR_MEMBER_FILAUR:
         {
           if ((memoState == 1) && !hasQuestItems(player, RECOMMENDATION_OF_FILAUR)) {
             giveItems(player, ARCHITECTURE_OF_CRUMA, 1);
             qs.setMemoState(4);
             htmltext = "30535-01.html";
           } else if (memoState == 4) {
             if (hasQuestItems(player, ARCHITECTURE_OF_CRUMA)
                 && !hasQuestItems(player, REPORT_OF_CRUMA)) {
               htmltext = "30535-02.html";
             } else if (hasQuestItems(player, REPORT_OF_CRUMA)
                 && !hasQuestItems(player, ARCHITECTURE_OF_CRUMA)) {
               giveItems(player, RECOMMENDATION_OF_FILAUR, 1);
               takeItems(player, REPORT_OF_CRUMA, 1);
               qs.setMemoState(1);
               if (hasQuestItems(player, RECOMMENDATION_OF_BALANKI, RECOMMENDATION_OF_ARIN)) {
                 qs.setCond(2, true);
               }
               htmltext = "30535-03.html";
             }
           } else if (hasQuestItems(player, RECOMMENDATION_OF_FILAUR)) {
             htmltext = "30535-04.html";
           }
           break;
         }
       case BLACK_ANVILS_ARIN:
         {
           if ((memoState == 1) && !hasQuestItems(player, RECOMMENDATION_OF_ARIN)) {
             giveItems(player, PAINT_OF_TELEPORT_DEVICE, 1);
             qs.setMemoState(3);
             htmltext = "30536-01.html";
           } else if (memoState == 3) {
             if (hasQuestItems(player, PAINT_OF_TELEPORT_DEVICE)
                 && !hasQuestItems(player, TELEPORT_DEVICE)) {
               htmltext = "30536-02.html";
             } else if (getQuestItemsCount(player, TELEPORT_DEVICE) >= 5) {
               giveItems(player, RECOMMENDATION_OF_ARIN, 1);
               takeItems(player, TELEPORT_DEVICE, -1);
               qs.setMemoState(1);
               if (hasQuestItems(player, RECOMMENDATION_OF_BALANKI, RECOMMENDATION_OF_FILAUR)) {
                 qs.setCond(2, true);
               }
               htmltext = "30536-03.html";
             }
           } else if (hasQuestItems(player, RECOMMENDATION_OF_ARIN)) {
             htmltext = "30536-04.html";
           }
           break;
         }
       case MASTER_TOMA:
         {
           if (memoState == 3) {
             if (hasQuestItems(player, PAINT_OF_TELEPORT_DEVICE)) {
               htmltext = "30556-01.html";
             } else if (hasQuestItems(player, BROKEN_TELEPORT_DEVICE)) {
               giveItems(player, TELEPORT_DEVICE, 5);
               takeItems(player, BROKEN_TELEPORT_DEVICE, 1);
               htmltext = "30556-06.html";
             } else if (getQuestItemsCount(player, TELEPORT_DEVICE) == 5) {
               htmltext = "30556-07.html";
             }
           }
           break;
         }
       case CHIEF_CROTO:
         {
           if ((memoState == 2)
               && !hasAtLeastOneQuestItem(
                   player, PAINT_OF_KAMURU, NECKLACE_OF_KAMUTU, LETTER_OF_SOLDER_DERACHMENT)) {
             htmltext = "30671-01.html";
           } else if (hasQuestItems(player, PAINT_OF_KAMURU)
               && !hasQuestItems(player, NECKLACE_OF_KAMUTU)) {
             htmltext = "30671-03.html";
           } else if (hasQuestItems(player, NECKLACE_OF_KAMUTU)) {
             giveItems(player, LETTER_OF_SOLDER_DERACHMENT, 1);
             takeItems(player, NECKLACE_OF_KAMUTU, 1);
             takeItems(player, PAINT_OF_KAMURU, 1);
             htmltext = "30671-04.html";
           } else if (hasQuestItems(player, LETTER_OF_SOLDER_DERACHMENT)) {
             htmltext = "30671-05.html";
           }
           break;
         }
       case JAILER_DUBABAH:
         {
           if (hasQuestItems(player, PAINT_OF_KAMURU)) {
             htmltext = "30672-01.html";
           }
           break;
         }
       case RESEARCHER_LORAIN:
         {
           if (memoState == 4) {
             if (hasQuestItems(player, ARCHITECTURE_OF_CRUMA)
                 && !hasAtLeastOneQuestItem(player, INGREDIENTS_OF_ANTIDOTE, REPORT_OF_CRUMA)) {
               giveItems(player, INGREDIENTS_OF_ANTIDOTE, 1);
               takeItems(player, ARCHITECTURE_OF_CRUMA, 1);
               htmltext = "30673-01.html";
             } else if (hasQuestItems(player, INGREDIENTS_OF_ANTIDOTE)
                 && !hasQuestItems(player, REPORT_OF_CRUMA)) {
               if ((getQuestItemsCount(player, STINGER_WASP_NEEDLE) >= 10)
                   && (getQuestItemsCount(player, MARSH_SPIDERS_WEB) >= 10)
                   && (getQuestItemsCount(player, BLOOD_OF_LEECH) >= 10)) {
                 htmltext = "30673-03.html";
               } else {
                 htmltext = "30673-02.html";
               }
             } else if (hasQuestItems(player, REPORT_OF_CRUMA)) {
               htmltext = "30673-05.html";
             }
           }
           break;
         }
     }
   } else if (qs.isCompleted()) {
     if (npc.getId() == IRON_GATES_LOCKIRIN) {
       htmltext = getAlreadyCompletedMsg(player);
     }
   }
   return htmltext;
 }
  @Override
  public String onAdvEvent(String event, L2Npc npc, L2PcInstance player) {
    final QuestState qs = getQuestState(player, false);
    if (qs == null) {
      return null;
    }

    String htmltext = null;
    switch (event) {
      case "ACCEPT":
        {
          if (player.getClassId() == ClassId.darkFighter) {
            if (player.getLevel() >= MIN_LEVEL) {
              if (hasQuestItems(player, GAZE_OF_ABYSS)) {
                htmltext = "30329-04.htm";
              } else {
                htmltext = "30329-05.htm";
              }
            } else {
              htmltext = "30329-02.htm";
            }
          } else if (player.getClassId() == ClassId.palusKnight) {
            htmltext = "30329-02a.htm";
          } else {
            htmltext = "30329-03.htm";
          }
          break;
        }
      case "30329-06.htm":
        {
          qs.startQuest();
          giveItems(player, PALLUS_TALISMAN, 1);
          htmltext = event;
          break;
        }
      case "30329-10.html":
        {
          if (hasQuestItems(player, PALLUS_TALISMAN, LYCANTHROPE_SKULL)) {
            takeItems(player, PALLUS_TALISMAN, 1);
            takeItems(player, LYCANTHROPE_SKULL, -1);
            giveItems(player, VIRGILS_LETTER, 1);
            qs.setCond(3, true);
            htmltext = event;
          }
          break;
        }
      case "30422-02.html":
        {
          if (hasQuestItems(player, VIRGILS_LETTER)) {
            takeItems(player, VIRGILS_LETTER, 1);
            giveItems(player, MORTE_TALISMAN, 1);
            qs.setCond(4, true);
            htmltext = event;
          }
          break;
        }
      case "30422-06.html":
        {
          if (hasQuestItems(
              player, MORTE_TALISMAN, ARACHNID_TRACKER_SILK, VENOMOUS_SPIDERS_CARAPACE)) {
            takeItems(player, MORTE_TALISMAN, 1);
            takeItems(player, VENOMOUS_SPIDERS_CARAPACE, 1);
            takeItems(player, ARACHNID_TRACKER_SILK, -1);
            giveItems(player, COFFIN_OF_ETERNAL_REST, 1);
            qs.setCond(6, true);
            htmltext = event;
          }
          break;
        }
    }
    return htmltext;
  }
  @Override
  public String onAdvEvent(String event, L2Npc npc, L2PcInstance player) {
    final QuestState qs = getQuestState(player, false);
    if (qs == null) {
      return null;
    }

    String htmltext = null;
    switch (event) {
      case "ACCEPT":
        {
          if (player.getClassId() == ClassId.ELVEN_MAGE) {
            if (player.getLevel() >= MIN_LEVEL) {
              if (hasQuestItems(player, LEAF_OF_ORACLE)) {
                htmltext = "30293-04.htm";
              } else {
                qs.startQuest();
                qs.setMemoState(1);
                giveItems(player, CRYSTAL_MEDALLION, 1);
                htmltext = "30293-05.htm";
              }
            } else {
              htmltext = "30293-03.htm";
            }
          } else if (player.getClassId() == ClassId.ORACLE) {
            htmltext = "30293-02a.htm";
          } else {
            htmltext = "30293-02.htm";
          }
          break;
        }
      case "30424-08.html":
      case "30424-09.html":
        {
          htmltext = event;
          break;
        }
      case "30424-07.html":
        {
          if (qs.isMemoState(1)) {
            htmltext = event;
          }
          break;
        }
      case "replay_1":
        {
          qs.setMemoState(2);
          addAttackPlayerDesire(addSpawn(lIZARDMAN_WARRIOR, npc, true, 0, false), player);
          addAttackPlayerDesire(addSpawn(LIZARDMAN_SCOUT, npc, true, 0, false), player);
          addAttackPlayerDesire(addSpawn(LIZARDMAN_SOLDIER, npc, true, 0, false), player);
          break;
        }
      case "30428-02.html":
      case "30428-03.html":
        {
          if (qs.isMemoState(2)) {
            htmltext = event;
          }
          break;
        }
      case "replay_2":
        {
          if (qs.isMemoState(2)) {
            qs.setMemoState(3);
            addAttackPlayerDesire(addSpawn(TAMIL, npc, true, 0, true), player);
          }
          break;
        }
    }
    return htmltext;
  }
 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;
 }
  @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);
  }
  private void initNewChar(L2GameClient client, L2PcInstance newChar) {
    if (Config.DEBUG) _log.fine("Character init start");

    L2World.getInstance().storeObject(newChar);

    L2PcTemplate template = newChar.getTemplate();

    newChar.addAdena("Init", Config.STARTING_ADENA, null, false);

    newChar.setXYZInvisible(template.spawnX, template.spawnY, template.spawnZ);
    newChar.setTitle("");

    if (Config.ENABLE_VITALITY)
      newChar.setVitalityPoints(
          Math.min(Config.STARTING_VITALITY_POINTS, PcStat.MAX_VITALITY_POINTS), true);

    if (Config.STARTING_LEVEL > 1) {
      newChar.getStat().addLevel((byte) (Config.STARTING_LEVEL - 1));
    }
    if (Config.STARTING_SP > 0) {
      newChar.getStat().addSp(Config.STARTING_SP);
    }

    L2ShortCut shortcut;
    // add attack shortcut
    shortcut = new L2ShortCut(0, 0, 3, 2, 0, 1);
    newChar.registerShortCut(shortcut);
    // add take shortcut
    shortcut = new L2ShortCut(3, 0, 3, 5, 0, 1);
    newChar.registerShortCut(shortcut);
    // add sit shortcut
    shortcut = new L2ShortCut(10, 0, 3, 0, 0, 1);
    newChar.registerShortCut(shortcut);

    for (PcTemplateItem ia : template.getItems()) {
      L2ItemInstance item =
          newChar.getInventory().addItem("Init", ia.getItemId(), ia.getAmount(), newChar, null);

      if (item == null) {
        _log.warning(
            "Could not create item during char creation: itemId "
                + ia.getItemId()
                + ", amount "
                + ia.getAmount()
                + ".");
        continue;
      }

      // add tutbook shortcut
      if (item.getItemId() == 5588) {
        shortcut = new L2ShortCut(11, 0, 1, item.getObjectId(), 0, 1);
        newChar.registerShortCut(shortcut);
      }

      if (item.isEquipable() && ia.isEquipped()) {
        newChar.getInventory().equipItem(item);
      }
    }

    for (L2SkillLearn skill :
        SkillTreesData.getInstance()
            .getAvailableSkills(newChar, newChar.getClassId(), false, true)) {
      newChar.addSkill(
          SkillTable.getInstance().getInfo(skill.getSkillId(), skill.getSkillLevel()), true);
      if (skill.getSkillId() == 1001 || skill.getSkillId() == 1177) {
        shortcut = new L2ShortCut(1, 0, 2, skill.getSkillId(), skill.getSkillLevel(), 1);
        newChar.registerShortCut(shortcut);
      }
      if (skill.getSkillId() == 1216) {
        shortcut = new L2ShortCut(10, 0, 2, skill.getSkillId(), skill.getSkillLevel(), 1);
        newChar.registerShortCut(shortcut);
      }
      if (Config.DEBUG)
        _log.fine("Adding starter skill:" + skill.getSkillId() + " / " + skill.getSkillLevel());
    }

    if (!Config.DISABLE_TUTORIAL) startTutorialQuest(newChar);

    newChar.setOnlineStatus(true, false);
    newChar.deleteMe();

    CharSelectionInfo cl =
        new CharSelectionInfo(client.getAccountName(), client.getSessionId().playOkID1);
    client.getConnection().sendPacket(cl);
    client.setCharSelection(cl.getCharInfo());

    if (Config.DEBUG) _log.fine("Character init end");
  }