Jump to content

Unique Interlude Event [Peloponnesian War] !!!!!!!!!!!!


Recommended Posts

Posted

Hi bro i have one bug whit this code can help me ?

Here i kill other pp winner in the other team -> http://imageshack.us/f/9/shot00001pa.png/

And in the moment who announce Team winner have this bug -> http://imageshack.us/f/19/shot00002xu.png/

Announce spartan and athenias winners O.o why?

 

I Use this code:

Index: L2jfrozen/java/com/l2jfrozen/gameserver/handler/VoicedCommandHandler.java
===================================================================
--- L2jHfrozen/java/com/l2jfrozen/gameserver/handler/VoicedCommandHandler.java	(revision 189)
+++ L2jfrozen/java/com/l2jfrozen/gameserver/handler/VoicedCommandHandler.java	(working copy)
@@ -35,6 +36,7 @@
import com.l2jfrozen.gameserver.handler.voicedcommandhandlers.OfflineShop;
import com.l2jfrozen.gameserver.handler.voicedcommandhandlers.Online;
+import com.l2jfrozen.gameserver.handler.voicedcommandhandlers.PeloponnesianRegi;
import com.l2jfrozen.gameserver.handler.voicedcommandhandlers.StatsCmd;
import com.l2jfrozen.gameserver.handler.voicedcommandhandlers.TvTCmd;

@@ -88,6 +89,7 @@
	if (Config.DM_COMMAND)
	{
		registerVoicedCommandHandler(new DMCmd());
	}

+		registerVoicedCommandHandler(new PeloponnesianRegi());

	if (Config.L2JMOD_ALLOW_WEDDING)

Index: L2jfrozen/java/com/l2jfrozen/gameserver/handler/admincommandhandlers/AdminReload.java
===================================================================
--- L2jfrozen/java/com/l2jfrozen/gameserver/handler/admincommandhandlers/AdminReload.java	(revision 189)
+++ L2jfrozen/java/com/l2jfrozen/gameserver/handler/admincommandhandlers/AdminReload.java	(working copy)
@@ -36,6 +36,7 @@
import com.l2jfrozen.gameserver.managers.Manager;
import com.l2jfrozen.gameserver.managers.QuestManager;
import com.l2jfrozen.gameserver.model.actor.instance.L2PcInstance;
+import com.l2jfrozen.gameserver.model.entity.event.PeloponnesianWar;
import com.l2jfrozen.gameserver.model.multisell.L2Multisell;
import com.l2jfrozen.gameserver.script.faenor.FaenorScriptEngine

/**
@@ -56,6 +56,7 @@

		if (command.startsWith("admin_reload"))
		{
+			PeloponnesianWar.startevent();
			sendReloadPage(activeChar);
		StringTokenizer st = new StringTokenizer(command);
		st.nextToken();

Index: L2jfrozen/java/com/l2jfrozen/gameserver/handler/voicedcommandhandlers/PeloponnesianRegi.java
===================================================================
--- L2jfrozen/java/com/l2jfrozen/gameserver/handler/voicedcommandhandlers/PeloponnesianRegi.java	(revision 0)
+++ L2jfrozen/java/com/l2jfrozen/gameserver/handler/voicedcommandhandlers/PeloponnesianRegi.java	(revision 0)
@@ -0,0 +1,95 @@
+/*
+ * This program is free software: you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License as published by the Free Software
+ * Foundation, either version 3 of the License, or (at your option) any later
+ * version.
+ * 
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ * 
+ * You should have received a copy of the GNU General Public License along with
+ * this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package com.l2jfrozen.gameserver.handler.voicedcommandhandlers;
+
+import java.io.File;
+
+import com.l2jfrozen.Config;
+import com.l2jfrozen.gameserver.handler.IVoicedCommandHandler;
+import com.l2jfrozen.gameserver.model.actor.instance.L2PcInstance;
+import com.l2jfrozen.gameserver.model.entity.event.PeloponnesianWar;
+import com.l2jfrozen.gameserver.network.serverpackets.NpcHtmlMessage;
+
+/**
+ * @author Boorinio
+ */
+public class PeloponnesianRegi implements IVoicedCommandHandler
+{
+	private static final String[] VOICED_COMMANDS =
+	{
+	"join", "leave"
+	};
+	
+	@Override
+	public boolean useVoicedCommand(String command, L2PcInstance activeChar, String target)
+	{
+		if(PeloponnesianWar.PeloRegi)
+		{
+			if (command.startsWith(VOICED_COMMANDS[0])&& isEligible(activeChar))
+			{
+				activeChar.inPeloponnesianWar =  true;
+				activeChar.sendMessage("You are now registered to PeloponnesianWar event!");
+				String Capture_Path = "data/html/TutorialPelo.htm";
+				File mainText = new File(Config.DATAPACK_ROOT, Capture_Path);
+				NpcHtmlMessage html = new NpcHtmlMessage(1);
+				html.setFile(Capture_Path);
+				activeChar.sendPacket(html);
+			}
+			if(command.startsWith(VOICED_COMMANDS[1])&&activeChar.inPeloponnesianWar)
+			{
+				activeChar.inPeloponnesianWar =  false;
+				activeChar.sendMessage("You are now unregistered.");
+			}
+		}
+		else
+		{
+			if (command.startsWith(VOICED_COMMANDS[0])||(command.startsWith(VOICED_COMMANDS[1])))
+				{
+				  activeChar.sendMessage("CaptureThem registrations are inactive.");
+				}
+		}
+		return true;
+	}
+	public boolean isEligible(L2PcInstance player)
+	{
+		if(player.inPeloponnesianWar)
+		{
+			player.sendMessage("You are already Registered");
+			return false;
+		}
+		if(player.getLevel()<76)
+		{
+			player.sendMessage("You are low level");
+			return false;
+		}
+		if(player.isInJail())
+		{
+			player.sendMessage("You are in jail...daah");
+			return false;
+		}
+		if(player.isInOlympiadMode())
+		{
+			player.sendMessage("You are in olympiad mode");
+			return false;
+		}
+		return true;
+	}
+	
+	@Override
+	public String[] getVoicedCommandList()
+	{
+		return VOICED_COMMANDS;
+	}
+}
\ No newline at end of file

Index: L2jfrozen/java/com/l2jfrozen/gameserver/model/actor/instance/L2PcInstance.java
===================================================================
--- L2jfrozen/java/com/l2jfrozen/gameserver/model/actor/instance/L2PcInstance.java	(revision 189)
+++ L2jfrozen/java/com/l2jfrozen/gameserver/model/actor/instance/L2PcInstance.java	(working copy)
@@ -144,6 +144,7 @@
import com.l2jfrozen.gameserver.model.entity.L2Rebirth;
import com.l2jfrozen.gameserver.model.entity.event.CTF;
import com.l2jfrozen.gameserver.model.entity.event.DM;
+import com.l2jfrozen.gameserver.model.entity.event.PeloponnesianWar;
import com.l2jfrozen.gameserver.model.entity.event.L2Event;
import com.l2jfrozen.gameserver.model.entity.event.TvT;
import com.l2jfrozen.gameserver.model.entity.event.VIP;
@@ -249,6 +249,11 @@

public final class L2PcInstance extends L2PlayableInstance
{
+	public boolean inPeloponnesianWar = false;
+	public boolean isAthenian=false;
+	public boolean isDeadAthenian=false;
+	public boolean isSpartan=false;
+	public boolean isDeadSpartan=false;

/** The Constant RESTORE_SKILLS_FOR_CHAR. */
private static final String RESTORE_SKILLS_FOR_CHAR = "SELECT skill_id,skill_level FROM character_skills WHERE char_obj_id=? AND class_index=?";

@@ -7608,6 +7609,22 @@
			{
				pk.kills.add(getName());
			}
+			if(inPeloponnesianWar)
+			{
+				inPeloponnesianWar = false;
+				
+				if(isAthenian)
+				{
+					isDeadAthenian=true;
+				}
+				if(isSpartan)
+				{
+					isDeadSpartan=true;
+				}
+				isAthenian=false;
+				isSpartan=false;
+				teleToLocation(82698, 148638,-3473);
+			}
			if(_inEventTvT && pk._inEventTvT)
			{
				if(TvT.is_teleport() || TvT.is_started())

Index: L2jfrozen/java/com/l2jfrozen/gameserver/model/entity/engines/PeloponnesianWar.java
===================================================================
--- L2jfrozen/java/com/l2jfrozen/gameserver/model/entity/engines/PeloponnesianWar.java	(revision 0)
+++ L2jfrozen/java/com/l2jfrozen/gameserver/model/entity/engines/PeloponnesianWar.java	(revision 0)
@@ -0,0 +1,285 @@
+package com.l2jfrozen.gameserver.model.entity.engines;
+
+import java.util.List;
+
+import javolution.util.FastList;
+import javolution.util.FastSet;
+
+import com.l2jfrozen.gameserver.model.entity.Announcements;
+import com.l2jfrozen.gameserver.datatables.sql.NpcTable;
+import com.l2jfrozen.gameserver.model.spawn.L2Spawn;
+import com.l2jfrozen.gameserver.model.L2World;
+import com.l2jfrozen.gameserver.model.actor.instance.L2NpcInstance;
+import com.l2jfrozen.gameserver.model.actor.instance.L2PcInstance;
+import com.l2jfrozen.gameserver.templates.L2NpcTemplate;
+
+/**
+ * @author Boorinio
+ */
+public class PeloponnesianWar
+{
+	private static boolean alaksokolies=true;
+	public static boolean PeloRunning;
+	private static int i,countA,countS;
+	public static boolean PeloRegi;
+	private static List<L2PcInstance> _participants = new FastList<L2PcInstance>();
+	private static List<L2PcInstance> _athenians = new FastList<L2PcInstance>();
+	private static List<L2PcInstance> _spartans = new FastList<L2PcInstance>();
+	private static FastSet<L2NpcInstance> _protectors = new FastSet<L2NpcInstance>();
+	private static int athenianx=72923;
+	private static int atheniany=142764;
+	private static int athenianz=-3773;
+	private static int spartanx=-87891;
+	private static int spartany=142198;
+	private static int spartanz=-3646;
+	private static int protectors=30627;
+	private static int [] protectorsx  =
+			{
+			73019,72986,72958,72921,72896,72975,73009,73044,73075,73095,-87893,-87921,-87944,-87971,-87992,-88017,-87931,-87904,-87872,-87849,-87821,
+			};
+	private static int [] protectorsy  =
+		{
+		143260,143260,143265,143257,143258,142276,142272,142275,142267,142262,142715,142717,142723,142719,142718,142717,141731,141738,141731,141730,141730,
+		};
+	private static int [] protectorsz  =
+		{
+		-3789,-3773,-3773,-3773,-3773,-3773,-3773,-3773,-3798,-3773,-3672,-3646,-3672,-3646,-3646,-3646,-3646,-3646,-3646,-3646,-3646,
+		};
+	public static void startevent()
+	
+	{
+		PeloRunning=true;
+		PeloRegi=true;
+		Announcements.getInstance().announceToAll("Peloponnesian Event has Started!");
+		Announcements.getInstance().announceToAll("Type .join to enter or .leave to leave!");
+		Announcements.getInstance().announceToAll("You have 5 minutes to register!");
+		waitSecs(300);
+		Announcements.getInstance().announceToAll("Registrations closed!");
+		PeloRegi=false;
+		for(L2PcInstance player: L2World.getInstance().getAllPlayers() )
+		{
+			if(player.inPeloponnesianWar)
+			{
+				_participants.add(player);
+				if(alaksokolies)
+				{
+					_spartans.add(player);
+					player.isSpartan = true;
+					player.setTitle("Spartan");
+					player.getAppearance().setNameColor(0x0000FF);
+					player.broadcastUserInfo();
+					alaksokolies = false;
+				}
+				else
+				{
+					_athenians.add(player);
+					player.isAthenian=true;
+					player.setTitle("Athenian");
+					player.getAppearance().setNameColor(0xFF0000);
+					player.broadcastUserInfo();
+					alaksokolies = true;
+				}
+				
+			}
+		}
+		spawnProtectors();
+		teleportplayers();
+		Announcements.getInstance().announceToAll("Civil War round started!");
+		Announcements.getInstance().announceToAll("You have 3 minutes the one who survive will face the opponent race!!");
+		waitSecs(180);
+		for(L2PcInstance finals:_athenians)
+		{
+			if(finals.isAthenian)
+				countA++;
+		}
+		for(L2PcInstance finals:_spartans)
+		{
+			if(finals.isSpartan)
+				countS++;
+		}
+		if(countA>1)
+		{
+			Announcements.getInstance().announceToAll("Athenians cheated and tried to send more than two players Spartans won!");
+			reward(false);
+		}
+		else if(countS>1)
+		{
+			Announcements.getInstance().announceToAll("Spartans cheated and tried to send more than two players Athenians won!");
+			reward(true);
+		}
+		else
+		{
+		finalround();
+		Announcements.getInstance().announceToAll("Spartan and Athenian representative have 2 minutes to face each other");
+		waitSecs(120);
+		checkwhowon();
+		}
+		cleanthemess();
+	}
+	public static void cleanthemess()
+	{
+		for(L2PcInstance participant: _participants)
+		{
+			if(participant.inPeloponnesianWar||participant.isAthenian||participant.isSpartan||participant.isDeadAthenian||participant.isDeadAthenian)
+			{
+				participant.setTitle("");
+				participant.getAppearance().setNameColor(0xFFFFFF);
+				participant.broadcastUserInfo();
+				participant.teleToLocation(82698, 148638,-3473);
+			}
+			participant.isAthenian=false;
+			participant.isSpartan=false;
+			participant.isDeadAthenian=false;
+			participant.isDeadSpartan=false;
+		}
+		for(L2NpcInstance protectorss: _protectors)
+		{
+			protectorss.deleteMe();
+		}
+		PeloRunning=false;
+		_protectors.clear();
+		_participants.clear();
+		_athenians.clear();
+		_spartans.clear();
+	}
+	private static void reward(boolean Athenians)
+	{
+		if(Athenians)
+		{
+			for(L2PcInstance participant:_participants)
+			{
+				if(participant.isAthenian||participant.isDeadAthenian)
+				{
+					participant.addItem("Reward", 3470,1, participant, true);
+				}
+			}
+		}
+		else
+		{
+			for(L2PcInstance participant:_participants)
+			{
+				if(participant.isSpartan||participant.isDeadSpartan)
+				{
+					participant.addItem("Reward", 3470,1, participant, true);
+				}
+			}
+		}
+	}
+	public static void checkwhowon()
+	{
+		for(L2PcInstance winner : _participants)
+		{
+			if(winner.inPeloponnesianWar&&winner.isAthenian)
+			{
+				Announcements.getInstance().announceToAll("Athenians won!");
+				reward(true);
+			}
+			else if(winner.inPeloponnesianWar&&winner.isSpartan)
+			{
+				Announcements.getInstance().announceToAll("Spartans won!");
+				reward(false);
+			}
+			else
+				Announcements.getInstance().announceToAll("No one won blame your representatives!");
+		}
+	}
+	public static void finalround()
+	{
+		for(L2PcInstance athenian : _athenians)
+		{
+			if(athenian.isAthenian)
+			{
+			athenian.sendMessage("You are the best athenian you will face the best spartan");
+			athenian.setTitle("FinalAthenian");
+			athenian.setCurrentHp(athenian.getMaxHp());
+			athenian.setCurrentMp(athenian.getMaxMp());
+			athenian.setCurrentCp(athenian.getMaxCp());
+			athenian.broadcastUserInfo();
+			athenian.teleToLocation(-21754,-20955,-3026);
+			}
+		}
+		for(L2PcInstance spartan : _spartans)
+		{
+			if(spartan.isSpartan)
+			{
+			spartan.sendMessage("You are the best spartan you will face the best athenian");
+			spartan.setTitle("FinalSpartan");
+			spartan.setCurrentHp(spartan.getMaxHp());
+			spartan.setCurrentMp(spartan.getMaxMp());
+			spartan.setCurrentCp(spartan.getMaxCp());
+			spartan.broadcastUserInfo();
+			spartan.teleToLocation(-19821,-20988,-3026);
+			}
+		}
+	}
+	public static void teleportplayers()
+	{
+		for(L2PcInstance player: _participants)
+		{
+			if(player.isAthenian)
+			{
+				player.teleToLocation(athenianx,atheniany, athenianz);
+			}
+			else
+			{
+				player.teleToLocation(spartanx,spartany,spartanz);
+			}
+		}
+	}
+	public static void spawnProtectors()
+	{
+		L2NpcInstance protector = null;
+		for(i=0;i<21;i++)
+		{
+			 protector = addSpawn(protectors,protectorsx[i],protectorsy[i],protectorsz[i]);
+			_protectors.add(protector);
+		}
+	}
+	public static void RemoveAthenian(String name)
+	{
+		_athenians.remove(name);
+		
+	}
+	public static void RemoveSpartan(String name)
+	{
+		_spartans.remove(name);
+	}
+	public static void waitSecs(int i)
+	{
+	 try
+	 {
+	  Thread.sleep(i * 1000);
+	 }
+	 catch (InterruptedException ie)
+	 {
+	  ie.printStackTrace();
+	 }
+	}
+	private static L2NpcInstance addSpawn(int npcId, int x, int y, int z)
+	{
+	        L2NpcInstance result = null;
+	        try
+	        {
+	                L2NpcTemplate template = NpcTable.getInstance().getTemplate(npcId);
+	                if (template != null)
+	                {
+	                        L2Spawn spawn = new L2Spawn(template);
+	                        spawn.setInstanceId(0);
+	                        spawn.setHeading(1);
+	                        spawn.setLocx(x);
+	                        spawn.setLocy(y);
+	                        spawn.setLocz(z);
+	                        spawn.stopRespawn();
+	                        result = spawn.spawnOne();
+	                        return result;
+	                }
+	        }
+	        catch (Exception e1)
+	        {
+	        }       
+	        return null;
+	}
+
+		
+		
+}

Index: L2JHellasD/data/html/TutorialPelo.htm
===================================================================
--- L2JHellasD/data/html/TutorialPelo.htm	(revision 0)
+++ L2JHellasD/data/html/TutorialPelo.htm	(revision 0)
@@ -0,0 +1,8 @@
+<html><title>Peloponnesian War</title><body>Jail:<br>
+How this works:<br>
+There are 2 teams.Athenians and Spartans.
+Once you get with your team in an arena<br>
+you will fight each other,the one that survives<br>
+ will fight the other race's survivor<br>
+ The representative that wins gets<br> rewards for everybody in his team!
+</body></html>
\ No newline at end of file

 

For jfrozen Have one idea how fix this bug?

Yeah you probably missed the l2pcinstance in dodie method that removes the dead athenian form the game (or the spartan) but it was too buggy anyways i will share zodiac engine here soon with +1 event so you can copy the new code from there!

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.




×
×
  • Create New...