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 #include "other_misc.h"
22 #include "creatures.h"
23 #include "unique.h"
24 #include "skeep_ai.h"
25 #include "xgen.h"
26 #include "game.h"
27 #include "item_misc.h"
28 
XMainLocation(LOCATION tl)29 XMainLocation::XMainLocation(LOCATION tl) : XLocation(tl)
30 {
31 	strcpy(brief_name, "Valley");
32 	strcpy(full_name, "Valley of Avanor");
33 
34 	int lm = 0;
35 	int rm = 200;
36 	int tm = 0;
37 	int bm = 90;
38 	map = new XMap(rm, bm);
39 	int i,j;
40 
41 	for (i = 0; i < map->hgt; i++)
42 		for (j = 0; j < map->len; j++)
43 		{
44 			if (vRand() % 3)
45 				map->SetXY(j, i, M_GREENGRAS);
46 			else
47 				map->SetXY(j, i, M_GREENTREE);
48 		}
49 
50 // creating high mountains
51 	for (i = lm; i < rm; i++)
52 	{
53 		int z1 = vRand() % ((i & 3) + 1) + 1;
54 		int z2 = vRand() % ((i & 3) + 1) + 1;
55 		for (j = 0; j < z1; j++)
56 		{
57 			map->SetXY(i, tm + j, M_HIGHMOUNTAIN);
58 		}
59 		for (j = 0; j < z2; j++)
60 		{
61 			map->SetXY(i, bm - j - 1, M_HIGHMOUNTAIN);
62 		}
63 	}
64 
65 	for (i = tm; i < bm; i++)
66 	{
67 		int z1 = vRand() % ((i & 3) + 1) + 1;
68 		int z2 = vRand() % ((i & 3) + 1) + 1;
69 		for (j = 0; j < z1; j++)
70 		{
71 			map->SetXY(lm + j, i, M_HIGHMOUNTAIN);
72 		}
73 		for (j = 0; j < z2; j++)
74 		{
75 			map->SetXY(rm - j - 1, i, M_HIGHMOUNTAIN);
76 		}
77 	}
78 
79 //evaluate high mountains till hills!
80 	for (i = 0; i < map->hgt; i++)
81 		for (j = 0; j < map->len; j++)
82 		{
83 			int m = map->GetXY(j, i);
84 			if (m > M_HILL && m <= M_HIGHMOUNTAIN)
85 			{
86 				for (int q = -2; q < 3; q++)
87 					for (int w = -2; w < 3; w++)
88 					{
89 						int nm;
90 						if (abs(q) >= abs(w))
91 							nm = m - abs(q);
92 						else
93 							nm = m - abs(w);
94 						if (nm < M_HILL) nm = M_HILL;
95 						if (j + q >= 0 && i + w >= 0
96 							&& j + q < map->len && i + w < map->hgt
97 							&& map->GetXY(j + q, i + w) < nm)
98 							map->SetXY(j + q, i + w, (STDMAP)nm);
99 					}
100 			}
101 
102 		}
103 
104 
105 //Small village
106 		PutPalette(0, 0, PAL_SMALL_VILLAGE, this);
107 
108 		NewWay(3, 6, L_MUSHROOMS_CAVE1, STW_DOWN);
109 
110 		XRect village_area(8, 6, 34, 16);
111 		for (i = 0; i < 5; i++)
112 		{
113 			NewCreature(CN_FARMER, &village_area, GID_SMALL_VILLAGE_FARMER, AIF_GUARD_AREA);
114 			NewCreature(CN_GOODWIFE, &village_area, GID_SMALL_VILLAGE_FARMER, AIF_GUARD_AREA);
115 		}
116 
117 
118 		XRect elder_area(19, 9, 25, 11);
119 		NewCreature(CN_ELDER_GRIDOR, &elder_area, GID_SMALL_VILLAGE_FARMER, AIF_GUARD_AREA);
120 		new XFurniture(24, 8, xBROWN, '~', "plain bed", this);
121 
122 		XRect shop_rect1(8, 7, 18, 11);
123 		CreateShop(IM_FOOD, &shop_rect1, "Nobel, the human shopkeeper");
124 
125 
126 //way to darven caves
127 		NewWay(5, 29, L_DWARFCITYCAVE1, STW_DOWN);
128 
129 
130 //master thief
131 		XRect master_thief_area(40, 10, 45, 14);
132 		map->CreateRoom(40, 10, 5, 4, 42, 10, M_SAND, M_WOODWALL);
133 		NewCreature(CN_JORGUS, &master_thief_area, GID_FOREST_BROTHER, AIF_GUARD_AREA);
134 
135 //bandits area
136 		XRect bandit_area(35, 4, 47, 16);
137 		for (i = 0; i < 10; i++)
138 			NewCreature(CN_BANDIT, &bandit_area, GID_FOREST_BROTHER, AIF_GUARD_AREA | AIF_PROTECT_AREA | AIF_PEACEFUL);
139 
140 
141 //small town
142 		PutPalette(10, 40, PAL_SMALL_TOWN, this);
143 		XRect small_town_area(16, 42, 30, 48);
144 
145 		for (i = 0; i < 8; i++)
146 			NewCreature(CN_ROYAL_GUARD, &small_town_area, GID_GUARDIAN, AIF_GUARD_AREA)->xai->SetEnemyClass(CR_ORC);
147 
148 		NewCreature(CN_GEKTA, &small_town_area, GID_GUARDIAN, AIF_GUARD_AREA)->xai->SetEnemyClass(CR_ORC);
149 
150 		XRect ozrect(24, 50, 27, 52);
151 		NewCreature(CN_OZORIK, &ozrect, GID_GUARDIAN, AIF_GUARD_AREA)->xai->SetEnemyClass(CR_ORC);
152 		new XFurniture(26, 51, xLIGHTRED, '~', "bed", this);
153 		new XFurniture(24, 51, xBROWN, '~', "desk", this);
154 
155 		new XFurniture(13, 46, xBROWN, '~', "plain bed", this);
156 		new XFurniture(19, 42, xBROWN, '~', "plain bed", this);
157 		new XFurniture(25, 42, xBROWN, '~', "plain bed", this);
158 		new XFurniture(31, 42, xBROWN, '~', "plain bed", this);
159 		new XFurniture(37, 42, xBROWN, '~', "plain bed", this);
160 		new XFurniture(43, 42, xBROWN, '~', "plain bed", this);
161 		new XFurniture(49, 42, xBROWN, '~', "plain bed", this);
162 
163 		new XFurniture(30, 46, xBROWN, '~', "table", this);
164 		new XFurniture(30, 48, xBROWN, '~', "table", this);
165 		new XFurniture(32, 46, xBROWN, '~', "table", this);
166 		new XFurniture(32, 48, xBROWN, '~', "table", this);
167 		new XFurniture(34, 46, xBROWN, '~', "table", this);
168 		new XFurniture(34, 48, xBROWN, '~', "table", this);
169 		new XFurniture(36, 46, xBROWN, '~', "table", this);
170 		new XFurniture(36, 48, xBROWN, '~', "table", this);
171 		new XFurniture(38, 46, xBROWN, '~', "table", this);
172 		new XFurniture(38, 48, xBROWN, '~', "table", this);
173 
174 		NewWay(13, 42, L_RATCELLAR, STW_DOWN);
175 
176 		XRect shop_rect2(11, 49, 22, 54);
177 		CreateShop(IM_ARMOUR | IM_WEAPON | IM_MISSILE | IM_MISSILEW, &shop_rect2, "Noberik, the human shopkeeper");
178 
179 //orcs!
180 		XRect orc_area(10, 70, 30, 80);
181 		for (i = 0; i < 20; i++)
182 			NewCreature(CR_ORC, &orc_area, GID_ORCS_WARPARTY, AIF_GUARD_AREA);
183 
184 		Game.Scheduler.Add(new XMainLocationGen(this));
185 
186 //Yohjishiro
187 		PutPalette(45, 25, PAL_WIZARD_TOWER, this);
188 		NewWay(55, 31, L_WIZTOWER_TOP, STW_UP);
189 
190 //Large City
191 		XRect city_area(139, 2, 157, 26);
192 		PutPalette(130, 2, PAL_CITY, this);
193 
194 		XRect shop_rect3(147, 18, 153, 24);
195 		CreateShop(IM_BOOK | IM_SCROLL | IM_POTION, &shop_rect3, "Toberik, the human shopkeeper", SHOP_DOOR_RIGHT);
196 
197 		XRect magic_guild_area(163, 12, 166, 15);
198 		NewCreature(CN_GEFEON, &magic_guild_area, GID_RODERICK_GUARDIAN, AIF_GUARD_AREA);
199 		new XFurniture(165, 13, xLIGHTRED, '~', "eternal flame", this);
200 
201 //Roderik palace
202 		XRect roderick_area(182, 4, 183, 5);
203 		NewCreature(CN_RODERIK, &roderick_area, GID_RODERICK_GUARDIAN, (AIF_GUARD_AREA | AIF_NO_SWAP));
204 		new XThrone(182, 4, "Avanor", this);
205 		new XFurniture(172, 9, xLIGHTRED, '~', "royal bed", this);
206 		new XFurniture(189, 6, xBROWN, '~', "round table", this);
207 		new XFurniture(191, 12, xBROWN, '~', "dinner table", this);
208 		{
209 			XRect gr(180, 7, 181, 8);
210 			NewCreature(CN_ROYAL_GUARD, &gr, GID_RODERICK_GUARDIAN, AIF_GUARD_AREA);
211 		}
212 
213 		{
214 			XRect gr(180, 6, 181, 7);
215 			NewCreature(CN_ROYAL_GUARD, &gr, GID_RODERICK_GUARDIAN, AIF_GUARD_AREA);
216 		}
217 
218 		{
219 			XRect gr(184, 7, 185, 8);
220 			NewCreature(CN_ROYAL_GUARD, &gr, GID_RODERICK_GUARDIAN, AIF_GUARD_AREA);
221 		}
222 
223 		{
224 			XRect gr(184, 6, 185, 7);
225 			NewCreature(CN_ROYAL_GUARD, &gr, GID_RODERICK_GUARDIAN, AIF_GUARD_AREA);
226 		}
227 
228 		{
229 			//treasure guardian
230 			XRect gr(175, 15, 176, 16);
231 			NewCreature(CN_ROYAL_GUARD, &gr, GID_RODERICK_GUARDIAN, AIF_GUARD_AREA | AIF_NO_SWAP);
232 			NewWay(175, 15, L_KINGS_TREASURE, STW_DOWN);
233 		}
234 
235 		{
236 			XRect gr(172, 14, 173, 15);
237 			NewCreature(CN_ROYAL_GUARD, &gr, GID_RODERICK_GUARDIAN, AIF_GUARD_AREA);
238 		}
239 		{
240 			XRect gr(172, 15, 173, 16);
241 			NewCreature(CN_ROYAL_GUARD, &gr, GID_RODERICK_GUARDIAN, AIF_GUARD_AREA);
242 		}
243 
244 //Lage city townee
245 		for (i = 0; i < 5; i++)
246 		{
247 			NewCreature(CN_CITIZEN, &city_area, GID_RODERICK_GUARDIAN, AIF_GUARD_AREA);
248 			NewCreature(CN_FCITIZEN, &city_area, GID_RODERICK_GUARDIAN, AIF_GUARD_AREA);
249 		}
250 
251 // teleports from small village to town and back
252 		new XTeleport(23, 20, this, L_MAIN, 154, 13);
253 		new XTeleport(154, 13, this, L_MAIN, 23, 20);
254 
255 		new XAltar(154, 4, D_LIFE, this);
256 		{
257 			XRect gr(153, 4, 156, 7);
258 			NewCreature(CN_HIGHPRIEST, &gr, GID_RODERICK_GUARDIAN, AIF_GUARD_AREA);
259 		}
260 		new XFurniture(152,5,xBROWN,'~',"pew",this);
261 		new XFurniture(152,6,xBROWN,'~',"pew",this);
262 		new XFurniture(153,5,xBROWN,'~',"pew",this);
263 		new XFurniture(153,6,xBROWN,'~',"pew",this);
264 		new XFurniture(155,5,xBROWN,'~',"pew",this);
265 		new XFurniture(155,6,xBROWN,'~',"pew",this);
266 		new XFurniture(156,5,xBROWN,'~',"pew",this);
267 		new XFurniture(156,6,xBROWN,'~',"pew",this);
268 
269 //Black wizard ruins
270 		PutPalette(155, 44, PAL_TOWER_RUINS, this);
271 		NewWay(165, 49, L_WIZARD_DUNGEON1, STW_DOWN);
272 
273 //tomb
274 		PutPalette(100, 50, PAL_UNDEAD_TOMB0, this);
275 		NewWay(118, 54, L_UNDEADS_TOMB1, STW_DOWN);
276 
277 		XRect tomb_area(104, 51, 117, 57);
278 
279 		for (i = 0; i < 20; i++)
280 			NewCreature(CN_SKELETON, &tomb_area);
281 
282 //Extint Volcano
283 		PutPalette(40, 72, PAL_EXTINCT_VOLCANO, this);
284 		NewWay(46, 75, L_EXTINCT_VOLCANO, STW_DOWN);
285 
286    		for (i = 0; i < map->hgt; i++)
287    			for (j = 0; j < map->len; j++)
288    			{
289          		if (vRand(18) == 0)
290 				{
291 					if(map->GetXY(j, i) == M_GREENGRAS && map->GetSpecial(j, i) == NULL)
292 						new XHerbBush(j, i, this);
293 				}
294 
295    			}
296 
297 
298 }
299 
XYohjiTower(LOCATION tl)300 XYohjiTower::XYohjiTower(LOCATION tl) : XLocation(tl)
301 {
302 	strcpy(brief_name, "WzTwr");
303 	strcpy(full_name, "Yohjishiro's Tower");
304 
305 	map = new XMap(80, 20);
306 	int i,j;
307 
308 	for (i = 0; i < map->hgt; i++)
309 		for (j = 0; j < map->len; j++)
310 		{
311 			if (vRand() % 3)
312 				map->SetXY(j, i, M_GREENGRAS);
313 			else
314 				map->SetXY(j, i, M_GREENTREE);
315 		}
316 
317 	PutPalette(30, 5, PAL_WIZTOWER_TOP, this);
318 	NewWay(40, 11, L_MAIN, STW_DOWN);
319 
320 	// It's her house...
321 	XRect wizard_tower_area(37, 7, 44, 12);
322 	NewCreature(CN_YOHJISHIRO, &wizard_tower_area, GID_NONE, AIF_GUARD_AREA);
323 
324 	new XFurniture(37, 10, xLIGHTRED, '~', "nice bed", this);
325 }
326 
327 
XKingsTreasureLocation(LOCATION tl)328 XKingsTreasureLocation::XKingsTreasureLocation(LOCATION tl) : XLocation(tl)
329 {
330 	strcpy(brief_name, "RoyalTr");
331 	strcpy(full_name, "Royal Treasure");
332 
333 	BuildCave();
334 
335 	PutPalette(0, 0, PAL_KINGS_TREASURE, this);
336 	NewWay(10, 9, L_MAIN, STW_UP);
337 
338 	int i;
339 	XPoint pt;
340 	XRect area(1, 1, 20, 7);
341 	for (i = 0; i < 16; i++)
342 	{
343 		GetFreeXY(&pt, &area);
344 		new XTrap(pt.x, pt.y, this);
345 	}
346 
347 	for (i = 0; i < 9; i++)
348 	{
349 		GetFreeXY(&pt, &area);
350 		XChest * tchest = new XChest(5, IM_ITEM, 200, 15000);
351 		tchest->Drop(this, pt.x, pt.y);
352 	}
353 
354 	XItem * it = new XAncientMachinePart();
355 	it->Drop(this, 2, 3);
356 
357 	it = new XAncientMachinePart();
358 	it->Drop(this, 2, 4);
359 
360 	for (i = 1; i < 20; i++)
361 	{
362 		for (int j = 1; j < 7; j++)
363 		{
364 			if (map->XGetMovability(i, j) == 0 && map->GetItemCount(i, j) == 0)
365 			{
366 				XMoney * money = new XMoney(vRand() % 200 + 50);
367 				money->Drop(this, i, j);
368 			}
369 		}
370 	}
371 }
372 
373 
XExtinctVolcanoLocation(LOCATION tl)374 XExtinctVolcanoLocation::XExtinctVolcanoLocation(LOCATION tl) : XLocation(tl)
375 {
376 	BuildCave();
377 	strcpy(brief_name, "Volcano");
378 	strcpy(full_name, "Crater of an Extinct Volcano");
379 	NewWay(L_MAIN, STW_UP);
380 
381 	NewCreature(CN_XSHEE_VOO);
382 }
383 
384