Bladeren bron

BETA: Two useful methods for Quests:
* executeForEachPlayer(..) you can use this for onKill(..) when a reward or quest state is set for the killer's party and/or command channel.
* actionForEachPlayer(..) overridable method in quests where the action logic is placed.
* L2DoorInstance and Instance minor cleanup.
* L2J_Server_README.txt update.

Zoey76 12 jaren geleden
bovenliggende
commit
06886fd3c3

+ 12 - 11
L2J_Server_BETA/dist/doc/L2J_Server_README.txt

@@ -19,7 +19,6 @@ Stop now.
 ====================
 L2J Server 
 ====================
-$Date: 2010/01/06 13:12:11 $
 
 TOC:
 I.    OVERVIEW
@@ -55,22 +54,24 @@ participate on development by submitting the code.
 II. LEGAL
 ====================
 
-This program is free software; you can redistribute it and/or modify
+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, or (at your option)
-any later version.
+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
+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, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
-USA.
+along with this program. If not, see <http://www.gnu.org/licenses/>.
 
-Full GNU/GPL License is included in LICENSE.TXT file.
+Full GNU/GPL License is included in L2J_Server_LICENSE.txt file.
 
 Whereas L2J is distributed under the terms of GNU/GPL, we require you to:
 a) Preserve login notice. This gives us, L2J Developers, appropriate

+ 0 - 11
L2J_Server_BETA/java/com/l2jserver/gameserver/model/actor/instance/L2DoorInstance.java

@@ -22,7 +22,6 @@ import java.util.Collection;
 import java.util.Set;
 import java.util.concurrent.Future;
 import java.util.logging.Level;
-import java.util.logging.Logger;
 
 import javolution.util.FastList;
 
@@ -59,14 +58,8 @@ import com.l2jserver.gameserver.network.serverpackets.StaticObject;
 import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
 import com.l2jserver.util.Rnd;
 
-/**
- * This class ...
- * @version $Revision: 1.3.2.2.2.5 $ $Date: 2005/03/27 15:29:32 $
- */
 public class L2DoorInstance extends L2Character
 {
-	protected static final Logger log = Logger.getLogger(L2DoorInstance.class.getName());
-	
 	public static final byte OPEN_BY_CLICK = 1;
 	public static final byte OPEN_BY_TIME = 2;
 	public static final byte OPEN_BY_ITEM = 4;
@@ -124,10 +117,6 @@ public class L2DoorInstance extends L2Character
 	/** This class may be created only by L2Character and only for AI */
 	public class AIAccessor extends L2Character.AIAccessor
 	{
-		protected AIAccessor()
-		{
-		}
-		
 		@Override
 		public L2DoorInstance getActor()
 		{

+ 2 - 3
L2J_Server_BETA/java/com/l2jserver/gameserver/model/entity/Instance.java

@@ -244,11 +244,10 @@ public class Instance
 			return;
 		}
 		
-		L2DoorTemplate temp = new L2DoorTemplate(set);
-		L2DoorInstance newdoor = new L2DoorInstance(IdFactory.getInstance().getNextId(), temp);
+		final L2DoorInstance newdoor = new L2DoorInstance(IdFactory.getInstance().getNextId(), new L2DoorTemplate(set));
 		newdoor.setInstanceId(getId());
 		newdoor.setCurrentHp(newdoor.getMaxHp());
-		newdoor.spawnMe(temp.getX(), temp.getY(), temp.getZ());
+		newdoor.spawnMe(newdoor.getX(), newdoor.getY(), newdoor.getZ());
 		_doors.put(doorId, newdoor);
 	}
 	

+ 56 - 0
L2J_Server_BETA/java/com/l2jserver/gameserver/model/quest/Quest.java

@@ -44,6 +44,7 @@ import com.l2jserver.gameserver.datatables.NpcTable;
 import com.l2jserver.gameserver.idfactory.IdFactory;
 import com.l2jserver.gameserver.instancemanager.QuestManager;
 import com.l2jserver.gameserver.instancemanager.ZoneManager;
+import com.l2jserver.gameserver.model.IL2Procedure;
 import com.l2jserver.gameserver.model.L2DropData;
 import com.l2jserver.gameserver.model.L2Object;
 import com.l2jserver.gameserver.model.L2Party;
@@ -3543,4 +3544,59 @@ public class Quest extends ManagedScript
 	{
 		return GameTimeController.getGameTicks();
 	}
+	
+	/**
+	 * Executes a procedure for each player, depending on the parameters.
+	 * @param player the player were the procedure will be executed
+	 * @param npc the related Npc
+	 * @param isPet {@code true} if the event that call this method was originated by the player's pet
+	 * @param includeParty if {@code true} #actionForEachPlayer(L2PcInstance, L2Npc, boolean) will be called with the player's party members
+	 * @param includeCommandChannel if {@code true} {@link #actionForEachPlayer(L2PcInstance, L2Npc, boolean)} will be called with the player's command channel members
+	 * @see #actionForEachPlayer(L2PcInstance, L2Npc, boolean)
+	 */
+	public final void executeForEachPlayer(L2PcInstance player, final L2Npc npc, final boolean isPet, boolean includeParty, boolean includeCommandChannel)
+	{
+		if ((includeParty || includeCommandChannel) && player.isInParty())
+		{
+			if (includeCommandChannel && player.getParty().isInCommandChannel())
+			{
+				player.getParty().getCommandChannel().forEachMember(new IL2Procedure<L2PcInstance>()
+				{
+					@Override
+					public boolean execute(L2PcInstance member)
+					{
+						actionForEachPlayer(member, npc, isPet);
+						return true;
+					}
+				});
+			}
+			else if (includeParty)
+			{
+				player.getParty().forEachMember(new IL2Procedure<L2PcInstance>()
+				{
+					@Override
+					public boolean execute(L2PcInstance member)
+					{
+						actionForEachPlayer(member, npc, isPet);
+						return true;
+					}
+				});
+			}
+		}
+		else
+		{
+			actionForEachPlayer(player, npc, isPet);
+		}
+	}
+	
+	/**
+	 * Overridable method called from {@link #executeForEachPlayer(L2PcInstance, L2Npc, boolean, boolean, boolean)}
+	 * @param player the player where the action will be run
+	 * @param npc the Npc related to this action
+	 * @param isPet isPet {@code true} if the event that call this method was originated by the player's pet
+	 */
+	public void actionForEachPlayer(L2PcInstance player, L2Npc npc, boolean isPet)
+	{
+		// To be overridden in quest scripts.
+	}
 }