Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Insurgency Bot Objective Capture
- * http://www.hlxcommunity.com/
- * Copyright (C) 2010 Deadbwoy
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
- #pragma semicolon 1
- #include <sourcemod>
- #include <sdktools>
- #define VERSION "1.0"
- new String:g_teamlist[4][17] = { "Unassigned", "", "", "SPECTATOR" };
- public Plugin:myinfo = {
- name = "Insurgency Bot Objective Capture",
- author = "Deadbwoy",
- description = "Gets a bot to freeze after entering an objective so they will capture objectives.",
- version = VERSION,
- url = "http://www.insmod.org"
- };
- public OnPluginStart()
- {
- PrintToConsole(0, "[SM] INS_BOC v1.0 by Deadbwoy loaded successfully!");
- CreateConVar("ins_boc_version", VERSION, "Insurgency Bot Objective Capture", FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY);
- GetTeams();
- HookUserMessage(GetUserMessageId("ObjMsg"), objmsg);
- HookEntityOutput("ins_objective", "OnCapture", BOC_Capture);
- }
- public OnMapStart()
- {
- GetTeams();
- new ent=-1;
- decl Float:EntPosition[3];
- while ((ent = FindEntityByClassname(ent, "ins_objective")) != -1)
- {
- GetEntityAbsOrigin(ent,EntPosition);
- }
- }
- public Action:objmsg(UserMsg:msg_id, Handle:bf, const players[], playersNum, bool:reliable, bool:init)
- {
- new byte1;
- new byte2;
- new byte3;
- byte1 = BfReadByte(bf); // Objective Point: 1 = point A, 2 = point B, 3 = point C, etc.
- byte2 = BfReadByte(bf); // Capture Status: 1 on starting capture, 2 on finished capture
- byte3 = BfReadByte(bf); // Team Index: 1 = Marines, 2 = Insurgents
- if (byte2 == 1)
- {
- decl String:capname[2];
- switch (byte1)
- {
- case 1:
- strcopy(capname, 2, "a");
- case 2:
- strcopy(capname, 2, "b");
- case 3:
- strcopy(capname, 2, "c");
- case 4:
- strcopy(capname, 2, "d");
- case 5:
- strcopy(capname, 2, "e");
- }
- LogToGame("BOC: OBJMSG FUNC triggered start_cap %s by team: %s", capname, g_teamlist[byte3]);
- BotSearch();
- }
- if (byte2 == 2)
- {
- decl String:pointname[2];
- switch (byte1)
- {
- case 1:
- strcopy(pointname, 2, "a");
- case 2:
- strcopy(pointname, 2, "b");
- case 3:
- strcopy(pointname, 2, "c");
- case 4:
- strcopy(pointname, 2, "d");
- case 5:
- strcopy(pointname, 2, "e");
- }
- LogToGame("Team \"%s\" triggered \"captured_%s\"", g_teamlist[byte3], pointname);
- }
- return Plugin_Continue;
- }
- GetTeams()
- {
- decl String:mapname[64];
- GetCurrentMap(mapname, sizeof(mapname));
- if (strcmp(mapname, "ins_karam") == 0 || strcmp(mapname, "ins_baghdad") == 0)
- {
- g_teamlist[1] = "Iraqi Insurgents";
- g_teamlist[2] = "U.S. Marines";
- }
- else
- {
- g_teamlist[1] = "U.S. Marines";
- g_teamlist[2] = "Iraqi Insurgents";
- }
- }
- BotSearch()
- {
- //Declare:
- decl MaxPlayers;
- //Initialize:
- MaxPlayers = GetMaxClients();
- //Loop:
- for(new client = 1; client <= MaxPlayers; client++)
- {
- if(IsClientInGame(client) && IsPlayerAlive(client) && IsFakeClient(client))
- {
- new Float:vec[3];
- GetClientAbsOrigin(client, Float:vec);
- LogToGame("BOC: Bot Found During Bot Search at %f %f %f! BotIndex= %i", vec[0], vec[1], vec[2], client);
- TraceEntitys(client);
- }
- }
- }
- GetEntityAbsOrigin(ent,Float:EntPosition[3])
- {
- decl Float:mins[3], Float:maxs[3];
- GetEntPropVector(ent,Prop_Send,"m_vecOrigin",EntPosition);
- GetEntPropVector(ent,Prop_Send,"m_vecMins",mins);
- GetEntPropVector(ent,Prop_Send,"m_vecMaxs",maxs);
- EntPosition[0] += (mins[0] + maxs[0]) * 0.5;
- EntPosition[1] += (mins[1] + maxs[1]) * 0.5;
- EntPosition[2] += (mins[2] + maxs[2]) * 0.5;
- LogToGame("BOC: INS_Objective found! EntityIndex: %i @ %f %f %f", ent, EntPosition[0], EntPosition[1], EntPosition[2]);
- }
- public TraceEntitys(client)
- {
- new vecClientEyePos[3];
- new vecClientEyeAng[3];
- GetClientEyePosition(client, vecClientEyePos); // Get the position of the player's eyes
- GetClientEyeAngles(client, vecClientEyeAng); // Get the angle the player is looking
- TR_TraceRayFilter(vecClientEyePos, vecClientEyeAng, MASK_PLAYERSOLID, RayType_Infinite, TraceRayDontHitSelf, client);
- if (TR_DidHit(INVALID_HANDLE))
- {
- new String:EdictName[128];
- new TRIndex = TR_GetEntityIndex(INVALID_HANDLE);
- GetEdictClassname(TRIndex, EdictName, sizeof(EdictName));
- LogToGame("Entity Found in Trace by bot: BotIndex= %i, EntityIndex= %i, classname= %s", client, TRIndex, EdictName);
- }
- }
- public bool:TraceRayDontHitSelf(entity, mask, any:data)
- {
- // Check if the TraceRay hit itself.
- if(entity == data)
- {
- // Don't let the entity be hit
- return false;
- }
- // It didn't hit itself
- return true;
- }
- public BOC_Capture(const String:output[], caller, activator, Float:delay)
- {
- if (activator > 0 && activator <= GetMaxClients() && IsClientInGame(activator) && IsPlayerAlive(activator) && IsFakeClient(activator))
- {
- LogToGame("BOC: Capture Completed by Bot: %i!", activator);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement