Kaynağa Gözat

Several additions to TvT Event, also all TvT htmls are unhardcoded

# TvT Event Participation Fee (itemId, number). Fee is not returned.
# Example: 57,100000
# Default = none
TvTEventParticipationFee =

# Participant's effects handling on teleport/death.
# Effects lasting through death never removed.
# 0 - always remove all effects.
# 1 - remove all effects only during port to event (noblesse blessing can be used)
# 2 - never remove any effect
# Default: 0
TvTEventEffectsRemoval = 0
_DS_ 16 yıl önce
ebeveyn
işleme
e10d6983a5

+ 12 - 0
L2_GameServer/java/config/l2jmods.properties

@@ -132,6 +132,11 @@ TvTEventRunningTime = 20
 # TvT Event NPC (create a custom npc of type L2TvTEventNpc).
 TvTEventParticipationNpcId = 70010
 
+# TvT Event Participation Fee (itemId, number). Fee is not returned.
+# Example: 57,100000
+# Default = none
+TvTEventParticipationFee =
+
 # Location for TvTEvent NPC to spawn.
 TvTEventParticipationNpcCoordinates = 83425,148585,-3406
 
@@ -173,6 +178,13 @@ TvTDoorsToClose =
 # Should both teams get reward if there's a tie?
 TvTRewardTeamTie = False
 
+# Participant's effects handling on teleport/death.
+# Effects lasting through death never removed.
+# 0 - always remove all effects.
+# 1 - remove all effects only during port to event (noblesse blessing can be used)
+# 2 - never remove any effect
+# Default: 0
+TvTEventEffectsRemoval = 0
 
 # ---------------------------------------------------------------------------
 # L2J Banking System

+ 14 - 0
L2_GameServer/java/net/sf/l2j/Config.java

@@ -534,6 +534,7 @@ public final class Config
 	public static int TVT_EVENT_RUNNING_TIME;
 	public static int TVT_EVENT_PARTICIPATION_NPC_ID;
 	public static int[] TVT_EVENT_PARTICIPATION_NPC_COORDINATES = new int[3];
+	public static int[] TVT_EVENT_PARTICIPATION_FEE = new int[2];
 	public static int TVT_EVENT_MIN_PLAYERS_IN_TEAMS;
 	public static int TVT_EVENT_MAX_PLAYERS_IN_TEAMS;
 	public static int TVT_EVENT_RESPAWN_TELEPORT_DELAY;
@@ -552,6 +553,7 @@ public final class Config
 	public static boolean TVT_REWARD_TEAM_TIE;
 	public static byte TVT_EVENT_MIN_LVL;
 	public static byte TVT_EVENT_MAX_LVL;
+	public static int TVT_EVENT_EFFECTS_REMOVAL;
 	public static boolean L2JMOD_ALLOW_WEDDING;
 	public static int L2JMOD_WEDDING_PRICE;
 	public static boolean L2JMOD_WEDDING_PUNISH_INFIDELITY;
@@ -1727,6 +1729,7 @@ public final class Config
 							TVT_EVENT_MAX_LVL = (byte)Integer.parseInt(L2JModSettings.getProperty("TvTEventMaxPlayerLevel", "80"));
 							TVT_EVENT_RESPAWN_TELEPORT_DELAY = Integer.parseInt(L2JModSettings.getProperty("TvTEventRespawnTeleportDelay", "20"));
 							TVT_EVENT_START_LEAVE_TELEPORT_DELAY = Integer.parseInt(L2JModSettings.getProperty("TvTEventStartLeaveTeleportDelay", "20"));
+							TVT_EVENT_EFFECTS_REMOVAL = Integer.parseInt(L2JModSettings.getProperty("TvTEventEffectsRemoval", "0"));
 							TVT_EVENT_TEAM_1_NAME = L2JModSettings.getProperty("TvTEventTeam1Name", "Team1");
 							propertySplit = L2JModSettings.getProperty("TvTEventTeam1Coordinates", "0,0,0").split(",");
 							if (propertySplit.length < 3)
@@ -1751,6 +1754,17 @@ public final class Config
 									TVT_EVENT_TEAM_2_COORDINATES[0] = Integer.parseInt(propertySplit[0]);
 									TVT_EVENT_TEAM_2_COORDINATES[1] = Integer.parseInt(propertySplit[1]);
 									TVT_EVENT_TEAM_2_COORDINATES[2] = Integer.parseInt(propertySplit[2]);
+									propertySplit = L2JModSettings.getProperty("TvTEventParticipationFee", "0,0").split(",");
+									try
+									{
+										TVT_EVENT_PARTICIPATION_FEE[0] = Integer.parseInt(propertySplit[0]);
+										TVT_EVENT_PARTICIPATION_FEE[1] = Integer.parseInt(propertySplit[1]);
+									}
+									catch (NumberFormatException nfe)
+									{
+										if (propertySplit.length > 0)
+											_log.warning("TvTEventEngine[Config.load()]: invalid config property -> TvTEventParticipationFee");
+									}
 									propertySplit = L2JModSettings.getProperty("TvTEventReward", "57,100000").split(";");
 									for (String reward : propertySplit)
 									{

+ 12 - 11
L2_GameServer/java/net/sf/l2j/gameserver/model/actor/instance/L2TvTEventNpcInstance.java

@@ -24,6 +24,8 @@ import net.sf.l2j.gameserver.templates.chars.L2NpcTemplate;
 
 public class L2TvTEventNpcInstance extends L2Npc
 {
+	private static final String htmlPath="data/html/mods/TvTEvent/";
+
 	public L2TvTEventNpcInstance(int objectId, L2NpcTemplate template)
 	{
 		super(objectId, template);
@@ -43,16 +45,13 @@ public class L2TvTEventNpcInstance extends L2Npc
 
 		if (TvTEvent.isParticipating())
 		{
-			String htmFile = "data/html/mods/";
+			final boolean isParticipant = TvTEvent.isPlayerParticipant(playerInstance.getObjectId()); 
+			final String htmContent;
 
-			if (!TvTEvent.isPlayerParticipant(playerInstance.getObjectId()))
-				htmFile += "TvTEventParticipation";
+			if (!isParticipant)
+				htmContent = HtmCache.getInstance().getHtm(htmlPath + "Participation.htm");
 			else
-				htmFile += "TvTEventRemoveParticipation";
-
-			htmFile += ".htm";
-
-			String htmContent = HtmCache.getInstance().getHtm(htmFile);
+				htmContent = HtmCache.getInstance().getHtm(htmlPath + "RemoveParticipation.htm");
 
 	    	if (htmContent != null)
 	    	{
@@ -66,13 +65,15 @@ public class L2TvTEventNpcInstance extends L2Npc
 				npcHtmlMessage.replace("%team2name%", Config.TVT_EVENT_TEAM_2_NAME);
 				npcHtmlMessage.replace("%team2playercount%", String.valueOf(teamsPlayerCounts[1]));
 				npcHtmlMessage.replace("%playercount%", String.valueOf(teamsPlayerCounts[0]+teamsPlayerCounts[1]));
-	    		playerInstance.sendPacket(npcHtmlMessage);
+				if (!isParticipant)
+					npcHtmlMessage.replace("%fee%", TvTEvent.getParticipationFee());
+
+				playerInstance.sendPacket(npcHtmlMessage);
 	    	}
 		}
 		else if (TvTEvent.isStarting() || TvTEvent.isStarted())
 		{
-			String htmFile = "data/html/mods/TvTEventStatus.htm";
-			String htmContent = HtmCache.getInstance().getHtm(htmFile);
+			final String htmContent = HtmCache.getInstance().getHtm(htmlPath + "Status.htm");
 
 	    	if (htmContent != null)
 	    	{

+ 65 - 15
L2_GameServer/java/net/sf/l2j/gameserver/model/entity/TvTEvent.java

@@ -20,6 +20,7 @@ import java.util.logging.Logger;
 
 import javolution.util.FastMap;
 import net.sf.l2j.Config;
+import net.sf.l2j.gameserver.cache.HtmCache;
 import net.sf.l2j.gameserver.datatables.DoorTable;
 import net.sf.l2j.gameserver.datatables.ItemTable;
 import net.sf.l2j.gameserver.datatables.NpcTable;
@@ -42,6 +43,7 @@ import net.sf.l2j.gameserver.network.serverpackets.NpcHtmlMessage;
 import net.sf.l2j.gameserver.network.serverpackets.StatusUpdate;
 import net.sf.l2j.gameserver.network.serverpackets.SystemMessage;
 import net.sf.l2j.gameserver.templates.chars.L2NpcTemplate;
+import net.sf.l2j.gameserver.util.StringUtil;
 import net.sf.l2j.util.Rnd;
 
 /**
@@ -60,6 +62,8 @@ public class TvTEvent
 	}
 	
 	protected static final Logger _log = Logger.getLogger(TvTEvent.class.getName());
+	/** html path **/
+	private static final String htmlPath = "data/html/mods/TvTEvent/";
 	/**	The teams of the TvTEvent<br> */
 	private static TvTEventTeam[] _teams = new TvTEventTeam[2];
 	/** The state of the TvTEvent<br> */
@@ -333,7 +337,7 @@ public class TvTEvent
 			NpcHtmlMessage npcHtmlMessage = new NpcHtmlMessage(0);
 			
 			statusUpdate.addAttribute(StatusUpdate.CUR_LOAD, playerInstance.getCurrentLoad());
-			npcHtmlMessage.setHtml("<html><head><title>TvT Event</title></head><body>Your team won the event. Look in your inventory, there should be your reward.</body></html>");
+			npcHtmlMessage.setHtml(HtmCache.getInstance().getHtm(htmlPath+"Reward.htm"));
 			playerInstance.sendPacket(statusUpdate);
 			playerInstance.sendPacket(npcHtmlMessage);
 		}
@@ -394,7 +398,7 @@ public class TvTEvent
 			NpcHtmlMessage npcHtmlMessage = new NpcHtmlMessage(0);
 			
 			statusUpdate.addAttribute(StatusUpdate.CUR_LOAD, playerInstance.getCurrentLoad());
-			npcHtmlMessage.setHtml("<html><head><title>TvT Event</title></head><body>Your team won the event. Look in your inventory, there should be your reward.</body></html>");
+			npcHtmlMessage.setHtml(HtmCache.getInstance().getHtm(htmlPath+"Reward.htm"));
 			playerInstance.sendPacket(statusUpdate);
 			playerInstance.sendPacket(npcHtmlMessage);
 		}
@@ -494,7 +498,31 @@ public class TvTEvent
 		
 		return false;
 	}
-	
+
+	public static boolean payParticipationFee(L2PcInstance playerInstance)
+	{
+		int itemId = Config.TVT_EVENT_PARTICIPATION_FEE[0];
+		int itemNum = Config.TVT_EVENT_PARTICIPATION_FEE[1];
+		if (itemId == 0 || itemNum == 0)
+			return true;
+
+		if (playerInstance.getInventory().getInventoryItemCount(itemId, -1) < itemNum)
+			return false;
+
+		return playerInstance.destroyItemByItemId("TvT Participation Fee", itemId, itemNum, _lastNpcSpawn, true);
+	}
+
+	public static String getParticipationFee()
+	{
+		int itemId = Config.TVT_EVENT_PARTICIPATION_FEE[0];
+		int itemNum = Config.TVT_EVENT_PARTICIPATION_FEE[1];
+
+		if (itemId == 0 || itemNum == 0)
+			return "-";
+		
+		return StringUtil.concat(String.valueOf(itemNum), " ", ItemTable.getInstance().getTemplate(itemId).getName());
+	}
+
 	/**
 	 * Send a SystemMessage to all participated players<br>
 	 * 1. Send the message to all players of team number one<br>
@@ -612,10 +640,10 @@ public class TvTEvent
 	public static synchronized void onBypass(String command, L2PcInstance playerInstance)
 	{
 		if (playerInstance == null || !isParticipating())
-		{
 			return;
-		}
 		
+		final String htmContent;
+
 		if (command.equals("tvt_event_participation"))
 		{
 			NpcHtmlMessage npcHtmlMessage = new NpcHtmlMessage(0);
@@ -623,32 +651,54 @@ public class TvTEvent
 			
 			if (playerInstance.isCursedWeaponEquipped())
 			{
-				npcHtmlMessage.setHtml("<html><head><title>TvT Event</title></head><body>Cursed weapon owners are not allowed to participate.</body></html>");
+				htmContent = HtmCache.getInstance().getHtm(htmlPath+"CursedWeaponEquipped.htm");
+				if (htmContent != null)
+					npcHtmlMessage.setHtml(htmContent);
 			}
 			else if (Olympiad.getInstance().isRegistered(playerInstance))
 			{
-				npcHtmlMessage.setHtml("<html><head><title>TvT Event</title></head><body>You can not participate when registered for Olympiad.</body></html>");
+				htmContent = HtmCache.getInstance().getHtm(htmlPath+"Olympiad.htm");
+				if (htmContent != null)
+					npcHtmlMessage.setHtml(htmContent);
 			}
 			else if (playerInstance.getKarma() > 0)
 			{
-				npcHtmlMessage.setHtml("<html><head><title>TvT Event</title></head><body>Chaotic players are not allowed to participate.</body></html>");
+				htmContent = HtmCache.getInstance().getHtm(htmlPath+"Karma.htm");
+				if (htmContent != null)
+					npcHtmlMessage.setHtml(htmContent);
 			}
 			else if (playerLevel < Config.TVT_EVENT_MIN_LVL || playerLevel > Config.TVT_EVENT_MAX_LVL)
 			{
-				npcHtmlMessage.setHtml("<html><head><title>TvT Event</title></head><body>Only players from level " + Config.TVT_EVENT_MIN_LVL + " to level " + Config.TVT_EVENT_MAX_LVL + " are allowed tro participate.</body></html>");
+				htmContent = HtmCache.getInstance().getHtm(htmlPath+"Level.htm");
+				if (htmContent != null)
+				{
+					npcHtmlMessage.setHtml(htmContent);
+					npcHtmlMessage.replace("%min%", String.valueOf(Config.TVT_EVENT_MIN_LVL));
+					npcHtmlMessage.replace("%max%", String.valueOf(Config.TVT_EVENT_MAX_LVL));
+				}
 			}
 			else if (_teams[0].getParticipatedPlayerCount() == Config.TVT_EVENT_MAX_PLAYERS_IN_TEAMS && _teams[1].getParticipatedPlayerCount() == Config.TVT_EVENT_MAX_PLAYERS_IN_TEAMS)
 			{
-				npcHtmlMessage.setHtml("<html><head><title>TvT Event</title></head><body>The event is full! Only " + Config.TVT_EVENT_MAX_PLAYERS_IN_TEAMS + " players are allowed per team.</body></html>");
+				htmContent = HtmCache.getInstance().getHtm(htmlPath+"TeamsFull.htm");
+				if (htmContent != null)
+				{
+					npcHtmlMessage.setHtml(htmContent);
+					npcHtmlMessage.replace("%max%", String.valueOf(Config.TVT_EVENT_MAX_PLAYERS_IN_TEAMS));
+				}
 			}
-			else if (addParticipant(playerInstance))
+			else if (!payParticipationFee(playerInstance))
 			{
-				npcHtmlMessage.setHtml("<html><head><title>TvT Event</title></head><body>You are on the registration list now.</body></html>");
+				htmContent = HtmCache.getInstance().getHtm(htmlPath+"ParticipationFee.htm");
+				if (htmContent != null)
+				{
+					npcHtmlMessage.setHtml(htmContent);
+					npcHtmlMessage.replace("%fee%", getParticipationFee());
+				}
 			}
+			else if (addParticipant(playerInstance))
+				npcHtmlMessage.setHtml(HtmCache.getInstance().getHtm(htmlPath+"Registered.htm"));
 			else
-			{
 				return;
-			}
 			
 			playerInstance.sendPacket(npcHtmlMessage);
 		}
@@ -658,7 +708,7 @@ public class TvTEvent
 			
 			NpcHtmlMessage npcHtmlMessage = new NpcHtmlMessage(0);
 			
-			npcHtmlMessage.setHtml("<html><head><title>TvT Event</title></head><body>You are not longer on the registration list.</body></html>");
+			npcHtmlMessage.setHtml(HtmCache.getInstance().getHtm(htmlPath+"Unregistered.htm"));
 			playerInstance.sendPacket(npcHtmlMessage);
 		}
 	}

+ 5 - 18
L2_GameServer/java/net/sf/l2j/gameserver/model/entity/TvTEventTeleporter.java

@@ -16,7 +16,6 @@ package net.sf.l2j.gameserver.model.entity;
 
 import net.sf.l2j.Config;
 import net.sf.l2j.gameserver.ThreadPoolManager;
-import net.sf.l2j.gameserver.model.L2Effect;
 import net.sf.l2j.gameserver.model.actor.L2Summon;
 import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
 import net.sf.l2j.util.Rnd;
@@ -62,25 +61,17 @@ public class TvTEventTeleporter implements Runnable
 	public void run()
 	{
 		if (_playerInstance == null)
-		{
 			return;
-		}
 		
 		L2Summon summon = _playerInstance.getPet();
 		
 		if (summon != null)
-		{
 			summon.unSummon(_playerInstance);
-		}
-		
-		for (L2Effect effect : _playerInstance.getAllEffects())
-		{
-			if (effect != null)
-			{
-				effect.exit();
-			}
-		}
-		
+
+		if (Config.TVT_EVENT_EFFECTS_REMOVAL == 0
+				|| (Config.TVT_EVENT_EFFECTS_REMOVAL == 1 && _playerInstance.getTeam() == 0))
+			_playerInstance.stopAllEffectsExceptThoseThatLastThroughDeath();
+
 		_playerInstance.doRevive();
 		_playerInstance.setCurrentCp(_playerInstance.getMaxCp());
 		_playerInstance.setCurrentHp(_playerInstance.getMaxHp());
@@ -89,13 +80,9 @@ public class TvTEventTeleporter implements Runnable
 		_playerInstance.teleToLocation( _coordinates[ 0 ] + Rnd.get(101)-50, _coordinates[ 1 ] + Rnd.get(101)-50, _coordinates[ 2 ], false );
 		
 		if (TvTEvent.isStarted() && !_adminRemove)
-		{
 			_playerInstance.setTeam(TvTEvent.getParticipantTeamId(_playerInstance.getObjectId()) + 1);
-		}
 		else
-		{
 			_playerInstance.setTeam(0);
-		}
 		
 		_playerInstance.broadcastStatusUpdate();
 		_playerInstance.broadcastUserInfo();