Exemplo n.º 1
0
        public static void ExpandPetBoxRequest(IRealmClient client, RealmPacketIn packet)
        {
            ++packet.Position;
            short num = packet.ReadInt16();

            if (client.ActiveCharacter.Record.PetBoxEnchants > (byte)14)
            {
                FunctionalItemsHandler.SendPetBoxExpandedResponse(client,
                                                                  FunctionalItemsHandler.ExpandPetBoxStatus.Fail, num);
                client.ActiveCharacter.SendInfoMsg("Pet box expand for maximum 90 slots.");
            }
            else
            {
                Asda2Item shopShopItem = client.ActiveCharacter.Asda2Inventory.GetShopShopItem(num);
                if (shopShopItem == null)
                {
                    FunctionalItemsHandler.SendPetBoxExpandedResponse(client,
                                                                      FunctionalItemsHandler.ExpandPetBoxStatus.Fail, num);
                    client.ActiveCharacter.SendInfoMsg("Item not found restart client.");
                }
                else if (shopShopItem.Category != Asda2ItemCategory.ExpandPetBoxBy6)
                {
                    client.ActiveCharacter.YouAreFuckingCheater("Tryes to expand pet box with wrong item.", 50);
                }
                else
                {
                    --shopShopItem.Amount;
                    ++client.ActiveCharacter.Record.PetBoxEnchants;
                    FunctionalItemsHandler.SendPetBoxExpandedResponse(client,
                                                                      FunctionalItemsHandler.ExpandPetBoxStatus.Ok, num);
                }
            }
        }
Exemplo n.º 2
0
            public static bool AddItem(Character chr, Asda2ItemTemplate templ, int amount, Character triggerer)
            {
                int num = amount;
                Asda2PlayerInventory asda2Inventory      = chr.Asda2Inventory;
                Asda2Item            asda2Item           = (Asda2Item)null;
                Asda2InventoryError  asda2InventoryError = asda2Inventory.TryAdd((int)templ.ItemId, amount, false,
                                                                                 ref asda2Item, new Asda2InventoryType?(), (Asda2Item)null);

                if (asda2InventoryError != Asda2InventoryError.Ok || amount < num)
                {
                    if (asda2InventoryError != Asda2InventoryError.Ok)
                    {
                        Asda2InventoryHandler.SendItemReplacedResponse(chr.Client, Asda2InventoryError.NotInfoAboutItem,
                                                                       (short)0, (byte)0, 0, (short)0, 0, (byte)0, 0, (short)0, false);
                    }
                    return(false);
                }

                Log.Create(Log.Types.ItemOperations, LogSourceType.Character, chr.EntryId)
                .AddAttribute("source", 0.0, "created_by_gm").AddItemAttributes(asda2Item, "")
                .AddAttribute("map", (double)chr.MapId, chr.MapId.ToString())
                .AddAttribute("x", (double)chr.Asda2Position.X, "")
                .AddAttribute("y", (double)chr.Asda2Position.Y, "")
                .AddAttribute("gm", (double)triggerer.EntryId, triggerer.Name).Write();
                Asda2InventoryHandler.SendBuyItemResponse(Asda2BuyItemStatus.Ok, chr, new Asda2Item[5]
                {
                    asda2Item,
                    null,
                    null,
                    null,
                    null
                });
                return(true);
            }
Exemplo n.º 3
0
        public static void SendItemBuyedFromPrivateShopResponse(Character chr, PrivateShopBuyResult status,
                                                                List <Asda2Item> buyedItems)
        {
            Asda2Item[] asda2ItemArray = new Asda2Item[6];
            if (buyedItems != null)
            {
                for (int index = 0; index < buyedItems.Count; ++index)
                {
                    asda2ItemArray[index] = buyedItems[index];
                }
            }

            using (RealmPacketOut packet = new RealmPacketOut(RealmServerOpCode.ItemBuyedFromPrivateShop))
            {
                packet.WriteByte((byte)status);
                if (status == PrivateShopBuyResult.Ok)
                {
                    packet.WriteInt16(chr.Asda2Inventory.Weight);
                    packet.WriteInt32(chr.Money);
                    packet.WriteByte(buyedItems.Count <Asda2Item>((Func <Asda2Item, bool>)(i => i != null)));
                    for (int index = 0; index < 6; ++index)
                    {
                        Asda2InventoryHandler.WriteItemInfoToPacket(packet, asda2ItemArray[index], false);
                    }
                }

                chr.Send(packet, false);
            }
        }
Exemplo n.º 4
0
        public static void SendFaceOrHairChangedResponse(IRealmClient client, bool isHair, bool success = false,
                                                         Asda2Item usedItem = null)
        {
            using (RealmPacketOut packet = new RealmPacketOut(RealmServerOpCode.FaceOrHairChanged))
            {
                packet.WriteByte(success ? 1 : 0);
                packet.WriteByte(isHair ? 1 : 2);
                packet.WriteByte(client.ActiveCharacter.HairStyle);
                packet.WriteByte(client.ActiveCharacter.HairColor);
                packet.WriteByte(client.ActiveCharacter.Record.Face);
                packet.WriteInt32(client.ActiveCharacter.Asda2Inventory.Weight);
                packet.WriteInt32(client.ActiveCharacter.Money);
                Asda2InventoryHandler.WriteItemInfoToPacket(packet, usedItem, false);
                client.Send(packet, true);
                if (!success)
                {
                    return;
                }
                AchievementProgressRecord progressRecord =
                    client.ActiveCharacter.Achievements.GetOrCreateProgressRecord(9U);
                switch (++progressRecord.Counter)
                {
                case 50:
                    client.ActiveCharacter.DiscoverTitle(Asda2TitleId.Beautiful47);
                    break;

                case 100:
                    client.ActiveCharacter.GetTitle(Asda2TitleId.Beautiful47);
                    break;
                }

                progressRecord.SaveAndFlush();
            }
        }
Exemplo n.º 5
0
        public static void SendRegularTradeCompleteResponse(IRealmClient client, Asda2Item[] items)
        {
            using (RealmPacketOut packet = new RealmPacketOut(RealmServerOpCode.RegularTradeComplete))
            {
                packet.WriteByte(5);
                packet.WriteInt32(client.ActiveCharacter.Asda2Inventory.Weight);
                for (int index = 0; index < 5; ++index)
                {
                    Asda2Item asda2Item = items[index];
                    if (asda2Item == null)
                    {
                        packet.WriteInt32(-1);
                        packet.WriteByte(0);
                        packet.WriteInt16(-1);
                        packet.WriteInt32(0);
                        packet.WriteInt16(0);
                    }
                    else
                    {
                        packet.WriteInt32(asda2Item.ItemId);
                        packet.WriteByte((byte)asda2Item.InventoryType);
                        packet.WriteInt16(asda2Item.Slot);
                        packet.WriteInt32(asda2Item.Amount);
                        packet.WriteInt16(asda2Item.Weight);
                    }
                }

                client.Send(packet, false);
            }
        }
Exemplo n.º 6
0
            public static bool AddItem(Character chr, Asda2ItemTemplate templ, int amount, Character triggerer)
            {
                var actualAmount = amount;
                var inv          = chr.Asda2Inventory;

                // just add
                Asda2Item           item = null;
                Asda2InventoryError err  = inv.TryAdd((int)templ.ItemId, amount, false, ref item);

                if (err != Asda2InventoryError.Ok || amount < actualAmount)
                {
                    // something went wrong
                    if (err != Asda2InventoryError.Ok)
                    {
                        Asda2InventoryHandler.SendItemReplacedResponse(chr.Client);
                    }
                    return(false);
                }

                Log.Create(Log.Types.ItemOperations, LogSourceType.Character, chr.EntryId)
                .AddAttribute("source", 0, "created_by_gm")
                .AddItemAttributes(item)
                .AddAttribute("map", (double)chr.MapId, chr.MapId.ToString())
                .AddAttribute("x", chr.Asda2Position.X)
                .AddAttribute("y", chr.Asda2Position.Y)
                .AddAttribute("gm", triggerer.EntryId, triggerer.Name)
                .Write();
                Asda2InventoryHandler.SendBuyItemResponse(Asda2BuyItemStatus.Ok, chr, new[] { item, null, null, null, null });
                return(true);
            }
Exemplo n.º 7
0
 public static void SendFactionResetedResponse(IRealmClient client, bool ok, Asda2Item item)
 {
     using (var packet = new RealmPacketOut(RealmServerOpCode.FactionReseted)) //6705
     {
         packet.WriteByte(ok ? 1 : 0);                                         //{status}default value : 1 Len : 1
         Asda2InventoryHandler.WriteItemInfoToPacket(packet, item, true);
         client.Send(packet);
     }
 }
Exemplo n.º 8
0
 public static void SendFactionResetedResponse(IRealmClient client, bool ok, Asda2Item item)
 {
     using (RealmPacketOut packet = new RealmPacketOut(RealmServerOpCode.FactionReseted))
     {
         packet.WriteByte(ok ? 1 : 0);
         Asda2InventoryHandler.WriteItemInfoToPacket(packet, item, true);
         client.Send(packet, false);
     }
 }
Exemplo n.º 9
0
        internal void NotifyUsed(Asda2Item item)
        {
            var evt = Used;

            if (evt != null)
            {
                evt(item);
            }
        }
Exemplo n.º 10
0
        internal void NotifyUnequip(Asda2Item item)
        {
            var evt = Unequipped;

            if (evt != null)
            {
                evt(item);
            }
        }
Exemplo n.º 11
0
        private Asda2Item[] Transfer(IEnumerable <Asda2ItemTradeRef> items, Character rcvr)
        {
            Asda2Item[] asda2ItemArray = new Asda2Item[5];
            int         index          = 0;

            foreach (Asda2ItemTradeRef asda2ItemTradeRef in items)
            {
                if (asda2ItemTradeRef != null && asda2ItemTradeRef.Item != null)
                {
                    Asda2Item itemToCopyStats = asda2ItemTradeRef.Item;
                    if (itemToCopyStats.IsDeleted)
                    {
                        LogUtil.WarnException("Trying to add to {0} item {1} which is deleted", new object[2]
                        {
                            (object)rcvr.Name,
                            (object)itemToCopyStats
                        });
                    }
                    else if (itemToCopyStats.Record == null)
                    {
                        LogUtil.WarnException("Trying to add to {0} item {1} which record is null", new object[2]
                        {
                            (object)rcvr.Name,
                            (object)itemToCopyStats
                        });
                    }
                    else if (itemToCopyStats.ItemId == 20551)
                    {
                        if (!asda2ItemTradeRef.Item.OwningCharacter.SubtractMoney((uint)asda2ItemTradeRef.Amount))
                        {
                            asda2ItemTradeRef.Item.OwningCharacter.YouAreFuckingCheater(
                                "transfering items while not enoght money", 40);
                            asda2ItemTradeRef.Item.OwningCharacter.Money = 1U;
                        }
                        else
                        {
                            rcvr.AddMoney((uint)asda2ItemTradeRef.Amount);
                        }
                    }
                    else
                    {
                        if (itemToCopyStats.Amount < asda2ItemTradeRef.Amount || asda2ItemTradeRef.Amount <= 0)
                        {
                            asda2ItemTradeRef.Amount = itemToCopyStats.Amount;
                        }
                        Asda2Item asda2Item = (Asda2Item)null;
                        int       num       = (int)rcvr.Asda2Inventory.TryAdd((int)asda2ItemTradeRef.Item.Template.ItemId,
                                                                              asda2ItemTradeRef.Amount, false, ref asda2Item, new Asda2InventoryType?(), itemToCopyStats);
                        itemToCopyStats.Amount -= asda2ItemTradeRef.Amount;
                        asda2ItemArray[index]   = asda2Item;
                        ++index;
                    }
                }
            }

            return(asda2ItemArray);
        }
Exemplo n.º 12
0
        internal void NotifyEquip(Asda2Item item)
        {
            Action <Asda2Item> equipped = this.Equipped;

            if (equipped == null)
            {
                return;
            }
            equipped(item);
        }
Exemplo n.º 13
0
        internal void NotifyUnequip(Asda2Item item)
        {
            Action <Asda2Item> unequipped = this.Unequipped;

            if (unequipped == null)
            {
                return;
            }
            unequipped(item);
        }
Exemplo n.º 14
0
        internal void NotifyUsed(Asda2Item item)
        {
            Action <Asda2Item> used = this.Used;

            if (used == null)
            {
                return;
            }
            used(item);
        }
Exemplo n.º 15
0
 public static void StartDigRequest(IRealmClient client, RealmPacketIn packet)
 {
     if (client.ActiveCharacter.IsDigging)
     {
         client.ActiveCharacter.SendSystemMessage("You already digging.");
         SendStartDigResponseResponse(client, Asda2DigResult.DiggingFail);
     }
     else if (client.ActiveCharacter.IsInCombat || client.ActiveCharacter.IsMoving)
     {
         client.ActiveCharacter.SendSystemMessage("You can't dig while moving or fighting.");
         SendStartDigResponseResponse(client, Asda2DigResult.DiggingFail);
     }
     else
     {
         Asda2Item mainWeapon = client.ActiveCharacter.MainWeapon as Asda2Item;
         if (mainWeapon == null || mainWeapon.Category != Asda2ItemCategory.Showel)
         {
             SendStartDigResponseResponse(client, Asda2DigResult.YouHaveNoShowel);
         }
         else
         {
             Asda2Item asda2Item = client.ActiveCharacter.Asda2Inventory.Equipment[10];
             bool      flag      = asda2Item != null && asda2Item.Category == Asda2ItemCategory.DigOil;
             if ((flag
        ? (client.ActiveCharacter.MapId < (MapId)Asda2DigMgr.PremiumMapDiggingTemplates.Count
          ? 1
          : 0)
        : (client.ActiveCharacter.MapId < (MapId)Asda2DigMgr.MapDiggingTemplates.Count ? 1 : 0)) ==
                 0)
             {
                 client.ActiveCharacter.YouAreFuckingCheater(
                     "Trying to dig in unknown location : " + client.ActiveCharacter.MapId, 10);
                 SendStartDigResponseResponse(client, Asda2DigResult.DiggingFail);
             }
             else if ((flag
             ? Asda2DigMgr.PremiumMapDiggingTemplates[(byte)client.ActiveCharacter.MapId]
             : Asda2DigMgr.MapDiggingTemplates[(byte)client.ActiveCharacter.MapId]).MinLevel >
                      client.ActiveCharacter.Level)
             {
                 SendStartDigResponseResponse(client,
                                              Asda2DigResult.YouUnableToDigInThisLocationDueLowLevel);
             }
             else
             {
                 client.ActiveCharacter.CancelAllActions();
                 client.ActiveCharacter.IsDigging = true;
                 ++client.ActiveCharacter.Stunned;
                 client.ActiveCharacter.Map.CallDelayed(6000, () => Asda2DigMgr.ProcessDig(client));
                 Asda2CharacterHandler.SendEmoteResponse(client.ActiveCharacter, 110, 0, 0.0f,
                                                         0.0f);
                 SendStartDigResponseResponse(client, Asda2DigResult.Ok);
             }
         }
     }
 }
Exemplo n.º 16
0
        public static void SendShopTradeCompleteResponse(IRealmClient client, Asda2Item[] items)
        {
            using (RealmPacketOut packet = new RealmPacketOut(RealmServerOpCode.ShopTradeComplete))
            {
                packet.WriteByte(5);
                packet.WriteInt32(client.ActiveCharacter.Asda2Inventory.Weight);
                for (int index = 0; index < 5; ++index)
                {
                    Asda2Item asda2Item = items[index];
                    packet.WriteInt32(asda2Item == null ? 0 : asda2Item.ItemId);
                    packet.WriteByte(asda2Item == null ? (byte)0 : (byte)asda2Item.InventoryType);
                    packet.WriteInt16(asda2Item == null ? -1 : asda2Item.Slot);
                    packet.WriteInt16(asda2Item == null ? -1 : (asda2Item.IsDeleted ? -1 : 0));
                    packet.WriteByte(asda2Item == null ? -1 : asda2Item.Durability);
                    packet.WriteInt16(asda2Item == null ? -1 : asda2Item.Weight);
                    packet.WriteInt32(0);
                    packet.WriteByte(asda2Item == null ? -1 : asda2Item.Enchant);
                    packet.WriteByte(0);
                    packet.WriteByte(0);
                    packet.WriteByte(0);
                    packet.WriteByte(asda2Item == null ? -1 : asda2Item.SealCount);
                    packet.WriteInt16(asda2Item == null ? -1 : (short)asda2Item.Parametr1Type);
                    packet.WriteInt16(asda2Item == null ? -1 : asda2Item.Parametr1Value);
                    packet.WriteInt16(asda2Item == null ? -1 : (short)asda2Item.Parametr2Type);
                    packet.WriteInt16(asda2Item == null ? -1 : asda2Item.Parametr2Value);
                    packet.WriteInt16(asda2Item == null ? -1 : (short)asda2Item.Parametr3Type);
                    packet.WriteInt16(asda2Item == null ? -1 : asda2Item.Parametr3Value);
                    packet.WriteInt16(asda2Item == null ? -1 : (short)asda2Item.Parametr4Type);
                    if (asda2Item != null && asda2Item.Template.IsAvatar)
                    {
                        Asda2ItemTemplate template1 = Asda2ItemMgr.GetTemplate(asda2Item.Soul2Id);
                        Asda2ItemTemplate template2 = Asda2ItemMgr.GetTemplate(asda2Item.Soul3Id);
                        packet.WriteInt16(template1 == null ? -1 : template1.SowelBonusValue);
                        packet.WriteInt16(-1);
                        packet.WriteInt16(template2 == null ? -1 : template2.SowelBonusValue);
                    }
                    else
                    {
                        packet.WriteInt16(asda2Item == null ? -1 : asda2Item.Parametr4Value);
                        packet.WriteInt16(asda2Item == null ? -1 : (short)asda2Item.Parametr5Type);
                        packet.WriteInt16(asda2Item == null ? -1 : asda2Item.Parametr5Value);
                    }

                    packet.WriteByte(0);
                    packet.WriteItemAmount(asda2Item, false);
                    packet.WriteInt16(asda2Item == null ? -1 : asda2Item.Soul1Id);
                    packet.WriteInt16(asda2Item == null ? -1 : asda2Item.Soul2Id);
                    packet.WriteInt16(asda2Item == null ? -1 : asda2Item.Soul3Id);
                    packet.WriteInt16(asda2Item == null ? -1 : asda2Item.Soul4Id);
                }

                client.Send(packet, false);
            }
        }
Exemplo n.º 17
0
        public static void ResurectPetRequest(IRealmClient client, RealmPacketIn packet)
        {
            int   key     = packet.ReadInt32();
            int   num     = (int)packet.ReadByte();
            short slotInq = packet.ReadInt16();

            if (!client.ActiveCharacter.OwnedPets.ContainsKey(key))
            {
                client.ActiveCharacter.YouAreFuckingCheater("Trying to resurect not existing pet", 20);
            }
            else
            {
                Asda2Item regularItem = client.ActiveCharacter.Asda2Inventory.GetRegularItem(slotInq);
                if (regularItem == null)
                {
                    client.ActiveCharacter.YouAreFuckingCheater(
                        "Trying to resurect pet with not existint resurect item.", 10);
                }
                else
                {
                    Asda2PetRecord ownedPet = client.ActiveCharacter.OwnedPets[key];
                    if (regularItem.Category == Asda2ItemCategory.PetFoodMeat ||
                        regularItem.Category == Asda2ItemCategory.PetFoodVegetable ||
                        regularItem.Category == Asda2ItemCategory.PetFoodOil)
                    {
                        if (client.ActiveCharacter.Asda2Pet != null)
                        {
                            client.ActiveCharacter.Asda2Pet.Feed(regularItem.Template.ValueOnUse / 2);
                            regularItem.ModAmount(-1);
                            Asda2PetHandler.SendPetResurectedResponse(client, ownedPet, regularItem);
                        }
                        else
                        {
                            client.ActiveCharacter.SendInfoMsg("You must summon pet to feed.");
                        }
                    }
                    else if (regularItem.Category != Asda2ItemCategory.PetResurect)
                    {
                        client.ActiveCharacter.YouAreFuckingCheater("Trying to resurect pet with not a resurect item.",
                                                                    50);
                    }
                    else if (ownedPet.HungerPrc != (byte)0)
                    {
                        client.ActiveCharacter.YouAreFuckingCheater("Trying to resurect alive pet.", 50);
                    }
                    else
                    {
                        ownedPet.HungerPrc = (byte)5;
                        regularItem.ModAmount(-1);
                        Asda2PetHandler.SendPetResurectedResponse(client, ownedPet, regularItem);
                    }
                }
            }
        }
Exemplo n.º 18
0
 public static void SendMailItemTakedResponse(IRealmClient client, Asda2MailItemTakedStatus status,
                                              Asda2Item item)
 {
     using (RealmPacketOut packet = new RealmPacketOut(RealmServerOpCode.MailItemTaked))
     {
         packet.WriteByte((byte)status);
         packet.WriteInt16(client.ActiveCharacter.Asda2Inventory.Weight);
         packet.WriteInt32(client.ActiveCharacter.Money);
         Asda2InventoryHandler.WriteItemInfoToPacket(packet, item, false);
         client.Send(packet, true);
     }
 }
Exemplo n.º 19
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);
                }
            }
        }
Exemplo n.º 20
0
 /// <summary>
 /// Create a new MailMessage
 /// </summary>
 public Asda2MailMessage(string subject, string body, Asda2Item item, uint gold, uint recieverId, string senderName)
 {
     Subject    = subject;
     Body       = body;
     Item       = item;
     Gold       = gold;
     RecieverId = recieverId;
     ItemGuid   = item == null?-1: item.Record.Guid;
     SenderName = senderName;
     DeleteTime = DateTime.Now.AddDays(10);
     Guid       = NextId();
 }
Exemplo n.º 21
0
 /// <summary>Create a new MailMessage</summary>
 public Asda2MailMessage(string subject, string body, Asda2Item item, uint gold, uint recieverId,
                         string senderName)
 {
     this.Subject    = subject;
     this.Body       = body;
     this.Item       = item;
     this.Gold       = gold;
     this.RecieverId = recieverId;
     this.ItemGuid   = item == null ? -1L : item.Record.Guid;
     this.SenderName = senderName;
     this.DeleteTime = DateTime.Now.AddDays(10.0);
     this.Guid       = Asda2MailMessage.NextId();
 }
Exemplo n.º 22
0
 public static void SendVeicheRegisteredResponse(Character chr, Asda2Item veicheItem, RegisterMountStatus status,
                                                 int veicheId = -1)
 {
     using (var packet = new RealmPacketOut(RealmServerOpCode.VeicheRegistered)) //6769
     {
         packet.WriteByte((byte)status);                                         //{status}default value : 1 Len : 1
         packet.WriteInt32(chr.AccId);                                           //{accId}default value : 361343 Len : 4
         Asda2InventoryHandler.WriteItemInfoToPacket(packet, veicheItem);
         packet.WriteInt16(chr.Asda2Inventory.Weight);                           //{invWeight}default value : 11847 Len : 2
         packet.WriteInt32(veicheId);                                            //value name : unk4 default value : 56Len : 4
         chr.Send(packet);
     }
 }
Exemplo n.º 23
0
 public static void SendVeicheRegisteredResponse(Character chr, Asda2Item veicheItem,
                                                 Asda2MountHandler.RegisterMountStatus status, int veicheId = -1)
 {
     using (RealmPacketOut packet = new RealmPacketOut(RealmServerOpCode.VeicheRegistered))
     {
         packet.WriteByte((byte)status);
         packet.WriteInt32(chr.AccId);
         Asda2InventoryHandler.WriteItemInfoToPacket(packet, veicheItem, false);
         packet.WriteInt16(chr.Asda2Inventory.Weight);
         packet.WriteInt32(veicheId);
         chr.Send(packet, false);
     }
 }
Exemplo n.º 24
0
        public static void WriteItemAmount(this RealmPacketOut packet, Asda2Item item,
                                           bool setAmountTo0WhenDeleted = false)
        {
            int val = item != null
        ? (item.ItemId != 20551
          ? (!item.IsDeleted
            ? (item.Template.IsStackable ? item.Amount : 0)
            : (!setAmountTo0WhenDeleted ? -1 : 0))
          : (item.OwningCharacter != null ? (int)item.OwningCharacter.Money : item.Amount))
        : -1;

            packet.WriteInt32(val);
        }
Exemplo n.º 25
0
 public static void SendPetNameChangedResponse(IRealmClient client, Asda2PetNamehangeResult status,
                                               Asda2PetRecord pet, Asda2Item changeNameItem)
 {
     using (RealmPacketOut packet = new RealmPacketOut(RealmServerOpCode.PetNameChanged))
     {
         packet.WriteByte((byte)status);
         packet.WriteInt32(client.ActiveCharacter.AccId);
         packet.WriteInt32(pet == null ? 0 : pet.Guid);
         packet.WriteFixedAsciiString(pet == null ? "" : pet.Name, 16, Locale.Start);
         Asda2InventoryHandler.WriteItemInfoToPacket(packet, changeNameItem, false);
         client.Send(packet, true);
     }
 }
Exemplo n.º 26
0
        public static void SendCharacterRegularEquipmentInfoResponse(IRealmClient client, Character target)
        {
            using (RealmPacketOut packet = new RealmPacketOut(RealmServerOpCode.CharacterRegularEquipmentInfo))
            {
                packet.WriteInt32(target.AccId);
                for (int index = 0; index < 11; ++index)
                {
                    Asda2Item asda2Item = target.Asda2Inventory.Equipment[index];
                    Asda2InventoryHandler.WriteItemInfoToPacket(packet, asda2Item, false);
                }

                client.Send(packet, true);
            }
        }
Exemplo n.º 27
0
        public static void SendItemsBuyedFromAukResponse(IRealmClient client, List <Asda2ItemTradeRef> items)
        {
            using (RealmPacketOut packet = new RealmPacketOut(RealmServerOpCode.ItemsBuyedFromAuk))
            {
                int num = 0;
                foreach (Asda2ItemTradeRef asda2ItemTradeRef in items)
                {
                    Asda2Item asda2Item = asda2ItemTradeRef.Item;
                    if (num < 7)
                    {
                        packet.WriteInt32(asda2ItemTradeRef.Price);
                        packet.WriteSkip(Asda2AuctionHandler.stub4);
                        packet.WriteInt32(asda2Item.ItemId);
                        packet.WriteInt32(asda2ItemTradeRef.Amount);
                        packet.WriteByte((byte)asda2Item.InventoryType);
                        packet.WriteInt16(asda2Item.Slot);
                        packet.WriteInt16(asda2Item.Weight);
                        packet.WriteByte(asda2Item.Durability);
                        packet.WriteInt32(asda2Item.Enchant);
                        packet.WriteByte(0);
                        packet.WriteInt32(0);
                        packet.WriteInt16(0);
                        packet.WriteInt16(asda2Item.Record.Parametr1Type);
                        packet.WriteInt16(asda2Item.Parametr1Value);
                        packet.WriteInt16(asda2Item.Record.Parametr2Type);
                        packet.WriteInt16(asda2Item.Parametr2Value);
                        packet.WriteInt16(asda2Item.Record.Parametr3Type);
                        packet.WriteInt16(asda2Item.Parametr3Value);
                        packet.WriteInt16(asda2Item.Record.Parametr4Type);
                        packet.WriteInt16(asda2Item.Parametr4Value);
                        packet.WriteInt16(asda2Item.Record.Parametr5Type);
                        packet.WriteInt16(asda2Item.Parametr5Value);
                        packet.WriteByte(0);
                        packet.WriteInt32(asda2Item.AuctionPrice);
                        packet.WriteFixedAsciiString(client.ActiveCharacter.Name, 20, Locale.Start);
                        packet.WriteInt16(asda2Item.Soul1Id);
                        packet.WriteInt16(asda2Item.Soul2Id);
                        packet.WriteInt16(asda2Item.Soul3Id);
                        packet.WriteInt16(asda2Item.Soul4Id);
                        ++num;
                    }
                    else
                    {
                        break;
                    }
                }

                client.Send(packet, false);
            }
        }
Exemplo n.º 28
0
 public static void SendDigEndedResponse(IRealmClient client, bool success, Asda2Item item = null)
 {
     if (client == null || client.ActiveCharacter == null)
     {
         return;
     }
     using (var packet = new RealmPacketOut(RealmServerOpCode.DigEnded)) //5431
     {
         packet.WriteByte(success ? 1 : 0);                              //{status}default value : 1 Len : 1
         packet.WriteInt16(client.ActiveCharacter.SessionId);            //{sessId}default value : 32 Len : 2
         Asda2InventoryHandler.WriteItemInfoToPacket(packet, item, false);
         client.ActiveCharacter.SendPacketToArea(packet);
     }
 }
Exemplo n.º 29
0
        public static void SendCharacterPrivateShopInfoResponse(IRealmClient client,
                                                                Asda2ViewTradeShopInfoStatus infoStatus, Asda2PrivateShop shop)
        {
            using (RealmPacketOut packet = new RealmPacketOut(RealmServerOpCode.CharacterPrivateShopInfo))
            {
                packet.WriteByte((byte)infoStatus);
                if (infoStatus == Asda2ViewTradeShopInfoStatus.Ok)
                {
                    packet.WriteInt32(shop.Owner.AccId);
                    packet.WriteInt16(shop.Owner.SessionId);
                    packet.WriteByte(shop.ItemsCount);
                    packet.WriteFixedAsciiString(shop.Owner.Asda2TradeDescription, 50, Locale.Start);
                    packet.WriteFixedAsciiString(shop.Owner.Name, 20, Locale.Start);
                    for (int index = 0; index < 10; ++index)
                    {
                        Asda2Item asda2Item = shop.ItemsOnTrade[index] == null || shop.ItemsOnTrade[index].Item == null
                            ? (Asda2Item)null
                            : shop.ItemsOnTrade[index].Item;
                        packet.WriteInt32(asda2Item == null ? 0 : asda2Item.ItemId);
                        packet.WriteInt32(shop.ItemsOnTrade[index] == null ? -1 : shop.ItemsOnTrade[index].Amount);
                        packet.WriteByte(asda2Item == null ? 0 : (int)asda2Item.Durability);
                        packet.WriteInt16(asda2Item == null ? 0 : (int)asda2Item.Weight);
                        packet.WriteInt16(asda2Item == null ? 0 : asda2Item.Soul1Id);
                        packet.WriteInt16(asda2Item == null ? 0 : asda2Item.Soul2Id);
                        packet.WriteInt16(asda2Item == null ? 0 : asda2Item.Soul3Id);
                        packet.WriteInt16(asda2Item == null ? 0 : asda2Item.Soul4Id);
                        packet.WriteInt16(asda2Item == null ? 0 : (int)asda2Item.Enchant);
                        packet.WriteInt16(0);
                        packet.WriteByte(0);
                        packet.WriteInt16(asda2Item == null ? (short)0 : (short)asda2Item.Parametr1Type);
                        packet.WriteInt16(asda2Item == null ? 0 : (int)asda2Item.Parametr1Value);
                        packet.WriteInt16(asda2Item == null ? (short)0 : (short)asda2Item.Parametr2Type);
                        packet.WriteInt16(asda2Item == null ? 0 : (int)asda2Item.Parametr2Value);
                        packet.WriteInt16(asda2Item == null ? (short)0 : (short)asda2Item.Parametr3Type);
                        packet.WriteInt16(asda2Item == null ? 0 : (int)asda2Item.Parametr3Value);
                        packet.WriteInt16(asda2Item == null ? (short)0 : (short)asda2Item.Parametr4Type);
                        packet.WriteInt16(asda2Item == null ? 0 : (int)asda2Item.Parametr4Value);
                        packet.WriteInt16(asda2Item == null ? (short)0 : (short)asda2Item.Parametr5Type);
                        packet.WriteInt16(asda2Item == null ? 0 : (int)asda2Item.Parametr5Value);
                        packet.WriteByte(0);
                        packet.WriteInt32(shop.ItemsOnTrade[index] == null ? -1 : shop.ItemsOnTrade[index].Price);
                        packet.WriteInt32(asda2Item == null ? 0 : 264156);
                        packet.WriteInt16(asda2Item == null ? 0 : 1);
                    }
                }

                client.Send(packet, false);
            }
        }
Exemplo n.º 30
0
        [PacketHandler(RealmServerOpCode.ReciveFishingBookReward)]//6182
        public static void ReciveFishingBookRewardRequest(IRealmClient client, RealmPacketIn packet)
        {
            var bookNum      = (byte)packet.ReadInt32();//default : 0Len : 4
            var rewardItemId = packet.ReadInt32();

            if (!client.ActiveCharacter.RegisteredFishingBooks.ContainsKey(bookNum))
            {
                client.ActiveCharacter.YouAreFuckingCheater(
                    "Tryes to recive fish book reward from not registered book.", 80);
                return;
            }
            var book = client.ActiveCharacter.RegisteredFishingBooks[bookNum];

            if (!book.Template.Rewards.Contains(rewardItemId))
            {
                client.ActiveCharacter.YouAreFuckingCheater(
                    "Tryes to recive fish book reward that this book not contained.", 80);
                return;
            }
            var       indexOfRewardItem = Array.IndexOf(book.Template.Rewards, rewardItemId);
            Asda2Item rewItem           = null;

            var err = client.ActiveCharacter.Asda2Inventory.TryAdd(rewardItemId,
                                                                   book.Template.RewardAmounts[indexOfRewardItem
                                                                   ], true,
                                                                   ref rewItem);

            Log.Create(Log.Types.ItemOperations, LogSourceType.Character, client.ActiveCharacter.EntryId)
            .AddAttribute("source", 0, "fishing_book")
            .AddItemAttributes(rewItem)
            .Write();
            client.ActiveCharacter.Map.AddMessage(() =>
            {
                if (!book.IsComleted)
                {
                    client.ActiveCharacter.YouAreFuckingCheater(
                        "Tryes to recive fish book reward from not completed book.", 150);
                    return;
                }
                if (err != Asda2InventoryError.Ok)
                {
                    client.ActiveCharacter.SendInfoMsg("Can't recive reward cause " + err);
                    return;
                }
                book.ResetBook();
                SendFishingBookRewardRecivedResponse(client, GetFishingBookRewardStatus.Ok, rewItem, bookNum);
            });
        }