Compatibility between two plugins (resolved)

Good morning,
I need help making two plugins compatible with each other.
I'm reaching the end of the combat part of my project, and I realize that there are some slight bugs due to the various origins of certain plugins. Most come from yanfly but not all.
You will probably need to master javascript to resolve this problem.

Here are the two incompatible effects (I give the codes and sources at the end):

1)
I created a state which allows an actor to protect another actor by absorbing part of the damage suffered in the form of reduced MP loss.
For example, actor A places the state on actor B. If B takes 1000 damage, then he will take 800 damage instead, but A will lose 20 MP.

2)
I also created a parry system using another plugin. It works pretty much like dodging. A parried attack will not inflict any damage. There's not much else to say.

My problem :
When a character parries an attack while he has the state that I described in 1), he does not suffer any damage but he transfers 20% of the damage to the other actor in loss of MP. Which is not supposed to happen.

Here are the codes:

Damage transfer (the annotations are not necessarily accurate because there has been some modification to the base code, but everything works):
Spoiler: Code
Code:
<Custom React Effect>
// Check if the action dealt HP damage
if (this.isHpEffect() && value > 0) {
  // Get the target's allies
  var members = target.friendsUnit().aliveMembers();
  // Get the Aura's Origin State ID
  var auraOriginId = 102;
  // Make the origin user undefined
  var auraOriginUser = undefined;
  // Loop through each member
  for (var i = 0; i < members.length; ++i) {
    // Get the currently looped member
    var member = members[i];
    // Check if the member exists, isn't the target, and is the aura holder
    if (member && member !== target && member.isStateAffected(auraOriginId)) {
      // Set the origin user to that member
      auraOriginUser = member;
      // Break the loop
      break;
    }
  }
  // Check if the origin user exists
  if (auraOriginUser) {
    // Calculate the amount of reduction
    var reduction = Math.ceil(0.08 * value);
    // Set the damage to the target to 0.
    value = value * 0.8;
    value = Math.round(value);
    // Make the origin user take damage instead.
    auraOriginUser.gainMp(-reduction);
    // Display an animation on the origin user.
    auraOriginUser.startAnimation(271);
    // Make the origin user display a damage popup.
    auraOriginUser.startDamagePopup();
    // Check if the origin user is dead
    if (auraOriginUser.isDead()) {
      // Collapse the origin user if dead
      auraOriginUser.performCollapse();
    }
    // Clear the origin user's results
    auraOriginUser.clearResult();
  }
}
</Custom React Effect>


The parry:
Spoiler: Code
Code:
<Custom React Effect>

var blockValue = (target.isEnemy() ? target.enemy().blockValue : target.equips()[1].blockValue)
var blockPercent = (target.isEnemy() ? target.enemy().blockPercent : target.equips()[1].blockPercent)
if (target.result().isBlocked()) {
target.addState(164);
value -= Math.round(value * (blockPercent/100));
value -= blockValue
value = Math.max(value, 0)
var blockAnim = (target.isEnemy() ? target.enemy().blockAnimation : target.equips()[1].blockAnimation)
target.startAnimation(blockAnim, true, 0);
target.requestMotion('guard')
}
</Custom React Effect>

The sources :
Spoiler: Link


The solution I would like if possible:
I don't know if it is possible to solve my problem, but can we consider an if/else condition in the damage transfer code?
I have another damage transfer state in my game, this will allow me to solve all my problems at once. I would really like to keep my parry system.
Thanks to those who will help me.

(translation by google, please ask me to rephrase if necessary)
If there is an actual plugin conflict and not just user error it will be hard for anyone to help you because Ramza's one is paid, meaning only those who have it or the author himself can look at the code.
have you tried changing the priority of the states so that the parry state is higher than the damage transfer one? iirc since theyre both react effects, if theyre both the same priority then the first one in the DB runs. if its the transfer one if higher, then the mp damage from the transfer happens before the parry reduces the damage to 0
Thank you for your response, especially to Robro33.
I thought the solution would be much more complex.
Parry's state being an "invisible" state, I gave it a priority of 0. I thought that the priorities were just an order of display of state alterations.
In any case, it works. Thank you very much =)

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

Original thread: https://forums.rpgmakerweb.com/threads/compatibility-between-two-plugins-resolved.162724/