Created
September 25, 2015 09:13
-
-
Save sigsegv-mvm/269d1e0abacb29040b5c to your computer and use it in GitHub Desktop.
TF2 airblast physics code
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// airblast physics code | |
// TF2 version 20150924 | |
// reverse engineered by sigsegv | |
void CTFFlameThrower::DeflectPlayer(CTFPlayer *player, Vector const& vec_in) | |
{ | |
Vector vec = vec_in; | |
// not shown: some math related to scaling vec | |
float airblast_pushback_scale = | |
CAttributeManager::AttribHookValue(1.0f, | |
"airblast_pushback_scale", this, nullptr, true); | |
float airblast_vertical_pushback_scale = | |
CAttributeManager::AttribHookValue(1.0f, | |
"airblast_vertical_pushback_scale", this, nullptr, true); | |
// this will be 1.0 for regular sized players | |
// for 1.75-scale giants, this is ~5.36 (1.75 cubed) | |
float hull_size_factor = | |
(player->m_collision.m_vecMins.x / 48) * | |
(player->m_collision.m_vecMins.y / 48) * | |
(player->m_collision.m_vecMins.z / 82); | |
// this will be 360 for regular sized players | |
// or roughly 67 for 1.75-scale giants | |
float impulse = 360 / hull_size_factor; | |
impulse = MIN(1000, impulse); | |
vec *= impulse; | |
vec *= airblast_pushback_scale; | |
// tf_flamethrower_burst_zvelocity: hidden cvar, default is 350 | |
vec.z += (tf_flamethrower_burst_zvelocity * | |
airblast_vertical_pushback_scale); | |
player->ApplyAirBlastImpulse(&vec); | |
} | |
void CTFPlayer::ApplyAirBlastImpulse(Vector const& vec_in) | |
{ | |
/* Mannpower: knockout gives airblast immunity */ | |
if (this->m_Shared.GetCarryingRuneType() == 8) { | |
return; | |
} | |
Vector vec = vec_in; | |
float airblast_vulnerability_multiplier = | |
CAttributeManager::AttribHookValue(1.0f, | |
"airblast_vulnerability_multiplier", this, nullptr, true); | |
float airblast_vertical_vulnerability_multiplier = | |
CAttributeManager::AttribHookValue(1.0f, | |
"airblast_vertical_vulnerability_multiplier", this, nullptr, true); | |
vec *= airblast_vulnerability_multiplier; | |
bool onground = ((this->m_fFlags & FL_ONGROUND) != 0); | |
if (onground && vec.z < 268.32816f) { | |
vec.z = 268.32816f; | |
} | |
vec.z *= airblast_vertical_vulnerability_multiplier; | |
this->RemoveFlag(FL_ONGROUND); | |
this->ApplyAbsVelocityImpulse(vec); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment