WoW:API UnitIsEnemy: Difference between revisions
Jump to navigation
Jump to search
(New page: {{wowapi}} This function will determine if the target is hostile towards you. == Parameters == === Function === :;UnitIsEnemy : UnitIsEnemy("unit","otherunit")<br>Determine whether a un...) |
m (Move page script moved page API UnitIsEnemy to API UnitIsEnemy without leaving a redirect) |
||
| (One intermediate revision by one other user not shown) | |||
| Line 12: | Line 12: | ||
=== Returns === | === Returns === | ||
;IsEnemy: true or false, boolean.<br>If the second parameter is "target" and nothing is targeted, this function returns <tt>nil</tt>. | |||
=== Example === | === Example === | ||
Latest revision as of 04:47, 15 August 2023
← WoW API < UnitIsEnemy
This function will determine if the target is hostile towards you.
Parameters
Function
- UnitIsEnemy
- UnitIsEnemy("unit","otherunit")
Determine whether a unit is hostile to you or not.
Arguments
Returns
- IsEnemy
- true or false, boolean.
If the second parameter is "target" and nothing is targeted, this function returns nil.
Example
- 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.