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.

Completely Modifying Battle Windows

I'm trying to change the background of all the windows in all the scenes in the game.
Currently, one of the only scenes I haven't modified yet is the battle scenes, and I am not sure where I need to modify them.
What I want to do is replace the windowskin with an image for each of the separate windows and to have the battler's pictures moved down 16 pixels (which is the distance from their bottom to the bottom of the entire screen).

Any help would be appreciated.
(If any images are needed for clarification, please say so and I'll post some)
 
To move the battlers, look at the screen_y method in Game_Actor

The background of the center part of the battle scene is defined in the database in the tileset.

You can change the windowskin of the status window by adding the following line to the initialize method of WindowBattleStatus

  self.windowskin = RPG::Cache.windowskin("windowskin_name")

replace windowskin_name with the name of your custom windowskin

Be Well
 
I tried the screen_y and that worked fine.
As for the windowskins, I really just don't want them at all.
Instead, I want to use an image in its place with the same dimensions as the window(and this will happen for every window).
 
Are you talking a detailed (picture) image, or just like a window with no borders?

It would help if you could post a prototype of a battle scene with the status window, actor command window & help window / party command window.
It doesn't need the battler graphics or status info.
Maybe a screenshot of the main menu (assuming you've done that already) would help describe what you're shooting for?

You do want to use a windowskin, since it also defines the cursor for selecting commands, and the arrows for selecting which enemy to attack.
A couple options are to use a windowskin with no borders, and the image you want as the background image for the window,
Or a transparent windowskin, with an additional picture displayed for each type of window.
 
Okay, so here's some pics of what I'm wanting.

For when the battle has the little strip at the top, this would be what it looks like:
battleattackfleetargethm5.png


For when you have to select attack, skill, defend, or item, it would look like this:
battleactionwh2.png


For the menus that you select a skill or item, the images would look like this:
battleskilloritemusepd5.png


I want the windowskins to be transparent and these images to be the background for each window.
You will still be able to see the text and icons of the images.
 
Alright, this will work in a brand new project. If you have already edited your scripts, use this as a guide.

You'll need to create the following background images in your Windowskins folder:

battle_actor_command.png # attack, skill, defend, item
battle_help.png # top window
battle_skin.png # modified windowskin with background & borders removed
battle_status.png #bottom window

Code:
#==============================================================================
# ** Window_Base
#------------------------------------------------------------------------------
#  This class is for all in-game windows.
#==============================================================================

class Window_Base < Window
  attr_accessor :bg_sprite
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     x      : window x-coordinate
  #     y      : window y-coordinate
  #     width  : window width
  #     height : window height
  #--------------------------------------------------------------------------
  def initialize(x, y, width, height)
    super()
    @windowskin_name = $game_system.windowskin_name
    self.windowskin = RPG::Cache.windowskin(@windowskin_name)
    self.x = x
    self.y = y
    self.width = width
    self.height = height
    self.z = 100
    @bg_sprite = Sprite.new(self.viewport)
    @bg_sprite.x = x
    @bg_sprite.y = y
    @bg_sprite.z = self.z + 1
    @bg_sprite.bitmap = Bitmap.new(width, height)
  end
  #--------------------------------------------------------------------------
  # * bg_bitmap = 
  #--------------------------------------------------------------------------
  def bg_bitmap=(bitmap_name)
    @bg_sprite.bitmap = Bitmap.new(bitmap_name)
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    super
    # Reset if windowskin was changed
    if $game_system.windowskin_name != @windowskin_name
      @windowskin_name = $game_system.windowskin_name
      self.windowskin = RPG::Cache.windowskin(@windowskin_name)
    end
    @bg_sprite.x = x
    @bg_sprite.y = y
  end
end

#------------------------------------------------------------------------------
#  This class performs battle screen processing.
#==============================================================================

class Scene_Battle
  #--------------------------------------------------------------------------
  # * Main Processing
  #--------------------------------------------------------------------------
  def main
    # Initialize each kind of temporary battle data
    $game_temp.in_battle = true
    $game_temp.battle_turn = 0
    $game_temp.battle_event_flags.clear
    $game_temp.battle_abort = false
    $game_temp.battle_main_phase = false
    $game_temp.battleback_name = $game_map.battleback_name
    $game_temp.forcing_battler = nil
    # Initialize battle event interpreter
    $game_system.battle_interpreter.setup(nil, 0)
    # Prepare troop
    @troop_id = $game_temp.battle_troop_id
    $game_troop.setup(@troop_id)
    # Make actor command window
    s1 = $data_system.words.attack
    s2 = $data_system.words.skill
    s3 = $data_system.words.guard
    s4 = $data_system.words.item
    @actor_command_window = Window_Command.new(160, [s1, s2, s3, s4])
    @actor_command_window.y = 160
    @actor_command_window.back_opacity = 160
#    @actor_command_window.bg_sprite.opacity = 160
    @actor_command_window.active = false
    @actor_command_window.visible = false
    blank_skin = RPG::Cache.windowskin("battle_skin")
    @actor_command_window.windowskin = blank_skin
    @actor_command_window.bg_bitmap = "Graphics/Windowskins/battle_actor_command"
    @actor_command_window.bg_sprite.visible = false
    # Make other windows
    @party_command_window = Window_PartyCommand.new
    @party_command_window.windowskin = blank_skin
    @party_command_window.bg_bitmap = "Graphics/Windowskins/battle_help"
#    @party_command_window.bg_sprite.opacity = 160
    @help_window = Window_Help.new
    @help_window.back_opacity = 160
#    @help_window.bg_sprite.opacity = 160
    @help_window.visible = false
    @help_window.windowskin = blank_skin
    @help_window.bg_bitmap = "Graphics/Windowskins/battle_help"
    @help_window.bg_sprite.visible = false
    @status_window = Window_BattleStatus.new
    @status_window.windowskin = blank_skin
    @status_window.bg_bitmap = "Graphics/Windowskins/battle_status"
#    @status_window.bg_sprite.opacity = 160
    @message_window = Window_Message.new
    # Make sprite set
    @spriteset = Spriteset_Battle.new
    # Initialize wait count
    @wait_count = 0
    # Execute transition
    if $data_system.battle_transition == ""
      Graphics.transition(20)
    else
      Graphics.transition(40, "Graphics/Transitions/" +
        $data_system.battle_transition)
    end
    # Start pre-battle phase
    start_phase1
    # Main loop
    loop do
      # Update game screen
      Graphics.update
      # Update input information
      Input.update
      # Frame update
      update
      # Abort loop if screen is changed
      if $scene != self
        break
      end
    end
    # Refresh map
    $game_map.refresh
    # Prepare for transition
    Graphics.freeze
    # Dispose of windows
    @actor_command_window.dispose
    @party_command_window.dispose
    @help_window.dispose
    @status_window.dispose
    @message_window.dispose
    if @skill_window != nil
      @skill_window.dispose
    end
    if @item_window != nil
      @item_window.dispose
    end
    if @result_window != nil
      @result_window.dispose
    end
    # Dispose of sprite set
    @spriteset.dispose
    # If switching to title screen
    if $scene.is_a?(Scene_Title)
      # Fade out screen
      Graphics.transition
      Graphics.freeze
    end
    # If switching from battle test to any screen other than game over screen
    if $BTEST and not $scene.is_a?(Scene_Gameover)
      $scene = nil
    end
  end
  #--------------------------------------------------------------------------
  # * Start Party Command Phase
  #--------------------------------------------------------------------------
  def start_phase2
    # Shift to phase 2
    @phase = 2
    # Set actor to non-selecting
    @actor_index = -1
    @active_battler = nil
    # Enable party command window
    @party_command_window.active = true
    @party_command_window.visible = true
    @party_command_window.bg_sprite.visible = true
    # Disable actor command window
    @actor_command_window.active = false
    @actor_command_window.visible = false
    @actor_command_window.bg_sprite.visible = false
    # Clear main phase flag
    $game_temp.battle_main_phase = false
    # Clear all party member actions
    $game_party.clear_actions
    # If impossible to input command
    unless $game_party.inputable?
      # Start main phase
      start_phase4
    end
  end
  #--------------------------------------------------------------------------
  # * Actor Command Window Setup
  #--------------------------------------------------------------------------
  def phase3_setup_command_window
    # Disable party command window
    @party_command_window.active = false
    @party_command_window.visible = false
    @party_command_window.bg_sprite.visible = false
    # Enable actor command window
    @actor_command_window.active = true
    @actor_command_window.visible = true
    @actor_command_window.bg_sprite.visible = true
    # Set actor command window position
    @actor_command_window.x = @actor_index * 160
    # Set index to 0
    @actor_command_window.index = 0
  end
  #--------------------------------------------------------------------------
  # * Start Enemy Selection
  #--------------------------------------------------------------------------
  def start_enemy_select
    # Make enemy arrow
    @enemy_arrow = Arrow_Enemy.new(@spriteset.viewport1)
    # Associate help window
    @enemy_arrow.help_window = @help_window
    @help_window.bg_sprite.visible = true
    # Disable actor command window
    @actor_command_window.active = false
    @actor_command_window.visible = false
    @actor_command_window.bg_sprite.visible = false
  end
  #--------------------------------------------------------------------------
  # * End Enemy Selection
  #--------------------------------------------------------------------------
  def end_enemy_select
    # Dispose of enemy arrow
    @enemy_arrow.dispose
    @enemy_arrow = nil
    # If command is [fight]
    if @actor_command_window.index == 0
      # Enable actor command window
      @actor_command_window.active = true
      @actor_command_window.visible = true
      @actor_command_window.bg_sprite.visible = true
      # Hide help window
      @help_window.visible = false
      @help_window.bg_sprite.visible = false
    end
  end
  #--------------------------------------------------------------------------
  # * Start Actor Selection
  #--------------------------------------------------------------------------
  def start_actor_select
    # Make actor arrow
    @actor_arrow = Arrow_Actor.new(@spriteset.viewport2)
    @actor_arrow.index = @actor_index
    # Associate help window
    @actor_arrow.help_window = @help_window
    @help_window.bg_sprite.visible = true
    # Disable actor command window
    @actor_command_window.active = false
    @actor_command_window.visible = false
    @actor_command_window.bg_sprite.visible = false
  end
  #--------------------------------------------------------------------------
  # * End Actor Selection
  #--------------------------------------------------------------------------
  def end_actor_select
    # Dispose of actor arrow
    @actor_arrow.dispose
    @actor_arrow = nil
  end
  #--------------------------------------------------------------------------
  # * Start Skill Selection
  #--------------------------------------------------------------------------
  def start_skill_select
    # Make skill window
    @skill_window = Window_Skill.new(@active_battler)
    # Associate help window
    @skill_window.help_window = @help_window
    @help_window.bg_sprite.visible = true
    # Disable actor command window
    @actor_command_window.active = false
    @actor_command_window.visible = false
    @actor_command_window.bg_sprite.visible = false
  end
  #--------------------------------------------------------------------------
  # * End Skill Selection
  #--------------------------------------------------------------------------
  def end_skill_select
    # Dispose of skill window
    @skill_window.dispose
    @skill_window = nil
    # Hide help window
    @help_window.visible = false
    @help_window.bg_sprite.visible = false
    # Enable actor command window
    @actor_command_window.active = true
    @actor_command_window.visible = true
    @actor_command_window.bg_sprite.visible = true
  end
  #--------------------------------------------------------------------------
  # * Start Item Selection
  #--------------------------------------------------------------------------
  def start_item_select
    # Make item window
    @item_window = Window_Item.new
    # Associate help window
    @item_window.help_window = @help_window
    @help_window.bg_sprite.visible = true
    # Disable actor command window
    @actor_command_window.active = false
    @actor_command_window.visible = false
    @actor_command_window.bg_sprite.visible = false
  end
  #--------------------------------------------------------------------------
  # * End Item Selection
  #--------------------------------------------------------------------------
  def end_item_select
    # Dispose of item window
    @item_window.dispose
    @item_window = nil
    # Hide help window
    @help_window.visible = false
    @help_window.bg_sprite.visible = false
    # Enable actor command window
    @actor_command_window.active = true
    @actor_command_window.visible = true
    @actor_command_window.bg_sprite.visible = true
  end
  #--------------------------------------------------------------------------
  # * Start Main Phase
  #--------------------------------------------------------------------------
  def start_phase4
    # Shift to phase 4
    @phase = 4
    # Turn count
    $game_temp.battle_turn += 1
    # Search all battle event pages
    for index in 0...$data_troops[@troop_id].pages.size
      # Get event page
      page = $data_troops[@troop_id].pages[index]
      # If this page span is [turn]
      if page.span == 1
        # Clear action completed flags
        $game_temp.battle_event_flags[index] = false
      end
    end
    # Set actor as unselectable
    @actor_index = -1
    @active_battler = nil
    # Enable party command window
    @party_command_window.active = false
    @party_command_window.visible = false
    @party_command_window.bg_sprite.visible = false
    # Disable actor command window
    @actor_command_window.active = false
    @actor_command_window.visible = false
    @actor_command_window.bg_sprite.visible = false
    # Set main phase flag
    $game_temp.battle_main_phase = true
    # Make enemy action
    for enemy in $game_troop.enemies
      enemy.make_action
    end
    # Make action orders
    make_action_orders
    # Shift to step 1
    @phase4_step = 1
  end
  #--------------------------------------------------------------------------
  # * Frame Update (main phase step 1 : action preparation)
  #--------------------------------------------------------------------------
  def update_phase4_step1
    # Hide help window
    @help_window.visible = false
    @help_window.bg_sprite.visible = false
    # Determine win/loss
    if judge
      # If won, or if lost : end method
      return
    end
    # If an action forcing battler doesn't exist
    if $game_temp.forcing_battler == nil
      # Set up battle event
      setup_battle_event
      # If battle event is running
      if $game_system.battle_interpreter.running?
        return
      end
    end
    # If an action forcing battler exists
    if $game_temp.forcing_battler != nil
      # Add to head, or move
      @action_battlers.delete($game_temp.forcing_battler)
      @action_battlers.unshift($game_temp.forcing_battler)
    end
    # If no actionless battlers exist (all have performed an action)
    if @action_battlers.size == 0
      # Start party command phase
      start_phase2
      return
    end
    # Initialize animation ID and common event ID
    @animation1_id = 0
    @animation2_id = 0
    @common_event_id = 0
    # Shift from head of actionless battlers
    @active_battler = @action_battlers.shift
    # If already removed from battle
    if @active_battler.index == nil
      return
    end
    # Slip damage
    if @active_battler.hp > 0 and @active_battler.slip_damage?
      @active_battler.slip_damage_effect
      @active_battler.damage_pop = true
    end
    # Natural removal of states
    @active_battler.remove_states_auto
    # Refresh status window
    @status_window.refresh
    # Shift to step 2
    @phase4_step = 2
  end
  #--------------------------------------------------------------------------
  # * Frame Update (main phase step 5 : damage display)
  #--------------------------------------------------------------------------
  def update_phase4_step5
    # Hide help window
    @help_window.visible = false
    @help_window.bg_sprite.visible = false
    # Refresh status window
    @status_window.refresh
    # Display damage
    for target in @target_battlers
      if target.damage != nil
        target.damage_pop = true
      end
    end
    # Shift to step 6
    @phase4_step = 6
  end
end
 
I'm using SDK 2.3 and I keep using an error about it not being able to make the bitmap (whatever that means).
The error occurs on line 29 of the script you posted:
Code:
    @bg_sprite.bitmap = Bitmap.new(width, height)
Hopefully this is a simple fix and not a problem with my project.
Do I need to modify the SDK for this to work?
 
I don't see anything in the SDK or MACL that redefines Bitmap in another way.
However, it's working fine for me without the SDK.
Try implementing it in a new project without SDK.

Also, what is the error?
 
It worked fine in a new project, so thanks for that.
The error is, "Script 'SDK 2.3' line 1750: RGSSError occured. failed to create bitmap.
The code for that class is:
Code:
#==============================================================================
# ** Bitmap
#==============================================================================

class Bitmap
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_accessor :disable_dispose
  #--------------------------------------------------------------------------
  # * Alias Listings
  #--------------------------------------------------------------------------
  alias_method :sdk_bitmap_init, :initialize
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize(*args)
    # Original Initialization
sdk_bitmap_init(*args)
    # Turn Disable Dispose ON
    @disable_dispose = true
  end
end
Line 1750 is
Code:
sdk_bitmap_init(*args)

I also noticed that the results window and the window where you select the skill or item still use the windowskin. I would like for those to also have a picture background.
battle_status.png remained on the screen after the battle ended.

I just tried copying the SDK to the new project, and your script wasn't compatible with it. The battler pictures didn't appear.
 
That's something to do with the SDK forcing creating bitmaps to run through it, it makes it hard to find where the actual problem is. But the important thing is it isn't the SDK's fault, just some bitmap isn't being created correctly. Most of the time when I encounter it it's because of a bitmap with 0 height or width, so make sure that's not happening.
 

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