Add buff to ally other than user + damage to enemies

Adding a buff to the user while dealing damage to the enemy is quite straightforward, I just use the damage formula e.g.
a.add_buff(3,3); a.atk * 4 - 2.def * 2

However, I want to add the buff to another ally (ideally it would always be actor 3) as well as deal damage to the enemy. Is there a way of doing this?

An escalation of the query would be - could this be done for all allies and all enemies?

Thanks
formulas run directly through the kernel, with the difference of having "a" and "b" as stand ins for actor and enemy, and "$game_variables" as an implicit argument.
so, you just run the code for grabbing actor 3 out of the actors object: "$game_actors(3).add_buff(x,y); formula"

this is a formula I used to decide damage with a condition.
Code:
b.hp / b.mhp < 0.25 ? {b.add_state(1); return b.mhp * 0.25} : return -1;
instantly kills anyone below 25% HP and heals the user for that amount.

check for enemy belonging to enemy type group before returning damage.
Code:
[b.element_rate(35), b.element_rate(34)].any?{|el| el > 1} ? 20 : -1;
damages only undead and demons

reverse damage calculation from function returned from third-party plugin (my personal favorite)
Code:
-a.xstat.patk + (b.hp.to_f * 0.26 / 70.0 * b.xstat.pdf.to_f).round
returns a negative damage to bypass the battle system's damage calculation, and any enemy defense, to deal a fixed 26% HP damage.


you just run the code.
you just run the code.
Sadly, if I could just "run the code" I would not be posting here.
None of the examples you gave apply to my particular query, so I am unable to use any of them as a basis on which to build.

Thank you, though, for taking the time to answer.
I think you would replace "a.add_buff" with "$game_actors[3].add_buff", though this would add it to Actor ID 3, if they exist in your battle party. If you wanted the actor in the 3rd slot, there's a way to reference that too, but I forget the syntax.
sorry, should have been $game_actors[3], not $game_actors(3)

I thought it would be evident the different combinations of code to run that you can make by using the damage formula, but I guess it wasn't.....
@Wavelength It is actor 3 that I wanted, so that is fine. Thank you very much.
Would you happen to know the syntax for a skill which would apply the buff to all allies?
Could you do:
Code:
$game_party.battle_members.each { |act| act.add_buff(3,3) }
@A-Moonless-Night In a test run that appears to work flawlessly.
Thank you very much for your help.

Original thread: https://forums.rpgmakerweb.com/threads/add-buff-to-ally-other-than-user-damage-to-enemies.95147/