Advertisement
Guest User

INS_BOC.sp

a guest
Apr 26th, 2010
201
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 5.42 KB | None | 0 0
  1. /**
  2. * Insurgency Bot Objective Capture
  3. * http://www.hlxcommunity.com/
  4. * Copyright (C) 2010 Deadbwoy
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public License
  8. * as published by the Free Software Foundation; either version 2
  9. * of the License, or (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  19. */
  20. #pragma semicolon 1
  21. #include <sourcemod>
  22. #include <sdktools>
  23. #define VERSION "1.0"
  24. new String:g_teamlist[4][17] = { "Unassigned", "", "", "SPECTATOR" };
  25. public Plugin:myinfo = {
  26.     name = "Insurgency Bot Objective Capture",
  27.     author = "Deadbwoy",
  28.     description = "Gets a bot to freeze after entering an objective so they will capture objectives.",
  29.     version = VERSION,
  30.     url = "http://www.insmod.org"
  31. };
  32. public OnPluginStart()
  33. {
  34.     PrintToConsole(0, "[SM] INS_BOC v1.0 by Deadbwoy loaded successfully!");
  35.     CreateConVar("ins_boc_version", VERSION, "Insurgency Bot Objective Capture", FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY);
  36.     GetTeams();
  37.     HookUserMessage(GetUserMessageId("ObjMsg"), objmsg);
  38.     HookEntityOutput("ins_objective", "OnCapture", BOC_Capture);
  39. }
  40. public OnMapStart()
  41. {
  42.     GetTeams();
  43.     new ent=-1;
  44.     decl Float:EntPosition[3];         
  45.     while ((ent = FindEntityByClassname(ent, "ins_objective")) != -1)
  46.     {
  47.         GetEntityAbsOrigin(ent,EntPosition);
  48.     }
  49. }
  50. public Action:objmsg(UserMsg:msg_id, Handle:bf, const players[], playersNum, bool:reliable, bool:init)
  51. {
  52.     new byte1;
  53.     new byte2;
  54.     new byte3;
  55.     byte1 = BfReadByte(bf); // Objective Point: 1 = point A, 2 = point B, 3 = point C, etc.
  56.     byte2 = BfReadByte(bf); // Capture Status: 1 on starting capture, 2 on finished capture
  57.     byte3 = BfReadByte(bf); // Team Index: 1 = Marines, 2 = Insurgents
  58.     if (byte2 == 1)
  59.     {
  60.         decl String:capname[2];
  61.         switch (byte1)
  62.         {
  63.             case 1:
  64.                 strcopy(capname, 2, "a");
  65.             case 2:
  66.                 strcopy(capname, 2, "b");
  67.             case 3:
  68.                 strcopy(capname, 2, "c");
  69.             case 4:
  70.                 strcopy(capname, 2, "d");
  71.             case 5:
  72.                 strcopy(capname, 2, "e");
  73.         }
  74.         LogToGame("BOC: OBJMSG FUNC triggered start_cap %s by team: %s", capname, g_teamlist[byte3]);
  75.         BotSearch();
  76.     }
  77.     if (byte2 == 2)
  78.     {
  79.         decl String:pointname[2];
  80.         switch (byte1)
  81.         {
  82.             case 1:
  83.                 strcopy(pointname, 2, "a");
  84.             case 2:
  85.                 strcopy(pointname, 2, "b");
  86.             case 3:
  87.                 strcopy(pointname, 2, "c");
  88.             case 4:
  89.                 strcopy(pointname, 2, "d");
  90.             case 5:
  91.                 strcopy(pointname, 2, "e");
  92.         }
  93.         LogToGame("Team \"%s\" triggered \"captured_%s\"", g_teamlist[byte3], pointname);
  94.     }
  95.     return Plugin_Continue;
  96. }
  97. GetTeams()
  98. {
  99.     decl String:mapname[64];
  100.     GetCurrentMap(mapname, sizeof(mapname));
  101.     if (strcmp(mapname, "ins_karam") == 0 || strcmp(mapname, "ins_baghdad") == 0)
  102.     {
  103.         g_teamlist[1] = "Iraqi Insurgents";
  104.         g_teamlist[2] = "U.S. Marines";
  105.     }
  106.     else
  107.     {
  108.         g_teamlist[1] = "U.S. Marines";
  109.         g_teamlist[2] = "Iraqi Insurgents";
  110.     }
  111. }
  112. BotSearch()
  113. {
  114.     //Declare:
  115.     decl MaxPlayers;
  116.     //Initialize:
  117.     MaxPlayers = GetMaxClients();
  118.     //Loop:
  119.     for(new client = 1; client <= MaxPlayers; client++)
  120.     {
  121.         if(IsClientInGame(client) && IsPlayerAlive(client) && IsFakeClient(client))
  122.         {
  123.             new Float:vec[3];
  124.             GetClientAbsOrigin(client, Float:vec);
  125.             LogToGame("BOC: Bot Found During Bot Search at %f %f %f! BotIndex= %i", vec[0], vec[1], vec[2], client);
  126.             TraceEntitys(client);
  127.         }
  128.     }
  129. }
  130. GetEntityAbsOrigin(ent,Float:EntPosition[3])
  131. {
  132.     decl Float:mins[3], Float:maxs[3];
  133.     GetEntPropVector(ent,Prop_Send,"m_vecOrigin",EntPosition);
  134.     GetEntPropVector(ent,Prop_Send,"m_vecMins",mins);
  135.     GetEntPropVector(ent,Prop_Send,"m_vecMaxs",maxs);
  136.     EntPosition[0] += (mins[0] + maxs[0]) * 0.5;
  137.     EntPosition[1] += (mins[1] + maxs[1]) * 0.5;
  138.     EntPosition[2] += (mins[2] + maxs[2]) * 0.5;
  139.     LogToGame("BOC: INS_Objective found!  EntityIndex: %i @ %f %f %f", ent, EntPosition[0], EntPosition[1], EntPosition[2]);
  140. }
  141. public TraceEntitys(client)
  142. {
  143.     new vecClientEyePos[3];
  144.     new vecClientEyeAng[3];
  145.     GetClientEyePosition(client, vecClientEyePos); // Get the position of the player's eyes
  146.     GetClientEyeAngles(client, vecClientEyeAng); // Get the angle the player is looking
  147.     TR_TraceRayFilter(vecClientEyePos, vecClientEyeAng, MASK_PLAYERSOLID, RayType_Infinite, TraceRayDontHitSelf, client);
  148.     if (TR_DidHit(INVALID_HANDLE))
  149.     {
  150.         new String:EdictName[128];
  151.         new TRIndex = TR_GetEntityIndex(INVALID_HANDLE);
  152.         GetEdictClassname(TRIndex, EdictName, sizeof(EdictName));
  153.         LogToGame("Entity Found in Trace by bot: BotIndex= %i, EntityIndex= %i, classname= %s", client, TRIndex, EdictName);
  154.     }
  155. }
  156. public bool:TraceRayDontHitSelf(entity, mask, any:data)
  157. {
  158.     // Check if the TraceRay hit itself.
  159.     if(entity == data)
  160.     {
  161.         // Don't let the entity be hit
  162.         return false;
  163.     }
  164.     // It didn't hit itself
  165.     return true;
  166. }
  167. public BOC_Capture(const String:output[], caller, activator, Float:delay)
  168. {
  169.     if (activator > 0 && activator <= GetMaxClients() && IsClientInGame(activator) && IsPlayerAlive(activator) && IsFakeClient(activator))
  170.     {
  171.         LogToGame("BOC: Capture Completed by Bot: %i!", activator);
  172.     }
  173. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement