Просмотр исходного кода

- Added AttributeType enum to make code more readable.
- Renamed "element" to "attributeType" and "elementPower" to
"attributePower";
- Fixed some skills with wrong attribute parameters.

Adry85 7 лет назад
Родитель
Сommit
fba965be41

+ 47 - 0
src/main/java/com/l2jserver/gameserver/model/skills/AttributeType.java

@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2004-2018 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.model.skills;
+
+/**
+ * Attribute type enumerate.
+ * @author Adry_85
+ * @since 2.6.0.0
+ */
+public enum AttributeType
+{
+	NONE(-2),
+	FIRE(0),
+	WATER(1),
+	WIND(2),
+	EARTH(3),
+	HOLY(4),
+	DARK(5);
+	
+	private final byte _id;
+	
+	AttributeType(int id)
+	{
+		_id = (byte) id;
+	}
+	
+	public byte getId()
+	{
+		return _id;
+	}
+}

+ 10 - 16
src/main/java/com/l2jserver/gameserver/model/skills/Skill.java

@@ -153,13 +153,10 @@ public class Skill implements IIdentifiable
 	
 	private final boolean _nextActionIsAttack;
 	
-	private final boolean _removedOnAnyActionExceptMove;
-	private final boolean _removedOnDamage;
-	
 	private final boolean _blockedInOlympiad;
 	
-	private final byte _element;
-	private final int _elementPower;
+	private final AttributeType _attributeType;
+	private final int _attributePower;
 	
 	private final BaseStats _basicProperty;
 	
@@ -308,13 +305,10 @@ public class Skill implements IIdentifiable
 		
 		_nextActionIsAttack = set.getBoolean("nextActionAttack", false);
 		
-		_removedOnAnyActionExceptMove = (_abnormalType == AbnormalType.INVINCIBILITY) || (_abnormalType == AbnormalType.HIDE);
-		_removedOnDamage = (_abnormalType == AbnormalType.SLEEP) || (_abnormalType == AbnormalType.FORCE_MEDITATION) || (_abnormalType == AbnormalType.HIDE);
-		
 		_blockedInOlympiad = set.getBoolean("blockedInOlympiad", false);
 		
-		_element = set.getByte("element", (byte) -1);
-		_elementPower = set.getInt("elementPower", 0);
+		_attributeType = set.getEnum("attributeType", AttributeType.class, AttributeType.NONE);
+		_attributePower = set.getInt("attributePower", 0);
 		
 		_basicProperty = set.getEnum("basicProperty", BaseStats.class, BaseStats.NONE);
 		
@@ -357,14 +351,14 @@ public class Skill implements IIdentifiable
 		return _traitType;
 	}
 	
-	public byte getElement()
+	public AttributeType getAttributeType()
 	{
-		return _element;
+		return _attributeType;
 	}
 	
-	public int getElementPower()
+	public int getAttributePower()
 	{
-		return _elementPower;
+		return _attributePower;
 	}
 	
 	/**
@@ -552,7 +546,7 @@ public class Skill implements IIdentifiable
 	 */
 	public boolean isRemovedOnAnyActionExceptMove()
 	{
-		return _removedOnAnyActionExceptMove;
+		return (_abnormalType == AbnormalType.INVINCIBILITY) || (_abnormalType == AbnormalType.HIDE);
 	}
 	
 	/**
@@ -560,7 +554,7 @@ public class Skill implements IIdentifiable
 	 */
 	public boolean isRemovedOnDamage()
 	{
-		return _removedOnDamage;
+		return (_abnormalType == AbnormalType.SLEEP) || (_abnormalType == AbnormalType.FORCE_MEDITATION) || (_abnormalType == AbnormalType.HIDE);
 	}
 	
 	/**

+ 3 - 2
src/main/java/com/l2jserver/gameserver/model/stats/Formulas.java

@@ -53,6 +53,7 @@ import com.l2jserver.gameserver.model.items.L2Item;
 import com.l2jserver.gameserver.model.items.L2Weapon;
 import com.l2jserver.gameserver.model.items.type.ArmorType;
 import com.l2jserver.gameserver.model.items.type.WeaponType;
+import com.l2jserver.gameserver.model.skills.AttributeType;
 import com.l2jserver.gameserver.model.skills.BuffInfo;
 import com.l2jserver.gameserver.model.skills.Skill;
 import com.l2jserver.gameserver.model.stats.functions.formulas.FuncArmorSet;
@@ -1701,11 +1702,11 @@ public final class Formulas
 		int attack_attribute;
 		if (skill != null)
 		{
-			if ((skill.getElement() == -1) || (attacker.getAttackElement() != skill.getElement()))
+			if ((skill.getAttributeType() == AttributeType.NONE) || (attacker.getAttackElement() != skill.getAttributeType().getId()))
 			{
 				return 1;
 			}
-			attack_attribute = attacker.getAttackElementValue(attacker.getAttackElement()) + skill.getElementPower();
+			attack_attribute = attacker.getAttackElementValue(attacker.getAttackElement()) + skill.getAttributePower();
 		}
 		else
 		{