public static string NextJijiHint()
        {
            string hint = string.Empty;

            bool ValidHintItem(string item)
            {
                ReqDef def = LogicManager.GetItemDef(item);

                if (def.majorItem)
                {
                    return(true);
                }
                else if (def.action == GiveItemActions.GiveAction.Kingsoul)
                {
                    return(true);
                }
                else if (def.action == GiveItemActions.GiveAction.Dreamer)
                {
                    return(true);
                }
                else if (item == "Focus")
                {
                    return(true);
                }

                return(false);
            }

            while (RandomizerMod.Instance.Settings.JijiHintCounter < RandomizerMod.Instance.Settings.MaxOrder)
            {
                string location = RandomizerMod.Instance.Settings.GetNthLocation(RandomizerMod.Instance.Settings.JijiHintCounter);
                string item     = RandomizerMod.Instance.Settings.GetNthLocationItems(RandomizerMod.Instance.Settings.JijiHintCounter).FirstOrDefault(i => ValidHintItem(i));
                if (string.IsNullOrEmpty(item) || string.IsNullOrEmpty(location))
                {
                    RandomizerMod.Instance.Settings.JijiHintCounter++;
                    continue;
                }
                else if (RandomizerMod.Instance.Settings.CheckItemFound(item))
                {
                    hint = CreateJijiHint(item, location);
                    RandoLogger.LogHintToTracker(hint);
                    RandomizerMod.Instance.Settings.JijiHintCounter++;
                    continue;
                }
                else
                {
                    hint = CreateJijiHint(item, location);
                    RandoLogger.LogHintToTracker(hint);
                    RandomizerMod.Instance.Settings.JijiHintCounter++;
                    break;
                }
            }
            if (string.IsNullOrEmpty(hint))
            {
                return("Oh! I guess I couldn't find any items you left behind. Since you're doing so well, though, I think I'll be keeping this meal.");
            }
            return(hint);
        }
        public SaveSettings()
        {
            AfterDeserialize += () =>
            {
                foreach (var pair in VariableCosts)
                {
                    ReqDef def = LogicManager.GetItemDef(pair.Item1);
                    def.cost = pair.Item2;
                    LogicManager.EditItemDef(pair.Item1, def);
                }

                RandomizerAction.CreateActions(ItemPlacements, Seed);
            };
        }
Exemple #3
0
        public static string CreateJijiHint(string hintItemName, string hintItemSpot)
        {
            ReqDef hintItem = LogicManager.GetItemDef(hintItemName);
            string areaName;

            if (LogicManager.TryGetItemDef(hintItemSpot, out ReqDef hintSpot))
            {
                areaName = hintSpot.areaName;
            }
            else
            {
                areaName = "Shop";
            }

            bool good   = false;
            int  useful = 0;

            foreach ((string, string)p in RandomizerMod.Instance.Settings.Hints)
            {
                ReqDef item     = LogicManager.GetItemDef(p.Item1);
                ReqDef location = LogicManager.GetItemDef(p.Item2);
                if (location.areaName == hintSpot.areaName)
                {
                    if (item.majorItem)
                    {
                        good = true;
                    }
                    if (item.progression)
                    {
                        useful++;
                    }
                }
            }
            string secondMessage;

            if (good)
            {
                secondMessage = " The items there... just thinking about them is getting me excited.";
            }
            else if (useful >= 2)
            {
                secondMessage = " There are a few useful things waiting for you there.";
            }
            else if (useful == 1)
            {
                secondMessage = " I can't say whether it would be worth your time though.";
            }
            else
            {
                secondMessage = " Although it does seem awfully out of the way...";
            }

            string hintPool = PoolText[hintItem.pool];

            if (!JijiHintText.TryGetValue(areaName, out string firstMessage))
            {
                firstMessage = $"***, somewhere beyond my vision in {areaName}";
            }

            firstMessage = firstMessage.Replace("***", hintPool);

            return(firstMessage + secondMessage);
        }
Exemple #4
0
        public override void Process(string scene, Object changeObj)
        {
            if (scene != _sceneName || !(changeObj is PlayMakerFSM fsm) || fsm.FsmName != _fsmName ||
                fsm.gameObject.name != _objectName)
            {
                return;
            }

            // Begin showing lore state
            FsmState startReading = fsm.GetState("Trink 1");

            startReading.ClearTransitions();
            startReading.RemoveActionsOfType <FsmStateAction>();

            // Yeeting the shop menu probably isn't ideal; however, we can't close it because the shop menu's descendant is carrying
            // this FSM that's showing the lore. So welcome to spaghetti-land I guess
            startReading.AddAction(new RandomizerExecuteLambda(() => {
                GameObject.Find("Shop Menu").transform.SetPositionY(200);
            }));

            startReading.AddAction(new RandomizerExecuteLambda(() => GameObject.Find("DialogueManager")
                                                               .LocateMyFSM("Box Open").SendEvent("BOX UP")));
            startReading.AddAction(new Wait()
            {
                time        = 0.3f,
                finishEvent = FsmEvent.Finished
            });


            // Reading
            FsmState loreReading = new FsmState(fsm.GetState("No"))
            {
                Name = "Lore Reading"
            };

            loreReading.ClearTransitions();
            loreReading.RemoveActionsOfType <FsmStateAction>();

            loreReading.AddAction(new RandomizerExecuteLambda(() => {
                GameObject dialogueManager = GameObject.Find("DialogueManager");
                GameObject textObj         = dialogueManager.transform.Find("Text").gameObject;

                // Extract the parameters of the shown lore
                ReqDef loredef             = LogicManager.GetItemDef(fsm.FsmVariables.StringVariables.First(v => v.Name == "PD Bool Name").Value.Split('.')[2]);
                string key                 = loredef.loreKey;
                string sheet               = string.IsNullOrEmpty(loredef.loreSheet) ? "Lore Tablets" : loredef.loreSheet;
                TextAlignmentOptions align = loredef.textType == ChangeShinyIntoText.TextType.LeftLore
                    ? TextAlignmentOptions.TopLeft : TextAlignmentOptions.Top;

                textObj.GetComponent <TextMeshPro>().alignment = align;
                textObj.GetComponent <DialogueBox>().StartConversation(key, sheet);
            }));


            // Finished Reading
            FsmState finishReading = new FsmState(fsm.GetState("No"))
            {
                Name = "Lore Finish Reading"
            };

            finishReading.ClearTransitions();
            finishReading.RemoveActionsOfType <FsmStateAction>();

            finishReading.AddAction(new RandomizerExecuteLambda(() => {
                GameObject dialogueManager = GameObject.Find("DialogueManager");
                GameObject textObj         = dialogueManager.transform.Find("Text").gameObject;
                dialogueManager.LocateMyFSM("Box Open").SendEvent("BOX DOWN");
                textObj.GetComponent <TextMeshPro>().alignment = TextAlignmentOptions.TopLeft;
            }));
            // Add a useless wait here; this is basically just to give the dialogue box time to disappear before returning the shop menu.
            // The time value isn't a special number; I just found that it seemed to work well.
            finishReading.AddAction(new Wait()
            {
                time        = 0.15f,
                finishEvent = FsmEvent.Finished
            });

            // Return the shop menu to its rightful position
            fsm.GetState("Reset").AddFirstAction(new RandomizerExecuteLambda(() => {
                GameObject.Find("Shop Menu").transform.SetPositionY(0.5f);
            }));

            // Adding states
            startReading.AddTransition("FINISHED", loreReading.Name);
            loreReading.AddTransition("CONVO_FINISH", finishReading.Name);
            finishReading.AddTransition("FINISHED", "Reset");

            fsm.AddState(loreReading);
            fsm.AddState(finishReading);
        }
Exemple #5
0
        public static void ShowEffectiveItemPopup(string item)
        {
            ReqDef def = LogicManager.GetItemDef(RandomizerMod.Instance.Settings.GetEffectiveItem(item));

            ShowItemPopup(def.nameKey, def.shopSpriteKey);
        }
        public static void UpdateHelperLog()
        {
            new Thread(() =>
            {
                File.Create(Application.persistentDataPath + "/RandomizerHelperLog.txt").Dispose();
                LogHelper("Generating helper log:");
                Stopwatch helperWatch = new Stopwatch();
                helperWatch.Start();

                Dictionary <string, List <string> > areaTransitions = new Dictionary <string, List <string> >();
                foreach (string transition in LogicManager.TransitionNames)
                {
                    string area = LogicManager.GetTransitionDef(transition).areaName;
                    if (!areaTransitions.ContainsKey(area))
                    {
                        areaTransitions[area] = new List <string>();
                    }
                }

                if (itemLocations == null)
                {
                    itemLocations = new List <string>();
                    foreach (string item in LogicManager.ItemNames)
                    {
                        ReqDef def = LogicManager.GetItemDef(item);
                        if (def.isFake)
                        {
                            continue;
                        }
                        if (def.type == ItemType.Shop)
                        {
                            continue;
                        }
                        if (def.pool == "Dreamer" && !AreaRando.Instance.Settings.RandomizeDreamers)
                        {
                            continue;
                        }
                        if (def.pool == "Skill" && !AreaRando.Instance.Settings.RandomizeSkills)
                        {
                            continue;
                        }
                        if (def.pool == "Charm" && !AreaRando.Instance.Settings.RandomizeCharms)
                        {
                            continue;
                        }
                        if (def.pool == "Key" && !AreaRando.Instance.Settings.RandomizeKeys)
                        {
                            continue;
                        }
                        if (def.pool == "Mask" && !AreaRando.Instance.Settings.RandomizeMaskShards)
                        {
                            continue;
                        }
                        if (def.pool == "Vessel" && !AreaRando.Instance.Settings.RandomizeVesselFragments)
                        {
                            continue;
                        }
                        if (def.pool == "Ore" && !AreaRando.Instance.Settings.RandomizePaleOre)
                        {
                            continue;
                        }
                        if (def.pool == "Notch" && !AreaRando.Instance.Settings.RandomizeCharmNotches)
                        {
                            continue;
                        }
                        if (def.pool == "Geo" && !AreaRando.Instance.Settings.RandomizeGeoChests)
                        {
                            continue;
                        }
                        if (def.pool == "Egg" && !AreaRando.Instance.Settings.RandomizeRancidEggs)
                        {
                            continue;
                        }
                        if (def.pool == "Relic" && !AreaRando.Instance.Settings.RandomizeRelics)
                        {
                            continue;
                        }
                        if (def.longItemTier > AreaRando.Instance.Settings.LongItemTier)
                        {
                            continue;
                        }
                        itemLocations.Add(item);
                    }
                }

                Dictionary <string, List <string> > areaItemLocations = new Dictionary <string, List <string> >();
                foreach (string item in itemLocations)
                {
                    string area = LogicManager.GetItemDef(item).areaName;
                    if (!areaItemLocations.ContainsKey(area))
                    {
                        areaItemLocations[area] = new List <string>();
                    }
                }

                List <string> logicTransitions = LogicManager.TransitionNames.Where(transition => LogicManager.GetTransitionDef(transition).oneWay != 2 && !LogicManager.GetTransitionDef(transition).isolated).ToList();
                foreach (string transition in LogicManager.TransitionNames)
                {
                    if (LogicManager.CheckForProgressionItem(AreaRando.Instance.Settings.ObtainedProgression, transition))
                    {
                        areaTransitions[LogicManager.GetTransitionDef(transition).areaName].Add(transition);
                    }
                    else if (logicTransitions.Contains(transition) && LogicManager.ParseProcessedLogic(transition, AreaRando.Instance.Settings.ObtainedProgression))
                    {
                        areaTransitions[LogicManager.GetTransitionDef(transition).areaName].Add("*" + transition);
                    }
                }

                foreach (string location in itemLocations)
                {
                    string item     = AreaRando.Instance.Settings.ItemPlacements.FirstOrDefault(pair => pair.Item2 == location).Item1;
                    string boolName = string.Empty;
                    if (Actions.RandomizerAction.AdditiveBoolNames.TryGetValue(item, out string _boolName))
                    {
                        boolName = _boolName;
                    }
                    else
                    {
                        boolName = LogicManager.GetItemDef(item).boolName;
                    }

                    if (PlayerData.instance.GetBool(boolName))
                    {
                        areaItemLocations[LogicManager.GetItemDef(location).areaName].Add(location);
                    }
                    else if (AreaRando.Instance.Settings.GetBool(false, boolName))
                    {
                        areaItemLocations[LogicManager.GetItemDef(location).areaName].Add(location);
                    }
                    else if (LogicManager.ParseProcessedLogic(location, AreaRando.Instance.Settings.ObtainedProgression))
                    {
                        areaItemLocations[LogicManager.GetItemDef(location).areaName].Add("*" + location);
                    }
                }

                string log = string.Empty;
                void AddToLog(string message) => log += message + Environment.NewLine;

                AddToLog(Environment.NewLine + "REACHABLE TRANSITIONS");
                foreach (KeyValuePair <string, List <string> > kvp in areaTransitions)
                {
                    if (kvp.Value.Count > 0)
                    {
                        AddToLog(Environment.NewLine + kvp.Key.Replace('_', ' ') + ":");
                        foreach (string transition in kvp.Value)
                        {
                            AddToLog(transition);
                        }
                    }
                }

                AddToLog(Environment.NewLine + "REACHABLE ITEM LOCATIONS");
                foreach (KeyValuePair <string, List <string> > kvp in areaItemLocations)
                {
                    if (kvp.Value.Count > 0)
                    {
                        AddToLog(Environment.NewLine + kvp.Key.Replace('_', ' ') + ":");
                        foreach (string item in kvp.Value)
                        {
                            AddToLog(item.Replace('_', ' '));
                        }
                    }
                }

                helperWatch.Stop();
                LogHelper(log);
                LogHelper("Generated helper log in " + helperWatch.Elapsed.TotalSeconds + " seconds.");
            }).Start();
        }
Exemple #7
0
        private static string NameOfItemPlacedAt(string location)
        {
            ReqDef item = LogicManager.GetItemDef(RandomizerMod.Instance.Settings.GetItemPlacedAt(location));

            return(GetLanguageString(item.nameKey, "UI"));
        }
Exemple #8
0
        public static string CreateJijiHint(string hintItemName, string hintItemSpot)
        {
            ReqDef hintItem = LogicManager.GetItemDef(hintItemName);
            ReqDef hintSpot = LogicManager.GetItemDef(hintItemSpot);
            bool   good     = false;
            int    useful   = 0;

            foreach ((string, string)p in RandomizerMod.Instance.Settings.Hints)
            {
                ReqDef item     = LogicManager.GetItemDef(p.Item1);
                ReqDef location = LogicManager.GetItemDef(p.Item2);
                if (location.areaName == hintSpot.areaName)
                {
                    if (item.isGoodItem)
                    {
                        good = true;
                    }
                    if (item.progression)
                    {
                        useful++;
                    }
                }
            }
            string secondMessage;

            if (good)
            {
                secondMessage = " The items there... just thinking about them is getting me excited.";
            }
            else if (useful >= 2)
            {
                secondMessage = " There are a few useful things waiting for you there.";
            }
            else if (useful == 1)
            {
                secondMessage = " I can't say whether it would be worth your time though.";
            }
            else
            {
                secondMessage = " Although it does seem awfully out of the way...";
            }

            hintItemName = GetLanguageString(hintItem.nameKey, "UI");
            string hintItemArea = hintSpot.areaName;
            string firstMessage;

            if (hintItemArea == "Greenpath")
            {
                firstMessage = "Yes, I can see the items you've left behind. " + hintItemName + " in a lush, green land.";
            }
            else if (hintItemArea == "Fungal_Wastes")
            {
                firstMessage = "Yes, I can see the items you've left behind. " + hintItemName + " nestled amongst strange fungus and bubbling lakes.";
            }
            else if (hintItemArea == "Crystal_Peak")
            {
                firstMessage = "Yes, I can see the items you've left behind. " + hintItemName + " almost hidden by the glow of shimmering crystals around it.";
            }
            else if (hintItemArea == "Abyss")
            {
                firstMessage = "Yes, I can see the items you've left behind. Only faintly though... " + hintItemName + " deep below the world, surrounded by darkness. Almost a part of it...";
            }
            else if (hintItemArea == "Royal_Waterways")
            {
                firstMessage = "Yes, I can see the items you've left behind. " + hintItemName + " surrounded by pipes and running water. It can not be washed away, though...";
            }
            else if (hintItemArea == "Resting_Grounds")
            {
                firstMessage = "Yes, I can see the items you've left behind. " + hintItemName + " in a holy place of repose.";
            }
            else if (hintItemArea == "Ancestral_Mound")
            {
                firstMessage = "Yes, I can see the items you've left behind. " + hintItemName + " in an ancestral mound... a place of strange worships.";
            }
            else if (hintItemArea == "City_of_Tears")
            {
                firstMessage = "Yes, I can see the items you've left behind. " + hintItemName + " in the heart of the kingdom's capital. Rain can not wash it away, though...";
            }
            else if (hintItemArea == "Fog_Canyon")
            {
                firstMessage = "Yes, I can see the items you've left behind. " + hintItemName + " lost in the fog of a strange land.";
            }
            else if (hintItemArea == "Howling_Cliffs")
            {
                firstMessage = "Yes, I can see the items you've left behind. " + hintItemName + " high above us, surrounded by howling winds.";
            }
            else if (hintItemArea == "Kingdoms_Edge")
            {
                firstMessage = "Yes, I can see the items you've left behind. " + hintItemName + " far away at the very edge of the world.";
            }
            else if (hintItemArea == "Forgotten_Crossroads")
            {
                firstMessage = "Yes, I can see the items you've left behind. " + hintItemName + " just below us, lost amongst the kingdom's twisting roads and highways.";
            }
            else if (hintItemArea == "Kings_Pass")
            {
                firstMessage = "Yes, I can see the items you've left behind. " + hintItemName + " nearby, right at the entrance to this kingdom.";
            }
            else if (hintItemArea == "Deepnest")
            {
                firstMessage = "Yes, I can see the items you've left behind. " + hintItemName + ", barely visible in the tunnels of a nest deep below this kingdom.";
            }
            else if (hintItemArea == "Dirtmouth")
            {
                firstMessage = "Yes, I can see the items you've left behind. " + hintItemName + " just outside, in a town quietly fading away.";
            }
            else if (hintItemArea == "Hive")
            {
                firstMessage = "Yes, I can see the items you've left behind. " + hintItemName + " surrounded by golden light, in a hive far away from here.";
            }
            else if (hintItemArea == "Queens_Gardens")
            {
                firstMessage = "Yes, I can see the items you've left behind. " + hintItemName + ", marring a garden's beauty.";
            }
            else if (hintItemArea == "Colosseum")
            {
                firstMessage = "Yes, I can see the items you've left behind. " + hintItemName + " surrounded by warriors and fools.";
            }
            else if (hintItemArea == "Ancient_Basin")
            {
                firstMessage = "Yes, I can see the items you've left behind. " + hintItemName + ", lying just outside the ruins of the king's palace.";
            }
            else
            {
                firstMessage = hintItemName + " is in " + hintItemArea + ".";
            }

            return(firstMessage + secondMessage);
        }