summaryrefslogtreecommitdiff
path: root/lib/mods/theme/scpt/god.lua
blob: 71a856609ccbc744e630beb1efbff0f7cea26a81 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
-- The god quest: find randomly placed relic in a randomly placed dungeon!

-- set some global variables (stored in the save file via the ["data"] key)
god_quest = {}

-- increase this number to make god quests more common, to a max value of 100
god_quest.CHANCE_OF_GOD_QUEST = 21

-- increase this number to make more quests
god_quest.MAX_NUM_GOD_QUESTS = 7

-- d_idx of the god_quest (Lost Temple) dungeon
god_quest.DUNGEON_GOD = 30

add_quest
{
	["global"] =    "GOD_QUEST",
	["name"] =      "God quest",
	["desc"] =      function()

			if quest(GOD_QUEST).status == QUEST_STATUS_TAKEN then

				-- get the direction that the dungeon lies from lothlorien/angband
				local home, home_axis, home_distance, home2, home2_axis, home2_distance = get_god_quest_axes()

				print_hook("#####yGod quest "..god_quest.quests_given.."!\n")
				print_hook("Thou art to find the lost temple of thy God and\n");
				print_hook("to retrieve the lost part of the relic for thy God! \n")
				if home_axis ~= "close" then
					print_hook("The temple lies "..home_distance.." to the "..home_axis.." of "..home..", \n")
				else
					print_hook("The temple lies very close to "..home..", \n")
				end
				if home2_axis ~= "close" then
					print_hook( "and "..home2_distance.." to the "..home2_axis.." of "..home2..", I can feel it.' \n")
				else
					print_hook("and very close to "..home2..", I can feel it.' \n")
				end					
				print_hook("\n")
			end
	end,
	["level"] =     -1,
	["data"] =      {
		["god_quest.relic_num"] = 1,
		["god_quest.quests_given"] = 0,
		["god_quest.relics_found"] = 0,
		["god_quest.dun_mindepth"] = 1,
		["god_quest.dun_maxdepth"] = 4,
		["god_quest.dun_minplev"] = 0,
		["god_quest.relic_gen_tries"] = 0,
		["god_quest.relic_generated"] = FALSE,
		["god_quest.dung_x"] = 1,
		["god_quest.dung_y"] = 1,
		["god_quest.player_x"] = 0,
		["god_quest.player_y"] = 0,
	},
	["hooks"] =     {
		-- Start the game without the quest, given it by chance
		[HOOK_BIRTH_OBJECTS] = function()
			quest(GOD_QUEST).status = QUEST_STATUS_UNTAKEN

			-- initialise save-file stored variables when new character is created
			god_quest.relic_num = 1
			god_quest.quests_given = 0
			god_quest.relics_found = 0
			god_quest.dun_mindepth = 1
			god_quest.dun_maxdepth = 4
			god_quest.dun_minplev = 0
			god_quest.relic_gen_tries = 0
			god_quest.relic_generated = FALSE
		end,
		[HOOK_PLAYER_LEVEL] = function(gained)
			local home_axis, home

			if gained > 0 then
				-- roll for chance of quest
				local give_god_quest = magik(god_quest.CHANCE_OF_GOD_QUEST)

				-- check player is worshipping a god, not already on a god quest.
				if (player.astral ~= FALSE) or (player.pgod <= 0) 
				or (quest(GOD_QUEST).status == QUEST_STATUS_TAKEN) or (quest(GOD_QUEST).status == QUEST_STATUS_FAILED)
				or (god_quest.quests_given >= god_quest.MAX_NUM_GOD_QUESTS) or (give_god_quest == FALSE)
				or ((current_dungeon_idx == god_quest.DUNGEON_GOD) and (dun_level > 0)) or (player.lev <= god_quest.dun_minplev) then
					-- Don't let a player get quests with trickery
					if player.lev > god_quest.dun_minplev then
						god_quest.dun_minplev = player.lev
					end
					return
				else
					-- each god has different characteristics, so the quests are differnet depending on your god
					if player.pgod == GOD_ERU then
						god_quest.relic_num = 7
					elseif player.pgod == GOD_MANWE then
						god_quest.relic_num = 8
					elseif player.pgod == GOD_TULKAS then
						god_quest.relic_num = 9
					elseif player.pgod == GOD_MELKOR then
						god_quest.relic_num = 10
					elseif player.pgod == GOD_YAVANNA then
						god_quest.relic_num = 11
					elseif player.pgod == GOD_AULE then
						god_quest.relic_num = 16
					elseif player.pgod == GOD_VARDA then
						god_quest.relic_num = 17
					elseif player.pgod == GOD_ULMO then
						god_quest.relic_num = 18
					elseif player.pgod == GOD_MANDOS then
						god_quest.relic_num = 19
					end

					-- This var will need resetting
					god_quest.relic_generated = FALSE
					quest(GOD_QUEST).status = QUEST_STATUS_TAKEN
					god_quest.quests_given = god_quest.quests_given + 1

					-- actually place the dungeon in a random place
					quest_god_place_rand_dung()

					-- store the variables of the coords where the player was given the quest
					god_quest.player_y, god_quest.player_x = player.get_wild_coord()

					-- establish direction of player and 'home' from dungeon
					local home, home_axis, home_distance, home2, home2_axis, home2_distance = get_god_quest_axes()

					-- God issues instructions
					cmsg_print(TERM_L_BLUE, "The voice of "..deity(player.pgod).name.." booms in your head:")

					cmsg_print(TERM_YELLOW, "'I have a task for thee.")
					cmsg_print(TERM_YELLOW, "Centuries ago an ancient relic of mine was broken apart.")
					cmsg_print(TERM_YELLOW, "The pieces of it have been lost in fallen temples.")
					cmsg_print(TERM_YELLOW, "Thou art to find my lost temple and retrieve a piece of the relic.")
					cmsg_print(TERM_YELLOW, "When thy task is done, thou art to lift it in the air and call upon my name.")
					cmsg_print(TERM_YELLOW, "I shall then come to reclaim what is mine!")
					if home_axis ~= "close" then
						cmsg_print(TERM_YELLOW, "The temple lies "..home_distance.." to the "..home_axis.." of "..home..", ")
					else
						cmsg_print(TERM_YELLOW, "The temple lies very close to "..home..",")
					end

					if home2_axis ~= "close" then
						cmsg_print(TERM_YELLOW, "and "..home2_distance.." to the "..home2_axis.." of "..home2..", I can feel it.'")
					else
						cmsg_print(TERM_YELLOW, "and very close to "..home2..", I can feel it.'")
					end

					-- Prepare depth of dungeon. If this was generated in set_god_dungeon_attributes(),
					-- then we'd have trouble if someone levelled up in the dungeon!
					god_quest.dun_mindepth = player.lev*2/3
					god_quest.dun_maxdepth = god_quest.dun_mindepth + 4
				end
			end
		end,
		[HOOK_LEVEL_END_GEN] = function()
			local chance

			-- Check for dungeon
			if (current_dungeon_idx ~= god_quest.DUNGEON_GOD) or (quest(GOD_QUEST).status == QUEST_STATUS_UNTAKEN) then
				return
			-- if the relic has been created at this point, then it was created on the *PREVIOUS* call of HOOK_LEVEL_END_GEN, and 
			-- therefore the player has caused another level generation in the temple and hence failed the quest.
			elseif (god_quest.relic_generated == TRUE) and quest(GOD_QUEST).status ~= QUEST_STATUS_FAILED then 
				
					-- fail the quest, don't give another one, don't give this message again
					quest(GOD_QUEST).status = QUEST_STATUS_FAILED
					-- God issues instructions
					cmsg_print(TERM_L_BLUE, "The voice of "..deity(player.pgod).name.." booms in your head:")

					cmsg_print(TERM_YELLOW, "'Thou art a fool!")
					cmsg_print(TERM_YELLOW, "I told thee to look carefully for the relic. It appears thou hast missed the")
					cmsg_print(TERM_YELLOW, "opportunity to claim it in my name, as I sense that those monsters who ")
					cmsg_print(TERM_YELLOW, "have overrun my temple have destroyed it themselves.")
					cmsg_print(TERM_YELLOW, "I shall not ask thee to do such a thing again, as thou hast failed me in this")
					cmsg_print(TERM_YELLOW, "simple task!'")					
			else
				-- Force relic generation on 5th attempt if others have been unsuccessful.
				if (god_quest.relic_gen_tries == 4) and (god_quest.relic_generated == FALSE) then
					generate_relic()
				else
					-- 1/5 chance of generation
					chance = randint(5)
					if (chance == 5) then
						generate_relic()
					else
						god_quest.relic_gen_tries = god_quest.relic_gen_tries + 1
					end
				end
			end
		end,
		[HOOK_ENTER_DUNGEON] = function(d_idx)
			-- call the function to set the dungeon variables (dependant on pgod) the first time we enter the dungeon
			if d_idx ~= god_quest.DUNGEON_GOD then
				return
			else
				set_god_dungeon_attributes()
			end
		end,
		[HOOK_GEN_LEVEL_BEGIN] = function()
			-- call the function to set the dungeon variables (dependant on pgod) when we WoR back into the dungeon
			if current_dungeon_idx ~= god_quest.DUNGEON_GOD then
				return
			else
				set_god_dungeon_attributes()
			end
		end,
		[HOOK_STAIR] = function()
			-- call the function to set the dungeon variables (dependant on pgod) every time we go down a level
			if current_dungeon_idx ~= god_quest.DUNGEON_GOD then
				return
			else
				set_god_dungeon_attributes()
			end
		end,
		[HOOK_GET] = function(o_ptr, item)
				-- Is it the relic, and check to make sure the relic hasn't already been identified
			if (quest(GOD_QUEST).status == QUEST_STATUS_TAKEN) and (o_ptr.tval == TV_JUNK) and (o_ptr.sval == god_quest.relic_num)
			and (o_ptr.pval ~= TRUE)  and (god_quest.relics_found < god_quest.quests_given) then

				-- more God talky-talky
				cmsg_print(TERM_L_BLUE, deity(player.pgod).name.." speaks to you:")

				-- Is it the last piece of the relic?
				if (god_quest.quests_given == god_quest.MAX_NUM_GOD_QUESTS) then
					cmsg_print(TERM_YELLOW, "'At last! Thou hast found all of the relic pieces.")

					-- reward player by increasing prayer skill
					cmsg_print(TERM_YELLOW, "Thou hast done exceptionally well! I shall increase thy prayer skill even more!'")
					skill(SKILL_PRAY).value = skill(SKILL_PRAY).value + (10 * (skill(SKILL_PRAY).mod))

					-- Take the relic piece
					floor_item_increase(item, -1)
					floor_item_optimize(item)
				else
					cmsg_print(TERM_YELLOW, "'Well done! Thou hast found part of the relic.")
					cmsg_print(TERM_YELLOW, "I shall surely ask thee to find more of it later!")
					cmsg_print(TERM_YELLOW, "I will take it from thee for now'")

					-- Take the relic piece
					floor_item_increase(item, -1)
					floor_item_optimize(item)

					-- reward player by increasing prayer skill
					cmsg_print(TERM_YELLOW, "'As a reward, I shall teach thee how to pray better'")
					skill(SKILL_PRAY).value = skill(SKILL_PRAY).value + (5 * (skill(SKILL_PRAY).mod))
				end

				-- relic piece has been identified
				o_ptr.pval = TRUE
				god_quest.relics_found = god_quest.relics_found + 1

				-- Make sure quests can be given again if neccesary
				quest(GOD_QUEST).status = QUEST_STATUS_UNTAKEN
				return TRUE
			end
		end,
		[HOOK_CHAR_DUMP] = function()

			if (god_quest.quests_given > 0) then

				local relics = god_quest.relics_found
				local append_text = ""
				if (god_quest.relics_found == god_quest.MAX_NUM_GOD_QUESTS) then
					relics = "all"
					append_text = " and pleased your god"
				else
					if (god_quest.relics_found == 0) then
						relics = "none"
					end
					if (quest(GOD_QUEST).status == QUEST_STATUS_FAILED) then
						append_text = " and failed in your quest"
					end
				end

				print_hook("\n You found "..(relics).." of the relic pieces"..(append_text)..".")

			end
		end,
	},
}

-- this function generates the relic at a randomly determined place in the temple.
function generate_relic()
	local tries, grid, x, y, relic

	-- initialise tries variable
	tries = 1000

	while (tries > 0) do

		tries = tries - 1
		-- get grid coordinates from current height/width, minus one to prevent relic being generated in outside wall. (would crash the game)
		y = randint(cur_hgt-1)
		x = randint(cur_wid-1)
		grid = cave(y, x)

		-- are the coordinates on a floor, not on a permanent feature (eg stairs), and not on a trap ?
		if (cave_is(grid, FF1_FLOOR) == TRUE) and (cave_is(grid, FF1_PERMANENT) == FALSE) and (grid.t_idx == 0) then break end

	end 
	
	-- create relic
	relic = create_object(TV_JUNK, god_quest.relic_num)

	-- inscribe it to prevent automatizer 'accidents'
	relic.note = quark_add("quest")

	-- If no safe co-ords were found, put it in the players backpack
	if tries == 0 then

		-- explain it
		msg_print(TERM_L_BLUE, "You luckily stumble across the relic on the stairs!")

		if (inven_carry_okay(relic)) then
			inven_carry(relic, FALSE)
		else
		-- no place found, drop it on the stairs
			drop_near(relic, -1, player.py, player.px)
		end

	else
		-- drop it
		drop_near(relic, -1, y, x)
	end

	-- Only generate once!
	god_quest.relic_generated = TRUE

	-- Reset some variables
	god_quest.relic_gen_tries = 0

end




function set_god_dungeon_attributes()

	-- dungeon properties altered according to which god player is worshipping,
	if player.pgod == GOD_ERU then

		-- The Eru temple is based on Meneltarma.
		-- W: Not too many monsters (they'll be tough though, with big levels)
		dungeon(god_quest.DUNGEON_GOD).min_m_alloc_level = 14
		dungeon(god_quest.DUNGEON_GOD).min_m_alloc_chance = 200

		-- L: Dirt and grass. More dirt at bottom, more grass at top. rocky ground would be nice
		dungeon(god_quest.DUNGEON_GOD).floor1 = 88
		dungeon(god_quest.DUNGEON_GOD).floor2 = 89
		dungeon(god_quest.DUNGEON_GOD).floor_percent1[1] = 70
		dungeon(god_quest.DUNGEON_GOD).floor_percent2[1] = 30
		dungeon(god_quest.DUNGEON_GOD).floor_percent1[2] = 10
		dungeon(god_quest.DUNGEON_GOD).floor_percent2[2] = 90

		-- A: Outer wall mountain chain. other walls granite
		dungeon(god_quest.DUNGEON_GOD).fill_type1 = 97
		dungeon(god_quest.DUNGEON_GOD).fill_percent1[1] = 100
		dungeon(god_quest.DUNGEON_GOD).outer_wall = 57
		dungeon(god_quest.DUNGEON_GOD).inner_wall = 97
		dungeon(god_quest.DUNGEON_GOD).fill_method = 2

		-- O: "At Meneltarma no weapon or tool had ever been borne" (but invaders would have left a small number)
		dungeon(god_quest.DUNGEON_GOD).objs.treasure = 45
		dungeon(god_quest.DUNGEON_GOD).objs.combat = 5
		dungeon(god_quest.DUNGEON_GOD).objs.magic = 45
		dungeon(god_quest.DUNGEON_GOD).objs.tools = 5

		-- F: A large pillar, with stairs created at edges. (You can't climb a rock through the middle, can you?)
		dungeon(god_quest.DUNGEON_GOD).flags1 = bor(DF1_BIG, DF1_NO_DOORS, DF1_CIRCULAR_ROOMS, DF1_EMPTY, DF1_TOWER, DF1_FLAT, DF1_ADJUST_LEVEL_2)
		dungeon(god_quest.DUNGEON_GOD).flags2 = bor(DF2_ADJUST_LEVEL_1_2, DF2_NO_SHAFT, DF2_ADJUST_LEVEL_PLAYER)

		-- R:
		dungeon(god_quest.DUNGEON_GOD).rules[1].mode = 3
		dungeon(god_quest.DUNGEON_GOD).rules[1].percent = 50

		-- M: We want evil or flying characters
		dungeon(god_quest.DUNGEON_GOD).rules[1].mflags3 = RF3_EVIL

		dungeon(god_quest.DUNGEON_GOD).rules[2].mode = 3
		dungeon(god_quest.DUNGEON_GOD).rules[2].percent = 50

		-- M: We want evil or flying characters
		dungeon(god_quest.DUNGEON_GOD).rules[2].mflags7 = RF7_CAN_FLY


	elseif player.pgod == GOD_MANWE then

		-- Manwe's lost temple is high in the clouds
		-- W: Has average number of monsters.
		dungeon(god_quest.DUNGEON_GOD).min_m_alloc_level = 18
		dungeon(god_quest.DUNGEON_GOD).min_m_alloc_chance = 160


		-- L: floor will be 'cloud-like vapour' and pools of 'condensing water'
		dungeon(god_quest.DUNGEON_GOD).floor1 = 208
		dungeon(god_quest.DUNGEON_GOD).floor2 = 209
		dungeon(god_quest.DUNGEON_GOD).floor_percent1[1] = 85
		dungeon(god_quest.DUNGEON_GOD).floor_percent2[1] = 15

		-- A: Outer wall is 'hail stone wall', inner wall 'dense fog'. FIlled at max smoothing, like islands.
		dungeon(god_quest.DUNGEON_GOD).fill_type1 = 211
		dungeon(god_quest.DUNGEON_GOD).fill_percent1[1] = 100
		dungeon(god_quest.DUNGEON_GOD).outer_wall = 210
		dungeon(god_quest.DUNGEON_GOD).inner_wall = 211
		dungeon(god_quest.DUNGEON_GOD).fill_method = 4

		-- O: Can't imagine Manwe having much treasure. Little need for tools in a cloud temple. lots of magical stuff though...
		dungeon(god_quest.DUNGEON_GOD).objs.treasure = 15
		dungeon(god_quest.DUNGEON_GOD).objs.combat = 25
		dungeon(god_quest.DUNGEON_GOD).objs.magic = 55
		dungeon(god_quest.DUNGEON_GOD).objs.tools = 5

		-- F: It's open, goes up like a tower, give it a few interesting rooms, make the monsters hard(ish).
		dungeon(god_quest.DUNGEON_GOD).flags1 = bor(DF1_NO_DOORS, DF1_TOWER, DF1_CAVERN,  DF1_ADJUST_LEVEL_2)
		dungeon(god_quest.DUNGEON_GOD).flags2 = bor(DF2_NO_SHAFT, DF2_ADJUST_LEVEL_PLAYER)

		-- R:
		dungeon(god_quest.DUNGEON_GOD).rules[1].mode = 3
		dungeon(god_quest.DUNGEON_GOD).rules[1].percent = 20
		dungeon(god_quest.DUNGEON_GOD).rules[2].mode = 3
		dungeon(god_quest.DUNGEON_GOD).rules[2].percent = 20
		dungeon(god_quest.DUNGEON_GOD).rules[3].mode = 3
		dungeon(god_quest.DUNGEON_GOD).rules[3].percent = 20
		dungeon(god_quest.DUNGEON_GOD).rules[4].mode = 3
		dungeon(god_quest.DUNGEON_GOD).rules[4].percent = 20
		dungeon(god_quest.DUNGEON_GOD).rules[5].mode = 3
		dungeon(god_quest.DUNGEON_GOD).rules[5].percent = 20

		-- M: We want air(poison-type) or flying characters. Orcs too. They would have ransacked his elf-loving temple :)
		dungeon(god_quest.DUNGEON_GOD).rules[1].mflags2 = RF2_INVISIBLE
		dungeon(god_quest.DUNGEON_GOD).rules[2].mflags3 = bor(RF3_ORC, RF3_IM_POIS)
		dungeon(god_quest.DUNGEON_GOD).rules[3].mflags4 = bor(RF4_BR_POIS, RF4_BR_GRAV)
		dungeon(god_quest.DUNGEON_GOD).rules[4].mflags5 = RF5_BA_POIS
		dungeon(god_quest.DUNGEON_GOD).rules[5].mflags7 = RF7_CAN_FLY


	elseif player.pgod == GOD_TULKAS then

		-- Tulkas dungeon is quite normal, possibly a bit boring to be honest. Maybe I should add something radical to it.
		-- 'The house of Tulkas in the midmost of  Valmar was a house of mirth and revelry. It sprang into the air with many storeys,
		-- and had a tower of bronze and pillars of copper in a wide arcade'
		-- W: but with lots of monsters
		dungeon(god_quest.DUNGEON_GOD).min_m_alloc_level = 20
		dungeon(god_quest.DUNGEON_GOD).min_m_alloc_chance = 120

		-- L: floor is normal
		dungeon(god_quest.DUNGEON_GOD).floor1 = 1
		dungeon(god_quest.DUNGEON_GOD).floor_percent1[1] = 100

		-- A: Granite walls
		dungeon(god_quest.DUNGEON_GOD).fill_type1 = 56
		dungeon(god_quest.DUNGEON_GOD).fill_percent1[1] = 100
		dungeon(god_quest.DUNGEON_GOD).outer_wall = 58
		dungeon(god_quest.DUNGEON_GOD).inner_wall = 57
		dungeon(god_quest.DUNGEON_GOD).fill_method = 0

		-- O: Loads of combat drops
		dungeon(god_quest.DUNGEON_GOD).objs.treasure = 10
		dungeon(god_quest.DUNGEON_GOD).objs.combat = 70
		dungeon(god_quest.DUNGEON_GOD).objs.magic = 5
		dungeon(god_quest.DUNGEON_GOD).objs.tools = 15

		-- F: fairly standard
		dungeon(god_quest.DUNGEON_GOD).flags1 = bor(DF1_NO_DESTROY, DF1_ADJUST_LEVEL_2)
		dungeon(god_quest.DUNGEON_GOD).flags2 = DF2_ADJUST_LEVEL_PLAYER

		-- R:
		dungeon(god_quest.DUNGEON_GOD).rules[1].mode = 3
		dungeon(god_quest.DUNGEON_GOD).rules[1].percent = 100

		-- M: plenty demons please
		dungeon(god_quest.DUNGEON_GOD).rules[1].mflags3 = bor(RF3_DEMON, RF3_EVIL)


	elseif player.pgod == GOD_MELKOR then

		-- Melkors dungeon will be dark, fiery and stuff
		-- Many many monsters! (but prob ADJUST_LEVEL_1_2)
		dungeon(god_quest.DUNGEON_GOD).min_m_alloc_level = 24
		dungeon(god_quest.DUNGEON_GOD).min_m_alloc_chance = 80


		-- L: floor is dirt/mud/nether
		dungeon(god_quest.DUNGEON_GOD).floor1 = 88
		dungeon(god_quest.DUNGEON_GOD).floor2 = 94
		dungeon(god_quest.DUNGEON_GOD).floor3 = 102
		dungeon(god_quest.DUNGEON_GOD).floor_percent1[1] = 45
		dungeon(god_quest.DUNGEON_GOD).floor_percent2[1] = 45
		dungeon(god_quest.DUNGEON_GOD).floor_percent3[1] = 10
		dungeon(god_quest.DUNGEON_GOD).floor_percent1[2] = 35
		dungeon(god_quest.DUNGEON_GOD).floor_percent2[2] = 35
		dungeon(god_quest.DUNGEON_GOD).floor_percent3[2] = 30

		-- A: Granite walls to fill but glass walls for room perimeters (you can see the nasty monsters coming)
		dungeon(god_quest.DUNGEON_GOD).fill_type1 = 188
		dungeon(god_quest.DUNGEON_GOD).fill_percent1[1] = 100
		dungeon(god_quest.DUNGEON_GOD).outer_wall = 188
		dungeon(god_quest.DUNGEON_GOD).inner_wall = 57
		dungeon(god_quest.DUNGEON_GOD).fill_method = 1

		-- O: Even drops
		dungeon(god_quest.DUNGEON_GOD).objs.treasure = 25
		dungeon(god_quest.DUNGEON_GOD).objs.combat = 25
		dungeon(god_quest.DUNGEON_GOD).objs.magic = 25
		dungeon(god_quest.DUNGEON_GOD).objs.tools = 25

		-- F: Small, lava rivers, nasty monsters hehehehehe
		dungeon(god_quest.DUNGEON_GOD).flags1 = bor(DF1_SMALL, DF1_LAVA_RIVERS, DF1_ADJUST_LEVEL_1)
		dungeon(god_quest.DUNGEON_GOD).flags2 = bor(DF2_ADJUST_LEVEL_1_2, DF2_ADJUST_LEVEL_PLAYER)

		-- R: No restrictions on monsters here
		dungeon(god_quest.DUNGEON_GOD).rules[1].mode = 0
		dungeon(god_quest.DUNGEON_GOD).rules[1].percent = 80

		-- R: Apart from making sure we have some GOOD ones
		dungeon(god_quest.DUNGEON_GOD).rules[2].mode = 3
		dungeon(god_quest.DUNGEON_GOD).rules[2].percent = 20

		-- M:
		dungeon(god_quest.DUNGEON_GOD).rules[2].mflags3 = RF3_GOOD

	elseif player.pgod == GOD_YAVANNA then

		-- Yavannas dungeon will be very natural, tress and stuff.
		dungeon(god_quest.DUNGEON_GOD).min_m_alloc_level = 22
		dungeon(god_quest.DUNGEON_GOD).min_m_alloc_chance = 100

		-- L: floor is grass/flowers, plus dirt so not always regenerating quick!
		dungeon(god_quest.DUNGEON_GOD).floor1 = 89
		dungeon(god_quest.DUNGEON_GOD).floor2 = 199
		dungeon(god_quest.DUNGEON_GOD).floor3 = 88
		dungeon(god_quest.DUNGEON_GOD).floor_percent1[1] = 40
		dungeon(god_quest.DUNGEON_GOD).floor_percent2[1] = 15
		dungeon(god_quest.DUNGEON_GOD).floor_percent3[1] = 45

		-- A: Tree walls to fill, small trees for inner walls
		dungeon(god_quest.DUNGEON_GOD).fill_type1 = 96
		dungeon(god_quest.DUNGEON_GOD).fill_percent1[1] = 100
		dungeon(god_quest.DUNGEON_GOD).outer_wall = 202
		dungeon(god_quest.DUNGEON_GOD).inner_wall = 96
		dungeon(god_quest.DUNGEON_GOD).fill_method = 1

		-- O: nt much combat.. tools where ransackers have tried to chop trees down.
		dungeon(god_quest.DUNGEON_GOD).objs.treasure = 20
		dungeon(god_quest.DUNGEON_GOD).objs.combat = 10
		dungeon(god_quest.DUNGEON_GOD).objs.magic = 30
		dungeon(god_quest.DUNGEON_GOD).objs.tools = 40

		-- F: Natural looking
		dungeon(god_quest.DUNGEON_GOD).flags1 = bor(DF1_NO_DOORS, DF1_WATER_RIVERS, DF1_NO_DESTROY, DF1_ADJUST_LEVEL_1, DF1_NO_RECALL)
		dungeon(god_quest.DUNGEON_GOD).flags2 = bor(DF2_ADJUST_LEVEL_1_2, DF2_NO_SHAFT, DF2_NO_GENO, DF2_ADJUST_LEVEL_PLAYER)

		-- R: Demons, Undead, non-living
		dungeon(god_quest.DUNGEON_GOD).rules[1].mode = 3
		dungeon(god_quest.DUNGEON_GOD).rules[1].percent = 100

		-- M:
		dungeon(god_quest.DUNGEON_GOD).rules[1].mflags3 = bor(RF3_DEMON, RF3_UNDEAD, RF3_NONLIVING)

	elseif player.pgod == GOD_AULE then

		dungeon(god_quest.DUNGEON_GOD).min_m_alloc_level = 24
		dungeon(god_quest.DUNGEON_GOD).min_m_alloc_chance = 80

		-- L: floor is dirt/mud/shallow water
		dungeon(god_quest.DUNGEON_GOD).floor1 = 88
		dungeon(god_quest.DUNGEON_GOD).floor2 = 94
		dungeon(god_quest.DUNGEON_GOD).floor3 = 84
		dungeon(god_quest.DUNGEON_GOD).floor_percent1[1] = 45
		dungeon(god_quest.DUNGEON_GOD).floor_percent2[1] = 45
		dungeon(god_quest.DUNGEON_GOD).floor_percent3[1] = 10
		dungeon(god_quest.DUNGEON_GOD).floor_percent1[2] = 35
		dungeon(god_quest.DUNGEON_GOD).floor_percent2[2] = 35
		dungeon(god_quest.DUNGEON_GOD).floor_percent3[2] = 30

		-- A: Grey mountains, inner walls are low hills
		dungeon(god_quest.DUNGEON_GOD).fill_type1 = 216
		dungeon(god_quest.DUNGEON_GOD).fill_percent1[1] = 100
		dungeon(god_quest.DUNGEON_GOD).outer_wall = 216
		dungeon(god_quest.DUNGEON_GOD).inner_wall = 213
		dungeon(god_quest.DUNGEON_GOD).fill_method = 1

		-- O: Weapons and tools only
		dungeon(god_quest.DUNGEON_GOD).objs.treasure = 0
		dungeon(god_quest.DUNGEON_GOD).objs.combat = 50
		dungeon(god_quest.DUNGEON_GOD).objs.magic = 0
		dungeon(god_quest.DUNGEON_GOD).objs.tools = 50

		-- F: Small, no destroyed levels, min monster level = dungeon level
		dungeon(god_quest.DUNGEON_GOD).flags1 = bor(DF1_SMALL, DF1_NO_DESTROY, DF1_ADJUST_LEVEL_1, DF1_NO_STREAMERS)

		-- R: No restrictions on monsters here
		dungeon(god_quest.DUNGEON_GOD).rules[1].mode = 0
		dungeon(god_quest.DUNGEON_GOD).rules[1].percent = 80

	elseif player.pgod == GOD_VARDA then

		-- Varda lives with Manwe, so high in the clouds
		-- W: Has average number of monsters.
		dungeon(god_quest.DUNGEON_GOD).min_m_alloc_level = 18
		dungeon(god_quest.DUNGEON_GOD).min_m_alloc_chance = 160


		-- L: floor will be grass and flowers
		dungeon(god_quest.DUNGEON_GOD).floor1 = 89
		dungeon(god_quest.DUNGEON_GOD).floor2 = 82
		dungeon(god_quest.DUNGEON_GOD).floor_percent1[1] = 85
		dungeon(god_quest.DUNGEON_GOD).floor_percent2[1] = 15

		-- A: Outer wall is 'hail stone wall', inner wall 'dense fog'. Filled at max smoothing, like islands.
		dungeon(god_quest.DUNGEON_GOD).fill_type1 = 211
		dungeon(god_quest.DUNGEON_GOD).fill_percent1[1] = 100
		dungeon(god_quest.DUNGEON_GOD).outer_wall = 210
		dungeon(god_quest.DUNGEON_GOD).inner_wall = 211
		dungeon(god_quest.DUNGEON_GOD).fill_method = 4

		-- O: Varda likes magical items and tools, not much treasure or weapons
		dungeon(god_quest.DUNGEON_GOD).objs.treasure = 15
		dungeon(god_quest.DUNGEON_GOD).objs.combat = 5
		dungeon(god_quest.DUNGEON_GOD).objs.magic = 55
		dungeon(god_quest.DUNGEON_GOD).objs.tools = 25

		-- F: It's open, goes up like a tower, give it a few interesting rooms, make the monsters hard(ish).
		dungeon(god_quest.DUNGEON_GOD).flags1 = bor(DF1_NO_DOORS, DF1_TOWER, DF1_CAVERN,  DF1_ADJUST_LEVEL_1)
		dungeon(god_quest.DUNGEON_GOD).flags2 = bor(DF2_NO_SHAFT, DF2_ADJUST_LEVEL_PLAYER)

		-- R:
		dungeon(god_quest.DUNGEON_GOD).rules[1].mode = 3
		dungeon(god_quest.DUNGEON_GOD).rules[1].percent = 20
		dungeon(god_quest.DUNGEON_GOD).rules[2].mode = 3
		dungeon(god_quest.DUNGEON_GOD).rules[2].percent = 20
		dungeon(god_quest.DUNGEON_GOD).rules[3].mode = 3
		dungeon(god_quest.DUNGEON_GOD).rules[3].percent = 20
		dungeon(god_quest.DUNGEON_GOD).rules[4].mode = 3
		dungeon(god_quest.DUNGEON_GOD).rules[4].percent = 20
		dungeon(god_quest.DUNGEON_GOD).rules[5].mode = 3
		dungeon(god_quest.DUNGEON_GOD).rules[5].percent = 20

		-- M: We want air(poison-type) or flying characters. Orcs too.
		dungeon(god_quest.DUNGEON_GOD).rules[1].mflags2 = RF2_INVISIBLE
		dungeon(god_quest.DUNGEON_GOD).rules[2].mflags3 = bor(RF3_ORC, RF3_IM_POIS)
		dungeon(god_quest.DUNGEON_GOD).rules[3].mflags4 = bor(RF4_BR_POIS, RF4_BR_GRAV)
		dungeon(god_quest.DUNGEON_GOD).rules[4].mflags5 = RF5_BA_POIS
		dungeon(god_quest.DUNGEON_GOD).rules[5].mflags7 = RF7_CAN_FLY


	elseif player.pgod == GOD_ULMO then

		-- Mandos dungeon is basically Tulkas, except with undead.
		-- W: but with lots of monsters
		dungeon(god_quest.DUNGEON_GOD).min_m_alloc_level = 20
		dungeon(god_quest.DUNGEON_GOD).min_m_alloc_chance = 120

		-- L: floor is dirt
		dungeon(god_quest.DUNGEON_GOD).floor1 = 88
		dungeon(god_quest.DUNGEON_GOD).floor_percent1[1] = 100

		-- A: Cheat: walls are water.
		dungeon(god_quest.DUNGEON_GOD).fill_type1 = 187
		dungeon(god_quest.DUNGEON_GOD).fill_percent1[1] = 100
		dungeon(god_quest.DUNGEON_GOD).outer_wall = 238
		dungeon(god_quest.DUNGEON_GOD).inner_wall = 84
		dungeon(god_quest.DUNGEON_GOD).fill_method = 0

		-- O: Lots of treasure, not much else.
		dungeon(god_quest.DUNGEON_GOD).objs.treasure = 90
		dungeon(god_quest.DUNGEON_GOD).objs.combat = 0
		dungeon(god_quest.DUNGEON_GOD).objs.magic = 5
		dungeon(god_quest.DUNGEON_GOD).objs.tools = 5

		-- F: fairly standard
		dungeon(god_quest.DUNGEON_GOD).flags1 = bor(DF1_NO_DESTROY, DF1_ADJUST_LEVEL_2)
		dungeon(god_quest.DUNGEON_GOD).flags2 = DF2_ADJUST_LEVEL_PLAYER

		-- R:
		dungeon(god_quest.DUNGEON_GOD).rules[1].mode = 3
		dungeon(god_quest.DUNGEON_GOD).rules[1].percent = 35
		dungeon(god_quest.DUNGEON_GOD).rules[2].mode = 3
		dungeon(god_quest.DUNGEON_GOD).rules[2].percent = 30
		dungeon(god_quest.DUNGEON_GOD).rules[3].mode = 3
		dungeon(god_quest.DUNGEON_GOD).rules[3].percent = 30

		-- M: Aquatic creatures only.
		dungeon(god_quest.DUNGEON_GOD).rules[1].mflags3 = RF7_CAN_FLY
		dungeon(god_quest.DUNGEON_GOD).rules[2].mflags3 = RF7_AQUATIC
		dungeon(god_quest.DUNGEON_GOD).rules[3].mflags3 = RF3_RES_WATE

	elseif player.pgod == GOD_MANDOS then

		-- Mandos dungeon is basically Tulkas, except with undead.
		-- W: but with lots of monsters
		dungeon(god_quest.DUNGEON_GOD).min_m_alloc_level = 20
		dungeon(god_quest.DUNGEON_GOD).min_m_alloc_chance = 120

		-- L: floor is normal
		dungeon(god_quest.DUNGEON_GOD).floor1 = 1
		dungeon(god_quest.DUNGEON_GOD).floor_percent1[1] = 100

		-- A: Granite walls
		dungeon(god_quest.DUNGEON_GOD).fill_type1 = 56
		dungeon(god_quest.DUNGEON_GOD).fill_percent1[1] = 100
		dungeon(god_quest.DUNGEON_GOD).outer_wall = 58
		dungeon(god_quest.DUNGEON_GOD).inner_wall = 57
		dungeon(god_quest.DUNGEON_GOD).fill_method = 0

		-- O: Loads of combat drops
		dungeon(god_quest.DUNGEON_GOD).objs.treasure = 10
		dungeon(god_quest.DUNGEON_GOD).objs.combat = 70
		dungeon(god_quest.DUNGEON_GOD).objs.magic = 5
		dungeon(god_quest.DUNGEON_GOD).objs.tools = 15

		-- F: fairly standard
		dungeon(god_quest.DUNGEON_GOD).flags1 = bor(DF1_NO_DESTROY, DF1_ADJUST_LEVEL_2)
		dungeon(god_quest.DUNGEON_GOD).flags2 = DF2_ADJUST_LEVEL_PLAYER

		-- R:
		dungeon(god_quest.DUNGEON_GOD).rules[1].mode = 3
		dungeon(god_quest.DUNGEON_GOD).rules[1].percent = 100

		-- M: vampires!
		dungeon(god_quest.DUNGEON_GOD).rules[1].r_char = "V"
		dungeon(god_quest.DUNGEON_GOD).rules[1].mflags3 = bor(RF3_UNDEAD, RF3_EVIL)

	end

	-- W: All dungeons are 5 levels deep, and created at 2/3 of the player clvl when the quest is given
	dungeon(god_quest.DUNGEON_GOD).mindepth = god_quest.dun_mindepth
	dungeon(god_quest.DUNGEON_GOD).maxdepth = god_quest.dun_maxdepth
	dungeon(god_quest.DUNGEON_GOD).minplev = god_quest.dun_minplev

end

-- Calling this function returns the direction the dungeon is in from the players position at the time
-- the quest was given, and also the direction from angband (if the player is worshipping Melkor) or lothlorien.
function get_god_quest_axes()
	local home, home_y_coord, home_x_coord, home_axis, home2, home2_y_coord, home2_x_coord, home2_axis, mydistance

	-- different values for different gods...
	if player.pgod ~= GOD_MELKOR then

		-- one of the valar, "home" is lothlorien, home2 is Minas Arnor
		home = "Bree"
		home_y_coord = 21
		home_x_coord = 35
		home2 = "Minas Anor"
		home2_y_coord = 56
		home2_x_coord = 60
	else
		-- Melkor, "home" is angband, home2 is Barad-dur
		home = "the Pits of Angband"
		home_y_coord = 7
		home_x_coord = 11
		home2 = "the Land of Mordor"
		home2_y_coord = 49
		home2_x_coord = 70
	end

	home_axis = compass(home_y_coord, home_x_coord, god_quest.dung_y, god_quest.dung_x)
	home2_axis = compass(home2_y_coord, home2_x_coord, god_quest.dung_y, god_quest.dung_x)

	home_distance = approximate_distance(home_y_coord, home_x_coord, god_quest.dung_y, god_quest.dung_x)
	home2_distance = approximate_distance(home2_y_coord, home2_x_coord, god_quest.dung_y, god_quest.dung_x)

	return home, home_axis, home_distance, home2, home2_axis, home2_distance
end