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)
|
||||
enemy_distance = float(enemy_distance)
|
||||
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; "
|
||||
if dist_target > min_distance_target_human:
|
||||
if dist_target > min_distance_target_human and targeteam == 3:
|
||||
#print('dist_target: ', dist_target)
|
||||
strInput += "use weapon_elite; wait 3; "
|
||||
elif targeteam == 3:
|
||||
strInput += "use weapon_p90; wait 3; "
|
||||
elif targeteam == 2:
|
||||
strInput += "use weapon_knife; wait 5; "
|
||||
print('date: ', datetime.datetime.now().time(), ' target_enemy: ', target_enemy, ' enemy distance: ', enemy_distance, ' target human: ', targethuman,
|
||||
' dist_target: ', dist_target)
|
||||
#print('date: ', datetime.datetime.now().time(), ' target_enemy: ', target_enemy, ' enemy distance: ', enemy_distance, ' target human: ', targethuman,
|
||||
# ' dist_target: ', dist_target)
|
||||
strInput = strinput_append(strInput, 2)
|
||||
#print('strInput final:', strInput)
|
||||
writeCfgInput(strInput)
|
||||
@ -122,14 +122,6 @@ def pairwise(it):
|
||||
# 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__':
|
||||
atexit.register(exit_handler)
|
||||
local_ip = "127.0.0.1"
|
||||
@ -184,32 +176,16 @@ if __name__ == '__main__':
|
||||
bot_process_movement(data)
|
||||
elif data.startswith("surfing:"):
|
||||
bot_process_surf(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:"):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))
|
||||
dot_product = float(dot_product)
|
||||
distance = float(distance)
|
||||
elif data.startswith("hull info:"):
|
||||
hull_info = data[data.index("hull info:") + len("hull info:"):]
|
||||
colored_text = colored(255, 0, 0, ('hull_info: ' + hull_info))
|
||||
strInput = ""
|
||||
corner_assumptions = []
|
||||
smallest_distance_caps = [16.0, 70.0]
|
||||
dot_product_jump_cap = 150.0
|
||||
#print('date: ', datetime.datetime.now().time(), ' ', colored_text)
|
||||
#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;"
|
||||
if hull_info == "jump":
|
||||
strInput += "+jump; wait 5; -jump; +duck; wait 50; -duck; wait 5; "
|
||||
elif hull_info == "crouch":
|
||||
strInput += "+duck; wait 250; -duck; wait 5; "
|
||||
writeCfgInput(strInput)
|
||||
print(colored_text)
|
||||
time.sleep(0.1)
|
||||
writeCfgInput("")
|
||||
except KeyboardInterrupt:
|
||||
|
@ -299,44 +299,65 @@ public Action recursive_pressing(Handle timer, any data)
|
||||
return Plugin_Continue;
|
||||
}
|
||||
|
||||
//https://developer.valvesoftware.com/wiki/Dimensions
|
||||
public void trace_hulling_bot()
|
||||
{
|
||||
float feet_origin[3];
|
||||
float eye_angles[3];
|
||||
char message[generic_length * 3];
|
||||
float feet_origin[3], mins[3], maxs[3];
|
||||
int BOUNDINGBOX_INFLATION_OFFSET = 3;
|
||||
GetClientAbsOrigin(present, feet_origin);
|
||||
GetClientEyeAngles(present, eye_angles); //RayType_Infinite || RayType_EndPoint (Less performance intensive)
|
||||
TR_TraceRayFilter(feet_origin, eye_angles, MASK_SOLID, RayType_Infinite, TraceRayDontHitSelf, present);
|
||||
GetClientMins(present, mins);
|
||||
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())
|
||||
{
|
||||
float EndOrigin[3];
|
||||
TR_GetEndPosition(EndOrigin, INVALID_HANDLE);
|
||||
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++)
|
||||
//make it not hit when 48 units free for crouching
|
||||
GetClientAbsOrigin(present, feet_origin);
|
||||
float maxs_edit[3];
|
||||
maxs_edit[0] = maxs[0];
|
||||
maxs_edit[1] = maxs[1];
|
||||
maxs_edit[2] = 48.0;
|
||||
float mins_edit[3];
|
||||
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;
|
||||
maxs[i] += BOUNDINGBOX_INFLATION_OFFSET;
|
||||
Format(message, sizeof(message), "hull info:crouch");
|
||||
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())
|
||||
{
|
||||
float end_origin_hud[3];
|
||||
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]);
|
||||
Format(message, sizeof(message), "hull info:jump");
|
||||
send_socket_msg(message, strlen(message));
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user