BustAim.inc 24 KB

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