/*
* 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.AvantGarde;
import java.util.List;
import ai.npc.AbstractNpcAI;
import com.l2jserver.gameserver.data.xml.impl.MultisellData;
import com.l2jserver.gameserver.data.xml.impl.SkillTreesData;
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.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;
/**
* Avant-Garde AI.<br>
* Sub-Class Certification system, skill learning and certification canceling.<br>
* Transformation skill learning and transformation scroll sell.
* @author Zoey76
*/
public final class AvantGarde extends AbstractNpcAI
{
// NPC
private static final int AVANT_GARDE = 32323;
public AvantGarde()
{
super(AvantGarde.class.getSimpleName(), "ai/npc");
addStartNpc(AVANT_GARDE);
addTalkId(AVANT_GARDE);
addFirstTalkId(AVANT_GARDE);
addAcquireSkillId(AVANT_GARDE);
}
@Override
public String onAcquireSkill(L2Npc npc, L2PcInstance player, Skill skill, AcquireSkillType type)
{
if (type.equals(AcquireSkillType.TRANSFORM))
{
showTransformSkillList(player);
}
return null;
}
@Override
public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
{
String htmltext = null;
switch (event)
{
case "32323-02.html":
case "32323-02a.html":
case "32323-02b.html":
case "32323-02c.html":
case "32323-05.html":
case "32323-05no.html":
case "32323-06.html":
case "32323-06no.html":
{
htmltext = event;
break;
}
case "LearnTransformationSkill":
{
if (RequestAcquireSkill.canTransform(player))
{
showTransformSkillList(player);
}
else
{
htmltext = "32323-03.html";
}
break;
}
case "BuyTransformationItems":
{
if (RequestAcquireSkill.canTransform(player))
{
MultisellData.getInstance().separateAndSend(32323001, player, npc, false);
}
else
{
htmltext = "32323-04.html";
}
break;
}
}
return htmltext;
}
@Override
public String onFirstTalk(L2Npc npc, L2PcInstance player)
{
return "32323-01.html";
}
@Override
public String onTalk(L2Npc npc, L2PcInstance talker)
{
return "32323-01.html";
}
/**
* This displays Transformation Skill List to the player.
* @param player the active character.
*/
public static void showTransformSkillList(L2PcInstance player)
{
final List<L2SkillLearn> skills = SkillTreesData.getInstance().getAvailableTransformSkills(player);
if (skills.isEmpty())
{
final int minlevel = SkillTreesData.getInstance().getMinLevelForNewSkill(player, SkillTreesData.getInstance().getTransformSkillTree());
if (minlevel > 0)
{
// No more skills to learn, come back when you level.
final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.YOU_DO_NOT_HAVE_ANY_FURTHER_SKILLS_TO_LEARN_COME_BACK_WHEN_YOU_HAVE_REACHED_LEVEL_S1);
sm.addInt(minlevel);
player.sendPacket(sm);
}
else
{
player.sendPacket(SystemMessageId.THERE_ARE_NO_OTHER_SKILLS_TO_LEARN);
}
}
else
{
player.sendPacket(new ExAcquirableSkillListByClass(skills, AcquireSkillType.TRANSFORM));
}
}
public static void main(String[] args)
{
new AvantGarde();
}
}