MV (MV) Enemy Team System Addon?

I'm working on a project which features multiple factions, many of which are hostile towards each other. And I want to have some fights where multiple factions are involved at once and have them attack each other as well as the actors. At first, I tried using statuses, first attempting with "Attack Allies", this kind of worked, but they'd never attack the actors, and they'd also attack the other that are in the same faction. I also tried "Attack Everyone", and while Free-for-alls are cool, it's still not what I wanted. I figured this had to be done with plugins/scripts.

I couldn't find anything like this when searching around plugin lists so I thought I'd put the idea out here. Because although on its own it's rather simple, I like to think it has a lot of potential, even in other kinds of projects.

How it'd work is enemies can have a "team number" in their notetags. Like <Team X>, and if there are enemies with different team numbers in the troop, they will be hostile towards each other. For simplicity, the default enemy team number will be 1 if it's unspecified.
So for example, this troop contains 3 unique enemies; "Bat" has <Team 1>, and "Slime" also has <Team 1>, but "Orc" has <Team 2>. All these enemies will attack the actors, and while Bat and Slime will not attack each other, will also attack Orc, and Orc will also attack Bat and Slime.
An extra idea I had was that <Team 0> could refer to the Actor's team, and they'd act as allies if set on team 0, but this is not something I see being easy to do without altering too much of the battle system.

Why do I say Addon? Well because in an attempt to create the battle system I wanted, I'm running a few different battle system plugins to sloppily create the active battle style that I wanted, I'm using Yanfly's Battle Core (with action sequences and AI cores and bunch of other flair stuff), and DoubleX Popularized ATB Core (which I find to be a bit buggy but is only ATB that doesn't pause the enemies and battle when the party command window opens, or that I know anyway). So I'm hoping that if this can be a simple addon to the default battle system then it won't have any trouble integrating with these other battle plugins.
You can do this using Yanfly's Target Core.

You'd look at an enemy's notetags with $dataEnemies[battler.enemyId()].meta

So, for example, if you want the scope of a skill to include the actors plus any enemy with the notetag Team2, you'd do:
Code:
<Custom Target Eval>
targets=$gameParty.aliveMembers();
targets=targets.concat($gameTroop.aliveMembers().filter(enemy => $dataEnemies[enemy.enemyId()].meta.Team2));
</Custom Target Eval>

You could also do it so your notetags are formatted:
Code:
<Team: 1>
<Team: 2>
etc.

Then you can make a skill target all actors as well as any enemies that aren't on the same team as the attacker:
Code:
<Custom Target Eval>
targets=$gameParty.aliveMembers();
targets=targets.concat($gameTroop.aliveMembers().filter(enemy => $dataEnemies[enemy.enemyId()].meta.Team!=$dataEnemies[user.enemyId()].meta.Team));
</Custom Target Eval>
Ah, thanks.
Tried the method you suggested and it works great!
It hits every eligible target, which proves that the team notetag works, now I just need to get it to scope one random out of them. I'm no good at custom scripting, but I imagine it's simple to do.
I often get mixed up mentally between the two - you may want to use Yanfly's Selection Control instead.

To reproduce my second example, able to target actors or anyone on a different team:
Code:
<Custom Select Condition>
condition=target.isActor() || $dataEnemies[target.enemyId()].meta.Team!=$dataEnemies[user.enemyId()].meta.Team;
</Custom Select Condition>

Then it should continue to obey your single target scope from the database. If that still doesn't work...urm, not sure.
The new set doesn't work.
I put only one actor, three enemies on team 1 and another three on team 2. And they always target the actor.
I got curious and tried removing target.isActor() || in hopes that it could now only pick from the enemies, and it still targets the actor.
I then tried putting both the Target and the Select code in the skill, and it seems the target script overrides select and it still sweeps every target.
I got it working. The first target script was correctly picking the eligible targets, I just needed it to pick one of them randomly.
I got some help in extending this script to have it make a new array for a single chosen target which picked randomly, then clear the target list and use just the chosen target.

<Custom Target Eval> targets=$gameParty.aliveMembers(); targets=targets.concat($gameTroop.aliveMembers().filter(enemy => $dataEnemies[enemy.enemyId()].meta.Team!=$dataEnemies[user.enemyId()].meta.Team)); var chosenTarget=targets[Math.floor(Math.random() * targets.length)]; targets=[]; targets.push(chosenTarget); </Custom Target Eval>

This notetag when applied to an enemy skill works perfectly.
I'd say this thread can now be closed.

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

Original thread: https://forums.rpgmakerweb.com/threads/mv-enemy-team-system-addon.158485/