diff --git a/src/core/game3/battle/ai.lua b/src/core/game3/battle/ai.lua index 903d4436..7ca77115 100644 --- a/src/core/game3/battle/ai.lua +++ b/src/core/game3/battle/ai.lua @@ -124,8 +124,8 @@ end local function move_target_byte(mv) if move_num(mv) == 0 then return 0 end local Moves = require("src.core.game3.battle.moves") - local m = Moves.get(mv) - return tonumber(m and m.target) or 0 + local ok, m = pcall(Moves.get, mv) + return tonumber(ok and m and m.target) or 0 end local function random_u16(rng) diff --git a/src/core/game3/battle/moves.lua b/src/core/game3/battle/moves.lua index b1be4e8d..73b15c7c 100644 --- a/src/core/game3/battle/moves.lua +++ b/src/core/game3/battle/moves.lua @@ -116,6 +116,7 @@ end local function from_rom(numId) Moves.romReady() + if not Moves._rom then return nil end local row = Moves._rom[numId] if not row then return nil end local cat = Types.isPhysical(row.type) and "physical" or "special"