MV Cool battle system with stacking states

Hi I really needbsome help with a plugin that’s the main feature of my game. I had the Idea that the basic attack of my actor will stack a state ob the enemy ( to 1 from 5max) and the number need to be shown on the enemy sprite (I’m in front view battle). The cool idea is that my actor will have a magic attack that add 5% more damage for each stack of state when he will use it. After he used this attack to do more damage on the enemy with the stacked state, the state will return to none and have to be re-increased by using the normal attack on the enemy.


I'm not sure if the idea is very clear but I think It’s a system that will help to make battles less boring.
I think this is okay with the yanfly states plugin?
Correct - look at Yanfly's Buffs & States Core, and the state counter functionality.
Correct - look at Yanfly's Buffs & States Core, and the state counter functionality.
Thanks for the reply! It's very cool that Yanfly's Buffs & States Core can do that 'cause I already use it. But i'm not very good at code. How do I can do that 5 stack states and the more abstract to me is the attack that add 5% more damage for every stack. I don't know what I'm supposed to code/write in my skill notetag.

EDIT : I think It's a better way to add the state on the actor. Like every time he use his basic attack he increase his state by 1 (5max). and he have a magic attack "rage" that doe 5% more damage for each iteration of the stackable state. It's more intelligent than give the state to an enemy i think
It's all in the plugin instructions. The only code you need to know is that it provides target as a reference point for the targeted battler.

How do I can do that 5 stack states
1702046921453.png

1702046941435.png

1702046991278.png


So your state has the notetag
Code:
<Custom Apply Effect>
target.addStateCounter(stateId, 1);
target.clampStateCounter(stateId, 1, 5);
</Custom Apply Effect>

and the more abstract to me is the attack that add 5% more damage for every stack.
1702047082408.png


And you just put it in your damage formula to do the math you want. So you'd do
Code:
whatever your damage formula is * (1 + b.getStateCounter(X)*.05)
where X is the ID of the state (no leading zeros)
It's all in the plugin instructions. The only code you need to know is that it provides target as a reference point for the targeted battler.


View attachment 287037
View attachment 287038
View attachment 287039

So your state has the notetag
Code:
<Custom Apply Effect>
target.addStateCounter(stateId, 1);
target.clampStateCounter(stateId, 1, 5);
</Custom Apply Effect>


View attachment 287040

And you just put it in your damage formula to do the math you want. So you'd do
Code:
whatever your damage formula is * (1 + b.getStateCounter(X)*.05)
where X is the ID of the state (no leading zeros)
bro you're really saving me. Thanks a lot
It's all in the plugin instructions. The only code you need to know is that it provides target as a reference point for the targeted battler.


View attachment 287037
View attachment 287038
View attachment 287039

So your state has the notetag
Code:
<Custom Apply Effect>
target.addStateCounter(stateId, 1);
target.clampStateCounter(stateId, 1, 5);
</Custom Apply Effect>


View attachment 287040

And you just put it in your damage formula to do the math you want. So you'd do
Code:
whatever your damage formula is * (1 + b.getStateCounter(X)*.05)
where X is the ID of the state (no leading zeros)

I try to solve my last problem. I modify your suggestions to make my user have the stacked state instead of the ennemy. So there's the code

Here's the forumla of my basic attack :
a.addState(9);a.atk * 2 - b.def;

Here's the state 9 notetag :
<Custom Apply Effect>
target.addStateCounter(9, 1);
target.clampStateCounter(9, 1, 5);
</Custom Apply Effect>

And now the special attack that goes more powerfull by the stack of state 9 on the user
a.atk * 2 - b.def + a.getStateCounter(9)*.05

The problem now is to remove all the stacked state 9. I was thinking about a formula like this :
a.atk * 2 - b.def + a.getStateCounter(9)*.05 + a.removeState(9);
But it seems that the state is removed in the same time as the attack so there is no more stack of state 9 and my attack does 0 damage.
How can I remove the state 9 after my actor did the damages ? and it is possible to make a formula like : if the state counter is 0 so its just the basic formula a.atk * 2 - b.def.

The fact that my attack did 0 damages when i have no stack of state 9. It will be a problem later in my game if the user use this attack and have no stacked state 9. I prefer to make it a basic attack formula instead of 0 damages
The problem now is to remove all the stacked state 9.
It's one of the regular Effects you can add to a skill to Remove State.


it is possible to make a formula like : if the state counter is 0 so its just the basic formula a.atk * 2 - b.def.
I gave you the formula in my previous post. You changed it, and your math is incorrect because you end up multiplying the entire end value by 5%, which will get rounded down to 0 unless you have higher numbers.
And now the special attack that goes more powerfull by the stack of state 9 on the user
a.atk * 2 - b.def + a.getStateCounter(9)*.05
you divide your counter by 20 but it caps out at 5, so the most thatll give you is a.atk*2 - b.def + 0.25, which is just going to round down to a.atk*2-b.def. look to the formula given to you and youll see what to do to make it work properly
The problem now is to remove all the stacked state 9. I was thinking about a formula like this :
a.atk * 2 - b.def + a.getStateCounter(9)*.05 + a.removeState(9);
But it seems that the state is removed in the same time as the attack so there is no more stack of state 9 and my attack does 0 damage.
that can only get you 0. removeState() doesnt return a value and will make that entire formula produce some non-number.

The fact that my attack did 0 damages when i have no stack of state 9
that is also true. if you dont have the state but use getStateCounter() to try to access it itll return an undefined value and negate your entire formula as well.
you can try
Code:
(a.atk * 2 - b.def) * (1 + a.getStateCounter(9)*.05 || 0)

How can I remove the state 9 after my actor did the damages

you can just use the built in effects section of the skill to remove the state as Turan suggested to remove the state
you divide your counter by 20 but it caps out at 5, so the most thatll give you is a.atk*2 - b.def + 0.25, which is just going to round down to a.atk*2-b.def. look to the formula given to you and youll see what to do to make it work properly

that can only get you 0. removeState() doesnt return a value and will make that entire formula produce some non-number.


that is also true. if you dont have the state but use getStateCounter() to try to access it itll return an undefined value and negate your entire formula as well.
you can try
Code:
(a.atk * 2 - b.def) * (1 + a.getStateCounter(9)*.05 || 0)



you can just use the built in effects section of the skill to remove the state as Turan suggested to remove the state
Hi sorry for late reply but I've been quite busy the last few days. I changed my code to correct it. thanks both of you for your replies

now i've got :


basic attack :
(a.atk * 2 - b.def) * (1 + a.getStateCounter(9)*.05|| 0)

state 9 notetag :
<Custom Apply Effect>
target.addStateCounter(9, 1);
target.clampStateCounter(9, 1, 5);
</Custom Apply Effect>

the special attack that supposed to use stacked state
(a.atk * 2 - b.def) * a.getStateCounter(9)*.05

the actor can stack state 9 every turn from 1 to 5. and the special attack works very well. BUT i can't make the special attack remove state 9.

I can't use the built in effects section of the skill. It don't work 'cause it's applied on the target of the attack which is the enemy. But I want the actor to be cured from state 9.

and If I try to do :
(a.atk * 2 - b.def) * (1 + a.getStateCounter(9)*.05|| 0);a.removeState(9)
It remove the state directly so the state counter doesn't work.
sorry if I make your repeat but I don't understand when you say that removeState() doesnt return a value. Maybe It's because I wrote a + before it instead of a ; in my first message
You might want to read through some of this - the replies here are presuming some basic understanding of how the damage formula works which you don't have.

The key to the damage formula is the last thing is the number of the damage dealt. So when @Robro33 says that removeState() doesn't return a number, he means exactly that:
1702411945109.png


And if the value of your damage formula is undefined, MV interprets that as 0 damage.

So you must put the removeState() in there before the final number that represents the damage dealt.

However, note that if you use any auto-battle trait in your game, you shouldn't be doing that at all. You should put it into a Skill Core notetag, because the game evaluates your damage formulae when it's considering which skill to use. And if you put extra code in there, that code will be run whether you actually select that skill or not.

basic attack :
(a.atk * 2 - b.def) * (1 + a.getStateCounter(9)*.05|| 0)
I know you got this from @Robro33, but he made a little mistake. OR has a higher operator precedence than multiplication, so that's going to evaluate as "0.5 || 0", which will always be 0.5, and not affect the value you get from getStateCounter().

It should be:
Code:
(a.atk * 2 - b.def) * (1 + a.getStateCounter(9) || 0 * 0.5)

and If I try to do :
(a.atk * 2 - b.def) * (1 + a.getStateCounter(9)*.05|| 0);a.removeState(9)
According to the thread and instructions I gave above, combined with the correction to the OR usage, that's:
Code:
a.removeState(9); (a.atk * 2 - b.def) * (1 + a.getStateCounter(9) || 0 * 0.5)

But, again, you may want to move the removeState() to a Skill Core notetag to ensure it works correctly.

Original thread: https://forums.rpgmakerweb.com/threads/cool-battle-system-with-stacking-states.163675/