- Joined
- Mar 16, 2008
- Messages
- 820
What is correct way to make AIs expand? This function seems to cause the game to crash intermittently but why? I thought the crash was related to the AI trying to expand to islands but it seems it still crashes even with no islands.
This is from the GUI build expansion town:
from the api manual:
When you call this function, within BuildPriorities, it seems to enable like a smart expand setting. It keeps taking gold mines as they are available, which is exactly as desired. However it seems to cause a crash intermittently for unknown reasons.
So I added a limiting condition, which seems to prevent the crashing. I've only tested a few times though, without human-player interference:
So I guess the problem is solved in some sense. However I still have some concerns:
1) What is the proper way to make an AI expand? When you just have the AI build a town hall, without this system above, it builds the town hall in useless spot. The above functions seems to make it build near a gold mine.
2) What if a player takes one of the AI's expansions, then the AI tries to take another expansion, which might crash the game? It's unclear exactly what causes the crash still.
This is from the GUI build expansion town:
JASS:
//===========================================================================
function ExpansionNeeded takes nothing returns boolean
return take_exp
endfunction
//===========================================================================
function BuildExpansion takes integer hallID, integer mineID returns nothing
if (HallsCompleted(hallID)) then
call SetBuildExpa( TownCount(hallID) + 1, mineID )
endif
endfunction
from the api manual:
JASS:
function SetBuildExpa takes integer qty, integer unitid returns nothing
call SetBuildAll(BUILD_EXPAND,qty,unitid,-1)
endfunction
When you call this function, within BuildPriorities, it seems to enable like a smart expand setting. It keeps taking gold mines as they are available, which is exactly as desired. However it seems to cause a crash intermittently for unknown reasons.
JASS:
call BuildExpansion (TOWN_HALL, TOWN_HALL)
So I added a limiting condition, which seems to prevent the crashing. I've only tested a few times though, without human-player interference:
JASS:
globals
boolean gCond_Need_Town_Hall = false
endglobals
JASS:
function UpdateConditions takes nothing returns nothing
set gCond_Need_Town_Hall = ( (GetUnitCount(TOWN_HALL)) < 2 )
endfunction
JASS:
function BuildPriorities takes nothing returns nothing
...
if gCond_Need_Town_Hall then
call BuildExpansion (TOWN_HALL, TOWN_HALL)
endif
...
endfunction
So I guess the problem is solved in some sense. However I still have some concerns:
1) What is the proper way to make an AI expand? When you just have the AI build a town hall, without this system above, it builds the town hall in useless spot. The above functions seems to make it build near a gold mine.
2) What if a player takes one of the AI's expansions, then the AI tries to take another expansion, which might crash the game? It's unclear exactly what causes the crash still.