private static void HandleSpecial(UberState state)
 {
     if (state.Name == "arenaBByteStateSerialized" && state.Value.Byte == 4)
     {
         // lumaPoolsStateGroup.arenaByteStateSerialized
         new UberId(5377, 1373).State().Write(state.Value);
     }
     else if (state.Name == "craftCutsceneState" && 0 < state.Value.Byte && state.Value.Byte < 3)
     {
         state.Write(new UberValue((byte)3));
         // Give diamond in the rough pickup.
         new UberId(23987, 14832).State().Write(new UberValue(true));
     }
     // the below is a fix for a vanilla bug where you can just miss getting voice if you
     else if (state.Name == "findToadQuestUberState" && state.Value.Int == 2 ||       // (a) skip the kwolok cutscene too fast
              state.Name == "cleanseWellspringQuestUberState" && state.Value.Int == 4 // (b) come to kwolok after wellspring and get the cutscenes stacked awkwardly
              )
     {
         Randomizer.InputUnlockCallback = () => {
             // this is really questionable!!
             var voiceState = new UberId(46462, 59806).State();
             if (!voiceState.Value.Bool)
             {
                 voiceState.Write(new UberValue(true));
                 InterOp.set_max_health(InterOp.get_max_health() + 10);
                 InterOp.set_max_energy(InterOp.get_max_energy() + 1);
                 InterOp.fill_health();
                 InterOp.fill_energy();
                 InterOp.save();
             }
             // should happen in both branches
             if (SeedController.Flags.Contains(Flag.ALLWISPS))
             {
                 HintsController.ProgressWithHints();
             }
         }
     }
     ;
 }
예제 #2
0
        public static void HandleSignal(string signal)
        {
            switch (signal)
            {
            case "reload":
                if (FramesTillUnlockReload == 0)
                {
                    iniFlagCache.Clear();
                    FramesTillNextSend = 0;
                    Randomizer.Client.Connect();
                    SeedController.ReadSeed();
                    if (InterOp.get_game_state() == GameState.Game)
                    {
                        PsuedoLocs.RELOAD_SEED.OnCollect();
                    }
                    FramesTillUnlockReload = 120;
                }
                break;

            case "lastPickup":
                FramesTillNextSend = 1; // the only reason this isn't = 0 is that spamming this could get really annoying
                MessageQueue.Enqueue(Last);
                break;

            case "progressAndHints":
                HintsController.ProgressWithHints();
                break;

            case "dev":
                Randomizer.Dev = !Randomizer.Dev;
                Randomizer.Log($"Dev: {Randomizer.Dev}");
                break;

            case "exitapp":
                Environment.Exit(Environment.ExitCode);
                break;

            case "toggleDebug":
                InterOp.set_debug_controls(!InterOp.get_debug_controls());
                Print($"Debug {(InterOp.get_debug_controls() ? "enabled" : "disabled")}", toMessageLog: false);
                break;

            case "toggleCursorLock":
                Print($"Cursor Lock {(InterOp.toggle_cursorlock() ? "enabled" : "disabled")}", toMessageLog: false);
                break;

            case "binding1":
                PsuedoLocs.BINDING_ONE.OnCollect();
                break;

            case "binding2":
                PsuedoLocs.BINDING_TWO.OnCollect();
                break;

            case "binding3":
                PsuedoLocs.BINDING_THREE.OnCollect();
                break;

            case "binding4":
                PsuedoLocs.BINDING_FOUR.OnCollect();
                break;

            case "binding5":
                PsuedoLocs.BINDING_FIVE.OnCollect();
                break;

            case "unlockSpoiers":
                if (SeedController.Settings.RaceMode)
                {
                    return;                             // no cheat
                }
                UberSet.Bool(GameComplete, true);
                Print("spoiler unlocked", toMessageLog: false);
                break;

            case "tpCheat":
                if (SeedController.Settings.RaceMode)
                {
                    return;                             // no cheat
                }
                tpCheatToggle = !tpCheatToggle;
                Print($"TPCheat {(tpCheatToggle ? "enabled" : "disabled")}", toMessageLog: false);
                break;

            case "warpCredits":
                if (UberGet.Bool(GameComplete))
                {
                    InterOp.start_credits();
                }
                else
                {
                    Print($"Credit warp not unlocked!", toMessageLog: false);
                }
                break;

            case "printCoords":
                var pos = InterOp.get_position();
                Print($"{pos.X}, {pos.Y}", toMessageLog: false);
                break;

            case "nameSpoilerToggle":
                MapController.NameLabels = !MapController.NameLabels;
                Print($"Loc name labels {(MapController.NameLabels ? "enabled" : "disabled")}", toMessageLog: false);
                break;

            case "logicprovidertoggle":
                MapController.RustLogic = !MapController.RustLogic;
                Print($"Logic Provider: {(MapController.RustLogic ? "Rust" : "Java")}", toMessageLog: false);
                MapController.UpdateReachable();
                break;

            default:
                Randomizer.Log($"Recieved unknown signal {signal}");
                break;
            }
        }
예제 #3
0
        public static void Tick()
        {
            var signal = Engine.ExecFunction("Tick");

            if (signal != null && signal != "none")
            {
                Engine.SetVar("signal", "none");
                switch (signal)
                {
                case "reload":
                    if (FramesTillUnlockReload == 0)
                    {
                        FramesTillNextSend = 0;
                        SeedController.ReadSeed();
                        Randomizer.Memory.OnInit();
                        if (Randomizer.Memory.GameState == Memory.GameState.Game)
                        {
                            PsuedoLocs.RELOAD_SEED.Pickup().Grant();
                        }
                        FramesTillUnlockReload = 60;
                    }
                    break;

                case "lastPickup":
                    FramesTillNextSend = 1; // the only reason this isn't = 0 is that spamming this could get really annoying
                    MessageQueue.Enqueue(Last);
                    break;

                case "hintMessage":
                    HintsController.ShowHintMessage();
                    break;

                case "dev":
                    Randomizer.Dev = !Randomizer.Dev;
                    Randomizer.Log($"Dev: {Randomizer.Dev}");
                    break;

                case "exitapp":
                    Environment.Exit(Environment.ExitCode);
                    break;

                case "toggleDebug":
                    Randomizer.Memory.Debug = !Randomizer.Memory.Debug;
                    Print($"Debug {(Randomizer.Memory.Debug ? "enabled" : "disabled")}", toMessageLog: false);
                    break;

                case "toggleCursorLock":
                    Print($"Cursor Lock {(InterOp.toggle_cursorlock() ? "enabled" : "disabled")}", toMessageLog: false);
                    break;

                case "test1":
                    PsuedoLocs.BINDING_ONE.Pickup().Grant();
                    break;

                case "test2":
                    PsuedoLocs.BINDING_TWO.Pickup().Grant();
                    break;

                case "test3":
                    PsuedoLocs.BINDING_THREE.Pickup().Grant();
                    break;

                case "test4":
                    Print("magic", 180, false);
                    InterOp.magic_function();
                    break;

                case "test5":
                    tpCheatToggle = !tpCheatToggle;
                    Print($"TPCheat {(tpCheatToggle ? "enabled" : "disabled")}");
                    break;

                default:
                    Randomizer.Log($"Recieved unknown signal {signal}");
                    break;
                }
            }
            FramesTillUnlockReload = Math.Max(0, FramesTillUnlockReload - 1);
            if (FramesTillNextSend > 0)
            {
                FramesTillNextSend--;
            }
            else
            {
                if (CanPrint)
                {
                    Current            = MessageQueue.Peek();
                    FramesTillNextSend = Current.Frames;
                    try {
                        InterOp.clear_visible_hints();
                        InterOp.display_hint(InterOp.Util.getIl2cppStringPointer(Current.Text), Current.Frames / 60f);
                        if (IniFlag("LogOnPrint"))
                        {
                            Randomizer.Log($"Sending {Current.Text} for {Current.Frames} ({MessageQueue.Count} remaining in queue)", false);
                        }
                        MessageQueue.Dequeue();
                    } catch (Exception e) { Randomizer.Error("AHK.sendMsg", e, false); }
                }
                else
                {
                    Current = null;
                }
            }
        }
        public static void Tick()
        {
            var signal = Engine.ExecFunction("Tick");

            if (signal != null && signal != "none")
            {
                Engine.SetVar("signal", "none");
                switch (signal)
                {
                case "reload":
                    if (FramesTillUnlockReload == 0)
                    {
                        iniFlagCache.Clear();
                        FramesTillNextSend = 0;
                        Randomizer.Client.Connect();
                        SeedController.ReadSeed();
                        if (InterOp.get_game_state() == GameState.Game)
                        {
                            PsuedoLocs.RELOAD_SEED.OnCollect();
                        }
                        FramesTillUnlockReload = 120;
                    }
                    break;

                case "lastPickup":
                    FramesTillNextSend = 1; // the only reason this isn't = 0 is that spamming this could get really annoying
                    MessageQueue.Enqueue(Last);
                    break;

                case "hintMessage":
                    HintsController.ProgressWithHints();
                    break;

                case "dev":
                    Randomizer.Dev = !Randomizer.Dev;
                    Randomizer.Log($"Dev: {Randomizer.Dev}");
                    break;

                case "exitapp":
                    Environment.Exit(Environment.ExitCode);
                    break;

                case "toggleDebug":
                    InterOp.set_debug_controls(!InterOp.get_debug_controls());
                    Print($"Debug {(InterOp.get_debug_controls() ? "enabled" : "disabled")}", toMessageLog: false);
                    break;

                case "toggleCursorLock":
                    Print($"Cursor Lock {(InterOp.toggle_cursorlock() ? "enabled" : "disabled")}", toMessageLog: false);
                    break;

                case "test1":
                    PsuedoLocs.BINDING_ONE.OnCollect();
                    break;

                case "test2":
                    PsuedoLocs.BINDING_TWO.OnCollect();
                    break;

                case "test3":
                    PsuedoLocs.BINDING_THREE.OnCollect();
                    break;

                case "test4":
                    if (SeedController.HasInternalSpoilers)
                    {
                        UberSet.Bool(34543, 11226, true);
                        Print("spoiler unlocked", toMessageLog: false);
                    }
                    break;

                case "test5":
                    tpCheatToggle = !tpCheatToggle;
                    Print($"TPCheat {(tpCheatToggle ? "enabled" : "disabled")}", toMessageLog: false);
                    break;

                case "printcoords":
                    var pos = InterOp.get_position();
                    Print($"{pos.X}, {pos.Y}", toMessageLog: false);
                    break;

                case "namespoilertoggle":
                    MapController.NameLabels = !MapController.NameLabels;
                    Print($"Loc name labels {(MapController.NameLabels ? "enabled" : "disabled")}", toMessageLog: false);
                    break;

                default:
                    Randomizer.Log($"Recieved unknown signal {signal}");
                    break;
                }
            }
            FramesTillUnlockReload = Math.Max(0, FramesTillUnlockReload - 1);
            if (FramesTillNextSend > 0)
            {
                FramesTillNextSend--;
            }
            else
            {
                if (CanPrint)
                {
                    Current            = MessageQueue.Peek();
                    FramesTillNextSend = Current.Frames;
                    try {
                        InterOp.clear_visible_hints();
                        InterOp.display_hint(Current.Text, Current.Frames / 60f, Current.Pos);
                        if (IniFlag("LogOnPrint"))
                        {
                            Randomizer.Log($"Sending {Current.Text} for {Current.Frames} ({MessageQueue.Count} remaining in queue)", false);
                        }
                        MessageQueue.Dequeue();
                    } catch (Exception e) { Randomizer.Error("AHK.sendMsg", e, false); }
                }
                else
                {
                    Current = null;
                }
            }
        }
        public static void ResolveUberStateChange(UberState state, UberValue old)
        {
            try {
                UberId key = state.GetUberId();
                if (!UberStates.TryGetValue(key, out UberState oldState))
                {
                    oldState       = state.Clone();
                    oldState.Value = old;
                    UberStates.Add(key, oldState);
                }

                UberValue value = state.Value;
                if (value.Int == old.Int)
                {
                    return;
                }

                var oldValFmt = old.FmtVal(state.Type); // get this now because we overwrite the value by reference
                if (ShouldRevert(state))
                {
                    Randomizer.Log($"Reverting state change of {state.Name} from {oldValFmt} to {state.FmtVal()}", false);
                    oldState.Write();
                    return;
                }

                HandleSpecial(state);
                UberStates[key].Value = state.Value;
                var  pos   = InterOp.get_position();
                bool found = false;
                if (value.Int > 0)
                {
                    var id = state.GetUberId();
                    if (SkipUberStateMapCount.GetOrElse(key, 0) > 0)
                    {
                        var p = id.toCond().Pickup().Concat(id.toCond(state.ValueAsInt()).Pickup());
                        if (p.NonEmpty)
                        {
                            SkipUberStateMapCount[key] -= 1;
                            Randomizer.Log($"Suppressed granting {p} from {id}={state.ValueAsInt()}. Will suppress {SkipUberStateMapCount[key]} more times", false, "DEBUG");
                            return;
                        }
                    }
                    found = SeedController.OnUberState(state);
                    if (!found)
                    {
                        HintsController.OnLupoState(id);
                    }
                }

                if (SyncedUberStates.Contains(key))
                {
                    Randomizer.Client.SendUpdate(key, state.ValueAsFloat());
                }

                BonusItemController.OnUberState(state);
                var zone = ZoneType.Void;
                if (InterOp.get_game_state() == GameState.Game)
                {
                    zone = InterOp.get_player_area().toZone();
                }
                if ((value.Int == 0 || !found) && !(state.GroupName == "statsUberStateGroup" || state.GroupName == "achievementsGroup" || state.GroupID == 8 || state.GroupID == 10))
                {
                    Randomizer.Debug($"State change: {state.GroupName}.{state.Name} ({state.GroupID}|{state.ID}) {state.Type} {oldValFmt}->{state.FmtVal()} at ({Math.Round(pos.X)}, {Math.Round(pos.Y)}) in {zone}");
                }
                //Randomizer.Debug($"{state.GroupName}.{state.Name}, {state.GroupID}, {state.ID}, {state.Type}, {oldValFmt}, {state.FmtVal()}, {zone}, {Math.Round(pos.X)},{Math.Round(pos.Y)}");
            }
            catch (Exception e) {
                Randomizer.Error($"USC.Update {state}", e);
            }
        }