def nextQuest(self, av, npc, questId): # Get the next QuestId and toNpcId. nextQuestId, toNpcId = Quests.getNextQuest(questId, npc, av) # Get the avatars current quests. avQuests = av.getQuests() questList = [] # Iterate through their current quests. for i in xrange(0, len(avQuests), 5): questDesc = avQuests[i:i + 5] if questDesc[QuestIdIndex] == questId: questDesc[QuestIdIndex] = nextQuestId questDesc[QuestToNpcIdIndex] = toNpcId questDesc[QuestProgressIndex] = 0 questList.append(questDesc) # Show the quest movie and set their quests. npc.incompleteQuest(av.doId, nextQuestId, Quests.QUEST, toNpcId) av.b_setQuests(questList)
def requestInteract(self, avId, npc): # Get the avatar. av = self.air.doId2do.get(avId) if not av: return avQuestPocketSize = av.getQuestCarryLimit() avQuests = av.getQuests() needTrackTask = False fakeTier = 0 avTrackProgress = av.getTrackProgress() if avTrackProgress[0] == -1: avQuestTier = av.getRewardTier() if avQuestTier < Quests.DG_TIER and avQuestTier > Quests.DD_TIER: fakeTier = Quests.DD_TIER needTrackTask = True elif avQuestTier < Quests.BR_TIER and avQuestTier > Quests.MM_TIER: fakeTier = Quests.MM_TIER needTrackTask = True elif avQuestTier < Quests.DL_TIER and avQuestTier > Quests.BR_TIER: fakeTier = Quests.BR_TIER needTrackTask = True # Iterate through their quests. for i in xrange(0, len(avQuests), 5): questDesc = avQuests[i:i + 5] questId, fromNpcId, toNpcId, rewardId, toonProgress = questDesc questClass = Quests.getQuest(questId, avId) if questClass: completeStatus = questClass.getCompletionStatus(av, questDesc, npc) else: continue # If the quest is a DeliverGagQuest, add the gags. if isinstance(questClass, Quests.DeliverGagQuest): # Check if it's the required NPC. if npc.npcId == toNpcId: # Add progress. questList = [] progress = questClass.removeGags(av) for i in xrange(0, len(avQuests), 5): questDesc = avQuests[i:i + 5] if questDesc[QuestIdIndex] == questId: questDesc[QuestProgressIndex] += progress if questDesc[QuestProgressIndex] >= questClass.getNumGags(): completeStatus = Quests.COMPLETE questList.append(questDesc) av.b_setQuests(questList) if completeStatus != Quests.COMPLETE: continue # If they've completed a quest. if completeStatus == Quests.COMPLETE: # ToonUp the toon to max health. av.toonUp(av.maxHp) # If it's a TrackChoiceQuest then present their track choices. if isinstance(questClass, Quests.TrackChoiceQuest): npc.presentTrackChoice(avId, questId, questClass.getChoices()) break # If there is another part to this quest then give them that. if Quests.getNextQuest(questId, npc, av)[0] != Quests.NA: self.nextQuest(av, npc, questId) if avId in self.air.tutorialManager.avId2fsm: self.air.tutorialManager.avId2fsm[avId].demand('Tunnel') break else: # The toon has completed this quest. Give them a reward! npc.completeQuest(avId, questId, rewardId) self.completeQuest(av, questId) break else: # They haven't completed any quests so we have to give them choices. # If they've got a full pouch then reject them. if (len(avQuests) == avQuestPocketSize*5): npc.rejectAvatar(avId) return elif isinstance(npc, DistributedNPCSpecialQuestGiverAI): # Don't display choices. Force a choice. self.tutorialQuestChoice(avId, npc) return else: #Present quest choices. if needTrackTask: choices = self.npcGiveTrackChoice(av, fakeTier) else: choices = self.avatarQuestChoice(av, npc) if choices != []: npc.presentQuestChoice(avId, choices) else: npc.rejectAvatar(avId)