Apexx 60 Posted September 15, 2017 Share Posted September 15, 2017 Hello, I searched around the forums a bit, but I cannot find an answer here. I was wondering how I can insert abilities based on the condition that I am fighting an actual player of the opposite faction? reaction = UnitReaction("unit", "otherUnit"); -- In Blizzard Code, UnitReaction is only used between the player and a Non Player Controlled target. Would I need to check each enum? wManager.Wow.Enums.PlayerFactions.Dwarf Link to comment https://wrobot.eu/forums/topic/7097-is-target-player-of-opposite-faction/ Share on other sites More sharing options...
reapler 154 Posted September 15, 2017 Share Posted September 15, 2017 Hello, ".PlayerFaction" should do its job: if (ObjectManager.Me.PlayerFaction == ((WoWPlayer) ObjectManager.Target).PlayerFaction) { Logging.Write("target same faction"); } if (ObjectManager.Me.PlayerFaction != ((WoWPlayer) ObjectManager.Target).PlayerFaction) { Logging.Write("target hostile faction"); } To check if target is a player: ObjectManager.Target.PlayerControlled Apexx 1 Link to comment https://wrobot.eu/forums/topic/7097-is-target-player-of-opposite-faction/#findComment-32123 Share on other sites More sharing options...
Apexx 60 Posted September 15, 2017 Author Share Posted September 15, 2017 Thanks, @reapler Link to comment https://wrobot.eu/forums/topic/7097-is-target-player-of-opposite-faction/#findComment-32124 Share on other sites More sharing options...
Apexx 60 Posted September 16, 2017 Author Share Posted September 16, 2017 I will have to do more testing, but when I tried this buffing friendly players within Power Word: Fortitude range and checking my faction with target faction, it would only buff those that were Undead as I was. It takes the player "Race" not Faction type which would be "Horde", "Alliance", "Horde Expedition", or "Alliance Vanguard". Quote Reference: https://wow.gamepedia.com/Faction World of Warcraft Races are noted here I guess I am just confused if there is no real substantial check for faction types. Link to comment https://wrobot.eu/forums/topic/7097-is-target-player-of-opposite-faction/#findComment-32144 Share on other sites More sharing options...
Apexx 60 Posted September 16, 2017 Author Share Posted September 16, 2017 I have since scrapped the project as trying to write healbots using WRobot was just too much for my skill of keeping things organized and maybe too many checks. Here is the snippet that did seem to work, but using the check for my warrior fight class, it would continuously crash WRobot before logging the actual error. // Buff Friendly Targets if (PriestSettings.CurrentSetting.BuffFriendlyTargets) { if (_powerWordFortitude.KnownSpell && _powerWordFortitude.IsSpellUsable && target.Faction == player.Faction && target.IsAlive && target.IsValid && target.GetDistance <= _powerWordFortitude.MaxRange && !TraceLine.TraceLineGo(target.Position) && !target.HaveBuff(_powerWordFortitude.Ids)) { Logging.WriteDebug(target.Name + " is missing Power Word: Fortitude."); _powerWordFortitude.Launch(); Thread.Sleep(SpellManager.GetSpellCooldownTimeLeft(_powerWordFortitude.Id)); } } Link to comment https://wrobot.eu/forums/topic/7097-is-target-player-of-opposite-faction/#findComment-32145 Share on other sites More sharing options...
reapler 154 Posted September 16, 2017 Share Posted September 16, 2017 12 hours ago, Apexx said: I have since scrapped the project as trying to write healbots using WRobot was just too much for my skill of keeping things organized and maybe too many checks. Here is the snippet that did seem to work, but using the check for my warrior fight class, it would continuously crash WRobot before logging the actual error. // Buff Friendly Targets if (PriestSettings.CurrentSetting.BuffFriendlyTargets) { if (_powerWordFortitude.KnownSpell && _powerWordFortitude.IsSpellUsable && target.Faction == player.Faction && target.IsAlive && target.IsValid && target.GetDistance <= _powerWordFortitude.MaxRange && !TraceLine.TraceLineGo(target.Position) && !target.HaveBuff(_powerWordFortitude.Ids)) { Logging.WriteDebug(target.Name + " is missing Power Word: Fortitude."); _powerWordFortitude.Launch(); Thread.Sleep(SpellManager.GetSpellCooldownTimeLeft(_powerWordFortitude.Id)); } } If this happens you should consider to use try and catch to log the error: try { // Buff Friendly Targets if (PriestSettings.CurrentSetting.BuffFriendlyTargets) { if (_powerWordFortitude.KnownSpell && _powerWordFortitude.IsSpellUsable && target.Faction == player.Faction && target.IsAlive && target.IsValid && target.GetDistance <= _powerWordFortitude.MaxRange && !TraceLine.TraceLineGo(target.Position) && !target.HaveBuff(_powerWordFortitude.Ids)) { Logging.WriteDebug(target.Name + " is missing Power Word: Fortitude."); _powerWordFortitude.Launch(); Thread.Sleep(SpellManager.GetSpellCooldownTimeLeft(_powerWordFortitude.Id)); } } } catch (Exception e) { Logging.WriteError(e.ToString()); } For example you haven't initialized "PriestSettings.CurrentSetting", so this would result in null and throw an exception. Apexx 1 Link to comment https://wrobot.eu/forums/topic/7097-is-target-player-of-opposite-faction/#findComment-32164 Share on other sites More sharing options...
Avvi 98 Posted September 16, 2017 Share Posted September 16, 2017 Just to clarify, the try / catch will prevent the bot from crashing, and then return the issue to WRobot logs. I use this technique when testing/trying to fix issues in my code all the time :) Apexx 1 Link to comment https://wrobot.eu/forums/topic/7097-is-target-player-of-opposite-faction/#findComment-32165 Share on other sites More sharing options...
Apexx 60 Posted September 16, 2017 Author Share Posted September 16, 2017 Thanks guys, I will be sure to use that. Link to comment https://wrobot.eu/forums/topic/7097-is-target-player-of-opposite-faction/#findComment-32168 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