Effect Conditions

Help spread the word!Share on FacebookShare on TumblrTweet about this on TwitterShare on Google+Share on LinkedInShare on RedditFlattr the author

effectConditions1

In RPG Maker, you can assign effects to items or skills. Effects are special behaviors that occur when the item or skill is successfully executed.

For example, you can create a “Poison” skill that has a 50% chance to add a “Poison” state to the target, or you can create a “Skill Book” item that will teach a new skill to a particular actor when that actor is selected.

Now, let’s say you had a skill book that teaches Fire, but only magic users can learn it. Do you want non-magic users to be able to use the book as well? Maybe not.

In this situation, it would be useful to be able to define “conditions” that must be met in order for the skill book to be used.

This plugin allows you to define “effect conditions”, which are conditions that are given to each and every effect on an item or skill. Before an effect can be applied, all conditions must be met.

With these conditions, you can now check whether the actor that you would like to use it on is able to learn Fire!

Effect conditions are formulas, so you can create conditions on anything that you can imagine.

Download

Plugin: download here (right-click, save as)

Installation

Download the plugin and place it in the “plugins” folder in your project’s “js” folder. Then open your Plugin Manager (F10), double-click an empty row, and select the HIME_EffectConditions plugin.

Once it is in your list of plugins, turn the plugin on.

Usage

In this plugin, you will need to be able to reference effects in note-tags. This is how the number system works:

effectConditions2

To create an effect condition, note-tag skills or items with

<effect condition: ID1, ID2, ... >
  FORMULA
</effect condition>

ID1, ID2, and so on are the effects that this condition applies to. So for example if you wanted to apply the condition to the first effect, you would write

<effect condition: 1>
  FORMULA
</effect condition>

and if you wanted to apply the condition to effects 1, 3, and 4, then you would write

<effect condition: 1, 3, 4>
  FORMULA
</effect condition>

FORMULA is the condition that will be added to the specified effects.
The following formula variables are available:

 a - the user of the item/skill
 b - the target of the item/skill
 i - the item/skill being used
 v - game variables
 s - game switches
 p - game party
 t - game troop

Effect Execution Sequence

IMPORTANT: effects are applied in order from top to bottom. They are also applied AFTER damage evaluation. So for example, if your condition is on HP, the HP damage will be applied BEFORE your condition is evaluated.

This timing may result in some odd behaviors if you don’t account for it.

Example

Let’s say you had an item called “Fire Skill Book” whichteaches the “Fire” spell.

You would add one effect to the item called “Learn Skill” that will add the fire spell.

effectConditions3

Now, if you used the book on anyone, you’ll see that they learn the fire skill.

We would like to add conditions for our “Learn Skill” effect now. Let’s say that only the “Magician” and “Wizard” classes can learn it.

Assuming magican is class 2 and wizard is class 4, our effect condition would start by targeting the first effect in the list, with a formula that checks the class of the target:

<effect condition: 1>
  b.isClass($dataClasses[2]) ||
  b.isClass($dataClasses[4])
</effect condition>

Here’s how it looks in the editor:

effectConditions4

Translating the formula into natural language, it means

  is the target class 2 or class 4?

If any of those conditions are true, our effect condition is satisfied, and we can proceed to teach the target the fire spell only to actors that are class 2 or class 4.

If you try to use the item on someone that doesn’t meet the requirements, the item can’t be used (in the menu), or will do nothing (during battle)

Help spread the word!Share on FacebookShare on TumblrTweet about this on TwitterShare on Google+Share on LinkedInShare on RedditFlattr the author

You may also like...

19 Responses

  1. Leysos says:

    I’m trying to get this plugin to work in tandem with your scope change plugin. Is there any way to change the scope of a condition?

  2. Sundricat says:

    I’m encountering a problem when using Enemy Classes to give enemies a class for use in an effect condition. When the skill is used by an enemy, the produced error is “undefined is not a function” When the same skill is used by an actor, the error doesn’t occur. I already tried putting the two plugins alone and the error still occurred when an enemy used the skill.
    The effect Condition:

    a.isClass($dataClasses[24]) || a.isClass($dataClasses[27]) || a.isClass($dataClasses[28])
    </effect condition>

    • Hime says:

      There is no method “isClass”
      You can access the current class via

      a.currentClass()
      

      Which returns a Class object. If you want to check the ID, you can say

      a.currentClass().id === 24
      

      or something.

  3. Sundricat says:

    How would I make it so enemies using the skill can’t apply an effect until a switch is turned on, but actors can even if the switch is off?

    • Hime says:

      You can check whether the user is an enemy and then condition it on the switch

      a.isActor() || a.isEnemy() && $gameSwitches.value(3)

      Which means the condition is met if the user is an actor, or the user is an enemy and switch 3 is ON.

  4. Quinn says:

    Thanks so much for this, been trying to get a favorite food system working where certain foods heal certain actors more than others, this script finally made that possible. Thanks a ton!

  5. Dilo says:

    How to make it so item not consumable when doesn’t meet the requirements?

  6. xoDeathy says:

    So let’s say I wanted to make the condition based off of the Actor’s level, would I be able to?:

    a.isLevel(2)
    </effect condition>

  7. kins says:

    hello princess. first a big ty and cheer for all your work on RPG Move. hope you okay I do have a question I am looking for something that have elemental status effect. lets say I wanna create a burn status effect which gradually exhaust the target. naturally I would want that elemental effect to have the target receive 2x damage from fire physical attacks or fire magical attacks on hit only not from thunder or ice or etc attributes. If i set the parameter to magical damage it affects every attributes where i don’t want that really (”.) I’m sorry if there is already something like that somewhere please do help me I am new to the rpg world all I could figure out is that the damage taken will be from any attributes which is bad. thank you so much. have a nice day.

    • kins says:

      thanks sweetie I’ved kinda sort it out -^w^- well I think so ^_^” figured I am just your casual noob asking idiot questions but by doing some research iv’e found some interesting stuff. Gomen ne. Gao! Keep doing the good stuff Cheers <33

  8. Paul says:

    Thank you! I’ve been waiting for this one for a while. 🙂

  9. Seijiro Mafuné says:

    Can this be used to have equipment affect a skill’s damage?

    • Hime says:

      No, since effects are separate from damage.

      However, you could have equipment affect a skill’s effects though, which could have “damage”-like properties like removing a certain % of HP.

Leave a Reply

Your email address will not be published.

To create code blocks or other preformatted text, indent by four spaces:

    This will be displayed in a monospaced font. The first four 
    spaces will be stripped off, but all other whitespace
    will be preserved.
    
    Markdown is turned off in code blocks:
     [This is not a link](http://example.com)

To create not a block, but an inline code span, use backticks:

Here is some inline `code`.

For more help see http://daringfireball.net/projects/markdown/syntax