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.

simple script that displays stats based on variables

I've started a script but am unsure as to how to do it. the image below explains everything

http://i5.photobucket.com/albums/y200/D ... titled.png[/IMG]

here are the current scripts, the text in the two windows is just for where they are, that can be removed

Code:
#==============================================================================
# * Scene_Release
#==============================================================================

class Scene_Release
  #--------------------------------------------------------------------------
  # * Main Processing
  #--------------------------------------------------------------------------
  def main
    #call the window
    @window = Window_Release_MonsterList.new
    @window2 = Window_Release_MonsterStats.new
    # 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
    @window.dispose
    @window2.dispose
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    # Update windows
    @window.update
    # If B button was pressed
    if Input.trigger?(Input::B)
      # Play cancel SE
      $game_system.se_play($data_system.cancel_se)
      # Switch to Map screen
      $scene = Scene_Map.new
      return
    end
  end
  end

Code:
class Window_Release_MonsterList < Window_Base
  
  #----------------------------------------------------------------------
  # * Object Initialization
  #----------------------------------------------------------------------
  
  def initialize
    super(0, 0, 150, 480)
    self.contents = Bitmap.new(width - 32, height - 32)
    refresh
  end
  
  def refresh
    self.contents.clear
    self.contents.font.color = normal_color
    self.contents.font.size = 20
    self.contents.draw_text(10, 10, 100, 32, "Monster Name")
  end
  
end

Code:
class Window_Release_MonsterStats < Window_Base
  
  #----------------------------------------------------------------------
  # * Object Initialization
  #----------------------------------------------------------------------
  
  def initialize
    super(150, 0, 490, 480)
    self.contents = Bitmap.new(width - 32, height - 32)
    refresh
  end
  
  def refresh
    self.contents.clear
    self.contents.font.color = normal_color
    self.contents.font.size = 20
    self.contents.draw_text(10, 10, 1000, 32, "Monster Description")
  end
  
end
 
well basically its a monster capture system, where you have to hatch an egg
Eggs are obtained by defeating monsters, and a variable related to them is set to 1 (each one has a different variable)

You then go to a person who hatches the egg for you. This sets the earlier variable to 2, you can then add to the party, release etc ones thats done

Each variable is named the monsters name, so if i capture an Elf, the game variable 3 is called Elf, if its a Sahgin, the game variable 1 is called Sahgin

Currently the variables are 1, 3, 10-19 but more will be added as i progress

Thats how you get the monster names of the left side

The right side is stats based upon the monster currently selected. You dont need to select the monster, just move the curser to it.

All monsters are included in the actor database, and i would like them to use the current stats, not the default ones

When you choose a monster to release, it comes up with a window that asks if you want to release it, with the option of choosing yes or no
If you say no then it just goes back to the release window at the position you were at
If you say yes, the the variable to that monster is set to 0 (meaning the monster is neither captured or hatched)

The monsters once they are hatched become actors you can add to the party. They need to display the current stats etc not the database ones


Thank you if you do decide to do it, ask if you need any more info
Once i have this script, i should be able to create the other two/three based off of it

If needs be i can provide an example of the capture script i have if it helps to understand how that side of it works
 
That's what I have done so far, just tell me if you have any questions or want me to change something.

Code:
#==============================================================================
# ** Module Monster
#==============================================================================
module Monster
  # Just include the Monsters you want to have in the array, they'll be displayed
  # in the order you place them in the array
  Database_Monster = [2, 4]
  # The variables are assigned to the actors in the array, means the first 
  # variable in the array is assigned to the first actor in the Database_Monster array
  Variables = [1, 3, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]
  # Text that shows up if a character / monster is not available
  Not_Available = "Not Available"
  # Text that shows up if you want to release a monster
  Release = "Are you sure you want to release it?"
end
#==============================================================================
# ** Scene_Release
#==============================================================================

class Scene_Release
  #--------------------------------------------------------------------------
  # * Main Processing
  #--------------------------------------------------------------------------
  def main
    @bestiary_left = Window_Bestiary_Left.new
    @bestiary_right = Window_Bestiary_Right.new
    @dummy_window = Window_Base.new(170, 129, 300, 64)
    @dummy_window.contents = Bitmap.new(@dummy_window.width - 32, @dummy_window.height - 32)
    @dummy_window.contents.draw_text(4, 0, 250, 32, Monster::Release)
    @command_window = Window_Command.new(160,["Yes", "No"])
    @command_window.active = false
    @command_window.visible = false
    @command_window.x = 320 - @command_window.width / 2
    @command_window.y = 240 - @command_window.height / 2
    @command_window.z = 150
    @dummy_window.z = 150
    @dummy_window.visible = false
    refresh
    # 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
    @bestiary_left.dispose
    @bestiary_right.dispose
    @command_window.dispose
    @dummy_window.dispose
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    if @old_index != @bestiary_left.index
      @bestiary_right.refresh(@bestiary_left.index)
      @old_index = @bestiary_left.index
    end
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    @command_window.update
    @bestiary_left.update
    refresh
    if @bestiary_left.active
      bestiary_update
    elsif @command_window.active
      command_update
    end
  end
  #--------------------------------------------------------------------------
  # * Frame Update (when bestiary window is active)
  #--------------------------------------------------------------------------
  def bestiary_update
    if Input.trigger?(Input::B)
      # Play cancel SE
      $game_system.se_play($data_system.cancel_se)
      # Switch to Map screen
      $scene = Scene_Map.new
      return
    end
    if Input.trigger?(Input::C)
      if $game_variables[Monster::Variables[@bestiary_left.index]] != 2
        # Play buzzer SE
        $game_system.se_play($data_system.buzzer_se)
        return
      end
      $game_system.se_play($data_system.decision_se)
      @bestiary_left.active = false
      @command_window.active = true
      @command_window.visible = true
      @dummy_window.visible = true
      @command_window.index = 0
      return
    end
  end
  #--------------------------------------------------------------------------
  # * Frame Update (when command window is active)
  #--------------------------------------------------------------------------
  def command_update
    if Input.trigger?(Input::B)
      # Play cancel SE
      $game_system.se_play($data_system.cancel_se)
      @bestiary_left.active = true
      @command_window.active = false
      @command_window.visible = false
      @dummy_window.visible = false
      @command_window.index = 0
      return
    end
    if Input.trigger?(Input::C)
      # Play decision SE
      $game_system.se_play($data_system.decision_se)
      case @command_window.index
      when 1
        @bestiary_left.active = true
        @command_window.active = false
        @command_window.visible = false
        @dummy_window.visible = false
        @command_window.index = 0
      when 0
        $game_variables[Monster::Variables[@bestiary_left.index]] = 0
        # Switch to Map screen
        $scene = Scene_Map.new
      end
    end
  end
end
#==============================================================================
# * Window_Bestiary_Left
#==============================================================================

class Window_Bestiary_Left < Window_Selectable
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    super(0, 0, 210, 480)
    self.contents = Bitmap.new(width - 32, height - 32)
    @index = 0
    @item_max = Monster::Database_Monster.size
    refresh
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    self.contents.font.color = Color.new(0, 0, 0)
    self.contents.draw_text(3, 1, 150, 32, "Monster Name:")
    self.contents.draw_text(5, -1, 150, 32, "Monster Name:")
    self.contents.draw_text(3, -1, 150, 32, "Monster Name:")
    self.contents.draw_text(5, 1, 150, 32, "Monster Name:")
    self.contents.font.color = normal_color
    self.contents.draw_text(4, 0, 150, 32, "Monster Name:")
    for i in 0...Monster::Database_Monster.size
      y = i * 32
      @name = $game_variables[Monster::Variables[i]] == 2 ? $game_actors[Monster::Database_Monster[i]].name : Monster::Not_Available
      self.contents.draw_text(4, y + 32, 150, 32, "#{@name}")
    end
  end
  #--------------------------------------------------------------------------
  # * Cursor Rectangle Update
  #--------------------------------------------------------------------------
  def update_cursor_rect
    self.cursor_rect.set(0, @index * 32 + 32, self.width - 32, 32)
  end
end
#==============================================================================
# * Window_Bestiary_Right
#==============================================================================

class Window_Bestiary_Right < Window_Base
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    super(210, 0, 430, 480)
    self.contents = Bitmap.new(width - 32, height - 32)
    refresh
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh(index = 0)
    self.contents.clear
    @monster = $game_actors[Monster::Database_Monster[index]]
    self.contents.font.color = Color.new(0, 0, 0)
    self.contents.draw_text(3, 1, 200, 32, "Monster Description:")
    self.contents.draw_text(5, -1, 200, 32, "Monster Description:")
    self.contents.draw_text(3, -1, 200, 32, "Monster Description:")
    self.contents.draw_text(5, 1, 200, 32, "Monster Description:")
    self.contents.font.color = normal_color
    self.contents.draw_text(4, 0, 200, 32, "Monster Description:")
    if $game_variables[Monster::Variables[index]] == 2
      draw_actor_battler(@monster, 140, 256)
      draw_actor_hp(@monster, 4, 32)
      draw_actor_parameter(@monster, 204, 32, 4)
      draw_actor_sp(@monster, 4, 64)
      draw_actor_parameter(@monster, 204, 64, 5)
      draw_actor_parameter(@monster, 4, 96, 3)
      draw_actor_parameter(@monster, 204, 96, 6)
      draw_actor_level(@monster, 4, 160)
      self.contents.draw_text(52, 192, 150, 32, "#{@monster.now_exp} / #{@monster.next_exp}")
      self.contents.font.color = system_color
      self.contents.draw_text(4, 192, 120, 32, "Exp:")
    else
      self.contents.font.color = system_color
      self.contents.draw_text(4, 32, 32, 32, $data_system.words.hp)
      self.contents.draw_text(4, 64, 32, 32, $data_system.words.sp)
      self.contents.draw_text(204, 32, 120, 32, $data_system.words.dex)
      self.contents.draw_text(204, 64, 120, 32, $data_system.words.agi)
      self.contents.draw_text(4, 96, 120, 32, $data_system.words.str)
      self.contents.draw_text(204, 96, 120, 32, $data_system.words.int)
      self.contents.draw_text(4, 160, 120, 32, "Lv")
      self.contents.draw_text(4, 192, 120, 32, "Exp:")
    end
  end
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 the current EXP
  #--------------------------------------------------------------------------
  def now_exp
    return @exp - @exp_list[@level]
  end
  #--------------------------------------------------------------------------
  # * Get the next level's EXP
  #--------------------------------------------------------------------------
  def next_exp
    return @exp_list[@level+1] > 0 ? @exp_list[@level+1] - @exp_list[@level] : 0
  end
end
#==============================================================================
# ** Window_Base
#==============================================================================

class Window_Base < Window
  #--------------------------------------------------------------------------
  # * Draw Battler
  #     actor : actor
  #     x     : draw spot x-coordinate
  #     y     : draw spot y-coordinate
  #--------------------------------------------------------------------------
  def draw_actor_battler(actor, x, y)
    bitmap = RPG::Cache.battler(actor.battler_name, actor.battler_hue)
    self.contents.blt(x, y, bitmap, Rect.new(0, 0, bitmap.width, bitmap.height))
  end
end

Instruction are within the script. I used the names from the actors in the database, because I don't know how to use a variable's name.
 
thank you, from what i've tested it works perfectly

ok, last question ,which hopefully will just be an edit

i'm also looking at a monster merge system, where you choose two monsters, and it produces a third, and you loose the first two

so if its possible to set up in the same way as this one that'd be great
 
bump

i realised it wasn't very good explanation.
Its a monster evolve system, but you evolve them by choosing 2 monsters, you loose the original 2 and you gain the third.

so if you chose monster 1 as sahgin (variable 2) and monster 2 as elf (variable 3) you would get water elf (variable 4) - variable numbers are examples
 

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