Problem with a state stacker

Hi everyone

My game revolves around a special mechanic that allows you to drink each turn. After a set number of drinks the player transitions to a new state called blackout and then the previous state dissapears.

I found a couple mods that could help with state stacking. State_EX my Mr.Trivel does not work with Yanfly plugins and the Yanfly engine does not allow for stacking of an element. I found one called Synrec State Stacker that seems to work well with my other plugins. However I am having some difficulties

  1. After a set number of stacks the code successfully transfers my player into the new state and removes the old stacks. However the state never expires naturally. In fact, it does not read the note section for that state when it is added so I cannot use other plug ins to fix the issue. Does anyone know how to make a plug in read the note section? I can use other plug ins to refresh the turn counter and fix the issue but it does not work when it is triggered by this plug in
  2. I would like the stacks to decay over time, but for some reason if the state is stackable it does not go away. I can remove 1 or more stacks by just adding multiple remove state sections. It would be nice for this to happen over time like other stacks but I will probably need a different work around.

I searched for a plug in that would work and only found this one so I think this is what I am stuck with. I am open to using Javascript to fix these issues. Any and all help is appreciated. Thanks!

I've moved this thread to Plugin Support. Thank you.

Just Yanfly's Buffs & State Cores is enough to make a state stacker, I think. I'm a bit familiar with this. Maybe you can tell me your idea in detail, and I will be able to help you.
Just Yanfly's Buffs & State Cores is enough to make a state stacker, I think. I'm a bit familiar with this. Maybe you can tell me your idea in detail, and I will be able to help you.

Awesome, my idea is not too crazy

Each turn battlers can use a free action to consume one drink. This gives them a stack of drink. Each stack increases the effect of the drink state, for example if drink raises attack to attack*110% then two stacks would be attack*110%*110%. (the free action I already coded in using instant cast and then a state that prevents using that command again)

At 7 stacks the state will turn into a brand new state called blackout. This drops all the stacks of drink and replaces it with the new state. This new state will disappear after 2-3 turns, this does not add any new states upon being removed

Drinks can also expire. Lets say actor 1 has used the drink command 4 times. If they do not use the drink command in 2-3 turns then their stack will decrease to 3. Adding a drink onto the stack will reset the turn count down.

some abillties in the game will add multiple drinks to a players stack and some can remove multiple drinks in a players stack.

I was not sure how to use the Yanfly engine to do this, I only want this state to be stackable (maybe some others later on, but for now just this one).
In the case with just Yanfly Buffs & States Core, it is unable to manipulate the ATK bonus of the state and make it stack with itself. Instead, the plugin can manipulate the damage dealt and stack them. If you are fine with this, I think I can make one like this:

- A stackable state, with no turn decay and a maximum of 7 instances to get replaced by a new one, each state increases damage dealt by 110%. If the actor does not use this consumable again after 2 turns, the number of instances decreases by 1 and gets removed upon 0. Using the consumable will reset the turn counter back to 5.

For this one, change "Auto-remove timing" of the state to "None" and put those pieces of codes in your state note tags (Replace something in the code where I mention as X or Y, etc). If you want the state to have turn decay, just reactivate "Auto-remove timing" with a certain number of turns:
Code:
<Reapply Reset Turns>

<Custom Apply Effect>
if (user._drinkIns === undefined || user._drinkIns === 0){
//Set the instance to 1 for the first use
user._drinkIns = 1;}
else{
//After the first use, check if the instances reach 7 or not
if (user._drinkIns < 7){
//If not, add 1 instance
user._drinkIns += 1;}
else{
//When the instances reach 7, remove the state and add a new one
//Change X to this state ID in your database
user.removeState(x);
//Change Y to the Blackout state ID
user.addState(y);}}
//Set a counter of the instances for your state. Change X to this state ID
user.setStateCounter(x, user._drinkIns);
//Set the decay counter. It counts the number of turns the user does not use the drink. I use 3 here because after the first use ends, the turn is counted as 1, so we still have 2 turns left.
user._drinkReset = 3;
</Custom Apply Effect>

<Custom Confirm Effect>
//Check if the user causes damage to the target
if (value > 0){
//Set the percentage of bonus damage deal. 1.1 means 110%, multiplies with the number of instances
var bonus = 1.1 * user._drinkIns;
//Multiply the damage dealt with the bonus amount
value = Math.ceil(value * bonus);}
</Custom Confirm Effect>

<Custom Turn End Effect>
//Decreases the counter by 1 to know when to decrease stack
user._drinkReset -= 1;
if (user._drinkReset <= 0){
//If the counter reaches 0, meaning 2 turns have passed and the user has not drunk a new one, decreases the instances by 1
user._drinkIns -= 1;
//Change the instance counter. Change X to this state ID
user.setStateCounter(x, user._drinkIns);
//Reset the decay counter. This time we use 2, because it is now at the end of the turn.
user._drinkReset = 2;
//Check if the instances reach 0 to remove it. Change X to this state ID
if (user._drinkIns <= 0){
user.removeState(x);}}
</Custom Turn End Effect>

<Custom Remove Effect>
user._drinkReset = undefined;
user._drinkIns = undefined;
</Custom Remove Effect>

I do not have enough time to test, but hope this will run fine. In case something happens, please tell me. If you still want to multiply the ATK parameters, I'm sorry that I cannot help with just this plugin alone.
wow, this is super helpful! I will play around with it tonight. I was thinking about making it lower their speed too, but it seems like that is not possible with this plug in alone. I bet there are other things I could manipulate using the stacker to add some penalty for excessive drinks (I could make them take more damage or something). Regardless this is an amazing basis to work around. Are there other plug ins you would suggest I look out for? Again though thanks!
whelp something is wrong, now all my attacks do 0 damage and the enemies do not attack back, I think it has to do with the drink command being an instant cast skill. Originally I had it so using the instant cast drink skill would put a state on that seals drinking. I deleted that but I am getting this weird error.

SyntaxError: missing ) after argument list
at Game_Actor.Game_Battler.customEffectEval (YEP_BuffsStatesCore.js:1378)
at Game_Actor.Game_Battler.addStateEffects (YEP_BuffsStatesCore.js:1396)
at Game_Actor.Game_Battler.addState (YEP_BuffsStatesCore.js:1391)
at Game_Actor.Game_Battler.addState (YEP_EnhancedTP.js:3664)
at Game_Actor.Game_Battler.addState (YEP_X_PartyLimitGauge.js:952)
at Game_Action.itemEffectAddNormalState (YEP_BattleEngineCore.js:3568)
at Game_Action.itemEffectAddState (rpg_objects.js:1873)
at Game_Action.applyItemEffect (rpg_objects.js:1805)
at Game_Action.<anonymous> (rpg_objects.js:1662)
at Array.forEach (<anonymous>)
It was a syntax error in Apply Effect. I edited the codes above. Please try again and tell me if it works.
Besides, there are 3 other plugins from Yanfly to manipulate the parameters (Base, Extra and Special), and they can be used with Buffs & State Cores to make even more complex states. But be very careful when toying with them because most of the time you have to raise/reduce the parameters manually when the state is removed. If you forget even one, it will be a mess.
- Base Parameter Control
- Extra Parameter Control
- Special Parameter Control
Hmm I am still getting a similar error even with the syntax fix. here is a snippet from the console

if (user._drinkIns === undefined || user._drinkIns === 0){
//Set the instance to 1 for the first use
user._drinkIns = 1;}
else{
//After the first use, check if the instances reach 7 or not
if (user._drinkIns < 7){
//If not, add 1 instance
user._drinkIns += 1;}
else{
//When the instances reach 7, remove the state and add a new one
//Change X to this state ID in your database
user.removeState(11);
//Change Y to the Blackout state ID
user.addState(12);}
//Set a counter of the instances for your state. Change X to this state ID
user.setStateCounter(11, user._drinkIns);
//Set the decay counter. It counts the number of turns the user does not use the drink. I use 3 here because after the first use ends, the turn is counted as 1, so we still have 2 turns left.
user._drinkReset = 3;

YEP_InstantCast.js:644 SyntaxError: Unexpected end of input
at Game_Actor.Game_Battler.customEffectEval (YEP_BuffsStatesCore.js:1378)
at Game_Actor.Game_Battler.addStateEffects (YEP_BuffsStatesCore.js:1396)
at Game_Actor.Game_Battler.addState (YEP_BuffsStatesCore.js:1391)
at Game_Actor.Game_Battler.addState (YEP_EnhancedTP.js:3664)
at Game_Actor.Game_Battler.addState (YEP_X_PartyLimitGauge.js:952)
at Game_Action.itemEffectAddNormalState (YEP_BattleEngineCore.js:3568)
at Game_Action.itemEffectAddState (rpg_objects.js:1873)
at Game_Action.applyItemEffect (rpg_objects.js:1805)
at Game_Action.<anonymous> (rpg_objects.js:1662)
at Array.forEach (<anonymous>)

A lot of things do not work, the enemy limit gauge is NaN, it keeps staying my turn and I do 0 damage.
Haha sorry I made another mistake after the fix. Silly me. Here! Try to add one "}" at the end of add state 12.
Currently, it is now:
Code:
user.addState(12);}

Change it to this:
Code:
user.addState(12);}}

And for the NaN in damage dealt, replace the <Custom Confirm Effect> with this new one:
Code:
<Custom Confirm Effect>
//Check if the user causes damage to the target
if (value > 0){
//Set the percentage of bonus damage deal. 1.1 means 110%, multiplies with the number of instances
var bonus = 1.1 * user._drinkIns;
//Multiply the damage dealt with the bonus amount
value = Math.ceil(value * bonus);}
</Custom Confirm Effect>


Hope it is alright now. Besides, you can even add animation when the number of stacks reaches the maximum, or when the user forgets to drink again to remind him. If you are interested in this, please let me know.
Haha sorry I made another mistake after the fix. Silly me. Here! Try to add one "}" at the end of add state 12.
Currently, it is now:
Code:
user.addState(12);}

Change it to this:
Code:
user.addState(12);}}

And for the NaN in damage dealt, replace the <Custom Confirm Effect> with this new one:
Code:
<Custom Confirm Effect>
//Check if the user causes damage to the target
if (value > 0){
//Set the percentage of bonus damage deal. 1.1 means 110%, multiplies with the number of instances
var bonus = 1.1 * user._drinkIns;
//Multiply the damage dealt with the bonus amount
value = Math.ceil(value * bonus);}
</Custom Confirm Effect>


Hope it is alright now. Besides, you can even add animation when the number of stacks reaches the maximum, or when the user forgets to drink again to remind him. If you are interested in this, please let me know.

This fix worked! There was a bug on my end where I forgot to turn on ATB in the battler that messed up how it counted turns and then I forgot to replace an x. I'm going to play around with what different effects I can work with while not using other plug ins and I'll reach out to see if I want to do some custom animations. Thanks so much!

Original thread: https://forums.rpgmakerweb.com/threads/problem-with-a-state-stacker.120179/