billr@saab.CNA.TEK.COM (Bill Randle) (06/24/89)
Submitted-by: adb@bu-it.bu.edu (Adam Bryant) Posting-number: Volume 6, Issue 87 Archive-name: conquer4/Part05 Superseeds: conquer3; Volume 4, Issue 42-49 #! /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 <file", e.g.. If this archive is complete, you # will see the following message at the end: # "End of archive 5 (of 14)." # Contents: npc.c txt1 # Wrapped by billr@saab on Thu Jun 15 15:20:13 1989 PATH=/bin:/usr/bin:/usr/ucb ; export PATH if test -f 'npc.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'npc.c'\" else echo shar: Extracting \"'npc.c'\" \(38437 characters\) sed "s/^X//" >'npc.c' <<'END_OF_FILE' X/*conquer : Copyright (c) 1988 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 "data.h" X#include <ctype.h> X Xextern FILE *fnews; X Xint stx, sty, endx, endy; /* npc range of operations */ Xextern short country; Xextern int **attr; /*sector attactiveness*/ Xextern int dissarray; /* has nation lost its leader */ Xint peace; /*is 8 if at peace, 12 if at war*/ X Xvoid Xprtattr() X{ X#ifdef DEBUG X int x,y; X/* FOR TESTING OF WHAT THE ATTRACTIVENESS ENDS UP LIKE */ X printf("Attractiveness for sectors around CAPITAL at %d %d veg alt des\n",curntn->capx,curntn->capy); X for(y=curntn->capy-3;y<curntn->capy+4;y++) { X printf("\n"); X for(x=curntn->capx-3;x<curntn->capx+4;x++) if(ONMAP(x,y)) { X if( sct[x][y].altitude != WATER ) { X printf("[%2d,%2d] ",x,y); X } X } X printf("\n"); X for(x=curntn->capx-3;x<curntn->capx+4;x++) if(ONMAP(x,y)) { X if( sct[x][y].altitude != WATER ) { X printf("%5d %c%c%c " X ,attr[x][y] X ,sct[x][y].vegetation X ,sct[x][y].altitude X ,sct[x][y].designation); X } else printf("0 ~ "); X } X printf("\n"); X } X#endif DEBUG X} X X/*newdip() diplomacy if unmet - ntn 1 is nation you are updating*/ Xvoid Xnewdip(ntn1,ntn2) Xint ntn1,ntn2; X{ X if( ispc( ntn[ntn1].active ) ) { X if( ntn[ntn2].race==ORC ) X ntn[ntn1].dstatus[ntn2]=HOSTILE; X else ntn[ntn1].dstatus[ntn2]=NEUTRAL; X return; X } X if((ntn[ntn1].race==ORC) X ||( ntn[ntn2].race==ORC)) { X if(ntn[ntn1].dstatus[ntn2]==UNMET) X if((rand()%2==0)|| ispc(ntn[ntn1].active)) X ntn[ntn1].dstatus[ntn2]=HOSTILE; X else X ntn[ntn1].dstatus[ntn2]=WAR; X } else if(ismonst(ntn[ntn2].active)) { X ntn[ntn1].dstatus[ntn2]=WAR; X } else if(ispc(ntn[ntn1].active)) { X if(ntn[ntn1].dstatus[ntn2]==UNMET) X ntn[ntn1].dstatus[ntn2]=NEUTRAL; X } else if(ntn[ntn1].race==ntn[ntn2].race){ X if(rand()%2<1) ntn[ntn1].dstatus[ntn2]=FRIENDLY; X else ntn[ntn1].dstatus[ntn2]=NEUTRAL; X } else ntn[ntn1].dstatus[ntn2]=NEUTRAL; X} X X#ifdef MONSTER Xvoid Xmonster() X{ X for(country=1;country<NTOTAL;country++) { X curntn = &ntn[country]; X if( curntn->active==NPC_NOMAD ) do_nomad(); X else if( curntn->active==NPC_PIRATE ) do_pirate(); X else if( curntn->active==NPC_BARBARIAN ) do_barbarian(); X else if( curntn->active==NPC_LIZARD ) do_lizard(); X } X} X Xvoid Xdo_nomad() X{ X int count; X short armynum; X int x, y; X X /*move nomads */ X printf("updating nomad nation %d\n",country); X for(armynum=0;armynum<MAXARM;armynum++) if(P_ASOLD>0){ X P_ASTAT=ATTACK; X P_AMOVE=(curntn->maxmove * *(unitmove+P_ATYPE%UTYPE))/10; X if(P_ATYPE<MINLEADER) { X P_ASOLD *= 102; X P_ASOLD /= 100; X } X count=0; X while( TRUE ) { X x=P_AXLOC+rand()%5-2; X y=P_AYLOC+rand()%5-2; X X if( count++ > 100 ) { X P_ASOLD=0; X break; X } X /* nomads cant stay in the same spot */ X if(( x==P_AXLOC && y==P_AYLOC ) X ||(!ONMAP(x,y) X ||(!is_habitable(x,y))) X ||(!land_reachp(P_AXLOC,P_AYLOC,x,y,curntn->maxmove,country))) continue; X X P_AXLOC=x; X P_AYLOC=y; X /*if owned & unoccupied you take & people flee*/ X if( ((sct[x][y].owner) == 0 X || solds_in_sector( x, y, sct[x][y].owner) == 0 ) X && (ntn[sct[x][y].owner].active!=NPC_NOMAD) ) { X fprintf(fnews,"3.\tnomads capture sector %d,%d\n",x,y); X if(sct[x][y].owner!=0) flee(x,y,1,FALSE); X sct[x][y].owner=country; X DEVASTATE(x,y); X } X break; X } X } X /* place a few new Nomad armies */ X for(armynum=0;armynum<MAXARM;armynum++) if(P_ASOLD<=0){ X if(rand()%4!=0) continue; X x=(rand()%(MAPX-8))+4; X y=(rand()%(MAPY-8))+4; X if(is_habitable(x,y)) { X P_AXLOC=x; X P_AYLOC=y; X P_ASOLD=100+100*(rand()%6); X P_ATYPE=A_LT_CAV; X P_ASTAT=ATTACK; X } X } X} X Xvoid Xdo_barbarian() X{ X short armynum; X int x, y; X X printf("updating barbarian nation %d\n",country); X for(armynum=0;armynum<MAXARM;armynum++) if(P_ASOLD>0){ X P_ASTAT=ATTACK; X if(P_ATYPE<MINLEADER) { X P_ASOLD *= 102; X P_ASOLD /= 100; X } X P_AMOVE=(curntn->maxmove * *(unitmove+P_ATYPE%UTYPE))/10; X x=P_AXLOC+rand()%2-1; X y=P_AYLOC+rand()%2-1; X if(ONMAP(x,y)&&(is_habitable(x,y)) X &&(land_reachp(P_AXLOC,P_AYLOC,x,y,P_AMOVE,country))){ X P_AXLOC=x; X P_AYLOC=y; X /*if owned & unoccupied you take & people flee*/ X if( ((sct[x][y].owner == 0) X || (solds_in_sector( x, y, sct[x][y].owner) == 0)) X && (ntn[sct[x][y].owner].active != NPC_BARBARIAN)) { X fprintf(fnews,"3.\tbarbarians capture sector %d,%d\n",x,y); X if(P_ATYPE<MINLEADER) { X if(sct[x][y].owner!=0) flee(x,y,1,FALSE); X sct[x][y].owner=country; X } X DEVASTATE(x,y); X } X } X } X /* place a few new Barbarian armies */ X for(armynum=0;armynum<MAXARM;armynum++) if(P_ASOLD<=0){ X x=(rand()%(MAPX-8))+4; X y=(rand()%(MAPY-8))+4; X if((rand()%4!=0) X ||( sct[x][y].altitude == PEAK) X ||( sct[x][y].altitude == WATER)) X continue; X if(sct[x][y].owner==0 || sct[x][y].owner==country X ||(sct[x][y].people< 50)) { X P_AXLOC=x; X P_AYLOC=y; X P_ASOLD=100+100*(rand()%3); X P_ATYPE=defaultunit(country); X P_ASTAT=ATTACK; X } X } X} X Xvoid Xdo_lizard() X{ X short armynum; X X printf("updating lizard nation %d\n",country); X for(armynum=0;armynum<MAXARM;armynum++) if(P_ASOLD>0){ X P_ASOLD*=102; X P_ASOLD/=100; X } X} X Xvoid Xdo_pirate() X{ X short nvynum,shipsize; X int x, y, campx, campy; X X printf("updating pirate nation %d\n",country); X X /* if pirate fleet within 3 attack if outnumber any fleets */ X /* automatically find their base first */ X for(nvynum=0;nvynum<MAXNAVY;nvynum++) if(P_NWSHP!=0) { X int temp=TRUE; X X campx=P_NXLOC; campy=P_NYLOC; X for(x=P_NXLOC-PRTZONE;x<=P_NXLOC+PRTZONE;x++) X for(y=P_NYLOC-PRTZONE;y<=P_NYLOC+PRTZONE;y++) { X if((ONMAP(x,y)) && sct[x][y].designation==DBASECAMP ) { X temp=FALSE; X campx=x; X campy=y; X } X } X if(temp==TRUE) { X fprintf(stderr,"Pirate fleet %d away from base\n",nvynum); X } else { X if (sct[campx][campy].designation!=DBASECAMP) { X fprintf(stderr,"BASECAMP NOT FOUND!!!\n"); X } else { X P_NXLOC=campx; X P_NYLOC=campy; X } X } X } X X for(nvynum=0;nvynum<MAXNAVY;nvynum++) if (P_NWSHP!=0) { X for(x=1;x<NTOTAL;x++) if(isntn(ntn[x].active)) X for(y=0;y<MAXNAVY;y++) X if(ntn[x].nvy[y].warships!=0 || ntn[x].nvy[y].merchant!=0 X || ntn[x].nvy[y].galleys!=0) { X if((abs(ntn[x].nvy[y].xloc-P_NXLOC)<=PRTZONE) X &&(abs(ntn[x].nvy[y].yloc-P_NYLOC)<=PRTZONE)) { X P_NXLOC= ntn[x].nvy[y].xloc; X P_NYLOC= ntn[x].nvy[y].yloc; X } X } X if(rand()%15==0) { X /*randomly add one warship to pirate fleet*/ X shipsize = rand()%(N_HEAVY-N_LIGHT+1); X (void) NADD_WAR(1); X } X } X} X#endif MONSTER X X#ifdef NPC Xvoid Xn_redes(x,y,goldthresh,metalthresh,citythresh,hunger) Xint x,y,goldthresh,metalthresh,citythresh; Xfloat hunger; X{ X register struct s_sector *sptr = &sct[x][y]; X X if((sptr->designation == DCAPITOL) X ||(sptr->designation == DCITY)) return; X X /*large enough for a city now?*/ X if(((sptr->people > (spread.civilians/CITYLIMIT)) X ||((spread.civilians<30000)&&(sptr->people>1000))) X &&( hunger > P_EATRATE*1.5 ) X &&( spread.incity+spread.incap < spread.civilians * CITYPERCENT / 100) X &&( spread.sectors > 10) X &&( sptr->tradegood == TG_none )){ X sptr->designation=DTOWN; X spread.incity+=sptr->people; X spread.infarm-=sptr->people; X } X X /* large enough for city and not enough food*/ X if((sptr->designation==DTOWN) X &&( hunger < P_EATRATE) X &&( tofood(sptr,sptr->owner) > citythresh )){ X sptr->designation=DFARM; X spread.incity-=sptr->people; X spread.infarm+=sptr->people; X } X X if((sptr->designation==DTOWN) X &&( spread.incity+spread.incap > spread.civilians * CITYPERCENT / 66)){ X sptr->designation=DFARM; X spread.incity-=sptr->people; X spread.infarm+=sptr->people; X } X X /*what if it is not a city*/ X if((sptr->designation!=DTOWN) X &&(sptr->designation!=DCITY) X &&(sptr->designation!=DCAPITOL)){ X if(( sptr->tradegood != TG_none ) X &&( tg_ok( sptr->owner, sptr ))) { X if(( metalthresh+goldthresh > 8 ) X ||(( sptr->metal < metalthresh ) X &&( sptr->metal != 0 )) X ||(( sptr->jewels < goldthresh ) X &&( sptr->jewels != 0 ))) { X sptr->designation = DFARM; X } else sptr->designation= *(tg_stype+sptr->tradegood); X X if(( sptr->metal < metalthresh ) X &&( sptr->metal != 0 )) X sptr->designation=DBLKSMITH; X X if(( sptr->designation== 'x' ) X ||(( sptr->designation== DCITY )&&(sptr->people<1000))) X sptr->designation=DFARM; X } else if( tofood(sptr,sptr->owner) >= 4 ){ X sptr->designation=DFARM; X } else sptr->designation=DSTOCKADE; X } X if(( sptr->designation==DFARM) X &&( hunger > P_EATRATE*1.5 ) X &&( tofood(sptr,sptr->owner) <= 6 )){ X if(( rand()%2 == 0 )&&( curntn->mine_ability<30 )) X sptr->designation=DBLKSMITH; X else if(( rand()%2 == 0 ) X &&( sptr->people<100 ) X &&( curntn->spoilrate >15)) X sptr->designation=DGRANARY; X else if(( rand()%2 == 0 )&&( curntn->popularity<50 )) X sptr->designation=DCHURCH; X else if( sptr->people>1000 ) X sptr->designation=DTOWN; X } X} X Xvoid Xredomil() X{ X short x,y,armynum,nvynum; X int i, free, done; X long militia=0l,ideal; X long diff=0l; X int ok; X X check(); X /* check out any ship crews */ X for(nvynum=1;nvynum<MAXNAVY;nvynum++) { X /* definite cheat -- add some random */ X if((P_NMSHP!=0)||(P_NWSHP!=0)||(P_NGSHP != 0)) X if(rand()%2==0) P_NCREW = SHIPCREW; X } X check(); X for(armynum=1;armynum<MAXARM;armynum++) if(P_ASOLD>0){ X /* move army back if too far out */ X ok = 0; X for(x=P_AXLOC-3;x<=P_AXLOC+3;x++) X for(y=P_AYLOC-3;y<=P_AYLOC+3;y++) X if((ONMAP(x,y))&&(sct[x][y].owner==country)) ok=1; X if(ok==0){ X P_AXLOC=curntn->capx; X P_AYLOC=curntn->capy; X } X X /* count and verify militia */ X if(P_ATYPE==A_MILITIA) { X /* eliminate invalid militia */ X if(((sct[P_AXLOC][P_AYLOC].designation!=DTOWN) X &&(sct[P_AXLOC][P_AYLOC].designation!=DCAPITOL) X &&(sct[P_AXLOC][P_AYLOC].designation!=DCITY)) X ||(sct[P_AXLOC][P_AYLOC].owner!=country)){ X#ifdef DEBUG X printf("\teliminating %s army %d as %d %d is des:%c alt:%c own:%d\n",unittype[P_ATYPE],armynum,P_AXLOC,P_AYLOC,sct[P_AXLOC][P_AYLOC].designation,sct[P_AXLOC][P_AYLOC].altitude,sct[P_AXLOC][P_AYLOC].owner); X#endif DEBUG X if(sct[P_AXLOC][P_AYLOC].owner == country) X sct[P_AXLOC][P_AYLOC].people+=P_ASOLD; X else sct[curntn->capx][curntn->capy].people+=P_ASOLD; X P_ASOLD=0; X } else militia+=P_ASOLD; X } X X /* set default status */ X if(P_ASTAT<NUMSTATUS) switch(P_ASTAT) { X case MILITIA: X case SIEGED: X case TRADED: X case ONBOARD: X case GENERAL: X break; X default: X P_ASTAT=DEFEND; X break; X } X } X curntn->tmil -= militia; X X /*make sure enough men in army 0 -- garrison duty in capitol*/ X armynum=0; X P_ASTAT=GARRISON; X P_ATYPE=defaultunit(country); X P_AXLOC=curntn->capx; X P_AYLOC=curntn->capy; X X /*Ideally P_ASOLD[0]*MILINCAP=tmil*peace/10*/ X ideal = curntn->tmil * peace / (10L*MILINCAP); X if(curntn->tgold < 0) ideal/=2L; X#ifdef DEBUG X if(peace==8) X printf("\t%s IS AT PEACE - garrison in cap is %ld, ideal is %ld\n",curntn->name,P_ASOLD,ideal); X else if(peace==12) X printf("\t%s IS AT WAR - garrison in cap is %d, ideal is %ld\n",curntn->name,P_ASOLD,ideal); X else printf("error - incap is %d ideal is %ld\n",P_ASOLD,ideal); X#endif DEBUG X X /*MILRATIO ratio mil:civ for non player countries*/ X /*MILINCAP ratio (mil in cap):mil for NPCs*/ X check(); X X if((P_ASOLD*10) < (9*ideal)){ X X /*too few soldiers on garrison*/ X /*diff is number to change mil in cap (>0)*/ X if(curntn->tgold<0L) diff=0; X else diff = (long) min(ideal-P_ASOLD,(int) (curntn->metals / *(u_enmetal + (P_ATYPE%UTYPE)))); X X diff=(long) min((int) diff, sct[curntn->capx][curntn->capy].people/2L); X X if(curntn->tgold<0L || curntn->metals<0L) if(diff > 0L) diff=0; X X#ifdef DEBUG X printf("\tadding %d men to garrison (too few men on garrison)\n",diff); X#endif DEBUG X X sct[curntn->capx][curntn->capy].people-=diff; X P_ASOLD+=diff; X curntn->tciv-=diff; X curntn->tmil+=diff; X if(magic(country,WARRIOR)==1) /* take WARRIOR power into account */ X curntn->tgold -= (diff * *(u_encost + (P_ATYPE%UTYPE))) / 2; X else curntn->tgold-=diff* *(u_encost + (P_ATYPE%UTYPE)); X curntn->metals-=(diff* *(u_enmetal + (P_ATYPE%UTYPE))); X#ifdef DEBUG X if(P_ASOLD < 0L) printf("error 2... P_ASOLD=%d <0\n",P_ASOLD); X#endif DEBUG X } X /*else split garrison army if 1.25* needed number*/ X else if(P_ASOLD *4L > 5L*ideal){ X /*diff here is a negative number*/ X diff=((4L*P_ASOLD)-(5L*ideal))/4L; X#ifdef DEBUG X printf("\tsplit garrison of %d men\n",diff); X#endif DEBUG X free=FALSE; X P_ASOLD-=diff; X#ifdef DEBUG X if(P_ASOLD < 0) printf("error... subtracting %d from %d\n",diff,P_ASOLD); X#endif DEBUG X curntn->tmil-=diff; X curntn->tciv+=diff; X sct[curntn->capx][curntn->capy].people+=diff; X /*I add back gold as armies get redone anyway*/ X curntn->metals += (diff* *(u_enmetal + (P_ATYPE%UTYPE))); X if(magic(country,WARRIOR)==TRUE) { /* WARRIOR power */ X curntn->tgold+=(diff* *(u_encost + (P_ATYPE%UTYPE))) / 2; X } else curntn->tgold+=diff* *(u_encost + (P_ATYPE%UTYPE)); X } X#ifdef DEBUG X else printf("\tno action - P_ASOLD (%d) ~= ideal (%d)\n",P_ASOLD,ideal); X printf("\tFinal Garrison Army %d (%s) type is %s men is %d\n",armynum,curntn->name,*(unittype+(P_ATYPE)),P_ASOLD); X#endif DEBUG X X /*build ships and/or armies*/ X done=FALSE; X ideal = curntn->tciv * peace / (10 * MILRATIO); X if(curntn->tgold<0) { ideal*=4; ideal/=5; } X#ifdef DEBUG X printf("\t%s total military is %d -> ideal is %d\n",curntn->name,curntn->tmil,ideal); X#endif DEBUG X check(); X X /* find leader and place on RULE in capitol */ X for(armynum=0;armynum<MAXARM;armynum++) X if (P_ATYPE==getleader(curntn->class)-1) { X P_ASTAT=RULE; X P_AXLOC=curntn->capx; X P_AYLOC=curntn->capy; X break; X } X X /* add to partial armies */ X for(armynum=1;armynum<MAXARM;armynum++) X if((P_ASOLD>0) X &&( P_ATYPE!=A_MILITIA ) X &&( P_ATYPE<MINLEADER ) X &&( P_ASOLD < TAKESECTOR ) X &&( curntn->tgold > 0 ) X &&( fort_val(&sct[P_AXLOC][P_AYLOC]) > 0) X &&( sct[P_AXLOC][P_AYLOC].owner == country )) { X#ifdef DEBUG X printf("\tadding %d men to weakened army %d\n",TAKESECTOR+20-P_ASOLD,armynum); X#endif DEBUG X if(magic(country,WARRIOR)==TRUE) /* WARRIOR power */ X curntn->tgold-=((TAKESECTOR+20-P_ASOLD)* X *(u_encost + (P_ATYPE%UTYPE))) / 2; X else curntn->tgold-=(TAKESECTOR+20-P_ASOLD)* X *(u_encost + (P_ATYPE%UTYPE)); X curntn->tmil += TAKESECTOR+20-P_ASOLD; X P_ASOLD = TAKESECTOR+20; X } X X /*if < ideal build new army in the capitol - if possible*/ X if(curntn->tmil < ((4*ideal)/5)) { X for(armynum=1;armynum<MAXARM;armynum++) X if((done==FALSE)&&(P_ASOLD==0)) { X done=TRUE; X P_ATYPE = defaultunit(country); X P_ASOLD = min ((int) (ideal-curntn->tmil), (int) (curntn->metals/ (*(u_enmetal + (P_ATYPE%UTYPE))))); X X P_ASOLD = min (P_ASOLD,sct[curntn->capx][curntn->capy].people/2); X P_ASOLD = min (P_ASOLD, (int) (curntn->tgold/ *(u_encost+(P_ATYPE%UTYPE)))); X if(P_ASOLD>0){ X#ifdef DEBUG X printf("\tnot enough soldiers - build new army %d with %d men\n",armynum,P_ASOLD); X#endif DEBUG X curntn->metals-=(P_ASOLD* *(u_enmetal + (P_ATYPE%UTYPE))); X P_AXLOC= curntn->capx; X P_AYLOC= curntn->capy; X curntn->tmil += P_ASOLD; X curntn->tciv -= P_ASOLD; X if(magic(country,WARRIOR)==TRUE) /* WARRIOR power */ X curntn->tgold-=(P_ASOLD* *(u_encost + (P_ATYPE%UTYPE))) / 2; X else curntn->tgold-=P_ASOLD* *(u_encost + (P_ATYPE%UTYPE)); X sct[P_AXLOC][P_AYLOC].people-=P_ASOLD; X P_ASTAT= DEFEND; X P_AMOVE=0; X } X else P_ASOLD=0; X } X check(); X } else if(curntn->tmil > (6*ideal/5)){ X check(); X /*disband a pseudo-random army*/ X done=FALSE; X diff=curntn->tmil-(6*ideal/5); X for(armynum=1;done==FALSE && armynum<MAXARM;armynum++){ X if((P_ASOLD<=0) X ||(P_ATYPE==A_MILITIA) X ||(P_ATYPE>=MINLEADER) X ||(P_ASTAT==ONBOARD) X ||(P_ASTAT==TRADED)) continue; X X if((sct[P_AXLOC][P_AYLOC].owner==country) X &&((sct[P_AXLOC][P_AYLOC].jewels>4) X ||(sct[P_AXLOC][P_AYLOC].metal>4) X ||(ISCITY(sct[P_AXLOC][P_AYLOC].designation)))){ X#ifdef DEBUG X printf("\ttoo many soldiers eliminate army %d (%d men)\n",armynum,P_ASOLD); X#endif DEBUG X diff-=P_ASOLD; X sct[P_AXLOC][P_AYLOC].people+=P_ASOLD; X curntn->tmil -= P_ASOLD; X curntn->tciv += P_ASOLD; X P_ASOLD=0; X if(diff<=50) done=TRUE; X } X } X } X check(); X#ifdef DEBUG X printf("\twhew... new tmil is %d\n",curntn->tmil); X#endif DEBUG X X /*resize armies */ X for(armynum=1;armynum<MAXARM;armynum++) if(P_ATYPE < MINLEADER) { X /*maximum npc army is 3*TAKESECTOR or 3*tmil/MAXARM */ X /* also let militia get big */ X if((P_ASOLD>(2*TAKESECTOR)) X &&(P_ATYPE!=A_MILITIA && P_ASTAT!=ONBOARD && P_ASTAT!=TRADED)) { X free=FALSE; X for(i=1;free==FALSE && i<MAXARM;i++){ X if(curntn->arm[i].sold==0){ X free=TRUE; X P_ASOLD/=2; X#ifdef DEBUG X printf("\tSplitting %ld troops from army %d forming %s army %d \n" X ,P_ASOLD,armynum,unittype[P_ATYPE],i); X#endif DEBUG X curntn->arm[i].sold = P_ASOLD; X curntn->arm[i].unittyp = P_ATYPE; X curntn->arm[i].smove = P_AMOVE; X curntn->arm[i].stat = P_ASTAT; X curntn->arm[i].xloc = P_AXLOC; X curntn->arm[i].yloc = P_AYLOC; X } X } X } X /*minimum npc army is TAKESECTOR, merge them*/ X else if(P_ASOLD>0 && (P_ASOLD<TAKESECTOR || P_ASTAT==MILITIA) X && P_ASTAT!=ONBOARD && P_ASTAT!=TRADED) { X free=FALSE; X for(i=1;free==FALSE && i<MAXARM;i++){ X if((curntn->arm[i].sold>0) X &&(curntn->arm[i].stat!=ONBOARD) X &&(i!=armynum) /* don't use same army */ X /* or it will be deleted */ X &&(curntn->arm[i].stat!=TRADED) X &&(curntn->arm[i].xloc==P_AXLOC) X &&(curntn->arm[i].yloc==P_AYLOC) X &&(curntn->arm[i].unittyp==P_ATYPE)) { X free=TRUE; X curntn->arm[i].sold += P_ASOLD; X#ifdef DEBUG X printf("\tMerge %ld men from army %d to make %ld troops in %s army %d \n" X ,P_ASOLD,armynum,curntn->arm[i].sold,unittype[P_ATYPE],i); X#endif DEBUG X P_ASOLD=0; X } X X } X } X } X check(); X X /* assure that a militia unit resides in each city */ X if(curntn->tgold > 0) X for(x=stx;x<endx;x++) for(y=sty;y<endy;y++) X if((sct[x][y].owner==country) X &&((sct[x][y].designation==DTOWN)||(sct[x][y].designation==DCITY)||(sct[x][y].designation==DCAPITOL))){ X free=FALSE; X for(armynum=0;armynum<MAXARM;armynum++){ X if((P_ASOLD>0) X &&(P_AXLOC==x)&&(P_AYLOC==y) X &&(P_ATYPE==A_MILITIA)) { X free=TRUE; X break; X } X } X if(free==FALSE) { /* draft new militia army */ X for(armynum=0;armynum<MAXARM;armynum++) if(P_ASOLD==0){ X P_AXLOC=x; X P_AYLOC=y; X free=TRUE; X break; X } X } X if((free==TRUE)) { X /* want to add ideal troops */ X ideal = sct[x][y].people/MILINCITY - P_ASOLD; X ideal = min(ideal, 250); X if (P_ASOLD < 50) /* make the militia at least 50 */ X ideal = max(ideal,50-P_ASOLD); X if (P_ASOLD + ideal < 50) /*don't let ideal bring it below 50*/ X continue; X if(ideal>0){ X if(magic(country,WARRIOR)==TRUE){ /* WARRIOR power */ X curntn->tgold-= X (ideal* *(u_encost+P_ATYPE))/2; X } else { X curntn->tgold-= X ideal* *(u_encost + P_ATYPE); X } X } X P_ASOLD+=ideal; X P_ATYPE=A_MILITIA; X P_ASTAT=MILITIA; X#ifdef DEBUG X printf("\tadding %ld troops to %s army %d (now %ld men - populace %ld)\n",ideal,unittype[P_ATYPE],armynum,P_ASOLD,sct[x][y].people); X#endif DEBUG X } X } X check(); X X /* setup default units */ X for(armynum=1;armynum<MAXARM;armynum++) X if((P_ASOLD>0)&&(P_ATYPE!=A_MILITIA)&&(P_ATYPE<MINLEADER)) X P_ATYPE=defaultunit(country); X} X X/* getdstatus() - do diplomacy for current nation */ Xvoid Xgetdstatus() X{ X int x,oldstat[NTOTAL]; X int X,Y; X int svhostile,hostile; /* chance nation will react hostile */ X int friendly; /* chance nation will react favorably */ X X if(!isnpc(curntn->active)) return; X X if(( curntn->active==GOOD_6FREE ) X ||( curntn->active==ISOLATIONIST ) X ||( curntn->active==NEUTRAL_6FREE ) X ||( curntn->active==EVIL_6FREE )) svhostile=5; X else if(( curntn->active==GOOD_4FREE ) X ||( curntn->active==NEUTRAL_4FREE ) X ||( curntn->active==EVIL_4FREE )) svhostile=10; X else if(( curntn->active==GOOD_2FREE ) X ||( curntn->active==NEUTRAL_2FREE ) X ||( curntn->active==EVIL_2FREE )) svhostile=20; X else if(( curntn->active==GOOD_0FREE ) X ||( curntn->active==NEUTRAL_0FREE ) X ||( curntn->active==EVIL_0FREE )) svhostile=35; X else svhostile=5; X X for(x=1;x<NTOTAL;x++) if( isntn(ntn[x].active) ){ X hostile = svhostile; X if(npctype(curntn->active) != npctype(ntn[x].active)) X hostile+=20; /* not same allignment */ X friendly = 60-hostile; X if( curntn->active==ISOLATIONIST ) friendly -= 20; X /* negate impact of above line on neutrals */ X if(isneutral(ntn[x].active)) { X friendly-=10; X hostile-=10; X } X if(ntn[x].race==curntn->race){ X friendly+=10; X hostile-=10; X } X if(isneutral(curntn->active)) { X friendly-=20; X hostile-=20; X } X /* if next to capitol, they dont like you */ X for(X=curntn->capx-1;X<=curntn->capx+1;X++) X for(Y=curntn->capy-1;Y<=curntn->capy+1;Y++) if(ONMAP(X,Y)) { X if(sct[X][Y].owner == x) { X friendly-=10; X hostile +=10; X } X } X X if( friendly < 0 ) friendly=0; X if( hostile < 0 ) hostile=0; X X oldstat[x] = curntn->dstatus[x]; X X /* break bad treaties */ X if(curntn->dstatus[x] == TREATY) { X if(ntn[x].dstatus[country]>=WAR) X curntn->dstatus[x] = JIHAD; X continue; X } X X if((curntn->dstatus[x] == JIHAD) X ||(curntn->dstatus[x]==UNMET) X ||(ispc(curntn->active))) X continue; X X /*if 4* mil and 4* score then not like them*/ X if((ntn[x].tmil>4*curntn->tmil) X &&(ntn[x].score>4*curntn->score)){ X if(curntn->dstatus[x]<WAR){ X if(rand()%100<=hostile) X curntn->dstatus[x]++; X } X } X /*adjust based on your status with them*/ X if((curntn->dstatus[x]==WAR) X &&(ntn[x].dstatus[country]<WAR)) X if(rand()%100<=friendly) curntn->dstatus[x]--; X X if((curntn->dstatus[x]<WAR) X &&(curntn->dstatus[x]>ALLIED)){ X if(ntn[x].dstatus[country]>1+curntn->dstatus[x]){ X if(rand()%100<=hostile) X curntn->dstatus[x]++; X } else if(ntn[x].dstatus[country]+1<curntn->dstatus[x]){ X if(rand()%100<=friendly) X curntn->dstatus[x]--; X } X } X if(rand()%100<= hostile) { X if((curntn->dstatus[x]!=JIHAD) X &&(curntn->dstatus[x]!=TREATY)) X curntn->dstatus[x]++; X } X if((rand()%100<= friendly) X &&(curntn->dstatus[x]!=TREATY) X &&(curntn->dstatus[x]!=JIHAD) X &&(curntn->dstatus[x]!=WAR)) curntn->dstatus[x]--; X } X X for(x=1;x<NTOTAL;x++) if(isntn( ntn[x].active ) ){ X if((rand()%5==0) X &&(ntn[x].dstatus[country]==WAR) X &&(curntn->dstatus[x]==WAR)) { X ntn[x].dstatus[country]=HOSTILE; X curntn->dstatus[x]=HOSTILE; X fprintf(fnews,"2.\tnation %s and %s announce ceasefire\n",curntn->name,ntn[x].name); X if( isnotpc(ntn[x].active) ) continue; X mailopen(x); X fprintf(fm,"nation %s and you negotiate a ceasefire\n",curntn->name); X mailclose(); X } else if((oldstat[x]==WAR)&&(curntn->dstatus[x]==WAR)){ X fprintf(fnews,"2.\tnation %s stays at war with %s\n",curntn->name,ntn[x].name); X } else if((oldstat[x]<WAR)&&(curntn->dstatus[x]==WAR)){ X fprintf(fnews,"2.\tnation %s goes to war with %s\n",curntn->name,ntn[x].name); X if( isnotpc(ntn[x].active) ) continue; X mailopen(x); X fprintf(fm,"nation %s goes to war with you\n",curntn->name); X mailclose(); X } else if((oldstat[x]!=JIHAD)&&(curntn->dstatus[x]==JIHAD)){ X fprintf(fnews,"2.\tnation %s announces a jihad with %s\n",curntn->name,ntn[x].name); X if( isnotpc(ntn[x].active) ) continue; X mailopen(x); X fprintf(fm,"nation %s announces a jihad with you\n",curntn->name); X mailclose(); X } X } X} X Xvoid Xnationrun() X{ X int goldthresh,metalthresh,citythresh,useful; X int armynum,loop; X int x,y,i,p; X float hunger; X long zz; X check(); X prep(country,FALSE); X X for(x=0;x<MAPX;x++) for(y=0;y<MAPY;y++) attr[x][y]=0; X X /* is there an error*/ X if((sct[curntn->capx][curntn->capy].owner==country) X &&(sct[curntn->capx][curntn->capy].designation!=DCAPITOL)){ X sct[curntn->capx][curntn->capy].designation=DCAPITOL; X } X X if( ispc( curntn->active )) { X stx=sty=0; X endx=MAPX; X endy=MAPY; X } else { X if( curntn->capx > NPCTOOFAR ) X stx=curntn->capx-NPCTOOFAR; X else stx=0; X if( curntn->capy > NPCTOOFAR ) X sty=curntn->capy-NPCTOOFAR; X else sty=0; X if( curntn->capx + NPCTOOFAR < MAPX ) X endx=curntn->capx+NPCTOOFAR; X else endx=MAPX; X if( curntn->capy + NPCTOOFAR < MAPY ) X endy=curntn->capy+NPCTOOFAR; X else endy=MAPY; X } X X getdstatus(); X X#ifdef SPEW X for(x=1;x<NTOTAL;x++) if(isntn( ntn[x].active )) { X /* here is the bit which will occasionally send a randomly X generated message from a hostile NPC to a PC (25% chance) */ X if((curntn->dstatus[x] >= HOSTILE) X && (ispc(ntn[x].active))) X if (rand()%4 == 0) { /* send the message!! */ X printf("Sent message to %s\n",ntn[x].name); X mailopen(x); X fprintf(fm,"Message to %s from %s (%s of year %d)\n\n" X ,ntn[x].name,curntn->name,PSEASON(TURN),YEAR(TURN)); X makemess(rand()%5 +1,fm); X mailclose(); X } X } X#endif SPEW X /*move units */ X /*are they at war with any normal countries*/ X peace=0; X for(i=1;i<NTOTAL;i++) X if(isntn(ntn[i].active)&&(curntn->dstatus[i]>peace)) { X peace=curntn->dstatus[i]; X if( peace>= WAR) break; X } X X if(peace<WAR){ X peace=8; X pceattr(); X } else { X /*if war then attack &/or expand */ X peace=12; X /*are they attacking or defending */ X if(curntn->tmil==0) defattr(); X else for(x=0;x<NTOTAL;x++) X if(isntn( ntn[x].active ) && (curntn->dstatus[x]>HOSTILE)){ X if(100*(curntn->tmil*(curntn->aplus+100))/((curntn->tmil*(curntn->aplus+100))+(ntn[x].tmil*(ntn[x].dplus+100)))>rand()%100){ X /*attacker*/ X for(armynum=1;armynum<MAXARM;armynum++) X if((P_ASOLD>0)&&(P_ATYPE!=A_MILITIA) X &&(P_ASTAT!=ONBOARD)&&(P_ASTAT!=TRADED) X &&(P_ASTAT<NUMSTATUS)&&(P_ASTAT!=GENERAL)) X P_ASTAT=ATTACK; X atkattr(); X } else { /*defender*/ X for(armynum=1;armynum<MAXARM;armynum++) X if((P_ASOLD>0)&&(P_ATYPE!=A_MILITIA) X &&(P_ASTAT!=ONBOARD)&&(P_ASTAT!=TRADED) X &&(P_ASTAT<NUMSTATUS)&&(P_ASTAT!=GENERAL)){ X if(P_ASOLD<350) P_ASTAT=DEFEND; X else P_ASTAT=ATTACK; X } X defattr(); X } X } X } X check(); X X /* move infantry then leader/monsters */ X n_people(TRUE); /* add to attr for people */ X X if( country < 5 ) prtattr(); X X loop=0; X for(armynum=1;armynum<MAXARM;armynum++) X if((P_ASOLD!=0)&&(P_ATYPE<MINLEADER)) loop+=armymove(armynum); X n_people(FALSE); /* subtract to attr for people */ X for(armynum=1;armynum<MAXARM;armynum++) X if((P_ASOLD!=0)&&(P_ATYPE>=MINLEADER)) loop+=armymove(armynum); X X /* NPC ACTIVE STATUS CHANGE */ X if(isnpc(curntn->active) X &&(curntn->active != ISOLATIONIST)) { X if(isgood(curntn->active)) { X if(loop<=1) curntn->active=GOOD_0FREE; X else if(loop>=6) curntn->active=GOOD_6FREE; X else if(loop>=4) curntn->active=GOOD_4FREE; X else curntn->active=GOOD_2FREE; X } else if(isneutral(curntn->active)) { X if(loop<=1) curntn->active=NEUTRAL_0FREE; X else if(loop>=6) curntn->active=NEUTRAL_6FREE; X else if(loop>=4) curntn->active=NEUTRAL_4FREE; X else curntn->active=NEUTRAL_2FREE; X } else if(isevil(curntn->active)) { X if(loop<=1) curntn->active=EVIL_0FREE; X else if(loop>=6) curntn->active=EVIL_6FREE; X else if(loop>=4) curntn->active=EVIL_4FREE; X else curntn->active=EVIL_2FREE; X } X } X X if( curntn->tgold > curntn->tciv ) curntn->charity=10; X else curntn->charity=0; X X /* INTELLIGENT SECTOR REDESIGNATION */ X /* note that only redesignate pc's if not designated yet */ X goldthresh=4; X metalthresh=4; X citythresh=10; X hunger = 5.0; X for(loop=1;loop<5;loop++) { X#ifdef DEBUG X printf("\tnpcredes(): country %s gold=%d metal=%d, city=%d hunger=%f\n",curntn->name,goldthresh,metalthresh,citythresh,hunger); X#endif DEBUG X X useful=FALSE; X for(x=stx;x<endx;x++) for(y=sty;y<endy;y++) X if((sct[x][y].owner==country) X &&(is_habitable(x,y)) X &&((isnotpc(curntn->active)) X ||(sct[x][y].designation==DNODESIG))) { X n_redes(x,y,goldthresh,metalthresh,citythresh,hunger); X useful=TRUE; X } X if(useful==FALSE) break; X X spreadsheet(country); X X hunger = spread.food/((float)(spread.civilians+2*curntn->tmil)); X if(hunger < P_EATRATE ) { X goldthresh++; X metalthresh++; X citythresh--; X } else if(hunger > 2*P_EATRATE) { X if( goldthresh==1 && metalthresh==1 ) break; X goldthresh-=2; X metalthresh-=2; X citythresh+=2; X } else { X if( goldthresh==1 && metalthresh==1 ) break; X if(rand()%2==0) goldthresh--; X else metalthresh--; X if(goldthresh==0) goldthresh=1; X if(metalthresh==0) metalthresh=1; X citythresh++; X } X if(goldthresh<=0) goldthresh=1; X if(metalthresh<=0) metalthresh=1; X } X X /*build forts in any cities*/ X if(isnotpc(curntn->active)) for(x=stx;x<endx;x++) for(y=sty;y<endy;y++) X if((sct[x][y].owner==country)&& X ((sct[x][y].designation==DTOWN) X ||(sct[x][y].designation==DCITY) X ||(sct[x][y].designation==DCAPITOL) X ||(sct[x][y].designation==DFORT)) X &&(sct[x][y].fortress<10) X &&(curntn->tgold>10000) X &&(rand()%5==0) X &&(sct[x][y].fortress<(sct[x][y].people%1000))) X sct[x][y].fortress++; X check(); X /*redo mil*/ X if(isnotpc(curntn->active)) redomil(); X check(); X X /*buy new powers and/or new weapons*/ X if(getmgkcost(M_MIL,country) < getmgkcost(M_CIV,country)){ X if(curntn->jewels > getmgkcost(M_MIL,country)) { X curntn->jewels-=getmgkcost(M_MIL,country); X if((zz=getmagic(M_MIL))!=0){ X for(p=S_MIL;p<E_MIL;p++) if(powers[p]==zz){ X fprintf(fnews,"1.\tnation %s gets combat power %s\n",curntn->name,pwrname[p]); X printf("\tnation %s gets combat power %s\n",curntn->name,pwrname[p]); X break; X } X exenewmgk(zz); X } else if((zz=getmagic(M_MIL))!=0){ X for(p=S_MIL;p<E_MIL;p++) if(powers[p]==zz){ X fprintf(fnews,"1.\tnation %s gets combat power %s\n",curntn->name,pwrname[p]); X printf("\tnation %s gets combat power %s\n",curntn->name,pwrname[p]); X break; X } X exenewmgk(zz); X } X else curntn->jewels+=getmgkcost(M_MIL,country); X } X } else { X if(curntn->jewels > getmgkcost(M_CIV,country)) { X curntn->jewels-=getmgkcost(M_CIV,country); X if((zz=getmagic(M_CIV))!=0){ X for(p=S_CIV;p<S_CIV+E_CIV;p++) if(powers[p]==zz){ X fprintf(fnews,"1.\tnation %s gets civilian power %s\n",curntn->name,pwrname[p]); X printf("\tnation %s gets civilian power %s\n",curntn->name,pwrname[p]); X break; X } X exenewmgk(zz); X } X else if((zz=getmagic(M_CIV))!=0){ X for(p=S_CIV;p<S_CIV+E_CIV;p++) if(powers[p]==zz){ X fprintf(fnews,"1.\tnation %s gets civilian power %s\n",curntn->name,pwrname[p]); X printf("\tnation %s gets civilian power %s\n",curntn->name,pwrname[p]); X break; X } X exenewmgk(zz); X } X else curntn->jewels+=getmgkcost(M_CIV,country); X } X } X X check(); X if(magic(country,VAMPIRE)!=TRUE) { X i=0; X if(magic(country,WARLORD)==TRUE) i=30; X else if(magic(country,CAPTAIN)==TRUE) i=20; X else if(magic(country,WARRIOR)==TRUE) i=10; X x = max ( curntn->aplus-i, 10 ) / 10; X x *= x; X if( curntn->race==ORC) x*=2; X /* SHOULD USE spread.metal but it didnt work right */ X if(rand()%2==0) X if(curntn->metals > 3 * METALORE * curntn->tmil*x){ X curntn->aplus+=1; X curntn->metals-=METALORE*curntn->tmil*x; X printf("\tnation %s buys +1 percent attack\n",curntn->name); X } X x = max ( curntn->dplus-i, 10 ) / 10; X x *= x; X if( curntn->race==ORC) x*=2; X if(curntn->metals > 3 * METALORE * curntn->tmil*x){ X curntn->dplus+=1; X curntn->metals-=METALORE*curntn->tmil*x; X printf("\tnation %s buys +1 percent defence\n",curntn->name); X } X } X /* don't allow status ATTACK from own city */ X for(armynum=0;armynum<MAXARM;armynum++) { X if (P_ASOLD<=0 || P_ASTAT!=ATTACK) continue; X if ((sct[P_AXLOC][P_AYLOC].owner==country) X && (fort_val(&sct[P_AXLOC][P_AYLOC]) > 0)) { X if(rand()%2==0) P_ASTAT=DEFEND; X else P_ASTAT=GARRISON; X } X } X} X X/* dont allow npcs to trespass onto other nations land */ Xvoid Xn_trespass() X{ X register int x,y; X for(x=stx;x<endx;x++) for(y=sty;y<endy;y++) { X if((sct[x][y].owner != country ) X &&( sct[x][y].owner != 0 ) X &&( abs(x-curntn->capx)>2 ) X &&( abs(y-curntn->capy)>2 ) X &&( ntn[country].dstatus[sct[x][y].owner]<WAR) X &&( ntn[sct[x][y].owner].dstatus[country]<WAR) X &&( ntn[country].dstatus[sct[x][y].owner]>ALLIED)) X attr[x][y]=1; X } X} X X/* you are too far from capitol */ Xvoid Xn_toofar() X{ X register int x,y; X for(x=0;x<MAPX;x++) for(y=0;y<MAPY;y++) { X if( x<stx || y<sty || x>=endx || y>=endy ) X attr[x][y]=1; X } X} X X/* take undefended land */ Xvoid Xn_unowned() X{ X register int x,y; X X /* around capitol */ X for(x=curntn->capx-4;x<=curntn->capx+4;x++){ X for(y=curntn->capy-4;y<=curntn->capy+4;y++){ X if((ONMAP(x,y))&&(sct[x][y].owner==0)) { X attr[x][y] += 700; X } X } X } X X for(x=stx;x<endx;x++) { X for(y=sty;y<endy;y++) { X /* add if metal high */ X if(sct[x][y].tradegood != TG_none) { X if(sct[x][y].metal != 0) attr[x][y]+=500; X else if(sct[x][y].jewels != 0) attr[x][y]+=500; X else attr[x][y]+=300; X } X /*add to attractiveness for unowned sectors*/ X if(sct[x][y].owner == 0) { X attr[x][y]+=300; X } else { X if(ntn[sct[x][y].owner].active == NPC_NOMAD) X attr[x][y]+=100; X } X attr[x][y] += 50*tofood(&sct[x][y],country); X if(!is_habitable(x,y)) attr[x][y] /= 5; X } X } X} Xvoid Xn_defend(natn) Xregister short natn; X{ X int x,y; X X /* add 1/10th of their soldiers in sector */ X for(x=1;x<MAXARM;x++) if(ntn[natn].arm[x].sold > 0) X if(sct[ntn[natn].arm[x].xloc][ntn[natn].arm[x].yloc].owner==country) X attr[ntn[natn].arm[x].xloc][ntn[natn].arm[x].yloc] += X ntn[natn].arm[x].sold/10; X X /*plus 80 if near your capitol */ X for(x=curntn->capx-1;x<=curntn->capy+1;x++){ X for(y=curntn->capy-1;y<=curntn->capy+1;y++){ X if(ONMAP(x,y)) attr[x][y]+=80; X } X } X X /*plus based on defensive value and population */ X for(x=stx;x<endx;x++) for(y=sty;y<endy;y++) { X if(movecost[x][y]==1) attr[x][y] += 50; X else if(movecost[x][y]<=3) attr[x][y] += 20; X else if(movecost[x][y]<=5) attr[x][y] += 10; X X if(sct[x][y].owner==country){ X if(ISCITY(sct[x][y].designation)) X attr[x][y] += 50; X /* should spread 3000 points over country */ X attr[x][y]+=3000*sct[x][y].people/ntn[country].tciv; X } X } X} X Xvoid Xn_attack(nation) Xregister short nation; X{ X register int x,y; X int armynum; X long solds; /* solds within 1 of capitol or city */ X X for(x=stx;x<endx;x++) for(y=sty;y<endy;y++){ X if((sct[x][y].owner==nation)&& X ((sct[x][y].designation==DCITY) X ||(sct[x][y].designation==DCAPITOL) X ||(sct[x][y].designation==DTOWN))){ X solds=0; X for(armynum=1;armynum<MAXARM;armynum++) X if((ntn[country].arm[armynum].sold > 0) X &&(abs(AXLOC-x)<=1) X &&(abs(AYLOC-y)<=1)) solds+=ASOLD; X X if(solds_in_sector(x,y,nation)*2 < 3*solds) X attr[x][y]+=500; X } X } X} X X/* +100 if undefended sectors of nation, +60 if not */ Xvoid Xn_undefended( nation ) X{ X register int x,y; X for(x=stx;x<endx;x++) for(y=sty;y<endy;y++) if(sct[x][y].owner==nation){ X if(is_habitable(x,y) == 0) { X attr[x][y] += 30; X } else if(occ[x][y]==0) { X attr[x][y]+=100; X } else { X attr[x][y]+=60; X } X } X} X X/* add 1/2 of people in owned sectors for small armies */ Xvoid Xn_people(doadd) Xint doadd; /* TRUE if adding, FALSE if subtracting */ X{ X register int x,y; X for(x=stx;x<endx;x++) for(y=sty;y<endy;y++) X if(sct[x][y].owner==country){ X if(is_habitable(x,y)){ X if(doadd==TRUE) { X attr[x][y] += sct[x][y].people/4; X } else attr[x][y] -= sct[x][y].people/4; X } X } X} X X/* +60 if between two capitols */ Xvoid Xn_between(nation) Xint nation; X{ X int x1,x2,y1,y2,x,y; X X /*plus if strategic blocking sector*/ X X /*+60 if between the two capitol*/ X if (ntn[nation].capx < curntn->capx){ X x1=ntn[nation].capx; X x2=curntn->capx; X } else { X x1=curntn->capx; X x2=ntn[nation].capx; X } X if (ntn[nation].capy < curntn->capy){ X y1=ntn[nation].capy; X y2=curntn->capy; X } X else { X y1=curntn->capy; X y2=ntn[nation].capy; X } X X for(x=x1;x<=x2;x++) for(y=y1;y<=y2;y++) { X if(ONMAP(x,y)) attr[x][y]+=60; X } X} X X/* if in jeopardy, move to survive X * if within two of cap add 1/5th of men X * if on cap and war and 2x your garrison go jihad and + 1/2 men X */ Xvoid Xn_survive() X{ X int nation,armynum; X int capx,capy; X X capx=curntn->capx; X capy=curntn->capy; X X if(sct[capx][capy].owner!=country){ X attr[capx][capy]=1000; X } X X /*defend your capitol if occupied, +50 more if with their army*/ X for(nation=1;nation<NTOTAL;nation++) X if((isntn(ntn[nation].active)) X &&((ntn[nation].dstatus[country]>=WAR) X ||(curntn->dstatus[nation]>=WAR))){ X for(armynum=1;armynum<MAXARM;armynum++) X if((ntn[nation].arm[armynum].sold > 0) X &&( ntn[nation].arm[armynum].xloc<=capx+2) X &&( ntn[nation].arm[armynum].xloc>=capx-2) X &&( ntn[nation].arm[armynum].yloc<=capy+2) X &&( ntn[nation].arm[armynum].yloc>=capy-2)){ X if((ntn[nation].arm[armynum].xloc==capx) X &&(ntn[nation].arm[armynum].yloc==capy)){ X attr[capx][capy]+=2*ntn[nation].arm[armynum].sold; X } else { X attr[ntn[nation].arm[armynum].xloc][ntn[nation].arm[armynum].yloc]+=ntn[nation].arm[armynum].sold; X } X } X } X} X Xvoid Xdefattr() X{ X int nation; X X#ifdef DEBUG X printf("atkattr()\n"); X#endif DEBUG X X n_unowned(); X X for(nation=1;nation<NTOTAL;nation++) X if((isntn(ntn[nation].active))&&(curntn->dstatus[nation]>=WAR)) { X n_defend(nation); X n_between(nation); X n_undefended(nation); X } X X n_trespass(); X n_toofar(); X n_survive(); X} X X/*calculate attractiveness of attacking sectors*/ Xvoid Xatkattr() X{ X int nation; X#ifdef DEBUG X printf("atkattr()\n"); X#endif DEBUG X X n_unowned(); X X /*adjust for each nation that you are at war with*/ X for(nation=1;nation<NTOTAL;nation++) if( isntn(ntn[nation].active) ){ X if(curntn->dstatus[nation]==WAR) { X n_between(nation); X n_undefended(nation); X n_attack(nation); X } else if(curntn->dstatus[nation]==JIHAD) { X n_attack(nation); X n_attack(nation); X n_between(nation); X n_undefended(nation); X n_attack(nation); X n_between(nation); X n_undefended(nation); X n_attack(nation); X } X } X X n_toofar(); X n_trespass(); X n_survive(); X} X X/*calculate attractiveness when at peace*/ Xvoid Xpceattr() X{ X#ifdef DEBUG X printf("pceattr()\n"); X#endif DEBUG X n_unowned(); X n_unowned(); X n_trespass(); X n_toofar(); X n_survive(); X} X#endif NPC END_OF_FILE if test 38437 -ne `wc -c <'npc.c'`; then echo shar: \"'npc.c'\" unpacked with wrong size! fi # end of 'npc.c' fi if test -f 'txt1' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'txt1'\" else echo shar: Extracting \"'txt1'\" \(15137 characters\) sed "s/^X//" >'txt1' <<'END_OF_FILE' X THE WORLD OF CONQUER X XThe Conquer world is very bloody, and a player needs skills at war gaming, Xdiplomacy, and building an economy to succeed. Rival races are constantly Xat war, and the world starts filled with player nations, random peoples X(lizard men in their cities of gold, barbarians, nomads, pirates, brigands), Xand both hostile and friendly computer controlled non player countries. XConquer can be played solitaire. The computer uses a highly intelligent Xmovement algorithm to run the armies and navies of these non player Xcountries (NPC), and has intelligent algorithms built in that control these Xnations diplomacy, construction, and economies. You can find NPCs allied with Xyou against a common enemy, but can also suddenly be stabbed in the Xback and find hostile NPC armies at your doorstep. XEND X WHAT IS WHAT IN THE WORLD X XThe world is composed of a 2 dimensional map of sectors, created by the Xcomputer at the beginning of the game. Each sector has about 10 unique Xcharacteristics (altitude, gold, vegetation...). X XSECTOR ELEVATIONS include: X ZMOUNTAIN ZHILL ZCLEAR X ZWATER ZPEAK XSECTOR VEGETATION XUninhabitable Areas (do not produce food and people simply do not like) X ZVOLCANO ZDESERT ZJUNGLE X ZTUNDRA ZICE ZSWAMP XInhabitable (people like, number is relative value of food production) X ZGOOD...9 ZFOREST...3 (4 ELF) ZLIGHT...6 X ZWOOD...7 ZBARREN...4 (3 ELF) X XCONQUER is designed so each race likes their appropriate terrain. Elves like Xwoods & forests, Humans like good & light vegetation, and Orcs and Dwarves Xlike hills and mountains. You can only redesignate inhabitable sector types. XEND X RACES OF THE WORLD X XORC 'O' See next page. XELF 'E' Great at defense and quick, but few in numbers. They start X with VOID power, which is perhaps the most potent power in the X game, but which costs them an extra distribution point. XDWARF 'D' Dwarves are good at combat, but slow and few in numbers. They X start with MINER power, which allows them to quickly mine X metal/jewels, and thus improve their combat skills and powers. XHUMAN 'H' Humans start average at everything -- with reasonable numbers, X of people, and WARRIOR power, which gives them +10% in combat. X They have OK reproduction and good movement. XLIZARD 'L' (NPC only) An ancient race bound to their cities of gold XPIRATE 'P' (NPC only) Wandering pirates/brigands intent on plunder XNOMAD 'N' (NPC only) Will the wandering nomads tribes leave you alone? XBARBARIAN 'B' (NPC only) Indigenous natives and monsters XEND X ORC NATIONS IN CONQUER X XOrc nations are very special in Conquer. The only thing an orc is good at is Xmaking other orcs. They are slow, poor at combat, & bad in special abilities. XThey can get reproduction of up to 14% per year (the normal limit is 10%) & Xcan start with a large number of people as initial reproduction costs are less Xthan normal. Orcs are led by monsters (they start with MINOR MONSTER power), Xand are always evil (the only good orc is a dead orc...). They are so nasty, XEVERYBODY they meet start out hostile (50%) or at war (50%) with them. XPlayer nations get an option here, but they usually start out hostile to you. X XIn combat, orc & goblin units types flee just like mercenaries (a random Xchance, modified by odds...), and orcs are charged 2x normal cost for raising Xtheir combat bonus at game start and 3x during play, so they usually need X2:1 odds or better to win (expect heavy losses). X XFinally, Orcs are slow, as they require tremendous leader incentive to move Xand not kill each other. Large orc nations do have the ability to take over Xother Orc nations (The Sauron Syndrome). There is no Orc CAVALRY. XEND X POSSIBLE NATION ALIGNMENTS X XNations in conquer can be good, neutral, or evil. Alignment impacts how Xnon player nations will react to your nation ( good nations like good Xnations, but hate evil nations. Nobody is mean to neutral nations, Xbut nobody likes them either ). Player nations choose an alignment Xwhen they get created (no limitations) which can not change. Players Xactions are not restricted by their alignments, but players should Xplay "in character". There are more evil non player nations than there Xare good non player nations, so it is more fun/challenging to play the Xgood guys. XEND X SECTOR DESIGNATIONS X XThe following is the list of possible sector designations: X X ZTOWN ZFORT ZMILL X ZCITY ZSTOCKADE ZGRANARY X ZCAPITOL ZUNIVERSITY ZCHURCH X ZMINE ZLUMBERYARD ZSPECIAL X ZGOLD ZBLACKSMITH ZRUIN X ZFARM ZROAD ZDEVASTATED X XFor more information on each, see the helpfile on 'Designations' XEND X METAL, FOOD, AND GOLD X XFOOD: You MUST have enough food to feed your people... One civilian eats X your national eatrate units of food. Soldiers eat double. If you X run out of food, you run the risk of famine. Food will spoil based X on the spoilrate percentage for each nation. XMETAL: You need to have metal to draft new military, as per the unit types X section. One person produces one metal per point of mineral in X the sector per turn. An amount of Metal (based on how many troops X you have) can be used to buy +1% in your nations attack or defense. XJEWELS: You can have a maximum of 10 talons debt for every jewel X point that you mined. After that point, you undergo a TAX REVOLT, X which has not yet been implemented. Thus gold can be negative to X a certain level. Jewels are also useful to obtain magic, spending X Jewels will buy you one random new power (command M). The cost for X the magic power is dependent on your race and how many other powers X you have. See the helpfile on magic for more information. You can X have 10 talons in the treasury for each jewel (gold based economy). X After that, your gold talons will be converted to jewels at a 10:1 X ratio. XEND X CIVILIAN MOVEMENT X XThe game offers users the capability to forcibly move civilians around Xthe map (via the 'Z' command). Civilians will, however, move of their Xown volition. Below are how civilians of different races think about "good" Xsectors of various types. The program is intelligent enough to appropriately Xhandle poor or low value sectors. Sum the numbers found below. The result Xis the relative "attractiveness" of a sector. X XGeneral Modifiers: Goldmine: XGOLDATTR / jewels Farm: XFARMATTR / food value Other: XOTHRATTR X Trade Good: XTGATTR Mine: XMINEATTR / metals Town: XTOWNATTR City: XCAPATTR X X Racial Modifiers XRace Mtn Hill Clear Forest Wood City Mine Gldmine XDwarf XDMNTNATTR XDHILLATTR XDCLERATTR XDFOREATTR XDWOODATTR XDCITYATTR XDMINEATTR XDGOLDATTR XElf XEMNTNATTR XEHILLATTR XECLERATTR XEFOREATTR XEWOODATTR XECITYATTR XEMINEATTR XEGOLDATTR XHuman XHMNTNATTR XHHILLATTR XHCLERATTR XHFOREATTR XHWOODATTR XHCITYATTR XHMINEATTR XHGOLDATTR XOrc XOMNTNATTR XOHILLATTR XOCLERATTR XOFOREATTR XOWOODATTR XOCITYATTR XOMINEATTR XOGOLDATTR XEND X VIEWING THE WORLD X XWhen you log in, you will notice that you can only see a part of the Xworld. You must discover the world by getting certain magical powers, Xby taking land, or by moving armies and navies. The use of SCOUT armies Xis intended for this purpose. X XThe 'd' command allows you to change what you see on the map. You can Xalter the information in the sector and can change the type of sectors that Xare highlighted as follows: X Xviewing options: (d)esignation, (r)ace, (M)ove cost, (p)eople, (D)efense X (f)ood, (c)ontour, (v)egetation, (m)etal, (n)ation mark, (j)ewels, (i)tems Xhighlight option: (o)wner (a)rmy (y)our Army, move (l)eft, (s)pecial, (x)=none Xtoggle move mode: hit '/' X XMove mode ('/' toggle) will display both the current display as well as Xthe move cost for each sector along side. X XI have tried to make the use of these options clear and self explanatory. XRoman numerals (for population...) indicate thousands of people. XEND X COMMERCE AND TRADING X XTrading makes it be possible to exchange items between nations. X XThere are seven types of items available for trade: gold, food, metal, Xjewels, land, soldiers, and ships. To place an item up for trade, Xthe player need only select the sell option on the commerce board. The Xplayer will then enter the type and amount of his product followed by the Xtype and minimum amount of what he wants in return. The product will Xremain on the commerce board until it is purchased or removed by the Xowner of the product. To purchase an item, a player can just select the Xitem number to purchase and then enter a bid amount. You may only trade Xmercenary, siege engine, catapult, (summoned) monster, or elephant units. XCertain Items will be available for "instant purchase" from the game Xitself, these are indicated by the nation name of "Conquer". X XDuring every update, bids will be resolved and the highest bid for a Xproduct will receive the product. There is a 20% administration fee Xfor a trade (i.e. 20% of the traded goods on each side disappear) XEND X DIPLOMACY IN CONQUER X XDiplomacy is very important in conquer. You maintain a diplomatic status with Xeach nation in the game. This is adjusted via the 'S' (diplomacy) command. XPossible status' are TREATY, ALLIED, FRIENDLY, NEUTRAL, HOSTILE, XWAR, and JIHAD. Be very careful with TREATY and JIHAD. Once chosen, Xit will take XBREAKJIHAD gold talons to change your mind (and might ruin Xyour reputation). You can only take land from a nation that you are at XWAR or JIHAD with. TREATY implies that you AUTOMATICALLY declare war on Xnations who ATTACK your ally - but not on nations whom they attack. X XDiplomacy with non player nations is important as it determines if you get Xattacked or not. XEND X BRIBING NPC NATIONS X XConquer allows you a chance to bribe non player nations for the paltry sum Xof XBRIBE per 1000 troops in the bribee's nation. A nation with 10000 troops Xcan be bribed for only 10xXBRIBE gold talons (a bargain). This has a Xpercentage chance of working, but you wont know if it worked until the update. X Xsame allignment: 50% X1 level allignment difference: 30% X2 level allignment difference: 20% XThey are isolationist: 15% Xsame race: +20% X XBribing NPCs is a good way to get some breathing room. XYou waste your money if you are at war with them that turn. XYou can not bribe player nations, barbarians, nomads, lizards, or pirates. XEND X SEASONS X (not fully implemented yet) X Xwinter: army units must end turn in town or suffer 10% attrition. X farms produce no food. movement is at half ability. Xspring: produce 1/2x food. Xsummer: produce 1x food. units get 50% movement bonus. Xfall: produce 2.5x food. X Xyou must have a sector spring,summer,and fall or it will produce no food Xglobal events should be good too; typhoon season, famine times, etc. XPerhaps the climate of a region should also effect the events. ie, Xmore typhoons in the equatorial belt. Typhoon should be calculated Xwith a starting point and an ending point and then it walks in Xbetween causing devastation. XEND X FINAL HINTS & OTHER COSTS X XIt is important to initially have a reproduction of 9-10% and a move of ~8-9. XYou need about 1000 military to start - to take enough new land. XTake as much land as possible in the beginning. XMake sure your combat bonus stays respectable. X X OTHER COSTS X X Designation Costs: $XDESCOST X Designation to Fort or Town: 10x$XDESCOST+$XDESCOST METAL X Designation to City: 20x$XDESCOST+5*$XDESCOST METAL X Fortification: $XFORTCOST*(2**Fort Level) X Bribe Nation: $XBRIBE/level X Move Civilians: $50/civilian XEND X OTHER NOTES X X The computer can move for players if they don't enter a turn and the XCMOVE variable is set before the program is compiled. This works well... Xfor a time. The Computer will NOT redesignate captured sectors for you. X XMercenaries must be paid a fee equal to enlistment fee when disbanded. X XIf you have too many people in a given non Town, non capitol sector, Xreproduction and production is halved for them. If you have a large Xnumber of people in a sector, they will not reproduce. X XWARNING: The Naval Code has been known to be buggy. Please pay attention Xand send the author notes on discrepancies in the code. XEND X OPTIONS OF YOUR VERSION X X Maximum Number of Armies Per Nation....XMAXARM X Maximum Number of Navies Per Nation....XMAXNAVY X Absolute Maximum Number of Nations.....XNTOTAL X Starting Points to buy your nation.....XMAXPTS X Percentage of land that is mountains...XPMOUNT X Storm Percentage.......................XPSTORM X Cost for Orc Npc Takeover..............XTAKEPRICE X Average Number of Random Events........XNORANDEVENTS X Chance of Volcano Eruption.............XPVULCAN X X Mail Checker XSYSMAIL System V XSYSV X Monsters XMONSTER Npc Cheat XCHEAT X Storms XSTORMS Volcanos XVULCANIZE X Npc Nations XNPC PC Automove XCMOVE X Random Events XRANEVENT Orc Takeovers XORCTAKE X Super God XOGOD Hidden News XHIDELOC X Trading XTRADE XEND X ADDITIONAL OPTIONS X X Land Vision Range is..................XLANDSEE X Navy Vision Range is..................XNAVYSEE X Army Vision Range is..................XARMYSEE X X Taxation Rates: X Food tax per value point per person...XTAXFOOD X Jewel tax per jewel point per person..XTAXGOLD X Metal tax per metal point per person..XTAXMETAL X Town tax per person...................XTAXTOWN X City tax per person...................XTAXCITY X X 100% chance per XTOMUCHMINED metal mined of deplete metal mines. X 100% chance per XTOMUCHMINED jewels mined of deplete gold mines. X XFINDPERCENT% chance that new materials are found in a sector. X Sector overpopulation occurs with XTOMANYPEOPLE people. X Maximum Sector Population is XABSMAXPEOPLE people. X Ships may carry XSHIPHOLD items per holding unit. XEND XDONE END_OF_FILE if test 15137 -ne `wc -c <'txt1'`; then echo shar: \"'txt1'\" unpacked with wrong size! fi # end of 'txt1' fi echo shar: End of archive 5 \(of 14\). cp /dev/null ark5isdone MISSING="" for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 ; do if test ! -f ark${I}isdone ; then MISSING="${MISSING} ${I}" fi done if test "${MISSING}" = "" ; then echo You have unpacked all 14 archives. rm -f ark[1-9]isdone ark[1-9][0-9]isdone else echo You still need to unpack the following archives: echo " " ${MISSING} fi ## End of shell archive. exit 0