Thread Tools
Old September 22, 2001, 06:36   #1
Martin Gühmann
staff
Call to Power II Democracy GameCall to Power Democracy GameCTP2 Source Code Project
Super Moderator
 
Martin Gühmann's Avatar
 
Local Time: 15:41
Local Date: October 31, 2010
Join Date: Mar 2001
Location: Tübingen, Germany
Posts: 6,206
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:
File Type: slc mg_fortsforais.slc (2.1 KB, 26 views)
__________________
Civ2 military advisor: "No complaints, Sir!"

Last edited by Martin Gühmann; September 22, 2001 at 07:53.
Martin Gühmann is offline  
Old September 22, 2001, 06:59   #2
Immortal Wombat
Apolytoners Hall of Fame
Prince
 
Immortal Wombat's Avatar
 
Local Time: 14:41
Local Date: October 31, 2010
Join Date: Dec 2000
Location: in perpetuity
Posts: 4,962
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
Immortal Wombat is offline  
Old September 22, 2001, 08:54   #3
Peter Triggs
CTP2 Source Code ProjectCivilization IV Creators
King
 
Local Time: 13:41
Local Date: October 31, 2010
Join Date: Jan 2000
Location: Gone Fishin, Canada
Posts: 1,059
Great, Martin. This is something we've needed for ages.
Peter Triggs is offline  
Old September 25, 2001, 03:23   #4
player1
Emperor
 
player1's Avatar
 
Local Time: 15:41
Local Date: October 31, 2010
Join Date: Sep 2001
Location: Belgrade, Serbia
Posts: 3,218
Excillent SLIC!

Still, sometimes AI builds too many forts.
player1 is offline  
Old March 30, 2002, 19:37   #5
Martin Gühmann
staff
Call to Power II Democracy GameCall to Power Democracy GameCTP2 Source Code Project
Super Moderator
 
Martin Gühmann's Avatar
 
Local Time: 15:41
Local Date: October 31, 2010
Join Date: Mar 2001
Location: Tübingen, Germany
Posts: 6,206
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!"
Martin Gühmann is offline  
Old March 31, 2002, 08:23   #6
child of Thor
Call to Power II Democracy GameCTP2 Source Code Project
Emperor
 
child of Thor's Avatar
 
Local Time: 13:41
Local Date: October 31, 2010
Join Date: Jan 2002
Location: UK
Posts: 3,272
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.
child of Thor is offline  
Old March 31, 2002, 12:08   #7
Martin Gühmann
staff
Call to Power II Democracy GameCall to Power Democracy GameCTP2 Source Code Project
Super Moderator
 
Martin Gühmann's Avatar
 
Local Time: 15:41
Local Date: October 31, 2010
Join Date: Mar 2001
Location: Tübingen, Germany
Posts: 6,206
Quote:
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.

Quote:
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!"
Martin Gühmann is offline  
Old March 31, 2002, 12:52   #8
child of Thor
Call to Power II Democracy GameCTP2 Source Code Project
Emperor
 
child of Thor's Avatar
 
Local Time: 13:41
Local Date: October 31, 2010
Join Date: Jan 2002
Location: UK
Posts: 3,272
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.
child of Thor is offline  
Old March 31, 2002, 15:00   #9
Martin Gühmann
staff
Call to Power II Democracy GameCall to Power Democracy GameCTP2 Source Code Project
Super Moderator
 
Martin Gühmann's Avatar
 
Local Time: 15:41
Local Date: October 31, 2010
Join Date: Mar 2001
Location: Tübingen, Germany
Posts: 6,206
Quote:
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!"
Martin Gühmann is offline  
Old April 2, 2002, 05:11   #10
child of Thor
Call to Power II Democracy GameCTP2 Source Code Project
Emperor
 
child of Thor's Avatar
 
Local Time: 13:41
Local Date: October 31, 2010
Join Date: Jan 2002
Location: UK
Posts: 3,272
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.
child of Thor is offline  
 

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT -4. The time now is 09:41.


Design by Vjacheslav Trushkin, color scheme by ColorizeIt!.
Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Apolyton Civilization Site | Copyright © The Apolyton Team