mirror of
https://github.com/bryanthaboi/gen1recomp.git
synced 2026-08-17 19:24:01 +02:00
CLOSES #806, CLOSES #809, CLOSES #853, CLOSES #854, CLOSES #860, CLOSES #862, CLOSES #865, CLOSES #866
This commit is contained in:
@@ -3188,6 +3188,16 @@ function BattleState:executeAction(user, target, action)
|
||||
user.boundTurns = target.trappingTurns
|
||||
and math.max(1, target.trappingTurns) or nil
|
||||
|
||||
-- wPlayerSelectedMove / wEnemySelectedMove as the status gauntlet
|
||||
-- reads it: the locked specials keep continuing the move they
|
||||
-- started, so they carry a move id too. Resolved once here and
|
||||
-- handed to every statusInterrupt below, which is where
|
||||
-- .TriedToUseDisabledMoveCheck lives (#860).
|
||||
local selectedId = action.id
|
||||
or (action.special == "trapping" and user.trapMove)
|
||||
or (action.special == "bide" and "BIDE")
|
||||
or nil
|
||||
|
||||
-- trainer class AI actions (engine/battle/trainer_ai.asm)
|
||||
if action.special == "aiItem" then
|
||||
self.aiUses = (self.aiUses or 1) - 1
|
||||
@@ -3245,17 +3255,17 @@ function BattleState:executeAction(user, target, action)
|
||||
return
|
||||
end
|
||||
if action.special == "trapping" then
|
||||
if self:statusInterrupt(user, target) then return end
|
||||
if self:statusInterrupt(user, target, selectedId) then return end
|
||||
self:continueTrapping(user, target)
|
||||
return
|
||||
end
|
||||
if action.special == "bide" then
|
||||
if self:statusInterrupt(user, target) then return end
|
||||
if self:statusInterrupt(user, target, selectedId) then return end
|
||||
self:continueBide(user, target)
|
||||
return
|
||||
end
|
||||
|
||||
if self:statusInterrupt(user, target) then return end
|
||||
if self:statusInterrupt(user, target, selectedId) then return end
|
||||
self:performMove(user, target, action, false)
|
||||
end
|
||||
run()
|
||||
@@ -3349,8 +3359,8 @@ end
|
||||
|
||||
-- Runs Status.beforeMove plus the shared interruption bookkeeping;
|
||||
-- returns true when the user's action is interrupted.
|
||||
function BattleState:statusInterrupt(user, target)
|
||||
local canMove, msgs, selfHit = Status.beforeMove(user, self.rng, self)
|
||||
function BattleState:statusInterrupt(user, target, selectedId)
|
||||
local canMove, msgs, selfHit = Status.beforeMove(user, self.rng, self, selectedId)
|
||||
for _, m in ipairs(msgs) do self:sayStatusMsg(user, m) end
|
||||
if selfHit then
|
||||
-- confusion self-hit (core.asm:3428-3434): clears everything in
|
||||
|
||||
+23
-1
@@ -168,7 +168,7 @@ end
|
||||
-- The active status record's beforeMove runs at its priority slot: above
|
||||
-- VOLATILE_PRIORITY before the held/disable/confusion block (sleep,
|
||||
-- freeze), at or below after it (paralysis) -- the original's order.
|
||||
function Status.beforeMove(battler, rng, battle)
|
||||
function Status.beforeMove(battler, rng, battle, selectedMoveId)
|
||||
local mon = battler.mon
|
||||
-- Haze curing this mon's sleep/freeze forfeits its pending move for
|
||||
-- the turn, silently (haze.asm writes $ff/CANNOT_MOVE to the selected
|
||||
@@ -225,6 +225,28 @@ function Status.beforeMove(battler, rng, battle)
|
||||
end
|
||||
end
|
||||
end
|
||||
-- .TriedToUseDisabledMoveCheck (engine/battle/core.asm, and the enemy
|
||||
-- copy .checkIfTriedToUseDisabledMove): the disabled-move test runs at
|
||||
-- EXECUTION time, comparing wPlayerDisabledMoveNumber against the
|
||||
-- already SELECTED move, so a Disable that lands earlier in the same
|
||||
-- turn still blocks the slower mon's move (#860). It sits after the
|
||||
-- confusion block and before the paralysis roll, so a confusion self-hit
|
||||
-- still pre-empts it and the paralysis roll is never spent on a turn the
|
||||
-- disable eats. PrintMoveIsDisabledText clears CHARGING_UP before
|
||||
-- printing, so a disabled charge move drops its stored turn instead of
|
||||
-- releasing later.
|
||||
if selectedMoveId and battler.disabledSlot then
|
||||
local disabled = (battler.curMoves or {})[battler.disabledSlot]
|
||||
if disabled and disabled.id == selectedMoveId then
|
||||
battler.charging, battler.chargeReady = nil, nil
|
||||
local moves = battle and battle.data and battle.data.moves
|
||||
local shown = moves and moves[selectedMoveId] and moves[selectedMoveId].name
|
||||
or tostring(selectedMoveId)
|
||||
table.insert(msgs, romText(battle and battle.data, "_MoveIsDisabledText",
|
||||
"%s's\n%s is\ndisabled!", name(battler), shown))
|
||||
return false, msgs
|
||||
end
|
||||
end
|
||||
if handler then
|
||||
local canMove, selfHit = runStatus()
|
||||
if not canMove or selfHit then return canMove, msgs, selfHit end
|
||||
|
||||
Reference in New Issue
Block a user