From 74652f9d1853eff7ffe5d860708539bd99fe1f12 Mon Sep 17 00:00:00 2001 From: jenzur Date: Mon, 24 Aug 2020 01:04:59 +0200 Subject: [PATCH] furhter updates to team joining as well as wall proximity to help with crouching/jumping --- AutismBotIngame/python/ingamefollowct.py | 11 ++-- AutismBotIngame/scripting/autism_bot_info.sp | 64 +++++++++++--------- 2 files changed, 42 insertions(+), 33 deletions(-) diff --git a/AutismBotIngame/python/ingamefollowct.py b/AutismBotIngame/python/ingamefollowct.py index bd2ef639..cf93cfa9 100644 --- a/AutismBotIngame/python/ingamefollowct.py +++ b/AutismBotIngame/python/ingamefollowct.py @@ -30,7 +30,7 @@ def exit_handler(): resetCfgInputShortWait() def joinTeam(): - str = "jointeam 2; wait 2; zspawn; wait 1; {0}; wait 5;" + str = "jointeam 2; wait 2; zspawn; wait 1; wait 5;" writeCfgInput(str) time.sleep(4.5) print('jointeam func: ') @@ -85,9 +85,12 @@ def bot_process_movement(input_line): #maybe 0.8 instead min_distance_target_human = 0.1 strInput = "-attack; wait 2; -use; wait 5; -jump; wait 5; -duck; wait 5; +attack; wait 5; cl_minmodels 1; wait 2; +use; +forward; wait 2; " - if crouch_or_jump > 0: - print('crouch_or_jump') - strInput += "+jump; wait 5; +duck; wait 5; -jump; wait 500; -duck; wait 3;" + if crouch_or_jump == 2: + print('crouching') + strInput += "+duck; wait 1500; -duck; wait 50;" + if crouch_or_jump == 3: + print('jumping') + strInput += "+jump; wait 750; +duck; wait 750; -jump; wait 500; -duck; wait 500; +jump; wait 1000; -jump; " if dist_target > min_distance_target_human: strInput += "use weapon_elite; wait 3; " elif targeteam == 3: diff --git a/AutismBotIngame/scripting/autism_bot_info.sp b/AutismBotIngame/scripting/autism_bot_info.sp index 59ad689c..0a1b0a2a 100644 --- a/AutismBotIngame/scripting/autism_bot_info.sp +++ b/AutismBotIngame/scripting/autism_bot_info.sp @@ -276,6 +276,12 @@ public Action recursive_pressing(Handle timer, any data) { if (IsValidClient(present) && IsPlayerAlive(present)) { + if (GetClientTeam(present) == 1) + { + //prevent him being stuck afk in spec + bot_send_connected_msg(); + return Plugin_Continue; + } char message[generic_length * 7]; float present_bot_coords[3]; GetClientAbsOrigin(present, present_bot_coords); @@ -335,7 +341,7 @@ public Action recursive_pressing(Handle timer, any data) int target_enemy = find_closest_enemy(present, targeteam); bool chasing_enemy = false; float dist_target = -1.0; - bool crouch_or_jump = false; + int crouch_or_jump = 0; if (bot_on_type != 0 && bot_on_type != 2 && bot_on_type != 4) { float pos[3]; @@ -373,6 +379,7 @@ public Action recursive_pressing(Handle timer, any data) } if (IsValidClient(targethuman) && !chasing_enemy) face_call(targethuman); + //0: nothing, 2: crouch, 3: jump crouch_or_jump = wall_circle(); } if (bot_on_type != 2) @@ -387,44 +394,43 @@ public Action recursive_pressing(Handle timer, any data) return Plugin_Continue; } -public bool wall_circle() +public int wall_circle() { - //TODO maybe - float min_cap_distance = 50.0; - for (float AngleRotate = 0.0; AngleRotate < 360.0; AngleRotate += 30.0) + //Circle: + for (int iterator = 0; iterator < 3; iterator++) + { + float angle_start = -360.0; //should be -180.0 ofc + float angle_end = 360.0; + for (float AngleRotate = angle_start; AngleRotate <= angle_end; AngleRotate += 10.0) { - float StartOrigin[3]; + float StartOrigin[3]; float Angles[3]; - Angles[0] = 0.0; - Angles[1] = AngleRotate; - Angles[2] = 0.0; + GetClientEyeAngles(present, Angles); + Angles[iterator] = AngleRotate; GetClientEyePosition(present, StartOrigin); - TR_TraceRayFilter(StartOrigin, Angles, MASK_SOLID, RayType_Infinite, TraceRayDontHitSelf); + TR_TraceRayFilter(StartOrigin, Angles, MASK_SOLID, RayType_Infinite, TraceRayDontHitSelf, present); if (TR_DidHit()) { float EndOrigin[3]; TR_GetEndPosition(EndOrigin, INVALID_HANDLE); - float Distance = (GetVectorDistance(StartOrigin, EndOrigin)); - if (Distance < min_cap_distance) - return true; - } - float StartOrigin1[3]; - float Angles1[3]; - Angles1[0] = AngleRotate; - Angles1[1] = 0.0; - Angles1[2] = 0.0; - GetClientEyePosition(present, StartOrigin1); - TR_TraceRayFilter(StartOrigin1, Angles1, MASK_SOLID, RayType_Infinite, TraceRayDontHitSelf); - if (TR_DidHit()) - { - float EndOrigin[3]; - TR_GetEndPosition(EndOrigin, INVALID_HANDLE); - float Distance = (GetVectorDistance(StartOrigin1, EndOrigin)); - if (Distance < min_cap_distance) - return true; + float dot_product = GetVectorDotProduct(StartOrigin, EndOrigin); + dot_product = dot_product / 1000; + float distance = GetVectorDistance(StartOrigin, EndOrigin); + float crouch_cap = 5000.0; + float jump_cap = 100000.0; + float distance_cap = 50.0; + if (distance <= distance_cap) + { + if (dot_product <= crouch_cap) + return 2; + else if (dot_product <= jump_cap) + return 3; + } + } } - return false; + } + return 0; } public void check_bot_surfing()