1 /*
2 This file is part of "Avanor, the Land of Mystery" roguelike game
3 Home page: http://www.avanor.com/
4 Copyright (C) 2000-2003 Vadim Gaidukevich
5 
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10 
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 GNU General Public License for more details.
15 
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 */
20 
21 #ifndef __LOCATION_H
22 #define __LOCATION_H
23 
24 #include "point.h"
25 #include "map.h"
26 #include "xanyplace.h"
27 #include "cr_defs.h"
28 
29 enum SHOP_DOOR
30 {
31 	SHOP_DOOR_UP,
32 	SHOP_DOOR_LEFT,
33 	SHOP_DOOR_DOWN,
34 	SHOP_DOOR_RIGHT
35 };
36 
37 enum LOCATION {
38 L_UNKNOWN = 0,
39 L_MAIN,
40 L_DWARFCITYCAVE1,
41 L_DWARFCITYCAVE2,
42 L_DWARFCITYCAVE3,
43 L_DWARFCITYCAVE4,
44 L_DWARFCITYCAVE5,
45 L_DWARFCITYCAVE6,
46 L_DWARFCITYCAVE7,
47 L_DWARFCITY,
48 L_DWARFTREASURE,
49 
50 L_GASMINE1,
51 L_GASMINE2,
52 L_GASMINE3,
53 
54 L_SMALLCAVE,
55 L_RATCELLAR,
56 
57 L_MUSHROOMS_CAVE1, //first
58 L_MUSHROOMS_CAVE2, //demon
59 L_MUSHROOMS_CAVE3, //misc
60 L_MUSHROOMS_CAVE4, //kobolds
61 L_MUSHROOMS_CAVE5, //mushrooms
62 
63 L_WIZARD_DUNGEON1,
64 L_WIZARD_DUNGEON2,
65 L_WIZARD_DUNGEON3,
66 L_WIZARD_DUNGEON4,
67 L_WIZARD_DUNGEON5,
68 L_AHKULAN_CASTLE,
69 
70 L_UNDEADS_TOMB1,
71 L_UNDEADS_TOMB2,
72 L_UNDEADS_TOMB3,
73 L_UNDEADS_TOMB4,
74 L_UNDEADS_TOMB5,
75 
76 L_EXTINCT_VOLCANO,
77 
78 L_KINGS_TREASURE,
79 
80 L_WIZTOWER_TOP,
81 
82 L_DEBUG1,
83 L_DEBUG2,
84 L_RANDOM = 100,
85 L_EOF = 200,
86 };
87 
88 
89 enum PALETTE
90 {
91 	PAL_UNKNOWN			= 0x0000,
92 	PAL_SMALL_TOWN		= 0x0001,
93 	PAL_SMALL_VILLAGE	= 0x0002,
94 	PAL_CITY			= 0x0003,
95 	PAL_DWARF_CITY		= 0x0004,
96 	PAL_WIZARD_TOWER	= 0x0005,
97 	PAL_AHKULAN_CASTLE	= 0x0006,
98 	PAL_RAT_CELLAR		= 0x0007,
99 	PAL_TOWER_RUINS		= 0x0008,
100 	PAL_DWARF_TREASURE	= 0x0009,
101 	PAL_KINGS_TREASURE	= 0x000A,
102 	PAL_WIZTOWER_TOP,
103 	PAL_UNDEAD_TOMB0,
104 	PAL_UNDEAD_TOMB1,
105 	PAL_EXTINCT_VOLCANO
106 };
107 
108 enum STDMAP;
109 struct PALETTE_MAP
110 {
111 	char this_view;
112 	STDMAP	real_view;
113 };
114 
115 
116 #define MAX_PLACES 8
117 
118 class XMap;
119 class XStairWay;
120 
121 class XLocation : public XObject
122 {
123 public:
124 	bool way_found_flag; //used for recursive way found alg...
125 
126 	XQList<XObject*> ways_list; //ways list used for AI...
127 	LOCATION ln;
128 
129 	static int rand_location_count;
130 	DECLARE_CREATOR(XLocation, XObject);
131 	XLocation(LOCATION location);
XLocation(XLocation * copy)132 	XLocation(XLocation * copy) {assert(0);}
133 
134 	XMap * map;
135 	void GetFreeXY(XPoint * pt, XRect * area = NULL);
136 	void AddPlace(XAnyPlace * pl);
137 
138 	virtual void Store(XFile * f);
139 	virtual void Restore(XFile * f);
140 	virtual void Invalidate();
GetBriefName()141 	char * GetBriefName() {return brief_name;}
GetFullName()142 	char * GetFullName() {return full_name;}
143 
144 	int visited_by_hero;
145 	void DumpLocation(FILE * f);
146 
147 	int GetCreatureCount(unsigned int creature_class); //count of such creatures on this level (need for quests)
148 
149 	static void CreateRandomCave();
150 
151 	XCreature * NewCreature(CREATURE_NAME cn, int x, int y, GROUP_ID gid = GID_NONE);
152 	XCreature * NewCreature(CREATURE_NAME cn, XRect * rect = NULL, GROUP_ID gid = GID_NONE, unsigned int ai_flags = 0);
153 	XCreature * NewCreature(CREATURE_CLASS crc, XRect * rect = NULL, GROUP_ID gid = GID_NONE, unsigned int ai_flags = 0);
154 
155 	XStairWay * NewWay(LOCATION target_ln, STAIRWAYTYPE s_type, XRect * area = NULL); //creates way at random place
156 	XStairWay * NewWay(int x, int y, LOCATION target_ln, STAIRWAYTYPE s_type);
157 
158 protected:
159 	char brief_name[10];
160 	char full_name[80];
161 	XPtr<XAnyPlace> places[MAX_PLACES];
162 
163 	void PutPalette(int x, int y, PALETTE pal, XLocation * l);
164 	char ** Resolve(PALETTE pal, int * size, PALETTE_MAP ** pm, int * pm_size);
165 
166 	void BuildCave();
167 	void BuildLabirint(int create_trap_door_chest = 1);
168 	void CreateTraps();
169 	void CreateChests();
170 
171 	void CreateShop(unsigned int im, XRect * rect, char * sk_name, SHOP_DOOR sd = SHOP_DOOR_UP);
172 };
173 
174 class XRandomLocation : public XLocation
175 {
176 public:
177 	XRandomLocation(int deep, int view, int way_up, int way_down, int cr_lvl); //view 0 - labirinth, 1 - cave
178 };
179 
180 
181 
182 
183 ////////////// ALL OTHER LOCATIONS /////////////////////
184 class XUndeadTombLocation : public XLocation
185 {
186 public:
187 	XUndeadTombLocation(LOCATION tl);
188 };
189 
190 
191 class XRatCellarLocation : public XLocation
192 {
193 public:
194 	XRatCellarLocation(LOCATION tl);
195 };
196 
197 
198 class XMushroomsCaveLocation : public XLocation
199 {
200 public:
201 	DECLARE_CREATOR(XMushroomsCaveLocation, XLocation);
202 	XMushroomsCaveLocation(LOCATION loc);
203 	int Run();
204 };
205 
206 class XWizardDungeonLocation : public XLocation
207 {
208 public:
209 	XWizardDungeonLocation(LOCATION l_name);
210 };
211 
212 class XAhkUlanCastleLocation : public XLocation
213 {
214 public:
215 	XAhkUlanCastleLocation(LOCATION tl);
216 };
217 
218 class XDwarfCityCaveLocation : public XLocation
219 {
220 public:
221 	XDwarfCityCaveLocation(LOCATION l_name);
222 };
223 
224 class XMainLocation : public XLocation
225 {
226 public:
227 	XMainLocation(LOCATION tl);
228 };
229 
230 class XYohjiTower : public XLocation
231 {
232 public:
233 	XYohjiTower(LOCATION tl);
234 };
235 
236 class XKingsTreasureLocation : public XLocation
237 {
238 public:
239 	XKingsTreasureLocation(LOCATION tl);
240 };
241 
242 class XExtinctVolcanoLocation : public XLocation
243 {
244 public:
245 	XExtinctVolcanoLocation(LOCATION tl);
246 };
247 
248 
249 #endif
250