Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Index: D:/Workspace/wks/L2_GameServer/java/config/l2jmods.properties
- ===================================================================
- --- D:/Workspace/wks/L2_GameServer/java/config/l2jmods.properties (revision 3457)
- +++ D:/Workspace/wks/L2_GameServer/java/config/l2jmods.properties (working copy)
- @@ -248,4 +248,32 @@
- # This option will enable core support for:
- # Mana Drug (item ID 726), using skill ID 9007.
- # Mana Potion (item ID 728), using skill ID 9008.
- -EnableManaPotionSupport = False
- \ No newline at end of file
- +EnableManaPotionSupport = False
- +
- +# ---------------------------------------------------------------------------
- +# Town War. Use //tw_start and //tw_end to run or end it.
- +# This gonna spawn mobs in towns. That's pretty much all.
- +# Long life MaxCheaters ^^.
- +# Vago & team...
- +# ---------------------------------------------------------------------------
- +MonsterId = 0
- +MaxHp = 1000
- +MaxMp = 1000
- +DropId = 0
- +DropChance = 0
- +DropMax = 0
- +DropMin = 0
- Index: D:/Workspace/wks/L2_GameServer/java/net/sf/l2j/Config.java
- ===================================================================
- --- D:/Workspace/wks/L2_GameServer/java/net/sf/l2j/Config.java (revision 3457)
- +++ D:/Workspace/wks/L2_GameServer/java/net/sf/l2j/Config.java (working copy)
- @@ -501,8 +501,15 @@
- public static boolean CUSTOM_TELEPORT_TABLE;
- public static boolean CUSTOM_DROPLIST_TABLE;
- public static boolean CUSTOM_MERCHANT_TABLES;
- + public static int TW_MOB_ID;
- + public static int TW_MAX_HP;
- + public static int TW_MAX_MP;
- + public static int TW_ID;
- + public static int TW_CHANCE;
- + public static int TW_MAX_DROP;
- + public static int TW_MIN_DROP;
- +
- @@ -1783,6 +1795,24 @@
- L2JMOD_ENABLE_WAREHOUSESORTING_PRIVATE = Boolean.valueOf(L2JModSettings.getProperty("EnableWarehouseSortingPrivate", "False"));
- L2JMOD_ENABLE_WAREHOUSESORTING_FREIGHT = Boolean.valueOf(L2JModSettings.getProperty("EnableWarehouseSortingFreight", "False"));
- TW_MOB_ID = Integer.parseInt(L2JModSettings.getProperty("MonsterId", "0"));
- + TW_MAX_HP = Integer.parseInt(L2JModSettings.getProperty("MaxHp", "1000"));
- + TW_MAX_MP = Integer.parseInt(L2JModSettings.getProperty("MaxMp", "1000"));
- + TW_ID = Integer.parseInt(L2JModSettings.getProperty("DropId", "0"));
- + TW_CHANCE = Integer.parseInt(L2JModSettings.getProperty("DropChance", "0"));
- + TW_MAX_DROP = Integer.parseInt(L2JModSettings.getProperty("DropMax", "0"));
- + TW_MIN_DROP = Integer.parseInt(L2JModSettings.getProperty("DropMin", "0"));
- +
- + if (DM_REVIVE_DELAY < 1000)
- + DM_REVIVE_DELAY = 1000; //can't be set less then 1 second
- +
- if (TVT_EVENT_PARTICIPATION_NPC_ID == 0)
- {
- TVT_EVENT_ENABLED = false;
- Index: D:/Workspace/wks/L2_GameServer/java/net/sf/l2j/gameserver/instancemanager/TownWar.java
- ===================================================================
- --- D:/Workspace/wks/L2_GameServer/java/net/sf/l2j/gameserver/instancemanager/TownWar.java (revision 0)
- +++ D:/Workspace/wks/L2_GameServer/java/net/sf/l2j/gameserver/instancemanager/TownWar.java (revision 0)
- @@ -0,0 +1,347 @@
- +/*
- + * 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 2, 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, write to the Free Software
- + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
- + * 02111-1307, USA.
- + *
- + * http://www.gnu.org/copyleft/gpl.html
- + */
- +
- +package net.sf.l2j.gameserver.instancemanager;
- +
- +import java.util.List;
- +import java.util.Random;
- +import java.util.concurrent.Future;
- +import java.util.logging.Logger;
- +
- +import javolution.util.FastList;
- +import net.sf.l2j.Config;
- +import net.sf.l2j.gameserver.Announcements;
- +import net.sf.l2j.gameserver.ThreadPoolManager;
- +import net.sf.l2j.gameserver.datatables.NpcTable;
- +import net.sf.l2j.gameserver.datatables.SpawnTable;
- +import net.sf.l2j.gameserver.idfactory.IdFactory;
- +import net.sf.l2j.gameserver.model.L2DropData;
- +import net.sf.l2j.gameserver.model.L2Object;
- +import net.sf.l2j.gameserver.model.L2Spawn;
- +import net.sf.l2j.gameserver.model.L2World;
- +import net.sf.l2j.gameserver.model.actor.L2Attackable;
- +import net.sf.l2j.gameserver.model.actor.L2Npc;
- +import net.sf.l2j.gameserver.model.actor.instance.L2NpcInstance;
- +import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
- +import net.sf.l2j.gameserver.templates.chars.L2NpcTemplate;
- +
- +
- +public class TownWar
- +{
- +
- + private static TownWar _instance = new TownWar();
- +
- + private static final Logger _log = Logger.getLogger(TownWar.class.getName());
- + // list of trees.
- + protected List<L2NpcInstance> objectQueue = new FastList<L2NpcInstance>();
- +
- + protected Random rand = new Random();
- +
- + private final int last = 73099;
- +
- + int monsterid = Config.TW_MOB_ID;
- +
- + // Manager should only be Initialized once:
- + protected int isManagerInit = 0;
- +
- + /**
- + * Empty constructor
- + * Does nothing
- + */
- + public TownWar()
- + {
- + // nothing.
- + }
- +
- +
- + public static TownWar getInstance()
- + {
- + if (_instance == null) _instance = new TownWar();
- +
- + return _instance;
- + }
- +
- +
- +
- + public void init(L2PcInstance activeChar)
- + {
- +
- + if (isManagerInit > 0)
- + {
- + activeChar.sendMessage("TownWar has already begun or is processing. Please be patient....");
- + return;
- + }
- +
- + activeChar.sendMessage("Started!!!! This will take a 2-3 hours (in order to reduce system lags to a minimum), please be patient... The process is working in the background and will spawn mobs at a fixed rate.");
- +
- + checkIfOkToAnnounce();
- +
- + }
- +
- +
- + public void end(L2PcInstance activeChar)
- + {
- +
- + if (isManagerInit < 4)
- + {
- +
- + if (activeChar != null)
- + activeChar.sendMessage("TownWar is not activated yet. Already Ended or is now processing....");
- + return;
- +
- + }
- +
- + if (activeChar != null)
- + activeChar.sendMessage("Terminating! This may take a while, please be patient...");
- +
- + //Tasks:
- +
- + ThreadPoolManager.getInstance().executeTask(new DeleteSpawns());
- +
- +
- + checkIfOkToAnnounce();
- +
- + }
- +
- +
- +
- + public class DeleteSpawns implements Runnable
- + {
- +
- + public void run()
- + {
- +
- + if (objectQueue == null || objectQueue.isEmpty())
- + return;
- +
- + for (L2NpcInstance deleted : objectQueue)
- + {
- +
- + if (deleted == null)
- + continue;
- +
- + else
- + {
- + try
- + {
- +
- + L2World.getInstance().removeObject(deleted);
- +
- + deleted.decayMe();
- + deleted.deleteMe();
- +
- +
- + }
- +
- + catch(Throwable t) { continue; }
- + }
- +
- + }
- +
- + objectQueue.clear();
- + objectQueue = null;
- +
- + isManagerInit = isManagerInit - 2;
- + checkIfOkToAnnounce();
- +
- + }
- +
- + }
- +
- +
- + @SuppressWarnings("null")
- + void spawnOneMob(int id, int x, int y, int z)
- + {
- + try
- + {
- +
- + L2NpcTemplate template1 = NpcTable.getInstance().getTemplate(id);
- + L2Spawn spawn = new L2Spawn(template1);
- +
- + spawn.setId(IdFactory.getInstance().getNextId());
- +
- + spawn.setLocx(x);
- + spawn.setLocy(y);
- + spawn.setLocz(z);
- +
- + L2Npc monster = spawn.spawnOne(false);
- +
- + monster.getStatus().setCurrentHp(Config.TW_MAX_HP);
- + monster.getStatus().setCurrentMp(Config.TW_MAX_MP);
- +
- + L2DropData drop = null;
- + drop.setItemId(Config.TW_ID);
- + drop.setChance(Config.TW_CHANCE);
- + drop.setMaxDrop(Config.TW_MAX_DROP);
- + drop.setMinDrop(Config.TW_MIN_DROP);
- +
- + monster.getTemplate().addDropData(drop, 1);
- + L2World.getInstance().storeObject(monster);
- + objectQueue.add((L2NpcInstance) monster);
- +
- + }
- +
- + catch(Throwable t){}
- + }
- +
- + public class SpawnMobs implements Runnable
- + {
- +
- + private int _iterator;
- +
- + @SuppressWarnings("unchecked")
- + private Future _task;
- +
- +
- + public SpawnMobs(int iter)
- + {
- + _iterator = iter;
- + }
- +
- +
- + @SuppressWarnings("unchecked")
- + public void setTask(Future task)
- + {
- + _task = task;
- + }
- +
- + public void run()
- + {
- +
- + if (_task != null)
- + {
- + _task.cancel(true);
- + _task = null;
- + }
- +
- +
- + try
- + {
- +
- + L2Object obj = null;
- + while (obj == null)
- + {
- + obj = SpawnTable.getInstance().getTemplate(_iterator).getLastSpawn();
- + _iterator++;
- + if (obj != null && obj instanceof L2Attackable)
- + obj = null;
- + }
- +
- + if ( obj != null &&
- + rand.nextInt(100)<80 &&
- + obj instanceof L2NpcInstance &&
- + TownManager.getTown(obj.getX(), obj.getY(), obj.getZ()) != null &&
- + TownManager.getTown(obj.getX(), obj.getY(), obj.getZ()).isPeaceZone())
- + {
- +
- + spawnOneMob ( monsterid ,
- + obj.getX() + rand.nextInt(500) - 250 ,
- + obj.getY() + rand.nextInt(500) - 250 ,
- + obj.getZ());
- +
- +
- + }
- +
- +
- +
- + }
- + catch(Throwable t){}
- +
- + if (_iterator >= last)
- + {
- + isManagerInit++;
- + checkIfOkToAnnounce();
- +
- + return;
- + }
- +
- + _iterator++;
- + SpawnMobs ssNPCs = new SpawnMobs(_iterator);
- +
- + _task = ThreadPoolManager.getInstance().scheduleGeneral(ssNPCs, 300);
- + ssNPCs.setTask(_task);
- +
- + }
- +
- + }
- +
- +
- +
- +
- + @SuppressWarnings("unchecked")
- + void checkIfOkToAnnounce()
- + {
- + if (isManagerInit == 4)
- + {
- + Announcements.getInstance().announceToAll("TownWar Event has begun!");
- + Announcements.getInstance().announceToAll("TownWar will end in 24 hours.");
- + _log.info("TownWar:Init TownWar was started successfully.");
- +
- + EndEvent ee = new EndEvent();
- + Future task = ThreadPoolManager.getInstance().scheduleGeneral(ee , 86400000);
- + ee.setTask(task);
- +
- + isManagerInit = 5;
- + }
- +
- + if (isManagerInit == 0)
- + {
- + Announcements.getInstance().announceToAll("TownWar has ended... Hope you enjoyed the event.");
- + _log.info("TownWar:Terminated TownWar.");
- +
- + isManagerInit = -1;
- + }
- + }
- +
- +
- + public class EndEvent implements Runnable
- + {
- +
- + @SuppressWarnings("unchecked")
- + private Future _task;
- +
- +
- + @SuppressWarnings("unchecked")
- + public void setTask(Future task)
- + {
- + _task = task;
- + }
- +
- +
- + public void run()
- + {
- + if (_task != null)
- + {
- + _task.cancel(true);
- + _task = null;
- + }
- +
- + end(null);
- +
- + }
- +
- + }
- +
- +}
- +
- +
Advertisement
Add Comment
Please, Sign In to add comment