s1m421 0 Posted February 26, 2021 Share Posted February 26, 2021 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 https://wrobot.eu/forums/topic/12869-wowplayerattackable-returns-wrong-values/ Share on other sites More sharing options...
Droidz 2738 Posted February 26, 2021 Share Posted February 26, 2021 Hi, use lua Lua.LuaDoString<bool>("return UnitCanAttack('player', 'target')") Link to comment https://wrobot.eu/forums/topic/12869-wowplayerattackable-returns-wrong-values/#findComment-61356 Share on other sites More sharing options...
s1m421 0 Posted February 26, 2021 Author Share Posted February 26, 2021 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 https://wrobot.eu/forums/topic/12869-wowplayerattackable-returns-wrong-values/#findComment-61364 Share on other sites More sharing options...
Droidz 2738 Posted February 26, 2021 Share Posted February 26, 2021 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 https://wrobot.eu/forums/topic/12869-wowplayerattackable-returns-wrong-values/#findComment-61365 Share on other sites More sharing options...
s1m421 0 Posted February 26, 2021 Author Share Posted February 26, 2021 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 https://wrobot.eu/forums/topic/12869-wowplayerattackable-returns-wrong-values/#findComment-61367 Share on other sites More sharing options...
Droidz 2738 Posted February 27, 2021 Share Posted February 27, 2021 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 s1m421 1 Link to comment https://wrobot.eu/forums/topic/12869-wowplayerattackable-returns-wrong-values/#findComment-61374 Share on other sites More sharing options...
s1m421 0 Posted February 28, 2021 Author Share Posted February 28, 2021 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 https://wrobot.eu/forums/topic/12869-wowplayerattackable-returns-wrong-values/#findComment-61383 Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now