Exemplo n.º 1
0
        /// <summary>
        /// Called when the character casts the spell
        /// </summary>
        public virtual bool Cast(float x, float y, float x2, float y2, IAttackableUnit u = null)
        {
            if (HasEmptyScript)
            {
                return(false);
            }
            if (Owner.IsCastingSpell)
            {
                return(false);
            }
            var stats = Owner.Stats;

            if (SpellData.ManaCost[Level] * (1 - stats.SpellCostReduction) >= stats.CurrentMana ||
                State != SpellState.STATE_READY)
            {
                return(false);
            }

            if (_game.Config.ManaCostsEnabled)
            {
                stats.CurrentMana = stats.CurrentMana - SpellData.ManaCost[Level] * (1 - stats.SpellCostReduction);
            }

            X                = x;
            Y                = y;
            X2               = x2;
            Y2               = y2;
            Target           = u;
            _futureProjNetId = _networkIdManager.GetNewNetId();
            Projectiles      = new Dictionary <uint, IProjectile>();
            SpellNetId       = _networkIdManager.GetNewNetId();

            if (SpellData.TargettingType == 1 && Target != null && Target.GetDistanceTo(Owner) > SpellData.CastRange[Level])
            {
                return(false);
            }
            if (RefItem != null)
            {
                DecraseStacks();
            }
            var newF = int.Parse(Convert.ToString(SpellData.Flags, 8));

            _spellGameScript.OnStartCasting(Owner, this, Target);
            if (SpellData.GetCastTime() > 0 && (SpellData.Flags & (int)SpellFlag.SPELL_FLAG_INSTANT_CAST) == 0)
            {
                Owner.SetPosition(Owner.X, Owner.Y); //stop moving serverside too. TODO: check for each spell if they stop movement or not
                State           = SpellState.STATE_CASTING;
                CurrentCastTime = SpellData.GetCastTime();
            }
            else
            {
                FinishCasting();
            }

            _game.PacketNotifier.NotifyNPC_CastSpellAns(_game.Map.NavigationGrid, this, new Vector2(x, y), new Vector2(x2, y2), _futureProjNetId);
            return(true);
        }
Exemplo n.º 2
0
        public void OnStartCasting(IChampion owner, ISpell spell, IAttackableUnit target)
        {
            _owningSpell = spell;

            spell.AddProjectileTarget("KatarinaQ", target);

            if (!_listenerAdded)
            {
                ApiEventManager.OnHitUnit.AddListener(this, _owningChampion, OnProc);
                _listenerAdded = true;
            }

            foreach (var enemyTarget in GetUnitsInRange(target, 625, true))
            {
                if (enemyTarget != null && enemyTarget.Team == CustomConvert.GetEnemyTeam(owner.Team) && enemyTarget != target && enemyTarget != owner && target.GetDistanceTo(enemyTarget) < 100 && !UnitIsTurret((AttackableUnit)enemyTarget))
                {
                    CreateTimer(3.0f, () => {
                        if (!(enemyTarget.IsDead))
                        {
                            AddParticle(owner, "katarina_bouncingBlades_mis.troy", enemyTarget.X, enemyTarget.Y);
                        }
                        spell.AddProjectileTarget("KatarinaQMark", enemyTarget);
                    });
                }
            }

            //WE NEED A TIMER ON THE Q TO BE FIXED
        }