Skip to content

Instantly share code, notes, and snippets.

@StinkyTwitch
Created February 19, 2015 17:59
Show Gist options
  • Save StinkyTwitch/1fc692b1199d64eae1e5 to your computer and use it in GitHub Desktop.
Save StinkyTwitch/1fc692b1199d64eae1e5 to your computer and use it in GitHub Desktop.
Get Objects Health using Descriptor
local _,_,_,_,_, target_id,_ = strsplit("-",UnitGUID("target"))
local object_pointer = nil
local total_objects = ObjectCount()
for i=1, total_objects do
local _, object = pcall(ObjectWithIndex, i)
local _, object_exists = pcall(ObjectExists, object)
if object_exists then
local _, object_type = pcall(ObjectType, object)
local bitband = bit.band(object_type, ObjectTypes.Unit)
local type, zero, server_id, instance_id, zone_uid, unit_id, spawn_id = strsplit("-",UnitGUID(object))
if bitband > 0 then
if unit_id == target_id then
local object_health = ObjectDescriptor(object, 0xEC, ObjectTypes.Unit)
print(tonumber(object_health,16))
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment