/// <summary> /// Give the artifact quest to the player. /// </summary> /// <param name="player"></param> /// <param name="questType"></param> private void GiveArtifactQuest(GamePlayer player, Type questType) { if (player == null || questType == null) { return; } ArtifactQuest quest = (ArtifactQuest)Activator.CreateInstance(questType, new object[] { player }); if (quest == null) { return; } player.AddQuest(quest); quest.WhisperReceive(player, this, quest.ArtifactID); }
/// <summary> /// When someone whispers to this scholar /// </summary> /// <param name="source"></param> /// <param name="text"></param> /// <returns></returns> public override bool WhisperReceive(GameLiving source, string text) { GamePlayer player = source as GamePlayer; if (player != null) { lock (QuestListToGive.SyncRoot) { // Start new quest... foreach (ArtifactTurnInQuest quest in QuestListToGive) { if (text.ToLower() == "interested" && quest.CheckQuestQualification(player)) { ArtifactTurnInQuest newQuest = new ArtifactTurnInQuest(player, this.Name); newQuest.Step = 0; player.AddQuest(newQuest); player.Out.SendQuestListUpdate(); SayTo(player, "Since you are still interested, simply hand me your Artifact and I shall begin."); return(true); } } // ...or continuing a quest? foreach (AbstractQuest quest in player.QuestList) { if (quest is ArtifactTurnInQuest && HasQuest(quest.GetType()) != null) { if ((quest as ArtifactTurnInQuest).WhisperReceive(player, this, text)) { return(true); } } } } } return(base.WhisperReceive(source, text)); }
/// <summary> /// Give a quest a to specific player /// used for scripted quests /// </summary> /// <param name="questType">The quest type</param> /// <param name="player">The player that gets the quest</param> /// <param name="startStep">The starting quest step</param> /// <returns>true if added, false if the player do already the quest!</returns> public bool GiveQuest(Type questType, GamePlayer player, int startStep) { AbstractQuest quest = HasQuest(questType); if (quest != null) { AbstractQuest newQuest = (AbstractQuest)Activator.CreateInstance(questType, new object[] { player, startStep }); if (newQuest != null && player.AddQuest(newQuest)) { player.Out.SendNPCsQuestEffect(this, GetQuestIndicator(player)); return true; } } return false; }
/// <summary> /// Check offered quests to see if whisper should be processed /// </summary> /// <param name="player"></param> /// <param name="living"></param> /// <param name="text"></param> protected virtual void CheckOfferedQuestWhisper(GamePlayer player, GameLiving living, string text) { //log.DebugFormat("Checking accept quest: '{0}' ID: {1} of type '{2}', key word '{3}', is qualified {4}", Name, ID, (eStartType)DBDataQuest.StartType, DBDataQuest.AcceptText, CheckQuestQualification(player)); if (CheckQuestQualification(player) && DBDataQuest.StartType == (byte)eStartType.Standard && DBDataQuest.AcceptText == text) { //log.DebugFormat("Adding quest {0} to player {1}", Name, player.Name); CharacterXDataQuest charQuest = GetCharacterQuest(player, ID, true); DataQuest dq = new DataQuest(player, living, DBDataQuest, charQuest); dq.Step = 1; player.AddQuest(dq); if (m_sourceTexts.Count > 0) { SendMessage(player, m_sourceTexts[0], 0, eChatType.CT_System, eChatLoc.CL_PopupWindow); } else { ChatUtil.SendDebugMessage(player, "Source Text missing on accept quest."); } if (living is GameNPC) { UpdateQuestIndicator(living as GameNPC, player); } } }
/// <summary> /// A player has interacted with an object that has a DataQuest. /// Check to see if we can offer this quest to the player and display the text /// </summary> /// <param name="player"></param> /// <param name="obj"></param> protected virtual void CheckOfferQuest(GamePlayer player, GameObject obj) { // Can we offer this quest to the player? if (CheckQuestQualification(player)) { if (StartType == eStartType.InteractComplete) { // This quest finishes with the interaction CharacterXDataQuest charQuest = GetCharacterQuest(player, ID, true); if (charQuest.Count < MaxQuestCount) { if (ExecuteCustomQuestStep(player, 0, eStepCheckType.Finish)) { if (Description.Trim() != "") { SendMessage(player, Description, 0, eChatType.CT_System, eChatLoc.CL_PopupWindow); } if (m_finalRewards.Count > 0) { lock (player.Inventory) { if (player.Inventory.IsSlotsFree(m_finalRewards.Count, eInventorySlot.FirstBackpack, eInventorySlot.LastBackpack)) { foreach (ItemTemplate item in m_finalRewards) { if (item != null) { GiveItem((obj is GameLiving ? obj as GameLiving : null), player, item, false); } } } else { SendMessage(player, "Your inventory does not have enough space to finish this quest!", 0, eChatType.CT_System, eChatLoc.CL_PopupWindow); return; } } } if (m_rewardXPs.Count > 0 && m_rewardXPs[0] > 0) { player.GainExperience(GameLiving.eXPSource.Quest, m_rewardXPs[0]); } if (m_rewardMoneys.Count > 0 && m_rewardMoneys[0] > 0) { player.AddMoney(m_rewardMoneys[0], "You are awarded {0}!"); InventoryLogging.LogInventoryAction("(QUEST;" + Name + ")", player, eInventoryActionType.Quest, m_rewardMoneys[0]); } charQuest.Count++; GameServer.Database.SaveObject(charQuest); bool add = true; lock (player.QuestListFinished) { foreach (AbstractQuest q in player.QuestListFinished) { if (q is DataQuest && (q as DataQuest).ID == ID) { add = false; break; } } } if (add) { player.QuestListFinished.Add(this); } player.Out.SendQuestListUpdate(); player.Out.SendMessage(String.Format(LanguageMgr.GetTranslation(player.Client, "AbstractQuest.FinishQuest.Completed", Name)), eChatType.CT_ScreenCenter, eChatLoc.CL_SystemWindow); player.Out.SendMessage(String.Format(LanguageMgr.GetTranslation(player.Client, "AbstractQuest.FinishQuest.Completed", Name)), eChatType.CT_Important, eChatLoc.CL_SystemWindow); } } return; } if (StartType == eStartType.AutoStart) { CharacterXDataQuest charQuest = GetCharacterQuest(player, ID, true); DataQuest dq = new DataQuest(player, obj, DBDataQuest, charQuest); dq.Step = 1; player.AddQuest(dq); if (m_sourceTexts.Count > 0) { if (string.IsNullOrEmpty(m_sourceTexts[0]) == false) { SendMessage(player, m_sourceTexts[0], 0, eChatType.CT_System, eChatLoc.CL_PopupWindow); } } else { ChatUtil.SendDebugMessage(player, "Source Text missing on AutoStart quest."); } if (obj is GameNPC) { UpdateQuestIndicator(obj as GameNPC, player); } return; } // Send offer quest dialog if (StartType == eStartType.RewardQuest) { GameNPC offerNPC = obj as GameNPC; if (offerNPC != null) { // Note: If the offer is handled by the custom step then it should return false to prevent a double offer if (ExecuteCustomQuestStep(player, 0, eStepCheckType.Offer)) { player.Out.SendQuestOfferWindow(offerNPC, player, this); } } } else if (string.IsNullOrEmpty(Description) == false) { SendMessage(player, Description, 0, eChatType.CT_System, eChatLoc.CL_PopupWindow); } } }
/// <summary> /// Give the artifact quest to the player. /// </summary> /// <param name="player"></param> /// <param name="questType"></param> private void GiveArtifactQuest(GamePlayer player, Type questType) { if (player == null || questType == null) return; ArtifactQuest quest = (ArtifactQuest)Activator.CreateInstance(questType, new object[] { player }); if (quest == null) return; player.AddQuest(quest); quest.WhisperReceive(player, this, quest.ArtifactID); }