So im building a map which allows you to basically save a state in a melee game, and load it for later use and practice. In doing this, i must tackle the question of how to set/get the construction progress of a building.
I'm currently stuck at even setting the buildings progress.
I am currently saving all units created (doesn't include mineral patches, etc) into a unit array, then when the load is called, it runs through a loop and creates each unit at that units position, with Under Construction and Ignore Placement as options.
As soon as I create it, I then set (last created unit) progress to (slot 1, 100%).
I've tried setting the health of a unit to set its progress, but no dice so far.
How can you set/get the construction progress of a building? Would I have to write a function in galaxy script to do it? (java for several years, so its all good), or is there a way to do it with triggers. (I've searched through everything so far, and nothing adequately solves this.)
You need to get/set the progress of the unit creating it, not the unit which is under construction itself. However, I haven't seen any way to get/set the progress of a morph thus far. (Also, the function to set progress uses a Real value, so make sure you're dealing with a Real parameter if you want to see the Unit Progress (Percent) function.)
For getting the build time, its relatively simple. There is a timer that substitutes as the in game timer. When a building's construction is started, it records that time down (realtivie to the game clock). When ever the map is saved, it compares the two times, and sets the time left for the building.
For setting build time, a solution I came up with is a rather "duck tape and WD-40" one. You can set the total time it takes to build a building with set value. So for building stuff, you take two arrays, one with all units that are already built, one that is units currently building.
There are ideally two paths with this methodology. You can take the smallest time until completion, and set timers , so that when the map loads everything, they wait until a certain time has passed until the building ends up completing when it supposed to. You can also do this, but just by setting timers to construct a building at a location.
Basically, when map saves, it records the time left to build.
When map loads (via triggers), it takes the time left, and applies it to a timer. A temp building is put in the place of the real building, and if that building isn't destroyed (you can simulate health regen and what not), then its placed down when the timer expires, which is at the same time as the building.
The solution isn't that elegant, and mainly hindered it seems by the lack of support for adjustment.
If anyone else has any more ideas on how to directly influance the progress of a build time for a building, via triggers, for one unit only, then please present it, because thats the ideal solution.
Rollback Post to RevisionRollBack
To post a comment, please login or register a new account.
So im building a map which allows you to basically save a state in a melee game, and load it for later use and practice. In doing this, i must tackle the question of how to set/get the construction progress of a building.
I'm currently stuck at even setting the buildings progress.
I am currently saving all units created (doesn't include mineral patches, etc) into a unit array, then when the load is called, it runs through a loop and creates each unit at that units position, with Under Construction and Ignore Placement as options.
As soon as I create it, I then set (last created unit) progress to (slot 1, 100%).
I've tried setting the health of a unit to set its progress, but no dice so far.
How can you set/get the construction progress of a building? Would I have to write a function in galaxy script to do it? (java for several years, so its all good), or is there a way to do it with triggers. (I've searched through everything so far, and nothing adequately solves this.)
@HellsAn631: Go
You need to get/set the progress of the unit creating it, not the unit which is under construction itself. However, I haven't seen any way to get/set the progress of a morph thus far. (Also, the function to set progress uses a Real value, so make sure you're dealing with a Real parameter if you want to see the Unit Progress (Percent) function.)
For getting the build time, its relatively simple. There is a timer that substitutes as the in game timer. When a building's construction is started, it records that time down (realtivie to the game clock). When ever the map is saved, it compares the two times, and sets the time left for the building.
For setting build time, a solution I came up with is a rather "duck tape and WD-40" one. You can set the total time it takes to build a building with set value. So for building stuff, you take two arrays, one with all units that are already built, one that is units currently building.
There are ideally two paths with this methodology. You can take the smallest time until completion, and set timers , so that when the map loads everything, they wait until a certain time has passed until the building ends up completing when it supposed to. You can also do this, but just by setting timers to construct a building at a location.
Basically, when map saves, it records the time left to build.
When map loads (via triggers), it takes the time left, and applies it to a timer. A temp building is put in the place of the real building, and if that building isn't destroyed (you can simulate health regen and what not), then its placed down when the timer expires, which is at the same time as the building.
The solution isn't that elegant, and mainly hindered it seems by the lack of support for adjustment.
If anyone else has any more ideas on how to directly influance the progress of a build time for a building, via triggers, for one unit only, then please present it, because thats the ideal solution.