mirror of
https://github.com/bryanthaboi/gen1recomp.git
synced 2026-08-17 11:11:10 +02:00
i did it for greg
This commit is contained in:
@@ -316,6 +316,27 @@ function BattleState.trainerPicPath(data, trainer, oppClass, partyIndex)
|
||||
return base and base.pic or nil
|
||||
end
|
||||
|
||||
-- trueColor on the trainer record, or on the basePic it reuses when the
|
||||
-- subclass does not set the flag itself. Explicit false stays false.
|
||||
function BattleState.trainerTrueColor(data, trainer)
|
||||
if not trainer then return false end
|
||||
if trainer.trueColor ~= nil then
|
||||
return trainer.trueColor and true or false
|
||||
end
|
||||
local base = trainer.basePic and data and data.trainers
|
||||
and data.trainers[trainer.basePic]
|
||||
return (base and base.trueColor) and true or false
|
||||
end
|
||||
|
||||
-- Load a trainer frontpic through getImage so a trueColor portrait skips
|
||||
-- the 4-shade quantize the same way a species pic does.
|
||||
function BattleState.trainerSprite(data, trainer, oppClass, partyIndex)
|
||||
return getImage(
|
||||
BattleState.trainerPicPath(data, trainer, oppClass, partyIndex),
|
||||
BattleState.trainerPalette(data, trainer),
|
||||
BattleState.trainerTrueColor(data, trainer))
|
||||
end
|
||||
|
||||
-- The battle-BGP fade variant of a pic (AnimationFlashScreen and the
|
||||
-- SetAnimationBGPalette effects remap the four BG shades; on the SGB
|
||||
-- the colorizer then colors the REMAPPED shade, so a faded pic shows
|
||||
@@ -756,9 +777,8 @@ function BattleState.newTrainer(game, oppClass, partyIndex)
|
||||
-- MonsterPalettes[0] = PAL_MEWMON -- InitBattleCommon zeroes
|
||||
-- wEnemyMonSpecies2 before the intro's SET_PAL_BATTLE
|
||||
-- (engine/battle/core.asm:6682, engine/gfx/palettes.asm SetPal_Battle)
|
||||
self.trainerPic = getImage(
|
||||
BattleState.trainerPicPath(game.data, self.trainer, oppClass, partyIndex),
|
||||
BattleState.trainerPalette(game.data, self.trainer))
|
||||
self.trainerPic = BattleState.trainerSprite(
|
||||
game.data, self.trainer, oppClass, partyIndex)
|
||||
self.introText = Strings("%s wants\nto fight!", self.trainer.name)
|
||||
return self
|
||||
end
|
||||
|
||||
@@ -1797,7 +1797,8 @@ local function buildBattleState()
|
||||
"throwBall", "ballChain", "tossAnimFor", "ballFlicker", "ballMissMessage",
|
||||
"storeCaughtMon", "safariAction", "safariEnemyTurn", "drawBallRow",
|
||||
"drawClassic", "isWideBattleLayout", "wideLayout", "bgMode", "uiSize",
|
||||
"sgbPalettes", "trainerPalette", "trainerPicPath", "invalidate",
|
||||
"sgbPalettes", "trainerPalette", "trainerPicPath", "trainerTrueColor",
|
||||
"trainerSprite", "invalidate",
|
||||
"imageBattleScale", "resolveBattleScale", "backPlacement",
|
||||
"frontPlacement", "StatBox", "enter", "exit",
|
||||
}) do
|
||||
@@ -1884,7 +1885,8 @@ COVERAGE["src.battle.BattleState"] = {
|
||||
absent = "newWild newTrainer makeSafari makeGhost makeBattler resolveTurn "
|
||||
.. "computeDamage catchAttempt runRoll enter exit sgbPalettes "
|
||||
.. "isWideBattleLayout wideLayout bgMode uiSize letterboxWhite "
|
||||
.. "holdsUIAnchors BG_WORLD_DIM trainerPalette trainerPicPath invalidate "
|
||||
.. "holdsUIAnchors BG_WORLD_DIM trainerPalette trainerPicPath "
|
||||
.. "trainerTrueColor trainerSprite invalidate "
|
||||
.. "backPlacement frontPlacement StatBox drawClassic drawBallRow "
|
||||
.. "safariAction safariEnemyTurn throwBall storeCaughtMon field ruleset "
|
||||
.. "rng oppClass partyIndex aiUses introText dead",
|
||||
|
||||
@@ -1017,6 +1017,9 @@ R.trainers = {
|
||||
index = f.opt(f.int(0, 255)),
|
||||
-- unused vanilla classes ship without a pic, so it cannot be required
|
||||
pic = f.opt(f.path),
|
||||
-- Full-color portrait: skip the 4-shade SGB/GBC remap, same flag pokemon
|
||||
-- and sprites already carry.
|
||||
trueColor = f.opt(f.bool),
|
||||
-- Optional Advanced-mode OBJ palette source for a custom trainer portrait.
|
||||
-- It follows the same ROM crosswalk form as sprites.paletteSource.
|
||||
paletteSource = f.opt(f.str),
|
||||
@@ -1068,6 +1071,11 @@ R.trainers = {
|
||||
gen2Fields = {
|
||||
id = f.opt(f.str), name = f.str,
|
||||
index = f.opt(f.int(0, 255)),
|
||||
-- class frontpic; when set, this wins over menu_gfx.battleHud.trainerPics
|
||||
pic = f.opt(f.path),
|
||||
-- Full-color portrait: skip the GBC 4-shade remap, same flag Gen 1
|
||||
-- trainers and pokemon already carry.
|
||||
trueColor = f.opt(f.bool),
|
||||
baseMoney = f.opt(f.int(0)),
|
||||
-- the class's battle theme; Gen 1 spells the same idea `battleTheme`,
|
||||
-- but this is the extractor's own key and a strict rename would reject
|
||||
|
||||
@@ -98,14 +98,14 @@ function OakSpeech.resolvePic(game, desc, speech)
|
||||
local t = desc.type
|
||||
if t == "trainer" then
|
||||
if speech and desc.id == "OPP_PROF_OAK" and speech.oakPic then
|
||||
return speech.oakPic, false, false
|
||||
return speech.oakPic, false, speech.oakTrueColor or false
|
||||
end
|
||||
if speech and desc.id == "OPP_RIVAL1" and speech.rivalPic then
|
||||
return speech.rivalPic, false, false
|
||||
return speech.rivalPic, false, speech.rivalTrueColor or false
|
||||
end
|
||||
local trainers = game.data.trainers or {}
|
||||
local tr = trainers[desc.id]
|
||||
return tryImage(tr and tr.pic), false, false
|
||||
return tryImage(tr and tr.pic), false, tr and tr.trueColor or false
|
||||
elseif t == "pokemon" then
|
||||
if speech and desc.id == speech.demoSpecies and speech.demoPic then
|
||||
return speech.demoPic, desc.flip and true or false, speech.demoTrueColor
|
||||
@@ -241,7 +241,11 @@ function OakSpeech.new(game, onDone)
|
||||
self.answers = {}
|
||||
local trainers = game.data.trainers or {}
|
||||
self.oakPic = tryImage(trainers.OPP_PROF_OAK and trainers.OPP_PROF_OAK.pic)
|
||||
self.oakTrueColor = self.oakPic
|
||||
and trainers.OPP_PROF_OAK and trainers.OPP_PROF_OAK.trueColor or false
|
||||
self.rivalPic = tryImage(trainers.OPP_RIVAL1 and trainers.OPP_RIVAL1.pic)
|
||||
self.rivalTrueColor = self.rivalPic
|
||||
and trainers.OPP_RIVAL1 and trainers.OPP_RIVAL1.trueColor or false
|
||||
local oakGfx = (game.data.field and game.data.field.oakSpeech) or {}
|
||||
self.cfg = oakGfx
|
||||
-- the show-off mon and the name length cap come from data; the vanilla
|
||||
|
||||
@@ -185,6 +185,19 @@ function BattleState:statusHUDVisible()
|
||||
self) ~= false
|
||||
end
|
||||
|
||||
-- Class frontpic for the battle intro. A trainers-registry `pic` wins over
|
||||
-- the extracted menu_gfx sheet; `trueColor` skips the GBC 4-shade remap.
|
||||
-- Returns path, trueColor.
|
||||
function BattleState.trainerArt(data, classId)
|
||||
if not classId then return nil, false end
|
||||
local classes = data and data.gen2Trainers and data.gen2Trainers.classes
|
||||
local classDef = classes and classes[classId]
|
||||
local hud = data and data.gen2MenuGfx and data.gen2MenuGfx.battleHud
|
||||
local path = (classDef and classDef.pic)
|
||||
or (hud and hud.trainerPics and hud.trainerPics[classId])
|
||||
return path, (classDef and classDef.trueColor) and true or false
|
||||
end
|
||||
|
||||
-- opts: battle (a Battle), onDone(outcome), save
|
||||
function BattleState.new(game, opts)
|
||||
opts = opts or {}
|
||||
@@ -308,6 +321,7 @@ function BattleState.new(game, opts)
|
||||
-- pic is a cache asset, so an import made before the extractor grew that
|
||||
-- stage has none and the mon stands in for the whole intro.
|
||||
self.showEnemyTrainer = false
|
||||
self.enemyTrainerTrueColor = false
|
||||
-- The CLASS CONSTANT (BUG_CATCHER), which is what both tables this looks the
|
||||
-- pic up in are keyed by: menu_gfx's trainerPics is written out of
|
||||
-- constants.trainerClassOrder, and palettes.trainers out of the same names.
|
||||
@@ -317,17 +331,19 @@ function BattleState.new(game, opts)
|
||||
-- no palette for every trainer the world starts, which is all of them.
|
||||
-- `classId` is the trainers.lua key, i.e. the constant; `className` is the
|
||||
-- DISPLAY name ("BUG CATCHER", with the space) and is not a key at all.
|
||||
-- A class record's own `pic` / `trueColor` (the trainers registry) wins
|
||||
-- over the extracted sheet, so a mod can drop in full-color art.
|
||||
local enemyTrainer = self.battle and self.battle.trainer
|
||||
self.enemyTrainerClass = enemyTrainer
|
||||
and (enemyTrainer.classId or enemyTrainer.class)
|
||||
local trainerPics = hudGfx and hudGfx.trainerPics
|
||||
local trainerPath = self.enemyTrainerClass and trainerPics
|
||||
and trainerPics[self.enemyTrainerClass]
|
||||
local trainerPath, trainerTrueColor =
|
||||
BattleState.trainerArt(data, self.enemyTrainerClass)
|
||||
if trainerPath then
|
||||
local ok, image = pcall(Assets.image, trainerPath)
|
||||
if ok and image then
|
||||
self.enemyTrainerImage = image
|
||||
self.enemyTrainerPath = trainerPath
|
||||
self.enemyTrainerTrueColor = trainerTrueColor and true or false
|
||||
self.showEnemyTrainer = true
|
||||
end
|
||||
end
|
||||
@@ -588,7 +604,10 @@ function BattleState:drawPic(mon, back)
|
||||
-- slides it out (InitEnemyTrainer, engine/battle/core.asm:7848).
|
||||
local enemyTrainer = (not back) and self.showEnemyTrainer
|
||||
and self.enemyTrainerImage
|
||||
if enemyTrainer then image, path = enemyTrainer, self.enemyTrainerPath end
|
||||
if enemyTrainer then
|
||||
image, path = enemyTrainer, self.enemyTrainerPath
|
||||
trueColor = self.enemyTrainerTrueColor
|
||||
end
|
||||
if not image then return end
|
||||
local side = back and "player" or "enemy"
|
||||
local anim = self:animPicState(side)
|
||||
|
||||
Reference in New Issue
Block a user