BustAim.inc 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695
  1. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  2. //BUST AIM
  3. //
  4. //BustAim is a feature rich anti-aimbot include which tries to detect players who are using aimbots. BustAim is designed to
  5. //trigger warnings and provide administrators with vital information about the suspected player. It by itself cannot do much
  6. //and requires human intelligence to confirm if the player is using an aimbot.
  7. //License:Public Domain
  8. //
  9. //Credits:
  10. //Yashas
  11. //RedShirt & niCe & JernejL for camera/aiming functions
  12. //ipsLeon & Kyance for their aimbot detectors
  13. //Pottus for constructive criticism
  14. //Slice for the information regarding Maximum Weapon Firing Range
  15. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  16. //Callbacks:
  17. // OnPlayerSuspectedForAimbot(playerid,hitid,weaponid,warnings)
  18. //
  19. //Stocks:
  20. // native BustAim::GetPlayerWeaponProfile(playerid,weaponid,&allshots,&hitshots,&max_cont_shots,&out_of_range_warns,&random_aim_warns,&proaim_tele_warns);
  21. // native BustAim::ResetPlayerWeaponProfile(playerid,weaponid);
  22. // native BustAim::GetPlayerProfile(playerid,&shotsfired,&shotshit,&max_cont_shots,&out_of_range_warns,&random_aim_warns,&proaim_tele_warns);
  23. // native BustAim::ResetPlayerProfile(playerid);
  24. // native BustAim::SetPlayerFlags(playerid,flags);
  25. // native BustAim::GetPlayerFlags(playerid,&flags);
  26. // native BustAim::ResetPlayerFlags(playerid);
  27. // native BustAim::GetTeleportStats(playerid,Float:arr[],sz = sizeof(arr));
  28. // native BustAim::GetAimStats(playerid,Float:arr[],sz = sizeof(arr))
  29. // native BustAim::GetRangeStats(playerid,Float:arr[],sz = sizeof(arr))
  30. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  31. #if defined _INCLUDE_BUSTAIM_
  32. #endinput
  33. #endif
  34. #define _INCLUDE_BUSTAIM_
  35. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  36. #define BustAim:: BS_
  37. #if !defined BUSTAIM_MAX_PL_PERCENTAGE
  38. #define BUSTAIM_MAX_PL_PERCENTAGE 5
  39. #endif
  40. #if !defined BUSTAIM_MAX_PING
  41. #define BUSTAIM_MAX_PING 600
  42. #endif
  43. #if !defined BUSTAIM_SKIP_WEAPON_IDS
  44. #define BUSTAIM_SKIP_WEAPON_IDS 38
  45. #endif
  46. #if !defined BUSTAIM_MAX_CONTINOUS_SHOTS
  47. #define BUSTAIM_MAX_CONTINOUS_SHOTS 10
  48. #endif
  49. #if !defined BUSTAIM_PROAIM_TELEPORT_PROBES
  50. #define BUSTAIM_PROAIM_TELEPORT_PROBES 3
  51. #endif
  52. #if !defined BUSTAIM_OUT_OF_RANGE_PROBES
  53. #define BUSTAIM_OUT_OF_RANGE_PROBES 2
  54. #endif
  55. #if !defined BUSTAIM_RANDOM_AIM_PROBES
  56. #define BUSTAIM_RANDOM_AIM_PROBES 5
  57. #endif
  58. #if !defined MIN_DIST_FOR_AIM_CHECKS
  59. #define MIN_DIST_FOR_AIM_CHECKS 10
  60. #endif
  61. #if !defined MAX_B2V_DEVIATION
  62. #define MAX_B2V_DEVIATION 15
  63. #endif
  64. #if !defined BUSTAIM_PLAYER_SPHERE_RADIUS
  65. #define BUSTAIM_PLAYER_SPHERE_RADIUS 3
  66. #endif
  67. #if !defined BUSTAIM_DEFAULT_PLAYER_FLAGS
  68. #define BUSTAIM_DEFAULT_PLAYER_FLAGS (CHECK_FOR_OUT_OF_RANGE_SHOTS | CHECK_FOR_PROAIM_TELEPORT | CHECK_FOR_RANDOM_AIM_SHOTS | CHECK_FOR_CONTINOUS_SHOTS)
  69. #endif
  70. #if !defined BUSTAIM_WSTATS_SHOTS
  71. #define BUSTAIM_WSTATS_SHOTS 3
  72. #endif
  73. //DO NOT CHANGE THIS
  74. #define BS_TOTAL_SHOOTING_WEAPONS 17 //includes RPG,HS,FT
  75. #if BS_TOTAL_SHOOTING_WEAPONS != 17
  76. #error BS_TOTAL_SHOOTING_WEAPONS should always be set to 17
  77. #endif
  78. #define BS_GetNormalWeaponRange(weaponid) BustAim_g_WeaponRangeOriginal[weaponid-22]
  79. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  80. forward OnPlayerSuspectedForAimbot(playerid,hitid,weaponid,warnings);
  81. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  82. enum (<<=1)
  83. {
  84. WARNING_OUT_OF_RANGE_SHOT=1,
  85. WARNING_PROAIM_TELEPORT,
  86. WARNING_RANDOM_AIM,
  87. WARNING_CONTINOUS_SHOTS
  88. }
  89. enum (<<=1)
  90. {
  91. PREVIOUS_SHOT_DID_DAMAGE=1,
  92. }
  93. enum (<<=1)
  94. {
  95. CHECK_FOR_OUT_OF_RANGE_SHOTS=1,
  96. CHECK_FOR_PROAIM_TELEPORT,
  97. CHECK_FOR_RANDOM_AIM_SHOTS,
  98. CHECK_FOR_CONTINOUS_SHOTS,
  99. IGNORE_PLAYER
  100. }
  101. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  102. //Modified Slice's Max Weapon Ranges from Weapon Config Include (Added 10 units extra for every weapon to make allowance for lagging players)
  103. static const Float:BustAim_g_WeaponRange[] =
  104. {
  105. 45.0, // 22 - Colt 45
  106. 45.0, // 23 - Silenced
  107. 45.0, // 24 - Deagle
  108. 50.0, // 25 - Shotgun
  109. 45.0, // 26 - Sawed-off
  110. 50.0, // 27 - Spas
  111. 45.0, // 28 - UZI
  112. 55.0, // 29 - MP5
  113. 100.0, // 30 - AK47
  114. 120.0, // 31 - M4
  115. 45.0, // 32 - Tec9
  116. 110.0, // 33 - Cuntgun
  117. 320.0, // 34 - Sniper
  118. 0.0, // 35 - Rocket launcher
  119. 0.0, // 36 - Heatseeker
  120. 0.0, // 37 - Flamethrower
  121. 85.0 // 38 - Minigun
  122. };
  123. //Original Slice's Max Weapon Ranges'
  124. stock const Float:BustAim_g_WeaponRangeOriginal[] =
  125. {
  126. 35.0, // 22 - Colt 45
  127. 35.0, // 23 - Silenced
  128. 35.0, // 24 - Deagle
  129. 40.0, // 25 - Shotgun
  130. 35.0, // 26 - Sawed-off
  131. 40.0, // 27 - Spas
  132. 35.0, // 28 - UZI
  133. 45.0, // 29 - MP5
  134. 70.0, // 30 - AK47
  135. 90.0, // 31 - M4
  136. 35.0, // 32 - Tec9
  137. 100.0, // 33 - Cuntgun
  138. 320.0, // 34 - Sniper
  139. 0.0, // 35 - Rocket launcher
  140. 0.0, // 36 - Heatseeker
  141. 0.0, // 37 - Flamethrower
  142. 75.0 // 38 - Minigun
  143. };
  144. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  145. static BustAim_g_PlayerSettings[MAX_PLAYERS char];
  146. static BustAim_g_PlayerPrevWeapon[MAX_PLAYERS char];
  147. static BustAim_g_IntrnlPlayerSettings[MAX_PLAYERS char];
  148. static BustAim_g_ContinousShots[MAX_PLAYERS char];
  149. static BustAim_g_RandomAimShots[MAX_PLAYERS char];
  150. static BustAim_g_TeleportShots[MAX_PLAYERS char];
  151. static BustAim_g_OutOfRangeShots[MAX_PLAYERS char];
  152. #if !defined BUSTAIM_DISABLE_PROFILING
  153. static BustAim_g_TotalRandomAimWarns[MAX_PLAYERS][BS_TOTAL_SHOOTING_WEAPONS];
  154. static BustAim_g_TotalTeleportWarns[MAX_PLAYERS][BS_TOTAL_SHOOTING_WEAPONS];
  155. static BustAim_g_TotalOutOfRangeWarns[MAX_PLAYERS][BS_TOTAL_SHOOTING_WEAPONS];
  156. static BustAim_g_MaxContinousShots[MAX_PLAYERS][BS_TOTAL_SHOOTING_WEAPONS];
  157. static BustAim_g_ShotsFired[MAX_PLAYERS][BS_TOTAL_SHOOTING_WEAPONS];
  158. static BustAim_g_ShotsHit[MAX_PLAYERS][BS_TOTAL_SHOOTING_WEAPONS];
  159. #endif
  160. #if !defined BUSTAIM_DISABLE_WSTATS
  161. static Float:BustAim_g_TeleportWarningStats[MAX_PLAYERS][BUSTAIM_WSTATS_SHOTS];
  162. static Float:BustAim_g_AimWarningStats[MAX_PLAYERS][BUSTAIM_WSTATS_SHOTS];
  163. static Float:BustAim_g_RangeWarningStats[MAX_PLAYERS][BUSTAIM_WSTATS_SHOTS];
  164. static Float:BustAim_g_DCTTL_temp;
  165. #endif
  166. #if !defined BUSTAIM_IS_PAUSED_FUNCTION
  167. static BustAim_g_LastUpdateTick[MAX_PLAYERS];
  168. #endif
  169. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  170. static Float:internal_BS_DCTTL(Float:CamX, Float:CamY, Float:CamZ, Float:ObjX, Float:ObjY, Float:ObjZ, Float:FrX, Float:FrY, Float:FrZ)
  171. {
  172. static Float:TGTDistance,Float:tmpX, Float:tmpY, Float:tmpZ;
  173. TGTDistance = floatsqroot((CamX - ObjX) * (CamX - ObjX) + (CamY - ObjY) * (CamY - ObjY) + (CamZ - ObjZ) * (CamZ - ObjZ));
  174. tmpX = FrX * TGTDistance + CamX;
  175. tmpY = FrY * TGTDistance + CamY;
  176. tmpZ = FrZ * TGTDistance + CamZ;
  177. return floatsqroot((tmpX - ObjX) * (tmpX - ObjX) + (tmpY - ObjY) * (tmpY - ObjY) + (tmpZ - ObjZ) * (tmpZ - ObjZ));
  178. }
  179. static Float:internal_BS_GPATP(Float:x2, Float:y2, Float:X, Float:Y)
  180. {
  181. static Float:DX, Float:DY,Float:angle;
  182. DX = floatabs(floatsub(x2,X));
  183. DY = floatabs(floatsub(y2,Y));
  184. if (DY == 0.0 || DX == 0.0)
  185. {
  186. if(DY == 0 && DX > 0) angle = 0.0;
  187. else if(DY == 0 && DX < 0) angle = 180.0;
  188. else if(DY > 0 && DX == 0) angle = 90.0;
  189. else if(DY < 0 && DX == 0) angle = 270.0;
  190. else if(DY == 0 && DX == 0) angle = 0.0;
  191. }
  192. else
  193. {
  194. angle = atan(DX/DY);
  195. if(X > x2 && Y <= y2) angle += 90.0;
  196. else if(X <= x2 && Y < y2) angle = floatsub(90.0, angle);
  197. else if(X < x2 && Y >= y2) angle -= 90.0;
  198. else if(X >= x2 && Y > y2) angle = floatsub(270.0, angle);
  199. }
  200. return floatadd(angle, 90.0);
  201. }
  202. static internal_BS_GXYIFOP(&Float:x, &Float:y, Float:angle, Float:distance)
  203. {
  204. x += (distance * floatsin(-angle, degrees));
  205. y += (distance * floatcos(-angle, degrees));
  206. }
  207. static internal_BS_IsCameraAimingAt(weaponid,Float:x, Float:y, Float:z,Float:vector_x,Float:vector_y,Float:vector_z,Float:camera_x,Float:camera_y,Float:camera_z,Float:radius)
  208. {
  209. static Float:vertical, Float:horizontal;
  210. switch (weaponid)
  211. {
  212. case 34,35,36:
  213. {
  214. if (internal_BS_DCTTL(camera_x, camera_y, camera_z, x, y, z, vector_x, vector_y, vector_z) < radius) return true;
  215. return false;
  216. }
  217. case 30,31: {vertical = 4.0; horizontal = -1.6;}
  218. case 33: {vertical = 2.7; horizontal = -1.0;}
  219. default: {vertical = 6.0; horizontal = -2.2;}
  220. }
  221. new Float:angle = internal_BS_GPATP(0, 0, floatsqroot(vector_x*vector_x+vector_y*vector_y), vector_z) - 270.0;
  222. new Float:resize_x, Float:resize_y, Float:resize_z = floatsin(angle+vertical, degrees);
  223. internal_BS_GXYIFOP(resize_x, resize_y, internal_BS_GPATP(0, 0, vector_x, vector_y)+horizontal, floatcos(angle+vertical, degrees));
  224. #if !defined BUSTAIM_DISABLE_WSTATS
  225. if ((BustAim_g_DCTTL_temp = internal_BS_DCTTL(camera_x, camera_y, camera_z, x, y, z, resize_x, resize_y, resize_z)) < radius) return true;
  226. #else
  227. if (internal_BS_DCTTL(camera_x, camera_y, camera_z, x, y, z, resize_x, resize_y, resize_z) < radius) return true;
  228. #endif
  229. return false;
  230. }
  231. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  232. public OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ)
  233. {
  234. static Float:pX,Float:pY,Float:pZ,Float:hX,Float:hY,Float:hZ,Float:cX,Float:cY,Float:cZ;
  235. if(!(21 < weaponid < 39)
  236. || !(-1 < hittype < 5))
  237. #if defined BustAim_OnPlayerWeaponShot
  238. return BustAim_OnPlayerWeaponShot( playerid, weaponid, hittype, hitid, fX, fY, fZ );
  239. #else
  240. return 0;
  241. #endif
  242. if(hittype == BULLET_HIT_TYPE_NONE)
  243. {
  244. if(floatabs(fX) > 20000.0 || floatabs(fY) > 20000.0 || floatabs(fZ) > 20000.0)
  245. {
  246. #if defined BustAim_OnPlayerWeaponShot
  247. return BustAim_OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, fX, fY, fZ);
  248. #else
  249. return 0;
  250. #endif
  251. }
  252. }
  253. else
  254. {
  255. if(floatabs(fX) > 1500.0 || floatabs(fY) > 1500.0 || floatabs(fZ) > 1500.0)
  256. {
  257. #if defined BustAim_OnPlayerWeaponShot
  258. return BustAim_OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, fX, fY, fZ);
  259. #else
  260. return 0;
  261. #endif
  262. }
  263. }
  264. #if !defined BUSTAIM_DISABLE_PROFILING
  265. BustAim_g_ShotsFired[playerid][weaponid-22]++;
  266. #endif
  267. if(hittype == BULLET_HIT_TYPE_PLAYER)
  268. {
  269. #if !defined BUSTAIM_DISABLE_PROFILING
  270. BustAim_g_ShotsHit[playerid][weaponid-22]++;
  271. #endif
  272. if(BustAim_g_PlayerSettings{playerid} & IGNORE_PLAYER)
  273. #if defined BustAim_OnPlayerWeaponShot
  274. return BustAim_OnPlayerWeaponShot(playerid,weaponid,hittype,hitid,fX,fY,fZ);
  275. #else
  276. return 1;
  277. #endif
  278. if(BustAim_g_PlayerPrevWeapon{playerid} != weaponid)
  279. {
  280. BustAim_g_ContinousShots{playerid} =
  281. BustAim_g_RandomAimShots{playerid} =
  282. BustAim_g_TeleportShots{playerid} =
  283. BustAim_g_OutOfRangeShots{playerid} = 0;
  284. BustAim_g_PlayerPrevWeapon{playerid} = weaponid;
  285. }
  286. if(IsPlayerNPC(hitid))
  287. #if defined BustAim_OnPlayerWeaponShot
  288. return BustAim_OnPlayerWeaponShot(playerid,weaponid,hittype,hitid,fX,fY,fZ);
  289. #else
  290. return 1;
  291. #endif
  292. #if defined BUSTAIM_IS_PAUSED_FUNCTION
  293. if(BUSTAIM_IS_PAUSED_FUNCTION(hitid))
  294. #if defined BustAim_OnPlayerWeaponShot
  295. return BustAim_OnPlayerWeaponShot(playerid,weaponid,hittype,hitid,fX,fY,fZ);
  296. #else
  297. return 1;
  298. #endif
  299. #else
  300. if((GetTickCount() - BustAim_g_LastUpdateTick[hitid]) > 1000)
  301. #if defined BustAim_OnPlayerWeaponShot
  302. return BustAim_OnPlayerWeaponShot(playerid,weaponid,hittype,hitid,fX,fY,fZ);
  303. #else
  304. return 1;
  305. #endif
  306. #endif
  307. if(NetStats_PacketLossPercent(playerid) > BUSTAIM_MAX_PL_PERCENTAGE || NetStats_PacketLossPercent(hitid) > BUSTAIM_MAX_PL_PERCENTAGE)
  308. #if defined BustAim_OnPlayerWeaponShot
  309. return BustAim_OnPlayerWeaponShot(playerid,weaponid,hittype,hitid,fX,fY,fZ);
  310. #else
  311. return 1;
  312. #endif
  313. if(GetPlayerPing(playerid) > BUSTAIM_MAX_PING || GetPlayerPing(hitid) > BUSTAIM_MAX_PING)
  314. #if defined BustAim_OnPlayerWeaponShot
  315. return BustAim_OnPlayerWeaponShot(playerid,weaponid,hittype,hitid,fX,fY,fZ);
  316. #else
  317. return 1;
  318. #endif
  319. if(IsPlayerInAnyVehicle(playerid) || IsPlayerInAnyVehicle(hitid))
  320. #if defined BustAim_OnPlayerWeaponShot
  321. return BustAim_OnPlayerWeaponShot(playerid,weaponid,hittype,hitid,fX,fY,fZ);
  322. #else
  323. return 1;
  324. #endif
  325. if(GetPlayerSurfingVehicleID(playerid) != INVALID_VEHICLE_ID || GetPlayerSurfingVehicleID(hitid) != INVALID_VEHICLE_ID)
  326. #if defined BustAim_OnPlayerWeaponShot
  327. return BustAim_OnPlayerWeaponShot(playerid,weaponid,hittype,hitid,fX,fY,fZ);
  328. #else
  329. return 1;
  330. #endif
  331. switch(weaponid)
  332. {
  333. case BUSTAIM_SKIP_WEAPON_IDS:
  334. {
  335. #if defined BustAim_OnPlayerWeaponShot
  336. return BustAim_OnPlayerWeaponShot(playerid,weaponid,hittype,hitid,fX,fY,fZ);
  337. #else
  338. return 1;
  339. #endif
  340. }
  341. }
  342. new warning = 0;
  343. GetPlayerVelocity(hitid,pX,pY,pZ);
  344. if(BustAim_g_PlayerSettings{playerid} & CHECK_FOR_CONTINOUS_SHOTS)
  345. if((pX*pX + pY*pY + pZ*pZ) > 0.01)
  346. if(!(++BustAim_g_ContinousShots{playerid} % BUSTAIM_MAX_CONTINOUS_SHOTS))
  347. warning |= WARNING_CONTINOUS_SHOTS;
  348. GetPlayerPos(hitid,hX,hY,hZ);
  349. GetPlayerLastShotVectors(playerid,pX,pY,pZ,cX,cY,cZ);
  350. new Float:S2V_dist = VectorSize(pX-hX,pY-hY,pZ-hZ); //Approximate Shooter to Victim Distance
  351. if(BustAim_g_PlayerSettings{playerid} & CHECK_FOR_OUT_OF_RANGE_SHOTS)
  352. {
  353. if(S2V_dist > BustAim_g_WeaponRange[weaponid-22])
  354. {
  355. #if !defined BUSTAIM_DISABLE_WSTATS
  356. BustAim_g_RangeWarningStats[playerid][BustAim_g_OutOfRangeShots{playerid}%BUSTAIM_WSTATS_SHOTS] = S2V_dist;
  357. #endif
  358. if(BustAim_g_IntrnlPlayerSettings{playerid} & PREVIOUS_SHOT_DID_DAMAGE)
  359. {
  360. if(++BustAim_g_OutOfRangeShots{playerid} > BUSTAIM_OUT_OF_RANGE_PROBES)
  361. {
  362. BustAim_g_OutOfRangeShots{playerid} = 0;
  363. #if !defined BUSTAIM_DISABLE_PROFILING
  364. BustAim_g_TotalOutOfRangeWarns[playerid][weaponid-22]++;
  365. #endif
  366. warning |= WARNING_OUT_OF_RANGE_SHOT;
  367. }
  368. BustAim_g_IntrnlPlayerSettings{playerid} &= ~PREVIOUS_SHOT_DID_DAMAGE;
  369. }
  370. }
  371. }
  372. if(BustAim_g_PlayerSettings{playerid} & CHECK_FOR_PROAIM_TELEPORT)
  373. if(VectorSize(cX-hX,cY-hY,cZ-hZ) > MAX_B2V_DEVIATION)
  374. {
  375. #if !defined BUSTAIM_DISABLE_WSTATS
  376. BustAim_g_TeleportWarningStats[playerid][BustAim_g_TeleportShots{playerid}%BUSTAIM_WSTATS_SHOTS] = VectorSize(cX-hX,cY-hY,cZ-hZ);
  377. #endif
  378. if(++BustAim_g_TeleportShots{playerid} > BUSTAIM_PROAIM_TELEPORT_PROBES)
  379. {
  380. BustAim_g_TeleportShots{playerid} = 0;
  381. #if !defined BUSTAIM_DISABLE_PROFILING
  382. BustAim_g_TotalTeleportWarns[playerid][weaponid-22]++;
  383. #endif
  384. warning |= WARNING_PROAIM_TELEPORT;
  385. }
  386. }
  387. if(BustAim_g_PlayerSettings{playerid} & CHECK_FOR_RANDOM_AIM_SHOTS)
  388. if(S2V_dist > MIN_DIST_FOR_AIM_CHECKS)
  389. {
  390. GetPlayerCameraFrontVector(playerid,pX,pY,pZ);
  391. GetPlayerCameraPos(playerid,cX,cY,cZ);
  392. if(!internal_BS_IsCameraAimingAt(weaponid,hX,hY,hZ,pX,pY,pZ,cX,cY,cZ,BUSTAIM_PLAYER_SPHERE_RADIUS))
  393. {
  394. #if !defined BUSTAIM_DISABLE_WSTATS
  395. BustAim_g_AimWarningStats[playerid][BustAim_g_RandomAimShots{playerid}%BUSTAIM_WSTATS_SHOTS] = BustAim_g_DCTTL_temp;
  396. #endif
  397. if(++BustAim_g_RandomAimShots{playerid} > BUSTAIM_RANDOM_AIM_PROBES)
  398. {
  399. BustAim_g_RandomAimShots{playerid} = 0;
  400. #if !defined BUSTAIM_DISABLE_PROFILING
  401. BustAim_g_TotalRandomAimWarns[playerid][weaponid-22]++;
  402. #endif
  403. warning |= WARNING_RANDOM_AIM;
  404. }
  405. }
  406. }
  407. if(warning)
  408. #if defined OnPlayerSuspectedForAimbot
  409. if(OnPlayerSuspectedForAimbot(playerid,hitid,weaponid,warning)) BustAim_g_PlayerSettings{playerid} |= IGNORE_PLAYER;
  410. #endif
  411. }
  412. else
  413. {
  414. #if !defined BUSTAIM_DISABLE_PROFILING
  415. if(BustAim_g_ContinousShots{playerid} > BustAim_g_MaxContinousShots[playerid][weaponid-22])
  416. BustAim_g_MaxContinousShots[playerid][weaponid-22] = BustAim_g_ContinousShots{playerid};
  417. #endif
  418. BustAim_g_ContinousShots{playerid} =
  419. BustAim_g_RandomAimShots{playerid} =
  420. BustAim_g_TeleportShots{playerid} =
  421. BustAim_g_OutOfRangeShots{playerid} = 0;
  422. }
  423. #if defined BustAim_OnPlayerWeaponShot
  424. return BustAim_OnPlayerWeaponShot(playerid,weaponid,hittype,hitid,fX,fY,fZ);
  425. #else
  426. return 1;
  427. #endif
  428. }
  429. public OnPlayerGiveDamage(playerid, damagedid, Float: amount, weaponid, bodypart)
  430. {
  431. if((0 <= damagedid < MAX_PLAYERS) && (0 <= weaponid < 50)) BustAim_g_IntrnlPlayerSettings{playerid} |= PREVIOUS_SHOT_DID_DAMAGE;
  432. #if defined BustAim_OnPlayerGiveDamage
  433. return BustAim_OnPlayerGiveDamage(playerid, damagedid, Float: amount, weaponid, bodypart);
  434. #else
  435. return 1;
  436. #endif
  437. }
  438. #if defined _ALS_OnPlayerWeaponShot
  439. #undef OnPlayerWeaponShot
  440. #else
  441. #define _ALS_OnPlayerWeaponShot
  442. #endif
  443. #define OnPlayerWeaponShot BustAim_OnPlayerWeaponShot
  444. #if defined BustAim_OnPlayerWeaponShot
  445. forward BustAim_OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ);
  446. #endif
  447. #if defined _ALS_OnPlayerGiveDamage
  448. #undef OnPlayerGiveDamage
  449. #else
  450. #define _ALS_OnPlayerGiveDamage
  451. #endif
  452. #define OnPlayerGiveDamage BustAim_OnPlayerGiveDamage
  453. #if defined BustAim_OnPlayerGiveDamage
  454. forward BustAim_OnPlayerGiveDamage(playerid, damagedid, Float: amount, weaponid, bodypart);
  455. #endif
  456. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  457. #if defined BUSTAIM_DISABLE_WSTATS
  458. stock BustAim::GetTeleportStats(playerid,Float:arr[],sz = sizeof(arr))
  459. {
  460. #pragma unused playerid
  461. #pragma unused arr
  462. #pragma unused sz
  463. print("[BUST-AIM] GetTeleportStats must not be used when WSTATS is disabled.");
  464. }
  465. stock BustAim::GetRandomAimStats(playerid,Float:arr[],sz = sizeof(arr))
  466. {
  467. #pragma unused playerid
  468. #pragma unused arr
  469. #pragma unused sz
  470. print("[BUST-AIM] GetAimStats must not be used when WSTATS is disabled.");
  471. }
  472. stock BustAim::GetRangeStats(playerid,Float:arr[],sz = sizeof(arr))
  473. {
  474. #pragma unused playerid
  475. #pragma unused arr
  476. #pragma unused sz
  477. print("[BUST-AIM] GetRangeStats must not be used when WSTATS is disabled.");
  478. }
  479. #else
  480. stock BustAim::GetTeleportStats(playerid,Float:arr[],sz = sizeof(arr))
  481. {
  482. memcpy(_:arr,_:BustAim_g_TeleportWarningStats[playerid],0,sz*4,sz);
  483. }
  484. stock BustAim::GetRandomAimStats(playerid,Float:arr[],sz = sizeof(arr))
  485. {
  486. memcpy(_:arr,_:BustAim_g_AimWarningStats[playerid],0,sz*4,sz);
  487. }
  488. stock BustAim::GetRangeStats(playerid,Float:arr[],sz = sizeof(arr))
  489. {
  490. memcpy(_:arr,_:BustAim_g_RangeWarningStats[playerid],0,sz*4,sz);
  491. }
  492. #endif
  493. #if defined BUSTAIM_DISABLE_PROFILING
  494. stock BustAim::GetPlayerWeaponProfile(playerid,weaponid,&allshots,&hitshots,&max_cont_shots,&out_of_range_warns,&random_aim_warns,&proaim_tele_warns)
  495. {
  496. #pragma unused playerid
  497. #pragma unused weaponid
  498. print("[BUST-AIM] GetPlayerWeaponProfile must not be used when profiling is disabled.");
  499. }
  500. stock BustAim::ResetPlayerWeaponProfile(playerid,weaponid)
  501. {
  502. #pragma unused playerid
  503. #pragma unused weaponid
  504. print("[BUST-AIM] ResetWeaponProfile must not be used when profiling is disabled");
  505. }
  506. stock BustAim::GetPlayerProfile(playerid,&shotsfired,&shotshit,&max_cont_shots,&out_of_range_warns,&random_aim_warns,&proaim_tele_warns)
  507. {
  508. #pragma unused playerid
  509. print("[BUST-AIM] GetPlayerProfile must not be used when profiling is disabled.");
  510. }
  511. stock BustAim::ResetPlayerProfile(playerid)
  512. {
  513. #pragma unused playerid
  514. print("[BUST-AIM] ResetPlayerProfile must not be used when profiling is disabled.");
  515. }
  516. #else
  517. stock BustAim::GetPlayerWeaponProfile(playerid,weaponid,&allshots,&hitshots,&max_cont_shots,&out_of_range_warns,&random_aim_warns,&proaim_tele_warns)
  518. {
  519. if(22 <= weaponid <= 39)
  520. {
  521. weaponid -= 22;
  522. allshots = BustAim_g_ShotsFired[playerid][weaponid];
  523. hitshots = BustAim_g_ShotsHit[playerid][weaponid];
  524. max_cont_shots = BustAim_g_MaxContinousShots[playerid][weaponid];
  525. out_of_range_warns = BustAim_g_TotalOutOfRangeWarns[playerid][weaponid];
  526. random_aim_warns = BustAim_g_TotalRandomAimWarns[playerid][weaponid];
  527. proaim_tele_warns = BustAim_g_TotalTeleportWarns[playerid][weaponid];
  528. return 0;
  529. }
  530. return 1;
  531. }
  532. stock BustAim::ResetPlayerWeaponProfile(playerid,weaponid)
  533. {
  534. if(22 <= weaponid <= 39)
  535. {
  536. weaponid -= 22;
  537. BustAim_g_ShotsFired[playerid][weaponid] =
  538. BustAim_g_ShotsHit[playerid][weaponid] =
  539. BustAim_g_MaxContinousShots[playerid][weaponid] =
  540. BustAim_g_TotalOutOfRangeWarns[playerid][weaponid] =
  541. BustAim_g_TotalRandomAimWarns[playerid][weaponid] =
  542. BustAim_g_TotalTeleportWarns[playerid][weaponid] = 0;
  543. return 0;
  544. }
  545. return 1;
  546. }
  547. stock BustAim::GetPlayerProfile(playerid,&shotsfired,&shotshit,&max_cont_shots,&out_of_range_warns,&random_aim_warns,&proaim_tele_warns)
  548. {
  549. for(new i = 0;i < BS_TOTAL_SHOOTING_WEAPONS;i++)
  550. {
  551. shotsfired += BustAim_g_ShotsFired[playerid][i];
  552. shotshit += BustAim_g_ShotsHit[playerid][i];
  553. out_of_range_warns += BustAim_g_TotalOutOfRangeWarns[playerid][i];
  554. random_aim_warns += BustAim_g_TotalRandomAimWarns[playerid][i];
  555. proaim_tele_warns+= BustAim_g_TotalTeleportWarns[playerid][i];
  556. if(BustAim_g_MaxContinousShots[playerid][i] > max_cont_shots)
  557. max_cont_shots = BustAim_g_MaxContinousShots[playerid][i];
  558. }
  559. return 1;
  560. }
  561. stock BustAim::ResetPlayerProfile(playerid)
  562. {
  563. Fill68(BustAim_g_TotalRandomAimWarns[playerid]);
  564. Fill68(BustAim_g_TotalTeleportWarns[playerid]);
  565. Fill68(BustAim_g_TotalOutOfRangeWarns[playerid]);
  566. Fill68(BustAim_g_ShotsFired[playerid]);
  567. Fill68(BustAim_g_ShotsHit[playerid]);
  568. Fill68(BustAim_g_MaxContinousShots[playerid]);
  569. return 0;
  570. }
  571. #endif
  572. stock BustAim::SetPlayerFlags(playerid,flags)
  573. {
  574. BustAim_g_PlayerSettings{playerid} = flags;
  575. }
  576. stock BustAim::GetPlayerFlags(playerid,&flags)
  577. {
  578. flags = BustAim_g_PlayerSettings{playerid};
  579. }
  580. stock BustAim::ResetPlayerFlags(playerid)
  581. {
  582. BustAim_g_PlayerSettings{playerid} = BUSTAIM_DEFAULT_PLAYER_FLAGS;
  583. }
  584. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  585. static stock Fill68(loc[])
  586. {
  587. new val = 0;
  588. #emit LOAD.S.alt loc
  589. #emit LOAD.S.pri val
  590. #emit FILL 68
  591. }
  592. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  593. public OnPlayerConnect(playerid)
  594. {
  595. BustAim_g_PlayerSettings{playerid} = BUSTAIM_DEFAULT_PLAYER_FLAGS;
  596. BustAim_g_IntrnlPlayerSettings{playerid} =
  597. BustAim_g_ContinousShots{playerid} =
  598. BustAim_g_RandomAimShots{playerid} =
  599. BustAim_g_TeleportShots{playerid} =
  600. BustAim_g_OutOfRangeShots{playerid} = 0;
  601. #if !defined BUSTAIM_DISABLE_PROFILING
  602. Fill68(BustAim_g_TotalRandomAimWarns[playerid]);
  603. Fill68(BustAim_g_TotalTeleportWarns[playerid]);
  604. Fill68(BustAim_g_TotalOutOfRangeWarns[playerid]);
  605. Fill68(BustAim_g_ShotsFired[playerid]);
  606. Fill68(BustAim_g_ShotsHit[playerid]);
  607. Fill68(BustAim_g_MaxContinousShots[playerid]);
  608. #endif
  609. #if defined BustAim_OnPlayerConnect
  610. return BustAim_OnPlayerConnect(playerid);
  611. #else
  612. return 1;
  613. #endif
  614. }
  615. #if defined _ALS_OnPlayerConnect
  616. #undef OnPlayerConnect
  617. #else
  618. #define _ALS_OnPlayerConnect
  619. #endif
  620. #define OnPlayerConnect BustAim_OnPlayerConnect
  621. #if defined BustAim_OnPlayerConnect
  622. forward BustAim_OnPlayerConnect(playerid);
  623. #endif
  624. #if !defined BUSTAIM_IS_PAUSED_FUNCTION
  625. public OnPlayerUpdate(playerid)
  626. {
  627. BustAim_g_LastUpdateTick[playerid] = GetTickCount();
  628. #if defined BustAim_OnPlayerUpdate
  629. return BustAim_OnPlayerUpdate(playerid);
  630. #else
  631. return 1;
  632. #endif
  633. }
  634. #if defined _ALS_OnPlayerUpdate
  635. #undef OnPlayerUpdate
  636. #else
  637. #define _ALS_OnPlayerUpdate
  638. #endif
  639. #define OnPlayerUpdate BustAim_OnPlayerUpdate
  640. #if defined BustAim_OnPlayerUpdate
  641. forward BustAim_OnPlayerUpdate(playerid);
  642. #endif
  643. #endif
  644. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////