[RMMV] State passing from one enemy to another, every turn (using Yanfly perhaps?)

Moon_Haven

Veteran
Veteran
Joined
May 5, 2020
Messages
168
Reaction score
65
First Language
French
Primarily Uses
RMMV
Hello! Need some help conceptualizing this one out.

In essence, I have a skill that applies a debuff state. What I want to add is: for 5 turns, this state will remove itself from current enemy and jump to another enemy.

Here's what I'm thinking of:

1- Skill applies state (duration 1 turn)

2- State to have Custom Apply

Code:
<Custom Apply Effect>

    // Duration of plague
    target._plagueTurns = 5;

</Custom Apply Effect>
3- Every turn, the state removes itself, so in my state, I would also have:

Code:
<Custom Remove Effect>

    // Check if the party is in battle.
    if ($gameParty.inBattle()) {

        // Remove 1 turn from plague duration
        target._plagueTurns -= 1;

        // Plague only jumps if >0 turns left
        if target._plagueTurns > 0 {

            // Get list of all foes
            var members = user.opponentsUnit().aliveMembers();

            // Remove current bearer of plague
            members.splice(members.indexOf(user), 1);

            // Select one member to transfer the plague to
            var member = members[Math.floor(Math.random() * members.length)];

            // Transfer plague state and remaining turns
            member.addState(10);
            member._plagueTurns = user._plagueTurns;

        }

    } else {

        // Not in battle, kill the plague
        user._plagueTurns = 0;

    }

}

</Custom Remove Effect>
Wondering if anyone would approach this one differently?
 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
2,604
Reaction score
1,961
First Language
English
Primarily Uses
RMMV
Edit: I don't think this would work quite the way you're envisioning, because the Custom Remove Effect for each turn after the first will treat the enemy that *currently* has it as target, rather than the original one the state started on.
 

Moon_Haven

Veteran
Veteran
Joined
May 5, 2020
Messages
168
Reaction score
65
First Language
French
Primarily Uses
RMMV
Edit: I don't think this would work quite the way you're envisioning, because the Custom Remove Effect for each turn after the first will treat the enemy that *currently* has it as target, rather than the original one the state started on.
hmm.. okay, I see what you mean. Have you worked on something similar or have any suggestion?
 

HumanNinjaToo

The Cheerful Pessimist
Veteran
Joined
Apr 18, 2013
Messages
1,226
Reaction score
603
First Language
English
Primarily Uses
RMMV
I think you could take a look at the Yanfly Roaming Mend state from tips and tricks to see how to handle a state that moves to new targets.

Basically, the state is given charges. Each turn a charge is consumed, if another charge exists, then the state is removed from the current affected unit and moved onto a random ally unit, else if no charges exist then it is just removed.

This is handled through the <Custom Apply Effect> and <Custom Remove Effect> and <Custom Deselect Effect>

I think if you read through the note tag for this state and come to understand how it works, with some slight changes, you can make it into what you want.
 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
2,604
Reaction score
1,961
First Language
English
Primarily Uses
RMMV
Yeah, I think I have this. The trick is removing the 1 turn expiry and handling the jump manually. It just means you'll have to remove the state from the old target. Give me 5 and I should have something that works.

Edit: Try this.

Code:
<Custom Apply Effect>
    // Duration of plague
    target._plagueTurns = 5;
</Custom Apply Effect>

<Custom Turn End Effect>
  target._plagueTurns -= 1;
  if (target._plagueTurns > 0) {
    var members = target.friendsUnit().aliveMembers();
    members.splice(members.indexOf(target), 1);
    var member = members[Math.randomInt(members.length)];
    member.addState(24);
    target.removeState(24);
    member._plagueTurns = target._plagueTurns;
    delete target._plagueTurns;
  } else {
    target.removeState(24);
    delete target._plagueTurns;
</Custom Turn End Effect>
 
Last edited:

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Profile Posts

Day 9 of giveaways! 8 prizes today :D
He mad, but he cute :kaopride:

Our latest feature is an interview with... me?!

People4_2 (Capelet off and on) added!

Just beat the last of us 2 last night and starting jedi: fallen order right now, both use unreal engine & when I say i knew 80% of jedi's buttons right away because they were the same buttons as TLOU2 its ridiculous, even the same narrow hallway crawl and barely-made-it jump they do. Unreal Engine is just big budget RPG Maker the way they make games nearly identical at its core lol.

Forum statistics

Threads
106,040
Messages
1,018,476
Members
137,824
Latest member
dobratemporal
Top