=begin #=============================================================================== Title: TP Damage Type Author: Hime Date: Nov 5, 2013 -------------------------------------------------------------------------------- ** Change log Nov 5, 2013 - 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 * Credits to Hime Works in your project * Preserve this header -------------------------------------------------------------------------------- ** Description This script allows you to create skills or items that perform TP related damage types. You can directly damage a target's TP, or recover the target's TP, or even drain the target's TP. -------------------------------------------------------------------------------- ** Installation In the script editor, place this script below Materials and above Main -------------------------------------------------------------------------------- ** Usage Note-tag your skills or items with the following tags to set the appropriate damage type. It should be self-explanatory what they do. #=============================================================================== =end $imported = {} if $imported.nil? $imported["TH_TPDamageType"] = true #=============================================================================== # ** Configuration #=============================================================================== module TH module TP_Damage_Type Damage_Regex = //i Recover_Regex = //i Drain_Regex = //i end end #=============================================================================== # ** Rest of script #=============================================================================== module RPG class UsableItem::Damage def to_tp? [:tp_damage, :tp_drain, :tp_recover].include?(@type) end alias :th_tp_damage_type_recover? :recover? def recover? return true if @type == :tp_recover th_tp_damage_type_recover? end alias :th_tp_damage_type_drain? :drain? def drain? return true if @type == :tp_drain th_tp_damage_type_drain? end end class UsableItem < BaseItem alias :th_tp_damage_type_damage :damage def damage load_notetag_tp_damage_type th_tp_damage_type_damage end #--------------------------------------------------------------------------- # load any damage related note-tags #--------------------------------------------------------------------------- def load_notetag_tp_damage_type damage = th_tp_damage_type_damage if self.note =~ TH::TP_Damage_Type::Damage_Regex damage.type = :tp_damage elsif self.note =~ TH::TP_Damage_Type::Recover_Regex damage.type = :tp_recover elsif self.note =~ TH::TP_Damage_Type::Drain_Regex damage.type = :tp_drain end @damage = damage end end end class Game_ActionResult attr_accessor :tp_drain #----------------------------------------------------------------------------- # TP damage is handled by the "TP damage" effect #----------------------------------------------------------------------------- alias :th_damage_type_clear_damage_values :clear_damage_values def clear_damage_values th_damage_type_clear_damage_values @tp_drain = 0 end alias :th_tp_damage_type_make_damage :make_damage def make_damage(value, item) th_tp_damage_type_make_damage(value, item) @tp_damage = value if item.damage.to_tp? @tp_drain = @tp_damage if item.damage.drain? @tp_drain = [@battler.tp, @tp_drain].min # re-check action success @success = true if @tp_damage != 0 end end class Game_Battler < Game_BattlerBase alias :th_tp_damage_type_execute_damage :execute_damage def execute_damage(user) th_tp_damage_type_execute_damage(user) self.tp -= @result.tp_damage user.tp += @result.tp_drain end end