TROOP ID BASED BATTLE BACKS

RPG Maker VX

Battleback defined by troop ID number

  • tpasmall
  • 10/24/2011 02:56 AM
  • 1496 views
Well, this is my first script. It basically does what it says, it creates battlebacks based on the ID of the troop your fighting. This makes it possible to have multiple backs per map or area. I know this is not for all games, but for games that don't repeat troops in different surroundings, I think this can be useful. Like I said, this is my first script and I'd like feedback on it. I'm not great with ruby but I do know some c++ and a few other languages so I'm hoping to get more into this.

*IMPORTANT: This script will not work unless you put "attr_accessor :troop_id" in the "game_troop" script.

Report bugs if you find them!


#--------------------------------------------------------------------------------
# Battle backgrounds go in the 'Pictures' folder (Graphics/Pictures)
# in the script "game_troop" go to line 29 and insert  "attr_accessor :troop_id"
# Script written by tpasmall
#--------------------------------------------------------------------------------

module TroopBB
  #------------------------------------------------------------------------------
  # To set the background put the troop ID number followed by the file name
  # ex. Slime x 2 is troop 001
  # 1 => "grassland" will make grassland.png as the battleback for slime x2 troop
  # make sure to put a "," after each battleback name
  #------------------------------------------------------------------------------
  BattleBackground =
  {
  1 => "grassland",
  2 => "forest",
  }
  #-----------------------------------------------------------------------------
  # Create the battlefloor?
  #-----------------------------------------------------------------------------
  Create_battlefloor = true
end
#-------------------------------------------------------------------------------
# Spriteset_Battle
#-------------------------------------------------------------------------------
class Spriteset_Battle
  alias crbattlefloor create_battlefloor
  #-----------------------------------------------------------------------------
  # Create Battleback
  #-----------------------------------------------------------------------------
  def create_battleback
    image = TroopBB::BattleBackground[$game_troop.troop_id]
    @battleback_sprite = Sprite.new(@viewport1)
    @battleback_sprite.bitmap = Cache.picture(image)
  end
  def create_battlefloor
    @battlefloor_sprite = Sprite.new(@viewport1)
    crbattlefloor if TroopBB::Create_battlefloor == true
  end
end