http://www.youtube.com/watch?v=z7OBTg3fRjE#t=124
### Eclipse Workspace Patch 1.0
#P L2J_DataPack
Index: dist/game/data/scripts/instances/PresentArms/DistanceParty.htm
===================================================================
--- dist/game/data/scripts/instances/PresentArms/DistanceParty.htm (revision 0)
+++ dist/game/data/scripts/instances/PresentArms/DistanceParty.htm (working copy)
@@ -0,0 +1,3 @@
+<html><body>Undead:<br>
+where is your party? <font color="LEVEL">must all here to enter</font>
+</body></html>
\ No newline at end of file
Index: dist/game/data/scripts/instances/PresentArms/DontNumber.htm
===================================================================
--- dist/game/data/scripts/instances/PresentArms/DontNumber.htm (revision 0)
+++ dist/game/data/scripts/instances/PresentArms/DontNumber.htm (working copy)
@@ -0,0 +1,3 @@
+<html><body>Undead:<br>
+You need to <font color="LEVEL">get more warriors</font> to enter.
+</body></html>
\ No newline at end of file
Index: dist/game/data/scripts/instances/PresentArms/Welcome.htm
===================================================================
--- dist/game/data/scripts/instances/PresentArms/Welcome.htm (revision 0)
+++ dist/game/data/scripts/instances/PresentArms/Welcome.htm (working copy)
@@ -0,0 +1,16 @@
+<html><body>
+<center>
+<table border="0" cellpadding="0" cellspacing="0" width="292" height="350" background="L2UI_CH3.refinewnd_back_Pattern">
+<tr><td valign="top" align="center">
+<table border="0" cellpadding="0" cellspacing="0">
+</table><br><br>
+<center>
+Hello adventurer<br>
+</center>
+<td align=center><button action="bypass -h Quest PresentArms Enter" value="Enter" width=200 height=31 back="L2UI_CT1.OlympiadWnd_DF_Info_Down" fore="L2UI_CT1.OlympiadWnd_DF_Info"><br>
+<br><br>
+<font color="6E6767">by L2jAdmins</color>
+</td>
+</tr></table>
+</center>
+</body></html>
\ No newline at end of file
Index: dist/game/data/scripts/instances/PresentArms/PresentArms.java
===================================================================
--- dist/game/data/scripts/instances/PresentArms/PresentArms.java (revision 0)
+++ dist/game/data/scripts/instances/PresentArms/PresentArms.java (working copy)
@@ -0,0 +1,421 @@
+package instances.PresentArms;
+
+import java.util.List;
+
+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.L2Party;
+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.L2MonsterInstance;
+import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
+import com.l2jserver.gameserver.model.entity.Instance;
+import com.l2jserver.gameserver.model.instancezone.InstanceWorld;
+import com.l2jserver.gameserver.model.quest.Quest;
+import com.l2jserver.gameserver.network.SystemMessageId;
+import com.l2jserver.gameserver.network.clientpackets.Say2;
+import com.l2jserver.gameserver.network.serverpackets.CreatureSay;
+import com.l2jserver.gameserver.network.serverpackets.NpcSay;
+import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
+import com.l2jserver.gameserver.util.Broadcast;
+
+/**
+ * @author fissban
+ */
+public class PresentArms extends Quest
+{
+ // INSTANCE - Don't Change
+ private static final int INSTANCE_ID = 998;
+ // NPC's list - Don't Change
+ private static List<L2Npc> _npclist = new FastList<>();
+ // Don't Change
+ private static int round = 0;
+ // Don't Change
+ private static int dead = 0;
+ // Don't Change
+ private static boolean run_events = false;
+ // Don't Change
+ private static final int x = 26907;
+ private static final int y = -49223;
+ private static final int z = -1301;
+ // Don't Change
+ private static int member_count = 1;
+ // Min Player enter instance
+ private static final int player_min = 2;
+ // NPC ID
+ private static final int NPC = 21;
+ // Time Instance
+ private static final int time = 60 * 60 * 1000; // 60 min
+
+ // @formatter:off
+ private static final int[] _guardias =
+ {
+ 50, //lord
+ 51, //warrior
+ 52 //archer
+ };
+ private static final int camp = 49;
+ private static final int[] _guardias_count = // valor x3x2+1
+ {
+ 2, 4, 6,
+ };
+
+ // Drops
+ // itemId, Chance, Minimo, Maximo
+ private static final int[][] DROPLIST =
+ {
+ { // Revita Pop
+ 20034,
+ 95, // 5%
+ 1,
+ 1
+ },
+ {// Giant's Codex
+ 6622,
+ 85, // 10%
+ 1,
+ 1
+ },
+ };
+
+ private static final int[][] DROPLIST_herbs =
+ {
+ {// Herbs Life
+ 8600,
+ 90, // 10%
+ 1,
+ 1
+ },
+ {// Herbs mana
+ 8604,
+ 80, // 10%
+ 1,
+ 1
+ },
+ };
+
+ // Teleports
+ private static final int[][] TELEPORTS =
+ {
+ // TODO agregar los demas puntos restantes para los castillos
+ {// ENTER - Rune Castle
+ 21742, -49137, -1301
+ },
+ {// EXIT - Giran
+ 83435, 148616, -3403
+ }
+ };
+ // @formatter:on
+
+ public PresentArms()
+ {
+ super(-1, PresentArms.class.getSimpleName(), "instances");
+
+ addStartNpc(NPC);
+ addFirstTalkId(NPC);
+ addTalkId(NPC);
+
+ addKillId(_guardias);
+ addSeeCreatureId(_guardias);
+ addStartNpc(_guardias);// TODO necesario?
+ }
+
+ public static void main(String[] args)
+ {
+ new PresentArms();
+ }
+
+ private class PresentArmsWorld extends InstanceWorld
+ {
+ public PresentArmsWorld()
+ {
+ }
+ }
+
+ @Override
+ public String onFirstTalk(L2Npc npc, L2PcInstance player)
+ {
+ if (npc.getNpcId() == NPC)
+ {
+ return "Welcome.htm";
+ }
+ return super.onTalk(npc, player);
+ }
+
+ @Override
+ public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
+ {
+ if (event.startsWith("Enter"))
+ {
+ if (!player.isGM())
+ {
+ if (!player.isInParty())
+ {
+ return "DontParty.htm";
+ }
+
+ final L2Party party = player.getParty();
+
+ if (!party.isLeader(player))
+ {
+ return "DontLeader.htm";
+ }
+
+ if ((party.getMemberCount() < player_min))
+ {
+ return "DontNumber.htm";
+ }
+
+ for (L2PcInstance partyMember : party.getMembers())
+ {
+ if (!partyMember.isInsideRadius(player, 300, true, true))
+ {
+ return "DistanceParty.htm";
+ }
+
+ if (partyMember.getClan() == null)
+ {
+ return "allClan.htm";
+ }
+
+ if (partyMember.getClanId() != player.getClanId())
+ {
+ return "allClan.htm";// TODO cambiar por otro xD
+ }
+
+ final String value = loadGlobalQuestVar(partyMember.getAccountName() + " PresArms");
+ final long _reuse_time = value == "" ? 0 : Long.parseLong(value);
+
+ if ((System.currentTimeMillis() < _reuse_time) && (_reuse_time != 0))
+ {
+ return "Time.htm";
+ }
+ }
+
+ member_count = party.getMemberCount();
+ enterInstance(npc, player);
+ }
+ else
+ {
+ // GM
+ enterInstance(npc, player);
+ }
+ }
+ else if (event.equals("SpawnCamp"))
+ {
+ SpawnCamp(player);
+ }
+ else if (event.equals("Spawn"))
+ {
+ SpawnGuardias(player);
+ }
+ else if (event.equals("Run"))
+ {
+ for (L2Npc guard : _npclist)
+ {
+ if (guard.getTarget() == null)
+ {
+ guard.setIsRunning(false);
+ guard.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, new L2CharPosition(TELEPORTS[0][0], guard.getY(), guard.getZ(), guard.getHeading()));
+ }
+ }
+ // startQuestTimer("Run", 8000, npc, player, false); // 1 seg
+ }
+ else if (event.equals("Say"))
+ {
+ switch (round)
+ {
+ case 0:
+ npc.broadcastPacket(new NpcSay(npc, Say2.NPC_ALL, "Este castillo volvera a ser Nuestro!"));
+ break;
+ case 1:
+ npc.broadcastPacket(new NpcSay(npc, Say2.NPC_ALL, "eh llegado con refuersos...!"));
+ break;
+ case 2:
+ npc.broadcastPacket(new NpcSay(npc, Say2.NPC_ALL, "Creo que hemos subestimado al enemigo!"));
+ break;
+ }
+ }
+ return super.onAdvEvent(event, npc, player);
+ }
+
+ @Override
+ public String onSeeCreature(L2Npc npc, L2Character player, boolean isSummon)
+ // public String onAggroRangeEnter(L2Npc npc, L2PcInstance player, boolean isSummon)
+ {
+ if (player.isPlayer())
+ {
+ cancelQuestTimer("Run", npc, player.getActingPlayer());
+ npc.getAI().stopAITask();
+ npc.setTarget(player);
+ npc.setRunning();
+ ((L2Attackable) npc).addDamageHate(player, 0, 99999);
+ npc.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, player);
+
+ startQuestTimer("Run", 2000, npc, player.getActingPlayer(), false); // 20 seg
+
+ }
+
+ return super.onSeeCreature(npc, player, isSummon);
+ }
+
+ @Override
+ public String onKill(L2Npc npc, L2PcInstance killer, boolean isSummon)
+ {
+ dropItem(npc, killer, DROPLIST_herbs);
+ dropItem(npc, killer, DROPLIST);
+
+ dead--;
+
+ if (dead == 0)
+ {
+ cancelQuestTimer("Spawn", npc, killer);
+ cancelQuestTimer("Run", npc, killer);
+ round++;
+ startQuestTimer("Spawn", 15 * 1000, npc, killer, false); // 15 seg
+ startQuestTimer("Run", 25 * 1000, npc, killer, false); // 20 seg
+ }
+
+ return super.onKill(npc, killer, isSummon);
+ }
+
+ // Metodos
+ private void teleportPlayer(L2Npc npc, L2PcInstance player, int[] coords, int instanceId)
+ {
+
+ player.stopAllEffectsExceptThoseThatLastThroughDeath();
+ player.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
+ player.setInstanceId(instanceId);
+ player.teleToLocation(coords[0], coords[1], coords[2], false);
+
+ if (!run_events)
+ {
+ run_events = true;
+ Broadcast.toPlayersInInstance(new CreatureSay(0, Say2.BATTLEFIELD, player.getName(), "Be careful, danger approaches!"), player.getInstanceId());
+ startQuestTimer("Spawn", 5000, npc, player, false); // 5 seg
+ startQuestTimer("SpawnCamp", 5000, npc, player, false); // 5 seg
+ startQuestTimer("Run", 20 * 1000, npc, player, false); // 20 seg
+ }
+
+ // }
+ }
+
+ private void enterInstance(L2Npc npc, L2PcInstance player)
+ {
+ InstanceWorld world = InstanceManager.getInstance().getPlayerWorld(player);
+ if (world != null)
+ {
+ if (!(world instanceof PresentArmsWorld))
+ {
+ player.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.ALREADY_ENTERED_ANOTHER_INSTANCE_CANT_ENTER));
+ return;
+ }
+
+ return;
+ }
+
+ final int instanceId = InstanceManager.getInstance().createDynamicInstance("PresentArmsWorld.xml");
+ final Instance inst = InstanceManager.getInstance().getInstance(instanceId);
+
+ world = new PresentArmsWorld();
+ world.setInstanceId(instanceId);
+ world.setTemplateId(INSTANCE_ID);
+ world.setStatus(0);
+ InstanceManager.getInstance().addWorld(world);
+
+ final L2Party party = player.getParty();
+
+ if (player.isGM())
+ {
+ world.addAllowed(player.getObjectId());
+ teleportPlayer(npc, player, TELEPORTS[0], instanceId);
+ }
+ else
+ {
+ for (L2PcInstance partyMember : party.getMembers())
+ {
+ saveGlobalQuestVar(partyMember.getAccountName() + " PresArms", Long.toString(System.currentTimeMillis() + (86400000)));// 24hs
+ world.addAllowed(partyMember.getObjectId());
+ teleportPlayer(npc, partyMember, TELEPORTS[0], instanceId);
+ }
+ }
+
+ inst.setName(InstanceManager.getInstance().getInstanceIdName(instanceId));
+ inst.setAllowSummon(false);
+ inst.setDuration(time);
+ inst.setEmptyDestroyTime(0);
+ inst.isShowTimer();// ???????????????????
+ }
+
+ private static final void dropItem(L2Npc mob, L2PcInstance player, int[][] droplist)
+ {
+ final int chance = getRandom(100);
+
+ for (int[] drop : droplist)
+ {
+ if (chance > drop[1])
+ {
+ ((L2MonsterInstance) mob).dropItem(player, drop[0], getRandom(drop[2], drop[3]));
+ return;
+ }
+ }
+ }
+
+ private void SpawnCamp(L2PcInstance player)
+ {
+ // TODO crear los spawn para los demas castillo
+ addSpawn(camp, 27800, -48255, -1303, 32658, false, time, false, player.getInstanceId());
+ addSpawn(camp, 28240, -48134, -1324, 32658, false, time, false, player.getInstanceId());
+ addSpawn(camp, 27394, -49704, -1327, 32658, false, time, false, player.getInstanceId());
+ }
+
+ private void SpawnGuardias(L2PcInstance player)
+ {
+ // TODO crear los spawn para los demas castillo
+ _npclist.clear();
+
+ int _x = x;
+
+ if (member_count > 0)
+ {
+ member_count = _guardias_count[round] + member_count;
+ }
+ else
+ {
+ member_count = _guardias_count[round];
+ }
+
+ // lord
+ L2Npc lord = addSpawn(_guardias[0], _x, y + 111, z, 32658, false, time, false, player.getInstanceId());
+ _npclist.add(lord);
+ startQuestTimer("Say", 20 * 1000, lord, null, false); // 20 seg
+
+ _x += 5;
+
+ // warriors
+ for (int cont = 0; cont < member_count; cont++)
+ {
+ _x += 100;
+ _npclist.add(addSpawn(_guardias[1], _x, y, z, 32658, false, time, false, player.getInstanceId()));
+ _npclist.add(addSpawn(_guardias[1], _x, y + 111, z, 32658, false, time, false, player.getInstanceId()));
+ _npclist.add(addSpawn(_guardias[1], _x, y + 222, z, 32658, false, time, false, player.getInstanceId()));
+ }
+ _x += 5;
+
+ // archers
+ for (int cont = 0; cont < member_count; cont++)
+ {
+ _x += 100;
+ _npclist.add(addSpawn(_guardias[2], _x, y, z, 32658, false, time, false, player.getInstanceId()));
+ _npclist.add(addSpawn(_guardias[2], _x, y + 111, z, 32658, false, time, false, player.getInstanceId()));
+ _npclist.add(addSpawn(_guardias[2], _x, y + 222, z, 32658, false, time, false, player.getInstanceId()));
+ }
+
+ dead = _npclist.size();
+ }
+
+}
\ No newline at end of file
Index: dist/game/data/scripts/instances/PresentArms/DontLeader.htm
===================================================================
--- dist/game/data/scripts/instances/PresentArms/DontLeader.htm (revision 0)
+++ dist/game/data/scripts/instances/PresentArms/DontLeader.htm (working copy)
@@ -0,0 +1,3 @@
+<html><body>Undead:<br>
+Only the <font color="LEVEL">party leader</font> can give the order to enter.
+</body></html>
\ No newline at end of file
Index: dist/game/data/scripts/instances/PresentArms/DontParty.htm
===================================================================
--- dist/game/data/scripts/instances/PresentArms/DontParty.htm (revision 0)
+++ dist/game/data/scripts/instances/PresentArms/DontParty.htm (working copy)
@@ -0,0 +1,3 @@
+<html><body>Undead:<br>
+need to be in <font color="LEVEL">party</font>.
+</body></html>
\ No newline at end of file
Index: dist/game/data/scripts/instances/PresentArms/Time.htm
===================================================================
--- dist/game/data/scripts/instances/PresentArms/Time.htm (revision 0)
+++ dist/game/data/scripts/instances/PresentArms/Time.htm (working copy)
@@ -0,0 +1,4 @@
+<html><body>Undead:<br>
+You or one of your warriors and has competed in the last <font color="LEVEL">24 hours</font><br>
+since your last visit to come back
+</body></html>
\ No newline at end of file
customnpc.sql
-- Instance PresentArms
(21,32226,'PresentArms',1,'L2jAdmins',1,'LineageNPC2.K_F1_grand',11.00,22.25,70,'male','L2Npc',40,2444,2444,0.00,0.00,10,10,10,10,10,10,0,0,500,500,500,500,278,1,333,0,0,0,28,120,0,0),
(49, 36590, "Camp", 0, "", 0, "LineageNPC2.feudal_custodian", 10, 22.5, 70, "male", "L2Npc", 40, 2444.46819, 1345.8, 7.5, 2.7, 40, 43, 30, 21, 20, 20, 0, 0, 688.86373, 295.91597, 470.40463, 216.53847, 253, 4, 333, 0, 0, 0, 50, 120, 0, 1),
(50, 35484, "Royal Knight", 0, "", 0, "LineageNPC.a_royal_guardA_MHuman", 7, 24, 81, "male", "L2Monster", 40, 34617.725322, 5126.4, 8.5, 3, 40, 43, 30, 21, 20, 20, 0, 0, 3036.96805, 345.61127, 691.28516, 252.90333, 253, 4, 333, 142, 633, 0, 50, 120, 0, 1),
(51, 35487, "Court Guard", 0, "", 0, "LineageNPC.e_elmore_guard_Mhuman", 8, 23.5, 79, "male", "L2Monster", 80, 31278.245933, 4923, 8.5, 3, 40, 43, 30, 21, 20, 20, 0, 0, 2789.79244, 337.07008, 635.0222, 246.65326, 253, 4, 333, 300, 0, 0, 50, 120, 0, 1),
(52, 35490, "Guard", 0, "", 0, "LineageNPC.a_guard_MElf", 8, 23.5, 78, "male", "L2Monster", 1100, 29743.56864, 4822.2, 8.5, 3, 40, 43, 30, 21, 20, 20, 0, 0, 2671.50258, 332.70061, 608.09666, 243.45587, 253, 8, 333, 285, 0, 0, 50, 120, 0, 1),
npcaidata.sql
-- Instance PresentArms
(21,7,15,0,1000,0,1,1,0,0,0,0,0,0,0,0,0,0,NULL,300,NULL,0,0,'fighter'),
(49, 7, 15, 0, 1000, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, 300, NULL, 0, 0, "balanced"), -- Territory Manager
(50, 7, 15, 0, 1000, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 400, 0, 0, NULL, 0, NULL, 0, 0, "fighter"), -- Royal Knight
(51, 7, 15, 0, 1000, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 400, 0, 0, NULL, 0, NULL, 0, 0, "fighter"), -- Royal Knight
(52, 7, 15, 0, 1000, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 400, 0, 0, NULL, 0, NULL, 0, 0, "fighter"), -- Royal Knight