Forráskód Böngészése

BETA: Moving Extractable skill handler to effects:
* Improved formatter a bit.
* Implemented ConditionTargetInvSize:
* Allows to check inventory size conditions on target.
* Implemented ConditionTargetWeight
* Allows to check weight gauge conditions on target.
* Reworked the way Extractable skills data is parsed.
* Removed old skill types and added RESTORATION_RANDOM effect type.

Zoey76 13 éve
szülő
commit
3443a3646d

+ 4 - 4
L2J_Server_BETA/.settings/org.eclipse.jdt.core.prefs

@@ -1,4 +1,4 @@
-#Sat Oct 15 19:54:02 UYST 2011
+#Sun Feb 05 16:44:50 UYST 2012
 eclipse.preferences.version=1
 org.eclipse.jdt.core.codeComplete.argumentPrefixes=
 org.eclipse.jdt.core.codeComplete.argumentSuffixes=
@@ -106,7 +106,7 @@ org.eclipse.jdt.core.formatter.alignment_for_binary_expression=0
 org.eclipse.jdt.core.formatter.alignment_for_compact_if=0
 org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=0
 org.eclipse.jdt.core.formatter.alignment_for_enum_constants=49
-org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=48
+org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=49
 org.eclipse.jdt.core.formatter.alignment_for_method_declaration=0
 org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16
 org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=0
@@ -182,9 +182,9 @@ org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_method=insert
 org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_package=insert
 org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter=do not insert
 org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_type=insert
-org.eclipse.jdt.core.formatter.insert_new_line_after_label=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_after_label=insert
 org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=insert
-org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing=insert
+org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing=do not insert
 org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement=insert
 org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer=insert
 org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement=insert

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

@@ -94,6 +94,7 @@ import com.l2jserver.gameserver.model.conditions.ConditionTargetActiveEffectId;
 import com.l2jserver.gameserver.model.conditions.ConditionTargetActiveSkillId;
 import com.l2jserver.gameserver.model.conditions.ConditionTargetAggro;
 import com.l2jserver.gameserver.model.conditions.ConditionTargetClassIdRestriction;
+import com.l2jserver.gameserver.model.conditions.ConditionTargetInvSize;
 import com.l2jserver.gameserver.model.conditions.ConditionTargetLevel;
 import com.l2jserver.gameserver.model.conditions.ConditionTargetNpcId;
 import com.l2jserver.gameserver.model.conditions.ConditionTargetNpcType;
@@ -101,6 +102,7 @@ import com.l2jserver.gameserver.model.conditions.ConditionTargetPlayable;
 import com.l2jserver.gameserver.model.conditions.ConditionTargetRace;
 import com.l2jserver.gameserver.model.conditions.ConditionTargetRaceId;
 import com.l2jserver.gameserver.model.conditions.ConditionTargetUsesWeaponKind;
+import com.l2jserver.gameserver.model.conditions.ConditionTargetWeight;
 import com.l2jserver.gameserver.model.conditions.ConditionUsingItemType;
 import com.l2jserver.gameserver.model.conditions.ConditionUsingSkill;
 import com.l2jserver.gameserver.model.conditions.ConditionWithSkill;
@@ -944,6 +946,16 @@ public abstract class DocumentBase
 				
 				cond = joinAnd(cond, new ConditionTargetNpcType(types));
 			}
+			else if ("weight".equalsIgnoreCase(a.getNodeName()))
+			{
+				int weight = Integer.decode(getValue(a.getNodeValue(), null));
+				cond = joinAnd(cond, new ConditionTargetWeight(weight));
+			}
+			else if ("invSize".equalsIgnoreCase(a.getNodeName()))
+			{
+				int size = Integer.decode(getValue(a.getNodeValue(), null));
+				cond = joinAnd(cond, new ConditionTargetInvSize(size));
+			}
 		}
 		if (cond == null) _log.severe("Unrecognized <target> condition in " + _file);
 		return cond;

+ 16 - 13
L2J_Server_BETA/java/com/l2jserver/gameserver/model/L2ExtractableProductItem.java

@@ -14,32 +14,35 @@
  */
 package com.l2jserver.gameserver.model;
 
+import java.util.List;
+
+import com.l2jserver.gameserver.model.holders.ItemHolder;
+
 /**
- * @author -Nemesiss-, Zoey76
+ * @author Zoey76
  */
 public class L2ExtractableProductItem
 {
-	private final int[] _id;
-	private final int[] _ammount;
+	private final List<ItemHolder> _items;
 	private final double _chance;
 	
-	public L2ExtractableProductItem(int[] id, int[] ammount, double chance)
+	public L2ExtractableProductItem(List<ItemHolder> items, double chance)
 	{
-		_id = id;
-		_ammount = ammount;
+		_items = items;
 		_chance = chance;
 	}
 	
-	public int[] getId()
-	{
-		return _id;
-	}
-	
-	public int[] getAmmount()
+	/**
+	 * @return the the production list.
+	 */
+	public List<ItemHolder> getItems()
 	{
-		return _ammount;
+		return _items;
 	}
 	
+	/**
+	 * @return the chance of the production list.
+	 */
 	public double getChance()
 	{
 		return _chance;

+ 1 - 1
L2J_Server_BETA/java/com/l2jserver/gameserver/model/L2ExtractableSkill.java

@@ -35,7 +35,7 @@ public class L2ExtractableSkill
 		return _hash;
 	}
 	
-	public FastList<L2ExtractableProductItem> getProductItemsArray()
+	public FastList<L2ExtractableProductItem> getProductItems()
 	{
 		return _product;
 	}

+ 49 - 0
L2J_Server_BETA/java/com/l2jserver/gameserver/model/conditions/ConditionTargetInvSize.java

@@ -0,0 +1,49 @@
+/*
+ * 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.model.conditions;
+
+import com.l2jserver.gameserver.model.actor.L2Character;
+import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
+import com.l2jserver.gameserver.model.stats.Env;
+
+/**
+ * The Class ConditionTargetInvSize.
+ * @author Zoey76
+ */
+public class ConditionTargetInvSize extends Condition
+{
+	private final int _size;
+	
+	/**
+	 * Instantiates a new condition player inv size.
+	 * @param size the size
+	 */
+	public ConditionTargetInvSize(int size)
+	{
+		_size = size;
+	}
+	
+	@Override
+	public boolean testImpl(Env env)
+	{
+		final L2Character targetObj = env.getTarget();
+		if ((targetObj != null) && targetObj.isPlayer())
+		{
+			final L2PcInstance target = targetObj.getActingPlayer();
+			return target.getInventory().getSize(false) <= (target.getInventoryLimit() - _size);
+		}
+		return false;
+	}
+}

+ 55 - 0
L2J_Server_BETA/java/com/l2jserver/gameserver/model/conditions/ConditionTargetWeight.java

@@ -0,0 +1,55 @@
+/*
+ * 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.model.conditions;
+
+import com.l2jserver.gameserver.model.actor.L2Character;
+import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
+import com.l2jserver.gameserver.model.stats.Env;
+import com.l2jserver.gameserver.model.stats.Stats;
+
+/**
+ * The Class ConditionTargetWeight.
+ * @author Zoey76
+ */
+public class ConditionTargetWeight extends Condition
+{
+	private final int _weight;
+	
+	/**
+	 * Instantiates a new condition player weight.
+	 * @param weight the weight
+	 */
+	public ConditionTargetWeight(int weight)
+	{
+		_weight = weight;
+	}
+	
+	@Override
+	public boolean testImpl(Env env)
+	{
+		final L2Character targetObj = env.getTarget();
+		if ((targetObj != null) && targetObj.isPlayer())
+		{
+			final L2PcInstance target = targetObj.getActingPlayer();
+			if (!target.getDietMode() && target.getMaxLoad() > 0)
+			{
+				int weightproc = (target.getCurrentLoad() * 100) / target.getMaxLoad();
+				weightproc *= (int) target.calcStat(Stats.WEIGHT_LIMIT, 1, target, null);
+				return (weightproc < _weight);
+			}
+		}
+		return false;
+	}
+}

+ 2 - 1
L2J_Server_BETA/java/com/l2jserver/gameserver/model/effects/L2EffectType.java

@@ -80,5 +80,6 @@ public enum L2EffectType
 	ABORT_CAST,
 	INCREASE_CHARGES,
 	BLOCK_RESURRECTION,
-	DAMAGE_TRANSFER
+	DAMAGE_TRANSFER,
+	RESTORATION_RANDOM
 }

+ 24 - 26
L2J_Server_BETA/java/com/l2jserver/gameserver/model/skills/L2Skill.java

@@ -50,6 +50,7 @@ import com.l2jserver.gameserver.model.conditions.Condition;
 import com.l2jserver.gameserver.model.effects.EffectTemplate;
 import com.l2jserver.gameserver.model.effects.L2Effect;
 import com.l2jserver.gameserver.model.entity.TvTEvent;
+import com.l2jserver.gameserver.model.holders.ItemHolder;
 import com.l2jserver.gameserver.model.items.L2Armor;
 import com.l2jserver.gameserver.model.items.type.L2ArmorType;
 import com.l2jserver.gameserver.model.skills.funcs.Func;
@@ -2001,51 +2002,48 @@ public abstract class L2Skill implements IChanceSkillTrigger
 	 */
 	private L2ExtractableSkill parseExtractableSkill(int skillId, int skillLvl, String values)
 	{
-		String[] lineSplit = values.split(";");
-		
-		final FastList<L2ExtractableProductItem> product_temp = new FastList<L2ExtractableProductItem>();
-		
-		for (int i = 0; i <= (lineSplit.length-1); i++)
+		final String[] prodLists = values.split(";");
+		final FastList<L2ExtractableProductItem> products = new FastList<>();
+		String[] prodData;
+		for (String prodList : prodLists)
 		{
-			final String[] lineSplit2 = lineSplit[i].split(",");
-			
-			if (lineSplit2.length < 3)
+			prodData = prodList.split(",");
+			if (prodData.length < 3)
+			{
 				_log.warning("Extractable skills data: Error in Skill Id: " + skillId + " Level: " + skillLvl + " -> wrong seperator!");
-			
-			int[] production = null;
-			int[] amount = null;
+			}
+			List<ItemHolder> items = null;
 			double chance = 0;
 			int prodId = 0;
 			int quantity = 0;
+			final int lenght = prodData.length - 1;
 			try
 			{
-				int k =0;
-				production = new int[(lineSplit2.length-1)/2];
-				amount = new int[(lineSplit2.length-1)/2];
-				for (int j = 0; j < (lineSplit2.length-1); j++)
+				items =  new ArrayList<>(lenght / 2);
+				for (int j = 0; j < lenght; j++)
 				{
-					prodId = Integer.parseInt(lineSplit2[j]);
-					quantity = Integer.parseInt(lineSplit2[j+=1]);
+					prodId = Integer.parseInt(prodData[j]);
+					quantity = Integer.parseInt(prodData[j += 1]);
 					if ((prodId <= 0) || (quantity <= 0))
+					{
 						_log.warning("Extractable skills data: Error in Skill Id: " + skillId + " Level: " + skillLvl + " wrong production Id: " + prodId + " or wrond quantity: " + quantity + "!");
-					production[k] = prodId;
-					amount[k] = quantity;
-					k++;
+					}
+					items.add(new ItemHolder(prodId, quantity));
 				}
-				chance = Double.parseDouble(lineSplit2[lineSplit2.length-1]);
+				chance = Double.parseDouble(prodData[lenght]);
 			}
 			catch (Exception e)
 			{
 				_log.warning("Extractable skills data: Error in Skill Id: " + skillId + " Level: " + skillLvl + " -> incomplete/invalid production data or wrong seperator!");
 			}
-			
-			product_temp.add(new L2ExtractableProductItem(production, amount, chance));
+			products.add(new L2ExtractableProductItem(items, chance));
 		}
 		
-		if (product_temp.size()== 0)
+		if (products.isEmpty())
+		{
 			_log.warning("Extractable skills data: Error in Skill Id: " + skillId + " Level: " + skillLvl + " -> There are no production items!");
-		
-		return new L2ExtractableSkill(SkillTable.getSkillHashCode(this), product_temp);
+		}
+		return new L2ExtractableSkill(SkillTable.getSkillHashCode(skillId, skillLvl), products);
 	}
 	
 	public L2ExtractableSkill getExtractableSkill()

+ 0 - 2
L2J_Server_BETA/java/com/l2jserver/gameserver/model/skills/L2SkillType.java

@@ -136,8 +136,6 @@ public enum L2SkillType
 	COMMON_CRAFT,
 	DWARVEN_CRAFT,
 	CREATE_ITEM(L2SkillCreateItem.class),
-	EXTRACTABLE,
-	EXTRACTABLE_FISH,
 	LEARN_SKILL(L2SkillLearnSkill.class),
 	
 	// Summons