A skill that changes based on if it's used by an Actor or an Enemy?

I've made a healing skill which is a little overpowered, it heals all allies, but I want this to be devided equally for all allies.
Then I realised that if I want to give it to an enemy, this skill should count the length of the enemies in the troop instead. I came up with this code and put it in the Damage Formula, but enemies nor allies heal at all now. Please help me, it might be a tiny error!


JavaScript:
if (this.isEnemy()) {
    (300 + a.mat) / $gameTroop.aliveMembers().length
} else {
    (300 + a.mat) / $gameParty.aliveMembers().length
}
don't use this - use b
that is the official shortcut to the skill target
don't use this - use b
that is the official shortcut to the skill target
I knew it would be easy. Thank you!
You can also get rid of the conditional entirely by using the appropriate reference to the group.

Code:
(300 + a.mat) / a.friendsUnit().length
You can also get rid of the conditional entirely by using the appropriate reference to the group.

Code:
(300 + a.mat) / a.friendsUnit().length
Oh, that's even better and probably the best way to do it for me. Thank you!

Original thread: https://forums.rpgmakerweb.com/threads/a-skill-that-changes-based-on-if-its-used-by-an-actor-or-an-enemy.166495/