IlDivinoGlade

GTA V 1.27 – Water Area Editor

Jul 16th, 2025 (edited)
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.57 KB | Source Code | 0 0
  1. /*I did not write the original code — it was created by a user on the forum known as "DemonForum" (I don't remember name). I simply made it a bit more complete.
  2. Of course, for the sake of better readability and understanding, I had it rewritten with more descriptive comments using A.I.
  3. */
  4.  
  5. #define WATER_AREA_PTR 0x020FCC48
  6. #define WATER_AREA_SIZE 0x020FCC48 + 0x4
  7.  
  8. struct WaterBlock {
  9.     __int16 minX;        // Minimum X coordinate
  10.     __int16 minY;        // Minimum Y coordinate
  11.     __int16 maxX;        // Maximum X coordinate
  12.     __int16 maxY;        // Maximum Y coordinate
  13.     DWORD textureID;     // Texture identifier (optional)
  14.     char padding[8];     //
  15.     float waterHeight;   // Water height at this block
  16. };
  17.  
  18. // Function to set the height of the water in all blocks
  19. void SetWaterHeightForAllBlocks(float newHeight) {
  20.     int blockCount = *(WORD*)WATER_AREA_SIZE; // Get the total number of water blocks
  21.  
  22.     for (int i = 0; i < blockCount; i++) {
  23.         // Calculate the memory address of the current water block structure
  24.         WaterBlock currentBlock = *(WaterBlock*)(*(DWORD*)WATER_AREA_PTR + (i * 0x1C));
  25.  
  26.         // Set the new water height
  27.         currentBlock.waterHeight = newHeight;
  28.  
  29.         // Restore the updated water block data
  30.         *(WaterBlock*)(*(DWORD*)WATER_AREA_PTR + (i * 0x1C)) = currentBlock;
  31.     }
  32. }
  33.  
  34. // Function to get the height of the water in a specific block
  35. float GetWaterHeightAtBlock(int blockIndex) {
  36.     int blockCount = *(WORD*)WATER_AREA_SIZE; // Get the total number of water blocks
  37.     if (blockIndex >= 0 && blockIndex < blockCount) {
  38.         // Fetch the water block data
  39.         WaterBlock currentBlock = *(WaterBlock*)(*(DWORD*)WATER_AREA_PTR + (blockIndex * 0x1C));
  40.  
  41.         // Return the water height of the block
  42.         return currentBlock.waterHeight;
  43.     }
  44.     return -1.0f; // Return an invalid value if the block index is out of range
  45. }
  46.  
  47. // Function to draw lines representing the water areas (quads)
  48. void RenderWaterAreaLines() {
  49.     int blockCount = *(WORD*)WATER_AREA_SIZE;
  50.  
  51.     for (int i = 0; i < blockCount; i++) {
  52.         // Fetch the current water block's data
  53.         WaterBlock currentBlock = *(WaterBlock*)(*(DWORD*)WATER_AREA_PTR + (i * 0x1C));
  54.  
  55.         // Get the player's coordinates
  56.         Vector3 playerCoords = ENTITY::GET_ENTITY_COORDS(PLAYER::PLAYER_PED_ID(), false);
  57.  
  58.         // Calculate the center of the water block (quad)
  59.         int centerX = (currentBlock.minX + currentBlock.maxX) / 2;
  60.         int centerY = (currentBlock.minY + currentBlock.maxY) / 2;
  61.  
  62.         // Draw a line from the player's coordinates to the water block center
  63.         GRAPHICS::DRAW_LINE(playerCoords.x, playerCoords.y, playerCoords.z,
  64.                             (float)centerX, (float)centerY, currentBlock.waterHeight + 1.0f,
  65.                             VariantArrowColor.r, VariantArrowColor.g, VariantArrowColor.b, 200);
  66.     }
  67. }
  68.  
  69. // Function to update the texture of all water blocks (example)
  70. void UpdateWaterTextures(DWORD newTextureID) {
  71.     int blockCount = *(WORD*)WATER_AREA_SIZE;
  72.  
  73.     for (int i = 0; i < blockCount; i++) {
  74.         WaterBlock currentBlock = *(WaterBlock*)(*(DWORD*)WATER_AREA_PTR + (i * 0x1C));
  75.  
  76.         // Update texture ID for the block
  77.         currentBlock.textureID = newTextureID;
  78.  
  79.         // Restore the updated block
  80.         *(WaterBlock*)(*(DWORD*)WATER_AREA_PTR + (i * 0x1C)) = currentBlock;
  81.     }
  82. }
  83.  
  84. // Function to reset all water heights to a default value (e.g., level 0)
  85. void ResetWaterHeightsToDefault() {
  86.     SetWaterHeightForAllBlocks(0.0f);
  87. }
  88.  
  89.  
Advertisement
Add Comment
Please, Sign In to add comment