예제 #1
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);
                }
            }
        }
예제 #2
0
        [PacketHandler(RealmServerOpCode.SummonPet)]//6100
        public static void SummonPetRequest(IRealmClient client, RealmPacketIn packet)
        {
            var petGuid = packet.ReadInt32();//default : 54857Len : 4

            if (!client.ActiveCharacter.OwnedPets.ContainsKey(petGuid))
            {
                client.ActiveCharacter.YouAreFuckingCheater("Trying to summon not existing pet.", 20);
                SendPetSummonOrUnSummondResponse(client, null);
                return;
            }
            var pet = client.ActiveCharacter.OwnedPets[petGuid];

            if (pet.HungerPrc == 0)
            {
                client.ActiveCharacter.YouAreFuckingCheater("Trying to summon dead pet.", 50);
                SendPetSummonOrUnSummondResponse(client, null);
                return;
            }
            if (pet.Template.MinimumUsingLevel > client.ActiveCharacter.Level)
            {
                client.ActiveCharacter.SendInfoMsg("You cant summon pet with grade higher than your level.");
                SendPetSummonOrUnSummondResponse(client, null);
                return;
            }
            if (client.ActiveCharacter.Asda2Pet != null)
            {
                pet = client.ActiveCharacter.Asda2Pet;
                client.ActiveCharacter.Asda2Pet.RemoveStatsFromOwner();
                client.ActiveCharacter.Asda2Pet = null;
                GlobalHandler.UpdateCharacterPetInfoToArea(client.ActiveCharacter);
                SendPetSummonOrUnSummondResponse(client, pet);

                Asda2CharacterHandler.SendUpdateStatsResponse(client);
                Asda2CharacterHandler.SendUpdateStatsOneResponse(client);
                return;
            }
            client.ActiveCharacter.Asda2Pet = pet;
            client.ActiveCharacter.Asda2Pet.AddStatsToOwner();
            client.ActiveCharacter.LastPetExpGainTime = (uint)Environment.TickCount + 60000;
            GlobalHandler.UpdateCharacterPetInfoToArea(client.ActiveCharacter);

            Asda2CharacterHandler.SendUpdateStatsResponse(client);
            Asda2CharacterHandler.SendUpdateStatsOneResponse(client);
            SendPetSummonOrUnSummondResponse(client, pet);
        }
예제 #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);
                }
            }
        }
예제 #4
0
        [PacketHandler(RealmServerOpCode.ChangePetName)]//6118
        public static void ChangePetNameRequest(IRealmClient client, RealmPacketIn packet)
        {
            var petGuid = packet.ReadInt32();                   //default : 54857Len : 4
            var petName = packet.ReadAsdaString(16, Locale.En); //default : Len : 17

            /*var isPruEng = Asda2EncodingHelper.IsPrueEnglish(petName);
             * if (!isPruEng)
             * {
             *  client.ActiveCharacter.SendOnlyEnglishCharactersAllowed("pet name");
             *  SendPetNameChangedResponse(client, Asda2PetNamehangeResult.AbnormalPetInfo, null, null);
             *  return;
             * }*/
            packet.Position += 1;
            var petCertSlot = packet.ReadInt16();

            if (!client.ActiveCharacter.OwnedPets.ContainsKey(petGuid))
            {
                client.ActiveCharacter.YouAreFuckingCheater("Trying to summon not existing pet.", 20);
                SendPetNameChangedResponse(client, Asda2PetNamehangeResult.AbnormalPetInfo, null, null);
                return;
            }
            var pet = client.ActiveCharacter.OwnedPets[petGuid];

            var changeNameItem = client.ActiveCharacter.Asda2Inventory.GetShopShopItem(petCertSlot);

            if (!pet.CanChangeName)
            {
                if (changeNameItem == null)
                {
                    SendPetNameChangedResponse(client, Asda2PetNamehangeResult.YouMustHavePremiumItemToChangePetName,
                                               pet, null);
                    return;
                }
                changeNameItem.ModAmount(-1);
            }
            pet.Name          = petName;
            pet.CanChangeName = false;
            SendPetNameChangedResponse(client, Asda2PetNamehangeResult.Ok, pet, changeNameItem);
            GlobalHandler.UpdateCharacterPetInfoToArea(client.ActiveCharacter);
        }
예제 #5
0
        public bool GainXp(int i)
        {
            if (Level == 10)
            {
                return(false);
            }
            int num = Asda2PetMgr.ExpTable[Template.Rank][Template.Rarity][Level - 1];

            if (Level == MaxLevel && Expirience >= num)
            {
                Expirience = (short)num;
                return(false);
            }

            Expirience += (short)i;
            if (Level == MaxLevel)
            {
                if (Expirience > num)
                {
                    Expirience = (short)num;
                }
                Asda2PetHandler.SendUpdatePetExpResponse(Owner.Client, this, false);
                return(true);
            }

            if (Expirience > num)
            {
                RemoveStatsFromOwner();
                ++Level;
                AddStatsToOwner();
                Asda2CharacterHandler.SendUpdateStatsResponse(Owner.Client);
                Asda2CharacterHandler.SendUpdateStatsOneResponse(Owner.Client);
                GlobalHandler.UpdateCharacterPetInfoToArea(Owner);
                Asda2PetHandler.SendUpdatePetHungerResponse(Owner.Client, this);
            }

            Asda2PetHandler.SendUpdatePetExpResponse(Owner.Client, this, true);
            return(true);
        }
예제 #6
0
        public bool GainXp(int i)
        {
            if (this.Level == (byte)10)
            {
                return(false);
            }
            int num = Asda2PetMgr.ExpTable[this.Template.Rank][this.Template.Rarity][(int)this.Level - 1];

            if ((int)this.Level == (int)this.MaxLevel && (int)this.Expirience >= num)
            {
                this.Expirience = (short)num;
                return(false);
            }

            this.Expirience += (short)i;
            if ((int)this.Level == (int)this.MaxLevel)
            {
                if ((int)this.Expirience > num)
                {
                    this.Expirience = (short)num;
                }
                Asda2PetHandler.SendUpdatePetExpResponse(this.Owner.Client, this, false);
                return(true);
            }

            if ((int)this.Expirience > num)
            {
                this.RemoveStatsFromOwner();
                ++this.Level;
                this.AddStatsToOwner();
                Asda2CharacterHandler.SendUpdateStatsResponse(this.Owner.Client);
                Asda2CharacterHandler.SendUpdateStatsOneResponse(this.Owner.Client);
                GlobalHandler.UpdateCharacterPetInfoToArea(this.Owner);
                Asda2PetHandler.SendUpdatePetHungerResponse(this.Owner.Client, this);
            }

            Asda2PetHandler.SendUpdatePetExpResponse(this.Owner.Client, this, true);
            return(true);
        }
예제 #7
0
        public override void Update(int dt)
        {
            base.Update(dt);

            if (m_isLoggingOut)
            {
                m_logoutTimer.Update(dt);
            }

            if (!IsMoving && LastSendIamNotMoving < (uint)Environment.TickCount)
            {
                LastSendIamNotMoving = (uint)(Environment.TickCount + CharacterFormulas.TimeBetweenImNotMovingPacketSendMillis);
                Asda2MovmentHandler.SendStartMoveCommonToAreaResponse(this, true, false);
            }
            Asda2MovmentHandler.CalculateAndSetRealPos(this, dt);
            if (Asda2Pet != null)
            {
                if (LastPetExpGainTime < (uint)Environment.TickCount)
                {
                    Asda2Pet.GainXp(1);
                    LastPetExpGainTime = (uint)Environment.TickCount + CharacterFormulas.TimeBetweenPetExpGainSecs * 1000;
                }
                if (!PetNotHungerEnabled && LastPetEatingTime < (uint)Environment.TickCount)
                {
                    if (Asda2Pet.HungerPrc == 1)
                    {
                        Asda2TitleChecker.OnPetStarve(this);
                        //Stop pet
                        Asda2PetHandler.SendPetGoesSleepDueStarvationResponse(Client, Asda2Pet);
                        Asda2Pet.RemoveStatsFromOwner();
                        Asda2Pet.HungerPrc = 0;
                        Asda2Pet           = null;
                        GlobalHandler.UpdateCharacterPetInfoToArea(this);
                    }
                    else
                    {
                        Asda2Pet.HungerPrc--;
                        LastPetEatingTime = (uint)Environment.TickCount + CharacterFormulas.TimeBetweenPetEatingsSecs * 1000;
                    }
                }
            }
            if (PremiumBuffs.Count > 0)
            {
                foreach (var functionItemBuff in PremiumBuffs.Values)
                {
                    if (functionItemBuff.Duration < dt)
                    {
                        ProcessFunctionalItemEffect(functionItemBuff, false);
                        CategoryBuffsToDelete.Add(functionItemBuff.Template.Category);
                        functionItemBuff.DeleteLater();
                    }
                    else
                    {
                        functionItemBuff.Duration -= dt;
                    }
                }
            }
            foreach (var functionItemBuff in LongTimePremiumBuffs)
            {
                if (functionItemBuff == null)
                {
                    continue;
                }
                if (functionItemBuff.EndsDate < DateTime.Now)
                {
                    ProcessFunctionalItemEffect(functionItemBuff, false);
                    CategoryBuffsToDelete.Add(functionItemBuff.Template.Category);
                    functionItemBuff.DeleteLater();
                }
            }
            if (CategoryBuffsToDelete.Count > 0)
            {
                foreach (var asda2ItemCategory in CategoryBuffsToDelete)
                {
                    PremiumBuffs.Remove(asda2ItemCategory);
                    for (int i = 0; i < LongTimePremiumBuffs.Length; i++)
                    {
                        if (LongTimePremiumBuffs[i] == null || LongTimePremiumBuffs[i].Template.Category != asda2ItemCategory)
                        {
                            continue;
                        }
                        LongTimePremiumBuffs[i] = null;
                        break;
                    }
                }
                CategoryBuffsToDelete.Clear();
            }
            var toDelete = new List <Asda2PereodicActionType>();

            foreach (var pereodicAction in PereodicActions)
            {
                pereodicAction.Value.Update(dt);
                if (pereodicAction.Value.CallsNum <= 0)
                {
                    toDelete.Add(pereodicAction.Key);
                }
            }
            foreach (var t in toDelete)
            {
                PereodicActions.Remove(t);
            }
            if (SoulmateRecord != null)
            {
                SoulmateRecord.OnUpdateTick();
            }
            if (BanChatTill < DateTime.Now)
            {
                BanChatTill = null;
                ChatBanned  = false;
                SendInfoMsg("Chat is unbanned.");
            }
        }