Wikia

WoWWiki

Watchlist Recent changes

API UnitIsEnemy

Main Menue



This function will determine if the target is hostile towards you.

Contents

Parameters Edit

Function Edit

UnitIsEnemy 
UnitIsEnemy("unit","otherunit")
Determine whether a unit is hostile to you or not.

Arguments Edit

unit
String - The UnitId of the first unit.
otherunit
String - The UnitId of the unit to compare with the first unit.

Returns Edit

IsEnemy
Returns either nil or 1, not a boolean value.
If the second parameter is "target" and nothing is targeted, this function returns nil.

Example Edit

IsEnemy 
/script if (UnitIsEnemy("player","target")) then DEFAULT_CHAT_FRAME:AddMessage( "target health ="..UnitHealth("target") ); end
This will determine if your target is hostile, and if it is, it will print the target's health to the chat frame.
Not IsEnemy 
/script if not (UnitIsEnemy("player","target")) then SendChatMessage("Don't shoot! It's %t!","SAY"); end;
This is to find if the target is not hostile with you (friendly). If you target an friendly target with the name "60Mage" this script will write "Don't shoot! It's 60Mage!" in /s, using your faction's default language.

Pages on WoWWiki

95,750pages on
this wiki
Advertisement | Your ad here

Latest Photos

Add a Photo
58,025photos on this wiki
See more >

Recent Wiki Activity

See more >

Recent Questions

Around Wikia's network

Random Wiki