- Joined
- Mar 10, 2009
- Messages
- 213
Context: I'm using either hand-placed (for small maps) or generated regions for TBS gameplay. When I worked with tiny maps, everything was rather easy and done via several loops within loops. However, now I'm working with the largest map (3 500 640 regions) and can't use Wc3 in-built loops (ForLoopA etc.) without game crashing every time.
And I can't create/remove them dynamically, because:
a) I suck at this (well, for now),
b) I require some regions to be kept at all times for quest events/doodad interaction etc.
Q: Why do you use waits?
A: ForLoopA bugs like hell with my array 0 to 1869 and onwards (1870 (horizontal) x1872 (vertical) matrix), and timers add too much trouble for a single player game. I'd consider them, if I ever convert this project to MUI. Past data generation stage I use timers almost for every other purpose, avoiding waits.
I'm posting below the most simplified version of my *working* triggers. While they do work, it takes forever to generate all the regions. Generating a row is OK, since I use 0.01 waits only with modulo, reducing the total amount of time required to generate a row to a minimum (mod of 1870=0, divisor 187).
The real trouble for me starts with column generation, that bugs if wait is inferior to 2 sec.
I can't have 1 hour-long region generation, that's beyond reasonable.
Would anyone know any proper way to optimize my crazy triggers?
Thank you for your attention.
And I can't create/remove them dynamically, because:
a) I suck at this (well, for now),
b) I require some regions to be kept at all times for quest events/doodad interaction etc.
Q: Why do you use waits?
A: ForLoopA bugs like hell with my array 0 to 1869 and onwards (1870 (horizontal) x1872 (vertical) matrix), and timers add too much trouble for a single player game. I'd consider them, if I ever convert this project to MUI. Past data generation stage I use timers almost for every other purpose, avoiding waits.
I'm posting below the most simplified version of my *working* triggers. While they do work, it takes forever to generate all the regions. Generating a row is OK, since I use 0.01 waits only with modulo, reducing the total amount of time required to generate a row to a minimum (mod of 1870=0, divisor 187).
The real trouble for me starts with column generation, that bugs if wait is inferior to 2 sec.
I can't have 1 hour-long region generation, that's beyond reasonable.
Would anyone know any proper way to optimize my crazy triggers?
Thank you for your attention.
-
INI Create Regions Setup
-
Events
-
Time - Elapsed game time is 2.00 seconds
-
-
Conditions
-
Actions
-
-------- Set Rect Size --------
-
Set Const_RectWidth = 32.00
-
Set Const_RectHeight = Const_RectWidth
-
-------- /Set Rect Size --------
-
-------- Set BL coordinates --------
-
Set Const_BL_L = -29920.00
-
Set Const_BL_B = -30208.00
-
Set Const_BL_R = (Const_BL_L + Const_RectWidth)
-
Set Const_BL_T = (Const_BL_B + Const_RectHeight)
-
-------- /Set BL coordinates --------
-
-------- Set Cell Limits --------
-
Set Const_FirstCellIndex = 0
-
Set Const_Limit_Cells_Per_Row = 1870
-
Set Const_Limt_Cells_Per_Column = (Const_Limit_Cells_Per_Row + 2)
-
Set Const_LastCellIndex = (Const_Limit_Cells_Per_Row x Const_Limt_Cells_Per_Column)
-
-------- /Set Cell Limits --------
-
-------- Run Main --------
-
Trigger - Run INI Create Regions Main <gen> (checking conditions)
-
-------- /Run Main --------
-
Custom script: call DestroyTrigger( GetTriggeringTrigger() )
-
-
-
INI Create Regions Main
-
Events
-
Conditions
-
Actions
-
-------- Create a row --------
-
Set FctVAR_ColumnCounter = 0
-
Trigger - Run subINI Create Regions Column Counter <gen> (checking conditions)
-
-------- /Create a row --------
-
Custom script: call DestroyTrigger( GetTriggeringTrigger() )
-
-
-
subINI Create Regions Column Counter
-
Events
-
Conditions
-
Actions
-
-------- Create Column --------
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
FctVAR_ColumnCounter Less than Const_Limt_Cells_Per_Column
-
-
Then - Actions
-
-------- Set B and T --------
-
Set FctVAR_TempB = (Const_BL_B + (Const_RectHeight x (Real(FctVAR_ColumnCounter))))
-
Set FctVAR_TempT = (Const_BL_T + (Const_RectHeight x (Real(FctVAR_ColumnCounter))))
-
Set FctVAR_ColumnCounter = (FctVAR_ColumnCounter + 1)
-
-------- /Set B and T --------
-
-------- Clean up --------
-
Set FctVAR_RowCounter = -1
-
-------- /Clean up --------
-
-------- Create Row --------
-
Trigger - Run subINI Create Regions Row Counter <gen> (checking conditions)
-
-------- /Create Row --------
-
Wait 2.00 seconds
-
Trigger - Run (This trigger) (checking conditions)
-
-
Else - Actions
-
Custom script: call DestroyTrigger( GetTriggeringTrigger() )
-
-
-
-------- /Create Column --------
-
-
-
subINI Create Regions Row Counter
-
Events
-
Conditions
-
Actions
-
-------- Create Row --------
-
Set FctVAR_RowCounter = (FctVAR_RowCounter + 1)
-
Set FctVAR_TempL = (Const_BL_L + (Const_RectWidth x (Real(FctVAR_RowCounter))))
-
Set FctVAR_TempR = (Const_BL_R + (Const_RectWidth x (Real(FctVAR_RowCounter))))
-
Set Region_Array[(((FctVAR_ColumnCounter - 1) x Const_Limit_Cells_Per_Row) + FctVAR_RowCounter)] = (Region(FctVAR_TempL, FctVAR_TempB, FctVAR_TempR, FctVAR_TempT))
-
-------- /Create Row --------
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
FctVAR_RowCounter Less than (Const_Limit_Cells_Per_Row - 1)
-
-
Then - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
(FctVAR_RowCounter mod (Const_Limit_Cells_Per_Row / 10)) Equal to 0
-
-
Then - Actions
-
Wait 0.01 seconds
-
-
Else - Actions
-
-
Trigger - Run (This trigger) (checking conditions)
-
-
Else - Actions
-
Game - Display to Player Group - Player 1 (Red) for 1.00 seconds the text: (Columns created: + (String(FctVAR_ColumnCounter)))
-
Game - Display to Player Group - Player 1 (Red) for 1.00 seconds the text: (Generating regions: + ((String(((Real(FctVAR_ColumnCounter)) x 0.05))) + %))
-
Trigger - Turn off (This trigger)
-
-
-
-
Last edited: