#===========================================================
#class Scene_Battle 5
#----------------------------------------------------------------------------------------------------------------------
#-written by Deke
#----------------------------------------------------------------------------------------------------------------------
#
# The purpose of this class is to generate random loot drops at the end of winning battles.
#This script work independently of the item drops programed in for monsters. This script allows
#easy customization of the frequency and quality of loots by simple modifications of the configure
#method-see description below (how this script works) to see what each value does.
#
#Optional feature A-Don't drop weapons/armors/items with price 0
# This option makes it so that equipment with price 0 is excluded from being dropped by monsters
# at random. Some of the items in the database have a default price of zero and have no effect.
# They are really only for event processing purposes, they really should be dropped at random.
# This also creates an easy way to designate an weapon/armor/item as "non" droppable. Simply
# set the price of the equipment to 0. By default this option is set to true.
#
#Optional feature B- Don't drop "flagged" items
#Credit RPG Advocate for creating the elemental taggin trick
# Certain weapons/armors/ and items can be designated as unique (random monsters won't drop
# them). This option requires some addition script modification. It is only recommended if you
# want to have non droppable items that the player can sell back at a later time for profit. By default
# this option is set to off. See comments at the very end of this script for information on how
# to implement this option.
#
#Optional feature C-Debug mode
# This option is allows the game tester to see what weapons/items/armor have a potential of being
# dropped. After a victory, the list of possible weapons/items/armors is displayed. This allows the
# tester to determine if the value of the "quality percentage" should be modified. By default this
# option is off.
#
#============================================================
# HOW THIS SCRIPT WORKS
#-----------------------------------------------------------------------------------------------------------------------
# Basically this script creates sorted list of weapons, armor, and items from cheapest to most
#expensive. (Actually the list are of the equipment I.D.'s) It also creates a list of experience from
#monster from the fewest eqperience to the most experience. Then the program determines a
#percentile of difficultly" based on the experience gained versus the possible experienced gained from
#any monster.
# Next, the program generats some random numbers to determine if you the party gains any
#weapons/armors/items. If the party gains equipment the "percentile cost" of that equipment should
#roughly correlate with the percentile of difficulty. Basically, what this mean is that if you kill a monster
#that gives you more exp than 30% of the monsters and you succeed at getting equipment, the cost
#of the equipments will be higher than approximatley 30% of that equipment of that type. Of course,
#there are some random variations thrown to create variety.
# Here's a list of the variables to edit to customize loot dropping.
# @option_a and option_b: see above
# @weapon_per, @armor_per, @item_per
# the percentage change that the equipment drops after a succesful battle
# Remember that armor also includes shields and accesories, so the percentage should
# proabably be higher.
# @weapon_quality_per,@armor_quality_per,@item_quality_per
# This value determines how much variance there is loot drops.
# The lower the number, the closer the loot cost percentile correlates with the difficulty percentile.
# @two_weapon_per,@two_armor_per,@two_item_per
# the percentage change that two of that type of equipment drop.
# @loot_size
# the maximum number of loots allowable after a battle INCLUDING monster specific drops
#NOTE: If this program starts to lag- it doesn't with the standard size equipment list. You may want
# to change @weapon_set, @armor_set, and @item_set, AND @exp_set to global variables.
# Just use the find and replace feature and change @weapon_set to $weapon_set... Also change
# the statements if @weapon_set==nil to $weapon_set==[]. Finally, in the Scene_Title class
# add the following lines of code right after the begining of the main method:
# $weapon_set=[]
# $armor_set=[]
# $item_set=[]
# $exp_set=[]
#Making this change will mean that the sort funcitons only run the once in the game. Sorting functions
#have the potential to take up a lot of time if the size of the equipment arrays get larg.e
#==========================================================
class Scene_Battle
#--------------------------------------------------------------------------------------------------------------------
#---------------------------------------------------------------------------------------------------------------
#This method sets the values for such thing as dropped percentages.
def configure
@option_a=true
@option_b=false
if @option_b
@unique=20
end
@option_c=false
@weapon_prob=10
@two_weapon_prob=1
@armor_prob = 20
@two_armor_prob=2
@item_prob=12
@two_item_prob=2
@weapon_quality_per=12
@armor_quality_per=12
@item_quality_per=18
@loot_size=5
end
#-----------------------------------------------------------------------------------------------------------
#This metod overwrite start_phase5 from Scene_Battle 2. It is nearly identidcal, except that
#it call the methods to create random loot drops.
def start_phase5
@phase = 5
$game_system.me_play($game_system.battle_end_me)
$game_system.bgm_play($game_temp.map_bgm)
exp = 0
gold = 0
highest_exp=0
treasures = []
for enemy in $game_troop.enemies
unless enemy.hidden
exp += enemy.exp
if enemy.exp > highest_exp
highest_exp=enemy.exp
end
gold += enemy.gold
if rand(100) < enemy.treasure_prob
if enemy.item_id > 0
treasures.push($data_items[enemy.item_id])
end
if enemy.weapon_id > 0
treasures.push($data_weapons[enemy.weapon_id])
end
if enemy.armor_id > 0
treasures.push($data_armors[enemy.armor_id])
end
end
end
end
loot=random_treasure(highest_exp)
treasures +=loot
treasures = treasures[0..@loot_size]
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
$game_party.gain_gold(gold)
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
@result_window = Window_BattleResult.new(exp, gold, treasures)
@phase5_wait_count = 100
end
#-----------------------------------------------------------------------------------------------------------
def random_treasure(exp)
configure
loot=[]
num=0
max=0
if @weapon_set == nil
weapon_set
end
if @armor_set==nil
armor_set
end
if @item_set==nil
item_set
end
if @exp_set == nil
exp_set
end
rank=0
for i in
0...@exp_set.size if exp >= @exp_set[i]
rank=i
end
end
@percentile = (rank/(@exp_set.size))
n=rand(100)
if n <= @weapon_prob
weapon=weapon_drop
loot.push(weapon)
end
if n <= @two_weapon_prob
weapon=weapon_drop
loot.push(weapon)
end
n=rand(100)
if n <= @armor_prob
armor=armor_drop
loot.push(armor)
end
if n <= @two_armor_prob
armor=armor_drop
loot.push(armor)
end
n=rand(100)
if n <= @item_prob
item=item_drop
loot.push(item)
end
if n <= @two_item_prob
item=item_drop
loot.push(item)
end
return loot
end
#-------------------------------------------------------------------------------------------
#This method, if called, determins what weapon should be dropped based on the difficulty of the
#battle and the settings in the configure method.
def weapon_drop
min=(@percentile-@weapon_quality_per)*@weapon_set.size
max=(@percentile+@weapon_quality_per)*@weapon_set.size
max=(max/100).ceil
min=(min/100).floor
if min <0
min=0
end
if max > @weapon_set.size
max=@weapon_set.size
end
weapons_possible=@weapon_set[min..max]
if weapons_possible.size != 0
if @option_c
for i in 0...weapons_possible.size-1
weapon=$data_weapons[weapons_possible[i]]
print weapon.name
end
end
index=rand(weapons_possible.size)
return $data_weapons[weapons_possible[index]]
else
mid = @percentile*@weapon_set.size
mic=(mid/100).ceil
return$data_weapons[mid]
end
end
#-------------------------------------------------------------------------------------------
#This method, if called, determins what armor should be dropped based on the difficulty of the
#battle and the settings in the configure method.
def armor_drop
min=(@percentile-@armor_quality_per)*@armor_set.size
max=(@percentile+@armor_quality_per)*@armor_set.size
max=(max/100).ceil
min=(min/100).floor
if min <0
min=0
end
if max > @armor_set.size
max=@armor_set.size
end
armors_possible=@armor_set[min..max]
if armors_possible.size != 0
if @option_c
for i in 0...armors_possible.size-1
armor=$data_armors[armors_possible[i]]
print armor.name
end
end
index=rand(armors_possible.size)
return $data_armors[armors_possible[index]]
else
mid = @percentile*@armor_set.size
mic=(mid/100).ceil
return$data_armors[mid]
end
end