How to make a state that lasts as long as the caster is alive

stramin

Veteran
Veteran
Joined
Nov 4, 2012
Messages
231
Reaction score
95
First Language
spanish
Primarily Uses
N/A
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)
 
Last edited:

DoubleX

Just a nameless weakling
Veteran
Joined
Jan 2, 2014
Messages
1,818
Reaction score
969
First Language
Chinese
Primarily Uses
N/A
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 ;)
 

Milennin

"With a bang and a boom!"
Veteran
Joined
Feb 7, 2013
Messages
2,773
Reaction score
1,939
First Language
English
Primarily Uses
RMMV
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.
 

Walldeaf

The Event-Master
Veteran
Joined
Apr 29, 2013
Messages
91
Reaction score
70
First Language
Dutch
Primarily Uses
RMVXA
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.

First, make the Wrap skill put a state on its user too
So the snake wraps the actor, and they both cannot do anything,untill the snake is killed?
That snake is making the ultimate sacrifice.
 

kirbwarrior

Veteran
Veteran
Joined
Nov 13, 2014
Messages
827
Reaction score
567
First Language
English
Primarily Uses
N/A
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.
 

JamesRyan

Game Designer
Veteran
Joined
Sep 13, 2014
Messages
704
Reaction score
224
First Language
Vietnamese
Primarily Uses
RMMV
I think of a way to do this. You just need a passive state (Require YEP Passive State plugin) for the snake, checking each of its damage-taking phases (Custom Respond Effect, Custom Regenerate Effect) to see if it is dead (or its HP is 0), then remove the state on all affected actors. This is a bit complex, but I think I can do it. You may try my method as below:

- Passive state for the snake:
Code:
<Custom Respond Effect>
if (target.isDead() || target.hp <= 0){
var members = target.opponentsUnit().aliveMembers();
var affected = [];
for (var i = 0; i < members.length; ++i) {
var member = members[i];
if (member && member.isStateAffected(X)) { //Change X to your "Wrap" state
affected.push(member);}}
for (var i = 0; i < affected.length; ++i) {
var member = affected[i];
member.removeState(X); //Change X to your "Wrap" state
member.startAnimation(Y);}} //Change Y to your desired animation ID if you want some fancy animation displayed
</Custom Respond Effect>

<Custom Regenerate Effect>
if (user.isDead() || user.hp <= 0){
var members = user.opponentsUnit().aliveMembers();
var affected = [];
for (var i = 0; i < members.length; ++i) {
var member = members[i];
if (member && member.isStateAffected(X)) { //Change X to your "Wrap" state
affected.push(member);}}
for (var i = 0; i < affected.length; ++i) {
var member = affected[i];
member.removeState(X); //Change X to your "Wrap" state
member.startAnimation(Y);}} //Change Y to your desired animation ID if you want some fancy animation displayed
</Custom Regenerate Effect>

Basically, these two phases are enough to check the status of the snake. However, there are still other damage-taking phases (Turn End, Turn Start, or when the snake attacks, etc). And when you make use of them, you will need to set up more.
 

Milennin

"With a bang and a boom!"
Veteran
Joined
Feb 7, 2013
Messages
2,773
Reaction score
1,939
First Language
English
Primarily Uses
RMMV
So the snake wraps the actor, and they both cannot do anything,untill the snake is killed?
That snake is making the ultimate sacrifice.
No, you use a unique, invisible state on the enemy itself, which is used in the event to check whether there is an enemy with Wrap in the encounter, and whether that enemy is alive.
 

coyotecraft

Veteran
Veteran
Joined
Mar 13, 2012
Messages
163
Reaction score
104
First Language
English
Primarily Uses
Use battle events.
Trigger: Enemy HP = 0; remove Wrap status from all actors.
 

Walldeaf

The Event-Master
Veteran
Joined
Apr 29, 2013
Messages
91
Reaction score
70
First Language
Dutch
Primarily Uses
RMVXA
Use battle events.
Trigger: Enemy HP = 0; remove Wrap status from all actors.
Was thinking the same thing. kinda like paralyze, but remove when the enemy dies.
 

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
960
Reaction score
506
First Language
English
Primarily Uses
RMMV
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).
 

kirbwarrior

Veteran
Veteran
Joined
Nov 13, 2014
Messages
827
Reaction score
567
First Language
English
Primarily Uses
N/A
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.
The main upside is if multiple enemies in multiple battles would do it. If it's (say) a single boss with a snake minion that does the wrap, the battle event will take far less less effort. If it's a player learning Wrap (say, as a blue mage) then you'd need those battle events in every battle.
 

stramin

Veteran
Veteran
Joined
Nov 4, 2012
Messages
231
Reaction score
95
First Language
spanish
Primarily Uses
N/A
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.
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.
I like this idea, and yes, there is the "more than 1 snake and more than 1 wrapped actor" problem.

I think of a way to do this. You just need a passive state (Require YEP Passive State plugin) for the snake, checking each of its damage-taking phases (Custom Respond Effect, Custom Regenerate Effect) to see if it is dead (or its HP is 0), then remove the state on all affected actors. This is a bit complex, but I think I can do it. You may try my method as below:
This is also a good idea, and I think the "more than 1 wrapped actor" problem could be fixed storing the affected actor id# or index# in a variable, then when the snake dies, it removes that actor state only, I think I saw an id#/index# stored like this before in a yanfly action sequence.

Use battle events.
Trigger: Enemy HP = 0; remove Wrap status from all actors.
This sounds very simple, I see the "more than 1 snake" problem continues here.

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).
You are right, a snake using wrap, could not use it again on a second actor, and if the wrapped actor dies, the snake should be able to use wrap again too!

This is getting more and more complex :kaojoy:
 

kirbwarrior

Veteran
Veteran
Joined
Nov 13, 2014
Messages
827
Reaction score
567
First Language
English
Primarily Uses
N/A
I like this idea, and yes, there is the "more than 1 snake and more than 1 wrapped actor" problem.
I don't know which of Yanfly's example videos talks about this (and I'm sorry, I don't even know what you'd search for), but I do know that a state can be connected to a unit or another state in some manner.
 

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
960
Reaction score
506
First Language
English
Primarily Uses
RMMV
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.
 

coyotecraft

Veteran
Veteran
Joined
Mar 13, 2012
Messages
163
Reaction score
104
First Language
English
Primarily Uses
"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.
 
Last edited:

stramin

Veteran
Veteran
Joined
Nov 4, 2012
Messages
231
Reaction score
95
First Language
spanish
Primarily Uses
N/A
Thank you all guys!

I finally did it, this is the code on the "wrap" state notetag:

Code:
<Custom Action End Effect>
if (origin.isDead() || origin.hp <= 0){
    user.removeState(63); // or any state you want to disable when the origin caster dies
}
</Custom Action End Effect>

Thank you again! :kaojoy:
 

JamesRyan

Game Designer
Veteran
Joined
Sep 13, 2014
Messages
704
Reaction score
224
First Language
Vietnamese
Primarily Uses
RMMV
Thank you all guys!

I finally did it, this is the code on the "wrap" state notetag:

Code:
<Custom Action End Effect>
if (origin.isDead() || origin.hp <= 0){
    user.removeState(63); // or any state you want to disable when the origin caster dies
}
</Custom Action End Effect>

Thank you again! :kaojoy:
This solves your problem, but not for all party members at once. In case the enemy's skill is a single one, it works perfectly. But if it is an AoE, just use mine above if you need all actors to be free of the state at the same time when the caster dies.
 

stramin

Veteran
Veteran
Joined
Nov 4, 2012
Messages
231
Reaction score
95
First Language
spanish
Primarily Uses
N/A
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 :kaojoy:
 

Latest Threads

Latest Posts

Latest Profile Posts

Have any of you read Sutter Kane?
My winter pack is now free on itch.io!
Writing music for Utara Forest, a location in All the King's Men. Nothing evokes a mysterious, dreamy sound like solo clarinet and modulation!
Man, nobody has created an MZ state animation plugin outside of VisuStella. That breaks my heart.
Finnuval wrote on Alador's profile.
Cute new avatar you got there ;)

Forum statistics

Threads
111,467
Messages
1,061,324
Members
144,840
Latest member
mrdiouf
Top