From 17d2b39d0dd2d94065fbe848e0dbf85e4a80ca66 Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Wed, 15 May 2024 12:12:24 -0400 Subject: Send checked paintings to server --- Archipelago/client.gd | 31 ++++++++++++- Archipelago/mypainting.gd | 113 +++++++++++++++++++++++----------------------- 2 files changed, 85 insertions(+), 59 deletions(-) (limited to 'Archipelago') diff --git a/Archipelago/client.gd b/Archipelago/client.gd index 7903df2..0625c82 100644 --- a/Archipelago/client.gd +++ b/Archipelago/client.gd @@ -115,6 +115,7 @@ var _cached_slowness = 0 var _cached_iceland = 0 var _cached_atbash = 0 var _geronimo_skip = false +var _checked_paintings = [] signal could_not_connect signal connect_status @@ -356,6 +357,18 @@ func _on_data(): requestSync() + sendMessage( + [ + { + "cmd": "Set", + "key": "Lingo_%d_Paintings" % [_slot], + "default": [], + "want_reply": true, + "operations": [{"operation": "default", "value": []}] + } + ] + ) + emit_signal("client_connected") elif cmd == "ConnectionRefused": @@ -471,6 +484,10 @@ func _on_data(): # Return the player home. get_tree().get_root().get_node("Spatial/player/pause_menu")._reload() + elif cmd == "SetReply": + if message.has("key") and message["key"] == ("Lingo_%d_Paintings" % _slot): + _checked_paintings = message["value"] + func _process(_delta): if _should_process: @@ -625,13 +642,14 @@ func sendLocation(loc_id): _held_locations.append(loc_id) -func setValue(key, value): +func setValue(key, value, operation = "replace"): sendMessage( [ { "cmd": "Set", "key": "Lingo_%d_%s" % [_slot, key], - "operations": [{"operation": "replace", "value": value}] + "want_reply": false, + "operations": [{"operation": operation, "value": value}] } ] ) @@ -787,6 +805,15 @@ func geronimo(): saveLocaldata() +func checkPainting(painting_id): + if _checked_paintings.has(painting_id): + return + + _checked_paintings.append(painting_id) + + setValue("Paintings", [painting_id], "add") + + func colorForItemType(flags): var int_flags = int(flags) if int_flags & 1: # progression diff --git a/Archipelago/mypainting.gd b/Archipelago/mypainting.gd index 999b122..7aee434 100644 --- a/Archipelago/mypainting.gd +++ b/Archipelago/mypainting.gd @@ -30,66 +30,65 @@ func movePainting(): func _looked_at(body, painting): - if ( - target != null - and body.is_in_group("player") - and (painting.get_name() == self.get_parent().get_name()) - ): - var target_dir = _dir_to_int(target.orientation) - var source_dir = _dir_to_int(orientation) - var rotate = target_dir - source_dir - if rotate < 0: - rotate += 4 - rotate *= 90 + if body.is_in_group("player") and (painting.get_name() == self.get_parent().get_name()): + var apclient = global.get_node("Archipelago") + apclient.checkPainting(painting.get_name()) - var target_painting = target.get_parent() + if target != null: + var target_dir = _dir_to_int(target.orientation) + var source_dir = _dir_to_int(orientation) + var rotate = target_dir - source_dir + if rotate < 0: + rotate += 4 + rotate *= 90 - # this is ACW - if rotate == 0: - body.translation.x = ( - target_painting.translation.x + (body.translation.x - painting.translation.x) - ) - body.translation.y = ( - target_painting.translation.y + (body.translation.y - painting.translation.y) - ) - body.translation.z = ( - target_painting.translation.z + (body.translation.z - painting.translation.z) - ) - elif rotate == 180: - body.translation.x = ( - target_painting.translation.x - (body.translation.x - painting.translation.x) - ) - body.translation.y = ( - target_painting.translation.y + (body.translation.y - painting.translation.y) - ) - body.translation.z = ( - target_painting.translation.z - (body.translation.z - painting.translation.z) - ) - body.rotate_y(PI) - body.velocity = body.velocity.rotated(Vector3(0, 1, 0), PI) - elif rotate == 90: - var diff_x = body.translation.x - painting.translation.x - var diff_y = body.translation.y - painting.translation.y - var diff_z = body.translation.z - painting.translation.z - body.translation.x = target_painting.translation.x + diff_z - body.translation.y = target_painting.translation.y + diff_y - body.translation.z = target_painting.translation.z - diff_x - body.rotate_y(PI / 2) - body.velocity = body.velocity.rotated(Vector3(0, 1, 0), PI / 2) - elif rotate == 270: - var diff_x = body.translation.x - painting.translation.x - var diff_y = body.translation.y - painting.translation.y - var diff_z = body.translation.z - painting.translation.z - body.translation.x = target_painting.translation.x - diff_z - body.translation.y = target_painting.translation.y + diff_y - body.translation.z = target_painting.translation.z + diff_x - body.rotate_y(3 * PI / 2) - body.velocity = body.velocity.rotated(Vector3(0, 1, 0), 3 * PI / 2) + var target_painting = target.get_parent() - var apclient = global.get_node("Archipelago") - if !apclient._pilgrimage_allows_paintings: - global.sunwarp = 1 - body.get_node("pivot/camera/sunwarp_background").visible = false + # this is ACW + if rotate == 0: + body.translation.x = ( + target_painting.translation.x + (body.translation.x - painting.translation.x) + ) + body.translation.y = ( + target_painting.translation.y + (body.translation.y - painting.translation.y) + ) + body.translation.z = ( + target_painting.translation.z + (body.translation.z - painting.translation.z) + ) + elif rotate == 180: + body.translation.x = ( + target_painting.translation.x - (body.translation.x - painting.translation.x) + ) + body.translation.y = ( + target_painting.translation.y + (body.translation.y - painting.translation.y) + ) + body.translation.z = ( + target_painting.translation.z - (body.translation.z - painting.translation.z) + ) + body.rotate_y(PI) + body.velocity = body.velocity.rotated(Vector3(0, 1, 0), PI) + elif rotate == 90: + var diff_x = body.translation.x - painting.translation.x + var diff_y = body.translation.y - painting.translation.y + var diff_z = body.translation.z - painting.translation.z + body.translation.x = target_painting.translation.x + diff_z + body.translation.y = target_painting.translation.y + diff_y + body.translation.z = target_painting.translation.z - diff_x + body.rotate_y(PI / 2) + body.velocity = body.velocity.rotated(Vector3(0, 1, 0), PI / 2) + elif rotate == 270: + var diff_x = body.translation.x - painting.translation.x + var diff_y = body.translation.y - painting.translation.y + var diff_z = body.translation.z - painting.translation.z + body.translation.x = target_painting.translation.x - diff_z + body.translation.y = target_painting.translation.y + diff_y + body.translation.z = target_painting.translation.z + diff_x + body.rotate_y(3 * PI / 2) + body.velocity = body.velocity.rotated(Vector3(0, 1, 0), 3 * PI / 2) + + if !apclient._pilgrimage_allows_paintings: + global.sunwarp = 1 + body.get_node("pivot/camera/sunwarp_background").visible = false func _dir_to_int(dir): -- cgit 1.4.1