From c72d96a71408ac460fefce1ae78eeeb7059cfd2a Mon Sep 17 00:00:00 2001 From: christian Date: Tue, 20 Apr 2021 22:22:15 +0200 Subject: [PATCH] adding prevention for bot to fall off the edge --- AutismBotIngame/scripting/autism_bot_info.sp | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/AutismBotIngame/scripting/autism_bot_info.sp b/AutismBotIngame/scripting/autism_bot_info.sp index bfe2d8e4..6dab5a0c 100644 --- a/AutismBotIngame/scripting/autism_bot_info.sp +++ b/AutismBotIngame/scripting/autism_bot_info.sp @@ -279,7 +279,7 @@ public void OnPlayerRunCmdPost(int client, int buttons, int impulse, const float 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") == 0) { float Vel[3], feet_origin[3], ground_pos[3], downwards[3]; - //TODO + //TODO prevent bot from falling off edge if nothing infront float velocity_addition_z_axis = 300.0; GetEntPropVector(client, Prop_Data, "m_vecVelocity", Vel); Vel[2] += velocity_addition_z_axis; @@ -312,8 +312,6 @@ public void OnPlayerRunCmdPost(int client, int buttons, int impulse, const float float feet_origin_pre[3], human_feet_origin[3]; GetClientAbsOrigin(client, feet_origin_pre); GetClientAbsOrigin(targethuman[client], human_feet_origin); - //target human is below, get down to them - //TODO maybe? if (feet_origin_pre[2] - 200 > human_feet_origin[2]) { buttons_old[client] = buttons; @@ -323,10 +321,17 @@ public void OnPlayerRunCmdPost(int client, int buttons, int impulse, const float } float velocity[3]; GetEntPropVector(client, Prop_Data, "m_vecVelocity", velocity); - velocity[2] += 30.0; NegateVector(velocity); - for (int y = 0; y < 10; y++) - TeleportEntity(client, NULL_VECTOR, NULL_VECTOR, velocity); + if (velocity[0] > 0) + velocity[0] += 150; + else + velocity[0] -= 150; + if (velocity[1] > 0) + velocity[1] += 150; + else + velocity[1] -= 150; + velocity[2] += 150; + TeleportEntity(client, NULL_VECTOR, NULL_VECTOR, velocity); } } } @@ -403,7 +408,6 @@ public Action recursive_pressing(Handle timer, any data) dist_target = get_power_distance(client, pos); } - //TODO maybe disable if requested if (IsValidClient(target_enemy[client])) { GetEntPropVector(target_enemy[client], Prop_Send, "m_vecOrigin", pos);