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.
Script: download here
The general note-tag for all effects is
<eff: effect_name arg1 arg2 arg3 ... >
Where the arguments are specified by each effect plugin.
All effects support trigger-specific note-tags, which is of the form
<eff: effect_name-triggerType arg1 arg2 arg3 ... >
For example, if you want an effect to only activate by attack triggers, you would write
<eff: effect_name-attack arg1 arg2 ... >
See the script for more details on which triggers are available. If you don’t specify the trigger, then all methods defined in the effect are activated whenever any trigger is run.
I spent about 15 minutes planning and writing an Effect Manager for RMVX Ace.
Then I spent another 15 minutes thinking about ways to improve it, and ended up adding in custom effect messages for the battle log and allowing you to pass in an arbitrary number of arguments which will be stored in the RPG::UsableItem::Effect object as an array of strings.
Next, I want to apply this plugin-based design to allow you to write a method that will let you determine how to store the arguments, because you may want to type cast them first rather than type casting them everytime you run the effect.
The script is remarkably simple:
- It replaces just one method. In Game_Battler, I changed the `item_effect_apply` method to point to a different hash which I dynamically generate using the plugin interface.
- I provide a single method, Effect_Manager.register_effect, that allows you to quickly register your effect. This involves choosing an effect code, a method name, as well as an idstring for your effect
- You then just implement the method you reference above, and then you’re done!
I quickly wrote up 3 scripts using these effects based on a couple completed scripts that seemed to be having a couple issues, or at least, were just very long and complex.
Effect: Rare Candy – a simple script based on the same item from the pokemon series
Effect: Gold Pouch – gives you money when you use the item. Or skill.
Effect: Steal Drops – add a “steal” effect to your item/skill to steal enemy drops
The amount of effort required to write the scripts was minimal in time, lines of code, number of aliases or overwrites, and overall complexity. Obviously I am impressed by the work I have done despite not doing a whole lot.