Creating an AI and for some reason it is unable to keep track of towns.
Town 1 is always the place where the player spawns. If I tell the AI to expand then it expands to the nearest location and sets town 2 to be the new expo. But after about 10-15 seconds it no longer recognizes it as a town. The expansion and buildings will still be there but it is no longer listed in the towns slot. My guess is there is an automatic, periodic trigger running every 30 seconds or so refreshing the AIs town slots to accomidate for when an expansion gets killed off.
I can manually set the town up using the set town functions and again, the new location is listed in the town slots but just like before it only lasts like that for < 30seconds or so before the town slots are refreshed and the AI no longer considers that location to be a town.
Does anyone know why it is considering these expansions as invalid? Anyone know how the town system keeps track of towns? Anyone know how I can turn it off? There is nothing I am doing between creating a new town and it not being registered anymore so it is the game which is doing it, not me.
For the moment I will try and have a periodic trigger which runs every 1 second and refreshes the town list. But running a periodic trigger constantly to prevent another periodic trigger from undoing my work is a pretty lame solution, if it can even be called that.
Thanks for any help or insight you may be able to provide.
Are you running the melee or campaign AI? The melee AI uses code on every expansion to check every expansion. I don't know a lot about it because the melee code is spaghetti in the best of places and completely hardcoded in others and my scripting know-how is exclusively derived from helping someone hack together a heavily modified melee AI for the game, but worth of note is some checks it runs in regards to expansion states.
if (town == mainTown) {
continue;
}
state = AIGetTownState(player, town);
if (state != c_townStateEstablished) {
continue;
}<</code>>
The big part being the StateTownEstablished. Depending on what code is running in the background it may not consider the towns "established" for some silly blizzard reason and result in puking rainbows.
I personally never ran into this issue when editing the melee AI, and my first recommendation would be to avoid triggering any aspect of the AI whenever possible, but that might be a clue at best.
Creating an AI and for some reason it is unable to keep track of towns.
Town 1 is always the place where the player spawns. If I tell the AI to expand then it expands to the nearest location and sets town 2 to be the new expo. But after about 10-15 seconds it no longer recognizes it as a town. The expansion and buildings will still be there but it is no longer listed in the towns slot. My guess is there is an automatic, periodic trigger running every 30 seconds or so refreshing the AIs town slots to accomidate for when an expansion gets killed off.
I can manually set the town up using the set town functions and again, the new location is listed in the town slots but just like before it only lasts like that for < 30seconds or so before the town slots are refreshed and the AI no longer considers that location to be a town.
Does anyone know why it is considering these expansions as invalid? Anyone know how the town system keeps track of towns? Anyone know how I can turn it off? There is nothing I am doing between creating a new town and it not being registered anymore so it is the game which is doing it, not me.
For the moment I will try and have a periodic trigger which runs every 1 second and refreshes the town list. But running a periodic trigger constantly to prevent another periodic trigger from undoing my work is a pretty lame solution, if it can even be called that.
Thanks for any help or insight you may be able to provide.
Are you running the melee or campaign AI? The melee AI uses code on every expansion to check every expansion. I don't know a lot about it because the melee code is spaghetti in the best of places and completely hardcoded in others and my scripting know-how is exclusively derived from helping someone hack together a heavily modified melee AI for the game, but worth of note is some checks it runs in regards to expansion states.
<<code>>
void TerranHDDefenseOtherTowns (int player) {....
mainTown = AIGetMainTown(player);
while (i < c_townMax) { town = i; i = i + 1;
if (town == mainTown) { continue; } state = AIGetTownState(player, town); if (state != c_townStateEstablished) { continue; }<</code>>
The big part being the StateTownEstablished. Depending on what code is running in the background it may not consider the towns "established" for some silly blizzard reason and result in puking rainbows.
I personally never ran into this issue when editing the melee AI, and my first recommendation would be to avoid triggering any aspect of the AI whenever possible, but that might be a clue at best.
/e Lol, this board culls lines on code tags.