Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

GTA IV - MOD GTA V HUD

By: a guest on Sep 6th, 2013  |  syntax: C++  |  size: 6.23 KB  |  views: 781  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. void CGame::RenderUIElements()
  2. {
  3.   // Render Images
  4.   float fX, fY, sX, sY;
  5.   CIVScript_NativeInvoke::Invoke<unsigned int>(CIVScript::NATIVE_GET_VIEWPORT_POS_AND_SIZE, 3, &fX, &fY, &sX, &sY);
  6.  
  7.   D3DVIEWPORT9 viewport;
  8.   g_pCore->GetGraphics()->GetDevice()->GetViewport(&viewport);
  9.   g_pCore->GetGraphics()->GetSprite()->Begin(0);
  10.   D3DXVECTOR2 spriteCentre = D3DXVECTOR2(0, 0);
  11.   D3DXVECTOR2 trans= D3DXVECTOR2(viewport.Width * fX  6.5, viewport.Height * fY  6.5);
  12.  
  13.   D3DXMATRIX mat;
  14.   D3DXVECTOR2 scaling2((viewport.Width * sX) / 990, (viewport.Height*sY) / 460);
  15.   float rotation=0.0f;
  16.   D3DXMatrixTransformation2D(&mat,NULL,0.0,&scaling2,&spriteCentre,rotation,&trans);
  17.  
  18.   g_pCore>GetGraphics()->GetSprite()->SetTransform(&mat);
  19.   g_pCore>GetGraphics()->GetSprite()->Draw(g_pCore->GetGraphics()->m_pRadarOverlayTexture,NULL, NULL,&D3DXVECTOR3(0.0f, 0.0f, 0.0f), D3DCOLOR_ARGB(255,255,255,255));
  20.  
  21.   // Draw health bar
  22.   float fxPos = viewport.Width * fX  6.5;
  23.   float fyPos = viewport.Height * fY  6.5;
  24.  
  25.   float fWidth = viewport.Width/12.4;
  26.   float fHeight = viewport.Height/50;
  27.  
  28.   D3DXVECTOR2 scaling3((viewport.Width * sX) / 1000, (viewport.Height*sY) / 460);
  29.   CVector3 vecScreen = CVector3(trans.x, (trans.y+scaling3.y), 0.0f);
  30.   vecScreen.fY += (viewport.Height/10)*2;
  31.  
  32.   if(m_pLocalPlayer && m_pLocalPlayer>IsSpawned()) {
  33.   g_pCore>GetGraphics()->DrawBox(((vecScreen.fX + 6)), (vecScreen.fY + 18), (fWidth  4), (fHeight  4), D3DCOLOR_ARGB(120, 125, 157, 120) );
  34.   g_pCore>GetGraphics()->DrawBox(((vecScreen.fX + 6)), (vecScreen.fY + 18), (((Math::Clamp( 0.0f, m_pLocalPlayer>GetHealth(), 720.0f ) * 100.0f) / 720.0f) / 100 * (fWidth  4)), (fHeight  4), D3DCOLOR_ARGB(255, 125, 157, 120) );
  35.  
  36.   vecScreen.fX += fWidth;
  37.   g_pCore>GetGraphics()->DrawBox(((vecScreen.fX + 6)), (vecScreen.fY + 18), (fWidth  4), (fHeight  4), D3DCOLOR_ARGB(210, 0, 79, 96) );
  38.   g_pCore>GetGraphics()->DrawBox(((vecScreen.fX + 6)), (vecScreen.fY + 18), (((Math::Clamp( 0.0f, m_pLocalPlayer>GetHealth(), 720.0f ) * 100.0f) / 720.0f) / 100 * (fWidth  4)), (fHeight  4), D3DCOLOR_ARGB(255, 0, 79, 96) );
  39.  
  40.   g_pCore>GetGraphics()->GetSprite()>Flush();
  41.   g_pCore>GetGraphics()->GetSprite()>End();
  42. }
  43.  
  44. Vector2 * v12;
  45. Vector2 * pViewportSize = new Vector2();
  46. float center;
  47. int bAbsolut;
  48.  
  49. #define MIN_X 0.025f
  50. #define MAX_X 0.975f
  51. #define MIN_Y 0.025f
  52. #define MAX_Y 0.975f
  53. #define ZERO 0.0f
  54. float fOriginalX;
  55. float fOriginalY;
  56.  
  57. void _declspec(naked) Keks()
  58. {
  59.   _asm  mov v12, edx;
  60.   _asm  push eax; get absolute flag
  61.   _asm  mov eax, [ebp+14h] ; 3th parameter
  62.   _asm  mov bAbsolut, eax;
  63.   _asm  pop eax;
  64.  
  65.   fOriginalX = v12->fX;
  66.   fOriginalY = v12->fY;
  67.  
  68.   // Calculate and check our coordinates
  69.   if(!bAbsolut) {
  70.  
  71.     if(v12->fX < MAX_X && v12->fX > MIN_X) { // Check if the X axis is smaller than 1, but still positive
  72.       if(v12->fY < MAX_Y && v12->fY > MIN_Y) // Check if the Y Acis is smaller than 1, but still positive
  73.       {
  74.         goto out; // Let GTA calc the position on itself
  75.       }
  76.       else {
  77.         if(v12->fY > MAX_Y) // Check if the Y Axis is bigger than 1 (set it 0.05 so it's not cutted of)
  78.           v12->fY = MAX_Y;
  79.  
  80.         if(v12->fY < MIN_Y) // Check if the Y Axis is smaller than 0 (set it +0.05 so it's not cutted of)
  81.           v12->fY = MIN_Y;
  82.       }
  83.  
  84.       goto out;
  85.     }
  86.     else
  87.     {
  88.       if(v12->fX > MAX_X)
  89.         v12->fX = MAX_X; // Check if the X Axis is bigger than 1 (set it 0.05 so it's not cutted of)
  90.  
  91.       if(v12->fX < MIN_X)
  92.         v12->fX = MIN_X; // Check if the X Axis is smaller than 0 (set it +0.05 so it's not cutted of)
  93.     }
  94.  
  95.     if(v12->fY < MAX_Y && v12->fY > MIN_Y) { // Check if the Y Acis is smaller than 1, but still positive
  96.       if(v12->fX < MAX_X && v12->fX > MIN_X)// Check if the X axis is smaller than 1, but still positive
  97.       {
  98.         goto out;
  99.       }
  100.       else
  101.       {
  102.         if(v12->fX > MAX_X) // Check if the X Axis is bigger than 1 (set it 0.05 so it's not cutted of)
  103.           v12>fX = MAX_X;
  104.  
  105.         if(v12->fX < 0) // Check if the X Axis is smaller than 0 (set it +0.05 so it's not cutted of)
  106.           v12>fX = MIN_X;
  107.       }
  108.  
  109.       goto out;
  110.     }
  111.     else {
  112.       if(v12->fY > MAX_Y) // Check if the Y Axis is bigger than 1 (set it 0.05 so it's not cutted of)
  113.         v12>fY = MAX_Y;
  114.  
  115.       if(v12->fY < MIN_Y) // Check if the Y Axis is smaller than 0 (set it +0.05 so it's not cutted of)
  116.         v12>fY = MIN_Y;
  117.     }
  118.     goto out;
  119.   }
  120.  
  121. out:
  122.  
  123.   _asm    mov esp, ebp;
  124.   _asm    pop ebp;
  125.   _asm    retn;
  126. }
  127.  
  128. DWORD ResizeMapJmpBack;
  129. int a1, a2, a3;
  130.  
  131. _declspec(naked) signed int ResizeMap()
  132. {
  133.   _asm push eax;
  134.   _asm mov eax, [ebp+4];
  135.   _asm mov a1, eax;
  136.   _asm mov eax, [ebp+8];
  137.   _asm mov a2, eax;
  138.   _asm mov eax, [ebp+0Ch];
  139.   _asm mov a3, eax;
  140.   _asm pushad;
  141.  
  142.   ResizeMapJmpBack = (g_pCore->GetBase() + 0x8364D7);
  143.  
  144.   _asm popad;
  145.   _asm pop eax;
  146.   _asm jmp ResizeMapJmpBack;
  147. }
  148.  
  149. DWORD sub_849BC0;
  150. _declspec(naked) void RenderMap()
  151. {
  152.   sub_849BC0 = (g_pCore->GetBase() + 0x849BC0);
  153.   _asm  call sub_849BC0;
  154.   _asm  add esp, 4;
  155.   _asm  popad;
  156.  
  157.   g_pCore->GetGame()->SetRadarVisible(true);
  158.  
  159.   _asm  pushad;
  160.   _asm  retn;
  161. }
  162.  
  163. // Other section
  164.  
  165. // Change calc from circle to square(blips)
  166. *(BYTE*)(g_pCore->GetBase() + 0x8385E7 + 0x6) = 0x1;
  167. PatchAddress(false, g_pCore->GetBase() + 0x8386AB, (DWORD)Keks); // E9
  168.  
  169. // Enable square map(instead of circle map)
  170. PatchAddress(false, g_pCore->GetBase() + 0xA22C53, g_pCore->GetBase() + 0xA22EF3); // E9
  171.  
  172. // Enable big radar
  173. *(BYTE *)(g_pCore->GetBase() + 0x08364D0 + 0x6) = 0x1;
  174.  
  175. // Hook resize map function
  176. PatchAddress(false, (g_pCore->GetBase() + 0x8364D0), (DWORD)ResizeMap); // E9
  177. *(WORD *)(g_pCore->GetBase() + 0x8364D0 + 0x5) = 0x9090;
  178.  
  179. // Make blip small
  180. *(BYTE *)(g_pCore->GetBase() + 0x4B516F + 0x6) = 0x1; // cmp VAR_DEVMODE, 1
  181. *(BYTE *)(g_pCore->GetBase() + 0x4B516F + 0x6) = 0x1; // cmp VAR_DEVMODE, 1
  182.  
  183. // Hook render map function
  184. PatchAddress(true,(g_pCore->GetBase() + 0xA22E71), (DWORD)RenderMap); // E8
  185.  
  186. // Example for call and jump:
  187. /*
  188. void PatchAddress(bool bJmp, DWORD dwAddress, DWORD dwNewAddress)
  189. {
  190.         if(bJmp)
  191.                 *(BYTE *)(dwAddress) = 0xE9; // jmp
  192.         else
  193.                 *(BYTE *)(dwAddress) = 0xE8; // call
  194.                
  195.         *(DWORD *)(dwAddress + 0x1) = (DWORD)dwNewAddress;
  196. }