Somebody knows how make this...compatible with BLIZZABS?

Started by elmangakac, February 28, 2011, 11:22:33 am

Previous topic - Next topic

elmangakac

February 28, 2011, 11:22:33 am Last Edit: February 28, 2011, 11:23:40 am by elmangakac
Author: Cold Strong


Description:
This script creates a Bestiary and Items Book that is possible to see information of monsters and items. It have also a system the monsters drop limitless items. And also a system of treasures.

Script:

Put This Above Main
Code:

################################################################################
################################################################################
########################### Cold Module ########################################
################################################################################
################################################################################
#===============================================================================
# By Cold Strong
#===============================================================================
# Cold Module
#-------------------------------------------------------------------------------
# This script count some functions used by my scripts
# Obs: It is some imcomplete...
#===============================================================================

class Customs_Data
 
  attr_accessor   :actors       
  attr_accessor   :classes     
  attr_accessor   :skills       
  attr_accessor   :items         
  attr_accessor   :weapons       
  attr_accessor   :armors       
  attr_accessor   :enemies       
  attr_accessor   :troops       
  attr_accessor   :states       
  attr_accessor   :animations   
  attr_accessor   :tilesets     
  attr_accessor   :common_events
  attr_accessor   :system
  attr_accessor   :map_infos
  attr_accessor   :maps
 
  def initialize
    @actors        = load_data("Data/Actors.rxdata")
    @classes       = load_data("Data/Classes.rxdata")
    @skills        = load_data("Data/Skills.rxdata")
    @items         = load_data("Data/Items.rxdata")
    @weapons       = load_data("Data/Weapons.rxdata")
    @armors        = load_data("Data/Armors.rxdata")
    @enemies       = load_data("Data/Enemies.rxdata")
    @troops        = load_data("Data/Troops.rxdata")
    @states        = load_data("Data/States.rxdata")
    @animations    = load_data("Data/Animations.rxdata")
    @tilesets      = load_data("Data/Tilesets.rxdata")
    @common_events = load_data("Data/CommonEvents.rxdata")
    @system        = load_data("Data/System.rxdata")
    @maps = {}
    for i in 1..999
      number = sprintf("%03d", i)
      if FileTest.exist?("Data/Map#{number}.rxdata")
        @maps[i] = load_data("Data/Map#{number}.rxdata")
      else
        break
      end
    end
    @map_infos     = load_data("Data/MapInfos.rxdata")
  end
 
  def [](str)
    return @customs_data[str]
  end
 
end

module Cold
   
  $data = Customs_Data.new
 
end

class Window_Base < Window
 
 
  #--------------------------------------------------------------------------
  # - Desenhar Gráfico
  #
  #     t     : Texto a ser feita as linhas
  #     width : Largura máxima da linha
  #     
  #     - Ele retorna uma array, em que cada elemento é uma string
  #       com a largura desejada.
  #--------------------------------------------------------------------------
 
  def lines(t, width)
    text = t.clone
    x = self.contents.text_size(text).width / width
    x += 1 if self.contents.text_size(text).width % width > 0
    texts = []
    for i in 0...x
      texts.push("")
    end
    for i in 0...texts.size
      words = text.split(" ")
      return_text = ""
      for w in 0...words.size
        word = words[w]
        x = "!@$%¨&*()"
        return_text += word + x + " "
        return_text2 = return_text.gsub(x,"")
        t_width = self.contents.text_size(return_text2).width
        if t_width > width
          texts[i] = return_text.gsub(" "+word+x, "")
          text.gsub!(texts[i], "")
          break
        elsif w == words.size - 1
          texts[i] = return_text.gsub(x+" ", "")
          text.gsub!(texts[i], "")
          break
        else
          return_text.gsub!(word+x, word)
        end
      end
    end
    return texts
  end
 
  def draw_text_in_lines(x, y_initial, width, height, text)
    lines = lines(text, width)
    y = y_initial
    for text_line in lines
      self.contents.draw_text(x, y, width, height, text_line)
      y += height
    end
  end
   
end


And Below....this



################################################################################
################################################################################
######################## Cold Books System #####################################
################################################################################
################################################################################
#===============================================================================
# By Cold Strong
#===============================================================================
# Bestiary and Item Book Script
#-------------------------------------------------------------------------------
# ***Necessary Cold Module
#===============================================================================
# How to use:
# To call the Items Menu:
#   - $scene = Scene_ItemsBook.new
# To call the Bestiary Menu:
#   - $scene = Scene_Bestiary.new
#-------------------------------------------------------------------------------
# Bugs: cold.strong@hotmail.com
#===============================================================================

$ColdScript ||= {}
$ColdScript["Books System"] = true

if $ColdScript["Books System"]
#===============================================================================
# Overall Customization
#===============================================================================
module Options
  #-----------------------------------------------------------------------------
  # Scope Information
  #-----------------------------------------------------------------------------
  SCOPE_INFO = ["Nothing", "Enemies", "All Enemies", "Ally", "All Alies",
  "Ally (HP 0)", "All Allies (HP 0)", "Hero"]
  #-----------------------------------------------------------------------------
  # Treasure System Active? It's important that you disable if you'll not use it.
  #-----------------------------------------------------------------------------
  TREASURE_ACTIVE = true
  #-----------------------------------------------------------------------------
  # Name of the Atribute that the Treasure item have to has.
  #-----------------------------------------------------------------------------
  TREASURE_ATRIBUTE = "Treasure"
  #-----------------------------------------------------------------------------
  # Animated Background Picture (It must be in past: Graphics/Pictures)
  #-----------------------------------------------------------------------------
  COLD_MENU_PLANE = ""
 
  #=============================================================================
  # Don't touch here
  ENEMY_ITEMS = []
  for i in 1... $data.enemies.size
    ENEMY_ITEMS[i] = []
  end
  #=============================================================================

  #-----------------------------------------------------------------------------
  # Items dropped by monsters, to add a new item you have
  # to use this code:
  # Enemy_items[enemy_id].push([type, id, prob])
  # -------------------------------
  # enemy_id    : ID of the enemy
  # type        : Kind of item (0:Item, 1:Weapon, 2:Armor)
  # id          : ID of the item
  # prob        : Probability of being dropped (%)
  #-----------------------------------------------------------------------------
  ENEMY_ITEMS[1].push( [0, 10, 50] )
 
  #=============================================================================
  # Don't touch here
  ENEMY_DESCRIPTION = []
  for i in 1...$data.enemies.size
    ENEMY_DESCRIPTION[i] = ""
  end
  #=============================================================================

  #-----------------------------------------------------------------------------
  # Enemy Description, to customize:
  # ENEMY_DESCRIPTION[enemy_id] = description
  # -------------------------------
  # enemy_id    : ID of the enemy
  # description : String with the description
  #-----------------------------------------------------------------------------
  ENEMY_DESCRIPTION[1] = "Dangerous ghost that lives in the darkness."
 
  #=============================================================================
  # CUSTOMIZATION END
  #=============================================================================
  ENEMIES_ORDER = {}
  ENEMIES_ORDER["By type"] = []
  for i in 1...$data.enemies.size
    ENEMIES_ORDER["By type"].push(i)
  end
  order = []
  for i in 1...$data.enemies.size
    order.push($data.enemies[i].name)
  end
  ENEMIES_ORDER["Alphabetical"] = order.sort
  for i in 0...ENEMIES_ORDER["Alphabetical"].size
    ENEMIES_ORDER["Alphabetical"][i] = order.index(ENEMIES_ORDER["Alphabetical"][i]) + 1
  end
  ITEMS_ORDER = {}
  order = []
  t_order = []
  for i in 1...$data.items.size
    t_order.push([0,i])
    order.push($data.items[i].name)
  end
  for i in 1...$data.weapons.size
    t_order.push([1,i])
    order.push($data.weapons[i].name)
  end
  for i in 1...$data.armors.size
    t_order.push([2,i])
    order.push($data.armors[i].name)
  end
  ITEMS_ORDER["By type"] = t_order
  order_i = order.sort
  for i in 0...order_i.size
    index = order.index(order_i[i])
    if index >= $data.items.size + $data.weapons.size - 2
      type = 2
      id = order.index(order_i[i]) + 3 - $data.items.size - $data.weapons.size
    elsif index >= $data.items.size - 1
      type = 1
      id = order.index(order_i[i]) + 2 - $data.items.size
    else
      type = 0
      id = order.index(order_i[i]) + 1
    end
    order[order.index(order_i[i])] = "nil!@$%"
    order_i[i] = [type,id]
  end
  ITEMS_ORDER["Alphabetical"] = order_i
  LAYOUTB = true
end

#==============================================================================
# Modulo RPG
#==============================================================================

module RPG
 
  class Item
    def treasure
      treasure_i = $data.system.elements.index(Options::TREASURE_ATRIBUTE)
      if @element_set.include?(treasure_i)
        return true
      end
      return false   
    end
  end
 
  class Weapon
    def treasure
      treasure_i = $data.system.elements.index(Options::TREASURE_ATRIBUTE)
      if @element_set.include?(treasure_i)
        return true
      end
      return false   
    end
  end
 
  class Armor
    def treasure
      treasure_i = $data.system.elements.index(Options::TREASURE_ATRIBUTE)
      if @guard_element_set.include?(treasure_i)
        return true
      end
      return false   
    end
  end
 
  class Enemy
    def items
      @items ||= []
      return @items
    end
  end
 
end

#==============================================================================
# Modulo Opções
#==============================================================================

module Options
 
  for i in 1...$data.enemies.size
    if $data.enemies[i].item_id > 0
      item_id = $data.enemies[i].item_id
      prob = $data.enemies[i].treasure_prob
      $data.enemies[i].items.push([0,item_id,prob])
    end
    if $data.enemies[i].weapon_id > 0
      item_id = $data.enemies[i].weapon_id
      prob = $data.enemies[i].treasure_prob
      $data.enemies[i].items.push([1,item_id,prob])
    end
    if $data.enemies[i].armor_id > 0
      item_id = $data.enemies[i].armor_id
      prob = $data.enemies[i].treasure_prob
      $data.enemies[i].items.push([1,item_id,prob])
    end
    unless ENEMY_ITEMS[i].nil?
      for item in ENEMY_ITEMS[i]
        $data.enemies[i].items.push(item)
      end
    end
  end
 
end

#==============================================================================
# Game_Enemy
#==============================================================================

class Game_Enemy < Game_Battler
 
  #--------------------------------------------------------------------------
  # - Selecionar items que podem dropar
  #--------------------------------------------------------------------------
 
  def items
    return $data.enemies[@enemy_id].items
  end
 
  #--------------------------------------------------------------------------
  # - Informação para o Bestiário
  #--------------------------------------------------------------------------
 
  def info
    if @info.new
      @info = Game_Info_Enemy.new(id)
    end
  end
end

#==============================================================================
# Window_BattleResult
#------------------------------------------------------------------------------
# Esta janela exibe os tesouros e o dinheiro ganho após uma batalha.
#==============================================================================

class Window_BattleResult < Window_Base
 
  #--------------------------------------------------------------------------
  # - Inicialização dos Objetos
  #
  #     exp       : EXP
  #     gold      : quantidade de dinheiro
  #     treasures : tesouros
  #--------------------------------------------------------------------------
 
  def initialize(exp, gold, treasures)
    @exp = exp
    @gold = gold
    @treasures = treasures
    x = treasures.uniq
    super(0, 0, 320, [x.size, 7].min * 32 + 64)
    self.width = [(x.size + 7) / 7 * 320, 640].min
    self.x = (640 - self.width) / 2
    self.contents = Bitmap.new(width - 32, height - 32)
    self.y = 160 - height / 2
    self.back_opacity = 160
    self.visible = false
    refresh
  end
 
  #--------------------------------------------------------------------------
  # - Atualização
  #--------------------------------------------------------------------------
 
  def refresh
    self.contents.clear
    x = ((self.width - 32) - 246) / 2
    self.contents.font.color = normal_color
    cx = contents.text_size(@exp.to_s).width
    self.contents.draw_text(x, 0, cx, 32, @exp.to_s)
    x += cx + 4
    self.contents.font.color = system_color
    cx = contents.text_size("EXP").width
    self.contents.draw_text(x, 0, 64, 32, "EXP")
    x += cx + 16
    self.contents.font.color = normal_color
    cx = contents.text_size(@gold.to_s).width
    self.contents.draw_text(x, 0, cx, 32, @gold.to_s)
    x += cx + 4
    self.contents.font.color = system_color
    self.contents.draw_text(x, 0, 128, 32, $data_system.words.gold)
    i = 0
    t = @treasures.uniq
    for item in t
      number = @treasures.rindex(item) + 1
      @treasures.delete(item)
      x = i / 7 * (320 - 16) + 4
      y = i % 7 * 32 + 32
      draw_item_name(item, x, y)
      self.contents.draw_text(x + 240, y, 16, 32, ":", 1)
      self.contents.draw_text(x + 256, y, 24, 32, number.to_s, 2)
      i += 1
    end
  end
end

#==============================================================================
# Scene_Battle
#==============================================================================

class Scene_Battle   
 
  #--------------------------------------------------------------------------
  # - Processamento Principal
  #--------------------------------------------------------------------------
 
  alias cold_menu_main main
  def main
    troop = $data.troops[$game_temp.battle_troop_id]
    map_name = $data.map_infos[$game_map.map_id].name
    $game_system.maps_battled.push(map_name)
    for enemy in troop.members
      $game_system.info_enemy(enemy.enemy_id).battled += 1
      unless $game_system.info_enemy(enemy.enemy_id).habitat.include?(map_name)
        $game_system.info_enemy(enemy.enemy_id).habitat.push(map_name)
      end
    end
    cold_menu_main
  end
 
  #--------------------------------------------------------------------------
  # - Fim da Batalha
  #
  #     result : resultado (0=vitória, 1=derrota e 2=fuga)
  #--------------------------------------------------------------------------
 
  alias cold_menu_battle_end battle_end
  def battle_end(result)
    for enemy in $game_troop.enemies
      if enemy.dead?
        $game_system.info_enemy(enemy.id).killed += 1
      end
    end
    $actor_index = nil
    cold_menu_battle_end(result)
  end
 
  #--------------------------------------------------------------------------
  # - Atualização do Frame
  #--------------------------------------------------------------------------
 
  alias cold_menu_update update
  def update
    $actor_index = @actor_index
    unless @active_battler.nil?
      $actor_index = @active_battler.index
    end
    cold_menu_update
  end
 
  #--------------------------------------------------------------------------
  # - Atualização do Frame (Fase de Pós-Batalha)
  #--------------------------------------------------------------------------
 
  def start_phase5
    # Alternar para a fase 5
    @phase = 5
    # Reproduzir ME de fim de Batalha
    $game_system.me_play($game_system.battle_end_me)
    # Retornar para BGM de antes da Batalha ser iniciada
    $game_system.bgm_play($game_temp.map_bgm)
    # Inicializar EXP, quantidade de dinheiro e tesouros
    exp = 0
    gold = 0
    treasures = []
    # Loop
    for enemy in $game_troop.enemies
      # Se o Inimigo não estiver escondido
      unless enemy.hidden
        # Adicionar a EXP e a quantidade de dinheiro obtidos
        exp += enemy.exp
        gold += enemy.gold
        # Determinar se aparece algum tesouro
        for item in enemy.items
          if rand(100) < item[2]
            case item[0]
            when 0
              treasures.push($data_items[item[1]])
              $game_system.info_enemy(enemy.id).gained_item(item[1])
            when 1
              treasures.push($data_weapons[item[1]])
              $game_system.info_enemy(enemy.id).gained_weapon(item[1])
            when 2
              treasures.push($data_armors[item[1]])
              $game_system.info_enemy(enemy.id).gained_armor(item[1])
            end
          end
        end
      end
    end
    old_treasures = [] + treasures
    treasures.clear
    i = 0
    for treasure in old_treasures
      treasures[i] = Array.new(old_treasures.rindex(treasure), treasure)
      old_treasures.delete(treasure)
      i += 1
    end
    # o Limite de tesouros é de 14 Itens
    treasures = treasures[0..13]
    treasures.flatten!
    # Obtendo a EXP
    for i in 0...$game_party.actors.size
      actor = $game_party.actors[i]
      if actor.cant_get_exp? == false
        last_level = actor.level
        actor.exp += exp
        if actor.level > last_level
          @status_window.level_up(i)
        end
      end
    end
    # Obtendo o dinheiro
    $game_party.gain_gold(gold)
    # Obtendo os tesouros
    for item in treasures
      case item
      when RPG::Item
        $game_party.gain_item(item.id, 1)
      when RPG::Weapon
        $game_party.gain_weapon(item.id, 1)
      when RPG::Armor
        $game_party.gain_armor(item.id, 1)
      end
    end
    # Criar janela de resultado de Batalha
    @result_window = Window_BattleResult.new(exp, gold, treasures)
    # Definir Espera
    @phase5_wait_count = 100
  end
end

#==============================================================================
# Game_Info_Enemy
#==============================================================================

class Game_Info_Enemy
 
  attr_accessor :battled
  attr_accessor :killed
  attr_reader   :id
  attr_reader   :name
  attr_reader   :items
  attr_reader   :armors
  attr_reader   :weapons
  attr_accessor :habitat
  attr_reader   :description
 
  def initialize(id)
    @battled = 0
    @killed = 0
    @enemy = $data_enemies[id]
    @name = @enemy.name
    @id = id
    @items = {}
    for i in 1...$data.items.size
      @items[i] = 0
    end
    @weapons = {}
    for i in 1...$data.weapons.size
      @weapons[i] = 0
    end
    @armors = {}
    for i in 1...$data.armors.size
      @armors[i] = 0
    end
    @habitat = []
  end

  def exp
    return @enemy.exp if @killed
  end
 
  def gold
    return @enemy.gold if @killed
  end
 
  def gained_item(id)
    @items[id] = @items[id] + 1
  end
 
  def gained_weapon(id)
    @weapons[id] = @weapons[id] + 1
  end
 
  def gained_armor(id)
    @armors[id] = @armors[id] + 1
  end
end

#==============================================================================
# Game_System
#==============================================================================

class Game_System
 
  #--------------------------------------------------------------------------
  # - Mapas que ocorreram batalhas
  #--------------------------------------------------------------------------
 
  def maps_battled
    @maps_battled ||= []
    return @maps_battled
  end
 
  #--------------------------------------------------------------------------
  # - info_enemy(id)
  #
  #     retorna as informações de um inimigo para ser usado no bestiario.
  #--------------------------------------------------------------------------
 
  def info_enemy(id)
    if id > 999 or $data_enemies[id].nil?
      return nil
    end
    @info_enemies ||= []
    if @info_enemies[id].nil?
      @info_enemies[id] = Game_Info_Enemy.new(id)
    end
    return @info_enemies[id]
  end
 
  #--------------------------------------------------------------------------
  # - Item Obtidos
  #--------------------------------------------------------------------------
 
  def items_obtained
    if @items_obtained.nil?
      @items_obtained = []
      for i in 1...$data_items.size
        @items_obtained[i] = false
      end
    end
    return @items_obtained
  end
 
  #--------------------------------------------------------------------------
  # - Equipamentos de def. obtidos
  #--------------------------------------------------------------------------
 
  def armors_obtained
    if @armors_obtained.nil?
      @armors_obtained = []
      for i in 1...$data_armors.size
        @armors_obtained[i] = false
      end
    end
    return @armors_obtained
  end
 
  #--------------------------------------------------------------------------
  # - Armas obtidas
  #--------------------------------------------------------------------------
 
  def weapons_obtained
    if @weapons_obtained.nil?
      @weapons_obtained = []
      for i in 1...$data_weapons.size
        @weapons_obtained[i] = false
      end
    end
    return @weapons_obtained
  end
 
  #--------------------------------------------------------------------------
  # - Hash para armazenar dados
  #--------------------------------------------------------------------------
 
  def save_hash
    @save_hash ||= {}
    return @save_hash
  end
end

#==============================================================================
# Game_Party
#==============================================================================

class Game_Party
 
  alias cold_bs_gain_item gain_item
  def gain_item(id, n)
    $game_system.items_obtained[id] = true
    cold_bs_gain_item(id, n)
  end
 
  alias cold_bs_gain_armor gain_armor
  def gain_armor(id, n)
    $game_system.armors_obtained[id] = true
    cold_bs_gain_armor(id, n)
  end
 
  alias cold_bs_gain_weapon gain_weapon
  def gain_weapon(id, n)
    $game_system.weapons_obtained[id] = true
    cold_bs_gain_weapon(id, n)
  end
end

#==============================================================================
# Game_Actor
#==============================================================================

class Game_Actor
 
  alias cold_bs_setup setup
  def setup(id)
    cold_bs_setup(id)
    $game_system.weapons_obtained[@weapon_id] = true
    $game_system.armors_obtained[armor1_id] = true
    $game_system.armors_obtained[armor2_id] = true
    $game_system.armors_obtained[armor3_id] = true
    $game_system.armors_obtained[armor4_id] = true
  end
 
end

#==============================================================================
# Window_BookCommand
#==============================================================================

class Window_BookCommand < Window_Base
 
  attr_reader   :index
 
  def initialize
    super(0,0,128+32,64)
    self.contents = Bitmap.new(640-32,480-32)
    self.contents.font.size = 14
    self.contents.font.color = normal_color
    self.z = 999999
    self.opacity = 0
    @line_max = 12
    @column_max = 2
    @index = 0
    @type_index = 0
    @item_max = 0
    @type_max = 0
  end
 
  def command
    return @commands[@index]
  end
 
  def type
    return @types[@type_index]
  end
 
  def refresh(text,types, commands)
    self.contents.clear
    self.height = commands.size*22 + 86 + 24
    self.x = (640-self.width)/2
    if Options::LAYOUTB
      self.y = 50+48
    else
      self.y = (480-self.height)/2
    end
    self.contents = Bitmap.new(128, commands.size*22+54+24)
    self.contents.font.size = 14
    self.contents.font.color = normal_color
    @types = types
    @commands = commands
    @item_max = commands.size
    @type_max = types.size
    for i in 0...commands.size
      x = 0
      y = i * 22 + 32 + 24
      self.contents.draw_text(x,y,128,22,@commands[i],1)
    end
    width = define_width(@types)
    x = (128-width)/2
    self.contents.draw_text(x-22, 24, 14, 22, "??")
    self.contents.draw_text(x+width+8, 24, 14, 22, "??")
    self.contents.draw_text(x-22, 0, width - 20, 24, text,2)
    draw_type
  end
 
  def define_width(array)
    contents = Bitmap.new(640,480)
    contents.font.size = 14
    width = 0
    for command in array
      p_width = contents.text_size(command).width
      if p_width > width
        width = p_width
      end
    end
    return [width, 128-44].max
  end
 
  def draw_type
    if @type_index != @last_t_index
      @last_t_index = @type_index
      width = define_width(@types)
      x = (128-width)/2
      rect = Rect.new(x, 24, width, 22)
      self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
      self.contents.draw_text(rect, @types[@type_index],1)
    end
  end
 
  def update
    super
    if self.active and @item_max > 0 and @index >= 0
      if Input.repeat?(Input::DOWN)
        if Input.trigger?(Input::DOWN) or @index < @item_max - 1
          $game_system.se_play($data_system.cursor_se)
          @index = (@index + 1) % @item_max
        end
      end
      if Input.repeat?(Input::UP)
        if Input.trigger?(Input::UP) or @index >= 1
          $game_system.se_play($data_system.cursor_se)
          @index = (@index - 1 + @item_max) % @item_max
        end
      end
      if Input.repeat?(Input::RIGHT)
        $game_system.se_play($data_system.cursor_se)
        @type_index = (@type_index + 1) % @type_max
      end
      if Input.repeat?(Input::LEFT)
        $game_system.se_play($data_system.cursor_se)
        @type_index = (@type_index - 1) % @type_max
      end
    end
    draw_type
    update_cursor_rect
  end
 
  def update_cursor_rect
    if @index < 0
      self.cursor_rect.clear
      return
    end
    y = @index * 22 + 32 + 24
    self.cursor_rect.set(0, y, self.width-32, 22)
  end
end

#==============================================================================
# Window_Book
#==============================================================================

class Window_Book < Window_Base
 
  attr_reader   :index
 
  def initialize
    super(0,0,160*2+32,12*22+37+32)
    self.contents = Bitmap.new(640-32,480-32)
    self.contents.font.size = 14
    self.contents.font.color = normal_color
    self.opacity = 0
    self.x = (640 - self.width) / 2
    self.y = (480 - (12*22+32)) / 2
    self.z = 999999
    self.active = false
    self.visible = false
    @line_max = 12
    @column_max = 2
    @item_max = 1
    @page = 0
    self.index = 0
    commands = []
    for i in 1..500
      if $data.items[i].nil?
        commands.push("???")
      else
        commands.push($data.items[i].name)
      end
    end
    #refresh(commands)
  end
 
  def define_width(array)
    contents = Bitmap.new(640,480)
    contents.font.size = 14
    width = 0
    for command in array
      p_width = contents.text_size(command).width
      if p_width > width
        width = p_width
      end
    end
    return [width, 128-44].max
  end
 
  def index=(index)
    @index = index
    self.page = (@index/item_max_per_pag) if index >= 0
    self.page = 0 if index < 0
    if self.active and @help_window != nil
      update_help
    end
    update_cursor_rect
  end
 
  def page=(page)
    @page = page
  end
 
  def page_max
    page = (@item_max / (@column_max * @line_max))
    page += 1 if (@item_max % (@column_max * @line_max)) > 0
    return page
  end
 
  def item_max_per_pag
    return (@column_max * @line_max)
  end
 
  def column_total
    column_total = (@column_max * (page_max - 1))
    i = [@item_max - item_max_per_pag, @column_max].min
    column_total += i
    return column_total
  end
 
  def show_page
    self.ox = @page * (self.width - 32)
  end

  def help_window=(help_window)
    @help_window = help_window
    if self.active and @help_window != nil
      update_help
    end
  end
 
  def refresh(commands)
    self.contents.clear
    @commands = commands
    @item_max = commands.size
    self.contents = Bitmap.new(160*2*[page_max, 1].max,height-32)
    self.contents.font.size = 14
    self.contents.font.color = normal_color
    for i in 0...commands.size
      x = i / 12 * 160
      y = i % 12 * 22
      self.contents.draw_text(x+4,y+4,160,18,@commands[i])
    end
    for pag in 0...page_max
      rect = Rect.new(pag*320, 22*12+4, 320, 1)
      self.contents.fill_rect(rect, normal_color)
      x = (self.width-32)/2 + pag*320
      y = 22*12+5
      self.contents.draw_text(x-28-22, y, 14, 32, "??")
      self.contents.draw_text(x+28, y, 14, 32, "??")
      p = pag + 1
      text = "Pag  " + p.to_s + "/" + page_max.to_s
      self.contents.draw_text(x-32, y, 56, 32, text, 1)
    end
  end
 
  def update_cursor_rect
    if @index < 0
      self.cursor_rect.empty
      return
    end
    show_page
    x = @index / 12 * 160 - self.ox
    y = @index % 12 * 22
    self.cursor_rect.set(x, y, 160, 22)
  end
 
  def update
    super
    if self.active and @item_max > 0 and @index >= 0
      x = @index - ((item_max_per_pag) * @page)
      if Input.repeat?(Input::DOWN)
        if @index % @line_max < @line_max - 1 and
          @index + 1 < @item_max
          $game_system.se_play($data_system.cursor_se)
          @index += 1
        end
      end
      if Input.repeat?(Input::UP)
        if @index > 0 and @index % @line_max > 0
          $game_system.se_play($data_system.cursor_se)
          @index -= 1
        end
      end
      if Input.repeat?(Input::RIGHT)
        if @index + @line_max < (@page+1) * item_max_per_pag and
          @index / 24 == @page and @index + @line_max < @item_max
          $game_system.se_play($data_system.cursor_se)
          @index += @line_max
        elsif ((@index / @line_max) % @column_max == @column_max - 1 and Input.trigger?(Input::RIGHT)) or
              ((@index / @line_max) % @column_max == @column_max - 1 and @page < page_max - 1)
          $game_system.se_play($data_system.cursor_se)
          if @page == page_max - 1
            self.index = (@index + item_max_per_pag) % (page_max * item_max_per_pag)
          else
            self.index = [@index + item_max_per_pag, @item_max-1].min
          end
        end
      end
      if Input.repeat?(Input::LEFT)
        if @index - @line_max >= @page * item_max_per_pag
          $game_system.se_play($data_system.cursor_se)
          @index -= @line_max
        elsif ((@index / @line_max) % @column_max == 0 and Input.trigger?(Input::LEFT)) or
              ((@index / @line_max) % @column_max == 0 and @page > 0)
          $game_system.se_play($data_system.cursor_se)
          if @page == 0
            #x = @index - 24
            self.index = [@index + ((page_max - 1) * item_max_per_pag), @item_max-1].min
            #self.index = [(page_max - 1) * item_max_per_pag - x, @item_max-1].min
          else
            self.index = [@index - item_max_per_pag, 0].max
          end
        end
      end
    end
    if self.active and @help_window != nil
      update_help
    end
    update_cursor_rect
  end
end

#==============================================================================
# Window_Enemy
#==============================================================================

class Window_Enemy < Window_Base
 
  attr_reader   :enemy_id
 
  def initialize(enemy_id)
    super(124,52,416,398-32)
    self.opacity = 0
    self.z = 1000
    @self_active = true
    self.active = false
    self.visible = false
    refresh(enemy_id)
  end
 
  def need_refresh?(killed)
    return (@need_refresh[0] != killed)
  end
 
  def visible=(value)
    super(value)
    @view.visible = value unless @view.nil?
  end
 
  def dispose
    super
    @view.dispose = value unless @view.nil?
  end
 
  def refresh(enemy_id)
    @enemy_id = enemy_id
    @enemy = $game_system.info_enemy(enemy_id)
    @index = 0
    @items = []
    for i in 1...$data.items.size
      if @enemy.items[i] > 0
        @items.push($data_items[i])
      end
    end
    for i in 1...$data.weapons.size
      if @enemy.weapons[i] > 0
        @items.push($data_weapons[i])
      end
    end
    for i in 1...$data.armors.size
      if @enemy.armors[i] > 0
        @items.push($data_armors[i])
      end
    end
    @maps = @enemy.habitat
    i_m = [@items.size, 6 - [@maps.size, 3].min].min
    @max_items = [[[@items.size, 0].max, 6].min - @maps.size, i_m].max
    m_m = [@maps.size, 6 - @max_items].min
    @max_maps = [[[@maps.size, 0].max, 6].min - @items.size, m_m].max
    @need_refresh = [0 + @enemy.killed,0 + @enemy.battled]
    self.contents = Bitmap.new(416-32,398-64)
    self.contents.font.size = 14
    self.contents.font.color = normal_color
    draw_name(0, 0)
    draw_battler(0,22)
    draw_exp(260, 22)
    draw_gold(260, 44)
    draw_killed(260, 66)
    self.contents.draw_text(260, 88, 124, 18, "Obtained Items :")
    rect = Rect.new(256,106,130,1)
    self.contents.fill_rect(rect, normal_color)
    draw_items(256, 107)
    i_size = @max_items*21
    self.contents.draw_text(260, 110+i_size, 124, 18, "Habitat:")
    rect = Rect.new(256,128+i_size,130,1)
    self.contents.fill_rect(rect, normal_color)
    draw_maps(256, 129+i_size)
    y = 67+67+23+23+88+4
    if Options::ENEMY_DESCRIPTION[@enemy.id] != ""
      self.contents.draw_text(4, y-20, 68, 22, "Description:")
      rect = Rect.new(0, y-1, 68, 1)
      self.contents.fill_rect(rect, normal_color)
    end
    draw_description(0,y)
  end

  def draw_name(x,y)
    id = sprintf("%03d", @enemy.id.to_s)
    name = id + ": " + @enemy.name
    width = self.contents.text_size(name).width
    self.contents.draw_text(x + 4, y, width, 22, name)
    rect = Rect.new(x,y+19,width+8,1)
    self.contents.fill_rect(rect, normal_color)
  end
 
  def draw_exp(x,y)
    self.contents.draw_text(x, y, 64, 22, "Exp: ")
    if @enemy.killed > 0
      exp = @enemy.exp.to_s
      self.contents.draw_text(x + 64, y, 60, 22, exp, 2)
    else
      self.contents.draw_text(x + 64, y, 60, 22, "???", 2)
    end
  end
 
  def draw_gold(x,y)
    g = $data_system.words.gold
    self.contents.draw_text(x, y, 64, 22, g)
    if @enemy.killed > 0
      gold = @enemy.gold.to_s
      self.contents.draw_text(x + 64, y, 60, 22, gold, 2)
    else
      self.contents.draw_text(x + 64, y, 60, 22, "???", 2)
    end
  end
 
  def draw_killed(x,y)
    self.contents.draw_text(x, y, 64, 22, "Defeated:")
    #if @enemy.killed > 0
    self.contents.draw_text(x + 64, y, 60, 22, @enemy.killed.to_s, 2)
    #end
  end
 
  def draw_items(x,y)
    @items_x = x
    @items_y = y
    @items_index = 0
    @items_active = false
    @items_oy = 0
    y2 = 0
    z = [@items.size * 21, (@max_items - 1)*21].min
    for item in @items
      if y2.between?(@items_oy, z)
        draw_item(item, x+4, y + y2)
        y2 += 21
      end
    end
  end
 
  def draw_item(item, x, y)
    rect = Rect.new(x, y, 124, 21)
    self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
    name = item.name
    self.contents.draw_text(x+2, y, 100, 20, name)
    case item
    when RPG::Item
      number = @enemy.items[item.id]
    when RPG::Weapon
      number = @enemy.weapons[item.id]
    when RPG::Armor
      number = @enemy.armors[item.id]
    end
    self.contents.draw_text(x+104, y, 18, 20, number.to_s, 2)
    rect = Rect.new(x, y + 20, 124, 1)
    self.contents.fill_rect(rect, normal_color)
  end
 
  def refresh_items
    row = @items_index
    if row < @items_oy / 21
      @items_oy = self.top_row(row, @items.size)
    end
    if row > @items_oy / 21 + (@max_items - 1)
      @items_oy = self.top_row(row - (@max_items - 1), @items.size)
    end
    x = @items_x
    y = @items_y
    y2 = 0
    y3 = 0
    z = [@items.size * 21, (@max_items - 1)*21].min + @items_oy
    for item in @items
      if y2.between?(@items_oy, z)
        draw_item(item, x+4, y + y3)
        y3 += 21
      end
      y2 += 21
    end
  end
 
  def draw_maps(x,y)
    @maps_x = x
    @maps_y = y
    @maps_index = 0
    @maps_active = false
    @maps_oy = 0
    y2 = 0
    z = [@maps.size * 21, (@max_maps - 1)*21].min
    for map in @maps
      if y2.between?(@maps_oy, z)
        draw_map(map, x, y + y2)
        y2 += 21
      end
    end
  end
 
  def draw_map(map, x, y)
    rect = Rect.new(x + 4, y, 124, 21)
    self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
    self.contents.draw_text(x + 6, y, 122, 20, map)
    rect = Rect.new(x + 4, y + 20, 124, 1)
    self.contents.fill_rect(rect, normal_color)
  end
 
  def refresh_maps
    row = @maps_index
    if row < @maps_oy / 21
      @maps_oy = self.top_row(row, @maps.size)
    end
    if row > @maps_oy / 21 + (@max_maps - 1)
      @maps_oy = self.top_row(row - (@max_maps - 1), @maps.size)
    end
    x = @maps_x
    y = @maps_y
    y2 = 0
    y3 = 0
    z = [@maps.size * 21, (@max_maps - 1)*21].min + @maps_oy
    for map in @maps
      if y2.between?(@maps_oy, z)
        draw_map(map, x, y + y3)
        y3 += 21
      end
      y2 += 21
    end
  end
 
  def draw_description(x, y)
    e_description = Options::ENEMY_DESCRIPTION[@enemy.id]
    description = lines(e_description, self.width - 32)
    for i in 0...description.size
      self.contents.draw_text(x+4, y+2+i*20, self.width - 32, 20, description[i])
    end
  end
 
  def line(text)
    words = text.split(" ")
    return_text = ""
    for word in words
      x = "!@$%¨&*()"
      return_text += word + x + " "
      return_text2 = return_text.gsub(x,"")
      t_width = self.contents.text_size(return_text2).width
      if t_width > self.width - 32
        return return_text.gsub(" "+word+x, "")
      else
        return_text.gsub!(word+x, word)
      end
    end
  end
 
  def draw_battler(x, y)
    enemy = $data.enemies[@enemy.id]
    bitmap = RPG::Cache.battler(enemy.battler_name, enemy.battler_hue)
    @view = Viewport.new(0, 0, 640, 480)
    @view.z = self.z - 10
    @view.visible = self.visible
    @sprite = Sprite.new(@view)
    @sprite.bitmap =  bitmap
    w = bitmap.width
    h = bitmap.height
    @sprite.x = x + (256 - w)/2 + self.x + 16
    @sprite.y = y + (256 - h)/2 + self.y + 16
  end
 
  def update
    super
    if @self_active and self.active
      if Input.repeat?(Input::DOWN)
        $game_system.se_play($data_system.cursor_se)
        @index = (@index + 1) % 2
      end
      if Input.repeat?(Input::UP)
        $game_system.se_play($data_system.cursor_se)
        @index = (@index - 1 + 2) % 2
      end
      if Input.repeat?(Input::RIGHT)
        case @index
        when 0
          if @items.size > 0
            $game_system.se_play($data_system.cursor_se)
            @self_active = false
            @items_active = true
          end
        when 1
          if @maps.size > 0
            $game_system.se_play($data_system.cursor_se)
            @self_active = false
            @maps_active = true
          end
        end
      end
    elsif @items_active and self.active and @items.size > 0
      if Input.repeat?(Input::DOWN)
        $game_system.se_play($data_system.cursor_se)
        @items_index = (@items_index + 1) % @items.size
        refresh_items
      end
      if Input.repeat?(Input::UP)
        $game_system.se_play($data_system.cursor_se)
        @items_index = (@items_index - 1 + @items.size) % @items.size
        refresh_items
      end
      if Input.repeat?(Input::LEFT)
        $game_system.se_play($data_system.cursor_se)
        @self_active = true
        @items_active = false
      end
    elsif @maps_active and self.active and @maps.size > 0
      if Input.repeat?(Input::DOWN)
        $game_system.se_play($data_system.cursor_se)
        @maps_index = (@maps_index + 1) % @maps.size
        refresh_maps
      end
      if Input.repeat?(Input::UP)
        $game_system.se_play($data_system.cursor_se)
        @maps_index = (@maps_index - 1 + @maps.size) % @maps.size
        refresh_maps
      end
      if Input.repeat?(Input::LEFT)
        $game_system.se_play($data_system.cursor_se)
        @self_active = true
        @maps_active = false
      end
    end
    update_cursor
  end
 
  def update_cursor
    if @self_active and self.active
      i_size = @max_items * 21 + 22
      y = 88 + i_size * @index
      self.cursor_rect.set(256, y, 128, 18)
    elsif @items_active and self.active
      y = 88 + 21*@items_index + 19 - @items_oy
      self.cursor_rect.set(260, y, 124, 20)
    elsif @maps_active and self.active
      i_size = @max_items * 21 + 22
      y = 88 + 21*@maps_index + 19 - @maps_oy + i_size
      self.cursor_rect.set(260, y, 124, 20)
    elsif !self.active
      self.cursor_rect.empty
    end
  end
 
  def top_row(row, row_max)
    if row < 0
      row = 0
    end
    if row > row_max - 1
      row = row_max - 1
    end
    return row * 21
  end
end


#==============================================================================
# Window_Enemies
#==============================================================================

class Window_Enemies
 
  attr_accessor :active
 
  def initialize
    @index = 0
    @windows = []
    @last_index = 0
    @active = false
    self.visible = false
  end
   
  def visible=(value)
    @visible = value
    @windows[@index].visible = value if @windows[@index].is_a?(Window)
  end
 
  def refresh(windows)
    @windows[@index].visible = false if @windows[@index].is_a?(Window)
    @windows[@index].active = false if @windows[@index].is_a?(Window)
    @windows = windows
    @index = 0
    @windows[@index].visible = true if @windows[@index].is_a?(Window)
  end
&nbs


Blizzard

Why don't you simply use my Bestiary and G_G's plugin for Blizz-ABS?
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.