Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- GameGuardian Lua Script to Apply Damage to Zombies Using "Zombie_Controller" Keyword Search
- -- Set the memory region to search (typically for C data)
- gg.setRanges(gg.REGION_C_DATA)
- -- Define the damage value as a float (1000.0)
- local DAMAGE_AMOUNT = 1000.0 -- Damage value set as float
- -- Function to search for the "Zombie_Controller" keyword and find zombies
- function findZombieControllers()
- local zombieControllers = {} -- Table to store zombie controller addresses
- -- Search for the "Zombie_Controller" keyword in memory
- gg.searchText("Zombie_Controller", gg.TYPE_BYTE) -- Search for the keyword (adjust type if needed)
- -- Wait for the search to complete
- gg.waitForSearchResults(10) -- Adjust timeout if needed (in seconds)
- -- Check if the search yielded any results
- if gg.getResultsCount() > 0 then
- local results = gg.getResults(gg.getResultsCount()) -- Retrieve all search results
- -- Loop through search results to find health addresses
- for _, result in ipairs(results) do
- -- Get the address where the "Zombie_Controller" was found
- local controllerAddr = result.address
- -- Read nearby memory to locate the health value (assuming it's at a known offset)
- local healthAddr = controllerAddr + 0xC -- Hypothetical offset for health data
- -- Read the current health value (assuming it's stored as a float)
- local healthValue = gg.getValues({{address = healthAddr, flags = gg.TYPE_FLOAT}})[1].value
- -- Only add zombies with health greater than 0 (alive zombies)
- if healthValue > 0 then
- table.insert(zombieControllers, healthAddr) -- Add the health address to the list
- end
- end
- else
- gg.toast("No 'Zombie_Controller' found in memory.")
- end
- -- Return the list of health addresses
- return zombieControllers
- end
- -- Function to apply damage to all zombies
- function damageAllZombies(zombieControllers)
- for _, healthAddr in ipairs(zombieControllers) do
- -- Read the current health value from memory
- local currentHealth = gg.getValues({{address = healthAddr, flags = gg.TYPE_FLOAT}})[1].value
- -- Calculate the new health after applying damage
- local newHealth = currentHealth - DAMAGE_AMOUNT
- -- Prevent health from going below 0 (set it to 0 if it does)
- if newHealth < 0 then
- newHealth = 0
- end
- -- Write the new health value back into memory (as a float)
- gg.setValues({{address = healthAddr, value = newHealth, flags = gg.TYPE_FLOAT}})
- -- Optionally, show a message for each damaged zombie (useful for debugging)
- gg.toast("Damaged zombie at address: " .. string.format("0x%X", healthAddr))
- end
- end
- -- Main function to run the script
- function mainLoop()
- -- Get all zombie controller health addresses
- local zombieControllers = findZombieControllers()
- -- If zombies are found, damage them
- if #zombieControllers > 0 then
- damageAllZombies(zombieControllers)
- gg.toast("Successfully damaged " .. #zombieControllers .. " zombies.")
- else
- gg.toast("No zombies found!")
- end
- end
- -- Run the script
- mainLoop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement