Exemple #1
0
        private static void MMSpawnAs(ConCommandArgs args)
        {
            if (args.Count == 0)
            {
                return;
            }

            string character = GetBodyName(args[0]);

            if (character == null)
            {
                Debug.Log("Please use mmspawnlist to view all bodies");
                return;
            }

            GameObject newBody = BodyCatalog.FindBodyPrefab(character);

            if (args.sender == null && args.Count < 2)
            {
                Debug.Log("Error");
                return;
            }

            CharacterMaster master = args.sender?.master;

            if (args.Count > 1)
            {
                NetworkUser player = GetNetUserFromString(args.userArgs, 1);

                if (player != null)
                {
                    master = player.master;
                }

                else
                {
                    Debug.Log("User not found");
                    return;
                }
            }

            if (!master.GetBody())
            {
                Debug.Log("User is dead");
                return;
            }

            master.bodyPrefab = newBody;
            Debug.Log(args.sender.userName + " is spawning as " + character);
            RoR2.ConVar.BoolConVar stage1pod = ((RoR2.ConVar.BoolConVar)(typeof(Stage)).GetFieldCached("stage1PodConVar").GetValue(null));
            bool oldVal = stage1pod.value;

            stage1pod.SetBool(false);

            master.Respawn(master.GetBody().transform.position, master.GetBody().transform.rotation);
            stage1pod.SetBool(oldVal);
        }
Exemple #2
0
        private static void CCSpawnAs(ConCommandArgs args)
        {
            if (args.Count == 0)
            {
                Log.MessageNetworked(Lang.SPAWNAS_ARGS, args, LogLevel.MessageClientOnly);
                return;
            }
            string character = StringFinder.Instance.GetBodyName(args[0]);

            if (character == null)
            {
                Log.MessageNetworked(Lang.SPAWN_ERROR + args[0], args, LogLevel.MessageClientOnly);
                Log.MessageNetworked("Please use list_body to print CharacterBodies", args, LogLevel.MessageClientOnly);
                return;
            }
            GameObject newBody = BodyCatalog.FindBodyPrefab(character);

            if (args.sender == null && args.Count < 2)
            {
                Log.Message(Lang.DS_REQUIREFULLQUALIFY, LogLevel.Error);
                return;
            }

            CharacterMaster master = args.sender?.master;

            if (args.Count > 1)
            {
                NetworkUser player = Util.GetNetUserFromString(args.userArgs, 1);
                if (player != null)
                {
                    master = player.master;
                }
                else
                {
                    Log.MessageNetworked(Lang.PLAYER_NOTFOUND, args, LogLevel.MessageClientOnly);
                    return;
                }
            }

            if (!master.GetBody())
            {
                Log.MessageNetworked(Lang.PLAYER_DEADRESPAWN, args, LogLevel.MessageClientOnly);
                return;
            }

            master.bodyPrefab = newBody;
            Log.MessageNetworked(args.sender.userName + " is spawning as " + character, args);
            RoR2.ConVar.BoolConVar stage1pod = ((RoR2.ConVar.BoolConVar)(typeof(Stage)).GetFieldCached("stage1PodConVar").GetValue(null));
            bool oldVal = stage1pod.value;

            stage1pod.SetBool(false);

            master.Respawn(master.GetBody().transform.position, master.GetBody().transform.rotation);
            stage1pod.SetBool(oldVal);
        }