private async Task ExecuteAsync(CancellationToken token) { try { if (Game.IsPaused) { return; } var Familiars = EntityManager<Unit>.Entities.Where(x => x.IsValid && x.IsAlive && x.IsControllable && x.IsAlly(Owner) && x.NetworkName == "CDOTA_Unit_VisageFamiliar").ToList(); var Others = EntityManager<Unit>.Entities.Where(x => !x.IsIllusion && x.IsValid && x.IsVisible && x.IsAlive && x.IsEnemy(Owner)).ToList(); foreach (var Familiar in Familiars) { var FamiliarsStoneForm = Familiar.GetAbilityById(AbilityId.visage_summon_familiars_stone_form); // Auto Stone Form if (Familiar.Health * 100 / Familiar.MaximumHealth <= Config.FamiliarsLowHPItem && CanBeCasted(FamiliarsStoneForm, Familiar)) { FamiliarsStoneForm.UseAbility(); await Await.Delay(GetDelay, token); } // Follow if (Config.FollowKeyItem) { Follow(Familiar, Owner); } // Courier if (Config.FamiliarsCourierItem) { var courier = Others.OrderBy(x => x.Distance2D(Familiar)).FirstOrDefault(x => x.NetworkName == "CDOTA_Unit_Courier"); if (courier != null && Familiar.Distance2D(courier) <= 600 && !Config.FollowKeyItem) { Attack(Familiar, courier); } } // Escape if (Config.EscapeKeyItem && !Config.ComboKeyItem && !Config.FamiliarsLockItem && !Config.LastHitItem && !Config.FollowKeyItem) { var hero = Others.OrderBy(x => x.Distance2D(Owner)).FirstOrDefault(x => x is Hero); if (hero == null || hero.IsMagicImmune() || hero.IsInvulnerable() || hero.HasModifier("modifier_winter_wyvern_winters_curse") || Owner.Distance2D(hero) > 800) { Follow(Familiar, Owner); continue; } if (CanBeCasted(FamiliarsStoneForm, Familiar) && Familiar.Distance2D(hero) <= 100 && !FamiliarsSleeper.Sleeping) { UseAbility(FamiliarsStoneForm, Familiar); FamiliarsSleeper.Sleep(FamiliarsStoneForm.GetAbilitySpecialData("stun_duration") * 1000 - 200); await Await.Delay(GetDelay, token); } else if (CanBeCasted(FamiliarsStoneForm, Familiar)) { Move(Familiar, hero.Position); } else { Follow(Familiar, Owner); } } } } catch (TaskCanceledException) { // canceled } catch (Exception e) { Config.Main.Log.Error(e); } }
private async Task ExecuteAsync(CancellationToken token) { try { if (Game.IsPaused) { return; } var Familiars = EntityManager <Unit> .Entities.Where(x => x.IsValid && x.IsAlive && x.IsControllable && !x.IsStunned() && x.IsAlly(Owner) && x.NetworkName == "CDOTA_Unit_VisageFamiliar").ToList(); if (Config.FamiliarsLockItem) { Target = Config.UpdateMode.FamiliarTarget; } else { Target = Config.UpdateMode.Target; } foreach (var Familiar in Familiars) { if (Target != null) { var FamiliarDamage = Familiar.Modifiers.Any(x => x.IsValid && x.StackCount > Config.FamiliarsChargeItem && x.Name == "modifier_visage_summon_familiars_damage_charge"); var StunDebuff = Target.Modifiers.Any(x => x.IsValid && x.IsStunDebuff && x.RemainingTime > 0.5f); var HexDebuff = Target.Modifiers.Any(x => x.IsValid && x.RemainingTime > 0.5f && x.Name == "modifier_sheepstick_debuff"); var FamiliarsStoneForm = Familiar.GetAbilityById(AbilityId.visage_summon_familiars_stone_form); if (!Target.IsMagicImmune() && !Target.IsInvulnerable() && !Target.HasModifier("modifier_winter_wyvern_winters_curse")) { // FamiliarsStoneForm if (Config.AbilityToggler.Value.IsEnabled(FamiliarsStoneForm.Name) && CanBeCasted(FamiliarsStoneForm, Familiar) && Familiar.Distance2D(Target) <= 100 && !StunDebuff && !HexDebuff && (!Config.FamiliarsStoneControlItem || SmartStone(Target) || !FamiliarDamage) && !FamiliarsSleeper.Sleeping) { UseAbility(FamiliarsStoneForm, Familiar); FamiliarsSleeper.Sleep(FamiliarsStoneForm.GetAbilitySpecialData("stun_duration") * 1000 - 200); await Await.Delay(GetDelay); } } if (Target.IsInvulnerable() || Target.IsAttackImmune()) { Move(Familiar, Target.Position); } else if (Config.FamiliarsStoneControlItem && FamiliarDamage && !SmartStone(Target)) { Attack(Familiar, Target); } else if ((Target.IsMagicImmune() || !CanBeCasted(FamiliarsStoneForm, Familiar)) || (StunDebuff || HexDebuff)) { Attack(Familiar, Target); } else { Move(Familiar, Target.Position); } } else { if (Config.FamiliarsFollowItem) { Move(Familiar, Game.MousePosition); } else { Follow(Familiar, Owner); } } } } catch (TaskCanceledException) { // canceled } catch (Exception e) { Config.Main.Log.Error(e); } }