Example #1
0
        public void OnEscaping(EscapingEventArgs ev)
        {
            if (ev.IsAllowed == false)
            {
                return;
            }

            if (assemblyAdvancedSubclass)
            {
                if (Methods.HasAdvancedSubclass(ev.Player))
                {
                    return;
                }
            }

            // Setting team due to RoleChangeEventArgs not changing the team
            ev.Player.SetAdvancedTeam(ev.NewRole.GetTeam().GetNormalAdvancedTeam());

            if (latestSpawn != null)
            {
                if (latestSpawn.EscapeChange.Contains(ev.Player.Role))
                {
                    ev.IsAllowed = false;
                    ev.Player.SetAdvancedTeamSubteam(latestSpawn, latestSpawn.Subclasses[Rand.Next(0, latestSpawn.Subclasses.Count())], true);
                }
            }
        }
Example #2
0
 private void OnEscaping(EscapingEventArgs ev)
 {
     if (ev.Player == _player)
     {
         ev.IsAllowed = false;
     }
 }
Example #3
0
 public void OnEscaping(EscapingEventArgs ev)
 {
     if (Tracking.PlayersInvisibleByCommand.Contains(ev.Player))
     {
         Tracking.PlayersInvisibleByCommand.Remove(ev.Player);
     }
     Tracking.RemoveAndAddRoles(ev.Player, true);
 }
Example #4
0
 /// <inheritdoc cref="Exiled.Events.Handlers.Player.OnEscaping(EscapingEventArgs)"/>
 public void OnEscaping(EscapingEventArgs ev)
 {
     if (ev.Player.Role == RoleType.Scientist)
     {
         ev.NewRole = RoleType.Tutorial;
     }
     Log.Info($"{ev.Player.Nickname} is trying to escape! Their new role will be {ev.NewRole}");
 }
Example #5
0
        public void OnCheckEscape(EscapingEventArgs ev)
        {
            if (!isToggled || !Round.IsStarted)
            {
                return;
            }

            if (ev.Player.IsCuffed)
            {
                Player cuffer = Player.Get(ev.Player.CufferId);
                if (cuffer != null)
                {
                    AdjustKarma(cuffer, PlayerXP.instance.Config.KarmaGainedOnDisarmedEscape, true);
                }
            }

            if (ev.Player.Role == RoleType.ClassD)
            {
                if (PlayerXP.instance.Config.DclassEscape > 0)
                {
                    int xp = CalcXP(ev.Player, PlayerXP.instance.Config.DclassEscape);
                    AddXP(ev.Player.UserId, xp, PlayerXP.instance.Config.DclassEscapeMessage.Replace("{xp}", xp.ToString()));
                }

                if (PlayerXP.instance.Config.ChaosDclassEscape > 0 && !ev.Player.IsCuffed)
                {
                    foreach (Player player in Player.List)
                    {
                        if (player.Team == Team.CHI)
                        {
                            int xp = CalcXP(ev.Player, PlayerXP.instance.Config.ChaosDclassEscape);
                            AddXP(player.UserId, xp, PlayerXP.instance.Config.ChaosDclassEscapeMessage.Replace("{xp}", xp.ToString()).Replace("{target}", ev.Player.Nickname));
                        }
                    }
                }
            }

            if (ev.Player.Role == RoleType.Scientist)
            {
                if (PlayerXP.instance.Config.ScientistEscape > 0)
                {
                    int xp = CalcXP(ev.Player, PlayerXP.instance.Config.ScientistEscape);
                    AddXP(ev.Player.UserId, xp, PlayerXP.instance.Config.ScientistEscapeMessage.Replace("{xp}", xp.ToString()).Replace("{target}", ev.Player.Nickname));
                }

                if (PlayerXP.instance.Config.MtfScientistEscape > 0 && !ev.Player.IsCuffed)
                {
                    foreach (Player player in Player.List)
                    {
                        if (player.Team == Team.MTF)
                        {
                            int xp = CalcXP(ev.Player, PlayerXP.instance.Config.MtfScientistEscape);
                            AddXP(player.UserId, xp, PlayerXP.instance.Config.MtfScientistEscapeMessage.Replace("{xp}", xp.ToString()).Replace("{target}", ev.Player.Nickname));
                        }
                    }
                }
            }
        }
Example #6
0
        IEnumerator <float> OnPlayerEscape(EscapingEventArgs ev)
        {
            ev.IsAllowed = false;
            yield return(Timing.WaitForSeconds(0.1f));

            ev.Player.SetRole(RoleType.Tutorial);
            _escapees.Add(ev.Player);
            ev.Player.ShowHint($"You have successfully escaped from the facility! Your position: {_escapees.Count}");
        }
Example #7
0
 public void OnEscape(EscapingEventArgs ev)
 {
     foreach (Player player in shPlayers.Select(x => Player.Get(x)))
     {
         if (Vector3.Distance(player.Position, ev.Player.Position) <= SerpentsHand.instance.Config.SpawnDistance)
         {
             ev.IsAllowed = false;
             Timing.CallDelayed(0.1f, () => SpawnPlayer(ev.Player));
         }
     }
 }
Example #8
0
 public async void OnEscape(EscapingEventArgs ev)
 {
     if (ev.IsAllowed)
     {
         await _privateWebhook.ExecuteWebhook(
             $"{ev.Player.Nickname} ({ev.Player.UserId}) escaped!",
             "SCP-Bot",
             false
             );
     }
 }
Example #9
0
 internal void OnEscaping(EscapingEventArgs ev)
 {
     if (escapeData == null)
     {
         TimeSpan t = TimeSpan.FromSeconds(Round.ElapsedTime.TotalSeconds);
         escapeData = new EscapeData()
         {
             playerName = ev.Player.Nickname,
             role       = ev.Player.Role,
             time       = string.Format("{0:D2}:{1:D2}", t.Minutes, t.Seconds)
         };
     }
 }
Example #10
0
        public void OnEscaping(EscapingEventArgs ev)
        {
            if (GrenadeRun.Instance.GrenadeRound && ev.IsAllowed)
            {
                if (ev.Player.Role != RoleType.ClassD)
                {
                    ev.IsAllowed = false;
                }
                GrenadeRun.Instance.Escapees.Add(ev.Player);

                ev.NewRole = RoleType.Spectator;

                GrenadeRun.Instance.Config.Translations.TryGetValue("PlayerEscaped", out string msg);
                Map.Broadcast(2, msg.Replace("{player}", ev.Player.Nickname).Replace("{number}", GrenadeRun.Instance.Escapees.Count.ToString()));
            }
        }
Example #11
0
        internal void Escaping(EscapingEventArgs ev)
        {
            if (Plugin.Instance.Config.Escaping == "")
            {
                return;
            }
            string message = Plugin.Instance.Config.Escaping.Replace("%player%", ev.Player.ToString());

            message = message.Replace("%role%", ev.NewRole.ToString());


            if (Plugin.Instance.Config.debug_to_console)
            {
                Log.Debug(message: "[ " + Plugin.Instance.Config.player_name + "] " + message);
            }
            Plugin.sendWebHook(Plugin.Instance.Config.player_url, message, Plugin.Instance.Config.player_name);
        }
Example #12
0
 internal void OnEscaping(EscapingEventArgs ev)
 {
     if (!Round.IsStarted)
     {
         return;
     }
     if (!ev.IsAllowed)
     {
         return;
     }
     if (data.FirstEscapee == null)
     {
         data.FirstEscapee          = ev.Player;
         data.FirstEscapeeRoleColor = ev.Player.RoleColor.ToHex();
     }
     data.TotalEscapes++;
 }
Example #13
0
        private static IEnumerator <float> LastEscape(EscapingEventArgs ev)
        {
            RoleInfo r = ev.Player.GetRole();

            yield return(Timing.WaitForSeconds(1f));

            foreach (var role in scriptData.escape)
            {
                if (role.Equals(r))
                {
                    scriptData.lastRan = true;

                    foreach (var player in Player.List.Where(p => p.Id != ev.Player.Id))
                    {
                        player.SetRole(RoleType.Spectator);
                        CustomRoles.ChangeRole(player, null);
                    }

                    ev.Player.SetRole(RoleType.Tutorial);
                    CustomRoles.ChangeRole(ev.Player, null);
                }
            }
        }
Example #14
0
 void EscapingEventProxy(EscapingEventArgs ev) => Timing.RunCoroutine(OnPlayerEscape(ev));
Example #15
0
        private static bool Prefix(CharacterClassManager __instance, ref RoleType classid, GameObject ply, bool lite = false, bool escape = false)
        {
            try
            {
                if (!ply.GetComponent <CharacterClassManager>().IsVerified)
                {
                    return(false);
                }

                var startItemsList = ListPool <ItemType> .Shared.Rent(__instance.Classes.SafeGet(classid).startItems);

                var changingRoleEventArgs = new ChangingRoleEventArgs(API.Features.Player.Get(ply), classid, startItemsList, lite, escape);

                Player.OnChangingRole(changingRoleEventArgs);

                lite   = changingRoleEventArgs.ShouldPreservePosition;
                escape = changingRoleEventArgs.IsEscaped;

                if (classid != RoleType.Spectator && changingRoleEventArgs.NewRole == RoleType.Spectator)
                {
                    var diedEventArgs = new DiedEventArgs(API.Features.Server.Host, changingRoleEventArgs.Player, new PlayerStats.HitInfo(-1, "Dedicated Server", DamageTypes.None, 0));
                    Player.OnDied(diedEventArgs);
                }

                classid = changingRoleEventArgs.NewRole;

                if (escape)
                {
                    var escapingEventArgs = new EscapingEventArgs(API.Features.Player.Get(ply), classid);

                    Player.OnEscaping(escapingEventArgs);

                    if (!escapingEventArgs.IsAllowed)
                    {
                        return(false);
                    }

                    classid = escapingEventArgs.NewRole;
                }

                ply.GetComponent <CharacterClassManager>().SetClassIDAdv(classid, lite, escape);
                ply.GetComponent <PlayerStats>().SetHPAmount(__instance.Classes.SafeGet(classid).maxHP);

                if (lite)
                {
                    ListPool <ItemType> .Shared.Return(startItemsList);

                    return(false);
                }

                Inventory component = ply.GetComponent <Inventory>();
                List <Inventory.SyncItemInfo> list = ListPool <Inventory.SyncItemInfo> .Shared.Rent();

                if (escape && __instance.KeepItemsAfterEscaping)
                {
                    foreach (Inventory.SyncItemInfo item in component.items)
                    {
                        list.Add(item);
                    }
                }

                component.items.Clear();
                foreach (ItemType id in changingRoleEventArgs.Items)
                {
                    component.AddNewItem(id, -4.65664672E+11f, 0, 0, 0);
                }

                ListPool <ItemType> .Shared.Return(startItemsList);

                if (escape && __instance.KeepItemsAfterEscaping)
                {
                    foreach (Inventory.SyncItemInfo syncItemInfo in list)
                    {
                        if (__instance.PutItemsInInvAfterEscaping)
                        {
                            Item itemByID = component.GetItemByID(syncItemInfo.id);
                            bool flag     = false;
                            InventoryCategory[] categories = __instance._search.categories;
                            int i = 0;
                            while (i < categories.Length)
                            {
                                InventoryCategory inventoryCategory = categories[i];
                                if (inventoryCategory.itemType == itemByID.itemCategory &&
                                    (itemByID.itemCategory != ItemCategory.None ||
                                     itemByID.itemCategory != ItemCategory.None))
                                {
                                    int num = 0;
                                    foreach (Inventory.SyncItemInfo syncItemInfo2 in component.items)
                                    {
                                        if (component.GetItemByID(syncItemInfo2.id).itemCategory ==
                                            itemByID.itemCategory)
                                        {
                                            num++;
                                        }
                                    }

                                    if (num >= inventoryCategory.maxItems)
                                    {
                                        flag = true;
                                        break;
                                    }

                                    break;
                                }
                                else
                                {
                                    i++;
                                }
                            }

                            if (component.items.Count >= 8 || flag)
                            {
                                component.SetPickup(syncItemInfo.id, syncItemInfo.durability, __instance._pms.RealModelPosition, Quaternion.Euler(__instance._pms.Rotations.x, __instance._pms.Rotations.y, 0f), syncItemInfo.modSight, syncItemInfo.modBarrel, syncItemInfo.modOther);
                            }
                            else
                            {
                                component.AddNewItem(syncItemInfo.id, syncItemInfo.durability, syncItemInfo.modSight, syncItemInfo.modBarrel, syncItemInfo.modOther);
                            }
                        }
                        else
                        {
                            component.SetPickup(syncItemInfo.id, syncItemInfo.durability, __instance._pms.RealModelPosition, Quaternion.Euler(__instance._pms.Rotations.x, __instance._pms.Rotations.y, 0f), syncItemInfo.modSight, syncItemInfo.modBarrel, syncItemInfo.modOther);
                        }
                    }
                }

                ListPool <Inventory.SyncItemInfo> .Shared.Return(list);

                return(false);
            }
            catch (Exception e)
            {
                Exiled.API.Features.Log.Error($"Exiled.Events.Patches.Events.Player.ChangingRole: {e}\n{e.StackTrace}");

                return(true);
            }
        }
 public void ThereIsNoEscape(EscapingEventArgs ev)
 {
     ev.IsAllowed = false;
 }
Example #17
0
 public void OnEscaping(EscapingEventArgs ev)
 {
     ev.IsAllowed = (!FacilityControl.EscapingDisabled);
 }
Example #18
0
 private static void OnEscape(EscapingEventArgs ev)
 {
     Timing.RunCoroutine(LastEscape(ev));
 }
Example #19
0
        private static bool Prefix(CharacterClassManager __instance, ref RoleType classid, GameObject ply, bool lite = false, bool escape = false)
        {
            if (!NetworkServer.active)
            {
                return(false);
            }

            if (!ply.GetComponent <CharacterClassManager>().IsVerified)
            {
                return(false);
            }

            var changingRoleEventArgs = new ChangingRoleEventArgs(API.Features.Player.Get(ply), classid, __instance.Classes.SafeGet(classid).startItems.ToList(), lite, escape);

            Player.OnChangingRole(changingRoleEventArgs);

            lite    = changingRoleEventArgs.ShouldPreservePosition;
            escape  = changingRoleEventArgs.IsEscaped;
            classid = changingRoleEventArgs.NewRole;

            if (escape)
            {
                var escapingEventArgs = new EscapingEventArgs(API.Features.Player.Get(ply), classid);

                Player.OnEscaping(escapingEventArgs);

                classid = escapingEventArgs.NewRole;
            }

            ply.GetComponent <CharacterClassManager>().SetClassIDAdv(classid, lite, escape);
            ply.GetComponent <PlayerStats>().SetHPAmount(__instance.Classes.SafeGet(classid).maxHP);

            if (lite)
            {
                return(false);
            }

            Inventory component = ply.GetComponent <Inventory>();
            List <Inventory.SyncItemInfo> list = new List <Inventory.SyncItemInfo>();

            if (escape && __instance.KeepItemsAfterEscaping)
            {
                foreach (Inventory.SyncItemInfo item in component.items)
                {
                    list.Add(item);
                }
            }

            component.items.Clear();
            foreach (ItemType id in changingRoleEventArgs.Items)
            {
                component.AddNewItem(id, -4.65664672E+11f, 0, 0, 0);
            }

            if (escape && __instance.KeepItemsAfterEscaping)
            {
                foreach (Inventory.SyncItemInfo syncItemInfo in list)
                {
                    if (__instance.PutItemsInInvAfterEscaping)
                    {
                        Item itemByID = component.GetItemByID(syncItemInfo.id);
                        bool flag     = false;
                        InventoryCategory[] categories = __instance._search.categories;
                        int i = 0;
                        while (i < categories.Length)
                        {
                            InventoryCategory inventoryCategory = categories[i];
                            if (inventoryCategory.itemType == itemByID.itemCategory && (itemByID.itemCategory != ItemCategory.None || itemByID.itemCategory != ItemCategory.None))
                            {
                                int num = 0;
                                foreach (Inventory.SyncItemInfo syncItemInfo2 in component.items)
                                {
                                    if (component.GetItemByID(syncItemInfo2.id).itemCategory == itemByID.itemCategory)
                                    {
                                        num++;
                                    }
                                }

                                if (num >= inventoryCategory.maxItems)
                                {
                                    flag = true;
                                    break;
                                }

                                break;
                            }
                            else
                            {
                                i++;
                            }
                        }

                        if (component.items.Count >= 8 || flag)
                        {
                            component.SetPickup(syncItemInfo.id, syncItemInfo.durability, __instance._pms.RealModelPosition, Quaternion.Euler(__instance._pms.Rotations.x, __instance._pms.Rotations.y, 0f), syncItemInfo.modSight, syncItemInfo.modBarrel, syncItemInfo.modOther);
                        }
                        else
                        {
                            component.AddNewItem(syncItemInfo.id, syncItemInfo.durability, syncItemInfo.modSight, syncItemInfo.modBarrel, syncItemInfo.modOther);
                        }
                    }
                    else
                    {
                        component.SetPickup(syncItemInfo.id, syncItemInfo.durability, __instance._pms.RealModelPosition, Quaternion.Euler(__instance._pms.Rotations.x, __instance._pms.Rotations.y, 0f), syncItemInfo.modSight, syncItemInfo.modBarrel, syncItemInfo.modOther);
                    }
                }
            }

            return(false);
        }
Example #20
0
 public void OnEscaping(EscapingEventArgs ev)
 {
 }
Example #21
0
 public void OnEscaping(EscapingEventArgs ev)
 {
     CheckForEvent("OnEscaping", true, false, ev.Player);
 }
Example #22
0
 /// <summary>
 /// Invoked before escaping from the facility.
 /// </summary>
 /// <param name="ev">The <see cref="EscapingEventArgs"/> instance.</param>
 public static void OnEscaping(EscapingEventArgs ev) => Escaping.InvokeSafely(ev);
 public void OnEscaping(EscapingEventArgs ev)
 {
     teamedPlayers[ev.Player] = MainPlugin.Singleton.Classes.ConvertToNormalTeamName(ev.NewRole).ToString().ToLower();
 }
Example #24
0
 /// <summary>
 /// Initializes a new instance of the <see cref="OwnerEscapingEventArgs"/> class.
 /// </summary>
 /// <param name="item"><inheritdoc cref="Item"/></param>
 /// <param name="ev">The <see cref="EscapingEventArgs"/> instance.</param>
 public OwnerEscapingEventArgs(Inventory.SyncItemInfo item, EscapingEventArgs ev)
     : this(item, ev.Player, ev.NewRole, ev.IsAllowed)
 {
 }
Example #25
0
 /// <summary>
 /// Initializes a new instance of the <see cref="OwnerEscapingEventArgs"/> class.
 /// </summary>
 /// <param name="item"><inheritdoc cref="Item"/></param>
 /// <param name="ev">The <see cref="EscapingEventArgs"/> instance.</param>
 public OwnerEscapingEventArgs(Item item, EscapingEventArgs ev)
     : this(item, ev.Player)
 {
 }