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