summary refs log tree commit diff stats
path: root/racing
diff options
context:
space:
mode:
Diffstat (limited to 'racing')
-rw-r--r--racing/load.gd12
-rw-r--r--racing/lobby.gd52
-rw-r--r--racing/manager.gd2
-rw-r--r--racing/multiplayer.gd5
-rw-r--r--racing/router.gd268
5 files changed, 191 insertions, 148 deletions
diff --git a/racing/load.gd b/racing/load.gd index 3fed3c9..0ec76b6 100644 --- a/racing/load.gd +++ b/racing/load.gd
@@ -52,16 +52,16 @@ func _load():
52 victory_panel.name = "Victory" 52 victory_panel.name = "Victory"
53 victory_panel.text = "i win" 53 victory_panel.text = "i win"
54 victory_panel.answer = "i win" 54 victory_panel.answer = "i win"
55 victory_panel.translation.x = race_manager.end_pos[1] + 0.5 55 victory_panel.translation.x = race_manager.end_pos["pos"][0] + 0.5
56 victory_panel.translation.y = race_manager.end_pos[2] + 1.5 56 victory_panel.translation.y = race_manager.end_pos["pos"][1] + 1.5
57 victory_panel.translation.z = race_manager.end_pos[3] + 0.01 57 victory_panel.translation.z = race_manager.end_pos["pos"][2] + 0.01
58 add_child(victory_panel) 58 add_child(victory_panel)
59 victory_panel.get_node("Viewport/GUI/Panel/TextEdit").connect("answer_correct", self, "victory") 59 victory_panel.get_node("Viewport/GUI/Panel/TextEdit").connect("answer_correct", self, "victory")
60 60
61 set_gridmap_tile( 61 set_gridmap_tile(
62 race_manager.end_pos[1], 62 race_manager.end_pos["pos"][0],
63 race_manager.end_pos[2] + 1.5, 63 race_manager.end_pos["pos"][1] + 1.5,
64 race_manager.end_pos[3] - 0.5, 64 race_manager.end_pos["pos"][2] - 0.5,
65 "MeshInstance5" 65 "MeshInstance5"
66 ) 66 )
67 67
diff --git a/racing/lobby.gd b/racing/lobby.gd index 36a90b6..d326098 100644 --- a/racing/lobby.gd +++ b/racing/lobby.gd
@@ -154,7 +154,7 @@ func _on_lobby_created(result: int, lobby_id: int) -> void:
154 _ignore = Steam.setLobbyData(lobby_id, "save_file", global.save_file.to_lower()) 154 _ignore = Steam.setLobbyData(lobby_id, "save_file", global.save_file.to_lower())
155 _ignore = Steam.setLobbyData(lobby_id, "racing_vip", str(player_steam_id)) 155 _ignore = Steam.setLobbyData(lobby_id, "racing_vip", str(player_steam_id))
156 _ignore = Steam.setLobbyData(lobby_id, "closed", "false") 156 _ignore = Steam.setLobbyData(lobby_id, "closed", "false")
157 is_vip = true 157 _become_vip()
158 _request_lobby_list() 158 _request_lobby_list()
159 159
160 160
@@ -166,7 +166,7 @@ func _on_lobby_joined(lobby_id: int, _permissions: int, _locked: bool, result: i
166 Steam.leaveLobby(active_lobby_id) 166 Steam.leaveLobby(active_lobby_id)
167 active_lobby_id = lobby_id 167 active_lobby_id = lobby_id
168 if Steam.getLobbyData(lobby_id, "racing_vip") == str(player_steam_id): 168 if Steam.getLobbyData(lobby_id, "racing_vip") == str(player_steam_id):
169 is_vip = true 169 _become_vip()
170 _update_lobby_members() 170 _update_lobby_members()
171 171
172 172
@@ -249,15 +249,14 @@ func _read_p2p_packet() -> void:
249 ) 249 )
250 if "start_x" in data: 250 if "start_x" in data:
251 race_manager.level = data["level"] 251 race_manager.level = data["level"]
252 race_manager.start_pos = [ 252 race_manager.start_pos = {
253 data["start_name"], 253 "title": data["start_name"],
254 int(data["start_x"]), 254 "pos": [int(data["start_x"]), int(data["start_y"]), int(data["start_z"])]
255 int(data["start_y"]), 255 }
256 int(data["start_z"]) 256 race_manager.end_pos = {
257 ] 257 "title": data["end_name"],
258 race_manager.end_pos = [ 258 "pos": [int(data["end_x"]), int(data["end_y"]), int(data["end_z"])]
259 data["end_name"], int(data["end_x"]), int(data["end_y"]), int(data["end_z"]) 259 }
260 ]
261 260
262 is_starting = true 261 is_starting = true
263 _start_game() 262 _start_game()
@@ -302,13 +301,22 @@ func _send_p2p_packet(data: Dictionary, recipient_id: int, mode: int, needs_ack:
302 var _ignore = Steam.sendP2PPacket(recipient_id, serialized, mode) 301 var _ignore = Steam.sendP2PPacket(recipient_id, serialized, mode)
303 302
304 303
304func _become_vip():
305 is_vip = true
306 get_node("Panel/ItemList").margin_left = 226
307 get_node("Panel/Settings").visible = true
308
309
305func _main_button_pressed(): 310func _main_button_pressed():
306 if everyone_ready and is_vip: 311 if everyone_ready and is_vip:
307 get_node("Panel/main_button").disabled = true 312 get_node("Panel/main_button").disabled = true
308 313
309 var _ignore = Steam.setLobbyData(active_lobby_id, "closed", "true") 314 var _ignore = Steam.setLobbyData(active_lobby_id, "closed", "true")
310 315
311 var route = router.choose_route() 316 var route = router.choose_route(
317 get_node("Panel/Settings/LevelOption").get_selected_id(),
318 get_node("Panel/Settings/LengthOption").get_selected_id()
319 )
312 var start_pos = route[1] 320 var start_pos = route[1]
313 var end_pos = route[2] 321 var end_pos = route[2]
314 322
@@ -327,14 +335,14 @@ func _main_button_pressed():
327 _send_p2p_packet( 335 _send_p2p_packet(
328 { 336 {
329 "level": route[0], 337 "level": route[0],
330 "start_name": start_pos[0], 338 "start_name": start_pos["title"],
331 "start_x": str(start_pos[1]), 339 "start_x": str(start_pos["pos"][0]),
332 "start_y": str(start_pos[2]), 340 "start_y": str(start_pos["pos"][1]),
333 "start_z": str(start_pos[3]), 341 "start_z": str(start_pos["pos"][2]),
334 "end_name": end_pos[0], 342 "end_name": end_pos["title"],
335 "end_x": str(end_pos[1]), 343 "end_x": str(end_pos["pos"][0]),
336 "end_y": str(end_pos[2]), 344 "end_y": str(end_pos["pos"][1]),
337 "end_z": str(end_pos[3]), 345 "end_z": str(end_pos["pos"][2]),
338 }, 346 },
339 RECIPIENT_BROADCAST_ALL, 347 RECIPIENT_BROADCAST_ALL,
340 Steam.P2P_SEND_RELIABLE, 348 Steam.P2P_SEND_RELIABLE,
@@ -361,7 +369,9 @@ func _start_game():
361 Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED) 369 Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
362 global.map = race_manager.level 370 global.map = race_manager.level
363 global.entry_point = Vector3( 371 global.entry_point = Vector3(
364 race_manager.start_pos[1], race_manager.start_pos[2] + 1, race_manager.start_pos[3] 372 race_manager.start_pos["pos"][0],
373 race_manager.start_pos["pos"][1] + 1,
374 race_manager.start_pos["pos"][2]
365 ) 375 )
366 global.entry_rotate = Vector3(0, 0, 0) 376 global.entry_rotate = Vector3(0, 0, 0)
367 global.sets_entry_point = true 377 global.sets_entry_point = true
diff --git a/racing/manager.gd b/racing/manager.gd index 48ef466..573e50a 100644 --- a/racing/manager.gd +++ b/racing/manager.gd
@@ -17,7 +17,7 @@ func everyone_ready():
17 get_node("/root/Spatial").remove_child(get_node("/root/Spatial/blindfold")) 17 get_node("/root/Spatial").remove_child(get_node("/root/Spatial/blindfold"))
18 var indicator = player.get_node("pivot/camera/achievement_label") 18 var indicator = player.get_node("pivot/camera/achievement_label")
19 indicator.visible = true 19 indicator.visible = true
20 indicator.text = "Destination:\n%s" % end_pos[0] 20 indicator.text = "Destination:\n%s" % end_pos["title"]
21 21
22 yield(get_tree().create_timer(10), "timeout") 22 yield(get_tree().create_timer(10), "timeout")
23 23
diff --git a/racing/multiplayer.gd b/racing/multiplayer.gd index ae2ed48..2aafbb9 100644 --- a/racing/multiplayer.gd +++ b/racing/multiplayer.gd
@@ -297,7 +297,10 @@ func time_to_start():
297 player.playable = true 297 player.playable = true
298 get_node("/root/Spatial/label").text = ( 298 get_node("/root/Spatial/label").text = (
299 "Start: %s\nDestination: %s" 299 "Start: %s\nDestination: %s"
300 % [global.get_node("RaceManager").start_pos[0], global.get_node("RaceManager").end_pos[0]] 300 % [
301 global.get_node("RaceManager").start_pos["title"],
302 global.get_node("RaceManager").end_pos["title"]
303 ]
301 ) 304 )
302 global.get_node("RaceManager").start_timer() 305 global.get_node("RaceManager").start_timer()
303 get_node("/root/Spatial").ingame_achieve("Go!") 306 get_node("/root/Spatial").ingame_achieve("Go!")
diff --git a/racing/router.gd b/racing/router.gd index debfafb..ea3693f 100644 --- a/racing/router.gd +++ b/racing/router.gd
@@ -1,135 +1,151 @@
1extends Node 1extends Node
2 2
3const LL1_AREAS = [ 3const LL1_AREAS = [
4 ["Starting Room", 0, 0, 0], 4 {"title": "Starting Room", "pos": [0, 0, 0]},
5 ["Second Room", 0, 0, -15], 5 {"title": "Second Room", "pos": [0, 0, -15]},
6 ["The Traveled", 34, 0, -18], 6 {"title": "The Traveled", "pos": [34, 0, -18]},
7 ["The Agreeable", 30, 0, -45], 7 {"title": "The Agreeable", "pos": [30, 0, -45]},
8 ["The Colorful", 10, 0, -83], 8 {"title": "The Colorful", "pos": [10, 0, -83]},
9 ["Suits Area", 0, 0, -78, true], 9 {"title": "Suits Area", "pos": [0, 0, -78], "no_start": true},
10 ["Arrow Garden", -93, 1, -93], 10 {"title": "Arrow Garden", "pos": [-93, 1, -93]},
11 ["The Wondrous (Table)", -108, 1, -78], 11 {"title": "The Wondrous (Table)", "pos": [-108, 1, -78]},
12 ["Courtyard", -64, 0, -71], 12 {"title": "Courtyard", "pos": [-64, 0, -71]},
13 ["Yellow Backside Nine", -38, 0, -58], 13 {"title": "Yellow Backside Nine", "pos": [-38, 0, -58]},
14 ["Hot Crusts Area", -20, 0, -81], 14 {"title": "Hot Crusts Area", "pos": [-20, 0, -81]},
15 ["Crossroads Corner", -28, 0, -54], 15 {"title": "Crossroads Corner", "pos": [-28, 0, -54]},
16 ["The Discerning", -54, 0, -34, true], 16 {"title": "The Discerning", "pos": [-54, 0, -34], "no_start": true},
17 ["Green Backside", 22, 0, -94], 17 {"title": "Green Backside", "pos": [22, 0, -94]},
18 ["Observant Upstairs", 40, 9, -92, true], 18 {"title": "Observant Upstairs", "pos": [40, 9, -92], "no_start": true},
19 ["Eight Room", 95, 15, -28], 19 {"title": "Eight Room", "pos": [95, 15, -28]},
20 ["The Perceptive", 60, 9, -57], 20 {"title": "The Perceptive", "pos": [60, 9, -57]},
21 ["The Tenacious", 0, 0, -43], 21 {"title": "The Tenacious", "pos": [0, 0, -43]},
22 ["Rainbow", -96, 0, -41], 22 {"title": "Rainbow", "pos": [-96, 0, -41]},
23 ["The Undeterred", -87, 0, 25, true], 23 {"title": "The Undeterred", "pos": [-87, 0, 25], "no_start": true},
24 ["Directional Gallery", -57, 0, 0], 24 {"title": "Directional Gallery", "pos": [-57, 0, 0]},
25 ["The Eyes They See", -54, 0, -23], 25 {"title": "The Eyes They See", "pos": [-54, 0, -23]},
26 ["Tower First Floor", -27, 0, -23], 26 {"title": "Tower First Floor", "pos": [-27, 0, -23], "long": true},
27 ["The Optimistic", 76, 0, -17], 27 {"title": "The Optimistic", "pos": [76, 0, -17]},
28 ["The Initiated", 63, 0, -0, true], 28 {"title": "The Initiated", "pos": [63, 0, -0], "no_start": true},
29 ["Art Gallery", 92, 0, 15], 29 {"title": "Art Gallery", "pos": [92, 0, 15]},
30 ["Art Gallery Top", 80, 30, 15], 30 {"title": "Art Gallery Top", "pos": [80, 30, 15]},
31 ["Lookout", 75, 18, 51], 31 {"title": "Lookout", "pos": [75, 18, 51]},
32 ["Knight Night Room", 37, 0, 7], 32 {"title": "Knight Night Room", "pos": [37, 0, 7]},
33 ["The Seeker", 9, 0, 16, true], 33 {"title": "The Seeker", "pos": [9, 0, 16], "no_start": true},
34 ["Hidden Room", 13, 0, 4], 34 {"title": "Hidden Room", "pos": [13, 0, 4]},
35 ["Owl Hallway", 44, 0, -26], 35 {"title": "Owl Hallway", "pos": [44, 0, -26]},
36 ["Challenge Room", -9, 6, 13], 36 {"title": "Challenge Room", "pos": [-9, 6, 13], "long": true},
37 ["Pilgrim Room", -22, 0, 24, true], 37 {"title": "Pilgrim Room", "pos": [-22, 0, 24], "no_start": true, "long": true},
38 ["Cellar Replica", -44, 0, 30], 38 {"title": "Cellar Replica", "pos": [-44, 0, 30]},
39 ["Elements Area", -61, 0, 40], 39 {"title": "Elements Area", "pos": [-61, 0, 40]},
40 ["The Artistic", -25, 0, 54, true], 40 {"title": "The Artistic", "pos": [-25, 0, 54], "no_start": true},
41 ["Outside The Wise", -44, 0, 71], 41 {"title": "Outside The Wise", "pos": [-44, 0, 71]},
42 ["The Wise", -72, 0, 72, true], 42 {"title": "The Wise", "pos": [-72, 0, 72], "no_start": true},
43 ["The Scientific", -18, 0, 89], 43 {"title": "The Scientific", "pos": [-18, 0, 89], "long": true},
44 ["The Wanderer", 0, 0, 80], 44 {"title": "The Wanderer", "pos": [0, 0, 80], "long": true},
45 ["The Fearless", 18, 10, 90], 45 {"title": "The Fearless", "pos": [18, 10, 90]},
46 ["Champion's Rest", 23, 0, 62, true], 46 {"title": "Champion's Rest", "pos": [23, 0, 62], "no_start": true, "long": true},
47 ["The Steady", 31, 0, 77, true], 47 {"title": "The Steady", "pos": [31, 0, 77], "no_start": true},
48 ["The Bold", 67, 0, 77, true], 48 {"title": "The Bold", "pos": [67, 0, 77], "no_start": true},
49 ["Color Hunt", 45, 0, 69], 49 {"title": "Color Hunt", "pos": [45, 0, 69]},
50 ["Room Room", 95, 6, 84], 50 {"title": "Room Room", "pos": [95, 6, 84]},
51 ["The Bearer", 61, 0, 51], 51 {"title": "The Bearer", "pos": [61, 0, 51]},
52 ["Tower Third Floor", 18, 0, 33], 52 {"title": "Tower Third Floor", "pos": [18, 0, 33]},
53 ["Rhyme Room (Cross)", 0, 9, 42], 53 {"title": "Rhyme Room (Cross)", "pos": [0, 9, 42]},
54 ["Tower Seventh Floor", 0, 37, 64], 54 {"title": "Tower Seventh Floor", "pos": [0, 37, 64], "long": true},
55] 55]
56 56
57const LL2_AREAS = [ 57const LL2_AREAS = [
58 ["Orange Pyramid", 86, 10, -84, true], 58 {"title": "Orange Pyramid", "pos": [86, 10, -84], "no_start": true, "long": true},
59 ["The Stellar", 43, 6, -86], 59 {"title": "The Stellar", "pos": [43, 6, -86]},
60 ["The Fuzzy", 12, 1, -86, true], 60 {"title": "The Fuzzy", "pos": [12, 1, -86], "no_start": true},
61 ["The Devious", 0, 0, -88], 61 {"title": "The Devious", "pos": [0, 0, -88]},
62 ["The Sharp", -26, 0, -88, true], 62 {"title": "The Sharp", "pos": [-26, 0, -88], "no_start": true},
63 ["The Structured", -50, 0, -88], 63 {"title": "The Structured", "pos": [-50, 0, -88]},
64 ["Brown Pyramid", -86, 10, -85, true], 64 {"title": "Brown Pyramid", "pos": [-86, 10, -85], "no_start": true, "long": true},
65 ["The Tasty", -86, 7, -62], 65 {"title": "The Tasty", "pos": [-86, 7, -62]},
66 ["Black White Room", -88, 0, -32], 66 {"title": "Black White Room", "pos": [-88, 0, -32]},
67 ["Lime Magenta Room", -96, 0, -24], 67 {"title": "Lime Magenta Room", "pos": [-96, 0, -24]},
68 ["Red Blue Room", -87, 0, -23], 68 {"title": "Red Blue Room", "pos": [-87, 0, -23]},
69 ["The Archaeologist", -74, 0, -32], 69 {"title": "The Archaeologist", "pos": [-74, 0, -32], "long": true},
70 ["The Earnest", -87, 0, -56], 70 {"title": "The Earnest", "pos": [-87, 0, -56]},
71 ["The Hidden", -50, 6, -71, true], 71 {"title": "The Hidden", "pos": [-50, 6, -71], "no_start": true},
72 ["The Sapient", -36, 36, -36], 72 {"title": "The Sapient", "pos": [-36, 36, -36]},
73 ["The Ethereal", -42, 0, -22], 73 {"title": "The Ethereal", "pos": [-42, 0, -22]},
74 ["The Learned", 34, 1, -64, true], 74 {"title": "The Learned", "pos": [34, 1, -64], "no_start": true},
75 ["Whispers Behind Quiet Walls", 44, 0, -51, true], 75 {"title": "Whispers Behind Quiet Walls", "pos": [44, 0, -51], "no_start": true, "long": true},
76 ["The Lunar", 45, 0, -22], 76 {"title": "The Lunar", "pos": [45, 0, -22]},
77 ["The Arcadian", 86, 0, -53], 77 {"title": "The Arcadian", "pos": [86, 0, -53]},
78 ["The Frozen", 84, 0, -27], 78 {"title": "The Frozen", "pos": [84, 0, -27]},
79 ["The Unscrambled", -50, 0, -10], 79 {"title": "The Unscrambled", "pos": [-50, 0, -10]},
80 ["Nightmare", 73, 0, -27, true], 80 {"title": "Nightmare", "pos": [73, 0, -27], "no_start": true},
81 ["The Amazing", -13, 0, -42], 81 {"title": "The Amazing", "pos": [-13, 0, -42]},
82 ["Challenge Room", -94, 0, 2], 82 {"title": "Challenge Room", "pos": [-94, 0, 2]},
83 ["The Fresh", -82, 0, -10], 83 {"title": "The Fresh", "pos": [-82, 0, -10]},
84 ["The Exemplary", -82, 0, 11], 84 {"title": "The Exemplary", "pos": [-82, 0, 11]},
85 ["The Roaming", -66, 0, -11], 85 {"title": "The Roaming", "pos": [-66, 0, -11]},
86 ["The Veteran", -66, 0, 12], 86 {"title": "The Veteran", "pos": [-66, 0, 12]},
87 ["The Royal", -50, 0, 10], 87 {"title": "The Royal", "pos": [-50, 0, 10]},
88 ["The Exact", -33, 0, -12], 88 {"title": "The Exact", "pos": [-33, 0, -12]},
89 ["The Appreciated", -33, 0, 11], 89 {"title": "The Appreciated", "pos": [-33, 0, 11]},
90 ["The Unsullied", -17, 0, -11], 90 {"title": "The Unsullied", "pos": [-17, 0, -11]},
91 ["The Unopposed", -18, 0, 10], 91 {"title": "The Unopposed", "pos": [-18, 0, 10]},
92 ["The Multitalented", -10, 0, 0], 92 {"title": "The Multitalented", "pos": [-10, 0, 0]},
93 ["Starting Room", 0, 0, 0], 93 {"title": "Starting Room", "pos": [0, 0, 0]},
94 ["Control Room", 0, 0, 14], 94 {"title": "Control Room", "pos": [0, 0, 14]},
95 ["Countdown Room", 0, 0, 33, true], 95 {"title": "Countdown Room", "pos": [0, 0, 33], "no_start": true},
96 ["The Lucky", 13, 1, 32, true], 96 {"title": "The Lucky", "pos": [13, 1, 32], "no_start": true, "long": true},
97 ["Greenhouse", 14, 0, 6], 97 {"title": "Greenhouse", "pos": [14, 0, 6]},
98 ["The Sweet", 24, 0, 18, true], 98 {"title": "The Sweet", "pos": [24, 0, 18], "no_start": true},
99 ["The Fall", 87, 0, -4, true], 99 {"title": "The Fall", "pos": [87, 0, -4], "no_start": true, "long": true},
100 ["White Pyramid", 46, 0, -1], 100 {"title": "White Pyramid", "pos": [46, 0, -1], "long": true},
101 ["Z", 95, 0, 25, true], 101 {"title": "Z", "pos": [95, 0, 25], "no_start": true},
102 ["The Worldly", 92, 0, 58], 102 {"title": "The Worldly", "pos": [92, 0, 58]},
103 ["The Perennial", 39, 0, 32], 103 {"title": "The Perennial", "pos": [39, 0, 32]},
104 ["The Analytical", -28, 0, 35], 104 {"title": "The Analytical", "pos": [-28, 0, 35]},
105 ["Car Room", -59, 0, 50, true], 105 {"title": "Car Room", "pos": [-59, 0, 50], "no_start": true},
106 ["The Mythical", -35, 4, 73], 106 {"title": "The Mythical", "pos": [-35, 4, 73]},
107 ["LL1 Starting Room", -70, 0, 41], 107 {"title": "LL1 Starting Room", "pos": [-70, 0, 41]},
108 ["LL1 Second Room", -86, 0, 41], 108 {"title": "LL1 Second Room", "pos": [-86, 0, 41]},
109 ["The Seen", -83, 0, 57, true], 109 {"title": "The Seen", "pos": [-83, 0, 57], "no_start": true},
110 ["Purple Pyramid", -87, 10, 85, true], 110 {"title": "Purple Pyramid", "pos": [-87, 10, 85], "no_start": true, "long": true},
111 ["Four Pips", -66, 0, 76], 111 {"title": "Four Pips", "pos": [-66, 0, 76]},
112 ["Twinkle Twinkle Little Star", 6, 0, 55, true], 112 {"title": "Twinkle Twinkle Little Star", "pos": [6, 0, 55], "no_start": true},
113 ["The Unforgettable", 9, 40, 88], 113 {"title": "The Unforgettable", "pos": [9, 40, 88]},
114 ["HI Room", 27, 0, 59], 114 {"title": "HI Room", "pos": [27, 0, 59]},
115 ["The Handy", 39, 10, 83], 115 {"title": "The Handy", "pos": [39, 10, 83]},
116 ["Mint Pyramid", 86, 10, 83, true], 116 {"title": "Mint Pyramid", "pos": [86, 10, 83], "no_start": true, "long": true},
117] 117]
118 118
119const kLEVEL_CHOICE_ANY = 0
120const kLEVEL_CHOICE_LL1 = 1
121const kLEVEL_CHOICE_LL2 = 2
119 122
120func choose_route(): 123const kLENGTH_CHOICE_ANY = 0
124const kLENGTH_CHOICE_SHORT = 1
125const kLENGTH_CHOICE_LONG = 2
126
127
128func choose_route(levelchoice: int, lengthchoice: int):
121 var rng = RandomNumberGenerator.new() 129 var rng = RandomNumberGenerator.new()
122 rng.randomize() 130 rng.randomize()
123 131
124 var areas_slot 132 var areas_slot
125 var level_name 133 var level_name
126 if rng.randi_range(0, 2) == 0: 134 if levelchoice == kLEVEL_CHOICE_ANY:
127 areas_slot = LL1_AREAS 135 if rng.randi_range(0, 2) == 0:
136 level_name = "level1"
137 else:
138 level_name = "level2"
139 elif levelchoice == kLEVEL_CHOICE_LL1:
128 level_name = "level1" 140 level_name = "level1"
129 else: 141 elif levelchoice == kLEVEL_CHOICE_LL2:
130 areas_slot = LL2_AREAS
131 level_name = "level2" 142 level_name = "level2"
132 143
144 if level_name == "level1":
145 areas_slot = LL1_AREAS
146 elif level_name == "level2":
147 areas_slot = LL2_AREAS
148
133 var start_pos 149 var start_pos
134 var end_pos 150 var end_pos
135 var found = false 151 var found = false
@@ -141,9 +157,23 @@ func choose_route():
141 i = rng.randi_range(0, areas_dupe.size() - 1) 157 i = rng.randi_range(0, areas_dupe.size() - 1)
142 end_pos = areas_dupe[i] 158 end_pos = areas_dupe[i]
143 159
144 var start_vec = Vector3(start_pos[1], start_pos[2], start_pos[3]) 160 var start_vec = Vector3(start_pos["pos"][0], start_pos["pos"][1], start_pos["pos"][2])
145 var end_vec = Vector3(end_pos[1], end_pos[2], end_pos[3]) 161 var end_vec = Vector3(end_pos["pos"][0], end_pos["pos"][1], end_pos["pos"][2])
146 if start_vec.distance_to(end_vec) > 50 and not (start_pos.size() >= 5 and start_pos[4]): 162 if start_vec.distance_to(end_vec) < 50:
147 found = true 163 continue
164
165 if start_pos.has("no_start") and start_pos["no_start"]:
166 continue
167
168 if end_pos.has("long") and end_pos["long"] and lengthchoice == kLENGTH_CHOICE_SHORT:
169 continue
170
171 if (
172 ((end_pos.has("long") and !end_pos["long"]) or !end_pos.has("long"))
173 and lengthchoice == kLENGTH_CHOICE_LONG
174 ):
175 continue
176
177 found = true
148 178
149 return [level_name, start_pos, end_pos] 179 return [level_name, start_pos, end_pos]