Exemplo n.º 1
0
        protected override void Apply()
        {
            var owner = Owner as Character;

            if (owner == null)
            {
                return;
            }
            switch ((ItemModType)SpellEffect.MiscValueB)
            {
            case ItemModType.Health:
                m_aura.Auras.Owner.ChangeModifier(StatModifierFloat.Health, (float)SpellEffect.MiscValue / 100);
                break;

            case ItemModType.Power:
                m_aura.Auras.Owner.ChangeModifier(StatModifierInt.PowerPct, SpellEffect.MiscValue);
                break;

            default:
                owner.ApplyStatMod((ItemModType)SpellEffect.MiscValueB, SpellEffect.MiscValue);
                break;
            }
            Asda2CharacterHandler.SendUpdateStatsOneResponse(owner.Client);
            Asda2CharacterHandler.SendUpdateStatsResponse(owner.Client);
        }
Exemplo n.º 2
0
        public void RemoveFromCharacter(Character character)
        {
            switch (Id)
            {
            case GuildSkillId.AtackPrc:
                character.RemoveStatMod(ItemModType.DamagePrc, ValueOnUse);
                character.RemoveStatMod(ItemModType.MagicDamagePrc, ValueOnUse);
                break;

            case GuildSkillId.DeffencePrc:
                character.RemoveStatMod(ItemModType.Asda2DefencePrc, ValueOnUse);
                character.RemoveStatMod(ItemModType.Asda2MagicDefencePrc, ValueOnUse);
                break;

            case GuildSkillId.MovingSpeedPrc:
                character.RemoveStatMod(ItemModType.Speed, ValueOnUse);
                break;

            case GuildSkillId.AtackSpeedPrc:
                character.RemoveStatMod(ItemModType.AtackTimePrc, -ValueOnUse);
                break;

            case GuildSkillId.Expirience:
                character.RemoveStatMod(ItemModType.Asda2Expirience, ValueOnUse);
                break;
            }

            Asda2CharacterHandler.SendUpdateStatsOneResponse(character.Client);
            Asda2CharacterHandler.SendUpdateStatsResponse(character.Client);
        }
Exemplo n.º 3
0
        protected override void Remove(bool cancelled)
        {
            Character owner = Owner as Character;

            if (owner == null)
            {
                return;
            }
            switch (SpellEffect.MiscValueB)
            {
            case 0:
                m_aura.Auras.Owner.ChangeModifier(StatModifierInt.PowerPct, -SpellEffect.MiscValue);
                break;

            case 1:
                m_aura.Auras.Owner.ChangeModifier(StatModifierFloat.Health,
                                                  (float)(-(double)SpellEffect.MiscValue / 100.0));
                break;

            default:
                owner.RemoveStatMod((ItemModType)SpellEffect.MiscValueB, SpellEffect.MiscValue);
                break;
            }

            Asda2CharacterHandler.SendUpdateStatsOneResponse(owner.Client);
            Asda2CharacterHandler.SendUpdateStatsResponse(owner.Client);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Re-calculates the mainhand melee damage of this Unit
        /// References:
        /// http://www.wowwiki.com/Attack_power
        /// </summary>
        internal static void UpdateMainDamage(this Unit unit)
        {
            float        num1       = 0.0f;
            float        num2       = 0.0f;
            float        num3       = 0.0f;
            float        num4       = 0.0f;
            IAsda2Weapon mainWeapon = unit.MainWeapon;

            foreach (DamageInfo damage in mainWeapon.Damages)
            {
                if (damage.School == DamageSchoolMask.Magical)
                {
                    num3 += UnitUpdates.CalcMagicDamage(unit, damage.Minimum);
                    num4 += UnitUpdates.CalcMagicDamage(unit, damage.Maximum);
                }
                else
                {
                    num1 += UnitUpdates.GetModifiedDamage(unit, damage.Minimum);
                    num2 += UnitUpdates.GetModifiedDamage(unit, damage.Maximum);
                }
            }

            unit.MinDamage      = num1 + (float)mainWeapon.BonusDamage;
            unit.MaxDamage      = num2 + (float)mainWeapon.BonusDamage;
            unit.MinMagicDamage = (int)num3;
            unit.MaxMagicDamage = (int)num4;
            Character character = unit as Character;

            if (character == null)
            {
                return;
            }
            Asda2CharacterHandler.SendUpdateStatsResponse(character.Client);
        }
Exemplo n.º 5
0
            public override void Process(CmdTrigger <RealmServerCmdArgs> trigger)
            {
                var movId = (short)trigger.Text.NextInt(1);

                foreach (var chr in trigger.Args.Character.GetNearbyCharacters(true))
                {
                    Asda2CharacterHandler.SendEmoteResponse(chr, movId);
                }
            }
Exemplo n.º 6
0
            public override void Process(CmdTrigger <RealmServerCmdArgs> trigger)
            {
                short emote = (short)trigger.Text.NextInt(1);

                foreach (Character nearbyCharacter in (IEnumerable <Character>)trigger.Args.Character
                         .GetNearbyCharacters <Character>(true))
                {
                    Asda2CharacterHandler.SendEmoteResponse(nearbyCharacter, emote, (byte)1, 0.0596617f, -0.9982219f);
                }
            }
Exemplo n.º 7
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.º 8
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);
        }
Exemplo n.º 9
0
        public static void UseSummonScrollRequest(IRealmClient client, RealmPacketIn packet)
        {
            packet.Position += 2;
            string    name      = packet.ReadAsdaString(20, Locale.Start);
            Character character = World.GetCharacter(name, false);

            if (character == null)
            {
                client.ActiveCharacter.SendSystemMessage(string.Format("{0} is not in game.", (object)name));
            }
            else if (character.IsAsda2BattlegroundInProgress)
            {
                client.ActiveCharacter.SendSystemMessage(string.Format("{0} is on war.", (object)name));
            }
            else if (client.ActiveCharacter.IsAsda2BattlegroundInProgress)
            {
                client.ActiveCharacter.SendSystemMessage("You cant teleport on war.");
            }
            else if (client.ActiveCharacter.Name == character.Name)
            {
                client.ActiveCharacter.SendSystemMessage("You cant teleport oneself.");
            }
            else
            {
                bool flag = client.ActiveCharacter.Asda2Inventory.UseTeleportScroll(true);
                AchievementProgressRecord progressRecord =
                    client.ActiveCharacter.Achievements.GetOrCreateProgressRecord(90U);
                switch (++progressRecord.Counter)
                {
                case 50:
                    client.ActiveCharacter.Map.CallDelayed(500,
                                                           (Action)(() => client.ActiveCharacter.DiscoverTitle(Asda2TitleId.Lonely224)));
                    break;

                case 100:
                    client.ActiveCharacter.Map.CallDelayed(500,
                                                           (Action)(() => client.ActiveCharacter.GetTitle(Asda2TitleId.Lonely224)));
                    break;
                }

                progressRecord.SaveAndFlush();
                if (flag)
                {
                    Asda2CharacterHandler.SendSummonChar(client.ActiveCharacter, character);
                }
                else
                {
                    client.ActiveCharacter.SendSystemMessage("You have not summon scroll");
                }
            }
        }
Exemplo n.º 10
0
 public void DecreaseDurability(byte i, bool silent = false)
 {
     if (Durability < i)
     {
         Durability = 0;
         OnUnEquip();
     }
     else
     {
         Durability -= i;
     }
     if (!silent)
     {
         Asda2CharacterHandler.SendUpdateDurabilityResponse(OwningCharacter.Client, this);
     }
 }
Exemplo n.º 11
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);
        }
Exemplo n.º 12
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);
                }
            }
        }
Exemplo n.º 13
0
 protected override void Remove(bool cancelled)
 {
     Character owner = this.Owner as Character;
     if (owner == null)
         return;
     owner.RemoveStatMod(ItemModType.AgilityPrc, this.SpellEffect.MiscValue);
     owner.RemoveStatMod(ItemModType.LuckPrc, this.SpellEffect.MiscValue);
     owner.RemoveStatMod(ItemModType.IntelectPrc, this.SpellEffect.MiscValue);
     owner.RemoveStatMod(ItemModType.StaminaPrc, this.SpellEffect.MiscValue);
     owner.RemoveStatMod(ItemModType.StrengthPrc, this.SpellEffect.MiscValue);
     owner.RemoveStatMod(ItemModType.EnergyPrc, this.SpellEffect.MiscValue);
     owner.RemoveStatMod(ItemModType.DamagePrc, this.SpellEffect.MiscValue);
     owner.RemoveStatMod(ItemModType.MagicDamagePrc, this.SpellEffect.MiscValue);
     owner.RemoveStatMod(ItemModType.Health, this.SpellEffect.MiscValue);
     owner.RemoveStatMod(ItemModType.Power, this.SpellEffect.MiscValue);
     owner.RemoveStatMod(ItemModType.Speed, this.SpellEffect.MiscValue);
     owner.RemoveStatMod(ItemModType.AtackTimePrc, -this.SpellEffect.MiscValue);
     Asda2CharacterHandler.SendUpdateStatsOneResponse(owner.Client);
     Asda2CharacterHandler.SendUpdateStatsResponse(owner.Client);
 }
Exemplo n.º 14
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);
        }
Exemplo n.º 15
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);
        }
Exemplo n.º 16
0
        protected override void Apply()
        {
            var owner = Owner as Character;

            if (owner == null)
            {
                return;
            }
            owner.ApplyStatMod(ItemModType.AgilityPrc, SpellEffect.MiscValue);
            owner.ApplyStatMod(ItemModType.LuckPrc, SpellEffect.MiscValue);
            owner.ApplyStatMod(ItemModType.IntelectPrc, SpellEffect.MiscValue);
            owner.ApplyStatMod(ItemModType.StaminaPrc, SpellEffect.MiscValue);
            owner.ApplyStatMod(ItemModType.StrengthPrc, SpellEffect.MiscValue);
            owner.ApplyStatMod(ItemModType.EnergyPrc, SpellEffect.MiscValue);
            owner.ApplyStatMod(ItemModType.DamagePrc, SpellEffect.MiscValue);
            owner.ApplyStatMod(ItemModType.MagicDamagePrc, SpellEffect.MiscValue);
            owner.ApplyStatMod(ItemModType.Health, SpellEffect.MiscValue);
            owner.ApplyStatMod(ItemModType.Power, SpellEffect.MiscValue);
            owner.ApplyStatMod(ItemModType.Speed, SpellEffect.MiscValue);
            owner.ApplyStatMod(ItemModType.AtackTimePrc, -SpellEffect.MiscValue);
            Asda2CharacterHandler.SendUpdateStatsOneResponse(owner.Client);
            Asda2CharacterHandler.SendUpdateStatsResponse(owner.Client);
        }
Exemplo n.º 17
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);
            });
        }
Exemplo n.º 18
0
        private static void ProcessFunctionalItem(IRealmClient client, uint parametr, short slot)
        {
            Asda2Item item = client.ActiveCharacter.Asda2Inventory.GetShopShopItem(slot);

            if (item == null)
            {
                FunctionalItemsHandler.SendUpdateShopItemInfoResponse(client,
                                                                      UseFunctionalItemError.FunctionalItemDoesNotExist, (Asda2Item)null);
            }
            else
            {
                UseFunctionalItemError status = UseFunctionalItemError.Ok;
                if ((int)item.RequiredLevel > client.ActiveCharacter.Level)
                {
                    FunctionalItemsHandler.SendUpdateShopItemInfoResponse(client,
                                                                          UseFunctionalItemError.YorLevelIsNotHightEnoght, item);
                }
                else
                {
                    ServerApp <WCell.RealmServer.RealmServer> .IOQueue.AddMessage((Action)(() =>
                    {
                        try
                        {
                            switch (item.Category)
                            {
                            case Asda2ItemCategory.IncPAtk:
                                client.ActiveCharacter.ApplyFunctionItemBuff(item.ItemId, false);
                                FunctionalItemsHandler.SendShopItemUsedResponse(client, item.ItemId,
                                                                                (int)item.Template.AtackRange);
                                break;

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

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

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

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

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

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

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

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

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

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

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

                            case Asda2ItemCategory.IncMoveSpeed:
                                if (client.ActiveCharacter.LastTransportUsedTime +
                                    TimeSpan.FromMilliseconds(30000.0) > DateTime.Now)
                                {
                                    status = UseFunctionalItemError.CoolingTimeRemain;
                                    break;
                                }

                                if (item.Record.IsSoulBound && item.Record.AuctionEndTime != DateTime.MinValue &&
                                    DateTime.Now > item.Record.AuctionEndTime)
                                {
                                    Asda2InventoryHandler.ItemRemovedFromInventoryResponse(client.ActiveCharacter,
                                                                                           item, DeleteOrSellItemStatus.Ok, 0);
                                    item.Destroy();
                                    client.ActiveCharacter.SendInfoMsg("Vehicle expired.");
                                    status = UseFunctionalItemError.TheDurationOfTheShopitemHaExprised;
                                    break;
                                }

                                if (item.Record.AuctionEndTime == DateTime.MinValue)
                                {
                                    item.Record.AuctionEndTime =
                                        DateTime.Now + TimeSpan.FromDays((double)item.AttackTime);
                                }
                                client.ActiveCharacter.LastTransportUsedTime = DateTime.Now;
                                item.IsSoulbound = true;
                                client.ActiveCharacter.TransportItemId = item.ItemId;
                                AchievementProgressRecord progressRecord1 =
                                    client.ActiveCharacter.Achievements.GetOrCreateProgressRecord(85U);
                                switch (++progressRecord1.Counter)
                                {
                                case 1:
                                    client.ActiveCharacter.Map.CallDelayed(500,
                                                                           (Action)(() =>
                                                                                    client.ActiveCharacter.DiscoverTitle(Asda2TitleId.Rapid219)));
                                    break;

                                case 1000:
                                    client.ActiveCharacter.Map.CallDelayed(500,
                                                                           (Action)(() =>
                                                                                    client.ActiveCharacter.GetTitle(Asda2TitleId.Rapid219)));
                                    break;
                                }

                                progressRecord1.SaveAndFlush();
                                break;

                            case Asda2ItemCategory.IncExp:
                                client.ActiveCharacter.ApplyFunctionItemBuff(item.ItemId, false);
                                FunctionalItemsHandler.SendShopItemUsedResponse(client, item.ItemId,
                                                                                (int)item.Template.AtackRange);
                                break;

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

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

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

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

                            case Asda2ItemCategory.ExpandWarehouse:
                                if (client.ActiveCharacter.Record.PremiumWarehouseBagsCount >= (byte)8)
                                {
                                    status = UseFunctionalItemError.WarehouseHasReachedMaxCapacity;
                                    break;
                                }

                                ++client.ActiveCharacter.Record.PremiumWarehouseBagsCount;
                                FunctionalItemsHandler.SendWarehouseSlotsExpandedResponse(client, false);
                                break;

                            case Asda2ItemCategory.ResetAllSkill:
                                FunctionalItemsHandler.ResetSkills(client.ActiveCharacter);
                                Asda2CharacterHandler.SendLearnedSkillsInfo(client.ActiveCharacter);
                                AchievementProgressRecord progressRecord2 =
                                    client.ActiveCharacter.Achievements.GetOrCreateProgressRecord(84U);
                                switch (++progressRecord2.Counter)
                                {
                                case 3:
                                    client.ActiveCharacter.Map.CallDelayed(500,
                                                                           (Action)(() =>
                                                                                    client.ActiveCharacter.DiscoverTitle(Asda2TitleId
                                                                                                                         .Perfectionist218)));
                                    break;

                                case 5:
                                    client.ActiveCharacter.Map.CallDelayed(500,
                                                                           (Action)(() =>
                                                                                    client.ActiveCharacter.GetTitle(Asda2TitleId.Perfectionist218)));
                                    break;
                                }

                                progressRecord2.SaveAndFlush();
                                break;

                            case Asda2ItemCategory.ResetOneSkill:
                                Spell spell1 =
                                    client.ActiveCharacter.Spells.First <Spell>(
                                        (Func <Spell, bool>)(s => (long)s.RealId == (long)parametr));
                                if (spell1 != null)
                                {
                                    int num1 = 0 + spell1.Cost;
                                    for (int index = spell1.Level - 1; index > 0; --index)
                                    {
                                        Spell spell2 =
                                            SpellHandler.Get((uint)spell1.RealId + (uint)(index * 1000));
                                        if (spell2 != null)
                                        {
                                            num1 += spell2.Cost;
                                        }
                                    }

                                    uint num2 = (uint)(num1 / 2);
                                    client.ActiveCharacter.Spells.Remove(spell1);
                                    client.ActiveCharacter.AddMoney(num2);
                                    Asda2CharacterHandler.SendPreResurectResponse(client.ActiveCharacter);
                                    FunctionalItemsHandler.SendSkillResetedResponse(client, spell1.RealId,
                                                                                    (short)spell1.Level, num2);
                                    Asda2CharacterHandler.SendUpdateStatsOneResponse(client);
                                    Asda2CharacterHandler.SendUpdateStatsResponse(client);
                                    client.ActiveCharacter.SendMoneyUpdate();
                                    AchievementProgressRecord progressRecord3 =
                                        client.ActiveCharacter.Achievements.GetOrCreateProgressRecord(84U);
                                    switch (++progressRecord3.Counter)
                                    {
                                    case 3:
                                        client.ActiveCharacter.Map.CallDelayed(500,
                                                                               (Action)(() =>
                                                                                        client.ActiveCharacter.DiscoverTitle(Asda2TitleId
                                                                                                                             .Perfectionist218)));
                                        break;

                                    case 5:
                                        client.ActiveCharacter.Map.CallDelayed(500,
                                                                               (Action)(() =>
                                                                                        client.ActiveCharacter.GetTitle(Asda2TitleId
                                                                                                                        .Perfectionist218)));
                                        break;
                                    }

                                    progressRecord3.SaveAndFlush();
                                    break;
                                }

                                status = UseFunctionalItemError.FailedToUse;
                                client.ActiveCharacter.SendInfoMsg("Skill is not learned. Restart client.");
                                break;

                            case Asda2ItemCategory.TeleportToCharacter:
                                if (parametr >= 10U || client.ActiveCharacter.TeleportPoints[parametr] == null)
                                {
                                    status = UseFunctionalItemError.FailedToUse;
                                    break;
                                }

                                Asda2TeleportingPointRecord teleportPoint =
                                    client.ActiveCharacter.TeleportPoints[parametr];
                                client.ActiveCharacter.TeleportTo(teleportPoint.MapId,
                                                                  new Vector3((float)teleportPoint.X, (float)teleportPoint.Y));
                                AchievementProgressRecord progressRecord4 =
                                    client.ActiveCharacter.Achievements.GetOrCreateProgressRecord(89U);
                                switch (++progressRecord4.Counter)
                                {
                                case 50:
                                    client.ActiveCharacter.Map.CallDelayed(500,
                                                                           (Action)(() =>
                                                                                    client.ActiveCharacter.DiscoverTitle(Asda2TitleId.Traveler223)));
                                    break;

                                case 100:
                                    client.ActiveCharacter.Map.CallDelayed(500,
                                                                           (Action)(() =>
                                                                                    client.ActiveCharacter.GetTitle(Asda2TitleId.Traveler223)));
                                    break;
                                }

                                progressRecord4.SaveAndFlush();
                                break;

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

                                client.ActiveCharacter.Last100PrcRecoveryUsed = (uint)Environment.TickCount;
                                client.ActiveCharacter.HealPercent(100, (Unit)null, (SpellEffect)null);
                                break;

                            case Asda2ItemCategory.InstantRecover100PrcHPandMP:
                                if (client.ActiveCharacter.Last100PrcRecoveryUsed + 30000U <
                                    (uint)Environment.TickCount)
                                {
                                    status = UseFunctionalItemError.CoolingTimeRemain;
                                }
                                client.ActiveCharacter.HealPercent(100, (Unit)null, (SpellEffect)null);
                                client.ActiveCharacter.Power = client.ActiveCharacter.MaxPower;
                                client.ActiveCharacter.Last100PrcRecoveryUsed = (uint)Environment.TickCount;
                                break;

                            case Asda2ItemCategory.RecoverHp10TimesByPrcOver30Sec:
                                PereodicAction pereodicAction = (PereodicAction)null;
                                if (client.ActiveCharacter.PereodicActions.ContainsKey(Asda2PereodicActionType
                                                                                       .HpRegenPrc))
                                {
                                    pereodicAction =
                                        client.ActiveCharacter.PereodicActions[Asda2PereodicActionType.HpRegenPrc];
                                }
                                if (pereodicAction != null && pereodicAction.CallsNum >= 10 &&
                                    pereodicAction.Value >= item.Template.ValueOnUse)
                                {
                                    status = UseFunctionalItemError.CoolingTimeRemain;
                                    break;
                                }

                                if (client.ActiveCharacter.PereodicActions.ContainsKey(Asda2PereodicActionType
                                                                                       .HpRegenPrc))
                                {
                                    client.ActiveCharacter.PereodicActions.Remove(
                                        Asda2PereodicActionType.HpRegenPrc);
                                }
                                client.ActiveCharacter.PereodicActions.Add(Asda2PereodicActionType.HpRegenPrc,
                                                                           new PereodicAction(client.ActiveCharacter, item.Template.ValueOnUse, 10, 3000,
                                                                                              Asda2PereodicActionType.HpRegenPrc));
                                break;

                            case Asda2ItemCategory.ShopBanner:
                                if (client.ActiveCharacter.Level < 10)
                                {
                                    status = UseFunctionalItemError.YorLevelIsNotHightEnoght;
                                    break;
                                }

                                FunctionalItemsHandler.SendPremiumLongBuffInfoResponse(client,
                                                                                       (byte)client.ActiveCharacter.ApplyFunctionItemBuff(item.ItemId, true),
                                                                                       item.ItemId, (short)item.Template.PackageId);
                                break;

                            case Asda2ItemCategory.OpenWarehouse:
                                break;

                            case Asda2ItemCategory.PremiumPotions:
                                FunctionalItemsHandler.SendPremiumLongBuffInfoResponse(client,
                                                                                       (byte)client.ActiveCharacter.ApplyFunctionItemBuff(item.ItemId, true),
                                                                                       item.ItemId, (short)item.Template.PackageId);
                                client.ActiveCharacter.Asda2WingsItemId = (short)item.ItemId;
                                AchievementProgressRecord progressRecord5 =
                                    client.ActiveCharacter.Achievements.GetOrCreateProgressRecord(86U);
                                switch (++progressRecord5.Counter)
                                {
                                case 50:
                                    client.ActiveCharacter.Map.CallDelayed(500,
                                                                           (Action)(() =>
                                                                                    client.ActiveCharacter.DiscoverTitle(Asda2TitleId.Winged220)));
                                    break;

                                case 100:
                                    client.ActiveCharacter.Map.CallDelayed(500,
                                                                           (Action)(() =>
                                                                                    client.ActiveCharacter.GetTitle(Asda2TitleId.Winged220)));
                                    break;
                                }

                                progressRecord5.SaveAndFlush();
                                break;

                            case Asda2ItemCategory.ExpandInventory:
                                FunctionalItemsHandler.SendPremiumLongBuffInfoResponse(client,
                                                                                       (byte)client.ActiveCharacter.ApplyFunctionItemBuff(item.ItemId, true),
                                                                                       item.ItemId, (short)item.Template.PackageId);
                                AchievementProgressRecord progressRecord6 =
                                    client.ActiveCharacter.Achievements.GetOrCreateProgressRecord(87U);
                                switch (++progressRecord6.Counter)
                                {
                                case 3:
                                    client.ActiveCharacter.Map.CallDelayed(500,
                                                                           (Action)(() =>
                                                                                    client.ActiveCharacter.DiscoverTitle(Asda2TitleId.Packrat221)));
                                    break;

                                case 5:
                                    client.ActiveCharacter.Map.CallDelayed(500,
                                                                           (Action)(() =>
                                                                                    client.ActiveCharacter.GetTitle(Asda2TitleId.Packrat221)));
                                    break;
                                }

                                progressRecord6.SaveAndFlush();
                                break;

                            case Asda2ItemCategory.PetNotEatingByDays:
                                FunctionalItemsHandler.SendPremiumLongBuffInfoResponse(client,
                                                                                       (byte)client.ActiveCharacter.ApplyFunctionItemBuff(item.ItemId, true),
                                                                                       item.ItemId, (short)item.Template.PackageId);
                                client.ActiveCharacter.Map.CallDelayed(500,
                                                                       (Action)(() => client.ActiveCharacter.GetTitle(Asda2TitleId.Treat366)));
                                break;

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

                            default:
                                status = UseFunctionalItemError.NotAunctionalItem;
                                break;
                            }
                        }
                        catch (AlreadyBuffedExcepton ex)
                        {
                            status = UseFunctionalItemError.AlreadyFeelingTheEffectOfSimilarSkillType;
                        }

                        if (status == UseFunctionalItemError.Ok && item.Category != Asda2ItemCategory.IncMoveSpeed)
                        {
                            item.ModAmount(-1);
                        }
                        FunctionalItemsHandler.SendUpdateShopItemInfoResponse(client, status, item);
                    }));
                }
            }
        }