not sure if this script is right, but im trying to make a troop event, for if the enemy reaches 10% of hp then the event happends and the battle is aborted, the thing is, it works like 50% of the time, sometimes the battle is aborted but other times the battle still continues, so dunno if the event needs fixing, this is the script i used
var enemyId = 1; // Replace 1 with the actual ID of your enemy
var thresholdPercentage = 10; // The desired threshold percentage
// Get the enemy object
var enemy = $gameTroop.members()[enemyId - 1];
// Calculate the minimum HP based on the threshold percentage
var minHp = (enemy.mhp * thresholdPercentage) / 100;
// Check if the current HP is below the minimum
if (enemy.hp < minHp) {
// Set the HP to the minimum
enemy.setHp(minHp);
}
// Now the enemy's HP will not drop below 10%
so i dont know why half the time the event doesnt abort the battle, i dont know if its the damage dots or an attack is stronger than 10% of enemy damage, it just doesnt want to work
i want it so any attack will not make the enemy drop bellow 10% hp no matter how stong the attack is, that way i can abort the battle
I could use immortal state but i want a more realistic approach, when your hp reaches 0 ur dead, so i dont want the enemy hp to reach 0, it needs to be 10% and cannot lose anymore hp no matter what
var enemyId = 1; // Replace 1 with the actual ID of your enemy
var thresholdPercentage = 10; // The desired threshold percentage
// Get the enemy object
var enemy = $gameTroop.members()[enemyId - 1];
// Calculate the minimum HP based on the threshold percentage
var minHp = (enemy.mhp * thresholdPercentage) / 100;
// Check if the current HP is below the minimum
if (enemy.hp < minHp) {
// Set the HP to the minimum
enemy.setHp(minHp);
}
// Now the enemy's HP will not drop below 10%
so i dont know why half the time the event doesnt abort the battle, i dont know if its the damage dots or an attack is stronger than 10% of enemy damage, it just doesnt want to work
i want it so any attack will not make the enemy drop bellow 10% hp no matter how stong the attack is, that way i can abort the battle
I could use immortal state but i want a more realistic approach, when your hp reaches 0 ur dead, so i dont want the enemy hp to reach 0, it needs to be 10% and cannot lose anymore hp no matter what