MV Working with stacking DOT

I think this goes here? My apologies if it doesn't.
Anyways, I'm using the Yanfly technique for stacking DOT, and the base stuff works in a fresh project, and then in my main project (yay!). But, I want to alter a few items, and the fresh project doesn't seem to like it (untested in my main project). I want each stack to do 1% of the target's max HP per turn, stacking up to 15 or 20 (currently unsure). I then want the stacks to decrease by 1 each turn (after damage calculation), and I want to have my Bandages (item) remove either 2 or 3 stacks (currently unsure). How would I do this? Thanks in advance!

Spoiler: What I have so far:
Code:
<Custom Apply Effect>
target._stackingPoison = target._stackingPoison || 0;
target._stackingPoison += 1;
</Custom Apply Effect>

<Custom Remove Effect>
target._stackingPoison -= 1;
</Custom Remove Effect>

<Custom Regenerate Effect>
target._stackingPoison = target._stackingPoison || 1;
var stacks = Math.min(20, target._stackingPoison);
var damage = stacks * a.mHp * 0.01;
// Play poison animation on the target.
target.startAnimation(59);
// Target takes HP damage.
target.gainHp(-damage);
// Play the popup.
target.startDamagePopup();
// Clear the results.
target.clearResult();
// Check if the target is dead.
if (target.isDead()) {
  // If the target is dead, make it collapse.
  target.performCollapse();
}
</Custom Regenerate Effect>
there is also a YEP DOT (Damage over Time) plugin which can achieve that.
I use that one too with a scriptcall and have it somewhere. (this check the state).
so you can combine the 2 for the desire effect if you have that plugin.
I haven't read through your code yet, but the error in your screenshot looks like you didn't make sure your damage values are integers. That looks like it's trying to draw a gauge for an HP that has decimals in it.

I want each stack to do 1% of the target's max HP per turn
You have that, but you need to keep your values as integers. So you'd do:
Code:
var damage = Math.ceil(stacks * a.mHp * .01);

and I want to have my Bandages (item) remove either 2 or 3 stacks (currently unsure). How would I do this?
Give your Bandages a Yanfly's Skill Core note tag:
Code:
<After Eval>
target._stackingPoison=Math.max(0, target._stackingPoison-3);
</After Eval>
I haven't read through your code yet, but the error in your screenshot looks like you didn't make sure your damage values are integers. That looks like it's trying to draw a gauge for an HP that has decimals in it.


You have that, but you need to keep your values as integers. So you'd do:
Code:
var damage = Math.ceil(stacks * a.mHp * .01);


Give your Bandages a Yanfly's Skill Core note tag:
Code:
<After Eval>
target._stackingPoison=Math.max(0, target._stackingPoison-3);
</After Eval>
Good news: this all now works. However, I still cannot figure out how to make the stacks decrease per turn by 1. I used the following code at the end of the State, to no avail.
Code:
<After Eval>
target._stackingPoison=Math.max(0, target._stackingPoison-1);
</After Eval>

I want to have the effect in turns to last the same length as the stacks (decreasing both the effect and duration by 1 stack/turn). I know that Buffs and States Core plug-in by Yanfly (already required for this method) that allows reapply/add/etc functions to states. I figured that I could make the Bleed state last 1 turn and cause it to "add" and I want the duration to match the stacks where 20 is the max.
Thank you in advance!
Edit: I figured it out. Used this, instead of the After Eval statement:
Code:
<Custom Turn End Effect>
target._stackingPoison=Math.max(0, target._stackingPoison-1);
</Custom Turn End Effect>
I used the following code at the end of the State, to no avail.
Make sure you're double checking documentation as you use notetags 😉

After Eval is not a State notetag. It's a Skill notetag, it's executed after the skill's Effects.
Make sure you're double checking documentation as you use notetags 😉

After Eval is not a State notetag. It's a Skill notetag, it's executed after the skill's Effects.
Yeah, I figured that out... after checking the documentation. xD
Any idea as to how to set the max of turn duration to 20? Or, for a custom condition to be added where if the turn is > 20 to stop adding, and switch to ignore? I went through all the documentation on that plug-in and didn't even see a Lunatic Mode way to do this, but my scope is pretty limited.
I am hoping to have some assistance, again, with this same problem, I still have not figured out how to cap the state duration at 20. Thank you in advance.
Yeah, I figured that out... after checking the documentation. xD
Any idea as to how to set the max of turn duration to 20? Or, for a custom condition to be added where if the turn is > 20 to stop adding, and switch to ignore? I went through all the documentation on that plug-in and didn't even see a Lunatic Mode way to do this, but my scope is pretty limited.
you can try this (but no lunatic expert)
JavaScript:
<Custom Apply Effect>
target._stackingPoison = target._stackingPoison || 0;
if (target._stackingPoison >= 20) {
    target._stackingPoison = 20;
} else {
    target._stackingPoison += 1;
}
</Custom Apply Effect>

if I'm correct, it adds +1 as long its lower than 20, if its equal or higher,
than it return to 20, but you need to test that the substracting of removing
does work.
you can try this (but no lunatic expert)
JavaScript:
<Custom Apply Effect>
target._stackingPoison = target._stackingPoison || 0;
if (target._stackingPoison >= 20) {
    target._stackingPoison = 20;
} else {
    target._stackingPoison += 1;
}
</Custom Apply Effect>

if I'm correct, it adds +1 as long its lower than 20, if its equal or higher,
than it return to 20, but you need to test that the substracting of removing
does work.
That works to keep the stacks at/under 20, but does not keep the turn duration at/under 20 actions. Thank you =]
I'm not sure on duration as I'm no lunatic expert, but if duration is important,
than it's missing something else further in the line that someone can help out.

but if adding/removing works, that's a good start at least I suppose.
Code:
target._stateTurns[stateId]=Math.min(target._stateTurns[stateId], 20);
EDIT: I got it to work!!! Never mind. Thank you both so much for all the help over the... several months...


Okay, back again with a continuation of this same problem.
I am using this code, from before:
Give your Bandages a Yanfly's Skill Core note tag:
Code:
<After Eval>
target._stackingPoison=Math.max(0, target._stackingPoison-3);
</After Eval>
It works... but only for skills, and not for the item itself. I also made an edit, and that works with a skill (I just put it on "Heal" for now).
<Code>
<After Eval>
target._stackingPoison=Math.max(0, target._stackingPoison-3);
target._stateTurns[4]=target._stateTurns[4]-3;
</After Eval>
</Code>

Spoiler: Screenshots
1714700127363.png

I tried this with the Damage formula off, as well as set to 0, and set to 10; none of these options work. The exact same code works with the "Heal" skill, though. Any ideas?

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

Original thread: https://forums.rpgmakerweb.com/threads/working-with-stacking-dot.159786/