updates to printing and trimming overload
This commit is contained in:
parent
2ce3e073c0
commit
06a4a6eea5
@ -20,21 +20,20 @@ def colored(r, g, b, text):
|
||||
|
||||
def writeCfgInput(Input_user):
|
||||
with open(looptestPath, 'w') as f:
|
||||
time.sleep(0.2)
|
||||
colored_text = colored(255, 0, 0, ('Input: ' + Input_user))
|
||||
#print(colored_text)
|
||||
f.write(Input_user)
|
||||
|
||||
def exit_handler():
|
||||
print('reached exithandler')
|
||||
writeCfgInput('wait 5;')
|
||||
writeCfgInput('')
|
||||
|
||||
def joinTeam():
|
||||
str = "jointeam 2; joinclass 3; zspawn;"
|
||||
writeCfgInput(str)
|
||||
print('jointeam func: ')
|
||||
time.sleep(4.5)
|
||||
writeCfgInput('wait 5;')
|
||||
writeCfgInput('')
|
||||
|
||||
def bot_process_surf(input_line):
|
||||
bot_surf_plane = input_line[input_line.index("surfing:") + len("surfing:"):]
|
||||
@ -56,23 +55,14 @@ def bot_process_surf(input_line):
|
||||
strInput += "+moveright; wait 3; "
|
||||
print('date: ', datetime.datetime.now().time(),'bot surfing bot_surf_plane: ', bot_surf_plane)
|
||||
writeCfgInput(strInput)
|
||||
writeCfgInput("wait 5;")
|
||||
|
||||
def bot_process_keyinput(input_line):
|
||||
movement_input = input_line[input_line.index("keyinput:") + len("keyinput:"):input_line.index("dist_target:")]
|
||||
dist_target = input_line[input_line.index("dist_target:") + len("dist_target:"):]
|
||||
dist_target = float(dist_target)
|
||||
strInput = f"""{movement_input}; wait 5; -jump; wait 5; -duck; wait 5; """
|
||||
writeCfgInput(strInput)
|
||||
print('MIMIC date: ', datetime.datetime.now().time(), ' dist_target: ', dist_target, ' movement strinput: ', strInput)
|
||||
writeCfgInput("wait 5;")
|
||||
time.sleep(0.1)
|
||||
writeCfgInput("")
|
||||
|
||||
def bot_process_movement(input_line):
|
||||
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:"):input_line.index("enemy_distance:")]
|
||||
enemy_distance = input_line[input_line.index("enemy_distance:") + len("enemy_distance:"):input_line.index("dot_product:")]
|
||||
dot_product = input_line[input_line.index("dot_product:") + len("dot_product:"):input_line.index("targeteam:")]
|
||||
enemy_distance = input_line[input_line.index("enemy_distance:") + len("enemy_distance:"):input_line.index("targeteam:")]
|
||||
targeteam = input_line[input_line.index("targeteam:") + len("targeteam:"):input_line.index("target_enemy:")]
|
||||
target_enemy = input_line[input_line.index("target_enemy:") + len("target_enemy:"):input_line.index("z_axis:")]
|
||||
z_axis = input_line[input_line.index("z_axis:") + len("z_axis:"):]
|
||||
@ -80,18 +70,9 @@ def bot_process_movement(input_line):
|
||||
z_axis = float(z_axis)
|
||||
enemy_distance = float(enemy_distance)
|
||||
bot_on_type = int(bot_on_type)
|
||||
dot_product = float(dot_product)
|
||||
targeteam = int(targeteam)
|
||||
min_distance_target_human = 800.0
|
||||
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; "
|
||||
crouch_cap = 5000.0
|
||||
jump_cap = 12000.0
|
||||
if 0.0 < dot_product <= crouch_cap:
|
||||
#print('crouching', datetime.datetime.now().time())
|
||||
strInput += "+duck; wait 1500; +jump; -duck; wait 250; -jump; wait 50;"
|
||||
elif 0.0 < dot_product <= jump_cap:
|
||||
#print('jumping', datetime.datetime.now().time())
|
||||
strInput += "+jump; wait 350; +duck; wait 250; -jump; -duck; wait 50;"
|
||||
if dist_target > min_distance_target_human:
|
||||
strInput += "use weapon_elite; wait 3; "
|
||||
elif targeteam == 3:
|
||||
@ -116,7 +97,8 @@ def bot_process_movement(input_line):
|
||||
strInput = strinput_append(strInput, 2)
|
||||
#print('strInput final:', strInput)
|
||||
writeCfgInput(strInput)
|
||||
writeCfgInput("wait 5;")
|
||||
time.sleep(0.1)
|
||||
writeCfgInput("")
|
||||
|
||||
def strinput_append(strInput, nth):
|
||||
for _ in range(10 * nth):
|
||||
@ -145,7 +127,7 @@ def bot_connect_ze():
|
||||
str1 = "connect 151.80.230.149:27015;"
|
||||
writeCfgInput(str1)
|
||||
time.sleep(0.4)
|
||||
writeCfgInput('wait 5;')
|
||||
writeCfgInput('')
|
||||
print('not yet connected')
|
||||
|
||||
if __name__ == '__main__':
|
||||
@ -176,8 +158,9 @@ if __name__ == '__main__':
|
||||
response_msg = f"""say {data}"""
|
||||
print("enabled remote UDP packet response_msg: ", response_msg)
|
||||
writeCfgInput(response_msg)
|
||||
time.sleep(1)
|
||||
writeCfgInput("wait 5;")
|
||||
#needs mini delay to have time to write input to console
|
||||
time.sleep(0.1)
|
||||
writeCfgInput("")
|
||||
if data == "autismo connected":
|
||||
print('Bot connected!')
|
||||
connection_issue_counter = 0
|
||||
@ -198,8 +181,24 @@ if __name__ == '__main__':
|
||||
bot_process_movement(data)
|
||||
elif data.startswith("surfing:"):
|
||||
bot_process_surf(data)
|
||||
elif data.startswith("keyinput:"):
|
||||
bot_process_keyinput(data)
|
||||
elif data.startswith("smallest_dot_product"):
|
||||
dot_product = data[data.index("smallest_dot_product:") + len("smallest_dot_product:"):data.index("smallest_distance:")]
|
||||
distance = data[data.index("smallest_distance:") + len("smallest_distance:"):]
|
||||
colored_text = colored(255, 0, 0, ('smallest_dot_product: ' + dot_product + ' smallest_distance: ', distance))
|
||||
print(colored_text)
|
||||
dot_product = float(dot_product)
|
||||
distance = float(distance)
|
||||
strInput = ""
|
||||
distance_jump_cap = 80.0
|
||||
dot_product_jump_cap = 14500.0
|
||||
if distance < distance_jump_cap:
|
||||
strInput += "+duck; wait 1500; +jump; -duck; wait 250; -jump; wait 50;"
|
||||
elif dot_product < dot_product_jump_cap:
|
||||
strInput += "+jump; wait 550; +duck; wait 250; -jump; -duck; wait 50;"
|
||||
writeCfgInput(strInput)
|
||||
time.sleep(0.1)
|
||||
writeCfgInput("")
|
||||
|
||||
except KeyboardInterrupt:
|
||||
pass
|
||||
finally:
|
||||
|
@ -24,8 +24,6 @@ float targethuman_teleported[3];
|
||||
float g_vCurrent[3];
|
||||
float g_vLast[3];
|
||||
bool client_stuck_g[MAXPLAYERS + 1];
|
||||
bool round_start_stuck = false;
|
||||
bool cmdpost_run_cooldown = false;
|
||||
|
||||
//admins & vips
|
||||
bool admins[MAXPLAYERS + 1];
|
||||
@ -61,8 +59,6 @@ public void OnPluginStart()
|
||||
SocketBind(socket, "127.0.0.1", 48475);
|
||||
connect(socket);
|
||||
global_socket = socket;
|
||||
round_start_stuck = true;
|
||||
cmdpost_run_cooldown = false;
|
||||
reset_target_human_tp_coord();
|
||||
targethuman = 0;
|
||||
}
|
||||
@ -164,23 +160,14 @@ public Action cmd_talk(int client, int args)
|
||||
|
||||
public void Event_RoundStart(Handle event, const char[] name, bool dontBroadcast)
|
||||
{
|
||||
round_start_stuck = false;
|
||||
targethuman = 0;
|
||||
cmdpost_run_cooldown = false;
|
||||
reset_target_human_tp_coord();
|
||||
CreateTimer(7.0, permitStuck);
|
||||
}
|
||||
|
||||
public Action permitStuck(Handle timer, any data)
|
||||
{
|
||||
round_start_stuck = true;
|
||||
return Plugin_Continue;
|
||||
}
|
||||
|
||||
public void OnMapStart()
|
||||
{
|
||||
//0.2 too spammmy, 1.5 too slow
|
||||
CreateTimer(0.85, recursive_pressing, INVALID_HANDLE, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE);
|
||||
CreateTimer(0.65, recursive_pressing, INVALID_HANDLE, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE);
|
||||
CreateTimer(1.0, clients_coordinates, INVALID_HANDLE, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE);
|
||||
CreateTimer(10.0, bot_check_connect, INVALID_HANDLE, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE);
|
||||
}
|
||||
@ -221,39 +208,11 @@ public Action bot_check_connect(Handle timer, any data)
|
||||
return Plugin_Continue;
|
||||
}
|
||||
|
||||
public Action runcmd_cooldown(Handle timer, any data)
|
||||
{
|
||||
cmdpost_run_cooldown = false;
|
||||
return Plugin_Continue;
|
||||
}
|
||||
|
||||
public void OnPlayerRunCmdPost(int client, int buttons, int impulse, const float vel[3], const float angles[3], int weapon, int subtype,
|
||||
int cmdnum, int tickcount, int seed, const int mouse[2])
|
||||
{
|
||||
if (!IsClientInGame(client)) return;
|
||||
if (client == targethuman && round_start_stuck && IsValidClient(present) && !cmdpost_run_cooldown)
|
||||
{
|
||||
char keyinput[generic_length * 5];
|
||||
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];
|
||||
GetEntPropVector(targethuman, Prop_Send, "m_vecOrigin", pos);
|
||||
float dist_target = get_power_distance(present, pos);
|
||||
//prior 1500.0
|
||||
//TODO
|
||||
float dist_cap = 50000.0;
|
||||
if (dist_target < dist_cap)
|
||||
{
|
||||
Format(keyinput, sizeof(keyinput), "keyinput: %s dist_target: %f", keyinput, dist_target);
|
||||
send_socket_msg(keyinput, strlen(keyinput));
|
||||
cmdpost_run_cooldown = true;
|
||||
CreateTimer(0.5, runcmd_cooldown);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (client == present)
|
||||
if (client == present)
|
||||
{
|
||||
int flags = GetEntityFlags(client);
|
||||
if (!(flags & FL_ONGROUND) && (flags_old & FL_ONGROUND) && !(buttons_old & IN_JUMP) && !(buttons & IN_JUMP))
|
||||
@ -273,7 +232,6 @@ public void OnPlayerRunCmdPost(int client, int buttons, int impulse, const float
|
||||
}
|
||||
Vel[2] += velocity_addition_z_axis;
|
||||
TeleportEntity(client, NULL_VECTOR, NULL_VECTOR, Vel);
|
||||
check_bot_surfing();
|
||||
}
|
||||
buttons_old = buttons;
|
||||
flags_old = flags;
|
||||
@ -342,7 +300,6 @@ 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;
|
||||
float dot_product = 0.0;
|
||||
float z_axis = 0.0;
|
||||
if (bot_on_type != 0 && bot_on_type != 4)
|
||||
{
|
||||
@ -390,14 +347,13 @@ public Action recursive_pressing(Handle timer, any data)
|
||||
}
|
||||
if (IsValidClient(targethuman) && !chasing_enemy)
|
||||
face_call(targethuman);
|
||||
//0: nothing, dot_product = crouch_cap = 5000.0; dot_product = jump_cap = 100000.0;
|
||||
dot_product = wall_circle();
|
||||
wall_circle();
|
||||
}
|
||||
char message[generic_length * 7];
|
||||
if (IsValidClient(targethuman))
|
||||
Format(message, sizeof(message), "dist_target: %f targethuman: %N bot_on_type: %i enemy_distance: %f dot_product: %f targeteam: %i", dist_target, targethuman, bot_on_type, enemy_distance, dot_product, targeteam);
|
||||
Format(message, sizeof(message), "dist_target: %f targethuman: %N bot_on_type: %i enemy_distance: %f targeteam: %i", dist_target, targethuman, bot_on_type, enemy_distance, targeteam);
|
||||
else
|
||||
Format(message, sizeof(message), "dist_target: %f targethuman: none bot_on_type: %i enemy_distance: %f dot_product: %f targeteam: %i", dist_target, bot_on_type, enemy_distance, dot_product, targeteam);
|
||||
Format(message, sizeof(message), "dist_target: %f targethuman: none bot_on_type: %i enemy_distance: %f targeteam: %i", dist_target, bot_on_type, enemy_distance, targeteam);
|
||||
if (IsValidClient(target_enemy))
|
||||
Format(message, sizeof(message), "%s target_enemy: %N z_axis: %f", message, target_enemy, z_axis);
|
||||
else
|
||||
@ -408,8 +364,10 @@ public Action recursive_pressing(Handle timer, any data)
|
||||
return Plugin_Continue;
|
||||
}
|
||||
|
||||
public float wall_circle()
|
||||
public void wall_circle()
|
||||
{
|
||||
float smallest_dot_product = -1.0;
|
||||
float smallest_distance = -1.0;
|
||||
//Circle:
|
||||
for (int iterator = 0; iterator < 3; iterator++)
|
||||
{
|
||||
@ -431,22 +389,20 @@ public float wall_circle()
|
||||
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;
|
||||
//TODO maybe 50.0 again
|
||||
float distance_cap = 100.0;
|
||||
if (distance <= distance_cap)
|
||||
{
|
||||
if (dot_product <= crouch_cap || dot_product <= jump_cap)
|
||||
return dot_product;
|
||||
}
|
||||
|
||||
if (distance < smallest_distance || smallest_distance == -1.0)
|
||||
smallest_distance = distance;
|
||||
if (dot_product < smallest_dot_product || smallest_dot_product == -1.0)
|
||||
smallest_dot_product = dot_product;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0.0;
|
||||
char message[generic_length * 7];
|
||||
Format(message, sizeof(message), "smallest_dot_product: %f smallest_distance: %f", smallest_dot_product, smallest_distance);
|
||||
send_socket_msg(message, strlen(message));
|
||||
}
|
||||
|
||||
//TODO implement surfing again but differently
|
||||
//check_bot_surfing();
|
||||
public void check_bot_surfing()
|
||||
{
|
||||
float vPos[3];
|
||||
@ -588,8 +544,6 @@ stock bool IsValidClient(int client)
|
||||
|
||||
stock bool is_client_stuck_or_afk(int client)
|
||||
{
|
||||
if (!round_start_stuck)
|
||||
return false;
|
||||
float min_distance_cap = 2.0;
|
||||
float client_own_distance = get_power_distance(client, client_old_coords[client]);
|
||||
client_stuck_g[client] = client_own_distance < min_distance_cap;
|
||||
|
Loading…
Reference in New Issue
Block a user