Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save sigsegv-mvm/9dd96aa6da5ee34fbf8505a0ed5d0eb9 to your computer and use it in GitHub Desktop.
Save sigsegv-mvm/9dd96aa6da5ee34fbf8505a0ed5d0eb9 to your computer and use it in GitHub Desktop.
RE: CObjectSentrygun::GetEnemyAimPosition
// Reverse engineered by sigsegv
// TF2 server, version 20170214a
Vector CObjectSentrygun::GetEnemyAimPosition(CBaseEntity *pEnemy) const
{
CTFPlayer *pTFPlayer = ToTFPlayer(pEnemy);
if (pTFPlayer != nullptr)
{
bool bOnGround = ((pTFPlayer->GetFlags() & FL_ONGROUND) != 0);
bool bDucking = ((pTFPlayer->GetFlags() & FL_DUCKING) != 0);
if ((!bOnGround && bDucking) || pTFPlayer->m_Shared.InCond(TF_COND_TAUNTING))
{
int iBoneBipSpine2 = pTFPlayer->LookupBone("bip_spine_2");
if (iBoneBipSpine2 != -1)
{
Vector vecBone; QAngle angBone;
pTFPlayer->GetBonePosition(iBoneBipSpine2, vecBone, angBone);
// special case: for players who are airborne-and-ducking, or taunting,
// shoot at their bip_spine_2 bone position instead of their hull center
return vecBone;
}
}
}
// by default, shoot at enemy's hull center
return pEnemy->WorldSpaceCenter();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment