Action Skill Change

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

This script allows you to set an action to execute a different skill if certain conditions are met, with some probability. The condition is a formula that can use any game data available, including the action’s user as well as the action targets.

For example, if your actor’s HP is less than 50%, then there might be a chance
that each attack will be a special “critical attack” instead.


Script: download here


Place this script below Materials and above Main


Tag your skills with something of the form

<skill change>
id: 3
chance: 0.5
condition: a.hp < a.mhp * 0.5
</skill change>

id is the skill ID to change it to
chance is the probability that it will be changed, as a percent
condition is a formula that must be satisfied

The following variables are reserved for your formulas:

a - the action's user
b - the action's target** (see below for warnings)

Note that a single skill may have multiple skill change tags: during the game, it will pick the first one whose condition is met and use it. If you would like your skill to do different things depending on different conditions, create multiple skill change tags with different conditions.

Per-Target mode

In the configuration, you will find an option called “Per Target Mode”. This means that the skill change is checked for each target individually, rather than checking all targets at the same time. Per-target mode is not necessary if none of your skills using the skill change property will have multiple targets.

Be careful about the targets variable. If per-target mode is OFF, then it is given as a list of targets. For example if you want to check if a target has certain states:

b[0].state?(5)   # first target has state 5 applied
b[1].state?(2)   # second target has state 2 aplied
b[-1].state?(6)  # last target has state 6 applied
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...

49 Responses

  1. Martín says:

    Can I use this to do a skill that changes with the terrain using map regions to tag the terrain type? Or do I need use something else to do that?

    • Hime says:

      Is this on the map or during battle? Maps are not supported, but during battle you should be able to reference the current map region using


  2. Alex says:


    I am facing some compatibility trouble between this script and your permastate one.

    Basically I use invisible perma states to tag actors and enemies, for exemple “Beast”, and then have your script change the skill when the Beast state is on.

    It works fine without the tag, but no more once it is on.

    I have no idea if you may solve that easily. But since both are your work, i thought it might be good you know. I guess i can do without it for most cases. But it could be a problem if an enemy is revived.

    • Alex says:

      Ok i just made a test and it seems more related to the permastate script actually.

      Rather than using your skill change script, I wrote a damage formula on a test skill :
      if b.state?(246); 100; else; 0; end
      I made sure the enemy had the state with an autostate.
      Without the permastate tag it deals 100 damage. With it it deals 0.

      It seems like the permastate make it somehow “invisible” to the program.

      • Hime says:

        Add this to the permanent states script. I will add this later

        class Game_BattlerBase
          alias :th_permanent_states_state? :state?
          def state?(state_id)
            th_permanent_states_state?(state_id) || @permastates.include?(state_id)
  3. Oriceles says:

    Can I tag a state with this?

  4. Joey Desud says:

    Hey, cool script. How about would I go changing a skill based on the weapon equipped?

    I have a double cut skill, which looks strange when using a long-range weapon. I want to switch the skill

    <skill change>
    id: 410
    chance: 1.0
    condition: a.weapons?(157) == true
    </skill change>

    this isn't working for me. As well, I want to define a LOT of different weapons (a whole class of bows)

    • Hime says:

      If you want to check by weapon ID you need to collect the ID's first and then do your comparison.

      a.weapons.collect {|w|}.include?(157)

      If you need help with formulas you should try one of the forums. You should get faster responses.

  5. KaizoVorna says:

    Hello! Sorry for bothering you all the time with this script recently, but I came to suggest something with Per Target Mode. I found it kind of cumbersome how it just executes the skill for every enemy in battle if used with All Enemies-skills, (I know there was a warning about it, but still.) so might it be feasible to make it so that it plays the animation normally and then just runs the calculation for each enemy?

    • Hime says:

      What happens if the skill animation is different from the original skill?

      • KaizoVorna says:

        Depends on the scale of the animation, methinks. (Center, Head, Feet or Screen) Now I'm not going to claim I know anything worth mentioning about making actual code, but can't it be at least made so that Screen-wide animations don't play four times for each enemy? Or maybe make Per Target Mode apply only to skills that actually CAN change..?

        If nothing can be done, then I can just suck it up and deal with it, the script is excellent as it is, but I just wondered if it could be improved a bit.

        • Hime says:

          You have a chicken and egg problem: skills are only checked if they can changed for each enemy, if per target mode is on. If you want per target mode to be on only if the skill can be changed for the enemy, well, that wouldn't work.

          If you mean that per target mode should only be applied if the skill has ANY skill change note-tags, then yes that could be done.

          For the animation type, let's suppose your skill could be changed to a fire magic that turned the entire screen red depending on the target, or it could be changed to an ice magic that turned the entire screen blue depending on the target. If you only played one animation, which one would be played?

          • KaizoVorna says:

            Yeah, I meant ANY notetag. I guess that's the only sensible thing that can be done, eh? Don't suppose Per Target can be made into a notetag or made work with Single Target Skills only, either.

          • Hime says:

            Per-target mode is only relevant for skills that target multiple enemies. The only advantage to turning on per-target mode for single-target skills is so your formulas are easier to write.

            If a skill targets all enemies, and you didn't want per-target mode, then the skill change would be evaluated before the skill is used, and you need to use array access syntax for your conditions because there are multiple targets.

        • KaizoVorna says:

          I see what you mean. In that case, I simply have to see what works and what doesn't with my project. Thank you for your patience!

          • Hime says:

            There is definitely room for more options in the form of note-tags or otherwise, but I don't know what they might be that would make sense.

  6. KaizoVorna says:

    Hello again, I came to notice that this script doesn't seem to support your Enemy Levels-script. (That, or a.level = b.level is not valid for making the skill change if the enemy has the same level as the user does.) Is there something that can be done with this?

    • Hime says:

      Comparing whether two values are equal is done using ==, not =

      • KaizoVorna says:

        Aha, so it's me just being dumb! Thank you.

        • KaizoVorna says:

          Wait, hold the phone, it still doesn't recognize "level" as a valid value. It gives a NoMethodError on Line 135 saying that
          undefined method 'level' for#(Arrow Left)Array:0x9b25b70(Arrow Right)

          • Hime says:

            This is a non-intuitive part of the script and is only noticeable if you read the usage instructions, but there are two modes: per-target mode and non per-target. The purpose of per-target mode is to allow a single skill to be changed for each target (rather than just changing it at the beginning).

            If you want this behavior, in the configuration look for Per_Target_Mode and set it to true.
            Also, <arrows> should work fine now

          • KaizoVorna says:

            Huh, by gum, it works now! I thought Per-Target Mode was meant for Multi-Target Skills. Thank you again!

          • Hime says:

            The instructions are vague now that I have read them again.

            But ya, I probably should just turn it on by default since most people probably assume it's on.

  7. KaizoVorna says:

    Hello! I wanted to ask, is it possible to make the skill change if the enemy used an attack of a certain element? Let’s say, enemy uses Thunder, then Actor #2 uses an attack that draws the electricity into his sword to make his next attack more powerful.

  8. SoulGryph says:

    After more testing switching is based on the first switch read so…
    Skill switch 1 :

    id: 150
    CHANCE: 1
    condition: a.luk > b[0].luk + 20

    id: 3
    CHANCE: 1
    condition: a.luk > b[0].luk + 10

    Would make it so if:
    20 or more luck over enemies, would go to skill 150
    10 or more luck over enemies, would go to skill 3
    PS:: Thank you so much this script has made my day ^_^

    • Hime says:

      I see what you mean now. I thought you were asking specifically to perform the skill more than once. Yes, for stats in general, the condition formula should be flexible enough for basically anything. Being able to assign multiple skill change tags depending on which condition is a good idea.

  9. SoulGryph says:

    is there a way to tie skills with stats…
    Example : If AGI = 40+ add +1 repeats ?

    Is there also a way to make it so.
    Example : If actor AGI is 20+ > enemies AGI then add +1 repeats?

    • Hime says:

      No, this simply changes the skill used during an action. Might be something that can be considered for a separate script.

      • SoulGryph says:

        I would honestly love to see that… would turn RPG maker around for me being able to tie skills to stats directly.

      • SoulGryph says:

        Actually Iv figured out how to do both, Ill be nice enough to share.

        id: 3
        CHANCE: 1
        condition: a.luk > b[0].luk + 10

        Add this to skill notes and attack 3 will play when the user has over 10 luck over the enemy.. Just keep making skills for each Luk upgrade (in this case) and set it to the next skill for a certain amount of Luk over enemy 10 in this case b[0].luk + 10

  10. RogueDeus says:

    I didn’t know I was going to need this, until I did, and now that I do, I have to say.

    So awesome.

    This is without a doubt one of the most understated scripts in your list. The possibilities for boss battles is CRAZY.

    • Hime says:

      I should definitely work on providing more examples on how the script could be used. I think the biggest thing that makes it difficult is that a lot of my scripts rely on users knowing how to write ruby formulas, which is a pretty heavy requirement. Being a strong formula writer would allow you to do all sorts of things, and is something that should be developed more in general.

  11. Hime says:

    Support for checking targets has been added. Note that because a skill can have multiple targets, you are given a list of targets and need to access them appropriately. See examples.

  12. Rodjie says:

    how will i use a specific state as a condition? example: enemy is in state of sleep, then skill 1 will be changing into skill 2. . very helpful script but i think we more example formula :”) THANKS.

  13. Pretty cool… It makes a nice addition to the possibilities of skills

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](

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

Here is some inline `code`.

For more help see