• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Check if a unit build a building

Status
Not open for further replies.
Level 23
Joined
Jun 26, 2020
Messages
1,838
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?
 
Level 5
Joined
Nov 13, 2017
Messages
17
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:
Level 23
Joined
Jun 26, 2020
Messages
1,838
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.
 
Level 5
Joined
Nov 13, 2017
Messages
17
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.
 
Level 23
Joined
Jun 26, 2020
Messages
1,838
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.
 
Level 5
Joined
Nov 13, 2017
Messages
17
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.
 
Level 23
Joined
Jun 26, 2020
Messages
1,838
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:
Status
Not open for further replies.
Top