Add TIMER_FLAG_NO_MAPCHANGE to most timers

& reduce l4d2_avoid_minigun timer from 2s -> 5s
This commit is contained in:
Jackzie 2020-12-27 20:01:15 -06:00
parent 7456c9b9be
commit fb2983f5da
No known key found for this signature in database
GPG key ID: 1E834FE36520537A
8 changed files with 15 additions and 19 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -51,7 +51,7 @@ public void Event_TankSpawn(Event event, const char[] name, bool dontBroadcast)
int userID = GetClientOfUserId(GetEventInt(event, "userid")); int userID = GetClientOfUserId(GetEventInt(event, "userid"));
bIsTank[userID] = true; bIsTank[userID] = true;
if(iAliveTanks == 0 && !bEscapeReady) { if(iAliveTanks == 0 && !bEscapeReady) {
CreateTimer(0.1, BotControlTimerV2, _, TIMER_REPEAT); CreateTimer(0.1, BotControlTimerV2, _, TIMER_REPEAT | TIMER_FLAG_NO_MAPCHANGE);
} }
iAliveTanks++; iAliveTanks++;
} }
@ -154,7 +154,7 @@ public void FindExistingTank() {
} }
if(iAliveTanks > 0) { if(iAliveTanks > 0) {
CreateTimer(0.1, BotControlTimerV2, _, TIMER_REPEAT); CreateTimer(0.1, BotControlTimerV2, _, TIMER_REPEAT | TIMER_FLAG_NO_MAPCHANGE);
} }
} }

View file

@ -34,7 +34,7 @@ public void OnPluginStart()
{ {
SetFailState("This plugin is for L4D/L4D2 only."); SetFailState("This plugin is for L4D/L4D2 only.");
} }
CreateTimer(2.0, CheckTimer, _, TIMER_REPEAT); CreateTimer(5.0, CheckTimer, _, TIMER_REPEAT);
HookEvent("player_team", Event_PlayerTeamSwitch); HookEvent("player_team", Event_PlayerTeamSwitch);
} }
@ -68,7 +68,7 @@ public void Event_PlayerTeamSwitch(Event event, const char[] name, bool dontBroa
public Action CheckTimer(Handle timer) { public Action CheckTimer(Handle timer) {
//Don't do any processing if no one is connected. //Don't do any processing if no one is connected.
//optimization: Only update player-based positions ever 5 loops (2 * 5 = 10 seconds) //optimization: Only update player-based positions ever 5 loops (5 * 5 = 25 seconds)
static int timer_update_pos; static int timer_update_pos;
if(GetClientCount(true) == 0) return Plugin_Continue; if(GetClientCount(true) == 0) return Plugin_Continue;
float pos[3], ang[3], botPos[3], center_distance; float pos[3], ang[3], botPos[3], center_distance;

View file

@ -20,11 +20,12 @@
3 -> Set primary reserve ammo in half 3 -> Set primary reserve ammo in half
4 -> UziRules (Pickup weapon defaults to uzi) 4 -> UziRules (Pickup weapon defaults to uzi)
5 -> PrimaryDisable (Cannot pickup primary weapons at all) 5 -> PrimaryDisable (Cannot pickup primary weapons at all)
6 -> Slow Drain 6 -> Slow Drain (Slowly drains hp over time)
7 -> Clusmy 7 -> Clusmy (Drops their melee weapon)
8 -> IcantSpellNoMore 8 -> IcantSpellNoMore (Chat messages letter will randomly changed with wrong letters )
9 -> CameTooEarly 9 -> CameTooEarly (When they shoot, they empty the whole clip at once.)
10 -> KillMeSoftly 10 -> KillMeSoftly (Make player eat or waste pills whenever)
11 -> ThrowItAll (Makes player just throw all their items at a nearby player, and periodically)
*/ */
#define TROLL_MODE_COUNT 12 #define TROLL_MODE_COUNT 12
static const char TROLL_MODES_NAMES[TROLL_MODE_COUNT][32] = { static const char TROLL_MODES_NAMES[TROLL_MODE_COUNT][32] = {
@ -52,7 +53,7 @@ public Plugin myinfo =
}; };
Handle hThrowTimer; Handle hThrowTimer;
ConVar hVictimsList, hThrowItemInterval; ConVar hVictimsList, hThrowItemInterval;
bool bTrollTargets[MAXPLAYERS+1], lateLoaded, bTimerEnabled = false; bool bTrollTargets[MAXPLAYERS+1], lateLoaded;
int iTrollMode = 0; //troll mode. 0 -> Slosdown | 1 -> Higher Gravity | 2 -> CameTooEarly | 3 -> UziRules int iTrollMode = 0; //troll mode. 0 -> Slosdown | 1 -> Higher Gravity | 2 -> CameTooEarly | 3 -> UziRules
int g_iAmmoTable; int g_iAmmoTable;
@ -108,7 +109,7 @@ public void Change_ThrowInterval(ConVar convar, const char[] oldValue, const cha
if(hThrowTimer != INVALID_HANDLE) { if(hThrowTimer != INVALID_HANDLE) {
delete hThrowTimer; delete hThrowTimer;
PrintToServer("Reset new throw item timer"); PrintToServer("Reset new throw item timer");
hThrowTimer = CreateTimer(convar.FloatValue, Timer_ThrowTimer, _, TIMER_REPEAT); hThrowTimer = CreateTimer(convar.FloatValue, Timer_ThrowTimer, _, TIMER_REPEAT | TIMER_FLAG_NO_MAPCHANGE);
} }
} }
// #endregion // #endregion
@ -329,17 +330,16 @@ void ApplyModeToClient(int client, int victim, int mode) {
int clientCount = GetClientsInRange(pos, RangeType_Visibility, clients, sizeof(clients)); int clientCount = GetClientsInRange(pos, RangeType_Visibility, clients, sizeof(clients));
for(int i = 0; i < clientCount; i++) { for(int i = 0; i < clientCount; i++) {
if(clients[i] != victim) { if(clients[i] != victim) {
PrintToChatAll("client %d throw to %d", victim, clients[i]);
float targPos[3]; float targPos[3];
GetClientAbsOrigin(clients[i], targPos); GetClientAbsOrigin(clients[i], targPos);
SDKHooks_DropWeapon(victim, wpn, targPos); SDKHooks_DropWeapon(victim, wpn, targPos);
iTrollUsers[victim] = mode; iTrollUsers[victim] = mode;
CreateTimer(0.2, Timer_GivePistol);
return; return;
} }
} }
SDKHooks_DropWeapon(victim, wpn); SDKHooks_DropWeapon(victim, wpn);
} }
ReplyToCommand(client, "res = %d" , hasMelee ? 1 : 0);
} }
case 8: case 8:
ReplyToCommand(client, "This troll mode is not implemented."); ReplyToCommand(client, "This troll mode is not implemented.");
@ -469,10 +469,6 @@ bool TestForTarget(int client, const char[] auth) {
PrintToServer("[Debug] Troll target detected with id %d and steamid %s", client, auth); PrintToServer("[Debug] Troll target detected with id %d and steamid %s", client, auth);
#endif #endif
bTrollTargets[client] = true; bTrollTargets[client] = true;
if(!bTimerEnabled) {
bTimerEnabled = true;
}
return true; return true;
} }
} }

View file

@ -159,7 +159,7 @@ public Action Cmd_SwarmToggle(int client, int args) {
SwarmUser(GetClientUserId(target_list[0]), range); SwarmUser(GetClientUserId(target_list[0]), range);
ReplyToCommand(client, "Now continously swarming victim %N. Radius: %d", target_list[0], range); ReplyToCommand(client, "Now continously swarming victim %N. Radius: %d", target_list[0], range);
if(timer == INVALID_HANDLE) if(timer == INVALID_HANDLE)
timer = CreateTimer(1.0, Timer_Swarm, _, TIMER_REPEAT); timer = CreateTimer(1.0, Timer_Swarm, _, TIMER_REPEAT | TIMER_FLAG_NO_MAPCHANGE);
} }
} }
return Plugin_Handled; return Plugin_Handled;
@ -230,7 +230,7 @@ public int Handle_SwarmMenuToggle(Menu menu, MenuAction action, int client, int
int clientID = GetClientOfUserId(SwarmTarget); int clientID = GetClientOfUserId(SwarmTarget);
PrintToChat(client, "Toggled swarm on for %N (#%d). Radius: %d", clientID, SwarmTarget, SwarmRadius); PrintToChat(client, "Toggled swarm on for %N (#%d). Radius: %d", clientID, SwarmTarget, SwarmRadius);
if(timer == INVALID_HANDLE) if(timer == INVALID_HANDLE)
timer = CreateTimer(1.0, Timer_Swarm, _, TIMER_REPEAT); timer = CreateTimer(1.0, Timer_Swarm, _, TIMER_REPEAT | TIMER_FLAG_NO_MAPCHANGE);
}else{ }else{
SwarmTarget = -1; SwarmTarget = -1;
SwarmRadius = hSwarmDefaultRange.IntValue; SwarmRadius = hSwarmDefaultRange.IntValue;