2009-04-29 01:58:41 +02:00
|
|
|
/*
|
|
|
|
* ============================================================================
|
|
|
|
*
|
|
|
|
* Zombie:Reloaded
|
|
|
|
*
|
2009-05-06 02:28:09 +02:00
|
|
|
* File: jumpboost.inc
|
|
|
|
* Type: Module
|
|
|
|
* Description: Modified jump vector magnitudes.
|
2009-04-29 01:58:41 +02:00
|
|
|
*
|
|
|
|
* ============================================================================
|
|
|
|
*/
|
|
|
|
|
2009-05-12 04:56:03 +02:00
|
|
|
/**
|
|
|
|
* The maximum forward velocity client can have for any additional push to be applied.
|
|
|
|
*/
|
|
|
|
#define JUMPBOOST_FORWARD_VEL_MAX 275.0
|
|
|
|
|
2009-04-29 01:58:41 +02:00
|
|
|
/**
|
|
|
|
* Client is jumping.
|
|
|
|
*
|
|
|
|
* @param client The client index.
|
|
|
|
*/
|
|
|
|
JumpBoostOnClientJump(client)
|
|
|
|
{
|
|
|
|
// Get class jump multipliers.
|
|
|
|
new Float:distance = ClassGetJumpDistance(client);
|
|
|
|
new Float:height = ClassGetJumpHeight(client);
|
|
|
|
|
|
|
|
// Get client's current velocity.
|
|
|
|
new Float:vecVelocity[3];
|
|
|
|
ToolsClientVelocity(client, vecVelocity, false);
|
|
|
|
|
2009-05-15 07:25:07 +02:00
|
|
|
// Protect against bunnyhopping, if cvar is enabled.
|
|
|
|
new bool:bunnyhopprotect = GetConVarBool(g_hCvarsList[CVAR_JUMPBOOST_BUNNYHOP_PROTECT]);
|
|
|
|
if (bunnyhopprotect)
|
2009-05-12 04:56:03 +02:00
|
|
|
{
|
2009-05-15 07:25:07 +02:00
|
|
|
new Float:magnitude = SquareRoot(Pow(vecVelocity[0], 2.0) + Pow(vecVelocity[1], 2.0));
|
|
|
|
if (magnitude >= JUMPBOOST_FORWARD_VEL_MAX)
|
|
|
|
{
|
|
|
|
// Set distance multiplier to 0.
|
|
|
|
distance = 0.0;
|
|
|
|
}
|
2009-05-12 04:56:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Apply forward jump boost.
|
2009-04-29 01:58:41 +02:00
|
|
|
vecVelocity[0] *= distance;
|
|
|
|
vecVelocity[1] *= distance;
|
2009-05-12 04:56:03 +02:00
|
|
|
|
|
|
|
// Apply vertical jump boost.
|
2009-05-10 18:49:47 +02:00
|
|
|
vecVelocity[2] += height;
|
2009-04-29 01:58:41 +02:00
|
|
|
|
2009-05-12 04:56:03 +02:00
|
|
|
// Apply velocity.
|
2009-04-29 01:58:41 +02:00
|
|
|
JumpBoostSetClientVelocity(client, vecVelocity);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2009-05-10 18:49:47 +02:00
|
|
|
* Set new velocity on client. (Special method separate from ToolsClientVelocity)
|
2009-04-29 01:58:41 +02:00
|
|
|
*
|
|
|
|
* @param client The client index.
|
|
|
|
* @param vecVelocity Velocity to set on client.
|
|
|
|
*/
|
|
|
|
JumpBoostSetClientVelocity(client, const Float:vecVelocity[3])
|
|
|
|
{
|
|
|
|
SetEntDataVector(client, g_iToolsBaseVelocity, vecVelocity, true);
|
2009-05-01 11:22:45 +02:00
|
|
|
}
|