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

    • Hello everyone. Has anyone else experienced the same thing at his server? I am entering baium by the Angelic vortex with 2 char that have arrogant search quest(at search begins) and the blooded fabric ofcourse but when I press the baium it spawns and despawn immediately but angels are staying alive.. Is there a DLL problem at files or the requirements for him to spawn correctly are not legit with the chars just to have the start of the quest... C4 OFF FILES 
    • so practially you are re-writing the game into unity ? 
    • Discord         :  utchiha_market Telegram        : https://t.me/utchiha_market Auto Buy Store  : https://utchiha-market.mysellauth.com/ Not sure if we’re legit? Check Our server — real reviews, real buyers https://discord.gg/4EPpYhe2HA  | https://campsite.bio/utchihaamkt  
    • I spent a lot of time transferring the UI from the original. I won't describe all the elements yet. But I'm very close to fully transferring all the basic windows. I'll leave this video here as an example.   In this video I check the work of the skills window. The server sends different lists, I immediately send them to update in SkillList
    • True value lies in people   We believe that a service is not only about functions, but about the people who use it. For us, it’s important that working with numbers is simple and convenient, so you can solve your tasks with peace of mind. We improve the service every day: making it more stable, adding new features, and ensuring everything works as it should. We want working with Vibe SMS to be enjoyable, and for you to feel like part of the team, not just a client. Vibe SMS is not only about service, but about the atmosphere where it’s comfortable and easy to work. Website: https://vibe-sms.net/ Telegram: https://t.me/vibe_sms      
  • 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