|
|
@ -2,6 +2,7 @@ package engine.objects; |
|
|
|
|
|
|
|
|
|
|
|
import engine.Enum; |
|
|
|
import engine.Enum; |
|
|
|
import engine.powers.effectmodifiers.AbstractEffectModifier; |
|
|
|
import engine.powers.effectmodifiers.AbstractEffectModifier; |
|
|
|
|
|
|
|
import engine.server.MBServerStatics; |
|
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.HashMap; |
|
|
@ -159,7 +160,7 @@ public class PlayerCombatStats { |
|
|
|
this.atrHandOne = 0.0f; |
|
|
|
this.atrHandOne = 0.0f; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} //perfect DO NOT TOUCH
|
|
|
|
|
|
|
|
|
|
|
|
public void calculateMin(boolean mainHand) { |
|
|
|
public void calculateMin(boolean mainHand) { |
|
|
|
Item weapon; |
|
|
|
Item weapon; |
|
|
@ -386,104 +387,105 @@ public class PlayerCombatStats { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void calculateDefense() { |
|
|
|
public void calculateDefense() { |
|
|
|
int armorDefense = 0; |
|
|
|
//Defense = (1+Armor skill / 50) * Armor defense + (1 + Block skill / 100) * Shield defense + (Primary weapon skill / 2)
|
|
|
|
int shieldDefense = 0; |
|
|
|
// + (Weapon mastery skill/ 2) + Dexterity * 2 + Flat bonuses from rings or cloth
|
|
|
|
int dexterity = this.owner.statDexCurrent; |
|
|
|
float armorSkill = this.owner.skills.get(this.owner.charItemManager.getEquipped(MBServerStatics.SLOT_CHEST)).getTotalSkillPercet(); |
|
|
|
double armorSkill = 0; |
|
|
|
float armorDefense = 0.0f; |
|
|
|
double blockSkill = 0; |
|
|
|
for(Item equipped : this.owner.charItemManager.getEquipped().values()){ |
|
|
|
double weaponSkill = 0; |
|
|
|
ItemBase ib = equipped.getItemBase(); |
|
|
|
double weaponMastery = 0; |
|
|
|
if(ib.isHeavyArmor() || ib.isMediumArmor() || ib.isLightArmor() || ib.isClothArmor()){ |
|
|
|
|
|
|
|
armorDefense += ib.getDefense(); |
|
|
|
//armor defense value need to loop all equipped items and log armor defense values
|
|
|
|
for(Effect eff : equipped.effects.values()){ |
|
|
|
ArrayList<String> armorTypes = new ArrayList<>(); |
|
|
|
for(AbstractEffectModifier mod : eff.getEffectModifiers()){ |
|
|
|
if (this.owner.charItemManager != null) { |
|
|
|
if(mod.modType.equals(Enum.ModType.DR)){ |
|
|
|
for (Item equipped : this.owner.charItemManager.getEquippedList()) { |
|
|
|
armorDefense += mod.minMod + (mod.getRamp() * eff.getTrains()); |
|
|
|
if (equipped.getItemBase().isHeavyArmor()) { |
|
|
|
|
|
|
|
armorDefense += equipped.getItemBase().getDefense(); |
|
|
|
|
|
|
|
if (!armorTypes.contains(equipped.getItemBase().getSkillRequired())) |
|
|
|
|
|
|
|
armorTypes.add(equipped.getItemBase().getSkillRequired()); |
|
|
|
|
|
|
|
} else if (equipped.getItemBase().isLightArmor()) { |
|
|
|
|
|
|
|
armorDefense += equipped.getItemBase().getDefense(); |
|
|
|
|
|
|
|
if (!armorTypes.contains(equipped.getItemBase().getSkillRequired())) |
|
|
|
|
|
|
|
armorTypes.add(equipped.getItemBase().getSkillRequired()); |
|
|
|
|
|
|
|
} else if (equipped.getItemBase().isMediumArmor()) { |
|
|
|
|
|
|
|
armorDefense += equipped.getItemBase().getDefense(); |
|
|
|
|
|
|
|
if (!armorTypes.contains(equipped.getItemBase().getSkillRequired())) |
|
|
|
|
|
|
|
armorTypes.add(equipped.getItemBase().getSkillRequired()); |
|
|
|
|
|
|
|
} else if (equipped.getItemBase().isClothArmor()) { |
|
|
|
|
|
|
|
armorDefense += equipped.getItemBase().getDefense(); |
|
|
|
|
|
|
|
} else if (equipped.getItemBase().isShield()) { |
|
|
|
|
|
|
|
shieldDefense += equipped.getItemBase().getDefense(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//armor skill needs to calculate all trains in armor types
|
|
|
|
|
|
|
|
for (String armorType : armorTypes) { |
|
|
|
|
|
|
|
if (this.owner.skills != null) { |
|
|
|
|
|
|
|
if (this.owner.skills.containsKey(armorType)) { |
|
|
|
|
|
|
|
armorSkill += this.owner.skills.get(armorType).getModifiedAmount(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
float blockSkill = 0.0f; |
|
|
|
|
|
|
|
if(this.owner.skills.containsKey("Block")) |
|
|
|
|
|
|
|
blockSkill = this.owner.skills.get("Block").getTotalSkillPercet(); |
|
|
|
|
|
|
|
|
|
|
|
if (this.owner.skills.containsKey("Block")) { |
|
|
|
float shieldDefense = 0.0f; |
|
|
|
blockSkill = this.owner.skills.get("Block").getModifiedAmount(); |
|
|
|
if(this.owner.charItemManager.getEquipped(2) != null && this.owner.charItemManager.getEquipped(2).getItemBase().isShield()){ |
|
|
|
|
|
|
|
Item shield = this.owner.charItemManager.getEquipped(2); |
|
|
|
|
|
|
|
shieldDefense += shield.getItemBase().getDefense(); |
|
|
|
|
|
|
|
for(Effect eff : shield.effects.values()){ |
|
|
|
|
|
|
|
for(AbstractEffectModifier mod : eff.getEffectModifiers()){ |
|
|
|
|
|
|
|
if(mod.modType.equals(Enum.ModType.DR)){ |
|
|
|
|
|
|
|
shieldDefense += mod.minMod + (mod.getRamp() * eff.getTrains()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
String primarySkillName = "Unarmed Combat"; |
|
|
|
float weaponSkill = 0.0f; |
|
|
|
String primaryMasteryName = "Unarmed Combat Mastery"; |
|
|
|
float masterySkill = 0.0f; |
|
|
|
Item weapon = this.owner.charItemManager.getEquipped(1); |
|
|
|
Item weapon = this.owner.charItemManager.getEquipped(1); |
|
|
|
if (weapon == null) { |
|
|
|
if(weapon == null){ |
|
|
|
weapon = this.owner.charItemManager.getEquipped(2); |
|
|
|
weapon = this.owner.charItemManager.getEquipped(2); |
|
|
|
} |
|
|
|
} |
|
|
|
if (weapon != null) { |
|
|
|
if(weapon != null && !weapon.getItemBase().isShield()) |
|
|
|
primarySkillName = weapon.getItemBase().getSkillRequired(); |
|
|
|
weapon = null; |
|
|
|
primaryMasteryName = weapon.getItemBase().getMastery(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (this.owner.skills != null) { |
|
|
|
String skillName = "Unarmed Combat"; |
|
|
|
if (this.owner.skills.containsKey(primarySkillName)) { |
|
|
|
String masteryName = "Unarmed Combat Mastery"; |
|
|
|
weaponSkill = this.owner.skills.get(primarySkillName).getModifiedAmount(); |
|
|
|
|
|
|
|
} |
|
|
|
if(weapon != null){ |
|
|
|
if (this.owner.skills.containsKey(primaryMasteryName)) { |
|
|
|
skillName = weapon.getItemBase().getSkillRequired(); |
|
|
|
weaponMastery = this.owner.skills.get(primaryMasteryName).getModifiedAmount(); |
|
|
|
masteryName = weapon.getItemBase().getMastery(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if(this.owner.skills.containsKey(skillName)) |
|
|
|
|
|
|
|
weaponSkill = this.owner.skills.get(skillName).getTotalSkillPercet(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(this.owner.skills.containsKey(masteryName)) |
|
|
|
|
|
|
|
masterySkill = this.owner.skills.get(masteryName).getTotalSkillPercet(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
float dexterity = this.owner.statDexBase; |
|
|
|
|
|
|
|
dexterity += this.owner.bonuses.getFloat(Enum.ModType.Attr, Enum.SourceType.Dexterity); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
float luckyRune = 1.0f; |
|
|
|
|
|
|
|
for(CharacterRune rune : this.owner.runes){ |
|
|
|
|
|
|
|
if(rune.getRuneBase().getName().equals("Lucky")) |
|
|
|
|
|
|
|
luckyRune += 0.05f; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
float stanceValue = 0.0f; |
|
|
|
float flatBonuses = 0.0f; |
|
|
|
float bonusValues = 0; |
|
|
|
float stanceMod = 1.0f; |
|
|
|
float percentBonus = 0; |
|
|
|
for(String effID : this.owner.effects.keySet()) { |
|
|
|
if (this.owner.bonuses != null) { |
|
|
|
|
|
|
|
for (String effID : this.owner.effects.keySet()) { |
|
|
|
|
|
|
|
if (effID.contains("Stance")) { |
|
|
|
if (effID.contains("Stance")) { |
|
|
|
if (this.owner.effects != null) { |
|
|
|
|
|
|
|
for (AbstractEffectModifier mod : this.owner.effects.get(effID).getEffectModifiers()) { |
|
|
|
for (AbstractEffectModifier mod : this.owner.effects.get(effID).getEffectModifiers()) { |
|
|
|
if (mod.modType.equals(Enum.ModType.DCV)) { |
|
|
|
if (mod.modType.equals(Enum.ModType.OCV)) { |
|
|
|
float percent = mod.getPercentMod(); |
|
|
|
float percent = mod.getPercentMod(); |
|
|
|
int trains = this.owner.effects.get(effID).getTrains(); |
|
|
|
int trains = this.owner.effects.get(effID).getTrains(); |
|
|
|
float modValue = percent + (trains * mod.getRamp()); |
|
|
|
float modValue = percent + (trains * mod.getRamp()); |
|
|
|
stanceValue += modValue * 0.01f; |
|
|
|
stanceMod += modValue * 0.01f; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
for (AbstractEffectModifier mod : this.owner.effects.get(effID).getEffectModifiers()) { |
|
|
|
|
|
|
|
if (mod.modType.equals(Enum.ModType.OCV)) { |
|
|
|
|
|
|
|
float value = mod.getMinMod(); |
|
|
|
|
|
|
|
int trains = this.owner.effects.get(effID).getTrains(); |
|
|
|
|
|
|
|
float modValue = value + (trains * mod.getRamp()); |
|
|
|
|
|
|
|
flatBonuses += modValue; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
bonusValues = this.owner.bonuses.getFloat(Enum.ModType.DCV, Enum.SourceType.None); |
|
|
|
|
|
|
|
percentBonus = this.owner.bonuses.getFloatPercentAll(Enum.ModType.DCV, Enum.SourceType.None) - stanceValue; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
double defense = (1 + armorSkill / 50.0) * armorDefense + |
|
|
|
float defense = (1 + armorDefense/ 50) * armorDefense; |
|
|
|
(1 + blockSkill / 100.0) * shieldDefense + |
|
|
|
defense += (1 + blockSkill / 100) * shieldDefense; |
|
|
|
(weaponSkill / 2.0) + |
|
|
|
defense += (weaponSkill / 2); |
|
|
|
(weaponMastery / 2.0) + |
|
|
|
defense += (masterySkill / 2); |
|
|
|
dexterity * 2.0 + |
|
|
|
defense += dexterity * 2; |
|
|
|
bonusValues; |
|
|
|
defense *= luckyRune; |
|
|
|
defense *= 1.0f + percentBonus + stanceValue; |
|
|
|
defense += flatBonuses; |
|
|
|
//defense *= 1.0f + stanceValue;
|
|
|
|
defense *= stanceMod; |
|
|
|
defense = Math.round(defense); |
|
|
|
|
|
|
|
this.defense = (int) defense; |
|
|
|
this.defense = Math.round(defense); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|