Пример #1
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);
     }
 }
Пример #2
0
        public static void ChangePetNameRequest(IRealmClient client, RealmPacketIn packet)
        {
            int    key = packet.ReadInt32();
            string s   = packet.ReadAsdaString(16, Locale.Start);

            if (!Asda2EncodingHelper.IsPrueEnglish(s))
            {
                client.ActiveCharacter.SendOnlyEnglishCharactersAllowed("pet name");
                Asda2PetHandler.SendPetNameChangedResponse(client, Asda2PetNamehangeResult.AbnormalPetInfo,
                                                           (Asda2PetRecord)null, (Asda2Item)null);
            }
            else
            {
                ++packet.Position;
                short slotInq = packet.ReadInt16();
                if (!client.ActiveCharacter.OwnedPets.ContainsKey(key))
                {
                    client.ActiveCharacter.YouAreFuckingCheater("Trying to summon not existing pet.", 20);
                    Asda2PetHandler.SendPetNameChangedResponse(client, Asda2PetNamehangeResult.AbnormalPetInfo,
                                                               (Asda2PetRecord)null, (Asda2Item)null);
                }
                else
                {
                    Asda2PetRecord ownedPet     = client.ActiveCharacter.OwnedPets[key];
                    Asda2Item      shopShopItem = client.ActiveCharacter.Asda2Inventory.GetShopShopItem(slotInq);
                    if (!ownedPet.CanChangeName)
                    {
                        if (shopShopItem == null)
                        {
                            Asda2PetHandler.SendPetNameChangedResponse(client,
                                                                       Asda2PetNamehangeResult.YouMustHavePremiumItemToChangePetName, ownedPet,
                                                                       (Asda2Item)null);
                            return;
                        }

                        shopShopItem.ModAmount(-1);
                    }

                    ownedPet.Name          = s;
                    ownedPet.CanChangeName = false;
                    Asda2PetHandler.SendPetNameChangedResponse(client, Asda2PetNamehangeResult.Ok, ownedPet,
                                                               shopShopItem);
                    GlobalHandler.UpdateCharacterPetInfoToArea(client.ActiveCharacter);
                }
            }
        }
Пример #3
0
        public static void SummonPetRequest(IRealmClient client, RealmPacketIn packet)
        {
            int key = packet.ReadInt32();

            if (!client.ActiveCharacter.OwnedPets.ContainsKey(key))
            {
                client.ActiveCharacter.YouAreFuckingCheater("Trying to summon not existing pet.", 20);
                Asda2PetHandler.SendPetSummonOrUnSummondResponse(client, (Asda2PetRecord)null);
            }
            else
            {
                Asda2PetRecord ownedPet = client.ActiveCharacter.OwnedPets[key];
                if (ownedPet.HungerPrc == (byte)0)
                {
                    client.ActiveCharacter.YouAreFuckingCheater("Trying to summon dead pet.", 50);
                    Asda2PetHandler.SendPetSummonOrUnSummondResponse(client, (Asda2PetRecord)null);
                }
                else if (ownedPet.Template.MinimumUsingLevel > client.ActiveCharacter.Level)
                {
                    client.ActiveCharacter.SendInfoMsg("You cant summon pet with grade higher than your level.");
                    Asda2PetHandler.SendPetSummonOrUnSummondResponse(client, (Asda2PetRecord)null);
                }
                else if (client.ActiveCharacter.Asda2Pet != null)
                {
                    Asda2PetRecord asda2Pet = client.ActiveCharacter.Asda2Pet;
                    client.ActiveCharacter.Asda2Pet.RemoveStatsFromOwner();
                    client.ActiveCharacter.Asda2Pet = (Asda2PetRecord)null;
                    GlobalHandler.UpdateCharacterPetInfoToArea(client.ActiveCharacter);
                    Asda2PetHandler.SendPetSummonOrUnSummondResponse(client, asda2Pet);
                    Asda2CharacterHandler.SendUpdateStatsResponse(client);
                    Asda2CharacterHandler.SendUpdateStatsOneResponse(client);
                }
                else
                {
                    client.ActiveCharacter.Asda2Pet = ownedPet;
                    client.ActiveCharacter.Asda2Pet.AddStatsToOwner();
                    client.ActiveCharacter.LastPetExpGainTime = (uint)(Environment.TickCount + 60000);
                    GlobalHandler.UpdateCharacterPetInfoToArea(client.ActiveCharacter);
                    Asda2CharacterHandler.SendUpdateStatsResponse(client);
                    Asda2CharacterHandler.SendUpdateStatsOneResponse(client);
                    Asda2PetHandler.SendPetSummonOrUnSummondResponse(client, ownedPet);
                }
            }
        }