sloppy AI update to just add extra native giving the index of 1-4 for the autismbots
This commit is contained in:
@@ -6,13 +6,24 @@
|
|||||||
|
|
||||||
bool g_bLateLoad = false;
|
bool g_bLateLoad = false;
|
||||||
bool g_bIsAutismBot[MAXPLAYERS+1] = { false, ... };
|
bool g_bIsAutismBot[MAXPLAYERS+1] = { false, ... };
|
||||||
|
int g_iAutismBotIndex[MAXPLAYERS+1] = { 0, ... }; // 0 = not an autism bot, 1-4 = autism bot index
|
||||||
|
|
||||||
|
// The position in this list is the autism bot index (first entry = 1).
|
||||||
|
// The index decides which UDP port the connection plugin talks to, so keep this order.
|
||||||
|
char g_sAutismBotAuthIDs[][] =
|
||||||
|
{
|
||||||
|
"STEAM_0:1:60189040", // autism bot 1
|
||||||
|
"STEAM_0:0:518094602", // autism bot 2
|
||||||
|
"STEAM_0:0:204398871", // autism bot 3
|
||||||
|
"STEAM_0:0:610560766" // autism bot 4
|
||||||
|
};
|
||||||
|
|
||||||
public Plugin myinfo =
|
public Plugin myinfo =
|
||||||
{
|
{
|
||||||
name = "Bot Targeting",
|
name = "Bot Targeting",
|
||||||
author = "zaCade",
|
author = "zaCade",
|
||||||
description = "Adds extra targeting methods",
|
description = "Adds extra targeting methods",
|
||||||
version = "1.0"
|
version = "1.1"
|
||||||
};
|
};
|
||||||
|
|
||||||
public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max)
|
public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max)
|
||||||
@@ -20,6 +31,7 @@ public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max
|
|||||||
g_bLateLoad = late;
|
g_bLateLoad = late;
|
||||||
|
|
||||||
CreateNative("IsClientAutismBot", Native_IsAutismBot);
|
CreateNative("IsClientAutismBot", Native_IsAutismBot);
|
||||||
|
CreateNative("GetClientAutismBotIndex", Native_GetAutismBotIndex);
|
||||||
|
|
||||||
RegPluginLibrary("BotTargeting");
|
RegPluginLibrary("BotTargeting");
|
||||||
return APLRes_Success;
|
return APLRes_Success;
|
||||||
@@ -52,16 +64,24 @@ public void OnPluginEnd()
|
|||||||
|
|
||||||
public void OnClientAuthorized(int client, const char[] sAuthID)
|
public void OnClientAuthorized(int client, const char[] sAuthID)
|
||||||
{
|
{
|
||||||
g_bIsAutismBot[client] = \
|
g_iAutismBotIndex[client] = 0;
|
||||||
StrEqual(sAuthID, "STEAM_0:1:60189040") || \
|
|
||||||
StrEqual(sAuthID, "STEAM_0:0:204398871") || \
|
for(int i = 0; i < sizeof(g_sAutismBotAuthIDs); i++)
|
||||||
StrEqual(sAuthID, "STEAM_0:0:518094602") || \
|
{
|
||||||
StrEqual(sAuthID, "STEAM_0:0:610560766");
|
if(StrEqual(sAuthID, g_sAutismBotAuthIDs[i]))
|
||||||
|
{
|
||||||
|
g_iAutismBotIndex[client] = i + 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnClientDisconnected(int client)
|
g_bIsAutismBot[client] = g_iAutismBotIndex[client] != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void OnClientDisconnect(int client)
|
||||||
{
|
{
|
||||||
g_bIsAutismBot[client] = false;
|
g_bIsAutismBot[client] = false;
|
||||||
|
g_iAutismBotIndex[client] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Filter_AutismBot(const char[] sPattern, Handle hClients, int client)
|
public bool Filter_AutismBot(const char[] sPattern, Handle hClients, int client)
|
||||||
@@ -90,10 +110,8 @@ public bool Filter_NonAutismBot(const char[] sPattern, Handle hClients, int clie
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int Native_IsAutismBot(Handle hPlugin, int numParams)
|
bool ValidateNativeClient(int client)
|
||||||
{
|
{
|
||||||
int client = GetNativeCell(1);
|
|
||||||
|
|
||||||
if(client > MaxClients || client <= 0)
|
if(client > MaxClients || client <= 0)
|
||||||
{
|
{
|
||||||
ThrowNativeError(SP_ERROR_NATIVE, "Client is not valid.");
|
ThrowNativeError(SP_ERROR_NATIVE, "Client is not valid.");
|
||||||
@@ -112,15 +130,29 @@ public int Native_IsAutismBot(Handle hPlugin, int numParams)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Native_IsAutismBot(Handle hPlugin, int numParams)
|
||||||
|
{
|
||||||
|
int client = GetNativeCell(1);
|
||||||
|
|
||||||
|
if(!ValidateNativeClient(client))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return g_bIsAutismBot[client];
|
return g_bIsAutismBot[client];
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
public int Native_GetAutismBotIndex(Handle hPlugin, int numParams)
|
||||||
public Action ZR_OnClientMotherZombieEligible(int client)
|
|
||||||
{
|
{
|
||||||
if (g_bIsAutismBot[client])
|
int client = GetNativeCell(1);
|
||||||
return Plugin_Handled;
|
|
||||||
|
|
||||||
return Plugin_Continue;
|
if(!ValidateNativeClient(client))
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return g_iAutismBotIndex[client];
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|||||||
@@ -3,8 +3,21 @@
|
|||||||
#endif
|
#endif
|
||||||
#define _BotTargeting_Included
|
#define _BotTargeting_Included
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns whether the client is one of the autism bots.
|
||||||
|
* Throws an error if the client is invalid, not in-game or not authorized.
|
||||||
|
*/
|
||||||
native bool IsClientAutismBot(int client);
|
native bool IsClientAutismBot(int client);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns which autism bot the client is.
|
||||||
|
* Throws an error if the client is invalid, not in-game or not authorized.
|
||||||
|
*
|
||||||
|
* @param client Client index.
|
||||||
|
* @return 1-4 for autism bot 1 to 4, 0 if the client is not an autism bot.
|
||||||
|
*/
|
||||||
|
native int GetClientAutismBotIndex(int client);
|
||||||
|
|
||||||
public SharedPlugin __pl_BotTargeting =
|
public SharedPlugin __pl_BotTargeting =
|
||||||
{
|
{
|
||||||
name = "BotTargeting",
|
name = "BotTargeting",
|
||||||
@@ -20,5 +33,6 @@ public SharedPlugin __pl_BotTargeting =
|
|||||||
public __pl_BotTargeting_SetNTVOptional()
|
public __pl_BotTargeting_SetNTVOptional()
|
||||||
{
|
{
|
||||||
MarkNativeAsOptional("IsClientAutismBot");
|
MarkNativeAsOptional("IsClientAutismBot");
|
||||||
|
MarkNativeAsOptional("GetClientAutismBotIndex");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user