mirror of
https://github.com/Jackzmc/sourcemod-plugins.git
synced 2025-05-06 21:53:21 +00:00
Keep idle time on map transitions
This commit is contained in:
parent
9fbb89e162
commit
a00922586a
2 changed files with 15 additions and 4 deletions
Binary file not shown.
|
@ -4,6 +4,7 @@
|
||||||
//#define DEBUG
|
//#define DEBUG
|
||||||
|
|
||||||
#define ALLOW_HEALING_MIN_IDLE_TIME 180
|
#define ALLOW_HEALING_MIN_IDLE_TIME 180
|
||||||
|
#define MIN_IGNORE_IDLE_TIME 5
|
||||||
#define PLUGIN_VERSION "1.0"
|
#define PLUGIN_VERSION "1.0"
|
||||||
|
|
||||||
#include <sourcemod>
|
#include <sourcemod>
|
||||||
|
@ -11,10 +12,10 @@
|
||||||
#include <actions>
|
#include <actions>
|
||||||
//#include <sdkhooks>
|
//#include <sdkhooks>
|
||||||
|
|
||||||
|
int lastIdleTimeStart[MAXPLAYERS+1];
|
||||||
int idleTimeStart[MAXPLAYERS+1];
|
int idleTimeStart[MAXPLAYERS+1];
|
||||||
|
|
||||||
public Plugin myinfo =
|
public Plugin myinfo = {
|
||||||
{
|
|
||||||
name = "L4D2 AI Tweaks",
|
name = "L4D2 AI Tweaks",
|
||||||
author = "jackzmc",
|
author = "jackzmc",
|
||||||
description = "",
|
description = "",
|
||||||
|
@ -27,16 +28,26 @@ public void OnPluginStart() {
|
||||||
if(g_Game != Engine_Left4Dead2) {
|
if(g_Game != Engine_Left4Dead2) {
|
||||||
SetFailState("This plugin is for L4D2 only.");
|
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);
|
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"));
|
int client = GetClientOfUserId(event.GetInt("userid"));
|
||||||
if(client > 0) {
|
if(client > 0) {
|
||||||
|
lastIdleTimeStart[client] = idleTimeStart[client];
|
||||||
idleTimeStart[client] = GetTime();
|
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 ) {
|
public void OnActionCreated( BehaviorAction action, int actor, const char[] name ) {
|
||||||
/* Hooking friend healing action (when bot wants to heal someone) */
|
/* Hooking friend healing action (when bot wants to heal someone) */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue