Submit Your Article


 
RPG Maker

Welcome Guest ( Log In | Register )


  Games Resources RPG Maker VX RPG Maker XP Scripts Tutorials Downloads

> Effect Manager
Tsukihime
post Oct 2 2012, 09:19 PM
Post #1


Level 25
Group Icon

Group: Revolutionary
Posts: 565
Type: None
RM Skill: Undisclosed
Rev Points: 25




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.

Download

Get it at Hime Works

Usage

Defining new effects is a simple 3-step process

Step 1: Registering your effect

At 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 behavior

In 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/skills

Tag 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.

Example

Here 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


__________________________
My Scripts
Go to the top of the page
 
+Quote Post
   
 
Start new topic
Replies
Tsukihime
post Dec 1 2012, 12:02 PM
Post #2


Level 25
Group Icon

Group: Revolutionary
Posts: 565
Type: None
RM Skill: Undisclosed
Rev Points: 25




Yes, and basically anything that should be triggered after a certain condition is met.


__________________________
My Scripts
Go to the top of the page
 
+Quote Post
   



Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 

Lo-Fi Version Time is now: 18th June 2013 - 01:39 PM
RPG RPG Revolution is an Privacy Policy and Legal
eXTReMe Tracker