Create skill that returns Damage x2 based on the amount of damage done to an Ally.

Hi there, everyone!

I didn’t see an MV specific Forum, so I dropped it here.

I am using RPG Maker MV. So what I was trying to do was to create a skill that returns damage times 2 to an enemy after they damage an ally. Depending on which ally you select, the damage they were dealt will be returned to the enemy that dealt it to them. I’m not new to RM necessarily, but I am new to creating skills, and using plugins and such.

I’m just wondering if this is possible, or if anyone has created a skill anything like this, and how they made it work. Thank you, in advance.
MV (Support) has its own section, that's probably why you missed it.

I've moved this thread to MV Support. Thank you.

You can do this with Yanfly's SkillCore and BuffStateCore plugins.

Put this in a universal state's notebox
Spoiler: State Code
Code:
<Custom Respond Effect>
//Makes sure it doesn't work on healing skills
if((this.isHpEffect() && value > 0)){
  target._storedDamage = target._storedDamage || 0;
  //Sets the damage taken and which enemy did it.
  target._storedDamage = value;
  target._returnTo = user.index();
}
</Custom Respond Effect>

<Custom Battle Effect>
user._returnTo = -1;
</Custom Battle Effect>

and put this in a skill that targets allies' notebox
Spoiler: Skill Code
Code:
<Before Eval>
target._storedDamage = target._storedDamage || 0;
target._returnTo = target._returnTo || 0;
//Transfers target and damage to the user of the skill so it doesn't get overwritten
user._damageToDeal = target._storedDamage * -2;
user._toTarget = target._returnTo;
</Before Eval>
<After Eval>
//Set proper troop so enemies could potentially use the skill.
var toDamagePool = $gameTroop;
if(user.isEnemy()){
toDamagePool = $gameParty;
}
//Check that the target to return damage to is alive.
if(user._toTarget !== -1 && toDamagePool._enemies[user._toTarget].isAlive()){
  var toDamage = toDamagePool._enemies[user._toTarget];
  //Deal that damage to the target.
  toDamage.startAnimation(1,false,0);
  toDamage.gainHp(user._damageToDeal);
  toDamage.startDamagePopup();
}
</After Eval>
@rainyday Thank you for your response! I need to do a little bit of brushing up with the RM programming, but you sure know your code. I'll try it out when I get back to my laptop tonight!

Thanks again!

Original thread: https://forums.rpgmakerweb.com/threads/create-skill-that-returns-damage-x2-based-on-the-amount-of-damage-done-to-an-ally.117046/