• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

How Can I Detect the Player Casting a Spell of a Shared Unit?

Status
Not open for further replies.
Level 8
Joined
Jul 8, 2013
Messages
249
Let's say I have a unit belonging to player 1 but with control shared with players 2, 3, 4, 5, and 6. If any of those players casts a spell that the unit has, I want to know which player and have something happen only for them.

What I don't know is how to find which player cast the spell.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,258
In SC2 this is very easy since Triggering Player returns the player who issued the order for a unit to cast an ability. This ironically has created many bugs in many maps with shared control.

In WC3 I do not think Triggering Player works like that. The only way I imagine you can do this is to synchronize current unit selection for all players and see who has the unit selected. Might give incorrect results if more than 1 player has the unit selected at the time of casting.
 
Level 8
Joined
Jul 8, 2013
Messages
249
Right, that was kind of my impression too since definitely multiple not owner players could have selected the same unit.

I think what I'll do instead is sort of fake the ability by giving it a 'hotkey' of the up arrow key and making its effects actually work by player keyboard event. Of course, one can no longer activate the ability by clicking on it, but I think that's just an issue I'll have to accept.
 
Since I haven't personally tried it, did you actually tried to use Triggering Player... just to be sure...

if it doesn't work... and since you seem to already be fine with triggering the whole effect, then you could also opt to make the skills as buyable items instead... that way you can detect the player who bought it... and it will still be "castable" via clicks....
 
Status
Not open for further replies.
Top