content.append("<a action=\"bypass -h npc_" + getObjectId() + "_Subclass 5 0\">" + CharTemplateTable.getClassNameById(baseClassId) + "</a> " + "<font color=\"LEVEL\">(Base Class)</font><br><br>");
}
for(Iterator<SubClass> subList = iterSubClasses(player); subList.hasNext();)
{
SubClass subClass = subList.next();
int subClassId = subClass.getClassId();
if(subClassId == player.getActiveClass())
{
content.append(CharTemplateTable.getClassNameById(subClassId) + "<br>");
}
else
{
content.append("<a action=\"bypass -h npc_" + getObjectId() + "_Subclass 5 " + subClass.getClassIndex() + "\">" + CharTemplateTable.getClassNameById(subClassId) + "</a><br>");
}
}
}
break;
case 3: // Change/Cancel Subclass - Initial
content.append("Change Subclass:<br>Which of the following sub classes would you like to change?<br>");
int classIndex = 1;
for(Iterator<SubClass> subList = iterSubClasses(player); subList.hasNext();)
{
SubClass subClass = subList.next();
content.append("Sub-class " + classIndex + "<br1>");
content.append("<a action=\"bypass -h npc_" + getObjectId() + "_Subclass 6 " + subClass.getClassIndex() + "\">" + CharTemplateTable.getClassNameById(subClass.getClassId()) + "</a><br>");
classIndex++;
}
content.append("<br>If you change a sub class, you'll start at level 40 after the 2nd class transfer.");
break;
case 4: // Add Subclass - Action (Subclass 4 x[x])
/*
* If the character is less than level 75 on any of their previously chosen
* classes then disallow them to change to their most recently added sub-class choice.
*/
// Fix exploit stuck subclass and skills
if(player.isLearningSkill() || player.isLocked())
return;
player.setLocked(true);
boolean allowAddition = true;
if (player._inEventRaid)
{
player.sendMessage("Come back later when the Raid Event is over.");
return;
}
// Subclass exploit fix during add subclass
if (!player.getFloodProtectors().getSubclass().tryPerformAction("add subclass"))
{
_log.warning("Player "+player.getName()+" has performed a subclass change too fast");
player.setLocked(false);
return;
}
// You can't add Subclass when you are registered in Events (TVT, CTF, DM)
if(player._inEventTvT || player._inEventCTF || player._inEventDM)
{
player.sendMessage("You can't add a subclass while in an event.");
player.setLocked(false);
return;
}
// Check player level
if(player.getLevel() < 75)
{
player.sendMessage("You may not add a new sub class before you are level 75 on your previous class.");
allowAddition = false;
}
// You can't add Subclass when you are registered in Olympiad
if(Olympiad.getInstance().isRegisteredInComp(player) || player.getOlympiadGameId() > 0)
{
player.sendPacket(new SystemMessage(SystemMessageId.YOU_HAVE_ALREADY_BEEN_REGISTERED_IN_A_WAITING_LIST_OF_AN_EVENT));
player.setLocked(false);
return;
}
if(allowAddition)
{
if(!player.getSubClasses().isEmpty())
{
for(Iterator<SubClass> subList = iterSubClasses(player); subList.hasNext();)
{
SubClass subClass = subList.next();
if(subClass.getLevel() < 75)
{
player.sendMessage("You may not add a new sub class before you are level 75 on your previous sub class.");
allowAddition = false;
break;
}
}
}
}
/*
* If quest checking is enabled, verify if the character has completed the Mimir's Elixir (Path to Subclass)
* and Fate's Whisper (A Grade Weapon) quests by checking for instances of their unique reward items.
*
* If they both exist, remove both unique items and continue with adding the sub-class.
*/
if(!Config.ALT_GAME_SUBCLASS_WITHOUT_QUESTS)
{
QuestState qs = player.getQuestState("235_MimirsElixir");
if(qs == null || !qs.isCompleted())
{
player.sendMessage("You must have completed the Mimir's Elixir quest to continue adding your sub class.");
player.setLocked(false);
return;
}
qs = player.getQuestState("234_FatesWhisper");
if(qs == null || !qs.isCompleted())
{
player.sendMessage("You must have completed the Fate's Whisper quest to continue adding your sub class.");
player.setLocked(false);
return;
}
}
if(allowAddition)
{
String className = CharTemplateTable.getClassNameById(paramOne);
if(!player.addSubClass(paramOne, player.getTotalSubClasses() + 1))
{
player.sendMessage("The sub class could not be added.");
player.setLocked(false);
return;
}
player.setActiveClass(player.getTotalSubClasses());
if(Config.CHECK_SKILLS_ON_ENTER && !Config.ALT_GAME_SKILL_LEARN)
{
player.checkAllowedSkills();
}
content.append("Add Subclass:<br>The sub class of <font color=\"LEVEL\">" + className + "</font> has been added.");
player.sendPacket(new SystemMessage(SystemMessageId.CLASS_TRANSFER)); // Transfer to new class.
className = null;
}
else
{
html.setFile("data/html/villagemaster/SubClass_Fail.htm");
}
player.setLocked(false);
break;
case 5: // Change Class - Action
/*
* If the character is less than level 75 on any of their previously chosen
* classes then disallow them to change to their most recently added sub-class choice.
*
* Note: paramOne = classIndex
*/
if (player._inEventRaid)
{
player.sendMessage("Come back later when the Raid Event is over.");
return;
}
// Fix exploit stuck subclass and skills
if(player.isLearningSkill() || player.isLocked())
return;
player.setLocked(true);
// Subclass exploit fix during change subclass
if (!player.getFloodProtectors().getSubclass().tryPerformAction("change subclass"))
{
_log.warning("Player "+player.getName()+" has performed a subclass change too fast");
player.setLocked(false);
return;
}
// You can't change Subclass when you are registered in Events (TVT, CTF, DM)
if(player._inEventTvT || player._inEventCTF || player._inEventDM)
{
player.sendMessage("You can't change subclass while in an event.");
player.setLocked(false);
return;
}
// You can't change Subclass when you are registered in Olympiad
if(Olympiad.getInstance().isRegisteredInComp(player) || player.getOlympiadGameId() > 0)
{
player.sendPacket(new SystemMessage(SystemMessageId.YOU_HAVE_ALREADY_BEEN_REGISTERED_IN_A_WAITING_LIST_OF_AN_EVENT));
player.setLocked(false);
return;
}
player.setActiveClass(paramOne);
content.append("Change Subclass:<br>Your active sub class is now a <font color=\"LEVEL\">" + CharTemplateTable.getClassNameById(player.getActiveClass()) + "</font>.");
player.sendPacket(new SystemMessage(SystemMessageId.SUBCLASS_TRANSFER_COMPLETED)); // Transfer completed.
// check player skills
if(Config.CHECK_SKILLS_ON_ENTER && !Config.ALT_GAME_SKILL_LEARN)
{
player.checkAllowedSkills();
}
player.setLocked(false);
break;
case 6: // Change/Cancel Subclass - Choice
content.append("Please choose a sub class to change to. If the one you are looking for is not here, " + "please seek out the appropriate master for that class.<br>" + "<font color=\"LEVEL\">Warning!</font> All classes and skills for this class will be removed.<br><br>");
subsAvailable = getAvailableSubClasses(player);
if(subsAvailable != null && !subsAvailable.isEmpty())
{
for(PlayerClass subClass : subsAvailable)
{
content.append("<a action=\"bypass -h npc_" + getObjectId() + "_Subclass 7 " + paramOne + " " + subClass.ordinal() + "\">" + formatClassForDisplay(subClass) + "</a><br>");
}
}
else
{
player.sendMessage("There are no sub classes available at this time.");