Added support for different speed methods, defaulted to prop method now. If you don't want to update class settings, use 'zr_classes_speed_method lmv' for backwards compatibility.

This commit is contained in:
Richard Helgeby 2010-07-04 17:58:27 +02:00
parent 4b693385fc
commit eab2333309
12 changed files with 325 additions and 39 deletions

View File

@ -90,7 +90,7 @@
"health_infect_gain" "700" "health_infect_gain" "700"
"kill_bonus" "2" "kill_bonus" "2"
"speed" "350" "speed" "75"
"knockback" "4" "knockback" "4"
"jump_height" "1.1" "jump_height" "1.1"
"jump_distance" "1.2" "jump_distance" "1.2"
@ -134,7 +134,7 @@
"health_infect_gain" "500" "health_infect_gain" "500"
"kill_bonus" "2" "kill_bonus" "2"
"speed" "380" "speed" "100"
"knockback" "4.5" "knockback" "4.5"
"jump_height" "1.3" "jump_height" "1.3"
"jump_distance" "1.2" "jump_distance" "1.2"
@ -178,7 +178,7 @@
"health_infect_gain" "850" "health_infect_gain" "850"
"kill_bonus" "2" "kill_bonus" "2"
"speed" "275" "speed" "-25"
"knockback" "3.5" "knockback" "3.5"
"jump_height" "1.3" "jump_height" "1.3"
"jump_distance" "1.3" "jump_distance" "1.3"
@ -222,7 +222,7 @@
"health_infect_gain" "1000" "health_infect_gain" "1000"
"kill_bonus" "2" "kill_bonus" "2"
"speed" "280" "speed" "-20"
"knockback" "2.5" "knockback" "2.5"
"jump_height" "0.9" "jump_height" "0.9"
"jump_distance" "0.9" "jump_distance" "0.9"
@ -266,7 +266,7 @@
"health_infect_gain" "700" "health_infect_gain" "700"
"kill_bonus" "4" "kill_bonus" "4"
"speed" "400" "speed" "110"
"knockback" "2.8" "knockback" "2.8"
"jump_height" "1.2" "jump_height" "1.2"
"jump_distance" "1.3" "jump_distance" "1.3"
@ -310,7 +310,7 @@
"health_infect_gain" "700" "health_infect_gain" "700"
"kill_bonus" "1" "kill_bonus" "1"
"speed" "425" "speed" "115"
"knockback" "2.8" "knockback" "2.8"
"jump_height" "1.2" "jump_height" "1.2"
"jump_distance" "1.3" "jump_distance" "1.3"
@ -360,7 +360,7 @@
"health_infect_gain" "0" "health_infect_gain" "0"
"kill_bonus" "2" "kill_bonus" "2"
"speed" "300" "speed" "0"
"knockback" "0" "knockback" "0"
"jump_height" "1.0" "jump_height" "1.0"
"jump_distance" "1.0" "jump_distance" "1.0"
@ -404,7 +404,7 @@
"health_infect_gain" "0" "health_infect_gain" "0"
"kill_bonus" "1" "kill_bonus" "1"
"speed" "320" "speed" "0"
"knockback" "0" "knockback" "0"
"jump_height" "1.2" "jump_height" "1.2"
"jump_distance" "1.2" "jump_distance" "1.2"
@ -448,7 +448,7 @@
"health_infect_gain" "0" "health_infect_gain" "0"
"kill_bonus" "1" "kill_bonus" "1"
"speed" "320" "speed" "50"
"knockback" "0" "knockback" "0"
"jump_height" "1.2" "jump_height" "1.2"
"jump_distance" "1.2" "jump_distance" "1.2"
@ -492,7 +492,7 @@
"health_infect_gain" "0" "health_infect_gain" "0"
"kill_bonus" "1" "kill_bonus" "1"
"speed" "380" "speed" "50"
"knockback" "0" "knockback" "0"
"jump_height" "1.0" "jump_height" "1.0"
"jump_distance" "1.0" "jump_distance" "1.0"
@ -536,7 +536,7 @@
"health_infect_gain" "0" "health_infect_gain" "0"
"kill_bonus" "1" "kill_bonus" "1"
"speed" "300" "speed" "-30"
"knockback" "0" "knockback" "0"
"jump_height" "1.3" "jump_height" "1.3"
"jump_distance" "1.3" "jump_distance" "1.3"

View File

@ -208,6 +208,10 @@ zr_classes_human_select "1"
// Default: "1" // Default: "1"
zr_classes_admin_select "1" zr_classes_admin_select "1"
// 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]
// Default: "command"
zr_classes_speed_method "prop"
// Overlay // Overlay
// Allow players to toggle class overlay. // Allow players to toggle class overlay.

View File

@ -16,7 +16,7 @@
<p class="headerinfo">Targets plugin version 3.0.0 Beta 2, 2009.12.11<br /> <p class="headerinfo">Targets plugin version 3.0.0 Beta 2, 2009.12.11<br />
Written by Richard Helgeby</p> Written by Richard Helgeby</p>
<p class="headerinfo">Manual last modified: 2009.12.11</p> <p class="headerinfo">Manual last modified: 2010.07.04</p>
<h2>Index</h2> <h2>Index</h2>
@ -291,14 +291,8 @@ for both zombies and humans in different classes.</p>
<li><a href="http://wiki.alliedmods.net/index.php/Category:SourceMod_Documentation">SourceMod Documentation</a></li> <li><a href="http://wiki.alliedmods.net/index.php/Category:SourceMod_Documentation">SourceMod Documentation</a></li>
</ul></li> </ul></li>
<li> <li><p><a href="http://forums.alliedmods.net/showthread.php?t=106748">SDK Hooks Extension</a>
<p>ZRTools extension (bundled). Provides some extra functions needed by Zombie:Reloaded. (version 1.3 or newer).</p></li>
See <a href="#2.2">Plugin Installation (2.2)</a>.</p>
<p>- Or, depending on Zombie:Reloaded release -</p>
<p><a href="http://forums.alliedmods.net/showthread.php?t=106748">SDK Hooks Extension</a>
(version 1.1 or newer).</p>
</li>
</ol> </ol>
<h3><a name="2.2" />2.2 Plugin Installation</h3> <h3><a name="2.2" />2.2 Plugin Installation</h3>
@ -1343,11 +1337,14 @@ the admin-only flag in the <span class="code">flags</span> attribute.</p>
<tr> <tr>
<td class="commandheader">speed</td> <td class="commandheader">speed</td>
<td class="commandheader">decimal</td> <td class="commandheader">decimal</td>
<td class="commandheader">10.0 - 2000.0</td> <td class="commandheader">10.0 - 2000.0 | -200.0 - 800.0</td>
</tr> </tr>
<tr> <tr>
<td class="indent" colspan="3"> <td class="indent" colspan="3">
<p>The player's running speed.</p> <p>The player's running speed.</p>
<p><strong>Note:</strong> The limits of this attribute depends on the speed method used.
In LMV-mode the values are absolute (10 to 2000), but in prop-mode values are offsets from
normal speed at 250 (-200 to 800).</p>
</td> </td>
</tr> </tr>
@ -1783,6 +1780,23 @@ Place these console variables in the main configuration file:</p>
0 or 1</p> 0 or 1</p>
</td> </td>
</tr> </tr>
<tr>
<td class="commandheader">zr_classes_speed_method</td>
<td class="commandheader">"prop"</td>
</tr>
<tr>
<td class="indent" colspan="2">
<p>Speed method to use when setting player speed.</p>
<p>Options:</p>
<table>
<tr><td class="valueoption">"lmv"</td><td>Modifies speed with the lagged movement
value. This is the old method and is available for compatibility reasons.</td></tr>
<tr><td class="valueoption">"prop"</td><td>Modifies speed with the players' speed
property.</td></tr>
</table>
</td>
</tr>
</table></blockquote> </table></blockquote>
<h4><a name="3.7.5" />5. Modifying Class Attributes</h4> <h4><a name="3.7.5" />5. Modifying Class Attributes</h4>

View File

@ -58,16 +58,47 @@ enum SDKHookType
SDKHook_WeaponCanUse, SDKHook_WeaponCanUse,
SDKHook_WeaponDrop, SDKHook_WeaponDrop,
SDKHook_WeaponEquip, SDKHook_WeaponEquip,
SDKHook_WeaponSwitch,
SDKHook_ShouldCollide,
SDKHook_PreThinkPost,
SDKHook_PostThinkPost,
SDKHook_ThinkPost
};
/*
Alphabetized for easy readability
SDKHook_EndTouch
SDKHook_FireBulletsPost
SDKHook_OnTakeDamage
SDKHook_OnTakeDamagePost
SDKHook_PreThink
SDKHook_PreThinkPost
SDKHook_PostThink
SDKHook_PostThinkPost
SDKHook_SetTransmit
SDKHook_ShouldCollide
SDKHook_Spawn
SDKHook_StartTouch
SDKHook_Think
SDKHook_ThinkPost
SDKHook_Touch
SDKHook_TraceAttack
SDKHook_TraceAttackPost
SDKHook_WeaponCanSwitchTo
SDKHook_WeaponCanUse
SDKHook_WeaponDrop
SDKHook_WeaponEquip
SDKHook_WeaponSwitch SDKHook_WeaponSwitch
} */
funcenum SDKHookCB funcenum SDKHookCB
{ {
// PreThink // PreThink/Post
// PostThink // PostThink/Post
public(client), public(client),
// Spawn // Spawn
// Think // Think/Post
public(entity), public(entity),
// EndTouch // EndTouch
// StartTouch // StartTouch
@ -90,8 +121,10 @@ funcenum SDKHookCB
// TraceAttack // TraceAttack
Action:public(victim, &attacker, &inflictor, &Float:damage, &damagetype, &ammotype, hitbox, hitgroup), Action:public(victim, &attacker, &inflictor, &Float:damage, &damagetype, &ammotype, hitbox, hitgroup),
// TraceAttackPost // TraceAttackPost
public(victim, attacker, inflictor, Float:damage, damagetype, ammotype, hitbox, hitgroup) public(victim, attacker, inflictor, Float:damage, damagetype, ammotype, hitbox, hitgroup),
} // ShouldCollide
Action:public(entity, &collisiongroup, &contentsmask, &bool:result)
};
/** /**
@ -138,6 +171,16 @@ forward Action:OnLevelInit(const String:mapName[], String:mapEntities[2097152]);
*/ */
native SDKHook(entity, SDKHookType:type, SDKHookCB:callback); native SDKHook(entity, SDKHookType:type, SDKHookCB:callback);
/**
* @brief Hooks an entity
*
* @param entity Entity index
* @param type Type of function to hook
* @param callback Function to call when hook is called
* @return bool Hook Successful
*/
native bool:SDKHookEx(entity, SDKHookType:type, SDKHookCB:callback);
/** /**
* @brief Unhooks an entity * @brief Unhooks an entity
* *
@ -164,4 +207,4 @@ public Extension:__ext_sdkhooks =
#else #else
required = 0, required = 0,
#endif #endif
}; };

View File

@ -214,6 +214,7 @@ public OnConfigsExecuted()
DamageLoad(); DamageLoad();
VEffectsLoad(); VEffectsLoad();
SEffectsLoad(); SEffectsLoad();
ClassOnConfigsExecuted();
ClassLoad(); ClassLoad();
VolLoad(); VolLoad();
@ -297,3 +298,20 @@ public OnClientDisconnect(client)
ZSpawnOnClientDisconnect(client); ZSpawnOnClientDisconnect(client);
VolOnPlayerDisconnect(client); VolOnPlayerDisconnect(client);
} }
/**
* Called when a clients movement buttons are being processed
*
* @param client Index of the client.
* @param buttons Copyback buffer containing the current commands (as bitflags - see entity_prop_stocks.inc).
* @param impulse Copyback buffer containing the current impulse command.
* @param vel Players desired velocity.
* @param angles Players desired view angles.
* @param weapon Entity index of the new weapon if player switches weapon, 0 otherwise.
* @return Plugin_Handled to block the commands from being processed, Plugin_Continue otherwise.
*/
public Action:OnPlayerRunCmd(client, &buttons, &impulse, Float:vel[3], Float:angles[3], &weapon)
{
Class_OnPlayerRunCmd(client, vel);
return Plugin_Continue;
}

View File

@ -70,6 +70,7 @@ enum CvarsList
Handle:CVAR_CLASSES_ZOMBIE_SELECT, Handle:CVAR_CLASSES_ZOMBIE_SELECT,
Handle:CVAR_CLASSES_HUMAN_SELECT, Handle:CVAR_CLASSES_HUMAN_SELECT,
Handle:CVAR_CLASSES_ADMIN_SELECT, Handle:CVAR_CLASSES_ADMIN_SELECT,
Handle:CVAR_CLASSES_SPEED_METHOD,
Handle:CVAR_WEAPONS, Handle:CVAR_WEAPONS,
Handle:CVAR_WEAPONS_RESTRICT, Handle:CVAR_WEAPONS_RESTRICT,
Handle:CVAR_WEAPONS_RESTRICT_ENDEQUIP, Handle:CVAR_WEAPONS_RESTRICT_ENDEQUIP,
@ -274,6 +275,7 @@ CvarsCreate()
g_hCvarsList[CVAR_CLASSES_ZOMBIE_SELECT] = CreateConVar("zr_classes_zombie_select", "1", "Allow players to select zombie classes."); g_hCvarsList[CVAR_CLASSES_ZOMBIE_SELECT] = CreateConVar("zr_classes_zombie_select", "1", "Allow players to select zombie classes.");
g_hCvarsList[CVAR_CLASSES_HUMAN_SELECT] = CreateConVar("zr_classes_human_select", "1", "Allow players to select human classes."); 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_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");
// Menu // Menu
g_hCvarsList[CVAR_CLASSES_MENU_AUTOCLOSE] = CreateConVar("zr_classes_menu_autoclose", "1", "Automatically close class selection menu after selecting a class."); g_hCvarsList[CVAR_CLASSES_MENU_AUTOCLOSE] = CreateConVar("zr_classes_menu_autoclose", "1", "Automatically close class selection menu after selecting a class.");

View File

@ -25,6 +25,11 @@
* ============================================================================ * ============================================================================
*/ */
/**
* Array that stores the client's current speed.
*/
new Float:g_flClassApplySpeed[MAXPLAYERS + 1];
/** /**
* Applies all class attributes on a player. Changing model, hp, speed, health, * Applies all class attributes on a player. Changing model, hp, speed, health,
* effects etc. The players current team will be used to get the class index. * effects etc. The players current team will be used to get the class index.
@ -418,6 +423,80 @@ bool:ClassApplySpeed(client, classindex, cachetype = ZR_CLASS_CACHE_PLAYER)
speed = ClassGetSpeed(classindex, cachetype); speed = ClassGetSpeed(classindex, cachetype);
} }
ToolsSetClientLMV(client, speed); ClassApplySpeedEx(client, speed);
return true; return true;
} }
/**
* Applies the specified speed to the player.
*
* @param client Client to apply to.
* @param speed Speed value.
*/
ClassApplySpeedEx(client, Float:speed)
{
// Check what speed method that's used and apply it.
switch (ClassSpeedMethod)
{
case ClassSpeed_LMV:
{
ToolsSetClientLMV(client, speed);
}
case ClassSpeed_Prop:
{
g_flClassApplySpeed[client] = speed;
}
}
}
/**
* Called before the client can "think"
* Here we can change the client's speed through m_flMaxSpeed.
*
* @param client The client index.
*/
public ClassPreThinkPost(client)
{
// Only apply speed if the prop method is used.
if (ClassSpeedMethod == ClassSpeed_Prop)
{
if (!IsPlayerAlive(client))
{
return;
}
// Note: Default is around 200.0 - 250.0
new Float:newspeed = GetEntPropFloat(client, Prop_Data, "m_flMaxspeed") + g_flClassApplySpeed[client];
SetEntPropFloat(client, Prop_Data, "m_flMaxspeed", newspeed);
}
}
/**
* Called when a clients movement buttons are being processed
*
* @param client Index of the client.
* @param vel Players desired velocity.
*/
Class_OnPlayerRunCmd(client, Float:vel[3])
{
if (!IsPlayerAlive(client))
return;
// Only modify speed if the prop method is used.
if (ClassSpeedMethod == ClassSpeed_Prop)
{
// x-axis speed.
if (vel[0] < 0.0)
vel[0] = -5000.0;
else if (vel[0] > 0.0)
vel[0] = 5000.0;
// y-axis speed.
if (vel[1] < 0.0)
vel[1] = -5000.0;
else if (vel[1] > 0.0)
vel[1] = 5000.0;
}
}

View File

@ -67,11 +67,34 @@ ClassOnMapStart()
ClassHealthRegenInit(); ClassHealthRegenInit();
} }
/**
* Called when all configs are executed.
*/
ClassOnConfigsExecuted()
{
new ClassSpeedMethods:speedMethod = ClassGetSpeedMethod();
if (speedMethod != ClassSpeed_Invalid)
{
// Set speed method.
ClassSpeedMethod = speedMethod;
}
else
{
// Fall back on default to avoid errors.
ClassSpeedMethod = ClassSpeed_Prop;
LogEvent(false, LogType_Error, LOG_CORE_EVENTS, LogModules:LogModule_Playerclasses, "Config validation", "Warning: Invalid value in zr_classes_speed_method. Using default value.");
}
}
/** /**
* Client has just connected to the server. * Client has just connected to the server.
*/ */
ClassOnClientConnected(client) ClassOnClientConnected(client)
{ {
// Unhook "PreThinkPost" on the client.
SDKUnhook(client, SDKHook_PreThinkPost, ClassPreThinkPost);
// Initialize the admin checked variable. // Initialize the admin checked variable.
g_bAdminChecked[client] = false; g_bAdminChecked[client] = false;
} }
@ -81,6 +104,9 @@ ClassOnClientConnected(client)
*/ */
ClassClientInit(client) ClassClientInit(client)
{ {
// Hook "PreThinkPost" on the client.
SDKHook(client, SDKHook_PreThinkPost, ClassPreThinkPost);
// Reset spawn flag. // Reset spawn flag.
ClassPlayerSpawned[client] = false; ClassPlayerSpawned[client] = false;
} }

View File

@ -267,7 +267,22 @@ stock ClassValidateAttributes(classindex)
// Speed. // Speed.
new Float:speed = ClassData[classindex][Class_Speed]; new Float:speed = ClassData[classindex][Class_Speed];
if (!(speed >= ZR_CLASS_SPEED_MIN && speed <= ZR_CLASS_SPEED_MAX)) new Float:min;
new Float:max;
switch (ClassSpeedMethod)
{
case ClassSpeed_LMV:
{
min = ZR_CLASS_SPEED_LMV_MIN;
max = ZR_CLASS_SPEED_LMV_MAX;
}
case ClassSpeed_Prop:
{
min = ZR_CLASS_SPEED_PROP_MIN;
max = ZR_CLASS_SPEED_PROP_MAX;
}
}
if (!(speed >= min && speed <= max))
{ {
flags += ZR_CLASS_SPEED; flags += ZR_CLASS_SPEED;
} }
@ -419,7 +434,22 @@ stock ClassValidateEditableAttributes(attributes[ClassEditableAttributes])
new Float:speed = attributes[ClassEdit_Speed]; new Float:speed = attributes[ClassEdit_Speed];
if (speed >= 0) if (speed >= 0)
{ {
if (!(speed >= ZR_CLASS_SPEED_MIN && speed <= ZR_CLASS_SPEED_MAX)) new Float:min;
new Float:max;
switch (ClassSpeedMethod)
{
case ClassSpeed_LMV:
{
min = ZR_CLASS_SPEED_LMV_MIN;
max = ZR_CLASS_SPEED_LMV_MAX;
}
case ClassSpeed_Prop:
{
min = ZR_CLASS_SPEED_PROP_MIN;
max = ZR_CLASS_SPEED_PROP_MAX;
}
}
if (!(speed >= min && speed <= max))
{ {
flags += ZR_CLASS_SPEED; flags += ZR_CLASS_SPEED;
} }

View File

@ -124,7 +124,7 @@
#define ZR_CLASS_DEFAULT_HEALTH_REGEN_AMOUNT 2 #define ZR_CLASS_DEFAULT_HEALTH_REGEN_AMOUNT 2
#define ZR_CLASS_DEFAULT_HEALTH_INFECT_GAIN 800 #define ZR_CLASS_DEFAULT_HEALTH_INFECT_GAIN 800
#define ZR_CLASS_DEFAULT_KILL_BONUS 2 #define ZR_CLASS_DEFAULT_KILL_BONUS 2
#define ZR_CLASS_DEFAULT_SPEED 360.0 #define ZR_CLASS_DEFAULT_SPEED 0.0
#define ZR_CLASS_DEFAULT_KNOCKBACK 2.0 #define ZR_CLASS_DEFAULT_KNOCKBACK 2.0
#define ZR_CLASS_DEFAULT_JUMP_HEIGHT 10.0 #define ZR_CLASS_DEFAULT_JUMP_HEIGHT 10.0
#define ZR_CLASS_DEFAULT_JUMP_DISTANCE 0.2 #define ZR_CLASS_DEFAULT_JUMP_DISTANCE 0.2
@ -163,8 +163,10 @@
#define ZR_CLASS_HEALTH_INFECT_GAIN_MAX 20000 #define ZR_CLASS_HEALTH_INFECT_GAIN_MAX 20000
#define ZR_CLASS_KILL_BONUS_MIN 0 #define ZR_CLASS_KILL_BONUS_MIN 0
#define ZR_CLASS_KILL_BONUS_MAX 16 #define ZR_CLASS_KILL_BONUS_MAX 16
#define ZR_CLASS_SPEED_MIN 10.0 #define ZR_CLASS_SPEED_LMV_MIN 10.0
#define ZR_CLASS_SPEED_MAX 2000.0 #define ZR_CLASS_SPEED_LMV_MAX 2000.0
#define ZR_CLASS_SPEED_PROP_MIN -200.0
#define ZR_CLASS_SPEED_PROP_MAX 800.0
#define ZR_CLASS_KNOCKBACK_MIN -30.0 #define ZR_CLASS_KNOCKBACK_MIN -30.0
#define ZR_CLASS_KNOCKBACK_MAX 30.0 #define ZR_CLASS_KNOCKBACK_MAX 30.0
#define ZR_CLASS_KNOCKBACK_IGNORE -31.0 /** Used by class editor volumetric feature. */ #define ZR_CLASS_KNOCKBACK_IGNORE -31.0 /** Used by class editor volumetric feature. */
@ -366,6 +368,16 @@ enum ClassFilter
ClassFilter_Client /** The client to check for class group permissions. Use 0 to ignore group filter and negative to exclude classes with groups set. */ ClassFilter_Client /** The client to check for class group permissions. Use 0 to ignore group filter and negative to exclude classes with groups set. */
} }
/**
* Speed methods for applying player speed.
*/
enum ClassSpeedMethods
{
ClassSpeed_Invalid = -1,
ClassSpeed_LMV, /** Modifies lagged movement value. */
ClassSpeed_Prop, /** Modifies players' max speed property(m_flMaxspeed). */
}
/** /**
* Empty filter structure. * Empty filter structure.
*/ */
@ -463,6 +475,11 @@ new String:ClassOriginalPlayerModel[MAXPLAYERS + 1][PLATFORM_MAX_PATH];
*/ */
new bool:ClassPlayerSpawned[MAXPLAYERS + 1]; new bool:ClassPlayerSpawned[MAXPLAYERS + 1];
/**
* What method used to apply speed on players.
*/
new ClassSpeedMethods:ClassSpeedMethod = ClassSpeed_Prop;
#include "zr/playerclasses/filtertools" #include "zr/playerclasses/filtertools"
#include "zr/playerclasses/attributes" #include "zr/playerclasses/attributes"
#include "zr/playerclasses/apply" #include "zr/playerclasses/apply"
@ -655,6 +672,30 @@ public ClassOnConfigReload(ConfigFile:config)
ClassLoad(); ClassLoad();
} }
/**
* Gets the speed method.
*
* @return Speed method, or ClassSpeed_Invalid on error.
*/
ClassSpeedMethods:ClassGetSpeedMethod()
{
decl String:speedMethod[16];
speedMethod[0] = 0;
GetConVarString(g_hCvarsList[CVAR_CLASSES_SPEED_METHOD], speedMethod, sizeof(speedMethod));
if (StrEqual(speedMethod, "lmv", false))
{
return ClassSpeed_LMV;
}
else if (StrEqual(speedMethod, "prop", false))
{
return ClassSpeed_Prop;
}
return ClassSpeed_Invalid;
}
/** /**
* Updates the class data cache. Original values are retrieved from ClassData. * Updates the class data cache. Original values are retrieved from ClassData.
* *

View File

@ -124,15 +124,44 @@ SpawnProtectStart(client)
return; return;
} }
// Set spawn protect flag on client.
bInfectImmune[client][INFECT_TYPE_NORMAL] = true;
// Get spawn protect attribute cvars. // Get spawn protect attribute cvars.
new Float:speed = GetConVarFloat(g_hCvarsList[CVAR_SPAWNPROTECT_SPEED]); new Float:speed = GetConVarFloat(g_hCvarsList[CVAR_SPAWNPROTECT_SPEED]);
new alpha = GetConVarInt(g_hCvarsList[CVAR_SPAWNPROTECT_ALPHA]); new alpha = GetConVarInt(g_hCvarsList[CVAR_SPAWNPROTECT_ALPHA]);
// Validate attributes
new Float:min;
new Float:max;
switch (ClassSpeedMethod)
{
case ClassSpeed_LMV:
{
min = ZR_CLASS_SPEED_LMV_MIN;
max = ZR_CLASS_SPEED_LMV_MAX;
}
case ClassSpeed_Prop:
{
min = ZR_CLASS_SPEED_PROP_MIN;
max = ZR_CLASS_SPEED_PROP_MAX;
}
}
if (speed < min && speed > max)
{
// Log a warning and abort.
LogEvent(false, LogType_Error, LOG_CORE_EVENTS, LogModules:LogModule_Config, "Config validation", "Out of range value in cvar zr_spawnprotect_speed (%f). Aborting spawn protection.", speed);
return;
}
if (alpha < ZR_CLASS_ALPHA_INITIAL_MIN && alpha > ZR_CLASS_ALPHA_INITIAL_MAX)
{
// Log a warning and abort.
LogEvent(false, LogType_Error, LOG_CORE_EVENTS, LogModules:LogModule_Config, "Config validation", "Out of range value in cvar zr_spawnprotect_alpha (%d). Aborting spawn protection.", alpha);
return;
}
// Set spawn protect flag on client.
bInfectImmune[client][INFECT_TYPE_NORMAL] = true;
// Set spawn protect attributes. // Set spawn protect attributes.
ToolsSetClientLMV(client, speed); ClassApplySpeedEx(client, speed);
ToolsSetClientAlpha(client, alpha); ToolsSetClientAlpha(client, alpha);
// Set time left to zr_protect_time's value. // Set time left to zr_protect_time's value.

View File

@ -70,7 +70,7 @@ stock ToolsClientVelocity(client, Float:vecVelocity[3], bool:apply = true, bool:
/** /**
* Set a client's lagged movement value. * Set a client's lagged movement value.
* @param client The client index. * @param client The client index.
* @param value LMV value. (1.0 = default, 2.0 = double) * @param value LMV value. (300.0 = default, 600.0 = double)
*/ */
stock ToolsSetClientLMV(client, Float:fLMV) stock ToolsSetClientLMV(client, Float:fLMV)
{ {