Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #===============================================================================
- # ** Ruby.Array.find
- #===============================================================================
- class Array
- #-----------------------------------------------------------------------------
- # * Name : Next Index From
- # Info : Gets next item in array (in a wrapped fashion)
- # Author : Kain Nobel
- # Call Info : Item is the object in question
- # Indexes is how many spaces ahead to look
- #-----------------------------------------------------------------------------
- def next_index_from(item, indexes = 1)
- indexes = -indexes if indexes < 0
- if self.include?(item)
- for i in 0...self.size
- if self[i] == item
- if self.size > (i + indexes)
- return self[i + indexes]
- end
- return self[(i + indexes) - self.size]
- end
- end
- end
- end
- #-----------------------------------------------------------------------------
- # * Name : Prev Index From
- # Info : Gets previous item in array (in a wrapped fashion)
- # Author : Kain Nobel
- # Call Info : Item is the object in question
- # Indexes is how many spaces ahead to look
- #-----------------------------------------------------------------------------
- def prev_index_from(item, indexes = 1)
- indexes = -indexes if indexes < 0
- if self.include?(item)
- for i in 0...self.size
- if self[i] == item
- if self.size >= i - indexes
- return self[i - indexes]
- end
- return self[self.size + (i - indexes)]
- end
- end
- end
- end
- end
- #===============================================================================
- # ** RGSS.Actor and Party Info
- #-------------------------------------------------------------------------------
- #
- # 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_Actors
- # -----------
- # each
- # min_stat
- # max_stat
- # average
- # avg_stat
- # min_stats
- # max_stats
- # avg_stats
- #
- #
- # Game_Party
- # ----------
- # members
- # gain_all
- # lose_all
- # min_stat
- # max_stat
- # min_stats
- # max_stats
- # average
- # recover_all
- # revive_all
- # kill_all
- # recover_hp
- # recover_sp
- # add_state
- # add_states
- # remove_state
- # remove_states
- # change_states
- #
- #===============================================================================
- #-------------------------------------------------------------------------------
- # * MACL Loading
- #-------------------------------------------------------------------------------
- if Object.const_defined?(:MACL)
- MACL::Loaded << 'RGSS.Actor and Party Info'
- end
- #===============================================================================
- # ** 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
- attr_accessor :exp_list
- #-----------------------------------------------------------------------------
- # * Alias Listings
- #-----------------------------------------------------------------------------
- alias_method :kn_macl_gm_actor_equip, :equip
- #-----------------------------------------------------------------------------
- # * Equip
- #-----------------------------------------------------------------------------
- def equip(equip_type, id)
- unless id < 0
- kn_macl_gm_actor_equip(equip_type, id)
- end
- end
- #-----------------------------------------------------------------------------
- # * Name : Now Exp
- # Info : Gets Actors Next in Current Level
- # Author : Near Fantastica
- # Call Info : No Arguments
- #-----------------------------------------------------------------------------
- def now_exp
- return @exp - @exp_list[@level]
- end
- #-----------------------------------------------------------------------------
- # * Name : Next Exp
- # Info : Gets Actors Exp for Next Level
- # Author : Near Fantastica
- # Call Info : No Arguments
- #-----------------------------------------------------------------------------
- def next_exp
- exp = @exp_list[@level+1] > 0 ? @exp_list[@level+1] - @exp_list[@level] : 0
- return exp
- end
- #-----------------------------------------------------------------------------
- # * Name : Last Exp
- # Info : Returns numerical value of last exp
- # Author : Kain Nobel
- # Call Info : None
- #-----------------------------------------------------------------------------
- def last_exp
- return @exp_list[-2]
- end
- #-----------------------------------------------------------------------------
- # * Name : Last Level
- # Info : Returns numerical value of last level achievable
- # Author : Kain Nobel
- # Call Info : None
- #-----------------------------------------------------------------------------
- def final_level
- unless $data_actors[id].nil?
- return $data_actors[id].final_level
- end
- return 0
- 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)
- if format == true
- return now_exp.between?(0, last_exp) ? now_exp.format_s : "Master"
- else
- return now_exp.between?(0, last_exp) ? now_exp.to_s : "Master"
- end
- 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)
- if self.now_exp >= self.last_exp
- return "Master"
- else
- if format == true
- return now_exp.between?(0, next_exp) ? next_exp.format_s : now_exp.format_s
- else
- return now_exp.between?(0, next_exp) ? next_exp.to_s : now_exp.to_s
- end
- end
- 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)
- arr, weapons = Array.new, Array.new
- weapon_set.each do |id|
- if $game_party.weapons.has_key?(id)
- if $game_party.weapons[id] > 0
- weapons << id
- end
- end
- end
- weapons.sort!
- weapons.each do |id|
- case parameter
- when 'name' ; arr << [id, $data_weapons[id].name]
- when 'price'; arr << [id, $data_weapons[id].price]
- when 'atk' ; arr << [id, $data_weapons[id].atk]
- when 'pdef' ; arr << [id, $data_weapons[id].pdef]
- when 'mdef' ; arr << [id, $data_weapons[id].mdef]
- when 'str' ; arr << [id, $data_weapons[id].str_plus]
- when 'dex' ; arr << [id, $data_weapons[id].dex_plus]
- when 'agi' ; arr << [id, $data_weapons[id].agi_plus]
- when 'int' ; arr << [id, $data_weapons[id].int_plus]
- else ; print(":"+parameter+": is not a valid parameter when\n",
- "checking for $game_actor["+@actor_id.to_s+"].weapon_stats()")
- end
- end
- return arr
- 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)
- arr, armors = Array.new, Array.new
- armor_set.each do |id|
- if $data_armors[id].kind == kind && $game_party.armors.has_key?(id)
- if $game_party.armors[id] > 0
- armors << id
- end
- end
- end
- armors.sort!
- armors.each do |id|
- case parameter
- when 'name' ; arr << [id, $data_armors[id].name]
- when 'price'; arr << [id, $data_armors[id].price]
- when 'atk' ; arr << [id, $data_armors[id].atk]
- when 'pdef' ; arr << [id, $data_armors[id].pdef]
- when 'mdef' ; arr << [id, $data_armors[id].mdef]
- when 'str' ; arr << [id, $data_armors[id].str_plus]
- when 'dex' ; arr << [id, $data_armors[id].dex_plus]
- when 'agi' ; arr << [id, $data_armors[id].agi_plus]
- when 'int' ; arr << [id, $data_armors[id].int_plus]
- else ; print(":"+parameter+": is not a valid parameter when\n",
- "checking for $game_actor["+@actor_id.to_s+"].armor_stats()")
- end
- end
- return arr
- 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)
- arr, stats = Array.new, Array.new
- weapon_stats(parameter).each do |stat|
- stats << stat[1]
- end
- stats.sort!
- stats.reverse!
- stats.each do |stat|
- weapon_stats(parameter).each do |param|
- if param[1] == stat && stat > 0
- return param[0]
- end
- end
- end
- return -1
- end
- #-----------------------------------------------------------------------------
- # * Name : Strongest Armor
- # Info : Returns the strongest armor, based on parameter and kind
- # Author : Kain Nobel
- # Call Info : Parameter is a string representing parameter in question
- # Kind is what kind of armor it is (shield, helmet, etc.)
- #-----------------------------------------------------------------------------
- def strongest_armor(parameter, kind = 0)
- arr, stats = Array.new, Array.new
- armor_stats(parameter, kind).each do |stat|
- stats << stat[1]
- end
- stats.sort!
- stats.reverse!
- stats.each do |stat|
- armor_stats(parameter, kind).each do |param|
- if param[1] == stat && stat > 0
- return param[0]
- end
- end
- end
- return -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)
- arr, stats = Array.new, Array.new
- weapon_stats(parameter).each do |stat|
- stats << stat[1]
- end
- stats.sort!
- stats.each do |stat|
- weapon_stats(parameter).each do |param|
- if param[1] == stat && stat > 0
- return param[0]
- end
- end
- end
- return -1
- end
- #-----------------------------------------------------------------------------
- # * Name : Weakest Armor
- # Info : Returns the strongest armor, based on parameter and kind
- # Author : Kain Nobel
- # Call Info : Parameter is a string representing parameter in question
- # Kind is what kind of armor it is (shield, helmet, etc.)
- #-----------------------------------------------------------------------------
- def weakest_armor(parameter, kind = 0)
- arr, stats = Array.new, Array.new
- armor_stats(parameter, kind).each do |stat|
- stats << stat[1]
- end
- stats.sort!
- stats.each do |stat|
- armor_stats(parameter, kind).each do |param|
- if param[1] == stat && stat > 0
- return param[0]
- end
- end
- end
- return -1
- end
- #-----------------------------------------------------------------------------
- # * Name : Unequip All
- # Info : Removes all equipment from actor
- # Author : Kain Nobel
- # Call Info : None
- #-----------------------------------------------------------------------------
- def unequip_all
- [0,1,2,3,4].each do |i|
- equip(i, 0)
- end
- end
- end
- #===============================================================================
- # ** Game_Actors
- #===============================================================================
- class Game_Actors
- #-----------------------------------------------------------------------------
- # * Name : Each
- # Info : Adds an 'each' method to $game_actors
- # Author : Kain Nobel
- # Call Info : Any normal way you'd call an 'each' method
- #-----------------------------------------------------------------------------
- def each(&block)
- @data.each(&block)
- end
- #-----------------------------------------------------------------------------
- # * Name : Min Stat
- # Info : For attribute in question, returns lowest value from actors
- # Author : Kain Nobel
- # Call Info : Attribute is a String representing attribute in question
- #-----------------------------------------------------------------------------
- def min_stat(attribute)
- attributes = Array.new
- for actor in @data
- value = eval("actor.#{attribute}")
- attributes << value
- end
- attributes.sort!
- return attributes[0]
- end
- #-----------------------------------------------------------------------------
- # * Name : Max Stat
- # Info : For attribute in question, returns highest value from actors
- # Author : Kain Nobel
- # Call Info : Attribute is a String representing attribute in question
- #-----------------------------------------------------------------------------
- def max_stat(attribute)
- attributes = Array.new
- for actor in @data
- value = eval("actor.#{attribute}")
- attributes << value
- end
- attributes.sort!
- return attributes[-1]
- end
- #-----------------------------------------------------------------------------
- # * Name : Average
- # Info : Same as 'avg_stat'
- # Author : Kain Nobel
- # Call Info : Parameter is a string representing parameter in question
- #-----------------------------------------------------------------------------
- def average(attribute)
- return avg_stat(attribute)
- end
- #-----------------------------------------------------------------------------
- # * Name : Avg Stat
- # Info : Returns average of all actors' stats, based on parameter
- # Author : Kain Nobel
- # Call Info : Parameter is a string representing parameter in question
- #-----------------------------------------------------------------------------
- def avg_stat(stat)
- avg = 0
- for i in 1...$data_actors.size
- case stat
- when 'hp' ; avg += self[i].hp
- when 'maxhp' ; avg += self[i].maxhp
- when 'sp' ; avg += self[i].sp
- when 'maxsp' ; avg += self[i].maxsp
- when 'level' ; avg += self[i].level
- when 'exp' ; avg += self[i].exp
- when 'str' ; avg += self[i].str
- when 'dex' ; avg += self[i].dex
- when 'agi' ; avg += self[i].agi
- when 'int' ; avg += self[i].int
- when 'atk' ; avg += self[i].atk
- when 'pdef' ; avg += self[i].pdef
- when 'mdef' ; avg += self[i].mdef
- when 'eva' ; avg += self[i].eva
- end
- end
- return (avg / $data_actors.size - 1)
- end
- #-----------------------------------------------------------------------------
- # * Name : Min Stats
- # Info : Generates an array of attributes with 'min_stat' method
- # Author : Kain Nobel
- # Call Info : Attributes is an Array of attributes names in Question
- #-----------------------------------------------------------------------------
- def min_stats(attributes)
- list = Array.new
- attributes.each {|attr| list << min_stat(attr)}
- return list
- end
- #-----------------------------------------------------------------------------
- # * Name : Max Stats
- # Info : Generates an array of attributes with 'max_stat' method
- # Author : Kain Nobel
- # Call Info : Attributes is an Array of attributes names in Question
- #-----------------------------------------------------------------------------
- def max_stats(attributes)
- list = Array.new
- attributes.each {|attr| list << max_stat(attr)}
- return list
- end
- #-----------------------------------------------------------------------------
- # * Name : Avg Stats
- # Info : Generates an array of attributes with 'average' method
- # Author : Kain Nobel
- # Call Info : Attributes is an Array of attributes names in Question
- #-----------------------------------------------------------------------------
- def avg_stats(attributes)
- list = Array.new
- attributes.each {|attr| list << avg_stat(attr)}
- return list
- 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 : Members
- # Info : Returns @actors
- # Author : Kain Nobel
- # Call Info : None
- #-----------------------------------------------------------------------------
- def members
- return @actors
- 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
- #-----------------------------------------------------------------------------
- # * Name : Min Stat
- # Info : For attribute in question, returns lowest value from members
- # Author : Kain Nobel
- # Call Info : Attribute is a String representing attribute in question
- #-----------------------------------------------------------------------------
- def min_stat(attribute)
- attributes = Array.new
- for member in self.members
- value = eval("member.#{attribute}")
- attributes << value
- end
- attributes.sort!
- return attributes[0]
- end
- #-----------------------------------------------------------------------------
- # * Name : Max Stat
- # Info : For attribute in question, returns highest value from members
- # Author : Kain Nobel
- # Call Info : Attribute is a String representing attribute in question
- #-----------------------------------------------------------------------------
- def max_stat(attribute)
- attributes = Array.new
- for member in self.members
- value = eval("member.#{attribute}")
- attributes << value
- end
- attributes.sort!
- return attributes[-1]
- end
- #-----------------------------------------------------------------------------
- # * Name : Average
- # Info : Same as 'avg_stat'
- # Author : Kain Nobel
- # Call Info : Parameter is a string representing parameter in question
- #-----------------------------------------------------------------------------
- def average(attribute)
- return avg_stat(attribute)
- end
- #-----------------------------------------------------------------------------
- # * Name : Avg Stat
- # Info : Returns average of party's attributes, based on parameter
- # Author : Kain Nobel
- # Call Info : Parameter is a string representing parameter in question
- #-----------------------------------------------------------------------------
- def avg_stat(attribute)
- return 0 if self.members.size == 0
- avg = 0
- case attribute.downcase
- when 'hp' ; self.members.each {|m| avg += m.hp}
- when 'maxhp' ; self.members.each {|m| avg += m.maxhp}
- when 'sp' ; self.members.each {|m| avg += m.sp}
- when 'maxsp' ; self.members.each {|m| avg += m.maxsp}
- when 'level' ; self.members.each {|m| avg += m.level}
- when 'exp' ; self.members.each {|m| avg += m.exp}
- when 'str' ; self.members.each {|m| avg += m.str}
- when 'dex' ; self.members.each {|m| avg += m.dex}
- when 'agi' ; self.members.each {|m| avg += m.agi}
- when 'int' ; self.members.each {|m| avg += m.int}
- when 'atk' ; self.members.each {|m| avg += m.atk}
- when 'pdef' ; self.members.each {|m| avg += m.pdef}
- when 'mdef' ; self.members.each {|m| avg += m.mdef}
- when 'eva' ; self.members.each {|m| avg += m.eva}
- end
- return (avg / self.members.size)
- end
- #-----------------------------------------------------------------------------
- # * Name : Min Stats
- # Info : Generates an array of attributes with 'min_stat' method
- # Author : Kain Nobel
- # Call Info : Attributes is an Array of attributes names in Question
- #-----------------------------------------------------------------------------
- def min_stats(attributes)
- list = Array.new
- attributes.each {|attr| list << min_stat(attr)}
- return list
- end
- #-----------------------------------------------------------------------------
- # * Name : Max Stats
- # Info : Generates an array of attributes with 'max_stat' method
- # Author : Kain Nobel
- # Call Info : Attributes is an Array of attributes names in Question
- #-----------------------------------------------------------------------------
- def max_stats(attributes)
- list = Array.new
- attributes.each {|attr| list << max_stat(attr)}
- return list
- end
- #-----------------------------------------------------------------------------
- # * Name : Avg Stats
- # Info : Generates an array of attributes with 'average' method
- # Author : Kain Nobel
- # Call Info : Attributes is an Array of attributes names in Question
- #-----------------------------------------------------------------------------
- def avg_stats(attributes)
- list = Array.new
- attributes.each {|attr| list << avg_stat(attr)}
- return list
- end
- #-----------------------------------------------------------------------------
- # * Name : Recover All
- # Info : Recover HP/SP and States
- # Author : Kain Nobel
- # Call Info : None
- #-----------------------------------------------------------------------------
- def recover_all
- self.members.each {|m| m.recover_all}
- end
- #-----------------------------------------------------------------------------
- # * Name : Revive All
- # Info : Revive all actors with percent/direct ammount of HP
- # Author : Kain Nobel
- # Call Info : None
- #-----------------------------------------------------------------------------
- def revive_all(direct = 0, percent = 0)
- self.members.each {|m|
- unless m.hp > 0
- m.hp += Integer(direct * (percent / 100.0))
- end}
- end
- #-----------------------------------------------------------------------------
- # * Name : Kill All
- # Info : Kill all actors instantly
- # Author : Kain Nobel
- # Call Info : None
- #-----------------------------------------------------------------------------
- def kill_all
- self.members.each {|m| m.hp = 0}
- end
- #-----------------------------------------------------------------------------
- # * Name : Add State
- # Info : Inflicts all actors with designated state
- # Author : Kain Nobel
- # Call Info : State ID - Integer representing State's ID in database
- #-----------------------------------------------------------------------------
- def add_state(state_id)
- self.members.each {|m| m.add_state(state_id)}
- end
- #-----------------------------------------------------------------------------
- # * Name : Remove State
- # Info : Removes designated State from all actors
- # Author : Kain Nobel
- # Call Info : State ID - Integer representing State's ID in database
- #-----------------------------------------------------------------------------
- def remove_state(state_id)
- self.members.each {|m| m.remove_state(state_id)}
- end
- #-----------------------------------------------------------------------------
- # * Name : Add States
- # Info : Inflicst all actors with an array of states
- # Author : Kain Nobel
- # Call Info : States - Array with State IDs to be added
- #-----------------------------------------------------------------------------
- def add_states(states = [])
- states.compact!
- states.each {|state| self.add_state(state)}
- end
- #-----------------------------------------------------------------------------
- # * Name : Remove States
- # Info : Removes an array of states from all actors
- # Author : Kain Nobel
- # Call Info : States - Array of State IDs to be removed
- #-----------------------------------------------------------------------------
- def remove_states(states = [])
- states.compact!
- states.each {|state| self.remove_state(state)}
- end
- #-----------------------------------------------------------------------------
- # * Name : Change States
- # Info : Compresses 'add_states' and 'remove_states'
- # Author : Kain Nobel
- # Call Info : States - Array of State IDs to be added/removed
- # State IDs must be positive to be added
- # State IDs must be negative to be removed
- # States can also be a Hash with (State ID => true/false)
- # If State ID points to True : it will be added
- # If State ID points to False : it will be removed
- #-----------------------------------------------------------------------------
- def change_states(states = [])
- add, rem = Array.new, Array.new
- if states.is_a?(Array)
- states.each do |id|
- add << id if id > 0
- rem << -id if id < 0
- end
- elsif states.is_a?(Hash)
- states.each_key do |key|
- add << key if states[key] == true
- rem << key if states[key] == false
- end
- end
- self.add_states(add)
- self.remove_states(rem)
- end
- end
- ]#===============================================================================
- # ** RGSS.Battler
- #===============================================================================
- class Game_Battler
- #-----------------------------------------------------------------------------
- # * Name : Is Actor?
- # Info : Returns true/false if self is a Game_Actor class
- # Author : Kain Nobel
- # Call Info : None
- #-----------------------------------------------------------------------------
- def is_actor?
- return (self.is_a?(Game_Actor) || self.kind_of?(Game_Actor))
- end
- #-----------------------------------------------------------------------------
- # * Name : Is Enemy?
- # Info : Returns true/false if self is a Game_Enemy class
- # Author : Kain Nobel
- # Call Info : None
- #-----------------------------------------------------------------------------
- def is_enemy?
- return (self.is_a?(Game_Enemy) || self.kind_of?(Game_Enemy))
- end
- #-----------------------------------------------------------------------------
- # * Name : Is Ally With?
- # Info : Returns true/false if battler kind is same
- # Author : Kain Nobel
- # Call Info : Battler is the Game_Battler object in question.
- #-----------------------------------------------------------------------------
- def is_ally_with?(battler)
- return self.kind_of?(battler.class)
- end
- #-----------------------------------------------------------------------------
- # * Name : Is Enemy With?
- # Info : Returns true/false if battler kind is different
- # Author : Kain Nobel
- # Call Info : Battler is the Game_Battler object in question.
- #-----------------------------------------------------------------------------
- def is_enemy_with?(battler)
- return !self.kind_of?(battler.class)
- end
- #-----------------------------------------------------------------------------
- # * Name : Belongs To Unit?
- # Info : Returns true/false if self belongs to Party or Troop
- # Author : Kain Nobel
- # Call Info : Unit is either a Game_Party or Game_Troop class
- #-----------------------------------------------------------------------------
- def belongs_to_unit?(unit)
- belongs = false
- belongs |= self.is_actor? && unit.is_a?(Game_Party)
- belongs |= self.is_enemy? && unit.is_a?(Game_Troop)
- return belongs
- end
- #-----------------------------------------------------------------------------
- # * Name : Member of Unit?
- # Info : Returns true/false if Party or Troop has battler
- # Author : Kain Nobel
- # Call Info : Unit is either a Game_Party or Game_Troop class
- #-----------------------------------------------------------------------------
- def member_of_unit?(unit)
- case unit.class
- when Game_Party ; return unit.actors.include?(self)
- when Game_Troop ; return unit.enemies.include?(self)
- end
- end
- #-----------------------------------------------------------------------------
- # * Name : Belongs To Party?
- # Info : Returns true/false if self belongs to Game_Party
- # Author : Kain Nobel
- # Call Info : None
- #-----------------------------------------------------------------------------
- def belongs_to_party?
- return self.belongs_to_unit?(Game_Party.new)
- end
- #-----------------------------------------------------------------------------
- # * Name : Belongs To Party?
- # Info : Returns true/false if self belongs to Game_Troop
- # Author : Kain Nobel
- # Call Info : None
- #-----------------------------------------------------------------------------
- def belongs_to_troop?
- return self.belongs_to_unit?(Game_Troop.new)
- end
- #-----------------------------------------------------------------------------
- # * Name : Member of Party?
- # Info : Returns true/false if Party has battler
- # Author : Kain Nobel
- # Call Info : None
- #-----------------------------------------------------------------------------
- def member_of_party?
- return self.member_of_unit?($game_party) rescue return false
- end
- #-----------------------------------------------------------------------------
- # * Name : Member of Troop?
- # Info : Returns true/false if Troop has battler
- # Author : Kain Nobel
- # Call Info : None
- #-----------------------------------------------------------------------------
- def member_of_troop?
- return self.member_of_unit?($game_troop) rescue return false
- end
- end
- #===============================================================================
- # ** RGSS.Character
- #===============================================================================
- class Game_Character
- #-----------------------------------------------------------------------------
- # * Name : XY
- # Info : Returns @x and @y properties to array.
- # Author : Kain Nobel
- # Call Info : None
- #-----------------------------------------------------------------------------
- def xy
- return [self.x, self.y]
- end
- #-----------------------------------------------------------------------------
- # * Name : XYD
- # Info : Returns @x, @y and @direction properties to array.
- # Author : Kain Nobel
- # Call Info : None
- #-----------------------------------------------------------------------------
- def xyd
- return [self.x, self.y, self.direction]
- end
- #-----------------------------------------------------------------------------
- # * Name : Next X
- # Info : Returns next X coord for facing direction
- # Author : Kain Nobel
- # Call Info : Direction is the direction character is facing
- #-----------------------------------------------------------------------------
- def next_x(d = self.direction, steps = 1)
- return (self.x + (steps * (d == 6 ? 1 : d == 4 ? -1 : 0)))
- end
- #-----------------------------------------------------------------------------
- # * Name : Next Y
- # Info : Returns next Y coord for facing direction
- # Author : Kain Nobel
- # Call Info : Direction is the direction character is facing
- #-----------------------------------------------------------------------------
- def next_y(d = self.direction, steps = 1)
- return (self.y + (steps * (d == 2 ? 1 : d == 8 ? -1 : 0)))
- end
- #-----------------------------------------------------------------------------
- # * Name : Next X/Y
- # Info : Returns next X & Y coord for facing direction (to an array)
- # Author : Kain Nobel
- # Call Info : Direction is the direction character is facing
- #-----------------------------------------------------------------------------
- def next_xy(d = self.direction, steps = 1)
- return [self.next_x(d, steps), self.next_y(d, steps)]
- end
- #-----------------------------------------------------------------------------
- # * Name : Events Front
- # Info : Returns all events on same tile
- # Author : Kain Nobel
- # Call Info : None
- #-----------------------------------------------------------------------------
- def events_here
- return $game_map.events_at(*self.xy)
- end
- #-----------------------------------------------------------------------------
- # * Name : Events Front
- # Info : Returns all events on tile front
- # Author : Kain Nobel
- # Call Info : None
- #-----------------------------------------------------------------------------
- def events_front
- return $game_map.events_at(*self.xyd)
- end
- #-----------------------------------------------------------------------------
- # * Name : Events Behind
- # Info : Returns all events on tile behind
- # Author : Kain Nobel
- # Call Info : None
- #-----------------------------------------------------------------------------
- def events_behind
- d = case self.direction
- when 2 then 8
- when 4 then 6
- when 6 then 4
- when 8 then 2
- end
- return $game_map.events_at(self.x, self.y, d)
- end
- #-----------------------------------------------------------------------------
- # * Name : Events Left
- # Info : Returns all events on tile to left hand of self
- # Author : Kain Nobel
- # Call Info : None
- #-----------------------------------------------------------------------------
- def events_left
- d = case self.direction
- when 2 then 6
- when 4 then 2
- when 6 then 8
- when 8 then 4
- end
- return $game_map.events_at(self.x, self.y, d)
- end
- #-----------------------------------------------------------------------------
- # * Name : Events Right
- # Info : Returns all events on tile to right hand of self
- # Author : Kain Nobel
- # Call Info : None
- #-----------------------------------------------------------------------------
- def events_right
- d = case self.direction
- when 2 then 4
- when 4 then 8
- when 6 then 2
- when 8 then 6
- end
- return $game_map.events_at(self.x, self.y, d)
- end
- #-----------------------------------------------------------------------------
- # * Name : This Event
- # Info : Returns very first event from 'events_here' or 'event_front'
- # Author : Kain Nobel
- # Call Info : None
- #-----------------------------------------------------------------------------
- def this_event
- return self.event_here unless self.event_here.nil?
- return self.event_front
- end
- #-----------------------------------------------------------------------------
- # * Name : Event Here
- # Info : Returns very first event from 'events_here'
- # Author : Kain Nobel
- # Call Info : None
- #-----------------------------------------------------------------------------
- def event_here
- return self.events_here[0]
- end
- #-----------------------------------------------------------------------------
- # * Name : Event Front
- # Info : Returns very first event from 'events_front'
- # Author : Kain Nobel
- # Call Info : None
- #-----------------------------------------------------------------------------
- def event_front
- return self.events_front[0]
- end
- #-----------------------------------------------------------------------------
- # * Name : Event Behind
- # Info : Returns very first event from 'events_behind'
- # Author : Kain Nobel
- # Call Info : None
- #-----------------------------------------------------------------------------
- def event_behind
- return self.events_behind[0]
- end
- #-----------------------------------------------------------------------------
- # * Name : Event Left
- # Info : Returns very first event from 'events_left'
- # Author : Kain Nobel
- # Call Info : None
- #-----------------------------------------------------------------------------
- def event_left
- return self.events_left[0]
- end
- #-----------------------------------------------------------------------------
- # * Name : Event Right
- # Info : Returns very first event from 'events_right'
- # Author : Kain Nobel
- # Call Info : None
- #-----------------------------------------------------------------------------
- def event_right
- return self.events_right[0]
- end
- end
- #===============================================================================
- # ** RGSS.Enemy and Troop Info
- #===============================================================================
- #===============================================================================
- # ** Game_Troop
- #===============================================================================
- class Game_Troop
- #-----------------------------------------------------------------------------
- # * Name : Members
- # Info : Returns @enemies
- # Author : Kain Nobel
- # Call Info : None
- #-----------------------------------------------------------------------------
- def members
- return @enemies
- end
- #-----------------------------------------------------------------------------
- # * 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
- #-----------------------------------------------------------------------------
- def average(stat)
- return 0 if self.members.size == 0
- avg = 0
- case stat.downcase
- when 'hp' ; self.members.each {|m| avg += m.hp}
- when 'maxhp' ; self.members.each {|m| avg += m.maxhp}
- when 'sp' ; self.members.each {|m| avg += m.sp}
- when 'maxsp' ; self.members.each {|m| avg += m.maxsp}
- when 'level' ; self.members.each {|m| avg += m.level}
- when 'exp' ; self.members.each {|m| avg += m.exp}
- when 'str' ; self.members.each {|m| avg += m.str}
- when 'dex' ; self.members.each {|m| avg += m.dex}
- when 'agi' ; self.members.each {|m| avg += m.agi}
- when 'int' ; self.members.each {|m| avg += m.int}
- when 'atk' ; self.members.each {|m| avg += m.atk}
- when 'pdef' ; self.members.each {|m| avg += m.pdef}
- when 'mdef' ; self.members.each {|m| avg += m.mdef}
- when 'eva' ; self.members.each {|m| avg += m.eva}
- end
- return (avg / self.members.size)
- end
- #-----------------------------------------------------------------------------
- # * Name : Recover All
- # Info : Recover HP/SP and States
- # Author : Kain Nobel
- # Call Info : None
- #-----------------------------------------------------------------------------
- def recover_all
- self.members.each {|m| m.recover_all}
- end
- #-----------------------------------------------------------------------------
- # * Name : Revive All
- # Info : Revive all enemies with percent/direct ammount of HP
- # Author : Kain Nobel
- # Call Info : None
- #-----------------------------------------------------------------------------
- def revive_all(direct = 0, percent = 0)
- self.members.each {|m|
- unless m.hp > 0
- m.hp += Integer(direct * (percent / 100.0))
- end}
- end
- #-----------------------------------------------------------------------------
- # * Name : Kill All
- # Info : Kill all enemies instantly
- # Author : Kain Nobel
- # Call Info : None
- #-----------------------------------------------------------------------------
- def kill_all
- self.members.each {|m| m.hp = 0}
- end
- #-----------------------------------------------------------------------------
- # * Name : Add State
- # Info : Inflicts all enemies with designated state
- # Author : Kain Nobel
- # Call Info : State ID - Integer representing State's ID in database
- #-----------------------------------------------------------------------------
- def add_state(state_id)
- self.members.each {|m| m.add_state(state_id)}
- end
- #-----------------------------------------------------------------------------
- # * Name : Remove State
- # Info : Removes designated State from all enemies
- # Author : Kain Nobel
- # Call Info : State ID - Integer representing State's ID in database
- #-----------------------------------------------------------------------------
- def remove_state(state_id)
- self.members.each {|m| m.remove_state(state_id)}
- end
- #-----------------------------------------------------------------------------
- # * Name : Add States
- # Info : Inflicst all enemies with an array of states
- # Author : Kain Nobel
- # Call Info : States - Array with State IDs to be added
- #-----------------------------------------------------------------------------
- def add_states(states = [])
- states.compact!
- states.each {|state| self.add_state(state)}
- end
- #-----------------------------------------------------------------------------
- # * Name : Remove States
- # Info : Removes an array of states from all enemies
- # Author : Kain Nobel
- # Call Info : States - Array of State IDs to be removed
- #-----------------------------------------------------------------------------
- def remove_states(states = [])
- states.compact!
- states.each {|state| self.remove_state(state)}
- end
- #-----------------------------------------------------------------------------
- # * Name : Change States
- # Info : Compresses 'add_states' and 'remove_states'
- # Author : Kain Nobel
- # Call Info : States - Array of State IDs to be added/removed
- # State IDs must be positive to be added
- # State IDs must be negative to be removed
- # States can also be a Hash with (State ID => true/false)
- # If State ID points to True : it will be added
- # If State ID points to False : it will be removed
- #-----------------------------------------------------------------------------
- def change_states(states = [])
- add, rem = Array.new, Array.new
- if states.is_a?(Array)
- states.each do |id|
- add << id if id > 0
- rem << -id if id < 0
- end
- elsif states.is_a?(Hash)
- states.each_key do |key|
- add << key if states[key] == true
- rem << key if states[key] == false
- end
- end
- self.add_states(add)
- self.remove_states(rem)
- end
- end
- #===============================================================================
- # ** RGSS.Map
- #-------------------------------------------------------------------------------
- # Methods List
- # ------------
- #
- # this_event
- # event_count
- # exists?
- # map_infos
- # map_count
- # map_name
- # parent_id
- # parent_name
- # print_list
- #===============================================================================
- #-------------------------------------------------------------------------------
- # * MACL Loading
- #-------------------------------------------------------------------------------
- if Object.const_defined?(:MACL)
- MACL::Loaded << 'RGSS.Map'
- end
- #===============================================================================
- # ** Game_Map
- #===============================================================================
- class Game_Map
- #-----------------------------------------------------------------------------
- # * Name : Events At
- # Info : Returns an array of events at location
- # Author : Kain Nobel
- # Call Info : Two Arguments Integer X, Y - Position to Check
- # D (Optional) Integer - Directional modifier to check
- #-----------------------------------------------------------------------------
- def events_at(x, y, d = 0, attr = nil)
- events = Array.new
- x += (d == 6 ? 1 : d == 4 ? -1 : 0)
- y += (d == 2 ? 1 : d == 8 ? -1 : 0)
- @events.each_value {|event|
- if event.x == x && event.y == y
- eval "events << (attr.nil? ? event : event.#{attr})"
- end}
- return events
- end
- #-----------------------------------------------------------------------------
- # * Name : Event At
- # Info : Returns very first event from events_at method.
- # Author : SephirothSpawn / Kain Nobel
- # Call Info : Two Arguments Integer X, Y - Position to Check
- # D (Optional) Integer - Directional modifier to check
- #-----------------------------------------------------------------------------
- def event_at(x, y, d = 0, attr = nil)
- return events_at(x, y, d, attr)[0]
- end
- #-----------------------------------------------------------------------------
- # * Name : Characters At
- # Info : Returns an array of characters at location
- # Author : Kain Nobel
- # Call Info : Two Arguments Integer X, Y - Position to Check
- # D (Optional) Integer - Directional modifier to check
- #-----------------------------------------------------------------------------
- def characters_at(x, y, d = 0, attr = nil)
- characters = Array.new
- x += (d == 6 ? 1 : d == 4 ? -1 : 0)
- y += (d == 2 ? 1 : d == 8 ? -1 : 0)
- @characters.each_value {|character|
- if character.x == x && character.y == y
- eval "characters << (attr.nil? ? character : character.#{attr})"
- end}
- return characters
- end
- #-----------------------------------------------------------------------------
- # * Name : Character At
- # Info : Returns very first character from characters_at method.
- # Author : SephirothSpawn / Kain Nobel
- # Call Info : Two Arguments Integer X, Y - Position to Check
- # D (Optional) Integer - Directional modifier to check
- #-----------------------------------------------------------------------------
- def character_at(x, y, d = 0, attr = nil)
- return characters_at(x, y, d, attr)[0]
- end
- #-----------------------------------------------------------------------------
- # * Name : This Event
- # Info : Finds the first event directly in front of $game_player
- # Author : Kain Nobel
- # Call Info : None, returns event here or event in front or nil if no event
- #-----------------------------------------------------------------------------
- def this_event
- return $game_player.this_event
- end
- #-----------------------------------------------------------------------------
- # * Name : Event Count
- # Info : Simply counts how many events are on the $game_map
- # Author : Kain Nobel
- # Call Info : None, returns number of events on map
- #-----------------------------------------------------------------------------
- def event_count
- return @events.empty? ? 0 : @events.size
- end
- #-----------------------------------------------------------------------------
- # * Name : Exists?
- # Info : Tests to see if Map exists
- # Author : Kain Nobel
- # Call Info : Map ID is the Map in question
- #-----------------------------------------------------------------------------
- def exists?(map_id)
- return FileTest.exist?(sprintf("Data/Map%03d.rxdata", map_id))
- end
- #-----------------------------------------------------------------------------
- # * Name : Map Infos
- # Info : Returns "Data/MapInfos.rxdata"
- # Author : Kain Nobel
- # Call Info : Miscellaneous
- #-----------------------------------------------------------------------------
- def map_infos
- @map_infos ||= load_data("Data/MapInfos.rxdata")
- return @map_infos
- end
- #-----------------------------------------------------------------------------
- # * Name : Map Count
- # Info : Returns number of valid Map filenames
- # Author : Kain Nobel
- # Call Info : None, returns number of maps in project folder
- #-----------------------------------------------------------------------------
- def map_count
- return map_infos.keys.size
- end
- #-----------------------------------------------------------------------------
- # * Name : Map Name
- # Info : Sends name of the map in question to a string
- # Author : Kain Nobel
- # Call Info : Map ID (Optional) returns specified Map ID's name
- #-----------------------------------------------------------------------------
- def map_name(map_id = @map_id)
- begin ; return map_infos[map_id].name
- rescue ; return ""
- end
- end
- #-----------------------------------------------------------------------------
- # * Name : Parent ID
- # Info : Returns ID of parent map
- # Author : Kain Nobel
- # Call Info : Map ID (Optional) returns specified Map ID's parent Map ID
- #-----------------------------------------------------------------------------
- def parent_id(map_id = @map_id)
- begin ; return map_infos[map_id].parent_id
- rescue ; return 0
- end
- end
- #-----------------------------------------------------------------------------
- # * Name : Parent Name
- # Info : Sends name of the parent map in question to a string
- # Author : Kain Nobel
- # Call Info : Map ID (Optional) returns specified Map ID's parent's name
- #-----------------------------------------------------------------------------
- def parent_name
- begin ; return map_name(parent_id)
- rescue ; return ""
- end
- end
- #-----------------------------------------------------------------------------
- # * Name : Print List
- # Info : Prints an Event's Command List in a human readable format
- # Author : Kain Nobel
- # Call Info : Event ID, the event whom's list shall be printed
- #-----------------------------------------------------------------------------
- def print_list(event_id)
- list = String.new
- unless $game_map.events[event_id].nil?
- for c in $game_map.events[event_id].list
- code = c.code.to_s
- code.gsub!("101", "Show Text")
- code.gsub!("102", "Show Choices")
- code.gsub!("401", "" * c.indent)
- code.gsub!("402", "When [**]")
- code.gsub!("403", "When Cancel")
- code.gsub!("103", "Input Number")
- code.gsub!("104", "Change Text Options")
- code.gsub!("105", "Button Input Processing")
- code.gsub!("106", "Wait")
- code.gsub!("111", "Conditional Branch")
- code.gsub!("411", "Else")
- code.gsub!("412", "Branch End")
- code.gsub!("112", "Loop")
- code.gsub!("413", "Repeat Above")
- code.gsub!("113", "Break Loop")
- code.gsub!("115", "Exit Event Processing")
- code.gsub!("116", "Erase Event")
- code.gsub!("117", "Call Common Event")
- code.gsub!("118", "Label")
- code.gsub!("119", "Jump to Label")
- code.gsub!("121", "Control Switches")
- code.gsub!("122", "Control Variables")
- code.gsub!("123", "Control Self Switch")
- code.gsub!("124", "Control Timer")
- code.gsub!("125", "Change Gold")
- code.gsub!("126", "Change Items")
- code.gsub!("127", "Change Weapons")
- code.gsub!("128", "Change Armor")
- code.gsub!("129", "Change Party Member")
- code.gsub!("131", "Change Windowskin")
- code.gsub!("132", "Change Battle BGM")
- code.gsub!("133", "Change Battle End ME")
- code.gsub!("134", "Change Save Access")
- code.gsub!("135", "Change Menu Access")
- code.gsub!("136", "Change Encounter")
- code.gsub!("201", "Transfer Player")
- code.gsub!("202", "Set Event Location")
- code.gsub!("203", "Scroll Map")
- code.gsub!("204", "Change Map Settings")
- code.gsub!("205", "Change Fog Color Tone")
- code.gsub!("206", "Change Fog Opacity")
- code.gsub!("207", "Show Animation")
- code.gsub!("208", "Change Transparent Flag")
- code.gsub!("209", "Set Move Route")
- code.gsub!("210", "Wait for Move's Completion")
- code.gsub!("221", "Prepare for Transition")
- code.gsub!("222", "Execute Transition")
- code.gsub!("223", "Change Screen Color Tone")
- code.gsub!("224", "Screen Flash")
- code.gsub!("225", "Screen Shake")
- code.gsub!("231", "Show Picture")
- code.gsub!("232", "Move Picture")
- code.gsub!("233", "Rotate Picture")
- code.gsub!("234", "Change Picture Color Tone")
- code.gsub!("235", "Erase Picture")
- code.gsub!("236", "Set Weather Effects")
- code.gsub!("241", "Play BGM")
- code.gsub!("242", "Fade Out BGM")
- code.gsub!("245", "Play BGS")
- code.gsub!("246", "Fade Out BGS")
- code.gsub!("247", "Memorize BGM/BGS")
- code.gsub!("248", "Restore BGM/BGS")
- code.gsub!("249", "Play ME")
- code.gsub!("250", "Play SE")
- code.gsub!("251", "Stop SE")
- code.gsub!("301", "Battle Processing")
- code.gsub!("601", "If Win")
- code.gsub!("602", "If Escape")
- code.gsub!("603", "If Lose")
- code.gsub!("302", "Shop Processing")
- code.gsub!("303", "Name Input Processing")
- code.gsub!("311", "Change HP")
- code.gsub!("312", "Change SP")
- code.gsub!("313", "Change State")
- code.gsub!("314", "Recover All")
- code.gsub!("315", "Change EXP")
- code.gsub!("316", "Change Level")
- code.gsub!("317", "Change Parameters")
- code.gsub!("318", "Change Skills")
- code.gsub!("319", "Change Equipment")
- code.gsub!("320", "Change Actor Name")
- code.gsub!("321", "Change Actor Class")
- code.gsub!("322", "Change Actor Graphic")
- code.gsub!("331", "Change Enemy HP")
- code.gsub!("332", "Change Enemy SP")
- code.gsub!("333", "Change Enemy State")
- code.gsub!("334", "Enemy Recover All")
- code.gsub!("335", "Enemy Appearance")
- code.gsub!("336", "Enemy Transform")
- code.gsub!("337", "Show Battle Animation")
- code.gsub!("338", "Deal Damage")
- code.gsub!("339", "Force Action")
- code.gsub!("340", "Abort Battle")
- code.gsub!("351", "Call Menu Screen")
- code.gsub!("352", "Call Save Screen")
- code.gsub!("353", "Game Over")
- code.gsub!("354", "Return to Title Screen")
- code.gsub!("355", "Script")
- code.gsub!("0", "")
- code = (" " * c.indent) + "@>#{code}:#{c.parameters}\n"
- list += code
- end
- end
- print list
- end
- end
- #===============================================================================
- # ** RGSS.RPG::Cache
- #===============================================================================
- class << RPG::Cache
- #-----------------------------------------------------------------------------
- # * Alias Listings
- #-----------------------------------------------------------------------------
- unless self.method_defined?(:knmacl_rpgcache_clear)
- alias_method :knmacl_rpgcache_clear, :clear
- end
- #-----------------------------------------------------------------------------
- # * Name : Clear
- # Info : Clears keys similiar to the specified key
- # Author : Kain Nobel
- # Call Info : Key (optional) is a string representing what kind of objects
- # to delete. For instance "Fog" remove any objects with keys
- # that include the word "Fog" in it. If no key is omitted,
- # the entire @cache is cleared.
- #-----------------------------------------------------------------------------
- def self.clear(key = nil)
- if key.nil?
- knmacl_rpgcache_clear
- return
- end
- @cache.each_key do |key|
- if key.is_a?(String) && key.include?(key)
- @cache.delete(key)
- end
- end
- end
- end
- #===============================================================================
- # ** RGSS.RPG::Item
- #===============================================================================
- class RPG::Item
- #-----------------------------------------------------------------------------
- # * Name : HP Neutral?
- # Info : Returns Recover HP and Recover HP Rate is 0
- # Author : Kain Nobel
- # Call Info : None
- #-----------------------------------------------------------------------------
- def hp_neutral?
- return @recover_hp == 0 && @recover_hp_rate == 0
- end
- #-----------------------------------------------------------------------------
- # * Name : HP Recovery?
- # Info : Returns Recover HP and Recover HP Rate more than 0
- # Author : Kain Nobel
- # Call Info : None
- #-----------------------------------------------------------------------------
- def hp_recovery?
- return @recover_hp > 0 && @recover_hp_rate > 0
- end
- #-----------------------------------------------------------------------------
- # * Name : HP Damage?
- # Info : Returns Recover HP and Recover HP Rate less than 0
- # Author : Kain Nobel
- # Call Info : None
- #-----------------------------------------------------------------------------
- def hp_damage?
- return @recover_hp < 0 && @recover_hp_rate < 0
- end
- #-----------------------------------------------------------------------------
- # * Name : SP Neutral?
- # Info : Returns Recover SP and Recover SP Rate is 0
- # Author : Kain Nobel
- # Call Info : None
- #-----------------------------------------------------------------------------
- def sp_neutral?
- return @recover_sp == 0 && @recover_sp_rate == 0
- end
- #-----------------------------------------------------------------------------
- # * Name : SP Recovery?
- # Info : Returns Recover SP and Recover SP Rate more than 0
- # Author : Kain Nobel
- # Call Info : None
- #-----------------------------------------------------------------------------
- def sp_recovery?
- return @recover_sp > 0 && @recover_sp_rate > 0
- end
- #-----------------------------------------------------------------------------
- # * Name : SP Damage?
- # Info : Returns Recover SP and Recover SP Rate less than 0
- # Author : Kain Nobel
- # Call Info : None
- #-----------------------------------------------------------------------------
- def sp_damage?
- return @recover_sp < 0 && @recover_sp_rate < 0
- end
- #-----------------------------------------------------------------------------
- # * Name : Is Item?
- # Info : Returns true
- # Author : Kain Nobel
- # Call Info : None
- #-----------------------------------------------------------------------------
- def is_item?
- return true
- end
- #-----------------------------------------------------------------------------
- # * Name : Is Armor?
- # Info : Returns false
- # Author : Kain Nobel
- # Call Info : None
- #-----------------------------------------------------------------------------
- def is_armor?
- return false
- end
- #-----------------------------------------------------------------------------
- # * Name : Is Weapon?
- # Info : Returns false
- # Author : Kain Nobel
- # Call Info : None
- #-----------------------------------------------------------------------------
- def is_weapon?
- return false
- end
- #-----------------------------------------------------------------------------
- # * Name : Is Skill?
- # Info : Returns false
- # Author : Kain Nobel
- # Call Info : None
- #-----------------------------------------------------------------------------
- def is_skill?
- return false
- end
- #-----------------------------------------------------------------------------
- # * Name : Party Quant
- # Info : Returns how many of self is in $game_party.items
- # Author : Kain Nobel
- # Call Info : None
- #-----------------------------------------------------------------------------
- def party_quant
- return 0 if $game_party.nil?
- unless $game_party.items.has_key?(@id)
- return 0
- end
- return $game_party.items[@id]
- end
- #-----------------------------------------------------------------------------
- # * Name : Has Element?
- # Info : Returns if @element_set includes element
- # Author : Kain Nobel
- # Call Info : Element is Integer representing Element Tag ID in question
- #-----------------------------------------------------------------------------
- def has_element?(id = 0)
- return true if id == 0
- return @element_set.include?(id)
- end
- #-----------------------------------------------------------------------------
- # * Name : Has Element?
- # Info : Returns an array of elements from 'has_element?'
- # Author : Kain Nobel
- # Call Info : Elements is an Array - See 'has_element?'
- #-----------------------------------------------------------------------------
- def has_elements?(elements = [])
- list = Array.new
- elements.each {|e| list << e if self.has_element?(e)}
- return list
- end
- end
- #===============================================================================
- # ** RGSS.RPG::Armor
- #===============================================================================
- class RPG::Armor
- #-----------------------------------------------------------------------------
- # * Name : Is Item?
- # Info : Returns false
- # Author : Kain Nobel
- # Call Info : None
- #-----------------------------------------------------------------------------
- def is_item?
- return false
- end
- #-----------------------------------------------------------------------------
- # * Name : Is Armor?
- # Info : Returns true
- # Author : Kain Nobel
- # Call Info : None
- #-----------------------------------------------------------------------------
- def is_armor?
- return true
- end
- #-----------------------------------------------------------------------------
- # * Name : Is Weapon?
- # Info : Returns false
- # Author : Kain Nobel
- # Call Info : None
- #-----------------------------------------------------------------------------
- def is_weapon?
- return false
- end
- #-----------------------------------------------------------------------------
- # * Name : Is Skill?
- # Info : Returns false
- # Author : Kain Nobel
- # Call Info : None
- #-----------------------------------------------------------------------------
- def is_skill?
- return false
- end
- #-----------------------------------------------------------------------------
- # * Name : Party Quant
- # Info : Returns how many of self is in $game_party.armors
- # Author : Kain Nobel
- # Call Info : None
- #-----------------------------------------------------------------------------
- def party_quant
- return 0 if $game_party.nil?
- unless $game_party.armors.has_key?(@id)
- return 0
- end
- return $game_party.armors[@id]
- end
- #-----------------------------------------------------------------------------
- # * Has Element? (ID)
- #-----------------------------------------------------------------------------
- def has_element?(id = 0)
- return true if id == 0
- return @guard_element_set.include?(id)
- end
- #-----------------------------------------------------------------------------
- # * Name : Has Element?
- # Info : Returns if @guard_element_set includes element
- # Author : Kain Nobel
- # Call Info : Element is Integer representing Element Tag ID in question
- #-----------------------------------------------------------------------------
- def has_element?(id = 0)
- return true if id == 0
- return @guard_element_set.include?(id)
- end
- #-----------------------------------------------------------------------------
- # * Name : Has Element?
- # Info : Returns an array of elements from 'has_element?'
- # Author : Kain Nobel
- # Call Info : Elements is an Array - See 'has_element?'
- #-----------------------------------------------------------------------------
- def has_elements?(elements = [])
- list = Array.new
- elements.each {|e| list << e if self.has_element?(e)}
- return list
- end
- end
- #===============================================================================
- # ** RGSS.RPG::Weapon
- #===============================================================================
- class RPG::Weapon
- #-----------------------------------------------------------------------------
- # * Name : Is Item?
- # Info : Returns false
- # Author : Kain Nobel
- # Call Info : None
- #-----------------------------------------------------------------------------
- def is_item?
- return false
- end
- #-----------------------------------------------------------------------------
- # * Name : Is Armor?
- # Info : Returns false
- # Author : Kain Nobel
- # Call Info : None
- #-----------------------------------------------------------------------------
- def is_armor?
- return false
- end
- #-----------------------------------------------------------------------------
- # * Name : Is Weapon?
- # Info : Returns true
- # Author : Kain Nobel
- # Call Info : None
- #-----------------------------------------------------------------------------
- def is_weapon?
- return true
- end
- #-----------------------------------------------------------------------------
- # * Name : Is Skill?
- # Info : Returns false
- # Author : Kain Nobel
- # Call Info : None
- #-----------------------------------------------------------------------------
- def is_skill?
- return false
- end
- #-----------------------------------------------------------------------------
- # * Name : Party Quant
- # Info : Returns how many of self is in $game_party.weapons
- # Author : Kain Nobel
- # Call Info : None
- #-----------------------------------------------------------------------------
- def party_quant
- return 0 if $game_party.nil?
- unless $game_party.weapons.has_key?(@id)
- return 0
- end
- return $game_party.weapons[@id]
- end
- #-----------------------------------------------------------------------------
- # * Name : Has Element?
- # Info : Returns if @element_set includes element
- # Author : Kain Nobel
- # Call Info : Element is Integer representing Element Tag ID in question
- #-----------------------------------------------------------------------------
- def has_element?(id = 0)
- return true if id == 0
- return @element_set.include?(id)
- end
- #-----------------------------------------------------------------------------
- # * Name : Has Element?
- # Info : Returns an array of elements from 'has_element?'
- # Author : Kain Nobel
- # Call Info : Elements is an Array - See 'has_element?'
- #-----------------------------------------------------------------------------
- def has_elements?(elements = [])
- list = Array.new
- elements.each {|e| list << e if self.has_element?(e)}
- return list
- end
- end
- #===============================================================================
- # ** RGSS.RPG::Skill
- #===============================================================================
- class RPG::Skill
- #-----------------------------------------------------------------------------
- # * Name : Has Element?
- # Info : Returns if @element_set includes element
- # Author : Kain Nobel
- # Call Info : Element is Integer representing Element Tag ID in question
- #-----------------------------------------------------------------------------
- def has_element?(id = 0)
- return true if id == 0
- return @element_set.include?(id)
- end
- #-----------------------------------------------------------------------------
- # * Name : Has Element?
- # Info : Returns an array of elements from 'has_element?'
- # Author : Kain Nobel
- # Call Info : Elements is an Array - See 'has_element?'
- #-----------------------------------------------------------------------------
- def has_elements?(elements = [])
- list = Array.new
- elements.each {|e| list << e if self.has_element?(e)}
- return list
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement