=begin #============================================================================== ** Effect: Blue Magic Author: Hime Date: Oct 14, 2012 ------------------------------------------------------------------------------ ** Change log Oct 14, 2012 - added option to learn skills after battle is over Oct 10, 2012 - added support for class effect - 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 "Blue Magic" effect to an armor or class. When this effect is active, any blue magic used on the battler will be learned by the battler. Tag your armor or class with Tag your skills with If they should be treated as blue magic #============================================================================== =end $imported = {} if $imported.nil? $imported["Effect_BlueMagic"] = true #============================================================================== # ** Configuration #============================================================================== module Effects module Blue_Magic # Learn new skills at the end of the battle? Battle_End_Learn = false #============================================================================== # ** Rest of the script #============================================================================== Effect_Manager.register_effect(:blue_magic) Blue_Magic_Regex = //i end end module RPG class Skill def is_blue_magic? return @blue_magic_type unless @blue_magic_type.nil? res = Effects::Blue_Magic::Blue_Magic_Regex.match(self.note) return @blue_magic_type = !res.nil? end end end module BattleManager class << self alias :eff_blue_magic_display_exp :display_exp end def self.display_exp eff_blue_magic_display_exp $game_party.battle_members.each {|actor| actor.learn_queued_blue_magic } end end class Game_Battler < Game_BattlerBase def armor_effect_blue_magic_guard(user, armor, effect) end end class Game_Enemy def class_effect_blue_magic_attack(user, cls, effect) end end class Game_Actor < Game_Battler alias :eff_blue_magic_init :initialize def initialize(actor_id) eff_blue_magic_init(actor_id) @blue_magic_queue = [] # blue magic to learn end def armor_effect_blue_magic_guard(user, armor, effect) if user.current_action if Effects::Blue_Magic::Battle_End_Learn queue_learn_blue_magic(user.current_action.item) else effect_learn_blue_magic(user.current_action.item) end end end def class_effect_blue_magic_guard(user, cls, effect) if user.current_action item = user.current_action.item return unless item.is_a?(RPG::Skill) && item.is_blue_magic? && !skill_learn?(item) if Effects::Blue_Magic::Battle_End_Learn queue_learn_blue_magic(item) else effect_learn_blue_magic(item) end end end # Learn the blue magic as an effect def effect_learn_blue_magic(item) learn_skill(item.id) @result.effect_results.push("%s learned %s!" %[self.name, item.name]) @result.success = true end # Add skill to blue magic list def queue_learn_blue_magic(item) return unless item.is_a?(RPG::Skill) @blue_magic_queue << item end def learn_queued_blue_magic @blue_magic_queue.each {|skill| learn_skill(skill.id) $game_message.add("%s learned %s!" %[self.name, skill.name]) } end alias :eff_blue_magic_action_battle_start :on_battle_start def on_battle_start eff_blue_magic_action_battle_start @blue_magic_queue.clear end alias :eff_blue_magic_battle_end :on_battle_end def on_battle_end @blue_magic_queue.clear eff_blue_magic_battle_end end end