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

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

    • 🍂 The cost on Vibe-sms is dropping, like autumn leaves falling from the trees.     It’s a little sad to watch the last days of summer fade away with its warmth, but that’s how the world works  every season has its own rules. The same goes for our prices: they are gradually but steadily going down, opening up new opportunities and great deals. 💸   🌍 USA is already at the minimum, and Europe, Asia, and dozens of other countries will follow soon. Don’t miss out  fresh rates are waiting for you!   Website link — https://vibe-sms.net/ Our Telegram channel — https://t.me/vibe_sms
    • You didn't tell me anywhere that you wanted core.jar as proof, I have everything ready for an independent developer to review. All the conversations, all your edits. I won't settle anything with you, so you can threaten me again and damage my name.
    • So what? Did i say anything wrong? You have no idea what source/compile is. I still wait for your .jar or source to be posted since you say i destroyed the compiled version of yours. Why you don't post it? Are you afraid that people will just see few addon lines and you did not even know that your source and compiled had different things? I should not even waste 2 minute to fix your raidboss_spawnlist thing.    Your mentally ill. What you posted is our primary deal nothing against me.  Because all he does is post whatever i write as if i hide and i did not say any mod to join and check my discord. i want him actual post something against me or any offenses i did. I also requested him several hours ago to post his .jar where my code "HACKED" his server but he wont post.    Nobody should allow open a random topic and cause issues to other's life without proofs. I demand punishment and soon unless he post evidence that i hurt his server or left him or did not make what he asked. 
    • guys it is probably a misunderstanding if it was windows he would have solve it since its not windows and from the paraphrasing of the developer who eventually fixed the server   the problem was from guessing the login server was not properly opening or already crashed, so the gameserver probably loaded because he was generating logs, and then stopped, my guess is still there was no login to connect and made exits, still this is a guess because i have only saw some logs and images   in one side nobody would destroy a server for this amount of money in the other side he had no experience with the operating system, and i find this logical, i am also still giving some tutorials in the topic owner so he can learn how to compile and not need the help of others, i still believe this can be solved for both parties if they behave   in the end nobody wants to cause bad to another so as i say in my starting point, it is probably a misunderstanding
  • Topics

×
×
  • Create New...

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