» Find Revision
L2J Revision Number: Latest
L2JDP Revision Number: Latest
Hello i am trying to convert "Monster Rush" event
(viewtopic.php?f=73&t=15744&p=80174&hili ... ush#p80174)
from Gracia Final to Gracia Epilogue,
what i have done is:
Code: Select all
### Eclipse Workspace Patch 1.0#P L2_GameServerIndex: data/scripts/events/MonsterRush.java===================================================================--- data/scripts/events/MonsterRush.java (revision 0)+++ data/scripts/events/MonsterRush.java (revision 0)@@ -0,0 +1,297 @@+package com.l2jserver.gameserver.events;++import javolution.util.FastSet;+import com.l2jserver.gameserver.Announcements;+import com.l2jserver.gameserver.ThreadPoolManager;+import com.l2jserver.gameserver.ai.CtrlIntention;+import com.l2jserver.gameserver.datatables.NpcTable;+import com.l2jserver.gameserver.model.L2CharPosition;+import com.l2jserver.gameserver.model.L2Spawn;+import com.l2jserver.gameserver.model.L2World;+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.TvTEvent;+import com.l2jserver.gameserver.templates.chars.L2NpcTemplate;+import com.l2jserver.util.Rnd;++public class MonsterRush+{+ enum Status+ {+ INACTIVE,+ STARTED,+ REGISTER,+ TELEPORT,+ REWARDING+ + }+ + public static FastSet<L2PcInstance> _participants = new FastSet<L2PcInstance>();+ public static FastSet<L2Npc> _monsters = new FastSet<L2Npc>();+ public static Status _status = Status.INACTIVE;+ public static int[] _miniIntervals ={40000,80000,120000,160000};+ public static int[] _CoordsX ={17432,21380,18955,16613};+ public static int[] _CoordsY ={147465,145848,142545,144201};+ public static int[] _CoordsZ ={-3123,-3146,-3050,-2978};+ public static int[][] _wave1Mons ={{21426,21404},{10,10}};+ public static int[][] _wave2Mons ={{21426},{10}};+ public static int[][] _wave3Mons ={{21426},{10}};+ protected static L2Npc _lord = null;+ public static int _wave = 1;+ public static int X = 18864;+ public static int Y = 145216;+ public static int Z = -3132;+ + public static int getParticipatingPlayers()+ {+ return _participants.size();+ }+ + protected static void monWave(final int _waveNum)+ {+ if(_status == Status.INACTIVE)+ return;+ if (_waveNum==2)+ Announcements.getInstance().announceToAll("First wave has ended. Prepare for second wave!");+ else if (_waveNum==3)+ Announcements.getInstance().announceToAll("Second wave has ended. Prepare for last wave!");+ if(_status == Status.INACTIVE)+ return;+ L2Npc mobas = null;+ int[][] wave = _wave1Mons;+ if (_waveNum==2)+ wave = _wave2Mons;+ else if (_waveNum==3)+ wave = _wave3Mons;++ for (int i=0;i<=wave[0].length-1;i++)+ for (int a=1;a<=wave[1][i];a++)+ for (int r=0;r<=_CoordsX.length-1;r++)+ {+ mobas = addSpawn(wave[0][i],_CoordsX[r],_CoordsY[r],_CoordsZ[r]);+ mobas.getKnownList().addKnownObject(_lord);+ _monsters.add(mobas);+ }+ for (L2Npc monster : _monsters)+ {+ ((L2Attackable) monster).addDamageHate(_lord,9000,9000);+ monster.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, _lord, null);+ }+ + for (int i=0;i<=_miniIntervals.length-1;i++)+ ThreadPoolManager.getInstance().scheduleGeneral(new Runnable(){public void run(){miniWave(_waveNum);}}, _miniIntervals[i]);+ + }+ + public static void abortEvent()+ {+ _status = Status.INACTIVE;+ synchronized (_participants)+ {+ for (L2PcInstance player : _participants)+ {+ player.teleToLocation(X,Y,Z, true);+ player.setTeam(0);+ player.inMonsterRush=false;+ }+ }+ for (L2Npc monster : _monsters)+ {+ monster.onDecay();+ }+ _monsters.clear();+ _participants.clear();+ Announcements.getInstance().announceToAll("Monster Rush: Event was aborted.");+ }+ + public static void endByLordDeath()+ {+ endAndReward();+ }+ + protected static void endAndReward()+ {+ if(_status == Status.INACTIVE)+ return;+ _status = Status.REWARDING;+ for (L2Npc monster : _monsters)+ {+ monster.onDecay();+ }+ _monsters.clear();+ if (L2World.getInstance().findObject(_lord.getObjectId()) == null)+ {+ Announcements.getInstance().announceToAll("Monster Rush: Lord was not protected!");+ Announcements.getInstance().announceToAll("Monster Rush: Teleporting players back to town.");+ Announcements.getInstance().announceToAll("Monster Rush: Event has ended.");+ synchronized (_participants)+ {+ for (L2PcInstance player : _participants)+ {+ player.teleToLocation(X,Y,Z, true);+ player.setTeam(0);+ player.inMonsterRush=false;+ }+ }+ }+ else+ {+ Announcements.getInstance().announceToAll("Monster Rush: Lord was protected!");+ Announcements.getInstance().announceToAll("Monster Rush: Teleporting players back to town.");+ Announcements.getInstance().announceToAll("Monster Rush: Event has ended.");+ _lord.deleteMe();+ synchronized (_participants)+ {+ for (L2PcInstance player : _participants)+ {+ player.sendMessage("Town lord thanks you for help and rewards you then disappears.");+ player.teleToLocation(X,Y,Z, true);+ player.setTeam(0);+ player.inMonsterRush =false;+ }+ }+ }+ _participants.clear();+ _status = Status.INACTIVE;+ }+ + protected static void miniWave(int _waveNum)+ {+ if(_status == Status.INACTIVE)+ return;+ int[][] wave = _wave1Mons;+ if (_waveNum==2)+ wave = _wave2Mons;+ else if (_waveNum==3)+ wave = _wave3Mons;+ L2Npc mobas = null;+ for (int i=0;i<=wave[0].length-1;i++)+ for (int a=1;a<=Math.round(wave[1][i]*0.65);a++)+ for (int r=0;r<=_CoordsX.length-1;r++)+ {+ mobas = addSpawn(wave[0][i],_CoordsX[r],_CoordsY[r],_CoordsZ[r]);+ _monsters.add(mobas);+ }+ for (L2Npc monster : _monsters)+ {+ ((L2Attackable) monster).addDamageHate(_lord,7000,7000);+ monster.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, _lord, null);+ }+ }+ + public static L2Npc addSpawn(int npcId, int x, int y, int z)+ {+ L2Npc result = null;+ try+ {+ L2NpcTemplate template = NpcTable.getInstance().getTemplate(npcId);+ if (template != null)+ {+ L2Spawn spawn = new L2Spawn(template);+ spawn.setInstanceId(0);+ spawn.setHeading(1);+ spawn.setLocx(x);+ spawn.setLocy(y);+ spawn.setLocz(z);+ spawn.stopRespawn();+ result = spawn.spawnOne(true);+ + return result;+ }+ }+ catch (Exception e1)+ {+ }+ + return null;+ }+ + public static void doUnReg(L2PcInstance player)+ {+ if (_status == Status.REGISTER && _status != null)+ {+ if (_participants.contains(player))+ {+ _participants.remove(player);+ player.sendMessage("You have succesfully unregistered from Monster Rush event.");+ }+ else+ {+ player.sendMessage("You aren't registered in this event.");+ }+ }+ else+ {+ player.sendMessage("Event is inactive.");+ }+ }+ + public static void doReg(L2PcInstance player)+ {+ if (_status == Status.REGISTER && _status != null)+ {+ if (!_participants.contains(player))+ {+ _participants.add(player);+ player.sendMessage("You have succesfully registered to Monster Rush event.");+ }+ else+ {+ player.sendMessage("You have already registered for this event.");+ }+ }+ else+ {+ player.sendMessage("You cannot register now.");+ }+ }+ + public static void startRegister()+ {+ _status = Status.REGISTER;+ _participants.clear();+ Announcements.getInstance().announceToAll("Monster rush: Registration is open.");+ }+ + public static void startEvent()+ {+ _status = Status.STARTED;+ Announcements.getInstance().announceToAll("Registration is over. Teleporting players to town center in 20 seconds.");+ ThreadPoolManager.getInstance().scheduleGeneral(new Runnable()+ {+ public void run()+ {+ beginTeleport();+ }+ }, 20000);+ }++ protected static void beginTeleport()+ {+ _status = Status.TELEPORT;+ _lord = addSpawn(25603,X,Y,Z);+ _lord.setIsParalyzed(true);+ synchronized (_participants)+ {+ for (L2PcInstance player : _participants)+ {+ if (player.isInOlympiadMode() || TvTEvent.isPlayerParticipant(player.getObjectId()))+ {+ _participants.remove(player);+ return;+ }+ player.teleToLocation(X, Y, Z, true);+ player.setTeam(2);+ player.inMonsterRush=true;+ }+ Announcements.getInstance().announceToAll("Teleportation done. First monster wave will approach town in 1 minute!");+ ThreadPoolManager.getInstance().scheduleGeneral(new Runnable(){public void run(){monWave(1);}}, 60000);+ ThreadPoolManager.getInstance().scheduleGeneral(new Runnable(){public void run(){monWave(2);}}, 260000);+ ThreadPoolManager.getInstance().scheduleGeneral(new Runnable(){public void run(){monWave(3);}}, 460000);+ ThreadPoolManager.getInstance().scheduleGeneral(new Runnable(){public void run(){endAndReward();}}, 660000);+ }+ }+} Index: java/com/l2jserver/gameserver/model/actor/L2Npc.java===================================================================--- java/com/l2jserver/gameserver/model/actor/L2Npc.java+++ java/com/l2jserver/gameserver/model/actor/L2Npc.java@@ -33,6 +33,7 @@ import com.l2jserver.gameserver.datatables.ItemTable; import com.l2jserver.gameserver.datatables.SkillTable; import com.l2jserver.gameserver.datatables.SpawnTable;+import com.l2jserver.gameserver.events.MonsterRush; import com.l2jserver.gameserver.idfactory.IdFactory; import com.l2jserver.gameserver.instancemanager.CastleManager; import com.l2jserver.gameserver.instancemanager.DimensionalRiftManager;@@ -2541,7 +2551,13 @@ { if (!super.doDie(killer)) return false;-+ + if (getTemplate().npcId == 25603)+ {+ this.deleteMe();+ MonsterRush.endByLordDeath();+ }+ // normally this wouldn't really be needed, but for those few exceptions, // we do need to reset the weapons back to the initial templated weapon. _currentLHandId = getTemplate().lhand; Index: java/com/l2jserver/gameserver/model/actor/L2Npc.java===================================================================--- com.l2jserver.gameserver.model.actor.instance.L2PcInstance; (revision 3514)+++ com.l2jserver.gameserver.model.actor.instance.L2PcInstance; (working copy)@@ -376,7 +385,9 @@ private Map<Integer, SubClass> _subClasses; private PcAppearance _appearance;-+ + public static boolean inMonsterRush = false;+ /** The Identifier of the L2PcInstance */ private int _charId = 0x00030b7a;
http://zapodaj.net/images/92507da181e9.jpg
any idea how i can fix it? Thanks for reply
