Announcement

Collapse
No announcement yet.

Forts for AIs

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Forts for AIs

    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:

    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
    }
    }
    }
    }
    }
    }
    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.
    Attached Files
    Last edited by Martin Gühmann; September 22, 2001, 07:53.
    Civ2 military advisor: "No complaints, Sir!"

  • #2
    Cool!

    Soon there will be no end to the AIs ability to kick human ass...

    That will be a great way to get the AI to (hopefully) get better priorities for defending, perhaps even attacking.
    Thanks Martin.

    (Could you drop the long outcommented bits down a line, it screwing with the page... Ta)
    Concrete, Abstract, or Squoingy?
    "I don't believe in giving scripting languages because the only additional power they give users is the power to create bugs." - Mike Breitkreutz, Firaxis

    Comment


    • #3
      Great, Martin. This is something we've needed for ages.

      Comment


      • #4
        Excillent SLIC!

        Still, sometimes AI builds too many forts.

        Comment


        • #5
          I had to do some slic debug work, today. At this occasion I found to bugs in the code. That causes some error messages if you played with DebugSlic=Yes. Now it is fixed. For download visit my page or click here. Note I didn't replaced the attachment in the first post, as I have problems with downloading attachments. Note that this slic file is compartible with all mods in which you have to pay 1000 PW for a fort.

          -Martin
          Civ2 military advisor: "No complaints, Sir!"

          Comment


          • #6
            Great work Martin, i'll have a go with it this weekend
            Which of the main mods will it work with? And will it work in a multiplayer game?
            Thanks again.
            'The very basis of the liberal idea – the belief of individual freedom is what causes the chaos' - William Kristol, son of the founder of neo-conservitivism, talking about neo-con ideology and its agenda for you.info here. prove me wrong.

            Bush's Republican=Neo-con for all intent and purpose. be afraid.

            Comment


            • #7
              Originally posted by child of Thor
              Which of the main mods will it work with?
              As I said it will work with all mods in which you have to pay for a fort 1000 PW that is the case in the original game, in AplytonPack, in GoodMod and I think also in World at War. It is not compartible with Cradle as you have in Cradle to pay 3600 PW for a fort. Note that all these mods already contain the first version of this script. In GoodMod you have just to replace the MG_FortsForAIs.slc, in the other mods that I mentioned above the MG_ prefix is replaced by the prefix of the mod, so you can rename the file and than replace the file of the mod by this one or just modify the according entry in the the *_script.slc of the modsetup.

              MedPack2 doesn't use this script but it is compartible.

              Originally posted by child of Thor
              And will it work in a multiplayer game?
              It works in MP, too. As it just asked for the fact is the current player not a human, only if this condition is true it will build a fort, so no benefits for the human.

              -Martin
              Civ2 military advisor: "No complaints, Sir!"

              Comment


              • #8
                O.K. If i wanted to include it in my Craddle games would i change the number 1000 to 3600 as in 'MGPw = MGPw + 3600;' ? (new territory for me - just seems logical?)
                'The very basis of the liberal idea – the belief of individual freedom is what causes the chaos' - William Kristol, son of the founder of neo-conservitivism, talking about neo-con ideology and its agenda for you.info here. prove me wrong.

                Bush's Republican=Neo-con for all intent and purpose. be afraid.

                Comment


                • #9
                  Originally posted by child of Thor
                  O.K. If i wanted to include it in my Craddle games would i change the number 1000 to 3600 as in 'MGPw = MGPw + 3600;' ? (new territory for me - just seems logical?)
                  Yes, or just download this one.

                  -Martin
                  Civ2 military advisor: "No complaints, Sir!"

                  Comment


                  • #10
                    Hey! Thanks Martin,
                    I'm going to be starting a new game on Friday night so thank you very much
                    'The very basis of the liberal idea – the belief of individual freedom is what causes the chaos' - William Kristol, son of the founder of neo-conservitivism, talking about neo-con ideology and its agenda for you.info here. prove me wrong.

                    Bush's Republican=Neo-con for all intent and purpose. be afraid.

                    Comment

                    Working...
                    X