Skip to content

Commit

Permalink
Add Fortune Teller Hint System
Browse files Browse the repository at this point in the history
  • Loading branch information
Witchybun committed Oct 31, 2024
1 parent f624600 commit 28068f1
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 7 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -118,3 +118,5 @@ obj/Release/netstandard2.1/FlipwitchAP.pdb
obj/Release/netstandard2.1/MyPluginInfo.cs
bin/Debug/netstandard2.1/Ak.Wwise.Api.WAAPI.dll
bin/Debug/netstandard2.1/AK.Wwise.Unity.Timeline.dll
bin/Release/netstandard2.1/Ak.Wwise.Api.WAAPI.dll
bin/Release/netstandard2.1/AK.Wwise.Unity.Timeline.dll
15 changes: 11 additions & 4 deletions Archipelago/ArchipelagoData.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Archipelago.MultiClient.Net.Models;
using FlipwitchAP.Data;
using Newtonsoft.Json;
Expand Down Expand Up @@ -28,18 +29,21 @@ public class ArchipelagoData
private string ANGEL_KEY = "angel_order";
private string HINT_KEY = "hints";
private string QUEST_KEY = "quest_for_sex";
private string FORTUNE_KEY = "path";
public string ClientVersion { get; private set; }
public int Seed { get; set; }
public Gender StartingGender { get; private set; }
public int ShopPrices { get; private set;}
public bool CrystalTeleport { get; private set; }
public Quest QuestForSex { get; private set; }
public bool DeathLink { get; private set; }
public List<int> AnimalGachaOrder {get; private set; }
public List<int> BunnyGachaOrder {get; private set; }
public List<int> MonsterGachaOrder {get; private set; }
public List<int> AngelGachaOrder {get; private set; }
public List<int> AnimalGachaOrder { get; private set; }
public List<int> BunnyGachaOrder { get; private set; }
public List<int> MonsterGachaOrder { get; private set; }
public List<int> AngelGachaOrder { get; private set; }
public Dictionary<string, string> HintLookup { get; private set; }
public Dictionary<int, string> FortuneTellerLookup { get; private set; }
public bool IsTherePlaythroughGenerated { get; private set; }
public SortedDictionary<long, ArchipelagoItem> ScoutedLocations = new() { };

private Dictionary<string, object> slotData;
Expand Down Expand Up @@ -80,6 +84,9 @@ public void SetupSession(Dictionary<string, object> roomSlotData)
AngelGachaOrder = ProcessGachaList(JsonConvert.DeserializeObject<List<string>>(angelOrderData));
var hintData = GetSlotSetting(HINT_KEY, "");
HintLookup = JsonConvert.DeserializeObject<Dictionary<string, string>>(hintData);
var pathData = GetSlotSetting(FORTUNE_KEY, "");
FortuneTellerLookup = JsonConvert.DeserializeObject<Dictionary<int, string>>(pathData);
IsTherePlaythroughGenerated = FortuneTellerLookup.Any();
}

// Why...?
Expand Down
30 changes: 30 additions & 0 deletions DialogueHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -146,5 +146,35 @@ private static Dictionary<string, string> HandleGroupedMessages(Dictionary<strin
translationDictionary[summonStone] = summonMessage;
return translationDictionary;
}

public static void GenerateCurrentHintForFortuneTeller(string sceneName)
{
if (!ArchipelagoClient.ServerData.IsTherePlaythroughGenerated)
{
return;
}
if (sceneName != "Spirit_City_Final")
{
return;
}
var translationDictionaryField = SwitchDatabase.instance.dialogueManager.GetType().GetField("translationStrings", GenericMethods.Flags);
var translationDictionary = (Dictionary<string, string>) translationDictionaryField.GetValue(SwitchDatabase.instance.dialogueManager);
foreach (var fortunePair in ArchipelagoClient.ServerData.FortuneTellerLookup)
{
if (fortunePair.Key == -100) // Last one; victory
{
translationDictionary["Psychic.1.1"] = fortunePair.Value;
break;
}
var wasLocationChecked = Plugin.ArchipelagoClient.IsLocationChecked(fortunePair.Key);
if (wasLocationChecked)
{
continue;
}
translationDictionary["Psychic.1.1"] = fortunePair.Value;
break;
}
translationDictionaryField.SetValue(SwitchDatabase.instance.dialogueManager, translationDictionary);
}
}
}
3 changes: 2 additions & 1 deletion Plugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class Plugin : BaseUnityPlugin
{
public const string PluginGUID = "com.Albrekka.FlipwitchAP";
public const string PluginName = "FlipwitchAP";
public const string PluginVersion = "0.2.0pre3";
public const string PluginVersion = "0.2.0pre4";
private const string APDisplayInfo = $"Archipelago v{ArchipelagoClient.APVersion}";
public static ArchipelagoClient ArchipelagoClient { get; private set; }
public static bool IsInGame = false;
Expand Down Expand Up @@ -118,6 +118,7 @@ private void OnSceneLoaded(Scene scene, LoadSceneMode mode)
ArchipelagoClient.SendCurrentScene(trueName);
}
}
DialogueHelper.GenerateCurrentHintForFortuneTeller(scene.name);
}

// Display was shamelessly used from Hunie Pop 2's implementation, by dotsofdarkness, since I just want the window on the right.
Expand Down
32 changes: 30 additions & 2 deletions QuestFixer.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Linq;
using FlipwitchAP.Data;
using HarmonyLib;
using UnityEngine;

Expand Down Expand Up @@ -420,7 +421,7 @@ private static void Start_FixQuests(NPCDialogueAdvanced __instance)
switchValue = 2,
comparisonOperator = ComparisonOperators.IS_LESS_THAN
};

if (!senseiGroups[4].switches.Any(x => x.switchName == "APPlayerWand"))
{
senseiGroups[4].switches[1] = receivedNoWandUpgrade;
Expand All @@ -437,7 +438,7 @@ private static void Start_FixQuests(NPCDialogueAdvanced __instance)
{
senseiGroups[7].switches[1] = receivedFirstWandNotSecond;
}

// 4 is first wand upgrade but wrong
// 5 is first wand upgrade
// 6 is second but you're a woman
Expand Down Expand Up @@ -474,6 +475,33 @@ private static void Start_FixQuests(NPCDialogueAdvanced __instance)
}
return;
}
case "FortuneTeller":
{
var madeUpShit = new NPCDialogueAdvanced.SwitchRequirement()
{
switchName = "APMYFUGGENDICC",
switchValue = 999,
comparisonOperator = ComparisonOperators.IS_EQUAL_TO
};
var fortuneGroups = __instance.dialogueGroups;
if (!fortuneGroups[0].switches.Any(x => x.switchName == "APMYFUGGENDICC"))
{
fortuneGroups[0].switches.Add(madeUpShit);
}
if (!fortuneGroups[2].switches.Any(x => x.switchName == "APMYFUGGENDICC"))
{
fortuneGroups[2].itemRequirements.Clear();
}
for (var i = 3; i < 9; i++)
{
if (!fortuneGroups[i].switches.Any(x => x.switchName == "APMYFUGGENDICC"))
{
fortuneGroups[i].switches.Add(madeUpShit);
}
}
DialogueHelper.GenerateCurrentHintForFortuneTeller(__instance.gameObject.scene.name);
return;
}
}
}
}
Expand Down

0 comments on commit 28068f1

Please sign in to comment.