123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144 |
- /*
- * 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.Katenar;
- import quests.Q00065_CertifiedSoulBreaker.Q00065_CertifiedSoulBreaker;
- import ai.npc.AbstractNpcAI;
- import com.l2jserver.gameserver.model.actor.L2Npc;
- import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
- import com.l2jserver.gameserver.model.quest.QuestState;
- import com.l2jserver.gameserver.network.NpcStringId;
- import com.l2jserver.gameserver.network.clientpackets.Say2;
- /**
- * Katenar AI for quests Certified Soul Breaker (65)
- * @author ivantotov
- */
- public final class Katenar extends AbstractNpcAI
- {
- // NPC
- private static final int KATENAR = 32242;
- // Item
- private static final int SEALED_DOCUMENT = 9803;
-
- private Katenar()
- {
- super(Katenar.class.getSimpleName(), "ai/npc");
- addStartNpc(KATENAR);
- addTalkId(KATENAR);
- addFirstTalkId(KATENAR);
- addSpawnId(KATENAR);
- }
-
- @Override
- public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
- {
- final L2Npc npc0 = npc.getVariables().getObject("npc0", L2Npc.class);
- String htmltext = null;
-
- switch (event)
- {
- case "CREATED_50":
- {
- if (npc0 != null)
- {
- if (!npc.getVariables().getBoolean("SPAWNED", false))
- {
- npc0.getVariables().set("SPAWNED", false);
- }
- }
- npc.deleteMe();
- break;
- }
- case "GOOD_LUCK":
- {
- final QuestState qs = player.getQuestState(Q00065_CertifiedSoulBreaker.class.getSimpleName());
- if (qs.isMemoState(14))
- {
- if (npc0 != null)
- {
- if (!npc.getVariables().getBoolean("SPAWNED", false))
- {
- npc0.getVariables().set("SPAWNED", false);
- broadcastNpcSay(npc, Say2.NPC_ALL, NpcStringId.GOOD_LUCK);
- }
- }
- npc.deleteMe();
- }
- break;
- }
- }
- return htmltext;
- }
-
- @Override
- public String onFirstTalk(L2Npc npc, L2PcInstance talker)
- {
- final QuestState qs = talker.getQuestState(Q00065_CertifiedSoulBreaker.class.getSimpleName());
- String htmltext = getNoQuestMsg(talker);
- final int memoState = qs.getMemoState();
- if (memoState == 12)
- {
- htmltext = "32242-01.html";
- }
- else if (memoState == 13)
- {
- final L2PcInstance player = npc.getVariables().getObject("player0", L2PcInstance.class);
- if (player == talker)
- {
- qs.setMemoState(14);
- qs.setCond(13, true);
- htmltext = "32242-02.html";
- }
- else
- {
- qs.setMemoState(14);
- qs.setCond(13, true);
- htmltext = "32242-03.html";
- }
- if (!hasQuestItems(player, SEALED_DOCUMENT))
- {
- giveItems(player, SEALED_DOCUMENT, 1);
- }
- }
- else if (memoState == 14)
- {
- htmltext = "32242-04.html";
- }
- return htmltext;
- }
-
- @Override
- public String onSpawn(L2Npc npc)
- {
- startQuestTimer("CREATED_50", 50000, npc, null);
- final L2PcInstance player = npc.getVariables().getObject("player0", L2PcInstance.class);
- if (player != null)
- {
- broadcastNpcSay(npc, Say2.NPC_ALL, NpcStringId.I_AM_LATE);
- }
- return super.onSpawn(npc);
- }
-
- public static void main(String[] args)
- {
- new Katenar();
- }
- }
|