- Joined
- Jan 9, 2016
- Messages
- 1,487
I hope this is the right place to ask this.How do I check the unit that constructed a structure?Is it triggering unit?
I believe he meant the unit who starts to construct/finishes a structure, it is triggering unit (for event unit begins construction/finishes construction).
let me rephrase what you posted with references.
Event: A unit Finishes construction
Conditions:
"1" is equal to 'a'
"1" is equal to 'a'
Actions:
Set Unit_constructedStructure = True
And the 2-nd trigger only checks if a construction-type has been already built.
Doesn't help with finding out who the builder is.
Because a buildings "builder" is poorly defined. In theory builders only place foundations, and not actually build.Why won't Blizzard make something useful such as Event Respond - Structure Constructer
Because a buildings "builder" is poorly defined. In theory builders only place foundations, and not actually build.
The big question is why is there no "a unit places a structure foundation" with triggering unit being the builder who placed the foundation and the structure functions being the foundation which was placed.
Anyway it is possible to a high degree of accuracy, but is a real pain to make such a system. When a unit is issued an order to place a foundation you need to remember its X/Y location, its builder, its foundation type and its owning player. When a unit starts construction you then track down which order it corresponded to. This is done by comparing the X/Y coordinate of the structure with some error (units are moved slightly from their order point), making sure the owner matches (builder owner is same as building owner), checking the structure type matches (you can stack foundations for different building types), and that its corresponding builder is nearby (obviously that builder across the map was not responsible for it).
If done correctly it will be 100% accurate for all normal construction cases. It will be 100% accurate with respect to player ownership (who paid for the building). It will not be accurate with respect to a player ordering two different builders to place a foundation at the same spot with both of them being near when one builds, in this case it could credit the wrong builder with placing the foundation. This inaccuracy will likely be harmless and not a source of exploits.
I made such a system for my never completed builder hero. The idea being the number of buildings he could maintain is based on his hero.
Sounds inefficient. There is no real need to poll since you already have a starts construction event. You just need to match up the construction to its order and find the unit which was issued the order.My system was doing something similar, but not exactly:
When a peon was ordered to build - I was remembering the x/y of the order.
And then periodically I was checking the distance between all of the builders and the coordinates of their order.
In this check - I was making a list, in which I was ranking the builders by "who is closest to their target".
And when a building was being constructed - I was checking who's the 1-st peon in that list![]()