mirror of
https://github.com/bryanthaboi/gen1recomp.git
synced 2026-08-17 19:24:01 +02:00
Add a fieldmove.eligibility hook to partyKnows (#310)
Mods that widen field-move rules (use an HM without teaching it, a rental mon) had to monkey-patch partyKnows, the one function every field-move path funnels through. Wrap the vanilla check in a hook instead: next_ is the whole badge-and-knows-move check, so a wrapper that calls it first keeps vanilla answers winning and only fills the cases vanilla denies. No hook, no behavior change. Co-authored-by: johnjohto <johnjohto@users.noreply.github.com>
This commit is contained in:
@@ -1241,7 +1241,7 @@ end
|
||||
-- (constants.hmBadges; distinct from constants.hmMoves, the forget gate).
|
||||
-- Gen 1 allows field use from fainted party members (party menu + name
|
||||
-- lookup for Cut/Surf messages); do not require mon.hp > 0 here.
|
||||
function OverworldState:partyKnows(moveId)
|
||||
local function partyKnowsVanilla(moveId)
|
||||
local gate = (FieldDefaults.constant(Game.data, "hmBadges") or {})[moveId]
|
||||
local badge = gate and gate.badge
|
||||
if badge and not Game.save.inventory[badge] then
|
||||
@@ -1255,6 +1255,17 @@ function OverworldState:partyKnows(moveId)
|
||||
return nil
|
||||
end
|
||||
|
||||
function OverworldState:partyKnows(moveId)
|
||||
-- a mod may unlock a field move another way (an HM in the bag, a rental
|
||||
-- mon); next_ is the whole vanilla check, so calling it first keeps
|
||||
-- vanilla answers winning
|
||||
if Runtime.wantsHook("fieldmove.eligibility") then
|
||||
return Runtime.call("fieldmove.eligibility", partyKnowsVanilla, moveId,
|
||||
{ save = Game.save, data = Game.data })
|
||||
end
|
||||
return partyKnowsVanilla(moveId)
|
||||
end
|
||||
|
||||
-- The rejection loop shared by the Good and Super Rods
|
||||
-- (item_effects.asm ItemUseGoodRod .RandomLoop / ReadSuperRodData): an
|
||||
-- odd random byte is no bite; otherwise a 2-bit pick rerolls until it
|
||||
|
||||
Reference in New Issue
Block a user