Просмотр исходного кода

BETA: npcstring improvements by Nyaran, for more detailed info about this and examples, look here: http://www.l2jserver.com/forum/viewtopic.php?f=69&t=22632

MELERIX 13 лет назад
Родитель
Сommit
14e05b0cb6

+ 19 - 13
L2J_Server_BETA/java/com/l2jserver/gameserver/SevenSignsFestival.java

@@ -1689,17 +1689,17 @@ public class SevenSignsFestival implements SpawnListener
 	 * Primarily used for Festival Guide and Witch related speech.
 	 *
 	 * @param senderName
-	 * @param message
+	 * @param npcString
 	 */
-	public void sendMessageToAll(String senderName, String message)
+	public void sendMessageToAll(String senderName, int npcString)
 	{
 		if (_dawnChatGuide == null || _duskChatGuide == null)
 			return;
 		
-		CreatureSay cs = new CreatureSay(_dawnChatGuide.getObjectId(), Say2.SHOUT, senderName, message);
+		CreatureSay cs = new CreatureSay(_dawnChatGuide.getObjectId(), Say2.SHOUT, senderName, npcString);
 		_dawnChatGuide.broadcastPacket(cs);
 		
-		cs = new CreatureSay(_duskChatGuide.getObjectId(), Say2.SHOUT, senderName, message);
+		cs = new CreatureSay(_duskChatGuide.getObjectId(), Say2.SHOUT, senderName, npcString);
 		_duskChatGuide.broadcastPacket(cs);
 	}
 	
@@ -1788,7 +1788,7 @@ public class SevenSignsFestival implements SpawnListener
 					_log.info("SevenSignsFestival: Festival manager initialized. Those wishing to participate have " + getMinsToNextFestival()
 							+ " minute(s) to sign up.");
 				
-				sendMessageToAll("Festival Guide", "The main event will start in " + getMinsToNextFestival() + " minutes. Please register now.");
+				sendMessageToAll("Festival Guide", 1000317);
 				
 				// Stand by until the allowed signup period has elapsed.
 				try
@@ -1856,7 +1856,7 @@ public class SevenSignsFestival implements SpawnListener
 				_festivalInitialized = true;
 				
 				setNextFestivalStart(Config.ALT_FESTIVAL_CYCLE_LENGTH);
-				sendMessageToAll("Festival Guide", "The main event is now starting.");
+				sendMessageToAll("Festival Guide", 1000318);
 				
 				if (Config.DEBUG)
 					_log.info("SevenSignsFestival: The current set of festivals will begin in " + (Config.ALT_FESTIVAL_FIRST_SPAWN / 60000)
@@ -1881,7 +1881,7 @@ public class SevenSignsFestival implements SpawnListener
 				for (L2DarknessFestival festivalInst : _festivalInstances.values())
 				{
 					festivalInst.festivalStart();
-					festivalInst.sendMessageToParticipants("The festival is about to begin!");
+					festivalInst.sendMessageToParticipants(1000318);
 				}
 				
 				if (Config.DEBUG)
@@ -1917,7 +1917,7 @@ public class SevenSignsFestival implements SpawnListener
 				{
 					festivalInst.spawnFestivalMonsters(FESTIVAL_DEFAULT_RESPAWN / 2, 2);
 					festivalInst.sendMessageToParticipants("The festival will end in "
-							+ ((Config.ALT_FESTIVAL_LENGTH - Config.ALT_FESTIVAL_SECOND_SPAWN) / 60000) + " minute(s).");
+							+ ((Config.ALT_FESTIVAL_LENGTH - Config.ALT_FESTIVAL_SECOND_SPAWN) / 60000) + " minute(s)."); //FIXME add support for 1000319 & 1000320
 				}
 				
 				elapsedTime += Config.ALT_FESTIVAL_SECOND_SPAWN - Config.ALT_FESTIVAL_FIRST_SWARM;
@@ -1950,7 +1950,7 @@ public class SevenSignsFestival implements SpawnListener
 				for (L2DarknessFestival festivalInst : _festivalInstances.values())
 				{
 					festivalInst.spawnFestivalMonsters(FESTIVAL_DEFAULT_RESPAWN, 3);
-					festivalInst.sendMessageToParticipants("The chests have spawned! Be quick, the festival will end soon.");
+					festivalInst.sendMessageToParticipants("The chests have spawned! Be quick, the festival will end soon."); //FIXME What is the correct npcString?
 				}
 				
 				elapsedTime += Config.ALT_FESTIVAL_CHEST_SPAWN - Config.ALT_FESTIVAL_SECOND_SWARM;
@@ -1979,7 +1979,7 @@ public class SevenSignsFestival implements SpawnListener
 				// Allow signups for the next festival cycle.
 				_festivalInitialized = false;
 				
-				sendMessageToAll("Festival Witch", "That will do! I'll move you to the outside soon.");
+				sendMessageToAll("Festival Witch", 1000380);
 				
 				if (Config.DEBUG)
 					_log.info("SevenSignsFestival: The next set of festivals begin in " + getMinsToNextFestival() + " minute(s).");
@@ -2160,7 +2160,7 @@ public class SevenSignsFestival implements SpawnListener
 			_witchInst.broadcastPacket(msu);
 			
 			// Send a message to all participants from the witch.
-			sendMessageToParticipants("The festival will begin in 2 minutes.");
+			sendMessageToParticipants(1000317);
 		}
 		
 		protected void festivalStart()
@@ -2312,10 +2312,16 @@ public class SevenSignsFestival implements SpawnListener
 			return true;
 		}
 		
-		public void sendMessageToParticipants(String message)
+		public void sendMessageToParticipants(int npcString)
 		{
 			if (_participants != null && !_participants.isEmpty())
-				_witchInst.broadcastPacket(new CreatureSay(_witchInst.getObjectId(), Say2.ALL, "Festival Witch", message));
+				_witchInst.broadcastPacket(new CreatureSay(_witchInst.getObjectId(), Say2.ALL, "Festival Witch", npcString));
+		}
+		
+		public void sendMessageToParticipants(String string)
+		{
+			if (_participants != null && !_participants.isEmpty())
+				_witchInst.broadcastPacket(new CreatureSay(_witchInst.getObjectId(), Say2.ALL, "Festival Witch", string));
 		}
 		
 		protected void festivalEnd()

+ 4 - 6
L2J_Server_BETA/java/com/l2jserver/gameserver/ai/L2NpcWalkerAI.java

@@ -115,15 +115,13 @@ public class L2NpcWalkerAI extends L2CharacterAI implements Runnable
 		
 		if (getActor().isInsideRadius(destinationX, destinationY, destinationZ, 5, false, false))
 		{
-			int id = _route.get(_currentPos).getChatId();
+			int npcString = _route.get(_currentPos).getNpcString();
 			String chat = null;
-			if (id == 0)
+			if (npcString == -1)
 				chat = _route.get(_currentPos).getChatText();
 			
-			if ((id > 0) || (chat != null && !chat.isEmpty()))
-			{
-				getActor().broadcastChat(chat, id);
-			}
+			if ((npcString != -1) || (chat != null && !chat.isEmpty()))
+				getActor().broadcastChat(chat, npcString);
 			
 			//time in millis
 			long delay = _route.get(_currentPos).getDelay() * 1000;

+ 13 - 2
L2J_Server_BETA/java/com/l2jserver/gameserver/datatables/NpcWalkerRoutesTable.java

@@ -95,9 +95,20 @@ public class NpcWalkerRoutesTable
 							int y = Integer.parseInt(attrs.getNamedItem("Y").getNodeValue());
 							int z = Integer.parseInt(attrs.getNamedItem("Z").getNodeValue());
 							int delay = Integer.parseInt(attrs.getNamedItem("delay").getNodeValue());
-							String chat = attrs.getNamedItem("string").getNodeValue();
+							String chatString = null;
+							int npcString = -1;
+							Node node = attrs.getNamedItem("string");
+							if (node != null)
+								chatString = node.getNodeValue();
+							else
+							{
+								node = attrs.getNamedItem("npcString");
+								if (node != null)
+									npcString = Integer.parseInt(node.getNodeValue());
+							}
+							
 							boolean running = Boolean.parseBoolean(attrs.getNamedItem("run").getNodeValue());
-							list.add(new L2NpcWalkerNode(id, chat, x, y, z, delay, running));
+							list.add(new L2NpcWalkerNode(id, npcString, chatString, x, y, z, delay, running));
 						}
 					}
 					_routes.put(npcId, list);

+ 10 - 16
L2J_Server_BETA/java/com/l2jserver/gameserver/model/L2NpcWalkerNode.java

@@ -14,7 +14,6 @@
  */
 package com.l2jserver.gameserver.model;
 
-
 /**
  * 
  * @author Rayan RPG, JIV
@@ -24,25 +23,20 @@ package com.l2jserver.gameserver.model;
 public class L2NpcWalkerNode
 {
 	private int _routeId;
-	private String _chatText;
-	private int _chatId = 0;
+	private String _chatString;
+	private int _npcString;
 	private int _moveX;
 	private int _moveY;
 	private int _moveZ;
 	private int _delay;
 	private boolean _running;
 	
-	public L2NpcWalkerNode(int routeId, String chatText, int moveX, int moveY, int moveZ, int delay, boolean running)
+	public L2NpcWalkerNode(int routeId, int npcString, String chatText, int moveX, int moveY, int moveZ, int delay, boolean running)
 	{
 		super();
 		this._routeId = routeId;
-		this._chatText = chatText;
-		if (_chatText.startsWith("#"))
-		{
-			_chatId = Integer.parseInt(_chatText.substring(1));
-		}
-		else if (_chatText.trim().isEmpty())
-			_chatText = null;
+		this._chatString = chatText;
+		this._npcString = npcString;
 		this._moveX = moveX;
 		this._moveY = moveY;
 		this._moveZ = moveZ;
@@ -57,9 +51,9 @@ public class L2NpcWalkerNode
 	
 	public String getChatText()
 	{
-		if (_chatId != 0)
-			throw new IllegalStateException("Chat id is defined for walker route!");
-		return _chatText;
+		if (_npcString != -1)
+			throw new IllegalStateException("npcString is defined for walker route!");
+		return _chatString;
 	}
 	
 	public int getMoveX()
@@ -87,8 +81,8 @@ public class L2NpcWalkerNode
 		return _running;
 	}
 
-	public int getChatId()
+	public int getNpcString()
 	{
-		return _chatId;
+		return _npcString;
 	}
 }

+ 6 - 6
L2J_Server_BETA/java/com/l2jserver/gameserver/model/actor/instance/L2FortCommanderInstance.java

@@ -114,24 +114,24 @@ public class L2FortCommanderInstance extends L2DefenderInstance
 			{
 				if (spawn2.getNpcId() == spawn.getNpcid())
 				{
-					String text = "";
+					int npcString = -1;
 					switch (spawn2.getId())
 					{
 						case 1:
-							text = "Attacking the enemy's reinforcements is necesary. Time to Die!";
+							npcString = 1300013;
 							break;
 						case 2:
 							if (attacker instanceof L2Summon)
 								attacker = ((L2Summon) attacker).getOwner();
-							text = "Everyone, concentrate your attacks on "+attacker.getName()+"! Show the enemy your resolve!";
+							npcString = 1300012;
 							break;
 						case 3:
-							text = "Spirit of Fire, unleash your power! Burn the enemy!!";
+							npcString = 1300014;
 							break;
 					}
-					if (!text.isEmpty())
+					if (npcString != -1)
 					{
-						broadcastPacket(new NpcSay(getObjectId(), 1, getNpcId(), text));
+						broadcastPacket(new NpcSay(getObjectId(), 1, getNpcId(), npcString));
 						setCanTalk(false);
 						ThreadPoolManager.getInstance().scheduleGeneral(new ScheduleTalkTask(), 10000);
 					}

+ 3 - 3
L2J_Server_BETA/java/com/l2jserver/gameserver/model/actor/instance/L2NpcWalkerInstance.java

@@ -69,13 +69,13 @@ public class L2NpcWalkerInstance extends L2Npc
 	 * Sends a chat to all _knowObjects
 	 * @param chat message to say
 	 */
-	public void broadcastChat(String chat, int id)
+	public void broadcastChat(String chat, int npcString)
 	{
 		NpcSay cs;
-		if (id == 0)
+		if (npcString == -1)
 			cs = new NpcSay(getObjectId(), Say2.ALL, getNpcId(), chat);
 		else
-			cs = new NpcSay(getObjectId(), Say2.ALL, getNpcId(), id);
+			cs = new NpcSay(getObjectId(), Say2.ALL, getNpcId(), npcString);
 		Broadcast.toKnownPlayers(this, cs);
 	}
 	

+ 2 - 2
L2J_Server_BETA/java/com/l2jserver/gameserver/model/actor/instance/L2PenaltyMonsterInstance.java

@@ -44,7 +44,7 @@ public class L2PenaltyMonsterInstance extends L2MonsterInstance
 	{
 		if (Rnd.get(100) <= 80)
 		{
-			CreatureSay cs = new CreatureSay(getObjectId(), Say2.ALL, getName(), "mmm your bait was delicious");
+			CreatureSay cs = new CreatureSay(getObjectId(), Say2.ALL, getName(), 1010441);
 			this.broadcastPacket(cs);
 		}
 		_ptk = ptk;
@@ -61,7 +61,7 @@ public class L2PenaltyMonsterInstance extends L2MonsterInstance
 		
 		if (Rnd.get(100) <= 75)
 		{
-			CreatureSay cs = new CreatureSay(getObjectId(), Say2.ALL, getName(), "I will tell fishes not to take your bait");
+			CreatureSay cs = new CreatureSay(getObjectId(), Say2.ALL, getName(), 1010416);
 			this.broadcastPacket(cs);
 		}
 		return true;

+ 7 - 7
L2J_Server_BETA/java/com/l2jserver/gameserver/model/entity/FortSiege.java

@@ -556,24 +556,24 @@ public class FortSiege implements Siegable
 				{
 					if (spawn2.getNpcId() == spawn.getNpcid())
 					{
-						int message = 0;
+						int npcString = -1;
 						switch (spawn2.getId())
 						{
 							case 1:
-								message = 1300004; // You may have broken our arrows, but you will never break our will! Archers, retreat!
+								npcString = 1300004; // You may have broken our arrows, but you will never break our will! Archers, retreat!
 								break;
 							case 2:
-								message = 1300006; // Aiieeee! Command Center! This is guard unit! We need backup right away!
+								npcString = 1300006; // Aiieeee! Command Center! This is guard unit! We need backup right away!
 								break;
 							case 3:
-								message = 1300005; // At last! The Magic Field that protects the fortress has weakened! Volunteers, stand back!
+								npcString = 1300005; // At last! The Magic Field that protects the fortress has weakened! Volunteers, stand back!
 								break;
 							case 4:
-								message = 1300020; // I feel so much grief that I can't even take care of myself. There isn't any reason for me to stay here any longer.
+								npcString = 1300020; // I feel so much grief that I can't even take care of myself. There isn't any reason for me to stay here any longer.
 								break;
 						}
-						if (message != 0)
-							instance.broadcastPacket(new NpcSay(instance.getObjectId(), 1, instance.getNpcId(), message));
+						if (npcString != -1)
+							instance.broadcastPacket(new NpcSay(instance.getObjectId(), 1, instance.getNpcId(), npcString));
 					}
 				}
 				_commanders.remove(spawn);

+ 5 - 8
L2J_Server_BETA/java/com/l2jserver/gameserver/model/olympiad/OlympiadAnnouncer.java

@@ -56,21 +56,18 @@ public final class OlympiadAnnouncer implements Runnable
 			task = OlympiadGameManager.getInstance().getOlympiadTask(_currentStadium);
 			if (task != null && task.getGame() != null && task.needAnnounce())
 			{
-				int msg;
+				int npcString;
 				final String arenaId = String.valueOf(task.getGame().getStadiumId() + 1);
 				switch (task.getGame().getType())
 				{
 					case NON_CLASSED:
-						// msg = "Olympiad class-free individual match is going to begin in Arena " + arenaId + " in a moment.";
-						msg = 1300166;
+						npcString = 1300166; // "Olympiad class-free individual match is going to begin in Arena " + arenaId + " in a moment.";
 						break;
 					case CLASSED:
-						// msg = "Olympiad class-specific individual match is going to begin in Arena " + arenaId + " in a moment.";
-						msg = 1300167;
+						npcString = 1300167; // "Olympiad class-specific individual match is going to begin in Arena " + arenaId + " in a moment.";
 						break;
 					case TEAMS:
-						// msg = "Olympiad class-free team match is going to begin in Arena " + arenaId + " in a moment.";
-						msg = 1300132;
+						npcString = 1300132; // "Olympiad class-free team match is going to begin in Arena " + arenaId + " in a moment.";
 						break;
 					default:
 						continue;
@@ -83,7 +80,7 @@ public final class OlympiadAnnouncer implements Runnable
 					manager = spawn.getLastSpawn();
 					if (manager != null)
 					{
-						packet = new NpcSay(manager.getObjectId(), Say2.SHOUT, manager.getNpcId(), msg);
+						packet = new NpcSay(manager.getObjectId(), Say2.SHOUT, manager.getNpcId(), npcString);
 						packet.addStringParameter(arenaId);
 						manager.broadcastPacket(packet);
 					}

+ 2 - 2
L2J_Server_BETA/java/com/l2jserver/gameserver/network/SystemMessageId.java

@@ -9463,7 +9463,7 @@ public final class SystemMessageId
 	 * ID: 1625<br>
 	 * Message: Departure for Rune Harbor will take place after anchoring for ten minutes.
 	 */
-	public static final SystemMessageId REPARTURE_FOR_RUNE_10_MINUTES;
+	public static final SystemMessageId DEPARTURE_FOR_RUNE_10_MINUTES;
 	
 	/**
 	 * ID: 1626<br>
@@ -16309,7 +16309,7 @@ public final class SystemMessageId
 		DEPARTURE_FOR_GLUDIN_1_MINUTE = new SystemMessageId(1622);
 		DEPARTURE_FOR_GLUDIN_SHORTLY = new SystemMessageId(1623);
 		DEPARTURE_FOR_GLUDIN_NOW = new SystemMessageId(1624);
-		REPARTURE_FOR_RUNE_10_MINUTES = new SystemMessageId(1625);
+		DEPARTURE_FOR_RUNE_10_MINUTES = new SystemMessageId(1625);
 		DEPARTURE_FOR_RUNE_5_MINUTES = new SystemMessageId(1626);
 		DEPARTURE_FOR_RUNE_1_MINUTE = new SystemMessageId(1627);
 		DEPARTURE_FOR_GLUDIN_SHORTLY2 = new SystemMessageId(1628);

+ 35 - 4
L2J_Server_BETA/java/com/l2jserver/gameserver/network/serverpackets/CreatureSay.java

@@ -13,6 +13,9 @@
  * this program. If not, see <http://www.gnu.org/licenses/>.
  */
 package com.l2jserver.gameserver.network.serverpackets;
+import java.util.ArrayList;
+import java.util.List;
+
 import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
 
 /**
@@ -29,7 +32,8 @@ public final class CreatureSay extends L2GameServerPacket
 	private String _charName = null;
 	private int _charId = 0;
 	private String _text = null;
-	private int _msgId = -1;
+	private int _npcString = -1;
+	private List<String> _parameters;
 	
 	/**
 	 * @param _characters
@@ -42,12 +46,31 @@ public final class CreatureSay extends L2GameServerPacket
 		_text = text;
 	}
 	
-	public CreatureSay(int objectId, int messageType, int charId, int msgId)
+	public CreatureSay(int objectId, int messageType, int charId, int npcString)
 	{
 		_objectId = objectId;
 		_textType = messageType;
 		_charId = charId;
-		_msgId = msgId;
+		_npcString = npcString;
+	}
+	
+	public CreatureSay(int objectId, int messageType, String charName, int npcString)
+	{
+		_objectId = objectId;
+		_textType = messageType;
+		_charName = charName;
+		_npcString = npcString;
+	}
+	
+	/**
+	 * String parameter for argument S1,S2,.. in npcstring-e.dat
+	 * @param text
+	 */
+	public void addStringParameter(String text)
+	{
+		if (_parameters == null)
+			_parameters = new ArrayList<String>();
+		_parameters.add(text);
 	}
 	
 	@Override
@@ -60,9 +83,17 @@ public final class CreatureSay extends L2GameServerPacket
 			writeS(_charName);
 		else
 			writeD(_charId);
-		writeD(_msgId); // High Five NPCString ID
+		writeD(_npcString); // High Five NPCString ID
 		if (_text != null)
 			writeS(_text);
+		else
+		{
+			if (_parameters != null)
+			{
+				for (String s : _parameters)
+					writeS(s);
+			}
+		}
 	}
 	
 	@Override

+ 54 - 10
L2J_Server_BETA/java/com/l2jserver/gameserver/network/serverpackets/ExShowScreenMessage.java

@@ -14,6 +14,9 @@
  */
 package com.l2jserver.gameserver.network.serverpackets;
 
+import java.util.ArrayList;
+import java.util.List;
+
 /**
  * @author Kerberos
  *
@@ -25,12 +28,14 @@ public class ExShowScreenMessage extends L2GameServerPacket
 	private int _unk1;
 	private int _unk2;
 	private int _unk3;
-	private int _unk4;
+	private boolean _fade;
 	private int _size;
 	private int _position;
 	private boolean _effect;
 	private String _text;
 	private int _time;
+	private int _npcString;
+	private List<String> _parameters;
 	
 	public ExShowScreenMessage (String text, int time)
 	{
@@ -39,28 +44,57 @@ public class ExShowScreenMessage extends L2GameServerPacket
 		_unk1 = 0;
 		_unk2 = 0;
 		_unk3 = 0;
-		_unk4 = 0;
+		_fade = false;
 		_position = 0x02;
 		_text = text;
 		_time = time;
 		_size = 0;
 		_effect = false;
+		_npcString = -1;
+	}
+	
+	public ExShowScreenMessage (int npcString, int position, int time) // For npcstring
+	{
+		_type = 2;
+		_sysMessageId = -1;
+		_unk1 = 0;
+		_unk2 = 0;
+		_unk3 = 0;
+		_fade = false;
+		_position = position;
+		_text = null;
+		_time = time;
+		_size = 0;
+		_effect = false;
+		_npcString = npcString;
 	}
 	
-	public ExShowScreenMessage (int type, int messageId, int position, int unk1, int size, int unk2, int unk3,boolean showEffect, int time,int unk4, String text)
+	/**
+	 * String parameter for argument S1,S2,.. in npcstring-e.dat
+	 * @param text
+	 */
+	public void addStringParameter(String text)
+	{
+		if (_parameters == null)
+			_parameters = new ArrayList<String>();
+		_parameters.add(text);
+	}
+	
+	/*public ExShowScreenMessage (int type, int messageId, int position, int unk1, int size, int unk2, int unk3,boolean showEffect, int time,boolean fade, String text, int npcString)
 	{
 		_type = type;
 		_sysMessageId = messageId;
 		_unk1 = unk1;
 		_unk2 = unk2;
 		_unk3 = unk3;
-		_unk4 = unk4;
+		_fade = fade;
 		_position = position;
 		_text = text;
 		_time = time;
 		_size = size;
 		_effect = showEffect;
-	}
+		_npcString = npcString;
+	}*/
 	
 	@Override
 	public String getType()
@@ -73,7 +107,7 @@ public class ExShowScreenMessage extends L2GameServerPacket
 	{
 		writeC(0xfe);
 		writeH(0x39);
-		writeD(_type); // 0 - system messages, 1 - your defined text
+		writeD(_type); // 0 - system messages, 1 - your defined text, 2 - npcstring
 		writeD(_sysMessageId); // system message id (_type must be 0 otherwise no effect)
 		writeD(_position); // message position
 		writeD(_unk1); // ?
@@ -82,8 +116,18 @@ public class ExShowScreenMessage extends L2GameServerPacket
 		writeD(_unk3); // ?
 		writeD(_effect == true ? 1 : 0); // upper effect (0 - disabled, 1 enabled) - _position must be 2 (center) otherwise no effect
 		writeD(_time); // time
-		writeD(_unk4); // ?
-		writeD(-1); //TODO: npcString
-		writeS(_text); // your text (_type must be 1, otherwise no effect)
+		writeD(_fade == true ? 1 : 0); // fade effect (0 - disabled, 1 enabled)
+		writeD(_npcString); // npcString
+		if (_npcString == -1)
+			writeS(_text); // your text (_type must be 1, otherwise no effect)
+		else
+		{
+			if (_parameters != null)
+			{
+				for (String s : _parameters)
+					writeS(s);
+			}
+		}
 	}
-}
+}
+