Exemplo n.º 1
0
        private static bool OnDeath(PlayerStats __instance, DamageHandlerBase handler, out bool __state)
        {
            try
            {
                var standardhandler = handler as StandardDamageHandler;
                var type            = handler.GetDamageType();
                var victim          = __instance.GetPlayer();
                var attacker        = handler is AttackerDamageHandler ahandler?ahandler.Attacker.GetPlayer() : null;

                if (type == DamageType.PocketDecay)
                {
                    attacker = Server.Get.Players.FirstOrDefault(x => x.Scp106Controller.PocketPlayers.Contains(victim));
                }

                SynapseController.Server.Events.Player.InvokePlayerDeathEvent(victim, attacker, type, out var allow);

                if (!allow)
                {
                    victim.Health = 1;
                }
                if (allow)
                {
                    victim.DeathPosition = victim.Position;
                }
                __state = allow;
                return(allow);
            }
            catch (Exception e)
            {
                __state = true;
                Logger.Get.Error($"Synapse-Event: PlayerDeath event failed!!\n{e}");
                return(true);
            }
        }
Exemplo n.º 2
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);
            }
        }