KnifeMadness: Fix random trigger timer shenanigans.
This commit is contained in:
parent
7316892835
commit
f420fda320
@ -33,9 +33,10 @@ public void OnPluginStart()
|
||||
{
|
||||
g_hCVar_Delay = CreateConVar("sm_knife_madness_kill_delay", "3", "Delay before ZMs die after being knifed by a human.", 0, true, 0.0);
|
||||
|
||||
HookEvent("player_spawn", OnClientSpawn);
|
||||
HookEvent("player_hurt", OnClientHurt);
|
||||
HookEvent("round_start", OnRoundStart);
|
||||
HookEvent("player_spawn", OnClientSpawn);
|
||||
HookEvent("player_hurt", OnClientHurt);
|
||||
HookEvent("round_start", OnRoundStart);
|
||||
HookEvent("round_end", OnRoundEnd);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
@ -85,25 +86,21 @@ public void OnClientHurt(Event hEvent, const char[] sEvent, bool bDontBroadcast)
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public void OnRoundStart(Event hEvent, const char[] sEvent, bool bDontBroadcast)
|
||||
{
|
||||
ResetTriggers();
|
||||
g_hTriggerTimer = CreateTimer(GetRandomFloat(12.0, 50.0), SpecialTrigger, INVALID_HANDLE, TIMER_FLAG_NO_MAPCHANGE);
|
||||
}
|
||||
|
||||
if (g_hTriggerTimer != INVALID_HANDLE)
|
||||
{
|
||||
PrintToChatAll("trigger active, needs kill");
|
||||
KillTimer(g_hTriggerTimer);
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public void OnRoundEnd(Event hEvent, const char[] sEvent, bool bDontBroadcast)
|
||||
{
|
||||
if (g_hTriggerTimer != INVALID_HANDLE && CloseHandle(g_hTriggerTimer))
|
||||
g_hTriggerTimer = INVALID_HANDLE;
|
||||
}
|
||||
|
||||
if (g_hTriggerResetTimer != INVALID_HANDLE)
|
||||
{
|
||||
PrintToChatAll("reset active, needs kill");
|
||||
KillTimer(g_hTriggerResetTimer);
|
||||
if (g_hTriggerResetTimer != INVALID_HANDLE && CloseHandle(g_hTriggerResetTimer))
|
||||
g_hTriggerResetTimer = INVALID_HANDLE;
|
||||
}
|
||||
|
||||
float fRandomInterval = GetRandomFloat(12.0, 50.0);
|
||||
g_hTriggerTimer = CreateTimer(fRandomInterval, SpecialTrigger, INVALID_HANDLE, TIMER_FLAG_NO_MAPCHANGE);
|
||||
g_hTriggerResetTimer = CreateTimer(fRandomInterval + 10.0, ResetTriggerTimer, INVALID_HANDLE, TIMER_FLAG_NO_MAPCHANGE);
|
||||
ResetTriggers();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
@ -111,6 +108,9 @@ public void OnRoundStart(Event hEvent, const char[] sEvent, bool bDontBroadcast)
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public Action SpecialTrigger(Handle timer)
|
||||
{
|
||||
g_hTriggerTimer = CreateTimer(GetRandomFloat(15.0, 45.0), SpecialTrigger, INVALID_HANDLE, TIMER_FLAG_NO_MAPCHANGE);
|
||||
EmitGameSoundToAll("Bot.Stuck1");
|
||||
|
||||
int iRandom = GetRandomInt(0, 8);
|
||||
if (iRandom == 0)
|
||||
{
|
||||
@ -218,12 +218,8 @@ public Action SpecialTrigger(Handle timer)
|
||||
}
|
||||
}
|
||||
}
|
||||
EmitGameSoundToAll("Bot.Stuck1");
|
||||
g_hTriggerTimer = INVALID_HANDLE;
|
||||
|
||||
float fRandomInterval = GetRandomFloat(11.0, 60.0);
|
||||
g_hTriggerTimer = CreateTimer(fRandomInterval, SpecialTrigger);
|
||||
g_hTriggerResetTimer = CreateTimer(fRandomInterval + 10.0, ResetTriggerTimer);
|
||||
g_hTriggerResetTimer = CreateTimer(10.0, ResetTriggerTimer, INVALID_HANDLE, TIMER_FLAG_NO_MAPCHANGE);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
@ -232,8 +228,9 @@ public Action SpecialTrigger(Handle timer)
|
||||
public Action ResetTriggerTimer(Handle timer)
|
||||
{
|
||||
g_hTriggerResetTimer = INVALID_HANDLE;
|
||||
ResetTriggers();
|
||||
EmitGameSoundToAll("Bot.Stuck2");
|
||||
|
||||
ResetTriggers();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
@ -241,7 +238,6 @@ public Action ResetTriggerTimer(Handle timer)
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public void ResetTriggers()
|
||||
{
|
||||
ServerCommand("sv_gravity 800");
|
||||
for (int client = 1; client <= MaxClients; client++)
|
||||
{
|
||||
if (IsValidClient(client, false) && IsPlayerAlive(client))
|
||||
@ -254,10 +250,12 @@ public void ResetTriggers()
|
||||
GivePlayerItem(client, "weapon_knife");
|
||||
}
|
||||
}
|
||||
|
||||
ServerCommand("sm plugins unload disabled/autobhop");
|
||||
ServerCommand("sv_friction 4");
|
||||
ServerCommand("sv_accelerate 5");
|
||||
ServerCommand("sv_airaccelerate 10");
|
||||
ServerCommand("sv_friction 4");
|
||||
ServerCommand("sv_gravity 800");
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
|
Loading…
Reference in New Issue
Block a user