Conditional States

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

conditionalStates1

This script allows you to create “conditional states”. A conditional state is simply a placeholder for other states, depending on the conditions at the time the state is applied.

For example, suppose you have a skill that adds a Weak Poison state to a target if it is not already poisoned, and adds a Strong Poison state if it has Weak Poison inflicted. You can use a formula to determine whether the weak poison has been added or not to determine which state should be added.

Download

Script: download here

Installation

In the script editor, place this script below Materials and above Main

Usage

To create a conditional state, note-tag a state with

<conditional state>
FORMULA
</conditional state>

Where the formula returns a number, which is the state ID that will be applied. If you don’t want a state to be applied, you can use 0.

The following formula variables are available

a - the battler that the state will be added to
p - game party
t - game troop
s - game switches
v - game variables

Example

Assuming you have two states Weak Poison (12) and Strong Poison (13), you can create a conditional state (14) that will add Strong Poison if Weak Poison is already applied, or apply Weak Poison otherwise.

<conditional state>
if a.state?(12)
  13
else
  12
end
</conditional state>
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...

9 Responses

  1. Aldiev says:

    I’m in the midst of putting together a states-heavy system, and this is helping me immensely. But I’d like to ask, can you double a proper state slot as a placeholder slot?

    for example, using yours from above, weak poison could become strong poison if you set the notetag down IN weak poison’s slot?

    Note box “12”

    if a.state?(12)
    13
    else
    12
    end
    </conditional state>

    • Hime says:

      Yes, there should not be an issue. I believe you should even be able to chain together multiple conditional states together.

      • Aldiev says:

        Beautiful. That’s a useful tidbit (I’ve been operating so far assuming it wouldn’t work based on the example). This script has worked to an extent but I fear what I’m using it for may be too dependent… practically making a whole battle system revolve around state changes. I’ve got a pretty complex dilemma here but it may be too much content to put it in a reply.

        Should I be using the github issue tracker (though I gotta go make an account for that, why so many accounts internet) to speak with you about it? Is there some other way I ought to contact you?

        • Hime says:

          I would prefer using github since if anyone has similar issues I can just point them to it.
          You can also use my facebook page or twitter DM

  2. Martín says:

    There’s a way to use this to do a state with the same mechanics of paralysis from pokemon games?

  3. EnGarcia says:

    Sorry to bother you again mate, this time with this one.

    Any way to check for more than two states? For instance, this one skill checks if state 1 is applied apply state 2 but if state 2 is applied apply state 3 and so on.

    I tried to stack the if-else on the formula but didn't work (wasn't actually expecting it to work for my coding skills are very limited but guess didn't hurt to try).

    Thanks in advance!

    • EnGarcia says:

      Nevermind mate, I was stacking them wrong, I figured it out:

      <conditional state>
      if a.state?(37)
      38
      if a.state?(38); 37
      39
      if a.state?(39); 38
      40
      if a.state?(40); 39
      41
      else
      40
      end
      else
      39
      end
      else
      38
      end
      else
      37
      end
      </conditional state>

  1. September 25, 2014

    […] Conditional States script allows you to create placeholder states whose sole purpose is to determine the proper state […]

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