Jump to content
  • 0

Question

4 answers to this question

Recommended Posts

  • 0
Posted (edited)

Its shared already.

i cant find it ...so i ask if somebody got it share it with me

Edited by aris96
  • 0
Posted

i cant find it ...so i ask if somebody got it share it with me

### Eclipse Workspace Patch 1.0
#P gameserver_chaos_86
Index: java/net/sf/l2j/gameserver/network/clientpackets/Logout.java
===================================================================
--- java/net/sf/l2j/gameserver/network/clientpackets/Logout.java	(revision 86)
+++ java/net/sf/l2j/gameserver/network/clientpackets/Logout.java	(working copy)
@@ -46,6 +46,12 @@
 	protected void runImpl()
 	{
 		final L2PcInstance player = getClient().getActiveChar();
+		EnterWorld world = new EnterWorld();
+				
+		if (world._onlineplayers.contains(player) && player!=null)
+		{
+			world._onlineplayers.remove(player);
+		}
 
 		if (player == null)
 			return;
Index: java/net/sf/l2j/gameserver/handler/admincommandhandlers/AdminChaos.java
===================================================================
--- java/net/sf/l2j/gameserver/handler/admincommandhandlers/AdminChaos.java	(revision 0)
+++ java/net/sf/l2j/gameserver/handler/admincommandhandlers/AdminChaos.java	(revision 0)
@@ -0,0 +1,89 @@
+/* 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 2, 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, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ *
+ * http://www.gnu.org/copyleft/gpl.html
+ */
+package net.sf.l2j.gameserver.handler.admincommandhandlers;
+
+import net.sf.l2j.gameserver.cache.HtmCache;
+import net.sf.l2j.gameserver.handler.IAdminCommandHandler;
+import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
+import net.sf.l2j.gameserver.model.entity.ChaosEvent;
+import net.sf.l2j.gameserver.network.clientpackets.EnterWorld;
+import net.sf.l2j.gameserver.network.serverpackets.NpcHtmlMessage;
+
+/**
+ *
+ * @author  Anarchy
+ */
+public class AdminChaos implements IAdminCommandHandler
+{
+	private static final String[] ADMIN_COMMANDS = { "admin_startchaos", "admin_endchaos", "admin_warnchaos" };
+	
+	public boolean useAdminCommand(String command, L2PcInstance activeChar)
+	{
+		ChaosEvent chaos = new ChaosEvent();
+		
+		if (command.equals("admin_warnchaos"))
+		{
+			if (chaos._isChaosActive)
+			{
+				activeChar.sendMessage("You can only warn the players if Chaos Event isn't active.");
+				return false;
+			}
+			
+			EnterWorld world = new EnterWorld();
+			
+			world.warnAllPlayers();
+			
+			return true;
+		}
+		if (command.equals("admin_startchaos"))
+		{
+			if(!chaos._isChaosActive)
+			{
+				chaos.startChaos();
+				activeChar.sendMessage("You have succesfully started Chaos Event. Press //endchaos to stop it.");
+				return true;
+			}
+			else
+			{
+				activeChar.sendMessage("Chaos Event is already active.");
+				return false;
+			}
+		}
+		if (command.equals("admin_endchaos"))
+		{
+			if(chaos._isChaosActive)
+			{
+				chaos.stopChaos();
+				activeChar.sendMessage("You have succesfully stopped Chaos Event.");
+				return true;
+			}
+			else
+			{
+				activeChar.sendMessage("Chaos Event is not active.");
+				return false;
+			}
+		}
+
+		return true;
+	}
+	
+	public String[] getAdminCommandList() 
+	{
+		return ADMIN_COMMANDS;
+	}
+}
Index: java/net/sf/l2j/gameserver/handler/AdminCommandHandler.java
===================================================================
--- java/net/sf/l2j/gameserver/handler/AdminCommandHandler.java	(revision 86)
+++ java/net/sf/l2j/gameserver/handler/AdminCommandHandler.java	(working copy)
@@ -70,6 +70,7 @@
 import net.sf.l2j.gameserver.handler.admincommandhandlers.AdminTest;
 import net.sf.l2j.gameserver.handler.admincommandhandlers.AdminUnblockIp;
 import net.sf.l2j.gameserver.handler.admincommandhandlers.AdminZone;
+import net.sf.l2j.gameserver.handler.admincommandhandlers.AdminChaos;
 
 public class AdminCommandHandler
 {
@@ -135,6 +136,7 @@
         registerAdminCommandHandler(new AdminTest());
         registerAdminCommandHandler(new AdminUnblockIp());
         registerAdminCommandHandler(new AdminZone());
+        registerAdminCommandHandler(new AdminChaos());
 	}
 	
 	public void registerAdminCommandHandler(IAdminCommandHandler handler)
Index: java/net/sf/l2j/gameserver/network/clientpackets/EnterWorld.java
===================================================================
--- java/net/sf/l2j/gameserver/network/clientpackets/EnterWorld.java	(revision 86)
+++ java/net/sf/l2j/gameserver/network/clientpackets/EnterWorld.java	(working copy)
@@ -18,6 +18,7 @@
  */
 package net.sf.l2j.gameserver.network.clientpackets;
 
+import java.util.Vector;
 import java.util.logging.Logger;
 
 import net.sf.l2j.Config;
@@ -72,6 +73,7 @@
 {
 	private static final String _C__03_ENTERWORLD = "[C] 03 EnterWorld";
 	private static Logger _log = Logger.getLogger(EnterWorld.class.getName());
+	public static Vector<L2PcInstance> _onlineplayers = new Vector<L2PcInstance>();
 
 	public TaskPriority getPriority() { return TaskPriority.PR_URGENT; }
 
@@ -86,6 +88,8 @@
 	{
 		L2PcInstance activeChar = getClient().getActiveChar();
 
+		_onlineplayers.add(activeChar);
+				
 		if (activeChar == null)
 		{
 			_log.warning("EnterWorld failed! activeChar is null...");
@@ -316,6 +320,19 @@
 			}
 		}
 	}
+	
+	public void warnAllPlayers()
+	{
+		for (L2PcInstance player : _onlineplayers)
+		{
+			String file = "data/html/chaos/warning.htm";
+			String html = HtmCache.getInstance().getHtm(file);
+			NpcHtmlMessage warning = new NpcHtmlMessage(1);
+			warning.setHtml(html);
+			
+			player.sendPacket(warning);
+		}
+	}
 
 	@Override
 	public String getType()
Index: java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java
===================================================================
--- java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java	(revision 86)
+++ java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java	(working copy)
@@ -122,6 +122,7 @@
 import net.sf.l2j.gameserver.model.base.Race;
 import net.sf.l2j.gameserver.model.base.SubClass;
 import net.sf.l2j.gameserver.model.entity.Castle;
+import net.sf.l2j.gameserver.model.entity.ChaosEvent;
 import net.sf.l2j.gameserver.model.entity.Duel;
 import net.sf.l2j.gameserver.model.entity.Hero;
 import net.sf.l2j.gameserver.model.entity.Siege;
@@ -216,6 +217,10 @@
  */
 public final class L2PcInstance extends L2Playable
 {	
+	// Chaos Event.
+	public int _chaosKills;
+	public boolean _inChaosEvent = false;
+
 	// Character Skill SQL String Definitions:
 	private static final String RESTORE_SKILLS_FOR_CHAR = "SELECT skill_id,skill_level FROM character_skills WHERE char_obj_id=? AND class_index=?";
 	private static final String ADD_NEW_SKILL = "INSERT INTO character_skills (char_obj_id,skill_id,skill_level,class_index) VALUES (?,?,?,?)";
@@ -4689,6 +4694,7 @@
 		if (!(target instanceof L2Playable)) return;
 		
 		L2PcInstance targetPlayer = target.getActingPlayer();
+		ChaosEvent chaos = new ChaosEvent();
 
 		if (targetPlayer == null) return;                                          // Target player is null
 		if (targetPlayer == this) return;                                          // Target player is self
@@ -4707,9 +4713,14 @@
 			return;
 
         // Check if it's pvp
-		if ((checkIfPvP(target) && targetPlayer.getPvpFlag() != 0) 
-				|| (isInsideZone(ZONE_PVP) && targetPlayer.isInsideZone(ZONE_PVP)))
+		if ((checkIfPvP(target) && targetPlayer.getPvpFlag() != 0) || (isInsideZone(ZONE_PVP) && targetPlayer.isInsideZone(ZONE_PVP)))
+		{
             increasePvpKills();
+            if (_inChaosEvent && targetPlayer._inChaosEvent)
+            {
+            	_chaosKills++;
+            }
+		}
 		// Target player doesn't have pvp flag set
 		else
 		{
@@ -4722,6 +4733,10 @@
 			{
 				// 'Both way war' -> 'PvP Kill'
 				increasePvpKills();
+				if (_inChaosEvent && targetPlayer._inChaosEvent)
+				{
+					_chaosKills++;
+				}
 				return;
 			}
 
@@ -4729,10 +4744,23 @@
             if (targetPlayer.getKarma() > 0)
 			{
 				if (Config.KARMA_AWARD_PK_KILL)
+				{
                     increasePvpKills();
+                    if (_inChaosEvent && targetPlayer._inChaosEvent)
+                    {
+                    	_chaosKills++;
+                    }
+				}
 			}
-			else if (targetPlayer.getPvpFlag() == 0)
-                increasePkKillsAndKarma(targetPlayer.getLevel());
+            else if (targetPlayer.getPvpFlag() == 0 && !(_inChaosEvent && _inChaosEvent(targetPlayer)))
+            {
+            	increasePkKillsAndKarma(targetPlayer.getLevel());
+            }
+                        
+            if (targetPlayer.getPvpFlag() == 0 && (_inChaosEvent && targetPlayer._inChaosEvent))
+            {
+                _chaosKills++;
+            }
 		}
 	}
 
@@ -4740,6 +4768,11 @@
      * Increase the pvp kills count and send the info to the player
      *
      */
+	public boolean _inChaosEvent(L2Character target)
+	{
+		L2PcInstance targetPlayer = target.getActingPlayer();
+		return targetPlayer._inChaosEvent;
+	}
     public void increasePvpKills()
     {
         // Add karma to attacker and increase its PK counter
@@ -9343,6 +9376,12 @@
 			if (!DimensionalRiftManager.getInstance().checkIfInPeaceZone(getX(), getY(), getZ()))
 				getParty().getDimensionalRift().memberRessurected(this);
 		}
+				
+		ChaosEvent chaos = new ChaosEvent();
+		if (_inChaosEvent)
+		{
+			chaos.addSuperHaste(this);
+		}
 	}
 
 	@Override
Index: java/net/sf/l2j/gameserver/handler/IVoicedCommandHandler.java
===================================================================
--- java/net/sf/l2j/gameserver/handler/IVoicedCommandHandler.java	(revision 0)
+++ java/net/sf/l2j/gameserver/handler/IVoicedCommandHandler.java	(revision 0)
@@ -0,0 +1,43 @@
+/*
+ * 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 2, 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, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ *
+ * http://www.gnu.org/copyleft/gpl.html
+ */
+package net.sf.l2j.gameserver.handler;
+
+import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
+
+/**
+ * This class ...
+ *
+ * @version $Revision: 1.1.4.2 $ $Date: 2005/03/27 15:30:09 $
+ */
+public interface IVoicedCommandHandler
+{
+	/**
+	 * this is the worker method that is called when someone uses an admin command.
+	 * @param activeChar
+	 * @param command
+	 * @return command success
+	 */
+	public boolean useVoicedCommand(String command, L2PcInstance activeChar, String target);
+
+	/**
+	 * this method is called at initialization to register all the item ids automatically
+	 * @return all known itemIds
+	 */
+	public String[] getVoicedCommandList();
+}
Index: java/net/sf/l2j/gameserver/handler/voicedcommandhandlers/Chaos.java
===================================================================
--- java/net/sf/l2j/gameserver/handler/voicedcommandhandlers/Chaos.java	(revision 0)
+++ java/net/sf/l2j/gameserver/handler/voicedcommandhandlers/Chaos.java	(revision 0)
@@ -0,0 +1,68 @@
+/* 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 2, 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, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ *
+ * http://www.gnu.org/copyleft/gpl.html
+ */
+package net.sf.l2j.gameserver.handler.voicedcommandhandlers;
+
+import net.sf.l2j.gameserver.handler.IVoicedCommandHandler;
+import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
+import net.sf.l2j.gameserver.model.entity.ChaosEvent;
+
+/**
+ *
+ * @author  Anarchy
+ */
+public class Chaos implements IVoicedCommandHandler
+{
+    private static final String[] VOICED_COMMANDS = { "joinchaos", "leavechaos" };
+    
+	public boolean useVoicedCommand(String command, L2PcInstance activeChar, String target)
+	{
+		ChaosEvent chaos = new ChaosEvent();
+		if (command.startsWith("joinchaos"))
+		{
+			if (chaos._isChaosActive)
+			{
+				chaos.registerToChaos(activeChar);
+				return true;
+			}
+			else
+			{
+				activeChar.sendMessage("Chaos Event is not currently active.");
+				return false;
+			}
+		}
+		if (command.startsWith("leavechaos"))
+		{
+			if (chaos._isChaosActive)
+			{
+				chaos.removeFromChaos(activeChar);
+				return true;
+			}
+			else
+			{
+				activeChar.sendMessage("Chaos Event is not currently active.");
+				return false;
+			}
+		}
+		return true;
+	}
+	
+	public String[] getVoicedCommandList()
+	{
+		return VOICED_COMMANDS;
+	}	
+}
Index: java/net/sf/l2j/gameserver/handler/chathandlers/ChatAll.java
===================================================================
--- java/net/sf/l2j/gameserver/handler/chathandlers/ChatAll.java	(revision 86)
+++ java/net/sf/l2j/gameserver/handler/chathandlers/ChatAll.java	(working copy)
@@ -15,8 +15,13 @@
 package net.sf.l2j.gameserver.handler.chathandlers;
 
 import java.util.Collection;
+import java.util.StringTokenizer;
+import java.util.logging.Logger;
 
+import net.sf.l2j.Config;
 import net.sf.l2j.gameserver.handler.IChatHandler;
+import net.sf.l2j.gameserver.handler.IVoicedCommandHandler;
+import net.sf.l2j.gameserver.handler.VoicedCommandHandler;
 import net.sf.l2j.gameserver.model.BlockList;
 import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
 import net.sf.l2j.gameserver.network.serverpackets.CreatureSay;
@@ -29,6 +34,7 @@
 public class ChatAll implements IChatHandler
 {
 	private static final int[] COMMAND_IDS = { 0 };
+	private static Logger _log = Logger.getLogger(ChatAll.class.getName());
 
 	/**
 	 * Handle chat type 'all'
@@ -36,16 +42,53 @@
 	 */
 	public void handleChat(int type, L2PcInstance activeChar, String params, String text)
 	{
-		CreatureSay cs = new CreatureSay(activeChar.getObjectId(), type, activeChar.getName(), text);
-		Collection<L2PcInstance> plrs = activeChar.getKnownList().getKnownPlayers().values();
-
-		for (L2PcInstance player : plrs)
+		boolean vcd_used = false;
+		if (text.startsWith("."))
 		{
-			if (player != null && activeChar.isInsideRadius(player, 1250, false, true) && !BlockList.isBlocked(player, activeChar))
-				player.sendPacket(cs);
-		}
+			StringTokenizer st = new StringTokenizer(text);
+			IVoicedCommandHandler vch;
+			String command = "";
 			
-		activeChar.sendPacket(cs);
+							if (st.countTokens() > 1)
+							{
+								command = st.nextToken().substring(1);
+								params = text.substring(command.length() + 2);
+								vch = VoicedCommandHandler.getInstance().getVoicedCommandHandler(command);
+							}
+							else
+							{
+								command = text.substring(1);
+								if (Config.DEBUG)
+									_log.info("Command: " + command);
+								vch = VoicedCommandHandler.getInstance().getVoicedCommandHandler(command);
+							}
+							
+							if (vch != null)
+							{
+								vch.useVoicedCommand(command, activeChar, params);
+								vcd_used = true;
+							}
+							else
+							{
+								if (Config.DEBUG)
+									_log.warning("No handler registered for bypass '" + command + "'");
+								vcd_used = false;
+							}
+						}
+						
+						if (!vcd_used)
+						{
+							CreatureSay cs = new CreatureSay(activeChar.getObjectId(), type, activeChar.getName(), text);
+							Collection<L2PcInstance> plrs = activeChar.getKnownList().getKnownPlayers().values();
+				
+							for (L2PcInstance player : plrs)
+							{
+								if (player != null && activeChar.isInsideRadius(player, 1250, false, true) && !BlockList.isBlocked(player, activeChar))
+									player.sendPacket(cs);
+							}
+							
+							activeChar.sendPacket(cs);
+						}
 	}
 
 	/**
Index: java/net/sf/l2j/gameserver/GameServer.java
===================================================================
--- java/net/sf/l2j/gameserver/GameServer.java	(revision 86)
+++ java/net/sf/l2j/gameserver/GameServer.java	(working copy)
@@ -68,6 +68,7 @@
 import net.sf.l2j.gameserver.handler.ItemHandler;
 import net.sf.l2j.gameserver.handler.SkillHandler;
 import net.sf.l2j.gameserver.handler.UserCommandHandler;
+import net.sf.l2j.gameserver.handler.VoicedCommandHandler; 
 import net.sf.l2j.gameserver.idfactory.IdFactory;
 import net.sf.l2j.gameserver.instancemanager.AuctionManager;
 import net.sf.l2j.gameserver.instancemanager.BoatManager;
@@ -242,6 +243,7 @@
 		_log.config("ItemHandler: Loaded " + ItemHandler.getInstance().size() + " handlers.");
         _log.config("SkillHandler: Loaded " + SkillHandler.getInstance().size() + " handlers.");
         _log.config("UserCommandHandler: Loaded " + UserCommandHandler.getInstance().size() + " handlers.");
+        _log.config("VoicedCommandHandler: Loaded " + VoicedCommandHandler.getInstance().size() + " handlers.");
 						
 		if (Config.ALLOW_WEDDING)
 			CoupleManager.getInstance();
Index: java/net/sf/l2j/gameserver/handler/VoicedCommandHandler.java
===================================================================
--- java/net/sf/l2j/gameserver/handler/VoicedCommandHandler.java	(revision 0)
+++ java/net/sf/l2j/gameserver/handler/VoicedCommandHandler.java	(revision 0)
@@ -0,0 +1,78 @@
+/*
+ * 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 2, 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, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ *
+ * http://www.gnu.org/copyleft/gpl.html
+ */
+package net.sf.l2j.gameserver.handler;
+
+import java.util.Map;
+import java.util.logging.Logger;
+
+import javolution.util.FastMap;
+import net.sf.l2j.Config;
+import net.sf.l2j.gameserver.handler.admincommandhandlers.AdminChaos;
+import net.sf.l2j.gameserver.handler.voicedcommandhandlers.*;
+
+public class VoicedCommandHandler
+{
+	private static Logger _log = Logger.getLogger(ItemHandler.class.getName());
+
+	private static VoicedCommandHandler 		_instance;
+	private Map<String, IVoicedCommandHandler> 	_datatable;
+
+	public static VoicedCommandHandler getInstance()
+	{
+		if (_instance == null)
+			_instance = new VoicedCommandHandler();
+		
+		return _instance;
+	}
+
+	private VoicedCommandHandler()
+	{
+		_datatable = new FastMap<String, IVoicedCommandHandler>();
+		
+        registerVoicedCommandHandler(new Chaos());
+	}
+
+	public void registerVoicedCommandHandler(IVoicedCommandHandler handler)
+	{
+		String[] ids = handler.getVoicedCommandList();
+		for (int i = 0; i < ids.length; i++)
+		{
+			if (Config.DEBUG) _log.fine("Adding handler for command "+ids[i]);
+			_datatable.put(ids[i], handler);
+		}
+	}
+
+	public IVoicedCommandHandler getVoicedCommandHandler(String voicedCommand)
+	{
+		String command = voicedCommand;
+		
+		if (voicedCommand.indexOf(" ") != -1)
+			command = voicedCommand.substring(0, voicedCommand.indexOf(" "));
+		
+		if (Config.DEBUG)
+			_log.fine("getting handler for command: "+command+" -> "+(_datatable.get(command) != null));
+		
+		return _datatable.get(command);
+	}
+
+    public int size()
+    {
+        return _datatable.size();
+    }
+}
\ No newline at end of file
Index: java/net/sf/l2j/gameserver/model/entity/ChaosEvent.java
===================================================================
--- java/net/sf/l2j/gameserver/model/entity/ChaosEvent.java	(revision 0)
+++ java/net/sf/l2j/gameserver/model/entity/ChaosEvent.java	(revision 0)
@@ -0,0 +1,230 @@
+/* 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 2, 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, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ *
+ * http://www.gnu.org/copyleft/gpl.html
+ */
+package net.sf.l2j.gameserver.model.entity;
+
+import java.util.Vector;
+
+import net.sf.l2j.gameserver.Announcements;
+import net.sf.l2j.gameserver.datatables.SkillTable;
+import net.sf.l2j.gameserver.model.L2Effect;
+import net.sf.l2j.gameserver.model.L2Skill;
+import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
+
+/**
+ *
+ * @author  Anarchy
+ */
+public class ChaosEvent
+{
+	public static Vector<L2PcInstance> _players = new Vector<L2PcInstance>();
+	public static L2PcInstance _topplayer, _topplayer2, _topplayer3, _topplayer4, _topplayer5;
+	public static int _topkills = 0, _topkills2 = 0, _topkills3 = 0, _topkills4 = 0, _topkills5 = 0;
+	public static boolean _isChaosActive;
+	
+	public void startChaos()
+	{
+		_isChaosActive = true;
+		_players.clear();
+		Announcements.getInstance().announceToAll("Chaos Event has started!");
+		Announcements.getInstance().announceToAll("Type .joinchaos to join and .leavechaos to leave!");
+	}
+	
+	public void stopChaos()
+	{
+		_isChaosActive = false;
+		Announcements.getInstance().announceToAll("Chaos Event has ended!");
+		getTopKiller();
+		calculateRewards();
+		for (L2PcInstance player : _players)
+		{
+			removeSuperHaste(player);
+		}
+		cleanColors();
+		cleanPlayers();
+		_players.clear();
+	}
+	
+	public void cleanColors()
+	{
+		for (L2PcInstance player : _players)
+		{
+			player.getAppearance().setNameColor(0xFFFFFF);
+			player.broadcastUserInfo();
+		}
+	}
+	
+	public void cleanPlayers()
+	{
+		for (L2PcInstance player : _players)
+		{
+			player._inChaosEvent = false;
+			player._chaosKills = 0;
+			_topkills = 0;
+			_topplayer = null;
+		}
+	}
+	
+	public void registerToChaos(L2PcInstance player)
+	{
+		if (!registerToChaosOk(player))
+		{
+			return;
+		}
+		_players.add(player);
+		player._inChaosEvent = true;
+		player._chaosKills = 0;
+		player.getAppearance().setNameColor(0x000000);
+		player.broadcastUserInfo();
+		player.sendMessage("You have joined Chaos Event.");
+		addSuperHaste(player);
+	}
+	
+	public void addSuperHaste(L2PcInstance player)
+	{
+		L2Skill skill = SkillTable.getInstance().getInfo(7029,4);
+		if (skill != null)
+		{
+			skill.getEffects(player, player);
+		}
+	}
+	
+	public boolean registerToChaosOk(L2PcInstance chaosplayer)
+	{
+		if (chaosplayer._inChaosEvent)
+		{
+			chaosplayer.sendMessage("You already are in Chaos Event.");
+			return false;
+		}
+		return true;
+	}
+	public void removeFromChaos(L2PcInstance player)
+	{
+		if (!removeFromChaosOk(player))
+		{
+			return;
+		}
+			_players.remove(player);
+			player._chaosKills = 0;
+			player._inChaosEvent = false;
+			player.sendMessage("You have left Chaos Event.");
+			player.getAppearance().setNameColor(0xFFFFFF);
+			player.broadcastUserInfo();
+			removeSuperHaste(player);
+	}
+	public boolean removeFromChaosOk(L2PcInstance chaosplayer)
+	{
+		if (!chaosplayer._inChaosEvent)
+		{
+			chaosplayer.sendMessage("You are not in Chaos Event.");
+			return false;
+		}
+		return true;
+	}
+	public static void getTopKiller()
+	{
+		for (L2PcInstance player : _players)
+		{
+			if (player._chaosKills > _topkills)
+			{
+				_topplayer = player;
+				_topkills = player._chaosKills;
+			}
+			if ((player._chaosKills > _topkills2) && (player._chaosKills < _topkills))
+			{
+				_topplayer2 = player;
+				_topkills2 = player._chaosKills;
+			}
+			if ((player._chaosKills > _topkills3) && (player._chaosKills < _topkills2))
+			{
+				_topplayer3 = player;
+				_topkills3 = player._chaosKills;
+			}
+			if ((player._chaosKills > _topkills4) && (player._chaosKills < _topkills3))
+			{
+				_topplayer4 = player;
+				_topkills4 = player._chaosKills;
+			}
+			if ((player._chaosKills > _topkills5) && (player._chaosKills < _topkills4))
+			{
+				_topplayer5 = player;
+				_topkills5 = player._chaosKills;
+			}
+		}
+	}
+	public void calculateRewards()
+	{
+		if (_topplayer != null)
+		{
+			_topplayer.addItem("Chaos Event Reward", 57, 5000, _topplayer, true);
+		}
+		if (_topplayer2 != null)
+		{
+			_topplayer2.addItem("Chaos Event Reward 2", 57, 4000, _topplayer2, true);
+		}
+		if (_topplayer3 != null)
+		{
+			_topplayer3.addItem("Chaos Event Reward 3", 57, 3000, _topplayer3, true);
+		}
+		if (_topplayer4 != null)
+		{
+			_topplayer4.addItem("Chaos Event Reward 4", 57, 2000, _topplayer4, true);
+		}
+		if (_topplayer5 != null)
+		{
+			_topplayer5.addItem("Chaos Event Reward 5", 57, 1000, _topplayer5, true);
+		}
+		
+		Announcements.getInstance().announceToAll("Winner of Chaos Event:");
+		if (_topplayer != null)
+		{
+			Announcements.getInstance().announceToAll("1) "+_topplayer.getName());
+		}
+		if (_topplayer2 != null)
+		{
+			Announcements.getInstance().announceToAll("2) "+_topplayer2.getName());
+		}
+		if (_topplayer3 != null)
+		{
+			Announcements.getInstance().announceToAll("3) "+_topplayer3.getName());
+		}
+		if (_topplayer4 != null)
+		{
+			Announcements.getInstance().announceToAll("4) "+_topplayer4.getName());
+		}
+		if (_topplayer5 != null)
+		{
+			Announcements.getInstance().announceToAll("5) "+_topplayer5.getName());
+		}
+	}
+	
+	public void removeSuperHaste(L2PcInstance activeChar)
+	{	
+		if (activeChar != null)
+		{
+			L2Effect[] effects = activeChar.getAllEffects();
+			
+			for (L2Effect e : effects)
+			{
+				if ((e != null) && (e.getSkill().getId() == 7029))
+				{
+					e.exit();
+				}
+			}
+		}
+	}
+}

Guest
This topic is now closed to further replies.


  • Posts

    • 🔥 Launch was a success! Over 500 players joined L2Elixir on opening day, and we are holding a steady 420–450 online! We faced extortion attempts and heavy DDoS attacks, but our protections held strong — even if the cost was far higher than expected. What matters is we fought back and kept the server online for you. ⚔️ 💙 Our priority is simple: Deliver a stable, fair, and growing server that will evolve for years to come. We continue to invest in protections, advertising, and development — and we won’t stop. All we ask from YOU is one thing: 👉 Keep playing. The more active the community is, the faster the server grows. 💠 Important Note: We have no paid clans or CPs, no “boosted” groups, no unfair benefits. Everyone has an equal chance to progress and compete. Thank you to everyone who joined, supported, and believed in this project. Let’s make L2Elixir great again — even in 2025–2026! 🚀   Website: https://l2elixir.org/ Discord: https://discord.gg/5ydPHvhbxs   @Atom Can you please move to Private Servers? Thanks!
    • https://jumpshare.com/share/kIdeKALOhgtMKpBKqxpg Test Equip Armors-> FullPlate, Gloves, Legs, Chest , Boots
    • 黑色星期五 — 为您的流量提供高级福利 仅在11月28日,我们的特别促销码可为您提供13%的商店折扣。 促销码: BLACKFRIDAY (13% 折扣) 您可以通过我们的网站或 Telegram 机器人在商店购物! 有效链接: 数字商品商店(网站): 前往 商店 Telegram 机器人: 前往 – 通过 Telegram Messenger 方便访问商店。 其他服务: 虚拟号码服务: 前往 用于购买 Telegram Stars 的机器人: 前往 – 快速且优惠地在 Telegram 中购买 Stars。 SMM 面板: 前往 – 推广您的社交媒体账户。 我们向您呈现当前的 促销和特惠活动 列表,用于购买我们服务的产品和服务: 1. 您可以在首次购买时使用促销码:SOCNET(15% 折扣) 2. 获取 $1 商店余额或 10–20% 折扣 — 只需在我们网站注册后发送您的用户名,格式如下:“SEND ME BONUS, MY USERNAME IS...” — 您需要在我们的论坛帖子中写下这句话! 3. SMM 面板首次试用可获得 $1:只需在我们的网站(支持)提交主题为“Get Trial Bonus”的工单。 4. 我们的 Telegram 频道和 Stars 购买机器人每周都会举办 Telegram Stars 抽奖活动! 新闻: ➡ Telegram 频道: https://t.me/accsforyou_shop ➡ WhatsApp 频道: https://chat.whatsapp.com/K8rBy500nA73z27PxgaJUw?mode=ems_copy_t ➡ Discord 服务器: https://discord.gg/y9AStFFsrh 联系方式与支持: ➡ Telegram: https://t.me/socnet_support ➡ WhatsApp: https://wa.me/79051904467 ➡ Discord: socnet_support ➡ ✉ 邮箱: solomonbog@socnet.store
    • BLACK FRIDAY — PREMIUM BENEFITS FOR YOUR TRAFFIC Only on November 28 our special promo code gives you a 13% discount in the store. PROMO CODE: BLACKFRIDAY (13% Discount) Shop in our store on the website or via the Telegram bot! Active links: Digital goods store (Website): Go Store Telegram bot: Go – convenient access to the store via Telegram messenger. Other services: Virtual numbers service: Go Telegram bot for purchasing Telegram Stars: Go – fast and profitable purchase of stars in Telegram. SMM Panel: Go – promotion of your social media accounts. We want to present you the current list of promotions and special offers for purchasing our service's products and services: 1. You can use a promo code for your first purchase: SOCNET (15% discount) 2. Get $1 to your store balance or a 10–20% discount — just send your username after registering on our website using the following template: "SEND ME BONUS, MY USERNAME IS..." — you need to write this in our forum thread! 3. Get $1 for the first trial start of the SMM Panel: just open a ticket with the subject "Get Trial Bonus" on our website (Support). 4. Weekly Telegram Stars giveaways in our Telegram channel and in our bot for purchasing stars! News: ➡ Telegram channel: https://t.me/accsforyou_shop ➡ WhatsApp channel: https://chat.whatsapp.com/K8rBy500nA73z27PxgaJUw?mode=ems_copy_t ➡ Discord server: https://discord.gg/y9AStFFsrh Contacts and Support: ➡ Telegram: https://t.me/socnet_support ➡ WhatsApp: https://wa.me/79051904467 ➡ Discord: socnet_support ➡ ✉ Email: solomonbog@socnet.store
    • Usually, I work alone on my projects, but sometimes the work is much more than I've expected. Could you provide a price list? It would be good if we knew your price before contacting you. 
  • 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