diff --git a/AutismBotIngame/python/ingamefollowct.py b/AutismBotIngame/python/ingamefollowct.py index c3508fdb..9c98c83a 100644 --- a/AutismBotIngame/python/ingamefollowct.py +++ b/AutismBotIngame/python/ingamefollowct.py @@ -31,86 +31,57 @@ def joinTeam(): writeCfgInput(str) time.sleep(4.5) print('jointeam func: ') - def bot_process_movement(input_line): - movement_list = [1, 0] - strInput = "-attack; wait 2; -use; wait 5; -jump; wait 5; -duck; wait 5; +attack; wait 5; cl_minmodels 1; wait 2; +use; " - movement_input = input_line[input_line.index("keyinput:") + len("keyinput:"):input_line.index("clientangles:")] client_angles = input_line[input_line.index("clientangles:") + len("clientangles:"):input_line.index("xyz:")] - xyz_difference = input_line[input_line.index("xyz:") + len("xyz:"):input_line.index("stuckX:")] - stuckx = input_line[input_line.index("stuckX:") + len("stuckX:"):input_line.index("stuckY:")] - stucky = input_line[input_line.index("stuckY:") + len("stuckY:"):input_line.index("dist_target:")] + xyz_difference = input_line[input_line.index("xyz:") + len("xyz:"):input_line.index("dist_target:")] dist_target = input_line[input_line.index("dist_target:") + len("dist_target:"):input_line.index("targethuman:")] targethuman = input_line[input_line.index("targethuman:") + len("targethuman:"):input_line.index("bot_on_type:")] bot_on_type = input_line[input_line.index("bot_on_type:") + len("bot_on_type:"):] dist_target = float(dist_target) xyz_difference = xyz_difference.strip() - xyz_difference = [float(i.replace('\U00002013', '-')) for i in xyz_difference.split(' ')] - stuckx = int(stuckx) - stucky = int(stucky) bot_on_type = int(bot_on_type) + strInput = "" + if dist_target < 100.0: + strInput += "-forward; wait 3; -back; wait 3; -moveleft; wait 3; -moveright; wait 3; " + strInput += "-attack; wait 2; -use; wait 5; -jump; wait 5; -duck; wait 5; +attack; wait 5; cl_minmodels 1; wait 2; +use; " + + if random.randint(0, 100) < 37 and random.randint(0, 100) > 63: + strInput += "wait 5; +jump; wait 5; +duck; " + if bot_on_type == 0: print('bot_on_type ladder ') - strInput += "setang -90 0 0; wait 5; -back; wait 3; -moveleft; wait 3; -moveright; wait 5; +forward; wait 5;" + strInput += "setang -90 90 0; wait 5; -back; wait 3; -moveleft; wait 3; -moveright; wait 5; +forward; wait 5;" + elif bot_on_type == 2: + print('bot surfing') + #make some setup to allow surfing/mimic else: if bot_on_type == 1: print('bot_on_type water') strInput += "+jump; wait 5;" - if dist_target > 300.0: - axis_distance = 150.0 - if stuckx: - print('stuckX enabled') - if movement_list[0] == 0: - movement_list[0] = 1 - elif movement_list[0] == 1: - movement_list[0] = 0 - strInput += " +jump; wait 3; +duck; wait 5;" - if stucky: - print('stuckY enabled') - if movement_list[1] == 0: - movement_list[1] = 1 - elif movement_list[1] == 1: - movement_list[1] = 0 - strInput += " +jump; wait 3; +duck; wait 5;" - print('hunt mode: target human: ', targethuman) - print('stuckx: ', stuckx, ' stuckY: ', stucky) - #print('movement_list: ', movement_list) - if not stuckx and not stucky: - #print('xyz_difference: ', xyz_difference) - if xyz_difference[0] > axis_distance: - movement_list[0] = 1 - elif xyz_difference[0] < -axis_distance: - movement_list[0] = 0 - - if xyz_difference[1] < -axis_distance: - movement_list[1] = 1 - elif xyz_difference[1] > axis_distance: - movement_list[1] = 0 - - if movement_list[0] == 1: - strInput += " -back; wait 5; +forward; wait 5;" - elif movement_list[0] == 0: - strInput += " -forward; wait 5; +back; wait 5;" - if movement_list[1] == 1: - strInput += " -moveleft; wait 5; +moveright; wait 5;" - elif movement_list[1] == 0: - strInput += " -moveright; wait 5; +moveleft; wait 5;" - - #print('xyz_difference[0]: ', xyz_difference[0]) - #print('xyz_difference[1]: ', xyz_difference[1]) - #print('movement_list[0]: ', movement_list[0], '0 = back. 1 = forward.') - #print('movement_list[1]: ', movement_list[1], '0 = moveleft. 1 = moveright') - strInput += f""" setang 0 180 0; wait 5; """ - else: - print('mimic mode enabled! dist_target: ', dist_target, ' targethuman: ', targethuman) - #print('movemenet_input: ', movement_input) + print('target human: ', targethuman, ' dist_target: ', dist_target) + #print('movemenet_input: ', movement_input) + if dist_target < 400.0: strInput += f"""setang {client_angles}; wait 5; {movement_input}; wait 5; """ - print('strInput final:', strInput) + if not movement_input or dist_target > 400: + strInput += f""" setang 0 180 0; wait 5; """ + #print('xyz_difference: ', xyz_difference) + axis_distance = 25.0 + if xyz_difference[0] > axis_distance: + strInput += " -back; wait 5; +forward; wait 5;" + elif xyz_difference[0] < axis_distance * -1: + strInput += " -forward; wait 5; +back; wait 5;" + + if xyz_difference[1] < axis_distance * -1: + strInput += " -moveleft; wait 5; +moveright; wait 5;" + elif xyz_difference[1] > axis_distance: + strInput += " -moveright; wait 5; +moveleft; wait 5;" + + #print('strInput final:', strInput) writeCfgInput(strInput) - time.sleep(0.2) + time.sleep(0.1) writeCfgInput("wait 5;") def bot_connect_ze(): diff --git a/AutismBotIngame/scripting/autism_bot_info.sp b/AutismBotIngame/scripting/autism_bot_info.sp index 625de812..9a88c969 100644 --- a/AutismBotIngame/scripting/autism_bot_info.sp +++ b/AutismBotIngame/scripting/autism_bot_info.sp @@ -14,8 +14,6 @@ int present = 0; int targethuman = 0; -int stuckcounterx = 0; -int stuckcountery = 0; //admins & vips int admins[MAXPLAYERS + 1]; @@ -72,7 +70,7 @@ public void Event_RoundStart(Handle event, const char[] name, bool dontBroadcast public void OnMapStart() { - CreateTimer(0.3, recursive_pressing, INVALID_HANDLE, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE); + CreateTimer(0.1, recursive_pressing, INVALID_HANDLE, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE); CreateTimer(10.0, bot_check_connect, INVALID_HANDLE, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE); } @@ -103,33 +101,8 @@ public Action recursive_pressing(Handle timer, any data) { if (IsValidClient(present) && IsPlayerAlive(present)) { - int stuckX; - int stuckY; float flVel[3]; - float minvelocity = 40.0; char message[generic_length * 7]; - //stuckcounterx, stuckcountery - float mincapvelocity = 40.0; - GetEntPropVector(present, Prop_Data, "m_vecAbsVelocity", flVel); - int stuckcap = 6; - if (flVel[0] < mincapvelocity) - { - if (stuckcounterx >= stuckcap) - { - stuckcounterx = 0; - stuckX = 1; - } - stuckcounterx++; - } - if (flVel[1] < mincapvelocity) - { - if (stuckcountery >= stuckcap) - { - stuckcountery = 0; - stuckY = 1; - } - stuckcountery++; - } float present_bot_coords[3]; GetClientAbsOrigin(present, present_bot_coords); int targeteam = 0; @@ -144,8 +117,7 @@ public Action recursive_pressing(Handle timer, any data) targeteam = 3; } bool find_closest_match = true; - float dist_target = 0.0; - float distance_limit = 500.0; + float distance_limit = 100.0; if (IsValidClient(targethuman) && GetClientTeam(targethuman) == targeteam && IsPlayerAlive(targethuman)) { float pos[3]; @@ -153,9 +125,15 @@ public Action recursive_pressing(Handle timer, any data) float dx = present_bot_coords[0] - pos[0]; float dy = present_bot_coords[1] - pos[1]; float dz = FloatAbs(present_bot_coords[2] - pos[2]); - dist_target = SquareRoot(dx*dx + dy*dy + dz*dz); + float dist_target = SquareRoot(dx*dx + dy*dy + dz*dz); GetEntPropVector(targethuman, Prop_Data, "m_vecAbsVelocity", flVel); - if (dist_target < distance_limit && flVel[0] > minvelocity && flVel[1] > minvelocity) + if (admins[targethuman]) + distance_limit = distance_limit * 5; + else if (vips[targethuman]) + distance_limit = distance_limit * 2.5; + if (flVel[0] < 100.0 && flVel[1] < 100.0) + find_closest_match = false; + if (dist_target < distance_limit) find_closest_match = false; } if (find_closest_match) @@ -163,6 +141,7 @@ public Action recursive_pressing(Handle timer, any data) float lowest_distance = 1000000.0; bool adminpresent = false; bool vippresent = false; + float dist_target = 0.0; for (int i = 1; i <= MaxClients; i++) if (IsValidClient(i) && IsPlayerAlive(i) && GetClientTeam(i) == targeteam && i != present) { @@ -173,12 +152,12 @@ public Action recursive_pressing(Handle timer, any data) float dz = FloatAbs(present_bot_coords[2] - pos[2]); dist_target = SquareRoot(dx*dx + dy*dy + dz*dz); - if (admins[i] == 1 && dist_target < distance_limit) + if (admins[i] == 1 && dist_target < distance_limit * 5) { adminpresent = true; vippresent = false; } - else if (vips[i] == 1 && !adminpresent && dist_target < distance_limit) + else if (vips[i] == 1 && !adminpresent && dist_target < distance_limit * 2.5) { vippresent = true; } @@ -193,10 +172,8 @@ public Action recursive_pressing(Handle timer, any data) continue; } GetEntPropVector(i, Prop_Data, "m_vecAbsVelocity", flVel); - if (flVel[0] < minvelocity && flVel[1] < minvelocity) + if (flVel[0] < 100.0 && flVel[1] < 100.0) continue; - - if (dist_target < lowest_distance) { lowest_distance = dist_target; @@ -209,6 +186,7 @@ public Action recursive_pressing(Handle timer, any data) float dx = 0.0; float dy = 0.0; float dz = 0.0; + float dist_target = 0.0; float target_human_original_coord[3]; GetClientAbsOrigin(targethuman, target_human_original_coord); dx = present_bot_coords[0] - target_human_original_coord[0]; @@ -219,9 +197,9 @@ public Action recursive_pressing(Handle timer, any data) char keyinput[generic_length * 2]; int counter = 0; int countercap = 5; - //check ladder = 0, water = 1, in air = 2 + //check ladder = 0, water = 1, in air(surfing) = 2 int bot_on_type = -1; - if (GetEntityMoveType(present) & MOVETYPE_LADDER) + if (GetEntityMoveType(present) == MOVETYPE_LADDER) bot_on_type = 0; int ilevel = GetEntProp(present, Prop_Data, "m_nWaterLevel"); if (ilevel >= 2) @@ -245,7 +223,7 @@ public Action recursive_pressing(Handle timer, any data) float clientangles[3]; GetClientAbsAngles(targethuman, clientangles); //PrintToChatAll("targethuman: %N", targethuman); - Format(message, sizeof(message), "keyinput: %s clientangles: %f %f %f xyz: %f %f %f stuckX: %i stuckY: %i dist_target: %f targethuman: %N bot_on_type: %i", keyinput, clientangles[0], clientangles[1], clientangles[2], dx, dy, dz, stuckX, stuckY, dist_target, targethuman, bot_on_type); + Format(message, sizeof(message), "keyinput: %s clientangles: %f %f %f xyz: %f %f %f dist_target: %f targethuman: %N bot_on_type: %i", keyinput, clientangles[0], clientangles[1], clientangles[2], dx, dy, dz, dist_target, targethuman, bot_on_type); send_socket_msg(message, strlen(message)); } }