From b137b526e7d45bcca5d15524f691af081cfb0af4 Mon Sep 17 00:00:00 2001 From: jenzur Date: Mon, 27 Jul 2020 19:14:50 +0200 Subject: [PATCH] pretty simple solution to jump over gaps and some slight changes to targeting --- AutismBotIngame/scripting/autism_bot_info.sp | 45 ++++++++++++++------ 1 file changed, 33 insertions(+), 12 deletions(-) diff --git a/AutismBotIngame/scripting/autism_bot_info.sp b/AutismBotIngame/scripting/autism_bot_info.sp index c94ae15a..76c7cb4b 100644 --- a/AutismBotIngame/scripting/autism_bot_info.sp +++ b/AutismBotIngame/scripting/autism_bot_info.sp @@ -13,6 +13,8 @@ //#pragma newdecls required int present = 0; int targethuman = 0; +int buttons_old; +int flags_old; bool client_stuck_g[MAXPLAYERS + 1]; bool round_start_stuck = false; float bot_old_coords[3]; @@ -140,10 +142,8 @@ public void OnPlayerRunCmdPost(int client, int buttons, int impulse, const float if (client == targethuman && round_start_stuck && IsValidClient(present)) { char keyinput[generic_length * 5]; - if (buttons & IN_JUMP) - Format(keyinput, sizeof(keyinput), "+jump; wait 5; ", keyinput); - if (buttons & IN_DUCK) - Format(keyinput, sizeof(keyinput), "%s +duck; wait 5; ", keyinput); + if (buttons & IN_JUMP || buttons & IN_DUCK) + Format(keyinput, sizeof(keyinput), "+jump; wait 5; +duck; wait 5; ", keyinput); if (strlen(keyinput) > 0) { float pos[3]; @@ -157,6 +157,19 @@ public void OnPlayerRunCmdPost(int client, int buttons, int impulse, const float } } } + else if (client == present) + { + int flags = GetEntityFlags(client); + if (!(flags & FL_ONGROUND) && (flags_old & FL_ONGROUND) && !(buttons_old & IN_JUMP)) + { + float Vel[3]; + GetEntPropVector(client, Prop_Data, "m_vecVelocity", Vel); + Vel[2] = 300.0; + TeleportEntity(client, NULL_VECTOR, NULL_VECTOR, Vel); + } + buttons_old = buttons; + flags_old = flags; + } } public Action recursive_pressing(Handle timer, any data) @@ -201,7 +214,6 @@ public Action recursive_pressing(Handle timer, any data) } } } - } //check ladder = 0, water = 1, in air(surfing) = 2, downhill = 3 @@ -238,14 +250,25 @@ public Action recursive_pressing(Handle timer, any data) enemy_distance = get_power_distance(present, pos); float min_distance_target_human = 0.2; //human aiming for zombie - if (targeteam == 3 && dist_target > 0 && dist_target < min_distance_target_human && enemy_distance > min_enemy_distance) + if (targeteam == 3) { - chasing_enemy = true; - face_call(target_enemy); + if (dist_target > 0 && dist_target < min_distance_target_human && enemy_distance > min_enemy_distance) + { + chasing_enemy = true; + face_call(target_enemy); + } + else if (!IsValidClient(targethuman)) + { + chasing_enemy = true; + face_call(target_enemy); + } } - //zombie aiming for human - if (0 < enemy_distance <= dist_target) + int zm_multiplier = 2; + if (dist_target < min_enemy_distance) + zm_multiplier = min_distance_mult; + if (0 < enemy_distance <= dist_target * zm_multiplier) min_enemy_distance = min_enemy_distance * min_distance_mult; + //zombie aiming for human if (targeteam == 2 && min_enemy_distance * min_distance_mult > enemy_distance && enemy_distance > 0) { chasing_enemy = true; @@ -257,8 +280,6 @@ public Action recursive_pressing(Handle timer, any data) if (round_start_stuck) bot_stuck = is_bot_stuck(); } - //TODO detect gaps and jump perfectly over them - if (IsValidClient(targethuman)) Format(message, sizeof(message), "dist_target: %f targethuman: %N bot_on_type: %i enemy_distance: %f bot_stuck: %i targeteam: %i", dist_target, targethuman, bot_on_type, enemy_distance, bot_stuck, targeteam); else