Esempio n. 1
0
        public static bool Cast(Ability ability, Unit target, string name)
        {
            if (ability.IsAbilityBehavior(AbilityBehavior.UnitTarget, name))
            {
                Game.ExecuteCommand("dota_player_units_auto_attack_after_spell 0");
                ManageAutoAttack.AutoAttackDisabled = true;
                SoulRing.Cast(ability);
                ability.UseAbility(target);
                return(true);
            }

            if ((ability.IsAbilityBehavior(AbilityBehavior.AreaOfEffect, name) ||
                 ability.IsAbilityBehavior(AbilityBehavior.Point, name)) &&
                (Prediction.StraightTime(target) > 1000 || target.MovementSpeed < 200))
            {
                Game.ExecuteCommand("dota_player_units_auto_attack_after_spell 0");
                ManageAutoAttack.AutoAttackDisabled = true;
                return(ability.CastSkillShot(target, name, SoulRing.Check(ability) ? MyAbilities.SoulRing : null));
            }

            if (ability.IsAbilityBehavior(AbilityBehavior.NoTarget, name))
            {
                SoulRing.Cast(ability);
                Game.ExecuteCommand("dota_player_units_auto_attack_after_spell 0");
                ManageAutoAttack.AutoAttackDisabled = true;
                ability.UseAbility();
                return(true);
            }

            return(false);
        }
Esempio n. 2
0
        public static bool Cast(Ability ability, Unit target, string name)
        {
            if (name == "item_tango" || name == "item_tango_single")
            {
                if (!target.Equals(AbilityMain.Me))
                {
                    return(false);
                }

                var closestTree =
                    ObjectMgr.GetEntities <Tree>()
                    .Where(x => x.IsAlive && x.IsVisible && x.Distance2D(target) < 250)
                    .MinOrDefault(x => x.Distance2D(target));
                if (closestTree == null)
                {
                    return(false);
                }

                //Console.WriteLine(closestTree);
                //ability.UseAbility(closestTree);
                //Player.UseAbility(target, ability, closestTree);
                return(true);
            }

            if (ability.IsAbilityBehavior(AbilityBehavior.NoTarget, name))
            {
                Game.ExecuteCommand("dota_player_units_auto_attack_after_spell 1");
                ManageAutoAttack.AutoAttackDisabled = true;
                SoulRing.Cast(ability);
                ability.UseAbility();
                return(true);
            }

            if (name == "abaddon_death_coil" && target.Equals(AbilityMain.Me))
            {
                return(false);
            }

            SoulRing.Cast(ability);
            Game.ExecuteCommand("dota_player_units_auto_attack_after_spell 1");
            ManageAutoAttack.AutoAttackDisabled = true;
            ability.UseAbility(target);
            return(true);
        }
Esempio n. 3
0
 public static bool Cast(Ability ability, Unit target, string name)
 {
     if (ability.IsAbilityBehavior(AbilityBehavior.NoTarget, name))
     {
         Game.ExecuteCommand("dota_player_units_auto_attack_after_spell 0");
         ManageAutoAttack.AutoAttackDisabled = true;
         SoulRing.Cast(ability);
         ability.UseAbility();
         return(true);
     }
     if ((name == "item_solar_crest" || name == "item_medallion_of_courage") && target.Equals(AbilityMain.Me))
     {
         return(false);
     }
     SoulRing.Cast(ability);
     Game.ExecuteCommand("dota_player_units_auto_attack_after_spell 0");
     ManageAutoAttack.AutoAttackDisabled = true;
     ability.UseAbility(target);
     return(true);
 }
Esempio n. 4
0
 public static bool Cast(Ability ability, Unit target, string name)
 {
     if (name == "item_tango" || name == "item_tango_single")
     {
         return(false);
         //if (!target.Equals(AbilityMain.Me))
         //{
         //    return false;
         //}
         //var closestTree =
         //    ObjectMgr.GetEntities<Entity>()
         //        .Where(x => x.Name == "ent_dota_tree" && x.Distance2D(target) < 250)
         //        .MinOrDefault(x => x.Distance2D(target)) as Tree;
         //if (closestTree == null)
         //{
         //    return false;
         //}
         //Player.UseAbility(AbilityMain.Me,ability,closestTree);
         //ability.UseAbility(closestTree as Unit);
     }
     if (ability.IsAbilityBehavior(AbilityBehavior.NoTarget, name))
     {
         Game.ExecuteCommand("dota_player_units_auto_attack_after_spell 1");
         ManageAutoAttack.AutoAttackDisabled = true;
         SoulRing.Cast(ability);
         ability.UseAbility();
         return(true);
     }
     if (name == "abaddon_death_coil" && target.Equals(AbilityMain.Me))
     {
         return(false);
     }
     SoulRing.Cast(ability);
     Game.ExecuteCommand("dota_player_units_auto_attack_after_spell 1");
     ManageAutoAttack.AutoAttackDisabled = true;
     ability.UseAbility(target);
     return(true);
 }
Esempio n. 5
0
        public static bool Cast(Ability ability, Unit target, string name, bool disabled = false)
        {
            if (!disabled)
            {
                disabled = target.IsStunned() || target.IsRooted() || target.IsHexed() || target.IsInvul();
            }

            if (target.HasModifier("modifier_item_blade_mail_reflect") &&
                AbilityDamage.CalculateDamage(ability, AbilityMain.Me, target) > AbilityMain.Me.Health)
            {
                return(false);
            }

            if (target.HasModifier("modifier_nyx_assassin_spiked_carapace"))
            {
                return(false);
            }

            if (ability.Name == "sniper_assassinate")
            {
                if (AbilityMain.Me.Distance2D(target) <= AbilityMain.Me.GetAttackRange() + 100)
                {
                    return(false);
                }
            }

            if (ability.IsAbilityBehavior(AbilityBehavior.UnitTarget, name) && ability.Name != "lion_impale" &&
                ability.Name != "lina_dragon_slave")
            {
                if (target.IsLinkensProtected())
                {
                    if (!Utils.SleepCheck("AbilitySharp.CancelLinkens"))
                    {
                        return(false);
                    }

                    if (MyAbilities.Cyclone != null && MyAbilities.Cyclone.CanBeCasted())
                    {
                        MyAbilities.Cyclone.UseAbility(target);
                    }
                    else if (MyAbilities.ForceStaff != null && MyAbilities.ForceStaff.CanBeCasted())
                    {
                        MyAbilities.ForceStaff.UseAbility(target);
                    }

                    Utils.Sleep(1000, "AbilitySharp.CancelLinkens");

                    Game.ExecuteCommand("dota_player_units_auto_attack_mode 0");
                    ManageAutoAttack.AutoAttackDisabled = true;
                    SoulRing.Cast(ability);
                    ability.UseAbility(target, true);
                    return(false);
                }

                Game.ExecuteCommand("dota_player_units_auto_attack_mode 0");
                ManageAutoAttack.AutoAttackDisabled = true;
                SoulRing.Cast(ability);
                ability.UseAbility(target);
                DelayAction.Add(
                    new DelayActionItem(300, () => { AbilityMain.LaunchSnowball(); }, CancellationToken.None));
                return(true);
            }

            if ((ability.IsAbilityBehavior(AbilityBehavior.AreaOfEffect, name) ||
                 ability.IsAbilityBehavior(AbilityBehavior.Point, name)) &&
                (disabled ||
                 Prediction.StraightTime(target)
                 > Nukes.NukesMenuDictionary[name].Item(name + "minstraighttime").GetValue <Slider>().Value ||
                 target.MovementSpeed < 200))
            {
                if (AbilityMain.Me.ClassId == ClassId.CDOTA_Unit_Hero_Invoker && !ability.CanBeCasted())
                {
                    var invoked = ability.Invoke();
                    if (!invoked)
                    {
                        return(false);
                    }

                    DelayAction.Add(
                        Game.Ping * 2,
                        () =>
                    {
                        Game.ExecuteCommand("dota_player_units_auto_attack_mode 0");
                        ManageAutoAttack.AutoAttackDisabled = true;
                        var casted2 = ability.CastSkillShot(
                            target,
                            MyHeroInfo.Position,
                            name,
                            SoulRing.Check(ability) ? MyAbilities.SoulRing : null);
                        if (!casted2)
                        {
                            return;
                        }

                        if (!disabled && Utils.SleepCheck(ability.Handle.ToString()) &&
                            ability.GetCastDelay(AbilityMain.Me, target, true) * 1000 - Game.Ping > 0.1)
                        {
                            DelayAction.Add(
                                new DelayActionItem(
                                    (int)
                                    (ability.GetCastDelay(AbilityMain.Me, target, true) * 1000
                                     - Math.Max(50, Game.Ping)),
                                    () =>
                            {
                                if (Prediction.StraightTime(target)
                                    < (600
                                       + (ability.GetCastDelay(AbilityMain.Me, target, true) * 1000
                                          - Math.Max(50, Game.Ping))) && target.MovementSpeed > 200)
                                {
                                    AbilityMain.Me.Stop();
                                }
                            },
                                    CancellationToken.None));
                        }
                    });
                    Utils.Sleep((Game.Ping * 2) + 200, "cancelorder");
                    Utils.Sleep((Game.Ping * 2) + 200, ability.Handle.ToString());
                    Utils.Sleep((Game.Ping * 2) + 200, "casting");
                }

                Game.ExecuteCommand("dota_player_units_auto_attack_mode 0");
                ManageAutoAttack.AutoAttackDisabled = true;
                var casted = ability.CastSkillShot(
                    target,
                    MyHeroInfo.Position,
                    name,
                    SoulRing.Check(ability) ? MyAbilities.SoulRing : null);
                if (!casted)
                {
                    return(false);
                }

                if (!disabled && Utils.SleepCheck(ability.Handle.ToString()) &&
                    ability.GetCastDelay(AbilityMain.Me, target, true) * 1000 - Game.Ping > 0.1)
                {
                    DelayAction.Add(
                        new DelayActionItem(
                            (int)(ability.GetCastDelay(AbilityMain.Me, target, true) * 1000 - Math.Max(50, Game.Ping)),
                            () =>
                    {
                        if (Prediction.StraightTime(target)
                            < (600
                               + (ability.GetCastDelay(AbilityMain.Me, target, true) * 1000
                                  - Math.Max(50, Game.Ping))) && target.MovementSpeed > 200)
                        {
                            AbilityMain.Me.Stop();
                        }
                    },
                            CancellationToken.None));
                }

                return(true);
            }

            if (ability.IsAbilityBehavior(AbilityBehavior.NoTarget, name))
            {
                if (ability.Name == "templar_assassin_meld")
                {
                    if (
                        !(target.Distance2D(MyHeroInfo.Position)
                          < (AbilityMain.Me.GetAttackRange() + 50 + target.HullRadius + AbilityMain.Me.HullRadius)) ||
                        Orbwalking.AttackOnCooldown(target) || AbilityMain.Me.IsAttacking() ||
                        (target.Predict(Game.Ping).Distance2D(MyHeroInfo.Position)
                         > (AbilityMain.Me.GetAttackRange() + 50 + target.HullRadius + AbilityMain.Me.HullRadius)) ||
                        !Utils.SleepCheck("GlobalCasting"))
                    {
                        return(false);
                    }

                    Game.ExecuteCommand("dota_player_units_auto_attack_mode 0");
                    ManageAutoAttack.AutoAttackDisabled = true;
                    ability.UseAbility();
                    DelayAction.Add(
                        new DelayActionItem(
                            (int)ability.GetCastDelay(AbilityMain.Me, target) * 1000,
                            () => { AbilityMain.Me.Attack(target); },
                            CancellationToken.None));
                    Utils.Sleep(ability.GetCastDelay(AbilityMain.Me, target) * 1000, "GlobalCasting");
                    Utils.Sleep(ability.GetCastDelay(AbilityMain.Me, target) * 1000 + 200, "casting");
                    Utils.Sleep(ability.GetCastDelay(AbilityMain.Me, target) * 1000 + 200, "Ability.Move");
                    Utils.Sleep(ability.GetCastDelay(AbilityMain.Me, target) * 1000 + 200, "cancelorder");
                    return(true);
                }

                if (ability.Name.Contains("nevermore_shadowraze"))
                {
                    Game.ExecuteCommand("dota_player_units_auto_attack_mode 0");
                    ManageAutoAttack.AutoAttackDisabled = true;
                    return(ability.CastSkillShot(target, name));
                }

                SoulRing.Cast(ability);
                Game.ExecuteCommand("dota_player_units_auto_attack_mode 0");
                ManageAutoAttack.AutoAttackDisabled = true;
                ability.UseAbility();
                return(true);
            }

            return(false);
        }
Esempio n. 6
0
        public static bool Cast(Ability ability, Unit target, string name)
        {
            if (name == "razor_static_link" && target.Distance2D(AbilityMain.Me) > (ability.GetCastRange(name) * 0.75))
            {
                return(false);
            }

            if (ability.IsAbilityBehavior(AbilityBehavior.UnitTarget, name))
            {
                Game.ExecuteCommand("dota_player_units_auto_attack_mode 0");
                ManageAutoAttack.AutoAttackDisabled = true;
                SoulRing.Cast(ability);
                ability.UseAbility(target);
                return(true);
            }

            if ((ability.IsAbilityBehavior(AbilityBehavior.AreaOfEffect, name) ||
                 ability.IsAbilityBehavior(AbilityBehavior.Point, name)) &&
                (Prediction.StraightTime(target) > 1000 || target.MovementSpeed < 200))
            {
                Game.ExecuteCommand("dota_player_units_auto_attack_mode 0");
                ManageAutoAttack.AutoAttackDisabled = true;
                if (ability.ClassId == ClassId.CDOTA_Item_SentryWard)
                {
                    var sentry =
                        ObjectManager.GetEntities <Entity>()
                        .FirstOrDefault(
                            x =>
                            x.ClassId == ClassId.CDOTA_NPC_Observer_Ward_TrueSight && x.Distance2D(target) < 800);
                    if (sentry != null)
                    {
                        return(false);
                    }

                    var tower =
                        AllyTowers.Towers.FirstOrDefault(x => x.IsValid && x.IsAlive && x.Distance2D(target) < 800);
                    if (tower != null)
                    {
                        return(false);
                    }

                    tower = EnemyTowers.Towers.FirstOrDefault(x => x.IsValid && x.IsAlive && x.Distance2D(target) < 800);
                    if (tower != null)
                    {
                        return(false);
                    }
                }

                var casted = ability.CastSkillShot(target, name, SoulRing.Check(ability) ? MyAbilities.SoulRing : null);
                if (!casted)
                {
                    return(false);
                }

                if (ability.ClassId == ClassId.CDOTA_Item_SentryWard)
                {
                    Utils.Sleep(20000, ability.Handle.ToString());
                }

                return(true);
            }

            if (ability.IsAbilityBehavior(AbilityBehavior.NoTarget, name))
            {
                Game.ExecuteCommand("dota_player_units_auto_attack_mode 0");
                ManageAutoAttack.AutoAttackDisabled = true;
                SoulRing.Cast(ability);
                ability.UseAbility();
                return(true);
            }

            return(false);
        }
Esempio n. 7
0
 public static bool Cast(
     Ability ability,
     Unit target,
     Unit buffTarget,
     string name,
     List <Modifier> modifiers,
     bool togglearmlet = false)
 {
     if (name == "item_armlet")
     {
         if (buffTarget.Modifiers.Any(x => x.Name == "modifier_ice_blast"))
         {
             return(false);
         }
         if (!togglearmlet && buffTarget.Distance2D(target) > Math.Max(target.GetAttackRange(), 500))
         {
             return(false);
         }
         var armlettoggled = modifiers.Any(x => x.Name == "modifier_item_armlet_unholy_strength") &&
                             ability.IsToggled;
         Game.ExecuteCommand("dota_player_units_auto_attack_after_spell 0");
         ManageAutoAttack.AutoAttackDisabled = true;
         if (armlettoggled)
         {
             ability.ToggleAbility();
             ability.ToggleAbility();
             return(true);
         }
         ability.ToggleAbility();
         return(true);
     }
     if (!(buffTarget.Distance2D(target) < MyHeroInfo.AttackRange() + 150))
     {
         return(false);
     }
     SoulRing.Cast(ability);
     if (ability.Name == "templar_assassin_refraction")
     {
         var meld = AbilityMain.Me.Spellbook.Spell2;
         if (meld != null && meld.CanBeCasted())
         {
             if (
                 !(target.Distance2D(MyHeroInfo.Position)
                   < (AbilityMain.Me.GetAttackRange() + 50 + target.HullRadius + AbilityMain.Me.HullRadius)) ||
                 Orbwalking.AttackOnCooldown(target) || AbilityMain.Me.IsAttacking() ||
                 (target.Predict(Game.Ping).Distance2D(MyHeroInfo.Position)
                  > (AbilityMain.Me.GetAttackRange() + 50 + target.HullRadius + AbilityMain.Me.HullRadius)) ||
                 !Utils.SleepCheck("GlobalCasting"))
             {
                 return(false);
             }
             Game.ExecuteCommand("dota_player_units_auto_attack_after_spell 0");
             ManageAutoAttack.AutoAttackDisabled = true;
             ability.UseAbility();
             if (Nuke.Cast(meld, target, NameManager.Name(meld)))
             {
                 DelayAction.Add(
                     new DelayActionItem(
                         (int)meld.GetCastDelay(AbilityMain.Me, target) * 1000 + 100,
                         () =>
                 {
                     AbilityMain.Me.Attack(target);
                 },
                         CancellationToken.None));
             }
             Utils.Sleep(meld.GetCastDelay(AbilityMain.Me, target) * 1000, "GlobalCasting");
             Utils.Sleep(meld.GetHitDelay(target, name) * 1000 + 200, "casting");
             Utils.Sleep(meld.GetHitDelay(target, name) * 1000 + 200, ability.Handle.ToString());
             return(true);
         }
     }
     if (ability.IsAbilityBehavior(AbilityBehavior.NoTarget, name))
     {
         Game.ExecuteCommand("dota_player_units_auto_attack_after_spell 0");
         ManageAutoAttack.AutoAttackDisabled = true;
         ability.UseAbility();
         return(true);
     }
     Game.ExecuteCommand("dota_player_units_auto_attack_after_spell 0");
     ManageAutoAttack.AutoAttackDisabled = true;
     ability.UseAbility(buffTarget);
     return(true);
 }
Esempio n. 8
0
 public static bool Cast(Ability ability, Unit target, string name)
 {
     if (target.Modifiers.Any(x => x.Name == "modifier_item_blade_mail_reflect") &&
         AbilityDamage.CalculateDamage(ability, AbilityMain.Me, target) > AbilityMain.Me.Health)
     {
         return(false);
     }
     if (target.Modifiers.Any(x => x.Name == "modifier_nyx_assassin_spiked_carapace"))
     {
         return(false);
     }
     if (ability.Name == "sniper_assassinate")
     {
         if (AbilityMain.Me.Distance2D(target) <= AbilityMain.Me.GetAttackRange() + 100)
         {
             return(false);
         }
     }
     if (ability.IsAbilityBehavior(AbilityBehavior.UnitTarget, name) && ability.Name != "lion_impale")
     {
         Game.ExecuteCommand("dota_player_units_auto_attack_after_spell 0");
         ManageAutoAttack.AutoAttackDisabled = true;
         SoulRing.Cast(ability);
         if (name == "omniknight_purification")
         {
             ability.UseAbility(AbilityMain.Me);
         }
         ability.UseAbility(target);
         return(true);
     }
     if ((ability.IsAbilityBehavior(AbilityBehavior.AreaOfEffect, name) ||
          ability.IsAbilityBehavior(AbilityBehavior.Point, name)) &&
         (Prediction.StraightTime(target) > 1000 || target.MovementSpeed < 200))
     {
         Game.ExecuteCommand("dota_player_units_auto_attack_after_spell 0");
         ManageAutoAttack.AutoAttackDisabled = true;
         return(ability.CastSkillShot(target, name, SoulRing.Check(ability) ? MyAbilities.SoulRing : null));
     }
     if (ability.IsAbilityBehavior(AbilityBehavior.NoTarget, name))
     {
         if (ability.Name == "templar_assassin_meld")
         {
             if (
                 !(target.Distance2D(MyHeroInfo.Position)
                   < (AbilityMain.Me.GetAttackRange() + 50 + target.HullRadius + AbilityMain.Me.HullRadius)) ||
                 Orbwalking.AttackOnCooldown(target) || AbilityMain.Me.IsAttacking() ||
                 (target.Predict(Game.Ping).Distance2D(MyHeroInfo.Position)
                  > (AbilityMain.Me.GetAttackRange() + 50 + target.HullRadius + AbilityMain.Me.HullRadius)) ||
                 !Utils.SleepCheck("GlobalCasting"))
             {
                 return(false);
             }
             Game.ExecuteCommand("dota_player_units_auto_attack_after_spell 0");
             ManageAutoAttack.AutoAttackDisabled = true;
             ability.UseAbility();
             DelayAction.Add(
                 new DelayActionItem(
                     (int)ability.GetCastDelay(AbilityMain.Me, target) * 1000,
                     () =>
             {
                 AbilityMain.Me.Attack(target);
             },
                     CancellationToken.None));
             Utils.Sleep(ability.GetCastDelay(AbilityMain.Me, target) * 1000, "GlobalCasting");
             Utils.Sleep(ability.GetCastDelay(AbilityMain.Me, target) * 1000 + 200, "casting");
             Utils.Sleep(ability.GetCastDelay(AbilityMain.Me, target) * 1000 + 200, "Ability.Move");
             return(true);
         }
         if (ability.Name.Contains("nevermore_shadowraze"))
         {
             Game.ExecuteCommand("dota_player_units_auto_attack_after_spell 0");
             ManageAutoAttack.AutoAttackDisabled = true;
             return(ability.CastSkillShot(target, name));
         }
         SoulRing.Cast(ability);
         Game.ExecuteCommand("dota_player_units_auto_attack_after_spell 0");
         ManageAutoAttack.AutoAttackDisabled = true;
         ability.UseAbility();
         return(true);
     }
     return(false);
 }