GetUnitFlags
The GetUnitFlags function retrieves the flags associated with a specified unit in the game world. Unlike GetObjectDynamicFlags, which works with all objects, GetUnitFlags is specific to units and uses a different flag system. These flags provide information about the unit's properties and states, such as whether the unit is in combat, stunned, or otherwise affected by game mechanics.
Parameters
unit: The unit identifier (GUID) or unit identifier (such as "player", "target", "focus", etc.) for which to retrieve the flags.
Returns
flags: A bitmask representing the flags of the specified unit. The specific meaning of each bit in the bitmask depends on the game's implementation and is usually documented in the game's API reference.
Example Usage in Lua
Here is an example of how to use the GetUnitFlags function in Lua:
local api = ...
-- Function to print the flags of the player
function PrintPlayerFlags()
local player = "player"
local flags = api.GetUnitFlags(player)
print("Unit Flags for player: " .. flags)
end
-- Function to print the flags of the target
function PrintTargetFlags()
local target = "target"
local flags = api.GetUnitFlags(target)
print("Unit Flags for target: " .. flags)
end
-- Function to print the flags of a specific unit by GUID
function PrintUnitFlagsByGUID(unitGUID)
local flags = api.GetUnitFlags(unitGUID)
print("Unit Flags for unit with GUID " .. unitGUID .. ": " .. flags)
end
-- Call the functions
PrintPlayerFlags()
PrintTargetFlags()
-- Example unit GUID (replace with an actual GUID in your game)
local exampleUnitGUID = "1234-5678-9012-3456"
PrintUnitFlagsByGUID(exampleUnitGUID)