Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 28 additions & 5 deletions EXILED/Exiled.API/Enums/DamageType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ namespace Exiled.API.Enums
{
using Features;

using InventorySystem.Items.Firearms.Modules;
using InventorySystem.Items.Jailbird;

using PlayerRoles;

/// <summary>
Expand Down Expand Up @@ -145,9 +148,9 @@ public enum DamageType
Scp173,

/// <summary>
/// Damage caused by <see cref="RoleTypeId.Scp939"/> with <see cref="PlayerRoles.PlayableScps.Scp939.Scp939DamageType.None"/>.
/// Damage caused by <see cref="RoleTypeId.Scp939"/> with <see cref="PlayerRoles.PlayableScps.Scp939.Scp939DamageType.None"/> or Unknown.
/// </summary>
Scp939None,
Scp939Other,

/// <summary>
/// Damage caused by <see cref="RoleTypeId.Scp0492"/>.
Expand Down Expand Up @@ -210,9 +213,9 @@ public enum DamageType
Hypothermia,

/// <summary>
/// Damage caused by <see cref="ItemType.ParticleDisruptor"/>.
/// Damage caused by <see cref="ItemType.ParticleDisruptor"/> when <see cref="DisruptorActionModule.FiringState.None"/> or Unknown.
/// </summary>
ParticleDisruptor,
ParticleDisruptorOther,

/// <summary>
/// Damage caused by <see cref="EffectType.CardiacArrest"/>.
Expand All @@ -227,7 +230,7 @@ public enum DamageType
/// <summary>
/// Damage caused by <see cref="ItemType.Jailbird"/>.
/// </summary>
Jailbird,
JailbirdOther,

/// <summary>
/// Damage caused by <see cref="ItemType.GunFRMG0"/>.
Expand Down Expand Up @@ -368,5 +371,25 @@ public enum DamageType
/// Damage dealt by a <see cref="Features.Items.MicroHid"/> when <see cref="InventorySystem.Items.MicroHID.Modules.MicroHidFiringMode.BrokenFire"/>.
/// </summary>
MicroHidBrokenFire,

/// <summary>
/// Damage caused by <see cref="ItemType.Jailbird"/> when <see cref="JailbirdItem._charging"/>.
/// </summary>
JailbirdCharged,

/// <summary>
/// Damage caused by <see cref="ItemType.Jailbird"/> when swinging.
/// </summary>
JailbirdSwing,

/// <summary>
/// Damage caused by <see cref="ItemType.ParticleDisruptor"/> when <see cref="DisruptorActionModule.FiringState.FiringRapid"/>.
/// </summary>
ParticleDisruptorRapidShot,

/// <summary>
/// Damage caused by <see cref="ItemType.ParticleDisruptor"/> when <see cref="DisruptorActionModule.FiringState.FiringSingle"/>.
/// </summary>
ParticleDisruptorSingleShot,
}
}
35 changes: 26 additions & 9 deletions EXILED/Exiled.API/Extensions/DamageTypeExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ namespace Exiled.API.Extensions

using Features;

using InventorySystem.Items.Firearms.Modules;
using InventorySystem.Items.Jailbird;
using InventorySystem.Items.MicroHID.Modules;
using InventorySystem.Items.Scp1509;

Expand Down Expand Up @@ -80,8 +82,8 @@ public static class DamageTypeExtensions
{ ItemType.GunFSP9, DamageType.Fsp9 },
{ ItemType.GunE11SR, DamageType.E11Sr },
{ ItemType.MicroHID, DamageType.MicroHidPrimaryFire },
{ ItemType.ParticleDisruptor, DamageType.ParticleDisruptor },
{ ItemType.Jailbird, DamageType.Jailbird },
{ ItemType.ParticleDisruptor, DamageType.ParticleDisruptorOther },
{ ItemType.Jailbird, DamageType.JailbirdOther },
{ ItemType.GunFRMG0, DamageType.Frmg0 },
{ ItemType.GunA7, DamageType.A7 },
{ ItemType.GunSCP127, DamageType.Scp127 },
Expand Down Expand Up @@ -111,8 +113,8 @@ public static class DamageTypeExtensions
public static bool IsWeapon(this DamageType type, bool checkNonFirearm = true) => type switch
{

DamageType.Crossvec or DamageType.Logicer or DamageType.Revolver or DamageType.Shotgun or DamageType.AK or DamageType.Com15 or DamageType.Com18 or DamageType.E11Sr or DamageType.Fsp9 or DamageType.ParticleDisruptor or DamageType.Com45 or DamageType.Frmg0 or DamageType.A7 or DamageType.Scp127 => true,
DamageType.MicroHidPrimaryFire or DamageType.MicroHidChargeFire or DamageType.MicroHidBrokenFire or DamageType.Jailbird when checkNonFirearm => true,
DamageType.Crossvec or DamageType.Logicer or DamageType.Revolver or DamageType.Shotgun or DamageType.AK or DamageType.Com15 or DamageType.Com18 or DamageType.E11Sr or DamageType.Fsp9 or DamageType.ParticleDisruptorOther or DamageType.ParticleDisruptorRapidShot or DamageType.ParticleDisruptorSingleShot or DamageType.Com45 or DamageType.Frmg0 or DamageType.A7 or DamageType.Scp127 => true,
DamageType.MicroHidPrimaryFire or DamageType.MicroHidChargeFire or DamageType.MicroHidBrokenFire or DamageType.JailbirdOther or DamageType.JailbirdCharged or DamageType.JailbirdSwing when checkNonFirearm => true,
_ => false,
};

Expand All @@ -124,7 +126,7 @@ public static class DamageTypeExtensions
/// <returns>Returns whether the <see cref="DamageType"/> is caused by SCP.</returns>
public static bool IsScp(this DamageType type, bool checkItems = true) => type switch
{
DamageType.Scp or DamageType.Scp049 or DamageType.Scp096SlapLeft or DamageType.Scp096SlapRight or DamageType.Scp096Charge or DamageType.Scp096GateKill or DamageType.Scp096Other or DamageType.Scp106 or DamageType.Scp173 or DamageType.Scp939None or DamageType.Scp939Claw or DamageType.Scp939LungeTarget or DamageType.Scp939LungeSecondary or DamageType.Scp0492 or DamageType.Scp3114 or DamageType.Scp3114SkinSteal => true,
DamageType.Scp or DamageType.Scp049 or DamageType.Scp096SlapLeft or DamageType.Scp096SlapRight or DamageType.Scp096Charge or DamageType.Scp096GateKill or DamageType.Scp096Other or DamageType.Scp106 or DamageType.Scp173 or DamageType.Scp939Other or DamageType.Scp939Claw or DamageType.Scp939LungeTarget or DamageType.Scp939LungeSecondary or DamageType.Scp0492 or DamageType.Scp3114 or DamageType.Scp3114SkinSteal => true,
DamageType.Scp018 or DamageType.Scp207 when checkItems => true,
_ => false,
};
Expand All @@ -141,7 +143,7 @@ public static class DamageTypeExtensions
/// </summary>
/// <param name="type">The damage type to be checked.</param>
/// <returns>Returns whether the <see cref="DamageType"/> is caused by SCP.</returns>
public static bool IsScp939(this DamageType type) => type is DamageType.Scp939None or DamageType.Scp939Claw or DamageType.Scp939LungeTarget or DamageType.Scp939LungeSecondary;
public static bool IsScp939(this DamageType type) => type is DamageType.Scp939Other or DamageType.Scp939Claw or DamageType.Scp939LungeTarget or DamageType.Scp939LungeSecondary;

/// <summary>
/// Check if a <see cref="DamageType">damage type</see> is caused by <see cref="RoleTypeId.Scp049"/>>.
Expand Down Expand Up @@ -222,8 +224,20 @@ public static DamageType GetDamageType(DamageHandlerBase damageHandlerBase)
MicroHidFiringMode.BrokenFire => DamageType.MicroHidBrokenFire,
_ => DamageType.Unknown,
};
case DisruptorDamageHandler:
return DamageType.ParticleDisruptor;
case JailbirdDamageHandler jailbirdDamageHandler:
if (jailbirdDamageHandler.Attacker.Hub?.inventory.CurInstance is not JailbirdItem jailbirdItem)
return DamageType.JailbirdOther;

return jailbirdItem._charging ? DamageType.JailbirdCharged : DamageType.JailbirdSwing;

case DisruptorDamageHandler disruptorDamageHandler:
return disruptorDamageHandler.FiringState switch
{
DisruptorActionModule.FiringState.FiringRapid => DamageType.ParticleDisruptorRapidShot,
DisruptorActionModule.FiringState.FiringSingle => DamageType.ParticleDisruptorSingleShot,
DisruptorActionModule.FiringState.None => DamageType.ParticleDisruptorOther,
_ => DamageType.ParticleDisruptorOther,
};
case Scp1507DamageHandler:
return DamageType.Scp1507;
case Scp956DamageHandler:
Expand All @@ -250,7 +264,7 @@ public static DamageType GetDamageType(DamageHandlerBase damageHandlerBase)
Scp939DamageType.Claw => DamageType.Scp939Claw,
Scp939DamageType.LungeTarget => DamageType.Scp939LungeTarget,
Scp939DamageType.LungeSecondary => DamageType.Scp939LungeSecondary,
_ => DamageType.Scp939None,
_ => DamageType.Scp939Other,
};
case Scp3114DamageHandler scp3114DamageHandler:
return scp3114DamageHandler.Subtype switch
Expand Down Expand Up @@ -298,6 +312,9 @@ public static DamageType GetDamageType(DamageHandlerBase damageHandlerBase)
return DamageType.Unknown;
}

case null:
return DamageType.Unknown;

default:
{
if (damageHandlerBase.GetType().Assembly.FullName.StartsWith("Assembly-CSharp"))
Expand Down
21 changes: 17 additions & 4 deletions EXILED/Exiled.API/Features/DamageHandlers/GenericDamageHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ namespace Exiled.API.Features.DamageHandlers

using UnityEngine;

using static InventorySystem.Items.Firearms.Modules.DisruptorActionModule;

/// <summary>
/// Allows generic damage to a player.
/// </summary>
Expand Down Expand Up @@ -118,7 +120,9 @@ public GenericDamageHandler(Player player, Player attacker, float damage, Damage
case DamageType.Recontainment:
Base = new RecontainmentDamageHandler(Attacker);
break;
case DamageType.Jailbird:
case DamageType.JailbirdOther:
case DamageType.JailbirdCharged:
case DamageType.JailbirdSwing:
Base = new JailbirdDamageHandler(Attacker.Hub, damage, Vector3.zero);
break;
case DamageType.Scp1509:
Expand Down Expand Up @@ -179,8 +183,17 @@ public GenericDamageHandler(Player player, Player attacker, float damage, Damage
case DamageType.Scp127:
GenericFirearm(damage, ItemType.GunSCP127);
break;
case DamageType.ParticleDisruptor:
Base = new DisruptorDamageHandler(new DisruptorShotEvent(default, Attacker, InventorySystem.Items.Firearms.Modules.DisruptorActionModule.FiringState.FiringSingle), Vector3.up, damage);
case DamageType.ParticleDisruptorOther:
case DamageType.ParticleDisruptorRapidShot:
case DamageType.ParticleDisruptorSingleShot:
FiringState state = damageType switch
{
DamageType.ParticleDisruptorRapidShot => FiringState.FiringRapid,
DamageType.ParticleDisruptorSingleShot => FiringState.FiringSingle,
DamageType.ParticleDisruptorOther => FiringState.None,
_ => FiringState.None,
};
Base = new DisruptorDamageHandler(new DisruptorShotEvent(default, Attacker, state), Vector3.up, damage);
break;
case DamageType.Scp096Other:
Scp096Role curr096 = attacker.ReferenceHub.roleManager.CurrentRole as Scp096Role ?? new Scp096Role();
Expand All @@ -189,7 +202,7 @@ public GenericDamageHandler(Player player, Player attacker, float damage, Damage

Base = new Scp096DamageHandler(curr096, damage, Scp096DamageHandler.AttackType.SlapRight);
break;
case DamageType.Scp939None:
case DamageType.Scp939Other:
Scp939Role curr939 = attacker.ReferenceHub.roleManager.CurrentRole as Scp939Role ?? new Scp939Role();

curr939?._lastOwner = attacker.ReferenceHub;
Expand Down
Loading