Method Creature:GetAITarget [-] [+]

Returns a target from the Creature's threat list based on the supplied arguments.

enum SelectAggroTarget
{
    SELECT_TARGET_RANDOM = 0,  //Just selects a random target
    SELECT_TARGET_TOPAGGRO,    //Selects targets from top aggro to bottom
    SELECT_TARGET_BOTTOMAGGRO, //Selects targets from bottom aggro to top
    SELECT_TARGET_NEAREST,
    SELECT_TARGET_FARTHEST
};

For example, if you wanted to select the third-farthest Player within 50 yards that has the Aura "Corrupted Blood" (ID 24328), you could use this function like so:

target = creature:GetAITarget(4, true, 3, 50, 24328)

Synopsis

target = Creature:GetAITarget( targetType )

target = Creature:GetAITarget( targetType, playerOnly )

target = Creature:GetAITarget( targetType, playerOnly, position )

target = Creature:GetAITarget( targetType, playerOnly, position, distance )

target = Creature:GetAITarget( targetType, playerOnly, position, distance, aura )

Arguments

SelectAggroTarget targetType

How the threat list should be sorted.

boolean playerOnly (false)

If true, skips targets that aren't Players.

number position (0)

Used as an offset into the threat list. If targetType is random, used as the number of players from top of aggro to choose from.

Valid numbers: integers from 0 to 4,294,967,295.

number distance (0)

Valid numbers: all decimal numbers.

number aura (0)

If positive, the target must have this Aura. If negative, the the target must not have this Aura.

Valid numbers: integers from -2,147,483,647 to 2,147,483,647.

Returns

Unit target

The target, or nil.

Generated on
©2016 - Eluna Lua Engine