public static bool Prefix(Scp268 __instance)
        {
            Player player = Player.Get(__instance.Hub);

            if (player == null)
            {
                return(true);
            }
            if (TrackingAndMethods.PlayersVenting.Contains(player))
            {
                return(false);
            }
            if (TrackingAndMethods.PlayersInvisibleByCommand.Contains(player))
            {
                return(false);
            }
            if (!TrackingAndMethods.PlayersWithSubclasses.ContainsKey(player) || !TrackingAndMethods.PlayersWithSubclasses[player].Abilities.Contains(AbilityType.InvisibleUntilInteract))
            {
                //Log.Debug($"Player {player.Nickname} does not have subclass or invibility", Subclass.Instance.Config.Debug);
                return(true);
            }

            float cooldown = TrackingAndMethods.PlayersWithSubclasses[player].AbilityCooldowns[AbilityType.InvisibleUntilInteract];

            player.Broadcast((ushort)Mathf.Clamp(cooldown / 2, 0.5f, 3), TrackingAndMethods.PlayersWithSubclasses[player].StringOptions["AbilityCooldownMessage"].Replace("{ability}", "invisibility").Replace("{seconds}", (cooldown).ToString()));
            Timing.CallDelayed(cooldown, () =>
            {
                if (TrackingAndMethods.PlayersWithSubclasses.ContainsKey(player) &&
                    TrackingAndMethods.PlayersWithSubclasses[player].Abilities.Contains(AbilityType.InvisibleUntilInteract))
                {
                    player.ReferenceHub.playerEffectsController.EnableEffect <Scp268>();
                }
            });

            return(true);
        }
예제 #2
0
        public bool Execute(ArraySegment <string> arguments, ICommandSender sender, out string response)
        {
            Player player = Player.Get(((PlayerCommandSender)sender).SenderId);

            if (!TrackingAndMethods.PlayersWithSubclasses.ContainsKey(player) || !TrackingAndMethods.PlayersWithSubclasses[player].Abilities.Contains(AbilityType.InvisibleOnCommand))
            {
                Log.Debug($"Player {player.Nickname} could not go invisible on command", Subclass.Instance.Config.Debug);
                response = "";
                return(true);
            }
            Scp268 scp268 = player.ReferenceHub.playerEffectsController.GetEffect <Scp268>();

            if (scp268 != null)
            {
                SubClass subClass = TrackingAndMethods.PlayersWithSubclasses[player];
                if (!TrackingAndMethods.CanUseAbility(player, AbilityType.InvisibleOnCommand, subClass))
                {
                    TrackingAndMethods.DisplayCantUseAbility(player, AbilityType.InvisibleOnCommand, subClass, "invisible on command");
                    response = "";
                    return(true);
                }

                if (scp268.Enabled)
                {
                    Log.Debug($"Player {player.Nickname} failed to go invisible on command", Subclass.Instance.Config.Debug);
                    player.Broadcast(3, Subclass.Instance.Config.AlreadyInvisibleMessage);
                    response = "";
                    return(true);
                }

                if (TrackingAndMethods.OnCooldown(player, AbilityType.InvisibleOnCommand, subClass))
                {
                    Log.Debug($"Player {player.Nickname} failed to go invisible on command", Subclass.Instance.Config.Debug);
                    TrackingAndMethods.DisplayCooldown(player, AbilityType.InvisibleOnCommand, subClass, "invisible", Time.time);
                    response = "";
                    return(true);
                }

                //scp268.Duration = subClass.FloatOptions.ContainsKey("InvisibleOnCommandDuration") ?
                //    subClass.FloatOptions["InvisibleOnCommandDuration"]*2f : 30f*2f;

                //player.ReferenceHub.playerEffectsController.EnableEffect(scp268);

                player.ReferenceHub.playerEffectsController.EnableEffect <Scp268>();
                TrackingAndMethods.PlayersInvisibleByCommand.Add(player);
                Timing.CallDelayed(subClass.FloatOptions.ContainsKey("InvisibleOnCommandDuration") ?
                                   subClass.FloatOptions["InvisibleOnCommandDuration"] : 30f, () =>
                {
                    if (TrackingAndMethods.PlayersInvisibleByCommand.Contains(player))
                    {
                        TrackingAndMethods.PlayersInvisibleByCommand.Remove(player);
                    }
                    if (scp268.Enabled)
                    {
                        player.ReferenceHub.playerEffectsController.DisableEffect <Scp268>();
                    }
                });

                TrackingAndMethods.AddCooldown(player, AbilityType.InvisibleOnCommand);
                TrackingAndMethods.UseAbility(player, AbilityType.InvisibleOnCommand, subClass);
            }
            response = "";
            return(true);
        }
예제 #3
0
        public void OnSendingConsoleCommand(SendingConsoleCommandEventArgs ev)
        {
            Log.Debug($"Player {ev.Player.Nickname} sent a console command", Subclass.Instance.Config.Debug);
            ev.IsAllowed = false;
            switch (ev.Name)
            {
            case "revive":
                Log.Debug($"Player {ev.Player.Nickname} is attempting to revive", Subclass.Instance.Config.Debug);
                if (Tracking.PlayersWithSubclasses.ContainsKey(ev.Player) && Tracking.PlayersWithSubclasses[ev.Player].Abilities.Contains(AbilityType.Revive))
                {
                    SubClass subClass = Tracking.PlayersWithSubclasses[ev.Player];
                    AttemptRevive(ev, subClass);
                }
                else
                {
                    ev.ReturnMessage = "You don't have the ability to revive!";
                }
                break;

            case "necro":
                Log.Debug($"Player {ev.Player.Nickname} is attempting to necro", Subclass.Instance.Config.Debug);
                if (Tracking.PlayersWithSubclasses.ContainsKey(ev.Player) && Tracking.PlayersWithSubclasses[ev.Player].Abilities.Contains(AbilityType.Necromancy))
                {
                    SubClass subClass = Tracking.PlayersWithSubclasses[ev.Player];
                    AttemptRevive(ev, subClass, true);
                }
                else
                {
                    ev.ReturnMessage = "You don't have the ability to necro!";
                }
                break;

            case "locate":
                if (ev.Player.Role != RoleType.Scp93953 && ev.Player.Role != RoleType.Scp93989 &&
                    (!Tracking.PlayersWithSubclasses.ContainsKey(ev.Player) ||
                     !Tracking.PlayersWithSubclasses[ev.Player].Abilities.Contains(AbilityType.Scp939Vision)))
                {
                    Log.Debug($"Player {ev.Player.Nickname} failed to echolocate", Subclass.Instance.Config.Debug);
                    ev.ReturnMessage = "You must be SCP-939 or have a subclass with its visuals to use this command";
                    return;
                }

                if (Tracking.PlayersWithSubclasses.ContainsKey(ev.Player) && Tracking.PlayersWithSubclasses[ev.Player].Abilities.Contains(AbilityType.Echolocate))
                {
                    SubClass subClass = Tracking.PlayersWithSubclasses[ev.Player];
                    if (Tracking.OnCooldown(ev.Player, AbilityType.Echolocate, subClass))
                    {
                        Log.Debug($"Player {ev.Player.Nickname} failed to echolocate", Subclass.Instance.Config.Debug);
                        Tracking.DisplayCooldown(ev.Player, AbilityType.Echolocate, subClass, "echolocation", Time.time);
                        return;
                    }

                    Collider[] colliders = Physics.OverlapSphere(ev.Player.Position, subClass.FloatOptions.ContainsKey("EcholocateRadius") ? subClass.FloatOptions["EcholocateRadius"] : 10f);

                    foreach (Collider PlayerCollider in colliders.Where(c => EPlayer.Get(c.gameObject) != null))
                    {
                        EPlayer.Get(PlayerCollider.gameObject).ReferenceHub.footstepSync?.CmdScp939Noise(100f);
                    }

                    Tracking.AddCooldown(ev.Player, AbilityType.Echolocate);
                    Log.Debug($"Player {ev.Player.Nickname} successfully used echolocate", Subclass.Instance.Config.Debug);
                }
                break;

            case "noclip":
                Log.Debug($"Player {ev.Player.Nickname} is attempting to noclip", Subclass.Instance.Config.Debug);
                if (Tracking.PlayersWithSubclasses.ContainsKey(ev.Player) && Tracking.PlayersWithSubclasses[ev.Player].Abilities.Contains(AbilityType.NoClip))
                {
                    SubClass subClass = Tracking.PlayersWithSubclasses[ev.Player];
                    if (Tracking.OnCooldown(ev.Player, AbilityType.NoClip, subClass))
                    {
                        Log.Debug($"Player {ev.Player.Nickname} failed to noclip - cooldown", Subclass.Instance.Config.Debug);
                        Tracking.DisplayCooldown(ev.Player, AbilityType.NoClip, subClass, "noclip", Time.time);
                        return;
                    }
                    bool previous = ev.Player.NoClipEnabled;
                    ev.Player.NoClipEnabled = !ev.Player.NoClipEnabled;
                    Tracking.AddCooldown(ev.Player, AbilityType.NoClip);
                    if (subClass.FloatOptions.ContainsKey("NoClipTime"))
                    {
                        Timing.CallDelayed(subClass.FloatOptions["NoClipTime"], () =>
                        {
                            if (ev.Player.NoClipEnabled != previous)
                            {
                                ev.Player.NoClipEnabled = previous;
                            }
                        });
                    }
                    Log.Debug($"Player {ev.Player.Nickname} successfully noclipped", Subclass.Instance.Config.Debug);
                }
                else
                {
                    ev.ReturnMessage = "You must have the noclip ability to use this command";
                    Log.Debug($"Player {ev.Player.Nickname} could not noclip", Subclass.Instance.Config.Debug);
                }
                break;

            case "flash":
                if (Tracking.PlayersWithSubclasses.ContainsKey(ev.Player) && Tracking.PlayersWithSubclasses[ev.Player].Abilities.Contains(AbilityType.FlashOnCommand))
                {
                    SubClass subClass = Tracking.PlayersWithSubclasses[ev.Player];
                    if (Tracking.OnCooldown(ev.Player, AbilityType.FlashOnCommand, subClass))
                    {
                        Log.Debug($"Player {ev.Player.Nickname} failed to flash on command", Subclass.Instance.Config.Debug);
                        Tracking.DisplayCooldown(ev.Player, AbilityType.FlashOnCommand, subClass, "flash", Time.time);
                        return;
                    }

                    // Credit to KoukoCocoa's AdminTools for the grenade spawn script below, I was lost. https://github.com/KoukoCocoa/AdminTools/
                    GrenadeManager  grenadeManager = ev.Player.ReferenceHub.gameObject.GetComponent <GrenadeManager>();
                    GrenadeSettings settings       = grenadeManager.availableGrenades.FirstOrDefault(g => g.inventoryID == ItemType.GrenadeFlash);
                    Grenade         grenade        = UnityEngine.Object.Instantiate(settings.grenadeInstance).GetComponent <Grenade>();
                    grenade.fuseDuration = subClass.FloatOptions.ContainsKey("FlashOnCommandFuseTimer") ? subClass.FloatOptions["FlashOnCommandFuseTimer"] : 0.3f;
                    grenade.FullInitData(grenadeManager, ev.Player.Position, Quaternion.Euler(grenade.throwStartAngle),
                                         grenade.throwLinearVelocityOffset, grenade.throwAngularVelocity);
                    NetworkServer.Spawn(grenade.gameObject);
                    Tracking.AddCooldown(ev.Player, AbilityType.FlashOnCommand);
                    Log.Debug($"Player {ev.Player.Nickname} successfully used flash on commad", Subclass.Instance.Config.Debug);
                }
                else
                {
                    ev.ReturnMessage = "You must have the flash on command ability to use this command";
                    Log.Debug($"Player {ev.Player.Nickname} could not flash on command", Subclass.Instance.Config.Debug);
                }
                break;

            case "invis":
                if (!Tracking.PlayersWithSubclasses.ContainsKey(ev.Player) || !Tracking.PlayersWithSubclasses[ev.Player].Abilities.Contains(AbilityType.InvisibleOnCommand))
                {
                    ev.ReturnMessage = "You must have the invisible on command ability to use this command";
                    Log.Debug($"Player {ev.Player.Nickname} could not go invisible on command", Subclass.Instance.Config.Debug);
                    return;
                }
                Scp268 scp268 = ev.Player.ReferenceHub.playerEffectsController.GetEffect <Scp268>();
                if (scp268 != null)
                {
                    SubClass subClass = Tracking.PlayersWithSubclasses[ev.Player];

                    if (scp268.Enabled)
                    {
                        Log.Debug($"Player {ev.Player.Nickname} failed to go invisible on command", Subclass.Instance.Config.Debug);
                        ev.Player.Broadcast(3, "You're already invisible!");
                        return;
                    }

                    if (Tracking.OnCooldown(ev.Player, AbilityType.InvisibleOnCommand, subClass))
                    {
                        Log.Debug($"Player {ev.Player.Nickname} failed to go invisible on command", Subclass.Instance.Config.Debug);
                        Tracking.DisplayCooldown(ev.Player, AbilityType.InvisibleOnCommand, subClass, "invisible", Time.time);
                        return;
                    }

                    //scp268.Duration = subClass.FloatOptions.ContainsKey("InvisibleOnCommandDuration") ?
                    //    subClass.FloatOptions["InvisibleOnCommandDuration"]*2f : 30f*2f;

                    //ev.Player.ReferenceHub.playerEffectsController.EnableEffect(scp268);

                    ev.Player.ReferenceHub.playerEffectsController.EnableEffect <Scp268>();
                    Tracking.PlayersInvisibleByCommand.Add(ev.Player);
                    Timing.CallDelayed(subClass.FloatOptions.ContainsKey("InvisibleOnCommandDuration") ?
                                       subClass.FloatOptions["InvisibleOnCommandDuration"] : 30f, () => {
                        if (Tracking.PlayersInvisibleByCommand.Contains(ev.Player))
                        {
                            Tracking.PlayersInvisibleByCommand.Remove(ev.Player);
                        }
                        if (scp268.Enabled)
                        {
                            ev.Player.ReferenceHub.playerEffectsController.DisableEffect <Scp268>();
                        }
                    });

                    Tracking.AddCooldown(ev.Player, AbilityType.InvisibleOnCommand);
                }
                break;

            default:
                ev.IsAllowed = true;
                break;
            }
        }
 public static bool Prefix(Scp268 __instance)
 {
     if (NetworkServer.active && ((PlayerEffect)__instance).Enabled)
     {
         __instance.curTime += Time.deltaTime;
         Player player = Player.Get(((PlayerEffect)__instance).Hub);
         if (!(TrackingAndMethods.PlayersWithSubclasses.ContainsKey(player) && TrackingAndMethods.PlayersWithSubclasses[player].Abilities.Contains(AbilityType.InvisibleUntilInteract)) && __instance.curTime > 15f)
         {
             ((PlayerEffect)__instance).ServerDisable();
         }
         bool flag = false;
         using (SyncList <Inventory.SyncItemInfo> .SyncListEnumerator enumerator = ((PlayerEffect)__instance).Hub.inventory.items.GetEnumerator())
         {
             while (enumerator.MoveNext())
             {
                 if (enumerator.Current.id != ItemType.SCP268)
                 {
                     continue;
                 }
                 flag = true;
             }
         }
         //if (!flag)
         //{
         //    //((PlayerEffect)__instance).ServerDisable();
         //}
     }
     if (((PlayerEffect)__instance).Hub.inventory.isLocalPlayer)
     {
         if (((PlayerEffect)__instance).Enabled)
         {
             __instance.animationTime += Time.deltaTime;
             if (__instance.animationTime > 1f)
             {
                 __instance.animationTime = 1f;
             }
         }
         else
         {
             __instance.animationTime -= Time.deltaTime * 2f;
             if (__instance.animationTime < 0f)
             {
                 __instance.animationTime = 0f;
             }
         }
         if (__instance.prevAnim != __instance.animationTime)
         {
             bool flag2;
             __instance.prevAnim = __instance.animationTime;
             CameraFilterPack_Colors_Adjust_ColorRGB effect = ((PlayerEffect)__instance).Hub.gfxController.CustomCameraEffects[1].Effect as CameraFilterPack_Colors_Adjust_ColorRGB;
             effect.enabled = flag2 = __instance.animationTime > 0f;
             CameraFilterPack_TV_Vignetting vignetting1 = ((PlayerEffect)__instance).Hub.gfxController.CustomCameraEffects[0].Effect as CameraFilterPack_TV_Vignetting;
             vignetting1.enabled         = flag2;
             vignetting1.Vignetting      = vignetting1.VignettingFull = __instance.animationTime;
             vignetting1.VignettingColor = (Color) new Color32(0, 1, 2, 0xff);
             effect.Blue       = __instance.animationTime * 0.98f;
             effect.Brightness = __instance.animationTime * -0.97f;
             effect.Red        = effect.Green = __instance.animationTime * 0.97f;
         }
     }
     return(false);
 }