- 0 Talk
-
API UnitCanAttack
Returns 1 if the first unit can attack the second, nil otherwise.
canAttack = UnitCanAttack(attacker, attacked);
Parameters
Edit
Arguments
Edit
Returns
Edit
- canAttack
- Bool - 1 if the attacker can attack the attacked, nil otherwise.
Example
Edit
if ( UnitCanAttack("player", "target") ) then
DEFAULT_CHAT_FRAME:AddMessage("You can attack " .. UnitName("target") .. ".");
end
Result
Edit
If the player can attack their target, a message stating so is displayed in the default chat frame.