Row Formation Question

So my concern is doing an ability which increases the damage and healing of the spells from the X tree by a set percentage. But it is only supposed to work if the character is in the front row.

Any ideas about how can I do that? I researched and tried a lot of things but could not succeed nor could I find anything of value. If you have any ideas it would be very welcome.

Original thread: https://forums.rpgmakerweb.com/threads/row-formation-question.85702/