mirror of
https://github.com/bryanthaboi/gen1recomp.git
synced 2026-08-16 08:11:35 +02:00
Extend ROM-text messages to statuses, items and the learn/evolve flows
This commit is contained in:
+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
|
||||
|
||||
Reference in New Issue
Block a user