#Weapon/Armor Randomization v1.2
#----------#
#Features: Allow the stats of an item to be randomized, yay! Also can tack
# on random prefixes and suffixes. Oooh, fancy.
#
#Usage: Basic Usage:
#
# Note tags for weapons and armors:
#
# <HP amount> <HP% amount> <ATK amount> <ATK% amount>
# <MP amount> <MP% amount> <DEF amount> <DEF% amount>
# <MAT amount> <MAT% amount> <MDF amount> <MDF% amount>
# <AGI amount> <AGI% amount> <LUK amount> <LUK% amount>
# <PRICE amount> <PRICE% amount>
#
# Where amount is the amount to be randomly added on, with % being
# a percentage instead of specific.
# Examples: <HP 500> or <HP% 10>
#
# Script calls:
# add_armor(base_id, amount)
# add_weapon(base_id, amount)
#
# These script calls create a new version of the item of the base_id
# number, with randomized stats as set in their note.
#
# Advanced Usage:
#
# Note tags for weapons and armors:
#
# <SUFFIX# rarity> <PREFIX# rarity>
#
# Where # is the id number of the affix and rarity is the chance of it
# occuring with 100 always occuring and 1 almost never occuring.
# Multiple affix notes can be added and the first one that passes it's
# rarity chance will be added.
# Examples: <PREFIX1 50> or <SUFFIX2 90>
#
# The Complicated Part: (Affixes)
# See that AFFIXES hash down there? That's where you set these up.
# Basic setup is:
# ID => { :symbol => data, },
# You can have as many different symbols in there as you want, each
# seperated by a comma, and don't forget the comma between each AFFIX
# id.
#
# Usable Symbols:
# :name = "name"
#
# :hp, :mp, :atk, :def, :mat, :mdf, :agi, :luk (random bonus)
# :Shp, :Smp, :Satk, :Sdef, :Smat, :Smdf, :Sagi, :Sluk (static bonus)
# :hpP, :mpP, :atkP, :defP, :matP, :mdfP, :agiP, :lukP (random % bonus)
# :ShpP, :SmpP, :SatkP, :SdefP, :SmatP, :SmdfP, :SagiP, :SlukP (static % bonus)
#
# :price, :Sprice, :priceP, :SpriceP
#
# each of these goes :symbol = value
#
# The fun part, :features
# You can have as many features as you want, set up in an array:
# :features = [[code, id, value],[code, id, value]] etc...
# But what are the codes, ids, and values?? Don't worry, I found out:
#
# Element Rate = 11, element_id, float value
# Debuff Rate = 12, param_id, float value
# State Rate = 13, state_id, float value
# State Resist = 14, state_id, 0
#
# Parameter = 21, param_id, float value
# Ex-Parameter = 22, exparam_id, float value
# Sp-Parameter = 23, spparam_id, float value
#
# Atk Element = 31, element_id, 0
# Atk State = 32, state_id, float value
# Atk Speed = 33, 0, value
# Atk Times+ = 34, 0, value
#
# Add Skill Type = 41, skill_type, 0
# Seal Skill Type = 42, skill_type, 0
# Add Skill = 43, skill_id, 0
# Seal Skill = 44, skill_id, 0
#
# Equip Weapon = 51, weapon_skill, 0
# Equip Armor = 52, armor_skill, 0
# Fix Equip = 53, item_type, 0
# Seal Equip = 54, item_type, 0
# Slot Type = 55, 1, 0
#
# Action Times+ = 61, 0, value
# Special Flag = 62, flag_id, 0
# Collapse Effect = 62, flag_id, 0
# Party Ability = 63, flag_id, 0
#
# float value = percentage value where 1 = 100%, 0.75 = 75%, and 1.25 = 125%
# param_id, 0=hp, 1=mp, 2=atk, 3=def, 4=mat, 5=mdf, 6=agi, 7=luk
#
# Examples: [21, 2, 1.5] which would increase atk to 150%
# [62, 0, 0] which makes the item give the auto-battle flag
# [32, 1, 0.5] which gives a 50% of applying death state
#
#----------#
#-- Script by: Vlue of Daimonious Tails
#
#- Questions or comments can be:
# posted on the thread for the script
# provided on facebook: [url]http://www.facebook.com/DaimoniousTailsGames[/url]
# posed on site: daimonioustails.wordpress.com
#
#--- Free to use in any project with credit given
AFFIXES = { 1 => { :name => "Bronze ",
:SatkP => 10,},
2 => { :name => "Iron ",
:SatkP => 30,},
3 => { :name => "Steel ",
:SatkP => 60,},
4 => { :name => "Mithril ",
:SatkP => 100,},
5 => { :name => "Harder Mithril ",
:SatkP => 150,},
100 => { :name => " of Power",
:SatkP => 40,
:SmatP => 40,},
200 => { :name => " of Defense",
:SdefP => 40,
:SmdfP => 40,},
300 => { :name => " of Speed",
:SagiP => 80,},
400 => { :name => " of Better Speed",
:features => [[34,0,2]],},
}
#If true, then weapons and armors dropped by enemies will be randomized
RANDOM_ENEMY_DROPS = true
class Game_Interpreter
def add_weapon(id, am)
$game_party.add_weapon(id, am)
end
def add_armor(id, am)
$game_party.add_armor(id, am)
end
end
class Game_Party
alias rig_initialize initialize
def initialize
rig_initialize
@saved_weapons = $data_weapons
@saved_armors = $data_armors
end
attr_accessor :saved_weapons
attr_accessor :saved_armors
def add_weapon(id, amount)
item = Marshal.load(Marshal.dump($data_weapons[id]))
item.id = $data_weapons.size
edit_item(item)
edit_affixes(item)
$data_weapons.each do |base_item|
next if base_item.nil?
if ( item.params == base_item.params &&
item.price == base_item.price &&
item.name == base_item.name )
$game_party.gain_item(base_item, amount)
return
end
end
$data_weapons.push(item)
$game_party.gain_item(item, amount)
end
def add_armor(id, amount)
item = Marshal.load(Marshal.dump($data_armors[id]))
item.id = $data_armors.size
edit_item(item)
edit_affixes(item)
$data_armors.push(item)
$game_party.gain_item(item, amount)
end
def edit_affixes(item)
note = item.note.clone
while note.include?("<SUF")
id = note =~ /<SUFFIX(\d+) (\d+)>/
if !AFFIXES[$~[1].to_i].nil?
break if add_affix(item, $~[1].to_i, false) if rand(100) < $2.to_i
note[id] = "N"
else
msgbox("Affix #" + $1 + " doesn't exist. \nItem creation failed.")
return
end
end
while note.include?("<PRE")
id = note =~ /<PREFIX(\d+) (\d+)>/
if !AFFIXES[$~[1].to_i].nil?
break if add_affix(item, $~[1].to_i, true) if rand(100) < $2.to_i
note[id] = "N"
else
msgbox("Affix #" + $1 + " doesn't exist. \nItem creation failed.")
return
end
end
end
def add_affix(item, id, prefix)
affix = AFFIXES[id]
if prefix && !affix[:name].nil?
item.name = affix[:name] + item.name
elsif !affix[:name].nil?
item.name = item.name + affix[:name]
end
item.params[0] += rand(affix[:hp]) if !affix[:hp].nil?
item.params[1] += rand(affix[:mp]) if !affix[:mp].nil?
item.params[2] += rand(affix[:atk]) if !affix[:atk].nil?
item.params[3] += rand(affix[:def]) if !affix[:def].nil?
item.params[4] += rand(affix[:mat]) if !affix[:mat].nil?
item.params[5] += rand(affix[:mdf]) if !affix[:mdf].nil?
item.params[6] += rand(affix[:agi]) if !affix[:agi].nil?
item.params[7] += rand(affix[:luk]) if !affix[:luk].nil?
item.price += rand(affix[:price]) if !affix[:price].nil?
item.params[0] += affix[:Shp] if !affix[:Shp].nil?
item.params[1] += affix[:Smp] if !affix[:Smp].nil?
item.params[2] += affix[:Satk] if !affix[:Satk].nil?
item.params[3] += affix[:Sdef] if !affix[:Sdef].nil?
item.params[4] += affix[:Smat] if !affix[:Smat].nil?
item.params[5] += affix[:Smdf] if !affix[:Smdf].nil?
item.params[6] += affix[:Sagi] if !affix[:Sagi].nil?
item.params[7] += affix[:Sluk] if !affix[:Sluk].nil?
item.price += affix[:Sprice] if !affix[:Sprice].nil?
item.params[0] += item.params[0] * (rand(affix[:hpP])) / 100 if !affix[:hpP].nil?
item.params[1] += item.params[1] * (rand(affix[:mpP])) / 100 if !affix[:mpP].nil?
item.params[2] += item.params[2] * (rand(affix[:atkP])) / 100 if !affix[:atkP].nil?
item.params[3] += item.params[3] * (rand(affix[:defP])) / 100 if !affix[:defP].nil?
item.params[4] += item.params[4] * (rand(affix[:matP])) / 100 if !affix[:matP].nil?
item.params[5] += item.params[5] * (rand(affix[:mdfP])) / 100 if !affix[:mdfP].nil?
item.params[6] += item.params[6] * (rand(affix[:agiP])) / 100 if !affix[:agiP].nil?
item.params[7] += item.params[7] * (rand(affix[:lukP])) / 100 if !affix[:lukP].nil?
item.price += item.price * (rand(affix[:priceP])) / 100 if !affix[:priceP].nil?
item.params[0] += item.params[0] * affix[:ShpP] / 100 if !affix[:ShpP].nil?
item.params[1] += item.params[1] * affix[:SmpP] / 100 if !affix[:SmpP].nil?
item.params[2] += item.params[2] * affix[:SatkP] / 100 if !affix[:SatkP].nil?
item.params[3] += item.params[3] * affix[:SdefP] / 100 if !affix[:SdefP].nil?
item.params[4] += item.params[4] * affix[:SmatP] / 100 if !affix[:SmatP].nil?
item.params[5] += item.params[5] * affix[:SmdfP] / 100 if !affix[:SmdfP].nil?
item.params[6] += item.params[6] * affix[:SagiP] / 100 if !affix[:SagiP].nil?
item.params[7] += item.params[7] * affix[:SlukP] / 100 if !affix[:SlukP].nil?
item.price += item.price * affix[:SpriceP] / 100 if !affix[:SpriceP].nil?
if !affix[:features].nil?
for feature in affix[:features]
new_feature = RPG::BaseItem::Feature.new(feature[0], feature[1], feature[2])
item.features.push(new_feature)
end
end
return true
end
def edit_item(item)
item.note =~ /<HP (\d+)>/
item.params[0] += rand($~[1].to_i) if $~
item.note =~ /<MP (\d+)>/
item.params[1] += rand($~[1].to_i) if $~
item.note =~ /<ATK (\d+)>/
item.params[2] += rand($~[1].to_i) if $~
item.note =~ /<DEF (\d+)>/
item.params[3] += rand($~[1].to_i) if $~
item.note =~ /<MAT (\d+)>/
item.params[4] += rand($~[1].to_i) if $~
item.note =~ /<MDF (\d+)>/
item.params[5] += rand($~[1].to_i) if $~
item.note =~ /<AGI (\d+)>/
item.params[6] += rand($~[1].to_i) if $~
item.note =~ /<LUK (\d+)>/
item.params[7] += rand($~[1].to_i) if $~
item.note =~ /<PRICE (\d+)>/
item.price += rand($~[1].to_i) if $~
item.note =~ /<HP% (\d+)>/
item.params[0] += item.params[2] * (rand($~[1].to_i)) / 100 if $~
item.note =~ /<MP% (\d+)>/
item.params[1] += item.params[2] * (rand($~[1].to_i)) / 100 if $~
item.note =~ /<ATK% (\d+)>/
item.params[2] += item.params[2] * (rand($~[1].to_i)) / 100 if $~
item.note =~ /<DEF% (\d+)>/
item.params[3] += item.params[2] * (rand($~[1].to_i)) / 100 if $~
item.note =~ /<MAT% (\d+)>/
item.params[4] += item.params[2] * (rand($~[1].to_i)) / 100 if $~
item.note =~ /<MDF% (\d+)>/
item.params[5] += item.params[2] * (rand($~[1].to_i)) / 100 if $~
item.note =~ /<AGI% (\d+)>/
item.params[6] += item.params[2] * (rand($~[1].to_i)) / 100 if $~
item.note =~ /<LUK% (\d+)>/
item.params[7] += item.params[2] * (rand($~[1].to_i)) / 100 if $~
item.note =~ /<PRICE% (\d+)>/
item.price += item.price * (rand($~[1].to_i)) / 100 if $~
end
end
module BattleManager
def self.gain_drop_items
$game_troop.make_drop_items.each do |item|
if RANDOM_ENEMY_DROPS
if item.is_a?(RPG::Weapon)
$game_party.add_weapon(item.id, 1)
item = $data_weapons[-1]
elsif item.is_a?(RPG::Armor)
$game_party.add_armor(item.id, 1)
item = $data_armors[-1]
else
$game_party.gain_item(item, 1)
end
else
$game_party.gain_item(item, 1)
end
$game_message.add(sprintf(Vocab::ObtainItem, item.name))
end
wait_for_message
end
end
class Scene_Load
alias rig_on_load_success on_load_success
def on_load_success
rig_on_load_success
$data_weapons = $game_party.saved_weapons
$data_armors = $game_party.saved_armors
end
end