public UniversalHealOrb(HurtBox target, GameObject effectPrefab, Boolean useSkin, UInt32 skin, Vector3 origin, Single value, Single speed, HealType healType = HealType.Flat, HealTarget healTarget = HealTarget.Health) { base.target = target; base.origin = origin; this.effectPrefab = effectPrefab; this.value = value; this.speed = speed; this.healType = healType; this.healTarget = healTarget; this.useSkin = useSkin; this.skin = skin; }
public override async Task ExecuteAsync(CancellationToken token) { if (TargetSelector.IsActive) { this.Target = this.TargetSelector.Active.GetTargets().FirstOrDefault(x => !x.IsInvulnerable()); this.AllTargets = this.TargetSelector.Active.GetTargets().FirstOrDefault(); } var silenced = UnitExtensions.IsSilenced(this.Owner); var sliderValue = this.Config.UseBlinkPrediction.Item.GetValue <Slider>().Value; var myHpThreshold = this.Config.SelfHPDrain.Item.GetValue <Slider>().Value; var postDrainHp = this.Config.PostDrainHP.Item.GetValue <Slider>().Value; var allyPostDrain = this.Config.HealAllyTo.Item.GetValue <Slider>().Value; var healThreshold = this.Config.DrainHP.Item.GetValue <Slider>().Value; var wardTars = this.Config.WardTargets.Item.GetValue <Slider>().Value; //warnings if (myHpThreshold < postDrainHp && this.Config.AbilityToggler.Value.IsEnabled(this.Drain.Name)) { Log.Debug( "Post drain hp is higher than your hp threshold to begin healing, please change this or the script won't work."); return; } if (healThreshold > allyPostDrain && this.Config.AbilityToggler.Value.IsEnabled(this.Drain.Name)) { Log.Debug("Your ally's post heal threshold is lower than their heal threshold, please fix this."); return; } if (!silenced) { try { var tempHealTarget = EntityManager <Hero> .Entities.FirstOrDefault( x => x.IsAlive && x.Team == this.Owner.Team && x != Owner && !x.IsIllusion && ((float)x.Health / (float)x.MaximumHealth) * 100 < healThreshold && !UnitExtensions.IsMagicImmune(x)); float myHealth = (float)Owner.Health / (float)Owner.MaximumHealth * 100; if (tempHealTarget != null) { HealTarget = tempHealTarget; } if (HealTarget != null) { if (HealTarget != null && this.Config.AbilityToggler.Value.IsEnabled(this.Drain.Name) && !UnitExtensions.IsChanneling(Owner) && myHealth >= myHpThreshold && HealTarget.HealthPercent() * 100 < healThreshold) { this.Drain.UseAbility(HealTarget); IsHealing = true; await Await.Delay(GetAbilityDelay(HealTarget, Drain), token); } //Stop Healing; There is no hidden modifier/any way to check if we are healing a target. if ((UnitExtensions.IsChanneling(Owner) && myHealth <= postDrainHp) && IsHealing) { Owner.Stop(); IsHealing = false; } if (HealTarget != null && IsHealing && (HealTarget.HealthPercent() >= ((float)allyPostDrain / 100))) { Owner.Stop(); IsHealing = false; } if (HealTarget == null && IsHealing) { Owner.Stop(); IsHealing = false; } } } catch (Exception e) { Log.Debug($"{e}"); } } if ((this.BlinkDagger != null) && (this.BlinkDagger.Item.IsValid) && this.Target != null && Owner.Distance2D(this.Target) <= 1200 + sliderValue && !(Owner.Distance2D(this.Target) <= 400) && this.BlinkDagger.Item.CanBeCasted(this.Target) && this.Config.ItemToggler.Value.IsEnabled(this.BlinkDagger.Item.Name) && !UnitExtensions.IsChanneling(Owner)) { var l = (this.Owner.Distance2D(this.Target) - sliderValue) / sliderValue; var posA = this.Owner.Position; var posB = this.Target.Position; var x = (posA.X + (l * posB.X)) / (1 + l); var y = (posA.Y + (l * posB.Y)) / (1 + l); var position = new Vector3((int)x, (int)y, posA.Z); Log.Debug("Using BlinkDagger"); this.BlinkDagger.UseAbility(position); await Await.Delay(this.GetItemDelay(this.Target) + (int)Game.Ping, token); } if (!silenced && this.Target != null) { var targets = EntityManager <Hero> .Entities.Where( x => x.IsValid && x.Team != this.Owner.Team && !x.IsIllusion && !UnitExtensions.IsMagicImmune(x) && x.Distance2D(this.Owner) <= Ward.GetAbilityData("radius")) .ToList(); if (targets.Count >= wardTars && this.Ward.CanBeCasted() && this.Config.AbilityToggler.Value.IsEnabled(this.Ward.Name)) { Ward.UseAbility(Owner.NetworkPosition); await Await.Delay(GetAbilityDelay(Owner, Ward), token); } // var thresholdTars = this.Config.WardTargets.Item.GetValue<Slider>(); var manaDecrepify = Decrepify.GetManaCost(Decrepify.Level - 1); var manaBlast = Blast.GetManaCost(Blast.Level - 1); // var manaDrain = Drain.GetManaCost(Drain.Level - 1); if (this.Target != null) { try { if (Decrepify.CanBeCasted() && Decrepify.CanHit(this.Target) && this.Config.AbilityToggler.Value.IsEnabled(this.Decrepify.Name) && this.Owner.Mana >= manaBlast + manaDecrepify && !UnitExtensions.IsChanneling(Owner) && this.Target.IsAlive && this.Target != null) { this.Decrepify.UseAbility(this.Target); await Await.Delay(GetAbilityDelay(this.Target, Decrepify), token); } if (this.Blast.CanBeCasted() && this.Config.AbilityToggler.Value.IsEnabled(this.Blast.Name) && (!this.Decrepify.CanBeCasted() || manaBlast > Owner.Mana - manaDecrepify) && !UnitExtensions.IsChanneling(Owner) && this.Target.IsAlive && this.Target != null) { var delay = Blast.GetAbilityData("delay") * 1000; var blastTargets = EntityManager <Hero> .Entities.OrderBy(x => x == this.AllTargets).Where( x => x.IsValid && x.IsVisible && x.Team != Owner.Team && !x.IsIllusion && !UnitExtensions.IsMagicImmune(x)).ToList(); if (blastTargets == null) { return; } var input = new PredictionInput( Owner, this.Target, delay, float.MaxValue, 620, 400, PredictionSkillshotType.SkillshotCircle, true, blastTargets) { CollisionTypes = CollisionTypes.None }; var output = Prediction.GetPrediction(input); if (output.HitChance >= HitChance.Medium) { this.Blast.UseAbility(output.CastPosition); await Await.Delay(GetAbilityDelay(this.Target, this.Blast), token); } } if (this.Drain.CanBeCasted() && !this.Blast.CanBeCasted() && !this.Decrepify.CanBeCasted() && this.Config.AbilityToggler.Value.IsEnabled(this.Drain.Name) && !UnitExtensions.IsChanneling(Owner) && this.Target.IsAlive && this.Target != null) { this.Drain.UseAbility(this.Target); await Await.Delay(GetAbilityDelay(this.Target, Drain), token); } } catch (Exception e) { Log.Debug($"{e}"); } } } if (this.BloodThorn != null && this.BloodThorn.Item.IsValid && this.Target != null && this.BloodThorn.Item.CanBeCasted(this.Target) && this.Config.ItemToggler.Value.IsEnabled(this.BloodThorn.Item.Name)) { Log.Debug("Using Bloodthorn"); this.BloodThorn.UseAbility(this.Target); await Await.Delay(this.GetItemDelay(this.Target), token); } if ((this.SheepStick != null) && (this.SheepStick.Item.IsValid) && this.Target != null && this.SheepStick.Item.CanBeCasted(this.Target) && this.Config.ItemToggler.Value.IsEnabled("item_sheepstick")) { Log.Debug("Using Sheepstick"); this.SheepStick.UseAbility(this.Target); await Await.Delay(this.GetItemDelay(this.Target), token); } if (this.Dagon != null && this.Dagon.Item.IsValid && this.Target != null && this.Dagon.Item.CanBeCasted(this.Target) && this.Config.ItemToggler.Value.IsEnabled(Dagon5.Item.Name)) { Log.Debug("Using Dagon"); this.Dagon.UseAbility(this.Target); await Await.Delay(this.GetItemDelay(this.Target), token); } if (this.Orchid != null && this.Orchid.Item.IsValid && this.Target != null && this.Orchid.Item.CanBeCasted(this.Target) && this.Config.ItemToggler.Value.IsEnabled("item_orchid")) { Log.Debug("Using Orchid"); this.Orchid.UseAbility(this.Target); await Await.Delay(this.GetItemDelay(this.Target), token); } if (this.RodofAtos != null && this.RodofAtos.Item.IsValid && this.Target != null && this.RodofAtos.Item.CanBeCasted(this.Target) && this.Config.ItemToggler.Value.IsEnabled("item_rod_of_atos")) { Log.Debug("Using RodofAtos"); this.RodofAtos.UseAbility(this.Target); await Await.Delay(this.GetItemDelay(this.Target), token); } if (this.VeilofDiscord != null && this.VeilofDiscord.Item.IsValid && this.Target != null && this.VeilofDiscord.Item.CanBeCasted() && this.Config.ItemToggler.Value.IsEnabled("item_veil_of_discord")) { Log.Debug("Using VeilofDiscord"); this.VeilofDiscord.UseAbility(this.Target.Position); await Await.Delay(this.GetItemDelay(this.Target), token); } if (this.HurricanePike != null && this.HurricanePike.Item.IsValid && this.Target != null && this.HurricanePike.Item.CanBeCasted() && this.Config.ItemToggler.Value.IsEnabled("item_hurricane_pike")) { Log.Debug("Using HurricanePike"); this.HurricanePike.UseAbility(this.Target); await Await.Delay(this.GetItemDelay(this.Target), token); } if (this.ShivasGuard != null && this.ShivasGuard.Item.IsValid && this.Target != null && this.ShivasGuard.Item.CanBeCasted() && Owner.Distance2D(this.Target) <= 900 && this.Config.ItemToggler.Value.IsEnabled("item_shivas_guard")) { Log.Debug("Using Shiva's Guard"); this.ShivasGuard.UseAbility(); await Await.Delay((int)Game.Ping, token); } if (this.Mjollnir != null && this.Mjollnir.Item.IsValid && this.Target != null && this.Mjollnir.Item.CanBeCasted() && this.Config.ItemToggler.Value.IsEnabled("item_mjollnir")) { Log.Debug("Using Mjollnir"); this.Mjollnir.UseAbility(Owner); await Await.Delay(this.GetItemDelay(this.Target), token); } if (UnitExtensions.IsAttackImmune(this.Target) || this.Target.IsInvulnerable()) { return; } if (this.Orbwalker.OrbwalkTo(this.Target)) { return; } await Await.Delay(50, token); }