2009-04-29 01:58:41 +02:00
|
|
|
/*
|
|
|
|
* ============================================================================
|
|
|
|
*
|
2009-07-05 08:49:23 +02:00
|
|
|
* Zombie:Reloaded
|
2009-04-29 01:58:41 +02:00
|
|
|
*
|
2009-06-12 05:51:26 +02:00
|
|
|
* File: jumpboost.inc
|
|
|
|
* Type: Module
|
|
|
|
* Description: Modified jump vector magnitudes.
|
|
|
|
*
|
2013-01-12 08:47:36 +01:00
|
|
|
* Copyright (C) 2009-2013 Greyscale, Richard Helgeby
|
2009-06-12 05:51:26 +02:00
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2009-04-29 01:58:41 +02:00
|
|
|
*
|
|
|
|
* ============================================================================
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Client is jumping.
|
2016-02-06 00:47:47 +01:00
|
|
|
*
|
2009-04-29 01:58:41 +02:00
|
|
|
* @param client The client index.
|
|
|
|
*/
|
2009-06-23 01:37:26 +02:00
|
|
|
JumpBoostOnClientJumpPost(client)
|
2009-04-29 01:58:41 +02:00
|
|
|
{
|
|
|
|
// Get class jump multipliers.
|
2009-06-23 01:37:26 +02:00
|
|
|
new Float:distancemultiplier = ClassGetJumpDistance(client);
|
|
|
|
new Float:heightmultiplier = ClassGetJumpHeight(client);
|
2016-02-06 00:47:47 +01:00
|
|
|
|
2009-06-24 07:31:48 +02:00
|
|
|
// If both are set to 1.0, then stop here to save some work.
|
|
|
|
if (distancemultiplier == 1.0 && heightmultiplier == 1.0)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2016-02-06 00:47:47 +01:00
|
|
|
|
2009-06-23 01:37:26 +02:00
|
|
|
new Float:vecVelocity[3];
|
2016-02-06 00:47:47 +01:00
|
|
|
|
2009-04-29 01:58:41 +02:00
|
|
|
// Get client's current velocity.
|
|
|
|
ToolsClientVelocity(client, vecVelocity, false);
|
2016-02-06 00:47:47 +01:00
|
|
|
|
2009-07-05 23:37:26 +02:00
|
|
|
// Only apply horizontal multiplier if it's not a bhop.
|
2009-06-24 01:55:58 +02:00
|
|
|
if (!JumpBoostIsBHop(vecVelocity))
|
|
|
|
{
|
|
|
|
// Apply horizontal multipliers to jump vector.
|
|
|
|
vecVelocity[0] *= distancemultiplier;
|
|
|
|
vecVelocity[1] *= distancemultiplier;
|
|
|
|
}
|
2016-02-06 00:47:47 +01:00
|
|
|
|
2009-06-24 01:55:58 +02:00
|
|
|
// Apply height multiplier to jump vector.
|
|
|
|
vecVelocity[2] *= heightmultiplier;
|
2016-02-06 00:47:47 +01:00
|
|
|
|
2009-06-23 23:28:26 +02:00
|
|
|
// Set new velocity.
|
2009-06-23 01:37:26 +02:00
|
|
|
ToolsClientVelocity(client, vecVelocity, true, false);
|
2009-04-29 01:58:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2009-06-24 01:55:58 +02:00
|
|
|
* This function detects excessive bunnyhopping.
|
|
|
|
* Note: This ONLY catches bunnyhopping that is worse than CS:S already allows.
|
2016-02-06 00:47:47 +01:00
|
|
|
*
|
2009-06-24 01:55:58 +02:00
|
|
|
* @param vecVelocity The velocity of the client jumping.
|
|
|
|
* @return True if the client is bunnyhopping, false if not.
|
2009-04-29 01:58:41 +02:00
|
|
|
*/
|
2009-06-24 01:55:58 +02:00
|
|
|
stock bool:JumpBoostIsBHop(const Float:vecVelocity[])
|
2009-04-29 01:58:41 +02:00
|
|
|
{
|
2009-06-23 01:37:26 +02:00
|
|
|
// If bunnyhop protection is disabled, then stop.
|
|
|
|
new bool:bunnyhopprotect = GetConVarBool(g_hCvarsList[CVAR_JUMPBOOST_BHOP_PROTECT]);
|
|
|
|
if (!bunnyhopprotect)
|
|
|
|
{
|
2009-06-24 01:55:58 +02:00
|
|
|
return false;
|
2009-06-23 01:37:26 +02:00
|
|
|
}
|
2016-02-06 00:47:47 +01:00
|
|
|
|
2009-06-23 01:37:26 +02:00
|
|
|
// Calculate the magnitude of jump on the xy plane.
|
|
|
|
new Float:magnitude = SquareRoot(Pow(vecVelocity[0], 2.0) + Pow(vecVelocity[1], 2.0));
|
2016-02-06 00:47:47 +01:00
|
|
|
|
2009-06-24 01:55:58 +02:00
|
|
|
// Return true if the magnitude exceeds the max.
|
2009-06-23 01:37:26 +02:00
|
|
|
new Float:bunnyhopmax = GetConVarFloat(g_hCvarsList[CVAR_JUMPBOOST_BHOP_MAX]);
|
2009-06-24 01:55:58 +02:00
|
|
|
return (magnitude > bunnyhopmax);
|
|
|
|
}
|