Пример #1
0
        /// <summary>
        /// Called when quest is finished, hands out rewards.
        /// </summary>
        public override void FinishQuest()
        {
            int inventorySpaceRequired = Rewards.BasicItems.Count + Rewards.ChosenItems.Count;

            if (QuestPlayer.Inventory.IsSlotsFree(inventorySpaceRequired, eInventorySlot.FirstBackpack, eInventorySlot.LastBackpack))
            {
                base.FinishQuest();
                QuestPlayer.Out.SendSoundEffect(11, 0, 0, 0, 0, 0);
                QuestPlayer.GainExperience(GameLiving.eXPSource.Quest, Rewards.Experience);
                QuestPlayer.AddMoney(Rewards.Money);
                InventoryLogging.LogInventoryAction($"(QUEST;{Name})", QuestPlayer, eInventoryActionType.Quest, Rewards.Money);
                if (Rewards.GiveBountyPoints > 0)
                {
                    QuestPlayer.GainBountyPoints(Rewards.GiveBountyPoints);
                }

                if (Rewards.GiveRealmPoints > 0)
                {
                    QuestPlayer.GainRealmPoints(Rewards.GiveRealmPoints);
                }

                foreach (ItemTemplate basicReward in Rewards.BasicItems)
                {
                    GiveItem(QuestPlayer, basicReward);
                }

                foreach (ItemTemplate optionalReward in Rewards.ChosenItems)
                {
                    GiveItem(QuestPlayer, optionalReward);
                }

                QuestPlayer.Out.SendNPCsQuestEffect(QuestGiver, QuestGiver.GetQuestIndicator(QuestPlayer));
            }
            else
            {
                QuestPlayer.Out.SendMessage($"Your inventory is full, you need {inventorySpaceRequired} free slot(s) to complete this quest.", eChatType.CT_System, eChatLoc.CL_SystemWindow);
                Rewards.ChosenItems.Clear();
            }
        }