Hello, for any1 who needs, I have implemented working polymorph offtarget with attacking poly after mainTarget is dead. Its quite reliable unsless there are 2 polyTargets - 2 mobs with same name and level pulled after mainTarget. If you guys could make a workaround, please share, but I will deffinitelly try to overcome it too (mby just run from them is a solution).
List<WoWUnit> attackers = ObjectManager.GetUnitAttackPlayer();
if (attackers.Count >= 2 && PolyMorph.KnownSpell)
{
FightEvents.OnFightLoop += (unit, cancelable) =>
{
WoWUnit mainTarget = attackers.Where(u => u.HealthPercent == attackers.Min(x => x.HealthPercent)).FirstOrDefault();
WoWUnit polyTarget = attackers.Where(u => u.HealthPercent == attackers.Max(x => x.HealthPercent)).FirstOrDefault();
if (!polyTarget.HaveBuff("Polymorph") && polyTarget != mainTarget && !ObjectManager.Me.IsDeadMe && !mainTarget.IsDead && !polyTarget.IsDead)
{
Interact.InteractGameObject(polyTarget.GetBaseAddress);
SpellManager.CastSpellByNameLUA("Polymorph");
Usefuls.WaitIsCasting();
Interact.InteractGameObject(mainTarget.GetBaseAddress);
}
else if (mainTarget.IsDead && !polyTarget.IsDead && !ObjectManager.Me.IsDeadMe)
{
Interact.InteractGameObject(polyTarget.GetBaseAddress);
SpellManager.CastSpellByIdLUA(116);
Thread.Sleep(500);
}
};
return;
}