Quote:
Originally Posted by Powerlord
I just checked the Superlogs support for HL2DM, and it does check the hitgroup using TraceAttack to see if it's equal to 1 (HITGROUP_HEAD from wstatshelper.inc).
Are you sure headshots are returning hitgroup 0?
Alternately, make sure you're using the correct arguments in your callbacks:
PHP Code:
// TraceAttack
Action:public(victim, &attacker, &inflictor, &Float:damage, &damagetype, &ammotype, hitbox, hitgroup),
// TraceAttackPost
public(victim, attacker, inflictor, Float:damage, damagetype, ammotype, hitbox, hitgroup),
|
Here's some test code I've been using to see what TraceAttackPost is seeing.
In superlogs-hl2mp.sp (Version 1.1.3) I've changed OnTraceAttack to:
PHP Code:
public OnTraceAttack(victim, attacker, inflictor, Float:damage, damagetype, ammotype, hitbox, hitgroup)
{
PrintToServer("SuperLogs:hl2mp 208 OnTraceAttack hitgroup=%d", hitgroup);
if (hitgroup > 0 && attacker > 0 && attacker <= MaxClients && victim > 0 && victim <= MaxClients)
{
if (IsValidEntity(inflictor))
{
decl String:inflictorclsname[64];
if (GetEntityNetClass(inflictor, inflictorclsname, sizeof(inflictorclsname)) && strcmp(inflictorclsname, "CCrossbowBolt") == 0)
{
PrintToServer("SuperLogs:hl2mp OnTraceAttack CCrossbowBolt; inflictorclsname=%s hitgroup = %d", inflictorclsname,hitgroup);
g_iNextBowHitgroup[victim] = hitgroup;
return;
} else {
PrintToServer("SuperLogs:hl2mp OnTraceAttack inflictor inflictor=%d classname=%s",inflictor,inflictorclsname);
}
}
g_iNextHitgroup[victim] = hitgroup;
}
}
With the 357 hitgroup is 1, as evidenced by the server output:
Quote:
SuperLogs:hl2mp 208 OnTraceAttack hitgroup=1
SuperLogs:hl2mp OnTraceAttack inflictor inflictor=1 classname=CHL2MP_Player
L 01/24/2013 - 13:02:05: World triggered "killlocation" (attacker_position "1588 103 -1") (victim_position "1208 208 33")
L 01/24/2013 - 13:02:05: "[foo] bar<2><STEAM_0:0:15703618><Unassigned>" triggered "headshot"
L 01/24/2013 - 13:02:05: "[foo] bar<2><STEAM_0:0:15703618><Unassigned>" killed "spawnkillerbait<3><STEAM_0:0:59539635><Unass igned>" with "357"
|
With crossbow, I see:
Quote:
SuperLogs:hl2mp 208 OnTraceAttack hitgroup=0
L 01/24/2013 - 13:02:16: World triggered "killlocation" (attacker_position "1588 103 -1") (victim_position "1208 208 33")
L 01/24/2013 - 13:02:16: "[foo] bar<2><STEAM_0:0:15703618><Unassigned>" killed "spawnkillerbait<3><STEAM_0:0:59539635><Unass igned>" with "crossbow_bolt"
|
Note that there is no "triggered headshot" log from superlogs on the crossbow hit either, but there is for the 357.
A much simpler test yields the same result:
PHP Code:
#include <sourcemod>
#include <smlib>
#include <sdkhooks>
#include <sdktools_sound.inc>
public OnPluginStart()
{
for(new i=1;i<MaxClients;i++){
if(IsClientInGame(i))
{
SDKHook(i, SDKHook_TraceAttackPost,Event_TrackAttack);
}
}
}
public OnClientPutInServer(client)
{
SDKHook(client, SDKHook_TraceAttackPost,Event_TrackAttack);
}
public Action:Event_TrackAttack(victim, &attacker, &inflictor, &Float:damage, &damagetype, &ammotype, hitbox, hitgroup)
{
PrintToServer("Bowtest TraceAttack: victim=%d,inflictor=%d,hitgroup=%d",victim,inflictor,hitgroup);
}
Quote:
|
Bowtest TraceAttack: victim=2,inflictor=25970,hitgroup=0
|
Now I do see that superlogs-hl2mp is doing some mangling in OnTakeDamage but hitgroup starts out 0, and ends up being set to 7.
PHP Code:
public OnTakeDamage(victim, attacker, inflictor, Float:damage, damagetype)
{
if (attacker > 0 && attacker <= MaxClients && victim > 0 && victim <= MaxClients)
{
decl String: weapon[MAX_WEAPON_LEN + PREFIX_LEN];
GetClientWeapon(attacker, weapon, sizeof(weapon));
new weapon_index = -1;
if (IsValidEntity(inflictor))
{
decl String:inflictorclsname[64];
if (GetEntityNetClass(inflictor, inflictorclsname, sizeof(inflictorclsname)) && strcmp(inflictorclsname, "CCrossbowBolt") == 0)
{
PrintToServer("OnTakeDamage: inflictorclsname=%s", inflictorclsname);
weapon_index = CROSSBOW;
}
}
if (weapon_index == -1)
{
weapon_index = get_weapon_index(weapon[PREFIX_LEN]);
}
new hitgroup = ((weapon_index == CROSSBOW)?g_iNextBowHitgroup[victim]:g_iNextHitgroup[victim]);
PrintToServer("OnTakeDamage 251 hitgroup=%d",hitgroup);
if (hitgroup < 8)
{
hitgroup += LOG_HIT_OFFSET;
PrintToServer("OnTakeDamage 255 hitgroup=%d",hitgroup);
}
new bool:headshot = (GetClientHealth(victim) <= 0 && hitgroup == HITGROUP_HEAD);
PrintToServer("OnTakeDamage: hitgroup=%d",hitgroup);
PrintToServer("OnTakeDamage: weapon_index=%d",weapon_index);
if (weapon_index > -1)
{
g_weapon_stats[attacker][weapon_index][LOG_HIT_HITS]++;
g_weapon_stats[attacker][weapon_index][LOG_HIT_DAMAGE] += RoundToNearest(damage);
g_weapon_stats[attacker][weapon_index][hitgroup]++;
if (headshot)
{
PrintToServer("This was a headshot!");
g_weapon_stats[attacker][weapon_index][LOG_HIT_HEADSHOTS]++;
} else {
PrintToServer("Not a headshot");
}
}
if (weapon_index == CROSSBOW)
{
g_iNextBowHitgroup[victim] = 0;
}
else
{
g_iNextHitgroup[victim] = 0;
}
}
}
yields:
Quote:
L 01/24/2013 - 13:11:27: World triggered "killlocation" (attacker_position "1588 103 -1") (victim_position "1208 208 33")
L 01/24/2013 - 13:11:27: "[foo] bar<2><STEAM_0:0:15703618><Unassigned>" killed "spawnkillerbait<3><STEAM_0:0:59539635><Unass igned>" with "crossbow_bolt"
OnTakeDamage: inflictorclsname=CCrossbowBolt
OnTakeDamage 251 hitgroup=0
OnTakeDamage 255 hitgroup=7
OnTakeDamage: hitgroup=7
OnTakeDamage: weapon_index=0
Not a headshot
|
I'm not sure what to make of this at the moment. I will need to spend some more time walking through this.
[foo] bar