Drop Luck for Advance Equipment
Authors: Twb6543
Version: 1.0
Type: Drop Item Modification
Key Term: Battle Add-On
IntroductionQuoteCreative Commons - Attribution-NonCommercial-ShareAlike 3.0 Unported
( http://creativecommons.org/licenses/by-nc-sa/3.0/ )
You are free:
to Share - to copy, distribute and transmit the work
to Remix - to adapt the work
Under the following conditions:
Attribution. You must attribute the work in the manner specified by the author or licensor (but not in any way that suggests that they endorse you or your use of the work).
Noncommercial. You may not use this work for commercial purposes.
Share alike. If you alter, transform, or build upon this work, you may distribute the resulting work only under the same or similar license to this one.
- For any reuse or distribution, you must make clear to others the license terms of this work. The best way to do this is with a link to this web page.
- Any of the above conditions can be waived if you get permission from the copyright holder.
- Nothing in this license impairs or restricts the authors moral rights.
This script was requested by JanraeMendoza...
This Script is a Xp version of the original VX one.
THIS SCRIPT HAS NOT BEEN FULLY TESTEDThis script may have a few flaws this is because I prefer and am much better at VX rather than XP.
This is my first proper released XP script.
Also a version that works with XAS Hero edition was requested and fufilled.
These Scripts are currently equal to the 1.1 version of the VX one, I may update these to match the VX version.
In both scripts a definition called dropluckcalc is added, and in Game_Actor two definitions are added (replicating the VX .armors and .weapons).
Features
- Generates A Drop luck variable that changes the probability of dropping any advance equipment
- Uses hashes and arrays for easy editing
ScreenshotsNot Needed
DemoNot Needed / Plugin, Set-up and Play
ScriptScripts add soon
#===============================================================================
# Drop Luck Ver 1.0
# By Twb6543
#===============================================================================
# Setup on lines 12 to 17
#===============================================================================
class Scene_Battle
alias initialize_old_Drop_Luck initialize
def initialize
@@AdvancedItems = []
@@AdvancedWeapons = []
@@AdvancedArmors = []
@@DropLuckIncreasingArmors = {}
@@DropLuckIncreasingWeapons = {}
end
def dropluckcalc
result = 0
@@DropLuckIncreasingArmors.each_key do |i|
if $game_actors[$game_party.members[0].id].armors.include?($data_armors[i]) == true
result += @@DropLuckIncreasingArmors[i]
end
end
@@DropLuckIncreasingWeapons.each_key do |i|
if $game_actors[$game_party.members[0].id].weapons.include?($data_armors[i]) == true
result += @@DropLuckIncreasingWeapons[i]
end
end
return result
end
alias start_phase5_old_Drop_Luck start_phase5
def start_phase5
# Shift to phase 5
@phase = 5
# Play battle end ME
$game_system.me_play($game_system.battle_end_me)
# Return to BGM before battle started
$game_system.bgm_play($game_temp.map_bgm)
# Initialize EXP, amount of gold, and treasure
exp = 0
gold = 0
treasures = []
#===========================================================================
# Drop Luck Added Here
#===========================================================================
dropluck = dropluckcalc # Calculate Drop Luck
# Loop
for enemy in $game_troop.enemies
# If enemy is not hidden
unless enemy.hidden
# Add EXP and amount of gold obtained
exp += enemy.exp
gold += enemy.gold
include_drop_luck = false
if enemy.item_id > 0
@@AdvancedItems.each_index do |i|
if enemy.item_id == @@AdvancedItems[i]
include_drop_luck = true # and item is an advance equipment then
# include drop luck
end
end
end
if enemy.weapon_id > 0
@@AdvancedWeapons.each_index do |i|
if enemy.weapon_id == @@AdvancedWeapons[i]
include_drop_luck = true # and item is an advance equipment then
# include drop luck
end
end
end
if enemy.armor_id > 0
@@AdvancedArmors.each_index do |i|
if enemy.armor_id == @@AdvancedArmors[i]
include_drop_luck = true # and item is an advance equipment then
# include drop luck
end
end
end
# Determine if treasure appears
if include_drop_luck == true
prob = enemy.treasure_prob + dropluck
if rand(100) < 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
else
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
end
#===========================================================================
# End
#===========================================================================
# Treasure is limited to a maximum of 6 items
treasures = treasures[0..5]
# Obtaining EXP
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
# Obtaining gold
$game_party.gain_gold(gold)
# Obtaining treasure
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
# Make battle result window
@result_window = Window_BattleResult.new(exp, gold, treasures)
# Set wait count
@phase5_wait_count = 100
end
end
class Game_Actor < Game_Battler
def armors
armor.clear
armor = []
armor.push($data_armors[@armor1_id])
armor.push($data_armors[@armor2_id])
armor.push($data_armors[@armor3_id])
armor.push($data_armors[@armor4_id])
return armor
end
def weapons
weapon.clear
weapon = []
weapon.push($data_weapons[@weapon_id])
return weapon
end
end
XAS Hero Edition v3.82 Version 1.0: ShowHide
#===============================================================================
# XAS_BA_ItemDrop with Drop Luck Ver 1.0
# By Twb6543
# XAS by Xiderowg / 桜雅 在土
# Hero Edition by Moghunter
# Translated Version by Calvin624
#===============================================================================
# Setup on lines 17 to 22
#===============================================================================
module XAS_BA_ItemDrop
def dropluckcalc
# Seeing as this def is called before the actuall usage this will surfice
# as a place to put them seeing as initialize def causes errors with XAS
# Setup Like the VX version
@@AdvancedItems = [] # array ids of AE items
@@AdvancedWeapons = [] # array ids of AE weapons
@@AdvancedArmors = [] # array ids of AE armors
@@DropLuckIncreasingArmors = {} # Hash | id => increase
@@DropLuckIncreasingWeapons = {}
result = 0
@@DropLuckIncreasingArmors.each_key do |i|
if $game_actors[$game_party.members[0].id].armors.include?($data_armors[i]) == true
result += @@DropLuckIncreasingArmors[i]
end
end
@@DropLuckIncreasingWeapons.each_key do |i|
if $game_actors[$game_party.members[0].id].weapons.include?($data_armors[i]) == true
result += @@DropLuckIncreasingWeapons[i]
end
end
return result
end
#--------------------------------------------------------------------------
# Defeat Process
#--------------------------------------------------------------------------
alias defeat_process_old_Drop_Luck defeat_process
def defeat_process
super
if self.battler.is_a?(Game_Enemy) and self.battler.dead? and
$game_map.passable?(self.x, self.y,2) and
terrain_tag != XAS::FALL_TERRAIN
treasure = nil
enemy = self.battler
dropluck = dropluckcalc
include_drop_luck = false
if enemy.item_id > 0
@@AdvancedItems.each_index do |i|
if enemy.item_id == @@AdvancedItems[i]
include_drop_luck = true # and item is an advance equipment then
# include drop luck
end
end
end
if enemy.weapon_id > 0
@@AdvancedWeapons.each_index do |i|
if enemy.weapon_id == @@AdvancedWeapons[i]
include_drop_luck = true # and item is an advance equipment then
# include drop luck
end
end
end
if enemy.armor_id > 0
@@AdvancedArmors.each_index do |i|
if enemy.armor_id == @@AdvancedArmors[i]
include_drop_luck = true # and item is an advance equipment then
# include drop luck
end
end
end
if include_drop_luck == true
prob = enemy.treasure_prob + dropluck
if rand(100) < prob and
self.battler.steal == false
if enemy.item_id > 0
treasure = $data_items[enemy.item_id]
end
if enemy.weapon_id > 0
treasure = $data_weapons[enemy.weapon_id]
end
if enemy.armor_id > 0
treasure = $data_armors[enemy.armor_id]
end
else
# Multi Drop
tesouro = XAS_BA_ENEMY::ENEMY_MULTI_TREASURE[enemy.id]
if tesouro != nil
item_2treasure = tesouro[rand(tesouro.size)]
end
if item_2treasure != nil
treasure_type = item_2treasure[0]
treasure_id = item_2treasure[1]
treasure_prob = item_2treasure[2]
include_drop_luck_tr = false
if treasure_type == 0
@@AdvancedItems.each_index do |i|
if treasure_id == @@AdvancedItems[i]
include_drop_luck_tr = true # and item is an advance equipment then
# include drop luck
end
end
elsif treasure_type == 1
@@AdvancedWeapons.each_index do |i|
if treasure_id == @@AdvancedWeapons[i]
include_drop_luck_tr = true # and item is an advance equipment then
# include drop luck
end
end
elsif treasure_type == 2
@@AdvancedArmors.each_index do |i|
if treasure_id == @@AdvancedArmors[i]
include_drop_luck_tr = true # and item is an advance equipment then
# include drop luck
end
end
end
if include_drop_luck_tr == true
prob_tr = treasure_prob + dropluck
if rand(100) < prob_tr
if treasure_type == 0
treasure = $data_items[treasure_id]
end
if treasure_type == 1
treasure = $data_weapons[treasure_id]
end
if treasure_type == 2
treasure = $data_armors[treasure_id]
end
end
else
if rand(100) < treasure_prob
if treasure_type == 0
treasure = $data_items[treasure_id]
end
if treasure_type == 1
treasure = $data_weapons[treasure_id]
end
if treasure_type == 2
treasure = $data_armors[treasure_id]
end
end
end
end
end
else
if rand(100) < enemy.treasure_prob and
self.battler.steal == false
if enemy.item_id > 0
treasure = $data_items[enemy.item_id]
end
if enemy.weapon_id > 0
treasure = $data_weapons[enemy.weapon_id]
end
if enemy.armor_id > 0
treasure = $data_armors[enemy.armor_id]
end
else
# Multi Drop
tesouro = XAS_BA_ENEMY::ENEMY_MULTI_TREASURE[enemy.id]
if tesouro != nil
item_2treasure = tesouro[rand(tesouro.size)]
end
if item_2treasure != nil
treasure_type = item_2treasure[0]
treasure_id = item_2treasure[1]
treasure_prob = item_2treasure[2]
if rand(100) < treasure_prob
if treasure_type == 0
treasure = $data_items[treasure_id]
end
if treasure_type == 1
treasure = $data_weapons[treasure_id]
end
if treasure_type == 2
treasure = $data_armors[treasure_id]
end
end
end
end
end
if treasure != nil
item_se = XAS::ITEMDROP_SE
opecode = treasure.is_a?(RPG::Item) ? 126 :
treasure.is_a?(RPG::Weapon) ? 127 :
treasure.is_a?(RPG::Armor) ? 128 :
nil
list = []
if opecode != nil
item_number = XAS::ITEM_NUMBER[treasure.id]
if item_number != nil and treasure.is_a?(RPG::Item)
list[0] = RPG::EventCommand.new(opecode, 0, [treasure.id,0,0,item_number])
else
list[0] = RPG::EventCommand.new(opecode, 0, [treasure.id,0,0,1])
end
list[1] = RPG::EventCommand.new(250, 0, [item_se])
list[2] = RPG::EventCommand.new(116, 0, [])
end
list.push(RPG::EventCommand.new)
command = RPG::MoveCommand.new
command.code = 14
command.parameters = [0,0]
route = RPG::MoveRoute.new
route.repeat = false
route.list = [command, RPG::MoveCommand.new]
page = RPG::Event::Page.new
page.move_type = 3
page.move_route = route
page.move_frequency = 6
page.always_on_top = true
page.trigger = 1
page.list = list
page.through = true
page.condition.variable_id = 10000
page.condition.variable_value = 100 + (40 * MOG::XAS_ICON_ERASE_TIME)
event = RPG::Event.new(self.x, self.y)
event.pages = [page]
token = Token_Event.new($game_map.id, event)
token.icon_name = treasure.icon_name
$game_map.add_token(token)
end
end
end
end
class Game_Actor < Game_Battler
def armors
armor.clear
armor = []
armor.push($data_armors[@armor1_id])
armor.push($data_armors[@armor2_id])
armor.push($data_armors[@armor3_id])
armor.push($data_armors[@armor4_id])
return armor
end
def weapons
weapon.clear
weapon = []
weapon.push($data_weapons[@weapon_id])
return weapon
end
end
InstructionsPlace like normal (Below standard scripts and above main // Make sure that the XAS is below the actual XAS scripts)
The Script runs at the end of the battle, If an enemy has the possibility to drop any Advance equipment the drop luck is subtracted from the Advance equipment denominator before the mostly normal procedure carries out.
To set Advance Equipment(AE) just add the id to the array of the correct type, e.g. AE Weapon ids in the array @@AdvancedWeapons...
To set the drop luck increasing weapons and armours just add to the correct hash the information using this as a key "id => dropluckincrease".
Read the comments in the script, post here if any bugs or the comments don't make sense.
CompatibilityThis script will probably not be compatible with any script that modifies Scene_Battle.start_phase5
XAS version modifies XAS_BA_ItemDrop.defeat_process...
Credits and ThanksThanks to:- JanraeMendoza for the request and original testing
XAS Credits:- Xiderowg for XAS
- MogHunter for XAS Hero Edition
- Calvin624 for the Translated Version
Author's NotesA = XP Version
B = XAS Version
Version History: // Note DL is Drop Luck and AE is Advanced Equipment...
1.0 - A/B - Original version for JanraeMendoza
To Add:
- Choose who's equipment is checked...
- Add more options and make easier for user...
Please report any bugs here...