A unit triggers an event. I want to get which player owns the triggering unit. I know you can do a conditional "Owner of unit" == player# which would execute the actions for the proper player, but I'd have to copy/paste this N times for an N-player game. Is there a more elegant way to do it?
Basically, I'd imagine something like:
for i=1 to <number of players>,
if "Owner of unit" == i,
int ownerID == i;
endif,
endfor
works, but I'm not really familiar with galaxy editor syntax/conventions.
Owner of unit returns the player. Players are just an integer value [0,15]. Make your actions/functions take in a parameter of type player (integer) and perform actions on that player #. If you need a unit group variable type, just create it on the fly for the action/function and add the player index to it.
Ah, that clarifies it. That's the sort of thing that I just have to get used to coming from other programming languages where you can call a method/function from anywhere instead of this silliness where you can't do it as an Action for some reason. I was having the same problems with Position of unit, but that answers it. Thanks.
A unit triggers an event. I want to get which player owns the triggering unit. I know you can do a conditional "Owner of unit" == player# which would execute the actions for the proper player, but I'd have to copy/paste this N times for an N-player game. Is there a more elegant way to do it?
Basically, I'd imagine something like:
for i=1 to <number of players>, if "Owner of unit" == i, int ownerID == i; endif, endfor
works, but I'm not really familiar with galaxy editor syntax/conventions.
Thanks for any help.
@mafaraxas: Go
Owner of unit returns the player. Players are just an integer value [0,15]. Make your actions/functions take in a parameter of type player (integer) and perform actions on that player #. If you need a unit group variable type, just create it on the fly for the action/function and add the player index to it.
to extend on what ulti said
set up a local variable (interger) name it what ever you want and set the inital value to "function - triggering player"
the interger value will be of 1 - 16 and you can just use that to go from there
@nevjmac: Go
Ah, that clarifies it. That's the sort of thing that I just have to get used to coming from other programming languages where you can call a method/function from anywhere instead of this silliness where you can't do it as an Action for some reason. I was having the same problems with Position of unit, but that answers it. Thanks.
Disregard this guys post.