shiny Pokemon, on by default

Gen 1 has no shininess of its own, but it has the four DVs Gen 2 reads to
decide it -- and the engine already ships that reading (Stats.isShiny, its
own comment calling it "the RBY virtual shiny", allowlisted for mods
precisely so an indicator mod can call it). Nothing new is stored on a
Pokemon and nothing migrates: every save already contains the answer, and
this starts drawing it. Random DVs land on the pattern 1 in 8192, which is
the classic rate and the default the odds dial ships at.

Deriving rather than storing is what makes it survive a save, a box, a
trade and an evolution with no second copy of the truth to drift. mon.shiny
is a cache written from the DVs, never read as the source.

The roll goes in Pokemon.new -- every wild, gift, starter and traded mon is
built there, and it is before the battle bakes its sprite, which
battle.started is already too late for. It draws from the mod's own random
stream so installing this does not shift the sequence damage rolls and
encounter slots come out of. Trainers stay ordinary by themselves: the
engine pins their DVs, as the real games do.

The models are genuinely recoloured, as part of the extraction. Each
species is decoded once, packed as usual, then recoloured and packed again
as NNNs.dsm. The colours are Stadium's own HSL slide (hue in degrees,
saturation and lightness on a -8..+8 scale at 12.5% a step); five species
carry an explicit colour table instead, because Stadium gives them a real
alternate texture that no single slide reproduces -- Jigglypuff's body must
stay pink while its irises rotate to green.

Extraction is the right moment because StadiumFx's generated frames are
still marked there and the packer drops the marker: it is the last point a
flame is distinguishable from a hide. A shiny Charizard has a shiny hide
and an ordinary fire. The normal packs are written BEFORE the recolour, so
they come out byte-identical and stadium_extract_test still diffs all 151
against the Python oracle unchanged -- no format change, no DSM4, no second
implementation to keep in step. REV goes to 3 so an existing cache rebuilds.

Flat art is tinted instead, because the engine bakes a species palette into
a cache with no notion of which individual is drawn. The tint comes from
that species' own slide rather than a generic gold. A multiply can only
darken, so species whose shiny is lighter read quieter there than on the
model; the status page's star is the mode-proof mark.

Tests: 58 assertions in tests/shiny_test.lua, including the colour
transform against 640 real colour pairs lifted from the verified texture
set, the DV model, the read side, and the end-to-end through the engine's
own constructor. stadium_extract_test gains --mod (worktrees have neither
the ROM nor the packs, both gitignored) and now also checks that every
shiny pack is the same length as its twin and actually differs.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
DramaticShape
2026-08-08 12:12:25 -04:00
parent 121c87b629
commit a3fb18a589
19 changed files with 3773 additions and 34 deletions
+22 -3
View File
@@ -179,6 +179,7 @@ function StadiumMon.new(side)
return setmetatable({
side = side, -- "player" or "enemy"
species = nil, -- the dex number currently modelled
shiny = false, -- and whether it is the recoloured variant
model = nil,
rig = nil,
state = "idle",
@@ -195,6 +196,9 @@ end
function StadiumMon:release()
if self.rig then self.rig:release() end
self.rig, self.model, self.species = nil, nil, nil
-- cleared with the species: a stale true here would make the next
-- setSpecies believe a shiny model was already loaded and early-return
self.shiny = false
end
-- ------- which species this side is showing
@@ -222,14 +226,29 @@ end
-- DATA rather than a list of dex numbers, so a future extraction bug that
-- corrupts a species' idle falls back to the sprite instead of coming
-- apart on the field -- and nothing here has to be edited when it does.
function StadiumMon:setSpecies(dex)
if dex == self.species then return self.rig ~= nil end
--
-- `shiny` is part of the IDENTITY, not a flag applied afterwards. The early
-- return below is keyed on it for that reason: a shiny Rattata and an
-- ordinary one share a dex number but are different models, loaded from
-- different packs, and comparing on the dex alone would keep whichever
-- loaded first and colour both sides with it. That is precisely the shape
-- of bug the two-Rattata note above describes, and it is silent -- the
-- model is valid, it is simply the wrong one.
function StadiumMon:setSpecies(dex, shiny)
shiny = shiny and true or false
if dex == self.species and shiny == (self.shiny or false) then
return self.rig ~= nil
end
if self.rig then self.rig:release() end
self.rig, self.model, self.species = nil, nil, dex
self.shiny = shiny
self.grow, self.grewOwn = nil, nil
if not dex then return false end
local model = StadiumPack.load(dex)
local model = StadiumPack.load(dex, shiny)
if not model then return false end
-- the pack falls back to the normal model when a species has no shiny
-- variant, so believe the model rather than the request
self.shiny = model.shiny and true or false
if model.staticPose then return false end
local rig = StadiumRig.new(model)
if not rig then return false end