MV Outcome based on how battle was won.

I want to have a skill that makes the enemy flee under certain conditions. But since enemies are on-map, I need to check if the enemy actually died in the battle or fled. Otherwise, the enemy on map would die in either case. By default, if the enemy flees, it immediately ends the battle with a victory.

I want to have some check if Enemy 1 fled or was killed during the battle. Is there a way to do this?

Edit:
I have a bit of a lead. Maybe with YEP_BuffsStatesCore I can have the applied state check the conditions, and also check if the affected enemy is Enemy 1. If so, a switch is enabled.

Something like this:
Code:
If Intidation stack - Bravery stack >= 5{
If EnemyAffected = Enemy1 {FleeSwitch == True};
EnemyAffected flee;
};
I don't think the core scripts clear troop info after a battle ends, so unless your death state is marked "Remove at Battle End" you may be able to simply use:
  • Conditional Branch -> Enemy -> State: Knockout
Troop info isn't included in save data, but this kind of thing should be fine if you only need to check immediately after battle ends~
I can confirm that the troop's condition can be safely checked after a battle ends (for example, in the "If Win" or "If Escape" block). I recently used this in one encounter to save the enemy's health when the user flees and use that information in another encounter.

The other options would be to turn on a switch when the battle begins, and turn it off when the player wins (which would require a plugin like HIME_EndPhaseTriggers); or turn the switch off when the battle begins and turn it on when the monster flees (which requires the fleeing to be scripted in an event page, not added to the monster's action list).
I cannot for the life of me figure out what the issue is.
1770928405446.png
Assuming that's JavaScript code, I can see two possible issues:

  • With if, you need to enclose the condition in parentheses
  • target.escape does nothing. Maybe you want to call it: target.escape()
Assuming that's JavaScript code, I can see two possible issues:

  • With if, you need to enclose the condition in parentheses
  • target.escape does nothing. Maybe you want to call it: target.escape()
Your advice made the error go away. But the condition doesn't ever seem to yield true. Maybe if the target doesn't have a stack of bravery it should set their stack to 0?

I set a variable called "bravery" to the stack value of the state. Then I checked if it is undefined, and if so, set it to 0. It seems to work as intended, but I'll likely want a bit more delay as it doesn't even have time to update the state counter before the guy flees.

Edit: For some reason turn start never gets triggered.
<Custom Turn Start Effect>
let bravery = target.getStateCounter(8);
if (bravery == undefined) {
console.log("aaaa");
bravery = 0;
} else {
console.log(bravery);
};
if(target.getStateCounter(7) - bravery >= 2) {
target.escape();
};
</Custom Turn Start Effect>
A couple of ideas:
  1. Are your Yanfly plugins loaded in the recommended order? Resources:
  2. Are you using a custom battle system? If so, maybe it doesn't have a "turn start" phase.
A couple of ideas:
  1. Are your Yanfly plugins loaded in the recommended order? Resources:
  2. Are you using a custom battle system? If so, maybe it doesn't have a "turn start" phase.
Your mention of a combat system made me realize I hadn't enabled YEP_BattleEngineCore. I put that in and it worked.

Original thread: https://forums.rpgmakerweb.com/threads/outcome-based-on-how-battle-was-won.182405/