//////////////////////////////////////////////////////////////////////////////////////////////// // // 2) City Expansion by BlueO, Pedrunn and IW // // Cities expand with tile improvements and not goods anymore and sea cities also expand // // 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. // // 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 // 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 // ('addDelete' == 3) Creates a wonder // // //////////////////////////////////////////////////////////////////////////////////////////////// // 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_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 (cellOwner(tmpLoc) == owner && addDelete == 2) { if(TileHasImprovement(tmpLoc, TerrainImprovementDB(TILEIMP_ANCIENT_CITY_ONE))) { Event:CreateImprovement(owner, tmpLoc, TerrainImprovementDB(TILEIMP_ANCIENT_CITY_DEAD), 0); 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 ReplaceFCTile(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 (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_MEDIEVAL_CITY_ONE),0 );// Create Railroad replaceOld = replaceOld + 1; } } if (cellOwner(tmpLoc) == owner && addDelete == 2) { if(TileHasImprovement(tmpLoc, TerrainImprovementDB(TILEIMP_ANCIENT_CITY_ONE)) || TileHasImprovement(tmpLoc, TerrainImprovementDB(TILEIMP_MEDIEVAL_CITY_ONE))) { Event:CreateImprovement(owner, tmpLoc, TerrainImprovementDB(TILEIMP_ANCIENT_CITY_DEAD), 0); return 1; } } if (newType == 1 && cellOwner(tmpLoc) == owner && addDelete == 1 && !TileHasImprovement(tmpLoc, TerrainImprovementDB(TILEIMP_MEDIEVAL_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_MEDIEVAL_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_MEDIEVAL_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_ANCIENT_CITY_ONE)) || TileHasImprovement(tmpLoc, TerrainImprovementDB(TILEIMP_MEDIEVAL_CITY_ONE))) { Event:CreateImprovement(owner, tmpLoc, TerrainImprovementDB(TILEIMP_ANCIENT_CITY_DEAD), 0); return 1; } elseif(TileHasImprovement(tmpLoc, TerrainImprovementDB(TILEIMP_MODERN_CITY_ONE))) { Event:CreateImprovement(owner, tmpLoc, TerrainImprovementDB(TILEIMP_MODERN_CITY_DEAD), 0); return 1; } } if (newType == 2 && cellOwner(tmpLoc) == owner && addDelete == 2) { if(TileHasImprovement(tmpLoc, TerrainImprovementDB(TILEIMP_MODERN_CITY_TWO))) { Event:CreateImprovement(owner, tmpLoc, TerrainImprovementDB(TILEIMP_MODERN_CITY_ONE), 0); return 1; } } if (newType == 3 && cellOwner(tmpLoc) == owner && addDelete == 2) { if(TileHasImprovement(tmpLoc, TerrainImprovementDB(TILEIMP_MODERN_CITY_THREE))) { Event:CreateImprovement(owner, tmpLoc, TerrainImprovementDB(TILEIMP_MODERN_CITY_TWO), 0); 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_MEDIEVAL_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 == 1 && cellOwner(tmpLoc) == owner && addDelete == 2) { if(TileHasImprovement(tmpLoc, TerrainImprovementDB(TILEIMP_ANCIENT_CITY_ONE)) || TileHasImprovement(tmpLoc, TerrainImprovementDB(TILEIMP_MEDIEVAL_CITY_ONE))) { Event:CreateImprovement(owner, tmpLoc, TerrainImprovementDB(TILEIMP_ANCIENT_CITY_DEAD), 0); return 1; } elseif(TileHasImprovement(tmpLoc, TerrainImprovementDB(TILEIMP_MODERN_CITY_ONE))) { Event:CreateImprovement(owner, tmpLoc, TerrainImprovementDB(TILEIMP_MODERN_CITY_DEAD), 0); return 1; } elseif(TileHasImprovement(tmpLoc, TerrainImprovementDB(TILEIMP_GENETIC_CITY_ONE))) { Event:CreateImprovement(owner, tmpLoc, TerrainImprovementDB(TILEIMP_GENETIC_CITY_DEAD), 0); return 1; } elseif(TileHasImprovement(tmpLoc, TerrainImprovementDB(TILEIMP_SEA_CITY_ONE))) { Event:CreateImprovement(owner, tmpLoc, TerrainImprovementDB(TILEIMP_SEA_CITY_DEAD), 0); return 1; } } if (newType == 2 && cellOwner(tmpLoc) == owner && addDelete == 2) { if(TileHasImprovement(tmpLoc, TerrainImprovementDB(TILEIMP_MODERN_CITY_TWO))) { Event:CreateImprovement(owner, tmpLoc, TerrainImprovementDB(TILEIMP_MODERN_CITY_ONE), 0); return 1; } elseif(TileHasImprovement(tmpLoc, TerrainImprovementDB(TILEIMP_GENETIC_CITY_TWO))) { Event:CreateImprovement(owner, tmpLoc, TerrainImprovementDB(TILEIMP_GENETIC_CITY_ONE), 0); return 1; } } if (newType == 3 && cellOwner(tmpLoc) == owner && addDelete == 2) { if(TileHasImprovement(tmpLoc, TerrainImprovementDB(TILEIMP_MODERN_CITY_THREE))) { Event:CreateImprovement(owner, tmpLoc, TerrainImprovementDB(TILEIMP_MODERN_CITY_TWO), 0); return 1; } elseif(TileHasImprovement(tmpLoc, TerrainImprovementDB(TILEIMP_GENETIC_CITY_TWO))) { 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)) && !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_MEDIEVAL_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 == 1 && cellOwner(tmpLoc) == owner && addDelete == 2) { if(TileHasImprovement(tmpLoc, TerrainImprovementDB(TILEIMP_ANCIENT_CITY_ONE)) || TileHasImprovement(tmpLoc, TerrainImprovementDB(TILEIMP_MEDIEVAL_CITY_ONE))) { Event:CreateImprovement(owner, tmpLoc, TerrainImprovementDB(TILEIMP_ANCIENT_CITY_DEAD), 0); return 1; } elseif(TileHasImprovement(tmpLoc, TerrainImprovementDB(TILEIMP_MODERN_CITY_ONE))) { Event:CreateImprovement(owner, tmpLoc, TerrainImprovementDB(TILEIMP_MODERN_CITY_DEAD), 0); return 1; } elseif(TileHasImprovement(tmpLoc, TerrainImprovementDB(TILEIMP_GENETIC_CITY_ONE))) { Event:CreateImprovement(owner, tmpLoc, TerrainImprovementDB(TILEIMP_GENETIC_CITY_DEAD), 0); return 1; } elseif(TileHasImprovement(tmpLoc, TerrainImprovementDB(TILEIMP_FUTURE_CITY_ONE))) { Event:CreateImprovement(owner, tmpLoc, TerrainImprovementDB(TILEIMP_FUTURE_CITY_DEAD), 0); return 1; } elseif(TileHasImprovement(tmpLoc, TerrainImprovementDB(TILEIMP_SEA_CITY_ONE))) { Event:CreateImprovement(owner, tmpLoc, TerrainImprovementDB(TILEIMP_SEA_CITY_DEAD), 0); return 1; } } if (newType == 2 && cellOwner(tmpLoc) == owner && addDelete == 2) { if(TileHasImprovement(tmpLoc, TerrainImprovementDB(TILEIMP_MODERN_CITY_TWO))) { Event:CreateImprovement(owner, tmpLoc, TerrainImprovementDB(TILEIMP_MODERN_CITY_ONE), 0); return 1; } elseif(TileHasImprovement(tmpLoc, TerrainImprovementDB(TILEIMP_GENETIC_CITY_TWO))) { Event:CreateImprovement(owner, tmpLoc, TerrainImprovementDB(TILEIMP_GENETIC_CITY_ONE), 0); return 1; } elseif(TileHasImprovement(tmpLoc, TerrainImprovementDB(TILEIMP_FUTURE_CITY_TWO))) { Event:CreateImprovement(owner, tmpLoc, TerrainImprovementDB(TILEIMP_FUTURE_CITY_ONE), 0); return 1; } } if (newType == 3 && cellOwner(tmpLoc) == owner && addDelete == 2) { if(TileHasImprovement(tmpLoc, TerrainImprovementDB(TILEIMP_MODERN_CITY_THREE))) { Event:CreateImprovement(owner, tmpLoc, TerrainImprovementDB(TILEIMP_MODERN_CITY_TWO), 0); return 1; } elseif(TileHasImprovement(tmpLoc, TerrainImprovementDB(TILEIMP_GENETIC_CITY_TWO))) { Event:CreateImprovement(owner, tmpLoc, TerrainImprovementDB(TILEIMP_GENETIC_CITY_ONE), 0); return 1; } elseif(TileHasImprovement(tmpLoc, TerrainImprovementDB(TILEIMP_FUTURE_CITY_TWO))) { 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)) && !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_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; 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 (HasAdvance(owner, ID_ADVANCE_AGRICULTURE) && !HasAdvance(owner, ID_ADVANCE_FEUDALISM) && !HasAdvance(owner, ID_ADVANCE_MASS_MEDIA) && !HasAdvance(owner, ID_ADVANCE_GAIA_THEORY) && !HasAdvance(owner, ID_ADVANCE_FUTURE_TECHNOLOGY)) { sucess = ReplaceACTile(ownerNum, tmpLoc, searchRadius, j, newType, addDeleteYN); } elseif (HasAdvance(owner, ID_ADVANCE_AGRICULTURE) && HasAdvance(owner, ID_ADVANCE_FEUDALISM) && !HasAdvance(owner, ID_ADVANCE_MASS_MEDIA) && !HasAdvance(owner, ID_ADVANCE_GAIA_THEORY) && !HasAdvance(owner, ID_ADVANCE_FUTURE_TECHNOLOGY)) { sucess = ReplaceFCTile(ownerNum, tmpLoc, searchRadius, j, newType, addDeleteYN); } elseif (HasAdvance(owner, ID_ADVANCE_AGRICULTURE) && HasAdvance(owner, ID_ADVANCE_FEUDALISM) && HasAdvance(owner, ID_ADVANCE_MASS_MEDIA) && !HasAdvance(owner, ID_ADVANCE_GAIA_THEORY) && !HasAdvance(owner, ID_ADVANCE_FUTURE_TECHNOLOGY)) { sucess = ReplaceMCTile(ownerNum, tmpLoc, searchRadius, j, newType, addDeleteYN); } elseif (HasAdvance(owner, ID_ADVANCE_AGRICULTURE) && HasAdvance(owner, ID_ADVANCE_FEUDALISM) && HasAdvance(owner, ID_ADVANCE_MASS_MEDIA) && HasAdvance(owner, ID_ADVANCE_GAIA_THEORY) && !HasAdvance(owner, ID_ADVANCE_FUTURE_TECHNOLOGY)) { sucess = ReplaceGCTile(ownerNum, tmpLoc, searchRadius, j, newType, addDeleteYN); } elseif (HasAdvance(owner, ID_ADVANCE_AGRICULTURE) && HasAdvance(owner, ID_ADVANCE_FEUDALISM) && HasAdvance(owner, ID_ADVANCE_MASS_MEDIA) && HasAdvance(owner, ID_ADVANCE_GAIA_THEORY) && HasAdvance(owner, ID_ADVANCE_FUTURE_TECHNOLOGY)) { sucess = ReplaceALTile(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 (HasAdvance(owner, ID_ADVANCE_AGRICULTURE) && !HasAdvance(owner, ID_ADVANCE_FEUDALISM) && !HasAdvance(owner, ID_ADVANCE_MASS_MEDIA) && !HasAdvance(owner, ID_ADVANCE_GAIA_THEORY) && !HasAdvance(owner, ID_ADVANCE_FUTURE_TECHNOLOGY)) { sucess = ReplaceACTile(ownerNum, tmpLoc, searchRadius, j, newType, addDeleteYN); } elseif (HasAdvance(owner, ID_ADVANCE_AGRICULTURE) && HasAdvance(owner, ID_ADVANCE_FEUDALISM) && !HasAdvance(owner, ID_ADVANCE_MASS_MEDIA) && !HasAdvance(owner, ID_ADVANCE_GAIA_THEORY) && !HasAdvance(owner, ID_ADVANCE_FUTURE_TECHNOLOGY)) { sucess = ReplaceFCTile(ownerNum, tmpLoc, searchRadius, j, newType, addDeleteYN); } elseif (HasAdvance(owner, ID_ADVANCE_AGRICULTURE) && HasAdvance(owner, ID_ADVANCE_FEUDALISM) && HasAdvance(owner, ID_ADVANCE_MASS_MEDIA) && !HasAdvance(owner, ID_ADVANCE_GAIA_THEORY) && !HasAdvance(owner, ID_ADVANCE_FUTURE_TECHNOLOGY)) { sucess = ReplaceMCTile(ownerNum, tmpLoc, searchRadius, j, newType, addDeleteYN); } elseif (HasAdvance(owner, ID_ADVANCE_AGRICULTURE) && HasAdvance(owner, ID_ADVANCE_FEUDALISM) && HasAdvance(owner, ID_ADVANCE_MASS_MEDIA) && HasAdvance(owner, ID_ADVANCE_GAIA_THEORY) && !HasAdvance(owner, ID_ADVANCE_FUTURE_TECHNOLOGY)) { sucess = ReplaceGCTile(ownerNum, tmpLoc, searchRadius, j, newType, addDeleteYN); } elseif (HasAdvance(owner, ID_ADVANCE_AGRICULTURE) && HasAdvance(owner, ID_ADVANCE_FEUDALISM) && HasAdvance(owner, ID_ADVANCE_MASS_MEDIA) && HasAdvance(owner, ID_ADVANCE_GAIA_THEORY) && HasAdvance(owner, ID_ADVANCE_FUTURE_TECHNOLOGY)) { sucess = ReplaceALTile(ownerNum, tmpLoc, searchRadius, j, newType, addDeleteYN); } i = i + 1; if (i == 8) { i = 0; } } searchRadius = searchRadius + 1; } return sucess; } HandleEvent(MakePop) 'expanding city' post { city_t theCity; int_t sucess; int_t pop; if (CityIsValid(city[0])) { ReplaceOld = 0; theCity = city[0]; sucess = 1; pop = theCity.population; if (pop == 3 || pop == 6 || pop == 9 || pop == 12 || pop == 15 || pop == 18) { sucess = ExpandCity(theCity.owner, theCity.location, 2, 1, 1); } elseif (pop == 21 || pop == 24 || pop == 27 || pop == 30) { sucess = ExpandCity(theCity.owner, theCity.location, 2, 2, 1); if (sucess == 1) { ExpandCity(theCity.owner, theCity.location, 3, 1, 1); } } elseif (pop == 33 || pop == 36) { sucess = ExpandCity(theCity.owner, theCity.location, 1, 3, 1); if (sucess == 1) { ExpandCity(theCity.owner, theCity.location, 2, 2, 1); ExpandCity(theCity.owner, theCity.location, 3, 1, 1); } } if (pop == 39 || pop == 42 || pop == 45 || pop == 48 || pop == 51 || pop == 54) { sucess = ExpandCity(theCity.owner, theCity.location, 3, 1, 1); } elseif (pop == 57 || pop == 60 || pop == 63 || pop == 66) { sucess = ExpandCity(theCity.owner, theCity.location, 2, 2, 1); if (sucess == 1) { ExpandCity(theCity.owner, theCity.location, 3, 1, 1); } } elseif (pop == 69 || pop == 72) { sucess = ExpandCity(theCity.owner, theCity.location, 2, 3, 1); if (sucess == 1) { ExpandCity(theCity.owner, theCity.location, 3, 2, 1); ExpandCity(theCity.owner, theCity.location, 4, 1, 1); } } if (pop == 75 || pop == 78 || pop == 81 || pop == 84 || pop == 87 || pop == 90) { sucess = ExpandCity(theCity.owner, theCity.location, 4, 1, 1); } elseif (pop == 93 || pop == 96 || pop == 99 || pop == 102) { sucess = ExpandCity(theCity.owner, theCity.location, 3, 2, 1); if (sucess == 1) { ExpandCity(theCity.owner, theCity.location, 4, 1, 1); } } elseif (pop == 105 || pop == 108) { sucess = ExpandCity(theCity.owner, theCity.location, 2, 3, 1); if (sucess == 1) { ExpandCity(theCity.owner, theCity.location, 3, 2, 1); ExpandCity(theCity.owner, theCity.location, 4, 1, 1); } } if (pop == 111 || pop == 114 || pop == 117 || pop == 120) { sucess = ExpandCity(theCity.owner, theCity.location, 4, 1, 1); } if (sucess == 0) { Event: KillPop(theCity); } } } // // // Reduce City // // // HandleEvent(KillPop) 'KillPop' post { city_t theCity; int_t sucess; int_t pop; if (CityIsValid(city[0])) { theCity = city[0]; ReplaceOld = 0; sucess = 1; pop = theCity.population; if (pop == 2 || pop == 5 || pop == 8 || pop == 11 || pop == 14 || pop == 17) { sucess = ExpandCity(theCity.owner, theCity.location, 2, 1, 2); } elseif (pop == 20 || pop == 23 || pop == 26 || pop == 29 || pop == 32 || pop == 35 || pop == 38 || pop == 41 || pop == 44 || pop == 47 || pop == 50 || pop == 53 || pop == 55 || pop == 58 || pop == 61 || pop == 64) { sucess = ExpandCity(theCity.owner, theCity.location, 3, 1, 2); if (sucess == 1) { ExpandCity(theCity.owner, theCity.location, 2, 2, 2); ExpandCity(theCity.owner, theCity.location, 1, 3, 2); } } elseif (pop == 68 || pop == 71 || pop == 74 || pop == 77 || pop == 80 || pop == 83 || pop == 86 || pop == 89 || pop == 92 || pop == 95 || pop == 98 || pop == 101 || pop == 104 || pop == 107 || pop == 110 || pop == 114 || pop == 117 || pop == 119) { sucess = ExpandCity(theCity.owner, theCity.location, 4, 1, 2); if (sucess == 1) { ExpandCity(theCity.owner, theCity.location, 3, 2, 2); ExpandCity(theCity.owner, theCity.location, 2, 3, 2); } } } } void_f ReduceCity(city_t theCity) { int_t pop; int_t radius; pop = theCity.population; if (pop < 9) { ExpandCity(theCity.owner, theCity.location, 1, 1, 2); } elseif (pop >= 9 && pop < 21) { ExpandCity(theCity.owner, theCity.location, 2, 1, 2); ExpandCity(theCity.owner, theCity.location, 1, 2, 2); } elseif (pop >= 21 && pop < 68) { ExpandCity(theCity.owner, theCity.location, 3, 1, 2); ExpandCity(theCity.owner, theCity.location, 2, 2, 2); ExpandCity(theCity.owner, theCity.location, 1, 3, 2); } elseif (pop >= 68) { ExpandCity(theCity.owner, theCity.location, 4, 1, 2); ExpandCity(theCity.owner, theCity.location, 3, 2, 2); ExpandCity(theCity.owner, theCity.location, 2, 3, 2); } } HandleEvent(SlaveRaidCity) 'SlaveRaidCity' pre { city_t theCity; if (CityIsValid(city[0])) { theCity = city[0]; ReduceCity(theCity); } } HandleEvent(UndergroundRailwayUnit) 'FreeSlavesInCity' pre { city_t theCity; if (CityIsValid(city[0])) { theCity = city[0]; ReduceCity(theCity); } } HandleEvent(PlagueCity) 'CityPlagued' pre { city_t theCity; if (CityIsValid(city[0])) { theCity = city[0]; ReduceCity(theCity); } } HandleEvent(CaptureCity) 'CityCaptured' pre { // Doesnt work :( city_t theCity; if (CityIsValid(city[0])) { theCity = city[0]; ReduceCity(theCity); } } HandleEvent(NukeCity) 'CityNuked' pre { int_t i; int_t Count; city_t theCity; if (CityIsValid(city[0])) { theCity = city[0]; Count = 1 + (theCity.population*2/9); for(i=0; i < Count; i = i + 1) { ReduceCity(theCity); } } } HandleEvent(KillCity) 'CityDestroyed' pre { // When will this work? A city only dies if it has size 1 int_t i; int_t Count; city_t theCity; if (CityIsValid(city[0])) { theCity = city[0]; Count = 1 + theCity.population/3; for(i=0; i < Count; i = i + 1) { ReduceCity(theCity); } } } HandleEvent(CreateParkUnit) 'CreatedParkOverCity' pre { // Doenst work but the Create Park destroys everything int_t i; // in a radius of 3 from the city. So it is not a big deal. int_t Count; city_t theCity; if (CityIsValid(city[0])) { theCity = city[0]; Count = 1 + theCity.population/3; for(i=0; i < Count; i = i + 1) { ReduceCity(theCity); } } }