Submit Your Article


 
RPG Maker

Welcome Guest ( Log In | Register )


  Games Resources RPG Maker VX RPG Maker XP Scripts Tutorials Downloads

 
Reply to this topicStart new topic
> Effect Manager
Tsukihime
post Oct 2 2012, 09:19 PM
Post #1


Level 25
Group Icon

Group: Revolutionary
Posts: 560
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
   
Tsukihime
post Nov 3 2012, 02:38 PM
Post #2


Level 25
Group Icon

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




This script is currently v2.2 and there are a couple dozen plugins written for it.
I've implemented the following features:

1. Effect Types: defined by the type of effect object it is assigned to. Actors, Classes, Skills, items, Weapons, Armors, Enemies, States, Class Learning
2. Effect Triggers. Many different types of triggers, activated at different times.

CODE
* attack       - triggered when you perform a skill on a battler
* guard        - triggered when you are the target of a skill or item
* critical     - triggered when a critical hit is inflicted
* level_up     - when you increase a level
* level_down   - when you decrease a level
* battle_start - triggered at the beginning of the battle
* battle_end   - triggered at the end of the battle
* turn_start   - triggered at the start of each turn
* turn_end     - triggered at the end of each turn
* equip        - equip trigger. When you equip a weapon/armor
* unequip      - equip trigger. When you unequip a weapon/armor
* add          - state trigger. When a state is added
* remove       - state trigger. When a state is removed.
* global       - special trigger. When an item/skill is used


3. Effect Callbacks. Pass your effect to other scenes and then trigger the effect after making choices

4. Effect Conditions. Activate a trigger only if the condition has been met.

All plugins I have written can be found on my blog page.


__________________________
My Scripts
Go to the top of the page
 
+Quote Post
   
spikeof2010
post Nov 29 2012, 04:31 AM
Post #3



Group Icon

Group: Member
Posts: 1
Type: None
RM Skill: Beginner




So basically, allows you to create custom effects to make more statuses (statii)?
Go to the top of the page
 
+Quote Post
   
Tsukihime
post Dec 1 2012, 12:02 PM
Post #4


Level 25
Group Icon

Group: Revolutionary
Posts: 560
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: 22nd May 2013 - 02:30 AM
RPG RPG Revolution is an Privacy Policy and Legal
eXTReMe Tracker