How to make an enemy attack every thing but not itself?

I am making an enemy that has a 50% chance to attack everything, allies and enemies, but I do not want it to hurt itself. I managed to make it also attack its allies with a common event attached to the skill but it keeps hurting itself.

Actually to expand on this for a more preferable option, how can I give it like a new class or something that makes it immune to the specific attack.

Since I use the common event for the part of the attack where it hurts its allies I can maybe do a conditional branch there but I already don’t know much about how “force action” works

Enemies don’t seem to have classes in VX Ace, but each one has its own Features list in the Enemies tab, so an element could handle the immunity part. Add a new element in the Terms tab (something like Chaos), set it as the Element on the skill that hits the allies, then give this enemy an Element Rate feature (under Resistance) for Chaos at 0%.

The catch is every copy of that enemy gets the immunity too, so if a troop has two of them they won’t hurt each other. If that matters, what if you tried checking for the user in that skill’s damage formula instead? a is the user and b is the target, so this only zeroes out the hit when it lands on itself:

a == b ? 0 : a.atk * 4 - b.def * 2

Swap the part after 0 : for the formula the skill already uses. Either way it’s still in the target list, so the battle log will show it taking no damage.

Thank you once again, I actually am gonna just stick with having the enemy type immune to it cause that was my plan I just forgot to mention it so that i can have two in a troop but them not hurt each other.

Actually to continue on the topic of this enemies skill, in the common event that triggers the skill that attacks the allies, in the battle how can I make it so the enemy that uses the skill is not simply the first enemy.

For example if there are two of the all ally attacking enemies and the first one dies, no one is there to do the skill. Or when the first enemy isn’t even the chaos enemy.

I considered using variables to get the enemies ID but I don’t know how in the common event I would use it.

The common event doesn’t know who used the skill, but the damage formula does, so you could have the formula save the user’s spot in the troop to a variable. In the skill that triggers the common event, something like this (variable 10 is just an example, any free one works):

v[10] = a.index; a.atk * 4 - b.def * 2

Keep your own formula as the last part. The first enemy in the troop is 0, the second is 1, and so on. Then in the common event, add a Conditional Branch for each value. Variable 10 == 0 runs Force Action on Enemy #1, == 1 runs it on Enemy #2, up to however many enemies your troops can have. Dead enemies keep their spot in the troop, so the numbers won’t shift when one dies.

The formula only runs when the skill does damage, so if that skill’s Damage Type is set to None I don’t think this will work.