Jump to content

Recommended Posts

  On 11/14/2017 at 3:27 AM, 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,

Expand  

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

 

  On 11/14/2017 at 5:47 PM, 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

 

Expand  

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

@Seminko Actually found your post about multi target rotations:

  Reveal hidden contents

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!

  On 11/14/2017 at 6:41 PM, 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!

Expand  

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

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