Browse Source

PlayerCombatStats dex penalty applied correctly

lakebane-dex-penalty
FatBoy-DOTC 4 days ago
parent
commit
69e2630d77
  1. 15
      src/engine/db/handlers/dbItemBaseHandler.java
  2. 8
      src/engine/objects/ItemBase.java
  3. 41
      src/engine/objects/PlayerCombatStats.java

15
src/engine/db/handlers/dbItemBaseHandler.java

@ -45,6 +45,21 @@ public class dbItemBaseHandler extends dbHandlerBase { @@ -45,6 +45,21 @@ public class dbItemBaseHandler extends dbHandlerBase {
}
}
public void LOAD_DEX_REDUCTION(ItemBase itemBase) {
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `static_item_dexpenalty` WHERE `ID` = ?")) {
preparedStatement.setInt(1, itemBase.getUUID());
ResultSet rs = preparedStatement.executeQuery();
itemBase.dexReduction = rs.getFloat("item_bulk_factor");
} catch (SQLException e) {
Logger.error(e);
}
}
public void LOAD_ANIMATIONS(ItemBase itemBase) {
ArrayList<Integer> tempList = new ArrayList<>();

8
src/engine/objects/ItemBase.java

@ -76,6 +76,8 @@ public class ItemBase { @@ -76,6 +76,8 @@ public class ItemBase {
private ArrayList<Integer> animations = new ArrayList<>();
private ArrayList<Integer> offHandAnimations = new ArrayList<>();
public float dexReduction = 0.0f;
/**
* ResultSet Constructor
*/
@ -151,7 +153,7 @@ public class ItemBase { @@ -151,7 +153,7 @@ public class ItemBase {
}
initBakedInStats();
initializeHashes();
initDexReduction();
}
public static void addToCache(ItemBase itemBase) {
@ -319,6 +321,10 @@ public class ItemBase { @@ -319,6 +321,10 @@ public class ItemBase {
DbManager.ItemBaseQueries.LOAD_BAKEDINSTATS(this);
}
private void initDexReduction(){
DbManager.ItemBaseQueries.LOAD_DEX_REDUCTION(this);
}
//TODO fix this later. Shouldn't be gotten from item base
public int getMagicValue() {
return this.value;

41
src/engine/objects/PlayerCombatStats.java

@ -110,7 +110,7 @@ public class PlayerCombatStats { @@ -110,7 +110,7 @@ public class PlayerCombatStats {
String skill = "Unarmed Combat";
String mastery = "Unarmed Combat Mastery";
int primaryStat = this.owner.statDexCurrent;
int primaryStat = getDexAfterPenalty(this.owner);
if(weapon != null) {
skill= weapon.getItemBase().getSkillRequired();
mastery = weapon.getItemBase().getMastery();
@ -185,8 +185,7 @@ public class PlayerCombatStats { @@ -185,8 +185,7 @@ public class PlayerCombatStats {
atr += 1;
atr = (float) Math.ceil(atr);
}else {
float dexterity = this.owner.statDexBase;
dexterity += this.owner.bonuses.getFloat(Enum.ModType.Attr, Enum.SourceType.Dexterity);
float dexterity = getDexAfterPenalty(this.owner);
atr = dexterity / 2;
atr += skillLevel * 4;
atr += masteryLevel * 3;
@ -215,7 +214,7 @@ public class PlayerCombatStats { @@ -215,7 +214,7 @@ public class PlayerCombatStats {
public void calculateMin(boolean mainHand) {
Item weapon;
float baseDMG = 1;
int primaryStat = this.owner.statDexCurrent;
int primaryStat = getDexAfterPenalty(this.owner);
int secondaryStat = this.owner.statStrCurrent;
double weaponSkill = 5;
double weaponMastery = 5;
@ -235,7 +234,7 @@ public class PlayerCombatStats { @@ -235,7 +234,7 @@ public class PlayerCombatStats {
mastery = weapon.getItemBase().getMastery();
if (weapon.getItemBase().isStrBased()) {
primaryStat = this.owner.statStrCurrent;
secondaryStat = this.owner.statDexCurrent;
secondaryStat = getDexAfterPenalty(this.owner);
}
for(Effect eff : weapon.effects.values()){
for(AbstractEffectModifier mod : eff.getEffectModifiers()){
@ -292,7 +291,7 @@ public class PlayerCombatStats { @@ -292,7 +291,7 @@ public class PlayerCombatStats {
// + 0.0022*Secondary Stat + 0.028*(Secondary Stat-0.75)^0.5 + 0.0075*(Weapon Skill + Weapon Mastery))
Item weapon;
double baseDMG = 5;
int primaryStat = this.owner.statDexCurrent;
int primaryStat = getDexAfterPenalty(this.owner);
int secondaryStat = this.owner.statStrCurrent;
double weaponSkill = 5;
double weaponMastery = 5;
@ -311,7 +310,7 @@ public class PlayerCombatStats { @@ -311,7 +310,7 @@ public class PlayerCombatStats {
mastery = weapon.getItemBase().getMastery();
if (weapon.getItemBase().isStrBased()) {
primaryStat = this.owner.statStrCurrent;
secondaryStat = this.owner.statDexCurrent;
secondaryStat = getDexAfterPenalty(this.owner);
}
for(Effect eff : weapon.effects.values()){
for(AbstractEffectModifier mod : eff.getEffectModifiers()){
@ -541,7 +540,7 @@ public class PlayerCombatStats { @@ -541,7 +540,7 @@ public class PlayerCombatStats {
if(this.owner.skills.containsKey(masteryName))
masterySkill = this.owner.skills.get(masteryName).getModifiedAmount();
float dexterity = this.owner.statDexCurrent;//this.owner.statDexBase;
float dexterity = getDexAfterPenalty(this.owner);
//dexterity += this.owner.bonuses.getFloat(Enum.ModType.Attr, Enum.SourceType.Dexterity);
float luckyRune = 1.0f;
@ -616,7 +615,7 @@ public class PlayerCombatStats { @@ -616,7 +615,7 @@ public class PlayerCombatStats {
if (skillBase.getStrMod() > 0)
statMod += (float) skillBase.getStrMod() * (float) pc.getStatStrCurrent() / 100f;
if (skillBase.getDexMod() > 0)
statMod += (float) skillBase.getDexMod() * (float) pc.getStatDexCurrent() / 100f;
statMod += (float) skillBase.getDexMod() * (float) getDexAfterPenalty(pc) / 100f;
if (skillBase.getConMod() > 0)
statMod += (float) skillBase.getConMod() * (float) pc.getStatConCurrent() / 100f;
if (skillBase.getIntMod() > 0)
@ -668,4 +667,28 @@ public class PlayerCombatStats { @@ -668,4 +667,28 @@ public class PlayerCombatStats {
return modifiedAmount;
}
public static int getDexAfterPenalty(PlayerCharacter pc){
if(pc.charItemManager == null)
return pc.statDexCurrent;
float dex = pc.statDexBase;
if(pc.bonuses != null)
dex += pc.bonuses.getFloat(Enum.ModType.Attr, Enum.SourceType.Dexterity);
float penaltyFactor = 0.0f;
for(Item equipped : pc.charItemManager.getEquipped().values()){
ItemBase ib = equipped.getItemBase();
if(ib.isHeavyArmor() || ib.isLightArmor() || ib.isMediumArmor()){
penaltyFactor += (ib.dexReduction);
}
}
if(penaltyFactor > 0)
penaltyFactor *= 0.01f;
float totalPenalty = dex * (1 + penaltyFactor);
return Math.round(dex - totalPenalty);
}
}

Loading…
Cancel
Save