billr@saab.CNA.TEK.COM (Bill Randle) (06/24/89)
Submitted-by: adb@bu-it.bu.edu (Adam Bryant) Posting-number: Volume 6, Issue 89 Archive-name: conquer4/Part07 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 7 (of 14)." # Contents: move.c newlogin.c txt4 # Wrapped by billr@saab on Thu Jun 15 15:20:15 1989 PATH=/bin:/usr/bin:/usr/ucb ; export PATH if test -f 'move.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'move.c'\" else echo shar: Extracting \"'move.c'\" \(16422 characters\) sed "s/^X//" >'move.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 *fexe; Xextern short redraw; Xextern short selector; Xextern short pager; Xextern short xcurs,ycurs,xoffset,yoffset; Xextern short hilmode; /*highlight modes: 0=owned sectors, 1= armies, 2=none*/ X Xextern short country; Xint armornvy=AORN; X Xvoid Xmymove() X{ X int mveleft; /* movement remaining to army group */ X long groupmen; /* infantry types in current army group */ X long othermen; /* leader & monster strength in current group */ X int i,j,x; X int total,Tarmynum,Tnation,fmove; X int valid=FALSE; /* TRUE if move was a valid move */ X short armynum; X short nvynum; X int oldxcurs,oldycurs,mvused; X int done=FALSE; /*done is TRUE if done with this move*/ X X armornvy=AORN; X clear_bottom(0); X X if((armynum=getselunit())<0) { /*get selected army or navy*/ X errormsg("Invalid Unit Selected"); X armornvy=AORN; X return; X } X X if(armynum>=MAXARM) { /*navy*/ X nvynum = armynum-MAXARM; X armynum=(-1); X mvprintw(LINES-4,0,"NAVY %d: move %d",nvynum,P_NMOVE); X standend(); X clrtoeol(); X if((P_NMOVE==0)) { X errormsg("That Fleet is Not Able Move Any Farther"); X redraw=FALSE; X armornvy=AORN; X return; X } X mvused=P_NMOVE; X } else { /*army*/ X mvprintw(LINES-4,0,"ARMY %d: ",armynum); X clrtoeol(); X if(P_AMOVE==0){ X errormsg("That Unit is Not Able to Move"); X redraw=FALSE; X armornvy=AORN; X return; X } X X /* check if ok to continue if part of army group */ X if(P_ASTAT>=NUMSTATUS) { X mvprintw(LINES-4,10,"Member of Army Group %d!! Continue? ",P_ASTAT-NUMSTATUS); X refresh(); X if( getch() == 'y' ) P_ASTAT=ATTACK; X else { X redraw=FALSE; X armornvy=AORN; X return; X } X } X X /* add up infantry types in army group */ X othermen = groupmen = 0; X if(P_ASTAT==GENERAL) { X x=armynum; X for(armynum=0;armynum<MAXARM;armynum++) X if(curntn->arm[armynum].stat==x+NUMSTATUS){ X if(P_ATYPE<MINLEADER) X groupmen += P_ASOLD; X else othermen += P_ASOLD; X } X armynum=x; X } else if(P_ATYPE<MINLEADER) { X groupmen = P_ASOLD; X } else othermen = P_ASOLD; X } X X clear_bottom(3); X standout(); X mvaddstr(LINES-2,0,"MOVEMENT SCREEN - see documentation"); X clrtoeol(); X mvaddstr(LINES-1,0,"HIT SPACE IF DONE "); X clrtoeol(); X standend(); X move(ycurs,xcurs*2); X refresh(); X X while(done==FALSE){ X valid=TRUE; X if(armornvy==NAVY) mveleft=P_NMOVE; X else mveleft=P_AMOVE; X oldxcurs=xcurs; X oldycurs=ycurs; X switch(getch()) { X case '1': X case 'b': X xcurs--; X ycurs++; X break; X case '4': X case 'h': X xcurs--; X break; X case '2': X case 'j': /*move down*/ X ycurs++; X break; X case '8': X case 'k': /*move up*/ X ycurs--; X break; X case '6': X case 'l': /*move east*/ X xcurs++; X break; X case '3': X case 'n': /*move south-east*/ X ycurs++; X xcurs++; X break; X case '9': X case 'u': /*move north-east*/ X ycurs--; X xcurs++; X break; X case '7': X case 'y': /*move north-west*/ X ycurs--; X xcurs--; X break; X case '': /* redraw map */ X valid=FALSE; X redraw=TRUE; X coffmap(); X /*see within one sector of unit*/ X if(hilmode==3) { X for(i=XREAL-xoffset-1;i<=XREAL-xoffset+1;i++){ X for(j=YREAL-yoffset-1;j<=YREAL-yoffset+1;j++){ X highlight(i,j); X see(i,j); X } X } X for(i=0;i<MAXARM;i++) if(curntn->arm[i].sold>0){ X standout(); X see(curntn->arm[i].xloc-xoffset,curntn->arm[i].yloc-yoffset); X } X for(i=0;i<MAXNAVY;i++) if(curntn->nvy[i].merchant+curntn->nvy[i].warships+curntn->nvy[i].galleys!=0){ X standout(); X see(curntn->nvy[i].xloc-xoffset,curntn->nvy[i].yloc-yoffset); X X } X } else for(i=XREAL-xoffset-1;i<=XREAL-xoffset+1;i++){ X for(j=YREAL-yoffset-1;j<=YREAL-yoffset+1;j++){ X highlight(i,j); X see(i,j); X } X } X move(ycurs,xcurs*2); X refresh(); X break; X case ' ': X valid=FALSE; X if(mveleft>0 && armornvy==ARMY && sct[XREAL][YREAL].altitude==WATER && P_ASTAT==FLIGHT) X errormsg("Please Sir! If we stop here we'll drown"); X else done=TRUE; X break; X default: X beep(); X valid=FALSE; X } X X if (!ONMAP(XREAL,YREAL)) { X errormsg("We refuse to go off the edge of the world"); X valid=FALSE; X xcurs=oldxcurs; X ycurs=oldycurs; X } X /*if valid move check if have enough movement points*/ X if(valid==TRUE) X if(armornvy==ARMY) { X if (P_ASTAT==FLIGHT) { X fmove=flightcost(XREAL,YREAL); X if (movecost[XREAL][YREAL]>0 && fmove>movecost[XREAL][YREAL]) X fmove=movecost[XREAL][YREAL]; X if (fmove<0 || fmove>mveleft) { X beep(); X valid=FALSE; X xcurs=oldxcurs; X ycurs=oldycurs; X } else { X P_AMOVE-=fmove; X if(P_AMOVE==0) done=TRUE; X } X } X else if((movecost[XREAL][YREAL]<0) X ||(movecost[XREAL][YREAL]>mveleft)) { X if(movecost[XREAL][YREAL]>mveleft) X errormsg("Costs Too Much To Move Here!!!"); X else errormsg("Can't Move Here"); X valid=FALSE; X xcurs=oldxcurs; X ycurs=oldycurs; X } else { X X /* CANT MOVE IN NON ALLIED / NON WAR/JIHAD COUNTRIES */ X if((P_ASTAT!=SCOUT) X &&(P_ATYPE!=A_NINJA) X &&(P_ATYPE<MINLEADER || P_ATYPE>=MINMONSTER || P_ASTAT==GENERAL) X &&(sct[XREAL][YREAL].owner!=0) X &&(sct[XREAL][YREAL].owner!=country) X &&(sct[XREAL][YREAL].people>100) X &&(ntn[sct[XREAL][YREAL].owner].dstatus[country]>ALLIED) X &&(curntn->dstatus[sct[XREAL][YREAL].owner]<WAR)){ X errormsg("You May Not Enter Non-Allied Land Without Declaring War."); X valid=FALSE; X xcurs=oldxcurs; X ycurs=oldycurs; X } X else if((sct[XREAL][YREAL].owner!=country) X &&(sct[XREAL][YREAL].owner!=0) X &&(P_ASTAT!=SCOUT) X &&(curntn->dstatus[sct[XREAL][YREAL].owner]==UNMET)){ X errormsg("Can't Enter Unmet Nations Land"); X valid=FALSE; X xcurs=oldxcurs; X ycurs=oldycurs; X } else { X P_AMOVE-=movecost[XREAL][YREAL]; X if(P_AMOVE==0) done=TRUE; X } X } X } else if(armornvy==NAVY) { X X if(abs(movecost[XREAL][YREAL])>mveleft){ X errormsg("Costs Too Much To Move Here!!!"); X valid=FALSE; X xcurs=oldxcurs; X ycurs=oldycurs; X } else if(movecost[XREAL][YREAL] >= 0){ X /* LAND OF SOME TYPE */ X valid=FALSE; X /* check for nearby water */ X for(i=XREAL-1;i<=XREAL+1;i++) X for(j=YREAL-1;j<=YREAL+1;j++) X if(ONMAP(i,j) && sct[i][j].altitude==WATER) valid=TRUE; X X if(valid==FALSE) { X errormsg("There isn't a waterway over there!"); X xcurs=oldxcurs; X ycurs=oldycurs; X } else X if(((sct[XREAL][YREAL].designation==DTOWN) X ||(sct[XREAL][YREAL].designation==DCAPITOL) X ||(sct[XREAL][YREAL].designation==DCITY))){ X /* harbor */ X if(P_NMOVE>=4) P_NMOVE-=4; X else { X errormsg("You need 4 move points for that"); X valid=FALSE; X xcurs=oldxcurs; X ycurs=oldycurs; X } X } else { /* coastland */ X standout(); X if (sct[XREAL][YREAL].owner==country) mvaddstr(LINES-3,0,"Do you wish to land?"); X else mvaddstr(LINES-3,0,"Do you wish to invade?"); X standend(); X clrtoeol(); X refresh(); X if(getch()=='y') { X move(LINES-3,0); X clrtoeol(); X if(P_NMOVE>=4) P_NMOVE=0; X else { X beep(); X valid=FALSE; X xcurs=oldxcurs; X ycurs=oldycurs; X errormsg("You need 4 move points to land"); X move(ycurs,xcurs*2); X refresh(); X } X } else { X move(LINES-3,0); X clrtoeol(); X valid=FALSE; X xcurs=oldxcurs; X ycurs=oldycurs; X move(ycurs,xcurs*2); X refresh(); X } X } X } else if((movecost[XREAL][YREAL]!=(-1)) X &&(P_NGAL(N_LIGHT)!=0||P_NWAR(N_LIGHT)!=0||P_NMER(N_LIGHT)!=0)) { X /* warship going into deep water */ X errormsg("Light Ships May Not Go Into Deep Water!"); X valid=FALSE; X xcurs=oldxcurs; X ycurs=oldycurs; X } else { X P_NMOVE -= abs( movecost[XREAL][YREAL] ); X } X X if(P_NMOVE==0) X done=TRUE; X X } else if(armornvy==AORN){ X errormsg("ERROR - NOT ARMY OR NAVY"); X return; X } X X /*if moved and not done*/ X if((valid==TRUE)&&(done==FALSE)){ X /*check if offmap and correct*/ X coffmap(); X X /*calc enemy soldiers */ X total=0; X if(armornvy==ARMY) { X for(Tnation=0;Tnation<NTOTAL;Tnation++) X if(Tnation!=country) X for(Tarmynum=0;Tarmynum<MAXARM;Tarmynum++) X if((ntn[Tnation].arm[Tarmynum].sold>0) X &&(ntn[Tnation].arm[Tarmynum].xloc==XREAL) X &&(ntn[Tnation].arm[Tarmynum].yloc==YREAL) X &&((curntn->dstatus[Tnation]>=HOSTILE) X ||(ntn[Tnation].dstatus[country]>=HOSTILE)) X &&(ntn[Tnation].arm[Tarmynum].stat!=SCOUT) X &&(ntn[Tnation].arm[Tarmynum].unittyp!=A_NINJA)) X total+=ntn[Tnation].arm[Tarmynum].sold; X } else { X /*naval total is number of at war WARSHIPS within one sector*/ X for(Tnation=0;Tnation<NTOTAL;Tnation++) X if(Tnation!=country) X for(Tarmynum=0;Tarmynum<MAXNAVY;Tarmynum++) X if((ntn[Tnation].nvy[Tarmynum].warships!=0) X &&(ntn[Tnation].nvy[Tarmynum].xloc<=XREAL+1) X &&(ntn[Tnation].nvy[Tarmynum].xloc>=XREAL-1) X &&(ntn[Tnation].nvy[Tarmynum].yloc<=YREAL+1) X &&(ntn[Tnation].nvy[Tarmynum].yloc>=YREAL-1) X &&(ntn[Tnation].dstatus[country]>=HOSTILE)) { X total+=SHIPS(ntn[Tnation].nvy[Tarmynum].warships,N_LIGHT); X total+=SHIPS(ntn[Tnation].nvy[Tarmynum].warships,N_MEDIUM); X total+=SHIPS(ntn[Tnation].nvy[Tarmynum].warships,N_HEAVY); X } X } X X move(LINES-3,0); X clrtoeol(); X X /*scouts/ninja and flying units ignore zoc's */ X if((armornvy==ARMY) X &&(P_ASTAT!=SCOUT) X &&(P_ATYPE!=A_NINJA) X &&((P_ATYPE<MINLEADER || P_ASTAT==GENERAL || P_ATYPE>=MINMONSTER)) X &&(P_ASTAT!=FLIGHT)){ X if(groupmen+othermen < total){ X /*stop if you have < total*/ X P_AMOVE=0; X AADJMOV; X errormsg("Zone Of Control - Stopping Movement!"); X } else if(total>0) { X /* remove proportion of starting move */ X P_AMOVE-= total * curntn->maxmove * *(unitmove+(P_ATYPE%UTYPE))/(10*(groupmen+othermen)); X if( P_AMOVE<0 || P_AMOVE>100 ) X P_AMOVE=0; X AADJMOV; X if( P_AMOVE==0 ) X errormsg("Zone Of Control - Stopping Movement"); X else errormsg("Zone Of Control - Reducing Movement"); X } X if( P_AMOVE==0 ) done=TRUE; X } else if((armornvy==NAVY)&&(total>0)){ X /*25% stop if they have > total*/ X if((P_NWAR(N_LIGHT)+P_NWAR(N_MEDIUM)+ X P_NWAR(N_HEAVY) < total) X &&(rand()%4==0)){ X P_NMOVE=0; X NADJMOV; X mvprintw(LINES-3,0,"%d Enemy Warships Sighted ",total); X beep(); X done=TRUE; X } X } X X if( done==FALSE ) { X standout(); X if(armornvy==ARMY){ X mvprintw(LINES-2,0,"MOVESCREEN: move left: %d",P_AMOVE); X if (P_ASTAT==FLIGHT) { X fmove=flightcost(XREAL,YREAL); X if (movecost[XREAL][YREAL]>0 && fmove>movecost[XREAL][YREAL]) X fmove=movecost[XREAL][YREAL]; X printw(" move cost is %d", fmove); X } else printw(" move cost is %d", movecost[XREAL][YREAL]); X } else mvprintw(LINES-2,0,"MOVESCREEN: move left: %d move cost is %d",P_NMOVE,abs(movecost[XREAL][YREAL])); X clrtoeol(); X standend(); X mvaddstr(LINES-1,0,"HIT SPACE IF DONE"); X clrtoeol(); X X /*see within one sector of unit*/ X for(i=XREAL-1;i<=XREAL+1;i++) X for(j=YREAL-1;j<=YREAL+1;j++) if(ONMAP(i,j)) X if(!canbeseen((int)i,(int)j)) { X highlight(i-xoffset,j-yoffset); X see(i-xoffset,j-yoffset); X } X X } X makeside(TRUE); X } X move(ycurs,xcurs*2); X refresh(); X } X X /*at this point you are done with move*/ X /*move unit now to XREAL,YREAL*/ X selector=0; X pager=0; X mvaddstr(LINES-1,0,"DONE MOVEMENT"); X clrtoeol(); X if(armornvy==ARMY){ X X P_AXLOC=XREAL; X P_AYLOC=YREAL; X AADJLOC; X if (P_ASTAT==FLIGHT) { X P_ASTAT=DEFEND; /* landed; must stay on ground */ X AADJSTAT; X /* check for drowning */ X if (sct[XREAL][YREAL].altitude==WATER) { X clear_bottom(0); X mvprintw(LINES-3,0,"Army #%d drowns in water",armynum); X if( P_ATYPE==A_MERCENARY) { X mvprintw(LINES-2,0,"Paying mercenary families %ld talons", *(u_encost+(P_ATYPE%UTYPE)) * P_ASOLD); X curntn->tgold -= *(u_encost+(P_ATYPE%UTYPE)) * P_ASOLD; X } X mvaddstr(LINES-1,60,"HIT ANY KEY"); X refresh(); X getch(); X groupmen=0; X P_ASOLD=0; X AADJMEN; X } X } X AADJMOV; X /*if sector unowned take it*/ X /*first check if occupied*/ X /* if (other owner and unoccupied) or (no owner) you take*/ X if(((P_ATYPE<MINLEADER)||(P_ASTAT==GENERAL)) X &&(P_ASOLD>0)){ X if((groupmen>=TAKESECTOR)&&(SOWN==0 )){ X mvaddstr(LINES-2,0,"Taking Unowned Sector"); X refresh(); X sleep(2); X SOWN=country; X curntn->popularity++; X SADJOWN; X P_AMOVE=0; X AADJMOV; X } else if((sct[P_AXLOC][P_AYLOC].owner!=country) X &&((sct[P_AXLOC][P_AYLOC].designation==DTOWN) X ||(sct[P_AXLOC][P_AYLOC].designation==DCAPITOL) X ||(sct[P_AXLOC][P_AYLOC].designation==DCITY))){ X mvaddstr(LINES-2,0,"Entering Town/City sector"); X refresh(); X sleep(2); X } else if((SOWN!=country) X &&(groupmen>=TAKESECTOR) X &&((occ[XREAL][YREAL]==0) X ||(occ[XREAL][YREAL]==country) X ||(groupmen+othermen > 7*total)) X &&(curntn->dstatus[SOWN]>HOSTILE) X &&(P_ASTAT>=DEFEND)) { /* atk, def, and group */ X /*people flee if not of same race*/ X if((sct[XREAL][YREAL].people>0) X &&(ntn[sct[XREAL][YREAL].owner].race!=curntn->race)) X if(magic(country,SLAVER)==TRUE) { X flee(XREAL,YREAL,0,TRUE); X } else{ X flee(XREAL,YREAL,0,FALSE); X } X mvprintw(LINES-2,0,"TAKING SECTOR"); X refresh(); X sleep(2); X SOWN=country; X curntn->popularity++; X SADJOWN; X P_AMOVE=0; X AADJMOV; X } else if(( sct[XREAL][YREAL].owner!=country ) X &&(total>0) X &&(groupmen<TAKESECTOR)&&(P_ASTAT!=SCOUT) X &&((P_ATYPE<MINLEADER)||(P_ASTAT==GENERAL))){ X clear_bottom(0); X mvprintw(LINES-3,0,"army has too few men (%d) to take sector (need %d) - hit any key",groupmen,TAKESECTOR); X refresh(); X getch(); X } X clrtoeol(); X refresh(); X } X X /*set move for parts of group*/ X if((P_ASOLD>=0)&&(P_ASTAT==GENERAL)) { X x=armynum; X for(armynum=0;armynum<MAXARM;armynum++) X if(curntn->arm[armynum].stat==x+NUMSTATUS){ X P_AXLOC=XREAL; X P_AYLOC=YREAL; X AADJLOC; X P_AMOVE=curntn->arm[x].smove; X AADJMOV; X } X armynum=x; X } X } else if(armornvy==AORN){ X errormsg("Error in move.c"); X return; X } else { X /*else navy*/ X mvprintw(LINES-1,0,"NAVY DONE: "); X clrtoeol(); X P_NXLOC=XREAL; X P_NYLOC=YREAL; X NADJLOC; X NADJMOV; X armynum=P_NARMY; X /* move army but do not take land -- still in ship */ X if((armynum>=0)&&(armynum<MAXARM)) { X P_AXLOC=XREAL; X P_AYLOC=YREAL; X AADJLOC; X P_AMOVE=0; X AADJMOV; X mvprintw(LINES-1,20,"Army (%d) transported",armynum); X } X /*calculate civilian survival*/ X mvused-=P_NMOVE; X if (mvused > LONGTRIP) mvused=LONGTRIP; X if (magic(country,SAILOR)==TRUE) mvused/=2; X if (mvused!=0) mvused= (rand()%mvused); X P_NPEOP = (unsigned char) (P_NPEOP*(LONGTRIP-mvused)/LONGTRIP); X mvprintw(LINES-1,60,"HIT ANY KEY"); X refresh(); X getch(); X } X whatcansee(); X redraw=FALSE; X makemap(); X armornvy=AORN; X} X X/************************************************************************/ X/* GETSELUNIT() returns id of selected unit (army or navy) */ X/* if navy, number is MAXARM+nvynum. set armornvy */ X/* current selected unit is selector/2+4*pager */ X/************************************************************************/ Xint Xgetselunit() X{ X int selunit=(-1); X short armynum=0, nvynum=0; X int count=0; X for(armynum=0;armynum<MAXARM;armynum++){ X if((P_ASOLD>0)&&(P_AXLOC==XREAL)&&(P_AYLOC==YREAL)) { X if((SCRARM*pager)+(selector/2)==count) selunit=armynum; X count++; X } X } X X if(selunit==(-1)){ X for(nvynum=0;nvynum<MAXNAVY;nvynum++) X if(((P_NWSHP!=0)||(P_NMSHP!=0)||(P_NGSHP!=0)) X &&(P_NXLOC==XREAL)&&(P_NYLOC==YREAL)) { X if((SCRARM*pager)+(selector/2)==count) X selunit=MAXARM+nvynum; X count++; X } X } X if(selunit>=0){ X if(selunit>=MAXARM) armornvy=NAVY; X else armornvy=ARMY; X } X return(selunit); X} END_OF_FILE if test 16422 -ne `wc -c <'move.c'`; then echo shar: \"'move.c'\" unpacked with wrong size! fi # end of 'move.c' fi if test -f 'newlogin.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'newlogin.c'\" else echo shar: Extracting \"'newlogin.c'\" \(31441 characters\) sed "s/^X//" >'newlogin.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/*create a new login for a new player*/ X#include <ctype.h> X#include "newlogin.h" X#include "header.h" X#include "data.h" X Xextern int pwater; /* percent water in world (0-100) */ Xextern FILE *fexe, *fopen(); Xextern short country; Xint numleaders; X X/* Teraform the area around somebodies capitol */ X/* this gives everybody some chance of success */ Xvoid Xteraform( x,y,range, chance ) Xint x,y; Xint range,chance; X{ X int i,j; X switch(curntn->race) { X case DWARF: X sct[x][y].altitude=MOUNTAIN; X for(i=x-range;i<=x+range;i++) X for(j=y-range;j<=y+range;j++) X if((i!=x)&&(j!=y)&&(ONMAP(i,j)) X &&(sct[i][j].altitude!=WATER)){ X if (rand()%3==0) X sct[i][j].altitude=MOUNTAIN; X else sct[i][j].altitude=HILL; X X if( rand()%100 < chance ) getmetal( &sct[i][j] ); X } X return; X case ELF: X sct[x][y].vegetation = FOREST; X for(i=x-range;i<=x+range;i++) X for(j=y-range;j<=y+range;j++) X if((i!=x)&&(j!=y)&&(ONMAP(i,j)) X &&(sct[i][j].altitude!=WATER)) { X if (rand()%3==0) X sct[i][j].vegetation=FOREST; X else sct[i][j].vegetation=WOOD; X if( rand()%100 < chance ) getjewel( &sct[i][j] ); X } X return; X case ORC: X sct[x][y].altitude=MOUNTAIN; X for(i=x-range;i<=x+range;i++) X for(j=y-range;j<=y+range;j++) X if((i!=x)&&(j!=y)&&(ONMAP(i,j)) X &&(sct[i][j].altitude!=WATER)) { X if (rand()%3==0) X sct[i][j].altitude=MOUNTAIN; X else sct[i][j].altitude=HILL; X X if( rand()%100 < chance ) { X if(rand()%2==0) X getmetal( &sct[i][j] ); X else getjewel( &sct[i][j] ); X } X } X return; X case HUMAN: X sct[x][y].altitude = CLEAR; X for(i=x-range;i<=x+range;i++) X for(j=y-range;j<=y+range;j++) X if((i!=x)&&(j!=y)&&(ONMAP(i,j)) X &&(sct[i][j].altitude!=WATER)) { X if (rand()%2==0) X sct[x][y].altitude = CLEAR; X X if (rand()%2==0) X sct[i][j].vegetation=WOOD; X else sct[i][j].vegetation=GOOD; X X if( rand()%100 < chance ) { X if (rand()%2==0) X getmetal( &sct[i][j] ); X else getjewel( &sct[i][j] ); X } X } X return; X } X} X Xvoid Xmailtopc(string) Xchar *string; X{ X int ctry; X for( ctry=0; ctry<NTOTAL; ctry++){ X if((ctry==0)||(ispc(ntn[ctry].active))){ X mailopen(ctry); X fprintf(fm,"%s",string); X mailclose(); X } X } X} X Xvoid Xnewlogin() X{ X /* use points to create empire, add if late starter*/ X int points; X char tempc[10]; X int n; X int valid=TRUE; /*valid==FALSE means continue loop*/ X int temp; X int more=TRUE; /*0 if add another player*/ X int loop; X long x; X char tempo[8],strin[80]; X char passwd[PASSLTH+1],*getpass(); X register i; X X printf("\nPreparing to add player\n"); X printf("break at any time to abort\n"); X X while(more==TRUE) { X points=MAXPTS; X /*find valid nation number type*/ X for(i=1;i<NTOTAL;i++) X if(ntn[i].active==INACTIVE) { X country=i; X curntn = &ntn[country]; X break; X } X printf("first valid nation id is %d\n",country); X X if(i==NTOTAL) { X beep(); X printf("error, cant add new nation\n"); X return; X } X X /* open output for future printing*/ X sprintf(tempc,"%s%d",exefile,i); X if ((fexe=fopen(tempc,"w"))==NULL) { X beep(); X printf("error opening %s\n",tempc); X exit(FAIL); X } X X valid=FALSE; X /*get name*/ X while(valid==FALSE) { X valid=TRUE; X printf("\nwhat name would you like your nation to have:"); X gets(curntn->name); X X if((strlen(curntn->name)<=1) X ||(strlen(curntn->name)>NAMELTH)){ X printf("\ninvalid name"); X valid=FALSE; X } X X /*check if already used*/ X if((strcmp(curntn->name,"god")==0) X ||(strcmp(curntn->name,"unowned")==0)){ X printf("\nname already used"); X valid=FALSE; X } X X for(i=1;i<NTOTAL;i++) X if((i!=country)&&(strcmp(ntn[i].name,curntn->name)==0)) { X printf("\nname already used"); X valid=FALSE; X } X } X X X valid=FALSE; X while(valid==FALSE) { /* password routine */ X strncpy(passwd,getpass("Enter national password (remember this!):"),PASSLTH); X strncpy(curntn->passwd,getpass("Please reenter password:"),PASSLTH); X if((strlen(passwd)<2) X ||(strncmp(curntn->passwd,passwd,PASSLTH)!=0)){ X beep(); X printf("\ninvalid user password\n"); X } else valid=TRUE; X } X strncpy(curntn->passwd,crypt(passwd,SALT),PASSLTH); X X /*get your name*/ X valid=FALSE; X while(valid==FALSE) { X valid=TRUE; X printf("\nEnter the name of your country's leader (Groo, The Ed, Gandalf...)"); X printf("\n\t(maximum %d characters):",LEADERLTH); X gets(tempc); X if((strlen(tempc)>LEADERLTH)||(strlen(tempc)<2)) { X beep(); X printf("\ninvalid name (too short or long)"); X valid=FALSE; X } X else strcpy(curntn->leader,tempc); X } X X valid=FALSE; X while(valid==FALSE) { X valid=TRUE; X printf("\nwhat race would you like to be:"); X printf("\n\tchoose (d)warf,(e)lf,(o)rc,(h)uman:"); X scanf("%1s",tempo); X switch(tempo[0]) { X case 'd': X printf("\ndwarf chosen\n"); X /*MINER POWER INATE TO DWARVES*/ X printf("Dwarves have MINING skills\n"); X curntn->powers=MINER; X x=MINER; X CHGMGK; X points -= getclass(DWARF); X curntn->race=DWARF; X curntn->tgold=NLDGOLD; X curntn->tfood=NLDFOOD; X curntn->jewels=NLDJEWEL; X curntn->metals=NLDMETAL; X curntn->tciv= NLDCIVIL; X curntn->tmil= NLDMILIT; X curntn->repro= NLDREPRO; X curntn->maxmove= NLDMMOVE; X curntn->aplus= NLDAPLUS; X curntn->dplus= NLDDPLUS; X curntn->location=RANDOM; X points-=startcost(); X break; X case 'e': X printf("\nelf chosen\n"); X printf("Elves are magically cloaked (VOID power)\n"); X curntn->powers=THE_VOID; X x=THE_VOID; X CHGMGK; X points -= getclass(ELF); X curntn->race=ELF; X curntn->tgold=NLEGOLD; X curntn->tfood=NLEFOOD; X curntn->jewels=NLEJEWEL; X curntn->metals=NLEMETAL; X curntn->tciv=NLECIVIL; X curntn->tmil=NLEMILIT; X curntn->repro=NLEREPRO; X curntn->maxmove=NLEMMOVE; X curntn->aplus=NLEAPLUS; X curntn->dplus=NLEDPLUS; X curntn->location=FAIR; X points-=startcost(); X break; X case 'o': X printf("\norc chosen\n"); X /*MINOR MONSTER POWER INATE TO ORCS*/ X printf("your leader is a monster!\n"); X curntn->powers=MI_MONST; X x=MI_MONST; X CHGMGK; X points -= getclass(ORC); X curntn->race=ORC; X curntn->tgold=NLOGOLD; X curntn->tfood=NLOFOOD; X curntn->jewels=NLOJEWEL; X curntn->metals=NLOMETAL; X curntn->tciv=NLOCIVIL; X curntn->tmil=NLOMILIT; X curntn->repro=NLOREPRO; X curntn->maxmove=NLOMMOVE; X curntn->aplus=NLOAPLUS; X curntn->dplus=NLODPLUS; X curntn->location=RANDOM; X points-=startcost(); X break; X case 'h': X printf("\nhuman chosen\n"); X curntn->race=HUMAN; X printf("Humans have the combat skill of a WARRIOR\n"); X curntn->powers = WARRIOR; X x=WARRIOR; X CHGMGK; X points -= getclass(HUMAN); X curntn->tgold=NLHGOLD; X curntn->tfood=NLHFOOD; X curntn->jewels=NLHJEWEL; X curntn->metals=NLHMETAL; X curntn->tciv=NLHCIVIL; X curntn->tmil=NLHMILIT; X curntn->repro=NLHREPRO; X curntn->maxmove=NLHMMOVE; X curntn->aplus=NLHAPLUS; X curntn->dplus=NLHDPLUS; X curntn->location=RANDOM; X points-=startcost(); X break; X default: X printf("\ninvalid race\n "); X valid=0; X } X } X X valid=FALSE; X if( curntn->race == ORC ) { /* orcs are always evil */ X valid=TRUE; X curntn->active=PC_EVIL; X } X while(valid==FALSE) { X valid=TRUE; X printf("\nplease enter alignment ((g)ood,(n)eutral,(e)vil): "); X scanf("%1s",tempo); X switch(tempo[0]) { X case 'g': curntn->active=PC_GOOD; break; X case 'n': curntn->active=PC_NEUTRAL; break; X case 'e': curntn->active=PC_EVIL; break; X default : X printf("\nsorry - please enter alignment ((g)ood,(n)eutral,(e)vil): "); X valid=FALSE; X break; X } X } X valid = npctype(curntn->active); X printf("ok... alignment is %s\n",allignment[valid]); X X /* get nation mark */ X valid=FALSE; X curntn->mark= (*curntn->name); X printf("\ntesting first letter of name (%c) for nation mark...",curntn->mark); X if( markok(curntn->mark, TRUE)==TRUE ) X curntn->mark= curntn->mark; X else if( islower(curntn->mark) && X markok( toupper(curntn->mark), TRUE )==TRUE ) X curntn->mark= toupper(curntn->mark); X else if( isupper(curntn->mark) && X markok( tolower(curntn->mark) , TRUE)==TRUE ) X curntn->mark= tolower(curntn->mark); X else while(TRUE) { X printf("\nplease enter new national mark (for maps):"); X printf("\n This can be any of the following:"); X for (tempc[0]='!';tempc[0]<='~';tempc[0]++) { X if( markok( tempc[0], FALSE ) ) X printf(" %c",tempc[0]); X } X printf("\n"); X scanf("%1s",tempc); X if( markok( tempc[0], TRUE ) ){ X curntn->mark=(*tempc); X printf("\nvalid..."); X break; X } X } X X printf("mark currently is %c\n",curntn->mark); X X while(points>0) { X printf("\n\nwhat would you like to buy with your remaining %d points\n\n",points); X printf("\t1. population (%ld/pt):\t\tnow have %ld civilians\n",NLPOP,curntn->tciv); X printf("\t2. more gold talons ($%ld/pt):\tnow have %ld gold talons\n",NLGOLD,curntn->tgold); X printf("\t3. better location (%d pt):\t\tlocation is now is %c\n",NLLOCCOST,curntn->location); X printf("\t4. more soldiers (%ld/pt):\t\tnow have %ld soldiers\n",NLSOLD,curntn->tmil); X if( curntn->race != ORC ){ X printf("\t5. better attack (%d%%/pt):\t\tnow is +%d\n ",NLATTACK,curntn->aplus); X printf("\t6. better defence (%d%%/pt):\t\tnow is +%d\n",NLDEFENCE,curntn->dplus); X printf("\t7. higher reproduction (+%d%%/%d pt):\trate is now %d%%/year\n",NLREPRO,NLREPCOST,curntn->repro); X printf("\t8. higher movement (%d/pt): \t\tnow move %d sectors\n",NLMOVE,curntn->maxmove); X } else { X printf("\t5. better attack (%d%%/pt):\t\tnow is +%d\n ",NLATTACK/2,curntn->aplus); X printf("\t6. better defence (%d%%/pt):\t\tnow is +%d\n",NLDEFENCE/2,curntn->dplus); X printf("\t7. higher reproduction (+%d%%/%d pt):\trate is now %d%%/year\n",NLREPRO_ORC,NLREPCOST,curntn->repro); X } X printf("\t9. double raw resources (%ld pts): \tfood now %ld\n",NLDBLCOST*curntn->tfood/NLHFOOD,curntn->tfood); X printf("\t \tjewels now %ld\n",curntn->jewels); X printf("\t \tmetals now %ld\n",curntn->metals); X printf("\t10. additional random magic power (%d pts)\n",NLMAGIC); X printf("\t11. additional %d leaders (%d pts)\tnation has %d %ss\n",NLEADER,NLEADPT,numleaders,unittype[getleader(curntn->class)%UTYPE]); X X printf("\nWhat option to buy:"); X if(scanf("%d",&n)==1) switch(n) { X X case 1: X printf("additional population costs 1 pt per %d\n",NLPOP); X printf("how many points to spend on population:"); X scanf("%d",&temp); X putchar('\n'); X if(points >= temp) { X points -= temp; X curntn->tciv+=temp*NLPOP; X } X else printf("You dont have enough points left"); X break; X case 2: X printf("you now have $%ld gold talons\n",curntn->tgold); X printf("and can buy more at $%ld per point\n",NLGOLD); X printf("how many points to spend on added gold talons:"); X scanf("%d",&temp); X putchar('\n'); X if(points>=temp) X { X points-=temp; X curntn->tgold+=temp*NLGOLD; X } X else printf("You dont have enough points left"); X break; X case 3: X if(curntn->location==GREAT) break; X X if(points>=NLLOCCOST) { X points -=NLLOCCOST; X if(curntn->location==RANDOM){ X curntn->location=FAIR; X } else if(curntn->location==FAIR){ X curntn->location=GREAT; X } X } else { X printf("Too Few Points Left..."); X break; X } X break; X case 4: X printf("you start with %ld soldiers\n",curntn->tmil); X printf("additional military costs 1 / %d\n",NLSOLD); X printf("how many points to spend?"); X scanf("%d",&temp); X putchar('\n'); X if(points >= temp) { X points -= temp; X curntn->tmil+=temp*NLSOLD; X } X else printf("You dont have enough points left"); X break; X case 5: X printf("now have %d percent attack bonus\n",curntn->aplus); X if(curntn->race == ORC ) { X printf("orcs cost additional for combat bonuses\n"); X printf("an additional %d percent per point\n",NLATTACK/2); X } else X printf("an additional %d percent per point\n",NLATTACK); X printf("how many points do you wish to spend?"); X scanf("%d",&temp); X putchar('\n'); X if(points >= temp) { X points -= temp; X if(curntn->race == ORC ) X curntn->aplus+=temp*NLATTACK/2; X else X curntn->aplus+=temp*NLATTACK; X } X else printf("You dont have enough points left"); X break; X case 6: X if(magic(country,VAMPIRE)==1) { X printf("you have vampire power and cant add to combat bonus\n"); X break; X } X printf("now have %d percent defence bonus\n",curntn->dplus); X if(curntn->race == ORC ) { X printf("orcs cost additional for combat bonuses\n"); X printf("an additional %d percent per point\n",NLDEFENCE/2); X } else X printf("an additional %d percent per point\n",NLDEFENCE); X printf("how many points do you wish to spend?"); X scanf("%d",&temp); X putchar('\n'); X if(points >= temp) { X points -= temp; X if(curntn->race == ORC ) X curntn->dplus+=temp*NLDEFENCE/2; X else X curntn->dplus+=temp*NLDEFENCE; X } X else printf("You dont have enough points left"); X break; X case 7: X if(curntn->race==ORC) X printf("repro rate costs %d points per %d percent per year\n",NLREPCOST,NLREPRO_ORC); X else X printf("repro rate costs %d points per %d percent per year\n",NLREPCOST,NLREPRO); X printf("you now have %d percent\n",curntn->repro); X if((curntn->race!=ORC) X &&(curntn->repro>=10)){ X printf("you have the maximum rate"); X break; X } X else if(curntn->repro>=14){ X printf("you have the maximum rate"); X break; X } X printf("how many percentage points to add?:"); X scanf("%d",&temp); X putchar('\n'); X if((points >= (temp*NLREPCOST)) X ||((curntn->race==ORC) X &&(points >= (temp*NLREPCOST/2)))) { X if((curntn->race!=ORC) X &&(curntn->repro+NLREPRO*temp>10)){ X printf("that exceeds the 10%% limit"); X } X else if((curntn->race==ORC) X &&(curntn->repro>14-NLREPRO_ORC*temp)){ X printf("that exceeds the 14%% limit"); X } X else { X if(curntn->race==ORC) X points -= (temp*NLREPCOST/2); X else points -= temp*NLREPCOST; X if(curntn->race==ORC) X curntn->repro+=NLREPRO_ORC*temp; X else curntn->repro+=NLREPRO*temp; X } X } X else printf("You dont have enough points left"); X break; X case 8: X if(curntn->race == ORC ) { X printf("orcs cant add to movement\n"); X break; X } X printf("additional movement costs 1 per +%d sct/turn\n",NLMOVE); X printf("you start with a rate of %d\n",curntn->maxmove); X printf("you now have a rate of %d\n",curntn->maxmove+NLMOVE); X putchar('\n'); X if(points >= 1) { X points -= 1; X curntn->maxmove+=NLMOVE; X } X else printf("You dont have enough points left"); X break; X case 9: X printf("doubling raw materials\n"); X if((curntn->tfood<800000L) X &&(points >=NLDBLCOST*curntn->tfood/NLHFOOD)) { X points-=NLDBLCOST*curntn->tfood/NLHFOOD; X curntn->tfood*=2; X curntn->jewels*=2; X curntn->metals*=2; X } X else printf("sorry\n"); X break; X case 10: X printf("choosing basic magic at %d point cost\n",NLMAGIC); X printf("log in and read the magic screen to be informed of your powers\n"); X if(points >0) { X points-=NLMAGIC; X loop=0; X while(loop==0) if((x=getmagic((rand()%M_MGK+M_MIL)))!=0){ X CHGMGK; X loop=1; X } X } X else printf("sorry not enough points\n"); X break; X case 11: X /* check if not more than 1/2 armies will be leaders */ X if( numleaders + NLEADER > MAXARM/2 ) { X printf("\tsorry... that would give you too many leaders\n"); X break; X } X if( points >= NLEADPT ) { X printf("\tadding %d leaders for %d points\n",NLEADER,NLEADPT); X numleaders += NLEADER; X points -= NLEADPT; X } else printf("sorry not enough points\n"); X break; X default: X printf("invalid option - hit return"); X scanf("%*s"); X } else scanf("%*s"); X } X check(); X X printnat(); X printf("\nhit 'y' if OK?"); X getchar(); X if(getchar()!='y'){ X curntn->active=INACTIVE; X getchar(); X curntn->powers=0; X printf("\n OK, nation deleted\n"); X printf("\nhit return to add another nation"); X printf("\nhit any other key to continue?"); X if(getchar()=='\n') more=TRUE; X else more=FALSE; X putchar('\n'); X fclose(fexe); X } X else { X place(-1,-1); X getchar(); X printf("\nNation is now added to world"); X printf("\nhit return to add another nation"); X printf("\nhit any other key to continue?"); X if(getchar()=='\n') more=TRUE; X else more=FALSE; X putchar('\n'); X att_setup(country); /* setup values ntn attributes */ X fclose(fexe); X sprintf(strin,"NOTICE: Nation %s added to world on turn %d\n",curntn->name,TURN); X mailtopc(strin); X /* cannot clear until after placement and initializing */ X curntn->powers=0; X } X } X att_base(); /* calculate base nation attributes */ X writedata(); X} X Xvoid Xprintnat() X{ X int i; X i=country; X printf("about to print stats for nation %d\n\n",i); X printf("name is .........%s\n",ntn[i].name); X printf("leader is .......%s\n",ntn[i].leader); X printf("total sctrs .....%d\n",ntn[i].tsctrs); X printf("class is ........%s\n",*(Class+ntn[i].class)); X printf("mark is .........%c\n",ntn[i].mark); X printf("race is .........%c\n",ntn[i].race); X printf("attack plus is ..+%d\n",ntn[i].aplus); X printf("defence plus is .+%d\n",ntn[i].dplus); X printf("gold talons......%ld\n",ntn[i].tgold); X printf("maxmove is ......%d sctrs\n",ntn[i].maxmove); X printf("jewels is .......%ld\n",ntn[i].jewels); X printf("# military ......%ld\n",ntn[i].tmil); X printf("# civilians .....%ld\n",ntn[i].tciv); X printf("repro is ........%d percent\n",ntn[i].repro); X printf("total metal .....%ld\n",ntn[i].metals); X printf("total food ......%ld\n",ntn[i].tfood); X printf("total ships .....%d\n",ntn[i].tships); X printf("total leaders ...%d\n",numleaders); X} X X/*****************************************************************/ X/* PLACE(): put nation on the map. Fill out army structures too */ X/*****************************************************************/ Xvoid Xplace(xloc,yloc) Xint xloc,yloc; /* if not -1,-1 should place in this spot */ X{ X int placed=0,armysize=100; X short armynum=0; X long people; X int x,y,i,j,temp,t; X int n=0, leadtype; X long soldsleft; /* soldiers left to place */ X X if( xloc != -1 && yloc != -1 && is_habitable(xloc,yloc)) { X placed=1; X x = xloc; X y = yloc; X } X X switch(curntn->location) { X case OOPS: X while((placed == 0)&&(n++<2000)){ X if(ispc(curntn->active)){ X x = (rand()%(MAPX-8))+4; X y = (rand()%(MAPY-8))+4; X } else { X x = (rand()%(MAPX-2))+1; X y = (rand()%(MAPY-2))+1; X } X if(is_habitable(x,y)) placed=1; X X for(i=x-1;i<=x+1;i++) for(j=y-1;j<=y+1;j++) X if(sct[i][j].owner!=0) placed=0; X temp=0; X for(i=x-1;i<=x+1;i++) for(j=y-1;j<=y+1;j++) X if(sct[i][j].altitude==WATER) temp++; X if(temp>=7) placed=0; X } X teraform( x,y,1,25 ); X break; X case RANDOM: X while ((placed == 0)&&(n++<2000)){ X if(ispc(curntn->active)){ X if(MAPX>12){ X x = rand()%(MAPX-12)+6; X y = rand()%(MAPY-12)+6; X } else { X x = rand()%(MAPX-8)+4; X y = rand()%(MAPY-8)+4; X } X if(is_habitable(x,y)) placed=1; X /*important that no countries near*/ X for(i=x-2;i<=x+2;i++) for(j=y-2;j<=y+2;j++) X if((isntn(ntn[sct[i][j].owner].active)) X &&(sct[i][j].owner!=0)) placed=0; X } else { X x = (rand()%(MAPX-6))+3; X y = (rand()%(MAPY-6))+3; X if(is_habitable(x,y)) placed=1; X /*important that no countries near*/ X for(i=x-2;i<=x+2;i++) for(j=y-2;j<=y+2;j++) X if((isntn(ntn[sct[i][j].owner].active)) X &&(sct[i][j].owner!=0)) placed=0; X } X temp=0; X for(i=x-1;i<=x+1;i++) for(j=y-1;j<=y+1;j++) X if(sct[i][j].altitude==WATER) temp++; X if(temp>=7) placed=0; X for(i=x-1;i<=x+1;i++) for(j=y-1;j<=y+1;j++) X if(sct[i][j].owner!=0) placed=0; X } X teraform( x,y,1,40 ); X break; X case FAIR: X while ((placed == 0)&&(n++<2000)) { X if(ispc(curntn->active)){ X if(MAPX>24) { X x = rand()%(MAPX-24)+12; X y = rand()%(MAPY-24)+12; X } else { X x = rand()%(MAPX-14)+7; X y = rand()%(MAPY-14)+7; X } X } else { X x = rand()%(MAPX-10)+5; X y = rand()%(MAPY-10)+5; X } X X if(!is_habitable(x,y)) continue; X if(tofood( &sct[x][y],country)<DESFOOD) continue; X X placed=1; X for(i=x-1;i<=x+1;i++) for(j=y-1;j<=y+1;j++) X if(sct[i][j].owner!=0) placed=0; X X if(pwater>50) { X temp=0; X for(i=x-1;i<=x+1;i++) for(j=y-1;j<=y+1;j++) X if(sct[i][j].altitude==WATER) temp++; X if(temp>=7) placed=0; X X /*important that no countries near*/ X for(i=x-3;i<=x+3;i++) for(j=y-3;j<=y+3;j++){ X if((isntn(ntn[sct[i][j].owner].active)) X &&(sct[i][j].owner!=0)) placed=0; X } X } else { X temp=0; X for(i=x-1;i<=x+1;i++) for(j=y-1;j<=y+1;j++) X if(sct[i][j].altitude==WATER) temp++; X if(temp>=5) placed=0; X X /*important that no countries near*/ X for(i=x-3;i<=x+3;i++) for(j=y-3;j<=y+3;j++){ X if((isntn(ntn[sct[i][j].owner].active)) X &&(sct[i][j].owner!=0)) placed=0; X } X } X } X X teraform( x,y,1,65 ); X break; X case GREAT: X placed = 0; X while ((placed == 0) && (n++<2000)){ X if(ispc(curntn->active)){ X if (MAPX>40){ X x = rand()%(MAPX-40)+20; X y = rand()%(MAPY-40)+20; X }else{ X x = rand()%(MAPX-18)+9; X y = rand()%(MAPY-18)+9; X } X X if(is_habitable(x,y)) placed=1; X /*important that no countries near*/ X for(i=x-4;i<=x+4;i++) for(j=y-4;j<=y+4;j++){ X if((isntn(ntn[sct[i][j].owner].active)) X &&( sct[i][j].owner!=0)) placed=0; X } X } else { X if(MAPX>24){ X x = rand()%(MAPX-24)+12; X y = rand()%(MAPY-24)+12; X }else { X x = rand()%(MAPX-12)+6; X y = rand()%(MAPY-12)+6; X } X if(is_habitable(x,y)) placed=1; X /*important that no countries near*/ X for(i=x-2;i<=x+2;i++) for(j=y-2;j<=y+2;j++){ X if((isntn(ntn[sct[i][j].owner].active)) X &&(sct[i][j].owner!=0)) placed=0; X } X } X X for(i=x-1;i<=x+1;i++) for(j=y-1;j<=y+1;j++) X if(sct[i][j].owner!=0) placed=0; X X temp=0; X /*if any water within 2 sectors placed = 0*/ X for(i=x-2;i<=x+2;i++) for(j=y-2;j<=y+2;j++) X if(tofood( &sct[x][y],country)<=0) X temp++; X X if( pwater>50 ) { X if(temp>=18) placed=0; X } else { X if(temp>=15) placed=0; X } X } X teraform( x,y,1,100 ); X } X X /*done with one try*/ X if(placed==1) { X curntn->capx = x; X curntn->capy = y; X sct[x][y].designation=DCAPITOL; X sct[x][y].tradegood=rand()%(END_KNOWLEDGE-END_SPOILRATE)+END_SPOILRATE+1; X sct[x][y].jewels=0; X sct[x][y].metal=0; X sct[x][y].owner=country; X sct[x][y].people=curntn->tciv; X sct[x][y].fortress=5; X X /* put all military into armies of armysize */ X armysize = (TAKESECTOR*12)/10; X if(armysize<100) armysize=100; X /* cant have more than 50% leaders */ X if( MAXARM < numleaders * 2 ) numleaders = MAXARM / 2; X armynum=0; X soldsleft = curntn->tmil; X P_ASOLD = curntn->tmil/MILINCAP; X soldsleft-=P_ASOLD; X P_ATYPE=defaultunit(country); X P_ASTAT=GARRISON; X P_AMOVE=0; X P_AXLOC=curntn->capx; X P_AYLOC=curntn->capy; X armynum++; X X armysize = max( armysize, soldsleft / (MAXARM-numleaders-1)); X X /* give you your leaders */ X leadtype = getleader(curntn->class); X P_ATYPE = leadtype-1; /* This is the national leader */ X P_ASOLD = *(unitminsth+((leadtype-1)%UTYPE)); X P_AXLOC = curntn->capx; X P_AYLOC = curntn->capy; X P_ASTAT = DEFEND; X P_AMOVE = 2*curntn->maxmove; X armynum++; X numleaders--; X while ((armynum < MAXARM)&&(numleaders>0)) { X P_ATYPE=leadtype; X P_ASOLD= *(unitminsth+(leadtype%UTYPE)); X P_AXLOC=curntn->capx; X P_AYLOC=curntn->capy; X P_ASTAT=DEFEND; X P_AMOVE=2*curntn->maxmove; X armynum++; X numleaders--; X } X X /* give you the rest of your armies */ X while((armynum < MAXARM)&&(soldsleft >0)) { X P_ATYPE=defaultunit(country); X if(soldsleft >= armysize){ X P_ASOLD=armysize; X soldsleft -=armysize; X } else { X P_ASOLD=soldsleft ; X soldsleft=0; X } X P_AXLOC=curntn->capx; X P_AYLOC=curntn->capy; X P_ASTAT=DEFEND; X P_AMOVE=curntn->maxmove; X armynum++; X } X X if(soldsleft >0) { X curntn->arm[0].sold += soldsleft; X curntn->arm[0].unittyp = A_INFANTRY; X } X X /* give you some terain to start with: pc nations get more*/ X if ((isnotpc(curntn->active))&&(curntn->location==GREAT)) t=1; X else if (isnotpc(curntn->active)) t=1; X else if (curntn->location==OOPS) t=0; X else if (curntn->location==RANDOM) t=0; X else if (curntn->location==FAIR) t=1; X else if (curntn->location==GREAT) t=2; X else printf("error"); X if( t==1 ) X people = sct[x][y].people / 12; X else if( t==2 ) X people = sct[x][y].people / 18; X X curntn->tsctrs=1; X for(i=x-t;i<=x+t;i++) for(j=y-t;j<=y+t;j++) X if((tofood( &sct[i][j],country)>=DESFOOD) X &&(sct[i][j].owner==0) X &&(is_habitable(i,j)==TRUE) X &&(sct[i][j].people==0)) { X curntn->tsctrs++; X sct[i][j].owner=country; X sct[i][j].designation=DFARM; X sct[i][j].people=people; X sct[x][y].people-=people; X } X } X else { X if(curntn->location==OOPS) printf("ERROR\n"); X else if(curntn->location==RANDOM) { X printf("RANDOM PLACE FAILED, TRYING TO PLACE AGAIN\n"); X curntn->location=OOPS; X place(-1,-1); X } X else if(curntn->location==FAIR) { X printf("FAIR PLACE FAILED, TRYING AGAIN - adding %d people to nation\n",NLPOP); X /*give back one point -> NLPOP people*/ X curntn->tciv+=NLPOP; X curntn->location=RANDOM; X place(-1,-1); X } X else if(curntn->location==GREAT) { X printf("GOOD PLACE FAILED, TRYING AGAIN - adding %d people to nation\n",NLPOP); X /*give back one point -> NLPOP people*/ X curntn->tciv+=NLPOP; X curntn->location=FAIR; X place(-1,-1); X } X } X} X X/*get class routine*/ X/* return the number of points needed */ Xint Xgetclass(race) X{ X short chk=FALSE; X short tmp; X while(chk==FALSE){ X printf("what type of nation would you like to be\n"); X if(race!=ORC){ X printf("1. king (Humans, Dwarves, and Elves)\n"); X printf("2. emperor (Humans, Dwarves, and Elves)\n"); X } X if((race!=ORC)&&(race!=DWARF)){ X printf("3. wizard (Humans and Elves)..................Cost = %d Points\n",2*NLMAGIC); X printf("\tWizards have WYZARD and SUMMON powers. \n"); X } X if(race==HUMAN){ X printf("4. theocracy (Humans Only).......................Cost = %d Points\n",NLMAGIC); X printf("\tTheocracies have RELIGION power. \n"); X } X if((race==HUMAN)||(race==ORC)||(race==DWARF)){ X printf("5. pirate (No Elves)..........................Cost = %d Points\n",NLMAGIC); X printf("\tPirates have SAILOR power\n"); X } X if((race==ELF)||(race==HUMAN)){ X printf("6. trader (Humans & Elves Only)...............Cost = %d Points\n",NLMAGIC); X printf("\tTraders have URBAN power\n"); X } X if(race==HUMAN) { X printf("7. warlord (No Elves)..........................Cost = %d Point\n",((int)(2*NLMAGIC*8/10))); X printf("\tHuman Warlords get CAPTAIN, and WARLORD powers\n"); X } else if((race==ORC)||(race==DWARF)) { X printf("7. warlord (No Elves)..........................Cost = %d Points\n",((int)(3*NLMAGIC*8/10))); X printf("\tWarlords get WARRIOR, CAPTAIN, and WARLORD powers\n"); X } X if( race==ORC) { X printf("8. demon (Orcs Only).........................Cost = %d Points\n",4*NLMAGIC/3); X printf("\tDemons have DESTROYER power\n"); X printf("9. dragon (Orcs Only).........................Cost = %d Points\n",((int)(3*NLMAGIC*7/10))); X printf("\tDragons have MINOR, AVERAGE, and MAJOR MONSTER powers\n"); X printf("10. shadow (Orcs Only)........................Cost = %d Points\n",NLMAGIC); X printf("\tShadows have VOID power\n"); X } X printf("\tinput:"); X scanf("%hd",&tmp); X if((tmp>C_NPC)&&(tmp<=C_END)) { X if((race==HUMAN)&&((tmp<=C_WARLORD))) X chk=TRUE; X else if((race==DWARF)&&((tmp<C_WIZARD)||(tmp==C_PIRATE)||(tmp==C_WARLORD))) X chk=TRUE; X else if((race==ELF)&&((tmp==C_TRADER)||(tmp<=C_WIZARD))) X chk=TRUE; X else if((race==ORC)&&((tmp==C_PIRATE)||(tmp>=C_WARLORD))) X chk=TRUE; X else printf("bad input \n\n\n"); X } else { X printf("\tinvalid input\n\n\n"); X getchar(); X } X } X curntn->class=tmp; X return( doclass( tmp, TRUE ) ); X} X Xint Xdoclass( tmp, isupd ) Xshort tmp; Xint isupd; /* true if update, false if interactive */ X{ X short i; X long x; X X /* determine number of leaders you want */ X if((tmp == C_TRADER) || (tmp <= C_WIZARD)) X numleaders = 5; X else numleaders = 7; X X switch(tmp){ X case C_WIZARD: X curntn->powers |= SUMMON; X x=SUMMON; X if( isupd ) CHGMGK; X curntn->powers |= WYZARD; X x=WYZARD; X if( isupd ) CHGMGK; X return(2*NLMAGIC); X case C_PRIEST: X curntn->powers|=RELIGION; X x=RELIGION; X if( isupd ) CHGMGK; X return(NLMAGIC); X case C_PIRATE: X curntn->powers|=SAILOR; X x=SAILOR; X if( isupd ) CHGMGK; X return(NLMAGIC); X case C_TRADER: X curntn->powers|=URBAN; X x=URBAN; X if( isupd ) CHGMGK; X return(NLMAGIC); X case C_WARLORD: X i=0; X if(magic(country,WARRIOR)!=TRUE){ X curntn->powers|=WARRIOR; X x=WARRIOR; X if( isupd ) CHGMGK; X i++; X } X if(magic(country,CAPTAIN)!=TRUE){ X curntn->powers|=CAPTAIN; X x=CAPTAIN; X if( isupd ) CHGMGK; X i++; X } X if(magic(country,WARLORD)!=TRUE){ X curntn->powers|=WARLORD; X x=WARLORD; X if( isupd ) CHGMGK; X i++; X } X return((int)(i*NLMAGIC*8/10)); /* 20% discount applied */ X case C_DEMON: X curntn->powers|=DESTROYER; X x=DESTROYER; X if( isupd ) CHGMGK; X return((int)(4*NLMAGIC/3)); X case C_DRAGON: X curntn->powers|=MI_MONST; X x=MI_MONST; X if( isupd ) CHGMGK; X curntn->powers|=AV_MONST; X x=AV_MONST; X if( isupd ) CHGMGK; X curntn->powers|=MA_MONST; X x=MA_MONST; X if( isupd ) CHGMGK; X return((int)(3*NLMAGIC*7/10)); /* 30% discount applied */ X case C_SHADOW: X curntn->powers|=THE_VOID; X x=THE_VOID; X if( isupd ) CHGMGK; X return(NLMAGIC); X default: X return(0); X } X} X Xint Xstartcost() /* cant be used for npc nations yet!!! see below */ X{ X float points; /* points */ X X points = ((float)curntn->tciv)/NLPOP; X points += ((float)curntn->tgold)/NLGOLD; X points += ((float)curntn->tmil)/NLSOLD; X if(curntn->race==ORC) { X points += ((float)curntn->repro)*NLREPCOST/(NLREPRO_ORC); X points += ((float)curntn->aplus*2)/NLATTACK; X points += ((float)curntn->dplus*2)/NLDEFENCE; X } else { X points += ((float)curntn->aplus)/NLATTACK; X points += ((float)curntn->dplus)/NLDEFENCE; X points += ((float)curntn->repro)*NLREPCOST/NLREPRO; X } X points += ((float)curntn->maxmove)/NLMOVE; X if(curntn->location==FAIR) X points += NLLOCCOST; X else if(curntn->location==GREAT) X points += 2*NLLOCCOST; X /* points+=NLDBLCOST*curntn->tfood/NLHFOOD; */ X points -= (TURN-1) / LATESTART; /* extra points if you start late */ X if( TURN > 1 ) X printf("point cost for nation %d is %.2f (bonus for latestart is %f)\n",country,points,(float) (TURN-1)/LATESTART); X X points += 1.0; /* round up */ X return((int) points); X} END_OF_FILE if test 31441 -ne `wc -c <'newlogin.c'`; then echo shar: \"'newlogin.c'\" unpacked with wrong size! fi # end of 'newlogin.c' fi if test -f 'txt4' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'txt4'\" else echo shar: Extracting \"'txt4'\" \(5594 characters\) sed "s/^X//" >'txt4' <<'END_OF_FILE' X SECTOR DESIGNATIONS X XFor nations to make use of the sectors that they own, they Xmust indicate what each sector should be used for. The following Xtable lists sector designations and the cost for their designation: X X name symbol gold cost iron cost X ---------------- --------- --------- X ZCITY 20 * XDESCOST 5 * XDESCOST X ZCAPITOL 20 * XDESCOST 5 * XDESCOST X ZTOWN 10 * XDESCOST XDESCOST X ZFORT 10 * XDESCOST XDESCOST X ZSTOCKADE ZSTOCKCOST ---- X XAll of the following designations only cost XDESCOST gold: X X ZMILL ZUNIVERSITY ZCHURCH X ZMINE ZLUMBERYARD ZSPECIAL X ZGOLD ZBLACKSMITH ZGRANARY X ZFARM ZROAD ZRUIN X ZDEVASTATED XEND X DESIGNATION DESCRIPTIONS pg.1 X XZTOWN Towns, Cities, & Capitols are your power bases. You can draft XZCITY troops (if population > civilians / 16+(number of sectors)/2) XZCAPITOL and can build ships here. Town tax=rate*XTAXTOWN talons/person and X City tax=rate*XTAXCITY talons/person. Both cost a lot to redesignate X AND take metal to create. They are captured only if you are the ONLY X occupant of the sector when the world is updated. NPC nations are X destroyed if they lose their capitol. Cities, Towns, and Capitols X add to many of a nations characteristics. XZMINE Mine: Produce (tax/100)*XTAXMETAL*Metal*People Talons & Produces X Metal Ores. Each mine you own adds to your nations mine_ability. XZFARM Produces (tax/100)*XTAXFOOD*Vegetation*People Talons & Produces Food X Each farm you own adds to your nations farm_ability. XZGOLD Produces (tax/100)*XTAXGOLD*Gold*People Talons & Produces Jewels XZDEVASTATED Devastated sector. People dont like to live where devastated. XZRUIN Ruins are devastated Cities. They may be rebuilt at 1/2 price. X They can't be redesignated to anything other than a city. XEND X DESIGNATION DESCRIPTIONS pg.2 X XZFORT Expensive fortress. Cost same as town cost. Only for defense. XZSPECIAL Produces Exotic Trade Goods - see next page. XZSTOCKADE Stockades are minor (+10%) fortresses. They cost ZSTOCKCOST. XZUNIVERSITY produce knowledge points (see nation attributes) XZLUMBERYARD UNUSED XZBLACKSMITH adds to nations mine ability XZROAD Roads add 0.1 to communication ability. 1/2 cost to movement, X but they cost gold to maintain. You may only build 2 each turn. X You must have 100 civilians in a sector to build a road. XZMILL 1.2x food production in one sector range if there are X adequate people in the sector. XZGRANARY these "warehouses" serve as a point to store any food for the X winter. They decrease national spoilrate. XZCHURCH add to your nations popularity and patriotism X Xsector redesignation requires food ability of XDESFOOD (not forts/stockades). XStockade, City, Town, & Fort defences work for defenders with garrison status. XEND X MINE ABILITY & WEALTH X XMine ability impacts your nations ability to mine ores (see below), and Xwealth impacts your nations ability to use specialty luxury items that Xcan be produced in your nation. As such, these are the most important Xattributes your nation has. It is difficult to get these attibutes to XOK levels at the beginning of the game - you must work at it. X Xmine ability = (people in cities,capitols,&towns)/333 + blacksmiths/167 X + (number of metal points being mined)/3 Xadd 15 if the nation has MINER power Xadd 15 if the nation has STEEL power (in addition to miner bonus) X Xwealth = % of worlds gold + % of worlds jewels + % of worlds metal X + cityfolk/1000 + townfolk/2000 X Xadd 30 to wealth if the nation is either a trader or empire class X XThe maximum wealth and mine ability is 100. XEND X METAL X XMany sectors have metal ores. Nations can use these ores if they have the Xappropriate mine ability. The following table details the metal type, Xrequired mine ability, metal production value, and percentage of the world Xmetal sectors containing that type of metal. X X required metal world Xtype mine_ability value percent Xcopper 0 1-2 10% Xlead 8 1-4 10% Xtin 11 2-5 15% Xbronze 15 2-5 20% Xiron 25 2-8 25% Xsteel 30 3-10 15% Xmithral 30 5-15 4% Xadamantine 40 8-20 1% XEND X WEALTH & JEWELS X XJewels is the "generic" name given to any luxury items you can make in Xyour nation. Like iron, certain sectors have an inate ability to produce Xthese luxury goods, which can be used only if the nation has a high enough Xwealth. The following table details the luxury good type, required wealth, Xjewel value, and percentage of the world jewel sectors containing that type Xof good. X X required jewel world Xtype wealth value percent Xspice 0 1-2 20 Xsilver 0 1-3 20 Xpearls 0 1-3 8 Xdye 5 1-5 8 Xsilk 5 1-5 8 Xgold 5 1-6 20 Xrubys 10 1-6 7 Xivory 10 2-8 5 Xdiamonds 20 2-12 3 Xplatinum 20 4-20 1 XEND XDONE END_OF_FILE if test 5594 -ne `wc -c <'txt4'`; then echo shar: \"'txt4'\" unpacked with wrong size! fi # end of 'txt4' fi echo shar: End of archive 7 \(of 14\). cp /dev/null ark7isdone 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