xref: /dragonfly/games/phantasia/phantglobs.c (revision f746689a)
1 /*
2  * phantglobs.c - globals for Phantasia
3  *
4  * $DragonFly: src/games/phantasia/phantglobs.c,v 1.3 2005/05/31 00:06:26 swildner Exp $
5  */
6 
7 #include "include.h"
8 
9 double	drandom(void);
10 
11 double	Circle;		/* which circle player is in			*/
12 double	Shield;		/* force field thrown up in monster battle	*/
13 
14 bool	Beyond;		/* set if player is beyond point of no return	*/
15 bool	Marsh;		/* set if player is in dead marshes		*/
16 bool	Throne;		/* set if player is on throne			*/
17 bool	Changed;	/* set if important player stats have changed	*/
18 bool	Wizard;		/* set if player is the 'wizard' of the game	*/
19 bool	Timeout;	/* set if short timeout waiting for input	*/
20 bool	Windows;	/* set if we are set up for curses stuff	*/
21 bool	Luckout;	/* set if we have tried to luck out in fight	*/
22 bool	Foestrikes;	/* set if foe gets a chance to hit in battleplayer()	*/
23 bool	Echo;		/* set if echo input to terminal		*/
24 
25 int	Users;		/* number of users currently playing		*/
26 int	Whichmonster;	/* which monster we are fighting		*/
27 int	Lines;		/* line on screen counter for fight routines	*/
28 
29 jmp_buf Fightenv;	/* used to jump into fight routine		*/
30 jmp_buf Timeoenv;	/* used for timing out waiting for input	*/
31 
32 long	Fileloc;	/* location in file of player statistics	*/
33 
34 const char	*Login;		/* pointer to login of player			*/
35 const char	*Enemyname;	/* pointer name of monster/player we are battling*/
36 
37 struct	player	Player;	/* stats for player				*/
38 struct	player	Other;	/* stats for another player			*/
39 
40 struct	monster	Curmonster;/* stats for current monster			*/
41 
42 struct	energyvoid Enrgyvoid;/* energy void buffer			*/
43 
44 struct	charstats *Statptr;/* pointer into Stattable[]			*/
45 
46 /* lookup table for character type dependent statistics */
47 struct	charstats Stattable[7] =
48 	{
49 	{
50 	/* MAGIC USER */
51 	/* max brains, max mana, weakness, gold tote, ring duration */
52 	15.0, 200.0, 18.0, 175.0, 10,
53 	/* quickness,	strength,	mana */
54 	{30, 6, 0.0},	{10, 6, 2.0},	{50, 51, 75.0},
55 	/* energy,	brains,		magic lvl */
56 	{30, 16, 20.0},	{60, 26, 6.0},	{5, 5, 2.75}
57 	},
58 
59 	{
60 	/* FIGHTER */
61 	/* max brains, max mana, weakness, gold tote, ring duration */
62 	10.0, 110.0, 15.0, 220.0, 20,
63 	/* quickness,	strength,	mana */
64 	{30, 6, 0.0},	{40, 16, 3.0},	{30, 21, 40.0},
65 	/* energy,	brains,		magic lvl */
66 	{45, 26, 30.0},	{25, 21, 3.0},	{3, 4, 1.5}
67 	},
68 
69 	{
70 	/* ELF */
71 	/* max brains, max mana, weakness, gold tote, ring duration */
72 	12.0, 150.0, 17.0, 190.0, 13,
73 	/* quickness,	strength,	mana */
74 	{32, 7, 0.0},	{35, 11, 2.5},	{45, 46, 65.0},
75 	/* energy,	brains,		magic lvl */
76 	{30, 21, 25.0},	{40, 26, 4.0},	{4, 4, 2.0}
77 	},
78 
79 	{
80 	/* DWARF */
81 	/* max brains, max mana, weakness, gold tote, ring duration */
82 	7.0, 80.0, 13.0, 255.0,  25,
83 	/* quickness,	strength,	mana */
84 	{25, 6, 0.0},	{50, 21, 5.0},	{25, 21, 30.0},
85 	/* energy,	brains,		magic lvl */
86 	{60, 41, 35.0},	{20, 21, 2.5},	{2, 4, 1.0}
87 	},
88 
89 	{
90 	/* HALFLING */
91 	/* max brains, max mana, weakness, gold tote, ring duration */
92 	11.0, 80.0, 10.0, 125.0, 40,
93 	/* quickness,	strength,	mana */
94 	{34, 0, 0.0},	{20, 6, 2.0},	{25, 21, 30.0},
95 	/* energy,	brains,		magic lvl */
96 	{55, 36, 30.0},	{40, 36, 4.5},	{1, 4, 1.0}
97 	},
98 
99 	{
100 	/* EXPERIMENTO */
101 	/* max brains, max mana, weakness, gold tote, ring duration */
102 	9.0, 90.0, 16.0, 160.0, 20,
103 	/* quickness,	strength,	mana */
104 	{27, 0, 0.0},	{25, 0, 0.0},	{100, 0, 0.0},
105 	/* energy,	brains,		magic lvl */
106 	{35, 0, 0.0},	{25, 0, 0.0},	{2, 0, 0.0}
107 	},
108 
109 	{
110 	/* SUPER */
111 	/* max brains, max mana, weakness, gold tote, ring duration */
112 	15.0, 200.0, 10.0, 225.0, 40,
113 	/* quickness,	strength,	mana */
114 	{38, 0, 0.0},	{65, 0, 5.0},	{100, 0, 75.0},
115 	/* energy,	brains,		magic lvl */
116 	{80, 0, 35.0},	{85, 0, 6.0},	{9, 0, 2.75}
117 	}
118 	};
119 
120 /* menu of items for purchase */
121 struct menuitem	Menu[] =
122     {
123     {"Mana", 1},
124     {"Shield", 5},
125     {"Book", 200},
126     {"Sword", 500},
127     {"Charm", 1000},
128     {"Quicksilver", 2500},
129     {"Blessing", 1000}
130     };
131 
132 FILE	*Playersfp;	/* pointer to open player file			*/
133 FILE	*Monstfp;	/* pointer to open monster file			*/
134 FILE	*Messagefp;	/* pointer to open message file			*/
135 FILE	*Energyvoidfp;	/* pointer to open energy void file		*/
136 
137 char	Databuf[SZ_DATABUF];	/* a place to read data into		*/
138 
139 /* some canned strings for messages */
140 const char	Illcmd[] = "Illegal command.\n";
141 const char	Illmove[] = "Too far.\n";
142 const char	Illspell[] = "Illegal spell.\n";
143 const char	Nomana[] = "Not enought mana for that spell.\n";
144 const char	Somebetter[] = "But you already have something better.\n";
145 const char	Nobetter[] = "That's no better than what you already have.\n";
146 
147 /**/
148 /************************************************************************
149 /
150 / FUNCTION NAME: drandom()
151 /
152 / FUNCTION: return a random number
153 /
154 / AUTHOR: E. A. Estes, 2/7/86
155 /
156 / ARGUMENTS: none
157 /
158 / RETURN VALUE: none
159 /
160 / MODULES CALLED: random()
161 /
162 / GLOBAL INPUTS: none
163 /
164 / GLOBAL OUTPUTS: none
165 /
166 / DESCRIPTION:
167 /
168 *************************************************************************/
169 
170 double
171 drandom(void)
172 {
173     if (sizeof(int) != 2)
174 	return((double) (random() & 0x7fff) / 32768.0);
175     else
176 	return((double) random() / 32768.0);
177 }
178