Guest User

Untitled

a guest
Sep 2nd, 2014
342
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.70 KB | None | 0 0
  1. #include <Windows.h>
  2. #include <math.h>
  3. #include <CPatch.h>
  4.  
  5. double NormalisePoint(float *);
  6. float gRadarCircle = 0.000001;
  7.  
  8. BOOL APIENTRY DllMain(HMODULE module, DWORD reason, LPVOID reserved)
  9. {
  10.     if(reason == DLL_PROCESS_ATTACH)
  11.     {
  12.         CPatch::SetPointer(0x58585C, &gRadarCircle);                    
  13.         CPatch::RedirectCall(0x5751F2       , NormalisePoint);
  14.         CPatch::RedirectCall(0x5773D0+0x32A , NormalisePoint);
  15.         CPatch::RedirectCall(0x5773D0+0x396 , NormalisePoint);
  16.         CPatch::RedirectCall(0x5773D0+0x416 , NormalisePoint);
  17.         CPatch::RedirectCall(0x5773D0+0x49E , NormalisePoint);
  18.         CPatch::RedirectCall(0x5773D0+0x51E , NormalisePoint);
  19.         CPatch::RedirectCall(0x5773D0+0x659 , NormalisePoint);
  20.         CPatch::RedirectCall(0x5773D0+0x93F , NormalisePoint);
  21.         CPatch::RedirectCall(0x5773D0+0xAD7 , NormalisePoint);
  22.         CPatch::RedirectCall(0x5773D0+0xB5B , NormalisePoint);
  23.         CPatch::RedirectCall(0x5773D0+0xC37 , NormalisePoint);
  24.         CPatch::RedirectCall(0x5773D0+0xCE7 , NormalisePoint);
  25.         CPatch::RedirectCall(0x5773D0+0xD9F , NormalisePoint);
  26.         CPatch::RedirectCall(0x5773D0+0xE53 , NormalisePoint);
  27.         CPatch::RedirectCall(0x5773D0+0xF87 , NormalisePoint);
  28.         CPatch::RedirectCall(0x5773D0+0x100B, NormalisePoint);
  29.         CPatch::RedirectCall(0x5773D0+0x111C, NormalisePoint);
  30.         CPatch::RedirectCall(0x5773D0+0x11A3, NormalisePoint);
  31.         CPatch::RedirectCall(0x5773D0+0x12B7, NormalisePoint);
  32.         CPatch::RedirectCall(0x5773D0+0x1343, NormalisePoint);
  33.         CPatch::RedirectCall(0x585B20+0x76  , NormalisePoint);
  34.         CPatch::RedirectCall(0x586E97       , NormalisePoint);
  35.         CPatch::RedirectCall(0x587221       , NormalisePoint);
  36.         CPatch::RedirectCall(0x587604       , NormalisePoint);
  37.         CPatch::RedirectCall(0x58798F       , NormalisePoint);
  38.         CPatch::RedirectCall(0x588161       , NormalisePoint);
  39.         CPatch::RedirectCall(0x58820D       , NormalisePoint);
  40.     }
  41.     return TRUE;
  42. }
  43.  
  44. double NormalisePoint(float *pos)
  45. {
  46.     double r, angle;
  47.     if(READCHAR(0xBA67A1))
  48.         r = sqrt(pos[0] * pos[0] + pos[1] * pos[1]);
  49.     else
  50.     {
  51.         r = sqrt(pos[0] * pos[0] + pos[1] * pos[1]);
  52.         if(r > 1.0)
  53.         {
  54.             if(pos[0] > -1.0 && pos[0] < 1.0 && pos[1] > -1.0 && pos[1] < 1.0)
  55.                 r = 0.99;
  56.             else
  57.             {
  58.                 angle = atan2(pos[1], pos[0]) * 57.295779513 + 180.0;
  59.                 if(angle <= 45 || angle > 315)
  60.                 {
  61.                     pos[0] = 1.0;
  62.                     pos[1] = sin(angle / 57.295779513) * 1.4142135623;
  63.                 }
  64.                 else if(angle > 45 && angle <= 135)
  65.                 {
  66.                     pos[0] = cos(angle / 57.295779513) * 1.4142135623;
  67.                     pos[1] = 1.0;
  68.                 }
  69.                 else if(angle > 135 && angle <= 225)
  70.                 {
  71.                     pos[0] = -1.0;
  72.                     pos[1] = sin(angle / 57.295779513) * 1.4142135623;
  73.                 }
  74.                 else
  75.                 {
  76.                     pos[0] = cos(angle / 57.295779513) * 1.4142135623;
  77.                     pos[1] = -1.0;
  78.                 }
  79.             }
  80.         }
  81.     }
  82.     return r;
  83. }
Advertisement
Add Comment
Please, Sign In to add comment