So I'm making an AI and within the trigger to make them build structures I made a side trigger to try and find places for the buildings to fit. Given that my last attempt made them pick locations in the middle of buildings and obviously couldn't build them there!!!
But back to this. The trigger has the dimensions of the building to be constructed and therefore picks an existing structure to work around. It then uses the dimensions to pick a point around the existing structure which isn't too far away from the existing one. Then from this point it makes a region with the point as a center to basically map out where the building would be. Then it checks to see if anything is in the way (I was planning to make it check for doodads and cliff problems but I didn't know how to so settled for just units). And if there was something in the way then it'd restart the process.
I added a small wait and some pings to see where it was putting the locations and it seemed that it would reset the point and it'd go mad about the center of the map for some reason? I have no idea! Please help though!!!!
NO WORRIES! I was a fool and used TempUnitGroup01 instead of TempUnitGroup02. It works fine now!!
But back to this. The trigger has the dimensions of the building to be constructed and therefore picks an existing structure to work around. It then uses the dimensions to pick a point around the existing structure which isn't too far away from the existing one. Then from this point it makes a region with the point as a center to basically map out where the building would be. Then it checks to see if anything is in the way (I was planning to make it check for doodads and cliff problems but I didn't know how to so settled for just units). And if there was something in the way then it'd restart the process.
I added a small wait and some pings to see where it was putting the locations and it seemed that it would reset the point and it'd go mad about the center of the map for some reason? I have no idea! Please help though!!!!
-
Generic AI Pick Build Location
- Events
- Conditions
-
Actions
- Set BuildLocationUnit = (Random unit from TempBuildings)
- Set BuildLocationUnitPoint = (Position of BuildLocationUnit)
- Set BuildLocationDistance = (Random real number between ((BuildLocationHeight + BuildLocationWidth) / 1.25) and ((BuildLocationHeight + BuildLocationWidth) x 1.50))
- Set TempReal = (Random real number between 0.00 and 359.99)
- Set BuildLocationPoint = (BuildLocationUnitPoint offset by BuildLocationDistance towards TempReal degrees)
- Set BuildLocationRegion = (Region centered at BuildLocationPoint with size (BuildLocationWidth, BuildLocationHeight))
- Set TempUnitGroup02 = (Units in BuildLocationRegion matching (((Matching unit) is alive) Equal to True))
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- (Number of units in TempUnitGroup01) Greater than or equal to 1
-
Then - Actions
- Trigger - Run Generic AI Pick Build Location <gen> (checking conditions)
- Else - Actions
-
If - Conditions
NO WORRIES! I was a fool and used TempUnitGroup01 instead of TempUnitGroup02. It works fine now!!
Last edited by a moderator: