Jump to content

[SHARE]TVT Addons - Inverval and Coliseum Doors Close


Recommended Posts

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

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



  • Posts

    • DISCORD : utchiha_market telegram : https://t.me/utchiha_market SELLIX STORE : https://utchihamkt.mysellix.io/ Join our server for more products : https://discord.gg/hood-services https://campsite.bio/utchihaamkt  
    • Server Rates: » Xp 500x. » Sp 500x. » Aden 500x. » Drop 1x. » PartyXp 2x. » PartySp 2x. » Starting character level -61. Enchant rates: » Safe enchant +4. » Blessed and simple scrolls max enchant (+16). » Crystal scrolls max enchant (+20). » Simple enchant scrolls chance – 65%. » Blessed enchant scrolls chance – 100%. » Crystal enchant scrolls chance – 50% Augmentations: » Mid life stone skill chance – 5%. » High life stone skill chance – 10%. » Top life stone skill chance – 20%. » Augments 1+1 Unique features: » Main town – Giran » Automatic-Manual Potions. » Working 2 castle sieges. (Giran-Aden) » SPS cancel lasts 10 seconds and than buffs come back. » Stackable scrolls, lifestones, book of giants. » Unique pvp zone » More then 11 active raid bosses. » Wedding system. » Unique farming areas. » Npc skill enchanter. » Full npc buffer with auto buff. » Max count of buffs – 55. » Max subclasses – 4. » Free and no quest class change. » Free and no quest sub class. » Raid boss drop nobless item. » No weight limit. » Unique protection anti-hwy armor for archers/daggers etc. » Ingame password change. » Top pvp/pk/online ranks NPC. » Unique monsters & NPC. » Interlude retail skills. » Server up-time [24/7] [99]%. » Perfect class balance (all class can kill all class depending on players skill and setup knowledge,gear,augmentations). » Announcements on double kills triple kills etc. » Announcements on Grand Boss death , with the name of the killer as well as clan name of the player. » Information Npc in game with all servers infromations. Custom server gear : 1). Titanium Armor Lv.1 2). Epic Armor Lv.2 3). Epic Weapons-Kamikaze-Black S grade (Same Stats) 4). Demonic-Angelic Wings-Baium Hair-Custom Accessories (SameStats) 5). Custom Fighter/Mage tattoo Lv1-Lv2-Lv3 6). Shirt (STR,CON,INT +1) 7). Custom Shields Server Commands: .tvtjoin .tvtleave – Join or leave tvt event. .ctfjoin .ctfleave – Join or leave ctf event. .dmjoin .dmleave – Join of leave dm event. .online – current online players count. .repair – repairs stuck character in world. .menu – opens online menu panel. .exit – PVP zone exit in case you are bullied. .changepassword - Opens online menu then u can change ur password in game. .farm - Enable/disable autofarm Event system: » TVT event » CTF event » DM event » Tournament Event » Party Zone » Unique event shop. Olympiad game: » Retail olympiad game. » Competition period [1] week. » Olympiad start time [18:00] end [00:00] GMT+2. » New Heroes every Sunday.
    • Tomorrow grand opening lests go 🙂 
    • New season of Warfire X150 has been postponed to September 28th.
  • Topics

×
×
  • Create New...