Advertisement
SnowyLife

Untitled

Nov 30th, 2024
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.37 KB | None | 0 0
  1. -- GameGuardian Lua Script to Apply Damage to Zombies Using "Zombie_Controller" Keyword Search
  2.  
  3. -- Set the memory region to search (typically for C data)
  4. gg.setRanges(gg.REGION_C_DATA)
  5.  
  6. -- Define the damage value as a float (1000.0)
  7. local DAMAGE_AMOUNT = 1000.0  -- Damage value set as float
  8.  
  9. -- Function to search for the "Zombie_Controller" keyword and find zombies
  10. function findZombieControllers()
  11.     local zombieControllers = {}  -- Table to store zombie controller addresses
  12.    
  13.     -- Search for the "Zombie_Controller" keyword in memory
  14.     gg.searchText("Zombie_Controller", gg.TYPE_BYTE)  -- Search for the keyword (adjust type if needed)
  15.    
  16.     -- Wait for the search to complete
  17.     gg.waitForSearchResults(10)  -- Adjust timeout if needed (in seconds)
  18.    
  19.     -- Check if the search yielded any results
  20.     if gg.getResultsCount() > 0 then
  21.         local results = gg.getResults(gg.getResultsCount())  -- Retrieve all search results
  22.        
  23.         -- Loop through search results to find health addresses
  24.         for _, result in ipairs(results) do
  25.             -- Get the address where the "Zombie_Controller" was found
  26.             local controllerAddr = result.address
  27.            
  28.             -- Read nearby memory to locate the health value (assuming it's at a known offset)
  29.             local healthAddr = controllerAddr + 0xC  -- Hypothetical offset for health data
  30.            
  31.             -- Read the current health value (assuming it's stored as a float)
  32.             local healthValue = gg.getValues({{address = healthAddr, flags = gg.TYPE_FLOAT}})[1].value
  33.            
  34.             -- Only add zombies with health greater than 0 (alive zombies)
  35.             if healthValue > 0 then
  36.                 table.insert(zombieControllers, healthAddr)  -- Add the health address to the list
  37.             end
  38.         end
  39.     else
  40.         gg.toast("No 'Zombie_Controller' found in memory.")
  41.     end
  42.    
  43.     -- Return the list of health addresses
  44.     return zombieControllers
  45. end
  46.  
  47. -- Function to apply damage to all zombies
  48. function damageAllZombies(zombieControllers)
  49.     for _, healthAddr in ipairs(zombieControllers) do
  50.         -- Read the current health value from memory
  51.         local currentHealth = gg.getValues({{address = healthAddr, flags = gg.TYPE_FLOAT}})[1].value
  52.        
  53.         -- Calculate the new health after applying damage
  54.         local newHealth = currentHealth - DAMAGE_AMOUNT
  55.        
  56.         -- Prevent health from going below 0 (set it to 0 if it does)
  57.         if newHealth < 0 then
  58.             newHealth = 0
  59.         end
  60.        
  61.         -- Write the new health value back into memory (as a float)
  62.         gg.setValues({{address = healthAddr, value = newHealth, flags = gg.TYPE_FLOAT}})
  63.        
  64.         -- Optionally, show a message for each damaged zombie (useful for debugging)
  65.         gg.toast("Damaged zombie at address: " .. string.format("0x%X", healthAddr))
  66.     end
  67. end
  68.  
  69. -- Main function to run the script
  70. function mainLoop()
  71.     -- Get all zombie controller health addresses
  72.     local zombieControllers = findZombieControllers()
  73.  
  74.     -- If zombies are found, damage them
  75.     if #zombieControllers > 0 then
  76.         damageAllZombies(zombieControllers)
  77.         gg.toast("Successfully damaged " .. #zombieControllers .. " zombies.")
  78.     else
  79.         gg.toast("No zombies found!")
  80.     end
  81. end
  82.  
  83. -- Run the script
  84. mainLoop()
  85.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement