public static int ChooseNewQuest() { int questChoice = 0; RoshiQuests roshiQuests = new RoshiQuests(); for (int i = 0; i < Quests.Count; i++) { if (Quests[i].IsAvailable()) { if (i <= roshiQuests.QuestsCompleted) { questChoice = i; } } } return(questChoice); }
void CheckQuests() { string NoQuest1 = "Sorry, that's all the requests I have for today."; string NoQuest2 = "Come back tommorow, I should have more jobs for you to do."; string NoQuest3 = "That's all I have for you to do, come back later."; foreach (Player player in Main.player) { if (player.active && player.talkNPC == npc.whoAmI) { var questSystem = player.GetModPlayer <RoshiQuests>(mod); if (questSystem.QuestsCompletedToday >= questSystem.QuestLimitPerDay) { switch (Main.rand.Next(3)) { case 0: Main.npcChatText = NoQuest1; return; case 1: Main.npcChatText = NoQuest2; return; default: Main.npcChatText = NoQuest3; return; } } else if (questSystem.CurrentQuest == 0) { int NewQuest = RoshiQuests.ChooseNewQuest(); Main.npcChatText = RoshiQuests.Quests[NewQuest].ToString(); if (RoshiQuests.Quests[NewQuest] is ItemQuest) { Main.npcChatCornerItem = (RoshiQuests.Quests[NewQuest] as ItemQuest).ItemType; questSystem.CurrentQuest = NewQuest; } if (RoshiQuests.Quests[NewQuest] is KillQuest) { Main.npcChatCornerItem = 0; questSystem.CurrentQuest = NewQuest; } return; } else if (questSystem.CheckQuest()) { Main.npcChatText = questSystem.GetCurrentQuest().SayThanks(); Main.PlaySound(12, -1, -1, 1); questSystem.SpawnReward(npc); questSystem.CompleteQuest(); return; } else { Main.npcChatText = questSystem.GetCurrentQuest().ToString(); if (questSystem.GetCurrentQuest() is ItemQuest) { Main.npcChatCornerItem = (questSystem.GetCurrentQuest() as ItemQuest).ItemType; } if (questSystem.GetCurrentQuest() is KillQuest) { Main.npcChatText += "You have killed " + questSystem.QuestKills + "out of " + (questSystem.GetCurrentQuest() as KillQuest).TargetCount + ", keep at it!"; } } } } }