Effect Manager-Tsukihime
This script is aimed at developers that wish to write and add more effects to the game, but find it too tedious to do so. It is also useful for users that are not as proficient with ruby to write their own effects without having to worry about all the technical stuff behind the scenes.
The script turns a potential 200 line script into one method call and one method definition.
You should place this above all custom scripts.
DownloadGet it at
Hime WorksUsageDefining new effects is a simple 3-step process
Step 1: Registering your effectAt the top of your script, add a single call to register your effect
CODE
Effect_Manager.register_effect(code, method_name, idstring)
where
`code` is a unique number that identifies your effect
`method_name` is the name of the method to invoke
`idstring` is a string that you will use to refer to your effect.
Step 2: defining the effect behaviorIn Game_Battler, define a method with the method name that you specified in step 1. Refer to the existing effect methods to see how they work. It is the same format.
Step 3: Tagging your items/skillsTag your items/skills with the following note tag:
CODE
<eff: idstring data_id value1 value2>
where
`idstring` is the name of the effect you wrote in step 1
`data_id` is an integer stored in the effect if you need it
`value1` is an integer and stored in the effect
`value2` is another integer and stored in the effect
And that's it. Note that currently the data types are all integers. I am not really sure how to enforce type checking or anything related to types, so for now I made it very simple and just used integers only.
ExampleHere is a quick "drain effect" script I put together to demonstrate how to use the effect manager.
Notice at the top that I make a two calls to register two of my effects, and then in Game_Battler I simply define how the effect should behave.
How much easier can it get? Note that this doesn't change battle log, so unfortunately you won't have nice messages there. Maybe in the future there will be a way to register messages as well. In fact, I am thinking of adding an extra "show_effect_messages" call to the battle log which would iterate over any effect messages that should be shown.
CODE
module Tsuki
module Drain_Effects
# register effects
Effect_Manager.register_effect(100, :item_effect_drain_hp, "hp_drain")
Effect_Manager.register_effect(101, :item_effect_drain_mp, "mp_drain")
# Other config for this script
end
end
class Game_Battler
def item_effect_drain_hp(user, item, effect)
value = effect.value1.to_i
@result.hp_drain += value
@result.success = true
user.hp = [user.hp + [value, self.hp].min, user.mhp].min
self.hp = [self.hp - value, 0].max
end
def item_effect_drain_mp(user, item, effect)
value = effect.value1.to_i
@result.mp_drain += value
@result.success = true
user.mp = [user.mp + [value, self.mp].min, user.mmp].min
self.mp = [self.mp - value, 0].max
end
end
To test the drain effect, simply tag an item/skill with the following note:
CODE
<eff: hp_drain 0 30 0> # drain 30 HP
<eff: mp_drain 0 200 0> # drain 200 MP
Notice that the name of the effect is the idstring that I specified when I registered the plugin. This makes it easy to identify which effect you are calling.
This post has been edited by Tsukihime: Mar 19 2013, 10:18 AM