#===============================================================
# ** Jens of Zanicuud dynamic battle backgrounds v 1.0
# - free use, just credit
# - free customization, just PM me the modified version
# - you can fin me on www.rpgrevolution.com
#===============================================================================
#==============================================================================
# ** Spriteset_Battle
#==============================================================================
class Spriteset_Battle
DYNAMIC_BATTLEBACKS = {
"train_bbd[15]" => ["train_bbd[15]_p","train_bbd[15]_b"],
}
#--------------------------------------------------------------------------
# * Addon: dynamic battlebacks
#--------------------------------------------------------------------------
# HOW TO USE:
# 1. create a battleback and save it into the usual folder;
# let's say the filename is BG.png
# 2. if you want to add a background to your battleback, create
# a file with the same name, with a "_p" at the end of the name
# (e.g. BG_p.png)
# 3. if you want your background moving, add a number written in
# square parenthesis (e.g. [10]) to both files name. Add a "d"
# if you want that background moving right;
# (e.g. BG[6].png -- BG[6]_p.png leftmoving battleback)
# (e.g. BGd[6].png -- BGd[6]_p.png rightmoving battleback)
# 4. if you want to move the background vertically, just put a "f" into
# the file name. (in that case, "d" will invert the moving direction)
# (e.g. BGv[5].png -- BGv[5]_p.png vertical moving battleback)
# (e.g. BGvd[3].png -- BGvd[3]_p.png vertical moving battleback)
# 5. if you want to display a second background, which moves slower than
# the previous one, just create another file and give it the same name
# with a "_b" in the end;
# (e.g. BG[3].png -- BG[3]_p.png -- BG[3]_b.png)
# 6. if you want to display a front picture over the battleback, just create
# another file and give it the same name with a "_f" in the end;
# (e.g. BG[3].png -- BG[3]_p.png -- BG[3]_f.png)
# 7. once you've created the files, insert them in the previous vector:
# DYNAMIC_BATTLEBACKS = {
# "BG[4]" => ["BG[4]_p","BG[4]_f"],
# }
# 8. Remember NOT TO USE "[", "]", "v","d","f","z" while naming the file
# because the script will interprete them as codes
# 9. You can also add a fog with the command from the command list (like you
# are in a map and not in battle)
# 10. Enjoy the view

#
# Ask for troubleshooting anytime
#
#--------------------------------------------------------------------------
# * public instances
#--------------------------------------------------------------------------
attr_reader :viewport1 # viewport1
attr_reader :viewport2 # viewport2
#--------------------------------------------------------------------------
# * initialize
#--------------------------------------------------------------------------
def initialize
# create viewports
@viewport0 = Viewport.new(0, 0, 640, 320)
@viewport1 = Viewport.new(0, 0, 640, 320)
@viewport5 = Viewport.new(0, 0, 640, 320)
@viewport2 = Viewport.new(0, 0, 640, 480)
@viewport3 = Viewport.new(0, 0, 640, 480)
@viewport4 = Viewport.new(0, 0, 640, 480)
# set viewports z
@viewport5.z = 1
@viewport2.z = 101
@viewport3.z = 200
@viewport4.z = 5000
# create fog
@fog = Plane.new(@viewport1)
@fog.z = 3000
@b2_speed = 3
# create battleback
@battleback_sprite = Sprite.new(@viewport1)
@battleback_sprite2 = Plane.new(@viewport0)
@battleback_sprite3 = Plane.new(@viewport5)
@battleback_sprite4 = Plane.new(@viewport0)
@battleback_sprite2.z = 10
# create enemies' sprites
@theta = 0
@enemy_sprites = []
for enemy in $game_troop.enemies.reverse
@enemy_sprites.push(Sprite_Battler.new(@viewport1, enemy))
end
# create actors' sprites
@actor_sprites = []
@actor_sprites.push(Sprite_Battler.new(@viewport2))
@actor_sprites.push(Sprite_Battler.new(@viewport2))
@actor_sprites.push(Sprite_Battler.new(@viewport2))
@actor_sprites.push(Sprite_Battler.new(@viewport2))
# set weather
@weather = RPG::Weather.new(@viewport1)
# set pictures
@picture_sprites = []
for i in 51..100
@picture_sprites.push(Sprite_Picture.new(@viewport3,
$game_screen.pictures[i]))
end
# set timer
@timer_sprite = Sprite_Timer.new
# update
update
end
#--------------------------------------------------------------------------
# — 解”
#--------------------------------------------------------------------------
def dispose
# dispose battleback bitmap
if @battleback_sprite.bitmap != nil
@battleback_sprite.bitmap.dispose
end
# dispose battleback
@battleback_sprite.dispose
@battleback_sprite2.dispose
@battleback_sprite3.dispose
@battleback_sprite4.dispose
# dispose enemies' + actors' sprites
for sprite in @enemy_sprites + @actor_spritesn + @actor_sprites
sprite.dispose
end
# dispose weather
@weather.dispose
# dispose pictures
for sprite in @picture_sprites
sprite.dispose
end
# dispose timer
@timer_sprite.dispose
# dispose fog
@fog.dispose
# dispose viewports
@viewport1.dispose
@viewport2.dispose
@viewport3.dispose
@viewport4.dispose
@viewport5.dispose
@viewport0.dispose
end
#--------------------------------------------------------------------------
# — effect?
#--------------------------------------------------------------------------
def effect?
# determine if effect is present
for sprite in @enemy_sprites + @actor_sprites
return true if sprite.effect?
end
return false
end
#--------------------------------------------------------------------------
# — update
#--------------------------------------------------------------------------
def update
# update actor sprites
@actor_sprites[0].battler = $game_party.actors[0]
@actor_sprites[1].battler = $game_party.actors[1]
@actor_sprites[2].battler = $game_party.actors[2]
@actor_sprites[3].battler = $game_party.actors[3]
# update battelback
if @battleback_name != $game_temp.battleback_name
@battleback_name = $game_temp.battleback_name
if @battleback_sprite.bitmap != nil
@battleback_sprite.bitmap.dispose
end
if @battleback_sprite2.bitmap != nil
@battleback_sprite2.bitmap.dispose
end
if @battleback_sprite3.bitmap != nil
@battleback_sprite3.bitmap.dispose
end
@fixed = false
@zoomin = false
@b2_vertical = false
@b2_speed = 3
@battleback_sprite.bitmap = RPG::Cache.battleback(@battleback_name)
if DYNAMIC_BATTLEBACKS.include?(@battleback_name)
dyna_vec = DYNAMIC_BATTLEBACKS[@battleback_name]
if dyna_vec.include?(@battleback_name+"_p")
@battleback_sprite2.bitmap = RPG::Cache.battleback(@battleback_name+"_p")
negate = 1
@battleback_name.gsub(/d/){negate = -1}
@battleback_name.gsub(/v/){@b2_vertical = true}
@battleback_name.gsub(/\[([0-9]+)\]/){@b2_speed = $1.to_i*negate}
@battleback_name.gsub(/f/){@fixed = true}
@battleback_name.gsub(/z/){@zoomin = true}
end
if dyna_vec.include?(@battleback_name+"_f")
@battleback_sprite3.bitmap = RPG::Cache.battleback(@battleback_name+"_f")
@battleback_sprite3.zoom_x = 640.0/@battleback_sprite.bitmap.width
@battleback_sprite3.zoom_y = 320.0/@battleback_sprite.bitmap.height
end
if dyna_vec.include?(@battleback_name+"_b")
@battleback_sprite4.bitmap = RPG::Cache.battleback(@battleback_name+"_b")
@battleback_sprite4.zoom_x = 640.0/@battleback_sprite.bitmap.width
@battleback_sprite4.zoom_y = 320.0/@battleback_sprite.bitmap.height
end
@battleback_sprite.zoom_x = 640.0/@battleback_sprite.bitmap.width
@battleback_sprite.zoom_y = 320.0/@battleback_sprite.bitmap.height
if @zoomin
@battleback_sprite2.zoom_x = 640.0/@battleback_sprite2.bitmap.width
@battleback_sprite2.zoom_y = 320.0/@battleback_sprite2.bitmap.height
end
end
end
# fog update
if @fog_name != $game_map.fog_name or @fog_hue != $game_map.fog_hue
@fog_name = $game_map.fog_name
@fog_hue = $game_map.fog_hue
if @fog.bitmap != nil
@fog.bitmap.dispose
@fog.bitmap = nil
end
if @fog_name != ""
@fog.bitmap = RPG::Cache.fog(@fog_name, @fog_hue)
end
Graphics.frame_reset
end
@fog.zoom_x = $game_map.fog_zoom / 100.0
@fog.zoom_y = $game_map.fog_zoom / 100.0
@fog.opacity = $game_map.fog_opacity
@fog.blend_type = $game_map.fog_blend_type
@fog.ox += $game_map.fog_sx/8
@fog.oy += $game_map.fog_sy/8
@fog.tone = $game_map.fog_tone
for sprite in @enemy_sprites + @actor_sprites
sprite.update
end
# weather update
@weather.type = $game_screen.weather_type
@weather.max = $game_screen.weather_max
@weather.update
@theta += 0.1
if !@fixed
if @b2_vertical
@battleback_sprite2.oy += @b2_speed
@battleback_sprite4.oy += @b2_speed/5
else
@battleback_sprite2.ox += @b2_speed
@battleback_sprite4.ox += @b2_speed/5
end
end
# update pictures
for sprite in @picture_sprites
sprite.update
end
# update timer
@timer_sprite.update
# update viewports' tone
@viewport1.tone = $game_screen.tone#Tone.new(0,0,0)
@viewport0.tone = $game_screen.tone
@viewport5.tone = $game_screen.tone
@viewport1.ox = $game_screen.shake
# set viewport color
@viewport4.color = $game_screen.flash_color
# update viewports
@viewport0.update
@viewport1.update
@viewport2.update
@viewport4.update
@viewport5.update
end
end
#==============================================================================
# ** Spriteset_Battle
#==============================================================================
class Scene_Title
#--------------------------------------------------------------------------
# * aliases
#--------------------------------------------------------------------------
alias joz_dynamic_bck_battle_test battle_test
#--------------------------------------------------------------------------
# * battle test
#--------------------------------------------------------------------------
def battle_test
joz_dynamic_bck_battle_test
$game_map.setup(1)
end
end