Thanks for all the suggestions.
I figured out what was wrong...
The weird problems happen when you,
1) check if it is NOT a bot being traced lined and
2) you DON"T check for a body part hit and
3) you deny the damage!
If it isn't a FL_FAKECLIENT it doesn't mean it IS a human.
It could be anything! And when it ISN"T a HUMAN and you refuse the TraceLine() weird thigns will happen because ALL tracelines on
most everything will fail. (as everyone was indicating...)
To get done what I am trying to do:
1) no head shots to human and
2) every 4th bullet doesn't do damage, here is the code:
This works fine.
Code:
// ---------------------------------------------------------------------------------------
// TraceLine()
// Disallow headshot damange to human players + skip damge from every 4th shot
// ---------------------------------------------------------------------------------------
void TraceLine(const float *v1, const float *v2, int fNoMonsters, edict_t *pentToSkip, TraceResult *ptr)
{
static int skipHit = 0;
TRACE_LINE(v1, v2, fNoMonsters, pentToSkip, ptr);
// is a human taking damage?
if ( !(ptr->pHit->v.flags & FL_FAKECLIENT) )
{
// is it a head shot?
if( (1<<HITGROUP_HEAD) & (1<<ptr->iHitgroup) )
{
// disallow head shots to humans, return no damage
ptr->flFraction = 1.0;
RETURN_META(MRES_SUPERCEDE);
}
else if ( (1<<HITGROUP_ANY) & (1<<ptr->iHitgroup) )
{
if(skipHit >= 4)
{
// skip damage from every 4th shot!
skipHit = 0;
ptr->flFraction = 1.0;
RETURN_META(MRES_SUPERCEDE);
}
else
{
skipHit++;
}
}
}// not a human
RETURN_META(MRES_IGNORED);
}
The weird problems were fixed when I added a check to see what if any body part was hit and then only refuse it.