=begin
#===============================================================================
Title: Gain Exp Effect
Author: Hime
Date: May 7, 2015
--------------------------------------------------------------------------------
** Change log
May 7, 2015
- 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 an effect for your skills and items that
will add (or remove) exp from the target.
--------------------------------------------------------------------------------
** Installation
In the script editor (F11), place this script below Materials and above Main
--------------------------------------------------------------------------------
** Usage
Add the note-tag to skills or items
FORMULA
Where the FORMULA is any valid formula that determines how much EXP you
will gain or lose.
The following formula variables are supported
a - user of the item/skill
b - target of the item/skill (the one that will gain/lose exp
v - game variables
s - game switches
p - game party
t - game troop
#===============================================================================
=end
$imported = {} if $imported.nil?
$imported[:th_gain_exp_effect] = true
#===============================================================================
# ** Configuration
#===============================================================================
module TH
class Gain_Exp_Effect
Regex = /(.+?)<\/eff:\s*gain[-_ ]exp>/im
end
end
#===============================================================================
# ** Rest of script
#===============================================================================
module RPG
class UsableItem
alias :th_gain_exp_effect_effects :effects
def effects
load_notetag_effects_gain_exp unless @exp_gain_effects_parsed
th_gain_exp_effect_effects
end
def load_notetag_effects_gain_exp
@exp_gain_effects_parsed = true
results = self.note.scan(TH::Gain_Exp_Effect::Regex)
results.each do |res|
code = :GAIN_EXP
formula = res[0]
self.effects << RPG::UsableItem::Effect.new(code, 0, formula)
end
end
end
class UsableItem::Effect
def eval_exp_gain(a, b, s=$game_switches, v=$game_variables, t=$game_troop, p=$game_party)
eval(self.value1)
end
end
end
class Game_Battler
alias :th_gain_exp_effect_item_effect_apply :item_effect_apply
def item_effect_apply(user, item, effect)
if effect.code == :GAIN_EXP
item_effect_gain_exp(user, item, effect)
else
th_gain_exp_effect_item_effect_apply(user, item, effect)
end
end
def item_effect_gain_exp(user, item, effect)
# stub
end
end
class Game_Actor < Game_Battler
def item_effect_gain_exp(user, item, effect)
exp = effect.eval_exp_gain(user, self)
self.gain_exp(exp)
end
end