Need help with a weird macro

Hello guys. I am looking for a pvp macro that will cast harmful spells on my friendly party members target without me having to target my party member to get the spell off. For example, lets say I want to mind blast whoever my party2 member is targeting, however, I do not want to have to click on his frame to do so. also, if my party members enemy target is out of range or LoS, then id like for it to cast the spell on the nearest target enemy player if possible. the current macro i am using is this:

#showtooltip mind blast
/cast [@targettarget,harm] [] mind blast

however, i need to target my party member first in order for it to work. so if i am being trained down as a healer, its not efficient as i have to target my party member then target myself again to heal.

Would

/assist party2

work?

#showtooltip
/cast [@party2target] Mind Blast

There’s also this if you want something more universal.

that actually works. thank you so much. now i just wish that there was a way to make a macro so that if im not able to cast a spell on party1’s target (if theyre behind a pillar or line of sight) that it will automatically then go to party2’s target. is that possible?

That sort of thing generally only works with phasing (or off-GCD spells like PI). That said, you can setup your macros for it regardless.

#showtooltip
/cast [@party1target,harm,nodead] [@party2target,harm,nodead] [] Mind Blast