Sync with L2JServer Feb 3rd 2015.

This commit is contained in:
mobius
2015-02-03 21:11:57 +00:00
parent 9cf1a6d6e5
commit fe25f74122
169 changed files with 3379 additions and 5414 deletions

View File

@@ -2,9 +2,8 @@
I am Avant-Garde, the Transformation Wizard. I have long wandered through the land and only recently settled here.<br>
In fact, my young friend, I am not a wizard of the Ivory Tower. You look surprised! Heh. Think of me as a wanderer who acquired a special power quite by chance... My magic, however, requires some very specialized items.<br>
If you have acquired these unique items from the dark wizard in Hardin's Academy, then perhaps I can help you.<br>
<Button ALIGN=LEFT ICON="NORMAL" action="bypass -h Quest AvantGarde 32323-02.html">Ask about transformation.</Button>
<Button ALIGN=LEFT ICON="NORMAL" action="bypass -h Quest AvantGarde LearnTransformationSkill">Learn transformation.</Button>
<Button ALIGN=LEFT ICON="NORMAL" action="bypass -h Quest AvantGarde BuyTransformationItems">Purchase items related to transformation.</Button>
<Button ALIGN=LEFT ICON="NORMAL" action="bypass -h Quest AvantGarde 32323-05a.html">Learn about subclass certification.</Button>
<Button ALIGN=LEFT ICON="QUEST" action="bypass -h npc_%objectId%_Quest">Quest.</Button>
<a action="bypass -h Quest AvantGarde 32323-02.html">Ask about transformation.</a><br>
<a action="bypass -h Quest AvantGarde LearnTransformationSkill">Learn transformation.</a><br>
<a action="bypass -h Quest AvantGarde BuyTransformationItems">Purchase items related to transformation.</a><br>
<a action="bypass -h npc_%objectId%_Quest">Quest.</a>
</body></html>

View File

@@ -22,25 +22,17 @@ import java.util.List;
import ai.npc.AbstractNpcAI;
import com.l2jserver.Config;
import com.l2jserver.gameserver.data.xml.impl.MultisellData;
import com.l2jserver.gameserver.data.xml.impl.SkillTreesData;
import com.l2jserver.gameserver.datatables.SkillData;
import com.l2jserver.gameserver.instancemanager.QuestManager;
import com.l2jserver.gameserver.model.L2SkillLearn;
import com.l2jserver.gameserver.model.actor.L2Npc;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.base.AcquireSkillType;
import com.l2jserver.gameserver.model.items.instance.L2ItemInstance;
import com.l2jserver.gameserver.model.quest.QuestState;
import com.l2jserver.gameserver.model.skills.Skill;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.gameserver.network.clientpackets.RequestAcquireSkill;
import com.l2jserver.gameserver.network.serverpackets.ExAcquirableSkillListByClass;
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
import com.l2jserver.gameserver.util.Util;
import custom.Validators.SubClassSkills;
/**
* Avant-Garde AI.<br>
@@ -52,21 +44,6 @@ public final class AvantGarde extends AbstractNpcAI
{
// NPC
private static final int AVANT_GARDE = 32323;
// Items
// @formatter:off
private static final int[] ITEMS =
{
10280, 10281, 10282, 10283, 10284, 10285, 10286, 10287, 10288, 10289, 10290, 10291, 10292, 10293, 10294, 10612
};
// @formatter:on
// Misc
private static final String[] QUEST_VAR_NAMES =
{
"EmergentAbility65-",
"EmergentAbility70-",
"ClassAbility75-",
"ClassAbility80-"
};
public AvantGarde()
{
@@ -80,18 +57,9 @@ public final class AvantGarde extends AbstractNpcAI
@Override
public String onAcquireSkill(L2Npc npc, L2PcInstance player, Skill skill, AcquireSkillType type)
{
switch (type)
if (type.equals(AcquireSkillType.TRANSFORM))
{
case TRANSFORM:
{
showTransformSkillList(player);
break;
}
case SUBCLASS:
{
showSubClassSkillList(player);
break;
}
showTransformSkillList(player);
}
return null;
}
@@ -107,7 +75,6 @@ public final class AvantGarde extends AbstractNpcAI
case "32323-02b.html":
case "32323-02c.html":
case "32323-05.html":
case "32323-05a.html":
case "32323-05no.html":
case "32323-06.html":
case "32323-06no.html":
@@ -139,153 +106,6 @@ public final class AvantGarde extends AbstractNpcAI
}
break;
}
case "LearnSubClassSkill":
{
if (!RequestAcquireSkill.canTransform(player))
{
htmltext = "32323-04.html";
}
if (player.isSubClassActive())
{
htmltext = "32323-08.html";
}
else
{
boolean hasItems = false;
for (int id : ITEMS)
{
if (player.getInventory().getItemByItemId(id) != null)
{
hasItems = true;
break;
}
}
if (hasItems)
{
showSubClassSkillList(player);
}
else
{
htmltext = "32323-08.html";
}
}
break;
}
case "CancelCertification":
{
if (player.getSubClasses().size() == 0)
{
htmltext = "32323-07.html";
}
else if (player.isSubClassActive())
{
htmltext = "32323-08.html";
}
else if (player.getAdena() < Config.FEE_DELETE_SUBCLASS_SKILLS)
{
htmltext = "32323-08no.html";
}
else
{
QuestState st = player.getQuestState(SubClassSkills.class.getSimpleName());
if (st == null)
{
st = QuestManager.getInstance().getQuest(SubClassSkills.class.getSimpleName()).newQuestState(player);
}
int activeCertifications = 0;
for (String varName : QUEST_VAR_NAMES)
{
for (int i = 1; i <= Config.MAX_SUBCLASS; i++)
{
String qvar = st.getGlobalQuestVar(varName + i);
if (!qvar.isEmpty() && (qvar.endsWith(";") || !qvar.equals("0")))
{
activeCertifications++;
}
}
}
if (activeCertifications == 0)
{
htmltext = "32323-10no.html";
}
else
{
for (String varName : QUEST_VAR_NAMES)
{
for (int i = 1; i <= Config.MAX_SUBCLASS; i++)
{
final String qvarName = varName + i;
final String qvar = st.getGlobalQuestVar(qvarName);
if (qvar.endsWith(";"))
{
final String skillIdVar = qvar.replace(";", "");
if (Util.isDigit(skillIdVar))
{
int skillId = Integer.parseInt(skillIdVar);
final Skill sk = SkillData.getInstance().getSkill(skillId, 1);
if (sk != null)
{
player.removeSkill(sk);
st.saveGlobalQuestVar(qvarName, "0");
}
}
else
{
_log.warning("Invalid Sub-Class Skill Id: " + skillIdVar + " for player " + player.getName() + "!");
}
}
else if (!qvar.isEmpty() && !qvar.equals("0"))
{
if (Util.isDigit(qvar))
{
final int itemObjId = Integer.parseInt(qvar);
L2ItemInstance itemInstance = player.getInventory().getItemByObjectId(itemObjId);
if (itemInstance != null)
{
player.destroyItem("CancelCertification", itemObjId, 1, player, false);
}
else
{
itemInstance = player.getWarehouse().getItemByObjectId(itemObjId);
if (itemInstance != null)
{
_log.warning("Somehow " + player.getName() + " put a certification book into warehouse!");
player.getWarehouse().destroyItem("CancelCertification", itemInstance, 1, player, false);
}
else
{
_log.warning("Somehow " + player.getName() + " deleted a certification book!");
}
}
st.saveGlobalQuestVar(qvarName, "0");
}
else
{
_log.warning("Invalid item object Id: " + qvar + " for player " + player.getName() + "!");
}
}
}
}
player.reduceAdena("Cleanse", Config.FEE_DELETE_SUBCLASS_SKILLS, npc, true);
htmltext = "32323-09no.html";
player.sendSkillList();
}
// Let's consume all certification books, even those not present in database.
for (int itemId : ITEMS)
{
L2ItemInstance item = player.getInventory().getItemByItemId(itemId);
if (item != null)
{
_log.warning(getClass().getName() + ": player " + player + " had 'extra' certification skill books while cancelling sub-class certifications!");
player.destroyItem("CancelCertificationExtraBooks", item, npc, false);
}
}
}
break;
}
}
return htmltext;
}
@@ -302,24 +122,6 @@ public final class AvantGarde extends AbstractNpcAI
return "32323-01.html";
}
/**
* Display the Sub-Class Skill list to the player.
* @param player the player
*/
public static void showSubClassSkillList(L2PcInstance player)
{
final List<L2SkillLearn> subClassSkills = SkillTreesData.getInstance().getAvailableSubClassSkills(player);
if (subClassSkills.isEmpty())
{
player.sendPacket(SystemMessageId.THERE_ARE_NO_OTHER_SKILLS_TO_LEARN);
}
else
{
player.sendPacket(new ExAcquirableSkillListByClass(subClassSkills, AcquireSkillType.TRANSFORM));
}
}
/**
* This displays Transformation Skill List to the player.
* @param player the active character.

View File

@@ -21,7 +21,6 @@ package ai.npc.AwakeningMaster;
import quests.Q10338_SeizeYourDestiny.Q10338_SeizeYourDestiny;
import ai.npc.AbstractNpcAI;
import com.l2jserver.Config;
import com.l2jserver.gameserver.ThreadPoolManager;
import com.l2jserver.gameserver.data.xml.impl.SkillTreesData;
import com.l2jserver.gameserver.enums.CategoryType;
@@ -86,14 +85,13 @@ public final class AwakeningMaster extends AbstractNpcAI
{
return null;
}
String htmltext = null;
switch (event)
{
case "awakening":
{
final QuestState st2 = player.getQuestState(Q10338_SeizeYourDestiny.class.getSimpleName());
if ((!Config.NEED_SCROLL_OF_AFTERLIFE_FOR_AWAKEN || st.hasQuestItems(SCROLL_OF_AFTERLIFE)) && (player.getLevel() > 84) && (!player.isSubClassActive() || player.isDualClassActive()) && player.isInCategory(CategoryType.FOURTH_CLASS_GROUP) && (!Config.NEED_SEIZE_YOUR_DESTINY_FOR_AWAKEN || ((st2 != null) && st2.isCompleted())))
if (st.hasQuestItems(SCROLL_OF_AFTERLIFE) && (player.getLevel() > 84) && (!player.isSubClassActive() || player.isDualClassActive()) && player.isInCategory(CategoryType.FOURTH_CLASS_GROUP) && (st2 != null) && st2.isCompleted())
{
switch (npc.getId())
{
@@ -194,14 +192,11 @@ public final class AwakeningMaster extends AbstractNpcAI
return;
}
if (Config.NEED_SEIZE_YOUR_DESTINY_FOR_AWAKEN)
final QuestState st = player.getQuestState(Q10338_SeizeYourDestiny.class.getSimpleName());
if ((st == null) || !st.isCompleted())
{
final QuestState st = player.getQuestState(Q10338_SeizeYourDestiny.class.getSimpleName());
if ((st == null) || !st.isCompleted())
{
return;
}
return;
}
if (player.isHero() || Hero.getInstance().isUnclaimedHero(player.getObjectId()))
@@ -222,23 +217,28 @@ public final class AwakeningMaster extends AbstractNpcAI
return;
}
if (Config.NEED_SCROLL_OF_AFTERLIFE_FOR_AWAKEN)
final L2ItemInstance item = player.getInventory().getItemByItemId(SCROLL_OF_AFTERLIFE);
if (item == null)
{
final L2ItemInstance item = player.getInventory().getItemByItemId(SCROLL_OF_AFTERLIFE);
if (item == null)
{
return;
}
if (!player.destroyItem("Awakening", item, player, true))
{
return;
}
return;
}
if (!player.destroyItem("Awakening", item, player, true))
{
return;
}
for (ClassId newClass : player.getClassId().getNextClassIds())
{
player.setClassId(newClass.getId());
if (player.isDualClassActive())
{
player.getSubClasses().get(player.getClassIndex()).setClassId(player.getActiveClass());
}
else
{
player.setBaseClass(player.getActiveClass());
}
player.sendPacket(SystemMessageId.CONGRATULATIONS_YOU_VE_COMPLETED_A_CLASS_TRANSFER);
final UserInfo ui = new UserInfo(player, false);
ui.addComponentType(UserInfoType.BASIC_INFO);

View File

@@ -112,14 +112,14 @@ public final class Minigame extends AbstractNpcAI
{
if (npc.getId() == BURNER)
{
npc.setDisplayEffect(2);
npc.setState(2);
npc.setIsRunning(false);
}
else
{
for (L2Npc burner : room.getBurners())
{
burner.setDisplayEffect(2);
burner.setState(2);
burner.setIsRunning(false);
}
}
@@ -147,7 +147,7 @@ public final class Minigame extends AbstractNpcAI
if (room.getCurrentPot() < 9)
{
L2Npc b = room.getBurners()[room.getOrder()[room.getCurrentPot()]];
b.setDisplayEffect(1);
b.setState(1);
b.setIsRunning(false);
startQuestTimer("off", 2000, b, null); // Stopping burning each pot 2s after
startQuestTimer("timer", TIMER_INTERVAL * 1000, npc, null);
@@ -279,7 +279,7 @@ public final class Minigame extends AbstractNpcAI
{
if (room.getCurrentPot() < 8)
{
npc.setDisplayEffect(1);
npc.setState(1);
npc.setIsRunning(false);
startQuestTimer("off", 2000, npc, null);
room.setCurrentPot(room.getCurrentPot() + 1);
@@ -427,7 +427,7 @@ public final class Minigame extends AbstractNpcAI
{
for (L2Npc burner : _burners)
{
burner.setDisplayEffect(1);
burner.setState(1);
burner.setIsRunning(false);
}
}

View File

@@ -1,10 +0,0 @@
<html><body>Subclass Skill Certification:<br>
Depending on your level, I may be able to certify your subclass.<br>
Take this certification to <font color="LEVEL">Avant-Garde, the Wizard of Transformation in the Ivory Tower</font>, for more information on which skills you will be able to acquire.<br>
Additionally, you will receive the Transformation Sealbook in lieu of ultimate skills.<br>
Now, what level of certification do you want to obtain?<br>
<Button ALIGN=LEFT ICON="NORMAL" action="bypass -h Quest SubclassCertification Obtain65">Level 65 Emergent Skill certification.</Button>
<Button ALIGN=LEFT ICON="NORMAL" action="bypass -h Quest SubclassCertification Obtain70">Level 70 Emergent Skill certification.</Button>
<Button ALIGN=LEFT ICON="NORMAL" action="bypass -h Quest SubclassCertification Obtain75">Level 75 Master or class-specific Skill certification.</Button>
<Button ALIGN=LEFT ICON="NORMAL" action="bypass -h Quest SubclassCertification Obtain80">Level 80 Divine Transformation certification.</Button>
</body></html>

View File

@@ -1,7 +0,0 @@
<html><body>Subclass Skill Certification:<br>
You are trying to obtain level 75 certification of %class%, common skill or special skill. Remember that once this subclass is certified, it cannot be re-certified -- even if you delete this class and develop another one -- without a special and expensive cancellation process.<br>
Do you still want to be certified?<br>
<Button ALIGN=LEFT ICON="NORMAL" action="bypass -h Quest SubclassCertification lvl75Class">Obtain class specific skill certification.</Button>
<Button ALIGN=LEFT ICON="NORMAL" action="bypass -h Quest SubclassCertification lvl75Master">Obtain master skill certification.</Button>
<Button ALIGN=LEFT ICON="NORMAL" action="bypass -h Quest SubclassCertification NotObtain.html">Do not obtain certification.</Button>
</body></html>

View File

@@ -1,6 +0,0 @@
<html><body>Subclass Skill Certification:<br>
You are trying to obtain level %level% certification of %class%, %skilltype%. Remember that once this subclass is certified, it cannot be re-certified -- even if you delete this class and develop another one -- without a special and expensive cancellation process.<br>
Do you still want to be certified?<br>
<Button ALIGN=LEFT ICON="NORMAL" action="bypass -h Quest SubclassCertification %event%">Obtain certification.</Button>
<Button ALIGN=LEFT ICON="NORMAL" action="bypass -h Quest SubclassCertification NotObtain.html">Do not obtain certification.</Button>
</body></html>

View File

@@ -1,6 +0,0 @@
<html><body>Subclass Skill Certification:<br>
You can be certified at levels 65, 70, 75 and 80. You can practice common skills at Level 65 and 70, common or special skills at Level 75, and ultimate skills at level 80.<br>
Common skills are not occupation specific. They can be learned regardless of class. Special skills and ultimate skills are specific to your occupation.<br>
The effects of skills learned through this certification can overlap each other, even if they are the same kind of skill.<br>
<Button ALIGN=LEFT ICON="NORMAL" action="bypass -h Quest SubclassCertification Main.html">Back.</Button>
</body></html>

View File

@@ -1,5 +0,0 @@
<html><body>Subclass Skill Certification:<br>
This certifies that you has reached the required level.<br>
Take it to <font color="LEVEL">Transformation Wizard Avant-Garde</font>, and you will be able to learn some new skills.<br>
To cancel this certification, simply ask her.
</body></html>

View File

@@ -1,7 +0,0 @@
<html><body>Subclass Skill Certification:<br>
Once you reach a certain level of skill in your subclass, your skills can be certified. As a result, you will be able to learn some special skills which you can use in your main class.<br>
However, each subclass slot can have only <font color="LEVEL">one certification</font>. That means that even if you come back with a different occupation for the subclass, you cannot obtain another certification unless you first spend a <font color="LEVEL">huge amount to cancel the first certification</font>.<br>
If you want to obtain a certification, <font color="LEVEL">your current occupation should be that of the subclass you want to be certified, and you should be above level 65</font>. Now, do you wish to be certified for this subclass?<br>
<Button ALIGN=LEFT ICON="NORMAL" action="bypass -h Quest SubclassCertification Explanation.html">Listen to a detailed explanation about subclass certification.</Button>
<Button ALIGN=LEFT ICON="NORMAL" action="bypass -h Quest SubclassCertification GetCertified">Get certified.</Button>
</body></html>

View File

@@ -1,4 +0,0 @@
<html><body>Subclass Ability Validation:<br>
Your skill level is not yet sufficient to obtain a certificate.<br>
You can get Skill Certificate once you have reached level 65, 70, 75 or 80.
</body></html>

View File

@@ -1,3 +0,0 @@
<html><body>Subclass Ability Validation:<br>
If you want to obtain the certificate, you should come as a form of subclass you wish to apply.
</body></html>

View File

@@ -1,283 +0,0 @@
/*
* Copyright (C) 2004-2015 L2J DataPack
*
* This file is part of L2J DataPack.
*
* L2J DataPack is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* L2J DataPack is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package ai.npc.SubclassCertification;
import java.util.HashMap;
import java.util.Map;
import ai.npc.AbstractNpcAI;
import com.l2jserver.gameserver.data.xml.impl.ClassListData;
import com.l2jserver.gameserver.enums.CategoryType;
import com.l2jserver.gameserver.model.actor.L2Npc;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.actor.instance.L2VillageMasterInstance;
import com.l2jserver.gameserver.model.items.instance.L2ItemInstance;
import com.l2jserver.gameserver.model.quest.QuestState;
import com.l2jserver.gameserver.model.quest.State;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
/**
* Subclass certification
* @author xban1x, jurchiks
*/
public final class SubclassCertification extends AbstractNpcAI
{
// @formatter:off
private static final int[] NPCS =
{
30026, 30031, 30037, 30066, 30070, 30109, 30115, 30120, 30154, 30174,
30175, 30176, 30187, 30191, 30195, 30288, 30289, 30290, 30297, 30358,
30373, 30462, 30474, 30498, 30499, 30500, 30503, 30504, 30505, 30508,
30511, 30512, 30513, 30520, 30525, 30565, 30594, 30595, 30676, 30677,
30681, 30685, 30687, 30689, 30694, 30699, 30704, 30845, 30847, 30849,
30854, 30857, 30862, 30865, 30894, 30897, 30900, 30905, 30910, 30913,
31269, 31272, 31276, 31279, 31285, 31288, 31314, 31317, 31321, 31324,
31326, 31328, 31331, 31334, 31336, 31755, 31958, 31961, 31965, 31968,
31974, 31977, 31996, 32092, 32093, 32094, 32095, 32096, 32097, 32098,
32145, 32146, 32147, 32150, 32153, 32154, 32157, 32158, 32160, 32171,
32193, 32199, 32202, 32213, 32214, 32221, 32222, 32229, 32230, 32233,
32234
};
// @formatter:on
private static final int CERTIFICATE_EMERGENT_ABILITY = 10280;
private static final int CERTIFICATE_MASTER_ABILITY = 10612;
private static final Map<Integer, Integer> ABILITY_CERTIFICATES = new HashMap<>();
private static final Map<Integer, Integer> TRANSFORMATION_SEALBOOKS = new HashMap<>();
static
{
ABILITY_CERTIFICATES.put(0, 10281); // Certificate - Warrior Ability
ABILITY_CERTIFICATES.put(1, 10283); // Certificate - Rogue Ability
ABILITY_CERTIFICATES.put(2, 10282); // Certificate - Knight Ability
ABILITY_CERTIFICATES.put(3, 10286); // Certificate - Summoner Ability
ABILITY_CERTIFICATES.put(4, 10284); // Certificate - Wizard Ability
ABILITY_CERTIFICATES.put(5, 10285); // Certificate - Healer Ability
ABILITY_CERTIFICATES.put(6, 10287); // Certificate - Enchanter Ability
TRANSFORMATION_SEALBOOKS.put(0, 10289); // Transformation Sealbook: Divine Warrior
TRANSFORMATION_SEALBOOKS.put(1, 10290); // Transformation Sealbook: Divine Rogue
TRANSFORMATION_SEALBOOKS.put(2, 10288); // Transformation Sealbook: Divine Knight
TRANSFORMATION_SEALBOOKS.put(3, 10294); // Transformation Sealbook: Divine Summoner
TRANSFORMATION_SEALBOOKS.put(4, 10292); // Transformation Sealbook: Divine Wizard
TRANSFORMATION_SEALBOOKS.put(5, 10291); // Transformation Sealbook: Divine Healer
TRANSFORMATION_SEALBOOKS.put(6, 10293); // Transformation Sealbook: Divine Enchanter
}
private static final int MIN_LVL = 65;
private SubclassCertification()
{
super(SubclassCertification.class.getSimpleName(), "ai/npc");
addStartNpc(NPCS);
addTalkId(NPCS);
}
@Override
public String onTalk(L2Npc npc, L2PcInstance player)
{
final QuestState st = player.getQuestState(getName());
String htmltext = getNoQuestMsg(player);
if (st != null)
{
st.setState(State.STARTED);
htmltext = "Main.html";
}
return htmltext;
}
@Override
public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
{
String htmltext = null;
final QuestState st = player.getQuestState(getName());
if (st == null)
{
return htmltext;
}
switch (event)
{
case "GetCertified":
{
if (!player.isSubClassActive())
{
htmltext = "NotSubclass.html";
}
else if (player.getLevel() < MIN_LVL)
{
htmltext = "NotMinLevel.html";
}
else if (((L2VillageMasterInstance) npc).checkVillageMaster(player.getActiveClass()))
{
htmltext = "CertificationList.html";
}
else
{
htmltext = "WrongVillageMaster.html";
}
break;
}
case "Obtain65":
{
htmltext = replaceHtml(player, "EmergentAbility.html", true, null).replace("%level%", "65").replace("%skilltype%", "common skill").replace("%event%", "lvl65Emergent");
break;
}
case "Obtain70":
{
htmltext = replaceHtml(player, "EmergentAbility.html", true, null).replace("%level%", "70").replace("%skilltype%", "common skill").replace("%event%", "lvl70Emergent");
break;
}
case "Obtain75":
{
htmltext = replaceHtml(player, "ClassAbility.html", true, null);
break;
}
case "Obtain80":
{
htmltext = replaceHtml(player, "EmergentAbility.html", true, null).replace("%level%", "80").replace("%skilltype%", "transformation skill").replace("%event%", "lvl80Class");
break;
}
case "lvl65Emergent":
{
htmltext = doCertification(player, st, "EmergentAbility", CERTIFICATE_EMERGENT_ABILITY, 65);
break;
}
case "lvl70Emergent":
{
htmltext = doCertification(player, st, "EmergentAbility", CERTIFICATE_EMERGENT_ABILITY, 70);
break;
}
case "lvl75Master":
{
htmltext = doCertification(player, st, "ClassAbility", CERTIFICATE_MASTER_ABILITY, 75);
break;
}
case "lvl75Class":
{
htmltext = doCertification(player, st, "ClassAbility", ABILITY_CERTIFICATES.get(getClassIndex(player)), 75);
break;
}
case "lvl80Class":
{
htmltext = doCertification(player, st, "ClassAbility", TRANSFORMATION_SEALBOOKS.get(getClassIndex(player)), 80);
break;
}
case "Main.html":
case "Explanation.html":
case "NotObtain.html":
{
htmltext = event;
break;
}
}
return htmltext;
}
private String replaceHtml(L2PcInstance player, String htmlFile, boolean replaceClass, String levelToReplace)
{
String htmltext = getHtm(player.getHtmlPrefix(), htmlFile);
if (replaceClass)
{
htmltext = htmltext.replace("%class%", String.valueOf(ClassListData.getInstance().getClass(player.getActiveClass()).getClientCode()));
}
if (levelToReplace != null)
{
htmltext = htmltext.replace("%level%", levelToReplace);
}
return htmltext;
}
private static int getClassIndex(L2PcInstance player)
{
if (player.isInCategory(CategoryType.SUB_GROUP_WARRIOR))
{
return 0;
}
else if (player.isInCategory(CategoryType.SUB_GROUP_ROGUE))
{
return 1;
}
else if (player.isInCategory(CategoryType.SUB_GROUP_KNIGHT))
{
return 2;
}
else if (player.isInCategory(CategoryType.SUB_GROUP_SUMMONER))
{
return 3;
}
else if (player.isInCategory(CategoryType.SUB_GROUP_WIZARD))
{
return 4;
}
else if (player.isInCategory(CategoryType.SUB_GROUP_HEALER))
{
return 5;
}
else if (player.isInCategory(CategoryType.SUB_GROUP_ENCHANTER))
{
return 6;
}
return -1;
}
private String doCertification(L2PcInstance player, QuestState qs, String variable, Integer itemId, int level)
{
if (itemId == null)
{
return null;
}
String htmltext;
String tmp = variable + level + "-" + player.getClassIndex();
String globalVariable = qs.getGlobalQuestVar(tmp);
if (!globalVariable.equals("") && !globalVariable.equals("0"))
{
htmltext = "AlreadyReceived.html";
}
else if (player.getLevel() < level)
{
htmltext = replaceHtml(player, "LowLevel.html", false, Integer.toString(level));
}
else
{
// Add items to player's inventory
final L2ItemInstance item = player.getInventory().addItem("Quest", itemId, 1, player, player.getTarget());
if (item == null)
{
return null;
}
final SystemMessage smsg = SystemMessage.getSystemMessage(SystemMessageId.YOU_HAVE_EARNED_S1);
smsg.addItemName(item);
player.sendPacket(smsg);
qs.saveGlobalQuestVar(tmp, String.valueOf(item.getObjectId()));
htmltext = "GetAbility.html";
}
return htmltext;
}
public static void main(String[] args)
{
new SubclassCertification();
}
}

View File

@@ -1,4 +0,0 @@
<html><body>Subclass Ability Validation:<br>
I'm sorry, but I cannot give you a certificate for your current occupation.<br>
You should go and look for the subclass master for your current occupation.
</body></html>

View File

@@ -0,0 +1,6 @@
<html><body>Subclass/Dual Class Certificate Manager Trandon:<br>
Subclass certification occurs at levels 65, 70, 75, and 80. New skills can be learned at each level.<br>
You can learn skills regardless of your occupation.<br>
Effects of the skills you learn through this certification can stack, even if you use the same skills.<br>
<Button ALIGN=LEFT ICON="RETURN" action="bypass -h Quest Trandon 33490.html">Back</Button>
</body></html>

View File

@@ -0,0 +1,5 @@
<html><body>Subclass/Dual Class Certificate Manager Trandon:<br>
Dual class certification can be done when <font color="LEVEL">your main and dual class levels both hit 85, 90, 95, and 99</font>. You can get certificates by getting certified for each of them, and with the certificates, you get to learn skills.<br>
Remember; <font color="LEVEL">skills you learned through dual certification only apply to main class and dual class</font>.<br>
<Button ALIGN=LEFT ICON="NORMAL" action="bypass -h Quest Trandon 33490.html">"Okay, I see."</Button>
</body></html>

View File

@@ -0,0 +1,5 @@
<html><body>Subclass/Dual Class Certificate Manager Trandon:<br>
So what do you want to know about subclass certification?<br>
<Button ALIGN=LEFT ICON="NORMAL" action="bypass -h Quest Trandon 33490-04.html">"I want to learn skills for certified subclasses."</Button>
<Button ALIGN=LEFT ICON="NORMAL" action="bypass -h Quest Trandon 33490-05.html">"I want to give up on skills and certification for certified subclasses."</Button>
</body></html>

View File

@@ -0,0 +1,8 @@
<html><body>Subclass/Dual Class Certificate Manager Trandon:<br>
If your subclass is strong enough, that class' power can be transferred to your main class.<br>
But this is a dangerous feat. Your power must be proven through certification.<br>
If you have a certificate, I will do a partial transfer on you.<br>
Now, will you learn the subclass skills transferred onto the main class? <br>
<Button ALIGN=LEFT ICON="NORMAL" action="bypass -h Quest Trandon learnSubSkill">"Of course!"</Button>
<Button ALIGN=LEFT ICON="NORMAL" action="bypass -h Quest Trandon 33490-07.html">"No, I want to give up."</Button>
</body></html>

View File

@@ -0,0 +1,7 @@
<html><body>Subclass/Dual Class Certificate Manager Trandon:<br>
Subclass skill certification and learning actually require tons of effort. Not just effort - it's more fundamental than that. The enormous pressure it puts on your soul... a normal person wouldn't be able to survive it.<br>
Not that it's completely impossible if you use special herbs. Except that those herbs cost about <font color="LEVEL">10 million Adena</font> each. But I have the herbs handy, so as long as you pay up, I can cancel that certification for you.<br>
If you cancel the certification, <font color="LEVEL">your current certification status disappears, and all the certificates and sealbooks you didn't learn skills with will be deleted</font>. So...what do you want to do?<br>
<Button ALIGN=LEFT ICON="NORMAL" action="bypass -h Quest Trandon deleteSubSkill">"Yeah, I'll go ahead and cancel the certification."</Button>
<Button ALIGN=LEFT ICON="NORMAL" action="bypass -h Quest Trandon 33490-06.html">"I want to quit."</Button>
</body></html>

View File

@@ -0,0 +1,4 @@
<html><body>Subclass/Dual Class Certificate Manager Trandon:<br>
Good idea. Those herbs aren't the easiest to come by. And that nasty black wizard in the Dragon Valley is the only one who knows how to formulate the thing, so I wasn't too excited about this either.<br>
And everything you got certified for... it's kind of a waste, right?
</body></html>

View File

@@ -0,0 +1,4 @@
<html><body>Subclass/Dual Class Certificate Manager Trandon:<br>
Well, I guess I'm not one to stop you if you want to give up.<br>
After all, it's no easy feat to use the power of a subclass in a main class.
</body></html>

View File

@@ -0,0 +1,5 @@
<html><body>Subclass/Dual Class Certificate Manager Trandon:<br>
So what do you want to do about dual class certification?<br>
<Button ALIGN=LEFT ICON="NORMAL" action="bypass -h Quest Trandon 33490-09.html">"I want to learn certified dual class skills."</Button>
<Button ALIGN=LEFT ICON="NORMAL" action="bypass -h Quest Trandon 33490-10.html">"Actually, I'll just give up on the whole certification deal."</Button>
</body></html>

View File

@@ -0,0 +1,8 @@
<html><body>Subclass/Dual Class Certificate Manager Trandon:<br>
You can obtain new powers if <font color="LEVEL">your main class and dual class both exceed level 85</font>.<br1>
You can't get these powers unless you are certified with your dual class and main class. i<br1>
<font color="LEVEL">I'll help you obtain new powers if you have the certificates</font>.<br1>
So, will you give me that dual class certificate and acquire the power contained within? <br>
<Button ALIGN=LEFT ICON="NORMAL" action="bypass -h Quest Trandon learnDualSkill">"Of course!"</Button>
<Button ALIGN=LEFT ICON="NORMAL" action="bypass -h Quest Trandon 33490-11.html">"Whoa, wait a minute. Give me some time to get ready."</Button>
</body></html>

View File

@@ -0,0 +1,10 @@
<html><body>Subclass/Dual Class Certificate Manager Trandon:<br>
Dual class certification and skill learning are actually incredible feats.<br1>
As you may know from the subclass experience you had before, but it's not just about effort. The enormous pressure it puts on your soul is beyond your imagination.<br1>
I will be usin the special herbs again to seal the certified skills you learned.<br1>
This time though, the herb will cost you about <font color="LEVEL">20 million Adena</font>. I have them handy, so just pay up and I can cancel that certification for you. <br1>
If you cancel the certification, <font color="LEVEL">your current certification status disappears, and all the certificates and sealbooks you didn't learn skills with will be deleted</font>.<br1>
So...what do you want to do?<br>
<Button ALIGN=LEFT ICON="NORMAL" action="bypass -h Quest Trandon deleteDualSkill">"Yeah, I'll go ahead and cancel the certification."</Button>
<Button ALIGN=LEFT ICON="NORMAL" action="bypass -h Quest Trandon 33490-06.html">"I want to quit."</Button>
</body></html>

View File

@@ -0,0 +1,4 @@
<html><body>Subclass/Dual Class Certificate Manager Trandon:<br>
Well, if you're not ready...I can't push you.<br1>
Come again after you <font color="LEVEL">get your main and dual class levels to 85, 90, 95, and 99 and get certified</font>.
</body></html>

View File

@@ -0,0 +1,9 @@
<html><body>Subclass Skill Certification:<br>
Subclass certification is handled at various different levels. If your skills are good enough, I can certify you.<br>
When you are ready, bring the certification to me and I will help you learn new skills.<br>
Now, what level of certification do you want?<br>
<Button ALIGN=LEFT ICON="NORMAL" action="bypass -h Quest Trandon subCertify 0">"Level 65 Skill Certification."</Button>
<Button ALIGN=LEFT ICON="NORMAL" action="bypass -h Quest Trandon subCertify 1">"Level 70 Skill Certification."</Button>
<Button ALIGN=LEFT ICON="NORMAL" action="bypass -h Quest Trandon subCertify 2">"Level 75 Skill Certification."</Button>
<Button ALIGN=LEFT ICON="NORMAL" action="bypass -h Quest Trandon subCertify 3">"Level 80 Skill Certification."</Button>
</body></html>

View File

@@ -0,0 +1,3 @@
<html><body>Subclass Skill Certification:<br>
To receive a subclass certification, you must come to me in the subclass state.
</body></html>

View File

@@ -0,0 +1,3 @@
<html><body>Subclass/Dual Class Certificate Manager Trandon:<br>
I wanted to give you your certificate once your subclass certification was completed, but you don't have sufficient free weight and inventory space. Return to me when 80% of your weight and inventory is free.
</body></html>

View File

@@ -0,0 +1,6 @@
<html><body>Subclass Skill Certification:<br>
You have already received the certificate for this occupation.<br>
I cannot give you any more certificates for your current occupation. If you wish to obtain another certificate, please come back as an occupation from another slot.<br>
However, Ertheia are still connected to gods. So it would be meaningless for them to start a new life as a subclass, which also means that subclass certificates are meaningless for them.<br>
(Ertheia cannot add a subclass or get a subclass certificate.)
</body></html>

View File

@@ -1,3 +1,3 @@
<html><body>Subclass Skill Certification:<br>
<html><body>Subclass Ability Validation:<br>
You are not yet ready to receive your level %level% certification. Work hard and come back later.
</body></html>

View File

@@ -1,3 +1,3 @@
<html><body>Subclass Skill Certification:<br>
<html><body>Subclass Ability Validation:<br>
You have already received the certificate for this skill.
</body></html>

View File

@@ -0,0 +1,6 @@
<html><body>Subclass Skill Certification:<br>
You want to be certified for Level %level%? Once you are certified, you can't be recertified unless you cancel the certification by jumping through some hoops first. Even if you delete the class and build up your skill, it's a no go. You OK with that?<br>
Do you still want to receive certification?<br>
<Button ALIGN=LEFT ICON="NORMAL" action="bypass -h Quest Trandon giveSubCertify %index%">"Yes."</Button>
<Button ALIGN=LEFT ICON="NORMAL" action="bypass -h Quest Trandon 33490-19.html">"Not really."</Button>
</body></html>

View File

@@ -0,0 +1,5 @@
<html><body>Subclass Skill Certification:<br>
This certification is to verify that your subclass has exceeded the required level.<br>
When your mind is clear and you've decided how to proceed, come and see me and I'll provide you with an appropriate skill.<br>
If you would like to cancel this certification, please let me know and I can cancel it.
</body></html>

View File

@@ -0,0 +1,3 @@
<html><body>Subclass/Dual Class Certificate Manager Trandon:<br>
To draw the power of a subclass, you must <font color="LEVEL">set your current class the main class, and bring the certificate to me.</font> Also, if you want to change any subclass certified skill you have acquired, you must abandon the skills and certification of the certified subclass. <font color="LEVEL">To abandon the subclass skills and certification, come and talk to me while you're in your main class.</font>
</body></html>

View File

@@ -0,0 +1,3 @@
<html><body>Subclass/Dual Class Certificate Manager Trandon:<br>
Sorry, but you need 10 million adena. You don't seem to have that much money.
</body></html>

View File

@@ -0,0 +1,4 @@
<html><body>Subclass/Dual Class Certificate Manager Trandon:<br>
Hmm... you have neither a certified certificate, nor any skills you've learned from certification. What are you trying to cancel?<br>
This herb is very rare and expensive, you don't want to use it unless it's necessary.
</body></html>

View File

@@ -0,0 +1,4 @@
<html><body>Sub/Dual Class Certificate Manager Trandon:<br>
<font color="LEVEL">To get dual class certification, don't you think you should come as a dual class?</font><br>
Please come back as a dual class.
</body></html>

View File

@@ -0,0 +1,4 @@
<html><body>Sub/Dual Class Certificate Manager Trandon:<br>
Your inventory and weight slots are still full.<br>
<font color="LEVEL">Come back when your inventory and weight slots are less than 80% full.</font>
</body></html>

View File

@@ -0,0 +1,9 @@
<html><body>Subclass/Dual Class Skill Certification:<br>
You have to be at a <font color="LEVEL">high enough level for both main and subclass.</font> I can give you the certificate if you're strong enough.<br>
After I give you the certificate, bring it back to me and I'll tell you about skills you can learn.<br>
Now, what level of certification do you want?<br>
<Button ALIGN=LEFT ICON="NORMAL" action="bypass -h Quest Trandon dualCertify 0">"Level 85 Skill Certification."</Button>
<Button ALIGN=LEFT ICON="NORMAL" action="bypass -h Quest Trandon dualCertify 1">"Level 90 Skill Certification."</Button>
<Button ALIGN=LEFT ICON="NORMAL" action="bypass -h Quest Trandon dualCertify 2">"Level 95 Skill Certification."</Button>
<Button ALIGN=LEFT ICON="NORMAL" action="bypass -h Quest Trandon dualCertify 3">"Level 99 Skill Certification."</Button>
</body></html>

View File

@@ -0,0 +1,5 @@
<html><body>Subclass/Dual Class Certificate Manager Trandon:<br>
Haven't you already been certified for level <font color="LEVEL">%level%?</font><br1>
Young ones these days...listen carefully.<br1>
You can get <font color="LEVEL">certified a total of 4 times for the dual class - when your main and dual class levels are at 85, 90, 95, and 99.</font>
</body></html>

View File

@@ -0,0 +1,4 @@
<html><body>Sub/Dual Class Certificate Manager Trandon:<br>
It seems <font color="LEVEL">you are not yet qualified to get dual class certification for level %level%</font>.<br>
You can get certified only when <font color="LEVEL">both your main class and dual class are level %level% or above</font>. So, come back after leveling up.
</body></html>

View File

@@ -0,0 +1,6 @@
<html><body>Sub/Dual Class Certificate Manager Trandon:<br>
Congratulations.<br1>
Let me give you a <font color="LEVEL">dual class certificate for level %level%.<br1>
Come back with this certificate when you want to learn a dual certification skill.</font><br1>
Keep in mind that <font color="LEVEL">you have to come back as your main class</font> to learn a dual certification skill.
</body></html>

View File

@@ -0,0 +1,4 @@
<html><body>Sub/Dual Class Certificate Manager Trandon:<br>
Just like subclass certification skills, you <font color="LEVEL">have to be your main class to learn dual certification skills</font>.<br1>
Please come back as your main class.
</body></html>

View File

@@ -0,0 +1,6 @@
<html><body>Subclass/Dual Class Certificate Manager Trandon:<br>
Hmm... You don't have a dual class certificate.<br1>
<font color="LEVEL">To learn a dual certification skill, you need a dual class certificate</font>. Get certified!<br1>
Luckily for you, I'm the person to talk to. Would you like to get certified?<br>
<Button ALIGN=LEFT ICON="NORMAL" action="bypass -h Quest Trandon 33490-26.html">"Yes, I'll try it."</Button>
</body></html>

View File

@@ -0,0 +1,7 @@
<html><body>Sub/Dual Class Certificate Manager Trandon:<br>
To re-seal the power of the dual certification skill you learned, I need herbs.<br1>
I need more herbs for this than for sealing subclass certification skills.<br1>
Let me see how much it will cost...<br>
Hmm... Just the herbs cost <font color="LEVEL">20 million Adena</font>.<br1>
Bring me <font color="LEVEL">20 million Adena</font>.
</body></html>

View File

@@ -0,0 +1,4 @@
<html><body>Sub/Dual Class Certificate Manager Trandon:<br>
You don't have any unsealed certification skills yet.<br1>
Come back when you want to seal the power of unsealed certification skills.
</body></html>

View File

@@ -0,0 +1,12 @@
<html><body>Subclass/Dual Class Certificate Manager Trandon:<br>
Discipline and endless training to bring your subclass up to a certain level open your eyes to new powers.<br1>
Now, let's see how much your training has taught you.<br1>
By the way, to receive this certification, <font color="LEVEL">your current class must be the class of the subclass or dual class you want to be certified for; you also need to be level 65 or above, and in the case of the dual class, level 85 or above</font>.<br1>
So, do you want to be certified? Or do you want to learn skills with the certification you received?<br>
<Button ALIGN=LEFT ICON="NORMAL" action="bypass -h Quest Trandon 33490-01.html">"Wait...care to explain more about the subclass certification?"</Button>
<Button ALIGN=LEFT ICON="NORMAL" action="bypass -h Quest Trandon 33490-12.html">"Certify me on the subclass."</Button>
<Button ALIGN=LEFT ICON="NORMAL" action="bypass -h Quest Trandon 33490-03.html">"I need to learn or forget a subclass skill."</Button>
<Button ALIGN=LEFT ICON="NORMAL" action="bypass -h Quest Trandon 33490-02.html">"So, uh, about this dual class certification..."</Button>
<Button ALIGN=LEFT ICON="NORMAL" action="bypass -h Quest Trandon 33490-26.html">"I need a dual class certification, please."</Button>
<Button ALIGN=LEFT ICON="NORMAL" action="bypass -h Quest Trandon 33490-08.html">"I need to learn or forget a dual class skill, actually."</Button>
</body></html>

View File

@@ -0,0 +1,463 @@
/*
* Copyright (C) 2004-2015 L2J DataPack
*
* This file is part of L2J DataPack.
*
* L2J DataPack is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* L2J DataPack is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package ai.npc.Trandon;
import java.util.Set;
import ai.npc.AbstractNpcAI;
import com.l2jserver.Config;
import com.l2jserver.gameserver.datatables.SkillData;
import com.l2jserver.gameserver.enums.Race;
import com.l2jserver.gameserver.model.actor.L2Npc;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.events.EventType;
import com.l2jserver.gameserver.model.events.ListenerRegisterType;
import com.l2jserver.gameserver.model.events.annotations.RegisterEvent;
import com.l2jserver.gameserver.model.events.annotations.RegisterType;
import com.l2jserver.gameserver.model.events.impl.character.player.OnPlayerLogin;
import com.l2jserver.gameserver.model.events.impl.character.player.OnPlayerSubChange;
import com.l2jserver.gameserver.model.itemcontainer.Inventory;
import com.l2jserver.gameserver.model.skills.Skill;
import com.l2jserver.gameserver.model.variables.PlayerVariables;
import com.l2jserver.gameserver.network.clientpackets.RequestAcquireSkill;
/**
* Trandon AI.
* @author malyelfik
*/
public final class Trandon extends AbstractNpcAI
{
// NPC
private static final int NPC_ID = 33490;
// Items
private static final int SUB_CERTIFICATE = 10280;
private static final int DUAL_CERTIFICATE = 36078;
// Misc @formatter:off
private static final int[] SUB_SKILL_LEVELS = {65, 70, 75, 80};
private static final int[] DUAL_SKILL_LEVELS = {85, 90, 95, 99};
// @formatter:on
private Trandon()
{
super(Trandon.class.getSimpleName(), "ai/npc");
addStartNpc(NPC_ID);
addFirstTalkId(NPC_ID);
addTalkId(NPC_ID);
}
@Override
public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
{
final String[] substrings = event.split(" ");
if (substrings.length < 1)
{
return null;
}
String htmltext = substrings[0];
switch (htmltext)
{
case "33490.html":
case "33490-01.html":
case "33490-02.html":
case "33490-03.html":
case "33490-04.html":
case "33490-05.html":
case "33490-06.html":
case "33490-07.html":
case "33490-08.html":
case "33490-09.html":
case "33490-10.html":
case "33490-11.html":
case "33490-19.html":
break;
case "33490-12.html":
{
if (player.getRace().equals(Race.ERTHEIA) || hasAllSubCertifications(player))
{
htmltext = "33490-15.html";
}
else if (!player.isSubClassActive())
{
htmltext = "33490-13.html";
}
else if (!player.isInventoryUnder90(false) || (player.getWeightPenalty() >= 2))
{
htmltext = "33490-14.html";
}
break;
}
case "subCertify":
{
if ((substrings.length < 2) || !player.isSubClassActive())
{
return null;
}
final int index = Integer.parseInt(substrings[1]);
if ((index < 0) || (index > 3))
{
return null;
}
final int level = SUB_SKILL_LEVELS[index];
if (player.getLevel() < level)
{
htmltext = getHtm(player.getHtmlPrefix(), "33490-16.html").replace("%level%", String.valueOf(level));
}
else if (player.getVariables().hasVariable(getSubSkillVariableName(player, level)))
{
htmltext = "33490-17.html";
}
else
{
htmltext = getHtm(player.getHtmlPrefix(), "33490-18.html");
htmltext = htmltext.replace("%level%", String.valueOf(level));
htmltext = htmltext.replace("%index%", String.valueOf(index));
}
break;
}
case "giveSubCertify":
{
if ((substrings.length < 2) || !player.isSubClassActive() || player.getRace().equals(Race.ERTHEIA))
{
return null;
}
final int index = Integer.parseInt(substrings[1]);
if ((index < 0) || (index > 3))
{
return null;
}
final int level = SUB_SKILL_LEVELS[index];
final PlayerVariables vars = player.getVariables();
if ((player.getLevel() < level) || vars.hasVariable(getSubSkillVariableName(player, level)))
{
htmltext = null;
}
else
{
vars.set(getSubSkillVariableName(player, level), true);
giveItems(player, SUB_CERTIFICATE, 1);
htmltext = "33490-20.html";
}
break;
}
case "learnSubSkill":
{
if (player.getRace().equals(Race.ERTHEIA))
{
htmltext = "33490-15.html";
}
else if (player.isSubClassActive() || !hasQuestItems(player, SUB_CERTIFICATE))
{
htmltext = "33490-21.html";
}
else
{
RequestAcquireSkill.showSubSkillList(player);
htmltext = null;
}
break;
}
case "deleteSubSkill":
{
if (player.getRace().equals(Race.ERTHEIA))
{
htmltext = "33490-15.html";
}
else if (player.isSubClassActive())
{
htmltext = "33490-21.html";
}
else if (player.getAdena() < Config.FEE_DELETE_SUBCLASS_SKILLS)
{
htmltext = "33490-22.html";
}
else if (!hasSubCertificate(player))
{
htmltext = "33490-23.html";
}
else
{
htmltext = null; // TODO: Unknown html
takeItems(player, SUB_CERTIFICATE, -1);
takeItems(player, Inventory.ADENA_ID, Config.FEE_DELETE_SUBCLASS_SKILLS);
final PlayerVariables vars = player.getVariables();
for (int i = 1; i <= 3; i++)
{
for (int lv : SUB_SKILL_LEVELS)
{
vars.remove("SubSkill-" + i + "-" + lv);
}
}
takeSkills(player, "SubSkillList");
}
break;
}
case "33490-26.html":
{
// TODO: What happens when you have all dual certificates?
if (!player.isDualClassActive())
{
htmltext = "33490-24.html";
}
else if (!player.isInventoryUnder90(false) || (player.getWeightPenalty() >= 2))
{
htmltext = "33490-25.html";
}
else if ((player.getLevel() < DUAL_SKILL_LEVELS[0]) || (player.getStat().getBaseLevel() < DUAL_SKILL_LEVELS[0])) // Dual or main class level is lower than 85
{
// TODO: What happens here?
player.sendMessage("Your level is too low.");
htmltext = null;
}
break;
}
case "dualCertify":
{
if ((substrings.length < 2) || !player.isDualClassActive())
{
return null;
}
final int index = Integer.parseInt(substrings[1]);
if ((index < 0) || (index > 3))
{
return null;
}
final int level = DUAL_SKILL_LEVELS[index];
final PlayerVariables vars = player.getVariables();
if (vars.hasVariable(getDualSkillVariableName(level)))
{
htmltext = getHtm(player.getHtmlPrefix(), "33490-27.html");
}
else if ((player.getLevel() < level) || (player.getStat().getBaseLevel() < level))
{
htmltext = getHtm(player.getHtmlPrefix(), "33490-28.html");
}
else
{
vars.set(getDualSkillVariableName(level), true);
giveItems(player, DUAL_CERTIFICATE, 1);
htmltext = getHtm(player.getHtmlPrefix(), "33490-29.html");
}
htmltext = htmltext.replace("%level%", String.valueOf(level));
break;
}
case "learnDualSkill":
{
// TODO: What happens when you have all dual-certificates used?
if (player.isSubClassActive())
{
htmltext = "33490-30.html";
}
else if (!hasQuestItems(player, DUAL_CERTIFICATE))
{
htmltext = "33490-31.html";
}
else if ((player.getLevel() < DUAL_SKILL_LEVELS[0]) || (player.getStat().getBaseLevel() < DUAL_SKILL_LEVELS[0]))
{
// This case should not happen
htmltext = null;
}
else
{
RequestAcquireSkill.showDualSkillList(player);
htmltext = null;
}
break;
}
case "deleteDualSkill":
{
if (player.isSubClassActive())
{
htmltext = "33490-30.html";
}
else if (player.getAdena() < Config.FEE_DELETE_DUALCLASS_SKILLS)
{
htmltext = "33490-32.html";
}
else if (!hasDualCertificate(player))
{
htmltext = "33490-33.html";
}
else
{
htmltext = null; // TODO: Unknown html
takeItems(player, DUAL_CERTIFICATE, -1);
takeItems(player, Inventory.ADENA_ID, Config.FEE_DELETE_DUALCLASS_SKILLS);
final PlayerVariables vars = player.getVariables();
for (int lv : DUAL_SKILL_LEVELS)
{
vars.remove(getDualSkillVariableName(lv));
}
takeSkills(player, "DualSkillList");
}
break;
}
default:
{
htmltext = null;
}
}
return htmltext;
}
// TODO: Move this to char skills
@RegisterEvent(EventType.ON_PLAYER_SUB_CHANGE)
@RegisterType(ListenerRegisterType.GLOBAL_PLAYERS)
public final void onSubChange(OnPlayerSubChange evt)
{
final L2PcInstance player = evt.getActiveChar();
if (player.isDualClassActive() || !player.isSubClassActive())
{
giveSkills(player, "DualSkillList");
}
giveSkills(player, "SubSkillList");
player.sendSkillList();
}
@RegisterEvent(EventType.ON_PLAYER_LOGIN)
@RegisterType(ListenerRegisterType.GLOBAL_PLAYERS)
public final void onLogin(OnPlayerLogin evt)
{
final L2PcInstance player = evt.getActiveChar();
if (player.isDualClassActive() || !player.isSubClassActive())
{
giveSkills(player, "DualSkillList");
}
giveSkills(player, "SubSkillList");
}
/**
* Checks if player has all sub certifications for current subclass
* @param player
* @return
*/
private final boolean hasAllSubCertifications(L2PcInstance player)
{
if (!player.isSubClassActive())
{
return false;
}
final PlayerVariables vars = player.getVariables();
for (int lv : SUB_SKILL_LEVELS)
{
if (!vars.hasVariable(getSubSkillVariableName(player, lv)))
{
return false;
}
}
return true;
}
/**
* Checks if player has any sub certification
* @param player
* @return
*/
private final boolean hasSubCertificate(L2PcInstance player)
{
final PlayerVariables vars = player.getVariables();
final Set<Integer> subs = player.getSubClasses().keySet();
for (int index : subs)
{
for (int lv : SUB_SKILL_LEVELS)
{
if (vars.hasVariable("SubSkill-" + index + "-" + lv))
{
return true;
}
}
}
return false;
}
/**
* Checks if player has any dual certification
* @param player
* @return
*/
private final boolean hasDualCertificate(L2PcInstance player)
{
final PlayerVariables vars = player.getVariables();
for (int lv : DUAL_SKILL_LEVELS)
{
if (vars.hasVariable(getDualSkillVariableName(lv)))
{
return true;
}
}
return false;
}
private final String getSubSkillVariableName(L2PcInstance player, int level)
{
return "SubSkill-" + player.getClassIndex() + "-" + level;
}
private final String getDualSkillVariableName(int level)
{
return "DualSkill-" + level;
}
private final void takeSkills(L2PcInstance player, String type)
{
final PlayerVariables vars = player.getVariables();
final String list = vars.getString(type, "");
if (!list.isEmpty())
{
final String[] skills = list.split(";");
for (String skill : skills)
{
final String[] str = skill.split("-");
final Skill sk = SkillData.getInstance().getSkill(Integer.parseInt(str[0]), Integer.parseInt(str[1]));
player.removeSkill(sk);
}
vars.remove(type);
player.sendSkillList();
}
}
private final void giveSkills(L2PcInstance player, String type)
{
final String list = player.getVariables().getString(type, "");
if (!list.isEmpty())
{
final String[] skills = list.split(";");
for (String skill : skills)
{
final String[] str = skill.split("-");
final Skill sk = SkillData.getInstance().getSkill(Integer.parseInt(str[0]), Integer.parseInt(str[1]));
player.addSkill(sk, false);
}
}
}
public static void main(String[] args)
{
new Trandon();
}
}