Ejemplo n.º 1
0
 private void HandleSplit(bool shouldSplit, OriSplit split, bool shouldReset = false)
 {
     if (currentSplit > 0 && shouldReset)
     {
         Model.Reset();
     }
     else if (shouldSplit)
     {
         if (split.ShouldSplit)
         {
             if (Model.CurrentState.CurrentPhase == TimerPhase.NotRunning)
             {
                 Model.Start();
             }
             else
             {
                 Model.Split();
             }
         }
         else
         {
             currentSplit++;
         }
     }
 }
Ejemplo n.º 2
0
        public void GetValues()
        {
            if (!mem.HookProcess())
            {
                return;
            }

            GameState gameState      = mem.GetGameState();
            bool      isInGame       = CheckInGame(gameState);
            bool      isInGameWorld  = CheckInGameWorld(gameState);
            bool      isStartingGame = CheckStartingNewGame(gameState);

            if (!isInGameWorld)
            {
                notInGame = DateTime.Now;
            }

            LogValues();

            if (settings.RainbowDash && isInGameWorld)
            {
                mem.ActivateRainbowDash();
            }

            if (Model != null && currentSplit < settings.Splits.Count)
            {
                bool shouldSplit = false;

                OriSplit split = settings.Splits[currentSplit];
                if (split.Field == "Start Game")
                {
                    shouldSplit = isStartingGame;
                }
                else if (split.Field == "In Game")
                {
                    shouldSplit = isInGame && notInGame.AddSeconds(1) > DateTime.Now;
                }
                else if (split.Field == "In Menu")
                {
                    shouldSplit = !isInGame;
                }
                else if (split.Field == "Hitbox" || split.Field == "End of Forlorn Escape" || split.Field == "End of Horu Escape" || split.Field == "Spirit Tree Reached")
                {
                    HitBox ori    = new HitBox(mem.GetCameraTargetPosition(), 0.68f, 1.15f, true);
                    HitBox hitBox = new HitBox(split.Value);
                    shouldSplit = hitBox.Intersects(ori);
                }
                else if (isInGameWorld && DateTime.Now.AddSeconds(-1) > notInGame)
                {
                    switch (split.Field)
                    {
                    case "Map %":
                        decimal map = mem.GetTotalMapCompletion();
                        decimal splitMap;
                        if (decimal.TryParse(split.Value, System.Globalization.NumberStyles.Number, System.Globalization.CultureInfo.GetCultureInfo("en-US"), out splitMap))
                        {
                            shouldSplit = map >= splitMap;
                        }
                        break;

                    case "Valley 100%":
                    case "Grotto 100%":
                    case "Swamp 100%":
                    case "Ginso 100%":
                    case "Forlorn 100%":
                    case "Horu 100%":
                    case "Glades 100%":
                    case "Sorrow 100%":
                    case "Black Root 100%":
                        string      areaName = split.Field.Substring(0, split.Field.Length - 5);
                        List <Area> areas    = mem.GetMapCompletion();
                        for (int i = 0; i < areas.Count; i++)
                        {
                            Area area = areas[i];
                            if (area.Name.IndexOf(areaName, StringComparison.OrdinalIgnoreCase) >= 0)
                            {
                                shouldSplit = area.Progress > (decimal)99.99;
                                break;
                            }
                        }
                        break;

                    case "Soul Flame":
                    case "Spirit Flame":
                    case "Wall Jump":
                    case "Charge Flame":
                    case "Dash":
                    case "Double Jump":
                    case "Bash":
                    case "Stomp":
                    case "Light Grenade":
                    case "Glide":
                    case "Climb":
                    case "Charge Jump":
                        shouldSplit = mem.GetAbility(split.Field); break;

                    case "Ability":
                        shouldSplit = mem.GetAbility(split.Value); break;

                    case "Mist Lifted":
                    case "Clean Water":
                    case "Wind Restored":
                    case "Gumo Free":
                    case "Warmth Returned":
                    case "Darkness Lifted":
                        shouldSplit = mem.GetEvent(split.Field); break;

                    case "Gumon Seal":
                    case "Sunstone":
                    case "Water Vein":
                        shouldSplit = mem.GetKey(split.Field); break;

                    case "Ginso Tree Entered":
                    case "Forlorn Ruins Entered":
                    case "Mount Horu Entered":
                    case "End Game":
                        List <Scene> scenes = mem.GetScenes();
                        for (int i = 0; i < scenes.Count; i++)
                        {
                            Scene scene = scenes[i];
                            if (scene.State == SceneState.Loaded)
                            {
                                switch (scene.Name)
                                {
                                case "ginsoEntranceIntro": shouldSplit = split.Field == "Ginso Tree Entered"; break;

                                case "forlornRuinsGetNightberry": shouldSplit = split.Field == "Forlorn Ruins Entered"; break;

                                case "mountHoruHubMid": shouldSplit = split.Field == "Mount Horu Entered"; break;
                                }
                            }
                            else if (scene.State == SceneState.Loading)
                            {
                                switch (scene.Name)
                                {
                                case "creditsScreen": shouldSplit = split.Field == "End Game"; break;
                                }
                            }
                        }
                        break;

                    case "Health Cells":
                        int maxHP = mem.GetCurrentHPMax();
                        int splitMaxHP;
                        if (int.TryParse(split.Value, System.Globalization.NumberStyles.Number, System.Globalization.CultureInfo.GetCultureInfo("en-US"), out splitMaxHP))
                        {
                            shouldSplit = maxHP >= splitMaxHP;
                        }
                        break;

                    case "Current Health":
                        int   curHP = mem.GetCurrentHP();
                        float splitCurHP;
                        if (float.TryParse(split.Value, System.Globalization.NumberStyles.Number, System.Globalization.CultureInfo.GetCultureInfo("en-US"), out splitCurHP))
                        {
                            shouldSplit = curHP == (int)(splitCurHP * 4);
                        }
                        break;

                    case "Energy Cells":
                        float maxEN = mem.GetCurrentENMax();
                        int   splitMaxEN;
                        if (int.TryParse(split.Value, System.Globalization.NumberStyles.Number, System.Globalization.CultureInfo.GetCultureInfo("en-US"), out splitMaxEN))
                        {
                            shouldSplit = maxEN >= splitMaxEN;
                        }
                        break;

                    case "Current Energy":
                        float curEN = mem.GetCurrentEN();
                        float splitCurEN;
                        if (float.TryParse(split.Value, System.Globalization.NumberStyles.Number, System.Globalization.CultureInfo.GetCultureInfo("en-US"), out splitCurEN))
                        {
                            shouldSplit = Math.Abs(curEN - splitCurEN) < 0.1f;
                        }
                        break;

                    case "Ability Cells":
                        int cells = mem.GetAbilityCells();
                        int splitCells;
                        if (int.TryParse(split.Value, System.Globalization.NumberStyles.Number, System.Globalization.CultureInfo.GetCultureInfo("en-US"), out splitCells))
                        {
                            shouldSplit = cells >= splitCells;
                        }
                        break;

                    case "Level":
                        int lvl = mem.GetCurrentLevel();
                        int splitLvl;
                        if (int.TryParse(split.Value, System.Globalization.NumberStyles.Number, System.Globalization.CultureInfo.GetCultureInfo("en-US"), out splitLvl))
                        {
                            shouldSplit = lvl >= splitLvl;
                        }
                        break;

                    case "Key Stones":
                        int keystones = mem.GetKeyStones();
                        int splitKeys;
                        if (int.TryParse(split.Value, System.Globalization.NumberStyles.Number, System.Globalization.CultureInfo.GetCultureInfo("en-US"), out splitKeys))
                        {
                            shouldSplit = keystones == splitKeys;
                        }
                        break;
                    }
                }
                HandleSplit(shouldSplit, split);
            }
        }