Conditional States

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>

You may also like...

90 Responses

  1. Nick says:

    Hi!

    Any chance you still have a working link for download? Thanks!

  2. Luth says:

    Hello,

    This is a nice script and it does the work ; however, it doesn’t seem to remove the weaker state by default, making the two states stack.

    I tried using this formula, but it returns in an error :

    <conditional state>
    if a.state?(6)
    7
    a.remove_state(6)
    else
    6
    end
    </conditional state>

    Could you help me with that ?

    Thanks !

  3. James says:

    Hello,
    I was using this script, but whenever I launched a test battle, and tried to use the skill resulting in calling the conditional state, it returned the error “Script ‘ConditionalStates’ line 113: SyntaxError occurred. unexpected $end, expecting keyword_end” My notetag is as follows in case that’s the problem:

    if a.state?(31)
    30
    if a.state?(30)
    29
    else
    31
    end
    </conditional state>

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

  5. Martín says:

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

  6. 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 to Hime Cancel reply

Your email address will not be published. Required fields are marked *