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.

Using facesets for this CBS

Status
Not open for further replies.
Could someone please edit this battle system so where the battlers usally go, facesets go insted? Here's an example pic of the battle system. The red circles are where I want the faces to go.
http://img72.imageshack.us/img72/8069/sdva2qh3.th.jpg[/IMG]

And here's the script:
Code:
#==============================================================================
# ++ Side View Battle (Walking Graphic Edition) ver. 1.14 ++
#  Script by ParaDog
#  http://2d6.parasite.jp/
#------------------------------------------------------------------------------
# Walking graphics are displayed as battlers on the battlefield.
#==============================================================================

module SDVA
  
  X_LINE = 500        # Horizontal coordinates of actor battlers
  Y_LINE = 200        # Vertical coordinates of actor battlers
  X_SPACE = 15        # Horizontal spacing between actor battlers
  Y_SPACE = 40        # Vertical spacing between actor battlers
                      # Formations:
  X_POSITION = 25     # Extra horizontal spacing between frontrow/backrow battlers
  Y_POSITION = 0      # Extra vertical spacing between frontrow/backrow battlers
  
  ATTACK_MOVE = true  # Move when attacking   ( true / false )
  SKILL_MOVE = true   # Move when using skill ( true / false )
  ITEM_MOVE = false   # Move when using item  ( true / false )
  MOVE_STEP = 1       # Number of steps taken
  MOVE_PIXEL = 10     # Number of pixels moved per step (see above)
  
  PARTY_POS = 0       # Direction the characters are facing
                      # (0: Down / 1: To the left / 2: To the right / 3: Up )

  WINDOWPOS_CHANGE = true   # Command Window position changes according to the 
                            # battler (appears under the battler) (true / false)
  
  end
  
#==============================================================================
# ** Game_Actor
#------------------------------------------------------------------------------
#  This class handles the actor. It's used within the Game_Actors class
#  ($game_actors) and refers to the Game_Party class ($game_party).
#==============================================================================

class Game_Actor < Game_Battler
  #--------------------------------------------------------------------------
  # * Get Battle Screen X-Coordinate
  #--------------------------------------------------------------------------
  def screen_x
    if self.index != nil
      # Acquiring the formation type
      pos = $data_classes[self.class_id].position
      x_pos = pos * SDVA::X_POSITION
      scr_x = self.index * SDVA::X_SPACE + SDVA::X_LINE + x_pos
      # If battler movement available
      if self.current_action.move_action == true
        # Move the battler
        scr_x += @shift_x
      end
      return scr_x
    else
      return 0
    end
  end
  #--------------------------------------------------------------------------
  # * Get Battle Screen Y-Coordinate
  #--------------------------------------------------------------------------
  def screen_y
    if self.index != nil
      # Acquiring the formation type
      pos = $data_classes[self.class_id].position
      y_pos = pos * SDVA::Y_POSITION
      scr_y = self.index * SDVA::Y_SPACE + SDVA::Y_LINE + y_pos
      # If battler movement available
      if self.current_action.move_action == true
        # Move the battler
        scr_y += @shift_y
      end
      return scr_y
    else
      return 0
    end
  end
  #--------------------------------------------------------------------------
  # * Get Battle Screen Z-Coordinate
  #--------------------------------------------------------------------------
  def screen_z
    if self.index != nil
      return self.index
    else
      return 0
    end
  end
end

#==============================================================================
# ** Game_Battler (part 1)
#------------------------------------------------------------------------------
#  This class deals with battlers. It's used as a superclass for the Game_Actor
#  and Game_Enemy classes.
#==============================================================================

class Game_Battler
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_reader   :pattern        # Pattern
  attr_reader   :trans_x        # trans_X
  attr_reader   :moving         # moving
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  alias initialize_sdva initialize
  def initialize
    initialize_sdva
    move_reset
  end
  #--------------------------------------------------------------------------
  # * Move
  #--------------------------------------------------------------------------
  def move
    @moving = 1
      if @step < SDVA::MOVE_STEP
        # Move until steps completed
        @pattern = (@pattern + 1) % 4
        @step += 1
        move_step
      else
        # End movement
        @pattern = 1
        @moving = 2
      end
  end
  #--------------------------------------------------------------------------
  # * Move Step
  #--------------------------------------------------------------------------
  def move_step
  # Branch according to party direction
  case SDVA::PARTY_POS
    when 0
      @shift_y = @step * SDVA::MOVE_PIXEL
    when 1
      @shift_x = -(@step * SDVA::MOVE_PIXEL)
    when 2
      @shift_x = @step * SDVA::MOVE_PIXEL
    when 3
      @shift_y = -(@step * SDVA::MOVE_PIXEL)
    end       
  end
  #--------------------------------------------------------------------------
  # * Move Reset
  #--------------------------------------------------------------------------
  def move_reset
    @moving = 0
    @pattern = 0
    @step = 0
    @shift_x = 0
    @shift_y = 0
  end
end

#==============================================================================
# ** Game_BattleAction
#------------------------------------------------------------------------------
#  This class handles actions in battle. It's used within the Game_Battler 
#  class.
#==============================================================================

class Game_BattleAction
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_accessor :move_action             # move action
  #--------------------------------------------------------------------------
  # * Clear
  #--------------------------------------------------------------------------
  alias clear_sdva clear
  def clear
    clear_sdva
    @move_action = false
  end
end

#==============================================================================
# ** Sprite_Battler
#------------------------------------------------------------------------------
#  This sprite is used to display the battler.It observes the Game_Character
#  class and automatically changes sprite conditions.
#==============================================================================

class Sprite_Battler < RPG::Sprite
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  alias update_sdva update
  def update
    # If actor which should be displayed
    if @battler.is_a?(Game_Actor)
      # If file name, hue or moving states are different than current ones
      if @battler.battler_name != @battler_name or
         @battler.battler_hue != @battler_hue or
         @battler.current_action.basic == 0 or
         @battler.current_action.kind != 3
        # Get and set bitmap
        @character_name = @battler.character_name
        @character_hue = @battler.character_hue
        # Draw walking graphics
        self.bitmap = RPG::Cache.character(@character_name, @character_hue)
        cw = self.bitmap.width / 4
        ch = self.bitmap.height / 4
        @width = cw
        @height = ch
        if @battler.current_action.move_action == true
          # Make it walk
          @battler.move
        else
          @battler.move_reset
        end
        # Set rectangular transfer
        sx = @battler.pattern * cw
        sy = SDVA::PARTY_POS * ch
        self.src_rect.set(sx, sy, cw, ch)
        self.ox = @width / 2
        self.oy = @height
        # If hidden, set opacity to 0
        if @battler.hidden
          self.opacity = 0
        end
      end
    end
    update_sdva
  end
end
  
#==============================================================================
# ** Scene_Battle 
#------------------------------------------------------------------------------
#  This class performs battle screen processing.
#==============================================================================

class Scene_Battle
  #--------------------------------------------------------------------------
  # * Actor Command Window Setup
  #--------------------------------------------------------------------------
  alias phase3_setup_command_window_sdva phase3_setup_command_window
  def phase3_setup_command_window
    phase3_setup_command_window_sdva
    if SDVA::WINDOWPOS_CHANGE
      # Branch and set position of the Actor Command Window
      case SDVA::PARTY_POS
        when 0
          x_pos = @active_battler.screen_x - (@actor_command_window.width/2)
          y_pos = @active_battler.screen_y
        when 1
          x_pos = @active_battler.screen_x - @actor_command_window.width - 16
          y_pos = @active_battler.screen_y - @actor_command_window.height
        when 2
          x_pos = @active_battler.screen_x + 16
          y_pos = @active_battler.screen_y - @actor_command_window.height
        when 3
          x_pos = @active_battler.screen_x - (@actor_command_window.width/2)
          y_pos = @active_battler.screen_y - @actor_command_window.height - 48
      end
      @actor_command_window.x = x_pos >= 0 ? x_pos : 0
      @actor_command_window.x = x_pos+@actor_command_window.width <= 640 ? x_pos : 640-@actor_command_window.width
      @actor_command_window.y = y_pos >= 0 ? y_pos : 0
      @actor_command_window.y = y_pos+@actor_command_window.height <= 480 ? y_pos : 480-@actor_command_window.height
      # Ensure Actor Command Window is in front of BattleStatus window
      @actor_command_window.z = 9999
    end
  end
  #--------------------------------------------------------------------------
  # * Frame Update (main phase step 3 : animation for action performer)
  #--------------------------------------------------------------------------
  alias update_phase4_step3_sdva update_phase4_step3
  def update_phase4_step3
    if SDVA::ATTACK_MOVE
      if @active_battler.current_action.basic == 0
        @active_battler.current_action.move_action = true
      end
    end
    if SDVA::SKILL_MOVE
      if @active_battler.current_action.kind == 1
        @active_battler.current_action.move_action = true
      end
    end
    if SDVA::ITEM_MOVE
      if @active_battler.current_action.kind == 2
        @active_battler.current_action.move_action = true
      end
    end
    # If actor is in action
    if @active_battler.is_a?(Game_Actor) and
     @active_battler.current_action.move_action
      # If the actor ends movement
      if @active_battler.moving == 2
        update_phase4_step3_sdva
      end
    elsif @active_battler.moving == 0
      update_phase4_step3_sdva
    end
  end
  #--------------------------------------------------------------------------
  # * Frame Update (main phase step 6 : refresh)
  #--------------------------------------------------------------------------
  alias update_phase4_step6_sdva update_phase4_step6
  def update_phase4_step6
    @active_battler.current_action.move_action = false
    @active_battler.move_reset
    update_phase4_step6_sdva
  end
end

#==============================================================================
# ** Spriteset_Battle
#------------------------------------------------------------------------------
#  This class brings together battle screen sprites. It's used within
#  the Scene_Battle class.
#==============================================================================

class Spriteset_Battle
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  alias initialize_sdva initialize
  def initialize
    initialize_sdva
    @viewport2.z = 1
  end
end

#==============================================================================
# ** Arrow_Actor
#------------------------------------------------------------------------------
#  This arrow cursor is used to choose an actor. This class inherits from the
#  Arrow_Base class.
#==============================================================================

class Arrow_Actor < Arrow_Base
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  alias update_sdva update
  def update
    update_sdva
    # If the down directional button was pressed
    if Input.repeat?(Input::DOWN)
      $game_system.se_play($data_system.cursor_se)
      @index += 1
      @index %= $game_party.actors.size
    end
    # If the up directional button was pressed
    if Input.repeat?(Input::UP)
      $game_system.se_play($data_system.cursor_se)
      @index += $game_party.actors.size - 1
      @index %= $game_party.actors.size
    end
  end
end

#==============================================================================
# ** Arrow_Enemy
#------------------------------------------------------------------------------
#  This arrow cursor is used to choose enemies. This class inherits from the 
#  Arrow_Base class.
#==============================================================================

class Arrow_Enemy < Arrow_Base
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  alias update_sdva update
  def update
    update_sdva
    # If the down directional button was pressed
    if Input.repeat?(Input::DOWN)
      $game_system.se_play($data_system.cursor_se)
      $game_troop.enemies.size.times do
        @index += 1
        @index %= $game_troop.enemies.size
        break if self.enemy.exist?
      end
    end
    # If the up directional button was pressed
    if Input.repeat?(Input::UP)
      $game_system.se_play($data_system.cursor_se)
      $game_troop.enemies.size.times do
        @index += $game_troop.enemies.size - 1
        @index %= $game_troop.enemies.size
        break if self.enemy.exist?
      end
    end
  end
end

The faces I plan on using are each 100x100 pixels.

Thanks in advance.
 
Go into Window_BattleStatus.

Below this line
Code:
      actor_x = i * 160 + 4

Add this:
Code:
      draw_actor_face(actor, actor_x, 0)

Now, in Window_Base, add this method before the final end.
Code:
  def draw_actor_face(actor, x, y)
    bitmap = RPG::Cache.face(actor.character_name, actor.character_hue)
    self.contents.blt(x, y, bitmap, Rect.new(0, 0, bitmap.width, bitmap.height)
  end

Now, insert this anywhere above Main.
Code:
module RPG::Cache
  def self.face(filename, hue)
    self.load_bitmap("Graphics/Faces/", filename, hue)
  end
end

Create a folder named "Faces" in your graphics folder and name them after the character names (the character sprite sheets).
 
I get an syntax error on Window_Base line 324 which is the next to the last end. Here's what I have at the end of Window_Base.
Code:
def draw_actor_face(actor, x, y)
    bitmap = RPG::Cache.face(actor.character_name, actor.character_hue)
    self.contents.blt(x, y, bitmap, Rect.new(0, 0, bitmap.width, bitmap.height)
  end
end
EDIT: Ok, I fixed it now. But do I need to put in coordinates? I couldent get the facesets to appear.
 

Mac

Member

Looks like SS forgot to close a bracket...replace that one with this:-

Code:
def draw_actor_face(actor, x, y)
    bitmap = RPG::Cache.face(actor.character_name, actor.character_hue)
    self.contents.blt(x, y, bitmap, Rect.new(0, 0, bitmap.width, bitmap.height))
  end
end

If it doesn't work then say and i will give you my version.
 
This topic has been resolved. If sithlord999 or any other users have any questions or further problems regarding this topic, please create a new thread about them.

Thank you!
 
Status
Not open for further replies.

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