State Add/Remove Commands

● ARCHIVED · READ-ONLY
Started by Shaz 20 posts View original ↗
  1. State Add/Remove Commands

    2015.11.24

    by Shaz

    Introduction

    This plugin allows you to run commands when a state is added or removed.

    How to use

    Add to your plugins folder (file name is irrelevant but I use StateAddRemoveCommands.js). There are no parameters to set or plugin commands to call.

    Add the following to the State note box:

    onadd: commandonremove: command to execute command when the state is added or removed.

    command is any Javascript command that will be executed in the context of a battler (actor or enemy). Use this to refer to the current battler.

    Examples

    onadd: this.gainHp(50)- add 50 HP to the battler when the state is added

    Code:
    onremove: this.gainMp(-100)
    - deduct 100 MP from the battler when the state is removed

    Code:
    onremove: this.addState(15)
    - adds state 15 to the battler when the current state (the one with the note tag) is removedPlugin

    Download from pastebin

    Credit

    - Shaz

    Terms

    - free for use in commercial games

    Notes

    This is a port of my State Add/Remove Commands script for Ace.  Some people previously reported issues with that script that I have not yet been able to reproduce or solve.  If you encounter any issues please list them and I'll attempt to resolve.
  2. Ohhhh...I can already think of a few great ideas with this. Thanks Shaz! <3
  3. Although I don't like the author's layout of introducing the functions of the plugin, I am considering this plugin in my commercial game.
  4. Tried using this to add 25 hp, and nothing happen what so ever.
  5. The note box of your state should have this:

    Code:
    onadd: this.gainHp(25)
    If this is not happening, can you try this plugin on its own without any others, and if that doesn't work, post a screenshot of your state and list the other plugins you are using?
  6. Was about to request this plug-in and this came. Thanks, Shaz! :)
  7. Ok found the issue:

    when I use:

    onadd: this.gainHp(25)

    it doesn't do anything, when I make it a skill that can be used, it just heals the actor for the # hp.

    Otherwise when I try and use it as a passive state, it does nothing.
  8. I remember using this script A LOT during VX Ace era. This script is so simple and yet so versatile. I can't tell you enough how much usefulness this script put on the table, from creating Doom state, running a common event, or even directly executing a method from other scripts!

    I am so glad you port this script to MV. :rock-left: :guffaw: :rock-right:
  9. Another request fulfilled. 

    dayhjawk said:
    Ok found the issue:

    when I use:

    onadd: this.gainHp(25)

    it doesn't do anything, when I make it a skill that can be used, it just heals the actor for the # hp.

    Otherwise when I try and use it as a passive state, it does nothing.
    You might have misunderstood the plugin. What you're explaining is exactly what it's designed to do. Whenever the state with the notetag is added, it runs one instance of the command. In your case, when the state is added, the actor gained the HP. That's what the notetag indicates. It doesn't mean it happens every turn like a normal state.

    To do that, I believe the plugin you're looking for is "Quasi Params". That lets states increase parameters by set numbers instead of percentages.

    As a passive state, Shaz's plugin would do nothing because the state is always on. Hope this clears things up.

    Also, thank you VERY much for this Shaz. I've been wanting this ported to MV since launch. :D
  10. I want to start with your plugin is awesome; simple and easy to use. Maybe you can help with me with this situation:

    I'm at a wall when it comes to me trying to recreate the "Doom" effect or "state" from the Final Fantasy games. Where you have a set number of turns starting from, say, 5 and each turn ends with a lower number until reaches 0. At that point you'd be inflicted with KO, DEATH, or Unconsciousness

    I have it all working fine until the point where at turn 0 you'd be inflicted with a death-like state. I've tried to give a negative regeneration effect while using the command:

    onremove: this.addState(1)

    On the final turn when the effect or switch is supposed to take place I get a "Range Error: Maximum call stack size exceeded"

    When I take off the command and try to use the negative regeneration effect alone while removing, I end with 1HP instead of the state affliction. Any ideas? And thank you in advance.
  11. You only need to post once - new member posts are hidden and need to be approved by a moderator.


    That error sounds like you might have a script added twice. What other plugins do you have, and have you made any manual changes to the js files? Can you open the console (F8) while playing, and when this error occurs, grab a screenshot of the console messages and post it?
  12. If I wanted to use this plugin to have the character use a specific skill on the removal of the state instead of another state how would I go about doing that? Something like onremove: this.useSkill (x) ? Is that even possible to do with this plugin?
  13. I really don't have a lot of experience with the battle system. I can tell you that the above won't work, because you assign actions in one phase and execute them in another, and by the time the state is removed, the character may already have had their turn.


    It might be worth investigating the Force Action command, either using this plugin to turn on a switch that would condition a troop page (then you'd have to set up that page on any troop where this skill could be used), or using the plugin to queue a common event. Even then I don't know if the timing of the state removal would happen prior to or after the check for a common event.
  14. Hey all! I know this thread is a year old but I wanted to add a comment for anyone still reading.


    Firstly, thanks so much for the plugin, Shaz! It's exactly what I needed.


    I just wanted to say that, if you find the plugin isn't doing anything, make sure your state IDs in the notes field don't have their opening 0s.


    So if your state's ID is 0010, write:


    onadd: this.removeState(10)


    not


    onadd: this.removeState(0010)


    This was driving me crazy before I figured it out.
  15. That is the case for ALL script calls and plugin commands, even for engines prior to MV.  Adding leading zeros to ids causes things to not work properly, because the scripts treat the number as hex or binary or something weird like that.
  16. So would this be effective at making a reraise/auto-life state?
    It can only be removed by Death, and once it is removed, it revives?
    (im actually using a plugin to make states remain upon death, so technically i want a reverse doom. place the buff on the player, once they die, the state is removed, and places the reverse doom effect, so in 3 turns, they are raised, because the state wears off in 3 turns, reviving them.)
  17. I don't really understand what you mean. If it can only be removed by death, and once it's removed, it revives, why make it removable by death in the first place?

    All I can suggest is to give it a go and see.
  18. Shaz said:
    If it can only be removed by death, and once it's removed, it revives, why make it removable by death in the first place?

    Technically I wouldnt want it to revive.
    I want to apply another state, the player can only be in, while dead.
    But I want that new state to auto remove itself, and the death state.
    (but only for the player with the original re-raise state, so not all people who die, get auto rezzed 3 turns later)

    EDIT#2 death seems to be unable to addState or removeState.
    and onadd or onremove both dont work with the KO state.
    Im currently using a plugin to allow states to remain on death, so do u think its an error, or do you think it goes against the core of the game too much?


    EDIT#3 ok, doing some testing (this part is the other plugin), I can have the reraise state remain upon KO, with the other plugin <retain on death>
    I cant use death to remove it, even with a resist state.
    I cant use a skill to remove state while they are dead.
    I can call a common event to remove a state while they are dead.


    The moment I attach
    onremove: this.addState(16)
    the state wears off upon KO. (ignoring the retain on death tag)


    For some reason I cannot both keep the state, and have it trigger upon being canceled.
    Im being forced into one, or the other.
    (obviously a compatibility issue)

    In short, its currently not possible to make a Reraise spell with this plugin, w/o making an additional "retain state on death" plugin built into it.
  19. I'm taking your advice and adding the plugin you recommended to my game that adds commands when a state is added or removed. However, I'm not very familiar with javascript commands and I don't understand what I should write to get the plugin to work as intended. Currently, the notebox for the state looks like this minus the quotations:

    "

    State #1 will be automatically added when

    HP reaches 0.

    onadd:

    onremove:"


    What do I need to write to get this to work properly? Thanks in advance.

    (Link to my old thread on this issue can be found here: https://forums.rpgmakerweb.com/inde...-are-affected-by-a-state.136072/#post-1184323 )
  20. I haven't tested this, but give it a go ...

    Let's say your actor map sprites are called Actor1MapNormal and Actor1MapVampire and in the sheet of 8, it's on the top left (index 0). And your face images are called Actor1FaceNormal and Actor1FaceVampire, and are also in the top left position. (The map sprites and face images don't have to have different names - they COULD have the same name because the images are in different folders). You would put the following into your state notebox:

    Code:
    onadd: this.setCharacterImage("Actor1MapVampire",0)
    onadd: this.setFaceImage("Actor1FaceVampire",0)
    onremove: this.setCharacterImage("Actor1MapNormal",0)
    onremove: this.setFaceImage("Actor1FaceNormal",0)

    If you wanted to have the two actor images on the same character sheet, and the two face images on the same character sheet, with the normal in the first position and the vampire in the second, your commands would be this instead (let's assume the image names are Actor1Map and Actor1Face):

    Code:
    onadd: this.setCharacterImage("Actor1Map",1)
    onadd:this.setFaceImage("Actor1Face",1)
    onremove: this.setCharacterImage("Actor1Map",0)
    onremove: this.setFaceImage("Actor1Face",0)

    So just use those commands and replace my file names with the correct ones (leave off the .png extension) and make sure the index is correct (top left is always 0).