Thanks Peter, I have updated my APOL_Units.txt file. Let me know if you find other mistakes.
HandleEvent(BeginTurn) 'UpgradeAIUnits' post {
int_t j;
int_t i;
int_t k;
int_t c;
int_t num;
int_t tmpPlayer;
int_t cityCount;
int_t unitNum;
unit_t tmpUnit;
army_t tmpArmy;
city_t tmpCity;
location_t tmpLoc;
num = 9;
tmpPlayer = player[0];
if(!IsHumanPlayer(tmpPlayer)) {
while(num > 0 && PlayerGold(tmpPlayer) > 300) {
for(j = 0; j < player[0].armies; j = j + 1) {
GetArmyByIndex(player[0], j, tmpArmy);
cityCount = PlayerCityCount(tmpPlayer);
for(c = 0; c < cityCount; c = c + 1) {
GetCityByIndex(tmpPlayer, c, tmpCity);
if(CityIsValid(tmpCity)
&& distance(tmpCity.location, tmpArmy.location) < 4
&& tmpArmy.size > num) {
for(k = 0; k < tmpArmy.size; k = k + 1) {
GetUnitFromArmy(tmpArmy, k, tmpUnit);
tmpLoc = tmpArmy.location;
for (i = 0; i < OLD_UNIT_TYPE.#; i = i + 1){
if(tmpUnit.type == OLD_UNIT_TYPE[i]
&& HasDataBaseAdvance(tmpPlayer, enadv[i])
&& PlayerGold(tmpPlayer) > PER_UNIT_UPDATE_COST[i]) {
CreateUnit(tmpPlayer, NEW_UNIT_TYPE[i], tmpLoc, 0);
Event: DisbandUnit(tmpUnit);
AddGold(tmpPlayer, -PER_UNIT_UPDATE_COST[i]);
}
}
}
}
}
}
num = num - 3;
}
}
}




Comment