GetUnitMovementFlags
The GetUnitMovementFlags function retrieves the movement flags associated with a specified unit in the game world. These flags provide information about the unit's movement state, such as whether the unit is moving forward, backward, strafing, or turning. The function returns a numeric value representing the direction and type of movement.
Parameters
unit: The object or unit identifier (GUID) or unit identifier (such as "player", "target", "focus", etc.) for which to retrieve the movement flags.
Returns
movementFlags: A numeric value representing the movement flags of the specified unit. The specific meaning of each value 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 GetUnitMovementFlags function in Lua, only returning the movement flags if the unit's speed is not zero:
local api = ...
-- Function to print the movement flags of the player if the player is not moving
function PrintPlayerMovementFlags()
local player = "player"
if api.GetUnitSpeed(player) == 0 then
print('player is not moving')
else
local movementFlags = api.GetUnitMovementFlags(player)
print("Movement Flags for player: " .. movementFlags)
end
end
-- Function to print the movement flags of the target if the target is not moving
function PrintTargetMovementFlags()
local target = "target"
if api.GetUnitSpeed(target) == 0 then
print('target is not moving')
else
local movementFlags = api.GetUnitMovementFlags(target)
print("Movement Flags for target: " .. movementFlags)
end
end
-- Function to print the movement flags of a specific unit by GUID if the unit is not moving
function PrintUnitMovementFlagsByGUID(unitGUID)
local target = unitGUID
if api.GetUnitSpeed(target) == 0 then
print('target is not moving')
else
local movementFlags = api.GetUnitMovementFlags(target)
print("Movement Flags for target: " .. movementFlags)
end
end
-- Call the functions
PrintPlayerMovementFlags()
PrintTargetMovementFlags()
-- Example unit GUID (replace with an actual GUID in your game)
local exampleUnitGUID = "1234-5678-9012-3456"
PrintUnitMovementFlagsByGUID(exampleUnitGUID)