Is there a way to make a buff-stealing skill?

emptymusician77

A human being
Member
Joined
Mar 12, 2019
Messages
2
Reaction score
0
First Language
Tagalog
Primarily Uses
RMVXA
I want to know if there is a plugin or if there is a combination of plugins to use in order to make this kind of skill.
It's where a certain skill is used to take the buffs an enemy already has.

Apologies if there's an obvious answer to this question.
 

JojoLaVache

Easily distracted
Veteran
Joined
Mar 26, 2020
Messages
45
Reaction score
29
First Language
French
Primarily Uses
RMMV
It can be done with Yanfly's Buffs & States Core (a free plugin), I guess, but I can't figure out how.
Here's what I tried to use:
Code:
<After Eval>
// Loop through all parameters
for (var i = 0; i < 8; i++) {
  if (target._buffs[i] > 0) {
  // Copy the target's buffs, if they exist
    user._buffs[i] = target._buffs[i];
  }
  // Remove the target's buffs
  target._buffs[i] = 0;
}
</After Eval>
The problem I have is while I can copy buffs, I can't copy their duration, meaning they'll expire the next turn, and I have no idea how to copy a buff's duration.

EDIT: Nevermind, there's actually a property called _buffTurns that can be used to return the number of remaining turns of a buff. Hooray!
Code:
<After Eval>
// Loop through all parameters
for (var i = 0; i < 8; i++) {
  if (target._buffs[i] > 0) {
  // Copy the target's buffs, if they exist
    user._buffs[i] = target._buffs[i];
  // Copy the duration of the target's buffs
    user._buffTurns[i] = target._buffTurns[i];
  }
  // Remove the target's buffs
  target._buffs[i] = 0;
}
</After Eval>
SECOND EDIT: Turns out my previous code overwrites the user's current buffs. I'll change it a bit again:

Code:
<After Eval>
// Loop through all parameters
for (var i = 0; i < 8; i++) {
  if (target._buffs[i] > 0) {
  // Copy the target's buffs, if they exist
    user._buffs[i] += target._buffs[i];
  // Copy the duration of the target's buffs
    user._buffTurns[i] = target._buffTurns[i];
  }
  // Remove the target's buffs
  target._buffs[i] = 0;
}
</After Eval>
If you also want to add the duration of the target's buffs:
Code:
<After Eval>
// Loop through all parameters
for (var i = 0; i < 8; i++) {
  if (target._buffs[i] > 0) {
  // Copy the target's buffs, if they exist
    user._buffs[i] += target._buffs[i];
  // Copy the duration of the target's buffs
    user._buffTurns[i] += target._buffTurns[i];
  }
  // Remove the target's buffs
  target._buffs[i] = 0;
}
</After Eval>
 
Last edited:

emptymusician77

A human being
Member
Joined
Mar 12, 2019
Messages
2
Reaction score
0
First Language
Tagalog
Primarily Uses
RMVXA
Thanks! Very much appreciated.
 

Moon_Haven

Veteran
Veteran
Joined
May 5, 2020
Messages
168
Reaction score
65
First Language
French
Primarily Uses
RMMV
Hi Guys, I've tweaked the code above from JojoLaVache (lol, ah la vache!) to do the exact opposite: my skill will take all ailments and debuffs from target(s) and transfer them to the user. This spell is for a cleric who will absorb ailments from the group and take it on.

This will require Yanfly's


Code:
<After Eval>

// There will be some healing at the end of all this
var healing = 0;

// TRANSFER AILMENTS

// Get the states the target is currently affected by.
var states = target.states();

// This is the category we want to transfer.
var category = 'Ailment';

// Create a loop that goes through each state.
while (states.length > 0) {

  // Get the currently looped state.
  var state = states.shift();

  // Check if the state's categories has the one we want.
  if (state.category.contains(category.toUpperCase())) {

    // Get the number of turns left on the target for the state.
    var turns = target.stateTurns(state.id);

    // Remove the state from the target.
    target.removeState(state.id);

    // Check if target was already affected by this state
    if (user.isStateAffected(state.id)) {

        // Add existing turns to pool
        turns += user.stateTurns(state.id);

    } else {

        // Add the state to the user.
        user.addState(state.id);

    }

    // Set the number of turns for that state for the user.
    user.setStateTurns(state.id, turns);

    // Add healing
    healing += 1;

  }
}

// TRANSFER DEBUFFS

// Loop through all parameters
for (var i = 0; i < 8; i++) {

    // If debuff
    if (target._buffs[i] < 0) {
       
        // Copy the target's debuffs, if they exist
        user._buffs[i] += target._buffs[i];
     
        // Copy the duration of the target's debuffs
        user._buffTurns[i] += target._buffTurns[i];

        // Remove the target's debuffs
        target._buffs[i] = 0;

        // Heal
        healing += 1;

    }

}

// HEAL

// Check if the healing amount isn't 0...
if (healing !== 0) {

    // Gain HP
    user.gainHp(healing);

}

</After Eval>
 

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

Latest Threads

Latest Posts

Latest Profile Posts

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.
Can someone recommend some fun story-heavy RPGs to me? Coming up with good gameplay is a nightmare! I was thinking of making some gameplay platforming-based, but that doesn't work well in RPG form*. I also was thinking of removing battles, but that would be too much like OneShot. I don't even know how to make good puzzles!
one bad plugin combo later and one of my followers is moonwalking off the screen on his own... I didn't even more yet on the new map lol.

Forum statistics

Threads
106,033
Messages
1,018,441
Members
137,820
Latest member
georg09byron
Top