예제 #1
0
파일: Quest.cs 프로젝트: KroneckerX/WCell
		/// <summary>
		/// Load Quest progress
		/// </summary>
		internal Quest(QuestLog log, QuestRecord record, QuestTemplate template)
			: this(log, template, record)
		{
			m_saved = true;

			// reset initial state

			if (template.HasObjectOrSpellInteractions)
			{
				if (Interactions == null ||
				//template has been changed, probably due to a quest fix
				template.ObjectOrSpellInteractions.Count() != Interactions.Count())
				{
					Interactions = new uint[template.ObjectOrSpellInteractions.Length];
				}

				for (var i = 0; i < Template.ObjectOrSpellInteractions.Length; i++)
				{
					var interaction = Template.ObjectOrSpellInteractions[i];
					
					if (interaction == null || !interaction.IsValid) continue;

					log.Owner.SetQuestCount(Slot, interaction.Index, (byte)Interactions[i]);
				}
			}
			UpdateStatus();
		}
예제 #2
0
파일: Quest.cs 프로젝트: pallmall/WCell
		/// <summary>
		/// Recreate existing Quest-progress
		/// </summary>
		internal Quest(QuestLog log, QuestRecord record, QuestTemplate template)
			: this(log, template, record)
		{
			m_saved = true;

			// reset initial state

			if (template.GOInteractions != null)
			{
				if (UsedGOs == null)
				{
					UsedGOs = new uint[template.NPCInteractions.Length];
				}

				for (var i = 0; i < Template.NPCInteractions.Length; i++)
				{
					var interaction = Template.NPCInteractions[i];
					log.Owner.SetQuestCount(Slot, interaction.Index, (byte)UsedGOs[i]);
				}
			}
			if (Template.NPCInteractions != null)
			{
				if (KilledNPCs == null)
				{
					KilledNPCs = new uint[template.NPCInteractions.Length];
				}

				for (var i = 0; i < Template.NPCInteractions.Length; i++)
				{
					var interaction = Template.NPCInteractions[i];
					log.Owner.SetQuestCount(Slot, interaction.Index, (byte)KilledNPCs[i]);
				}
			}
			UpdateStatus();
		}
예제 #3
0
		static void InitQuest()
		{
			AmbusherQuest = new QuestTemplate {
				Id = 12345,
				// TODO: Setup QuestTemplate here
			};
		}
예제 #4
0
        public static void DumpQuest(IndentTextWriter writer, QuestTemplate quest)
        {
            writer.WriteLine("Quest: " + quest);
            writer.IndentLevel++;
            quest.Dump(writer);
            writer.IndentLevel--;

            writer.WriteLine();
            writer.WriteLine("##################################################################");
            writer.WriteLine();
        }
예제 #5
0
파일: Quest.cs 프로젝트: KroneckerX/WCell
		/// <summary>
		/// Initializes a new instance of the <see cref="Quest"/> class.
		/// Which represents one item in character's <seealso cref="QuestLog"/>
		/// </summary>
		/// <param name="template">The Quest Template.</param>
		internal Quest(QuestLog log, QuestTemplate template, int slot)
			: this(log, template, new QuestRecord(template.Id, log.Owner.EntityId.Low))
		{
			if (template.HasObjectOrSpellInteractions)
			{
				Interactions = new uint[template.ObjectOrSpellInteractions.Length];
			}
			if (template.AreaTriggerObjectives.Length > 0)
			{
				VisitedATs = new bool[template.AreaTriggerObjectives.Length];
			}

			Slot = slot;
		}
예제 #6
0
파일: Quest.cs 프로젝트: NecroSharper/WCell
        private Quest(QuestLog log, QuestTemplate template, QuestRecord record)
        {
            m_record = record;

            if (template.CollectableItems.Length > 0)
            {
                CollectedItems = new int[template.CollectableItems.Length];
            }

            if (template.CollectableSourceItems.Length > 0)
            {
                CollectedSourceItems = new int[template.CollectableSourceItems.Length];
            }

            m_Log    = log;
            Template = template;
        }
예제 #7
0
        public Quest TryAddQuest(QuestTemplate template, IQuestHolder questGiver)
        {
            var slot = m_Owner.QuestLog.FindFreeSlot();

            if (slot == INVALID_SLOT)
            {
                QuestHandler.SendQuestLogFull(m_Owner);
            }
            else
            {
                var err = template.CheckBasicRequirements(m_Owner);
                if (err != QuestInvalidReason.Ok)
                {
                    QuestHandler.SendQuestInvalid(m_Owner, err);
                }
                else if (m_Owner.QuestLog.GetActiveQuest(template.Id) != null)
                {
                    QuestHandler.SendQuestInvalid(m_Owner, QuestInvalidReason.AlreadyHave);
                }
                else if (!template.Repeatable && m_Owner.QuestLog.FinishedQuests.Contains(template.Id))
                {
                    QuestHandler.SendQuestInvalid(m_Owner, QuestInvalidReason.AlreadyCompleted);
                }
                else if (!questGiver.CanGiveQuestTo(m_Owner))
                {
                    // cheat protection
                    QuestHandler.SendQuestInvalid(m_Owner, QuestInvalidReason.Tired);
                }
                else
                {
                    var quest = m_Owner.QuestLog.AddQuest(template, slot);
                    if (quest.Template.Flags.HasFlag(QuestFlags.Escort))
                    {
                        AutoComplete(quest, m_Owner);
                    }
                    return(quest);
                }
            }
            return(null);
        }
예제 #8
0
        public Quest TryAddQuest(QuestTemplate template, IQuestHolder questGiver)
        {
            int freeSlot = m_Owner.QuestLog.FindFreeSlot();

            if (freeSlot == -1)
            {
                QuestHandler.SendQuestLogFull(m_Owner);
            }
            else
            {
                QuestInvalidReason reason = template.CheckBasicRequirements(m_Owner);
                if (reason != QuestInvalidReason.Ok)
                {
                    QuestHandler.SendQuestInvalid(m_Owner, reason);
                }
                else if (m_Owner.QuestLog.GetActiveQuest(template.Id) != null)
                {
                    QuestHandler.SendQuestInvalid(m_Owner, QuestInvalidReason.AlreadyHave);
                }
                else if (!template.Repeatable && m_Owner.QuestLog.FinishedQuests.Contains(template.Id))
                {
                    QuestHandler.SendQuestInvalid(m_Owner, QuestInvalidReason.AlreadyCompleted);
                }
                else if (!questGiver.CanGiveQuestTo(m_Owner))
                {
                    QuestHandler.SendQuestInvalid(m_Owner, QuestInvalidReason.Tired);
                }
                else
                {
                    Quest quest = m_Owner.QuestLog.AddQuest(template, freeSlot);
                    if (quest.Template.Flags.HasFlag(QuestFlags.Escort))
                    {
                        AutoComplete(quest, m_Owner);
                    }
                    return(quest);
                }
            }

            return(null);
        }
예제 #9
0
파일: Quest.cs 프로젝트: pallmall/WCell
		/// <summary>
		/// Initializes a new instance of the <see cref="Quest"/> class.
		/// Which represents one item in character's <seealso cref="QuestLog"/>
		/// </summary>
		/// <param name="template">The Quest Template.</param>
		internal Quest(QuestLog log, QuestTemplate template, int slot)
			: this(log, template, new QuestRecord(template.Id, log.Owner.EntityId.Low))
		{

			if (template.GOInteractions != null)
			{
				UsedGOs = new uint[template.GOInteractions.Length];
			}
			if (template.NPCInteractions != null)
			{
				KilledNPCs = new uint[template.NPCInteractions.Length];
			}
			if (template.SpellCastObjectives != null)
			{
				CastedSpells = new int[template.SpellCastObjectives.Length];
			}
			if (template.AreaTriggerObjectives.Length > 0)
			{
				VisitedATs = new bool[template.AreaTriggerObjectives.Length];
			}

			Slot = slot;
		}
예제 #10
0
        /// <summary>
        /// If we want this method to be public,
        /// it should update all Quests correctly (remove non-existant ones etc)
        /// </summary>
        internal void Load()
        {
            QuestRecord[] recordForCharacter;
            try
            {
                recordForCharacter = QuestRecord.GetQuestRecordForCharacter(Owner.EntityId.Low);
            }
            catch (Exception ex)
            {
                RealmDBMgr.OnDBError(ex);
                recordForCharacter = QuestRecord.GetQuestRecordForCharacter(Owner.EntityId.Low);
            }

            if (recordForCharacter == null)
            {
                return;
            }
            foreach (QuestRecord record in recordForCharacter)
            {
                QuestTemplate template = QuestMgr.GetTemplate(record.QuestTemplateId);
                if (template != null)
                {
                    Quest quest = new Quest(this, record, template);
                    AddQuest(quest);
                    if (template.EventIds.Count > 0 && !template.EventIds
                        .Where(WorldEventMgr.IsEventActive).Any())
                    {
                        quest.Cancel(false);
                    }
                }
                else
                {
                    log.Error("Character {0} had Invalid Quest: {1} (Record: {2})", Owner,
                              record.QuestTemplateId, record.QuestRecordId);
                }
            }
        }
예제 #11
0
        /// <summary>
        /// Sends the quest query response.
        /// </summary>
        /// <param name="qt">The quest id.</param>
        /// <param name="chr">The client.</param>
        public static void SendQuestQueryResponse(QuestTemplate qt, Character chr)
        {
            var locale = chr.Client.Info.Locale;
            using (var pckt = new RealmPacketOut(RealmServerOpCode.SMSG_QUEST_QUERY_RESPONSE))
            {
                pckt.Write(qt.Id);
                pckt.Write((uint)qt.IsActive);
                pckt.Write(qt.Level);
                pckt.Write(qt.MinLevel);			// since 3.3
                pckt.Write(qt.Category);			// questsort
                pckt.Write((uint)qt.QuestType);
                pckt.Write(qt.SuggestedPlayers);
                pckt.Write((uint)qt.ObjectiveMinReputation.ReputationIndex);
                pckt.Write(qt.ObjectiveMinReputation.Value);
                pckt.Write((uint)qt.ObjectiveMaxReputation.ReputationIndex);
                pckt.Write(qt.ObjectiveMaxReputation.Value);				//  (#10)

                pckt.Write(qt.FollowupQuestId);
                pckt.Write(qt.CalcRewardXp(chr));										// since 3.3

                if (qt.Flags.HasFlag(QuestFlags.HiddenRewards))
                {
                    pckt.Write(0);
                }
                else
                {
                    pckt.Write(qt.RewMoney);
                }
                pckt.Write(qt.MoneyAtMaxLevel);
                pckt.Write((uint)qt.CastSpell);
                if (qt.RewSpell > 0)
                {
                    pckt.Write((uint)qt.RewSpell);
                }
                else
                {
                    pckt.Write((uint)qt.RewSpellCast);
                }

                pckt.Write(qt.RewHonorAddition);
                pckt.WriteFloat(qt.RewHonorMultiplier);										// since 3.3

                pckt.Write((uint)qt.SrcItemId);
                pckt.Write((uint)qt.Flags);
                pckt.Write((uint)qt.RewardTitleId);
                pckt.Write(qt.PlayersSlain);
                pckt.Write(qt.RewardTalents);// NEW 3.0.2 RewardTalentCount (#21)
                pckt.Write(0);										// since 3.3: bonus arena points
                pckt.Write(0);										// since 3.3

                int i;
                if (qt.Flags.HasFlag(QuestFlags.HiddenRewards))
                {
                    for (i = 0; i < QuestConstants.MaxRewardItems; ++i)
                    {
                        pckt.WriteUInt(0u);
                        pckt.WriteUInt(0u);
                    }
                    for (i = 0; i < QuestConstants.MaxRewardChoiceItems; ++i)
                    {
                        pckt.WriteUInt(0u);
                        pckt.WriteUInt(0u);
                    }
                }
                else
                {
                    for (i = 0; i < QuestConstants.MaxRewardItems; i++)
                    {
                        if (i < qt.RewardItems.Length)
                        {
                            pckt.Write((uint)qt.RewardItems[i].ItemId);
                            pckt.Write(qt.RewardItems[i].Amount);
                        }
                        else
                        {
                            pckt.WriteUInt(0u);
                            pckt.WriteUInt(0u);
                        }
                    }

                    for (i = 0; i < QuestConstants.MaxRewardChoiceItems; i++)
                    {
                        if (i < qt.RewardChoiceItems.Length)
                        {
                            pckt.Write((uint)qt.RewardChoiceItems[i].ItemId);
                            pckt.Write(qt.RewardChoiceItems[i].Amount);
                        }
                        else
                        {
                            pckt.WriteUInt(0u);
                            pckt.WriteUInt(0u);
                        }
                    }
                }
                // #### since 3.3
                for (i = 0; i < QuestConstants.MaxReputations; i++)
                    pckt.Write((uint)qt.RewardReputations[i].Faction);
                for (i = 0; i < QuestConstants.MaxReputations; i++)
                    pckt.Write(qt.RewardReputations[i].ValueId);
                for (i = 0; i < QuestConstants.MaxReputations; i++)
                    pckt.Write(qt.RewardReputations[i].Value);

                //     ######

                pckt.Write((uint)qt.MapId);
                pckt.Write(qt.PointX);
                pckt.Write(qt.PointY);
                pckt.Write(qt.PointOpt);

                pckt.WriteCString(qt.Titles.Localize(locale));
                pckt.WriteCString(qt.Instructions.Localize(locale));
                pckt.WriteCString(qt.Details.Localize(locale));
                pckt.WriteCString(qt.EndTexts.Localize(locale));
                pckt.WriteCString(qt.CompletedTexts.Localize(locale));												// since 3.3

                for (i = 0; i < QuestConstants.MaxObjectInteractions; i++)
                {
                    pckt.Write(qt.ObjectOrSpellInteractions[i].RawId);		// Mob or GO entry ID [i]
                    pckt.Write(qt.ObjectOrSpellInteractions[i].Amount);	// amount [i],
                    pckt.Write((uint)qt.CollectableSourceItems[i].ItemId);
                    pckt.Write(qt.CollectableSourceItems[i].Amount);
                }

                for (i = 0; i < QuestConstants.MaxCollectableItems; i++)
                {
                    if (i < qt.CollectableItems.Length)
                    {
                        pckt.Write((uint)qt.CollectableItems[i].ItemId);
                        pckt.Write(qt.CollectableItems[i].Amount);
                    }
                    else
                    {
                        pckt.WriteUInt(0u);
                        pckt.WriteUInt(0u);
                    }
                }

                for (i = 0; i < QuestConstants.MaxObjectiveTexts; i++)
                {
                    var set = qt.ObjectiveTexts[(int)locale];
                    if (set != null)
                    {
                        pckt.Write(set.Texts[i]);
                    }
                    else
                    {
                        pckt.Write("");
                    }
                }
                chr.Client.Send(pckt);
            }
        }
예제 #12
0
 public static void SendQuestForceRemoved(IRealmClient client, QuestTemplate quest)
 {
     using (var pkt = new RealmPacketOut(RealmServerOpCode.SMSG_QUEST_FORCE_REMOVE, 4))
     {
         pkt.Write((uint)quest.Id);
         client.Send(pkt);
     }
 }
예제 #13
0
 public QuestGossipInfo(QuestTemplate qt, IRealmClient client)
 {
     QuestId = qt.Id;
     Title   = qt.DefaultTitle;
 }
예제 #14
0
 public QuestGossipInfo(QuestTemplate qt, IRealmClient client)
 {
     QuestId = qt.Id;
     //Status = QuestMgr.GetQuestStatus(qt,) // kua jak do tohohle?
     Title = qt.DefaultTitle;
 }
예제 #15
0
파일: QuestMgr.cs 프로젝트: MeaNone/WCell
		public static void AddQuest(QuestTemplate template)
		{
			if (Templates.Get(template.Id) == null)
			{
				_questCount++;
			}
			ArrayUtil.Set(ref Templates, template.Id, template);
		}
예제 #16
0
		/// <summary>
		/// Adds the given Quest as new active Quest
		/// Returns null if inital Items could not be handed out.
		/// </summary>
		/// <param name="qt"></param>
		/// <param name="slot"></param>
		/// <returns></returns>
		public Quest AddQuest(QuestTemplate qt, int slot)
		{
			var quest = new Quest(this, qt, slot);

			AddQuest(quest);

			return quest;
		}
예제 #17
0
        /// <summary>
        /// Sends SMSG_QUESTGIVER_REQUEST_ITEMS
        /// </summary>
        /// <param name="qg">The qg.</param>
        /// <param name="qt">The qt.</param>
        /// <param name="chr">The client.</param>
        public static void SendRequestItems(IQuestHolder qg, QuestTemplate qt, Character chr, bool closeOnCancel)
        {
            if (qg.QuestHolderInfo != null)
            {
                //var list = qg.QuestHolderInfo.QuestEnds;
                //if (list != null && list.Contains(qt))
                {
                    var locale = chr.Locale;
                    using (var pckt = new RealmPacketOut(RealmServerOpCode.SMSG_QUESTGIVER_REQUEST_ITEMS))
                    {
                        pckt.Write(qg.EntityId);
                        pckt.Write(qt.Id);
                        pckt.Write(qt.Titles.Localize(locale));
                        pckt.Write(qt.ProgressTexts.Localize(locale));
                        pckt.Write((uint)0); // emote delay
                        pckt.Write((uint)qt.RequestEmoteType); // Emote type
                        if (closeOnCancel)
                        {
                            pckt.Write((uint)1);
                        }
                        else
                        {
                            pckt.Write((uint)0);
                        }
                        pckt.Write((uint)qt.Flags);
                        pckt.Write((uint)qt.SuggestedPlayers);
                        if (qt.RewMoney < 0)
                        {
                            pckt.Write((uint)-qt.RewMoney);
                        }
                        else
                        {
                            pckt.Write((uint)0);
                        }
                        pckt.Write(qt.CollectableItems.Length);
                        for (uint i = 0; i < qt.CollectableItems.Length; i++)
                        {
                            pckt.Write((uint)qt.CollectableItems[i].ItemId);
                            pckt.Write(qt.CollectableItems[i].Amount);
                            var template = qt.CollectableItems[i].Template;
                            if (template != null)
                            {
                                pckt.Write(template.DisplayId);
                            }
                            else
                            {
                                pckt.Write((uint)0);
                            }
                        }
                        pckt.Write((uint)2); // unknown, probably IsActive
                        pckt.Write(4);			// if can advance: 4
                        pckt.Write((uint)8); //always eight
                        pckt.Write((uint)10); // always ten

                        chr.Client.Send(pckt);
                    }
                }
            }
        }
예제 #18
0
        /// <summary>Creates the graph of all quests and their relations</summary>
        private static void CreateQuestRelationGraph()
        {
            Dictionary <int, List <uint> > map = new Dictionary <int, List <uint> >();

            foreach (QuestTemplate template1 in QuestMgr.Templates)
            {
                if (template1 != null)
                {
                    if (template1.Id == 10068U)
                    {
                        template1.ToString();
                    }
                    if (template1.ExclusiveGroup != 0)
                    {
                        map.GetOrCreate <int, uint>(template1.ExclusiveGroup).AddUnique <uint>(template1.Id);
                    }
                    else if (template1.NextQuestId != 0)
                    {
                        QuestTemplate template2 = QuestMgr.GetTemplate((uint)Math.Abs(template1.NextQuestId));
                        if (template2 == null)
                        {
                            ContentMgr.OnInvalidDBData("NextQuestId {0} is invalid in: {1}",
                                                       (object)template1.NextQuestId, (object)template1);
                        }
                        else if (template1.NextQuestId > 0)
                        {
                            template2.ReqAllFinishedQuests.AddUnique <uint>(template1.Id);
                        }
                        else
                        {
                            template2.ReqAllActiveQuests.AddUnique <uint>(template1.Id);
                        }
                    }

                    if (template1.PreviousQuestId != 0)
                    {
                        if (template1.PreviousQuestId > 0)
                        {
                            template1.ReqAllFinishedQuests.AddUnique <uint>((uint)template1.PreviousQuestId);
                        }
                        else
                        {
                            template1.ReqAllActiveQuests.AddUnique <uint>((uint)-template1.PreviousQuestId);
                        }
                    }

                    if (template1.FollowupQuestId != 0U)
                    {
                        QuestTemplate template2 = QuestMgr.GetTemplate(template1.FollowupQuestId);
                        if (template2 != null)
                        {
                            template2.ReqAllFinishedQuests.AddUnique <uint>(template1.Id);
                        }
                    }
                }
            }

            foreach (KeyValuePair <int, List <uint> > keyValuePair in map)
            {
                foreach (uint id in keyValuePair.Value)
                {
                    QuestTemplate template1 = QuestMgr.GetTemplate(id);
                    foreach (uint num in keyValuePair.Value)
                    {
                        if ((int)num != (int)id && keyValuePair.Key > 0)
                        {
                            template1.ReqUndoneQuests.AddUnique <uint>(num);
                        }
                    }

                    if (template1.NextQuestId != 0)
                    {
                        QuestTemplate template2 = QuestMgr.GetTemplate((uint)Math.Abs(template1.NextQuestId));
                        if (template2 == null)
                        {
                            ContentMgr.OnInvalidDBData("NextQuestId {0} is invalid in: {1}",
                                                       (object)template1.NextQuestId, (object)template1);
                        }
                        else if (keyValuePair.Key > 0)
                        {
                            template2.ReqAllFinishedQuests.AddUnique <uint>(template1.Id);
                        }
                        else
                        {
                            template2.ReqAnyFinishedQuests.AddUnique <uint>(template1.Id);
                        }
                    }
                }
            }
        }
예제 #19
0
		public QuestGossipInfo(QuestTemplate qt, IRealmClient client)
		{
			QuestId = qt.Id;
			//Status = QuestMgr.GetQuestStatus(qt,) // kua jak do tohohle?
			Title = qt.Title;
		}
예제 #20
0
파일: Quest.cs 프로젝트: KroneckerX/WCell
		private Quest(QuestLog log, QuestTemplate template, QuestRecord record)
		{
			m_record = record;

			if (template.CollectableItems.Length > 0)
			{
				CollectedItems = new int[template.CollectableItems.Length];
			}

            if (template.CollectableSourceItems.Length > 0)
            {
                CollectedSourceItems = new int[template.CollectableSourceItems.Length];
            }

			m_Log = log;
			Template = template;
		}
예제 #21
0
		public Quest TryAddQuest(QuestTemplate template, IQuestHolder questGiver)
		{
			var slot = m_Owner.QuestLog.FindFreeSlot();
			if (slot == INVALID_SLOT)
			{
				QuestHandler.SendQuestLogFull(m_Owner);
			}
			else
			{
				var err = template.CheckBasicRequirements(m_Owner);
				if (err != QuestInvalidReason.Ok)
				{
					QuestHandler.SendQuestInvalid(m_Owner, err);
				}
				else if (m_Owner.QuestLog.GetActiveQuest(template.Id) != null)
				{
					QuestHandler.SendQuestInvalid(m_Owner, QuestInvalidReason.AlreadyHave);
				}
				else if (!template.Repeatable && m_Owner.QuestLog.FinishedQuests.Contains(template.Id))
				{
					QuestHandler.SendQuestInvalid(m_Owner, QuestInvalidReason.AlreadyCompleted);
				}
				else if (!questGiver.CanGiveQuestTo(m_Owner))
				{
					// cheat protection
					QuestHandler.SendQuestInvalid(m_Owner, QuestInvalidReason.Tired);
				}
				else
				{
					var quest = m_Owner.QuestLog.AddQuest(template, slot);
					if (quest.Template.Flags.HasFlag(QuestFlags.Escort))
					{
						AutoComplete(quest, m_Owner);
					}
					return quest;
				}
			}
			return null;
		}
예제 #22
0
        /// <summary>
        /// Adds the given Quest (if not already existing) marks it as completed
        /// and offers the reward to the user.
        /// Does nothing and returns null if all Quest slots are currently used.
        /// </summary>
        //public Quest SetQuestFinished(QuestTemplate template)
        //{
        //    var quest = GetQuestById(template.Id);
        //    if (quest == null)
        //    {
        //        quest = AddQuest(template);
        //        if (quest == null)
        //        {
        //            return null;
        //        }
        //    }
        //    Owner.QuestHolderInfo.QuestStarts.Add(template);
        //    quest.Status = QuestStatus.Completable;
        //    quest.OfferReward(m_Owner);
        //    return quest;
        //}
        #endregion

        #region Checks/Getters

        public bool HasActiveQuest(QuestTemplate templ)
        {
            return(GetActiveQuest(templ.Id) != null);
        }
예제 #23
0
		/// <summary>
		/// Adds the given new Quest.
		/// Returns null if no free slot was available or inital Items could not be handed out.
		/// </summary>
		/// <param name="qt">The qt.</param>
		/// <returns>false if it failed to add the quest</returns>
		public Quest AddQuest(QuestTemplate qt)
		{
			var slot = FindFreeSlot();
			if (slot != INVALID_SLOT)
			{
				return AddQuest(qt, slot);
			}
			return null;
		}
예제 #24
0
        /// <summary>
        /// Sends the quest giver quest detail.
        /// </summary>
        /// <param name="questGiver">The qg.</param>
        /// <param name="qt">The quest id.</param>
        /// <param name="chr">The client.</param>
        /// <param name="acceptable">if set to <c>true</c> [acceptable].</param>
        public static void SendDetails(IEntity questGiver, QuestTemplate qt, Character chr, bool acceptable)
        {
            var locale = chr.Locale;
            using (var pckt = new RealmPacketOut(RealmServerOpCode.SMSG_QUESTGIVER_QUEST_DETAILS))
            {
                pckt.Write(questGiver != null ? questGiver.EntityId : EntityId.Zero);

                pckt.Write(EntityId.Zero);						// unknown, wotlk, quest sharing?

                pckt.Write(qt.Id);

                pckt.WriteCString(qt.Titles.Localize(locale));
                pckt.WriteCString(qt.Details.Localize(locale));
                pckt.WriteCString(qt.Instructions.Localize(locale));


                pckt.Write((byte)(acceptable ? 1 : 0));			// doesn't work
                pckt.WriteUInt((uint)qt.Flags);
                pckt.WriteUInt(qt.SuggestedPlayers);
                pckt.Write((byte)0); // probably some pvp flag
                if (qt.Flags.HasFlag(QuestFlags.HiddenRewards))
                {
                    pckt.WriteUInt(0u);		// choice items length
                    pckt.WriteUInt(0u);		// reward items length
                    pckt.WriteUInt(0u);		// money
                    pckt.WriteUInt(0u);		// xp
                }
                else
                {
                    pckt.Write(qt.RewardChoiceItems.Length);
                    for (uint i = 0; i < qt.RewardChoiceItems.Length; i++)
                    {
                        pckt.Write((uint)qt.RewardChoiceItems[i].ItemId);
                        pckt.Write(qt.RewardChoiceItems[i].Amount);
                        var template = qt.RewardChoiceItems[i].Template;
                        if (template != null)
                        {
                            pckt.Write(template.DisplayId);
                        }
                        else
                        {
                            pckt.Write(0);
                        }
                    }

                    pckt.Write(qt.RewardItems.Length);
                    for (uint i = 0; i < qt.RewardItems.Length; i++)
                    {
                        pckt.Write((uint)qt.RewardItems[i].ItemId);
                        pckt.Write(qt.RewardItems[i].Amount);

                        var template = qt.RewardItems[i].Template;
                        if (template != null)
                        {
                            pckt.Write(template.DisplayId);
                        }
                        else
                        {
                            pckt.Write(0);
                        }
                    }

                    if (chr.Level >= RealmServerConfiguration.MaxCharacterLevel)
                    {
                        pckt.Write(qt.MoneyAtMaxLevel);
                    }
                    else
                    {
                        pckt.Write(qt.RewMoney);
                    }

                    pckt.Write(qt.CalcRewardXp(chr));						// since 3.3
                }

                pckt.Write(qt.RewHonorAddition);
                pckt.Write(qt.RewHonorMultiplier);						// since 3.3
                if (qt.RewSpell > 0)
                {
                    pckt.Write((uint)qt.RewSpell);
                }
                else
                {
                    pckt.Write((uint)qt.RewSpellCast);
                }
                pckt.Write((uint)qt.CastSpell);
                pckt.Write((uint)qt.RewardTitleId);		// since 2.4.0
                pckt.Write(qt.RewardTalents);

                // #### since 3.3
                pckt.Write(0);						// bonus arena points
                pckt.Write(0);
                for (uint i = 0; i < QuestConstants.MaxReputations; ++i)
                {
                    pckt.Write((uint)qt.RewardReputations[i].Faction);
                }
                for (uint i = 0; i < QuestConstants.MaxReputations; ++i)
                {
                    pckt.Write(qt.RewardReputations[i].ValueId);
                }
                for (uint i = 0; i < QuestConstants.MaxReputations; ++i)
                {
                    pckt.Write(qt.RewardReputations[i].Value);
                }

                pckt.Write(QuestConstants.MaxEmotes);
                for (var i = 0; i < QuestConstants.MaxEmotes; i++)
                {
                    var emote = qt.QuestDetailedEmotes[i];
                    pckt.Write((int)emote.Type);
                    pckt.Write(emote.Delay);
                }
                chr.Client.Send(pckt);
            }
        }
예제 #25
0
		/// <summary>
		/// Sends the quest query response.
		/// </summary>
		/// <param name="qt">The quest id.</param>
		/// <param name="chr">The client.</param>
		public static void SendQuestQueryResponse(QuestTemplate qt, Character chr)
		{
			var locale = chr.Client.Info.Locale;
			using (var pckt = new RealmPacketOut(RealmServerOpCode.SMSG_QUEST_QUERY_RESPONSE))
			{
				pckt.Write(qt.Id);
				pckt.Write((uint)qt.IsActive);
				pckt.Write(qt.Level);
				pckt.Write(qt.MinLevel);			// since 3.3
				pckt.Write(qt.Category);			// questsort
				pckt.Write((uint)qt.QuestType);
				pckt.Write(qt.SuggestedPlayers);
				pckt.Write((uint)qt.MinReqReputation.ReputationIndex);
				pckt.Write(qt.MinReqReputation.Value);
				pckt.Write((uint)qt.MaxReqReputation.ReputationIndex);
				pckt.Write(qt.MaxReqReputation.Value);				//  (#10)

				pckt.Write(qt.FollowupQuestId);
				pckt.Write(0);										// since 3.3

				if (qt.Flags.HasFlag(QuestFlags.HiddenRewards))
				{
					pckt.Write(0);
				}
				else
				{
					pckt.Write(qt.RewMoney);
				}
				pckt.Write(qt.MoneyAtMaxLevel);
				pckt.Write((uint)qt.CastSpell);
				pckt.Write((uint)qt.RewSpell);
				pckt.Write(qt.BonusHonor);
				pckt.Write(0f);										// since 3.3
				pckt.Write((uint)qt.SrcItemId);
				pckt.Write((uint)qt.Flags);
				pckt.Write(qt.RewardTitleId);
				pckt.Write(0);// NEW 3.0.2 PlayerKillCount

				pckt.Write(qt.RewardTalents);// NEW 3.0.2 RewardTalentCount (#21)
				pckt.Write(0);										// since 3.3: bonus arena points
				pckt.Write(0);										// since 3.3
				
				int i;
				for (i = 0; i < qt.RewardItems.Length; i++)
				{
					pckt.Write((uint)qt.RewardItems[i].ItemId);
					pckt.Write(qt.RewardItems[i].Amount);
				}
				for (; i < QuestConstants.MaxRewardItems; i++)
				{
					pckt.Write(0ul);
				}

				for (i = 0; i < qt.RewardChoiceItems.Length; i++)
				{
					pckt.Write((uint)qt.RewardChoiceItems[i].ItemId);
					pckt.Write(qt.RewardChoiceItems[i].Amount);
				}
				for (; i < QuestConstants.MaxRewardChoiceItems; i++)
				{
					pckt.Write(0ul);
				}

				// #### since 3.3
				for (i = 0; i < QuestConstants.MaxReputations; i++)
				{
					pckt.Write(0);
					pckt.Write(0);
					pckt.Write(0);
				}
				//     ######

				pckt.Write((uint)qt.MapId);
				pckt.Write(qt.PointX);
				pckt.Write(qt.PointY);
				pckt.Write(qt.PointOpt);

				pckt.Write(qt.Titles.Localize(locale));
				pckt.Write(qt.Instructions.Localize(locale));
				pckt.Write(qt.Details.Localize(locale));
				pckt.Write(qt.EndTexts.Localize(locale));
				pckt.Write((byte)0);												// since 3.3

				for (i = 0; i < QuestConstants.MaxObjectInteractions; i++)
				{
					pckt.Write(qt.ObjectInteractions[i].RawId);		// Mob or GO entry ID [i]
					pckt.Write(qt.ObjectInteractions[i].Amount);	// amount [i],
					pckt.Write(0);
					pckt.Write(0);									// since 3.3
				}

				for (i = 0; i < qt.CollectableItems.Length; i++)
				{
					pckt.Write((uint)qt.CollectableItems[i].ItemId);
					pckt.Write(qt.CollectableItems[i].Amount);
				}

				for (; i < QuestConstants.MaxObjectInteractions; i++)
				{
					pckt.Write(0L);
				}

				pckt.Write(0L);	// 3.0.8 battleground quests

				for (i = 0; i < 4; i++)
				{
					var set = qt.ObjectiveTexts[(int) locale];
					if (set != null)
					{
						pckt.Write(set.Texts[i]);
					}
					else
					{
						pckt.Write("");
					}
				}
				chr.Client.Send(pckt);
			}
		}
예제 #26
0
        /// <summary>
        /// Offers the reward of the given Quest to the given Character.
        /// When replying the Quest will be complete.
        /// </summary>
        /// <param name="questGiver">The qg.</param>
        /// <param name="qt">The quest id.</param>
        /// <param name="chr">The client.</param>
        public static void SendQuestGiverOfferReward(IEntity questGiver, QuestTemplate qt, Character chr)
        {
            //if (questGiver.QuestHolderInfo != null)

            //var list = qg.QuestHolderInfo.QuestEnds;
            //if (list != null && list.Contains(qt))

            var locale = chr.Locale;
            using (var pckt = new RealmPacketOut(RealmServerOpCode.SMSG_QUESTGIVER_OFFER_REWARD))
            {
                pckt.Write(questGiver.EntityId);
                pckt.WriteUInt(qt.Id);
                pckt.WriteCString(qt.Titles.Localize(locale));
                pckt.WriteCString(qt.OfferRewardTexts.Localize(locale));
                pckt.WriteByte((byte)(qt.FollowupQuestId > 0 ? 1 : 0));

                pckt.WriteUInt((uint)qt.Flags);
                pckt.WriteUInt(qt.SuggestedPlayers); // Suggested Group Num

                pckt.Write(qt.OfferRewardEmotes.Length);
                for (uint i = 0; i < qt.OfferRewardEmotes.Length; i++)
                {
                    pckt.Write(qt.OfferRewardEmotes[i].Delay);
                    pckt.Write((uint)qt.OfferRewardEmotes[i].Type);
                }

                pckt.Write(qt.RewardChoiceItems.Length);
                for (var i = 0; i < qt.RewardChoiceItems.Length; i++)
                {
                    pckt.Write((uint)qt.RewardChoiceItems[i].ItemId);
                    pckt.Write(qt.RewardChoiceItems[i].Amount);
                    var template = qt.RewardChoiceItems[i].Template;
                    if (template != null)
                    {
                        pckt.Write(template.DisplayId);
                    }
                    else
                    {
                        pckt.Write(0);
                    }
                }

                pckt.Write(qt.RewardItems.Length);
                for (var i = 0; i < qt.RewardItems.Length; i++)
                {
                    pckt.Write((uint)qt.RewardItems[i].ItemId);
                    pckt.Write(qt.RewardItems[i].Amount);
                    var template = qt.RewardItems[i].Template;
                    if (template != null)
                    {
                        pckt.WriteUInt(template.DisplayId);
                    }
                    else
                    {
                        pckt.Write(0);
                    }
                }

                if (chr.Level >= RealmServerConfiguration.MaxCharacterLevel)
                {
                    pckt.Write(qt.MoneyAtMaxLevel);
                }
                else
                {
                    pckt.Write(qt.RewMoney);
                }

                pckt.Write(qt.CalcRewardXp(chr));
                pckt.Write(qt.CalcRewardHonor(chr)); // honor points
                pckt.Write(qt.RewHonorMultiplier); // since 3.3

                pckt.Write((uint)0x08); // unused by client
                if (qt.RewSpell > 0)
                {
                    pckt.Write((uint)qt.RewSpell);
                }
                else
                {
                    pckt.Write((uint)qt.RewSpellCast);
                }
                pckt.Write((uint)qt.CastSpell);
                pckt.Write((uint)qt.RewardTitleId);
                pckt.Write(qt.RewardTalents); // reward talents
                pckt.Write(0); // since 3.3
                pckt.Write(0); // since 3.3

                // #### since 3.3
                for (uint i = 0; i < QuestConstants.MaxReputations; i++)
                    pckt.Write((uint)qt.RewardReputations[i].Faction);
                for (uint i = 0; i < QuestConstants.MaxReputations; i++)
                    pckt.Write(qt.RewardReputations[i].ValueId);
                for (uint i = 0; i < QuestConstants.MaxReputations; i++)
                    pckt.Write(qt.RewardReputations[i].Value);

                //     ######

                chr.Client.Send(pckt);
            }
        }
예제 #27
0
		/// <summary>
		/// Sends the quest giver quest detail.
		/// </summary>
		/// <param name="questGiver">The qg.</param>
		/// <param name="qt">The quest id.</param>
		/// <param name="chr">The client.</param>
		/// <param name="acceptable">if set to <c>true</c> [acceptable].</param>
		public static void SendDetails(IEntity questGiver, QuestTemplate qt, Character chr, bool acceptable)
		{
			var locale = chr.Locale;
			using (var pckt = new RealmPacketOut(RealmServerOpCode.SMSG_QUESTGIVER_QUEST_DETAILS))
			{
				if (questGiver != null)
				{
					pckt.Write(questGiver.EntityId);
				}
				else
				{
					pckt.Write(EntityId.Zero);
				}

				pckt.Write(EntityId.Zero);		// unknown, wotlk, quest sharing?

				pckt.Write(qt.Id);

				pckt.WriteCString(qt.Titles.Localize(locale));
				pckt.WriteCString(qt.Details.Localize(locale));
				pckt.WriteCString(qt.Instructions.Localize(locale));


				pckt.Write((byte)(acceptable ? 1 : 0));
			    pckt.Write((uint)qt.Flags);
				pckt.Write(qt.SuggestedPlayers);
				pckt.Write((byte)0); // probably some pvp flag

				pckt.Write(qt.RewardChoiceItems.Length);
				for (uint i = 0; i < qt.RewardChoiceItems.Length; i++)
				{
					pckt.Write((uint)qt.RewardChoiceItems[i].ItemId);
					pckt.Write(qt.RewardChoiceItems[i].Amount);
					var template = qt.RewardChoiceItems[i].Template;
					if (template != null)
					{
						pckt.Write(template.DisplayId);
					}
					else
					{
						pckt.Write(0);
					}
				}

				pckt.Write(qt.RewardItems.Length);
				for (uint i = 0; i < qt.RewardItems.Length; i++)
				{
					pckt.Write((uint)qt.RewardItems[i].ItemId);
					pckt.Write(qt.RewardItems[i].Amount);

					var template = qt.RewardItems[i].Template;
					if (template != null)
					{
						pckt.Write(template.DisplayId);
					}
					else
					{
						pckt.Write(0);
					}
				}

				if (qt.Flags.HasFlag(QuestFlags.HiddenRewards))
				{
					pckt.Write(0);
				}
				else
				{
					pckt.Write(qt.RewMoney);
				}

				pckt.Write(0);						// since 3.3
				pckt.Write(10 * qt.BonusHonor);
				pckt.Write(0f);						// since 3.3
				pckt.Write((uint)qt.RewSpell);
				pckt.Write((uint)qt.CastSpell);
				pckt.Write(qt.RewardTitleId);		// since 2.4.0
				pckt.Write(qt.RewardTalents);

				// #### since 3.3
				pckt.Write(0);						// bonus arena points
				pckt.Write(0);
				for (uint i = 0; i < QuestConstants.MaxReputations; i++)
				{
					pckt.Write(0);
					pckt.Write(0);
					pckt.Write(0);
				}
				// ###########


				// qt.QuestDetailsEmotes
				//TODO FIX UP! and include to quest template
				/*pckt.Write((uint)4); // quantity of emotes, always four
				pckt.Write((uint)1); // emote id 1
				pckt.Write((uint)0); // emote delay or player emote
				pckt.Write((uint)0); // emote id 2
				pckt.Write((uint)0); // emote delay
				pckt.Write((uint)0); // emote id 3
				pckt.Write((uint)0); // emote delay
				pckt.Write((uint)0); // emote id 4
				pckt.Write((uint)0); // emote delay
                */

				pckt.Write(qt.QuestDetailedEmotes.Length);
				for (var i = 0; i < qt.QuestDetailedEmotes.Length; i++)
				{
					var emote = qt.QuestDetailedEmotes[i];
					pckt.Write((int) emote.Type);
					pckt.Write(emote.Delay);
				}
				chr.Client.Send(pckt);
			}
		}
예제 #28
0
        /// <summary>
        /// Sends the quest giver quest complete.
        /// </summary>
        /// <param name="qt">The quest id.</param>
        /// <param name="chr">The client.</param>
        public static void SendComplete(QuestTemplate qt, Character chr)
        {
            using (var pckt = new RealmPacketOut(RealmServerOpCode.SMSG_QUESTGIVER_QUEST_COMPLETE))
            {
                pckt.Write(qt.Id);


                if (chr.Level >= RealmServerConfiguration.MaxCharacterLevel)
                {
                    pckt.Write(0u);
                    pckt.Write(qt.MoneyAtMaxLevel);
                }
                else
                {
                    pckt.Write(qt.CalcRewardXp(chr));
                    pckt.Write(qt.RewMoney);
                }
                pckt.Write(qt.CalcRewardHonor(chr));
                pckt.Write(qt.RewardTalents);
                pckt.Write(0);							// since 3.3: Arena reward

                chr.Client.Send(pckt);
                /*if (chr.Level >= LevelMgr.MaxCharacterLevel)
                {
                    pckt.Write(qt.MoneyAtMaxLevel);
                }
                else
                {
                    pckt.Write(qt.RewMoney);
                }
                pckt.Write((uint)0); // unknown value

                pckt.Write(qt.RewardItems.Length);

                foreach (var reward in qt.RewardItems)
                {
                    pckt.Write(reward.ItemId);
                    pckt.Write(reward.Amount);
                }*/
            }
        }
예제 #29
0
		/// <summary>
		/// Adds the given Quest (if not already existing) marks it as completed 
		/// and offers the reward to the user.
		/// Does nothing and returns null if all Quest slots are currently used.
		/// </summary>
		//public Quest SetQuestFinished(QuestTemplate template)
		//{
		//    var quest = GetQuestById(template.Id);
		//    if (quest == null)
		//    {
		//        quest = AddQuest(template);
		//        if (quest == null)
		//        {
		//            return null;
		//        }
		//    }
		//    Owner.QuestHolderInfo.QuestStarts.Add(template);
		//    quest.Status = QuestStatus.Completable;
		//    quest.OfferReward(m_Owner);
		//    return quest;
		//}
		#endregion

		#region Checks/Getters

		public bool HasActiveQuest(QuestTemplate templ)
		{
			return GetActiveQuest(templ.Id) != null;
		}