I am about to port my whole map to pure galaxy for speed/performance reasons. I read somewhere I can save the map in unpacked format, however I cannot figure out how to do this... I don't even really want to use the trigger editor. I am not sure how I would start like for example, triggers are event based. Do I only code triggers or, is there a thread entry point I can just code functions and such?
Sounds like you're trying to save the map as a .SC2Components file. File > Save As > Save As Type > .SC2Components. You can then open the folder and add your galaxy script files. Don't forget to include.
There is a sort of "main" function which is called by the virtual machine when it start up. This initializes all globals (that are not automatically initialized such as arrays) and calls all event attachment functions and "map initialization" event triggers.
It sounds like you are trying to make life harder for yourself than it should be. I advise sticking with the trigger editor and only bother using Galaxy when you need performance or for things GUI cannot do. The speed up you can get from pure Galaxy is often trivial compared with an algorithmic optimization.
Analyse performance using the trigger debugger. Only bother optimizing the functions that take considerable amounts of execution time or are called a lot. Anything else is a waste of resources.
If your map has performance issues identify the cause. It is very easy to get the data editor to cause performance problems as well (most are caused by it).
I hate the GUI and have programmed for years. I feel that I would personally( probably only speaking for myself here ) be way more productive using galaxy. I am an expert at optimizing c/c code and have even wrote my own libraries in the past. So does everything have to be event based? Can I not just execute code every frame? (without every .016 time event). Also, I have another question, does galaxy support multidimensional arrays?
I just looked at my galaxy code generated by my map and all the arrays have +1 at the end, like wtf? What a waste of space... I realize people think arrays start at 1 but this seems like a dumb idea...
No everything does not need to be event based. However events are generally the best way to respond to game engine state changes efficiently. The game engine itself does not use Galaxy so events act as a interface between the native compiled C++ code and Galaxy virtual machine. All events generate a new Galaxy virtual machine thread with its own stack and event state.
Quote:
Can I not just execute code every frame? (without every .016 time event).
You do not understand the concept of frames in SC2. SC2 runs at 16 deterministic frames per second with graphic interpolation between frames every display update. This was done so that 1 thread can advance the deterministic game state (which is identical between clients) while the other thread handles actors and orders the GPU around (which is very time consuming). Since the Galaxy virtual machine has to be deterministic so clients remain in syncs it means that the smallest resolvable time is exactly 0.0625 game seconds. Do note that game seconds are scaled by game speed into real time so it is possible for more or less to occur per real second however they are used to determine the advancement of time so will scale equally with everything else.
You can execute code 16 times a second (every frame) in 3 ways.
Periodic event set every 0.0625 seconds.
Timer expiration event with a timer set as repeating with period set as 0.0625 seconds.
Start a thread via some means and then at the end of an infinite loop (while (true)) Wait for 0.0625 seconds.
Quote:
I just looked at my galaxy code generated by my map and all the arrays have +1 at the end, like wtf? What a waste of space... I realize people think arrays start at 1 but this seems like a dumb idea...
Read their official response about it. They were tired of people running into array out of bounds errors after being used to WC3 JASS which were dynamic arrays with a 8192 maximum size. The wastage is minimal (trivial) and I believe they might even have some automatic optimization in place to avoid allocating the extra index unless necessary.
Quote:
Also, I have another question, does galaxy support multidimensional arrays?
Yes it does. However I do not know the maximum number of dimensions it supports. You can arrayref multidimensional arrays as well. They are even supported by GUI.
I am about to port my whole map to pure galaxy for speed/performance reasons. I read somewhere I can save the map in unpacked format, however I cannot figure out how to do this... I don't even really want to use the trigger editor. I am not sure how I would start like for example, triggers are event based. Do I only code triggers or, is there a thread entry point I can just code functions and such?
@penguinwars: Go
Sounds like you're trying to save the map as a .SC2Components file. File > Save As > Save As Type > .SC2Components. You can then open the folder and add your galaxy script files. Don't forget to include.
@PirateArcade | I make games | Ask me things on Discord
There is a sort of "main" function which is called by the virtual machine when it start up. This initializes all globals (that are not automatically initialized such as arrays) and calls all event attachment functions and "map initialization" event triggers.
It sounds like you are trying to make life harder for yourself than it should be. I advise sticking with the trigger editor and only bother using Galaxy when you need performance or for things GUI cannot do. The speed up you can get from pure Galaxy is often trivial compared with an algorithmic optimization.
Analyse performance using the trigger debugger. Only bother optimizing the functions that take considerable amounts of execution time or are called a lot. Anything else is a waste of resources.
If your map has performance issues identify the cause. It is very easy to get the data editor to cause performance problems as well (most are caused by it).
I hate the GUI and have programmed for years. I feel that I would personally( probably only speaking for myself here ) be way more productive using galaxy. I am an expert at optimizing c/c code and have even wrote my own libraries in the past. So does everything have to be event based? Can I not just execute code every frame? (without every .016 time event). Also, I have another question, does galaxy support multidimensional arrays?
I just looked at my galaxy code generated by my map and all the arrays have +1 at the end, like wtf? What a waste of space... I realize people think arrays start at 1 but this seems like a dumb idea...
No everything does not need to be event based. However events are generally the best way to respond to game engine state changes efficiently. The game engine itself does not use Galaxy so events act as a interface between the native compiled C
++
code and Galaxy virtual machine. All events generate a new Galaxy virtual machine thread with its own stack and event state.You do not understand the concept of frames in SC2. SC2 runs at 16 deterministic frames per second with graphic interpolation between frames every display update. This was done so that 1 thread can advance the deterministic game state (which is identical between clients) while the other thread handles actors and orders the GPU around (which is very time consuming). Since the Galaxy virtual machine has to be deterministic so clients remain in syncs it means that the smallest resolvable time is exactly 0.0625 game seconds. Do note that game seconds are scaled by game speed into real time so it is possible for more or less to occur per real second however they are used to determine the advancement of time so will scale equally with everything else.
You can execute code 16 times a second (every frame) in 3 ways.
Read their official response about it. They were tired of people running into array out of bounds errors after being used to WC3 JASS which were dynamic arrays with a 8192 maximum size. The wastage is minimal (trivial) and I believe they might even have some automatic optimization in place to avoid allocating the extra index unless necessary.
Yes it does. However I do not know the maximum number of dimensions it supports. You can arrayref multidimensional arrays as well. They are even supported by GUI.
Thanks for the reply again. Can structs not be nested? I tried nesting a bunch of structs for organization sakes and its not compiling...
struct Player
{
struct Stats <-error expected a field inside the structure
{
};
};
Also, is this syntax valid?
struct somestruct
{
int someValue;
}structInstance;
Yes however the declarations cannot be nested. You need to declare the struct type outside and before the struct you want to nest it in.
I am not sure off the top of my head. Try it out and if not then declare it before declaring an instance.