Skip to content
View in the app

A better way to browse. Learn more.

WRobot

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Is Target Player of Opposite Faction

Featured Replies

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

 

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

  • 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

World of Warcraft Races are noted here

I guess I am just confused if there is no real substantial check for faction types.

  • 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));
	}
}

 

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.

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

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.