123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177 |
- package instances.HideoutOfTheDawn;
- import com.l2jserver.gameserver.ai.CtrlIntention;
- import com.l2jserver.gameserver.instancemanager.InstanceManager;
- import com.l2jserver.gameserver.instancemanager.InstanceManager.InstanceWorld;
- import com.l2jserver.gameserver.model.actor.L2Character;
- import com.l2jserver.gameserver.model.actor.L2Npc;
- import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
- import com.l2jserver.gameserver.model.effects.L2Effect;
- import com.l2jserver.gameserver.model.quest.Quest;
- import com.l2jserver.gameserver.model.quest.QuestState;
- import com.l2jserver.gameserver.model.skills.L2Skill;
- import com.l2jserver.gameserver.network.SystemMessageId;
- /**
- * @author Adry_85
- */
- public class HideoutOfTheDawn extends Quest
- {
- private class HoDWorld extends InstanceWorld
- {
- public long[] storeTime =
- {
- 0,
- 0
- };
-
- public HoDWorld()
- {
- }
- }
-
- private static final int INSTANCEID = 113;
- private static final int WOOD = 32593;
- private static final int JAINA = 32617;
-
- public class teleCoord
- {
- int instanceId;
- int x;
- int y;
- int z;
- }
-
- public HideoutOfTheDawn(int questId, String name, String descr)
- {
- super(questId, name, descr);
-
- addStartNpc(WOOD);
- addTalkId(WOOD, JAINA);
- }
-
- @Override
- public String onTalk(L2Npc npc, L2PcInstance player)
- {
- QuestState st = player.getQuestState(getName());
- if (st == null)
- {
- st = newQuestState(player);
- }
-
- switch (npc.getNpcId())
- {
- case WOOD:
- {
- teleCoord tele = new teleCoord();
- tele.x = -23758;
- tele.y = -8959;
- tele.z = -5384;
- enterInstance(player, "HideoutOfTheDawn.xml", tele);
- return "32593-01.htm";
- }
-
- case JAINA:
- {
- InstanceManager.InstanceWorld world = InstanceManager.getInstance().getPlayerWorld(player);
- world.allowed.remove(world.allowed.indexOf(Integer.valueOf(player.getObjectId())));
- teleCoord tele = new teleCoord();
- tele.instanceId = 0;
- tele.x = 147072;
- tele.y = 23743;
- tele.z = -1984;
- exitInstance(player, tele);
- return "32617-01.htm";
- }
- }
-
- return "";
- }
-
- private void teleportplayer(L2PcInstance player, teleCoord teleto)
- {
- removeBuffs(player);
- player.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
- player.setInstanceId(teleto.instanceId);
- player.teleToLocation(teleto.x, teleto.y, teleto.z);
- }
-
- protected int enterInstance(L2PcInstance player, String template, teleCoord teleto)
- {
- int instanceId = 0;
- // check for existing instances for this player
- InstanceWorld world = InstanceManager.getInstance().getPlayerWorld(player);
- // existing instance
- if (world != null)
- {
- if (!(world instanceof HoDWorld))
- {
- player.sendPacket(SystemMessageId.ALREADY_ENTERED_ANOTHER_INSTANCE_CANT_ENTER);
- return 0;
- }
- teleto.instanceId = world.instanceId;
- teleportplayer(player, teleto);
- return instanceId;
- }
- // New instance
- instanceId = InstanceManager.getInstance().createDynamicInstance(template);
- world = new HoDWorld();
- world.instanceId = instanceId;
- world.templateId = INSTANCEID;
- world.status = 0;
- ((HoDWorld) world).storeTime[0] = System.currentTimeMillis();
- InstanceManager.getInstance().addWorld(world);
- _log.info("SevenSign started " + template + " Instance: " + instanceId + " created by player: " + player.getName());
- // teleport players
- teleto.instanceId = instanceId;
- teleportplayer(player, teleto);
- world.allowed.add(player.getObjectId());
-
- return instanceId;
- }
-
- protected void exitInstance(L2PcInstance player, teleCoord tele)
- {
- player.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
- player.setInstanceId(0);
- player.teleToLocation(tele.x, tele.y, tele.z);
- }
-
- private static final void removeBuffs(L2Character ch)
- {
- for (L2Effect e : ch.getAllEffects())
- {
- if (e == null)
- {
- continue;
- }
- L2Skill skill = e.getSkill();
- if (skill.isDebuff() || skill.isStayAfterDeath())
- {
- continue;
- }
- e.exit();
- }
- if (ch.getSummon() != null)
- {
- for (L2Effect e : ch.getSummon().getAllEffects())
- {
- if (e == null)
- {
- continue;
- }
- L2Skill skill = e.getSkill();
- if (skill.isDebuff() || skill.isStayAfterDeath())
- {
- continue;
- }
- e.exit();
- }
- }
- }
-
- public static void main(String[] args)
- {
- new HideoutOfTheDawn(-1, HideoutOfTheDawn.class.getSimpleName(), "instances");
- }
- }
|