////////////////////////////////////////////////////////////////////////////////// // // 1) Scenario script for Frenzy AI Mod version 1.04 // // 2) City Expansion // // by BlueOrange // ////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////// // GLOBAL VARIABLES ////////////////////////////////////////////// int_t FAI_INIT; int_t FAI_ATTACK_SIZE; // minimum stack size for what I consider BIG int_t FAI_SECOND_ARMY_COEF; // ai needs this many (coef x human units) to form SecondAttackArmy; int_t FAI_HATE1_COEF; // level of hate to reach level 1 FAI_FRENZY state int_t FAI_HATE2_COEF; // level of hate to reach level 2 int_t FAI_HATE3_COEF; // level of hate to reach level 3 int_t FAI_HATE4_COEF; // level of hate to reach level 4 int_t FAI_FRENZY; // FAI_FRENZY state of AI players. int_t FAI_MAXPLAYERS; int_t FAI_PlayerAge[]; int_t FAI_HateLevel[]; army_t FAI_FirstArmy[]; army_t FAI_SecondArmy[]; location_t FAI_AttackTarget[]; int_t FAI_HumanNumber; HandleEvent(BeginTurn) 'FAI_Initialization' pre { int_t i; army_t tmpArmy; FAI_ATTACK_SIZE = 5; FAI_SECOND_ARMY_COEF = 2; FAI_HATE1_COEF = 20; //PEDRUNN: set to 20 FAI_HATE2_COEF = 45; FAI_HATE3_COEF = 75; FAI_HATE4_COEF = 100; FAI_FRENZY = 0; FAI_MAXPLAYERS = 31; i = 0; while (i <= FAI_MAXPLAYERS) { // try all possible players player[1] = i; if (player[1].units > 0) { GetArmyByIndex(player[1], 0, tmpArmy); i = FAI_MAXPLAYERS; } i = i + 1; } for (i = 0; i <= FAI_MAXPLAYERS; i = i + 1) { // initialize all playes, so new players from revolts will be 'supported' as well // much simpler & faster like this FAI_PlayerAge[i] = 1; FAI_HateLevel[i] = 0; FAI_FirstArmy[i] = tmpArmy; FAI_SecondArmy[i] = tmpArmy; FAI_AttackTarget[i] = tmpArmy.location; } FAI_INIT = 1000; DisableTrigger('FAI_Initialization'); } int_f FAI_UnitsCount(int_t tmpPlayer) { player[5] = tmpPlayer; // 5 is unlikely to overwrite an existing value return player[5].units; } //////////////////////////////////////////////////////////////////////////////////////////////// HandleEvent(BeginTurn) 'FAI_New_Age' post { int_t i; int_t num; city_t tmpCity; num = player[0]; if (HasAdvance(num, ID_ADVANCE_FUTURE_TECHNOLOGY) && FAI_PlayerAge[num] < 9) { FAI_PlayerAge[num] = 9; } elseif (HasAdvance(num, ID_ADVANCE_GAIA_THEORY) && FAI_PlayerAge[num] < 8) { FAI_PlayerAge[num] = 8; } elseif (FAI_PlayerAge[num] < 7 && HasAdvance(num, ID_ADVANCE_CYBERNETICS)) { FAI_PlayerAge[num] = 7; } elseif (FAI_PlayerAge[num] < 6 && HasAdvance(num, ID_ADVANCE_MASS_MEDIA)) { FAI_PlayerAge[num] = 6; } elseif (FAI_PlayerAge[num] < 5 && HasAdvance(num, ID_ADVANCE_INDUSTRIAL_REVOLUTION)) { FAI_PlayerAge[num] = 5; } elseif (FAI_PlayerAge[num] < 4 && HasAdvance(num, ID_ADVANCE_NATIONALISM)) { FAI_PlayerAge[num] = 4; } elseif (FAI_PlayerAge[num] < 3 && HasAdvance(num, ID_ADVANCE_FEUDALISM)) { FAI_PlayerAge[num] = 3; } elseif (FAI_PlayerAge[num] < 2 && HasAdvance(num, ID_ADVANCE_PHILOSOPHY)) { FAI_PlayerAge[num] = 2; } else { FAI_PlayerAge[num] = 1; } } //////////////////////////////////////////////////////////////////////////////////////////////// // 2) ExpandCity Fuction: // Given the location of the city 'cityLoc', fuction will attempt to fill the 'numOfType' of the subcity 'tileType' // around the city. The 'owner' parameter ensures that the tiles belong to the city owner. // // Fuction begins by searching all surrounding tiles 1 radius away from the city and look for proper tiles to put // the new subcity tile 'tileType' into. If it fails to find such a tile 1 radius away, it'll look 2 radius away, // then 3, and finally 4 radius away. // If it cannot put in all the subcity tiles, then that means there are no more room for the city to expand. // // If all the tiles are placed, returns 1. // If all the tiles are not placed, returns 0. // ('addDelete' == 1) adds the tile // ('addDelete' == 2) deletes a tile // // PEDRUNN: - Cities expand with tile improvements and not goods // - I cleaned the code for the terrain types to be ID's and not numbers (this improves the // modder reading of the code and prevents editing mistakes) // - Took off dead cities. // - Sea cities also expand // - Create roads, railroad, maglev or undersea tunnel in city tiles in the next turn. //////////////////////////////////////////////////////////////////////////////////////////////// // ReplaceTile Fuction: // Will search through the tiles with certain 'range' and 'direction' starting from 'checkLoc' for player 'owner'. // If applicable terrain type is found for 'checkType', that terrain will be replaced accordingly. // The 'newType' parameter determines what to replace. // ('addDelete' == 1) adds the tile // ('addDelete' == 2) deletes the tile // // Only grasslands, plains, tundras, deserts, and abandoned lands can be used to expand the city. // Function returns 1 if any tile replacement took place. Returns 0 if it doesn't. int_f TileHasWonder(location_t tmpLoc) { if(TileHasImprovement(tmpLoc, TerrainImprovementDB(TILEIMP_WONDER_PYRAMIDS) || TileHasImprovement(tmpLoc, TerrainImprovementDB(TILEIMP_WONDER_HANGING_GARDENS) || TileHasImprovement(tmpLoc, TerrainImprovementDB(TILEIMP_WONDER_CHICHEN_ITZA) || TileHasImprovement(tmpLoc, TerrainImprovementDB(TILEIMP_WONDER_LIGHTHOUSE) || TileHasImprovement(tmpLoc, TerrainImprovementDB(TILEIMP_WONDER_COLOSSUS) || TileHasImprovement(tmpLoc, TerrainImprovementDB(TILEIMP_WONDER_COLISEUM) || TileHasImprovement(tmpLoc, TerrainImprovementDB(TILEIMP_WONDER_OLYMPICS) || TileHasImprovement(tmpLoc, TerrainImprovementDB(TILEIMP_WONDER_GREAT_LIBRARY) || TileHasImprovement(tmpLoc, TerrainImprovementDB(TILEIMP_WONDER_THE_lABYRINTH) || TileHasImprovement(tmpLoc, TerrainImprovementDB(TILEIMP_WONDER_THE_FORBIDDEN_CITY) || TileHasImprovement(tmpLoc, TerrainImprovementDB(TILEIMP_WONDER_HAGIA_SOPHIA) || TileHasImprovement(tmpLoc, TerrainImprovementDB(TILEIMP_WONDER_ANGKOR_WAT) || TileHasImprovement(tmpLoc, TerrainImprovementDB(TILEIMP_WONDER_THE_VATICAN) || TileHasImprovement(tmpLoc, TerrainImprovementDB(TILEIMP_WONDER_DOME_OF_THE_ROCK) || TileHasImprovement(tmpLoc, TerrainImprovementDB(TILEIMP_WONDER_TAJ_MAHAL) || TileHasImprovement(tmpLoc, TerrainImprovementDB(TILEIMP_WONDER_EAST_INDIA_COMPANY) || TileHasImprovement(tmpLoc, TerrainImprovementDB(TILEIMP_WONDER_COPERNICUS_OBSERVATORY) || TileHasImprovement(tmpLoc, TerrainImprovementDB(TILEIMP_WONDER_EMANCIPATION_PROCLAMATION) || TileHasImprovement(tmpLoc, TerrainImprovementDB(TILEIMP_WONDER_HOLY_INQUISITION) || TileHasImprovement(tmpLoc, TerrainImprovementDB(TILEIMP_WONDER_ADAM_SMITH_COMPANY) || TileHasImprovement(tmpLoc, TerrainImprovementDB(TILEIMP_WONDER_DISNEYLAND) || TileHasImprovement(tmpLoc, TerrainImprovementDB(TILEIMP_WONDER_EMPIRE_STATE_BUILDING) || TileHasImprovement(tmpLoc, TerrainImprovementDB(TILEIMP_WONDER_HOLLYWOOD) || TileHasImprovement(tmpLoc, TerrainImprovementDB(TILEIMP_WONDER_GREAT_DAM) || TileHasImprovement(tmpLoc, TerrainImprovementDB(TILEIMP_WONDER_APOLLO_PROGRAM) || TileHasImprovement(tmpLoc, TerrainImprovementDB(TILEIMP_WONDER_GLOBESAT) || TileHasImprovement(tmpLoc, TerrainImprovementDB(TILEIMP_WONDER_GENOME_PROJECT) || TileHasImprovement(tmpLoc, TerrainImprovementDB(TILEIMP_WONDER_FIELD_DYNAMICS_LAB) || TileHasImprovement(tmpLoc, TerrainImprovementDB(TILEIMP_WONDER_THE_AGENCY) || TileHasImprovement(tmpLoc, TerrainImprovementDB(TILEIMP_WONDER_UNITED_NATIONS) || TileHasImprovement(tmpLoc, TerrainImprovementDB(TILEIMP_WONDER_FIELD_DYNAMICS_LABORATORY) || TileHasImprovement(tmpLoc, TerrainImprovementDB(TILEIMP_WONDER_NATIONAL_SHIELD) || TileHasImprovement(tmpLoc, TerrainImprovementDB(TILEIMP_WONDER_DATA_HAVEN) || TileHasImprovement(tmpLoc, TerrainImprovementDB(TILEIMP_WONDER_NANITE_DEFUSER) || TileHasImprovement(tmpLoc, TerrainImprovementDB(TILEIMP_WONDER_DINOSAUR_PARK) || TileHasImprovement(tmpLoc, TerrainImprovementDB(TILEIMP_WONDER_CENTRAL_MATTER_DECOMPILER) || TileHasImprovement(tmpLoc, TerrainImprovementDB(TILEIMP_WONDER_THE_SOLARIS_PROJECT) || TileHasImprovement(tmpLoc, TerrainImprovementDB(TILEIMP_WONDER_AI_ENTITY) || TileHasImprovement(tmpLoc, TerrainImprovementDB(TILEIMP_WONDER_GREAT_WALL_A) || TileHasImprovement(tmpLoc, TerrainImprovementDB(TILEIMP_WONDER_GREAT_WALL_B)) { return 1; } else { return 0; } } int_f ReplaceACTile(int_t owner, location_t checkLoc, int_t range, int_t direction, int_t newType, int_t addDelete) { location_t tmpLoc; location_t tmp2Loc; int_t searchDirection; int_t TType; int_t count; int_t sucess; tmpLoc = checkLoc; count = range; // Searching through the tiles, clockwise. if (direction == 0) { // searchDirection = 4; } // NORTH if (direction == 1) { // 0 searchDirection = 4; } // 3 1 if (direction == 2) { // WEST 5 + 2 EAST searchDirection = 6; } // 6 4 if (direction == 3) { // 7 searchDirection = 1; } // SOUTH if (direction == 4) { // searchDirection = 6; } if (direction == 5) { searchDirection = 1; } if (direction == 6) { searchDirection = 3; } if (direction == 7) { searchDirection = 3; } while (count > 0) { TType = TerrainType(tmpLoc); if (newType == 1 && cellOwner(tmpLoc) == owner && addDelete == 2) { if(TileHasImprovement(tmpLoc, TerrainImprovementDB(TILEIMP_ANCIENT_CITY_ONE))){ Event:CutImprovements(tmpLoc); return 1; } } if (newType == 1 && cellOwner(tmpLoc) == owner && addDelete == 1 && !TileHasImprovement(tmpLoc, TerrainImprovementDB(TILEIMP_ANCIENT_CITY_ONE)) && TileHasWonder(tmpLoc) == 0) { if (TType == TerrainDB(TERRAIN_FOREST) || TType == TerrainDB(TERRAIN_JUNGLE) || TType == TerrainDB(TERRAIN_SWAMP)){ Terraform(tmpLoc, TerrainDB(TERRAIN_PLAINS)); } elseif (TType == TerrainDB(TERRAIN_GRASSLAND) || TType == TerrainDB(TERRAIN_PLAINS) || TType == TerrainDB(TERRAIN_DESERT) || TType == TerrainDB(TERRAIN_TUNDRA) || TType == TerrainDB(TERRAIN_HILL) || TType == TerrainDB(TERRAIN_BROWN_HILL)) { Event:CreateImprovement(owner,tmpLoc,TerrainImprovementDB(TILEIMP_ANCIENT_CITY_ONE),0 ); return 1; } } GetNeighbor(tmpLoc, searchDirection, tmp2Loc); tmpLoc = tmp2Loc; count = count - 1; } return 0; } int_f ReplaceMCTile(int_t owner, location_t checkLoc, int_t range, int_t direction, int_t newType, int_t addDelete) { location_t tmpLoc; location_t tmp2Loc; int_t searchDirection; int_t TType; int_t count; int_t sucess; int_t replaceOld; tmpLoc = checkLoc; count = range; replaceOld = 0; // Searching through the tiles, clockwise. if (direction == 0) { // searchDirection = 4; } // NORTH if (direction == 1) { // 0 searchDirection = 4; } // 3 1 if (direction == 2) { // WEST 5 + 2 EAST searchDirection = 6; } // 6 4 if (direction == 3) { // 7 searchDirection = 1; } // SOUTH if (direction == 4) { // searchDirection = 6; } if (direction == 5) { searchDirection = 1; } if (direction == 6) { searchDirection = 3; } if (direction == 7) { searchDirection = 3; } while (count > 0) { TType = TerrainType(tmpLoc); if (replaceOld < 1 && cellOwner(tmpLoc) == owner) { if (TileHasImprovement(tmpLoc, TerrainImprovementDB(TILEIMP_ANCIENT_CITY_ONE)) || TileHasImprovement(tmpLoc, TerrainImprovementDB(TILEIMP_ANCIENT_CITY_DEAD))) { Event:CreateImprovement(owner,tmpLoc, TerrainImprovementDB(TILEIMP_MODERN_CITY_ONE),0 );// Create Railroad replaceOld = replaceOld + 1; } } if (newType == 1 && cellOwner(tmpLoc) == owner && addDelete == 2) { if(TileHasImprovement(tmpLoc, TerrainImprovementDB(TILEIMP_MODERN_CITY_ONE)) || TileHasImprovement(tmpLoc, TerrainImprovementDB(TILEIMP_MODERN_CITY_TWO)) || TileHasImprovement(tmpLoc, TerrainImprovementDB(TILEIMP_MODERN_CITY_THREE))) { Event:CutImprovements(tmpLoc); return 1; } } if (newType == 1 && cellOwner(tmpLoc) == owner && addDelete == 1) { if(!TileHasImprovement(tmpLoc, TerrainImprovementDB(TILEIMP_MODERN_CITY_ONE)) && !TileHasImprovement(tmpLoc, TerrainImprovementDB(TILEIMP_MODERN_CITY_TWO)) && !TileHasImprovement(tmpLoc, TerrainImprovementDB(TILEIMP_MODERN_CITY_THREE)) && TileHasWonder(tmpLoc) == 0) { if (TType == TerrainDB(TERRAIN_FOREST) || TType == TerrainDB(TERRAIN_JUNGLE) || TType == TerrainDB(TERRAIN_SWAMP)) { Terraform(tmpLoc, TerrainDB(TERRAIN_PLAINS)); } elseif (TType == TerrainDB(TERRAIN_GRASSLAND) || TType == TerrainDB(TERRAIN_PLAINS) || TType == TerrainDB(TERRAIN_DESERT) || TType == TerrainDB(TERRAIN_TUNDRA) || TType == TerrainDB(TERRAIN_HILL) || TType == TerrainDB(TERRAIN_BROWN_HILL)) { Event:CreateImprovement(owner,tmpLoc,TerrainImprovementDB(TILEIMP_MODERN_CITY_ONE),0 ); // Create Road return 1; } } } if (newType == 2 && cellOwner(tmpLoc) == owner && addDelete == 1) { if (TileHasImprovement(tmpLoc, TerrainImprovementDB(TILEIMP_MODERN_CITY_ONE))) { Event:CreateImprovement(owner,tmpLoc, TerrainImprovementDB(TILEIMP_MODERN_CITY_TWO),0 );// Create Railroad return 1; } } if (newType == 3 && cellOwner(tmpLoc) == owner && addDelete == 1) { if (TileHasImprovement(tmpLoc, TerrainImprovementDB(TILEIMP_MODERN_CITY_TWO))) { Event:CreateImprovement(owner,tmpLoc, TerrainImprovementDB(TILEIMP_MODERN_CITY_THREE),0 );// Create Railroad return 1; } } GetNeighbor(tmpLoc, searchDirection, tmp2Loc); tmpLoc = tmp2Loc; count = count - 1; } return 0; } int_f ReplaceGCTile(int_t owner, location_t checkLoc, int_t range, int_t direction, int_t newType, int_t addDelete) { location_t tmpLoc; location_t tmp2Loc; int_t searchDirection; int_t TType; int_t count; int_t sucess; int_t ReplaceOld; tmpLoc = checkLoc; count = range; // Searching through the tiles, clockwise. if (direction == 0) { // searchDirection = 4; } // NORTH if (direction == 1) { // 0 searchDirection = 4; } // 3 1 if (direction == 2) { // WEST 5 + 2 EAST searchDirection = 6; } // 6 4 if (direction == 3) { // 7 searchDirection = 1; } // SOUTH if (direction == 4) { // searchDirection = 6; } if (direction == 5) { searchDirection = 1; } if (direction == 6) { searchDirection = 3; } if (direction == 7) { searchDirection = 3; } while (count > 0) { TType = TerrainType(tmpLoc); if (replaceOld < 2 && cellOwner(tmpLoc) == owner) { if (TileHasImprovement(tmpLoc, TerrainImprovementDB(TILEIMP_ANCIENT_CITY_ONE)) || TileHasImprovement(tmpLoc, TerrainImprovementDB(TILEIMP_ANCIENT_CITY_DEAD)) || TileHasImprovement(tmpLoc, TerrainImprovementDB(TILEIMP_MODERN_CITY_ONE)) || TileHasImprovement(tmpLoc, TerrainImprovementDB(TILEIMP_MODERN_CITY_TWO)) || TileHasImprovement(tmpLoc, TerrainImprovementDB(TILEIMP_MODERN_CITY_DEAD))) { Event:CreateImprovement(owner,tmpLoc, TerrainImprovementDB(TILEIMP_GENETIC_CITY_ONE),0 ); replaceOld = replaceOld + 1; } elseif (TileHasImprovement(tmpLoc, TerrainImprovementDB(TILEIMP_MODERN_CITY_THREE))) { Event:CreateImprovement(owner,tmpLoc, TerrainImprovementDB(TILEIMP_GENETIC_CITY_TWO),0 ); replaceOld = replaceOld + 1; } } if (newType > 0 && cellOwner(tmpLoc) == owner && addDelete == 2) { if(TileHasImprovement(tmpLoc, TerrainImprovementDB(TILEIMP_GENETIC_CITY_ONE)) || TileHasImprovement(tmpLoc, TerrainImprovementDB(TILEIMP_GENETIC_CITY_TWO)) || TileHasImprovement(tmpLoc, TerrainImprovementDB(TILEIMP_SEA_CITY_ONE))) { Event:CutImprovements(tmpLoc); return 1; } } if (newType <= 2 && cellOwner(tmpLoc) == owner && addDelete == 1) { if(!TileHasImprovement(tmpLoc, TerrainImprovementDB(TILEIMP_GENETIC_CITY_ONE)) && !TileHasImprovement(tmpLoc, TerrainImprovementDB(TILEIMP_GENETIC_CITY_TWO)) && TileHasWonder(tmpLoc) == 0) { if (TType == TerrainDB(TERRAIN_FOREST) || TType == TerrainDB(TERRAIN_JUNGLE) || TType == TerrainDB(TERRAIN_SWAMP) || TType == TerrainDB(TERRAIN_PLAINS) || TType == TerrainDB(TERRAIN_GRASSLAND) || TType == TerrainDB(TERRAIN_DESERT) || TType == TerrainDB(TERRAIN_TUNDRA) || TType == TerrainDB(TERRAIN_HILL) || TType == TerrainDB(TERRAIN_BROWN_HILL)) { Event:CreateImprovement(owner,tmpLoc, TerrainImprovementDB(TILEIMP_GENETIC_CITY_ONE),0 ); return 1; } } } if (newType > 2 && cellOwner(tmpLoc) == owner && addDelete == 1) { if (TileHasImprovement(tmpLoc, TerrainImprovementDB(TILEIMP_GENETIC_CITY_ONE))) { Event:CreateImprovement(owner,tmpLoc, TerrainImprovementDB(TILEIMP_GENETIC_CITY_TWO),0 ); return 1; } } if (newType > 0 && cellOwner(tmpLoc) == owner && addDelete == 1) { if (TType == TerrainDB(TERRAIN_WATER_DEEP) || TType == TerrainDB(TERRAIN_WATER_TRENCH) || TType == TerrainDB(TERRAIN_WATER_RIFT)) { Event:CreateImprovement(owner,tmpLoc, TerrainImprovementDB(TILEIMP_SEA_CITY_ONE),0 ); return 1; } } GetNeighbor(tmpLoc, searchDirection, tmp2Loc); tmpLoc = tmp2Loc; count = count - 1; } return 0; } int_f ReplaceALTile(int_t owner, location_t checkLoc, int_t range, int_t direction, int_t newType, int_t addDelete) { location_t tmpLoc; location_t tmp2Loc; int_t searchDirection; int_t TType; int_t count; int_t sucess; int_t ReplaceOld; tmpLoc = checkLoc; count = range; // Searching through the tiles, clockwise. if (direction == 0) { // searchDirection = 4; } // NORTH if (direction == 1) { // 0 searchDirection = 4; } // 3 1 if (direction == 2) { // WEST 5 + 2 EAST searchDirection = 6; } // 6 4 if (direction == 3) { // 7 searchDirection = 1; } // SOUTH if (direction == 4) { // searchDirection = 6; } if (direction == 5) { searchDirection = 1; } if (direction == 6) { searchDirection = 3; } if (direction == 7) { searchDirection = 3; } while (count > 0) { TType = TerrainType(tmpLoc); if (replaceOld < 2 && cellOwner(tmpLoc) == owner) { if (TileHasImprovement(tmpLoc, TerrainImprovementDB(TILEIMP_ANCIENT_CITY_ONE)) || TileHasImprovement(tmpLoc, TerrainImprovementDB(TILEIMP_ANCIENT_CITY_DEAD)) || TileHasImprovement(tmpLoc, TerrainImprovementDB(TILEIMP_MODERN_CITY_ONE)) || TileHasImprovement(tmpLoc, TerrainImprovementDB(TILEIMP_MODERN_CITY_TWO)) || TileHasImprovement(tmpLoc, TerrainImprovementDB(TILEIMP_MODERN_CITY_DEAD)) || TileHasImprovement(tmpLoc, TerrainImprovementDB(TILEIMP_GENETIC_CITY_ONE)) || TileHasImprovement(tmpLoc, TerrainImprovementDB(TILEIMP_GENETIC_CITY_DEAD))) { Event:CreateImprovement(owner,tmpLoc, TerrainImprovementDB(TILEIMP_FUTURE_CITY_ONE),0 ); replaceOld = replaceOld + 1; } elseif (TileHasImprovement(tmpLoc, TerrainImprovementDB(TILEIMP_GENETIC_CITY_TWO)) || TileHasImprovement(tmpLoc, TerrainImprovementDB(TILEIMP_MODERN_CITY_THREE))) { Event:CreateImprovement(owner,tmpLoc, TerrainImprovementDB(TILEIMP_FUTURE_CITY_TWO),0 ); replaceOld = replaceOld + 1; } } if( newType > 0 && cellOwner(tmpLoc) == owner && addDelete == 2) { if (TileHasImprovement(tmpLoc, TerrainImprovementDB(TILEIMP_FUTURE_CITY_ONE)) || TileHasImprovement(tmpLoc, TerrainImprovementDB(TILEIMP_FUTURE_CITY_TWO)) || TileHasImprovement(tmpLoc, TerrainImprovementDB(TILEIMP_SEA_CITY_ONE))) { Event: CutImprovements(tmpLoc); return 1; } } if (newType == 1 && cellOwner(tmpLoc) == owner && addDelete == 1) { if(!TileHasImprovement(tmpLoc, TerrainImprovementDB(TILEIMP_FUTURE_CITY_ONE)) && !TileHasImprovement(tmpLoc, TerrainImprovementDB(TILEIMP_FUTURE_CITY_TWO)) && TileHasWonder(tmpLoc) == 0) { if (TType == TerrainDB(TERRAIN_FOREST) || TType == TerrainDB(TERRAIN_JUNGLE) || TType == TerrainDB(TERRAIN_SWAMP) || TType == TerrainDB(TERRAIN_PLAINS) || TType == TerrainDB(TERRAIN_GRASSLAND) || TType == TerrainDB(TERRAIN_DESERT) || TType == TerrainDB(TERRAIN_TUNDRA) || TType == TerrainDB(TERRAIN_HILL) || TType == TerrainDB(TERRAIN_BROWN_HILL)) { Event:CreateImprovement(owner,tmpLoc, TerrainImprovementDB(TILEIMP_FUTURE_CITY_ONE),0 ); return 1; } } } if (newType > 1 && cellOwner(tmpLoc) == owner && addDelete == 1) { if (TileHasImprovement(tmpLoc, TerrainImprovementDB(TILEIMP_FUTURE_CITY_ONE))) { Event:CreateImprovement(owner,tmpLoc, TerrainImprovementDB(TILEIMP_FUTURE_CITY_TWO),0 ); return 1; } } if (newType > 0 && cellOwner(tmpLoc) == owner && addDelete == 1) { if (TType == TerrainDB(TERRAIN_WATER_DEEP) || TType == TerrainDB(TERRAIN_WATER_TRENCH) || TType == TerrainDB(TERRAIN_WATER_RIFT)) { Event:CreateImprovement(owner,tmpLoc, TerrainImprovementDB(TILEIMP_SEA_CITY_ONE),0 ); return 1; } } GetNeighbor(tmpLoc, searchDirection, tmp2Loc); tmpLoc = tmp2Loc; count = count - 1; } return 0; } int_t ReplaceOld; int_t DontReduce1; int_f ExpandCity(int_t owner, location_t cityLoc, int_t cityRadius, int_t tileType, int_t addDelete) { location_t tmpLoc; location_t tmp2Loc; int_t i; int_t j; int_t k; int_t sucess; int_t newType; int_t searchRadius; int_t addDeleteYN; int_t ownerNum; if (FAI_INIT == 1000) { searchRadius = 1; sucess = 0; newType = tileType; addDeleteYN = addDelete; ownerNum = owner; j = random(6); if (j == 0 || j == 5 || j == 2 || j == 7) { j = 6; } while (searchRadius <= cityRadius && sucess == 0) { tmpLoc = cityLoc; for (k = 0; k < searchRadius; k = k + 1) { GetNeighbor(tmpLoc, j, tmp2Loc); tmpLoc = tmp2Loc; } if (FAI_PlayerAge[owner] < 6) { sucess = ReplaceACTile(ownerNum, tmpLoc, searchRadius, j, newType, addDeleteYN); } elseif (FAI_PlayerAge[owner]== 6 || FAI_PlayerAge[owner] == 7) { sucess = ReplaceMCTile(ownerNum, tmpLoc, searchRadius, j, newType, addDeleteYN); } elseif (FAI_PlayerAge[owner] == 8) { sucess = ReplaceGCTile(ownerNum, tmpLoc, searchRadius, j, newType, addDeleteYN); if(addDeleteYN == 2 && sucess == 0) { sucess = ReplaceMCTile(ownerNum, tmpLoc, searchRadius, j, newType, addDeleteYN); } } elseif (FAI_PlayerAge[owner] == 9) { sucess = ReplaceALTile(ownerNum, tmpLoc, searchRadius, j, newType, addDeleteYN); if(addDeleteYN == 2 && sucess == 0) { sucess = ReplaceGCTile(ownerNum, tmpLoc, searchRadius, j, newType, addDeleteYN); if(addDeleteYN == 2 && sucess == 0) { sucess = ReplaceMCTile(ownerNum, tmpLoc, searchRadius, j, newType, addDeleteYN); } } } i = j + 1; while (i != j && sucess == 0) { tmpLoc = cityLoc; for (k = 0; k < searchRadius; k = k + 1) { GetNeighbor(tmpLoc, i, tmp2Loc); tmpLoc = tmp2Loc; } if (FAI_PlayerAge[owner] < 6) { sucess = ReplaceACTile(ownerNum, tmpLoc, searchRadius, i, newType, addDeleteYN); } elseif (FAI_PlayerAge[owner] == 6 || FAI_PlayerAge[owner] == 7) { sucess = ReplaceMCTile(ownerNum, tmpLoc, searchRadius, i, newType, addDeleteYN); } elseif (FAI_PlayerAge[owner] == 8) { sucess = ReplaceGCTile(ownerNum, tmpLoc, searchRadius, i, newType, addDeleteYN); if(addDeleteYN == 2 && sucess == 0) { sucess = ReplaceMCTile(ownerNum, tmpLoc, searchRadius, j, newType, addDeleteYN); } } elseif (FAI_PlayerAge[owner] == 9) { sucess = ReplaceALTile(ownerNum, tmpLoc, searchRadius, j, newType, addDeleteYN); if(addDeleteYN == 2 && sucess == 0) { ReplaceMCTile(ownerNum, tmpLoc, searchRadius, j, newType, addDeleteYN); if(addDeleteYN == 2 && sucess == 0) { sucess = ReplaceGCTile(ownerNum, tmpLoc, searchRadius, j, newType, addDeleteYN); } } } i = i + 1; if (i == 8) { i = 0; } } searchRadius = searchRadius + 1; } return sucess; } else { return 0; } } HandleEvent(MakePop) 'expanding city' post { city_t theCity; int_t sucess; if (CityIsValid(city[0])) { ReplaceOld = 0; theCity = city[0]; sucess = 1; if (theCity.population == 6) { sucess = ExpandCity(theCity.owner, theCity.location, 1, 1, 1); } elseif (theCity.population == 9) { sucess = ExpandCity(theCity.owner, theCity.location, 1, 1, 1); if (sucess == 1) { ExpandCity(theCity.owner, theCity.location, 1, 2, 1); } } elseif (theCity.population == 12) { sucess = ExpandCity(theCity.owner, theCity.location, 2, 1, 1); } elseif (theCity.population == 15) { sucess = ExpandCity(theCity.owner, theCity.location, 2, 1, 1); if (sucess == 1) { ExpandCity(theCity.owner, theCity.location, 2, 2, 1); } } elseif (theCity.population == 18) { sucess = ExpandCity(theCity.owner, theCity.location, 3, 1, 1); } elseif (theCity.population == 21) { sucess = ExpandCity(theCity.owner, theCity.location, 3, 1, 1); if (sucess == 1) { ExpandCity(theCity.owner, theCity.location, 3, 2, 1); } } elseif (theCity.population == 24) { sucess = ExpandCity(theCity.owner, theCity.location, 3, 1, 1); if (sucess == 1) { ExpandCity(theCity.owner, theCity.location, 3, 2, 1); ExpandCity(theCity.owner, theCity.location, 3, 2, 1); ExpandCity(theCity.owner, theCity.location, 3, 3, 1); } } elseif (theCity.population == 27) { sucess = ExpandCity(theCity.owner, theCity.location, 4, 1, 1); } elseif (theCity.population == 30) { sucess = ExpandCity(theCity.owner, theCity.location, 4, 1, 1); if (sucess == 1) { ExpandCity(theCity.owner, theCity.location, 4, 2, 1); } } elseif (theCity.population == 33) { sucess = ExpandCity(theCity.owner, theCity.location, 4, 1, 1); if (sucess == 1) { ExpandCity(theCity.owner, theCity.location, 4, 2, 1); ExpandCity(theCity.owner, theCity.location, 4, 2, 1); ExpandCity(theCity.owner, theCity.location, 4, 3, 1); } } elseif (theCity.population == 36) { sucess = ExpandCity(theCity.owner, theCity.location, 4, 1, 1); if (sucess == 1) { ExpandCity(theCity.owner, theCity.location, 4, 2, 1); } } elseif (theCity.population == 39) { sucess = ExpandCity(theCity.owner, theCity.location, 4, 1, 1); } elseif (theCity.population == 42) { sucess = ExpandCity(theCity.owner, theCity.location, 4, 1, 1); if (sucess == 1) { ExpandCity(theCity.owner, theCity.location, 4, 2, 1); } } elseif (theCity.population == 45) { sucess = ExpandCity(theCity.owner, theCity.location, 4, 1, 1); if (sucess == 1) { ExpandCity(theCity.owner, theCity.location, 4, 2, 1); ExpandCity(theCity.owner, theCity.location, 4, 2, 1); ExpandCity(theCity.owner, theCity.location, 4, 3, 1); } } elseif (theCity.population == 50) { sucess = ExpandCity(theCity.owner, theCity.location, 4, 1, 1); if (sucess == 1) { ExpandCity(theCity.owner, theCity.location, 4, 2, 1); } } elseif (theCity.population == 55) { sucess = ExpandCity(theCity.owner, theCity.location, 4, 1, 1); if (sucess == 1) { ExpandCity(theCity.owner, theCity.location, 4, 2, 1); ExpandCity(theCity.owner, theCity.location, 4, 2, 1); ExpandCity(theCity.owner, theCity.location, 4, 3, 1); } } elseif (theCity.population == 60) { sucess = ExpandCity(theCity.owner, theCity.location, 4, 1, 1); if (sucess == 1) { ExpandCity(theCity.owner, theCity.location, 4, 2, 1); } } if (sucess == 0) { DontReduce1 = 1; Event: KillPop(theCity); } } } void_f ReduceCity1 (city_t redCity) { city_t theCity; int_t sucess; theCity = redCity; if (theCity.population == 5) { sucess = ExpandCity(theCity.owner, theCity.location, 1, 1, 2); } elseif (theCity.population == 8) { sucess = ExpandCity(theCity.owner, theCity.location, 2, 2, 2); if (sucess == 0) { ExpandCity(theCity.owner, theCity.location, 2, 1, 2); } } elseif (theCity.population == 11) { sucess = ExpandCity(theCity.owner, theCity.location, 3, 1, 2); } elseif (theCity.population == 14) { sucess = ExpandCity(theCity.owner, theCity.location, 4, 2, 2); if (sucess == 0) { ExpandCity(theCity.owner, theCity.location, 4, 1, 2); } } elseif (theCity.population == 17) { sucess = ExpandCity(theCity.owner, theCity.location, 4, 1, 2); } elseif (theCity.population == 20) { sucess = ExpandCity(theCity.owner, theCity.location, 4, 2, 2); if (sucess == 0) { ExpandCity(theCity.owner, theCity.location, 4, 1, 2); } } elseif (theCity.population == 23) { sucess = ExpandCity(theCity.owner, theCity.location, 4, 3, 2); if (sucess == 0) { sucess = ExpandCity(theCity.owner, theCity.location, 4, 2, 2); if (sucess == 0) { ExpandCity(theCity.owner, theCity.location, 4, 1, 2); } } } elseif (theCity.population == 26) { sucess = ExpandCity(theCity.owner, theCity.location, 4, 1, 2); } elseif (theCity.population == 29) { sucess = ExpandCity(theCity.owner, theCity.location, 4, 2, 2); if (sucess == 0) { ExpandCity(theCity.owner, theCity.location, 4, 1, 2); } } elseif (theCity.population == 32) { sucess = ExpandCity(theCity.owner, theCity.location, 4, 3, 2); if (sucess == 0) { sucess = ExpandCity(theCity.owner, theCity.location, 4, 2, 2); if (sucess == 0) { ExpandCity(theCity.owner, theCity.location, 4, 1, 2); } } } elseif (theCity.population == 35) { sucess = ExpandCity(theCity.owner, theCity.location, 4, 2, 2); if (sucess == 0) { ExpandCity(theCity.owner, theCity.location, 4, 1, 2); } } elseif (theCity.population == 38) { sucess = ExpandCity(theCity.owner, theCity.location, 4, 1, 2); } elseif (theCity.population == 41) { sucess = ExpandCity(theCity.owner, theCity.location, 4, 2, 2); if (sucess == 0) { ExpandCity(theCity.owner, theCity.location, 4, 1, 2); } } elseif (theCity.population == 44) { sucess = ExpandCity(theCity.owner, theCity.location, 3, 3, 2); if (sucess == 0) { sucess = ExpandCity(theCity.owner, theCity.location, 3, 2, 2); if (sucess == 0) { ExpandCity(theCity.owner, theCity.location, 3, 1, 2); } } } elseif (theCity.population == 49) { sucess = ExpandCity(theCity.owner, theCity.location, 2, 2, 2); if (sucess == 0) { ExpandCity(theCity.owner, theCity.location, 2, 1, 2); } } elseif (theCity.population == 54) { sucess = ExpandCity(theCity.owner, theCity.location, 1, 3, 2); if (sucess == 0) { sucess = ExpandCity(theCity.owner, theCity.location, 1, 2, 2); if (sucess == 0) { ExpandCity(theCity.owner, theCity.location, 1, 1, 2); } } } elseif (theCity.population == 59) { sucess = ExpandCity(theCity.owner, theCity.location, 2, 3, 2); if (sucess == 0) { ExpandCity(theCity.owner, theCity.location, 2, 2, 2); } } } void_f ReduceCity4 (city_t redCity) { city_t theCity; int_t sucess; theCity = redCity; if (theCity.population >= 5) { sucess = ExpandCity(theCity.owner, theCity.location, 1, 1, 2); } if (theCity.population >= 8) { sucess = ExpandCity(theCity.owner, theCity.location, 2, 2, 2); if (sucess == 0) { ExpandCity(theCity.owner, theCity.location, 2, 1, 2); } } if (theCity.population >= 11) { sucess = ExpandCity(theCity.owner, theCity.location, 3, 1, 2); } if (theCity.population >= 14) { sucess = ExpandCity(theCity.owner, theCity.location, 4, 2, 2); if (sucess == 0) { ExpandCity(theCity.owner, theCity.location, 4, 1, 2); } } if (theCity.population >= 17) { sucess = ExpandCity(theCity.owner, theCity.location, 4, 1, 2); } if (theCity.population >= 20) { sucess = ExpandCity(theCity.owner, theCity.location, 4, 2, 2); if (sucess == 0) { ExpandCity(theCity.owner, theCity.location, 4, 1, 2); } } if (theCity.population >= 23) { sucess = ExpandCity(theCity.owner, theCity.location, 4, 3, 2); if (sucess == 0) { sucess = ExpandCity(theCity.owner, theCity.location, 4, 2, 2); if (sucess == 0) { ExpandCity(theCity.owner, theCity.location, 4, 1, 2); } } } if (theCity.population >= 26) { sucess = ExpandCity(theCity.owner, theCity.location, 4, 1, 2); } if (theCity.population >= 29) { sucess = ExpandCity(theCity.owner, theCity.location, 4, 2, 2); if (sucess == 0) { ExpandCity(theCity.owner, theCity.location, 4, 1, 2); } } if (theCity.population >= 32) { sucess = ExpandCity(theCity.owner, theCity.location, 4, 3, 2); if (sucess == 0) { sucess = ExpandCity(theCity.owner, theCity.location, 4, 2, 2); if (sucess == 0) { ExpandCity(theCity.owner, theCity.location, 4, 1, 2); } } } if (theCity.population >= 35) { sucess = ExpandCity(theCity.owner, theCity.location, 4, 2, 2); if (sucess == 0) { ExpandCity(theCity.owner, theCity.location, 4, 1, 2); } } if (theCity.population >= 38) { sucess = ExpandCity(theCity.owner, theCity.location, 4, 1, 2); } if (theCity.population >= 41) { sucess = ExpandCity(theCity.owner, theCity.location, 4, 2, 2); if (sucess == 0) { ExpandCity(theCity.owner, theCity.location, 4, 1, 2); } } if (theCity.population >= 44) { sucess = ExpandCity(theCity.owner, theCity.location, 3, 3, 2); if (sucess == 0) { sucess = ExpandCity(theCity.owner, theCity.location, 3, 2, 2); if (sucess == 0) { ExpandCity(theCity.owner, theCity.location, 3, 1, 2); } } } if (theCity.population >= 49) { sucess = ExpandCity(theCity.owner, theCity.location, 2, 2, 2); if (sucess == 0) { ExpandCity(theCity.owner, theCity.location, 2, 1, 2); } } if (theCity.population >= 54) { sucess = ExpandCity(theCity.owner, theCity.location, 1, 3, 2); if (sucess == 0) { sucess = ExpandCity(theCity.owner, theCity.location, 1, 2, 2); if (sucess == 0) { ExpandCity(theCity.owner, theCity.location, 1, 1, 2); } } } if (theCity.population >= 59) { sucess = ExpandCity(theCity.owner, theCity.location, 2, 3, 2); if (sucess == 0) { ExpandCity(theCity.owner, theCity.location, 2, 2, 2); } } } HandleEvent(KillPop) 'reducing city' post { if (DontReduce1 == 0) { if (CityIsValid(city[0])) { ReduceCity1 (city[0]); } } else { DontReduce1 = 0; } } HandleEvent(SlaveRaidCity) 'slave raid' post { if (CityIsValid(city[0])) { ReduceCity1 (city[0]); } } HandleEvent(UndergroundRailwayUnit) 'free slaves' post { if (CityIsValid(city[0])) { ReduceCity1 (city[0]); } } HandleEvent(PlagueCity) 'city plagued' pre { if (CityIsValid(city[0])) { ReduceCity1 (city[0]); } } HandleEvent(CreateUnit) 'settler built' post { city_t tmpcity; unit_t tmpunit; unit[0]=tmpunit; city[0]=tmpcity; if ((unit[0].type == UnitDB(UNIT_SETTLER)) // if a the unit is one of those listed here ||(unit[0].type == UnitDB(UNIT_URBAN_PLANNER)) // ... ||(unit[0].type == UnitDB(UNIT_SEA_ENGINEER)) ||(unit[0].type == UnitDB(UNIT_ARCHER)) ||(unit[0].type == UnitDB(UNIT_BOWMAN)) ||(unit[0].type == UnitDB(UNIT_LONGBOWMAN)) ||(unit[0].type == UnitDB(UNIT_LIGHT_CAVALRY)) ||(unit[0].type == UnitDB(UNIT_HEAVY_CAVALRY)) ||(unit[0].type == UnitDB(UNIT_KNIGHT)) ||(unit[0].type == UnitDB(UNIT_CAVALRY)) ||(unit[0].type == UnitDB(UNIT_SPEARMAN)) ||(unit[0].type == UnitDB(UNIT_WARRIOR)) ||(unit[0].type == UnitDB(UNIT_HOPLITE)) ||(unit[0].type == UnitDB(UNIT_PIKEMEN)) ||(unit[0].type == UnitDB(UNIT_INFANTRYMAN)) ||(unit[0].type == UnitDB(UNIT_MACHINE_GUNNER)) ||(unit[0].type == UnitDB(UNIT_MARINE)) ||(unit[0].type == UnitDB(UNIT_MECH_WARRIOR)) ||(unit[0].type == UnitDB(UNIT_HOVER_INFANTRY)) ||(unit[0].type == UnitDB(UNIT_ZULU_WARRIOR)) ||(unit[0].type == UnitDB(UNIT_CHARIOT)) ||(unit[0].type == UnitDB(UNIT_WARRIOR)) ||(unit[0].type == UnitDB(UNIT_HEAVY_WARRIOR)) ||(unit[0].type == UnitDB(UNIT_LEGION)) ||(unit[0].type == UnitDB(UNIT_ELEPHANT)) ||(unit[0].type == UnitDB(UNIT_BERSERKER)) ||(unit[0].type == UnitDB(UNIT_SAMURAI)) ||(unit[0].type == UnitDB(UNIT_TEUTONIC_KNIGHT)) ||(unit[0].type == UnitDB(UNIT_ARQUEBUSIER)) ||(unit[0].type == UnitDB(UNIT_MUSKETEER)) ||(unit[0].type == UnitDB(UNIT_RIFLEMAN)) ||(unit[0].type == UnitDB(UNIT_FASCIST)) ||(unit[0].type == UnitDB(UNIT_MECHANIZED_INFANTRY)) ||(unit[0].type == UnitDB(UNIT_PARATROOPER)) ||(unit[0].type == UnitDB(UNIT_WAR_WALKER)) ||(unit[0].type == UnitDB(UNIT_MECH_TROOPER)) ||(unit[0].type == UnitDB(UNIT_RANGER)) ||(unit[0].type == UnitDB(UNIT_SWARM))) { //... if (CityIsValid(city[0])) { ReduceCity1(city[0]); } } } HandleEvent(NukeCity) 'city nuked' pre { if (CityIsValid(city[0])) { ReduceCity4 (city[0]); } } HandleEvent(KillCity) 'city destroyed' pre { if (CityIsValid(city[0])) { ReduceCity4 (city[0]); } } HandleEvent(CreateParkUnit) 'park created' pre { if (CityIsValid(city[0])) { ReduceCity4 (city[0]); } } // // Cities cant be pilagged // HandleEvent(PillageOrder) 'CantPillageCities' pre { location_t tmpLoc; army_t tmparmy; tmpLoc = tmparmy.location; if(TileHasImprovement(tmpLoc, TerrainImprovementDB(TILEIMP_ANCIENT_CITY_ONE)) || TileHasImprovement(tmpLoc, TerrainImprovementDB(TILEIMP_ANCIENT_CITY_DEAD)) || TileHasImprovement(tmpLoc, TerrainImprovementDB(TILEIMP_MODERN_CITY_ONE)) || TileHasImprovement(tmpLoc, TerrainImprovementDB(TILEIMP_MODERN_CITY_TWO)) || TileHasImprovement(tmpLoc, TerrainImprovementDB(TILEIMP_MODERN_CITY_THREE)) || TileHasImprovement(tmpLoc, TerrainImprovementDB(TILEIMP_MODERN_CITY_DEAD)) || TileHasImprovement(tmpLoc, TerrainImprovementDB(TILEIMP_GENETIC_CITY_ONE)) || TileHasImprovement(tmpLoc, TerrainImprovementDB(TILEIMP_GENETIC_CITY_TWO)) || TileHasImprovement(tmpLoc, TerrainImprovementDB(TILEIMP_GENETIC_CITY_DEAD)) || TileHasImprovement(tmpLoc, TerrainImprovementDB(TILEIMP_FUTURE_CITY_ONE)) || TileHasImprovement(tmpLoc, TerrainImprovementDB(TILEIMP_FUTURE_CITY_TWO)) || TileHasImprovement(tmpLoc, TerrainImprovementDB(TILEIMP_FUTURE_CITY_DEAD)) || TileHasImprovement(tmpLoc, TerrainImprovementDB(TILEIMP_SEA_CITY_ONE)) || TileHasImprovement(tmpLoc, TerrainImprovementDB(TILEIMP_SEA_CITY_DEAD))) { return STOP; } } HandleEvent(CreateImprovement) 'CantCreateImprovementsOverCities' pre { location_t tmpLoc; if(TileHasImprovement(tmpLoc, TerrainImprovementDB(TILEIMP_ANCIENT_CITY_ONE)) || TileHasImprovement(tmpLoc, TerrainImprovementDB(TILEIMP_ANCIENT_CITY_DEAD)) || TileHasImprovement(tmpLoc, TerrainImprovementDB(TILEIMP_MODERN_CITY_ONE)) || TileHasImprovement(tmpLoc, TerrainImprovementDB(TILEIMP_MODERN_CITY_TWO)) || TileHasImprovement(tmpLoc, TerrainImprovementDB(TILEIMP_MODERN_CITY_THREE)) || TileHasImprovement(tmpLoc, TerrainImprovementDB(TILEIMP_MODERN_CITY_DEAD)) || TileHasImprovement(tmpLoc, TerrainImprovementDB(TILEIMP_GENETIC_CITY_ONE)) || TileHasImprovement(tmpLoc, TerrainImprovementDB(TILEIMP_GENETIC_CITY_TWO)) || TileHasImprovement(tmpLoc, TerrainImprovementDB(TILEIMP_GENETIC_CITY_DEAD)) || TileHasImprovement(tmpLoc, TerrainImprovementDB(TILEIMP_FUTURE_CITY_ONE)) || TileHasImprovement(tmpLoc, TerrainImprovementDB(TILEIMP_FUTURE_CITY_TWO)) || TileHasImprovement(tmpLoc, TerrainImprovementDB(TILEIMP_FUTURE_CITY_DEAD)) || TileHasImprovement(tmpLoc, TerrainImprovementDB(TILEIMP_SEA_CITY_ONE)) || TileHasImprovement(tmpLoc, TerrainImprovementDB(TILEIMP_SEA_CITY_DEAD))) { return STOP; } } HandleEvent(CutImprovements) 'CantCreateImprovementsOverCities' pre { location_t tmpLoc; if(TileHasImprovement(tmpLoc, TerrainImprovementDB(TILEIMP_ANCIENT_CITY_ONE)) || TileHasImprovement(tmpLoc, TerrainImprovementDB(TILEIMP_ANCIENT_CITY_DEAD)) || TileHasImprovement(tmpLoc, TerrainImprovementDB(TILEIMP_MODERN_CITY_ONE)) || TileHasImprovement(tmpLoc, TerrainImprovementDB(TILEIMP_MODERN_CITY_TWO)) || TileHasImprovement(tmpLoc, TerrainImprovementDB(TILEIMP_MODERN_CITY_THREE)) || TileHasImprovement(tmpLoc, TerrainImprovementDB(TILEIMP_MODERN_CITY_DEAD)) || TileHasImprovement(tmpLoc, TerrainImprovementDB(TILEIMP_GENETIC_CITY_ONE)) || TileHasImprovement(tmpLoc, TerrainImprovementDB(TILEIMP_GENETIC_CITY_TWO)) || TileHasImprovement(tmpLoc, TerrainImprovementDB(TILEIMP_GENETIC_CITY_DEAD)) || TileHasImprovement(tmpLoc, TerrainImprovementDB(TILEIMP_FUTURE_CITY_ONE)) || TileHasImprovement(tmpLoc, TerrainImprovementDB(TILEIMP_FUTURE_CITY_TWO)) || TileHasImprovement(tmpLoc, TerrainImprovementDB(TILEIMP_FUTURE_CITY_DEAD)) || TileHasImprovement(tmpLoc, TerrainImprovementDB(TILEIMP_SEA_CITY_ONE)) || TileHasImprovement(tmpLoc, TerrainImprovementDB(TILEIMP_SEA_CITY_DEAD))) { return STOP; } } // // Cities must have roads // HandleEvent(BeginTurn) 'PlaceRoadsInCities' pre { int_t i; //array location counter int_t j; //array location counter int_t owner; location_t tmpLoc; for (i=0; i<=GetMapWidth()-1; i=i+1) { for (j=0; j<=GetMapHeight()-1 ; j=j+1) { MakeLocation(tmpLoc, i, j); if(!TileHasImprovement(tmpLoc, TerrainImprovementDB(TILEIMP_ROAD)) && !TileHasImprovement(tmpLoc, TerrainImprovementDB(TILEIMP_RAILROAD)) && !TileHasImprovement(tmpLoc, TerrainImprovementDB(TILEIMP_MAGLEV))) { if(TileHasImprovement(tmpLoc, TerrainImprovementDB(TILEIMP_ANCIENT_CITY_ONE))) { Event:CreateImprovement(owner,tmpLoc, TerrainImprovementDB(TILEIMP_ROAD),0 ); } elseif(TileHasImprovement(tmpLoc, TerrainImprovementDB(TILEIMP_MODERN_CITY_ONE)) || TileHasImprovement(tmpLoc, TerrainImprovementDB(TILEIMP_MODERN_CITY_TWO)) || TileHasImprovement(tmpLoc, TerrainImprovementDB(TILEIMP_MODERN_CITY_THREE))) { Event:CreateImprovement(owner,tmpLoc, TerrainImprovementDB(TILEIMP_RAILROAD),0 ); } elseif( TileHasImprovement(tmpLoc, TerrainImprovementDB(TILEIMP_GENETIC_CITY_ONE)) || TileHasImprovement(tmpLoc, TerrainImprovementDB(TILEIMP_GENETIC_CITY_TWO)) || TileHasImprovement(tmpLoc, TerrainImprovementDB(TILEIMP_FUTURE_CITY_ONE)) || TileHasImprovement(tmpLoc, TerrainImprovementDB(TILEIMP_FUTURE_CITY_TWO))) { Event:CreateImprovement(owner,tmpLoc, TerrainImprovementDB(TILEIMP_MAGLEV),0 ); } elseif( TileHasImprovement(tmpLoc, TerrainImprovementDB(TILEIMP_SEA_CITY_ONE))){ Event:CreateImprovement(owner,tmpLoc, TerrainImprovementDB(TILEIMP_UNDERSEA_TUNNEL),0 ); } } } } }