Esempio n. 1
0
        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);
            }
        }
        private static bool Prefix(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 (scp.RoleType != RoleType.Scp0492 || Vector3.Distance(scp.Position, player.Position) > __instance.distance * 1.5f)
                {
                    return(false);
                }

                if (!scp.WeaponManager.GetShootPermission(player.ClassManager))
                {
                    return(false);
                }

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

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

                player.Hurt((int)__instance.damage, DamageTypes.Scp0492, scp);
                __instance.TargetHitMarker(scp.Connection);
                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}\nStackTrace:\n{e.StackTrace}");
                return(true);
            }
        }