Hey all,
In my game I have this state I made that checks what element is dealing the killing blow to the enemy. It looks like this:
I apologize for the ugly code. Probably a lot of unnecessary stuff in there. Anyway, this works in most cases. The problem is when I use an attack that has repeats in it. So if I have an attack that hits 10 times, and the target dies after the first hit, this will run every single time.
I've tried using target.isDead() and target.isAlive() but those don't seem to be recognized while an attack is repeating. What I think I need is something that checks if the attack is changing the target's HP (since it's stuck at 0, right?), but I don't know how to check that.
I don't think the other Yanfly notetags will work. They seem to run with the wrong timing, or something like "on removal" doesn't seem to work in the case of death.
In my game I have this state I made that checks what element is dealing the killing blow to the enemy. It looks like this:
JavaScript:
<Custom Deselect Effect>
var lethal = 1;
var nonlethal = 2;
var diplomacy = 3;
var xp = target.def;
var basexpa = $gameVariables.value(1);
var basexpb = $gameVariables.value(2);
var basexpc = $gameVariables.value(3);
if (this.isHpEffect() && target.hp == 0 && this.item().damage.elementId === lethal) {
target.startAnimation(65);
$gameVariables.setValue(1, basexpa +xp);
}
if (this.isHpEffect() && target.hp == 0 && this.item().damage.elementId === nonlethal) {
target.startAnimation(60);
$gameVariables.setValue(2, basexpb +xp);
}
if (this.isHpEffect() && target.hp == 0 && this.item().damage.elementId === diplomacy) {
$gameVariables.setValue(3, basexpc +xp);
}
</Custom Deselect Effect>
I apologize for the ugly code. Probably a lot of unnecessary stuff in there. Anyway, this works in most cases. The problem is when I use an attack that has repeats in it. So if I have an attack that hits 10 times, and the target dies after the first hit, this will run every single time.
I've tried using target.isDead() and target.isAlive() but those don't seem to be recognized while an attack is repeating. What I think I need is something that checks if the attack is changing the target's HP (since it's stuck at 0, right?), but I don't know how to check that.
I don't think the other Yanfly notetags will work. They seem to run with the wrong timing, or something like "on removal" doesn't seem to work in the case of death.