From 6a9ff88b6c07a7f7d236da008f8a328418c49571 Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Sat, 25 May 2024 15:00:56 -0400 Subject: Trade items, trade locations, windmill, some AP bugs --- AnodyneArchipelago/ArchipelagoManager.cs | 12 +++- AnodyneArchipelago/Patches/GameplayPatches.cs | 96 +++++++++++++++++++++++++++ 2 files changed, 107 insertions(+), 1 deletion(-) (limited to 'AnodyneArchipelago') diff --git a/AnodyneArchipelago/ArchipelagoManager.cs b/AnodyneArchipelago/ArchipelagoManager.cs index 7c67114..4570c39 100644 --- a/AnodyneArchipelago/ArchipelagoManager.cs +++ b/AnodyneArchipelago/ArchipelagoManager.cs @@ -107,6 +107,8 @@ namespace AnodyneArchipelago NetworkItem item = _session.Items.AllItemsReceived[i]; _itemsToCollect.Enqueue(item); } + + _itemIndex = _session.Items.AllItemsReceived.Count; } if (_itemsToCollect.Count > 0 && (GlobalState.Dialogue == null || GlobalState.Dialogue == "") && !GlobalState.ScreenTransition && Plugin.Player != null && GlobalState.black_overlay.alpha == 0f) @@ -132,7 +134,7 @@ namespace AnodyneArchipelago private void HandleItem(NetworkItem item) { - if (item.Player == _session.ConnectionInfo.Slot) + if (item.Player == _session.ConnectionInfo.Slot && item.Location >= 0) { string itemKey = $"ArchipelagoLocation-{item.Location}"; if (GlobalState.events.GetEvent(itemKey) > 0) @@ -213,6 +215,14 @@ namespace AnodyneArchipelago cardTreasure.GetTreasure(); GlobalState.SpawnEntity(cardTreasure); } + else if (itemName == "Cardboard Box") + { + GlobalState.events.SetEvent("ReceivedCardboardBox", 1); + } + else if (itemName == "Biking Shoes") + { + GlobalState.events.SetEvent("ReceivedBikingShoes", 1); + } string message; if (item.Player == _session.ConnectionInfo.Slot) diff --git a/AnodyneArchipelago/Patches/GameplayPatches.cs b/AnodyneArchipelago/Patches/GameplayPatches.cs index 9db87a5..ba33457 100644 --- a/AnodyneArchipelago/Patches/GameplayPatches.cs +++ b/AnodyneArchipelago/Patches/GameplayPatches.cs @@ -10,6 +10,11 @@ using System; using System.Collections.Generic; using System.Reflection; using Microsoft.Xna.Framework; +using AnodyneSharp.Entities.Interactive.Npc.RunningTradeNPCs; +using AnodyneSharp.Dialogue; +using AnodyneSharp.Sounds; +using AnodyneSharp.States; +using AnodyneSharp.Entities.Interactive.Npc; namespace AnodyneArchipelago.Patches { @@ -225,4 +230,95 @@ namespace AnodyneArchipelago.Patches } } } + + [HarmonyPatch(typeof(Box), nameof(Box.PlayerInteraction))] + class BoxOpenPatch + { + static bool Prefix(Box __instance, ref bool __result) + { + if (!GlobalState.events.SpookedMonster) + { + __result = false; + return false; + } + + __instance.Play("open"); + SoundManager.PlaySoundEffect("broom_hit"); + GlobalState.StartCutscene = OnOpened(__instance); + __result = true; + return false; + } + + static IEnumerator OnOpened(Box box) + { + MethodInfo openedMethod = typeof(Box).GetMethod("OnOpened", BindingFlags.NonPublic | BindingFlags.Instance); + IEnumerator subCutscene = (IEnumerator)openedMethod.Invoke(box, new object[] { }); + + yield return subCutscene.Current; + while (subCutscene.MoveNext()) + { + yield return subCutscene.Current; + } + + GlobalState.inventory.tradeState = InventoryManager.TradeState.NONE; + + Plugin.ArchipelagoManager.SendLocation("Fields - Cardboard Box"); + } + } + + [HarmonyPatch(typeof(ShopKeep), nameof(ShopKeep.PlayerInteraction))] + class ShopKeepTalkPatch + { + static bool Prefix(ShopKeep __instance) + { + if (GlobalState.events.GetEvent("ReceivedCardboardBox") == 1 && GlobalState.events.GetEvent("UsedCardboardBox") == 0) + { + GlobalState.Dialogue = GetDiag(2) + " " + GetDiag(4); + GlobalState.events.SetEvent("UsedCardboardBox", 1); + + EntityPreset preset = PatchHelper.GetEntityPreset(typeof(ShopKeep), __instance); + preset.Activated = true; + + Plugin.ArchipelagoManager.SendLocation("Fields - Shopkeeper Trade"); + + return false; + } + + return true; + } + + static string GetDiag(int i) => DialogueManager.GetDialogue("misc", "any", "tradenpc", i); + } + + [HarmonyPatch(typeof(MitraFields), "GetInteractionText")] + class MitraFieldsTextPatch + { + static bool Prefix(ref string __result) + { + if (GlobalState.events.GetEvent("ReceivedBikingShoes") == 1 && GlobalState.events.GetEvent("UsedBikingShoes") == 0) + { + __result = DialogueManager.GetDialogue("misc", "any", "mitra", 1); + + GlobalState.events.SetEvent("UsedBikingShoes", 1); + + Plugin.ArchipelagoManager.SendLocation("Fields - Mitra Trade"); + + return false; + } + + return true; + } + } + + [HarmonyPatch("AnodyneSharp.Entities.Interactive.Npc.Windmill.Console", "PlayerInteraction")] + class WindmillInteractPatch + { + static void Prefix(object __instance) + { + if ((__instance as Entity).CurAnimName == "active") + { + Plugin.ArchipelagoManager.SendLocation("Windmill - Activation"); + } + } + } } -- cgit 1.4.1