瀏覽代碼

BETA/STABLE: Levels Range Condition by Zoey76.

MELERIX 14 年之前
父節點
當前提交
ae79806fe5

+ 12 - 0
L2J_Server_BETA/java/com/l2jserver/gameserver/skills/DocumentBase.java

@@ -68,6 +68,7 @@ import com.l2jserver.gameserver.skills.conditions.ConditionPlayerIsClanLeader;
 import com.l2jserver.gameserver.skills.conditions.ConditionPlayerIsHero;
 import com.l2jserver.gameserver.skills.conditions.ConditionPlayerLandingZone;
 import com.l2jserver.gameserver.skills.conditions.ConditionPlayerLevel;
+import com.l2jserver.gameserver.skills.conditions.ConditionPlayerLevelRange;
 import com.l2jserver.gameserver.skills.conditions.ConditionPlayerMp;
 import com.l2jserver.gameserver.skills.conditions.ConditionPlayerPkCount;
 import com.l2jserver.gameserver.skills.conditions.ConditionPlayerPledgeClass;
@@ -460,6 +461,17 @@ abstract class DocumentBase
 				int lvl = Integer.decode(getValue(a.getNodeValue(), template));
 				cond = joinAnd(cond, new ConditionPlayerLevel(lvl));
 			}
+			else if ("levelRange".equalsIgnoreCase(a.getNodeName()))
+			{
+				String[] range = getValue(a.getNodeValue(), template).split(";");
+				if (range.length == 2)
+				{
+					int[] lvlRange = new int[2];
+					lvlRange[0] = Integer.decode(getValue(a.getNodeValue(), template).split(";")[0]);
+					lvlRange[1] = Integer.decode(getValue(a.getNodeValue(), template).split(";")[1]);
+					cond = joinAnd(cond, new ConditionPlayerLevelRange(lvlRange));
+				}
+			}
 			else if ("resting".equalsIgnoreCase(a.getNodeName()))
 			{
 				boolean val = Boolean.valueOf(a.getNodeValue());

+ 40 - 0
L2J_Server_BETA/java/com/l2jserver/gameserver/skills/conditions/ConditionPlayerLevelRange.java

@@ -0,0 +1,40 @@
+/*
+ * 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.skills.Env;
+
+/**
+ * @author Zoey76
+ */
+public class ConditionPlayerLevelRange extends Condition
+{
+	private final int[] _levels;
+	
+	/**
+	 * Instantiates a new condition player levels range.
+	 * @param the {@code levels} range.
+	 */
+	public ConditionPlayerLevelRange(int[] levels)
+	{
+		_levels = levels;
+	}
+	
+	@Override
+	public boolean testImpl(Env env)
+	{
+		return ((env.player.getLevel() >= _levels[0]) && (env.player.getLevel() <= _levels[1]));
+	}
+}