Beispiel #1
0
        public void AnswerSuccess(User user)
        {
            if (!Database.HasPlayerCompletedRiddle(this.Id, user.Id))
            {
                Database.CompleteRiddle(this.Id, user.Id);
            }

            byte[] riddleAnswerCorrectPacket = PacketBuilder.CreateChat(Messages.FormatRiddlerAnswerCorrect(this.Reason), PacketBuilder.CHAT_BOTTOM_RIGHT);
            user.LoggedinClient.SendPacket(riddleAnswerCorrectPacket);
            user.AddMoney(10000);

            if (HasCompletedAllRiddles(user))
            {
                user.Awards.AddAward(Award.GetAwardById(11)); // Riddlers Riddles
            }
        }
Beispiel #2
0
        public void Win(User winner)
        {
            if (!Active)
            {
                return;
            }

            if (Database.HasPlayerCompletedRealTimeRiddle(RiddleId, winner.Id))
            {
                byte[] alreadyWonRiddleMessage = PacketBuilder.CreateChat(Messages.EventAlreadySovledRealTimeRiddle, PacketBuilder.CHAT_BOTTOM_RIGHT);
                winner.LoggedinClient.SendPacket(alreadyWonRiddleMessage);
                return;
            }

            LastWon = true;

            Database.CompleteRealTimeRiddle(RiddleId, winner.Id);

            winner.TrackedItems.GetTrackedItem(Tracking.TrackableItem.RiddleWin).Count++;

            if (winner.TrackedItems.GetTrackedItem(Tracking.TrackableItem.RiddleWin).Count >= 25)
            {
                winner.Awards.AddAward(Award.GetAwardById(33)); // Quick Wit
            }
            if (winner.TrackedItems.GetTrackedItem(Tracking.TrackableItem.RiddleWin).Count >= 250)
            {
                winner.Awards.AddAward(Award.GetAwardById(34)); // Riddle Genius
            }
            winner.AddMoney(Reward);
            byte[] riddleWonMessage    = PacketBuilder.CreateChat(Messages.FormatEventRealTimeRiddleWonForOthers(winner.Username), PacketBuilder.CHAT_BOTTOM_RIGHT);
            byte[] riddleYouWonMessage = PacketBuilder.CreateChat(Messages.FormatEventRealTimeRiddleWonForYou(Reward), PacketBuilder.CHAT_BOTTOM_RIGHT);
            foreach (GameClient client in GameClient.ConnectedClients)
            {
                if (client.LoggedIn)
                {
                    if (client.LoggedinUser.Id != winner.Id)
                    {
                        client.SendPacket(riddleWonMessage);
                    }
                    else
                    {
                        client.SendPacket(riddleYouWonMessage);
                    }
                }
            }
            EndEvent();
        }
Beispiel #3
0
        public void CollectTreasure(User user)
        {
            treasures.Remove(this);
            Database.DeleteTreasure(this.RandomId);
            GenerateTreasure();

            byte[] MovementPacket = PacketBuilder.CreateMovementPacket(user.X, user.Y, user.CharacterId, user.Facing, PacketBuilder.DIRECTION_TELEPORT, true);
            user.LoggedinClient.SendPacket(MovementPacket);

            user.Money += Value;

            if (this.Type == "BURIED")
            {
                byte[] treasureReceivedPacket = PacketBuilder.CreateChat(Messages.FormatPirateTreasure(this.Value), PacketBuilder.CHAT_BOTTOM_RIGHT);
                user.LoggedinClient.SendPacket(treasureReceivedPacket);
                user.TrackedItems.GetTrackedItem(Tracking.TrackableItem.PirateTreasure).Count++;

                if (user.TrackedItems.GetTrackedItem(Tracking.TrackableItem.PirateTreasure).Count >= 10)
                {
                    user.Awards.AddAward(Award.GetAwardById(18)); // Pirate Tracker
                }
                if (user.TrackedItems.GetTrackedItem(Tracking.TrackableItem.PirateTreasure).Count >= 100)
                {
                    user.Awards.AddAward(Award.GetAwardById(19)); // Pirate Stalker
                }
            }
            else if (this.Type == "RAINBOW")
            {
                byte[] treasureReceivedPacket = PacketBuilder.CreateChat(Messages.FormatPotOfGold(this.Value), PacketBuilder.CHAT_BOTTOM_RIGHT);
                user.LoggedinClient.SendPacket(treasureReceivedPacket);

                user.TrackedItems.GetTrackedItem(Tracking.TrackableItem.PotOfGold).Count++;

                if (user.TrackedItems.GetTrackedItem(Tracking.TrackableItem.PotOfGold).Count >= 3)
                {
                    user.Awards.AddAward(Award.GetAwardById(20)); // Leprechaun
                }
                if (user.TrackedItems.GetTrackedItem(Tracking.TrackableItem.PirateTreasure).Count >= 20)
                {
                    user.Awards.AddAward(Award.GetAwardById(21)); // Lucky Leprechaun
                }
            }
        }
Beispiel #4
0
        public void WinEvent(User winner)
        {
            byte[] eventWinMessage = PacketBuilder.CreateChat(Messages.FormatEventRealTimeQuizWin(winner.Username), PacketBuilder.CHAT_BOTTOM_RIGHT);
            foreach (GameClient client in GameClient.ConnectedClients)
            {
                if (client.LoggedIn)
                {
                    client.SendPacket(eventWinMessage);
                }
            }

            getParticipent(winner.Id).Won = true;

            winner.TrackedItems.GetTrackedItem(Tracking.TrackableItem.QuizWin).Count++;
            if (winner.TrackedItems.GetTrackedItem(Tracking.TrackableItem.QuizWin).Count >= 15)
            {
                winner.Awards.AddAward(Award.GetAwardById(54)); // Quiz Genius
            }
            if (winner.TrackedItems.GetTrackedItem(Tracking.TrackableItem.QuizWin).Count >= 25)
            {
                winner.Awards.AddAward(Award.GetAwardById(33)); // Quick Wit
            }
            stopEvent();
        }
Beispiel #5
0
        public void End()
        {
            if (Mode == "COMPETING")
            {
                string chatMessage = Messages.ArenaResultsMessage;

                string[] avaliblePlacings = new string[6] {
                    Messages.ArenaFirstPlace, Messages.ArenaSecondPlace, Messages.ArenaThirdPlace, Messages.ArenaFourthPlace, Messages.ArenaFifthPlace, Messages.ArenaSixthPlace
                };


                int          place   = 0;
                ArenaEntry[] winners = Entries.OrderByDescending(o => o.SubmitScore).ToArray();

                int[] expRewards = new int[winners.Length];
                Array.Copy(ExpRewards, expRewards, winners.Length);
                expRewards = expRewards.Reverse().ToArray();

                foreach (ArenaEntry entry in winners)
                {
                    string placing = avaliblePlacings[place % avaliblePlacings.Length];

                    chatMessage += Messages.FormatArenaPlacing(placing, entry.EnteredUser.Username, entry.SubmitScore);

                    place++;
                }
                place = 0;
                foreach (ArenaEntry entry in winners)
                {
                    try
                    {
                        byte[] arenaResults = PacketBuilder.CreateChat(chatMessage, PacketBuilder.CHAT_BOTTOM_RIGHT);
                        entry.EnteredUser.LoggedinClient.SendPacket(arenaResults);

                        int expReward = expRewards[place];

                        entry.EnteredHorse.BasicStats.Experience += expReward;
                        entry.EnteredUser.Experience             += expReward;

                        if (place == 0) // WINNER!
                        {
                            int prize = EntryCost * Entries.Length;
                            entry.EnteredUser.AddMoney(prize);


                            byte[] youWinMessage = PacketBuilder.CreateChat(Messages.FormatArenaYouWinMessage(prize, expReward), PacketBuilder.CHAT_BOTTOM_RIGHT);
                            entry.EnteredUser.LoggedinClient.SendPacket(youWinMessage);

                            // Awards:

                            if (Entries.Length >= 2 && Type == "JUMPING")
                            {
                                entry.EnteredUser.Awards.AddAward(Award.GetAwardById(5)); // Good Jumper
                            }
                            if (Entries.Length >= 4 && Type == "JUMPING")
                            {
                                entry.EnteredUser.Awards.AddAward(Award.GetAwardById(6)); // Great Jumper
                            }
                            if (Entries.Length >= 2 && Type == "RACING")
                            {
                                entry.EnteredUser.Awards.AddAward(Award.GetAwardById(7)); // Good Racer
                            }
                            if (Entries.Length >= 4 && Type == "RACING")
                            {
                                entry.EnteredUser.Awards.AddAward(Award.GetAwardById(8)); // Great Racer
                            }
                            if (Entries.Length >= 2 && Type == "DRESSAGE")
                            {
                                entry.EnteredUser.Awards.AddAward(Award.GetAwardById(9)); // Good Dressage
                            }
                            if (Entries.Length >= 4 && Type == "DRESSAGE")
                            {
                                entry.EnteredUser.Awards.AddAward(Award.GetAwardById(10)); // Great Dressage
                            }
                            if (Entries.Length >= 2 && Type == "DRAFT")
                            {
                                entry.EnteredUser.Awards.AddAward(Award.GetAwardById(38)); // Strong Horse Award
                            }
                            if (Entries.Length >= 4 && Type == "DRAFT")
                            {
                                entry.EnteredUser.Awards.AddAward(Award.GetAwardById(39)); // Strongest Horse Award
                            }
                        }
                        else
                        {
                            entry.EnteredUser.TrackedItems.GetTrackedItem(Tracking.TrackableItem.ArenaLoss).Count++;

                            if (entry.EnteredUser.TrackedItems.GetTrackedItem(Tracking.TrackableItem.ArenaLoss).Count >= 100)
                            {
                                entry.EnteredUser.Awards.AddAward(Award.GetAwardById(32)); // Perseverance
                            }
                            byte[] youDONTWinMessage = PacketBuilder.CreateChat(Messages.FormatArenaOnlyWinnerWinsMessage(expReward), PacketBuilder.CHAT_BOTTOM_RIGHT);
                            entry.EnteredUser.LoggedinClient.SendPacket(youDONTWinMessage);
                        }
                        place++;
                    }
                    catch (Exception)
                    {
                        continue;
                    }
                }
            }
            reset();
            updateWaitingPlayers();
        }
Beispiel #6
0
        public static bool Give(string message, string[] args, User user)
        {
            if (args.Length <= 0)
            {
                return(false);
            }
            if (!user.Administrator)
            {
                return(false);
            }
            if (args[0].ToUpper() == "OBJECT")
            {
                int itemId = 0;
                try
                {
                    if (args[1] != "RANDOM")
                    {
                        itemId = int.Parse(args[1]);
                    }
                    else
                    {
                        itemId = Item.GetRandomItem().Id;
                    }

                    Item.GetItemById(itemId); // Calling this makes sure this item id exists.

                    ItemInstance newItemInstance = new ItemInstance(itemId);

                    if (itemId == Item.Present)
                    {
                        newItemInstance.Data = Item.GetRandomItem().Id;
                    }

                    if (args.Length >= 3)
                    {
                        if (args[2] == "ALL")
                        {
                            foreach (GameClient client in GameClient.ConnectedClients)
                            {
                                if (client.LoggedIn)
                                {
                                    ItemInstance itmInstance = new ItemInstance(itemId);

                                    if (itemId == Item.Present)
                                    {
                                        itmInstance.Data = Item.GetRandomItem().Id;
                                    }

                                    client.LoggedinUser.Inventory.AddIgnoringFull(itmInstance);
                                }
                            }
                        }
                        else
                        {
                            findNamePartial(args[2]).Inventory.AddIgnoringFull(newItemInstance);
                        }
                    }
                    else
                    {
                        user.Inventory.AddIgnoringFull(newItemInstance);
                    }
                }
                catch (Exception)
                {
                    return(false);
                }
            }
            else if (args[0].ToUpper() == "HORSE")
            {
                int horseId = 0;
                try
                {
                    horseId = int.Parse(args[1]);
                    HorseInstance horse = new HorseInstance(HorseInfo.GetBreedById(horseId));

                    if (args.Length >= 3)
                    {
                        findNamePartial(args[2]).HorseInventory.AddHorse(horse);
                    }
                    else
                    {
                        user.HorseInventory.AddHorse(horse);
                    }
                }
                catch (Exception)
                {
                    return(false);
                }
            }
            else if (args[0].ToUpper() == "AWARD")
            {
                int awardId = 0;
                try
                {
                    awardId = int.Parse(args[1]);
                    if (args.Length >= 3)
                    {
                        findNamePartial(args[2]).Awards.AddAward(Award.GetAwardById(awardId));
                    }
                    else
                    {
                        user.Awards.AddAward(Award.GetAwardById(awardId));
                    }
                }
                catch (Exception)
                {
                    return(false);
                }
            }
            else if (args[0].ToUpper() == "MONEY")
            {
                int money = 0;
                try
                {
                    money = int.Parse(args[1]);
                    if (args.Length >= 3)
                    {
                        findNamePartial(args[2]).AddMoney(money);
                    }
                    else
                    {
                        user.AddMoney(money);
                    }
                }
                catch (Exception)
                {
                    return(false);
                }
            }
            else if (args[0].ToUpper() == "QUEST")
            {
                int questId = 0;
                try
                {
                    questId = int.Parse(args[1]);
                    if (args.Length >= 3)
                    {
                        if (args[2].ToUpper() == "FORCE")
                        {
                            Quest.CompleteQuest(user, Quest.GetQuestById(questId));
                            goto msg;
                        }
                    }
                    Quest.ActivateQuest(user, Quest.GetQuestById(questId));
                }
                catch (Exception)
                {
                    return(false);
                }
            }
            else
            {
                return(false);
            }
            msg :;
            byte[] chatPacket = PacketBuilder.CreateChat(Messages.FormatAdminCommandCompleteMessage(message.Substring(1)), PacketBuilder.CHAT_BOTTOM_LEFT);
            user.LoggedinClient.SendPacket(chatPacket);
            return(true);
        }
Beispiel #7
0
        public static QuestResult CompleteQuest(User user, QuestEntry quest, bool npcActivation = false, QuestResult res = null)
        {
            if (res == null)
            {
                res = new QuestResult();
            }
            // Take Items
            foreach (QuestItemInfo itemInfo in quest.ItemsRequired)
            {
                InventoryItem itm = user.Inventory.GetItemByItemId(itemInfo.ItemId);
                for (int i = 0; i < itemInfo.Quantity; i++)
                {
                    user.Inventory.Remove(itm.ItemInstances[0]);
                }
            }
            // Take Money
            user.TakeMoney(quest.MoneyCost);
            // Give money
            user.AddMoney(quest.MoneyEarned);
            // Give items
            foreach (QuestItemInfo itemInfo in quest.ItemsEarned)
            {
                for (int i = 0; i < itemInfo.Quantity; i++)
                {
                    ItemInstance         itm             = new ItemInstance(itemInfo.ItemId);
                    Item.ItemInformation itemInformation = itm.GetItemInfo();
                    if (itemInformation.Type == "CONCEPTUAL")
                    {
                        Item.ConsumeItem(user, itemInformation);
                    }
                    else
                    {
                        user.Inventory.AddIgnoringFull(itm);
                    }
                }
            }
            if (quest.WarpX != 0 && quest.WarpY != 0)
            {
                user.Teleport(quest.WarpX, quest.WarpY);
            }

            // Give quest points
            user.QuestPoints += quest.QuestPointsEarned;

            res.QuestCompleted = true;
            if (npcActivation)
            {
                if (quest.SuccessNpcChat != null && quest.SuccessNpcChat != "")
                {
                    res.NpcChat = quest.SuccessNpcChat;
                }

                if (quest.SetNpcChatpoint != -1)
                {
                    res.SetChatpoint = quest.SetNpcChatpoint;
                }

                if (quest.GotoNpcChatpoint != -1)
                {
                    res.GotoChatpoint = quest.GotoNpcChatpoint;
                }
            }

            if (quest.Tracked)
            {
                user.Quests.TrackQuest(quest.Id);
            }

            if (quest.ChainedQuestId != 0)
            {
                res = ActivateQuest(user, Quest.GetQuestById(quest.ChainedQuestId), npcActivation, res);
            }

            if (quest.SuccessMessage != null)
            {
                byte[] ChatPacket = PacketBuilder.CreateChat(quest.SuccessMessage, PacketBuilder.CHAT_BOTTOM_RIGHT);
                user.LoggedinClient.SendPacket(ChatPacket);
            }

            if (quest.SuccessNpcChat != null)
            {
                if (!npcActivation)
                {
                    byte[] ChatPacket = PacketBuilder.CreateChat(quest.SuccessNpcChat, PacketBuilder.CHAT_BOTTOM_RIGHT);
                    user.LoggedinClient.SendPacket(ChatPacket);
                }
            }

            // Check if award unlocked
            int questPointsPercent = Convert.ToInt32(Math.Floor(((decimal)user.QuestPoints / (decimal)GetTotalQuestPoints()) * (decimal)100.0));

            if (questPointsPercent >= 25)
            {
                user.Awards.AddAward(Award.GetAwardById(1)); // 25% Quest Completion Award.
            }
            if (questPointsPercent >= 50)
            {
                user.Awards.AddAward(Award.GetAwardById(2)); // 50% Quest Completion Award.
            }
            if (questPointsPercent >= 75)
            {
                user.Awards.AddAward(Award.GetAwardById(3)); // 75% Quest Completion Award.
            }
            if (questPointsPercent >= 100)
            {
                user.Awards.AddAward(Award.GetAwardById(4)); // 100% Quest Completion Award.
            }
            // Is cloud isles quest?
            if (quest.Id == 1373)
            {
                byte[] swfLoadPacket = PacketBuilder.CreateSwfModulePacket("ballooncutscene", PacketBuilder.PACKET_SWF_CUTSCENE);
                user.LoggedinClient.SendPacket(swfLoadPacket);
            }

            return(res);
        }
Beispiel #8
0
        public static bool CanComplete(User user, QuestEntry quest)
        {
            // Has completed other required quests?
            foreach (int questId in quest.RequiresQuestIdCompleted)
            {
                if (user.Quests.GetTrackedQuestAmount(questId) < 1)
                {
                    return(false);
                }
            }

            // Has NOT competed other MUST NOT BE required quests
            foreach (int questId in quest.RequiresQuestIdNotCompleted)
            {
                if (user.Quests.GetTrackedQuestAmount(questId) > 1)
                {
                    return(false);
                }
            }

            if (quest.Tracked)
            {
                // Has allready tracked this quest?
                if (user.Quests.GetTrackedQuestAmount(quest.Id) >= quest.MaxRepeats)
                {
                    return(false);
                }
            }

            // Check if user has award unlocked
            if (quest.AwardRequired != 0)
            {
                if (!user.Awards.HasAward(Award.GetAwardById(quest.AwardRequired)))
                {
                    return(false);
                }
            }

            // Check if i have required items
            foreach (QuestItemInfo itemInfo in quest.ItemsRequired)
            {
                bool            hasThisItem = false;
                InventoryItem[] items       = user.Inventory.GetItemList();
                foreach (InventoryItem item in items)
                {
                    if (item.ItemId == itemInfo.ItemId && item.ItemInstances.Length >= itemInfo.Quantity)
                    {
                        hasThisItem = true;
                        break;
                    }
                }
                if (!hasThisItem)
                {
                    return(false);
                }
            }

            // Have enough money?
            if (user.Money < quest.MoneyCost)
            {
                return(false);
            }


            return(true);
        }