=begin #============================================================================== ** Effect: Mana Shield Author: Hime Date: Oct 8, 2012 ------------------------------------------------------------------------------ ** Change log Oct 8, 2012 - fixed issue where applying mana shield to ally killed them - initial release ------------------------------------------------------------------------------ ** Terms of Use * Free to use in non-commercial projects * Contact me for commercial use * No real support. The script is provided as-is * Will do bug fixes, but no compatibility patches * Features may be requested but no guarantees, especially if it is non-trivial * Preserve this header ------------------------------------------------------------------------------ Adds a "mana shield" effect to a state. When this effect is active, all damage will be directed to the battler's MP. If the battler has no MP, then HP damage will be inflicted as usual. This handles boundary cases where the amount of damage to be absorbed by MP is greater than the battler's current MP and the difference will be inflicted as HP damage. Simply tag your state with Where x is the percentage of damage that should be absorbed. By default it is 1, which means 100% You can use the variable `self` to reference the battler's attributes. The value can be greater than 1 if needed. For example if a mana shield can absorb 200% damage, then it is basically absorbing 2 damage per point of MP #============================================================================== =end $imported = {} if $imported.nil? $imported["Effect_ManaShield"] = true #============================================================================== # ** Rest of the script #============================================================================== module Effect module Mana_Shield Effect_Manager.register_effect(:mana_shield) end end class Game_Battler < Game_BattlerBase def state_effect_mana_shield_guard(user, state, effect) return if user == self mod = eval(effect.value1[0]) rescue 1 # re-do the damage count. mp_damage = [@mp * mod, @result.hp_damage].min # damage absorbed hp_damage = @result.hp_damage - mp_damage # actual HP damage # restore HP to value before damage, if any damage @hp = @result.old_hp if @result.hp_damage > 0 # now inflict damage @mp = [(@mp - mp_damage).to_i, 0].max @hp = [(@hp - hp_damage).to_i, 0].max if mp_damage > 0 @result.effect_results.push("%s's mana shield absorbed %d damage" %[self.name, mp_damage]) end @result.success = true end end