Suggestion Open

Add a setdamage mechanic (or modifydamage action=REPLACE) to set absolute damage values

#6524 opened by Unknown 1 year ago

Unknownreported this suggestion

Summary

It would be very helpful to have a mechanic that sets the event damage to an absolute value in damage-related triggers (e.g., ~onDamaged, ~onBowHit), equivalent to Bukkit’s event.setDamage(double). This avoids the ordering/stacking quirks that can occur when combining multiple modifydamage operations and provides a straightforward, deterministic way to set final damage.

Note: Perhaps even a "REPLACE" modifier could be added to the existing modifyDamage mechanic.

Usage

Option A (new mechanic):

setdamage{amount=<value>[;execution=PRE|POST]}
  • amount: number or placeholder/math expression.
  • execution (optional): whether to apply at PRE/POST stage, similar to existing hooks.

Option B (extend existing): Add action=REPLACE (alias SET) to modifydamage, which sets the absolute damage rather than adding/multiplying:

modifydamage{action=REPLACE;amount=<value>}

Usage examples

  • Set fixed bow hit damage:
setdamage{amount=7.5} ~onBowHit
  • Make damage scale with stats/placeholders:
setdamage{amount="<math.(<stat.ATK_BASE> + <stat.ATK_WEAPON>) * (1 + <stat.ATK_MULT_PCT>/100)>"}
  ~onDamaged

Value

  • Gives pack authors a deterministic way to set final damage, mirroring Bukkit API behavior.
  • Reduces complexity when combining many modifiers and eliminates confusion about operation order.
  • Easier to reason about when integrating external stat systems or custom formulas..

Compatibility / Notes

  • Pure addition: no breaking changes expected.
  • If implemented via modifydamage, REPLACE/SET would be backward compatible with current actions (ADD, MULTIPLY, etc.).
  • Ideally keeps damage metadata/types intact; only the final numeric value is replaced.
  • If clamping is relevant, clamping to >= 0 would be fine.

Priority

From a pack-author perspective this is quite valuable; I’d mark it Enhancement / High, but of course defer to your roadmap.

Implementation

Bukkit API parity: event.setDamage(double val).

Willing to help Happy to test snapshots and provide feedback on edge cases (order with PRE/POST, interactions with armor/resistances, etc.).

Unknowncommented

@matricali The ModifyDamage mechanic can already use a SETTER modifier to statically set the damage of an event. This was not reflected in the wiki, where an older version of its usage must have been recorded and not changed after. Could you try it out and let us know?

Sign in to join the discussion.