# Check if a unit build a building

#### HerlySQR

Level 20
I have a units that when a tower is destroyed some of them has to replace that tower (There are a lot of towers) or build it for first time, but they can be interrumped (and in some cases locked), how can I confirm the tower was succesfully builded?

#### kspec

Level 5
Here is a GUI solution

Do a generic unit event: a unit finishes construction.
Then make a condition that either
If you want to check the type of the constructing unit, set the condition to unit-type comparison: unit type of triggering unit = peasant or whatever
If you want to check the type of the building constructed, set the condition to unit-type comparison: unit type of constructed structure = scout tower or whatever

You can also check if the player has already constructed that building by doing an integer comparison condition

Last edited:

#### HerlySQR

Level 20
Here is a GUI solution

Do a generic unit event: a unit finishes construction.
Then make a condition that either
If you want to check the type of the constructing unit, set the condition to unit-type comparison: unit type of triggering unit = peasant or whatever
If you want to check the type of the building constructed, set the condition to unit-type comparison: unit type of constructed structure = scout tower or whatever

You can also check if the player has already constructed that building by doing an integer comparison condition
But how can I determine if the building was constructed before a specific time passed?, and I think I forgot to mention that I also wanna that if this happens, so order the unit build the building that must builded, and if the worker is incapable to build the building (for any reason) do a "Reset" to that worker.

#### kspec

Level 5
But how can I determine if the building was constructed before a specific time passed?, and I think I forgot to mention that I also wanna that if this happens, so order the unit build the building that must builded, and if the worker is incapable to build the building (for any reason) do a "Reset" to that worker.

Check the game time with this Elapsed Game Time

Then do an integer comparison condition in the trigger above where if your time elapsed variable is greater than equal to a specific time.

To order a unit to build the building do an effect: Unit: Issue Build Order. This orders the unit to build the building at a point.

Then check if the unit is idle after issuing the order. To do that, make a condition that checks if the current order of the unit (order comparison) is set to "none". If the unit is idle, it was incapable of building the building. I don't know what you mean by "Reset", but you can make the unit stop after that.

#### HerlySQR

Level 20
Check the game time with this Elapsed Game Time

Then do an integer comparison condition in the trigger above where if your time elapsed variable is greater than equal to a specific time.
I have one (made by me) and is not neccesary, I can use a timer, but both aren't an option, it can be more than 1 destroyed towers and it can be overwritten, example: if the time confirmer is 30 seconds and a tower is destroyed then 25 seconds later another tower is destroyed so 5 seconds later the trigger will count the 2 towers at the same time, and maybe the reason of the second tower is not builded was the worker didn't even have time to arrive and send 2 workers to the same place, I need a confirmer for each missing tower.
To order a unit to build the building do an effect: Unit: Issue Build Order. This orders the unit to build the building at a point.

Then check if the unit is idle after issuing the order. To do that, make a condition that checks if the current order of the unit (order comparison) is set to "none".
I know that, that's not the problem, the problem is, how can I store the build order, the point and the tower-type and they can't overwritten?
If the unit is idle, it was incapable of building the building. I don't know what you mean by "Reset", but you can make the unit stop after that.
I mean, if the unit is stucked or can't move or something then move it to the start position.

#### kspec

Level 5
I have one (made by me) and is not neccesary, I can use a timer, but both aren't an option, it can be more than 1 destroyed towers and it can be overwritten, example: if the time confirmer is 30 seconds and a tower is destroyed then 25 seconds later another tower is destroyed so 5 seconds later the trigger will count the 2 towers at the same time, and maybe the reason of the second tower is not builded was the worker didn't even have time to arrive and send 2 workers to the same place, I need a confirmer for each missing tower..

You start with a trigger with the event whenever a tower is destroyed (unit killed), not a periodic or elapsed timer. The condition integer comparison checks if the game time elapsed is after a certain point. So if the time is after a certain point, you create a worker? and order it (last created unit) to build a tower that was the same type as the tower destroyed. This will send multiple workers out to build towers whenever a tower is destroyed.

If you need to delay sending out the 2 workers until the timer confirmer you can store the number of destroyed towers and their type in a variable array. Then create the number of workers that you counted in index (see below what index is).

If you really need to store the information, you can use GUI or local variables with jass. To do it in GUI, make a variable array with a really big index, then set the variable to the tower type of the destroyed tower to store the tower type information. After every execution of the trigger, set the variable index (the index will be a variable) = to itself + 1.

Then after every timer confirmer, reset the index to 0.

The index will be the number of towers destroyed and the variable Tower_destroyed(index) or Tower_destroyed(1) if index > 1, for example if you had a variable array called "Tower_destroyed" would be the tower type. If you had a variable array called "Point", then Point(1) to Point(index) would be the point where each destroyed tower was destroyed.

#### HerlySQR

Level 20
You start with a trigger with the event whenever a tower is destroyed (unit killed), not a periodic or elapsed timer. The condition integer comparison checks if the game time elapsed is after a certain point. So if the time is after a certain point, you create a worker? and order it (last created unit) to build a tower that was the same type as the tower destroyed. This will send multiple workers out to build towers whenever a tower is destroyed.

If you need to delay sending out the 2 workers until the timer confirmer you can store the number of destroyed towers and their type in a variable array. Then create the number of workers that you counted in index (see below what index is).
Did you understand what I said?
If you really need to store the information, you can use GUI or local variables with jass. To do it in GUI, make a variable array with a really big index, then set the variable to the tower type of the destroyed tower to store the tower type information. After every execution of the trigger, set the variable index (the index will be a variable) = to itself + 1.

Then after every timer confirmer, reset the index to 0.

The index will be the number of towers destroyed and the variable Tower_destroyed(index) or Tower_destroyed(1) if index > 1, for example if you had a variable array called "Tower_destroyed" would be the tower type. If you had a variable array called "Point", then Point(1) to Point(index) would be the point where each destroyed tower was destroyed.
In resume, you say I have to use dynamic indexing, I wanna a more elegant solution but anyway.

Edit: Ok I made a variable arrays fot the point, the timer, the tower-type, but when the tower is builded, how can I relate that tower with that variables?

Edit 2: Ah forget it, I just will use a region variable.

Last edited:

#### GIMLI_2

Level 17
In resume, you say I have to use dynamic indexing, I wanna a more elegant solution but anyway.
Dynamic indexing is afaik the only solution in GUI to make your triggers truly MUI. There is no more elegant solution.

#### HerlySQR

Level 20
Dynamic indexing is afaik the only solution in GUI to make your triggers truly MUI. There is no more elegant solution.
Oh yes, what am I saying.

Replies
7
Views
771
[Solved] Building order
Replies
9
Views
879
Replies
6
Views
525
Replies
2
Views
343
Replies
6
Views
2K