diff --git a/plugins/l4d2_ai_tweaks.smx b/plugins/l4d2_ai_tweaks.smx index 2a417c7..e8c85cd 100644 Binary files a/plugins/l4d2_ai_tweaks.smx and b/plugins/l4d2_ai_tweaks.smx differ diff --git a/scripting/l4d2_ai_tweaks.sp b/scripting/l4d2_ai_tweaks.sp index 938f3de..f2e8bf6 100644 --- a/scripting/l4d2_ai_tweaks.sp +++ b/scripting/l4d2_ai_tweaks.sp @@ -4,6 +4,7 @@ //#define DEBUG #define ALLOW_HEALING_MIN_IDLE_TIME 180 +#define MIN_IGNORE_IDLE_TIME 5 #define PLUGIN_VERSION "1.0" #include @@ -11,10 +12,10 @@ #include //#include +int lastIdleTimeStart[MAXPLAYERS+1]; int idleTimeStart[MAXPLAYERS+1]; -public Plugin myinfo = -{ +public Plugin myinfo = { name = "L4D2 AI Tweaks", author = "jackzmc", description = "", @@ -27,16 +28,26 @@ public void OnPluginStart() { if(g_Game != Engine_Left4Dead2) { SetFailState("This plugin is for L4D2 only."); } - // HookEvent("player_bot_replace", Event_PlayerOutOfIdle ); + HookEvent("player_bot_replace", Event_PlayerOutOfIdle ); HookEvent("bot_player_replace", Event_PlayerToIdle); } -public Action Event_PlayerToIdle(Event event, const char[] name, bool dontBroadcast) { +void Event_PlayerToIdle(Event event, const char[] name, bool dontBroadcast) { int client = GetClientOfUserId(event.GetInt("userid")); if(client > 0) { + lastIdleTimeStart[client] = idleTimeStart[client]; idleTimeStart[client] = GetTime(); } } +void Event_PlayerOutOfIdle(Event event, const char[] name, bool dontBroadcast) { + int client = GetClientOfUserId(event.GetInt("userid")); + if(client > 0) { + // After saferooms, idle players get resumed then immediately idle - so ignore that + if(GetTime() - idleTimeStart[client] < MIN_IGNORE_IDLE_TIME) { + idleTimeStart[client] = lastIdleTimeStart[client]; + } + } +} public void OnActionCreated( BehaviorAction action, int actor, const char[] name ) { /* Hooking friend healing action (when bot wants to heal someone) */