Random targets damage formula

So I was wondering if it's possible to create a damage formula that if the there is multiple targets it will follow the skill code and hit 4 targets randomly but if there is only one target the damage is reduced? And if the attacker is effected by a state they cannot use that ability.

Thanks,
Oggy
How are you causing the skill to have a variable number of targets in the first place?
You can set it on the skill itself. Where you would set 1 enemy all enemies and self there is a random selection.
It seems to me there are other problems in your setup you'd need to account for.

By default, the X Random Targets skills can hit the same target multiple times. And, of course, if you have few enough enemies in the troop, it's guaranteed to do so.

So if you use your skill against 1 enemy, it's guaranteed to hit them 4 times. Do you want your damage formula to make it so that the 4 hits add up to the total damage it would do to separate enemies? What about if it has more enemies but just happens to randomly hit the same enemy more than once?

There's a lot of room for vagaries here. I'm inclined to say your solution is in VisuStella action sequences, where you can control the skill on a more granular level, but I think you should first codify exactly how you want the skill to behave under all circumstances.

And if the attacker is effected by a state they cannot use that ability.
That's really simple, Seal Skill is one of the traits available for states.
Ideally if there is more than one enemy I want It to hit them for full damage even if it it's the same one twice. But if it's only one enemy the damage would be reduce by the number of perspective hits. So if it can hit 4 enemies then on a one enemy situation the damage would be divided by 4.

The skill is essentially and attack out of pure rage so the hits on multiple targets are random but full power because they "dont know where it will strike next" but a single target would "obviously" know its coming.
Ideally if there is more than one enemy I want It to hit them for full damage...But if it's only one enemy the damage would be reduce by the number of perspective hits.
That's very simple then.
let dam = whatever_your_damage_formula_is; $gameTroop.aliveMembers().length>1 ? dam : dam/4
Thanks for the help.

Original thread: https://forums.rpgmakerweb.com/threads/random-targets-damage-formula.152154/