made bots go spec if no humans on t or CT team
This commit is contained in:
parent
91e7c75f03
commit
6e814e5974
@ -3,7 +3,7 @@
|
||||
#define DEBUG
|
||||
|
||||
#define PLUGIN_AUTHOR "jenz"
|
||||
#define PLUGIN_VERSION "1.7"
|
||||
#define PLUGIN_VERSION "1.8"
|
||||
#define generic_length 256
|
||||
|
||||
#include <sourcemod>
|
||||
@ -44,7 +44,7 @@ public Plugin myinfo =
|
||||
public void OnPluginStart()
|
||||
{
|
||||
for (int i = 1; i <= MaxClients; i++)
|
||||
if (IsValidClient(i))
|
||||
if (IsValidClient(i))
|
||||
{
|
||||
target_friend[i] = 0;
|
||||
target_enemy[i] = 0;
|
||||
@ -62,11 +62,11 @@ public void OnPluginStart()
|
||||
public void reset_target_tp(int client)
|
||||
{
|
||||
if (IsValidClient(client) && is_bot_player(client))
|
||||
{
|
||||
targethuman_self_teleported[client][0] = 0.0;
|
||||
targethuman_self_teleported[client][1] = 0.0;
|
||||
targethuman_self_teleported[client][2] = 0.0;
|
||||
}
|
||||
{
|
||||
targethuman_self_teleported[client][0] = 0.0;
|
||||
targethuman_self_teleported[client][1] = 0.0;
|
||||
targethuman_self_teleported[client][2] = 0.0;
|
||||
}
|
||||
}
|
||||
|
||||
public Action reset_target_tp_timer(Handle timer, int client)
|
||||
@ -467,128 +467,153 @@ public bool is_bot_player(int client)
|
||||
|
||||
public Action recursive_pressing(Handle timer, any data)
|
||||
{
|
||||
bool found_valid_ct = false;
|
||||
for (int client = 1; client <= MaxClients; client++)
|
||||
{
|
||||
if (!IsValidClient(client)) continue;
|
||||
if (!is_bot_player(client) && GetClientTeam(client) == 3 && IsPlayerAlive(client))
|
||||
{
|
||||
found_valid_ct = true;
|
||||
}
|
||||
bool found_valid_ct = false;
|
||||
for (int client = 1; client <= MaxClients; client++)
|
||||
{
|
||||
if (!IsValidClient(client)) continue;
|
||||
if (!is_bot_player(client) && GetClientTeam(client) > 1)
|
||||
{
|
||||
found_valid_ct = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
for (int client = 1; client <= MaxClients; client++)
|
||||
{
|
||||
if (!IsValidClient(client)) continue;
|
||||
if (!found_valid_ct && is_bot_player(client))
|
||||
{
|
||||
if (GetClientTeam(client) != 0)
|
||||
ChangeClientTeam(client, 0);
|
||||
continue;
|
||||
}
|
||||
if (is_bot_player(client))
|
||||
{
|
||||
if (GetClientTeam(client) == 1 || GetClientTeam(client) == 0)
|
||||
{
|
||||
ChangeClientTeam(client, 2);
|
||||
continue;
|
||||
}
|
||||
if (bot_avoid_edge[client] >= 3)
|
||||
bot_avoid_edge[client] = -1;
|
||||
if (bot_avoid_edge[client] > -1)
|
||||
{
|
||||
bot_avoid_edge[client]++;
|
||||
continue;
|
||||
}
|
||||
if (IsPlayerAlive(client))
|
||||
{
|
||||
int targeteam = 0;
|
||||
if (GetClientTeam(client) != 3)
|
||||
{
|
||||
//2 = autismo is zm and should follow enemies sometimes
|
||||
targeteam = 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
//3 = autismo is human and should follow closest moving ct
|
||||
targeteam = 3;
|
||||
}
|
||||
if (IsValidClient(target_friend[client]))
|
||||
{
|
||||
did_target_tp(target_friend[client], client);
|
||||
}
|
||||
else if (IsValidClient(target_enemy[client]))
|
||||
{
|
||||
did_target_tp(target_enemy[client], client);
|
||||
}
|
||||
if (targethuman_self_teleported[client][0] != 0.0)
|
||||
{
|
||||
float ClientPos[3];
|
||||
float Result[3];
|
||||
GetClientEyePosition(client, ClientPos);
|
||||
MakeVectorFromPoints(ClientPos, targethuman_self_teleported[client], Result);
|
||||
GetVectorAngles(Result, Result);
|
||||
TeleportEntity(client, NULL_VECTOR, Result, NULL_VECTOR);
|
||||
if (!distance_check(client, client, false))
|
||||
reset_target_tp(client);
|
||||
continue;
|
||||
}
|
||||
//no target in water somehow
|
||||
target_enemy[client] = GetClosestClient_option1(false, client);
|
||||
target_friend[client] = GetClosestClient_option1(true, client);
|
||||
float pos[3];
|
||||
did_target_tp(client, client);
|
||||
float enemy_distance = -1.0;
|
||||
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 = 500.0;
|
||||
if (0 < dist_target < max_range_dist && IsValidClient(target_enemy[client]))
|
||||
{
|
||||
face_call(target_enemy[client], client);
|
||||
}
|
||||
else if (IsValidClient(target_friend[client]))
|
||||
face_call(target_friend[client], client);
|
||||
else if (IsValidClient(target_enemy[client]) && !admins[target_enemy[client]] && !vips[target_enemy[client]])
|
||||
{
|
||||
face_call(target_enemy[client], client);
|
||||
}
|
||||
if (GetEntProp(client, Prop_Data, "m_nWaterLevel") <= 2 && GetEntityMoveType(client) != MOVETYPE_LADDER)
|
||||
trace_hulling_bot(client);
|
||||
char message[generic_length * 7];
|
||||
if (IsValidClient(target_friend[client]))
|
||||
Format(message, sizeof(message), "dist_target: %f targethuman: %N enemy_distance: %f targeteam: %i", dist_target, target_friend[client], enemy_distance, targeteam);
|
||||
else
|
||||
Format(message, sizeof(message), "dist_target: %f targethuman: none enemy_distance: %f targeteam: %i", dist_target, enemy_distance, targeteam);
|
||||
if (IsValidClient(target_enemy[client]))
|
||||
Format(message, sizeof(message), "%s target_enemy: %N", message, target_enemy[client]);
|
||||
else
|
||||
Format(message, sizeof(message), "%s target_enemy: none", message);
|
||||
|
||||
if (is_bot_player(client))
|
||||
{
|
||||
if (GetClientTeam(client) == 1 || GetClientTeam(client) == 0)
|
||||
{
|
||||
ChangeClientTeam(client, 2);
|
||||
continue;
|
||||
}
|
||||
if (bot_avoid_edge[client] >= 3)
|
||||
bot_avoid_edge[client] = -1;
|
||||
if (bot_avoid_edge[client] > -1)
|
||||
{
|
||||
bot_avoid_edge[client]++;
|
||||
continue;
|
||||
}
|
||||
if (IsPlayerAlive(client))
|
||||
{
|
||||
int targeteam = 0;
|
||||
if (GetClientTeam(client) != 3)
|
||||
{
|
||||
//2 = autismo is zm and should follow enemies sometimes
|
||||
targeteam = 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
//3 = autismo is human and should follow closest moving ct
|
||||
targeteam = 3;
|
||||
}
|
||||
if (IsValidClient(target_friend[client]))
|
||||
{
|
||||
did_target_tp(target_friend[client], client);
|
||||
}
|
||||
else if (IsValidClient(target_enemy[client]))
|
||||
{
|
||||
did_target_tp(target_enemy[client], client);
|
||||
}
|
||||
if (targethuman_self_teleported[client][0] != 0.0)
|
||||
{
|
||||
float ClientPos[3];
|
||||
float Result[3];
|
||||
GetClientEyePosition(client, ClientPos);
|
||||
MakeVectorFromPoints(ClientPos, targethuman_self_teleported[client], Result);
|
||||
GetVectorAngles(Result, Result);
|
||||
TeleportEntity(client, NULL_VECTOR, Result, NULL_VECTOR);
|
||||
if (!distance_check(client, client, false))
|
||||
reset_target_tp(client);
|
||||
continue;
|
||||
}
|
||||
//no target in water somehow
|
||||
target_enemy[client] = GetClosestClient_option1(false, client);
|
||||
target_friend[client] = GetClosestClient_option1(true, client);
|
||||
float pos[3];
|
||||
did_target_tp(client, client);
|
||||
float enemy_distance = -1.0;
|
||||
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);
|
||||
}
|
||||
if (IsValidClient(target_friend[client]))
|
||||
face_call(target_friend[client], client);
|
||||
else if (IsValidClient(target_enemy[client]) && !admins[target_enemy[client]] && !vips[target_enemy[client]])
|
||||
{
|
||||
face_call(target_enemy[client], client);
|
||||
}
|
||||
if (GetEntProp(client, Prop_Data, "m_nWaterLevel") <= 2 && GetEntityMoveType(client) != MOVETYPE_LADDER)
|
||||
trace_hulling_bot(client);
|
||||
char message[generic_length * 7];
|
||||
if (IsValidClient(target_friend[client]))
|
||||
Format(message, sizeof(message), "dist_target: %f targethuman: %N enemy_distance: %f targeteam: %i", dist_target, target_friend[client], enemy_distance, targeteam);
|
||||
else
|
||||
Format(message, sizeof(message), "dist_target: %f targethuman: none enemy_distance: %f targeteam: %i", dist_target, enemy_distance, targeteam);
|
||||
if (IsValidClient(target_enemy[client]))
|
||||
Format(message, sizeof(message), "%s target_enemy: %N", message, target_enemy[client]);
|
||||
else
|
||||
Format(message, sizeof(message), "%s target_enemy: none", message);
|
||||
|
||||
if (is_autism_bot1(client))
|
||||
{
|
||||
send_socket_msg(message, strlen(message), ports[0]);
|
||||
}
|
||||
if (is_autism_bot2(client))
|
||||
{
|
||||
send_socket_msg(message, strlen(message), ports[1]);
|
||||
}
|
||||
if (is_autism_bot3(client))
|
||||
{
|
||||
send_socket_msg(message, strlen(message), ports[2]);
|
||||
}
|
||||
if (is_autism_bot4(client))
|
||||
{
|
||||
send_socket_msg(message, strlen(message), ports[3]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!found_valid_ct)
|
||||
{
|
||||
for (int client = 1; client <= MaxClients; client++)
|
||||
{
|
||||
if (!IsValidClient(client)) continue;
|
||||
if (is_bot_player(client) && GetClientTeam(client) == 3)
|
||||
{
|
||||
ForcePlayerSuicide(client);
|
||||
}
|
||||
}
|
||||
}
|
||||
return Plugin_Continue;
|
||||
if (is_autism_bot1(client))
|
||||
{
|
||||
send_socket_msg(message, strlen(message), ports[0]);
|
||||
}
|
||||
if (is_autism_bot2(client))
|
||||
{
|
||||
send_socket_msg(message, strlen(message), ports[1]);
|
||||
}
|
||||
if (is_autism_bot3(client))
|
||||
{
|
||||
send_socket_msg(message, strlen(message), ports[2]);
|
||||
}
|
||||
if (is_autism_bot4(client))
|
||||
{
|
||||
send_socket_msg(message, strlen(message), ports[3]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
found_valid_ct = false;
|
||||
for (int client = 1; client <= MaxClients; client++)
|
||||
{
|
||||
if (!IsValidClient(client)) continue;
|
||||
if (!is_bot_player(client) && GetClientTeam(client) == 3 && IsPlayerAlive(client))
|
||||
{
|
||||
found_valid_ct = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found_valid_ct)
|
||||
{
|
||||
for (int client = 1; client <= MaxClients; client++)
|
||||
{
|
||||
if (!IsValidClient(client)) continue;
|
||||
if (is_bot_player(client) && GetClientTeam(client) == 3)
|
||||
{
|
||||
ForcePlayerSuicide(client);
|
||||
}
|
||||
}
|
||||
}
|
||||
return Plugin_Continue;
|
||||
}
|
||||
|
||||
//https://developer.valvesoftware.com/wiki/Dimensions
|
||||
@ -806,7 +831,7 @@ public int GetClosestClient_option1(bool finding_friend, int client)
|
||||
for (int i = 1; i <= MaxClients; i++)
|
||||
if (IsValidClient(i) && IsPlayerAlive(i) && i != client && !is_bot_player(i))
|
||||
{
|
||||
if (!IsAbleToSee(client, i) || is_client_stuck_or_afk(client, i))
|
||||
if (!IsAbleToSee(client, i) || is_client_stuck_or_afk(client, i) || admins[i])
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user