Get number of Targets

Ok. I want to believe what I'm asking is simple:

 

I want to reference the number of targets (Enemies or allies.) into the damage formula, after spending the whole day searching to reference it, I finally decided to ask.

 

The closest thing I managed to find though was $game_troop.members.size, which doesn't really help cause not only it doesn't get the number of targets, but it's also only referring to enemies (If I'm correct.)

 

Actually I'm using Yanfly's Lunatic damage (Which more or less replaces the normal damage formula.) except that it allows for more than 100 characters.

What I intend to do is:

value /= [number of targets]

 

So if I have a single target, the damage will remain unchanged but when there are two, or more targets. the damage will be divided among them.

 

I'm using Tsukihime's Scope change script which can make a skill or item change it's scope from a single enemy/ally to all enemies/allies and vice versa.

 

That way the player will think more strategically about casting a spell on multiple targets since it won't do as much damage as it would do on a single target.

 

Anyway thanks in advance 🙂

 

Edit: I'm aware that Tsukihime made a script that does this job (Or al least it's easy to modify it do that job.) but unfortunately Yanfly's Lunatic Damage overwrites it and I don't want to choose between those two awesome scripts that can make the gameplay very interesting.
All I can think of is to make a variable array that assigns each target a slot in the array and then counts the number of slots (obviously assign the total to another variable that you will reference). Use the @game_variable call, I think (I'm still a rudimentary scripter).
Well... It would be nice if I could even refer to targets somehow. The thing is I have no clue how VX Ace handles the targets.

If I could find the array that contains the targets I could refer to it as [Array containing targets].length. Well that would be more usefull with actionscript though, but when that time comes it won't be too hard to check how Arrays in Ruby work.
Getting targets is easy.

Install this utility script

http://himeworks.wordpress.com/2013/08/09/utils-action-targets/

Code:
class Game_Action  attr_reader :targets    alias :th_action_targets_clear :clear  def clear    th_action_targets_clear    @targets = []  end    alias :th_action_targets_make_targets :make_targets  def make_targets    @targets = th_action_targets_make_targets  endend
You can retrieve this by checking the user's current action in your formula

Code:
a.current_action.targets.size
Tsukihime Enters the Battle and Scores!

http://i2.kym-cdn.com/entries/icons/original/000/011/065/YES%20MEME.JPG

I feel like a princess trapped inside the dark corridor's of Babician! Today I learned the true meaning of love!

Tsuki-san I wanna have your babies!

 

Seriously now, thanks!

This is truly awesome!

 

Also I didn't get the chance the previous time but even the previous script you made about Dynamically adding Equip Slots worked, but I'm so stupid that I tested it with many scripts that collide.

Anyway thanks again! you are a lifesaver!

 

/lock plz!
This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

Original thread: https://forums.rpgmakerweb.com/threads/get-number-of-targets.16661/