MV Lethal and Non-Lethal Death States Update Troop Content, Possibly Prevent Mob Respawn

Hi everyone. Title really says it all, but I will elaborate.

I am creating a hobby project in RPG Maker MV, and as I rapidly find myself approaching the nightmarish consideration of a "general troop manager" plugin that replaces the troop tab in the database with a .csv I can control with plugin commands and variables, well, I figured I would pause and ask the community if they've worked on or heard of anything like this:

The concept of this game is that the main character is employed by an organization that grants him license to kill but encourages him not to abuse it with incentive rewards for non-lethally dispatching foes.

So the player will have access to lethal and non-lethal damage types, and those will proc lethal and non-lethal battle-ending or "death" states on targets. Generally speaking, lethal attacks will be devastating damage-wise, non-lethal less so. (not the place for a discussion on this mechanic but basically the damage types target different gauges, to prevent power gaming this)

I'll be using a chrono trigger-style encounter system - there are no "random" encounters save for special circumstances. In general, enemies are events walking around the map, triggering battle on touch. In addition, the player will be able to engage combat with almost any NPC they speak with.

I'll be using a plugin for a calendar system, and after some time passes, enemy events will be able to respawn after defeat, but only if at least one enemy was left "merely KO'd" after the player is victorious.

Thus, the player will have the option to "cull" specific enemies within the troops.

Consider a mob representing an encounter with a troop of five goblins. The player uses a non-lethal state to “merely KO” 4 Goblins, then uses a lethal state to “permakill” the fifth.

As a result, after time passes when the enemy group “respawns,” only 4 goblins remain in that troop.

But… if the player decides to use the lethal state to kill all 5, well, then they won’t respawn at all.

Now when it's 5 goblins, well, whatever. But what if it were 3 bandits and a powerful wizard? The player may want, or even be forced to outright kill the wizard to minimize the damage he can do to the party, while leaving the bandits alive to try and hold on to some of the incentive reward. Just one possible example.

I've been poking around Yanfly's plugin set, as well as looking at MZ plugins. I have found numerous "reinforcement" plugins including Himeworks' that dynamically add and subtract from troops DURING battle, and I also found OcRam's battle_ex plugin that can modify troop content on the fly, but i'm having trouble finding anything that stores state info about the troop and changes what's in it based on that, while also making this information available for events and manipulable via triggers, switches, and states.

"in-engine" solutions to similar problems that I've found seem limited to creating all possible troop configurations and a jungle gym of branch path event logic. That's not a good, expansible solution, and I need one for the game I'm creating - because in the example of the five goblins, all possibilities would already require over 30 troops! which is obviously insane and not sustainable even for 10-15 minutes of gameplay demo.

So, wondering if anyone has encountered or worked on anything like this before in MV! Happy to consider switching engines as well if there's another that accomplishes what i'm looking for out-the-box, but i somehow doubt it because it's somewhat outside the scope for turnbased RPGs.

Thanks everyone!!!
Hmmm at the end of battle store which enemies are afflicted with the "non-lethal death state" to a self-variable of the event that initiates the battle (make the variable an array). Then use your dynamic troop plugin to read that to select the enemies. I haven't checked if you can use that OcRam plugin with variables. If not, maybe you can edit the Game_Troop setup function to not push enemies to the troop enemies list depending on variables.
Hmmm at the end of battle store which enemies are afflicted with the "non-lethal death state" to a self-variable of the event that initiates the battle (make the variable an array). Then use your dynamic troop plugin to read that to select the enemies. I haven't checked if you can use that OcRam plugin with variables. If not, maybe you can edit the Game_Troop setup function to not push enemies to the troop enemies list depending on variables.
heh, well unfortunately i don’t have a dynamic troop plugin yet, haha. i’m thinking to use one of the mining/bonfire solutions posted to this forum, combined with having all troops start with enemies hidden, then we’ll only reveal enemies that didn’t get marked dead last go around.
Oh I thought that OcRam plugin did something like you wanted. Anyway, I thought the problem with that hiding solution is that can you start a battle with everything hidden? I thought you needed at least 1 visible, which would mean those conditionals.
If you decide to use OcRam_Battle_EX

Basically you could do such thing via simulating plugin command via JS.

Example if you have troop with 1,1,2,2 enemy id's and last one gets perma killed:

Just store enemies in variable eg. to id 9.
$gameVariables.setValue(9, "1,1,2")

Then just run this JS script as you would run plugin command before battle:
$gameMap._interpreter.pluginCommand("init_battle", [$gameVariables.value(9)]);

As result combat should start with enemy id 1, 1 and 2.
If you decide to use OcRam_Battle_EX

Basically you could do such thing via simulating plugin command via JS.

Example if you have troop with 1,1,2,2 enemy id's and last one gets perma killed:

Just store enemies in variable eg. to id 9.
$gameVariables.setValue(9, "1,1,2")

Then just run this JS script as you would run plugin command before battle:
$gameMap._interpreter.pluginCommand("init_battle", [$gameVariables.value(9)]);

As result combat should start with enemy id 1, 1 and 2.
right, but wouldn't i need to program a conditional branch for each possible combination for each troop? that would no longer be manageable/testable after more than, say, 5 unique enemy groups

EDIT:
i've found this thread: https://forums.rpgmakerweb.com/index.php?threads/start-end-battle-common-events.55866/

my idea was to create a common event "Battle Eval" that would receive state info from the most recent battle, update all related variables accordingly,

then configure troops such that all enemies "appear halfway," with turn 0 switching the battle evaluator on and causing any enemies whose associated variable is in a living state to appear. but Harold wins the battle instantly if no enemies are in the troop at the start of battle. so we can't start off unpopulated and then selectively populate the troop with appearance, because evaluating whether you win or lose based on enemy party size seems to occur "before turn 0"

i wouldnt want to do the opposite, where it starts populated and the enemy just disappears...

EDIT 2: so, i have found a possible solution to this. HIME already noticed that battle commands terminate as soon as combat is eligible to end, which means the developer has no control, other than enemy death state, over whether a battle ends or not! fortunately he developed this plugin -- https://himeworks.com/2015/10/end-phase-triggers-mv/

using this, i should be able to set up a "life check" for each enemy in each troop at the start of each battle. while somewhat tedious, it's WAY better than multiplying conditional loops to join up different troop configs, even if these are stored as variables in stead of enemy/troop data.

then, i'll combine it with Solar Flare's custom death states - https://forums.rpgmakerweb.com/index.php?threads/miscellaneous-plugins-sfg.122826/.

I was gonna use HIME's but Solar Flare has MP 0 state effects built in, which is great, because i'm going to have non-lethal damage target mp and inflict a "sleep-like" status from which battle can optionally end without turning on that enemy's "dead" switch.

so now the player will be able to enter a battle with 0 enemies, event will check who's alive and make those enemies appear; player can then reduce MP to 0 for 2, reduce HP to 0 for one, ending battle and triggering life/death evaluation for each enemy in the troop and turning on the death switch for just the one; then, when we return to battle, only two enemies will be able to appear. finally, we can also add some interesting undertale-like flavor text for "Exterminated" troops before returning to overworld!!!

will report back if i get this rube goldberg machine working

EDIT 3

So far so good. AS a test, I created a troop with two bats. These bats are set to "Appear Halfway." My game is small in scope, so i will build each and every troop to "initialize enemy visibilty" by checking an isDead switch for each enemy in the troop. I've created an event NPC (bat manager or "batman" for short) where the player uses choices to manipulate those switches, one choice for each bat.

using Hime's end-phase processing, i can let the player configure a state where there are no enemies "appeared" in the troop, and it gives a little "but no one came..." flavor text before aborting battle.

Now, we want the player to be able to configure a battle in which Bat 1 does not appear, and Bat 2 does. the problem is that thanks to end-phase processing, battle never ends. Bat 2 dies, and Harold just flails at the wall, forever. I'm trying to use an End Turn Each Turn event page conditional on the $gameTroop.isAllDead() to abort battle if there's no one there, but i keep getting stuck with the empty battle field after killing the one bat i allowed to appear.

is this because "appear halfway" enemies are "alive" for the purposes of isAllDead?

EDIT 4 - the answer is yes, but i've solved it quite simply - initializing enemy visibility adds one to a "presence counter," starting at 0 on 0th turn, for each enemy appearing in this way. killing enemies, making them flee, knocking them out, or even just having them not appear in the first place - all of these end battle because the count subtracts or was never added to in the first place, and battle ends at the end of a turn where presence = 0. further, i think i could also configure special states that DONT subtract from presence. so you could be left standing there in front of an unconscious foe...many possibilities for diegetic skill use naturally stem from this.

now i want other mechanics to key off these states, and im starting to think that the "template troop" is going to become quite gargantuan to account for all these things. is there a better data structure i can use to key off this stuff? for example, i want the player to get more or less reward from a certain npc that is evaluating their performance throughout the mission. so my initial thought is a common event that adjusts the value, depending on the "kill state" used on each enemy. is there a way to construct common events that basically take arguments from the current battle?
Hmmm okay I hope you get your method working, but if you do what OcRam said, you don't need conditionals. You just need to build the id list based on the variable that tells who is alive. Like if you need to give the ids as a string, I think it's something like:

// you have troop with 3 members and an event self variable array, 0 killed, 1 alive, like [1,0,1]

const troop = $dataTroops[1].members;
let ids = "";
for (let i=0; i<troop.length; i++) {
if (this.getSelfVariableValue(mapId, eventId, varId)[i]) {
ids += troop[i].id.toString();
ids += ",";
}
}

Just add to the end there code to take away the final comma, I've no motivation to check how to do that LOL. But yeah, I think something like that should work.

EDIT: removed the unncessary dot from first code line
hi there... in case anyone is still watching this thread. we now have a fully functional persistence system!

enemies remember their state between battles - if you damage them and escape, they're still wounded when you come back. dead enemies stay dead. the system tracks HP, MP, and status effects.
it's all handled through game variables and plugin commands. each battle can optionally be persistent - regular battles still work normally. the troop event pages stay clean since everything runs in the background.

next step is making map events reflect the battle outcomes - so defeated enemies could show different graphics, or you could interact with KO'd enemies for special mechanics.

thinking about releasing this as a plugin. would anyone be interested? could enable some interesting gameplay - stealth sequences where you hide bodies, or exploration where clearing areas actually matters.

the implementation is pretty straightforward - no complex eventing needed, just simple plugin commands. fully compatible with existing battle systems too.

Original thread: https://forums.rpgmakerweb.com/threads/lethal-and-non-lethal-death-states-update-troop-content-possibly-prevent-mob-respawn.179788/