Lunatic States

Last Updated: 2012.01.30
Download Link
Github Link


Lunatic mode effects have always been a core part of Yanfly Engine scripts. They exist to provide more effects for those who want more power and control for their items, skills, status effects, etc., but the users must be able to add them in themselves.

This script provides the base setup for state lunatic effects. These effects will occur under certain conditions, which can include when a state is applied, erased, leaves naturally, before taking damage, after taking damage, at the start of a turn, while an action finishes, and at the end of a turn.

Lunatic States allow allow states to trigger various scripted functions throughout certain set periods of times or when certain conditions trigger. These effects can occur when a state is applied, when a state is erased, when a state leaves naturally, before damage is taken, after damage is taken, at the beginning of a turn, while the turn is occuring, and at the closing of a turn. These effects are separated by these eight different notetags.

<apply effect: string>     - Occurs when state is applied.
<erase effect: string>     - Occurs when state is removed.
<leave effect: string>     - Occurs when state timer hits 0.
<react effect: string>     - Occurs before taking damage.
<shock effect: string>     - Occurs after taking damage.
<begin effect: string>     - Occurs at the start of each turn.
<while effect: string>     - Occurs after performing an action.
<close effect: string>     - Occurs at the end of a turn.

If multiple tags of the same type are used in the same skill/item’s notebox, then the effects will occur in that order. Replace “string” in the tags with the appropriate flag for the method below to search for. Note that unlike the previous versions, these are all upcase.

Should you choose to use multiple lunatic effects for a single state, you may use these notetags in place of the ones shown above.

<apply effect>
</apply effect>

<erase effect>
</erase effect>

<leave effect>
</leave effect>

<react effect>
</react effect>

<shock effect>
</shock effect>

<begin effect>
</begin effect>

<while effect>
</while effect>

<close effect>
</close effect>

All of the string information in between those two notetags will be stored the same way as the notetags shown before those. There is no difference between using either.


  • Punishment Package
    • Undead HP, Undead MP, Backfire Physical, Backfire Magical, Stat Slip Damage, Stat Slip Healing, Drain HP, Drain MP
  • Protection Package
    • Damage Cut, Damage Barrier, Damage Shelter, Damage Block, Heal Boost, Heal Bonus, Persist

Use your Lunatic Effects wisely!

And that’s all, folks!

64 comments on “Lunatic States

  1. Pingback: YSA Battle Add-on – Party Combo Counter « Yami World

  2. Is it possible to deal unhealable damage? For example, by decreasing HP as well as maximum HP at the same time by the amount of damage dealt? I mean, you can have MORE damage, you can have FAST damage and you can have CERTAIN damage with your skill, but what about UNHEALABLE damage? :)

  3. I have a question. There are states that are removed when the battle ends. Does the “erase” effect covers that too?

    From my experiments the answer should be “No” as the effect I want doesn’t gappen after the battle ends (though it works fine if the state is removed during battle), but maybe I’m just doing something wrong…?

    • Well, no idea.
      The “erase effect” still doesn’t work upon battle end for some reason, even though I fail to detect anything wrong with the script…

      • That’s because when they’re removed at the end of battle, it’s no longer considered in-battle. Lunatic State effects only occur in-battle.

  4. Pingback: XP Battlebacks « .:: Tieris Illia ::.

  5. Pingback: Ramiro + RMVXA = ♥

  6. I’m sorry that I need to ask this and it might be a stupid question, but for some reason I don’t really understand what I need to replace “string” with. If I want to make a “death sentence”-state for example, the owner of the state should die after a set number of turns, which could be achieved by using the “”-command. The problem that I have is that even after hours of trial and error, I still don’t know what I need to write instead of “string” in that case. Is there a list of commands that I didn’t see for some reason or does the sentence “but the users must be able to add them in themselves” mean that I need to edit the script with my own commands? Maybe I’m just thinking too complicated…
    I would really appreciate any kind of help, since I’m kind of desperate trying to find out what to do.

  7. Well i want to increase a variable x while being attacked if stat is on.
    thougth it would work like this :

    But basicly nothing happens. what is wrong about the string? When i do “$game_variables[x] += 1” to an events comment it counts the variable correctly.

  8. Does anyone know how to make a state deal a precise amount of elemental damage? I hate working with the health slip % and want to make it a static number.

  9. I think I’m pretty much at the level where I can use the Lunatic stuff now. =O Looking at what you can do with this, I’m just so happy to see this now.
    Oh Yanfly, how I love your specific preferences for setting up scripts to make battles more unique and interesting instead of just visually appealing~ <3

  10. Is it possible to use this script to create doom and auto-life states using a script call in the notetag? I’m no scripter by any means, but here is an example of what I was thinking.

    add_new_state(state ID)

    Something like this would be placed in the note box of the doom state so that after the set number of turns were up and the doom state is removed, it will then add the state associated to state ID.

    remove_state(state ID)
    actor_MHP = x%

    Something like this could be used to make an auto-life state. The character has auto-life on, when said character dies the state is erased which triggers the specified state (which would be Death) to be removed, and the player to have x% of max HP restored.

    As I said, I am definitely not a scripter, but if there is a way to do this, or some other method in existence, could you help me get on the right track? Any help would be greatly appreciated.

    I have looked into the add-ons developed by pillanious, but they do not work.

  11. Sorry for the double post. My examples were supposed to contain the “” tags like this:
    add_new_state(state ID)


    remove_state(state ID)
    actor_MHP = x%

  12. I’m having the same problem as Skywad for playing an animation for the state, have tried both

    @animation_id = 7

    could you tell me what I’m doing wrong?

  13. Thanks for your marvelous posting! I quite enjoyed reading it,
    you happen to be a great author.I will be sure to bookmark your blog and definitely will come
    back from now on. I want to encourage you to ultimately continue
    your great posts, have a nice weekend!

  14. Could one use this script to create a two-turn skill, like Jump from the Final Fantasy games or Dig and Fly from Pokemon?
    Eg: use the skill Jump, which adds the Airborne state to the user, and when the user leaves the state on the next turn, they automatically attack an enemy.
    Is this doable?

  15. I’m thinking it should be possible to set up an entire party as the state origin (so for example an attacker could inflict an HP drain that heals her entire party instead of just herself) but I’m unsure how to implement it. I’m looking in

    # new method: change_state_origin
    # new method: state_origin?

    and pretty certain that is where it would need to be added (plus I made up a new Party Drain effect in the Punishment Package, “when /PDRAIN HP”).

    ATM it works, but still only heals the caster.

    • @XPhater: I have been working on something similar, the concept being this:
      An actor has a shield which lets you, when attacked, have a chance at activating an ability, which would restore every party member’s HP by a small amount. I have tried with equipment that, when attacked, has a chance to cast a state on the targeted actor themself, but I can’t seem to be getting those to work. I’m using the Passive States script in conjunction with Lunatic States for this:

      if c>=10

      I couldn’t be assed to write it all in one line, and I don’t know how Ruby’s Syntax works THAT well. Can anyone with experience tell me what I am doing wrong, with this effect? ( … The state_id there is purely coincidential. I swear. D: )

  16. Yanfly, I don’t know if you still monitor this, but there are two major bugs in this script that you might want to be aware of:

    1) On line 505 you have for state in states, then it calls the extension, which then also has a for state in states! What this does is it loops through the states n^2 times, where n is the number of states present! This causes weird effects with your other scripts, which you can see by adding two other states (pick any two) then add a state with . What will happen is it will end up blocking 75 damage, as the damage block state is applied n times due to the double loop! You might want to fix it by deleting the for at line 505 and line 508

    2) Where is the eval line in this script? I find no eval line, so any time I try to add a custom condition it does nothing. If you examine the code, what happens is all it does is calls the lunatic condition, which dumps it to the extension, which then does nothing! I managed to fix this by adding an eval line to all of the common conditions (with a rescue “” line for those non-lunatic states).

    As it is, this script by itself does not work due to bug #2, and only the add-ons work at all.

  17. Pingback: Thorn Aura – ADDON | Alistair Engine

  18. Pingback: Lose MP – ADDON | Alistair Engine

  19. Pingback: Transfer Damage to Hero | Alistair Engine

  20. Pingback: Recover all – ADDON | Alistair Engine

  21. Pingback: Attacker State – ADDON | Alistair Engine

  22. Pingback: Devotion – ADDON | Alistair Engine

  23. Hi, I’m wondering if you could use this to make a state that vanishes after the affected target evades an attack?

  24. I don’t know if anyone still watches this, but when I use this script all of the sudden all characters and enemies state they are unaffected by all attacks. Not sure what is up with that, but I NEED this script. ._.

    • Edit:
      If anyone is reading this, there is a conflict somewhere in Yami’s battle damage popups and this script. Cause’s yami’s script to say that all damage is unaffected, even though damage is being applied. I am going to see what I can find between the two.

  25. I can’t seem to get this script to do… ANYTHING. These are to be used in the states notebox, right? It would seem obvious but… Why can’t I get it to do -anything- at all? Do I need another script to run this one? Is the github one an old version? I’ve tried multiple script calls, tried having this script at the start of my script order, at the middle, at the end… I don’t know what else to try.

  26. I’m having trouble getting a shock effect to function. Here is what i have: “” Unfortunately it comes up with a system stack error. I’m not really sure what I’m doing and would appreciate some help. Thanks :)

  27. Something seems to be happening to the text. Lets try this one more time. shock effect: if $game_actors[1].hp = 1 $game_actors[1].remove_state(25) (This time i removed the arrows)

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s