From 6fd9741fab3242fa12d4463f213ef7a5ee0efc76 Mon Sep 17 00:00:00 2001 From: sirj0k3r Date: Fri, 31 Jul 2026 21:12:21 +0100 Subject: [PATCH] + Implemented Low Health Alert hook for modding --- src/battle/BattleState.lua | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/src/battle/BattleState.lua b/src/battle/BattleState.lua index 4306cd56..2f90f29e 100644 --- a/src/battle/BattleState.lua +++ b/src/battle/BattleState.lua @@ -2677,10 +2677,24 @@ function BattleState:updateFx() -- so a sounding siren rides out the next hit's HP drain instead of -- dropping out mid-announcement (#293) self.lowHealthAlarmOn = self:lowHealthAlarmActive() - if self.lowHealthAlarmOn then - Sound.startLoop(self.data, "Low_Health_Alarm") + -- battle.low_health_alarm: on/off toggle for the siren loop, ctx.on + -- mirrors self.lowHealthAlarmOn. Vanilla just starts/stops the loop + -- each frame; a mod can wrap this to reshape the toggle (e.g. force + -- ctx.on false after some budget) before letting vanilla act on it. + if Runtime.wantsHook("battle.low_health_alarm") then + Runtime.call("battle.low_health_alarm", function(ctx) + if ctx.on then + Sound.startLoop(ctx.battle.data, "Low_Health_Alarm") + else + Sound.stopLoop("Low_Health_Alarm") + end + end, { on = self.lowHealthAlarmOn, battle = self }) else - Sound.stopLoop("Low_Health_Alarm") + if self.lowHealthAlarmOn then + Sound.startLoop(self.data, "Low_Health_Alarm") + else + Sound.stopLoop("Low_Health_Alarm") + end end end