mirror of
https://github.com/bryanthaboi/gen1recomp.git
synced 2026-08-17 11:11:10 +02:00
Merge pull request #759 from jherediagu/fix/rom-text-statuses-items-evolve
Extend ROM-text messages to statuses, items and the learn/evolve flows
This commit is contained in:
@@ -385,8 +385,8 @@ local function displayName(b)
|
||||
end
|
||||
|
||||
-- Apply the "Enemy " prefix to a pre-built message from a module that
|
||||
-- only knows the raw nickname (Status.beforeMove/residual,
|
||||
-- TrainerAI.useItem): splice it in before the first name occurrence.
|
||||
-- only knows the raw nickname (Status.beforeMove/residual): splice it
|
||||
-- in before the first name occurrence.
|
||||
local function prefixEnemy(msg, battler)
|
||||
if battler.isPlayer then return msg end
|
||||
local s = msg:find(battler.name, 1, true)
|
||||
@@ -3044,8 +3044,11 @@ function BattleState:executeAction(user, target, action)
|
||||
-- trainer class AI actions (engine/battle/trainer_ai.asm)
|
||||
if action.special == "aiItem" then
|
||||
self.aiUses = (self.aiUses or 1) - 1
|
||||
-- useItem's messages arrive final: its item line prints the raw
|
||||
-- nickname on purpose (no "Enemy " in AIPrintItemUseText), so the
|
||||
-- prefix splice must not touch them.
|
||||
for _, m in ipairs(TrainerAI.useItem(self, action.item)) do
|
||||
self:sayNext(prefixEnemy(m, self.enemy))
|
||||
self:sayNext(m)
|
||||
end
|
||||
self:drainNext()
|
||||
require("src.core.Sound").play(self.data, "Heal_Ailment")
|
||||
|
||||
+49
-30
@@ -6,6 +6,7 @@
|
||||
-- back to the vanilla records, which is bit-identical behavior.
|
||||
|
||||
local Strings = require("src.core.Strings")
|
||||
local romText = require("src.core.RomText")
|
||||
|
||||
local Status = {}
|
||||
|
||||
@@ -34,8 +35,8 @@ end
|
||||
-- sentence rather than the noun: "hurt by poison" and "hurt by the burn"
|
||||
-- decline differently once translated, so a shared fragment cannot be the
|
||||
-- translatable unit.
|
||||
local function damageOverTime(template)
|
||||
return function(battler)
|
||||
local function damageOverTime(label, template)
|
||||
return function(battler, _, battle)
|
||||
local mon = battler.mon
|
||||
local base = math.max(1, math.floor(mon.stats.hp / 16))
|
||||
local dmg = base
|
||||
@@ -44,7 +45,7 @@ local function damageOverTime(template)
|
||||
battler.toxicCounter = battler.toxicCounter + 1
|
||||
end
|
||||
mon.hp = math.max(0, mon.hp - dmg)
|
||||
return { Strings(template, name(battler)) }
|
||||
return { romText(battle and battle.data, label, template, name(battler)) }
|
||||
end
|
||||
end
|
||||
|
||||
@@ -63,53 +64,63 @@ Status.RECORDS = {
|
||||
id = "SLP", label = "SLP", hudLabel = "SLP",
|
||||
catchBonus = 25, shakeBonus = 10,
|
||||
beforeMovePriority = 40,
|
||||
beforeMove = function(battler)
|
||||
beforeMove = function(battler, _, battle)
|
||||
battler.sleepTurns = (battler.sleepTurns or 1) - 1
|
||||
if battler.sleepTurns <= 0 then
|
||||
battler.mon.status = nil
|
||||
return false, { Strings("%s\nwoke up!", name(battler)) } -- wakes, loses the turn
|
||||
-- wakes, loses the turn
|
||||
return false, { romText(battle and battle.data, "_WokeUpText",
|
||||
"%s\nwoke up!", name(battler)) }
|
||||
end
|
||||
return false, { Strings("%s\nis fast asleep!", name(battler)) }
|
||||
return false, { romText(battle and battle.data, "_FastAsleepText",
|
||||
"%s\nis fast asleep!", name(battler)) }
|
||||
end,
|
||||
onInflict = function(battle, target, opts, display)
|
||||
target.sleepTurns = battle.rng(1, 7)
|
||||
return { Strings("%s\nfell asleep!", display) }
|
||||
return { romText(battle.data, "_FellAsleepText",
|
||||
"%s\nfell asleep!", display) }
|
||||
end,
|
||||
},
|
||||
FRZ = {
|
||||
id = "FRZ", label = "FRZ", hudLabel = "FRZ",
|
||||
catchBonus = 25, shakeBonus = 10,
|
||||
beforeMovePriority = 30,
|
||||
beforeMove = function(battler)
|
||||
return false, { Strings("%s\nis frozen solid!", name(battler)) }
|
||||
beforeMove = function(battler, _, battle)
|
||||
return false, { romText(battle and battle.data, "_IsFrozenText",
|
||||
"%s\nis frozen solid!", name(battler)) }
|
||||
end,
|
||||
canInflict = function(target) return not hasType(target, "ICE") end,
|
||||
onInflict = function(_, _, _, display)
|
||||
return { Strings("%s\nwas frozen solid!", display) }
|
||||
onInflict = function(battle, _, _, display)
|
||||
return { romText(battle and battle.data, "_FrozenText",
|
||||
"%s\nwas frozen solid!", display) }
|
||||
end,
|
||||
},
|
||||
PSN = {
|
||||
id = "PSN", label = "PSN", hudLabel = "PSN",
|
||||
catchBonus = 12, shakeBonus = 5,
|
||||
residual = damageOverTime(Strings.source("%s's\nhurt by poison!")),
|
||||
residual = damageOverTime("_HurtByPoisonText",
|
||||
Strings.source("%s's\nhurt by poison!")),
|
||||
canInflict = function(target) return not hasType(target, "POISON") end,
|
||||
onInflict = function(_, target, opts, display)
|
||||
onInflict = function(battle, target, opts, display)
|
||||
if opts.toxic then
|
||||
target.toxicCounter = 1
|
||||
-- _BadlyPoisonedText
|
||||
return { Strings("%s's\nbadly poisoned!", display) }
|
||||
return { romText(battle and battle.data, "_BadlyPoisonedText",
|
||||
"%s's\nbadly poisoned!", display) }
|
||||
end
|
||||
return { Strings("%s\nwas poisoned!", display) }
|
||||
return { romText(battle and battle.data, "_PoisonedText",
|
||||
"%s\nwas poisoned!", display) }
|
||||
end,
|
||||
},
|
||||
BRN = {
|
||||
id = "BRN", label = "BRN", hudLabel = "BRN",
|
||||
catchBonus = 12, shakeBonus = 5,
|
||||
statPenalty = { stat = "attack", div = 2 },
|
||||
residual = damageOverTime(Strings.source("%s's\nhurt by the burn!")),
|
||||
residual = damageOverTime("_HurtByBurnText",
|
||||
Strings.source("%s's\nhurt by the burn!")),
|
||||
canInflict = function(target) return not hasType(target, "FIRE") end,
|
||||
onInflict = function(_, _, _, display)
|
||||
return { Strings("%s\nwas burned!", display) }
|
||||
onInflict = function(battle, _, _, display)
|
||||
return { romText(battle and battle.data, "_BurnedText",
|
||||
"%s\nwas burned!", display) }
|
||||
end,
|
||||
},
|
||||
PAR = {
|
||||
@@ -117,10 +128,11 @@ Status.RECORDS = {
|
||||
catchBonus = 12, shakeBonus = 5,
|
||||
statPenalty = { stat = "speed", div = 4 },
|
||||
beforeMovePriority = 10,
|
||||
beforeMove = function(battler, rng)
|
||||
beforeMove = function(battler, rng, battle)
|
||||
-- cp 25 percent / jr nc: fully paralyzed on rand < 63 (63/256)
|
||||
if rng(0, 255) < 63 then
|
||||
return false, { Strings("%s's\nfully paralyzed!", name(battler)) }
|
||||
return false, { romText(battle and battle.data, "_FullyParalyzedText",
|
||||
"%s's\nfully paralyzed!", name(battler)) }
|
||||
end
|
||||
return true, {}
|
||||
end,
|
||||
@@ -128,9 +140,10 @@ Status.RECORDS = {
|
||||
-- ParalyzeEffect_: Electric-type moves can't paralyze Ground-types
|
||||
return not (opts.moveType == "ELECTRIC" and hasType(target, "GROUND"))
|
||||
end,
|
||||
onInflict = function(_, _, _, display)
|
||||
-- _ParalyzedMayNotAttackText (primary and secondary paralysis)
|
||||
return { Strings("%s's\nparalyzed! It may\nnot attack!", display) }
|
||||
onInflict = function(battle, _, _, display)
|
||||
-- primary and secondary paralysis share this line
|
||||
return { romText(battle and battle.data, "_ParalyzedMayNotAttackText",
|
||||
"%s's\nparalyzed! It may\nnot attack!", display) }
|
||||
end,
|
||||
},
|
||||
}
|
||||
@@ -166,7 +179,8 @@ function Status.beforeMove(battler, rng, battle)
|
||||
end
|
||||
if battler.flinched then
|
||||
battler.flinched = false
|
||||
return false, { Strings("%s\nflinched!", name(battler)) }
|
||||
return false, { romText(battle and battle.data, "_FlinchedText",
|
||||
"%s\nflinched!", name(battler)) }
|
||||
end
|
||||
local record = Status.recordFor(battleStatuses(battle), mon.status)
|
||||
local handler = record and record.beforeMove
|
||||
@@ -184,23 +198,27 @@ function Status.beforeMove(battler, rng, battle)
|
||||
end
|
||||
if battler.boundTurns and battler.boundTurns > 0 then
|
||||
battler.boundTurns = battler.boundTurns - 1
|
||||
msgs[#msgs + 1] = Strings("%s\ncan't move!", name(battler))
|
||||
msgs[#msgs + 1] = romText(battle and battle.data, "_CantMoveText",
|
||||
"%s\ncan't move!", name(battler))
|
||||
return false, msgs
|
||||
end
|
||||
if battler.disabledTurns then
|
||||
battler.disabledTurns = battler.disabledTurns - 1
|
||||
if battler.disabledTurns <= 0 then
|
||||
battler.disabledTurns, battler.disabledSlot = nil, nil
|
||||
table.insert(msgs, Strings("%s's\ndisabled no more!", name(battler)))
|
||||
table.insert(msgs, romText(battle and battle.data, "_DisabledNoMoreText",
|
||||
"%s's\ndisabled no more!", name(battler)))
|
||||
end
|
||||
end
|
||||
if battler.confusedTurns then
|
||||
battler.confusedTurns = battler.confusedTurns - 1
|
||||
if battler.confusedTurns <= 0 then
|
||||
battler.confusedTurns = nil
|
||||
table.insert(msgs, Strings("%s\nsnapped out of\nconfusion!", name(battler)))
|
||||
table.insert(msgs, romText(battle and battle.data, "_ConfusedNoMoreText",
|
||||
"%s\nsnapped out of\nconfusion!", name(battler)))
|
||||
else
|
||||
table.insert(msgs, Strings("%s\nis confused!", name(battler)))
|
||||
table.insert(msgs, romText(battle and battle.data, "_IsConfusedText",
|
||||
"%s\nis confused!", name(battler)))
|
||||
-- cp 50 percent + 1 / jr c: hurt itself on rand >= 128 (128/256)
|
||||
if rng(0, 255) < 128 then
|
||||
return false, msgs, true -- hurt itself
|
||||
@@ -241,7 +259,8 @@ function Status.residual(battler, opponent, battle)
|
||||
dmg = math.min(dmg, mon.hp)
|
||||
mon.hp = mon.hp - dmg
|
||||
opponent.mon.hp = math.min(opponent.mon.stats.hp, opponent.mon.hp + dmg)
|
||||
table.insert(msgs, Strings("LEECH SEED saps\n%s!", name(battler)))
|
||||
table.insert(msgs, romText(battle and battle.data, "_HurtByLeechSeedText",
|
||||
"LEECH SEED saps\n%s!", name(battler)))
|
||||
end
|
||||
return msgs
|
||||
end
|
||||
|
||||
@@ -20,9 +20,16 @@
|
||||
|
||||
local TypeChart = require("src.battle.TypeChart")
|
||||
local Strings = require("src.core.Strings")
|
||||
local romText = require("src.core.RomText")
|
||||
|
||||
local TrainerAI = {}
|
||||
|
||||
-- pokered's <USER>/<TARGET> text macros print "Enemy " before the
|
||||
-- enemy mon's nickname (home/text.asm PlaceMoveUsersName)
|
||||
local function displayName(b)
|
||||
return b.isPlayer and b.name or ("Enemy " .. b.name)
|
||||
end
|
||||
|
||||
local HEAL_AMOUNT = { POTION = 20, SUPER_POTION = 50, HYPER_POTION = 200 }
|
||||
local X_STAT = { X_ATTACK = "attack", X_DEFEND = "defense", X_SPEED = "speed" }
|
||||
|
||||
@@ -95,12 +102,16 @@ function TrainerAI.switchAction(battle)
|
||||
return { special = "aiSwitch", index = alive[1] }
|
||||
end
|
||||
|
||||
-- Apply an aiItem action to the enemy battler; returns messages.
|
||||
-- Apply an aiItem action to the enemy battler; returns messages, already
|
||||
-- final: the item line prints the raw nickname (AIPrintItemUseText has no
|
||||
-- "Enemy " prefix in pokered), the stat lines carry it via displayName, so
|
||||
-- the caller must not run these through prefixEnemy.
|
||||
function TrainerAI.useItem(battle, item)
|
||||
local enemy = battle.enemy
|
||||
local trainerName = battle.trainer.name
|
||||
local itemName = battle.data.items[item] and battle.data.items[item].name or item
|
||||
local msgs = { Strings("%s\nused %s!", trainerName, itemName) }
|
||||
local msgs = { romText(battle.data, "_AIBattleUseItemText",
|
||||
"%s\nused %s!", trainerName, itemName, enemy.name) }
|
||||
if item == "FULL_HEAL" then
|
||||
enemy.mon.status = nil
|
||||
enemy.toxicCounter = nil
|
||||
@@ -113,10 +124,10 @@ function TrainerAI.useItem(battle, item)
|
||||
elseif X_STAT[item] then
|
||||
local stat = X_STAT[item]
|
||||
enemy.stages[stat] = math.min(6, (enemy.stages[stat] or 0) + 1)
|
||||
table.insert(msgs, Strings("%s's\n%s rose!", enemy.name, stat:upper()))
|
||||
table.insert(msgs, Strings("%s's\n%s rose!", displayName(enemy), stat:upper()))
|
||||
elseif item == "GUARD_SPEC" then
|
||||
enemy.mist = true
|
||||
table.insert(msgs, Strings("%s's\nprotected against\nstat changes!", enemy.name))
|
||||
table.insert(msgs, Strings("%s's\nprotected against\nstat changes!", displayName(enemy)))
|
||||
end
|
||||
return msgs
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user