summary refs log tree commit diff stats
path: root/racing/router.gd
blob: 7d10ac06b42e9dc195b31252caefc51cb833d6dd (plain) (blame)
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
extends Node

const LL1_AREAS = [
	{"title": "Starting Room", "pos": [0, 0, 0]},
	{"title": "Second Room", "pos": [0, 0, -15]},
	{"title": "The Traveled", "pos": [34, 0, -18]},
	{"title": "The Agreeable", "pos": [30, 0, -45]},
	{"title": "The Colorful", "pos": [10, 0, -83]},
	{"title": "Suits Area", "pos": [0, 0, -78], "no_start": true},
	{"title": "Arrow Garden", "pos": [-93, 1, -93]},
	{"title": "The Wondrous (Table)", "pos": [-108, 1, -78]},
	{"title": "Courtyard", "pos": [-64, 0, -71]},
	{"title": "Yellow Backside Nine", "pos": [-38, 0, -58]},
	{"title": "Hot Crusts Area", "pos": [-20, 0, -81]},
	{"title": "Crossroads Corner", "pos": [-28, 0, -54]},
	{"title": "The Discerning", "pos": [-54, 0, -34], "no_start": true},
	{"title": "Green Backside", "pos": [22, 0, -94]},
	{"title": "Observant Upstairs", "pos": [40, 9, -92], "no_start": true},
	{"title": "Eight Room", "pos": [95, 15, -28]},
	{"title": "The Perceptive", "pos": [60, 9, -57]},
	{"title": "The Tenacious", "pos": [0, 0, -43]},
	{"title": "Rainbow", "pos": [-96, 0, -41]},
	{"title": "The Undeterred", "pos": [-87, 0, 25], "no_start": true},
	{"title": "Directional Gallery", "pos": [-57, 0, 0]},
	{"title": "The Eyes They See", "pos": [-56, 0, -25]},
	{"title": "Tower First Floor", "pos": [-27, 0, -23], "long": true},
	{"title": "The Optimistic", "pos": [76, 0, -17]},
	{"title": "The Initiated", "pos": [63, 0, -0], "no_start": true},
	{"title": "Art Gallery", "pos": [92, 0, 15]},
	{"title": "Art Gallery Top", "pos": [80, 30, 15]},
	{"title": "Lookout", "pos": [75, 18, 51]},
	{"title": "Knight Night Room", "pos": [37, 0, 7]},
	{"title": "The Seeker", "pos": [9, 0, 16], "no_start": true},
	{"title": "Hidden Room", "pos": [13, 0, 4]},
	{"title": "Owl Hallway", "pos": [44, 0, -26]},
	{"title": "Challenge Room", "pos": [-9, 6, 13], "long": true},
	{"title": "Pilgrim Room", "pos": [-22, 0, 24], "no_start": true, "long": true},
	{"title": "Cellar Replica", "pos": [-44, 0, 30]},
	{"title": "Elements Area", "pos": [-61, 0, 40]},
	{"title": "The Artistic", "pos": [-25, 0, 54], "no_start": true},
	{"title": "Outside The Wise", "pos": [-44, 0, 71]},
	{"title": "The Wise", "pos": [-72, 0, 72], "no_start": true},
	{"title": "The Scientific", "pos": [-18, 0, 89], "long": true},
	{"title": "The Wanderer", "pos": [0, 0, 80], "long": true},
	{"title": "The Fearless", "pos": [18, 10, 90]},
	{"title": "Champion's Rest", "pos": [23, 0, 62], "no_start": true, "long": true},
	{"title": "The Steady", "pos": [31, 0, 77], "no_start": true},
	{"title": "The Bold", "pos": [67, 0, 77], "no_start": true},
	{"title": "Color Hunt", "pos": [45, 0, 69]},
	{"title": "Room Room", "pos": [95, 6, 84]},
	{"title": "The Bearer", "pos": [61, 0, 51]},
	{"title": "Tower Third Floor", "pos": [18, 0, 33]},
	{"title": "Rhyme Room (Cross)", "pos": [0, 9, 42]},
	{"title": "Tower Seventh Floor", "pos": [0, 37, 64], "long": true},
]

const LL2_AREAS = [
	{"title": "Orange Pyramid", "pos": [86, 10, -84], "no_start": true, "long": true},
	{"title": "The Stellar", "pos": [43, 6, -86]},
	{"title": "The Fuzzy", "pos": [12, 1, -86], "no_start": true},
	{"title": "The Devious", "pos": [0, 0, -88]},
	{"title": "The Sharp", "pos": [-26, 0, -88], "no_start": true},
	{"title": "The Structured", "pos": [-50, 0, -88]},
	{"title": "Brown Pyramid", "pos": [-86, 10, -85], "no_start": true, "long": true},
	{"title": "The Tasty", "pos": [-86, 7, -62]},
	{"title": "Black White Room", "pos": [-88, 0, -32]},
	{"title": "Lime Magenta Room", "pos": [-96, 0, -24]},
	{"title": "Red Blue Room", "pos": [-87, 0, -23]},
	{"title": "The Archaeologist", "pos": [-74, 0, -32], "long": true},
	{"title": "The Earnest", "pos": [-87, 0, -56]},
	{"title": "The Hidden", "pos": [-50, 6, -71], "no_start": true},
	{"title": "The Sapient", "pos": [-36, 36, -36]},
	{"title": "The Ethereal", "pos": [-42, 0, -22]},
	{"title": "The Learned", "pos": [34, 1, -64], "no_start": true},
	{
		"title": "Whispers Behind Quiet Walls",
		"pos": [44, 0, -51],
		"no_start": true,
		"long": true,
		"small_font": true
	},
	{"title": "The Lunar", "pos": [45, 0, -22]},
	{"title": "The Arcadian", "pos": [86, 0, -53]},
	{"title": "The Frozen", "pos": [84, 0, -27]},
	{"title": "The Unscrambled", "pos": [-50, 0, -10]},
	{"title": "Nightmare", "pos": [73, 0, -27], "no_start": true},
	{"title": "The Amazing", "pos": [-13, 0, -42]},
	{"title": "Challenge Room", "pos": [-94, 0, 2]},
	{"title": "The Fresh", "pos": [-82, 0, -10]},
	{"title": "The Exemplary", "pos": [-82, 0, 11]},
	{"title": "The Roaming", "pos": [-66, 0, -11]},
	{"title": "The Veteran", "pos": [-66, 0, 12]},
	{"title": "The Royal", "pos": [-50, 0, 10]},
	{"title": "The Exact", "pos": [-33, 0, -12]},
	{"title": "The Appreciated", "pos": [-33, 0, 11]},
	{"title": "The Unsullied", "pos": [-17, 0, -11]},
	{"title": "The Unopposed", "pos": [-18, 0, 10]},
	{"title": "The Multitalented", "pos": [-10, 0, 0]},
	{"title": "Starting Room", "pos": [0, 0, 0]},
	{"title": "Control Room", "pos": [0, 0, 14]},
	{"title": "Countdown Room", "pos": [0, 0, 33], "no_start": true},
	{"title": "The Lucky", "pos": [13, 1, 32], "no_start": true, "long": true},
	{"title": "Greenhouse", "pos": [14, 0, 6]},
	{"title": "The Sweet", "pos": [24, 0, 18], "no_start": true},
	{"title": "The Fall", "pos": [87, 0, -4], "no_start": true, "long": true},
	{"title": "White Pyramid", "pos": [46, 0, -1], "long": true},
	{"title": "Z", "pos": [95, 0, 25], "no_start": true},
	{"title": "The Worldly", "pos": [92, 0, 58]},
	{"title": "The Perennial", "pos": [39, 0, 32]},
	{"title": "The Analytical", "pos": [-28, 0, 35]},
	{"title": "Car Room", "pos": [-59, 0, 50], "no_start": true},
	{"title": "The Mythical", "pos": [-35, 4, 73]},
	{"title": "LL1 Starting Room", "pos": [-70, 0, 41]},
	{"title": "LL1 Second Room", "pos": [-86, 0, 41]},
	{"title": "The Seen", "pos": [-83, 0, 57], "no_start": true},
	{"title": "Purple Pyramid", "pos": [-87, 10, 85], "no_start": true, "long": true},
	{"title": "Four Pips", "pos": [-66, 0, 76]},
	{"title": "Twinkle Twinkle Little Star", "pos": [6, 0, 55], "no_start": true},
	{"title": "The Unforgettable", "pos": [9, 40, 88]},
	{"title": "HI Room", "pos": [27, 0, 59]},
	{"title": "The Handy", "pos": [39, 10, 83]},
	{"title": "Mint Pyramid", "pos": [86, 10, 83], "no_start": true, "long": true},
]

const kLEVEL_CHOICE_ANY = 0
const kLEVEL_CHOICE_LL1 = 1
const kLEVEL_CHOICE_LL2 = 2

const kLENGTH_CHOICE_ANY = 0
const kLENGTH_CHOICE_SHORT = 1
const kLENGTH_CHOICE_LONG = 2


func choose_route(levelchoice: int, lengthchoice: int):
	var rng = RandomNumberGenerator.new()
	rng.randomize()

	var areas_slot
	var level_name
	if levelchoice == kLEVEL_CHOICE_ANY:
		if rng.randi_range(0, 2) == 0:
			level_name = "level1"
		else:
			level_name = "level2"
	elif levelchoice == kLEVEL_CHOICE_LL1:
		level_name = "level1"
	elif levelchoice == kLEVEL_CHOICE_LL2:
		level_name = "level2"

	if level_name == "level1":
		areas_slot = LL1_AREAS
	elif level_name == "level2":
		areas_slot = LL2_AREAS

	var start_pos
	var end_pos
	var found = false
	while !found:
		var areas_dupe = areas_slot.duplicate()
		var i = rng.randi_range(0, areas_dupe.size() - 1)
		start_pos = areas_dupe[i]
		areas_dupe.remove(i)
		i = rng.randi_range(0, areas_dupe.size() - 1)
		end_pos = areas_dupe[i]

		var start_vec = Vector3(start_pos["pos"][0], start_pos["pos"][1], start_pos["pos"][2])
		var end_vec = Vector3(end_pos["pos"][0], end_pos["pos"][1], end_pos["pos"][2])
		if start_vec.distance_to(end_vec) < 50:
			continue

		if start_pos.has("no_start") and start_pos["no_start"]:
			continue

		if end_pos.has("long") and end_pos["long"] and lengthchoice == kLENGTH_CHOICE_SHORT:
			continue

		if (
			((end_pos.has("long") and !end_pos["long"]) or !end_pos.has("long"))
			and lengthchoice == kLENGTH_CHOICE_LONG
		):
			continue

		found = true

	return [level_name, start_pos, end_pos]


func get_area(level, name):
	var areas_slot
	if level == "level1":
		areas_slot = LL1_AREAS
	elif level == "level2":
		areas_slot = LL2_AREAS

	for item in areas_slot:
		if item["title"] == name:
			return item

	return {"title": "Error"}