feat(mod-api): expose charge decision hook

This commit is contained in:
MaxTomahawk
2026-08-21 14:40:51 +02:00
parent c11c762f15
commit 4b0496bad1
8 changed files with 440 additions and 5 deletions
+11 -1
View File
@@ -3980,7 +3980,17 @@ function BattleState:performMove(user, target, moveInst, isCalled)
-- record (chargeText) and the invulnerability from semiInvulnerable,
-- falling back to the id tables (Fly AND Dig go semi-invulnerable:
-- ChargeEffect sets INVULNERABLE for both)
if record and record.charge and not releasing then
local chargeRequired = record and record.charge ~= nil and not releasing
if chargeRequired and Runtime.wantsHook("battle.charge_required") then
local required = Runtime.call("battle.charge_required", function(c)
return c.charge
end, {
battle = self, user = user, target = target, move = move,
charge = true, isCalled = isCalled or false,
})
chargeRequired = required ~= false
end
if chargeRequired then
self:cancelMoveAnim()
user.charging = moveInst
user.chargeReady = true
+9
View File
@@ -1494,6 +1494,15 @@ function Battle:useMove(attacker, defender, moveId)
if def.effect == "EFFECT_SOLARBEAM" and self.weather == "sun" then
charge = nil
end
if charge and not charging and Runtime.wantsHook("battle.charge_required") then
local required = Runtime.call("battle.charge_required", function(c)
return c.charge
end, {
battle = self, user = attacker, target = defender, move = def,
charge = true, isCalled = (self.copyDepth or 0) > 0,
})
if required == false then charge = nil end
end
if charge and not charging then
state.chargeMove = moveId
state.vanished = charge.vanish or nil