minor updates and fixes
This commit is contained in:
parent
43cb66b2d8
commit
26315fe33e
@ -9,36 +9,40 @@ public Plugin myinfo =
|
|||||||
name = "test surfing plugin",
|
name = "test surfing plugin",
|
||||||
author = "jenzur",
|
author = "jenzur",
|
||||||
description = "hello ",
|
description = "hello ",
|
||||||
version = "1.0",
|
version = "1.1",
|
||||||
url = "www.unloze.com"
|
url = "www.unloze.com"
|
||||||
};
|
};
|
||||||
float bot_finished_surf_coords[MAXPLAYERS + 1][3];
|
float bot_finished_surf_coords[MAXPLAYERS + 1][3];
|
||||||
char map_coorindates[65][256];
|
char map_coorindates[65][256];
|
||||||
char map_recordname[65][256];
|
char map_recordname[65][256];
|
||||||
bool round_switch = false;
|
bool round_switch = false;
|
||||||
|
Handle g_hTraceTimer = null;
|
||||||
Database g_dDatabase;
|
Database g_dDatabase;
|
||||||
|
|
||||||
public void OnPluginStart()
|
public void OnPluginStart()
|
||||||
{
|
{
|
||||||
for (int i = 1; i <= MaxClients; i++)
|
for (int i = 1; i <= MaxClients; i++)
|
||||||
if (IsValidClient(i))
|
if (IsValidClient(i))
|
||||||
{
|
{
|
||||||
reset_client(i);
|
reset_client(i);
|
||||||
reset_bot_finished_surf(i);
|
reset_bot_finished_surf(i);
|
||||||
}
|
}
|
||||||
OnMapStart();
|
g_hTraceTimer = CreateTimer(0.30, update_mimic_coords, _, TIMER_REPEAT);
|
||||||
HookEvent("round_start", Event_RoundStart, EventHookMode_Pre);
|
OnMapStart();
|
||||||
HookEvent("round_end", OnRoundEnd, EventHookMode_Pre);
|
HookEvent("round_start", Event_RoundStart, EventHookMode_Pre);
|
||||||
|
HookEvent("round_end", OnRoundEnd, EventHookMode_Pre);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnPluginEnd()
|
public void OnPluginEnd()
|
||||||
{
|
{
|
||||||
for (int i = 1; i <= MaxClients; i++)
|
for (int i = 1; i <= MaxClients; i++)
|
||||||
if (IsValidClient(i))
|
if (IsValidClient(i))
|
||||||
{
|
{
|
||||||
reset_client(i);
|
reset_client(i);
|
||||||
reset_bot_finished_surf(i);
|
reset_bot_finished_surf(i);
|
||||||
}
|
}
|
||||||
|
if (g_hTraceTimer != null)
|
||||||
|
delete g_hTraceTimer;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Action OnRoundEnd(Handle event, const char[] name, bool dontBroadcast)
|
public Action OnRoundEnd(Handle event, const char[] name, bool dontBroadcast)
|
||||||
@ -53,14 +57,14 @@ public void Event_RoundStart(Handle event, const char[] name, bool dontBroadcast
|
|||||||
|
|
||||||
public void perform_resets()
|
public void perform_resets()
|
||||||
{
|
{
|
||||||
round_switch = true;
|
round_switch = true;
|
||||||
for (int i = 1; i <= MaxClients; i++)
|
for (int i = 1; i <= MaxClients; i++)
|
||||||
if (IsValidClient(i))
|
if (IsValidClient(i))
|
||||||
{
|
{
|
||||||
reset_client(i);
|
reset_client(i);
|
||||||
reset_bot_finished_surf(i);
|
reset_bot_finished_surf(i);
|
||||||
}
|
}
|
||||||
CreateTimer(7.00, reset_round_switch, INVALID_HANDLE);
|
CreateTimer(7.00, reset_round_switch, INVALID_HANDLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Action reset_round_switch(Handle timer, any data)
|
public Action reset_round_switch(Handle timer, any data)
|
||||||
@ -71,7 +75,7 @@ public Action reset_round_switch(Handle timer, any data)
|
|||||||
stock bool IsValidClient(int client)
|
stock bool IsValidClient(int client)
|
||||||
{
|
{
|
||||||
if (client > 0 && client <= MaxClients && IsClientConnected(client) && IsClientInGame(client))
|
if (client > 0 && client <= MaxClients && IsClientConnected(client) && IsClientInGame(client))
|
||||||
return true;
|
return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -88,106 +92,106 @@ public void OnClientDisconnect(int client)
|
|||||||
|
|
||||||
public void reset_bot_finished_surf(int client)
|
public void reset_bot_finished_surf(int client)
|
||||||
{
|
{
|
||||||
bot_finished_surf_coords[client][0] = 0.0;
|
bot_finished_surf_coords[client][0] = 0.0;
|
||||||
bot_finished_surf_coords[client][1] = 0.0;
|
bot_finished_surf_coords[client][1] = 0.0;
|
||||||
bot_finished_surf_coords[client][2] = 0.0;
|
bot_finished_surf_coords[client][2] = 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void reset_client(int client)
|
public void reset_client(int client)
|
||||||
{
|
{
|
||||||
if (bot_finished_surf_coords[client][0] != 0.0)
|
if (BotMimic_IsPlayerMimicing(client))
|
||||||
{
|
{
|
||||||
BotMimic_StopPlayerMimic(client);
|
BotMimic_StopPlayerMimic(client);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public int BotMimic_OnPlayerMimicLoops(int client)
|
public int BotMimic_OnPlayerMimicLoops(int client)
|
||||||
{
|
{
|
||||||
char map_name[256];
|
char map_name[256];
|
||||||
GetCurrentMap(map_name, sizeof(map_name));
|
GetCurrentMap(map_name, sizeof(map_name));
|
||||||
if (StrContains(map_name, "ze_surf", false) == -1)
|
if (StrContains(map_name, "ze_surf", false) == -1)
|
||||||
{
|
{
|
||||||
reset_client(client);
|
reset_client(client);
|
||||||
reset_bot_finished_surf(client);
|
reset_bot_finished_surf(client);
|
||||||
}
|
}
|
||||||
else if (bot_finished_surf_coords[client][0] != 0.0)
|
else if (bot_finished_surf_coords[client][0] != 0.0)
|
||||||
{
|
{
|
||||||
reset_client(client);
|
reset_client(client);
|
||||||
TeleportEntity(client, bot_finished_surf_coords[client], NULL_VECTOR, NULL_VECTOR);
|
TeleportEntity(client, bot_finished_surf_coords[client], NULL_VECTOR, NULL_VECTOR);
|
||||||
reset_bot_finished_surf(client);
|
reset_bot_finished_surf(client);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
GetEntPropVector(client, Prop_Send, "m_vecOrigin", bot_finished_surf_coords[client]);
|
GetEntPropVector(client, Prop_Send, "m_vecOrigin", bot_finished_surf_coords[client]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Action update_mimic_coords(Handle timer, any data)
|
public Action update_mimic_coords(Handle timer, any data)
|
||||||
{
|
{
|
||||||
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))
|
||||||
{
|
{
|
||||||
if (bot_finished_surf_coords[i][0] != 0.0)
|
if (bot_finished_surf_coords[i][0] != 0.0)
|
||||||
{
|
{
|
||||||
GetEntPropVector(i, Prop_Send, "m_vecOrigin", bot_finished_surf_coords[i]);
|
GetEntPropVector(i, Prop_Send, "m_vecOrigin", bot_finished_surf_coords[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (round_switch)
|
if (round_switch)
|
||||||
{
|
{
|
||||||
return Plugin_Continue;
|
return Plugin_Continue;
|
||||||
}
|
}
|
||||||
Handle records_list = BotMimic_GetLoadedRecordList();
|
Handle records_list = BotMimic_GetLoadedRecordList();
|
||||||
for (int i = 0; i < sizeof(map_coorindates); i++)
|
for (int i = 0; i < sizeof(map_coorindates); i++)
|
||||||
{
|
{
|
||||||
bool found = false;
|
bool found = false;
|
||||||
char char_coord[3][256];
|
char char_coord[3][256];
|
||||||
if (strlen(map_coorindates[i]) > 0)
|
if (strlen(map_coorindates[i]) > 0)
|
||||||
{
|
{
|
||||||
ExplodeString(map_coorindates[i], " ", char_coord, sizeof(char_coord[]), sizeof(char_coord[]));
|
ExplodeString(map_coorindates[i], " ", char_coord, sizeof(char_coord[]), sizeof(char_coord[]));
|
||||||
float coords[3];
|
float coords[3];
|
||||||
coords[0] = StringToFloat(char_coord[0]);
|
coords[0] = StringToFloat(char_coord[0]);
|
||||||
coords[1] = StringToFloat(char_coord[1]);
|
coords[1] = StringToFloat(char_coord[1]);
|
||||||
coords[2] = StringToFloat(char_coord[2]);
|
coords[2] = StringToFloat(char_coord[2]);
|
||||||
for (int j = 1; j <= MaxClients; j++)
|
for (int j = 1; j <= MaxClients; j++)
|
||||||
{
|
{
|
||||||
if (IsValidClient(j) && bot_finished_surf_coords[j][0] == 0.0 && is_bot_player(j))
|
if (IsValidClient(j) && bot_finished_surf_coords[j][0] == 0.0 && is_bot_player(j))
|
||||||
{
|
{
|
||||||
float distance = get_power_distance(j, coords);
|
float distance = get_power_distance(j, coords);
|
||||||
if (distance < 225.0)
|
if (distance < 225.0)
|
||||||
{
|
{
|
||||||
char path[256];
|
char path[1024];
|
||||||
for (int f = 0; f < GetArraySize(records_list); f++)
|
for (int f = 0; f < GetArraySize(records_list); f++)
|
||||||
{
|
{
|
||||||
if (f != i) continue;
|
if (f != i) continue;
|
||||||
GetArrayString(records_list, f, path, sizeof(path));
|
GetArrayString(records_list, f, path, sizeof(path));
|
||||||
for (int h = 0; h < sizeof(map_recordname); h++)
|
for (int h = 0; h < sizeof(map_recordname); h++)
|
||||||
{
|
{
|
||||||
//i != h assures coordinates match the right iterated name
|
//i != h assures coordinates match the right iterated name
|
||||||
if (strlen(map_recordname[h]) == 0 || i != h)
|
if (strlen(map_recordname[h]) == 0 || i != h)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (StrEqual(path, map_recordname[h], false))
|
if (StrEqual(path, map_recordname[h], false))
|
||||||
{
|
{
|
||||||
BotMimic_PlayRecordFromFile(j, path);
|
BotMimic_PlayRecordFromFile(j, path);
|
||||||
found = true;
|
found = true;
|
||||||
}
|
}
|
||||||
if (found)
|
if (found)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (found)
|
if (found)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (found)
|
if (found)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (found)
|
if (found)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return Plugin_Continue;
|
return Plugin_Continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
public float get_power_distance(int target_player, float [3]pos)
|
public float get_power_distance(int target_player, float [3]pos)
|
||||||
@ -254,20 +258,19 @@ public void SQL_OnQueryCompleted(Database db, DBResultSet results, const char[]
|
|||||||
|
|
||||||
public void OnMapStart()
|
public void OnMapStart()
|
||||||
{
|
{
|
||||||
for (int i = 1; i <= MaxClients; i++)
|
for (int i = 1; i <= MaxClients; i++)
|
||||||
if (IsValidClient(i))
|
if (IsValidClient(i))
|
||||||
{
|
{
|
||||||
reset_bot_finished_surf(i);
|
reset_bot_finished_surf(i);
|
||||||
}
|
}
|
||||||
char map_name[256];
|
char map_name[256];
|
||||||
GetCurrentMap(map_name, sizeof(map_name));
|
GetCurrentMap(map_name, sizeof(map_name));
|
||||||
if (!g_dDatabase)
|
if (!g_dDatabase)
|
||||||
Database.Connect(SQL_OnDatabaseConnect, "bot_surfing");
|
Database.Connect(SQL_OnDatabaseConnect, "bot_surfing");
|
||||||
else if(StrContains(map_name, "ze_surf", false) != -1)
|
else if(StrContains(map_name, "ze_surf", false) != -1)
|
||||||
{
|
{
|
||||||
select_map_related_surfs();
|
select_map_related_surfs();
|
||||||
CreateTimer(0.30, update_mimic_coords, INVALID_HANDLE, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE);
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SQL_OnDatabaseConnect(Database db, const char[] error, any data)
|
public void SQL_OnDatabaseConnect(Database db, const char[] error, any data)
|
||||||
@ -285,11 +288,11 @@ public void SQL_OnDatabaseConnect(Database db, const char[] error, any data)
|
|||||||
|
|
||||||
public void SQL_insertQuery_record_saved(Database db, DBResultSet results, const char[] error, DataPack data)
|
public void SQL_insertQuery_record_saved(Database db, DBResultSet results, const char[] error, DataPack data)
|
||||||
{
|
{
|
||||||
if (!db || strlen(error))
|
if (!db || strlen(error))
|
||||||
{
|
{
|
||||||
LogError("Query error: %s", error);
|
LogError("Query error: %s", error);
|
||||||
}
|
}
|
||||||
select_map_related_surfs();
|
select_map_related_surfs();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SQL_insertQuery(Database db, DBResultSet results, const char[] error, DataPack data)
|
public void SQL_insertQuery(Database db, DBResultSet results, const char[] error, DataPack data)
|
||||||
@ -311,19 +314,17 @@ public void SQL_FinishedQuery_creating_tables(Database db, DBResultSet results,
|
|||||||
if (StrContains(map_name, "ze_surf", false) != -1)
|
if (StrContains(map_name, "ze_surf", false) != -1)
|
||||||
{
|
{
|
||||||
select_map_related_surfs();
|
select_map_related_surfs();
|
||||||
CreateTimer(0.30, update_mimic_coords, INVALID_HANDLE, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public bool is_bot_player(int client)
|
public bool is_bot_player(int client)
|
||||||
{
|
{
|
||||||
bool debug_b = false;
|
bool debug_b = false;
|
||||||
if (debug_b && is_jenz(client))
|
if (debug_b && is_jenz(client))
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return is_autism_bot1(client) || is_autism_bot2(client) || is_autism_bot3(client) || is_autism_bot4(client); //change to true for debugging on dev
|
return is_autism_bot1(client) || is_autism_bot2(client) || is_autism_bot3(client) || is_autism_bot4(client); //change to true for debugging on dev
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool is_jenz(int client)
|
public bool is_jenz(int client)
|
||||||
|
Loading…
Reference in New Issue
Block a user