State count in damage

Hi everyone, I'm trying to create a mechanic im RMMV that takes into account the remaining number of turns of a certain effect state, but I don't know how. I use Yanfly plugin buff/debuffs. Does anyone knows any scrip or plugin to do that?

An example would be a poison purge effect, that would do 1000*(remaining turns of poison on target) damage.
An example would be a poison purge effect, that would do 1000*(remaining turns of poison on target) damage.
If it's for a skill/item, you can try something like this in the damage formula:

b._stateTurns[123] * 1000
I.e. "(remaining turns of state 123 on the target) times 1000". Replace 123 with the ID of your poison state.

If it's for a damage-over-time effect you use YEP Buffs & States Core, e.g. like described here:
Code:
<Custom Regenerate Effect>
var dmg = user.stateTurns(stateId);
user.startAnimation(59);
user.gainHp(-dmg);
</Custom Regenerate Effect>
If it's for a skill/item, you can try something like this in the damage formula:

b._stateTurns[123] * 1000

I.e. "(remaining turns of state 123 on the target) times 1000". Replace 123 with the ID of your poison state.

If it's for a damage-over-time effect you use YEP Buffs & States Core, e.g. like described here:
I tried it this way, but the damage always results in zero. I tried with and without the underscore, but I wanted to know, to call a js function in the skill calculation do I have to use the underscore?
If it's for a skill/item, you can try something like this in the damage formula:

b._stateTurns[123] * 1000

I.e. "(remaining turns of state 123 on the target) times 1000". Replace 123 with the ID of your poison state.

If it's for a damage-over-time effect you use YEP Buffs & States Core, e.g. like described here:
NVM i just was dumb, i was puting 'a' instead of 'b' in the formula... well thx a lot! Now i can do the purge system
now i have another question: how, in addition to causing damage, do I increase the counter of a state?
All of the functions for working with state counters are right in the Buffs & States documentation, at the bottom.

You'd just replace the word "battler" with whatever reference you have (in damage formulae it's a/b, in notetags that are evaluating JavaScript you typically have user/target, etc.).
All of the functions for working with state counters are right in the Buffs & States documentation, at the bottom.

You'd just replace the word "battler" with whatever reference you have (in damage formulae it's a/b, in notetags that are evaluating JavaScript you typically have user/target, etc.).
yes i figured that the commands work, but i didn't know how to call them in battle. For example, the attack based on the number of turns only worked, when I put the underscore in the plugin command (b._stateTurns[123] * 1000). But now I don't know how besides dealing the damage, call the command to increase the amount of turns (b._addStatTurns(123, 1)). I actually don't know what to call it outside of combat either. Let's say a poisonous land that with each step that the person walk in it, the amount of poison increases. Would it be a script call, plugin call, or something else?
To process when a skill is used, you could use a notetag from a plugin like YEP Skill Core, e.g. (untested):

<Pre-Damage Eval> if (target.isStateAffected(123)) { user.addStateCounter(456, 1); } </Pre-Damage Eval>
I.e. "if the target is affected by state ID 123, +1 to the user's counter for state ID 456".

Alternatively you could put it in the skill's damage formula, e.g. (untested):

if (b.isStateAffected(123)) { a.addStateCounter(456, 1); b._stateTurns[123] * 1000; } else 0;
...but note that autobattle actors will evaluate the formula of each available skill to decide which one to use, and plugins might extend that behaviour to other things, e.g. enemy AI.

Also, to clarify something:
  • b._stateTurns[123] is from the core scripts: it gets a value from an array.
  • b.stateTurns(123) is a function from YEP Buffs & States Core.
They both return the same value for a battler b. However, they are different things, with different names. And neither of them are plugin commands.
To process when a skill is used, you could use a notetag from a plugin like YEP Skill Core, e.g. (untested):

<Pre-Damage Eval> if (target.isStateAffected(123)) { user.addStateCounter(456, 1); } </Pre-Damage Eval>

I.e. "if the target is affected by state ID 123, +1 to the user's counter for state ID 456".

Alternatively you could put it in the skill's damage formula, e.g. (untested):

if (b.isStateAffected(123)) { a.addStateCounter(456, 1); b._stateTurns[123] * 1000; } else 0;

...but note that autobattle actors will evaluate the formula of each available skill to decide which one to use, and plugins might extend that behaviour to other things, e.g. enemy AI.

Also, to clarify something:
  • b._stateTurns[123] is from the core scripts: it gets a value from an array.
  • b.stateTurns(123) is a function from YEP Buffs & States Core.
They both return the same value for a battler b. However, they are different things, with different names. And neither of them are plugin commands.
<Pre-Damage Eval> if (target.isStateAffected(123)) { user.addStateCounter(456, 1); } </Pre-Damage Eval>

this part, where do i put it? in the attack formula, in abiliity note, in a comom event or somewere else?
It's a Skill tag from YEP Skill Core:
You'd put it in the skill's Note box, like any other notetag.
It's a Skill tag from YEP Skill Core:
You'd put it in the skill's Note box, like any other notetag.
well thats helps a lot, and now i able to increase the state count, but im still strugling with the duration. i tryied diferents ways but no use. none of then worked

<Pre-Damage Eval>
user.addStateTurn(36, 3);
batt._stateTurns[36] += 3;
</Pre-Damage Eval>

<State 36 Turns: +3>
<Pre-Damage Eval>
user.addStateTurn(36, 3);
batt._stateTurns[36] += 3;
</Pre-Damage Eval>
😅 Where did you get batt from? If you want to refer to the target, try target, or b.

<State 36 Turns: +3>
I think this should work if you have YEP Buffs & States Core. You put the tag in the skill's Note box, right?

Maybe check that any Yanfly plugins you're using are loading in the recommended order, listed here:
You can click+drag to rearrange the order in the Plugin Manager. Remember to save your project to apply Plugin Manager changes before testing~
😅 Where did you get batt from? If you want to refer to the target, try target, or b.


I think this should work if you have YEP Buffs & States Core. You put the tag in the skill's Note box, right?

Maybe check that any Yanfly plugins you're using are loading in the recommended order, listed here:
You can click+drag to rearrange the order in the Plugin Manager. Remember to save your project to apply Plugin Manager changes before testing~
The "batt" i Saw in another post around here. In this specifc skill i was using the own user state. The "batt" was a desperate try to do that.

Yes im using yep buff And skills. I put that code in "note" box.

The plugins are in the right order. Its so true that i can increase the amout of stacks, but something in the code fonte work to increase the turns.

What is wrong with that call?:
<State 36 Turns: +3>
I know there may be a translation issue in play here, and that's okay - but I feel a part of your problem is you're mixing and combining some terminology.

It's going to be very hard to get you to do exactly what you want unless we can clear some of it up.

For example, you seem to be interchanging "script calls" (a.k.a. JavaScript or Lunatic Mode) with "plugin commands" and "notetags." These are three very distinct things, used in distinct places in RPG Maker, and they cannot be interchanged.

You're also being a bit loose with some of your typing/spelling, and that's critical in these things. If you mistype a notetag or change the capitalization of a script call, it won't work.

So please start providing screenshots with your posts. That way we can see exactly what you have typed and where it is in your project, and it doesn't matter whether you've made a typo in your forum post, it only matters what you typed in your project. 🙂

There's nothing inherently wrong with the notetag you just posted, but we need to see the rest of the skill you put it into.
I know there may be a translation issue in play here, and that's okay - but I feel a part of your problem is you're mixing and combining some terminology.

It's going to be very hard to get you to do exactly what you want unless we can clear some of it up.

For example, you seem to be interchanging "script calls" (a.k.a. JavaScript or Lunatic Mode) with "plugin commands" and "notetags." These are three very distinct things, used in distinct places in RPG Maker, and they cannot be interchanged.

You're also being a bit loose with some of your typing/spelling, and that's critical in these things. If you mistype a notetag or change the capitalization of a script call, it won't work.

So please start providing screenshots with your posts. That way we can see exactly what you have typed and where it is in your project, and it doesn't matter whether you've made a typo in your forum post, it only matters what you typed in your project. 🙂

There's nothing inherently wrong with the notetag you just posted, but we need to see the rest of the skill you put it into.
Well, I really was confused about a lot of things, not only because some idea might have been lost in the translation of my thinking into my writing, but also because I didn't really understand much about the RMMV system. In fact I mixed notetag with script with puglincalls with lunaticmode. In addition to having mixed the state stack with the state duration. But thanks to the help here, I think I not only solved the problem of the specific mechanics I was creating, but also understood more about RMMV.

I had thought of putting screenshots of my screen, but I thought it would be confusing in some things because my program is in Portuguese, so I just put the codes.

In the end I managed to solve it as follows: in the skill formula field I put the following code:

a._stateTurns[36] * 1000;a._stateTurns[36] += 3

The YEP "note" "<State x Turns: +y>" does not work in this case, as I was trying to increase the user state turns, and this command only refers to the target.

I would still like to know how to use a lunatic mode command to do this increase during a specific phase of the turn (Pre-Damage, Damage Phase, Post-Damage, etc)

I tried using the following lunatic command in Notebox, but it didn't work:

<Pre-Damage Eval>
user.addStateTurns(36, 3);
</Pre-Damage Eval>

And guys, thank you so much for your help and patience with me.
In the end I managed to solve it as follows: in the skill formula field I put the following code:

a._stateTurns[36] * 1000;a._stateTurns[36] += 3
Screenshots of your skill are still the best thing, even if they need to be figured out and translated. What you typed is not going to end up working correctly, because you're typing it into a damage formula.

That means it sounds like you're making the actor target themselves with a damaging skill that's going to receive an invalid result. I'm actually surprised it's not throwing errors at you or making your battle go wonky.

The YEP "note" "<State x Turns: +y>" does not work in this case, as I was trying to increase the user state turns, and this command only refers to the target.
If your skill is set up correctly the user should be the target.

<Pre-Damage Eval>
user.addStateTurns(36, 3);
</Pre-Damage Eval>
Where did you get this addStateTurns() function from? It doesn't exist, it's not in any documentation for any plugin.
That means it sounds like you're making the actor target themselves with a damaging skill that's going to receive an invalid result. I'm actually surprised it's not throwing errors at you or making your battle go wonky.
It didnt broke, because it was a damage formula that target someone. We can call any atribute of user or target. We can do a damage that only takes in count the defense or attack atribute of the target, not any atribute of the user. Like this:

b.def * 2 + 100

But this skill idea is to damage the target taking into account a positive state of the user.
If your skill is set up correctly the user should be the target.
But that is the point, i need increase the duration of a state of the user, when the user hits someone with this skill.
Where did you get this addStateTurns() function from? It doesn't exist, it's not in any documentation for any plugin.
At this point im not really sure, its been two days loking in everywhere trying to discovery how implement this idea. But for sure "a._stateTurns[36] += 3" worked in the skill formula, but dont work in the note.

1673879778075.png

i tryed all these ways in the notebox but none of then worked. And im sure the the YEP skill/buff plugins are working since i using their tips to do the thornmail and its working.
It didnt broke, because it was a damage formula that target someone. We can call any atribute of user or target. We can do a damage that only takes in count the defense or attack atribute of the target, not any atribute of the user.
I know how damage formulae work. What you posted above is probably not a valid formula because I doubt the result of the turns + 3 is how much you want to hit the enemy for.

Feel free to tag me when you post a screenshot of your entire skill, and I'll try to help you.
I know how damage formulae work. What you posted above is probably not a valid formula because I doubt the result of the turns + 3 is how much you want to hit the enemy for.

Feel free to tag me when you post a screenshot of your entire skill, and I'll try to help you.
1673881430647.png

nothing in the notebox works
As I mentioned before, it looks like your damage formula is backwards. Whatever you say last is what it will use for damage, so right now it's going to use the number of turns the attacker has of state 36.

Do you really want it to be hitting for, like, 4 damage? If so, what's the point of the first part, the stateTurns * 1000? It seems like you want that to be second, so that's the damage.

For the notetags, you should delete all of the things you've been told isn't right.
- stateTurns(36) += 3 can't work because that returns a value, it doesn't let you set one
- addStateTurns() doesn't exist

As caethyril told you in post #2, ._stateTurns[36] is the correct syntax. So user._stateTurns[36]+=3 should work correctly. However, I would expect it to not work while you have incorrect code in the same notetag.

So delete everything else and see if that works correctly.

Original thread: https://forums.rpgmakerweb.com/threads/state-count-in-damage.154102/