mirror of
https://github.com/bryanthaboi/gen1recomp.git
synced 2026-08-18 11:44:42 +02:00
Refuse a TM/HM on a species with no tmhm list instead of crashing
ItemEffects.use walked speciesDef.tmhm with a bare ipairs() to check whether the species could learn the machine's move. A record with no tmhm field at all -- a mod species that never set one, or any record missing it for whatever reason -- hit ipairs(nil) and took the whole game down on the first TM/HM use, rather than reaching the ordinary "can't learn that move" refusal a species whose list simply omits the move already gets. An absent list now reads the same as an empty one: nothing to learn, same refusal, same sound, same text.
This commit is contained in:
@@ -515,7 +515,10 @@ function ItemEffects.use(data, save, itemId, target, battle, moveIndex, ow)
|
||||
if not target then return "failed", { noEffect(data) } end
|
||||
local speciesDef = data.pokemon[target.species]
|
||||
local ok = false
|
||||
for _, m in ipairs(speciesDef.tmhm) do
|
||||
-- a species record with no tmhm list at all is "teaches nothing", the
|
||||
-- same as one whose list just does not name this move -- not a reason
|
||||
-- to crash instead of refusing normally
|
||||
for _, m in ipairs(speciesDef.tmhm or {}) do
|
||||
if m == itemDef.machine.move then ok = true break end
|
||||
end
|
||||
if not ok then
|
||||
|
||||
Reference in New Issue
Block a user