State auto-removal duration: Can I use a variable?

jjleroy

I love bananas
Veteran
Joined
Aug 5, 2017
Messages
184
Reaction score
34
First Language
German, English
Primarily Uses
RMMV
You know like you can set each state in RPGMV to a duration, for example 2-3 turns,

1fynfkR.png


but is there a script call where I could set this duration to a VARIABLE!?

I couldn't find anything in my research...
 

ShadowDragon

Realist
Veteran
Joined
Oct 8, 2018
Messages
4,488
Reaction score
1,719
First Language
Dutch
Primarily Uses
RMMV
I would remove it on battle end (the check mark)

and create a common event that hold the variable or the states, and control there when the state is removed :)
other than that, I have no clue otherwise to be honest.
 

caethyril

^_^
Global Mod
Joined
Feb 21, 2018
Messages
2,823
Reaction score
2,162
First Language
EN
Primarily Uses
RMMZ
I'd suggest Yanfly's Buffs & States Core. It offers a <State x Turns: +y> tag for skills/items, nice and simple. It also offers the <Custom Apply Effect> notetag for states, so you can set the duration via script when the state gets applied, e.g.
Code:
<Custom Apply Effect>
var turns = $gameVariables.value(1);
user.setStateTurns(stateId, turns);
</Custom Apply Effect>
This, verbatim, will set the state's duration to the value of game variable 1; just replace the 1 with the variable ID you want to reference. :kaothx:

Also, in case it helps: you can get the current turn count with this~
Code:
user.stateTurns(stateId)


Edit: just noticed this is in Learning JavaScript, so I'll add some more explanation. Note that both stateTurns and setStateTurns are methods added by Yanfly's Buffs & States Core. The real use of the plugin here is to give an appropriate trigger for the script call. State turn counts are stored in an array on the battler, so you can, for example, set state 5's duration to 3 turns like this:
Code:
user._stateTurns[5] = 3;
 

Latest Threads

Latest Profile Posts

"I didn't know X song was about that!" Uh... why? Do you not listen to the lyrics? I mean, I guess that makes sense. We live in a world where nobody listens, but everyone wants to be heard.
Coding class: Python
Game dev work: Javascript
Result: AHHH!!! Writing program for an assignment and having it crash and burn because I used Javascript syntax or format. Or having my game die on me because of a python call :yswt:
Can we make it so whenever a banned user tries to use their account whilst banned, the forum should redirect to this
Anyone doing anything for NaNoWriMo this year?
Listening to, "Draum" by Eldrim. If you haven't heard it before, do so. Absolutely lovely, and utterly haunting.

Forum statistics

Threads
115,835
Messages
1,093,312
Members
151,025
Latest member
Mynastrus
Top