Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package hellbound.Naia;
- import java.util.ArrayList;
- import java.util.Iterator;
- import javolution.util.FastMap;
- import com.l2jserver.gameserver.instancemanager.InstanceManager;
- import com.l2jserver.gameserver.instancemanager.InstanceManager.InstanceWorld;
- import com.l2jserver.gameserver.model.L2Party;
- import com.l2jserver.gameserver.model.L2Skill;
- import com.l2jserver.gameserver.model.actor.L2Npc;
- import com.l2jserver.gameserver.model.actor.L2Summon;
- import com.l2jserver.gameserver.model.actor.instance.L2DoorInstance;
- import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
- import com.l2jserver.gameserver.model.quest.Quest;
- import com.l2jserver.gameserver.model.quest.QuestState;
- import com.l2jserver.gameserver.network.SystemMessageId;
- import com.l2jserver.gameserver.network.serverpackets.NpcSay;
- import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
- import com.l2jserver.gameserver.util.Util;
- import com.l2jserver.util.Rnd;
- public class Naia extends Quest
- {
- private class teleCoord
- {
- int instanceId;
- int x;
- int y;
- int z;
- }
- private class TNNpc
- {
- public L2Npc npc;
- public boolean isDead = false;
- }
- private class TNRoom
- {
- public ArrayList<TNNpc> npcRoomList = new ArrayList<TNNpc>();
- }
- public class TNWorld extends InstanceWorld
- {
- public ArrayList<L2Npc> npcContolerList = new ArrayList<L2Npc>();
- public FastMap<String, TNRoom> rooms = new FastMap<String, TNRoom>().shared();
- //public ArrayList<L2Character> PlayerInZone = new ArrayList<L2Character>();
- public ArrayList<L2PcInstance> PlsInInstance = new ArrayList<L2PcInstance>();
- public L2Npc elpy = null;
- public boolean isMainParty = false;
- public int numberOfParties = 0;
- public int partyEntered = 0 ;
- public boolean naiaIsDone = false;
- public TNWorld()
- {
- InstanceManager.getInstance().super();
- }
- }
- private static boolean DEBUG = true;
- private static final String qn = "Naia";
- private static int[] NaiaMob = { 18490, 18491, 18493, 22393, 22394, 22395, 22411, 22412, 22413, 22414, 22415, 22439, 22440, 22441, 22442, 25604, 25605, 25606, 25607, 25608, 25609, 25610, 25611, 25612, 25613 };
- private static int[] IC = { 18494,18495,18496,18497,18498,18499,18500,18501,18502,18503,18504,18505, 18506};
- private final static int[][] IC_COORD = {
- {-46199, 246119, -9133, 32767}, //ws 0
- {-48992, 249171, -9132, 879}, //1
- {-51627, 246109, -9998, 16042}, //2
- {-48980, 243410, -9999,32767}, //3
- {-46199,246132,-9998,49952}, //4
- {-49332, 248580, -9999, 56600}, //5 Spawn in 1st rb room
- {-51636, 246116, -10860, 17864}, //6
- {-48541,243693, -10860, 23911}, //7 in boss room
- {-46226, 246120, -11718, 49151}, //8
- {-49320, 248561, -11721, 55801}, //9 in boss room
- {-51625, 246166, -12581, 16004}, //10
- {-48261, 243650, -13386, 32767}, //11
- };
- private final static int[][] BOSSES = //Used to store 4 bosses
- {
- {25609, -45472, 247462, -13957, 47813},
- {25610, -45472, 247462, -13957, 47813},
- {25611, -45472, 247462, -13957, 47813},
- {25612, -45472, 247462, -13957, 47813}
- };
- private final static int [][] EXIT_NPC = {
- {18506, -45230, 248372, -14190, 13986},
- {18506, -46146, 248125, -14191, 24541},
- {18506, -44562, 247703, -14191, 2786 },
- {18506, -44802, 246783, -14190, 56795},
- {18506, -45723, 246533, -14191, 46562},
- {18506, -46400, 247202, -14190, 35881}
- };
- private final static int [][] SPORES =
- {
- { 25605, -45725, 246538, -14192, 45892 },
- { 25606, -44567, 247697, -14192, 2810 },
- { 25607, -46145, 248116, -14192, 24848 },
- { 25608, -45234, 246538, -14191, 51727 },
- { 25605, -44814, 248123, -14191, 8121 },
- { 25606, -46395, 247696, -14191, 30119 },
- { 25607, -44806, 246779, -14191, 57414 },
- { 25608, -45235, 248365, -14191, 13993 },
- { 25605, -46393, 247206, -14191, 35486 },
- { 25606, -44562, 247206, -14191, 62746 },
- { 25607, -45724, 248362, -14192, 19111 },
- { 25608, -46145, 246786, -14192, 41005 },
- { 25613, -45675, 246719, -14192, 46825 },
- { 25613, -46020, 246907, -14192, 29412 },
- { 25613, -46221, 247255, -14192, 21673 },
- { 25613, -46224, 247653, -14192, 16109 },
- { 25613, -46026, 247991, -14192, 10467 },
- { 25613, -45684, 248194, -14192, 4728 },
- { 25613, -45287, 248192, -14192, 64612 },
- { 25613, -44935, 247995, -14192, 59571 },
- { 25613, -44740, 247652, -14192, 52771 },
- { 25613, -44738, 247253, -14192, 49946 },
- { 25613, -44935, 246909, -14192, 49151 },
- { 25613, -45278, 246712, -14192, 37969 }
- };
- public static void main(String[] args)
- {
- new Naia(-1, qn, "hellbound");
- }
- //CopyOnWriteArrayList
- public ArrayList<L2Npc> roofControllerList = new ArrayList<L2Npc>();
- public ArrayList<L2Npc> npcRoofList = new ArrayList<L2Npc>();
- private boolean isSpawnWard = false;
- private boolean isSpawnLock = false;
- private boolean isSpawnController = false;
- public Naia(int id, String name, String descr)
- {
- super(id, name, descr);
- addStartNpc(18492);
- addFirstTalkId(18492);
- addTalkId(18492);
- for (final int icnpc : IC)
- {
- addStartNpc(icnpc);
- addFirstTalkId(icnpc);
- addTalkId(icnpc);
- }
- for (final int mob : NaiaMob)
- addKillId(mob);
- //addEnterZoneId(12016);
- //addExitZoneId(12016);
- addAttackId(18491);
- SpawnRoofNpc();
- }
- private boolean checkConditions(L2PcInstance player)
- {
- if(DEBUG)
- return true;
- if(player.getParty() == null || player.getParty().getCommandChannel() == null)
- {
- player.sendMessage("You must enter with at least 2 full parties ( 18 members level 80 minimum ) in a Command Channel");
- return false;
- }
- if(player.getParty() != null || player.getParty().getCommandChannel() != null)
- {
- final L2Party party = player.getParty();
- if ( party.getCommandChannel().getMembers().size() < 4)//18 )
- {
- player.sendMessage("You must enter with at least 2 full parties ( 18 members level 80 minimum ) in a Command Channel");
- return false;
- }
- else if (party.getCommandChannel().getChannelLeader() != player)
- {
- player.sendMessage("Only the Command Channel Leader Can Talk to Me");
- return false;
- }
- else if (party.getCommandChannel().getMembers().size() > 45)
- {
- player.sendMessage("You can't enter with more than 45 members");
- return false;
- }
- else
- {
- for (final L2PcInstance channelMember : party.getCommandChannel().getMembers())
- {
- if (channelMember.getLevel() < 80)
- {
- final SystemMessage sm = new SystemMessage(SystemMessageId.C1_LEVEL_REQUIREMENT_NOT_SUFFICIENT);
- sm.addPcName(channelMember);
- player.sendPacket(sm);
- return false;
- }
- else if (!Util.checkIfInRange(500, player, channelMember, true))
- {
- final SystemMessage sm = new SystemMessage(SystemMessageId.C1_IS_IN_LOCATION_THAT_CANNOT_BE_ENTERED);
- sm.addPcName(channelMember);
- player.sendPacket(sm);
- return false;
- }
- }
- }
- return true;
- }
- player.sendMessage("Only the Command Channel Leader with minimum 18 members lvl 80 Can Talk to Me");
- return false;
- }
- private boolean checkConditions2(L2PcInstance player)
- {
- if(DEBUG)
- return true;
- if(player.getParty() == null || player.getParty().getCommandChannel() == null)
- {
- player.sendMessage("You must enter with at least 2 full parties ( 14 members level 80 minimum ) in a Command Channel");
- return false;
- }
- else if(player.getParty() != null || player.getParty().getCommandChannel() != null)
- {
- final L2Party party = player.getParty();
- if (player != player.getParty().getLeader())
- {
- player.sendMessage("Only a leader of a party in Command Channel can talk to me.");
- return false;
- }
- else if ( party.getCommandChannel().getMembers().size() < 4)//14 )
- {
- player.sendMessage("You must enter with at least 2 parties ( min 14 members level 80 minimum ) in a Command Channel");
- return false;
- }
- else if (party.getCommandChannel().getMembers().size() > 45)
- {
- player.sendMessage("You can't enter with more than 45 members");
- return false;
- }
- else
- {
- for (final L2PcInstance partyMember : party.getPartyMembers())
- {
- if (partyMember.getLevel() < 80)
- {
- final SystemMessage sm = new SystemMessage(SystemMessageId.C1_LEVEL_REQUIREMENT_NOT_SUFFICIENT);
- sm.addPcName(partyMember);
- player.sendPacket(sm);
- return false;
- }
- else if (!Util.checkIfInRange(500, player, partyMember, true))
- {
- final SystemMessage sm = new SystemMessage(SystemMessageId.C1_IS_IN_LOCATION_THAT_CANNOT_BE_ENTERED);
- sm.addPcName(partyMember);
- player.sendPacket(sm);
- return false;
- }
- }
- }
- return true;
- }
- player.sendMessage("Only the party Leader in command channel that contains minimum 14 members lvl 80 Can Talk to Me");
- return false;
- }
- private boolean checkKillProgress(L2Npc npc, TNRoom room)
- {
- boolean cont = true;
- for (final TNNpc npcobj : room.npcRoomList)
- {
- if (npcobj.npc == npc)
- npcobj.isDead = true;
- if (!npcobj.isDead)
- cont = false;
- }
- return cont;
- }
- protected void closeDoor(int doorId, int instanceId)
- {
- for (final L2DoorInstance door : InstanceManager.getInstance().getInstance(instanceId).getDoors())
- if (door.getDoorId() == doorId)
- if (door.getOpen())
- door.closeMe();
- }
- private final void enterInstance(L2PcInstance player, String template, teleCoord teleto)
- {
- if(DEBUG)
- {
- int instanceId = InstanceManager.getInstance().createDynamicInstance(template);
- TNWorld world = new TNWorld();
- world.instanceId = instanceId;
- teleto.instanceId = instanceId;
- InstanceManager.getInstance().addWorld(world);
- world.allowed.add(player.getObjectId());
- if (player.getQuestState(qn) == null)
- {
- newQuestState(player);
- }
- teleportplayer(player, teleto);
- world.PlsInInstance.add(player);
- addSpawn(IC[world.status], IC_COORD[world.status][0], IC_COORD[world.status][1], IC_COORD[world.status][2], IC_COORD[world.status][3], false, 0, false, world.instanceId);
- openDoor(18250001, world.instanceId);
- /*for (final L2Npc control : roofControllerList)
- {
- if (control.getNpcId() == 18492)
- {
- control.deleteMe();
- roofControllerList.remove(control);
- }
- }*/
- for (Iterator<L2Npc> it = roofControllerList.iterator() ; it.hasNext();)
- {
- L2Npc controller = it.next();
- if (controller.getNpcId() == 18492)
- {
- controller.deleteMe();
- it.remove();
- }
- }
- isSpawnController = false;
- isSpawnWard = false;
- isSpawnLock = false;
- startQuestTimer("respawn_roof",180000 , null, null);
- return;
- }
- if(player.getInstanceId() != 0 && !DEBUG)
- {
- player.sendMessage("You are already in another instance Teleportation aborted.");
- return ;
- }
- if (!DEBUG)
- {
- int counter = 0;
- for(L2Party party : player.getParty().getCommandChannel().getPartys())
- {
- counter++;
- int instanceId = InstanceManager.getInstance().createDynamicInstance(template);
- TNWorld world = new TNWorld();
- world.instanceId = instanceId;
- teleto.instanceId = instanceId;
- InstanceManager.getInstance().addWorld(world);
- _log.info("Tower Of Naia: started " + template + " Instance: " + instanceId + " created for party leader : " + party.getLeader().getName()
- + ", The CCL is :" + party.getCommandChannel().getChannelLeader().getName() + ".");
- for (L2PcInstance partyMember : party.getPartyMembers())
- {
- world.allowed.add(partyMember.getObjectId());
- if (partyMember.getQuestState(qn) == null)
- {
- newQuestState(partyMember);
- }
- if (partyMember == party.getCommandChannel().getChannelLeader())
- {
- world.isMainParty = true;
- }
- teleportplayer(partyMember, teleto);
- world.PlsInInstance.add(partyMember);
- }
- addSpawn(IC[world.status], IC_COORD[world.status][0], IC_COORD[world.status][1], IC_COORD[world.status][2], IC_COORD[world.status][3], false, 0, false, world.instanceId);
- openDoor(18250001, world.instanceId);
- }
- /*
- for (final L2Npc control : roofControllerList)
- {
- if (control.getNpcId() == 18492)
- {
- control.deleteMe();
- roofControllerList.remove(control);
- }
- }
- */
- for (Iterator<L2Npc> it = roofControllerList.iterator() ; it.hasNext();)
- {
- L2Npc controller = it.next();
- if (controller.getNpcId() == 18492)
- {
- controller.deleteMe();
- it.remove();
- }
- }
- isSpawnController = false;
- isSpawnWard = false;
- isSpawnLock = false;
- startQuestTimer("respawn_roof",180000 , null, null);
- InstanceWorld mainInstance = InstanceManager.getInstance().getPlayerWorld(player.getParty().getCommandChannel().getChannelLeader());
- if (mainInstance instanceof TNWorld)
- {
- TNWorld mainWorld = (TNWorld) mainInstance;
- mainWorld.numberOfParties = counter;
- }
- return ;
- }
- }
- /*final L2Party party = player.getParty();
- InstanceWorld world = InstanceManager.getInstance().getPlayerWorld(player);
- final FastMap<Integer, Instance> instanceMap = InstanceManager.getInstance().getInstances();
- if (!checkConditions(player))
- return 0;
- for (final Instance temp : instanceMap.values())
- {
- if(temp.getName().contains("TowerOfNaia"))
- {
- IsNaia = 1;
- instanceId = temp.getId();
- world = InstanceManager.getInstance().getWorld(instanceId);
- world.instanceId = instanceId;
- teleto.instanceId = instanceId;
- if (DEBUG)
- {
- if (player != LeaderChannel)
- {
- player.sendMessage("Leader is not player in instance check"); //mising txt
- return 0;
- }
- }
- else if ( party.getCommandChannel().getChannelLeader() != LeaderChannel )
- {
- player.sendMessage("You are not the party channel Leader"); //mising txt
- return 0;
- }
- }
- }
- if ( IsNaia == 0 )
- {
- instanceId = InstanceManager.getInstance().createDynamicInstance(template);
- world = new TNWorld();
- world.instanceId = instanceId;
- teleto.instanceId = instanceId;
- InstanceManager.getInstance().addWorld(world);
- _log.info("Tower Of Naia: started " + template + " Instance: " + instanceId + " created");
- if(DEBUG)
- {
- LeaderChannel = player;
- }
- else
- {
- LeaderChannel = party.getCommandChannel().getChannelLeader();
- }
- }
- final Instance InstanceZone = InstanceManager.getInstance().getInstance(world.instanceId);
- final TNWorld wroof = (TNWorld) world;
- if (DEBUG)
- {
- if (player.getQuestState(qn) == null)
- newQuestState(player);
- teleportplayer(player, teleto);
- wroof.PlsInInstance.add(player);
- startQuestTimer("stopfight_30",1800000,null,player);
- }
- else if (InstanceZone.getPlayers().size() + party.getPartyMembers().size() < 46)
- for (final L2PcInstance partyMember : party.getPartyMembers())
- {
- if (partyMember.getQuestState(qn) == null)
- newQuestState(partyMember);
- teleportplayer(partyMember, teleto);
- wroof.PlsInInstance.add(partyMember);
- startQuestTimer("stopfight_30",1800000,null,partyMember);
- }
- else
- {
- player.sendMessage("SomeThing Wrong"); //mising txt
- return 0;
- }
- addSpawn(IC[world.status], IC_COORD[world.status][0], IC_COORD[world.status][1], IC_COORD[world.status][2], IC_COORD[world.status][3], false, 0, false, world.instanceId);
- openDoor(18250001, world.instanceId);
- isSpawnController = false;
- isSpawnWard = false;
- isSpawnLock = false;
- for (final L2Npc control : roofControllerList)
- {
- if (control.getNpcId() == 18492)
- {
- control.deleteMe();
- roofControllerList.remove(control);
- }
- }
- startQuestTimer("respawn_roof",180000 , null, player);
- return instanceId;
- }
- */
- private void exitInstance(L2PcInstance player, teleCoord tele)
- {
- final InstanceWorld insworld = InstanceManager.getInstance().getWorld(player.getInstanceId());
- if (insworld instanceof TNWorld)
- {
- final TNWorld world = (TNWorld) insworld;
- for (final L2PcInstance plr : world.PlsInInstance)
- {
- plr.sendMessage("Exit Instance");
- plr.setInstanceId(0);
- plr.teleToLocation(tele.x, tele.y, tele.z);
- }
- }
- }
- private void goToBeleth(L2PcInstance player, teleCoord tele)
- {
- final InstanceWorld insworld = InstanceManager.getInstance().getWorld(player.getInstanceId());
- if (DEBUG && insworld instanceof TNWorld )
- {
- final TNWorld world = (TNWorld) insworld;
- world.naiaIsDone = true;
- player.setInstanceId(tele.instanceId);
- player.teleToLocation(tele.x, tele.y, tele.z);
- return;
- }
- final InstanceWorld mainWorldIns = InstanceManager.getInstance().getWorld(player.getParty().getCommandChannel().getChannelLeader().getInstanceId());
- if (insworld instanceof TNWorld && mainWorldIns instanceof TNWorld)
- {
- final TNWorld world = (TNWorld) insworld;
- final TNWorld mainWorld = (TNWorld) mainWorldIns;
- if ( world.status == 13 )
- {
- for (final L2PcInstance plr : player.getParty().getPartyMembers())
- {
- plr.setInstanceId(tele.instanceId);
- plr.teleToLocation(tele.x, tele.y, tele.z);
- world.allowed.remove(world.allowed.indexOf(plr.getObjectId()));
- mainWorld.allowed.add(plr.getObjectId());
- }
- mainWorld.partyEntered++;
- if (mainWorld.numberOfParties == mainWorld.partyEntered)
- {
- mainWorld.naiaIsDone = true;
- _log.info("Tower of naia is Done , Command channel Leader name is : "+ player.getParty().getCommandChannel().getChannelLeader().getName());
- }
- }
- }
- }
- @Override
- public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
- {
- if (player != null)
- {
- final InstanceWorld insworld = InstanceManager.getInstance().getWorld(player.getInstanceId());
- final TNRoom Room = new TNRoom();
- TNNpc roomnpc;
- TNWorld world;
- //final int NpcId = npc.getNpcId();
- if (insworld instanceof TNWorld)
- {
- world = (TNWorld) insworld;
- if(event.equalsIgnoreCase("startfight") && player.getInstanceId() == world.instanceId && Util.contains(IC, npc.getNpcId()))
- if (!world.npcContolerList.contains(npc))
- {
- world.npcContolerList.add(npc);
- startQuestTimer("stopfight", 300000, npc, player);
- Room.npcRoomList.clear();
- if(npc.getNpcId() == 18494)
- {
- closeDoor(18250001, world.instanceId);
- world.status = 1;
- for (int i = 0; i < 6; i++)
- {
- roomnpc = new TNNpc();
- roomnpc.npc = addSpawn(22393 + Rnd.get(2), -45700 - Rnd.get(1000), 245600 + Rnd.get(1000), -9125, Rnd.get(65000), false, 0, false, world.instanceId);
- Room.npcRoomList.add(roomnpc);
- }
- world.rooms.put("Room_1", Room);
- }
- else if(npc.getNpcId() == 18495)
- {
- closeDoor(18250003, world.instanceId);
- world.status = 2;
- for (int i = 0; i < 6; i++)
- {
- roomnpc = new TNNpc();
- roomnpc.npc = addSpawn(22439, -48100 - Rnd.get(1600), 249000 + Rnd.get(300), -9123, Rnd.get(65000), false, 0, false, world.instanceId);
- Room.npcRoomList.add(roomnpc);
- }
- world.rooms.put("Room_2", Room);
- }
- else if(npc.getNpcId() == 18496)
- {
- closeDoor(18250005, world.instanceId);
- world.status = 3;
- for (int i = 0; i < 6; i++)
- {
- roomnpc = new TNNpc();
- roomnpc.npc = addSpawn(22441, -51120 - Rnd.get(1000), 245600 + Rnd.get(1000), -9990, Rnd.get(65000), false, 0, false, world.instanceId);
- Room.npcRoomList.add(roomnpc);
- }
- world.rooms.put("Room_3", Room);
- }
- else if(npc.getNpcId() == 18497)
- {
- closeDoor(18250007, world.instanceId);
- world.status = 4;
- for (int i = 0; i < 6; i++)
- {
- roomnpc = new TNNpc();
- roomnpc.npc = addSpawn(22440, -48100 - Rnd.get(1600), 243250 + Rnd.get(300), -9990, Rnd.get(65000), false, 0, false, world.instanceId);
- Room.npcRoomList.add(roomnpc);
- }
- world.rooms.put("Room_4", Room);
- }
- else if(npc.getNpcId() == 18498)
- {
- closeDoor(18250009, world.instanceId);
- world.status = 5;
- roomnpc = new TNNpc();
- roomnpc.npc = addSpawn(22393, -45700 - Rnd.get(1000), 245600 + Rnd.get(1000), -9990, Rnd.get(65000), false, 0, false, world.instanceId);
- Room.npcRoomList.add(roomnpc);
- roomnpc = new TNNpc();
- roomnpc.npc = addSpawn(22415, -45700 - Rnd.get(1000), 245600 + Rnd.get(1000), -9990, Rnd.get(65000), false, 0, false, world.instanceId);
- Room.npcRoomList.add(roomnpc);
- roomnpc = new TNNpc();
- roomnpc.npc = addSpawn(22411, -45700 - Rnd.get(1000), 245600 + Rnd.get(1000), -9990, Rnd.get(65000), false, 0, false, world.instanceId);
- Room.npcRoomList.add(roomnpc);
- world.rooms.put("Room_5", Room);
- for (int i = 0; i < 3; i++)
- {
- roomnpc = new TNNpc();
- roomnpc.npc = addSpawn(22394, -45700 - Rnd.get(1000), 245600 + Rnd.get(1000), -9990, Rnd.get(65000), false, 0, false, world.instanceId);
- Room.npcRoomList.add(roomnpc);
- }
- world.rooms.put("Room_5", Room);
- }
- else if(npc.getNpcId() == 18499)
- {
- closeDoor(18250011, world.instanceId);
- world.status = 6;
- for (int i = 0; i < 6; i++)
- {
- roomnpc = new TNNpc();
- roomnpc.npc = addSpawn(22395, -48500 - Rnd.get(800), 247800 + Rnd.get(800), -9990, Rnd.get(65000), false, 0, false, world.instanceId);
- Room.npcRoomList.add(roomnpc);
- }
- world.rooms.put("Room_6", Room);
- }
- else if(npc.getNpcId() == 18500)
- {
- closeDoor(18250013, world.instanceId);
- world.status = 7;
- for (int i = 0; i < 6; i++)
- {
- roomnpc = new TNNpc();
- roomnpc.npc = addSpawn(22414 + Rnd.get(2), -51200 - Rnd.get(800), 245600 + Rnd.get(800), -10852, Rnd.get(65000), false, 0, false, world.instanceId);
- Room.npcRoomList.add(roomnpc);
- }
- world.rooms.put("Room_7", Room);
- }
- else if(npc.getNpcId() == 18501)
- {
- closeDoor(18250015, world.instanceId);
- world.status = 8;
- for (int i = 0; i < 6; i++)
- {
- roomnpc = new TNNpc();
- roomnpc.npc = addSpawn(22395, -48550 - Rnd.get(700), 243700 + Rnd.get(700), -10854, Rnd.get(65000), false, 0, false, world.instanceId);
- Room.npcRoomList.add(roomnpc);
- }
- world.rooms.put("Room_8", Room);
- }
- else if(npc.getNpcId() == 18502)
- {
- closeDoor(18250017, world.instanceId);
- world.status = 9;
- for (int i = 0; i < 3; i++)
- {
- roomnpc = new TNNpc();
- roomnpc.npc = addSpawn(22441, -45700 - Rnd.get(1000), 245600 + Rnd.get(1000), -11712, Rnd.get(65000), false, 0, false, world.instanceId);
- Room.npcRoomList.add(roomnpc);
- roomnpc = new TNNpc();
- roomnpc.npc = addSpawn(22442, -45700 - Rnd.get(1000), 245600 + Rnd.get(1000), -11712, Rnd.get(65000), false, 0, false, world.instanceId);
- Room.npcRoomList.add(roomnpc);
- }
- world.rooms.put("Room_9", Room);
- }
- else if(npc.getNpcId() == 18503)
- {
- closeDoor(18250019, world.instanceId);
- world.status = 10;
- for (int i = 0; i < 6; i++)
- {
- roomnpc = new TNNpc();
- roomnpc.npc = addSpawn(22395, -48550 - Rnd.get(700), 247800 + Rnd.get(700), -11712, Rnd.get(65000), false, 0, false, world.instanceId);
- Room.npcRoomList.add(roomnpc);
- }
- world.rooms.put("Room_10", Room);
- }
- else if(npc.getNpcId() == 18504)
- {
- closeDoor(18250021, world.instanceId);
- world.status = 11;
- for (int i = 0; i < 6; i++)
- {
- roomnpc = new TNNpc();
- roomnpc.npc = addSpawn(22413, -51100 - Rnd.get(1000), 245500 + Rnd.get(1200), -12575, Rnd.get(65000), false, 0, false, world.instanceId);
- Room.npcRoomList.add(roomnpc);
- }
- world.rooms.put("Room_11", Room);
- }
- else if(npc.getNpcId() == 18505)
- {
- closeDoor(18250023, world.instanceId);
- world.status = 12;
- for (int i = 0; i < 6; i++)
- {
- roomnpc = new TNNpc();
- roomnpc.npc = addSpawn(18490, -47700 - Rnd.get(1100), 243100 + Rnd.get(1000), -13379, Rnd.get(65000), false, 0, false, world.instanceId);
- Room.npcRoomList.add(roomnpc);
- }
- world.elpy = addSpawn( 25604, -44938, 248334, -14194, 57995, false, 0, false, world.instanceId);
- world.rooms.put("Room_12", Room);
- }
- }
- else
- return "<html><body>Ingenious Contraption:<br>Button is activated.</body></html>";
- if(event.equalsIgnoreCase("SpawnSpores") && player.getInstanceId() == world.instanceId)
- {
- closeDoor(18250025, world.instanceId);
- world.status = 13;
- for (int i = 0 ; i < 24 ; i++)
- {
- roomnpc = new TNNpc();
- roomnpc.npc = addSpawn( SPORES[i][0], SPORES[i][1], SPORES[i][2], SPORES[i][3], SPORES[i][4], false, 0, false, world.instanceId);
- roomnpc.npc.setIsNoRndWalk(true);
- Room.npcRoomList.add(roomnpc);
- }
- world.rooms.put("Room_13", Room);
- }
- if (event.equals("stopfight"))
- {
- final teleCoord tele = new teleCoord();
- tele.x = 16323 ;
- tele.y = 209090 ;
- tele.z = -9365 ;
- world.rooms.clear();
- world.npcContolerList.clear();
- exitInstance(player,tele);
- cancelQuestTimers("stopfight_30");
- }
- /*if (event.equals("stopfight_30"))
- {
- final teleCoord tele = new teleCoord();
- tele.x = 16430;
- tele.y = 244437;
- tele.z = 11618;
- world.rooms.clear();
- world.npcContolerList.clear();
- exitInstance(player,tele);
- cancelQuestTimers("stopfight");
- }*/
- if (event.equalsIgnoreCase("GoToBeleth"))
- {
- if (DEBUG)
- {
- player.sendMessage("Regrouping Parties Going to Beleth");
- final teleCoord tele = new teleCoord();
- tele.x = 16310;
- tele.y = 209323;
- tele.z = -9365;
- tele.instanceId = world.instanceId;
- goToBeleth(player, tele);
- }
- else if (player.getParty().getCommandChannel() !=null)
- {
- InstanceWorld temp = InstanceManager.getInstance().getPlayerWorld(player.getParty().getCommandChannel().getChannelLeader());
- int instanceId = player.getParty().getCommandChannel().getChannelLeader().getInstanceId();
- if (temp instanceof TNWorld && instanceId != 0)
- {
- final teleCoord tele = new teleCoord();
- tele.x = 16310;
- tele.y = 209323;
- tele.z = -9365;
- tele.instanceId = instanceId;
- goToBeleth(player, tele);
- }
- }
- else
- {
- player.sendMessage("Wrong Conditions !!");
- return "";
- }
- }
- }
- if (event.equalsIgnoreCase("enternaia"))
- {
- if (DEBUG)
- {
- player.sendMessage("Event enter Naia");
- }
- final teleCoord tele = new teleCoord();
- tele.x = -47240;
- tele.y = 246120;
- tele.z = -9125;
- enterInstance(player, "TowerOfNaia.xml", tele);
- }
- }
- else if (event.equalsIgnoreCase("respawn_roof"))
- {
- if (roofControllerList.size() > 0)
- {
- //for (L2Npc controller : roofControllerList)
- //{
- //if (controller.getNpcId() == 18492)
- //{
- //controller.deleteMe();
- //roofControllerList.remove(controller);
- //}
- //}
- for (Iterator<L2Npc> it= roofControllerList.iterator();it.hasNext();)
- {
- L2Npc controller = it.next();
- if (controller.getNpcId() == 18492)
- {
- controller.deleteMe();
- it.remove();
- }
- }
- }
- if (npcRoofList.size() > 0)
- {
- //for (L2Npc rfNpc : npcRoofList)
- //{
- //if (rfNpc.getNpcId() == 18491 || rfNpc.getNpcId() == 18493 )
- //{
- //rfNpc.deleteMe();
- //npcRoofList.remove(rfNpc);
- //}
- //}
- for (Iterator<L2Npc> it = npcRoofList.iterator(); it.hasNext();)
- {
- L2Npc rfNpc = it.next();
- if (rfNpc.getNpcId() == 18491 || rfNpc.getNpcId() == 18493)
- {
- rfNpc.deleteMe();
- it.remove();
- }
- }
- }
- isSpawnController = false;
- isSpawnLock = false;
- isSpawnWard = false;
- SpawnRoofNpc();
- }
- return "";
- }
- @Override
- public String onAttack (L2Npc npc, L2PcInstance attacker, int damage, boolean isPet, L2Skill skill)
- {
- if(npc.getNpcId() == 18491 && npcRoofList.size() < 2 && npc.getCurrentHp() < npc.getMaxHp()*0.4 && !isSpawnWard)
- {
- for(int i = 0; i < 4; i++)
- {
- final L2Npc roofmob = addSpawn(18493,16100 + Rnd.get(600),244100 + Rnd.get(600),11620,Rnd.get(65000),false,0,false,0);
- npcRoofList.add(roofmob);
- }
- isSpawnWard = true;
- }
- return "";
- }
- /* @Override
- public String onEnterZone(L2Character character, L2ZoneType zone)
- {
- TNWorld world;
- if (character instanceof L2PcInstance)
- {
- final InstanceWorld tmpw = InstanceManager.getInstance().getWorld(character.getInstanceId());
- final Instance instance = InstanceManager.getInstance().getInstance(character.getInstanceId());
- if (tmpw instanceof TNWorld && instance != null && zone.getId() == 12016)
- {
- character.sendMessage("Enterzone");
- world = (TNWorld) tmpw;
- world.PlayerInZone.add(character);
- if ( world.PlayerInZone.size() == instance.getPlayers().size() && npcRoofList.size() == 0)
- {
- cancelQuestTimers("stopfight_30");
- world.PlsInInstance.clear();
- npcContolerList.clear();
- for (final L2DoorInstance door : InstanceManager.getInstance().getInstance(world.instanceId).getDoors())
- if (door.getDoorId() != 18250025)
- door.closeMe();
- if(!isSpawncontroller)
- SpawnRoofNpc();
- }
- }
- }
- return super.onEnterZone(character, zone);
- }
- @Override
- public String onExitZone(L2Character character, L2ZoneType zone)
- {
- TNWorld world;
- if (character instanceof L2PcInstance)
- {
- final InstanceWorld tmpw = InstanceManager.getInstance().getWorld(character.getInstanceId());
- final Instance instance = InstanceManager.getInstance().getInstance(character.getInstanceId());
- if (tmpw instanceof TNWorld && instance != null && zone.getId() == 12016)
- {
- character.sendMessage("Exit Zone");
- world = (TNWorld) tmpw;
- world.PlayerInZone.remove(character);
- }
- }
- return super.onExitZone(character, zone);
- }
- */
- @Override
- public String onFirstTalk(L2Npc npc, L2PcInstance player)
- {
- final QuestState st = player.getQuestState(getName());
- if (st == null)
- newQuestState(player);
- final int NpcId = npc.getNpcId();
- if (NpcId == 18492 )
- {
- if(npcRoofList.size() > 0 )
- {
- npc.deleteMe();
- roofControllerList.remove(npc);
- isSpawnController = false;
- /*for(final L2Npc rfnpc : npcRoofList)
- if (rfnpc.getNpcId() == 18491)
- {
- rfnpc.deleteMe();
- npcRoofList.remove(rfnpc);
- }*/
- for (Iterator<L2Npc> it = npcRoofList.iterator(); it.hasNext(); )
- {
- L2Npc rfnpc = it.next();
- if (rfnpc.getNpcId() == 18491)
- {
- rfnpc.deleteMe();
- it.remove();
- }
- }
- isSpawnLock = false;
- startQuestTimer("respawn_roof",(180 + Rnd.get(120))*1000,null,null);
- }
- else if (checkConditions(player))
- return "18492.htm";
- }
- else if (NpcId == 18506 && checkConditions2(player) )
- return "ToBeleth.htm";
- else if (Util.contains(IC, NpcId) && NpcId != 18506)
- {
- if (player.getParty() == null)
- {
- player.sendMessage("Only a party leader can talk to me ");
- return "";
- }
- else if (player != player.getParty().getLeader())
- {
- player.sendMessage("Only a party leader can talk to me ");
- return"";
- }
- else if (true)
- {
- for (final L2PcInstance partyMember : player.getParty().getPartyMembers())
- {
- if (!Util.checkIfInRange(500, player, partyMember, true))
- {
- final SystemMessage sm = new SystemMessage(SystemMessageId.C1_IS_IN_LOCATION_THAT_CANNOT_BE_ENTERED);
- sm.addPcName(partyMember);
- player.sendPacket(sm);
- return "";
- }
- }
- }
- return "Start.htm";
- }
- return "";
- }
- @Override
- public String onKill(L2Npc npc, L2PcInstance player, boolean isPet)
- {
- final InstanceWorld insid = InstanceManager.getInstance().getWorld(npc.getInstanceId());
- if (insid instanceof TNWorld)
- {
- TNRoom Room;
- TNNpc roomnpc;
- final TNWorld world = (TNWorld) insid;
- final int ws = world.status;
- if ( ws == 5 && npc.getNpcId() == 22415)
- {
- Room = new TNRoom();
- for (int i = 1; i < 3; i++)
- {
- roomnpc = new TNNpc();
- roomnpc.npc = addSpawn(22412, -45700 - Rnd.get(1000), 245600 + Rnd.get(1000), -9990, Rnd.get(65000), false, 0, false, world.instanceId);
- Room.npcRoomList.add(roomnpc);
- }
- world.rooms.put("Room_5", Room);
- }
- else if ( ws == 7 )
- {
- if ( npc.getNpcId() == 22414 || npc.getNpcId() == 22415)
- if (checkKillProgress(npc, world.rooms.get("Room_"+String.valueOf(ws))))
- {
- Room = new TNRoom();
- for (int i = 1; i < 3; i++)
- {
- roomnpc = new TNNpc();
- roomnpc.npc = addSpawn(22412, -51200 - Rnd.get(800), 245600 + Rnd.get(800), -10852, Rnd.get(65000), false, 0, false, world.instanceId);
- Room.npcRoomList.add(roomnpc);
- }
- world.rooms.put("Room_7", Room);
- }
- }
- else if (ws == 13)
- {
- if ( npc.getNpcId() == 25605 || npc.getNpcId() == 25606 || npc.getNpcId() == 25607 || npc.getNpcId() == 25608 || npc.getNpcId() == 25613)
- {
- if (DEBUG)
- _log.info("NPC true");
- if (checkKillProgress(npc, world.rooms.get("Room_"+String.valueOf(ws))))
- {
- if (DEBUG)
- _log.info("room Empty true");
- Room = new TNRoom();
- int spawnChance = Rnd.get(4);
- roomnpc = new TNNpc();
- roomnpc.npc = addSpawn(BOSSES[spawnChance][0],BOSSES[spawnChance][1],BOSSES[spawnChance][2],BOSSES[spawnChance][3], BOSSES[spawnChance][4], false, 0, false, world.instanceId);
- Room.npcRoomList.add(roomnpc);
- world.rooms.put("Room_13", Room);
- }
- }
- }
- if (checkKillProgress(npc, world.rooms.get("Room_"+String.valueOf(ws))))
- {
- if (ws == 6)
- openDoor(18250101,world.instanceId);
- else if (ws == 8)
- openDoor(18250102,world.instanceId);
- else if (ws == 10)
- openDoor(18250103,world.instanceId);
- else if (ws < 13)
- openDoor(18250000 + ws*2,world.instanceId);
- if (ws < 13)
- {
- openDoor(18250001 + ws*2,world.instanceId);
- cancelQuestTimers("stopfight");
- }
- if (ws < 12 )
- {
- addSpawn(IC[ws], IC_COORD[ws][0], IC_COORD[ws][1], IC_COORD[ws][2], IC_COORD[ws][3], false, 0, false, world.instanceId);
- }
- else if (ws == 12 && world.elpy != null && npc.getObjectId() == world.elpy.getObjectId() )
- {
- startQuestTimer("SpawnSpores", 300000, null, player);
- world.elpy.broadcastPacket(new NpcSay(world.elpy.getObjectId(), 1, world.elpy.getNpcId(), "Huh ? Killing Elpys ?! Is that all you can do ?! All doors will be closed in 5 mins ! Stay in this Room, Lets show up !!"));
- }
- else if (ws == 13)
- for (int i = 0 ;i < 6 ; i++)
- addSpawn (EXIT_NPC[i][0], EXIT_NPC[i][1], EXIT_NPC[i][2], EXIT_NPC[i][3], EXIT_NPC[i][4], false, 0, false, world.instanceId);
- }
- }
- if ( npc.getNpcId() == 18491 || npc.getNpcId() == 18493)
- npcRoofList.remove(npc);
- return "";
- }
- protected void openDoor(int doorId, int instanceId)
- {
- for (final L2DoorInstance door : InstanceManager.getInstance().getInstance(instanceId).getDoors())
- if (door.getDoorId() == doorId)
- door.openMe();
- }
- private void SpawnRoofNpc()
- {
- if (!isSpawnLock && !isSpawnController)
- {
- final L2Npc roofnpc = addSpawn(18491,16409,244437,11618,0,false,0,false,0);
- roofnpc.setIsNoRndWalk(true);
- isSpawnLock = true;
- npcRoofList.add(roofnpc);
- final L2Npc roofcontr = addSpawn(18492,16640,244400,11618,33300,false,0,false,0);
- roofControllerList.add(roofcontr);
- isSpawnController = true;
- }
- }
- private void teleportplayer(L2PcInstance player, teleCoord teleto)
- {
- player.setInstanceId(teleto.instanceId);
- player.teleToLocation(teleto.x, teleto.y, teleto.z);
- final L2Summon pet = player.getPet();
- if (pet != null)
- {
- pet.setInstanceId(teleto.instanceId);
- pet.teleToLocation(teleto.x, teleto.y, teleto.z);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement