[comp.sources.games] v06i090: conquer4 - middle earth multi-player game

billr@saab.CNA.TEK.COM (Bill Randle) (06/24/89)

Submitted-by: adb@bu-it.bu.edu (Adam Bryant)
Posting-number: Volume 6, Issue 90
Archive-name: conquer4/Part08
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 8 (of 14)."
# Contents:  data.h magic.c
# Wrapped by billr@saab on Thu Jun 15 15:20:16 1989
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'data.h' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'data.h'\"
else
echo shar: Extracting \"'data.h'\" \(31789 characters\)
sed "s/^X//" >'data.h' <<'END_OF_FILE'
X/* conquer : Copyright (c) 1988 by Ed Barlow.	*/
X
X/*--------I DO NOT BELIEVE IT IS NECESSARY TO ALTER THIS FILE----------------*/
X#define	FAIL	1		/* fail return to shell			*/
X#define	SUCCESS	0		/* successful return to shell		*/
X#define	BIG	500000000L	/* BIGGER THAN ANYTHING SHOULD BE	*/
X				/* this is used to protect against overflow */
X#define	SCRARM	((LINES-14)/2)	/* number of armies to fit on screen	*/
X
Xextern	char	*strcpy(),*strncpy(),*strcat(),*strncat();
X
X#include <stdio.h>
X#include <curses.h>
X
X/* sometimes curses.h defines TRUE	*/
X#ifndef TRUE
X#define	TRUE		1
X#define	FALSE		0
X#endif
X
X#define	SCREEN_X_SIZE	(( COLS - 21) / 2)	/* divide by two as only 1/2 
X						   sectors will be shown */
X#define	SCREEN_Y_SIZE	( LINES - 5 )
X#define HAS_SEEN(x,y)	hasseen[(x)+((y)*((COLS-10)/2))]
X#define	PASSLTH		7	/*one less than the characters in the password*/
X#define	NAMELTH		9	/*one less than the characters in the name*/
X#define	LEADERLTH	9	/*one less than the characters in the leader*/
X
X/*simple contour map definitions*/
X#define	WATER		(*(ele+0))
X#define	PEAK		(*(ele+1))
X#define	MOUNTAIN	(*(ele+2))
X#define	HILL		(*(ele+3))
X#define	CLEAR		(*(ele+4))
X
X/*racial types*/
X#define	GOD		'-'
X#define	ORC		'O'
X#define	ELF		'E'
X#define	DWARF		'D'
X#define	LIZARD		'L'
X#define	HUMAN		'H'
X#define	PIRATE		'P'
X#define	BARBARIAN	'B'
X#define	NOMAD		'N'
X#define	TUNKNOWN	'?'
X
X/*designations*/
X#define	DTOWN		(*(des+0))
X#define	DCITY		(*(des+1))
X#define	DMINE		(*(des+2))
X#define	DFARM		(*(des+3))
X#define	DDEVASTATED	(*(des+4))
X#define	DGOLDMINE	(*(des+5))
X#define	DFORT		(*(des+6))
X#define	DRUIN		(*(des+7))
X#define	DSTOCKADE	(*(des+8))
X#define	DCAPITOL	(*(des+9))
X#define	DSPECIAL	(*(des+10))
X#define	DLUMBERYD	(*(des+11))
X#define	DBLKSMITH	(*(des+12))
X#define	DROAD		(*(des+13))
X#define	DMILL		(*(des+14))
X#define	DGRANARY	(*(des+15))
X#define	DCHURCH		(*(des+16))
X#define	DUNIVERSITY	(*(des+17))
X#define	DNODESIG	(*(des+18))
X#define	DBASECAMP	(*(des+19))
X
X/* nation placement variables	*/
X#define	GREAT		'G'
X#define	FAIR		'F'
X#define	RANDOM		'R'
X#define	OOPS		'X'
X
X/*vegetation types -- these are legal in designations too*/
X#define	VOLCANO		(*(veg+0))
X#define	DESERT		(*(veg+1))
X#define	TUNDRA		(*(veg+2))
X#define	BARREN		(*(veg+3))
X#define	LT_VEG		(*(veg+4))
X#define	GOOD		(*(veg+5))
X#define	WOOD		(*(veg+6))
X#define	FOREST		(*(veg+7))
X#define	JUNGLE		(*(veg+8))
X#define	SWAMP		(*(veg+9))
X#define	ICE		(*(veg+10))
X#define	NONE		(*(veg+11))
X
X/*Diplomacy Variables*/
X#define	JIHAD		7
X#define	WAR		6
X#define	HOSTILE		5
X#define	NEUTRAL		4
X#define	FRIENDLY	3
X#define	ALLIED		2
X#define	TREATY		1
X#define	UNMET		0
X
X#define	BREAKJIHAD	200000L /* $ cost to break confederacy or jihad	*/
X
X/*army status*/
X#define	MARCH		1	/*March	*/
X#define	SCOUT		2	/*Scouting--will not engage enemy if possible*/
X#define	GARRISON	3	/*Garrison--for a town or Capitol	*/
X#define	TRADED		4	/*Indicates an army that has been traded*/
X#define	MILITIA		5	/*Unit is a militia unit */
X#define	FLIGHT		6	/*Indicates army is flying*/
X#define	DEFEND		7	/*Defend	*/
X#define	MAGDEF		8	/*Magically enhanced defend mode*/
X#define	ATTACK		9	/*Attack anybody (Hostile+) within 2 sectors*/
X#define	MAGATT		10	/*Magically enhanced attack mode*/
X#define	GENERAL		11	/* group leader !!!	*/
X#define	SORTIE		12	/*Quick attack from a city */
X#define	SIEGE		13	/*Set siege on a city */
X#define	SIEGED		14	/*Unit under siege */
X#define	ONBOARD		15	/*On board a fleet */
X#define	RULE		16	/*Nation leader status for capitol */
X#define	NUMSTATUS	17	/* number of possible stats	*/
X				/* Army groups are implemented in the army
X				status vbl.  if >= NUMSTATUS, you belong to
X				army group x-NUMSTATUS - army groups always
X				of status attack and may not be magicked */
X
X/*seasonal definitions	*/
X#define	TURN		world.turn	/* game turn	*/
X#define	SEASON(x)	((x)%4)
X#define	PSEASON(x)	seasonstr[((x)%4)]
X#define	YEAR(x)		((int)((x+3)/4))
X#define	WINTER		0
X#define	SPRING		1
X#define	SUMMER		2
X#define	FALL		3
X
X/* definitions for compass directions */
X#define	CENTERED	0
X#define	NORTH		1
X#define	NORTHEAST	2
X#define	EAST		3
X#define	SOUTHEAST	4
X#define	SOUTH		5
X#define	SOUTHWEST	6
X#define	WEST		7
X#define	NORTHWEST	8
X
Xstruct	s_world
X{
X	short	mapx,mapy;	/* size of world		*/
X	short	nations;	/* number of actual nations	*/
X	short	othrntns;	/* god, lizard...		*/
X	short	turn;		/* game turn			*/
X	long	m_mil;		/* number of mercs available	*/
X	short	m_aplus;	/* mercenary attack bonus	*/
X	short	m_dplus;	/* mercenary defence bonus	*/
X	long	w_jewels;	/* jewels in world		*/
X	long	w_gold;		/* gold talons in world		*/
X	long	w_food;		/* food in world		*/
X	long	w_metal;	/* metal in world		*/
X	long	w_civ;		/* world population		*/
X	long	w_mil;		/* world military		*/
X	long	w_sctrs;	/* owned sectors in world	*/
X	long	score;		/* world score total		*/
X};
X
X#define MAPX		world.mapx
X#define MAPY		world.mapy
X#define	MERCMEN		world.m_mil
X#define	MERCATT		world.m_aplus
X#define	MERCDEF		world.m_dplus
X#define	WORLDJEWELS	world.w_jewels
X#define	WORLDGOLD	world.w_gold
X#define	WORLDMETAL	world.w_metal
X#define	WORLDFOOD	world.w_food
X#define	WORLDSCORE	world.score
X#define	WORLDCIV	world.w_civ
X#define	WORLDSCT	world.w_sctrs
X#define	WORLDMIL	world.w_mil
X#define	WORLDNTN	world.nations
X
Xstruct s_sector
X{
X	char	designation;		/* designation of sector	*/
X	char	altitude;		/* sector altitude		*/
X	char	vegetation;		/* sector vegetation		*/
X	char	owner;			/* nation id of owner		*/
X	long	people;			/* civilians in sector		*/
X	short	i_people;		/* initial civilians in sector	*/
X	unsigned char	jewels;		/* jewel production ability	*/
X	unsigned char	fortress;	/* fortification level (0 to 9)	*/
X	unsigned char	metal;		/* metal produced by sector	*/
X	unsigned char	tradegood;	/* exotic trade goods in sector	*/
X	/* unsigned char	region;		/* index of region	*/
X};
X#define	SOWN	sct[xcurs+xoffset][ycurs+yoffset].owner
X#define	XREAL	(xcurs+xoffset)
X#define	YREAL	(ycurs+yoffset)
X
Xstruct navy
X{
X	unsigned short warships;
X	unsigned short merchant;
X	unsigned short galleys;
X	char xloc;
X	char yloc;
X	char smove;			/* movement ability of ship */
X	unsigned char crew;		/* crew on ship */
X	unsigned char people;		/* people carried */
X	unsigned char commodity;	/* future commodities */
X	char armynum;			/* army carried */
X};
X
X
X/* NATION STRATEGY: a nation's strategy is a part of the ntn[].active
X * variable which tells if it is a PC or NPC, its allignment, and its
X * constraints allignments can be good, neutral, or evil. 
X * NPC Nations can be Expansionsist (with 0,2,4,6 sectors to expand into)
X * or Isolationist.	*/
X#define	INACTIVE	0
X#define	PC_GOOD		1		/* PC NATIONS	*/
X#define	PC_NEUTRAL	2
X#define	PC_EVIL		3
X#define	GOOD_0FREE	4		/* NPC NATIONS	*/
X#define	GOOD_2FREE	5
X#define	GOOD_4FREE	6
X#define	GOOD_6FREE	7
X#define	NEUTRAL_0FREE	8
X#define	NEUTRAL_2FREE	9
X#define	NEUTRAL_4FREE	10
X#define	NEUTRAL_6FREE	11
X#define	EVIL_0FREE	12
X#define	EVIL_2FREE	13
X#define	EVIL_4FREE	14
X#define	EVIL_6FREE	15
X#define	ISOLATIONIST	16		/* ISOLATIONIST NATIONS	*/
X#define	NPC_PEASANT	17		/* PEASANT REVOLT TYPE NATIONS	*/
X#define NPC_PIRATE	18
X#define NPC_LIZARD	19
X#define NPC_NOMAD	20
X#define NPC_BARBARIAN	21
X
X#define	ispc(x)		(((x)==PC_GOOD)||((x)==PC_EVIL)||((x)==PC_NEUTRAL))
X#define	npctype(x)	(ispc(x) ? (x) : (x)/4)
X#define	isgood(x)	(npctype(x) == 1)
X#define	isneutral(x)	(npctype(x) == 2)
X#define	isevil(x)	(npctype(x) == 3)
X#define	isnpc(x)	(((x)>=GOOD_0FREE)&&((x)<=ISOLATIONIST))
X#define	isnotpc(x)	(((x)>=GOOD_0FREE)&&((x)!=INACTIVE))
X#define	ismonst(x)	((x)>=NPC_PEASANT)
X#define	ispeasant(x)	((x)==NPC_PEASANT)
X#define	isntn(x)	(((x)!=INACTIVE)&&((x)<=ISOLATIONIST))
X#define	isntnorp(x)	(((x)!=INACTIVE)&&((x)<=NPC_PEASANT))
X#define	isactive(x)	((x)!=INACTIVE)
X
X/* definitions for mail checker */
X#define	NO_MAIL		0
X#define	NEW_MAIL	1
X
X/* definitions for naval types	*/
X#define	N_LIGHT		0
X#define	N_MEDIUM	1
X#define	N_HEAVY		2
X#define	N_BITSIZE	5
X#define	N_MASK		((unsigned short) 0x001f)
X
X/* definitions for naval calculations */
X#define	N_WSPD		20	/* speed of warships */
X#define	N_GSPD		18	/* speed of galleys */
X#define	N_MSPD		15	/* speed of merchants */
X#define	N_NOSPD		0	/* no ships no speed */
X#define	N_SIZESPD	3	/* bonus speed for lighter ships */
X
X#define	UTYPE		75
X#define	TWOUTYPE	150	/* two times value of UTYPE above	*/
X
X#define	A_MILITIA	0
X#define	A_GOBLIN	1
X#define	A_ORC		2
X#define	A_INFANTRY	3
X#define	A_SAILOR	4
X#define	A_MARINES	5
X#define	A_ARCHER	6
X#define	A_URUK		7
X#define	A_NINJA		8
X#define	A_PHALANX	9
X#define	A_OLOG		10
X#define	A_LEGION	11
X#define	A_DRAGOON	12
X#define	A_MERCENARY	13
X#define	A_TROLL		14
X#define	A_ELITE		15
X#define	A_LT_CAV	16
X#define	A_CAVALRY	17
X#define	A_CATAPULT	18
X#define	A_SIEGE		19
X#define	A_ROC		20
X#define	A_KNIGHT	21
X#define	A_GRIFFON	22
X#define	A_ELEPHANT	23
X#define	A_ZOMBIE	24
X#define A_SPY		25
X#define A_SCOUT		26
X#define	NOUNITTYPES	26	/*number of unit types*/
X
X#define	MINLEADER	(27+UTYPE)	/* min value of a leader -1*/
X#define	L_KING		(27+UTYPE)
X#define	L_BARON		(28+UTYPE)
X#define	L_EMPEROR	(29+UTYPE)
X#define	L_PRINCE	(30+UTYPE)
X#define	L_WIZARD	(31+UTYPE)
X#define	L_MAGI		(32+UTYPE)
X#define	L_APOSTLE	(33+UTYPE)
X#define	L_BISHOP	(34+UTYPE)
X#define	L_ADMIRAL	(35+UTYPE)
X#define	L_CAPTAIN	(36+UTYPE)
X#define	L_WARLORD	(37+UTYPE)
X#define	L_LORD		(38+UTYPE)
X#define	L_DEMON		(39+UTYPE)
X#define	L_DEVIL		(40+UTYPE)
X#define	L_DRAGON	(41+UTYPE)
X#define	L_WYRM		(42+UTYPE)
X#define	L_SHADOW	(43+UTYPE)
X#define	L_NAZGUL	(44+UTYPE)
X
X#define	MINMONSTER	(45+TWOUTYPE)	/* min value of a monster	*/
X#define	SPIRIT		(45+TWOUTYPE)
X#define	ASSASSIN	(46+TWOUTYPE)
X#define	DJINNI		(47+TWOUTYPE)
X#define	GARGOYLE	(48+TWOUTYPE)
X#define	WRAITH		(49+TWOUTYPE)
X#define	HERO		(50+TWOUTYPE)
X#define	CENTAUR		(51+TWOUTYPE)
X#define	GIANT		(52+TWOUTYPE)
X#define	SUPERHERO	(53+TWOUTYPE)
X#define	MUMMY		(54+TWOUTYPE)
X#define	ELEMENTAL	(55+TWOUTYPE)
X#define	MINOTAUR	(56+TWOUTYPE)
X#define	DEMON		(57+TWOUTYPE)
X#define	BALROG		(58+TWOUTYPE)
X#define	DRAGON		(59+TWOUTYPE)
X#define	MAXMONSTER	(59+TWOUTYPE)
X
Xstruct army
X{
X	unsigned char unittyp;
X	char xloc;
X	char yloc;
X	char smove;
X	long sold;
X	char stat;
X};
X
Xstruct	s_nation		/* player nation stats	*/
X{
X	char	name[NAMELTH+1];	/* name			*/
X	char	passwd[PASSLTH+1];	/* password		*/
X	char	leader[LEADERLTH+1];	/* leader title		*/
X	char	race;		/* national race (integer--see header.h)*/
X	char	location;	/* location variable (gfr)	*/
X	char	mark;		/* unique mark for nation	*/
X	char	capx;		/* Capitol x coordinate		*/
X	char	capy;		/* Capitol y coordinate		*/
X	char	active;		/* nation type and strategy	*/
X	char	maxmove;	/* maximum movement of soldiers */
X	char	repro;		/* reproduction rate of nation	*/
X	long	score;		/* score			*/
X	long	tgold;		/* gold in treasury		*/
X	long	jewels;		/* raw amount of jewels in treasury	*/
X	long	tmil;		/* total military		*/
X	long	tciv;		/* total civilians		*/
X	long	metals;		/* total real metal in nation	*/
X	long	tfood;		/* total food in nation		*/
X	long	powers;
X	short	class;		/* national class		*/
X	short	aplus;		/* attack plus of all soldiers	*/
X	short	dplus;		/* attack plus of all soldiers	*/
X	short	spellpts;	/* spell points			*/
X	short	tsctrs;		/* total number sectors		*/
X	short	tships;		/* number warships		*/
X	short	inflation;	/* inflation rate		*/
X	unsigned char charity;	/* charity budget (% of Taxes)	*/
X	struct	army arm[MAXARM];
X	struct	navy nvy[MAXNAVY];
X	char	dstatus[NTOTAL];	/* diplomatic status	*/
X	unsigned char	tax_rate;	/* taxrate populace	*/
X	unsigned char	prestige;	/* nations prestige	*/
X	unsigned char	popularity;	/* governments popularity	*/
X	unsigned char	power;			/* nation power	*/
X	unsigned char	communications;		/* leader communication	*/
X	unsigned char	wealth;			/* per capita income	*/
X	unsigned char	eatrate;		/* food eaten / 10 people*/
X	unsigned char	spoilrate;		/* food spoilage rate	*/
X	unsigned char	knowledge;		/* general knowledge	*/
X	unsigned char	farm_ability;		/* farming ability	*/
X	unsigned char	mine_ability;		/* mine ability		*/
X	unsigned char	poverty;		/* % poor people	*/
X	unsigned char	terror;			/* peoples terror of you*/
X	unsigned char	reputation;		/* reputation of nation	*/
X};
X#define	P_NTNCOM	((((float) curntn->communications)/ 50.0 ))
X#define	P_EATRATE	((((float) curntn->eatrate) / 25.0 ))
X#define	P_REPRORATE	( ((float) (100.0 + 25.0*curntn->repro )/100.0))
X
X#define	P_ATYPE	curntn->arm[armynum].unittyp
X#define	P_AXLOC	curntn->arm[armynum].xloc
X#define	P_AYLOC	curntn->arm[armynum].yloc
X#define	P_AMOVE	curntn->arm[armynum].smove
X#define	P_ASOLD	curntn->arm[armynum].sold
X#define	P_ASTAT	curntn->arm[armynum].stat
X#define	P_NWSHP	curntn->nvy[nvynum].warships
X#define	P_NMSHP	curntn->nvy[nvynum].merchant
X#define P_NGSHP	curntn->nvy[nvynum].galleys
X#define	P_NCREW	curntn->nvy[nvynum].crew
X#define	P_NARMY	curntn->nvy[nvynum].armynum
X#define	P_NPEOP	curntn->nvy[nvynum].people
X#define	P_NXLOC	curntn->nvy[nvynum].xloc
X#define	P_NYLOC	curntn->nvy[nvynum].yloc
X#define	P_NMOVE	curntn->nvy[nvynum].smove
X
X/* naval routine macros */
X#define	SHIPS(x,y)	(short)( ((x)&(N_MASK<<((y)*N_BITSIZE))) >> ((y)*N_BITSIZE) )
X#define	P_NWAR(x)	SHIPS(P_NWSHP,x)
X#define	P_NMER(x)	SHIPS(P_NMSHP,x)
X#define	P_NGAL(x)	SHIPS(P_NGSHP,x)
X#define	NADD_WAR(x)	addwships(nvynum,shipsize,(x));
X#define	NADD_MER(x)	addmships(nvynum,shipsize,(x));
X#define	NADD_GAL(x)	addgships(nvynum,shipsize,(x));
X#define	NSUB_WAR(x)	subwships(nvynum,shipsize,(x));
X#define	NSUB_MER(x)	submships(nvynum,shipsize,(x));
X#define	NSUB_GAL(x)	subgships(nvynum,shipsize,(x));
X
X#define	ATYPE	ntn[country].arm[armynum].unittyp
X#define	AXLOC	ntn[country].arm[armynum].xloc
X#define	AYLOC	ntn[country].arm[armynum].yloc
X#define	AMOVE	ntn[country].arm[armynum].smove
X#define	ASOLD	ntn[country].arm[armynum].sold
X#define	ASTAT	ntn[country].arm[armynum].stat
X#define	NWSHP	ntn[country].nvy[nvynum].warships
X#define	NMSHP	ntn[country].nvy[nvynum].merchant
X#define	NGSHP	ntn[country].nvy[nvynum].galleys
X#define	NCREW	ntn[country].nvy[nvynum].crew
X#define	NARMY	ntn[country].nvy[nvynum].armynum
X#define	NPEOP	ntn[country].nvy[nvynum].people
X#define	NXLOC	ntn[country].nvy[nvynum].xloc
X#define	NYLOC	ntn[country].nvy[nvynum].yloc
X#define	NMOVE	ntn[country].nvy[nvynum].smove
X
X/* these defines are for types of magic	powers	*/
X#define	M_MIL		1	/* military	*/
X#define	M_CIV		2	/* civilian	*/
X#define	M_MGK		3	/* magical	*/
X#define M_TECH		4	/* technological	*/
X#define	M_ALL		5
X
X#define	AORN		0
X#define	ARMY		1
X#define	NAVY		2
X
X#define	XASTAT		1
X#define	XAMEN		2
X#define	XBRIBE		3
X#define	XALOC		4
X#define	XNLOC		5
X#define	XNAMER		6
X#define	XNACREW		7
X#define	XECNAME		8
X#define	XECPAS		9
X#define	EDSPL		10
X#define	XSADES		11
X#define	XSACIV		12
X#define	XSIFORT		13
X#define	XNAGOLD		14
X#define	XAMOV		15
X#define	XNMOV		16
X#define	XSAOWN		17
X#define	EDADJ		18
X#define	XNARGOLD	19
X#define	XNAMETAL	20
X#define	INCAPLUS	22
X#define	INCDPLUS	23
X#define	CHG_MGK		24
X#define	DESTRY		25
X#define	MSETA		26
X#define	MSETB		27
X#define NTAX		28
X#define XNAWAR		29
X#define XNAGAL		30
X#define XNAHOLD		31
X#define NPOP		32
X
X#define	BRIBENATION fprintf(fm,"L_NGOLD\t%d\t%d\t%ld\t0\t%d\t%s\n",XBRIBE,country,bribecost,nation,"null");
X#define	DESTROY fprintf(fexe,"DESTROY\t%d\t%d\t%hd\t0\t0\t%s\n",DESTRY,save,country,"null")
X#define	CHGMGK fprintf(fexe,"L_MAGIC\t%d\t%hd\t%ld\t%ld\t0\t%s\n",CHG_MGK,country,ntn[country].powers,x,"null")
X#define	I_APLUS	fprintf(fexe,"INC_APLUS\t%d\t%hd\t0\t0\t0\t%s\n",INCAPLUS,country,"null")
X#define	I_DPLUS	fprintf(fexe,"INC_DPLUS\t%d\t%hd\t0\t0\t0\t%s\n",INCDPLUS,country,"null")
X#define	AADJMERC fprintf(fexe,"A_MERC\t%d\t%d\t%ld\t0\t0\t%s\n",MSETA,country,men,"null")
X#define	AADJDISB fprintf(fexe,"A_MERC\t%d\t%d\t%ld\t%d\t%d\t%s\n",MSETB,country,bemerc,attset,defset,"null")
X#define	AADJSTAT fprintf(fexe,"A_STAT\t%d\t%hd\t%d\t%d\t0\t%s\n",XASTAT,country,armynum,ntn[country].arm[armynum].stat,"null")
X#define	AADJMEN	fprintf(fexe,"L_ADJMEN\t%d\t%hd\t%hd\t%ld\t%d\t%s\n",XAMEN,country,armynum,P_ASOLD,P_ATYPE,"null")
X#define	NADJCRW	fprintf(fexe,"N_ASHP\t%d\t%hd\t%hd\t%d\t%d\t%s\n",XNACREW,country,nvynum,NCREW,ntn[country].nvy[nvynum].armynum,"null")
X#define	NADJMER	fprintf(fexe,"N_ASHP\t%d\t%hd\t%d\t%hd\t%d\t%s\n",XNAMER,country,nvynum,ntn[country].nvy[nvynum].merchant,0,"null")
X#define	NADJWAR	fprintf(fexe,"N_ASHP\t%d\t%hd\t%d\t%hd\t%d\t%s\n",XNAWAR,country,nvynum,ntn[country].nvy[nvynum].warships,0,"null")
X#define	NADJGAL	fprintf(fexe,"N_ASHP\t%d\t%hd\t%d\t%hd\t%d\t%s\n",XNAGAL,country,nvynum,ntn[country].nvy[nvynum].galleys,0,"null")
X#define	NADJHLD	fprintf(fexe,"N_ASHP\t%d\t%hd\t%d\t%hd\t%d\t%s\n",XNAHOLD,country,nvynum,ntn[country].nvy[nvynum].armynum,ntn[country].nvy[nvynum].people,"null")
X#define	AADJLOC	fprintf(fexe,"A_LOC\t%d\t%hd\t%d\t%d\t%d\t%s\n",XALOC,country,armynum,ntn[country].arm[armynum].xloc,ntn[country].arm[armynum].yloc,"null")
X#define	NADJLOC	fprintf(fexe,"N_LOC\t%d\t%hd\t%d\t%d\t%d\t%s\n",XNLOC,country,nvynum,ntn[country].nvy[nvynum].xloc,ntn[country].nvy[nvynum].yloc,"null")
X#define	AADJMOV	fprintf(fexe,"A_MOV\t%d\t%hd\t%d\t%d\t0\t%s\n",XAMOV,country,armynum,ntn[country].arm[armynum].smove,"null")
X#define	NADJMOV	fprintf(fexe,"N_MOV\t%d\t%hd\t%d\t%d\t0\t%s\n",XNMOV,country,nvynum,ntn[country].nvy[nvynum].smove,"null")
X#define	ECHGNAME fprintf(fexe,"E_CNAME\t%d\t%hd\t0\t0\t0\t%s\n",XECNAME,country,ntn[country].name)
X#define	ECHGPAS	fprintf(fexe,"E_CPAS\t%d\t%hd\t0\t0\t0\t%s\n",XECPAS,country,curntn->passwd)
X#define	SADJDES	fprintf(fexe,"S_ADES\t%d\t%hd\t0\t%d\t%d\t%c\n",XSADES,country,xcurs+xoffset,ycurs+yoffset,sct[xcurs+xoffset][ycurs+yoffset].designation)
X#define	SADJDES2	fprintf(fexe,"S_ADES\t%d\t%hd\t0\t%d\t%d\t%c\n",XSADES,country,x,y,sct[x][y].designation)
X#define	SADJCIV2 fprintf(fexe,"S_ACIV\t%d\t%hd\t%ld\t%d\t%d\t%s\n",XSACIV,country,sct[i][j].people,i,j,"null")
X#define	SADJCIV	fprintf(fexe,"S_ACIV\t%d\t%hd\t%ld\t%d\t%d\t%s\n",XSACIV,country,sct[xcurs+xoffset][ycurs+yoffset].people,xcurs+xoffset,ycurs+yoffset,"null")
X#define	INCFORT fprintf(fexe,"SIFORT\t%d\t%hd\t0\t%d\t%d\t%s\n",XSIFORT,country,xcurs+xoffset,ycurs+yoffset,"null")
X#define	SADJOWN	fprintf(fexe,"S_AOWN\t%d\t%hd\t0\t%d\t%d\t%s\n",XSAOWN,country,xcurs+xoffset,ycurs+yoffset,"null")
X#define	EADJDIP(a,b)	fprintf(fexe,"E_ADJ\t%d\t%hd\t%d\t%d\t0\t%s\n",EDADJ,a,b,ntn[a].dstatus[b],"null")
X#define	EDECSPL	fprintf(fexe,"E_SPL\t%d\t%hd\t%d\t%d\t0\t%s\n",EDSPL,country,s_cost,0,"null")
X#define	NADJNTN  fprintf(fexe,"N_TAX \t%d \t%hd \t%d \t%d \t%d \tnull\n",NTAX,country,(int) curntn->tax_rate,(int) curntn->active, (int) curntn->charity)
X#define	NADJNTN2  fprintf(fexe,"N_POP \t%d \t%hd \t%d \t%d \t%d \tnull\n",NPOP,country,(int) curntn->popularity,(int) curntn->terror, (int) curntn->reputation)
X
X#define	S_MIL		0		/* position in powers array	*/
X#define	WARRIOR		0x00000001L
X#define	CAPTAIN		0x00000002L
X#define	WARLORD		0x00000004L
X#define	ARCHER		0x00000008L
X#define	CAVALRY		0x00000010L
X#define	SAPPER		0x00000020L
X#define	ARMOR		0x00000040L
X#define	AVIAN		0x00000080L
X#define	MI_MONST	0x00000100L
X#define	AV_MONST	0x00000200L
X#define	MA_MONST	0x00000400L
X#define	E_MIL		11
X		/*CIVILIAN POWERS	*/
X#define	S_CIV		11
X#define	SLAVER		0x00000800L
X#define	DERVISH		0x00001000L
X#define	HIDDEN		0x00002000L
X#define	ARCHITECT	0x00004000L
X#define	RELIGION	0x00008000L
X#define	MINER		0x00010000L
X#define	BREEDER		0x00020000L
X#define	URBAN		0x00040000L
X#define	STEEL		0x00080000L
X#define	NINJA		0x00100000L
X#define	SAILOR		0x00200000L
X#define	DEMOCRACY	0x00400000L
X#define	ROADS		0x00800000L
X#define	E_CIV		13
X			/* MAGICAL SKILLS	*/
X#define	S_MGK		24
X#define	THE_VOID	0x01000000L
X#define	KNOWALL		0x02000000L
X#define	DESTROYER	0x04000000L
X#define	VAMPIRE		0x08000000L
X#define	SUMMON		0x10000000L
X#define	WYZARD		0x20000000L
X#define	SORCERER	0x40000000L
X#define	E_MGK		7
X#define	MAXPOWER	31 /* number of powers	*/
X
X/* magic macro: returns TRUE if the nation has that power*/
X#define	magic(NATION,POWER)	((ntn[NATION].powers&(POWER))!=0)
X#define	ONMAP(x,y)	(x>=0 && y>=0 && x<MAPX && y<MAPY)
X
X#ifndef HILIGHT
X#define	standout()
X#endif HILIGHT
X
X#ifdef BEEP
X#define	beep()		putc('\007',stderr)
X#else
X#define	beep()
X#endif
X
X#ifdef SYSV
Xextern	long		lrand48();
X#define	rand()		lrand48()
X#define	srand(x)	srand48(x)
X#endif
X
X#ifdef	BSD
X#define	rand()		random()
X#define	srand(x)	srandom(x)
X#endif
X
X#ifndef DEBUG
X#define	check()	;
X#else
X#define	check()	checkout(__FILE__,__LINE__)
X#endif DEBUG
X
X#define	GOLDTHRESH	10	/* min ratio of gold:jewels */
X
X#define	SALT "aa"		/* seed for crypt() encryption	*/
X
X/* extern all subroutine calls	*/
Xextern long	getmagic(), getmagic(), getmgkcost(), score_one();
Xextern long	get_number(), solds_in_sector(),defaultunit();
X
Xextern int	move_file(), land_2reachp(), land_reachp(), canbeseen();
Xextern int	water_reachp(), markok(), is_habitable();
Xextern int	units_in_sector(), num_powers(), tofood();
Xextern int	get_god(), flightcost(), todigit(), getclass(), startcost();
Xextern int	water_2reachp(),tg_ok(), readmap(), avian();
Xextern int	cbonus(), armymove(),takeover(),getnewname();
Xextern int	getleader(),execute(),peasant_revolt(),other_revolt();
Xextern int	aretheyon(),armygoto(),navygoto(),getselunit();
Xextern int	unitvalid(),access(),orctake(),fort_val();
Xextern int	addgships(),addmships(),addwships(),fltships();
Xextern int	fltghold(),fltwhold(),fltmhold(),flthold(),compass();
Xextern int	get_country(),check_lock(),doclass();
Xextern unsigned short	fltspeed();
Xextern void	do_pirate(), do_nomad(), do_barbarian(), do_lizard();
Xextern void	getjewel(),getmetal(),loadfleet(),removemgk(),exenewmgk();
Xextern struct	s_sector *rand_sector();
Xextern void	subgships(),submships(),subwships(),getspace(),sackem();
Xextern void	sleep(), whatcansee(), reset_god(), get_nname(), camp_info();
Xextern void	main(), makebottom(), parse(), makeside(), check_mail();
Xextern void	checkout(),copyscreen(),bye(),credits(),init_hasseen();
Xextern void	combinearmies(),change_status(),reducearmy(),splitarmy();
Xextern void	errormsg(), clear_bottom(), addgroup(),ext_cmd();
Xextern void	randomevent(), wdisaster(), weather(), deplete();
Xextern void	verify_ntn(), verify_sct(), verifydata(), prep();
Xextern void	destroy(), updmove(), spreadsheet(), mailopen(), mailclose();
Xextern void	updexecs(), updlizards(), updcapture(), updsectors();
Xextern void	updmil(), updcomodities(), updleader();
Xextern void	nationrun(), n_atpeace(), n_trespass(), n_people();
Xextern void	n_toofar(), n_unowned(), pceattr(), checkout();
Xextern void	fdxyretreat(), retreat(), rawmaterials(), createworld();
Xextern void	att_setup(), att_base(), att_bonus();
Xextern void	adjarm(),armyrpt(),atkattr(),blowup();
Xextern void	budget(),change(),cheat(),coffmap(),combat(),construct();
Xextern void	defattr(),diploscrn(),domagic(),draft(),erupt();
Xextern void	fight();
Xextern void	fill_edge(),flee(),fleetrpt(),hangup(),help();
Xextern void	highlight(),makemap(),makeside();
Xextern void	makeworld(),monster(),moveciv();
Xextern void	mymove(),navalcbt(),newdip(),newdisplay(),newlogin();
Xextern void	newspaper(),npcredes(),offmap(),place(),populate();
Xextern void	printele(),printnat(),printscore(),printveg();
Xextern void	pr_ntns(),produce();
Xextern void	readdata(),redesignate(),redomil(),reduce(),rmessage(),score();
Xextern void	see(),showscore(),update();
Xextern void	wmessage(),writedata(),getdstatus(),exit();
Xextern void	wizardry();
Xextern	char	*crypt(),**m2alloc();
X#ifdef TRADE
Xvoid trade(),uptrade(),checktrade();
X#endif TRADE
X
X#define	HI_OWN		0	/* hilight modes	*/
X#define	HI_ARMY		1
X#define	HI_NONE		2
X#define	HI_YARM		3
X#define	HI_MOVE		4
X#define HI_GOOD		5
X
X#define	DI_VEGE		1	/* display modes	*/
X#define	DI_DESI		2
X#define	DI_CONT		3
X#define	DI_FOOD		4
X#define	DI_NATI		5
X#define	DI_RACE		6
X#define	DI_MOVE		7
X#define	DI_DEFE		8
X#define	DI_PEOP		9
X#define	DI_GOLD		10
X#define	DI_METAL	11
X#define	DI_ITEMS	12
X
Xextern	struct sprd_sht
X{
X	long food,gold,jewels,metal; 		/* total @ end of turn	*/
X	long revfood,revjewels,revmetal,
X	     revcap,revcity,revothr; 		/* revenue in turn	*/
X	long ingold,inmetal,infarm,incity,incap,inothr; 
X						/* civilians in area	*/
X	long civilians;				/* total civilians	*/
X	int sectors;
X} spread;
X
X#ifndef max
X#define	max(x,y)	((x)>(y) ? (x) : (y))
X#define	min(x,y)	((x)<(y) ? (x) : (y))
X#endif
X
X/* attractiveness of sector to general populace	*/
X#define	GOLDATTR	9	/* per jewel value of sector */
X#define	FARMATTR	7	/* per point of food producable */
X#define	MINEATTR	9	/* per metal value of sector */
X#define	TOWNATTR	150
X#define	CITYATTR 	300
X#define TGATTR		10	/* bonus per point of value for tradegoods */
X#define OTHRATTR	50	/* attractiveness of other sector types */
X
X
X#define	DMNTNATTR	40	/* DWARF ATTRACTIVENESS	*/
X#define	DHILLATTR	20
X#define	DCLERATTR	0
X#define	DCITYATTR	-20
X#define	DTOWNATTR	-20
X#define	DGOLDATTR	40
X#define	DMINEATTR	40
X#define	DFOREATTR	-20
X#define	DWOODATTR	-10
X
X#define	EMNTNATTR	-40	/* ELF	*/
X#define	EHILLATTR	-20
X#define	ECLERATTR	0
X#define	ECITYATTR	-50
X#define	ETOWNATTR	-50
X#define	EGOLDATTR	0
X#define	EMINEATTR	0
X#define	EFOREATTR	40
X#define	EWOODATTR	40
X
X#define	OMNTNATTR	30	/* ORC	*/
X#define	OHILLATTR	20
X#define	OCLERATTR	0
X#define	OCITYATTR	50
X#define	OTOWNATTR	25
X#define	OGOLDATTR	20
X#define	OMINEATTR	20
X#define	OFOREATTR	-40
X#define	OWOODATTR	-20
X
X#define	HMNTNATTR	-10	/* HUMAN	*/
X#define	HHILLATTR	0
X#define	HCLERATTR	30
X#define	HCITYATTR	50
X#define	HTOWNATTR	40
X#define	HGOLDATTR	10
X#define	HMINEATTR	10
X#define	HFOREATTR	-20
X#define	HWOODATTR	0
X
X/* EXOTIC TRADE GOODS	*/
X#define	TG_furs		0
X#define	TG_wool		1
X#define	TG_beer		2
X#define	TG_cloth	3
X#define	TG_wine		4
X#define	END_POPULARITY	4
X
X#define	TG_mules	5
X#define	TG_horses	6
X#define	TG_pigeons	7
X#define	TG_griffons	8
X#define	END_COMMUNICATION	8
X
X#define	TG_corn		9
X#define	TG_fish		10
X#define	TG_sugar	11
X#define	TG_honey	12
X#define	TG_fruit	13
X#define	TG_rice		14
X#define	TG_wheat	15
X#define	TG_dairy	16
X#define	TG_peas		17
X#define	TG_bread	18
X#define	TG_cereal	19
X#define	END_EATRATE	19
X
X#define	TG_pottery	20
X#define	TG_salt		21
X#define	TG_timber	22
X#define	TG_granite	23
X#define	TG_pine		24
X#define	TG_oak		25
X#define	TG_nails	26
X#define	END_SPOILRATE	26	/* also Knowledge start */
X
X#define	TG_papyrus	27
X#define	TG_math		28
X#define	TG_library	29
X#define	TG_drama	30
X#define	TG_paper	31
X#define	TG_literature	32
X#define	TG_law		33
X#define	TG_philosophy	34
X#define	END_KNOWLEDGE	34
X
X#define	TG_irregation	35
X#define	TG_oxen		36
X#define	TG_plows	37
X#define	END_FARM	37	
X
X#define	TG_stones	38
X#define	END_SPELL	38
X
X#define	TG_herbs	39
X#define	TG_medecine	40
X#define	END_HEALTH	40
X
X#define	TG_torture	41
X#define	TG_prison	42
X#define	END_TERROR	42	
X#define	END_NORMAL	42	/* also end of non mine/jewel goods */
X
X#define	TG_bronze	43
X#define	TG_copper	44
X#define	TG_lead		45
X#define	TG_tin		46
X#define	TG_iron		47
X#define	TG_steel	48
X#define	TG_mithral	49
X#define	TG_adamantine	50
X#define	END_MINE	50
X
X#define	TG_spice	51
X#define	TG_silver	52
X#define	TG_pearls	53
X#define	TG_dye		54
X#define	TG_silk		55
X#define	TG_gold		56
X#define	TG_rubys	57
X#define	TG_ivory	58
X#define	TG_diamonds	59
X#define	TG_platinum	60
X#define	END_WEALTH	60
X#define	TG_none		61	/* no trade goods in sector	*/
X#define MAXTGVAL	100	/* maximum value for stat */
X
X/* defines for a nations class	*/
X#define	C_NPC		0
X#define	C_KING		1
X#define	C_EMPEROR	2
X#define	C_WIZARD	3
X#define	C_PRIEST	4
X#define	C_PIRATE	5
X#define	C_TRADER	6
X#define	C_WARLORD	7
X#define	C_DEMON		8
X#define	C_DRAGON	9
X#define	C_SHADOW	10
X#define	C_END		10
X
X#define	ISCITY(desig)	((desig==DCITY)||(desig==DCAPITOL)||(desig==DFORT)||(desig==DTOWN))
X
X#define	PWR_NA	10	/* national attributes gained from power	*/
X#define	CLA_NA	30	/* national attributes gained from class	*/
X
X/* MAGIC/CIVILIAN/MILITARY POWER COSTS BY RACE	*/
X#define	BASEMAGIC	50000L	/* default for all not mentioned	*/
X#define	DWFMAGIC	80000L
X#define	HUMMAGIC	100000L
X#define	ORCMAGIC	150000L
X#define	DWFCIVIL	40000L
X#define	ORCCIVIL	75000L
X#define	HUMCIVIL	25000L
X#define	DWFMILIT	40000L
X#define	ORCMILIT	45000L
X
X#define	abrt() { \
Xfprintf(stderr,"\nSerious Error (File %s, Line %d) - Aborting\n",__FILE__,__LINE__); \
Xabort(); \
X}
X
X#define	DEVASTATE(X,Y) { \
Xif(is_habitable(X,Y)) { \
Xif((sct[X][Y].designation == DCAPITOL) \
X||(sct[X][Y].designation == DRUIN) \
X||(sct[X][Y].designation == DCITY)) { \
X	if(sct[X][Y].fortress >= 4) { \
X		sct[X][Y].fortress -= 4; \
X	} else sct[X][Y].fortress = 0; \
X	sct[X][Y].designation = DRUIN; \
X} else sct[X][Y].designation = DDEVASTATED; \
X} \
X}
X
Xextern	FILE	*fm;
Xextern	int	mailok;
Xextern	char	*seasonstr[];
Xextern	char	*allignment[];	
Xextern	struct	s_sector	**sct;
Xextern	struct	s_nation	ntn[NTOTAL];
Xextern	struct	s_nation	*curntn;	
Xextern	struct	s_world		world;
X
Xextern	short	**movecost;
Xextern	char	**occ;		/* sector occupied?, NTOTAL+1 if contested */
Xextern	char	*ele, *elename[], *veg,	*vegfood, *vegname[];
Xextern	char	*Class[],*races[],*diploname[];
Xextern	char	*soldname[], *unittype[], *shunittype[], *directions[];
Xextern	int	unitminsth[], u_enmetal[], u_encost[], unitmaint[];
Xextern	char	*des, *desname[], *pwrname[];
Xextern	long	powers[];
Xextern	char	*tg_value, *tg_name[], *tg_stype;	/* trade goods	*/
X
X#ifdef CONQUER
Xextern	long	mercgot;
X#endif CONQUER
X
X#ifdef ADMIN
Xextern	char	*npcsfile;
Xextern	char	scenario[];
X#endif ADMIN
Xextern	int	unitmove[], unitattack[], unitdefend[];
X
X/*	file name definitions	*/
Xextern	char *sortname,*exefile,*datafile,*msgfile,*helpfile,*newsfile,*isonfile;
X
X#ifdef CONQUER
Xextern	int	conq_mail_status;
Xextern	char	conqmail[];
X#ifdef SYSMAIL
Xextern	int	sys_mail_status;
Xextern	char	sysmail[];
X#endif SYSMAIL
X#endif CONQUER
X#ifdef TRADE
Xextern	char	*tradefile;
X#endif TRADE
X
X#define EXT_CMD '\033'		/* ESC to start extended command */
X
X#define MAXX		(MAPX / 8)	/* Number of X areas on map */
X#define MAXY		(MAPY / 8)	/* Number of Y areas on map */
X#define NUMAREAS	(MAXX * MAXY)	/* total # areas, MAXX*MAXY */
X#define NUMSECTS	(MAPX * MAPY)	/* total # areas, MAXX*MAXY */
X#define MAXHELP		6
X
X#ifdef HPUX
X#define SYSV
X#endif HPUX
X
X/* minor market items */
X#define GETFOOD		97		/* response needed to get food */
X#define GETMETAL	98
X#define GETJEWL		99
X#define GODFOOD		8000L		/* food recieved for GODPRICE */
X#define GODMETAL	2000L		/* " */
X#define GODJEWL		3000L		/* " */
X#define GODPRICE	25000L
X
X#ifdef 0
X/* THE FOLLOWING DEFINES ARE NOT IMPLEMENTED YET		*/
X/* THEY DEFINE THE ATTRIBUTES OF A (TO BE IMPLEMENTED) REGION	*/
X
X/* REGIONS REVOLT STATUS:	if larger than the value	*/
X#define	R_OPEN_REVOLT	220
X#define R_GUERILLA_WAR	170
X#define R_UNREST	150
X#define R_DISSENT	120
X#define R_CALM		80
X#define R_HAPPY		50
X#define R_PROSPEROUS	0
X
X/* REGIONS GOVERNMENTAL STRENGTH	*/
X#define R_BARBARIAN	0
X#define R_IND_VILAGES	20
X#define R_TRIBAL	40
X#define R_CITY_STATES	80
X#define R_BALKANIZED	110
X#define R_CONFEDERACY	140
X#define R_NATION	160
X#define R_MONARCHY	180
X#define R_EMPIRE	200
X
X/* REGION STRATEGY: region strategy by owning nation	*/
X#define R_ISOLATION	37
X#define R_BUILD_ECON	36
X#define R_EXPAND_PCE	35
X#define R_TAX		34
X#define R_BUILD_MIL	33
X#define R_EXPAND_MIL	32
X#define R_AT_WAR	31
X#define R_SUBDUE	20	/* 20-30: # of turns left in unrest	*/
X#define R_CIVIL_WAR	0	/* 0-19: number of turns left in war	*/
X
X#define	NUMREGIONS	250	/* number of regions in the world	*/
X#define	STARTYEAR	-10000	/* year that game treats as 0.  In this	
X					case - ten thousand years B.C	*/
X
Xstruct s_region
X{
X	char	*name;			/* name of region	*/
X	long	people;			/* civilians in sector*/
X	long	tax;			/* tax production ability*/
X	unsigned char owner;		/* nation id of owner	*/
X	unsigned char color;		/* color to display region*/
X	unsigned char tech_level;	/* technology level	*/
X	unsigned char law_level;	/* law level of region	*/
X	unsigned char social_level;	/* social level of region*/
X	unsigned char govt_sth;	/* owners sth. in region	*/
X	unsigned char strategy;	/* owners strategy in region	*/
X	unsigned char revolt;	/* status of region	*/
X	unsigned char prestige;	/* prestige for owning	*/
X};
X#endif 0
END_OF_FILE
if test 31789 -ne `wc -c <'data.h'`; then
    echo shar: \"'data.h'\" unpacked with wrong size!
fi
# end of 'data.h'
fi
if test -f 'magic.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'magic.c'\"
else
echo shar: Extracting \"'magic.c'\" \(22754 characters\)
sed "s/^X//" >'magic.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 "header.h"
X#include "data.h"
X#include <ctype.h>
X
Xextern short country;
Xextern short redraw;
Xextern FILE *fexe;
Xextern FILE *fnews;
X
X/*give player one new magic power in current magic (powers)*/
X/*do nothing if that player has that power or it is not permitted*/
X/*getmagic() returns the value of the power gained, and stores it in power*/
X
Xlong
Xgetmagic(type)
Xint type;
X{
X	long newpower;
X	int start,end;
X	switch(type){
X		case M_MGK:
X			start=S_MGK;
X			end=E_MGK;
X			break;
X		case M_CIV:
X			start=S_CIV;
X			end=E_CIV;
X			break;
X		case M_MIL:
X			start=S_MIL;
X			end=E_MIL;
X			break;
X		default:
X			printf("fatal error in num_powers");
X			abrt();
X	}
X	newpower=powers[start+(rand()%end)];
X	if(newpower==0) {
X		printf("ILLEGAL POWER");
X		abrt();
X	}
X
X	if((newpower==WARRIOR)||(newpower==CAPTAIN)||(newpower==WARLORD)){
X		if(magic(country,WARRIOR)!=TRUE){
X			curntn->powers|=WARRIOR;
X			return(WARRIOR);
X		}
X		else if(magic(country,CAPTAIN)!=TRUE){
X			curntn->powers|=CAPTAIN;
X			return(CAPTAIN);
X		}
X		else if(magic(country,WARLORD)!=TRUE){
X			curntn->powers|=WARLORD;
X			return(WARLORD);
X		}
X		else return(0L);
X	}else if((newpower==MI_MONST) ||(newpower==AV_MONST) ||(newpower==MA_MONST)){
X		if(curntn->race!=ORC) return(0L);
X		if(magic(country,MI_MONST)!=TRUE){
X			curntn->powers|=MI_MONST;
X			return(MI_MONST);
X		}
X		else if(magic(country,AV_MONST)!=TRUE){
X			curntn->powers|=AV_MONST;
X			return(AV_MONST);
X		}
X		else if(magic(country,MA_MONST)==TRUE){
X			curntn->powers|=MA_MONST;
X			return(MA_MONST);
X		}
X		else return(0L);
X	}else if(newpower==CAVALRY){
X		if(curntn->race==ORC) return(0L);
X		if(isnotpc(curntn->active)) return(0L);	/*npc nation*/
X		if(magic(country,newpower)==TRUE) return(0L);
X		curntn->powers|=newpower;
X		return(newpower);
X	}else if(newpower==URBAN){
X		if(magic(country,BREEDER)==TRUE) return(0L);
X		if(magic(country,newpower)==TRUE) return(0L);
X		curntn->powers|=newpower;
X		return(newpower);
X	}else if(newpower==RELIGION){
X		if(curntn->race==ORC) return(0L);
X		if(magic(country,newpower)==TRUE) return(0L);
X		curntn->powers|=newpower;
X		return(newpower);
X	}else if(newpower==KNOWALL){
X#ifdef OGOD
X#ifdef HIDELOC
X	     /* only god should have KNOWALL if sectors hidden */
X	     if(country!=0) return(0L);
X#endif
X#endif
X	     if(magic(country,KNOWALL)==TRUE) return(0L);
X	     curntn->powers|=KNOWALL;
X	     return(KNOWALL);
X	}else if((newpower==SLAVER)
X	||(newpower==DERVISH)
X	||(newpower==HIDDEN)
X	||(newpower==ARCHITECT)
X	||(newpower==THE_VOID)
X	||(newpower==ARCHER)){
X		if((magic(country,newpower)==TRUE)
X		||((newpower==DERVISH)&&(magic(country,DESTROYER)==TRUE)))
X			 return(0L);
X		curntn->powers|=newpower;
X		return(newpower);
X	}else if(newpower==DESTROYER){
X		if((curntn->race!=ELF)
X		&&(magic(country,DESTROYER)!=TRUE)
X		&&(magic(country,DERVISH)!=TRUE)){
X			curntn->powers|=DESTROYER;
X			return(DESTROYER);
X		}
X		return(0L);
X	}else if(newpower==VAMPIRE){
X		if((curntn->race!=ELF)&&(magic(country,VAMPIRE)!=TRUE)){
X			curntn->powers|=VAMPIRE;
X			return(VAMPIRE);
X		}
X		return(0L);
X	}else if(newpower==MINER){
X		if((curntn->race!=ELF)&&(curntn->race!=DWARF)&&(magic(country,MINER)!=TRUE)){
X			curntn->powers|=MINER;
X			return(MINER);
X		}
X		return(0L);
X	}else if(newpower==STEEL){
X		if(magic(country,STEEL)==TRUE) return(0L);
X		if(magic(country,MINER)!=TRUE) return(0L);
X		curntn->powers|=STEEL;
X		return(STEEL);
X	}else if(newpower==BREEDER){
X		if(magic(country,URBAN)==TRUE) return(0L);
X		if(magic(country,BREEDER)==TRUE) return(0L);
X		if(curntn->race!=ORC) return(0L);
X		curntn->powers|=BREEDER;
X		return(BREEDER);
X	}
X	else if(isnotpc(curntn->active)) {
X		return(0L);	/* remaining powers only for pc's */
X	} else if((newpower==NINJA)
X	||(newpower==SLAVER)
X	||(newpower==SAILOR)
X	||(newpower==DEMOCRACY)
X	||(newpower==ROADS)
X	||(newpower==SAPPER)
X	||(newpower==ARMOR)
X	||(newpower==AVIAN)){
X		if(magic(country,newpower)==TRUE) return(0L);
X		curntn->powers|=newpower;
X		return(newpower);
X	}
X	else if((newpower==SUMMON)||(newpower==WYZARD)||(newpower==SORCERER)){
X		/* dwarves may not cast spells */
X		if(curntn->race==DWARF) return(0L);
X		if(magic(country,SUMMON)!=TRUE) {
X			curntn->powers|=SUMMON;
X			return(SUMMON);
X		} else if(magic(country,WYZARD)!=TRUE) {
X			curntn->powers|=WYZARD;
X			return(WYZARD);
X		} else if(magic(country,SORCERER)!=TRUE) {
X			curntn->powers|=SORCERER;
X			return(SORCERER);
X		} else return(0L);
X	} else return(0L);
X}
X#ifdef CONQUER
X/*form to interactively get a magic power*/
Xvoid
Xdomagic()
X{
X	int count, done=FALSE, loop=0, i,type;
X	long price,x;
X	short isgod=0;
X	if(country==0) {
X		isgod=TRUE;
X		if (get_god()) return;
X	}
X
X	while(done==FALSE){
X		done=TRUE;
X		clear();
X		count=3;
X		redraw=TRUE;
X		standout();
X		mvprintw(0,(COLS/2)-15,"MAGIC POWERS FOR %s",curntn->name);
X		mvprintw(count++,30,"1) %d military powers: %ld jewels",
X			num_powers(country,M_MIL) ,getmgkcost(M_MIL,country));
X		mvprintw(count++,30,"2) %d civilian powers: %ld jewels",
X			num_powers(country,M_CIV) ,getmgkcost(M_CIV,country));
X		mvprintw(count++,30,"3) %d magic powers:    %ld jewels",
X			num_powers(country,M_MGK),getmgkcost(M_MGK,country));
X
X		price =  getmgkcost(M_MIL,country);
X		if(price > getmgkcost(M_CIV,country))
X			price = getmgkcost(M_CIV,country);
X		if(price > getmgkcost(M_MGK,country))
X			price = getmgkcost(M_MGK,country);
X#ifdef OGOD
X		if (isgod==TRUE) price=0;
X#endif OGOD
X
X		standend();
X		count=3;
X		/*print the powers that you have*/
X		i=0;
X		while( powers[i] != 0 ){
X			if(magic(country,powers[i])==TRUE)
X			mvprintw(count++,0,"you have power %s",*(pwrname+i));
X			i++;
X		}
X
X		if(count<=7) count=8;
X		else count++;
X		standout();
X		mvprintw(count++,0,"YOU HAVE %ld JEWELS IN YOUR TREASURY",curntn->jewels);
X		if(price < curntn->jewels){
X		mvaddstr(count++,0,"DO YOU WISH TO BUY A RANDOM NEW POWER (enter y or n):");
X		standend();
X		refresh();
X		count++;
X		if(getch()=='y'){
X			done=FALSE;
X			mvprintw(count++,0,"ENTER SELECTION (1,2,3):");
X			refresh();
X			type = getch() - '0';
X			if(type==M_MIL || type==M_CIV || type==M_MGK){
X			price=getmgkcost(type,country);
X#ifdef OGOD
X			if (isgod==TRUE) price=0;
X#endif OGOD
X			if(curntn->jewels>=price) {
X				loop = 0;
X				while(loop++ < 500) if((x=getmagic(type))!=0){
X					curntn->jewels -= price;
X					CHGMGK;
X					exenewmgk(x);
X					refresh();
X					if (isgod==TRUE) reset_god();
X					break;
X				}
X				if (loop >= 500)
X					errormsg("You have too many powers!");
X			} else errormsg("CAN'T AFFORD A NEW POWER");
X			} else errormsg("BAD SELECTION");
X		}
X		} else {
X			mvaddstr(LINES-1,0,"CAN'T AFFORD A NEW POWER");
X			clrtoeol();
X			mvaddstr(LINES-1,60,"PRESS ANY KEY");
X			refresh();
X			standend();
X			getch();
X		}
X#ifdef ORCTAKE
X		if((curntn->race==ORC)&&(curntn->jewels>=ORCTAKE)&&(curntn->spellpts>=TAKEPOINTS))
X			done |= orctake(&count);
X#endif ORCTAKE
X#ifdef OGOD
X		if (isgod==TRUE) {
X			mvaddstr(count++,0,"GOD: REMOVE A MAGIC POWER? (y or n)");
X			refresh();
X			if (getch()=='y') killmagk();
X		}
X#endif OGOD
X	}
X	if(isgod==TRUE) reset_god();
X}
X#endif CONQUER
X#ifdef ORCTAKE
X/*do magic for both npcs and pcs in update*/
X/*if target is 0 then it is update and target will be picked randomly*/
Xint
Xtakeover(percent,target)
Xint percent,target;
X{
X	int loop=1,y,save,isupdate=0;
X	save=country;
X	if(target==country) return(0);
X	if(target==0) isupdate=1;
X	country=target;
X	if(rand()%100<percent){
X		loop=0;
X		y=0;
X		if (target==0) while(loop==FALSE){
X			y++;
X			country=rand()%NTOTAL;
X			if((ntn[country].race==ntn[save].race)
X			&&(isnpc(ntn[country].active))
X			&&(curntn->dstatus[country]<HOSTILE)
X			&&(curntn->dstatus[country]!=UNMET)
X			&&(country!=save))
X				loop=TRUE;
X			else if(y>=500) {
X				country=save;
X				return(0);
X			}
X		}
X		sct[ntn[country].capx][ntn[country].capy].owner=save;
X		if(isupdate==1){
X		printf("nation %s magically taken over by %s\n",ntn[country].name,ntn[save].name);
X		fprintf(fnews,"1.\tnation %s magically taken over by %s\n",ntn[country].name,ntn[save].name);
X		}
X		else {
X			DESTROY;
X			if ((fnews=fopen("/dev/null","w"))==NULL){
X				printf("error opening null file\n");
X				exit(FAIL);
X			}
X		}
X		destroy(country);
X		sct[ntn[country].capx][ntn[country].capy].designation=DCITY;
X		if(isupdate!=1) fclose(fnews);
X		y=country;
X		country=save;
X		return(y);
X	}
X	country=save;
X	return(0);
X}
X#endif ORCTAKE
X
X/*execute new magic*/
Xvoid
Xexenewmgk(newpower)
Xlong newpower;
X{
X	short x,armynum;
X#ifdef ADMIN
X	short y;
X#endif
X	if(newpower==WARRIOR) {
X		curntn->aplus+=10;
X		curntn->dplus+=10;
X		return;
X	}
X	if(newpower==CAPTAIN) {
X		curntn->aplus+=10;
X		curntn->dplus+=10;
X		return;
X	}
X	if(newpower==WARLORD) {
X		curntn->aplus+=10;
X		curntn->dplus+=10;
X		return;
X	}
X	if(newpower==RELIGION) {
X		if(curntn->race==ORC) {
X			printf("ORCS CANT HAVE RELIGION POWER\n");
X			abrt();
X		} else if(curntn->repro<=8){
X			curntn->repro+=2;
X		} else if(curntn->repro==9){
X			curntn->repro=10;
X			curntn->dplus+=5;
X		} else if(curntn->repro>=10){
X			curntn->dplus+=10;
X		}
X		return;
X	}
X	if(newpower==DESTROYER) {
X/* this ifdef is so that destroyer only takes place in an update */
X#ifdef ADMIN
X		for(x=curntn->capx-3;x<=curntn->capx+3;x++) {
X			for(y=curntn->capy-3;y<=curntn->capy+3;y++){
X				if((ONMAP(x,y))
X				&&(sct[x][y].altitude!=WATER)
X#ifdef DERVDESG
X				&&((rand()%2)==0)
X#else
X				&&(tofood( &sct[x][y],0)<6)
X#endif DERVDESG
X				&&((x!=curntn->capx)
X					||(y!=curntn->capy))){
X					sct[x][y].vegetation=DESERT;
X					sct[x][y].designation=DNODESIG;
X				}
X			}
X		}
X		fprintf(fnews,"1.\tnation %s gets destroyer power: land turns to desert\n",curntn->name);
X#endif ADMIN
X		updmove(curntn->race,country);
X		return;
X	}
X	if(newpower==DERVISH) {
X		updmove(curntn->race,country);
X		return;
X	}
X	if((newpower==MI_MONST)
X	||(newpower==AV_MONST)
X	||(newpower==MA_MONST)
X	||(newpower==KNOWALL)
X	||(newpower==HIDDEN)
X	||(newpower==THE_VOID)
X	||(newpower==ARCHITECT)
X	||(newpower==MINER))
X		return;
X	if(newpower==VAMPIRE) {
X		curntn->aplus-=35;
X		curntn->dplus-=35;
X		for(armynum=0;armynum<MAXARM;armynum++){
X			if((P_ATYPE == A_INFANTRY)||(P_ATYPE == A_MILITIA))
X				P_ATYPE=A_ZOMBIE;
X		}
X		return;
X	}
X	if(newpower==URBAN) {
X		if(curntn->race==ORC) {
X			x=curntn->repro;
X			if(curntn->repro>=14){
X				curntn->maxmove+=3;
X			}
X			else if(curntn->repro>11){
X				curntn->maxmove+= x-11;
X				curntn->repro=14;
X			}
X			else curntn->repro+=3;
X		}
X		else if(curntn->repro<=9){
X			curntn->repro+=3;
X		}
X		else {
X			curntn->maxmove+=2*(curntn->repro-9);
X			curntn->repro=12;
X		}
X		return;
X	}
X	if(newpower==BREEDER) {
X		x=curntn->repro;
X		if(curntn->repro>=14){
X			curntn->maxmove+=3;
X		}
X		else if(curntn->repro>11){
X			curntn->maxmove+= x-11;
X			curntn->repro=14;
X		}
X		else curntn->repro+=3;
X		curntn->dplus-=10;
X		curntn->aplus-=10;
X		return;
X	}
X	if(newpower==DEMOCRACY){
X		curntn->maxmove+=1;
X		curntn->repro+=1;
X		curntn->dplus+=10;
X		curntn->aplus+=10;
X		return;
X	}
X	if(newpower==ROADS){
X		curntn->maxmove+=4;
X		return;
X	}
X	if(newpower==ARMOR){
X		curntn->maxmove-=3;
X		if( curntn->maxmove<4) curntn->maxmove=4;
X		curntn->dplus+=20;
X	}
X	if((newpower==NINJA)
X	||(newpower==STEEL)
X	||(newpower==ARCHER)
X	||(newpower==CAVALRY)
X	||(newpower==SAILOR)
X	||(newpower==SUMMON)
X	||(newpower==WYZARD)
X	||(newpower==SORCERER)
X	||(newpower==SAPPER)
X	||(newpower==AVIAN)){	/* these powers are only for pc's */
X		return;
X	}
X}
X#ifdef CONQUER
X/* returns 0 if summon occurred, 1 else */
Xvoid
Xdosummon()
X{
X	int x,count,i,armynum;
X	long e_cost;
X	int newtype,s_cost;
X	char line[80],ch;
X
X	x=0;
X	count=LINES-4;
X	clear_bottom(0);
X	mvaddstr(count,x,"options:");
X	x+=9;
X	for(i=MINMONSTER;i<=MAXMONSTER;i++){
X		if(unitvalid(i)==TRUE) {
X			mvprintw(count,x+2,"%s",*(shunittype+(i%UTYPE)));
X			mvprintw(count,x,"(%c)",*(shunittype+(i%UTYPE))[0]);
X			x+=7;
X			if(x>COLS-20){
X				x=0;
X				count++;
X			}
X		}
X	}
X	count++;
X	mvaddstr(count++,0,"what type of unit do you want to raise:");
X	refresh();
X	ch=getch();
X	for(newtype=MINMONSTER;newtype<=MAXMONSTER;newtype++){
X		if( *(shunittype+(newtype%UTYPE))[0] == ch ) break;
X	}
X
X	if (newtype==MAXMONSTER+1) {
X		/* quick exit */
X		return;
X	}
X	if(unitvalid(newtype)==FALSE) {
X		beep();
X		clear_bottom(0);
X		errormsg("you are unable to summon that monster");
X		return;
X	}
X
X	s_cost= *(u_encost+(newtype%UTYPE));
X	if(s_cost > curntn->spellpts) {
X		sprintf(line,"you dont have %d spell points",s_cost);
X		clear_bottom(0);
X		errormsg(line);
X		return;
X	}
X
X	e_cost= (long) *(u_encost+(newtype%UTYPE)) * *(unitminsth+(newtype%UTYPE));
X	if(e_cost >  curntn->tgold) {
X		sprintf(line,"you dont have %ld gold talons in your treasury",e_cost);
X		clear_bottom(0);
X		errormsg(line);
X		return;
X	}
X
X	armynum=0;
X	while(armynum<MAXARM) {
X		if(P_ASOLD<=0) {
X			P_ASOLD= *(unitminsth+(newtype%UTYPE));
X			P_ATYPE=newtype;
X			P_ASTAT=DEFEND; /* set new armies to DEFEND */
X			P_AXLOC=curntn->capx;
X			P_AYLOC=curntn->capy;
X			P_AMOVE=0;
X			AADJLOC;
X			AADJSTAT;
X			AADJMEN;
X			AADJMOV;
X			armynum=MAXARM;
X		} else if(armynum==MAXARM-1) {
X			clear_bottom(0);
X			errormsg("NO FREE ARMIES");
X			return;
X		} else armynum++;
X  	}
X  	curntn->tgold -= e_cost;
X  	curntn->spellpts -= s_cost;
X	EDECSPL;
X}
X#ifdef ORCTAKE
X/* orc takeover routine... returns 0 if run, 1 if not */
Xint
Xorctake(count)
Xint *count;
X{
X	int chance=0,done=TRUE,i,s_cost;
X	if((*count)>20) {
X		(*count)=2;
X		clear();
X	}
X	if(magic(country,MA_MONST)==TRUE) {
X	mvprintw((*count)++,0,"  You have a 10 percent chance for %ld Jewels take over other orcs",ORCTAKE);
X	chance=10;
X	} else if(magic(country,AV_MONST)==TRUE) {
X	mvprintw((*count)++,0,"  You have a 6 percent chance for %ld Jewels take over other orcs",ORCTAKE);
X	chance=6;
X	} else if(magic(country,MI_MONST)==TRUE){
X	mvprintw((*count)++,0,"  You have a 3 percent chance for %ld Jewels to take over other orcs",ORCTAKE);
X	chance=3;
X	}
X	if(chance==0) return(TRUE);
X
X	mvaddstr((*count)++,0,"DO YOU WISH TO TAKE OVER AN ORC NPC NATION");
X	mvaddstr((*count)++,0,"target cant be unmet, hostile, war, or jihad (enter y or n):");
X	refresh();
X	if(getch()=='y'){
X		done=FALSE;
X		mvaddstr((*count)++,0,"  What orc nation:");
X		refresh();
X		i=get_country();
X		if(i<=0 || i>NTOTAL || !isntn(ntn[i].active) )
X			mvaddstr((*count)++,0,"  Invalid Nation");
X		else if((curntn->dstatus[i]<HOSTILE)
X		&&(curntn->dstatus[i]!=UNMET)
X		&&(ntn[i].race==ORC)){
X			curntn->jewels-=ORCTAKE;
X			s_cost=TAKEPOINTS;
X			curntn->spellpts-=s_cost;
X			EDECSPL;
X			if(( takeover(chance,i)) !=0 )
X				mvprintw((*count)++,0," Successful: %d",i);
X			else {
X				mvaddstr((*count)++,0," Failed: Nation becomes more hostile");
X				curntn->dstatus[i]++;
X				EADJDIP(country,i);
X			}
X		}
X		else mvaddstr((*count)++,0,"  Wrong Race");
X	}
X	return(done);
X}
X#endif ORCTAKE
X#endif CONQUER
X#ifdef CONQUER
X
X/**********************************************************************/
X/* unitvalid() returns TRUE if nation has powers needed to draft unit */
X/**********************************************************************/
Xint
Xunitvalid(type)
Xint type;
X{
X	int valid=FALSE;
X	switch(type){
X		case A_INFANTRY: /* not everyone gets infantry now */
X				if(defaultunit(country)==A_INFANTRY) valid=TRUE;
X				break;
X		case GARGOYLE:
X		case A_GOBLIN:
X		case A_ORC:	if(magic(country,MI_MONST)==TRUE) valid=TRUE;
X				break;
X		case A_MARINES: if(magic(country,SAILOR)==TRUE) valid=TRUE;
X				break;
X		case A_ARCHER:	if(magic(country,ARCHER)==TRUE) valid=TRUE;
X				break;
X		case A_URUK:	if(magic(country,AV_MONST)==TRUE) valid=TRUE;
X				break;
X		case A_NINJA:	if(magic(country,NINJA)==TRUE) valid=TRUE;
X				break;
X		case A_PHALANX:	if(magic(country,CAPTAIN)==TRUE) valid=TRUE;
X				break;
X		case A_OLOG:	if((magic(country,BREEDER)==TRUE)
X				&&(magic(country,AV_MONST)==TRUE)) valid=TRUE;
X				break;
X		case A_ELEPHANT:if(magic(country,DERVISH)==TRUE)  valid=TRUE;
X				break;
X		case SUPERHERO:
X		case A_LEGION:	if(magic(country,WARLORD)==TRUE) valid=TRUE;
X				break;
X		case A_TROLL:	if(magic(country,MA_MONST)==TRUE) valid=TRUE;
X				break;
X		case A_ELITE:	if(magic(country,ARMOR)==TRUE) valid=TRUE;
X				break;
X		case CENTAUR:
X		case A_LT_CAV:
X		case A_CAVALRY:	if(magic(country,CAVALRY)==TRUE) valid=TRUE;
X				break;
X		case A_KNIGHT:	if((magic(country,ARMOR)==TRUE)
X				&&(magic(country,CAVALRY)==TRUE)) valid=TRUE;
X				break;
X		case A_ROC:
X		case A_GRIFFON: if(magic(country,AVIAN)==TRUE) valid=TRUE;
X				break;
X		case ASSASSIN:	if(magic(country,NINJA)==TRUE) valid=TRUE;
X				break;
X		case DJINNI:	if(magic(country,DERVISH)==TRUE) valid=TRUE;
X				break;
X		case HERO:	if(magic(country,WARRIOR)==TRUE) valid=TRUE;
X				break;
X		case ELEMENTAL:	if(magic(country,SORCERER)==TRUE) valid=TRUE;
X				break;
X		case A_ZOMBIE:
X		case WRAITH:
X		case MUMMY:	if(magic(country,VAMPIRE)==TRUE) valid=TRUE;
X				break;
X		case MINOTAUR:
X		case DEMON:	if(magic(country,DESTROYER)==TRUE) valid=TRUE;
X				break;
X		case BALROG:	if((magic(country,WYZARD)==TRUE)
X				&&(magic(country,VAMPIRE)==TRUE)) valid=TRUE;
X				break;
X		case DRAGON:	if((magic(country,MA_MONST)==TRUE)
X				&&(magic(country,WYZARD)==TRUE)) valid=TRUE;
X				break;
X		case A_SPY:
X		case A_SCOUT:	break;	/* handled elsewhere */
X		default:	valid=TRUE;	/* for all unrestricted types */
X	}
X	return(valid);
X}
X#endif CONQUER
X
X/*remove properties of magic power; must first remove power */
Xvoid
Xremovemgk(oldpower)
Xlong oldpower;
X{
X	short x,y,armynum;
X	if((oldpower==WARRIOR)
X	||(oldpower==CAPTAIN)
X	||(oldpower==WARLORD)) {
X		curntn->aplus-=10;
X		curntn->dplus-=10;
X		return;
X	}
X	if(oldpower==RELIGION) {
X		if(curntn->race==ORC) {
X			printf("ORCS CANT HAVE RELIGION POWER\n");
X			abrt();
X		} else curntn->repro -= 2;
X		return;
X	}
X	if(oldpower==DESTROYER) {
X		for(x=curntn->capx-3;x<=curntn->capx+3;x++) {
X			for(y=curntn->capy-3;y<=curntn->capy+3;y++){
X				if((ONMAP(x,y))
X				&&(sct[x][y].altitude!=WATER)
X				&&((x!=curntn->capx)
X					||(y!=curntn->capy))){
X					if (sct[x][y].vegetation==DESERT)
X					{
X						/* LT_VEG has medium value*/
X						sct[x][y].vegetation=LT_VEG;
X						sct[x][y].designation=DNODESIG;
X					}
X				}
X			}
X		}
X		updmove(curntn->race,country);
X		return;
X	}
X	if(oldpower==DERVISH) {
X		updmove(curntn->race,country);
X		return;
X	}
X	if(oldpower==VAMPIRE) {
X		curntn->aplus+=35;
X		curntn->dplus+=35;
X		for(armynum=0;armynum<MAXARM;armynum++){
X			if(P_ATYPE == A_ZOMBIE) P_ATYPE=defaultunit(country);
X		}
X		return;
X	}
X	if(oldpower==URBAN) {
X		curntn->repro -= 3;
X		return;
X	}
X	if(oldpower==BREEDER) {
X		curntn->repro-=3;
X		curntn->dplus+=10;
X		curntn->aplus+=10;
X		for(armynum=0;armynum<MAXARM;armynum++){
X			if(P_ATYPE == A_OLOG) P_ATYPE=A_URUK;
X		}
X		return;
X	}
X	if(oldpower==DEMOCRACY){
X		curntn->maxmove-=1;
X		curntn->repro-=1;
X		curntn->dplus-=10;
X		curntn->aplus-=10;
X		return;
X	}
X	if(oldpower==ROADS){
X		curntn->maxmove-=4;
X		return;
X	}
X	if(oldpower==ARMOR){
X		curntn->maxmove+=3;
X		curntn->dplus-=20;
X		return;
X	}
X	if(oldpower==MI_MONST) {
X		for(armynum=0;armynum<MAXARM;armynum++){
X			if(P_ATYPE == A_ORC) P_ATYPE=defaultunit(country);
X		}
X		return;
X	}
X	if(oldpower==AV_MONST) {
X		for(armynum=0;armynum<MAXARM;armynum++){
X			if(P_ATYPE == A_URUK || P_ATYPE == A_OLOG)
X				P_ATYPE=defaultunit(country);
X		}
X		return;
X	}
X	if(oldpower==ARCHER) {
X		for(armynum=0;armynum<MAXARM;armynum++){
X			if(P_ATYPE == A_ARCHER) P_ATYPE=defaultunit(country);
X		}
X		return;
X	}
X	/* remaining cause no change in statistics */
X}
X
X#ifdef CONQUER
X#ifdef OGOD
X/* killmagk: this routine removes a magic power */
Xkillmagk()
X{
X	int count,choice,i;
X
X	clear();
X	count=3;
X	standout();
X	mvprintw(0,(COLS/2)-15,"MAGIC POWERS FOR %s",curntn->name);
X	standend();
X	i=0;
X	while( powers[i] != 0 ){
X		if(magic(country,powers[i])==TRUE) {
X			mvprintw(count,0,"%d: power %s",i+1,*(pwrname+i));
X			count++;
X		}
X		i++;
X	}
X	count++;
X	standout();
X	mvaddstr(count++,5," Which power to remove? ");
X	standend();
X	refresh();
X	choice=get_number();
X	if(choice!=0) {
X		mvprintw(count++,0," Remove magic #%d? (y or [n])",choice);
X		refresh();
X		if (getch()=='y') {
X			if(magic(country,powers[choice-1])) {
X				curntn->powers ^= powers[choice-1];
X				removemgk(powers[choice-1]);
X			}
X		}
X	}
X}
X#endif OGOD
X
X#define NUMSPELLS 4
Xchar *spellstr[NUMSPELLS]={"(S)ummon","(F)light","(A)ttack Enhancement",
X	"(D)efense Enhancement"};
X/* quick adjustment to allow magical status change */
Xint magicstat[NUMSPELLS]={DEFEND, FLIGHT, MAGATT, MAGDEF};
X/* number of soldiers per point of spell cost */
Xint magiccost[NUMSPELLS]={0,100,300,300};
X/* routine to perform spells */
Xvoid
Xwizardry()
X{
X	int i,xspt,yspt,choice,armynum,s_cost;
X	char line[80];
X	void dosummon();
X
X	clear_bottom(0);
X	if(curntn->spellpts>0)
X	{
X		xspt=0; yspt=LINES-3;
X		/* summon only to those with summon */
X		if (magic(country,SUMMON)==TRUE) i=0;
X		else i=1;
X		for (;i<NUMSPELLS;i++) {
X			sprintf(line,"  %s",spellstr[i]);
X			mvaddstr(yspt,xspt,line);
X			xspt += strlen(line);
X			if (xspt>COLS-20) {
X				xspt=0;
X				yspt++;
X			}
X		}
X		mvaddstr(LINES-4,0,"Which spell to cast:");
X		refresh();
X		choice=NUMSPELLS;
X		switch(getch()) {
X		case 's':
X		case 'S':
X			if (magic(country,SUMMON)==TRUE) dosummon();
X			else {
X				clear_bottom(0);
X				errormsg("you do not have SUMMON power");
X			}
X			break;
X		case 'f':
X		case 'F':
X			choice--;
X		case 'a':
X		case 'A':
X			choice--;
X		case 'd':
X		case 'D':
X			choice--;
X			/* change status of currently selected army */
X			armynum = getselunit();
X			clear_bottom(0);
X			if (armynum<0 || armynum>=MAXARM ||
X			P_ASTAT==SCOUT || P_ASTAT==TRADED ||
X			P_ASTAT==GENERAL || P_ASTAT>NUMSTATUS ||
X			P_ASOLD<=0) {
X				errormsg("Invalid Unit for Magicking");
X			} else if(P_ASTAT==ONBOARD) {
X				errormsg("Carried armies must be unloaded");
X			} else if(P_ASTAT==magicstat[choice]) {
X				errormsg("Unit has already been magicked");
X			} else if(P_ASTAT==MARCH) {
X				errormsg("That unit is too busy marching");
X			} else {
X				/*cost of 1 spell point for magiccost men*/
X				s_cost = (P_ASOLD-1) / magiccost[choice] + 1;
X				if (s_cost > curntn->spellpts) {
X					sprintf(line,"You don't have %d spell points",s_cost);
X					errormsg(line);
X				} else {
X					change_status(armynum,magicstat[choice]);
X					curntn->spellpts -= s_cost;
X					EDECSPL;
X				}
X			}
X			break;
X		default:
X			break;
X		}
X	}
X	else errormsg("You have no spell points for spell casting");
X	makebottom();
X}
X#endif CONQUER
END_OF_FILE
if test 22754 -ne `wc -c <'magic.c'`; then
    echo shar: \"'magic.c'\" unpacked with wrong size!
fi
# end of 'magic.c'
fi
echo shar: End of archive 8 \(of 14\).
cp /dev/null ark8isdone
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