Yanfly Skill cooldown, help to reset on kill

I'm trying to make a skill that has a 2 turn cooldown, but if it kills the target, the cooldown is reset to 0.

I have no idea what I'm doing...someone who knows the plugin help me please XD


What I put in the skill note tag:
Spoiler
<Cooldown Eval>

if (target.hp <=0) {

cooldown = 0;

}

</Cooldown Eval>

<Cooldown: 2>

So far it gives an error that the target is undefined.
I can think of a few possible issues. First, <Cooldown: 2> may be conflicting with your <Cooldown Eval>. Get rid of the <Cooldown: 2> notetag and try this instead:

<Cooldown Eval>

if (target.hp <=0) {

cooldown = 0;

} else {

cooldown = 2;

}

</Cooldown Eval>

My big corcern is that if target is undefined, then it's trying to find something that no longer exists. In that case, we may need another solution. If Plan A doesn't work, try this instead:

<Cooldown Eval>

cooldown = 0;

if (target && target.hp > 0) {

cooldown = 2;

}

</Cooldown Eval>

I may need to dig a little more to find a solution, because I'm not sure that this will work either. I don't know if target can even work in this case.
Well it didn't work, I may just have to find a different gimmick for the skill :/
I think it's still possible; we just need to figure out a way to change the cooldown after it's been set. Let me check into the script side of it and see what I can find.

Edit: Maybe if we try an <Post-Damage Eval> notetag. Try this:

<Post-Damage Eval>
if (target.hp <= 0) {
user.setCooldown(SkillID, 0);
}
</Post-Damage Eval>

If that doesn't work, I have another idea. It's a bit of a workaround, but it could work if this doesn't.
Oh wow that one works! Thanks a bunch

Original thread: https://forums.rpgmakerweb.com/threads/yanfly-skill-cooldown-help-to-reset-on-kill.92991/