some refactoring and changes. there are still plenty of updates i need to have time for

This commit is contained in:
christian 2021-07-27 22:55:12 +02:00
parent b460d906da
commit 7ff258df50

View File

@ -3,7 +3,7 @@
#define DEBUG
#define PLUGIN_AUTHOR "jenz"
#define PLUGIN_VERSION "1.5"
#define PLUGIN_VERSION "1.6"
#define generic_length 256
#include <sourcemod>
@ -18,6 +18,7 @@ int targethuman[MAXPLAYERS + 1];
int target_enemy[MAXPLAYERS + 1];
int buttons_old[MAXPLAYERS + 1];
int flags_old[MAXPLAYERS + 1];
int ports[4] = {48479, 48482, 48476, 48481};
bool surf_cooldown = false;
int bot_avoid_edge[MAXPLAYERS + 1];
float client_old_coords[MAXPLAYERS + 1][3];
@ -141,9 +142,48 @@ public bool distance_check(int client)
return true;
}
public void cmd_talk_help(int port, int client, char[] info)
{
char msg[generic_length * 5];
chat_cooldown = true;
char magic_code[16];
Format(magic_code, sizeof(magic_code), "72DqZ84");
Format(msg, sizeof(msg), "clientmessage:%N %s %s", client, magic_code, info);
send_socket_msg(msg, strlen(msg), port);
CreateTimer(2.0, bot_chat_cooldown);
}
public bool is_autism_bot1(int client)
{
char auth[50];
GetClientAuthId(client, AuthId_Engine, auth, sizeof(auth));
return StrEqual("[U:1:120378081]", auth, false) || StrEqual("STEAM_0:1:60189040", auth, false);
}
public bool is_autism_bot2(int client)
{
char auth[50];
GetClientAuthId(client, AuthId_Engine, auth, sizeof(auth));
return StrEqual("[U:1:1036189204]", auth, false) || StrEqual("STEAM_0:0:518094602", auth, false);
}
public bool is_autism_bot3(int client)
{
char auth[50];
GetClientAuthId(client, AuthId_Engine, auth, sizeof(auth));
return StrEqual("[U:1:408797742]", auth, false) || StrEqual("STEAM_0:0:204398871", auth, false);
}
public bool is_autism_bot4(int client)
{
char auth[50];
GetClientAuthId(client, AuthId_Engine, auth, sizeof(auth));
return StrEqual("[U:1:1221121532]", auth, false) || StrEqual("STEAM_0:0:610560766", auth, false);
}
public Action cmd_talk(int client, int args)
{
char msg[generic_length * 5];
char info[generic_length];
GetCmdArgString(info, sizeof(info));
if (strlen(info) == 0)
@ -160,46 +200,24 @@ public Action cmd_talk(int client, int args)
for (int i = 1; i <= MaxClients; i++)
if (IsValidClient(i) && !IsFakeClient(i))
{
char auth[50];
GetClientAuthId(i, AuthId_Engine, auth, sizeof(auth));
if (StrEqual("[U:1:120378081]", auth, false) || StrEqual("STEAM_0:1:60189040", auth, false))
if (is_autism_bot1(i))
{
chat_cooldown = true;
char magic_code[16];
Format(magic_code, sizeof(magic_code), "72DqZ84");
Format(msg, sizeof(msg), "clientmessage:%N %s %s", client, magic_code, info);
send_socket_msg(msg, strlen(msg));
CreateTimer(2.0, bot_chat_cooldown);
cmd_talk_help(ports[0], client, info);
bot_found = true;
}
if (StrEqual("[U:1:1036189204]", auth, false) || StrEqual("STEAM_0:0:518094602", auth, false))
if (is_autism_bot2(i))
{
chat_cooldown = true;
char magic_code[16];
Format(magic_code, sizeof(magic_code), "72DqZ84");
Format(msg, sizeof(msg), "clientmessage:%N %s %s", client, magic_code, info);
send_socket_msg1(msg, strlen(msg));
CreateTimer(2.0, bot_chat_cooldown);
cmd_talk_help(ports[1], client, info);
bot_found = true;
}
if (StrEqual("[U:1:408797742]", auth, false) || StrEqual("STEAM_0:0:204398871", auth, false))
if (is_autism_bot3(i))
{
chat_cooldown = true;
char magic_code[16];
Format(magic_code, sizeof(magic_code), "72DqZ84");
Format(msg, sizeof(msg), "clientmessage:%N %s %s", client, magic_code, info);
send_socket_msg2(msg, strlen(msg));
CreateTimer(2.0, bot_chat_cooldown);
cmd_talk_help(ports[2], client, info);
bot_found = true;
}
if (StrEqual("[U:1:1221121532]", auth, false) || StrEqual("STEAM_0:0:610560766", auth, false))
if (is_autism_bot4(i))
{
chat_cooldown = true;
char magic_code[16];
Format(magic_code, sizeof(magic_code), "72DqZ84");
Format(msg, sizeof(msg), "clientmessage:%N %s %s", client, magic_code, info);
send_socket_msg3(msg, strlen(msg));
CreateTimer(2.0, bot_chat_cooldown);
cmd_talk_help(ports[3], client, info);
bot_found = true;
}
}
@ -233,91 +251,50 @@ public void OnMapStart()
CreateTimer(15.0, bot_check_connect, INVALID_HANDLE, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE);
}
public void send_socket_msg(char[] query_msg, int len)
public void send_socket_msg(char[] query_msg, int len, int port)
{
if (global_socket != INVALID_HANDLE && SocketIsConnected(global_socket))
SocketSendTo(global_socket, query_msg, len, "127.0.0.1", 48479); //udp
SocketSendTo(global_socket, query_msg, len, "127.0.0.1", port); //udp
}
public void send_socket_msg1(char[] query_msg, int len)
{
if (global_socket != INVALID_HANDLE && SocketIsConnected(global_socket))
SocketSendTo(global_socket, query_msg, len, "127.0.0.1", 48482); //udp
}
public void send_socket_msg2(char[] query_msg, int len)
{
if (global_socket != INVALID_HANDLE && SocketIsConnected(global_socket))
SocketSendTo(global_socket, query_msg, len, "127.0.0.1", 48476); //udp
}
public void send_socket_msg3(char[] query_msg, int len)
{
if (global_socket != INVALID_HANDLE && SocketIsConnected(global_socket))
SocketSendTo(global_socket, query_msg, len, "127.0.0.1", 48481); //udp
}
public Action bot_check_connect(Handle timer, any data)
{
int client_count = GetClientCount(false);
bool found_bot_1 = false;
bool found_bot_2 = false;
bool found_bot_3 = false;
bool found_bot_4 = false;
char msg[generic_length];
//PrintToChatAll("sending UDP message...");
Format(msg, sizeof(msg), "connect to ze");
for (int i = 1; i <= MaxClients; i++)
if (IsValidClient(i) && !IsFakeClient(i))
{
if (client_count > 60)
{
found_bot_1 = true;
found_bot_2 = true;
found_bot_3 = true;
found_bot_4 = true;
if (is_bot_player(i))
{
KickClient(i, "server full you need to leave");
}
}
else
else if (client_count < 50)
{
char auth[50];
GetClientAuthId(i, AuthId_Engine, auth, sizeof(auth));
if (StrEqual("[U:1:120378081]", auth, false) || StrEqual("STEAM_0:1:60189040", auth, false))
if (is_autism_bot1(i))
{
found_bot_1 = true;
send_socket_msg(msg, strlen(msg), ports[0]);
}
if (StrEqual("[U:1:1036189204]", auth, false) || StrEqual("STEAM_0:0:518094602", auth, false))
if (is_autism_bot2(i))
{
found_bot_2 = true;
send_socket_msg(msg, strlen(msg), ports[1]);
}
if (StrEqual("[U:1:408797742]", auth, false) || StrEqual("STEAM_0:0:204398871", auth, false))
if (is_autism_bot3(i))
{
found_bot_3 = true;
send_socket_msg(msg, strlen(msg), ports[2]);
}
if (client_count < 55)
if (is_autism_bot4(i))
{
if (StrEqual("[U:1:1221121532]", auth, false) || StrEqual("STEAM_0:0:610560766", auth, false))
{
found_bot_4 = true;
}
send_socket_msg(msg, strlen(msg), ports[3]);
}
}
}
char msg[generic_length];
//PrintToChatAll("sending UDP message...");
Format(msg, sizeof(msg), "connect to ze");
if (!found_bot_1)
send_socket_msg(msg, strlen(msg));
if (!found_bot_2)
send_socket_msg1(msg, strlen(msg));
if (!found_bot_3)
send_socket_msg2(msg, strlen(msg));
if (client_count < 55)
{
if (!found_bot_4)
send_socket_msg3(msg, strlen(msg));
}
return Plugin_Continue;
}
@ -372,43 +349,28 @@ public void OnPlayerRunCmdPost(int client, int buttons, int impulse, const float
}
}
}
TeleportEntity(client, NULL_VECTOR, NULL_VECTOR, Vel);
SetEntPropVector(client, Prop_Data, "m_vecBaseVelocity", Vel);
//TeleportEntity(client, NULL_VECTOR, NULL_VECTOR, Vel);
}
buttons_old[client] = buttons;
flags_old[client] = flags;
}
}
//this was for turning around to prevent falling off edges
void ApplyBoost(int client, float amount){
float direction[3], vel[3];
GetEntPropVector(client, Prop_Data, "m_vecVelocity", vel);
NormalizeVector(vel, direction);
ScaleVector(direction, amount);
AddVectors(vel, direction, vel);
TeleportEntity(client, NULL_VECTOR, NULL_VECTOR, vel);
//TeleportEntity(client, NULL_VECTOR, NULL_VECTOR, vel);
SetEntPropVector(client, Prop_Data, "m_vecBaseVelocity", vel);
}
public bool is_bot_player(int client)
{
char auth[50];
GetClientAuthId(client, AuthId_Engine, auth, sizeof(auth));
if (StrEqual("[U:1:120378081]", auth, false) || StrEqual("STEAM_0:1:60189040", auth, false))
{
return true;
}
if (StrEqual("[U:1:1036189204]", auth, false) || StrEqual("STEAM_0:0:518094602", auth, false))
{
return true;
}
if (StrEqual("[U:1:408797742]", auth, false) || StrEqual("STEAM_0:0:204398871", auth, false))
{
return true;
}
if (StrEqual("[U:1:1221121532]", auth, false) || StrEqual("STEAM_0:0:610560766", auth, false))
{
return true;
}
return false;
return is_autism_bot1(client) || is_autism_bot2(client) || is_autism_bot3(client) || is_autism_bot4(client);
}
public Action recursive_pressing(Handle timer, any data)
@ -489,7 +451,8 @@ public Action recursive_pressing(Handle timer, any data)
}
else if (IsValidClient(targethuman[client]))
face_call(targethuman[client], client);
if (GetEntProp(client, Prop_Data, "m_nWaterLevel") == 0)
//might prevent bot from jumping off ladders
if (GetEntProp(client, Prop_Data, "m_nWaterLevel") == 0 && GetEntityMoveType(client) != MOVETYPE_LADDER)
trace_hulling_bot(client);
char message[generic_length * 7];
if (IsValidClient(targethuman[client]))
@ -500,24 +463,22 @@ public Action recursive_pressing(Handle timer, any data)
Format(message, sizeof(message), "%s target_enemy: %N", message, target_enemy[client]);
else
Format(message, sizeof(message), "%s target_enemy: none", message);
char auth[50];
GetClientAuthId(client, AuthId_Engine, auth, sizeof(auth));
if (StrEqual("[U:1:120378081]", auth, false) || StrEqual("STEAM_0:1:60189040", auth, false))
if (is_autism_bot1(client))
{
send_socket_msg(message, strlen(message));
send_socket_msg(message, strlen(message), ports[0]);
}
if (StrEqual("[U:1:1036189204]", auth, false) || StrEqual("STEAM_0:0:518094602", auth, false))
if (is_autism_bot2(client))
{
send_socket_msg1(message, strlen(message));
send_socket_msg(message, strlen(message), ports[1]);
}
if (StrEqual("[U:1:408797742]", auth, false) || StrEqual("STEAM_0:0:204398871", auth, false))
if (is_autism_bot3(client))
{
send_socket_msg2(message, strlen(message));
send_socket_msg(message, strlen(message), ports[2]);
}
if (StrEqual("[U:1:1221121532]", auth, false) || StrEqual("STEAM_0:0:610560766", auth, false))
if (is_autism_bot4(client))
{
send_socket_msg3(message, strlen(message));
send_socket_msg(message, strlen(message), ports[3]);
}
}
}
@ -569,23 +530,21 @@ public void trace_hulling_bot(int client)
{
//can crouch
Format(message, sizeof(message), "hull info:crouch");
char auth[50];
GetClientAuthId(client, AuthId_Engine, auth, sizeof(auth));
if (StrEqual("[U:1:120378081]", auth, false) || StrEqual("STEAM_0:1:60189040", auth, false))
if (is_autism_bot1(client))
{
send_socket_msg(message, strlen(message));
send_socket_msg(message, strlen(message), ports[0]);
}
if (StrEqual("[U:1:1036189204]", auth, false) || StrEqual("STEAM_0:0:518094602", auth, false))
if (is_autism_bot2(client))
{
send_socket_msg1(message, strlen(message));
send_socket_msg(message, strlen(message), ports[1]);
}
if (StrEqual("[U:1:408797742]", auth, false) || StrEqual("STEAM_0:0:204398871", auth, false))
if (is_autism_bot3(client))
{
send_socket_msg2(message, strlen(message));
send_socket_msg(message, strlen(message), ports[2]);
}
if (StrEqual("[U:1:1221121532]", auth, false) || StrEqual("STEAM_0:0:610560766", auth, false))
if (is_autism_bot4(client))
{
send_socket_msg3(message, strlen(message));
send_socket_msg(message, strlen(message), ports[3]);
}
return;
}
@ -596,23 +555,21 @@ public void trace_hulling_bot(int client)
{
//should not block jump level
Format(message, sizeof(message), "hull info:jump");
char auth[50];
GetClientAuthId(client, AuthId_Engine, auth, sizeof(auth));
if (StrEqual("[U:1:120378081]", auth, false) || StrEqual("STEAM_0:1:60189040", auth, false))
if (is_autism_bot1(client))
{
send_socket_msg(message, strlen(message));
send_socket_msg(message, strlen(message), ports[0]);
}
if (StrEqual("[U:1:1036189204]", auth, false) || StrEqual("STEAM_0:0:518094602", auth, false))
if (is_autism_bot2(client))
{
send_socket_msg1(message, strlen(message));
send_socket_msg(message, strlen(message), ports[1]);
}
if (StrEqual("[U:1:408797742]", auth, false) || StrEqual("STEAM_0:0:204398871", auth, false))
if (is_autism_bot3(client))
{
send_socket_msg2(message, strlen(message));
send_socket_msg(message, strlen(message), ports[2]);
}
if (StrEqual("[U:1:1221121532]", auth, false) || StrEqual("STEAM_0:0:610560766", auth, false))
if (is_autism_bot4(client))
{
send_socket_msg3(message, strlen(message));
send_socket_msg(message, strlen(message), ports[3]);
}
return;
}
@ -636,23 +593,21 @@ public void trace_hulling_bot(int client)
if (!(TR_DidHit()))
{
Format(message, sizeof(message), "hull info:jump");
char auth[50];
GetClientAuthId(client, AuthId_Engine, auth, sizeof(auth));
if (StrEqual("[U:1:120378081]", auth, false) || StrEqual("STEAM_0:1:60189040", auth, false))
if (is_autism_bot1(client))
{
send_socket_msg(message, strlen(message));
send_socket_msg(message, strlen(message), ports[0]);
}
if (StrEqual("[U:1:1036189204]", auth, false) || StrEqual("STEAM_0:0:518094602", auth, false))
if (is_autism_bot2(client))
{
send_socket_msg1(message, strlen(message));
send_socket_msg(message, strlen(message), ports[1]);
}
if (StrEqual("[U:1:408797742]", auth, false) || StrEqual("STEAM_0:0:204398871", auth, false))
if (is_autism_bot3(client))
{
send_socket_msg2(message, strlen(message));
send_socket_msg(message, strlen(message), ports[2]);
}
if (StrEqual("[U:1:1221121532]", auth, false) || StrEqual("STEAM_0:0:610560766", auth, false))
if (is_autism_bot4(client))
{
send_socket_msg3(message, strlen(message));
send_socket_msg(message, strlen(message), ports[3]);
}
return;
}
@ -660,23 +615,21 @@ public void trace_hulling_bot(int client)
if (!(TR_DidHit()))
{
Format(message, sizeof(message), "hull info:jump");
char auth[50];
GetClientAuthId(client, AuthId_Engine, auth, sizeof(auth));
if (StrEqual("[U:1:120378081]", auth, false) || StrEqual("STEAM_0:1:60189040", auth, false))
if (is_autism_bot1(client))
{
send_socket_msg(message, strlen(message));
send_socket_msg(message, strlen(message), ports[0]);
}
if (StrEqual("[U:1:1036189204]", auth, false) || StrEqual("STEAM_0:0:518094602", auth, false))
if (is_autism_bot2(client))
{
send_socket_msg1(message, strlen(message));
send_socket_msg(message, strlen(message), ports[1]);
}
if (StrEqual("[U:1:408797742]", auth, false) || StrEqual("STEAM_0:0:204398871", auth, false))
if (is_autism_bot3(client))
{
send_socket_msg2(message, strlen(message));
send_socket_msg(message, strlen(message), ports[2]);
}
if (StrEqual("[U:1:1221121532]", auth, false) || StrEqual("STEAM_0:0:610560766", auth, false))
if (is_autism_bot4(client))
{
send_socket_msg3(message, strlen(message));
send_socket_msg(message, strlen(message), ports[3]);
}
return;
}
@ -701,65 +654,6 @@ public void trace_hulling_bot(int client)
}
}
//TODO implement surfing again but differently
//check_bot_surfing();
/*
public void check_bot_surfing()
{
float vPos[3];
float vMins[3];
float vMaxs[3];
GetEntPropVector(, Prop_Data, "m_vecOrigin", vPos);
GetEntPropVector(, Prop_Send, "m_vecMins", vMins);
GetEntPropVector(, Prop_Send, "m_vecMaxs", vMaxs);
float vEndPos[3];
vEndPos[0] = vPos[0];
vEndPos[1] = vPos[1];
vEndPos[2] = vPos[2] - FindConVar("sv_maxvelocity").FloatValue;
TR_TraceHullFilter(vPos, vEndPos, vMins, vMaxs, MASK_ALL, TraceRayDontHitSelf, );
if (TR_DidHit())
{
//< 0.7 = surf ramp
float surf_ramp = 0.6;
char keyinput[generic_length * 3];
float vPlane[3];
TR_GetPlaneNormal(INVALID_HANDLE, vPlane);
if (0.0 < vPlane[2] < surf_ramp)
{
vPlane[0] *= 100;
vPlane[1] *= 100;
vPlane[2] *= 100;
if (!surf_cooldown)
{
surf_cooldown = true;
TeleportEntity(, NULL_VECTOR, vPlane, NULL_VECTOR);
Format(keyinput, sizeof(keyinput), "surfing: %f %f %f", vPlane[0], vPlane[1], vPlane[2]);
char auth[50];
GetClientAuthId(client, AuthId_Engine, auth, sizeof(auth));
if (StrEqual("[U:1:120378081]", auth, false) || StrEqual("STEAM_0:1:60189040", auth, false))
{
send_socket_msg(keyinput, strlen(keyinput));
}
if (StrEqual("[U:1:1036189204]", auth, false) || StrEqual("STEAM_0:0:518094602", auth, false))
{
send_socket_msg1(keyinput, strlen(keyinput));
}
if (StrEqual("[U:1:408797742]", auth, false) || StrEqual("STEAM_0:0:204398871", auth, false))
{
send_socket_msg2(keyinput, strlen(keyinput));
}
if (StrEqual("[U:1:1221121532]", auth, false) || StrEqual("STEAM_0:0:610560766", auth, false))
{
send_socket_msg3(keyinput, strlen(keyinput));
}
CreateTimer(0.5, surf_cooldown_timer);
}
}
}
}
*/
public Action surf_cooldown_timer(Handle timer, any data)
{
surf_cooldown = false;
@ -833,11 +727,11 @@ public int GetClosestClient_option1(int targeteam, int client)
float pos[3];
GetEntPropVector(i, Prop_Send, "m_vecOrigin", pos);
float dist_target = get_power_distance(client, pos);
if (GetClientTeam(client) == 2 && i != targeteam && (admins[i] || vips[i]))
if (GetClientTeam(client) == 2 && (admins[i] || vips[i]))
{
continue;
}
if ((admins[i] || vips[i] || i == targethuman[client]) && client == targeteam)
if ((admins[i] || vips[i] || i == targethuman[client]) && GetClientTeam(client) == targeteam)
dist_target /= 5;
if (nearestdistance < 0 || dist_target < nearestdistance)
{
@ -857,31 +751,27 @@ public float get_power_distance(int target_player, float [3]pos)
public void OnClientPostAdminCheck(int client)
{
//STEAM_0:1:34783317
//STEAM_0:1:60189040
//[U:1:120378081]
//[U:1:69566635]
target_human_afk_counter[client] = 0;
bot_avoid_edge[client] = -1;
char auth[50];
GetClientAuthId(client, AuthId_Engine, auth, sizeof(auth));
char msg[generic_length];
Format(msg, sizeof(msg), "autismo connected");
if (StrEqual("[U:1:120378081]", auth, false) || StrEqual("STEAM_0:1:60189040", auth, false))
if (is_autism_bot1(client))
{
send_socket_msg(msg, strlen(msg));
send_socket_msg(msg, strlen(msg), ports[0]);
}
if (StrEqual("[U:1:1036189204]", auth, false) || StrEqual("STEAM_0:0:518094602", auth, false))
if (is_autism_bot2(client))
{
send_socket_msg1(msg, strlen(msg));
send_socket_msg(msg, strlen(msg), ports[1]);
}
if (StrEqual("[U:1:408797742]", auth, false) || StrEqual("STEAM_0:0:204398871", auth, false))
if (is_autism_bot3(client))
{
send_socket_msg2(msg, strlen(msg));
send_socket_msg(msg, strlen(msg), ports[2]);
}
if (StrEqual("[U:1:1221121532]", auth, false) || StrEqual("STEAM_0:0:610560766", auth, false))
if (is_autism_bot4(client))
{
send_socket_msg3(msg, strlen(msg));
send_socket_msg(msg, strlen(msg), ports[3]);
}
if (CheckCommandAccess(client, "sm_kick", ADMFLAG_KICK))
admins[client] = true;