Skip to content
Merged
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
19 changes: 18 additions & 1 deletion apps/counterstrikesharp/src/FiveStack.Events/PlayerDamage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,12 @@ public HookResult OnPlayerDamage(EventPlayerHurt @event, GameEventInfo info)
? $"{Convert.ToInt32(attackerLocation.X)} {Convert.ToInt32(attackerLocation.Y)} {Convert.ToInt32(attackerLocation.Z)}"
: ""
},
{ "weapon", $"{(@event.Weapon.Length == 0 ? "worldent" : @event.Weapon)}" },
{
"weapon",
@event.Weapon.Length == 0
? "worldent"
: CommunityWeapons.InHand(@event.Weapon, ActiveItemDefinitionIndex(attacker))
},
{ "damage", damageDealt },
{ "damage_armor", @event.DmgArmor },
{ "hitgroup", $"{DamageUtility.HitGroupToString(@event.Hitgroup)}" },
Expand All @@ -87,4 +92,16 @@ public HookResult OnPlayerDamage(EventPlayerHurt @event, GameEventInfo info)

return HookResult.Continue;
}

private static int? ActiveItemDefinitionIndex(CCSPlayerController? player)
{
CBasePlayerWeapon? weapon = player?.PlayerPawn.Value?.WeaponServices?.ActiveWeapon.Value;

if (weapon == null || !weapon.IsValid)
{
return null;
}

return weapon.AttributeManager.Item.ItemDefinitionIndex;
}
}
19 changes: 18 additions & 1 deletion apps/swiftly/src/FiveStack.Events/PlayerDamage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,12 @@ public HookResult OnPlayerDamage(EventPlayerHurt @event)
? $"{Convert.ToInt32(attackerLocation.Value.X)} {Convert.ToInt32(attackerLocation.Value.Y)} {Convert.ToInt32(attackerLocation.Value.Z)}"
: ""
},
{ "weapon", @event.Weapon.Length == 0 ? "worldent" : @event.Weapon },
{
"weapon",
@event.Weapon.Length == 0
? "worldent"
: CommunityWeapons.InHand(@event.Weapon, ActiveItemDefinitionIndex(attackerPawn))
},
{ "damage", damageDealt },
{ "damage_armor", @event.DmgArmor },
{ "hitgroup", DamageUtility.HitGroupToString((int)@event.ActualHitGroup) },
Expand All @@ -97,4 +102,16 @@ public HookResult OnPlayerDamage(EventPlayerHurt @event)
return HookResult.Continue;
}
#pragma warning restore CS0618

private static int? ActiveItemDefinitionIndex(CCSPlayerPawn? pawn)
{
CBasePlayerWeapon? weapon = pawn?.WeaponServices?.ActiveWeapon.Value;

if (weapon == null || !weapon.IsValid)
{
return null;
}

return weapon.AttributeManager.Item.ItemDefinitionIndex;
}
}
Loading