Skip to content

Commit

Permalink
Fix #193 - Make 'non-weapon' items apply critical damage as percent p…
Browse files Browse the repository at this point in the history
…roperly
  • Loading branch information
Travja committed Feb 11, 2024
1 parent e0d7f08 commit a61056f
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions src/main/java/su/nightexpress/quantumrpg/stats/EntityStats.java
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,8 @@ private void addBonus(@NotNull BonusMap bMap) {

@NotNull
public List<BiFunction<Boolean, Double, Double>> getBonuses(@NotNull ItemLoreStat<?> stat) {
List<BiFunction<Boolean, Double, Double>> bonuses = new ArrayList<>(this.bonuses.computeIfAbsent(stat, list -> new ArrayList<>()));
List<BiFunction<Boolean, Double, Double>> bonuses =
new ArrayList<>(this.bonuses.computeIfAbsent(stat, list -> new ArrayList<>()));

BonusMap arrowBonus = this.arrowBonus != null ? this.arrowBonus.getBonusMap(this.arrowLevel) : null;
if (arrowBonus != null) {
Expand Down Expand Up @@ -556,7 +557,8 @@ private void applyBonusAttribute(@NotNull NBTAttribute att, double value) {

if (value == 0D) return;

AttributeModifier am = new AttributeModifier(ATTRIBUTE_BONUS_UUID, att.getNmsName(), value, Operation.ADD_NUMBER);
AttributeModifier am =
new AttributeModifier(ATTRIBUTE_BONUS_UUID, att.getNmsName(), value, Operation.ADD_NUMBER);
attInst.addModifier(am);
}

Expand Down Expand Up @@ -693,9 +695,17 @@ public double getItemStat(@NotNull AbstractStat.Type type, boolean safe) {

double statVal = stat.get(item);

if (statVal != 0)
value += statVal
- (type == AbstractStat.Type.CRITICAL_DAMAGE ? 1D : 0);
if (statVal != 0) {
if (type == AbstractStat.Type.CRITICAL_DAMAGE) {
if (!stat.isMainItem(item)) { // This stat should be applied as a percent
value *= (1D + statVal / 100);
} else {
value += statVal - 1D;
}
} else {
value += statVal;
}
}
}

// Get Sets bonuses
Expand Down

0 comments on commit a61056f

Please sign in to comment.