November 14, 20178 yr 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,
November 14, 20178 yr Is your fightclass done in C#? If not, you won't be able to achieve this. I believe @Seminko recently figured out targeting in a (more or less) safe way.
November 14, 20178 yr 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 November 14, 20178 yr by Seminko corrected unitToAttack --> lowestHP
November 14, 20178 yr 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
November 14, 20178 yr 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.
November 14, 20178 yr 2 hours ago, Lockem said: Going to try it out now, thanks a lot! Let us know if it works for you Lockem.
November 14, 20178 yr 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!
November 14, 20178 yr 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