Exemple #1
0
        /// <summary>
        /// Build a network representation of the <see cref="ActionSetShortcut"/>'s in the <see cref="ActionSet"/>.
        /// </summary>
        public ServerActionSet BuildServerActionSet()
        {
            var serverActionSet = new ServerActionSet
            {
                Index    = Index,
                Unknown3 = 1,
                Result   = LimitedActionSetResult.Ok
            };

            for (UILocation i = 0; i < (UILocation)MaxActionCount; i++)
            {
                ActionSetShortcut action = GetShortcut(i);
                serverActionSet.Actions.Add(new ServerActionSet.Action
                {
                    ShortcutType = action?.ShortcutType ?? ShortcutType.None,
                    ObjectId     = action?.ObjectId ?? 0,
                    Location     = new ItemLocation
                    {
                        // TODO: this might not be correct, what about shortcuts that aren't spells?
                        Location = action != null ? InventoryLocation.Ability : (InventoryLocation)300, // no idea why 300, this is what retail did
                        BagIndex = (uint)(action?.Location ?? i)
                    }
                });
            }

            return(serverActionSet);
        }
Exemple #2
0
        public void SendInitialPackets()
        {
            foreach (Item spell in player.Inventory
                     .Where(b => b.Location == InventoryLocation.Ability)
                     .SelectMany(s => s))
            {
                player.Session.EnqueueMessageEncrypted(new ServerItemAdd
                {
                    InventoryItem = new InventoryItem
                    {
                        Item   = spell.BuildNetworkItem(),
                        Reason = 49
                    }
                });
            }

            var serverSpellList = new ServerSpellList();

            foreach ((uint spell4BaseId, UnlockedSpell spell) in spells)
            {
                serverSpellList.Spells.Add(new ServerSpellList.Spell
                {
                    Spell4BaseId      = spell4BaseId,
                    TierIndexAchieved = spell.Tier
                });
            }

            player.Session.EnqueueMessageEncrypted(serverSpellList);

            player.Session.EnqueueMessageEncrypted(new ServerAbilityPoints
            {
                AbilityPoints      = actionSets[activeActionSet].TierPoints,
                TotalAbilityPoints = ActionSet.MaxTierPoints
            });

            foreach (ActionSet actionSet in actionSets)
            {
                var serverActionSet = new ServerActionSet
                {
                    Index    = actionSet.Index,
                    Unknown3 = 1,
                    Unknown5 = 1
                };

                foreach (ActionSetAction action in actionSet)
                {
                    serverActionSet.Actions.Add(new ServerActionSet.Action
                    {
                        ShortcutType = action.ShortcutType,
                        ObjectId     = action.ObjectId,
                        Location     = new ItemLocation
                        {
                            Location = InventoryLocation.Ability,
                            BagIndex = (uint)action.Location
                        }
                    });
                }

                // initial action set packet requires all slots to be sent
                uint count = (uint)serverActionSet.Actions.Count;
                for (byte i = 0; i < ActionSet.MaxActionCount - count; i++)
                {
                    serverActionSet.Actions.Add(new ServerActionSet.Action
                    {
                        ShortcutType = 0,
                        ObjectId     = 0,
                        Location     = new ItemLocation
                        {
                            Location = (InventoryLocation)300, // no idea why 300, this is what retail did
                            BagIndex = count + i
                        }
                    });
                }

                player.Session.EnqueueMessageEncrypted(serverActionSet);
            }
        }