Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_
- #_/ ◆ Equipment Effects - KGC_AddEquipmentOptions ◆ VX ◆
- #_/ ◇ Last Update: 2008/04/01 ◇
- #_/ ◆ Translation by Mr. Anonymous ◆
- #_/ ◆ http://ytomy.sakura.ne.jp/ ◆
- #_/-----------------------------------------------------------------------------
- #_/ This script allows the designer to add additional effects to items, weapons
- #_/ and armor. You add effects through tags, such as <Auto HP Recover 10%>
- #_/=============================================================================
- #_/ ◆ 2008/03/29 UPDATE [KCG] ◆
- #_/ Added "MP Conversion" and "MP Absorbtion"
- #_/=============================================================================
- #_/ ◆ Instructions For Usage ◆
- #_/ To make use of these functions, you must insert the desired tag into the
- #_/ "Notes" box located in the appropriate section of the database. For
- #_/ example, you want a magic Robe to restore a small amount of MP before
- #_/ each combat round combat, you would locate the robe in the armor tab of
- #_/ the database and insert "<auto MP recover 10%>" (without quotations)
- #_/ in the note box. Simple, no? Note: Tags are case-sensitive.
- #_/
- #_/ Key:
- #_/ * Rate = Numerical value of desired outcome.
- #_/ * Modifier = Subtraction, Addition, Mulpication, etc
- #_/ * ElementalID = The number of the desired "Element Name" (See Database)
- #_/ * StateID = The number of the desired "State" (See Database)
- #_/
- #_/ ◆ Restored Combat Functions ◆
- #_/
- #_/ ◆ Shields - Headgear - Accessories Related ◆
- #_/ <auto HP recover Rate %>
- #_/ Automatically regenerate a specified percentage of HP at the beginning of
- #_/ each combat round. It can also be written without the rate and percentile.
- #_/
- #_/ <auto MP recover Rate %>
- #_/ Automatically regenerate a specified percentage of MP at the beginning of
- #_/ each combat round. It can also be written without the rate and percentile.
- #_/
- #_/ <MP absorb Rate %>
- #_/ Absorb a specified amount of MP based on a percentile of damage the actor
- #_/ recieved.
- #_/
- #_/ <MP convert Rate %>
- #_/ Converts a specified amount of MP that depends on the amount of MP the
- #_/ attacking foe uses for an attack.
- #_/
- #_/ <element resist ElementID: Modifier Rate %>
- #_/ Resist a specified amount of damage from a specified element.
- #_/ Modifier is optional.
- #_/
- #_/ <element weakness ElementID: Modifier Rate>
- #_/ Damage from specified element is increased by 1.5 times to the character
- #_/ equipped with the tagged weapon.
- #_/
- #_/ <element half ElementID>
- #_/ Damage from specified element is divided in half.
- #_/
- #_/ <element null ElementID>
- #_/ Damaged from specified element is completely nullified (cancelled).
- #_/
- #_/ <element absorb ElementID: Modifier Rate>
- #_/ Damage from specified element is completely absorbed.
- #_/
- #_/ <state resist stateID: Modifier Rate %>
- #_/ Resist a specified state.
- #_/
- #_/ ◆ Weapons Related ◆
- #_/
- #_/ <prevent critical>
- #_/ Prevent critical attacks done by equipped character.
- #_/
- #_/ <half MP cost>
- #_/ Decreases MP spent on skills by 50%.
- #_/
- #_/ <double exp>
- #_/ Increases experience points gained from defeated foes in battle by 50%.
- #_/
- #_/
- #_/ ◆ Body Gear Related ◆
- #_/ <fast attack>
- #_/ Adds "Preemptive Strike" aka "Fast Attack" to the character.
- #_/
- #_/ <dual attack>
- #_/ Adds the "Dual Attack" style to the character, allowing the character to
- #_/ equip attack twice in a row on every attack.
- #_/
- #_/ <critical bonus>
- #_/ Same as the Critical Bonus in the Actors Database.
- #_/
- #_/ <attack element ElementID>
- #_/ Adds additional elements to the character's default attack.
- #_/
- #_/ <plus state StateID>
- #_/ Adds additional status effects to the character's default attack.
- #_/=============================================================================
- #_/ Installation: Insert above Main.
- #_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_
- #==============================================================================#
- # ★ Customization ★ #
- #==============================================================================#
- module KGC
- module AddEquipmentOptions
- # ◆ <auto HP recover> Default HP Recovery Rate (Percentile)
- # (When not manually assigned)
- # Allows you to change the default amount of HP recovered per-round.
- DEFAULT_RECOVER_HP_RATE = 5
- # ◆ <auto MP recover> Default MP Recovery Rate (Percentile)
- # (When not manually assigned)
- # Allows you to change the default amount of HP recovered per-round.
- DEFAULT_RECOVER_MP_RATE = 5
- # ◆ <MP convert> Default MP Conversion Rate (Percentile)
- # (When not manually assigned)
- # Allows you to change the default amount of MP converted on damage.
- DEFAULT_CONVERT_MP_RATE = 1
- # ◆ <MP absorb> Default MP Absorbtion Rate (Percentile)
- # (When not manually assigned)
- # Allows you to change the default amount of MP absorbed on damage.
- DEFAULT_ABSORB_MP_RATE = 5
- end
- end
- ## * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * #
- # Unless you know what you're doing, it's best not to alter anything beyond #
- # this point, as this only affects the tags used for "Notes" in database. #
- # * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * #
- # Whatever word(s) are after the separator ( | ) in the following lines are
- # what are used to determine what is searched for in the "Notes" section.
- $imported = {} if $imported == nil
- $imported["AddEquipmentOptions"] = true
- module KGC::AddEquipmentOptions
- # Regular Expressions Defined
- module Regexp
- # Base Item Module
- module BaseItem
- # Multi Attack Tag String
- MULTI_ATTACK = /<(\d+)\s*(?:TIMES_ATTACK|multiatk)>/i
- # HP Automatic Recovery Tag String
- AUTO_HP_RECOVER = /<(?:AUTO_HP_RECOVER|auto HP recover)(\s*(\d+)([%%])?)?>/i
- # MP Automatic Recovery Tag String
- AUTO_MP_RECOVER = /<(?:AUTO_MP_RECOVER|auto MP recover)(\s*(\d+)([%%])?)?>/i
- # MP conversion Tag String
- CONVERT_MP = /<(?:CONVERT_MP|MP convert)\s*(\d+)?[%%]?>/i
- # MP Absorbtion Tag String
- ABSORB_MP = /<(?:ABSORB_MP|MP absorb)\s*(\d+)?[%%]?>/i
- # Attribute Resistance Tag String
- ELEMENT_RESISTANCE =
- /<(?:ELEMENT_RESISTANCE|element resist)\s*(\d+):(\-?\d+)[%%]?>/i
- # Attribute Weakness Tag String
- WEAK_ELEMENT =
- /<(?:WEAK_ELEMENT|element weakness)\s*(\d+(?:\s*,\s*\d+)*)>/i
- # Attribute Half Damage Tag String
- GUARD_ELEMENT =
- /<(?:GUARD_ELEMENT|element half)\s*(\d+(?:\s*,\s*\d+)*)>/i
- # Attribute Nullification Tag String
- INVALID_ELEMENT =
- /<(?:INVALID_ELEMENT|element null)\s*(\d+(?:\s*,\s*\d+)*)>/i
- # Attribute Absorbtion Tag String
- ABSORB_ELEMENT =
- /<(?:ABSORB_ELEMENT|element absorb)\s*(\d+(?:\s*,\s*\d+)*)>/i
- # State Resistance Tag String
- STATE_RESISTANCE =
- /<(?:STATE_RESISTANCE|state resist)\s*(\d+):(\d+)[%%]?>/i
- end
- # Base Weapon Module
- module Weapon
- # Critical Prevention Tag String
- PREVENT_CRITICAL = /<(?:PREVENT_CRITICAL|prevent critical)>/i
- # Half MP Consumption Tag String
- HALF_MP_COST = /<(?:HALF_MP_COST|half MP cost)>/i
- # Experience Gain x2 Tag String
- DOUBLE_EXP_GAIN = /<(?:DOUBLE_EXP_GAIN|double exp)>/i
- end
- # Base Armor Module
- module Armor
- # Premptive Attack Tag String
- FAST_ATTACK = /<(?:FAST_ATTACK|fast attack)>/i
- # Dual Attack Tag String
- DUAL_ATTACK = /<(?:DUAL_ATTACK|dual attack)>/i
- # Critial Bonus Tag String
- CRITICAL_BONUS = /<(?:CRITICAL_BONUS|critical bonus)>/i
- # Attack Element Tag String
- ATTACK_ELEMENT =
- /<(?:ATTACK_ELEMENT|attack element)\s*(\d+(?:\s*,\s*\d+)*)>/i
- # Status Addition Tag String
- PLUS_STATE = /<(?:PLUS_STATE|plus state)\s*(\d+(?:\s*,\s*\d+)*)>/i
- end
- end
- end
- #==============================================================================
- # ■ RPG::BaseItem
- #==============================================================================
- class RPG::BaseItem
- #--------------------------------------------------------------------------
- # ○ Additional Equipment Augmentation Compilation
- #--------------------------------------------------------------------------
- def create_add_equipment_options_cache
- @__multi_attack_count = 1
- @__auto_hp_recover = false
- @__auto_hp_recover_value = 0
- @__auto_hp_recover_rate = 0
- @__auto_mp_recover = false
- @__auto_mp_recover_value = 0
- @__auto_mp_recover_rate = 0
- @__convert_mp_rate = 0
- @__absorb_mp_rate = 0
- @note.split(/[\r\n]+/).each { |line|
- case line
- when KGC::AddEquipmentOptions::Regexp::BaseItem::MULTI_ATTACK
- # n回攻撃
- @__multi_attack_count = [$1.to_i, 1].max
- when KGC::AddEquipmentOptions::Regexp::BaseItem::AUTO_HP_RECOVER
- # HP自動回復
- @__auto_hp_recover = true
- next if $1 == nil
- if $3 != nil
- @__auto_hp_recover_rate += $2.to_i
- else
- @__auto_hp_recover_value += $2.to_i
- end
- when KGC::AddEquipmentOptions::Regexp::BaseItem::AUTO_MP_RECOVER
- # MP自動回復
- @__auto_mp_recover = true
- next if $1 == nil
- if $3 != nil
- @__auto_mp_recover_rate += $2.to_i
- else
- @__auto_mp_recover_value += $2.to_i
- end
- when KGC::AddEquipmentOptions::Regexp::BaseItem::CONVERT_MP
- # MP転換
- @__convert_mp_rate = ($1 != nil ?
- $1.to_i : KGC::AddEquipmentOptions::DEFAULT_CONVERT_MP_RATE)
- when KGC::AddEquipmentOptions::Regexp::BaseItem::ABSORB_MP
- # MP吸収
- @__absorb_mp_rate = ($1 != nil ?
- $1.to_i : KGC::AddEquipmentOptions::DEFAULT_ABSORB_MP_RATE)
- end
- }
- create_resistance_cache
- end
- #--------------------------------------------------------------------------
- # ○ 耐性のキャッシュ生成
- #--------------------------------------------------------------------------
- def create_resistance_cache
- @__element_resistance = []
- @__weak_element_set = []
- @__guard_element_set = []
- @__invalid_element_set = []
- @__absorb_element_set = []
- @__state_resistance = []
- @note.split(/[\r\n]+/).each { |line|
- case line
- when KGC::AddEquipmentOptions::Regexp::BaseItem::ELEMENT_RESISTANCE
- # 属性耐性
- element_id = $1.to_i
- value = $2.to_i
- if @__element_resistance[element_id] == nil
- @__element_resistance[element_id] = 100
- end
- @__element_resistance[element_id] -= (100 - value)
- when KGC::AddEquipmentOptions::Regexp::BaseItem::WEAK_ELEMENT
- # 弱点属性
- $1.scan(/\d+/).each { |num|
- @__weak_element_set << num.to_i
- }
- when KGC::AddEquipmentOptions::Regexp::BaseItem::GUARD_ELEMENT
- # 半減属性
- $1.scan(/\d+/).each { |num|
- @__guard_element_set << num.to_i
- }
- when KGC::AddEquipmentOptions::Regexp::BaseItem::INVALID_ELEMENT
- # 無効属性
- $1.scan(/\d+/).each { |num|
- @__invalid_element_set << num.to_i
- }
- when KGC::AddEquipmentOptions::Regexp::BaseItem::ABSORB_ELEMENT
- # 吸収属性
- $1.scan(/\d+/).each { |num|
- @__absorb_element_set << num.to_i
- }
- when KGC::AddEquipmentOptions::Regexp::BaseItem::STATE_RESISTANCE
- # ステート耐性
- state_id = $1.to_i
- value = $2.to_i
- if @__state_resistance[state_id] == nil
- @__state_resistance[state_id] = 100
- end
- @__state_resistance[state_id] -= (100 - value)
- end
- }
- end
- #--------------------------------------------------------------------------
- # ○ 攻撃回数
- #--------------------------------------------------------------------------
- def multi_attack_count
- create_add_equipment_options_cache if @__multi_attack_count == nil
- return @__multi_attack_count
- end
- #--------------------------------------------------------------------------
- # ○ 装備オプション [HP自動回復]
- #--------------------------------------------------------------------------
- def auto_hp_recover
- create_add_equipment_options_cache if @__auto_hp_recover == nil
- return @__auto_hp_recover
- end
- #--------------------------------------------------------------------------
- # ○ 装備オプション [MP自動回復]
- #--------------------------------------------------------------------------
- def auto_mp_recover
- create_add_equipment_options_cache if @__auto_mp_recover == nil
- return @__auto_mp_recover
- end
- #--------------------------------------------------------------------------
- # ○ HP 自動回復量 (即値)
- #--------------------------------------------------------------------------
- def auto_hp_recover_value
- create_add_equipment_options_cache if @__auto_hp_recover_value == nil
- return @__auto_hp_recover_value
- end
- #--------------------------------------------------------------------------
- # ○ HP 自動回復量 (割合)
- #--------------------------------------------------------------------------
- def auto_hp_recover_rate
- create_add_equipment_options_cache if @__auto_hp_recover_rate == nil
- return @__auto_hp_recover_rate
- end
- #--------------------------------------------------------------------------
- # ○ MP 自動回復量 (即値)
- #--------------------------------------------------------------------------
- def auto_mp_recover_value
- create_add_equipment_options_cache if @__auto_mp_recover_value == nil
- return @__auto_mp_recover_value
- end
- #--------------------------------------------------------------------------
- # ○ MP 自動回復量 (割合)
- #--------------------------------------------------------------------------
- def auto_mp_recover_rate
- create_add_equipment_options_cache if @__auto_mp_recover_rate == nil
- return @__auto_mp_recover_rate
- end
- #--------------------------------------------------------------------------
- # ○ MP 転換率
- #--------------------------------------------------------------------------
- def convert_mp_rate
- create_add_equipment_options_cache if @__convert_mp_rate == nil
- return @__convert_mp_rate
- end
- #--------------------------------------------------------------------------
- # ○ MP 吸収率
- #--------------------------------------------------------------------------
- def absorb_mp_rate
- create_add_equipment_options_cache if @__absorb_mp_rate == nil
- return @__absorb_mp_rate
- end
- #--------------------------------------------------------------------------
- # ○ 属性耐性
- #--------------------------------------------------------------------------
- def element_resistance
- create_add_equipment_options_cache if @__element_resistance == nil
- return @__element_resistance
- end
- #--------------------------------------------------------------------------
- # ○ 弱点属性
- #--------------------------------------------------------------------------
- def weak_element_set
- create_add_equipment_options_cache if @__weak_element_set == nil
- return @__weak_element_set
- end
- #--------------------------------------------------------------------------
- # ○ 半減属性
- #--------------------------------------------------------------------------
- def guard_element_set
- create_add_equipment_options_cache if @__guard_element_set == nil
- return @__guard_element_set
- end
- #--------------------------------------------------------------------------
- # ○ 無効属性
- #--------------------------------------------------------------------------
- def invalid_element_set
- create_add_equipment_options_cache if @__invalid_element_set == nil
- return @__invalid_element_set
- end
- #--------------------------------------------------------------------------
- # ○ 吸収属性
- #--------------------------------------------------------------------------
- def absorb_element_set
- create_add_equipment_options_cache if @__absorb_element_set == nil
- return @__absorb_element_set
- end
- #--------------------------------------------------------------------------
- # ○ ステート耐性
- #--------------------------------------------------------------------------
- def state_resistance
- create_add_equipment_options_cache if @__state_resistance == nil
- return @__state_resistance
- end
- end
- #==================================End Class===================================#
- #==============================================================================
- # ■ RPG::Weapon
- #==============================================================================
- class RPG::Weapon < RPG::BaseItem
- #--------------------------------------------------------------------------
- # ○ 追加オプションのキャッシュを作成
- #--------------------------------------------------------------------------
- def create_add_equipment_options_cache
- super
- @__prevent_critical = false
- @__half_mp_cost = false
- @__double_exp_gain = false
- @note.split(/[\r\n]+/).each { |line|
- case line
- when KGC::AddEquipmentOptions::Regexp::Weapon::PREVENT_CRITICAL
- # クリティカル防止
- @__prevent_critical = true
- when KGC::AddEquipmentOptions::Regexp::Weapon::HALF_MP_COST
- # 消費MP半分
- @__half_mp_cost = true
- when KGC::AddEquipmentOptions::Regexp::Weapon::DOUBLE_EXP_GAIN
- # 取得経験値2倍
- @__double_exp_gain = true
- end
- }
- end
- #--------------------------------------------------------------------------
- # ○ 装備オプション [クリティカル防止]
- #--------------------------------------------------------------------------
- def prevent_critical
- create_add_equipment_options_cache if @__prevent_critical == nil
- return @__prevent_critical
- end
- #--------------------------------------------------------------------------
- # ○ 装備オプション [消費MP半分]
- #--------------------------------------------------------------------------
- def half_mp_cost
- create_add_equipment_options_cache if @__half_mp_cost == nil
- return @__half_mp_cost
- end
- #--------------------------------------------------------------------------
- # ○ 装備オプション [取得経験値2倍]
- #--------------------------------------------------------------------------
- def double_exp_gain
- create_add_equipment_options_cache if @__double_exp_gain == nil
- return @__double_exp_gain
- end
- end
- #==================================End Class===================================#
- #==============================================================================
- # ■ RPG::Armor
- #==============================================================================
- class RPG::Armor < RPG::BaseItem
- #--------------------------------------------------------------------------
- # ○ 追加オプションのキャッシュを作成
- #--------------------------------------------------------------------------
- def create_add_equipment_options_cache
- super
- @__fast_attack = false
- @__dual_attack = false
- @__critical_bonus = false
- @__attack_element_set = []
- @__plus_state_set = []
- @note.split(/[\r\n]+/).each { |line|
- case line
- when KGC::AddEquipmentOptions::Regexp::Armor::FAST_ATTACK
- # ターン内先制
- @__fast_attack = true
- when KGC::AddEquipmentOptions::Regexp::Armor::DUAL_ATTACK
- # 連続攻撃
- @__dual_attack = true
- when KGC::AddEquipmentOptions::Regexp::Armor::CRITICAL_BONUS
- # クリティカル頻発
- @__critical_bonus = true
- when KGC::AddEquipmentOptions::Regexp::Armor::ATTACK_ELEMENT
- # 攻撃属性
- $1.scan(/\d+/).each { |num|
- @__attack_element_set << num.to_i
- }
- when KGC::AddEquipmentOptions::Regexp::Armor::PLUS_STATE
- # 付加ステート
- $1.scan(/\d+/).each { |num|
- @__plus_state_set << num.to_i
- }
- end
- }
- end
- #--------------------------------------------------------------------------
- # ○ 装備オプション [ターン内先制]
- #--------------------------------------------------------------------------
- def fast_attack
- create_add_equipment_options_cache if @__fast_attack == nil
- return @__fast_attack
- end
- #--------------------------------------------------------------------------
- # ○ 装備オプション [連続攻撃]
- #--------------------------------------------------------------------------
- def dual_attack
- create_add_equipment_options_cache if @__dual_attack == nil
- return @__dual_attack
- end
- #--------------------------------------------------------------------------
- # ○ 装備オプション [クリティカル頻発]
- #--------------------------------------------------------------------------
- def critical_bonus
- create_add_equipment_options_cache if @__critical_bonus == nil
- return @__critical_bonus
- end
- #--------------------------------------------------------------------------
- # ● 装備オプション [HP自動回復]
- #--------------------------------------------------------------------------
- def auto_hp_recover
- return (@auto_hp_recover || super)
- end
- #--------------------------------------------------------------------------
- # ○ 攻撃属性
- #--------------------------------------------------------------------------
- def attack_element_set
- create_add_equipment_options_cache if @__attack_element_set == nil
- return @__attack_element_set
- end
- #--------------------------------------------------------------------------
- # ○ 付加ステート
- #--------------------------------------------------------------------------
- def plus_state_set
- create_add_equipment_options_cache if @__plus_state_set == nil
- return @__plus_state_set
- end
- end
- #==================================End Class===================================#
- #==============================================================================
- # ■ Game_Battler
- #==============================================================================
- class Game_Battler
- #--------------------------------------------------------------------------
- # ○ 攻撃回数の取得
- #--------------------------------------------------------------------------
- def multi_attack_count
- return 1
- end
- #--------------------------------------------------------------------------
- # ● 通常攻撃によるダメージ計算
- # attacker : 攻撃者
- # 結果は @hp_damage に代入する。
- #--------------------------------------------------------------------------
- alias make_attack_damage_value_KGC_AddEquipmentOptions make_attack_damage_value unless $@
- def make_attack_damage_value(attacker)
- make_attack_damage_value_KGC_AddEquipmentOptions(attacker)
- make_convert_mp_value(attacker)
- make_absorb_mp_value(attacker)
- end
- #--------------------------------------------------------------------------
- # ● スキルまたはアイテムによるダメージ計算
- # user : スキルまたはアイテムの使用者
- # obj : スキルまたはアイテム
- # 結果は @hp_damage または @mp_damage に代入する。
- #--------------------------------------------------------------------------
- alias make_obj_damage_value_KGC_AddEquipmentOptions make_obj_damage_value unless $@
- def make_obj_damage_value(user, obj)
- make_obj_damage_value_KGC_AddEquipmentOptions(user, obj)
- make_convert_mp_value(user, obj)
- make_absorb_mp_value(user, obj)
- end
- #--------------------------------------------------------------------------
- # ○ MP 転換率の計算
- #--------------------------------------------------------------------------
- def calc_convert_mp_rate
- return 0
- end
- #--------------------------------------------------------------------------
- # ○ MP 吸収率の計算
- #--------------------------------------------------------------------------
- def calc_absorb_mp_rate
- return 0
- end
- #--------------------------------------------------------------------------
- # ○ MP 転換効果の適用
- # user : 攻撃者
- # obj : スキルまたはアイテム (nil なら通常攻撃)
- # 結果は @hp_damage または @mp_damage に代入する。
- #--------------------------------------------------------------------------
- def make_convert_mp_value(user, obj = nil)
- return if @hp_damage <= 0 # 回復する場合は転換しない
- rate = calc_convert_mp_rate
- return if rate == 0 # 転換率が 0 なら転換しない
- @mp_damage -= [@hp_damage * rate / 100, 1].max
- end
- #--------------------------------------------------------------------------
- # ○ MP 吸収効果の適用
- # user : 攻撃者
- # obj : スキルまたはアイテム (nil なら通常攻撃)
- # 結果は @hp_damage または @mp_damage に代入する。
- #--------------------------------------------------------------------------
- def make_absorb_mp_value(user, obj = nil)
- return unless mp_absorb?(user, obj)
- # HP ダメージを MP 回復値に変換
- rate = elements_max_rate( (obj == nil ? user : obj).element_set )
- rate = rate.abs * calc_absorb_mp_rate / 100
- @mp_damage -= [@hp_damage.abs * rate / 100, 1].max
- @hp_damage = 0
- end
- #--------------------------------------------------------------------------
- # ○ MP 吸収判定
- # user : 攻撃者
- # obj : スキルまたはアイテム (nil なら通常攻撃)
- #--------------------------------------------------------------------------
- def mp_absorb?(user, obj = nil)
- if obj.is_a?(RPG::UsableItem)
- return false if obj.base_damage < 0 # 回復なら吸収しない
- if obj.is_a?(RPG::Item)
- # 回復アイテムなら吸収しない
- return false if obj.hp_recovery_rate > 0 || obj.hp_recovery > 0
- end
- end
- return false if calc_absorb_mp_rate == 0 # 吸収率が 0 なら吸収しない
- rate = elements_max_rate( (obj == nil ? user : obj).element_set )
- return false if rate >= 0 # 有効な属性なら吸収しない
- return true
- end
- end
- #==================================End Class===================================#
- #==============================================================================
- # ■ Game_BattleAction
- #==============================================================================
- class Game_BattleAction
- #--------------------------------------------------------------------------
- # ● 通常攻撃のターゲット作成
- #--------------------------------------------------------------------------
- alias make_attack_targets_KGC_AddEquipmentOptions make_attack_targets unless $@
- def make_attack_targets
- buf = make_attack_targets_KGC_AddEquipmentOptions
- targets = buf.clone
- # n 回攻撃
- (battler.multi_attack_count - 1).times { targets += buf }
- return targets
- end
- end
- #==================================End Class===================================#
- #==============================================================================
- # ■ Game_Actor
- #==============================================================================
- class Game_Actor < Game_Battler
- #--------------------------------------------------------------------------
- # ● 属性修正値の取得
- # element_id : 属性 ID
- #--------------------------------------------------------------------------
- alias element_rate_KGC_AddEquipmentOptions element_rate unless $@
- def element_rate(element_id)
- result = element_rate_KGC_AddEquipmentOptions(element_id)
- # 耐性の適用
- result = result * element_resistance(element_id) / 100
- absorb_flag = (result < 0)
- result = result.abs
- equips.compact.each { |item|
- if item.invalid_element_set.include?(element_id) # 無効
- result = 0
- break
- end
- if item.guard_element_set.include?(element_id) # 半減
- result /= 2
- end
- if item.weak_element_set.include?(element_id) # 弱点
- result = result * 3 / 2
- end
- absorb_flag |= item.absorb_element_set.include?(element_id) # 吸収フラグ
- }
- result = -result if absorb_flag
- return result
- end
- #--------------------------------------------------------------------------
- # ○ 属性耐性の取得
- # element_id : 属性 ID
- #--------------------------------------------------------------------------
- def element_resistance(element_id)
- n = 100
- equips.compact.each { |item|
- if item.element_resistance[element_id] != nil
- n += item.element_resistance[element_id] - 100
- end
- }
- return n
- end
- #--------------------------------------------------------------------------
- # ● ステートの付加成功率の取得
- # state_id : ステート ID
- #--------------------------------------------------------------------------
- alias state_probability_KGC_AddEquipmentOptions state_probability unless $@
- def state_probability(state_id)
- result = state_probability_KGC_AddEquipmentOptions(state_id)
- return result * state_resistance(state_id) / 100
- end
- #--------------------------------------------------------------------------
- # ○ ステート耐性の取得
- # state_id : ステート ID
- #--------------------------------------------------------------------------
- def state_resistance(state_id)
- n = 100
- equips.compact.each { |item|
- if item.state_resistance[state_id] != nil
- n += item.state_resistance[state_id] - 100
- end
- }
- return [n, 0].max
- end
- #--------------------------------------------------------------------------
- # ● 通常攻撃の属性取得
- #--------------------------------------------------------------------------
- alias element_set_KGC_AddEquipmentOptions element_set unless $@
- def element_set
- result = element_set_KGC_AddEquipmentOptions
- armors.compact.each { |armor|
- result |= armor.attack_element_set
- }
- return result
- end
- #--------------------------------------------------------------------------
- # ● 通常攻撃の追加効果 (ステート変化) 取得
- #--------------------------------------------------------------------------
- alias plus_state_set_KGC_AddEquipmentOptions plus_state_set unless $@
- def plus_state_set
- result = plus_state_set_KGC_AddEquipmentOptions
- armors.compact.each { |armor|
- result |= armor.plus_state_set
- }
- return result
- end
- #--------------------------------------------------------------------------
- # ● クリティカル率の取得
- #--------------------------------------------------------------------------
- alias cri_KGC_AddEquipmentOptions cri unless $@
- def cri
- n = cri_KGC_AddEquipmentOptions
- armors.compact.each { |armor|
- n += 4 if armor.critical_bonus
- }
- return n
- end
- #--------------------------------------------------------------------------
- # ○ 攻撃回数の取得
- #--------------------------------------------------------------------------
- def multi_attack_count
- result = [1]
- equips.compact.each { |item|
- result << item.multi_attack_count
- }
- return result.max
- end
- #--------------------------------------------------------------------------
- # ● 武器オプション [ターン内先制] の取得
- #--------------------------------------------------------------------------
- alias fast_attack_KGC_AddEquipmentOptions fast_attack unless $@
- def fast_attack
- return true if fast_attack_KGC_AddEquipmentOptions
- armors.compact.each { |armor|
- return true if armor.fast_attack
- }
- return false
- end
- #--------------------------------------------------------------------------
- # ● 武器オプション [連続攻撃] の取得
- #--------------------------------------------------------------------------
- alias dual_attack_KGC_AddEquipmentOptions dual_attack unless $@
- def dual_attack
- # 2回攻撃以上なら無視
- return false if multi_attack_count >= 2
- return true if dual_attack_KGC_AddEquipmentOptions
- armors.compact.each { |armor|
- return true if armor.dual_attack
- }
- return false
- end
- #--------------------------------------------------------------------------
- # ● 防具オプション [クリティカル防止] の取得
- #--------------------------------------------------------------------------
- alias prevent_critical_KGC_AddEquipmentOptions prevent_critical unless $@
- def prevent_critical
- return true if prevent_critical_KGC_AddEquipmentOptions
- weapons.compact.each { |weapon|
- return true if weapon.prevent_critical
- }
- return false
- end
- #--------------------------------------------------------------------------
- # ● 防具オプション [消費 MP 半分] の取得
- #--------------------------------------------------------------------------
- alias half_mp_cost_KGC_AddEquipmentOptions half_mp_cost unless $@
- def half_mp_cost
- return true if half_mp_cost_KGC_AddEquipmentOptions
- weapons.compact.each { |weapon|
- return true if weapon.half_mp_cost
- }
- return false
- end
- #--------------------------------------------------------------------------
- # ● 防具オプション [取得経験値 2 倍] の取得
- #--------------------------------------------------------------------------
- alias double_exp_gain_KGC_AddEquipmentOptions double_exp_gain unless $@
- def double_exp_gain
- return true if double_exp_gain_KGC_AddEquipmentOptions
- weapons.compact.each { |weapon|
- return true if weapon.double_exp_gain
- }
- return false
- end
- #--------------------------------------------------------------------------
- # ● 防具オプション [HP 自動回復] の取得
- #--------------------------------------------------------------------------
- alias auto_hp_recover_KGC_AddEquipmentOptions auto_hp_recover unless $@
- def auto_hp_recover
- return true if auto_hp_recover_KGC_AddEquipmentOptions
- weapons.compact.each { |weapon|
- return true if weapon.auto_hp_recover
- }
- return false
- end
- #--------------------------------------------------------------------------
- # ● 装備オプション [MP 自動回復] の取得
- #--------------------------------------------------------------------------
- def auto_mp_recover
- equips.compact.each { |item|
- return true if item.auto_mp_recover
- }
- return false
- end
- #--------------------------------------------------------------------------
- # ○ HP 自動回復量の取得
- #--------------------------------------------------------------------------
- def auto_hp_recover_value
- value = 0
- rate = 0
- equips.compact.each { |item|
- value += item.auto_hp_recover_value
- rate += item.auto_hp_recover_rate
- }
- # 回復量を算出
- if value == 0 && rate == 0
- n = maxhp * KGC::AddEquipmentOptions::DEFAULT_RECOVER_HP_RATE / 100
- else
- n = value + (maxhp * rate / 100)
- end
- return [n, 1].max
- end
- #--------------------------------------------------------------------------
- # ○ MP 自動回復量の取得
- #--------------------------------------------------------------------------
- def auto_mp_recover_value
- value = 0
- rate = 0
- equips.compact.each { |item|
- value += item.auto_mp_recover_value
- rate += item.auto_mp_recover_rate
- }
- # 回復量を算出
- if value == 0 && rate == 0
- n = maxmp * KGC::AddEquipmentOptions::DEFAULT_RECOVER_MP_RATE / 100
- else
- n = value + (maxmp * rate / 100)
- end
- return [n, 1].max
- end
- #--------------------------------------------------------------------------
- # ● 自動回復の実行 (ターン終了時に呼び出し)
- #--------------------------------------------------------------------------
- def do_auto_recovery
- return if dead?
- self.hp += auto_hp_recover_value if auto_hp_recover
- self.mp += auto_mp_recover_value if auto_mp_recover
- end
- #--------------------------------------------------------------------------
- # ○ MP 転換率の計算
- #--------------------------------------------------------------------------
- def calc_convert_mp_rate
- n = 0
- equips.compact.each { |item| n += item.convert_mp_rate }
- return n
- end
- #--------------------------------------------------------------------------
- # ○ MP 吸収率の計算
- #--------------------------------------------------------------------------
- def calc_absorb_mp_rate
- n = 0
- equips.compact.each { |item| n += item.absorb_mp_rate }
- return n
- end
- end
- #==================================End Class===================================#
- #==============================================================================
- # ■ Scene_Battle
- #==============================================================================
- class Scene_Battle < Scene_Base
- #--------------------------------------------------------------------------
- # ● HP ダメージ表示
- # target : 対象者
- # obj : スキルまたはアイテム
- #--------------------------------------------------------------------------
- alias display_hp_damage_KGC_AddEquipmentOptions display_hp_damage unless $@
- def display_hp_damage(target, obj = nil)
- if target.hp_damage == 0 && target.mp_damage < 0
- return if target.mp_absorb?(@active_battler, obj) # MP 吸収
- end
- display_hp_damage_KGC_AddEquipmentOptions(target, obj)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment