This week only. Pastebin PRO Accounts Christmas Special! Don't miss out!Want more features on Pastebin? Sign Up, it's FREE!
Guest

Kain Nobel

By: a guest on Apr 22nd, 2009  |  syntax: Ruby  |  size: 72.53 KB  |  views: 82  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
This paste has a previous version, view the difference. Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. #===============================================================================
  2. # ** Ruby.Array.find
  3. #===============================================================================
  4.  
  5. class Array
  6.   #-----------------------------------------------------------------------------
  7.   # * Name      : Next Index From
  8.   #   Info      : Gets next item in array (in a wrapped fashion)
  9.   #   Author    : Kain Nobel
  10.   #   Call Info : Item is the object in question
  11.   #               Indexes is how many spaces ahead to look
  12.   #-----------------------------------------------------------------------------
  13.   def next_index_from(item, indexes = 1)
  14.     indexes = -indexes if indexes < 0
  15.     if self.include?(item)
  16.       for i in 0...self.size
  17.         if self[i] == item
  18.           if self.size > (i + indexes)
  19.             return self[i + indexes]
  20.           end
  21.           return self[(i + indexes) - self.size]
  22.         end
  23.       end
  24.     end
  25.   end
  26.   #-----------------------------------------------------------------------------
  27.   # * Name      : Prev Index From
  28.   #   Info      : Gets previous item in array (in a wrapped fashion)
  29.   #   Author    : Kain Nobel
  30.   #   Call Info : Item is the object in question
  31.   #               Indexes is how many spaces ahead to look
  32.   #-----------------------------------------------------------------------------
  33.   def prev_index_from(item, indexes = 1)
  34.     indexes = -indexes if indexes < 0
  35.     if self.include?(item)
  36.       for i in 0...self.size
  37.         if self[i] == item
  38.           if self.size >= i - indexes
  39.             return self[i - indexes]
  40.           end
  41.           return self[self.size + (i - indexes)]
  42.         end
  43.       end
  44.     end
  45.   end
  46. end
  47.  
  48.  
  49. #===============================================================================
  50. # ** RGSS.Actor and Party Info
  51. #-------------------------------------------------------------------------------
  52. #
  53. # Method List:
  54. # ------------
  55. #
  56. #   Game_Actor
  57. #   ----------
  58. #   exp_s
  59. #   next_exp_s
  60. #   next_rest_exp_s
  61. #   now_exp
  62. #   next_exp
  63. #   weapon_set
  64. #   armor_set
  65. #   weapon_stats
  66. #   armor_stats
  67. #   strongest_weapon
  68. #   weakest_weapon
  69. #   strongest_armor
  70. #   weakest_armor
  71. #
  72. #   Game_Actors
  73. #   -----------
  74. #   each
  75. #   min_stat
  76. #   max_stat
  77. #   average
  78. #   avg_stat
  79. #   min_stats
  80. #   max_stats
  81. #   avg_stats
  82. #  
  83. #
  84. #   Game_Party
  85. #   ----------
  86. #   members
  87. #   gain_all
  88. #   lose_all
  89. #   min_stat
  90. #   max_stat
  91. #   min_stats
  92. #   max_stats
  93. #   average
  94. #   recover_all
  95. #   revive_all
  96. #   kill_all
  97. #   recover_hp
  98. #   recover_sp
  99. #   add_state
  100. #   add_states
  101. #   remove_state
  102. #   remove_states
  103. #   change_states
  104. #
  105. #===============================================================================
  106. #-------------------------------------------------------------------------------
  107. # * MACL Loading
  108. #-------------------------------------------------------------------------------
  109. if Object.const_defined?(:MACL)
  110.   MACL::Loaded << 'RGSS.Actor and Party Info'
  111. end
  112. #===============================================================================
  113. # ** Game_Actor
  114. #===============================================================================
  115. class Game_Actor < Game_Battler
  116.   #-----------------------------------------------------------------------------
  117.   # * Public Instance Variables
  118.   #-----------------------------------------------------------------------------
  119.   attr_accessor :weapon_id
  120.   attr_accessor :armor1_id
  121.   attr_accessor :armor2_id
  122.   attr_accessor :armor3_id
  123.   attr_accessor :armor4_id
  124.   attr_accessor :exp_list
  125.   #-----------------------------------------------------------------------------
  126.   # * Alias Listings
  127.   #-----------------------------------------------------------------------------
  128.   alias_method :kn_macl_gm_actor_equip, :equip
  129.   #-----------------------------------------------------------------------------
  130.   # * Equip
  131.   #-----------------------------------------------------------------------------
  132.   def equip(equip_type, id)
  133.     unless id < 0
  134.       kn_macl_gm_actor_equip(equip_type, id)
  135.     end
  136.   end
  137.   #-----------------------------------------------------------------------------
  138.   # * Name      : Now Exp
  139.   #   Info      : Gets Actors Next in Current Level
  140.   #   Author    : Near Fantastica
  141.   #   Call Info : No Arguments
  142.   #-----------------------------------------------------------------------------
  143.   def now_exp
  144.     return @exp - @exp_list[@level]
  145.   end
  146.   #-----------------------------------------------------------------------------
  147.   # * Name      : Next Exp
  148.   #   Info      : Gets Actors Exp for Next Level
  149.   #   Author    : Near Fantastica
  150.   #   Call Info : No Arguments
  151.   #-----------------------------------------------------------------------------
  152.   def next_exp
  153.     exp = @exp_list[@level+1] > 0 ? @exp_list[@level+1] - @exp_list[@level] : 0
  154.     return exp
  155.   end
  156.   #-----------------------------------------------------------------------------
  157.   # * Name      : Last Exp
  158.   #   Info      : Returns numerical value of last exp
  159.   #   Author    : Kain Nobel
  160.   #   Call Info : None
  161.   #-----------------------------------------------------------------------------
  162.   def last_exp
  163.     return @exp_list[-2]
  164.   end
  165.   #-----------------------------------------------------------------------------
  166.   # * Name      : Last Level
  167.   #   Info      : Returns numerical value of last level achievable
  168.   #   Author    : Kain Nobel
  169.   #   Call Info : None
  170.   #-----------------------------------------------------------------------------
  171.   def final_level
  172.     unless $data_actors[id].nil?
  173.       return $data_actors[id].final_level
  174.     end
  175.     return 0
  176.   end
  177.   #-----------------------------------------------------------------------------
  178.   # * Name      : Experience String (Overwrite)
  179.   #   Info      : Returns Experience String
  180.   #   Author    : Kain Nobel
  181.   #   Call Info : Format will format experience string with commas
  182.   #-----------------------------------------------------------------------------
  183.   def exp_s(format = true)
  184.     if format == true
  185.       return now_exp.between?(0, last_exp) ? now_exp.format_s : "Master"
  186.     else
  187.       return now_exp.between?(0, last_exp) ? now_exp.to_s     : "Master"
  188.     end
  189.   end
  190.   #-----------------------------------------------------------------------------
  191.   # * Name      : Next Experience String (Overwrite)
  192.   #   Info      : Returns Experience String
  193.   #   Author    : Kain Nobel
  194.   #   Call Info : Format will format experience string with commas
  195.   #-----------------------------------------------------------------------------
  196.   def next_exp_s(format = true)
  197.     if self.now_exp >= self.last_exp
  198.       return "Master"
  199.     else
  200.       if format == true
  201.         return now_exp.between?(0, next_exp) ? next_exp.format_s : now_exp.format_s
  202.       else
  203.         return now_exp.between?(0, next_exp) ? next_exp.to_s     : now_exp.to_s
  204.       end
  205.     end
  206.   end
  207.   #-----------------------------------------------------------------------------
  208.   # * Name      : Weapon Set
  209.   #   Info      : Returns all weapon objects for an actor's class
  210.   #   Author    : Kain Nobel
  211.   #   Call Info : None
  212.   #-----------------------------------------------------------------------------
  213.   def weapon_set
  214.     return $data_classes[@class_id].weapon_set
  215.   end
  216.   #-----------------------------------------------------------------------------
  217.   # * Name      : Armor Set
  218.   #   Info      : Returns all armor objects for an actor's class
  219.   #   Author    : Kain Nobel
  220.   #   Call Info : Kind ID for the Armors to check
  221.   #-----------------------------------------------------------------------------
  222.   def armor_set(kind = nil)
  223.     if kind.nil?
  224.       return $data_classes[@class_id].armor_set
  225.     end
  226.     armors = []
  227.     ($data_classes[@class_id].armor_set).each do |armor|
  228.       armors.push(armor) if $data_armors[armor].kind == kind
  229.     end
  230.     return armors
  231.   end
  232.   #-----------------------------------------------------------------------------
  233.   # * Name      : Weapon Stats
  234.   #   Info      : Returns a list of desired stats for the actor's weapon set
  235.   #   Author    : Kain Nobel
  236.   #   Call Info : Parameter is a string representing parameter in question
  237.   #-----------------------------------------------------------------------------
  238.   def weapon_stats(parameter)
  239.     arr, weapons = Array.new, Array.new
  240.     weapon_set.each do |id|
  241.       if $game_party.weapons.has_key?(id)
  242.         if $game_party.weapons[id] > 0
  243.           weapons << id
  244.         end
  245.       end
  246.     end
  247.     weapons.sort!
  248.     weapons.each do |id|
  249.       case parameter
  250.       when 'name' ; arr << [id, $data_weapons[id].name]
  251.       when 'price'; arr << [id, $data_weapons[id].price]
  252.       when 'atk'  ; arr << [id, $data_weapons[id].atk]
  253.       when 'pdef' ; arr << [id, $data_weapons[id].pdef]
  254.       when 'mdef' ; arr << [id, $data_weapons[id].mdef]
  255.       when 'str'  ; arr << [id, $data_weapons[id].str_plus]
  256.       when 'dex'  ; arr << [id, $data_weapons[id].dex_plus]
  257.       when 'agi'  ; arr << [id, $data_weapons[id].agi_plus]
  258.       when 'int'  ; arr << [id, $data_weapons[id].int_plus]
  259.       else ; print(":"+parameter+": is not a valid parameter when\n",
  260.       "checking for $game_actor["+@actor_id.to_s+"].weapon_stats()")
  261.       end
  262.     end
  263.     return arr
  264.   end
  265.   #-----------------------------------------------------------------------------
  266.   # * Name      : Armor Stats
  267.   #   Info      : Returns a list of desired stats for an actor's armor set
  268.   #   Author    : Kain Nobel
  269.   #   Call Info : Parameter is a string representing parameter in question
  270.   #               Kind refers to the kind of amror it is
  271.   #-----------------------------------------------------------------------------
  272.   def armor_stats(parameter, kind = 0)
  273.     arr, armors = Array.new, Array.new
  274.     armor_set.each do |id|
  275.       if $data_armors[id].kind == kind && $game_party.armors.has_key?(id)
  276.         if $game_party.armors[id] > 0
  277.           armors << id
  278.         end
  279.       end
  280.     end
  281.     armors.sort!
  282.     armors.each do |id|
  283.       case parameter
  284.       when 'name' ; arr << [id, $data_armors[id].name]
  285.       when 'price'; arr << [id, $data_armors[id].price]
  286.       when 'atk'  ; arr << [id, $data_armors[id].atk]
  287.       when 'pdef' ; arr << [id, $data_armors[id].pdef]
  288.       when 'mdef' ; arr << [id, $data_armors[id].mdef]
  289.       when 'str'  ; arr << [id, $data_armors[id].str_plus]
  290.       when 'dex'  ; arr << [id, $data_armors[id].dex_plus]
  291.       when 'agi'  ; arr << [id, $data_armors[id].agi_plus]
  292.       when 'int'  ; arr << [id, $data_armors[id].int_plus]
  293.       else ; print(":"+parameter+": is not a valid parameter when\n",
  294.       "checking for $game_actor["+@actor_id.to_s+"].armor_stats()")
  295.       end
  296.     end
  297.     return arr
  298.   end
  299.   #-----------------------------------------------------------------------------
  300.   # * Name      : Strongest Weapon
  301.   #   Info      : Returns the strongest weapon, based on parameter
  302.   #   Author    : Kain Nobel
  303.   #   Call Info : Parameter is a string representing parameter in question
  304.   #-----------------------------------------------------------------------------
  305.   def strongest_weapon(parameter)
  306.     arr, stats = Array.new, Array.new
  307.     weapon_stats(parameter).each do |stat|
  308.       stats << stat[1]
  309.     end
  310.     stats.sort!
  311.     stats.reverse!
  312.     stats.each do |stat|
  313.       weapon_stats(parameter).each do |param|
  314.         if param[1] == stat && stat > 0
  315.           return param[0]
  316.         end
  317.       end
  318.     end
  319.     return -1
  320.   end
  321.   #-----------------------------------------------------------------------------
  322.   # * Name      : Strongest Armor
  323.   #   Info      : Returns the strongest armor, based on parameter and kind
  324.   #   Author    : Kain Nobel
  325.   #   Call Info : Parameter is a string representing parameter in question
  326.   #               Kind is what kind of armor it is (shield, helmet, etc.)
  327.   #-----------------------------------------------------------------------------
  328.   def strongest_armor(parameter, kind = 0)
  329.     arr, stats = Array.new, Array.new
  330.     armor_stats(parameter, kind).each do |stat|
  331.       stats << stat[1]
  332.     end
  333.     stats.sort!
  334.     stats.reverse!
  335.     stats.each do |stat|
  336.       armor_stats(parameter, kind).each do |param|
  337.         if param[1] == stat && stat > 0
  338.           return param[0]
  339.         end
  340.       end
  341.     end
  342.     return -1
  343.   end
  344.   #-----------------------------------------------------------------------------
  345.   # * Name      : Weakest Weapon
  346.   #   Info      : Returns the weakest weapon, based on parameter
  347.   #   Author    : Kain Nobel
  348.   #   Call Info : Parameter is a string representing parameter in question
  349.   #-----------------------------------------------------------------------------
  350.   def weakest_weapon(parameter)
  351.     arr, stats = Array.new, Array.new
  352.     weapon_stats(parameter).each do |stat|
  353.       stats << stat[1]
  354.     end
  355.     stats.sort!
  356.     stats.each do |stat|
  357.       weapon_stats(parameter).each do |param|
  358.         if param[1] == stat && stat > 0
  359.           return param[0]
  360.         end
  361.       end
  362.     end
  363.     return -1
  364.   end
  365.   #-----------------------------------------------------------------------------
  366.   # * Name      : Weakest Armor
  367.   #   Info      : Returns the strongest armor, based on parameter and kind
  368.   #   Author    : Kain Nobel
  369.   #   Call Info : Parameter is a string representing parameter in question
  370.   #               Kind is what kind of armor it is (shield, helmet, etc.)
  371.   #-----------------------------------------------------------------------------
  372.   def weakest_armor(parameter, kind = 0)
  373.     arr, stats = Array.new, Array.new
  374.     armor_stats(parameter, kind).each do |stat|
  375.       stats << stat[1]
  376.     end
  377.     stats.sort!
  378.     stats.each do |stat|
  379.       armor_stats(parameter, kind).each do |param|
  380.         if param[1] == stat && stat > 0
  381.           return param[0]
  382.         end
  383.       end
  384.     end
  385.     return -1
  386.   end
  387.   #-----------------------------------------------------------------------------
  388.   # * Name      : Unequip All
  389.   #   Info      : Removes all equipment from actor
  390.   #   Author    : Kain Nobel
  391.   #   Call Info : None
  392.   #-----------------------------------------------------------------------------
  393.   def unequip_all
  394.     [0,1,2,3,4].each do |i|
  395.       equip(i, 0)
  396.     end
  397.   end
  398. end
  399.  
  400. #===============================================================================
  401. # ** Game_Actors
  402. #===============================================================================
  403.  
  404. class Game_Actors
  405.   #-----------------------------------------------------------------------------
  406.   # * Name      : Each
  407.   #   Info      : Adds an 'each' method to $game_actors
  408.   #   Author    : Kain Nobel
  409.   #   Call Info : Any normal way you'd call an 'each' method
  410.   #-----------------------------------------------------------------------------
  411.   def each(&block)
  412.     @data.each(&block)
  413.   end
  414.   #-----------------------------------------------------------------------------
  415.   # * Name      : Min Stat
  416.   #   Info      : For attribute in question, returns lowest value from actors
  417.   #   Author    : Kain Nobel
  418.   #   Call Info : Attribute is a String representing attribute in question
  419.   #-----------------------------------------------------------------------------
  420.   def min_stat(attribute)
  421.     attributes = Array.new
  422.     for actor in @data
  423.       value = eval("actor.#{attribute}")
  424.       attributes << value
  425.     end
  426.     attributes.sort!
  427.     return attributes[0]
  428.   end
  429.   #-----------------------------------------------------------------------------
  430.   # * Name      : Max Stat
  431.   #   Info      : For attribute in question, returns highest value from actors
  432.   #   Author    : Kain Nobel
  433.   #   Call Info : Attribute is a String representing attribute in question
  434.   #-----------------------------------------------------------------------------
  435.   def max_stat(attribute)
  436.     attributes = Array.new
  437.     for actor in @data
  438.       value = eval("actor.#{attribute}")
  439.       attributes << value
  440.     end
  441.     attributes.sort!
  442.     return attributes[-1]
  443.   end
  444.   #-----------------------------------------------------------------------------
  445.   # * Name      : Average
  446.   #   Info      : Same as 'avg_stat'
  447.   #   Author    : Kain Nobel
  448.   #   Call Info : Parameter is a string representing parameter in question
  449.   #-----------------------------------------------------------------------------
  450.   def average(attribute)
  451.     return avg_stat(attribute)
  452.   end
  453.   #-----------------------------------------------------------------------------
  454.   # * Name      : Avg Stat
  455.   #   Info      : Returns average of all actors' stats, based on parameter
  456.   #   Author    : Kain Nobel
  457.   #   Call Info : Parameter is a string representing parameter in question
  458.   #-----------------------------------------------------------------------------
  459.   def avg_stat(stat)
  460.     avg = 0
  461.     for i in 1...$data_actors.size
  462.       case stat
  463.       when 'hp'     ; avg += self[i].hp
  464.       when 'maxhp'  ; avg += self[i].maxhp
  465.       when 'sp'     ; avg += self[i].sp
  466.       when 'maxsp'  ; avg += self[i].maxsp
  467.       when 'level'  ; avg += self[i].level
  468.       when 'exp'    ; avg += self[i].exp
  469.       when 'str'    ; avg += self[i].str
  470.       when 'dex'    ; avg += self[i].dex
  471.       when 'agi'    ; avg += self[i].agi
  472.       when 'int'    ; avg += self[i].int
  473.       when 'atk'    ; avg += self[i].atk
  474.       when 'pdef'   ; avg += self[i].pdef
  475.       when 'mdef'   ; avg += self[i].mdef
  476.       when 'eva'    ; avg += self[i].eva
  477.       end
  478.     end
  479.     return (avg / $data_actors.size - 1)
  480.   end
  481.   #-----------------------------------------------------------------------------
  482.   # * Name      : Min Stats
  483.   #   Info      : Generates an array of attributes with 'min_stat' method
  484.   #   Author    : Kain Nobel
  485.   #   Call Info : Attributes is an Array of attributes names in Question
  486.   #-----------------------------------------------------------------------------
  487.   def min_stats(attributes)
  488.     list = Array.new
  489.     attributes.each {|attr| list << min_stat(attr)}
  490.     return list
  491.   end
  492.   #-----------------------------------------------------------------------------
  493.   # * Name      : Max Stats
  494.   #   Info      : Generates an array of attributes with 'max_stat' method
  495.   #   Author    : Kain Nobel
  496.   #   Call Info : Attributes is an Array of attributes names in Question
  497.   #-----------------------------------------------------------------------------
  498.   def max_stats(attributes)
  499.     list = Array.new
  500.     attributes.each {|attr| list << max_stat(attr)}
  501.     return list
  502.   end
  503.   #-----------------------------------------------------------------------------
  504.   # * Name      : Avg Stats
  505.   #   Info      : Generates an array of attributes with 'average' method
  506.   #   Author    : Kain Nobel
  507.   #   Call Info : Attributes is an Array of attributes names in Question
  508.   #-----------------------------------------------------------------------------
  509.   def avg_stats(attributes)
  510.     list = Array.new
  511.     attributes.each {|attr| list << avg_stat(attr)}
  512.     return list
  513.   end
  514. end
  515.  
  516. #===============================================================================
  517. # ** Game_Party
  518. #===============================================================================
  519.  
  520. class Game_Party
  521.   #-----------------------------------------------------------------------------
  522.   # * Public Instance Variables
  523.   #-----------------------------------------------------------------------------
  524.   attr_accessor :gold # This is set so you can do $game_party.gold = n
  525.   #-----------------------------------------------------------------------------
  526.   # * Name      : Members
  527.   #   Info      : Returns @actors
  528.   #   Author    : Kain Nobel
  529.   #   Call Info : None
  530.   #-----------------------------------------------------------------------------
  531.   def members
  532.     return @actors
  533.   end
  534.   #-----------------------------------------------------------------------------
  535.   # * Name      : Gain All
  536.   #   Info      : Gain all items (depending on type)
  537.   #   Author    : Kain Nobel
  538.   #   Call Info : Type is the type of 'item' to gain
  539.   #                 -1 : All Items, Weapons, Armors
  540.   #                  0 : All Items
  541.   #                  1 : All Weapons
  542.   #                  2 : All Armors
  543.   #               Quantity is an integer from 1 to 99 (Optional)
  544.   #-----------------------------------------------------------------------------
  545.   def gain_all(type, quantity = 99)
  546.     if type.is_a?(Fixnum) && type.between?(-1, 2)
  547.       case type
  548.       when -1
  549.         $data_items.each_index    {|i| gain_item(i, quantity.abs)}
  550.         $data_weapons.each_index  {|i| gain_weapon(i, quantity.abs)}
  551.         $data_armors.each_index   {|i| gain_armor(i, quantity.abs)}
  552.       when 0 ; $data_items.each_index   {|i| gain_item(i, quantity.abs)}
  553.       when 1 ; $data_weapons.each_index {|i| gain_weapon(i, quantity.abs)}
  554.       when 2 ; $data_armors.each_index  {|i| gain_armor(i, quantity.abs)}
  555.       end
  556.     end
  557.   end
  558.   #-----------------------------------------------------------------------------
  559.   # * Name      : Lose All
  560.   #   Info      : Lose all items (depending on type)
  561.   #   Author    : Kain Nobel
  562.   #   Call Info : Type is the type of 'item' to lose
  563.   #                 -1 : All Items, Weapons, Armors
  564.   #                  0 : All Items
  565.   #                  1 : All Weapons
  566.   #                  2 : All Armors
  567.   #               Quantity is an integer from 1 to 99 (Optional)
  568.   #-----------------------------------------------------------------------------
  569.   def lose_all(type, quantity = 99)
  570.     quantity = -quantity.abs if quantity > 0
  571.     gain_all(type, quantity)
  572.   end
  573.   #-----------------------------------------------------------------------------
  574.   # * Name      : Min Stat
  575.   #   Info      : For attribute in question, returns lowest value from members
  576.   #   Author    : Kain Nobel
  577.   #   Call Info : Attribute is a String representing attribute in question
  578.   #-----------------------------------------------------------------------------
  579.   def min_stat(attribute)
  580.     attributes = Array.new
  581.     for member in self.members
  582.       value = eval("member.#{attribute}")
  583.       attributes << value
  584.     end
  585.     attributes.sort!
  586.     return attributes[0]
  587.   end
  588.   #-----------------------------------------------------------------------------
  589.   # * Name      : Max Stat
  590.   #   Info      : For attribute in question, returns highest value from members
  591.   #   Author    : Kain Nobel
  592.   #   Call Info : Attribute is a String representing attribute in question
  593.   #-----------------------------------------------------------------------------
  594.   def max_stat(attribute)
  595.     attributes = Array.new
  596.     for member in self.members
  597.       value = eval("member.#{attribute}")
  598.       attributes << value
  599.     end
  600.     attributes.sort!
  601.     return attributes[-1]
  602.   end
  603.   #-----------------------------------------------------------------------------
  604.   # * Name      : Average
  605.   #   Info      : Same as 'avg_stat'
  606.   #   Author    : Kain Nobel
  607.   #   Call Info : Parameter is a string representing parameter in question
  608.   #-----------------------------------------------------------------------------
  609.   def average(attribute)
  610.     return avg_stat(attribute)
  611.   end
  612.   #-----------------------------------------------------------------------------
  613.   # * Name      : Avg Stat
  614.   #   Info      : Returns average of party's attributes, based on parameter
  615.   #   Author    : Kain Nobel
  616.   #   Call Info : Parameter is a string representing parameter in question
  617.   #-----------------------------------------------------------------------------
  618.   def avg_stat(attribute)
  619.     return 0 if self.members.size == 0
  620.     avg = 0
  621.     case attribute.downcase
  622.     when 'hp'    ; self.members.each {|m| avg += m.hp}
  623.     when 'maxhp' ; self.members.each {|m| avg += m.maxhp}
  624.     when 'sp'    ; self.members.each {|m| avg += m.sp}
  625.     when 'maxsp' ; self.members.each {|m| avg += m.maxsp}
  626.     when 'level' ; self.members.each {|m| avg += m.level}
  627.     when 'exp'   ; self.members.each {|m| avg += m.exp}
  628.     when 'str'   ; self.members.each {|m| avg += m.str}
  629.     when 'dex'   ; self.members.each {|m| avg += m.dex}
  630.     when 'agi'   ; self.members.each {|m| avg += m.agi}
  631.     when 'int'   ; self.members.each {|m| avg += m.int}
  632.     when 'atk'   ; self.members.each {|m| avg += m.atk}
  633.     when 'pdef'  ; self.members.each {|m| avg += m.pdef}
  634.     when 'mdef'  ; self.members.each {|m| avg += m.mdef}
  635.     when 'eva'   ; self.members.each {|m| avg += m.eva}
  636.     end
  637.     return (avg / self.members.size)
  638.   end
  639.   #-----------------------------------------------------------------------------
  640.   # * Name      : Min Stats
  641.   #   Info      : Generates an array of attributes with 'min_stat' method
  642.   #   Author    : Kain Nobel
  643.   #   Call Info : Attributes is an Array of attributes names in Question
  644.   #-----------------------------------------------------------------------------
  645.   def min_stats(attributes)
  646.     list = Array.new
  647.     attributes.each {|attr| list << min_stat(attr)}
  648.     return list
  649.   end
  650.   #-----------------------------------------------------------------------------
  651.   # * Name      : Max Stats
  652.   #   Info      : Generates an array of attributes with 'max_stat' method
  653.   #   Author    : Kain Nobel
  654.   #   Call Info : Attributes is an Array of attributes names in Question
  655.   #-----------------------------------------------------------------------------
  656.   def max_stats(attributes)
  657.     list = Array.new
  658.     attributes.each {|attr| list << max_stat(attr)}
  659.     return list
  660.   end
  661.   #-----------------------------------------------------------------------------
  662.   # * Name      : Avg Stats
  663.   #   Info      : Generates an array of attributes with 'average' method
  664.   #   Author    : Kain Nobel
  665.   #   Call Info : Attributes is an Array of attributes names in Question
  666.   #-----------------------------------------------------------------------------
  667.   def avg_stats(attributes)
  668.     list = Array.new
  669.     attributes.each {|attr| list << avg_stat(attr)}
  670.     return list
  671.   end
  672.   #-----------------------------------------------------------------------------
  673.   # * Name      : Recover All
  674.   #   Info      : Recover HP/SP and States
  675.   #   Author    : Kain Nobel
  676.   #   Call Info : None
  677.   #-----------------------------------------------------------------------------
  678.   def recover_all
  679.     self.members.each {|m| m.recover_all}
  680.   end
  681.   #-----------------------------------------------------------------------------
  682.   # * Name      : Revive All
  683.   #   Info      : Revive all actors with percent/direct ammount of HP
  684.   #   Author    : Kain Nobel
  685.   #   Call Info : None
  686.   #-----------------------------------------------------------------------------
  687.   def revive_all(direct = 0, percent = 0)
  688.     self.members.each {|m|
  689.     unless m.hp > 0
  690.       m.hp += Integer(direct * (percent / 100.0))
  691.     end}
  692.   end
  693.   #-----------------------------------------------------------------------------
  694.   # * Name      : Kill All
  695.   #   Info      : Kill all actors instantly
  696.   #   Author    : Kain Nobel
  697.   #   Call Info : None
  698.   #-----------------------------------------------------------------------------
  699.   def kill_all
  700.     self.members.each {|m| m.hp = 0}
  701.   end
  702.   #-----------------------------------------------------------------------------
  703.   # * Name      : Add State
  704.   #   Info      : Inflicts all actors with designated state
  705.   #   Author    : Kain Nobel
  706.   #   Call Info : State ID - Integer representing State's ID in database
  707.   #-----------------------------------------------------------------------------
  708.   def add_state(state_id)
  709.     self.members.each {|m| m.add_state(state_id)}
  710.   end
  711.   #-----------------------------------------------------------------------------
  712.   # * Name      : Remove State
  713.   #   Info      : Removes designated State from all actors
  714.   #   Author    : Kain Nobel
  715.   #   Call Info : State ID - Integer representing State's ID in database
  716.   #-----------------------------------------------------------------------------
  717.   def remove_state(state_id)
  718.     self.members.each {|m| m.remove_state(state_id)}
  719.   end
  720.   #-----------------------------------------------------------------------------
  721.   # * Name      : Add States
  722.   #   Info      : Inflicst all actors with an array of states
  723.   #   Author    : Kain Nobel
  724.   #   Call Info : States - Array with State IDs to be added
  725.   #-----------------------------------------------------------------------------
  726.   def add_states(states = [])
  727.     states.compact!
  728.     states.each {|state| self.add_state(state)}
  729.   end
  730.   #-----------------------------------------------------------------------------
  731.   # * Name      : Remove States
  732.   #   Info      : Removes an array of states from all actors
  733.   #   Author    : Kain Nobel
  734.   #   Call Info : States - Array of State IDs to be removed
  735.   #-----------------------------------------------------------------------------
  736.   def remove_states(states = [])
  737.     states.compact!
  738.     states.each {|state| self.remove_state(state)}
  739.   end
  740.   #-----------------------------------------------------------------------------
  741.   # * Name      : Change States
  742.   #   Info      : Compresses 'add_states' and 'remove_states'
  743.   #   Author    : Kain Nobel
  744.   #   Call Info : States - Array of State IDs to be added/removed
  745.   #                 State IDs must be positive to be added
  746.   #                 State IDs must be negative to be removed
  747.   #               States can also be a Hash with (State ID => true/false)
  748.   #                 If State ID points to True  : it will be added
  749.   #                 If State ID points to False : it will be removed
  750.   #-----------------------------------------------------------------------------
  751.   def change_states(states = [])
  752.     add, rem = Array.new, Array.new
  753.     if states.is_a?(Array)
  754.       states.each do |id|
  755.         add << id if id > 0
  756.         rem << -id if id < 0
  757.       end
  758.     elsif states.is_a?(Hash)
  759.       states.each_key do |key|
  760.         add << key if states[key] == true
  761.         rem << key if states[key] == false
  762.       end
  763.     end
  764.     self.add_states(add)
  765.     self.remove_states(rem)
  766.   end
  767. end
  768.  
  769.  
  770. ]#===============================================================================
  771. # ** RGSS.Battler
  772. #===============================================================================
  773.  
  774. class Game_Battler
  775.   #-----------------------------------------------------------------------------
  776.   # * Name      : Is Actor?
  777.   #   Info      : Returns true/false if self is a Game_Actor class
  778.   #   Author    : Kain Nobel
  779.   #   Call Info : None
  780.   #-----------------------------------------------------------------------------
  781.   def is_actor?
  782.     return (self.is_a?(Game_Actor) || self.kind_of?(Game_Actor))
  783.   end
  784.   #-----------------------------------------------------------------------------
  785.   # * Name      : Is Enemy?
  786.   #   Info      : Returns true/false if self is a Game_Enemy class
  787.   #   Author    : Kain Nobel
  788.   #   Call Info : None
  789.   #-----------------------------------------------------------------------------
  790.   def is_enemy?
  791.     return (self.is_a?(Game_Enemy) || self.kind_of?(Game_Enemy))
  792.   end
  793.   #-----------------------------------------------------------------------------
  794.   # * Name      : Is Ally With?
  795.   #   Info      : Returns true/false if battler kind is same
  796.   #   Author    : Kain Nobel
  797.   #   Call Info : Battler is the Game_Battler object in question.
  798.   #-----------------------------------------------------------------------------
  799.   def is_ally_with?(battler)
  800.     return self.kind_of?(battler.class)
  801.   end
  802.   #-----------------------------------------------------------------------------
  803.   # * Name      : Is Enemy With?
  804.   #   Info      : Returns true/false if battler kind is different
  805.   #   Author    : Kain Nobel
  806.   #   Call Info : Battler is the Game_Battler object in question.
  807.   #-----------------------------------------------------------------------------
  808.   def is_enemy_with?(battler)
  809.     return !self.kind_of?(battler.class)
  810.   end
  811.   #-----------------------------------------------------------------------------
  812.   # * Name      : Belongs To Unit?
  813.   #   Info      : Returns true/false if self belongs to Party or Troop
  814.   #   Author    : Kain Nobel
  815.   #   Call Info : Unit is either a Game_Party or Game_Troop class
  816.   #-----------------------------------------------------------------------------
  817.   def belongs_to_unit?(unit)
  818.     belongs = false
  819.     belongs |= self.is_actor? && unit.is_a?(Game_Party)
  820.     belongs |= self.is_enemy? && unit.is_a?(Game_Troop)
  821.     return belongs
  822.   end
  823.   #-----------------------------------------------------------------------------
  824.   # * Name      : Member of Unit?
  825.   #   Info      : Returns true/false if Party or Troop has battler
  826.   #   Author    : Kain Nobel
  827.   #   Call Info : Unit is either a Game_Party or Game_Troop class
  828.   #-----------------------------------------------------------------------------
  829.   def member_of_unit?(unit)
  830.     case unit.class
  831.     when Game_Party ; return unit.actors.include?(self)
  832.     when Game_Troop ; return unit.enemies.include?(self)
  833.     end
  834.   end
  835.   #-----------------------------------------------------------------------------
  836.   # * Name      : Belongs To Party?
  837.   #   Info      : Returns true/false if self belongs to Game_Party
  838.   #   Author    : Kain Nobel
  839.   #   Call Info : None
  840.   #-----------------------------------------------------------------------------
  841.   def belongs_to_party?
  842.     return self.belongs_to_unit?(Game_Party.new)
  843.   end
  844.   #-----------------------------------------------------------------------------
  845.   # * Name      : Belongs To Party?
  846.   #   Info      : Returns true/false if self belongs to Game_Troop
  847.   #   Author    : Kain Nobel
  848.   #   Call Info : None
  849.   #-----------------------------------------------------------------------------
  850.   def belongs_to_troop?
  851.     return self.belongs_to_unit?(Game_Troop.new)
  852.   end
  853.   #-----------------------------------------------------------------------------
  854.   # * Name      : Member of Party?
  855.   #   Info      : Returns true/false if Party has battler
  856.   #   Author    : Kain Nobel
  857.   #   Call Info : None
  858.   #-----------------------------------------------------------------------------
  859.   def member_of_party?
  860.     return self.member_of_unit?($game_party) rescue return false
  861.   end
  862.   #-----------------------------------------------------------------------------
  863.   # * Name      : Member of Troop?
  864.   #   Info      : Returns true/false if Troop has battler
  865.   #   Author    : Kain Nobel
  866.   #   Call Info : None
  867.   #-----------------------------------------------------------------------------
  868.   def member_of_troop?
  869.     return self.member_of_unit?($game_troop) rescue return false
  870.   end
  871. end
  872.  
  873.  
  874. #===============================================================================
  875. # ** RGSS.Character
  876. #===============================================================================
  877.  
  878. class Game_Character
  879.   #-----------------------------------------------------------------------------
  880.   # * Name      : XY
  881.   #   Info      : Returns @x and @y properties to array.
  882.   #   Author    : Kain Nobel
  883.   #   Call Info : None
  884.   #-----------------------------------------------------------------------------
  885.   def xy
  886.     return [self.x, self.y]
  887.   end
  888.   #-----------------------------------------------------------------------------
  889.   # * Name      : XYD
  890.   #   Info      : Returns @x, @y and @direction properties to array.
  891.   #   Author    : Kain Nobel
  892.   #   Call Info : None
  893.   #-----------------------------------------------------------------------------
  894.   def xyd
  895.     return [self.x, self.y, self.direction]
  896.   end
  897.   #-----------------------------------------------------------------------------
  898.   # * Name      : Next X
  899.   #   Info      : Returns next X coord for facing direction
  900.   #   Author    : Kain Nobel
  901.   #   Call Info : Direction is the direction character is facing
  902.   #-----------------------------------------------------------------------------
  903.   def next_x(d = self.direction, steps = 1)
  904.     return (self.x + (steps * (d == 6 ? 1 : d == 4 ? -1 : 0)))
  905.   end
  906.   #-----------------------------------------------------------------------------
  907.   # * Name      : Next Y
  908.   #   Info      : Returns next Y coord for facing direction
  909.   #   Author    : Kain Nobel
  910.   #   Call Info : Direction is the direction character is facing
  911.   #-----------------------------------------------------------------------------
  912.   def next_y(d = self.direction, steps = 1)
  913.     return (self.y + (steps * (d == 2 ? 1 : d == 8 ? -1 : 0)))
  914.   end
  915.   #-----------------------------------------------------------------------------
  916.   # * Name      : Next X/Y
  917.   #   Info      : Returns next X & Y coord for facing direction (to an array)
  918.   #   Author    : Kain Nobel
  919.   #   Call Info : Direction is the direction character is facing
  920.   #-----------------------------------------------------------------------------
  921.   def next_xy(d = self.direction, steps = 1)
  922.     return [self.next_x(d, steps), self.next_y(d, steps)]
  923.   end
  924.   #-----------------------------------------------------------------------------
  925.   # * Name      : Events Front
  926.   #   Info      : Returns all events on same tile
  927.   #   Author    : Kain Nobel
  928.   #   Call Info : None
  929.   #-----------------------------------------------------------------------------
  930.   def events_here
  931.     return $game_map.events_at(*self.xy)
  932.   end
  933.   #-----------------------------------------------------------------------------
  934.   # * Name      : Events Front
  935.   #   Info      : Returns all events on tile front
  936.   #   Author    : Kain Nobel
  937.   #   Call Info : None
  938.   #-----------------------------------------------------------------------------
  939.   def events_front
  940.     return $game_map.events_at(*self.xyd)
  941.   end
  942.   #-----------------------------------------------------------------------------
  943.   # * Name      : Events Behind
  944.   #   Info      : Returns all events on tile behind
  945.   #   Author    : Kain Nobel
  946.   #   Call Info : None
  947.   #-----------------------------------------------------------------------------
  948.   def events_behind
  949.     d = case self.direction
  950.     when 2 then 8
  951.     when 4 then 6
  952.     when 6 then 4
  953.     when 8 then 2
  954.     end
  955.     return $game_map.events_at(self.x, self.y, d)
  956.   end
  957.   #-----------------------------------------------------------------------------
  958.   # * Name      : Events Left
  959.   #   Info      : Returns all events on tile to left hand of self
  960.   #   Author    : Kain Nobel
  961.   #   Call Info : None
  962.   #-----------------------------------------------------------------------------
  963.   def events_left
  964.     d = case self.direction
  965.     when 2 then 6
  966.     when 4 then 2
  967.     when 6 then 8
  968.     when 8 then 4
  969.     end
  970.     return $game_map.events_at(self.x, self.y, d)
  971.   end
  972.   #-----------------------------------------------------------------------------
  973.   # * Name      : Events Right
  974.   #   Info      : Returns all events on tile to right hand of self
  975.   #   Author    : Kain Nobel
  976.   #   Call Info : None
  977.   #-----------------------------------------------------------------------------
  978.   def events_right
  979.     d = case self.direction
  980.     when 2 then 4
  981.     when 4 then 8
  982.     when 6 then 2
  983.     when 8 then 6
  984.     end
  985.     return $game_map.events_at(self.x, self.y, d)
  986.   end
  987.   #-----------------------------------------------------------------------------
  988.   # * Name      : This Event
  989.   #   Info      : Returns very first event from 'events_here' or 'event_front'
  990.   #   Author    : Kain Nobel
  991.   #   Call Info : None
  992.   #-----------------------------------------------------------------------------
  993.   def this_event
  994.     return self.event_here unless self.event_here.nil?
  995.     return self.event_front
  996.   end
  997.   #-----------------------------------------------------------------------------
  998.   # * Name      : Event Here
  999.   #   Info      : Returns very first event from 'events_here'
  1000.   #   Author    : Kain Nobel
  1001.   #   Call Info : None
  1002.   #-----------------------------------------------------------------------------
  1003.   def event_here
  1004.     return self.events_here[0]
  1005.   end
  1006.   #-----------------------------------------------------------------------------
  1007.   # * Name      : Event Front
  1008.   #   Info      : Returns very first event from 'events_front'
  1009.   #   Author    : Kain Nobel
  1010.   #   Call Info : None
  1011.   #-----------------------------------------------------------------------------
  1012.   def event_front
  1013.     return self.events_front[0]
  1014.   end
  1015.   #-----------------------------------------------------------------------------
  1016.   # * Name      : Event Behind
  1017.   #   Info      : Returns very first event from 'events_behind'
  1018.   #   Author    : Kain Nobel
  1019.   #   Call Info : None
  1020.   #-----------------------------------------------------------------------------
  1021.   def event_behind
  1022.     return self.events_behind[0]
  1023.   end
  1024.   #-----------------------------------------------------------------------------
  1025.   # * Name      : Event Left
  1026.   #   Info      : Returns very first event from 'events_left'
  1027.   #   Author    : Kain Nobel
  1028.   #   Call Info : None
  1029.   #-----------------------------------------------------------------------------
  1030.   def event_left
  1031.     return self.events_left[0]
  1032.   end
  1033.   #-----------------------------------------------------------------------------
  1034.   # * Name      : Event Right
  1035.   #   Info      : Returns very first event from 'events_right'
  1036.   #   Author    : Kain Nobel
  1037.   #   Call Info : None
  1038.   #-----------------------------------------------------------------------------
  1039.   def event_right
  1040.     return self.events_right[0]
  1041.   end
  1042. end
  1043.  
  1044.  
  1045. #===============================================================================
  1046. # ** RGSS.Enemy and Troop Info
  1047. #===============================================================================
  1048.  
  1049. #===============================================================================
  1050. # ** Game_Troop
  1051. #===============================================================================
  1052.  
  1053. class Game_Troop
  1054.   #-----------------------------------------------------------------------------
  1055.   # * Name      : Members
  1056.   #   Info      : Returns @enemies
  1057.   #   Author    : Kain Nobel
  1058.   #   Call Info : None
  1059.   #-----------------------------------------------------------------------------
  1060.   def members
  1061.     return @enemies
  1062.   end
  1063.   #-----------------------------------------------------------------------------
  1064.   # * Name      : Average
  1065.   #   Info      : Returns average of party's stats, based on parameter
  1066.   #   Author    : Kain Nobel
  1067.   #   Call Info : Parameter is a string representing parameter in question
  1068.   #-----------------------------------------------------------------------------
  1069.   def average(stat)
  1070.     return 0 if self.members.size == 0
  1071.     avg = 0
  1072.     case stat.downcase
  1073.     when 'hp'    ; self.members.each {|m| avg += m.hp}
  1074.     when 'maxhp' ; self.members.each {|m| avg += m.maxhp}
  1075.     when 'sp'    ; self.members.each {|m| avg += m.sp}
  1076.     when 'maxsp' ; self.members.each {|m| avg += m.maxsp}
  1077.     when 'level' ; self.members.each {|m| avg += m.level}
  1078.     when 'exp'   ; self.members.each {|m| avg += m.exp}
  1079.     when 'str'   ; self.members.each {|m| avg += m.str}
  1080.     when 'dex'   ; self.members.each {|m| avg += m.dex}
  1081.     when 'agi'   ; self.members.each {|m| avg += m.agi}
  1082.     when 'int'   ; self.members.each {|m| avg += m.int}
  1083.     when 'atk'   ; self.members.each {|m| avg += m.atk}
  1084.     when 'pdef'  ; self.members.each {|m| avg += m.pdef}
  1085.     when 'mdef'  ; self.members.each {|m| avg += m.mdef}
  1086.     when 'eva'   ; self.members.each {|m| avg += m.eva}
  1087.     end
  1088.     return (avg / self.members.size)
  1089.   end
  1090.   #-----------------------------------------------------------------------------
  1091.   # * Name      : Recover All
  1092.   #   Info      : Recover HP/SP and States
  1093.   #   Author    : Kain Nobel
  1094.   #   Call Info : None
  1095.   #-----------------------------------------------------------------------------
  1096.   def recover_all
  1097.     self.members.each {|m| m.recover_all}
  1098.   end
  1099.   #-----------------------------------------------------------------------------
  1100.   # * Name      : Revive All
  1101.   #   Info      : Revive all enemies with percent/direct ammount of HP
  1102.   #   Author    : Kain Nobel
  1103.   #   Call Info : None
  1104.   #-----------------------------------------------------------------------------
  1105.   def revive_all(direct = 0, percent = 0)
  1106.     self.members.each {|m|
  1107.     unless m.hp > 0
  1108.       m.hp += Integer(direct * (percent / 100.0))
  1109.     end}
  1110.   end
  1111.   #-----------------------------------------------------------------------------
  1112.   # * Name      : Kill All
  1113.   #   Info      : Kill all enemies instantly
  1114.   #   Author    : Kain Nobel
  1115.   #   Call Info : None
  1116.   #-----------------------------------------------------------------------------
  1117.   def kill_all
  1118.     self.members.each {|m| m.hp = 0}
  1119.   end
  1120.   #-----------------------------------------------------------------------------
  1121.   # * Name      : Add State
  1122.   #   Info      : Inflicts all enemies with designated state
  1123.   #   Author    : Kain Nobel
  1124.   #   Call Info : State ID - Integer representing State's ID in database
  1125.   #-----------------------------------------------------------------------------
  1126.   def add_state(state_id)
  1127.     self.members.each {|m| m.add_state(state_id)}
  1128.   end
  1129.   #-----------------------------------------------------------------------------
  1130.   # * Name      : Remove State
  1131.   #   Info      : Removes designated State from all enemies
  1132.   #   Author    : Kain Nobel
  1133.   #   Call Info : State ID - Integer representing State's ID in database
  1134.   #-----------------------------------------------------------------------------
  1135.   def remove_state(state_id)
  1136.     self.members.each {|m| m.remove_state(state_id)}
  1137.   end
  1138.   #-----------------------------------------------------------------------------
  1139.   # * Name      : Add States
  1140.   #   Info      : Inflicst all enemies with an array of states
  1141.   #   Author    : Kain Nobel
  1142.   #   Call Info : States - Array with State IDs to be added
  1143.   #-----------------------------------------------------------------------------
  1144.   def add_states(states = [])
  1145.     states.compact!
  1146.     states.each {|state| self.add_state(state)}
  1147.   end
  1148.   #-----------------------------------------------------------------------------
  1149.   # * Name      : Remove States
  1150.   #   Info      : Removes an array of states from all enemies
  1151.   #   Author    : Kain Nobel
  1152.   #   Call Info : States - Array of State IDs to be removed
  1153.   #-----------------------------------------------------------------------------
  1154.   def remove_states(states = [])
  1155.     states.compact!
  1156.     states.each {|state| self.remove_state(state)}
  1157.   end
  1158.   #-----------------------------------------------------------------------------
  1159.   # * Name      : Change States
  1160.   #   Info      : Compresses 'add_states' and 'remove_states'
  1161.   #   Author    : Kain Nobel
  1162.   #   Call Info : States - Array of State IDs to be added/removed
  1163.   #                 State IDs must be positive to be added
  1164.   #                 State IDs must be negative to be removed
  1165.   #               States can also be a Hash with (State ID => true/false)
  1166.   #                 If State ID points to True  : it will be added
  1167.   #                 If State ID points to False : it will be removed
  1168.   #-----------------------------------------------------------------------------
  1169.   def change_states(states = [])
  1170.     add, rem = Array.new, Array.new
  1171.     if states.is_a?(Array)
  1172.       states.each do |id|
  1173.         add << id if id > 0
  1174.         rem << -id if id < 0
  1175.       end
  1176.     elsif states.is_a?(Hash)
  1177.       states.each_key do |key|
  1178.         add << key if states[key] == true
  1179.         rem << key if states[key] == false
  1180.       end
  1181.     end
  1182.     self.add_states(add)
  1183.     self.remove_states(rem)
  1184.   end
  1185. end
  1186.  
  1187.  
  1188. #===============================================================================
  1189. # ** RGSS.Map
  1190. #-------------------------------------------------------------------------------
  1191. # Methods List
  1192. # ------------
  1193. #
  1194. # this_event
  1195. # event_count
  1196. # exists?
  1197. # map_infos
  1198. # map_count
  1199. # map_name
  1200. # parent_id
  1201. # parent_name
  1202. # print_list
  1203. #===============================================================================
  1204. #-------------------------------------------------------------------------------
  1205. # * MACL Loading
  1206. #-------------------------------------------------------------------------------
  1207. if Object.const_defined?(:MACL)
  1208.   MACL::Loaded << 'RGSS.Map'
  1209. end
  1210. #===============================================================================
  1211. # ** Game_Map
  1212. #===============================================================================
  1213.  
  1214. class Game_Map
  1215.   #-----------------------------------------------------------------------------
  1216.   # * Name      : Events At
  1217.   #   Info      : Returns an array of events at location
  1218.   #   Author    : Kain Nobel
  1219.   #   Call Info : Two Arguments Integer X, Y - Position to Check
  1220.   #               D (Optional) Integer - Directional modifier to check
  1221.   #-----------------------------------------------------------------------------
  1222.   def events_at(x, y, d = 0, attr = nil)
  1223.     events = Array.new
  1224.     x += (d == 6 ? 1 : d == 4 ? -1 : 0)
  1225.     y += (d == 2 ? 1 : d == 8 ? -1 : 0)
  1226.     @events.each_value {|event|
  1227.     if event.x == x && event.y == y
  1228.       eval "events << (attr.nil? ? event : event.#{attr})"
  1229.     end}
  1230.     return events
  1231.   end
  1232.   #-----------------------------------------------------------------------------
  1233.   # * Name      : Event At
  1234.   #   Info      : Returns very first event from events_at method.
  1235.   #   Author    : SephirothSpawn / Kain Nobel
  1236.   #   Call Info : Two Arguments Integer X, Y - Position to Check
  1237.   #               D (Optional) Integer - Directional modifier to check
  1238.   #-----------------------------------------------------------------------------
  1239.   def event_at(x, y, d = 0, attr = nil)
  1240.     return events_at(x, y, d, attr)[0]
  1241.   end
  1242.   #-----------------------------------------------------------------------------
  1243.   # * Name      : Characters At
  1244.   #   Info      : Returns an array of characters at location
  1245.   #   Author    : Kain Nobel
  1246.   #   Call Info : Two Arguments Integer X, Y - Position to Check
  1247.   #               D (Optional) Integer - Directional modifier to check
  1248.   #-----------------------------------------------------------------------------
  1249.   def characters_at(x, y, d = 0, attr = nil)
  1250.     characters = Array.new
  1251.     x += (d == 6 ? 1 : d == 4 ? -1 : 0)
  1252.     y += (d == 2 ? 1 : d == 8 ? -1 : 0)
  1253.     @characters.each_value {|character|
  1254.     if character.x == x && character.y == y
  1255.       eval "characters << (attr.nil? ? character : character.#{attr})"
  1256.     end}
  1257.     return characters
  1258.   end
  1259.   #-----------------------------------------------------------------------------
  1260.   # * Name      : Character At
  1261.   #   Info      : Returns very first character from characters_at method.
  1262.   #   Author    : SephirothSpawn / Kain Nobel
  1263.   #   Call Info : Two Arguments Integer X, Y - Position to Check
  1264.   #               D (Optional) Integer - Directional modifier to check
  1265.   #-----------------------------------------------------------------------------
  1266.   def character_at(x, y, d = 0, attr = nil)
  1267.     return characters_at(x, y, d, attr)[0]
  1268.   end
  1269.   #-----------------------------------------------------------------------------
  1270.   # * Name      : This Event
  1271.   #   Info      : Finds the first event directly in front of $game_player
  1272.   #   Author    : Kain Nobel
  1273.   #   Call Info : None, returns event here or event in front or nil if no event
  1274.   #-----------------------------------------------------------------------------
  1275.   def this_event
  1276.     return $game_player.this_event
  1277.   end
  1278.   #-----------------------------------------------------------------------------
  1279.   # * Name      : Event Count
  1280.   #   Info      : Simply counts how many events are on the $game_map
  1281.   #   Author    : Kain Nobel
  1282.   #   Call Info : None, returns number of events on map
  1283.   #-----------------------------------------------------------------------------
  1284.   def event_count
  1285.     return @events.empty? ? 0 : @events.size
  1286.   end
  1287.   #-----------------------------------------------------------------------------
  1288.   # * Name      : Exists?
  1289.   #   Info      : Tests to see if Map exists
  1290.   #   Author    : Kain Nobel
  1291.   #   Call Info : Map ID is the Map in question
  1292.   #-----------------------------------------------------------------------------
  1293.   def exists?(map_id)
  1294.     return FileTest.exist?(sprintf("Data/Map%03d.rxdata", map_id))
  1295.   end
  1296.   #-----------------------------------------------------------------------------
  1297.   # * Name      : Map Infos
  1298.   #   Info      : Returns "Data/MapInfos.rxdata"
  1299.   #   Author    : Kain Nobel
  1300.   #   Call Info : Miscellaneous
  1301.   #-----------------------------------------------------------------------------
  1302.   def map_infos
  1303.     @map_infos ||= load_data("Data/MapInfos.rxdata")
  1304.     return @map_infos
  1305.   end
  1306.   #-----------------------------------------------------------------------------
  1307.   # * Name      : Map Count
  1308.   #   Info      : Returns number of valid Map filenames
  1309.   #   Author    : Kain Nobel
  1310.   #   Call Info : None, returns number of maps in project folder
  1311.   #-----------------------------------------------------------------------------
  1312.   def map_count
  1313.     return map_infos.keys.size
  1314.   end
  1315.   #-----------------------------------------------------------------------------
  1316.   # * Name      : Map Name
  1317.   #   Info      : Sends name of the map in question to a string
  1318.   #   Author    : Kain Nobel
  1319.   #   Call Info : Map ID (Optional) returns specified Map ID's name
  1320.   #-----------------------------------------------------------------------------
  1321.   def map_name(map_id = @map_id)
  1322.     begin ; return map_infos[map_id].name
  1323.     rescue ; return ""
  1324.     end
  1325.   end
  1326.   #-----------------------------------------------------------------------------
  1327.   # * Name      : Parent ID
  1328.   #   Info      : Returns ID of parent map
  1329.   #   Author    : Kain Nobel
  1330.   #   Call Info : Map ID (Optional) returns specified Map ID's parent Map ID
  1331.   #-----------------------------------------------------------------------------
  1332.   def parent_id(map_id = @map_id)
  1333.     begin  ; return map_infos[map_id].parent_id
  1334.     rescue ; return 0
  1335.     end
  1336.   end
  1337.   #-----------------------------------------------------------------------------
  1338.   # * Name      : Parent Name
  1339.   #   Info      : Sends name of the parent map in question to a string
  1340.   #   Author    : Kain Nobel
  1341.   #   Call Info : Map ID (Optional) returns specified Map ID's parent's name
  1342.   #-----------------------------------------------------------------------------
  1343.   def parent_name
  1344.     begin ; return map_name(parent_id)
  1345.     rescue ; return ""
  1346.     end
  1347.   end
  1348.   #-----------------------------------------------------------------------------
  1349.   # * Name      : Print List
  1350.   #   Info      : Prints an Event's Command List in a human readable format
  1351.   #   Author    : Kain Nobel
  1352.   #   Call Info : Event ID, the event whom's list shall be printed
  1353.   #-----------------------------------------------------------------------------
  1354.   def print_list(event_id)
  1355.     list = String.new
  1356.     unless $game_map.events[event_id].nil?
  1357.       for c in $game_map.events[event_id].list
  1358.         code = c.code.to_s
  1359.         code.gsub!("101", "Show Text")
  1360.         code.gsub!("102", "Show Choices")
  1361.         code.gsub!("401", "" * c.indent)
  1362.         code.gsub!("402", "When [**]")
  1363.         code.gsub!("403", "When Cancel")
  1364.         code.gsub!("103", "Input Number")
  1365.         code.gsub!("104", "Change Text Options")
  1366.         code.gsub!("105", "Button Input Processing")
  1367.         code.gsub!("106", "Wait")
  1368.         code.gsub!("111", "Conditional Branch")
  1369.         code.gsub!("411", "Else")
  1370.         code.gsub!("412", "Branch End")
  1371.         code.gsub!("112", "Loop")
  1372.         code.gsub!("413", "Repeat Above")
  1373.         code.gsub!("113", "Break Loop")
  1374.         code.gsub!("115", "Exit Event Processing")
  1375.         code.gsub!("116", "Erase Event")
  1376.         code.gsub!("117", "Call Common Event")
  1377.         code.gsub!("118", "Label")
  1378.         code.gsub!("119", "Jump to Label")
  1379.         code.gsub!("121", "Control Switches")
  1380.         code.gsub!("122", "Control Variables")
  1381.         code.gsub!("123", "Control Self Switch")
  1382.         code.gsub!("124", "Control Timer")
  1383.         code.gsub!("125", "Change Gold")
  1384.         code.gsub!("126", "Change Items")
  1385.         code.gsub!("127", "Change Weapons")
  1386.         code.gsub!("128", "Change Armor")
  1387.         code.gsub!("129", "Change Party Member")
  1388.         code.gsub!("131", "Change Windowskin")
  1389.         code.gsub!("132", "Change Battle BGM")
  1390.         code.gsub!("133", "Change Battle End ME")
  1391.         code.gsub!("134", "Change Save Access")
  1392.         code.gsub!("135", "Change Menu Access")
  1393.         code.gsub!("136", "Change Encounter")
  1394.         code.gsub!("201", "Transfer Player")
  1395.         code.gsub!("202", "Set Event Location")
  1396.         code.gsub!("203", "Scroll Map")
  1397.         code.gsub!("204", "Change Map Settings")
  1398.         code.gsub!("205", "Change Fog Color Tone")
  1399.         code.gsub!("206", "Change Fog Opacity")
  1400.         code.gsub!("207", "Show Animation")
  1401.         code.gsub!("208", "Change Transparent Flag")
  1402.         code.gsub!("209", "Set Move Route")
  1403.         code.gsub!("210", "Wait for Move's Completion")
  1404.         code.gsub!("221", "Prepare for Transition")
  1405.         code.gsub!("222", "Execute Transition")
  1406.         code.gsub!("223", "Change Screen Color Tone")
  1407.         code.gsub!("224", "Screen Flash")
  1408.         code.gsub!("225", "Screen Shake")
  1409.         code.gsub!("231", "Show Picture")
  1410.         code.gsub!("232", "Move Picture")
  1411.         code.gsub!("233", "Rotate Picture")
  1412.         code.gsub!("234", "Change Picture Color Tone")
  1413.         code.gsub!("235", "Erase Picture")
  1414.         code.gsub!("236", "Set Weather Effects")
  1415.         code.gsub!("241", "Play BGM")
  1416.         code.gsub!("242", "Fade Out BGM")
  1417.         code.gsub!("245", "Play BGS")
  1418.         code.gsub!("246", "Fade Out BGS")
  1419.         code.gsub!("247", "Memorize BGM/BGS")
  1420.         code.gsub!("248", "Restore BGM/BGS")
  1421.         code.gsub!("249", "Play ME")
  1422.         code.gsub!("250", "Play SE")
  1423.         code.gsub!("251", "Stop SE")
  1424.         code.gsub!("301", "Battle Processing")
  1425.         code.gsub!("601", "If Win")
  1426.         code.gsub!("602", "If Escape")
  1427.         code.gsub!("603", "If Lose")
  1428.         code.gsub!("302", "Shop Processing")
  1429.         code.gsub!("303", "Name Input Processing")
  1430.         code.gsub!("311", "Change HP")
  1431.         code.gsub!("312", "Change SP")
  1432.         code.gsub!("313", "Change State")
  1433.         code.gsub!("314", "Recover All")
  1434.         code.gsub!("315", "Change EXP")
  1435.         code.gsub!("316", "Change Level")
  1436.         code.gsub!("317", "Change Parameters")
  1437.         code.gsub!("318", "Change Skills")
  1438.         code.gsub!("319", "Change Equipment")
  1439.         code.gsub!("320", "Change Actor Name")
  1440.         code.gsub!("321", "Change Actor Class")
  1441.         code.gsub!("322", "Change Actor Graphic")
  1442.         code.gsub!("331", "Change Enemy HP")
  1443.         code.gsub!("332", "Change Enemy SP")
  1444.         code.gsub!("333", "Change Enemy State")
  1445.         code.gsub!("334", "Enemy Recover All")
  1446.         code.gsub!("335", "Enemy Appearance")
  1447.         code.gsub!("336", "Enemy Transform")
  1448.         code.gsub!("337", "Show Battle Animation")
  1449.         code.gsub!("338", "Deal Damage")
  1450.         code.gsub!("339", "Force Action")
  1451.         code.gsub!("340", "Abort Battle")
  1452.         code.gsub!("351", "Call Menu Screen")
  1453.         code.gsub!("352", "Call Save Screen")
  1454.         code.gsub!("353", "Game Over")
  1455.         code.gsub!("354", "Return to Title Screen")
  1456.         code.gsub!("355", "Script")
  1457.         code.gsub!("0",   "")
  1458.         code = ("  " * c.indent) + "@>#{code}:#{c.parameters}\n"
  1459.         list += code
  1460.       end
  1461.     end
  1462.     print list
  1463.   end
  1464. end
  1465.  
  1466.  
  1467. #===============================================================================
  1468. # ** RGSS.RPG::Cache
  1469. #===============================================================================
  1470.  
  1471. class << RPG::Cache
  1472.   #-----------------------------------------------------------------------------
  1473.   # * Alias Listings
  1474.   #-----------------------------------------------------------------------------
  1475.   unless self.method_defined?(:knmacl_rpgcache_clear)
  1476.     alias_method :knmacl_rpgcache_clear, :clear
  1477.   end
  1478.   #-----------------------------------------------------------------------------
  1479.   # * Name      : Clear
  1480.   #   Info      : Clears keys similiar to the specified key
  1481.   #   Author    : Kain Nobel
  1482.   #   Call Info : Key (optional) is a string representing what kind of objects
  1483.   #                 to delete. For instance "Fog" remove any objects with keys
  1484.   #                 that include the word "Fog" in it. If no key is omitted,
  1485.   #                 the entire @cache is cleared.
  1486.   #-----------------------------------------------------------------------------
  1487.   def self.clear(key = nil)
  1488.     if key.nil?
  1489.       knmacl_rpgcache_clear
  1490.       return
  1491.     end
  1492.     @cache.each_key do |key|
  1493.       if key.is_a?(String) && key.include?(key)
  1494.         @cache.delete(key)
  1495.       end
  1496.     end
  1497.   end
  1498. end
  1499.  
  1500.  
  1501. #===============================================================================
  1502. # ** RGSS.RPG::Item
  1503. #===============================================================================
  1504.  
  1505. class RPG::Item
  1506.   #-----------------------------------------------------------------------------
  1507.   # * Name      : HP Neutral?
  1508.   #   Info      : Returns Recover HP and Recover HP Rate is 0
  1509.   #   Author    : Kain Nobel
  1510.   #   Call Info : None
  1511.   #-----------------------------------------------------------------------------
  1512.   def hp_neutral?
  1513.     return @recover_hp == 0 && @recover_hp_rate == 0
  1514.   end
  1515.   #-----------------------------------------------------------------------------
  1516.   # * Name      : HP Recovery?
  1517.   #   Info      : Returns Recover HP and Recover HP Rate more than 0
  1518.   #   Author    : Kain Nobel
  1519.   #   Call Info : None
  1520.   #-----------------------------------------------------------------------------
  1521.   def hp_recovery?
  1522.     return @recover_hp > 0 && @recover_hp_rate > 0
  1523.   end
  1524.   #-----------------------------------------------------------------------------
  1525.   # * Name      : HP Damage?
  1526.   #   Info      : Returns Recover HP and Recover HP Rate less than 0
  1527.   #   Author    : Kain Nobel
  1528.   #   Call Info : None
  1529.   #-----------------------------------------------------------------------------
  1530.   def hp_damage?
  1531.     return @recover_hp < 0 && @recover_hp_rate < 0
  1532.   end
  1533.   #-----------------------------------------------------------------------------
  1534.   # * Name      : SP Neutral?
  1535.   #   Info      : Returns Recover SP and Recover SP Rate is 0
  1536.   #   Author    : Kain Nobel
  1537.   #   Call Info : None
  1538.   #-----------------------------------------------------------------------------
  1539.   def sp_neutral?
  1540.     return @recover_sp == 0 && @recover_sp_rate == 0
  1541.   end
  1542.   #-----------------------------------------------------------------------------
  1543.   # * Name      : SP Recovery?
  1544.   #   Info      : Returns Recover SP and Recover SP Rate more than 0
  1545.   #   Author    : Kain Nobel
  1546.   #   Call Info : None
  1547.   #-----------------------------------------------------------------------------
  1548.   def sp_recovery?
  1549.     return @recover_sp > 0 && @recover_sp_rate > 0
  1550.   end
  1551.   #-----------------------------------------------------------------------------
  1552.   # * Name      : SP Damage?
  1553.   #   Info      : Returns Recover SP and Recover SP Rate less than 0
  1554.   #   Author    : Kain Nobel
  1555.   #   Call Info : None
  1556.   #-----------------------------------------------------------------------------
  1557.   def sp_damage?
  1558.     return @recover_sp < 0 && @recover_sp_rate < 0
  1559.   end
  1560.   #-----------------------------------------------------------------------------
  1561.   # * Name      : Is Item?
  1562.   #   Info      : Returns true
  1563.   #   Author    : Kain Nobel
  1564.   #   Call Info : None
  1565.   #-----------------------------------------------------------------------------
  1566.   def is_item?
  1567.     return true
  1568.   end
  1569.   #-----------------------------------------------------------------------------
  1570.   # * Name      : Is Armor?
  1571.   #   Info      : Returns false
  1572.   #   Author    : Kain Nobel
  1573.   #   Call Info : None
  1574.   #-----------------------------------------------------------------------------
  1575.   def is_armor?
  1576.     return false
  1577.   end
  1578.   #-----------------------------------------------------------------------------
  1579.   # * Name      : Is Weapon?
  1580.   #   Info      : Returns false
  1581.   #   Author    : Kain Nobel
  1582.   #   Call Info : None
  1583.   #-----------------------------------------------------------------------------
  1584.   def is_weapon?
  1585.     return false
  1586.   end
  1587.   #-----------------------------------------------------------------------------
  1588.   # * Name      : Is Skill?
  1589.   #   Info      : Returns false
  1590.   #   Author    : Kain Nobel
  1591.   #   Call Info : None
  1592.   #-----------------------------------------------------------------------------
  1593.   def is_skill?
  1594.     return false
  1595.   end
  1596.   #-----------------------------------------------------------------------------
  1597.   # * Name      : Party Quant
  1598.   #   Info      : Returns how many of self is in $game_party.items
  1599.   #   Author    : Kain Nobel
  1600.   #   Call Info : None
  1601.   #-----------------------------------------------------------------------------
  1602.   def party_quant
  1603.     return 0 if $game_party.nil?
  1604.     unless $game_party.items.has_key?(@id)
  1605.       return 0
  1606.     end
  1607.     return $game_party.items[@id]
  1608.   end
  1609.   #-----------------------------------------------------------------------------
  1610.   # * Name      : Has Element?
  1611.   #   Info      : Returns if @element_set includes element
  1612.   #   Author    : Kain Nobel
  1613.   #   Call Info : Element is Integer representing Element Tag ID in question
  1614.   #-----------------------------------------------------------------------------
  1615.   def has_element?(id = 0)
  1616.     return true if id == 0
  1617.     return @element_set.include?(id)
  1618.   end
  1619.   #-----------------------------------------------------------------------------
  1620.   # * Name      : Has Element?
  1621.   #   Info      : Returns an array of elements from 'has_element?'
  1622.   #   Author    : Kain Nobel
  1623.   #   Call Info : Elements is an Array - See 'has_element?'
  1624.   #-----------------------------------------------------------------------------
  1625.   def has_elements?(elements = [])
  1626.     list = Array.new
  1627.     elements.each {|e| list << e if self.has_element?(e)}
  1628.     return list
  1629.   end
  1630. end
  1631.  
  1632.  
  1633. #===============================================================================
  1634. # ** RGSS.RPG::Armor
  1635. #===============================================================================
  1636.  
  1637. class RPG::Armor
  1638.   #-----------------------------------------------------------------------------
  1639.   # * Name      : Is Item?
  1640.   #   Info      : Returns false
  1641.   #   Author    : Kain Nobel
  1642.   #   Call Info : None
  1643.   #-----------------------------------------------------------------------------
  1644.   def is_item?
  1645.     return false
  1646.   end
  1647.   #-----------------------------------------------------------------------------
  1648.   # * Name      : Is Armor?
  1649.   #   Info      : Returns true
  1650.   #   Author    : Kain Nobel
  1651.   #   Call Info : None
  1652.   #-----------------------------------------------------------------------------
  1653.   def is_armor?
  1654.     return true
  1655.   end
  1656.   #-----------------------------------------------------------------------------
  1657.   # * Name      : Is Weapon?
  1658.   #   Info      : Returns false
  1659.   #   Author    : Kain Nobel
  1660.   #   Call Info : None
  1661.   #-----------------------------------------------------------------------------
  1662.   def is_weapon?
  1663.     return false
  1664.   end
  1665.   #-----------------------------------------------------------------------------
  1666.   # * Name      : Is Skill?
  1667.   #   Info      : Returns false
  1668.   #   Author    : Kain Nobel
  1669.   #   Call Info : None
  1670.   #-----------------------------------------------------------------------------
  1671.   def is_skill?
  1672.     return false
  1673.   end
  1674.   #-----------------------------------------------------------------------------
  1675.   # * Name      : Party Quant
  1676.   #   Info      : Returns how many of self is in $game_party.armors
  1677.   #   Author    : Kain Nobel
  1678.   #   Call Info : None
  1679.   #-----------------------------------------------------------------------------
  1680.   def party_quant
  1681.     return 0 if $game_party.nil?
  1682.     unless $game_party.armors.has_key?(@id)
  1683.       return 0
  1684.     end
  1685.     return $game_party.armors[@id]
  1686.   end
  1687.   #-----------------------------------------------------------------------------
  1688.   # * Has Element? (ID)
  1689.   #-----------------------------------------------------------------------------
  1690.   def has_element?(id = 0)
  1691.     return true if id == 0
  1692.     return @guard_element_set.include?(id)
  1693.   end
  1694.   #-----------------------------------------------------------------------------
  1695.   # * Name      : Has Element?
  1696.   #   Info      : Returns if @guard_element_set includes element
  1697.   #   Author    : Kain Nobel
  1698.   #   Call Info : Element is Integer representing Element Tag ID in question
  1699.   #-----------------------------------------------------------------------------
  1700.   def has_element?(id = 0)
  1701.     return true if id == 0
  1702.     return @guard_element_set.include?(id)
  1703.   end
  1704.   #-----------------------------------------------------------------------------
  1705.   # * Name      : Has Element?
  1706.   #   Info      : Returns an array of elements from 'has_element?'
  1707.   #   Author    : Kain Nobel
  1708.   #   Call Info : Elements is an Array - See 'has_element?'
  1709.   #-----------------------------------------------------------------------------
  1710.   def has_elements?(elements = [])
  1711.     list = Array.new
  1712.     elements.each {|e| list << e if self.has_element?(e)}
  1713.     return list
  1714.   end
  1715. end
  1716.  
  1717.  
  1718. #===============================================================================
  1719. # ** RGSS.RPG::Weapon
  1720. #===============================================================================
  1721.  
  1722. class RPG::Weapon
  1723.   #-----------------------------------------------------------------------------
  1724.   # * Name      : Is Item?
  1725.   #   Info      : Returns false
  1726.   #   Author    : Kain Nobel
  1727.   #   Call Info : None
  1728.   #-----------------------------------------------------------------------------
  1729.   def is_item?
  1730.     return false
  1731.   end
  1732.   #-----------------------------------------------------------------------------
  1733.   # * Name      : Is Armor?
  1734.   #   Info      : Returns false
  1735.   #   Author    : Kain Nobel
  1736.   #   Call Info : None
  1737.   #-----------------------------------------------------------------------------
  1738.   def is_armor?
  1739.     return false
  1740.   end
  1741.   #-----------------------------------------------------------------------------
  1742.   # * Name      : Is Weapon?
  1743.   #   Info      : Returns true
  1744.   #   Author    : Kain Nobel
  1745.   #   Call Info : None
  1746.   #-----------------------------------------------------------------------------
  1747.   def is_weapon?
  1748.     return true
  1749.   end
  1750.   #-----------------------------------------------------------------------------
  1751.   # * Name      : Is Skill?
  1752.   #   Info      : Returns false
  1753.   #   Author    : Kain Nobel
  1754.   #   Call Info : None
  1755.   #-----------------------------------------------------------------------------
  1756.   def is_skill?
  1757.     return false
  1758.   end
  1759.   #-----------------------------------------------------------------------------
  1760.   # * Name      : Party Quant
  1761.   #   Info      : Returns how many of self is in $game_party.weapons
  1762.   #   Author    : Kain Nobel
  1763.   #   Call Info : None
  1764.   #-----------------------------------------------------------------------------
  1765.   def party_quant
  1766.     return 0 if $game_party.nil?
  1767.     unless $game_party.weapons.has_key?(@id)
  1768.       return 0
  1769.     end
  1770.     return $game_party.weapons[@id]
  1771.   end
  1772.   #-----------------------------------------------------------------------------
  1773.   # * Name      : Has Element?
  1774.   #   Info      : Returns if @element_set includes element
  1775.   #   Author    : Kain Nobel
  1776.   #   Call Info : Element is Integer representing Element Tag ID in question
  1777.   #-----------------------------------------------------------------------------
  1778.   def has_element?(id = 0)
  1779.     return true if id == 0
  1780.     return @element_set.include?(id)
  1781.   end
  1782.   #-----------------------------------------------------------------------------
  1783.   # * Name      : Has Element?
  1784.   #   Info      : Returns an array of elements from 'has_element?'
  1785.   #   Author    : Kain Nobel
  1786.   #   Call Info : Elements is an Array - See 'has_element?'
  1787.   #-----------------------------------------------------------------------------
  1788.   def has_elements?(elements = [])
  1789.     list = Array.new
  1790.     elements.each {|e| list << e if self.has_element?(e)}
  1791.     return list
  1792.   end
  1793. end
  1794.  
  1795.  
  1796. #===============================================================================
  1797. # ** RGSS.RPG::Skill
  1798. #===============================================================================
  1799.  
  1800. class RPG::Skill
  1801.   #-----------------------------------------------------------------------------
  1802.   # * Name      : Has Element?
  1803.   #   Info      : Returns if @element_set includes element
  1804.   #   Author    : Kain Nobel
  1805.   #   Call Info : Element is Integer representing Element Tag ID in question
  1806.   #-----------------------------------------------------------------------------
  1807.   def has_element?(id = 0)
  1808.     return true if id == 0
  1809.     return @element_set.include?(id)
  1810.   end
  1811.   #-----------------------------------------------------------------------------
  1812.   # * Name      : Has Element?
  1813.   #   Info      : Returns an array of elements from 'has_element?'
  1814.   #   Author    : Kain Nobel
  1815.   #   Call Info : Elements is an Array - See 'has_element?'
  1816.   #-----------------------------------------------------------------------------
  1817.   def has_elements?(elements = [])
  1818.     list = Array.new
  1819.     elements.each {|e| list << e if self.has_element?(e)}
  1820.     return list
  1821.   end
  1822. end
clone this paste RAW Paste Data