#===============================================================================
#
# Play BGM at Death and Skip to Title
# Last Date Updated: 2011.9.24
# Author: Gamesfreak13563
#
# This script plays a BGM when the party is deeated in battle, which lingers
# until the Defeat line is advanced past. It also skips the game over screen
# and goes straight to the title after a defeat, This provides a similar ex-
# pereance to being defeated in an early Final Fantasy title.
#
#===============================================================================

module GF
module BGM
module DEFEAT

# Set the name, volume, and pitch of the BGM.
DEFEAT_BGM = RPG::BGM.new("Field1", 100, 100)

end
end
end

#===============================================================================
# MAIN SCRIPT BELOW
#===============================================================================

class Scene_Battle < Scene_Base

#--------------------------------------------------------------------------
# Overwrite judge_win_loss
#--------------------------------------------------------------------------

def judge_win_loss
if $game_temp.in_battle
if $game_party.all_dead?
sad_music # Plays the DEFEAT_BGM
process_defeat
return true
elsif $game_troop.all_dead?
process_victory
return true
else
return false
end
else
return true
end
end

#--------------------------------------------------------------------------
# Define the method which plays the BGM
#--------------------------------------------------------------------------

def sad_music # Method which plays the BGM
RPG::BGM.stop
RPG::BGS.stop # Stop BGM and BGS
defeat_bgm = GF::BGM::DEFEAT::DEFEAT_BGM # Define the BGM
defeat_bgm.play # Play the BGM

end

#--------------------------------------------------------------------------
# Skip the Game Over Screen
#--------------------------------------------------------------------------
def call_gameover
$game_temp.next_scene = nil
$scene = Scene_PreTitle.new # Go straight to Title instead of GameOver
@message_window.clear
Graphics.fadeout(120) # Apply a fadeout
end
end