Ejemplo n.º 1
0
        public override void Process(CmdTrigger <RealmServerCmdArgs> trigger)
        {
            Character targetChr = trigger.Args.Target as Character;

            if (targetChr == null)
            {
                trigger.Reply("Wrong target.");
            }
            else
            {
                Asda2ItemTemplate templ =
                    Asda2ItemMgr.GetTemplate(trigger.Text.NextEnum <Asda2ItemId>(Asda2ItemId.None));
                if (templ == null)
                {
                    trigger.Reply("Invalid ItemId.");
                }
                else
                {
                    int amount = trigger.Text.NextInt(1);
                    if (amount <= 0)
                    {
                        trigger.Reply("Wrong amount.");
                    }
                    else
                    {
                        ServerApp <WCell.RealmServer.RealmServer> .IOQueue.AddMessage((Action)(() =>
                                                                                               targetChr.Asda2Inventory.AddDonateItem(templ, amount, trigger.Args.Character.Name, false)));
                    }
                }
            }
        }
Ejemplo n.º 2
0
            public static bool AddItem(Character chr, Asda2ItemTemplate templ, int amount, Character triggerer)
            {
                int num = amount;
                Asda2PlayerInventory asda2Inventory      = chr.Asda2Inventory;
                Asda2Item            asda2Item           = (Asda2Item)null;
                Asda2InventoryError  asda2InventoryError = asda2Inventory.TryAdd((int)templ.ItemId, amount, false,
                                                                                 ref asda2Item, new Asda2InventoryType?(), (Asda2Item)null);

                if (asda2InventoryError != Asda2InventoryError.Ok || amount < num)
                {
                    if (asda2InventoryError != Asda2InventoryError.Ok)
                    {
                        Asda2InventoryHandler.SendItemReplacedResponse(chr.Client, Asda2InventoryError.NotInfoAboutItem,
                                                                       (short)0, (byte)0, 0, (short)0, 0, (byte)0, 0, (short)0, false);
                    }
                    return(false);
                }

                Log.Create(Log.Types.ItemOperations, LogSourceType.Character, chr.EntryId)
                .AddAttribute("source", 0.0, "created_by_gm").AddItemAttributes(asda2Item, "")
                .AddAttribute("map", (double)chr.MapId, chr.MapId.ToString())
                .AddAttribute("x", (double)chr.Asda2Position.X, "")
                .AddAttribute("y", (double)chr.Asda2Position.Y, "")
                .AddAttribute("gm", (double)triggerer.EntryId, triggerer.Name).Write();
                Asda2InventoryHandler.SendBuyItemResponse(Asda2BuyItemStatus.Ok, chr, new Asda2Item[5]
                {
                    asda2Item,
                    null,
                    null,
                    null,
                    null
                });
                return(true);
            }
Ejemplo n.º 3
0
            public override void Process(CmdTrigger <RealmServerCmdArgs> trigger)
            {
                int id = trigger.Text.NextInt(20622);

                if (trigger.Args.Target is Character)
                {
                    Asda2NPCLoot      asda2NpcLoot = new Asda2NPCLoot();
                    Asda2ItemTemplate templ        = Asda2ItemMgr.GetTemplate(id) ?? Asda2ItemMgr.GetTemplate(20622);
                    asda2NpcLoot.Items = new Asda2LootItem[1]
                    {
                        new Asda2LootItem(templ, 1, 0U)
                        {
                            Loot = (Asda2Loot)asda2NpcLoot
                        }
                    };
                    asda2NpcLoot.Lootable = (IAsda2Lootable)trigger.Args.Character;
                    asda2NpcLoot.Looters.Add(new Asda2LooterEntry(trigger.Args.Character));
                    asda2NpcLoot.MonstrId = new short?((short)12345);
                    trigger.Args.Character.Map.SpawnLoot((Asda2Loot)asda2NpcLoot);
                    trigger.Reply("Done.");
                }
                else
                {
                    trigger.Reply("Wrong target.");
                }
            }
Ejemplo n.º 4
0
            public static bool AddItem(Character chr, Asda2ItemTemplate templ, int amount, Character triggerer)
            {
                var actualAmount = amount;
                var inv          = chr.Asda2Inventory;

                // just add
                Asda2Item           item = null;
                Asda2InventoryError err  = inv.TryAdd((int)templ.ItemId, amount, false, ref item);

                if (err != Asda2InventoryError.Ok || amount < actualAmount)
                {
                    // something went wrong
                    if (err != Asda2InventoryError.Ok)
                    {
                        Asda2InventoryHandler.SendItemReplacedResponse(chr.Client);
                    }
                    return(false);
                }

                Log.Create(Log.Types.ItemOperations, LogSourceType.Character, chr.EntryId)
                .AddAttribute("source", 0, "created_by_gm")
                .AddItemAttributes(item)
                .AddAttribute("map", (double)chr.MapId, chr.MapId.ToString())
                .AddAttribute("x", chr.Asda2Position.X)
                .AddAttribute("y", chr.Asda2Position.Y)
                .AddAttribute("gm", triggerer.EntryId, triggerer.Name)
                .Write();
                Asda2InventoryHandler.SendBuyItemResponse(Asda2BuyItemStatus.Ok, chr, new[] { item, null, null, null, null });
                return(true);
            }
Ejemplo n.º 5
0
            public override void Process(CmdTrigger <RealmServerCmdArgs> trigger)
            {
                string            str      = trigger.Text.NextModifiers();
                Asda2ItemId       id       = trigger.Text.NextEnum <Asda2ItemId>(Asda2ItemId.None);
                Asda2ItemTemplate template = Asda2ItemMgr.GetTemplate(id);

                if (template == null)
                {
                    trigger.Reply("Invalid ItemId.");
                }
                else
                {
                    int amount = trigger.Text.NextInt(1);
                    if (id == Asda2ItemId.Gold20551)
                    {
                        ((Character)trigger.Args.Target).AddMoney((uint)amount);
                        ((Character)trigger.Args.Target).SendMoneyUpdate();
                    }
                    else
                    {
                        uint num1 = trigger.Text.NextUInt(1U);
                        str.Contains("a");
                        int num2 = 0;
                        while ((long)num2 < (long)num1 &&
                               InventoryCommand.ItemAddCommand.AddItem((Character)trigger.Args.Target, template,
                                                                       amount, trigger.Args.Character))
                        {
                            ++num2;
                        }
                    }
                }
            }
Ejemplo n.º 6
0
        public static Asda2ItemRecord CreateRecord(Asda2ItemTemplate templ)
        {
            Asda2ItemRecord record = Asda2ItemRecord.CreateRecord();

            record.ItemId     = (int)templ.Id;
            record.Amount     = templ.MaxAmount;
            record.Durability = templ.MaxDurability;
            record.Duration   = templ.Duration;
            record.Soul1Id    = (int)templ.DefaultSoul1Id;
            return(record);
        }
Ejemplo n.º 7
0
        public static void SendShopTradeCompleteResponse(IRealmClient client, Asda2Item[] items)
        {
            using (RealmPacketOut packet = new RealmPacketOut(RealmServerOpCode.ShopTradeComplete))
            {
                packet.WriteByte(5);
                packet.WriteInt32(client.ActiveCharacter.Asda2Inventory.Weight);
                for (int index = 0; index < 5; ++index)
                {
                    Asda2Item asda2Item = items[index];
                    packet.WriteInt32(asda2Item == null ? 0 : asda2Item.ItemId);
                    packet.WriteByte(asda2Item == null ? (byte)0 : (byte)asda2Item.InventoryType);
                    packet.WriteInt16(asda2Item == null ? -1 : asda2Item.Slot);
                    packet.WriteInt16(asda2Item == null ? -1 : (asda2Item.IsDeleted ? -1 : 0));
                    packet.WriteByte(asda2Item == null ? -1 : asda2Item.Durability);
                    packet.WriteInt16(asda2Item == null ? -1 : asda2Item.Weight);
                    packet.WriteInt32(0);
                    packet.WriteByte(asda2Item == null ? -1 : asda2Item.Enchant);
                    packet.WriteByte(0);
                    packet.WriteByte(0);
                    packet.WriteByte(0);
                    packet.WriteByte(asda2Item == null ? -1 : asda2Item.SealCount);
                    packet.WriteInt16(asda2Item == null ? -1 : (short)asda2Item.Parametr1Type);
                    packet.WriteInt16(asda2Item == null ? -1 : asda2Item.Parametr1Value);
                    packet.WriteInt16(asda2Item == null ? -1 : (short)asda2Item.Parametr2Type);
                    packet.WriteInt16(asda2Item == null ? -1 : asda2Item.Parametr2Value);
                    packet.WriteInt16(asda2Item == null ? -1 : (short)asda2Item.Parametr3Type);
                    packet.WriteInt16(asda2Item == null ? -1 : asda2Item.Parametr3Value);
                    packet.WriteInt16(asda2Item == null ? -1 : (short)asda2Item.Parametr4Type);
                    if (asda2Item != null && asda2Item.Template.IsAvatar)
                    {
                        Asda2ItemTemplate template1 = Asda2ItemMgr.GetTemplate(asda2Item.Soul2Id);
                        Asda2ItemTemplate template2 = Asda2ItemMgr.GetTemplate(asda2Item.Soul3Id);
                        packet.WriteInt16(template1 == null ? -1 : template1.SowelBonusValue);
                        packet.WriteInt16(-1);
                        packet.WriteInt16(template2 == null ? -1 : template2.SowelBonusValue);
                    }
                    else
                    {
                        packet.WriteInt16(asda2Item == null ? -1 : asda2Item.Parametr4Value);
                        packet.WriteInt16(asda2Item == null ? -1 : (short)asda2Item.Parametr5Type);
                        packet.WriteInt16(asda2Item == null ? -1 : asda2Item.Parametr5Value);
                    }

                    packet.WriteByte(0);
                    packet.WriteItemAmount(asda2Item, false);
                    packet.WriteInt16(asda2Item == null ? -1 : asda2Item.Soul1Id);
                    packet.WriteInt16(asda2Item == null ? -1 : asda2Item.Soul2Id);
                    packet.WriteInt16(asda2Item == null ? -1 : asda2Item.Soul3Id);
                    packet.WriteInt16(asda2Item == null ? -1 : asda2Item.Soul4Id);
                }

                client.Send(packet, false);
            }
        }
Ejemplo n.º 8
0
        public static Asda2ItemRecord CreateRecord(Asda2ItemTemplate templ)
        {
            var item = CreateRecord();

            item.ItemId     = (int)templ.Id;
            item.Amount     = templ.MaxAmount;
            item.Durability = templ.MaxDurability;
            item.Duration   = templ.Duration;
            item.Soul1Id    = templ.DefaultSoul1Id;
            return(item);
        }
Ejemplo n.º 9
0
 private bool IsValidSowelEquipSlot(Asda2ItemTemplate sowel)
 {
     switch (sowel.SowelEquipmentType)
     {
     default:
         if ((int)Template.EquipmentSlot != (int)sowel.SowelEquipmentType)
         {
             return(false);
         }
         break;
     }
     //Todo sowel equipent slot logic
     return(true);
 }
Ejemplo n.º 10
0
 bool IsValidSowel(Asda2ItemTemplate sowel)
 {
     if (sowel == null || sowel.Category != Asda2ItemCategory.Sowel)
     {
         return(false);
     }
     if (!IsValidSowelEquipSlot(sowel))
     {
         return(false);
     }
     if (sowel.RequiredLevel > Owner.Level)
     {
         return(false);
     }
     return(true);
 }
Ejemplo n.º 11
0
        /// <summary>
        /// Returns all Items that can be looted off the given lootable
        /// </summary>
        public static Asda2LootItem[] CreateLootItems(uint lootId, Asda2LootEntryType type,
                                                      IList <Asda2LooterEntry> looters, float dropChanceBoost)
        {
            List <Asda2LootItemEntry> entries = Asda2LootMgr.GetEntries(type, lootId);

            if (entries == null)
            {
                return(Asda2LootItem.EmptyArray);
            }
            Asda2LootItem[] array   = new Asda2LootItem[Math.Min(CharacterFormulas.MaxLootCount, entries.Count)];
            int             newSize = 0;

            foreach (Asda2LootItemEntry asda2LootItemEntry in entries)
            {
                if (100.0 * (double)Utility.RandomFloat() <
                    (double)(asda2LootItemEntry.DropChance * (Asda2LootMgr.LootItemDropFactor + dropChanceBoost)))
                {
                    Asda2ItemTemplate itemTemplate = asda2LootItemEntry.ItemTemplate;
                    if (itemTemplate != null)
                    {
                        array[newSize] = new Asda2LootItem(itemTemplate,
                                                           Utility.Random(asda2LootItemEntry.MinAmount, asda2LootItemEntry.MaxAmount), (uint)newSize);
                        ++newSize;
                        if (newSize == CharacterFormulas.MaxLootCount)
                        {
                            break;
                        }
                    }
                }
            }

            if (newSize == 0)
            {
                return(Asda2LootItem.EmptyArray);
            }
            Array.Resize <Asda2LootItem>(ref array, newSize);
            return(array);
        }
Ejemplo n.º 12
0
 public static void InitQuestGOs()
 {
     foreach (GOEntry goEntry in Entries.Values)
     {
         if (goEntry.Flags.HasFlag(GameObjectFlags.ConditionalInteraction) &&
             goEntry.Type == GameObjectType.Chest)
         {
             List <Asda2LootItemEntry> lootEntries = goEntry.GetLootEntries();
             if (lootEntries != null)
             {
                 foreach (Asda2LootEntity asda2LootEntity in lootEntries)
                 {
                     Asda2ItemTemplate itemTemplate = asda2LootEntity.ItemTemplate;
                     if (itemTemplate != null && itemTemplate.CollectQuests != null)
                     {
                         goEntry.RequiredQuests.AddRange(
                             itemTemplate.CollectQuests);
                     }
                 }
             }
         }
     }
 }
Ejemplo n.º 13
0
 public Asda2LootItem(Asda2ItemTemplate templ, int amount, uint index)
 {
     this.Template = templ;
     this.Amount   = amount;
     this.Index    = index;
 }
Ejemplo n.º 14
0
        public static void ProcessDig(IRealmClient client)
        {
            if (client.ActiveCharacter == null)
            {
                return;
            }
            Asda2Item mainWeapon = client.ActiveCharacter.MainWeapon as Asda2Item;

            if (mainWeapon == null)
            {
                return;
            }
            Asda2Item asda2Item = client.ActiveCharacter.Asda2Inventory.Equipment[10];
            bool      flag      = asda2Item != null && asda2Item.Category == Asda2ItemCategory.DigOil;

            if (flag)
            {
                --asda2Item.Amount;
            }
            if (flag)
            {
                AchievementProgressRecord progressRecord1 =
                    client.ActiveCharacter.Achievements.GetOrCreateProgressRecord(92U);
                AchievementProgressRecord progressRecord2 =
                    client.ActiveCharacter.Achievements.GetOrCreateProgressRecord(91U);
                ++progressRecord1.Counter;
                if (progressRecord1.Counter >= 1000U || progressRecord2.Counter >= 1000U)
                {
                    client.ActiveCharacter.GetTitle(Asda2TitleId.Automatic225);
                }
                progressRecord1.SaveAndFlush();
            }

            if (Utility.Random(0, 100000) > CharacterFormulas.CalculateDiggingChance(mainWeapon.Template.ValueOnUse,
                                                                                     client.ActiveCharacter.SoulmateRecord == null
             ? (byte)0
             : client.ActiveCharacter.SoulmateRecord.FriendShipPoints, client.ActiveCharacter.Asda2Luck) &&
                (flag
           ? (client.ActiveCharacter.MapId < (MapId)PremiumMapDiggingTemplates.Count ? 1 : 0)
           : (client.ActiveCharacter.MapId < (MapId)MapDiggingTemplates.Count ? 1 : 0)) != 0)
            {
                Asda2DiggingHandler.SendDigEndedResponse(client, true, asda2Item);
                MineTableRecord mineTableRecord =
                    flag
            ? PremiumMapDiggingTemplates[(byte)client.ActiveCharacter.MapId]
            : MapDiggingTemplates[(byte)client.ActiveCharacter.MapId];
                int               randomItem   = mineTableRecord.GetRandomItem();
                Asda2NPCLoot      asda2NpcLoot = new Asda2NPCLoot();
                Asda2ItemTemplate templ        = Asda2ItemMgr.GetTemplate(randomItem) ?? Asda2ItemMgr.GetTemplate(20622);
                asda2NpcLoot.Items = new Asda2LootItem[1]
                {
                    new Asda2LootItem(templ, 1, 0U)
                    {
                        Loot = asda2NpcLoot
                    }
                };
                asda2NpcLoot.Lootable = client.ActiveCharacter;
                asda2NpcLoot.Looters.Add(new Asda2LooterEntry(client.ActiveCharacter));
                asda2NpcLoot.MonstrId = 22222;
                if ((int)templ.ItemId >= 33542 && 33601 <= (int)templ.ItemId)
                {
                    AchievementProgressRecord progressRecord =
                        client.ActiveCharacter.Achievements.GetOrCreateProgressRecord(125U);
                    switch (++progressRecord.Counter)
                    {
                    case 250:
                        client.ActiveCharacter.DiscoverTitle(Asda2TitleId.Astrological292);
                        break;

                    case 500:
                        client.ActiveCharacter.GetTitle(Asda2TitleId.Astrological292);
                        break;
                    }

                    progressRecord.SaveAndFlush();
                }

                if (templ.ItemId == Asda2ItemId.TreasureBox31407 || templ.ItemId == Asda2ItemId.GoldenTreasureBox31408)
                {
                    AchievementProgressRecord progressRecord1 =
                        client.ActiveCharacter.Achievements.GetOrCreateProgressRecord(126U);
                    switch (++progressRecord1.Counter)
                    {
                    case 25:
                        client.ActiveCharacter.DiscoverTitle(Asda2TitleId.Treasure293);
                        break;

                    case 50:
                        client.ActiveCharacter.GetTitle(Asda2TitleId.Treasure293);
                        break;
                    }

                    progressRecord1.SaveAndFlush();
                    if (templ.ItemId == Asda2ItemId.GoldenTreasureBox31408)
                    {
                        AchievementProgressRecord progressRecord2 =
                            client.ActiveCharacter.Achievements.GetOrCreateProgressRecord((uint)sbyte.MaxValue);
                        switch (++progressRecord2.Counter)
                        {
                        case 389:
                            client.ActiveCharacter.DiscoverTitle(Asda2TitleId.Lucky295);
                            break;

                        case 777:
                            client.ActiveCharacter.GetTitle(Asda2TitleId.Lucky295);
                            break;
                        }

                        progressRecord2.SaveAndFlush();
                    }
                }

                client.ActiveCharacter.Map.SpawnLoot(asda2NpcLoot);
                client.ActiveCharacter.GainXp(
                    CharacterFormulas.CalcDiggingExp(client.ActiveCharacter.Level, mineTableRecord.MinLevel), "digging",
                    false);
                client.ActiveCharacter.GuildPoints += CharacterFormulas.DiggingGuildPoints;
            }
            else
            {
                Asda2DiggingHandler.SendDigEndedResponse(client, false, asda2Item);
            }

            client.ActiveCharacter.IsDigging = false;
            --client.ActiveCharacter.Stunned;
        }
Ejemplo n.º 15
0
 public Asda2LootItem(Asda2ItemTemplate templ, int amount, uint index)
 {
     Template = templ;
     Amount   = amount;
     Index    = index;
 }