MZ [SOLVED] BattleCore Post-Damage Notetag skill user detection issues

I have this notetag on one of states
  1. <JS Post-Damage as Target>
    //Does counterattack on enemy
    if (this.isSkill() && this.item().id != 154 && user.isActor()) {
    if (user.enemyId() === 12) {
    target.forceAction(380, 1);
    }
    if (user.enemyId() === 13) {
    target.forceAction(380, 2);
    }
    if (user.actorId() === 1) {
    target.forceAction(381, 0);
    } else {
    target.forceAction(381, 1);
    }
    BattleManager.forceAction(target);
    }
    </JS Post-Damage as Target>
    As you can see, it forces an enemy to use certain skill on either enemies or actors when struck, and it does works
    on enemies, but doesn't detect actor hits at all.
    And this is notetag I took as template for this one. And this one actually works, so I found it weird mine doesn't work. Any ideas how to solve it?

    <JS Post-Damage as Target>

    //Does counterattack on enemy

    if (this.isSkill() && this.item().id != 154 && user.isActor()) {

    if (user.actorId() === 1) {

    target.forceAction(366, 0);

    } else {

    target.forceAction(366, 1);

    }

    BattleManager.forceAction(target);

    }

    </JS Post-Damage as Target>

    EDIT: Solved, this is the right code

    <JS Post-Damage as Target>//Does counterattack on enemy
    if (user.isEnemy()) {
    if (user.enemyId() === 12) {
    target.forceAction(384, 1);
    }
    if (user.enemyId() === 13) {
    target.forceAction(380, 2);
    }
    }
    if (this.isSkill() && this.item().id != 154 && user.isActor()) {
    if (user.actorId() === 1) {
    target.forceAction(381, 0);
    }
    if (user.actorId() === 2) {
    target.forceAction(381, 1);
    }
    else {
    }
    BattleManager.forceAction(target);
    }
    </JS Post-Damage as Target>
your logic was off a bit
if (this.isSkill() && this.item().id != 154 && user.isActor()) {
a part of your first check was to see if the user of the skill being used on the target with this state was an actor

if (user.enemyId() === 12) {
target.forceAction(380, 1);
}
if (user.enemyId() === 13) {
target.forceAction(380, 2);
}
two things here. 1) actors do not have an enemyId() method, so these *cannot* happen, as to get past the first check, the user must have been an actor.
2) (the actual issue) in trying to access a non existant method on an actor, itll cause an error and the console would have told you that. the rest of the code then wouldnt run because of the error

Original thread: https://forums.rpgmakerweb.com/threads/solved-battlecore-post-damage-notetag-skill-user-detection-issues.164446/