Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!tektronix!tekgen!tekred!games-request From: games-request@tekred.TEK.COM Newsgroups: comp.sources.games Subject: v02i058: conquest - middle earth multi-player game, Part01/05 Message-ID: <1741@tekred.TEK.COM> Date: Mon, 26-Oct-87 14:01:49 EST Article-I.D.: tekred.1741 Posted: Mon Oct 26 14:01:49 1987 Date-Received: Wed, 28-Oct-87 06:20:22 EST Sender: billr@tekred.TEK.COM Lines: 1771 Approved: billr@tekred.TEK.COM Submitted by: ihnp4!mhuxd!smile (E.BARLOW) Comp.sources.games: Volume 2, Issue 58 Archive-name: conquest/Part01 [The following is from the author... -br] [[This is the first posting of my multi player game "conquest". CONQUEST is a middle earth multi-player computer game in which each player is the leader of a nation, composed of people (humans, orcs, elves, dwarves), resources, and land. Several neat features are supported, chiefly non player countries and magic powers. The game is somewhat like the game "empire", so I would think that any news articles about it should go to either rec.games.empire or, preferably, rec.games.]] #! /bin/sh # This is a shell archive. Remove anything before this line, then unpack # it by saving it into a file and typing "sh file". To overwrite existing # files, type "sh file -c". You can also feed this as standard input via # unshar, or by typing "sh README <<'END_OF_README' X X NOTES TO INSTALLER OF CONQUEST X XWhat you have here is a copyrighted beta test version of CONQUEST. Included Xin this file are the following: X X 1) A Brief Description of Conquest X 2) Installation (unpacking) Instructions X 3) A Manifest (after you have installed it) X 4) Compilation Instructions X 5) administration instructions X 6) execution instructions (how to play) X 7) a list of further enhancements I am planning on making X 8) Bug list and unimplemented options X XRemember this is an BETA version, not to be redistributed, and Xprobably has bugs. Any comments and bug reports would be appreciated. X X----------------------------------------------------------- XI A Brief Description of Conquest X----------------------------------------------------------- X XREAD FILE .help FOR A DESCRIPTION OF CONQUEST. The help file can be Xread in nice format by using "conquest -h" after compilation. X X----------------------------------------------------------- XII Installation (unpacking) Instructions X----------------------------------------------------------- X XThis program came in three shar scripts, which can be unpacked Xby using "sh filename". If you are reading this, you know this. X X----------------------------------------------------------- XIII A Manifest (after you have unpacked it) of Conquest Files is a follows X /bin/ls -aFC should look like this X----------------------------------------------------------- X XTHE FOLLOWING 2 FILES SHOULD BE MODIFIED TO REFLECT THE TYPE OF GAME YOU WISH X Xheader file: header.h Xmakefile: Makefile X Xsuport files: .nations .help README X XC code: X combat.c forms.c main.c newlogin.c update.c X commands.c io.c makeworld.c npc.c X execute.c magic.c move.c reports.c X X----------------------------------------------------------- XIV Compilation Instructions X----------------------------------------------------------- X XBrowse the file header.h. This sets up configurable parameters for the Xgame. This program should be easy to compile (although it never really is -- XI have tried to make it as easy as possible). If there are problems check Xthe following. X X1. Sometimes termcap/termlib... are not on systems. You will know this X is the error if all the '.c' files compile but will not compile together. X Unreferenced symbol errors will occur. Try changing the name X of the library (or eliminating it on some systems) on the final compile X and link step. X2. Find your nearest unix guru and ask him. X X----------------------------------------------------------- XV administration instructions X----------------------------------------------------------- X XNow that you have compiled it, this is how you administer the game. XI recommend following these instructions once yourself in a mock game X(ie. no other players) for a few turns to get things straight. Then you Xcan add other players. X XYou can type the following commands to help administer the game X XMake clobber: clobber everything but the source (destroys executable) XMake clean: clean up objects (does not destroy executable) XMake install: Installs executable & data in appropriate directories (header.h) XMake docs: Creates documentation from help file X XMake lint: produces lint output for the game. Xrun: read it, it permits you to run the update automatically X XThis is the command line format for conquest: X Cmd line format: conquest [-maxhp] X (no options) play the game X -m make a world (file '.data' must not exist, must be god) X -a add new player (must be god) X -x execute program (must be god) X -h print help text X -p print a map to stdout (must be god) X XAgain, prior to the compile, you should have browsed the header.h file. XFollow the comments. X XThen create the world via: X this will make your world. Try it. X This also sets up npc nations as per the .nations file X npc stats can be adjusted by editing .nations X prior to making the world. Non player nations have X the same password as god. X XAdd 0 or more players via X which should be self explanitory X XNow type and log in as with the appropriate super user Xpassword. X XLearn the commands (Type '?' to get help) & play around to get your Xsyntax right. X XTry logging in as either a player or non player nation (they use the super Xuser passwd) and noticing any differences. X XNow move around on the map and learn where the players are Xpositioned. If there is a problem (they are surrounded by water...), Xuse the redesignate command to change elvation or vegitation. XIn the worst case, god can destroy a nation Xwith 'c', the change nation command. Once you Xthink the game will be fair, it is time to allow players to proceed. X XNow you are all set -- play via X X Xand update (every midnight via at...) with X Xan "at" script to do this is contained in the shell script "run". X XI have attempted to give enough aides to playing that it should Xtake no longer than fifteen minutes per day to play. If it takes Xmore, something is wrong. X X*WARNING* IF YOU REMOVE THE .data FILE, REMEMBER TO ZERO THE .execute Xfile or the world will be screwed up when you recreate it. This will Xcause you to spend hours browsing the source code and result in untold Xfrustration (I speak from experience). X X-------------------------------------------------------------------- XVI a list of further enhancements/bug fixes I am planning on making X-------------------------------------------------------------------- X XTrade is unimplemented XNaval combat and movement has not been system tested XCities do not have garrison armies XOnly one type of soldier and one type of warship allowed XVarious Scoreing techniques are not implemented XCharacter Classes are not fully implemented X X--------------------------------------------------------------------------- XVII The following are future changes to myh magic system (Comments, Ideas?) X--------------------------------------------------------------------------- X X ADDITIONAL (UNIMPLEMENTED) MAGIC POWERS X XWARLOCK Use all level 1 Spells (see separate) XSORCERER Use all level 2 Spells (see separate) XWYZARD Use all level 3 Spells (see separate) XSEA LORD: 2x sea movement/combat, storms not sink ships, (HUMANS ONLY) XESKIMO: Ice sectors = 0 move, have vegitation 9, and give +30% combat XDRUID: Wood/Jungle sectors = 0 move, have vegitation 9, and +30% combat XTYRANT: Costs nothing to enlist and support troops. X X MAGIC ARTIFACTS X X 1)KINGS SWORD (KNOWALL) X 2)LONG SPEAR (CAPTAIN) X 3)SILVER ARMOR (CAPTAIN) X 4)BLACK SHIELD (DEFENDER) X 5)EVIL CLOAK (VOID) X 6)DEMON WAND (MINOR MONSTER) X 7)GREAT HELM (HIDDEN) X 8)DWARVEN PYRAMID (MINER) X 9)BLACK RING (SPY) X 10)SEA FLASK (SEA LORD) X 11)GREAT HAMMER (MINER) X 12)ELVEN BOW (ARCHER) X 13)DEATH SCEPTER (VAMPIRE) X 14)GOLD CROWN (MINOR MONSTER,DESTROYER) X 15)FIRE BOOTS X 16)GREAT THRONE (DESTROYER) X 17)FROST BELT (ICE LORD) X 18)WOOD STAFF (WOOD LORD) X 19)DARK HORN X 20)TREE OF LIFE (URBAN) X X WYZARDRY X XThere are three spell levels: Warlock, Sorcerer, and Wizard. Spells can Ximitate any of the powers listed above, and can do single shot impacts. XSpells are used as follows. First the user is asked what spell they wish Xto use. These spells effect either the nations temporary magic level, or Xspecific areas. X X Jewel pts:level XUse a Magic Item :Free : none X XKill 50% of civilians in non city sector : : XKill all civilians in non city sector : : XKill 50% of civilians in city sector : : XDestroy all civilians in city sector : : XFreeze all movement by 1 npc (AMOVE=0) : : XCurse -- -2 to movement of 1 PC nations armies : : XCurse -- -2 to movement of 1 NPC nations armies : : Xfriendly (+1) with 1 npc nation : : XBuild 1 point of fort walls : : XSummon dead army (VAMPIRE ONLY, 500 men) : : XSummon dead legion (VAMPIRE ONLY, 1500 men) : : XFriendship (+2) with 1 npc nation : : XAnimosity (-1) between 2 other nations : : XHatred (-2) between 2 other nations : : XWarm Permanently (+1 vegitation to sector) : : XFreeze Permanently (-1 vegitation to sector) : : XBreech forts walls : : XTakeover NPC Nation Of Same Race : : XTeleport one army (up to 100 men) : : XTeleport one army (up to 1000 men) : : XTeleport one army (any # men) : : XTransmute iron to jewels : : XCloak activity : : XCause fear (1 oposing army to home capitol) : : END_OF_README if test 8579 -ne `wc -c MANIFEST <<'END_OF_MANIFEST' X File Name Archive # Description X----------------------------------------------------------- X .help 4 X .nations 5 X DIST-NOTE 5 X MANIFEST 1 This shipping list X Makefile 4 X README 1 X combat.c 2 X commands.c 3 X execute.c 4 X forms.c 5 X header.h 5 X io.c 5 X magic.c 2 X main.c 3 X makeworld.c 1 X move.c 4 X newlogin.c 2 X npc.c 1 X reports.c 3 X run 3 X update.c 4 END_OF_MANIFEST if test 744 -ne `wc -c makeworld.c <<'END_OF_makeworld.c' X/*conquest is copyrighted 1986 by Ed Barlow. X * I spent a long time writing this code & I hope that you respect this. X * I give permission to alter the code, but not to copy or redistribute X * it without my explicit permission. If you alter the code, X * please document changes and send me a copy, so all can have it. X * This code, to the best of my knowledge works well, but it is my first X * 'C' program and should be treated as such. I disclaim any X * responsibility for the codes actions (use at your own risk). I guess X * I am saying "Happy gaming", and am trying not to get sued in the process. X * Ed X */ X X/*Create a world*/ X X/*DEFINE TEMPORARY VARIABLES FROM MAKEFILE*/ X#include X#include X#include "header.h" X X#define HALF 2 X#define LAND 3 X Xextern short country; Xint area_map[MAXX][MAXY];/*Value Map of Areas*/ Xint type[MAPX][MAPY]; X Xmakeworld() X{ X register int i,j; X register int x,y; X int n; /*count used in string searches*/ X float avvalue; /*Average water tvalue of sectors*/ X int number[5]; /*Number of sectors with type=[0-4]*/ X char passwd[12]; X int alloc = NUMAREAS * 2;/*Value Allocated*/ X int place[MAXX][MAXY] ;/*Temporary matrix to see if an area is placed*/ X int X, Y; X int X1,Y1; X int X2,Y2; X int valid; X int nranges; X int rnd; X int tempfd; X X /*abort if DATAFILE currently exists*/ X if(tempfd=open(DATAFILE,0)!=-1) { X printf("ABORTING: File %s exists-->a game is in progress\n",DATAFILE); X printf("to proceed, you must remove the existing game\n"); X printf("file. This will, of course, destroy that game\n"); X printf("\nIf you do remove that file, be aware that you need"); X printf("\nto also zero the .execute file"); X exit(1); X } X X printf("please enter new super user password (remember this!):"); X scanf("%s",passwd); X getchar(); X printf("\nplease reenter password:"); X scanf("%s",ntn[0].passwd); X getchar(); X if((strlen(ntn[0].passwd)<2)||(strncmp(passwd,ntn[0].passwd,PASSLTH)!=0)) { X printf("\ninvalid super user password\n"); X exit(1); X } X else printf("super user password is %s\n",ntn[0].passwd); X strncpy(ntn[0].passwd,crypt(passwd,SALT),PASSLTH); X X printf("\nThe world will now be created...Your super user login"); X printf("\nwill be 'god'. All non player countries that were"); X printf("\ncreated when the world was created from the file .nations"); X printf("\nwill have the same password as the one you just entered"); X printf("\nto add player nations, use "); X printf("\nhave fun"); X X printf("\n\ncreating world\n"); X /*initialize variables */ X avvalue = (((float) PWATER/25.0)); /*Average water tvalue of sectors*/ X for(i=0;ialloc) { X /*have not allocated high enough so Allocate more */ X x = rand()%4; /*0 to 3*/ X if(number[x]>0) { X number[x] = number[x] - 1; X number[x+1] = number[x+1] + 1; X alloc = alloc + 1; X } X } X else { X /*have allocated too much Allocate less */ X x = (rand()%4) +1; /*1 to 4*/ X if(number[x]>0) { X number[x] = number[x] - 1; X number[x-1] = number[x-1] + 1; X alloc = alloc - 1; X } X } X } X X i=0; X while((number[4]>0)&&(i<500)) { X i++; X /*place a full land sector anywhere but on edge*/ X X = ((rand()%(MAXX-2))+1); /*1 to MAXX-2)*/ X Y = ((rand()%(MAXY-2))+1); /*1 to MAXY-2)*/ X if(place[X][Y] == 0) { X place[X][Y]=1; X area_map[X][Y]=4; X number[4]=number[4] - 1; X /*place surrounding sectors*/ X if(place[X+1][Y] == 0) { X rnd = rand()%100 + 1; /*1 to 100*/ X if((rnd<25) && (number[4]>0)) { X area_map[X+1][Y]=4; X number[4]=number[4]-1; X place[X+1][Y]=1; X } X if(rnd>25 && number[3]>0) { X area_map[X+1][Y]=3; X number[3]=number[3]-1; X place[X+1][Y]=1; X } X } X if(place[X-1][Y] == 0) { X rnd = rand()%100 + 1 ; /*(1 to 100)*/ X if(rnd<25 && number[4]>0) { X area_map[X-1][Y]=4; X number[4]=number[4]-1; X place[X-1][Y]=1; X } X if(rnd>25 && number[3]>0) { X area_map[X-1][Y]=3; X number[3]=number[3]-1; X place[X-1][Y]=1; X } X } X if(place[X][Y+1] == 0) { X rnd = rand()%100 + 1 ; /*(1 to 100)*/ X if(rnd<25 && number[4]>0) { X area_map[X][Y+1]=4; X number[4]=number[4]-1; X place[X][Y+1]=1; X } X if(rnd>25 && number[3]>0) { X area_map[X][Y+1]=3; X number[3]=number[3]-1; X place[X][Y+1]=1; X } X } X if(place[X][Y-1] == 0) { X rnd = rand()%100 + 1 ; /*(1 to 100)*/ X if(rnd<25 && number[4]>0) { X area_map[X][Y-1]=4; X number[4]=number[4]-1; X place[X][Y-1]=1; X } X if(rnd>25 && number[3]>0) { X area_map[X][Y-1]=3; X number[3]=number[3]-1; X place[X][Y-1]=1; X } X } X } X } X X /* place all other areas*/ X for(X=0;X0) { X area_map[X][Y]=rnd; X number[rnd]=number[rnd]-1; X place[X][Y]=1; X } X } X } X X /*ALL AREAS PLACED, NOW DETERMINE SECTOR TYPE X *fill in each area with sectors X * 1) water X * 2) water with major islands (25% land) X * 3) 50/50 water/land X * 4) land with major water (75% Land) X * 5) land X */ X for(Y=0;Y0) { X /*Place one range randomly*/ X X1 = rand()%(MAPX-6); X Y1 = rand()%(MAPY-6); X if((type[X1][Y1]==LAND)&&(type[X1+1][Y1+1]==LAND)&&(type[X1+1][Y1]==LAND)&&(type[X1][Y1+1]==LAND)&&(type[X1+2][Y1+2]==LAND)) { X /*place second endpoint */ X valid = 0; X i=0; X nranges--; X while((valid==0) && (i<500)) { X i++; X X2 = (rand()%7) + X1; X Y2 = (rand()%7) + Y1; X if(type[X2][Y2] == LAND) { X valid = 1; X /*fill in mountain range*/ X for(x=X1;x<=X2;x++) { X if(X180) sct[x][y].altitude=PEAK; X else sct[x][y].altitude=MOUNTAIN; X if(type[x][y+1] == LAND) { X rnd=rand()%100+1; X if(rnd>90) sct[x][y+1].altitude=PEAK; X else if(rnd>50) sct[x][y+1].altitude=MOUNTAIN; X else if(rnd>20) sct[x][y+1].altitude=HILL; X } X if(type[x][y-1] == LAND ) { X rnd=rand()%100+1; X if(rnd>90) sct[x][y-1].altitude=PEAK; X else if(rnd>50) sct[x][y-1].altitude=MOUNTAIN; X else if(rnd>20) sct[x][y-1].altitude=HILL; X } X if(type[x][y-2] == LAND ) { X rnd=rand()%100+1; X if(rnd>90) sct[x][y-2].altitude=MOUNTAIN; X else if(rnd>50) sct[x][y-2].altitude=HILL; X } X if(type[x][y+2] == LAND ) { X rnd=rand()%100+1; X if(rnd>90) sct[x][y+2].altitude=MOUNTAIN; X else if(rnd>50) sct[x][y+2].altitude=HILL; X } X } X } X } X } X } X X /*fill in random hills to work out,not to left of to water*/ X for(i=1;iMAPY/2+8)||(yMAPY/2+8)||(y 6) for(i=0;i<8;i++) type[X0*8+i][Y0*8+7] = LAND; X else if((area + edgearea)>3) { X for(i=0;i<8;i++) X if(rand()%2 == 0) type[(X0*8)+i][Y0*8+7] = LAND; X else type[(X0*8)+i][Y0*8+7] = WATER; X } X else for(i=0;i<8;i++) type[(X0*8)+i][Y0*8+7] = WATER; X /*fill in east*/ X edgearea=area_map[X2][Y2]; X if(area + edgearea > 6) for(i=0;i<8;i++) type[X0*8+7][Y0*8+i] = LAND; X else if((area + edgearea)>3) { X for(i=0;i<8;i++) X if(rand()%2==0) type[X0*8+7][Y0*8+i] = LAND; X else type[X0*8+7][Y0*8+i] = WATER; X } X else for(i=0;i<8;i++) type[X0*8+7][Y0*8+i] = WATER; X /*fill in west*/ X edgearea=area_map[X1][Y1]; X if(area + edgearea > 6) for(i=0;i<=7;i++) type[X0*8][Y0*8+i] = LAND; X else if((area + edgearea)>3) { X for(i=0;i<8 ;i++) X if(rand()%2==0) type[X0*8][Y0*8+i] = LAND; X else type[X0*8][Y0*8+i] = WATER; X } X else for(i=0;i<8 ;i++) type[X0*8][Y0*8+i] = WATER; X /*fill in north*/ X edgearea=area_map[X3][Y3]; X if(area + edgearea > 6) for(i=0;i<8 ;i++) type[X0*8+i][Y0*8] = LAND; X else if((area + edgearea)>3) { X for(i=0;i<8 ;i++) X if(rand()%2==0) type[(X0*8)+i][Y0*8] = LAND; X else type[(X0*8)+i][Y0*8] = WATER; X } X else for(i=0;i<8 ;i++) type[(X0*8)+i][Y0*8] = WATER; X} X X/* ALLOCATE POPULATIONS OF THE WORLD*/ Xpopulate() X{ X int i=0,x=0,y=0,j=0; X int nvynum=0,army2num=0,armynum=0; X int temp; X int cnum=0; X FILE *fp, *fopen(); X int done=0; X char line[80]; X X X /*randomly scatter lizard city (want in DESERTS/swamp/Ice) */ X /*don't reproduce or move. Their cities are fortified and stockpiled */ X#ifdef LZARD X strncpy(ntn[NLIZARD].name,"lizard",10); X strncpy(ntn[NLIZARD].leader,"dragon",10); X strcpy(ntn[NLIZARD].passwd,ntn[0].passwd); X ntn[NLIZARD].race=LIZARD; X ntn[NLIZARD].mark='*'; X ntn[NLIZARD].active=2; X ntn[NLIZARD].aplus=0; X ntn[NLIZARD].dplus=0; X ntn[NLIZARD].maxmove=0; X ntn[NLIZARD].repro=0; X ntn[NLIZARD].powers=KNOWALL; X for(i=0;i=0&&j>=0&&inpc.c <<'END_OF_npc.c' X/*conquest is copyrighted 1986 by Ed Barlow. X * I spent a long time writing this code & I hope that you respect this. X * I give permission to alter the code, but not to copy or redistribute X * it without my explicit permission. If you alter the code, X * please document changes and send me a copy, so all can have it. X * This code, to the best of my knowledge works well, but it is my first X * 'C' program and should be treated as such. I disclaim any X * responsibility for the codes actions (use at your own risk). I guess X * I am saying "Happy gaming", and am trying not to get sued in the process. X * Ed X */ X X#include "header.h" X#include X Xextern FILE *fnews; X Xextern short country; Xextern int attr[MAPX][MAPY]; /*sector attactiveness*/ Xextern short occ[MAPX][MAPY]; Xextern short movecost[MAPX][MAPY]; Xint peace; /*is 8 if at peace, 12 if at war*/ X X#ifdef NPC Xnationrun() X{ X int loop,armynum; X int x,y,i,z; X X prep(); X X /* is there an error*/ X if((sct[ntn[country].capx][ntn[country].capy].owner==country)&&(sct[ntn[country].capx][ntn[country].capy].designation!=DCAPITOL)){ X sct[ntn[country].capx][ntn[country].capy].designation=DCAPITOL; X } X X /*go to war*/ X for(x=1;x=WAR) { X ntn[country].dstatus[x]=WAR; X } X /*else adjust diplomacy*/ X else if((ntn[country].dstatus[x]!=UNMET)&&(ntn[country].dstatus[x]!=JIHAD)&&(ntn[country].dstatus[x]!=CONFEDERACY)){ X if((ntn[x].tmil>4*ntn[country].tmil)&&(ntn[x].score>4*ntn[country].score)){ X if(rand()%3==0) ntn[country].dstatus[x]=WAR; X else if(rand()%8==0) X ntn[country].dstatus[x]=JIHAD; X else ntn[country].dstatus[x]++; X } X /*if 2* mil and 2* score then not like them*/ X else if((ntn[x].tmil>2*ntn[country].tmil)&&(ntn[x].score>2*ntn[country].score)){ X if(ntn[country].dstatus[x]!=WAR) X if(ntn[x].race==ntn[country].race){ X if(rand()%10==0) ntn[country].dstatus[x]++; X } X else if(rand()%3==0) ntn[country].dstatus[x]++; X } X /*adjust based on your status with them*/ X if(ntn[country].dstatus[x]!=WAR){ X if(ntn[x].dstatus[country]>ntn[country].dstatus[x]){ X if(rand()%3==0) X ntn[country].dstatus[x]++; X } X else X if(ntn[x].dstatus[country]=2) takeover(1,x); X } X } X X /*move units */ X /*are they at war with any normal countries*/ X peace=0; X for(i=1;ipeace) X peace=ntn[country].dstatus[i]; X X if(peaceHOSTILE){ X if(100*(ntn[country].tmil*(ntn[country].aplus+100))/((ntn[country].tmil*(ntn[country].aplus+100))+(ntn[x].tmil*(ntn[x].dplus+100)))>rand()%100){ X /*attacker*/ X for(armynum=1;armynum0)&&(ASTAT!=GARRISON)) ASTAT=ATTACK; X atkattr(); X } X /*defender*/ X else { X for(armynum=1;armynum0)&&(ASTAT!=GARRISON)){ X if(ASOLD<350) ASTAT=DEFEND; X else ASTAT=ATTACK; X } X defattr(); X } X } X X for(armynum=1;armynum 2* JWL_MGK) { X loop=0; X for(armynum==0;armynum<=MAXPOWER;armynum++){ X if(magic(country,armynum)==1) i++; X } X /*maximum of nine powers for NPC nations*/ X if(i>NPCPOWERS) loop=1; X while(loop==0){ X if((z=getmagic())!=1){ X fprintf(fnews,"2.\tnation %s gets magic power number %d\n",ntn[country].name,z); X exenewmgk(z); X ntn[country].jewels-=JWL_MGK; X loop=1; X } X } X X } X if(ntn[country].tiron > 4 * IRONORE * ntn[country].tmil){ X ntn[country].aplus+=1; X ntn[country].dplus+=1; X ntn[country].tgold-=2*IRONORE * ntn[country].tmil; X } X} X X/*calculate attractiveness when at peace*/ Xpceattr() X{ X int x,y,temp; X /*add around capital*/ X for(x=ntn[country].capx-2;x<=ntn[country].capx+2;x++) X for(y=ntn[country].capy-2;y<=ntn[country].capy+2;y++) X if(sct[x][y].owner==0) attr[x][y]+=80; X /*add to attractiveness for unowned sectors*/ X for(x=0;xntn[country].capx) temp+=x-ntn[country].capx; X else temp+=ntn[country].capx-x; X if(y>ntn[country].capy) temp+=y-ntn[country].capy; X else temp+=ntn[country].capy-y; X if(temp<3) attr[x][y]+=300-(50*temp); X else if(temp<20) attr[x][y]+=100; X } X else if((sct[x][y].owner==NNOMAD)||(sct[x][y].owner==NBARBARIAN)||(sct[x][y].owner==NPIRATE)) attr[x][y]+=100; X if(sct[ntn[country].capy][ntn[country].capy].owner!=country){ X attr[ntn[country].capy][ntn[country].capy]=1000; X } X} X X/*calculate attractiveness of attacking sectors*/ Xatkattr() X{ X int nation,armie,x,y,x1,x2,Y1,y2; X X for(x=ntn[country].capx-2;x<=ntn[country].capx+2;x++) X for(y=ntn[country].capy-2;y<=ntn[country].capy+2;y++) X if(sct[x][y].owner==0) attr[x][y]+=80; X X for(x=0;x=WAR)&&(ntn[country].active!=0)){ X X /*plus 1/2 men if in sector with their army*/ X /*defend your capital if occupied, +50 more if with their army*/ X for(armie=1;armie 0) { X X attr[ntn[nation].arm[armie].xloc][ntn[nation].arm[armie].yloc]+=ntn[nation].arm[armie].sold%10; X X if((ntn[nation].arm[armie].xloc<=ntn[country].capx+2)&&(ntn[nation].arm[armie].yloc<=ntn[country].capy+2)&&(ntn[nation].arm[armie].xloc>=ntn[country].capx-2)&&(ntn[nation].arm[armie].yloc>=ntn[country].capy-2)){ X attr[ntn[nation].arm[armie].xloc][ntn[nation].arm[armie].yloc]+=ntn[nation].arm[armie].sold%5; X if((rand()%3==0)&&(ntn[country].dstatus[nation]2*ntn[country].arm[0].sold){ X attr[ntn[nation].arm[armie].xloc][ntn[nation].arm[armie].yloc]+=ntn[nation].arm[armie].sold%2; X } X else attr[ntn[nation].arm[armie].xloc][ntn[nation].arm[armie].yloc]+=ntn[nation].arm[armie].sold%5; X } X } X } X } X X /*plus 40 if next to their capital */ X for(x=ntn[nation].capx-1;x<=ntn[nation].capy+1;x++){ X for(y=ntn[nation].capy-1;y<=ntn[nation].capy+1;y++){ X if((x>0)&&(x0)&&(y0)&&(x0)&&(y=WAR)) { X X /*plus if near enemy army*/ X /*plus 30 if next to their army*/ X /*plus 60 if with their army*/ X for(armie=1;armie 0) { X X attr[ntn[nation].arm[armie].xloc][ntn[nation].arm[armie].yloc]+=ntn[nation].arm[armie].sold%10; X X if((ntn[nation].arm[armie].xloc<=ntn[country].capx+2)&&(ntn[nation].arm[armie].yloc<=ntn[country].capy+2)&&(ntn[nation].arm[armie].xloc>=ntn[country].capx-2)&&(ntn[nation].arm[armie].yloc>=ntn[country].capy-2)){ X attr[ntn[nation].arm[armie].xloc][ntn[nation].arm[armie].yloc]+=ntn[nation].arm[armie].sold%5; X if((rand()%3==0)&&(ntn[country].dstatus[nation]2*ntn[country].arm[0].sold){ X attr[ntn[nation].arm[armie].xloc][ntn[nation].arm[armie].yloc]+=ntn[nation].arm[armie].sold%2; X } X else attr[ntn[nation].arm[armie].xloc][ntn[nation].arm[armie].yloc]+=ntn[nation].arm[armie].sold%5; X } X } X } X X X /*plus if strategic blocking sector*/ X /*+60 if between the two capitals*/ X if (ntn[nation].capx < ntn[country].capx){ X x1=ntn[nation].capx; X x2=ntn[country].capx; X } X else { X x1=ntn[country].capx; X x2=ntn[nation].capx; X } X if (ntn[nation].capy < ntn[country].capy){ X y1=ntn[nation].capy; X y2=ntn[country].capy; X } X else { X y1=ntn[country].capy; X y2=ntn[nation].capy; X } X X for(x=x1;x<=x2;x++) for(y=y1;y<=y2;y++) { X if((x>0)&&(x0)&&(y0)&&(x0)&&(y0) { X if(ntn[sct[AXLOC][AYLOC].owner].race==ntn[country].race) X sct[AXLOC][AYLOC].people+=ASOLD; X ASOLD=0; X } X for(nvynum=0;nvynum0) ntn[sct[ntn[country].capx][ntn[country].capy].owner].tgold+=ntn[country].tgold; X if(ntn[country].jewels>0) ntn[sct[ntn[country].capx][ntn[country].capy].owner].jewels+=ntn[country].jewels; X if(ntn[country].tiron>0) ntn[sct[ntn[country].capx][ntn[country].capy].owner].tiron+=ntn[country].tiron; X if(ntn[country].tfood>0) ntn[sct[ntn[country].capx][ntn[country].capy].owner].tfood+=ntn[country].tfood; X } X X /*if god destroys then kill all population*/ X if(country==sct[ntn[country].capx][ntn[country].capy].owner){ X for(x=0;x0){ X x=AXLOC+rand()%4-2; X y=AYLOC+rand()%4-2; X if((x>0)&&(x0)&&(y0)) done=1; X X /*nomads take sector if done=0*/ X if(done==0){ X if(sct[x][y].owner==0) X fprintf(fnews,"3.\tnomads take sector %d,%d\n",x,y); X else fprintf(fnews,"3.\tnomads capture sector %d,%d\n",x,y); X if(sct[x][y].owner!=0) flee(x,y,1); X sct[x][y].owner=NNOMAD; X sct[x][y].designation=DDEVASTATED; X } X } X } X else { X /*place a new Nomad army*/ X x=(rand()%MAPX-8)+4; X y=(rand()%MAPY-8)+4; X if((rand()%4==0)&&(sct[x][y].altitude!=PEAK)&&(sct[x][y].altitude!=WATER)) { X AXLOC=x; X AYLOC=y; X ASOLD=100+100*rand()%10; X ASTAT=ATTACK; X } X } X fprintf(fnews,"2.\t%s are updated\n",ntn[NPIRATE].name); X /*if pirate fleet within 3 attack if outnumber any fleets */ X for(nvynum=0;nvynum(-2))&& X (ntn[x].nvy[y].yloc-NYLOC<2)&&(ntn[x].nvy[y].yloc-NYLOC>(-2))&& X (sct[ntn[x].nvy[y].xloc][ntn[x].nvy[y].yloc].altitude==WATER)){ X NXLOC= ntn[x].nvy[y].xloc; X NYLOC= ntn[x].nvy[y].yloc; X } X /*add one warship to random pirate fleet*/ X if((NWAR>0)&&(rand()%3==0)) NWAR++; X } X} X Xnpcredes(x,y) X{ X int food; X /*large enough for a city now?*/ X if(((sct[x][y].people*(CITYLIMIT+(ntn[sct[x][y].owner].tsctrs/3))>ntn[sct[x][y].owner].tciv)||((ntn[sct[x][y].owner].tciv<30000)&&(sct[x][y].people>1000)))&&(ntn[sct[x][y].owner].tfood>ntn[sct[x][y].owner].tciv*2)){ X if((rand()%2==0)&&((sct[x][y].designation==DFARM)||(sct[x][y].designation==DGOLDMINE)||(sct[x][y].designation==DMINE))) X sct[x][y].designation=DCITY; X } X /*not large enough for city and not enough food*/ X else if((sct[x][y].designation==DCITY)&&(ntn[sct[x][y].owner].tfood5)){ X sct[x][y].designation=DFARM; X food=todigit(sct[x][y].vegitation)*sct[x][y].people; X ntn[sct[x][y].owner].tfood += food; X ntn[sct[x][y].owner].tgold += food*TAXFOOD/100-(sct[x][y].people * TAXCITY/100); X } X /*not large enough for a city but enough food*/ X else if((sct[x][y].designation==DCITY)&&(rand()%5==0)){ X sct[x][y].designation=DFARM; X food=todigit(sct[x][y].vegitation)*sct[x][y].people; X ntn[sct[x][y].owner].tfood += food; X ntn[sct[x][y].owner].tgold += food*TAXFOOD/100-(sct[x][y].people * TAXCITY/100); X } X X /*what if it is not a city*/ X if((sct[x][y].designation!=DCITY)&&(sct[x][y].designation!=DCAPITOL)) { X sct[x][y].designation=DFARM; X /*crisis situation -- need more food producers*/ X if(ntn[sct[x][y].owner].tfood<=2*ntn[sct[x][y].owner].tciv){ X if(sct[x][y].iron>5) X sct[x][y].designation=DMINE; X if((sct[x][y].gold>5)&&(sct[x][y].gold>sct[x][y].iron-2)) X sct[x][y].designation=DGOLDMINE; X } X /*non crisis situation -- need more food producers*/ X else { X if(sct[x][y].iron>2) X sct[x][y].designation=DMINE; X if((sct[x][y].gold>2)&&(sct[x][y].gold>sct[x][y].iron-2)) X sct[x][y].designation=DGOLDMINE; X } X } X} X Xredomil() X{ X short x,y,armynum; X int diff, i, free, done; X X /*make sure enough men in army 0 -- garrison duty in capital*/ X armynum=0; X ASTAT=GARRISON; X AXLOC=ntn[country].capx; X AYLOC=ntn[country].capy; X X /*Ideally ASOLD(0)*MILINCAP=tmil*peace/10*/ X /*MILRATIO ratio mil:civ for non player countries*/ X /*MILINCAP ratio (mil in cap):mil for NPCs*/ X if(ASOLD*MILINCAP<.9*ntn[country].tmil*peace/10){ X /*too few soldiers on garrison*/ X /*diff is number to change mil in cap (>0)*/ X diff=(ntn[country].tmil*peace/(10*MILINCAP))-ASOLD; X X if(diffsct[ntn[country].capx][ntn[country].capy].people) X diff=sct[ntn[country].capx][ntn[country].capy].people/2; X X sct[ntn[country].capx][ntn[country].capy].people-=diff; X ASOLD+=diff; X ntn[country].tciv-=diff; X ntn[country].tmil+=diff; X ntn[country].tgold-=diff*ENLISTCOST; X ntn[country].tiron-=diff*10; X } X /*else split garrison army if 1.25* needed number*/ X else if(ASOLD*MILINCAP>1.1*ntn[country].tmil*peace/10){ X diff=ASOLD-(1.25*ntn[country].tmil*peace/(10*MILINCAP)); X free=0; X ASOLD-=diff; X ntn[country].tciv-=diff; X ntn[country].tmil+=diff; X sct[ntn[country].capx][ntn[country].capy].people+=diff; X } X X /*build ships and/or armies*/ X done=0; X /*if tmil*MILRATIO0L)) for(armynum=1;armynumntn[country].tiron*10) ASOLD= ntn[country].tiron/10; X if(2*ASOLD>sct[ntn[country].capx][ntn[country].capy].people) X ASOLD=sct[ntn[country].capx][ntn[country].capy].people/2; X ntn[country].tiron-=ASOLD*10; X AXLOC= ntn[country].capx; X AYLOC= ntn[country].capy; X ntn[country].tmil += ASOLD; X ntn[country].tciv -= ASOLD; X ntn[country].tgold-=ASOLD*ENLISTCOST; X sct[AXLOC][AYLOC].people-=ASOLD; X ASTAT= DEFEND; X AMOVE=0; X } X X /*disband ships and/or armies*/ X if(ntn[country].tmil*MILRATIO>1.2*ntn[country].tciv*peace/10){ X /*disband a pseudo-random army*/ X done=0; X diff=ntn[country].tmil-(1.2*ntn[country].tciv*peace/(10*MILRATIO)); X for(armynum=1;armynum5)||(sct[AXLOC][AYLOC].iron>5))&&(rand()%5==0)&&(ASOLD1.2*ntn[country].tciv*peace/10) done=1; X } X } X X /*resize armies */ X /*maximum npc army is 200 or tmil/20, minimum is 50*/ X for(armynum=1;armynum200)&&(ASOLD>ntn[country].tmil/20)) { X free=0; X for(i=1;i0)&&(ntn[country].arm[i].xloc==AXLOC)&&(ntn[country].arm[i].yloc==AYLOC)&&(i!=armynum)&&(free==0)){ X free=1; X ntn[country].arm[i].sold += ASOLD; X ASOLD=0; X } X } X } X } X X for(x=0;x0){ X armynum=free; X AXLOC=x; X AYLOC=y; X } X } X } X} END_OF_npc.c if test 22830 -ne `wc -c