Added knock back boost workaround for CS: GO, with cvar to disable it: zr_classes_csgo_knockback_boost. Side effects: Weaker and flying zombies, can be compensated with lower knock back.

This commit is contained in:
Richard Helgeby
2012-09-20 11:32:00 +02:00
parent 15a542ba76
commit 75518ba11a
6 changed files with 249 additions and 15 deletions

View File

@ -71,6 +71,7 @@ enum CvarsList
Handle:CVAR_CLASSES_HUMAN_SELECT,
Handle:CVAR_CLASSES_ADMIN_SELECT,
Handle:CVAR_CLASSES_SPEED_METHOD,
Handle:CVAR_CLASSES_CSGO_KNOCKBACK_BOOST,
Handle:CVAR_WEAPONS,
Handle:CVAR_WEAPONS_RESTRICT,
Handle:CVAR_WEAPONS_RESTRICT_ENDEQUIP,
@ -278,6 +279,7 @@ CvarsCreate()
g_hCvarsList[CVAR_CLASSES_HUMAN_SELECT] = CreateConVar("zr_classes_human_select", "1", "Allow players to select human classes.");
g_hCvarsList[CVAR_CLASSES_ADMIN_SELECT] = CreateConVar("zr_classes_admin_select", "1", "Allow admins to select admin mode classes. (Not to be confused by admin-only classes!)");
g_hCvarsList[CVAR_CLASSES_SPEED_METHOD] = CreateConVar("zr_classes_speed_method", "prop", "Speed method to use when applying player speed. Do not touch this if you don't know what you're doing! [\"lmv\" = Lagged movement value | \"prop\" = Player speed property");
g_hCvarsList[CVAR_CLASSES_CSGO_KNOCKBACK_BOOST] = CreateConVar("zr_classes_csgo_knockback_boost", "1", "CS: GO only: Applies an upwards boost if necessary as a workaround for low knock back when standing on the ground. Side effects: Weaker and flying zombies (compensate with lower knock back).");
// Menu
g_hCvarsList[CVAR_CLASSES_MENU_AUTOCLOSE] = CreateConVar("zr_classes_menu_autoclose", "1", "Automatically close class selection menu after selecting a class.");

View File

@ -24,7 +24,13 @@
*
* ============================================================================
*/
/**
* Minimum upwards boost that is required to push zombies off the ground.
*/
#define CSGO_KNOCKBACK_BOOST 251.0
#define CSGO_KNOCKBACK_BOOST_MAX 350.0
/** Client has been hurt.
*
* @param client The client index. (zombie)
@ -134,6 +140,26 @@ KnockbackSetVelocity(client, const Float:startpoint[3], const Float:endpoint[3],
// Apply the magnitude by scaling the vector (multiplying each of its components).
ScaleVector(vector, magnitude);
// CS: GO workaround. Apply knock back boost if enabled.
if (g_Game == Game_CSGO && GetConVarBool(g_hCvarsList[CVAR_CLASSES_CSGO_KNOCKBACK_BOOST]))
{
new flags = GetEntityFlags(client);
new Float:velocity[3];
ToolsGetClientVelocity(client, velocity);
// Remove boost if current velocity is too high.
if (velocity[2] > CSGO_KNOCKBACK_BOOST_MAX)
{
// Don't add extra boost.
vector[2] = 0.0;
}
else if (flags & FL_ONGROUND && vector[2] < CSGO_KNOCKBACK_BOOST)
{
// Apply minimum boost required to push player off the ground.
vector[2] = CSGO_KNOCKBACK_BOOST;
}
}
// ADD the given vector to the client's current velocity.
ToolsClientVelocity(client, vector);
}

View File

@ -67,6 +67,21 @@ stock ToolsClientVelocity(client, Float:vecVelocity[3], bool:apply = true, bool:
TeleportEntity(client, NULL_VECTOR, NULL_VECTOR, vecVelocity);
}
/**
* Gets client's velocity.
*
* @param client The client index.
* @param vecVelocity Array to store vector in.
*/
stock ToolsGetClientVelocity(client, Float:vecVelocity[3])
{
// x = vector component.
for (new x = 0; x < 3; x++)
{
vecVelocity[x] = GetEntDataFloat(client, g_iToolsVelocity + (x*4));
}
}
/**
* Set a client's lagged movement value.
* @param client The client index.

View File

@ -67,8 +67,8 @@ enum Game
/**
* Current game.
*/
new Game:g_game = Game_Unknown;
#pragma unused g_game
new Game:g_Game = Game_Unknown;
#pragma unused g_Game
/**
* Updates g_game. Will log a warning if a unsupported game is detected.
@ -80,19 +80,19 @@ UpdateGameFolder()
if (StrEqual(gameFolder, "cstrike", false))
{
g_game = Game_CSS;
g_Game = Game_CSS;
PrintToServer("Game detected: cstrike");
return;
}
else if (StrEqual(gameFolder, "csgo", false))
{
g_game = Game_CSGO;
g_Game = Game_CSGO;
PrintToServer("Game detected: csgo");
return;
}
LogError("Warning: Zombie:Reloaded doesn't support this game: %s", gameFolder);
g_game = Game_Unknown;
g_Game = Game_Unknown;
}
/**