Hi all, I've been searching and experimenting for a while and I'm having trouble with the galaxy editor. Here's what I have so far:
constintarray_count=5;inti=0;int[array_count]t;t[0]=DataTableGetPoint(true,"Zombie Spawn 1");t[1]=DataTableGetPoint(true,"Zombie Spawn 2");t[2]=DataTableGetPoint(true,"Zombie Spawn 3");t[3]=DataTableGetPoint(true,"Zombie Spawn 4");t[4]=DataTableGetPoint(true,"Zombie Spawn 5");while(i<5){// Unit - Create 1 Zealot for player 15 at [hoping to use t[i] here] using default facing (No Options)// Unit - Order (Last created unit) to ( Attack targeting (Closest unit to (Position of (Last created unit)) in (Any units in (Entire map) owned by player Any Player matching Excluded: Self, with at most Any Amount))) (Replace Existing Orders)i+=1;}
The comments inside the while loop are what I'm having trouble with. Those comments came from actions, which I'm trying to translate into galaxy script.
My end goal here is to create one zealot at each of my points, and tell them to attack the nearest enemy unit. Can anyone help me out? There's so many things I'm lost on in this.
Happy to help out. What you're doing is exactly what I did at first when figuring out Galaxy.
One minor point, you might want to change "while (i < 5)" to "while (i < array_count)". :)
You'll also want to change the declaration of "t" to be of type "point", not "int", as you're saving points in there.
You'll want to also keep your web browser open to this link: http://cortexrp.com/starcraft/natives.galaxy. That would be the SC2 Galaxy natives list. You'll find all the useful functions there.
1. I figured out that there are such things as "point groups" that seem to be similar to my point array. I found how to get a unit out of a unit group, UnitGroupUnit(), but there's no PointGroupPoint(), or any PointGroup functions for that matter. Is there something I'm missing about point groups?
2. How did you know that 0 was okay for the third parameter in UnitCreate? Where can I find some information on what create style means?
3. The last parameter for UnitIssueOrder is int inQueueType. Where can I find a more indepth reference of the UnitIssueOrder function, so I can know that it's okay to put 0 in there?
4. Does my usage of abilCmd look right? It seems awkward that to do something as simple as attacking I need two intermediate objects like that.
5. I saw in that link that UnitCreate returned a unitgroup. In my catching of its return type, I declared a unitgroup. Is that a reference or a copy? In C that would be a copy and I'd probably be in trouble.
In my actions, my Custom Script action has the code in the previous post, but this generated code has a if (!runActions) { ... } which is put before my variable declarations. I know variable declarations are supposed to be the first in the function, but I can't modify the text window that shows me this generated code. What should I do?
In my actions, my Custom Script action has the code in the previous post, but this generated code has a if (!runActions) { ... } which is put before my variable declarations. I know variable declarations are supposed to be the first in the function, but I can't modify the text window that shows me this generated code. What should I do?
Two options:
A) Recreate the entire trigger as pure custom script so you have full control over it.
B) Add those variables as local GUI variables and use those in your script.
1. I figured out that there are such things as "point groups" that seem to be similar to my point array. I found how to get a unit out of a unit group, UnitGroupUnit(), but there's no PointGroupPoint(), or any PointGroup functions for that matter. Is there something I'm missing about point groups?
Yea, the point groups itself are missing :) There is nothing like that. You'll have to use arrays or input them by hand. Your way of using the DataTable is pretty inventive, by the way :)
2. How did you know that 0 was okay for the third parameter in UnitCreate? Where can I find some information on what create style means?
There are two creation styles:
c_unitCreateConstruct
c_unitCreateIgnorePlacement
0 means you're placing them normally.
If you look at Motive's text file and search for UnitCreate you'll find them.
There's an easy way of figuring out what belongs where:
Create the action in GUI first (make sure it's valid), then press CRTL+F11 (I think that's it :p).
It'll show you the entire map script, including the script-version of all GUI triggers. Search for your action and look at the parameters :)
That's the way I learned JASS2 lolz.
3. The last parameter for UnitIssueOrder is int inQueueType. Where can I find a more indepth reference of the UnitIssueOrder function, so I can know that it's okay to put 0 in there?
Again, Motive's text file tells us that:
const int c_orderQueueReplace = 0;
const int c_orderQueueAddToEnd = 1;
const int c_orderQueueAddToFront = 2;
And you can use GUI to figure it out.
Basically 0 means that the unit will forget whatever it's order is, and do what you just told it to.
1 means it'll be queued to the end. So the unit will finish it's current orders and then do what you told it to.
2 means it'll be queued to the front. So the unit will first execute your order and then go back to it's old orders.
4. Does my usage of abilCmd look right? It seems awkward that to do something as simple as attacking I need two intermediate objects like that.
Again I'd look at the script-version of the GUI action and see how it looks like.
I don't remember 100%, but I do remember that you indeed needed some kind of weird constructs to issue orders.
You could also write this, by the way:
UnitIssueOrder(newUnit, order(abilCmd("attack")), 0);
5. I saw in that link that UnitCreate returned a unitgroup. In my catching of its return type, I declared a unitgroup. Is that a reference or a copy? In C that would be a copy and I'd probably be in trouble.
God damnit I don't remember anymore lol.. I think it was passed as a reference. Or maybe not.. You should test it to be sure :)
Btw you declared a unitgroup, unit, abilCmd and order in your loop. I'm pretty sure that's also a case of "variable declarations must be placed before any code".
Well, I was starting a giant-ish post, and now s3rius has answered everything...
Just want to add, that coding in galaxy becomes a LOT easier, if you use external tools like Notepad++ (with Galaxy plugins) or Beier's Galaxy++ editor.
They provide you with autocompletion, parameter tooltips, correct syntax highlighting, in case of Galaxy++ even more useful error messages and several language additions you can use.
Its just so much more convenient and way faster to just type "unit" and select your desired function from the suggested ones (and see the parameters displayed as you type them) instead of having to look it up in a different place.
Hi all, I've been searching and experimenting for a while and I'm having trouble with the galaxy editor. Here's what I have so far:
The comments inside the while loop are what I'm having trouble with. Those comments came from actions, which I'm trying to translate into galaxy script.
My end goal here is to create one zealot at each of my points, and tell them to attack the nearest enemy unit. Can anyone help me out? There's so many things I'm lost on in this.
Thanks a bunch,
- Evan
Happy to help out. What you're doing is exactly what I did at first when figuring out Galaxy.
One minor point, you might want to change "while (i < 5)" to "while (i < array_count)". :)
You'll also want to change the declaration of "t" to be of type "point", not "int", as you're saving points in there.
You'll want to also keep your web browser open to this link: http://cortexrp.com/starcraft/natives.galaxy. That would be the SC2 Galaxy natives list. You'll find all the useful functions there.
If you look closely, you'll find:
So it looks like you want...
...to spawn the unit itself.
Take a look at:
to actually tell the unit to do a specific order.
Wow, that link is a gold mine! Thank you so much!
1. I figured out that there are such things as "point groups" that seem to be similar to my point array. I found how to get a unit out of a unit group, UnitGroupUnit(), but there's no PointGroupPoint(), or any PointGroup functions for that matter. Is there something I'm missing about point groups?
2. How did you know that 0 was okay for the third parameter in UnitCreate? Where can I find some information on what create style means?
3. The last parameter for UnitIssueOrder is int inQueueType. Where can I find a more indepth reference of the UnitIssueOrder function, so I can know that it's okay to put 0 in there?
4. Does my usage of abilCmd look right? It seems awkward that to do something as simple as attacking I need two intermediate objects like that.
5. I saw in that link that UnitCreate returned a unitgroup. In my catching of its return type, I declared a unitgroup. Is that a reference or a copy? In C that would be a copy and I'd probably be in trouble.
Thanks so much for your help!
Also, when I try to save, I get a syntax error on this code:
In my actions, my Custom Script action has the code in the previous post, but this generated code has a if (!runActions) { ... } which is put before my variable declarations. I know variable declarations are supposed to be the first in the function, but I can't modify the text window that shows me this generated code. What should I do?
Thanks,
- Evan
Two options:
A) Recreate the entire trigger as pure custom script so you have full control over it.
B) Add those variables as local GUI variables and use those in your script.
Yea, the point groups itself are missing :) There is nothing like that. You'll have to use arrays or input them by hand. Your way of using the DataTable is pretty inventive, by the way :)
There are two creation styles:
c_unitCreateConstruct
c_unitCreateIgnorePlacement
0 means you're placing them normally.
If you look at Motive's text file and search for UnitCreate you'll find them.
There's an easy way of figuring out what belongs where:
Create the action in GUI first (make sure it's valid), then press CRTL+F11 (I think that's it :p).
It'll show you the entire map script, including the script-version of all GUI triggers. Search for your action and look at the parameters :)
That's the way I learned JASS2 lolz.
Again, Motive's text file tells us that:
const int c_orderQueueReplace = 0;
const int c_orderQueueAddToEnd = 1;
const int c_orderQueueAddToFront = 2;
And you can use GUI to figure it out.
Basically 0 means that the unit will forget whatever it's order is, and do what you just told it to.
1 means it'll be queued to the end. So the unit will finish it's current orders and then do what you told it to.
2 means it'll be queued to the front. So the unit will first execute your order and then go back to it's old orders.
Again I'd look at the script-version of the GUI action and see how it looks like.
I don't remember 100%, but I do remember that you indeed needed some kind of weird constructs to issue orders.
You could also write this, by the way:
UnitIssueOrder(newUnit, order(abilCmd("attack")), 0);
God damnit I don't remember anymore lol.. I think it was passed as a reference. Or maybe not.. You should test it to be sure :)
Btw you declared a unitgroup, unit, abilCmd and order in your loop. I'm pretty sure that's also a case of "variable declarations must be placed before any code".
Well, I was starting a giant-ish post, and now s3rius has answered everything...
Just want to add, that coding in galaxy becomes a LOT easier, if you use external tools like Notepad++ (with Galaxy plugins) or Beier's Galaxy++ editor.
They provide you with autocompletion, parameter tooltips, correct syntax highlighting, in case of Galaxy++ even more useful error messages and several language additions you can use.
Its just so much more convenient and way faster to just type "unit" and select your desired function from the suggested ones (and see the parameters displayed as you type them) instead of having to look it up in a different place.
Thanks to everyone who helped me out with this, it works now, and I feel much more at home in the galaxy editor =)