Licence Board Problems...

Started by Viviatus, August 24, 2008, 06:06:25 am

Previous topic - Next topic

Viviatus

Well I extracted the Licence Board script from that FFXII Script compilation. It works fine so far. There're only two things that I can't semm to get solved:
1st: How the hell do the character EARN LP in order to learn things from the board?
2nd: The battle scense lag like hell... how can this be fixed?

Would be really cool if someone could see through the code and get it cleaned or rather tell me how to add/solve my probs. These script needs an License.rxdata which stores the different boards for each character, if you really wanna help me I could send it, since I'm too lazy to get it uploaded.

I'd really appreciate it.

Scripts: ShowHide
class Game_Actor < Game_Battler
 
  attr_accessor :active
  attr_accessor :lp
  attr_reader   :licence_table
 
  #-----------------------------------------------------------------------------
  # Alias
  #-----------------------------------------------------------------------------
   
  unless method_defined?("ffxii_abs_gactor_initialize")
    alias ffxii_abs_gactor_initialize initialize
    alias ffxii_abs_gactor_setup setup
  end
 
  #-----------------------------------------------------------------------------
  # Inicialização
  #-----------------------------------------------------------------------------
   
  def initialize(actor_id)
    @active = false
    ffxii_abs_gactor_initialize(actor_id)
  end
 
  def setup(actor_id)
    ffxii_abs_gactor_setup(actor_id)
    @test_licence_table = (FFXII::LICENCES.data[actor_id].nil? ? nil : FFXII::LICENCES.data[actor_id].dup)
    if @test_licence_table.nil?
      @test_licence_table = (FFXII::LICENCES.data[0].nil? ? Licence_Table.new : FFXII::LICENCES.data[0].dup)
    end
    @licence_table = Licence_Table.new
    for x in 0...FFXII::LICENCES::MAX_LICENCES_WIDTH
      for y in 0...FFXII::LICENCES::MAX_LICENCES_HEIGHT
        @licence_table[x, y] = Licence_Spot.new(x, y, "", 0)
        unless @test_licence_table[x, y].nil?
          if @test_licence_table[x, y].get
            case @test_licence_table[x, y].type
            when "hp"
              self.maxhp += @test_licence_table[x, y].id
            when "sp"
              self.maxsp += @test_licence_table[x, y].id
            when "str"
              self.str += @test_licence_table[x, y].id
            when "dex"
              self.dex += @test_licence_table[x, y].id
            when "agi"
              self.agi += @test_licence_table[x, y].id
            when "int"
              self.int += @test_licence_table[x, y].id
            when "skill"
              self.learn_skill(@test_licence_table[x, y].id)
            when "skill_licence"
              self.learn_skill_licence(@test_licence_table[x, y].id)
            end
          end
          @licence_table[x, y].setup(@test_licence_table[x, y])
        end
      end
    end
    @licence_table.refresh_table
    @lp = 0
  end
end
#===============================================================================
# módulo FFXII::LICENCES
#-------------------------------------------------------------------------------
# Criador: RTH
#===============================================================================
module RPG::Cache
  def self.licence(name)
    return self.load_bitmap("Graphics/Licences/", name, 0)
  end
 
end




module FFXII
 
  module LICENCES
   
    #---------------------
    # INSTRUÇÕES
    #---------------------
    # To create the licence board, call:
    # $scene = Scene_Create_Licences.new(Hero ID)
    # To create de default board, call:
    # $scene = Scene_Create_Licences.new(0)
    # All the heros who don't have a board, the default one will be used.
    #---------------------
   
    # Licence table max width
    MAX_LICENCES_WIDTH = 20
    # Licence table max height
    MAX_LICENCES_HEIGHT = 15
    # Licence Points String
    LICENCE_POINTS_S = "LP"
    # Licence Points Cost String
    LICENCE_POINTS_COST_S = "LP Cost"
    # Table pictures
    PICTURE_SQUARE = ["Black", "White"]
   
    # Pictures' name
    # Folder: Graphics/Licences
    LICENCE_PICTURES = {}
    LICENCE_PICTURES["hp"]    = "HP"
    LICENCE_PICTURES["sp"]    = "SP"
    LICENCE_PICTURES["str"]   = "STR"
    LICENCE_PICTURES["dex"]   = "DEX"
    LICENCE_PICTURES["agi"]   = "AGI"
    LICENCE_PICTURES["int"]   = "INT"
    LICENCE_PICTURES["skill"] = "SKILL"
    LICENCE_PICTURES["skill_licence"] = "SKILL"
   
    # Back
    LICENCE_BACK = "Back"
    # Back OX/OY speed
    LICENCE_BACK_OX_SPEED = -1
    LICENCE_BACK_OY_SPEED = -1
   
    # Amount of LP won by defeating an enemy (default)
    ENEMIES_LP_DEFAULT = [10, 50, 80]
    # Invariável
    ENEMIES_LP = []
    # Amount of LP won by defeating an enemy
    # ENEMIES_LP[Enemy id] = X
   
    @@data = nil
   
    def self.data
      if @@data.nil?
        @@data = load_data("Data/Licences.rxdata")
      end
      return @@data
    end
   
  end 
 
end


#===============================================================================
# FFXII - Licence_Spot
#-------------------------------------------------------------------------------
# Criador: RTH
#===============================================================================

class Licence_Spot
 
  attr_accessor :x
  attr_accessor :y
  attr_accessor :type
  attr_accessor :id
  attr_accessor :cost
  attr_accessor :get
  attr_accessor :near
 
  def initialize(x, y, type, id, cost=1)
    @x = x
    @y = y
    @type = type
    @id = id
    @cost = cost
    @get = false
    @near = false
  end
 
  def setup(spot)
    return unless spot.is_a?(Licence_Spot)
    @x = spot.x
    @y = spot.y
    @type = spot.type
    @id = spot.id
    @cost = spot.cost
    @get = spot.get
    @near = spot.near
  end
 
end

#===============================================================================
# FFXII - Licence_Table
#-------------------------------------------------------------------------------
# Criador: RTH
#===============================================================================

class Licence_Table
 
  def initialize
    @data = []
  end
 
  def [](x, y)
    if @data[x].nil?
      @data[x] = []
    end
    return @data[x][y]
  end
 
  def []=(x, y, valor)
    if @data[x].nil?
      @data[x] = []
    end
    @data[x][y] = valor
  end
 
  def each
    for x in 0...@data.size
      next if @data[x].nil?
      for y in 0...@data[x].size
        next if @data[x][y].nil?
        yield @data[x][y]
      end
    end
  end
 
  def refresh_table
    data = [-1, 0, 1]
    self.each {|i|
      next if i.nil?
      i.near = false
    }
    for x in 0...@data.size
      next if @data[x].nil?
      for y in 0...@data[x].size
        if @data[x][y].get
          for i1 in 0..2
            for i2 in 0..2
              next if [[0, 0], [0, 2], [2, 0], [2, 2]].include?([i1, i2])
              real_i1 = [[x+i1-1, 0].max, @data.size-1].min
              real_i2 = [[y+i2-1, 0].max, @data[x].size-1].min
              self[real_i1, real_i2].near = true
            end
          end
        end
      end
    end
  end
 
end 

#===============================================================================
# FFXII - Sprite_Licences_Spot
#-------------------------------------------------------------------------------
# Criador: RTH
#===============================================================================

class Sprite_Licences_Spot < Sprite
 
  include FFXII::LICENCES
 
  def initialize(viewport, house)
    super(viewport)
    @house = house
    @house_picture = RPG::Cache.licence(PICTURE_SQUARE[((@house.x + 1) + (@house.y + 1)) % PICTURE_SQUARE.size])
    @house_sprite = Sprite.new(@viewport)
    self.bitmap = Bitmap.new(@house_picture.width, @house_picture.height)
    refresh
  end
 
  def x=(valor)
    super
    @house_sprite.x = self.x
  end
 
  def y=(valor)
    super
    @house_sprite.y = self.y
  end
 
  def dispose
    if self.bitmap != nil
      self.bitmap.dispose
      self.bitmap = nil
    end
    @house_sprite.dispose
    super()
  end
 
  def refresh
    return if @house.type == ""
    @house_bonus = RPG::Cache.licence((LICENCE_PICTURES[@house.type].nil? ? "" : LICENCE_PICTURES[@house.type]))
    self.bitmap.clear
    self.bitmap.blt(0, 0, @house_picture, Rect.new(0, 0, @house_picture.width, @house_picture.height))
    if @house.near == false and @house.get == false
      @house_sprite.bitmap = nil
      return
    end
    x = (self.bitmap.width / 2) - (@house_bonus.width / 2)
    y = (self.bitmap.height / 2) - (@house_bonus.height / 2)
    @house_sprite.bitmap = @house_bonus
    @house_sprite.ox = -x
    @house_sprite.oy = -y
    @house_sprite.color.set(0, 0, 0, 0)
    if (@house.get == false)
      @house_sprite.color.set(128, 128, 128, 128)
      return
    end
  end
 
end

#===============================================================================
# FFXII - Spriteset_Licence_Spots
#-------------------------------------------------------------------------------
# Criador: RTH
#===============================================================================

class Spriteset_Licence_Spots
 
  include FFXII::LICENCES

  attr_reader :ox
  attr_reader :oy
 
  def initialize(actor_data)
    @ox = 0
    @oy = 0
    @actor_data = actor_data
    @viewport = Viewport.new(0, 0, 640, 480)
    @back = Plane.new(@viewport)
    @back.bitmap = RPG::Cache.licence(LICENCE_BACK)
    @licence_spots = Licence_Table.new
    for x in 0...MAX_LICENCES_WIDTH
      for y in 0...MAX_LICENCES_HEIGHT
        sprite = Sprite_Licences_Spot.new(@viewport, @actor_data[x, y])
        sprite.x = x * 32
        sprite.y = y * 32
        @licence_spots[x, y] = sprite
      end
    end 
  end
 
  def refresh(x, y)
    @licence_spots[x, y].refresh
  end
 
  def refresh_all
    for x in 0...MAX_LICENCES_WIDTH
      for y in 0...MAX_LICENCES_HEIGHT
        @licence_spots[x, y].refresh
      end
    end
  end
 
  def update
    @back.ox += LICENCE_BACK_OX_SPEED
    @back.oy += LICENCE_BACK_OY_SPEED
  end
 
  def ox=(valor)
    return if @ox == valor
    @back.ox -= (@ox - valor)
    @ox = valor
    for x in 0...MAX_LICENCES_WIDTH
      for y in 0...MAX_LICENCES_HEIGHT
        @licence_spots[x, y].ox = @ox
      end
    end
  end
 
  def oy=(valor)
    return if @oy == valor
    @back.oy -= (@oy - valor)
    @oy = valor
    for x in 0...MAX_LICENCES_WIDTH
      for y in 0...MAX_LICENCES_HEIGHT
        @licence_spots[x, y].oy = @oy
      end
    end
  end
 
  def dispose
    for x in @licence_spots
      next if x.nil?
      x.dispose
    end
    @licence_spots = []
    @back.dispose
    @viewport.dispose
  end
 
end

#===============================================================================
# FFXII - Sprite_Licence_Cursor
#-------------------------------------------------------------------------------
# Criador: RTH
#===============================================================================

class Sprite_Licence_Cursor < Sprite
 
  #--------------------------------------------------------------------------
  # - Inicialização dos Objetos
  #--------------------------------------------------------------------------
 
  def initialize(counter_max=0, viewport=nil)
    if viewport.nil?
      super()
    else
      super(viewport)
    end
    @up_down = true
    self.bitmap = RPG::Cache.licence("glove")
    @cursor_growing = false
    @cursor_counter_max = counter_max
    @cursor_counter = 0
    @updating = false
  end
 
  #--------------------------------------------------------------------------
  # - Muda o Up_Down
  #--------------------------------------------------------------------------
 
  def up_down=(valor)
    @up_down = valor
    self.ox = 0
    self.oy = 0
  end
 
  #--------------------------------------------------------------------------
  # - Muda o OX
  #--------------------------------------------------------------------------
 
  def ox=(valor)
    super
    if (@updating == false)
      @cursor_counter = 0
      @cursor_growing = false
    end
  end
 
  #--------------------------------------------------------------------------
  # - Muda o OY
  #--------------------------------------------------------------------------
 
  def oy=(valor)
    unless @up_down
      valor -= self.bitmap.height - 7
    end
    super
    if (@updating == false)
      @cursor_counter = 0
      @cursor_growing = false
    end
  end
 
  #--------------------------------------------------------------------------
  # - Atualização
  #--------------------------------------------------------------------------
 
  def update
    super()
    @updating = true
    if @cursor_counter_max > 0
      if @cursor_growing
        if @up_down
          self.oy = self.oy - 1
        else
          self.ox = self.ox - 1
        end
        @cursor_counter = @cursor_counter + 1
        if @cursor_counter >= @cursor_counter_max
          @cursor_growing = false
          @cursor_counter = 0
        end
      else
        if @up_down
          self.oy = self.oy + 1
        else
          self.ox = self.ox + 1
        end
        @cursor_counter = @cursor_counter + 1
        if @cursor_counter >= @cursor_counter_max
          @cursor_growing = true
          @cursor_counter = 0
        end
      end
    end
    @updating = false
  end
 
end 

#===============================================================================
# FFXII - Window_Licence_Select
#-------------------------------------------------------------------------------
# Criador: RTH
#===============================================================================

class Window_Licence_Select < Window_Command
 
  def initialize
    @data = ["hp", "sp", "str", "dex", "agi", "int", "skill", "skill_licence", ""]
    commands = []
    for x in @data
      case x
      when ""
        commands.push("Nada")
      when "skill_licence"
        commands.push("Skill Licence")
      else
        eval("commands.push($data_system.words.#{x})")
      end
    end
    commands.push("Sair")
    super(240, commands)
    self.back_opacity = 160
    self.y = 64
    self.height = 480-64
  end
 
  def data
    return @data[self.index]
  end
 
  def last_index?
    return (self.index == (@item_max - 1))
  end
 
  def update_help
    text = @commands[self.index]
    @help_window.set_text(text)
  end
 
end

#===============================================================================
# FFXII - Window_Licence_Select
#-------------------------------------------------------------------------------
# Criador: RTH
#===============================================================================

class Window_Licence_Spot_Status < Window_Base
 
  attr_reader :spot
 
  def initialize(spot, actor=nil)
    super(0, 480-96, 640, 96)
    @spot = spot
    @actor = actor
    self.contents = Bitmap.new(width - 32, height - 32)
    self.back_opacity = 160
    refresh
  end
 
  def spot=(valor)
    return if @spot == valor
    @spot = valor
    refresh
  end
 
  def refresh
    self.contents.clear
    if @actor != nil
      text = "#{FFXII::LICENCES::LICENCE_POINTS_S} "
      text2 = sprintf("%04d", @actor.lp)
      self.contents.font.color = system_color
      self.contents.draw_text((width - 40) - self.contents.text_size(text2).width - self.contents.text_size(text).width, 32, self.contents.text_size(text).width, 32, text)
      self.contents.font.color = normal_color
      self.contents.draw_text((width - 40) - self.contents.text_size(text2).width, 32, self.contents.text_size(text2).width, 32, text2)
    end
    return if @spot.type == ""
    x = 4
    if @spot.type == "skill" or @spot.type == "skill_licence"
      refresh_skill
    else
      text = eval("$data_system.words.#{@spot.type}")
      self.contents.font.color = system_color
      self.contents.draw_text(x, 0, width - 40, 32, text)
      x += self.contents.text_size(text).width
      text = " +" + ((@spot.near == false and !@spot.get and !$scene.instance_of?(Scene_Create_Licences)) ? "???" : "#{@spot.id}")
      self.contents.font.color = normal_color
      self.contents.draw_text(x, 0, width - 40, 32, text)
    end
    self.contents.font.color = system_color
    text = "#{FFXII::LICENCES::LICENCE_POINTS_COST_S} "
    text2 = ((@spot.near == false and !@spot.get and !$scene.instance_of?(Scene_Create_Licences)) ? "????" : sprintf("%04d", @spot.cost))
    self.contents.draw_text((width - 40) - self.contents.text_size(text2).width - self.contents.text_size(text).width, 0, self.contents.text_size(text).width, 32, text)
    self.contents.font.color = normal_color
    self.contents.draw_text((width - 40) - self.contents.text_size(text2).width, 0, self.contents.text_size(text2).width, 32, text2)
    self.contents.draw_text(4, 32, width - 40, 32, "Owned") if @spot.get
  end
 
  def refresh_skill
    x = 4
    self.contents.font.color = system_color
    self.contents.draw_text(x, 0, 200, 32, $data_system.words.skill + " - ")
    x += [self.contents.text_size($data_system.words.skill + " - ").width, 200].min
    self.contents.font.color = normal_color
    if (@spot.near == false and !@spot.get and !$scene.instance_of?(Scene_Create_Licences))
      self.contents.draw_text(x, 0, 200, 32, "???")
      return
    end
    opacity = 255
    if @spot.type == "skill_licence"
      opacity = 160 unless $game_party.skill_learn?(@spot.id)
    end
    if $data_skills[@spot.id].icon_name != ""
      self.contents.blt(x, 0, RPG::Cache.icon($data_skills[@spot.id].icon_name), Rect.new(0, 0, 24, 24), opacity)
      x += 28
    end
    self.contents.font.color = disabled_color if opacity == 160
    self.contents.draw_text(x, 0, 200, 32, $data_skills[@spot.id].name)
  end
 
end

#===============================================================================
# FFXII - Window_Licence_Skills
#-------------------------------------------------------------------------------
# Criador: RTH
#===============================================================================

class Window_Licence_Skills < Window_Command
 
  attr_reader :spot
 
  def initialize()
    commands = []
    for i in 1...$data_skills.size
      commands.push($data_skills[i].name)
    end
    super(640, commands)
    self.back_opacity = 160
    self.y = 64
    self.height = 480 - 64
  end
 
  def skill
    return ($data_skills[self.index+1])
  end
 
end

#===============================================================================
# FFXII - Scene_Create_Licences
#-------------------------------------------------------------------------------
# Criador: RTH
#===============================================================================

class Scene_Create_Licences
 
  include FFXII::LICENCES
 
  def initialize(actor_id)
    @actor_id = actor_id
  end
 
  def main
    # Carregar o Banco de Dados
    $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")
    # Criar um Sistema
    $game_system = Game_System.new
    begin
      @data = load_data("Data/Licences.rxdata")
    rescue
      @data = []
    end
    @actor_data = @data[@actor_id]
    if @actor_data.nil?
      @actor_data = Licence_Table.new
    end
    for x in 0...MAX_LICENCES_WIDTH
      for y in 0...MAX_LICENCES_HEIGHT
        if @actor_data[x, y].nil?
          @actor_data[x, y] = Licence_Spot.new(x, y, "", 0)
        end
      end
    end
    @spriteset = Spriteset_Licence_Spots.new(@actor_data)
    @help_window = Window_Help.new
    @help_window.back_opacity = 160
    @window_select = Window_Licence_Select.new
    @window_select.help_window = @help_window
    @window_select.active = false
    @window_select.visible = false
    @window_select.index = 0
    @input_number = Window_InputNumber.new(4)
    @input_number.back_opacity = 160
    @input_number.opacity = 255
    @input_number.active = false
    @input_number.visible = false
    @help_window.visible = false
    @x = 0
    @y = 0
    @spot_info = Window_Licence_Spot_Status.new(@actor_data[@x, @y])
    @cursor = Sprite_Licence_Cursor.new(10)
    @cursor.x = (@x * 32)
    @cursor.y = (@y * 32) - 16
    Graphics.transition()
    loop {
      Graphics.update
      Input.update
      update
      if $scene != self
        break
      end
    }
    if decision_exit
      @actor_data = nil
    end
    Graphics.freeze
    Graphics.freeze
    @spriteset.dispose
    @window_select.dispose
    @help_window.dispose
    @input_number.dispose
    @spot_info.dispose
    @cursor.dispose
    @data[@actor_id] = @actor_data
    file = File.open("Data/Licences.rxdata", "wb")
    Marshal.dump(@data, file)
    file.close
  end
 
  def update
    if @window_select.active
      update_window_select
      return
    end
    @cursor.update
    if Input.trigger?(Input::B)
      $game_system.se_play($data_system.cancel_se)
      $scene = nil
      return
    end
    if Input.trigger?(Input::C)
      $game_system.se_play($data_system.decision_se)
      @window_select.active = true
      @window_select.visible = true
      @help_window.visible = true
      @spot_info.visible = false
      return
    end
    if Input.repeat?(Input::DOWN)
      if Input.trigger?(Input::DOWN) or @y < (MAX_LICENCES_HEIGHT - 1)
        $game_system.se_play($data_system.cursor_se)
        self.y = (@y + 1) % MAX_LICENCES_HEIGHT
        return
      end
    end
    if Input.repeat?(Input::UP)
      if Input.trigger?(Input::UP) or @y > 0
        $game_system.se_play($data_system.cursor_se)
        self.y = (@y - 1) % MAX_LICENCES_HEIGHT
        return
      end
    end
    if Input.trigger?(Input::LEFT)
      $game_system.se_play($data_system.cursor_se)
      self.x = (@x - 1) % MAX_LICENCES_WIDTH
      return
    end
    if Input.trigger?(Input::RIGHT)
      $game_system.se_play($data_system.cursor_se)
      self.x = (@x + 1) % MAX_LICENCES_WIDTH
      return
    end
  end
 
  def update_window_select
    @window_select.update
    if Input.trigger?(Input::B)
      $game_system.se_play($data_system.cancel_se)
      @window_select.active = false
      @window_select.visible = false
      @help_window.visible = false
      @spot_info.visible = true
      return
    end
    if Input.trigger?(Input::C)
      $game_system.se_play($data_system.decision_se)
      if @window_select.last_index?
        @window_select.active = false
        @window_select.visible = false
        @help_window.visible = false
        @spot_info.visible = true
        return
      end
      @actor_data[@x, @y].type = @window_select.data
      @spriteset.refresh(@x, @y)
      @window_select.active = false
      @window_select.visible = false
      if @actor_data[@x, @y].type == ""
        @help_window.y = 0
        @help_window.visible = false
        @spot_info.visible = true
        @spot_info.refresh
        return
      end
      phase = 0
      loop do
        if phase == 0
          if @window_select.data == "skill" or @window_select.data == "skill_licence"
            unless window_skill
              @window_select.active = true
              @window_select.visible = true
              return
            end         
          else
            unless input_number
              @window_select.active = true
              @window_select.visible = true
              return
            end
            @actor_data[@x, @y].id = @input_number.number
          end
        end
        unless input_lp_number
          phase = 0
          next
        end
        phase = 1
        if decision
          break
        end
      end
      @spriteset.refresh(@x, @y)
      @help_window.y = 0
      @help_window.visible = false
      @spot_info.visible = true
      @spot_info.refresh
      return
    end
  end
 
  def window_skill
    window = Window_Licence_Skills.new
    @help_window.y = 0
    @help_window.set_text("Choose the skill.")
    loop do
      Graphics.update
      Input.update
      window.update
      if Input.trigger?(Input::B)
        $game_system.se_play($data_system.cancel_se)
        window.dispose
        return false
      end
      if Input.trigger?(Input::C)
        $game_system.se_play($data_system.decision_se)
        break
      end
    end 
    @actor_data[@x, @y].id = window.skill.id
    window.dispose
    @help_window.y = 0
    return true
  end
 
  def input_number
    @input_number.number = 0
    @input_number.x = 320 - (@input_number.width / 2)
    @input_number.y = 240 - (@input_number.height / 2)
    @help_window.y = @input_number.y - 64
    @help_window.set_text("Set the value.", 1)
    @input_number.active = true
    @input_number.visible = true
    loop do
      Graphics.update
      Input.update
      @input_number.update
      if Input.trigger?(Input::B)
        $game_system.se_play($data_system.cancel_se)
        @input_number.active = false
        @input_number.visible = false
        @help_window.y = 0
        return false
      end
      if Input.trigger?(Input::C)
        $game_system.se_play($data_system.decision_se)
        break
      end
    end 
    @input_number.active = false
    @input_number.visible = false
    @help_window.y = 0
    return true
  end
 
  def input_lp_number
    @input_number.number = 0
    @input_number.x = 320 - (@input_number.width / 2)
    @input_number.y = 240 - (@input_number.height / 2)
    @help_window.y = @input_number.y - 64
    @help_window.set_text("Set the LP Cost value.", 1)
    @input_number.active = true
    @input_number.visible = true
    loop do
      Graphics.update
      Input.update
      @input_number.update
      if Input.trigger?(Input::B)
        $game_system.se_play($data_system.cancel_se)
        @input_number.active = false
        @input_number.visible = false
        @help_window.y = 0
        return false
      end
      if Input.trigger?(Input::C)
        $game_system.se_play($data_system.decision_se)
        break
      end
    end 
    @actor_data[@x, @y].cost = @input_number.number
    @input_number.active = false
    @input_number.visible = false
    @help_window.y = 0
    return true
  end
 
  def decision
    command = Window_Command.new(100, ["Yes", "No"])
    command.x = 320 - (command.width / 2)
    command.y = 240 - (command.height / 2)
    command.back_opacity = 160
    @help_window.y = command.y - 64
    @help_window.set_text("Will the hero starts width this place owned?", 1)
    loop do
      Graphics.update
      Input.update
      command.update
      if Input.trigger?(Input::B)
        $game_system.se_play($data_system.cancel_se)
        command.dispose
        @help_window.y = 0
        return false
      end
      if Input.trigger?(Input::C)
        $game_system.se_play($data_system.decision_se)
        break
      end
    end 
    @actor_data[@x, @y].get = (command.index == 0)
    command.dispose
    @help_window.y = 0
    return true
  end
 
  def decision_exit
    command = Window_Command.new(100, ["No", "Yes"])
    command.x = 320 - (command.width / 2)
    command.y = 240 - (command.height / 2)
    command.back_opacity = 160
    @help_window.y = command.y - 64
    @help_window.set_text("Would you like to DELETE this table?", 1)
    valor = false
    loop do
      Graphics.update
      Input.update
      command.update
      if Input.trigger?(Input::B)
        $game_system.se_play($data_system.cancel_se)
        command.dispose
        @help_window.y = 0
        valor = false
        break
      end
      if Input.trigger?(Input::C)
        $game_system.se_play($data_system.decision_se)
        valor = (command.index == 1)
        break
      end
    end 
    command.dispose
    @help_window.visible = false
    return valor
  end
 
  def x=(valor)
    return if @x == valor
    @x = valor
    if ((@x + 1) * 32) > @spriteset.ox + 640
      @spriteset.ox = ((@x + 1) * 32) - 640
    elsif (@x * 32) < @spriteset.ox
      @spriteset.ox = (@x * 32)
    end
    @cursor.x = (@x * 32) - @spriteset.ox
    @spot_info.spot = @actor_data[@x, @y]
  end
 
  def y=(valor)
    return if @y == valor
    @y = valor
    if ((@y + 1) * 32) > @spriteset.oy + 480
      @spriteset.oy = ((@y + 1) * 32) - 480
    elsif (@y * 32) < @spriteset.oy
      @spriteset.oy = (@y * 32)
    end
    @cursor.y = (@y * 32) - 16 - @spriteset.oy
    @spot_info.spot = @actor_data[@x, @y]
  end
 
end

#===============================================================================
# FFXII - Scene_Create_Licences
#-------------------------------------------------------------------------------
# Criador: RTH
#===============================================================================

class Scene_Licences
 
  include FFXII::LICENCES
 
  def initialize(party_id, main_menu_index=0)
    @actor_id = $game_party.actors[party_id].id
    @main_menu_index = main_menu_index
  end
 
  def main
    @actor = $game_actors[@actor_id]
    @spriteset = Spriteset_Licence_Spots.new(@actor.licence_table)
    @help_window = Window_Help.new
    @help_window.back_opacity = 160
    @help_window.visible = false
    @x = 10
    @y = 7
    @spot_info = Window_Licence_Spot_Status.new(@actor.licence_table[@x, @y], @actor)
    @cursor = Sprite_Licence_Cursor.new(10)
    @cursor.x = (@x * 32)
    @cursor.y = (@y * 32) - 16
    Graphics.transition()
    loop {
      Graphics.update
      Input.update
      update
      if $scene != self
        break
      end
    }
    Graphics.freeze
    @spriteset.dispose
    @help_window.dispose
    @spot_info.dispose
    @cursor.dispose
  end
 
  def update
    @spriteset.update
    update_cursor
    if ((@y + 1) * 32) > @spriteset.oy + (480 - @spot_info.height + 32)
      @spot_info.y = 0
    elsif (@y * 32) < @spriteset.oy + (@spot_info.height + 32)
      @spot_info.y = 480 - @spot_info.height
    end
    if Input.trigger?(Input::B)
      $game_system.se_play($data_system.cancel_se)
      $scene = Scene_Menu.new(@main_menu_index)
      return
    end
    if Input.trigger?(Input::C)
      if @actor.licence_table[@x, @y].type == ""
        return
      end
      if ((@actor.lp < @actor.licence_table[@x, @y].cost) or (@actor.licence_table[@x, @y].get) or (!@actor.licence_table[@x, @y].near))
        $game_system.se_play($data_system.buzzer_se)
        return
      end
      $game_system.se_play($data_system.decision_se)
      if decision
        @actor.lp -= @actor.licence_table[@x, @y].cost
        @actor.licence_table[@x, @y].get = true
        @actor.licence_table.refresh_table
        case @actor.licence_table[@x, @y].type
        when "hp"
          @actor.maxhp += @actor.licence_table[@x, @y].id
        when "sp"
          @actor.maxsp += @actor.licence_table[@x, @y].id
        when "str"
          @actor.str += @actor.licence_table[@x, @y].id
        when "dex"
          @actor.dex += @actor.licence_table[@x, @y].id
        when "agi"
          @actor.agi += @actor.licence_table[@x, @y].id
        when "int"
          @actor.int += @actor.licence_table[@x, @y].id
        when "skill"
          @actor.learn_skill(@actor.licence_table[@x, @y].id)
        when "skill_licence"
          @actor.learn_skill_licence(@actor.licence_table[@x, @y].id)
        end
        for i1 in 0..2
          for i2 in 0..2
            next if [[0, 0], [0, 2], [2, 0], [2, 2]].include?([i1, i2])
            real_i1 = [[@x+i1-1, 0].max, MAX_LICENCES_WIDTH-1].min
            real_i2 = [[@y+i2-1, 0].max, MAX_LICENCES_HEIGHT-1].min
            @spriteset.refresh(real_i1, real_i2)
          end
        end
        @spot_info.refresh
      end
      return
    end
  end
 
  def update_cursor
    @cursor.update
    if Input.repeat?(Input::DOWN)
      if Input.trigger?(Input::DOWN) or @y < (MAX_LICENCES_HEIGHT - 1)
        $game_system.se_play($data_system.cursor_se)
        self.y = (@y + 1) % MAX_LICENCES_HEIGHT
        return
      end
    end
    if Input.repeat?(Input::UP)
      if Input.trigger?(Input::UP) or @y > 0
        $game_system.se_play($data_system.cursor_se)
        self.y = (@y - 1) % MAX_LICENCES_HEIGHT
        return
      end
    end
    if Input.trigger?(Input::LEFT)
      $game_system.se_play($data_system.cursor_se)
      self.x = (@x - 1) % MAX_LICENCES_WIDTH
      return
    end
    if Input.trigger?(Input::RIGHT)
      $game_system.se_play($data_system.cursor_se)
      self.x = (@x + 1) % MAX_LICENCES_WIDTH
      return
    end
  end
 
  def decision
    command = Window_Command.new(100, ["Yes", "No"])
    command.x = 320 - (command.width / 2)
    command.y = 240 - (command.height / 2)
    command.back_opacity = 160
    @help_window.y = command.y - 64
    @help_window.set_text("Deseja ativar esta casa?", 1)
    for i in 0..20
      @help_window.back_opacity = (160 / 20.0) * i
      command.back_opacity = (160 / 20.0) * i
      Graphics.update
    end
    value = false
    loop do
      Graphics.update
      Input.update
      command.update
      if Input.trigger?(Input::B)
        $game_system.se_play($data_system.cancel_se)
        value = false
        break
      end
      if Input.trigger?(Input::C)
        $game_system.se_play($data_system.decision_se)
        value = (command.index == 0)
        break
      end
    end 
    for i in 0..20
      @help_window.back_opacity = 160 - (160 / 20.0) * i
      command.back_opacity = 160 - (160 / 20.0) * i
      Graphics.update
    end
    command.dispose
    @help_window.visible = false
    return value
  end
 
  def x=(valor)
    return if @x == valor
    @x = valor
    if ((@x + 1) * 32) > @spriteset.ox + 640
      @spriteset.ox = ((@x + 1) * 32) - 640
    elsif (@x * 32) < @spriteset.ox
      @spriteset.ox = (@x * 32)
    end
    @cursor.x = (@x * 32) - @spriteset.ox
    @spot_info.spot = @actor.licence_table[@x, @y]
  end
 
  def y=(valor)
    return if @y == valor
    @y = valor
    if ((@y + 1) * 32) > @spriteset.oy + 480
      @spriteset.oy = ((@y + 1) * 32) - 480
    elsif (@y * 32) < @spriteset.oy
      @spriteset.oy = (@y * 32)
    end
    @cursor.y = (@y * 32) - 16 - @spriteset.oy
    @spot_info.spot = @actor.licence_table[@x, @y]
  end
 
end




Blizzard

Battle lags? Does the status get refreshed over and over by any chance?
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

Viviatus

Quote from: Blizzard on August 24, 2008, 07:04:39 am
Battle lags? Does the status get refreshed over and over by any chance?


I have no Idea... Without the script there's no lag at all... Afterall I'm not a scripter.

Blizzard

Lol, so you still haven't learnt to script? xD Welcome back, BTW, long time no see.
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

Viviatus

Quote from: Blizzard on August 24, 2008, 07:08:55 am
Lol, so you still haven't learnt to script? xD Welcome back, BTW, long time no see.


Nope, hence I'm asking for help... The book I have rather deals about programming in RUBY and since I only need to learn how to script it's not much of a help. And it also only it only covers the bloody basics in theory. I'm still searching for books or decent tutorials on how to script, preferably in german. And there also is this time issue... Work's keeping me awfully busy. I'm on holiday right now...

Yeah, good to see you're still keeping it up with CP.

Berans

My personal suggestion on learning how to script is pretty simple: Just script.
By trying to script stuff you'll learn much better how to script than you will by reading tutorials and books about it, since you geniunely have to learn how stuff works. That means you'll have a better understanding of the underlying structures and can therefore more aptly use them.
Of course there's massive internet communities out there to help you when you run into trouble, so you'll just keep learning ;)

Viviatus

Quote from: Berans on August 24, 2008, 07:20:52 am
My personal suggestion on learning how to script is pretty simple: Just script.
By trying to script stuff you'll learn much better how to script than you will by reading tutorials and books about it, since you geniunely have to learn how stuff works. That means you'll have a better understanding of the underlying structures and can therefore more aptly use them.
Of course there's massive internet communities out there to help you when you run into trouble, so you'll just keep learning ;)


Thanks for help, and that is what I'm actually doing. I only ask for help when I'm totally clueless.

Berans

August 24, 2008, 07:41:58 am #7 Last Edit: August 24, 2008, 07:47:12 am by Berans
Man....those scripts are pretty big. I'm trying to find scene battle to see if I can find the update method, but I can't seem to find it. As Blizzard suggested, a very likely problem causing the lag is inefficient use of refresh methods...no clue where to look though T_T
EDIT: oh, I just saw something that might interest you in the start of the script. This line here

ENEMIES_LP = []
    # Amount of LP won by defeating an enemy
    # ENEMIES_LP[Enemy id] = X

will let you set up earning license points.
Basically, from what I can tell (the comments are a bit less informative than they could be)
You should set it up like this
after:

ENEMIES_LP = []

For every enemy you add a line saying

ENEMIES_LP[enemy id] = some amount of lp

where the id is the enemy's ID in the database

Viviatus

There you go! ^^
I have the feeling that those scripts are kinda messed up, too. I'd prefere a one scripted standalone, but I can't ask for one since there already IS one, I just needs to be cleaned/edited.

Berans

On a sidenote, if you don't want to set up every single enemy separately, you could set it up in batches in various ways.
One way, if a number of consecutive enemies in the database should give the same LP is this

for id in first_enemy's_id..last_enemy's_id
  ENEMIES_LP [id] = some amount of lp
end

where "first_enemy's_id" is the id of the first enemy in the list you want to create and "last_enemy's_id" the last id in that list.
Another compactish way to do it is:

ENEMIES_LP[some id] , ENEMIES_LP[some other id] , ENEMIES_LP[another one] = lp, other lp, another lp value

I love the compact set-ups :P

Viviatus

I tried everything I know, and also tried the things you told me to. Thing is the actors won't gain any LP.
Thanks anyway!

Aqua

What other scripts are you using?

There might be an incompatibility among some of them with the License Board Script.

Viviatus

Already turned off all other scripts, the lag and the actors not gaining LP still persist.