Jump to content

WoWPlayer.Attackable returns wrong values?


s1m421

Recommended Posts

Hi guys, Im trying to make pvp stuff for my own use with the bot

Ive noticed for example when I try to loop objectmanager to get Players arround me (not npc/units, real players). unit.Attackable should return true in duel for example or in arenas. but na it is not returning true, so I guess is wrong return value. Which would be the sense if adding Attackable extension if its same as checking faction or enemy. they are not enemies, we both same faction, but we are rivals sometimes like in arena, crossfaction bg or duels. so attackable should adapt to any situation that the unit become attackable imo.

Thanks

Link to comment
Share on other sites

7 hours ago, Droidz said:

Hi,

use lua 


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

 

Hi @Droidz I already did that, the issue is that I actually need to control enemies Around me, not my particular target. I need to search all wow players around me and then filter them by ally and enemy. Target by wow api works good (a bit slow but works as intended). The thing is I need this to be able to check for Every Objectmanager unit that I find by memory reading, I cannot target each one of them, I need to get this value from the nontarget unit like I get IsPartyMember, IsAlive, etc...

Thanks

Link to comment
Share on other sites

WoWPlayer player1 = ...;
bool canAttack = false;
var f = wManager.Wow.ObjectManager.ObjectManager.Me.FocusGuid;
wManager.Wow.ObjectManager.ObjectManager.Me.FocusGuid = player1.Guid;
if (wManager.Wow.ObjectManager.ObjectManager.Me.FocusGuid == player1.Guid)
    canAttack = Lua.LuaDoString<bool>("return UnitCanAttack('player', 'focus')");
wManager.Wow.ObjectManager.ObjectManager.Me.FocusGuid = f;
Logging.WriteDebug("Can attack = " + canAttack + " > " + player1);

try code like (no tested)

Link to comment
Share on other sites

11 minutes ago, Droidz said:

WoWPlayer player1 = ...;
bool canAttack = false;
var f = wManager.Wow.ObjectManager.ObjectManager.Me.FocusGuid;
wManager.Wow.ObjectManager.ObjectManager.Me.FocusGuid = player1.Guid;
if (wManager.Wow.ObjectManager.ObjectManager.Me.FocusGuid == player1.Guid)
    canAttack = Lua.LuaDoString<bool>("return UnitCanAttack('player', 'focus')");
wManager.Wow.ObjectManager.ObjectManager.Me.FocusGuid = f;
Logging.WriteDebug("Can attack = " + canAttack + " > " + player1);

try code like (no tested)

makes sense, i apreciate you take the time 
this code is an alternative to work with 2 units, target and focus, I like it. but, is there any way to work with more than 2 units at once?

like anyway to loop thru all units around localplayer and store them into friend and enemy list using similar method?
loop each one, focus each one and check?
something like localplayer range 40, each tick, focus all them quick and determine who is friend and who is enemy?

Link to comment
Share on other sites

var playersAttackable = new List<wManager.Wow.ObjectManager.WoWPlayer>();
foreach (var player in wManager.Wow.ObjectManager.ObjectManager.GetObjectWoWPlayer())
{
    bool canAttack = false;
    var f = wManager.Wow.ObjectManager.ObjectManager.Me.FocusGuid;
    wManager.Wow.ObjectManager.ObjectManager.Me.FocusGuid = player.Guid;
    if (wManager.Wow.ObjectManager.ObjectManager.Me.FocusGuid == player.Guid)
        canAttack = Lua.LuaDoString<bool>("return UnitCanAttack('player', 'focus')");
    wManager.Wow.ObjectManager.ObjectManager.Me.FocusGuid = f;
    if (canAttack)
        playersAttackable.Add(player);
    Logging.WriteDebug("Can attack = " + canAttack + " > " + player); 
}

You can change focus several time

Link to comment
Share on other sites

15 hours ago, Droidz said:

var playersAttackable = new List<wManager.Wow.ObjectManager.WoWPlayer>();
foreach (var player in wManager.Wow.ObjectManager.ObjectManager.GetObjectWoWPlayer())
{
    bool canAttack = false;
    var f = wManager.Wow.ObjectManager.ObjectManager.Me.FocusGuid;
    wManager.Wow.ObjectManager.ObjectManager.Me.FocusGuid = player.Guid;
    if (wManager.Wow.ObjectManager.ObjectManager.Me.FocusGuid == player.Guid)
        canAttack = Lua.LuaDoString<bool>("return UnitCanAttack('player', 'focus')");
    wManager.Wow.ObjectManager.ObjectManager.Me.FocusGuid = f;
    if (canAttack)
        playersAttackable.Add(player);
    Logging.WriteDebug("Can attack = " + canAttack + " > " + player); 
}

You can change focus several time

Thanks you alot, this is extremly useful

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...