Jelajahi Sumber

Two new conditions:
PlayerClassIdRestriction (same for TargetClassIdRestriction but for player itself)
IsClanLeader (true if player is clan leader)

_DS_ 16 tahun lalu
induk
melakukan
27fb85e42e

+ 16 - 0
L2_GameServer/java/net/sf/l2j/gameserver/skills/DocumentBase.java

@@ -540,6 +540,11 @@ abstract class DocumentBase
                 int size = Integer.decode(getValue(a.getNodeValue(), null));
                 cond = joinAnd(cond, new ConditionPlayerInvSize(size));
             }
+            else if ("isClanLeader".equalsIgnoreCase(a.getNodeName()))
+            {
+            	boolean val = Boolean.valueOf(a.getNodeValue());
+                cond = joinAnd(cond, new ConditionPlayerIsClanLeader(val));
+            }
             else if ("pledgeClass".equalsIgnoreCase(a.getNodeName()))
             {
                 int pledgeClass = Integer.decode(getValue(a.getNodeValue(), null));
@@ -593,6 +598,17 @@ abstract class DocumentBase
         		int skill_lvl = Integer.decode(getValue(val.split(",")[1], template));
                 cond = joinAnd(cond, new ConditionPlayerActiveSkillId(skill_id, skill_lvl));
             }
+            else if ("class_id_restriction".equalsIgnoreCase(a.getNodeName()))
+            {
+            	FastList<Integer> array = new FastList<Integer>();
+            	StringTokenizer st = new StringTokenizer(a.getNodeValue(), ",");
+            	while (st.hasMoreTokens())
+                {
+                    String item = st.nextToken().trim();
+                    array.add(Integer.decode(getValue(item, null)));
+                }
+            	cond = joinAnd(cond, new ConditionPlayerClassIdRestriction(array));
+            }
         }
 
         if(forces[0] + forces[1] > 0)

+ 37 - 0
L2_GameServer/java/net/sf/l2j/gameserver/skills/conditions/ConditionPlayerClassIdRestriction.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 net.sf.l2j.gameserver.skills.conditions;
+
+import javolution.util.FastList;
+import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
+import net.sf.l2j.gameserver.skills.Env;
+
+public class ConditionPlayerClassIdRestriction extends Condition
+{
+	private final FastList<Integer> _classIds;
+
+	public ConditionPlayerClassIdRestriction(FastList<Integer> classId)
+	{
+		_classIds = classId;
+	}
+
+	@Override
+	public boolean testImpl(Env env)
+	{
+		if (!(env.player instanceof L2PcInstance))
+			return false;
+		return (_classIds.contains(((L2PcInstance)env.player).getClassId().getId()));
+	}
+}

+ 36 - 0
L2_GameServer/java/net/sf/l2j/gameserver/skills/conditions/ConditionPlayerIsClanLeader.java

@@ -0,0 +1,36 @@
+/*
+ * 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 net.sf.l2j.gameserver.skills.conditions;
+
+import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
+import net.sf.l2j.gameserver.skills.Env;
+
+public class ConditionPlayerIsClanLeader extends Condition
+{
+	private final boolean _val;
+
+	public ConditionPlayerIsClanLeader(boolean val)
+	{
+		_val = val;
+	}
+
+	@Override
+	public boolean testImpl(Env env)
+	{
+		if (!(env.player instanceof L2PcInstance))
+			return false;
+		return (((L2PcInstance)env.player).isClanLeader() == _val);
+	}
+}