Skip to content

GetNPCFlags

The GetNPCFlags function retrieves the flags associated with a specified NPC (Non-Player Character) in the game world. These flags provide information about the NPC's properties and behaviors, such as whether the NPC is a vendor, quest giver, or trainer.

Parameters

  • npc: The NPC identifier (GUID) or unit identifier (such as "target", "focus", etc.) for which to retrieve the flags.

Returns

  • flags: A bitmask representing the flags of the specified NPC. 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 GetNPCFlags function in Lua:

local api = ...

-- Function to print the flags of the target NPC
function PrintTargetNPCFlags()
    local target = "target"
    local flags = api.GetNPCFlags(target)
    print("NPC Flags for target: " .. flags)
end

-- Function to print the flags of a specific NPC by GUID
function PrintNPCFlagsByGUID(npcGUID)
    local flags = api.GetNPCFlags(npcGUID)
    print("NPC Flags for NPC with GUID " .. npcGUID .. ": " .. flags)
end

-- Call the functions
PrintTargetNPCFlags()

-- Example NPC GUID (replace with an actual GUID in your game)
local exampleNPCGUID = "1234-5678-9012-3456"
PrintNPCFlagsByGUID(exampleNPCGUID)