Example #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DiedEventArgs"/> class.
 /// </summary>
 /// <param name="target"><inheritdoc cref="Target"/></param>
 /// <param name="targetOldRole">Target's old <see cref="RoleType"/>.</param>
 /// <param name="damageHandler"><inheritdoc cref="DamageHandler"/></param>
 public DiedEventArgs(Player target, RoleType targetOldRole, DamageHandlerBase damageHandler)
 {
     Handler       = new CustomDamageHandler(target, damageHandler);
     Killer        = Handler.BaseIs(out CustomAttackerHandler attackerDamageHandler) ? attackerDamageHandler.Attacker : null;
     Target        = target;
     TargetOldRole = targetOldRole;
 }
Example #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DyingEventArgs"/> class.
 /// </summary>
 /// <param name="target"><inheritdoc cref="Target"/></param>
 /// <param name="damageHandler"><inheritdoc cref="DamageHandler"/></param>
 public DyingEventArgs(Player target, DamageHandlerBase damageHandler)
 {
     Handler     = new CustomDamageHandler(target, damageHandler);
     ItemsToDrop = new List <Item>(target.Items.ToList());
     Killer      = Handler.BaseIs(out CustomAttackerHandler attackerDamageHandler) ? attackerDamageHandler.Attacker : null;
     Target      = target;
 }
Example #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="HurtingEventArgs"/> class.
 /// </summary>
 /// <param name="target"><inheritdoc cref="Target"/></param>
 /// <param name="damageHandler"><inheritdoc cref="DamageHandler"/></param>
 public HurtingEventArgs(Player target, DamageHandlerBase damageHandler)
 {
     Handler  = new CustomDamageHandler(target, damageHandler);
     Attacker = Handler.BaseIs(out CustomAttackerHandler attackerDamageHandler)
         ? attackerDamageHandler.Attacker
         : null;
     Target = target;
 }
Example #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="AnnouncingScpTerminationEventArgs"/> class.
 /// </summary>
 /// <param name="scp"><inheritdoc cref="Player"/></param>
 /// <param name="damageHandlerBase"><inheritdoc cref="DamageHandler"/></param>
 /// <param name="isAllowed"><inheritdoc cref="IsAllowed"/></param>
 public AnnouncingScpTerminationEventArgs(Player scp, DamageHandlerBase damageHandlerBase, bool isAllowed = true)
 {
     Player           = scp;
     Role             = scp.ReferenceHub.characterClassManager.CurRole;
     Handler          = new CustomDamageHandler(scp, damageHandlerBase);
     Killer           = Handler.BaseIs(out CustomAttackerHandler customAttackerHandler) ? customAttackerHandler.Attacker : null;
     TerminationCause = damageHandlerBase.CassieDeathAnnouncement.Announcement;
     IsAllowed        = isAllowed;
 }
Example #5
0
        private static bool ServerSpawnRagdoll(ReferenceHub hub, PlayerStatsSystem.DamageHandlerBase handler)
        {
            if (hub == null)
            {
                return(false);
            }

            var model_ragdoll = hub.characterClassManager.CurRole.model_ragdoll;

            if (model_ragdoll == null || !Object.Instantiate(model_ragdoll).TryGetComponent <Ragdoll>(out var ragdoll))
            {
                return(false);
            }

            ragdoll.NetworkInfo = new RagdollInfo(hub, handler, model_ragdoll.transform.localPosition, model_ragdoll.transform.localRotation);
            NetworkServer.Spawn(ragdoll.gameObject);

            Map.Get.Ragdolls.Add(new Synapse.Api.Ragdoll(ragdoll));
            return(false);
        }
Example #6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="AttackerDamageHandler"/> class.
 /// </summary>
 /// <param name="target">The target to be set.</param>
 /// <param name="baseHandler"><inheritdoc cref="DamageHandlerBase.Base"/></param>
 protected AttackerDamageHandler(Player target, BaseHandler baseHandler)
     : base(target, baseHandler)
 {
 }
Example #7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DamagingWindowEventArgs"/> class.
 /// </summary>
 /// <param name="window"><inheritdoc cref="Window"/></param>
 /// <param name="damage">The damage being dealt.</param>
 /// <param name="handler"><inheritdoc cref="Handler"/></param>
 public DamagingWindowEventArgs(BreakableWindow window, float damage, DamageHandlerBase handler)
 {
     Window         = Window.Get(window);
     Handler        = new CustomDamageHandler(handler is AttackerDamageHandler attackerDamageHandler ? Player.Get(attackerDamageHandler.Attacker.Hub) : null, handler);
     Handler.Damage = damage;
 }
Example #8
0
 //Returns the most likely applicable damage type for the damage handler given
 public DamageTypes ParseHandler(PlayerStatsSystem.DamageHandlerBase d)
 {
     if (d.ServerLogsText == null)
     {
         return(DamageTypes.None);
     }
     if (d.ServerLogsText.Contains("Micro H.I.D."))
     {
         return(DamageTypes.MicroHID);
     }
     if (d.ServerLogsText.Contains("Fall damage"))
     {
         return(DamageTypes.Falldown);
     }
     if (d.ServerLogsText.Contains("Crushed."))
     {
         return(DamageTypes.Wall);
     }
     if (d.ServerLogsText.Contains("SCP-207"))
     {
         return(DamageTypes.Scp207);
     }
     if (d.ServerLogsText.Contains("SCP-096's charge"))
     {
         return(DamageTypes.Scp096Charge);
     }
     if (d.ServerLogsText.Contains("Melted by a highly corrosive substance"))
     {
         return(DamageTypes.Decont);
     }
     if (d.ServerLogsText.Contains("Tried to pass through a gate being breached by SCP-096"))
     {
         return(DamageTypes.Scp096Pry);
     }
     if (d.ServerLogsText.Contains("Got slapped by SCP-096"))
     {
         return(DamageTypes.Scp096);
     }
     if (d.ServerLogsText.Contains("SCP-018"))
     {
         return(DamageTypes.Scp018);
     }
     if (d.ServerLogsText.Contains("Scp0492"))
     {
         return(DamageTypes.Scp0492);
     }
     if (d.ServerLogsText.Contains("bait for SCP-106"))
     {
         return(DamageTypes.Lure);
     }
     if (d.ServerLogsText.Contains("Died to alpha warhead"))
     {
         return(DamageTypes.Nuke);
     }
     if (d.ServerLogsText.Contains("Friendly Fire"))
     {
         return(DamageTypes.FriendlyFireDetector);
     }
     if (d.ServerLogsText.Contains("Asphyxiated"))
     {
         return(DamageTypes.Asphyxiation);
     }
     if (d.ServerLogsText.Contains("GunCrossvec"))
     {
         return(DamageTypes.CrossVec);
     }
     if (d.ServerLogsText.Contains("GunCOM18"))
     {
         return(DamageTypes.Com18);
     }
     if (d.ServerLogsText.Contains("GunCOM15"))
     {
         return(DamageTypes.Com15);
     }
     if (d.ServerLogsText.Contains("GunShotgun"))
     {
         return(DamageTypes.Shotgun);
     }
     if (d.ServerLogsText.Contains("Explosion."))
     {
         return(DamageTypes.Grenade);
     }
     foreach (DamageTypes dmgtyp in DamageTypes.GetValues(typeof(DamageTypes)))
     {
         if (d.ServerLogsText.Contains(dmgtyp.ToString()))
         {
             return(dmgtyp);
         }
     }
     return(DamageTypes.Unknown);
 }