Additional Enemy Drops

30 de julho de 2011

Additional Enemy Drops é um script para o RPG Maker XP que foi desenvolvido para você controlar drops (uma giria relativamente moderna para itens que o inimigo deixa quando é derrotado ou morto, que o jogador recolhe) múltiplos de armas, armaduras e ítens em geral. Com ele, você também pode controlar a porcentagem de drop também.

Para configurar o script, coloque o script depois do SDK e em cima do Main. Para customizar os seus drops, olhe nas instruções de customização.

Se tiver mais dúvidas quanto a implementação de scripts no RPG Maker XP e VX, olhe este post.

#==============================================================================
# ** Additional Enemy Drops
#------------------------------------------------------------------------------
# SephirothSpawn
# Version 2
# 2006-09-20
#------------------------------------------------------------------------------
# * Description :
#
#   This script was designed to let you control multiple item, weapon & armor
#   drops for each enemy. You can also control the drop percentages as well.
#------------------------------------------------------------------------------
# * Instructions :
#
#   Place The Script Below the SDK and Above Main.
#   To Customize your drops, refer to the customization instructions.
#------------------------------------------------------------------------------
# * Customization :
#
#    = { monster_id => { key => percent, ... }
#
#   Enemy_Item_Drops
#    - Description : List Of Items Dropped By Monster
#    - Key : Item ID
#
#   Enemy_Weapon_Drops
#    - Description : List Of Weapons Dropped By Monster
#    - Key : Weapon ID
#
#   Enemy_Armor_Drops
#    - Description : List Of Armors Dropped By Monster
#    - Key : Armor ID
#------------------------------------------------------------------------------
# * Syntax :
#
#   Collect Random Drop List of Items, Weapons or Armors. These methods will
#   return a random list of dropped items.
#    - .multi_item_drops
#    - .multi_weapon_drops
#    - .multi_armor_drops
#
#   Force Enemy to Drop Items, Weapons & Armors. All items will be
#   automatically gained, and a list of RPG::Items, RPG::Weapons & RPG::Armors
#   will be returned.
#    - .drop_multi_items
#==============================================================================

#------------------------------------------------------------------------------
# * SDK Log Script
#------------------------------------------------------------------------------
SDK.log('Additional Enemy Drops', 'SephirothSpawn', 1, '2006-07-09')

#------------------------------------------------------------------------------
# * Begin SDK Enable Test
#------------------------------------------------------------------------------
if SDK.state('Additional Enemy Drops')

#==============================================================================
# ** Game_Enemy
#==============================================================================

class Game_Enemy < Game_Battler
  #--------------------------------------------------------------------------
  # * Enemy Item Drops   #  ~ enemy_id => { item_id => drop_percent, ... }
  #--------------------------------------------------------------------------
  Enemy_Item_Drops = {
    1 => {1 => 50, 2 => 30, 3 => 10}
  }
  #--------------------------------------------------------------------------
  # * Enemy Weapon Drops
  #  ~ enemy_id => { weapon_id => drop_percent, ... }
  #--------------------------------------------------------------------------
  Enemy_Weapon_Drops = {
    1 => {1 => 25}
  }
  #--------------------------------------------------------------------------
  # * Enemy Item Drops
  #  ~ enemy_id => { item_id => drop_percent, ... }
  #--------------------------------------------------------------------------
  Enemy_Armor_Drops = {
    1 => {1 => 25}
  }
  #--------------------------------------------------------------------------
  # * Multiple Item Drops
  #--------------------------------------------------------------------------
  def multi_item_drops
    items = []
    # Item Lists
    if Enemy_Item_Drops.has_key?(@enemy_id)
      # Passes Each Item
      Enemy_Item_Drops[@enemy_id].each do |item_id, drop_percent|
        # Adds items If Randomly Dropped
        if rand(100) < drop_percent
          items << $data_items[item_id]
        end
      end
    end
    return items
  end
  #--------------------------------------------------------------------------
  # * Multiple Weapon Drops
  #--------------------------------------------------------------------------
  def multi_weapon_drops
    items = []
    # Item Lists
    if Enemy_Weapon_Drops.has_key?(@enemy_id)
      # Passes Each Weapon
      Enemy_Weapon_Drops[@enemy_id].each do |weapon_id, drop_percent|
        # Adds items If Randomly Dropped
        if rand(100) < drop_percent
          items << $data_weapons[weapon_id]
        end
      end
    end
    return items
  end
  #--------------------------------------------------------------------------
  # * Multiple Armor Drops
  #--------------------------------------------------------------------------
  def multi_armor_drops
    items = []
    if Enemy_Armor_Drops.has_key?(@enemy_id)
      # Passes Each Armor
      Enemy_Armor_Drops[@enemy_id].each do |armor_id, drop_percent|
        # Adds items If Randomly Dropped
        if rand(100) < drop_percent
          items << $data_armors[armor_id]
        end
      end
    end
    return items
  end
  #--------------------------------------------------------------------------
  # * Drop Multi Items
  #--------------------------------------------------------------------------
  def drop_multi_items
    # Starts Item List
    items = []
    items << multi_item_drops
    items << multi_weapon_drops
    items << multi_armor_drops
    items.flatten!
    # Passes Through Item Drop List
    for item in items
      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
    # Returns Drop List
    return items
  end
end

#==============================================================================
# ** Window_BattleResult
#==============================================================================

class Window_BattleResult < Window_Base
  #--------------------------------------------------------------------------
  # * Add Multiple Drops
  #--------------------------------------------------------------------------
  def add_multi_drops
    # Collects Extra Droppings
    for enemy in $game_troop.enemies
      # Adds Extra Treasures
      @treasures << enemy.drop_multi_items
    end
    # Flatten Array
    @treasures.flatten!
    # Sort Treasures By ID
    @treasures.sort! {|a, b| a.id  b.id}
    # Sort Treasures By Type
    @treasures.sort! do |a, b|
      a_class = a.is_a?(RPG::Item) ? 0 : a.is_a?(RPG::Weapon) ? 1 : 2
      b_class = b.is_a?(RPG::Item) ? 0 : b.is_a?(RPG::Weapon) ? 1 : 2
      a_class  b_class
    end
    # Adjust Height & Window Contents
    self.height = [@treasures.size * 32 + 64, 256].min
    self.contents = Bitmap.new(width - 32, @treasures.size * 32 + 32)
    # Adjust Y
    self.y = 160 - height / 2
    # Refresh Window
    refresh
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    super
    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

#==============================================================================
# ** Scene_Battle
#==============================================================================

class Scene_Battle
  #--------------------------------------------------------------------------
  # * Alias Listings
  #--------------------------------------------------------------------------
  alias seph_enemydrops_scnbtl_sp5 start_phase5
  #--------------------------------------------------------------------------
  # * Start After Battle Phase
  #--------------------------------------------------------------------------
  def start_phase5
    # Original Start Phase 5
    seph_enemydrops_scnbtl_sp5
    # Add Extra Item Drops
    @result_window.add_multi_drops
  end
end

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

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!