public static void VTTameNearbyCreatures(this Player player)
 {
     if (player != null)
     {
         Tameable.TameAllInArea(player.transform.position, 20f);
     }
 }
Example #2
0
        public static void InputCMD(string inCommand)
        {
            if (inCommand.Length > 0)

            {
                if (inCommand.StartsWith(" "))
                {
                    inCommand = inCommand.Remove(0, 1);
                }
                #region env
                if (inCommand.StartsWith("/env"))
                {
                    inCommand = inCommand.Remove(0, 5);
                    //float num1;
                    //if (!float.TryParse(inCommand, NumberStyles.Float, CultureInfo.InvariantCulture, out num1))
                    //{
                    //cprt("Wrong Number");
                    //return;
                    //}
                    if (inCommand == "list")
                    {
                        string wl = "pick from these ones,list: ";
                        foreach (var w in WeatherList)
                        {
                            wl += w;
                            wl += ",";
                        }
                        cprt(wl);
                        return;
                    }
                    if (EnvMan.instance)
                    {
                        if (WeatherList.Contains(inCommand))
                        {
                            if (inCommand == "reset")
                            {
                                EnvMan.instance.m_debugEnv = "";
                                cprt("reset enviroment");
                                return;
                            }
                            EnvMan.instance.m_debugEnv = inCommand;
                            cprt("set enviroment to " + inCommand);
                            return;
                        }
                        else
                        {
                            cprt("Wrong Word,Try /env list");
                        }
                    }
                    blogWarning("EnvMan is null");
                    return;
                }
                #endregion
                #region admin
                if (inCommand == "/amd")
                {
                    if (CheckPlayerNull())
                    {
                        return;
                    }
                    //isAdmin = true;
                    SetAdmin(true);
                }
                if (inCommand == "/oadm")
                {
                    if (CheckPlayerNull())
                    {
                        return;
                    }
                    //isAdmin = false;
                    SetAdmin(false);
                }
                if (inCommand == "/gst")
                {
                    if (CheckPlayerNull())
                    {
                        return;
                    }
                    SetGhost();
                }
                if (inCommand == "/rds")
                {
                    ItemDrop[] array2 = UnityEngine.Object.FindObjectsOfType <ItemDrop>();
                    int        num    = 0;
                    for (int i = 0; i < array2.Length; i++)
                    {
                        ZNetView component = array2[i].GetComponent <ZNetView>();
                        if (component && component.IsValid() && component.IsOwner())
                        {
                            component.Destroy();
                            num++;
                        }
                    }
                    InfoTL("Destoyed " + num.ToString() + " items");
                }
                if (inCommand == "/cam")
                {
                    GameCamera.instance.ToggleFreeFly();
                }
                #region noclip
                if (inCommand == "/noclip")
                {
                    if (CheckPlayerNull())
                    {
                        return;
                    }
                    SetClip();
                }
                #endregion

                #endregion
                #region Terrain
                if (inCommand.StartsWith("/tf"))
                {
                    inCommand = inCommand.Remove(0, 4);
                    string[] arg = inCommand.Split(new char[] { ',' });
                    if (arg.Length > 2 || arg.Length < 2 || !inCommand.Contains(","))
                    {
                        cprt("/tf syntax wrong");
                        return;
                    }
                    try
                    {
                        float x = float.Parse(arg[0]);
                        float y = float.Parse(arg[1]);
                        Terrain.Flatten(x, y);
                    }
                    catch (Exception e)
                    {
                        blogWarning("/tf failed :" + e);
                    }
                }
                if (inCommand.StartsWith("/trf"))
                {
                    inCommand = inCommand.Remove(0, 5);
                    cprt(inCommand);
                    try
                    {
                        Terrain.RemoveFlora(float.Parse(inCommand));
                    }
                    catch (Exception e)
                    {
                        blogWarning("/trf failed:" + e);
                    }
                }
                if (inCommand.StartsWith("/trst"))
                {
                    inCommand = inCommand.Remove(0, 6);
                    cprt(inCommand);
                    try
                    {
                        Terrain.Reset(Player.m_localPlayer.transform.position, float.Parse(inCommand));
                    }
                    catch (Exception e)
                    {
                        blogWarning("/trst failed:" + e);
                    }
                }
                #endregion
                #region tod
                if (inCommand.StartsWith("/tod"))
                {
                    float a = 0;
                    inCommand = inCommand.Remove(0, 5);
                    try { a = float.Parse(inCommand); }
                    catch (Exception)
                    {
                        cprt("Wrong Number");
                    }
                    if (a <= 0 || a >= 1)
                    {
                        EnvMan.instance.m_debugTimeOfDay = false;
                        return;
                    }
                    EnvMan.instance.m_debugTimeOfDay = true;
                    EnvMan.instance.m_debugTime      = a;
                }
                #endregion
                #region tame
                if (inCommand == "/tame")
                {
                    Tameable.TameAllInArea(Player.m_localPlayer.transform.position, 30f);
                }
                #endregion
                #region list
                if (inCommand.StartsWith("/listi"))
                {
                    inCommand = inCommand.Remove(0, 7);
                    if (inCommand.Length > 0)
                    {
                        string list = "Result: ";
                        if (inCommand.StartsWith("?"))
                        {
                            foreach (GameObject g in ObjectDB.instance.m_items)
                            {
                                ItemDrop component = g.GetComponent <ItemDrop>();
                                list += component.name;
                                list += ",";
                                list  = LimitLog(list);
                            }
                            list = LimitLog(list);
                            if (list != "")
                            {
                                Traverse.Create(MessageHud.instance).Method("AddLog", new object[] { list }).GetValue();
                                cprt(list);
                                cprt("Check your Message Log");
                                list = "";
                                return;
                            }
                            return;
                        }
                        using (List <GameObject> .Enumerator enumerator3 = ObjectDB.instance.m_items.GetEnumerator())
                        {
                            while (enumerator3.MoveNext())
                            {
                                GameObject g2 = enumerator3.Current;
                                ItemDrop   c2 = g2.GetComponent <ItemDrop>();
                                if (c2.name.ToLower().Contains(inCommand.ToLower()))
                                {
                                    list += c2.name;
                                    list += ",";
                                    list  = LimitLog(list);
                                }
                            }
                            list = LimitLog(list);
                            if (list != "")
                            {
                                Traverse.Create(MessageHud.instance).Method("AddLog", new object[] { list }).GetValue();
                                cprt(list);
                                cprt("Check your Message Log");
                                list = "";
                                return;
                            }
                            return;
                        }
                    }
                    return;
                }
                #endregion
                #region trader
                if (inCommand == "/trader")
                {
                    Game.instance.DiscoverClosestLocation("Vendor_BlackForest", Player.m_localPlayer.transform.position, "Merchant", 8);
                    Minimap.PinData pinData = Enumerable.First <Minimap.PinData>((List <Minimap.PinData>)Traverse.Create(Minimap.instance).Field("m_pins").GetValue(), (Minimap.PinData p) => p.m_type == Minimap.PinType.None && p.m_name == "");
                    return;
                }
                #endregion
                #region spi
                if (inCommand.StartsWith("/spi"))
                {
                    inCommand = inCommand.Remove(0, 5);
                    string[] c = inCommand.Split(new char[] { ' ' });
                    if (c.Length == 1)
                    {
                        FT.SpawnPrefab(c[0], Player.m_localPlayer);
                        return;
                    }
                    if (c.Length == 2)
                    {
                        int amt = 1;
                        if (!int.TryParse(c[1], out amt))
                        {
                            cprt("Wrong Syntax");
                            return;
                        }
                        FT.SpawnPrefab(c[0], Player.m_localPlayer, amt);
                    }
                    else
                    {
                        cprt("Wrong Syntax");
                        return;
                    }
                }
                #endregion
                //end
            }
        }
Example #3
0
        void Awake()
        {
            Console = new DurandaConsole();

            Console.RegisterCommand("commands", "Duranda console command list", new ConsoleCommandCallback((args) =>
            {
                Console.ListCommands();
            }));

            Console.RegisterCommand("echo", "Print to console", new ConsoleCommandCallback((args) =>
            {
                string buffer = "";
                foreach (var i in args)
                {
                    buffer += i + " ";
                }

                Console.WriteLine(buffer);
            }));

            Console.RegisterCommand("debug_mode", "Toggle debug mode.", new ConsoleCommandCallback((args) =>
            {
                if (args.Count == 0)
                {
                    Console.WriteLine($"Usage: debug_mode [value]\nCurrent value: {DebugMode}");
                    return;
                }

                if (!bool.TryParse(args[0], out DebugMode))
                {
                    Console.WriteLine("Invalid input!");
                    return;
                }

                Console.WriteLine($"Debug mode is now {DebugMode}");
                GetLocalPlayer()?.Message(MessageHud.MessageType.Center, $"Debug mode is now {DebugMode}");
            }));

            Console.RegisterCommand("fly_toggle", "Toggle debug fly.", new ConsoleCommandCallback((args) =>
            {
                if (args.Count == 0)
                {
                    Console.WriteLine($"Usage: fly_toggle [value]\nCurrent value: {FlyMode}");
                    return;
                }

                if (!bool.TryParse(args[0], out FlyMode))
                {
                    Console.WriteLine("Invalid input!");
                    return;
                }

                Console.WriteLine($"Fly mode is now {FlyMode}");
                GetLocalPlayer()?.Message(MessageHud.MessageType.Center, $"Fly mode is now {FlyMode}");
            }));

            Console.RegisterCommand("text_echo", "Print text message", new ConsoleCommandCallback((args) =>
            {
                Player localPlayer = GetLocalPlayer();
                if (localPlayer == null)
                {
                    Console.WriteLine("Not in-game");
                    return;
                }

                string buffer = "";
                foreach (var i in args)
                {
                    buffer += i + " ";
                }

                localPlayer.Message(MessageHud.MessageType.Center, buffer);
            }));

            Console.RegisterCommand("hud_echo", "Print to hud", new ConsoleCommandCallback((args) =>
            {
                string buffer = "";
                foreach (var i in args)
                {
                    buffer += i + " ";
                }

                SendHudMessage(buffer);
            }));

            Console.RegisterCommand("killmobs", "Kill mobs in the area.", new ConsoleCommandCallback((args) =>
            {
                if (args.Count == 0)
                {
                    Console.WriteLine("Usage: killmobs [amount] => 'all' for every mob");
                    return;
                }

                int amount = -1;
                if (args[0] != "all" && !int.TryParse(args[0], out amount))
                {
                    Console.WriteLine("Invalid input!");
                    return;
                }

                int killed = KillMobs(amount);
                Console.WriteLine($"Killed {killed} mobs.");
            }));

            Console.RegisterCommand("player_kill", "Kill the given player.", new ConsoleCommandCallback((args) =>
            {
                if (args.Count == 0)
                {
                    Console.WriteLine("Usage: killplayer [name]");
                    return;
                }

                if (KillPlayer(args[0]))
                {
                    Console.WriteLine($"The player has been killed.");
                }
                else
                {
                    Console.WriteLine($"No player found with name {args[0]}.");
                }
            }));

            Console.RegisterCommand("camerashake", "Set the camera shake value.", new ConsoleCommandCallback((args) =>
            {
                if (args.Count == 0)
                {
                    Console.WriteLine($"Usage: camerashake [value]\nCurrent value: {CameraShake}");
                    return;
                }

                if (!int.TryParse(args[0], out CameraShake))
                {
                    Console.WriteLine("Invalid input!");
                    return;
                }

                Console.WriteLine($"Camera shake has been changed to {CameraShake}");
            }));

            Console.RegisterCommand("interact_distance", "Set the interact distance value.", new ConsoleCommandCallback((args) =>
            {
                if (args.Count == 0)
                {
                    Console.WriteLine($"Usage: interact_distance [value]\nCurrent value: {InteractDistance}");
                    return;
                }

                if (!int.TryParse(args[0], out InteractDistance))
                {
                    Console.WriteLine("Invalid input!");
                    return;
                }

                Console.WriteLine($"Interact distance has been changed to {InteractDistance}");
            }));

            Console.RegisterCommand("place_distance", "Set the place distance value.", new ConsoleCommandCallback((args) =>
            {
                if (args.Count == 0)
                {
                    Console.WriteLine($"Usage: place_distance [value]\nCurrent value: {PlaceDistance}");
                    return;
                }

                if (!int.TryParse(args[0], out PlaceDistance))
                {
                    Console.WriteLine("Invalid input!");
                    return;
                }

                Console.WriteLine($"Interact distance has been changed to {PlaceDistance}");
            }));

            Console.RegisterCommand("pickuprange", "Set the pickup range. (aka loot magnet)", new ConsoleCommandCallback((args) =>
            {
                if (args.Count == 0)
                {
                    Console.WriteLine($"Usage: pickuprange [value]\nCurrent value: {PickupRange}");
                    return;
                }

                if (!int.TryParse(args[0], out PickupRange))
                {
                    Console.WriteLine("Invalid input!");
                    return;
                }

                Console.WriteLine($"Pickup range has been changed to {PickupRange}");
            }));

            Console.RegisterCommand("durability_toggle", "Disable durability for every item in your inventory.", new ConsoleCommandCallback((args) =>
            {
                if (args.Count == 0)
                {
                    Console.WriteLine($"Usage: durability_toggle [value]\nCurrent value: {Durability}");
                    return;
                }

                if (!bool.TryParse(args[0], out Durability))
                {
                    Console.WriteLine("Invalid input!");
                    return;
                }

                Console.WriteLine($"No durability is now {Durability}");
                GetLocalPlayer()?.Message(MessageHud.MessageType.Center, $"No durability is now {Durability}");
            }));

            Console.RegisterCommand("jumpheight", "Set the jump height.", new ConsoleCommandCallback((args) =>
            {
                if (args.Count == 0)
                {
                    Console.WriteLine($"Usage: jumpheight [value]\nCurrent value: {JumpForce}");
                    return;
                }

                if (!int.TryParse(args[0], out JumpForce))
                {
                    Console.WriteLine("Invalid input!");
                    return;
                }

                Console.WriteLine($"Jump height has been changed to {JumpForce}");
            }));

            Console.RegisterCommand("unlockdlcs", "Unlock every DLC.", new ConsoleCommandCallback((args) =>
            {
                if (args.Count == 0)
                {
                    Console.WriteLine($"Usage: unlockdlcs [value]\nCurrent value: {UnlockDLCs}");
                    return;
                }

                if (!bool.TryParse(args[0], out UnlockDLCs))
                {
                    Console.WriteLine("Invalid input!");
                    return;
                }

                Console.WriteLine($"Unlock every DLC is now {UnlockDLCs}");
                GetLocalPlayer()?.Message(MessageHud.MessageType.Center, $"Unlock every DLC is now {UnlockDLCs}");
            }));

            Console.RegisterCommand("map_reveal", "Reveals the whole map.", new ConsoleCommandCallback((args) =>
            {
                Minimap.instance.ExploreAll();
                Console.WriteLine("Revealed the whole map!");
            }));

            Console.RegisterCommand("map_reset", "Resets the whole map.", new ConsoleCommandCallback((args) =>
            {
                Minimap.instance.Reset();
                Console.WriteLine("Reseted the whole map!");
            }));

            Console.RegisterCommand("map_merchant", "Discover vendor.", new ConsoleCommandCallback((args) =>
            {
                Player localPlayer = GetLocalPlayer();
                if (localPlayer == null)
                {
                    Console.WriteLine("Not in-game");
                    return;
                }

                ZoneSystem.LocationInstance locationInstance;
                ZoneSystem.instance.FindClosestLocation("Vendor_BlackForest", localPlayer.transform.position, out locationInstance);
                Minimap.instance.DiscoverLocation(locationInstance.m_position, Minimap.PinType.Icon3, "Merchant");
                Console.WriteLine($"Merchant position: X: {locationInstance.m_position.x} Y: {locationInstance.m_position.y} Z: {locationInstance.m_position.z}");
            }));

            Console.RegisterCommand("healself", "Heal to maxhealth.", new ConsoleCommandCallback((args) =>
            {
                Player localPlayer = GetLocalPlayer();

                if (localPlayer != null)
                {
                    localPlayer.Heal(localPlayer.GetMaxHealth(), true);
                    Console.WriteLine("You have been healed up!");
                }
            }));

            Console.RegisterCommand("setfov", "Change the player fov.", new ConsoleCommandCallback((args) =>
            {
                if (args.Count == 0)
                {
                    Console.WriteLine($"Usage: setfov [value]\nCurrent value: {FOV}");
                    return;
                }

                if (!int.TryParse(args[0], out FOV))
                {
                    Console.WriteLine("Invalid input!");
                    return;
                }

                Console.WriteLine($"FOV has been changed to {FOV}");
            }));

            Console.RegisterCommand("skill_setlevel", "Set the level of a skill.", new ConsoleCommandCallback((args) =>
            {
                if (args.Count == 0)
                {
                    string skillNames = GetSkillNames();
                    Console.WriteLine($"Usage: skill_setlevel [name] [value]\n{skillNames}");
                    return;
                }

                Skills.SkillType skill = GetSkillFromName(args[0]);
                if (skill == Skills.SkillType.None)
                {
                    string skillNames = GetSkillNames();
                    Console.WriteLine($"Invalid skill name!\n{skillNames}");
                    return;
                }

                Player localPlayer = GetLocalPlayer();
                if (args.Count == 1)
                {
                    if (skill == Skills.SkillType.All)
                    {
                        foreach (var i in Enum.GetValues(typeof(Skills.SkillType)))
                        {
                            Skills.SkillType tempType = (Skills.SkillType)i;
                            if (tempType == Skills.SkillType.None || tempType == Skills.SkillType.All)
                            {
                                continue;
                            }

                            Console.WriteLine($"Current level of the {i} skill: {GetSkillLevel(tempType)}");
                        }
                    }
                    else
                    {
                        Console.WriteLine($"Current level of the {skill} skill: {GetSkillLevel(skill)}");
                    }

                    return;
                }

                if (!int.TryParse(args[1], out int skillLevel))
                {
                    Console.WriteLine("Invalid input!");
                    return;
                }

                SetSkillLevel(skill, skillLevel);

                string message = skill == Skills.SkillType.All ? $"Changed the level of every skill to {skillLevel}" : $"Changed the level of the {skill} to {skillLevel}";
                Console.WriteLine(message);
                localPlayer.Message(MessageHud.MessageType.Center, message);
            }));

            Console.RegisterCommand("god_toggle", "Toggle god mode.", new ConsoleCommandCallback((args) =>
            {
                if (args.Count == 0)
                {
                    Console.WriteLine($"Usage: god_toggle [value]\nCurrent value: {God}");
                    return;
                }

                if (!bool.TryParse(args[0], out God))
                {
                    Console.WriteLine("Invalid input!");
                    return;
                }

                Console.WriteLine($"God mode is now {God}");
                GetLocalPlayer()?.Message(MessageHud.MessageType.Center, $"God mode is now {God}");
            }));

            Console.RegisterCommand("ghost_toggle", "Toggle ghost mode.", new ConsoleCommandCallback((args) =>
            {
                if (args.Count == 0)
                {
                    Console.WriteLine($"Usage: ghost_toggle [value]\nCurrent value: {Ghost}");
                    return;
                }

                if (!bool.TryParse(args[0], out Ghost))
                {
                    Console.WriteLine("Invalid input!");
                    return;
                }

                Console.WriteLine($"Ghost mode is now {Ghost}");
                GetLocalPlayer()?.Message(MessageHud.MessageType.Center, $"Ghost mode is now {Ghost}");
            }));

            Console.RegisterCommand("food_puke", "Clear foods.", new ConsoleCommandCallback((args) =>
            {
                Player localPlayer = GetLocalPlayer();

                if (localPlayer != null)
                {
                    localPlayer.ClearFood();
                    localPlayer.Message(MessageHud.MessageType.Center, "Your foods cleared!");
                    Console.WriteLine("Your foods cleared!");
                }
            }));

            Console.RegisterCommand("tame_all", "Tame every mob in your area.", new ConsoleCommandCallback((args) =>
            {
                if (args.Count == 0)
                {
                    Console.WriteLine($"Usage: tame_all [radius]");
                    return;
                }

                if (!int.TryParse(args[0], out int radius))
                {
                    Console.WriteLine("Invalid input!");
                    return;
                }

                Player localPlayer = GetLocalPlayer();

                if (localPlayer != null)
                {
                    Tameable.TameAllInArea(localPlayer.transform.position, radius);

                    localPlayer.Message(MessageHud.MessageType.Center, "You have tamed every mob in the given area!");
                    Console.WriteLine("You have tamed every mob in the given area!");
                }
            }));

            Console.RegisterCommand("getpos", "Get your position.", new ConsoleCommandCallback((args) =>
            {
                Player localPlayer = GetLocalPlayer();
                if (localPlayer == null)
                {
                    Console.WriteLine("Couldn't get player position. (Not in-game?)");
                    return;
                }

                string message = $"X: {localPlayer.transform.position.x:F0} Y: {localPlayer.transform.position.y:F0} Z: {localPlayer.transform.position.z:F0}";

                Console.WriteLine(message);
                localPlayer.Message(MessageHud.MessageType.Center, message);
            }));

            Console.RegisterCommand("wind_reset", "Reset wind.", new ConsoleCommandCallback((args) =>
            {
                EnvMan.instance.ResetDebugWind();
                Player localPlayer = GetLocalPlayer();
                localPlayer.Message(MessageHud.MessageType.Center, "Wind reseted!");
                Console.WriteLine("Wind reseted!");
            }));

            Console.RegisterCommand("wind_set", "Set wind.", new ConsoleCommandCallback((args) =>
            {
                if (args.Count != 2)
                {
                    Console.WriteLine($"Usage: wind_set [angle] [intensity]");
                    return;
                }

                if (!int.TryParse(args[0], out int angle))
                {
                    Console.WriteLine("Invalid input!");
                    return;
                }

                if (!int.TryParse(args[1], out int intensity))
                {
                    Console.WriteLine("Invalid input!");
                    return;
                }

                EnvMan.instance.SetDebugWind(angle, intensity);

                Player localPlayer = GetLocalPlayer();
                string message     = $"Wind has been changed to angle {angle} with intensity {intensity}";

                localPlayer.Message(MessageHud.MessageType.Center, message);
                Console.WriteLine(message);
            }));

            Console.RegisterCommand("teleport_coord", "Teleport to coord.", new ConsoleCommandCallback((args) =>
            {
                if (args.Count != 3)
                {
                    Console.WriteLine($"Usage: teleport_coord [x] [y] [z]");
                    return;
                }

                int[] coords = { 0, 0, 0 };
                for (int i = 0; i < coords.Length; i++)
                {
                    if (!int.TryParse(args[i], out coords[i]))
                    {
                        Console.WriteLine("Invalid input!");
                        return;
                    }
                }

                Player localPlayer = GetLocalPlayer();
                localPlayer.TeleportTo(new Vector3(coords[0], coords[1], coords[2]), localPlayer.transform.rotation, true);
                string message = $"Teleported to coord: {coords[0]} {coords[1]} {coords[2]}";

                localPlayer.Message(MessageHud.MessageType.Center, message);
                Console.WriteLine(message);
            }));

            Console.RegisterCommand("teleport_player", "Teleport to the given player.", new ConsoleCommandCallback((args) =>
            {
                if (args.Count == 0)
                {
                    Console.WriteLine("Usage: teleport_player [name]");
                    return;
                }

                Player targetPlayer = GetPlayerFromName(args[0]);
                if (targetPlayer == null)
                {
                    Console.WriteLine($"No player found with name {args[0]}");
                    return;
                }

                Player localPlayer = GetLocalPlayer();
                localPlayer.TeleportTo(targetPlayer.transform.position, targetPlayer.transform.rotation, true);
                string message = $"Teleported to player: {targetPlayer.GetPlayerName()}";

                Console.WriteLine(message);
                localPlayer.Message(MessageHud.MessageType.Center, message);
            }));

            Console.RegisterCommand("teleport_restrict", "Disable teleport restrictions for every item in your inventory.", new ConsoleCommandCallback((args) =>
            {
                if (args.Count == 0)
                {
                    Console.WriteLine($"Usage: teleport_restrict [value]\nCurrent value: {Teleportable}");
                    return;
                }

                if (!bool.TryParse(args[0], out Teleportable))
                {
                    Console.WriteLine("Invalid input!");
                    return;
                }

                Console.WriteLine($"No teleport restrict is now {Teleportable}");
                GetLocalPlayer()?.Message(MessageHud.MessageType.Center, $"No teleport restrict is now {Teleportable}");
            }));

            Console.RegisterCommand("no_cost", "Toggle no cost.", new ConsoleCommandCallback((args) =>
            {
                if (args.Count == 0)
                {
                    Console.WriteLine($"Usage: no_cost [value]\nCurrent value: {NoCost}");
                    return;
                }

                if (!bool.TryParse(args[0], out NoCost))
                {
                    Console.WriteLine("Invalid input!");
                    return;
                }

                Console.WriteLine($"No cost is now {NoCost}");
                GetLocalPlayer()?.Message(MessageHud.MessageType.Center, $"No cost is now {NoCost}");
            }));

            Console.RegisterCommand("player_list", "Prints the available players.", new ConsoleCommandCallback((args) =>
            {
                ListPlayers();
            }));

            Console.RegisterCommand("prefab_dump", "Dump prefabs to file 'prefabs_dump.txt'. (inside Valheim's folder)", new ConsoleCommandCallback((args) =>
            {
                DumpPrefabs();
            }));

            Console.RegisterCommand("prefab_spawn", "Spawn any game prefab. (Items, mobs, etc.)", new ConsoleCommandCallback((args) =>
            {
                if (args.Count != 3)
                {
                    Console.WriteLine($"Usage: prefab_spawn [prefab_name] [amount] [level]");
                    return;
                }

                GameObject prefab = ZNetScene.instance.GetPrefab(args[0]);
                if (prefab == null)
                {
                    Console.WriteLine("Invalid prefab!\nFor prefab names, use 'prefab_dump'");
                    return;
                }

                if (!int.TryParse(args[1], out int amount))
                {
                    Console.WriteLine("Invalid input!");
                    return;
                }

                if (amount < 1)
                {
                    return;
                }

                if (!int.TryParse(args[2], out int level))
                {
                    Console.WriteLine("Invalid input!");
                    return;
                }

                try
                {
                    Player localPlayer = GetLocalPlayer();
                    DateTime now       = DateTime.Now;

                    for (int i = 0; i < amount; i++)
                    {
                        Character component = UnityEngine.Object.Instantiate <GameObject>(prefab, localPlayer.transform.position + localPlayer.transform.forward * 2.0f + Vector3.up + (UnityEngine.Random.insideUnitSphere * 0.5f), Quaternion.identity).GetComponent <Character>();

                        if (component & level > 1)
                        {
                            component.SetLevel(level);
                        }
                    }

                    string message = $"Spawned x{amount} of {prefab.name} (Level {level})";
                    localPlayer.Message(MessageHud.MessageType.Center, message);
                    Console.WriteLine(message + $" in {(DateTime.Now - now).TotalMilliseconds} ms");
                } catch (Exception ex)
                {
                    Console.Debug(ex);
                }
            }));

            Console.RegisterCommand("font_size", "Set console font size.", new ConsoleCommandCallback((args) =>
            {
                if (args.Count == 0)
                {
                    Console.WriteLine($"Usage: font_size [size]\nCurrent Value: {Console.GetFontSize()}");
                    return;
                }

                int size = Console.GetFontSize();
                if (!int.TryParse(args[0], out size))
                {
                    Console.WriteLine("Invalid input!");
                    return;
                }

                Console.SetFontSize(size);
                Console.WriteLine($"Changed console font size to {size}");
            }));

            Console.RegisterCommand("font_color", "Set console font color.", new ConsoleCommandCallback((args) =>
            {
                if (args.Count == 0)
                {
                    Console.WriteLine($"Usage: font_color [color]\nAvailable Colors: blue white black yellow cyan grey gray green clear magenta red");
                    return;
                }

                try
                {
                    var colorField = typeof(Color).GetProperty(args[0]);
                    if (colorField != null)
                    {
                        Console.SetFontColor((Color)colorField.GetValue(null));
                        Console.WriteLine($"Changed console font color to {args[0]}");
                    }
                } catch (Exception ex)
                {
                    Console.Debug(ex);
                }
            }));

            Console.RegisterCommand("inventory_carryweight", "Set the maximum inventory weight limit.", new ConsoleCommandCallback((args) =>
            {
                if (args.Count == 0)
                {
                    Console.WriteLine($"Usage: inventory_carryweight [weight]\nCurrent value: {CarryWeight}");
                    return;
                }

                if (!int.TryParse(args[0], out CarryWeight))
                {
                    Console.WriteLine("Invalid input!");
                    return;
                }

                Console.WriteLine($"Carry weight limit has been changed to {CarryWeight}");
            }));

            Console.RegisterCommand("inventory_height", "Set the inventory height. (aka more slots)", new ConsoleCommandCallback((args) =>
            {
                if (args.Count == 0)
                {
                    Console.WriteLine($"Usage: inventory_height [height]\nCurrent value: {InventoryHeight}");
                    return;
                }

                if (!int.TryParse(args[0], out InventoryHeight))
                {
                    Console.WriteLine("Invalid input!");
                    return;
                }

                Console.WriteLine($"Inventory height has been changed to {InventoryHeight}");
            }));

            Console.RegisterCommand("clear", "Clear the console output.", new ConsoleCommandCallback((args) =>
            {
                Console.Clear();
            }));

            Console.RegisterCommand("quit", "Quit from the game.", new ConsoleCommandCallback((args) =>
            {
                Application.Quit();
            }));

            Console.RegisterCommand("exec", "Execute configuration file. (Relative .cfg path from Valheim folder)", new ConsoleCommandCallback((args) =>
            {
                if (args.Count == 0)
                {
                    Console.WriteLine($"Usage: exec [path]");
                    return;
                }

                Console.LoadConfig(args[0]);
            }));

            Console.RegisterCommand("equip_toggle", "Toggle instant equip.", new ConsoleCommandCallback((args) =>
            {
                if (args.Count == 0)
                {
                    Console.WriteLine($"Usage: equip_toggle [value]\nCurrent value: {InstaEquip}");
                    return;
                }

                if (!bool.TryParse(args[0], out InstaEquip))
                {
                    Console.WriteLine("Invalid input!");
                    return;
                }

                Console.WriteLine($"Instant equip is now {InstaEquip}");
                GetLocalPlayer()?.Message(MessageHud.MessageType.Center, $"Instant equip is now {InstaEquip}");
            }));

            Console.RegisterCommand("stamina_toggle", "Toggle infinite stamina.", new ConsoleCommandCallback((args) =>
            {
                if (args.Count == 0)
                {
                    Console.WriteLine($"Usage: stamina_toggle [value]\nCurrent value: {UnlimitedStamina}");
                    return;
                }

                if (!bool.TryParse(args[0], out UnlimitedStamina))
                {
                    Console.WriteLine("Invalid input!");
                    return;
                }

                Console.WriteLine($"Infinite stamina is now {UnlimitedStamina}");
                GetLocalPlayer()?.Message(MessageHud.MessageType.Center, $"Infinite stamina is now {UnlimitedStamina}");
            }));

            Console.RegisterCommand("comfort_level", "Set the comfort level.", new ConsoleCommandCallback((args) =>
            {
                if (args.Count == 0)
                {
                    Console.WriteLine($"Usage: comfort_level [value]\nCurrent value: {ComfortLevel}");
                    return;
                }

                if (!int.TryParse(args[0], out ComfortLevel))
                {
                    Console.WriteLine("Invalid input!");
                    return;
                }

                Console.WriteLine($"Comfort level is now {ComfortLevel}");
                GetLocalPlayer()?.Message(MessageHud.MessageType.Center, $"Comfort level is now {ComfortLevel}");
            }));

            Console.RegisterCommand("roof_state", "Set roof state.", new ConsoleCommandCallback((args) =>
            {
                if (args.Count == 0)
                {
                    Console.WriteLine($"Usage: comfort_level [value]\nCurrent value: {Roof}");
                    return;
                }

                if (!bool.TryParse(args[0], out Roof))
                {
                    Console.WriteLine("Invalid input!");
                    return;
                }

                Console.WriteLine($"Roof state is now {Roof}");
                GetLocalPlayer()?.Message(MessageHud.MessageType.Center, $"Roof state is now {Roof}");
            }));

            Console.RegisterCommand("guardian_cooldown", "Toggle guardian cooldown.", new ConsoleCommandCallback((args) =>
            {
                if (args.Count == 0)
                {
                    Console.WriteLine($"Usage: guardian_cooldown [value]\nCurrent value: {NoGuardianCd}");
                    return;
                }

                if (!bool.TryParse(args[0], out NoGuardianCd))
                {
                    Console.WriteLine("Invalid input!");
                    return;
                }

                Console.WriteLine($"Disable guardian cooldown is now {NoGuardianCd}");
                GetLocalPlayer()?.Message(MessageHud.MessageType.Center, $"Disable guardian cooldown is now {NoGuardianCd}");
            }));

            Console.RegisterCommand("guardian_power", "Set guardian power to any status effect.", new ConsoleCommandCallback((args) =>
            {
                if (args.Count == 0)
                {
                    Console.WriteLine($"Usage: guardian_power [name]\nCurrent value: {GuardianPower}\nAvailable Status Effects: {GetStatusEffectNames()}");
                    return;
                }

                foreach (var i in ObjectDB.instance.m_StatusEffects)
                {
                    if (i.name == args[0])
                    {
                        GuardianPower = args[0];
                        Console.WriteLine($"Guardian power has been changed to {GuardianPower}");
                        GetLocalPlayer()?.Message(MessageHud.MessageType.Center, $"Guardian power has been changed to {GuardianPower}");
                        return;
                    }
                }

                Console.WriteLine("Invalid status effect name!");
            }));

            Console.RegisterCommand("guardian_start", "Force start guardian power.", new ConsoleCommandCallback((args) =>
            {
                Player localPlayer = GetLocalPlayer();
                if (localPlayer == null)
                {
                    Console.WriteLine("Not in-game");
                    return;
                }

                if (localPlayer.StartGuardianPower())
                {
                    Console.WriteLine("Force started guardian power.");
                    GetLocalPlayer()?.Message(MessageHud.MessageType.Center, "Force started guardian power.");
                }
                else
                {
                    Console.WriteLine("No guaridan power is equipped or coudln't force start it!");
                }
            }));

            Console.RegisterCommand("add_status_effect", "Add status effect.", new ConsoleCommandCallback((args) =>
            {
                if (args.Count == 0)
                {
                    Console.WriteLine($"Usage: add_status_effect [name]\nAvailable Status Effects: {GetStatusEffectNames()}");
                    return;
                }

                Player localPlayer = GetLocalPlayer();
                if (localPlayer == null)
                {
                    Console.WriteLine("Not in-game");
                    return;
                }

                foreach (var i in ObjectDB.instance.m_StatusEffects)
                {
                    if (i.name == args[0])
                    {
                        AddStatusEffect(args[0]);
                        Console.WriteLine($"Added status effect {args[0]}");
                        GetLocalPlayer()?.Message(MessageHud.MessageType.Center, $"Added status effect {args[0]}");
                        return;
                    }
                }

                Console.WriteLine("Invalid status effect name!");
                GetLocalPlayer()?.Message(MessageHud.MessageType.Center, "Invalid status effect name!");
            }));

            Console.RegisterCommand("set_keybind", "Set keybind to execute command", new ConsoleCommandCallback((args) =>
            {
                if (args.Count == 0)
                {
                    Console.WriteLine($"Usage: set_keybind [keycode]\nAvailable keycodes: https://docs.unity3d.com/ScriptReference/KeyCode.html");
                    return;
                }

                KeyCode keyCode = KeyCode.None;
                foreach (var i in Enum.GetValues(typeof(KeyCode)))
                {
                    if (i.ToString().ToLower() == args[0])
                    {
                        keyCode = (KeyCode)i;
                    }
                }

                if (keyCode != KeyCode.None)
                {
                    string buffer = "";
                    for (int i = 1; i < args.Count; i++)
                    {
                        buffer += args[i] + " ";
                    }

                    Keybinds[keyCode] = buffer;
                }
                else
                {
                    Console.WriteLine("Invalid keycode!");
                }
            }));

            SendHudMessage("DURANDA LOADED");

            Console.LoadConfig();
        }
Example #4
0
    // Token: 0x060004D0 RID: 1232 RVA: 0x00026ED4 File Offset: 0x000250D4
    private void InputText()
    {
        string text = this.m_input.text;

        this.AddString(text);
        string[] array = text.Split(new char[]
        {
            ' '
        });
        if (text.StartsWith("help"))
        {
            this.AddString("kick [name/ip/userID] - kick user");
            this.AddString("ban [name/ip/userID] - ban user");
            this.AddString("unban [ip/userID] - unban user");
            this.AddString("banned - list banned users");
            this.AddString("ping - ping server");
            this.AddString("lodbias - set distance lod bias");
            this.AddString("info - print system info");
            this.AddString("save - force saving of world");
            if (this.IsCheatsEnabled())
            {
                this.AddString("genloc - regenerate all locations.");
                this.AddString("debugmode - fly mode");
                this.AddString("spawn [amount] [level] - spawn something");
                this.AddString("pos - print current player position");
                this.AddString("goto [x,z]- teleport");
                this.AddString("exploremap - explore entire map");
                this.AddString("resetmap - reset map exploration");
                this.AddString("killall - kill nearby enemies");
                this.AddString("tame - tame all nearby tameable creatures");
                this.AddString("hair");
                this.AddString("beard");
                this.AddString("location - spawn location");
                this.AddString("raiseskill [skill] [amount]");
                this.AddString("resetskill [skill]");
                this.AddString("freefly - freefly photo mode");
                this.AddString("ffsmooth - freefly smoothness");
                this.AddString("tod -1 OR [0-1]");
                this.AddString("env [env]");
                this.AddString("resetenv");
                this.AddString("wind [angle] [intensity]");
                this.AddString("resetwind");
                this.AddString("god");
                this.AddString("event [name] - start event");
                this.AddString("stopevent - stop current event");
                this.AddString("randomevent");
                this.AddString("resetcharacter - reset character data");
                this.AddString("removedrops - remove all item-drops in area");
                this.AddString("setkey [name]");
                this.AddString("resetkeys [name]");
                this.AddString("listkeys");
                this.AddString("players [nr] - force diffuculty scale ( 0 = reset)");
                this.AddString("dpsdebug - toggle dps debug print");
            }
        }
        if (array[0] == "devcommands")
        {
            this.m_cheat = !this.m_cheat;
            this.AddString("Dev commands: " + this.m_cheat.ToString());
            this.AddString("WARNING: using any dev commands is not recommended and is done on your own risk.");
            Gogan.LogEvent("Cheat", "CheatsEnabled", this.m_cheat.ToString(), 0L);
            return;
        }
        if (array[0] == "hidebetatext" && Hud.instance)
        {
            Hud.instance.ToggleBetaTextVisible();
        }
        if (array[0] == "ping")
        {
            if (Game.instance)
            {
                Game.instance.Ping();
            }
            return;
        }
        if (array[0] == "dpsdebug")
        {
            Character.SetDPSDebug(!Character.IsDPSDebugEnabled());
            this.AddString("DPS debug " + Character.IsDPSDebugEnabled().ToString());
        }
        if (!(array[0] == "lodbias"))
        {
            if (array[0] == "info")
            {
                this.Print("Render threading mode:" + SystemInfo.renderingThreadingMode);
                long totalMemory = GC.GetTotalMemory(false);
                this.Print("Total allocated mem: " + (totalMemory / 1048576L).ToString("0") + "mb");
            }
            if (array[0] == "gc")
            {
                long totalMemory2 = GC.GetTotalMemory(false);
                GC.Collect();
                long totalMemory3 = GC.GetTotalMemory(true);
                long num          = totalMemory3 - totalMemory2;
                this.Print(string.Concat(new string[]
                {
                    "GC collect, Delta: ",
                    (num / 1048576L).ToString("0"),
                    "mb   Total left:",
                    (totalMemory3 / 1048576L).ToString("0"),
                    "mb"
                }));
            }
            if (array[0] == "fov")
            {
                Camera mainCamera = Utils.GetMainCamera();
                if (mainCamera)
                {
                    float num2;
                    if (array.Length == 1)
                    {
                        this.Print("Fov:" + mainCamera.fieldOfView);
                    }
                    else if (float.TryParse(array[1], NumberStyles.Float, CultureInfo.InvariantCulture, out num2) && num2 > 5f)
                    {
                        this.Print("Setting fov to " + num2);
                        Camera[] componentsInChildren = mainCamera.GetComponentsInChildren <Camera>();
                        for (int i = 0; i < componentsInChildren.Length; i++)
                        {
                            componentsInChildren[i].fieldOfView = num2;
                        }
                    }
                }
            }
            if (ZNet.instance)
            {
                if (text.StartsWith("kick "))
                {
                    string user = text.Substring(5);
                    ZNet.instance.Kick(user);
                    return;
                }
                if (text.StartsWith("ban "))
                {
                    string user2 = text.Substring(4);
                    ZNet.instance.Ban(user2);
                    return;
                }
                if (text.StartsWith("unban "))
                {
                    string user3 = text.Substring(6);
                    ZNet.instance.Unban(user3);
                    return;
                }
                if (text.StartsWith("banned"))
                {
                    ZNet.instance.PrintBanned();
                    return;
                }
                if (array.Length != 0 && array[0] == "save")
                {
                    ZNet.instance.ConsoleSave();
                }
            }
            if (ZNet.instance && ZNet.instance.IsServer() && Player.m_localPlayer && this.IsCheatsEnabled())
            {
                if (array[0] == "genloc")
                {
                    ZoneSystem.instance.GenerateLocations();
                    return;
                }
                if (array[0] == "players" && array.Length >= 2)
                {
                    int num3;
                    if (int.TryParse(array[1], out num3))
                    {
                        Game.instance.SetForcePlayerDifficulty(num3);
                        this.Print("Setting players to " + num3);
                    }
                    return;
                }
                if (array[0] == "setkey")
                {
                    if (array.Length >= 2)
                    {
                        ZoneSystem.instance.SetGlobalKey(array[1]);
                        this.Print("Setting global key " + array[1]);
                    }
                    else
                    {
                        this.Print("Syntax: setkey [key]");
                    }
                }
                if (array[0] == "resetkeys")
                {
                    ZoneSystem.instance.ResetGlobalKeys();
                    this.Print("Global keys cleared");
                }
                if (array[0] == "listkeys")
                {
                    List <string> globalKeys = ZoneSystem.instance.GetGlobalKeys();
                    this.Print("Keys " + globalKeys.Count);
                    foreach (string text2 in globalKeys)
                    {
                        this.Print(text2);
                    }
                }
                if (array[0] == "debugmode")
                {
                    Player.m_debugMode = !Player.m_debugMode;
                    this.Print("Debugmode " + Player.m_debugMode.ToString());
                }
                if (array[0] == "raiseskill")
                {
                    if (array.Length > 2)
                    {
                        string name = array[1];
                        int    num4 = int.Parse(array[2]);
                        Player.m_localPlayer.GetSkills().CheatRaiseSkill(name, (float)num4);
                        return;
                    }
                    this.Print("Syntax: raiseskill [skill] [amount]");
                    return;
                }
                else if (array[0] == "resetskill")
                {
                    if (array.Length > 1)
                    {
                        string name2 = array[1];
                        Player.m_localPlayer.GetSkills().CheatResetSkill(name2);
                        return;
                    }
                    this.Print("Syntax: resetskill [skill]");
                    return;
                }
                else
                {
                    if (text == "sleep")
                    {
                        EnvMan.instance.SkipToMorning();
                        return;
                    }
                    if (array[0] == "skiptime")
                    {
                        double num5 = ZNet.instance.GetTimeSeconds();
                        float  num6 = 240f;
                        if (array.Length > 1)
                        {
                            num6 = float.Parse(array[1]);
                        }
                        num5 += (double)num6;
                        ZNet.instance.SetNetTime(num5);
                        this.Print(string.Concat(new object[]
                        {
                            "Skipping ",
                            num6.ToString("0"),
                            "s , Day:",
                            EnvMan.instance.GetDay(num5)
                        }));
                        return;
                    }
                    if (text == "resetcharacter")
                    {
                        this.AddString("Reseting character");
                        Player.m_localPlayer.ResetCharacter();
                        return;
                    }
                    if (array[0] == "randomevent")
                    {
                        RandEventSystem.instance.StartRandomEvent();
                    }
                    if (text.StartsWith("event "))
                    {
                        if (array.Length <= 1)
                        {
                            return;
                        }
                        string text3 = text.Substring(6);
                        if (!RandEventSystem.instance.HaveEvent(text3))
                        {
                            this.Print("Random event not found:" + text3);
                            return;
                        }
                        RandEventSystem.instance.SetRandomEventByName(text3, Player.m_localPlayer.transform.position);
                        return;
                    }
                    else
                    {
                        if (array[0] == "stopevent")
                        {
                            RandEventSystem.instance.ResetRandomEvent();
                            return;
                        }
                        if (text.StartsWith("removedrops"))
                        {
                            this.AddString("Removing item drops");
                            ItemDrop[] array2 = UnityEngine.Object.FindObjectsOfType <ItemDrop>();
                            for (int i = 0; i < array2.Length; i++)
                            {
                                ZNetView component = array2[i].GetComponent <ZNetView>();
                                if (component && component.IsValid() && component.IsOwner())
                                {
                                    component.Destroy();
                                }
                            }
                        }
                        if (text.StartsWith("freefly"))
                        {
                            this.Print("Toggling free fly camera");
                            GameCamera.instance.ToggleFreeFly();
                            return;
                        }
                        if (array[0] == "ffsmooth")
                        {
                            if (array.Length <= 1)
                            {
                                this.Print(GameCamera.instance.GetFreeFlySmoothness().ToString());
                                return;
                            }
                            float num7;
                            if (!float.TryParse(array[1], NumberStyles.Float, CultureInfo.InvariantCulture, out num7))
                            {
                                this.Print("syntax error");
                                return;
                            }
                            this.Print("Setting free fly camera smoothing:" + num7);
                            GameCamera.instance.SetFreeFlySmoothness(num7);
                            return;
                        }
                        else
                        {
                            if (text.StartsWith("location "))
                            {
                                if (array.Length <= 1)
                                {
                                    return;
                                }
                                string  name3 = text.Substring(9);
                                Vector3 pos   = Player.m_localPlayer.transform.position + Player.m_localPlayer.transform.forward * 10f;
                                ZoneSystem.instance.TestSpawnLocation(name3, pos);
                            }
                            if (array[0] == "spawn")
                            {
                                if (array.Length <= 1)
                                {
                                    return;
                                }
                                string     text4  = array[1];
                                int        num8   = (array.Length >= 3) ? int.Parse(array[2]) : 1;
                                int        num9   = (array.Length >= 4) ? int.Parse(array[3]) : 1;
                                GameObject prefab = ZNetScene.instance.GetPrefab(text4);
                                if (!prefab)
                                {
                                    Player.m_localPlayer.Message(MessageHud.MessageType.TopLeft, "Missing object " + text4, 0, null);
                                    return;
                                }
                                DateTime now = DateTime.Now;
                                if (num8 == 1)
                                {
                                    Player.m_localPlayer.Message(MessageHud.MessageType.TopLeft, "Spawning object " + text4, 0, null);
                                    Character component2 = UnityEngine.Object.Instantiate <GameObject>(prefab, Player.m_localPlayer.transform.position + Player.m_localPlayer.transform.forward * 2f + Vector3.up, Quaternion.identity).GetComponent <Character>();
                                    if (component2 & num9 > 1)
                                    {
                                        component2.SetLevel(num9);
                                    }
                                }
                                else
                                {
                                    for (int j = 0; j < num8; j++)
                                    {
                                        Vector3 b = UnityEngine.Random.insideUnitSphere * 0.5f;
                                        Player.m_localPlayer.Message(MessageHud.MessageType.TopLeft, "Spawning object " + text4, 0, null);
                                        Character component3 = UnityEngine.Object.Instantiate <GameObject>(prefab, Player.m_localPlayer.transform.position + Player.m_localPlayer.transform.forward * 2f + Vector3.up + b, Quaternion.identity).GetComponent <Character>();
                                        if (component3 & num9 > 1)
                                        {
                                            component3.SetLevel(num9);
                                        }
                                    }
                                }
                                ZLog.Log("Spawn time :" + (DateTime.Now - now).TotalMilliseconds + " ms");
                                Gogan.LogEvent("Cheat", "Spawn", text4, (long)num8);
                                return;
                            }
                            else
                            {
                                if (array[0] == "pos")
                                {
                                    Player localPlayer = Player.m_localPlayer;
                                    if (localPlayer)
                                    {
                                        this.AddString("Player position (X,Y,Z):" + localPlayer.transform.position.ToString("F0"));
                                    }
                                }
                                if (text.StartsWith("goto "))
                                {
                                    string text5     = text.Substring(5);
                                    char[] separator = new char[]
                                    {
                                        ',',
                                        ' '
                                    };
                                    string[] array3 = text5.Split(separator);
                                    if (array3.Length < 2)
                                    {
                                        this.AddString("Syntax /goto x,y");
                                        return;
                                    }
                                    try
                                    {
                                        float  x            = float.Parse(array3[0]);
                                        float  z            = float.Parse(array3[1]);
                                        Player localPlayer2 = Player.m_localPlayer;
                                        if (localPlayer2)
                                        {
                                            Vector3 pos2 = new Vector3(x, localPlayer2.transform.position.y, z);
                                            localPlayer2.TeleportTo(pos2, localPlayer2.transform.rotation, true);
                                        }
                                    }
                                    catch (Exception ex)
                                    {
                                        ZLog.Log("parse error:" + ex.ToString() + "  " + text5);
                                    }
                                    Gogan.LogEvent("Cheat", "Goto", "", 0L);
                                    return;
                                }
                                else
                                {
                                    if (text.StartsWith("exploremap"))
                                    {
                                        Minimap.instance.ExploreAll();
                                        return;
                                    }
                                    if (text.StartsWith("resetmap"))
                                    {
                                        Minimap.instance.Reset();
                                        return;
                                    }
                                    if (text.StartsWith("puke") && Player.m_localPlayer)
                                    {
                                        Player.m_localPlayer.ClearFood();
                                    }
                                    if (text.StartsWith("tame"))
                                    {
                                        Tameable.TameAllInArea(Player.m_localPlayer.transform.position, 20f);
                                    }
                                    if (text.StartsWith("killall"))
                                    {
                                        foreach (Character character in Character.GetAllCharacters())
                                        {
                                            if (!character.IsPlayer())
                                            {
                                                HitData hitData = new HitData();
                                                hitData.m_damage.m_damage = 1E+10f;
                                                character.Damage(hitData);
                                            }
                                        }
                                        return;
                                    }
                                    if (text.StartsWith("heal"))
                                    {
                                        Player.m_localPlayer.Heal(Player.m_localPlayer.GetMaxHealth(), true);
                                        return;
                                    }
                                    if (text.StartsWith("god"))
                                    {
                                        Player.m_localPlayer.SetGodMode(!Player.m_localPlayer.InGodMode());
                                        this.Print("God mode:" + Player.m_localPlayer.InGodMode().ToString());
                                        Gogan.LogEvent("Cheat", "God", Player.m_localPlayer.InGodMode().ToString(), 0L);
                                    }
                                    if (text.StartsWith("ghost"))
                                    {
                                        Player.m_localPlayer.SetGhostMode(!Player.m_localPlayer.InGhostMode());
                                        this.Print("Ghost mode:" + Player.m_localPlayer.InGhostMode().ToString());
                                        Gogan.LogEvent("Cheat", "Ghost", Player.m_localPlayer.InGhostMode().ToString(), 0L);
                                    }
                                    if (text.StartsWith("beard"))
                                    {
                                        string beard = (text.Length >= 6) ? text.Substring(6) : "";
                                        if (Player.m_localPlayer)
                                        {
                                            Player.m_localPlayer.SetBeard(beard);
                                        }
                                        return;
                                    }
                                    if (text.StartsWith("hair"))
                                    {
                                        string hair = (text.Length >= 5) ? text.Substring(5) : "";
                                        if (Player.m_localPlayer)
                                        {
                                            Player.m_localPlayer.SetHair(hair);
                                        }
                                        return;
                                    }
                                    if (text.StartsWith("model "))
                                    {
                                        string s = text.Substring(6);
                                        int    playerModel;
                                        if (Player.m_localPlayer && int.TryParse(s, out playerModel))
                                        {
                                            Player.m_localPlayer.SetPlayerModel(playerModel);
                                        }
                                        return;
                                    }
                                    if (text.StartsWith("tod "))
                                    {
                                        float num10;
                                        if (!float.TryParse(text.Substring(4), NumberStyles.Float, CultureInfo.InvariantCulture, out num10))
                                        {
                                            return;
                                        }
                                        this.Print("Setting time of day:" + num10);
                                        if (num10 < 0f)
                                        {
                                            EnvMan.instance.m_debugTimeOfDay = false;
                                        }
                                        else
                                        {
                                            EnvMan.instance.m_debugTimeOfDay = true;
                                            EnvMan.instance.m_debugTime      = Mathf.Clamp01(num10);
                                        }
                                    }
                                    if (array[0] == "env" && array.Length > 1)
                                    {
                                        string text6 = text.Substring(4);
                                        this.Print("Setting debug enviornment:" + text6);
                                        EnvMan.instance.m_debugEnv = text6;
                                        return;
                                    }
                                    if (text.StartsWith("resetenv"))
                                    {
                                        this.Print("Reseting debug enviornment");
                                        EnvMan.instance.m_debugEnv = "";
                                        return;
                                    }
                                    if (array[0] == "wind" && array.Length == 3)
                                    {
                                        float angle     = float.Parse(array[1]);
                                        float intensity = float.Parse(array[2]);
                                        EnvMan.instance.SetDebugWind(angle, intensity);
                                    }
                                    if (array[0] == "resetwind")
                                    {
                                        EnvMan.instance.ResetDebugWind();
                                    }
                                }
                            }
                        }
                    }
                }
            }
            return;
        }
        if (array.Length == 1)
        {
            this.Print("Lod bias:" + QualitySettings.lodBias);
            return;
        }
        float num11;

        if (float.TryParse(array[1], NumberStyles.Float, CultureInfo.InvariantCulture, out num11))
        {
            this.Print("Setting lod bias:" + num11);
            QualitySettings.lodBias = num11;
        }
    }
Example #5
0
        static void Postfix(Console __instance)
        {
            string text = __instance.m_input.text;

            string[] array = text.Split(new char[]
                                        { ' ' });

            // do not enable unless we are on dedicated server
            if (__instance.IsCheatsEnabled() && !ZNet_Patch.m_isServer)
            {
                if (array[0] == "debugmode")
                {
                    Player.m_debugMode = !Player.m_debugMode;
                    __instance.Print("Debugmode " + Player.m_debugMode.ToString());
                }

                if (text.StartsWith("god"))
                {
                    Player.m_localPlayer.SetGodMode(!Player.m_localPlayer.InGodMode());
                    __instance.Print("God mode:" + Player.m_localPlayer.InGodMode().ToString());
                    Gogan.LogEvent("Cheat", "God", Player.m_localPlayer.InGodMode().ToString(), 0L);
                }

                if (array[0] == "raiseskill")
                {
                    if (array.Length > 2)
                    {
                        string name = array[1];
                        int    num4 = int.Parse(array[2]);
                        Player.m_localPlayer.GetSkills().CheatRaiseSkill(name, (float)num4);
                        return;
                    }
                    __instance.Print("Syntax: raiseskill [skill] [amount]");
                    return;
                }
                else if (array[0] == "resetskill")
                {
                    if (array.Length > 1)
                    {
                        string name2 = array[1];
                        Player.m_localPlayer.GetSkills().CheatResetSkill(name2);
                        return;
                    }
                    __instance.Print("Syntax: resetskill [skill]");
                    return;
                }

                if (text.StartsWith("exploremap"))
                {
                    Minimap.instance.ExploreAll();
                    return;
                }
                if (text.StartsWith("resetmap"))
                {
                    Minimap.instance.Reset();
                    return;
                }
                if (text.StartsWith("puke") && Player.m_localPlayer)
                {
                    Player.m_localPlayer.ClearFood();
                }
                if (text.StartsWith("tame"))
                {
                    Tameable.TameAllInArea(Player.m_localPlayer.transform.position, 20f);
                }
                if (text.StartsWith("killall"))
                {
                    foreach (Character character in Character.GetAllCharacters())
                    {
                        if (!character.IsPlayer())
                        {
                            HitData hitData = new HitData();
                            hitData.m_damage.m_damage = 1E+10f;
                            character.Damage(hitData);
                        }
                    }
                    return;
                }
                if (text.StartsWith("heal"))
                {
                    Player.m_localPlayer.Heal(Player.m_localPlayer.GetMaxHealth(), true);
                    return;
                }

                if (text.StartsWith("ghost"))
                {
                    Player.m_localPlayer.SetGhostMode(!Player.m_localPlayer.InGhostMode());
                    __instance.Print("Ghost mode:" + Player.m_localPlayer.InGhostMode().ToString());
                    Gogan.LogEvent("Cheat", "Ghost", Player.m_localPlayer.InGhostMode().ToString(), 0L);
                }

                if (text.StartsWith("removedrops"))
                {
                    __instance.Print("Removing item drops");
                    ItemDrop[] array2 = UnityEngine.Object.FindObjectsOfType <ItemDrop>();
                    for (int j = 0; j < array2.Length; j++)
                    {
                        ZNetView component = array2[j].GetComponent <ZNetView>();
                        if (component && component.IsValid() && component.IsOwner())
                        {
                            component.Destroy();
                        }
                    }
                }

                if (array[0] == "spawn")
                {
                    if (array.Length <= 1)
                    {
                        return;
                    }
                    string     text4  = array[1];
                    int        num8   = (array.Length >= 3) ? int.Parse(array[2]) : 1;
                    int        num9   = (array.Length >= 4) ? int.Parse(array[3]) : 1;
                    GameObject prefab = ZNetScene.instance.GetPrefab(text4);
                    if (!prefab)
                    {
                        Player.m_localPlayer.Message(MessageHud.MessageType.TopLeft, "Missing object " + text4, 0, null);
                        return;
                    }
                    DateTime now = DateTime.Now;
                    if (num8 == 1)
                    {
                        Player.m_localPlayer.Message(MessageHud.MessageType.TopLeft, "Spawning object " + text4, 0, null);
                        Character component2 = UnityEngine.Object.Instantiate <GameObject>(prefab, Player.m_localPlayer.transform.position + Player.m_localPlayer.transform.forward * 2f + Vector3.up, Quaternion.identity).GetComponent <Character>();
                        if (component2 & num9 > 1)
                        {
                            component2.SetLevel(num9);
                        }
                    }
                    else
                    {
                        for (int j = 0; j < num8; j++)
                        {
                            Vector3 vector = Random.insideUnitSphere * 0.5f;
                            Player.m_localPlayer.Message(MessageHud.MessageType.TopLeft, "Spawning object " + text4, 0, null);
                            Character component3 = UnityEngine.Object.Instantiate <GameObject>(prefab, Player.m_localPlayer.transform.position + Player.m_localPlayer.transform.forward * 2f + Vector3.up + vector, Quaternion.identity).GetComponent <Character>();
                            if (component3 & num9 > 1)
                            {
                                component3.SetLevel(num9);
                            }
                        }
                    }
                    Gogan.LogEvent("Cheat", "Spawn", text4, (long)num8);
                    return;
                }
            }

            return;
        }