Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Clive's Hero Database
#1
Clive's Hero Database
by SephirothSpawn
Version: 1 (02.22.06)


This is a locked, single-post thread from Creation Asylum. Archived here to prevent its loss.
No support is given.


Introduction
Lets you view all the heros in your database. Un-recruited heros, will show up as an unknown actor.

Demo:

.zip   Clive__s_Hero_Database.zip (Size: 208.47 KB / Downloads: 1)

Script:
Code:
#==============================================================================
# Clive's Hero Database
#==============================================================================
# SephirothSpawn
# Version 1
# 22.02.06
#==============================================================================
# Instructions:
#   ~ Setting Up Hero's Bio
#         Find the line HERO_BIO = {
#         Below That, have a x=>[] for each actor in your database
#         Withing the array, have up to 3 lines of 'text'
#   ~ Calling the Scene
#         Use: $scene = Scene_Hero_DataBase.new
#==============================================================================

#------------------------------------------------------------------------------
# * SDK Log Script
#------------------------------------------------------------------------------
SDK.log("Clive's Hero Database", 'SephirothSpawn', 1, '22.02.06')

#------------------------------------------------------------------------------
# * Begin SDK Enable Test
#------------------------------------------------------------------------------

if SDK.state("Clive's Hero Database") == true

  #==============================================================================
# ** Window_Clive_HeroStatus
#==============================================================================
class Window_Clive_HeroStatus < Window_Base
  #--------------------------------------------------------------------------
  # * Hero Biography Constant
  #--------------------------------------------------------------------------
  HERO_BIO = {
    1=>["Here's a neat fact:", 'Arshes is the most used sprite in the rmxp community'],
    2=>['I thought Basil was something for cooking?'],
    3=>['I am thor!', 'Fear My Axe!'],
    4=>['Watch out fellas,', 'She will steal your hearts', '[/chessy]'],
    5=>['I still do not understant', 'whats up with the end of here bow...'],
    6=>['Bang Bang!'],
    7=>['Only for healing...'],
    8=>['Woot Woot!', 'Kill those Ghost with Fire', 'The secret to beat Sephs Demos']
    }
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize(actor, index)
    super(0, 0, 640, 480)
    self.contents = Bitmap.new(width - 32, height - 32)
    @actor, @index, @frame = actor, index, 0
    refresh
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    # Information Arrays
    main_info = ['Name:', 'Class:', 'Level:', 'Experience:', 'Next Level:']
    stat_info = ['hp', 'sp', 'str', 'dex', 'agi', 'int'].collect! {|x| (eval "$data_system.words.#{x}") + ':'}
    stat_info.push('Evasion:', 'Hit %:')
    equip_info = ['atk', 'pdef', 'mdef'].collect! {|x| (eval "$data_system.words.#{x}") + ':'}
    # Draws Page
    self.contents.font.color = system_color
    self.contents.draw_text(192, 0, 224, 24, "Page : #{@index} / #{$data_actors.size - 1}", 1)
    # Draws Stat Words
    for i in 0...stat_info.size
      self.contents.draw_text(4, 144 + i * 24, 284, 24, stat_info[i])
    end
    # Draws Equipment Words
    for i in 0...equip_info.size
      self.contents.draw_text(324, 144 + i * 24, 284, 24, equip_info[i])
    end
    # Draws Biography Heading
    self.contents.font.color = @actor.nil? ? disabled_color : normal_color
    self.contents.draw_text(20, 336, contents.width, 24, 'Biography:')
    # If Actor isn't nil
    unless @actor.nil?
      # Draws Actor Sprite
      refresh_sprite
      # Draws Actor Battler
      self.contents.scale_blt(Rect.new(400, 0, 192, 144),
        bitmap = RPG::Cache.battler(@actor.battler_name, @actor.battler_hue),
        Rect.new(0, 0, bitmap.width, bitmap.height))      
      # Gets Actor Main Information
      info = ['name', 'class_name', 'level', 'exp', 'next_rest_exp_s'].collect! {|x| eval "@actor.#{x}"}
      # Draws Main Information
      self.contents.font.color = system_color
      for i in 0...info.size
        self.contents.draw_text(192, (i + 1) * 24, 224, 24, "#{main_info[i]} #{info[i]}", 1)
      end
      # Gets Acor Stat Information
      info = ["#{@actor.hp} / #{@actor.maxhp}", "#{@actor.sp} / #{@actor.maxsp}"]
      info << ['str', 'dex', 'agi', 'int', 'eva', 'hit'].collect! {|x| eval "@actor.#{x}"}
      # Draws Actor Stat Information
      self.contents.font.color = normal_color
      for i in 0...info.flatten!.size
        self.contents.draw_text(- 4, 144 + i * 24, 284, 24, info[i].to_s, 2)
      end
      # Gets Actor Base Equip Information
      info = ['atk', 'pdef', 'mdef'].collect! {|x| eval "@actor.#{x}"}
      for i in 0..info.size
        self.contents.draw_text(316, 144 + i * 24, 284, 24, info[i].to_s, 2)
      end
      # Gets Equipment IDs
      equipment = ['weapon_id', 'armor1_id', 'armor2_id', 'armor3_id', 'armor4_id'].collect! {|x| eval "@actor.#{x}"}
      # Gets Equipment
      for i in 0..4
        equipment[i] = i == 0 ? $data_weapons[equipment[i]] : $data_armors[equipment[i]]
      end
      # Draws Equipment
      for i in 0..4
        draw_equipment(equipment[i], 324, 216 + i * 24, 284, 1, i)
      end
      # Gets Bio
      bio = HERO_BIO[@index]
      # Draws bio
      self.contents.font.color = normal_color
      for i in 0...bio.size
        self.contents.draw_text(36, 336 + (i + 1) * 24, contents.width - 72, 24, bio[i], 1)
      end
    # If Actor is nil
    else
      # Draws Main Information
      self.contents.font.color = system_color
      for i in 0..4
        self.contents.draw_text(192, (i + 1) * 24, 224, 24, "#{main_info[i]} ??????", 1)
      end
      # Draws Actor Stat Information
      self.contents.font.color = normal_color
      for i in 0..7
        text = i == 0 ? '???? / ????' : i == 1 ? '??? / ???' : '???'
        self.contents.draw_text(- 4, 144 + i * 24, 284, 24, text, 2)
      end
      # Gets Actor Base Equip Information
      for i in 0..2
        self.contents.draw_text(316, 144 + i * 24, 284, 24, '???', 2)
      end
      # Draws Equipment
      for i in 0..4
        draw_equipment(nil, 324, 216 + i * 24, 284, 1, i, false)
      end
      # Draws Empty Bio
      self.contents.font.color = disabled_color
      self.contents.draw_text(36, 360, contents.width - 72, 24, 'Unknown Bio', 1)
    end
  end
  #--------------------------------------------------------------------------
  # * Refresh Sprite
  #--------------------------------------------------------------------------
  def refresh_sprite
    # Clears Bitmap Area
    self.contents.fill_rect(Rect.new(0, 0, 192, 144), Color.new(0, 0, 0, 0))
    # Draws Actor Sprite
    draw_sprite(0, 0, 192, 144, @actor.character_name, @actor.character_hue, 0, @frame)
  end
  #--------------------------------------------------------------------------
  # * Update
  #--------------------------------------------------------------------------
  def update
    super
    # Checks to Refresh Sprite
    if Graphics.frame_count % 10 == 0
      @frame == 3 ? @frame = 0 : @frame += 1
      refresh_sprite unless @actor.nil?
    end
  end
  #--------------------------------------------------------------------------
  # * Draw Equipment
  #     item : item
  #     x    : draw spot x-coordinate
  #     y    : draw spot y-coordinate
  #     width : draw text width
  #     align  : text align
  #--------------------------------------------------------------------------
  def draw_equipment(item, x, y, width = 212, align = 0, type = 0, unknown = true)
    if item.nil?
      case type
      when 0  # Weapon
        bitmap = RPG::Cache.icon("001-Weapon01")
      when 1  # Shield
        bitmap = RPG::Cache.icon("009-Shield01")
      when 2  # Helmet
        bitmap = RPG::Cache.icon("010-Head01")
      when 3  # Armor
        bitmap = RPG::Cache.icon("014-Body02")
      when 4  # Accessory
        bitmap = RPG::Cache.icon("016-Accessory01")
      end
      contents.font.color, alpha = disabled_color, disabled_color.alpha
      txt = unknown ? 'Nothing' : 'Unknown'
    else
      bitmap = RPG::Cache.icon(item.icon_name)
      contents.font.color, alpha, txt = normal_color, 255, item.name
    end
    # Draws Icon
    self.contents.blt(x, y, bitmap, Rect.new(0, 0, 24, 24), alpha)
    self.contents.draw_text(x + 28, y, width - 28, 24, txt, align)
  end
  #--------------------------------------------------------------------------
  # * Draw Sprite
  #--------------------------------------------------------------------------
  def draw_sprite(x, y, w, h, name, hue, stance, frame)
    # Gets Bitmap
    bitmap = RPG::Cache.character(name, hue)
    # Bitmap Division
    cw, ch = bitmap.width / 4,  bitmap.height / 4
    # Gets Animation Offsets
    x_off, y_off = cw * frame, ch * stance
    # Draws Bitmap
    self.contents.scale_blt(Rect.new(x, y, w, h), bitmap, Rect.new(x_off, y_off, cw, ch))
  end
end

#==============================================================================
# ** Bitmap
#==============================================================================
class Bitmap
  #--------------------------------------------------------------------------
  # * Scale Blt
  #--------------------------------------------------------------------------
  def scale_blt(dest_rect, src_bitmap, src_rect, opacity = 255)
    w, h = src_rect.width, src_rect.height
    scale = [w / dest_rect.width.to_f, h / dest_rect.height.to_f].max
    ow, oh = (w / scale).to_i, (h / scale).to_i
    ox, oy = (dest_rect.width - ow) / 2, (dest_rect.height - oh) / 2
    stretch_blt(Rect.new(ox + dest_rect.x, oy + dest_rect.y, ow, oh),
      src_bitmap, src_rect )
  end
end

#==============================================================================
# ** Game_Actors
#==============================================================================
class Game_Actors
  #--------------------------------------------------------------------------
  # * Public Instance Variabeles
  #--------------------------------------------------------------------------
  attr_reader :data
end

#==============================================================================
# ** Scene_Hero_DataBase
#==============================================================================
class Scene_Hero_DataBase
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize(actor_index = 1)
    @actor_index = actor_index
  end
  #--------------------------------------------------------------------------
  # * Main Processing
  #--------------------------------------------------------------------------
  def main
    # Sets Actor
    @actor = $game_actors.data[@actor_index].nil? ? nil : @actor = $game_actors[@actor_index]
    # Creates Database Profile Window
    @actor_profile_window = Window_Clive_HeroStatus.new(@actor, @actor_index)
    # Draws Blank Sprites if Actor isn't in you actors database
    if @actor.nil?
      # Starts Frame Count
      @frame = 0
      # Creates Actor Character Sprite
      @actor_c_sprite = Sprite.new
        @actor_c_sprite.x, @actor_c_sprite.y = 16, 16
        @actor_c_sprite.z, @actor_c_sprite.opacity = 999, 160
      # Refreshes Sprite
      refresh_character_sprite
      # Creates Actor Battle Sprite
      @actor_b_sprite = Sprite.new
        @actor_b_sprite.x, @actor_b_sprite.y = 416, 16
        @actor_b_sprite.z, @actor_b_sprite.opacity = 999, 160
        @actor_b_sprite.bitmap = Bitmap.new(192, 144)
        actor = $data_actors[@actor_index]
        bitmap = RPG::Cache.battler(actor.battler_name, actor.battler_hue)
        @actor_b_sprite.bitmap.scale_blt(Rect.new(0, 0, 192, 144), bitmap,
          Rect.new(0, 0, bitmap.width, bitmap.height))
        @actor_b_sprite.tone = Tone.new(- 255, - 255, - 255, 160)
    end
    # Execute transition
    Graphics.transition
    # Main loop
    while $scene == self
      # Update game screen
      Graphics.update
      # Update input information
      Input.update
      # Frame update
      update
    end
    # Prepare for transition
    Graphics.freeze
    # Dispose of Database Profile Window
    @actor_profile_window.dispose
    # Disposes nil actor sprites
    if @actor.nil?
      @actor_c_sprite.dispose
      @actor_b_sprite.dispose
    end
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    # Update Profile Window
    @actor_profile_window.update
    # If L button is pressed
    if Input.trigger?(Input::L)
      # Play Cursor SE
      $game_system.se_play($data_system.cursor_se)
      # Changes Index
      @actor_index == 1 ? @actor_index = $data_actors.size - 1 : @actor_index -= 1
      # Changes Actor
      $scene = Scene_Hero_DataBase.new(@actor_index)
    end
    # If R button is pressed
    if Input.trigger?(Input::R)
      # Play Cursor SE
      $game_system.se_play($data_system.cursor_se)
      # Changes Index
      @actor_index == $data_actors.size - 1 ? @actor_index = 1 : @actor_index += 1
      # Changes Actor
      $scene = Scene_Hero_DataBase.new(@actor_index)
    end
    # If b button is pressed
    if Input.trigger?(Input::B)
      # Play cancel SE
      $game_system.se_play($data_system.cancel_se)
      # Proceeds to Menu Screen
      $scene = Scene_Menu.new
    end
    # If nil actor
    if @actor.nil?
      # Checks to Refresh Contents
      if Graphics.frame_count % 10 == 0
        @frame == 3 ? @frame = 0 : @frame += 1
        refresh_character_sprite
      end
    end
  end
  #--------------------------------------------------------------------------
  # * Refresh Character Sprite
  #--------------------------------------------------------------------------
  def refresh_character_sprite
    # Sets Blank Bitmap
    @actor_c_sprite.bitmap = Bitmap.new(192, 144)
    # Gets Actor
    actor = $data_actors[@actor_index]
    # Gets Bitmap
    bitmap = RPG::Cache.character(actor.character_name, actor.character_hue)
    # Draws Bitmap
    @actor_c_sprite.bitmap.scale_blt(Rect.new(0, 0, 192, 144),
      bitmap,
      Rect.new(bitmap.width / 4 * @frame, 0, bitmap.width / 4, bitmap.height / 4))
    # Adjust Sprite Tone
    @actor_c_sprite.tone = Tone.new(- 255, - 255, - 255, 160)
  end
end

#--------------------------------------------------------------------------
# * End SDK Enable Test
#--------------------------------------------------------------------------
end



Features
  • Animated Characters in the window. Woot Woot!
  • Press L & R to cycle through your characters
  • You can give your characters biographies to be viewed within the scene

Instructions
Place the Script Above Main.

To setup your characters profile:
  • Find the line: HERO_BIO = {
  • Below That, have a x=>[] for each actor_id in your database (From 1 to however many actors)
  • Withing the array, have up to 3 lines of 'text', seperated by commas (['line 1', 'line 2', 'line 3'])

FAQ

How do you call the Scene?

CODE
$scene = Scene_Hero_DataBase.new


Compatibility

Is SDK Compatable & Compiant. Works with and without SDK.

Credits and Thanks

Clive for requesting it

Author's Notes

Enjoy!
}


Possibly Related Threads…
Thread Author Replies Views Last Post
  Xenosaga Information Database Nakate 0 2,118 07-26-2007, 01:00 PM
Last Post: Nakate
  Advanced Monster Database SephirothSpawn 0 2,387 11-19-2005, 01:00 PM
Last Post: SephirothSpawn



Users browsing this thread: