MZ Faction/variable increase / decrease on creature death.

Hello everyone, plugin wizards, and the like. I hope your new years and holiday celebrations went great. I'm getting the itch to work on my project again and I am wondering the possibility of creating an extremely simple faction system. How I envision it, would be through use of enemy note tags. Ie;

Kobold Runt
<Factions>
Variable 100: +1
Variable 101: -10
</Factions>

It must be enemy specific, because troops may have several different types of enemies with various faction hits.

I just want the game to add or deduct an assigned variable when the enemy dies or their health reaches 0. I'd like to be able to assign as many variables as id like. At least 10 if unlimited is not an option.

If for whatever reason this extra bit is also possible; if it could be made to have plugin settings where the corresponding variable and label for it could be assigned. Then I could use the label in the note tags instead. For example,

In the settings;

Variable #: 100, name; Qeynos
Variable #: 101, name; Kobold King

Note tag example;

Kobold Runt
<Factions>
Qeynos: +1
Kobold King: -10
</Factions>

I hope I'm outlining this correctly. I'm in the very beginning stages of learning JavaScript. Lol.

Thank you for your time!
Sounds like something you can just do with states. Using visustella's skills and states core, perhaps with an on erase or on expire notetag. Not sure if they have an alternative to yanfly's autopassive states, but I would imagine so. Sadly I'm not on MZ myself, so I'm not too familiar with their notetags, but considering they have ported almost all of yanfly functionality over to their library, this should be fairly straight forward.

If that's the case, you can just give each of your enemies a state that runs js code to increase/decrease the proper variables.
It probably wouldn't be all that hard to make a plugin that does exactly what you request and no more.

Using states for this wouldn't be my first choice, as it seems like a bit of a roundabout way to do it, but if that works for you then that's great.

I could also envision leveraging the default EnemyBook plugin to take care of this. That would be a bit of work though. The EnemyBook doesn't even work in MZ, though the tracking part might work (and the rest you could just ignore). Of course, you can only do this if you own both MV and MZ.
It probably wouldn't be all that hard to make a plugin that does exactly what you request and no more.

Using states for this wouldn't be my first choice, as it seems like a bit of a roundabout way to do it, but if that works for you then that's great.

I could also envision leveraging the default EnemyBook plugin to take care of this. That would be a bit of work though. The EnemyBook doesn't even work in MZ, though the tracking part might work (and the rest you could just ignore). Of course, you can only do this if you own both MV and MZ.

I only use MZ, unfortunately, with no plans to use MV. With my limited experience I can't picture how I would make it work with the visumz states core. Unless maybe I'm making a different state for every enemy type or something, but I'd have to dig into it to even get a grasp of it. I would probably figure out the most complicated, inefficient way to get it working anyways.

There's a few mechanics I want to try to figure out and this is one of them that I'm having trouble with. I have no grasp at how difficult or easy it would be to develop a plugin like this.

My battle system is triggered, so I COULD implement a very crude faction system in the if won section, but id have to keep troops with similar enemies. Otherwise, if it wasn't possible to make the plugin I might just go with quest turn in style faction gains. Like turn in kobold teeth or something and get it that way.

Using a plugin like this could also enable me to keep track of how many specific enemies are killed, which would be nice for quest tracking purposes too.

Is it something you'd be able to take a crack at?
Hmmm, I didn't test this, so it might be sh*t, but here's a suggestion (I also don't know how to use REGEXP):

ENEMY NOTETAG:
<Factions:
blue:+5
green:-8
>

DEATH STATE NOTETAG (VS States)
<JS On Add State>
if (target.isEnemy()) {
target.changeFactionValues();
}
</JS On Add State>

PLUGIN:
const enemyFactions = {
red : 10,
blue : 11,
green : 12
}

Game_Enemy.prototype.changeFactionValues = function() {
const tagLines = this.enemy().meta.Factions.split("\n");
tagLines.forEach(line => {
if (line === "") return;
const split = line.split(":");
const name = split[0];
const value = split[1].parseInt();
const variable = enemyFactions[name];
$gameVariables.setValue(variable, $gameVariables.value(variable) + value);
});
};

EDIT: Oh yeah and to be clear, in the enemyFactions object the values are the variable Id of the faction

Original thread: https://forums.rpgmakerweb.com/threads/faction-variable-increase-decrease-on-creature-death.181862/