Jump to content

Recommended Posts

Posted

TvT event addons.

Config for Coliseum Doors Close

and Interval time.

 

Index: trunk/L2JTeon/java/config/Custom/L2JTeonMods.properties
===================================================================
--- /tmp/svn_fs20100723-29606-1862i5m-0	Fri Jul 23 15:53:20 2010
+++ /tmp/svn_fs20100723-29606-1iufh0i-0	Fri Jul 23 15:53:20 2010
@@ -52,6 +52,9 @@
# players with cursed weapon are allowed to join ?
TvtJoinWithCursedWeapon=True

+# we must close coliseum doors on tvt start up?
+TvTCloseColiseumDoors = False
+
# ------------------------------------------------------------- #
#                       CTF Event Engine                        #
# ------------------------------------------------------------- #

Index: trunk/L2JTeon/java/net/sf/l2j/Config.java
===================================================================
--- /tmp/svn_fs20100723-29606-1isqhr4-0	Fri Jul 23 15:53:20 2010
+++ /tmp/svn_fs20100723-29606-j6ert5-0	Fri Jul 23 15:53:20 2010
@@ -765,6 +765,7 @@
	public static boolean TVT_ANNOUNCE_TEAM_STATS;
	public static boolean TVT_PRICE_NO_KILLS;
	public static boolean TVT_JOIN_CURSED;
+	public static boolean TVT_CLOSE_COLISEUM_DOORS;
	// * CTF Event Engine *//
	public static String CTF_EVEN_TEAMS;
	public static boolean CTF_ALLOW_INTERFERENCE;
@@ -2479,6 +2480,7 @@
					TVT_ANNOUNCE_TEAM_STATS = Boolean.parseBoolean(L2JTeonEventMods.getProperty("TvtAnnounceTeamStats", "False"));
					TVT_PRICE_NO_KILLS = Boolean.parseBoolean(L2JTeonEventMods.getProperty("TvtPriceNoKills", "False"));
					TVT_JOIN_CURSED = Boolean.parseBoolean(L2JTeonEventMods.getProperty("TvtJoinWithCursedWeapon", "True"));
+					TVT_CLOSE_COLISEUM_DOORS = Boolean.parseBoolean(L2JTeonEventMods.getProperty("TvTCloseColiseumDoors", "False"));
					// -------------------- //
					// CTF Event Engine //
					// -------------------- //

Index: trunk/L2JTeon/java/net/sf/l2j/gameserver/handler/admincommandhandlers/AdminTvTEngine.java
===================================================================
--- /tmp/svn_fs20100723-29606-zz246b-0	Fri Jul 23 15:53:20 2010
+++ /tmp/svn_fs20100723-29606-w17z1-0	Fri Jul 23 15:53:20 2010
@@ -29,11 +29,12 @@
import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
import net.sf.l2j.gameserver.model.entity.L2JTeonEvents.TvT;
import net.sf.l2j.gameserver.network.serverpackets.NpcHtmlMessage;
+import net.sf.l2j.gameserver.util.Util;

public class AdminTvTEngine implements IAdminCommandHandler
{
	private static final String[] ADMIN_COMMANDS = { "admin_tvt", "admin_tvt_name", "admin_tvt_desc", "admin_tvt_join_loc", "admin_tvt_minlvl", "admin_tvt_maxlvl", "admin_tvt_npc", "admin_tvt_npc_pos", "admin_tvt_reward", "admin_tvt_reward_amount", "admin_tvt_team_add", "admin_tvt_team_remove", "admin_tvt_team_pos", "admin_tvt_team_color", "admin_tvt_join", "admin_tvt_teleport",
-			"admin_tvt_start", "admin_tvt_abort", "admin_tvt_finish", "admin_tvt_sit", "admin_tvt_dump", "admin_tvt_save", "admin_tvt_load", "admin_tvt_jointime", "admin_tvt_eventtime", "admin_tvt_autoevent", "admin_tvt_minplayers", "admin_tvt_maxplayers" };
+			"admin_tvt_start", "admin_tvt_abort", "admin_tvt_finish", "admin_tvt_sit", "admin_tvt_dump", "admin_tvt_save", "admin_tvt_load", "admin_tvt_jointime", "admin_tvt_eventtime", "admin_tvt_autoevent", "admin_tvt_minplayers", "admin_tvt_maxplayers", "admin_tvt_interval" };
	private static final int REQUIRED_LEVEL = 100;

	public boolean useAdminCommand(String command, L2PcInstance activeChar)
@@ -197,6 +198,13 @@
		else if (command.equals("admin_tvt_dump")) {
			TvT.dumpData();
		}
+		else if (command.startsWith("admin_tvt_interval "))
+		{
+			int value = Integer.valueOf(command.substring(19));
+
+			TvT._intervalBetweenMatchs = Util.convertMinutesToMiliseconds(value);
+			showMainPage(activeChar);
+		}
		return true;
	}

@@ -247,7 +255,10 @@
		replyMSG.append("<td width=\"100\"><button value=\"Join\" action=\"bypass -h admin_tvt_join\" width=90 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td>");
		replyMSG.append("<td width=\"100\"><button value=\"Teleport\" action=\"bypass -h admin_tvt_teleport\" width=90 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td>");
		replyMSG.append("<td width=\"100\"><button value=\"Start\" action=\"bypass -h admin_tvt_start\" width=90 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td>");
+		//L2EMU_ADD
		replyMSG.append("</tr></table><table><tr>");
+		replyMSG.append("<td width=\"100\"><button value=\"Set Interval\" action=\"bypass -h admin_tvt_interval $input1\" width=90 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td>");
+		replyMSG.append("</tr></table><table><tr>");
		replyMSG.append("<td width=\"100\"><button value=\"Abort\" action=\"bypass -h admin_tvt_abort\" width=90 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td>");
		replyMSG.append("<td width=\"100\"><button value=\"Finish\" action=\"bypass -h admin_tvt_finish\" width=90 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td>");
		replyMSG.append("</tr></table><br><table><tr>");

Index: trunk/L2JTeon/java/net/sf/l2j/gameserver/model/entity/L2JTeonEvents/TvT.java
===================================================================
--- /tmp/svn_fs20100723-29606-eaztck-0	Fri Jul 23 15:53:20 2010
+++ /tmp/svn_fs20100723-29606-gzh6l5-0	Fri Jul 23 15:53:20 2010
@@ -32,6 +32,7 @@
import net.sf.l2j.L2DatabaseFactory;
import net.sf.l2j.gameserver.Announcements;
import net.sf.l2j.gameserver.ThreadPoolManager;
+import net.sf.l2j.gameserver.datatables.DoorTable;
import net.sf.l2j.gameserver.datatables.NpcTable;
import net.sf.l2j.gameserver.datatables.SpawnTable;
import net.sf.l2j.gameserver.lib.Rnd;
@@ -446,6 +447,11 @@

	public static void startEvent(L2PcInstance activeChar)
	{
+		if (_inProgress)
+		{
+			activeChar.sendMessage("A TvT event is already in progress, try abort.");
+			return;
+		}
		if (!startEventOk())
		{
			if (_log.isDebugEnabled()) {
@@ -455,8 +461,13 @@
		}
		_teleport = false;
		sit();
+		
+		if (Config.TVT_CLOSE_COLISEUM_DOORS)
+			closeColiseumDoors();
+
		Announcements.getInstance().announceToAll(_eventName + "(TvT): Started. Go to kill your enemies!");
		_started = true;
+		_inProgress = true;
	}

	public static void setJoinTime(int time)
@@ -480,34 +491,64 @@
		}
		_teleport = false;
		sit();
+		
+		if (Config.TVT_CLOSE_COLISEUM_DOORS)
+			closeColiseumDoors();
+		
		Announcements.getInstance().announceToAll(_eventName + "(TvT): Started. Go to kill your enemies!");
		_started = true;
		return true;
	}

-	public static void autoEvent()
+	public static synchronized void autoEvent()
	{
+		_log.info("Starting TvT!");
+		_log.info("Matchs Are Restarted At Every: " + getIntervalBetweenMatchs() + " Minutes.");
		if (startAutoJoin())
		{
-			if (_joinTime > 0) {
+			_eventType = 2;
+
+			if (_joinTime > 0)
				waiter(_joinTime * 60 * 1000); // minutes for join event
-			} else if (_joinTime <= 0)
+			else if (_joinTime <= 0)
			{
+				_log.info("TvT: join time <=0 aborting event.");
				abortEvent();
				return;
			}
			if (teleportAutoStart())
			{
-				waiter(1 * 60 * 1000); // 1 min wait time untill start fight after teleported
+				waiter(30 * 1000); // 30 sec wait time untill start fight after teleported
				if (startAutoEvent())
				{
+					_log.debug("TvT: waiting.....minutes for event time " + TvT._eventTime);
+
					waiter(_eventTime * 60 * 1000); // minutes for event time
					finishEvent();
+
+					_log.info("TvT: waiting... delay for final messages ");
+					waiter(60000);//just a give a delay delay for final messages
+					sendFinalMessages();
+
+					if (_finished && _eventType == 2)
+						_log.info("TVT: waiting.....delay for restart event  " + TvT.getIntervalBetweenMatchs() + " minutes.");
+					waiter(60000);//just a give a delay to next restart
+
+					try
+					{
+						restartEvent();
+					}
+					catch (Exception e)
+					{
+						_log.error("Error while tying to Restart Event", e);
+						e.printStackTrace();
+					}
				}
			}
			else if (!teleportAutoStart())
			{
				abortEvent();
+				restartEvent();
			}
		}
	}
@@ -705,9 +746,13 @@

	private static boolean finishEventOk()
	{
-		if (!_started) {
+		if (!_started)
			return false;
-		}
+
+		_inProgress = false;
+		if (Config.TVT_CLOSE_COLISEUM_DOORS)
+			openColiseumDoors();
+
		return true;
	}

@@ -760,6 +805,7 @@
		_joining = false;
		_teleport = false;
		_started = false;
+		_inProgress = false;
		unspawnEventNpc();
		Announcements.getInstance().announceToAll(_eventName + "(TvT): Match aborted!");
		teleportFinish();
@@ -904,6 +950,7 @@
		_eventTime = 0;
		_minPlayers = 0;
		_maxPlayers = 0;
+		_intervalBetweenMatchs = 0;
		java.sql.Connection con = null;
		try
		{
@@ -932,6 +979,7 @@
				_eventTime = rs.getInt("eventTime");
				_minPlayers = rs.getInt("minPlayers");
				_maxPlayers = rs.getInt("maxPlayers");
+				_intervalBetweenMatchs = rs.getLong("delayForNextEvent");
			}
			statement.close();
			int index = -1;
@@ -987,7 +1035,7 @@
			statement = con.prepareStatement("Delete from tvt");
			statement.execute();
			statement.close();
-			statement = con.prepareStatement("INSERT INTO tvt (eventName, eventDesc, joiningLocation, minlvl, maxlvl, npcId, npcX, npcY, npcZ, npcHeading, rewardId, rewardAmount, teamsCount, joinTime, eventTime, minPlayers, maxPlayers) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
+			statement = con.prepareStatement("INSERT INTO tvt (eventName, eventDesc, joiningLocation, minlvl, maxlvl, npcId, npcX, npcY, npcZ, npcHeading, rewardId, rewardAmount, teamsCount, joinTime, eventTime, minPlayers, maxPlayers, delayForNextEvent) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
			statement.setString(1, _eventName);
			statement.setString(2, _eventDesc);
			statement.setString(3, _joiningLocationName);
@@ -1005,6 +1053,7 @@
			statement.setInt(15, _eventTime);
			statement.setInt(16, _minPlayers);
			statement.setInt(17, _maxPlayers);
+			statement.setLong(18, _intervalBetweenMatchs);
			statement.execute();
			statement.close();
			statement = con.prepareStatement("Delete from tvt_teams");
@@ -1441,4 +1490,134 @@
		}
		_teamPlayersCount.set(index, teamPlayersCount);
	}
+	public static long _intervalBetweenMatchs = 0;
+
+	/**
+	 * The type of TvT Event
+	 * 1 = Manual
+	 * 2 = Automatic
+	 */
+	public static int _eventType = 0;
+
+	private static boolean _inProgress = false;
+	private static boolean _finished = false;
+	private static boolean _aborted	= false;
+
+	/**
+	 * Opens All Coliseum Doors
+	 */
+	private static void closeColiseumDoors()
+	{
+		Announcements.getInstance().announceToAll("Closing Coliseum Doors, TvT event has just started !");
+		DoorTable.getInstance().getDoor(24190001).closeMe();//west gate out
+		DoorTable.getInstance().getDoor(24190002).closeMe();//west gate in
+		DoorTable.getInstance().getDoor(24190003).closeMe();//east gate out
+		DoorTable.getInstance().getDoor(24190004).closeMe();//east gate in
+
+		try
+		{
+			//just to give a lil delay :P
+			Thread.sleep(20);
+		}
+		catch (InterruptedException ie)
+		{
+			_log.fatal("Error, " + ie.getMessage());
+		}
+	}
+
+	/**
+	 * Open all Coliseum Doors
+	 */
+	private static void openColiseumDoors()
+	{
+		Announcements.getInstance().announceToAll("Opening Coliseum Doors, TvT event has finished!");
+		DoorTable.getInstance().getDoor(24190001).openMe();
+		DoorTable.getInstance().getDoor(24190002).openMe();
+		DoorTable.getInstance().getDoor(24190003).openMe();
+		DoorTable.getInstance().getDoor(24190004).openMe();
+
+	}
+
+	/**
+	 * Restarts Event
+	 * checks if event was aborted. and if true cancels restart task
+	 */
+	public synchronized static void restartEvent()
+	{
+		if (_aborted)
+		{
+			_log.debug("TvT: restart skipped, event was aborted.");
+			return;
+		}
+		_log.info("TvT: Event has been restarted...");
+		_joining = false;
+		_started = false;
+		_finished = false;
+		_inProgress = false;
+		long delay = _intervalBetweenMatchs;
+
+		Announcements.getInstance().announceToAll("TvT: joining period will be avaible again in " + getIntervalBetweenMatchs() + " minute(s)!");
+
+		waiter(delay);
+
+		try
+		{
+			autoEvent(); //start a new event
+		}
+		catch (Exception e)
+		{
+			_log.fatal("TvT: Error While Trying to restart Event...", e);
+			e.printStackTrace();
+		}
+	}
+
+	/**
+	 * Returns the event type by name.
+	 * @param value
+	 * @return
+	 */
+	public static String getEventTypeByName(int value)
+	{
+		String type = String.valueOf(value);
+
+		switch (value)
+		{
+		case 0:
+			type = ("None");
+			break;
+
+		case 1:
+			type = ("Manual");
+			break;
+
+		case 2:
+			type = ("Automatic");
+			break;
+		}
+		return type;
+	}
+
+	/**
+	 * just an announcer to send termination messages
+	 *
+	 */
+	public static void sendFinalMessages()
+	{
+		if (_finished && !_aborted)
+			Announcements.getInstance().announceToAll("TvT: Thank you For Participating At, " + "TVT Event.");
+	}
+
+	/**
+	 * returns the interval between each event
+	 * @return
+	 */
+	public static int getIntervalBetweenMatchs()
+	{
+		long actualTime = System.currentTimeMillis();
+		long totalTime = actualTime + _intervalBetweenMatchs;
+		long interval = totalTime - actualTime;
+		int seconds = (int) (interval / 1000);
+
+		return Math.round(seconds / 60);
+	}
}
\ No newline at end of file

Index: trunk/L2JTeon/java/net/sf/l2j/gameserver/util/Util.java
===================================================================
--- /tmp/svn_fs20100723-29606-14uvgwl-0	Fri Jul 23 15:53:20 2010
+++ /tmp/svn_fs20100723-29606-i9bjve-0	Fri Jul 23 15:53:20 2010
@@ -369,4 +369,8 @@
	{
		return calcCameraAngle(target.getHeading());
	}
+	public static int convertMinutesToMiliseconds(int minutesToConvert)
+	{
+		return minutesToConvert * 60000;
+	}
}

 

Credits to L2jTeon

Posted

man dont c/p timelines thats shit

cant disagree more,

anyway thanks for share even if c/p maybe it will be helpful.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


×
×
  • Create New...

Important Information

This community uses essential cookies to function properly. Non-essential cookies and third-party services are used only with your consent. Read our Privacy Policy and We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue..

AdBlock Extension Detected!

Our website is made possible by displaying online advertisements to our members.

Please disable AdBlock browser extension first, to be able to use our community.

I've Disabled AdBlock