From 12c696bc5b6e960a1d9228a5b68e5aafcc02e23c Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Fri, 9 Feb 2024 11:24:39 -0500 Subject: LL2 support --- racing/lobby.gd | 85 +++++-------------------------- racing/manager.gd | 1 + racing/router.gd | 149 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 162 insertions(+), 73 deletions(-) create mode 100644 racing/router.gd 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 var members_to_join = [] var is_starting = false +var router + const MAX_PLAYERS = 250 const PROTOCOL_VERSION = 2 const RECIPIENT_BROADCAST_ALL = -1 const LOBBY_MAP_NAME = "ll1_racing" const VERSION = "0.0.7" -const LL1_AREAS = [ - ["Starting Room", 0, 0, 0], - ["Second Room", 0, 0, -15], - ["The Traveled", 34, 0, -18], - ["The Agreeable", 30, 0, -45], - ["The Colorful", 10, 0, -83], - ["Suits Area", 0, 0, -78, true], - ["Arrow Garden", -93, 1, -93], - ["The Wondrous (Table)", -108, 1, -78], - ["Courtyard", -64, 0, -71], - ["Yellow Backside Nine", -38, 0, -58], - ["Hot Crusts Area", -20, 0, -81], - ["Crossroads Corner", -28, 0, -54], - ["The Discerning", -54, 0, -34, true], - ["Green Backside", 22, 0, -94], - ["Observant Upstairs", 40, 9, -92, true], - ["Eight Room", 95, 15, -28], - ["The Perceptive", 60, 9, -57], - ["The Tenacious", 0, 0, -43], - ["Rainbow", -96, 0, -41], - ["The Undeterred", -87, 0, 25, true], - ["Directional Gallery", -57, 0, 0], - ["The Eyes They See", -54, 0, -23], - ["Tower First Floor", -27, 0, -23], - ["The Optimistic", 76, 0, -17], - ["The Initiated", 63, 0, -0, true], - ["Art Gallery", 92, 0, 15], - ["Art Gallery Top", 80, 30, 15], - ["Lookout", 75, 18, 51], - ["Knight Night Room", 37, 0, 7], - ["The Seeker", 9, 0, 16, true], - ["Hidden Room", 13, 0, 4], - ["Owl Hallway", 44, 0, -26], - ["Challenge Room", -9, 6, 13], - ["Pilgrim Room", -22, 0, 24, true], - ["Cellar Replica", -44, 0, 30], - ["Elements Area", -61, 0, 40], - ["The Artistic", -25, 0, 54, true], - ["Outside The Wise", -44, 0, 71], - ["The Wise", -72, 0, 72, true], - ["The Scientific", -18, 0, 89], - ["The Wanderer", 0, 0, 80], - ["The Fearless", 18, 10, 90], - ["Champion's Rest", 23, 0, 62, true], - ["The Steady", 31, 0, 77, true], - ["The Bold", 67, 0, 77, true], - ["Color Hunt", 45, 0, 69], - ["Room Room", 95, 6, 84], - ["The Bearer", 61, 0, 51], - ["Tower Third Floor", 18, 0, 33], - ["Rhyme Room (Cross)", 0, 9, 42], - ["Tower Seventh Floor", 0, 37, 64], -] - func _ready(): global._print("Starting Lobby") @@ -100,6 +48,9 @@ func _ready(): var race_manager = global.get_node("RaceManager") race_manager.held_messages.clear() + var router_script = load("user://maps/racing/router.gd") + router = router_script.new() + var _ignore = get_node("Panel/main_button").connect("pressed", self, "_main_button_pressed") _ignore = get_node("Panel/return_button").connect("pressed", self, "_return_button_pressed") @@ -295,6 +246,7 @@ func _read_p2p_packet() -> void: false ) if "start_x" in data: + race_manager.level = data["level"] race_manager.start_pos = [ data["start_name"], int(data["start_x"]), @@ -352,30 +304,16 @@ func _main_button_pressed(): if everyone_ready and is_vip: get_node("Panel/main_button").disabled = true - var rng = RandomNumberGenerator.new() - rng.randomize() - - var start_pos - var end_pos - var found = false - while !found: - var areas_dupe = LL1_AREAS.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[1], start_pos[2], start_pos[3]) - var end_vec = Vector3(end_pos[1], end_pos[2], end_pos[3]) - if start_vec.distance_to(end_vec) > 50 and not (start_pos.size() >= 5 and start_pos[4]): - found = true + var route = router.choose_route() + var start_pos = route[1] + var end_pos = route[2] members_to_join = active_lobby_members.duplicate() members_to_join.erase(player_steam_id) is_starting = true var race_manager = global.get_node("RaceManager") + race_manager.level = route[0] race_manager.start_pos = start_pos race_manager.end_pos = end_pos @@ -384,6 +322,7 @@ func _main_button_pressed(): else: _send_p2p_packet( { + "level": route[0], "start_name": start_pos[0], "start_x": str(start_pos[1]), "start_y": str(start_pos[2]), @@ -416,7 +355,7 @@ func _start_game(): # Switch to LL1 Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED) - global.map = "level1" + global.map = race_manager.level global.entry_point = Vector3( race_manager.start_pos[1], race_manager.start_pos[2] + 1, race_manager.start_pos[3] ) 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 var SCRIPT_multiplayer +var level var start_pos var end_pos 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 @@ +extends Node + +const LL1_AREAS = [ + ["Starting Room", 0, 0, 0], + ["Second Room", 0, 0, -15], + ["The Traveled", 34, 0, -18], + ["The Agreeable", 30, 0, -45], + ["The Colorful", 10, 0, -83], + ["Suits Area", 0, 0, -78, true], + ["Arrow Garden", -93, 1, -93], + ["The Wondrous (Table)", -108, 1, -78], + ["Courtyard", -64, 0, -71], + ["Yellow Backside Nine", -38, 0, -58], + ["Hot Crusts Area", -20, 0, -81], + ["Crossroads Corner", -28, 0, -54], + ["The Discerning", -54, 0, -34, true], + ["Green Backside", 22, 0, -94], + ["Observant Upstairs", 40, 9, -92, true], + ["Eight Room", 95, 15, -28], + ["The Perceptive", 60, 9, -57], + ["The Tenacious", 0, 0, -43], + ["Rainbow", -96, 0, -41], + ["The Undeterred", -87, 0, 25, true], + ["Directional Gallery", -57, 0, 0], + ["The Eyes They See", -54, 0, -23], + ["Tower First Floor", -27, 0, -23], + ["The Optimistic", 76, 0, -17], + ["The Initiated", 63, 0, -0, true], + ["Art Gallery", 92, 0, 15], + ["Art Gallery Top", 80, 30, 15], + ["Lookout", 75, 18, 51], + ["Knight Night Room", 37, 0, 7], + ["The Seeker", 9, 0, 16, true], + ["Hidden Room", 13, 0, 4], + ["Owl Hallway", 44, 0, -26], + ["Challenge Room", -9, 6, 13], + ["Pilgrim Room", -22, 0, 24, true], + ["Cellar Replica", -44, 0, 30], + ["Elements Area", -61, 0, 40], + ["The Artistic", -25, 0, 54, true], + ["Outside The Wise", -44, 0, 71], + ["The Wise", -72, 0, 72, true], + ["The Scientific", -18, 0, 89], + ["The Wanderer", 0, 0, 80], + ["The Fearless", 18, 10, 90], + ["Champion's Rest", 23, 0, 62, true], + ["The Steady", 31, 0, 77, true], + ["The Bold", 67, 0, 77, true], + ["Color Hunt", 45, 0, 69], + ["Room Room", 95, 6, 84], + ["The Bearer", 61, 0, 51], + ["Tower Third Floor", 18, 0, 33], + ["Rhyme Room (Cross)", 0, 9, 42], + ["Tower Seventh Floor", 0, 37, 64], +] + +const LL2_AREAS = [ + ["Orange Pyramid", 86, 10, -84, true], + ["The Stellar", 43, 6, -86], + ["The Fuzzy", 12, 1, -86, true], + ["The Devious", 0, 0, -88], + ["The Sharp", -26, 0, -88, true], + ["The Structured", -50, 0, -88], + ["Brown Pyramid", -86, 10, -85, true], + ["The Tasty", -86, 7, -62], + ["Black White Room", -88, 0, -32], + ["Lime Magenta Room", -96, 0, -24], + ["Red Blue Room", -87, 0, -23], + ["The Archaeologist", -74, 0, -32], + ["The Earnest", -87, 0, -56], + ["The Hidden", -50, 6, -71, true], + ["The Sapient", -36, 36, -41], + ["The Ethereal", -42, 0, -22], + ["The Learned", 34, 1, -64, true], + ["Whispers Behind Quiet Walls", 44, 0, -51, true], + ["The Lunar", 45, 0, -22], + ["The Arcadian", 86, 0, -53], + ["The Frozen", 84, 0, -27], + ["The Unscrambled", -50, 0, -10], + ["Nightmare", 73, 0, -27, true], + ["The Amazing", -13, 0, -42], + ["Challenge Room", -94, 0, 2], + ["The Fresh", -82, 0, -10], + ["The Exemplary", -82, 0, 11], + ["The Roaming", -66, 0, -11], + ["The Veteran", -66, 0, 12], + ["The Royal", -50, 0, 10], + ["The Exact", -33, 0, -12], + ["The Appreciated", -33, 0, 11], + ["The Unsullied", -17, 0, -11], + ["The Unopposed", -18, 0, 10], + ["The Multitalented", -10, 0, 0], + ["Starting Room", 0, 0, 0], + ["Control Room", 0, 0, 14], + ["Countdown Room", 0, 0, 33, true], + ["The Lucky", 13, 1, 32, true], + ["Greenhouse", 14, 0, 6], + ["The Sweet", 24, 0, 18, true], + ["The Fall", 87, 0, -4, true], + ["White Pyramid", 46, 0, -1], + ["Z", 95, 0, 25, true], + ["The Worldly", 92, 0, 58], + ["The Perennial", 39, 0, 32], + ["The Analytical", -28, 0, 35], + ["Car Room", -59, 0, 50, true], + ["The Mythical", -35, 4, 73], + ["LL1 Starting Room", -70, 0, 41], + ["LL1 Second Room", -86, 0, 41], + ["The Seen", -83, 0, 57, true], + ["Purple Pyramid", -87, 10, 85, true], + ["Four Pips", -66, 0, 76], + ["Twinkle Twinkle Little Star", 6, 0, 55, true], + ["The Unforgettable", 9, 40, 88], + ["HI Room", 27, 0, 59], + ["The Handy", 39, 10, 83], + ["Mint Pyramid", 86, 10, 83, true], +] + + +func choose_route(): + var rng = RandomNumberGenerator.new() + rng.randomize() + + var areas_slot + var level_name + if rng.randi_range(0, 2) == 0: + areas_slot = LL1_AREAS + level_name = "level1" + else: + areas_slot = LL2_AREAS + level_name = "level2" + + 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[1], start_pos[2], start_pos[3]) + var end_vec = Vector3(end_pos[1], end_pos[2], end_pos[3]) + if start_vec.distance_to(end_vec) > 50 and not (start_pos.size() >= 5 and start_pos[4]): + found = true + + return [level_name, start_pos, end_pos] -- cgit 1.4.1