wall detection update
This commit is contained in:
parent
d59b90c187
commit
fa55ea1e17
@ -74,20 +74,20 @@ 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("bot_on_type:")]
|
||||||
bot_on_type = input_line[input_line.index("bot_on_type:") + len("bot_on_type:"):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("bot_stuck:")]
|
enemy_distance = input_line[input_line.index("enemy_distance:") + len("enemy_distance:"):input_line.index("crouch_or_jump:")]
|
||||||
bot_stuck = input_line[input_line.index("bot_stuck:") + len("bot_stuck:"):input_line.index("targeteam:")]
|
crouch_or_jump = input_line[input_line.index("crouch_or_jump:") + len("crouch_or_jump:"):input_line.index("targeteam:")]
|
||||||
targeteam = input_line[input_line.index("targeteam:") + len("targeteam:"):]
|
targeteam = input_line[input_line.index("targeteam:") + len("targeteam:"):]
|
||||||
dist_target = float(dist_target)
|
dist_target = float(dist_target)
|
||||||
enemy_distance = float(enemy_distance)
|
enemy_distance = float(enemy_distance)
|
||||||
bot_on_type = int(bot_on_type)
|
bot_on_type = int(bot_on_type)
|
||||||
bot_stuck = int(bot_stuck)
|
crouch_or_jump = int(crouch_or_jump)
|
||||||
targeteam = int(targeteam)
|
targeteam = int(targeteam)
|
||||||
#maybe 0.8 instead
|
#maybe 0.8 instead
|
||||||
min_distance_target_human = 0.1
|
min_distance_target_human = 0.1
|
||||||
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; "
|
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; "
|
||||||
if bot_stuck:
|
if crouch_or_jump > 0:
|
||||||
print('bot stuck')
|
print('crouch_or_jump')
|
||||||
strInput += "+jump; wait 5; +duck; wait 5; -jump; wait 15; -duck; wait 3;"
|
strInput += "+jump; wait 5; +duck; wait 5; -jump; wait 500; -duck; wait 3;"
|
||||||
if dist_target > min_distance_target_human:
|
if dist_target > min_distance_target_human:
|
||||||
strInput += "use weapon_elite; wait 3; "
|
strInput += "use weapon_elite; wait 3; "
|
||||||
elif targeteam == 3:
|
elif targeteam == 3:
|
||||||
@ -214,3 +214,6 @@ if __name__ == '__main__':
|
|||||||
#cd /home/gameservers/ze_runner_files
|
#cd /home/gameservers/ze_runner_files
|
||||||
#./play.sh
|
#./play.sh
|
||||||
#screen -A -d -m -S ze_runner ./play.sh
|
#screen -A -d -m -S ze_runner ./play.sh
|
||||||
|
|
||||||
|
#before steam login: export SDL_VIDEO_X11_VISUALID=0x074
|
||||||
|
#to find correct SDL_VIDEO_X11_VISUALID use glxinfo in X2GO
|
||||||
|
@ -18,7 +18,6 @@ int targethuman = 0;
|
|||||||
int buttons_old;
|
int buttons_old;
|
||||||
int flags_old;
|
int flags_old;
|
||||||
int surf_delay = 0;
|
int surf_delay = 0;
|
||||||
float bot_old_coords[3];
|
|
||||||
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_vCurrent[3];
|
||||||
@ -68,7 +67,6 @@ public void OnPluginStart()
|
|||||||
cmdpost_run_cooldown = false;
|
cmdpost_run_cooldown = false;
|
||||||
bot_surf_plane = false;
|
bot_surf_plane = false;
|
||||||
reset_target_human_tp_coord();
|
reset_target_human_tp_coord();
|
||||||
reset_bot_old_coords();
|
|
||||||
targethuman = 0;
|
targethuman = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -258,19 +256,19 @@ public void OnPlayerRunCmdPost(int client, int buttons, int impulse, const float
|
|||||||
if (IsValidClient(targethuman))
|
if (IsValidClient(targethuman))
|
||||||
{
|
{
|
||||||
//TODO maybe?
|
//TODO maybe?
|
||||||
GetEntPropVector(present, Prop_Send, "m_vecOrigin", bot_old_coords);
|
/*
|
||||||
if (client_old_coords[targethuman][2] != bot_old_coords[2])
|
|
||||||
{
|
{
|
||||||
Vel[0] -= velocity_addition_z_axis / 10;
|
Vel[0] -= velocity_addition_z_axis / 10;
|
||||||
Vel[1] -= 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);
|
||||||
|
check_bot_surfing();
|
||||||
}
|
}
|
||||||
buttons_old = buttons;
|
buttons_old = buttons;
|
||||||
flags_old = flags;
|
flags_old = flags;
|
||||||
check_bot_surfing();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -293,7 +291,6 @@ public Action recursive_pressing(Handle timer, any data)
|
|||||||
targeteam = 3;
|
targeteam = 3;
|
||||||
}
|
}
|
||||||
bool find_closest_match = true;
|
bool find_closest_match = true;
|
||||||
bool bot_stuck = false;
|
|
||||||
|
|
||||||
//check ladder = 0, water = 1, in air(surfing) = 2, downhill = 3, teleporter = 4
|
//check ladder = 0, water = 1, in air(surfing) = 2, downhill = 3, teleporter = 4
|
||||||
int bot_on_type = -1;
|
int bot_on_type = -1;
|
||||||
@ -338,6 +335,7 @@ public Action recursive_pressing(Handle timer, any data)
|
|||||||
int target_enemy = find_closest_enemy(present, targeteam);
|
int target_enemy = find_closest_enemy(present, targeteam);
|
||||||
bool chasing_enemy = false;
|
bool chasing_enemy = false;
|
||||||
float dist_target = -1.0;
|
float dist_target = -1.0;
|
||||||
|
bool crouch_or_jump = false;
|
||||||
if (bot_on_type != 0 && bot_on_type != 2 && bot_on_type != 4)
|
if (bot_on_type != 0 && bot_on_type != 2 && bot_on_type != 4)
|
||||||
{
|
{
|
||||||
float pos[3];
|
float pos[3];
|
||||||
@ -367,7 +365,7 @@ public Action recursive_pressing(Handle timer, any data)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
//zombie aiming for human
|
//zombie aiming for human
|
||||||
if (targeteam == 2 && 0 < enemy_distance <= min_enemy_distance * 10)
|
if (targeteam == 2 && 0 < enemy_distance)
|
||||||
{
|
{
|
||||||
chasing_enemy = true;
|
chasing_enemy = true;
|
||||||
face_call(target_enemy);
|
face_call(target_enemy);
|
||||||
@ -375,38 +373,58 @@ public Action recursive_pressing(Handle timer, any data)
|
|||||||
}
|
}
|
||||||
if (IsValidClient(targethuman) && !chasing_enemy)
|
if (IsValidClient(targethuman) && !chasing_enemy)
|
||||||
face_call(targethuman);
|
face_call(targethuman);
|
||||||
if (round_start_stuck)
|
crouch_or_jump = wall_circle();
|
||||||
bot_stuck = is_bot_stuck();
|
|
||||||
}
|
}
|
||||||
//TODO in some cases crouch under obstacles or jump more? maybe trace raying all obstacles, maybe use TR_GetPlaneNormal
|
|
||||||
//make this replace is_bot_stuck() probably
|
|
||||||
//crouch_or_jump = 0: nothing. crouch_or_jump = 1: crouch. crouch_or_jump = 2: jump.
|
|
||||||
int crouch_or_jump = trace_geometry();
|
|
||||||
|
|
||||||
if (bot_on_type != 2)
|
if (bot_on_type != 2)
|
||||||
{
|
{
|
||||||
if (IsValidClient(targethuman))
|
if (IsValidClient(targethuman))
|
||||||
Format(message, sizeof(message), "dist_target: %f targethuman: %N bot_on_type: %i enemy_distance: %f bot_stuck: %i targeteam: %i", dist_target, targethuman, bot_on_type, enemy_distance, bot_stuck, targeteam);
|
Format(message, sizeof(message), "dist_target: %f targethuman: %N bot_on_type: %i enemy_distance: %f crouch_or_jump: %i targeteam: %i", dist_target, targethuman, bot_on_type, enemy_distance, crouch_or_jump, targeteam);
|
||||||
else
|
else
|
||||||
Format(message, sizeof(message), "dist_target: %f targethuman: none bot_on_type: %i enemy_distance: %f bot_stuck: %i targeteam: %i", dist_target, bot_on_type, enemy_distance, bot_stuck, targeteam);
|
Format(message, sizeof(message), "dist_target: %f targethuman: none bot_on_type: %i enemy_distance: %f crouch_or_jump: %i targeteam: %i", dist_target, bot_on_type, enemy_distance, crouch_or_jump, targeteam);
|
||||||
send_socket_msg(message, strlen(message));
|
send_socket_msg(message, strlen(message));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return Plugin_Continue;
|
return Plugin_Continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int trace_geometry()
|
public bool wall_circle()
|
||||||
{
|
{
|
||||||
float vPos[3];
|
//TODO maybe
|
||||||
float angles[3];
|
float min_cap_distance = 50.0;
|
||||||
//GetClientEyeAngles(client, angles);
|
for (float AngleRotate = 0.0; AngleRotate < 360.0; AngleRotate += 30.0)
|
||||||
GetEntPropVector(present, Prop_Data, "m_vecOrigin", vPos);
|
{
|
||||||
TR_TraceRay(vPos, angles, MASK_PLAYERSOLID_BRUSHONLY, RayType_Infinite);
|
float StartOrigin[3];
|
||||||
|
float Angles[3];
|
||||||
|
Angles[0] = 0.0;
|
||||||
|
Angles[1] = AngleRotate;
|
||||||
|
Angles[2] = 0.0;
|
||||||
|
GetClientEyePosition(present, StartOrigin);
|
||||||
|
TR_TraceRayFilter(StartOrigin, Angles, MASK_SOLID, RayType_Infinite, TraceRayDontHitSelf);
|
||||||
if (TR_DidHit())
|
if (TR_DidHit())
|
||||||
{
|
{
|
||||||
|
float EndOrigin[3];
|
||||||
|
TR_GetEndPosition(EndOrigin, INVALID_HANDLE);
|
||||||
|
float Distance = (GetVectorDistance(StartOrigin, EndOrigin));
|
||||||
|
if (Distance < min_cap_distance)
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
return 0;
|
float StartOrigin1[3];
|
||||||
|
float Angles1[3];
|
||||||
|
Angles1[0] = AngleRotate;
|
||||||
|
Angles1[1] = 0.0;
|
||||||
|
Angles1[2] = 0.0;
|
||||||
|
GetClientEyePosition(present, StartOrigin1);
|
||||||
|
TR_TraceRayFilter(StartOrigin1, Angles1, MASK_SOLID, RayType_Infinite, TraceRayDontHitSelf);
|
||||||
|
if (TR_DidHit())
|
||||||
|
{
|
||||||
|
float EndOrigin[3];
|
||||||
|
TR_GetEndPosition(EndOrigin, INVALID_HANDLE);
|
||||||
|
float Distance = (GetVectorDistance(StartOrigin1, EndOrigin));
|
||||||
|
if (Distance < min_cap_distance)
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void check_bot_surfing()
|
public void check_bot_surfing()
|
||||||
@ -522,16 +540,6 @@ public bool TraceRayDontHitSelf(int entity, int mask, any data)
|
|||||||
return entity != data && !(0 < entity <= MaxClients);
|
return entity != data && !(0 < entity <= MaxClients);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool is_bot_stuck()
|
|
||||||
{
|
|
||||||
if (!round_start_stuck)
|
|
||||||
return false;
|
|
||||||
float min_distance_cap = 0.05;
|
|
||||||
float bot_own_distance = get_power_distance(present, bot_old_coords);
|
|
||||||
GetEntPropVector(present, Prop_Send, "m_vecOrigin", bot_old_coords);
|
|
||||||
return bot_own_distance <= min_distance_cap;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void face_call(int client)
|
public void face_call(int client)
|
||||||
{
|
{
|
||||||
for (int j = 0; j < 5; j++)
|
for (int j = 0; j < 5; j++)
|
||||||
@ -670,13 +678,6 @@ public float get_power_distance(int target_player, float [3]pos)
|
|||||||
return power_distance / defaultcap;
|
return power_distance / defaultcap;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void reset_bot_old_coords()
|
|
||||||
{
|
|
||||||
bot_old_coords[0] = 0.0;
|
|
||||||
bot_old_coords[1] = 0.0;
|
|
||||||
bot_old_coords[2] = 0.0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void OnClientPostAdminCheck(int client)
|
public void OnClientPostAdminCheck(int client)
|
||||||
{
|
{
|
||||||
//STEAM_0:1:34783317
|
//STEAM_0:1:34783317
|
||||||
@ -688,13 +689,11 @@ public void OnClientPostAdminCheck(int client)
|
|||||||
if (StrEqual("[U:1:120378081]", auth, false))
|
if (StrEqual("[U:1:120378081]", auth, false))
|
||||||
{
|
{
|
||||||
present = client;
|
present = client;
|
||||||
reset_bot_old_coords();
|
|
||||||
bot_send_connected_msg();
|
bot_send_connected_msg();
|
||||||
}
|
}
|
||||||
else if (StrEqual("STEAM_0:1:60189040", auth, false))
|
else if (StrEqual("STEAM_0:1:60189040", auth, false))
|
||||||
{
|
{
|
||||||
present = client;
|
present = client;
|
||||||
reset_bot_old_coords();
|
|
||||||
bot_send_connected_msg();
|
bot_send_connected_msg();
|
||||||
}
|
}
|
||||||
if (CheckCommandAccess(client, "sm_kick", ADMFLAG_KICK))
|
if (CheckCommandAccess(client, "sm_kick", ADMFLAG_KICK))
|
||||||
|
Loading…
Reference in New Issue
Block a user