#==============================================================================
# ** RGSS.Actor and Party Info
#------------------------------------------------------------------------------
# Description:
# ------------
# These set of methods add observer methods to the Game_Actor and Game_Party
# classes, you can get information on how weak an enemy is to a state, all
# of the enemies resistances and weaknesses, etc.
#
# Method List:
# ------------
#
# Game_Actor
# ----------
# exp_s
# next_exp_s
# next_rest_exp_s
# now_exp
# next_exp
# weapon_set
# armor_set
# weapon_stats()
# armor_stats
# strongest_weapon
# weakest_weapon
# strongest_armor
# weakest_armor
#
# Game_Party
# ----------
# average()
# gain_all()
# lose_all
#
#==============================================================================
#-------------------------------------------------------------------------------
# * SDK Log
#-------------------------------------------------------------------------------
if Object.const_defined?(:SDK)
SDK.log('MACL::RGSS.Actor and Party Info', 'Kain Nobel', 2.0, '09.27.2008')
end
#-------------------------------------------------------------------------------
# * MACL Loading
#-------------------------------------------------------------------------------
MACL::Loaded << 'RGSS.Actor and Party Info'
#===============================================================================
# ** Game_Actor
#===============================================================================
class Game_Actor < Game_Battler
#-----------------------------------------------------------------------------
# * Public Instance Variables
#-----------------------------------------------------------------------------
attr_accessor :weapon_id
attr_accessor :armor1_id
attr_accessor :armor2_id
attr_accessor :armor3_id
attr_accessor :armor4_id
#-----------------------------------------------------------------------------
# * Name : Experience List
# Info : Returns '@exp_list[@level+1]'
# Author : Kain Nobel
# Call Info : None
#-----------------------------------------------------------------------------
def exp_list
return @exp_list[@level+1]
end
#--------------------------------------------------------------------------
# * Name : Experience String (Overwrite)
# Info : Returns Experience String
# Author : Kain Nobel
# Call Info : Format will format experience string with commas
#--------------------------------------------------------------------------
def exp_s(format = true)
return exp_list > 0 ? format ? @exp.format_s : @exp.to_s : "Master"
end
#--------------------------------------------------------------------------
# * Name : Next Experience String (Overwrite)
# Info : Returns Experience String
# Author : Kain Nobel
# Call Info : Format will format experience string with commas
#--------------------------------------------------------------------------
def next_exp_s(format = true)
return exp_list > 0 ? format ? exp_list.format_s : exp_list.to_s : "Master"
end
#--------------------------------------------------------------------------
# * Name : Next Rest Experience String (Overwrite)
# Info : Returns Experience String
# Author : Kain Nobel
# Call Info : Format will format experience string with commas
#--------------------------------------------------------------------------
def next_rest_exp_s(format = true)
return exp_list > 0 ? format ? (exp_list-@exp).format :
(exp_list-@exp).to_s : "Master"
end
#--------------------------------------------------------------------------
# * Name : Now Experience
# Info : Returns current Experience
# Author : Kain Nobel
# Call Info : None
#-----------------------------------------------------------------------------
def now_exp
return @exp - @exp_list[@level]
end
#-----------------------------------------------------------------------------
# * Name : Next Experience
# Info : Returns Experience to Next Level
# Author : Kain Nobel
# Call Info : None
#-----------------------------------------------------------------------------
def next_exp
return exp_list > 0 ? exp_list - @exp_list[@level] : 0
end
#-----------------------------------------------------------------------------
# * Name : Weapon Set
# Info : Returns all weapon objects for an actor's class
# Author : Kain Nobel
# Call Info : None
#-----------------------------------------------------------------------------
def weapon_set
return $data_classes[@class_id].weapon_set
end
#-----------------------------------------------------------------------------
# * Name : Armor Set
# Info : Returns all armor objects for an actor's class
# Author : Kain Nobel
# Call Info : Kind ID for the Armors to check
#-----------------------------------------------------------------------------
def armor_set(kind = nil)
if kind.nil?
return $data_classes[@class_id].armor_set
end
armors = []
($data_classes[@class_id].armor_set).each do |armor|
armors.push(armor) if $data_armors[armor].kind == kind
end
return armors
end
#-----------------------------------------------------------------------------
# * Name : Weapon Stats
# Info : Returns a list of desired stats for the actor's weapon set
# Author : Kain Nobel
# Call Info : Parameter is a string representing parameter in question
#-----------------------------------------------------------------------------
def weapon_stats(parameter)
stats = []
weapon_set.each do |i|
if $game_party.weapons.include?(i)
case (parameter.to_s)
when 'name' ; stats.push($data_weapons[i].name)
when 'price'; stats.push($data_weapons[i].price)
when 'atk' ; stats.push($data_weapons[i].atk)
when 'pdef' ; stats.push($data_weapons[i].pdef)
when 'mdef' ; stats.push($data_weapons[i].mdef)
when 'str' ; stats.push($data_weapons[i].str_plus)
when 'dex' ; stats.push($data_weapons[i].dex_plus)
when 'agi' ; stats.push($data_weapons[i].agi_plus)
when 'int' ; stats.push($data_weapons[i].int_plus)
else ; print(":"+parameter+": is not a valid parameter when\n",
"checking for $game_actor["+@actor_id.to_s+"].weapon_set()")
end
end
end
return stats.sort!
end
#-----------------------------------------------------------------------------
# * Name : Armor Stats
# Info : Returns a list of desired stats for an actor's armor set
# Author : Kain Nobel
# Call Info : Parameter is a string representing parameter in question
# Kind refers to the kind of amror it is
#-----------------------------------------------------------------------------
def armor_stats(parameter, kind = 0)
stats = []
armor_set.each do |i|
if $data_armors[i].kind == kind && $game_party.armors.include?(i)
case (parameter.to_s)
when 'name' ; stats.push($data_armors[i].name)
when 'price'; stats.push($data_armors[i].price)
when 'atk' ; stats.push($data_armors[i].atk)
when 'pdef' ; stats.push($data_armors[i].pdef)
when 'mdef' ; stats.push($data_armors[i].mdef)
when 'str' ; stats.push($data_armors[i].str_plus)
when 'dex' ; stats.push($data_armors[i].dex_plus)
when 'agi' ; stats.push($data_armors[i].agi_plus)
when 'int' ; stats.push($data_armors[i].int_plus)
else ; print(":"+parameter+": is not a valid parameter when\n",
"checking for $game_actor["+@actor_id.to_s+"].armor_set()")
end
end
end
return stats.sort!
end
#-----------------------------------------------------------------------------
# * Name : Strongest Weapon
# Info : Returns the strongest weapon, based on parameter
# Author : Kain Nobel
# Call Info : Parameter is a string representing parameter in question
#-----------------------------------------------------------------------------
def strongest_weapon(parameter)
w = weapon_stats(parameter)
return w[-1]
end
#-----------------------------------------------------------------------------
# * Name : Strongest Armor
# Info : Returns the strongest armor, based on parameter
# Author : Kain Nobel
# Call Info : Parameter is a string representing parameter in question
# Kind refers to the kind of amror it is
#-----------------------------------------------------------------------------
def strongest_armor(parameter, kind = 0)
a = armor_stats(parameter, kind)
return a[-1]
end
#-----------------------------------------------------------------------------
# * Name : Weakest Weapon
# Info : Returns the weakest weapon, based on parameter
# Author : Kain Nobel
# Call Info : Parameter is a string representing parameter in question
#-----------------------------------------------------------------------------
def weakest_weapon(parameter)
w = weapon_stats(parameter)
return w[0]
end
#-----------------------------------------------------------------------------
# * Name : Weakest Armor
# Info : Returns the weakest armor, based on parameter
# Author : Kain Nobel
# Call Info : Parameter is a string representing parameter in question
# Kind refers to the kind of amror it is
#-----------------------------------------------------------------------------
def weakest_armor(parameter, kind = 0)
a = armor_stats(parameter, kind)
return a[0]
end
end
#===============================================================================
# ** Game_Party
#===============================================================================
class Game_Party
#-----------------------------------------------------------------------------
# * Public Instance Variables
#-----------------------------------------------------------------------------
attr_accessor :gold # This is set so you can do $game_party.gold = n
#-----------------------------------------------------------------------------
# * Name : Average
# Info : Returns average of party's stats, based on parameter
# Author : Kain Nobel
# Call Info : Parameter is a string representing parameter in question
# Float will return the average as a float (Optional)
#-----------------------------------------------------------------------------
def average(stat, float = false)
return 0 if @actors.size == 0
avg = float ? 0.0 : 0
case stat.downcase!
when 'hp' ; @actors.each_index {|i| avg += @actors[i].hp}
when 'maxhp' ; @actors.each_index {|i| avg += @actors[i].maxhp}
when 'sp' ; @actors.each_index {|i| avg += @actors[i].sp}
when 'maxsp' ; @actors.each_index {|i| avg += @actors[i].maxsp}
when 'level' ; @actors.each_index {|i| avg += @actors[i].level}
when 'exp' ; @actors.each_index {|i| avg += @actors[i].exp}
when 'str' ; @actors.each_index {|i| avg += @actors[i].str}
when 'dex' ; @actors.each_index {|i| avg += @actors[i].dex}
when 'agi' ; @actors.each_index {|i| avg += @actors[i].agi}
when 'int' ; @actors.each_index {|i| avg += @actors[i].int}
when 'atk' ; @actors.each_index {|i| avg += @actors[i].atk}
when 'pdef' ; @actors.each_index {|i| avg += @actors[i].pdef}
when 'mdef' ; @actors.each_index {|i| avg += @actors[i].mdef}
when 'eva' ; @actors.each_index {|i| avg += @actors[i].eva}
end
return avg / @actors.size
end
#-----------------------------------------------------------------------------
# * Name : Gain All
# Info : Gain all items (depending on type)
# Author : Kain Nobel
# Call Info : Type is the type of 'item' to gain
# -1 : All Items, Weapons, Armors
# 0 : All Items
# 1 : All Weapons
# 2 : All Armors
# Quantity is an integer from 1 to 99 (Optional)
#-----------------------------------------------------------------------------
def gain_all(type, quantity = 99)
if type.is_a?(Fixnum) && type.between?(-1, 2)
case type
when -1
$data_items.each_index {|i| gain_item(i, quantity.abs)}
$data_weapons.each_index {|i| gain_weapon(i, quantity.abs)}
$data_armors.each_index {|i| gain_armor(i, quantity.abs)}
when 0 ; $data_items.each_index {|i| gain_item(i, quantity.abs)}
when 1 ; $data_weapons.each_index {|i| gain_weapon(i, quantity.abs)}
when 2 ; $data_armors.each_index {|i| gain_armor(i, quantity.abs)}
end
end
end
#-----------------------------------------------------------------------------
# * Name : Lose All
# Info : Lose all items (depending on type)
# Author : Kain Nobel
# Call Info : Type is the type of 'item' to lose
# -1 : All Items, Weapons, Armors
# 0 : All Items
# 1 : All Weapons
# 2 : All Armors
# Quantity is an integer from 1 to 99 (Optional)
#-----------------------------------------------------------------------------
def lose_all(type, quantity = 99)
quantity = -quantity.abs if quantity > 0
gain_all(type, quantity)
end
end