CyberForte

DoW Add Equip

Oct 10th, 2017
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 38.24 KB | None | 0 0
  1. #_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_
  2. #_/    ◆          Equipment Effects - KGC_AddEquipmentOptions           ◆ VX ◆
  3. #_/    ◇                   Last Update: 2008/04/01                           ◇
  4. #_/    ◆                Translation by Mr. Anonymous                         ◆
  5. #_/   ◆ http://ytomy.sakura.ne.jp/                                            ◆
  6. #_/-----------------------------------------------------------------------------
  7. #_/  This script allows the designer to add additional effects to items, weapons
  8. #_/  and armor. You add effects through tags, such as <Auto HP Recover 10%>
  9. #_/=============================================================================
  10. #_/                      ◆ 2008/03/29 UPDATE [KCG] ◆
  11. #_/               Added "MP Conversion" and "MP Absorbtion"
  12. #_/=============================================================================
  13. #_/                         ◆ Instructions For Usage ◆
  14. #_/  To make use of these functions, you must insert the desired tag into the
  15. #_/   "Notes" box located in the appropriate section of the database. For
  16. #_/   example, you want a magic Robe to restore a small amount of MP before
  17. #_/   each combat round combat, you would locate the robe in the armor tab of
  18. #_/   the database and insert "<auto MP recover 10%>" (without quotations)
  19. #_/   in the note box. Simple, no? Note: Tags are case-sensitive.
  20. #_/
  21. #_/    Key:
  22. #_/    * Rate = Numerical value of desired outcome.
  23. #_/    * Modifier = Subtraction, Addition, Mulpication, etc
  24. #_/    * ElementalID = The number of the desired "Element Name" (See Database)
  25. #_/    * StateID = The number of the desired "State" (See Database)
  26. #_/  
  27. #_/                        ◆ Restored Combat Functions ◆
  28. #_/
  29. #_/                 ◆ Shields - Headgear - Accessories Related ◆
  30. #_/  <auto HP recover Rate %>
  31. #_/  Automatically regenerate a specified percentage of HP at the beginning of
  32. #_/  each combat round. It can also be written without the rate and percentile.
  33. #_/  
  34. #_/  <auto MP recover Rate %>
  35. #_/  Automatically regenerate a specified percentage of MP at the beginning of
  36. #_/  each combat round. It can also be written without the rate and percentile.
  37. #_/  
  38. #_/  <MP absorb Rate %>
  39. #_/  Absorb a specified amount of MP based on a percentile of damage the actor
  40. #_/  recieved.
  41. #_/
  42. #_/  <MP convert Rate %>
  43. #_/  Converts a specified amount of MP that depends on the amount of MP the
  44. #_/  attacking foe uses for an attack.
  45. #_/
  46. #_/  <element resist ElementID: Modifier Rate %>
  47. #_/  Resist a specified amount of damage from a specified element.
  48. #_/  Modifier is optional.
  49. #_/  
  50. #_/  <element weakness ElementID: Modifier Rate>
  51. #_/  Damage from specified element is increased by 1.5 times to the character
  52. #_/  equipped with the tagged weapon.
  53. #_/  
  54. #_/  <element half ElementID>
  55. #_/  Damage from specified element is divided in half.
  56. #_/  
  57. #_/  <element null ElementID>
  58. #_/  Damaged from specified element is completely nullified (cancelled).
  59. #_/  
  60. #_/  <element absorb ElementID: Modifier Rate>
  61. #_/  Damage from specified element is completely absorbed.
  62. #_/  
  63. #_/  <state resist stateID: Modifier Rate %>
  64. #_/  Resist a specified state.
  65. #_/  
  66. #_/                              ◆ Weapons Related ◆
  67. #_/
  68. #_/  <prevent critical>
  69. #_/  Prevent critical attacks done by equipped character.
  70. #_/  
  71. #_/  <half MP cost>
  72. #_/  Decreases MP spent on skills by 50%.
  73. #_/  
  74. #_/  <double exp>
  75. #_/  Increases experience points gained from defeated foes in battle by 50%.
  76. #_/
  77. #_/  
  78. #_/                               ◆ Body Gear Related ◆
  79. #_/  <fast attack>
  80. #_/  Adds "Preemptive Strike" aka "Fast Attack" to the character.
  81. #_/  
  82. #_/  <dual attack>
  83. #_/  Adds the "Dual Attack" style to the character, allowing the character to
  84. #_/  equip attack twice in a row on every attack.
  85. #_/
  86. #_/  <critical bonus>
  87. #_/  Same as the Critical Bonus in the Actors Database.
  88. #_/  
  89. #_/  <attack element ElementID>
  90. #_/  Adds additional elements to the character's default attack.
  91. #_/  
  92. #_/  <plus state StateID>
  93. #_/  Adds additional status effects to the character's default attack.
  94. #_/=============================================================================
  95. #_/  Installation: Insert above Main.
  96. #_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_
  97.  
  98. #==============================================================================#
  99. #                            ★ Customization ★                                 #
  100. #==============================================================================#
  101.  
  102. module KGC
  103.  module AddEquipmentOptions
  104.   # ◆ <auto HP recover> Default HP Recovery Rate (Percentile)
  105.   #   (When not manually assigned)
  106.   #   Allows you to change the default amount of HP recovered per-round.
  107.   DEFAULT_RECOVER_HP_RATE = 5
  108.   # ◆ <auto MP recover> Default MP Recovery Rate (Percentile)
  109.   #   (When not manually assigned)
  110.   #   Allows you to change the default amount of HP recovered per-round.
  111.   DEFAULT_RECOVER_MP_RATE = 5
  112.  
  113.   # ◆ <MP convert> Default MP Conversion Rate (Percentile)
  114.   #   (When not manually assigned)
  115.   #   Allows you to change the default amount of MP converted on damage.
  116.   DEFAULT_CONVERT_MP_RATE = 1
  117.   # ◆ <MP absorb> Default MP Absorbtion Rate (Percentile)
  118.   #   (When not manually assigned)
  119.   #   Allows you to change the default amount of MP absorbed on damage.
  120.   DEFAULT_ABSORB_MP_RATE  = 5
  121.  end
  122. end
  123.  
  124. ## * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * #
  125. #  Unless you know what you're doing, it's best not to alter anything beyond  #
  126. #  this point, as this only affects the tags used for "Notes" in database.    #
  127. # * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * #
  128. #  Whatever word(s) are after the separator ( | ) in the following lines are
  129. #   what are used to determine what is searched for in the "Notes" section.
  130.  
  131. $imported = {} if $imported == nil
  132. $imported["AddEquipmentOptions"] = true
  133.  
  134. module KGC::AddEquipmentOptions
  135.   # Regular Expressions Defined
  136.   module Regexp
  137.     # Base Item Module
  138.     module BaseItem
  139.       # Multi Attack Tag String
  140.       MULTI_ATTACK = /<(\d+)\s*(?:TIMES_ATTACK|multiatk)>/i
  141.       # HP Automatic Recovery Tag String
  142.       AUTO_HP_RECOVER = /<(?:AUTO_HP_RECOVER|auto HP recover)(\s*(\d+)([%%])?)?>/i
  143.       # MP Automatic Recovery Tag String
  144.       AUTO_MP_RECOVER = /<(?:AUTO_MP_RECOVER|auto MP recover)(\s*(\d+)([%%])?)?>/i
  145.       # MP conversion Tag String
  146.       CONVERT_MP = /<(?:CONVERT_MP|MP convert)\s*(\d+)?[%%]?>/i
  147.       # MP Absorbtion Tag String
  148.       ABSORB_MP = /<(?:ABSORB_MP|MP absorb)\s*(\d+)?[%%]?>/i
  149.  
  150.       # Attribute Resistance Tag String
  151.       ELEMENT_RESISTANCE =
  152.         /<(?:ELEMENT_RESISTANCE|element resist)\s*(\d+):(\-?\d+)[%%]?>/i
  153.       # Attribute Weakness Tag String
  154.       WEAK_ELEMENT =
  155.         /<(?:WEAK_ELEMENT|element weakness)\s*(\d+(?:\s*,\s*\d+)*)>/i
  156.       # Attribute Half Damage Tag String
  157.       GUARD_ELEMENT =
  158.         /<(?:GUARD_ELEMENT|element half)\s*(\d+(?:\s*,\s*\d+)*)>/i
  159.       # Attribute Nullification Tag String
  160.       INVALID_ELEMENT =
  161.         /<(?:INVALID_ELEMENT|element null)\s*(\d+(?:\s*,\s*\d+)*)>/i
  162.       # Attribute Absorbtion Tag String
  163.       ABSORB_ELEMENT =
  164.         /<(?:ABSORB_ELEMENT|element absorb)\s*(\d+(?:\s*,\s*\d+)*)>/i
  165.       # State Resistance Tag String
  166.       STATE_RESISTANCE =
  167.         /<(?:STATE_RESISTANCE|state resist)\s*(\d+):(\d+)[%%]?>/i
  168.     end
  169.  
  170.     # Base Weapon Module
  171.     module Weapon
  172.       # Critical Prevention Tag String
  173.       PREVENT_CRITICAL = /<(?:PREVENT_CRITICAL|prevent critical)>/i
  174.       # Half MP Consumption Tag String
  175.       HALF_MP_COST = /<(?:HALF_MP_COST|half MP cost)>/i
  176.       # Experience Gain x2 Tag String
  177.       DOUBLE_EXP_GAIN = /<(?:DOUBLE_EXP_GAIN|double exp)>/i
  178.     end
  179.  
  180.     # Base Armor Module
  181.     module Armor
  182.       # Premptive Attack Tag String
  183.       FAST_ATTACK = /<(?:FAST_ATTACK|fast attack)>/i
  184.       # Dual Attack Tag String
  185.       DUAL_ATTACK = /<(?:DUAL_ATTACK|dual attack)>/i
  186.       # Critial Bonus Tag String
  187.       CRITICAL_BONUS = /<(?:CRITICAL_BONUS|critical bonus)>/i
  188.       # Attack Element Tag String
  189.       ATTACK_ELEMENT =
  190.         /<(?:ATTACK_ELEMENT|attack element)\s*(\d+(?:\s*,\s*\d+)*)>/i
  191.       # Status Addition Tag String
  192.       PLUS_STATE = /<(?:PLUS_STATE|plus state)\s*(\d+(?:\s*,\s*\d+)*)>/i
  193.     end
  194.   end
  195. end
  196.  
  197. #==============================================================================
  198. # ■ RPG::BaseItem
  199. #==============================================================================
  200.  
  201. class RPG::BaseItem
  202.   #--------------------------------------------------------------------------
  203.   # ○ Additional Equipment Augmentation Compilation
  204.   #--------------------------------------------------------------------------
  205.   def create_add_equipment_options_cache
  206.     @__multi_attack_count = 1
  207.     @__auto_hp_recover = false
  208.     @__auto_hp_recover_value = 0
  209.     @__auto_hp_recover_rate = 0
  210.     @__auto_mp_recover = false
  211.     @__auto_mp_recover_value = 0
  212.     @__auto_mp_recover_rate = 0
  213.     @__convert_mp_rate = 0
  214.     @__absorb_mp_rate = 0
  215.  
  216.     @note.split(/[\r\n]+/).each { |line|
  217.       case line
  218.       when KGC::AddEquipmentOptions::Regexp::BaseItem::MULTI_ATTACK
  219.         # n回攻撃
  220.         @__multi_attack_count = [$1.to_i, 1].max
  221.       when KGC::AddEquipmentOptions::Regexp::BaseItem::AUTO_HP_RECOVER
  222.         # HP自動回復
  223.         @__auto_hp_recover = true
  224.         next if $1 == nil
  225.         if $3 != nil
  226.           @__auto_hp_recover_rate += $2.to_i
  227.         else
  228.           @__auto_hp_recover_value += $2.to_i
  229.         end
  230.       when KGC::AddEquipmentOptions::Regexp::BaseItem::AUTO_MP_RECOVER
  231.         # MP自動回復
  232.         @__auto_mp_recover = true
  233.         next if $1 == nil
  234.         if $3 != nil
  235.           @__auto_mp_recover_rate += $2.to_i
  236.         else
  237.           @__auto_mp_recover_value += $2.to_i
  238.         end
  239.       when KGC::AddEquipmentOptions::Regexp::BaseItem::CONVERT_MP
  240.         # MP転換
  241.         @__convert_mp_rate = ($1 != nil ?
  242.           $1.to_i : KGC::AddEquipmentOptions::DEFAULT_CONVERT_MP_RATE)
  243.       when KGC::AddEquipmentOptions::Regexp::BaseItem::ABSORB_MP
  244.         # MP吸収
  245.         @__absorb_mp_rate = ($1 != nil ?
  246.           $1.to_i : KGC::AddEquipmentOptions::DEFAULT_ABSORB_MP_RATE)
  247.       end
  248.     }
  249.  
  250.     create_resistance_cache
  251.   end
  252.   #--------------------------------------------------------------------------
  253.   # ○ 耐性のキャッシュ生成
  254.   #--------------------------------------------------------------------------
  255.   def create_resistance_cache
  256.     @__element_resistance = []
  257.     @__weak_element_set = []
  258.     @__guard_element_set = []
  259.     @__invalid_element_set = []
  260.     @__absorb_element_set = []
  261.  
  262.     @__state_resistance = []
  263.  
  264.     @note.split(/[\r\n]+/).each { |line|
  265.       case line
  266.       when KGC::AddEquipmentOptions::Regexp::BaseItem::ELEMENT_RESISTANCE
  267.         # 属性耐性
  268.         element_id = $1.to_i
  269.         value = $2.to_i
  270.         if @__element_resistance[element_id] == nil
  271.           @__element_resistance[element_id] = 100
  272.         end
  273.         @__element_resistance[element_id] -= (100 - value)
  274.       when KGC::AddEquipmentOptions::Regexp::BaseItem::WEAK_ELEMENT
  275.         # 弱点属性
  276.         $1.scan(/\d+/).each { |num|
  277.           @__weak_element_set << num.to_i
  278.         }
  279.       when KGC::AddEquipmentOptions::Regexp::BaseItem::GUARD_ELEMENT
  280.         # 半減属性
  281.         $1.scan(/\d+/).each { |num|
  282.           @__guard_element_set << num.to_i
  283.         }
  284.       when KGC::AddEquipmentOptions::Regexp::BaseItem::INVALID_ELEMENT
  285.         # 無効属性
  286.         $1.scan(/\d+/).each { |num|
  287.           @__invalid_element_set << num.to_i
  288.         }
  289.       when KGC::AddEquipmentOptions::Regexp::BaseItem::ABSORB_ELEMENT
  290.         # 吸収属性
  291.         $1.scan(/\d+/).each { |num|
  292.           @__absorb_element_set << num.to_i
  293.         }
  294.       when KGC::AddEquipmentOptions::Regexp::BaseItem::STATE_RESISTANCE
  295.         # ステート耐性
  296.         state_id = $1.to_i
  297.         value = $2.to_i
  298.         if @__state_resistance[state_id] == nil
  299.           @__state_resistance[state_id] = 100
  300.         end
  301.         @__state_resistance[state_id] -= (100 - value)
  302.       end
  303.     }
  304.   end
  305.   #--------------------------------------------------------------------------
  306.   # ○ 攻撃回数
  307.   #--------------------------------------------------------------------------
  308.   def multi_attack_count
  309.     create_add_equipment_options_cache if @__multi_attack_count == nil
  310.     return @__multi_attack_count
  311.   end
  312.   #--------------------------------------------------------------------------
  313.   # ○ 装備オプション [HP自動回復]
  314.   #--------------------------------------------------------------------------
  315.   def auto_hp_recover
  316.     create_add_equipment_options_cache if @__auto_hp_recover == nil
  317.     return @__auto_hp_recover
  318.   end
  319.   #--------------------------------------------------------------------------
  320.   # ○ 装備オプション [MP自動回復]
  321.   #--------------------------------------------------------------------------
  322.   def auto_mp_recover
  323.     create_add_equipment_options_cache if @__auto_mp_recover == nil
  324.     return @__auto_mp_recover
  325.   end
  326.   #--------------------------------------------------------------------------
  327.   # ○ HP 自動回復量 (即値)
  328.   #--------------------------------------------------------------------------
  329.   def auto_hp_recover_value
  330.     create_add_equipment_options_cache if @__auto_hp_recover_value == nil
  331.     return @__auto_hp_recover_value
  332.   end
  333.   #--------------------------------------------------------------------------
  334.   # ○ HP 自動回復量 (割合)
  335.   #--------------------------------------------------------------------------
  336.   def auto_hp_recover_rate
  337.     create_add_equipment_options_cache if @__auto_hp_recover_rate == nil
  338.     return @__auto_hp_recover_rate
  339.   end
  340.   #--------------------------------------------------------------------------
  341.   # ○ MP 自動回復量 (即値)
  342.   #--------------------------------------------------------------------------
  343.   def auto_mp_recover_value
  344.     create_add_equipment_options_cache if @__auto_mp_recover_value == nil
  345.     return @__auto_mp_recover_value
  346.   end
  347.   #--------------------------------------------------------------------------
  348.   # ○ MP 自動回復量 (割合)
  349.   #--------------------------------------------------------------------------
  350.   def auto_mp_recover_rate
  351.     create_add_equipment_options_cache if @__auto_mp_recover_rate == nil
  352.     return @__auto_mp_recover_rate
  353.   end
  354.   #--------------------------------------------------------------------------
  355.   # ○ MP 転換率
  356.   #--------------------------------------------------------------------------
  357.   def convert_mp_rate
  358.     create_add_equipment_options_cache if @__convert_mp_rate == nil
  359.     return @__convert_mp_rate
  360.   end
  361.   #--------------------------------------------------------------------------
  362.   # ○ MP 吸収率
  363.   #--------------------------------------------------------------------------
  364.   def absorb_mp_rate
  365.     create_add_equipment_options_cache if @__absorb_mp_rate == nil
  366.     return @__absorb_mp_rate
  367.   end
  368.   #--------------------------------------------------------------------------
  369.   # ○ 属性耐性
  370.   #--------------------------------------------------------------------------
  371.   def element_resistance
  372.     create_add_equipment_options_cache if @__element_resistance == nil
  373.     return @__element_resistance
  374.   end
  375.   #--------------------------------------------------------------------------
  376.   # ○ 弱点属性
  377.   #--------------------------------------------------------------------------
  378.   def weak_element_set
  379.     create_add_equipment_options_cache if @__weak_element_set == nil
  380.     return @__weak_element_set
  381.   end
  382.   #--------------------------------------------------------------------------
  383.   # ○ 半減属性
  384.   #--------------------------------------------------------------------------
  385.   def guard_element_set
  386.     create_add_equipment_options_cache if @__guard_element_set == nil
  387.     return @__guard_element_set
  388.   end
  389.   #--------------------------------------------------------------------------
  390.   # ○ 無効属性
  391.   #--------------------------------------------------------------------------
  392.   def invalid_element_set
  393.     create_add_equipment_options_cache if @__invalid_element_set == nil
  394.     return @__invalid_element_set
  395.   end
  396.   #--------------------------------------------------------------------------
  397.   # ○ 吸収属性
  398.   #--------------------------------------------------------------------------
  399.   def absorb_element_set
  400.     create_add_equipment_options_cache if @__absorb_element_set == nil
  401.     return @__absorb_element_set
  402.   end
  403.   #--------------------------------------------------------------------------
  404.   # ○ ステート耐性
  405.   #--------------------------------------------------------------------------
  406.   def state_resistance
  407.     create_add_equipment_options_cache if @__state_resistance == nil
  408.     return @__state_resistance
  409.   end
  410. end
  411.  
  412. #==================================End Class===================================#
  413.  
  414. #==============================================================================
  415. # ■ RPG::Weapon
  416. #==============================================================================
  417.  
  418. class RPG::Weapon < RPG::BaseItem
  419.   #--------------------------------------------------------------------------
  420.   # ○ 追加オプションのキャッシュを作成
  421.   #--------------------------------------------------------------------------
  422.   def create_add_equipment_options_cache
  423.     super
  424.     @__prevent_critical = false
  425.     @__half_mp_cost = false
  426.     @__double_exp_gain = false
  427.  
  428.     @note.split(/[\r\n]+/).each { |line|
  429.       case line
  430.       when KGC::AddEquipmentOptions::Regexp::Weapon::PREVENT_CRITICAL
  431.         # クリティカル防止
  432.         @__prevent_critical = true
  433.       when KGC::AddEquipmentOptions::Regexp::Weapon::HALF_MP_COST
  434.         # 消費MP半分
  435.         @__half_mp_cost = true
  436.       when KGC::AddEquipmentOptions::Regexp::Weapon::DOUBLE_EXP_GAIN
  437.         # 取得経験値2倍
  438.         @__double_exp_gain = true
  439.       end
  440.     }
  441.   end
  442.   #--------------------------------------------------------------------------
  443.   # ○ 装備オプション [クリティカル防止]
  444.   #--------------------------------------------------------------------------
  445.   def prevent_critical
  446.     create_add_equipment_options_cache if @__prevent_critical == nil
  447.     return @__prevent_critical
  448.   end
  449.   #--------------------------------------------------------------------------
  450.   # ○ 装備オプション [消費MP半分]
  451.   #--------------------------------------------------------------------------
  452.   def half_mp_cost
  453.     create_add_equipment_options_cache if @__half_mp_cost == nil
  454.     return @__half_mp_cost
  455.   end
  456.   #--------------------------------------------------------------------------
  457.   # ○ 装備オプション [取得経験値2倍]
  458.   #--------------------------------------------------------------------------
  459.   def double_exp_gain
  460.     create_add_equipment_options_cache if @__double_exp_gain == nil
  461.     return @__double_exp_gain
  462.   end
  463. end
  464.  
  465. #==================================End Class===================================#
  466.  
  467. #==============================================================================
  468. # ■ RPG::Armor
  469. #==============================================================================
  470.  
  471. class RPG::Armor < RPG::BaseItem
  472.   #--------------------------------------------------------------------------
  473.   # ○ 追加オプションのキャッシュを作成
  474.   #--------------------------------------------------------------------------
  475.   def create_add_equipment_options_cache
  476.     super
  477.     @__fast_attack = false
  478.     @__dual_attack = false
  479.     @__critical_bonus = false
  480.     @__attack_element_set = []
  481.     @__plus_state_set = []
  482.  
  483.     @note.split(/[\r\n]+/).each { |line|
  484.       case line
  485.       when KGC::AddEquipmentOptions::Regexp::Armor::FAST_ATTACK
  486.         # ターン内先制
  487.         @__fast_attack = true
  488.       when KGC::AddEquipmentOptions::Regexp::Armor::DUAL_ATTACK
  489.         # 連続攻撃
  490.         @__dual_attack = true
  491.       when KGC::AddEquipmentOptions::Regexp::Armor::CRITICAL_BONUS
  492.         # クリティカル頻発
  493.         @__critical_bonus = true
  494.       when KGC::AddEquipmentOptions::Regexp::Armor::ATTACK_ELEMENT
  495.         # 攻撃属性
  496.         $1.scan(/\d+/).each { |num|
  497.           @__attack_element_set << num.to_i
  498.         }
  499.       when KGC::AddEquipmentOptions::Regexp::Armor::PLUS_STATE
  500.         # 付加ステート
  501.         $1.scan(/\d+/).each { |num|
  502.           @__plus_state_set << num.to_i
  503.         }
  504.       end
  505.     }
  506.   end
  507.   #--------------------------------------------------------------------------
  508.   # ○ 装備オプション [ターン内先制]
  509.   #--------------------------------------------------------------------------
  510.   def fast_attack
  511.     create_add_equipment_options_cache if @__fast_attack == nil
  512.     return @__fast_attack
  513.   end
  514.   #--------------------------------------------------------------------------
  515.   # ○ 装備オプション [連続攻撃]
  516.   #--------------------------------------------------------------------------
  517.   def dual_attack
  518.     create_add_equipment_options_cache if @__dual_attack == nil
  519.     return @__dual_attack
  520.   end
  521.   #--------------------------------------------------------------------------
  522.   # ○ 装備オプション [クリティカル頻発]
  523.   #--------------------------------------------------------------------------
  524.   def critical_bonus
  525.     create_add_equipment_options_cache if @__critical_bonus == nil
  526.     return @__critical_bonus
  527.   end
  528.   #--------------------------------------------------------------------------
  529.   # ● 装備オプション [HP自動回復]
  530.   #--------------------------------------------------------------------------
  531.   def auto_hp_recover
  532.     return (@auto_hp_recover || super)
  533.   end
  534.   #--------------------------------------------------------------------------
  535.   # ○ 攻撃属性
  536.   #--------------------------------------------------------------------------
  537.   def attack_element_set
  538.     create_add_equipment_options_cache if @__attack_element_set == nil
  539.     return @__attack_element_set
  540.   end
  541.   #--------------------------------------------------------------------------
  542.   # ○ 付加ステート
  543.   #--------------------------------------------------------------------------
  544.   def plus_state_set
  545.     create_add_equipment_options_cache if @__plus_state_set == nil
  546.     return @__plus_state_set
  547.   end
  548. end
  549.  
  550. #==================================End Class===================================#
  551.  
  552. #==============================================================================
  553. # ■ Game_Battler
  554. #==============================================================================
  555.  
  556. class Game_Battler
  557.   #--------------------------------------------------------------------------
  558.   # ○ 攻撃回数の取得
  559.   #--------------------------------------------------------------------------
  560.   def multi_attack_count
  561.     return 1
  562.   end
  563.   #--------------------------------------------------------------------------
  564.   # ● 通常攻撃によるダメージ計算
  565.   #     attacker : 攻撃者
  566.   #    結果は @hp_damage に代入する。
  567.   #--------------------------------------------------------------------------
  568.   alias make_attack_damage_value_KGC_AddEquipmentOptions make_attack_damage_value unless $@
  569.   def make_attack_damage_value(attacker)
  570.     make_attack_damage_value_KGC_AddEquipmentOptions(attacker)
  571.  
  572.     make_convert_mp_value(attacker)
  573.     make_absorb_mp_value(attacker)
  574.   end
  575.   #--------------------------------------------------------------------------
  576.   # ● スキルまたはアイテムによるダメージ計算
  577.   #     user : スキルまたはアイテムの使用者
  578.   #     obj  : スキルまたはアイテム
  579.   #    結果は @hp_damage または @mp_damage に代入する。
  580.   #--------------------------------------------------------------------------
  581.   alias make_obj_damage_value_KGC_AddEquipmentOptions make_obj_damage_value unless $@
  582.   def make_obj_damage_value(user, obj)
  583.     make_obj_damage_value_KGC_AddEquipmentOptions(user, obj)
  584.  
  585.     make_convert_mp_value(user, obj)
  586.     make_absorb_mp_value(user, obj)
  587.   end
  588.   #--------------------------------------------------------------------------
  589.   # ○ MP 転換率の計算
  590.   #--------------------------------------------------------------------------
  591.   def calc_convert_mp_rate
  592.     return 0
  593.   end
  594.   #--------------------------------------------------------------------------
  595.   # ○ MP 吸収率の計算
  596.   #--------------------------------------------------------------------------
  597.   def calc_absorb_mp_rate
  598.     return 0
  599.   end
  600.   #--------------------------------------------------------------------------
  601.   # ○ MP 転換効果の適用
  602.   #     user : 攻撃者
  603.   #     obj  : スキルまたはアイテム (nil なら通常攻撃)
  604.   #    結果は @hp_damage または @mp_damage に代入する。
  605.   #--------------------------------------------------------------------------
  606.   def make_convert_mp_value(user, obj = nil)
  607.     return if @hp_damage <= 0  # 回復する場合は転換しない
  608.  
  609.     rate = calc_convert_mp_rate
  610.     return if rate == 0        # 転換率が 0 なら転換しない
  611.  
  612.     @mp_damage -= [@hp_damage * rate / 100, 1].max
  613.   end
  614.   #--------------------------------------------------------------------------
  615.   # ○ MP 吸収効果の適用
  616.   #     user : 攻撃者
  617.   #     obj  : スキルまたはアイテム (nil なら通常攻撃)
  618.   #    結果は @hp_damage または @mp_damage に代入する。
  619.   #--------------------------------------------------------------------------
  620.   def make_absorb_mp_value(user, obj = nil)
  621.     return unless mp_absorb?(user, obj)
  622.  
  623.     # HP ダメージを MP 回復値に変換
  624.     rate = elements_max_rate( (obj == nil ? user : obj).element_set )
  625.     rate = rate.abs * calc_absorb_mp_rate / 100
  626.     @mp_damage -= [@hp_damage.abs * rate / 100, 1].max
  627.     @hp_damage = 0
  628.   end
  629.   #--------------------------------------------------------------------------
  630.   # ○ MP 吸収判定
  631.   #     user : 攻撃者
  632.   #     obj  : スキルまたはアイテム (nil なら通常攻撃)
  633.   #--------------------------------------------------------------------------
  634.   def mp_absorb?(user, obj = nil)
  635.     if obj.is_a?(RPG::UsableItem)
  636.       return false if obj.base_damage < 0     # 回復なら吸収しない
  637.       if obj.is_a?(RPG::Item)
  638.         # 回復アイテムなら吸収しない
  639.         return false if obj.hp_recovery_rate > 0 || obj.hp_recovery > 0
  640.       end
  641.     end
  642.     return false if calc_absorb_mp_rate == 0  # 吸収率が 0 なら吸収しない
  643.     rate = elements_max_rate( (obj == nil ? user : obj).element_set )
  644.     return false if rate >= 0                 # 有効な属性なら吸収しない
  645.  
  646.     return true
  647.   end
  648. end
  649.  
  650. #==================================End Class===================================#
  651.  
  652. #==============================================================================
  653. # ■ Game_BattleAction
  654. #==============================================================================
  655.  
  656. class Game_BattleAction
  657.   #--------------------------------------------------------------------------
  658.   # ● 通常攻撃のターゲット作成
  659.   #--------------------------------------------------------------------------
  660.   alias make_attack_targets_KGC_AddEquipmentOptions make_attack_targets unless $@
  661.   def make_attack_targets
  662.     buf = make_attack_targets_KGC_AddEquipmentOptions
  663.     targets = buf.clone
  664.  
  665.     # n 回攻撃
  666.     (battler.multi_attack_count - 1).times { targets += buf }
  667.     return targets
  668.   end
  669. end
  670.  
  671. #==================================End Class===================================#
  672.  
  673. #==============================================================================
  674. # ■ Game_Actor
  675. #==============================================================================
  676.  
  677. class Game_Actor < Game_Battler
  678.   #--------------------------------------------------------------------------
  679.   # ● 属性修正値の取得
  680.   #     element_id : 属性 ID
  681.   #--------------------------------------------------------------------------
  682.   alias element_rate_KGC_AddEquipmentOptions element_rate unless $@
  683.   def element_rate(element_id)
  684.     result = element_rate_KGC_AddEquipmentOptions(element_id)
  685.  
  686.     # 耐性の適用
  687.     result = result * element_resistance(element_id) / 100
  688.  
  689.     absorb_flag = (result < 0)
  690.     result = result.abs
  691.     equips.compact.each { |item|
  692.       if item.invalid_element_set.include?(element_id)  # 無効
  693.         result = 0
  694.         break
  695.       end
  696.       if item.guard_element_set.include?(element_id)    # 半減
  697.         result /= 2
  698.       end
  699.       if item.weak_element_set.include?(element_id)     # 弱点
  700.         result = result * 3 / 2
  701.       end
  702.       absorb_flag |= item.absorb_element_set.include?(element_id)  # 吸収フラグ
  703.     }
  704.     result = -result if absorb_flag
  705.     return result
  706.   end
  707.   #--------------------------------------------------------------------------
  708.   # ○ 属性耐性の取得
  709.   #     element_id : 属性 ID
  710.   #--------------------------------------------------------------------------
  711.   def element_resistance(element_id)
  712.     n = 100
  713.     equips.compact.each { |item|
  714.       if item.element_resistance[element_id] != nil
  715.         n += item.element_resistance[element_id] - 100
  716.       end
  717.     }
  718.     return n
  719.   end
  720.   #--------------------------------------------------------------------------
  721.   # ● ステートの付加成功率の取得
  722.   #     state_id : ステート ID
  723.   #--------------------------------------------------------------------------
  724.   alias state_probability_KGC_AddEquipmentOptions state_probability unless $@
  725.   def state_probability(state_id)
  726.     result = state_probability_KGC_AddEquipmentOptions(state_id)
  727.  
  728.     return result * state_resistance(state_id) / 100
  729.   end
  730.   #--------------------------------------------------------------------------
  731.   # ○ ステート耐性の取得
  732.   #     state_id : ステート ID
  733.   #--------------------------------------------------------------------------
  734.   def state_resistance(state_id)
  735.     n = 100
  736.     equips.compact.each { |item|
  737.       if item.state_resistance[state_id] != nil
  738.         n += item.state_resistance[state_id] - 100
  739.       end
  740.     }
  741.     return [n, 0].max
  742.   end
  743.   #--------------------------------------------------------------------------
  744.   # ● 通常攻撃の属性取得
  745.   #--------------------------------------------------------------------------
  746.   alias element_set_KGC_AddEquipmentOptions element_set unless $@
  747.   def element_set
  748.     result = element_set_KGC_AddEquipmentOptions
  749.  
  750.     armors.compact.each { |armor|
  751.       result |= armor.attack_element_set
  752.     }
  753.     return result
  754.   end
  755.   #--------------------------------------------------------------------------
  756.   # ● 通常攻撃の追加効果 (ステート変化) 取得
  757.   #--------------------------------------------------------------------------
  758.   alias plus_state_set_KGC_AddEquipmentOptions plus_state_set unless $@
  759.   def plus_state_set
  760.     result = plus_state_set_KGC_AddEquipmentOptions
  761.  
  762.     armors.compact.each { |armor|
  763.       result |= armor.plus_state_set
  764.     }
  765.     return result
  766.   end
  767.   #--------------------------------------------------------------------------
  768.   # ● クリティカル率の取得
  769.   #--------------------------------------------------------------------------
  770.   alias cri_KGC_AddEquipmentOptions cri unless $@
  771.   def cri
  772.     n = cri_KGC_AddEquipmentOptions
  773.  
  774.     armors.compact.each { |armor|
  775.       n += 4 if armor.critical_bonus
  776.     }
  777.     return n
  778.   end
  779.   #--------------------------------------------------------------------------
  780.   # ○ 攻撃回数の取得
  781.   #--------------------------------------------------------------------------
  782.   def multi_attack_count
  783.     result = [1]
  784.     equips.compact.each { |item|
  785.       result << item.multi_attack_count
  786.     }
  787.     return result.max
  788.   end
  789.   #--------------------------------------------------------------------------
  790.   # ● 武器オプション [ターン内先制] の取得
  791.   #--------------------------------------------------------------------------
  792.   alias fast_attack_KGC_AddEquipmentOptions fast_attack unless $@
  793.   def fast_attack
  794.     return true if fast_attack_KGC_AddEquipmentOptions
  795.  
  796.     armors.compact.each { |armor|
  797.       return true if armor.fast_attack
  798.     }
  799.     return false
  800.   end
  801.   #--------------------------------------------------------------------------
  802.   # ● 武器オプション [連続攻撃] の取得
  803.   #--------------------------------------------------------------------------
  804.   alias dual_attack_KGC_AddEquipmentOptions dual_attack unless $@
  805.   def dual_attack
  806.     # 2回攻撃以上なら無視
  807.     return false if multi_attack_count >= 2
  808.  
  809.     return true if dual_attack_KGC_AddEquipmentOptions
  810.  
  811.     armors.compact.each { |armor|
  812.       return true if armor.dual_attack
  813.     }
  814.     return false
  815.   end
  816.   #--------------------------------------------------------------------------
  817.   # ● 防具オプション [クリティカル防止] の取得
  818.   #--------------------------------------------------------------------------
  819.   alias prevent_critical_KGC_AddEquipmentOptions prevent_critical unless $@
  820.   def prevent_critical
  821.     return true if prevent_critical_KGC_AddEquipmentOptions
  822.  
  823.     weapons.compact.each { |weapon|
  824.       return true if weapon.prevent_critical
  825.     }
  826.     return false
  827.   end
  828.   #--------------------------------------------------------------------------
  829.   # ● 防具オプション [消費 MP 半分] の取得
  830.   #--------------------------------------------------------------------------
  831.   alias half_mp_cost_KGC_AddEquipmentOptions half_mp_cost unless $@
  832.   def half_mp_cost
  833.     return true if half_mp_cost_KGC_AddEquipmentOptions
  834.  
  835.     weapons.compact.each { |weapon|
  836.       return true if weapon.half_mp_cost
  837.     }
  838.     return false
  839.   end
  840.   #--------------------------------------------------------------------------
  841.   # ● 防具オプション [取得経験値 2 倍] の取得
  842.   #--------------------------------------------------------------------------
  843.   alias double_exp_gain_KGC_AddEquipmentOptions double_exp_gain unless $@
  844.   def double_exp_gain
  845.     return true if double_exp_gain_KGC_AddEquipmentOptions
  846.  
  847.     weapons.compact.each { |weapon|
  848.       return true if weapon.double_exp_gain
  849.     }
  850.     return false
  851.   end
  852.   #--------------------------------------------------------------------------
  853.   # ● 防具オプション [HP 自動回復] の取得
  854.   #--------------------------------------------------------------------------
  855.   alias auto_hp_recover_KGC_AddEquipmentOptions auto_hp_recover unless $@
  856.   def auto_hp_recover
  857.     return true if auto_hp_recover_KGC_AddEquipmentOptions
  858.  
  859.     weapons.compact.each { |weapon|
  860.       return true if weapon.auto_hp_recover
  861.     }
  862.     return false
  863.   end
  864.   #--------------------------------------------------------------------------
  865.   # ● 装備オプション [MP 自動回復] の取得
  866.   #--------------------------------------------------------------------------
  867.   def auto_mp_recover
  868.     equips.compact.each { |item|
  869.       return true if item.auto_mp_recover
  870.     }
  871.     return false
  872.   end
  873.   #--------------------------------------------------------------------------
  874.   # ○ HP 自動回復量の取得
  875.   #--------------------------------------------------------------------------
  876.   def auto_hp_recover_value
  877.     value = 0
  878.     rate = 0
  879.     equips.compact.each { |item|
  880.       value += item.auto_hp_recover_value
  881.       rate  += item.auto_hp_recover_rate
  882.     }
  883.     # 回復量を算出
  884.     if value == 0 && rate == 0
  885.       n = maxhp * KGC::AddEquipmentOptions::DEFAULT_RECOVER_HP_RATE / 100
  886.     else
  887.       n = value + (maxhp * rate / 100)
  888.     end
  889.     return [n, 1].max
  890.   end
  891.   #--------------------------------------------------------------------------
  892.   # ○ MP 自動回復量の取得
  893.   #--------------------------------------------------------------------------
  894.   def auto_mp_recover_value
  895.     value = 0
  896.     rate = 0
  897.     equips.compact.each { |item|
  898.       value += item.auto_mp_recover_value
  899.       rate  += item.auto_mp_recover_rate
  900.     }
  901.     # 回復量を算出
  902.     if value == 0 && rate == 0
  903.       n = maxmp * KGC::AddEquipmentOptions::DEFAULT_RECOVER_MP_RATE / 100
  904.     else
  905.       n = value + (maxmp * rate / 100)
  906.     end
  907.     return [n, 1].max
  908.   end
  909.   #--------------------------------------------------------------------------
  910.   # ● 自動回復の実行 (ターン終了時に呼び出し)
  911.   #--------------------------------------------------------------------------
  912.   def do_auto_recovery
  913.     return if dead?
  914.  
  915.     self.hp += auto_hp_recover_value if auto_hp_recover
  916.     self.mp += auto_mp_recover_value if auto_mp_recover
  917.   end
  918.   #--------------------------------------------------------------------------
  919.   # ○ MP 転換率の計算
  920.   #--------------------------------------------------------------------------
  921.   def calc_convert_mp_rate
  922.     n = 0
  923.     equips.compact.each { |item| n += item.convert_mp_rate }
  924.     return n
  925.   end
  926.   #--------------------------------------------------------------------------
  927.   # ○ MP 吸収率の計算
  928.   #--------------------------------------------------------------------------
  929.   def calc_absorb_mp_rate
  930.     n = 0
  931.     equips.compact.each { |item| n += item.absorb_mp_rate }
  932.     return n
  933.   end
  934. end
  935.  
  936. #==================================End Class===================================#
  937.  
  938. #==============================================================================
  939. # ■ Scene_Battle
  940. #==============================================================================
  941.  
  942. class Scene_Battle < Scene_Base
  943.   #--------------------------------------------------------------------------
  944.   # ● HP ダメージ表示
  945.   #     target : 対象者
  946.   #     obj    : スキルまたはアイテム
  947.   #--------------------------------------------------------------------------
  948.   alias display_hp_damage_KGC_AddEquipmentOptions display_hp_damage unless $@
  949.   def display_hp_damage(target, obj = nil)
  950.     if target.hp_damage == 0 && target.mp_damage < 0
  951.       return if target.mp_absorb?(@active_battler, obj)  # MP 吸収
  952.     end
  953.  
  954.     display_hp_damage_KGC_AddEquipmentOptions(target, obj)
  955.   end
  956. end
Advertisement
Add Comment
Please, Sign In to add comment