2020-01-23 23:15:26 +01:00
|
|
|
#pragma semicolon 1
|
|
|
|
|
|
|
|
#define DEBUG
|
|
|
|
|
|
|
|
#define PLUGIN_AUTHOR "jenz"
|
2021-07-27 22:55:12 +02:00
|
|
|
#define PLUGIN_VERSION "1.6"
|
2020-04-22 00:17:28 +02:00
|
|
|
#define generic_length 256
|
2020-01-23 23:15:26 +01:00
|
|
|
|
|
|
|
#include <sourcemod>
|
|
|
|
#include <sdktools>
|
2020-07-30 18:01:57 +02:00
|
|
|
#include <sdkhooks>
|
|
|
|
#include <outputinfo>
|
2020-06-26 00:11:22 +02:00
|
|
|
#include <socket>
|
2020-01-23 23:15:26 +01:00
|
|
|
|
2020-06-26 00:11:22 +02:00
|
|
|
//#pragma newdecls required
|
2021-04-20 17:08:38 +02:00
|
|
|
int target_human_afk_counter[MAXPLAYERS + 1];
|
2021-04-05 23:01:54 +02:00
|
|
|
int targethuman[MAXPLAYERS + 1];
|
|
|
|
int target_enemy[MAXPLAYERS + 1];
|
|
|
|
int buttons_old[MAXPLAYERS + 1];
|
|
|
|
int flags_old[MAXPLAYERS + 1];
|
2021-07-27 22:55:12 +02:00
|
|
|
int ports[4] = {48479, 48482, 48476, 48481};
|
2020-08-30 20:00:02 +02:00
|
|
|
bool surf_cooldown = false;
|
2021-04-27 00:55:50 +02:00
|
|
|
int bot_avoid_edge[MAXPLAYERS + 1];
|
2020-07-24 00:25:03 +02:00
|
|
|
float client_old_coords[MAXPLAYERS + 1][3];
|
2021-04-05 23:01:54 +02:00
|
|
|
float targethuman_teleported[MAXPLAYERS + 1][3];
|
2020-09-27 13:57:10 +02:00
|
|
|
bool chat_cooldown = false;
|
2020-01-23 23:15:26 +01:00
|
|
|
|
2020-07-15 02:14:00 +02:00
|
|
|
//admins & vips
|
2020-07-21 01:03:06 +02:00
|
|
|
bool admins[MAXPLAYERS + 1];
|
|
|
|
bool vips[MAXPLAYERS + 1];
|
2021-08-06 19:16:01 +02:00
|
|
|
bool rtv;
|
2020-07-15 02:14:00 +02:00
|
|
|
|
2020-06-26 00:11:22 +02:00
|
|
|
//socket for bot input
|
|
|
|
Handle global_socket;
|
|
|
|
|
2020-01-23 23:15:26 +01:00
|
|
|
public Plugin myinfo =
|
|
|
|
{
|
|
|
|
name = "coordinates for the bot",
|
|
|
|
author = PLUGIN_AUTHOR,
|
|
|
|
description = "hello ",
|
|
|
|
version = PLUGIN_VERSION,
|
|
|
|
url = ""
|
|
|
|
};
|
|
|
|
|
2020-02-28 22:00:22 +01:00
|
|
|
public void OnPluginStart()
|
2020-01-23 23:15:26 +01:00
|
|
|
{
|
2021-08-06 19:16:01 +02:00
|
|
|
rtv = false;
|
2021-03-27 00:57:40 +01:00
|
|
|
for (int i = 1; i <= MaxClients; i++)
|
|
|
|
if (IsValidClient(i))
|
2021-04-05 23:01:54 +02:00
|
|
|
{
|
|
|
|
targethuman[i] = 0;
|
|
|
|
target_enemy[i] = 0;
|
|
|
|
reset_target_human_tp_coord(i);
|
|
|
|
}
|
2020-05-05 23:52:01 +02:00
|
|
|
//talking
|
|
|
|
RegConsoleCmd("sm_autism", cmd_talk, "talking to the bot through java application");
|
2021-08-06 19:16:01 +02:00
|
|
|
RegConsoleCmd("sm_rtv", cmd_botrtv, "making bots rtv");
|
2020-05-05 23:52:01 +02:00
|
|
|
|
2020-02-28 22:00:22 +01:00
|
|
|
//hooks
|
|
|
|
HookEvent("round_start", Event_RoundStart, EventHookMode_PostNoCopy);
|
2020-07-30 18:01:57 +02:00
|
|
|
HookEntityOutput("trigger_multiple", "OnTrigger", Trigger_Multiple);
|
|
|
|
HookEntityOutput("trigger_multiple", "OnStartTouch", Trigger_Multiple);
|
|
|
|
HookEntityOutput("trigger_teleport", "OnTrigger", trigger_teleport);
|
|
|
|
HookEntityOutput("trigger_teleport", "OnStartTouch", trigger_teleport);
|
2020-04-22 00:17:28 +02:00
|
|
|
|
2020-09-23 11:48:11 +02:00
|
|
|
//UDP connection
|
|
|
|
connect_socket();
|
2020-09-27 13:57:10 +02:00
|
|
|
chat_cooldown = false;
|
2020-01-23 23:15:26 +01:00
|
|
|
}
|
|
|
|
|
2021-04-05 23:01:54 +02:00
|
|
|
public void reset_target_human_tp_coord(int client)
|
2020-07-30 18:01:57 +02:00
|
|
|
{
|
2021-04-05 23:01:54 +02:00
|
|
|
targethuman_teleported[client][0] = 0.0;
|
|
|
|
targethuman_teleported[client][1] = 0.0;
|
|
|
|
targethuman_teleported[client][2] = 0.0;
|
2020-07-30 18:01:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public void trigger_teleport(const char[] output, int entity_index, int client, float delay)
|
|
|
|
{
|
|
|
|
if (IsValidEdict(entity_index))
|
2021-04-05 23:01:54 +02:00
|
|
|
for (int i = 1; i <= MaxClients; i++)
|
|
|
|
if (IsValidClient(i))
|
|
|
|
{
|
|
|
|
if (targethuman[i] == client)
|
|
|
|
{
|
|
|
|
GetEntPropVector(client, Prop_Send, "m_vecOrigin", targethuman_teleported[i]);
|
|
|
|
CreateTimer(6.0, reset_target_tp, client);
|
|
|
|
}
|
2021-04-09 21:17:30 +02:00
|
|
|
else if (is_bot_player(i) && i == client)
|
2021-04-05 23:01:54 +02:00
|
|
|
CreateTimer(0.1, reset_target_tp, client);
|
2020-08-01 01:15:39 +02:00
|
|
|
}
|
2020-07-30 18:01:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public void Trigger_Multiple(const char[] output, int entity_index, int client, float delay)
|
|
|
|
{
|
2021-04-05 23:01:54 +02:00
|
|
|
if (IsValidEdict(entity_index) && origin_command_check(entity_index))
|
2020-07-30 18:01:57 +02:00
|
|
|
{
|
2021-04-05 23:01:54 +02:00
|
|
|
for (int i = 1; i <= MaxClients; i++)
|
|
|
|
if (IsValidClient(i))
|
|
|
|
{
|
|
|
|
if (targethuman[i] == client)
|
|
|
|
{
|
|
|
|
GetEntPropVector(client, Prop_Send, "m_vecOrigin", targethuman_teleported[i]);
|
|
|
|
CreateTimer(6.0, reset_target_tp, client);
|
|
|
|
}
|
2021-04-09 21:17:30 +02:00
|
|
|
else if (is_bot_player(i) && i == client)
|
2021-04-05 23:01:54 +02:00
|
|
|
CreateTimer(0.1, reset_target_tp, client);
|
|
|
|
}
|
2020-07-30 18:01:57 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public bool origin_command_check(int entity_index)
|
|
|
|
{
|
|
|
|
int count_trigger = GetOutputCount(entity_index, "m_OnTrigger");
|
|
|
|
int count_starttouch = GetOutputCount(entity_index, "m_OnStartTouch");
|
|
|
|
for (int i = 0; i < count_trigger; i++)
|
|
|
|
{
|
|
|
|
char buffer[generic_length];
|
|
|
|
GetOutputParameter(entity_index, "m_OnTrigger", i, buffer, sizeof(buffer));
|
|
|
|
if (StrContains(buffer, "origin", true) != -1)
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
for (int i = 0; i < count_starttouch; i++)
|
|
|
|
{
|
|
|
|
char buffer[generic_length];
|
|
|
|
GetOutputParameter(entity_index, "m_OnStartTouch", i, buffer, sizeof(buffer));
|
|
|
|
if (StrContains(buffer, "origin", true) != -1)
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2021-04-05 23:01:54 +02:00
|
|
|
public Action reset_target_tp(Handle timer, int client)
|
2020-07-30 18:01:57 +02:00
|
|
|
{
|
2021-04-05 23:01:54 +02:00
|
|
|
reset_target_human_tp_coord(client);
|
2020-07-30 18:01:57 +02:00
|
|
|
return Plugin_Continue;
|
|
|
|
}
|
|
|
|
|
2021-03-27 00:57:40 +01:00
|
|
|
public bool distance_check(int client)
|
2020-07-30 18:01:57 +02:00
|
|
|
{
|
2021-04-05 23:01:54 +02:00
|
|
|
float dist_target = get_power_distance(client, targethuman_teleported[client]);
|
2020-09-27 03:16:52 +02:00
|
|
|
float min_required_distance = 50000.0;
|
2020-07-30 18:01:57 +02:00
|
|
|
if (dist_target > min_required_distance)
|
|
|
|
return false;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2021-07-27 22:55:12 +02:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2021-08-06 19:16:01 +02:00
|
|
|
public Action cmd_botrtv(int client, int args)
|
|
|
|
{
|
|
|
|
if ((vips[client] || admins[client]) && !rtv)
|
|
|
|
{
|
|
|
|
bool bot_found = false;
|
|
|
|
for (int i = 1; i <= MaxClients; i++)
|
|
|
|
{
|
|
|
|
if (IsValidClient(i) && !IsFakeClient(i) && is_bot_player(i))
|
|
|
|
{
|
|
|
|
FakeClientCommand(i, "sm_say rtv");
|
|
|
|
bot_found = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (bot_found)
|
|
|
|
{
|
|
|
|
rtv = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return Plugin_Handled;
|
|
|
|
}
|
|
|
|
|
2020-05-05 23:52:01 +02:00
|
|
|
public Action cmd_talk(int client, int args)
|
|
|
|
{
|
|
|
|
char info[generic_length];
|
|
|
|
GetCmdArgString(info, sizeof(info));
|
2020-05-06 01:24:15 +02:00
|
|
|
if (strlen(info) == 0)
|
|
|
|
{
|
2020-06-09 23:34:49 +02:00
|
|
|
PrintToChat(client, "Add a message to the command if autism bot is ingame and running on discord");
|
2020-05-06 01:24:15 +02:00
|
|
|
return Plugin_Handled;
|
|
|
|
}
|
2021-08-06 19:16:01 +02:00
|
|
|
if (is_bot_player(client))
|
|
|
|
{
|
|
|
|
return Plugin_Handled;
|
|
|
|
}
|
2020-09-27 13:57:10 +02:00
|
|
|
if (chat_cooldown)
|
|
|
|
{
|
|
|
|
PrintToChat(client, "spamming bot too much, applying cooldown");
|
|
|
|
return Plugin_Handled;
|
|
|
|
}
|
2021-04-05 23:01:54 +02:00
|
|
|
bool bot_found = false;
|
2021-03-27 00:57:40 +01:00
|
|
|
for (int i = 1; i <= MaxClients; i++)
|
|
|
|
if (IsValidClient(i) && !IsFakeClient(i))
|
|
|
|
{
|
2021-07-27 22:55:12 +02:00
|
|
|
if (is_autism_bot1(i))
|
2021-04-05 23:01:54 +02:00
|
|
|
{
|
2021-07-27 22:55:12 +02:00
|
|
|
cmd_talk_help(ports[0], client, info);
|
2021-04-05 23:01:54 +02:00
|
|
|
bot_found = true;
|
2021-03-27 00:57:40 +01:00
|
|
|
}
|
2021-07-27 22:55:12 +02:00
|
|
|
if (is_autism_bot2(i))
|
2021-04-05 23:01:54 +02:00
|
|
|
{
|
2021-07-27 22:55:12 +02:00
|
|
|
cmd_talk_help(ports[1], client, info);
|
2021-04-05 23:01:54 +02:00
|
|
|
bot_found = true;
|
|
|
|
}
|
2021-07-27 22:55:12 +02:00
|
|
|
if (is_autism_bot3(i))
|
2021-06-18 16:11:42 +02:00
|
|
|
{
|
2021-07-27 22:55:12 +02:00
|
|
|
cmd_talk_help(ports[2], client, info);
|
2021-06-18 16:11:42 +02:00
|
|
|
bot_found = true;
|
|
|
|
}
|
2021-07-27 22:55:12 +02:00
|
|
|
if (is_autism_bot4(i))
|
2021-06-18 16:11:42 +02:00
|
|
|
{
|
2021-07-27 22:55:12 +02:00
|
|
|
cmd_talk_help(ports[3], client, info);
|
2021-06-18 16:11:42 +02:00
|
|
|
bot_found = true;
|
|
|
|
}
|
2021-04-05 23:01:54 +02:00
|
|
|
}
|
|
|
|
if (!bot_found)
|
|
|
|
PrintToChat(client, "bot not connected to server");
|
2020-05-05 23:52:01 +02:00
|
|
|
return Plugin_Handled;
|
|
|
|
}
|
|
|
|
|
2020-09-27 13:57:10 +02:00
|
|
|
public Action bot_chat_cooldown(Handle timer, any data)
|
|
|
|
{
|
|
|
|
chat_cooldown = false;
|
|
|
|
return Plugin_Continue;
|
|
|
|
}
|
|
|
|
|
2020-02-28 22:00:22 +01:00
|
|
|
public void Event_RoundStart(Handle event, const char[] name, bool dontBroadcast)
|
2020-01-23 23:15:26 +01:00
|
|
|
{
|
2021-04-05 23:01:54 +02:00
|
|
|
for (int i = 1; i <= MaxClients; i++)
|
|
|
|
if (IsValidClient(i) && !IsFakeClient(i))
|
|
|
|
{
|
|
|
|
targethuman[i] = 0;
|
|
|
|
target_enemy[i] = 0;
|
|
|
|
reset_target_human_tp_coord(i);
|
|
|
|
}
|
2020-01-23 23:15:26 +01:00
|
|
|
}
|
|
|
|
|
2020-02-28 22:00:22 +01:00
|
|
|
public void OnMapStart()
|
2020-02-09 00:26:05 +01:00
|
|
|
{
|
2021-08-06 19:16:01 +02:00
|
|
|
rtv = true;
|
2020-08-30 20:00:02 +02:00
|
|
|
//0.2 too spammmy, 1.5 too slow
|
2020-09-27 13:57:10 +02:00
|
|
|
chat_cooldown = false;
|
2020-10-02 22:42:53 +02:00
|
|
|
CreateTimer(0.30, recursive_pressing, INVALID_HANDLE, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE);
|
2020-09-27 03:16:52 +02:00
|
|
|
CreateTimer(15.0, bot_check_connect, INVALID_HANDLE, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE);
|
2021-08-06 19:16:01 +02:00
|
|
|
CreateTimer(600.0, bot_allow_rtv);
|
2020-07-24 00:25:03 +02:00
|
|
|
}
|
|
|
|
|
2021-07-27 22:55:12 +02:00
|
|
|
public void send_socket_msg(char[] query_msg, int len, int port)
|
2020-06-09 23:34:49 +02:00
|
|
|
{
|
2021-07-29 00:59:36 +02:00
|
|
|
//LogMessage("query_msg: %s port: %i", query_msg, port);
|
2020-06-26 00:11:22 +02:00
|
|
|
if (global_socket != INVALID_HANDLE && SocketIsConnected(global_socket))
|
2021-07-27 22:55:12 +02:00
|
|
|
SocketSendTo(global_socket, query_msg, len, "127.0.0.1", port); //udp
|
2021-03-27 00:57:40 +01:00
|
|
|
}
|
|
|
|
|
2021-08-06 19:16:01 +02:00
|
|
|
public Action bot_allow_rtv(Handle timer, any data)
|
|
|
|
{
|
|
|
|
rtv = false;
|
|
|
|
return Plugin_Continue;
|
|
|
|
}
|
|
|
|
|
2020-06-26 00:11:22 +02:00
|
|
|
public Action bot_check_connect(Handle timer, any data)
|
|
|
|
{
|
2021-03-27 00:57:40 +01:00
|
|
|
int client_count = GetClientCount(false);
|
2021-07-27 22:55:12 +02:00
|
|
|
char msg[generic_length];
|
|
|
|
//PrintToChatAll("sending UDP message...");
|
|
|
|
Format(msg, sizeof(msg), "connect to ze");
|
2021-07-29 00:59:36 +02:00
|
|
|
bool found_bot1 = false;
|
|
|
|
bool found_bot2 = false;
|
|
|
|
bool found_bot3 = false;
|
|
|
|
bool found_bot4 = false;
|
2021-03-27 00:57:40 +01:00
|
|
|
for (int i = 1; i <= MaxClients; i++)
|
|
|
|
if (IsValidClient(i) && !IsFakeClient(i))
|
|
|
|
{
|
2021-07-29 13:39:19 +02:00
|
|
|
if (client_count > 50)
|
2021-03-27 00:57:40 +01:00
|
|
|
{
|
2021-07-29 13:39:19 +02:00
|
|
|
found_bot1 = true;
|
|
|
|
found_bot2 = true;
|
|
|
|
found_bot3 = true;
|
|
|
|
found_bot4 = true;
|
|
|
|
if (client_count > 60)
|
2021-03-27 00:57:40 +01:00
|
|
|
{
|
2021-07-29 13:39:19 +02:00
|
|
|
if (is_bot_player(i))
|
|
|
|
{
|
|
|
|
KickClient(i, "server full you need to leave");
|
|
|
|
}
|
2021-03-27 00:57:40 +01:00
|
|
|
}
|
|
|
|
}
|
2021-07-29 13:20:05 +02:00
|
|
|
else
|
2021-04-05 23:01:54 +02:00
|
|
|
{
|
2021-07-27 22:55:12 +02:00
|
|
|
if (is_autism_bot1(i))
|
2021-06-18 16:11:42 +02:00
|
|
|
{
|
2021-07-29 00:59:36 +02:00
|
|
|
found_bot1 = true;
|
2021-06-18 16:11:42 +02:00
|
|
|
}
|
2021-07-27 22:55:12 +02:00
|
|
|
if (is_autism_bot2(i))
|
2021-06-18 16:11:42 +02:00
|
|
|
{
|
2021-07-29 00:59:36 +02:00
|
|
|
found_bot2 = true;
|
2021-06-18 16:11:42 +02:00
|
|
|
}
|
2021-07-27 22:55:12 +02:00
|
|
|
if (is_autism_bot3(i))
|
2021-06-18 16:11:42 +02:00
|
|
|
{
|
2021-07-29 00:59:36 +02:00
|
|
|
found_bot3 = true;
|
2021-06-18 16:11:42 +02:00
|
|
|
}
|
2021-07-27 22:55:12 +02:00
|
|
|
if (is_autism_bot4(i))
|
2021-04-05 23:01:54 +02:00
|
|
|
{
|
2021-07-29 00:59:36 +02:00
|
|
|
found_bot4 = true;
|
2021-04-05 23:01:54 +02:00
|
|
|
}
|
|
|
|
}
|
2021-07-29 00:59:36 +02:00
|
|
|
}
|
|
|
|
if (!found_bot1)
|
|
|
|
{
|
|
|
|
send_socket_msg(msg, strlen(msg), ports[0]);
|
|
|
|
}
|
|
|
|
if (!found_bot2)
|
|
|
|
{
|
|
|
|
send_socket_msg(msg, strlen(msg), ports[1]);
|
|
|
|
}
|
|
|
|
if (!found_bot3)
|
|
|
|
{
|
|
|
|
send_socket_msg(msg, strlen(msg), ports[2]);
|
|
|
|
}
|
|
|
|
if (!found_bot4)
|
|
|
|
{
|
|
|
|
send_socket_msg(msg, strlen(msg), ports[3]);
|
2021-04-05 23:01:54 +02:00
|
|
|
}
|
2020-07-30 18:01:57 +02:00
|
|
|
return Plugin_Continue;
|
|
|
|
}
|
|
|
|
|
2020-07-21 01:03:06 +02:00
|
|
|
public void OnPlayerRunCmdPost(int client, int buttons, int impulse, const float vel[3], const float angles[3], int weapon, int subtype,
|
|
|
|
int cmdnum, int tickcount, int seed, const int mouse[2])
|
|
|
|
{
|
|
|
|
if (!IsClientInGame(client)) return;
|
2021-04-09 21:17:30 +02:00
|
|
|
if (is_bot_player(client))
|
2020-07-27 19:14:50 +02:00
|
|
|
{
|
2021-04-06 00:37:47 +02:00
|
|
|
int flags = GetEntityFlags(client);
|
2021-07-29 13:20:05 +02:00
|
|
|
if (!(flags & FL_ONGROUND) && (flags_old[client] & FL_ONGROUND) && !(buttons_old[client] & IN_JUMP) && !(buttons & IN_JUMP) && (GetEntityMoveType(client) != MOVETYPE_LADDER) && GetEntProp(client, Prop_Data, "m_nWaterLevel") <= 2)
|
2020-07-27 19:14:50 +02:00
|
|
|
{
|
2021-04-06 00:37:47 +02:00
|
|
|
float Vel[3], feet_origin[3], ground_pos[3], downwards[3];
|
2021-04-20 22:22:15 +02:00
|
|
|
//TODO prevent bot from falling off edge if nothing infront
|
2021-07-29 13:54:27 +02:00
|
|
|
float velocity_addition_z_axis = 300.0; //300.0
|
2021-04-06 00:37:47 +02:00
|
|
|
GetEntPropVector(client, Prop_Data, "m_vecVelocity", Vel);
|
|
|
|
Vel[2] += velocity_addition_z_axis;
|
|
|
|
|
|
|
|
GetClientAbsOrigin(client, feet_origin);
|
|
|
|
downwards[0] = 90.0;
|
|
|
|
downwards[1] = 0.0;
|
|
|
|
downwards[2] = 0.0;
|
2021-05-02 02:15:50 +02:00
|
|
|
TR_TraceRayFilter(feet_origin, downwards, MASK_SOLID, RayType_Infinite, TraceRayDontHitSelf, client);
|
2021-04-06 00:37:47 +02:00
|
|
|
if (TR_DidHit())
|
2020-10-18 22:54:22 +02:00
|
|
|
{
|
2021-04-06 00:37:47 +02:00
|
|
|
TR_GetEndPosition(ground_pos);
|
|
|
|
feet_origin[2] -= 10.0;
|
|
|
|
float ground_distance = GetVectorDistance(feet_origin, ground_pos);
|
|
|
|
if (ground_distance > 80)
|
2020-10-18 22:54:22 +02:00
|
|
|
{
|
2021-04-06 00:37:47 +02:00
|
|
|
float angles_eye[3];
|
|
|
|
GetClientEyeAngles(client, angles_eye);
|
2021-04-25 01:01:05 +02:00
|
|
|
//feet_origin[2] += 10.0;
|
2021-05-02 02:15:50 +02:00
|
|
|
TR_TraceRayFilter(feet_origin, angles_eye, MASK_SOLID, RayType_Infinite, TraceRayDontHitSelf, client);
|
2021-04-25 01:01:05 +02:00
|
|
|
if (TR_DidHit())
|
|
|
|
{
|
|
|
|
TR_GetEndPosition(ground_pos);
|
|
|
|
ground_distance = GetVectorDistance(feet_origin, ground_pos);
|
|
|
|
float forward_distance = GetVectorDistance(feet_origin, ground_pos);
|
2021-04-29 11:55:38 +02:00
|
|
|
if (forward_distance > 280)
|
2021-04-25 01:01:05 +02:00
|
|
|
{
|
2021-04-26 20:25:40 +02:00
|
|
|
float ClientPos[3];
|
|
|
|
float Result[3];
|
|
|
|
GetClientEyePosition(client, ClientPos);
|
|
|
|
MakeVectorFromPoints(ClientPos, ground_pos, Result);
|
|
|
|
NegateVector(Result);
|
|
|
|
GetVectorAngles(Result, Result);
|
|
|
|
TeleportEntity(client, NULL_VECTOR, Result, NULL_VECTOR);
|
2021-04-27 00:55:50 +02:00
|
|
|
bot_avoid_edge[client] = 0;
|
2021-07-29 13:54:27 +02:00
|
|
|
ApplyBoost(client, 350.0);
|
2021-04-25 01:01:05 +02:00
|
|
|
}
|
|
|
|
}
|
2020-10-18 22:54:22 +02:00
|
|
|
}
|
|
|
|
}
|
2021-07-29 13:54:27 +02:00
|
|
|
//SetEntPropVector(client, Prop_Data, "m_vecBaseVelocity", Vel);
|
|
|
|
TeleportEntity(client, NULL_VECTOR, NULL_VECTOR, Vel);
|
2020-07-27 19:14:50 +02:00
|
|
|
}
|
2021-04-06 00:37:47 +02:00
|
|
|
buttons_old[client] = buttons;
|
|
|
|
flags_old[client] = flags;
|
2020-07-27 19:14:50 +02:00
|
|
|
}
|
2020-07-21 01:03:06 +02:00
|
|
|
}
|
|
|
|
|
2021-07-27 22:55:12 +02:00
|
|
|
//this was for turning around to prevent falling off edges
|
2021-05-02 00:52:51 +02:00
|
|
|
void ApplyBoost(int client, float amount){
|
|
|
|
float direction[3], vel[3];
|
|
|
|
GetEntPropVector(client, Prop_Data, "m_vecVelocity", vel);
|
2021-04-29 11:55:38 +02:00
|
|
|
NormalizeVector(vel, direction);
|
|
|
|
ScaleVector(direction, amount);
|
|
|
|
AddVectors(vel, direction, vel);
|
2021-07-29 13:54:27 +02:00
|
|
|
TeleportEntity(client, NULL_VECTOR, NULL_VECTOR, vel);
|
|
|
|
//SetEntPropVector(client, Prop_Data, "m_vecBaseVelocity", vel);
|
2021-04-29 11:55:38 +02:00
|
|
|
}
|
|
|
|
|
2021-04-09 21:17:30 +02:00
|
|
|
public bool is_bot_player(int client)
|
|
|
|
{
|
2021-07-27 22:55:12 +02:00
|
|
|
return is_autism_bot1(client) || is_autism_bot2(client) || is_autism_bot3(client) || is_autism_bot4(client);
|
2021-04-09 21:17:30 +02:00
|
|
|
}
|
|
|
|
|
2020-07-15 02:14:00 +02:00
|
|
|
public Action recursive_pressing(Handle timer, any data)
|
2020-06-26 00:11:22 +02:00
|
|
|
{
|
2021-06-29 01:12:10 +02:00
|
|
|
bool found_valid_ct = false;
|
2021-04-05 23:01:54 +02:00
|
|
|
for (int client = 1; client <= MaxClients; client++)
|
|
|
|
{
|
2021-04-06 00:37:47 +02:00
|
|
|
if (!IsValidClient(client)) continue;
|
2021-06-30 12:37:35 +02:00
|
|
|
if (!is_bot_player(client) && GetClientTeam(client) == 3 && IsPlayerAlive(client))
|
2021-06-29 01:12:10 +02:00
|
|
|
{
|
|
|
|
found_valid_ct = true;
|
|
|
|
}
|
2021-04-09 21:17:30 +02:00
|
|
|
if (is_bot_player(client))
|
2021-04-05 23:01:54 +02:00
|
|
|
{
|
2021-04-06 00:37:47 +02:00
|
|
|
if (GetClientTeam(client) == 1 || GetClientTeam(client) == 0)
|
|
|
|
{
|
|
|
|
ChangeClientTeam(client, 2);
|
|
|
|
continue;
|
|
|
|
}
|
2021-04-29 11:55:38 +02:00
|
|
|
if (bot_avoid_edge[client] >= 3)
|
2021-04-27 00:55:50 +02:00
|
|
|
bot_avoid_edge[client] = -1;
|
|
|
|
if (bot_avoid_edge[client] > -1)
|
|
|
|
{
|
|
|
|
bot_avoid_edge[client]++;
|
|
|
|
continue;
|
|
|
|
}
|
2021-04-06 00:37:47 +02:00
|
|
|
if (IsPlayerAlive(client))
|
|
|
|
{
|
|
|
|
int targeteam = 0;
|
|
|
|
if (GetClientTeam(client) != 3)
|
|
|
|
{
|
2021-07-29 13:20:05 +02:00
|
|
|
//2 = autismo is zm and should follow enemies sometimes
|
2021-04-06 00:37:47 +02:00
|
|
|
targeteam = 2;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
//3 = autismo is human and should follow closest moving ct
|
|
|
|
targeteam = 3;
|
|
|
|
}
|
|
|
|
if (targethuman_teleported[client][0] != 0.0)
|
|
|
|
{
|
|
|
|
float ClientPos[3];
|
|
|
|
float Result[3];
|
|
|
|
GetClientEyePosition(client, ClientPos);
|
|
|
|
MakeVectorFromPoints(ClientPos, targethuman_teleported[client], Result);
|
|
|
|
GetVectorAngles(Result, Result);
|
|
|
|
TeleportEntity(client, NULL_VECTOR, Result, NULL_VECTOR);
|
|
|
|
if (!distance_check(client))
|
|
|
|
reset_target_human_tp_coord(client);
|
2021-04-05 23:01:54 +02:00
|
|
|
continue;
|
2021-04-06 00:37:47 +02:00
|
|
|
}
|
2021-04-25 01:01:05 +02:00
|
|
|
//no target in water somehow
|
2021-07-29 13:20:05 +02:00
|
|
|
target_enemy[client] = GetClosestClient_option1(false, client);
|
|
|
|
targethuman[client] = GetClosestClient_option1(true, client);
|
2021-04-06 00:37:47 +02:00
|
|
|
float enemy_distance = -1.0;
|
|
|
|
float dist_target = -1.0;
|
|
|
|
float pos[3];
|
|
|
|
if (IsValidClient(targethuman[client]))
|
|
|
|
{
|
|
|
|
GetEntPropVector(targethuman[client], Prop_Send, "m_vecOrigin", pos);
|
|
|
|
dist_target = get_power_distance(client, pos);
|
|
|
|
}
|
|
|
|
if (IsValidClient(target_enemy[client]))
|
|
|
|
{
|
|
|
|
GetEntPropVector(target_enemy[client], Prop_Send, "m_vecOrigin", pos);
|
|
|
|
enemy_distance = get_power_distance(client, pos);
|
|
|
|
}
|
2021-07-05 18:27:58 +02:00
|
|
|
if ((750 > enemy_distance > 0 && enemy_distance > dist_target && targeteam == 2) || dist_target < 0 < enemy_distance)
|
2021-04-06 00:37:47 +02:00
|
|
|
{
|
2021-04-19 22:35:02 +02:00
|
|
|
/*
|
2021-04-06 00:37:47 +02:00
|
|
|
float feet_origin[3], enemy_feet_origin[3];
|
|
|
|
GetClientAbsOrigin(client, feet_origin);
|
|
|
|
GetClientAbsOrigin(target_enemy[client], enemy_feet_origin);
|
|
|
|
if (feet_origin[2] + 100 > enemy_feet_origin[2])
|
2021-04-19 22:35:02 +02:00
|
|
|
*/
|
|
|
|
face_call(target_enemy[client], client);
|
2021-04-06 00:37:47 +02:00
|
|
|
}
|
2021-04-20 01:24:04 +02:00
|
|
|
else if (IsValidClient(targethuman[client]))
|
2021-04-06 00:37:47 +02:00
|
|
|
face_call(targethuman[client], client);
|
2021-07-27 22:55:12 +02:00
|
|
|
//might prevent bot from jumping off ladders
|
2021-07-29 13:20:05 +02:00
|
|
|
if (GetEntProp(client, Prop_Data, "m_nWaterLevel") <= 2 && GetEntityMoveType(client) != MOVETYPE_LADDER)
|
2021-04-20 19:31:43 +02:00
|
|
|
trace_hulling_bot(client);
|
2021-04-06 00:37:47 +02:00
|
|
|
char message[generic_length * 7];
|
|
|
|
if (IsValidClient(targethuman[client]))
|
|
|
|
Format(message, sizeof(message), "dist_target: %f targethuman: %N enemy_distance: %f targeteam: %i", dist_target, targethuman[client], enemy_distance, targeteam);
|
|
|
|
else
|
|
|
|
Format(message, sizeof(message), "dist_target: %f targethuman: none enemy_distance: %f targeteam: %i", dist_target, enemy_distance, targeteam);
|
|
|
|
if (IsValidClient(target_enemy[client]))
|
|
|
|
Format(message, sizeof(message), "%s target_enemy: %N", message, target_enemy[client]);
|
|
|
|
else
|
|
|
|
Format(message, sizeof(message), "%s target_enemy: none", message);
|
2021-07-27 22:55:12 +02:00
|
|
|
|
|
|
|
if (is_autism_bot1(client))
|
2021-04-06 00:37:47 +02:00
|
|
|
{
|
2021-07-27 22:55:12 +02:00
|
|
|
send_socket_msg(message, strlen(message), ports[0]);
|
2021-04-06 00:37:47 +02:00
|
|
|
}
|
2021-07-27 22:55:12 +02:00
|
|
|
if (is_autism_bot2(client))
|
2021-04-06 00:37:47 +02:00
|
|
|
{
|
2021-07-27 22:55:12 +02:00
|
|
|
send_socket_msg(message, strlen(message), ports[1]);
|
2021-04-06 00:37:47 +02:00
|
|
|
}
|
2021-07-27 22:55:12 +02:00
|
|
|
if (is_autism_bot3(client))
|
2021-06-18 16:11:42 +02:00
|
|
|
{
|
2021-07-27 22:55:12 +02:00
|
|
|
send_socket_msg(message, strlen(message), ports[2]);
|
2021-06-18 16:11:42 +02:00
|
|
|
}
|
2021-07-27 22:55:12 +02:00
|
|
|
if (is_autism_bot4(client))
|
2021-06-18 16:11:42 +02:00
|
|
|
{
|
2021-07-27 22:55:12 +02:00
|
|
|
send_socket_msg(message, strlen(message), ports[3]);
|
2021-06-18 16:11:42 +02:00
|
|
|
}
|
2021-04-06 00:37:47 +02:00
|
|
|
}
|
2021-04-05 23:01:54 +02:00
|
|
|
}
|
|
|
|
}
|
2021-06-29 01:12:10 +02:00
|
|
|
if (!found_valid_ct)
|
|
|
|
{
|
|
|
|
for (int client = 1; client <= MaxClients; client++)
|
|
|
|
{
|
|
|
|
if (!IsValidClient(client)) continue;
|
|
|
|
if (is_bot_player(client) && GetClientTeam(client) == 3)
|
|
|
|
{
|
|
|
|
ForcePlayerSuicide(client);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-04-05 23:01:54 +02:00
|
|
|
return Plugin_Continue;
|
2020-01-23 23:15:26 +01:00
|
|
|
}
|
|
|
|
|
2020-10-02 19:05:48 +02:00
|
|
|
//https://developer.valvesoftware.com/wiki/Dimensions
|
2021-03-27 00:57:40 +01:00
|
|
|
public void trace_hulling_bot(int client)
|
2020-08-19 00:12:39 +02:00
|
|
|
{
|
2020-10-02 19:05:48 +02:00
|
|
|
char message[generic_length * 3];
|
2020-10-18 22:54:22 +02:00
|
|
|
float step_cap = 18.0;
|
|
|
|
float crouch_min = 48.0;
|
|
|
|
float stand_min = 63.0;
|
|
|
|
float feet_origin[3], mins[3], maxs[3], eye_position[3];
|
2020-10-02 19:05:48 +02:00
|
|
|
int BOUNDINGBOX_INFLATION_OFFSET = 3;
|
2021-04-05 23:01:54 +02:00
|
|
|
GetClientEyePosition(client, eye_position);
|
|
|
|
GetClientAbsOrigin(client, feet_origin);
|
|
|
|
GetClientMins(client, mins);
|
|
|
|
GetClientMaxs(client, maxs);
|
2020-10-02 19:05:48 +02:00
|
|
|
//increasing boxes sizes
|
|
|
|
for (int ij = 0; ij < sizeof(mins) - 1; ij++)
|
|
|
|
{
|
|
|
|
mins[ij] -= BOUNDINGBOX_INFLATION_OFFSET;
|
|
|
|
maxs[ij] += BOUNDINGBOX_INFLATION_OFFSET;
|
|
|
|
}
|
2020-10-03 02:28:36 +02:00
|
|
|
//acts as full body check
|
|
|
|
feet_origin[2] += BOUNDINGBOX_INFLATION_OFFSET;
|
2020-10-24 23:07:38 +02:00
|
|
|
TR_TraceHullFilter(feet_origin, feet_origin, mins, maxs, MASK_ALL, TraceRayDontHitSelf);
|
2020-09-27 03:16:52 +02:00
|
|
|
if (TR_DidHit())
|
2020-08-24 01:04:59 +02:00
|
|
|
{
|
2020-10-18 22:54:22 +02:00
|
|
|
//check 0.0 to 48.0 units starting from feet
|
|
|
|
feet_origin[2] -= BOUNDINGBOX_INFLATION_OFFSET;
|
2020-10-03 02:28:36 +02:00
|
|
|
mins[2] = 0.0;
|
2020-10-18 22:54:22 +02:00
|
|
|
maxs[2] = crouch_min;
|
|
|
|
TR_TraceHullFilter(feet_origin, feet_origin, mins, maxs, MASK_ALL, TraceRayDontHitSelf);
|
2020-10-02 19:05:48 +02:00
|
|
|
if (!(TR_DidHit()))
|
|
|
|
{
|
2020-10-18 22:54:22 +02:00
|
|
|
//can crouch
|
2020-10-02 19:05:48 +02:00
|
|
|
Format(message, sizeof(message), "hull info:crouch");
|
2021-07-27 22:55:12 +02:00
|
|
|
if (is_autism_bot1(client))
|
2021-04-05 23:01:54 +02:00
|
|
|
{
|
2021-07-27 22:55:12 +02:00
|
|
|
send_socket_msg(message, strlen(message), ports[0]);
|
2021-04-05 23:01:54 +02:00
|
|
|
}
|
2021-07-27 22:55:12 +02:00
|
|
|
if (is_autism_bot2(client))
|
2021-04-05 23:01:54 +02:00
|
|
|
{
|
2021-07-27 22:55:12 +02:00
|
|
|
send_socket_msg(message, strlen(message), ports[1]);
|
2021-04-05 23:01:54 +02:00
|
|
|
}
|
2021-07-27 22:55:12 +02:00
|
|
|
if (is_autism_bot3(client))
|
2021-06-18 16:11:42 +02:00
|
|
|
{
|
2021-07-27 22:55:12 +02:00
|
|
|
send_socket_msg(message, strlen(message), ports[2]);
|
2021-06-18 16:11:42 +02:00
|
|
|
}
|
2021-07-27 22:55:12 +02:00
|
|
|
if (is_autism_bot4(client))
|
2021-06-18 16:11:42 +02:00
|
|
|
{
|
2021-07-27 22:55:12 +02:00
|
|
|
send_socket_msg(message, strlen(message), ports[3]);
|
2021-06-18 16:11:42 +02:00
|
|
|
}
|
2020-10-18 22:54:22 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
//something blocks floor crouch
|
|
|
|
eye_position[2] += 5.0;
|
|
|
|
TR_TraceHullFilter(eye_position, eye_position, mins, maxs, MASK_ALL, TraceRayDontHitSelf);
|
|
|
|
if (!(TR_DidHit()))
|
|
|
|
{
|
|
|
|
//should not block jump level
|
|
|
|
Format(message, sizeof(message), "hull info:jump");
|
2021-07-27 22:55:12 +02:00
|
|
|
if (is_autism_bot1(client))
|
2021-04-05 23:01:54 +02:00
|
|
|
{
|
2021-07-27 22:55:12 +02:00
|
|
|
send_socket_msg(message, strlen(message), ports[0]);
|
2021-04-05 23:01:54 +02:00
|
|
|
}
|
2021-07-27 22:55:12 +02:00
|
|
|
if (is_autism_bot2(client))
|
2021-04-05 23:01:54 +02:00
|
|
|
{
|
2021-07-27 22:55:12 +02:00
|
|
|
send_socket_msg(message, strlen(message), ports[1]);
|
2021-04-05 23:01:54 +02:00
|
|
|
}
|
2021-07-27 22:55:12 +02:00
|
|
|
if (is_autism_bot3(client))
|
2021-06-18 16:11:42 +02:00
|
|
|
{
|
2021-07-27 22:55:12 +02:00
|
|
|
send_socket_msg(message, strlen(message), ports[2]);
|
2021-06-18 16:11:42 +02:00
|
|
|
}
|
2021-07-27 22:55:12 +02:00
|
|
|
if (is_autism_bot4(client))
|
2021-06-18 16:11:42 +02:00
|
|
|
{
|
2021-07-27 22:55:12 +02:00
|
|
|
send_socket_msg(message, strlen(message), ports[3]);
|
2021-06-18 16:11:42 +02:00
|
|
|
}
|
2020-10-18 22:54:22 +02:00
|
|
|
return;
|
2020-10-02 19:05:48 +02:00
|
|
|
}
|
|
|
|
else
|
2020-08-21 02:30:29 +02:00
|
|
|
{
|
2020-10-18 22:54:22 +02:00
|
|
|
//still potentially crouch hole in wall or one side jumpable
|
|
|
|
mins[2] = step_cap;
|
|
|
|
float iterator = step_cap;
|
|
|
|
while (iterator < stand_min)
|
2020-10-02 19:05:48 +02:00
|
|
|
{
|
2020-10-18 22:54:22 +02:00
|
|
|
maxs[2] = iterator;
|
|
|
|
iterator += step_cap;
|
|
|
|
for (int jj = 0; jj < 2; jj++)
|
|
|
|
for (int ij = 0; ij < 2; ij++)
|
|
|
|
{
|
|
|
|
if (jj == 0)
|
|
|
|
mins[ij] += BOUNDINGBOX_INFLATION_OFFSET;
|
|
|
|
else
|
|
|
|
maxs[ij] -= BOUNDINGBOX_INFLATION_OFFSET;
|
|
|
|
TR_TraceHullFilter(feet_origin, feet_origin, mins, maxs, MASK_ALL, TraceRayDontHitSelf);
|
|
|
|
if (!(TR_DidHit()))
|
|
|
|
{
|
|
|
|
Format(message, sizeof(message), "hull info:jump");
|
2021-07-27 22:55:12 +02:00
|
|
|
if (is_autism_bot1(client))
|
2021-04-05 23:01:54 +02:00
|
|
|
{
|
2021-07-27 22:55:12 +02:00
|
|
|
send_socket_msg(message, strlen(message), ports[0]);
|
2021-04-05 23:01:54 +02:00
|
|
|
}
|
2021-07-27 22:55:12 +02:00
|
|
|
if (is_autism_bot2(client))
|
2021-04-05 23:01:54 +02:00
|
|
|
{
|
2021-07-27 22:55:12 +02:00
|
|
|
send_socket_msg(message, strlen(message), ports[1]);
|
2021-04-05 23:01:54 +02:00
|
|
|
}
|
2021-07-27 22:55:12 +02:00
|
|
|
if (is_autism_bot3(client))
|
2021-06-18 16:11:42 +02:00
|
|
|
{
|
2021-07-27 22:55:12 +02:00
|
|
|
send_socket_msg(message, strlen(message), ports[2]);
|
2021-06-18 16:11:42 +02:00
|
|
|
}
|
2021-07-27 22:55:12 +02:00
|
|
|
if (is_autism_bot4(client))
|
2021-06-18 16:11:42 +02:00
|
|
|
{
|
2021-07-27 22:55:12 +02:00
|
|
|
send_socket_msg(message, strlen(message), ports[3]);
|
2021-06-18 16:11:42 +02:00
|
|
|
}
|
2020-10-18 22:54:22 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
TR_TraceHullFilter(eye_position, eye_position, mins, maxs, MASK_ALL, TraceRayDontHitSelf);
|
|
|
|
if (!(TR_DidHit()))
|
|
|
|
{
|
|
|
|
Format(message, sizeof(message), "hull info:jump");
|
2021-07-27 22:55:12 +02:00
|
|
|
if (is_autism_bot1(client))
|
2021-04-05 23:01:54 +02:00
|
|
|
{
|
2021-07-27 22:55:12 +02:00
|
|
|
send_socket_msg(message, strlen(message), ports[0]);
|
2021-04-05 23:01:54 +02:00
|
|
|
}
|
2021-07-27 22:55:12 +02:00
|
|
|
if (is_autism_bot2(client))
|
2021-04-05 23:01:54 +02:00
|
|
|
{
|
2021-07-27 22:55:12 +02:00
|
|
|
send_socket_msg(message, strlen(message), ports[1]);
|
2021-04-05 23:01:54 +02:00
|
|
|
}
|
2021-07-27 22:55:12 +02:00
|
|
|
if (is_autism_bot3(client))
|
2021-06-18 16:11:42 +02:00
|
|
|
{
|
2021-07-27 22:55:12 +02:00
|
|
|
send_socket_msg(message, strlen(message), ports[2]);
|
2021-06-18 16:11:42 +02:00
|
|
|
}
|
2021-07-27 22:55:12 +02:00
|
|
|
if (is_autism_bot4(client))
|
2021-06-18 16:11:42 +02:00
|
|
|
{
|
2021-07-27 22:55:12 +02:00
|
|
|
send_socket_msg(message, strlen(message), ports[3]);
|
2021-06-18 16:11:42 +02:00
|
|
|
}
|
2020-10-18 22:54:22 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (jj == 0)
|
|
|
|
mins[ij] -= BOUNDINGBOX_INFLATION_OFFSET;
|
|
|
|
else
|
|
|
|
maxs[ij] += BOUNDINGBOX_INFLATION_OFFSET;
|
|
|
|
}
|
2020-10-02 19:05:48 +02:00
|
|
|
}
|
2020-10-18 22:54:22 +02:00
|
|
|
//currently detects when two walls meet and create a corner
|
|
|
|
float move_angles[3];
|
2021-07-29 13:20:05 +02:00
|
|
|
GetClientEyeAngles(client, move_angles);
|
|
|
|
move_angles[0] = 0.0;
|
|
|
|
move_angles[1] += 35.0;
|
|
|
|
move_angles[2] = 0.0;
|
|
|
|
TeleportEntity(client, NULL_VECTOR, move_angles, NULL_VECTOR);
|
2020-10-18 22:54:22 +02:00
|
|
|
return;
|
2020-09-27 03:16:52 +02:00
|
|
|
}
|
2020-10-02 19:05:48 +02:00
|
|
|
}
|
2020-08-19 00:12:39 +02:00
|
|
|
}
|
|
|
|
|
2020-08-30 20:00:02 +02:00
|
|
|
public Action surf_cooldown_timer(Handle timer, any data)
|
|
|
|
{
|
|
|
|
surf_cooldown = false;
|
|
|
|
return Plugin_Continue;
|
2020-08-01 01:15:39 +02:00
|
|
|
}
|
|
|
|
|
2020-07-27 00:34:15 +02:00
|
|
|
public bool TraceRayDontHitSelf(int entity, int mask, any data)
|
|
|
|
{
|
|
|
|
return entity != data && !(0 < entity <= MaxClients);
|
|
|
|
}
|
|
|
|
|
2021-03-27 00:57:40 +01:00
|
|
|
public void face_call(int client, int selfclient)
|
2020-07-24 00:25:03 +02:00
|
|
|
{
|
2020-07-25 00:50:00 +02:00
|
|
|
for (int j = 0; j < 5; j++)
|
2021-03-27 00:57:40 +01:00
|
|
|
faceclient(client, selfclient);
|
2020-07-21 02:09:41 +02:00
|
|
|
}
|
|
|
|
|
2021-03-27 00:57:40 +01:00
|
|
|
public void faceclient(int target_human, int client)
|
2020-07-19 00:05:07 +02:00
|
|
|
{
|
2021-03-27 00:57:40 +01:00
|
|
|
if (IsValidClient(client) && IsValidClient(target_human))
|
2020-07-24 00:25:03 +02:00
|
|
|
{
|
|
|
|
float TargetPos[3];
|
|
|
|
float ClientPos[3];
|
|
|
|
float Result[3];
|
|
|
|
GetClientEyePosition(target_human, TargetPos);
|
2021-03-27 00:57:40 +01:00
|
|
|
GetClientEyePosition(client, ClientPos);
|
2020-07-24 00:25:03 +02:00
|
|
|
MakeVectorFromPoints(ClientPos, TargetPos, Result);
|
|
|
|
GetVectorAngles(Result, Result);
|
2021-03-27 00:57:40 +01:00
|
|
|
TeleportEntity(client, NULL_VECTOR, Result, NULL_VECTOR);
|
2020-07-24 00:25:03 +02:00
|
|
|
}
|
2020-07-19 00:05:07 +02:00
|
|
|
}
|
|
|
|
|
2020-01-23 23:15:26 +01:00
|
|
|
stock bool IsValidClient(int client)
|
|
|
|
{
|
|
|
|
if (client > 0 && client <= MaxClients && IsClientConnected(client) && IsClientInGame(client))
|
|
|
|
return true;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2020-07-19 00:05:07 +02:00
|
|
|
stock bool is_client_stuck_or_afk(int client)
|
2020-09-27 03:16:52 +02:00
|
|
|
{
|
2021-07-29 13:20:05 +02:00
|
|
|
float min_distance_cap = 1.0;
|
2020-07-24 00:25:03 +02:00
|
|
|
float client_own_distance = get_power_distance(client, client_old_coords[client]);
|
2020-09-27 03:16:52 +02:00
|
|
|
GetEntPropVector(client, Prop_Send, "m_vecOrigin", client_old_coords[client]);
|
|
|
|
return client_own_distance < min_distance_cap;
|
2020-07-19 00:05:07 +02:00
|
|
|
}
|
|
|
|
|
2021-07-29 13:20:05 +02:00
|
|
|
public bool check_client_team(int client, int i, bool finding_friend)
|
|
|
|
{
|
|
|
|
return (finding_friend && GetClientTeam(client) == GetClientTeam(i)) || (!finding_friend && GetClientTeam(client) != GetClientTeam(i));
|
|
|
|
}
|
|
|
|
|
|
|
|
public int GetClosestClient_option1(bool finding_friend, int client)
|
2020-07-19 00:05:07 +02:00
|
|
|
{
|
|
|
|
float nearestdistance = -1.0;
|
|
|
|
int nearest = -1;
|
2021-04-25 01:01:05 +02:00
|
|
|
if (GetEntityMoveType(client) == MOVETYPE_LADDER)
|
|
|
|
return nearest;
|
2021-07-29 13:20:05 +02:00
|
|
|
//are there other players than bots to follow
|
|
|
|
bool other_players_than_bots = false;
|
2020-08-19 00:12:39 +02:00
|
|
|
for (int i = 1; i <= MaxClients; i++)
|
2021-07-29 13:20:05 +02:00
|
|
|
if (IsValidClient(i) && IsPlayerAlive(i) && i != client && !is_bot_player(i) && IsAbleToSee(client, i) && check_client_team(client, i, finding_friend))
|
|
|
|
{
|
|
|
|
other_players_than_bots = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
for (int i = 1; i <= MaxClients; i++)
|
|
|
|
if (IsValidClient(i) && IsPlayerAlive(i) && i != client && (!other_players_than_bots || !is_bot_player(i)) && check_client_team(client, i, finding_friend))
|
2021-07-05 18:27:58 +02:00
|
|
|
{
|
2021-07-29 13:20:05 +02:00
|
|
|
if (!IsAbleToSee(client, i))
|
|
|
|
continue;
|
|
|
|
if (is_client_stuck_or_afk(i))
|
|
|
|
{
|
|
|
|
if (i != targethuman[client])
|
|
|
|
continue;
|
|
|
|
target_human_afk_counter[client]++;
|
|
|
|
int afk_cap = 4;
|
|
|
|
if (target_human_afk_counter[client] > afk_cap)
|
|
|
|
{
|
|
|
|
target_human_afk_counter[client] = 0;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
float pos[3];
|
|
|
|
GetEntPropVector(i, Prop_Send, "m_vecOrigin", pos);
|
|
|
|
float dist_target = get_power_distance(client, pos);
|
|
|
|
if (GetClientTeam(i) != GetClientTeam(client) && (admins[i] || vips[i]))
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if ((admins[i] || vips[i] || i == targethuman[client]))
|
|
|
|
dist_target /= 5;
|
|
|
|
if (nearestdistance < 0 || dist_target < nearestdistance)
|
|
|
|
{
|
|
|
|
nearest = i;
|
|
|
|
nearestdistance = dist_target;
|
|
|
|
}
|
2021-07-05 18:27:58 +02:00
|
|
|
}
|
2020-07-19 00:05:07 +02:00
|
|
|
return nearest;
|
|
|
|
}
|
|
|
|
|
|
|
|
public float get_power_distance(int target_player, float [3]pos)
|
|
|
|
{
|
|
|
|
float vec[3];
|
|
|
|
GetClientAbsOrigin(target_player, vec);
|
2020-09-27 03:16:52 +02:00
|
|
|
return GetVectorDistance(vec, pos);
|
2020-07-19 00:05:07 +02:00
|
|
|
}
|
|
|
|
|
2020-01-23 23:15:26 +01:00
|
|
|
public void OnClientPostAdminCheck(int client)
|
|
|
|
{
|
2021-04-20 17:08:38 +02:00
|
|
|
target_human_afk_counter[client] = 0;
|
2021-04-27 00:55:50 +02:00
|
|
|
bot_avoid_edge[client] = -1;
|
2020-01-23 23:15:26 +01:00
|
|
|
char auth[50];
|
2021-04-09 21:17:30 +02:00
|
|
|
GetClientAuthId(client, AuthId_Engine, auth, sizeof(auth));
|
|
|
|
char msg[generic_length];
|
|
|
|
Format(msg, sizeof(msg), "autismo connected");
|
2021-07-27 22:55:12 +02:00
|
|
|
if (is_autism_bot1(client))
|
2020-04-22 00:17:28 +02:00
|
|
|
{
|
2021-07-27 22:55:12 +02:00
|
|
|
send_socket_msg(msg, strlen(msg), ports[0]);
|
2020-04-22 00:17:28 +02:00
|
|
|
}
|
2021-07-27 22:55:12 +02:00
|
|
|
if (is_autism_bot2(client))
|
2020-04-22 00:17:28 +02:00
|
|
|
{
|
2021-07-27 22:55:12 +02:00
|
|
|
send_socket_msg(msg, strlen(msg), ports[1]);
|
2020-04-22 00:17:28 +02:00
|
|
|
}
|
2021-07-27 22:55:12 +02:00
|
|
|
if (is_autism_bot3(client))
|
2021-06-18 16:11:42 +02:00
|
|
|
{
|
2021-07-27 22:55:12 +02:00
|
|
|
send_socket_msg(msg, strlen(msg), ports[2]);
|
2021-06-18 16:11:42 +02:00
|
|
|
}
|
2021-07-27 22:55:12 +02:00
|
|
|
if (is_autism_bot4(client))
|
2021-06-18 16:11:42 +02:00
|
|
|
{
|
2021-07-27 22:55:12 +02:00
|
|
|
send_socket_msg(msg, strlen(msg), ports[3]);
|
2021-06-18 16:11:42 +02:00
|
|
|
}
|
2020-07-15 02:14:00 +02:00
|
|
|
if (CheckCommandAccess(client, "sm_kick", ADMFLAG_KICK))
|
2020-07-21 01:03:06 +02:00
|
|
|
admins[client] = true;
|
2020-07-15 02:14:00 +02:00
|
|
|
else if (CheckCommandAccess(client, "sm_reserved", ADMFLAG_RESERVATION))
|
2020-07-21 01:03:06 +02:00
|
|
|
vips[client] = true;
|
2020-07-24 00:25:03 +02:00
|
|
|
client_old_coords[client][0] = 0.0;
|
|
|
|
client_old_coords[client][1] = 0.0;
|
|
|
|
client_old_coords[client][2] = 0.0;
|
2020-04-22 00:17:28 +02:00
|
|
|
}
|
|
|
|
|
2020-06-26 00:11:22 +02:00
|
|
|
public OnSocketError(Handle socket, const int errorType, const int errorNum, any args)
|
2020-04-22 00:17:28 +02:00
|
|
|
{
|
2020-09-23 11:48:11 +02:00
|
|
|
CloseHandle(socket);
|
|
|
|
LogError("[MR] Socket error: %d (errno %d)", errorType, errorNum);
|
|
|
|
CreateTimer(10.0, TimerConnect, INVALID_HANDLE, TIMER_HNDL_CLOSE);
|
2020-04-22 00:17:28 +02:00
|
|
|
}
|
|
|
|
|
2020-09-23 11:48:11 +02:00
|
|
|
stock void connect_socket()
|
2020-04-22 00:17:28 +02:00
|
|
|
{
|
2020-09-23 11:48:11 +02:00
|
|
|
if (global_socket == INVALID_HANDLE || !SocketIsConnected(global_socket))
|
|
|
|
{
|
|
|
|
//socket otherwise declare in public OnConfigsExecuted(){}
|
|
|
|
global_socket = SocketCreate(SOCKET_UDP, OnSocketError);
|
|
|
|
SocketSetOption(global_socket, SocketReuseAddr, 1);
|
2021-06-17 22:17:19 +02:00
|
|
|
SocketBind(global_socket, "127.0.0.0", 48475);
|
2020-09-23 11:48:11 +02:00
|
|
|
SocketConnect(global_socket, OnSocketConnected, OnSocketReceive, OnSocketDisconnected, "127.0.0.1", 48475);
|
2021-04-05 23:01:54 +02:00
|
|
|
}
|
2020-04-22 00:17:28 +02:00
|
|
|
}
|
|
|
|
|
2020-06-26 00:11:22 +02:00
|
|
|
public void OnClientDisconnect(int client)
|
2020-04-22 00:17:28 +02:00
|
|
|
{
|
2020-07-21 01:03:06 +02:00
|
|
|
admins[client] = false;
|
2021-04-27 00:55:50 +02:00
|
|
|
bot_avoid_edge[client] = -1;
|
2020-07-21 01:03:06 +02:00
|
|
|
vips[client] = false;
|
2020-07-24 00:25:03 +02:00
|
|
|
client_old_coords[client][0] = 0.0;
|
|
|
|
client_old_coords[client][1] = 0.0;
|
|
|
|
client_old_coords[client][2] = 0.0;
|
2021-04-20 17:08:38 +02:00
|
|
|
target_human_afk_counter[client] = 0;
|
2020-04-22 00:17:28 +02:00
|
|
|
}
|
|
|
|
|
2020-06-26 00:11:22 +02:00
|
|
|
//Socket callback
|
|
|
|
public OnSocketConnected(Handle socket, any arg)
|
2020-04-22 00:17:28 +02:00
|
|
|
{
|
2020-06-26 00:11:22 +02:00
|
|
|
|
2020-04-22 00:17:28 +02:00
|
|
|
}
|
|
|
|
|
2020-06-26 00:11:22 +02:00
|
|
|
//manage message
|
|
|
|
public OnSocketReceive(Handle socket, char[] receiveData, const dataSize, any hFile)
|
2020-04-22 00:17:28 +02:00
|
|
|
{
|
2020-06-26 00:11:22 +02:00
|
|
|
//PrintToChatAll("receiveData: %s", receiveData);
|
|
|
|
}
|
|
|
|
|
|
|
|
public OnSocketDisconnected(Handle socket, any arg)
|
|
|
|
{
|
2020-09-23 11:48:11 +02:00
|
|
|
CreateTimer(10.0, TimerConnect, INVALID_HANDLE, TIMER_HNDL_CLOSE);
|
2020-06-09 23:34:49 +02:00
|
|
|
}
|
|
|
|
|
2020-06-26 00:11:22 +02:00
|
|
|
public Action TimerConnect(Handle timer, any arg)
|
2020-06-09 23:34:49 +02:00
|
|
|
{
|
2020-09-23 11:48:11 +02:00
|
|
|
connect_socket();
|
2020-06-26 00:11:22 +02:00
|
|
|
return Plugin_Handled;
|
2020-07-25 21:15:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public bool IsAbleToSee(int entity, int client)
|
|
|
|
{
|
|
|
|
float vecorigin[3];
|
|
|
|
float vecEyePos[3];
|
|
|
|
GetClientAbsOrigin(entity, vecorigin);
|
|
|
|
GetClientEyePosition(client, vecEyePos);
|
|
|
|
// Check if centre is visible.
|
|
|
|
if (IsPointVisible(vecEyePos, vecorigin))
|
|
|
|
return true;
|
|
|
|
float vecEyePos_ent[3];
|
|
|
|
float vecEyeAng[3];
|
|
|
|
GetClientEyeAngles(entity, vecEyeAng);
|
|
|
|
GetClientEyePosition(entity, vecEyePos_ent);
|
|
|
|
// Check if weapon tip is visible.
|
|
|
|
if (IsFwdVecVisible(vecEyePos, vecEyeAng, vecEyePos_ent))
|
|
|
|
return true;
|
|
|
|
float mins[3];
|
|
|
|
float maxs[3];
|
|
|
|
GetClientMins(client, mins);
|
|
|
|
GetClientMaxs(client, maxs);
|
|
|
|
// Check outer 4 corners of player.
|
|
|
|
if (IsRectangleVisible(vecEyePos, vecorigin, mins, maxs, 1.30))
|
|
|
|
return true;
|
|
|
|
// Check inner 4 corners of player.
|
|
|
|
if (IsRectangleVisible(vecEyePos, vecorigin, mins, maxs, 0.65))
|
|
|
|
return true;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
public bool Filter_NoPlayers(int entity, int mask)
|
|
|
|
{
|
|
|
|
return (entity > MaxClients && !(0 < GetEntPropEnt(entity, Prop_Data, "m_hOwnerEntity") <= MaxClients));
|
|
|
|
}
|
|
|
|
|
|
|
|
public bool IsPointVisible(const float start[3], const float end[3])
|
|
|
|
{
|
2021-04-25 01:01:05 +02:00
|
|
|
TR_TraceRayFilter(start, end, MASK_SOLID, RayType_EndPoint, Filter_NoPlayers);
|
2020-07-25 21:15:00 +02:00
|
|
|
return TR_GetFraction() == 1.0;
|
|
|
|
}
|
|
|
|
|
|
|
|
public bool IsFwdVecVisible(const float start[3], const float angles[3], const float end[3])
|
|
|
|
{
|
|
|
|
float fwd[3];
|
|
|
|
GetAngleVectors(angles, fwd, NULL_VECTOR, NULL_VECTOR);
|
2021-07-29 13:20:05 +02:00
|
|
|
ScaleVector(fwd, 50.0); //ScaleVector(fwd, 50.0);
|
2020-07-25 21:15:00 +02:00
|
|
|
AddVectors(end, fwd, fwd);
|
|
|
|
return IsPointVisible(start, fwd);
|
|
|
|
}
|
|
|
|
|
|
|
|
public bool IsRectangleVisible(const float start[3], const float end[3], const float mins[3], const float maxs[3], float scale)
|
|
|
|
{
|
|
|
|
float ZpozOffset = maxs[2];
|
|
|
|
float ZnegOffset = mins[2];
|
|
|
|
float WideOffset = ((maxs[0] - mins[0]) + (maxs[1] - mins[1])) / 4.0;
|
|
|
|
// This rectangle is just a point!
|
|
|
|
if (ZpozOffset == 0.0 && ZnegOffset == 0.0 && WideOffset == 0.0)
|
|
|
|
return IsPointVisible(start, end);
|
|
|
|
// Adjust to scale.
|
|
|
|
ZpozOffset *= scale;
|
|
|
|
ZnegOffset *= scale;
|
|
|
|
WideOffset *= scale;
|
|
|
|
// Prepare rotation matrix.
|
|
|
|
float angles[3];
|
|
|
|
float fwd[3];
|
|
|
|
float right[3];
|
|
|
|
SubtractVectors(start, end, fwd);
|
|
|
|
NormalizeVector(fwd, fwd);
|
|
|
|
GetVectorAngles(fwd, angles);
|
|
|
|
GetAngleVectors(angles, fwd, right, NULL_VECTOR);
|
|
|
|
float vRectangle[4][3];
|
|
|
|
float vTemp[3];
|
|
|
|
// If the player is on the same level as us, we can optimize by only rotating on the z-axis.
|
|
|
|
if (FloatAbs(fwd[2]) <= 0.7071)
|
|
|
|
{
|
|
|
|
ScaleVector(right, WideOffset);
|
|
|
|
|
|
|
|
// Corner 1, 2
|
|
|
|
vTemp = end;
|
|
|
|
vTemp[2] += ZpozOffset;
|
|
|
|
AddVectors(vTemp, right, vRectangle[0]);
|
|
|
|
SubtractVectors(vTemp, right, vRectangle[1]);
|
|
|
|
|
|
|
|
// Corner 3, 4
|
|
|
|
vTemp = end;
|
|
|
|
vTemp[2] += ZnegOffset;
|
|
|
|
AddVectors(vTemp, right, vRectangle[2]);
|
|
|
|
SubtractVectors(vTemp, right, vRectangle[3]);
|
|
|
|
|
|
|
|
}
|
|
|
|
else if (fwd[2] > 0.0) // Player is below us.
|
|
|
|
{
|
|
|
|
fwd[2] = 0.0;
|
|
|
|
NormalizeVector(fwd, fwd);
|
|
|
|
ScaleVector(fwd, scale);
|
|
|
|
ScaleVector(fwd, WideOffset);
|
|
|
|
ScaleVector(right, WideOffset);
|
|
|
|
// Corner 1
|
|
|
|
vTemp = end;
|
|
|
|
vTemp[2] += ZpozOffset;
|
|
|
|
AddVectors(vTemp, right, vTemp);
|
|
|
|
SubtractVectors(vTemp, fwd, vRectangle[0]);
|
|
|
|
// Corner 2
|
|
|
|
vTemp = end;
|
|
|
|
vTemp[2] += ZpozOffset;
|
|
|
|
SubtractVectors(vTemp, right, vTemp);
|
|
|
|
SubtractVectors(vTemp, fwd, vRectangle[1]);
|
|
|
|
// Corner 3
|
|
|
|
vTemp = end;
|
|
|
|
vTemp[2] += ZnegOffset;
|
|
|
|
AddVectors(vTemp, right, vTemp);
|
|
|
|
AddVectors(vTemp, fwd, vRectangle[2]);
|
|
|
|
// Corner 4
|
|
|
|
vTemp = end;
|
|
|
|
vTemp[2] += ZnegOffset;
|
|
|
|
SubtractVectors(vTemp, right, vTemp);
|
|
|
|
AddVectors(vTemp, fwd, vRectangle[3]);
|
|
|
|
}
|
|
|
|
else // Player is above us.
|
|
|
|
{
|
|
|
|
fwd[2] = 0.0;
|
|
|
|
NormalizeVector(fwd, fwd);
|
|
|
|
ScaleVector(fwd, scale);
|
|
|
|
ScaleVector(fwd, WideOffset);
|
|
|
|
ScaleVector(right, WideOffset);
|
|
|
|
// Corner 1
|
|
|
|
vTemp = end;
|
|
|
|
vTemp[2] += ZpozOffset;
|
|
|
|
AddVectors(vTemp, right, vTemp);
|
|
|
|
AddVectors(vTemp, fwd, vRectangle[0]);
|
|
|
|
// Corner 2
|
|
|
|
vTemp = end;
|
|
|
|
vTemp[2] += ZpozOffset;
|
|
|
|
SubtractVectors(vTemp, right, vTemp);
|
|
|
|
AddVectors(vTemp, fwd, vRectangle[1]);
|
|
|
|
// Corner 3
|
|
|
|
vTemp = end;
|
|
|
|
vTemp[2] += ZnegOffset;
|
|
|
|
AddVectors(vTemp, right, vTemp);
|
|
|
|
SubtractVectors(vTemp, fwd, vRectangle[2]);
|
|
|
|
// Corner 4
|
|
|
|
vTemp = end;
|
|
|
|
vTemp[2] += ZnegOffset;
|
|
|
|
SubtractVectors(vTemp, right, vTemp);
|
|
|
|
SubtractVectors(vTemp, fwd, vRectangle[3]);
|
|
|
|
}
|
|
|
|
// Run traces on all corners.
|
|
|
|
for (new i = 0; i < 4; i++)
|
|
|
|
if (IsPointVisible(start, vRectangle[i]))
|
|
|
|
return true;
|
|
|
|
return false;
|
2020-10-18 22:54:22 +02:00
|
|
|
}
|