Did you ever noticed that the AI doesn't use forts to close the gaps in its empire between cities. I notice that the AI tries to connect its cities by roads, but it can only build the road straight to its borders, without forts it can't connect the cities. Therefore here is the code: It detects if the construction of a road is complete in the neighbourhood of this border and will build a fort on a neutral neighbour tile:
To install the script file open the file script.slc (of coarse if you are using in your \ctp2_data\default\gamedata\ directory and insert at the end of that file the line:
#include "MG_FortsForAIs.slc"
And put the file MG_FortsForAIs.slc into your \ctp2_data\default\gamedata\ directory.
This fort code will be a part of the next version of GoodMod. Unfortunatly this code doesn't detect the gaps in an existing road network. Therefore the best would be to start a new game, but it can also implemented in an existing game. All what you have to do after installation of this file: Open the the chat window in the game by typing (') of coarse without the brackets and type /reloadslic.
I tried to make such a code that detect existing gaps in the road network but the code didn't work. Maybe someone can help.
-Martin
Edit: Hope it is better now.
Code:
HandleEvent(ImprovementComplete) 'MG_BuildFortification' post { int_t MG_tilimpcomplete; MG_tilimpcomplete = value[0]; improvement[0] = MG_tilimpcomplete; location_t MGFortLoc; int_t k; int_t MG_OK; MG_OK = 0; unit_t MGFortUnit; int_t MGPw; if(!(IsHumanPlayer(player[0]))){ if ((MG_tilimpcomplete == TerrainImprovementDB(TILEIMP_ROAD)) // check if terrain has roads, railroads or maglevs ||(MG_tilimpcomplete == TerrainImprovementDB(TILEIMP_RAILROAD)) ||(MG_tilimpcomplete == TerrainImprovementDB(TILEIMP_MAGLEV))){ for (k=7; k>=0 ; k=k-1) { //directions GetNeighbor(location[0], k, MGFortLoc);//look around if ((TerrainType(MGFortLoc)<=9)||(18<=(TerrainType(MGFortLoc))<=21)) { //check if neighbour tile is a land tile if ((CellOwner(MGFortLoc)==-1)&&(MG_OK == 0)) { //make shure that neighbour tile is owned by noone MGPw = player[0].publicworkslevel; // get AI players current public works level MGPw = MGPw + 1000; setPW(CellOwner(location[0]), MGPw); // make shure that AI player has enough puplic works to build a fort CreateUnit(CellOwner(location[0]), UnitDB(UNIT_DIPLOMAT), MGFortLoc, 1, MGFortUnit); //creates a unit to make shure that fort location is in the vision range of the AI player Event: CreateImprovement(CellOwner(location[0]), MGFortLoc, 8, 0); //create fort Event: DisbandUnit(MGFortUnit); //disband unit at fort location MG_OK = 1; // make shure that only one fort is build } } } } } }
#include "MG_FortsForAIs.slc"
And put the file MG_FortsForAIs.slc into your \ctp2_data\default\gamedata\ directory.
This fort code will be a part of the next version of GoodMod. Unfortunatly this code doesn't detect the gaps in an existing road network. Therefore the best would be to start a new game, but it can also implemented in an existing game. All what you have to do after installation of this file: Open the the chat window in the game by typing (') of coarse without the brackets and type /reloadslic.
I tried to make such a code that detect existing gaps in the road network but the code didn't work. Maybe someone can help.
-Martin
Edit: Hope it is better now.
Comment