General: Apply ZSpawn logic on late spawners.
Improvement on `a45be16399`
This commit is contained in:
parent
9f157e14e9
commit
c32cda3fc9
|
@ -278,14 +278,10 @@ InfectOnClientSpawn(client)
|
||||||
// Disable zombie flag on client.
|
// Disable zombie flag on client.
|
||||||
g_bZombie[client] = false;
|
g_bZombie[client] = false;
|
||||||
|
|
||||||
// Check if client is spawning on the terrorist team.
|
|
||||||
if (ZRIsClientOnTeam(client, CS_TEAM_T) && InfectHasZombieSpawned())
|
|
||||||
{
|
|
||||||
CS_SwitchTeam(client, CS_TEAM_CT);
|
|
||||||
CS_RespawnPlayer(client);
|
|
||||||
}
|
|
||||||
|
|
||||||
InfectUnglitchKevlar(client);
|
InfectUnglitchKevlar(client);
|
||||||
|
|
||||||
|
// Forward event to modules.
|
||||||
|
ZSpawnOnClientSpawn(client);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -25,6 +25,16 @@
|
||||||
* ============================================================================
|
* ============================================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Conditions for respawning players.
|
||||||
|
*/
|
||||||
|
enum ZSpawnCondition
|
||||||
|
{
|
||||||
|
ZSpawn_Block = -1, /** Let ZR decide according to its settings. */
|
||||||
|
ZSpawn_Human = 0, /** Respawn as a human. */
|
||||||
|
ZSpawn_Zombie /** Respawn as a zombie. */
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Global variable to store infect timer handle.
|
* Global variable to store infect timer handle.
|
||||||
*/
|
*/
|
||||||
|
@ -106,6 +116,48 @@ ZSpawnOnClientDeath(client)
|
||||||
SteamidCacheAddClient(g_hZSpawnSteamIDCache, client);
|
SteamidCacheAddClient(g_hZSpawnSteamIDCache, client);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Client is spawning into the game.
|
||||||
|
*
|
||||||
|
* @param client The client index.
|
||||||
|
*/
|
||||||
|
ZSpawnOnClientSpawn(client)
|
||||||
|
{
|
||||||
|
if (InfectHasZombieSpawned())
|
||||||
|
{
|
||||||
|
// Get our zspawn condition.
|
||||||
|
new ZSpawnCondition:condition = GetZSpawnCondition();
|
||||||
|
|
||||||
|
switch(condition)
|
||||||
|
{
|
||||||
|
case ZSpawn_Human:
|
||||||
|
{
|
||||||
|
// Disable zombie flag on client.
|
||||||
|
g_bZombie[client] = false;
|
||||||
|
|
||||||
|
// Check if client is spawning on the terrorists team.
|
||||||
|
if (ZRIsClientOnTeam(client, CS_TEAM_T))
|
||||||
|
{
|
||||||
|
CS_SwitchTeam(client, CS_TEAM_CT);
|
||||||
|
CS_RespawnPlayer(client);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
case ZSpawn_Zombie:
|
||||||
|
{
|
||||||
|
// Enable zombie flag on client.
|
||||||
|
g_bZombie[client] = true;
|
||||||
|
|
||||||
|
// Check if client is spawning on the counter-terrorists team.
|
||||||
|
if (ZRIsClientOnTeam(client, CS_TEAM_CT))
|
||||||
|
{
|
||||||
|
CS_SwitchTeam(client, CS_TEAM_T);
|
||||||
|
CS_RespawnPlayer(client);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Client has been infected.
|
* Client has been infected.
|
||||||
*
|
*
|
||||||
|
@ -253,48 +305,38 @@ bool:ZSpawnClient(client, bool:force = false, bool:zombie = false)
|
||||||
|
|
||||||
if (!force)
|
if (!force)
|
||||||
{
|
{
|
||||||
// Check if zspawn override is enabled, and if so get overidden value.
|
// Get our zspawn condition.
|
||||||
new bool:teamoverride = GetConVarBool(g_hCvarsList[CVAR_ZSPAWN_TEAM_OVERRIDE]);
|
new ZSpawnCondition:condition = GetZSpawnCondition();
|
||||||
teamzombie = teamoverride ? GetConVarBool(g_hCvarsList[CVAR_ZSPAWN_TEAM_ZOMBIE]) : GetConVarBool(g_hCvarsList[CVAR_RESPAWN_TEAM_ZOMBIE]);
|
|
||||||
|
|
||||||
// Block is the time limit is up.
|
switch(condition)
|
||||||
new bool:zspawntimelimit = GetConVarBool(g_hCvarsList[CVAR_ZSPAWN_TIMELIMIT]);
|
|
||||||
if (zspawntimelimit)
|
|
||||||
{
|
{
|
||||||
if (tZSpawn == INVALID_HANDLE)
|
case ZSpawn_Block:
|
||||||
{
|
{
|
||||||
new zspawntimelimitzombie = GetConVarInt(g_hCvarsList[CVAR_ZSPAWN_TIMELIMIT_ZOMBIE]);
|
// Get timelimit.
|
||||||
switch(zspawntimelimitzombie)
|
new Float:zspawntime = GetConVarFloat(g_hCvarsList[CVAR_ZSPAWN_TIMELIMIT_TIME]);
|
||||||
{
|
|
||||||
case -1:
|
|
||||||
{
|
|
||||||
// Get timelimit
|
|
||||||
new Float:zspawntime = GetConVarFloat(g_hCvarsList[CVAR_ZSPAWN_TIMELIMIT_TIME]);
|
|
||||||
|
|
||||||
// Tell client the timelimit for this command has expired.
|
// Tell client the timelimit for this command has expired.
|
||||||
TranslationPrintToChat(client, "ZSpawn timelimit", RoundToNearest(zspawntime));
|
TranslationPrintToChat(client, "ZSpawn timelimit", RoundToNearest(zspawntime));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
case 0:
|
case ZSpawn_Human:
|
||||||
{
|
{
|
||||||
teamzombie = false;
|
teamzombie = false;
|
||||||
}
|
}
|
||||||
case 1:
|
case ZSpawn_Zombie:
|
||||||
{
|
{
|
||||||
teamzombie = true;
|
teamzombie = true;
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Client has been infected this round, respawning as a zombie
|
// Client has been infected this round, respawning as a zombie.
|
||||||
if(g_bZSpawnClientInfected[client])
|
if(g_bZSpawnClientInfected[client])
|
||||||
teamzombie = true;
|
teamzombie = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Use the override team in the function if were forcing the spawn.
|
// Use the override team in the function if were forcing the spawn.
|
||||||
teamzombie = zombie;
|
teamzombie = zombie;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Tell respawn module to respawn client.
|
// Tell respawn module to respawn client.
|
||||||
|
@ -488,3 +530,50 @@ public Action:ZSpawnTimer(Handle:timer)
|
||||||
// Reset timer handle.
|
// Reset timer handle.
|
||||||
tZSpawn = INVALID_HANDLE;
|
tZSpawn = INVALID_HANDLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get ZSpawn condition.
|
||||||
|
*/
|
||||||
|
ZSpawnCondition:GetZSpawnCondition()
|
||||||
|
{
|
||||||
|
new ZSpawnCondition:condition;
|
||||||
|
|
||||||
|
// Check if zspawn override is enabled, and if so use overriden value.
|
||||||
|
if (GetConVarBool(g_hCvarsList[CVAR_ZSPAWN_TEAM_OVERRIDE]))
|
||||||
|
{
|
||||||
|
// Convert boolean to zspawn condition.
|
||||||
|
condition = GetConVarBool(g_hCvarsList[CVAR_ZSPAWN_TEAM_ZOMBIE]) ? ZSpawn_Zombie : ZSpawn_Human;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Convert boolean to zspawn condition.
|
||||||
|
condition = GetConVarBool(g_hCvarsList[CVAR_RESPAWN_TEAM_ZOMBIE]) ? ZSpawn_Zombie : ZSpawn_Human;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if zspawn timelimit is enabled.
|
||||||
|
if (GetConVarBool(g_hCvarsList[CVAR_ZSPAWN_TIMELIMIT]))
|
||||||
|
{
|
||||||
|
// Check if zspawn timelimit is expired.
|
||||||
|
if (!ZRIsTimerRunning(tZSpawn))
|
||||||
|
{
|
||||||
|
new zspawntimelimitzombie = GetConVarInt(g_hCvarsList[CVAR_ZSPAWN_TIMELIMIT_ZOMBIE]);
|
||||||
|
switch(zspawntimelimitzombie)
|
||||||
|
{
|
||||||
|
case -1:
|
||||||
|
{
|
||||||
|
condition = ZSpawn_Block;
|
||||||
|
}
|
||||||
|
case 0:
|
||||||
|
{
|
||||||
|
condition = ZSpawn_Human;
|
||||||
|
}
|
||||||
|
case 1:
|
||||||
|
{
|
||||||
|
condition = ZSpawn_Zombie;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return condition;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user