Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

[VX] backdrop (battle back) script?

Is there a backdrop script that lets me change depending on what place I'm in?
for example if I'm in a desert and i run into a battle the backdrop will be a area? and if I'm in a forest I battle on a Forest backdrop instead? :neutral:
I'll be very great full if some one can write or find me one! :thumb:
 

khmp

Sponsor

I think I got this I just need to figure out how to get around no terrain tags.

[edit]

Ok so like I said there are no terrain tags to decide what terrain type is associated with which battle background. But there are areas. In this code areas are what define which battle background to use. I require that at the end of an area name you place an additional four characters. This tag will identify which battle background to use. At the top is the module containing all the settings you will need to tinker with to get the results you want. First is the constant Battleback_Dir which identifies what directory to look at to get the battle backgrounds from. By default I set it to './Graphics/Battlebacks/'. Next is the more important item which is the Hash object called Battlebacks that links what Tag loads what image. In the code below I will use the example that if an area is named 'whatever_pla' the battle background that will attempt to load is 'plains.png'. You can actually extend it to whatever amount of characters you want as long as they are prefixed by an underscore, '_'. If you omit that underscore in the key you will effectively nullify the code's purpose. If the bitmap for some reason is unable to load there won't be a crash it will go with the default battleback bitmap. Which is that blurred wavy thing.

One last thing what happens if you have an event that initiates a battle? Well you will need to look at the hash keys and decide which one fits. In the event before the battle processing command have a Script call with this line:
Code:
$game_player.area_type = '_etc' # where '_etc' is the key to the image you want.

Code:
#==============================================================================
# ** Battleback_Settings
#------------------------------------------------------------------------------
#  Holds all pertinent information for Battle Backgrounds.
#==============================================================================

module Battleback_Settings
  #--------------------------------------------------------------------------
  # * Constants
  #--------------------------------------------------------------------------
  #------------------------------------------------------------------------
  # * Battleback_Dir
  #     The default directory to look for battlebackgrounds.
  #------------------------------------------------------------------------
  Battleback_Dir = './Graphics/Battlebacks/'
  #------------------------------------------------------------------------
  # * Battlebacks
  #     This hash holds the key that identifies what battleback an area
  #     should use.
  #     key   : String tag to be found in an areas name to determine value.
  #     value : String of the battleback image to load based on key.
  #------------------------------------------------------------------------
  Battlebacks = {
    '_oce' => 'ocean.png',
    '_des' => 'desert.png',
    '_for' => 'forest.png',
    '_pla' => 'plains.png',
    '_swa' => 'swamp.png',
    '_cas' => 'castle.png',
    '_tow' => 'town.png',
    '_bea' => 'beach.png',
  }
end

#==============================================================================
# ** Game_Player
#------------------------------------------------------------------------------
#  This class handles maps. It includes event starting determinants and map
# scrolling functions. The instance of this class is referenced by $game_map.
#==============================================================================

class Game_Player < Game_Character
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_accessor :area_type
  #--------------------------------------------------------------------------
  # * Create Group ID for Troop Encountered !OVERRIDE!
  #--------------------------------------------------------------------------
  def make_encounter_troop_id
    encounter_list = $game_map.encounter_list.clone
    for area in $data_areas.values
      if in_area?(area)
        encounter_list += area.encounter_list 
        @area_type = '_' + area.name.split('_').last
      end
    end
    if encounter_list.empty?
      make_encounter_count
      return 0
    end
    return encounter_list[rand(encounter_list.size)]
  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 !OVERRIDE!
  #--------------------------------------------------------------------------
  def create_battleback
    # Create the sprite.
    @battleback_sprite = Sprite.new(@viewport1)

    begin
      # Load the battleback.
      bitmap = Bitmap.new(Battleback_Settings::Battleback_Dir + 
        Battleback_Settings::Battlebacks[$game_player.area_type])
    rescue
      # Do the usual stuff if there is ever a problem.
      source = $game_temp.background_bitmap
      bitmap = Bitmap.new(640, 480)
      bitmap.stretch_blt(bitmap.rect, source, source.rect)
      bitmap.radial_blur(90, 12)
      @battleback_sprite.ox = 320
      @battleback_sprite.oy = 240
      @battleback_sprite.x = 272
      @battleback_sprite.y = 176
      @battleback_sprite.wave_amp = 8
      @battleback_sprite.wave_length = 240
      @battleback_sprite.wave_speed = 120 
    end
    
    # Set the bitmap.
    @battleback_sprite.bitmap = bitmap
  end
end

Good luck with it Death God! :thumb:
 
Thanks! :thumb: although I'm a little confused  :crazy: about the event part.
does the event part work with multiple events, and do I have to add more add more $game_player.area_type = '_etc' # where '_etc' depending on how many event battles I have? an where do they go? :crazy:

also i tried it out and what it really does is make the weird wavy thing turn translucent (partly transparent) and any thing placed on the map will be blurred out as well, what I'm really asking is theres know way for it to add a totally knew background that looks like backgrounds from rmxp?
 

khmp

Sponsor

El demo

What I mean by '_etc' In VX. I'll start from scratch. You define battle locations with areas yes? Well you can rename so they are something more intuitive than AREA001. With this script, let's say you define a battle area on grassland terrain and you have a grassland background you want to use called, "grassland.png" inside yourproject/Graphics/Battlebacks/. Now you'll want to make sure you edit this first:
Code:
Battlebacks = {
  
  }

We want to add a grassland battleback. So I'm choosing '_grass' as the area identifier and tying it to the proper battle background.
Code:
Battlebacks = {
  '_grass' => 'grassland.png',
  }

Now go back to your editor. Rename the area you want to use the grassland battle background to anything as long as you have enough room to end it with "_grass". So you can name the area like "Albion_grass". Whenever you get into a fight within this area it should use "grassland.png" as the battle background like how its done in XP.

Now lets say you initiate a battle through an event. Using "Battle Processing...". Well before hand because the player has no idea what area he is in you will have to initialize what the area type is manually. So use "Script..." and have a line like this:
Code:
$game_player.area_type = '_grass'
That will tell the player that he is in a grass zone and use the appropriate background.

I hope that helped to clear things up.
 
:thumb: Thanks it makes PERFECT sense to me now!
You should make a Rgss2 scripting for dummies manual so People like me could under stand! :wink:

p.s. where did you save plains.png I see it in your script but did you iport it in to the game
p.s.s. you put a lot of faces and stuff into your demo Thanks
 

khmp

Sponsor

Those faces came with VX. I thought I cleaned it up before I handed it to you but I see I also had a windowskin in there too. The plains.png is in Graphics/Battlebacks/. But I renamed it to see what happened if the file wasn't loaded properly. It still runs yes? Just rename it back to plains.png from aplains.png.

It looks like I missed the pictures folder. :thumb:
 
the mean part was a joke but after i wrote that I went back and renamed the file I still get the clear wave thing. is the name supposed to be plains or plains.png

and where i write $game_player.area_type = '_etc' # where '_etc' in the event i select "script..." then $game_player.area_type = '_pla' plains.png '_pla'

[edit]
i got everything working right except the event battle thats a little hard, do i use "script" or "comment" in the event commands i tried script once but i think i wrote It wrong.
 

khmp

Sponsor

You use the "Script..." event command. Use the following line of syntax:
Code:
$game_player.area_type = '_pla'
Then on the next line begin your battle.

I used the abbreviation for etcetera because I have no idea what kind of battlebacks or naming scheme you would want in your game. It was meant to be like "Lorem Ipsum" is on a cover letter. Not to be used as anything but an example.
 
yeah it's funny i just figured out that i wrote wrong! now all i gotta do is find some battle backs for my game I'll think I'll look for xp ones, unless you know where i can get some?

p.s. i made a little bit of instructions for any one who needs it.

Code:
#==============================================================================
# ** Battleback_Settings
#------------------------------------------------------------------------------
#  Holds all pertinent information for Battle Backgrounds.
#==============================================================================

#==============================================================================
# Add $game_player.area_type = '_etc' in a comment before battle comand
# '_ect' is a battleback image ex: $game_player.area_type = '_pla' for plains
# Add battlebacks in the battlebacks folder thats in the graphics folder of
# your game folder.
#==============================================================================

module Battleback_Settings
  #--------------------------------------------------------------------------
  # * Constants
  #--------------------------------------------------------------------------
  #------------------------------------------------------------------------
  # * Battleback_Dir
  #     The default directory to look for battlebackgrounds.
  #------------------------------------------------------------------------
  Battleback_Dir = './Graphics/Battlebacks/'
  #------------------------------------------------------------------------
  # * Battlebacks
  #     This hash holds the key that identifies what battleback an area
  #     should use.
  #     key   : String tag to be found in an areas name to determine value.
  #     value : String of the battleback image to load based on key.
  #------------------------------------------------------------------------
  Battlebacks = {
    '_oce' => 'ocean.png',
    '_des' => 'desert.png',
    '_for' => 'forest.png',
    '_pla' => 'plains.png',
    '_swa' => 'swamp.png',
    '_cas' => 'castle.png',
    '_tow' => 'town.png',
    '_bea' => 'beach.png',
  }
end

#==============================================================================
# ** Game_Player
#------------------------------------------------------------------------------
#  This class handles maps. It includes event starting determinants and map
# scrolling functions. The instance of this class is referenced by $game_map.
#==============================================================================

class Game_Player < Game_Character
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_accessor :area_type
  #--------------------------------------------------------------------------
  # * Create Group ID for Troop Encountered !OVERRIDE!
  #--------------------------------------------------------------------------
  def make_encounter_troop_id
    encounter_list = $game_map.encounter_list.clone
    for area in $data_areas.values
      if in_area?(area)
        encounter_list += area.encounter_list 
        @area_type = '_' + area.name.split('_').last
      end
    end
    if encounter_list.empty?
      make_encounter_count
      return 0
    end
    return encounter_list[rand(encounter_list.size)]
  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 !OVERRIDE!
  #--------------------------------------------------------------------------
  def create_battleback
    # Create the sprite.
    @battleback_sprite = Sprite.new(@viewport1)

    begin
      # Load the battleback.
      bitmap = Bitmap.new(Battleback_Settings::Battleback_Dir + 
        Battleback_Settings::Battlebacks[$game_player.area_type])
    rescue
      # Do the usual stuff if there is ever a problem.
      source = $game_temp.background_bitmap
      bitmap = Bitmap.new(640, 480)
      bitmap.stretch_blt(bitmap.rect, source, source.rect)
      bitmap.radial_blur(90, 12)
      @battleback_sprite.ox = 320
      @battleback_sprite.oy = 240
      @battleback_sprite.x = 272
      @battleback_sprite.y = 176
      @battleback_sprite.wave_amp = 8
      @battleback_sprite.wave_length = 240
      @battleback_sprite.wave_speed = 120 
    end
    
    # Set the bitmap.
    @battleback_sprite.bitmap = bitmap
  end
end
 

khmp

Sponsor

Shinigami":3i270w1o said:
thank an khmp where did you find that plains battle back hopefully I can make due with what I find there.

I actually made that one as part of a Title Screen request for kimpoy2006. But it's just a background I used for a quick example because it was already in VX resolution. Why not just take XP battlebacks and scale them down? And as always...

Good luck with it Death God! :thumb:
 

khmp

Sponsor

Would you be willing to create a demo of your project? As I am absolutely confused as to why it would do something like that. And if you are worried about privacy feel free to PM me the download information.
 
actually I have know Idea how to set it up but i have a test project of your script setup you just have to walk until you find a battle it looks ok I'd just perfer it to be bigger, so you can see it through the menu, just tell me how to put things up to download on the site that you did your demo.
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top