State Add/Remove Commands

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
38,543
Reaction score
12,059
First Language
English
Primarily Uses
RMMV
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.
 
Last edited by a moderator:

Fernyfer775

Veteran
Veteran
Joined
Oct 6, 2013
Messages
1,310
Reaction score
812
First Language
English
Ohhhh...I can already think of a few great ideas with this. Thanks Shaz! <3
 

hardqueen

Crazy Talker
Veteran
Joined
Oct 26, 2015
Messages
78
Reaction score
15
First Language
Chinese
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.
 
Last edited by a moderator:

dayhjawk

Veteran
Veteran
Joined
Jul 5, 2015
Messages
107
Reaction score
12
First Language
English
Primarily Uses
Tried using this to add 25 hp, and nothing happen what so ever.
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
38,543
Reaction score
12,059
First Language
English
Primarily Uses
RMMV
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?
 
Last edited by a moderator:

Riff

Eorzean
Veteran
Joined
Oct 25, 2015
Messages
262
Reaction score
82
First Language
English
Primarily Uses
RMMV
Was about to request this plug-in and this came. Thanks, Shaz! :)
 

dayhjawk

Veteran
Veteran
Joined
Jul 5, 2015
Messages
107
Reaction score
12
First Language
English
Primarily Uses
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.
 

Moogle_X

Veteran
Veteran
Joined
Apr 25, 2015
Messages
157
Reaction score
314
First Language
English
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:
 

Neo Soul Gamer

Veteran
Veteran
Joined
Aug 10, 2012
Messages
628
Reaction score
344
First Language
English
Primarily Uses
N/A
Another request fulfilled. 

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
 
Last edited by a moderator:

Baconleaf

Villager
Member
Joined
Dec 28, 2015
Messages
8
Reaction score
1
First Language
English
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.
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
38,543
Reaction score
12,059
First Language
English
Primarily Uses
RMMV
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?
 
Last edited by a moderator:

Nuxill

Ok
Veteran
Joined
Jun 22, 2014
Messages
44
Reaction score
47
First Language
English
Primarily Uses
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?
 
Last edited by a moderator:

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
38,543
Reaction score
12,059
First Language
English
Primarily Uses
RMMV
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.
 

JMcMinn

Villager
Member
Joined
Oct 20, 2016
Messages
5
Reaction score
2
First Language
English
Primarily Uses
N/A
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.
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
38,543
Reaction score
12,059
First Language
English
Primarily Uses
RMMV
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.
 

Blair Pendragon

Veteran
Veteran
Joined
Jul 15, 2012
Messages
91
Reaction score
41
First Language
English
Primarily Uses
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.)
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
38,543
Reaction score
12,059
First Language
English
Primarily Uses
RMMV
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.
 

Blair Pendragon

Veteran
Veteran
Joined
Jul 15, 2012
Messages
91
Reaction score
41
First Language
English
Primarily Uses
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.
 
Last edited:

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

40 card deck size, the plugin seems more sluggish.
Village theme I composed for a commission!
Stream will be live shortly with some Haunting Ground! Feel free to drop by!
welp, the stock market went down by 7% because of corona today. Time to buy stocks?

Forum statistics

Threads
94,563
Messages
921,916
Members
124,429
Latest member
sheepman
Top