Ver Fonte

Stats order improved
* Stats Enum hold name and order now (is not need in dp anymore)
* Custom order is still support
* Fix few bugs with not proper calculation
* Switch from hex to decimal values

Require Data Pack!

Reviewed by: @Zoey76, @NosBit

Zealar há 10 anos atrás
pai
commit
2d6af28bc6
23 ficheiros alterados com 131 adições e 118 exclusões
  1. 4 21
      L2J_Server/java/com/l2jserver/gameserver/datatables/EnchantItemHPBonusData.java
  2. 14 27
      L2J_Server/java/com/l2jserver/gameserver/datatables/OptionsData.java
  3. 29 49
      L2J_Server/java/com/l2jserver/gameserver/engines/DocumentBase.java
  4. 53 0
      L2J_Server/java/com/l2jserver/gameserver/enums/StatFunction.java
  5. 13 3
      L2J_Server/java/com/l2jserver/gameserver/model/stats/functions/FuncTemplate.java
  6. 1 1
      L2J_Server/java/com/l2jserver/gameserver/model/stats/functions/formulas/FuncArmorSet.java
  7. 1 1
      L2J_Server/java/com/l2jserver/gameserver/model/stats/functions/formulas/FuncAtkAccuracy.java
  8. 1 1
      L2J_Server/java/com/l2jserver/gameserver/model/stats/functions/formulas/FuncAtkCritical.java
  9. 1 1
      L2J_Server/java/com/l2jserver/gameserver/model/stats/functions/formulas/FuncAtkEvasion.java
  10. 1 1
      L2J_Server/java/com/l2jserver/gameserver/model/stats/functions/formulas/FuncGatesMDefMod.java
  11. 1 1
      L2J_Server/java/com/l2jserver/gameserver/model/stats/functions/formulas/FuncGatesPDefMod.java
  12. 1 1
      L2J_Server/java/com/l2jserver/gameserver/model/stats/functions/formulas/FuncHenna.java
  13. 1 1
      L2J_Server/java/com/l2jserver/gameserver/model/stats/functions/formulas/FuncMAtkCritical.java
  14. 1 1
      L2J_Server/java/com/l2jserver/gameserver/model/stats/functions/formulas/FuncMAtkMod.java
  15. 1 1
      L2J_Server/java/com/l2jserver/gameserver/model/stats/functions/formulas/FuncMAtkSpeed.java
  16. 1 1
      L2J_Server/java/com/l2jserver/gameserver/model/stats/functions/formulas/FuncMDefMod.java
  17. 1 1
      L2J_Server/java/com/l2jserver/gameserver/model/stats/functions/formulas/FuncMaxCpMul.java
  18. 1 1
      L2J_Server/java/com/l2jserver/gameserver/model/stats/functions/formulas/FuncMaxHpMul.java
  19. 1 1
      L2J_Server/java/com/l2jserver/gameserver/model/stats/functions/formulas/FuncMaxMpMul.java
  20. 1 1
      L2J_Server/java/com/l2jserver/gameserver/model/stats/functions/formulas/FuncMoveSpeed.java
  21. 1 1
      L2J_Server/java/com/l2jserver/gameserver/model/stats/functions/formulas/FuncPAtkMod.java
  22. 1 1
      L2J_Server/java/com/l2jserver/gameserver/model/stats/functions/formulas/FuncPAtkSpeed.java
  23. 1 1
      L2J_Server/java/com/l2jserver/gameserver/model/stats/functions/formulas/FuncPDefMod.java

+ 4 - 21
L2J_Server/java/com/l2jserver/gameserver/datatables/EnchantItemHPBonusData.java

@@ -27,6 +27,7 @@ import java.util.Map;
 import org.w3c.dom.Node;
 
 import com.l2jserver.gameserver.engines.DocumentParser;
+import com.l2jserver.gameserver.enums.StatFunction;
 import com.l2jserver.gameserver.model.items.L2Item;
 import com.l2jserver.gameserver.model.items.instance.L2ItemInstance;
 import com.l2jserver.gameserver.model.items.type.CrystalType;
@@ -41,7 +42,7 @@ public class EnchantItemHPBonusData extends DocumentParser
 {
 	private final Map<CrystalType, List<Integer>> _armorHPBonuses = new EnumMap<>(CrystalType.class);
 	
-	private static final float fullArmorModifier = 1.5f; // TODO: Move it to config!
+	private static final float FULL_ARMOR_MODIFIER = 1.5f; // TODO: Move it to config!
 	
 	/**
 	 * Instantiates a new enchant hp bonus data.
@@ -99,25 +100,7 @@ public class EnchantItemHPBonusData extends DocumentParser
 						case L2Item.SLOT_UNDERWEAR:
 						case L2Item.SLOT_L_HAND:
 						case L2Item.SLOT_BELT:
-							item.attach(new FuncTemplate(null, null, "EnchantHp", Stats.MAX_HP, 0x60, 0));
-							break;
-						default:
-							break;
-					}
-				}
-			}
-			
-			// Shields
-			final Collection<Integer> shieldIds = it.getAllWeaponsId();
-			for (Integer itemId : shieldIds)
-			{
-				item = it.getTemplate(itemId);
-				if ((item != null) && (item.getCrystalType() != CrystalType.NONE))
-				{
-					switch (item.getBodyPart())
-					{
-						case L2Item.SLOT_L_HAND:
-							item.attach(new FuncTemplate(null, null, "EnchantHp", Stats.MAX_HP, 0x60, 0));
+							item.attach(new FuncTemplate(null, null, StatFunction.ENCHANTHP.getName(), -1, Stats.MAX_HP, 0));
 							break;
 						default:
 							break;
@@ -151,7 +134,7 @@ public class EnchantItemHPBonusData extends DocumentParser
 		final int bonus = values.get(Math.min(item.getOlyEnchantLevel(), values.size()) - 1);
 		if (item.getItem().getBodyPart() == L2Item.SLOT_FULL_ARMOR)
 		{
-			return (int) (bonus * fullArmorModifier);
+			return (int) (bonus * FULL_ARMOR_MODIFIER);
 		}
 		return bonus;
 	}

+ 14 - 27
L2J_Server/java/com/l2jserver/gameserver/datatables/OptionsData.java

@@ -80,36 +80,18 @@ public class OptionsData extends DocumentParser
 										switch (fd.getNodeName())
 										{
 											case "add":
-											{
-												parseFuncs(fd.getAttributes(), "Add", op);
-												break;
-											}
-											case "mul":
-											{
-												parseFuncs(fd.getAttributes(), "Mul", op);
-												break;
-											}
-											case "basemul":
-											{
-												parseFuncs(fd.getAttributes(), "BaseMul", op);
-												break;
-											}
 											case "sub":
-											{
-												parseFuncs(fd.getAttributes(), "Sub", op);
-												break;
-											}
+											case "mul":
 											case "div":
-											{
-												parseFuncs(fd.getAttributes(), "Div", op);
-												break;
-											}
 											case "set":
+											case "share":
+											case "enchant":
+											case "enchanthp":
 											{
-												parseFuncs(fd.getAttributes(), "Set", op);
-												break;
+												parseFuncs(fd.getAttributes(), fd.getNodeName(), op);
 											}
 										}
+										
 									}
 									break;
 								}
@@ -147,12 +129,17 @@ public class OptionsData extends DocumentParser
 		}
 	}
 	
-	private void parseFuncs(NamedNodeMap attrs, String func, Options op)
+	private void parseFuncs(NamedNodeMap attrs, String functionName, Options op)
 	{
 		Stats stat = Stats.valueOfXml(parseString(attrs, "stat"));
-		int ord = Integer.decode(parseString(attrs, "order"));
 		double val = parseDouble(attrs, "val");
-		op.addFunc(new FuncTemplate(null, null, func, stat, ord, val));
+		int order = -1;
+		final Node orderNode = attrs.getNamedItem("order");
+		if (orderNode != null)
+		{
+			order = Integer.parseInt(orderNode.getNodeValue());
+		}
+		op.addFunc(new FuncTemplate(null, null, functionName, order, stat, val));
 	}
 	
 	public Options getOptions(int id)

+ 29 - 49
L2J_Server/java/com/l2jserver/gameserver/engines/DocumentBase.java

@@ -222,65 +222,46 @@ public abstract class DocumentBase
 		}
 		for (; n != null; n = n.getNextSibling())
 		{
-			switch (n.getNodeName().toLowerCase())
+			final String name = n.getNodeName().toLowerCase();
+			
+			if (name.equalsIgnoreCase("effect"))
 			{
-				case "add":
-				{
-					attachFunc(n, template, "Add", condition);
-					break;
-				}
-				case "sub":
-				{
-					attachFunc(n, template, "Sub", condition);
-					break;
-				}
-				case "mul":
-				{
-					attachFunc(n, template, "Mul", condition);
-					break;
-				}
-				case "div":
-				{
-					attachFunc(n, template, "Div", condition);
-					break;
-				}
-				case "set":
+				if (template instanceof AbstractEffect)
 				{
-					attachFunc(n, template, "Set", condition);
-					break;
+					throw new RuntimeException("Nested effects");
 				}
-				case "share":
-				{
-					attachFunc(n, template, "Share", condition);
-					break;
-				}
-				case "enchant":
-				{
-					attachFunc(n, template, "Enchant", condition);
-					break;
-				}
-				case "enchanthp":
-				{
-					attachFunc(n, template, "EnchantHp", condition);
-					break;
-				}
-				case "effect":
-				{
-					if (template instanceof AbstractEffect)
+				attachEffect(n, template, condition, effectScope);
+			}
+			else
+			{
+				switch (name)
+				{
+					case "add":
+					case "sub":
+					case "mul":
+					case "div":
+					case "set":
+					case "share":
+					case "enchant":
+					case "enchanthp":
 					{
-						throw new RuntimeException("Nested effects");
+						attachFunc(n, template, name, condition);
 					}
-					attachEffect(n, template, condition, effectScope);
-					break;
 				}
 			}
 		}
 	}
 	
-	protected void attachFunc(Node n, Object template, String name, Condition attachCond)
+	protected void attachFunc(Node n, Object template, String functionName, Condition attachCond)
 	{
 		Stats stat = Stats.valueOfXml(n.getAttributes().getNamedItem("stat").getNodeValue());
-		String order = n.getAttributes().getNamedItem("order").getNodeValue();
+		int order = -1;
+		final Node orderNode = n.getAttributes().getNamedItem("order");
+		if (orderNode != null)
+		{
+			order = Integer.parseInt(orderNode.getNodeValue());
+		}
+		
 		String valueString = n.getAttributes().getNamedItem("val").getNodeValue();
 		double value;
 		if (valueString.charAt(0) == '#')
@@ -292,9 +273,8 @@ public abstract class DocumentBase
 			value = Double.parseDouble(valueString);
 		}
 		
-		final int ord = Integer.decode(getValue(order, template));
 		final Condition applayCond = parseCondition(n.getFirstChild(), template);
-		final FuncTemplate ft = new FuncTemplate(attachCond, applayCond, name, stat, ord, value);
+		final FuncTemplate ft = new FuncTemplate(attachCond, applayCond, functionName, order, stat, value);
 		if (template instanceof L2Item)
 		{
 			((L2Item) template).attach(ft);

+ 53 - 0
L2J_Server/java/com/l2jserver/gameserver/enums/StatFunction.java

@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2004-2014 L2J Server
+ * 
+ * This file is part of L2J Server.
+ * 
+ * L2J Server 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.
+ * 
+ * L2J Server 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.enums;
+
+/**
+ * @author Zealar
+ */
+public enum StatFunction
+{
+	ADD("Add", 30),
+	DIV("Div", 20),
+	ENCHANT("Enchant", 0),
+	ENCHANTHP("EnchantHp", 40),
+	MUL("Mul", 20),
+	SET("Set", 0),
+	SHARE("Share", 30),
+	SUB("Sub", 30);
+	
+	String name;
+	int order;
+	
+	StatFunction(String name, int order)
+	{
+		this.name = name;
+		this.order = order;
+	}
+	
+	public String getName()
+	{
+		return name;
+	}
+	
+	public int getOrder()
+	{
+		return order;
+	}
+}

+ 13 - 3
L2J_Server/java/com/l2jserver/gameserver/model/stats/functions/FuncTemplate.java

@@ -21,6 +21,7 @@ package com.l2jserver.gameserver.model.stats.functions;
 import java.lang.reflect.Constructor;
 import java.util.logging.Logger;
 
+import com.l2jserver.gameserver.enums.StatFunction;
 import com.l2jserver.gameserver.model.actor.L2Character;
 import com.l2jserver.gameserver.model.conditions.Condition;
 import com.l2jserver.gameserver.model.items.instance.L2ItemInstance;
@@ -42,17 +43,26 @@ public final class FuncTemplate
 	private final int _order;
 	private final double _value;
 	
-	public FuncTemplate(Condition attachCond, Condition applayCond, String functionName, Stats stat, int order, double value)
+	public FuncTemplate(Condition attachCond, Condition applayCond, String functionName, int order, Stats stat, double value)
 	{
+		final StatFunction function = StatFunction.valueOf(functionName.toUpperCase());
+		if (order >= 0)
+		{
+			_order = order;
+		}
+		else
+		{
+			_order = function.getOrder();
+		}
+		
 		_attachCond = attachCond;
 		_applayCond = applayCond;
 		_stat = stat;
-		_order = order;
 		_value = value;
 		
 		try
 		{
-			final Class<?> functionClass = Class.forName("com.l2jserver.gameserver.model.stats.functions.Func" + functionName);
+			final Class<?> functionClass = Class.forName("com.l2jserver.gameserver.model.stats.functions.Func" + function.getName());
 			_constructor = functionClass.getConstructor(new Class<?>[]
 			{
 				// Stats to update

+ 1 - 1
L2J_Server/java/com/l2jserver/gameserver/model/stats/functions/formulas/FuncArmorSet.java

@@ -48,7 +48,7 @@ public class FuncArmorSet extends AbstractFunction
 	
 	private FuncArmorSet(Stats stat)
 	{
-		super(stat, 0x10, null, 0, null);
+		super(stat, 10, null, 0, null);
 	}
 	
 	@Override

+ 1 - 1
L2J_Server/java/com/l2jserver/gameserver/model/stats/functions/formulas/FuncAtkAccuracy.java

@@ -37,7 +37,7 @@ public class FuncAtkAccuracy extends AbstractFunction
 	
 	private FuncAtkAccuracy()
 	{
-		super(Stats.ACCURACY_COMBAT, 0x10, null, 0, null);
+		super(Stats.ACCURACY_COMBAT, 10, null, 0, null);
 	}
 	
 	@Override

+ 1 - 1
L2J_Server/java/com/l2jserver/gameserver/model/stats/functions/formulas/FuncAtkCritical.java

@@ -38,7 +38,7 @@ public class FuncAtkCritical extends AbstractFunction
 	
 	private FuncAtkCritical()
 	{
-		super(Stats.CRITICAL_RATE, 0x09, null, 0, null);
+		super(Stats.CRITICAL_RATE, 10, null, 0, null);
 	}
 	
 	@Override

+ 1 - 1
L2J_Server/java/com/l2jserver/gameserver/model/stats/functions/formulas/FuncAtkEvasion.java

@@ -37,7 +37,7 @@ public class FuncAtkEvasion extends AbstractFunction
 	
 	private FuncAtkEvasion()
 	{
-		super(Stats.EVASION_RATE, 0x10, null, 0, null);
+		super(Stats.EVASION_RATE, 10, null, 0, null);
 	}
 	
 	@Override

+ 1 - 1
L2J_Server/java/com/l2jserver/gameserver/model/stats/functions/formulas/FuncGatesMDefMod.java

@@ -39,7 +39,7 @@ public class FuncGatesMDefMod extends AbstractFunction
 	
 	private FuncGatesMDefMod()
 	{
-		super(Stats.MAGIC_DEFENCE, 0x20, null, 0, null);
+		super(Stats.MAGIC_DEFENCE, 10, null, 0, null);
 	}
 	
 	@Override

+ 1 - 1
L2J_Server/java/com/l2jserver/gameserver/model/stats/functions/formulas/FuncGatesPDefMod.java

@@ -39,7 +39,7 @@ public class FuncGatesPDefMod extends AbstractFunction
 	
 	private FuncGatesPDefMod()
 	{
-		super(Stats.POWER_DEFENCE, 0x20, null, 0, null);
+		super(Stats.POWER_DEFENCE, 10, null, 0, null);
 	}
 	
 	@Override

+ 1 - 1
L2J_Server/java/com/l2jserver/gameserver/model/stats/functions/formulas/FuncHenna.java

@@ -45,7 +45,7 @@ public class FuncHenna extends AbstractFunction
 	
 	private FuncHenna(Stats stat)
 	{
-		super(stat, 0x10, null, 0, null);
+		super(stat, 10, null, 0, null);
 	}
 	
 	@Override

+ 1 - 1
L2J_Server/java/com/l2jserver/gameserver/model/stats/functions/formulas/FuncMAtkCritical.java

@@ -38,7 +38,7 @@ public class FuncMAtkCritical extends AbstractFunction
 	
 	private FuncMAtkCritical()
 	{
-		super(Stats.MCRITICAL_RATE, 0x09, null, 0, null);
+		super(Stats.MCRITICAL_RATE, 10, null, 0, null);
 	}
 	
 	@Override

+ 1 - 1
L2J_Server/java/com/l2jserver/gameserver/model/stats/functions/formulas/FuncMAtkMod.java

@@ -38,7 +38,7 @@ public class FuncMAtkMod extends AbstractFunction
 	
 	private FuncMAtkMod()
 	{
-		super(Stats.MAGIC_ATTACK, 0x20, null, 0, null);
+		super(Stats.MAGIC_ATTACK, 10, null, 0, null);
 	}
 	
 	@Override

+ 1 - 1
L2J_Server/java/com/l2jserver/gameserver/model/stats/functions/formulas/FuncMAtkSpeed.java

@@ -38,7 +38,7 @@ public class FuncMAtkSpeed extends AbstractFunction
 	
 	private FuncMAtkSpeed()
 	{
-		super(Stats.MAGIC_ATTACK_SPEED, 0x20, null, 0, null);
+		super(Stats.MAGIC_ATTACK_SPEED, 10, null, 0, null);
 	}
 	
 	@Override

+ 1 - 1
L2J_Server/java/com/l2jserver/gameserver/model/stats/functions/formulas/FuncMDefMod.java

@@ -40,7 +40,7 @@ public class FuncMDefMod extends AbstractFunction
 	
 	private FuncMDefMod()
 	{
-		super(Stats.MAGIC_DEFENCE, 0x20, null, 0, null);
+		super(Stats.MAGIC_DEFENCE, 1, null, 0, null);
 	}
 	
 	@Override

+ 1 - 1
L2J_Server/java/com/l2jserver/gameserver/model/stats/functions/formulas/FuncMaxCpMul.java

@@ -38,7 +38,7 @@ public class FuncMaxCpMul extends AbstractFunction
 	
 	private FuncMaxCpMul()
 	{
-		super(Stats.MAX_CP, 0x20, null, 0, null);
+		super(Stats.MAX_CP, 10, null, 0, null);
 	}
 	
 	@Override

+ 1 - 1
L2J_Server/java/com/l2jserver/gameserver/model/stats/functions/formulas/FuncMaxHpMul.java

@@ -38,7 +38,7 @@ public class FuncMaxHpMul extends AbstractFunction
 	
 	private FuncMaxHpMul()
 	{
-		super(Stats.MAX_HP, 0x20, null, 0, null);
+		super(Stats.MAX_HP, 10, null, 0, null);
 	}
 	
 	@Override

+ 1 - 1
L2J_Server/java/com/l2jserver/gameserver/model/stats/functions/formulas/FuncMaxMpMul.java

@@ -38,7 +38,7 @@ public class FuncMaxMpMul extends AbstractFunction
 	
 	private FuncMaxMpMul()
 	{
-		super(Stats.MAX_MP, 0x20, null, 0, null);
+		super(Stats.MAX_MP, 10, null, 0, null);
 	}
 	
 	@Override

+ 1 - 1
L2J_Server/java/com/l2jserver/gameserver/model/stats/functions/formulas/FuncMoveSpeed.java

@@ -38,7 +38,7 @@ public class FuncMoveSpeed extends AbstractFunction
 	
 	private FuncMoveSpeed()
 	{
-		super(Stats.MOVE_SPEED, 0x30, null, 0, null);
+		super(Stats.MOVE_SPEED, 10, null, 0, null);
 	}
 	
 	@Override

+ 1 - 1
L2J_Server/java/com/l2jserver/gameserver/model/stats/functions/formulas/FuncPAtkMod.java

@@ -38,7 +38,7 @@ public class FuncPAtkMod extends AbstractFunction
 	
 	private FuncPAtkMod()
 	{
-		super(Stats.POWER_ATTACK, 0x30, null, 0, null);
+		super(Stats.POWER_ATTACK, 10, null, 0, null);
 	}
 	
 	@Override

+ 1 - 1
L2J_Server/java/com/l2jserver/gameserver/model/stats/functions/formulas/FuncPAtkSpeed.java

@@ -38,7 +38,7 @@ public class FuncPAtkSpeed extends AbstractFunction
 	
 	private FuncPAtkSpeed()
 	{
-		super(Stats.POWER_ATTACK_SPEED, 0x20, null, 0, null);
+		super(Stats.POWER_ATTACK_SPEED, 10, null, 0, null);
 	}
 	
 	@Override

+ 1 - 1
L2J_Server/java/com/l2jserver/gameserver/model/stats/functions/formulas/FuncPDefMod.java

@@ -40,7 +40,7 @@ public class FuncPDefMod extends AbstractFunction
 	
 	private FuncPDefMod()
 	{
-		super(Stats.POWER_DEFENCE, 0x20, null, 0, null);
+		super(Stats.POWER_DEFENCE, 1, null, 0, null);
 	}
 	
 	@Override