예제 #1
0
        public RebornEnum Reborn()
        {
            if (CurrentAccount == null || CurrentAccount.ActiveCharacter == null)
            {
                return(RebornEnum.Error);
            }
            if (CurrentAccount.ActiveCharacter.IsAsda2BattlegroundInProgress)
            {
                return(RebornEnum.YouMustLeaveWar);
            }
            if (CurrentAccount.ActiveCharacter.Level < CharacterFormulas.RebornLevel)
            {
                return(RebornEnum.YouMustReachAtLeast80Level);
            }
            foreach (Asda2Item asda2Item in CurrentAccount.ActiveCharacter.Asda2Inventory.Equipment)
            {
                if (asda2Item != null)
                {
                    return(RebornEnum.YouMustPutOffCloses);
                }
            }

            if (CurrentAccount.ActiveCharacter.IsReborning)
            {
                return(RebornEnum.Error);
            }
            CurrentAccount.ActiveCharacter.IsReborning = true;
            CurrentAccount.ActiveCharacter.AddMessage(() =>
            {
                ++CurrentAccount.ActiveCharacter.Record.RebornCount;
                FunctionalItemsHandler.ResetSkills(CurrentAccount.ActiveCharacter);
                CurrentAccount.ActiveCharacter.SetClass(CurrentAccount.ActiveCharacter.RealProffLevel,
                                                        (int)CurrentAccount.ActiveCharacter.Archetype.ClassId);
                ServerApp <RealmServer> .IOQueue.AddMessage(() =>
                {
                    foreach (CharacterFormulas.ItemIdAmounted itemIdAmounted in CharacterFormulas.ItemIdsToAddOnReborn)
                    {
                        CurrentAccount.ActiveCharacter.Asda2Inventory.AddDonateItem(
                            Asda2ItemMgr.GetTemplate(itemIdAmounted.ItemId), itemIdAmounted.Amount, "reborn_system",
                            false);
                    }
                });
                Log.Create(Log.Types.StatsOperations, LogSourceType.Character,
                           CurrentAccount.ActiveCharacter.EntryId).AddAttribute("source", 0.0, "reborn")
                .AddAttribute("count", CurrentAccount.ActiveCharacter.Record.RebornCount, "").Write();
                CurrentAccount.ActiveCharacter.Level = 1;
                CurrentAccount.ActiveCharacter.ResetStatPoints();
                CurrentAccount.ActiveCharacter.SendInfoMsg(
                    "Congratulations on the new reincarnation!");
                CurrentAccount.ActiveCharacter.IsReborning = false;
            });
            return(RebornEnum.Ok);
        }
예제 #2
0
        public static void Start(int monsterId, int itemId)
        {
            var template = Asda2ItemMgr.GetTemplate(itemId);

            if (Started || template == null)
            {
                return;
            }

            Asda2EventMgr.SendMessageToWorld("Kill monster event started.");
            Started    = true;
            _itemId    = itemId;
            _monsterId = monsterId;
        }
예제 #3
0
        public RebornEnum Reborn()
        {
            //if (CurrentAccount == null || CurrentAccount.ActiveCharacter == null)
            return(RebornEnum.Error);

            if (CurrentAccount.ActiveCharacter.IsAsda2BattlegroundInProgress)
            {
                return(RebornEnum.YouMustLeaveWar);
            }
            if (CurrentAccount.ActiveCharacter.Level < CharacterFormulas.RebornLevel)
            {
                return(RebornEnum.YouMustReachAtLeast80Level);
            }
            foreach (var asda2Item in CurrentAccount.ActiveCharacter.Asda2Inventory.Equipment)
            {
                if (asda2Item != null)
                {
                    return(RebornEnum.YouMustPutOffCloses);
                }
            }
            if (CurrentAccount.ActiveCharacter.IsReborning)
            {
                return(RebornEnum.Error);
            }
            CurrentAccount.ActiveCharacter.IsReborning = true;
            CurrentAccount.ActiveCharacter.AddMessage(() =>
            {
                CurrentAccount.ActiveCharacter.Record.RebornCount++;
                FunctionalItemsHandler.ResetSkills(CurrentAccount.ActiveCharacter);
                CurrentAccount.ActiveCharacter.SetClass(CurrentAccount.ActiveCharacter.RealProffLevel, (int)CurrentAccount.ActiveCharacter.Archetype.ClassId);
                RealmServer.IOQueue.AddMessage(() =>
                {
                    foreach (var itemIdAmounted in CharacterFormulas.ItemIdsToAddOnReborn)
                    {
                        CurrentAccount.ActiveCharacter.Asda2Inventory.AddDonateItem(
                            Asda2ItemMgr.GetTemplate(itemIdAmounted.ItemId), itemIdAmounted.Amount, "reborn_system");
                    }
                });
                Log.Create(Log.Types.StatsOperations, LogSourceType.Character, CurrentAccount.ActiveCharacter.EntryId)
                .AddAttribute("source", 0, "reborn")
                .AddAttribute("count", CurrentAccount.ActiveCharacter.Record.RebornCount)
                .Write();

                CurrentAccount.ActiveCharacter.Level = 49;
                CurrentAccount.ActiveCharacter.ResetStatPoints();
                CurrentAccount.ActiveCharacter.SendInfoMsg(string.Format("ѕоздравл¤ем с новым перерождением!"));
                CurrentAccount.ActiveCharacter.IsReborning = false;
            });
            return(RebornEnum.Ok);
        }
예제 #4
0
        public static void OnLogin(Character chr)
        {
            var chrId = (uint)chr.Record.Guid;

            if (SelledRecords.ContainsKey(chrId))
            {
                var items = SelledRecords[chrId];
                foreach (var rec in items)
                {
                    SendMoneyToSeller(Asda2ItemMgr.GetTemplate(rec.ItemId).Name, rec.GoldAmount, rec.ItemAmount, chr);
                    rec.DeleteLater();
                }
                items.Clear();
                SelledRecords.Remove(chrId);
            }
        }
예제 #5
0
        public static void Start(int intervalMins, int itemId)
        {
            var template = Asda2ItemMgr.GetTemplate(itemId);

            if (Started || template == null)
            {
                return;
            }

            _timer = GetRewardQueue.CallPeriodically(_tickInterval, GiveReward);

            Asda2EventMgr.SendMessageToWorld("STAY ONLINE Event started. Every ~{0} mins you will get a prize! Stay ONLINE!",
                                             intervalMins);
            Started       = true;
            _itemId       = itemId;
            _intervalMins = intervalMins;
        }
예제 #6
0
            public override void Process(CmdTrigger <RealmServerCmdArgs> trigger)
            {
                var monsterId = trigger.Text.NextInt();
                var itemId    = trigger.Text.NextInt();
                var template  = Asda2ItemMgr.GetTemplate(itemId);

                if (template == null)
                {
                    trigger.Reply("Item not found");
                    return;
                }
                if (KillMonsterEventManager.Started)
                {
                    trigger.Reply("Kill Monster event is already started.");
                    return;
                }
                KillMonsterEventManager.Start(monsterId, itemId);
                trigger.Reply("Ok,Kill Monster event stated. monsterId {0}, itemid is {1}.", monsterId, itemId);
            }
예제 #7
0
        public static void OnLogin(Character chr)
        {
            uint guid = (uint)chr.Record.Guid;

            if (!Asda2AuctionMgr.SelledRecords.ContainsKey(guid))
            {
                return;
            }
            List <AuctionSelledRecord> selledRecord = Asda2AuctionMgr.SelledRecords[guid];

            foreach (AuctionSelledRecord record in selledRecord)
            {
                Asda2AuctionMgr.SendMoneyToSeller(Asda2ItemMgr.GetTemplate(record.ItemId).Name, record.GoldAmount,
                                                  record.ItemAmount, chr);
                record.DeleteLater();
            }

            selledRecord.Clear();
            Asda2AuctionMgr.SelledRecords.Remove(guid);
        }
예제 #8
0
            public override void Process(CmdTrigger <RealmServerCmdArgs> trigger)
            {
                var interval = trigger.Text.NextInt();
                var itemId   = trigger.Text.NextInt();
                var template = Asda2ItemMgr.GetTemplate(itemId);

                if (interval < 1)
                {
                    trigger.Reply("Min inteval is 1");
                    return;
                }
                if (template == null)
                {
                    trigger.Reply("Item not found");
                    return;
                }
                if (StayOnlineEventManager.Started)
                {
                    trigger.Reply("Stay online event is already started.");
                    return;
                }
                StayOnlineEventManager.Start(interval, itemId);
                trigger.Reply("Ok, stay online event stated. interval {0}, itemid is {1}.", interval, itemId);
            }
예제 #9
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.");
                }
            }
예제 #10
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;
        }
예제 #11
0
 bool IsValidSowel(int id)
 {
     return(IsValidSowel(Asda2ItemMgr.GetTemplate(id)));
 }
예제 #12
0
 public static void TryGuess(string word, Character senderChr)
 {
     lock (typeof(Asda2EventMgr))
     {
         if (!Started)
         {
             return;
         }
         var   fixedWord   = word.ToLower();
         float correctHits = 0f;
         for (int i = 0; i < fixedWord.Length; i++)
         {
             if (i >= _word.Length)
             {
                 break;
             }
             if (fixedWord[i] == _word[i])
             {
                 correctHits++;
             }
         }
         if (correctHits / _word.Length >= _percision)
         {
             //character is winner
             var exp        = CharacterFormulas.CalcExpForGuessWordEvent(senderChr.Level);
             var eventItems = CharacterFormulas.EventItemsForGuessEvent;
             Asda2EventMgr.SendMessageToWorld("{0} is winner. Prize is {1} exp and {2} event items.", senderChr.Name, exp, eventItems);
             senderChr.GainXp(exp, "guess_event");
             RealmServer.IOQueue.AddMessage(() => senderChr.Asda2Inventory.AddDonateItem(Asda2ItemMgr.GetTemplate(CharacterFormulas.EventItemId), eventItems, "guess_event"));
             Stop();
             Log.Create(Log.Types.EventOperations, LogSourceType.Character, senderChr.EntryId)
             .AddAttribute("win", eventItems, "guess_event")
             .Write();
         }
     }
 }
예제 #13
0
 private void InitAfterLoad()
 {
     this.Template = Asda2ItemMgr.GetTemplate(this.ItemId);
     this.Owner    = World.GetCharacter(this.OwnerId);
 }
예제 #14
0
        public static void TryGuess(string word, Character senderChr)
        {
            lock (typeof(Asda2EventMgr))
            {
                if (!Asda2EventMgr.IsGuessWordEventStarted)
                {
                    return;
                }
                string lower = word.ToLower();
                float  num   = 0.0f;
                for (int index = 0; index < lower.Length && index < Asda2EventMgr._word.Length; ++index)
                {
                    if ((int)lower[index] == (int)Asda2EventMgr._word[index])
                    {
                        ++num;
                    }
                }

                if ((double)num / (double)Asda2EventMgr._word.Length < (double)Asda2EventMgr._percision)
                {
                    return;
                }
                int experience = CharacterFormulas.CalcExpForGuessWordEvent(senderChr.Level);
                int eventItems = CharacterFormulas.EventItemsForGuessEvent;
                Asda2EventMgr.SendMessageToWorld("{0} is winner. Prize is {1} exp and {2} event items.",
                                                 (object)senderChr.Name, (object)experience, (object)eventItems);
                senderChr.GainXp(experience, "guess_event", false);
                ServerApp <WCell.RealmServer.RealmServer> .IOQueue.AddMessage((Action)(() =>
                                                                                       senderChr.Asda2Inventory.AddDonateItem(Asda2ItemMgr.GetTemplate(CharacterFormulas.EventItemId),
                                                                                                                              eventItems, "guess_event", false)));

                Asda2EventMgr.StopGueesWordEvent();
                Log.Create(Log.Types.EventOperations, LogSourceType.Character, senderChr.EntryId)
                .AddAttribute("win", (double)eventItems, "guess_event").Write();
            }
        }
예제 #15
0
        public virtual void Stop(bool success)
        {
            if (!this.Started)
            {
                return;
            }
            this.Started = false;
            Asda2EventMgr.SendMessageToWorld("Deffence town event stoped in {0} [{2}-{3}]. Status : {1}",
                                             (object)this.Town, success ? (object)"Win" : (object)"Loose", (object)this.MinLevel,
                                             (object)this.MaxLevel);
            this._spawnTasks.IsRunning = false;
            this._spawnTasks.Clear();
            this._map.DefenceTownEvent = (DeffenceTownEvent)null;
            if (success)
            {
                float num1 = (float)this._lives / (float)CharacterFormulas.DefenceTownLives;
                float num2 = (float)this.ExpPortionsTotal * num1;
                float num3 = (float)this.EventItemsTotal * num1;
                this.NotifyBestDamagers();
                List <object>             objectList = new List <object>();
                Dictionary <object, long> dictionary = new Dictionary <object, long>();
                foreach (KeyValuePair <object, long> damage in this.Damages)
                {
                    Group key = damage.Key as Group;
                    if (key != null)
                    {
                        List <GroupMember> list = key.Where <GroupMember>((Func <GroupMember, bool>)(m =>
                        {
                            if (m.Character != null && m.Character.Level >= this.MinLevel)
                            {
                                return(m.Character.Level <= this.MaxLevel);
                            }
                            return(false);
                        })).ToList <GroupMember>();
                        foreach (GroupMember groupMember in list)
                        {
                            if (this.Damages.ContainsKey((object)groupMember.Character))
                            {
                                objectList.Add((object)groupMember.Character);
                            }
                            dictionary.Add((object)groupMember.Character, damage.Value / (long)list.Count);
                        }

                        objectList.Add(damage.Key);
                    }
                }

                WCell.RealmServer.Global.World.BroadcastMsg("Rewarder",
                                                            string.Format("Damagers count is {0}.", (object)this.Damages.Count), Color.OrangeRed);
                foreach (object key in objectList)
                {
                    this.Damages.Remove(key);
                }
                foreach (KeyValuePair <object, long> keyValuePair in dictionary)
                {
                    this.Damages.Add(keyValuePair.Key, keyValuePair.Value);
                }
                long num4 = this.Damages.Sum <KeyValuePair <object, long> >(
                    (Func <KeyValuePair <object, long>, long>)(d => d.Value));
                WCell.RealmServer.Global.World.BroadcastMsg("Rewarder",
                                                            string.Format("Total damage is {0}.", (object)num4), Color.OrangeRed);
                foreach (KeyValuePair <object, long> keyValuePair in (IEnumerable <KeyValuePair <object, long> >) this
                         .Damages.OrderByDescending <KeyValuePair <object, long>, long>(
                             (Func <KeyValuePair <object, long>, long>)(kvp => kvp.Value)))
                {
                    Character chr = keyValuePair.Key as Character;
                    try
                    {
                        if (chr != null)
                        {
                            if (chr.Asda2Inventory != null)
                            {
                                float num5       = (float)keyValuePair.Value / (float)num4;
                                int   experience = (int)((double)num5 * (double)num2 *
                                                         (double)XpGenerator.GetBaseExpForLevel(chr.Level));
                                int num6 = (int)((double)num5 * (double)num3);
                                chr.GainXp(experience, "defence_town_event", false);
                                if (num6 > 0)
                                {
                                    ServerApp <WCell.RealmServer.RealmServer> .IOQueue.AddMessage((Action)(() =>
                                                                                                           chr.Asda2Inventory.AddDonateItem(
                                                                                                               Asda2ItemMgr.GetTemplate(CharacterFormulas.DonationItemId), 100,
                                                                                                               "defence_town_event", false)));
                                }
                                WCell.RealmServer.Global.World.BroadcastMsg("Rw",
                                                                            string.Format("{2} gain {0} coins and {1} exp for {3} dmg.", (object)100,
                                                                                          (object)experience, (object)chr.Name, (object)keyValuePair.Value),
                                                                            Color.OrangeRed);
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        WCell.RealmServer.Global.World.BroadcastMsg("Event manager",
                                                                    "exception when rewarding." + ex.Message, Color.Red);
                    }
                }
            }

            this.Damages.Clear();
        }
예제 #16
0
 void InitAfterLoad()
 {
     Template = Asda2ItemMgr.GetTemplate(ItemId);
     Owner    = World.GetCharacter(OwnerId);
 }
예제 #17
0
        public void FinalizeDataHolder()
        {
            var list = new List <FishingSpot>();

            Asda2FishingMgr.FishingSpotsByMaps.Add(Id, list);
            for (int i = 0; i < 10; i++)
            {
                if (RequiredFishingLvls[i] == -1)
                {
                    continue;
                }
                var nfs = new FishingSpot();
                nfs.RequiredFishingLevel = RequiredFishingLvls[i];
                nfs.Map      = (MapId)Id;
                nfs.Position = new Vector3(Points[i], Points[i + 10], 0);
                nfs.Radius   = (byte)Radius[i];
                nfs.Fishes   = new Dictionary <int, Fish>();
                var bi     = Asda2FishingMgr.FishingBaseInfos[DataKey[i]];
                var chance = 0;
                for (int j = 0; j < 20; j++)
                {
                    if (bi.Chances[j] == 0)
                    {
                        continue;
                    }
                    chance += bi.Chances[j];
                    var nf = new Fish();
                    nf.ItemTemplate = Asda2ItemMgr.GetTemplate(bi.ItemIds[j]) ?? Asda2ItemMgr.GetTemplate(31725);
                    nf.BaitIds      = new List <int>();
                    var ft = Asda2FishingMgr.FishRecords[bi.ItemIds[j]];
                    nf.FishingTime = ft.FishingTime;
                    for (int k = 0; k < 6; k++)
                    {
                        if (ft.BaitIds[k] == -1)
                        {
                            continue;
                        }
                        nf.BaitIds.Add(ft.BaitIds[k]);
                    }
                    nf.MinLength = (byte)bi.MinFishLengths[j];
                    nf.MaxLength = (byte)bi.MaxFishLenghts[j];
                    nfs.Fishes.Add(chance, nf);
                }

                nfs.PremiumFishes = new Dictionary <int, Fish>();
                bi     = Asda2FishingMgr.PremiumFishingBaseInfos[DataKey[i]];
                chance = 0;
                for (int j = 0; j < 20; j++)
                {
                    if (bi.Chances[j] == 0)
                    {
                        continue;
                    }
                    chance += bi.Chances[j];
                    var nf = new Fish();
                    nf.ItemTemplate = Asda2ItemMgr.GetTemplate(bi.ItemIds[j]) ?? Asda2ItemMgr.GetTemplate(31725);
                    nf.BaitIds      = new List <int>();
                    var ft = Asda2FishingMgr.FishRecords[bi.ItemIds[j]];
                    nf.FishingTime = ft.FishingTime;
                    for (int k = 0; k < 6; k++)
                    {
                        if (ft.BaitIds[k] == -1)
                        {
                            continue;
                        }
                        nf.BaitIds.Add(ft.BaitIds[k]);
                    }
                    nf.MinLength = (byte)bi.MinFishLengths[j];
                    nf.MaxLength = (byte)bi.MaxFishLenghts[j];
                    nfs.PremiumFishes.Add(chance, nf);
                }
                list.Add(nfs);
            }
        }
예제 #18
0
        public void FinalizeDataHolder()
        {
            List <FishingSpot> fishingSpotList = new List <FishingSpot>();

            Asda2FishingMgr.FishingSpotsByMaps.Add(this.Id, fishingSpotList);
            for (int index1 = 0; index1 < 10; ++index1)
            {
                if (this.RequiredFishingLvls[index1] != -1)
                {
                    FishingSpot fishingSpot = new FishingSpot();
                    fishingSpot.RequiredFishingLevel = this.RequiredFishingLvls[index1];
                    fishingSpot.Map      = (MapId)this.Id;
                    fishingSpot.Position =
                        new Vector3((float)this.Points[index1], (float)this.Points[index1 + 10], 0.0f);
                    fishingSpot.Radius = (byte)this.Radius[index1];
                    fishingSpot.Fishes = new Dictionary <int, Fish>();
                    FishingBaseInfoRecord fishingBaseInfo = Asda2FishingMgr.FishingBaseInfos[this.DataKey[index1]];
                    int key1 = 0;
                    for (int index2 = 0; index2 < 20; ++index2)
                    {
                        if (fishingBaseInfo.Chances[index2] != 0)
                        {
                            key1 += fishingBaseInfo.Chances[index2];
                            Fish fish = new Fish();
                            fish.ItemTemplate = Asda2ItemMgr.GetTemplate(fishingBaseInfo.ItemIds[index2]) ??
                                                Asda2ItemMgr.GetTemplate(31725);
                            fish.BaitIds = new List <int>();
                            FishingFishInfoRecord fishRecord =
                                Asda2FishingMgr.FishRecords[fishingBaseInfo.ItemIds[index2]];
                            fish.FishingTime = fishRecord.FishingTime;
                            for (int index3 = 0; index3 < 6; ++index3)
                            {
                                if (fishRecord.BaitIds[index3] != -1)
                                {
                                    fish.BaitIds.Add(fishRecord.BaitIds[index3]);
                                }
                            }

                            fish.MinLength = (byte)fishingBaseInfo.MinFishLengths[index2];
                            fish.MaxLength = (byte)fishingBaseInfo.MaxFishLenghts[index2];
                            fishingSpot.Fishes.Add(key1, fish);
                        }
                    }

                    fishingSpot.PremiumFishes = new Dictionary <int, Fish>();
                    FishingBaseInfoRecord premiumFishingBaseInfo =
                        Asda2FishingMgr.PremiumFishingBaseInfos[this.DataKey[index1]];
                    int key2 = 0;
                    for (int index2 = 0; index2 < 20; ++index2)
                    {
                        if (premiumFishingBaseInfo.Chances[index2] != 0)
                        {
                            key2 += premiumFishingBaseInfo.Chances[index2];
                            Fish fish = new Fish();
                            fish.ItemTemplate = Asda2ItemMgr.GetTemplate(premiumFishingBaseInfo.ItemIds[index2]) ??
                                                Asda2ItemMgr.GetTemplate(31725);
                            fish.BaitIds = new List <int>();
                            FishingFishInfoRecord fishRecord =
                                Asda2FishingMgr.FishRecords[premiumFishingBaseInfo.ItemIds[index2]];
                            fish.FishingTime = fishRecord.FishingTime;
                            for (int index3 = 0; index3 < 6; ++index3)
                            {
                                if (fishRecord.BaitIds[index3] != -1)
                                {
                                    fish.BaitIds.Add(fishRecord.BaitIds[index3]);
                                }
                            }

                            fish.MinLength = (byte)premiumFishingBaseInfo.MinFishLengths[index2];
                            fish.MaxLength = (byte)premiumFishingBaseInfo.MaxFishLenghts[index2];
                            fishingSpot.PremiumFishes.Add(key2, fish);
                        }
                    }

                    fishingSpotList.Add(fishingSpot);
                }
            }
        }
예제 #19
0
 public virtual void Stop(bool success)
 {
     if (!Started)
     {
         return;
     }
     Started = false;
     Asda2EventMgr.SendMessageToWorld("Deffence town event stoped in {0} [{2}-{3}]. Status : {1}", Town, success ? "Win" : "Loose", MinLevel, MaxLevel);
     _spawnTasks.IsRunning = false;
     _spawnTasks.Clear();
     _map.DefenceTownEvent = null;
     if (success)//getting prizies to players
     {
         var livesPrc         = (float)_lives / CharacterFormulas.DefenceTownLives;
         var expPortionsTotal = ExpPortionsTotal * livesPrc;
         var eventItemsTotal  = EventItemsTotal * livesPrc;
         NotifyBestDamagers();
         var objectsToDelete = new List <object>();
         var objectsToAdd    = new Dictionary <object, long>();
         foreach (var damage in Damages)
         {
             var grp = damage.Key as Group;
             if (grp != null)
             {
                 var receivers = grp.Where(m => m.Character != null && m.Character.Level >= MinLevel && m.Character.Level <= MaxLevel).ToList();
                 foreach (var member in receivers)
                 {
                     if (Damages.ContainsKey(member.Character))
                     {
                         objectsToDelete.Add(member.Character);
                     }
                     objectsToAdd.Add(member.Character, damage.Value / receivers.Count);
                 }
                 objectsToDelete.Add(damage.Key);
             }
         }
         World.BroadcastMsg("Rewarder", string.Format("Damagers count is {0}.", Damages.Count), Color.OrangeRed);
         foreach (var o in objectsToDelete)
         {
             Damages.Remove(o);
         }
         foreach (var l in objectsToAdd)
         {
             Damages.Add(l.Key, l.Value);
         }
         var totalDamage = Damages.Sum(d => d.Value);
         World.BroadcastMsg("Rewarder", string.Format("Total damage is {0}.", totalDamage), Color.OrangeRed);
         foreach (var damage in Damages.OrderByDescending(kvp => kvp.Value))
         {
             var chr = damage.Key as Character;
             try
             {
                 if (chr != null && chr.Asda2Inventory != null)
                 {
                     var prcFromMainPrize = (float)damage.Value / totalDamage;
                     var exp             = (int)(prcFromMainPrize * expPortionsTotal * XpGenerator.GetBaseExpForLevel(chr.Level));
                     var eventItemsCount = (int)(prcFromMainPrize * eventItemsTotal);
                     chr.GainXp(exp, "defence_town_event");
                     if (eventItemsCount > 0)
                     {
                         RealmServer.IOQueue.AddMessage(() => chr.Asda2Inventory.AddDonateItem(Asda2ItemMgr.GetTemplate(CharacterFormulas.EventItemId), eventItemsCount, "defence_town_event"));
                     }
                     World.BroadcastMsg("Rw", string.Format("{2} gain {0} coins and {1} exp for {3} dmg.", eventItemsCount, exp, chr.Name, damage.Value), Color.OrangeRed);
                 }
             }
             catch (Exception ex)
             {
                 World.BroadcastMsg("Event manager", "exception when rewarding." + ex.Message, Color.Red);
             }
         }
     }
     Damages.Clear();
 }