def initQuestFrame(self, toon, avQuests):
        self.endTrackFrame.hide()
        self.gagExpFrame.hide()
        self.newGagFrame.hide()
        self.promotionFrame.hide()
        self.questFrame.show()
        self.itemFrame.hide()
        self.cogPartFrame.hide()
        self.missedItemFrame.hide()
        for i in xrange(ToontownGlobals.MaxQuestCarryLimit):
            questLabel = self.questLabelList[i]
            questLabel['text_fg'] = (0, 0, 0, 1)
            questLabel.hide()

        for i in xrange(len(avQuests)):
            questDesc = avQuests[i]
            questId, npcId, toNpcId, rewardId, toonProgress = questDesc
            quest = Quests.getQuest(questId)
            if quest:
                questString = quest.getString()
                progressString = quest.getProgressString(toon, questDesc)
                rewardString = quest.getRewardString(progressString)
                rewardString = Quests.fillInQuestNames(rewardString, toNpcId=toNpcId)
                completed = quest.getCompletionStatus(toon, questDesc) == Quests.COMPLETE
                questLabel = self.questLabelList[i]
                questLabel.show()
                if base.localAvatar.tutorialAck:
                    questLabel['text'] = rewardString
                    if completed:
                        questLabel['text_fg'] = (0, 0.3, 0, 1)
                else:
                    questLabel['text'] = questString + ' :'
    def initQuestFrame(self, toon, avQuests):
        self.endTrackFrame.hide()
        self.gagExpFrame.hide()
        self.newGagFrame.hide()
        self.promotionFrame.hide()
        self.questFrame.show()
        self.itemFrame.hide()
        self.cogPartFrame.hide()
        self.missedItemFrame.hide()
        for i in xrange(ToontownGlobals.MaxQuestCarryLimit):
            questLabel = self.questLabelList[i]
            questLabel['text_fg'] = (0, 0, 0, 1)
            questLabel.hide()

        for i in xrange(len(avQuests)):
            questDesc = avQuests[i]
            questId, npcId, toNpcId, rewardId, toonProgress = questDesc
            quest = Quests.getQuest(questId)
            if quest:
                questString = quest.getString()
                progressString = quest.getProgressString(toon, questDesc)
                rewardString = quest.getRewardString(progressString)
                rewardString = Quests.fillInQuestNames(rewardString,
                                                       toNpcId=toNpcId)
                completed = quest.getCompletionStatus(
                    toon, questDesc) == Quests.COMPLETE
                questLabel = self.questLabelList[i]
                questLabel.show()
                if base.localAvatar.tutorialAck:
                    questLabel['text'] = rewardString
                    if completed:
                        questLabel['text_fg'] = (0, 0.3, 0, 1)
                else:
                    questLabel['text'] = questString + ' :'
Beispiel #3
0
    def __tasksChanged(self):
        self.clearMenu()
        try:
            lt = base.localAvatar
        except:
            return

        phrases = []

        def addTerminal(terminal, self = self, phrases = phrases):
            displayText = terminal.getDisplayText()
            if displayText not in phrases:
                self.append(terminal)
                phrases.append(displayText)

        for task in lt.quests:
            taskId, fromNpcId, toNpcId, rewardId, toonProgress = task
            try:
               q = Quests.getQuest(taskId, base.localAvatar.doId)
            except:
                continue 
            if q is None:
                continue
            msgs = q.getSCStrings(toNpcId, toonProgress)
            if type(msgs) != type([]):
                msgs = [msgs]
            for i in xrange(len(msgs)):
                addTerminal(TTSCToontaskTerminal(msgs[i], taskId, toNpcId, toonProgress, i))

        needToontask = 1
        if hasattr(lt, 'questCarryLimit'):
            needToontask = len(lt.quests) != lt.questCarryLimit
        if needToontask:
            addTerminal(SCStaticTextTerminal(1299))
        return
    def toonCaughtFishingItem(self, av):
        # Get the avatars current quests.
        avQuests = av.getQuests()
        fishingItem = -1
        questList = []

        # Iterate through their current quests.
        for i in xrange(0, len(avQuests), 5):
            questDesc = avQuests[i : i + 5]
            questClass = Quests.getQuest(questDesc[QuestIdIndex], av.doId)
            if fishingItem != -1:
                questList.append(questDesc)
                continue
            if isinstance(questClass, Quests.RecoverItemQuest):
                if not hasattr(questClass, 'getItem'):
                    questList.append(questDesc)
                    continue
                if questClass.getHolder() == Quests.AnyFish:
                    if not questClass.getCompletionStatus(av, questDesc) == Quests.COMPLETE:
                        baseChance = questClass.getPercentChance()
                        amountRemaining = questClass.getNumItems() - questDesc[QuestProgressIndex]
                        chance = Quests.calcRecoverChance(amountRemaining, baseChance)
                        if chance >= baseChance:
                            questDesc[QuestProgressIndex] += 1
                            fishingItem = questClass.getItem()
            questList.append(questDesc)

        av.b_setQuests(questList)
        return fishingItem
 def toonCalledClarabelle(self, av):
     avQuests = av.getQuests()
     questList = []
     for i in xrange(0, len(avQuests), 5):
         questDesc = avQuests[i : i + 5]
         questClass = Quests.getQuest(questDesc[QuestIdIndex], av.doId)
         if isinstance(questClass, Quests.PhoneQuest) and questClass.getCompletionStatus(av, questDesc) == Quests.INCOMPLETE:
             questDesc[QuestProgressIndex] += 1
         questList.append(questDesc)
     av.b_setQuests(questList)
    def removeClothingTicket(self, av, npc):
        # Get the avatars current quests.
        avQuests = av.getQuests()

        # Iterate through their current quests.
        for i in xrange(0, len(avQuests), 5):
            questDesc = avQuests[i : i + 5]
            questClass = Quests.getQuest(questDesc[QuestIdIndex], av.doId)
            if isinstance(questClass, Quests.DeliverItemQuest):
                if questClass.getCompletionStatus(av, questDesc, npc) == Quests.COMPLETE:
                    av.removeQuest(questDesc[QuestIdIndex])
                    break
    def recoverItems(self, av, suitsKilled, taskZoneId):
        # Get the avatars current quests.
        avQuests = av.getQuests()
        questList = []
        recoveredItems = []
        unrecoveredItems = []
        taskZoneId = ZoneUtil.getBranchZone(taskZoneId)

        # Iterate through the avatars current quests.
        for i in xrange(0, len(avQuests), 5):
            questDesc = avQuests[i : i + 5]
            questClass = Quests.getQuest(questDesc[QuestIdIndex], av.doId)

            # Check if the Quest isnt already complete
            if questClass.getCompletionStatus(av, questDesc) == Quests.INCOMPLETE:

                # Check if we are dealing with a RecoverItemQuest
                if isinstance(questClass, Quests.RecoverItemQuest):

                    # Iterate through all the Cogs that were killed in the battle
                    for suit in suitsKilled:

                        # Because the RecoveItemQuest class doesn't have a
                        # function to see if a Cog counts. We need to manually
                        # check if the Cog is valid for the Quest
                        if (questClass.getHolder() == Quests.Any) or \
                            (questClass.getHolderType() == 'type' and \
                            questClass.getHolder() == suit['type']) or \
                            (questClass.getHolderType() == 'track' and \
                            questClass.getHolder() == suit['track']) or \
                            (questClass.getHolderType() == 'level' and \
                            questClass.getHolder() <= suit['level']):

                            # It looks like the Cog was valid. Lets see if they
                            # found what they were looking for.
                            baseChance = questClass.getPercentChance()
                            amountRemaining = questClass.getNumItems() - questDesc[QuestProgressIndex]
                            chance = Quests.calcRecoverChance(amountRemaining, baseChance)

                            # They found it! Give them their reward!
                            if chance >= baseChance:
                                questDesc[QuestProgressIndex] += 1
                                recoveredItems.append(questClass.getItem())

                            # Better luck next time :(
                            else:
                                unrecoveredItems.append(questClass.getItem())

            questList.append(questDesc)

        av.b_setQuests(questList)

        return (recoveredItems, unrecoveredItems)
def decodeTTSCToontaskMsg(taskId, toNpcId, toonProgress, msgIndex):
    q = Quests.getQuest(taskId)
    if q is None:
        return
    name = NPCToons.getNPCName(toNpcId)
    if name is None:
        return
    msgs = q.getSCStrings(toNpcId, toonProgress)
    if type(msgs) != type([]):
        msgs = [msgs]
    if msgIndex >= len(msgs):
        return
    return msgs[msgIndex]
Beispiel #9
0
def decodeTTSCToontaskMsg(taskId, toNpcId, toonProgress, msgIndex):
    q = Quests.getQuest(taskId)
    if q is None:
        return
    name = NPCToons.getNPCName(toNpcId)
    if name is None:
        return
    msgs = q.getSCStrings(toNpcId, toonProgress)
    if type(msgs) != type([]):
        msgs = [msgs]
    if msgIndex >= len(msgs):
        return
    return msgs[msgIndex]
    def toonMadeNPCFriend(self, av, count, method):
        avQuests = av.getQuests()
        questList = []

        for i in xrange(0, len(avQuests), 5):
            questDesc = avQuests[i : i + 5]
            questClass = Quests.getQuest(questDesc[QuestIdIndex], av.doId)

            if isinstance(questClass, Quests.RescueQuest) and questClass.getCompletionStatus(av, questDesc) == Quests.INCOMPLETE and questClass.isMethodMatch(method):
                questDesc[QuestProgressIndex] += count
            questList.append(questDesc)

        av.b_setQuests(questList)
Beispiel #11
0
    def updateQuestInfo(self):
        for marker in self.buildingMarkers:
            marker.destroy()

        self.buildingMarkers = []

        for (i, questDesc) in enumerate(self.av.quests):
            mapIndex = i + 1
            quest = Quests.getQuest(questDesc[0])
            toNpcId = questDesc[2]

            completed = quest.getCompletionStatus(self.av,
                                                  questDesc) == Quests.COMPLETE
            if not completed:
                if quest.getType() == Quests.RecoverItemQuest:
                    if quest.getHolder() == Quests.AnyFish:
                        self.putBuildingMarker(self.fishingSpotInfo,
                                               mapIndex=mapIndex)
                    continue
                elif quest.getType() not in (Quests.DeliverGagQuest,
                                             Quests.DeliverItemQuest,
                                             Quests.VisitQuest,
                                             Quests.TrackChoiceQuest):
                    continue

            if toNpcId == Quests.ToonHQ:
                self.putBuildingMarker(self.hqPosInfo, mapIndex=mapIndex)
                continue

            npcZoneId = NPCToons.getNPCZone(toNpcId)
            hoodId = ZoneUtil.getCanonicalHoodId(npcZoneId)
            branchId = ZoneUtil.getCanonicalBranchZone(npcZoneId)

            if (self.hoodId != hoodId) or (self.zoneId != branchId):
                continue

            for blockIndex in xrange(
                    base.cr.playGame.dnaStore.getNumBlockNumbers()):
                blockNumber = base.cr.playGame.dnaStore.getBlockNumberAt(
                    blockIndex)
                zoneId = base.cr.playGame.dnaStore.getZoneFromBlockNumber(
                    blockNumber)
                interiorZoneId = (zoneId - (zoneId % 100)) + 500 + blockNumber
                if npcZoneId == interiorZoneId:
                    self.putBuildingMarker(
                        base.cr.playGame.dnaStore.getDoorPosHprFromBlockNumber(
                            blockNumber).getPos(render),
                        base.cr.playGame.dnaStore.getDoorPosHprFromBlockNumber(
                            blockNumber).getHpr(render),
                        mapIndex=mapIndex,
                        zoneId=zoneId)
    def toonPlayedMinigame(self, av, toons):
        # 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]
            questClass = Quests.getQuest(questDesc[QuestIdIndex], av.doId)
            if isinstance(questClass, Quests.TrolleyQuest):
                questDesc[QuestProgressIndex] = 1
            questList.append(questDesc)

        av.b_setQuests(questList)
    def toonDefeatedMint(self, av, mintId):
        # Get the avatars current quests.
        avQuests = av.getQuests()
        questList = []

        # Iterate through the avatars current quests.
        for i in xrange(0, len(avQuests), 5):
            questDesc = avQuests[i : i + 5]
            questClass = Quests.getQuest(questDesc[QuestIdIndex], av.doId)
            if isinstance(questClass, Quests.MintQuest):
                if questClass.doesMintCount(av, mintId):
                    questDesc[QuestProgressIndex] += 1
            questList.append(questDesc)

        av.b_setQuests(questList)
    def completeQuest(self, av, completeQuestId):
        #Get the avatars current quests.
        avQuests = av.getQuests()

        # Iterate through their current quests.
        for i in xrange(0, len(avQuests), 5):
            questDesc = avQuests[i:i + 5]
            questId, fromNpcId, toNpcId, rewardId, toonProgress = questDesc
            questClass = Quests.getQuest(questId, av.doId)

            if questId == completeQuestId:
                av.removeQuest(questId)
                self.giveReward(av, questId, rewardId)
                self.avatarConsiderProgressTier(av)
                break
    def toonKilledBuilding(self, av, type, difficulty, floors, zoneId, cogdo):
        # Get the avatars current quests.
        avQuests = av.getQuests()
        questList = []
        zoneId = ZoneUtil.getBranchZone(zoneId)

        # Iterate through the avatars current quests.
        for i in xrange(0, len(avQuests), 5):
            questDesc = avQuests[i : i + 5]
            questClass = Quests.getQuest(questDesc[QuestIdIndex], av.doId)
            if isinstance(questClass, Quests.BuildingQuest) and questClass.getCompletionStatus(av, questDesc) == Quests.INCOMPLETE:
                if questClass.isLocationMatch(zoneId) and questClass.doesBuildingTypeCount(type):
                    if questClass.isCogdo() == cogdo:
                        if floors >= questClass.getNumFloors():
                            questDesc[QuestProgressIndex] += 1
            questList.append(questDesc)

        av.b_setQuests(questList)
    def toonUsedPhone(self, avId):
        # Get the avatar.
        av = self.air.doId2do.get(avId)
        if not av:
            return

        # 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]
            questClass = Quests.getQuest(questDesc[QuestIdIndex], av.doId)
            if isinstance(questClass, Quests.PhoneQuest):
                questDesc[QuestProgressIndex] += 1
            questList.append(questDesc)

        av.b_setQuests(questList)
    def toonMadeFriend(self, avId):
        # Get the avatar.
        av = self.air.doId2do.get(avId)
        if not av:
            return

        # 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]
            questClass = Quests.getQuest(questDesc[QuestIdIndex], av.doId)
            if isinstance(questClass, Quests.FriendQuest) and questClass.getCompletionStatus(av, questDesc) == Quests.INCOMPLETE:
                questDesc[QuestProgressIndex] += 1
            questList.append(questDesc)

        av.b_setQuests(questList)
    def updateQuestInfo(self):
        for marker in self.buildingMarkers:
            marker.destroy()

        self.buildingMarkers = []

        for (i, questDesc) in enumerate(self.av.quests):
            mapIndex = i + 1
            quest = Quests.getQuest(questDesc[0])
            toNpcId = questDesc[2]

            completed = quest.getCompletionStatus(self.av, questDesc) == Quests.COMPLETE
            if not completed:
                if quest.getType() == Quests.RecoverItemQuest:
                    if quest.getHolder() == Quests.AnyFish:
                        self.putBuildingMarker(self.fishingSpotInfo, mapIndex=mapIndex)
                    continue
                elif quest.getType() not in (
                    Quests.DeliverGagQuest, Quests.DeliverItemQuest,
                    Quests.VisitQuest, Quests.TrackChoiceQuest):
                    continue

            if toNpcId == Quests.ToonHQ:
                self.putBuildingMarker(self.hqPosInfo, mapIndex=mapIndex)
                continue

            npcZoneId = NPCToons.getNPCZone(toNpcId)
            hoodId = ZoneUtil.getCanonicalHoodId(npcZoneId)
            branchId = ZoneUtil.getCanonicalBranchZone(npcZoneId)

            if (self.hoodId != hoodId) or (self.zoneId != branchId):
                continue

            for blockIndex in xrange(base.cr.playGame.dnaStore.getNumBlockNumbers()):
                blockNumber = base.cr.playGame.dnaStore.getBlockNumberAt(blockIndex)
                zoneId = base.cr.playGame.dnaStore.getZoneFromBlockNumber(blockNumber)
                interiorZoneId = (zoneId - (zoneId%100)) + 500 + blockNumber
                if npcZoneId == interiorZoneId:
                    self.putBuildingMarker(
                        base.cr.playGame.dnaStore.getDoorPosHprFromBlockNumber(blockNumber).getPos(render),
                        base.cr.playGame.dnaStore.getDoorPosHprFromBlockNumber(blockNumber).getHpr(render),
                        mapIndex=mapIndex, zoneId=zoneId)
    def toonKilledCogs(self, av, suitsKilled, zoneId):
        # Get the avatar's current quests.
        avQuests = av.getQuests()
        questList = []

        # Iterate through the avatar's current quests.
        for i in xrange(0, len(avQuests), 5):
            questDesc = avQuests[i : i + 5]
            questClass = Quests.getQuest(questDesc[QuestIdIndex], av.doId)

            # Check if they are doing a cog quest
            if isinstance(questClass, Quests.CogQuest):
                # Check if the cog counts...
                for suit in suitsKilled:
                    if questClass.doesCogCount(av.doId, suit, zoneId):
                        # Looks like the cog counts!
                        if questClass.getCompletionStatus(av, questDesc) != Quests.COMPLETE:
                            questDesc[QuestProgressIndex] += 1

            # Add the quest to the questList
            questList.append(questDesc)

        # Update the avatar's quests
        av.b_setQuests(questList)
    def getQuestIntervalList(self,
                             toon,
                             deathList,
                             toonList,
                             origQuestsList,
                             itemList,
                             helpfulToonsList=[]):
        avId = toon.getDoId()
        tickDelay = 0.2
        intervalList = []

        cogList = []
        for i in xrange(0, len(deathList), 4):
            cogIndex = deathList[i]
            cogLevel = deathList[i + 1]
            activeToonBits = deathList[i + 2]
            flags = deathList[i + 3]
            activeToonIds = []
            for j in xrange(8):
                if activeToonBits & 1 << j:
                    if toonList[j] is not None:
                        activeToonIds.append(toonList[j].getDoId())

            isSkelecog = flags & ToontownBattleGlobals.DLF_SKELECOG
            isForeman = flags & ToontownBattleGlobals.DLF_FOREMAN
            isBoss = flags & ToontownBattleGlobals.DLF_BOSS
            isSupervisor = flags & ToontownBattleGlobals.DLF_SUPERVISOR
            isVirtual = flags & ToontownBattleGlobals.DLF_VIRTUAL
            hasRevives = flags & ToontownBattleGlobals.DLF_REVIVES
            if isBoss > 0:
                cogType = None
                cogTrack = SuitDNA.suitDepts[cogIndex]
            else:
                cogType = SuitDNA.suitHeadTypes[cogIndex]
                cogTrack = SuitDNA.getSuitDept(cogType)
            cogList.append({
                'type': cogType,
                'level': cogLevel,
                'track': cogTrack,
                'isSkelecog': isSkelecog,
                'isForeman': isForeman,
                'isBoss': isBoss,
                'isSupervisor': isSupervisor,
                'isVirtual': isVirtual,
                'hasRevives': hasRevives,
                'activeToons': activeToonIds
            })

        try:
            zoneId = base.cr.playGame.getPlace().getTaskZoneId()
        except:
            zoneId = 0

        avQuests = []
        for i in xrange(0, len(origQuestsList), 5):
            avQuests.append(origQuestsList[i:i + 5])

        for i in xrange(len(avQuests)):
            questDesc = avQuests[i]
            questId, npcId, toNpcId, rewardId, toonProgress = questDesc
            quest = Quests.getQuest(questId)
            if quest and i < len(self.questLabelList):
                questString = quest.getString()
                progressString = quest.getProgressString(toon, questDesc)
                questLabel = self.questLabelList[i]
                earned = 0
                orig = questDesc[4] & pow(2, 16) - 1
                num = 0
                if quest.getType() == Quests.RecoverItemQuest:
                    questItem = quest.getItem()
                    if questItem in itemList:
                        earned = itemList.count(questItem)
                else:
                    for cogDict in cogList:
                        num = quest.doesCogCount(avId, cogDict, zoneId)

                        if num:
                            if base.config.GetBool('battle-passing-no-credit',
                                                   True):
                                if avId in helpfulToonsList:
                                    earned += num
                                else:
                                    self.notify.debug(
                                        'avId=%d not getting %d kill cog quest credit'
                                        % (avId, num))
                            else:
                                earned += num

                if base.localAvatar.tutorialAck:
                    if earned > 0:
                        earned = min(earned,
                                     quest.getNumQuestItems() - questDesc[4])
                if earned > 0 or base.localAvatar.tutorialAck == 0 and num == 1:
                    barTime = 0.5
                    numTicks = int(math.ceil(barTime / tickDelay))
                    for i in xrange(numTicks):
                        t = (i + 1) / float(numTicks)
                        newValue = int(orig + t * earned + 0.5)
                        questDesc[4] = newValue
                        progressString = quest.getProgressString(
                            toon, questDesc)
                        str = '%s : %s' % (questString, progressString)
                        if quest.getCompletionStatus(
                                toon, questDesc) == Quests.COMPLETE:
                            intervalList.append(
                                Func(questLabel.setProp, 'text_fg',
                                     (0, 0.3, 0, 1)))
                        intervalList.append(
                            Func(questLabel.setProp, 'text', str))
                        intervalList.append(Wait(tickDelay))

        return intervalList
    def getQuestIntervalList(self, toon, deathList, toonList, origQuestsList, itemList, helpfulToonsList = []):
        avId = toon.getDoId()
        tickDelay = 0.2
        intervalList = []

        cogList = []
        for i in xrange(0, len(deathList), 4):
            cogIndex = deathList[i]
            cogLevel = deathList[i + 1]
            activeToonBits = deathList[i + 2]
            flags = deathList[i + 3]
            activeToonIds = []
            for j in xrange(8):
                if activeToonBits & 1 << j:
                    if toonList[j] is not None:
                        activeToonIds.append(toonList[j].getDoId())

            isSkelecog = flags & ToontownBattleGlobals.DLF_SKELECOG
            isForeman = flags & ToontownBattleGlobals.DLF_FOREMAN
            isBoss = flags & ToontownBattleGlobals.DLF_BOSS
            isSupervisor = flags & ToontownBattleGlobals.DLF_SUPERVISOR
            isVirtual = flags & ToontownBattleGlobals.DLF_VIRTUAL
            hasRevives = flags & ToontownBattleGlobals.DLF_REVIVES
            if isBoss > 0:
                cogType = None
                cogTrack = SuitDNA.suitDepts[cogIndex]
            else:
                cogType = SuitDNA.suitHeadTypes[cogIndex]
                cogTrack = SuitDNA.getSuitDept(cogType)
            cogList.append({'type': cogType,
             'level': cogLevel,
             'track': cogTrack,
             'isSkelecog': isSkelecog,
             'isForeman': isForeman,
             'isBoss': isBoss,
             'isSupervisor': isSupervisor,
             'isVirtual': isVirtual,
             'hasRevives': hasRevives,
             'activeToons': activeToonIds})

        try:
            zoneId = base.cr.playGame.getPlace().getTaskZoneId()
        except:
            zoneId = 0

        avQuests = []
        for i in xrange(0, len(origQuestsList), 5):
            avQuests.append(origQuestsList[i:i + 5])

        for i in xrange(len(avQuests)):
            questDesc = avQuests[i]
            questId, npcId, toNpcId, rewardId, toonProgress = questDesc
            quest = Quests.getQuest(questId)
            if quest and i < len(self.questLabelList):
                questString = quest.getString()
                progressString = quest.getProgressString(toon, questDesc)
                questLabel = self.questLabelList[i]
                earned = 0
                orig = questDesc[4] & pow(2, 16) - 1
                num = 0
                if quest.getType() == Quests.RecoverItemQuest:
                    questItem = quest.getItem()
                    if questItem in itemList:
                        earned = itemList.count(questItem)
                else:
                    for cogDict in cogList:
                        num = quest.doesCogCount(avId, cogDict, zoneId)

                        if num:
                            if base.config.GetBool('battle-passing-no-credit', True):
                                if avId in helpfulToonsList:
                                    earned += num
                                else:
                                    self.notify.debug('avId=%d not getting %d kill cog quest credit' % (avId, num))
                            else:
                                earned += num

                if base.localAvatar.tutorialAck:
                    if earned > 0:
                        earned = min(earned, quest.getNumQuestItems() - questDesc[4])
                if earned > 0 or base.localAvatar.tutorialAck == 0 and num == 1:
                    barTime = 0.5
                    numTicks = int(math.ceil(barTime / tickDelay))
                    for i in xrange(numTicks):
                        t = (i + 1) / float(numTicks)
                        newValue = int(orig + t * earned + 0.5)
                        questDesc[4] = newValue
                        progressString = quest.getProgressString(toon, questDesc)
                        str = '%s : %s' % (questString, progressString)
                        if quest.getCompletionStatus(toon, questDesc) == Quests.COMPLETE:
                            intervalList.append(Func(questLabel.setProp, 'text_fg', (0, 0.3, 0, 1)))
                        intervalList.append(Func(questLabel.setProp, 'text', str))
                        intervalList.append(Wait(tickDelay))

        return intervalList
    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)