OVRKLL
New Member
- Reaction score
- 3
Hey all,
A friend of mine started to un-bug a Line Tower Wars map (1.24.something, now 1.24K) and I figured I might just as well help him by adding a proper anti-block system. Instead of having manic-depressive little gnoll run through the mazes now and then I wrote three triggers to effectively handle block-cheating. Unfortunately, there is a problem. While the theory between the triggers (illustrated below) seems to work perfectly, I must have made a mistake in the programming somewhere sinse the game suddenly won't allow specific placements - primarily building the first towers of new lines.
Okay, I may need some illustrations... Here we go:
THEORY
PROBLEM
TRIGGER 1: 'ANTIBLOCK StartSequence'
TRIGGER 2: 'ANTIBLOCK PickCurrentUnits'
TRIGGER 3: 'ANTIBLOCK PickConnectedUnits'
Can anyone help me find the cause of the problem? I've searched through the codes for an eternity but just can't figure it out!
So, can someone help? Any comments are appreciated!
Thanks.
A friend of mine started to un-bug a Line Tower Wars map (1.24.something, now 1.24K) and I figured I might just as well help him by adding a proper anti-block system. Instead of having manic-depressive little gnoll run through the mazes now and then I wrote three triggers to effectively handle block-cheating. Unfortunately, there is a problem. While the theory between the triggers (illustrated below) seems to work perfectly, I must have made a mistake in the programming somewhere sinse the game suddenly won't allow specific placements - primarily building the first towers of new lines.
Okay, I may need some illustrations... Here we go:
THEORY
Code:
1. Find all towers touching the currently constructing one.
2. Find all towers touching each of the previously found towers and repeat until a chain of towers is completed and no more touching buildings exist.
3. Find the horizontal span of the towers during step 2.
4. Find out whether the total horizontal span is greater than a certain value.
5. If step 4 is positive: KILL TEH TOWER (the currently constructing one, that is)!!!
PROBLEM
Code:
Here is an example of a problematic scenario (T's and O's are different towers):
| |
|TTOOTTOOTTOOTT |
|TTOOTTOOTTOOTT |
| |
| OO|
| OO|
| |
For some reason I am not allowed to place the lower tower. Why, oh, why not?!
TRIGGER 1: 'ANTIBLOCK StartSequence'
Code:
ANTIBLOCK StartSequence
Events
Unit - A unit Begins construction
Conditions
Actions
-------- Set variables --------
Set UNIT_Antiblock_New = (Constructing structure)
Set REAL_Antiblock_X1 = (X of (Position of UNIT_Antiblock_New))
Set REAL_Antiblock_X2 = REAL_Antiblock_X1
-------- Clear groups --------
Unit Group - Remove all units from UNITGROUP_Antiblock_All
Unit Group - Remove all units from UNITGROUP_Antiblock_New
-------- Add to new units --------
Unit Group - Add UNIT_Antiblock_New to UNITGROUP_Antiblock_New
-------- Start primary loop --------
Trigger - Run ANTIBLOCK PickCurrentUnits <gen> (checking conditions)
TRIGGER 2: 'ANTIBLOCK PickCurrentUnits'
Code:
ANTIBLOCK PickCurrentUnits
Events
Conditions
Actions
-------- Update groups --------
Unit Group - Remove all units from UNITGROUP_Antiblock_Current
Unit Group - Add all units of UNITGROUP_Antiblock_New to UNITGROUP_Antiblock_All
Unit Group - Add all units of UNITGROUP_Antiblock_New to UNITGROUP_Antiblock_Current
Unit Group - Remove all units from UNITGROUP_Antiblock_New
-------- Pick new units --------
Unit Group - Pick every unit in UNITGROUP_Antiblock_Current and do (Actions)
Loop - Actions
-------- Set picked unit --------
Set UNIT_Antiblock_Picked = (Picked unit)
-------- Start secondary loop --------
Trigger - Run ANTIBLOCK PickConnectedUnits <gen> (checking conditions)
-------- Primary loop --------
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Number of units in UNITGROUP_Antiblock_Current) Equal to 0
Then - Actions
-------- End primary loop --------
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(REAL_Antiblock_X2 - REAL_Antiblock_X1) Equal to 896.00
Then - Actions
-------- Kill unit --------
Unit - Kill UNIT_Antiblock_New
Else - Actions
Else - Actions
-------- Continue primary loop --------
Trigger - Run ANTIBLOCK PickCurrentUnits <gen> (checking conditions)
TRIGGER 3: 'ANTIBLOCK PickConnectedUnits'
Code:
ANTIBLOCK PickConnectedUnits
Events
Conditions
Actions
-------- Pick connected units --------
Unit Group - Pick every unit in (Units owned by (Owner of UNIT_Antiblock_Picked) matching (((Distance between (Position of (Matching unit)) and (Position of UNIT_Antiblock_Picked)) Less than 182.00) and (((Matching unit) is in UNITGROUP_Antiblock_All) Equal to False))) and do (Actions)
Loop - Actions
-------- Add to new units --------
Unit Group - Add (Picked unit) to UNITGROUP_Antiblock_New
-------- Update positions --------
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(X of (Position of (Picked unit))) Less than REAL_Antiblock_X1
Then - Actions
Set REAL_Antiblock_X1 = (X of (Position of (Picked unit)))
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(X of (Position of (Picked unit))) Greater than REAL_Antiblock_X2
Then - Actions
Set REAL_Antiblock_X2 = (X of (Position of (Picked unit)))
Else - Actions
Can anyone help me find the cause of the problem? I've searched through the codes for an eternity but just can't figure it out!
So, can someone help? Any comments are appreciated!
Thanks.