CyberForte

DoW Reproduce

Oct 10th, 2017
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 41.71 KB | None | 0 0
  1. #_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
  2. #_/ ◆ Restored Combat Functions - KGC_ReproduceFunctions ◆ VX ◆
  3. #_/ ◇  Last Update: 01/18/2009
  4. #_/ ◆ Written by TOMY    
  5. #_/ ◆ Translation by Mr. Anonymous                  
  6. #_/ ◆ KGC Site:                                                  
  7. #_/ ◆  http://ytomy.sakura.ne.jp/                                  
  8. #_/ ◆ Translator's Blog:                                            
  9. #_/ ◆  http://mraprojects.wordpress.com    
  10. #_/----------------------------------------------------------------------------
  11. #_/  This script restores some lost combat functionality since the release of  
  12. #_/  RPG Maker VX. These functions were in RPG Maker 2000, 2003, and XP.      
  13. #_/============================================================================
  14. #_/                  ◆ Instructions For Usage ◆
  15. #_/  To make use of these functions, you must insert the desired tag into the
  16. #_/   "Notes" box located in the appropriate section of the database. For
  17. #_/   example, you want a Great Sword to inflict damage to all enemies on-screen
  18. #_/   during combat, you would locate Great Sword in the weapons tab of the
  19. #_/   database and insert "<target all>" (without quotations) in the note box.
  20. #_/   Simple, no?
  21. #_/
  22. #_/  Key: n = Number
  23. #_/       SkillID = The ID number of the desired skill in the skills database
  24. #_/       StateID = The ID number of the desired state in the state database
  25. #_/
  26. #_/   This may be obvious, but to the right of the tag inside the brackets
  27. #_/    is either a number or the word StateID/SkillID. Replace these with the
  28. #_/    desired value.
  29. #_/  
  30. #_/                  ◆ Restored Combat Functions ◆
  31. #_/
  32. #_/                       ◆ Skill Related ◆
  33. #_/  <minimum_atk n>
  34. #_/  Assigns a minimum requirement of a designated amount of Attack to a skill.
  35. #_/  (Ex. <minimum_atk 80>)
  36. #_/  
  37. #_/  <minimum_spi n>
  38. #_/  Assigns a minimum requirement of a designated amount of Spirit to a skill.
  39. #_/  (Ex. <minimum_spi 40>)
  40. #_/
  41. #_/                        ◆ Item Related ◆
  42. #_/  <multi_use n>
  43. #_/  Sets an item to be used a specified amount of times.
  44. #_/  (Ex. <multi_use 5>)
  45. #_/  
  46. #_/  <exec_skill SkillID>
  47. #_/  Allows you to set an item to force the character to use a specified skill.
  48. #_/  (Ex. <exec_skill 7>)
  49. #_/
  50. #_/                       ◆ Equipment Related ◆
  51. #_/  <auto_state ID>
  52. #_/  Automatically adds the indictacted state to the equipped character.
  53. #_/  These can be assigned in multiples. (Ex. <auto_state 1,2,3>)
  54. #_/
  55. #_/  <target_all>
  56. #_/  Treats basic attack made by the equipped character as Target: All
  57. #_/
  58. #_/  <ignore_eva>
  59. #_/  Attacks made by equipped character ignore the target's evasion ratio.
  60. #_/
  61. #_/  <mp_cost n>
  62. #_/  Sets a weapon to consume a specified amount of MP each time it is used.
  63. #_/  (Ex. <mp_cost 10>)
  64. #_/  
  65. #_/  <critical n>
  66. #_/  Increase the critical ratio of the equipped character by a specified amount
  67. #_/   in percentage. (Ex. <critical 20>)
  68. #_/
  69. #_/                         ◆ Enemy Related ◆
  70. #_/  <translucent>
  71. #_/  Makes an enemy semi-transparent.
  72. #_/  
  73. #_/  <critical n>
  74. #_/  Increase the critical ratio of an enemy by a specified amount in percentage
  75. #_/  (Ex. <critical 30>)
  76. #_/
  77. #_/                         ◆ State Related ◆
  78. #_/  <maxmp_rate n%>
  79. #_/  Increase the maximum hitpoints by a specified amount in percentage.
  80. #_/  (Ex. <maxhp_rate 150%>)
  81. #_/  
  82. #_/  <maxmp_rate n%>
  83. #_/  Increase the maximum magic points by a specified amount in percentage.
  84. #_/  (Ex. <maxmp_rate 150%>)
  85. #_/  
  86. #_/  <plus_state StateID>
  87. #_/  Adds additional state(s) affects to a designated state. These can be
  88. #_/   assigned in multiples (Ex. <plus_state 1,2,3>).
  89. #_/  
  90. #_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
  91.  
  92. #=============================================================================#
  93. #                           ★ Customization ★                                 #
  94. #=============================================================================#
  95.  
  96. module KGC
  97.   module ReproduceFunctions
  98.   #  If a weapon is set to cost MP when used, this toggle will show the amount
  99.   #   of MP when used if set to true.
  100.   SHOW_WEAPON_MP_COST_ON_ATTACK = true
  101.  
  102.   #                   ★ Weapon Attributes Assignment ★
  103.   #  If the equipped weapon has the same attribute(s) as the skill being
  104.   #   then that skill is usable. If the attributes are different, then the skill
  105.   #   is unusable. These attributes are the same as the first six elements in
  106.   #   the database.
  107.   #
  108.   #  If you have more attributes you'd like to assign for weapon types, you
  109.   #  may assign them in the box below.
  110.   # For example, let's say you have an element labeled "Bullet" on ElementID 14
  111.   #  You'd then enter WEAPON_ELEMENTS = [1..6, 14] (assuming the first six are
  112.   #                                                               weapon types)
  113.   WEAPON_ELEMENTS = [1..6]
  114.   # Attributes may be written as an array or abbreviated arrays.
  115.   #   Ex. [1..6] Which begins at 1 and counts each number to six.
  116.   # [1..6] is the same as [1, 2, 3, 4, 5, 6]
  117.   # [1..4, 5, 6] is also the same as the above.
  118.   end
  119. end
  120.  
  121. #=============================================================================#
  122. #                          ★ End Customization ★                              #
  123. #=============================================================================#
  124.  
  125. $imported = {} if $imported == nil
  126. $imported["ReproduceFunctions"] = true
  127.  
  128. module KGC::ReproduceFunctions
  129.   #--------------------------------------------------------------------------
  130.   # ○ Convert attribute array of weapons to an integer.
  131.   #--------------------------------------------------------------------------
  132.   def self.create_weapon_element_list
  133.     result = []
  134.     WEAPON_ELEMENTS.each { |e|
  135.       if e.is_a?(Range)
  136.         result |= e.to_a
  137.       elsif e.is_a?(Integer)
  138.         result |= [e]
  139.       end
  140.     }
  141.     return result.sort
  142.   end
  143.  
  144.   # Attribute array of weapons
  145.   WEAPON_ELEMENT_ID_LIST = create_weapon_element_list
  146.  
  147. #==============================================================================
  148. # □ KGC::ReproduceFunctions::Regexp
  149. #==============================================================================
  150. # * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * #
  151. #                          Note Field Tag Strings                             #
  152. # * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * #
  153. #  Whatever word(s) are after the separator ( | ) in the following lines are
  154. #   what are used to determine what is searched for in the "Note" section of
  155. #   an item, weapon, armor, enemy, or state.
  156.  
  157.   # Define Regular Expressions  
  158.   module Regexp
  159.      # Base Item Module
  160.     module BaseItem
  161.       # Auto State tag string
  162.       AUTO_STATE = /<(?:AUTO_STATE|auto_state)\s*(\d+(?:\s*,\s*\d+)*)>/i
  163.       # Whole Attack tag string
  164.       WHOLE_ATTACK = /<(?:WHOLE_ATTACK|target_all)>/i
  165.       # Ignore Evasion tag string
  166.       IGNORE_EVA = /<(?:IGNORE_EVA|ignore_eva)>/i
  167.       # Consume MP tag string
  168.       MP_COST = /<(?:MP_COST|mp_cost)\s*([\-]?\d+)>/i
  169.       # Critical tag string
  170.       CRITICAL = /<(?:CRITICAL|critical)\s*(\-?\d+)>/i
  171.     end
  172.    
  173.     # Item Module
  174.     module Item
  175.       # Multi-Usable Items Tag String
  176.       MULTI_USABLE = /<(?:MULTI_USABLE|multi_use)\s*(\d+)>/i
  177.       # Execute Skill Tag String
  178.       EXEC_SKILL = /<(?:EXEC_SKILL|exec_skill)\s*(\d+)>/i
  179.     end
  180.    
  181.     # Enemy Module
  182.     module Enemy
  183.       # Translucent tag string
  184.       TRANSLUCENT = /<(?:TRANSLUCENT|translucent)>/i
  185.       # Critical tag string
  186.       CRITICAL = /<(?:CRITICAL|critical)\s*(\d+)>/i
  187.     end
  188.  
  189.     # State module
  190.     module State
  191.       # MaxHP / MaxMP Rate Tag Strings
  192.       PARAMETER_NAME = {
  193.         "maxhp"=>"MAXHP_RATE|maxhp_rate",
  194.         "maxmp"=>"MAXMP_RATE|maxmp_rate"
  195.       }
  196.       # Stat-Dependant Skills
  197.       # Attack Dependant Skill Tag String (Originally Japanese)
  198.       SEAL_ATK_F_JP = /<SEAL_ATK_F\s*(\d+)\s*minimum>/
  199.       # Attack Dependant Skill Tag String
  200.       SEAL_ATK_F_EN = /<minimum_atk\s*(\d+)>/i
  201.       # Spirit Dependant Skill Tag String (Originally Japanese)
  202.       SEAL_SPI_F_JP = /<SEAL_SPI_F\s*(\d+)\s*以上封印>/
  203.       # # Spirit Dependant Skill Tag String
  204.       SEAL_SPI_F_EN = /<minimum_spi\s*(\d+)>/i
  205.       # Add State Tag String
  206.       PLUS_STATE = /<(?:PLUS_STATE|plus_state)\s*(\d+(?:\s*,\s*\d+)*)>/i
  207.     end
  208.   end
  209. end
  210.  
  211. #=================================End Module===================================#
  212.  
  213. #==============================================================================
  214. # ■ RPG::BaseItem
  215. #==============================================================================
  216.  
  217. class RPG::BaseItem
  218.   #--------------------------------------------------------------------------
  219.   # ○ Generated feature reproduction cache
  220.   #--------------------------------------------------------------------------
  221.   def create_reproduce_functions_cache
  222.     @__whole_attack = false
  223.     @__ignore_eva = false
  224.     @__mp_cost = 0
  225.     @__cri = 0
  226.  
  227.     self.note.each_line { |line|
  228.       case line
  229.       when KGC::ReproduceFunctions::Regexp::BaseItem::WHOLE_ATTACK
  230.         # 全体攻撃
  231.         @__whole_attack = true
  232.       when KGC::ReproduceFunctions::Regexp::BaseItem::IGNORE_EVA
  233.         # 回避率無視
  234.         @__ignore_eva = true
  235.       when KGC::ReproduceFunctions::Regexp::BaseItem::MP_COST
  236.         # 通常攻撃消費 MP
  237.         @__mp_cost += $1.to_i
  238.       when KGC::ReproduceFunctions::Regexp::BaseItem::CRITICAL
  239.         # クリティカル修正
  240.         @__cri += $1.to_i
  241.       end
  242.     }
  243.  
  244.     create_auto_state_cache
  245.   end
  246.   #--------------------------------------------------------------------------
  247.   # ○ オートステートのキャッシュ生成
  248.   #--------------------------------------------------------------------------
  249.   def create_auto_state_cache
  250.     # ID のキャッシュ生成
  251.     @__auto_state_ids = []
  252.     @__auto_state_ids_battle = []
  253.     self.note.each_line { |line|
  254.       next unless line =~ KGC::ReproduceFunctions::Regexp::BaseItem::AUTO_STATE
  255.       $1.scan(/\d+/).each { |num|
  256.         if (state = $data_states[num.to_i]) != nil
  257.           @__auto_state_ids_battle << state.id
  258.           unless state.battle_only
  259.             @__auto_state_ids << state.id
  260.           end
  261.         end
  262.       }
  263.     }
  264.  
  265.     # オブジェクトのキャッシュ作成
  266.     @__auto_states = []
  267.     @__auto_state_ids.each { |i|
  268.       @__auto_states << $data_states[i]
  269.     }
  270.     @__auto_states_battle = []
  271.     @__auto_state_ids_battle.each { |i|
  272.       @__auto_states_battle << $data_states[i]
  273.     }
  274.   end
  275.   #--------------------------------------------------------------------------
  276.   # ○ 全体攻撃判定
  277.   #--------------------------------------------------------------------------
  278.   def whole_attack
  279.     create_reproduce_functions_cache if @__whole_attack == nil
  280.     return @__whole_attack
  281.   end
  282.   #--------------------------------------------------------------------------
  283.   # ○ 回避無視判定
  284.   #--------------------------------------------------------------------------
  285.   def ignore_eva
  286.     create_reproduce_functions_cache if @__ignore_eva == nil
  287.     return @__ignore_eva
  288.   end
  289.   #--------------------------------------------------------------------------
  290.   # ○ 通常攻撃消費 MP
  291.   #--------------------------------------------------------------------------
  292.   def mp_cost
  293.     create_reproduce_functions_cache if @__mp_cost == nil
  294.     return @__mp_cost
  295.   end
  296.   #--------------------------------------------------------------------------
  297.   # ○ クリティカル修正
  298.   #--------------------------------------------------------------------------
  299.   def cri
  300.     create_reproduce_functions_cache if @__cri == nil
  301.     return @__cri
  302.   end
  303.   #--------------------------------------------------------------------------
  304.   # ○ オートステート ID
  305.   #--------------------------------------------------------------------------
  306.   def auto_state_ids
  307.     return ($game_temp.in_battle ? auto_state_ids_battle : auto_state_ids_always)
  308.   end
  309.   #--------------------------------------------------------------------------
  310.   # ○ オートステート ID (常時)
  311.   #--------------------------------------------------------------------------
  312.   def auto_state_ids_always
  313.     create_reproduce_functions_cache if @__auto_state_ids == nil
  314.     return @__auto_state_ids
  315.   end
  316.   #--------------------------------------------------------------------------
  317.   # ○ オートステート ID (戦闘時)
  318.   #--------------------------------------------------------------------------
  319.   def auto_state_ids_battle
  320.     create_reproduce_functions_cache if @__auto_state_ids_battle == nil
  321.     return @__auto_state_ids_battle
  322.   end
  323.   #--------------------------------------------------------------------------
  324.   # ○ オートステート
  325.   #--------------------------------------------------------------------------
  326.   def auto_states
  327.     return ($game_temp.in_battle ? auto_states_battle : auto_states_always)
  328.   end
  329.   #--------------------------------------------------------------------------
  330.   # ○ オートステート (常時)
  331.   #--------------------------------------------------------------------------
  332.   def auto_states_always
  333.     create_reproduce_functions_cache if @__auto_states == nil
  334.     return @__auto_states
  335.   end
  336.   #--------------------------------------------------------------------------
  337.   # ○ オートステート (戦闘時)
  338.   #--------------------------------------------------------------------------
  339.   def auto_states_battle
  340.     create_reproduce_functions_cache if @__auto_states_battle == nil
  341.     return @__auto_states_battle
  342.   end
  343. end
  344.  
  345. #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
  346.  
  347. #==============================================================================
  348. # ■ RPG::Item
  349. #==============================================================================
  350.  
  351. class RPG::Item < RPG::UsableItem
  352.   #--------------------------------------------------------------------------
  353.   # ○ 再現機能のキャッシュ生成
  354.   #--------------------------------------------------------------------------
  355.   def create_reproduce_functions_cache
  356.     super
  357.     @__usable_count = 1
  358.     @__skill_id = 0
  359.  
  360.     self.note.each_line { |line|
  361.       case line
  362.       when KGC::ReproduceFunctions::Regexp::Item::MULTI_USABLE
  363.         # 使用可能回数
  364.         @__usable_count = $1.to_i
  365.       when KGC::ReproduceFunctions::Regexp::Item::EXEC_SKILL
  366.         # 発動スキル ID
  367.         @__skill_id = $1.to_i
  368.       end
  369.     }
  370.   end
  371.   #--------------------------------------------------------------------------
  372.   # ● アニメーション ID
  373.   #--------------------------------------------------------------------------
  374.   def animation_id
  375.     if exec_skill?
  376.       return $data_skills[skill_id].animation_id
  377.     else
  378.       return @animation_id
  379.     end
  380.   end
  381.   #--------------------------------------------------------------------------
  382.   # ○ 使用可能回数
  383.   #--------------------------------------------------------------------------
  384.   def usable_count
  385.     create_reproduce_functions_cache if @__usable_count == nil
  386.     return @__usable_count
  387.   end
  388.   #--------------------------------------------------------------------------
  389.   # ○ スキル発動判定
  390.   #--------------------------------------------------------------------------
  391.   def exec_skill?
  392.     return (skill_id > 0)
  393.   end
  394.   #--------------------------------------------------------------------------
  395.   # ○ 発動スキル ID
  396.   #--------------------------------------------------------------------------
  397.   def skill_id
  398.     create_reproduce_functions_cache if @__skill_id == nil
  399.     return @__skill_id
  400.   end
  401. end
  402.  
  403. #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
  404.  
  405. #==============================================================================
  406. # ■ RPG::Skill
  407. #==============================================================================
  408.  
  409. class RPG::Skill < RPG::UsableItem
  410.   #--------------------------------------------------------------------------
  411.   # ○ 再現機能のキャッシュ生成
  412.   #--------------------------------------------------------------------------
  413.   def create_reproduce_functions_cache
  414.     super
  415.  
  416.     @__weapon_element_set =
  417.       self.element_set & KGC::ReproduceFunctions::WEAPON_ELEMENT_ID_LIST
  418.   end
  419.   #--------------------------------------------------------------------------
  420.   # ○ 使用時に必要な武器属性を取得
  421.   #--------------------------------------------------------------------------
  422.   def weapon_element_set
  423.     create_reproduce_functions_cache if @__weapon_element_set == nil
  424.     return @__weapon_element_set
  425.   end
  426. end
  427.  
  428. #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
  429.  
  430. #==============================================================================
  431. # ■ RPG::Enemy
  432. #==============================================================================
  433.  
  434. class RPG::Enemy
  435.   #--------------------------------------------------------------------------
  436.   # ○ 再現機能のキャッシュ生成
  437.   #--------------------------------------------------------------------------
  438.   def create_reproduce_functions_cache
  439.     @__translucent = false
  440.     @__cri = 0
  441.  
  442.     self.note.each_line { |line|
  443.       case line
  444.       when KGC::ReproduceFunctions::Regexp::Enemy::TRANSLUCENT
  445.         # 半透明
  446.         @__translucent = true
  447.       when KGC::ReproduceFunctions::Regexp::Enemy::CRITICAL
  448.         # クリティカル修正
  449.         @__cri += $1.to_i
  450.       end
  451.     }
  452.   end
  453.   #--------------------------------------------------------------------------
  454.   # ○ 半透明
  455.   #--------------------------------------------------------------------------
  456.   def translucent?
  457.     create_reproduce_functions_cache if @__translucent == nil
  458.     return @__translucent
  459.   end
  460.   #--------------------------------------------------------------------------
  461.   # ○ クリティカル修正
  462.   #--------------------------------------------------------------------------
  463.   def cri
  464.     create_reproduce_functions_cache if @__cri == nil
  465.     return @__cri
  466.   end
  467. end
  468.  
  469. #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
  470.  
  471. #==============================================================================
  472. # ■ RPG::State
  473. #==============================================================================
  474.  
  475. class RPG::State
  476.   #--------------------------------------------------------------------------
  477.   # ○ 再現機能のキャッシュ生成
  478.   #--------------------------------------------------------------------------
  479.   def create_reproduce_functions_cache
  480.     @__seal_atk_f = 999
  481.     @__seal_spi_f = 999
  482.     @__plus_state_set = []
  483.  
  484.     self.note.each_line { |line|
  485.       case line
  486.       when KGC::ReproduceFunctions::Regexp::State::SEAL_ATK_F_JP,
  487.            KGC::ReproduceFunctions::Regexp::State::SEAL_ATK_F_EN
  488.         # 封印するスキルの打撃関係度
  489.         @__seal_atk_f = $1.to_i
  490.       when KGC::ReproduceFunctions::Regexp::State::SEAL_SPI_F_JP,
  491.            KGC::ReproduceFunctions::Regexp::State::SEAL_SPI_F_EN
  492.         # 封印するスキルの精神関係度
  493.         @__seal_spi_f = $1.to_i
  494.       when KGC::ReproduceFunctions::Regexp::State::PLUS_STATE
  495.         # 付加ステート
  496.         $1.scan(/\d+/).each { |num|
  497.           if (state = $data_states[num.to_i]) != nil
  498.             @__plus_state_set << state.id
  499.           end
  500.         }
  501.       end
  502.     }
  503.  
  504.     create_parameter_rate_cache
  505.   end
  506.   #--------------------------------------------------------------------------
  507.   # ○ パラメータ修正値のキャッシュ生成
  508.   #--------------------------------------------------------------------------
  509.   def create_parameter_rate_cache
  510.     @__parameter_rate = {}
  511.     # 初期化
  512.     KGC::ReproduceFunctions::Regexp::State::PARAMETER_NAME.each_key { |k|
  513.       @__parameter_rate[k] = 100
  514.     }
  515.     # メモ反映
  516.     self.note.each_line { |line|
  517.       KGC::ReproduceFunctions::Regexp::State::PARAMETER_NAME.each { |k, v|
  518.         if line =~ /<(?:#{v})[ ]*(\d+)[%%]>/i
  519.           @__parameter_rate[k] = @__parameter_rate[k] * $1.to_i / 100
  520.           break
  521.         end
  522.       }
  523.     }
  524.   end
  525.   #--------------------------------------------------------------------------
  526.   # ○ MaxHP 修正
  527.   #--------------------------------------------------------------------------
  528.   def maxhp_rate
  529.     create_reproduce_functions_cache if @__parameter_rate == nil
  530.     return @__parameter_rate["maxhp"]
  531.   end
  532.   #--------------------------------------------------------------------------
  533.   # ○ MaxMP 修正
  534.   #--------------------------------------------------------------------------
  535.   def maxmp_rate
  536.     create_reproduce_functions_cache if @__parameter_rate == nil
  537.     return @__parameter_rate["maxmp"]
  538.   end
  539.   #--------------------------------------------------------------------------
  540.   # ○ 封印するスキルの打撃関係度
  541.   #--------------------------------------------------------------------------
  542.   def seal_atk_f
  543.     create_reproduce_functions_cache if @__seal_atk_f == nil
  544.     return @__seal_atk_f
  545.   end
  546.   #--------------------------------------------------------------------------
  547.   # ○ 封印するスキルの精神関係度
  548.   #--------------------------------------------------------------------------
  549.   def seal_spi_f
  550.     create_reproduce_functions_cache if @__seal_spi_f == nil
  551.     return @__seal_spi_f
  552.   end
  553.   #--------------------------------------------------------------------------
  554.   # ○ 付加ステート
  555.   #--------------------------------------------------------------------------
  556.   def plus_state_set
  557.     create_reproduce_functions_cache if @__plus_state_set == nil
  558.     return @__plus_state_set
  559.   end
  560. end
  561.  
  562. #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
  563.  
  564. #==============================================================================
  565. # ■ Game_Temp
  566. #==============================================================================
  567.  
  568. class Game_Temp
  569.   #--------------------------------------------------------------------------
  570.   # ● 公開インスタンス変数
  571.   #--------------------------------------------------------------------------
  572.   attr_accessor :exec_skill_on_item       # アイテムによるスキル発動フラグ
  573.   #--------------------------------------------------------------------------
  574.   # ● オブジェクト初期化
  575.   #--------------------------------------------------------------------------
  576.   alias initialize_KGC_ReproduceFunctions initialize unless $@
  577.   def initialize
  578.     initialize_KGC_ReproduceFunctions
  579.  
  580.     @exec_skill_on_item = false
  581.   end
  582. end
  583.  
  584. #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
  585.  
  586. #==============================================================================
  587. # ■ Game_Battler
  588. #==============================================================================
  589.  
  590. class Game_Battler
  591.   #--------------------------------------------------------------------------
  592.   # ● 現在のステートをオブジェクトの配列で取得
  593.   #--------------------------------------------------------------------------
  594.   alias states_KGC_ReproduceFunctions states unless $@
  595.   def states
  596.     result = states_KGC_ReproduceFunctions + auto_states
  597.     result.sort! { |a, b| b.priority <=> a.priority }
  598.     return result
  599.   end
  600.   #--------------------------------------------------------------------------
  601.   # ● MaxHP の取得
  602.   #--------------------------------------------------------------------------
  603.   alias maxhp_KGC_ReproduceFunctions maxhp unless $@
  604.   def maxhp
  605.     n = maxhp_KGC_ReproduceFunctions
  606.     states.each { |state| n *= state.maxhp_rate / 100.0 }
  607.     return [[Integer(n), 1].max, maxhp_limit].min
  608.   end
  609.   #--------------------------------------------------------------------------
  610.   # ● MaxMP の取得
  611.   #--------------------------------------------------------------------------
  612.   alias maxmp_KGC_ReproduceFunctions maxmp unless $@
  613.   def maxmp
  614.     n = maxmp_KGC_ReproduceFunctions
  615.     states.each { |state| n *= state.maxmp_rate / 100.0 }
  616.     limit = (defined?(maxmp_limit) ? maxmp_limit : 9999)
  617.     return [[Integer(n), 0].max, limit].min
  618.   end
  619.   #--------------------------------------------------------------------------
  620.   # ● HP の取得
  621.   #--------------------------------------------------------------------------
  622.   alias hp_KGC_ReproduceFunctions_Battler hp unless $@
  623.   def hp
  624.     @hp = maxhp if @hp > maxhp
  625.     return hp_KGC_ReproduceFunctions_Battler
  626.   end
  627.   #--------------------------------------------------------------------------
  628.   # ● MP の取得
  629.   #--------------------------------------------------------------------------
  630.   alias mp_KGC_ReproduceFunctions_Battler mp unless $@
  631.   def mp
  632.     @mp = maxmp if @mp > maxmp
  633.     return mp_KGC_ReproduceFunctions_Battler
  634.   end
  635.   #--------------------------------------------------------------------------
  636.   # ○ オートステートの ID を取得
  637.   #--------------------------------------------------------------------------
  638.   def auto_state_ids
  639.     return auto_states(true)
  640.   end
  641.   #--------------------------------------------------------------------------
  642.   # ○ オートステートの配列を取得
  643.   #     id_only : ID のみを取得
  644.   #--------------------------------------------------------------------------
  645.   def auto_states(id_only = false)
  646.     return []
  647.   end
  648.   #--------------------------------------------------------------------------
  649.   # ● ステートの検査
  650.   #     state_id : ステート ID
  651.   #    該当するステートが付加されていれば true を返す。
  652.   #--------------------------------------------------------------------------
  653.   alias state_KGC_ReproduceFunctions? state? unless $@
  654.   def state?(state_id)
  655.     return (state_KGC_ReproduceFunctions?(state_id) || auto_state?(state_id))
  656.   end
  657.   #--------------------------------------------------------------------------
  658.   # ● ステートの付加
  659.   #     state_id : ステート ID
  660.   #--------------------------------------------------------------------------
  661.   alias add_state_KGC_ReproduceFunctions add_state unless $@
  662.   def add_state(state_id)
  663.     last_states = @states.dup
  664.  
  665.     add_state_KGC_ReproduceFunctions(state_id)
  666.  
  667.     if (@states - last_states).include?(state_id)  # ステートが付加された場合
  668.       state = $data_states[state_id]
  669.       # [付加するステート] を適用
  670.       state.plus_state_set.each { |i|
  671.         add_state(i)
  672.       }
  673.     end
  674.   end
  675.   #--------------------------------------------------------------------------
  676.   # ○ オートステートの検査
  677.   #     state_id : ステート ID
  678.   #    該当するステートが付加されていれば true を返す。
  679.   #--------------------------------------------------------------------------
  680.   def auto_state?(state_id)
  681.     return auto_state_ids.include?(state_id)
  682.   end
  683.   #--------------------------------------------------------------------------
  684.   # ● ステートの解除
  685.   #     state_id : ステート ID
  686.   #--------------------------------------------------------------------------
  687.   alias remove_state_KGC_ReproduceFunctions remove_state unless $@
  688.   def remove_state(state_id)
  689.     if auto_state?(state_id)  # オートステートは解除しない
  690.       return
  691.     end
  692.  
  693.     remove_state_KGC_ReproduceFunctions(state_id)
  694.   end
  695.   #--------------------------------------------------------------------------
  696.   # ○ 半透明化判定
  697.   #--------------------------------------------------------------------------
  698.   def translucent?
  699.     # エネミーの場合は Game_Enemy で再定義
  700.     return false
  701.   end
  702.   #--------------------------------------------------------------------------
  703.   # ○ 装備オプション [全体攻撃] の取得
  704.   #--------------------------------------------------------------------------
  705.   def whole_attack
  706.     return false
  707.   end
  708.   #--------------------------------------------------------------------------
  709.   # ○ 装備オプション [回避無視] の取得
  710.   #--------------------------------------------------------------------------
  711.   def ignore_eva
  712.     return false
  713.   end
  714.   #--------------------------------------------------------------------------
  715.   # ○ MP ダメージ加算
  716.   #     value : 加算する値
  717.   #--------------------------------------------------------------------------
  718.   def add_mp_damage(value)
  719.     @mp_damage += value
  720.   end
  721.   #--------------------------------------------------------------------------
  722.   # ○ 通常攻撃の消費 MP 計算
  723.   #--------------------------------------------------------------------------
  724.   def calc_attack_mp_cost
  725.     return 0
  726.   end
  727.   #--------------------------------------------------------------------------
  728.   # ● スキルの使用可能判定
  729.   #     skill : スキル
  730.   #--------------------------------------------------------------------------
  731.   alias skill_can_use_KGC_ReproduceFunctions? skill_can_use? unless $@
  732.   def skill_can_use?(skill)
  733.     return false unless skill.is_a?(RPG::Skill)
  734.     unless $imported["CooperationSkill"] && $game_temp.judging_cooperation_skill
  735.       return false if skill_seal?(skill)
  736.       return false unless skill_satisfied_weapon_element?(skill)
  737.     end
  738.  
  739.     return skill_can_use_KGC_ReproduceFunctions?(skill)
  740.   end
  741.   #--------------------------------------------------------------------------
  742.   # ○ スキル封印判定
  743.   #--------------------------------------------------------------------------
  744.   def skill_seal?(skill)
  745.     return (seal_atk_f <= skill.atk_f || seal_spi_f <= skill.spi_f)
  746.   end
  747.   #--------------------------------------------------------------------------
  748.   # ○ 封印する打撃関係度を取得
  749.   #--------------------------------------------------------------------------
  750.   def seal_atk_f
  751.     n = 999
  752.     states.each { |state| n = [n, state.seal_atk_f].min }
  753.     return n
  754.   end
  755.   #--------------------------------------------------------------------------
  756.   # ○ 封印する精神関係度を取得
  757.   #--------------------------------------------------------------------------
  758.   def seal_spi_f
  759.     n = 999
  760.     states.each { |state| n = [n, state.seal_spi_f].min }
  761.     return n
  762.   end
  763.   #--------------------------------------------------------------------------
  764.   # ○ 必要な武器属性を満たしているか判定
  765.   #--------------------------------------------------------------------------
  766.   def skill_satisfied_weapon_element?(skill)
  767.     return true
  768.   end
  769.   #--------------------------------------------------------------------------
  770.   # ● 最終回避率の計算
  771.   #     user : 攻撃者、スキルまたはアイテムの使用者
  772.   #     obj  : スキルまたはアイテム (通常攻撃の場合は nil)
  773.   #--------------------------------------------------------------------------
  774.   alias calc_eva_KGC_ReproduceFunctions calc_eva unless $@
  775.   def calc_eva(user, obj = nil)
  776.     eva = calc_eva_KGC_ReproduceFunctions(user, obj)
  777.  
  778.     physical = (obj == nil || obj.physical_attack)
  779.     if physical && user.ignore_eva  # 物理攻撃かつ回避無視の場合
  780.       eva = 0
  781.     end
  782.     return eva
  783.   end
  784.   #--------------------------------------------------------------------------
  785.   # ● アイテムの効果適用
  786.   #     user : アイテムの使用者
  787.   #     item : アイテム
  788.   #--------------------------------------------------------------------------
  789.   alias item_effect_KGC_ReproduceFunctions item_effect unless $@
  790.   def item_effect(user, item)
  791.     # スキル発動判定
  792.     if item.exec_skill?
  793.       $game_temp.exec_skill_on_item = true
  794.       skill_effect(user, $data_skills[item.skill_id])
  795.       $game_temp.exec_skill_on_item = false
  796.     else
  797.       item_effect_KGC_ReproduceFunctions(user, item)
  798.     end
  799.   end
  800. end
  801.  
  802. #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
  803.  
  804. #==============================================================================
  805. # ■ Game_BattleAction
  806. #==============================================================================
  807.  
  808. class Game_BattleAction
  809.   #--------------------------------------------------------------------------
  810.   # ● 通常攻撃のターゲット作成
  811.   #--------------------------------------------------------------------------
  812.   alias make_attack_targets_KGC_ReproduceFunctions make_attack_targets unless $@
  813.   def make_attack_targets
  814.     unless battler.whole_attack  # 全体攻撃でない
  815.       return make_attack_targets_KGC_ReproduceFunctions
  816.     end
  817.  
  818.     targets = []
  819.     if battler.confusion?
  820.       targets += friends_unit.existing_members
  821.     else
  822.       targets += opponents_unit.existing_members
  823.     end
  824.     if battler.dual_attack      # 連続攻撃
  825.       targets += targets
  826.     end
  827.     return targets.compact
  828.   end
  829. end
  830.  
  831. #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
  832.  
  833. #==============================================================================
  834. # ■ Game_Actor
  835. #==============================================================================
  836.  
  837. class Game_Actor < Game_Battler
  838.   #--------------------------------------------------------------------------
  839.   # ● クリティカル率の取得
  840.   #--------------------------------------------------------------------------
  841.   alias cri_KGC_ReproduceFunctions cri unless $@
  842.   def cri
  843.     n = cri_KGC_ReproduceFunctions
  844.  
  845.     equips.compact.each { |item| n += item.cri }
  846.     return n
  847.   end
  848.   #--------------------------------------------------------------------------
  849.   # ○ オートステートの配列を取得
  850.   #     id_only : ID のみを取得
  851.   #--------------------------------------------------------------------------
  852.   def auto_states(id_only = false)
  853.     result = []
  854.     equips.compact.each { |item|
  855.       result |= (id_only ? item.auto_state_ids : item.auto_states)
  856.     }
  857.     return result
  858.   end
  859.   #--------------------------------------------------------------------------
  860.   # ○ 装備オプション [全体攻撃] の取得
  861.   #--------------------------------------------------------------------------
  862.   def whole_attack
  863.     equips.compact.each { |item|
  864.       return true if item.whole_attack
  865.     }
  866.     return false
  867.   end
  868.   #--------------------------------------------------------------------------
  869.   # ○ 装備オプション [回避無視] の取得
  870.   #--------------------------------------------------------------------------
  871.   def ignore_eva
  872.     equips.compact.each { |item|
  873.       return true if item.ignore_eva
  874.     }
  875.     return false
  876.   end
  877.   #--------------------------------------------------------------------------
  878.   # ○ 通常攻撃の消費 MP 計算
  879.   #--------------------------------------------------------------------------
  880.   def calc_attack_mp_cost
  881.     n = 0
  882.     equips.compact.each { |item|
  883.       n += item.mp_cost
  884.     }
  885.     return n
  886.   end
  887.   #--------------------------------------------------------------------------
  888.   # ○ 必要な武器属性を満たしているか判定
  889.   #--------------------------------------------------------------------------
  890.   def skill_satisfied_weapon_element?(skill)
  891.     elements = skill.weapon_element_set
  892.     return (self.element_set & elements) == elements
  893.   end
  894. end
  895.  
  896. #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
  897.  
  898. #==============================================================================
  899. # ■ Game_Enemy
  900. #==============================================================================
  901.  
  902. class Game_Enemy < Game_Battler
  903.   #--------------------------------------------------------------------------
  904.   # ○ 半透明化判定
  905.   #--------------------------------------------------------------------------
  906.   def translucent?
  907.     return enemy.translucent?
  908.   end
  909.   #--------------------------------------------------------------------------
  910.   # ● クリティカル率の取得
  911.   #--------------------------------------------------------------------------
  912.   alias cri_KGC_ReproduceFunctions cri unless $@
  913.   def cri
  914.     n = cri_KGC_ReproduceFunctions
  915.     if enemy.has_critical && enemy.cri != 0
  916.       n += enemy.cri - 10
  917.     end
  918.     return n
  919.   end
  920. end
  921.  
  922. #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
  923.  
  924. #==============================================================================
  925. # ■ Game_Party
  926. #==============================================================================
  927.  
  928. class Game_Party < Game_Unit
  929.   #--------------------------------------------------------------------------
  930.   # ● オブジェクト初期化
  931.   #--------------------------------------------------------------------------
  932.   alias initialize_KGC_ReproduceFunctions initialize unless $@
  933.   def initialize
  934.     initialize_KGC_ReproduceFunctions
  935.  
  936.     @item_use_count = {}  # 所持品使用回数ハッシュ (アイテム ID)
  937.   end
  938.   #--------------------------------------------------------------------------
  939.   # ● アイテムの減少
  940.   #     item          : アイテム
  941.   #     n             : 個数
  942.   #     include_equip : 装備品も含める
  943.   #--------------------------------------------------------------------------
  944.   alias lose_item_KGC_ReproduceFunctions lose_item unless $@
  945.   def lose_item(item, n, include_equip = false)
  946.     lose_item_KGC_ReproduceFunctions(item, n, include_equip)
  947.  
  948.     # アイテムが無くなったら使用回数をリセット
  949.     if item.is_a?(RPG::Item) && item.consumable && item_number(item) == 0
  950.       @item_use_count[item.id] = 0
  951.     end
  952.   end
  953.   #--------------------------------------------------------------------------
  954.   # ● アイテムの消耗
  955.   #     item : アイテム
  956.   #--------------------------------------------------------------------------
  957.   alias consume_item_KGC_ReproduceFunctions consume_item unless $@
  958.   def consume_item(item)
  959.     if item.is_a?(RPG::Item) && item.consumable
  960.       update_use_count(item)
  961.  
  962.       # 使用回数が 0 の場合のみ消耗
  963.       if @item_use_count[item.id] == 0
  964.         consume_item_KGC_ReproduceFunctions(item)
  965.       end
  966.     else
  967.       consume_item_KGC_ReproduceFunctions(item)
  968.     end
  969.   end
  970.   #--------------------------------------------------------------------------
  971.   # ○ 使用回数の更新
  972.   #     item : アイテム
  973.   #    指定アイテムの使用回数を 1 増やす。
  974.   #    使用後に消耗する場合は、使用回数を 0 にする。
  975.   #--------------------------------------------------------------------------
  976.   def update_use_count(item)
  977.     if @item_use_count == nil
  978.       @item_use_count = {}
  979.     end
  980.  
  981.     unless @item_use_count.has_key?(item.id)
  982.       @item_use_count[item.id] = 0
  983.     end
  984.     @item_use_count[item.id] += 1
  985.     # 使用可能回数に達したら、使用回数を 0 にする
  986.     if @item_use_count[item.id] >= item.usable_count
  987.       @item_use_count[item.id] = 0
  988.     end
  989.   end
  990. end
  991.  
  992. #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
  993.  
  994. #==============================================================================
  995. # ■ Sprite_Battler
  996. #==============================================================================
  997.  
  998. class Sprite_Battler < Sprite_Base
  999.   #--------------------------------------------------------------------------
  1000.   # ● エフェクトの更新
  1001.   #--------------------------------------------------------------------------
  1002.   alias update_effect_KGC_ReproduceFunctions update_effect unless $@
  1003.   def update_effect
  1004.     # エフェクト実行前に半透明化判定をしておく
  1005.     trans_flag = (@effect_duration > 0 && @battler.translucent?)
  1006.  
  1007.     update_effect_KGC_ReproduceFunctions
  1008.  
  1009.     if trans_flag
  1010.       self.opacity /= 2
  1011.     end
  1012.   end
  1013. end
  1014.  
  1015. #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
  1016.  
  1017. #==============================================================================
  1018. # ■ Scene_Battle
  1019. #==============================================================================
  1020.  
  1021. class Scene_Battle < Scene_Base
  1022.   #--------------------------------------------------------------------------
  1023.   # ● 対象敵キャラ選択の開始
  1024.   #--------------------------------------------------------------------------
  1025.   alias start_target_enemy_selection_KGC_ReproduceFunctions start_target_enemy_selection unless $@
  1026.   def start_target_enemy_selection
  1027.     # 全体通常攻撃なら選択をスキップ
  1028.     if @active_battler.action.kind == 0 &&
  1029.         @active_battler.action.basic == 0 &&
  1030.         @active_battler.whole_attack
  1031.       next_actor
  1032.       return
  1033.     end
  1034.  
  1035.     start_target_enemy_selection_KGC_ReproduceFunctions
  1036.   end
  1037.   #--------------------------------------------------------------------------
  1038.   # ● 戦闘行動の実行 : 攻撃
  1039.   #--------------------------------------------------------------------------
  1040.   alias execute_action_attack_KGC_ReproduceFunctions execute_action_attack unless $@
  1041.   def execute_action_attack
  1042.     execute_action_attack_KGC_ReproduceFunctions
  1043.  
  1044.     # 攻撃者の MP 消費
  1045.     mp_cost = @active_battler.calc_attack_mp_cost
  1046.     return if mp_cost == 0
  1047.     @active_battler.mp -= mp_cost
  1048.     if KGC::ReproduceFunctions::SHOW_WEAPON_MP_COST_ON_ATTACK
  1049.       @active_battler.add_mp_damage(mp_cost)
  1050.       display_mp_damage(@active_battler)
  1051.     end
  1052.   end
  1053. end
Advertisement
Add Comment
Please, Sign In to add comment