mirror of
https://github.com/infinitefusion/infinitefusion-e18.git
synced 2025-12-06 06:01:46 +00:00
NPC trainers' end of battle text is now read directly from the trainer object rather than extracted to an array
This commit is contained in:
@@ -55,8 +55,6 @@ class Battle
|
||||
attr_reader :opponent # Opponent trainer (or array of trainers)
|
||||
attr_accessor :items # Items held by opponents
|
||||
attr_accessor :ally_items # Items held by allies
|
||||
attr_accessor :endSpeeches
|
||||
attr_accessor :endSpeechesWin
|
||||
attr_accessor :party1starts # Array of start indexes for each player-side trainer's party
|
||||
attr_accessor :party2starts # Array of start indexes for each opponent-side trainer's party
|
||||
attr_accessor :internalBattle # Internal battle flag
|
||||
@@ -123,8 +121,6 @@ class Battle
|
||||
@opponent = opponent # Array of NPCTrainer objects, or nil
|
||||
@items = nil
|
||||
@ally_items = nil # Array of items held by ally. This is just used for Mega Evolution for now.
|
||||
@endSpeeches = []
|
||||
@endSpeechesWin = []
|
||||
@party1 = p1
|
||||
@party2 = p2
|
||||
@party1order = Array.new(@party1.length) { |i| i }
|
||||
|
||||
@@ -412,9 +412,10 @@ class Battle
|
||||
pbDisplayPaused(_INTL("You defeated {1}, {2} and {3}!", @opponent[0].full_name,
|
||||
@opponent[1].full_name, @opponent[2].full_name))
|
||||
end
|
||||
@opponent.each_with_index do |_t, i|
|
||||
@opponent.each_with_index do |trainer, i|
|
||||
@scene.pbShowOpponent(i)
|
||||
msg = (@endSpeeches[i] && @endSpeeches[i] != "") ? @endSpeeches[i] : "..."
|
||||
msg = trainer.lose_text
|
||||
msg = "..." if !msg || msg.empty?
|
||||
pbDisplayPaused(msg.gsub(/\\[Pp][Nn]/, pbPlayer.name))
|
||||
end
|
||||
end
|
||||
@@ -444,11 +445,12 @@ class Battle
|
||||
# Lose money from losing a battle
|
||||
pbLoseMoney
|
||||
pbDisplayPaused(_INTL("You blacked out!")) if !@canLose
|
||||
elsif @decision == 2
|
||||
elsif @decision == 2 # Lost in a Battle Frontier battle
|
||||
if @opponent
|
||||
@opponent.each_with_index do |_t, i|
|
||||
@opponent.each_with_index do |trainer, i|
|
||||
@scene.pbShowOpponent(i)
|
||||
msg = (@endSpeechesWin[i] && @endSpeechesWin[i] != "") ? @endSpeechesWin[i] : "..."
|
||||
msg = trainer.win_text
|
||||
msg = "..." if !msg || msg.empty?
|
||||
pbDisplayPaused(msg.gsub(/\\[Pp][Nn]/, pbPlayer.name))
|
||||
end
|
||||
end
|
||||
|
||||
@@ -33,14 +33,14 @@ module RecordedBattleModule
|
||||
if tr.is_a?(Player)
|
||||
ret.push([tr.trainer_type, tr.name.clone, tr.id, tr.badges.clone])
|
||||
else # NPCTrainer
|
||||
ret.push([tr.trainer_type, tr.name.clone, tr.id])
|
||||
ret.push([tr.trainer_type, tr.name.clone, tr.id, tr.lose_text || "...", tr.win_text || "..."])
|
||||
end
|
||||
end
|
||||
return ret
|
||||
elsif trainer[i].is_a?(Player)
|
||||
return [[trainer.trainer_type, trainer.name.clone, trainer.id, trainer.badges.clone]]
|
||||
else
|
||||
return [[trainer.trainer_type, trainer.name.clone, trainer.id]]
|
||||
return [[trainer.trainer_type, trainer.name.clone, trainer.id, trainer.lose_text || "...", trainer.win_text || "..."]]
|
||||
end
|
||||
end
|
||||
|
||||
@@ -53,8 +53,6 @@ module RecordedBattleModule
|
||||
@properties["party2"] = Marshal.dump(@party2)
|
||||
@properties["party1starts"] = Marshal.dump(@party1starts)
|
||||
@properties["party2starts"] = Marshal.dump(@party2starts)
|
||||
@properties["endSpeeches"] = (@endSpeeches) ? @endSpeeches.clone : ""
|
||||
@properties["endSpeechesWin"] = (@endSpeechesWin) ? @endSpeechesWin.clone : ""
|
||||
@properties["weather"] = @field.weather
|
||||
@properties["weatherDuration"] = @field.weatherDuration
|
||||
@properties["canRun"] = @canRun
|
||||
@@ -167,8 +165,6 @@ module RecordedBattlePlaybackModule
|
||||
@party1starts = Marshal.restore(@properties["party1starts"])
|
||||
@party2starts = Marshal.restore(@properties["party2starts"])
|
||||
@internalBattle = @properties["internalBattle"]
|
||||
@endSpeeches = @properties["endSpeeches"]
|
||||
@endSpeechesWin = @properties["endSpeechesWin"]
|
||||
@field.weather = @properties["weather"]
|
||||
@field.weatherDuration = @properties["weatherDuration"]
|
||||
@canRun = @properties["canRun"]
|
||||
@@ -280,6 +276,8 @@ module RecordedBattle::PlaybackHelper
|
||||
t.badges = tr[3]
|
||||
else # NPCTrainer
|
||||
t = NPCTrainer.new(tr[1], tr[0])
|
||||
t.lose_text = tr[3] || "..."
|
||||
t.win_text = tr[4] || "..."
|
||||
end
|
||||
t.id = tr[2]
|
||||
ret.push(t)
|
||||
|
||||
@@ -484,7 +484,7 @@ class TrainerBattle
|
||||
# comparing levels for an evolution check)
|
||||
EventHandlers.trigger(:on_start_battle)
|
||||
# Generate information for the foes
|
||||
foe_trainers, foe_items, end_speeches, foe_party, foe_party_starts = TrainerBattle.generate_foes(*args)
|
||||
foe_trainers, foe_items, foe_party, foe_party_starts = TrainerBattle.generate_foes(*args)
|
||||
# Generate information for the player and partner trainer(s)
|
||||
player_trainers, ally_items, player_party, player_party_starts = BattleCreationHelperMethods.set_up_player_trainers(foe_party)
|
||||
# Create the battle scene (the visual side of it)
|
||||
@@ -495,7 +495,6 @@ class TrainerBattle
|
||||
battle.party2starts = foe_party_starts
|
||||
battle.ally_items = ally_items
|
||||
battle.items = foe_items
|
||||
battle.endSpeeches = end_speeches
|
||||
# Set various other properties in the battle class
|
||||
setBattleRule("#{foe_trainers.length}v#{foe_trainers.length}") if $game_temp.battle_rules["size"].nil?
|
||||
BattleCreationHelperMethods.prepare_battle(battle)
|
||||
@@ -517,7 +516,6 @@ class TrainerBattle
|
||||
def self.generate_foes(*args)
|
||||
trainer_array = []
|
||||
foe_items = []
|
||||
end_speeches = []
|
||||
pokemon_array = []
|
||||
party_starts = []
|
||||
trainer_type = nil
|
||||
@@ -528,7 +526,6 @@ class TrainerBattle
|
||||
raise _INTL("Trainer type {1} was given but not a trainer name.", trainer_type) if trainer_type
|
||||
trainer_array.push(arg)
|
||||
foe_items.push(arg.items)
|
||||
end_speeches.push(arg.lose_text)
|
||||
party_starts.push(pokemon_array.length)
|
||||
arg.party.each { |pkmn| pokemon_array.push(pkmn) }
|
||||
when Array # [trainer type, trainer name, version number, speech (optional)]
|
||||
@@ -538,9 +535,9 @@ class TrainerBattle
|
||||
trainer = pbLoadTrainer(arg[0], arg[1], arg[2]) if !trainer # Try again
|
||||
raise _INTL("Trainer for data '{1}' is not defined.", arg) if !trainer
|
||||
EventHandlers.trigger(:on_trainer_load, trainer)
|
||||
trainer.lose_text = arg[3] if arg[3] && !arg[3].empty?
|
||||
trainer_array.push(trainer)
|
||||
foe_items.push(trainer.items)
|
||||
end_speeches.push(arg[3] || trainer.lose_text)
|
||||
party_starts.push(pokemon_array.length)
|
||||
trainer.party.each { |pkmn| pokemon_array.push(pkmn) }
|
||||
else
|
||||
@@ -555,7 +552,6 @@ class TrainerBattle
|
||||
EventHandlers.trigger(:on_trainer_load, trainer)
|
||||
trainer_array.push(trainer)
|
||||
foe_items.push(trainer.items)
|
||||
end_speeches.push(trainer.lose_text)
|
||||
party_starts.push(pokemon_array.length)
|
||||
trainer.party.each { |pkmn| pokemon_array.push(pkmn) }
|
||||
trainer_type = nil
|
||||
@@ -574,7 +570,6 @@ class TrainerBattle
|
||||
EventHandlers.trigger(:on_trainer_load, trainer)
|
||||
trainer_array.push(trainer)
|
||||
foe_items.push(trainer.items)
|
||||
end_speeches.push(trainer.lose_text)
|
||||
party_starts.push(pokemon_array.length)
|
||||
trainer.party.each { |pkmn| pokemon_array.push(pkmn) }
|
||||
trainer_type = nil
|
||||
@@ -588,7 +583,7 @@ class TrainerBattle
|
||||
end
|
||||
end
|
||||
raise _INTL("Trainer type {1} was given but not a trainer name.", trainer_type) if trainer_type
|
||||
return trainer_array, foe_items, end_speeches, pokemon_array, party_starts
|
||||
return trainer_array, foe_items, pokemon_array, party_starts
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -180,10 +180,12 @@ end
|
||||
class NPCTrainer < Trainer
|
||||
attr_accessor :items
|
||||
attr_accessor :lose_text
|
||||
attr_accessor :win_text
|
||||
|
||||
def initialize(name, trainer_type)
|
||||
super
|
||||
@items = []
|
||||
@lose_text = nil
|
||||
@win_text = nil
|
||||
end
|
||||
end
|
||||
|
||||
@@ -98,9 +98,9 @@ class BattleChallenge
|
||||
opponent = pbGenerateBattleTrainer(self.nextTrainer, self.rules)
|
||||
bttrainers = pbGetBTTrainers(@id)
|
||||
trainerdata = bttrainers[self.nextTrainer]
|
||||
ret = pbOrganizedBattleEx(opponent, self.rules,
|
||||
pbGetMessageFromHash(MessageTypes::EndSpeechLose, trainerdata[4]),
|
||||
pbGetMessageFromHash(MessageTypes::EndSpeechWin, trainerdata[3]))
|
||||
opponent.lose_text = pbGetMessageFromHash(MessageTypes::EndSpeechLose, trainerdata[4])
|
||||
opponent.win_text = pbGetMessageFromHash(MessageTypes::EndSpeechWin, trainerdata[3])
|
||||
ret = pbOrganizedBattleEx(opponent, self.rules)
|
||||
return ret
|
||||
end
|
||||
|
||||
@@ -375,6 +375,8 @@ class BattleFactoryData
|
||||
pbGetMessageFromHash(MessageTypes::TrainerNames, trainerdata[1]),
|
||||
trainerdata[0]
|
||||
)
|
||||
@opponent.lose_text = pbGetMessageFromHash(MessageTypes::EndSpeechLose, trainerdata[4])
|
||||
@opponent.win_text = pbGetMessageFromHash(MessageTypes::EndSpeechWin, trainerdata[3])
|
||||
opponentPkmn = pbBattleFactoryPokemon(pbBattleChallenge.rules, @bcdata.wins, @bcdata.swaps, @rentals)
|
||||
@opponent.party = opponentPkmn.sample(3)
|
||||
end
|
||||
@@ -398,6 +400,8 @@ class BattleFactoryData
|
||||
pbGetMessageFromHash(MessageTypes::TrainerNames, trainerdata[1]),
|
||||
trainerdata[0]
|
||||
)
|
||||
@opponent.lose_text = pbGetMessageFromHash(MessageTypes::EndSpeechLose, trainerdata[4])
|
||||
@opponent.win_text = pbGetMessageFromHash(MessageTypes::EndSpeechWin, trainerdata[3])
|
||||
opponentPkmn = pbBattleFactoryPokemon(pbBattleChallenge.rules, @bcdata.wins, @bcdata.swaps,
|
||||
[].concat(@rentals).concat(@oldopponent))
|
||||
@opponent.party = opponentPkmn.sample(3)
|
||||
@@ -418,8 +422,6 @@ class BattleFactoryData
|
||||
def pbBattle(challenge)
|
||||
bttrainers = pbGetBTTrainers(pbBattleChallenge.currentChallenge)
|
||||
trainerdata = bttrainers[@trainerid]
|
||||
return pbOrganizedBattleEx(@opponent, challenge.rules,
|
||||
pbGetMessageFromHash(MessageTypes::EndSpeechLose, trainerdata[4]),
|
||||
pbGetMessageFromHash(MessageTypes::EndSpeechWin, trainerdata[3]))
|
||||
return pbOrganizedBattleEx(@opponent, challenge.rules)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -37,12 +37,12 @@ end
|
||||
#===============================================================================
|
||||
#
|
||||
#===============================================================================
|
||||
def pbOrganizedBattleEx(opponent, challengedata, endspeech, endspeechwin)
|
||||
def pbOrganizedBattleEx(opponent, challengedata)
|
||||
# Skip battle if holding Ctrl in Debug mode
|
||||
if Input.press?(Input::CTRL) && $DEBUG
|
||||
pbMessage(_INTL("SKIPPING BATTLE..."))
|
||||
pbMessage(_INTL("AFTER WINNING..."))
|
||||
pbMessage(endspeech || "...")
|
||||
pbMessage(opponent.lose_text || "...")
|
||||
$game_temp.last_battle_record = nil
|
||||
pbMEStop
|
||||
return true
|
||||
@@ -58,8 +58,6 @@ def pbOrganizedBattleEx(opponent, challengedata, endspeech, endspeechwin)
|
||||
# Create the battle class (the mechanics side of it)
|
||||
battle = challengedata.createBattle(scene, $player, opponent)
|
||||
battle.internalBattle = false
|
||||
battle.endSpeeches = [endspeech]
|
||||
battle.endSpeechesWin = [endspeechwin]
|
||||
# Set various other properties in the battle class
|
||||
BattleCreationHelperMethods.prepare_battle(battle)
|
||||
# Perform the battle itself
|
||||
|
||||
Reference in New Issue
Block a user