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.

Hero graphic set to one character

Status
Not open for further replies.
I was wondering if there was a way to make it so that no matter what character is in the first position, the graphic of that character never changes. say Actor 1 is the main character and is in slot 1, if I were to switch actor 2 into the first slot, it'd still show actor one walking around the map, not actor 2's graphics. Make sense? I've looked around a bit but I can't seem to figure out how to make it happen beyond setting every single characters graphic to that of the main characters and I'd rather not do that.

Any tips, ideas or possibly an answer, I'm sure this is quite simple.
 
Lockheart;285547 said:
I've looked around a bit but I can't seem to figure out how to make it happen beyond setting every single characters graphic to that of the main characters and I'd rather not do that.

I already stated that I don't want to have to do that. But thanks anyways.
 
I'm using something similar in my game, wrote this up in about 5 minutes:

Code:
class Sprite_Character < RPG::Sprite
  def update
    super
    # If tile ID, file name, or hue are different from current ones
    if @tile_id != @character.tile_id or
       @character_name != @character.character_name or
       @character_hue != @character.character_hue
      # Remember tile ID, file name, and hue
      @tile_id = @character.tile_id
      @character_name = @character.character_name
      @character_hue = @character.character_hue
      # If tile ID value is valid
      if @tile_id >= 384
        self.bitmap = RPG::Cache.tile($game_map.tileset_name,
          @tile_id, @character.character_hue)
        self.src_rect.set(0, 0, 32, 32)
        self.ox = 16
        self.oy = 32
      # If tile ID value is invalid
      else
        if @character.is_a?(Game_Player)
          self.bitmap = RPG::Cache.character($game_actors[$game_temp.leadchar].character_name,
                                             $game_actors[$game_temp.leadchar].character_hue)
        else
          self.bitmap = RPG::Cache.character(@character.character_name,
            @character.character_hue)
        end
        @cw = bitmap.width / 4
        @ch = bitmap.height / 4
        self.ox = @cw / 2
        self.oy = @ch
      end
    end
    # Set visible situation
    self.visible = (not @character.transparent)
    # If graphic is character
    if @tile_id == 0
      # Set rectangular transfer
      sx = @character.pattern * @cw
      sy = (@character.direction - 2) / 2 * @ch
      self.src_rect.set(sx, sy, @cw, @ch)
    end
    # Set sprite coordinates
    self.x = @character.screen_x
    self.y = @character.screen_y
    self.z = @character.screen_z(@ch)
    # Set opacity level, blend method, and bush depth
    self.opacity = @character.opacity
    self.blend_type = @character.blend_type
    self.bush_depth = @character.bush_depth
    # Animation
    if @character.animation_id != 0
      animation = $data_animations[@character.animation_id]
      animation(animation, true)
      @character.animation_id = 0
    end
  end
end

class Game_Temp
  attr_accessor :leadchar
  alias frarghckinitialize initialize
  def initialize
    frarghckinitialize
    @leadchar = 1
  end
end

class Scene_Save < Scene_File
  alias frarghckwritesavedata write_save_data
  def write_save_data(file)
    frarghckwritesavedata(file)
    Marshal.dump($game_temp.leadchar, file)
  end
end

class Scene_Load < Scene_File
  alias frarghckreadsavedata read_save_data
  def read_save_data(file)
    $game_temp.leadchar = Marshal.load(file)
    frarghckreadsavedata(file)
  end
end
Just stick it above main and use
$game_temp.leadchar = X
Replace X with the ID number of the actor whose graphic you want to use.
It'll use the graphic whether or not the actor is in your party, so you might need to check for that if the lead character ever leaves the group <.<

Note that if you have any saves, this'll mess them up.
You can fix them all by removing the Scene_Load part of the script, loading up your saves and saving them again, then putting the Scene_Load part back in.
o_ob
 
This topic has been resolved. If Lockheart 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