added support for fakesclient movement losely based on what the autism bots do. crouching does not work atm however
This commit is contained in:
parent
f549e8b5e2
commit
c960e3fc15
@ -24,6 +24,9 @@ int ports[7] = {48470, 48471, 48472, 48473, 48474, 48479, 48480}; //last three i
|
|||||||
int server_ports[2] = {27015, 27035}; //server ports: ze, ze2
|
int server_ports[2] = {27015, 27035}; //server ports: ze, ze2
|
||||||
float client_old_coords[MAXPLAYERS + 1][3];
|
float client_old_coords[MAXPLAYERS + 1][3];
|
||||||
float targetfriend_prev_coords[MAXPLAYERS + 1][3];
|
float targetfriend_prev_coords[MAXPLAYERS + 1][3];
|
||||||
|
|
||||||
|
int fakes_state[MAXPLAYERS + 1];
|
||||||
|
bool fakes_hit_ground[MAXPLAYERS + 1];
|
||||||
int has_to_jump_bots[MAXPLAYERS + 1];
|
int has_to_jump_bots[MAXPLAYERS + 1];
|
||||||
float coords_run_cmd[MAXPLAYERS + 1][3];
|
float coords_run_cmd[MAXPLAYERS + 1][3];
|
||||||
bool chat_cooldown = false;
|
bool chat_cooldown = false;
|
||||||
@ -38,6 +41,8 @@ Handle g_hTimer_bot_connect = null;
|
|||||||
//cmdrun handle for gamedata txt
|
//cmdrun handle for gamedata txt
|
||||||
Handle g_hGetRunCmdPre;
|
Handle g_hGetRunCmdPre;
|
||||||
|
|
||||||
|
int g_iVelocity = -1;
|
||||||
|
|
||||||
//is botplayer
|
//is botplayer
|
||||||
bool is_bot_player[MAXPLAYERS + 1];
|
bool is_bot_player[MAXPLAYERS + 1];
|
||||||
int specific_bot_player[MAXPLAYERS + 1];
|
int specific_bot_player[MAXPLAYERS + 1];
|
||||||
@ -53,6 +58,7 @@ public Plugin myinfo =
|
|||||||
|
|
||||||
public void OnPluginStart()
|
public void OnPluginStart()
|
||||||
{
|
{
|
||||||
|
g_iVelocity = FindSendPropInfo("CBasePlayer", "m_vecVelocity[0]");
|
||||||
for (int i = 1; i <= MaxClients; i++)
|
for (int i = 1; i <= MaxClients; i++)
|
||||||
if (IsValidClient(i))
|
if (IsValidClient(i))
|
||||||
{
|
{
|
||||||
@ -86,7 +92,7 @@ public void OnPluginStart()
|
|||||||
|
|
||||||
for (int i = 1; i <= MaxClients; i++)
|
for (int i = 1; i <= MaxClients; i++)
|
||||||
{
|
{
|
||||||
if (IsValidClient(i) && is_bot_player[i])
|
if (IsValidClient(i) && (is_bot_player[i] || IsFakeClient(i)))
|
||||||
{
|
{
|
||||||
if (g_hGetRunCmdPre != INVALID_HANDLE)
|
if (g_hGetRunCmdPre != INVALID_HANDLE)
|
||||||
DHookEntity(g_hGetRunCmdPre, false, i);
|
DHookEntity(g_hGetRunCmdPre, false, i);
|
||||||
@ -112,10 +118,9 @@ public MRESReturn OnGetRunCmdPre(int entity, Handle hReturn)
|
|||||||
{
|
{
|
||||||
if (!IsValidEntity(entity))
|
if (!IsValidEntity(entity))
|
||||||
return MRES_Ignored;
|
return MRES_Ignored;
|
||||||
|
|
||||||
//check here if fell off edge, if did change some boolean around tell it to OnPlayerRunCmd when still on ground there
|
//check here if fell off edge, if did change some boolean around tell it to OnPlayerRunCmd when still on ground there
|
||||||
if (IsValidClient(entity) && IsPlayerAlive(entity) && !(GetEntityFlags(entity) & FL_ONGROUND) && !has_to_jump_bots[entity]
|
if (IsValidClient(entity) && IsPlayerAlive(entity) && !(GetEntityFlags(entity) & FL_ONGROUND) && !has_to_jump_bots[entity]
|
||||||
&& is_bot_player[entity])
|
&& (is_bot_player[entity] || IsFakeClient(entity)))
|
||||||
{
|
{
|
||||||
has_to_jump_bots[entity] = 1;
|
has_to_jump_bots[entity] = 1;
|
||||||
}
|
}
|
||||||
@ -143,7 +148,7 @@ public void get_new_angles(int client, int target, float angles[3])
|
|||||||
public Action OnPlayerRunCmd(int client, int& buttons, int& impulse, float vel[3], float angles[3], int& weapon, int& subtype, int& cmdnum, int& tickcount, int& seed, int mouse[2])
|
public Action OnPlayerRunCmd(int client, int& buttons, int& impulse, float vel[3], float angles[3], int& weapon, int& subtype, int& cmdnum, int& tickcount, int& seed, int mouse[2])
|
||||||
{
|
{
|
||||||
//we use info we just got from OnPlayerRunCmdPre to determine if to jump
|
//we use info we just got from OnPlayerRunCmdPre to determine if to jump
|
||||||
if (!IsValidClient(client) || !IsPlayerAlive(client) || !is_bot_player[client]) return Plugin_Continue;
|
if (!IsValidClient(client) || !IsPlayerAlive(client) || !(is_bot_player[client] || IsFakeClient(client))) return Plugin_Continue;
|
||||||
|
|
||||||
//2023 october: the new place to set angles for the client instead of using face_call, through this is teleporting avoided which can trigger trigger_multiples
|
//2023 october: the new place to set angles for the client instead of using face_call, through this is teleporting avoided which can trigger trigger_multiples
|
||||||
if (!bot_follow_tp[client])
|
if (!bot_follow_tp[client])
|
||||||
@ -239,14 +244,14 @@ public Action OnPlayerRunCmd(int client, int& buttons, int& impulse, float vel[3
|
|||||||
GetEntPropVector(client, Prop_Send, "m_vecOrigin", coords_run_cmd[client]);
|
GetEntPropVector(client, Prop_Send, "m_vecOrigin", coords_run_cmd[client]);
|
||||||
return Plugin_Continue;
|
return Plugin_Continue;
|
||||||
}
|
}
|
||||||
if (GetEntProp(client, Prop_Data, "m_nWaterLevel") != 0)
|
if (GetEntProp(client, Prop_Data, "m_nWaterLevel") != 0 && !IsFakeClient(client))
|
||||||
{
|
{
|
||||||
has_to_jump_bots[client] = 2;
|
has_to_jump_bots[client] = 2;
|
||||||
return Plugin_Continue;
|
return Plugin_Continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
//make sure fell of an edge instead of actually jumping
|
//make sure fell of an edge instead of actually jumping. update: i suppose buttons & IN_JUMP probably wont detected for fakes correctly.
|
||||||
if (buttons & IN_JUMP && has_to_jump_bots[client] == 1)
|
if (buttons & IN_JUMP && has_to_jump_bots[client] == 1 && !IsFakeClient(client))
|
||||||
{
|
{
|
||||||
has_to_jump_bots[client] = 2;
|
has_to_jump_bots[client] = 2;
|
||||||
return Plugin_Continue;
|
return Plugin_Continue;
|
||||||
@ -268,12 +273,92 @@ public Action OnPlayerRunCmd(int client, int& buttons, int& impulse, float vel[3
|
|||||||
//teleport back on ground so can jump
|
//teleport back on ground so can jump
|
||||||
TeleportEntity(client, coords_run_cmd[client], NULL_VECTOR, NULL_VECTOR);
|
TeleportEntity(client, coords_run_cmd[client], NULL_VECTOR, NULL_VECTOR);
|
||||||
buttons |= IN_JUMP; //jump
|
buttons |= IN_JUMP; //jump
|
||||||
|
|
||||||
|
if (IsFakeClient(client) && fakes_hit_ground[client]) //fakes not affected by buttons
|
||||||
|
{
|
||||||
|
float fVelocity[3];
|
||||||
|
GetEntDataVector(client, g_iVelocity, fVelocity);
|
||||||
|
fVelocity[2] = 300.0;
|
||||||
|
TeleportEntity(client, NULL_VECTOR, NULL_VECTOR, fVelocity); //jump
|
||||||
|
fakes_hit_ground[client] = false;
|
||||||
|
}
|
||||||
has_to_jump_bots[client] = 2;
|
has_to_jump_bots[client] = 2;
|
||||||
}
|
}
|
||||||
if (GetEntityFlags(client) & FL_ONGROUND)
|
if (GetEntityFlags(client) & FL_ONGROUND)
|
||||||
{
|
{
|
||||||
GetEntPropVector(client, Prop_Send, "m_vecOrigin", coords_run_cmd[client]);
|
GetEntPropVector(client, Prop_Send, "m_vecOrigin", coords_run_cmd[client]);
|
||||||
has_to_jump_bots[client] = 0;
|
has_to_jump_bots[client] = 0;
|
||||||
|
fakes_hit_ground[client] = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
//fake clients movement input processed here
|
||||||
|
if (IsFakeClient(client))
|
||||||
|
{
|
||||||
|
int weapon_knife = GetPlayerWeaponSlot(client, 2);
|
||||||
|
int weapon_p90 = GetPlayerWeaponSlot(client, 0);
|
||||||
|
int weapon_elite = GetPlayerWeaponSlot(client, 1);
|
||||||
|
|
||||||
|
//check what weapon the client is currently using and set it to -1 so it wont constantly set it again
|
||||||
|
char weaponc[128];
|
||||||
|
GetClientWeapon(client, weaponc, sizeof(weaponc));
|
||||||
|
if (StrEqual(weaponc, "weapon_knife"))
|
||||||
|
{
|
||||||
|
weapon_knife = -1;
|
||||||
|
}
|
||||||
|
else if (StrEqual(weaponc, "weapon_p90"))
|
||||||
|
{
|
||||||
|
weapon_p90 = -1;
|
||||||
|
}
|
||||||
|
else if (StrEqual(weaponc, "weapon_elite"))
|
||||||
|
{
|
||||||
|
weapon_elite = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fakes_state[client] == 5 || fakes_state[client] == 7)
|
||||||
|
{
|
||||||
|
if (weapon_knife != -1)
|
||||||
|
EquipPlayerWeapon(client, weapon_knife);
|
||||||
|
}
|
||||||
|
else if (fakes_state[client] >= 3)
|
||||||
|
{
|
||||||
|
if (weapon_knife != -1)
|
||||||
|
EquipPlayerWeapon(client, weapon_knife);
|
||||||
|
vel[0] = 400.0;
|
||||||
|
vel[1] += 0.0;
|
||||||
|
vel[2] += 0.0;
|
||||||
|
}
|
||||||
|
else if (fakes_state[client] == 0)
|
||||||
|
{
|
||||||
|
if (weapon_p90 != -1)
|
||||||
|
EquipPlayerWeapon(client, weapon_p90);
|
||||||
|
}
|
||||||
|
else if (fakes_state[client] == 1)
|
||||||
|
{
|
||||||
|
if (weapon_elite != -1)
|
||||||
|
EquipPlayerWeapon(client, weapon_elite);
|
||||||
|
vel[0] = 400.0;
|
||||||
|
vel[1] += 0.0;
|
||||||
|
vel[2] += 0.0;
|
||||||
|
}
|
||||||
|
else if (fakes_state[client] == 2)
|
||||||
|
{
|
||||||
|
if (weapon_elite != -1)
|
||||||
|
EquipPlayerWeapon(client, weapon_elite);
|
||||||
|
}
|
||||||
|
|
||||||
|
int random = GetRandomInt(0, 1);
|
||||||
|
if (!random)
|
||||||
|
{
|
||||||
|
vel[0] += 0.0;
|
||||||
|
vel[1] += 400.0; //move right?
|
||||||
|
vel[2] += 0.0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
vel[0] += 0.0;
|
||||||
|
vel[1] -= 400.0; //move left?
|
||||||
|
vel[2] += 0.0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return Plugin_Continue;
|
return Plugin_Continue;
|
||||||
}
|
}
|
||||||
@ -295,7 +380,7 @@ public void Event_RoundEnd(Handle event, const char[] name, bool dontBroadcast)
|
|||||||
{
|
{
|
||||||
if (IsValidClient(i))
|
if (IsValidClient(i))
|
||||||
{
|
{
|
||||||
if (is_bot_player[i])
|
if (is_bot_player[i] || IsFakeClient(i))
|
||||||
{
|
{
|
||||||
has_to_jump_bots[i] = 3;
|
has_to_jump_bots[i] = 3;
|
||||||
}
|
}
|
||||||
@ -309,7 +394,7 @@ public void Event_RoundStart(Handle event, const char[] name, bool dontBroadcast
|
|||||||
{
|
{
|
||||||
if (IsValidClient(i))
|
if (IsValidClient(i))
|
||||||
{
|
{
|
||||||
if (is_bot_player[i])
|
if (is_bot_player[i] || IsFakeClient(i))
|
||||||
{
|
{
|
||||||
target_friend[i] = -1;
|
target_friend[i] = -1;
|
||||||
target_enemy[i] = -1;
|
target_enemy[i] = -1;
|
||||||
@ -565,7 +650,7 @@ public Action recursive_pressing(Handle timer, any data)
|
|||||||
{
|
{
|
||||||
found_enemy = true;
|
found_enemy = true;
|
||||||
}
|
}
|
||||||
if (!is_bot_player[client] && GetClientTeam(client) > 1)
|
if (!(is_bot_player[client] || IsFakeClient(client)) && GetClientTeam(client) > 1)
|
||||||
{
|
{
|
||||||
found_valid_ct = true;
|
found_valid_ct = true;
|
||||||
}
|
}
|
||||||
@ -573,7 +658,7 @@ public Action recursive_pressing(Handle timer, any data)
|
|||||||
for (int client = 1; client <= MaxClients; client++)
|
for (int client = 1; client <= MaxClients; client++)
|
||||||
{
|
{
|
||||||
if (!IsValidClient(client)) continue;
|
if (!IsValidClient(client)) continue;
|
||||||
if (!found_valid_ct && is_bot_player[client])
|
if (!found_valid_ct && (is_bot_player[client]))
|
||||||
{
|
{
|
||||||
if (GetClientTeam(client) != 0)
|
if (GetClientTeam(client) != 0)
|
||||||
ChangeClientTeam(client, 0);
|
ChangeClientTeam(client, 0);
|
||||||
@ -586,6 +671,9 @@ public Action recursive_pressing(Handle timer, any data)
|
|||||||
ChangeClientTeam(client, 2);
|
ChangeClientTeam(client, 2);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
if (is_bot_player[client] || IsFakeClient(client))
|
||||||
|
{
|
||||||
if (IsPlayerAlive(client))
|
if (IsPlayerAlive(client))
|
||||||
{
|
{
|
||||||
int targeteam = 0;
|
int targeteam = 0;
|
||||||
@ -738,6 +826,10 @@ public Action recursive_pressing(Handle timer, any data)
|
|||||||
{
|
{
|
||||||
send_socket_msg(message, strlen(message), ports[3]);
|
send_socket_msg(message, strlen(message), ports[3]);
|
||||||
}
|
}
|
||||||
|
if (IsFakeClient(client))
|
||||||
|
{
|
||||||
|
fakes_state[client] = state;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -745,7 +837,7 @@ public Action recursive_pressing(Handle timer, any data)
|
|||||||
for (int client = 1; client <= MaxClients; client++)
|
for (int client = 1; client <= MaxClients; client++)
|
||||||
{
|
{
|
||||||
if (!IsValidClient(client)) continue;
|
if (!IsValidClient(client)) continue;
|
||||||
if (!is_bot_player[client] && GetClientTeam(client) == 3 && IsPlayerAlive(client))
|
if (!(is_bot_player[client] || IsFakeClient(client)) && GetClientTeam(client) == 3 && IsPlayerAlive(client))
|
||||||
{
|
{
|
||||||
found_valid_ct = true;
|
found_valid_ct = true;
|
||||||
break;
|
break;
|
||||||
@ -756,7 +848,7 @@ public Action recursive_pressing(Handle timer, any data)
|
|||||||
for (int client = 1; client <= MaxClients; client++)
|
for (int client = 1; client <= MaxClients; client++)
|
||||||
{
|
{
|
||||||
if (!IsValidClient(client)) continue;
|
if (!IsValidClient(client)) continue;
|
||||||
if (is_bot_player[client] && GetClientTeam(client) == 3)
|
if ((is_bot_player[client] || IsFakeClient(client)) && GetClientTeam(client) == 3)
|
||||||
{
|
{
|
||||||
ForcePlayerSuicide(client);
|
ForcePlayerSuicide(client);
|
||||||
}
|
}
|
||||||
@ -779,11 +871,13 @@ public void trace_hulling_bot(int client)
|
|||||||
GetClientMins(client, mins);
|
GetClientMins(client, mins);
|
||||||
GetClientMaxs(client, maxs);
|
GetClientMaxs(client, maxs);
|
||||||
//increasing boxes sizes
|
//increasing boxes sizes
|
||||||
|
|
||||||
for (int ij = 0; ij < sizeof(mins) - 1; ij++)
|
for (int ij = 0; ij < sizeof(mins) - 1; ij++)
|
||||||
{
|
{
|
||||||
mins[ij] -= BOUNDINGBOX_INFLATION_OFFSET;
|
mins[ij] -= BOUNDINGBOX_INFLATION_OFFSET;
|
||||||
maxs[ij] += BOUNDINGBOX_INFLATION_OFFSET;
|
maxs[ij] += BOUNDINGBOX_INFLATION_OFFSET;
|
||||||
}
|
}
|
||||||
|
|
||||||
//acts as full body check
|
//acts as full body check
|
||||||
feet_origin[2] += BOUNDINGBOX_INFLATION_OFFSET;
|
feet_origin[2] += BOUNDINGBOX_INFLATION_OFFSET;
|
||||||
TR_TraceHullFilter(feet_origin, feet_origin, mins, maxs, MASK_ALL, TraceRayDontHitSelf);
|
TR_TraceHullFilter(feet_origin, feet_origin, mins, maxs, MASK_ALL, TraceRayDontHitSelf);
|
||||||
@ -814,6 +908,10 @@ public void trace_hulling_bot(int client)
|
|||||||
{
|
{
|
||||||
send_socket_msg(message, strlen(message), ports[3]);
|
send_socket_msg(message, strlen(message), ports[3]);
|
||||||
}
|
}
|
||||||
|
if (IsFakeClient(client))
|
||||||
|
{
|
||||||
|
FakeClientCommandEx(client, "+duck; wait 5; -duck;"); //crouch but probably not working for fakes.
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
//something blocks floor crouch
|
//something blocks floor crouch
|
||||||
@ -849,6 +947,13 @@ public void trace_hulling_bot(int client)
|
|||||||
{
|
{
|
||||||
send_socket_msg(message, strlen(message), ports[3]);
|
send_socket_msg(message, strlen(message), ports[3]);
|
||||||
}
|
}
|
||||||
|
if (IsFakeClient(client) && (GetEntityFlags(client) & FL_ONGROUND))
|
||||||
|
{
|
||||||
|
float fVelocity[3];
|
||||||
|
GetEntDataVector(client, g_iVelocity, fVelocity);
|
||||||
|
fVelocity[2] = 300.0;
|
||||||
|
TeleportEntity(client, NULL_VECTOR, NULL_VECTOR, fVelocity); //jump
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -920,6 +1025,13 @@ public void trace_hulling_bot(int client)
|
|||||||
{
|
{
|
||||||
send_socket_msg(message, strlen(message), ports[3]);
|
send_socket_msg(message, strlen(message), ports[3]);
|
||||||
}
|
}
|
||||||
|
if (IsFakeClient(client) && (GetEntityFlags(client) & FL_ONGROUND))
|
||||||
|
{
|
||||||
|
float fVelocity[3];
|
||||||
|
GetEntDataVector(client, g_iVelocity, fVelocity);
|
||||||
|
fVelocity[2] = 300.0;
|
||||||
|
TeleportEntity(client, NULL_VECTOR, NULL_VECTOR, fVelocity); //jump
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1010,7 +1122,7 @@ public int GetClosestClient_option1(bool finding_friend, int client, int enemy)
|
|||||||
dist_target = 8000000.0;
|
dist_target = 8000000.0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (is_bot_player[i])
|
if (is_bot_player[i] || IsFakeClient(i))
|
||||||
{
|
{
|
||||||
//just making sure bots have lowest priority
|
//just making sure bots have lowest priority
|
||||||
dist_target = 9000000.0;
|
dist_target = 9000000.0;
|
||||||
@ -1033,6 +1145,8 @@ public float get_power_distance(int target_player, float pos[3])
|
|||||||
|
|
||||||
public void OnClientPostAdminCheck(int client)
|
public void OnClientPostAdminCheck(int client)
|
||||||
{
|
{
|
||||||
|
fakes_hit_ground[client] = false;
|
||||||
|
fakes_state[client] = -1;
|
||||||
is_bot_player[client] = false;
|
is_bot_player[client] = false;
|
||||||
specific_bot_player[client] = 0;
|
specific_bot_player[client] = 0;
|
||||||
is_autism_bot1(client);
|
is_autism_bot1(client);
|
||||||
@ -1043,12 +1157,12 @@ public void OnClientPostAdminCheck(int client)
|
|||||||
{
|
{
|
||||||
if (!IsValidClient(i)) continue;
|
if (!IsValidClient(i)) continue;
|
||||||
|
|
||||||
if (is_bot_player[i] && i != client)
|
if ((is_bot_player[i] || IsFakeClient(client)) && i != client)
|
||||||
{
|
{
|
||||||
target_friend_afk_counter[i][client] = 0;
|
target_friend_afk_counter[i][client] = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (is_bot_player[client])
|
if (is_bot_player[client] || IsFakeClient(client))
|
||||||
{
|
{
|
||||||
if (g_hGetRunCmdPre != INVALID_HANDLE)
|
if (g_hGetRunCmdPre != INVALID_HANDLE)
|
||||||
DHookEntity(g_hGetRunCmdPre, false, client);
|
DHookEntity(g_hGetRunCmdPre, false, client);
|
||||||
@ -1124,6 +1238,8 @@ stock void connect_socket()
|
|||||||
|
|
||||||
public void OnClientDisconnect(int client)
|
public void OnClientDisconnect(int client)
|
||||||
{
|
{
|
||||||
|
fakes_hit_ground[client] = false;
|
||||||
|
fakes_state[client] = -1;
|
||||||
client_old_coords[client][0] = 0.0;
|
client_old_coords[client][0] = 0.0;
|
||||||
client_old_coords[client][1] = 0.0;
|
client_old_coords[client][1] = 0.0;
|
||||||
client_old_coords[client][2] = 0.0;
|
client_old_coords[client][2] = 0.0;
|
||||||
@ -1138,7 +1254,7 @@ public void OnClientDisconnect(int client)
|
|||||||
has_to_jump_bots[client] = 0;
|
has_to_jump_bots[client] = 0;
|
||||||
for (int i = 1; i <= MaxClients; i++)
|
for (int i = 1; i <= MaxClients; i++)
|
||||||
{
|
{
|
||||||
if (IsValidClient(i) && is_bot_player[i] && i != client)
|
if (IsValidClient(i) && (is_bot_player[i] || IsFakeClient(client)) && i != client)
|
||||||
{
|
{
|
||||||
target_friend_afk_counter[i][client] = 0;
|
target_friend_afk_counter[i][client] = 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user