Lockem 1 Posted November 14, 2017 Share Posted November 14, 2017 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, Link to comment https://wrobot.eu/forums/topic/7658-prioritize-low-hp-targets/ Share on other sites More sharing options...
Matenia 630 Posted November 14, 2017 Share Posted November 14, 2017 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. Link to comment https://wrobot.eu/forums/topic/7658-prioritize-low-hp-targets/#findComment-34970 Share on other sites More sharing options...
Seminko 41 Posted November 14, 2017 Share Posted November 14, 2017 (edited) 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, 2017 by Seminko corrected unitToAttack --> lowestHP Matenia 1 Link to comment https://wrobot.eu/forums/topic/7658-prioritize-low-hp-targets/#findComment-34971 Share on other sites More sharing options...
Lockem 1 Posted November 14, 2017 Author Share Posted November 14, 2017 Going to try it out now, thanks a lot! Link to comment https://wrobot.eu/forums/topic/7658-prioritize-low-hp-targets/#findComment-35000 Share on other sites More sharing options...
Apexx 60 Posted November 14, 2017 Share Posted November 14, 2017 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 Seminko 1 Link to comment https://wrobot.eu/forums/topic/7658-prioritize-low-hp-targets/#findComment-35006 Share on other sites More sharing options...
Seminko 41 Posted November 14, 2017 Share Posted November 14, 2017 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. Link to comment https://wrobot.eu/forums/topic/7658-prioritize-low-hp-targets/#findComment-35007 Share on other sites More sharing options...
Apexx 60 Posted November 14, 2017 Share Posted November 14, 2017 No problem! Link to comment https://wrobot.eu/forums/topic/7658-prioritize-low-hp-targets/#findComment-35008 Share on other sites More sharing options...
Seminko 41 Posted November 14, 2017 Share Posted November 14, 2017 2 hours ago, Lockem said: Going to try it out now, thanks a lot! Let us know if it works for you Lockem. Link to comment https://wrobot.eu/forums/topic/7658-prioritize-low-hp-targets/#findComment-35009 Share on other sites More sharing options...
Lockem 1 Posted November 14, 2017 Author Share Posted November 14, 2017 I noticed the typo too, seems to be working :D Link to comment https://wrobot.eu/forums/topic/7658-prioritize-low-hp-targets/#findComment-35010 Share on other sites More sharing options...
Seminko 41 Posted November 14, 2017 Share Posted November 14, 2017 good :) enjoy Link to comment https://wrobot.eu/forums/topic/7658-prioritize-low-hp-targets/#findComment-35012 Share on other sites More sharing options...
Lockem 1 Posted November 14, 2017 Author Share Posted November 14, 2017 @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! Link to comment https://wrobot.eu/forums/topic/7658-prioritize-low-hp-targets/#findComment-35013 Share on other sites More sharing options...
Seminko 41 Posted November 14, 2017 Share Posted November 14, 2017 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. Link to comment https://wrobot.eu/forums/topic/7658-prioritize-low-hp-targets/#findComment-35014 Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now