Ejemplo n.º 1
0
 public static void SendLocationSavedResponse(IRealmClient client, LocationSavedStatus status,
                                              Asda2TeleportingPointRecord rec, short pointNum)
 {
     using (RealmPacketOut packet = new RealmPacketOut(RealmServerOpCode.ItemsFromAvatarWhRetrived))
     {
         packet.WriteByte((byte)status);
         packet.WriteFixedAsciiString(rec == null ? "" : rec.Name, 32, Locale.Start);
         packet.WriteByte(0);
         byte val = rec == null ? (byte)0 : (byte)rec.MapId;
         packet.WriteByte(val);
         packet.WriteInt16(pointNum);
         packet.WriteInt16(rec == null ? 0 : rec.X - 1000 * val);
         packet.WriteInt16(rec == null ? 0 : rec.Y - 1000 * val);
         client.Send(packet, true);
     }
 }
Ejemplo n.º 2
0
        public static void DeleteSavedLocationRequest(IRealmClient client, RealmPacketIn packet)
        {
            byte num = packet.ReadByte();

            if (client.ActiveCharacter.TeleportPoints[num] == null)
            {
                client.ActiveCharacter.SendInfoMsg("Can't delete, point not founded.");
                SendSavedLocationDeletedResponse(client, LocationSavedStatus.Fail, -1);
            }
            else
            {
                Asda2TeleportingPointRecord teleportPoint = client.ActiveCharacter.TeleportPoints[num];
                client.ActiveCharacter.TeleportPoints[num] = null;
                teleportPoint.DeleteLater();
                SendSavedLocationDeletedResponse(client, LocationSavedStatus.Ok, num);
            }
        }
Ejemplo n.º 3
0
        public static void SaveLocationRequest(IRealmClient client, RealmPacketIn packet)
        {
            string name = packet.ReadAsdaString(32, Locale.Start);

            ++packet.Position;
            int    num1     = packet.ReadByte();
            ushort pointNum = packet.ReadUInt16();
            int    num2     = packet.ReadInt16();
            int    num3     = packet.ReadInt16();

            if (pointNum > 9)
            {
                client.ActiveCharacter.YouAreFuckingCheater("Trying to save teleportation point with id more than 9.",
                                                            50);
                SendLocationSavedResponse(client, LocationSavedStatus.Fail,
                                          null, 0);
            }
            else if (client.ActiveCharacter.TeleportPoints[pointNum] == null)
            {
                ServerApp <RealmServer> .IOQueue.AddMessage(() =>
                {
                    Asda2TeleportingPointRecord record = Asda2TeleportingPointRecord.CreateRecord(
                        client.ActiveCharacter.EntityId.Low, (short)client.ActiveCharacter.Position.X,
                        (short)client.ActiveCharacter.Position.Y, client.ActiveCharacter.MapId);
                    record.CreateLater();
                    client.ActiveCharacter.TeleportPoints[pointNum] = record;
                    record.X     = (short)client.ActiveCharacter.Position.X;
                    record.Y     = (short)client.ActiveCharacter.Position.Y;
                    record.MapId = client.ActiveCharacter.MapId;
                    record.Name  = name;
                    SendLocationSavedResponse(client, LocationSavedStatus.Ok, record,
                                              (short)pointNum);
                });
            }
            else
            {
                Asda2TeleportingPointRecord teleportPoint = client.ActiveCharacter.TeleportPoints[pointNum];
                teleportPoint.X     = (short)client.ActiveCharacter.Position.X;
                teleportPoint.Y     = (short)client.ActiveCharacter.Position.Y;
                teleportPoint.MapId = client.ActiveCharacter.MapId;
                teleportPoint.Name  = name;
                teleportPoint.SaveLater();
                SendLocationSavedResponse(client, LocationSavedStatus.Ok, teleportPoint,
                                          (short)pointNum);
            }
        }
Ejemplo n.º 4
0
        public static void SendSavedLocationsInitResponse(IRealmClient client)
        {
            using (RealmPacketOut packet = new RealmPacketOut(RealmServerOpCode.SavedLocationsInit))
            {
                packet.WriteByte(1);
                for (int index = 0; index < client.ActiveCharacter.TeleportPoints.Length; ++index)
                {
                    Asda2TeleportingPointRecord teleportPoint = client.ActiveCharacter.TeleportPoints[index];
                    packet.WriteFixedAsciiString(teleportPoint == null ? "" : teleportPoint.Name, 32, Locale.Start);
                    packet.WriteByte(0);
                    byte val = teleportPoint == null ? (byte)0 : (byte)teleportPoint.MapId;
                    packet.WriteByte(val);
                    packet.WriteInt16(teleportPoint == null ? -1 : index);
                    packet.WriteInt16(teleportPoint == null ? 0 : teleportPoint.X - 1000 * val);
                    packet.WriteInt16(teleportPoint == null ? 0 : teleportPoint.Y - 1000 * val);
                }

                client.Send(packet, true);
            }
        }
Ejemplo n.º 5
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);
                    }));
                }
            }
        }