Sleep - persist after magical attacks

Hi all! Continuing bug crushing. This one I couldn't solve even after searching in the web for quite some time:

Is it possible to keep a sleeping state after the enemy was being attacked by magic? I know this from some games and was wondering if there is an easy way to apply this.

Somehow I feel like nobody ever tried to implement something like that - at least I couldn't find a thread about it.
you define the ways a state can be lifted in the state itself, and if you don't want it to be lifted by damage then simply don't allow that.

If you want something else you'll have to give a better description of when you want a state to be lifted and when not.
you define the ways a state can be lifted in the state itself, and if you don't want it to be lifted by damage then simply don't allow that.

If you want something else you'll have to give a better description of when you want a state to be lifted and when not.
Sure: Only physical damage should remove the sleep state, magical damage should not affect the sleep state.
You would have to modify it with a plugin.

Do you want all states with Remove by Damage to ignore magical? Just this?
You would have to modify it with a plugin.

Do you want all states with Remove by Damage to ignore magical? Just this?
Oh damn okay :/ Whatever would be easier? Preferably only sleep.
Does it work if you uncheck the 'remove by damage' in your sleep state and then use yanfly buff and states core and a state custom respond effect in sleep state note:

<Custom Respond Effect>
if (this.item().damage.elementId <= 1) {
b.removeState(X)
}
</Custom Respond Effect>

(X is the ID of your sleep state + supposing your magic element types start after normal attack, none and physical)
I think @rpgLord69's suggestion is good.

Just as a note, the Buffs and States Core provides the variable stateId to refer to the state the notetag is on.

There are also implementation questions here. How do you want to define "magical" damage? rpgLord's method will do it by element, which might be what you want.

If you change the condition to:
Code:
if (this.isPhysical())
then it will go off of whether you defined the skill to be a Physical Attack or Magical Attack in its database entry.
Does it work if you uncheck the 'remove by damage' in your sleep state and then use yanfly buff and states core and a state custom respond effect in sleep state note:

<Custom Respond Effect>
if (this.item().damage.elementId <= 1) {
b.removeState(X)
}
</Custom Respond Effect>

(X is the ID of your sleep state + supposing your magic element types start after normal attack, none and physical)
This works great. Could you explain to me why you chose "<=" instead of "="?
My element ID 1 is physical. All above is elemental.

Reason: If I use "=" elements again remove the sleep state. That doesn't make sense to me.

@ATT_Turan I tried yours too and it works just as well. Will check my skill settings on which suits the game best.

Thank you both!
Reason: If I use "=" elements again remove the sleep state. That doesn't make sense to me.
= in JavaScript is an assignment operator, just like in math. You're saying "make this equal to this." That will make the code you're trying to do meaningless.

== is a conditional, asking "is this equal to this?"

If you look at your skills in the database, when you're choosing their element there are options for "Normal Attack" and "None," which are not options listed in your list of elements. Those use values less than 1.

Original thread: https://forums.rpgmakerweb.com/threads/sleep-persist-after-magical-attacks.156702/