So your friend was on the right track with that trigger, but there's some unnecessary stuff:
1) You should either use a Hashtable or Custom Value, in this case you don't need both.
2) You should never set Custom Value yourself, instead, rely on a
Unit Indexer.
3) Everything in the Else - Actions section doesn't make sense to me. Why is it necessary?
4) The SBTIndex doesn't make sense to me either. Why is it necessary?
So with that in mind, let's fix it up, luckily your friend got us 90% of the way there:
-
SBT Build
-

Events
-


Unit - A unit Begins construction
-

Conditions
-

Actions
-


Set VariableSet SBTTempPoint[0] = (Position of (Constructing structure))
-


Set VariableSet SBTTempPoint[1] = (SBTTempPoint[0] offset by (-32.00, -32.00))
-


Set VariableSet SBTTempPoint[2] = (SBTTempPoint[0] offset by (32.00, -32.00))
-


Set VariableSet SBTTempPoint[3] = (SBTTempPoint[0] offset by (-32.00, 32.00))
-


Set VariableSet SBTTempPoint[4] = (SBTTempPoint[0] offset by (32.00, 32.00))
-


For each SBTLoop from 1 to 4, do (Actions)
-



Loop - Actions
-




Destructible - Create a Line of Sight Blocker Tower at SBTTempPoint[SBTLoop] facing (Random angle) with scale 1.00 and variation 0
-




Hashtable - Save Handle Of(Last created destructible) as SBTLoop of Key(Constructing structure) in SBTHash.
-




Custom script: call RemoveLocation(udg_SBTTempPoint[udg_SBTLoop)
-


Custom script: call RemoveLocation(udg_SBTTempPoint[0])
-
SBT Destroy
-

Events
-

Conditions
-


((Triggering unit) is a Structure) Equal to True
-

Actions
-


For each SBTLoop from 1 to 4, do (Actions)
-



Loop - Actions
-




Destructible - Destroy (Load SBTLoop of Key(Triggering unit) from SBTHash)
1) This will properly surround a constructed structure with Line of Sight blockers and then destroy them when the structure dies (
SBT Destroy).
2) I added a new Integer variable called
SBTLoop. You should never rely on (Integer A) or (Integer B) in your For Loops.
3) This all assumes that you've created and setup SBTHash in some Initialization trigger, which you obviously have.
To help better understand Hashtables:
A Hashtable essentially gives us an Array with an extra [index]. Additionally, it allows us to use an object's Handle id as an [index], which you can see being done twice in the
SBT Build trigger with the
(Last created destructible) and the
(Constructing structure):
-
Hashtable - Save Handle Of(Last created destructible) as SBTLoop of Key(Constructing structure) in SBTHash.
Understand that every single object in the game (Unit, Item, Point, etc) has what's called a Handle id, which is a unique Integer used for identifying that object. In this case, we're using the Handle id of our
(Constructing structure) as one of our two [indexes]. This allows us to Save data to our
(Constructing structure) which we can then reference at a later time. This data can be just about anything. We take advantage of this in the
SBT Destroy trigger which Loads the saved data from our dying structure in order to Destroy it's four Saved line of sight blockers.
In more simplified terms, here's what our Hashtable is doing:
-
For each SBTLoop from 1 to 4, do (Actions)
-

Loop - Actions
-


Destructible - Create a Line of Sight Blocker Tower at SBTTempPoint[SBTLoop] facing (Random angle) with scale 1.00 and variation 0
-


Set Variable SightBlocker[(Constructing structure)][SBTLoop] = (Last created destructible)
It's just a more powerful Array with an extra [index]. It also has the special feature of being able to use Handle ids instead of just standard Integers like 0, 1, 2, etc.