Esempio n. 1
0
        public static void Prefix(ExileController __instance, [HarmonyArgument(0)] ref GameData.PlayerInfo exiled, [HarmonyArgument(1)] bool tie)
        {
            // Shifter shift
            if (Shifter.shifter != null && AmongUsClient.Instance.AmHost && Shifter.futureShift != null)   // We need to send the RPC from the host here, to make sure that the order of shifting and erasing is correct (for that reason the futureShifted and futureErased are being synced)
            {
                MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.ShifterShift, Hazel.SendOption.Reliable, -1);
                writer.Write(Shifter.futureShift.PlayerId);
                AmongUsClient.Instance.FinishRpcImmediately(writer);
                RPCProcedure.shifterShift(Shifter.futureShift.PlayerId);
            }
            Shifter.futureShift = null;

            // Eraser erase
            if (Eraser.eraser != null && AmongUsClient.Instance.AmHost && Eraser.futureErased != null)    // We need to send the RPC from the host here, to make sure that the order of shifting and erasing is correct (for that reason the futureShifted and futureErased are being synced)
            {
                foreach (PlayerControl target in Eraser.futureErased)
                {
                    if (target != null)
                    {
                        MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.ErasePlayerRole, Hazel.SendOption.Reliable, -1);
                        writer.Write(target.PlayerId);
                        AmongUsClient.Instance.FinishRpcImmediately(writer);
                        RPCProcedure.erasePlayerRole(target.PlayerId);
                    }
                }
            }
            Eraser.futureErased = new List <PlayerControl>();

            // Trickster boxes
            if (Trickster.trickster != null && JackInTheBox.hasJackInTheBoxLimitReached())
            {
                JackInTheBox.convertToVents();
            }
        }
Esempio n. 2
0
 public static void Prefix(ExileController __instance, [HarmonyArgument(0)] ref GameData.PlayerInfo exiled, [HarmonyArgument(1)] bool tie)
 {
     if (exiled != null && exiled.Object == target)
     {
         OnTargetExiled();
     }
 }
Esempio n. 3
0
        public static void Postfix([HarmonyArgument(0)] GameData.PlayerInfo exiled, ExileController __instance)
        {
            RoleCheck a = new RoleCheck();

            foreach (PlayerControl player in PlayerControl.AllPlayerControls)
            {
                if (!PlayerControl.GameOptions.ConfirmImpostor)
                {
                    continue;
                }
                if (player.PlayerId != exiled.PlayerId)
                {
                    continue;
                }
                if (!a.isAnyRole(player.PlayerId))
                {
                    continue;
                }
                foreach (RoleGenerator role in allRoles)
                {
                    if (role.NameOfRole == player.getModdedControl().Role)
                    {
                        __instance.completeString = exiled.PlayerName + " " + role.EjectionText;
                    }
                }
            }
        }
Esempio n. 4
0
 public static void Postfix([HarmonyArgument(0)] GameData.PlayerInfo exiled, ExileController __instance)
 {
     foreach (PlayerControl player in PlayerControl.AllPlayerControls)
     {
         if (!PlayerControl.GameOptions.ConfirmImpostor)
         {
             continue;
         }
         if (player.PlayerId != exiled.PlayerId)
         {
             continue;
         }
         if (!player.isAnyRole())
         {
             continue;
         }
         foreach (RoleGenerator role in allRoles)
         {
             if (role.containedPlayerIds.Contains(player.PlayerId))
             {
                 __instance.completeString = exiled.PlayerName + " " + role.EjectionText;
             }
         }
     }
 }
Esempio n. 5
0
            public static void Postfix(ExileController __instance, GameData.PlayerInfo LNMDIKCFBAK)
            {
                int playersLeft = PlayerControl.AllPlayerControls.ToArray().Count(pc =>
                                                                                  pc.Data.IsDead || pc.Data.Disconnected) + (LNMDIKCFBAK != null ? 1 : 0);

                udpateBools(playersLeft);
            }
Esempio n. 6
0
        public override void MeetingEnd(ExileController Exile)
        {
            base.MeetingEnd(Exile);

            IsActive = false;
            TimeWarpCooldown.UpdateForExile(Exile);
            TasksCooldown.UpdateForExile(Exile);
        }
Esempio n. 7
0
 public static void Postfix(ExileController __instance, [HarmonyArgument(0)] GameData.Nested_1 exiled)
 {
     CustomRoles.TryGetValue(exiled.FMAAJCIEMEH, out var isJester);
     if (isJester)
     {
         __instance.ImpostorText.Text = "But they were the Jester.";
     }
 }
Esempio n. 8
0
        public override void MeetingEnd(ExileController Exile)
        {
            base.MeetingEnd(Exile);

            IsActive = false;
            InvisibleCooldown.UpdateForExile(Exile);
            DisguiseCooldown.UpdateForExile(Exile);
        }
Esempio n. 9
0
        /// <summary>
        /// Send a meeting end request using the HTTP client.
        /// </summary>
        /// <param name="exileController">The exile controller responsible for the meeting end.</param>
        private static void SendMeetingEndRequest(ExileController exileController)
        {
            var exiled = exileController.exiled;

            var gameData = GameData.Instance;

            if (gameData != null)
            {
                var players = gameData.AllPlayers;
                if (players != null)
                {
                    var crewCount     = 0;
                    var imposterCount = 0;

                    // Count how many of the alive players are impostor and crew mate
                    foreach (var player in players)
                    {
                        // Skip dead and the exiled player (if they exist)
                        if (player.IsDead || exiled != null && player.PlayerId == exiled.PlayerId)
                        {
                            continue;
                        }

                        if (player.Role.IsImpostor)
                        {
                            imposterCount++;
                        }
                        else
                        {
                            crewCount++;
                        }
                    }

                    // We skip sending the meeting end request, since this meeting will end the game
                    // Therefore, we prevent sending unnecessary requests
                    if (imposterCount == 0 || imposterCount >= crewCount)
                    {
                        return;
                    }
                }
            }

            if (exiled == null)
            {
                Log.LogMessage("Meeting has ended!");

                _httpClient.SendMeetingEndRequest();
            }
            else
            {
                var playerName = exiled.PlayerName;

                Log.LogMessage("Meeting has ended, exiled player: " + playerName + "!");

                _httpClient.SendMeetingEndRequest(playerName);
            }
        }
Esempio n. 10
0
 public static void Postfix(ExileController __instance, [HarmonyArgument(0)] GameData.PlayerInfo exiled)
 {
     AmongUsPlugin.customRoles.TryGetValue(exiled.PlayerId, out var roles);
     if (roles != null && roles.Contains(_instance))
     {
         //__instance.Field_9 = exiled.PlayerName + " was the " + Instance.Name;
         __instance.ImpostorText.Text = "But they were the " + _instance.Name;
     }
 }
Esempio n. 11
0
        public static void Prefix(ExileController __instance, [HarmonyArgument(0)] ref GameData.PlayerInfo exiled, [HarmonyArgument(1)] bool tie)
        {
            // Shifter shift
            if (Shifter.shifter != null && AmongUsClient.Instance.AmHost && Shifter.futureShift != null)   // We need to send the RPC from the host here, to make sure that the order of shifting and erasing is correct (for that reason the futureShifted and futureErased are being synced)
            {
                MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.ShifterShift, Hazel.SendOption.Reliable, -1);
                writer.Write(Shifter.futureShift.PlayerId);
                AmongUsClient.Instance.FinishRpcImmediately(writer);
                RPCProcedure.shifterShift(Shifter.futureShift.PlayerId);
            }
            Shifter.futureShift = null;

            // Eraser erase
            if (Eraser.eraser != null && AmongUsClient.Instance.AmHost && Eraser.futureErased != null)    // We need to send the RPC from the host here, to make sure that the order of shifting and erasing is correct (for that reason the futureShifted and futureErased are being synced)
            {
                foreach (PlayerControl target in Eraser.futureErased)
                {
                    if (target != null)
                    {
                        MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.ErasePlayerRole, Hazel.SendOption.Reliable, -1);
                        writer.Write(target.PlayerId);
                        AmongUsClient.Instance.FinishRpcImmediately(writer);
                        RPCProcedure.erasePlayerRole(target.PlayerId);
                    }
                }
            }
            Eraser.futureErased = new List <PlayerControl>();

            // Trickster boxes
            if (Trickster.trickster != null && JackInTheBox.hasJackInTheBoxLimitReached())
            {
                JackInTheBox.convertToVents();
            }

            // SecurityGuard vents and cameras
            var allCameras = ShipStatus.Instance.AllCameras.ToList();

            MapOptions.camerasToAdd.ForEach(camera => {
                camera.gameObject.SetActive(true);
                camera.gameObject.GetComponent <SpriteRenderer>().color = Color.white;
                allCameras.Add(camera);
            });
            ShipStatus.Instance.AllCameras = allCameras.ToArray();
            MapOptions.camerasToAdd        = new List <SurvCamera>();

            foreach (Vent vent in MapOptions.ventsToSeal)
            {
                PowerTools.SpriteAnim animator = vent.GetComponent <PowerTools.SpriteAnim>();
                animator?.Stop();
                vent.EnterVentAnim = vent.ExitVentAnim = null;
                vent.myRend.sprite = animator == null?SecurityGuard.getStaticVentSealedSprite() : SecurityGuard.getAnimatedVentSealedSprite();

                vent.myRend.color = Color.white;
                vent.name         = "SealedVent_" + vent.name;
            }
            MapOptions.ventsToSeal = new List <Vent>();
        }
Esempio n. 12
0
 public static void Postfix(ExileController __instance, [HarmonyArgument(0)] GameData.PlayerInfo target)
 {
     if (target.PlayerId == SetJesterPatch.Jester.PlayerId)
     {
         if (PlayerControl.GameOptions.ConfirmEjects)
         {
             __instance.Field_9 = $"{target.PlayerName} was the Jester!";
         }
     }
 }
Esempio n. 13
0
 public static void Postfix(ExileController __instance, [HarmonyArgument(0)] GameData.PlayerInfo target)
 {
     if (target != null && RoleInfo.IsRole(target, Roles.Jester))
     {
         if (PlayerControl.GameOptions.ConfirmImpostor)
         {
             __instance.completeString = $"{target.PlayerName} was the Jester.";
         }
     }
 }
Esempio n. 14
0
        public override void MeetingEnd(ExileController Exile)
        {
            base.MeetingEnd(Exile);

            StoneficationActive = false;
            StoneficationCooldown.UpdateForExile(Exile);
            StoneficationEffect.UpdateForExile(Exile);
            TranspositionCooldown.UpdateForExile(Exile);

            DisableStonefication();
        }
Esempio n. 15
0
 static void Postfix(ExileController __instance)
 {
     if (IsCultistUsed)
     {
         LastConversion = DateTime.UtcNow.AddMilliseconds(__instance.Duration);
         if (CheckCultistWin())
         {
             ExecuteCultistWin();
         }
     }
 }
Esempio n. 16
0
        private static bool Prefix(ExileController __instance)
        {
            bool isJester = __instance.exiled?.Is <JesterRole>() ?? false;

            if (isJester && AmongUsClient.Instance.AmHost)
            {
                PlayerControl.LocalPlayer.RpcCustomEndGame <JesterWon>();
            }

            return(!isJester); // don't make jester dead (why not)
        }
Esempio n. 17
0
 public static void Prefix(ExileController __instance)
 {
     if (__instance.exiled != null)
     {
         if (Helper.isJester(__instance.exiled.PlayerId))
         {
             CLog.Info("Jester Voted Out");
             __instance.completeString = __instance.exiled.PlayerName + " was the Jester";
             ShipStatus.RpcEndGame(GameOverReason.HumansByVote, false);
         }
     }
 }
Esempio n. 18
0
 public static void Postfix([HarmonyArgument(0)] GameData.PlayerInfo exiled, ExileController __instance)
 {
     if (Utils.Jester == null)
     {
         return;
     }
     if (exiled == null)
     {
         return;
     }
     if (exiled.PlayerId != Utils.Jester.PlayerId)
     {
         return;
     }
     EndCriteria.JesterVotedOut = true;
     JesterWins();
 }
Esempio n. 19
0
        public static void ExileControllerPostfix(ExileController __instance)
        {
            var exiled = __instance.exiled?.Object;

            if (!PlayerControl.LocalPlayer.Data.IsDead && exiled != PlayerControl.LocalPlayer)
            {
                return;
            }
            if (exiled == PlayerControl.LocalPlayer && PlayerControl.LocalPlayer.Is(RoleEnum.Jester))
            {
                return;
            }
            if (PlayerControl.LocalPlayer != WillBePhantom)
            {
                return;
            }

            if (!PlayerControl.LocalPlayer.Is(RoleEnum.Phantom))
            {
                Role.RoleDictionary.Remove(PlayerControl.LocalPlayer.PlayerId);
                var role = new Phantom(PlayerControl.LocalPlayer);
                role.RegenTask();

                RemoveTasks(PlayerControl.LocalPlayer);
                PlayerControl.LocalPlayer.MyPhysics.ResetMoveState();

                System.Console.WriteLine("Become Phantom - Phantom");

                PlayerControl.LocalPlayer.gameObject.layer = LayerMask.NameToLayer("Players");

                var writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId,
                                                                        (byte)CustomRPC.PhantomDied, SendOption.Reliable, -1);
                AmongUsClient.Instance.FinishRpcImmediately(writer);
            }

            if (Role.GetRole <Phantom>(PlayerControl.LocalPlayer).Caught)
            {
                return;
            }
            Vent startingVent =
                ShipStatus.Instance.AllVents[Random.RandomRangeInt(0, ShipStatus.Instance.AllVents.Count)];
            Vector3 destination = Utils.GetCoordinatesToSendPlayerToVent(startingVent);

            PlayerControl.LocalPlayer.NetTransform.RpcSnapTo(destination);
            PlayerControl.LocalPlayer.MyPhysics.RpcEnterVent(startingVent.Id);
        }
Esempio n. 20
0
        private static void Postfix(ExileController __instance)
        {
            var exiled = __instance.exiled;

            if (exiled == null)
            {
                return;
            }
            var player = exiled.Object;

            foreach (var role in Role.GetRoles(RoleEnum.Executioner))
            {
                if (player.PlayerId == ((Executioner)role).target.PlayerId)
                {
                    ((Executioner)role).Wins();
                }
            }
        }
Esempio n. 21
0
        public static void Postfix([HarmonyArgument(0)] GameData.PlayerInfo exiled, ExileController __instance)
        {
            if (exiled == null)
            {
                return;
            }
            var player = exiled.Object;

            var role = Role.GetRole(player);

            if (role == null)
            {
                return;
            }
            if (role.RoleType == RoleEnum.Child)
            {
                ((Child)role).Wins();
            }
        }
Esempio n. 22
0
        private static void Postfix(ExileController __instance)
        {
            var exiled = __instance.exiled;

            if (exiled == null)
            {
                return;
            }
            var player = exiled.Object;

            var role = Role.GetRole(player);

            if (role == null)
            {
                return;
            }
            if (role.RoleType == RoleEnum.Jester)
            {
                ((Jester)role).Wins();
            }
        }
Esempio n. 23
0
            public static void Postfix(ExileController __instance)
            {
                if (__instance.exiled == null)
                {
                    return;
                }
                var role = __instance.exiled.GetRole();

                if (role == null)
                {
                    return;
                }
                var revealRole = role.RevealExiledRole;

                if (revealRole != RevealRole.Never && (revealRole == RevealRole.Always ||
                                                       revealRole == RevealRole.Default &&
                                                       PlayerControl.GameOptions.ConfirmImpostor))
                {
                    __instance.completeString = $"{__instance.exiled.PlayerName} was {(role.Name.ToLower().StartsWith("the") ? "" : "The ")}{role.Name}.";
                }
            }
Esempio n. 24
0
        public static void Postfix(ExileController __instance)
        {
            if (ExtraRoles.ConfirmExtraRoles.GetValue() && !__instance.exiled.IsImpostor)
            {
                foreach (var Role in Role.ROLES)
                {
                    if (Role.Player == null)
                    {
                        continue;
                    }

                    if (Role.Player.PlayerId == __instance.exiled.PlayerId)
                    {
                        __instance.completeString += LanguageManager.Get($"er.{Role.Id}.exile");
                    }
                }
            }

            foreach (var Role in Role.ROLES)
            {
                Role.MeetingEnd(__instance);
            }
        }
Esempio n. 25
0
 static void Postfix(ExileController __instance)
 {
     System.Console.WriteLine("Meeting Ended!");
     OfficerSettings.lastKilled = DateTime.UtcNow.AddMilliseconds(__instance.Duration);
 }
Esempio n. 26
0
 public override void MeetingEnd(ExileController Exile)
 {
     base.MeetingEnd(Exile);
     IsActive = false;
 }
Esempio n. 27
0
 public virtual void MeetingEnd(ExileController Exile)
 {
     Cooldown?.UpdateForExile(Exile);
 }
Esempio n. 28
0
 public static void Prefix(ExileController __instance)
 {
     SendMeetingEndRequest(__instance);
 }
Esempio n. 29
0
 public static void Postfix(ExileController __instance) => ExileControllerPostfix(__instance);
Esempio n. 30
0
 public void UpdateForExile(ExileController Exile)
 {
     LastUsed = DateTime.UtcNow.AddMilliseconds(Exile.Duration);
 }