Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*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.
- Of course, for the sake of better readability and understanding, I had it rewritten with more descriptive comments using A.I.
- */
- #define WATER_AREA_PTR 0x020FCC48
- #define WATER_AREA_SIZE 0x020FCC48 + 0x4
- struct WaterBlock {
- __int16 minX; // Minimum X coordinate
- __int16 minY; // Minimum Y coordinate
- __int16 maxX; // Maximum X coordinate
- __int16 maxY; // Maximum Y coordinate
- DWORD textureID; // Texture identifier (optional)
- char padding[8]; //
- float waterHeight; // Water height at this block
- };
- // Function to set the height of the water in all blocks
- void SetWaterHeightForAllBlocks(float newHeight) {
- int blockCount = *(WORD*)WATER_AREA_SIZE; // Get the total number of water blocks
- for (int i = 0; i < blockCount; i++) {
- // Calculate the memory address of the current water block structure
- WaterBlock currentBlock = *(WaterBlock*)(*(DWORD*)WATER_AREA_PTR + (i * 0x1C));
- // Set the new water height
- currentBlock.waterHeight = newHeight;
- // Restore the updated water block data
- *(WaterBlock*)(*(DWORD*)WATER_AREA_PTR + (i * 0x1C)) = currentBlock;
- }
- }
- // Function to get the height of the water in a specific block
- float GetWaterHeightAtBlock(int blockIndex) {
- int blockCount = *(WORD*)WATER_AREA_SIZE; // Get the total number of water blocks
- if (blockIndex >= 0 && blockIndex < blockCount) {
- // Fetch the water block data
- WaterBlock currentBlock = *(WaterBlock*)(*(DWORD*)WATER_AREA_PTR + (blockIndex * 0x1C));
- // Return the water height of the block
- return currentBlock.waterHeight;
- }
- return -1.0f; // Return an invalid value if the block index is out of range
- }
- // Function to draw lines representing the water areas (quads)
- void RenderWaterAreaLines() {
- int blockCount = *(WORD*)WATER_AREA_SIZE;
- for (int i = 0; i < blockCount; i++) {
- // Fetch the current water block's data
- WaterBlock currentBlock = *(WaterBlock*)(*(DWORD*)WATER_AREA_PTR + (i * 0x1C));
- // Get the player's coordinates
- Vector3 playerCoords = ENTITY::GET_ENTITY_COORDS(PLAYER::PLAYER_PED_ID(), false);
- // Calculate the center of the water block (quad)
- int centerX = (currentBlock.minX + currentBlock.maxX) / 2;
- int centerY = (currentBlock.minY + currentBlock.maxY) / 2;
- // Draw a line from the player's coordinates to the water block center
- GRAPHICS::DRAW_LINE(playerCoords.x, playerCoords.y, playerCoords.z,
- (float)centerX, (float)centerY, currentBlock.waterHeight + 1.0f,
- VariantArrowColor.r, VariantArrowColor.g, VariantArrowColor.b, 200);
- }
- }
- // Function to update the texture of all water blocks (example)
- void UpdateWaterTextures(DWORD newTextureID) {
- int blockCount = *(WORD*)WATER_AREA_SIZE;
- for (int i = 0; i < blockCount; i++) {
- WaterBlock currentBlock = *(WaterBlock*)(*(DWORD*)WATER_AREA_PTR + (i * 0x1C));
- // Update texture ID for the block
- currentBlock.textureID = newTextureID;
- // Restore the updated block
- *(WaterBlock*)(*(DWORD*)WATER_AREA_PTR + (i * 0x1C)) = currentBlock;
- }
- }
- // Function to reset all water heights to a default value (e.g., level 0)
- void ResetWaterHeightsToDefault() {
- SetWaterHeightForAllBlocks(0.0f);
- }
Advertisement
Add Comment
Please, Sign In to add comment