Esempio n. 1
0
 /// <summary>
 /// Gives the receiver the money and informs everyone else
 /// </summary>
 /// <param name="receiver"></param>
 /// <param name="amount"></param>
 protected void SendMoney(Character receiver, uint amount)
 {
     Asda2InventoryHandler.SendGoldPickupedResponse(receiver.Money + amount, receiver);
     receiver.AddMoney(amount);
     Asda2TitleChecker.OnGoldPickUp(receiver);
     //LootHandler.SendClearMoney(this);
 }
Esempio n. 2
0
        public void StopPvp()
        {
            if (!IsActive)
            {
                return;
            }
            IsActive = false;
            if (Losser == null)
            {
                Losser = FirstCharacter;
            }
            FirstCharacter.EnemyCharacters.Remove(SecondCharacter);
            SecondCharacter.EnemyCharacters.Remove(FirstCharacter);
            FirstCharacter.CheckEnemysCount();
            SecondCharacter.CheckEnemysCount();
            Asda2PvpHandler.SendDuelEndedResponse(Winner, Losser);

            Asda2TitleChecker.OnWinDuel(Winner);

            FirstCharacter.Asda2Duel            = null;
            SecondCharacter.Asda2Duel           = null;
            FirstCharacter.Asda2DuelingOponent  = null;
            SecondCharacter.Asda2DuelingOponent = null;
            FirstCharacter  = null;
            SecondCharacter = null;
        }
Esempio n. 3
0
        public static void ProcessDig(IRealmClient client)
        {
            if (client.ActiveCharacter == null)
            {
                return;
            }
            var showel = client.ActiveCharacter.MainWeapon as Asda2Item;

            if (showel == null)
            {
                return;
            }
            var oilItem = client.ActiveCharacter.Asda2Inventory.Equipment[10];

            var isUseOil = oilItem != null && oilItem.Category == Asda2ItemCategory.DigOil;

            if (isUseOil)
            {
                oilItem.Amount--;
            }
            var chance = CharacterFormulas.CalculateDiggingChance(showel.Template.ValueOnUse, (byte)(client.ActiveCharacter.SoulmateRecord == null ? 0 : client.ActiveCharacter.SoulmateRecord.FriendShipPoints), client.ActiveCharacter.Asda2Luck);
            var rnd    = Utility.Random(0, 100000);

            if (rnd > chance && (isUseOil ? client.ActiveCharacter.MapId < (MapId)PremiumMapDiggingTemplates.Count : client.ActiveCharacter.MapId < (MapId)MapDiggingTemplates.Count))
            {
                //dig ok
                Asda2DiggingHandler.SendDigEndedResponse(client, true, oilItem);
                var templ = isUseOil
                                 ? PremiumMapDiggingTemplates[(byte)client.ActiveCharacter.MapId]
                                 : MapDiggingTemplates[(byte)client.ActiveCharacter.MapId];
                var itemId    = templ.GetRandomItem();
                var loot      = new Asda2NPCLoot();
                var itemTempl = Asda2ItemMgr.GetTemplate(itemId) ?? Asda2ItemMgr.GetTemplate(20622);
                loot.Items = new[] { new Asda2LootItem(itemTempl, 1, 0)
                                     {
                                         Loot = loot
                                     } };
                loot.Lootable = client.ActiveCharacter;
                loot.Looters.Add(new Asda2LooterEntry(client.ActiveCharacter));
                loot.MonstrId = 22222;
                client.ActiveCharacter.Map.SpawnLoot(loot);
                client.ActiveCharacter.GainXp(CharacterFormulas.CalcDiggingExp(client.ActiveCharacter.Level, templ.MinLevel), "digging");
                client.ActiveCharacter.GuildPoints += CharacterFormulas.DiggingGuildPoints;

                Asda2TitleChecker.OnSuccessDig(client.ActiveCharacter, itemId, itemTempl.Quality, client);
            }
            else
            {
                // dig fail
                Asda2DiggingHandler.SendDigEndedResponse(client, false, oilItem);
            }

            client.ActiveCharacter.IsDigging = false;
            client.ActiveCharacter.Stunned--;
        }
Esempio n. 4
0
        static void SendMoneyToSeller(string itemName, int gold, int itemAmount, Character chr)
        {
            var comission   = (int)(gold * CharacterFormulas.AuctionSellComission);
            var goldToOwner = gold - comission;

            chr.AddMoney((uint)goldToOwner);
            chr.SendMoneyUpdate();
            chr.SendAuctionMsg(string.Format("{0} {3} success solded for {1} gold. {2} comission has collected.", itemName, goldToOwner, comission, itemAmount < 2 ? "" : string.Format("[{0}]", itemAmount)));

            Asda2TitleChecker.OnAuctionItemSold(chr);
        }
Esempio n. 5
0
        protected override void Apply(WorldObject target, ref DamageAction[] actions)
        {
            var chr = target as Character;

            if (chr != null && chr.IsDead)
            {
                chr.Resurrect();
                chr.GainXp(chr.LastExpLooseAmount * Effect.MiscValue, "resurect_spell");
                Asda2TitleChecker.OnResurectUse(Cast.CasterChar);
            }
        }
Esempio n. 6
0
        [PacketHandler(RealmServerOpCode.StartDig)]//5428
        public static void StartDigRequest(IRealmClient client, RealmPacketIn packet)
        {
            //var accId = packet.ReadInt32();//default : 340701Len : 4
            if (client.ActiveCharacter.IsDigging)
            {
                client.ActiveCharacter.SendSystemMessage("You already digging.");
                SendStartDigResponseResponse(client, Asda2DigResult.DiggingFail);
                return;
            }
            if (client.ActiveCharacter.IsInCombat || client.ActiveCharacter.IsMoving)
            {
                client.ActiveCharacter.SendSystemMessage("You can't dig while moving or fighting.");
                SendStartDigResponseResponse(client, Asda2DigResult.DiggingFail);
                return;
            }
            var showel = client.ActiveCharacter.MainWeapon as Asda2Item;

            if (showel == null || showel.Category != Asda2ItemCategory.Showel)
            {
                SendStartDigResponseResponse(client, Asda2DigResult.YouHaveNoShowel);
                return;
            }
            var oilItem  = client.ActiveCharacter.Asda2Inventory.Equipment[10];
            var isUseOil = oilItem != null && oilItem.Category == Asda2ItemCategory.DigOil;

            if (!(isUseOil ? client.ActiveCharacter.MapId < (MapId)Asda2DigMgr.PremiumMapDiggingTemplates.Count : client.ActiveCharacter.MapId < (MapId)Asda2DigMgr.MapDiggingTemplates.Count))
            {
                client.ActiveCharacter.YouAreFuckingCheater("Trying to dig in unknown location : " + client.ActiveCharacter.MapId, 10);
                SendStartDigResponseResponse(client, Asda2DigResult.DiggingFail);
                return;
            }

            if (isUseOil)
            {
                Asda2TitleChecker.OnUseAutoFishDig(client.ActiveCharacter);
            }
            var templ = isUseOil
                                 ? Asda2DigMgr.PremiumMapDiggingTemplates[(byte)client.ActiveCharacter.MapId]
                                 : Asda2DigMgr.MapDiggingTemplates[(byte)client.ActiveCharacter.MapId];

            if (templ.MinLevel > client.ActiveCharacter.Level)
            {
                SendStartDigResponseResponse(client, Asda2DigResult.YouUnableToDigInThisLocationDueLowLevel);
                return;
            }
            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, 0);
            SendStartDigResponseResponse(client, Asda2DigResult.Ok);
        }
Esempio n. 7
0
        public Asda2PetRecord AddAsda2Pet(PetTemplate petTemplate, bool silent = false)
        {
            var newPet = new Asda2PetRecord(petTemplate, this);

            newPet.Create();
            OwnedPets.Add(newPet.Guid, newPet);
            Asda2TitleChecker.OnPetCountChanged(OwnedPets.Count, this);
            if (!silent)
            {
                Asda2PetHandler.SendInitPetInfoOnLoginResponse(Client, newPet);
            }
            return(newPet);
        }
Esempio n. 8
0
        [PacketHandler(RealmServerOpCode.WishperChatRequest)] //5088
        public static void WishperChatRequest(IRealmClient client, RealmPacketIn packet)
        {
            packet.Position -= 24;
            var isSoulmate = packet.ReadByte();                    //default : 0Len : 1
            var target     = packet.ReadAsdaString(20, Locale.En); //default : Len : 20
            var index      = target.IndexOf('|');

            if (index >= 0)
            {
                target = target.Substring(index + 1, target.Length - index - 1);
            }
            var msg = packet.ReadAsciiString(client.Locale); //default : Len : 0

            if (msg.Length > 100)
            {
                client.ActiveCharacter.SendSystemMessage(string.Format(
                                                             "Can't send wishper to {0} cause it's length more than 100 symbols.", target));
                return;
            }
            if (msg.Length < 1 ||
                RealmCommandHandler.HandleCommand(client.ActiveCharacter, msg,
                                                  client.ActiveCharacter.Target as Character))
            {
                return;
            }
            var targetChar = World.GetCharacter(target, false);

            if (targetChar == null)
            {
                client.ActiveCharacter.SendSystemMessage(string.Format(
                                                             "Can't send wishper to {0} cause can't found it.", target));
                return;
            }
            if (!targetChar.EnableWishpers && !client.ActiveCharacter.Role.IsStaff)
            {
                client.ActiveCharacter.SendSystemMessage(string.Format(
                                                             "Sorry, but {0} rejects all wishpers.", target));
                return;
            }
            //if (client.ActiveCharacter.ChatBanned)
            //{
            //    client.ActiveCharacter.SendInfoMsg("Your chat is banned.");
            //    return;
            //}

            SendWishperChatResponse(client, isSoulmate, targetChar.SessionId,
                                    client.ActiveCharacter.SessionId, CreateSenderName(client.ActiveCharacter), msg);
            SendWishperChatResponse(targetChar.Client, isSoulmate, client.ActiveCharacter.SessionId,
                                    targetChar.SessionId, CreateSenderName(client.ActiveCharacter), msg, client);
            Asda2TitleChecker.OnWishperChat(client.ActiveCharacter);
        }
Esempio n. 9
0
        [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);
        }
 private void TryLevelUp()
 {
     if (Level >= ExpTable.Length)
     {
         return;
     }
     if (ExpTable[Level] < Expirience)
     {
         Level++;
         var firstChar = World.GetCharacterByAccId(AccId);
         var secChar   = World.GetCharacterByAccId(RelatedAccId);
         Asda2TitleChecker.OnSoulmatingLevelChanged(Level, firstChar);
         Asda2TitleChecker.OnSoulmatingLevelChanged(Level, secChar);
     }
 }
Esempio n. 11
0
        [PacketHandler(RealmServerOpCode.RemovePet)]//6110
        public static void RemovePetRequest(IRealmClient client, RealmPacketIn packet)
        {
            var petGuid = packet.ReadInt32(); //default : 68411Len : 4

            if (!client.ActiveCharacter.OwnedPets.ContainsKey(petGuid))
            {
                client.ActiveCharacter.YouAreFuckingCheater("Trying delete not existing pet.", 10);
                return;
            }
            if (client.ActiveCharacter.Asda2Pet != null && client.ActiveCharacter.Asda2Pet.Guid == petGuid)
            {
                client.ActiveCharacter.SendInfoMsg("You can't delete summoned pet.");
                return;
            }
            var pet = client.ActiveCharacter.OwnedPets[petGuid];

            client.ActiveCharacter.OwnedPets.Remove(petGuid);
            SendPetRemovedResponse(client, pet.Guid);
            pet.DeleteLater();
            Asda2TitleChecker.OnPetRemoved(client.ActiveCharacter, pet.Template.Rarity);
        }
Esempio n. 12
0
        [PacketHandler(RealmServerOpCode.UseTeleportScroll)]//5458
        public static void UseTeleportScrollRequest(IRealmClient client, RealmPacketIn packet)
        {
            packet.Position += 2;                                      //nk8 default : 1Len : 2
            var targetCharName = packet.ReadAsdaString(20, Locale.En); //default : Len : 20
            var targetChr      = World.GetCharacter(targetCharName, false);

            if (targetChr == null)
            {
                client.ActiveCharacter.SendWarMsg(string.Format("{0} is not in game.", targetCharName));
                return;
            }
            if (targetChr.IsAsda2BattlegroundInProgress)
            {
                client.ActiveCharacter.SendWarMsg(string.Format("{0} is  on war.", targetCharName));
                return;
            }
            if (!targetChr.EnableWishpers && !client.ActiveCharacter.Role.IsStaff)
            {
                client.ActiveCharacter.SendInfoMsg("you cant do that!");
                return;
            }
            if (client.ActiveCharacter.IsAsda2BattlegroundInProgress)
            {
                client.ActiveCharacter.SendWarMsg("You cant teleport on war.");
                return;
            }
            var scrollRemoved = client.ActiveCharacter.Asda2Inventory.UseTeleportScroll();

            if (scrollRemoved)
            {
                client.ActiveCharacter.TeleportTo(targetChr);
                Asda2TitleChecker.OnTeleportScrolUse(client.ActiveCharacter);
            }
            else
            {
                client.ActiveCharacter.SendSystemMessage("You have not teleport scroll");
            }
        }
Esempio n. 13
0
        private static void ProcessFunctionalItem(IRealmClient client, uint parametr, short slot)
        {
            var item = client.ActiveCharacter.Asda2Inventory.GetShopShopItem(slot);

            if (item == null)
            {
                SendUpdateShopItemInfoResponse(client, UseFunctionalItemError.FunctionalItemDoesNotExist);
                return;
            }
            var status = UseFunctionalItemError.Ok;

            if (item.RequiredLevel > client.ActiveCharacter.Level)
            {
                SendUpdateShopItemInfoResponse(client, UseFunctionalItemError.YorLevelIsNotHightEnoght, item);
                return;
            }
            RealmServer.IOQueue.AddMessage(() =>
            {
                try
                {
                    switch (item.Category)
                    {
                    case Asda2ItemCategory.ExpandWarehouse:
                        if (client.ActiveCharacter.Record.PremiumWarehouseBagsCount >= 8)
                        {
                            status = UseFunctionalItemError.WarehouseHasReachedMaxCapacity;
                        }

                        else
                        {
                            client.ActiveCharacter.Record.PremiumWarehouseBagsCount++;
                            SendWarehouseSlotsExpandedResponse(client, false);
                        }
                        break;

                    /* case Asda2ItemCategory.AvatarWarehouseExpand:
                     *
                     *   if (client.ActiveCharacter.Record.PremiumAvatarWarehouseBagsCount >= 8)
                     *       status = UseFunctionalItemError.WarehouseHasReachedMaxCapacity;
                     *   else
                     *   {
                     *       client.ActiveCharacter.Record.PremiumAvatarWarehouseBagsCount++;
                     *       SendWarehouseSlotsExpandedResponse(client, false);
                     *   }
                     *   break;*/
                    case Asda2ItemCategory.IncExp:
                        client.ActiveCharacter.ApplyFunctionItemBuff(item.ItemId);
                        SendShopItemUsedResponse(client, item.ItemId, item.Template.AtackRange);
                        break;

                    case Asda2ItemCategory.IncMoveSpeed:
                        if (item.Record.IsSoulBound && item.Record.AuctionEndTime != DateTime.MinValue &&
                            DateTime.Now > item.Record.AuctionEndTime)
                        {
                            client.ActiveCharacter.Asda2Inventory.RemoveItemFromInventory(item);
                            item.Destroy();
                            client.ActiveCharacter.SendInfoMsg("Vehicle expired.");
                            status = UseFunctionalItemError.TheDurationOfTheShopitemHaExprised;
                        }
                        else
                        {
                            if (!item.IsSoulbound)
                            {
                                Asda2TitleChecker.OnUseVeiche(client.ActiveCharacter);
                            }
                            item.IsSoulbound                       = true;
                            item.Record.AuctionEndTime             = DateTime.Now + TimeSpan.FromDays(item.AttackTime);
                            client.ActiveCharacter.TransportItemId = item.ItemId;
                        }
                        break;

                    case Asda2ItemCategory.IncHp:
                        client.ActiveCharacter.ApplyFunctionItemBuff(item.ItemId);
                        SendShopItemUsedResponse(client, item.ItemId, item.Template.AtackRange);
                        break;

                    case Asda2ItemCategory.IncMp:
                        client.ActiveCharacter.ApplyFunctionItemBuff(item.ItemId);
                        SendShopItemUsedResponse(client, item.ItemId, item.Template.AtackRange);
                        break;

                    case Asda2ItemCategory.IncAtackSpeed:
                        client.ActiveCharacter.ApplyFunctionItemBuff(item.ItemId);
                        SendShopItemUsedResponse(client, item.ItemId, item.Template.AtackRange);
                        break;

                    case Asda2ItemCategory.IncDex:
                        client.ActiveCharacter.ApplyFunctionItemBuff(item.ItemId);
                        SendShopItemUsedResponse(client, item.ItemId, item.Template.AtackRange);
                        break;

                    case Asda2ItemCategory.IncDigChance:
                        client.ActiveCharacter.ApplyFunctionItemBuff(item.ItemId);
                        SendShopItemUsedResponse(client, item.ItemId, item.Template.AtackRange);
                        break;

                    case Asda2ItemCategory.IncDropChance:
                        client.ActiveCharacter.ApplyFunctionItemBuff(item.ItemId);
                        SendShopItemUsedResponse(client, item.ItemId, item.Template.AtackRange);
                        break;

                    case Asda2ItemCategory.IncExpStackable:
                        client.ActiveCharacter.ApplyFunctionItemBuff(item.ItemId);
                        SendShopItemUsedResponse(client, item.ItemId, item.Template.AtackRange);
                        break;

                    case Asda2ItemCategory.IncInt:
                        client.ActiveCharacter.ApplyFunctionItemBuff(item.ItemId);
                        SendShopItemUsedResponse(client, item.ItemId, item.Template.AtackRange);
                        break;

                    case Asda2ItemCategory.IncLuck:
                        client.ActiveCharacter.ApplyFunctionItemBuff(item.ItemId);
                        SendShopItemUsedResponse(client, item.ItemId, item.Template.AtackRange);
                        break;

                    case Asda2ItemCategory.IncMAtk:
                        client.ActiveCharacter.ApplyFunctionItemBuff(item.ItemId);
                        SendShopItemUsedResponse(client, item.ItemId, item.Template.AtackRange);
                        break;

                    case Asda2ItemCategory.IncMdef:
                        client.ActiveCharacter.ApplyFunctionItemBuff(item.ItemId);
                        SendShopItemUsedResponse(client, item.ItemId, item.Template.AtackRange);
                        break;

                    case Asda2ItemCategory.IncPAtk:
                        client.ActiveCharacter.ApplyFunctionItemBuff(item.ItemId);
                        SendShopItemUsedResponse(client, item.ItemId, item.Template.AtackRange);
                        break;

                    case Asda2ItemCategory.IncPDef:
                        client.ActiveCharacter.ApplyFunctionItemBuff(item.ItemId);
                        SendShopItemUsedResponse(client, item.ItemId, item.Template.AtackRange);
                        break;

                    case Asda2ItemCategory.IncSpi:
                        client.ActiveCharacter.ApplyFunctionItemBuff(item.ItemId);
                        SendShopItemUsedResponse(client, item.ItemId, item.Template.AtackRange);
                        break;

                    case Asda2ItemCategory.IncSta:
                        client.ActiveCharacter.ApplyFunctionItemBuff(item.ItemId);
                        SendShopItemUsedResponse(client, item.ItemId, item.Template.AtackRange);
                        break;

                    case Asda2ItemCategory.IncStr:
                        client.ActiveCharacter.ApplyFunctionItemBuff(item.ItemId);
                        SendShopItemUsedResponse(client, item.ItemId, item.Template.AtackRange);
                        break;

                    case Asda2ItemCategory.DoublePetExpirience:
                        client.ActiveCharacter.ApplyFunctionItemBuff(item.ItemId);
                        SendShopItemUsedResponse(client, item.ItemId, item.Template.AtackRange);
                        break;

                    case Asda2ItemCategory.PetNotEating:
                        client.ActiveCharacter.ApplyFunctionItemBuff(item.ItemId);
                        SendShopItemUsedResponse(client, item.ItemId, item.Template.AtackRange);
                        break;

                    case Asda2ItemCategory.ResetAllSkill:
                        ResetSkills(client.ActiveCharacter);
                        Asda2CharacterHandler.SendLearnedSkillsInfo(client.ActiveCharacter);
                        Asda2TitleChecker.OnResetAllSkills(client.ActiveCharacter);
                        break;

                    case Asda2ItemCategory.ExpandInventory:
                        SendPremiumLongBuffInfoResponse(client,
                                                        (byte)client.ActiveCharacter.ApplyFunctionItemBuff(item.ItemId, true),
                                                        item.ItemId, (short)item.Template.PackageId);
                        break;

                    case Asda2ItemCategory.RemoveDeathPenaltiesByDays:
                        SendPremiumLongBuffInfoResponse(client,
                                                        (byte)client.ActiveCharacter.ApplyFunctionItemBuff(item.ItemId, true),
                                                        item.ItemId, (short)item.Template.PackageId);
                        break;

                    case Asda2ItemCategory.ShopBanner:
                        if (client.ActiveCharacter.Level < 10)
                        {
                            status = UseFunctionalItemError.YorLevelIsNotHightEnoght;
                        }
                        else
                        {
                            SendPremiumLongBuffInfoResponse(client,
                                                            (byte)client.ActiveCharacter.ApplyFunctionItemBuff(item.ItemId, true),
                                                            item.ItemId, (short)item.Template.PackageId);
                        }
                        break;

                    case Asda2ItemCategory.PetNotEatingByDays:
                        SendPremiumLongBuffInfoResponse(client,
                                                        (byte)client.ActiveCharacter.ApplyFunctionItemBuff(item.ItemId, true),
                                                        item.ItemId, (short)item.Template.PackageId);
                        break;

                    case Asda2ItemCategory.InstantRecover100PrcHPandMP:
                        if (client.ActiveCharacter.Last100PrcRecoveryUsed + 30000 > (uint)Environment.TickCount)
                        {
                            status = UseFunctionalItemError.CoolingTimeRemain;
                        }
                        else
                        {
                            client.ActiveCharacter.Last100PrcRecoveryUsed = (uint)Environment.TickCount;
                            client.ActiveCharacter.HealPercent(100);
                            client.ActiveCharacter.Power = client.ActiveCharacter.MaxPower;
                        }
                        break;

                    case Asda2ItemCategory.InstantRecover100PrcHP:
                        if (client.ActiveCharacter.Last100PrcRecoveryUsed + 30000 > (uint)Environment.TickCount)
                        {
                            status = UseFunctionalItemError.CoolingTimeRemain;
                        }
                        else
                        {
                            client.ActiveCharacter.Last100PrcRecoveryUsed = (uint)Environment.TickCount;
                            client.ActiveCharacter.HealPercent(100);
                        }
                        break;

                    case Asda2ItemCategory.RecoverHp10TimesByPrcOver30Sec:
                        PereodicAction a = null;
                        if (client.ActiveCharacter.PereodicActions.ContainsKey(Asda2PereodicActionType.HpRegenPrc))
                        {
                            a = client.ActiveCharacter.PereodicActions[Asda2PereodicActionType.HpRegenPrc];
                        }
                        if (a != null && a.CallsNum >= 6 && a.Value >= item.Template.ValueOnUse)
                        {
                            status = UseFunctionalItemError.CoolingTimeRemain;
                        }
                        else
                        {
                            if (
                                client.ActiveCharacter.PereodicActions.ContainsKey(
                                    Asda2PereodicActionType.HpRegenPrc))
                            {
                                client.ActiveCharacter.PereodicActions.Remove(Asda2PereodicActionType.HpRegenPrc);
                            }
                            a = new PereodicAction(client.ActiveCharacter, item.Template.ValueOnUse, 10, 5000,
                                                   Asda2PereodicActionType.HpRegenPrc);
                            client.ActiveCharacter.PereodicActions.Add(Asda2PereodicActionType.HpRegenPrc, a);
                        }
                        break;

                    case Asda2ItemCategory.PremiumPotions:
                        SendPremiumLongBuffInfoResponse(client,
                                                        (byte)client.ActiveCharacter.ApplyFunctionItemBuff(item.ItemId, true),
                                                        item.ItemId, (short)item.Template.PackageId);
                        break;

                    case Asda2ItemCategory.TeleportToCharacter:
                        if (parametr >= 10 ||
                            client.ActiveCharacter.TeleportPoints[parametr] == null)
                        {
                            status = UseFunctionalItemError.FailedToUse;
                        }
                        else
                        {
                            var point = client.ActiveCharacter.TeleportPoints[parametr];
                            Asda2TitleChecker.OnTeleportingToTelepotPoint(client.ActiveCharacter);
                            client.ActiveCharacter.TeleportTo(point.MapId, new Vector3(point.X, point.Y));
                        }
                        break;
                    // case Asda2ItemCategory.Monstertransformpotion:

                    // break;
                    case Asda2ItemCategory.OpenWarehouse:

                        break;

                    case Asda2ItemCategory.ResetOneSkill:
                        var spell = client.ActiveCharacter.Spells.First(s => s.RealId == parametr);
                        if (spell != null)
                        {
                            var totalcost = 0;
                            totalcost    += spell.Cost;
                            for (int i = spell.Level - 1; i > 0; i--)
                            {
                                var lowSpell = SpellHandler.Get((uint)(spell.RealId + i * 1000));
                                if (lowSpell != null)
                                {
                                    totalcost += lowSpell.Cost;
                                }
                            }
                            var tm = (uint)(totalcost / 2);
                            client.ActiveCharacter.Spells.Remove(spell);
                            client.ActiveCharacter.AddMoney(tm);
                            Asda2CharacterHandler.SendPreResurectResponse(client.ActiveCharacter);
                            SendSkillResetedResponse(client, spell.RealId, (short)spell.Level, tm);
                            Asda2CharacterHandler.SendUpdateStatsOneResponse(client);
                            Asda2CharacterHandler.SendUpdateStatsResponse(client);
                            client.ActiveCharacter.SendMoneyUpdate();
                        }
                        else
                        {
                            status = UseFunctionalItemError.FailedToUse;
                            client.ActiveCharacter.SendInfoMsg("Skill is not learned. Restart client.");
                        }
                        break;

                    default:
                        status = UseFunctionalItemError.NotAunctionalItem;
                        break;
                    }
                }
                catch (AlreadyBuffedExcepton)
                {
                    status = UseFunctionalItemError.AlreadyFeelingTheEffectOfSimilarSkillType;
                }
                if (status == UseFunctionalItemError.Ok && item.Category != Asda2ItemCategory.IncMoveSpeed)
                {
                    item.ModAmount(-1);
                }
                SendUpdateShopItemInfoResponse(client, status, item);
            });
        }
Esempio n. 14
0
        [PacketHandler(RealmServerOpCode.EndFishing)]//6171
        public static void EndFishingRequest(IRealmClient client, RealmPacketIn packet)
        {
            if (client.ActiveCharacter.CurrentFish == null)
            {
                SendFishingEndedResponse(client, Asda2EndFishingStatus.YouAlreadyFishing, 0);
                return;
            }
            var ft = client.ActiveCharacter.CurrentFish;

            client.ActiveCharacter.CurrentFish = null;
            if (client.ActiveCharacter.FishReadyTime > (uint)Environment.TickCount)
            {
                SendFishingEndedResponse(client, Asda2EndFishingStatus.YouAlreadyFishing, 0);
                return;
            }
            if (client.ActiveCharacter.Asda2Inventory.Equipment[9] == null || !client.ActiveCharacter.Asda2Inventory.Equipment[9].IsRod)
            {
                client.ActiveCharacter.YouAreFuckingCheater("Trying to fishing without rod.", 30);
                SendFishingStartedResponse(client, Asda2StartFishStatus.YouHaveNoFishRod);
                return;
            }
            if (client.ActiveCharacter.Asda2Inventory.Equipment[10] == null || !client.ActiveCharacter.Asda2Inventory.Equipment[10].Template.IsBait)
            {
                client.ActiveCharacter.YouAreFuckingCheater("Trying to fishing without bait.", 30);
                SendFishingStartedResponse(client, Asda2StartFishStatus.YouHaveNoBait);
                return;
            }
            var rod = client.ActiveCharacter.Asda2Inventory.Equipment[9];

            if (rod.Category != Asda2ItemCategory.PremiumFishRod && CharacterFormulas.DecraseRodDurability())
            {
                rod.DecreaseDurability(1);
            }
            var bait = client.ActiveCharacter.Asda2Inventory.Equipment[10];

            bait.ModAmount(-1);
            if (bait.Category != Asda2ItemCategory.BaitElite && !ft.BaitIds.Contains(bait.ItemId))
            {
                SendFishingEndedResponse(client, Asda2EndFishingStatus.Ok, 0, bait);
                return;
            }
            FishingSpot spot = null;

            foreach (var fishingSpot in Asda2FishingMgr.FishingSpotsByMaps[(int)client.ActiveCharacter.MapId])
            {
                if (client.ActiveCharacter.Asda2Position.GetDistance(fishingSpot.Position) > fishingSpot.Radius / 2)
                {
                    continue;
                }
                spot = fishingSpot;
                break;
            }
            if (spot == null)
            {
                client.ActiveCharacter.YouAreFuckingCheater("Trying to fishing in wrong place.", 30);
                SendFishingStartedResponse(client, Asda2StartFishStatus.YouCantFishHere);
                return;
            }
            if (client.ActiveCharacter.FishingLevel < spot.RequiredFishingLevel)
            {
                SendFishingStartedResponse(client, Asda2StartFishStatus.YourFishingLevelIsToLowToFishHereItMustBe, 0, (uint)spot.RequiredFishingLevel);
                return;
            }
            if (client.ActiveCharacter.Asda2Inventory.FreeRegularSlotsCount < 1)
            {
                SendFishingStartedResponse(client, Asda2StartFishStatus.NotEnoughtSpace);
                return;
            }
            var success = CharacterFormulas.CalcFishingSuccess(client.ActiveCharacter.FishingLevel, spot.RequiredFishingLevel, client.ActiveCharacter.Asda2Luck);

            if (!success)
            {
                SendFishingEndedResponse(client, Asda2EndFishingStatus.Ok, 0, bait, null);
                return;
            }
            var fishSize =
                (short)
                Util.Utility.Random(ft.MinLength,
                                    ft.MaxLength);

            fishSize = (short)(fishSize + fishSize * client.ActiveCharacter.GetIntMod(StatModifierInt.Asda2FishingGauge) / 100 * (client.ActiveCharacter.GodMode ? 10 : 1));
            if (CharacterFormulas.CalcFishingLevelRised(client.ActiveCharacter.FishingLevel) && client.ActiveCharacter.Record.FishingLevel < spot.RequiredFishingLevel + 80)
            {
                client.ActiveCharacter.Record.FishingLevel++;
            }

            client.ActiveCharacter.GuildPoints += CharacterFormulas.FishingGuildPoints;

            Asda2Item item   = null;
            var       err    = client.ActiveCharacter.Asda2Inventory.TryAdd((int)ft.ItemTemplate.ItemId, 1, true, ref item);
            var       resLog = Log.Create(Log.Types.ItemOperations, LogSourceType.Character, client.ActiveCharacter.EntryId)
                               .AddAttribute("source", 0, "fishing")
                               .AddItemAttributes(item)
                               .Write();

            client.ActiveCharacter.Map.AddMessage(() =>
            {
                if (err != Asda2InventoryError.Ok)
                {
                    SendFishingEndedResponse(client, Asda2EndFishingStatus.NoSpace, 0, bait, null);
                    return;
                }
                foreach (var registeredFishingBook in client.ActiveCharacter.RegisteredFishingBooks.Values)
                {
                    registeredFishingBook.OnCatchFish(item.ItemId, fishSize);
                }
                client.ActiveCharacter.GainXp(
                    CharacterFormulas.CalcExpForFishing(client.ActiveCharacter.Level,
                                                        client.ActiveCharacter.FishingLevel, item.Template.Quality,
                                                        spot.RequiredFishingLevel, fishSize),
                    "fishing");
                SendFishingEndedResponse(client, Asda2EndFishingStatus.Ok, fishSize, bait, item);
                SendSomeOneStartedFishingResponse(client.ActiveCharacter, (int)ft.ItemTemplate.Id, fishSize);
                Asda2TitleChecker.OnSuccessFishing(client.ActiveCharacter, (int)ft.ItemTemplate.Id, fishSize);
            });
        }
Esempio n. 15
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.");
            }
        }
Esempio n. 16
0
        protected override void OnDeath()
        {
            if (m_brain != null)
            {
                m_brain.IsRunning = false;
            }

            if (m_Map != null || this != null)
            {
                var       rcvrs  = this.GetNearbyClients(false);
                var       looter = CalcLooter();
                Asda2Loot loot   = null;
                if (looter != null && m_Map.DefenceTownEvent == null)
                {
                    loot = Asda2LootMgr.GetOrCreateLoot(this, looter,
                                                        Asda2LootEntryType.Npc);
                    if (loot != null && Template != null)
                    {
                        loot.MonstrId = (short?)Template.Id;
                    }
                }



                Loot = null;
                var map = m_Map;
                m_Map.CallDelayed(LastDamageDelay, () =>
                {
                    Asda2CombatHandler.SendMostrDeadToAreaResponse(rcvrs,
                                                                   (short)
                                                                   UniqIdOnMap,
                                                                   (short)
                                                                   Asda2Position.
                                                                   X,
                                                                   (short)
                                                                   Asda2Position.
                                                                   Y);
                    map.OnNPCDied(this);

                    var chr = LastKiller as Character;
                    if (chr != null)
                    {
                        Asda2TitleChecker.OnNpcDeath(this, chr);
                        if (chr.IsInGroup)
                        {
                            chr.Group.ForeachCharacter(x => KillMonsterEventManager.TryGiveReward(x, Template.Id));
                        }
                        else
                        {
                            KillMonsterEventManager.TryGiveReward(chr, Template.Id);
                        }
                    }
                    if (loot != null && loot.Lootable is NPC)
                    {
                        var npc = ((NPC)loot.Lootable);
                        if (npc != null && npc.Map != null)
                        {
                            npc.Map.SpawnLoot(loot);
                        }
                    }

                    if (m_entry != null && Entry != null && Template != null)
                    {
                        if (Entry.Rank >= CreatureRank.Boss)
                        {
                            if (LastKiller != null)
                            {
                                ChatMgr.SendGlobalMessageResponse(LastKiller.Name,
                                                                  ChatMgr.Asda2GlobalMessageType
                                                                  .HasDefeated, 0, 0,
                                                                  (short)Template.Id);
                            }
                            if (chr != null)
                            {
                                chr.GuildPoints += m_entry.MinLevel * CharacterFormulas.BossKillingGuildPointsPerLevel;
                            }
                        }
                        else
                        {
                            if (chr != null && chr.Level < m_entry.MinLevel + 3)
                            {
                                chr.GuildPoints += CharacterFormulas.MobKillingGuildPoints;
                            }
                        }
                        // notify events
                        m_entry.NotifyDied(this);
                    }
                    EnterFinalState();
                });
            }


            //UnitFlags |= UnitFlags.SelectableNotAttackable;

            // send off the tamer
            if (m_currentTamer != null)
            {
                PetHandler.SendTameFailure(m_currentTamer, TameFailReason.TargetDead);
                CurrentTamer.SpellCast.Cancel(SpellFailedReason.Ok);
            }

            // reset spawn timer
            if (m_spawnPoint != null)
            {
                m_spawnPoint.SignalSpawnlingDied(this);
            }
        }
Esempio n. 17
0
        public void GuildWaveResultAndItems(Character chr)
        {
            if (chr.IsDead)
            {
                chr.Resurrect();
            }

            Asda2TitleChecker.OnGuildWaveEnd(chr, LastWinnedWave);

            Asda2GuildWaveItemRecord waveItem = null;

            foreach (Asda2GuildWaveItemRecord record in Asda2ItemMgr.GuildWaveRewardRecords)
            {
                if (record.Wave == LastWinnedWave + 1 && record.Lvl == (int)Math.Ceiling(chr.Level / 10.0F) * 10 && record.Difficulty == _difficulty)
                {
                    waveItem = record;
                    break;
                }
            }

            if (waveItem != null)
            {
                List <KeyValuePair <int, int> > pairs = new List <KeyValuePair <int, int> >();
                pairs.Add(new KeyValuePair <int, int>(1, waveItem.Chance1));
                pairs.Add(new KeyValuePair <int, int>(2, waveItem.Chance2));
                pairs.Add(new KeyValuePair <int, int>(3, waveItem.Chance3));
                pairs.Add(new KeyValuePair <int, int>(4, waveItem.Chance4));
                pairs.Add(new KeyValuePair <int, int>(5, waveItem.Chance5));
                pairs.Add(new KeyValuePair <int, int>(6, waveItem.Chance6));
                pairs.Add(new KeyValuePair <int, int>(7, waveItem.Chance7));
                pairs.Add(new KeyValuePair <int, int>(8, waveItem.Chance8));
                pairs.Sort((a, b) => a.Value.CompareTo(b.Value));

                int templateId1 = getTemplateIdFromIndex(CharacterFormulas.GetWaveRewardItems(pairs), waveItem);
                int templateId2 = getTemplateIdFromIndex(CharacterFormulas.GetWaveRewardItems(pairs), waveItem);
                int templateId3 = getTemplateIdFromIndex(CharacterFormulas.GetWaveRewardItems(pairs), waveItem);

                Asda2Item item1 = Asda2Item.CreateItem(templateId1, chr, 1);

                Asda2Item wavecoin = null;

                int amount = getAverageLevel() / CharacterFormulas.WaveCoinsDivider;

                if (amount > 0)
                {
                    wavecoin = Asda2Item.CreateItem(33712, chr, amount);
                    chr.Asda2Inventory.TryAdd(33712, amount, true, ref wavecoin);
                }

                chr.Asda2Inventory.TryAdd(templateId1, 1, true, ref item1);

                if (_difficulty > 0)
                {
                    Asda2Item item2 = Asda2Item.CreateItem(templateId2, chr, 1);
                    chr.Asda2Inventory.TryAdd(templateId2, 1, true, ref item2);

                    if (_difficulty == 2)
                    {
                        Asda2Item item3 = Asda2Item.CreateItem(templateId3, chr, 1);
                        chr.Asda2Inventory.TryAdd(templateId3, 1, true, ref item3);
                    }
                }

                Asda2GuildWaveHandler.GuildWaveResult(this, chr, wavecoin == null ? 0 : wavecoin.Amount, templateId1, templateId2, templateId3);
            }
        }
Esempio n. 18
0
        public void Stop()
        {
            if (!IsRunning)
            {
                return;
            }
            _notificationsAboutStart = 3;
            IsStarted = false;
            World.Broadcast(string.Format("ÇáÍÑÈ Ýí {0} ÇäÊåÊ.. äÞÇØ ÇáäæÑ {1} ÖÏ {2} äÞÇØ ÇáÙáÇã", Town, LightScores,
                                          DarkScores));
            IsRunning = false;
            SetNextWarParametrs();
            //Notify players war ended.
            lock (JoinLock)
            {
                //find mvp
                foreach (var character in LightScores > DarkScores ? LightTeam.Values : DarkTeam.Values)
                {
                    if (MvpCharacter == null)
                    {
                        MvpCharacter = character;
                        continue;
                    }
                    if (MvpCharacter.BattlegroundActPoints < character.BattlegroundActPoints)
                    {
                        MvpCharacter = character;
                    }
                }
                Asda2BattlegroundHandler.SendWiningFactionInfoResponse(Town, WiningFactionId,
                                                                       MvpCharacter == null ? "[áÇ ÃÍÏ]" : MvpCharacter.Name);

                if (MvpCharacter != null)
                {
                    //create db records about war

                    RealmServer.IOQueue.AddMessage(() =>
                    {
                        var warResRec = new BattlegroundResultRecord(Town, MvpCharacter.Name, MvpCharacter.EntityId.Low,
                                                                     LightScores, DarkScores);
                        warResRec.CreateLater();
                        CurrentWarResultRecordGuid = warResRec.Guid;
                        Asda2BattlegroundMgr.ProcessBattlegroundResultRecord(warResRec);
                    });
                }
                foreach (var character in LightTeam.Values)
                {
                    ProcessEndWar(character);
                    if (WiningFactionId == 0)
                    {
                        Asda2TitleChecker.OnWinWar(character);
                    }
                    else
                    {
                        Asda2TitleChecker.OnLoseWar(character);
                    }
                }
                foreach (var character in DarkTeam.Values)
                {
                    ProcessEndWar(character);
                    if (WiningFactionId == 1)
                    {
                        Asda2TitleChecker.OnWinWar(character);
                    }
                    else
                    {
                        Asda2TitleChecker.OnLoseWar(character);
                    }
                }
                foreach (var asda2WarPoint in Points)
                {
                    asda2WarPoint.Status       = Asda2WarPointStatus.NotOwned;
                    asda2WarPoint.OwnedFaction = -1;

                    Asda2BattlegroundHandler.SendUpdatePointInfoResponse(null, asda2WarPoint);
                }
                World.TaskQueue.CallDelayed(60000, KickAll);
            }
        }
Esempio n. 19
0
        [PacketHandler(RealmServerOpCode.ChangeFaceOrHair)]//5470
        public static void ChangeFaceOrHairRequest(IRealmClient client, RealmPacketIn packet)
        {
            var isHair    = packet.ReadByte() == 1; //default : 1Len : 1
            var id        = packet.ReadInt16();     //default : 95Len : 2
            var hairId    = packet.ReadByte();      //default : 1Len : 1
            var hairColor = packet.ReadByte();      //default : 23Len : 1
            var faceId    = packet.ReadInt32();     //default : 0Len : 4

            packet.Position += 2;
            var itemSlot = packet.ReadInt16();//default : 0Len : 4


            var item = client.ActiveCharacter.Asda2Inventory.GetShopShopItem(itemSlot);

            if (isHair)
            {
                if (!Asda2StyleMgr.HairTemplates.ContainsKey(id))
                {
                    client.ActiveCharacter.YouAreFuckingCheater("Trying to change hair to unknown hair.", 50);
                    SendFaceOrHairChangedResponse(client, true);
                    return;
                }
                var template = Asda2StyleMgr.HairTemplates[id];
                if (template.Price > 0)
                {
                    if (!client.ActiveCharacter.SubtractMoney((uint)template.Price))
                    {
                        client.ActiveCharacter.SendInfoMsg("Not enought gold.");
                        SendFaceOrHairChangedResponse(client, isHair);
                        return;
                    }
                }
                if (template.CuponCount > 0)
                {
                    if (item == null || item.Category != Constants.Items.Asda2ItemCategory.StyleShopCoupon)
                    {
                        client.ActiveCharacter.YouAreFuckingCheater("Not enought style coupons.", 30);
                        SendFaceOrHairChangedResponse(client, isHair);
                        return;
                    }
                    item.ModAmount(-template.CuponCount);
                }
                client.ActiveCharacter.HairColor = template.HairColor;
                client.ActiveCharacter.HairStyle = template.HairId;
                Asda2TitleChecker.OnHairChange(client.ActiveCharacter);
            }
            else
            {
                if (!Asda2StyleMgr.FaceTemplates.ContainsKey(id))
                {
                    client.ActiveCharacter.YouAreFuckingCheater("Trying to change face to unknown face.", 50);
                    SendFaceOrHairChangedResponse(client, isHair);
                    return;
                }
                var template = Asda2StyleMgr.FaceTemplates[id];
                if (template.Price > 0)
                {
                    if (!client.ActiveCharacter.SubtractMoney((uint)template.Price))
                    {
                        client.ActiveCharacter.SendInfoMsg("Not enought gold.");
                        SendFaceOrHairChangedResponse(client, isHair);
                        return;
                    }
                }
                if (template.CuponCount > 0)
                {
                    if (item == null || item.Category != Constants.Items.Asda2ItemCategory.StyleShopCoupon)
                    {
                        client.ActiveCharacter.YouAreFuckingCheater("Not enought style coupons.", 30);
                        SendFaceOrHairChangedResponse(client, isHair);
                        return;
                    }
                    item.ModAmount(-template.CuponCount);
                }
                client.ActiveCharacter.Record.Face = (byte)template.FaceId;
            }
            SendFaceOrHairChangedResponse(client, isHair, true, item);
        }