GENERAL: Infection update.
This commit is contained in:
parent
bd10d160c4
commit
1b81c27314
|
@ -56,9 +56,10 @@ native bool ZR_IsClientHuman(int client);
|
|||
* @param respawnOverride (Optional) Set to true to override respawn cvar.
|
||||
* @param respawn (Optional) Value to override with.
|
||||
*
|
||||
* @return True if the client was infected, false if not.
|
||||
* @error Invalid client index, not connected or not alive.
|
||||
*/
|
||||
native int ZR_InfectClient(int client, int attacker = -1, bool motherInfect = false, bool respawnOverride = false, bool respawn = false);
|
||||
native bool ZR_InfectClient(int client, int attacker = -1, bool motherInfect = false, bool respawnOverride = false, bool respawn = false);
|
||||
|
||||
/**
|
||||
* Turns a zombie back into a human.
|
||||
|
@ -70,9 +71,10 @@ native int ZR_InfectClient(int client, int attacker = -1, bool motherInfect = fa
|
|||
* @param respawn Teleport client back to spawn.
|
||||
* @param protect Start spawn protection on client.
|
||||
*
|
||||
* @return True if the client was uninfected, false if not.
|
||||
* @error Invalid client index, not connected or not alive.
|
||||
*/
|
||||
native int ZR_HumanClient(int client, bool respawn = false, bool protect = false);
|
||||
native bool ZR_HumanClient(int client, bool respawn = false, bool protect = false);
|
||||
|
||||
/**
|
||||
* Called when a player is about to become a zombie.
|
||||
|
|
|
@ -105,7 +105,7 @@ public APIInfectClient(Handle:plugin, numParams)
|
|||
// Validate the client index.
|
||||
APIValidateClientIndex(client, Condition_True);
|
||||
|
||||
InfectHumanToZombie(client, attacker, motherInfect, respawnOverride, respawn);
|
||||
return InfectHumanToZombie(client, attacker, motherInfect, respawnOverride, respawn);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -123,7 +123,7 @@ public APIHumanClient(Handle:plugin, numParams)
|
|||
// Validate the client index.
|
||||
APIValidateClientIndex(client, Condition_True);
|
||||
|
||||
InfectZombieToHuman(client, respawn, protect);
|
||||
return InfectZombieToHuman(client, respawn, protect);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -533,77 +533,96 @@ public Action:InfectMotherZombie(Handle:timer)
|
|||
}
|
||||
}
|
||||
|
||||
new candidates = 0;
|
||||
new Handle:aCandidates = CreateArray();
|
||||
new candidatesMain = 0;
|
||||
new candidatesAlt = 0;
|
||||
new Handle:aCandidatesMain = CreateArray();
|
||||
new Handle:aCandidatesAlt = CreateArray();
|
||||
for (new n = 0; n < eligibleclients; n++)
|
||||
{
|
||||
// Get the client stored in the array index.
|
||||
new client = GetArrayCell(arrayEligibleClients, n);
|
||||
|
||||
// If client hasn't been chosen this cycle, put into aCandidates array.
|
||||
// If client hasn't been chosen this cycle, put into aCandidatesMain array.
|
||||
if (!SteamidCacheClientExists(g_hInfectMotherCycle, client))
|
||||
{
|
||||
PushArrayCell(aCandidates, client);
|
||||
candidates++;
|
||||
}
|
||||
PushArrayCell(aCandidatesMain, client);
|
||||
candidatesMain++;
|
||||
}
|
||||
|
||||
// Not enough candidates found.
|
||||
if (candidates < mothercount)
|
||||
// If client hasn't been chosen last round, put into aCandidatesAlt array.
|
||||
else if (!g_bInfectMotherLast[client])
|
||||
{
|
||||
for (new n = 0; n < eligibleclients; n++)
|
||||
{
|
||||
// Get the client stored in the array index.
|
||||
new client = GetArrayCell(arrayEligibleClients, n);
|
||||
|
||||
// If client hasn't been chosen last round, put into aCandidates array,
|
||||
// but only until we have enough candidates.
|
||||
if (!g_bInfectMotherLast[client])
|
||||
{
|
||||
PushArrayCell(aCandidates, client);
|
||||
candidates++;
|
||||
|
||||
// Enough candidates found.
|
||||
if(candidates >= mothercount)
|
||||
break;
|
||||
PushArrayCell(aCandidatesAlt, client);
|
||||
candidatesAlt++;
|
||||
}
|
||||
}
|
||||
|
||||
// Restart the cycle.
|
||||
// Clear mother zombie round-robin cycle storage.
|
||||
SteamidCacheReset(g_hInfectMotherCycle);
|
||||
|
||||
// Announce start of new cycle
|
||||
TranslationPrintToChatAll(true, false, "Mother zombie infect cycle reset");
|
||||
}
|
||||
|
||||
// Remove mother zombie last flag from all players.
|
||||
for (int client = 0; client <= MAXPLAYERS; client++)
|
||||
{
|
||||
g_bInfectMotherLast[client] = false;
|
||||
}
|
||||
|
||||
// Infect players.
|
||||
for (new n = 0; n < mothercount; n++)
|
||||
{
|
||||
// Stop if there are no more candidates.
|
||||
if (candidates <= 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
new bool:resetcycle;
|
||||
|
||||
// Infect players.
|
||||
new infected = 0;
|
||||
while (infected < mothercount)
|
||||
{
|
||||
// Infect one of the main candidates.
|
||||
if (candidatesMain)
|
||||
{
|
||||
// Get a random array index.
|
||||
new i = Math_GetRandomInt(0, candidates - 1);
|
||||
new i = Math_GetRandomInt(0, candidatesMain - 1);
|
||||
|
||||
// Get the client stored in the random array index.
|
||||
new client = GetArrayCell(aCandidates, i);
|
||||
new client = GetArrayCell(aCandidatesMain, i);
|
||||
|
||||
// Infect player.
|
||||
InfectHumanToZombie(client, _, true);
|
||||
if (InfectHumanToZombie(client, _, true))
|
||||
infected++;
|
||||
|
||||
// Remove player from eligible client list.
|
||||
RemoveFromArray(aCandidates, i);
|
||||
candidates--;
|
||||
RemoveFromArray(aCandidatesMain, i);
|
||||
candidatesMain--;
|
||||
}
|
||||
// Infect one of the alternate candidates.
|
||||
else if (candidatesAlt)
|
||||
{
|
||||
// Get a random array index.
|
||||
new i = Math_GetRandomInt(0, candidatesAlt - 1);
|
||||
|
||||
// Get the client stored in the random array index.
|
||||
new client = GetArrayCell(aCandidatesAlt, i);
|
||||
|
||||
// Infect player.
|
||||
if (InfectHumanToZombie(client, _, true))
|
||||
infected++;
|
||||
|
||||
// Remove player from eligible client list.
|
||||
RemoveFromArray(aCandidatesAlt, i);
|
||||
candidatesAlt--;
|
||||
|
||||
// Enable the cycle reset.
|
||||
resetcycle = true;
|
||||
}
|
||||
// We have no candidates at all, abort!
|
||||
else
|
||||
{
|
||||
// Enable the cycle reset.
|
||||
resetcycle = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (resetcycle)
|
||||
{
|
||||
// Restart the cycle.
|
||||
// Clear mother zombie round-robin cycle storage.
|
||||
SteamidCacheReset(g_hInfectMotherCycle);
|
||||
|
||||
// Announce start of new cycle
|
||||
TranslationPrintToChatAll(true, false, "Mother zombie infect cycle reset");
|
||||
}
|
||||
|
||||
// Mother zombies have been infected.
|
||||
|
@ -611,7 +630,8 @@ public Action:InfectMotherZombie(Handle:timer)
|
|||
|
||||
// Destroy client list.
|
||||
CloseHandle(arrayEligibleClients);
|
||||
CloseHandle(aCandidates);
|
||||
CloseHandle(aCandidatesMain);
|
||||
CloseHandle(aCandidatesAlt);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -712,7 +732,7 @@ InfectHumanToZombie(client, attacker = -1, bool:motherinfect = false, bool:respa
|
|||
// Check if infection should be blocked.
|
||||
if (result == Plugin_Handled)
|
||||
{
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
// Mark player as zombie.
|
||||
|
@ -812,6 +832,8 @@ InfectHumanToZombie(client, attacker = -1, bool:motherinfect = false, bool:respa
|
|||
APIOnClientInfected(client, attacker, motherinfect, respawnoverride, respawn);
|
||||
ImmunityOnClientInfected(client);
|
||||
ZSpawnOnClientInfected(client);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -830,7 +852,7 @@ InfectZombieToHuman(client, bool:respawn = false, bool:protect = false)
|
|||
// Check if action should be blocked.
|
||||
if (result == Plugin_Handled)
|
||||
{
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
// Mark player as human.
|
||||
|
@ -878,6 +900,8 @@ InfectZombieToHuman(client, bool:respawn = false, bool:protect = false)
|
|||
APIOnClientHumanPost(client, respawn, protect);
|
||||
ImmunityOnClientHuman(client);
|
||||
ZSpawnOnClientHuman(client);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue
Block a user