Advertisement
Guest User

MW2 Custom Radar

a guest
Apr 23rd, 2018
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.81 KB | None | 0 0
  1. //credits to s0beit on UC
  2. //Updated for engine drawing
  3. typedef struct
  4. {
  5. float x;
  6. float y;
  7. float w;
  8. float h;
  9. }RadarGlobals_t;
  10.  
  11. RadarGlobals_t; rGlobals;
  12.  
  13. bool IsInSpace(int x, int y)
  14. {
  15. return ((x >= rGlobals.x && y >= rGlobals.y) && (x <= (rGlobals.x + rGlobals.w) && y <= (rGlobals.y + rGlobals.h)));
  16. }
  17.  
  18. bool CalculatePoint(Vector3 vec, int *nx, int *ny, float flRange)
  19. {
  20. float fy = cg->ViewAngle.y / 180 * 3.141;
  21. float fc = cos(fy);
  22. float fs = sin(fy);
  23.  
  24. float dx = vec[0] - pRefdef->vOrigin[0];
  25. float dy = vec[1] - pRefdef->vOrigin[1];
  26.  
  27. float px = dy * (-fc) + (dx * fs);
  28. float py = dx * (-fc) - (dy * fs);
  29.  
  30. int irrx = (rGlobals.x + (rGlobals.w / 2)) + int(px / flRange);
  31. int irry = (rGlobals.y + (rGlobals.h / 2)) + int(py / flRange);
  32.  
  33. if (IsInSpace(irrx, irry) == false)
  34. return false;
  35.  
  36. *nx = irrx;
  37. *ny = irry;
  38.  
  39. return true;
  40. }
  41.  
  42. //Put inside your loop
  43. if (bRadar)
  44. {
  45.  
  46. //Radar coordinates
  47. rGlobals.x = 1240;
  48. rGlobals.y = 60;
  49. rGlobals.w = 300;
  50. rGlobals.h = 300;
  51.  
  52.  
  53.  
  54. if (pRefdef == NULL)
  55. return;
  56.  
  57. entity_t *pLocalEntity = cg_entities[cg->ClientNumber];
  58. if (cg_entities == NULL)
  59. return;
  60.  
  61. clientinfo_t *pLocalInfo = clientInfo[cg->ClientNumber];
  62. if (clientInfo == NULL)
  63. return;
  64.  
  65. entity_t *pEntity = cg_entities[i];
  66.  
  67. if (pEntity == NULL)
  68. continue;
  69.  
  70. clientinfo_t *pEntityInfo = clientInfo[i];
  71.  
  72. if (pEntityInfo == NULL)
  73. continue;
  74.  
  75. if (pEntity->iAlive == false)
  76. continue;
  77.  
  78. if (pLocalEntity->clientNum == pEntity->clientNum)
  79. continue;
  80.  
  81. int cx = 0, cy = 0;
  82.  
  83.  
  84. if (CalculatePoint(pEntity->vOrigin, &cx, &cy, 20.0f)) {
  85.  
  86.  
  87.  
  88. cx -= 3;
  89. cy -= 3;
  90.  
  91. CG_DrawRotatedPicPhysical(0x10FB780, cx - 8, cy - 8, 20, 20, (cg->ViewAngle.y - clientInfo[i]->vAngles.y), flColor, Material_RegisterHandle("compassping_player", 3));
  92.  
  93. }
  94.  
  95. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement