removed trigger hooking entirely
This commit is contained in:
parent
714f73daff
commit
1d4bf1451c
@ -52,7 +52,9 @@ if [[ $DISPLAY ]]; then
|
|||||||
echo 'SDL_VIDEO_X11_VISUALID: ' $SDL_VIDEO_X11_VISUALID
|
echo 'SDL_VIDEO_X11_VISUALID: ' $SDL_VIDEO_X11_VISUALID
|
||||||
export SDL_VIDEO_X11_VISUALID=0x205
|
export SDL_VIDEO_X11_VISUALID=0x205
|
||||||
echo 'SDL_VIDEO_X11_VISUALID: ' $SDL_VIDEO_X11_VISUALID
|
echo 'SDL_VIDEO_X11_VISUALID: ' $SDL_VIDEO_X11_VISUALID
|
||||||
steam -no-browser -console #should reduce ram usage
|
#native libraries tried instead of runtime libraries for not crashing i suppose, no-browser -console should also save RAM usage
|
||||||
|
#STEAM_RUNTIME=0 steam no-browser -console
|
||||||
|
steam no-browser -console
|
||||||
fi
|
fi
|
||||||
|
|
||||||
##steam settings -> library -> low bandwith mode and low performance mode
|
##steam settings -> library -> low bandwith mode and low performance mode
|
||||||
@ -62,3 +64,16 @@ fi
|
|||||||
#keeps session as R instead of S which is needed for interaction with graphical components such as steam and CS:S
|
#keeps session as R instead of S which is needed for interaction with graphical components such as steam and CS:S
|
||||||
|
|
||||||
ovh: 0x205, 0x209
|
ovh: 0x205, 0x209
|
||||||
|
|
||||||
|
#if running steam native libraries instead of runtime libraries one might require following apt install for making libpipewire work
|
||||||
|
#specifically on debian steam
|
||||||
|
apt install pipewire:i386
|
||||||
|
apt-get install libbz2-1.0:i386
|
||||||
|
|
||||||
|
#further steam native libraries specifically for debian
|
||||||
|
apt-get install libxtst6:i386 libxrandr2:i386 libglib2.0-0:i386 libgtk2.0-0:i386 libpulse0:i386 libgdk-pixbuf2.0-0:i386 libcurl4-openssl-dev:i386 libopenal1:i386 libusb-1.0-0:i386 libdbus-glib-1-2:i386
|
||||||
|
apt-get install libsm6:i386
|
||||||
|
|
||||||
|
#check if all libs are present with
|
||||||
|
cd ~/.steam/steam/ubuntu12_32
|
||||||
|
LD_LIBRARY_PATH=. ldd vgui2_s.so
|
||||||
|
@ -243,6 +243,7 @@ if [[ $DISPLAY ]]; then
|
|||||||
echo 'SDL_VIDEO_X11_VISUALID: ' $SDL_VIDEO_X11_VISUALID
|
echo 'SDL_VIDEO_X11_VISUALID: ' $SDL_VIDEO_X11_VISUALID
|
||||||
export SDL_VIDEO_X11_VISUALID=0x205
|
export SDL_VIDEO_X11_VISUALID=0x205
|
||||||
echo 'SDL_VIDEO_X11_VISUALID: ' $SDL_VIDEO_X11_VISUALID
|
echo 'SDL_VIDEO_X11_VISUALID: ' $SDL_VIDEO_X11_VISUALID
|
||||||
steam
|
#native libraries being prefered over runtime here
|
||||||
|
STEAM_RUNTIME=0 steam no-browser -console
|
||||||
fi
|
fi
|
||||||
"""
|
"""
|
||||||
|
@ -22,7 +22,7 @@ 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
|
||||||
int bot_avoid_edge[MAXPLAYERS + 1];
|
int bot_avoid_edge[MAXPLAYERS + 1];
|
||||||
float client_old_coords[MAXPLAYERS + 1][3];
|
float client_old_coords[MAXPLAYERS + 1][3];
|
||||||
float targethuman_teleported[MAXPLAYERS + 1][3];
|
float targethuman_self_teleported[MAXPLAYERS + 1][3];
|
||||||
bool chat_cooldown = false;
|
bool chat_cooldown = false;
|
||||||
|
|
||||||
//admins & vips
|
//admins & vips
|
||||||
@ -48,58 +48,46 @@ public void OnPluginStart()
|
|||||||
{
|
{
|
||||||
target_friend[i] = 0;
|
target_friend[i] = 0;
|
||||||
target_enemy[i] = 0;
|
target_enemy[i] = 0;
|
||||||
reset_target_human_tp_coord(i);
|
|
||||||
OnClientPostAdminCheck(i);
|
OnClientPostAdminCheck(i);
|
||||||
}
|
}
|
||||||
//talking
|
//talking
|
||||||
RegConsoleCmd("sm_autism", cmd_talk, "talking to the bot through java application");
|
RegConsoleCmd("sm_autism", cmd_talk, "talking to the bot through java application");
|
||||||
RegConsoleCmd("sm_botrtv", cmd_botrtv, "making bots rtv");
|
RegConsoleCmd("sm_botrtv", cmd_botrtv, "making bots rtv");
|
||||||
|
|
||||||
//hooks
|
|
||||||
HookEvent("round_start", Event_RoundStart, EventHookMode_PostNoCopy);
|
|
||||||
HookEvent("round_end", Event_RoundEnd);
|
|
||||||
//UDP connection
|
//UDP connection
|
||||||
connect_socket();
|
connect_socket();
|
||||||
chat_cooldown = false;
|
chat_cooldown = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void reset_target_human_tp_coord(int client)
|
public void reset_target_tp(int client)
|
||||||
{
|
{
|
||||||
targethuman_teleported[client][0] = 0.0;
|
if (IsValidClient(client) && is_bot_player(client))
|
||||||
targethuman_teleported[client][1] = 0.0;
|
{
|
||||||
targethuman_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 bool origin_command_check(int entity_index)
|
public Action reset_target_tp_timer(Handle timer, int client)
|
||||||
{
|
{
|
||||||
int count_trigger = GetOutputCount(entity_index, "m_OnTrigger");
|
reset_target_tp(client);
|
||||||
int count_starttouch = GetOutputCount(entity_index, "m_OnStartTouch");
|
|
||||||
for (int i = 0; i < count_trigger; i++)
|
|
||||||
{
|
|
||||||
char buffer[generic_length];
|
|
||||||
GetOutputParameter(entity_index, "m_OnTrigger", i, buffer, sizeof(buffer));
|
|
||||||
if (StrContains(buffer, "origin", true) != -1)
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
for (int i = 0; i < count_starttouch; i++)
|
|
||||||
{
|
|
||||||
char buffer[generic_length];
|
|
||||||
GetOutputParameter(entity_index, "m_OnStartTouch", i, buffer, sizeof(buffer));
|
|
||||||
if (StrContains(buffer, "origin", true) != -1)
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Action reset_target_tp(Handle timer, int client)
|
|
||||||
{
|
|
||||||
reset_target_human_tp_coord(client);
|
|
||||||
return Plugin_Continue;
|
return Plugin_Continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool distance_check(int client)
|
public bool distance_check(int client, int botclient, bool nowpos)
|
||||||
{
|
{
|
||||||
float dist_target = get_power_distance(client, targethuman_teleported[client]);
|
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
|
||||||
|
{
|
||||||
|
dist_target = get_power_distance(client, targethuman_self_teleported[botclient]);
|
||||||
|
}
|
||||||
float min_required_distance = 50000.0;
|
float min_required_distance = 50000.0;
|
||||||
if (dist_target > min_required_distance)
|
if (dist_target > min_required_distance)
|
||||||
return false;
|
return false;
|
||||||
@ -233,129 +221,18 @@ public Action bot_chat_cooldown(Handle timer, any data)
|
|||||||
return Plugin_Continue;
|
return Plugin_Continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void unhookAll()
|
public void did_target_tp(int client, int bot_client)
|
||||||
{
|
{
|
||||||
int entity_tp = MaxClients + 1;
|
if (client == bot_client && targethuman_self_teleported[client][0] != 0.0 && !distance_check(client, bot_client, false))
|
||||||
int entity_mp = MaxClients + 1;
|
|
||||||
while((entity_mp = FindEntityByClassname(entity_mp, "trigger_multiple")) != -1)
|
|
||||||
{
|
{
|
||||||
char targetName[64];
|
reset_target_tp(client);
|
||||||
GetEntPropString(entity_mp, Prop_Data, "m_iName", targetName, sizeof(targetName));
|
|
||||||
if (strlen(targetName) > 0)
|
|
||||||
{
|
|
||||||
UnhookSingleEntityOutput(entity_mp, "OnStartTouch", OnEntityOutPut_mp);
|
|
||||||
UnhookSingleEntityOutput(entity_mp, "OnTrigger", OnEntityOutPut_mp);
|
|
||||||
}
|
}
|
||||||
}
|
else if (client != bot_client && targethuman_self_teleported[bot_client][0] == 0.0 && !distance_check(client, bot_client, true))
|
||||||
while((entity_tp = FindEntityByClassname(entity_tp, "trigger_teleport")) != -1)
|
|
||||||
{
|
{
|
||||||
char targetName[64];
|
GetEntPropVector(client, Prop_Send, "m_vecOrigin", targethuman_self_teleported[bot_client]);
|
||||||
GetEntPropString(entity_tp, Prop_Data, "m_iName", targetName, sizeof(targetName));
|
CreateTimer(6.0, reset_target_tp_timer, bot_client);
|
||||||
if (strlen(targetName) > 0)
|
|
||||||
{
|
|
||||||
UnhookSingleEntityOutput(entity_tp, "OnStartTouch", OnEntityOutPut_tp);
|
|
||||||
UnhookSingleEntityOutput(entity_tp, "OnTrigger", OnEntityOutPut_tp);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void Event_RoundEnd(Event event, const char[] name, bool dontBroadcast)
|
|
||||||
{
|
|
||||||
unhookAll();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void round_start_void()
|
|
||||||
{
|
|
||||||
unhookAll();
|
|
||||||
for (int i = 1; i <= MaxClients; i++)
|
|
||||||
if (IsValidClient(i) && !IsFakeClient(i))
|
|
||||||
{
|
|
||||||
target_friend[i] = 0;
|
|
||||||
target_enemy[i] = 0;
|
|
||||||
reset_target_human_tp_coord(i);
|
|
||||||
}
|
|
||||||
int entity_tp = MaxClients + 1;
|
|
||||||
int entity_mp = MaxClients + 1;
|
|
||||||
while((entity_mp = FindEntityByClassname(entity_mp, "trigger_multiple")) != -1)
|
|
||||||
{
|
|
||||||
char targetName[64];
|
|
||||||
GetEntPropString(entity_mp, Prop_Data, "m_iName", targetName, sizeof(targetName));
|
|
||||||
if (strlen(targetName) > 0)
|
|
||||||
{
|
|
||||||
HookSingleEntityOutput(entity_mp, "OnStartTouch", OnEntityOutPut_mp, true);
|
|
||||||
HookSingleEntityOutput(entity_mp, "OnTrigger", OnEntityOutPut_mp, true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
while((entity_tp = FindEntityByClassname(entity_tp, "trigger_teleport")) != -1)
|
|
||||||
{
|
|
||||||
char targetName[64];
|
|
||||||
GetEntPropString(entity_tp, Prop_Data, "m_iName", targetName, sizeof(targetName));
|
|
||||||
if (strlen(targetName) > 0)
|
|
||||||
{
|
|
||||||
HookSingleEntityOutput(entity_tp, "OnStartTouch", OnEntityOutPut_tp, true);
|
|
||||||
HookSingleEntityOutput(entity_tp, "OnTrigger", OnEntityOutPut_tp, true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Event_RoundStart(Handle event, const char[] name, bool dontBroadcast)
|
|
||||||
{
|
|
||||||
round_start_void();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void OnEntityOutPut_mp(const char[] output, int entity_index, int client, float delay)
|
|
||||||
{
|
|
||||||
if (IsValidEdict(entity_index) && origin_command_check(entity_index))
|
|
||||||
{
|
|
||||||
for (int i = 1; i <= MaxClients; i++)
|
|
||||||
if (IsValidClient(i))
|
|
||||||
{
|
|
||||||
if (target_friend[i] == client)
|
|
||||||
{
|
|
||||||
GetEntPropVector(client, Prop_Send, "m_vecOrigin", targethuman_teleported[i]);
|
|
||||||
CreateTimer(6.0, reset_target_tp, client);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
else if (is_bot_player(i) && i == client)
|
|
||||||
{
|
|
||||||
CreateTimer(0.1, reset_target_tp, client);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
UnhookSingleEntityOutput(entity_index, "OnStartTouch", OnEntityOutPut_mp);
|
|
||||||
UnhookSingleEntityOutput(entity_index, "OnTrigger", OnEntityOutPut_mp);
|
|
||||||
//experimental if unhooking very shortly solves tp lag
|
|
||||||
DataPack dPack;
|
|
||||||
CreateDataTimer(0.5, reset_hook_mp, dPack);
|
|
||||||
dPack.WriteCell(entity_index);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void OnEntityOutPut_tp(const char[] output, int entity_index, int client, float delay)
|
|
||||||
{
|
|
||||||
for (int i = 1; i <= MaxClients; i++)
|
|
||||||
if (IsValidClient(i))
|
|
||||||
{
|
|
||||||
//i is an autismbot following this player
|
|
||||||
if (target_friend[i] == client)
|
|
||||||
{
|
|
||||||
GetEntPropVector(client, Prop_Send, "m_vecOrigin", targethuman_teleported[i]);
|
|
||||||
CreateTimer(6.0, reset_target_tp, client);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
else if (is_bot_player(i) && i == client)
|
|
||||||
{
|
|
||||||
CreateTimer(0.1, reset_target_tp, client);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
UnhookSingleEntityOutput(entity_index, "OnStartTouch", OnEntityOutPut_tp);
|
|
||||||
UnhookSingleEntityOutput(entity_index, "OnTrigger", OnEntityOutPut_tp);
|
|
||||||
//experimental if unhooking very shortly solves tp lag
|
|
||||||
DataPack dPack;
|
|
||||||
CreateDataTimer(0.5, reset_hook_tp, dPack);
|
|
||||||
dPack.WriteCell(entity_index);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void OnMapStart()
|
public void OnMapStart()
|
||||||
{
|
{
|
||||||
@ -588,30 +465,6 @@ public bool is_bot_player(int client)
|
|||||||
return is_autism_bot1(client) || is_autism_bot2(client) || is_autism_bot3(client) || is_autism_bot4(client);
|
return is_autism_bot1(client) || is_autism_bot2(client) || is_autism_bot3(client) || is_autism_bot4(client);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Action reset_hook_mp(Handle timer, DataPack dPack)
|
|
||||||
{
|
|
||||||
dPack.Reset();
|
|
||||||
int entity_index = dPack.ReadCell();
|
|
||||||
if (IsValidEdict(entity_index))
|
|
||||||
{
|
|
||||||
HookSingleEntityOutput(entity_index, "OnStartTouch", OnEntityOutPut_mp, true);
|
|
||||||
HookSingleEntityOutput(entity_index, "OnTrigger", OnEntityOutPut_mp, true);
|
|
||||||
}
|
|
||||||
return Plugin_Continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Action reset_hook_tp(Handle timer, DataPack dPack)
|
|
||||||
{
|
|
||||||
dPack.Reset();
|
|
||||||
int entity_index = dPack.ReadCell();
|
|
||||||
if (IsValidEdict(entity_index))
|
|
||||||
{
|
|
||||||
HookSingleEntityOutput(entity_index, "OnStartTouch", OnEntityOutPut_tp, true);
|
|
||||||
HookSingleEntityOutput(entity_index, "OnTrigger", OnEntityOutPut_tp, true);
|
|
||||||
}
|
|
||||||
return Plugin_Continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Action recursive_pressing(Handle timer, any data)
|
public Action recursive_pressing(Handle timer, any data)
|
||||||
{
|
{
|
||||||
bool found_valid_ct = false;
|
bool found_valid_ct = false;
|
||||||
@ -650,24 +503,33 @@ public Action recursive_pressing(Handle timer, any data)
|
|||||||
//3 = autismo is human and should follow closest moving ct
|
//3 = autismo is human and should follow closest moving ct
|
||||||
targeteam = 3;
|
targeteam = 3;
|
||||||
}
|
}
|
||||||
if (targethuman_teleported[client][0] != 0.0)
|
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 ClientPos[3];
|
||||||
float Result[3];
|
float Result[3];
|
||||||
GetClientEyePosition(client, ClientPos);
|
GetClientEyePosition(client, ClientPos);
|
||||||
MakeVectorFromPoints(ClientPos, targethuman_teleported[client], Result);
|
MakeVectorFromPoints(ClientPos, targethuman_self_teleported[client], Result);
|
||||||
GetVectorAngles(Result, Result);
|
GetVectorAngles(Result, Result);
|
||||||
TeleportEntity(client, NULL_VECTOR, Result, NULL_VECTOR);
|
TeleportEntity(client, NULL_VECTOR, Result, NULL_VECTOR);
|
||||||
if (!distance_check(client))
|
if (!distance_check(client, client, false))
|
||||||
reset_target_human_tp_coord(client);
|
reset_target_tp(client);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
//no target in water somehow
|
//no target in water somehow
|
||||||
target_enemy[client] = GetClosestClient_option1(false, client);
|
target_enemy[client] = GetClosestClient_option1(false, client);
|
||||||
target_friend[client] = GetClosestClient_option1(true, client);
|
target_friend[client] = GetClosestClient_option1(true, client);
|
||||||
|
float pos[3];
|
||||||
|
did_target_tp(client, client);
|
||||||
float enemy_distance = -1.0;
|
float enemy_distance = -1.0;
|
||||||
float dist_target = -1.0;
|
float dist_target = -1.0;
|
||||||
float pos[3];
|
|
||||||
if (IsValidClient(target_friend[client]))
|
if (IsValidClient(target_friend[client]))
|
||||||
{
|
{
|
||||||
GetEntPropVector(target_friend[client], Prop_Send, "m_vecOrigin", pos);
|
GetEntPropVector(target_friend[client], Prop_Send, "m_vecOrigin", pos);
|
||||||
@ -1008,6 +870,7 @@ public void OnClientPostAdminCheck(int client)
|
|||||||
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;
|
||||||
|
reset_target_tp(client);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnSocketError(Handle socket, const int errorType, const int errorNum, any args)
|
public void OnSocketError(Handle socket, const int errorType, const int errorNum, any args)
|
||||||
@ -1052,6 +915,7 @@ public void OnClientDisconnect(int client)
|
|||||||
if (IsValidClient(i) && is_bot_player(i) && i != client)
|
if (IsValidClient(i) && is_bot_player(i) && i != client)
|
||||||
target_friend_afk_counter[i][client] = 0;
|
target_friend_afk_counter[i][client] = 0;
|
||||||
}
|
}
|
||||||
|
reset_target_tp(client);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Socket callback
|
//Socket callback
|
||||||
|
Loading…
Reference in New Issue
Block a user