private static bool ServerKillPlayerPatch(PlayableScps.Scp173 __instance, ReferenceHub target)
        {
            try
            {
                var scp    = __instance.GetPlayer();
                var player = target.GetPlayer();

                if (target == __instance.Hub || player.ClassManager.IsAnyScp() || player.ClassManager.CurClass == RoleType.Spectator)
                {
                    return(false);
                }

                if (!SynapseExtensions.GetHarmPermission(scp, player))
                {
                    return(false);
                }

                SynapseController.Server.Events.Scp.InvokeScpAttack(scp, player, Api.Enum.ScpAttackType.Scp173_Snap, out var allow);

                return(allow);
            }
            catch (Exception e)
            {
                Synapse.Api.Logger.Get.Error($"Synapse-Event: ScpAttackEvent(Scp173) failed!!\n{e}");
                return(true);
            }
        }
        private static bool BodyInteract(PlayableScps.Scp049 __instance, byte num, GameObject go)
        {
            if (num != 0)
            {
                return(true);
            }

            try
            {
                if (!__instance._interactRateLimit.CanExecute(true))
                {
                    return(false);
                }
                if (go == null || __instance.RemainingServerKillCooldown > 0f)
                {
                    return(false);
                }

                var scp    = __instance.GetPlayer();
                var player = go.GetPlayer();

                if (!SynapseExtensions.GetHarmPermission(scp, player))
                {
                    return(false);
                }

                if (Vector3.Distance(scp.Position, player.Position) >= PlayableScps.Scp049.AttackDistance * 1.25f)
                {
                    return(false);
                }

                if (Physics.Linecast(scp.Position, player.Position, InventorySystem.Items.MicroHID.MicroHIDItem.WallMask))
                {
                    return(false);
                }

                ev.Get.Scp.InvokeScpAttack(scp, player, Api.Enum.ScpAttackType.Scp049_Touch, out var allow);
                if (!allow)
                {
                    return(false);
                }

                player.PlayerStats.DealDamage(new ScpDamageHandler(scp.Hub, 4949f, DeathTranslations.Scp049));
                GameCore.Console.AddDebugLog("SCPCTRL", "SCP-049 | Sent 'death time' RPC", MessageImportance.LessImportant, false);
                scp.Hub.scpsController.RpcTransmit_Byte(0);
                __instance.RemainingServerKillCooldown = PlayableScps.Scp049.KillCooldown;
                return(false);
            }
            catch (Exception e)
            {
                Synapse.Api.Logger.Get.Error($"Synapse-Event: ScpAttackEvent(Scp049) failed!!\n{e}");
                return(true);
            }
        }
Exemple #3
0
 private static bool CheckFF(out bool __result, ReferenceHub attacker, ReferenceHub victim, bool ignoreConfig = false)
 {
     try
     {
         __result = SynapseExtensions.GetHarmPermission(attacker.GetPlayer(), victim.GetPlayer(), ignoreConfig);
         return(false);
     }
     catch (Exception e)
     {
         Synapse.Api.Logger.Get.Error($"Synapse-API: GetShootPermission  failed!!\n{e}\nStackTrace:\n{e.StackTrace}");
         __result = true;
         return(true);
     }
 }
        private static bool HurtPlayer(Scp049_2PlayerScript __instance, GameObject plyObj)
        {
            try
            {
                if (!__instance._iawRateLimit.CanExecute(true) || plyObj == null)
                {
                    return(false);
                }

                var scp    = __instance.GetPlayer();
                var player = plyObj?.GetPlayer();

                if (player == null)
                {
                    return(false);
                }

                if (!__instance.iAm049_2 || Vector3.Distance(scp.Position, player.Position) > __instance.distance * 1.5f)
                {
                    return(false);
                }

                if (!SynapseExtensions.GetHarmPermission(scp, player))
                {
                    return(false);
                }

                ev.Get.Scp.InvokeScpAttack(scp, player, Api.Enum.ScpAttackType.Scp0492_Scratch, out var allow);

                if (!allow)
                {
                    return(false);
                }

                player.PlayerStats.DealDamage(new ScpDamageHandler(scp.Hub, __instance.damage, DeathTranslations.Zombie));
                Hitmarker.SendHitmarker(scp.Connection, 1f);
                scp.ClassManager.RpcPlaceBlood(player.Position, 0, player.RoleType == RoleType.Spectator ? 1.3f : 0.5f);
                return(false);
            }
            catch (Exception e)
            {
                Synapse.Api.Logger.Get.Error($"Synapse-Event: ScpAttackEvent(Scp049-2) failed!!\n{e}");
                return(true);
            }
        }
Exemple #5
0
        private static bool OnDamage(HitboxIdentity __instance, DamageHandlerBase handler)
        {
            try
            {
                if (handler is AttackerDamageHandler ahandler)
                {
                    var ply      = __instance.TargetHub.GetPlayer();
                    var attacker = ahandler.Attacker.GetPlayer();
                    Logger.Get.Debug($"{ply == null} - {attacker == null}");
                    return(SynapseExtensions.GetHarmPermission(attacker, ply));
                }
            }
            catch (Exception ex)
            {
                Logger.Get.Error($"Synapse-FF: PlayerDamage failed!!\n{ex}");
            }

            return(true);
        }
        private static bool Scp939Attack(PlayableScps.Scp939 __instance, GameObject target, out bool __result)
        {
            __result = false;
            try
            {
                var scp = __instance.GetPlayer();

                if (target.TryGetComponent <BreakableWindow>(out var window))
                {
                    window.Damage(50f, new ScpDamageHandler(scp.Hub, 50f, DeathTranslations.Scp939), Vector3.zero);
                    __result = true;
                }
                else
                {
                    var targetplayer = target.GetPlayer();

                    if (!SynapseExtensions.GetHarmPermission(scp, targetplayer))
                    {
                        return(false);
                    }

                    ev.Get.Scp.InvokeScpAttack(scp, targetplayer, Api.Enum.ScpAttackType.Scp939_Bite, out var allow);

                    if (!allow)
                    {
                        return(false);
                    }

                    targetplayer.PlayerStats.DealDamage(new ScpDamageHandler(scp.Hub, 50f, DeathTranslations.Scp939));
                    scp.ClassManager.RpcPlaceBlood(targetplayer.Position, 0, 2f);

                    targetplayer.PlayerEffectsController.EnableEffect <CustomPlayerEffects.Amnesia>(3f, true);
                    __result = true;
                }

                return(false);
            }
            catch (Exception e)
            {
                Synapse.Api.Logger.Get.Error($"Synapse-Event: ScpAttackEvent(Scp939) failed!!\n{e}");
                return(true);
            }
        }
Exemple #7
0
        private static bool DealDamagePatch(PlayerStats __instance, DamageHandlerBase handler)
        {
            try
            {
                if (!__instance._hub.characterClassManager.IsAlive ||
                    __instance._hub.characterClassManager.GodMode)
                {
                    return(false);
                }

                var standardhandler = handler as StandardDamageHandler;
                var type            = handler.GetDamageType();
                var victim          = __instance.GetPlayer();
                var attacker        = handler is AttackerDamageHandler ahandler?ahandler.Attacker.GetPlayer() : null;

                var damage = standardhandler.Damage;

                if (type == DamageType.PocketDecay)
                {
                    attacker = Server.Get.Players.FirstOrDefault(x => x.Scp106Controller.PocketPlayers.Contains(victim));
                    if (attacker != null && !SynapseExtensions.GetHarmPermission(attacker, victim))
                    {
                        return(false);
                    }
                }

                SynapseController.Server.Events.Player.InvokePlayerDamageEvent(victim, attacker, ref damage, type, out var allow);
                standardhandler.Damage = damage;

                return(allow);
            }
            catch (Exception e)
            {
                Logger.Get.Error($"Synapse-Event: PlayerDamage event failed!!\n{e}");
                return(true);
            }
        }
        private static bool HitObject(PlayableScps.Scp096 __instance, GameObject target, out bool __result)
        {
            try
            {
                __result = false;

                if (target.TryGetComponent <BreakableWindow>(out var window))
                {
                    __result = window.Damage(500f, new Scp096DamageHandler(__instance, 500f, Scp096DamageHandler.AttackType.Slap), target.transform.position);
                    return(false);
                }

                if (target.TryGetComponent <DoorVariant>(out var door) && (object)door is IDamageableDoor damageable && !door.IsConsideredOpen())
                {
                    __result = damageable.ServerDamage(250f, DoorDamageType.Scp096);
                    return(false);
                }

                if (!ReferenceHub.TryGetHub(target, out var hub) || hub == null || hub == __instance.Hub || hub.characterClassManager.IsAnyScp())
                {
                    return(false);
                }

                var scp    = __instance.GetPlayer();
                var player = hub.GetPlayer();

                if (Physics.Linecast(scp.Position, player.Position, PlayableScps.Scp096._solidObjectMask))
                {
                    return(false);
                }

                if (Vector3.Distance(scp.Position, player.Position) > 5f)
                {
                    return(false);
                }

                if (!SynapseExtensions.GetHarmPermission(scp, player))
                {
                    return(false);
                }
                try
                {
                    ev.Get.Scp.InvokeScpAttack(scp, player, Api.Enum.ScpAttackType.Scp096_Tear, out var allow);
                    if (!allow)
                    {
                        return(false);
                    }
                }
                catch (Exception e)
                {
                    Synapse.Api.Logger.Get.Error($"Synapse-Event: ScpAttackEvent(Scp096-Charge) failed!!\n{e}");
                }

                if (hub.playerStats.DealDamage(new Scp096DamageHandler(__instance, 9696f, Scp096DamageHandler.AttackType.Slap)))
                {
                    __instance._targets.Remove(hub);
                    NetworkServer.SendToAll(default(PlayableScps.Messages.Scp096OnKillMessage), 0, false);
                }

                __result = true;
                return(false);
            }
            catch (Exception e)
            {
                Synapse.Api.Logger.Get.Error($"Synapse-Event: ScpAttackEvent(HitObject) failed!!\n{e}");
                __result = false;
                return(true);
            }
        }
Exemple #9
0
        private static bool MovePlayer(Scp106PlayerScript __instance, GameObject ply, int t)
        {
            try
            {
                if (!__instance._iawRateLimit.CanExecute(true) || ply == null || !__instance.iAm106)
                {
                    return(false);
                }

                var scp    = __instance.GetPlayer();
                var player = ply.GetPlayer();

                if (player == null || player.GodMode || !ServerTime.CheckSynchronization(t) || !player.ClassManager.IsHuman())
                {
                    return(false);
                }

                if (!SynapseExtensions.GetHarmPermission(scp, player))
                {
                    return(false);
                }

                var pos  = player.Position;
                var num  = Vector3.Distance(scp.Position, pos);
                var num2 = Math.Abs(scp.Position.y - pos.y);
                if ((num >= 1.818f && num2 < 1.02f) || (num >= 3.4f && num2 < 1.95f) || (num >= 3.7f && num2 < 2.2f) || (num >= 3.9f && num2 < 3f) || num >= 4.2f)
                {
                    __instance._hub.characterClassManager.TargetConsolePrint(scp.Connection, string.Format("106 MovePlayer command rejected - too big distance (code: T1). Distance: {0}, Y Diff: {1}.", num, num2), "gray");
                    return(false);
                }
                if (Physics.Linecast(scp.Position, player.Position, MicroHIDItem.WallMask))
                {
                    __instance._hub.characterClassManager.TargetConsolePrint(scp.Connection, string.Format("106 MovePlayer command rejected - collider found between you and the target (code: T2). Distance: {0}, Y Diff: {1}.", num, num2), "gray");
                    return(false);
                }

                EventHandler.Get.Scp.InvokeScpAttack(scp, player, Api.Enum.ScpAttackType.Scp106_Grab, out var allow);
                if (!allow)
                {
                    return(false);
                }

                scp.ClassManager.RpcPlaceBlood(player.Position, 1, 2f);
                __instance.TargetHitMarker(scp.Connection, __instance.captureCooldown);
                __instance._currentServerCooldown = __instance.captureCooldown;
                if (Scp106PlayerScript._blastDoor.isClosed)
                {
                    __instance._hub.characterClassManager.RpcPlaceBlood(player.Position, 1, 2f);
                    player.PlayerStats.DealDamage(new ScpDamageHandler(__instance._hub, PlayerStatsSystem.DeathTranslations.PocketDecay));
                }
                else
                {
                    EventHandler.Get.Scp.Scp106.InvokePocketDimensionEnterEvent(player, scp, ref allow);
                    if (!allow)
                    {
                        return(false);
                    }

                    foreach (var script in Scp079PlayerScript.instances)
                    {
                        script.ServerProcessKillAssist(player.Hub, ExpGainType.PocketAssist);
                    }

                    player.Hub.scp106PlayerScript.GrabbedPosition = player.Hub.playerMovementSync.RealModelPosition;
                    player.PlayerStats.DealDamage(new ScpDamageHandler(__instance._hub, 40f, PlayerStatsSystem.DeathTranslations.PocketDecay));
                    player.Position = Vector3.down * 1998.5f;
                    scp.Scp106Controller.PocketPlayers.Add(player);
                }
                player.PlayerEffectsController.EnableEffect <CustomPlayerEffects.Corroding>(0f, false);

                return(false);
            }
            catch (Exception e)
            {
                Logger.Get.Error($"Synapse-Event: PocketDimEnter/ScpAttackEvent(106) failed!!\n{e}");
                return(true);
            }
        }