Răsfoiți Sursa

Action handler use L2Object instead of L2Character as target.
Unhardcoding actions for L2ItemInstance.
Require DP update !

_DS_ 15 ani în urmă
părinte
comite
4a519a62c2

+ 2 - 2
L2_GameServer/java/com/l2jserver/gameserver/handler/IActionHandler.java

@@ -17,14 +17,14 @@ package com.l2jserver.gameserver.handler;
 import java.util.logging.Logger;
 
 import com.l2jserver.gameserver.model.L2Object.InstanceType;
-import com.l2jserver.gameserver.model.actor.L2Character;
+import com.l2jserver.gameserver.model.L2Object;
 import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
 
 public interface IActionHandler
 {
 	public static Logger _log = Logger.getLogger(IActionHandler.class.getName());
 
-	public boolean action(L2PcInstance activeChar, L2Character target, boolean interact);
+	public boolean action(L2PcInstance activeChar, L2Object target, boolean interact);
 
 	public InstanceType getInstanceType();
 }

+ 2 - 33
L2_GameServer/java/com/l2jserver/gameserver/model/L2ItemInstance.java

@@ -30,7 +30,6 @@ import com.l2jserver.Config;
 import com.l2jserver.L2DatabaseFactory;
 import com.l2jserver.gameserver.GeoData;
 import com.l2jserver.gameserver.ThreadPoolManager;
-import com.l2jserver.gameserver.ai.CtrlIntention;
 import com.l2jserver.gameserver.datatables.ItemTable;
 import com.l2jserver.gameserver.instancemanager.ItemsOnGroundManager;
 import com.l2jserver.gameserver.instancemanager.MercTicketManager;
@@ -39,7 +38,6 @@ import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
 import com.l2jserver.gameserver.model.actor.knownlist.NullKnownList;
 import com.l2jserver.gameserver.model.quest.QuestState;
 import com.l2jserver.gameserver.network.SystemMessageId;
-import com.l2jserver.gameserver.network.serverpackets.ActionFailed;
 import com.l2jserver.gameserver.network.serverpackets.DropItem;
 import com.l2jserver.gameserver.network.serverpackets.GetItem;
 import com.l2jserver.gameserver.network.serverpackets.InventoryUpdate;
@@ -165,6 +163,7 @@ public final class L2ItemInstance extends L2Object
 	public L2ItemInstance(int objectId, int itemId)
 	{
 		super(objectId);
+		setInstanceType(InstanceType.L2ItemInstance);
 		_itemId = itemId;
 		_item = ItemTable.getInstance().getTemplate(itemId);
 		if (_itemId == 0 || _item == null)
@@ -188,6 +187,7 @@ public final class L2ItemInstance extends L2Object
 	public L2ItemInstance(int objectId, L2Item item)
 	{
 		super(objectId);
+		setInstanceType(InstanceType.L2ItemInstance);
 		_itemId = item.getItemId();
 		_item = item;
 		if (_itemId == 0)
@@ -761,37 +761,6 @@ public final class L2ItemInstance extends L2Object
     		);
     }
 
-    /* (non-Javadoc)
-	 * @see com.l2jserver.gameserver.model.L2Object#onAction(com.l2jserver.gameserver.model.L2PcInstance)
-	 * also check constraints: only soloing castle owners may pick up mercenary tickets of their castle
-	 */
-	@Override
-	public void onAction(L2PcInstance player, boolean interact)
-	{
-		// this causes the validate position handler to do the pickup if the location is reached.
-		// mercenary tickets can only be picked up by the castle owner.
-        int castleId = MercTicketManager.getInstance().getTicketCastleId(_itemId);
-        
-        if (castleId > 0 && 
-                (!player.isCastleLord(castleId) || player.isInParty()))
-        {
-            if  (player.isInParty())    //do not allow owner who is in party to pick tickets up
-                player.sendMessage("You cannot pickup mercenaries while in a party.");
-            else
-                player.sendMessage("Only the castle lord can pickup mercenaries.");
-
-            player.setTarget(this);
-            player.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
-            // Send a Server->Client ActionFailed to the L2PcInstance in order to avoid that the client wait another packet
-            player.sendPacket(ActionFailed.STATIC_PACKET);
-        }
-        else if (player.isFlying()) // cannot pickup
-        {
-        	player.sendPacket(ActionFailed.STATIC_PACKET);
-        }
-		else
-			player.getAI().setIntention(CtrlIntention.AI_INTENTION_PICK_UP, this);
-	}
 	/**
 	 * Returns the level of enchantment of the item
 	 * @return int

+ 11 - 0
L2_GameServer/java/com/l2jserver/gameserver/model/L2Object.java

@@ -14,6 +14,8 @@
  */
 package com.l2jserver.gameserver.model;
 
+import com.l2jserver.gameserver.handler.ActionHandler;
+import com.l2jserver.gameserver.handler.IActionHandler;
 import com.l2jserver.gameserver.idfactory.IdFactory;
 import com.l2jserver.gameserver.instancemanager.InstanceManager;
 import com.l2jserver.gameserver.model.actor.L2Character;
@@ -65,6 +67,7 @@ public abstract class L2Object
 	public static enum InstanceType
 	{
 		L2Object(null),
+		L2ItemInstance(L2Object),
 		L2Character(L2Object),
 		L2Npc(L2Character),
 		L2Playable(L2Character),
@@ -264,11 +267,19 @@ public abstract class L2Object
 	
 	public void onAction(L2PcInstance player, boolean interact)
 	{
+		IActionHandler handler = ActionHandler.getInstance().getActionHandler(getInstanceType());
+		if (handler != null)
+			handler.action(player, this, interact);
+
 		player.sendPacket(ActionFailed.STATIC_PACKET);
 	}
 	
 	public void onActionShift(L2PcInstance player)
 	{
+		IActionHandler handler = ActionHandler.getInstance().getActionShiftHandler(getInstanceType());
+		if (handler != null)
+			handler.action(player, this, true);
+
 		player.sendPacket(ActionFailed.STATIC_PACKET);
 	}
 	

+ 0 - 23
L2_GameServer/java/com/l2jserver/gameserver/model/actor/L2Character.java

@@ -42,8 +42,6 @@ import com.l2jserver.gameserver.datatables.DoorTable;
 import com.l2jserver.gameserver.datatables.MapRegionTable;
 import com.l2jserver.gameserver.datatables.SkillTable;
 import com.l2jserver.gameserver.datatables.MapRegionTable.TeleportWhereType;
-import com.l2jserver.gameserver.handler.ActionHandler;
-import com.l2jserver.gameserver.handler.IActionHandler;
 import com.l2jserver.gameserver.handler.ISkillHandler;
 import com.l2jserver.gameserver.handler.SkillHandler;
 import com.l2jserver.gameserver.instancemanager.DimensionalRiftManager;
@@ -2459,27 +2457,6 @@ public abstract class L2Character extends L2Object
     	setObjectPosition(new CharPosition(this));
     }
 
-    @Override
-	public void onAction(L2PcInstance player, boolean interact)
-    {
-		IActionHandler handler = ActionHandler.getInstance().getActionHandler(getInstanceType());
-		if (handler != null)
-			handler.action(player, this, interact);
-
-		player.sendPacket(ActionFailed.STATIC_PACKET);
-    }
-
-	@Override
-	public void onActionShift(L2PcInstance player)
-	{
-		IActionHandler handler = ActionHandler.getInstance().getActionShiftHandler(getInstanceType());
-		if (handler != null)
-			handler.action(player, this, true);
-
-		// Send a Server->Client ActionFailed to the L2PcInstance in order to avoid that the client wait another packet
-		player.sendPacket(ActionFailed.STATIC_PACKET);
-	}
-
 	public L2CharTemplate getTemplate() { return _template; }
 	/**
 	 * Set the template of the L2Character.<BR><BR>