some major updates to targeting and avoiding but still not done yet
This commit is contained in:
parent
3b7bf8d3f0
commit
bdc8fb6eb6
@ -13,7 +13,6 @@ import time
|
|||||||
|
|
||||||
looptestPath = '/home/gameservers/.steam/steam/steamapps/common/Counter-Strike Source/cstrike/cfg/looptest.cfg'
|
looptestPath = '/home/gameservers/.steam/steam/steamapps/common/Counter-Strike Source/cstrike/cfg/looptest.cfg'
|
||||||
chatmsg = ""
|
chatmsg = ""
|
||||||
ladder_counter = 0
|
|
||||||
|
|
||||||
def colored(r, g, b, text):
|
def colored(r, g, b, text):
|
||||||
return "\033[38;2;{};{};{}m{} \033[38;2;255;255;255m".format(r, g, b, text)
|
return "\033[38;2;{};{};{}m{} \033[38;2;255;255;255m".format(r, g, b, text)
|
||||||
@ -60,43 +59,24 @@ def bot_process_surf(input_line):
|
|||||||
|
|
||||||
def bot_process_movement(input_line):
|
def bot_process_movement(input_line):
|
||||||
dist_target = input_line[input_line.index("dist_target:") + len("dist_target:"):input_line.index("targethuman:")]
|
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:")]
|
targethuman = input_line[input_line.index("targethuman:") + len("targethuman:"):input_line.index("enemy_distance:")]
|
||||||
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("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:")]
|
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:")]
|
target_enemy = input_line[input_line.index("target_enemy:") + len("target_enemy:"):]
|
||||||
z_axis = input_line[input_line.index("z_axis:") + len("z_axis:"):]
|
|
||||||
dist_target = float(dist_target)
|
dist_target = float(dist_target)
|
||||||
z_axis = float(z_axis)
|
|
||||||
enemy_distance = float(enemy_distance)
|
enemy_distance = float(enemy_distance)
|
||||||
bot_on_type = int(bot_on_type)
|
|
||||||
targeteam = int(targeteam)
|
targeteam = int(targeteam)
|
||||||
min_distance_target_human = 12800.0
|
min_distance_target_human = 1280.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; "
|
strInput = "-attack; wait 2; -use; wait 5; +attack; wait 5; cl_minmodels 1; wait 2; +use; +forward; wait 2; "
|
||||||
if dist_target > min_distance_target_human:
|
if dist_target > min_distance_target_human:
|
||||||
print('dist_target: ', dist_target)
|
#print('dist_target: ', dist_target)
|
||||||
strInput += "use weapon_elite; wait 3; "
|
strInput += "use weapon_elite; wait 3; "
|
||||||
elif targeteam == 3:
|
elif targeteam == 3:
|
||||||
strInput += "use weapon_p90; wait 3; "
|
strInput += "use weapon_p90; wait 3; "
|
||||||
elif targeteam == 2:
|
elif targeteam == 2:
|
||||||
strInput += "use weapon_knife; wait 5; "
|
strInput += "use weapon_knife; wait 5; "
|
||||||
global ladder_counter
|
print('date: ', datetime.datetime.now().time(), ' target_enemy: ', target_enemy, ' enemy distance: ', enemy_distance, ' target human: ', targethuman,
|
||||||
if bot_on_type == 0 and ladder_counter < 100:
|
' dist_target: ', dist_target)
|
||||||
print('bot_on_type ladder, ladder_counter: ', ladder_counter)
|
|
||||||
strInput += "setang -90 0 0; wait 5; -back; wait 3; -moveleft; wait 3; -moveright; wait 5; -jump; wait 3; -duck; wait 3; "
|
|
||||||
ladder_counter += 1
|
|
||||||
else:
|
|
||||||
ladder_counter = 0
|
|
||||||
min_enemy_distance = 100.0
|
|
||||||
if bot_on_type == 3:
|
|
||||||
for _ in range(5):
|
|
||||||
strInput += "+jump; wait 5;"
|
|
||||||
if enemy_distance > 0:
|
|
||||||
pass
|
|
||||||
#print('date: ', datetime.datetime.now().time(), ' target_enemy: ', target_enemy, ' enemy distance: ', enemy_distance)
|
|
||||||
else:
|
|
||||||
pass
|
|
||||||
#print('date: ', datetime.datetime.now().time(), ' target human: ', targethuman, ' dist_target: ', dist_target,)
|
|
||||||
strInput = strinput_append(strInput, 2)
|
strInput = strinput_append(strInput, 2)
|
||||||
#print('strInput final:', strInput)
|
#print('strInput final:', strInput)
|
||||||
writeCfgInput(strInput)
|
writeCfgInput(strInput)
|
||||||
@ -129,10 +109,27 @@ def bot_connect_ze():
|
|||||||
strdev = "connect 151.80.230.149:27019/test132;"
|
strdev = "connect 151.80.230.149:27019/test132;"
|
||||||
str1 = "connect 151.80.230.149:27015;"
|
str1 = "connect 151.80.230.149:27015;"
|
||||||
writeCfgInput(str1)
|
writeCfgInput(str1)
|
||||||
time.sleep(0.4)
|
time.sleep(0.2)
|
||||||
writeCfgInput('')
|
writeCfgInput('')
|
||||||
print('not yet connected')
|
print('not yet connected')
|
||||||
|
|
||||||
|
def pairwise(it):
|
||||||
|
it = iter(it)
|
||||||
|
while True:
|
||||||
|
try:
|
||||||
|
yield next(it), next(it)
|
||||||
|
except StopIteration:
|
||||||
|
# no more elements in the iterator
|
||||||
|
return
|
||||||
|
|
||||||
|
def spam_jump_crouch_input():
|
||||||
|
str_input = ''
|
||||||
|
for _ in range(10):
|
||||||
|
str_input += '+jump; wait 5; +duck; '
|
||||||
|
for _ in range(10):
|
||||||
|
str_input += '-jump; wait 5; -duck; '
|
||||||
|
return str_input
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
atexit.register(exit_handler)
|
atexit.register(exit_handler)
|
||||||
local_ip = "127.0.0.1"
|
local_ip = "127.0.0.1"
|
||||||
@ -144,7 +141,7 @@ if __name__ == '__main__':
|
|||||||
sock_external = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
sock_external = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
||||||
sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
|
sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
|
||||||
sock.bind(("", local_port))
|
sock.bind(("", local_port))
|
||||||
messager_name_index = []
|
messager_name = ""
|
||||||
print('reached deadlock')
|
print('reached deadlock')
|
||||||
try:
|
try:
|
||||||
while True:
|
while True:
|
||||||
@ -158,7 +155,6 @@ if __name__ == '__main__':
|
|||||||
if ip not in [local_ip, udp_external_ip]:
|
if ip not in [local_ip, udp_external_ip]:
|
||||||
continue
|
continue
|
||||||
if ip == udp_external_ip:
|
if ip == udp_external_ip:
|
||||||
messager_name = messager_name_index.pop(0)
|
|
||||||
if messager_name in data:
|
if messager_name in data:
|
||||||
messager_name = ""
|
messager_name = ""
|
||||||
response_msg = f"""say {messager_name} {data}"""
|
response_msg = f"""say {messager_name} {data}"""
|
||||||
@ -184,30 +180,38 @@ if __name__ == '__main__':
|
|||||||
databyte_send_message = messager_name + data.split("72DqZ84")[1]
|
databyte_send_message = messager_name + data.split("72DqZ84")[1]
|
||||||
sock_external.sendto(databyte_send_message.encode(), (udp_external_ip, local_port))
|
sock_external.sendto(databyte_send_message.encode(), (udp_external_ip, local_port))
|
||||||
print('databyte_send_message: ', databyte_send_message)
|
print('databyte_send_message: ', databyte_send_message)
|
||||||
messager_name_index.append(messager_name)
|
|
||||||
elif data.startswith("dist_target:"):
|
elif data.startswith("dist_target:"):
|
||||||
bot_process_movement(data)
|
bot_process_movement(data)
|
||||||
elif data.startswith("surfing:"):
|
elif data.startswith("surfing:"):
|
||||||
bot_process_surf(data)
|
bot_process_surf(data)
|
||||||
elif data.startswith("smallest_dot_product"):
|
elif data.startswith("smallest_dot_product"):
|
||||||
dot_product = data[data.index("smallest_dot_product:") + len("smallest_dot_product:"):data.index("smallest_distance:")]
|
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:"):]
|
distance = data[data.index("smallest_distance:") + len("smallest_distance:"):data.index("end_origin_hud:")]
|
||||||
|
end_origin_hud = data[data.index("end_origin_hud:") + len("end_origin_hud:"):]
|
||||||
colored_text = colored(255, 0, 0, ('smallest_dot_product: ' + dot_product + ' smallest_distance: ', distance))
|
colored_text = colored(255, 0, 0, ('smallest_dot_product: ' + dot_product + ' smallest_distance: ', distance))
|
||||||
dot_product = float(dot_product)
|
dot_product = float(dot_product)
|
||||||
distance = float(distance)
|
distance = float(distance)
|
||||||
strInput = ""
|
strInput = ""
|
||||||
smallest_distance_caps = [70.0, 85.0, 150.0, 200.0]
|
corner_assumptions = []
|
||||||
dot_product_jump_cap = 0.0
|
smallest_distance_caps = [16.0, 70.0]
|
||||||
print(colored_text)
|
dot_product_jump_cap = 150.0
|
||||||
if smallest_distance_caps[0] < distance < smallest_distance_caps[1] or smallest_distance_caps[2] < distance < smallest_distance_caps[3]:
|
#print('date: ', datetime.datetime.now().time(), ' ', colored_text)
|
||||||
strInput += "+jump; wait 50; +duck; wait 50; -duck; -jump;"
|
#print('end_origin_hud: ', end_origin_hud)
|
||||||
elif dot_product < dot_product_jump_cap:
|
#print('dot product:', dot_product)
|
||||||
print('dot product:', dot_product)
|
#print('distance: ', distance)
|
||||||
#strInput += "+jump; wait 50; +duck; wait 50; -jump; -duck;"
|
for a, b in pairwise(smallest_distance_caps):
|
||||||
|
if a < distance < b:
|
||||||
|
print('distance: ', distance)
|
||||||
|
strInput += spam_jump_crouch_input()
|
||||||
|
if 0 < dot_product < dot_product_jump_cap:
|
||||||
|
pass
|
||||||
|
#strInput += spam_jump_crouch_input()
|
||||||
|
for a, b in pairwise(corner_assumptions):
|
||||||
|
if a < distance < b:
|
||||||
|
strInput += "+moveleft; wait 250; -moveleft; +moveright; wait 250; -moveright;"
|
||||||
writeCfgInput(strInput)
|
writeCfgInput(strInput)
|
||||||
time.sleep(0.1)
|
time.sleep(0.1)
|
||||||
writeCfgInput("")
|
writeCfgInput("")
|
||||||
|
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
pass
|
pass
|
||||||
finally:
|
finally:
|
||||||
|
@ -21,9 +21,6 @@ bool surf_cooldown = false;
|
|||||||
bool connected_cooldown = false;
|
bool connected_cooldown = false;
|
||||||
float client_old_coords[MAXPLAYERS + 1][3];
|
float client_old_coords[MAXPLAYERS + 1][3];
|
||||||
float targethuman_teleported[3];
|
float targethuman_teleported[3];
|
||||||
float g_vCurrent[3];
|
|
||||||
float g_vLast[3];
|
|
||||||
bool client_stuck_g[MAXPLAYERS + 1];
|
|
||||||
|
|
||||||
//admins & vips
|
//admins & vips
|
||||||
bool admins[MAXPLAYERS + 1];
|
bool admins[MAXPLAYERS + 1];
|
||||||
@ -129,7 +126,7 @@ public Action reset_target_tp(Handle timer, any data)
|
|||||||
public bool distance_check()
|
public bool distance_check()
|
||||||
{
|
{
|
||||||
float dist_target = get_power_distance(present, targethuman_teleported);
|
float dist_target = get_power_distance(present, targethuman_teleported);
|
||||||
float min_required_distance = 500000.0;
|
float min_required_distance = 50000.0;
|
||||||
if (dist_target > min_required_distance)
|
if (dist_target > min_required_distance)
|
||||||
return false;
|
return false;
|
||||||
return true;
|
return true;
|
||||||
@ -166,20 +163,8 @@ public void Event_RoundStart(Handle event, const char[] name, bool dontBroadcast
|
|||||||
public void OnMapStart()
|
public void OnMapStart()
|
||||||
{
|
{
|
||||||
//0.2 too spammmy, 1.5 too slow
|
//0.2 too spammmy, 1.5 too slow
|
||||||
CreateTimer(0.70, recursive_pressing, INVALID_HANDLE, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE);
|
CreateTimer(0.60, recursive_pressing, INVALID_HANDLE, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE);
|
||||||
CreateTimer(1.0, clients_coordinates, INVALID_HANDLE, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE);
|
CreateTimer(15.0, bot_check_connect, INVALID_HANDLE, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE);
|
||||||
CreateTimer(10.0, bot_check_connect, INVALID_HANDLE, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Action clients_coordinates(Handle timer, any data)
|
|
||||||
{
|
|
||||||
if (IsValidClient(present) && IsPlayerAlive(present))
|
|
||||||
{
|
|
||||||
for (int i = 1; i <= MaxClients; i++)
|
|
||||||
if (IsValidClient(i) && IsPlayerAlive(i) && i != present && !client_stuck_g[i])
|
|
||||||
GetEntPropVector(i, Prop_Send, "m_vecOrigin", client_old_coords[i]);
|
|
||||||
}
|
|
||||||
return Plugin_Continue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void send_socket_msg(char[] query_msg, int len)
|
public void send_socket_msg(char[] query_msg, int len)
|
||||||
@ -219,16 +204,6 @@ public void OnPlayerRunCmdPost(int client, int buttons, int impulse, const float
|
|||||||
float Vel[3];
|
float Vel[3];
|
||||||
float velocity_addition_z_axis = 300.0;
|
float velocity_addition_z_axis = 300.0;
|
||||||
GetEntPropVector(client, Prop_Data, "m_vecVelocity", Vel);
|
GetEntPropVector(client, Prop_Data, "m_vecVelocity", Vel);
|
||||||
if (IsValidClient(targethuman))
|
|
||||||
{
|
|
||||||
//TODO maybe?
|
|
||||||
/*
|
|
||||||
{
|
|
||||||
Vel[0] -= velocity_addition_z_axis / 10;
|
|
||||||
Vel[1] -= velocity_addition_z_axis / 10;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
Vel[2] += velocity_addition_z_axis;
|
Vel[2] += velocity_addition_z_axis;
|
||||||
TeleportEntity(client, NULL_VECTOR, NULL_VECTOR, Vel);
|
TeleportEntity(client, NULL_VECTOR, NULL_VECTOR, Vel);
|
||||||
}
|
}
|
||||||
@ -243,12 +218,13 @@ public Action recursive_pressing(Handle timer, any data)
|
|||||||
{
|
{
|
||||||
if (GetClientTeam(present) == 1 || GetClientTeam(present) == 0)
|
if (GetClientTeam(present) == 1 || GetClientTeam(present) == 0)
|
||||||
{
|
{
|
||||||
//TODO still stuck in spectate, fuck
|
|
||||||
ChangeClientTeam(present, 2);
|
ChangeClientTeam(present, 2);
|
||||||
return Plugin_Continue;
|
return Plugin_Continue;
|
||||||
}
|
}
|
||||||
if (IsPlayerAlive(present))
|
if (IsPlayerAlive(present))
|
||||||
{
|
{
|
||||||
|
if (GetEntityMoveType(present) == MOVETYPE_LADDER)
|
||||||
|
return Plugin_Continue;
|
||||||
int targeteam = 0;
|
int targeteam = 0;
|
||||||
if (GetClientTeam(present) != 3)
|
if (GetClientTeam(present) != 3)
|
||||||
{
|
{
|
||||||
@ -261,16 +237,8 @@ public Action recursive_pressing(Handle timer, any data)
|
|||||||
targeteam = 3;
|
targeteam = 3;
|
||||||
}
|
}
|
||||||
bool find_closest_match = true;
|
bool find_closest_match = true;
|
||||||
|
|
||||||
//check ladder = 0, downhill = 3, teleporter = 4
|
|
||||||
int bot_on_type = -1;
|
|
||||||
if (GetEntityMoveType(present) == MOVETYPE_LADDER)
|
|
||||||
bot_on_type = 0;
|
|
||||||
else
|
|
||||||
bot_on_type = check_bot_downhill();
|
|
||||||
if (targethuman_teleported[0] != 0.0)
|
if (targethuman_teleported[0] != 0.0)
|
||||||
{
|
{
|
||||||
bot_on_type = 4;
|
|
||||||
float ClientPos[3];
|
float ClientPos[3];
|
||||||
float Result[3];
|
float Result[3];
|
||||||
GetClientEyePosition(present, ClientPos);
|
GetClientEyePosition(present, ClientPos);
|
||||||
@ -279,127 +247,95 @@ public Action recursive_pressing(Handle timer, any data)
|
|||||||
TeleportEntity(present, NULL_VECTOR, Result, NULL_VECTOR);
|
TeleportEntity(present, NULL_VECTOR, Result, NULL_VECTOR);
|
||||||
if (!distance_check())
|
if (!distance_check())
|
||||||
reset_target_human_tp_coord();
|
reset_target_human_tp_coord();
|
||||||
|
return Plugin_Continue;
|
||||||
}
|
}
|
||||||
if (IsValidClient(targethuman) && GetClientTeam(targethuman) == targeteam && IsPlayerAlive(targethuman) && bot_on_type != 0 && bot_on_type != 4)
|
if (IsValidClient(targethuman) && GetClientTeam(targethuman) == targeteam && IsPlayerAlive(targethuman))
|
||||||
{
|
{
|
||||||
face_call(targethuman);
|
face_call(targethuman);
|
||||||
find_closest_match = is_client_stuck_or_afk(targethuman);
|
find_closest_match = is_client_stuck_or_afk(targethuman);
|
||||||
if (!find_closest_match || admins[targethuman] || vips[targethuman])
|
if (!find_closest_match)
|
||||||
{
|
{
|
||||||
face_call(targethuman);
|
face_call(targethuman);
|
||||||
find_closest_match = IsAbleToSee(present, targethuman) ? false : true;
|
find_closest_match = IsAbleToSee(present, targethuman) ? false : true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (find_closest_match && bot_on_type != 0 && bot_on_type != 4)
|
if (find_closest_match)
|
||||||
{
|
targethuman = GetClosestClient_option1(targeteam);
|
||||||
targethuman = 0;
|
|
||||||
targethuman = GetClosestClient_option1(present, targeteam);
|
|
||||||
}
|
|
||||||
float enemy_distance = -1.0;
|
float enemy_distance = -1.0;
|
||||||
int target_enemy = find_closest_enemy(present, targeteam);
|
int target_enemy = find_closest_enemy(present, targeteam);
|
||||||
bool chasing_enemy = false;
|
|
||||||
float dist_target = -1.0;
|
float dist_target = -1.0;
|
||||||
float z_axis = 0.0;
|
float pos[3];
|
||||||
if (bot_on_type != 0 && bot_on_type != 4)
|
if (IsValidClient(targethuman))
|
||||||
{
|
{
|
||||||
float pos[3];
|
GetEntPropVector(targethuman, Prop_Send, "m_vecOrigin", pos);
|
||||||
if (IsValidClient(targethuman))
|
dist_target = get_power_distance(present, pos);
|
||||||
{
|
|
||||||
GetEntPropVector(targethuman, Prop_Send, "m_vecOrigin", pos);
|
|
||||||
dist_target = get_power_distance(present, pos);
|
|
||||||
}
|
|
||||||
if (IsValidClient(target_enemy))
|
|
||||||
{
|
|
||||||
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 = 12800.0;
|
|
||||||
float min_enemy_distance = min_distance_target_human * 15;
|
|
||||||
if (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);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
target_enemy = 0;
|
|
||||||
enemy_distance = -1.0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//zombie aiming for human
|
|
||||||
float present_bot_coords[3];
|
|
||||||
GetClientAbsOrigin(present, present_bot_coords);
|
|
||||||
z_axis = FloatAbs(Pow(present_bot_coords[2] - pos[2], 2.0));
|
|
||||||
float z_axis_cap = 20.0;
|
|
||||||
if ((targeteam == 2 && 0 < enemy_distance && z_axis < z_axis_cap) || dist_target == -1.0)
|
|
||||||
{
|
|
||||||
chasing_enemy = true;
|
|
||||||
face_call(target_enemy);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (IsValidClient(targethuman) && !chasing_enemy)
|
|
||||||
face_call(targethuman);
|
|
||||||
wall_circle();
|
|
||||||
}
|
}
|
||||||
|
if (IsValidClient(target_enemy))
|
||||||
|
{
|
||||||
|
GetEntPropVector(target_enemy, Prop_Send, "m_vecOrigin", pos);
|
||||||
|
enemy_distance = get_power_distance(present, pos);
|
||||||
|
}
|
||||||
|
float enemey_cap = 900.0;
|
||||||
|
if ((0 < enemy_distance < enemey_cap && targeteam == 2) || dist_target < 0 < enemy_distance)
|
||||||
|
face_call(target_enemy);
|
||||||
|
else if (0 < dist_target)
|
||||||
|
face_call(targethuman);
|
||||||
|
trace_hulling_bot();
|
||||||
char message[generic_length * 7];
|
char message[generic_length * 7];
|
||||||
if (IsValidClient(targethuman))
|
if (IsValidClient(targethuman))
|
||||||
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);
|
Format(message, sizeof(message), "dist_target: %f targethuman: %N enemy_distance: %f targeteam: %i", dist_target, targethuman, enemy_distance, targeteam);
|
||||||
else
|
else
|
||||||
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);
|
Format(message, sizeof(message), "dist_target: %f targethuman: none enemy_distance: %f targeteam: %i", dist_target, enemy_distance, targeteam);
|
||||||
if (IsValidClient(target_enemy))
|
if (IsValidClient(target_enemy))
|
||||||
Format(message, sizeof(message), "%s target_enemy: %N z_axis: %f", message, target_enemy, z_axis);
|
Format(message, sizeof(message), "%s target_enemy: %N", message, target_enemy);
|
||||||
else
|
else
|
||||||
Format(message, sizeof(message), "%s target_enemy: none z_axis: %f", message, z_axis);
|
Format(message, sizeof(message), "%s target_enemy: none", message);
|
||||||
send_socket_msg(message, strlen(message));
|
send_socket_msg(message, strlen(message));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return Plugin_Continue;
|
return Plugin_Continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void wall_circle()
|
public void trace_hulling_bot()
|
||||||
{
|
{
|
||||||
float smallest_dot_product = -1.0;
|
float feet_origin[3];
|
||||||
float smallest_distance = -1.0;
|
float eye_angles[3];
|
||||||
//Circle:
|
GetClientAbsOrigin(present, feet_origin);
|
||||||
for (int iterator = 0; iterator < 3; iterator++)
|
GetClientEyeAngles(present, eye_angles); //RayType_Infinite || RayType_EndPoint (Less performance intensive)
|
||||||
|
TR_TraceRayFilter(feet_origin, eye_angles, MASK_SOLID, RayType_Infinite, TraceRayDontHitSelf, present);
|
||||||
|
if (TR_DidHit())
|
||||||
{
|
{
|
||||||
float angle_start = -360.0; //should be -180.0 ofc
|
float EndOrigin[3];
|
||||||
float angle_end = 360.0;
|
TR_GetEndPosition(EndOrigin, INVALID_HANDLE);
|
||||||
for (float AngleRotate = angle_start; AngleRotate <= angle_end; AngleRotate += 10.0)
|
float mins[3], maxs[3];
|
||||||
|
int BOUNDINGBOX_INFLATION_OFFSET = 3;
|
||||||
|
GetClientMins(present, mins);
|
||||||
|
GetClientMaxs(present, maxs);
|
||||||
|
//increasing boxes sizes
|
||||||
|
for (int i = 0; i < sizeof(mins); i++)
|
||||||
{
|
{
|
||||||
float StartOrigin[3];
|
mins[i] -= BOUNDINGBOX_INFLATION_OFFSET;
|
||||||
float Angles[3];
|
maxs[i] += BOUNDINGBOX_INFLATION_OFFSET;
|
||||||
GetClientEyeAngles(present, Angles);
|
}
|
||||||
Angles[iterator] = AngleRotate;
|
TR_TraceHullFilter(EndOrigin, EndOrigin, mins, maxs, MASK_SOLID, TraceRayDontHitSelf, present);
|
||||||
GetClientEyePosition(present, StartOrigin);
|
if (TR_DidHit())
|
||||||
//TR_TraceRayFilter(StartOrigin, Angles, MASK_SOLID, RayType_Infinite, TraceRayDontHitSelf, present);
|
{
|
||||||
TR_TraceRayFilter(StartOrigin, Angles, MASK_SHOT, RayType_EndPoint, TraceRayDontHitSelf, present);
|
float end_origin_hud[3];
|
||||||
if (TR_DidHit())
|
float forward_origin[3];
|
||||||
{
|
float plane[3];
|
||||||
float EndOrigin[3];
|
TR_GetEndPosition(end_origin_hud, INVALID_HANDLE);
|
||||||
TR_GetEndPosition(EndOrigin, INVALID_HANDLE);
|
//TODO GetVectorDotProduct failing
|
||||||
float dot_product = GetVectorDotProduct(StartOrigin, EndOrigin);
|
GetAngleVectors(end_origin_hud, forward_origin, NULL_VECTOR, NULL_VECTOR);
|
||||||
dot_product = dot_product / 1000;
|
SubtractVectors(feet_origin, eye_angles, plane);
|
||||||
float distance = GetVectorDistance(StartOrigin, EndOrigin);
|
NormalizeVector(plane, plane);
|
||||||
if (distance < smallest_distance || smallest_distance == -1.0)
|
float smallest_dot_product = GetVectorDotProduct(plane, forward_origin);
|
||||||
smallest_distance = distance;
|
|
||||||
if (dot_product < smallest_dot_product || smallest_dot_product == -1.0)
|
float smallest_distance = GetVectorDistance(feet_origin, end_origin_hud);
|
||||||
smallest_dot_product = dot_product;
|
char message[generic_length * 5];
|
||||||
}
|
Format(message, sizeof(message), "smallest_dot_product: %f smallest_distance: %f end_origin_hud: %f %f %f", smallest_dot_product,
|
||||||
|
smallest_distance, end_origin_hud[0], end_origin_hud[1], end_origin_hud[2]);
|
||||||
|
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));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -420,14 +356,13 @@ public void check_bot_surfing()
|
|||||||
TR_TraceHullFilter(vPos, vEndPos, vMins, vMaxs, MASK_PLAYERSOLID_BRUSHONLY, TraceRayDontHitSelf, present);
|
TR_TraceHullFilter(vPos, vEndPos, vMins, vMaxs, MASK_PLAYERSOLID_BRUSHONLY, TraceRayDontHitSelf, present);
|
||||||
if (TR_DidHit())
|
if (TR_DidHit())
|
||||||
{
|
{
|
||||||
//< 0.7 = surf ramp, 0.6 experimental //TODO
|
//< 0.7 = surf ramp
|
||||||
float surf_ramp = 0.6;
|
float surf_ramp = 0.6;
|
||||||
char keyinput[generic_length * 3];
|
char keyinput[generic_length * 3];
|
||||||
float vPlane[3];
|
float vPlane[3];
|
||||||
TR_GetPlaneNormal(INVALID_HANDLE, vPlane);
|
TR_GetPlaneNormal(INVALID_HANDLE, vPlane);
|
||||||
if (0.0 < vPlane[2] < surf_ramp)
|
if (0.0 < vPlane[2] < surf_ramp)
|
||||||
{
|
{
|
||||||
//TODO this is very experimental
|
|
||||||
vPlane[0] *= 100;
|
vPlane[0] *= 100;
|
||||||
vPlane[1] *= 100;
|
vPlane[1] *= 100;
|
||||||
vPlane[2] *= 100;
|
vPlane[2] *= 100;
|
||||||
@ -450,67 +385,6 @@ public Action surf_cooldown_timer(Handle timer, any data)
|
|||||||
return Plugin_Continue;
|
return Plugin_Continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int check_bot_downhill()
|
|
||||||
{
|
|
||||||
//TODO experimental
|
|
||||||
if (GetEntityFlags(present) & FL_ONGROUND)
|
|
||||||
{
|
|
||||||
g_vLast[0] = g_vCurrent[0];
|
|
||||||
g_vLast[1] = g_vCurrent[1];
|
|
||||||
g_vLast[2] = g_vCurrent[2];
|
|
||||||
g_vCurrent[0] = GetEntPropFloat(present, Prop_Send, "m_vecVelocity[0]");
|
|
||||||
g_vCurrent[1] = GetEntPropFloat(present, Prop_Send, "m_vecVelocity[1]");
|
|
||||||
g_vCurrent[2] = GetEntPropFloat(present, Prop_Send, "m_vecVelocity[2]");
|
|
||||||
float vPos[3];
|
|
||||||
float vMins[3];
|
|
||||||
float vMaxs[3];
|
|
||||||
GetEntPropVector(present, Prop_Data, "m_vecOrigin", vPos);
|
|
||||||
GetEntPropVector(present, Prop_Send, "m_vecMins", vMins);
|
|
||||||
GetEntPropVector(present, Prop_Send, "m_vecMaxs", vMaxs);
|
|
||||||
float vEndPos[3];
|
|
||||||
vEndPos[0] = vPos[0];
|
|
||||||
vEndPos[1] = vPos[1];
|
|
||||||
vEndPos[2] = vPos[2] - FindConVar("sv_maxvelocity").FloatValue;
|
|
||||||
TR_TraceHullFilter(vPos, vEndPos, vMins, vMaxs, MASK_PLAYERSOLID_BRUSHONLY, TraceRayDontHitSelf, present);
|
|
||||||
if (TR_DidHit())
|
|
||||||
{
|
|
||||||
//1.0 = flat ground
|
|
||||||
float vPlane[3];
|
|
||||||
float vLast[3];
|
|
||||||
float flat_ground = 1.0;
|
|
||||||
TR_GetPlaneNormal(INVALID_HANDLE, vPlane);
|
|
||||||
if (0 < vPlane[2] < flat_ground)
|
|
||||||
{
|
|
||||||
vLast[0] = g_vLast[0];
|
|
||||||
vLast[1] = g_vLast[1];
|
|
||||||
vLast[2] = g_vLast[2];
|
|
||||||
vLast[2]-= (FindConVar("sv_gravity").FloatValue * GetTickInterval() * 0.5);
|
|
||||||
float fBackOff = GetVectorDotProduct(vLast, vPlane);
|
|
||||||
float change;
|
|
||||||
float vVel[3];
|
|
||||||
for (int i; i < 2; i++)
|
|
||||||
{
|
|
||||||
change = vPlane[i] * fBackOff;
|
|
||||||
vVel[i] = vLast[i] - change;
|
|
||||||
}
|
|
||||||
float fAdjust = GetVectorDotProduct(vVel, vPlane);
|
|
||||||
if (fAdjust < 0.0)
|
|
||||||
{
|
|
||||||
for(int i; i < 2; i++)
|
|
||||||
{
|
|
||||||
vVel[i] -= (vPlane[i] * fAdjust);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
vVel[2] = 0.0;
|
|
||||||
vLast[2] = 0.0;
|
|
||||||
if (GetVectorLength(vVel) > GetVectorLength(vLast))
|
|
||||||
return 3;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool TraceRayDontHitSelf(int entity, int mask, any data)
|
public bool TraceRayDontHitSelf(int entity, int mask, any data)
|
||||||
{
|
{
|
||||||
return entity != data && !(0 < entity <= MaxClients);
|
return entity != data && !(0 < entity <= MaxClients);
|
||||||
@ -546,10 +420,10 @@ stock bool IsValidClient(int client)
|
|||||||
|
|
||||||
stock bool is_client_stuck_or_afk(int client)
|
stock bool is_client_stuck_or_afk(int client)
|
||||||
{
|
{
|
||||||
float min_distance_cap = 2.0;
|
float min_distance_cap = 5.0;
|
||||||
float client_own_distance = get_power_distance(client, client_old_coords[client]);
|
float client_own_distance = get_power_distance(client, client_old_coords[client]);
|
||||||
client_stuck_g[client] = client_own_distance < min_distance_cap;
|
GetEntPropVector(client, Prop_Send, "m_vecOrigin", client_old_coords[client]);
|
||||||
return client_stuck_g[client];
|
return client_own_distance < min_distance_cap;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int find_closest_enemy(int entity, int targeteam)
|
public int find_closest_enemy(int entity, int targeteam)
|
||||||
@ -576,7 +450,7 @@ public int find_closest_enemy(int entity, int targeteam)
|
|||||||
return nearest;
|
return nearest;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int GetClosestClient_option1(int entity, int targeteam)
|
public int GetClosestClient_option1(int targeteam)
|
||||||
{
|
{
|
||||||
bool adminpresent = false;
|
bool adminpresent = false;
|
||||||
bool vippresent = false;
|
bool vippresent = false;
|
||||||
@ -593,7 +467,7 @@ public int GetClosestClient_option1(int entity, int targeteam)
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 1; i <= MaxClients; i++)
|
for (int i = 1; i <= MaxClients; i++)
|
||||||
if (IsValidClient(i) && IsPlayerAlive(i) && GetClientTeam(i) == targeteam && i != present)
|
if (IsValidClient(i) && IsPlayerAlive(i) && GetClientTeam(i) == targeteam && i != present && i != targethuman)
|
||||||
{
|
{
|
||||||
if (!IsAbleToSee(present, i))
|
if (!IsAbleToSee(present, i))
|
||||||
continue;
|
continue;
|
||||||
@ -620,17 +494,7 @@ public int GetClosestClient_option1(int entity, int targeteam)
|
|||||||
}
|
}
|
||||||
float pos[3];
|
float pos[3];
|
||||||
GetEntPropVector(i, Prop_Send, "m_vecOrigin", pos);
|
GetEntPropVector(i, Prop_Send, "m_vecOrigin", pos);
|
||||||
float dist_target = get_power_distance(entity, pos);
|
float dist_target = get_power_distance(present, pos);
|
||||||
//focuses on group of priority to determine while still ignoring non vip/admins
|
|
||||||
if (admins[i] || vips[i])
|
|
||||||
{
|
|
||||||
for (int j = 0; j <= targets; j++)
|
|
||||||
{
|
|
||||||
float pos_priority[3];
|
|
||||||
GetEntPropVector(priority_targets[j], Prop_Send, "m_vecOrigin", pos_priority);
|
|
||||||
dist_target += get_power_distance(i, pos_priority);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (nearestdistance < 0 || dist_target < nearestdistance)
|
if (nearestdistance < 0 || dist_target < nearestdistance)
|
||||||
{
|
{
|
||||||
nearest = i;
|
nearest = i;
|
||||||
@ -644,12 +508,7 @@ public float get_power_distance(int target_player, float [3]pos)
|
|||||||
{
|
{
|
||||||
float vec[3];
|
float vec[3];
|
||||||
GetClientAbsOrigin(target_player, vec);
|
GetClientAbsOrigin(target_player, vec);
|
||||||
//float x_axis = Pow(vec[0] - pos[0], 2.0);
|
return GetVectorDistance(vec, pos);
|
||||||
//float y_axis = Pow(vec[1] - pos[1], 2.0);
|
|
||||||
//float z_axis = FloatAbs(Pow(vec[2] - pos[2], 1.4));
|
|
||||||
//TODO
|
|
||||||
return GetVectorDistance(vec, pos, true);
|
|
||||||
//return SquareRoot(x_axis * x_axis + y_axis * y_axis + z_axis * z_axis);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnClientPostAdminCheck(int client)
|
public void OnClientPostAdminCheck(int client)
|
||||||
@ -677,7 +536,6 @@ public void OnClientPostAdminCheck(int client)
|
|||||||
client_old_coords[client][0] = 0.0;
|
client_old_coords[client][0] = 0.0;
|
||||||
client_old_coords[client][1] = 0.0;
|
client_old_coords[client][1] = 0.0;
|
||||||
client_old_coords[client][2] = 0.0;
|
client_old_coords[client][2] = 0.0;
|
||||||
client_stuck_g[client] = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public OnSocketError(Handle socket, const int errorType, const int errorNum, any args)
|
public OnSocketError(Handle socket, const int errorType, const int errorNum, any args)
|
||||||
@ -710,7 +568,6 @@ public void OnClientDisconnect(int client)
|
|||||||
client_old_coords[client][0] = 0.0;
|
client_old_coords[client][0] = 0.0;
|
||||||
client_old_coords[client][1] = 0.0;
|
client_old_coords[client][1] = 0.0;
|
||||||
client_old_coords[client][2] = 0.0;
|
client_old_coords[client][2] = 0.0;
|
||||||
client_stuck_g[client] = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void bot_send_connected_msg()
|
public void bot_send_connected_msg()
|
||||||
|
Loading…
Reference in New Issue
Block a user