Code:
#==============================================================================
# ** Battlebacks VX
#------------------------------------------------------------------------------
# by DerVVulfman
# version 1.2
# 03-29-2008
# RGSS2
#==============================================================================
#
# INTRODUCTION:
#
# This system reintroduces the use of 'Battleback' graphics into your pro-
# jects, something that was sadly lacking in tbe RPGMaker VX system.
#
#------------------------------------------------------------------------------
#
# SCRIPT CALLS:
#
# There's only one script call that you need to know.
#
# --Changing Battlebacks--
# Given that this system allows you to use 'Battlebacks, you may find a need
# to 'change' the battleback in-game. Unfortunately, this can't be done with
# a pre-rendered map event, so I had to make a script call:
#
# $game_system.battleback = "filename"
#
# The filename is whatever is stored within the folder that you have speci-
# fied in the configuration section (in the BATTLEBACK_DIR value).
#
#------------------------------------------------------------------------------
#
# SCRIPT PLACEMENT:
#
# As a core/re-insertion script, it returns the classic battle backgrounds
# that many users became used to with other RPG gaming systems.
#
# If this script is being used with any other script that alters any dis-
# played effect or any system in the battlesystem's spriteset window, then
# those scripts will most likely be placed BELOW this script as they will
# most need access to the revised battle viewport.
#
#------------------------------------------------------------------------------
#
# EDITS AND MODIFICATIONS:
#
# This system Aliases the following methods:
# * initialize (Game_System)
# * create_battleback (Spriteset_Battle)
# * create_battlefloor (Spriteset_Battle)
#
# This system adds the following methods:
# * battleback (Cache)
#
#------------------------------------------------------------------------------
#
# THANKS:
#
# To Fantasy at RPG RPG Revolution for noticing a bug when using the 'Battle
# Test' feature.
#
#------------------------------------------------------------------------------
# TERMS AND CONDITIONS:
#
# Free to use, even in commercial projects. Just note that I need some form
# of due credit... even a mere mention in some end titles.
#
#==============================================================================
#========================================================================
# ** C O N F I G U R A T I O N S Y S T E M ** #
#========================================================================
# Name of directory (used in cache)
BATTLEBACK_DIR = "Graphics/Parallaxes/"
# List of battlebacks by Map ID.
# MapID Filename
BATTLEBACK_LIST = {1 => "Ocean",
2 => "CloudySky"}
# The name of the battleback used
# when using the Battle Test feature.
BATTLEBACK_TEST = "Mountains"
#==============================================================================
# ** Cache
#------------------------------------------------------------------------------
# This module loads each of graphics, creates a Bitmap object, and retains it.
# To speed up load times and conserve memory, this module holds the created
# Bitmap object in the internal hash, allowing the program to return
# preexisting objects when the same bitmap is requested again.
#==============================================================================
module Cache
#--------------------------------------------------------------------------
# * Get Battleback Graphic
# filename : Filename
#--------------------------------------------------------------------------
def self.battleback(filename)
load_bitmap(BATTLEBACK_DIR, filename)
end
end
#==============================================================================
# ** Game_System
#------------------------------------------------------------------------------
# This class handles system-related data. Also manages vehicles and BGM, etc.
# The instance of this class is referenced by $game_system.
#==============================================================================
class Game_System
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_accessor :battleback # filename of battleback
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
alias bback_initialize initialize
def initialize
bback_initialize
@battleback = nil
end
end
#==============================================================================
# ** Spriteset_Battle
#------------------------------------------------------------------------------
# This class brings together battle screen sprites. It's used within the
# Scene_Battle class.
#==============================================================================
class Spriteset_Battle
#--------------------------------------------------------------------------
# * Create Battleback Sprite
#--------------------------------------------------------------------------
alias bback_create_battleback create_battleback
def create_battleback
# Perform and exit for battletests
if $BTEST
if BATTLEBACK_TEST != nil
# Create Battleback sprite
@battleback_sprite = Sprite.new(@viewport1)
# Load image from cache
@battleback_sprite.bitmap = Cache.battleback(BATTLEBACK_TEST)
return
else
bback_create_battleback
return
end
end
# If map used 'called' battleback.
if $game_system.battleback != nil
# Create Battleback sprite
@battleback_sprite = Sprite.new(@viewport1)
# Load image from cache
@battleback_sprite.bitmap = Cache.battleback($game_system.battleback)
# If map has assigned battleback
elsif BATTLEBACK_LIST.key?($game_map.map_id)
# Create Battleback sprite
@battleback_sprite = Sprite.new(@viewport1)
# Load image from cache
@battleback_sprite.bitmap = Cache.battleback(BATTLEBACK_LIST[$game_map.map_id])
# Otherwise, as normal
else
# Perform the original call
bback_create_battleback
end
end
#--------------------------------------------------------------------------
# * Create Battlefloor Sprite
#--------------------------------------------------------------------------
alias bback_create_battlefloor create_battlefloor
def create_battlefloor
# Disable battlefloor for existing battleback maps
if BATTLEBACK_LIST.key?($game_map.map_id) or $game_system.battleback != nil
@battlefloor_sprite = Sprite.new(@viewport1)
return
end
# Disable for battletests with set battleback
if $BTEST
if BATTLEBACK_TEST != nil
@battlefloor_sprite = Sprite.new(@viewport1)
return
end
end
# Perform the original call
bback_create_battlefloor
end
end