Optional Enemies

I'd like a plugin in which I can specify in an enemy notebox if the enemy is an optional kill.


Meaning if that enemy(s) is the last enemy alive at the end of the battle, then the battle counts as a win and is over.


I believe I've seen this kind of thing in games before, perhaps Final Fantasy IX?  Say there's a Chest Enemy in the battle, then you'd want to defeat it or use a skill on it (steal) before you kill the other enemies, if you kill the other 'non optional' enemies first then you miss out on the chance to kill/steal from the chest and gain it's rewards,


Obviously this type of enemy would only work when placed in a troop with at least one other normal enemy, or else it'd be an instant win. 


I hope that made sense, and thanks to anyone who attempts to make this! I'm already amazed at how many plugins there are already for this engine. 
Does this also mean that any optional enemies left alive at the end of a battle do not give loot?  Only the regular enemies you've killed as well as the optional enemies you've already killed?


What battle plugins are you already using?  Any that change the calculation and/or display of battle rewards?
Does this also mean that any optional enemies left alive at the end of a battle do not give loot?  Only the regular enemies you've killed as well as the optional enemies you've already killed?



Yes that's correct. Left over optional enemies retain their loot.


You will only receive loot from the enemies you have killed be they normal or optional.


At least that's how I think it should work. 
What battle plugins are you already using?  Any that change the calculation and/or display of battle rewards?
Yanfly's Battle Engine Core and Yanfly's Victory Aftermath. 
This was easier than I thought it would be - only had to change the battle win conditions, and the loot distribution took care of itself.


Plugin name doesn't matter.  Should work with the plugins you mentioned above.

Code:
//=============================================================================
// OptionalEnemies.js
//=============================================================================

/*:
 * @plugindesc Flag enemies as optional for battle win and loot.
 * @author Shaz
 *
 * @help This plugin does not provide plugin commands.
 *
 * Add <optional> as a tag against an enemy to flag it as an optional enemy.
 *
 * Optional enemies do not need to be killed in order to win a battle.  If
 * you do kill them, you will get loot from them; if you don't kill them,
 * you miss out on the loot.
 */

(function() {

  Game_Troop.prototype.isAllDead = function() {
    return this.aliveMembers().filter(function(member) {
      return !member.enemy().meta.optional;
    }).length === 0;
  };

})();
Just wow, It works perfectly! Thanks so much, I'll be able to do lots more with my battle system thanks to this.


You're amazing, Thank you! 😀  

Original thread: https://forums.rpgmakerweb.com/threads/optional-enemies.70809/