From ee63ffff2d778abbefd27cd126b294fa36fefc22 Mon Sep 17 00:00:00 2001 From: thibautbus <310327033+thibautbus@users.noreply.github.com> Date: Tue, 22 Sep 2026 10:51:24 +0200 Subject: [PATCH] Name a FireRed egg by the language's own EGG MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Party.giveMon stores "EGG" as a new egg's nickname (party.lua for a gift egg, breeding.lua for the Day-Care's), and the party slots and the other screens that name a mon through Pokemon.displayName and displayMonName print that nickname as it is. A translated game therefore listed its eggs as EGG, while the summary, which prints Strings("EGG") for an egg, already said OEUF, EI, HUEVO or UOVO. The cart does not rely on the stored nickname either: its Day-Care writes the Japanese タマゴ there (daycare.c:1100), and GetMonData returns gText_EggNickname for any egg's nickname (pokemon.c:3020). Do the same in both name helpers: an egg reads as Strings("EGG"), whatever its nickname holds, which also covers the eggs saves already carry. A hatched egg, whose nickname is cleared, goes back to its species name. --- src/core/game3/pokemon.lua | 12 ++++++ tests/engine/game3_egg_display_name_test.lua | 44 ++++++++++++++++++++ 2 files changed, 56 insertions(+) create mode 100644 tests/engine/game3_egg_display_name_test.lua diff --git a/src/core/game3/pokemon.lua b/src/core/game3/pokemon.lua index 555cdd34..9dd36b35 100644 --- a/src/core/game3/pokemon.lua +++ b/src/core/game3/pokemon.lua @@ -1160,8 +1160,18 @@ function Pokemon.replaceMove(mon, slot, newMoveId) return old end +-- An egg reads as the language's own EGG whatever its nickname holds: pret's +-- GetMonData(MON_DATA_NICKNAME) returns gText_EggNickname for any egg +-- (pokefirered/src/pokemon.c:3020). The stored nickname is only a placeholder +-- -- the cart's daycare writes タマゴ (daycare.c:1100), this engine "EGG". +local function eggName(mon) + if Pokemon.isEgg(mon) then return Strings("EGG") end +end + function Pokemon.displayMonName(mon) if not mon then return "POKéMON" end + local egg = eggName(mon) + if egg then return egg end local nick = mon.nickname if type(nick) == "string" and nick ~= "" then return nick end if mon.name and mon.name ~= "" then return mon.name end @@ -1572,6 +1582,8 @@ end function Pokemon.displayName(mon) if not mon then return "?????" end + local egg = eggName(mon) + if egg then return egg end if mon.nickname and mon.nickname ~= "" then return tostring(mon.nickname) end -- Prefer pack name over host species string when we can resolve. local sp = Pokemon.speciesOf(mon) diff --git a/tests/engine/game3_egg_display_name_test.lua b/tests/engine/game3_egg_display_name_test.lua new file mode 100644 index 00000000..994d3e77 --- /dev/null +++ b/tests/engine/game3_egg_display_name_test.lua @@ -0,0 +1,44 @@ +#!/usr/bin/env luajit +-- An egg is named by the language's own EGG, as pret's GetMonData(MON_DATA_NICKNAME) +-- does for any egg (pokefirered/src/pokemon.c:3020): the party and every screen +-- that names a mon through Pokemon.displayName / displayMonName show it, whatever +-- placeholder the egg's nickname stores. + +package.path = "./?.lua;./?/init.lua;" .. package.path +love = require("tests.love_stub") + +local T = require("tests.harness") +local check = T.check + +local Strings = require("src.core.Strings") +local Pokemon = require("src.core.game3.pokemon") + +-- A minimal pack, so no ROM is needed. +Pokemon._names = { [25] = "PIKACHU", [172] = "PICHU" } + +local egg = { species = 172, isEgg = true, nickname = "EGG", name = "EGG" } +local hatched = { species = 172, isEgg = false, nickname = "", name = "PICHU" } +local named = { species = 25, nickname = "SPARKY" } + +Strings.load({}) +check(Pokemon.displayName(egg) == "EGG", "an egg reads EGG with no catalog") +check(Pokemon.displayMonName(egg) == "EGG", "in both name helpers") + +Strings.load({ strings = { EGG = "OEUF" } }) +check(Pokemon.displayName(egg) == "OEUF", "an egg follows the catalog's EGG") +check(Pokemon.displayMonName(egg) == "OEUF", "in both name helpers") +check(egg.nickname == "EGG", "without its stored nickname being rewritten") + +local bare = { species = 172, isEgg = true, nickname = "" } +check(Pokemon.displayName(bare) == "OEUF", "an egg with no nickname at all is still named EGG") +local species_only = { species = 412, nickname = "" } +check(Pokemon.displayName(species_only) == "OEUF", "and so is one known only by the egg species") + +-- (looking up a species the pack lacks reloads it; put the minimal one back) +Pokemon._names = { [25] = "PIKACHU", [172] = "PICHU" } +check(Pokemon.displayName(hatched) == "PICHU", "a hatched egg goes back to its species name") +check(Pokemon.displayName(named) == "SPARKY", "and a nicknamed mon keeps its nickname") +check(Pokemon.displayMonName(named) == "SPARKY", "in both name helpers") + +Strings.load({}) +T.finish("game3_egg_display_name_test")