diff --git a/AutismBotIngame/scripting/bot_surfing.sp b/AutismBotIngame/scripting/bot_surfing.sp index 6206af65..8e9c5c01 100644 --- a/AutismBotIngame/scripting/bot_surfing.sp +++ b/AutismBotIngame/scripting/bot_surfing.sp @@ -12,10 +12,10 @@ public Plugin myinfo = version = "1.0", url = "www.unloze.com" }; -float bot_finished_surf_coords[MAXPLAYERS + 1][3] ; -bool is_forward_called[MAXPLAYERS + 1]; +float bot_finished_surf_coords[MAXPLAYERS + 1][3]; char map_coorindates[65][256]; char map_recordname[65][256]; +bool round_switch = false; Database g_dDatabase; public void OnPluginStart() @@ -24,28 +24,48 @@ public void OnPluginStart() if (IsValidClient(i)) { reset_client(i); + reset_bot_finished_surf(i); } OnMapStart(); - HookEvent("round_start", Event_RoundStart, EventHookMode_PostNoCopy); - HookEvent("round_end", OnRoundEnd, EventHookMode_Post); + HookEvent("round_start", Event_RoundStart, EventHookMode_Pre); + HookEvent("round_end", OnRoundEnd, EventHookMode_Pre); +} + +public void OnPluginEnd() +{ + for (int i = 1; i <= MaxClients; i++) + if (IsValidClient(i)) + { + reset_client(i); + reset_bot_finished_surf(i); + } } public Action OnRoundEnd(Handle event, const char[] name, bool dontBroadcast) { - for (int i = 1; i <= MaxClients; i++) - if (IsValidClient(i) && !IsFakeClient(i)) - { - reset_client(i); - } + perform_resets(); } public void Event_RoundStart(Handle event, const char[] name, bool dontBroadcast) { - for (int i = 1; i <= MaxClients; i++) - if (IsValidClient(i) && !IsFakeClient(i)) + perform_resets(); +} + +public void perform_resets() +{ + round_switch = true; + for (int i = 1; i <= MaxClients; i++) + if (IsValidClient(i)) { - reset_client(i); + reset_client(i); + reset_bot_finished_surf(i); } + CreateTimer(7.00, reset_round_switch, INVALID_HANDLE); +} + +public Action reset_round_switch(Handle timer, any data) +{ + round_switch = false; } stock bool IsValidClient(int client) @@ -57,50 +77,48 @@ stock bool IsValidClient(int client) public void OnClientPostAdminCheck(int client) { - is_forward_called[client] = false; - reset_client(client); + reset_bot_finished_surf(client); } public void OnClientDisconnect(int client) { - is_forward_called[client] = false; - reset_client(client); + reset_client(client); //casual autism thinking + reset_bot_finished_surf(client); } -public void reset_client(int client) +public void reset_bot_finished_surf(int client) { bot_finished_surf_coords[client][0] = 0.0; bot_finished_surf_coords[client][1] = 0.0; bot_finished_surf_coords[client][2] = 0.0; - is_forward_called[client] = false; - if (BotMimic_IsPlayerMimicing(client)) - { - BotMimic_StopPlayerMimic(client); - } } -//unknown delay before forward is called. -//BotMimic_IsPlayerMimicing() is true in update_mimic_coords before the BotMimic_OnPlayerMimicLoops forward is called +public void reset_client(int client) +{ + if (bot_finished_surf_coords[client][0] != 0.0) + { + BotMimic_StopPlayerMimic(client); + } +} + public int BotMimic_OnPlayerMimicLoops(int client) { char map_name[256]; GetCurrentMap(map_name, sizeof(map_name)); - if (!is_bot_player(client) || StrContains(map_name, "ze_surf", false) == -1) + if (StrContains(map_name, "ze_surf", false) == -1) { reset_client(client); + reset_bot_finished_surf(client); + } + else if (bot_finished_surf_coords[client][0] != 0.0) + { + reset_client(client); + TeleportEntity(client, bot_finished_surf_coords[client], NULL_VECTOR, NULL_VECTOR); + reset_bot_finished_surf(client); } else { - if (bot_finished_surf_coords[client][0] != 0.0 && BotMimic_IsPlayerMimicing(client)) - { - BotMimic_StopPlayerMimic(client); - TeleportEntity(client, bot_finished_surf_coords[client], NULL_VECTOR, NULL_VECTOR); - reset_client(client); - } - else - { - is_forward_called[client] = true; - } + GetEntPropVector(client, Prop_Send, "m_vecOrigin", bot_finished_surf_coords[client]); } } @@ -109,14 +127,19 @@ public Action update_mimic_coords(Handle timer, any data) for (int i = 1; i <= MaxClients; i++) if (IsValidClient(i) && is_bot_player(i)) { - if (BotMimic_IsPlayerMimicing(i) && is_forward_called[i]) + if (bot_finished_surf_coords[i][0] != 0.0) { GetEntPropVector(i, Prop_Send, "m_vecOrigin", bot_finished_surf_coords[i]); } } + if (round_switch) + { + return Plugin_Continue; + } Handle records_list = BotMimic_GetLoadedRecordList(); for (int i = 0; i < sizeof(map_coorindates); i++) { + bool found = false; char char_coord[3][256]; if (strlen(map_coorindates[i]) > 0) { @@ -126,34 +149,45 @@ public Action update_mimic_coords(Handle timer, any data) coords[1] = StringToFloat(char_coord[1]); coords[2] = StringToFloat(char_coord[2]); for (int j = 1; j <= MaxClients; j++) - if (IsValidClient(j) && !IsFakeClient(j) && bot_finished_surf_coords[j][0] == 0.0 && is_bot_player(j)) { - float distance = get_power_distance(j, coords); - //PrintToChatAll("distance %f client %N", distance, j); - if (distance < 225.0) + if (IsValidClient(j) && bot_finished_surf_coords[j][0] == 0.0 && is_bot_player(j)) { - char path[256]; - for (int f = 0; f < GetArraySize(records_list); f++) + float distance = get_power_distance(j, coords); + if (distance < 225.0) { - if (f != i) continue; - GetArrayString(records_list, f, path, sizeof(path)); - for (int h = 0; h < sizeof(map_recordname); h++) + char path[256]; + for (int f = 0; f < GetArraySize(records_list); f++) { - //i != h assures coordinates match the right iterated name - if (strlen(map_recordname[h]) == 0 || i != h) + if (f != i) continue; + GetArrayString(records_list, f, path, sizeof(path)); + for (int h = 0; h < sizeof(map_recordname); h++) { - continue; - } - if (StrEqual(path, map_recordname[h], false)) - { - BotMimic_PlayRecordFromFile(j, path); + //i != h assures coordinates match the right iterated name + if (strlen(map_recordname[h]) == 0 || i != h) + { + continue; + } + if (StrEqual(path, map_recordname[h], false)) + { + BotMimic_PlayRecordFromFile(j, path); + found = true; + } + if (found) + break; } + if (found) + break; } } } + if (found) + break; } } + if (found) + break; } + return Plugin_Continue; } public float get_power_distance(int target_player, float [3]pos) @@ -221,9 +255,9 @@ public void SQL_OnQueryCompleted(Database db, DBResultSet results, const char[] public void OnMapStart() { for (int i = 1; i <= MaxClients; i++) - if (IsValidClient(i) && !IsFakeClient(i)) + if (IsValidClient(i)) { - reset_client(i); + reset_bot_finished_surf(i); } char map_name[256]; GetCurrentMap(map_name, sizeof(map_name)); @@ -284,7 +318,19 @@ public void SQL_FinishedQuery_creating_tables(Database db, DBResultSet results, public bool is_bot_player(int client) { - return is_autism_bot1(client) || is_autism_bot2(client) || is_autism_bot3(client) || is_autism_bot4(client) || false; //change to true for debugging on dev + bool debug_b = false; + if (debug_b && is_jenz(client)) + { + return true; + } + return is_autism_bot1(client) || is_autism_bot2(client) || is_autism_bot3(client) || is_autism_bot4(client); //change to true for debugging on dev +} + +public bool is_jenz(int client) +{ + char auth[50]; + GetClientAuthId(client, AuthId_Engine, auth, sizeof(auth)); + return StrEqual("[U:1:69566635]", auth, false) || StrEqual("STEAM_0:1:34783317", auth, false); } public bool is_autism_bot1(int client)