Jump to content
Toggle menu
  • 17.3K articles
  • 8.2K files
  • 5 users
  • 280.7K edits
WoW Classic Wiki
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.
UnitCanAttack -Documentation by danboo-

Returns 1 if the first unit can attack the second, nil otherwise.

UnitCanAttack(attacker, attacked);

Arguments
(String attacker, Table attacked)
attacker
the unit that would initiate the attack (e.g., "player" or "target")
attacked
the unit that would be attacked (e.g., "player" or "target")

Returns
1 if the attacker can attack the attacked, nil otherwise

Example
 if ( UnitCanAttack("target", "player") ) then
   -- Hostile players are red
   if ( UnitCanAttack("player", "target") ) then
     TargetFrameNameBackground:SetVertexColor(1.0, 0.0, 0.0);
   end
 end
Result
If the target can attack the player and the player can attack the target then the target's name will appear red to the player.

Description
Returns 1 if the first unit can attack the second, nil otherwise.

Template:WoW API