Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Index: dist/game/data/html/default/32781.htm
- ===================================================================
- --- dist/game/data/html/default/32781.htm (revision 0)
- +++ dist/game/data/html/default/32781.htm (working copy)
- @@ -0,0 +1,6 @@
- +<html><body>Jinia<br>
- +This place is so cold I can´t feel my nose. I´m sure it´s so red,
- + I could lead a pack of flying reindeer.<br>
- +
- +<a action="bypass -h npc_%objectId%_Quest FreyaInstance">"TEST TEST TEST."</a><br>
- +</body></html>
- \ No newline at end of file
- Index: dist/game/data/scripts/instances/Freya/FreyaInstance.java
- ===================================================================
- --- dist/game/data/scripts/instances/Freya/FreyaInstance.java (revision 0)
- +++ dist/game/data/scripts/instances/Freya/FreyaInstance.java (working copy)
- @@ -0,0 +1,1143 @@
- +/*
- + * This program 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.
- + *
- + * This program 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 instances.Freya;
- +
- +import java.util.Calendar;
- +import java.util.List;
- +import java.util.concurrent.locks.Lock;
- +import java.util.concurrent.locks.ReentrantLock;
- +
- +import javolution.util.FastList;
- +
- +import com.l2jserver.gameserver.ai.CtrlIntention;
- +import com.l2jserver.gameserver.instancemanager.InstanceManager;
- +import com.l2jserver.gameserver.model.L2CharPosition;
- +import com.l2jserver.gameserver.model.L2CommandChannel;
- +import com.l2jserver.gameserver.model.L2Party;
- +import com.l2jserver.gameserver.model.L2Spawn;
- +import com.l2jserver.gameserver.model.L2World;
- +import com.l2jserver.gameserver.model.Location;
- +import com.l2jserver.gameserver.model.actor.L2Attackable;
- +import com.l2jserver.gameserver.model.actor.L2Character;
- +import com.l2jserver.gameserver.model.actor.L2Npc;
- +import com.l2jserver.gameserver.model.actor.instance.L2GuardInstance;
- +import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
- +import com.l2jserver.gameserver.model.entity.Instance;
- +import com.l2jserver.gameserver.model.holders.SkillHolder;
- +import com.l2jserver.gameserver.model.instancezone.InstanceWorld;
- +import com.l2jserver.gameserver.model.quest.Quest;
- +import com.l2jserver.gameserver.model.quest.QuestState;
- +import com.l2jserver.gameserver.model.quest.State;
- +import com.l2jserver.gameserver.model.zone.L2ZoneType;
- +import com.l2jserver.gameserver.network.NpcStringId;
- +import com.l2jserver.gameserver.network.SystemMessageId;
- +import com.l2jserver.gameserver.network.clientpackets.Say2;
- +import com.l2jserver.gameserver.network.serverpackets.ExSendUIEvent;
- +import com.l2jserver.gameserver.network.serverpackets.ExShowScreenMessage;
- +import com.l2jserver.gameserver.network.serverpackets.NpcSay;
- +import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
- +import com.l2jserver.gameserver.taskmanager.DecayTaskManager;
- +import com.l2jserver.gameserver.util.Util;
- +import com.l2jserver.util.Rnd;
- +
- +/**
- + ** @author Gnacik, Gladicek
- + * TODO: Glaciers, Ice Queen Castle room animation (we currently have only "blizzard" effect)
- + */
- +
- +public class FreyaInstance extends Quest
- +{
- + // Debug
- + private static final boolean DEBUG = true;
- +
- + // Instance ID
- + private static final int INSTANCEID = 139;
- +
- + // Zone
- + private static final int ZONE = 90578;
- +
- + // Instance limits
- + private static final int MIN_PLAYERS = 9;
- + private static final int MAX_PLAYERS = 27;
- + private static final int MIN_LEVEL = 82;
- +
- + // Doors
- + private static final int HALL_DOORS = 23140101;
- +
- + // NPC's
- + private static final int JINIA = 32781; // ENTER
- + private static final int SIRRA = 32762; // DOOR OPENER
- + private static final int KEGOR_EXIT = 49302; // EXIT
- +
- + // Skills
- + private static SkillHolder JINIA_PRAYER = new SkillHolder(6288, 1);
- + private static SkillHolder KEGOR_COURAGE = new SkillHolder(6289, 1);
- + private static SkillHolder ETERNAL_BLIZZARD1 = new SkillHolder(6274, 1);
- + private static SkillHolder ETERNAL_BLIZZARD2 = new SkillHolder(6275, 1);
- +
- + // Initialization at 6:30 am on Wednesday and Saturday
- + private static final int RESET_HOUR = 6;
- + private static final int RESET_MIN = 30;
- + private static final int RESET_DAY_1 = 4;
- + private static final int RESET_DAY_2 = 7;
- +
- + // Epic one with client animation
- + // private static SkillHolder ETERNAL_BLIZZARD3 = new SkillHolder(6276, 1);
- +
- + // Monsters
- + private static final int[] MOBS =
- + {
- + 29177,
- + 29178,
- + 29179,
- + 29180,
- + 18854,
- + 18855,
- + 18856,
- + 25699,
- + 25700
- + };
- +
- + // Enter/Exit
- + private static final int[] ENTER_TELEPORT =
- + {
- + 114185,
- + -112435,
- + -11210
- + };
- +
- + // Timers
- + private static final int TIMER_FIRST_MOVIE = 60000;
- + private static final int TIMER_GLAKIAS = 100000;
- + private static final int TIMER_BREATHS = 30000;
- + // Movies
- + private static final int MOVIE_START = 15;
- + private static final int MOVIE_SECOND = 16;
- + private static final int MOVIE_FREYA = 17;
- + private static final int MOVIE_KEGOR = 18;
- + private static final int MOVIE_DEATH = 19;
- + private static final int MOVIE_FINAL = 20;
- + private static final int MOVIE_GLAKIAS = 23;
- +
- + // Spawns
- + private static final Location[] MONUMENTS =
- + {
- + new Location(113845, -116091, -11168, 8264),
- + new Location(113381, -115622, -11168, 8264),
- + new Location(113380, -113978, -11168, -8224),
- + new Location(113845, -113518, -11168, -8224),
- + new Location(115591, -113516, -11168, -24504),
- + new Location(116053, -113981, -11168, -24504),
- + new Location(116061, -115611, -11168, 24804),
- + new Location(115597, -116080, -11168, 24804),
- + new Location(112942, -115480, -10960, 52),
- + new Location(112940, -115146, -10960, 52),
- + new Location(112945, -114453, -10960, 52),
- + new Location(112945, -114123, -10960, 52),
- + new Location(116497, -114117, -10960, 32724),
- + new Location(116499, -114454, -10960, 32724),
- + new Location(116501, -115145, -10960, 32724),
- + new Location(116502, -115473, -10960, 32724)
- + };
- +
- + private static final Location[] SPAWNS =
- + {
- + new Location(114713, -115109, -11202, 16456),
- + new Location(114008, -115080, -11202, 3568),
- + new Location(114422, -115508, -11202, 12400),
- + new Location(115023, -115508, -11202, 20016),
- + new Location(115459, -115079, -11202, 27936)
- + };
- +
- +
- + protected class FreyaWorld extends InstanceWorld
- + {
- + public Lock lock = new ReentrantLock();
- + public List<L2PcInstance> PlayersInInstance = new FastList<>();
- + public boolean showed = false;
- + public boolean screen_message = false;
- + public boolean screen_message2 = false;
- + public boolean screen_message3 = false;
- + public boolean started = false;
- + public boolean opened = false;
- + int id_freya_first;
- + int id_freya_second;
- + int id_freya_last;
- + int id_glakias;
- + int id_ice_knight;
- + int id_arch_breath;
- + int id_kegor;
- + int id_jinia;
- + FastList<L2Npc> allmobs = null;
- + FastList<L2Npc> monuments = null;
- + L2Npc freya;
- + L2Npc kegor;
- + L2Npc jinia;
- + L2Npc kegor_exit;
- + L2Npc freya_exit;
- +
- + public FreyaWorld()
- + {
- + allmobs = new FastList<>();
- + monuments = new FastList<>();
- + id_freya_first = 0;
- + id_freya_second = 0;
- + id_freya_last = 0;
- + id_glakias = 0;
- + id_ice_knight = 0;
- + id_arch_breath = 0;
- + id_kegor = 0;
- + id_jinia = 0;
- + }
- + }
- +
- + public FreyaInstance(int questId, String name, String descr)
- + {
- + super(questId, name, descr);
- +
- + addEnterZoneId(ZONE);
- + addStartNpc(JINIA);
- + addTalkId(JINIA);
- + addTalkId(SIRRA);
- + addStartNpc(KEGOR_EXIT);
- + addFirstTalkId(KEGOR_EXIT);
- + addTalkId(KEGOR_EXIT);
- +
- + for (int mob : MOBS)
- + {
- + addAttackId(mob);
- + addKillId(mob);
- + addSpawnId(mob);
- + }
- + }
- +
- + private void setupIDs(FreyaWorld world, int template_id)
- + {
- + {
- + world.id_freya_first = 29177;
- + world.id_freya_second = 29178;
- + world.id_freya_last = 29179;
- + world.id_glakias = 25699;
- + world.id_ice_knight = 18855;
- + world.id_arch_breath = 18854;
- + world.id_kegor = 18851;
- + world.id_jinia = 18850;
- + }
- + }
- +
- + @Override
- + public final String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
- + {
- +
- + if (DEBUG)
- + _log.info(getName() + "onAdvEvent=" + event);
- +
- + InstanceWorld wrld = null;
- + if (npc != null)
- + wrld = InstanceManager.getInstance().getWorld(npc.getInstanceId());
- + else if (player != null)
- + wrld = InstanceManager.getInstance().getPlayerWorld(player);
- + else
- + {
- + _log.warning("Freya Instance: onAdvEvent : Unable to get world.");
- + return null;
- + }
- + if (wrld != null && wrld instanceof FreyaWorld)
- + {
- + FreyaWorld world = (FreyaWorld) wrld;
- +
- + switch (event)
- + {
- + case "start_freya":
- + {
- + if (DEBUG)
- + _log.info("Freya Instance: Starting timer for stage 1 movie!");
- + if (world.getStatus() == 0)
- + {
- + // Set status
- + world.setStatus(1);
- + // Schedule Movie
- + startQuestTimer("stage_1_movie", TIMER_FIRST_MOVIE, npc, null);
- + /**
- + * If you are using GMChar to test, you can skip parts here and schedule some next timer not stage_1_movie
- + * startQuestTimer("stage_3_begin", TIMER_FIRST_MOVIE, npc, null);
- + */
- + }
- + break;
- + }
- + case "open_doors":
- + {
- + if (DEBUG)
- + _log.info("Freya instance: Opening doors!");
- + // Open Door
- + if (!world.opened)
- + InstanceManager.getInstance().getInstance(INSTANCEID).getDoor(HALL_DOORS).openMe();
- + world.opened = true;
- + break;
- + }
- + case "knight_pillar":
- + {
- + if (npc != null)
- + {
- + npc.setDisplayEffect(1);
- + }
- + break;
- + }
- + case "random_first_attack":
- + {
- + if (npc != null)
- + {
- + if (!world.monuments.isEmpty())
- + {
- + if (world.getStatus() < 6 && world.monuments.contains(npc))
- + return null;
- + if (world.getStatus() == 6 && world.monuments.contains(npc))
- + npc.setDisplayEffect(2);
- +
- + for (int objId : world.getAllowed())
- + {
- + L2PcInstance victim = L2World.getInstance().getPlayer(objId);
- + if (victim != null && victim.isOnline() && victim.getInstanceId() == world.getInstanceId() && (!(victim.isDead() || victim.isGM() || victim.isInvul() || victim.getAppearance().getInvisible())) && !npc.isDead() && !npc.isImmobilized() && npc.getAI().getIntention() == CtrlIntention.AI_INTENTION_ACTIVE)
- + {
- + ((L2Attackable) npc).addDamageHate(victim, 0, 99);
- + npc.setIsRunning(true);
- + npc.setTarget(victim);
- + npc.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, victim, null);
- + }
- + startQuestTimer("random_first_attack", Rnd.get(1000, 2000), npc, null);
- + }
- + }
- + else
- + {
- + // Monuments are always in battle time
- + // If world.monuments is empty just delete npc, should not be happend
- + if (npc.getNpcId() == world.id_glakias || npc.getNpcId() == world.id_arch_breath)
- + npc.deleteMe();
- + }
- + break;
- + }
- + }
- + case "stage_1_movie":
- + {
- + // Stop players before movie
- + stopPc(world);
- + // Show movie
- + showMovie(world, MOVIE_START);
- + // Close Door
- + InstanceManager.getInstance().getInstance(world.getInstanceId()).getDoor(HALL_DOORS).closeMe();
- + startQuestTimer("stage_1_begin", 53500 + 1000, npc, null);
- + break;
- + }
- + case "stage_1_begin":
- + {
- + world.setStatus(2);
- + spawnMonuments(world);
- + // Spawn boos
- + world.freya = addSpawn(world.id_freya_first, 114720, -117085, -11088, 15956, false, 0, true, world.getInstanceId());
- + // Begin stage 1
- + ExShowScreenMessage message1 = new ExShowScreenMessage(NpcStringId.BEGIN_STAGE_1, 2, 7000);
- + sendScreenMessage(world, message1);
- + // Move freya
- + startQuestTimer("freya_move", 2000, world.freya, null, false);
- + // start ai for cast skill
- + startQuestTimer("cast_skill", 15000, world.freya, null, false);
- + break;
- + }
- + case "freya_move":
- + {
- + ExShowScreenMessage message2 = new ExShowScreenMessage(NpcStringId.FREYA_HAS_STARTED_TO_MOVE, 2, 5000);
- + sendScreenMessage(world, message2);
- + // Initialize movement
- + world.freya.setIsRunning(true);
- + world.freya.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, new L2CharPosition(114717, -114973, -11200, 0));
- + world.freya.getSpawn().setLocx(114717);
- + world.freya.getSpawn().setLocy(-114973);
- + world.freya.getSpawn().setLocz(-11200);
- + // Spawn Knights
- + spawnMobs(world, world.id_ice_knight);
- + break;
- + }
- + case "cast_skill":
- + {
- + ExShowScreenMessage message3 = new ExShowScreenMessage(NpcStringId.STRONG_MAGIC_POWER_CAN_BE_FELT_FROM_SOMEWHERE, 2, 4000);
- + sendScreenMessage(world, message3);
- + world.freya.doCast(ETERNAL_BLIZZARD1.getSkill());
- + startQuestTimer("cast_skill", 60000, world.freya, null, false);
- + break;
- + }
- + case "cast_skill_3stage":
- + {
- + ExShowScreenMessage message4 = new ExShowScreenMessage(NpcStringId.STRONG_MAGIC_POWER_CAN_BE_FELT_FROM_SOMEWHERE, 2, 4000);
- + sendScreenMessage(world, message4);
- + world.freya.doCast(ETERNAL_BLIZZARD2.getSkill());
- + // Here you can setup Eternal Blizzard with client animation!
- + // world.freya.doCast(ETERNAL_BLIZZARD3.getSkill());
- + startQuestTimer("cast_skill_3stage", 60000, world.freya, null, false);
- + break;
- + }
- + case "stage_1_final_movie":
- + {
- + cancelQuestTimer("cast_skill", npc, null);
- + // Delete freya
- + world.freya.deleteMe();
- + // Despawn mobs
- + despawnAll(world);
- + // Stop players before movie
- + stopPc(world);
- + // Show movie
- + showMovie(world, MOVIE_SECOND);
- + startQuestTimer("stage_1_pause", 21100 + 1000, npc, null);
- + break;
- + }
- + case "stage_1_pause":
- + {
- + // Spawn boss upstairs
- + L2Npc freya = addSpawn(world.id_freya_second, 114723, -117502, -10672, 15956, false, 0, true, world.getInstanceId());
- + freya.setIsImmobilized(true);
- + freya.setIsInvul(true);
- + freya.disableCoreAI(true);
- + freya.disableAllSkills();
- + world.freya = freya;
- + // Set world status
- + world.setStatus(4);
- + // Despawn monuments
- + despawnMonuments(world);
- + // 1 min pause for rebuff
- + showTimer(world, false);
- + // Start Stage 2
- + startQuestTimer("stage_2_begin", 60000, npc, null);
- + break;
- + }
- + case "stage_2_begin":
- + {
- + // Set world status
- + world.setStatus(5);
- + // Begin stage 2
- + ExShowScreenMessage message5 = new ExShowScreenMessage(NpcStringId.BEGIN_STAGE_2, 2, 7000);
- + sendScreenMessage(world, message5);
- + // Spawn monuments
- + spawnMonuments(world);
- + // Spawn Knights
- + spawnMobs(world, world.id_ice_knight);
- + // 4 min to Glakias spawn
- + startQuestTimer("stage_2_glakias_movie", TIMER_GLAKIAS, npc, null);
- + // 2 min to Breaths spawn
- + startQuestTimer("stage_2_breaths", TIMER_BREATHS, npc, null);
- + break;
- + }
- + case "stage_2_breaths":
- + {
- + // Disable new spawns for knights
- + for (L2Npc knight : world.allmobs)
- + knight.getSpawn().stopRespawn();
- + // Spawn Breaths
- + spawnMobs(world, world.id_arch_breath);
- + break;
- + }
- + case "stage_2_glakias_movie":
- + {
- + showMovie(world, MOVIE_GLAKIAS);
- + startQuestTimer("stage_2_glakias_spawn", 7000 + 1000, npc, null);
- + break;
- + }
- + case "stage_2_glakias_spawn":
- + {
- + addSpawn(world.id_glakias, 114707, -114799, -11199, 15956, false, 0, true, world.getInstanceId());
- + break;
- + }
- + case "stage_2_pause":
- + {
- + // Despawn mobs
- + despawnAll(world);
- + // Despawn monuments
- + despawnMonuments(world);
- + // 1 min pause for rebuff
- + showTimer(world, false);
- + // Start Stage 3
- + startQuestTimer("stage_3_movie", 60000, npc, null);
- + break;
- + }
- + case "stage_3_movie":
- + {
- + // Delete freya
- + world.freya.deleteMe();
- + // Show movie
- + showMovie(world, MOVIE_FREYA);
- + // Begin Stage 3
- + startQuestTimer("stage_3_begin", 21500 + 1000, npc, null);
- + break;
- + }
- + case "stage_3_begin":
- + {
- + // TODO: Here must be done room animation!
- + // Spawn monuments
- + spawnMonuments(world);
- + // Spawn Freya
- + world.freya = addSpawn(world.id_freya_last, 114720, -117085, -11088, 15956, false, 0, true, world.getInstanceId());
- + // Begin stage 2
- + ExShowScreenMessage message6 = new ExShowScreenMessage(NpcStringId.BEGIN_STAGE_3, 2, 7000);
- + sendScreenMessage(world, message6);
- + // Spawn Knights
- + spawnMobs(world, world.id_arch_breath);
- + // Add monument timers
- + startQuestTimer("stage_3_monuments", 60000, npc, null);
- + // start ai for cast skill
- + startQuestTimer("cast_skill_3stage", 15000, world.freya, null, false);
- + break;
- + }
- + case "stage_3_monuments":
- + {
- + // Set status
- + world.setStatus(6);
- + // Monuments start move
- + for (L2Npc monument : world.monuments)
- + {
- + monument.getSpawn().stopRespawn();
- + monument.setIsImmobilized(false);
- + monument.setIsInvul(false);
- + monument.enableAllSkills();
- + monument.disableCoreAI(false);
- + startQuestTimer("random_first_attack", Rnd.get(1000, 10000), monument, null);
- + }
- + break;
- + }
- + case "finish_world":
- + {
- + cancelQuestTimer("player_buff", npc, null);
- + cancelQuestTimer("cast_skill_3stage", npc, null);
- + cancelQuestTimer("check_for_enemies", npc, null);
- + // Despawn mobs
- + despawnAll(world);
- + // Despawn monuments
- + despawnMonuments(world);
- + // Begin Movie 2
- + startQuestTimer("finish_world2", 100, npc, null);
- + break;
- + }
- + case "buff_support":
- + {
- + startWorld(world);
- + startQuestTimer("cast_skill_3stage", 15000, npc, null);
- + ExShowScreenMessage message7 = new ExShowScreenMessage(NpcStringId.BEGIN_STAGE_4, 2, 7000);
- + sendScreenMessage(world, message7);
- + world.kegor = addSpawn(world.id_kegor, 114659, -114796, -11205, 0, false, 0, true, world.getInstanceId());
- + world.jinia = addSpawn(world.id_jinia, 114751, -114781, -11205, 0, false, 0, true, world.getInstanceId());
- + world.kegor.setIsInvul(true);
- + world.kegor.setIsRunning(true);
- + world.jinia.setIsInvul(true);
- + world.jinia.setIsRunning(true);
- + startQuestTimer("player_buff", 3000, npc, null);
- + startQuestTimer("check_for_enemies", 5000, npc, null);
- + break;
- + }
- + case "player_buff":
- + {
- + world.kegor.doCast(KEGOR_COURAGE.getSkill());
- + world.jinia.doCast(JINIA_PRAYER.getSkill());
- + startQuestTimer("player_buff", 30000, npc, null);
- + break;
- + }
- + case "finish_world2":
- + {
- + world.kegor.deleteMe();
- + world.jinia.deleteMe();
- + despawnAll(world);
- + // Show movie 2
- + showMovie(world, MOVIE_DEATH);
- + // Spawn exit NPC + Freya (dying)
- + startQuestTimer("spawn_exit", 500, npc, null);
- + // Set 5 min time
- + Instance inst = InstanceManager.getInstance().getInstance(world.getInstanceId());
- + if (inst != null)
- + inst.setDuration(300000);
- + break;
- + }
- + case "finish_world3":
- + {
- + // Show movie 3
- + showMovie(world, MOVIE_FINAL);
- + questSupport2(npc, player);
- + world.kegor_exit.deleteMe();
- + world.freya_exit.deleteMe();
- + break;
- + }
- + case "spawn_exit":
- + {
- + world.kegor_exit = addSpawn(KEGOR_EXIT, 114659, -114796, -11205, 0, false, 0, true, world.getInstanceId());
- + world.freya_exit = addSpawn(world.id_freya_last, 114785, -114789, -11206, 0, false, 0, true, world.getInstanceId());
- + world.freya_exit.setIsImmobilized(true);
- + world.freya_exit.setIsInvul(true);
- + world.freya_exit.doDie(world.freya_exit);
- + DecayTaskManager.getInstance().cancelDecayTask(world.freya_exit);
- + world.freya_exit.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
- + world.freya_exit.disableCoreAI(true);
- + world.freya_exit.disableAllSkills();
- + break;
- + }
- + case "check_for_enemies":
- + {
- + ((L2GuardInstance) world.kegor).addDamageHate(world.freya, 0, 10000);
- + ((L2GuardInstance) world.kegor).getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, world.freya, null);
- + ((L2GuardInstance) world.jinia).addDamageHate(world.freya, 0, 10000);
- + ((L2GuardInstance) world.jinia).getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, world.freya, null);
- + startQuestTimer("check_for_enemies", 15000, npc, null);
- + break;
- + }
- + }
- + }
- + return null;
- + }
- +
- +
- + @Override
- + public String onFirstTalk(L2Npc npc, L2PcInstance player)
- + {
- + int npcid = npc.getNpcId();
- +
- + if (npcid == KEGOR_EXIT)
- + {
- + return "kegor.htm";
- + }
- + return null;
- + }
- +
- + @Override
- + public String onKill(L2Npc npc, L2PcInstance killer, boolean isPet)
- + {
- + if (DEBUG)
- + _log.info("onKill [" + npc.getNpcId() + "]" + npc.getName());
- +
- + InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc.getInstanceId());
- + if (tmpworld instanceof FreyaWorld)
- + {
- + FreyaWorld world = (FreyaWorld) tmpworld;
- + // Delete corpse, because doesn't look good
- + npc.deleteMe();
- +
- + if (npc.getNpcId() == world.id_ice_knight)
- + {
- + // Start timer to change effectId
- + startQuestTimer("knight_pillar", 5000, npc, null);
- + }
- + else if (npc.getNpcId() == world.id_glakias)
- + {
- + // Run Pause before stage 3
- + startQuestTimer("stage_2_pause", 500, npc, null);
- + showTimer(world, false);
- + }
- + else if (npc.getNpcId() == world.id_freya_last)
- + {
- + // Finish Instance
- + startQuestTimer("finish_world", 500, npc, null);
- + for (L2PcInstance p : world.PlayersInInstance)
- + {
- + if (p != null)
- + {
- + setInstanceTimeRestrictions(world);
- + if (DEBUG)
- + _log.info("Save reenter for " + p.getName() + ".");
- + }
- + }
- + }
- + else if ((npc.getNpcId() == 29179 || npc.getNpcId() == 29180) && killer.isInParty())
- + {
- +
- + if (killer.getParty().getCommandChannel() != null)
- + {
- + for (L2PcInstance ccm : killer.getParty().getCommandChannel().getMembers())
- + {
- + questSupport(npc, ccm);
- + }
- + }
- + }
- + }
- + return super.onKill(npc, killer, isPet);
- + }
- +
- + private void questSupport(L2Npc npc, L2PcInstance player)
- + {
- + if (player.isInsideRadius(npc, 2000, false, false))
- + {
- + final int _fragment = 21723;
- + final QuestState st = player.getQuestState("Q10502_FreyaEmbroideredSoulCloak");
- + if (st != null && st.getState() == State.STARTED && st.getInt("cond") == 1)
- + {
- + if (player.getQuestState("Q10502_FreyaEmbroideredSoulCloak").getQuestItemsCount(_fragment) < 19)
- + {
- + player.getQuestState("Q10502_FreyaEmbroideredSoulCloak").giveItems(_fragment, Rnd.get(1, 2));
- + st.playSound("ItemSound.quest_middle");
- + }
- + else
- + {
- + player.getQuestState("Q10502_FreyaEmbroideredSoulCloak").giveItems(_fragment, 1);
- + }
- + if (player.getQuestState("Q10502_FreyaEmbroideredSoulCloak").getQuestItemsCount(_fragment) >= 20)
- + {
- + player.getQuestState("Q10502_FreyaEmbroideredSoulCloak").set("cond", "2");
- + }
- + }
- + }
- + }
- +
- +
- + protected void setInstanceTimeRestrictions(FreyaWorld world)
- + {
- + Calendar reenter = Calendar.getInstance();
- + reenter.set(Calendar.MINUTE, RESET_MIN);
- + reenter.set(Calendar.HOUR_OF_DAY, RESET_HOUR);
- + // if time is >= RESET_HOUR - roll to the next day
- + if (reenter.getTimeInMillis() <= System.currentTimeMillis())
- + {
- + reenter.add(Calendar.DAY_OF_MONTH, 1);
- + }
- + if (reenter.get(Calendar.DAY_OF_WEEK) <= RESET_DAY_1)
- + {
- + while (reenter.get(Calendar.DAY_OF_WEEK) != RESET_DAY_1)
- + {
- + reenter.add(Calendar.DAY_OF_MONTH, 1);
- + }
- + }
- + else
- + {
- + while (reenter.get(Calendar.DAY_OF_WEEK) != RESET_DAY_2)
- + {
- + reenter.add(Calendar.DAY_OF_MONTH, 1);
- + }
- + }
- +
- + SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.INSTANT_ZONE_S1_RESTRICTED);
- + sm.addInstanceName(INSTANCEID);
- +
- + // set instance reenter time for all allowed players
- + for (int objectId : world.getAllowed())
- + {
- + L2PcInstance player = L2World.getInstance().getPlayer(objectId);
- + InstanceManager.getInstance().setInstanceTime(objectId, INSTANCEID, reenter.getTimeInMillis());
- + if ((player != null) && player.isOnline())
- + {
- + player.sendPacket(sm);
- + }
- + }
- + }
- +
- + @Override
- + public final String onAttack(L2Npc npc, L2PcInstance attacker, int damage, boolean isPet)
- + {
- + if (npc == null || attacker == null)
- + return null;
- +
- + final InstanceWorld tmpWorld = InstanceManager.getInstance().getWorld(npc.getInstanceId());
- + if (tmpWorld instanceof FreyaWorld)
- + {
- + final FreyaWorld world = (FreyaWorld) tmpWorld;
- + // First freya
- + if (world.getStatus() == 2 && npc.getNpcId() == world.id_freya_first)
- + {
- + if (npc.getCurrentHp() < (npc.getMaxHp() * 0.1))
- + {
- + if (world.lock.tryLock())
- + {
- + try
- + {
- + world.setStatus(3);
- + startQuestTimer("stage_1_final_movie", 1000, npc, attacker);
- + }
- + finally
- + {
- + world.lock.unlock();
- + }
- + }
- + }
- + }
- + else if (npc.getNpcId() == world.id_ice_knight && npc.getDisplayEffect() == 1)
- + {
- + if (npc.getCurrentHp() < (npc.getMaxHp() * 0.3))
- + npc.setDisplayEffect(2);
- + }
- + else if (npc.getNpcId() == world.id_freya_last)
- + {
- + if (npc.getCurrentHp() < (npc.getMaxHp() * 0.25) && !world.showed)
- + {
- + world.showed = true;
- + stopWorld(world);
- + // Show Movie 4
- + showMovie(world, MOVIE_KEGOR);
- + startQuestTimer("buff_support", 27000 + 200, npc, null);
- + cancelQuestTimer("cast_skill_3stage", npc, null);
- + }
- + }
- + else if (npc.getNpcId() == world.id_glakias)
- + {
- + if (npc.getCurrentHp() < (npc.getMaxHp() * 0.2) && !world.screen_message)
- + {
- + world.screen_message = true;
- + npc.broadcastPacket(new NpcSay(npc.getObjectId(), Say2.NPC_SHOUT, npc.getNpcId(), NpcStringId.I_CAN_TAKE_IT_NO_LONGER));
- + }
- + if (npc.getCurrentHp() < (npc.getMaxHp() * 0.4) && !world.screen_message)
- + {
- + world.screen_message = true;
- + npc.broadcastPacket(new NpcSay(npc.getObjectId(), Say2.NPC_SHOUT, npc.getNpcId(), NpcStringId.ARCHER_HEED_MY_CALL));
- + }
- + if (npc.getCurrentHp() < (npc.getMaxHp() * 0.6) && !world.screen_message2)
- + {
- + world.screen_message2 = true;
- + ExShowScreenMessage message8 = new ExShowScreenMessage(NpcStringId.THE_SPACE_FEELS_LIKE_ITS_GRADUALLY_STARTING_TO_SHAKE, 2, 7000);
- + sendScreenMessage(world, message8);
- + npc.broadcastPacket(new NpcSay(npc.getObjectId(), Say2.NPC_SHOUT, npc.getNpcId(), NpcStringId.MY_KNIGHTS_SHOW_YOUR_LOYALTY));
- + }
- + if (npc.getCurrentHp() < (npc.getMaxHp() * 0.8) && !world.screen_message3)
- + {
- + world.screen_message3 = true;
- + npc.broadcastPacket(new NpcSay(npc.getObjectId(), Say2.NPC_SHOUT, npc.getNpcId(), NpcStringId.ARCHER_GIVE_YOUR_BREATH_FOR_THE_INTRUDER));
- + }
- + }
- + }
- + return super.onAttack(npc, attacker, damage, isPet);
- + }
- +
- + private void startWorld(FreyaWorld world)
- + {
- + Instance instance = InstanceManager.getInstance().getInstance(world.getInstanceId());
- + for (L2Npc npc : instance.getNpcs())
- + {
- + if (npc != null)
- + {
- + npc.setIsImmobilized(false);
- + npc.setIsInvul(false);
- + npc.disableCoreAI(false);
- + npc.enableAllSkills();
- + }
- + }
- + }
- +
- + private void stopWorld(FreyaWorld world)
- + {
- + Instance instance = InstanceManager.getInstance().getInstance(world.getInstanceId());
- + for (L2Npc npc : instance.getNpcs())
- + {
- + if (npc != null)
- + {
- + npc.abortAttack();
- + npc.abortCast();
- + npc.setTarget(null);
- + npc.stopMove(null);
- + npc.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
- + npc.setIsImmobilized(true);
- + npc.setIsInvul(true);
- + npc.disableCoreAI(true);
- + npc.disableAllSkills();
- + }
- + }
- + }
- +
- + private void questSupport2(L2Npc npc, L2PcInstance player)
- + {
- + if (player.isInsideRadius(npc, 2000, false, false))
- + {
- + final QuestState st = player.getQuestState("Q10286_ReunionWithSirra");
- + if (st != null && st.getState() == State.STARTED && st.getInt("cond") == 6)
- + {
- + st.playSound("ItemSound.quest_middle");
- + player.getQuestState("Q10286_ReunionWithSirra").set("cond", "7");
- + }
- + }
- + }
- +
- + private void setupPlayer(FreyaWorld world, L2PcInstance player, int template_id)
- + {
- + // Remove buffs from player
- + player.stopAllEffectsExceptThoseThatLastThroughDeath();
- + // Add player to allowed list
- + world.PlayersInInstance.add(player);
- + if (player.getQuestState("Q10286_ReunionWithSirra") != null && player.getQuestState("Q10286_ReunionWithSirra").getState() == State.STARTED && player.getQuestState("Q10286_ReunionWithSirra").getInt("cond") == 5)
- + {
- + player.getQuestState("Q10286_ReunionWithSirra").set("cond", "6");
- + }
- + }
- +
- + private void showMovie(FreyaWorld world, int movie)
- + {
- + for (int objId : world.getAllowed())
- + {
- + L2PcInstance player = L2World.getInstance().getPlayer(objId);
- + if (player != null && player.isOnline() && player.getInstanceId() == world.getInstanceId())
- + player.showQuestMovie(movie);
- + }
- + }
- +
- + private void showTimer(FreyaWorld world, boolean hide)
- + {
- + for (int objId : world.getAllowed())
- + {
- + L2PcInstance player = L2World.getInstance().getPlayer(objId);
- + if (player != null && player.isOnline() && player.getInstanceId() == world.getInstanceId())
- + // TODO: Rework it for NpcStringId.TIME_REMAINING_UNTIL_NEXT_BATTLE
- + player.sendPacket(new ExSendUIEvent(player, hide, false, 60, 0, "Time remaining until next battle"));
- + }
- + }
- +
- + private void sendScreenMessage(FreyaWorld world, ExShowScreenMessage message)
- + {
- + for (int objId : world.getAllowed())
- + {
- + L2PcInstance player = L2World.getInstance().getPlayer(objId);
- + if (player != null)
- + player.sendPacket(message);
- + }
- + }
- +
- + private void stopPc(FreyaWorld world)
- + {
- + for (int objId : world.getAllowed())
- + {
- + L2PcInstance player = L2World.getInstance().getPlayer(objId);
- + if (player != null && player.isOnline() && player.getInstanceId() == world.getInstanceId())
- + {
- + player.abortAttack();
- + player.abortCast();
- + player.setTarget(null);
- + player.stopMove(null);
- + player.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
- + }
- + }
- + }
- +
- + private void despawnAll(FreyaWorld world)
- + {
- + for (L2Npc npc : world.allmobs)
- + {
- + npc.getSpawn().stopRespawn();
- + npc.deleteMe();
- + }
- +
- + world.allmobs.clear();
- + }
- +
- + private void spawnMonuments(FreyaWorld world)
- + {
- + if (DEBUG)
- + _log.info("spawnMonuments");
- +
- + for (Location loc : MONUMENTS)
- + {
- + L2Npc npc = addSpawn(world.id_ice_knight, loc.getX(), loc.getY(), loc.getZ(), loc.getHeading(), false, 0, true, world.getInstanceId());
- + world.monuments.add(npc);
- + npc.disableCoreAI(true);
- + npc.setIsImmobilized(true);
- + npc.setIsInvul(true);
- + npc.disableAllSkills();
- + npc.setDisplayEffect(1);
- + npc.setEnchant(1);
- + L2Spawn spawn = npc.getSpawn();
- + spawn.getLastSpawn().setSpawn(spawn);
- + spawn.setRespawnDelay(20);
- + spawn.setAmount(1);
- + spawn.startRespawn();
- + }
- + }
- +
- + private void despawnMonuments(FreyaWorld world)
- + {
- + for (L2Npc npc : world.monuments)
- + {
- + npc.setDisplayEffect(2);
- + npc.getSpawn().stopRespawn();
- + npc.doDie(npc);
- + }
- + world.monuments.clear();
- + }
- +
- + private void spawnMobs(FreyaWorld world, int mobId)
- + {
- + if (DEBUG)
- + {
- + _log.info("spawnMobs");
- + }
- +
- + for (Location loc : SPAWNS)
- + {
- + L2Npc npc = addSpawn(mobId, loc.getX(), loc.getY(), loc.getZ(), loc.getHeading(), false, 0, true, world.getInstanceId());
- + world.allmobs.add(npc);
- + npc.setDisplayEffect(1);
- + L2Spawn spawn = npc.getSpawn();
- + spawn.setRespawnDelay(20);
- + spawn.setAmount(1);
- + spawn.startRespawn();
- + }
- + }
- +
- + @Override
- + public String onTalk(L2Npc npc, L2PcInstance player)
- + {
- + int npcId = npc.getNpcId();
- + QuestState st = player.getQuestState(getName());
- + if (st == null)
- + {
- + st = newQuestState(player);
- + }
- + if (npcId == JINIA)
- + {
- + if (DEBUG)
- + _log.info("Freya Instance: Teleporting player/s into Freya instance!");
- + enterInstance(player, "Freya.xml", ENTER_TELEPORT);
- + startQuestTimer("open_doors", 1500, npc, player);
- + }
- + return "";
- + }
- +
- + private void teleportPlayer(L2PcInstance player, int[] coords, int instanceId)
- + {
- + player.setInstanceId(instanceId);
- + player.teleToLocation(coords[0], coords[1], coords[2]);
- + }
- +
- + protected int enterInstance(L2PcInstance player, String template, int[] coords)
- + {
- + int instanceId = 0;
- + // check for existing instances for this player
- + InstanceWorld world = InstanceManager.getInstance().getPlayerWorld(player);
- + // existing instance
- + if (world != null)
- + {
- + if (!(world instanceof FreyaWorld))
- + {
- + player.sendPacket(SystemMessageId.ALREADY_ENTERED_ANOTHER_INSTANCE_CANT_ENTER);
- + return 0;
- + }
- + teleportPlayer(player, coords, world.getInstanceId());
- + return world.getInstanceId();
- + }
- +
- + // New instance
- + if (!checkConditions(player))
- + {
- + return 0;
- + }
- + instanceId = InstanceManager.getInstance().createDynamicInstance(template);
- + world = new FreyaWorld();
- + world.setInstanceId(instanceId);
- + world.setStatus(0);
- + InstanceManager.getInstance().addWorld(world);
- + setupIDs((FreyaWorld) world, INSTANCEID);
- + _log.info("Freya instance started " + template + " Instance: " + instanceId + " created by player: " + player.getName());
- + // Teleport players
- + if ((player.getParty() == null) || (player.getParty().getCommandChannel() == null))
- + {
- + setupPlayer((FreyaWorld) world, player, instanceId);
- + world.addAllowed(player.getObjectId());
- + teleportPlayer(player, coords, instanceId);
- + }
- + else
- + {
- + for (L2PcInstance channelMember : player.getParty().getCommandChannel().getMembers())
- + {
- + setupPlayer((FreyaWorld) world, channelMember, instanceId);
- + world.addAllowed(channelMember.getObjectId());
- + teleportPlayer(channelMember, coords, instanceId);
- + }
- + }
- + return instanceId;
- + }
- +
- + private boolean checkConditions(L2PcInstance player)
- + {
- + if (DEBUG)
- + {
- + _log.info("Freya instance: Started wtih DEBUG mode on!");
- + return true;
- + }
- + L2Party party = player.getParty();
- + if (party == null)
- + {
- + player.sendPacket(SystemMessageId.NOT_IN_PARTY_CANT_ENTER);
- + return false;
- + }
- + L2CommandChannel channel = player.getParty().getCommandChannel();
- + if (channel == null)
- + {
- + player.sendPacket(SystemMessageId.NOT_IN_COMMAND_CHANNEL_CANT_ENTER);
- + return false;
- + }
- + else if (channel.getLeader() != player)
- + {
- + player.sendPacket(SystemMessageId.ONLY_PARTY_LEADER_CAN_ENTER);
- + return false;
- + }
- + else if ((channel.getMemberCount() < MIN_PLAYERS) || (channel.getMemberCount() > MAX_PLAYERS))
- + {
- + player.sendPacket(SystemMessageId.PARTY_EXCEEDED_THE_LIMIT_CANT_ENTER);
- + return false;
- + }
- + for (L2PcInstance channelMember : channel.getMembers())
- + {
- + if (channelMember.getLevel() < MIN_LEVEL)
- + {
- + SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_LEVEL_REQUIREMENT_NOT_SUFFICIENT);
- + sm.addPcName(channelMember);
- + party.broadcastPacket(sm);
- + return false;
- + }
- + QuestState st = channelMember.getQuestState("Q10286_ReunionWithSirra");
- + if (!(st != null && (st.getState() == State.COMPLETED || st.isCond(4))))
- + {
- + SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_QUEST_REQUIREMENT_NOT_SUFFICIENT);
- + sm.addPcName(channelMember);
- + party.broadcastPacket(sm);
- + return false;
- + }
- + if (!Util.checkIfInRange(1000, player, channelMember, true))
- + {
- + SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_IS_IN_LOCATION_THAT_CANNOT_BE_ENTERED);
- + sm.addPcName(channelMember);
- + party.broadcastPacket(sm);
- + return false;
- + }
- + Long reentertime = InstanceManager.getInstance().getInstanceTime(channelMember.getObjectId(), INSTANCEID);
- + if (System.currentTimeMillis() < reentertime)
- + {
- + SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_MAY_NOT_REENTER_YET);
- + sm.addPcName(channelMember);
- + party.broadcastPacket(sm);
- + return false;
- + }
- + }
- + return true;
- + }
- +
- + @Override
- + public String onEnterZone(L2Character character, L2ZoneType zone)
- + {
- + final InstanceWorld tmpWorld = InstanceManager.getInstance().getWorld(zone.getInstanceId());
- + if (tmpWorld instanceof FreyaWorld)
- + {
- + final FreyaWorld world = (FreyaWorld) tmpWorld;
- +
- + if (((character.isPlayer() && !world.started)))
- + {
- + if (DEBUG)
- + _log.info("Freya Instance: Player entered zone. Starting timer start_freya!");
- +
- + world.started = true;
- + startQuestTimer("start_freya", 5000, null, null);
- + }
- + }
- + return null;
- + }
- +
- + public static void main(String[] args)
- + {
- + new FreyaInstance(-1, FreyaInstance.class.getSimpleName(), "instances");
- + }
- +}
- \ No newline at end of file
Advertisement
Add Comment
Please, Sign In to add comment