Jump to content

Checking if unit is hostile


knights

Recommended Posts

Is there anyway to check if the unit targetted is Hostile in CSharp code? something like below?

return ObjectManager.GetWoWUnitHostile()

Not really an issue now but the bot is always trying to cast spell on vendor...  the spell is supposed to be an opening before combat

Link to comment
Share on other sites

In my profile I don't check "hostily", I check if "not friendly" thats a different. And npc's wouldn't attack

 

if UnitExists("target") and not UnitIsFriend("player", "target") then 
...
end

Its LUA, but I think, there is an option in C# also

Link to comment
Share on other sites

3 hours ago, Bugreporter said:

In my profile I don't check "hostily", I check if "not friendly" thats a different. And npc's wouldn't attack

 


if UnitExists("target") and not UnitIsFriend("player", "target") then 
...
end

Its LUA, but I think, there is an option in C# also

I did tried your version, but it still kept casting...

 

Link to comment
Share on other sites

Hello, you can check Reaction:

wManager.Wow.ObjectManager.ObjectManager.Target.Reaction
Quote

        Hated,
        Hostile,
        Unfriendly,
        Neutral,
        Friendly,
        Honored,
        Revered,
        Exalted,

You can also use:

wManager.Wow.ObjectManager.ObjectManager.Target.IsAttackable

or use this lua code:

Lua.LuaDoString<bool>("return UnitCanAttack('player', 'target');")

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...