Spreading State

Trying to make a State that if casted on an Actor that already has the state, apply state to all party members.
I'm using Visustella State and skills. This is as far as I got lol I cant code but I'm trying.


<JS On Add State>

if target.isStateAffected(35)

</JS On Add State>
imo itd be easier to make any skills that apply this state apply it to the whole unit if the state was already on the primary target. i believe that notetag runs after the state is applied, not before. so any check within the state to see if its on the affected battler would only ever be true.

Edit: eh, realized setting it to the skills might be a cumbersome if you have other sources of it. try this
Code:
<JS On Add State>
if (target._applied)
  target.friendsUnit().aliveMembers().forEach(member => member.addState(state.id))
target._applied = true
</JS On Add State>

<JS On Erase State>
delete target._applied
</JS On Erase State>
Hmmmm doesnt seem to work, Just reapplies to the character who had it.
1740237577651.png

Would it be easier to do in the damage formula? Also yea I want character to kind of play off each
other so I'll have multiple Actors who can use the Shield Skill but this actor might be the only one who's shield spreads on apply if they already have one.

b.isStateAffected(35) ? (b.addState(35).allfriendunits) : b.addState(35)

something like that I don't know lol
Just reapplies to the character who had it.
oh. yeah, should have thought that one through 🤣
i blame the morning

use after the "if" line isntead
Code:
target.friendsUnit().aliveMembers().filter(member => !member._applied).forEach(member => member.addState(state.id))

Edit:
didnt notice this
b.isStateAffected(35) ? (b.addState(35).allfriendunits) : b.addState(35)

something like that I don't know lol
you can use the damage formula for it if youre not making use of the autobattle trait for actors. since youre already using visustella plugins though, you can just use notetags for it.
Code:
<JS Post-Apply>
if (target.isStateAffected(35))
  target.friendsUnit().aliveMembers().forEach(member => member.addState(35))
else
  target.addState(35)
</JS Post-Apply>
if you do this, you should remove the prior code from the state
Like this?
1740239339471.png
yes. did you try it and it didnt work?
Yea still only refreshes the state on the Actor

just saw your edit above trying now.

This for whatever reason just gave it to everyone first cast.
1740240033983.png

GOT IT! Just changed the Post-Apply to Pre-Apply Works perfect now! Thank you Rob at this rate im gonna have to put you in the credits of my game lol
This for whatever reason just gave it to everyone first cast.
you have to remove the skill effect for it to work
you have to remove the skill effect for it to work
ahhhh okay okay thanks again, really appreciate the help!

Original thread: https://forums.rpgmakerweb.com/threads/spreading-state.175736/