Ejemplo n.º 1
0
        public void HandleSpellAdd(ICommandContext context,
                                   [Parameter("Spell base id to add to character.")]
                                   uint spell4BaseId,
                                   [Parameter("Tier of the base spell to add to character.")]
                                   byte?tier)
        {
            tier ??= 1;

            SpellBaseInfo spellBaseInfo = GlobalSpellManager.Instance.GetSpellBaseInfo(spell4BaseId);

            if (spellBaseInfo == null)
            {
                context.SendMessage($"Invalid spell base id {spell4BaseId}!");
                return;
            }

            SpellInfo spellInfo = spellBaseInfo.GetSpellInfo(tier.Value);

            if (spellInfo == null)
            {
                context.SendMessage($"Invalid tier {tier.Value} for spell base id {spell4BaseId}!");
                return;
            }

            context.GetTargetOrInvoker <Player>().SpellManager.AddSpell(spell4BaseId, tier.Value);
        }
Ejemplo n.º 2
0
        public void HandleSpellCast(ICommandContext context,
                                    [Parameter("Spell base id to cast from target.")]
                                    uint spell4BaseId,
                                    [Parameter("Tier of the base spell to cast from target.")]
                                    byte?tier)
        {
            tier ??= 1;

            SpellBaseInfo spellBaseInfo = GlobalSpellManager.Instance.GetSpellBaseInfo(spell4BaseId);

            if (spellBaseInfo == null)
            {
                context.SendMessage($"Invalid spell base id {spell4BaseId}!");
                return;
            }

            SpellInfo spellInfo = spellBaseInfo.GetSpellInfo(tier.Value);

            if (spellInfo == null)
            {
                context.SendMessage($"Invalid tier {tier.Value} for spell base id {spell4BaseId}!");
                return;
            }

            context.GetTargetOrInvoker <UnitEntity>().CastSpell(spell4BaseId, tier.Value, new SpellParameters
            {
                UserInitiatedSpellCast = false
            });
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Add a new <see cref="UnlockedSpell"/> created from supplied spell base id and tier.
        /// </summary>
        public void AddSpell(uint spell4BaseId, byte tier = 1)
        {
            SpellBaseInfo spellBaseInfo = GlobalSpellManager.GetSpellBaseInfo(spell4BaseId);

            if (spellBaseInfo == null)
            {
                throw new ArgumentOutOfRangeException();
            }

            SpellInfo spellInfo = spellBaseInfo.GetSpellInfo(tier);

            if (spellInfo == null)
            {
                throw new ArgumentOutOfRangeException();
            }

            if (spells.ContainsKey(spell4BaseId))
            {
                throw new InvalidOperationException();
            }

            Item item = player.Inventory.SpellCreate(spellBaseInfo.Entry, 49);

            var unlockedSpell = new UnlockedSpell(spellBaseInfo, tier, item);

            if (!player.IsLoading)
            {
                player.Session.EnqueueMessageEncrypted(new ServerSpellUpdate
                {
                    Spell4BaseId = spell4BaseId,
                    TierIndex    = tier,
                    Activated    = true
                });
            }

            spells.Add(spellBaseInfo.Entry.Id, unlockedSpell);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Cast a <see cref="Spell"/> with the supplied spell base id, tier and <see cref="SpellParameters"/>.
        /// </summary>
        public void CastSpell(uint spell4BaseId, byte tier, SpellParameters parameters)
        {
            if (parameters == null)
            {
                throw new ArgumentNullException();
            }

            SpellBaseInfo spellBaseInfo = GlobalSpellManager.Instance.GetSpellBaseInfo(spell4BaseId);

            if (spellBaseInfo == null)
            {
                throw new ArgumentOutOfRangeException();
            }

            SpellInfo spellInfo = spellBaseInfo.GetSpellInfo(tier);

            if (spellInfo == null)
            {
                throw new ArgumentOutOfRangeException();
            }

            parameters.SpellInfo = spellInfo;
            CastSpell(parameters);
        }