Skip to content

Instantly share code, notes, and snippets.

@sigsegv-mvm
Created November 27, 2017 00:27
Show Gist options
  • Save sigsegv-mvm/7fd6f0b03aa92a4f667529cc96009911 to your computer and use it in GitHub Desktop.
Save sigsegv-mvm/7fd6f0b03aa92a4f667529cc96009911 to your computer and use it in GitHub Desktop.
TFPlayer body part scaling speeds
// TF2 20171020a server_srv.so
// reverse engineering by sigsegv
float CTFPlayer::GetDesiredHeadScale()
{
float desired = 1.0f;
CALL_ATTRIB_HOOK_FLOAT(desired, head_scale);
return desired;
}
float CTFPlayer::GetDesiredTorsoScale()
{
float desired = 1.0f;
CALL_ATTRIB_HOOK_FLOAT(desired, torso_scale);
return desired;
}
float CTFPlayer::GetDesiredHandScale()
{
float desired = 1.0f;
CALL_ATTRIB_HOOK_FLOAT(desired, hand_scale);
return desired;
}
float CTFPlayer::GetHeadScaleSpeed()
{
/* scale instantly if in any of these conditions */
if (this->m_Shared.InCond(TF_COND_HALLOWEEN_BOMB_HEAD)) return this->GetDesiredHeadScale();
if (this->m_Shared.InCond(TF_COND_MELEE_ONLY)) return this->GetDesiredHeadScale();
if (this->m_Shared.InCond(TF_COND_HALLOWEEN_KART)) return this->GetDesiredHeadScale();
if (this->m_Shared.InCond(TF_COND_HALLOWEEN_BALLOON_HEAD)) return this->GetDesiredHeadScale();
/* otherwise, scale at approximately 1.0x per second */
return gpGlobals->frametime;
}
float CTFPlayer::GetTorsoScaleSpeed()
{
/* scale at approximately 1.0x per second */
return gpGlobals->frametime;
}
float CTFPlayer::GetHandScaleSpeed()
{
/* scale instantly if in this condition */
if (this->m_Shared.InCond(TF_COND_MELEE_ONLY)) return this->GetDesiredHandScale();
/* otherwise, scale at approximately 1.0x per second */
return gpGlobals->frametime;
}
/* this Think function is called once per tick */
void CTFPlayer::TFPlayerThink()
{
// ...
this->m_flHeadScale = Approach(this->GetDesiredHeadScale(), this->m_flHeadScale, this->GetHeadScaleSpeed());
this->m_flTorsoScale = Approach(this->GetDesiredTorsoScale(), this->m_flTorsoScale, this->GetTorsoScaleSpeed());
this->m_flHandScale = Approach(this->GetDesiredHandScale(), this->m_flHandScale, this->GetHandScaleSpeed());
// ...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment