improved jump/crouch handling
This commit is contained in:
parent
c17175d0b2
commit
55da3bc311
@ -66,17 +66,17 @@ def bot_process_movement(input_line):
|
|||||||
dist_target = float(dist_target)
|
dist_target = float(dist_target)
|
||||||
enemy_distance = float(enemy_distance)
|
enemy_distance = float(enemy_distance)
|
||||||
targeteam = int(targeteam)
|
targeteam = int(targeteam)
|
||||||
min_distance_target_human = 1280.0
|
min_distance_target_human = 50.0
|
||||||
strInput = "-attack; wait 2; -use; 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 and targeteam == 3:
|
||||||
#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; "
|
||||||
print('date: ', datetime.datetime.now().time(), ' target_enemy: ', target_enemy, ' enemy distance: ', enemy_distance, ' target human: ', targethuman,
|
#print('date: ', datetime.datetime.now().time(), ' target_enemy: ', target_enemy, ' enemy distance: ', enemy_distance, ' target human: ', targethuman,
|
||||||
' dist_target: ', dist_target)
|
# ' 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)
|
||||||
@ -122,14 +122,6 @@ def pairwise(it):
|
|||||||
# no more elements in the iterator
|
# no more elements in the iterator
|
||||||
return
|
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"
|
||||||
@ -184,32 +176,16 @@ if __name__ == '__main__':
|
|||||||
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("hull info:"):
|
||||||
dot_product = data[data.index("smallest_dot_product:") + len("smallest_dot_product:"):data.index("smallest_distance:")]
|
hull_info = data[data.index("hull info:") + len("hull info:"):]
|
||||||
distance = data[data.index("smallest_distance:") + len("smallest_distance:"):data.index("end_origin_hud:")]
|
colored_text = colored(255, 0, 0, ('hull_info: ' + hull_info))
|
||||||
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))
|
|
||||||
dot_product = float(dot_product)
|
|
||||||
distance = float(distance)
|
|
||||||
strInput = ""
|
strInput = ""
|
||||||
corner_assumptions = []
|
if hull_info == "jump":
|
||||||
smallest_distance_caps = [16.0, 70.0]
|
strInput += "+jump; wait 5; -jump; +duck; wait 50; -duck; wait 5; "
|
||||||
dot_product_jump_cap = 150.0
|
elif hull_info == "crouch":
|
||||||
#print('date: ', datetime.datetime.now().time(), ' ', colored_text)
|
strInput += "+duck; wait 250; -duck; wait 5; "
|
||||||
#print('end_origin_hud: ', end_origin_hud)
|
|
||||||
#print('dot product:', dot_product)
|
|
||||||
#print('distance: ', distance)
|
|
||||||
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)
|
||||||
|
print(colored_text)
|
||||||
time.sleep(0.1)
|
time.sleep(0.1)
|
||||||
writeCfgInput("")
|
writeCfgInput("")
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
|
@ -299,44 +299,65 @@ public Action recursive_pressing(Handle timer, any data)
|
|||||||
return Plugin_Continue;
|
return Plugin_Continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//https://developer.valvesoftware.com/wiki/Dimensions
|
||||||
public void trace_hulling_bot()
|
public void trace_hulling_bot()
|
||||||
{
|
{
|
||||||
float feet_origin[3];
|
char message[generic_length * 3];
|
||||||
float eye_angles[3];
|
float feet_origin[3], mins[3], maxs[3];
|
||||||
|
int BOUNDINGBOX_INFLATION_OFFSET = 3;
|
||||||
GetClientAbsOrigin(present, feet_origin);
|
GetClientAbsOrigin(present, feet_origin);
|
||||||
GetClientEyeAngles(present, eye_angles); //RayType_Infinite || RayType_EndPoint (Less performance intensive)
|
GetClientMins(present, mins);
|
||||||
TR_TraceRayFilter(feet_origin, eye_angles, MASK_SOLID, RayType_Infinite, TraceRayDontHitSelf, present);
|
GetClientMaxs(present, maxs);
|
||||||
|
//increasing boxes sizes
|
||||||
|
for (int ij = 0; ij < sizeof(mins) - 1; ij++)
|
||||||
|
{
|
||||||
|
mins[ij] -= BOUNDINGBOX_INFLATION_OFFSET;
|
||||||
|
maxs[ij] += BOUNDINGBOX_INFLATION_OFFSET;
|
||||||
|
}
|
||||||
|
float blocking_jump = 73.0;
|
||||||
|
feet_origin[2] += blocking_jump;
|
||||||
|
TR_TraceHullFilter(feet_origin, feet_origin, mins, maxs, MASK_SOLID, TraceRayDontHitSelf);
|
||||||
if (TR_DidHit())
|
if (TR_DidHit())
|
||||||
{
|
{
|
||||||
float EndOrigin[3];
|
//make it not hit when 48 units free for crouching
|
||||||
TR_GetEndPosition(EndOrigin, INVALID_HANDLE);
|
GetClientAbsOrigin(present, feet_origin);
|
||||||
float mins[3], maxs[3];
|
float maxs_edit[3];
|
||||||
int BOUNDINGBOX_INFLATION_OFFSET = 3;
|
maxs_edit[0] = maxs[0];
|
||||||
GetClientMins(present, mins);
|
maxs_edit[1] = maxs[1];
|
||||||
GetClientMaxs(present, maxs);
|
maxs_edit[2] = 48.0;
|
||||||
//increasing boxes sizes
|
float mins_edit[3];
|
||||||
for (int i = 0; i < sizeof(mins); i++)
|
mins_edit[0] = mins[0];
|
||||||
|
mins_edit[1] = mins[1];
|
||||||
|
mins_edit[2] = 0.0;
|
||||||
|
TR_TraceHullFilter(feet_origin, feet_origin, mins_edit, maxs_edit, MASK_SOLID, TraceRayDontHitSelf);
|
||||||
|
if (!(TR_DidHit()))
|
||||||
{
|
{
|
||||||
mins[i] -= BOUNDINGBOX_INFLATION_OFFSET;
|
Format(message, sizeof(message), "hull info:crouch");
|
||||||
maxs[i] += BOUNDINGBOX_INFLATION_OFFSET;
|
send_socket_msg(message, strlen(message));
|
||||||
}
|
}
|
||||||
TR_TraceHullFilter(EndOrigin, EndOrigin, mins, maxs, MASK_SOLID, TraceRayDontHitSelf, present);
|
else
|
||||||
|
{
|
||||||
|
GetClientAbsOrigin(present, feet_origin);
|
||||||
|
feet_origin[2] += BOUNDINGBOX_INFLATION_OFFSET;
|
||||||
|
TR_TraceHullFilter(feet_origin, feet_origin, mins, maxs, MASK_SOLID, TraceRayDontHitSelf);
|
||||||
|
if (TR_DidHit())
|
||||||
|
{
|
||||||
|
//ran into wall
|
||||||
|
float move_angles[3];
|
||||||
|
GetClientEyePosition(present, move_angles);
|
||||||
|
move_angles[1] += 5.0;
|
||||||
|
TeleportEntity(present, NULL_VECTOR, move_angles, NULL_VECTOR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
GetClientAbsOrigin(present, feet_origin);
|
||||||
|
feet_origin[2] += BOUNDINGBOX_INFLATION_OFFSET;
|
||||||
|
TR_TraceHullFilter(feet_origin, feet_origin, mins, maxs, MASK_SOLID, TraceRayDontHitSelf);
|
||||||
if (TR_DidHit())
|
if (TR_DidHit())
|
||||||
{
|
{
|
||||||
float end_origin_hud[3];
|
Format(message, sizeof(message), "hull info:jump");
|
||||||
float forward_origin[3];
|
|
||||||
float plane[3];
|
|
||||||
TR_GetEndPosition(end_origin_hud, INVALID_HANDLE);
|
|
||||||
//TODO GetVectorDotProduct failing
|
|
||||||
GetAngleVectors(end_origin_hud, forward_origin, NULL_VECTOR, NULL_VECTOR);
|
|
||||||
SubtractVectors(feet_origin, eye_angles, plane);
|
|
||||||
NormalizeVector(plane, plane);
|
|
||||||
float smallest_dot_product = GetVectorDotProduct(plane, forward_origin);
|
|
||||||
|
|
||||||
float smallest_distance = GetVectorDistance(feet_origin, end_origin_hud);
|
|
||||||
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));
|
send_socket_msg(message, strlen(message));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user