WoW:API UnitCanAttack: Difference between revisions

From AddOn Studio
Jump to navigation Jump to search
No edit summary
 
mNo edit summary
Line 16: Line 16:
;''Returns''
;''Returns''


:isTrue
:Boolean isTrue
:;isTrue : true if the <tt>attacker</tt> can attack the <tt>attacked</tt>, false otherwise
:;isTrue : true if the <tt>attacker</tt> can attack the <tt>attacked</tt>, false otherwise


Line 29: Line 29:


;''Result''
;''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.
: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.


----
----

Revision as of 18:37, 21 November 2004

UnitCanAttack -Documentation by danboo-

Returns true if the first unit can attack the second, false 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
Boolean isTrue
isTrue
true if the attacker can attack the attacked, false 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 true if the first unit can attack the second, false otherwise.

Template:WoW API