[comp.sources.games] v02i061: conquest - middle earth multi-player game, Part04/05

games-request@tekred.TEK.COM (10/26/87)

Submitted by: ihnp4!mhuxd!smile (E.BARLOW)
Comp.sources.games: Volume 2, Issue 61
Archive-name: conquest/Part04



#! /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 4 (of 5)."
# Contents:  .help Makefile execute.c move.c update.c
# Wrapped by billr@tekred on Mon Oct 26 10:33:07 1987
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f .help -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \".help\"
else
echo shar: Extracting \".help\" \(14239 characters\)
sed "s/^X//" >.help <<'END_OF_.help'
X                           WELCOME TO CONQUEST
X
XCONQUEST is a multi player computer game designed to run under the UNIX 
Xoperating system.  In CONQUEST,  each player is the leader of a nation, 
Xcomposed of people (humans, orcs, elves, dwarves), recourses, and land.  
XEach ruler can customize the nation at creation, by chosing their race and
Xby giving their nation powers (magic, combat factor, location, speed...)
Xand resources (civilians, troops, iron, gold...). Play involves building, 
Xmoving, and controlling armies and navies, diplomacy with other players, 
Xand adjusting economic activity, which is primarily geared to the production 
Xof gold for your treasury.  Iron is needed, however to build ships & armies, 
Xand food is needed to prevent revolts and keep people alive.  
X
XCommand line format: conquest [-maxhp]	-m   make a world
X					-a   add new player
X            				-x   execute program
X            				-h   print this help text
X            				-p   print a map to stdout
XEND
X 			CONQUEST COMMAND HELP SCREEN
X
X    MOVEMENT 	       		COMMANDS 		   ADMINISTRATION
X'h': move west 		    'a': army report		'p': pick item 
X'y': move north-west 	    'r': redesignate		'd': change display 
X'k': move north 	    'ctrl-L': redraw screen	'c': administration
X'u': move north-east	    'm': move selected unit 	'?': help screen
X'l': move east 		    'A': adjust army 		's': score
X'n': move south-east 	    'f': fleet report		'B': budget status 
X'j': move south		    'Z': move people 2 Sectors 	'P': production stats
X'b': move south west 	    'S': diplomacy status  	'N': read newspaper
X'J': scroll south 	    'Q': quit			'W': write message
X'K': scroll north 	    'M': magic   		'R': read messages
X'L': scroll east 	    'C': construct
X'H': scroll west 	    'D': draft
X	
XEND
X				THE WORLD
X
XThe Conquest 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.
XConquest can be played solitaire.  The computer uses an highly intelligent
Xmovement algorithm to run the armies and navies of these non player
Xnations, and has intelligent algorithms built in that control these nations
Xdiplomacy, 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.
X
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, vegitation...).   For example;
X
XSECTOR ELEVATIONS include:	WATER    '~'   	PEAK     '#' 
X		MOUNTAIN '^'	HILL     '%'	CLEAR    '-' 
X
XSECTOR VEGETATION
XUninhabitable Areas (do not produce food and people simply do not like)
X     VOLCANO   'V'	DESERT 'D'     JUNGLE  'J'
X     WASTE     'W'	ICE 'I'        SWAMP  'S'
X
XInhabitable (people like, number is relative value of food production)
X     LIGHT VEGETATION 	'6'         GOOD   '9'     FOREST   '3'
X     WOOD      		'7'         BARREN '4'
X
XCONQUEST is designed so each race likes their appropriate terrain.  Elves 
Xlike woods & forests,  Humans like good & light vegitation, and Orcs and 
XDwarves like hills and mountains.
XEND
X                     	RACES OF THE WORLD
X
XORC	'O'  	Poor at combat but they reproduce like mad.  Orcs reproduce
X		like mad, and can go over 10% reproduction ceiling. 
X		They are lousy fighters and are led by a minor monster, which 
X		means their army #0 is very potent.
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		iron/jewels, and thus build up their combat skills and powers.
XHUMAN	'H'	The Flexible race, above average at everything.  Humans start
X		with reasonable numbers of people, and WARRIOR power, which
X		gives them +10% in all combats.  They have OK reproduction
X		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)  Wandering Nomads Tribes.  Will they leave you alone?
XBARBARIAN  'B' 	(NPC only)  Indigenous natives
XEND
X			POSSIBLE SECTOR DESIGNATIONS
X
X    MINE       'm'   Produces 100*Iron*People Talons + Produces Iron Ores
X    FARM       'f'   Produces 100*Vegetation*People Talons + Produces Food 
X    GOLD MINE  '$'   Produces 100*Gold*People Talons + Produces Jewels 
X    CASTLE     '!'   Fortified Cities of the Lizards (only)
X    DEVASTATED 'x'   devastated sector
X
X    CITY       'c'   Cities and Capitols are the bases of your power.  They
X    CAPITOL    'C'   are the only places you can draft armies or construct 
X		     ships. Drafting only works if the sectors people is
X		     greater than your total civilians divided by the quantity
X		     16+(number of sectors)/2.  Cities give 750 talons per
X		     person and Capitols give 1000 talons per person. Cities and
X		     Capitols cost more to redesignate.
XEND
X			 COSTS
X
XCosts are as follows:
X
X		Ship Maintenance:	$1000/turn
X		Soldier Maintenance:	$25/turn
X		Designation Costs:	$300
X		Fortification:		$1000 * (2**Fort Level)
X		Build Warship:		$3000
X		Build Merchant:		$2000
X		Bribe Nation:		$100000 per level diplomacy
X		Move Civilians:		$50 per civilian
XEND
X                          SCORING & CHARACTER CLASSES
X
XTHIS STUFF IS NOT IMPLEMENTED IN THIS VERSION!!!!
XVictory points are based on your nations class and the following table.
XFor example, an empire gains points by controlling sectors, people, gold, and
Xsoldiers. Some of these types also have magic powers.  
X
X                     Per    1000    1000      100K 100K   100K   Magic  10
X             Races   Sector People  Soldiers  Gold Jewels Iron   Power Ship
X"kingdom"    EDHO    1        1        2       3    0      0      0     0
X"empire"     H       1.5      0        0       0    0      0      0     0
X"wizard"     EH      0        2        1       0    3      5      20    0
X"theocracy"  HO      1        1        0       0    3      0      7     0
X"pirate"     HO      0        0        5       0    10     10     1     5
X"miner"      D       0        0        5       0    10     10     1     5
X"trader"     EHO     1        1        0       0    1      1      1     8
X"tyranny"    DHO     1        1        2       0    1      1      1     0
X"demon"      DHO     1        0        1       0    1      0      10    0
X"dragon"     HO      0        0        0       10   20     0      0     0
X"shadow"     O       1        0        0       0    0      5      0     0
X"NPC"        EDHO    1        1        0       0    1      1      1     0
XEND
X			POSSIBLE ARMY STATUS
X
XMARCH   :Marching doubles army movement at the expense of combat strength.
XSCOUT   :Scouts avoid any enemy, if possible, and can move through hostile
X        :   armies, but must have less than 25 men per army and can not take
X	:   even unowned land.  They are useful to check out the  map and
X        :   to determine the enemy combat strength.
XATTACK  :Armies in this mode can take owned sectors, initiate
X        :   combat, and have they reasonable movement rates.
XDEFEND  :In this mode, can take owned sectors and have good defense 
X        :   and movement, but can not initiate combat.
XGARRISON:This mode offers the strongest defense but is used only in cities
X	:   and castles.  Garrisons may not move.
X
XNote: It takes 75 men to take a sector.  Your attack bonus increases by 
X	5% if you take over a non player country. Fortresses can be built 
X	in cities/capitols at a cost of 1000*(2**fort level) gold pieces.
XEND
X			NON PLAYER NATIONS 
X
XDiplomacy with non player nations is important in this game.  This determines
Xif you get attacked or not.  
X
Xhint;  use your gold talons to bribe non player countries that are at war with
X	you.  It may not work, but may allow you some breathing room and 
X	at some point the gold becomes irrelevant anyway.
Xhint;  you had best not be at war with NPCs when you bribe them.  If you are,
X	you have just wasted your money.
Xhint;  if you are in a mutual confederacy with a non player nation of the
X	same race there is a % chance that they come over to your side!!!
XEND
X			ADDITIONAL NOTES ON COMBAT
X
XLosses per unit are scaled by (1.2 / 1 + combat plus) so if you have a high
X	combat plus your losses will be less.
XYou can expect to take several turns to reduce a large army, especially
X	on a City or Capitol, as the defenders will draft new troops each turn
XShips (believe it or not) are more powerful than you might expect.  They
X	permit you to rapidly relocate large armies or large numbers of
X	civilians to strategic points.  Their movement is 3x that of
X	a land army and they pay 1 move point per sector.  I will warn
X	you, however, that naval combat has not been play tested.
X
XTHE NEXT PAGE IS THE COMBAT RESULTS TABLE			
X	basically the attacker wants a high roll and the defender wants
X	a low roll.
X
XEND
X               6-1 5-1 4-1 3-1 2-1 3-2 5-4 1-1 4-5 2-3 1-2 1-3 1-4 1-5 1-6
X    <--010     30% 40% 40% 55% 60% 65% 65% 85% 100%100%110%110%110%120%130%
X   010-020     20% 30% 35% 45% 50% 55% 55% 65% 75% 85% 100%100%110%110%120%
X   020-030     15% 20% 30% 35% 35% 35% 45% 55% 65% 75% 95% 100%100%110%110%
X   030-040     15% 20% 25% 30% 35% 35% 45% 55% 65% 75% 90% 100%100%110%110%
X   040-050     15% 20% 25% 25% 35% 35% 45% 55% 65% 65% 80% 90% 90% 100%100%
XD  050-060     15% 20% 20% 25% 35% 35% 45% 55% 65% 65% 80% 90% 90% 90% 100%
XI  060-070     15% 15% 20% 20% 25% 30% 35% 45% 55% 55% 75% 85% 90% 90% 100%
XE  070-080     15% 15% 15% 20% 25% 30% 35% 45% 55% 55% 75% 85% 85% 90% 90%
X   080-090     15% 15% 15% 20% 20% 25% 30% 35% 45% 45% 65% 80% 80% 80% 90%
XR  090-100     10% 10% 15% 15% 20% 25% 30% 35% 45% 45% 60% 80% 80% 80% 90%
XO  100-110     10% 10% 10% 15% 15% 20% 30% 35% 45% 45% 60% 70% 70% 70% 80%
XL  110-120     10% 10% 10% 10% 15% 20% 30% 35% 45% 45% 60% 70% 70% 70% 80%
XL  120-130     5%  5%  10% 10% 10% 15% 25% 25% 35% 40% 45% 65% 65% 65% 80%
X   130-140     5%  5%  5%  10% 10% 15% 25% 25% 35% 40% 50% 65% 65% 65% 70%
X   140-150     5%  5%  5%  5%  10% 15% 25% 25% 35% 35% 45% 55% 55% 55% 65%
X   150-160     0%  0%  5%  5%  10% 15% 25% 25% 35% 35% 45% 50% 50% 50% 50%
X   160-170     0%  0%  0%  5%  10% 15% 25% 25% 35% 35% 45% 45% 45% 45% 45%
X   170-180     0%  0%  0%  0%  5%  10% 15% 15% 25% 35% 35% 40% 40% 40% 40%
X   180-190     0%  0%  0%  0%  5%  10% 10% 10% 20% 25% 30% 30% 30% 30% 30%
X   190+++      0%  0%  0%  0%  5%  10% 10% 10% 15% 20% 25% 25% 25% 25% 25%
XEND
X  	                RULES ON IRON, FOOD, AND GOLD
X
XFOOD:      You MUST have enough food to feed your people... One civilian eats 
X	one unit of food, and one soldier eats two units.  If you run out of 
X	food, half the difference of people in cities die.  Your Granary
X	will store 3x your civilian population in food.  The remainder 
X	is converted to gold talons at a rate of 1 per food point.
XIRON:      You need to have iron to draft new military.  Ten iron units
X	will suffice to equip one soldier.  You also need 200 gold talons to 
X	train a soldier. One person produces one iron per point of mineral in 
X	the sector per turn.  An ammount of Iron (based on the number of troops 
X	you have) can be used to buy +1% in 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 used in magic, and 100000 Jewels
X	will buy you one random new power (command M).  You can have 10
X	talons in the treasury for each jewel (gold based economy).  After
X	that, your gold talons will be converted to jewels at a 10:1 ratio.
XEND
X				MAGIC POWERS   
X
XWARRIOR/CAPTAIN/WARLORD: +10% each in combat, 1/2 Enlistment cost
X(MINOR/AVERAGE/MAJOR) MONSTER: (ORCS) Army 0 fights at +20% per level. 
X		Takeover ORC NPC 1%/3%/5% / 20K jewels.  
XSPY        	All enemy troop/civilian strength is shown exactly (even voids)
XKNOWALL		Know all troop strengths and see the whole map (except voids)
XDERVISH    	Desert/ICE sectors => 1 move point, vegitation 6, +30% combat in
XDESTROYER	Vegetation in 3 sectors of capital = Desert.  Act as Dervish. 
XHIDDEN		Nobody can count troops in your armies on map. 
XTHE_VOID	Nobody can see your sectors/armies (appear blank) 
XARCHITECT	Double strength fortresses, Double city revenue.
XVAMPIRE    	50% troops killed become yours, -35% in combat, -2 Move, 0 maint
XHEALER     	+2 repro to 10% limit.  excess repro adds to defense
XMINER      	(DWARVES) 2x iron and jewel production
XBREEDER:        +3% Birth Rate (ORCS ONLY) (beyond 10% limit).  -10% combat.
XURBAN:          +3% Birth Rate to 12% limit.  remainder gives + to move (roads)
XSTEEL:          Additional 2x Iron Production for MINERS.
XARCHER:	        +10% on defense, +30% for garrisons
XCAVALRY:        +10% to attacking combat skill, +6 movement.
XEND
X			FINAL HINTS
X
XYou would be a fool not to buy a reproduction rate of 9-10% percent.
XExtra movement is very useful (especially if your movement is 6)
XBuy civilians instead of military (who dont reproduce).  This assumes
X	that you have a military of about 1500 men for taking land.
XTake as much land as possible in the beginning.
X
XONE NOTE ON HOW THE GAME WORKS>> you will find that when you do something
Xthat effects another country and then logoff/logon, that change will not
Xbe displayed (ie. if you bribe them or overrun one of their armies).  There
Xis no easy fix for this.  The changes occurred!!! the computer knows about
Xthem, and if you logged in as their nation you would see the army gone or
Xthe diplomatic status changed, but you can not see them because only
Xa selected part of the turns total moves are updated when you log in.
X
X<To be added to later>
XEND
XDONE
END_OF_.help
if test 14239 -ne `wc -c <.help`; then
    echo shar: \".help\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f Makefile -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"Makefile\"
else
echo shar: Extracting \"Makefile\" \(2333 characters\)
sed "s/^X//" >Makefile <<'END_OF_Makefile'
X#	MODIFICATION OF THIS FILE COMMITS THE MODIFIER TO FOLLOW THE
X#	THE LIMITED USE CONTRACT CONTAINED IN THE FILE "header.h"
XMAKE	= $(BINROOT)/bin/make
XCC	= $(BINROOT)/bin/cc
XCURSES	= microcurses
XCFLAGS	= -O
XRM	= /bin/rm -f
XLD	= mld
XLDFLAGS	= $(LLDFLAGS)
XEXECUTABLE = .
XDATA = ./lib
XLIB	= /lib
XSHAREDLIB= $(LIB)/crt0s.o $(LIB)/shlib.ifile
X
XOBJ=main.o makeworld.o io.o newlogin.o forms.o commands.o update.o move.o combat.o  execute.o magic.o npc.o reports.o
XFILS=combat.c commands.c execute.c forms.c io.c main.c makeworld.c move.c newlogin.c update.c magic.c npc.c reports.c
XHEADERS=header.h
XSUPT1=.nations Makefile .help README run
XSUPT2=.execute .messages .news
XMISC= MISC/MAGIC MISC/creleader.c MISC/combat.c MISC/io.c MISC/ucommands.c MISC/rivers 
X
Xall: $(OBJ) 
X	@echo phew... it is time to link, link your hands together and pray this works
X	$(CC) $(LDFLAGS) -o $(EXECUTABLE)/conquest $(OBJ) -lcurses -ltermcap
X	@echo YAY!  make install if this is your !first! time.  this will set up
X	@echo permissions and zero appropriate initial files.  have fun
X
Xagain: $(OBJ) 
X	$(CC) $(LDFLAGS) -o $(EXECUTABLE)/conquest $(OBJ) -lcurses -ltermcap
X	@echo ALL MADE
X	cp .help $(DATA)/.help
X	cp .nations $(DATA)/.nations
X	chmod 0600 *
X	chmod +x MISC $(EXECUTABLE) $(DATA)
X
X$(OBJ): header.h 
X
Xlint:
X	lint -u $(FILS) 
X
Xclobber:
X	$(RM) shar1 shar2 shar3 *.o conquest .data core
X	$(RM) $(DATA)/conq.* $(EXECUTABLE)/conquest 
X
Xclean:
X	$(RM) shar1 shar2 shar3 *.o core
X
Xflop:
X	$(RM) core
X	find . -name '*[CrpsEech]' -print | cpio -ocBv > /dev/rfp021
X
Xinstall:
X	if test -d !$(EXECUTABLE) ; \
X	then mkdir $(EXECUTABLE) ; \
X	fi 
X	if test -d !$(DATA) ; \
X	then mkdir $(DATA) ; \
X	fi 
X	cp .help $(DATA)/.help
X	cp .nations $(DATA)/.nations
X	cp run $(DATA)/run
X	> $(DATA)/.execute
X	> $(DATA)/.messages
X	> $(DATA)/.news
X	chmod 0600 *
X	chmod +x MISC $(EXECUTABLE) $(DATA) $(DATA)/run
X	chmod 0666 $(DATA)/.execute
X	chmod 0644 $(DATA)/.help $(DATA)/.news $(DATA)/.messages
X
Xdocs:
X	sed -e "s/^END//g" .help | pr
X
Xshar:
X	makeshar 1 combat.c commands.c forms.c io.c 
X	mv shar.out shar1 
X	makeshar 2  move.c makeworld.c main.c 
X	mv shar.out shar2 
X	makeshar 3 $(SUPT1) $(HEADERS) 
X	mv shar.out shar3
X	makeshar 4 update.c npc.c newlogin.c
X	mv shar.out shar4
X	makeshar 5 execute.c reports.c magic.c
X	mv shar.out shar5
X
Xrmshar:
X	$(RM) shar1
X	$(RM) shar2
X	$(RM) shar3
END_OF_Makefile
if test 2333 -ne `wc -c <Makefile`; then
    echo shar: \"Makefile\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f execute.c -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"execute.c\"
else
echo shar: Extracting \"execute.c\" \(3142 characters\)
sed "s/^X//" >execute.c <<'END_OF_execute.c'
X/*conquest is copyrighted 1986 by Ed Barlow.
X *  I spent a long time writing this code & I hope that you respect this.  
X *  I give permission to alter the code, but not to copy or redistribute
X *  it without my explicit permission.  If you alter the code, 
X *  please document changes and send me a copy, so all can have it.  
X *  This code, to the best of my knowledge works well,  but it is my first
X *  'C' program and should be treated as such.  I disclaim any
X *  responsibility for the codes actions (use at your own risk).  I guess
X *  I am saying "Happy gaming", and am trying not to get sued in the process.
X *                                                Ed
X */
X
X/*EXECUTE THE PROGRAM*/
X#include "header.h"
Xextern short country;
X
Xexecute()
X{
X	FILE *fp, *fopen();
X	int cmd;
X	char comment[20];
X	char temp[10];
X	int armynum;
X	short nation;
X	short int x,y;
X	int execed=0;
X	int done=0;
X	char line[80];
X
X	/*execute in random order*/
X	/*open EXEFILE file*/
X	if ((fp=fopen(EXEFILE,"r"))==NULL) {
X		printf("\nerror on read \n");
X		return(0);
X	}
X
X	/*read in file*/
X	if(fgets(line,80,fp)==NULL) done=1;
X	while(done==0) {
X		/*read and parse a new line*/
X		sscanf(line,"%s %d %hd %d %hd %hd %s",temp,&cmd,&nation,&armynum,&x,&y,comment);
X		if(country==nation) {
X			execed=1;
X			switch(cmd){
X			case XASTAT:		/*Aadjstat*/
X				if((x>0)&&(x<6))  ASTAT=x;
X				break;
X			case XAMEN:	/*Aadjmen*/
X				ASOLD=x;
X				break;
X			case XALOC:	/*Aadjloc*/
X				AXLOC=x;
X				AYLOC=y;
X				break;
X			case XNLOC: /*nadjloc*/
X				ntn[country].nvy[armynum].xloc=x;
X				ntn[country].nvy[armynum].yloc=y;
X				break;
X			case XNASHP: /*nadjshp*/
X				ntn[country].nvy[armynum].merchant=x;
X				ntn[country].nvy[armynum].warships=y;
X				break;
X			case XECNAME:	/*Nadjname*/
X				strcpy(ntn[country].name,comment);
X				break;
X			case XECPAS:	/*Nadjpas*/
X				strncpy(ntn[country].passwd,comment,PASSLTH);
X				break;
X			case XECMARK:	/*Echgmark*/
X				ntn[country].mark=comment[0];
X				break;
X			case XSADES:	/*Sadjdes*/
X				if((sct[x][y].owner==country)||(country==0)) {
X					sct[x][y].designation=comment[0];
X				}
X				if(sct[x][y].designation==DCAPITOL){
X					ntn[country].capx=x;
X					ntn[country].capy=y;
X				}
X				break;
X			case XSACIV:	/*Sadjciv*/
X				sct[x][y].people=armynum;
X				break;
X			case XSIFORT:	/*Sincfort*/
X				sct[x][y].fortress++;
X				break;
X			case XNAGOLD:	/*Nadjgold:*/
X				ntn[country].tgold = armynum;
X				break;
X			case XAMOV:
X				AMOVE=x;
X				break;
X			case XNMOV:
X				ntn[country].nvy[armynum].smove=x;
X				break;
X			case XSAOWN:
X				sct[x][y].owner=country;
X				break;
X			case EDADJ:
X				ntn[country].dstatus[armynum]=x;
X				break;
X			case XNARGOLD:
X				ntn[country].jewels = armynum;
X				break;
X			case XNAIRON:
X				ntn[country].tiron = armynum;
X				break;
X			case INCAPLUS:
X				ntn[country].aplus++;
X				break;
X			case INCDPLUS:
X				ntn[country].dplus++;
X				break;
X			case CHG_MGK:
X				ntn[country].powers*=x;
X				if(ntn[country].powers!=armynum)
X					printf("ERROR ON MAGIC READ");
X				exenewmgk(x);
X			}
X		}
X		if(fgets(line,80,fp)==NULL) done=1;
X	}
X	fclose(fp);
X	/*return 1 if it did something*/
X	if(execed==1) return(1);
X	else return(0);
X}
END_OF_execute.c
if test 3142 -ne `wc -c <execute.c`; then
    echo shar: \"execute.c\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f move.c -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"move.c\"
else
echo shar: Extracting \"move.c\" \(16053 characters\)
sed "s/^X//" >move.c <<'END_OF_move.c'
X/*conquest is copyrighted 1986 by Ed Barlow.
X *  I spent a long time writing this code & I hope that you respect this.  
X *  I give permission to alter the code, but not to copy or redistribute
X *  it without my explicit permission.  If you alter the code, 
X *  please document changes and send me a copy, so all can have it.  
X *  This code, to the best of my knowledge works well,  but it is my first
X *  'C' program and should be treated as such.  I disclaim any
X *  responsibility for the codes actions (use at your own risk).  I guess
X *  I am saying "Happy gaming", and am trying not to get sued in the process.
X *                                                Ed
X */
X
X
X/*include files*/
X#include "header.h"
X#include <ctype.h>
X
Xextern FILE *fexe;
X/*redraw map in this turn if redraw is a 1*/
Xextern short redraw;
Xextern short selector;
Xextern short xcurs,ycurs,xoffset,yoffset;
Xextern short occ[MAPX][MAPY];
Xextern short hilmode;   /*highlight modes: 0=owned sectors, 1= armies, 2=none*/
X
X/* nation id of owner*/
Xextern short country;
Xint armornvy=AORN;	/*is one if navy*/
X
Xmymove()
X{
X	int mveleft;
X	int i,j,x,y;
X	char carried;
X	int total,Tarmynum,Tnation;
X	int startx=0,starty=0;
X	int ctransport=0;	 /*number of civilians to transport*/
X	int valid=0;     /*1 if move was a valid move (you must pay cost)*/
X	short armynum;
X	int oldxcurs,oldycurs;
X	short nvynum;
X	int done=0;	/*done is 1 if done with this move*/
X	int capacity;
X
X	armornvy=AORN;
X	redraw=TRUE;
X	/*get selected army or navy*/
X	if((armynum=getselunit())<0) {
X		standout();
X		beep();
X		mvprintw(LINES-3,0,"ERROR: FAKE UNIT (%d) SELECTED: ",armynum);
X		clrtoeol();
X		mvaddstr(LINES-1,0,"hit return to continue");
X		clrtoeol();
X		standend();
X		refresh();
X		getch();
X		return;
X	}
X
X	/*navy*/
X	if((armynum>=MAXARM)&&(armynum<MAXARM+MAXNAVY)) {
X		nvynum=armynum-MAXARM;
X		armynum=(-1);
X		standout();
X		mvprintw(LINES-3,0,"NAVY %d SELECTED: ",nvynum);
X		standend();
X		clrtoeol();
X		capacity=NMER*SHIPHOLD;
X		if((NMOVE<=0)) {
X			mvprintw(LINES-2,0,"NO MOVE POINTS LEFT on fleet %d",nvynum);
X			beep();
X			redraw=FALSE;
X			clrtoeol();
X			mvaddstr(LINES-1,0,"hit return to continue");
X			clrtoeol();
X			refresh();
X			getch();
X			armornvy=AORN;
X			return;
X		}
X		if(capacity>0){
X			mvaddstr(LINES-2,0,"Transport (a)rmy,(c)iv,(b)oth a & c,(n)othing:");
X			clrtoeol();
X			refresh();
X			carried=getch();
X		}
X		else carried='n';
X
X		/*transport army*/
X		if(carried=='a'||carried=='b'){
X			mvprintw(LINES-2,0,"CAPACITY=%d ;WHAT ARMY TO XPORT?:",capacity);
X			clrtoeol();
X			refresh();
X			scanw("%hd",&armynum);
X			if((armynum<MAXARM)&&(armynum>=0)&&(AXLOC==XREAL)&&(AYLOC==YREAL)){
X				if(ASOLD>capacity){
X					mvaddstr(LINES-1,0,"ERROR: TOO MANY TROOPS");
X					clrtoeol();
X					refresh();
X					getch();
X					armornvy=AORN;
X					return;
X				}
X				else capacity-=ASOLD;
X			}
X			else {
X				mvaddstr(LINES-1,0,"ERROR: INVALID ARMY!");
X				refresh();
X				getch();
X				armornvy=AORN;
X				return;
X			}
X		}
X		/*transport civilians*/
X		if(carried=='c'||carried=='b'){
X			mvprintw(LINES-2,0,"CAPACITY=%d ;HOW MANY CIVILIANS XPORT?:",capacity);
X			clrtoeol();
X			refresh();
X			scanw("%d",&ctransport);
X			if(ctransport>0&&ctransport<=sct[XREAL][YREAL].people&&(ctransport<capacity)){
X				startx=XREAL;
X				starty=YREAL;
X			}
X			else {
X				mvaddstr(LINES-2,0,"NUMBER OF MEN ERROR");
X				refresh();
X				getch();
X				armornvy=AORN;
X				return;
X			}
X		}
X		refresh();
X		standend();
X	}
X	/*army*/
X	else {
X		mvprintw(LINES-3,0,"ARMY %d SELECTED: ",armynum);
X		clrtoeol();
X		if(AMOVE<=0){
X			mvaddstr(LINES-2,0,"NO MOVEMENT POINTS LEFT");
X			clrtoeol();
X			mvaddstr(LINES-1,0,"hit return to continue");
X			clrtoeol();
X			beep();
X			standend();
X			refresh();
X			redraw=FALSE;
X			getch();
X			armornvy=AORN;
X			return;
X		}
X	}
X
X	standout();
X	mvaddstr(LINES-2,0,"MOVEMENT SCREEN");
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==0){
X		valid=1;
X		if(armornvy==NAVY) mveleft=NMOVE;
X		else mveleft=AMOVE;
X		oldxcurs=xcurs;
X		oldycurs=ycurs;
X		switch(getch()) {
X		case 'b':
X			xcurs--;
X			ycurs++;
X			break;
X		case 'h':
X			xcurs--;
X			break;
X		case 'j':		/*move down*/
X			ycurs++;
X			break;
X		case 'k':		/*move up*/
X			ycurs--;
X			break;
X		case 'l':		/*move east*/
X			xcurs++;
X			break;
X		case 'n':		/*move south-east*/
X			ycurs++;
X			xcurs++;
X			break;
X		case 'u':		/*move north-east*/
X			ycurs--;
X			xcurs++;
X			break;
X		case 'y':		/*move north-west*/
X			ycurs--;
X			xcurs--;
X			break;
X		case ' ':
X			valid=0;
X			done=1;
X			break;
X		default:
X			beep();
X			valid=0;
X		}
X
X		/*if valid move check if have enough movement points*/
X		if(valid==1){
X			/*if valid move decrement move rate*/
X			if(armornvy==ARMY) {
X				if((movecost[XREAL][YREAL]<0)||(movecost[XREAL][YREAL]>mveleft)) {
X					beep();
X					valid=0;
X					xcurs=oldxcurs;
X					ycurs=oldycurs;
X				}
X				else {
X					AMOVE-=movecost[XREAL][YREAL];
X					if(AMOVE<=0) done=1;
X				}
X			}
X			/*then navy*/
X			else if(armornvy==NAVY) {
X				if(movecost[XREAL][YREAL]>mveleft) {
X					beep();
X					valid=0;
X					xcurs=oldxcurs;
X					ycurs=oldycurs;
X				}
X				else if(movecost[XREAL][YREAL]>0){
X					standout();
X					mvprintw(LINES-3,0,"DO YOU WISH TO LAND SHIPS?");
X					standend();
X					clrtoeol();
X					refresh();
X					if(getch()=='y') {
X						move(3,0);
X						clrtoeol();
X						done=0;
X						NMOVE=0;
X					}
X					else {
X						move(3,0);
X						clrtoeol();
X						valid=0;
X						xcurs=oldxcurs;
X						ycurs=oldycurs;
X						move(ycurs,xcurs*2);
X						refresh();
X					}
X				}
X				else NMOVE+=movecost[XREAL][YREAL];
X				if(NMOVE<=0) done=1;
X			}
X			else if(armornvy==AORN){
X				mvprintw(LINES-3,0,"AORN ERROR -- aborting hit return");
X				refresh();
X				getch();
X				return;
X			}
X		}
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)&&(ntn[Tnation].arm[Tarmynum].xloc==XREAL)&&(ntn[Tnation].arm[Tarmynum].yloc==YREAL)&&((ntn[country].dstatus[Tnation]>=HOSTILE)||(ntn[Tnation].dstatus[country]>=HOSTILE))&&(ntn[Tnation].arm[Tarmynum].stat!=SCOUT))
X				total+=ntn[Tnation].arm[Tarmynum].sold;
X		}
X		/*naval total is number of at war WARSHIPS within one sector*/
X		else {
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)&&(ntn[Tnation].nvy[Tarmynum].xloc<=XREAL+1)&&(ntn[Tnation].nvy[Tarmynum].xloc>=XREAL-1)&&(ntn[Tnation].nvy[Tarmynum].yloc<=YREAL+1)&&(ntn[Tnation].nvy[Tarmynum].yloc>=YREAL-1)&&(ntn[Tnation].dstatus[country]>=
XHOSTILE))
X				total+=ntn[Tnation].nvy[Tarmynum].warships;
X		}
X
X		/*if moved and not done*/
X		if((valid==1)&&(done==0)){
X			/*check if offmap and correct*/
X			if((xcurs<1)||(ycurs<1)||(xcurs>=(COLS-21)/2)||((ycurs>=LINES-5))||((XREAL)>=MAPX)||((YREAL)>=MAPY)) {
X				clear();
X				offmap();
X				makemap();
X			}
X
X			mvaddstr(LINES-3,0,"                  ");
X
X			if((armornvy==ARMY)&&(ASTAT!=SCOUT)){
X				if((sct[XREAL][YREAL].owner!=0)&&(sct[XREAL][YREAL].owner!=country)&&(sct[XREAL][YREAL].people>100)&&(ntn[sct[XREAL][YREAL].owner].dstatus[country]>FRIENDLY)&&(ntn[country].dstatus[sct[XREAL][YREAL].owner]<WAR)){
X		/*if other owner (with civilians) and not hostile then stop*/
X					beep();
X					mvaddstr(LINES-3,0,"HALT! YOU MAY NOT PASS HERE!");
X					clrtoeol();
X					refresh();
X					AMOVE=0;
X					AADJMOV;
X					done=1;
X				}
X				else if(total>0){
X					/*stop if you have < 2* total*/
X					if(ASOLD < 2 * total){
X						AMOVE=0;
X						AADJMOV;
X						mvprintw(LINES-3,0,"Zone Of Control -- hit return");
X						beep();
X						done=1;
X					}
X					else mvaddstr(LINES-3,0,"SAFE -- hit return");
X				}
X			}
X			else if((armornvy==NAVY)&&(total>0)){
X				/*25% stop if they have > total*/
X				if((ntn[country].nvy[nvynum].warships < total)&&(rand()%4==0)){
X					NMOVE=0;
X					NADJMOV;
X					mvprintw(LINES-3,0,"%d Enemy WarShips Sighted -- hit return",total);
X					beep();
X					done=1;
X				}
X				else mvaddstr(LINES-3,0,"SAFE -- hit return");
X			}
X
X			standout();
X			if(armornvy==ARMY){
X				mvprintw(LINES-2,0,"MOVESCREEN: move left: %d  ",AMOVE);
X			}
X			else mvprintw(LINES-2,0,"MOVESCREEN: move left: %d  ",NMOVE);
X
X			mvprintw(LINES-1,20,"move cost is %d  ",movecost[XREAL][YREAL]);
X			standend();
X			move(ycurs,xcurs*2);
X
X			/*if you just moved off map then see it*/
X			if(inch()==' ') {
X				if(armornvy==ARMY) {
X					AXLOC=XREAL;
X					AYLOC=YREAL;
X				}
X				else if(armornvy==NAVY) {
X					NXLOC=XREAL;
X					NYLOC=YREAL;
X				}
X				makemap();
X			}
X			else {
X				makeside();
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(ntn[country].arm[i].sold>0){
X						standout();
X						see(ntn[country].arm[i].xloc-xoffset,ntn[country].arm[i].yloc-yoffset);
X					}
X					for(i=0;i<MAXNAVY;i++) if(ntn[country].nvy[i].merchant+ntn[country].nvy[i].warships>0){
X						standout();
X						see(ntn[country].nvy[i].xloc-xoffset,ntn[country].nvy[i].yloc-yoffset);
X
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			}
X			move(ycurs,xcurs*2);
X			refresh();
X		}
X	}
X
X	/*at this point you are done with move*/
X	/*move unit now to XREAL,YREAL*/
X	selector=0;
X	mvaddstr(LINES-1,0,"DONE MOVEMENT");
X	clrtoeol();
X	if(armornvy==ARMY){
X		AXLOC=XREAL;
X		AYLOC=YREAL;
X		AADJLOC;
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(ASOLD>=75){
X			if(SOWN==0){
X				mvprintw(LINES-2,0,"TAKING UNOWNED SECTOR");
X				SOWN=country;
X				SADJOWN;
X				AMOVE=0;
X				AADJMOV;
X			}
X			else if((sct[AXLOC][AYLOC].owner!=country)&&((sct[AXLOC][AYLOC].designation==DCITY)||(sct[AXLOC][AYLOC].designation==DCAPITOL))){
X				mvprintw(LINES-2,0,"ENTERING CITY SECTOR");
X			}
X			else if((ASOLD > 7*total)&&(total!=0)){
X				/*over run if > 7x as many*/
X				mvaddstr(LINES-3,0,"OVERRAN HOSTILE ARMY ");
X				AMOVE=0;
X				AADJMOV;
X				x=country;
X				y=armynum;
X				for(Tnation=0;Tnation<MAXNTN;Tnation++) 
X				if(Tnation!=x)
X				for(Tarmynum=0;Tarmynum<MAXARM;Tarmynum++) 
X				if((ntn[Tnation].arm[Tarmynum].xloc==XREAL)&&(ntn[Tnation].arm[Tarmynum].yloc==YREAL)&&((ntn[x].dstatus[Tnation]>=HOSTILE)||(ntn[Tnation].dstatus[x]>=HOSTILE))) {
X					country=Tnation;
X					armynum=Tarmynum;
X					ASOLD=0;
X					AADJMEN;
X				}
X				country=x;
X				armynum=y;
X				if(sct[XREAL][YREAL].owner!=country){
X				if((sct[XREAL][YREAL].people>0)&&(ntn[sct[XREAL][YREAL].owner].race!=ntn[country].race)) flee(XREAL,YREAL,0);
X				SOWN=country;
X				SADJOWN;
X				sct[AXLOC][AYLOC].designation=DDEVASTATED;
X				SADJDES;
X				}
X				beep();
X			}
X			else if((SOWN!=country)&&((occ[XREAL][YREAL]==0)||(occ[XREAL][YREAL]==country))&&(ntn[country].dstatus[SOWN]>HOSTILE)&&((ASTAT==ATTACK)||(ASTAT==DEFEND))) {
X				/*people flee if not of same race*/
X				if((sct[XREAL][YREAL].people>0)&&(ntn[sct[XREAL][YREAL].owner].race!=ntn[country].race)) flee(XREAL,YREAL,0);
X				mvprintw(LINES-2,0,"TAKING SECTOR");
X				SOWN=country;
X				SADJOWN;
X				AMOVE=0;
X				AADJMOV;
X			}
X			clrtoeol();
X			refresh();
X		}
X	}
X	else if(armornvy==AORN){
X		mvprintw(LINES-3,0,"ERROR");
X		return;
X	}
X	else {
X		/*else navy*/
X		mvprintw(LINES-1,0,"NAVY DONE: ");
X		clrtoeol();
X		NXLOC=XREAL;
X		NYLOC=YREAL;
X		NADJLOC;
X		NADJMOV;
X		if((carried=='a'||carried=='b')&&(sct[XREAL][YREAL].altitude!=WATER)&&(armynum>=0)&&(armynum<MAXARM)) {
X			AXLOC=XREAL;
X			AYLOC=YREAL;
X			AADJLOC;
X			AMOVE=0;
X			AADJMOV;
X			/*take unowned land*/
X			if(SOWN==0) {
X				SOWN=country;
X				SADJOWN;
X			}
X		}
X		/*land civilians*/
X		if((carried=='b'||carried=='c')&&(sct[XREAL][YREAL].altitude!=WATER)&&(ctransport>0)) {
X			if(SOWN==country) {
X				sct[XREAL][YREAL].people+=ctransport;
X				SADJCIV;
X				sct[startx][starty].people-=ctransport;
X				i=startx;
X				j=starty;
X				SADJCIV2;
X			}
X			else mvprintw(LINES-3,0,"cant move people to %d,%d as unowned",XREAL,YREAL);
X		}
X	}
X	redraw=FALSE;
X	makemap();
X	armornvy=AORN;
X}
X
X/*movecost contains movement cost unless water (-1) or unenterable land (-2)*/
Xupdmove(race)
X{
X	int i,j;
X	int x,y;
X	int onecost;
X	int twocost;
X	char *HVegcost=  "83210000232E";
X	char *OVegcost=  "52100012517E";
X	char *EVegcost=  "86221000017E";
X	char *DVegcost=  "57100013577E";
X	char *XVegcost=  "83210001232E";	/*others*/
X	char *HElecost=  "E321E";
X	char *OElecost=  "E211E";
X	char *EElecost=  "E631E";
X	char *DElecost=  "E211E";
X	char *XElecost=  "E321E";  		/*others*/
X
X	for(x=0;x<MAPX;x++) for(y=0;y<MAPX;y++){
X
X		onecost=(-1);
X		twocost=(-1);
X		if(race==GOD) movecost[x][y]=0;
X		else if(sct[x][y].altitude==WATER) movecost[x][y]=(-1);
X		else if(((magic(country,DERVISH)==1)||(magic(country,DESTROYER)==1))&&((sct[x][y].vegitation==ICE)||(sct[x][y].vegitation==DESERT))) movecost[x][y]=1;
X		else {
X			for(j=0;j<=10;j++) if(sct[x][y].vegitation==*(veg+j))
X				for(i=0;i<=9;i++) switch(race) {
X				case ELF:
X					if(*(EVegcost+j)==*(numbers+i)) onecost=i;
X					break;
X				case DWARF:
X					if(*(DVegcost+j)==*(numbers+i)) onecost=i;
X					break;
X				case ORC:
X					if(*(OVegcost+j)==*(numbers+i)) onecost=i;
X					break;
X				case HUMAN:
X					if(*(HVegcost+j)==*(numbers+i)) onecost=i;
X					break;
X				default:
X					if(*(XVegcost+j)==*(numbers+i)) onecost=i;
X					break;
X				}
X
X			for(j=0;j<=4;j++) if(sct[x][y].altitude==*(ele+j)) for(i=0;i<=9;i++) switch(race) {
X			case ELF:
X				if(*(EElecost+j)==*(numbers+i)) twocost=i;
X				break;
X			case DWARF:
X				if(*(DElecost+j)==*(numbers+i)) twocost=i;
X				break;
X			case ORC:
X				if(*(OElecost+j)==*(numbers+i)) twocost=i;
X				break;
X			case HUMAN:
X				if(*(HElecost+j)==*(numbers+i)) twocost=i;
X				break;
X			default:
X				if(*(XElecost+j)==*(numbers+i)) twocost=i;
X				break;
X			}
X
X			if(onecost==-1) movecost[x][y]=(-2);
X			else if(twocost==-1) movecost[x][y]=(-2);
X			else movecost[x][y]=onecost+twocost;
X		}
X	}
X}
X
X/*get selected army or navy: navy number is MAXARM+nvynum*/
Xgetselunit()
X{
X	int number=(-1);
X	short armynum=0;
X	short nvynum=0;
X	int count=0;
X	/*count is order of that army in sector*/
X	/*armynum is number of that army*/
X	for(armynum=0;armynum<MAXARM;armynum++){
X		if((ASOLD>0)&&(AXLOC==XREAL)&&(AYLOC==YREAL)) {
X			if(selector==count*2) number=armynum;
X			count++;
X		}
X	}
X
X	if(number==(-1)){
X		for(nvynum=0;nvynum<MAXNAVY;nvynum++)
X			if((NMER+NWAR>0)&&(NXLOC==XREAL)&&(NYLOC==YREAL)) {
X				if(selector==2*(count)) number=MAXARM+nvynum;
X				count++;
X			}
X	}
X	if(number>=0){
X		if(number>=MAXARM) armornvy=NAVY;
X		else armornvy=ARMY;
X	}
X	return(number);
X}
X
Xflee(x,y,z)
X{
X	/*count is number of acceptable sectors*/
X	int count=0;
X	int i,j;
X	/*flee*/
X	/*check if next to anybody of the sectors owners race*/
X	for(i=x-2;i<=x+2;i++) for(j=y-2;j<=y+2;j++)
X		if(i>=0&&i<MAPX&&j>=0&&j<MAPY&&(ntn[sct[i][j].owner].race==ntn[sct[x][y].owner].race)) count++;
X
X	if(count>0) {
X	mvaddstr(LINES-2,20,"CIVILIANS ABANDON SECTOR");
X	for(i=x-2;i<=x+2;i++) for(j=y-2;j<=y+2;j++)
X		if(i>=0&&i<MAPX&&j>=0&&j<MAPY&&(ntn[sct[i][j].owner].race==ntn[sct[x][y].owner].race)) {
X			sct[i][j].people += sct[x][y].people / count;
X			if(z==0) SADJCIV2;
X		}
X	}
X	else {
X	sct[x][y].people /= 2;
X	for(i=x-4;i<=x+4;i++) for(j=y-4;j<=y+4;j++)
X		if(i>=0&&i<MAPX&&j>=0&&j<MAPY&&(ntn[sct[i][j].owner].race==ntn[sct[x][y].owner].race)) count++;
X	if(count>0) {
X	mvaddstr(LINES-2,20,"PEOPLE FLEE SECTOR AND HALF DIE");
X	for(i=x-4;i<=x+4;i++) for(j=y-4;j<=y+4;j++)
X		if(i>=0&&i<MAPX&&j>=0&&j<MAPY&&(ntn[sct[i][j].owner].race==ntn[sct[x][y].owner].race)) {
X			sct[i][j].people += sct[x][y].people / count;
X			if(z==0) SADJCIV2;
X		}
X	}
X	else mvaddstr(LINES-2,20,"PEOPLE IN SECTOR DIE");
X	}
X
X	sct[x][y].people = 0;
X	if(z==0) SADJCIV;
X	sct[x][y].fortress=0;
X	/*SINFORT;*/
X	if(isdigit(sct[XREAL][YREAL].vegitation)!=0) {
X		sct[x][y].designation=DDEVASTATED;
X		if(z==0) SADJDES2;
X	}
X}
END_OF_move.c
if test 16053 -ne `wc -c <move.c`; then
    echo shar: \"move.c\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f update.c -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"update.c\"
else
echo shar: Extracting \"update.c\" \(15212 characters\)
sed "s/^X//" >update.c <<'END_OF_update.c'
X/*conquest is copyrighted 1986 by Ed Barlow.
X *  I spent a long time writing this code & I hope that you respect this.  
X *  I give permission to alter the code, but not to copy or redistribute
X *  it without my explicit permission.  If you alter the code, 
X *  please document changes and send me a copy, so all can have it.  
X *  This code, to the best of my knowledge works well,  but it is my first
X *  'C' program and should be treated as such.  I disclaim any
X *  responsibility for the codes actions (use at your own risk).  I guess
X *  I am saying "Happy gaming", and am trying not to get sued in the process.
X *                                                Ed
X */
X
X#include "header.h"
X#include <ctype.h>
X
XFILE *fnews, *fopen();
X
Xextern short country;
Xint attr[MAPX][MAPY];     /*sector attactiveness*/
Xextern short occ[MAPX][MAPY];
Xextern short movecost[MAPX][MAPY];
X
X/*update nation file*/
Xupdate()
X{
X	register int x,y;
X	int moved,armynum,nvynum,done,finis=0,j,i,number=0;
X	int food,iron;
X	char command[80];
X	int execed[MAXNTN];
X
X	if ((fnews=fopen(NEWSFILE,"w"))==NULL) {
X		printf("error opening news file\n");
X		exit(1);
X	}
X
X	/*run each nation in a random order*/
X	country=0;
X	execute();
X	for(i=0;i<MAXNTN;i++) execed[i]=0;
X	system("/bin/date");
X	while(finis==0){
X		/*get random active nation*/
X		country=(rand()%(MAXNTN-1))+1;
X		if(ntn[country].active>0) {
X			done=0;
X			number=0;
X			/*Find the next unupdated nation*/
X			while(done==0){
X				if((ntn[country].active>0)&&(execed[country]==0)) {
X					done=1;
X					execed[country]=1;
X				}
X				else {
X					country++;
X					number++;
X					if(number>MAXNTN) {
X						finis=1;
X						done=1;
X					}
X					else if(country>=MAXNTN) country=1;
X				}
X			}
X
X			if(finis==0){
X				printf("updating nation number %d -> %s\n",country,ntn[country].name);
X
X				/*if execute is 0 and PC nation then they did not move*/
X				if((execute()==0)&&(ntn[country].active==1)){
X					printf("nation %s did not move\n",ntn[country].name);
X#ifdef CMOVE
X					printf("the computer will move for %s\n",ntn[country].name);
X					fprintf(fnews,"1.\tthe computer will move for %s\n",ntn[country].name);
X					nationrun();
X#endif
X				}
X#ifdef NPC
X				/*run npc nations*/
X				if(ntn[country].active>=2) nationrun();
X#endif
X				/*do magic*/
X				if(magic(country,MI_MONST)==1){
X					if(magic(country,AV_MONST)==1) {
X						if(magic(country,MA_MONST)==1)
X							takeover(5,0);
X						else takeover(3,0);
X					}
X					else takeover(1,0);
X				}
X
X				/*update movement array*/
X				updmove(ntn[country].race);
X
X				/*THIS IS WHERE YOU ZERO THE ATTR MATRIX*/
X				/*calculate sector attractiveness*/
X				for(x=0;x<MAPX;x++) for(y=0;y<MAPY;y++) {
X					if((sct[x][y].owner==country)&&(isdigit(sct[x][y].vegitation)!=0)){
X						attr[x][y]=attract(x,y,ntn[country].race);
X					}
X					else if(((magic(country,DERVISH)==1)||(magic(country,DESTROYER)==1))&&((sct[x][y].vegitation==ICE)||(sct[x][y].vegitation==DESERT))) {
X						attr[x][y]=36;
X					}
X					else attr[x][y]=0;
X				}
X
X				/*if near capital add to attr*/
X				for(x=ntn[country].capx-2;x<=ntn[country].capx+2;x++)
X					for(y=ntn[country].capy-2;y<=ntn[country].capy+2;y++)
X						if(attr[x][y]>0) attr[x][y]+=20;
X
X/*MOVE CIVILIANS based on the ratio of attractivenesses
X	 *
X	 * EQUILIBRIUM(1) = A1/(A1+A2) * (P1+P2)
X	 * EQUILIBRIUM(2) = A2/(A1+A2) * (P1+P2)
X	 * MOVE 1/5 of way to equilibrium each turn
X	 * DELTA(1) = (EQUILIBRIUM(1)-P1)/5 = (A1P2-P1A2)/5(A1+A2)
X	 * DELTA(2) = (EQUILIBRIUM(2)-P2)/5 = (A2P1-P2A1)/5(A1+A2) = -DELTA(1)
X	 * ij is refered to as 1, xy as 2
X	 * NOTE AM ADDING 1 to divisor to prevent floating exception errors
X	 */
X				for(x=0;x<MAPX-1;x++) for(y=0;y<MAPY-1;y++) for(i=(-2);i<=2;i++) for(j=(-2);j<=2;j++)
X				if((x+i>0)&&(x+i<MAPX)&&(x+j>0)&&(x+j<MAPY)&&(sct[x+i][y+j].owner==country)&&(sct[x][y].owner==country)) {
X					moved=(sct[x][y].people*attr[x+i][y+j]-sct[x+i][y+j].people*attr[x][y])/(1+5*(attr[x+i][y+j]+attr[x][y]));
X					sct[x+i][y+j].people += moved;
X					sct[x][y].people -= moved;
X				}
X			}
X		}
X	}
X
X	/* run npc nations */
X#ifdef LZARD
X	puts("updating lizards\n ");
X	country = NLIZARD;
X	armynum=0;
X	/*move to lizard castle*/
X	for(armynum=0;armynum<MAXARM;armynum++) if(ASTAT!=GARRISON){
X		for(i=AXLOC-1;i<=AXLOC+1;i++) for(j=AYLOC-1;j<=AYLOC+1;j++){
X			if((i>=0)&&(j>=0)&&(i<MAPX)&&(j<MAPX)&&(sct[i][j].designation==DCASTLE)){
X				AXLOC=i;
X				AYLOC=j;
X			}
X		}
X		for(i=AXLOC-1;i<=AXLOC+1;i++) for(j=AYLOC-1;j<=AYLOC+1;j++){
X			if((i>=0)&&(j>=0)&&(i<MAPX)&&(j<MAPX)&&(sct[i][j].altitude!=WATER)&&(sct[i][j].owner != NLIZARD)&&(rand()%2==0)){
X				AXLOC=i;
X				AYLOC=j;
X			}
X		}
X	}
X#endif
X
X#ifdef MONSTER
X	monster();
X#endif
X
X	/*run combat*/
X	combat();
X
X	fprintf(fnews,"3\tNEWS ON WHAT SECTORS HAVE BEEN CAPTURED");
X	/*look for any areas where armies alone in sector*/
X	prep();
X	for(country=1;country<NTOTAL;country++) if(ntn[country].active!=0){
X		for(armynum=0;armynum<MAXARM;armynum++) if(ASOLD>75){
X			if(sct[AXLOC][AYLOC].owner==0){
X				sct[AXLOC][AYLOC].owner=country;
X			}
X			else if((sct[AXLOC][AYLOC].owner!=country)&&(ntn[country].dstatus[sct[AXLOC][AYLOC].owner]>=WAR)&&(occ[AXLOC][AYLOC]==country)){
X
X				if((sct[AXLOC][AYLOC].owner!=0)&&(ntn[sct[AXLOC][AYLOC].owner].race!=ntn[country].race)) flee(AXLOC,AYLOC,1);
X				fprintf(fnews,"\n3.\tarea %d,%d captured by %s from %s",AXLOC,AYLOC,ntn[country].name,ntn[sct[AXLOC][AYLOC].owner].name);
X				sct[AXLOC][AYLOC].owner=country;
X			}
X		}
X	}
X	fprintf(fnews,"\n1\tIMPORTANT WORLD NEWS\n");
X
X	for(country=1;country<MAXNTN;country++) 
X		if((ntn[country].active>=2)&&((ntn[country].tciv==0)||(sct[ntn[country].capx][ntn[country].capy].owner!=country))) destroy();
X
X	/*zero out all recalculated values*/
X	for(i=0;i<MAXNTN;i++){
X		ntn[i].tsctrs=0;
X		ntn[i].tships=0;
X		ntn[i].tciv=0;
X		ntn[i].tmil=0;
X	}
X
X	/*for whole map, update one sector at a time, owned sectors only*/
X	printf("\nupdating all sectors\n");
X	for(x=0;x<MAPX;x++) for(y=0;y<MAPY;y++) if(sct[x][y].owner!=0) {
X
X		/*check all adjacent sectors and decide if met*/
X		for(i=x-1;i<=x+1;i++) for(j=y-2;j<=y+2;j++) {
X			if(i>=0&&i<MAPX&&j>=0&&j<MAPY&&(sct[i][j].owner!=0)) {
X				if(sct[x][y].owner!=sct[i][j].owner) {
X					if(ntn[sct[x][y].owner].dstatus[sct[i][j].owner]==UNMET) newdip(sct[x][y].owner,sct[i][j].owner);
X					if(ntn[sct[i][j].owner].dstatus[sct[x][y].owner]==UNMET) newdip(sct[i][j].owner,sct[x][y].owner);
X				}
X			}
X		}
X
X		/*update nation file for owner*/
X		ntn[sct[x][y].owner].tsctrs++;
X		ntn[sct[x][y].owner].tciv += sct[x][y].people;
X
X		/*grow populations*/
X		if(sct[x][y].people<100) sct[x][y].people+=sct[x][y].people/10;
X		else sct[x][y].people+=(ntn[sct[x][y].owner].repro*sct[x][y].people)/100;
X
X		/*PRODUCE*/
X		/*increase tmin based on mined stuff...*/
X		if(sct[x][y].designation==DMINE) {
X			iron=sct[x][y].iron*sct[x][y].people;
X			if(magic(sct[x][y].owner,MINER)==1) iron*=2;
X			if(magic(sct[x][y].owner,STEEL)==1) iron*=2;
X			ntn[sct[x][y].owner].tiron += iron;
X			ntn[sct[x][y].owner].tgold += iron*TAXIRON/100;
X		}
X		/*harvest food*/
X		else if(sct[x][y].designation==DFARM) {
X			food=todigit(sct[x][y].vegitation)*sct[x][y].people;
X			ntn[sct[x][y].owner].tfood += food;
X			ntn[sct[x][y].owner].tgold += food*TAXFOOD/100;
X		}
X		/*gold mines produce gold*/
X		else if(sct[x][y].designation==DGOLDMINE) {
X			if(magic(sct[x][y].owner,MINER)==1){
X				ntn[sct[x][y].owner].tgold+=  2*sct[x][y].gold * sct[x][y].people * TAXGOLD/100;
X				ntn[sct[x][y].owner].jewels+= 2*sct[x][y].gold * sct[x][y].people;
X			}
X			else {
X				ntn[sct[x][y].owner].tgold+= sct[x][y].gold * sct[x][y].people * TAXGOLD/100;
X				ntn[sct[x][y].owner].jewels+= sct[x][y].gold * sct[x][y].people;
X			}
X		}
X		else if(sct[x][y].designation==DCAPITOL) {
X			if((x!=ntn[sct[x][y].owner].capx)&&(y!=ntn[sct[x][y].owner].capy)) {
X				ntn[sct[x][y].owner].tgold+= 2*sct[x][y].people * TAXCITY/100;
X				sct[x][y].designation=DCITY;
X				if(magic(sct[x][y].owner,ARCHITECT)==1){
X					ntn[sct[x][y].owner].tgold+= 2 * sct[x][y].people * TAXCITY/100;
X				}
X				else {
X					ntn[sct[x][y].owner].tgold+= sct[x][y].people * TAXCITY/100;
X				}
X			}
X			else if(magic(sct[x][y].owner,ARCHITECT)==1){
X				ntn[sct[x][y].owner].tgold+= 2 * sct[x][y].people * TAXCAP/100;
X			}
X			else 
X				ntn[sct[x][y].owner].tgold+= sct[x][y].people * TAXCAP/100;
X		}
X		else if(sct[x][y].designation==DCITY) {
X			if(magic(sct[x][y].owner,ARCHITECT)==1){
X				ntn[sct[x][y].owner].tgold+= 2*sct[x][y].people * TAXCITY/100;
X			}
X			else {
X				ntn[sct[x][y].owner].tgold+= sct[x][y].people * TAXCITY/100;
X			}
X		}
X		else if(((magic(country,DERVISH)==1)||(magic(country,DESTROYER)==1))&&((sct[x][y].vegitation==ICE)||(sct[x][y].vegitation==DESERT))&&(sct[x][y].people>0)) {
X			food=6*sct[x][y].people;
X			ntn[sct[x][y].owner].tfood += food;
X			ntn[sct[x][y].owner].tgold += food*TAXFOOD/100;
X		}
X	}
X
X	/*reset military stuff*/
X	printf("updating armies and navies\n");
X	for(country=1;country<MAXNTN;country++) if(ntn[country].active!=0){
X		for(armynum=0;armynum<MAXARM;armynum++){
X			if(ASOLD>0) {
X				ntn[country].tmil+=ASOLD;
X				if(magic(country,VAMPIRE)!=1)
X					ntn[country].tgold-=ASOLD*SOLDMAINT;
X
X				/*add movement to all armies */
X				switch(ASTAT) {
X				case MARCH:
X					AMOVE=2*ntn[country].maxmove;
X					break;
X				case SCOUT:
X				case ATTACK:
X				case DEFEND:
X					AMOVE=ntn[country].maxmove;
X					break;
X				case GARRISON:
X					AMOVE=0;
X					break;
X				default:
X					ASTAT=DEFEND;
X					AMOVE=ntn[country].maxmove;
X				}
X			}
X		}
X		/*add to movement of fleets*/
X		for(nvynum=0;nvynum<MAXNAVY;nvynum++) {
X			/*update sea sectors*/
X			if(NMER+NWAR>0) {
X				if(sct[NXLOC][NYLOC].altitude==WATER) {
X					/*all ships sunk on 0 (d12)*/
X					/*pirates never are sunk (implicitly)*/
X					if(rand()%12==0){
X						fprintf(fnews,"3.\tstorm in %d,%d\n",x,y);
X						NWAR=0;
X						NMER=0;
X					}
X				}
X				NMOVE=3*ntn[country].maxmove;
X				ntn[country].tships+=NWAR+NMER;
X				ntn[country].tgold-=(NWAR+NMER)*SHIPMAINT;
X			}
X			else {
X				NWAR=0;
X				NMER=0;
X			}
X		}
X	}
X
X	/*commodities: feed the people, too much gold?, validate iron*/
X	fprintf(fnews,"2\tSTATUS OF THE WORLDS FOOD SUPPLY\n");
X	for(country=1;country<MAXNTN;country++) if(ntn[country].active!=0){
X		/*soldiers eat  2*/
X		ntn[country].tfood-=ntn[country].tmil*2;
X		/*civilians eat 1*/
X		ntn[country].tfood-=ntn[country].tciv;
X
X		/*starve people*/
X		if(ntn[country].tfood<0) for(x=0;x<MAPX;x++) for(y=0;y<MAPX;y++) {
X			if((sct[x][y].owner==country)&&((sct[x][y].designation==DCITY)||(sct[x][y].designation==DCAPITOL))&&(ntn[country].tfood<0)){
X				/*lose one person in city per three food*/
X				/*maximum of 1/3 people in city lost*/
X				if(sct[x][y].people>(-1)*ntn[country].tfood){
X					sct[x][y].people+=ntn[country].tfood/3;
X					ntn[country].tfood=0;
X				}
X				else {
X					ntn[country].tfood+=sct[x][y].people;
X					sct[x][y].people*=(2/3);
X				}
X				fprintf(fnews,"2.\tfamine hits city at %d,%d in %s.\n",x,y,ntn[country].name);
X			}
X		}
X
X		/*this state can occur if few people live in cities*/
X		if(ntn[country].tfood<0) {
X			ntn[country].tfood=0;
X		}
X		else if(ntn[country].tfood>FOODTHRESH*ntn[country].tciv) {
X			ntn[country].tgold+=ntn[country].tfood-FOODTHRESH*ntn[country].tciv;
X			ntn[country].tfood=FOODTHRESH*ntn[country].tciv;
X		}
X
X		if(ntn[country].tgold>GOLDTHRESH*ntn[country].jewels){
X			x=ntn[country].tgold-GOLDTHRESH*ntn[country].jewels;
X			ntn[country].jewels += x/GOLDTHRESH;
X			ntn[country].tgold  -= x;
X		}
X		else if(ntn[country].tgold<((-1)*JEWELTHRESH)*ntn[country].jewels){
X			fprintf(fnews,"3.\tTAX REVOLT IN NATION %s\n",ntn[country].name);
X		}
X	}
X
X	fclose(fnews);
X	score();
X	strcpy(command,"> ");
X	strcat(command,EXEFILE);
X	system(command);
X	strcpy(command,"/bin/sort -n -o ");
X	strcat(command,NEWSFILE);
X	strcat(command," ");
X	strcat(command,NEWSFILE);
X	printf("sort done\n");
X	system(command);
X}
X
Xattract(x,y,race)
X{
X	int Attr=0;
X
X	if((sct[x][y].designation==DGOLDMINE)&&(sct[x][y].gold>3)){
X		if(ntn[sct[x][y].owner].jewels<=ntn[sct[x][y].owner].tgold*GOLDTHRESH) Attr+=120;
X		else if(sct[x][y].gold>5) Attr+=120;
X		else Attr+=75;
X	}
X	else if((sct[x][y].designation==DFARM)&&(todigit(sct[x][y].vegitation)>6)){
X		if(ntn[sct[x][y].owner].tfood<=ntn[sct[x][y].owner].tciv*FOODTHRESH) Attr+=300;
X		else if(todigit(sct[x][y].vegitation)==9) Attr+=100;
X		else Attr+=40;
X	}
X	else if(sct[x][y].designation==DCAPITOL) Attr+=200;
X	else if(sct[x][y].designation==DCITY) Attr+=125;
X	else if((sct[x][y].designation==DMINE)&&(sct[x][y].iron>3)) {
X		if(ntn[sct[x][y].owner].tiron<=ntn[sct[x][y].owner].tciv)
X			Attr+=120;
X		else if(sct[x][y].iron>5) Attr+=100;
X		else Attr+=50;
X	}
X
X	switch(race){
X	case DWARF:
X		if((sct[x][y].designation==DGOLDMINE)&&(sct[x][y].gold>=5))
X			Attr+=100;
X		else if((sct[x][y].designation==DMINE)&&(sct[x][y].iron>=5))
X			Attr+=100;
X
X		if(sct[x][y].altitude==MOUNTAIN) Attr+=40;
X		else if(sct[x][y].altitude==HILL) Attr+=20;
X		else if(sct[x][y].altitude==CLEAR) Attr+=0;
X		else Attr=0;
X		break;
X	case ELF:
X		if(sct[x][y].vegitation==JUNGLE) Attr+=40;
X		else if(sct[x][y].vegitation==WOOD) Attr+=90;
X		else if(sct[x][y].vegitation==FORREST) Attr+=70;
X
X		if((sct[x][y].designation==DGOLDMINE)&&(sct[x][y].gold>=5))
X			Attr+=75;
X
X		if(sct[x][y].altitude==MOUNTAIN) Attr-=20;
X		else if(sct[x][y].altitude==HILL) Attr-=10;
X		else if(sct[x][y].altitude==CLEAR) Attr+=0;
X		else Attr=0;
X		break;
X	case HUMAN:
X		Attr+=todigit(sct[x][y].vegitation)*4;
X
X		if((sct[x][y].designation==DGOLDMINE)&&(sct[x][y].gold>=5))
X			Attr+=75;
X		else if((sct[x][y].designation==DMINE)&&(sct[x][y].iron>=5))
X			Attr+=75;
X		else if((sct[x][y].designation==DFARM)&&(todigit(sct[x][y].vegitation)>=6))
X			Attr+=55;
X		else if(sct[x][y].designation==DCAPITOL) Attr+=70;
X		else if(sct[x][y].designation==DCITY) Attr+=50;
X
X		if(sct[x][y].altitude==MOUNTAIN) Attr-=10;
X		else if(sct[x][y].altitude==HILL) Attr+=00;
X		else if(sct[x][y].altitude==CLEAR) Attr+=10;
X		else Attr=0;
X		break;
X	case ORC:
X		if(sct[x][y].designation==DCAPITOL) Attr+=120;
X		else if(sct[x][y].designation==DCITY) Attr+=75;
X		else if((sct[x][y].designation==DGOLDMINE)&&(sct[x][y].gold>=5))
X			Attr+=75;
X		else if((sct[x][y].designation==DMINE)&&(sct[x][y].iron>=5))
X			Attr+=75;
X
X		if(sct[x][y].altitude==MOUNTAIN) Attr+=20;
X		else if(sct[x][y].altitude==HILL) Attr+=10;
X		else if(sct[x][y].altitude==CLEAR) Attr+=0;
X		else Attr=0;
X		break;
X	default:
X		break;
X	}
X	if((Attr<0)||(movecost[x][y]<0)) Attr=0;
X	return(Attr);
X}
X
Xtodigit(character)
X{
X	int j;
X	for(j=0;j<=9;j++) if(character==*(numbers+j)) return(j);
X	return(0);
X}
X
Xarmymove(armynum)
X{
X	int sum,done,place;
X	register int x,y;
X	sum=0;
X	for(x=AXLOC-2;x<=AXLOC+2;x++)
X		for(y=AYLOC-2;y<=AYLOC+2;y++)
X			if(x>=0&&x<MAPX&&y>=0&&y<MAPY)
X				sum+=attr[x][y];
X
X	if(sum==0) {
X		AXLOC=ntn[country].capx;
X		AYLOC=ntn[country].capy;
X		sum=1;
X	}
X	else {
X		place=rand()%sum;
X		done=0;
X		for(x=AXLOC-2;x<=AXLOC+2;x++) for(y=AYLOC-2;y<=AYLOC+2;y++) {
X			if(x>=0&&x<MAPX&&y>=0&&y<MAPY) place-=attr[x][y];
X			if((done==0)&&(place<0)&&(movecost[x][y]>0)){
X				AXLOC=x;
X				AYLOC=y;
X				done=1;
X				if(sct[x][y].owner==0)
X					sct[x][y].owner=country;
X			}
X		}
X	}
X}
X
Xscore()
X{
X	int x,y;
X
X	printf("\nupdating scores for all nations\n");
X	for(x=0;x<MAPX;x++) for(y=0;y<MAPY;y++)
X		if(sct[x][y].people>0) ntn[sct[x][y].owner].score += SECTSCORE;
X}
END_OF_update.c
if test 15212 -ne `wc -c <update.c`; then
    echo shar: \"update.c\" unpacked with wrong size!
fi
# end of overwriting check
fi
echo shar: End of archive 4 \(of 5\).
cp /dev/null ark4isdone
MISSING=""
for I in 1 2 3 4 5 ; do
    if test ! -f ark${I}isdone ; then
	MISSING="${MISSING} ${I}"
    fi
done
if test "${MISSING}" = "" ; then
    echo You have unpacked all 5 archives.
    rm -f ark[1-9]isdone
else
    echo You still need to unpack the following archives:
    echo "        " ${MISSING}
fi
##  End of shell archive.
exit 0