I think I have an idea. This is your code.
if @active_battler.is_a?(Game_Actor)
@common_event_id = 1
end
for target in @target_battlers
target.attack_effect(@active_battler)
end
Right now, the event id is hardcoded to 1, so obviously it will always use the first common event. So we need to define which enemy was targetted.
There is a property for each enemy called
index. This property tells us what position the enemy has inside the enemy group. So, this actually tells us if it is the 1st, 2nd, 3rd, and so on.
Now, in order to be able to access the
index, since is a property of the enemy object, we need a reference to that enemy object.
Luckily for me (?), you've actually shared a place that includes a reference to that object!
for target in @target_battlers
target.attack_effect(@active_battler)
end
And this is the new code:
for target in @target_battlers
if @active_battler.is_a?(Game_Actor)
@common_event_id = target.index if target.is_a?(Game_Enemy) ########
end
target.attack_effect(@active_battler)
end
The important line is the one marked with the #s. The for cycle iterates between all targets. We now check if the attacking battler is an actor (like in your code), and if it is, we set the common event ID to the target index if target is an enemy.
And voilĂ ! It should activate a common event depending on the targetted enemy index. Only thing is, if your attack affects all enemies, it will only run the last common event.
But I'm lazy today so I leave this here xD. Salut!