RynthAi.Combat v1: let a RynthLua script choose RynthAi's attack and heal spells

Adds a polling hand-off ("RynthAi.Combat" v1 interface table) so a script can
pick the spell RynthAi casts for an attack or an HP heal, while RynthAi keeps
scanning, targeting, the arbiter, nav/loot gating, thresholds, buffs, stance and
wand. Decline, invalid answers, timeouts and lease lapse all fall back to
native selection in the same tick; the emergency heal path is untouched; the
hook is inert when no script registers. RynthAi's mana reserve holds a script's
attack spell as it holds its own (the answer is kept, nothing native is cast
instead, and the script is asked again after the deadline plus 1 s); a spell
costing more than max mana is rejected so RynthAi chooses its own. Lua API:
ai.SetAttackHandler, ai.SetHealHandler, ai.ClearCombatHandlers, ai.CombatHook.
Includes host and compat tests and Examples/combat-handler.lua. No
RynthCore/SDK changes.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Daniel Wallace 2026-10-10 10:26:25 -07:00
commit 10e2c2eb0a
30 changed files with 3620 additions and 27 deletions

View file

@ -105,6 +105,7 @@ public sealed partial class RynthLuaPlugin : RynthPluginBase
List<string> resume = new();
try { resume = CaptureResume(); } catch { }
try { StopAll("stopped: RynthLua unloaded"); } catch (Exception ex) { Log("[RynthLua] shutdown: " + ex.Message); }
try { ReleaseCombatHook(); } catch { } // RynthAi goes native now, not when the lease lapses
try { ShutdownHuds(); } catch { }
FlushHudMemory();
SaveEditor();
@ -134,6 +135,10 @@ public sealed partial class RynthLuaPlugin : RynthPluginBase
try { PollHudEvents(); } // script windows: input first, so this tick's passes see it
catch (Exception ex) { LogHudFault("events", ex); }
TickApi();
// RynthAi's combat hook: renew the lease, start handlers for new requests (they run in
// TickScripts just below, so a handler that doesn't yield answers in this same tick).
try { PumpCombatHook(); }
catch (Exception ex) { Log("[RynthLua] combat hook: " + ex.Message); }
TickScripts();
try { TickHuds(); } // render passes that are due, then submit what changed
catch (Exception ex) { LogHudFault("passes", ex); }