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.

Medina Stories License Board

I cracked the code, you fucktards. Finally, after five days of struggling, the stupid Action List window works! Fuck you.

Now I just have to organize the code, make a demo, and a video. Hopefully, I'll be releasing v2.0 tonight.

EDIT: The code now is now definitely finished. Now I'm uploading files and making a demo.
 
Excellent script, Juan Definitely one of my favorites.

I have this script set up to use different boards for each class, but this only affects the character's database class. The board stays the same when I change a character's class.

Would it be possible to make it so when a character's class changes, their class' license board ID also changes to the corresponding class' board ID? And would it be too difficult to have it where if a character's class changes, the character would keep all of their parameter increases and licenses that they activated after getting a new board ID?

I followed the instructions in the YouTube video's comments on how to make boards character specific, and just changed "if board_id == 1" to "if class_id == 1" for each board.

This is the edited script I currently have, it's merged with Moghunter's title screen to fix compatibility issues:

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 = "AP"

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

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

    when 5   # Magic Defense

      return "Increase magic resistance"

    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 ""

      elsif value >= 0 and value <= 6

        return "White Magic #{level}"

      elsif value >= 7 and value <= 32

        return "Black Magic #{level}"

      elsif value >= 33 and value <= 56

        return "Green Magic #{level}"

      elsif value >= 57 and value <= 80

        return "Arcane Magic #{level}"

      else

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

      end

    when 9   # Weapon Set

      if level == -1

        return ""

      elsif value >= 0 and value <= 4

        return "Swords #{level}"

      elsif value >= 5 and value <= 8

        return "Spears #{level}"

      elsif value >= 9 and value <= 12

        return "Axes #{level}"

      elsif value >= 13 and value <= 16

        return "Daggers #{level}"

      elsif value >= 17 and value <= 20

        return "Bows #{level}"

      elsif value >= 21 and value <= 24

        return "Guns #{level}"

      elsif value >= 25 and value <= 28

        return "Maces #{level}"

      elsif value >= 29 and value <= 32

        return "Poles #{level}"

      else

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

      end

    when 10  # Armor Set

      if level == -1

        return ""

      elsif value >= 0 and value <= 4

        return "Shields #{level}"

      elsif value >= 5 and value <= 8

        return "Helmets #{level}"

      elsif value >= 9 and value <= 12

        return "Hats #{level}"

      elsif value >= 13 and value <= 16

        return "Armors #{level}"

      elsif value >= 17 and value <= 20

        return "Breastplates #{level}"

      elsif value >= 21 and value <= 24

        return "Robes #{level}"

      elsif value >= 25 and value <= 32

        return "Rings #{level}"

      else

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

      end

    end

    return nil

  end

end

 

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

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

 

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

# ** List

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

#  This module contains global variables and classes.

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

 

module List

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

  # * Create item lists

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

  def 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}\n")

        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}\n")

      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}\n")

      end

    end

  end

end

 

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

# ** Game_Actor

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

#  This class handles the actor. It's used within the Game_Actors class

#  ($game_actors) and refers to the Game_Party class ($game_party).

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

 

class Game_Actor < Game_Battler

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

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

    

    

    

    

    

    

    

    ##############################

    # EDIT CUSTOM BOARD IDs HERE #

    ##############################

    

    @board = Board.new(1) if class_id == 1

    @board = Board.new(2) if class_id == 2

    @board = Board.new(3) if class_id == 3

    @board = Board.new(4) if class_id == 4

    @board = Board.new(5) if class_id == 5

    @board = Board.new(6) if class_id == 6

    @board = Board.new(7) if class_id == 7

    @board = Board.new(8) if class_id == 8

    @board = Board.new(9) if class_id == 9

    @board = Board.new(10) if class_id == 10

    @board = Board.new(11) if class_id == 11

    @board = Board.new(12) if class_id == 12

    @board = Board.new(13) if class_id == 13

    @board = Board.new(14) if class_id == 14

    @board = Board.new(15) if class_id == 15

    @board = Board.new(16) if class_id == 16

    @board = Board.new(17) if class_id == 17

    @board = Board.new(18) if class_id == 18

    @board = Board.new(19) if class_id == 19

    @board = Board.new(20) if class_id == 20

    @board = Board.new(21) if class_id == 21

    @board = Board.new(22) if class_id == 22

    @board = Board.new(23) if class_id == 23

    @board = Board.new(24) if class_id == 24

    @board = Board.new(25) if class_id == 25

    @board = Board.new(26) if class_id == 26

    @board = Board.new(27) if class_id == 27

    @board = Board.new(28) if class_id == 28

    @board = Board.new(29) if class_id == 29

    @board = Board.new(30) if class_id == 30

    @board = Board.new(31) if class_id == 31

    @board = Board.new(32) if class_id == 32

    @board = Board.new(33) if class_id == 33

    @board = Board.new(34) if class_id == 34

    @board = Board.new(35) if class_id == 35

    @board = Board.new(36) if class_id == 36

    @board = Board.new(37) if class_id == 37

    @board = Board.new(38) if class_id == 38

    @board = Board.new(39) if class_id == 39

    @board = Board.new(40) if class_id == 40

    @board = Board.new(41) if class_id == 41

    @board = Board.new(42) if class_id == 42

    @board = Board.new(43) if class_id == 43

    @board = Board.new(44) if class_id == 44

    @board = Board.new(45) if class_id == 45

    @board = Board.new(46) if class_id == 46

    @board = Board.new(47) if class_id == 47

    @board = Board.new(48) if class_id == 48

    @board = Board.new(49) if class_id == 49

    @board = Board.new(50) if class_id == 50

    @board = Board.new(51) if class_id == 51

    @board = Board.new(52) if class_id == 52

    @board = Board.new(53) if class_id == 53

    @board = Board.new(54) if class_id == 54

    @board = Board.new(55) if class_id == 55

    @board = Board.new(56) if class_id == 56

    @board = Board.new(57) if class_id == 57

    @board = Board.new(58) if class_id == 58

    @board = Board.new(59) if class_id == 59

    @board = Board.new(60) if class_id == 60

    @board = Board.new(61) if class_id == 61

    @board = Board.new(62) if class_id == 62

    @board = Board.new(63) if class_id == 63

    @board = Board.new(64) if class_id == 64

    @board = Board.new(65) if class_id == 65

    @board = Board.new(66) if class_id == 66

    @board = Board.new(67) if class_id == 67

    @board = Board.new(68) if class_id == 68

    @board = Board.new(69) if class_id == 69

    @board = Board.new(70) if class_id == 70

    @board = Board.new(71) if class_id == 71

    @board = Board.new(72) if class_id == 72

    @board = Board.new(73) if class_id == 73

    @board = Board.new(74) if class_id == 74

    @board = Board.new(75) if class_id == 75

    @board = Board.new(76) if class_id == 76

    @board = Board.new(77) if class_id == 77

    @board = Board.new(78) if class_id == 78

    @board = Board.new(79) if class_id == 79

    @board = Board.new(80) if class_id == 80

    @board = Board.new(81) if class_id == 81

    @board = Board.new(82) if class_id == 82

    @board = Board.new(83) if class_id == 83

    @board = Board.new(84) if class_id == 84

    @board = Board.new(85) if class_id == 85

    @board = Board.new(86) if class_id == 86

    @board = Board.new(87) if class_id == 87

    @board = Board.new(88) if class_id == 88

    @board = Board.new(89) if class_id == 89

    @board = Board.new(90) if class_id == 90

    @board = Board.new(91) if class_id == 91

    @board = Board.new(92) if class_id == 92

    @board = Board.new(93) if class_id == 93

    @board = Board.new(94) if class_id == 94

    @board = Board.new(95) if class_id == 95

    @board = Board.new(96) if class_id == 96

    @board = Board.new(97) if class_id == 97

    @board = Board.new(98) if class_id == 98

    @board = Board.new(99) if class_id == 99

    

    

    

    @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.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

 

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

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

 

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

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

 

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

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

 

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

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

 

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

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

 

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

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

 

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

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

 

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

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

    if board.ap_cost?(bx, by) > 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

  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)

    if board.ap_cost?(bx, by) > 0

      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

  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

 

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

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

 

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

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

 

 

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

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

 

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

# ** Window_BoardSelectable

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

#  This window class contains cursor movement and scroll functions.

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

 

class Window_BoardSelectable < Window_Base

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

  # * Public Instance Variables

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

  attr_reader   :index                    # cursor position

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

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

    @scroll_y = 0

    @scroll_speed = 5

    @cursor = Sprite_Cursor.new

    @cursor.z = 65536

    update_cursor

  end

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

  # * Set Cursor Position

  #     index : new cursor position

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

  def index=(index)

    @index = index

    update_cursor_rect

  end

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

  # * Get Row Count

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

  def row_max

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

  end

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

  # * Get Top Row

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

  def top_row

    return @scroll_y / (self.contents.height / row_max) rescue 0

  end

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

  # * Set Top Row

  #     row : row shown on top

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

  def top_row=(row)

    if row < 0

      row = 0

    elsif row > row_max - 1

      row = row_max - 1

    end

    @scroll_y = row * ((self.height - 32) / page_row_max)

  end

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

  # * Get Number of Rows Displayable on 1 Page

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

  def page_row_max

    return (self.height - 32) / (self.contents.height / row_max) rescue 1

  end

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

  # * Get Number of Items Displayable on 1 Page

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

  def page_item_max

    return page_row_max * @column_max

  end

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

  # * Update Cursor Rectangle

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

  def update_cursor_rect

    if @index < 0

      self.cursor_rect.empty

      return

    end

    row = @index / @column_max

    if row < self.top_row

      self.top_row = row

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

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

    end

    cursor_width = (self.width - 32) / @column_max

    x = @index % @column_max * cursor_width

    y = @index / @column_max * (self.contents.height / row_max) -

        @scroll_y rescue 0

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

  end

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

  # * Frame Update

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

  def update

    super

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

      if Input.repeat?(Input::DOWN)

        if Input.press?(Input::SHIFT)

          $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

          $game_system.se_play($data_system.cursor_se)

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

        end

      end

      if Input.repeat?(Input::UP)

        if Input.press?(Input::SHIFT)

          $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

          $game_system.se_play($data_system.cursor_se)

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

        end

      end

      if Input.repeat?(Input::RIGHT)

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

          $game_system.se_play($data_system.cursor_se)

          @index += 1

        end

      end

      if Input.repeat?(Input::LEFT)

        if @column_max >= 2 and @index > 0

          $game_system.se_play($data_system.cursor_se)

          @index -= 1

        end

      end

      if Input.repeat?(Input::R)

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

          $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 Input.repeat?(Input::L)

        if self.top_row > 0

          $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_cursor_rect

    update_scroll

    update_cursor

  end

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

  # * Update Cursor

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

  def update_cursor

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

    @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 self.oy < @scroll_y

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

      n = 1 if n == 0

      self.oy += n

    elsif self.oy > @scroll_y

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

      n = 1 if n == 0

      self.oy -= n

    end

  end

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

  # * Dispose

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

  def dispose

    @cursor.dispose

    super

  end

end

 

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

# ** 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 = "")

    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

  #     x     : item x-coordinate

  #     y     : item y-coordinate

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

  def draw_item(index, x, y)

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

  end

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

  # * Update Cursor

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

  def update_cursor

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

    correction = @index % @item_max * 16

    @cursor.true_y = self.cursor_rect.y + self.y + 48 - correction

    @cursor.update

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

  end

end

 

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

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

    rows_max = (@item_max + @column_max - 1) / @column_max

    self.contents = Bitmap.new(width - 32, rows_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

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

  # * Update Cursor

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

  def update_cursor

    correction = @index % @column_max * 5

    @cursor.true_x = self.cursor_rect.x + self.x + 26 - correction

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

    @cursor.update

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

  end

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

  # * Dispose

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

  def dispose

    self.contents.clear

    @bg.dispose

    @shadow_sprite.dispose

    super

  end

end

 

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

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

 

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

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

 

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

# ** Window_EditBoardKey

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

#  This window designates boards on the board edit screen.

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

 

class Window_EditBoardKey < Window_Base

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

  # * Object Initialization

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

  def initialize

    super(0, 352, 192, 128)

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

    refresh

  end

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

  # * Refresh

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

  def refresh

    self.contents.draw_text(0, 0,  152, 32, "A: Delete")

    self.contents.draw_text(0, 32, 152, 32, "B: Cancel")

    self.contents.draw_text(0, 64, 152, 32, "C: Decision")

  end

end

 

 

 

 

 

 

 

 

module MOG

  #Ativar fullScreen automático.  

  FULL_SCREEN = false

  #Velocidade da animação

  BACKTITLESPEED = 10

  #Posição do comando.

  COM_X = 0  # Com X Pos

  COM_Y = 0  # Com Y Pos

end

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

# Scene_Title

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

$mogscript = {} if $mogscript == nil

$mogscript["title_celia"] = true

$full_screen = 0

class Scene_Title

  include Boards 

  def main

    if $BTEST

      battle_test

      return

    end

    $full_screen += 1

    if MOG::FULL_SCREEN == true and $full_screen == 1

    $showm = Win32API.new 'user32', 'keybd_event', %w(l l l l), ' ' 

    $showm.call(18,0,0,0) 

    $showm.call(13,0,0,0) 

    $showm.call(13,0,2,0) 

    $showm.call(18,0,2,0)

    end             

    $data_actors        = load_data("Data/Actors.rxdata")

    $data_classes       = load_data("Data/Classes.rxdata")

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

    $data_items         = load_data("Data/Items.rxdata")

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

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

    $data_enemies       = load_data("Data/Enemies.rxdata")

    $data_troops        = load_data("Data/Troops.rxdata")

    $data_states        = load_data("Data/States.rxdata")

    $data_animations    = load_data("Data/Animations.rxdata")

    $data_tilesets      = load_data("Data/Tilesets.rxdata")

    $data_common_events = load_data("Data/CommonEvents.rxdata")

    $data_system        = load_data("Data/System.rxdata")

    

    

    

    # Load Boards.rxdata, create new if it does not exist

    $data_boards = get_boards

    if $data_boards.empty?

      new_board(NEW_BOARD_XSIZE, NEW_BOARD_YSIZE)

      p "New Boards.rxdata file created!"

    end

    

    

    

    $game_system = Game_System.new

    s1 = "New Game"

    s2 = "Continue"

    s3 = "Shutdown"

    @command_window = Window_Command.new(192, [s1, s2, s3])

    @command_window.back_opacity = 160

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

    @command_window.y = 288

    @command_window.visible = false

    @com = Sprite.new

    @com.bitmap = RPG::Cache.title("Com_01") rescue nil 

    @com.z = 10

    @com.x = (MOG::COM_X)

    @com.y = (MOG::COM_Y)

    @continue_enabled = false

    @frmtitle = Sprite.new

    @frmtitle.bitmap = Bitmap.new(640,480)

    @frmtitle.bitmap = RPG::Cache.title("Title0") rescue nil 

    @backtitleref = 0 

    @backtitlespeed = 0

    for i in 0..3

      if FileTest.exist?("Save#{i+1}.rxdata")

        @continue_enabled = true

      end

    end

    if @continue_enabled

      @command_window.index = 1

    else

      @command_window.disable_item(1)

    end

    $game_system.bgm_play($data_system.title_bgm)

    Audio.me_stop

    Audio.bgs_stop

    Graphics.transition

    loop do

      Graphics.update

      Input.update

      update

      if $scene != self

        break

      end

    end

    Graphics.freeze

    @command_window.dispose

    @frmtitle.dispose

    @com.dispose

  end

  def update

    @command_window.update

     case @command_window.index

     when 0

     @com.bitmap = RPG::Cache.title("Com_01") rescue nil       

     when 1

     @com.bitmap = RPG::Cache.title("Com_02") rescue nil       

     when 2

     @com.bitmap = RPG::Cache.title("Com_03") rescue nil 

     end       

    if Input.trigger?(Input::C)

      case @command_window.index

      when 0  

        command_new_game

      when 1  

        command_continue

      when 2 

        command_shutdown

      end

    end

     @backtitlespeed += 1    

  if @backtitlespeed > MOG::BACKTITLESPEED 

     @backtitleref += 1

     @backtitlespeed = 0

  end

  if @frmtitle.bitmap != nil 

  @frmtitle.bitmap = RPG::Cache.title("Title" + @backtitleref.to_s) rescue nil

  end

  if @frmtitle.bitmap == nil 

     @backtitleref = 0 

  @frmtitle.bitmap = RPG::Cache.title("Title" + @backtitleref.to_s) rescue nil

  end  

  end

  def command_new_game

    $game_system.se_play($data_system.decision_se)

    Audio.bgm_stop

    Graphics.frame_count = 0

    $game_temp          = Game_Temp.new

    $game_system        = Game_System.new

    $game_switches      = Game_Switches.new

    $game_variables     = Game_Variables.new

    $game_self_switches = Game_SelfSwitches.new

    $game_screen        = Game_Screen.new

    $game_actors        = Game_Actors.new

    $game_party         = Game_Party.new

    $game_troop         = Game_Troop.new

    $game_map           = Game_Map.new

    $game_player        = Game_Player.new

    $game_party.setup_starting_members

    $game_map.setup($data_system.start_map_id)

    $game_player.moveto($data_system.start_x, $data_system.start_y)

    $game_player.refresh

    $game_map.autoplay

    $game_map.update

    

    

    

    

    

    

    

    

    #Disable Prologue?

    $scene = Scene_Map.new

    #$scene = Scene_Prologue.new

    #######################

    

    

    

    

    

    

    

    

    #

  end

  def command_continue

    unless @continue_enabled

      $game_system.se_play($data_system.buzzer_se)

      return

    end

    $game_system.se_play($data_system.decision_se)

    $scene = Scene_Load.new

  end

  def command_shutdown

    $game_system.se_play($data_system.decision_se)

    Audio.bgm_fade(800)

    Audio.bgs_fade(800)

    Audio.me_fade(800)

    $scene = nil

  end

  def battle_test

    $data_actors        = load_data("Data/BT_Actors.rxdata")

    $data_classes       = load_data("Data/BT_Classes.rxdata")

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

    $data_items         = load_data("Data/BT_Items.rxdata")

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

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

    $data_enemies       = load_data("Data/BT_Enemies.rxdata")

    $data_troops        = load_data("Data/BT_Troops.rxdata")

    $data_states        = load_data("Data/BT_States.rxdata")

    $data_animations    = load_data("Data/BT_Animations.rxdata")

    $data_tilesets      = load_data("Data/BT_Tilesets.rxdata")

    $data_common_events = load_data("Data/BT_CommonEvents.rxdata")

    $data_system        = load_data("Data/BT_System.rxdata")

    Graphics.frame_count = 0

    $game_temp          = Game_Temp.new

    $game_system        = Game_System.new

    $game_switches      = Game_Switches.new

    $game_variables     = Game_Variables.new

    $game_self_switches = Game_SelfSwitches.new

    $game_screen        = Game_Screen.new

    $game_actors        = Game_Actors.new

    $game_party         = Game_Party.new

    $game_troop         = Game_Troop.new

    $game_map           = Game_Map.new

    $game_player        = Game_Player.new

    $game_party.setup_battle_test_members

    $game_temp.battle_troop_id = $data_system.test_troop_id

    $game_temp.battle_can_escape = true

    $game_map.battleback_name = $data_system.battleback_name

    $game_system.se_play($data_system.battle_start_se)

    $game_system.bgm_play($game_system.battle_bgm)

    $scene = Scene_Battle.new

  end

end

 

 

 

 

 

 

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

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

 

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

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

 

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

# ** Scene_EditBoard

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

#  This class performs board edit screen processing.

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

 

class Scene_EditBoard

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

  # * Invariables

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

  include FFXII                           # FFXII module

  include Boards                          # Boards module

  include List                            # List module

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

  # * Object Initialization

  #     index : index

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

  def initialize(index = 0)

    @index = index

    item_list

  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

 

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

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

 

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

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

 

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

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

 

 

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

# Custom AP Stuff

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

 

class Scene_Battle

  include FFXII

  def gain_exp

    exp = exp_gained

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

      actor = $game_party.actors[i]

      

      # Gain AP instead of EXP

      actor.ap += exp_gained

    end

    return exp

  end

end

 

Also, the scripts I am using are:
Ultimate Splash Scene 3.1.2 Plug-n-Play Edition
Glitchfinder's Multiple Timers
FFXII License Board (Merged with Moghunter's Title Screen for compatibility)
Wachunga's Auto Font Installer
RPG Advocate's Custom Debugger
Fantasist's Transition Pack
Modified Advanced Weather System
Guillaume777's Multi-Slot Equipment
Nechigawara's Skill Shop
Prexus' Music Selector
MiDas Mike's Credits (duplicate for prologue)
PreXCraft
SephirothSpawn's Slanted Bars
Cogwheel's Pixelmovement
Tileset Changer
All of Moghunter's Menu enhancements (except the level up one, it's not compatible with something.)

I don't know exactly how your script works, or if you'd have to totally rewrite it for this to happen, but I would be eternally grateful if you could make it work like that. I have 88 different board IDs for each class if that helps. Thanks in advance.
 
Rathuldr, it wouldn't be too difficult to change the board according to each character's class. However, this can't be done directly with my script, it must be done with whatever script you're using to change character classes. It must be done like this, since the Game_Actor class isn't regularly updated.

As for keeping all of the learned parameters, this would require extensive rewriting of the script, particularly the Game_Actor class. Here's the updated version of the Game_Actor class, if you're interested in giving it a shot.

Ruby:
#==============================================================================

# ** 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                           # Final Fantasy XII module

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

  # * Public Instance Variables

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

  attr_reader   :board                    # board ID

  attr_reader   :ap                       # ability points

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

  # * Setup

  #     actor_id : actor ID

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

  alias mslb_game_actor_setup setup

  def setup(actor_id)

    board_id = actor_id == 1 ? 0 :

               actor_id == 2 ? 1 :

               actor_id == 3 ? 0 :

               actor_id == 4 ? 1 :

               actor_id == 5 ? 0 :

               actor_id == 6 ? 1 : 0

    @board = Board.new(board_id)

    @ap = 0

    mslb_game_actor_setup(actor_id)

  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

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

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

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

  # * Skills

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

  def skills

    @board.skills.sort!

    skills = @board.skills | @skills

    return skills

  end

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

  # * Determine if Finished Learning Skill

  #     skill_id : skill ID

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

  def skill_learn?(skill_id)

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

  end

end

I won't do this for you, but I can help you out. I would suggest you have a boards array in the Game_Actor class and have a new variable called current board. Then you simply have to edit the Game_Actor methods to go through all of the boards. You can do this with a simply loop.

If you're not familiar with scripting, find someone to do this for you. If you need help, I'll gladly be of assistance.
 
Guys, it's finally done, demo and everything. I didn't make a new video. I don't think it's necessary (as the previous video covers all the basics). However, I took a bunch of screenshots to show the differences. I hope you guys like it!

MSLB0008.png
MSLB0007.png
MSLB0006.png
MSLB0005.png
MSLB0004.png
MSLB0003.png
MSLB0002.png
MSLB0001.png
 
wooot its awesome :thumb: well its already awesome, now its even more :lol: you certainly out did your self for making this @Juan J.Sanchez
havent tinker further with this, but so far its all smooth :thumb:
its a bit laggy when reading description skill that comes out when press X (A keyboard) meaning the finger icon got a bit laggy if we move too fast or keep pressing left/right (i think it happen when the skill already opened) not that big of a problem though. just want to let you know :thumb:
 
Sadly, I think I've optimized the code as much as I can. Having so much heavy graphics really takes a blow on memory. My only advice would be smaller graphics. Thanks, by the way. I really feel like it's done.
 
hi guys, i dont want to bother you but the download links are not working, I'd really like to try this awesome system :smile:
please, it would be really nice if someone reuploaded the v2.0.0 demo or even just the pictures folder required for test the script, thank you so much in advance, have a nice day :thumb:
 
I'm more than retired from RPG Maker. It heavily interferes with my studies and considering I study medicine I really can't afford not to study. You know, people might die or something.
 
Very well done sir, :P A lot better than mine :<
815f40c8301a26b7fc50c3824470fbaa.png


Q_Q, But hey thats fine, Mind If I link it on my blog? Also is it okay if I use some of those graphics in my future projects? i got a few ideas from this :3
 

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