September 15, 20178 yr 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
September 15, 20178 yr 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
September 16, 20178 yr Author 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.
September 16, 20178 yr Author 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)); } }
September 16, 20178 yr 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.
September 16, 20178 yr 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 :)
Create an account or sign in to comment