Jump to content

MultiTarget Rotation C# Trouble


RonSwanson

Recommended Posts

Hey guys been trying to figure out this Multi Target rotation but I cant figure it out!

 

I need help because my attempt failed but I will link it so other learn from my mistakes. THIS METHOD IS BROKEN :b

 

I need a method that does such: Detect if there is more then 1 mob aggroed to me and or my pet which I believe ObjectManager.GetNumberAttackPlayer() > 1 does that. The method needs have the pet attack each target that is attacking me to try and get aggro. Then I just need to cycle through the aggroed units casting my warlock dots on each one until each target is dead then if all of my dots are on each target then focus the target with the least amount of health, rinse and repeat. I plan on calling this method from my CombatRotation method unless there is a better way. All are welcome to help, thanks!

GUYS I SERIOUSLY NEED YOUR HELP (: @Droidz , @iMod 

 

 private WoWUnit target;

internal void MultiTargetRotation()
    {
        if (ObjectManager.GetNumberAttackPlayer() > 1)
        {
            var UnitToAttack = ObjectManager.GetUnitAttackPlayer().FirstOrDefault();
            if (UnitToAttack != null)
            {
                target = UnitToAttack;
                Lua.LuaDoString("PetAttack();");
                Logging.Write("PET ATTACKING");

            }
            
            //IF ALL THE MOBS ARE ATTACKING THE PET FOCUS THE LOWER HP ONE
            else
            {
                double LowerHP = ObjectManager.GetUnitAttackPlayer().Min(unit => unit.HealthPercent);
                var LowerHPUnit =
                    ObjectManager.GetUnitAttackPlayer().SingleOrDefault(unit => unit.HealthPercent == LowerHP);

                if (LowerHPUnit != null && LowerHPUnit.Guid != target.Guid)
                {
                    Logging.Write("WHATS GOING ON");
                    target = LowerHPUnit;

                }
                {

                }
            }
        }
    }

 

Link to comment
Share on other sites

No tested but use code like

    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);
                if (unitToAttack.IsMyTarget)
                    Lua.LuaDoString("PetAttack();");
                Logging.Write("PET ATTACKING: " + unitToAttack);
            }
        }
        //IF ALL THE MOBS ARE ATTACKING THE PET FOCUS THE LOWER HP ONE
        else
        {
            var unitsAttackPet = unitsAffectingMyCombat.Where(u => u != null && u.IsValid && u.IsTargetingMyPet).ToList();
            var lowerHpUnit = unitsAttackPet.OrderBy(unit => unit.HealthPercent).FirstOrDefault();
            if (lowerHpUnit != null && lowerHpUnit.IsValid && lowerHpUnit.IsAlive && !lowerHpUnit.IsMyPetTarget)
            {
                if (!lowerHpUnit.IsMyTarget)
                    Interact.InteractGameObject(lowerHpUnit.GetBaseAddress, !ObjectManager.Me.GetMove);
                if (lowerHpUnit.IsMyTarget)
                    Lua.LuaDoString("PetAttack();");
                Logging.Write("PET ATTACKING LOWER HP: " + lowerHpUnit);
            }
        }
    }

 

Link to comment
Share on other sites

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