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.

Prioritize Low HP targets

Featured Replies

Like the title says...

I'm working on a BM hunter fightclass. I'd like to find a way to make it prioritize low hp enemies when there are multiple aggro'd... I have no idea where to start though.

Thanks,

14 hours ago, Lockem said:

Like the title says...

I'm working on a BM hunter fightclass. I'd like to find a way to make it prioritize low hp enemies when there are multiple aggro'd... I have no idea where to start though.

Thanks,

You need an OnFightLoop fight event.

I'm not sure whether this is the correct way to handle events but it's the way I could come up with, since my knowledge of Csharp is very limited still... BUT, what I do is put the OnFightLoop event in a method and call it during initialization. Once it is called the events "are recognized" and will fire everytime you are in a fight loop.

Disclaimer: this is not tested, put this together just now...

public void TargetSwitcher() // needs to be called just once, ie during Initialize
{
	FightEvents.OnFightLoop += (unit, cancelable) => { // this code will loop everytime you are fighting
		List<WoWUnit> attackers = ObjectManager.GetUnitAttackPlayer(); // gets all units attacking you
		if (attackers.Count > 1) // if you are attacked by more than one mob
		{
			Logging.WriteDebug("More than 1 attackers detected.");
			//WoWUnit highestHP = attackers.OrderBy(uo => uo.HealthPercent).LastOrDefault(); // sort the list based on HP from lowest to highest, pick highest
			WoWUnit lowestHP = attackers.OrderBy(ou => ou.HealthPercent).FirstOrDefault(); // sort the list based on HP from lowest to highest, pick lowest
			if (lowestHP != null && lowestHP.IsValid && lowestHP.IsAlive && !lowestHP.IsMyTarget) // if the lowest hp mob is valid, alive and NOT your current target
			{
				cancelable.Cancel = true; // not TOO sure about this one haha
				Interact.InteractGameObject(lowestHP.GetBaseAddress); // switch to it
				Fight.StartFight(lowestHP.GetBaseAddress); // start fighting it
				Logging.WriteDebug("Switched to lowestHP target.");
			}
		}
	};
}

 

As a bonus, check this post by Droidz. Might be usefull too.

 

Let me know how it worked out for ya...

Edited by Seminko
corrected unitToAttack --> lowestHP

I do believe Seminko did not define unitToAttack.

Simply replace

if (lowestHP != null && unitToAttack.IsValid && unitToAttack.IsAlive && !lowestHP.IsMyTarget) // if the lowest hp mob is valid, alive and NOT your current target

with:

if (lowestHP != null && lowestHP.IsValid && lowestHP.IsAlive && !lowestHP.IsMyTarget) // if the lowest hp mob is valid, alive and NOT your current target

 

3 minutes ago, Apexx said:

I do believe Seminko did not define unitToAttack.

Simply replace


if (lowestHP != null && unitToAttack.IsValid && unitToAttack.IsAlive && !lowestHP.IsMyTarget) // if the lowest hp mob is valid, alive and NOT your current target

with:


if (lowestHP != null && lowestHP.IsValid && lowestHP.IsAlive && !lowestHP.IsMyTarget) // if the lowest hp mob is valid, alive and NOT your current target

 

Yea, that is my bad. Was copying stuff from my other FCs :) Let me update the original reply. Thx for correcting me.

  • Author

@Seminko Actually found your post about multi target rotations:

Spoiler

internal void MultiTargetRotation()
    {
        var unitsAffectingMyCombat = ObjectManager.GetUnitAttackPlayer();

        if (unitsAffectingMyCombat.Count <= 0)
            return;

        var unitsAttackMe = unitsAffectingMyCombat.Where(u => u != null && u.IsValid && u.IsTargetingMe).ToList();

        if (unitsAttackMe.Count >= 1)
        {
            var unitToAttack = unitsAttackMe.FirstOrDefault(u => u != null && u.IsValid && !u.IsMyPetTarget);
            if (unitToAttack != null && unitToAttack.IsValid && unitToAttack.IsAlive)
            {
                if (!unitToAttack.IsMyTarget)
                    Interact.InteractGameObject(unitToAttack.GetBaseAddress, !ObjectManager.Me.GetMove);
					Lua.LuaDoString("PetAttack();");
                if (unitToAttack.IsMyTarget)
                    Lua.LuaDoString("PetAttack();");
                Logging.Write("PET ATTACKING: " + unitToAttack);
            }
        }
		else
		{
			var unitsAttackPet = unitsAffectingMyCombat.Where(u => u != null && u.IsValid && u.IsTargetingMyPet && (!u.HaveBuff("Corruption") || !u.HaveBuff("Curse of Agony"))).FirstOrDefault();
            if (unitsAttackPet != null && unitsAttackPet.IsValid && unitsAttackPet.IsAlive && !unitsAttackPet.IsMyPetTarget)
            {
                if (!unitsAttackPet.IsMyTarget)
				{
					if (!unitsAttackPet.HaveBuff("Corruption") && Corruption.IsSpellUsable)
					{
						Interact.InteractGameObject(unitsAttackPet.GetBaseAddress, !ObjectManager.Me.GetMove);
						SpellManager.CastSpellByNameLUA("Corruption");
					}
					if (!unitsAttackPet.HaveBuff("Curse of Agony") && CurseOfAgony.IsSpellUsable)
					{
						Interact.InteractGameObject(unitsAttackPet.GetBaseAddress, !ObjectManager.Me.GetMove);
						SpellManager.CastSpellByNameLUA("Curse of Agony");
					}
				}
                if (unitsAttackPet.IsMyTarget)
				{	
					if (!unitsAttackPet.HaveBuff("Corruption") && Corruption.IsSpellUsable)
					{
						SpellManager.CastSpellByNameLUA("Corruption");
					}
					if (!unitsAttackPet.HaveBuff("Curse of Agony") && CurseOfAgony.IsSpellUsable)
					{
						SpellManager.CastSpellByNameLUA("Curse of Agony");
					}
                    Lua.LuaDoString("PetAttack();");
				}
            }
		}
    }

 

This is exactly what I'm trying to do with my hunter FC... Just updating it a bit based on the function you linked above. Hope that's ok!

2 minutes ago, Lockem said:

@Seminko Actually found your post about multi target rotations:

This is exactly what I'm trying to do with my hunter FC... Just updating it a bit based on the function you linked above. Hope that's ok!

Sure thing, but that's an old code. ;) Now I would not "hardcode" abilities into an OnFightLoop since it might mess with your FC.

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.