예제 #1
0
        public void ClaimRewards()
        {
            if (m_Quest == null || m_Player == null || m_Player.Deleted || !ClaimReward || Removed)
            {
                return;
            }

            List <Item> rewards = new List <Item>();

            foreach (BaseReward reward in m_Quest.Rewards)
            {
                reward.AddRewardItems(m_Player, rewards);
            }

            if (rewards.Count != 0)
            {
                // On OSI a more naive method of checking is used.
                // For containers, only the actual container item counts.
                bool canFit = true;

                foreach (Item rewardItem in rewards)
                {
                    if (!m_Player.AddToBackpack(rewardItem))
                    {
                        canFit = false;
                        break;
                    }
                }

                if (!canFit)
                {
                    foreach (Item rewardItem in rewards)
                    {
                        rewardItem.Delete();
                    }

                    m_Player.SendLocalizedMessage(1078524); // Your backpack is full. You cannot complete the quest and receive your reward.
                    return;
                }

                foreach (Item rewardItem in rewards)
                {
                    string rewardName = (rewardItem.Name != null) ? rewardItem.Name : String.Concat("#", rewardItem.LabelNumber);

                    if (rewardItem.Stackable)
                    {
                        m_Player.SendLocalizedMessage(1115917, String.Concat(rewardItem.Amount, "\t", rewardName)); // You receive a reward: ~1_QUANTITY~ ~2_ITEM~
                    }
                    else
                    {
                        m_Player.SendLocalizedMessage(1074360, rewardName); // You receive a reward: ~1_REWARD~
                    }
                }
            }

            foreach (BaseObjectiveInstance objective in m_ObjectiveInstances)
            {
                objective.OnRewardClaimed();
            }

            m_Quest.OnRewardClaimed(this);

            MLQuestContext context = PlayerContext;

            if (m_Quest.RecordCompletion && !m_Quest.HasRestartDelay) // Quests with restart delays are logged earlier as per OSI
            {
                context.SetDoneQuest(m_Quest);
            }

            if (m_Quest.IsChainTriggered)
            {
                context.ChainOffers.Remove(m_Quest);
            }

            Type nextQuestType = m_Quest.NextQuest;

            if (nextQuestType != null)
            {
                MLQuest nextQuest = MLQuestSystem.FindQuest(nextQuestType);

                if (nextQuest != null && !context.ChainOffers.Contains(nextQuest))
                {
                    context.ChainOffers.Add(nextQuest);
                }
            }

            Remove();
        }
예제 #2
0
        public bool IsDoingQuest(Type questType)
        {
            MLQuest quest = MLQuestSystem.FindQuest(questType);

            return(quest != null && IsDoingQuest(quest));
        }
예제 #3
0
 public void Serialize(GenericWriter writer)
 {
     MLQuestSystem.WriteQuestRef(writer, m_Quest);
     writer.Write(m_NextAvailable);
 }
예제 #4
0
        public bool HasDoneQuest(Type questType)
        {
            MLQuest quest = MLQuestSystem.FindQuest(questType);

            return(quest != null && HasDoneQuest(quest));
        }