All that does is call TakeDamage, which I'm already doing.
CBasePlayer::TraceAttack calls AddMultiDamage(), which does this:
Code:
void AddMultiDamage( entvars_t *pevInflictor, CBaseEntity *pEntity, float flDamage, int bitsDamageType)
{
if ( !pEntity )
return;
gMultiDamage.type |= bitsDamageType;
if ( pEntity != gMultiDamage.pEntity )
{
ApplyMultiDamage(pevInflictor,pevInflictor); // UNDONE: wrong attacker!
gMultiDamage.pEntity = pEntity;
gMultiDamage.amount = 0;
}
gMultiDamage.amount += flDamage;
}
So in the end TraceAttack should send TakeDamage by itself, but it doesn't. At least not correctly...
I'm not sure what Arkshine's comment means, is it bugged in the CSSDK itself? If it is, that would kinda explain why there's no killer shown in the DeathMsg.
Anyway, seeing that my way is more or less correct, the real question still exists: How to fool TakeDamage so teamplayers can attack each other even if mp_friendlyfire is off? The only solution I can think of is to set mp_friendlyfire to 1 right before the damage and back to 0 after it, but is there anything better that this? It sounds dirty.