From d6fc4b7c3813532f91c6a341f49e2abb1e8c5014 Mon Sep 17 00:00:00 2001 From: christian Date: Sat, 30 Oct 2021 16:54:43 +0200 Subject: [PATCH] changed respawning and team joining for gg server --- AutismBotIngame/python/ingamefollowct.py | 6 --- AutismBotIngame/scripting/autism_bot_info.sp | 53 +++++++++++++++++--- 2 files changed, 46 insertions(+), 13 deletions(-) diff --git a/AutismBotIngame/python/ingamefollowct.py b/AutismBotIngame/python/ingamefollowct.py index 58f3abd9..5fbf420c 100644 --- a/AutismBotIngame/python/ingamefollowct.py +++ b/AutismBotIngame/python/ingamefollowct.py @@ -30,11 +30,6 @@ def exit_handler(): writeCfgInput('') #securing the looptest.cfg wont be stuck accidently with commands -def joinTeam(): - str = "jointeam 2; joinclass 3; zspawn;" - writeCfgInput(str) - print('jointeam func: ') - def bot_process_movement(input_line): dist_target = input_line[input_line.index("dist_target:") + len("dist_target:"):input_line.index("targethuman:")] targethuman = input_line[input_line.index("targethuman:") + len("targethuman:"):input_line.index("enemy_distance:")] @@ -187,7 +182,6 @@ if __name__ == '__main__': if data == "autismo connected": print('Bot connected!') connection_issue_counter = 0 - joinTeam() elif data == "rtv": response_msg = "say rtv" writeCfgInput(response_msg) diff --git a/AutismBotIngame/scripting/autism_bot_info.sp b/AutismBotIngame/scripting/autism_bot_info.sp index c23cf065..52b30f6c 100644 --- a/AutismBotIngame/scripting/autism_bot_info.sp +++ b/AutismBotIngame/scripting/autism_bot_info.sp @@ -362,7 +362,7 @@ public Action bot_check_connect(Handle timer, any data) found_bot4 = true; Format(msg, sizeof(msg), "connect to gg"); send_socket_msg(msg, strlen(msg), ports[0]); - Format(msg, sizeof(msg), "connect to zr"); + //Format(msg, sizeof(msg), "connect to zr"); send_socket_msg(msg, strlen(msg), ports[1]); send_socket_msg(msg, strlen(msg), ports[2]); send_socket_msg(msg, strlen(msg), ports[3]); @@ -371,30 +371,35 @@ public Action bot_check_connect(Handle timer, any data) } else { + //respawning bot on the GG server because they dont respawn for whatever reason if (is_autism_bot1(i)) { Format(msg, sizeof(msg), "connected to gg"); send_socket_msg(msg, strlen(msg), ports[0]); found_bot1 = true; + CreateTimer(1.0, respawn_bot, i); } else if (is_bot_player(i)) { - Format(msg, sizeof(msg), "connected to zr"); + Format(msg, sizeof(msg), "connected to gg"); } if (is_autism_bot2(i)) { send_socket_msg(msg, strlen(msg), ports[1]); found_bot2 = true; + CreateTimer(1.0, respawn_bot, i); } if (is_autism_bot3(i)) { send_socket_msg(msg, strlen(msg), ports[2]); found_bot3 = true; + CreateTimer(1.0, respawn_bot, i); } if (is_autism_bot4(i)) { send_socket_msg(msg, strlen(msg), ports[3]); found_bot4 = true; + CreateTimer(1.0, respawn_bot, i); } } } @@ -407,17 +412,17 @@ public Action bot_check_connect(Handle timer, any data) //gg send_socket_msg(msg, strlen(msg), ports[0]); } - if (!found_bot2 && i_port == server_ports[2]) + if (!found_bot2 && i_port == server_ports[1]) { //zr send_socket_msg(msg, strlen(msg), ports[1]); } - if (!found_bot3 && i_port == server_ports[2]) + if (!found_bot3 && i_port == server_ports[1]) { //zr send_socket_msg(msg, strlen(msg), ports[2]); } - if (!found_bot4 && i_port == server_ports[2]) + if (!found_bot4 && i_port == server_ports[1]) { //zr send_socket_msg(msg, strlen(msg), ports[3]); @@ -522,6 +527,12 @@ public bool is_bot_player(int client) public Action recursive_pressing(Handle timer, any data) { + int i_port = GetConVarInt(FindConVar("hostport")); + bool is_host_ze = false; + if (i_port == server_ports[0]) + { + is_host_ze = true; + } bool found_valid_ct = false; for (int client = 1; client <= MaxClients; client++) { @@ -534,7 +545,35 @@ public Action recursive_pressing(Handle timer, any data) { if (GetClientTeam(client) == 1 || GetClientTeam(client) == 0) { - ChangeClientTeam(client, 2); + if (is_host_ze) + { + ChangeClientTeam(client, 2); + } + else + { + int T_client_count = 0; + int CT_client_count = 0; + for (int clientI = 1; clientI <= MaxClients; clientI++) + { + if (!IsValidClient(clientI)) continue; + if (GetClientTeam(clientI) == 2) + { + T_client_count++; + } + else if (GetClientTeam(clientI) == 3) + { + CT_client_count++; + } + } + if (T_client_count > CT_client_count) + { + ChangeClientTeam(client, 3); + } + else + { + ChangeClientTeam(client, 2); + } + } continue; } if (bot_avoid_edge[client] >= 3) @@ -634,7 +673,7 @@ public Action recursive_pressing(Handle timer, any data) for (int client = 1; client <= MaxClients; client++) { if (!IsValidClient(client)) continue; - if (is_bot_player(client) && GetClientTeam(client) == 3) + if (is_bot_player(client) && GetClientTeam(client) == 3 && is_host_ze) { ForcePlayerSuicide(client); }