further fixes like targeting and preventing spam connections
This commit is contained in:
parent
80ba110c42
commit
f7f896b94e
@ -278,7 +278,14 @@ public Action bot_check_connect(Handle timer, any data)
|
||||
KickClient(i, "server full you need to leave");
|
||||
}
|
||||
}
|
||||
else if (client_count < 50)
|
||||
else if (50 < client_count < 60)
|
||||
{
|
||||
found_bot1 = true;
|
||||
found_bot2 = true;
|
||||
found_bot3 = true;
|
||||
found_bot4 = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (is_autism_bot1(i))
|
||||
{
|
||||
@ -324,7 +331,7 @@ public void OnPlayerRunCmdPost(int client, int buttons, int impulse, const float
|
||||
if (is_bot_player(client))
|
||||
{
|
||||
int flags = GetEntityFlags(client);
|
||||
if (!(flags & FL_ONGROUND) && (flags_old[client] & FL_ONGROUND) && !(buttons_old[client] & IN_JUMP) && !(buttons & IN_JUMP) && (GetEntityMoveType(client) != MOVETYPE_LADDER) && GetEntProp(client, Prop_Data, "m_nWaterLevel") == 0)
|
||||
if (!(flags & FL_ONGROUND) && (flags_old[client] & FL_ONGROUND) && !(buttons_old[client] & IN_JUMP) && !(buttons & IN_JUMP) && (GetEntityMoveType(client) != MOVETYPE_LADDER) && GetEntProp(client, Prop_Data, "m_nWaterLevel") <= 2)
|
||||
{
|
||||
float Vel[3], feet_origin[3], ground_pos[3], downwards[3];
|
||||
//TODO prevent bot from falling off edge if nothing infront
|
||||
@ -363,7 +370,7 @@ public void OnPlayerRunCmdPost(int client, int buttons, int impulse, const float
|
||||
GetVectorAngles(Result, Result);
|
||||
TeleportEntity(client, NULL_VECTOR, Result, NULL_VECTOR);
|
||||
bot_avoid_edge[client] = 0;
|
||||
ApplyBoost(client, 400.0);
|
||||
ApplyBoost(client, 150.0);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -421,7 +428,7 @@ public Action recursive_pressing(Handle timer, any data)
|
||||
int targeteam = 0;
|
||||
if (GetClientTeam(client) != 3)
|
||||
{
|
||||
//2 = autismo is zm and should follow closest moving zm
|
||||
//2 = autismo is zm and should follow enemies sometimes
|
||||
targeteam = 2;
|
||||
}
|
||||
else
|
||||
@ -442,8 +449,8 @@ public Action recursive_pressing(Handle timer, any data)
|
||||
continue;
|
||||
}
|
||||
//no target in water somehow
|
||||
target_enemy[client] = GetClosestClient_option1(targeteam == 2 ? 3 : 2, client);
|
||||
targethuman[client] = GetClosestClient_option1(targeteam == 2 ? 2 : 3, client);
|
||||
target_enemy[client] = GetClosestClient_option1(false, client);
|
||||
targethuman[client] = GetClosestClient_option1(true, client);
|
||||
float enemy_distance = -1.0;
|
||||
float dist_target = -1.0;
|
||||
float pos[3];
|
||||
@ -452,7 +459,6 @@ public Action recursive_pressing(Handle timer, any data)
|
||||
GetEntPropVector(targethuman[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);
|
||||
@ -471,7 +477,7 @@ public Action recursive_pressing(Handle timer, any data)
|
||||
else if (IsValidClient(targethuman[client]))
|
||||
face_call(targethuman[client], client);
|
||||
//might prevent bot from jumping off ladders
|
||||
if (GetEntProp(client, Prop_Data, "m_nWaterLevel") == 0 && GetEntityMoveType(client) != MOVETYPE_LADDER)
|
||||
if (GetEntProp(client, Prop_Data, "m_nWaterLevel") <= 2 && GetEntityMoveType(client) != MOVETYPE_LADDER)
|
||||
trace_hulling_bot(client);
|
||||
char message[generic_length * 7];
|
||||
if (IsValidClient(targethuman[client]))
|
||||
@ -660,14 +666,11 @@ public void trace_hulling_bot(int client)
|
||||
}
|
||||
//currently detects when two walls meet and create a corner
|
||||
float move_angles[3];
|
||||
if (GetEntityMoveType(client) != MOVETYPE_LADDER && GetEntProp(client, Prop_Data, "m_nWaterLevel") == 0)
|
||||
{
|
||||
GetClientEyeAngles(client, move_angles);
|
||||
move_angles[0] = 0.0;
|
||||
move_angles[1] += 35.0;
|
||||
move_angles[2] = 0.0;
|
||||
TeleportEntity(client, NULL_VECTOR, move_angles, NULL_VECTOR);
|
||||
}
|
||||
GetClientEyeAngles(client, move_angles);
|
||||
move_angles[0] = 0.0;
|
||||
move_angles[1] += 35.0;
|
||||
move_angles[2] = 0.0;
|
||||
TeleportEntity(client, NULL_VECTOR, move_angles, NULL_VECTOR);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -714,50 +717,63 @@ stock bool IsValidClient(int client)
|
||||
|
||||
stock bool is_client_stuck_or_afk(int client)
|
||||
{
|
||||
float min_distance_cap = 5.0;
|
||||
float min_distance_cap = 1.0;
|
||||
float client_own_distance = get_power_distance(client, client_old_coords[client]);
|
||||
GetEntPropVector(client, Prop_Send, "m_vecOrigin", client_old_coords[client]);
|
||||
return client_own_distance < min_distance_cap;
|
||||
}
|
||||
|
||||
public int GetClosestClient_option1(int targeteam, int client)
|
||||
public bool check_client_team(int client, int i, bool finding_friend)
|
||||
{
|
||||
return (finding_friend && GetClientTeam(client) == GetClientTeam(i)) || (!finding_friend && GetClientTeam(client) != GetClientTeam(i));
|
||||
}
|
||||
|
||||
public int GetClosestClient_option1(bool finding_friend, int client)
|
||||
{
|
||||
float nearestdistance = -1.0;
|
||||
int nearest = -1;
|
||||
if (GetEntityMoveType(client) == MOVETYPE_LADDER)
|
||||
return nearest;
|
||||
//are there other players than bots to follow
|
||||
bool other_players_than_bots = false;
|
||||
for (int i = 1; i <= MaxClients; i++)
|
||||
if (IsValidClient(i) && IsPlayerAlive(i) && i != client && !is_bot_player(i))
|
||||
if (IsValidClient(i) && IsPlayerAlive(i) && i != client && !is_bot_player(i) && IsAbleToSee(client, i) && check_client_team(client, i, finding_friend))
|
||||
{
|
||||
other_players_than_bots = true;
|
||||
break;
|
||||
}
|
||||
for (int i = 1; i <= MaxClients; i++)
|
||||
if (IsValidClient(i) && IsPlayerAlive(i) && i != client && (!other_players_than_bots || !is_bot_player(i)) && check_client_team(client, i, finding_friend))
|
||||
{
|
||||
if (!IsAbleToSee(client, i))
|
||||
continue;
|
||||
if (is_client_stuck_or_afk(i))
|
||||
{
|
||||
if (i != targethuman[client])
|
||||
continue;
|
||||
target_human_afk_counter[client]++;
|
||||
int afk_cap = 4;
|
||||
if (target_human_afk_counter[client] > afk_cap)
|
||||
{
|
||||
target_human_afk_counter[client] = 0;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
float pos[3];
|
||||
GetEntPropVector(i, Prop_Send, "m_vecOrigin", pos);
|
||||
float dist_target = get_power_distance(client, pos);
|
||||
if (GetClientTeam(client) == 2 && (admins[i] || vips[i]))
|
||||
{
|
||||
continue;
|
||||
if (!IsAbleToSee(client, i))
|
||||
continue;
|
||||
if (is_client_stuck_or_afk(i))
|
||||
{
|
||||
if (i != targethuman[client])
|
||||
continue;
|
||||
target_human_afk_counter[client]++;
|
||||
int afk_cap = 4;
|
||||
if (target_human_afk_counter[client] > afk_cap)
|
||||
{
|
||||
target_human_afk_counter[client] = 0;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
float pos[3];
|
||||
GetEntPropVector(i, Prop_Send, "m_vecOrigin", pos);
|
||||
float dist_target = get_power_distance(client, pos);
|
||||
if (GetClientTeam(i) != GetClientTeam(client) && (admins[i] || vips[i]))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if ((admins[i] || vips[i] || i == targethuman[client]))
|
||||
dist_target /= 5;
|
||||
if (nearestdistance < 0 || dist_target < nearestdistance)
|
||||
{
|
||||
nearest = i;
|
||||
nearestdistance = dist_target;
|
||||
}
|
||||
}
|
||||
if ((admins[i] || vips[i] || i == targethuman[client]) && GetClientTeam(client) == targeteam)
|
||||
dist_target /= 5;
|
||||
if (nearestdistance < 0 || dist_target < nearestdistance)
|
||||
{
|
||||
nearest = i;
|
||||
nearestdistance = dist_target;
|
||||
}
|
||||
}
|
||||
return nearest;
|
||||
}
|
||||
|
||||
@ -898,7 +914,7 @@ public bool IsFwdVecVisible(const float start[3], const float angles[3], const f
|
||||
{
|
||||
float fwd[3];
|
||||
GetAngleVectors(angles, fwd, NULL_VECTOR, NULL_VECTOR);
|
||||
ScaleVector(fwd, 50.0);
|
||||
ScaleVector(fwd, 50.0); //ScaleVector(fwd, 50.0);
|
||||
AddVectors(end, fwd, fwd);
|
||||
return IsPointVisible(start, fwd);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user