Skip to content

Commit

Permalink
Make sure divinity damages done via Fabled actually get scaled properly
Browse files Browse the repository at this point in the history
  • Loading branch information
Travja committed Feb 21, 2025
1 parent 30d1b9c commit a83d198
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,27 @@ public Start(
}
}

public static class BeforeScale extends DivinityDamageEvent {

public BeforeScale(
@NotNull LivingEntity zertva,
@Nullable LivingEntity damager,
@Nullable Projectile projectile,
@NotNull Map<DamageAttribute, Double> damageMap,
@NotNull Map<DefenseAttribute, Double> defenseMap,
@NotNull Map<SimpleStat.Type, Double> statsMap,
@NotNull EntityDamageEvent eventOrig,
@NotNull DamageMeta meta,
boolean exempt
) {
super(zertva, damager, projectile, eventOrig, meta);
this.damageMap = damageMap;
this.defenseMap = defenseMap;
this.damagerItemStatsMap = statsMap;
this.exempt = exempt;
}
}

/**
* Called at the start of Damage Event, before damage calculations.
* This is the second QuantumDamageEvent instance.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,7 @@ public boolean dealDamage(@NotNull LivingEntity entity,
final boolean[] success = {false};
Listener listener = new Listener() {
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onDamage(DivinityDamageEvent.Start event) {
public void onDamage(DivinityDamageEvent.BeforeScale event) {
if (event.getOriginalEvent().getEntity() != entity) return;
Map<DamageAttribute, Double> damageMap = event.getDamageMap();
damageMap.clear();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,20 @@ public void onVanillaDamage(EntityDamageEvent e) {
.forEach((dmgAtt) -> damages.compute(dmgAtt,
(dmgKey, dmgVal) -> (dmgVal != null ? dmgVal : 0) + damageStart2));

DivinityDamageEvent.BeforeScale beforeScale = new DivinityDamageEvent.BeforeScale(victim,
damager,
projectile,
damages,
defenses,
stats,
e,
meta,
skillShouldIgnore);
plugin.getPluginManager().callEvent(beforeScale);
if (beforeScale.isCancelled()) {
return;
}

scaleValuesWithCore(damager, projectile, damages, defenses, victim);

DivinityDamageEvent.Start eventStart = new DivinityDamageEvent.Start(victim,
Expand Down

0 comments on commit a83d198

Please sign in to comment.