Exemplo n.º 1
0
        /// <summary>
        ///     Casting Logic.
        /// </summary>
        public static void Casting(Spell.SpellBase spellBase, Obj_AI_Base target, bool enabled = true)
        {
            if (spellBase == null || target == null || !enabled)
            {
                return;
            }

            if (spellBase.DontWaste() && ModesManager.CurrentMode == ModesManager.Modes.LaneClear || ModesManager.CurrentMode == ModesManager.Modes.Harass)
            {
                return;
            }

            if (spellBase.IsDangerDash() && target.CountAllyHeros(1000) >= target.CountEnemyHeros(1000) && ModesManager.CurrentMode != ModesManager.Modes.LaneClear &&
                (target.PredictPosition().UnderEnemyTurret() && Misc.SafeToDive || !target.PredictPosition().UnderEnemyTurret()))
            {
                if (target.Position.IsSafe() && target.Position.SafeDive())
                {
                    spellBase.Cast(target);
                }
                return;
            }

            if (spellBase.IsDangerDash())
            {
                return;
            }

            if (spellBase.IsDash())
            {
                if (target.Distance(Player.Instance) > 400 && Player.Instance.PredictHealthPercent() > 50)
                {
                    var chargeable = spellBase as Spell.Chargeable;
                    if (chargeable != null)
                    {
                        if (!chargeable.IsCharging)
                        {
                            if (target.Position.IsSafe() && target.Position.SafeDive())
                            {
                                chargeable.StartCharging();
                            }
                            return;
                        }
                        if (chargeable.IsInRange(target))
                        {
                            if (target.Position.IsSafe() && target.Position.SafeDive())
                            {
                                chargeable.Cast(target);
                            }
                            return;
                        }
                        return;
                    }
                    var pos = target.PredictPosition().Extend(Player.Instance, 300).To3D();
                    if (pos.IsSafe() && pos.SafeDive())
                    {
                        spellBase.Cast(target.PredictPosition().Extend(Player.Instance, 300).To3D());
                    }
                }
                else
                {
                    var pos = Player.Instance.ServerPosition.Extend(ObjectsManager.AllySpawn, 300).To3D();
                    if (pos.IsSafe() && pos.SafeDive())
                    {
                        spellBase.Cast(pos);
                    }
                }
                return;
            }

            if (spellBase.IsToggle())
            {
                if (spellBase is Spell.Active)
                {
                    if (spellBase.Handle.ToggleState != 2 && target.IsValidTarget(spellBase.Range))
                    {
                        spellBase.Cast();
                        return;
                    }
                    if (spellBase.Handle.ToggleState == 2 && !target.IsValidTarget(spellBase.Range))
                    {
                        spellBase.Cast();
                        return;
                    }
                }
                else
                {
                    if (spellBase.Handle.ToggleState != 2 && target.IsValidTarget(spellBase.Range))
                    {
                        spellBase.Cast(target);
                        return;
                    }
                    if (spellBase.Handle.ToggleState == 2 && !target.IsValidTarget(spellBase.Range))
                    {
                        spellBase.Cast(Game.CursorPos);
                        return;
                    }
                }
            }

            if (spellBase is Spell.Active)
            {
                spellBase.Cast();
                return;
            }

            if ((spellBase is Spell.Skillshot || spellBase is Spell.Targeted || spellBase is Spell.Ranged) && !(spellBase is Spell.Chargeable))
            {
                spellBase.Cast(target);
                return;
            }

            if (spellBase is Spell.Chargeable)
            {
                var chargeable = spellBase as Spell.Chargeable;

                if (!chargeable.IsCharging)
                {
                    chargeable.StartCharging();
                    return;
                }
                if (chargeable.IsInRange(target))
                {
                    chargeable.Cast(target);
                }
            }
        }