mirror of
https://github.com/bryanthaboi/gen1recomp
synced 2026-10-07 17:31:35 -04:00
Put a translated wild or foe word after the name when the cart does
The battle text joins a foe's name to the cart's sText_WildPkmnPrefix or sText_FoePkmnPrefix the way the US code does, word first. The French, Italian and Spanish carts write those rows to follow the name (" sauvage", " salvaje", " selvatico") and append them (pret pokeemerald multi-language, src/battle_message.c:4042 and :4649), and the German row has the same shape (" (Wild)"), so a French battle read " sauvageZIGZATON utilise RUGISSEMENT!".
BattleText.withMonPrefix joins the two in the row's order: a row that starts with a space follows the name, and the US and Japanese rows ("Wild ", "やせいの ") still go first. Both the battle string placeholder (B_ATK_NAME_WITH_PREFIX and the other WITH_PREFIX codes) and the buffered name (State.prefixedName) use it, in FireRed/LeafGreen and Emerald alike.
This commit is contained in:
@@ -39,11 +39,21 @@ local function monName(ref)
|
||||
return require("src.core.game3.battle.state").displayName(ref)
|
||||
end
|
||||
|
||||
-- A foe's name with the cart's wild/foe word. The US and Japanese rows go
|
||||
-- before the name ("Wild ", "やせいの "); the French, Italian and Spanish
|
||||
-- carts write theirs to follow it (" sauvage", " salvaje", " selvatico") and
|
||||
-- append it (pret pokeemerald multi-language, src/battle_message.c:4042,
|
||||
-- :4649). The German row has the same shape (" (Wild)").
|
||||
function BattleText.withMonPrefix(prefix, name)
|
||||
if prefix:sub(1, 1) == " " then return name .. prefix end
|
||||
return prefix .. name
|
||||
end
|
||||
|
||||
-- src/battle_message.c:1807 HANDLE_NICKNAME_STRING_CASE
|
||||
local function withPrefix(fill, ref)
|
||||
if isPlayer(ref) then return monName(ref) end
|
||||
local prefix = fill.trainer and "sText_FoePkmnPrefix" or "sText_WildPkmnPrefix"
|
||||
return RomText.plain(prefix) .. monName(ref)
|
||||
return BattleText.withMonPrefix(RomText.plain(prefix), monName(ref))
|
||||
end
|
||||
|
||||
local function moveName(fill, move)
|
||||
|
||||
@@ -466,7 +466,8 @@ function State.prefixedName(st, battler, name)
|
||||
local RomText = require("src.core.game3.rom_text")
|
||||
local prefix = (st ~= nil and not st.wild) and "sText_FoePkmnPrefix" or "sText_WildPkmnPrefix"
|
||||
local ok, pre = pcall(RomText.plain, prefix)
|
||||
return (ok and pre or (st ~= nil and not st.wild and "Foe " or "Wild ")) .. name
|
||||
pre = ok and pre or (st ~= nil and not st.wild and "Foe " or "Wild ")
|
||||
return require("src.core.game3.battle.battle_text").withMonPrefix(pre, name)
|
||||
end
|
||||
|
||||
function State.isFainted(battler)
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
-- The wild/foe word joined to a foe's name: the US and Japanese rows go before
|
||||
-- it, the European carts write theirs to follow it and append it (pret
|
||||
-- pokeemerald multi-language, src/battle_message.c:4042, :4649).
|
||||
|
||||
package.path = "./?.lua;./?/init.lua;" .. package.path
|
||||
|
||||
local T = require("tests.harness")
|
||||
local eq = T.eq
|
||||
|
||||
local RomText = require("src.core.game3.rom_text")
|
||||
local BattleText = require("src.core.game3.battle.battle_text")
|
||||
local State = require("src.core.game3.battle.state")
|
||||
|
||||
local saved = {}
|
||||
local function set(key, ir)
|
||||
if saved[key] == nil then saved[key] = RomText.overrides[key] or false end
|
||||
RomText.overrides[key] = ir
|
||||
end
|
||||
local function text(s) return { { t = "text", s = s }, { t = "eos" } } end
|
||||
|
||||
-- pokeemerald multi-language src/battle_message.c:4042
|
||||
eq(BattleText.withMonPrefix("Wild ", "ZIGZAGOON"), "Wild ZIGZAGOON", "US: the wild word comes first")
|
||||
eq(BattleText.withMonPrefix("やせいの ", "ジグザグマ"), "やせいの ジグザグマ", "Japanese: the wild word comes first")
|
||||
eq(BattleText.withMonPrefix(" sauvage", "ZIGZATON"), "ZIGZATON sauvage", "French: the wild word follows the name")
|
||||
eq(BattleText.withMonPrefix(" (Wild)", "ZIGZACHS"), "ZIGZACHS (Wild)", "German: the wild word follows the name")
|
||||
|
||||
set("sText_WildPkmnPrefix", text(" sauvage"))
|
||||
set("sText_FoePkmnPrefix", text(" ennemi"))
|
||||
set("sText_TestAttackerUses", { { t = "bph", code = 0x0F }, { t = "text", s = " utilise" }, { t = "eos" } })
|
||||
eq(BattleText.get("sText_TestAttackerUses", { atk = { name = "ZIGZATON", side = "opponent" } }),
|
||||
"ZIGZATON sauvage utilise", "B_ATK_NAME_WITH_PREFIX puts the French wild word after the name")
|
||||
eq(BattleText.get("sText_TestAttackerUses", { atk = { name = "ZIGZATON", side = "opponent" }, trainer = true }),
|
||||
"ZIGZATON ennemi utilise", "and the foe word against a trainer")
|
||||
eq(BattleText.get("sText_TestAttackerUses", { atk = { name = "POUSSIFEU", side = "player" } }),
|
||||
"POUSSIFEU utilise", "the player's own POKéMON has no prefix")
|
||||
-- src/battle_message.c:4649 B_BUFF_MON_NICK_WITH_PREFIX
|
||||
eq(State.prefixedName({ wild = true }, { side = "opponent" }, "ZIGZATON"), "ZIGZATON sauvage",
|
||||
"a buffered name takes the same order")
|
||||
eq(State.prefixedName({ wild = false }, { side = "opponent" }, "ZIGZATON"), "ZIGZATON ennemi",
|
||||
"a buffered foe name too")
|
||||
set("sText_WildPkmnPrefix", text("Wild "))
|
||||
eq(State.prefixedName({ wild = true }, { side = "opponent" }, "ZIGZAGOON"), "Wild ZIGZAGOON",
|
||||
"the US row still goes first")
|
||||
|
||||
for key, ir in pairs(saved) do RomText.overrides[key] = ir or nil end
|
||||
|
||||
T.finish("game3_european_mon_prefix_test")
|
||||
Reference in New Issue
Block a user