Browse Source

epilogue weapon/armor penalty

janiii 15 years ago
parent
commit
53ef1e9c21

+ 61 - 22
L2_GameServer/java/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java

@@ -694,7 +694,8 @@ public final class L2PcInstance extends L2Playable
 
 
 	/** The current higher Expertise of the L2PcInstance (None=0, D=1, C=2, B=3, A=4, S=5, S80=6, S84=7)*/
 	/** The current higher Expertise of the L2PcInstance (None=0, D=1, C=2, B=3, A=4, S=5, S80=6, S84=7)*/
 	private int _expertiseIndex; // index in EXPERTISE_LEVELS
 	private int _expertiseIndex; // index in EXPERTISE_LEVELS
-	private int _expertisePenalty = 0;
+	private int _expertiseArmorPenalty = 0;
+	private int _expertiseWeaponPenalty = 0;
 
 
 	private boolean _isEnchanting = false;
 	private boolean _isEnchanting = false;
 	private L2ItemInstance _activeEnchantItem = null;
 	private L2ItemInstance _activeEnchantItem = null;
@@ -2173,9 +2174,14 @@ public final class L2PcInstance extends L2Playable
 		return (int)calcStat(Stats.MAX_LOAD, baseLoad*Config.ALT_WEIGHT_LIMIT, this, null);
 		return (int)calcStat(Stats.MAX_LOAD, baseLoad*Config.ALT_WEIGHT_LIMIT, this, null);
 	}
 	}
 
 
-	public int getExpertisePenalty()
+	public int getExpertiseArmorPenalty()
 	{
 	{
-		return _expertisePenalty;
+		return _expertiseArmorPenalty;
+	}
+
+	public int getExpertiseWeaponPenalty()
+	{
+		return _expertiseWeaponPenalty;
 	}
 	}
 
 
 	public int getWeightPenalty()
 	public int getWeightPenalty()
@@ -2240,35 +2246,68 @@ public final class L2PcInstance extends L2Playable
 
 
 	public void refreshExpertisePenalty()
 	public void refreshExpertisePenalty()
 	{
 	{
-		int newPenalty = 0;
-
+		int armorPenalty = 0;
+		int weaponPenalty = 0;
+		
 		for (L2ItemInstance item : getInventory().getItems())
 		for (L2ItemInstance item : getInventory().getItems())
 		{
 		{
 			if (item != null && item.isEquipped())
 			if (item != null && item.isEquipped())
 			{
 			{
 				int crystaltype = item.getItem().getCrystalType();
 				int crystaltype = item.getItem().getCrystalType();
-
-				if (crystaltype > newPenalty)
-					newPenalty = crystaltype;
+				
+				if (crystaltype > getExpertiseIndex())
+				{
+					if (item.isWeapon() && crystaltype > weaponPenalty)
+						weaponPenalty = crystaltype;
+					else if (crystaltype > armorPenalty)
+						armorPenalty = crystaltype;
+				}
 			}
 			}
 		}
 		}
-
-		newPenalty = newPenalty - getExpertiseIndex();
-
-		if (newPenalty <= 0)
-            newPenalty = 0;
-
-		if (getExpertisePenalty() != newPenalty)
+		
+		boolean changed = false;
+		
+		// calc armor penalty
+		armorPenalty = armorPenalty - getExpertiseIndex();
+		
+		if (armorPenalty < 0)
+			armorPenalty = 0;
+		else if (armorPenalty > 4)
+			armorPenalty = 4;
+		
+		if (getExpertiseArmorPenalty() != armorPenalty)
 		{
 		{
-			_expertisePenalty = newPenalty;
-
-			if (newPenalty > 0)
-				super.addSkill(SkillTable.getInstance().getInfo(4267, 1)); // level used to be newPenalty
+			_expertiseArmorPenalty = armorPenalty;
+			
+			if (_expertiseArmorPenalty > 0)
+				super.addSkill(SkillTable.getInstance().getInfo(6213, _expertiseArmorPenalty)); // level used to be newPenalty
 			else
 			else
-                super.removeSkill(getKnownSkill(4267));
-
-			sendPacket(new EtcStatusUpdate(this));
+				super.removeSkill(getKnownSkill(6213));
+			
+			changed = true;
 		}
 		}
+		
+		// calc weapon penalty
+		weaponPenalty = weaponPenalty - getExpertiseIndex();
+		if (weaponPenalty < 0)
+			weaponPenalty = 0;
+		else if (weaponPenalty > 4)
+			weaponPenalty = 4;
+		
+		if (getExpertiseWeaponPenalty() != weaponPenalty)
+		{
+			_expertiseWeaponPenalty = weaponPenalty;
+			
+			if (_expertiseWeaponPenalty > 0)
+				super.addSkill(SkillTable.getInstance().getInfo(6209, _expertiseWeaponPenalty)); // level used to be newPenalty
+			else
+				super.removeSkill(getKnownSkill(weaponPenalty));
+			
+			changed = true;
+		}
+		
+		if (changed)
+			sendPacket(new EtcStatusUpdate(this));
 	}
 	}
 
 
     public void checkIfWeaponIsAllowed()
     public void checkIfWeaponIsAllowed()

+ 2 - 2
L2_GameServer/java/com/l2jserver/gameserver/network/serverpackets/EtcStatusUpdate.java

@@ -44,8 +44,8 @@ public class EtcStatusUpdate extends L2GameServerPacket
 		writeD(_activeChar.getWeightPenalty()); // 1-4 weight penalty, lvl (1=50%, 2=66.6%, 3=80%, 4=100%)
 		writeD(_activeChar.getWeightPenalty()); // 1-4 weight penalty, lvl (1=50%, 2=66.6%, 3=80%, 4=100%)
 		writeD((_activeChar.getMessageRefusal() || _activeChar.isChatBanned() || _activeChar.isSilenceMode()) ? 1 : 0); // 1 = block all chat 
 		writeD((_activeChar.getMessageRefusal() || _activeChar.isChatBanned() || _activeChar.isSilenceMode()) ? 1 : 0); // 1 = block all chat 
 		writeD(0x00); // 1 = danger area
 		writeD(0x00); // 1 = danger area
-		writeD(Math.min(_activeChar.getExpertisePenalty(),1)); // 1 = grade penalty - weapon penalty [1-4]
-		writeD(0x00); // Armor Grade Penalty, need to implement it. [1-4]
+		writeD(_activeChar.getExpertiseWeaponPenalty()); // 1 = grade penalty - weapon penalty [1-4]
+		writeD(_activeChar.getExpertiseArmorPenalty()); // Armor Grade Penalty, need to implement it. [1-4]
 		writeD(_activeChar.getCharmOfCourage() ? 1 : 0); // 1 = charm of courage (allows resurrection on the same spot upon death on the siege battlefield)
 		writeD(_activeChar.getCharmOfCourage() ? 1 : 0); // 1 = charm of courage (allows resurrection on the same spot upon death on the siege battlefield)
 		writeD(_activeChar.getDeathPenaltyBuffLevel()); // 1-15 death penalty, lvl (combat ability decreased due to death)
 		writeD(_activeChar.getDeathPenaltyBuffLevel()); // 1-15 death penalty, lvl (combat ability decreased due to death)
         	writeD(_activeChar.getSouls());
         	writeD(_activeChar.getSouls());