diff options
Diffstat (limited to 'Archipelago/client.gd')
-rw-r--r-- | Archipelago/client.gd | 182 |
1 files changed, 117 insertions, 65 deletions
diff --git a/Archipelago/client.gd b/Archipelago/client.gd index a3b503a..bc952b9 100644 --- a/Archipelago/client.gd +++ b/Archipelago/client.gd | |||
@@ -7,6 +7,7 @@ var SCRIPT_multiplayer | |||
7 | var SCRIPT_mypainting | 7 | var SCRIPT_mypainting |
8 | var SCRIPT_notifier | 8 | var SCRIPT_notifier |
9 | var SCRIPT_panel | 9 | var SCRIPT_panel |
10 | var SCRIPT_pilgrimage_terminator | ||
10 | var SCRIPT_uuid | 11 | var SCRIPT_uuid |
11 | 12 | ||
12 | var ap_server = "" | 13 | var ap_server = "" |
@@ -15,60 +16,30 @@ var ap_pass = "" | |||
15 | var confusify_world = false | 16 | var confusify_world = false |
16 | var enable_multiplayer = false | 17 | var enable_multiplayer = false |
17 | var track_player = false | 18 | var track_player = false |
19 | var connection_history = [] | ||
18 | 20 | ||
19 | const my_version = "2.1.0" | 21 | const my_version = "3.0.1" |
20 | const ap_version = {"major": 0, "minor": 4, "build": 5, "class": "Version"} | 22 | const ap_version = {"major": 0, "minor": 4, "build": 6, "class": "Version"} |
21 | const color_items = [ | 23 | const color_items = [ |
22 | "White", "Black", "Red", "Blue", "Green", "Brown", "Gray", "Orange", "Purple", "Yellow" | 24 | "White", "Black", "Red", "Blue", "Green", "Brown", "Gray", "Orange", "Purple", "Yellow" |
23 | ] | 25 | ] |
24 | const progressive_items = { | 26 | const progressive_items = { |
25 | "Progressive Orange Tower": | 27 | "Progressive Orange Tower": |
26 | [ | 28 | ["Second Floor", "Third Floor", "Fourth Floor", "Fifth Floor", "Sixth Floor", "Seventh Floor"], |
27 | {"item": "Orange Tower - Second Floor", "display": "Second Floor"}, | ||
28 | {"item": "Orange Tower - Third Floor", "display": "Third Floor"}, | ||
29 | {"item": "Orange Tower - Fourth Floor", "display": "Fourth Floor"}, | ||
30 | {"item": "Orange Tower - Fifth Floor", "display": "Fifth Floor"}, | ||
31 | {"item": "Orange Tower - Sixth Floor", "display": "Sixth Floor"}, | ||
32 | {"item": "Orange Tower - Seventh Floor", "display": "Seventh Floor"}, | ||
33 | ], | ||
34 | "Progressive Art Gallery": | 29 | "Progressive Art Gallery": |
35 | [ | 30 | ["Second Floor", "Third Floor", "Fourth Floor", "Fifth Floor", "Exit"], |
36 | {"item": "Art Gallery - Second Floor", "display": "Second Floor"}, | 31 | "Progressive Hallway Room": ["First Door", "Second Door", "Third Door", "Fourth Door"], |
37 | {"item": "Art Gallery - Third Floor", "display": "Third Floor"}, | 32 | "Progressive Fearless": ["Second Floor", "Third Floor"], |
38 | {"item": "Art Gallery - Fourth Floor", "display": "Fourth Floor"}, | ||
39 | {"item": "Art Gallery - Fifth Floor", "display": "Fifth Floor"}, | ||
40 | {"item": "Art Gallery - Exit", "display": "Exit"}, | ||
41 | ], | ||
42 | "Progressive Hallway Room": | ||
43 | [ | ||
44 | {"item": "Outside The Agreeable - Hallway Door", "display": "First Door"}, | ||
45 | {"item": "Hallway Room (2) - Exit", "display": "Second Door"}, | ||
46 | {"item": "Hallway Room (3) - Exit", "display": "Third Door"}, | ||
47 | {"item": "Hallway Room (4) - Exit", "display": "Fourth Door"}, | ||
48 | ], | ||
49 | "Progressive Fearless": | ||
50 | [ | ||
51 | {"item": "The Fearless (First Floor) - Second Floor", "display": "Second Floor"}, | ||
52 | {"item": "The Fearless (Second Floor) - Third Floor", "display": "Third Floor"}, | ||
53 | ], | ||
54 | "Progressive Colorful": | 33 | "Progressive Colorful": |
55 | [ | 34 | ["White", "Black", "Red", "Yellow", "Blue", "Purple", "Orange", "Green", "Brown", "Gray"], |
56 | {"item": "The Colorful - White Door", "display": "White"}, | 35 | "Progressive Pilgrimage": |
57 | {"item": "The Colorful - Black Door", "display": "Black"}, | 36 | ["1 Sunwarp", "2 Sunwarp", "3 Sunwarp", "4 Sunwarp", "5 Sunwarp", "6 Sunwarp"] |
58 | {"item": "The Colorful - Red Door", "display": "Red"}, | ||
59 | {"item": "The Colorful - Yellow Door", "display": "Yellow"}, | ||
60 | {"item": "The Colorful - Blue Door", "display": "Blue"}, | ||
61 | {"item": "The Colorful - Purple Door", "display": "Purple"}, | ||
62 | {"item": "The Colorful - Orange Door", "display": "Orange"}, | ||
63 | {"item": "The Colorful - Green Door", "display": "Green"}, | ||
64 | {"item": "The Colorful - Brown Door", "display": "Brown"}, | ||
65 | {"item": "The Colorful - Gray Door", "display": "Gray"}, | ||
66 | ] | ||
67 | } | 37 | } |
68 | 38 | ||
69 | const kTHE_END = 0 | 39 | const kTHE_END = 0 |
70 | const kTHE_MASTER = 1 | 40 | const kTHE_MASTER = 1 |
71 | const kLEVEL_2 = 2 | 41 | const kLEVEL_2 = 2 |
42 | const kPILGRIMAGE = 3 | ||
72 | 43 | ||
73 | const kNO_PANEL_SHUFFLE = 0 | 44 | const kNO_PANEL_SHUFFLE = 0 |
74 | const kREARRANGE_PANELS = 1 | 45 | const kREARRANGE_PANELS = 1 |
@@ -81,6 +52,12 @@ const kCLASSIFICATION_REMOTE_NORMAL = 0 | |||
81 | const kCLASSIFICATION_REMOTE_REDUCED = 1 | 52 | const kCLASSIFICATION_REMOTE_REDUCED = 1 |
82 | const kCLASSIFICATION_REMOTE_INSANITY = 2 | 53 | const kCLASSIFICATION_REMOTE_INSANITY = 2 |
83 | 54 | ||
55 | const kSUNWARP_ACCESS_NORMAL = 0 | ||
56 | const kSUNWARP_ACCESS_DISABLED = 1 | ||
57 | const kSUNWARP_ACCESS_UNLOCK = 2 | ||
58 | const kSUNWARP_ACCESS_INDIVIDUAL = 3 | ||
59 | const kSUNWARP_ACCESS_PROGRESSIVE = 4 | ||
60 | |||
84 | var _client = WebSocketClient.new() | 61 | var _client = WebSocketClient.new() |
85 | var _should_process = false | 62 | var _should_process = false |
86 | var _initiated_disconnect = false | 63 | var _initiated_disconnect = false |
@@ -94,6 +71,7 @@ var _item_name_to_id = {} # LINGO only | |||
94 | var _location_name_to_id = {} # LINGO only | 71 | var _location_name_to_id = {} # LINGO only |
95 | 72 | ||
96 | var _remote_version = {"major": 0, "minor": 0, "build": 0} | 73 | var _remote_version = {"major": 0, "minor": 0, "build": 0} |
74 | var _gen_version = {"major": 0, "minor": 0, "build": 0} | ||
97 | 75 | ||
98 | # TODO: caching per MW/slot, reset between connections | 76 | # TODO: caching per MW/slot, reset between connections |
99 | var _authenticated = false | 77 | var _authenticated = false |
@@ -102,6 +80,7 @@ var _team = 0 | |||
102 | var _slot = 0 | 80 | var _slot = 0 |
103 | var _players = [] | 81 | var _players = [] |
104 | var _player_name_by_slot = {} | 82 | var _player_name_by_slot = {} |
83 | var _game_by_player = {} | ||
105 | var _checked_locations = [] | 84 | var _checked_locations = [] |
106 | var _slot_data = {} | 85 | var _slot_data = {} |
107 | var _paintings_mapping = {} | 86 | var _paintings_mapping = {} |
@@ -112,10 +91,17 @@ var _door_shuffle = false | |||
112 | var _color_shuffle = false | 91 | var _color_shuffle = false |
113 | var _panel_shuffle = 0 # none, rearrange | 92 | var _panel_shuffle = 0 # none, rearrange |
114 | var _painting_shuffle = false | 93 | var _painting_shuffle = false |
94 | var _sunwarp_access = 0 # normal, disabled, unlock, progressive | ||
115 | var _mastery_achievements = 21 | 95 | var _mastery_achievements = 21 |
116 | var _level_2_requirement = 223 | 96 | var _level_2_requirement = 223 |
117 | var _location_classification_bit = 0 | 97 | var _location_classification_bit = 0 |
118 | var _early_color_hallways = false | 98 | var _early_color_hallways = false |
99 | var _pilgrimage_compatibility = false # set to true for pre-0.4.6 | ||
100 | var _pilgrimage_enabled = false | ||
101 | var _pilgrimage_allows_roof_access = false | ||
102 | var _pilgrimage_allows_paintings = false | ||
103 | var _sunwarp_shuffle = false | ||
104 | var _sunwarp_mapping = [] | ||
119 | var _slot_seed = 0 | 105 | var _slot_seed = 0 |
120 | 106 | ||
121 | var _map_loaded = false | 107 | var _map_loaded = false |
@@ -147,6 +133,10 @@ func _init(): | |||
147 | var data = file.get_var(true) | 133 | var data = file.get_var(true) |
148 | file.close() | 134 | file.close() |
149 | 135 | ||
136 | if typeof(data) != TYPE_ARRAY: | ||
137 | global._print("AP settings file is corrupted") | ||
138 | data = [] | ||
139 | |||
150 | if data.size() > 0: | 140 | if data.size() > 0: |
151 | ap_server = data[0] | 141 | ap_server = data[0] |
152 | if data.size() > 1: | 142 | if data.size() > 1: |
@@ -161,6 +151,8 @@ func _init(): | |||
161 | enable_multiplayer = data[5] | 151 | enable_multiplayer = data[5] |
162 | if data.size() > 6: | 152 | if data.size() > 6: |
163 | track_player = data[6] | 153 | track_player = data[6] |
154 | if data.size() > 7: | ||
155 | connection_history = data[7] | ||
164 | 156 | ||
165 | processDatapackages() | 157 | processDatapackages() |
166 | 158 | ||
@@ -230,6 +222,7 @@ func _on_data(): | |||
230 | if cmd == "RoomInfo": | 222 | if cmd == "RoomInfo": |
231 | _seed = message["seed_name"] | 223 | _seed = message["seed_name"] |
232 | _remote_version = message["version"] | 224 | _remote_version = message["version"] |
225 | _gen_version = message["generator_version"] | ||
233 | 226 | ||
234 | var needed_games = [] | 227 | var needed_games = [] |
235 | for game in message["datapackage_checksums"].keys(): | 228 | for game in message["datapackage_checksums"].keys(): |
@@ -268,6 +261,7 @@ func _on_data(): | |||
268 | 261 | ||
269 | for player in _players: | 262 | for player in _players: |
270 | _player_name_by_slot[player["slot"]] = player["alias"] | 263 | _player_name_by_slot[player["slot"]] = player["alias"] |
264 | _game_by_player[player["slot"]] = message["slot_info"][str(player["slot"])]["game"] | ||
271 | 265 | ||
272 | _death_link = _slot_data.has("death_link") and _slot_data["death_link"] | 266 | _death_link = _slot_data.has("death_link") and _slot_data["death_link"] |
273 | if _death_link: | 267 | if _death_link: |
@@ -283,6 +277,10 @@ func _on_data(): | |||
283 | _painting_shuffle = _slot_data["shuffle_paintings"] | 277 | _painting_shuffle = _slot_data["shuffle_paintings"] |
284 | if _slot_data.has("shuffle_panels"): | 278 | if _slot_data.has("shuffle_panels"): |
285 | _panel_shuffle = _slot_data["shuffle_panels"] | 279 | _panel_shuffle = _slot_data["shuffle_panels"] |
280 | if _slot_data.has("sunwarp_access"): | ||
281 | _sunwarp_access = _slot_data["sunwarp_access"] | ||
282 | else: | ||
283 | _sunwarp_access = kSUNWARP_ACCESS_NORMAL | ||
286 | if _slot_data.has("seed"): | 284 | if _slot_data.has("seed"): |
287 | _slot_seed = _slot_data["seed"] | 285 | _slot_seed = _slot_data["seed"] |
288 | if _slot_data.has("painting_entrance_to_exit"): | 286 | if _slot_data.has("painting_entrance_to_exit"): |
@@ -300,6 +298,25 @@ func _on_data(): | |||
300 | _location_classification_bit = kCLASSIFICATION_LOCAL_INSANITY | 298 | _location_classification_bit = kCLASSIFICATION_LOCAL_INSANITY |
301 | if _slot_data.has("early_color_hallways"): | 299 | if _slot_data.has("early_color_hallways"): |
302 | _early_color_hallways = _slot_data["early_color_hallways"] | 300 | _early_color_hallways = _slot_data["early_color_hallways"] |
301 | if _slot_data.has("enable_pilgrimage"): | ||
302 | _pilgrimage_enabled = _slot_data["enable_pilgrimage"] | ||
303 | else: | ||
304 | _pilgrimage_compatibility = true | ||
305 | _pilgrimage_enabled = true | ||
306 | if _slot_data.has("pilgrimage_allows_roof_access"): | ||
307 | _pilgrimage_allows_roof_access = _slot_data["pilgrimage_allows_roof_access"] | ||
308 | else: | ||
309 | _pilgrimage_allows_roof_access = true | ||
310 | if _slot_data.has("pilgrimage_allows_paintings"): | ||
311 | _pilgrimage_allows_paintings = _slot_data["pilgrimage_allows_paintings"] | ||
312 | else: | ||
313 | _pilgrimage_allows_paintings = true | ||
314 | if _slot_data.has("shuffle_sunwarps"): | ||
315 | _sunwarp_shuffle = _slot_data["shuffle_sunwarps"] | ||
316 | else: | ||
317 | _sunwarp_shuffle = false | ||
318 | if _slot_data.has("sunwarp_permutation"): | ||
319 | _sunwarp_mapping = _slot_data["sunwarp_permutation"] | ||
303 | 320 | ||
304 | if track_player: | 321 | if track_player: |
305 | setValue("PlayerPos", {"x": 0, "z": 0}) | 322 | setValue("PlayerPos", {"x": 0, "z": 0}) |
@@ -315,6 +332,10 @@ func _on_data(): | |||
315 | var localdata = ap_file.get_var(true) | 332 | var localdata = ap_file.get_var(true) |
316 | ap_file.close() | 333 | ap_file.close() |
317 | 334 | ||
335 | if typeof(localdata) != TYPE_ARRAY: | ||
336 | global._print("AP localdata file is corrupted") | ||
337 | localdata = [] | ||
338 | |||
318 | if localdata.size() > 0: | 339 | if localdata.size() > 0: |
319 | _last_new_item = localdata[0] | 340 | _last_new_item = localdata[0] |
320 | else: | 341 | else: |
@@ -412,12 +433,14 @@ func _on_data(): | |||
412 | continue | 433 | continue |
413 | 434 | ||
414 | var item_name = "Unknown" | 435 | var item_name = "Unknown" |
415 | if _item_id_to_name.has(message["item"]["item"]): | 436 | var item_player_game = _game_by_player[message["receiving"]] |
416 | item_name = _item_id_to_name[message["item"]["item"]] | 437 | if _item_id_to_name[item_player_game].has(message["item"]["item"]): |
438 | item_name = _item_id_to_name[item_player_game][message["item"]["item"]] | ||
417 | 439 | ||
418 | var location_name = "Unknown" | 440 | var location_name = "Unknown" |
419 | if _location_id_to_name.has(message["item"]["location"]): | 441 | var location_player_game = _game_by_player[message["item"]["player"]] |
420 | location_name = _location_id_to_name[message["item"]["location"]] | 442 | if _location_id_to_name[location_player_game].has(message["item"]["location"]): |
443 | location_name = _location_id_to_name[location_player_game][message["item"]["location"]] | ||
421 | 444 | ||
422 | var player_name = "Unknown" | 445 | var player_name = "Unknown" |
423 | if _player_name_by_slot.has(message["receiving"]): | 446 | if _player_name_by_slot.has(message["receiving"]): |
@@ -485,7 +508,8 @@ func saveSettings(): | |||
485 | _datapackages, | 508 | _datapackages, |
486 | confusify_world, | 509 | confusify_world, |
487 | enable_multiplayer, | 510 | enable_multiplayer, |
488 | track_player | 511 | track_player, |
512 | connection_history | ||
489 | ] | 513 | ] |
490 | file.store_var(data, true) | 514 | file.store_var(data, true) |
491 | file.close() | 515 | file.close() |
@@ -566,12 +590,16 @@ func requestDatapackages(games): | |||
566 | func processDatapackages(): | 590 | func processDatapackages(): |
567 | _item_id_to_name = {} | 591 | _item_id_to_name = {} |
568 | _location_id_to_name = {} | 592 | _location_id_to_name = {} |
569 | for package in _datapackages.values(): | 593 | for game in _datapackages.keys(): |
594 | var package = _datapackages[game] | ||
595 | |||
596 | _item_id_to_name[game] = {} | ||
570 | for name in package["item_name_to_id"].keys(): | 597 | for name in package["item_name_to_id"].keys(): |
571 | _item_id_to_name[package["item_name_to_id"][name]] = name | 598 | _item_id_to_name[game][package["item_name_to_id"][name]] = name |
572 | 599 | ||
600 | _location_id_to_name[game] = {} | ||
573 | for name in package["location_name_to_id"].keys(): | 601 | for name in package["location_name_to_id"].keys(): |
574 | _location_id_to_name[package["location_name_to_id"][name]] = name | 602 | _location_id_to_name[game][package["location_name_to_id"][name]] = name |
575 | 603 | ||
576 | if _datapackages.has("Lingo"): | 604 | if _datapackages.has("Lingo"): |
577 | _item_name_to_id = _datapackages["Lingo"]["item_name_to_id"] | 605 | _item_name_to_id = _datapackages["Lingo"]["item_name_to_id"] |
@@ -660,8 +688,8 @@ func processItem(item, index, from, flags): | |||
660 | 688 | ||
661 | var gamedata = $Gamedata | 689 | var gamedata = $Gamedata |
662 | var item_name = "Unknown" | 690 | var item_name = "Unknown" |
663 | if _item_id_to_name.has(item): | 691 | if _item_id_to_name["Lingo"].has(item): |
664 | item_name = _item_id_to_name[item] | 692 | item_name = _item_id_to_name["Lingo"][item] |
665 | 693 | ||
666 | if gamedata.door_ids_by_item_id.has(int(item)): | 694 | if gamedata.door_ids_by_item_id.has(int(item)): |
667 | var doorsNode = get_tree().get_root().get_node("Spatial/Doors") | 695 | var doorsNode = get_tree().get_root().get_node("Spatial/Doors") |
@@ -682,19 +710,25 @@ func processItem(item, index, from, flags): | |||
682 | if painting_node != null: | 710 | if painting_node != null: |
683 | painting_node.get_node("Script").movePainting() | 711 | painting_node.get_node("Script").movePainting() |
684 | 712 | ||
713 | if gamedata.warp_ids_by_item_id.has(int(item)): | ||
714 | var warpsNode = get_tree().get_root().get_node("Spatial/Warps") | ||
715 | for warp_id in gamedata.warp_ids_by_item_id[int(item)]: | ||
716 | warpsNode.get_node(warp_id).unlock_warp() | ||
717 | |||
685 | # Handle progressive items. | 718 | # Handle progressive items. |
686 | if item_name in progressive_items.keys(): | 719 | if int(item) in gamedata.items_by_progressive_id.keys(): |
687 | if not item_name in _progressive_progress: | 720 | if not int(item) in _progressive_progress: |
688 | _progressive_progress[item_name] = 0 | 721 | _progressive_progress[int(item)] = 0 |
689 | 722 | ||
690 | if _progressive_progress[item_name] < progressive_items[item_name].size(): | 723 | if _progressive_progress[int(item)] < gamedata.items_by_progressive_id[int(item)].size(): |
691 | var subitem_name = progressive_items[item_name][_progressive_progress[item_name]]["item"] | 724 | var subitems = gamedata.items_by_progressive_id[int(item)] |
692 | global._print(subitem_name) | 725 | var subitem_id = subitems[_progressive_progress[int(item)]] |
693 | processItem(_item_name_to_id[subitem_name], null, null, null) | 726 | global._print("Subitem: %d" % subitem_id) |
694 | _progressive_progress[item_name] += 1 | 727 | processItem(subitem_id, null, null, null) |
695 | 728 | _progressive_progress[int(item)] += 1 | |
696 | if _color_shuffle and color_items.has(_item_id_to_name[item]): | 729 | |
697 | var lcol = _item_id_to_name[item].to_lower() | 730 | if _color_shuffle and color_items.has(_item_id_to_name["Lingo"][item]): |
731 | var lcol = _item_id_to_name["Lingo"][item].to_lower() | ||
698 | if not _has_colors.has(lcol): | 732 | if not _has_colors.has(lcol): |
699 | _has_colors.append(lcol) | 733 | _has_colors.append(lcol) |
700 | emit_signal("evaluate_solvability") | 734 | emit_signal("evaluate_solvability") |
@@ -705,8 +739,8 @@ func processItem(item, index, from, flags): | |||
705 | saveLocaldata() | 739 | saveLocaldata() |
706 | 740 | ||
707 | if item_name in progressive_items: | 741 | if item_name in progressive_items: |
708 | var subitem = progressive_items[item_name][_progressive_progress[item_name] - 1] | 742 | var subitem = progressive_items[item_name][_progressive_progress[int(item)] - 1] |
709 | item_name += " (%s)" % subitem["display"] | 743 | item_name += " (%s)" % subitem |
710 | 744 | ||
711 | var player_name = "Unknown" | 745 | var player_name = "Unknown" |
712 | if _player_name_by_slot.has(from): | 746 | if _player_name_by_slot.has(from): |
@@ -742,6 +776,10 @@ func paintingIsVanilla(painting): | |||
742 | return !$Gamedata.mentioned_paintings.has(painting) | 776 | return !$Gamedata.mentioned_paintings.has(painting) |
743 | 777 | ||
744 | 778 | ||
779 | func warpIsVanilla(warp): | ||
780 | return !$Gamedata.mentioned_warps.has(warp) | ||
781 | |||
782 | |||
745 | func evaluateSolvability(): | 783 | func evaluateSolvability(): |
746 | emit_signal("evaluate_solvability") | 784 | emit_signal("evaluate_solvability") |
747 | 785 | ||
@@ -775,3 +813,17 @@ func colorForItemType(flags): | |||
775 | return "#d63a22" | 813 | return "#d63a22" |
776 | else: # filler | 814 | else: # filler |
777 | return "#14de9e" | 815 | return "#14de9e" |
816 | |||
817 | |||
818 | func compareVersion(lhs, rhs): | ||
819 | if lhs["major"] == rhs["major"]: | ||
820 | if lhs["minor"] == rhs["minor"]: | ||
821 | return lhs["build"] < rhs["build"] | ||
822 | else: | ||
823 | return lhs["minor"] < rhs["minor"] | ||
824 | else: | ||
825 | return lhs["major"] < rhs["major"] | ||
826 | |||
827 | |||
828 | func wasGeneratedBeforeVersion(major, minor, build): | ||
829 | return compareVersion(_gen_version, {"major": major, "minor": minor, "build": build}) | ||