From d3b61a64efe7fe0ab53cd6ef7c96426acdcd674b Mon Sep 17 00:00:00 2001 From: Maruno17 Date: Wed, 20 Apr 2022 22:11:04 +0100 Subject: [PATCH] Turned trainer intro MEs into BGMs --- Data/Scripts/003_Game processing/003_Interpreter.rb | 2 +- .../001_Switches and Variables/001_Game_Temp.rb | 4 ++++ Data/Scripts/010_Data/002_PBS data/014_TrainerType.rb | 6 +++--- .../001_Overworld_BattleStarting.rb | 2 -- .../002_Overworld_BattleIntroAnim.rb | 9 ++++++--- .../Scripts/019_Utilities/003_Utilities_BattleAudio.rb | 10 ++++++---- .../020_Debug/001_Editor screens/001_EditorScreens.rb | 6 +++--- Data/Scripts/021_Compiler/002_Compiler_CompilePBS.rb | 2 +- Data/Scripts/021_Compiler/003_Compiler_WritePBS.rb | 2 +- 9 files changed, 25 insertions(+), 18 deletions(-) diff --git a/Data/Scripts/003_Game processing/003_Interpreter.rb b/Data/Scripts/003_Game processing/003_Interpreter.rb index b7fea5939..29869dcf3 100644 --- a/Data/Scripts/003_Game processing/003_Interpreter.rb +++ b/Data/Scripts/003_Game processing/003_Interpreter.rb @@ -438,7 +438,7 @@ class Interpreter return true if $DEBUG && !GameData::TrainerType.exists?(symbol) tr_type = GameData::TrainerType.get(symbol).id pbGlobalLock - pbPlayTrainerIntroME(tr_type) + pbPlayTrainerIntroBGM(tr_type) return true end diff --git a/Data/Scripts/004_Game classes/001_Switches and Variables/001_Game_Temp.rb b/Data/Scripts/004_Game classes/001_Switches and Variables/001_Game_Temp.rb index 61f28fe52..569977385 100644 --- a/Data/Scripts/004_Game classes/001_Switches and Variables/001_Game_Temp.rb +++ b/Data/Scripts/004_Game classes/001_Switches and Variables/001_Game_Temp.rb @@ -42,6 +42,8 @@ class Game_Temp attr_accessor :begun_new_game # new game flag (true fron new game until saving) attr_accessor :menu_beep # menu: play sound effect flag attr_accessor :menu_last_choice # pause menu: index of last selection + attr_accessor :memorized_bgm # set when trainer intro BGM is played + attr_accessor :memorized_bgm_position # set when trainer intro BGM is played attr_accessor :darkness_sprite # DarknessSprite or nil attr_accessor :mart_prices @@ -80,6 +82,8 @@ class Game_Temp # Other @begun_new_game = false @menu_beep = false + @memorized_bgm = nil + @memorized_bgm_position = 0 @menu_last_choice = 0 @mart_prices = {} end diff --git a/Data/Scripts/010_Data/002_PBS data/014_TrainerType.rb b/Data/Scripts/010_Data/002_PBS data/014_TrainerType.rb index 16de68c47..d91fe73c7 100644 --- a/Data/Scripts/010_Data/002_PBS data/014_TrainerType.rb +++ b/Data/Scripts/010_Data/002_PBS data/014_TrainerType.rb @@ -6,7 +6,7 @@ module GameData attr_reader :base_money attr_reader :skill_level attr_reader :flags - attr_reader :intro_ME + attr_reader :intro_BGM attr_reader :battle_BGM attr_reader :victory_ME @@ -22,7 +22,7 @@ module GameData "BaseMoney" => [:base_money, "u"], "SkillLevel" => [:skill_level, "u"], "Flags" => [:flags, "*s"], - "IntroME" => [:intro_ME, "s"], + "IntroBGM" => [:intro_BGM, "s"], "BattleBGM" => [:battle_BGM, "s"], "VictoryME" => [:victory_ME, "s"] } @@ -86,7 +86,7 @@ module GameData @base_money = hash[:base_money] || 30 @skill_level = hash[:skill_level] || @base_money @flags = hash[:flags] || [] - @intro_ME = hash[:intro_ME] + @intro_BGM = hash[:intro_BGM] @battle_BGM = hash[:battle_BGM] @victory_ME = hash[:victory_ME] end diff --git a/Data/Scripts/012_Overworld/002_Battle triggering/001_Overworld_BattleStarting.rb b/Data/Scripts/012_Overworld/002_Battle triggering/001_Overworld_BattleStarting.rb index 9049809e6..173d255a5 100644 --- a/Data/Scripts/012_Overworld/002_Battle triggering/001_Overworld_BattleStarting.rb +++ b/Data/Scripts/012_Overworld/002_Battle triggering/001_Overworld_BattleStarting.rb @@ -453,8 +453,6 @@ def pbTrainerBattleCore(*args) # Set various other properties in the battle class pbPrepareBattle(battle) $game_temp.clear_battle_rules - # End the trainer intro music - Audio.me_stop # Perform the battle itself decision = 0 pbBattleAnimation(pbGetTrainerBattleBGM(foeTrainers), (battle.singleBattle?) ? 1 : 3, foeTrainers) { diff --git a/Data/Scripts/012_Overworld/002_Battle triggering/002_Overworld_BattleIntroAnim.rb b/Data/Scripts/012_Overworld/002_Battle triggering/002_Overworld_BattleIntroAnim.rb index 89f36154e..d79af56d6 100644 --- a/Data/Scripts/012_Overworld/002_Battle triggering/002_Overworld_BattleIntroAnim.rb +++ b/Data/Scripts/012_Overworld/002_Battle triggering/002_Overworld_BattleIntroAnim.rb @@ -68,10 +68,11 @@ def pbBattleAnimation(bgm = nil, battletype = 0, foe = nil) playingBGM = $game_system.getPlayingBGM $game_system.bgm_pause $game_system.bgs_pause + if $game_temp.memorized_bgm + playingBGM = $game_temp.memorized_bgm + $game_system.bgm_position = $game_temp.memorized_bgm_position + end end - pbMEFade(0.25) - pbWait(Graphics.frame_rate / 4) - pbMEStop # Play battle music bgm = pbGetWildBattleBGM([]) if !bgm pbBGMPlay(bgm) @@ -129,6 +130,8 @@ def pbBattleAnimation(bgm = nil, battletype = 0, foe = nil) $game_system.bgm_resume(playingBGM) $game_system.bgs_resume(playingBGS) end + $game_temp.memorized_bgm = nil + $game_temp.memorized_bgm_position = 0 $PokemonGlobal.nextBattleBGM = nil $PokemonGlobal.nextBattleME = nil $PokemonGlobal.nextBattleCaptureME = nil diff --git a/Data/Scripts/019_Utilities/003_Utilities_BattleAudio.rb b/Data/Scripts/019_Utilities/003_Utilities_BattleAudio.rb index 9b2a4b100..512a5488d 100644 --- a/Data/Scripts/019_Utilities/003_Utilities_BattleAudio.rb +++ b/Data/Scripts/019_Utilities/003_Utilities_BattleAudio.rb @@ -63,11 +63,13 @@ end #=============================================================================== # Load/play various trainer battle music #=============================================================================== -def pbPlayTrainerIntroME(trainer_type) +def pbPlayTrainerIntroBGM(trainer_type) trainer_type_data = GameData::TrainerType.get(trainer_type) - return if nil_or_empty?(trainer_type_data.intro_ME) - bgm = pbStringToAudioFile(trainer_type_data.intro_ME) - pbMEPlay(bgm) + return if nil_or_empty?(trainer_type_data.intro_BGM) + bgm = pbStringToAudioFile(trainer_type_data.intro_BGM) + $game_temp.memorized_bgm = $game_system.getPlayingBGM + $game_temp.memorized_bgm_position = (Audio.bgm_pos rescue 0) + pbBGMPlay(bgm) end def pbGetTrainerBattleBGM(trainer) # can be a Player, NPCTrainer or an array of them diff --git a/Data/Scripts/020_Debug/001_Editor screens/001_EditorScreens.rb b/Data/Scripts/020_Debug/001_Editor screens/001_EditorScreens.rb index 321d943c1..5f43ec7be 100644 --- a/Data/Scripts/020_Debug/001_Editor screens/001_EditorScreens.rb +++ b/Data/Scripts/020_Debug/001_Editor screens/001_EditorScreens.rb @@ -353,7 +353,7 @@ def pbTrainerTypeEditor [_INTL("BaseMoney"), LimitProperty.new(9999), _INTL("Player earns this much money times the highest level among the trainer's Pokémon.")], [_INTL("SkillLevel"), LimitProperty.new(9999), _INTL("Skill level of this Trainer Type.")], [_INTL("Flags"), StringListProperty, _INTL("Words/phrases that can be used to make trainers of this type behave differently to others.")], - [_INTL("IntroME"), MEProperty, _INTL("ME played before battles against trainers of this type.")], + [_INTL("IntroBGM"), BGMProperty, _INTL("BGM played before battles against trainers of this type.")], [_INTL("BattleBGM"), BGMProperty, _INTL("BGM played in battles against trainers of this type.")], [_INTL("VictoryME"), MEProperty, _INTL("ME played when player wins battles against trainers of this type.")] ] @@ -377,7 +377,7 @@ def pbTrainerTypeEditor t_data.base_money, t_data.skill_level, t_data.flags, - t_data.intro_ME, + t_data.intro_BGM, t_data.battle_BGM, t_data.victory_ME ] @@ -390,7 +390,7 @@ def pbTrainerTypeEditor :base_money => data[3], :skill_level => data[4], :flags => data[5], - :intro_ME => data[6], + :intro_BGM => data[6], :battle_BGM => data[7], :victory_ME => data[8] } diff --git a/Data/Scripts/021_Compiler/002_Compiler_CompilePBS.rb b/Data/Scripts/021_Compiler/002_Compiler_CompilePBS.rb index d6d362f03..5c979e5bd 100644 --- a/Data/Scripts/021_Compiler/002_Compiler_CompilePBS.rb +++ b/Data/Scripts/021_Compiler/002_Compiler_CompilePBS.rb @@ -1399,7 +1399,7 @@ module Compiler :base_money => line[3], :battle_BGM => line[4], :victory_ME => line[5], - :intro_ME => line[6], + :intro_BGM => line[6], :gender => line[7], :skill_level => line[8], :flags => line[9] diff --git a/Data/Scripts/021_Compiler/003_Compiler_WritePBS.rb b/Data/Scripts/021_Compiler/003_Compiler_WritePBS.rb index ff591a45c..026f971a2 100644 --- a/Data/Scripts/021_Compiler/003_Compiler_WritePBS.rb +++ b/Data/Scripts/021_Compiler/003_Compiler_WritePBS.rb @@ -634,7 +634,7 @@ module Compiler f.write(sprintf("BaseMoney = %d\r\n", t.base_money)) f.write(sprintf("SkillLevel = %d\r\n", t.skill_level)) if t.skill_level != t.base_money f.write(sprintf("Flags = %s\r\n", t.flags.join(","))) if t.flags.length > 0 - f.write(sprintf("IntroME = %s\r\n", t.intro_ME)) if !nil_or_empty?(t.intro_ME) + f.write(sprintf("IntroBGM = %s\r\n", t.intro_BGM)) if !nil_or_empty?(t.intro_BGM) f.write(sprintf("BattleBGM = %s\r\n", t.battle_BGM)) if !nil_or_empty?(t.battle_BGM) f.write(sprintf("VictoryME = %s\r\n", t.victory_ME)) if !nil_or_empty?(t.victory_ME) end