Skip to content

New Engine Feature: Tweak op138#114

Open
4Luke4 wants to merge 4 commits into
Bubb13:masterfrom
4Luke4:op138
Open

New Engine Feature: Tweak op138#114
4Luke4 wants to merge 4 commits into
Bubb13:masterfrom
4Luke4:op138

Conversation

@4Luke4
Copy link
Copy Markdown
Contributor

@4Luke4 4Luke4 commented Mar 17, 2026

Description:
param2 in {0, 8, 11, 12, 13} and (param1 & 1) ~= 0 -> perform a real attack and call the Lua function in resource before the attack roll / damage is finalized.

Callback signature:

FUNC(op138: CGameEffect, sprite: CGameSprite, baseAttackRoll: number, baseDamageRoll: number) -> newBaseAttackRoll: number, newBaseDamageRoll: number[, boolean]

Notes:

  • The callback name must be 8 characters or less, and be ALL UPPERCASE.
  • The returned base attack roll is clamped to the engine's natural d20 range [1, 20].
  • The returned base damage roll is clamped to >= 0.
  • The returned base damage roll replaces only the engine's raw Roll:X basis;
    • later damage modifiers still apply normally unless the optional third return forces final damage to 0.
  • If the optional third return is true and the returned base damage roll clamps to 0, final damage is forced to 0 too, ignoring later damage modifiers.

Example Usage:
See attached files: B3OP138.zip

Addendum:
See also: Bubb13/InfinityLoader#4.

@4Luke4
Copy link
Copy Markdown
Contributor Author

4Luke4 commented Mar 17, 2026

Bonus:
This PR also adds a brand new script/dialog action: EEex_AttackOnce(O:Target*).

It functions as per existing Attack(O:Target*), but will stop after the first matched real roll.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants