Jump to content
Tsukihime

FP: Conditional Effects

Recommended Posts

FP: Conditional Effects

Author: Tsukihime

 

Overview

 

Ever wanted to make sure that item/skill effects are only activated when certain conditions are met?

 

Features

  • Specify that critical hit must occur in order to activate effects
  • Specify that a formula must be satisfied to activate effects

Usage

 

The critical condition is straightforward: if your attack was a critical hit, the effects will be activated. Otherwise, they won't.

 

Just tag your skills/items with

 

<fp:ce crit-hit>

 

Now...the real functionality in this script comes with formulas.

To specify a formula, use the tag

 

<fp:ce f [formula]>

 

For the formula, it is a little more challenging. You will need some knowledge of ruby syntax (mainly comparisons), and you will need to be able to do basic math. But it is straightforward if you know what they are.

 

All formulas must be in the form of truth statements. That is, they must evaluate to true or false.

 

The operators that you will be using are

 

<=  less than or equal to
<   less than
>=  greater or equal to
>   greater than
==  equal
!=  not equal

 

Of course, you are not limited to comparison. Any ruby statement that evaluates to true or false is valid, for example checking for substrings:

 

<fp:ce a.name.include?("slime")>

 

You will likely be using math operators

 

+   add
-   subtract
*   multiply
/   divide. Returns the quotient of a division operation
%   mod. Returns the remainder of a division operation

 

The keywords are "a" and "b", where a is user, and b are the target(s).

You can also specify variables using "v" and switches using "s"

Let's look at some simple truth statements:

 

<fp:ce f a.atk < b.def>

 

This means that the effects will only activate when the user's attack is less than the target's defense. Might be useful if you want to implement some sort of "guard break" skill that is only effective when the enemy's guard is decently high.

 

You can imagine the kinds of things you can do with formulas. How about a "level 5 death" spell? Only targets that have a level that is a multiple of 5 will be affected by this skill.

 

<fp:ce f b.level % 5 == 0>

 

We check whether the remainder of level / 5 is 0 (definition of multiple of 5), and then add "Death state" if it's true.

 

Download

 

script: http://db.tt/LJVjslBy

 

Notes

 

I am trying to find a good way to make it so that you can specify conditions for individual effects rather than all effects, but the only reasonable way is to specify an index of the effect (since it's stored in an array).

Edited by Tsukihime

Share this post


Link to post
Share on other sites

Additional examples for the syntax would be awesome. Great script, I'm working with it now to try to create a Skill that can only be used on one character. A Knight of Darkness serves the Vampire Queen, and when he has the Death State, she can use her ability "Loyal Beyond Death" to bring him back as a Death Knight.

 

I'm going to mess around with it a while, but what is the syntax that should go in the skill's notebox?

 

<fp: ce f b.name == Derevius> ? (Derevius is the name of the Knight). b.actor_id?

Share this post


Link to post
Share on other sites

<fp:ce f b.name == "Derevius">

 

However, this doesn't say much about actual targeting.

You might need to set the scope to "all allies" so that you don't rely on the engine to randomly pick the specific enemy.

Edited by Tsukihime

Share this post


Link to post
Share on other sites

I've set the ability to only work on One Ally (Dead), of course. I'm using <fp:ce f b.actor_id == 006> to check whether the Knight is targeted, and it works, for the most part. When I'm using that tag, though, it removes the Death State properly, but it doesn't apply the Death Knight state. When I remove the tag, the Death Knight State is properly applied, and the Death State is properly removed. Any ideas what is preventing the Death Knight state from being applied while I'm using the <fp:ce f b.actor_id == 006> note tag?

Share this post


Link to post
Share on other sites

Turns out the issue was actor_id isn't exposed to the public.

If the code fails I just catch the exception and return false (eg: doesn't work), but that probably makes it difficult to debug.

 

class Game_Actor < Game_Battler

 def actor_id
   @actor_id
 end
end

 

You will need to add this if you want to access actor_id

Edited by Tsukihime

Share this post


Link to post
Share on other sites

Hi Tsukihime,

 

Thanks for the script, it works great.

 

I know it's an old script but I wondered what you thought about updating it, and adding something similar to Jet's Self Effects script where you can specify which effect is used by the script.

Right now your script applies all effects when conditions are met, but it would be extremely useful to be able to target specific effects.

 

For example: I can't have an attack that deals damage, heals the user AND does something else on a critical hit.

 

For quick reference here's Jet's script:

http://blog.rpgmakerweb.com/wp-content/uploads/2012/05/SkillSelfEffects.txt

 

Cheers

Share this post


Link to post
Share on other sites

Fair enough, thanks for your reply.

 

I'm glad you said what you did actually because as a result I've now got Lunatic Damage running and have achieved exactly what I wanted.

 

Cheers

Share this post


Link to post
Share on other sites

Lunatic Damage is definitely much more flexible than this script.

 

Going to have this topic locked to indicate that it is no longer supported.

Edited by Tsukihime

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.

  • Recently Browsing   0 members

    No registered users viewing this page.

×
Top ArrowTop Arrow Highlighted