#1: How could I adapt SetUnitPos to multiple units with a single command? It won't accept arrays of units.
It seems that one of the most oft overlooked commands is forEach, and any others that allow application to multiple units. Anyway, use the following code:
"_x setUnitPos {Down}" forEach units squad1
Replace
Down with
Up or
Auto if those are what you intend to use instead. Replace
squad1 with the name of your group.
#2: I still can't get a script to check for a dynamic global variable, and nobody was really clear with me on how to get that working last time...
You use global variables exactly the same way as you do local variables, except that they don't have the underscore (_) in front of them. E.g.,
GlobalVar1 = GlobalVar1 + 1
vs.
_LocalVar1 = _LocalVar1 + 1
Same syntax.
Condition = _this select 2*************
...
? (Condition == 1) : goto "End2";**********
exit;
The lines with the asterisks are the ones that don't work. I have tried at least a dozen variations, but this script never can return T/F on a global variable.
What value are you passing to the third parameter? That's probably where your problem lies.
Why are you using a global variable for this, anyway?
#3: How (if it's possible) can I get the names of individual units comprising a group to be returned on the fly?
The easiest way I know how to explain this is to use an example of trying to display the unit's name in a title or hint. In this case, just treat the unit's variable as a string.
hint format ["Unit's name: %1",_soldier1]
Where
_soldier1 is the example unit for which you want the name. The resulting hint will display the following text:
Unit's name: Alpha Black 1Or something similar.
Say I'm facing north at 0, 0, 0. GetDir returns that I'm facing 0, so I want SetPos to move me to 0, 4, 0. That's simple enough, but it gets more complicated when GetDir returns something like 128... How would I have SetPos move a unit in that direction?
You would need to use some geometry functions to move a unit some meters in some direction. I'm no math expert, so I'll leave this one up to the resident math experts.
I could figure it out, but it would take me a while, whereas I'm sure others here could pull it off the top of their heads.