updated prioritizing yet again so bot should avoid CT too close to zombies and hopefully fixed teleport path following

This commit is contained in:
jenz 2022-07-24 16:03:27 +02:00
parent 007ecbec7e
commit efaba98b0e

View File

@ -105,24 +105,6 @@ public void Event_RoundStart(Handle event, const char[] name, bool dontBroadcast
}
}
public bool distance_check(int client, int botclient, bool nowpos)
{
float dist_target = 0.0;
if (nowpos)
{
float pos[3];
GetEntPropVector(botclient, Prop_Send, "m_vecOrigin", pos);
dist_target = get_power_distance(client, pos);
}
else
{
}
float min_required_distance = 50000.0;
if (dist_target > min_required_distance)
return false;
return true;
}
public void cmd_talk_help(int port, int client, char[] info)
{
char msg[generic_length * 5];
@ -388,13 +370,13 @@ public void OnPlayerRunCmdPost(int client, int buttons, int impulse, const float
//this was for turning around to prevent falling off edges
void ApplyBoost(int client, float amount){
float direction[3], vel[3];
GetEntPropVector(client, Prop_Data, "m_vecVelocity", vel);
NormalizeVector(vel, direction);
ScaleVector(direction, amount);
AddVectors(vel, direction, vel);
TeleportEntity(client, NULL_VECTOR, NULL_VECTOR, vel);
//SetEntPropVector(client, Prop_Data, "m_vecBaseVelocity", vel);
float direction[3], vel[3];
GetEntPropVector(client, Prop_Data, "m_vecVelocity", vel);
NormalizeVector(vel, direction);
ScaleVector(direction, amount);
AddVectors(vel, direction, vel);
TeleportEntity(client, NULL_VECTOR, NULL_VECTOR, vel);
//SetEntPropVector(client, Prop_Data, "m_vecBaseVelocity", vel);
}
public bool is_bot_player(int client)
@ -451,23 +433,23 @@ public Action recursive_pressing(Handle timer, any data)
targeteam = 3;
}
int previous_friend = target_friend[client];
target_enemy[client] = GetClosestClient_option1(false, client);
target_friend[client] = GetClosestClient_option1(true, client);
float pos[3];
target_enemy[client] = GetClosestClient_option1(false, client, 0);
float enemy_distance = -1.0;
float pos[3];
if (IsValidClient(target_enemy[client]))
{
GetEntPropVector(target_enemy[client], Prop_Send, "m_vecOrigin", pos);
enemy_distance = get_power_distance(client, pos);
}
target_friend[client] = GetClosestClient_option1(true, client, target_enemy[client]);
float dist_target = -1.0;
if (IsValidClient(target_friend[client]))
{
GetEntPropVector(target_friend[client], Prop_Send, "m_vecOrigin", pos);
dist_target = get_power_distance(client, pos);
}
if (IsValidClient(target_enemy[client]))
{
GetEntPropVector(target_enemy[client], Prop_Send, "m_vecOrigin", pos);
enemy_distance = get_power_distance(client, pos);
}
float max_range_dist = 65.0;
//here we put into consideration if the human is leaving or standing around. If the bots already catched up to the human they can have a larger distance between the player and themselves so they dont constantly follow him. If the player is leaving the bots needs to follow him much closer.
if (targeteam == 3 && human_too_close[client])
@ -475,16 +457,20 @@ public Action recursive_pressing(Handle timer, any data)
max_range_dist = 200.0;
}
int state = -1;
//the friend just moved an probably impossible distance so is most likely teleported
if (targetfriend_prev_coords[client][0] != 0.0 && IsValidClient(previous_friend))
//Our previous friend is still an alive human, if we cant see him anymore he went around a corner or teleported
if (targetfriend_prev_coords[client][0] != 0.0 && IsValidClient(previous_friend) && GetClientTeam(previous_friend) == GetClientTeam(client)
&& IsPlayerAlive(previous_friend) && previous_friend != target_friend[client])
{
//how far from old coords did our previous friend move, teleports sometimes dont move one very far,
//has to be further than what noclip/surfing/speed might do. Not using hooking on trigger_multiple or trigger_teleport as origin also may be used
float distance_between_prev_coord_and_new_coord = get_power_distance(previous_friend, targetfriend_prev_coords[client]);
float min_required_distance = 1000.0;
if (distance_between_prev_coord_and_new_coord > min_required_distance)
float ClientPos[3];
float friend_prev[3];
GetClientEyePosition(client, ClientPos);
//if the bot cant see him anymore he around corner or teleported most likley.
//therefore a small distance check should also be needed
float distance_prev_friend_prior = get_power_distance(previous_friend, targetfriend_prev_coords[client]);
GetEntPropVector(previous_friend, Prop_Send, "m_vecOrigin", friend_prev);
if (!IsPointVisible(ClientPos, friend_prev) && distance_prev_friend_prior > 500.0)
{
bot_follow_tp[client] = true;
}
@ -846,7 +832,7 @@ stock bool is_client_stuck_or_afk(int client, int i)
return false;
}
public int GetClosestClient_option1(bool finding_friend, int client)
public int GetClosestClient_option1(bool finding_friend, int client, int enemy)
{
float nearestdistance = -1.0;
int nearest = -1;
@ -864,6 +850,18 @@ public int GetClosestClient_option1(bool finding_friend, int client)
{
continue;
}
if (GetClientTeam(client) == 3 && IsValidClient(enemy))
{
float enemy_pos[3];
GetEntPropVector(enemy, Prop_Send, "m_vecOrigin", enemy_pos);
float enemy_distance = get_power_distance(i, enemy_pos);
//this should later be an issue at parts where zombies are on all sides around one. having to run close by them.
if (enemy_distance <= 800.0)
{
dist_target = 8000000.0;
}
}
if (is_bot_player(i))
{
//just making sure bots have lowest priority