Beispiel #1
0
        public Asda2MountRecord(MountTemplate mount, Character owner)
        {
            Guid = (int)IdGenerator.Next();

            Id      = mount.Id;
            OwnerId = owner.EntityId.Low;
        }
Beispiel #2
0
        public static void RegisterVeicheRequest(IRealmClient client, RealmPacketIn packet)
        {
            packet.ReadInt32();
            int       num          = (int)packet.ReadByte();
            short     slotInq      = packet.ReadInt16();
            Asda2Item shopShopItem = client.ActiveCharacter.Asda2Inventory.GetShopShopItem(slotInq);

            if (shopShopItem == null)
            {
                Asda2MountHandler.SendVeicheRegisteredResponse(client.ActiveCharacter, (Asda2Item)null,
                                                               Asda2MountHandler.RegisterMountStatus.Fail, -1);
                client.ActiveCharacter.SendInfoMsg("Mount item not fount. Restart client please.");
            }
            else
            {
                MountTemplate mount = (MountTemplate)null;
                if (Asda2MountMgr.TemplatesByItemIDs.ContainsKey(shopShopItem.ItemId))
                {
                    mount = Asda2MountMgr.TemplatesByItemIDs[shopShopItem.ItemId];
                }
                if (mount == null)
                {
                    Asda2MountHandler.SendVeicheRegisteredResponse(client.ActiveCharacter, (Asda2Item)null,
                                                                   Asda2MountHandler.RegisterMountStatus.Fail, -1);
                    client.ActiveCharacter.SendInfoMsg("Selected item is not mount.");
                }
                else if (client.ActiveCharacter.OwnedMounts.ContainsKey(mount.Id))
                {
                    Asda2MountHandler.SendVeicheRegisteredResponse(client.ActiveCharacter, (Asda2Item)null,
                                                                   Asda2MountHandler.RegisterMountStatus.Fail, -1);
                    client.ActiveCharacter.SendInfoMsg("Selected mount already registered.");
                }
                else if ((int)client.ActiveCharacter.MountBoxSize <= client.ActiveCharacter.OwnedMounts.Count)
                {
                    Asda2MountHandler.SendVeicheRegisteredResponse(client.ActiveCharacter, (Asda2Item)null,
                                                                   Asda2MountHandler.RegisterMountStatus.Fail, -1);
                    client.ActiveCharacter.SendInfoMsg("Not enoght space in mount inventory.");
                }
                else
                {
                    if (client.ActiveCharacter.OwnedMounts.ContainsKey(mount.Id))
                    {
                        return;
                    }
                    Asda2MountRecord asda2MountRecord = new Asda2MountRecord(mount, client.ActiveCharacter);
                    client.ActiveCharacter.OwnedMounts.Add(mount.Id, asda2MountRecord);
                    asda2MountRecord.Create();
                    shopShopItem.Amount = 0;
                    Asda2MountHandler.SendVeicheRegisteredResponse(client.ActiveCharacter, shopShopItem,
                                                                   Asda2MountHandler.RegisterMountStatus.Ok, mount.Id);
                }
            }
        }
        [PacketHandler(RealmServerOpCode.RegisterVeiche)] //6768
        public static void RegisterVeicheRequest(IRealmClient client, RealmPacketIn packet)
        {
            var veicheId = packet.ReadInt32(); //default : 175Len : 4
            var inv      = packet.ReadByte();  //default : 1Len : 1
            var slot     = packet.ReadInt16(); //default : 12Len : 2
            var item     = client.ActiveCharacter.Asda2Inventory.GetShopShopItem(slot);

            if (item == null)
            {
                SendVeicheRegisteredResponse(client.ActiveCharacter, null, RegisterMountStatus.Fail);
                client.ActiveCharacter.SendInfoMsg("Mount item not fount. Restart client please.");
                return;
            }
            MountTemplate templ = null;

            if (Asda2MountMgr.TemplatesByItemIDs.ContainsKey(item.ItemId))
            {
                templ = Asda2MountMgr.TemplatesByItemIDs[item.ItemId];
            }
            if (templ == null)
            {
                SendVeicheRegisteredResponse(client.ActiveCharacter, null, RegisterMountStatus.Fail);
                client.ActiveCharacter.SendInfoMsg("Selected item is not mount.");
                return;
            }
            if (client.ActiveCharacter.OwnedMounts.ContainsKey(templ.Id))
            {
                SendVeicheRegisteredResponse(client.ActiveCharacter, null, RegisterMountStatus.Fail);
                client.ActiveCharacter.SendInfoMsg("Selected mount already registered.");
                return;
            }
            if (client.ActiveCharacter.MountBoxSize <= client.ActiveCharacter.OwnedMounts.Count)
            {
                SendVeicheRegisteredResponse(client.ActiveCharacter, null, RegisterMountStatus.Fail);
                client.ActiveCharacter.SendInfoMsg("Not enoght space in mount inventory.");
                return;
            }
            if (client.ActiveCharacter.OwnedMounts.ContainsKey(templ.Id))
            {
                return;
            }
            var rec = new Asda2MountRecord(templ, client.ActiveCharacter);

            client.ActiveCharacter.OwnedMounts.Add(templ.Id, rec);
            rec.Create();
            item.Amount = 0;
            Asda2TitleChecker.OnNewMount(client.ActiveCharacter, item.ItemId);
            SendVeicheRegisteredResponse(client.ActiveCharacter, item,
                                         RegisterMountStatus.Ok, templ.Id);
        }