예제 #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DyingEventArgs"/> class.
 /// </summary>
 /// <param name="killer"><inheritdoc cref="Killer"/></param>
 /// <param name="target"><inheritdoc cref="Target"/></param>
 /// <param name="hitInformation"><inheritdoc cref="HitInformation"/></param>
 /// <param name="isAllowed"><inheritdoc cref="IsAllowed"/></param>
 public DyingEventArgs(Player killer, Player target, PlayerStats.HitInfo hitInformation, bool isAllowed = true)
 {
     Killer         = killer;
     Target         = target;
     HitInformation = hitInformation;
     IsAllowed      = isAllowed;
 }
예제 #2
0
파일: Map.cs 프로젝트: somebofy/EXILED
        /// <summary>
        /// Spawns a ragdoll on the map based on the different arguments.
        /// </summary>
        /// <remarks>
        /// Tip: You can do, for example, '<paramref name="velocity"/>: "Vector3.up * 3"' to skip parameters.
        /// </remarks>
        /// <example>
        /// <code>
        /// // Code to spawn a fake ragdoll
        /// if (ev.Player == MyPlugin.TheInmortalPlayer)
        /// {
        ///     var fakeRagdoll = Map.SpawnRagdoll(ev.Player.Role, ev.Player.Position, victimNick: ev.Player.DisplayNickname, playerId: ev.Player.Id);
        /// }
        /// </code>
        /// </example>
        /// <param name="roleType">The <see cref="RoleType"/> to use as ragdoll.</param>
        /// <param name="victimNick">The name from the victim, who the corpse belongs to.</param>
        /// <param name="hitInfo">The <see cref="PlayerStats.HitInfo"/> that displays who killed this ragdoll, and using which tool.</param>
        /// <param name="position">Where the ragdoll will be spawned.</param>
        /// <param name="rotation">The rotation for the ragdoll.</param>
        /// <param name="velocity">The initial velocity the ragdoll will have, as if it was exploded.</param>
        /// <param name="allowRecall">Sets this ragdoll as respawnable by SCP-049.</param>
        /// <param name="playerId">Used for recall. The <see cref="Player.Id"/> to be recalled.</param>
        /// <param name="mirrorOwnerId">Can be ignored. The <see cref="Dissonance.Integrations.MirrorIgnorance.MirrorIgnorancePlayer"/>'s PlayerId field, likely used in the client.</param>
        /// <returns>The Ragdoll component (requires Assembly-CSharp to be referenced).</returns>
        public static Ragdoll SpawnRagdoll(
            RoleType roleType,
            string victimNick,
            PlayerStats.HitInfo hitInfo,
            Vector3 position,
            Quaternion rotation  = default,
            Vector3 velocity     = default,
            bool allowRecall     = false,
            int playerId         = -1,
            string mirrorOwnerId = null)
        {
            Role role = CharacterClassManager._staticClasses.SafeGet(roleType);

            // Check if there's no ragdoll for this class, or if the class is invalid
            if (role.model_ragdoll == null)
            {
                return(null);
            }
            var @default = DefaultRagdollOwner;

            var ragdollInfo = new Ragdoll.Info()
            {
                ownerHLAPI_id = mirrorOwnerId ?? @default.ownerHLAPI_id,
                PlayerId      = playerId,
                DeathCause    = hitInfo != default ? hitInfo : @default.DeathCause,
                ClassColor    = role.classColor,
                FullName      = role.fullName,
                Nick          = victimNick,
            };

            return(SpawnRagdoll(role, ragdollInfo, position, rotation, velocity, allowRecall));
        }
예제 #3
0
        private static void Postfix(PlayerStats __instance, ref PlayerStats.HitInfo info, GameObject go)
        {
            try
            {
                API.Features.Player attacker = API.Features.Player.Get(__instance.gameObject);
                API.Features.Player target   = API.Features.Player.Get(go);

                if ((target != null &&
                     (target.Role != RoleType.Spectator || target.IsGodModeEnabled || target.IsHost)) ||
                    attacker == null)
                {
                    return;
                }

                var ev = new DiedEventArgs(API.Features.Player.Get(__instance.gameObject), target, info);

                target.Position = Vector3.zero;

                Player.OnDied(ev);

                info = ev.HitInformations;
            }
            catch (Exception e)
            {
                Exiled.API.Features.Log.Error($"Exiled.Events.Patches.Events.Player.Died: {e}\n{e.StackTrace}");
            }
        }
예제 #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="HurtingEventArgs"/> class.
 /// </summary>
 /// <param name="attacker"><inheritdoc cref="Attacker"/></param>
 /// <param name="target"><inheritdoc cref="Target"/></param>
 /// <param name="hitInformations"><inheritdoc cref="HitInformations"/></param>
 /// <param name="isAllowed"><inheritdoc cref="IsAllowed"/></param>
 public HurtingEventArgs(Player attacker, Player target, PlayerStats.HitInfo hitInformations, bool isAllowed = true)
 {
     Attacker        = attacker;
     Target          = target;
     HitInformations = hitInformations;
     IsAllowed       = isAllowed;
 }
예제 #5
0
 public Info(string owner, string nick, PlayerStats.HitInfo info, int cc)
 {
     this.ownerHLAPI_id   = owner;
     this.steamClientName = nick;
     this.charclass       = cc;
     this.deathCause      = info;
 }
예제 #6
0
        public static void Prefix(PlayerStats __instance, ref PlayerStats.HitInfo info, GameObject go)
        {
            try
            {
                if (go == null)
                {
                    return;
                }

                var killer = __instance.GetPlayer();

                if (info.GetDamageType() == DamageTypes.Grenade)
                {
                    killer = Player.GetPlayer(info.PlayerId);
                }

                var player = go.GetPlayer();

                Events.InvokePlayerHurtEvent(player, killer, ref info);

                if (player.GodMode)
                {
                    return;
                }

                if (player.Health + player.ArtificialHealth - info.Amount <= 0)
                {
                    Events.InvokePlayerDieEvent(player, killer, info);
                }
            }
            catch (Exception e)
            {
                Log.Error($"PlayerDamageEvent Error: {e}");
            }
        }
예제 #7
0
        private static void Prefix(PlayerStats __instance, ref PlayerStats.HitInfo info, GameObject go)
        {
            if (go == null)
            {
                return;
            }

            API.Features.Player attacker = API.Features.Player.Get(__instance.gameObject);
            API.Features.Player target   = API.Features.Player.Get(go);

            if (attacker == null || target == null || attacker.IsHost || target.IsHost)
            {
                return;
            }

            var ev = new HurtingEventArgs(API.Features.Player.Get(__instance.gameObject), API.Features.Player.Get(go), info);

            if (ev.Target.IsHost)
            {
                return;
            }

            Player.OnHurting(ev);

            info = ev.HitInformations;
        }
예제 #8
0
 public PlayerDeathEvent(PheggPlayer player, PheggPlayer attacker, float damage, DamageTypes.DamageType damageType, PlayerStats.HitInfo info) : base(player)
 {
     Attacker   = attacker;
     Damage     = damage;
     DamageType = damageType;
     HitInfo    = info;
 }
예제 #9
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SpawningRagdollEventArgs"/> class.
 /// </summary>
 /// <param name="killer"><inheritdoc cref="Killer"/></param>
 /// <param name="owner"><inheritdoc cref="Owner"/></param>
 /// <param name="position"><inheritdoc cref="Position"/></param>
 /// <param name="rotation"><inheritdoc cref="Rotation"/></param>
 /// <param name="roleType"><inheritdoc cref="RoleType"/></param>
 /// <param name="hinInformations"><inheritdoc cref="HitInformations"/></param>
 /// <param name="isRecallAllowed"><inheritdoc cref="IsRecallAllowed"/></param>
 /// <param name="dissonanceId"><inheritdoc cref="DissonanceId"/></param>
 /// <param name="playerName"><inheritdoc cref="PlayerNickname"/></param>
 /// <param name="playerId"><inheritdoc cref="PlayerId"/></param>
 /// <param name="isAllowed"><inheritdoc cref="IsAllowed"/></param>
 public SpawningRagdollEventArgs(
     Player killer,
     Player owner,
     Vector3 position,
     Quaternion rotation,
     RoleType roleType,
     PlayerStats.HitInfo hinInformations,
     bool isRecallAllowed,
     string dissonanceId,
     string playerName,
     int playerId,
     bool isAllowed = true)
 {
     Killer          = killer;
     Owner           = owner;
     Position        = position;
     Rotation        = rotation;
     RoleType        = roleType;
     HitInformations = hinInformations;
     IsRecallAllowed = isRecallAllowed;
     DissonanceId    = dissonanceId;
     PlayerNickname  = playerName;
     PlayerId        = playerId;
     IsAllowed       = isAllowed;
 }
예제 #10
0
파일: Hurting.cs 프로젝트: iRebbok/EXILED
        private static void Prefix(PlayerStats __instance, ref PlayerStats.HitInfo info, GameObject go, bool noTeamDamage = false)
        {
            try
            {
                if (go == null)
                {
                    return;
                }

                API.Features.Player attacker = API.Features.Player.Get(__instance.gameObject);
                API.Features.Player target   = API.Features.Player.Get(go);

                if (attacker == null || target == null || attacker.IsHost || target.IsHost)
                {
                    return;
                }

                var ev = new HurtingEventArgs(API.Features.Player.Get(__instance.gameObject), API.Features.Player.Get(go), info);

                if (ev.Target.IsHost)
                {
                    return;
                }

                Handlers.Player.OnHurting(ev);

                info = ev.HitInformations;
            }
            catch (Exception e)
            {
                Exiled.API.Features.Log.Error($"Exiled.Events.Patches.Events.Player.Hurting: {e}\n{e.StackTrace}");
            }
        }
예제 #11
0
 public PlayerDeathEvent(GameObject plr, GameObject atr, PlayerStats.HitInfo info)
 {
     player   = new PheggPlayer(plr);
     attacker = new PheggPlayer(atr);
     //weapon = info.GetDamageType();
     hitInfo = info;
 }
예제 #12
0
        private static bool Prefix(PlayableScps.Scp096 __instance, PlayerStats.HitInfo info)
        {
            try
            {
                if (info == null || info.RHub == null)
                {
                    return(false);
                }

                var player = info.RHub.GetPlayer();

                if (player.Invisible || Server.Get.Configs.SynapseConfiguration.CantRage096.Contains(player.RoleID))
                {
                    return(false);
                }

                if (player.RealTeam == Team.SCP && !Server.Get.Configs.SynapseConfiguration.ScpTrigger096)
                {
                    return(false);
                }

                Server.Get.Events.Scp.Scp096.InvokeScpTargetEvent(player, __instance.GetPlayer(), __instance.PlayerState, out var allow);
                return(allow);
            }
            catch (Exception e)
            {
                Synapse.Api.Logger.Get.Error($"Synapse-Event: Scp096AddTargetEvent failed!!\n{e}");
                return(true);
            }
        }
예제 #13
0
    public void HurtPlayer(PlayerStats.HitInfo info, GameObject go)
    {
        PlayerStats           component   = go.GetComponent <PlayerStats>();
        CharacterClassManager component2  = go.GetComponent <CharacterClassManager>();
        PlayerStats           playerStats = component;

        playerStats.Networkhealth = playerStats.health - Mathf.CeilToInt(info.amount);
        if (component.health < 1 && component2.curClass != 2)
        {
            go.GetComponent <Inventory>().ServerDropAll();
            if (component2.curClass == 3)
            {
                go.GetComponent <Scp106PlayerScript>().CallRpcAnnounceContaining();
            }
            if (info.amount != 999799f)
            {
                base.GetComponent <RagdollManager>().SpawnRagdoll(go.transform.position, go.transform.rotation, component2.curClass, info, component2.klasy[component2.curClass].team != Team.SCP, go.GetComponent <HlapiPlayer>().PlayerId, go.GetComponent <NicknameSync>().myNick);
            }
            component2.NetworkdeathPosition = go.transform.position;
            component.SetHPAmount(100);
            component2.SetClassID(2);
            if (TutorialManager.status)
            {
                PlayerManager.localPlayer.GetComponent <TutorialManager>().KillNPC();
            }
        }
    }
예제 #14
0
        private static bool Prefix(Role scp, ref PlayerStats.HitInfo hit, ref string groupId)
        {
            var ev = new AnnouncingScpTerminationEventArgs(string.IsNullOrEmpty(hit.Attacker) ? null : API.Features.Player.Get(hit.Attacker), scp, hit, groupId);

            Map.OnAnnouncingScpTermination(ev);

            return(ev.IsAllowed);
        }
예제 #15
0
 /// <summary>
 /// Initializes a new instance of the <see cref="AnnouncingScpTerminationEventArgs"/> class.
 /// </summary>
 /// <param name="killer"><inheritdoc cref="Killer"/></param>
 /// <param name="role"><inheritdoc cref="Role"/></param>
 /// <param name="hitInfo"><inheritdoc cref="HitInfo"/></param>
 /// <param name="terminationCause"><inheritdoc cref="TerminationCause"/></param>
 /// <param name="isAllowed"><inheritdoc cref="IsAllowed"/></param>
 public AnnouncingScpTerminationEventArgs(Player killer, Role role, PlayerStats.HitInfo hitInfo, string terminationCause, bool isAllowed = true)
 {
     Killer           = killer;
     Role             = role;
     HitInfo          = hitInfo;
     TerminationCause = terminationCause;
     IsAllowed        = isAllowed;
 }
예제 #16
0
        internal void InvokePlayerDeathEvent(Player victim, Player killer, PlayerStats.HitInfo info)
        {
            var ev = new PlayerDeathEventArgs {
                HitInfo = info, Killer = killer, Victim = victim
            };

            PlayerDeathEvent?.Invoke(ev);
        }
예제 #17
0
 public void CmdSuicide(PlayerStats.HitInfo hitInfo)
 {
     if (!NetworkClient.active)
     {
         Debug.LogWarning("[Client] function 'System.Void CharacterClassManager::CmdSuicide(PlayerStats/HitInfo)' called on server");
         return;
     }
     hitInfo.amount = ((hitInfo.amount != 0f) ? hitInfo.amount : 999799f);
     base.GetComponent <PlayerStats>().HurtPlayer(hitInfo, base.gameObject);
 }
예제 #18
0
        public bool HurtPlayer(PlayerStats.HitInfo info, GameObject go)
        {
            bool stop = false;

            LabModPlayerHurt.TriggerEvent(this, info, go, out stop);
            if (!stop)
            {
                return(orig_HurtPlayer(info, go));
            }
            return(false);
        }
예제 #19
0
 public static SimpleHitInfo Parse(this PlayerStats.HitInfo hitInfo)
 {
     return(new SimpleHitInfo()
     {
         Amount = hitInfo.Amount,
         Attacker = hitInfo.Attacker,
         Tool = hitInfo.Tool,
         DamageType = hitInfo.GetDamageType().Parse(),
         Time = hitInfo.Time
     });
 }
예제 #20
0
        public static void Postfix(PlayerStats __instance, PlayerStats.HitInfo info, GameObject go)
        {
            CharacterClassManager ccm = go.GetComponent <CharacterClassManager>();

            if (ccm != null)
            {
                // No need to check for availability,
                // we will get true if deleted,
                // otherwise false, there will be no error
                PlayerHurtEvent.DeathStuff.Remove(ccm.UserId);
            }
        }
예제 #21
0
        private static bool Prefix(PlayerStats __instance, ref PlayerStats.HitInfo info, GameObject go)
        {
            try
            {
                if (go == null)
                {
                    return(true);
                }

                API.Features.Player attacker = API.Features.Player.Get(info.IsPlayer ? info.RHub.gameObject : __instance.gameObject);
                API.Features.Player target   = API.Features.Player.Get(go);

                if (attacker == null || target == null || attacker.IsHost || target.IsHost)
                {
                    return(true);
                }

                var ev = new HurtingEventArgs(attacker, target, info);

                if (ev.Target.IsHost)
                {
                    return(true);
                }

                Player.OnHurting(ev);

                info = ev.HitInformations;

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

                if (ev.Amount >= ev.Target.Health + ev.Target.AdrenalineHealth)
                {
                    var dyingEventArgs = new DyingEventArgs(ev.Attacker, ev.Target, ev.HitInformations);

                    Player.OnDying(dyingEventArgs);

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

                return(true);
            }
            catch (Exception e)
            {
                Exiled.API.Features.Log.Error($"Exiled.Events.Patches.Events.Player.Hurting: {e}\n{e.StackTrace}");
                return(true);
            }
        }
예제 #22
0
        public static void Postfix(PlayerStats __instance, PlayerStats.HitInfo info, GameObject go)
        {
            CharacterClassManager ccm = go.GetComponent <CharacterClassManager>();

            if (ccm != null)
            {
                if (PlayerHurtEvent.DeathStuff.Contains(ccm.UserId))
                {
                    PlayerHurtEvent.DeathStuff.Remove(ccm.UserId);
                }
            }
        }
            public static bool Prefix(PlayerStats __instance, PlayerStats.HitInfo info, GameObject go)
            {
                var referenceHub = ReferenceHub.GetHub(go);

                if (referenceHub.playerStats.Health - info.Amount <= 0 &&
                    ReferenceHub.HostHub != null && !ReferenceHub.HostHub.characterClassManager.RoundStarted)
                {
                    Spawn(referenceHub);
                    return(false);
                }

                return(true);
            }
예제 #24
0
    public void SpawnRagdoll(Vector3 pos, Quaternion rot, int classID, PlayerStats.HitInfo ragdollInfo, bool allowRecall, string ownerID, string ownerNick)
    {
        Class      @class     = base.GetComponent <CharacterClassManager>().klasy[1];
        GameObject gameObject = UnityEngine.Object.Instantiate <GameObject>(@class.model_ragdoll, pos + @class.ragdoll_offset.position, Quaternion.Euler(rot.eulerAngles + @class.ragdoll_offset.rotation));

        NetworkServer.Spawn(gameObject);
        gameObject.GetComponent <Ragdoll>().SetOwner(new Ragdoll.Info(ownerID, ownerNick, ragdollInfo, classID));
        gameObject.GetComponent <Ragdoll>().SetRecall(allowRecall);
        if (ragdollInfo.tool.Contains("SCP") || ragdollInfo.tool == "POCKET")
        {
            this.CallCmdRegisterScpFrag();
        }
    }
예제 #25
0
        bool ILabModPlayerHurt.Event(PlayerStats stats, PlayerStats.HitInfo info, GameObject go)
        {
            if (!dodgeball)
            {
                return(true);
            }

            /*if (go.GetComponent<CharacterClassManager>().NetworkCurClass == RoleType.Spectator)
             * {
             *  stats.StartCoroutine("SpawnLate", new PlayerStats.SpawnLateHelper() { ccm = go.GetComponent<CharacterClassManager>(), rt = info.GetPlayerObject().GetComponent<CharacterClassManager>().NetworkCurClass });
             * }*/
            return(true);
        }
예제 #26
0
 public static bool Prefix(Scp096 __instance, PlayerStats.HitInfo info)
 {
     try
     {
         var allow = true;
         Events.InvokeScp096AddTarget(info.RHub.GetPlayer(), __instance.GetPlayer(), __instance.PlayerState, ref allow);
         return(allow);
     }
     catch (Exception e)
     {
         Log.Info($"Scp096AddTarget Event Error: {e}");
         return(true);
     }
 }
예제 #27
0
 public static bool Prefix(Scp096 __instance, PlayerStats.HitInfo info)
 {
     if (info.GetDamageType().isWeapon&& SCP096Re.instance.Config.re096_damage_add_target)
     {
         GameObject playerObject = info.GetPlayerObject();
         if (playerObject != null && __instance.CanEnrage)
         {
             __instance.AddTarget(playerObject);
             __instance.Windup(false);
         }
     }
     __instance.TimeUntilShieldRecharge = 10f;
     return(false);
 }
예제 #28
0
        internal void InvokePlayerDamageEvent(Player victim, Player killer, ref PlayerStats.HitInfo info, out bool allow)
        {
            var ev = new PlayerDamageEventArgs
            {
                HitInfo = info,
                Killer  = killer,
                Victim  = victim
            };

            PlayerDamageEvent?.Invoke(ev);

            info  = ev.HitInfo;
            allow = ev.Allow;
        }
예제 #29
0
        public static bool Prefix(Role scp, ref PlayerStats.HitInfo hit, ref string groupId)
        {
            try
            {
                bool allow = true;

                Events.InvokeAnnounceScpTermination(scp, ref hit, ref groupId, ref allow);

                return(allow);
            }
            catch (Exception exception)
            {
                Log.Error($"AnnounceScpTerminationEvent error: {exception}");
                return(true);
            }
        }
예제 #30
0
        private static void Postfix(PlayerStats __instance, ref PlayerStats.HitInfo info, GameObject go)
        {
            API.Features.Player attacker = API.Features.Player.Get(__instance.gameObject);
            API.Features.Player target   = API.Features.Player.Get(go);

            if ((target != null && (target.Role != RoleType.Spectator || target.IsGodModeEnabled || target.IsHost)) || attacker == null)
            {
                return;
            }

            var ev = new DiedEventArgs(API.Features.Player.Get(__instance.gameObject), target, info);

            Player.OnDied(ev);

            info = ev.HitInformations;
        }