• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[Trigger] Building

Status
Not open for further replies.
Level 13
Joined
Oct 27, 2008
Messages
1,176

I'm looking to make a map where every 100 kills = 1 builder
Whenever a builder enters a new area a barracks is built
The Barracks build a footman every 5 seconds
Last of the 4 main barracks standing wins
The trigger i need is
  • Barracks 1 1
    • Events
      • Unit - A unit enters 1 1 <gen>
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to Builder
    • Actions
      • Unit - Create 1 Barracks for (Owner of (Triggering unit)) at (Center of 1 1 <gen>) facing Default building facing degrees
But there cant be a barracks in the region already for a barracks to go there
 
Last edited:
Level 29
Joined
Jul 29, 2007
Messages
5,174
There are two common ways to solve this.

1. An array (would be better with a 2 dimensional array) of booleans which tell you if a square is occupied.
Once a barracks is built you set the boolean representing it to true and once it is destroyed you set it to false.

2. Every time a builder enters a square (which can be checked either with pre-set regions, or with coordinates*.) you check if that square contains a barracks and act according to that.

*what I mean by coordinates is, say each square is 100 units, you need to check if that unit changed from a "block" of 100 units to another block on both X and Y axises.
I do not suggest this with GUI (not at all actually, just go with regions).
 
Level 29
Joined
Jul 29, 2007
Messages
5,174
You should put a region over each "square".

1. When a builder enters a region, you check if a barracks already exists there with "pick every unit in region X matching unit is Barracks", and respond according to that.

2. You initialize an array of booleans, each of them representing a square (region).

Code:
Note: This is 10x10 because I didn't look at your picture 
      and I'm too lazy to edit it to 8x8

-------------------------------
|00|01|02|03|04|05|06|07|08|09|
|10|11|12|13|14|15|16|17|18|19|
|20|21|22|23|24|25|26|27|28|29|
|30|31|32|33|34|35|36|37|38|39|
|40|41|42|43|44|45|46|47|48|49|
|50|51|52|53|54|55|56|57|58|59|
|60|61|62|63|64|65|66|67|68|69|
|70|71|72|73|74|75|76|77|78|79|
|80|81|82|83|84|85|86|87|88|89|
|90|91|92|93|94|95|96|97|98|99|
-------------------------------

All of the booleans should be initialized to false.
When a builder enters a region, you check the boolean that represents that region (you can easly do this by setting all the regions to an array with each index matching the boolean index. For example, booleans[0] will represent regions[0], booleans[34] will represent regions[34] and so on), if it is false, build the barracks, if it is true, don't build.
Once a barracks is destroyed, you check which region it was in (by using the "region contains point"), and set the boolean that represents that region to false.
 
Status
Not open for further replies.
Top