more updates regarding input, targeting, jumping and such

This commit is contained in:
jenzur 2020-09-22 22:10:24 +02:00
parent 06a4a6eea5
commit 3afffae783
2 changed files with 38 additions and 24 deletions

View File

@ -71,9 +71,10 @@ def bot_process_movement(input_line):
enemy_distance = float(enemy_distance)
bot_on_type = int(bot_on_type)
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; "
min_distance_target_human = 12800.0
strInput = "wait 2; -use; wait 5; -jump; wait 5; -duck; wait 5; +attack; wait 5; cl_minmodels 1; wait 2; +use; +forward; wait 2; "
if dist_target > min_distance_target_human:
print('dist_target: ', dist_target)
strInput += "use weapon_elite; wait 3; "
elif targeteam == 3:
strInput += "use weapon_p90; wait 3; "
@ -91,9 +92,11 @@ def bot_process_movement(input_line):
for _ in range(5):
strInput += "+jump; wait 5;"
if enemy_distance > 0:
print('date: ', datetime.datetime.now().time(), ' target_enemy: ', target_enemy, ' enemy distance: ', enemy_distance)
pass
#print('date: ', datetime.datetime.now().time(), ' target_enemy: ', target_enemy, ' enemy distance: ', enemy_distance)
else:
print('date: ', datetime.datetime.now().time(), ' target human: ', targethuman, ' dist_target: ', dist_target,)
pass
#print('date: ', datetime.datetime.now().time(), ' target human: ', targethuman, ' dist_target: ', dist_target,)
strInput = strinput_append(strInput, 2)
#print('strInput final:', strInput)
writeCfgInput(strInput)
@ -141,11 +144,11 @@ if __name__ == '__main__':
sock_external = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
sock.bind(("", local_port))
messager_name_index = []
print('reached deadlock')
try:
while True:
data, addr = sock.recvfrom(buffer_size)
databyte = data
data = codecs.decode(data, "utf-8", "ignore")
ip = addr[0]
port = addr[1]
@ -155,8 +158,11 @@ if __name__ == '__main__':
if ip not in [local_ip, udp_external_ip]:
continue
if ip == udp_external_ip:
response_msg = f"""say {data}"""
print("enabled remote UDP packet response_msg: ", response_msg)
messager_name = messager_name_index.pop(0)
if messager_name in data:
messager_name = ""
response_msg = f"""say {messager_name} {data}"""
print("remote UDP packet response_msg: ", response_msg)
writeCfgInput(response_msg)
#needs mini delay to have time to write input to console
time.sleep(0.1)
@ -174,9 +180,11 @@ if __name__ == '__main__':
print('connection_issue_counter: ', connection_issue_counter)
bot_connect_ze()
elif "clientmessage:" in data:
sock_external.sendto(databyte, (udp_external_ip, local_port))
iterator = 3
print('enabled send databyte: ', databyte)
messager_name = data.split("clientmessage:", 1)[1].split(" 72DqZ84")[0]
databyte_send_message = messager_name + data.split("72DqZ84")[1]
sock_external.sendto(databyte_send_message.encode(), (udp_external_ip, local_port))
print('databyte_send_message: ', databyte_send_message)
messager_name_index.append(messager_name)
elif data.startswith("dist_target:"):
bot_process_movement(data)
elif data.startswith("surfing:"):
@ -185,16 +193,17 @@ if __name__ == '__main__':
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;"
smallest_distance_caps = [70.0, 85.0, 150.0, 200.0]
dot_product_jump_cap = 0.0
print(colored_text)
if smallest_distance_caps[0] < distance < smallest_distance_caps[1] or smallest_distance_caps[2] < distance < smallest_distance_caps[3]:
strInput += "+jump; wait 50; +duck; wait 50; -duck; -jump;"
elif dot_product < dot_product_jump_cap:
strInput += "+jump; wait 550; +duck; wait 250; -jump; -duck; wait 50;"
print('dot product:', dot_product)
#strInput += "+jump; wait 50; +duck; wait 50; -jump; -duck;"
writeCfgInput(strInput)
time.sleep(0.1)
writeCfgInput("")

View File

@ -140,7 +140,7 @@ public bool distance_check()
public Action cmd_talk(int client, int args)
{
char msg[generic_length];
char msg[generic_length * 5];
char info[generic_length];
GetCmdArgString(info, sizeof(info));
if (strlen(info) == 0)
@ -150,7 +150,9 @@ public Action cmd_talk(int client, int args)
}
if (IsValidClient(present))
{
Format(msg, sizeof(msg), "clientmessage: %s", info);
char magic_code[16];
Format(magic_code, sizeof(magic_code), "72DqZ84");
Format(msg, sizeof(msg), "clientmessage:%N %s %s", client, magic_code, info);
send_socket_msg(msg, strlen(msg));
}
else
@ -167,7 +169,7 @@ public void Event_RoundStart(Handle event, const char[] name, bool dontBroadcast
public void OnMapStart()
{
//0.2 too spammmy, 1.5 too slow
CreateTimer(0.65, recursive_pressing, INVALID_HANDLE, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE);
CreateTimer(0.70, 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);
}
@ -311,13 +313,13 @@ public Action recursive_pressing(Handle timer, any data)
}
if (IsValidClient(target_enemy))
{
float min_enemy_distance = 10000.0;
GetEntPropVector(target_enemy, Prop_Send, "m_vecOrigin", pos);
enemy_distance = get_power_distance(present, pos);
//human aiming for zombie
if (targeteam == 3)
{
float min_distance_target_human = 800.0;
float min_distance_target_human = 12800.0;
float min_enemy_distance = min_distance_target_human * 8;
if (0 < dist_target <= min_distance_target_human && enemy_distance > min_enemy_distance)
{
chasing_enemy = true;
@ -396,9 +398,12 @@ public void wall_circle()
}
}
}
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));
if (!(GetEntityMoveType(present) & MOVETYPE_LADDER))
{
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