From fb6e8d916619bb1221caf087c0b7ce82052e09e8 Mon Sep 17 00:00:00 2001 From: christian Date: Thu, 29 Apr 2021 11:55:38 +0200 Subject: [PATCH] further attempt at avoiding bot falling off edges --- AutismBotIngame/scripting/autism_bot_info.sp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/AutismBotIngame/scripting/autism_bot_info.sp b/AutismBotIngame/scripting/autism_bot_info.sp index 5b2793e7..b40e430b 100644 --- a/AutismBotIngame/scripting/autism_bot_info.sp +++ b/AutismBotIngame/scripting/autism_bot_info.sp @@ -306,7 +306,7 @@ public void OnPlayerRunCmdPost(int client, int buttons, int impulse, const float TR_GetEndPosition(ground_pos); ground_distance = GetVectorDistance(feet_origin, ground_pos); float forward_distance = GetVectorDistance(feet_origin, ground_pos); - if (forward_distance > 250) + if (forward_distance > 280) { float ClientPos[3]; float Result[3]; @@ -316,6 +316,10 @@ public void OnPlayerRunCmdPost(int client, int buttons, int impulse, const float GetVectorAngles(Result, Result); TeleportEntity(client, NULL_VECTOR, Result, NULL_VECTOR); bot_avoid_edge[client] = 0; + ApplyBoost(client, 500.0, Result); + buttons_old[client] = buttons; + flags_old[client] = flags; + return; } } } @@ -327,6 +331,14 @@ public void OnPlayerRunCmdPost(int client, int buttons, int impulse, const float } } +void ApplyBoost(int client, float amount, float vel[3]){ + float direction[3]; + NormalizeVector(vel, direction); + ScaleVector(direction, amount); + AddVectors(vel, direction, vel); + TeleportEntity(client, NULL_VECTOR, NULL_VECTOR, vel); +} + public bool is_bot_player(int client) { char auth[50]; @@ -354,7 +366,7 @@ public Action recursive_pressing(Handle timer, any data) ChangeClientTeam(client, 2); continue; } - if (bot_avoid_edge[client] >= 4) + if (bot_avoid_edge[client] >= 3) bot_avoid_edge[client] = -1; if (bot_avoid_edge[client] > -1) {