Noticias:

No tienes permiso para ver los enlaces. Para poder verlos Registrate o Conectate.

Menú Principal

Evento One In The Chamber Event

Iniciado por Swarlog, Jun 28, 2025, 11:59 PM

Tema anterior - Siguiente tema

Swarlog

Simple evento configurable de arqueros :P

### Eclipse Workspace Patch 1.0
#P L2J_DataPack_BETA
Index: dist/game/data/scripts/handlers/MasterHandler.java
===================================================================
--- dist/game/data/scripts/handlers/MasterHandler.java	(revision 9910)
+++ dist/game/data/scripts/handlers/MasterHandler.java	(working copy)
@@ -274,6 +274,7 @@
 import handlers.usercommandhandlers.Time;
 import handlers.usercommandhandlers.Unstuck;
 import handlers.voicedcommandhandlers.Banking;
+import handlers.voicedcommandhandlers.Chamber;
 import handlers.voicedcommandhandlers.ChangePassword;
 import handlers.voicedcommandhandlers.ChatAdmin;
 import handlers.voicedcommandhandlers.Debug;
@@ -540,6 +541,7 @@
 			// TODO: Add configuration options for this voiced commands:
 			// CastleVCmd.class,
 			// SetVCmd.class,
+			Chamber.class,
 			(Config.L2JMOD_ALLOW_WEDDING ? Wedding.class : null),
 			(Config.BANKING_SYSTEM_ENABLED ? Banking.class : null),
 			(Config.TVT_ALLOW_VOICED_COMMAND ? TvTVoicedInfo.class : null),
Index: dist/game/data/scripts/handlers/voicedcommandhandlers/Chamber.java
===================================================================
--- dist/game/data/scripts/handlers/voicedcommandhandlers/Chamber.java	(revision 0)
+++ dist/game/data/scripts/handlers/voicedcommandhandlers/Chamber.java	(revision 0)
@@ -0,0 +1,57 @@
+/*
+ * Copyright (C) 2004-2013 L2J DataPack
+ * 
+ * This file is part of L2J DataPack.
+ * 
+ * L2J DataPack 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.
+ * 
+ * L2J DataPack 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 handlers.voicedcommandhandlers;
+
+import com.l2jserver.gameserver.handler.IVoicedCommandHandler;
+import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
+import com.l2jserver.gameserver.model.entity.OneInTheChamber;
+
+/**
+ * @author Zoey76
+ */
+public class Chamber implements IVoicedCommandHandler
+{
+	private static final String[] VOICED_COMMANDS =
+	{
+		"register",
+		"unregister"
+	
+	};
+	
+	@Override
+	public boolean useVoicedCommand(String command, L2PcInstance activeChar, String params)
+	{
+		if (command.equalsIgnoreCase(VOICED_COMMANDS[0]))
+		{
+			OneInTheChamber.getInstance().register(activeChar);
+		}
+		else if (command.equalsIgnoreCase(VOICED_COMMANDS[1]))
+		{
+			OneInTheChamber.getInstance().unregister(activeChar);
+		}
+		
+		return true;
+	}
+	
+	@Override
+	public String[] getVoicedCommandList()
+	{
+		return VOICED_COMMANDS;
+	}
+}
#P L2J_Server_BETA
Index: java/com/l2jserver/gameserver/network/clientpackets/RequestRestartPoint.java
===================================================================
--- java/com/l2jserver/gameserver/network/clientpackets/RequestRestartPoint.java	(revision 6166)
+++ java/com/l2jserver/gameserver/network/clientpackets/RequestRestartPoint.java	(working copy)
@@ -33,6 +33,7 @@
 import com.l2jserver.gameserver.model.entity.Castle;
 import com.l2jserver.gameserver.model.entity.ClanHall;
 import com.l2jserver.gameserver.model.entity.Fort;
+import com.l2jserver.gameserver.model.entity.OneInTheChamber;
 import com.l2jserver.gameserver.model.entity.clanhall.SiegableHall;
 
 /**
@@ -264,7 +265,14 @@
 			}
 			default:
 			{
-				loc = MapRegionManager.getInstance().getTeleToLocation(activeChar, TeleportWhereType.TOWN);
+				if (activeChar.inChamber)
+				{
+					loc = new Location(OneInTheChamber.getInstance().getX(), OneInTheChamber.getInstance().getY(), OneInTheChamber.getInstance().getZ());
+				}
+				else
+				{
+					loc = MapRegionManager.getInstance().getTeleToLocation(activeChar, TeleportWhereType.TOWN);
+				}
 				break;
 			}
 		}
Index: java/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java
===================================================================
--- java/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java	(revision 6166)
+++ java/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java	(working copy)
@@ -196,6 +196,7 @@
 import com.l2jserver.gameserver.model.entity.Hero;
 import com.l2jserver.gameserver.model.entity.Instance;
 import com.l2jserver.gameserver.model.entity.L2Event;
+import com.l2jserver.gameserver.model.entity.OneInTheChamber;
 import com.l2jserver.gameserver.model.entity.Siege;
 import com.l2jserver.gameserver.model.entity.TvTEvent;
 import com.l2jserver.gameserver.model.fishing.L2Fish;
@@ -336,6 +337,10 @@
  */
 public final class L2PcInstance extends L2Playable
 {
+	
+	public int chamberKills = 0;
+	public boolean inChamber = false;
+	public int arrowCount = 0;
 	// Character Skill SQL String Definitions:
 	private static final String RESTORE_SKILLS_FOR_CHAR = "SELECT skill_id,skill_level FROM character_skills WHERE charId=? AND class_index=?";
 	private static final String ADD_NEW_SKILL = "INSERT INTO character_skills (charId,skill_id,skill_level,class_index) VALUES (?,?,?,?)";
@@ -427,7 +432,13 @@
 		public void doAttack(L2Character target)
 		{
 			super.doAttack(target);
-			
+			L2PcInstance targett = target.getActingPlayer();
+			if (inChamber)
+			{
+				targett.doDie(target);
+				chamberKills += 1;
+				OneInTheChamber.getInstance().addArrow(this.getPlayer());
+			}
 			// cancel the recent fake-death protection instantly if the player attacks or casts spells
 			getPlayer().setRecentFakeDeath(false);
 		}
@@ -5448,6 +5459,10 @@
 			return false;
 		}
 		
+		if (inChamber)
+		{
+			OneInTheChamber.addArrow(this.getActingPlayer());
+		}
 		if (isMounted())
 		{
 			stopFeed();
@@ -5810,7 +5825,6 @@
 		{
 			// Add karma to attacker and increase its PK counter
 			setPvpKills(getPvpKills() + 1);
-			
 			// Send a Server->Client UserInfo packet to attacker with its Karma and PK Counter
 			sendPacket(new UserInfo(this));
 			sendPacket(new ExBrExtraUserInfo(this));
Index: java/com/l2jserver/gameserver/model/entity/OneInTheChamber.java
===================================================================
--- java/com/l2jserver/gameserver/model/entity/OneInTheChamber.java	(revision 0)
+++ java/com/l2jserver/gameserver/model/entity/OneInTheChamber.java	(revision 0)
@@ -0,0 +1,215 @@
+/*
+ * Copyright (C) 2004-2013 L2J Server
+ * 
+ * This file is part of L2J Server.
+ * 
+ * L2J Server 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.
+ * 
+ * L2J Server 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.l2jserver.gameserver.model.entity;
+
+import javolution.util.FastList;
+
+import com.l2jserver.gameserver.Announcements;
+import com.l2jserver.gameserver.ThreadPoolManager;
+import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
+import com.l2jserver.gameserver.model.items.instance.L2ItemInstance;
+import com.l2jserver.gameserver.network.serverpackets.CreatureSay;
+
+/**
+ * @author Marwan
+ */
+public class OneInTheChamber
+{
+	int regTime = 1;
+	int eventTime = 10;
+	int LocationX = 1;
+	int LocationY = 1;
+	int LocationZ = 1;
+	int itemId = 57;
+	int itemCount = 100;
+	FastList<L2PcInstance> players = new FastList<L2PcInstance>();
+	L2PcInstance pls = null;
+	
+	public OneInTheChamber()
+	{
+		ThreadPoolManager.getInstance().scheduleAiAtFixedRate(new Run(), 600000, 600000);
+		
+	}
+	
+	public class Run implements Runnable
+	{
+		
+		@Override
+		public void run()
+		{
+			start();
+		}
+	}
+	
+	public void start()
+	{
+		announce("One in The Chamber event will start in " + regTime, true);
+		sleep(regTime);
+		if (players.size() >= 2)
+		{
+			announce("One in The Chamber event has started", true);
+			telePlayers(LocationX, LocationY, LocationZ);
+			giveBow();
+			announce("You have been teleported to event area", false);
+			sleep(eventTime);
+			reward();
+			clean();
+		}
+		else
+		{
+			announce("One in The Chamber event has ended due to lack of participants", true);
+			
+		}
+	}
+	
+	public void register(L2PcInstance i)
+	{
+		players.add(i);
+		i.inChamber = true;
+	}
+	
+	public void unregister(L2PcInstance i)
+	{
+		players.remove(i);
+		i.inChamber = false;
+	}
+	
+	public void telePlayers(int x, int y, int z)
+	{
+		for (L2PcInstance pls : players)
+		{
+			pls.teleToLocation(x, y, z);
+		}
+	}
+	
+	public void announce(String message, boolean all)
+	{
+		if (all)
+		{
+			Announcements.getInstance().announceToAll(message);
+		}
+		else
+		{
+			for (L2PcInstance pls : players)
+			{
+				CreatureSay cs = new CreatureSay(1, 2, "OneInTheChamber", message);
+				pls.sendPacket(cs);
+				
+			}
+		}
+	}
+	
+	public void sleep(int mints)
+	{
+		try
+		{
+			Thread.sleep(mints * 1000);
+		}
+		catch (InterruptedException e)
+		{
+			e.printStackTrace();
+		}
+	}
+	
+	public int getX()
+	{
+		return LocationX;
+	}
+	
+	public int getY()
+	{
+		return LocationY;
+	}
+	
+	public int getZ()
+	{
+		return LocationZ;
+	}
+	
+	public void giveBow()
+	{
+		for (L2PcInstance pls : players)
+		{
+			
+			pls.getInventory().addItem("bow", 14, 1, pls, this);
+			announce("You have recieved a bow and one arrow", false);
+		}
+	}
+	
+	public void removeArrows()
+	{
+		for (L2PcInstance pls : players)
+		{
+			L2ItemInstance item;
+			item = pls.getInventory().getItemByItemId(17);
+			if (item != null)
+			{
+				pls.getInventory().destroyItemByItemId("arrow", item.getId(), item.getCount(), pls, item);
+			}
+			pls.arrowCount = (int) item.getCount();
+		}
+	}
+	
+	public void addArrowsBack()
+	{
+		for (L2PcInstance pls : players)
+		{
+			
+			pls.getInventory().addItem("arrow", 17, pls.arrowCount, pls, this);
+		}
+	}
+	
+	public static void addArrow(L2PcInstance player)
+	{
+		player.getInventory().addItem("arrow", 17, 1, player, null);
+	}
+	
+	public void reward()
+	{
+		int topkills = 0;
+		for (L2PcInstance playas : players)
+		{
+			if (topkills < playas.chamberKills)
+			{
+				topkills = playas.chamberKills;
+				pls = playas;
+			}
+		}
+		pls.addItem("chamber", itemId, itemCount, pls, false);
+		announce(pls.getName() + " has won OneInTheChamber event", true);
+		
+	}
+	
+	public void clean()
+	{
+		players.removeAll(players);
+		addArrowsBack();
+	}
+	
+	public static OneInTheChamber getInstance()
+	{
+		return SingletonHolder._instance;
+	}
+	
+	private static class SingletonHolder
+	{
+		@SuppressWarnings("synthetic-access")
+		protected static final OneInTheChamber _instance = new OneInTheChamber();
+	}
+}