Apply State To User On A Non-Damaging Skill

EDIT: Looks like the best solution here is to download Yanfly's Action Begin/End Plugin and apply the State to the user through <End Action: Add State x>.

Currently, I'm trying to create a Skill that seems simple, but is proving to be a bit complicated to implement. In short, this Skill applies a State to the enemy targeted by the Skill, while also applying a separate State to the user. The threads I've encountered so far with people attempting similar things are usually met with the easy answer of applying the user's State through the Skill's damage formula (so something like a.addState(11); [damage formula]) - however, by not including any actual damage in the formula, this ends up applying both States and then subsequently making all enemies affected by the Skill not lose HP upon taking damage.

I have also tried achieving this effect through two separate Common Events which each have their own problem, either through Force Action causing the user to use a separate Skill immediately after (which is a bit messy, as it involves 2 separate actions - I'd rather the one action apply both States), or though Change State, which requires a specific target which can't simply be "User" or "Target".

Is there something I'm missing here? Some way to not have damage in the damage formula without breaking the game? Some way to use Common Events to apply States more flexibly? Any help would be appreciated.

For what it's worth, I'm using pretty much every Yanfly Core plugin (or, at least those related to combat), and can add any other plugins if needed.
Your wording is slightly confusing. I'll set out what I have understood you to be asking, so if I'm incorrect it will be easier to spot.
You want to apply a state to the user (e.g. state 11)
You also want to apply a state to the target (e.g. state 57)
You do not want to apply any damage to the target, simply apply the state.

I am at a loss to understand the bit about all enemies then not taking any damage. I assume that this is an attribute of one of the states.

Did you try:

a.addState(11); b.addState(57)

obviously putting your real state id in instead of 57
Your wording is slightly confusing. I'll set out what I have understood you to be asking, so if I'm incorrect it will be easier to spot.
You want to apply a state to the user (e.g. state 11)
You also want to apply a state to the target (e.g. state 57)
You do not want to apply any damage to the target, simply apply the state.

I am at a loss to understand the bit about all enemies then not taking any damage. I assume that this is an attribute of one of the states.

Did you try:

a.addState(11); b.addState(57)

obviously putting your real state id in instead of 57

Ah, sorry about that! I'm still getting used to the vocabulary here, but I'll try to explain things to the best of my abilities.

You're correct about what I'm intending - with a single Skill, add a state to the user (a) and the target (b). My first attempt was what you laid out (a.addState(x); b.addState(y)), and upon using the Skill, State X was applied to the Skill's user and State Y was applied to the Skill's targets. I used HP Damage under the Type drop-down menu, as leaving it as None would not allow me to input anything into the formula.

However, with this, in addition to applying State Y to all applicable targets, it would deal 0 damage to them. Afterwards, using damage-dealing Skills against them would still display the damage number, but their HP would not go down, rendering them functionally immortal (and for whatever reason, they would all take 0 damage simultaneously at the end of every subsequent round). Here are some screenshots to help illustrate this: [Screenshot 1] [Screenshot 2]

So as you can see, once the Skill's effects have been applied, all enemies take 0 damage, and then upon taking subsequent damage, no HP is depleted. It's a bit weird! However, even just adding "1" into the Formula has things functioning normally - no more invulnerability, no more 0 damage at the end of each round.

Is there any more information you need? It seems like having a Damage Type at all associated with it is the source of the problem (as no matter what's in the Formula, it expects to deal damage), but without a Damage Type, there's no Formula.

EDIT: I have a version of this Skill that technically functions, but only because of a Common Event that applies the State to the specific actor that also happens to be the user (rather than the "user" in script terms), so the problem doesn't seem to have to do with the States themselves. I'm trying to go about this subtractively, but there may be things under the hood that I'm missing.
I'm not an MV user, but if this had happened in Ace, I would be looking for a script (in your case a plugin) which might be affecting this.

Okay, let's go with what the engine seems to be wanting to do as a work around. Try
a.addState(x); b.addState(y); 0

It may be that having some damage number indicated (even if it is zero) will satisfy it.

Or, you could reverse things and have
b.addState(y); a.addState(x)
I'm not an MV user, but if this had happened in Ace, I would be looking for a script (in your case a plugin) which might be affecting this.

Okay, let's go with what the engine seems to be wanting to do as a work around. Try
a.addState(x); b.addState(y); 0

It may be that having some damage number indicated (even if it is zero) will satisfy it.

Or, you could reverse things and have
b.addState(y); a.addState(x)

I ended up deactivating all plugins just to see if the problem was related to them, however nothing seems to have changed. Even reversing the states in the Formula (b before a) yields the same results, although again, indicating damage even as low as 0 stops this problem from occurring. I think the cleanest solution for this would be to ultimately find a way to remove damage popups on specific Skills, although I haven't found anything that would allow me to do that yet.

My band-aid solution for this right now is to just deal MP damage, which doesn't have a damage popup - although this might be due to enemies not currently having mana, so that might end up falling apart if there's some way to give them mana and I do it. Although, I just noticed that for whatever reason, applying the State to the user (a) through the Formula ends up extending the State's duration from 1 Action to 3, so I'm not sure what's up with that (as doing it via Common Event causes it to function as intended). Increasing the duration to 3 Actions will cause the State to tick down normally upon using the 3rd Action, so it seems to be increasing the duration by 2 rather than setting it to 3. The State applied to the targets (b) works as intended.
Did you remember to save the project after disabling the plugins but before testing? I can't seem to replicate the issue in v1.5.1, regardless of plugins. 😅

A skill with a formula will evaluate it and apply the final clause's value as damage/healing, showing the amount as a popup. In this case, addState happens to return null, which is coerced to the numerical value 0. Good practice to put add the ";0" at the end just to be safe, though. The following snippet should suppress all zero-value popups in battle. If you want to try it out, just save it as a .js file and import as you would a plugin:
Code:
_Sprite_Damage_createDigits = Sprite_Damage.prototype.createDigits;			// Alias
Sprite_Damage.prototype.createDigits = function(baseRow, value) {
	if (value !== 0) _Sprite_Damage_createDigits.call(this, baseRow, value);	// Callback
}
Did you remember to save the project after disabling the plugins but before testing? I can't seem to replicate the issue in v1.5.1, regardless of plugins. 😅

A skill with a formula will evaluate it and apply the final clause's value as damage/healing, showing the amount as a popup. In this case, addState happens to return null, which is coerced to the numerical value 0. Good practice to put add the ";0" at the end just to be safe, though. The following snippet should suppress all zero-value popups in battle. If you want to try it out, just save it as a .js file and import as you would a plugin:
Code:
_Sprite_Damage_createDigits = Sprite_Damage.prototype.createDigits;            // Alias
Sprite_Damage.prototype.createDigits = function(baseRow, value) {
    if (value !== 0) _Sprite_Damage_createDigits.call(this, baseRow, value);    // Callback
}

Previously, I had only turned off all but the Core plugins (since I needed those in place for other things to work), but I ended up going back and deactivating them all before activating them one-by-one to get a more accurate look at the problem. It seems like the problem of the self-applied State (applied to "a" in the Skill's damage formula) being extended by 2 Actions only occurs when the Battle Engine Core plugin is on, while the problem of enemy HP not being depleted by damage once affected by the State-applying skill (again, using damage formula) only occurs when the Damage Core plugin is on.

...Which is pretty unfortunate, since these plugins are not only what's making all the other important plugins work, they also provide a lot of useful functionality themselves! I'm at a bit of a loss at what to do about this - maybe if there were some way to designate the target of Add State effects (beyond the target), or if Event Commands could be directed at "user" and "target" rather than having to specify a named actor or variable number.

UPDATE: It looks like the weird State extending side-effect only occurs when the Removal Condition is set to Action End (rather than Turn End), so I'm not really sure what that means. This lessens the problem somewhat for my current case since I can technically change it to Turn End and bump the Duration up by 1 (as a 1 Turn duration would end before the character can act on their next turn), although ideally I'd like to find a cleaner solution.
I think you may be getting confused over the different state removal timings?

Let's say Harold is afflicted two states: Poison, which wears off after 3 periods at Action End, and Haste, which wears off after 1 period at Turn End. Haste gives Harold the Action Times +100% trait, letting him act twice per turn! The battle turns might go like this:
  • Harold attacks twice. After each attack, the Poison's duration decreases by 1, due to the Action End timing. At the end of the turn, Harold suffers damage from the Poison state during the regen phase, then the Haste state's duration decreases by 1 and is removed. =(
  • Harold guards, since the Poison has left him low on health. At the end of his action, the Poison's duration decreases by 1 and is removed (since it's now 0). At the end of the turn, there are no states left on Harold and he takes no poison damage. =)
Yanfly's Battle Engine Core modifies the timing of Action End states that are applied to on self, as stated in the plugin's help documentation:
States with Action End have a unique trait to them where if the caster of
the state is the current active battler (subject) and if the state is then
applied on the user itself, they will gain a 'free turn'. The 'free turn' is
to mitigate the user from losing 1 duration of the turn since with an Action
End timing, they would lose the benefit of being under the state for that
turn's timing.
To compensate, the plugin adds Turn Start and Action Start removal timings via state notetags. Any regen from traits will be applied at the end of the turn.

I'm not familiar with Yanfly's Damage Core plugin, myself. Are you using it to make a custom formula for the state damage? Depending on what you're using it for you may be able to use just Buffs & States Core.
I think you may be getting confused over the different state removal timings?

Let's say Harold is afflicted two states: Poison, which wears off after 3 periods at Action End, and Haste, which wears off after 1 period at Turn End. Haste gives Harold the Action Times +100% trait, letting him act twice per turn! The battle turns might go like this:
  • Harold attacks twice. After each attack, the Poison's duration decreases by 1, due to the Action End timing. At the end of the turn, Harold suffers damage from the Poison state during the regen phase, then the Haste state's duration decreases by 1 and is removed. =(
  • Harold guards, since the Poison has left him low on health. At the end of his action, the Poison's duration decreases by 1 and is removed (since it's now 0). At the end of the turn, there are no states left on Harold and he takes no poison damage. =)
Yanfly's Battle Engine Core modifies the timing of Action End states that are applied to on self, as stated in the plugin's help documentation:

To compensate, the plugin adds Turn Start and Action Start removal timings via state notetags. Any regen from traits will be applied at the end of the turn.

I'm not familiar with Yanfly's Damage Core plugin, myself. Are you using it to make a custom formula for the state damage? Depending on what you're using it for you may be able to use just Buffs & States Core.

I see what you mean, and that "Free Turn" buffer for Action-based States is handy (although I'm not really seeing its effect - as upon removing the Plugin, a 1-duration Action-based state is still removed after the actor's next Action, with the timer removing it after 0 rather than after 1 unlike Turn-based States)...However, I'm not sure if that's the main issue here, as the +2 extra Action issue only occurs when the State is applied through the Damage Formula, rather than through Common Events.

To break it down, let's say [Skill] has Damage Type: None (and thus has no Damage Formula), so instead, it applies a State to the Skill's targets (All Enemies) through the Add State effect, and applies a State to the user through a Common Event Effect that targets a specific, named actor and thus would necessitate a unique copy of that Skill for any actor it could be applied to, which seems like it would introduce way more problems than it would fix. Applying the States this way functions as intended, with all enemies receiving a 3-Turn State that ticks down at the end of each round and is removed when the round ending would bring it to 0, and the specific, named user receiving a 1-Action State that ticks down whenever they act, and is removed after they perform one Action.

Now, let's say [Skill (Dud)] has Damage Type: MP (since it doesn't show a damage popup, and with the Damage Core Plugin causing a scene when no damage is mentioned in the Damage Formula, I have to put 0 in there). Now, this is the version that applies the States through the Damage Formula, since this allows the State to be applied to the user of that Skill (whoever it may be), and looks something like this: a.addState(11); b.addState(12); 0. This has the desired effect of applying the 3-Turn State to enemies and having it work as intended, however, when the 1-Action State is applied to the user in this specific way, it doesn't count down Actions until the user has acted twice (so the first two Actions don't reduce the time down from 1, then the next Action reduces it by 1, removing it).

For the time being, changing the duration from Action to Turn and hiding the countdown (since it only lasts 1 turn) should work as a temporary fix, however this still leaves issues with future Skills that may rely on Turn duration to function as intended, or those with a longer duration which would need to be displayed to the player. Since this seems like it might be a bug with the plugin's functionality and not a "How do I do this?" sort of thing, it might be best for me to take it to some sort of Yanfly-specific board, although I'm not really sure where that would be, since there isn't really any such place on its main site and this forum is more RPG Maker-focused. However, if there are any ways to apply States to the user of a Skill without using Damage Formula (or having to specify a named actor or index number with Common Events), I'm all ears!

EDIT: I ended up rooting through some of the Plugins I wasn't using, and it seems like Yanfly's "Action Begin/End" Plugin provides the cleanest solution to this. By adding the State to the user at the end of their Action (rather than through RMMV's default Damage Formula or through Battle Core's <After Eval> note tag), any Action-based durations behave as intended.

Thanks for the help, and hopefully this solution works for anyone else having the same problem!
Well, I'm still not sure what's happening with your project, but glad you've found a satisfactory solution. =P

Actually, it may be worth checking that your plugins are the latest versions and that they're loading in the recommended order, as listed on yanfly.moe/yep? Even if this problem is solved, it's worth checking now in case of future issues.

Happy RPG Making! 😂

Original thread: https://forums.rpgmakerweb.com/threads/apply-state-to-user-on-a-non-damaging-skill.91875/