API UnitCanCooperate

Returns true if the first unit can cooperate with the second, false otherwise.

UnitCanCooperate(unit1, unit2);

Arguments

 * unit1 : String - The UnitId of the unit to check (Tested with "player", "pet", "party1", hostile "target")
 * unit2 : String - The UnitId of the unit to check (Tested with "player", "pet", "party1", hostile "target")

Returns

 * cancooperate : Boolean - Returns true if the first unit can cooperate with the second, nil otherwise

Example
if ( UnitCanCooperate("player", "target") ) then AddFriend(UnitName("target")); else StaticPopup_Show("ADD_FRIEND"); end

Result
Adds the target to the friends list, if the target can be added to the friends list. Shows the add friend dialog otherwise.