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.

FFXII License Board

Code:
#==============================================================================

# ** FFXII

#------------------------------------------------------------------------------

#  This module contains global variables and classes.

#==============================================================================

 

module FFXII

  #--------------------------------------------------------------------------

  # * Game_Actor

  #     AP_MAX : ability points max

  #--------------------------------------------------------------------------

  AP_MAX = 9999

  #--------------------------------------------------------------------------

  # * Game_Party

  #     ACTOR_MAX : actor max

  #--------------------------------------------------------------------------

  ACTOR_MAX = 12

  #--------------------------------------------------------------------------

  # * Sprite_AvailableLP

  #     STATUS : status bitmap

  #     AVATAR : avatar bitmap

  #--------------------------------------------------------------------------

  STATUS = RPG::Cache.picture("bar")

  def AVATAR(id)

    return RPG::Cache.picture("avatar#{id}") rescue

           RPG::Cache.picture("avatar-1")

  end

  #--------------------------------------------------------------------------

  # * Sprite_LicenseDescription

  #     HELP         : help bitmap

  #     CATEGORY     : category bitmap

  #     CATEGORY_HUE : category hue

  #     STAR         : star bitmap

  #--------------------------------------------------------------------------

  HELP = RPG::Cache.picture("Help")

  CATEGORY = RPG::Cache.picture("Category")

  CATEGORY_HUE = [90, 270, 0, 180, 0, 180, 120, 120, 240, 0, 180]

  STAR = RPG::Cache.picture("Star")

  #--------------------------------------------------------------------------

  # * Sprite_Cursor

  #     CURSOR : cursor bitmap

  #--------------------------------------------------------------------------

  CURSOR = RPG::Cache.picture("cursor")

  #--------------------------------------------------------------------------

  # * Spriteset_Board

  #     BOARD_BG             : board background

  #     TILE                 : tile bitmap

  #     ICON                 : icon bitmap

  #     TILE_XSIZE           : tile x-size

  #     TILE_YSIZE           : tile y-size

  #     TILE_AP_FONT_SIZE    : tile ap font size

  #     TILE_LEVEL_FONT_SIZE : tile level font size

  #--------------------------------------------------------------------------

  BOARD_BG = RPG::Cache.picture("parchment")

  def TILE(id)

    return RPG::Cache.picture("tile#{id}")

  end

  def ICON(type)

    return RPG::Cache.picture("#{type}")

  end

  TILE_X_SIZE = 32

  TILE_Y_SIZE = 32

  TILE_AP_FONT_SIZE = 16

  TILE_LEVEL_FONT_SIZE = 16

  #--------------------------------------------------------------------------

  # * Bitmap

  #     HIDDEN : hidden text

  #     LP     : license points text

  #--------------------------------------------------------------------------

  HIDDEN = "???"

  LP = "LP"

  #--------------------------------------------------------------------------

  # * Bitmap_MiniBoard

  #     MINIBOARD        : miniature board bitmap directory

  #     MINIBOARD_MARGIN : miniature board margin (pixels)

  #     MINI_TILE        : miniature board tile

  #     MINI_TILE_XSIZE  : miniature tile x-size

  #     MINI_TILE_YSIZE  : miniature tile y-size

  #--------------------------------------------------------------------------

  MINIBOARD = "Graphics/Pictures/minibg"

  MINIBOARD_MARGIN = 8

  def MINI_TILE(type)

    return RPG::Cache.picture("mini#{type}") rescue

           RPG::Cache.picture("mini-1")

  end

  MINI_TILE_XSIZE = 8

  MINI_TILE_YSIZE = 8

  #--------------------------------------------------------------------------

  # * Scene_Board

  #     BOARD_OX                    : board initial x-coordinate

  #     BOARD_OY                    : board initial y-coordinate 

  #     BOARD_MARGIN                : board margin (tiles)

  #     SHADOW                      : shadow sprite

  #     BLACK                       : black sprite

  #     CONFIRM_MESSAGE             : confirm window message

  #     ANIMATION                   : animation bitmap

  #     ANIMATION_HORIZONTAL_FRAMES : animation horizontal frames

  #     ANIMATION_VERTICAL_FRAMES   : animation vertical frames

  #     ANIMATION_TOTAL_FRAMES      : animation total frames

  #     ANIMATION_BLENDTYPE         : animation blend type

  #--------------------------------------------------------------------------

  BOARD_OX = 0

  BOARD_OY = 0

  BOARD_MARGIN = 3

  SHADOW = RPG::Cache.picture("shadow")

  BLACK = RPG::Cache.picture("black")

  def CONFIRM_MESSAGE(message)

    return "Obtain #{message}?"

  end

  ANIMATION = RPG::Cache.picture("Light1")

  ANIMATION_HORIZONTAL_FRAMES = 5

  ANIMATION_VERTICAL_FRAMES = 3

  ANIMATION_TOTAL_FRAMES = 15

  ANIMATION_BLENDTYPE = 1

  #--------------------------------------------------------------------------

  # * Board

  #     BOARD_NAME        : board name

  #     BOARD_ITEM        : board item

  #     BOARD_DESCRIPTION : board description

  #     BOARD_CLASS       : board class

  #--------------------------------------------------------------------------

  def BOARD_NAME(id)

    case id

    when 0

      return "No Board"

    end

    return "Board"

  end

  def BOARD_ITEM(type, value)

    case type

    when 8   # Skills

      return $data_skills[value]

    when 9   # Weapon Set

      return $data_weapons[value]

    when 10  # Armor Set

      return $data_armors[value]

    end

    return nil

  end

  def BOARD_DESCRIPTION(type, value)

    case type

    when 0   # HP

      return "Increase max HP by #{value}"

    when 1   # SP

      return "Increase max MP by #{value}"

    when 2   # Strength

      return "Increase physical attack"

    when 3   # Physical Defense

      return "Increase physical defense"

    when 4   # Intelligence

      return "Increase magick potency"

    when 5   # Magic Defense

      return "Increase magick defense"

    when 6   # Agility

      return "Increase agility"

    when 7   # Dexterity

      return "Increase dexterity"

    when 8   # Skills

      return "#{$data_skills[value].description}"

    when 9   # Weapon Set

      return "#{$data_weapons[value].description}"

    when 10  # Armor Set

      return "#{$data_armors[value].description}"

    end

    return nil

  end

  def BOARD_CLASS(type, value, level)

    case type

    when 0   # HP

      return "Max HP"

    when 1   # SP

      return "Max MP"

    when 2   # Strength

      return "Strength"

    when 3   # Physical Defense

      return "Physical Defense"

    when 4   # Intelligence

      return "Intelligence"

    when 5   # Magic Defense

      return "Magic Defense"

    when 6   # Agility

      return "Agility"

    when 7   # Dexterity

      return "Dexterity"

    when 8   # Skills

      if level == -1

        return "#{$data_skills[value].name}"

      elsif value >= 0 and value <= 18

        return "White Magick #{level}"

      elsif value > 19 and value <= 36

        return "Black Magick #{level}"

      elsif value > 36 and value <= 51

        return "Time Magick #{level}"

      elsif value > 51 and value <= 66

        return "Green Magick #{level}"

      elsif value > 66 and value <= 81

        return "Arcane Magick #{level}"

      else

        return "#{$data_skills[value].name}"

      end

    when 9   # Weapon Set

      if level == -1

        return "#{$data_weapons[value].name}"

      elsif value >= 0 and value <= 19

        return "Swords #{level}"

      elsif value > 19 and value <= 30

        return "Daggers #{level}"

      elsif value > 30 and value <= 42

        return "Axes & Hammers #{level}"

      elsif value > 42 and value <= 51

        return "Maces #{level}"

      elsif value > 51 and value <= 57

        return "Measures #{level}"

      elsif value > 57 and value <= 67

        return "Greatswords #{level}"

      elsif value > 67 and value <= 77

        return "Katanas #{level}"

      elsif value > 77 and value <= 84

        return "Ninja Swords #{level}"

      elsif value > 84 and value <= 96

        return "Spears #{level}"

      elsif value > 96 and value <= 108

        return "Poles #{level}"

      elsif value > 108 and value <= 116

        return "Rods #{level}"

      elsif value > 116 and value <= 126

        return "Staves #{level}"

      elsif value > 126 and value <= 140

        return "Bows #{level}"

      elsif value > 140 and value <= 147

        return "Crossbows #{level}"

      elsif value > 147 and value <= 158

        return "Guns #{level}"

      elsif value > 158 and value <= 163

        return "Hand-Bombs #{level}"

      else

        return "#{$data_weapons[value].name}"

      end

    when 10  # Armor Set

      return "#{$data_armors[value].name}"

    end

    return nil

  end

end

 

Code:
#==============================================================================

# ** Boards

#------------------------------------------------------------------------------

#  This module contains global variables and classes.

#==============================================================================

 

module Boards

  #--------------------------------------------------------------------------

  # * Scene_EditBoard

  #     NEW_BOARD_XSIZE : new board x-size

  #     NEW_BOARD_YSIZE : new board y-size

  #--------------------------------------------------------------------------

  NEW_BOARD_XSIZE = 24

  NEW_BOARD_YSIZE = 24

  #--------------------------------------------------------------------------

  # * Creates an empty board

  #--------------------------------------------------------------------------

  def new_board(xsize, ysize)

    $data_boards = get_boards

    board = Table.new(xsize, ysize, 9)

    for x in 0...board.xsize

      for y in 0...board.ysize

        for z in 0...board.zsize

          case z

          when 0  # ACTIVATED

            board[x, y, z] = 0

          when 1  # VISIBLE

            board[x, y, z] = 0

          when 2  # AP

            board[x, y, z] = 0

          when 3  # TYPE

            board[x, y, z] = -1

          when 4  # OBJECT 1 VALUE

            board[x, y, z] = 0

          when 5  # OBJECT 2 VALUE

            board[x, y, z] = 0

          when 6  # OBJECT 3 VALUE

            board[x, y, z] = 0

          when 7  # OBJECT 4 VALUE

            board[x, y, z] = 0

          when 8  # LEVEL

            board[x, y, z] = -1

          end

        end

      end

    end

    $data_boards.push(board)

    save_boards($data_boards)

  end

  #--------------------------------------------------------------------------

  # * Deletes a board

  #     index : index

  #--------------------------------------------------------------------------

  def delete_board(index)

    $data_boards = get_boards

    $data_boards.delete_at(index)

    save_boards($data_boards)

  end

  #--------------------------------------------------------------------------

  # * Save boards

  #     board : board

  #--------------------------------------------------------------------------

  def save_boards(boards)

    save_data(boards, "Data/Boards.rxdata")

  end

  #--------------------------------------------------------------------------

  # * Get boards

  #--------------------------------------------------------------------------

  def get_boards

    $data_boards = load_data("Data/Boards.rxdata") rescue

    $data_boards = []

    return $data_boards

  end

end

 

Code:
#==============================================================================

# ** List

#------------------------------------------------------------------------------

#  This module contains global variables and classes.

#==============================================================================

 

module List

  #--------------------------------------------------------------------------

  # * Create item lists

  #--------------------------------------------------------------------------

  def self.item_list

    # Load database

    $data_skills  = load_data("Data/Skills.rxdata")

    $data_weapons = load_data("Data/Weapons.rxdata")

    $data_armors  = load_data("Data/Armors.rxdata")

    # Create a new file and write to it   

    File.open("README.txt", "wb") do |file|   

      # Add skills

      for i in 1...$data_skills.size

        item = $data_skills[i]

        file.print("#{item.id}\t")

        file.print("#{item.name}\t")

        file.puts("#{item.description}")

        end

      # Add weapons

      for i in 1...$data_weapons.size

        item = $data_weapons[i]

        file.print("#{item.id}\t")

        file.print("#{item.name}\t")

        file.puts("#{item.description}")

      end

      # Add armors

      for i in 1...$data_armors.size

        item = $data_armors[i]

        file.print("#{item.id}\t")

        file.print("#{item.name}\t")

        file.puts("#{item.description}")

      end

    end

  end

end

 

Code:
#==============================================================================

# ** 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

  #--------------------------------------------------------------------------

  # * Invariables

  #--------------------------------------------------------------------------

  include FFXII                           # FFXII module

  #--------------------------------------------------------------------------

  # * Public Instance Variables

  #--------------------------------------------------------------------------

  attr_reader   :name                     # name

  attr_reader   :character_name           # character file name

  attr_reader   :character_hue            # character hue

  attr_reader   :class_id                 # class ID

  attr_reader   :weapon_id                # weapon ID

  attr_reader   :armor1_id                # shield ID

  attr_reader   :armor2_id                # helmet ID

  attr_reader   :armor3_id                # body armor ID

  attr_reader   :armor4_id                # accessory ID

  attr_reader   :board                    # board ID

  attr_reader   :level                    # level

  attr_reader   :exp                      # experience

  attr_reader   :ap                       # ability points

  attr_reader   :skills                   # skills

  #--------------------------------------------------------------------------

  # * Object Initialization

  #     actor_id : actor ID

  #--------------------------------------------------------------------------

  def initialize(actor_id)

    super()

    setup(actor_id)

  end

  #--------------------------------------------------------------------------

  # * Setup

  #     actor_id : actor ID

  #--------------------------------------------------------------------------

  def setup(actor_id)

    actor = $data_actors[actor_id]

    @actor_id = actor_id

    @name = actor.name

    @character_name = actor.character_name

    @character_hue = actor.character_hue

    @battler_name = actor.battler_name

    @battler_hue = actor.battler_hue

    @class_id = actor.class_id

    @weapon_id = actor.weapon_id

    @armor1_id = actor.armor1_id

    @armor2_id = actor.armor2_id

    @armor3_id = actor.armor3_id

    @armor4_id = actor.armor4_id

    @board   = Board.new(0)

    @level = actor.initial_level

    @exp_list = Array.new(101)

    make_exp_list

    @exp = @exp_list[@level]

    @ap = 0

    @skills = []

    @hp = maxhp

    @sp = maxsp

    @states = []

    @states_turn = {}

    @maxhp_plus = 0

    @maxsp_plus = 0

    @str_plus = 0

    @dex_plus = 0

    @agi_plus = 0

    @int_plus = 0

    # Learn skill

    for i in 1..@level

      for j in $data_classes[@class_id].learnings

        if j.level == i

          learn_skill(j.skill_id)

        end

      end

    end

    # Update auto state

    update_auto_state(nil, $data_armors[@armor1_id])

    update_auto_state(nil, $data_armors[@armor2_id])

    update_auto_state(nil, $data_armors[@armor3_id])

    update_auto_state(nil, $data_armors[@armor4_id])

  end

  #--------------------------------------------------------------------------

  # * Get Actor ID

  #--------------------------------------------------------------------------

  def id

    return @actor_id

  end

  #--------------------------------------------------------------------------

  # * Get Index

  #--------------------------------------------------------------------------

  def index

    return $game_party.actors.index(self)

  end

  #--------------------------------------------------------------------------

  # * Calculate EXP

  #--------------------------------------------------------------------------

  def make_exp_list

    actor = $data_actors[@actor_id]

    @exp_list[1] = 0

    pow_i = 2.4 + actor.exp_inflation / 100.0

    for i in 2..100

      if i > actor.final_level

        @exp_list[i] = 0

      else

        n = actor.exp_basis * ((i + 3) ** pow_i) / (5 ** pow_i)

        @exp_list[i] = @exp_list[i-1] + Integer(n)

      end

    end

  end

  #--------------------------------------------------------------------------

  # * Get Element Revision Value

  #     element_id : element ID

  #--------------------------------------------------------------------------

  def element_rate(element_id)

    # Get values corresponding to element effectiveness

    table = [0,200,150,100,50,0,-100]

    result = table[$data_classes[@class_id].element_ranks[element_id]]

    # If this element is protected by armor, then it's reduced by half

    for i in [@armor1_id, @armor2_id, @armor3_id, @armor4_id]

      armor = $data_armors[i]

      if armor != nil and armor.guard_element_set.include?(element_id)

        result /= 2

      end

    end

    # If this element is protected by states, then it's reduced by half

    for i in @states

      if $data_states[i].guard_element_set.include?(element_id)

        result /= 2

      end

    end

    # End Method

    return result

  end

  #--------------------------------------------------------------------------

  # * Get State Effectiveness

  #--------------------------------------------------------------------------

  def state_ranks

    return $data_classes[@class_id].state_ranks

  end

  #--------------------------------------------------------------------------

  # * Determine State Guard

  #     state_id : state ID

  #--------------------------------------------------------------------------

  def state_guard?(state_id)

    for i in [@armor1_id, @armor2_id, @armor3_id, @armor4_id]

      armor = $data_armors[i]

      if armor != nil

        if armor.guard_state_set.include?(state_id)

          return true

        end

      end

    end

    return false

  end

  #--------------------------------------------------------------------------

  # * Get Normal Attack Element

  #--------------------------------------------------------------------------

  def element_set

    weapon = $data_weapons[@weapon_id]

    return weapon != nil ? weapon.element_set : []

  end

  #--------------------------------------------------------------------------

  # * Get Normal Attack State Change (+)

  #--------------------------------------------------------------------------

  def plus_state_set

    weapon = $data_weapons[@weapon_id]

    return weapon != nil ? weapon.plus_state_set : []

  end

  #--------------------------------------------------------------------------

  # * Get Normal Attack State Change (-)

  #--------------------------------------------------------------------------

  def minus_state_set

    weapon = $data_weapons[@weapon_id]

    return weapon != nil ? weapon.minus_state_set : []

  end

  #--------------------------------------------------------------------------

  # * Get AP

  #--------------------------------------------------------------------------

  def ap=(ap)

    @ap = [[ap, 0].max, AP_MAX].min

  end

  #--------------------------------------------------------------------------

  # * Get Maximum HP

  #--------------------------------------------------------------------------

  def maxhp

    n = [[base_maxhp + @maxhp_plus, 1].max, 9999].min

    for i in @states

      n *= $data_states[i].maxhp_rate / 100.0

    end

    n += @board.hp

    n = [[Integer(n), 1].max, 9999].min

    return n

  end

  #--------------------------------------------------------------------------

  # * Get Maximum SP

  #--------------------------------------------------------------------------

  def maxsp

    n = [[base_maxsp + @maxsp_plus, 0].max, 999].min

    for i in @states

      n *= $data_states[i].maxsp_rate / 100.0

    end

    n += @board.sp

    n = [[Integer(n), 0].max, 999].min

    return n

  end

  #--------------------------------------------------------------------------

  # * Get Strength

  #--------------------------------------------------------------------------

  def str

    n = [[base_str + @str_plus, 1].max, 99].min

    for i in @states

      n *= $data_states[i].str_rate / 100.0

    end

    n += @board.str

    n = [[Integer(n), 1].max, 99].min

    return n

  end

  #--------------------------------------------------------------------------

  # * Get Intelligence

  #--------------------------------------------------------------------------

  def int

    n = [[base_int + @int_plus, 1].max, 99].min

    for i in @states

      n *= $data_states[i].int_rate / 100.0

    end

    n += @board.int

    n = [[Integer(n), 1].max, 99].min

    return n

  end

  #--------------------------------------------------------------------------

  # * Get Dexterity

  #--------------------------------------------------------------------------

  def dex

    n = [[base_dex + @dex_plus, 1].max, 99].min

    for i in @states

      n *= $data_states[i].dex_rate / 100.0

    end

    n += @board.dex

    n = [[Integer(n), 1].max, 99].min

    return n

  end

  #--------------------------------------------------------------------------

  # * Get Agility

  #--------------------------------------------------------------------------

  def agi

    n = [[base_agi + @agi_plus, 1].max, 99].min

    for i in @states

      n *= $data_states[i].agi_rate / 100.0

    end

    n += @board.agi

    n = [[Integer(n), 1].max, 99].min

    return n

  end

  #--------------------------------------------------------------------------

  # * Get Physical Defense

  #--------------------------------------------------------------------------

  def pdef

    n = [[base_pdef, 0].max, 999].min

    for i in @states

      n *= $data_states[i].pdef_rate / 100.0

    end

    n += @board.pdef

    n = [[Integer(n), 0].max, 999].min

    return n

  end

  #--------------------------------------------------------------------------

  # * Get Magic Defense

  #--------------------------------------------------------------------------

  def mdef

    n = [[base_mdef, 0].max, 999].min

    for i in @states

      n *= $data_states[i].mdef_rate / 100.0

    end

    n += @board.mdef

    n = [[Integer(n), 0].max, 999].min

    return n

  end

  #--------------------------------------------------------------------------

  # * Get Basic Maximum HP

  #--------------------------------------------------------------------------

  def base_maxhp

    return $data_actors[@actor_id].parameters[0, @level]

  end

  #--------------------------------------------------------------------------

  # * Get Basic Maximum SP

  #--------------------------------------------------------------------------

  def base_maxsp

    return $data_actors[@actor_id].parameters[1, @level]

  end

  #--------------------------------------------------------------------------

  # * Get Basic Strength

  #--------------------------------------------------------------------------

  def base_str

    n = $data_actors[@actor_id].parameters[2, @level]

    weapon = $data_weapons[@weapon_id]

    armor1 = $data_armors[@armor1_id]

    armor2 = $data_armors[@armor2_id]

    armor3 = $data_armors[@armor3_id]

    armor4 = $data_armors[@armor4_id]

    n += weapon != nil ? weapon.str_plus : 0

    n += armor1 != nil ? armor1.str_plus : 0

    n += armor2 != nil ? armor2.str_plus : 0

    n += armor3 != nil ? armor3.str_plus : 0

    n += armor4 != nil ? armor4.str_plus : 0

    return [[n, 1].max, 999].min

  end

  #--------------------------------------------------------------------------

  # * Get Basic Dexterity

  #--------------------------------------------------------------------------

  def base_dex

    n = $data_actors[@actor_id].parameters[3, @level]

    weapon = $data_weapons[@weapon_id]

    armor1 = $data_armors[@armor1_id]

    armor2 = $data_armors[@armor2_id]

    armor3 = $data_armors[@armor3_id]

    armor4 = $data_armors[@armor4_id]

    n += weapon != nil ? weapon.dex_plus : 0

    n += armor1 != nil ? armor1.dex_plus : 0

    n += armor2 != nil ? armor2.dex_plus : 0

    n += armor3 != nil ? armor3.dex_plus : 0

    n += armor4 != nil ? armor4.dex_plus : 0

    return [[n, 1].max, 999].min

  end

  #--------------------------------------------------------------------------

  # * Get Basic Agility

  #--------------------------------------------------------------------------

  def base_agi

    n = $data_actors[@actor_id].parameters[4, @level]

    weapon = $data_weapons[@weapon_id]

    armor1 = $data_armors[@armor1_id]

    armor2 = $data_armors[@armor2_id]

    armor3 = $data_armors[@armor3_id]

    armor4 = $data_armors[@armor4_id]

    n += weapon != nil ? weapon.agi_plus : 0

    n += armor1 != nil ? armor1.agi_plus : 0

    n += armor2 != nil ? armor2.agi_plus : 0

    n += armor3 != nil ? armor3.agi_plus : 0

    n += armor4 != nil ? armor4.agi_plus : 0

    return [[n, 1].max, 999].min

  end

  #--------------------------------------------------------------------------

  # * Get Basic Intelligence

  #--------------------------------------------------------------------------

  def base_int

    n = $data_actors[@actor_id].parameters[5, @level]

    weapon = $data_weapons[@weapon_id]

    armor1 = $data_armors[@armor1_id]

    armor2 = $data_armors[@armor2_id]

    armor3 = $data_armors[@armor3_id]

    armor4 = $data_armors[@armor4_id]

    n += weapon != nil ? weapon.int_plus : 0

    n += armor1 != nil ? armor1.int_plus : 0

    n += armor2 != nil ? armor2.int_plus : 0

    n += armor3 != nil ? armor3.int_plus : 0

    n += armor4 != nil ? armor4.int_plus : 0

    return [[n, 1].max, 999].min

  end

  #--------------------------------------------------------------------------

  # * Get Basic Attack Power

  #--------------------------------------------------------------------------

  def base_atk

    weapon = $data_weapons[@weapon_id]

    return weapon != nil ? weapon.atk : 0

  end

  #--------------------------------------------------------------------------

  # * Get Basic Physical Defense

  #--------------------------------------------------------------------------

  def base_pdef

    weapon = $data_weapons[@weapon_id]

    armor1 = $data_armors[@armor1_id]

    armor2 = $data_armors[@armor2_id]

    armor3 = $data_armors[@armor3_id]

    armor4 = $data_armors[@armor4_id]

    pdef1 = weapon != nil ? weapon.pdef : 0

    pdef2 = armor1 != nil ? armor1.pdef : 0

    pdef3 = armor2 != nil ? armor2.pdef : 0

    pdef4 = armor3 != nil ? armor3.pdef : 0

    pdef5 = armor4 != nil ? armor4.pdef : 0

    return pdef1 + pdef2 + pdef3 + pdef4 + pdef5

  end

  #--------------------------------------------------------------------------

  # * Get Basic Magic Defense

  #--------------------------------------------------------------------------

  def base_mdef

    weapon = $data_weapons[@weapon_id]

    armor1 = $data_armors[@armor1_id]

    armor2 = $data_armors[@armor2_id]

    armor3 = $data_armors[@armor3_id]

    armor4 = $data_armors[@armor4_id]

    mdef1 = weapon != nil ? weapon.mdef : 0

    mdef2 = armor1 != nil ? armor1.mdef : 0

    mdef3 = armor2 != nil ? armor2.mdef : 0

    mdef4 = armor3 != nil ? armor3.mdef : 0

    mdef5 = armor4 != nil ? armor4.mdef : 0

    return mdef1 + mdef2 + mdef3 + mdef4 + mdef5

  end

  #--------------------------------------------------------------------------

  # * Get Basic Evasion Correction

  #--------------------------------------------------------------------------

  def base_eva

    armor1 = $data_armors[@armor1_id]

    armor2 = $data_armors[@armor2_id]

    armor3 = $data_armors[@armor3_id]

    armor4 = $data_armors[@armor4_id]

    eva1 = armor1 != nil ? armor1.eva : 0

    eva2 = armor2 != nil ? armor2.eva : 0

    eva3 = armor3 != nil ? armor3.eva : 0

    eva4 = armor4 != nil ? armor4.eva : 0

    return eva1 + eva2 + eva3 + eva4

  end

  #--------------------------------------------------------------------------

  # * Get Offensive Animation ID for Normal Attacks

  #--------------------------------------------------------------------------

  def animation1_id

    weapon = $data_weapons[@weapon_id]

    return weapon != nil ? weapon.animation1_id : 0

  end

  #--------------------------------------------------------------------------

  # * Get Target Animation ID for Normal Attacks

  #--------------------------------------------------------------------------

  def animation2_id

    weapon = $data_weapons[@weapon_id]

    return weapon != nil ? weapon.animation2_id : 0

  end

  #--------------------------------------------------------------------------

  # * Get Class Name

  #--------------------------------------------------------------------------

  def class_name

    return $data_classes[@class_id].name

  end

  #--------------------------------------------------------------------------

  # * Get EXP String

  #--------------------------------------------------------------------------

  def exp_s

    return @exp_list[@level+1] > 0 ? @exp.to_s : "-------"

  end

  #--------------------------------------------------------------------------

  # * Get Next Level EXP String

  #--------------------------------------------------------------------------

  def next_exp_s

    return @exp_list[@level+1] > 0 ? @exp_list[@level+1].to_s : "-------"

  end

  #--------------------------------------------------------------------------

  # * Get Until Next Level EXP String

  #--------------------------------------------------------------------------

  def next_rest_exp_s

    return @exp_list[@level+1] > 0 ?

      (@exp_list[@level+1] - @exp).to_s : "-------"

  end

  #--------------------------------------------------------------------------

  # * Update Auto State

  #     old_armor : unequipped armor

  #     new_armor : equipped armor

  #--------------------------------------------------------------------------

  def update_auto_state(old_armor, new_armor)

    # Forcefully remove unequipped armor's auto state

    if old_armor != nil and old_armor.auto_state_id != 0

      remove_state(old_armor.auto_state_id, true)

    end

    # Forcefully add unequipped armor's auto state

    if new_armor != nil and new_armor.auto_state_id != 0

      add_state(new_armor.auto_state_id, true)

    end

  end

  #--------------------------------------------------------------------------

  # * Determine Fixed Equipment

  #     equip_type : type of equipment

  #--------------------------------------------------------------------------

  def equip_fix?(equip_type)

    case equip_type

    when 0  # Weapon

      return $data_actors[@actor_id].weapon_fix

    when 1  # Shield

      return $data_actors[@actor_id].armor1_fix

    when 2  # Head

      return $data_actors[@actor_id].armor2_fix

    when 3  # Body

      return $data_actors[@actor_id].armor3_fix

    when 4  # Accessory

      return $data_actors[@actor_id].armor4_fix

    end

    return false

  end

  #--------------------------------------------------------------------------

  # * Change Equipment

  #     equip_type : type of equipment

  #     id    : weapon or armor ID (If 0, remove equipment)

  #--------------------------------------------------------------------------

  def equip(equip_type, id)

    case equip_type

    when 0  # Weapon

      if id == 0 or $game_party.weapon_number(id) > 0

        $game_party.gain_weapon(@weapon_id, 1)

        @weapon_id = id

        $game_party.lose_weapon(id, 1)

      end

    when 1  # Shield

      if id == 0 or $game_party.armor_number(id) > 0

        update_auto_state($data_armors[@armor1_id], $data_armors[id])

        $game_party.gain_armor(@armor1_id, 1)

        @armor1_id = id

        $game_party.lose_armor(id, 1)

      end

    when 2  # Head

      if id == 0 or $game_party.armor_number(id) > 0

        update_auto_state($data_armors[@armor2_id], $data_armors[id])

        $game_party.gain_armor(@armor2_id, 1)

        @armor2_id = id

        $game_party.lose_armor(id, 1)

      end

    when 3  # Body

      if id == 0 or $game_party.armor_number(id) > 0

        update_auto_state($data_armors[@armor3_id], $data_armors[id])

        $game_party.gain_armor(@armor3_id, 1)

        @armor3_id = id

        $game_party.lose_armor(id, 1)

      end

    when 4  # Accessory

      if id == 0 or $game_party.armor_number(id) > 0

        update_auto_state($data_armors[@armor4_id], $data_armors[id])

        $game_party.gain_armor(@armor4_id, 1)

        @armor4_id = id

        $game_party.lose_armor(id, 1)

      end

    end

  end

  #--------------------------------------------------------------------------

  # * Determine if Equippable

  #     item : item

  #--------------------------------------------------------------------------

  def equippable?(item)

    # If weapon

    if item.is_a?(RPG::Weapon)

      weapon_set = $data_classes[@class_id].weapon_set

      weapon_set = @board.weapon_set | weapon_set

      # If included among equippable weapons in current class and board

      if weapon_set.include?(item.id)

        return true

      end

    end

    # If armor

    if item.is_a?(RPG::Armor)

      armor_set = $data_classes[@class_id].armor_set

      armor_set = @board.armor_set | armor_set

      # If included among equippable armor in current class and board

      if armor_set.include?(item.id)

        return true

      end

    end

    return false

  end

  #--------------------------------------------------------------------------

  # * Change EXP

  #     exp : new EXP

  #--------------------------------------------------------------------------

  def exp=(exp)

    @exp = [[exp, 9999999].min, 0].max

    # Level up

    while @exp >= @exp_list[@level+1] and @exp_list[@level+1] > 0

      @level += 1

      # Learn skill

      for j in $data_classes[@class_id].learnings

        if j.level == @level

          learn_skill(j.skill_id)

        end

      end

    end

    # Level down

    while @exp < @exp_list[@level]

      @level -= 1

    end

    # Correction if exceeding current max HP and max SP

    @hp = [@hp, self.maxhp].min

    @sp = [@sp, self.maxsp].min

  end

  #--------------------------------------------------------------------------

  # * Change Level

  #     level : new level

  #--------------------------------------------------------------------------

  def level=(level)

    # Check up and down limits

    level = [[level, $data_actors[@actor_id].final_level].min, 1].max

    # Change EXP

    self.exp = @exp_list[level]

  end

  #--------------------------------------------------------------------------

  # * Skills

  #--------------------------------------------------------------------------

  def skills

    @board.skills.sort!

    skills = @board.skills | @skills

    return skills

  end

  #--------------------------------------------------------------------------

  # * Learn Skill

  #     skill_id : skill ID

  #--------------------------------------------------------------------------

  def learn_skill(skill_id)

    if skill_id > 0 and not skill_learn?(skill_id)

      @skills.push(skill_id)

      @skills.sort!

    end

  end

  #--------------------------------------------------------------------------

  # * Forget Skill

  #     skill_id : skill ID

  #--------------------------------------------------------------------------

  def forget_skill(skill_id)

    @skills.delete(skill_id)

  end

  #--------------------------------------------------------------------------

  # * Determine if Finished Learning Skill

  #     skill_id : skill ID

  #--------------------------------------------------------------------------

  def skill_learn?(skill_id)

    return (@skills + @board.skills).include?(skill_id)

  end

  #--------------------------------------------------------------------------

  # * Determine if Skill can be Used

  #     skill_id : skill ID

  #--------------------------------------------------------------------------

  def skill_can_use?(skill_id)

    if not skill_learn?(skill_id)

      return false

    end

    return super

  end

  #--------------------------------------------------------------------------

  # * Change Name

  #     name : new name

  #--------------------------------------------------------------------------

  def name=(name)

    @name = name

  end

  #--------------------------------------------------------------------------

  # * Change Class ID

  #     class_id : new class ID

  #--------------------------------------------------------------------------

  def class_id=(class_id)

    if $data_classes[class_id] != nil

      @class_id = class_id

      # Remove items that are no longer equippable

      unless equippable?($data_weapons[@weapon_id])

        equip(0, 0)

      end

      unless equippable?($data_armors[@armor1_id])

        equip(1, 0)

      end

      unless equippable?($data_armors[@armor2_id])

        equip(2, 0)

      end

      unless equippable?($data_armors[@armor3_id])

        equip(3, 0)

      end

      unless equippable?($data_armors[@armor4_id])

        equip(4, 0)

      end

    end

  end

  #--------------------------------------------------------------------------

  # * Change Graphics

  #     character_name : new character file name

  #     character_hue  : new character hue

  #     battler_name   : new battler file name

  #     battler_hue    : new battler hue

  #--------------------------------------------------------------------------

  def set_graphic(character_name, character_hue, battler_name, battler_hue)

    @character_name = character_name

    @character_hue = character_hue

    @battler_name = battler_name

    @battler_hue = battler_hue

  end

  #--------------------------------------------------------------------------

  # * Get Battle Screen X-Coordinate

  #--------------------------------------------------------------------------

  def screen_x

    # Return after calculating x-coordinate by order of members in party

    if self.index != nil

      return self.index * 160 + 80

    else

      return 0

    end

  end

  #--------------------------------------------------------------------------

  # * Get Battle Screen Y-Coordinate

  #--------------------------------------------------------------------------

  def screen_y

    return 464

  end

  #--------------------------------------------------------------------------

  # * Get Battle Screen Z-Coordinate

  #--------------------------------------------------------------------------

  def screen_z

    # Return after calculating z-coordinate by order of members in party

    if self.index != nil

      return 4 - self.index

    else

      return 0

    end

  end

end

 

Code:
#==============================================================================

# ** Game_Party

#------------------------------------------------------------------------------

#  This class handles the party. It includes information on amount of gold 

#  and items. Refer to "$game_party" for the instance of this class.

#==============================================================================

 

class Game_Party

  #--------------------------------------------------------------------------

  # * Invariables

  #--------------------------------------------------------------------------

  include FFXII                           # FFXII module

  #--------------------------------------------------------------------------

  # * Public Instance Variables

  #--------------------------------------------------------------------------

  attr_reader   :actors                   # actors

  attr_reader   :gold                     # amount of gold

  attr_reader   :steps                    # number of steps

  #--------------------------------------------------------------------------

  # * Add an Actor

  #     actor_id : actor ID

  #--------------------------------------------------------------------------

  def add_actor(actor_id)

    # Get actor

    actor = $game_actors[actor_id]

    # If the party has less than 4 members and this actor is not in the party

    if @actors.size < ACTOR_MAX and not @actors.include?(actor)

      # Add actor

      @actors.push(actor)

      # Refresh player

      $game_player.refresh

    end

  end

end

 

Code:
#==============================================================================

# ** Animated_Sprite

#------------------------------------------------------------------------------

#  This sprite is used to display an animated image. It observes a superclass

#  and automatically changes sprite conditions.

#==============================================================================

 

class Animated_Sprite < RPG::Sprite

  #--------------------------------------------------------------------------

  # * Public Instance Variables

  #--------------------------------------------------------------------------

  attr_reader   :frames                   # frames total

  attr_reader   :bitmap                   # bitmap

  attr_accessor :frame                    # frame ID

  attr_accessor :wait                     # frame delay

  #--------------------------------------------------------------------------

  # * Object Initialization

  #     bitmap   : bitmap

  #     x        : draw spot x-coordinate

  #     y        : draw spot y-coordinate

  #     columns  : columns

  #     rows     : rows

  #     wait     : frame delay

  #     viewport : viewport

  #--------------------------------------------------------------------------

  def initialize(bitmap, x, y, columns, rows, frames,

                 blend_type = 0, wait = 1, viewport = nil)

    super(viewport)

    @bitmap = bitmap

    @ox, @oy = x, y

    @columns = columns

    @rows = rows

    @frames = frames

    self.blend_type = blend_type

    @wait = wait

    @counter = wait

    @frame = 0

    update

  end

  #--------------------------------------------------------------------------

  # * Frame Update

  #--------------------------------------------------------------------------

  def update

    super

    if ready?

      self.bitmap = @bitmap

      self.x = @ox

      self.y = @oy

      cw = @bitmap.width / @columns

      ch = @bitmap.height / @rows

      self.src_rect.set(0, 0, cw, ch)

      sx = (@frame % @columns) * cw

      sy = (@frame / @columns) * ch

      self.src_rect.set(sx, sy, cw, ch)

      @counter = 0

    else

      @counter += 1

    end

  end

  #--------------------------------------------------------------------------

  # * Ready?

  #--------------------------------------------------------------------------

  def ready?

    return @counter >= @wait

  end

end

 

Code:
#==============================================================================

# ** Dynamic_Sprite

#------------------------------------------------------------------------------

#  This sprite is used to display a moving image. It observes a superclass

#  and automatically changes sprite conditions.

#==============================================================================

 

class Dynamic_Sprite < RPG::Sprite

  #--------------------------------------------------------------------------

  # * Public Instance Variables

  #--------------------------------------------------------------------------

  attr_accessor :true_x                   # true x

  attr_accessor :true_y                   # true y

  attr_accessor :true_zoom_x              # true zoom x

  attr_accessor :true_zoom_y              # true zoom y

  attr_accessor :true_opacity             # true opacity

  attr_accessor :speed                    # speed

  #--------------------------------------------------------------------------

  # * Object Initialization

  #     viewport : viewport

  #--------------------------------------------------------------------------

  def initialize(viewport = nil)

    super(viewport)

    @true_x = 0

    @true_y = 0

    @true_zoom_x = 1.00

    @true_zoom_y = 1.00

    @true_opacity = 255

    @speed = 5

  end

  #--------------------------------------------------------------------------

  # * Frame Update

  #--------------------------------------------------------------------------

  def update

    super

    if self.y < @true_y

      n = (@true_y - self.y) / @speed

      n = 1 if n == 0

      self.y += n

    elsif self.y > @true_y

      n = (self.y - @true_y) / @speed

      n = 1 if n == 0

      self.y -= n

    end

    if self.x < @true_x

      n = (@true_x - self.x) / @speed

      n = 1 if n == 0

      self.x += n

    elsif self.x > @true_x

      n = (self.x - @true_x) / @speed

      n = 1 if n == 0

      self.x -= n

    end

    if self.zoom_y < @true_zoom_y

      n = (@true_zoom_y - self.zoom_y) / @speed

      n = 1 if n == 0

      self.zoom_y += n

    elsif self.zoom_y > @true_zoom_y

      n = (self.zoom_y - @true_zoom_y) / @speed

      n = 1 if n == 0

      self.zoom_y -= n

    end

    if self.zoom_x < @true_zoom_x

      n = (@true_zoom_x - self.zoom_x) / @speed

      n = 1 if n == 0

      self.zoom_x += n

    elsif self.zoom_x > @true_zoom_x

      n = (self.zoom_x - @true_zoom_x) / @speed

      n = 1 if n == 0

      self.zoom_x -= n

    end

    if self.opacity < @true_opacity

      n = (@true_opacity - self.opacity) / @speed

      n = 1 if n == 0

      self.opacity += n

    elsif self.opacity > @true_opacity

      n = (self.opacity - @true_opacity) / @speed

      n = 1 if n == 0

      self.opacity -= n

    end

  end

end

 

Code:
#==============================================================================

# ** Sprite_AvailableLP

#------------------------------------------------------------------------------

#  This sprite is used to display available LP. It observes the Scene_Board

#  class and automatically changes sprite conditions.

#==============================================================================

 

class Sprite_AvailableLP < RPG::Sprite

  #--------------------------------------------------------------------------

  # * Invariables

  #--------------------------------------------------------------------------

  include FFXII                           # FFXII module

  #--------------------------------------------------------------------------

  # * Object Initialization

  #     actor    : actor

  #     board    : board

  #     viewport : viewport

  #--------------------------------------------------------------------------

  def initialize(actor, board, viewport = nil)

    super(viewport)

    self.bitmap = STATUS.dup

    @actor = actor

    @board = board

    @ap = @actor.ap

    self.y = 15

    refresh

  end

  #--------------------------------------------------------------------------

  # * Refresh

  #--------------------------------------------------------------------------

  def refresh

    self.bitmap.clear

    self.bitmap = STATUS.dup

    self.bitmap.draw_actor_name(  @actor, 72, -5)

    self.bitmap.draw_actor_ap(    @actor, 71, 15)

    self.bitmap.draw_actor_avatar(@actor, 12, 0)

  end

  #--------------------------------------------------------------------------

  # * Frame Update

  #--------------------------------------------------------------------------

  def update

    super

    if @actor.ap != @ap

      @ap = @actor.ap

      refresh

    end

  end

end

 

Code:
#==============================================================================

# ** Sprite_BoardHelp

#------------------------------------------------------------------------------

#  This sprite is used to display board help. It observes the Scene_Board

#  class and automatically changes sprite conditions.

#==============================================================================

 

class Sprite_LicenseDescription < Dynamic_Sprite

  #--------------------------------------------------------------------------

  # * Invariables

  #--------------------------------------------------------------------------

  include FFXII                           # FFXII module

  #--------------------------------------------------------------------------

  # * Object Initialization

  #     cursor    : cursor

  #     board     : board

  #     edit_mode : edit mode ON

  #     viewport  : viewport

  #--------------------------------------------------------------------------

  def initialize(cursor, board, edit_mode = false, viewport = nil)

    super(viewport)

    self.bitmap = HELP.dup

    @cursor = cursor

    @board = board

    @edit_mode = edit_mode

    @ox, @oy = @cursor.tile_x, @cursor.tile_y

    self.y = 370

    self.opacity = 0

    refresh

  end

  #--------------------------------------------------------------------------

  # * Refresh

  #--------------------------------------------------------------------------

  def refresh

    self.bitmap.clear

    self.bitmap = HELP.dup

    x, y = @cursor.tile_x, @cursor.tile_y

    hue = CATEGORY_HUE[@board.type?(x, y)]

    self.bitmap.draw_board_category(   @board, x, y, 28,  20, hue)

    self.bitmap.draw_board_ap(         @board, x, y, 55,  16)

    self.bitmap.draw_board_activated(  @board, x, y, 114, 18,    @edit_mode)

    self.bitmap.draw_board_class(      @board, x, y, 138, 16)

    self.bitmap.draw_board_item(       @board, x, y, 62,  42, 0, @edit_mode)

    self.bitmap.draw_board_item(       @board, x, y, 312, 42, 1, @edit_mode)

    self.bitmap.draw_board_item(       @board, x, y, 62,  63, 2, @edit_mode)

    self.bitmap.draw_board_item(       @board, x, y, 312, 63, 3, @edit_mode)

    self.bitmap.draw_board_description(@board, x, y, 90,  42,    @edit_mode)

  end

  #--------------------------------------------------------------------------

  # * Frame Update

  #--------------------------------------------------------------------------

  def update

    super

    if [@cursor.tile_x, @cursor.tile_y] != [@ox, @oy]

      @ox, @oy = @cursor.tile_x, @cursor.tile_y

      refresh

    end

  end

end

 

Code:
#==============================================================================

# ** Cursor_Base

#------------------------------------------------------------------------------

#  This sprite is used to display the cursor. It observes a superclass

#  and automatically changes sprite conditions.

#==============================================================================

 

class Sprite_Cursor < Dynamic_Sprite

  #--------------------------------------------------------------------------

  # * Invariables

  #--------------------------------------------------------------------------

  include FFXII                           # FFXII module

  #--------------------------------------------------------------------------

  # * Object Initialization

  #     viewport : viewport

  #--------------------------------------------------------------------------

  def initialize(viewport = nil)

    super(viewport)

    self.bitmap = CURSOR

  end

end

 

Code:
#==============================================================================

# ** Spriteset_Board

#------------------------------------------------------------------------------

#  This class brings together the board tiles, icons and active slots.

#  It's used within the Scene_Board class.

#==============================================================================

 

class Spriteset_Board

  #--------------------------------------------------------------------------

  # * Invariables

  #--------------------------------------------------------------------------

  include FFXII                           # FFXII module

  #--------------------------------------------------------------------------

  # * Public Instance Variables

  #--------------------------------------------------------------------------

  attr_accessor :tiles                    # tiles

  attr_accessor :icons                    # icons

  attr_accessor :active                   # active

  #--------------------------------------------------------------------------

  # * Object Initialization

  #     board     : board

  #     edit_mode : edit mode ON

  #--------------------------------------------------------------------------

  def initialize(board, edit_mode = false)

    @board = board

    @edit_mode = edit_mode

    @bg = Plane.new

    @bg.bitmap = BOARD_BG

    @xs, @ys = TILE_X_SIZE, TILE_Y_SIZE

    @tiles = Dynamic_Sprite.new

    @tiles.bitmap = Bitmap.new(@board.xsize * @xs, @board.ysize * @ys)

    @icons = Dynamic_Sprite.new

    @icons.bitmap = Bitmap.new(@board.xsize * @xs, @board.ysize * @ys)

    @icons.blink_on

    @active = Dynamic_Sprite.new

    @active.bitmap = Bitmap.new(@board.xsize * @xs, @board.ysize * @ys)

    refresh

  end

  #--------------------------------------------------------------------------

  # * Refresh

  #--------------------------------------------------------------------------

  def refresh

    @tiles.bitmap.clear

    @icons.bitmap.clear

    @active.bitmap.clear

    for x in [email=0...@board.xsize]0...@board.xsize[/email]

      for y in [email=0...@board.ysize]0...@board.ysize[/email]

        @tiles.bitmap.draw_board_tile(@board, x, y)

        @icons.bitmap.draw_board_icon(@board, x, y, @edit_mode)

        @active.bitmap.draw_board_active(@board, x, y, @edit_mode)

      end

    end

  end

  #--------------------------------------------------------------------------

  # * Dispose

  #--------------------------------------------------------------------------

  def dispose

    @bg.dispose

    @tiles.dispose

    @icons.dispose

    @active.dispose

  end

  #--------------------------------------------------------------------------

  # * Frame Update

  #--------------------------------------------------------------------------

  def update

    @tiles.update

    @icons.update

    @active.update

  end

end

 

Code:
#==============================================================================

# ** Bitmap

#------------------------------------------------------------------------------

#  The bitmap class. Bitmaps are expressions of so-called graphics.

#  Sprites and other objects must be used to display bitmaps on the screen.

#==============================================================================

 

class Bitmap

  #--------------------------------------------------------------------------

  # * Invariables

  #--------------------------------------------------------------------------

  include FFXII                           # FFXII module

  #--------------------------------------------------------------------------

  # * Draw Actor Name

  #     actor : actor

  #     x     : draw spot x-coordinate

  #     y     : draw spot y-coordinate

  #--------------------------------------------------------------------------

  def draw_actor_name(actor, x, y)

    self.draw_outline(x, y, 120, 32, actor.name)

  end

  #--------------------------------------------------------------------------

  # * Draw Actor AP

  #     actor : actor

  #     x     : draw spot x-coordinate

  #     y     : draw spot y-coordinate

  #     width : draw spot width

  #--------------------------------------------------------------------------

  def draw_actor_ap(actor, x, y, width = 78)

    color = Color.new(204, 204, 153)

    text = LP

    self.draw_outline(x, y, 32, 32, text, 0, color)

    ap_x = x + width - 48

    ap = actor.ap.to_s

    self.draw_outline(ap_x, y, 48, 32, ap, 2, color)

  end

  #--------------------------------------------------------------------------

  # * Draw Actor Avatar

  #     actor : actor

  #     x     : draw spot x-coordinate

  #     y     : draw spot y-coordinate

  #--------------------------------------------------------------------------

  def draw_actor_avatar(actor, x, y)

    rect = Rect.new(0, 0, 60, 60)

    avatar = AVATAR(actor.id)

    self.blt(x, y, avatar, rect)

  end

  #--------------------------------------------------------------------------

  # * Draw Actor Minimap

  #     actor : actor

  #     x     : draw spot x-coordinate

  #     y     : draw spot y-coordinate

  #--------------------------------------------------------------------------

  def draw_actor_minimap(actor, x, y)

    bitmap = Bitmap_MiniBoard.new(actor.board)

    rect = Rect.new(0, 0, bitmap.width, bitmap.height)

    self.blt(x, y, bitmap, rect)

  end

  #--------------------------------------------------------------------------

  # * Draw Board Category

  #     board : board

  #     bx    : board x-coordinate

  #     by    : board y-coordinate

  #     x     : draw spot x-coordinate

  #     y     : draw spot y-coordinate

  #     hue   : hue

  #--------------------------------------------------------------------------

  def draw_board_category(board, bx, by, x, y, hue = 0)

    bitmap = Bitmap.new(26, 26)

    rect = Rect.new(0, 0, 26, 26)

    bitmap.blt(0, 0, CATEGORY, rect)

    bitmap.hue_change(hue)

    self.blt(x, y, bitmap, rect)

  end

  #--------------------------------------------------------------------------

  # * Draw Board AP

  #     board : board

  #     bx    : board x-coordinate

  #     by    : board y-coordinate

  #     x     : draw spot x-coordinate

  #     y     : draw spot y-coordinate

  #     width : draw spot width

  #--------------------------------------------------------------------------

  def draw_board_ap(board, bx, by, x, y, width = 56)

    color = Color.new(204, 204, 153)

    text = LP

    self.draw_outline(x, y, 32, 32, text, 0, color)

    ap_x = x + width - 48

    ap = board.ap_cost?(bx, by).to_s

    self.draw_outline(ap_x, y, 48, 32, ap, 2, color)

  end

  #--------------------------------------------------------------------------

  # * Draw Board Activated

  #     board     : board

  #     bx        : board x-coordinate

  #     by        : board y-coordinate

  #     x         : draw spot x-coordinate

  #     y         : draw spot y-coordinate

  #     edit_mode : edit mode ON

  #--------------------------------------------------------------------------

  def draw_board_activated(board, bx, by, x, y, edit_mode = false)

    if board.activated?(bx, by) or edit_mode and board.visible?(bx, by)

      bitmap = Bitmap.new(24, 24)

      rect = Rect.new(0, 0, 24, 24)

      bitmap.blt(0, 0, STAR, rect)

      self.blt(x, y, bitmap, rect)

    end

  end

  #--------------------------------------------------------------------------

  # * Draw Board Class

  #     board : board

  #     bx    : board x-coordinate

  #     by    : board y-coordinate

  #     x     : draw spot x-coordinate

  #     y     : draw spot y-coordinate

  #     width : draw spot width

  #--------------------------------------------------------------------------

  def draw_board_class(board, bx, by, x, y, width = 472)

    board_class = board.class(bx, by)

    if board_class != nil

      self.draw_outline(x, y, width, 32, board_class)

    end

  end

  #--------------------------------------------------------------------------

  # * Draw Board Item

  #     board     : board

  #     bx        : board x-coordinate

  #     by        : board y-coordinate

  #     x         : draw spot x-coordinate

  #     y         : draw spot y-coordinate

  #     n         : item number

  #     edit_mode : edit mode ON

  #     width     : draw spot width

  #--------------------------------------------------------------------------

  def draw_board_item(board, bx, by, x, y, n = 0, edit_mode = false, width = 240)

    item = board.item(bx, by, n)

    if item != nil

      if board.visible?(bx, by) or edit_mode

        bitmap = RPG::Cache.icon(item.icon_name)

        rect = Rect.new(0, 0, 24, 24)

        self.blt(x, y + 4, bitmap, rect)

        self.draw_outline(x + 28, y, 212, 32, item.name)

      else

        text = HIDDEN

        self.draw_outline(x + 28, y, 212, 32, text)

      end

    end

  end

  #--------------------------------------------------------------------------

  # * Draw Board Description

  #     board     : board

  #     bx        : board x-coordinate

  #     by        : board y-coordinate

  #     x         : draw spot x-coordinate

  #     y         : draw spot y-coordinate

  #     edit_mode : edit mode ON

  #     width     : draw spot width

  #--------------------------------------------------------------------------

  def draw_board_description(board, bx, by, x, y, edit_mode = false, width = 480)

    type = board.type?(bx, by)

    if type >= 0 and type < 8

      if board.visible?(bx, by) or edit_mode

        description = board.description(bx, by)

        self.draw_outline(x, y, width, 32, description)

      else

        text = HIDDEN

        self.draw_outline(x, y, width, 32, text)

      end

    end

  end

  #--------------------------------------------------------------------------

  # * Draw Board Tile

  #     board : board

  #     bx    : board x-coordinate

  #     by    : board y-coordinate

  #--------------------------------------------------------------------------

  def draw_board_tile(board, bx, by)

    type = board.type?(bx, by)

    if type >= 0

      xs, ys = TILE_X_SIZE, TILE_Y_SIZE

      bitmap = Bitmap.new(xs, ys)

      id = (bx + by) % 2

      rect = Rect.new(0, 0, xs, ys)

      bitmap.blt(0, 0, TILE(id), rect)

      self.blt(bx * xs, by * ys, bitmap, rect)

    end

  end

  #--------------------------------------------------------------------------

  # * Draw Board Icon

  #     board     : board

  #     bx        : board x-coordinate

  #     by        : board y-coordinate

  #     edit_mode : edit mode ON

  #--------------------------------------------------------------------------

  def draw_board_icon(board, bx, by, edit_mode)

    visible = board.visible?(bx, by)

    activated = board.activated?(bx, by)

    if visible and not activated and not edit_mode

      xs, ys = TILE_X_SIZE, TILE_Y_SIZE

      bitmap = Bitmap.new(xs, ys)

      type = board.type?(bx, by)

      rect = Rect.new(0, 0, xs, ys)

      bitmap.blt(0, 0, ICON(type), rect)

      bitmap.font.size = TILE_AP_FONT_SIZE

      ap_y = ys - bitmap.font.size - 8

      ap_cost = board.ap_cost?(bx, by).to_s

      color = Color.new(204, 204, 153)

      bitmap.draw_outline(0, ap_y, xs, ys, ap_cost, 0, color)

      bitmap.font.size = TILE_LEVEL_FONT_SIZE

      level = board.level?(bx, by)

      if level >= 0

        bitmap.draw_outline(0, -8, xs, ys, level.to_s, 2)

      end

      self.blt(bx * xs, by * ys, bitmap, rect)

    end

  end

  #--------------------------------------------------------------------------

  # * Draw Board Active

  #     board     : board

  #     bx        : board x-coordinate

  #     by        : board y-coordinate

  #     edit_mode : edit mode ON

  #--------------------------------------------------------------------------

  def draw_board_active(board, bx, by, edit_mode)

    visible = board.visible?(bx, by)

    activated = board.activated?(bx, by)

    if visible and activated or edit_mode

      xs, ys = TILE_X_SIZE, TILE_Y_SIZE

      bitmap = Bitmap.new(xs, ys)

      type = board.type?(bx, by)

      rect = Rect.new(0, 0, xs, ys)

      bitmap.blt(0, 0, ICON(type), rect)

      bitmap.font.size = TILE_LEVEL_FONT_SIZE

      level = board.level?(bx, by)

      if level >= 0

        bitmap.draw_outline(0, -8, xs, ys, level.to_s, 2)

      end

      self.blt(bx * xs, by * ys, bitmap, rect)

    end

  end

  #--------------------------------------------------------------------------

  # * Draw Board Statistics

  #     board : board

  #--------------------------------------------------------------------------

  def draw_board_statistics(board)

    self.draw_text(0, 0, 408, 32, board.name)

    self.draw_text(0, 0, 408, 32, "ID: #{board.id}", 2)

    self.draw_text(32, 48, 344, 32, "X Size: #{board.xsize}")

    self.draw_text(32, 48, 344, 32, "Y Size: #{board.ysize}", 2)

    stats = board.statistics

    text = ["HP", "SP", "Strength", "Physical Defense",

            "Intelligence", "Magical Defense", "Agility",

            "Dexterity", "Skills", "Weapon Set", "Armor Set"]

    for i in 0...text.length

      self.draw_text(32, 96 + i * 32, 344, 32, "#{text[i]}: #{stats[i]}")

    end

  end

  #--------------------------------------------------------------------------

  # * Draw Miniature Board Tile

  #     board : board

  #     bx    : board x-coordinate

  #     by    : board y-coordinate

  #--------------------------------------------------------------------------

  def draw_miniboard_tile(board, bx, by)

    type = board.type?(bx, by)

    activated = board.activated?(bx, by)

    xs, ys = MINI_TILE_XSIZE, MINI_TILE_YSIZE

    margin = MINIBOARD_MARGIN

    cx, cy = bx * xs + margin, by * ys + margin

    rect = Rect.new(0, 0, xs, ys)

    if type != -1 and not activated

      self.blt(cx, cy, MINI_TILE(-1), rect)

    elsif activated

      self.blt(cx, cy, MINI_TILE(type), rect)

    end

  end

  #--------------------------------------------------------------------------

  # * Draw Outline

  #     x     : draw spot x-coordinate

  #     y     : draw spot y-coordinate

  #     w     : draw spot width

  #     h     : draw spot height

  #     text  : text string displayed

  #     align : alignment (0..flush left, 1..center, 2..flush right)

  #     color : text string color

  #--------------------------------------------------------------------------

  def draw_outline(x, y, w, h, text, align=0, color=Color.new(255, 255, 255))

    self.font.color = Color.new(0, 0, 0)

    self.draw_text(x,     y + 1, w, h, text, align)  # U

    self.draw_text(x - 1, y + 1, w, h, text, align)  # UL

    self.draw_text(x - 1, y,     w, h, text, align)  # L

    self.draw_text(x - 1, y - 1, w, h, text, align)  # DL

    self.draw_text(x,     y - 1, w, h, text, align)  # D

    self.draw_text(x + 1, y - 1, w, h, text, align)  # DR

    self.draw_text(x + 1, y,     w, h, text, align)  # R

    self.draw_text(x + 1, y + 1, w, h, text, align)  # UR

    self.font.color = color

    self.draw_text(x, y, w, h, text, align)

  end

end

 

Code:
#==============================================================================

# ** Bitmap_MiniBoard

#------------------------------------------------------------------------------

#  This bitmap draws a miniature board. It observes the Window_BoardSelectable

#  class and automatically changes bitmap conditions.

#==============================================================================

 

class Bitmap_MiniBoard < Bitmap

  #--------------------------------------------------------------------------

  # * Invariables

  #--------------------------------------------------------------------------

  include FFXII                           # FFXII module

  #--------------------------------------------------------------------------

  # * Object Initialization

  #     board : board

  #--------------------------------------------------------------------------

  def initialize(board)

    super(MINIBOARD)

    @board = board

    update

  end

  #--------------------------------------------------------------------------

  # * Frame Update

  #--------------------------------------------------------------------------

  def update

    for x in [email=0...@board.xsize]0...@board.xsize[/email]

      for y in [email=0...@board.ysize]0...@board.ysize[/email]

        self.draw_miniboard_tile(@board, x, y)

      end

    end

  end

end

 

Code:
#==============================================================================

# ** Window_EquipItem

#------------------------------------------------------------------------------

#  This window displays choices when opting to change equipment on the

#  equipment screen.

#==============================================================================

 

class Window_EquipItem < Window_Selectable

  #--------------------------------------------------------------------------

  # * Refresh

  #--------------------------------------------------------------------------

  def refresh

    if self.contents != nil

      self.contents.dispose

      self.contents = nil

    end

    @data = []

    # Add equippable weapons

    if @equip_type == 0

      weapon_set = $data_classes[@actor.class_id].weapon_set

      for i in 1...$data_weapons.size

        if $game_party.weapon_number(i) > 0 and

            @actor.equippable?($data_weapons[i])

          @data.push($data_weapons[i])

        end

      end

    end

    # Add equippable armor

    if @equip_type != 0

      armor_set = $data_classes[@actor.class_id].armor_set

      for i in 1...$data_armors.size

        if $game_party.armor_number(i) > 0 and

            @actor.equippable?($data_armors[i])

          if $data_armors[i].kind == @equip_type-1

            @data.push($data_armors[i])

          end

        end

      end

    end

    # Add blank page

    @data.push(nil)

    # Make a bit map and draw all items

    @item_max = @data.size

    self.contents = Bitmap.new(width - 32, row_max * 32)

    for i in 0...@item_max-1

      draw_item(i)

    end

  end

end

 

Code:
#==============================================================================

# ** Window_InputNumber

#------------------------------------------------------------------------------

#  This window is for inputting numbers, and is used within the

#  message window.

#==============================================================================

 

class Window_InputNumber < Window_Base

  #--------------------------------------------------------------------------

  # * Object Initialization

  #     digits_max : digit count

  #--------------------------------------------------------------------------

  def initialize(digits_max, message, width)

    @digits_max = digits_max

    @message = message

    @number = 0

    # Calculate cursor width from number width (0-9 equal width and postulate)

    dummy_bitmap = Bitmap.new(32, 32)

    @cursor_width = dummy_bitmap.text_size("0").width + 8

    dummy_bitmap.dispose

    super(0, 0, width, 64)

    self.contents = Bitmap.new(width - 32, height - 32)

    text_x = @cursor_width * @digits_max + 32

    self.contents.draw_text(text_x, 0, width - text_x - 32, 32, @message)

    self.z += 9999

    @index = 0

    refresh

    update_cursor_rect

  end

  #--------------------------------------------------------------------------

  # * Get Number

  #--------------------------------------------------------------------------

  def number

    return @number

  end

  #--------------------------------------------------------------------------

  # * Set Number

  #     number : new number

  #--------------------------------------------------------------------------

  def number=(number)

    @number = [[number, 0].max, 10 ** @digits_max - 1].min

    refresh

  end

  #--------------------------------------------------------------------------

  # * Cursor Rectangle Update

  #--------------------------------------------------------------------------

  def update_cursor_rect

    self.cursor_rect.set(@index * @cursor_width, 0, @cursor_width, 32)

  end

  #--------------------------------------------------------------------------

  # * Frame Update

  #--------------------------------------------------------------------------

  def update

    super

    # If up or down directional button was pressed

    if Input.repeat?(Input::UP) or Input.repeat?(Input::DOWN)

      $game_system.se_play($data_system.cursor_se)

      # Get current place number and change it to 0

      place = 10 ** (@digits_max - 1 - @index)

      n = @number / place % 10

      @number -= n * place

      # If up add 1, if down substract 1

      n = (n + 1) % 10 if Input.repeat?(Input::UP)

      n = (n + 9) % 10 if Input.repeat?(Input::DOWN)

      # Reset current place number

      @number += n * place

      refresh

    end

    # Cursor right

    if Input.repeat?(Input::RIGHT)

      if @digits_max >= 2

        $game_system.se_play($data_system.cursor_se)

        @index = (@index + 1) % @digits_max

      end

    end

    # Cursor left

    if Input.repeat?(Input::LEFT)

      if @digits_max >= 2

        $game_system.se_play($data_system.cursor_se)

        @index = (@index + @digits_max - 1) % @digits_max

      end

    end

    update_cursor_rect

  end

  #--------------------------------------------------------------------------

  # * Refresh

  #--------------------------------------------------------------------------

  def refresh

    self.contents.clear

    self.contents.font.color = normal_color

    s = sprintf("%0*d", @digits_max, @number)

    for i in 0...@digits_max

      self.contents.draw_text(i * @cursor_width + 4, 0, 32, 32, s[i,1])

    end

    text_x = @cursor_width * @digits_max + 32

    self.contents.draw_text(text_x, 0, width - text_x - 32, 32, @message)

  end

end

 

Code:
#==============================================================================

# ** Window_BoardSelectable

#------------------------------------------------------------------------------

#  This window class contains cursor movement and scroll functions.

#==============================================================================

 

class Window_BoardSelectable < Window_Base

  #--------------------------------------------------------------------------

  # * Public Instance Variables

  #--------------------------------------------------------------------------

  attr_reader   :index                    # cursor position

  attr_reader   :help_window              # help window

  #--------------------------------------------------------------------------

  # * Object Initialization

  #     x      : window x-coordinate

  #     y      : window y-coordinate

  #     width  : window width

  #     height : window height

  #--------------------------------------------------------------------------

  def initialize(x, y, width, height)

    super(x, y, width, height)

    @item_max = 1

    @column_max = 1

    @index = -1

    @cy = 32

    @scroll_y = 0

    @scroll_speed = 0

    @cursor = Sprite_Cursor.new

    @cursor.z = 3000

    update_cursor

  end

  #--------------------------------------------------------------------------

  # * Set Cursor Position

  #     index : new cursor position

  #--------------------------------------------------------------------------

  def index=(index)

    @index = index

    # Update Help Text (update_help is defined by the subclasses)

    if self.active and @help_window != nil

      update_help

    end

    # Update cursor rectangle

    update_cursor_rect

  end

  #--------------------------------------------------------------------------

  # * Get Row Count

  #--------------------------------------------------------------------------

  def row_max

    # Compute rows from number of items and columns

    return (@item_max + @column_max - 1) / @column_max

  end

  #--------------------------------------------------------------------------

  # * Get Top Row

  #--------------------------------------------------------------------------

  def top_row

    # Divide scroll y-coordinate window contents transfer origin by

    # cursor y-coordinate

    return @scroll_y / @cy

  end

  #--------------------------------------------------------------------------

  # * Set Top Row

  #     row : row shown on top

  #--------------------------------------------------------------------------

  def top_row=(row)

    # If row is less than 0, change it to 0

    if row < 0

      row = 0

    end

    # If row exceeds row_max - 1, change it to row_max - 1

    if row > row_max - 1

      row = row_max - 1

    end

    # Multiply row height by cursor y-coordinate for scroll y-coordinate

    # of window contents transfer origin

    @scroll_y = row * @cy

  end

  #--------------------------------------------------------------------------

  # * Get Number of Rows Displayable on 1 Page

  #--------------------------------------------------------------------------

  def page_row_max

    # Subtract a frame height of 32 from the window height, and divide it

    # by cursor y-coordinate

    return (self.height - 32) / @cy

  end

  #--------------------------------------------------------------------------

  # * Get Number of Items Displayable on 1 Page

  #--------------------------------------------------------------------------

  def page_item_max

    # Multiply row count (page_row_max) times column count (@column_max)

    return page_row_max * @column_max

  end

  #--------------------------------------------------------------------------

  # * Set Help Window

  #     help_window : new help window

  #--------------------------------------------------------------------------

  def help_window=(help_window)

    @help_window = help_window

    # Update help text (update_help is defined by the subclasses)

    if self.active and @help_window != nil

      update_help

    end

  end

  #--------------------------------------------------------------------------

  # * Update Cursor Rectangle

  #--------------------------------------------------------------------------

  def update_cursor_rect

    # If cursor position is less than 0

    if @index < 0

      self.cursor_rect.empty

      return

    end

    # Get current row

    row = @index / @column_max

    # If current row is before top row

    if row < self.top_row

      # Scroll so that current row becomes top row

      self.top_row = row

      @scroll_speed = (self.oy - @scroll_y) / 6

    end

    # If current row is more to back than back row

    if row > self.top_row + (self.page_row_max - 1)

      # Scroll so that current row becomes back row

      self.top_row = row - (self.page_row_max - 1)

      @scroll_speed = (@scroll_y - self.oy) / 6

    end

    # Calculate cursor width

    cursor_width = self.width / @column_max - 32

    # Calculate cursor coordinates

    x = @index % @column_max * (cursor_width + 32)

    y = @index / @column_max * @cy - @scroll_y

    # Update cursor rectangle

    self.cursor_rect.set(x, y, 0, 0)

  end

  #--------------------------------------------------------------------------

  # * Frame Update

  #--------------------------------------------------------------------------

  def update

    super

    # If cursor is movable

    if self.active and @item_max > 0 and @index >= 0

      # If pressing down on the directional buttons

      if Input.repeat?(Input::DOWN)

        # If column count is 1 and directional button was pressed down with no

        # repeat, or if cursor position is more to the front than

        # (item count - column count)

        if Input.press?(Input::SHIFT)

          # Move cursor to page item max

          $game_system.se_play($data_system.cursor_se)

          n = @index + page_item_max

          @index = n > @item_max - 1 ? @item_max - 1 : n

        elsif (@column_max == 1 and Input.trigger?(Input::DOWN)) or

            @index < @item_max - @column_max

          # Move cursor down

          $game_system.se_play($data_system.cursor_se)

          @index = (@index + @column_max) % @item_max

        end

      end

      # If the up directional button was pressed

      if Input.repeat?(Input::UP)

        # If column count is 1 and directional button was pressed up with no

        # repeat, or if cursor position is more to the back than column count

        if Input.press?(Input::SHIFT)

          # Move cursor to initial page index

          $game_system.se_play($data_system.cursor_se)

          n = @index - page_item_max

          @index = n < 0 ? 0 : n

        elsif (@column_max == 1 and Input.trigger?(Input::UP)) or

            @index >= @column_max

          # Move cursor up

          $game_system.se_play($data_system.cursor_se)

          @index = (@index - @column_max + @item_max) % @item_max

        end

      end

      # If the right directional button was pressed

      if Input.repeat?(Input::RIGHT)

        # If column count is 2 or more, and cursor position is closer to front

        # than (item count -1)

        if @column_max >= 2 and @index < @item_max - 1

          # Move cursor right

          $game_system.se_play($data_system.cursor_se)

          @index += 1

        end

      end

      # If the left directional button was pressed

      if Input.repeat?(Input::LEFT)

        # If column count is 2 or more, and cursor position is more back than 0

        if @column_max >= 2 and @index > 0

          # Move cursor left

          $game_system.se_play($data_system.cursor_se)

          @index -= 1

        end

      end

      # If R button was pressed

      if Input.repeat?(Input::R)

        # If bottom row being displayed is more to front than bottom data row

        if self.top_row + (self.page_row_max - 1) < (self.row_max - 1)

          # Move cursor 1 page back

          $game_system.se_play($data_system.cursor_se)

          @index = [@index + self.page_item_max, @item_max - 1].min

          self.top_row += self.page_row_max

        end

      end

      # If L button was pressed

      if Input.repeat?(Input::L)

        # If top row being displayed is more to back than 0

        if self.top_row > 0

          # Move cursor 1 page forward

          $game_system.se_play($data_system.cursor_se)

          @index = [@index - self.page_item_max, 0].max

          self.top_row -= self.page_row_max

        end

      end

    end

    # Update help text (update_help is defined by the subclasses)

    if self.active and @help_window != nil

      update_help

    end

    # Update cursor rectangle

    update_cursor_rect

    # Update scroll

    update_scroll

    # Update cursor

    update_cursor

  end

  #--------------------------------------------------------------------------

  # * Update Cursor

  #--------------------------------------------------------------------------

  def update_cursor

    @cursor.true_x = self.cursor_rect.x + self.x - 8

    @cursor.true_y = self.cursor_rect.y + self.y + 16

    @cursor.update

    @cursor.visible = (self.visible and self.index >= 0)

  end

  #--------------------------------------------------------------------------

  # * Update Scroll

  #--------------------------------------------------------------------------

  def update_scroll

    # If y-coordinate position is less than scroll y-coordinate

    if self.oy < @scroll_y

      self.oy += @scroll_speed

      if self.oy > @scroll_y

        self.oy = @scroll_y

      end

    end

    # If y-coordinate position is more than scroll y-coordinate

    if self.oy > @scroll_y

      self.oy -= @scroll_speed

      if self.oy < @scroll_y

        self.oy = @scroll_y

      end

    end

  end

  #--------------------------------------------------------------------------

  # * Dispose

  #--------------------------------------------------------------------------

  def dispose

    @cursor.dispose

    super

  end

end

 

Code:
#==============================================================================

# ** Window_BoardConfirm

#------------------------------------------------------------------------------

#  This window is used to confirm the activation of a slot.

#==============================================================================

 

class Window_BoardConfirm < Window_BoardSelectable

  #--------------------------------------------------------------------------

  # * Public Instance Variables

  #--------------------------------------------------------------------------

  attr_accessor :message              # message

  #--------------------------------------------------------------------------

  # * Object Initialization

  #     width    : window width

  #     commands : command text string array

  #--------------------------------------------------------------------------

  def initialize(width, commands, message = "")

    # Compute window height from command quantity

    super(0, 0, width, commands.size * 32 + 64)

    @item_max = commands.size

    @commands = commands

    @message = message

    self.contents = Bitmap.new(width - 32, @item_max * 32 + 32)

    refresh

    self.index = 0

  end

  #--------------------------------------------------------------------------

  # * Refresh

  #--------------------------------------------------------------------------

  def refresh

    self.contents.clear

    self.contents.draw_text(0, 0, self.width - 32, 32, @message)

    for i in 0...@item_max

      self.draw_item(i, 32, i * 32 + 32)

    end

  end

  #--------------------------------------------------------------------------

  # * Draw Item

  #     index : item number

  #     color : text color

  #--------------------------------------------------------------------------

  def draw_item(index, x, y, color=normal_color)

    self.contents.draw_text(x, y, 120, 32, @commands[index])

  end

  #--------------------------------------------------------------------------

  # * Disable Item

  #     index : item number

  #--------------------------------------------------------------------------

  def disable_item(index)

    self.draw_item(index, 32, index * 32 + 32, disabled_color)

  end

  #--------------------------------------------------------------------------

  # * Update Cursor Rectangle

  #--------------------------------------------------------------------------

  def update_cursor_rect

    # If cursor position is less than 0

    if @index < 0

      self.cursor_rect.empty

      return

    end

    # Get current row

    row = @index / @column_max

    # If current row is before top row

    if row < self.top_row

      # Scroll so that current row becomes top row

      self.top_row = row

      @scroll_speed = (self.oy - @scroll_y) / 6

    end

    # If current row is more to back than back row

    if row > self.top_row + (self.page_row_max - 1)

      # Scroll so that current row becomes back row

      self.top_row = row - (self.page_row_max - 1)

      @scroll_speed = (@scroll_y - self.oy) / 6

    end

    # Calculate cursor width

    cursor_width = self.width / @column_max - 32

    # Calculate cursor coordinates

    x = @index % @column_max * (cursor_width + 32)

    y = @index / @column_max * @cy - @scroll_y

    # Update cursor rectangle

    self.cursor_rect.set(x + 16, y + 32, 0, 0)

  end

end

 

Code:
#==============================================================================

# ** Window_BoardSelect

#------------------------------------------------------------------------------

#  This window selects a board to display from an actor.

#==============================================================================

 

class Window_BoardSelect < Window_BoardSelectable

  #--------------------------------------------------------------------------

  # * Invariables

  #--------------------------------------------------------------------------

  include FFXII                           # FFXII module

  #--------------------------------------------------------------------------

  # * Object Initialization

  #--------------------------------------------------------------------------

  def initialize

    super(0, 0, 672, 512)

    @item_max = $game_party.actors.size

    @column_max = 3

    self.contents = Bitmap.new(width - 32, @item_max * 240)

    @bg = Plane.new

    @bg.bitmap = BOARD_BG

    @shadow_sprite = RPG::Sprite.new

    @shadow_sprite.bitmap = SHADOW.dup

    refresh

    self.index = 0

    self.x = -16

    self.y = -16

    self.opacity = 0

  end

  #--------------------------------------------------------------------------

  # * Refresh

  #--------------------------------------------------------------------------

  def refresh

    self.contents.clear

    for i in 0...$game_party.actors.size

      x = i % @column_max * 208

      y = i / @column_max * 240

      actor = $game_party.actors[i]

      self.contents.draw_actor_minimap(actor, x + 8,   y + 32)

      self.contents.draw_actor_name(   actor, x + 12,  y)

      self.contents.draw_actor_ap(     actor, x + 126, y + 4)

    end

  end

  #--------------------------------------------------------------------------

  # * Dispose

  #--------------------------------------------------------------------------

  def dispose

    self.contents.clear

    @bg.dispose

    @shadow_sprite.dispose

    @cursor.dispose

    super

  end

  #--------------------------------------------------------------------------

  # * Update Cursor Rectangle

  #--------------------------------------------------------------------------

  def update_cursor_rect

    super

    x = @index % @column_max * 208

    y = @index / @column_max * 240 - @scroll_y

    self.cursor_rect.set(x + 32, y + 32, 0, 0)

  end

end

 

Code:
#==============================================================================

# ** Window_EditBoardLeft

#------------------------------------------------------------------------------

#  This window designates boards on the board edit screen.

#==============================================================================

 

class Window_EditBoardLeft < Window_Selectable

  #--------------------------------------------------------------------------

  # * Object Initialization

  #--------------------------------------------------------------------------

  def initialize

    super(0, 0, 192, 352)

    self.index = 0

    refresh

  end

  #--------------------------------------------------------------------------

  # * Refresh

  #--------------------------------------------------------------------------

  def refresh

    if self.contents != nil

      self.contents.dispose

      self.contents = nil

    end

    @item_max = $data_boards.size + 1

    self.contents = Bitmap.new(width - 32, @item_max * 32)

    for i in 0...@item_max - 1

      text = "License Board #{i}"

      self.contents.draw_text(4, i * 32, 152, 32, text)

    end

    self.contents.draw_text(4, self.contents.height - 32, 152, 32, "New board")

  end

  #--------------------------------------------------------------------------

  # * Get Index

  #--------------------------------------------------------------------------

  def index?

    return self.index

  end

  #--------------------------------------------------------------------------

  # * Get Board

  #--------------------------------------------------------------------------

  def board

    return Board.new(index?) rescue nil

  end

end

 

Code:
#==============================================================================

# ** Window_EditBoardRight

#------------------------------------------------------------------------------

#  This window displays boards separately on the board edit screen.

#==============================================================================

 

class Window_EditBoardRight < Window_Base

  #--------------------------------------------------------------------------

  # * Public Instance Variables

  #--------------------------------------------------------------------------

  attr_accessor :board                    # board

  #--------------------------------------------------------------------------

  # * Object Initialization

  #--------------------------------------------------------------------------

  def initialize(board = nil)

    super(192, 0, 448, 480)

    self.contents = Bitmap.new(width - 32, height - 32)

    @board = board

    refresh

  end

  #--------------------------------------------------------------------------

  # * Refresh

  #--------------------------------------------------------------------------

  def refresh

    self.contents.clear

    if @board != nil

      self.contents.draw_board_statistics(@board)

    else

      self.contents.draw_text(4, 0, 408, 32, "Create new board")

    end

  end

end

 

Code:
$data_boards  = load_data("Data/Boards.rxdata")

Code:
#==============================================================================

# ** Scene_BoardSelect

#------------------------------------------------------------------------------

#  This class performs board select screen processing.

#==============================================================================

 

class Scene_BoardSelect

  #--------------------------------------------------------------------------

  # * Invariables

  #--------------------------------------------------------------------------

  include FFXII                           # FFXII module

  include Boards                          # Boards module

  #--------------------------------------------------------------------------

  # * Object Initialization

  #     index : index

  #--------------------------------------------------------------------------

  def initialize(index = 0)

    @index = index

  end

  #--------------------------------------------------------------------------

  # * Main Processing

  #--------------------------------------------------------------------------

  def main

    $data_boards = get_boards

    @select_window = Window_BoardSelect.new

    @select_window.index = @index

    Graphics.transition

    loop do

      Graphics.update

      Input.update

      update

      if $scene != self

        break

      end  

    end

    Graphics.freeze

    @select_window.dispose

  end

  #--------------------------------------------------------------------------

  # * Frame Update

  #--------------------------------------------------------------------------

  def update

    @select_window.update

    if Input.trigger?(Input::B)

      $game_system.se_play($data_system.cancel_se)

      $scene = Scene_Map.new

      return

    end

    if Input.trigger?(Input::C)

      $game_system.se_play($data_system.decision_se)

      actor_index = @select_window.index

      actor = $game_party.actors[actor_index]

      board = actor.board

      $scene = Scene_Board.new(board, actor_index)

      return

    end

  end

end

 

Code:
#==============================================================================

# ** Scene_Board

#------------------------------------------------------------------------------

#  This class performs board screen processing.

#==============================================================================

 

class Scene_Board

  #--------------------------------------------------------------------------

  # * Invariables

  #--------------------------------------------------------------------------

  include FFXII                           # FFXII module

  include Boards                          # Boards module

  #--------------------------------------------------------------------------

  # * Object Initialization

  #     board       : board

  #     actor_index : actor index

  #--------------------------------------------------------------------------

  def initialize(board, actor_index)

    @board = board

    @actor_index = actor_index

    @actor = $game_party.actors[@actor_index]

  end

  #--------------------------------------------------------------------------

  # * Main Processing

  #--------------------------------------------------------------------------

  def main

    $data_boards = get_boards

    @spriteset = Spriteset_Board.new(@board)

    x, y = BOARD_OX, BOARD_OY

    @cursor = Cursor_Board.new(@board, x, y)

    @cursor.px, @cursor.py = BOARD_MARGIN, BOARD_MARGIN

    update_cursor

    @shadow_sprite = RPG::Sprite.new

    @shadow_sprite.bitmap = SHADOW.dup

    @status_sprite = Sprite_AvailableLP.new(@actor, @board)

    @help_sprite = Sprite_LicenseDescription.new(@cursor, @board)

    update_help

    @confirm_window = Window_BoardConfirm.new(240, ["Yes","No"])

    @confirm_window.back_opacity = 160

    @confirm_window.x = 320 - @confirm_window.width / 2

    @confirm_window.y = 240 - @confirm_window.height / 2

    @confirm_window.index = -1

    @confirm_window.active = false

    @confirm_window.visible = false

    @black_sprite = Dynamic_Sprite.new

    @black_sprite.bitmap = BLACK

    @black_sprite.true_opacity = 0

    @black_sprite.opacity = 0

    Graphics.transition

    loop do

      Graphics.update

      Input.update

      update

      if $scene != self

        break

      end  

    end

    Graphics.freeze

    @spriteset.dispose

    @cursor.dispose

    @shadow_sprite.dispose

    @status_sprite.dispose

    @help_sprite.dispose

    @confirm_window.dispose

    @black_sprite.dispose

  end

  #--------------------------------------------------------------------------

  # * Frame Update

  #--------------------------------------------------------------------------

  def update

    @spriteset.update

    @cursor.update

    @status_sprite.update

    @help_sprite.update

    @confirm_window.update

    @black_sprite.update

    if @confirm_window.active

      update_confirm

      return

    end

    if Input.repeat?(Input.dir8)

      $game_system.se_play($data_system.cursor_se)

      update_cursor

      update_help

    end

    if Input.trigger?(Input::B)

      $game_system.se_play($data_system.cancel_se)

      $scene = Scene_BoardSelect.new(@actor_index)

      return

    end

    if Input.trigger?(Input::C)

      x, y = @cursor.tile_x, @cursor.tile_y

      valid = @board.valid?(x, y)

      visible = @board.visible?(x, y)

      activated = @board.activated?(x, y)

      ap_cost = @board.ap_cost?(x, y)

      if valid and visible and not activated and @actor.ap >= ap_cost

        $game_system.se_play($data_system.decision_se)

        board_class = @board.class(x, y)

        @confirm_window.message = CONFIRM_MESSAGE(board_class)

        @confirm_window.refresh

        @confirm_window.index = 1

        @confirm_window.active = true

        @confirm_window.visible = true

        @black_sprite.true_opacity = 128

      else

        $game_system.se_play($data_system.buzzer_se)

      end

      return

    end

    if Input.trigger?(Input::R)

      $game_system.se_play($data_system.cursor_se)

      @actor_index += 1

      @actor_index %= $game_party.actors.size

      actor = $game_party.actors[@actor_index]

      board = actor.board

      $scene = Scene_Board.new(board, @actor_index)

      return

    end

    if Input.trigger?(Input::L)

      $game_system.se_play($data_system.cursor_se)

      @actor_index += $game_party.actors.size - 1

      @actor_index %= $game_party.actors.size

      actor = $game_party.actors[@actor_index]

      board = actor.board

      $scene = Scene_Board.new(board, @actor_index)

      return

    end

  end

  #--------------------------------------------------------------------------

  # * Help Update

  #--------------------------------------------------------------------------

  def update_help

    x, y = @cursor.tile_x, @cursor.tile_y

    if @board.valid?(x, y)

      @help_sprite.true_y = 360

      @help_sprite.true_opacity = 255

    else

      @help_sprite.true_y = 370

      @help_sprite.true_opacity = 0

    end

  end

  #--------------------------------------------------------------------------

  # * Cursor Update

  #--------------------------------------------------------------------------

  def update_cursor

    xs, ys = TILE_X_SIZE, TILE_Y_SIZE

    max_x = 640 / xs - 1

    max_y = 480 / ys - 1

    margin = BOARD_MARGIN

    case Input.dir8

    when 2  # Down

      @cursor.tile_y += 1

      if @cursor.py < max_y - margin

        @cursor.py += 1

      elsif @cursor.tile_y >= @board.ysize

        @cursor.py = margin

      end

    when 4  # Left

      @cursor.tile_x -= 1

      if @cursor.px > margin

        @cursor.px -= 1

      elsif @cursor.tile_x < 0

        @cursor.px = max_x - margin

      end

    when 6  # Right

      @cursor.tile_x += 1

      if @cursor.px < max_x - margin

        @cursor.px += 1

      elsif @cursor.tile_x >= @board.xsize

        @cursor.px = margin

      end

    when 8  # Up

      @cursor.tile_y -= 1

      if @cursor.py > margin

        @cursor.py -= 1

      elsif @cursor.tile_y < 0

        @cursor.py = max_y - margin

      end

    end

    @cursor.tile_x %= @board.xsize

    @cursor.tile_y %= @board.ysize

    cx = (@cursor.px - @cursor.tile_x) * xs

    cy = (@cursor.py - @cursor.tile_y) * ys

    @spriteset.tiles.true_x  = cx

    @spriteset.tiles.true_y  = cy

    @spriteset.icons.true_x  = cx

    @spriteset.icons.true_y  = cy

    @spriteset.active.true_x = cx

    @spriteset.active.true_y = cy

    @cursor.true_x = (@cursor.px * xs) - 20

    @cursor.true_y = (@cursor.py * ys) - 4

  end

  #--------------------------------------------------------------------------

  # * Confirm Window Update

  #--------------------------------------------------------------------------

  def update_confirm

    if Input.trigger?(Input::B)

      $game_system.se_play($data_system.cursor_se)

      @confirm_window.index = 1

      return

    end

    if Input.trigger?(Input::C)

      case @confirm_window.index

      when 0  # Confirm

        $game_system.se_play($data_system.decision_se)

        @confirm_window.index = -1

        @confirm_window.active = false

        @confirm_window.visible = false

        @confirm_window.update

        @black_sprite.true_opacity = 0

        x, y = @cursor.tile_x, @cursor.tile_y

        @board.activate(x, y, true)

        @actor.ap -= @board.ap_cost?(x, y)

        @spriteset.refresh

        @status_sprite.refresh

        @help_sprite.refresh

        animation

      when 1  # Cancel

        $game_system.se_play($data_system.cancel_se)

        @confirm_window.index = -1

        @confirm_window.active = false

        @confirm_window.visible = false

        @confirm_window.update

        @black_sprite.true_opacity = 0

      end

      return

    end

  end

  #--------------------------------------------------------------------------

  # * Animation

  #--------------------------------------------------------------------------

  def animation

    bitmap = ANIMATION

    xs, ys = TILE_X_SIZE, TILE_Y_SIZE

    hf = ANIMATION_HORIZONTAL_FRAMES

    vf = ANIMATION_VERTICAL_FRAMES

    tf = ANIMATION_TOTAL_FRAMES

    blend = ANIMATION_BLENDTYPE

    cx = (@cursor.px * xs) - ((bitmap.width / hf) - xs) / 2

    cy = (@cursor.py * ys) - ((bitmap.height / vf) - ys) / 2

    @animation = Animated_Sprite.new(bitmap, cx, cy, hf, vf, tf, blend)

    loop do

      if @animation.ready?

        @animation.frame += 1

      end

      @animation.update

      @black_sprite.update

      Graphics.update

      if @animation.frame == @animation.frames

        break

      end

    end

    @animation.dispose

  end

end

 

Code:
#==============================================================================

# ** Scene_EditBoard

#------------------------------------------------------------------------------

#  This class performs board edit screen processing.

#==============================================================================

 

class Scene_EditBoard

  #--------------------------------------------------------------------------

  # * Invariables

  #--------------------------------------------------------------------------

  include FFXII                           # FFXII module

  include Boards                          # Boards module

  #--------------------------------------------------------------------------

  # * Object Initialization

  #     index : index

  #--------------------------------------------------------------------------

  def initialize(index = 0)

    @index = index

  end

  #--------------------------------------------------------------------------

  # * Main Processing

  #--------------------------------------------------------------------------

  def main

    $data_boards = get_boards

    @left_window = Window_EditBoardLeft.new

    @right_window = Window_EditBoardRight.new

    @key_window = Window_EditBoardKey.new

    @left_window.index = @index

    @right_window.board = @left_window.board

    @right_window.refresh

    Graphics.transition

    loop do

      Graphics.update

      Input.update

      update

      if $scene != self

        break

      end

    end

    Graphics.freeze

    @left_window.dispose

    @right_window.dispose

    @key_window.dispose

  end

  #--------------------------------------------------------------------------

  # * Frame Update

  #--------------------------------------------------------------------------

  def update

    @right_window.board = @left_window.board

    @right_window.refresh

    @left_window.update

    @right_window.update

    if @left_window.active

      update_left

      return

    end

  end

  #--------------------------------------------------------------------------

  # * Frame Update (when left window is active)

  #--------------------------------------------------------------------------

  def update_left

    if Input.trigger?(Input::A)

      $game_system.se_play($data_system.decision_se)

      index = @left_window.index?

      delete_board(index)

      shutdown

      return

    end

    if Input.trigger?(Input::B)

      $game_system.se_play($data_system.cancel_se)

      shutdown

      return

    end

    if Input.trigger?(Input::C)

      $game_system.se_play($data_system.decision_se)

      board = @right_window.board

      index = @left_window.index?

      if board != nil

        $scene = Scene_CreateBoard.new(board)

      else

        xsize, ysize = NEW_BOARD_XSIZE, NEW_BOARD_YSIZE

        new_board(xsize, ysize)

        shutdown

      end

      return

    end

  end

  #--------------------------------------------------------------------------

  # * Shutdown

  #--------------------------------------------------------------------------

  def shutdown

    Audio.bgm_fade(800)

    Audio.bgs_fade(800)

    Audio.me_fade(800)

    $scene = nil

  end

end

 

Code:
#==============================================================================

# ** Scene_CreateBoard

#------------------------------------------------------------------------------

#  This class performs board create screen processing.

#==============================================================================

 

class Scene_CreateBoard

  #--------------------------------------------------------------------------

  # * Invariables

  #--------------------------------------------------------------------------

  include FFXII                           # FFXII module

  include Boards                          # Boards module

  #--------------------------------------------------------------------------

  # * Object Initialization

  #     board : board

  #--------------------------------------------------------------------------

  def initialize(board)

    @board = board

  end

  #--------------------------------------------------------------------------

  # * Main Processing

  #--------------------------------------------------------------------------

  def main

    $data_boards = get_boards

    @spriteset = Spriteset_Board.new(@board, true)

    x, y = BOARD_OX, BOARD_OY

    @cursor = Cursor_Board.new(@board, x, y)

    @cursor.px, @cursor.py = BOARD_MARGIN, BOARD_MARGIN

    update_cursor

    @shadow_sprite = RPG::Sprite.new

    @shadow_sprite.bitmap = SHADOW.dup

    @help_sprite = Sprite_LicenseDescription.new(@cursor, @board, true)

    update_help

    @commands = ["Health Points", "Magic Points", "Strength", "Power Defense",

                "Intelligence", "Magic Defense", "Agility", "Dexterity",

                "Skill", "Weapon", "Armor", "Empty"]

    @command_window = Window_Command.new(192, @commands)

    @command_window.back_opacity = 160

    @command_window.x = 160 - @command_window.width / 2

    @command_window.y = 240 - @command_window.height / 2

    @command_window.index = -1

    @command_window.active = false

    @command_window.visible = false

    width = 640 - @command_window.width - @command_window.x * 2

    @input_window = []

    for i in 0..5

      if i == 5

        @input_window.push(Window_InputNumber.new(3, "Set a level",      width))

      elsif i == 4

        @input_window.push(Window_InputNumber.new(3, "Set an AP cost",   width))

      else

        @input_window.push(Window_InputNumber.new(3, "Set value #{i+1}", width))

      end

      @input_window[i].back_opacity = 160

      @input_window[i].x = 160 + @command_window.width / 2

      @input_window[i].y = @command_window.y + @input_window[i].height * i

      @input_window[i].active = false

      @input_window[i].visible = false

    end

    @confirm_window = Window_Command.new(192, ["Save changes","Discard changes"])

    @confirm_window.back_opacity = 160

    @confirm_window.x = 320 - @confirm_window.width / 2

    @confirm_window.y = 240 - @confirm_window.height / 2

    @confirm_window.index = -1

    @confirm_window.active = false

    @confirm_window.visible = false

    Graphics.transition

    loop do

      Graphics.update

      Input.update

      update

      if $scene != self

        break

      end  

    end

    Graphics.freeze

    @spriteset.dispose

    @cursor.dispose

    @shadow_sprite.dispose

    @help_sprite.dispose

    @command_window.dispose

    for i in 0..5

      @input_window[i].dispose

    end

    @confirm_window.dispose

  end

  #--------------------------------------------------------------------------

  # * Frame Update

  #--------------------------------------------------------------------------

  def update

    @spriteset.update

    @cursor.update

    @help_sprite.update

    if @command_window.active

      loop do

        Graphics.update

        Input.update

        @command_window.update

        update_command

        if !@command_window.active

          break

        end

      end

      return

    end

    for i in 0..5

      if @input_window[i].active

        loop do

          Graphics.update

          Input.update

          @input_window[i].update

          update_input(i)

          if !@input_window[i].active

            break

          end

        end

        return

      end

    end

    if @confirm_window.active

      loop do

        Graphics.update

        Input.update

        @confirm_window.update

        update_confirm

        if !@confirm_window.active

          break

        end

      end

      return

    end

    if Input.repeat?(Input.dir8)

      $game_system.se_play($data_system.cursor_se)

      update_cursor

      update_help

    end

    if Input.trigger?(Input::A)

      $game_system.se_play($data_system.decision_se)

      x, y = @cursor.tile_x, @cursor.tile_y

      visible = @board.visible?(x, y) == true ? false : true

      @board.visible(x, y, visible)

      @help_sprite.refresh

      @help_sprite.update

      return

    end

    if Input.trigger?(Input::B)

      $game_system.se_play($data_system.cancel_se)

      @confirm_window.index = 0

      @confirm_window.active = true

      @confirm_window.visible = true

      return

    end

    if Input.trigger?(Input::C)

      $game_system.se_play($data_system.decision_se)

      @command_window.index = 0

      @command_window.active = true

      @command_window.visible = true

      return

    end

  end

  #--------------------------------------------------------------------------

  # * Help Update

  #--------------------------------------------------------------------------

  def update_help

    x, y = @cursor.tile_x, @cursor.tile_y

    if @board.valid?(x, y)

      @help_sprite.true_y = 360

      @help_sprite.true_opacity = 255

    else

      @help_sprite.true_y = 370

      @help_sprite.true_opacity = 0

    end

  end

  #--------------------------------------------------------------------------

  # * Cursor Update

  #--------------------------------------------------------------------------

  def update_cursor

    xs, ys = TILE_X_SIZE, TILE_Y_SIZE

    max_x = 640 / xs - 1

    max_y = 480 / ys - 1

    margin = BOARD_MARGIN

    case Input.dir8

    when 2  # Down

      @cursor.tile_y += 1

      if @cursor.py < max_y - margin

        @cursor.py += 1

      elsif @cursor.tile_y >= @board.ysize

        @cursor.py = margin

      end

    when 4  # Left

      @cursor.tile_x -= 1

      if @cursor.px > margin

        @cursor.px -= 1

      elsif @cursor.tile_x < 0

        @cursor.px = max_x - margin

      end

    when 6  # Right

      @cursor.tile_x += 1

      if @cursor.px < max_x - margin

        @cursor.px += 1

      elsif @cursor.tile_x >= @board.xsize

        @cursor.px = margin

      end

    when 8  # Up

      @cursor.tile_y -= 1

      if @cursor.py > margin

        @cursor.py -= 1

      elsif @cursor.tile_y < 0

        @cursor.py = max_y - margin

      end

    end

    @cursor.tile_x %= @board.xsize

    @cursor.tile_y %= @board.ysize

    cx = (@cursor.px - @cursor.tile_x) * xs

    cy = (@cursor.py - @cursor.tile_y) * ys

    @spriteset.tiles.true_x  = cx

    @spriteset.tiles.true_y  = cy

    @spriteset.icons.true_x  = cx

    @spriteset.icons.true_y  = cy

    @spriteset.active.true_x = cx

    @spriteset.active.true_y = cy

    @cursor.true_x = (@cursor.px * xs) - 20

    @cursor.true_y = (@cursor.py * ys) - 4

  end

  #--------------------------------------------------------------------------

  # * Command Window Update

  #--------------------------------------------------------------------------

  def update_command

    if Input.trigger?(Input::B)

      $game_system.se_play($data_system.cancel_se)

      @command_window.index = -1

      @command_window.active = false

      @command_window.visible = false

      @command_window.update

      @help_sprite.refresh

      update_help

      return

    end

    if Input.trigger?(Input::C)

      $game_system.se_play($data_system.decision_se)

      length = @commands.length - 1

      if @command_window.index == length

        @command_window.index = -1

        @command_window.active = false

        @command_window.visible = false

        @command_window.update

        x, y = @cursor.tile_x, @cursor.tile_y

        @board.reset_tile(x, y)

        @spriteset.refresh

        @help_sprite.refresh

        update_help

      else

        @command_window.active = false

        @command_window.update

        @input_window[0].number = 0

        @input_window[0].active = true

        @input_window[0].visible = true

        @input_window[0].update

      end

      return

    end

  end

  #--------------------------------------------------------------------------

  # * Input Window Update

  #--------------------------------------------------------------------------

  def update_input(i)

    if Input.trigger?(Input::B)

      $game_system.se_play($data_system.cancel_se)

      if i == 0

        @command_window.active = true

        @command_window.update

      else

        @input_window[i - 1].active = true

        @input_window[i - 1].visible = true

        @input_window[i - 1].update

      end

      @input_window[i].active = false

      @input_window[i].visible = false

      @input_window[i].update

      return

    end

    if Input.trigger?(Input::C)

      $game_system.se_play($data_system.decision_se)

      @input_window[i].active = false

      @input_window[i].update

      if i == 5

        @command_window.visible = false

        for i in 0..5

          @input_window[i].visible = false

        end

        x, y = @cursor.tile_x, @cursor.tile_y

        input = [@input_window[4].number, @command_window.index,

                 @input_window[0].number, @input_window[1].number,

                 @input_window[2].number, @input_window[3].number,

                 @input_window[5].number == 0 ? -1 : @input_window[5].number]

        @board.set_tile(x, y, input)

        @spriteset.refresh

        @help_sprite.refresh

        update_help

      else

        @input_window[i + 1].number = 0

        @input_window[i + 1].active = true

        @input_window[i + 1].visible = true

        @input_window[i + 1].update

      end

      return

    end

  end

  #--------------------------------------------------------------------------

  # * Confirm Window Update

  #--------------------------------------------------------------------------

  def update_confirm

    if Input.trigger?(Input::B)

      $game_system.se_play($data_system.cancel_se)

      @confirm_window.index = -1

      @confirm_window.active = false

      @confirm_window.visible = false

      @confirm_window.update

      return

    end

    if Input.trigger?(Input::C)

      if @confirm_window.index == 0

        $game_system.se_play($data_system.decision_se)

        boards = get_boards

        boards[@board.id] = @board.board

        save_boards(boards)

      end

      @confirm_window.index = -1

      @confirm_window.active = false

      @confirm_window.visible = false

      @confirm_window.update

      $scene = Scene_EditBoard.new(@board.id)

      return

    end

  end

end

 

Code:
#==============================================================================

# ** Board

#------------------------------------------------------------------------------

#

#  This class defines a board and all of its settings. Board data is found in

#  the Data folder under the name Board.rxdata. Refer to the Board Module in

#  order to learn how to make a Board.rxdata file.

#

#------------------------------------------------------------------------------

#

#  Boards.rxdata

#

#  Boards are stored in Table[] BOARDS.

#

#      BOARDS = Table[BOARD_0, BOARD_1, BOARD_2, ...]

#

#  Each board is a Table with three dimensions (x, y, z), BOARD_n, where n is

#  an integer equal to or greater than 0.

#

#      BOARD_n = Table.new(x, y, z)

#

#  Dimensions x and y measure, respectively, the Table's width and height.

#  Dimension z manages attributes such as ACTIVATED, VISIBLE, AP COST, TYPE,

#  VALUE and LEVEL. This data is stored as integers.

#

#  If BOARD_n[x, y, 0] = v, this means the space occupied by the coordinate

#  (x, y) when z is equal to 0 is equal to v. If v is equal to 0, then tile

#  (x, y) is false or NOT ACTIVATED. If v is equal to 1, then tile (x, y) is

#  true or ACTIVATED.

#

#  The following figure outlines the board data structure:

#

#      x : 24 (default)

#      y : 24 (default)

#      z :

#          0 : ACTIVATED

#              0 : false

#              1 : true

#          1 : VISIBLE

#              0 : false

#              1 : true

#          2 : AP COST

#          3 : TYPE

#              -1 : nothing

#              0  : hp

#              1  : mp

#              2  : str

#              3  : pdef

#              4  : int

#              5  : mdef

#              6  : agi

#              7  : dex

#              8  : skill

#              9  : weapon

#              10 : armor

#          4, 5, 6, 7 : VALUE

#              statistic boost

#              skill id

#              weapon id

#              armor id

#          8 : LEVEL

#

#  By default, all slots are NOT ACTIVATED, NOT VISIBLE, AP COST 0, TYPE -1,

#  VALUE 0 and LEVEL -1.

#

#  The following code excerpt creates an empty board:

#

#    BOARD_n = Table.new(24, 24, 9)

#    for x in 0...BOARD_n.xsize

#      for y in 0...BOARD_n.ysize

#        for z in 0...BOARD_n.zsize

#          case z

#          when 0  # ACTIVATED

#            BOARD_n[x, y, z] = 0

#          when 1  # VISIBLE

#            BOARD_n[x, y, z] = 0

#          when 2  # AP COST

#            BOARD_n[x, y, z] = 0

#          when 3  # TYPE

#            BOARD_n[x, y, z] = -1

#          when 4  # OBJECT 1 VALUE

#            BOARD_n[x, y, z] = 0

#          when 5  # OBJECT 2 VALUE

#            BOARD_n[x, y, z] = 0

#          when 6  # OBJECT 3 VALUE

#            BOARD_n[x, y, z] = 0

#          when 7  # OBJECT 4 VALUE

#            BOARD_n[x, y, z] = 0

#          when 8  # LEVEL

#            BOARD_n[x, y, z] = -1

#          end

#        end

#      end

#    end

#

#  Once created, boards can be edited manually. Simply type in a coordinate

#  (x, y), an attribute number and a value. Always start with OBJECT 1 VALUE,

#  since this value is necessary to compute board data. You might have up to

#  four different values in a single coordinate (x, y). Hence, if you're TYPE

#  is a skill, by activating tile (x, y) you can learn up to four skills.

#

#  The following code excerpt creates a coordinate (x, y) with four skills:

#

#      # Define ACTIVATED

#      BOARD_n[x, y, 0] = 0

#      # Define VISIBLE

#      BOARD_n[x, y, 1] = 0

#      # Define AP COST

#      BOARD_n[x, y, 2] = 40

#      # Define TYPE

#      BOARD_n[x, y, 3] = 8

#      # Define OBJECT 1 VALUE

#      BOARD_n[x, y, 4] = 1

#      # Define OBJECT 2 VALUE

#      BOARD_n[x, y, 5] = 2

#      # Define OBJECT 3 VALUE

#      BOARD_n[x, y, 6] = 3

#      # Define OBJECT 4 VALUE

#      BOARD_n[x, y, 7] = 4

#      # Define LEVEL

#      BOARD_n[x, y, 8] = 9

#

#  Tile (x, y) is NOT ACTIVATED and NOT VISIBLE. To activate tile (x, y), you

#  need to spend 40 ability points. Tile (x, y) TYPE is a skill with values

#  1, 2, 3 and 4. By activating this tile you will learn skills 1, 2, 3 and 4.

#

#   _____   The attribute AP COST appears in the lower left corner of the

#  |    9|  tile. The attribute LEVEL appears in the upper right corner of

#  |     |  the tile. If LEVEL is equal to -1, then no level will be shown

#  |40___|  and OBJECT 1 will be used as the tile's class name.

#

#  To write a file, simply edit the boards Method in the BOARDS Module and

#  type in the following code excerpt in the Main Class:

#

#      BOARDS::boards

#

#  Boards graphic files and text can be edited in the FFXII Module.

#

#==============================================================================

 

class Board

  #--------------------------------------------------------------------------

  # * Invariables

  #--------------------------------------------------------------------------

  include FFXII                           # FFXII module

  #--------------------------------------------------------------------------

  # * Public Instance Variables

  #--------------------------------------------------------------------------

  attr_reader   :id                       # board ID

  attr_reader   :board                    # board table

  attr_reader   :xsize                    # board x size

  attr_reader   :ysize                    # board y size

  attr_accessor :hp                       # health points

  attr_accessor :sp                       # special points

  attr_accessor :str                      # strength

  attr_accessor :pdef                     # physical defense

  attr_accessor :int                      # intelligence

  attr_accessor :mdef                     # magic defense

  attr_accessor :agi                      # agility

  attr_accessor :dex                      # dexterity

  attr_accessor :skills                   # skills

  attr_accessor :weapon_set               # weapon set

  attr_accessor :armor_set                # armor set

  #--------------------------------------------------------------------------

  # * Object Initialization

  #     board_id : board ID

  #--------------------------------------------------------------------------

  def initialize(board_id)

    @id = board_id

    @board = $data_boards[@id].dup

    @xsize = @board.xsize

    @ysize = @board.ysize

    reset

  end

  #--------------------------------------------------------------------------

  # * Reset Board

  #--------------------------------------------------------------------------

  def reset

    @hp = 0

    @sp = 0

    @str = 0

    @pdef = 0

    @int = 0

    @mdef = 0

    @agi = 0

    @dex = 0

    @skills = []

    @weapon_set = []

    @armor_set = []

  end

  #--------------------------------------------------------------------------

  # * Reset Tile

  #     x : board x-coordinate

  #     y : board y-coordinate

  #--------------------------------------------------------------------------

  def reset_tile(x, y)

    activated(x, y, false)

    visible(x, y, false)

    ap_cost(x, y, 0)

    type(x, y, -1)

    for i in 0..3

      value(x, y, 0, i)

    end

    level(x, y, -1)

  end

  #--------------------------------------------------------------------------

  # * Determine if Valid

  #     x : board x-coordinate

  #     y : board y-coordinate

  #--------------------------------------------------------------------------

  def valid?(x, y)

    return @board[x, y, 3] >= 0 rescue false

  end

  #--------------------------------------------------------------------------

  # * Activate Slot

  #     x       : board x-coordinate

  #     y       : board y-coordinate

  #     boolean : false / true

  #--------------------------------------------------------------------------

  def activate(x, y, boolean)

    @board[x, y, 0] = [false, true].index(boolean)

    for obj in 0..3

      n = value?(x, y, obj)

      case type?(x, y)

      when 0   # HP

        @hp += n

      when 1   # SP

        @sp += n

      when 2   # Strength

        @str += n

      when 3   # Physical Defense

        @pdef += n

      when 4   # Intelligence

        @int += n

      when 5   # Magic Defense

        @mdef += n

      when 6   # Agility

        @agi += n

      when 7   # Dexterity

        @dex += n

      when 8   # Skills

        @skills.push(n)

      when 9   # Weapon Set

        @weapon_set.push(n)

      when 10  # Armor Set

        @armor_set.push(n)

      end

    end

    if (y - 1) >= 0

      if valid?(x, y - 1)  # Up

        visible(x, y - 1, true)

      end

    end

    if (y + 1) < @board.ysize

      if valid?(x, y + 1)  # Down

        visible(x, y + 1, true)

      end

    end

    if (x - 1) >= 0

      if valid?(x - 1, y)  # Left

        visible(x - 1, y, true)

      end

    end

    if (x + 1) < @board.xsize

      if valid?(x + 1, y)  # Right

        visible(x + 1, y, true)

      end

    end

  end

  #--------------------------------------------------------------------------

  # * Set Activated

  #     x       : board x-coordinate

  #     y       : board y-coordinate

  #     boolean : false / true

  #--------------------------------------------------------------------------

  def activated(x, y, bool)

    @board[x, y, 0] = bool == true ? 1 : 0

  end

  #--------------------------------------------------------------------------

  # * Set Visible

  #     x       : board x-coordinate

  #     y       : board y-coordinate

  #     boolean : false / true

  #--------------------------------------------------------------------------

  def visible(x, y, bool)

    @board[x, y, 1] = bool == true ? 1 : 0

  end

  #--------------------------------------------------------------------------

  # * Set AP Cost

  #     x       : board x-coordinate

  #     y       : board y-coordinate

  #     ap_cost : AP cost

  #--------------------------------------------------------------------------

  def ap_cost(x, y, ap_cost)

    @board[x, y, 2] = ap_cost

  end

  #--------------------------------------------------------------------------

  # * Set Type

  #     x    : board x-coordinate

  #     y    : board y-coordinate

  #     type : type

  #--------------------------------------------------------------------------

  def type(x, y, type)

    @board[x, y, 3] = type

  end

  #--------------------------------------------------------------------------

  # * Set Value

  #     x     : board x-coordinate

  #     y     : board y-coordinate

  #     value : value

  #     obj   : object ID

  #--------------------------------------------------------------------------

  def value(x, y, value, obj = 0)

    @board[x, y, 4 + obj] = value

  end

  #--------------------------------------------------------------------------

  # * Set Level

  #     x     : board x-coordinate

  #     y     : board y-coordinate

  #     level : level

  #--------------------------------------------------------------------------

  def level(x, y, level)

    @board[x, y, 8] = level

  end

  #--------------------------------------------------------------------------

  # * Set Tile

  #     x         : board x-coordinate

  #     y         : board y-coordinate

  #     input     : input

  #--------------------------------------------------------------------------

  def set_tile(x, y, input)

    if input

      ap_cost(x, y, input[0])

      type(x, y, input[1])

      for i in 0..3

        value(x, y, input[2 + i], i)

      end

      level(x, y, input[6])

    end

  end

  #--------------------------------------------------------------------------

  # * Get Activated

  #     x : board x-coordinate

  #     y : board y-coordinate

  #--------------------------------------------------------------------------

  def activated?(x, y)

    return [false, true][@board[x, y, 0]]

  end

  #--------------------------------------------------------------------------

  # * Get Visible

  #     x : board x-coordinate

  #     y : board y-coordinate

  #--------------------------------------------------------------------------

  def visible?(x, y)

    return [false, true][@board[x, y, 1]]

  end

  #--------------------------------------------------------------------------

  # * Get AP Cost

  #     x : board x-coordinate

  #     y : board y-coordinate

  #--------------------------------------------------------------------------

  def ap_cost?(x, y)

    if @board[x, y, 2]

      return @board[x, y, 2]

    end

    return 0

  end

  #--------------------------------------------------------------------------

  # * Get Type

  #     x : board x-coordinate

  #     y : board y-coordinate

  #--------------------------------------------------------------------------

  def type?(x, y)

    if @board[x, y, 3]

      return @board[x, y, 3]

    end

    return -1

  end

  #--------------------------------------------------------------------------

  # * Get Value

  #     x   : board x-coordinate

  #     y   : board y-coordinate

  #     obj : object ID

  #--------------------------------------------------------------------------

  def value?(x, y, obj = 0)

    if @board[x, y, 4 + obj]

      return @board[x, y, 4 + obj]

    end

    return 0

  end

  #--------------------------------------------------------------------------

  # * Get Level

  #     x : board x-coordinate

  #     y : board y-coordinate

  #--------------------------------------------------------------------------

  def level?(x, y)

    if @board[x, y, 8]

      return @board[x, y, 8]

    end

    return -1

  end

  #--------------------------------------------------------------------------

  # * Get Board Name

  #--------------------------------------------------------------------------

  def name

    return BOARD_NAME(@id)

  end

  #--------------------------------------------------------------------------

  # * Get Board Statistics

  #--------------------------------------------------------------------------

  def statistics

    stats = []

    for x in [email=0...@board.xsize]0...@board.xsize[/email]

      for y in [email=0...@board.ysize]0...@board.ysize[/email]

        type = type?(x, y)

        if type >= 0 and type < 8

          value = value?(x, y)

        stats[type] += value rescue

          stats[type] = value

        elsif type >= 8

          for i in 0..3

            value = value?(x, y, i)

            if value > 0

              stats[type] += 1 rescue

              stats[type] = 1

            end

          end

        end

      end

    end

    return stats

  end

  #--------------------------------------------------------------------------

  # * Get Item

  #     x   : board x-coordinate

  #     y   : board y-coordinate

  #     obj : object ID

  #--------------------------------------------------------------------------

  def item(x, y, obj = 0)

    type = type?(x, y)

    value = value?(x, y, obj)

    return BOARD_ITEM(type, value)

  end

  #--------------------------------------------------------------------------

  # * Get Description

  #     x   : board x-coordinate

  #     y   : board y-coordinate

  #     obj : object ID

  #--------------------------------------------------------------------------

  def description(x, y, obj = 0)

    type = type?(x, y)

    value = value?(x, y, obj)

    return BOARD_DESCRIPTION(type, value)

  end

  #--------------------------------------------------------------------------

  # * Get Class

  #     x : board x-coordinate

  #     y : board y-coordinate

  #--------------------------------------------------------------------------

  def class(x, y)

    type = type?(x, y)

    value = value?(x, y)

    level = level?(x, y)

    return BOARD_CLASS(type, value, level)

  end

end

 

Code:
#==============================================================================

# ** Cursor_Board

#------------------------------------------------------------------------------

#  This sprite is used to display the cursor. It observes the Scene_Board

#  class and automatically changes sprite conditions.

#==============================================================================

 

class Cursor_Board < Sprite_Cursor

  #--------------------------------------------------------------------------

  # * Public Instance Variables

  #--------------------------------------------------------------------------

  attr_accessor :tile_x                   # tile x

  attr_accessor :tile_y                   # tile y

  attr_accessor :px                       # pan x

  attr_accessor :py                       # pan y

  #--------------------------------------------------------------------------

  # * Object Initialization

  #     board    : board

  #     x        : cursor x-coordinate

  #     y        : cursor y-coordinate

  #     viewport : viewport

  #--------------------------------------------------------------------------

  def initialize(board, x = 0, y = 0, viewport = nil)

    super(viewport)

    @board = board

    @tile_x, @tile_y = x, y

    @px, @py = 0, 0

  end

end

 

Code:
List::item_list
 
nah its fine if you are having internet troubles that is totally cool I understand how that could be sometimes. Dont sweat it. I have to say this looks rather cool and i like the idea a lot. :D
 

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