I need to be able to, using the trigger editor, return (as a real) the build progress of a given structure under construction. I am not looking for construction events (such as started/cancelled/complete), but a real that represents a % completion.
Getting training/research progress turns out to be easy enough, but getting the progress of any given building under construction seems to be a secret art. I imagine there may be a simple function that eludes me, but searching the usual sources of information didn't turn up anything very useful. Most times this question was posed it just got lost without ever being answered and other times people suggested "hacks" or "work-arounds" to similar problems.
If anyone knows how to go about obtaining this information, sharing would be greatly appreciated. Thanks!
Most constructions are tied to the hitpoints, maybe you can calculate with them? Afaik, buildings start at 10% hitpoints and gradually fill the remaining hitpoints proportional to the construction progress. You would need to keep track of the damage done to the building during construction, or make it invulnerable.
Most constructions are tied to the hitpoints, maybe you can calculate with them? Afaik, buildings start at 10% hitpoints and gradually fill the remaining hitpoints proportional to the construction progress. You would need to keep track of the damage done to the building during construction, or make it invulnerable.
That is how i would go about doing it. Should be good enough.
How would you go about tracking the damage done to a building in a normal melee game situation? The first thought that came to me when I considered it was to put 1 stack of a behavior on the constructing building for each point of damage taken, but that obviously has some issues.
I would use the custom value of the unit, or probably add charges to the unit via trigger. Both values can be easily set and read via trigger and allow you to store any number "within" the unit.
While the custom value is limited to 64(?) instances and can only hold integers, it is the common way to store numbers in a unit, since it is designed for this task.
The charges might be a little hack-ish, but they can use fixed numbers, are unlimited on a unit (at least I didn't hit a limit yet) and you can use a string key instead of a numeric index for them.
The Problem
I need to be able to, using the trigger editor, return (as a real) the build progress of a given structure under construction. I am not looking for construction events (such as started/cancelled/complete), but a real that represents a % completion.
Getting training/research progress turns out to be easy enough, but getting the progress of any given building under construction seems to be a secret art. I imagine there may be a simple function that eludes me, but searching the usual sources of information didn't turn up anything very useful. Most times this question was posed it just got lost without ever being answered and other times people suggested "hacks" or "work-arounds" to similar problems.
If anyone knows how to go about obtaining this information, sharing would be greatly appreciated. Thanks!
Not sure, if there is a direct way to check that.
Most constructions are tied to the hitpoints, maybe you can calculate with them? Afaik, buildings start at 10% hitpoints and gradually fill the remaining hitpoints proportional to the construction progress. You would need to keep track of the damage done to the building during construction, or make it invulnerable.
So progress would be:
(CurrentHP + Damage Taken - 0.1 * MaxHP) / (0.9 * MaxHP)
That is how i would go about doing it. Should be good enough.
How would you go about tracking the damage done to a building in a normal melee game situation? The first thought that came to me when I considered it was to put 1 stack of a behavior on the constructing building for each point of damage taken, but that obviously has some issues.
I would use the custom value of the unit, or probably add charges to the unit via trigger. Both values can be easily set and read via trigger and allow you to store any number "within" the unit.
While the custom value is limited to 64(?) instances and can only hold integers, it is the common way to store numbers in a unit, since it is designed for this task.
The charges might be a little hack-ish, but they can use fixed numbers, are unlimited on a unit (at least I didn't hit a limit yet) and you can use a string key instead of a numeric index for them.
You know, I've never actually used custom values of units before so that just skipped right over my head. Thanks.