public static void HandleCastSpell(WorldSession session, ClientCastSpell castSpell)
        {
            Item item = session.Player.Inventory.GetItem(InventoryLocation.Ability, castSpell.BagIndex);

            if (item == null)
            {
                throw new InvalidPacketValueException();
            }

            UnlockedSpell spell = session.Player.SpellManager.GetSpell(item.Id);

            if (spell == null)
            {
                throw new InvalidPacketValueException();
            }

            // true is button pressed, false is sent on release
            if (!castSpell.ButtonPressed)
            {
                return;
            }

            byte tier = session.Player.SpellManager.GetSpellTier(spell.Info.Entry.Id);

            session.Player.CastSpell(new SpellParameters
            {
                SpellInfo = spell.Info.GetSpellInfo(tier)
            });
        }
Exemple #2
0
        public static void HandlePlayerCastSpell(WorldSession session, ClientCastSpell castSpell)
        {
            Item item = session.Player.Inventory.GetItem(InventoryLocation.Ability, castSpell.BagIndex);

            if (item == null)
            {
                throw new InvalidPacketValueException();
            }

            UnlockedSpell spell = session.Player.SpellManager.GetSpell(item.Id);

            if (spell == null)
            {
                throw new InvalidPacketValueException();
            }

            // true is probably "begin casting"
            if (!castSpell.Unknown48)
            {
                return;
            }

            session.Player.CastSpell(new SpellParameters
            {
                SpellInfo = spell.Info.GetSpellInfo(spell.Tier)
            });
        }
Exemple #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)
        {
            Spell4BaseEntry entry = GameTableManager.Spell4Base.GetEntry(spell4BaseId);

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

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

            // TODO: validate tier

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

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

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

            spells.Add(entry.Id, unlockedSpell);
        }
Exemple #4
0
        public static void HandleClientSummonVanityPet(WorldSession session, ClientSummonVanityPet summonVanityPet)
        {
            UnlockedSpell spell = session.Player.SpellManager.GetSpell(summonVanityPet.Spell4BaseId);

            if (spell == null)
            {
                throw new InvalidPacketValueException();
            }

            byte tier = session.Player.SpellManager.GetSpellTier(spell.Info.Entry.Id);

            session.Player.CastSpell(new SpellParameters
            {
                SpellInfo = spell.Info.GetSpellInfo(tier)
            });
        }
        public static void HandleCastSpell(WorldSession session, Client009A castSpell)
        {
            Item item = session.Player.Inventory.GetItem(InventoryLocation.Ability, castSpell.BagIndex);

            if (item == null)
            {
                throw new InvalidPacketValueException();
            }

            UnlockedSpell spell = session.Player.SpellManager.GetSpell(item.Id);

            if (spell == null)
            {
                throw new InvalidPacketValueException();
            }

            byte tier = session.Player.SpellManager.GetSpellTier(spell.Info.Entry.Id);

            session.Player.CastSpell(new SpellParameters
            {
                SpellInfo = spell.Info.GetSpellInfo(tier)
            });
        }
Exemple #6
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);
        }
Exemple #7
0
        public static void HandlePlayerCastSpell(WorldSession session, ClientCastSpell castSpell)
        {
            // the code in the function is temporary and just for a bit of fun, it will be replaced when the underlying spell system is implemented
            Item item = session.Player.Inventory.GetItem(InventoryLocation.Ability, castSpell.BagIndex);

            if (item == null)
            {
                throw new InvalidPacketValueException();
            }

            UnlockedSpell spell = session.Player.SpellManager.GetSpell(item.Id);

            if (spell == null)
            {
                throw new InvalidPacketValueException();
            }

            // true is probably "begin casting"
            if (!castSpell.Unknown48)
            {
                return;
            }

            uint        castingId   = GlobalSpellManager.NextCastingId;
            Spell4Entry spell4Entry = GameTableManager.Spell4.Entries
                                      .SingleOrDefault(x => x.Spell4BaseIdBaseSpell == spell.Entry.Id && x.TierIndex == spell.Tier);

            session.Player.EnqueueToVisible(new ServerSpellStart
            {
                CastingId              = castingId,
                CasterId               = session.Player.Guid,
                PrimaryTargetId        = session.Player.Guid,
                Spell4Id               = spell4Entry.Id,
                RootSpell4Id           = spell4Entry.Id,
                ParentSpell4Id         = 0,
                FieldPosition          = new Position(session.Player.Position),
                UserInitiatedSpellCast = true
            }, true);

            var targetInfo = new ServerSpellGo.TargetInfo
            {
                UnitId        = session.Player.Guid, // FIXME: insert target
                TargetFlags   = 1,
                InstanceCount = 1,
                CombatResult  = 2
            };

            foreach (Spell4EffectsEntry spell4EffectEntry in GameTableManager.Spell4Effects.Entries
                     .Where(x => x.SpellId == spell4Entry.Id))
            {
                targetInfo.EffectInfoData.Add(new ServerSpellGo.TargetInfo.EffectInfo
                {
                    Spell4EffectId = spell4EffectEntry.Id,
                    EffectUniqueId = 4722,
                    TimeRemaining  = -1
                });
            }

            session.Player.EnqueueToVisible(new ServerSpellGo
            {
                ServerUniqueId     = castingId,
                PrimaryDestination = new Position(session.Player.Position),
                Phase          = 255,
                TargetInfoData = new List <ServerSpellGo.TargetInfo>
                {
                    targetInfo
                }
            }, true);
        }