浏览代码

Support for Condition '''npcIdRadius''' thanks UnAfraid (and thanks Qwerty13 for test).

MELERIX 14 年之前
父节点
当前提交
95d7b531d0

+ 13 - 0
L2J_Server/java/com/l2jserver/gameserver/skills/DocumentBase.java

@@ -72,6 +72,7 @@ import com.l2jserver.gameserver.skills.conditions.ConditionPlayerMp;
 import com.l2jserver.gameserver.skills.conditions.ConditionPlayerPkCount;
 import com.l2jserver.gameserver.skills.conditions.ConditionPlayerPledgeClass;
 import com.l2jserver.gameserver.skills.conditions.ConditionPlayerRace;
+import com.l2jserver.gameserver.skills.conditions.ConditionPlayerRangeFromNpc;
 import com.l2jserver.gameserver.skills.conditions.ConditionPlayerServitorNpcId;
 import com.l2jserver.gameserver.skills.conditions.ConditionPlayerSex;
 import com.l2jserver.gameserver.skills.conditions.ConditionPlayerSiegeSide;
@@ -698,6 +699,18 @@ abstract class DocumentBase
 				}
 				cond = joinAnd(cond, new ConditionPlayerServitorNpcId(array));
 			}
+			else if ("npcIdRadius".equalsIgnoreCase(a.getNodeName()))
+			{
+				StringTokenizer st = new StringTokenizer(a.getNodeValue(), ",");
+				int npcId = 0;
+				int radius = 0;
+				if (st.countTokens() > 1)
+				{
+					npcId = Integer.decode(getValue(st.nextToken().trim(), null));
+					radius = Integer.decode(getValue(st.nextToken().trim(), null));
+				}
+				cond = joinAnd(cond, new ConditionPlayerRangeFromNpc(npcId, radius));
+			}
 		}
 		
 		if (forces[0] + forces[1] > 0)

+ 52 - 0
L2J_Server/java/com/l2jserver/gameserver/skills/conditions/ConditionPlayerRangeFromNpc.java

@@ -0,0 +1,52 @@
+/*
+ * 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.L2Character;
+import com.l2jserver.gameserver.model.actor.L2Npc;
+import com.l2jserver.gameserver.skills.Env;
+
+/**
+ * @author UnAfraid
+ *
+ */
+public class ConditionPlayerRangeFromNpc extends Condition
+{
+	private final int _npcId;
+	private final int _radius;
+	public ConditionPlayerRangeFromNpc(int npcId, int radius)
+	{
+		_npcId = npcId;
+		_radius = radius;
+	}
+	
+	@Override
+	boolean testImpl(Env env)
+	{
+		if (_npcId == 0 || _radius == 0)
+			return false;
+		
+		for (L2Character target : env.player.getKnownList().getKnownCharactersInRadius(_radius))
+		{
+			if (target instanceof L2Npc)
+			{
+				if (((L2Npc) target).getNpcId() == _npcId)
+					return true;
+			}
+		}
+		
+		return false;
+	}
+}