- Joined
- Apr 20, 2014
- Messages
- 616
As far as I know, AI has issue with custom Town Hall and all. With classic buildings, if you order:
It will build a single Town Hall and then upgrade it until Castle.
But, if you do the same with custom buildings, it will build a custom Town Hall, then upgrade it to custom Keep AND build a new Town Hall, which it's not what we want.
So I myself tried to find a solution:
(Note that it's custom units)
I tried to make something like: don't build a new town hall if you have one.
In fact, I thought it worked perfectly... but nope.
The function GetUnitCount seems to work only once: at the beginning of the map.
If you make the AI start with no buildings: Town Hall is builded but not upgraded
If you make the AI start with a Keep: Keep is upgraded to Castle and no new Town Hall is builded. But if it's destroyed, it's not builded again.
...
As you can see, the IF conditions are respected only at the launch.
So my great question is: is there a way to make the "GetUnitCount" being checked in real-time?
Or is there a total different solution?
Thanks.
JASS:
call SetBuildUnit(1, TOWN_HALL)
call SetBuildUnit(1, KEEP)
call SetBuildUnit(1, CASTLE)
But, if you do the same with custom buildings, it will build a custom Town Hall, then upgrade it to custom Keep AND build a new Town Hall, which it's not what we want.
So I myself tried to find a solution:
JASS:
if (((GetUnitCount(KEEPD) == 0) and (GetUnitCount(CASTLED) == 0))) then
call SetBuildUnit(1, TOWND)
endif
if (((GetUnitCount(TOWND) == 1) and (GetUnitCount(CASTLED) == 0))) then
call SetBuildUnit(1, KEEPD)
endif
if (((GetUnitCount(TOWND) == 0) and (GetUnitCount(KEEPD) == 1))) then
call SetBuildUnit(1, CASTLED)
endif
I tried to make something like: don't build a new town hall if you have one.
In fact, I thought it worked perfectly... but nope.
The function GetUnitCount seems to work only once: at the beginning of the map.
If you make the AI start with no buildings: Town Hall is builded but not upgraded
If you make the AI start with a Keep: Keep is upgraded to Castle and no new Town Hall is builded. But if it's destroyed, it's not builded again.
...
As you can see, the IF conditions are respected only at the launch.
So my great question is: is there a way to make the "GetUnitCount" being checked in real-time?
Or is there a total different solution?
Thanks.