game/server/npc_wretch.cpp
void CWretch::LeapAttack( void )
{
	SetGroundEntity( NULL );

	BeginAttackJump();

	LeapAttackSound();

	//
	// Take him off ground so engine doesn't instantly reset FL_ONGROUND.
	//
	UTIL_SetOrigin( this, GetLocalOrigin() + Vector( 0 , 0 , 1 ));

	Vector vecJumpDir;
	CBaseEntity *pEnemy = GetEnemy();

	if ( pEnemy )
	{
		Vector vecEnemyPos = pEnemy->WorldSpaceCenter();

		float gravity = GetCurrentGravity();
		if ( gravity <= 1 )
		{
			gravity = 1;
		}

		//
		// How fast does the zombie need to travel to reach my enemy's eyes given gravity?
		//
		float height = ( vecEnemyPos.z - GetAbsOrigin().z );

		if ( height < 16 )
		{
			height = 16;
		}
		else if ( height > 120 )
		{
			height = 120;
		}
		float speed = sqrt( 2 * gravity * height );
		float time = speed / gravity;

		//
		// Scale the sideways velocity to get there at the right time
		//
		vecJumpDir = vecEnemyPos - GetAbsOrigin();
		vecJumpDir = vecJumpDir / time;

		//
		// Speed to offset gravity at the desired height.
		//
		vecJumpDir.z = speed;

		//
		// Don't jump too far/fast.
		//
#define CLAMP 1000.0
		float distance = vecJumpDir.Length();
		if ( distance > CLAMP )
		{
			vecJumpDir = vecJumpDir * ( CLAMP / distance );
		}

		// try speeding up a bit.
		SetAbsVelocity( vecJumpDir );
		m_flNextAttack = gpGlobals->curtime + 2;
	}
}
//-----------------------------------------------------------------------------
// Purpose: Jump at the enemy!! (stole this from the headcrab)
//
//
//-----------------------------------------------------------------------------
Jump at the enemy!. (stole this from the headcrab)
Jump at the enemy! . ( stole this from the headcrab )
void CWretch::LeapAttack( void )
{
	SetGroundEntity( NULL );
	BeginAttackJump();
	LeapAttackSound();
	 Take him off ground so engine doesn't instantly reset FL_ONGROUND.
	UTIL_SetOrigin( this, GetLocalOrigin() + Vector( 0 , 0 , 1 ));
	Vector vecJumpDir;
	CBaseEntity *pEnemy = GetEnemy();
	if ( pEnemy )
	{
		Vector vecEnemyPos = pEnemy->WorldSpaceCenter();
		float gravity = GetCurrentGravity();
		if ( gravity <= 1 )
		{
			gravity = 1;
		}
		 How fast does the zombie need to travel to reach my enemy's eyes given gravity?
		float height = ( vecEnemyPos.z - GetAbsOrigin().z );
		if ( height < 16 )
		{
			height = 16;
		}
		else if ( height > 120 )
		{
			height = 120;
		}
		float speed = sqrt( 2 * gravity * height );
		float time = speed / gravity;
		 Scale the sideways velocity to get there at the right time
		vecJumpDir = vecEnemyPos - GetAbsOrigin();
		vecJumpDir = vecJumpDir / time;
		 Speed to offset gravity at the desired height.
		vecJumpDir.z = speed;
		 Don't jump too far/fast.
#define CLAMP 1000.0
		float distance = vecJumpDir.Length();
		if ( distance > CLAMP )
		{
			vecJumpDir = vecJumpDir * ( CLAMP / distance );
		}
		 try speeding up a bit.
		SetAbsVelocity( vecJumpDir );
		m_flNextAttack = gpGlobals->curtime + 2;
	}
}
void CWretch :: LeapAttack ( void ) { SetGroundEntity ( NULL ) ; BeginAttackJump ( ) ; LeapAttackSound ( ) ; UTIL_SetOrigin ( this , GetLocalOrigin ( ) + Vector ( 0 , 0 , 1 ) ) ; Vector vecJumpDir ; CBaseEntity * pEnemy = GetEnemy ( ) ; if ( pEnemy ) { Vector vecEnemyPos = pEnemy -> WorldSpaceCenter ( ) ; float gravity = GetCurrentGravity ( ) ; if ( gravity <= 1 ) { gravity = 1 ; } float height = ( vecEnemyPos . z - GetAbsOrigin ( ) . z ) ; if ( height < 16 ) { height = 16 ; } else if ( height > 120 ) { height = 120 ; } float speed = sqrt ( 2 * gravity * height ) ; float time = speed / gravity ; vecJumpDir = vecEnemyPos - GetAbsOrigin ( ) ; vecJumpDir = vecJumpDir / time ; vecJumpDir . z = speed ; #define CLAMP  1000.0 float distance = vecJumpDir . Length ( ) ; if ( distance > CLAMP ) { vecJumpDir = vecJumpDir * ( CLAMP / distance ) ; } SetAbsVelocity ( vecJumpDir ) ; m_flNextAttack = gpGlobals -> curtime + 2 ; } }
Purpose: Jump at the enemy!!
Purpose : Jump at the enemy!!
// // Take him off ground so engine doesn't instantly reset FL_ONGROUND. // // // How fast does the zombie need to travel to reach my enemy's eyes given gravity? // // // Scale the sideways velocity to get there at the right time // // // Speed to offset gravity at the desired height. // // // Don't jump too far/fast. // // try speeding up a bit.