#_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
#_/ Item Drop Expansion - KGC_ExtraDropItem
#_/ Last Update: 2008/08/28
#_/ Translation by Mr. Anonymous
#_/ KGC Site:
#_/
http://f44.aaa.livedoor.j...echlist_vx.html
#_/ Translator's Blog:
#_/
http://mraprojects.wordpress.com
#_/----------------------------------------------------------------------------
#_/ This script allows you to increase the amount of items and equipment which
#_/ are "dropped" by an enemy after it is defeated.
#_/----------------------------------------------------------------------------
#_/ Instructions For Usage
#_/ To make use of this function, you must insert the <drop> tag into the
#_/ "Notes" box in the desired enemy in the database.
#_/
#_/ The format is as such: <drop ItemType:ID Probability/Percentile>
#_/ Where ItemType = A = Armor, I = Item, W = Weapon
#_/ Where ID = The ID # of the item/equipment in the database
#_/ Where Probability = A fraction statement (IE 1/4) which determines the
#_/ chance of the item dropping
#_/ OR
#_/ Where Percentile = A percentage chance (IE 70%) of the item dropping
#_/============================================================================
#_/ Example: You have a bandit (enemy) who has a Long Sword you'd like for him
#_/ to drop at a 50% chance. Tag him with:
#_/ <drop W:2 50%>
#_/ OR
#_/ <drop W:2 1/2>
#_/ Simple, yes?
#_/============================================================================
#_/ Installation: Insert above KGC_BattleDifficulty and KGC_EnemyGuide.
#_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
$imported = {} if $imported == nil
$imported["ExtraDropItem"] = true
module KGC
module ExtraDropItem
# Regular Expression Defined
module Regexp
# Base Enemy Module
module Enemy
# Drop Item tag string
DROP_ITEM = /<(?:DROP|drop)\s*([IWA]):(\d+)\s+(\d+)([%%])?>/i
end
end
end
end
#==============================================================================
# ■ RPG::Enemy
#==============================================================================
class RPG::Enemy
#--------------------------------------------------------------------------
# ○ Generate Extra Drop Items Cache
#--------------------------------------------------------------------------
def create_extra_drop_item_cache
@__extra_drop_items = []
self.note.split(/[\r\n]+/).each { |line|
case line
when KGC::ExtraDropItem::Regexp::Enemy::DROP_ITEM
# Drop Item
item = RPG::Enemy::DropItem.new
case $1.upcase
when "I" # Item
item.kind = 1
item.item_id = $2.to_i
when "W" # Weapon
item.kind = 2
item.weapon_id = $2.to_i
when "A" # Armor
item.kind = 3
item.armor_id = $2.to_i
else
next
end
# Drop Rate
if $4 != nil
item.drop_prob = $3.to_i
else
item.denominator = $3.to_i
end
@__extra_drop_items << item
end
}
end
#--------------------------------------------------------------------------
# ○ Return Extra Drop Items
#--------------------------------------------------------------------------
def extra_drop_items
create_extra_drop_item_cache if @__extra_drop_items == nil
return @__extra_drop_items
end
end
#==============================================================================
# ■ RPG::Enemy::DropItem
#==============================================================================
unless $@
class RPG::Enemy::DropItem
#--------------------------------------------------------------------------
# ● Public Instance Variable
#--------------------------------------------------------------------------
attr_accessor :drop_prob # Drop rate
#--------------------------------------------------------------------------
# ● Object initialization
#--------------------------------------------------------------------------
def drop_prob
@drop_prob = 0 if @drop_prob == nil
return @drop_prob
end
end
end
#==============================================================================
# ■ Game_Enemy
#==============================================================================
class Game_Enemy < Game_Battler
#--------------------------------------------------------------------------
# ○ Aquire Item Drop
#--------------------------------------------------------------------------
def extra_drop_items
return enemy.extra_drop_items
end
end
#==============================================================================
# ■ Game_Troop
#==============================================================================
class Game_Troop < Game_Unit
#--------------------------------------------------------------------------
# ● Create Item Drop Array
#--------------------------------------------------------------------------
alias make_drop_items_KGC_ExtraDropItem make_drop_items
def make_drop_items
drop_items = make_drop_items_KGC_ExtraDropItem
dead_members.each { |enemy|
enemy.extra_drop_items.each_with_index { |di, i|
next if di.kind == 0
if di.drop_prob > 0
# Probability specification
next if di.drop_prob < rand(100)
else
# Denominator specification
next if rand(di.denominator) != 0
end
if di.kind == 1
drop_items.push($data_items[di.item_id])
elsif di.kind == 2
drop_items.push($data_weapons[di.weapon_id])
elsif di.kind == 3
drop_items.push($data_armors[di.armor_id])
end
# Set up compatability with KGC_EnemyGuide.
if $imported["EnemyGuide"]
KGC::Commands.set_enemy_item_dropped(enemy.enemy.id, i + 2)
end
}
}
return drop_items
end
end