==============================================================================
# ** Dynamic & Additional Enemy Drops
#------------------------------------------------------------------------------
# SephirothSpawn
# Version 3
# 2007-03-01
# SDK : Version 2.0+, Part 1
#------------------------------------------------------------------------------
# * Version History :
#
# Version 1 ---------------------------------------------------- (2006-07-09)
# Version 2 ---------------------------------------------------- (2006-09-20)
# - Update : Re-scripted Much of the System
# Version 2.1 ------------------------------------------------- (2006-12-13)
# - Addition : Added Max Number of Drops Feature
# Version 3 ---------------------------------------------------- (2007-03-01)
# - Update : Re-scripted the entire system. Added Dynamic Drops.
#------------------------------------------------------------------------------
# * Requirements :
#
# Method & Class Library 2.1+
# Dynamic Enemies (3.0 +) (Optional : Required For Dynamic Drops)
#------------------------------------------------------------------------------
# * 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.
#
# With the Dynamic Enemies script, you can also make drops occur at certain
# levels.
#
# You can set a number of times an item can be dropped in each way.
#
# As a bonus, you can limit the number of items, weapons, armors or total
# items dropped by a monster.
#------------------------------------------------------------------------------
# * Instructions :
#
# Place The Script Below the SDK and Above Main.
# To Customize your drops, refer to the customization instructions.
#------------------------------------------------------------------------------
# * Customization :
#
# Max Drops (Item, Weapon, Armor & Overall Drops)
# - <Type> = { enemy_id => max, ... }
#
# Types : Max_Item_Drops, Max_Weapon_Drops,
# Max_Armor_Drops, Max_Overall_Drops
#
# Additional Drops
# - <Type> = { enemy_id => { item_id => [max, drop_percent], ... }, ... }
#
# Types : Enemy_Item_Drops, Enemy_Weapon_Drops, Enemy_Armor_Drops
#
# Dynamic Drops
# - <Type> = {
# enemy_id => {
# level => {
# <operator> => { item_id => [max, drop_percent], ... }
# , ... }
# , ... }
# , ... }
# }
#
# <Type> = Dynamic_Item_Drops, Dynamic_Weapon_Drops, Dynamic_Armor_Drops
#
# <operator> : 0 - Less Than, 1 - Less Than or Equal To, 2 - Equals,
# 3 - Greater Than or Equal To, 4 - Greater Than
#------------------------------------------------------------------------------
# * Syntax :
#
# Force Enemy to Drop Items (Auto-added to inventory)
# - <game_enemy>.multi_item_drops
# - <game_enemy>.multi_weapon_drops
# - <game_enemy>.multi_armor_drops
# - <game_enemy>.drop_multi_items
#==============================================================================
#------------------------------------------------------------------------------
# * SDK Log Script
#------------------------------------------------------------------------------
SDK.log('Dynamic + Additional Enemy Drops', 'SephirothSpawn', 3, '2007-03-01')
SDK.check_requirements(2.0, [], {'Method & Class Library' => 2.1})
#------------------------------------------------------------------------------
# * Begin SDK Enable Test
#------------------------------------------------------------------------------
unless SDK.enabled?('Dynamic Enemies', 3)
p 'Dynamic Enemies System Not Found. You will not be able to set Dynamic ' +
'item, weapon and armor drops.'
end
#------------------------------------------------------------------------------
# * End SDK Enable Test
#------------------------------------------------------------------------------
#------------------------------------------------------------------------------
# * Begin SDK Enable Test
#------------------------------------------------------------------------------
if SDK.enabled?('Dynamic + Additional Enemy Drops')
#==============================================================================
# ** Dynamic_Additiona_Drops
#==============================================================================
module DA_Enemy_Drops
#--------------------------------------------------------------------------
# * Max Item, Weapon & Armor Drops
#
# ~ enemy_id => max_items
#--------------------------------------------------------------------------
Max_Item_Drops = {1 => 5, 2 => 4}
Max_Weapon_Drops = {1 => 0, 2 => 0}
Max_Armor_Drops = {1 => 0, 2 => 0}
Max_Overall_Drops = {1 => 5, 2 => 4}
#--------------------------------------------------------------------------
# * Enemy Item Drops
#
# ~ enemy_id => { item_id => [max, drop_percent], ... }
#--------------------------------------------------------------------------
Enemy_Item_Drops = {
# Enemy 1
1 => {32 => [5, 70], 33 => [5, 65]},
2 => {32 => [2, 70], 35 => [3, 70], 36 => [2, 60]},
# Item 1 : 3* 50%, Item 2 : 2 * 30%, Item 3 : 1 * 10%
}
#--------------------------------------------------------------------------
# * Enemy Weapon Drops
#
# ~ enemy_id => { weapon_id => [max, drop_percent], ... }
#--------------------------------------------------------------------------
Enemy_Weapon_Drops = {
# Enemy 1
1 => {
# Weapon 1 : 2 * 25%
}
}
#--------------------------------------------------------------------------
# * Enemy Item Drops
#
# ~ enemy_id => { armor_id => [max, drop_percent], ... }
#--------------------------------------------------------------------------
Enemy_Armor_Drops = {
# Enemy 1
1 => {
# Armor 1 : 2 * 25%
}
}
#--------------------------------------------------------------------------
# * Dynamic Item Drops
#
# ~ enemy_id => { level => { <operator_value> =>
# { item_id => [max, drop_percent] }, ... }, ... }
#
# Operator Value : 0 - Less Than, 1 - Less Than or Equal To, 2 - Equals,
# 3 - Greater Than or Equal To, 4 - Greater Than
#--------------------------------------------------------------------------
Dynamic_Item_Drops = {
# Enemy 1
# Level 5
5 => {
# Greater or Equal to 5
3 => {
# Item 4 : 3 * 50%, Item 5 : 2 * 25%
}
}
}
#--------------------------------------------------------------------------
# * Dynamic Weapon Drops
#
# ~ enemy_id => { level => { <operator_value> =>
# { weapon_id => [max, drop_percent] }, ... }, ... }
#
# Operator Value : 0 - Less Than, 1 - Less Than or Equal To, 2 - Equals,
# 3 - Greater Than or Equal To, 4 - Greater Than
#--------------------------------------------------------------------------
Dynamic_Weapon_Drops = {
# Enemy 1
# Level 5
5 => {
# Greater or Equal to 5
3 => {
# Weapon 2 : 3 * 25%, Armor 3 : 2 * 5%
}
}
}
#--------------------------------------------------------------------------
# * Dynamic Armor Drops
#
# ~ enemy_id => { level => { <operator_value> =>
# { armor_id => [max, drop_percent] }, ... }, ... }
#
# Operator Value : 0 - Less Than, 1 - Less Than or Equal To, 2 - Equals,
# 3 - Greater Than or Equal To, 4 - Greater Than
#--------------------------------------------------------------------------
Dynamic_Armor_Drops = {
# Enemy 1
1 => {
# Level 5
5 => {
# Greater or Equal to 5
3 => {
# Armor 2 : 3 * 25%, Armor 3 : 2 * 5%
}
}
}
#--------------------------------------------------------------------------
# * Collect Item List
#--------------------------------------------------------------------------
def self. collect_item_list (c1, c2, c3, enemy_id, level = nil)
# Starts Item List
items = [32, 33, 34, 35, 36, 37, 38, 39, 40]
# If Enemy Has Additional Item Drop
if c1.has_key?(enemy_id)
# Pass Through Item List
c1[enemy_id].each do |item_id, par|
par[0].times do
items << item_id if rand(100) < par[1]
end
end
end
# If Max Items Defined
if c3.has_key?(enemy_id)
# Until Item List is at max size
until items.size <= c3[enemy_id]
# Delete Random Item
items.delete_at(rand(items.size))
end
end
# Returns Item List
return items.sort
end
#--------------------------------------------------------------------------
# * Generate Item List
#--------------------------------------------------------------------------
def self.generate_item_list(enemy_id, level = nil)
return self.collect_item_list(Enemy_Item_Drops, Dynamic_Item_Drops,
Max_Item_Drops, enemy_id, level)
end
#--------------------------------------------------------------------------
# * Generate Weapon List
#--------------------------------------------------------------------------
def self.generate_weapon_list(enemy_id, level = nil)
return self.collect_item_list(Enemy_Weapon_Drops, Dynamic_Weapon_Drops,
Max_Weapon_Drops, enemy_id, level)
end
#--------------------------------------------------------------------------
# * Generate Armor List
#--------------------------------------------------------------------------
def self.generate_armor_list(enemy_id, level = nil)
return self.collect_item_list(Enemy_Armor_Drops, Dynamic_Armor_Drops,
Max_Armor_Drops, enemy_id, level)
end
#--------------------------------------------------------------------------
# * Generate Complete List
#--------------------------------------------------------------------------
def self.generate_complete_list(enemy_id, level = nil)
# Start Item List
list = []
# Collect Items
items = self.generate_item_list(enemy_id, level)
items.each {|item_id| list << $data_items[item_id]}
# Collect Weapons
weapons = self.generate_weapon_list(enemy_id, level)
weapons.each {|weapon_id| list << $data_weapons[weapon_id]}
# Collect Armors
armors = self.generate_armor_list(enemy_id, level)
armors.each {|armor_id| list << $data_armors[armor_id]}
# If Max Items Defined
if Max_Overall_Drops.has_key?(enemy_id)
# Until Item List is at max size
until list.size <= Max_Overall_Drops[enemy_id]
# Delete Random Item
list.delete_at(rand(list.size))
end
end
# Gains Items
for item in list
# Branch By Item Type
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
# Return Drop List
return list
end
end
#==============================================================================
# ** Game_Enemy
#==============================================================================
class Game_Enemy < Game_Battler
#--------------------------------------------------------------------------
# * Multiple Item Drops
#--------------------------------------------------------------------------
def multi_item_drops
return DA_Enemy_Drops.generate_item_list(@enemy_id, @level)
end
#--------------------------------------------------------------------------
# * Multiple Weapon Drops
#--------------------------------------------------------------------------
def multi_weapon_drops
return DA_Enemy_Drops.generate_weapon_list(@enemy_id, @level)
end
#--------------------------------------------------------------------------
# * Multiple Armor Drops
#--------------------------------------------------------------------------
def multi_armor_drops
return DA_Enemy_Drops.generate_armor_list(@enemy_id, @level)
end
#--------------------------------------------------------------------------
# * Drop Multi Items
#--------------------------------------------------------------------------
def drop_multi_items
return DA_Enemy_Drops.generate_complete_list(@enemy_id, @level)
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 - (self.height - 32)
end
end
end
#==============================================================================
# ** Scene_Battle
#==============================================================================
class Scene_Battle
#--------------------------------------------------------------------------
# * Alias Listings
#--------------------------------------------------------------------------
alias_method :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