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.

Varible-based Stat Display?

I am making a game in which all of my character's stats are variables.  (So, throwing the built-in "HP", "intelligence", etc. out the window and building my own... mainly because I have so many.)

I would like to have one big, easy, convenient window that the user can pull up to look at all the "stats" at once.

Whether it's just one big message window or, even better, if I can somehow redirect to a screen like this when they select "Status" in the Menu, that would be grand.

Obviously, I can get variable #s to display in a normal message window, BUT normal message windows are very tiny and only allow me to list a few variables.  I have tried custom message scripts that supposedly allow you to increase the size of a message window, but even when the msg. window size is increased, I'm bound by RPGXP's "four lines per box" rule.

Thanks for your advice!
 

khmp

Sponsor

For this you would need to edit Scene_Status and create a new window. Not that either of those things are difficult but that be all you would need to do to get this to work. You just need some way of finding what stats are associated with what actor. And how would you link them together so you don't have a ridiculous amount of hard coding going on. So my recommendation is storing players stats within ranges within $game_variables. Like Actor 0 would have 10..19 reserved while Actor 1 in the database would have 20..29. There's an array inside the code that has every actor stored within it directly from the database. We will use the actor's id value, which is the index where the actor is located within the array that I just mentioned, to offset into the variable location of the stats. So going back to my example of every 9 values after variable 10 contain actor stats lets say we want the stats of the leader. Whose index in the actors array is actually [3]. (9 * 3 + 10) Would be the starting variable location of where the actors stats would be found within $game_variables. Or with variables to better explain what's happening:
Code:
starting_index = amount_of_stats * actors_index + variable_offset

Code:
#==============================================================================
# ** Scene_Status
#------------------------------------------------------------------------------
#  This class performs status screen processing.
#==============================================================================

class Scene_Status
  #--------------------------------------------------------------------------
  # * Main Processing !OVERRIDE!
  #--------------------------------------------------------------------------
  def main
    # Get actor
    @actor = $game_party.actors[@actor_index]


    # THIS LINE WE WILL CHANGE TO INSTANTIATE OUR NEW WINDOW
    @status_window = Window_StatusRedux.new(@actor)


    # Execute transition
    Graphics.transition
    # 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

    # Prepare for transition
    Graphics.freeze
    # Dispose of windows
    @status_window.dispose
  end
end

So now that we've changed Scene_Status to show our new window. Let's actually create that window.

Code:
#==============================================================================
# ** Window_StatusRedux
#------------------------------------------------------------------------------
#  This window class shows the stats of an actor.
#==============================================================================

class Window_StatusRedux
  #--------------------------------------------------------------------------
  # * Constant Variables
  #--------------------------------------------------------------------------
  Starting_Stat = 10 # The index of the first variable containing a stat.
  Stat_Amount = 9 # The number of stats per actor.
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     actor : actor
  #--------------------------------------------------------------------------
  def initialize(actor)
    super(0, 0, 640, 480)
    self.contents = Bitmap.new(width - 32, height - 32)
    @offset = Stat_Amount * actor.id + Starting_Stat
    refresh
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    fir_stat = $game_variables[@offset]
    self.contents.draw_text(x, y, width, height, 'First Stat:' + fir_stat.to_s)

    sec_stat = $game_variables[@offset + 1]
    self.contents.draw_text(x, y, width, height, 'Second Stat:' + sec_stat.to_s)

    thi_stat = $game_variables[@offset + 2]
    self.contents.draw_text(x, y, width, height, 'Third Stat:' + thi_stat.to_s)

    # Ad infinitum
    ...
  end
end

That's the basics behind it. You very well may want to do more elaborate text drawing. Mine was just a quick and dirty example of how to do it.

Good luck with it Mallamun! :thumb:
 
Thanks, this was really helpful!

Unfortunately, I am having a problem loading the newly created window.  I was given a "wrong number of arguments" error for the line:

    super(0, 0, 640, 480)

in Window_StatusRedux.  I don't really know how to make sense of this; any pointers?
 

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