MV Damage timing problem

Im using Yanfly's Buffs & States and the skill core in my project and i ran into a snag regarding a specific skill and a few state effects I made standard. If anyone has any ideas as how to get this working or alternatives it'd be appreciated.

I made a skill that deals no damage to its target upfront. It leaves a state on the target that deals the skill's intended damage upon its expiration. I let the damage formula box calculate the damage so that element rates/typed damage traits would be factored in automatically, and then used a <pre-damage eval> to set a variable to store the damage and set the damage to 0. That much works fine alone.
1701468661334.png
1701471349852.png

Code:
<Pre-Damage Eval>
target._reverb = value;
target.addState(390);
value = 0;
</Pre-Damage Eval>
Code:
<Custom Apply Effect>
user.setStateCounter(stateId, user._reverb);
</Custom Apply Effect>

<Custom Leave Effect>
user.gainHp(-user._reverb);
delete user._reverb;
</Custom Leave Effect>

I have a number of states that boost damage dealt through <Custom Confirm Effect> tags. nothing special. They all work by themselves and with eachother just fine.
1701468966603.png
1701470472356.png



The issue is that together, the states and this skill dont work. The damage calculated by the reverberation skill that gets passed to the state doesnt consider damage modifiers this way. I can see why, but i cant think of an *easy* way to go about it. From what i get from this, a state's Confirm Effects run after a skill's Pre-Damage Eval effects, so additional damage multipliers applied this way are being applied after ive already set the damage to 0.
I can't see a convenient way around this with the number of multiplier states that i already have and the lack of a "multiplier stat" i can reference (which would also require me to change every state to even start setting up). I cant have the skill itself easily check for each state alone either since the damage multipliers for each may vary and calculating for each would just lead to bugs down the line when i add more later and forget to add them to this skill.

Am I overlooking something? Is there an easier way to achieve this anyone else can think of, or am I just left to doing either of the above? If its the latter, I'd be leaving it as is and putting a note somewhere that the damage of the skill cant be boosted, but one of the points of the game is to combine effects on different classes and try to break it before it breaks you. id figure itd be more fun for a player if it worked.
Maybe someone else will think of something that didn't occur to me.

But I think the most efficient way to do this would be:
1 - Edit Buffs & States Game_Action.onPreDamageStateEffects() to sort the states by ID. So, say, after line 1860 you do states.sort(function(a, b) {return a.id - b.id});

2 - Use an earlier notetag in the skill (e.g. Before Eval) that applies a state to the user.

3 - Make sure that state is the highest ID state you're using with any confirm effects.

4 - Take your damage storing and nullification out of the skill's Pre-Damage. Give your state a Custom Confirm Effect with that code, and then it removes itself.

That means that code is now the last thing to run before damage execution occurs, so it should store the damage with all modifiers.
EDIT: Actually, realized that if you have multiple different damage altering states, that wouldn't work.

(Hmmm, wouldn't it also work if you put a conditional in your pre-damage to not change the value to 0 if the user is affected by any of those states? And then in the states' notes put a conditional with "if this is reverb skill" change the value to 0 (and store the final damage before that). Don't know if that's most efficient though (or if it even works, LOL).)
But I think the most efficient way to do this would be:
It sounds promising. Ill give it a shot... When I can.
My pc decided to pull a really cool trick today and BSOD mid raid. Windows wont boot and ill have to go get a spare drive in the morning from somewhere just to start off of. All the data looks intact, and my last backup of the project was today across 2 drives anyways, but all the options Windows offered to troubleshoot it sans formatting the main drive failed and id rather not do that

Don't know if that's most efficient though (or if it even works, LOL).)
I can see that working too, but it runs afoul of the same issue I had with having the skill adjust for each state, Just that it'll be across the states instead of the skill. If I add more damage states later, ill have to keep considering the skill(s?) and keep making exceptions too. I know myself well enough to know that some will slip through the cracks and ill have to bug hunt them later. If I had less states itd be more practical
And then in the states' notes put a conditional with "if this is reverb skill" change the value to 0 (and store the final damage before that).
The problem, as I read the OP, is that there are potentially multiple states that affect the damage.

So you'd have to not only do that, but also have the state check whether it's the last state in the user's state array. It's possible, but in the end it's more code and processor work than just sorting the array.

Well, maybe. I suppose it depends on how out of order the array is and how many times sort has to iterate through it.

But it's tidier, anyhow, less to copy and paste 😉

Original thread: https://forums.rpgmakerweb.com/threads/damage-timing-problem.163499/