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

Bandit Stronghold is now working. DP side

BiggBoss 13 лет назад
Родитель
Сommit
623915c64b

+ 4 - 1
L2J_DataPack_BETA/data/html/admin/siegablehall.htm

@@ -29,7 +29,10 @@ ClanHall Owner: %clanhallOwner%
 </tr><tr>
 <td><button value="Set Siege Date" action="bypass -h admin_chsiege_setSiegeDate %clanhallId% $box" width=135 height=21 back="L2UI_CT1.Button_DF_Down" fore="L2UI_CT1.Button_DF"></td>
 <td><button value="Teleport self" action="bypass -h admin_clanhallteleportself %clanhallId%" width=135 height=21 back="L2UI_CT1.Button_DF_Down" fore="L2UI_CT1.Button_DF"></td>
-</tr></table></center>
+</tr><tr>
+<td><button value="Forward Siege" action="bypass -h admin_chsiege_forwardSiege %clanhallId%" width=135 height=21 back="L2UI_CT1.Button_DF_Down" fore="L2UI_CT1.Button_DF"></td>
+</tr>
+</table></center>
 <br><font color="FF0000">
 Note:</font> Use the box to enter the clan name to add/remove (can be done just by targetting a clan member) or the date to set the siege. Date must be on this format DD-MM-YYYY;HH:MM.
 </body></html>

+ 71 - 94
L2J_DataPack_BETA/data/scripts/conquerablehalls/BanditStrongHold/BanditStrongHold.java

@@ -3,13 +3,13 @@
  */
 package conquerablehalls.BanditStrongHold;
 
+import gnu.trove.TIntObjectHashMap;
+
 import java.sql.Connection;
 import java.sql.PreparedStatement;
 import java.sql.ResultSet;
 import java.util.ArrayList;
 
-import javolution.util.FastMap;
-
 import com.l2jserver.L2DatabaseFactory;
 import com.l2jserver.gameserver.Announcements;
 import com.l2jserver.gameserver.ai.CtrlIntention;
@@ -39,12 +39,12 @@ public final class BanditStrongHold extends ClanHallSiegeEngine
 {
 	private class ClanData
 	{
-		private int flag = 0;
-		private int npc = 0;
-		private ArrayList<Integer> players = new ArrayList<Integer>(18);
-		private ArrayList<L2PcInstance> playersInstance = new ArrayList<L2PcInstance>(18);
-		private L2Spawn warrior = null;
-		private L2Spawn flagInstance = null;
+		int flag = 0;
+		int npc = 0;
+		ArrayList<Integer> players = new ArrayList<Integer>(18);
+		ArrayList<L2PcInstance> playersInstance = new ArrayList<L2PcInstance>(18);
+		L2Spawn warrior = null;
+		L2Spawn flagInstance = null;
 	}
 	
 	private static final String qn = "BanditStrongHold";
@@ -94,7 +94,7 @@ public final class BanditStrongHold extends ClanHallSiegeEngine
 	// Custom values
 	private static final L2CharPosition CENTER = new L2CharPosition(82882,-16280,-1894,0);
 	
-	private FastMap<Integer, ClanData> _data;
+	private TIntObjectHashMap<ClanData> _data = new  TIntObjectHashMap<ClanData>();
 	private L2Clan _winner;
 	
 	public BanditStrongHold(int questId, String name, String descr, final int hallId)
@@ -110,20 +110,12 @@ public final class BanditStrongHold extends ClanHallSiegeEngine
 		addKillId(BLUE_FLAG);
 		addKillId(PURPLE_FLAG);
 		
-		addAttackId(RED_FLAG);
-		addAttackId(YELLOW_FLAG);
-		addAttackId(GREEN_FLAG);
-		addAttackId(BLUE_FLAG);
-		addAttackId(PURPLE_FLAG);
-		
 		addSpawnId(OEL_MAHUM_BERSERKER);
 		addSpawnId(OEL_MAHUM_SCOUT);
 		addSpawnId(OEL_MAHUM_LEADER);
 		addSpawnId(OEL_MAHUM_CLERIC);
 		addSpawnId(OEL_MAHUM_THIEF);
 		
-		_data = new FastMap<Integer, ClanData>();
-		
 		// Load alredy registered attackers
 		loadAttackers();
 		
@@ -155,11 +147,10 @@ public final class BanditStrongHold extends ClanHallSiegeEngine
 				msg.replace("%objectId%", String.valueOf(npc.getObjectId()));
 				msg.replace("%nextSiege%", _hall.getSiegeDate().getTime().toString());
 				player.sendPacket(msg);
+				return null;
 			}
 			else if(clan == null || !player.isClanLeader())
 				html = "agit_oel_mahum_messenger_2.htm";
-			else if(!_hall.isRegistering())
-				html = "agit_oel_mahum_messenger_3.htm";
 			else if((_hall.getOwnerId() > 0 && getAttackers().size() >= 4)
 					|| getAttackers().size() >= 5)
 				html = "agit_oel_mahum_messenger_21.htm";
@@ -175,7 +166,7 @@ public final class BanditStrongHold extends ClanHallSiegeEngine
 					// Register passing the quest
 					if(arg[1].equals("wQuest"))
 					{
-						if(player.destroyItemByItemId("BanditStrongHold Siege", 5009, 1, npc, true)) // Quest passed
+						if(player.destroyItemByItemId("BanditStrongHold Siege", 5009, 1, npc, false)) // Quest passed
 						{
 							registerClan(clan);
 							html = getFlagHtml(_data.get(clan.getClanId()).flag);
@@ -210,10 +201,7 @@ public final class BanditStrongHold extends ClanHallSiegeEngine
 				if(var.length >= 2)
 				{
 					int id = 0;
-					try
-					{
-						id = Integer.parseInt(var[1]);
-					}
+					try { id = Integer.parseInt(var[1]); }
 					catch(Exception e)
 					{
 						_log.warning("BanditStronghold->select_clan_npc->Wrong mahum warrior id: "+var[1]);
@@ -224,6 +212,8 @@ public final class BanditStrongHold extends ClanHallSiegeEngine
 						saveNpc(id, clan.getClanId());
 					}
 				}
+				else
+					_log.warning("BanditStrongHold Siege: Not enough parameters to save clan npc for clan: "+clan.getName());
 			}
 		}
 		// View (and change ? ) the current selected mahum warrior
@@ -265,41 +255,26 @@ public final class BanditStrongHold extends ClanHallSiegeEngine
 		return html;
 	}
 	
-	@Override
-	public String onAttack(L2Npc npc, L2PcInstance attacker, int damage, boolean isPet)
-	{
-		if(_hall.isInSiege())
-		{
-			final int clan = attacker.getClan().getClanId();
-			// Attacking own flag or non-registered players
-			if((_data.containsKey(clan) && npc.getNpcId() == _data.get(clan).flag)
-					|| !_data.containsKey(clan))
-				npc.setCurrentHp(npc.getCurrentHp() + damage);
-		}
-		return null;
-	}
-	
 	@Override
 	public synchronized String onKill(L2Npc npc, L2PcInstance killer, boolean isPet)
 	{
 		if(_hall.isInSiege())
 		{
-			final int id = npc.getNpcId();
-			if(id == RED_FLAG || id == YELLOW_FLAG || id == GREEN_FLAG
-					|| id == BLUE_FLAG || id == PURPLE_FLAG)
+			final int npcId = npc.getNpcId();
+			for(int keys : _data.keys())
+				if(_data.get(keys).flag == npcId)
+					removeParticipant(keys, true);
+			
+			synchronized(this)
 			{
-				final int index = id - 35423;
-				removeParticipant(index, true);
-				
-				synchronized(this)
+				// Siege ends if just 1 flag is alive
+				if(_data.size() == 1)
 				{
-					// Siege ends if just 1 flag is alive
-					if(_data.size() == 1)
-					{
-						_winner = removeParticipant(0, false);
-						cancelSiegeTask();
-						endSiege();
-					}
+					_missionAccomplished = true;
+					_winner = ClanTable.getInstance().getClan(_data.keys()[0]);
+					removeParticipant(_data.keys()[0], false);
+					cancelSiegeTask();
+					endSiege();
 				}
 			}
 		}
@@ -340,22 +315,32 @@ public final class BanditStrongHold extends ClanHallSiegeEngine
 	@Override
 	public void onSiegeStarts()
 	{
-		for(ClanData data : _data.values())
+		for(Object obj : _data.getValues())
 		{
 			try
 			{
-				L2NpcTemplate flagTemplate = null;
-				L2NpcTemplate mahumTemplate = null;
+				ClanData data = (ClanData)obj;
+				
+				L2NpcTemplate flagTemplate = NpcTable.getInstance().getTemplate(data.flag);
+				L2NpcTemplate mahumTemplate = NpcTable.getInstance().getTemplate(data.npc);
 				
-				assert (flagTemplate = NpcTable.getInstance().getTemplate(data.flag)) != null
-						&& (mahumTemplate = NpcTable.getInstance().getTemplate(data.npc)) != null;
+				if(flagTemplate == null)
+				{
+					_log.warning("BanditStrongHoldSiege: Flag L2NpcTemplate["+data.flag+"] does not exist!");
+					continue;
+				}
+				if(mahumTemplate == null)
+				{
+					_log.warning("BanditStrongHoldSiege: Mahum L2NpcTemplate["+data.npc+"] does not exist!");
+					continue;
+				}
 						
 				data.flagInstance = new L2Spawn(flagTemplate);
-				int index = 35423 - data.flag;
+				int index = data.flag - 35423;
 				int[] flagCoords = FLAGS_COORDS[index];		
-				data.flagInstance.setLocx(FLAGS_COORDS[index][0]);
-				data.flagInstance.setLocy(FLAGS_COORDS[index][1]);
-				data.flagInstance.setLocz(FLAGS_COORDS[index][2]);
+				data.flagInstance.setLocx(flagCoords[0]);
+				data.flagInstance.setLocy(flagCoords[1]);
+				data.flagInstance.setLocz(flagCoords[2]);
 				data.flagInstance.setRespawnDelay(10000);
 				data.flagInstance.setAmount(1);
 				data.flagInstance.init();
@@ -371,7 +356,7 @@ public final class BanditStrongHold extends ClanHallSiegeEngine
 				}
 				
 				data.warrior = new L2Spawn(mahumTemplate);
-				int indexx = 35428 - data.npc;
+				int indexx = data.npc - 35428;
 				data.warrior.setLocx(MAHUM_COORDS[indexx][0]);
 				data.warrior.setLocy(MAHUM_COORDS[indexx][1]);
 				data.warrior.setLocz(MAHUM_COORDS[indexx][2]);
@@ -383,6 +368,7 @@ public final class BanditStrongHold extends ClanHallSiegeEngine
 			}
 			catch(Exception e)
 			{
+				endSiege();
 				_log.warning(_hall.getName()+": Problems in siege initialization!");
 				e.printStackTrace();
 			}
@@ -394,15 +380,12 @@ public final class BanditStrongHold extends ClanHallSiegeEngine
 	{
 		if(_data.size() > 0)
 		{
-			for(int clanId : _data.keySet())
+			for(int clanId : _data.keys())
 			{
-				L2Clan clan = ClanTable.getInstance().getClan(clanId);
-				if(clan == null)
-					continue;
-				if(_hall.getOwnerId() == clan.getClanId())
-					removeParticipant(clan, false);
+				if(_hall.getOwnerId() == clanId)
+					removeParticipant(clanId, false);
 				else
-					removeParticipant(clan, true);
+					removeParticipant(clanId, true);
 			}
 		}
 		clearTables();
@@ -416,23 +399,17 @@ public final class BanditStrongHold extends ClanHallSiegeEngine
 		getAttackers().put(clanId, sc);
 		
 		ClanData data = new ClanData();
-		_data.put(clanId, data);
-		data.flag = 35422 + _data.size();
+		data.flag = 35423 + _data.size();
 		data.players.add(clan.getLeaderId());
+		_data.put(clanId, data);
 		
 		saveClan(clanId, data.flag);
 		saveMember(clanId, clan.getLeaderId());
 	}
 	
-	private final L2Clan removeParticipant(int index, boolean teleport)
+	private final void removeParticipant(int clanId, boolean teleport)
 	{
-		final L2Clan clan = (L2Clan)(_data.keySet().toArray()[index]);
-		return removeParticipant(clan, teleport);
-	}
-	
-	private final L2Clan removeParticipant(L2Clan clan, boolean teleport)
-	{
-		ClanData dat = _data.remove(clan);
+		ClanData dat = _data.remove(clanId);
 		
 		if(dat != null)
 		{	
@@ -440,30 +417,30 @@ public final class BanditStrongHold extends ClanHallSiegeEngine
 			if(dat.flagInstance != null)
 			{
 				dat.flagInstance.stopRespawn();
-				dat.flagInstance.getLastSpawn().deleteMe();
+				if(dat.flagInstance.getLastSpawn() != null)
+					dat.flagInstance.getLastSpawn().deleteMe();
 			}
 		
 			if(dat.warrior != null)
 			{
 				// Destroy clan warrior
 				dat.warrior.stopRespawn();
-				dat.warrior.getLastSpawn().deleteMe();
+				if(dat.warrior.getLastSpawn() != null)
+					dat.warrior.getLastSpawn().deleteMe();
 			}
 		
 			dat.players.clear();
+			
+			if(teleport)
+			{
+				// Teleport players outside
+				for(L2PcInstance pc : dat.playersInstance)
+					if(pc != null)
+						pc.teleToLocation(TeleportWhereType.Town);
+			}
+			
+			dat.playersInstance.clear();
 		}
-		
-		if(teleport)
-		{
-			// Teleport players outside
-			for(L2PcInstance pc : dat.playersInstance)
-				if(pc != null)
-					pc.teleToLocation(TeleportWhereType.Town);
-		}
-		
-		dat.playersInstance.clear();
-		
-		return clan;
 	}
 	
 	private String getFlagHtml(int flag)
@@ -624,7 +601,7 @@ public final class BanditStrongHold extends ClanHallSiegeEngine
 		}
 	}
 	
-	private final void saveNpc(int clanId, int npc)
+	private final void saveNpc(int npc, int clanId)
 	{
 		Connection con = null;
 		try

+ 1 - 1
L2J_DataPack_BETA/data/scripts/conquerablehalls/BanditStrongHold/agit_oel_mahum_messenger_1.htm

@@ -1 +1 @@
-<html><head><body>I'm just here to make sure the siege comes off without a hitch. I'll try to stay out of the way. Knock yourselves out!<br><a action="bypass -h Quest BanditStrongHold register_clan wQuest">Register a clan (must be a clan leader)</a><br><a action="bypass -h Quest BanditStrongHold agit_oel_mahum_messenger_11.htm">Select a Clan NPC (must be a clan leader)</a><br><a action="bypass -h Quest BanditStrongHold view_clan_npc">View a Clan NPC (any clan member)</a><br><a action="bypass -h Quest BanditStrongHold register_member">Register as a clan member. (Any clan member)</a><br><br><a action="bypass -h npc_%objectId%_Quest 504_CompetitionfortheBanditStronghold">Quest</a></body></html>
+<html><head><body>I'm just here to make sure the siege comes off without a hitch. I'll try to stay out of the way. Knock yourselves out!<br><a action="bypass -h Quest BanditStrongHold register_clan wQuest">Register a clan (must be a clan leader)</a><br><a action="bypass -h Quest BanditStrongHold agit_oel_mahum_messenger_6.htm">Select a Clan NPC (must be a clan leader)</a><br><a action="bypass -h Quest BanditStrongHold view_clan_npc">View a Clan NPC (any clan member)</a><br><a action="bypass -h Quest BanditStrongHold register_member">Register as a clan member. (Any clan member)</a><br><br><a action="bypass -h npc_%objectId%_Quest 504_CompetitionfortheBanditStronghold">Quest</a></body></html>

+ 1 - 1
L2J_DataPack_BETA/data/scripts/conquerablehalls/BanditStrongHold/agit_oel_mahum_messenger_16.htm

@@ -1 +1 @@
-<html><head><body>
+++Your clan leader has not yet chosen who he will ally himself with! Go and tell him that his decision is required!
+++</body></html>
+<html><head><body>
Your clan leader has not yet chosen who he will ally himself with! Go and tell him that his decision is required!
</body></html>

+ 1 - 1
L2J_DataPack_BETA/data/scripts/conquerablehalls/BanditStrongHold/agit_oel_mahum_messenger_17.htm

@@ -1 +1 @@
-<html><head><body>
+++Ol mahum berserkers live for the most appalling aspects of war. An alliance with them would be quite useful to you. They are superior examples of their kind, but their enthusiasm for battle often prevents their proper healing after injury. They are a challenge to handle but are worth the effort.<br>
+++<a action="bypass -h Quest BanditStrongHold agit_oel_mahum_messenger_6.htm">Select another NPC.</a><br>
+++<a action="bypass -h Quest BanditStrongHold select_clan_npc 35428">Form an alliance.</a>
+++</body></html>
+<html><head><body>
Ol mahum berserkers live for the most appalling aspects of war. An alliance with them would be quite useful to you. They are superior examples of their kind, but their enthusiasm for battle often prevents their proper healing after injury. They are a challenge to handle but are worth the effort.<br>
<a action="bypass -h Quest BanditStrongHold agit_oel_mahum_messenger_6.htm">Select another NPC.</a><br>
<a action="bypass -h Quest BanditStrongHold select_clan_npc 35428">Form an alliance.</a>
</body></html>

+ 1 - 1
L2J_DataPack_BETA/data/scripts/conquerablehalls/BanditStrongHold/agit_oel_mahum_messenger_22.htm

@@ -1 +1 @@
-<html><head><body>
+++Oh, sir, a master such as yourself need not prove himself! Leave such matters to the youngsters! Enjoy the show!
+++</body></html>
+<html><head><body>
Oh, sir, a master such as yourself need not prove himself! Leave such matters to the youngsters! Enjoy the show!
</body></html>

+ 1 - 1
L2J_DataPack_BETA/data/scripts/conquerablehalls/BanditStrongHold/agit_oel_mahum_messenger_23.htm

@@ -1 +1 @@
-<html><head><body>
+++Ol mahum thieves are amusing little fellows. Shorter than the average ol mahum, they are exceptionally lithe. If they think they have the advantage, they will attack a target. But if they feel threatened they will evade direct conflict with the enemy while using a unique strategy to bind his legs.
+++<br>
+++<a action="bypass -h Quest BanditStrongHold agit_oel_mahum_messenger_6.htm">Select another NPC.</a><br>
+++<a action="bypass -h Quest BanditStrongHold select_clan_npc 35432">Form an alliance.</a>
+++</body></html>
+<html><head><body>
Ol mahum thieves are amusing little fellows. Shorter than the average ol mahum, they are exceptionally lithe. If they think they have the advantage, they will attack a target. But if they feel threatened they will evade direct conflict with the enemy while using a unique strategy to bind his legs.
<br>
<a action="bypass -h Quest BanditStrongHold agit_oel_mahum_messenger_6.htm">Select another NPC.</a><br>
<a action="bypass -h Quest BanditStrongHold select_clan_npc 35432">Form an alliance.</a>
</body></html>

+ 1 - 1
L2J_DataPack_BETA/data/scripts/conquerablehalls/BanditStrongHold/agit_oel_mahum_messenger_24.htm

@@ -1 +1 @@
-<html><head><body>
+++What's that, you want to register without qualifying? Well, maybe we can work something out... 200,000 adena might get this conversation started...
+++<br><a action="bypass -h Quest BanditStrongHold register_clan wFee">Pay the adena and register a clan. (clan leader)</a>
+++</body></html>
+<html><head><body>
What's that, you want to register without qualifying? Well, maybe we can work something out... 200,000 adena might get this conversation started...
<br><a action="bypass -h Quest BanditStrongHold register_clan wFee">Pay the adena and register a clan. (clan leader)</a>
</body></html>

+ 1 - 1
L2J_DataPack_BETA/data/scripts/conquerablehalls/BanditStrongHold/agit_oel_mahum_messenger_26.htm

@@ -1 +1 @@
-<html><head><body>
+++So you want to register for free, eh? There is a way... You can take a test if you can't afford the fee...<br>
+++<center>
+++<a action="bypass -h npc_%objectId%_Quest Q504_CompetitionfortheBanditStronghold">"I want to take the test."</a><br>
+++</center>
+++</body></html>
+<html><head><body>
So you want to register for free, eh? There is a way... You can take a test if you can't afford the fee...<br>
<center>
<a action="bypass -h npc_%objectId%_Quest Q504_CompetitionfortheBanditStronghold">"I want to take the test."</a><br>
</center>
</body></html>

+ 21 - 1
L2J_DataPack_BETA/data/scripts/handlers/admincommandhandlers/AdminCHSiege.java

@@ -31,7 +31,8 @@ public final class AdminCHSiege implements IAdminCommandHandler
 		"admin_chsiege_addAttacker",
 		"admin_chsiege_removeAttacker",
 		"admin_chsiege_clearAttackers",
-		"admin_chsiege_listAttackers"
+		"admin_chsiege_listAttackers",
+		"admin_chsiege_forwardSiege"
 	};
 	
 	@Override
@@ -51,6 +52,8 @@ public final class AdminCHSiege implements IAdminCommandHandler
 			activeChar.sendMessage("You have to specify the hall id at least");
 		else if((hall = getHall(split[1], activeChar)) == null)
 			activeChar.sendMessage("Couldnt find he desired siegable hall ("+split[1]+")");
+		else if(hall.getSiege() == null)
+			activeChar.sendMessage("The given hall dont have any attached siege!");
 		else if(split[0].equals(COMMANDS[1]))
 		{
 			if(hall.isInSiege())
@@ -214,6 +217,23 @@ public final class AdminCHSiege implements IAdminCommandHandler
 		}
 		else if(split[0].equals(COMMANDS[7]))
 			activeChar.sendPacket(new SiegeInfo(hall));
+		else if(split[0].equals(COMMANDS[8]))
+		{
+			ClanHallSiegeEngine siegable = hall.getSiege();
+			siegable.cancelSiegeTask();
+			switch(hall.getSiegeStatus())
+			{
+				case REGISTERING:
+					siegable.prepareOwner();
+					break;
+				case WAITING_BATTLE:
+					siegable.startSiege();
+					break;
+				case RUNNING:
+					siegable.endSiege();
+					break;
+			}
+		}
 			
 		sendSiegableHallPage(activeChar, split[1], hall);
 		return false;

+ 2 - 2
L2J_DataPack_BETA/data/scripts/quests/Q504_CompetitionfortheBanditStronghold/Q504_CompetitionfortheBanditStronghold.java

@@ -17,7 +17,7 @@ import com.l2jserver.gameserver.util.Util;
  */
 public final class Q504_CompetitionfortheBanditStronghold extends Quest
 {
-	private static final String qn = "504_CompetitionfortheBanditStronghold";
+	private static final String qn = 	"504_CompetitionfortheBanditStronghold";
 	// Quest reward item
 	private static final int TARLK_AMULET = 4332;
 	private static final int TROPHY_OF_ALLIANCE = 5009;
@@ -50,7 +50,7 @@ public final class Q504_CompetitionfortheBanditStronghold extends Quest
 		
 		if(st == null)
 			result = getNoQuestMsg(player);
-		else if(!BANDIT_STRONGHOLD.isInSiege())
+		else if(!BANDIT_STRONGHOLD.isWaitingBattle())
 		{
 			sendDatePage("azit_messenger_q0504_09.htm", player, npc);
 			result = null;

+ 2 - 1
L2J_DataPack_BETA/dist/sql/game/admin_command_access_rights.sql

@@ -620,4 +620,5 @@ INSERT IGNORE INTO `admin_command_access_rights` VALUES
 ('admin_chsiege_addAttacker', 1, 'false'),
 ('admin_chsiege_removeAttacker', 1, 'false'),
 ('admin_chsiege_listAttackers', 1, 'false'),
-('admin_chsiege_clearAttackers', 1, 'false');
+('admin_chsiege_clearAttackers', 1, 'false'),
+('admin_chsiege_forwardSiege', 1, 'false');