MZ Trying to make a passive that adjusts damage taken based on states.

For a little more context than just the title, in the states I've created, I've got two called Redirection and Conduction. Using Visustella's Aggro Control System plugin, they're a Physical Taunt and Magical Taunt respectively. I'm currently trying to make a passive state that halves or doubles damage taken based on these effects. For example, if an actor has Redirection active on them, physical damage they take will be halved, while magical damage will be doubled.

I've tried hashing out some code and I think I'm close to something working, but I'm running into issues. This is the itteration of the code that works best:
Code:
//Attempt 1
<JS Pre-Damage as Target>
const stateRedirectId = 60;
const stateConductId = 61;

//Check if taking Damage
if(this.isHpEffect() && value > 0) {
    //Check if under effect of Redirection
    if(target.states().includes($dataStates[stateRedirectId])) {
        //Check for damage type
        if(this.isPhysical) {
            //Halve damage
            value *= 0.5;
        } else if (this.isMagical) {
            //Double damage
            value *= 2;
        } else {
            value *= 1;
        }
    }
    //Check if under effect of Conduction
    if(target.states().includes($dataStates[stateConductId])) {
        //Check for damage type
        if(this.isPhysical) {
            //Double damage
            value *= 2;
        } else if (this.isMagical) {
            //Halve damage
            value *= 0.5;
        } else {
            value *= 1;
        }
    }
}
</JS Pre-Damage as Target>

This code properly halved physical damage when the actor was affected by Redirection, but didn't do anything to magical damage. I tried a second version with a different structure, but it didn't have any effect at all.

Would anyone mind looking over my code and helping me figure out what I need to change to get it working?
isPhysical() and isMagical() are function calls, not objects - they need the open and close parentheses after them.

There's also no need to have the else at the end that multiplies damage by 1, that's the same as not doing anything.

Since you're manipulating the damage outside of the damage formula, you also want to make sure you end up with an integer value. So instead of
Code:
value *= .5;
do
Code:
value = Math.round(value * .5);
That got it working. Thank you!

Original thread: https://forums.rpgmakerweb.com/threads/trying-to-make-a-passive-that-adjusts-damage-taken-based-on-states.166954/