Jump to content

Recommended Posts

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

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

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.

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.

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