From 84a20b3f6180721c19d7fc5ebf1a54b11fb7fd54 Mon Sep 17 00:00:00 2001 From: bryanthaboi Date: Thu, 1 Oct 2026 11:56:12 -0400 Subject: [PATCH] CLOSES #2603 --- src/core/game3/battle_bridge.lua | 2 + src/core/game3/party.lua | 1 + .../game3_evolve_ability_battle_2603.lua | 88 +++++++++++++++++++ 3 files changed, 91 insertions(+) create mode 100644 tests/drivers/game3_evolve_ability_battle_2603.lua diff --git a/src/core/game3/battle_bridge.lua b/src/core/game3/battle_bridge.lua index e73f2acb..bad32e95 100644 --- a/src/core/game3/battle_bridge.lua +++ b/src/core/game3/battle_bridge.lua @@ -232,6 +232,8 @@ local function writeback(session, battleParty, remap, result, save, opts) speed = src.speed or src.spe, spAtk = src.spAtk or src.spa, spDef = src.spDef or src.spd, + ability = src.ability, + abilityId = src.abilityId, _allowMoveRewrite = true, }) -- pokefirered/src/battle_controller_player.c:1909 diff --git a/src/core/game3/party.lua b/src/core/game3/party.lua index c9c77572..d9e9661e 100644 --- a/src/core/game3/party.lua +++ b/src/core/game3/party.lua @@ -50,6 +50,7 @@ function Party.applyBattleFields(opaqueMon, fields) "species", "speciesId", "name", "growthRate", "attack", "defense", "speed", "spAtk", "spDef", "atk", "def", "spe", "spa", "spd", "ppBonusesPacked", + "ability", "abilityId", }) do if fields[key] ~= nil then opaqueMon[key] = fields[key] end end diff --git a/tests/drivers/game3_evolve_ability_battle_2603.lua b/tests/drivers/game3_evolve_ability_battle_2603.lua new file mode 100644 index 00000000..623e42d5 --- /dev/null +++ b/tests/drivers/game3_evolve_ability_battle_2603.lua @@ -0,0 +1,88 @@ +local U = require("tests.drivers.util") + +local MAGIKARP, GYARADOS = 129, 130 +local SWIFT_SWIM, INTIMIDATE = 33, 22 + +local failures = 0 +local function result(ok, label) + print((ok and "PASS " or "FAIL ") .. label) + if not ok then failures = failures + 1 end + return ok +end + +local function finish() + print(failures == 0 and "PASS evolve_ability_battle_2603" or ("FAIL evolve_ability_battle_2603 failures=" .. failures)) + love.event.quit(failures == 0 and 0 or 1) + U.wait(10) +end + +return function(game) + for _ = 1, 900 do + if game.phase == "boot" and game.boot then break end + U.wait(1) + end + game:_handleBootAction({ action = "new_game", name = "RED", gender = 0 }) + U.wait(240) + + local Runtime = require("src.core.game3.runtime") + local Party = require("src.core.game3.party") + local Pokemon = require("src.core.game3.pokemon") + local SummaryData = require("src.core.game3.summary_data") + local BattleBridge = require("src.core.game3.battle_bridge") + local Battle = require("src.core.game3.battle") + local Anim = require("src.core.game3.battle.anim") + local Ui = require("src.core.game3.battle.ui") + local Choice = require("src.ui.game3.choice") + local SummaryMenu = require("src.ui.game3.summary_menu") + local EvolutionScene = require("src.ui.game3.evolution_scene") + + local session = Runtime.getSession() + if not result(session ~= nil, "field reached (" .. tostring(session and session.version) .. ")") then return finish() end + session.party = {} + Party.giveMon(session, MAGIKARP, 19) + local mine = session.party[1] + mine.moves = { 33, 0, 0, 0 } + mine.pp = { 35, 0, 0, 0 } + mine.maxPp = { 35, 0, 0, 0 } + mine.exp = SummaryData.expForLevel(Pokemon.growthRate(MAGIKARP), 20) - 1 + result(mine.ability == SWIFT_SWIM, "Magikarp starts with Swift Swim (" .. tostring(mine.ability) .. ")") + + local ok, err = BattleBridge.startWild(Runtime._mod, game, { species = MAGIKARP, level = 30 }, { fade = false }) + if not result(ok == true, "battle started " .. tostring(err or "")) then return finish() end + + local lastTap, f = 0, 0 + for _ = 1, 20000 do + f = f + 1 + local evoOpen = EvolutionScene.isOpen() + if not Battle.isActive() and not evoOpen then break end + if Battle.isActive() and Battle._phase == "command" and Ui._mode == "menu" then + local est = Battle.getState() and Battle.getState().enemy + if est and est.mon then + est.mon.moves = { 150, 0, 0, 0 } + est.mon.pp = { 40, 0, 0, 0 } + est.mon.hp = 1 + local ep = Anim.present("enemy") + if ep then ep.displayHp = 1 end + end + Ui._pendingCommand = { kind = "move", move = 33, slot = 1, user = "player" } + Ui._mode = "none" + U.wait(2) + elseif Choice.active or SummaryMenu.isOpen() then + U.tap(game, "a") + U.wait(6) + elseif Anim.vm() and Anim.vm():busy() then + U.wait(1) + elseif f - lastTap >= 12 then + lastTap = f + U.tap(game, "a") + else + U.wait(1) + end + end + U.wait(30) + local mon = session.party[1] + result(Pokemon.speciesOf(mon) == GYARADOS, "post-battle evolution to Gyarados (" .. tostring(Pokemon.speciesOf(mon)) .. ")") + result(mon.ability == INTIMIDATE and mon.abilityId == INTIMIDATE, + "Gyarados has Intimidate (" .. tostring(mon.ability) .. "/" .. tostring(mon.abilityId) .. ")") + finish() +end