diff options
author | Star Rauchenberger <fefferburbia@gmail.com> | 2024-02-09 11:24:39 -0500 |
---|---|---|
committer | Star Rauchenberger <fefferburbia@gmail.com> | 2024-02-09 11:24:39 -0500 |
commit | 12c696bc5b6e960a1d9228a5b68e5aafcc02e23c (patch) | |
tree | 93dee66407e73ff4bab7b5737f3ddf447aa5605e /racing | |
parent | 56857faf6f9149e0cd48cb9bfc842849c796f3a7 (diff) | |
download | lingo-race-12c696bc5b6e960a1d9228a5b68e5aafcc02e23c.tar.gz lingo-race-12c696bc5b6e960a1d9228a5b68e5aafcc02e23c.tar.bz2 lingo-race-12c696bc5b6e960a1d9228a5b68e5aafcc02e23c.zip |
LL2 support
Diffstat (limited to 'racing')
-rw-r--r-- | racing/lobby.gd | 85 | ||||
-rw-r--r-- | racing/manager.gd | 1 | ||||
-rw-r--r-- | racing/router.gd | 149 |
3 files changed, 162 insertions, 73 deletions
diff --git a/racing/lobby.gd b/racing/lobby.gd index 86e4920..c81694a 100644 --- a/racing/lobby.gd +++ b/racing/lobby.gd | |||
@@ -11,66 +11,14 @@ var everyone_ready = false | |||
11 | var members_to_join = [] | 11 | var members_to_join = [] |
12 | var is_starting = false | 12 | var is_starting = false |
13 | 13 | ||
14 | var router | ||
15 | |||
14 | const MAX_PLAYERS = 250 | 16 | const MAX_PLAYERS = 250 |
15 | const PROTOCOL_VERSION = 2 | 17 | const PROTOCOL_VERSION = 2 |
16 | const RECIPIENT_BROADCAST_ALL = -1 | 18 | const RECIPIENT_BROADCAST_ALL = -1 |
17 | const LOBBY_MAP_NAME = "ll1_racing" | 19 | const LOBBY_MAP_NAME = "ll1_racing" |
18 | const VERSION = "0.0.7" | 20 | const VERSION = "0.0.7" |
19 | 21 | ||
20 | const LL1_AREAS = [ | ||
21 | ["Starting Room", 0, 0, 0], | ||
22 | ["Second Room", 0, 0, -15], | ||
23 | ["The Traveled", 34, 0, -18], | ||
24 | ["The Agreeable", 30, 0, -45], | ||
25 | ["The Colorful", 10, 0, -83], | ||
26 | ["Suits Area", 0, 0, -78, true], | ||
27 | ["Arrow Garden", -93, 1, -93], | ||
28 | ["The Wondrous (Table)", -108, 1, -78], | ||
29 | ["Courtyard", -64, 0, -71], | ||
30 | ["Yellow Backside Nine", -38, 0, -58], | ||
31 | ["Hot Crusts Area", -20, 0, -81], | ||
32 | ["Crossroads Corner", -28, 0, -54], | ||
33 | ["The Discerning", -54, 0, -34, true], | ||
34 | ["Green Backside", 22, 0, -94], | ||
35 | ["Observant Upstairs", 40, 9, -92, true], | ||
36 | ["Eight Room", 95, 15, -28], | ||
37 | ["The Perceptive", 60, 9, -57], | ||
38 | ["The Tenacious", 0, 0, -43], | ||
39 | ["Rainbow", -96, 0, -41], | ||
40 | ["The Undeterred", -87, 0, 25, true], | ||
41 | ["Directional Gallery", -57, 0, 0], | ||
42 | ["The Eyes They See", -54, 0, -23], | ||
43 | ["Tower First Floor", -27, 0, -23], | ||
44 | ["The Optimistic", 76, 0, -17], | ||
45 | ["The Initiated", 63, 0, -0, true], | ||
46 | ["Art Gallery", 92, 0, 15], | ||
47 | ["Art Gallery Top", 80, 30, 15], | ||
48 | ["Lookout", 75, 18, 51], | ||
49 | ["Knight Night Room", 37, 0, 7], | ||
50 | ["The Seeker", 9, 0, 16, true], | ||
51 | ["Hidden Room", 13, 0, 4], | ||
52 | ["Owl Hallway", 44, 0, -26], | ||
53 | ["Challenge Room", -9, 6, 13], | ||
54 | ["Pilgrim Room", -22, 0, 24, true], | ||
55 | ["Cellar Replica", -44, 0, 30], | ||
56 | ["Elements Area", -61, 0, 40], | ||
57 | ["The Artistic", -25, 0, 54, true], | ||
58 | ["Outside The Wise", -44, 0, 71], | ||
59 | ["The Wise", -72, 0, 72, true], | ||
60 | ["The Scientific", -18, 0, 89], | ||
61 | ["The Wanderer", 0, 0, 80], | ||
62 | ["The Fearless", 18, 10, 90], | ||
63 | ["Champion's Rest", 23, 0, 62, true], | ||
64 | ["The Steady", 31, 0, 77, true], | ||
65 | ["The Bold", 67, 0, 77, true], | ||
66 | ["Color Hunt", 45, 0, 69], | ||
67 | ["Room Room", 95, 6, 84], | ||
68 | ["The Bearer", 61, 0, 51], | ||
69 | ["Tower Third Floor", 18, 0, 33], | ||
70 | ["Rhyme Room (Cross)", 0, 9, 42], | ||
71 | ["Tower Seventh Floor", 0, 37, 64], | ||
72 | ] | ||
73 | |||
74 | 22 | ||
75 | func _ready(): | 23 | func _ready(): |
76 | global._print("Starting Lobby") | 24 | global._print("Starting Lobby") |
@@ -100,6 +48,9 @@ func _ready(): | |||
100 | var race_manager = global.get_node("RaceManager") | 48 | var race_manager = global.get_node("RaceManager") |
101 | race_manager.held_messages.clear() | 49 | race_manager.held_messages.clear() |
102 | 50 | ||
51 | var router_script = load("user://maps/racing/router.gd") | ||
52 | router = router_script.new() | ||
53 | |||
103 | var _ignore = get_node("Panel/main_button").connect("pressed", self, "_main_button_pressed") | 54 | var _ignore = get_node("Panel/main_button").connect("pressed", self, "_main_button_pressed") |
104 | _ignore = get_node("Panel/return_button").connect("pressed", self, "_return_button_pressed") | 55 | _ignore = get_node("Panel/return_button").connect("pressed", self, "_return_button_pressed") |
105 | 56 | ||
@@ -295,6 +246,7 @@ func _read_p2p_packet() -> void: | |||
295 | false | 246 | false |
296 | ) | 247 | ) |
297 | if "start_x" in data: | 248 | if "start_x" in data: |
249 | race_manager.level = data["level"] | ||
298 | race_manager.start_pos = [ | 250 | race_manager.start_pos = [ |
299 | data["start_name"], | 251 | data["start_name"], |
300 | int(data["start_x"]), | 252 | int(data["start_x"]), |
@@ -352,30 +304,16 @@ func _main_button_pressed(): | |||
352 | if everyone_ready and is_vip: | 304 | if everyone_ready and is_vip: |
353 | get_node("Panel/main_button").disabled = true | 305 | get_node("Panel/main_button").disabled = true |
354 | 306 | ||
355 | var rng = RandomNumberGenerator.new() | 307 | var route = router.choose_route() |
356 | rng.randomize() | 308 | var start_pos = route[1] |
357 | 309 | var end_pos = route[2] | |
358 | var start_pos | ||
359 | var end_pos | ||
360 | var found = false | ||
361 | while !found: | ||
362 | var areas_dupe = LL1_AREAS.duplicate() | ||
363 | var i = rng.randi_range(0, areas_dupe.size() - 1) | ||
364 | start_pos = areas_dupe[i] | ||
365 | areas_dupe.remove(i) | ||
366 | i = rng.randi_range(0, areas_dupe.size() - 1) | ||
367 | end_pos = areas_dupe[i] | ||
368 | |||
369 | var start_vec = Vector3(start_pos[1], start_pos[2], start_pos[3]) | ||
370 | var end_vec = Vector3(end_pos[1], end_pos[2], end_pos[3]) | ||
371 | if start_vec.distance_to(end_vec) > 50 and not (start_pos.size() >= 5 and start_pos[4]): | ||
372 | found = true | ||
373 | 310 | ||
374 | members_to_join = active_lobby_members.duplicate() | 311 | members_to_join = active_lobby_members.duplicate() |
375 | members_to_join.erase(player_steam_id) | 312 | members_to_join.erase(player_steam_id) |
376 | is_starting = true | 313 | is_starting = true |
377 | 314 | ||
378 | var race_manager = global.get_node("RaceManager") | 315 | var race_manager = global.get_node("RaceManager") |
316 | race_manager.level = route[0] | ||
379 | race_manager.start_pos = start_pos | 317 | race_manager.start_pos = start_pos |
380 | race_manager.end_pos = end_pos | 318 | race_manager.end_pos = end_pos |
381 | 319 | ||
@@ -384,6 +322,7 @@ func _main_button_pressed(): | |||
384 | else: | 322 | else: |
385 | _send_p2p_packet( | 323 | _send_p2p_packet( |
386 | { | 324 | { |
325 | "level": route[0], | ||
387 | "start_name": start_pos[0], | 326 | "start_name": start_pos[0], |
388 | "start_x": str(start_pos[1]), | 327 | "start_x": str(start_pos[1]), |
389 | "start_y": str(start_pos[2]), | 328 | "start_y": str(start_pos[2]), |
@@ -416,7 +355,7 @@ func _start_game(): | |||
416 | 355 | ||
417 | # Switch to LL1 | 356 | # Switch to LL1 |
418 | Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED) | 357 | Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED) |
419 | global.map = "level1" | 358 | global.map = race_manager.level |
420 | global.entry_point = Vector3( | 359 | global.entry_point = Vector3( |
421 | race_manager.start_pos[1], race_manager.start_pos[2] + 1, race_manager.start_pos[3] | 360 | race_manager.start_pos[1], race_manager.start_pos[2] + 1, race_manager.start_pos[3] |
422 | ) | 361 | ) |
diff --git a/racing/manager.gd b/racing/manager.gd index 349b83e..48ef466 100644 --- a/racing/manager.gd +++ b/racing/manager.gd | |||
@@ -2,6 +2,7 @@ extends Node | |||
2 | 2 | ||
3 | var SCRIPT_multiplayer | 3 | var SCRIPT_multiplayer |
4 | 4 | ||
5 | var level | ||
5 | var start_pos | 6 | var start_pos |
6 | var end_pos | 7 | var end_pos |
7 | var lobby_id | 8 | var lobby_id |
diff --git a/racing/router.gd b/racing/router.gd new file mode 100644 index 0000000..15b3f31 --- /dev/null +++ b/racing/router.gd | |||
@@ -0,0 +1,149 @@ | |||
1 | extends Node | ||
2 | |||
3 | const LL1_AREAS = [ | ||
4 | ["Starting Room", 0, 0, 0], | ||
5 | ["Second Room", 0, 0, -15], | ||
6 | ["The Traveled", 34, 0, -18], | ||
7 | ["The Agreeable", 30, 0, -45], | ||
8 | ["The Colorful", 10, 0, -83], | ||
9 | ["Suits Area", 0, 0, -78, true], | ||
10 | ["Arrow Garden", -93, 1, -93], | ||
11 | ["The Wondrous (Table)", -108, 1, -78], | ||
12 | ["Courtyard", -64, 0, -71], | ||
13 | ["Yellow Backside Nine", -38, 0, -58], | ||
14 | ["Hot Crusts Area", -20, 0, -81], | ||
15 | ["Crossroads Corner", -28, 0, -54], | ||
16 | ["The Discerning", -54, 0, -34, true], | ||
17 | ["Green Backside", 22, 0, -94], | ||
18 | ["Observant Upstairs", 40, 9, -92, true], | ||
19 | ["Eight Room", 95, 15, -28], | ||
20 | ["The Perceptive", 60, 9, -57], | ||
21 | ["The Tenacious", 0, 0, -43], | ||
22 | ["Rainbow", -96, 0, -41], | ||
23 | ["The Undeterred", -87, 0, 25, true], | ||
24 | ["Directional Gallery", -57, 0, 0], | ||
25 | ["The Eyes They See", -54, 0, -23], | ||
26 | ["Tower First Floor", -27, 0, -23], | ||
27 | ["The Optimistic", 76, 0, -17], | ||
28 | ["The Initiated", 63, 0, -0, true], | ||
29 | ["Art Gallery", 92, 0, 15], | ||
30 | ["Art Gallery Top", 80, 30, 15], | ||
31 | ["Lookout", 75, 18, 51], | ||
32 | ["Knight Night Room", 37, 0, 7], | ||
33 | ["The Seeker", 9, 0, 16, true], | ||
34 | ["Hidden Room", 13, 0, 4], | ||
35 | ["Owl Hallway", 44, 0, -26], | ||
36 | ["Challenge Room", -9, 6, 13], | ||
37 | ["Pilgrim Room", -22, 0, 24, true], | ||
38 | ["Cellar Replica", -44, 0, 30], | ||
39 | ["Elements Area", -61, 0, 40], | ||
40 | ["The Artistic", -25, 0, 54, true], | ||
41 | ["Outside The Wise", -44, 0, 71], | ||
42 | ["The Wise", -72, 0, 72, true], | ||
43 | ["The Scientific", -18, 0, 89], | ||
44 | ["The Wanderer", 0, 0, 80], | ||
45 | ["The Fearless", 18, 10, 90], | ||
46 | ["Champion's Rest", 23, 0, 62, true], | ||
47 | ["The Steady", 31, 0, 77, true], | ||
48 | ["The Bold", 67, 0, 77, true], | ||
49 | ["Color Hunt", 45, 0, 69], | ||
50 | ["Room Room", 95, 6, 84], | ||
51 | ["The Bearer", 61, 0, 51], | ||
52 | ["Tower Third Floor", 18, 0, 33], | ||
53 | ["Rhyme Room (Cross)", 0, 9, 42], | ||
54 | ["Tower Seventh Floor", 0, 37, 64], | ||
55 | ] | ||
56 | |||
57 | const LL2_AREAS = [ | ||
58 | ["Orange Pyramid", 86, 10, -84, true], | ||
59 | ["The Stellar", 43, 6, -86], | ||
60 | ["The Fuzzy", 12, 1, -86, true], | ||
61 | ["The Devious", 0, 0, -88], | ||
62 | ["The Sharp", -26, 0, -88, true], | ||
63 | ["The Structured", -50, 0, -88], | ||
64 | ["Brown Pyramid", -86, 10, -85, true], | ||
65 | ["The Tasty", -86, 7, -62], | ||
66 | ["Black White Room", -88, 0, -32], | ||
67 | ["Lime Magenta Room", -96, 0, -24], | ||
68 | ["Red Blue Room", -87, 0, -23], | ||
69 | ["The Archaeologist", -74, 0, -32], | ||
70 | ["The Earnest", -87, 0, -56], | ||
71 | ["The Hidden", -50, 6, -71, true], | ||
72 | ["The Sapient", -36, 36, -41], | ||
73 | ["The Ethereal", -42, 0, -22], | ||
74 | ["The Learned", 34, 1, -64, true], | ||
75 | ["Whispers Behind Quiet Walls", 44, 0, -51, true], | ||
76 | ["The Lunar", 45, 0, -22], | ||
77 | ["The Arcadian", 86, 0, -53], | ||
78 | ["The Frozen", 84, 0, -27], | ||
79 | ["The Unscrambled", -50, 0, -10], | ||
80 | ["Nightmare", 73, 0, -27, true], | ||
81 | ["The Amazing", -13, 0, -42], | ||
82 | ["Challenge Room", -94, 0, 2], | ||
83 | ["The Fresh", -82, 0, -10], | ||
84 | ["The Exemplary", -82, 0, 11], | ||
85 | ["The Roaming", -66, 0, -11], | ||
86 | ["The Veteran", -66, 0, 12], | ||
87 | ["The Royal", -50, 0, 10], | ||
88 | ["The Exact", -33, 0, -12], | ||
89 | ["The Appreciated", -33, 0, 11], | ||
90 | ["The Unsullied", -17, 0, -11], | ||
91 | ["The Unopposed", -18, 0, 10], | ||
92 | ["The Multitalented", -10, 0, 0], | ||
93 | ["Starting Room", 0, 0, 0], | ||
94 | ["Control Room", 0, 0, 14], | ||
95 | ["Countdown Room", 0, 0, 33, true], | ||
96 | ["The Lucky", 13, 1, 32, true], | ||
97 | ["Greenhouse", 14, 0, 6], | ||
98 | ["The Sweet", 24, 0, 18, true], | ||
99 | ["The Fall", 87, 0, -4, true], | ||
100 | ["White Pyramid", 46, 0, -1], | ||
101 | ["Z", 95, 0, 25, true], | ||
102 | ["The Worldly", 92, 0, 58], | ||
103 | ["The Perennial", 39, 0, 32], | ||
104 | ["The Analytical", -28, 0, 35], | ||
105 | ["Car Room", -59, 0, 50, true], | ||
106 | ["The Mythical", -35, 4, 73], | ||
107 | ["LL1 Starting Room", -70, 0, 41], | ||
108 | ["LL1 Second Room", -86, 0, 41], | ||
109 | ["The Seen", -83, 0, 57, true], | ||
110 | ["Purple Pyramid", -87, 10, 85, true], | ||
111 | ["Four Pips", -66, 0, 76], | ||
112 | ["Twinkle Twinkle Little Star", 6, 0, 55, true], | ||
113 | ["The Unforgettable", 9, 40, 88], | ||
114 | ["HI Room", 27, 0, 59], | ||
115 | ["The Handy", 39, 10, 83], | ||
116 | ["Mint Pyramid", 86, 10, 83, true], | ||
117 | ] | ||
118 | |||
119 | |||
120 | func choose_route(): | ||
121 | var rng = RandomNumberGenerator.new() | ||
122 | rng.randomize() | ||
123 | |||
124 | var areas_slot | ||
125 | var level_name | ||
126 | if rng.randi_range(0, 2) == 0: | ||
127 | areas_slot = LL1_AREAS | ||
128 | level_name = "level1" | ||
129 | else: | ||
130 | areas_slot = LL2_AREAS | ||
131 | level_name = "level2" | ||
132 | |||
133 | var start_pos | ||
134 | var end_pos | ||
135 | var found = false | ||
136 | while !found: | ||
137 | var areas_dupe = areas_slot.duplicate() | ||
138 | var i = rng.randi_range(0, areas_dupe.size() - 1) | ||
139 | start_pos = areas_dupe[i] | ||
140 | areas_dupe.remove(i) | ||
141 | i = rng.randi_range(0, areas_dupe.size() - 1) | ||
142 | end_pos = areas_dupe[i] | ||
143 | |||
144 | var start_vec = Vector3(start_pos[1], start_pos[2], start_pos[3]) | ||
145 | var end_vec = Vector3(end_pos[1], end_pos[2], end_pos[3]) | ||
146 | if start_vec.distance_to(end_vec) > 50 and not (start_pos.size() >= 5 and start_pos[4]): | ||
147 | found = true | ||
148 | |||
149 | return [level_name, start_pos, end_pos] | ||