In most cases, doing a condition check simply use "self" or "self.xxx" should works.
eg. self.transparent = true/false will show/hide whichever game object in that class currently running this command method,
which can be event/enemy/follower or even player.
Not sure what you are trying to achieve, a 3-party war situation maybe?
Due to the way how the battle system is setup, the current available "target" is either "friend" or "opponent" for Game_Actors/Game_Enemy.
So I don't think "self" check works here because it will still link to "MY" foe/friend.
To create a brand new "army"(3rd target) into the battle that has their own friend/foe setting will mean you need to make a new unit.
(Both Game_Party and Game_Troop are considered a set of units by their own in the battle scene both are super classed by Game_Unit)
(Both Game_Actors and Game_Enemy are the "Factions" in battle, super classed by Game_Battler)
To make a new unit, you have to at least clone game_troop + game_enemy and rename it accordingly.
Then check for those that link to the methods in $game_troop and add the new $game_troop_clone to whichever lines calling it.
eg, datamanager, battlemanager, scene_battle... and lastly you need a way to "call" the new units as battlers into the battle.
datamanager manages the global $ for the new class
battlemanager setup the battles calling troops and parties into the game.
scene_battle is a new scene that is called when you encounter a battle (and return to scene_map with results after the battle)
Not an easy job but do-able for those that have the time for it.
And it sounds like you are almost there,
Since you managed to set it up to attack enemies and not player, and not all enemies attacking themselves.
I assume you have found your way to create a new unit by cloning the existing ones.
But still need that final add-on bit?
If you did clone one of the party/troop class (renamed and rewired the new class and methods into the class game_unit)
and made a 3rd battle party available in the battle,
they should be having their own set of targets and allies even though they still uses the enemy graphic and settings.
So i am not sure why they are still attacking themselves unless the methods are still pointing to somewhere wrong.
---------------------
Or, alternatively.. If you only want one enemy to act out of the way..
Don't really remember how the ally targeting works, since i haven't been using the original battle engine for ages,
but might be easier to just make a set of skills that target allies only,
and have that enemy use that skill and you should be able to have it attacking other enemies. If this is what you did and it's attacking itself.
Means you probably need to find a way to minus itself from the member index the game_action script is referring to. Scripting is still needed but at least much easier than making a 3rd battle party.
Or, simply have it acts like a "hostage" like most game did. Put an "invisible"(no icon) state on it at the start of a battle
and disable it from doing anything through out the battle.