2009-04-29 01:58:41 +02:00
|
|
|
/*
|
|
|
|
* ============================================================================
|
|
|
|
*
|
|
|
|
* Zombie:Reloaded
|
|
|
|
*
|
2009-06-12 05:51:26 +02:00
|
|
|
* File: jumpboost.inc
|
|
|
|
* Type: Module
|
|
|
|
* Description: Modified jump vector magnitudes.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2009 Greyscale, Richard Helgeby
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* @param client The client index.
|
|
|
|
*/
|
|
|
|
JumpBoostOnClientJump(client)
|
|
|
|
{
|
2009-05-31 00:13:24 +02:00
|
|
|
new Float:vecVelocity[3];
|
|
|
|
new Float:vecBuffer[3];
|
|
|
|
new Float:magnitude;
|
|
|
|
|
2009-04-29 01:58:41 +02:00
|
|
|
// Get class jump multipliers.
|
|
|
|
new Float:distance = ClassGetJumpDistance(client);
|
|
|
|
new Float:height = ClassGetJumpHeight(client);
|
|
|
|
|
2009-06-22 01:09:51 +02:00
|
|
|
// Do not apply jump boost if settings indicate no boost.
|
|
|
|
if (height == 0.0 && distance == 0.2)
|
2009-05-30 23:19:32 +02:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2009-04-29 01:58:41 +02:00
|
|
|
// Get client's current velocity.
|
|
|
|
ToolsClientVelocity(client, vecVelocity, false);
|
|
|
|
|
2009-05-31 00:13:24 +02:00
|
|
|
// Get bunny hop setting.
|
2009-05-15 07:25:07 +02:00
|
|
|
new bool:bunnyhopprotect = GetConVarBool(g_hCvarsList[CVAR_JUMPBOOST_BUNNYHOP_PROTECT]);
|
2009-05-31 00:13:24 +02:00
|
|
|
|
|
|
|
// Check if bunny hop protection is enabled.
|
2009-05-15 07:25:07 +02:00
|
|
|
if (bunnyhopprotect)
|
2009-05-12 04:56:03 +02:00
|
|
|
{
|
2009-05-31 00:13:24 +02:00
|
|
|
// Get jump boost settings.
|
|
|
|
new bool:bunnyhopreset = GetConVarBool(g_hCvarsList[CVAR_JUMPBOOST_BUNNYHOP_RESET]);
|
|
|
|
new Float:bunnyhopmax = GetConVarFloat(g_hCvarsList[CVAR_JUMPBOOST_BUNNYHOP_MAX]);
|
|
|
|
|
|
|
|
// Get movement distance.
|
|
|
|
magnitude = SquareRoot(Pow(vecVelocity[0], 2.0) + Pow(vecVelocity[1], 2.0));
|
|
|
|
|
|
|
|
// Check if maximum speed is reached and reset setting is set.
|
|
|
|
if ((magnitude > bunnyhopmax) && bunnyhopreset)
|
2009-05-15 07:25:07 +02:00
|
|
|
{
|
2009-05-31 00:13:24 +02:00
|
|
|
// Reset horizontal velocity.
|
2009-05-15 07:25:07 +02:00
|
|
|
distance = 0.0;
|
|
|
|
}
|
2009-05-31 00:13:24 +02:00
|
|
|
|
|
|
|
// Check if maximum speed is reached and reset setting is disabled.
|
|
|
|
else if ((magnitude > bunnyhopmax) && !bunnyhopreset)
|
|
|
|
{
|
|
|
|
// Set horizontal velocity to maximum allowed.
|
|
|
|
|
|
|
|
// Copy to buffer.
|
|
|
|
vecBuffer[0] = vecVelocity[0];
|
|
|
|
vecBuffer[1] = vecVelocity[1];
|
|
|
|
vecBuffer[2] = 1.0; // Dummy value.
|
|
|
|
|
|
|
|
// Normalize buffer vector to make it a unit vector.
|
|
|
|
NormalizeVector(vecBuffer, vecBuffer);
|
|
|
|
|
|
|
|
// Restore horizontal axis in buffer to velocity vector.
|
|
|
|
vecVelocity[0] = vecBuffer[0];
|
|
|
|
vecVelocity[1] = vecBuffer[1];
|
|
|
|
|
|
|
|
// Set distance to maximum speed.
|
|
|
|
distance = bunnyhopmax;
|
|
|
|
}
|
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
|
|
|
}
|