Updated jump module, removed no longer needed offset.

This commit is contained in:
Greyscale 2009-06-22 16:37:26 -07:00
parent 79bf4230c1
commit 268ab778cf
6 changed files with 97 additions and 112 deletions

View File

@ -42,8 +42,8 @@
// kill_bonus number How many points to give per kill. Humans only.
// speed decimal The player speed.
// knockback decimal Force of the knockback when shot at. Zombies only.
// jump_height decimal Extra upwards jump boost in units. 0.0 for no extra boost.
// jump_distance decimal Extra forwards jump boost multiplier. 0.2 is normal distance.
// jump_height decimal Multiplier of the players jump height. 0.0 means no jump, 1.0 is normal.
// jump_distance decimal Multiplier of the players jump distance. 0.0 means no forward jump, 1.0 is normal.
"classes"
{
@ -91,8 +91,8 @@
"speed" "350"
"knockback" "4"
"jump_height" "10.0"
"jump_distance" "0.3"
"jump_height" "1.1"
"jump_distance" "1.2"
}
"fast"
@ -134,8 +134,8 @@
"speed" "380"
"knockback" "4.5"
"jump_height" "30.0"
"jump_distance" "0.4"
"jump_height" "1.3"
"jump_distance" "1.2"
}
"mutated"
@ -177,8 +177,8 @@
"speed" "275"
"knockback" "3.5"
"jump_height" "20.0"
"jump_distance" "0.4"
"jump_height" "1.3"
"jump_distance" "1.3"
}
"heavy"
@ -220,8 +220,8 @@
"speed" "280"
"knockback" "2.5"
"jump_height" "0.0"
"jump_distance" "0.2"
"jump_height" "0.9"
"jump_distance" "0.9"
}
// ------------------------------------------
@ -269,8 +269,8 @@
"speed" "300"
"knockback" "0"
"jump_height" "0.0"
"jump_distance" "0.2"
"jump_height" "1.0"
"jump_distance" "1.0"
}
"human_speedy"
@ -312,8 +312,8 @@
"speed" "380"
"knockback" "0"
"jump_height" "0.0"
"jump_distance" "0.2"
"jump_height" "1.0"
"jump_distance" "1.0"
}
"human_light"
@ -355,7 +355,7 @@
"speed" "300"
"knockback" "0"
"jump_height" "30.0"
"jump_distance" "0.4"
"jump_height" "1.3"
"jump_distance" "1.3"
}
}

View File

@ -554,7 +554,7 @@ zr_respawn_team_zombie_world "1"
// Napalm (module)
// ----------------------------------------------------------------------------
// Ignite grenade in mid-air after player throws it. [Dependency: Human Attribute 'napalm']
// Ignite grenade in mid-air after player throws it. [Dependency: Human Attribute 'has_napalm']
// Default: "1"
zr_napalm_ignite "1"
@ -565,15 +565,15 @@ zr_napalm_ignite "1"
// Prevent players from using forward jump boost multipliers to bunny hop.
// Default: "1"
zr_jumpboost_bunnyhop_protect "1"
zr_jumpboost_bhop_protect "1"
// The maximum horizontal velocity a player can have for any additional push to be applied, when bunny hop prevention is enabled.
// Default: "275"
zr_jumpboost_bunnyhop_max "275"
// The maximum horizontal velocity a player can achieve before bunnyhop protection kicks in. [Dependency: zr_jumpboost_bhop_protect]
// Default: "300"
zr_jumpboost_bhop_max "300"
// Specifies whether the speed should be reset, or limited to maximum when the limit is reached.
// Default: "1"
zr_jumpboost_bunnyhop_reset "1"
// This is the horizontal jump multiplier for when the max limit is exceeded. ['0.9' = 90% of the jumps original magnitude | '>1.0' = Redundant | Dependency: zr_jumpboost_bhop_protect&zr_jumpboost_bhop_max]
// Default: "0.9"
zr_jumpboost_bhop_reset "0.9"
// ----------------------------------------------------------------------------

View File

@ -135,9 +135,9 @@ enum CvarsList
Handle:CVAR_RESPAWN_TEAM_ZOMBIE,
Handle:CVAR_RESPAWN_TEAM_ZOMBIE_WORLD,
Handle:CVAR_NAPALM_IGNITE,
Handle:CVAR_JUMPBOOST_BUNNYHOP_PROTECT,
Handle:CVAR_JUMPBOOST_BUNNYHOP_MAX,
Handle:CVAR_JUMPBOOST_BUNNYHOP_RESET,
Handle:CVAR_JUMPBOOST_BHOP_PROTECT,
Handle:CVAR_JUMPBOOST_BHOP_MAX,
Handle:CVAR_JUMPBOOST_BHOP_RESET,
Handle:CVAR_VOL,
Handle:CVAR_VOL_UPDATE_INTERVAL,
Handle:CVAR_VOL_TRIGGER_INTERVAL,
@ -406,14 +406,14 @@ CvarsCreate()
// Napalm (module)
// ===========================
g_hCvarsList[CVAR_NAPALM_IGNITE] = CreateConVar("zr_napalm_ignite", "1", "Ignite grenade in mid-air after player throws it. [Dependency: Human Attribute 'hasnapalm']");
g_hCvarsList[CVAR_NAPALM_IGNITE] = CreateConVar("zr_napalm_ignite", "1", "Ignite grenade in mid-air after player throws it. [Dependency: Human Attribute 'has_napalm']");
// ===========================
// Jump Boost (module)
// ===========================
g_hCvarsList[CVAR_JUMPBOOST_BUNNYHOP_PROTECT] = CreateConVar("zr_jumpboost_bunnyhop_protect", "1", "Prevent players from using forward jump boost multipliers to bunny hop.");
g_hCvarsList[CVAR_JUMPBOOST_BUNNYHOP_MAX] = CreateConVar("zr_jumpboost_bunnyhop_max", "275", "The maximum horizontal velocity a player can have for any additional push to be applied. [Dependency: zr_jumpboost_bunnyhop_protect]");
g_hCvarsList[CVAR_JUMPBOOST_BUNNYHOP_RESET] = CreateConVar("zr_jumpboost_bunnyhop_reset", "1", "Specifies whether the speed should be reset, or limited to maximum when the limit is reached. [Dependency: zr_jumpboost_bunnyhop_protect&zr_jumpboost_bunnyhop_max]");
g_hCvarsList[CVAR_JUMPBOOST_BHOP_PROTECT] = CreateConVar("zr_jumpboost_bhop_protect", "1", "Prevent players from using forward jump boost multipliers to bunny hop.");
g_hCvarsList[CVAR_JUMPBOOST_BHOP_MAX] = CreateConVar("zr_jumpboost_bhop_max", "300", "The maximum horizontal velocity a player can achieve before bunnyhop protection kicks in. [Dependency: zr_jumpboost_bhop_protect]");
g_hCvarsList[CVAR_JUMPBOOST_BHOP_RESET] = CreateConVar("zr_jumpboost_bhop_reset", "0.9", "This is the horizontal jump multiplier for when the max limit is exceeded. ['0.9' = 90% of the jumps original magnitude | '>1.0' = Redundant | Dependency: zr_jumpboost_bhop_protect&zr_jumpboost_bhop_max]");
// ===========================

View File

@ -103,7 +103,7 @@ public Action:EventRoundStart(Handle:event, const String:name[], bool:dontBroadc
* @param name Name of the event.
* @dontBroadcast If true, event is broadcasted to all clients, false if not.
*/
public Action:EventRoundStartPost(Handle:timer, any:index)
public Action:EventRoundStartPost(Handle:timer)
{
// Forward event to modules.
}
@ -213,18 +213,18 @@ public Action:EventPlayerSpawn(Handle:event, const String:name[], bool:dontBroad
* @param name Name of the event.
* @dontBroadcast If true, event is broadcasted to all clients, false if not.
*/
public Action:EventPlayerSpawnPost(Handle:timer, any:index)
public Action:EventPlayerSpawnPost(Handle:timer, any:client)
{
// If client isn't in-game, then stop.
if (!IsClientInGame(index))
if (!IsClientInGame(client))
{
return;
}
// Forward event to modules.
WeaponsOnClientSpawnPost(index);
SEffectsOnClientSpawnPost(index);
SpawnProtectOnClientSpawnPost(index);
WeaponsOnClientSpawnPost(client);
SEffectsOnClientSpawnPost(client);
SpawnProtectOnClientSpawnPost(client);
}
/**
@ -307,8 +307,28 @@ public Action:EventPlayerJump(Handle:event, const String:name[], bool:dontBroadc
// Get all required event info.
new index = GetClientOfUserId(GetEventInt(event, "userid"));
// Fire post player_jump event.
CreateTimer(0.0, EventPlayerJumpPost, index);
}
/**
* Event callback (player_jump)
* Client is jumping. *Post
*
* @param event The event handle.
* @param name Name of the event.
* @dontBroadcast If true, event is broadcasted to all clients, false if not.
*/
public Action:EventPlayerJumpPost(Handle:timer, any:client)
{
// If client isn't in-game, then stop.
if (!IsClientInGame(client))
{
return;
}
// Forward event to modules.
JumpBoostOnClientJump(index);
JumpBoostOnClientJumpPost(client);
}
/**

View File

@ -30,85 +30,58 @@
*
* @param client The client index.
*/
JumpBoostOnClientJump(client)
JumpBoostOnClientJumpPost(client)
{
new Float:vecVelocity[3];
new Float:vecBuffer[3];
new Float:magnitude;
// Get class jump multipliers.
new Float:distance = ClassGetJumpDistance(client);
new Float:height = ClassGetJumpHeight(client);
new Float:distancemultiplier = ClassGetJumpDistance(client);
new Float:heightmultiplier = ClassGetJumpHeight(client);
// Do not apply jump boost if settings indicate no boost.
if (height == 0.0 && distance == 0.2)
{
return;
}
new Float:vecVelocity[3];
// Get client's current velocity.
ToolsClientVelocity(client, vecVelocity, false);
// Get bunny hop setting.
new bool:bunnyhopprotect = GetConVarBool(g_hCvarsList[CVAR_JUMPBOOST_BUNNYHOP_PROTECT]);
// Protect against bunnyhop.
JumpBoostBHopProtect(vecVelocity, distancemultiplier);
// Check if bunny hop protection is enabled.
if (bunnyhopprotect)
{
// Get jump boost settings.
new bool:bunnyhopreset = GetConVarBool(g_hCvarsList[CVAR_JUMPBOOST_BUNNYHOP_RESET]);
new Float:bunnyhopmax = GetConVarFloat(g_hCvarsList[CVAR_JUMPBOOST_BUNNYHOP_MAX]);
// Apply multipliers to jump vector.
vecVelocity[0] *= distancemultiplier;
vecVelocity[1] *= distancemultiplier;
vecVelocity[2] *= heightmultiplier;
// 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)
{
// Reset horizontal velocity.
distance = 0.0;
}
// 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;
}
}
// Apply forward jump boost.
vecVelocity[0] *= distance;
vecVelocity[1] *= distance;
// Apply vertical jump boost.
vecVelocity[2] += height;
// Apply velocity.
JumpBoostSetClientVelocity(client, vecVelocity);
ToolsClientVelocity(client, vecVelocity, true, false);
}
/**
* Set new velocity on client. (Special method separate from ToolsClientVelocity)
* This function protects against excessive bunnyhopping.
* Note: This ONLY stops bunnyhopping from being worse than CS:S already allows.
*
* @param client The client index.
* @param vecVelocity Velocity to set on client.
* @param vecVelocity The velocity of the client jumping.
* @param distancemultiplier The distance multiplier used on this jump.
*/
JumpBoostSetClientVelocity(client, const Float:vecVelocity[3])
stock JumpBoostBHopProtect(Float:vecVelocity[], Float:distancemultiplier)
{
SetEntDataVector(client, g_iToolsBaseVelocity, vecVelocity, true);
// If bunnyhop protection is disabled, then stop.
new bool:bunnyhopprotect = GetConVarBool(g_hCvarsList[CVAR_JUMPBOOST_BHOP_PROTECT]);
if (!bunnyhopprotect)
{
return;
}
// Calculate the magnitude of jump on the xy plane.
new Float:magnitude = SquareRoot(Pow(vecVelocity[0], 2.0) + Pow(vecVelocity[1], 2.0));
// If the magnitude doesn't exceed the limit, then stop.
new Float:bunnyhopmax = GetConVarFloat(g_hCvarsList[CVAR_JUMPBOOST_BHOP_MAX]);
if (magnitude <= bunnyhopmax)
{
return;
}
// If we are resetting the velocity, then set to 1.0 (normal jump)
new Float:bunnyhopreset = GetConVarFloat(g_hCvarsList[CVAR_JUMPBOOST_BHOP_RESET]);
// Scale with cvar value.
vecVelocity[0] /= (distancemultiplier / bunnyhopreset);
vecVelocity[1] /= (distancemultiplier / bunnyhopreset);
}

View File

@ -29,7 +29,6 @@
* Initialize global offset variables.
*/
new g_iToolsVelocity;
new g_iToolsBaseVelocity;
new g_iToolsLMV;
new g_iToolsHasNightVision;
new g_iToolsNightVisionOn;
@ -77,13 +76,6 @@ ToolsFindOffsets()
LogEvent(false, LogType_Fatal, LOG_CORE_EVENTS, LogModule_Tools, "Offsets", "Offset \"CBasePlayer::m_vecVelocity[0]\" was not found.");
}
// If offset "m_vecBaseVelocity" can't be found, then stop the plugin.
g_iToolsBaseVelocity = FindSendPropInfo("CBasePlayer", "m_vecBaseVelocity");
if (g_iToolsBaseVelocity == -1)
{
LogEvent(false, LogType_Fatal, LOG_CORE_EVENTS, LogModule_Tools, "Offsets", "Offset \"CBasePlayer::m_vecBaseVelocity\" was not found.");
}
// If offset "m_flLaggedMovementValue" can't be found, then stop the plugin.
g_iToolsLMV = FindSendPropInfo("CCSPlayer", "m_flLaggedMovementValue");
if (g_iToolsLMV == -1)