mirror of
https://github.com/infinitefusion/infinitefusion-e18.git
synced 2026-07-21 23:27:00 +00:00
172 lines
5.9 KiB
Ruby
172 lines
5.9 KiB
Ruby
#===============================================================================
|
|
# Load various wild battle music
|
|
#===============================================================================
|
|
def pbGetWildBattleBGM(_wildParty) # wildParty is an array of Pokémon objects
|
|
if $PokemonGlobal.nextBattleBGM
|
|
return $PokemonGlobal.nextBattleBGM.clone
|
|
end
|
|
ret = nil
|
|
if !ret
|
|
# Check map metadata
|
|
map_metadata = GameData::MapMetadata.try_get($game_map.map_id)
|
|
music = (map_metadata) ? map_metadata.wild_battle_BGM : nil
|
|
ret = pbStringToAudioFile(music) if music && music != ""
|
|
end
|
|
if !ret
|
|
# Check global metadata
|
|
music = GameData::Metadata.get.wild_battle_BGM
|
|
ret = pbStringToAudioFile(music) if music && music!=""
|
|
end
|
|
ret = pbStringToAudioFile("battle_wild") if !ret
|
|
return ret
|
|
end
|
|
|
|
def pbGetWildVictoryME
|
|
if $PokemonGlobal.nextBattleME
|
|
return $PokemonGlobal.nextBattleME.clone
|
|
end
|
|
ret = pbStringToAudioFile(Settings::WILD_VICTORY_MUSIC)
|
|
ret.name = "../../Audio/ME/"+ret.name
|
|
return ret
|
|
end
|
|
|
|
def pbGetWildCaptureME
|
|
if $PokemonGlobal.nextBattleCaptureME
|
|
return $PokemonGlobal.nextBattleCaptureME.clone
|
|
end
|
|
ret = nil
|
|
if !ret
|
|
# Check map metadata
|
|
map_metadata = GameData::MapMetadata.try_get($game_map.map_id)
|
|
music = (map_metadata) ? map_metadata.wild_capture_ME : nil
|
|
ret = pbStringToAudioFile(music) if music && music != ""
|
|
end
|
|
if !ret
|
|
# Check global metadata
|
|
music = GameData::Metadata.get.wild_capture_ME
|
|
ret = pbStringToAudioFile(music) if music && music!=""
|
|
end
|
|
ret = pbStringToAudioFile("Battle capture success") if !ret
|
|
ret.name = "../../Audio/ME/"+ret.name
|
|
return ret
|
|
end
|
|
|
|
#===============================================================================
|
|
# Load/play various trainer battle music
|
|
#===============================================================================
|
|
def pbPlayTrainerIntroME(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)
|
|
end
|
|
|
|
def pbGetTrainerBattleBGM(trainer) # can be a Player, NPCTrainer or an array of them
|
|
if $PokemonGlobal.nextBattleBGM
|
|
return $PokemonGlobal.nextBattleBGM.clone
|
|
end
|
|
ret = nil
|
|
music = nil
|
|
trainerarray = (trainer.is_a?(Array)) ? trainer : [trainer]
|
|
trainerarray.each do |t|
|
|
trainer_type_data = GameData::TrainerType.get(t.trainer_type)
|
|
music = trainer_type_data.battle_BGM if trainer_type_data.battle_BGM
|
|
end
|
|
ret = pbStringToAudioFile(music) if music && music!=""
|
|
if !ret
|
|
# Check map metadata
|
|
map_metadata = GameData::MapMetadata.try_get($game_map.map_id)
|
|
music = (map_metadata) ? map_metadata.trainer_battle_BGM : nil
|
|
ret = pbStringToAudioFile(music) if music && music != ""
|
|
end
|
|
if !ret
|
|
# Check global metadata
|
|
music = GameData::Metadata.get.trainer_battle_BGM
|
|
if music && music!=""
|
|
ret = pbStringToAudioFile(music)
|
|
end
|
|
end
|
|
ret = pbStringToAudioFile("battle_trainer") if !ret
|
|
return ret
|
|
end
|
|
|
|
def pbGetTrainerBattleBGMFromType(trainertype)
|
|
if $PokemonGlobal.nextBattleBGM
|
|
return $PokemonGlobal.nextBattleBGM.clone
|
|
end
|
|
trainer_type_data = GameData::TrainerType.get(trainertype)
|
|
ret = trainer_type_data.battle_BGM if trainer_type_data.battle_BGM
|
|
if !ret
|
|
# Check map metadata
|
|
map_metadata = GameData::MapMetadata.try_get($game_map.map_id)
|
|
music = (map_metadata) ? map_metadata.trainer_battle_BGM : nil
|
|
ret = pbStringToAudioFile(music) if music && music != ""
|
|
end
|
|
if !ret
|
|
# Check global metadata
|
|
music = GameData::Metadata.get.trainer_battle_BGM
|
|
ret = pbStringToAudioFile(music) if music && music!=""
|
|
end
|
|
ret = pbStringToAudioFile("battle_trainer") if !ret
|
|
return ret
|
|
end
|
|
|
|
def pbGetTrainerVictoryME(trainer) # can be a Player, NPCTrainer or an array of them
|
|
begin
|
|
if $PokemonGlobal.nextBattleME
|
|
return $PokemonGlobal.nextBattleME.clone
|
|
end
|
|
if trainer.is_a?(Array)
|
|
npcTrainer=trainer[0]
|
|
else
|
|
npcTrainer=trainer
|
|
end
|
|
|
|
if is_gym_leader(npcTrainer)
|
|
ret = pbStringToAudioFile(Settings::LEADER_VICTORY_MUSIC)
|
|
elsif is_champion(npcTrainer)
|
|
ret = pbStringToAudioFile(Settings::CHAMPION_VICTORY_MUSIC)
|
|
elsif is_evil_team(npcTrainer)
|
|
ret = pbStringToAudioFile(Settings::GRUNT_VICTORY_MUSIC)
|
|
else
|
|
ret = pbStringToAudioFile(Settings::TRAINER_VICTORY_MUSIC)
|
|
end
|
|
ret.name = "../../Audio/ME/"+ret.name
|
|
return ret
|
|
rescue
|
|
ret = pbStringToAudioFile(Settings::TRAINER_VICTORY_MUSIC)
|
|
ret.name = "../../Audio/ME/"+ret.name
|
|
return ret
|
|
end
|
|
|
|
end
|
|
|
|
GYM_LEADERS_TYPES=[:LEADER_Brock,:LEADER_Misty, :LEADER_Surge, :LEADER_Erika, :LEADER_Koga, :LEADER_Sabrina, :LEADER_Blaine,
|
|
:LEADER_Giovanni, :ELITEFOUR_Lorelei, :ELITEFOUR_Bruno, :ELITEFOUR_Agatha, :ELITEFOUR_Lance, :CHAMPION,
|
|
:LEADER_Whitney, :LEADER_Kurt, :LEADER_Falkner, :LEADER_Clair, :LEADER_Morty, :LEADER_Pryce, :LEADER_Chuck,
|
|
:LEADER_Jasmine,
|
|
:ROCKETBOSS,
|
|
:LEADER_Roxanne, :LEADER_Brawly, :LEADER_Wattson, :LEADER_Flannery, :LEADER_Norman, :LEADER_Winona,
|
|
:LEADER_Tate, :LEADER_Liza,
|
|
:LEADER_Wallace, :LEADER_Juan,
|
|
:ELITEFOUR_Sidney, :ELITEFOUR_Phoebe, :ELITEFOUR_Glacia, :ELITEFOUR_Drake,
|
|
]
|
|
EVIL_TEAM_TYPES=[:TEAMROCKET_M,:TEAMROCKET_F,:ROCKETEXEC_F, :ROCKETEXEC_M, :ROCKETEXEC_Ariana, :ROCKETEXEC_Archer,
|
|
:TEAM_AQUA_GRUNT_M, :TEAM_AQUA_GRUNT_F, :TEAM_AQUA_EXEC_M, :TEAM_AQUA_EXEC_F, :TEAM_AQUA_BOSS,
|
|
:TEAM_MAGMA_GRUNT_M, :TEAM_MAGMA_GRUNT_F, :TEAM_MAGMA_EXEC_M, :TEAM_MAGMA_EXEC_F, :TEAM_MAGMA_BOSS,
|
|
:TEAM_MAGMAQUA_GRUNT_M, :TEAM_MAGMAQUA_GRUNT_F]
|
|
|
|
CHAMPION_TYPES=[:CHAMPION_Steven, :CHAMPION, :CHAMPION_Sinnoh]
|
|
|
|
def is_gym_leader(trainer)
|
|
return GYM_LEADERS_TYPES.include?(trainer.trainer_type)
|
|
end
|
|
|
|
def is_evil_team(trainer)
|
|
return EVIL_TEAM_TYPES.include?(trainer.trainer_type)
|
|
end
|
|
|
|
def is_champion(trainer)
|
|
return CHAMPION_TYPES.include?(trainer.trainer_type)
|
|
end
|