Remove player pushack: Difference between revisions
(This tutorial shows you how to remove the annoying pushback on take damage for player entity) |
No edit summary |
||
Line 8: | Line 8: | ||
in the middle of the function youll find this block of code below | in the middle of the function youll find this block of code below | ||
{| class="wikitable" | {| class="wikitable" | ||
|+ | |+ codeblock | ||
|- | |- | ||
| | | if ( info.GetInflictor() && (GetMoveType() == MOVETYPE_WALK) && | ||
( !attacker->IsSolidFlagSet(FSOLID_TRIGGER)) ) | |||
{ | |||
Vector force = vecDir * -DamageForce( WorldAlignSize(), info.GetBaseDamage() ); | |||
if ( force.z > 250.0f ) | |||
{ | |||
force.z = 250.0f; | |||
} | |||
//ApplyAbsVelocityImpulse( force ); drn0 disabled to remove pushback on hit | |||
} | |||
|} | |} | ||
like so remove the call ApplyAbsVelocityImpulse( force ); from the end of the calculation | like so remove the call ApplyAbsVelocityImpulse( force ); from the end of the calculation | ||
Line 19: | Line 29: | ||
within this youll find the code | within this youll find the code | ||
{| class="wikitable" | {| class="wikitable" | ||
|+ | |+ code block | ||
|- | |- | ||
| | | void CBasePlayer::VelocityPunch( const Vector &vecForce ) | ||
{ | |||
// Clear onground and add velocity. | |||
SetGroundEntity( NULL ); | |||
//ApplyAbsVelocityImpulse(vecForce ); drn0 removing pushback on hit | |||
} | |||
|} | |} | ||
Revision as of 13:43, 24 June 2025
In this tutorial i will show you how to remove the push back velocity when a player takes a hit.
This tutorial was made using Source SDKbase 2013 Multiplayer - the legacy version >_> not the team fortress 2 update.
To start open your game solution - find and open the player.cpp file and find the CBasePlayer::OnTakeDamage_Alive function around line 1708
in the middle of the function youll find this block of code below
if ( info.GetInflictor() && (GetMoveType() == MOVETYPE_WALK) &&
( !attacker->IsSolidFlagSet(FSOLID_TRIGGER)) ) { Vector force = vecDir * -DamageForce( WorldAlignSize(), info.GetBaseDamage() ); if ( force.z > 250.0f ) { force.z = 250.0f; } //ApplyAbsVelocityImpulse( force ); drn0 disabled to remove pushback on hit } |
like so remove the call ApplyAbsVelocityImpulse( force ); from the end of the calculation
this removes the velocities resolution from the OnTakeDamage - but still Alive fuction
Then proceed towards line 5670 to find the void CBasePlayer::VelocityPunch( const Vector &vecForce ) function within this youll find the code
void CBasePlayer::VelocityPunch( const Vector &vecForce )
{ // Clear onground and add velocity. SetGroundEntity( NULL ); //ApplyAbsVelocityImpulse(vecForce ); drn0 removing pushback on hit } |
this is the initial velocity function to set the force applied at the time i believe so we remove that tihs too.
go ahead and compile the solution - there shouldnt be any errors but if you get any let me know. now when you get hit you dont get magically slide backwards 2 arm lengths away - you just stand there and eat it. this was implemented in A Nights Haunting: Source