As previously discussed
battler.friendsUnit() will give either
$gameParty or
$gameTroop, whichever one is appropriate. In either case the unit will have a function called
unit.members() that will give us an array with all members that are part of that unit (during battle we will only get actual battle members, not benched members).
On second thought we should probably use
unit.aliveMembers() instead. That will automatically exclude any dead members from the above mentioned array.
In javascript arrays have the built-in function
array.forEach(). This function takes another function as its argument and executes it once for each element of the array.
I declared this function using the shorthand arrow function.
JavaScript:
x => {/*some code here*/}
//the above is shorthand for the following
new function(x){/*some code here*/}
x (or as I called it above 'mate') is the name of the current element of the array for which forEach is currently executing the function.
JavaScript:
//Example
[1,3,5].forEach(x => console.log(x));
//Expected Output:
//1
//3
//5
//the {} around console.log(x) can be omitted
//since the function consists of a single statement
Since we are talking about doing stuff to the target's teammates I presumed you wanted to exclude the target from the processing. That's why I added the
if(target != mate){/*...*/} condition as the first statement of the function that I am passing to forEach. In this function you can refer to the currently processed teammate as 'mate' (though you can of course also choose any other name). So
mate.startDamagePopup() and so on ...
Lastly a side-note: I'm not sure how javascript handles this, but I am fairly certain that you would actually need to type out 0.5 instead of shortening it to .5 in other programming languages.