Lets imagine an enemy snake that can use its tail to tie up an actor and immobilize her/him.
The only way I can imagine this is to give the snake a skill "wrap" and this skill will cause a state "wrap", while the actor is in this state can not move.
But, what happens if the snake dies?
I should be able to remove the state when the snake (the caster) dies.
Do you know a way to achieve this?
(I am using Yanfly Buffs & States Core)
I think you're going to need a plugin for this, especially if the battle system you're using isn't the default turn based(while I don't think it's impossible without it, it'd still be far too complicated and convoluted that way).
The core idea of such a plugin would be, for every battler to store the mapping from the ids(key) of their states to the casters(value) of those states, and for every frame, every battler will check whether any caster in that mapping has died, then removes all states from such casters(along with those records in the mapping itself) 🙂
Of course that's not an ideal approach, but the plugin written this way should be at least easy, simple and small enough to be done within hours 😉
First, make the Wrap skill put a state on its user too. Second, run a common event every turn/action that checks whether there's an enemy with that state, and if not, remove Wrap from the actors.
If you have multiple of the same enemies at once (which seems unlikely, if the only way to get rid of it is by killing it), it'll become more complicated. But for 1 enemy with the skill, it's easy to do it this way.
What you could do is make two states; the 'snake' state and the 'wrap' state. The skill in question will give 'snake' to the user and 'wrap' to the target. 'Wrap' does whatever you want, 'snake' should have a custom remove effect that removes the 'wrap' state from all enemies. And then just make sure the state will actually get removed when the snake dies.
Use battle events.
Trigger: Enemy HP = 0; remove Wrap status from all actors.
You should try both ways...I'm curious if there's any advantage to using the second state with a Custom Respond Effect over the battle event.
You could use it to have secondary effects (for example, if you want to say the snake can't attack other people while using Wrap, or can only use specific other moves, like Bite, but not Tail Whip).
They're connected by default by the engine tracking which actor initiated the skill that placed the state on the target actor - in Yanfly's plugins, that's accessible via the variable "origin"
As far as the Wrap changing what else the snake can do, you should be able to do all of that via the state method and Yanfly's A.I.
"more than 1 snake" still isn't a problem for battle events.
But, I got to say, having multiple snakes restrict multiple characters is B.S. game design. You're potentially soft locking the game.
I seriously doubt you'll have more than 2 snakes. But if you insist, you should just make each snake a unique enemy, with individual skills, that inflict, individual status - that are all named the same.
So Snake(a) uses Skill#4 "Coil" which inflicts Status#4 "Restricted"
Snake(b) uses Skill#5 also named "Coil" which inflicts Status #5 also named "Restricted"
From the player's perspective, it's all the same thing. The Battle Event wipes the states accordingly.
It's no effort on your part to copy and paste multiple entries.
Better yet, if the 2 snakes coil the same target they'll have 2 "Restricted" icons!
Edit: To avoid soft locking the game, you should consider adding a battle event to force a game over screen if all the party members are restricted and it's impossible to take any more actions.
Yes, my problem is about a single snake wrapping a single actor.
Maybe I could make a monster able to wrap more than 1 enemy, like an octupus... I like that idea 😂