Save-Point

Full Version: Save-Point
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Board Message
Sorry, you do not have permission to access this resource.
Save-Point - Portraits in RPGMXP Battles. (Edited Scene_Battle 1)

Save-Point

Full Version: Portraits in RPGMXP Battles. (Edited Scene_Battle 1)
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I'm attempting to display a reversed character portrait of the character who is currently selecting their action on the top right side of the screen.
I'm having a few problems with this script that I edited: (Scene_Battle 1)

Scene_Battle 1 (Please review only the edited portion. It's notated in the script, as is the line with the Syntax Error)

The main issue is that not only is a portrait not displayed, I get a line 344 Syntax Error for "end." (The last one in the script.)
Also, I don't know how to show a reversed image of the portrait.

Thank you in advance for the help. It's appreciated.
You need to put your code in a new Window class (class Window_Portrait < Window), and then instantiate this class in your scene (@window_portrait = Window_Portrait.new). Look at the existing code !
Moreover, you began a loop (for i in 0...$game_party.actors.size) without ending it, giving the syntax error.
I changed it to this, but I'm still getting the "end" Syntax Error and I'm also getting a Syntax Error on the "class Window_Portrait < Window" line.
New Script

Step by step :

1. Create your new window class. You need your initialize, draw_actor_face_graphic and refresh methods.
As you want to display the curent actor's portrait, you need to refresh the window for an actor.
Don't call refresh in your initialize method, because you don't have a selected actor yet.

Code:
#===========================================================
# ** Window_Portrait
#===========================================================
class Window_Portrait < Window_Base
  #-----------------------------------------------------------------------------
  # * Object Initialization
  #-----------------------------------------------------------------------------
  def initialize
    super(533, 0, 110, 96)
    self.contents = Bitmap.new(width - 32, height - 32)
  end
  #-----------------------------------------------------------------------------
  # * Draw Actor Graphic
  #-----------------------------------------------------------------------------
  def draw_actor_face_graphic(actor, x, y)
    bitmap = RPG::Cache.picture(actor.id.to_s)
    self.contents.blt(x, y, bitmap, Rect.new(0, 0, bitmap.width, bitmap.height))
  end
  #-----------------------------------------------------------------------------
  # * Refresh
  #-----------------------------------------------------------------------------
  def refresh(actor)
    self.contents.clear
    draw_actor_face_graphic(actor, 0, 0)
  end
end

2. In your scene for battles, create a Window_Portrait objet at the beginning of the battle, and delete it at the end, as it is already done for other windows. So modify the main method of the Scene_battle class like this (2 modifications - search "NEW" in the code) :

Code:
#--------------------------------------------------------------------------
  # * 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.active = false
    @actor_command_window.visible = false
    # Make other windows
    @party_command_window = Window_PartyCommand.new
    @help_window = Window_Help.new
    @help_window.back_opacity = 160
    @help_window.visible = false
    @status_window = Window_BattleStatus.new
    @message_window = Window_Message.new
    
    # NEW create a window for portraits
    @window_portrait = Window_Portrait.new
    @window_portrait.visible = false # not visible by default
    
    # 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
    
    # NEW : delete the window for portraits
    @window_portrait = Window_Portrait.new
    
    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

3. You want to make your window visible and refresh it when an actor select its actions, so modify the phase3_setup_command_window method (Scene_Battle class) like this (two lines added at the end) :

Code:
#--------------------------------------------------------------------------
  # * Actor Command Window Setup
  #--------------------------------------------------------------------------
  def phase3_setup_command_window
    # Disable party command window
    @party_command_window.active = false
    @party_command_window.visible = false
    # Enable actor command window
    @actor_command_window.active = true
    @actor_command_window.visible = true
    # Set actor command window position
    @actor_command_window.x = @actor_index * 160
    # Set index to 0
    @actor_command_window.index = 0
    
    # refresh the portrait
    @window_portrait.visible = true
    @window_portrait.refresh(@active_battler)
  end

4. Hide the window when the selection is done : you have to add @window_portrait.visible = false at the beginning of the two following methods in the Scene_Battle class:
phase3_next_actor and phase3_prior_actor.

Code:
#--------------------------------------------------------------------------
  # * Go to Command Input for Next Actor
  #--------------------------------------------------------------------------
  def phase3_next_actor
    @window_portrait.visible = false
    # Loop
    begin
      # Actor blink effect OFF
      if @active_battler != nil
        @active_battler.blink = false
      end
      # If last actor
      if @actor_index == $game_party.actors.size-1
        # Start main phase
        start_phase4
        return
      end
      # Advance actor index
      @actor_index += 1
      @active_battler = $game_party.actors[@actor_index]
      @active_battler.blink = true
    # Once more if actor refuses command input
    end until @active_battler.inputable?
    # Set up actor command window
    phase3_setup_command_window
  end
  #--------------------------------------------------------------------------
  # * Go to Command Input of Previous Actor
  #--------------------------------------------------------------------------
  def phase3_prior_actor
    @window_portrait.visible = false
    # Loop
    begin
      # Actor blink effect OFF
      if @active_battler != nil
        @active_battler.blink = false
      end
      # If first actor
      if @actor_index == 0
        # Start party command phase
        start_phase2
        return
      end
      # Return to actor index
      @actor_index -= 1
      @active_battler = $game_party.actors[@actor_index]
      @active_battler.blink = true
    # Once more if actor refuses command input
    end until @active_battler.inputable?
    # Set up actor command window
    phase3_setup_command_window
  end


Thank you so much. I'll be sure to credit you when my game is done.