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

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

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

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

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

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

            client.ActiveCharacter.IsDigging = false;
            client.ActiveCharacter.Stunned--;
        }
Esempio n. 2
0
            public override void Process(CmdTrigger <RealmServerCmdArgs> trigger)
            {
                var id        = trigger.Text.NextInt(20622);
                var character = trigger.Args.Target as Character;

                if (character != null)
                {
                    var loot      = new Asda2NPCLoot();
                    var itemTempl = Asda2ItemMgr.GetTemplate(id) ?? Asda2ItemMgr.GetTemplate(20622);
                    loot.Items = new[] { new Asda2LootItem(itemTempl, 1, 0)
                                         {
                                             Loot = loot
                                         } };
                    loot.Lootable = trigger.Args.Character;
                    loot.Looters.Add(new Asda2LooterEntry(trigger.Args.Character));
                    loot.MonstrId = 12345;
                    trigger.Args.Character.Map.SpawnLoot(loot);
                    trigger.Reply("Done.");
                }
                else
                {
                    trigger.Reply("Wrong target.");
                }
            }
Esempio n. 3
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;
        }