Bläddra i källkod

New condition <player pkCount="xx" />
Caution: true if player's PK count value is lower or equal.

_DS_ 15 år sedan
förälder
incheckning
eb6bb22ca8

+ 1 - 14
L2_GameServer/java/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java

@@ -5776,20 +5776,7 @@ public final class L2PcInstance extends L2Playable
 			{
 				increasePkKillsAndKarma(target);
 				//Unequip adventurer items
-				if(getInventory().getPaperdollItemId(7) >= 7816 && getInventory().getPaperdollItemId(7) <= 7831) 
-				{
-					L2ItemInstance invItem = getInventory().getItemByItemId(getInventory().getPaperdollItemId(7));
-					if(invItem.isEquipped()) 
-					{
-						L2ItemInstance[] unequiped = getInventory().unEquipItemInSlotAndRecord(invItem.getLocationSlot());
-						InventoryUpdate iu = new InventoryUpdate();
-						for(L2ItemInstance itm: unequiped)
-							iu.addModifiedItem(itm);
-						sendPacket(iu);
-					}
-					refreshExpertisePenalty();			
-					sendPacket(new SystemMessage(SystemMessageId.YOU_ARE_UNABLE_TO_EQUIP_THIS_ITEM_WHEN_YOUR_PK_COUNT_IS_GREATER_THAN_OR_EQUAL_TO_ONE));
-				}
+				checkItemRestriction();
 			}
 		}
 	}

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

@@ -31,9 +31,7 @@ import com.l2jserver.gameserver.model.L2Skill;
 import com.l2jserver.gameserver.model.L2World;
 import com.l2jserver.gameserver.model.L2ItemInstance.ItemLocation;
 import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
-import com.l2jserver.gameserver.network.SystemMessageId;
 import com.l2jserver.gameserver.network.serverpackets.SkillCoolTime;
-import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
 import com.l2jserver.gameserver.skills.Stats;
 import com.l2jserver.gameserver.templates.item.L2Armor;
 import com.l2jserver.gameserver.templates.item.L2EtcItem;
@@ -1385,12 +1383,6 @@ public abstract class Inventory extends ItemContainer
 		{
 			L2PcInstance player = (L2PcInstance)getOwner();
 
-			if (player.getPkKills() > 0 && item.getItemId() >= 7816 && item.getItemId() <= 7831)
-			{
-				player.sendPacket(new SystemMessage(SystemMessageId.YOU_ARE_UNABLE_TO_EQUIP_THIS_ITEM_WHEN_YOUR_PK_COUNT_IS_GREATER_THAN_OR_EQUAL_TO_ONE));
-					return;
-			}
-
 			if (!player.isGM() && !player.isHero() && item.isHeroItem())
 				return;
 		}
@@ -1694,9 +1686,6 @@ public abstract class Inventory extends ItemContainer
 				{
 					L2PcInstance player = (L2PcInstance)getOwner();
 
-					if (player.getPkKills() > 0 && item.getItemId() >= 7816 && item.getItemId() <= 7831)
-						item.setLocation(ItemLocation.INVENTORY);
-
 					if (!player.isGM() && !player.isHero() && item.isHeroItem())
 						item.setLocation(ItemLocation.INVENTORY);
 				}

+ 5 - 0
L2_GameServer/java/com/l2jserver/gameserver/skills/DocumentBase.java

@@ -499,6 +499,11 @@ abstract class DocumentBase
             	int expIndex = Integer.decode(getValue(a.getNodeValue(), template));
             	cond = joinAnd(cond, new ConditionPlayerGrade(expIndex));
             }
+            else if ("pkCount".equalsIgnoreCase(a.getNodeName()))
+            {
+            	int expIndex = Integer.decode(getValue(a.getNodeValue(), template));
+            	cond = joinAnd(cond, new ConditionPlayerPkCount(expIndex));
+            }
             else if ("siegezone".equalsIgnoreCase(a.getNodeName()))
             {
                 int value = Integer.decode(getValue(a.getNodeValue(), null));

+ 37 - 0
L2_GameServer/java/com/l2jserver/gameserver/skills/conditions/ConditionPlayerPkCount.java

@@ -0,0 +1,37 @@
+/*
+ * 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 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 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.skills.conditions;
+
+import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
+import com.l2jserver.gameserver.skills.Env;
+
+public class ConditionPlayerPkCount extends Condition
+{
+	public final int _pk;
+
+	public ConditionPlayerPkCount(int pk)
+	{
+		_pk = pk;
+	}
+
+	@Override
+	public boolean testImpl(Env env)
+	{
+		if (!(env.player instanceof L2PcInstance))
+			return false;
+
+		return ((L2PcInstance)env.player).getPkKills() <= _pk;
+	}
+}