Quick Treasure Chest [RPG Maker XP]

25 de agosto de 2016

Quick Treasure Chest é um script para o RPG Maker XP criado pelo SephirothSpawn que foi desenvolvido para permitir que o usuário crie facilmente tesouros para ganhar gold, itens, armas armaduras ou qualquer outra combinação. Ele cria uma pequena janela que mostra os itens ganhos.

O script é de simples instalação, precisando ser colocado abaixo do “SDK” e acima do “Main”.

Nos comentários do código tem mais informações sobre a sintaxe para os chamados para os tipos de ganho em “Syntax“.

Código do Script

#==============================================================================
# ** Quick Treasure Chest
#------------------------------------------------------------------------------
# SephirothSpawn
# Version 1
# 2006-07-09
#------------------------------------------------------------------------------
# * Description :
#
#   This script was designed to allow you to make easy treasure chest for
#   gaining gold, items, weapons, armors or any combination. A small window
#   will appear displaying gained items.
#------------------------------------------------------------------------------
# * Instructions :
#
#   Place The Script Below the SDK and Above Main.
#   Refer to Syntax for gaining type callings.
#------------------------------------------------------------------------------
# * Syntax :
#
#   How to Gain Gold
#    - Call Script: gain_gold(amount)
#
#   How to Gain Items
#    - Call Script: gain_items({item_id => n, ...})
#
#   How to Gain Weapons
#    - Call Script: gain_weapons({weapon_id => n, ...})
#
#   How to Gain Armors
#    - Call Script: gain_armors({armor_id => n, ...})
#
#   How to Gain Combination
#
#    - Call Script: gold = amount
#                  i = {item_id => n, ...}
#                  w = {weapon_id => n, ...}
#                  a = {armor_id => n, ...}
#                  gain_combined(gold, i, w, a)
#
#   N = number of items to gain
#==============================================================================

#------------------------------------------------------------------------------
# * SDK Log Script
#------------------------------------------------------------------------------
SDK.log('Quick Treasure Chest', 'SephirothSpawn', 1, '2006-07-09')

#------------------------------------------------------------------------------
# * Begin SDK Enable Test
#------------------------------------------------------------------------------
if SDK.state('Quick Treasure Chest')
  
#==============================================================================
# ** Window_QuickTreasure
#==============================================================================

class Window_QuickTreasure < Window_Base
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize(kind, items)
    super(160, 128, 320, 96)
    item_max = 0
    # Finds Item Max
    items.each do |list|
      if list.is_a?(Hash)
        item_max += list.keys.size
      else
        item_max += 1
      end
    end
    # Creates Contents
    self.contents = Bitmap.new(width - 32, item_max * 32 + 32)
    self.opacity = 160
    refresh(kind, items)
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh(kind, items)
    self.contents.font.color = system_color
    self.contents.draw_text(0, 0, 288, 32, 
      'You Gained the Following Item(s)', 1)
    self.contents.font.color = normal_color
    y = 32
    case kind
    when 0 # Just Items
      items[0].each do |item_id, n|
        item = $data_items[item_id]
        next if item.nil?
        draw_item(y, item, n)
        y += 32
      end
    when 1 # Just Weapons
      items[0].each do |weapon_id, n|
        item = $data_weapons[weapon_id]
        next if item.nil?
        draw_item(y, item, n)
        y += 32
      end
    when 2 # Just Armors
      items[0].each do |armor_id, n|
        item = $data_armors[armor_id]
        next if item.nil?
        draw_item(y, item, n)
        y += 32
      end
    when 3 # Money
      draw_gold(y, items[0])
    when 4 # All
      draw_gold(y, items[3])
      y += 32
      items[0].each do |item_id, n|
        item = $data_items[item_id]
        next if item.nil?
        draw_item(y, item, n)
        y += 32
      end
      items[1].each do |weapon_id, n|
        item = $data_weapons[weapon_id]
        next if item.nil?
        draw_item(y, item, n)
        y += 32
      end
      items[2].each do |armor_id, n|
        item = $data_armors[armor_id]
        next if item.nil?
        draw_item(y, item, n)
        y += 32
      end
    end
  end
  #--------------------------------------------------------------------------
  # * Draw Item
  #--------------------------------------------------------------------------
  def draw_item(y, item, n)
    icon = RPG::Cache.icon(item.icon_name)
    self.contents.blt(4, y + 4, icon, Rect.new(0, 0, 24, 24))
    self.contents.draw_text(32, y, 288, 32, item.name)
    self.contents.draw_text(- 4, y, 288, 32, n.to_s, 2)
  end
  #--------------------------------------------------------------------------
  # * Draw Gold
  #--------------------------------------------------------------------------
  def draw_gold(y, n)
    self.contents.draw_text(4, y, 320, 32, 'Gained Gold :')
    self.contents.draw_text(-4, y, 288, 32, n.to_s, 2)
  end
  #--------------------------------------------------------------------------
  # * Frame update
  #--------------------------------------------------------------------------
  def update
    if Input.press?(Input::UP)
      self.oy -= 4 if self.oy > 0
    elsif Input.press?(Input::DOWN)
      self.oy += 4 if self.oy < self.contents.height - 64
    end
  end
end

#==============================================================================
# ** Interpreter
#==============================================================================

class Interpreter
  #--------------------------------------------------------------------------
  # * Gain Gold
  #--------------------------------------------------------------------------
  def gain_gold(amount)
    $game_system.se_play($data_system.decision_se)
    $game_party.gain_gold(amount)
    $scene.auto_item_aquire(3, amount)
  end
  #--------------------------------------------------------------------------
  # * Gain Item
  #--------------------------------------------------------------------------
  def gain_items(items = {})
    $game_system.se_play($data_system.decision_se)
    items.each {|id, n| $game_party.gain_item(id, n)}
    $scene.auto_item_aquire(0, items)
  end
  #--------------------------------------------------------------------------
  # * Gain Weapons
  #--------------------------------------------------------------------------
  def gain_weapons(weapons = {})
    $game_system.se_play($data_system.decision_se)
    weapons.each {|id, n| $game_party.gain_weapon(id, n)}
    $scene.auto_item_aquire(1, weapons)
  end
  #--------------------------------------------------------------------------
  # * Gain Armors
  #--------------------------------------------------------------------------
  def gain_armors(armors = {})
    $game_system.se_play($data_system.decision_se)
    armors.each {|id, n| $game_party.gain_armor(id, n)}
    $scene.auto_item_aquire(2, armors)
  end
  #--------------------------------------------------------------------------
  # * Gain Combined
  #--------------------------------------------------------------------------
  def gain_combined(gold = 0, items = {}, weapons = {}, armors = {})
    $game_system.se_play($data_system.decision_se)
    $game_party.gain_gold(gold)
    items.each {|id, n| $game_party.gain_item(id, n)}
    weapons.each {|id, n| $game_party.gain_weapon(id, n)}
    armors.each {|id, n| $game_party.gain_armor(id, n)}
    $scene.auto_item_aquire(4, gold, items, weapons, armors)
  end
end

#==============================================================================
# ** Scene_Map
#==============================================================================

class Scene_Map
  #--------------------------------------------------------------------------
  # * Alias Listings
  #--------------------------------------------------------------------------
  alias seph_autoaqitem_scnmap_update update
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    # If Item Aquired Window On
    unless @autotreasure_window.nil?
      update_auto_treasure
      return
    end
    # Original Update Method
    seph_autoaqitem_scnmap_update
  end
  #--------------------------------------------------------------------------
  # * Frame Update : Auto Treasure Window
  #--------------------------------------------------------------------------
  def update_auto_treasure
    # Update Map, System, Screen, Spriteset & Windows
    $game_map.update
    $game_system.map_interpreter.update
    $game_system.update
    $game_screen.update
    @spriteset.update
    @message_window.update
    @autotreasure_window.update
    # If C Button is Pressed
    if Input.trigger?(Input::C)
      # Delete Item Aquired Windows
      @autotreasure_window.dispose
      @autotreasure_window = nil
    end
  end
  #--------------------------------------------------------------------------
  # * Auto Item Aquire Start
  #--------------------------------------------------------------------------
  def auto_item_aquire(kind, *items)
    # Create Auto Item Aquire Window
    @autotreasure_window = Window_QuickTreasure.new(kind, items)
  end
end

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

Mais RMXP

Observação: se você gostou deste post ou ele lhe foi útil de alguma forma, por favor considere apoiar financeiramente a Gaming Room. Fico feliz só de ajudar, mas a contribuição do visitante é muito importante para que este site continua existindo e para que eu possa continuar provendo este tipo de conteúdo e melhorar cada vez mais. Clique aqui e saiba como. Obrigado!

Deixe um comentário

Inscreva-se na nossa newsletter!