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])
            if questClass.getCompletionStatus(av, questDesc) == Quests.INCOMPLETE:
                if isinstance(questClass, Quests.CogQuest):
                    for suit in suitsKilled:
                        if questClass.doesCogCount(av.doId, suit, taskZoneId, suit['activeToons']):
                            questDesc[QuestProgressIndex] += 1
                elif isinstance(questClass, Quests.RecoverItemQuest):
                    if questClass.getHolder() != Quests.AnyFish:
                        for suit in suitsKilled:
                            if questClass.doesCogCount(av.doId, suit, taskZoneId, suit['activeToons']):
                                baseChance = questClass.getPercentChance()
                                amountRemaining = questClass.getNumItems() - questDesc[QuestProgressIndex]
                                chance = Quests.calcRecoverChance(amountRemaining, baseChance)
                                if chance >= baseChance:
                                    questDesc[QuestProgressIndex] += 1
                                    recoveredItems.append(questClass.getItem())
                                else:
                                    unrecoveredItems.append(questClass.getItem())
            questList.append(questDesc)

        av.b_setQuests(questList)
        return (recoveredItems, unrecoveredItems)
コード例 #2
0
 def trolleyLeft(self):
     numPlayers = self.countFullSeats()
     if numPlayers > 0:
         newbieIds = []
         for avId in self.seats:
             if avId:
                 toon = self.air.doId2do.get(avId)
                 if toon:
                     if Quests.avatarHasTrolleyQuest(toon):
                         if not Quests.avatarHasCompletedTrolleyQuest(toon):
                             newbieIds.append(avId)
         playerArray = []
         for i in self.seats:
             if i not in [None, 0]:
                 playerArray.append(i)
         mgDict = MinigameCreatorAI.createMinigame(
             self.air, playerArray, self.zoneId, newbieIds=newbieIds)
         minigameZone = mgDict['minigameZone']
         minigameId = mgDict['minigameId']
         for seatIndex in xrange(len(self.seats)):
             avId = self.seats[seatIndex]
             if avId:
                 self.sendUpdateToAvatarId(avId, 'setMinigameZone', [minigameZone, minigameId])
                 self.clearFullNow(seatIndex)
     else:
         self.notify.warning('The trolley left, but was empty.')
     self.enter()
コード例 #3
0
    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])
            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
コード例 #4
0
ファイル: RewardPanel.py プロジェクト: frogtongue/tonguefrog
    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 + ' :'
コード例 #5
0
 def avatarChoseQuest(self, avId, npc, questId, rewardId, building):
     toon = self.air.doId2do.get(avId)
     if not toon:
         return
     fromNpc = Quests.getQuestFromNpcId(questId)
     toNpc = Quests.getQuestToNpcId(questId)
     toon.addQuest([questId, fromNpc, toNpc, rewardId, 0], 0,
                     recordHistory = 0)
     npc.assignQuest(avId, questId, rewardId, toNpc)
     taskMgr.remove(npc.uniqueName('clearMovie'))
コード例 #6
0
 def requestInteract(self, avId, npc):
     toon = self.air.doId2do.get(avId)
     if not toon:
         return
     toonQuestPocketSize = toon.getQuestCarryLimit()
     self.avatarProgressTier(toon)
     toonQuests = toon.getQuests()
     for i in xrange(0, len(toonQuests), 5):
         questDesc = toonQuests[i:i + 5]
         questId, fromNpcId, toNpcId, rewardId, toonProgress = questDesc
         questClass = Quests.getQuest(questId)
         if questClass:
             completeStatus = questClass.getCompletionStatus(toon, questDesc, npc)
         else:
             continue
         if completeStatus == Quests.COMPLETE:
             print 'QuestManager: %s (AvId: %s) Completed QuestId: %s'%(toon.getName(), toon.doId, questId)
             toon.toonUp(toon.maxHp)
             if isinstance(questClass, Quests.TrackChoiceQuest):
                 npc.presentTrackChoice(avId, questId, questClass.getChoices())
                 break
             elif Quests.getNextQuest(questId, npc, toon)[0] != Quests.NA:
                 self.nextQuest(toon, npc, questId)
             else:
                 npc.completeQuest(avId, questId, rewardId)
                 self.completeQuest(toon, questId)
             if isinstance(npc, DistributedNPCSpecialQuestGiverAI):
                 if npc.tutorial and (npc.npcId == 20002):
                     messenger.send('intHqDoor0-{0}'.format(npc.zoneId), [FADoorCodes.WRONG_DOOR_HQ])
                     messenger.send('intHqDoor1-{0}'.format(npc.zoneId), [FADoorCodes.UNLOCKED])
                     streetZone = self.air.tutorialManager.currentAllocatedZones[avId][0]
                     messenger.send('extHqDoor0-{0}'.format(streetZone), [FADoorCodes.GO_TO_PLAYGROUND])
                     messenger.send('extHqDoor1-{0}'.format(streetZone), [FADoorCodes.GO_TO_PLAYGROUND])
                     messenger.send('extShopDoor-{0}'.format(streetZone), [FADoorCodes.GO_TO_PLAYGROUND])
             break
     else:
         if (len(toonQuests) == toonQuestPocketSize*5):
             npc.rejectAvatar(avId)
             return
         elif isinstance(npc, DistributedNPCSpecialQuestGiverAI):
             choices = self.avatarQuestChoice(toon, npc)
             quest = choices[0]
             self.avatarChoseQuest(avId, npc, quest[0], quest[1], 0)
             if npc.tutorial:
                 if npc.npcId == 20000:
                     messenger.send('intShopDoor-{0}'.format(npc.zoneId), [FADoorCodes.UNLOCKED])
             return
         else:
             choices = self.avatarQuestChoice(toon, npc)
             if choices != []:
                 npc.presentQuestChoice(avId, choices)
                 return
             else:
                 npc.rejectAvatar(avId)
                 return
コード例 #7
0
 def requestSkipTutorial(self):
     avId = self.air.getAvatarIdFromSender()
     av = self.air.doId2do.get(avId)
     if av:
         av.b_setTutorialAck(1)
         av.b_setQuestHistory([110, 100])
         av.addQuest((110, Quests.getQuestFromNpcId(110), Quests.getQuestToNpcId(110), Quests.getQuestReward(110, av), 0), 0)
         self.air.questManager.toonRodeTrolleyFirstTime(av) #gg hacky
         self.d_skipTutorialResponse(avId, 1)
     else:
         self.d_skipTutorialResponse(avId, 0)
コード例 #8
0
 def giveReward(self, toon, questId, rewardId):
     #Actual reward giving.
     rewardClass = Quests.getReward(rewardId)
     rewardClass.sendRewardAI(toon)
     #Add it to reward history.
     realRewardId = Quests.transformReward(rewardId, toon)
     tier, rewardList = toon.getRewardHistory()
     rewardList.append(rewardId)
     if realRewardId != rewardId:
         rewardList.append(realRewardId)
     toon.b_setRewardHistory(tier, rewardList)
コード例 #9
0
    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])

            # 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)
コード例 #10
0
    def __applyReward(self, av, questId, rewardId):
        Quests.getReward(rewardId).sendRewardAI(av)

        transId = Quests.transformReward(rewardId, av)
        
        tier, rewardList = av.getRewardHistory()
        
        rewardList.append(rewardId)
        if transId != rewardId:
            rewardList.append(transId)
            
        av.b_setRewardHistory(tier, rewardList)
コード例 #11
0
 def requestInteract(self, avId, npc):
     av = self.air.doId2do.get(avId)
     if not av:
         self.notify.warning("Got requestInteract with unknown avId: %s" % avId)
         return
                     
     # check if the avatar wants to turn in a quest
     quests = av.getQuests()
     for i in xrange(0, len(quests), 5):
         quest = quests[i:i + 5]
         klass = Quests.getQuest(quest[0])
         
         if not klass:
             self.notify.debug('Quest %s has no class.' % quest[0])
             continue
             
         if klass.getCompletionStatus(av, quest, npc) == Quests.COMPLETE:
             # complete quest, the avatar is turning it in
             self.notify.debug("Toon %s completed quest %s" % (av.doId, quest[0]))
             
             # fill the laff
             av.toonUp(av.maxHp)
             
             if isinstance(klass, Quests.TrackChoiceQuest):
                 npc.presentTrackChoice(avId, quest[0], klass.getChoices())
                 return 1
                 
             nextQuest = Quests.getNextQuest(quest[0], npc, av)
             if nextQuest[0] != Quests.NA:
                 self.__goToNextQuest(av, npc, quest[0], nextQuest)
                 
             else:
                 npc.completeQuest(avId, quest[0], quest[-2])
                 self.__questCompleted(av, quest[0])
                 
             return 1
             
     if self.__considerProgressTier(av):
         npc.rejectAvatarTierNotDone(avId)
         return 0
             
     # give choices if the av doesn't have enough quests already
     if len(quests) / 5 < av.getQuestCarryLimit():
         choices = Quests.chooseBestQuests(av.getRewardTier(), npc, av)
         if choices:
             npc.presentQuestChoice(avId, choices)
             return 1
     
     return 0
コード例 #12
0
    def giveReward(self, av, questId, rewardId):
        # Give the reward.
        rewardClass = Quests.getReward(rewardId)
        if rewardClass is None:
            self.notify.warning('rewardClass was None for rewardId: %s.' % rewardId)
        else:
            rewardClass.sendRewardAI(av)

        # Add the rewardId to the avatars rewardHistory.
        rewardTier, rewardHistory = av.getRewardHistory()
        transformedRewardId = Quests.transformReward(rewardId, av)
        if transformedRewardId != rewardId:
            rewardHistory.append(rewardId)

        av.b_setRewardHistory(rewardTier, rewardHistory)
コード例 #13
0
    def toonKilledCogs(self, av, suitsKilled, zoneId):
        # Get the avatar's current quests.
        messenger.send("topToonsManager-event", [av.doId, TopToonsGlobals.CAT_COGS, len(suitsKilled)])
        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])

            # 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)
コード例 #14
0
 def toonKilledCogs(self, av, suits, zoneId, activeToons):
     if self.air.topToonsMgr:
         self.air.topToonsMgr.toonKilledCogs(av, suits)
         
     quests = av.getQuests()
     newQuests = []
     
     for i in xrange(0, len(quests), 5):
         quest = quests[i:i + 5]
         klass = Quests.getQuest(quest[0])
         
         if not klass:
             continue
                         
         if isinstance(klass, Quests.CogQuest):
             for suit in suits:
                 if klass.getCompletionStatus(av, quest) == Quests.COMPLETE:
                     break
                     
                 if klass.doesCogCount(av.doId, suit, zoneId, suit['activeToons']):
                     quest[4] += 1
         
         newQuests.append(quest)
         
     av.b_setQuests(newQuests)
 def enter(self):
     doneStatus = {}
     questHistory = base.localAvatar.getQuestHistory()
     imgScale = 0.5
     if questHistory != [] and questHistory != [1000] and questHistory != [101, 110]:
         doneStatus['mode'] = 'complete'
         messenger.send(self.doneEvent, [doneStatus])
     elif len(base.localAvatar.quests) > 1 or len(base.localAvatar.quests) == 0:
         doneStatus['mode'] = 'complete'
         messenger.send(self.doneEvent, [doneStatus])
     elif base.localAvatar.quests[0][0] != Quests.TROLLEY_QUEST_ID:
         doneStatus['mode'] = 'complete'
         messenger.send(self.doneEvent, [doneStatus])
     else:
         base.localAvatar.b_setAnimState('neutral', 1)
         doneStatus['mode'] = 'incomplete'
         self.doneStatus = doneStatus
         imageModel = loader.loadModel('phase_4/models/gui/tfa_images')
         if Quests.avatarHasTrolleyQuest(base.localAvatar):
             if base.localAvatar.quests[0][4] != 0:
                 imgNodePath = imageModel.find('**/hq-dialog-image')
                 imgPos = (0, 0, -0.02)
                 msg = TTLocalizer.NPCForceAcknowledgeMessage2
             else:
                 imgNodePath = imageModel.find('**/trolley-dialog-image')
                 imgPos = (0, 0, 0.04)
                 msg = TTLocalizer.NPCForceAcknowledgeMessage
         self.dialog = TTDialog.TTDialog(text=msg, command=self.handleOk, style=TTDialog.Acknowledge)
         imgLabel = DirectLabel.DirectLabel(parent=self.dialog, relief=None, pos=imgPos, scale=TTLocalizer.NPCFimgLabel, image=imgNodePath, image_scale=imgScale)
     return
コード例 #16
0
    def updateQuestInfo(self):
        for marker in self.buildingMarkers:
            marker.destroy()

        self.buildingMarkers = []
        dnaData = base.cr.playGame.dnaData
        for questIndex in self.av.questPage.quests.keys():
            questDesc = self.av.questPage.quests.get(questIndex)
            if questDesc is None:
                continue
            mapIndex = questIndex + 1
            questId, fromNpcId, toNpcId, rewardId, toonProgress = questDesc
            quest = Quests.getQuest(questId)
            fComplete = quest.getCompletionStatus(self.av, questDesc) == Quests.COMPLETE
            if not fComplete:
                if quest.getType() == Quests.RecoverItemQuest:
                    if quest.getHolder() == Quests.AnyFish:
                        self.putBuildingMarker(self.fishingSpotInfo, mapIndex=mapIndex)
                    continue
                elif quest.getType() != Quests.DeliverGagQuest and quest.getType() != Quests.DeliverItemQuest and quest.getType() != Quests.VisitQuest and quest.getType() != Quests.TrackChoiceQuest:
                    continue
            if toNpcId == Quests.ToonHQ:
                self.putBuildingMarker(self.hqPosInfo, mapIndex=mapIndex)
            else:
                npcZone = NPCToons.getNPCZone(toNpcId)
                hoodId = ZoneUtil.getCanonicalHoodId(npcZone)
                branchId = ZoneUtil.getCanonicalBranchZone(npcZone)
                if self.hoodId == hoodId and self.zoneId == branchId:
                    for blockId, block in dnaData.getBlocks():
                        zone = block.zone
                        branchZone = zone - zone % 100
                        finalZone = branchZone + 500 + blockId
                        if npcZone == finalZone:
                            building = block.node
                            self.putBuildingMarker(Point3(building.getPos()), building.getHpr(), mapIndex=mapIndex)
    def isNewbie(self, avId):
        # Does avId have the "ride the Trolley" quest?
        toon = self.air.doId2do.get(avId)
        if not toon:
            return False

        return Quests.avatarHasTrolleyQuest(toon)
コード例 #18
0
 def recoverItems(self, toon, suitsKilled, taskZoneId):
     flattenedQuests = toon.getQuests()
     questList = [] #unflattened
     recoveredItems = []
     unrecoveredItems = []
     taskZoneId = ZoneUtil.getBranchZone(taskZoneId)
     for i in xrange(0, len(flattenedQuests), 5):
         questDesc = flattenedQuests[i : i + 5]
         questClass = Quests.getQuest(questDesc[0])
         if questClass.getCompletionStatus(toon, questDesc) == Quests.INCOMPLETE:
             if isinstance(questClass, Quests.CogQuest):
                 for suit in suitsKilled:
                     if questClass.doesCogCount(toon.doId, suit, taskZoneId, suit['activeToons']):
                         questDesc[4] += 1
             elif isinstance(questClass, Quests.RecoverItemQuest):
                 if questClass.getHolder() != Quests.AnyFish:
                     for suit in suitsKilled:
                         if questClass.doesCogCount(toon.doId, suit, taskZoneId, suit['activeToons']):
                             minchance = questClass.getPercentChance()
                             import random
                             chance = random.randint(minchance - 40, 100)
                             if chance <= minchance:
                                 questDesc[4] += 1
                                 recoveredItems.append(questClass.getItem())
                             else:
                                 unrecoveredItems.append(questClass.getItem())
         questList.append(questDesc)
     toon.b_setQuests(questList)
     return (recoveredItems, unrecoveredItems)
コード例 #19
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
            q = Quests.getQuest(taskId)
            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
コード例 #20
0
    def toonKilledCogs(self, av, suitsKilled, zoneId, activeToonList):
         # Get the avatar's current quests.
        avQuests = av.getQuests()
        questList = []

        # Make a list of the activeToonDoIds
        activeToonDoIds = [toon.doId for toon in activeToonList if not None]

        # 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, activeToonDoIds):

                        # 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)
コード例 #21
0
 def __showQuestItem(self, itemId):
     self.__makeGui()
     itemName = Quests.getItemName(itemId)
     self.itemLabel['text'] = itemName
     self.itemGui.reparentTo(aspect2d)
     self.itemPackage.show()
     self.itemJellybean.hide()
     self.itemBoot.hide()
コード例 #22
0
ファイル: RewardPanel.py プロジェクト: frogtongue/tonguefrog
    def getMissedItemIntervalList(self, toon, missedItemList):
        intervalList = []
        for itemId in missedItemList:
            itemName = Quests.getItemName(itemId)
            intervalList.append(Func(self.missedItemLabel.setProp, 'text', itemName))
            intervalList.append(Wait(1))

        return intervalList
コード例 #23
0
 def avatarQuestChoice(self, toon, npc):
     tasks = Quests.chooseBestQuests(toon.getRewardTier(), npc, toon)
     #Does the avatar already have any of these rewardIds?
     #[QuestId, RewardId, toNPCID]
     toonQuests = toon.getQuests() #Flattened Quests.
     rewardList = [] #Unflattened Quests.
     for i in xrange(0, len(toonQuests), 5):
         questDesc = toonQuests[i:i + 5]
         rewardList.append(questDesc[3])
     for task in tasks:
         if task[1] in rewardList:
             tier = toon.getRewardHistory()[0]
             rewards = Quests.getOptionalRewardsInTier(tier)
             if rewards:
                 rewardId = random.choice(Quests.getOptionalRewardsInTier(tier))
                 task[1] = rewardId
     return tasks
コード例 #24
0
    def getItemIntervalList(self, toon, itemList):
        intervalList = []
        for itemId in itemList:
            itemName = Quests.getItemName(itemId)
            intervalList.append(Func(self.itemLabel.setProp, "text", itemName))
            intervalList.append(Wait(1))

        return intervalList
コード例 #25
0
 def avatarChoseTrack(self, avId, npc, pendingTrackQuest, trackId):
     toon = self.air.doId2do.get(avId)
     if not toon:
         return
     npc.completeQuest(avId, pendingTrackQuest, Quests.getRewardIdFromTrackId(trackId))
     self.completeQuest(toon, pendingTrackQuest)
     toon.removeQuest(pendingTrackQuest)
     toon.b_setTrackProgress(trackId, 0)
コード例 #26
0
 def avatarChoseTrack(self, avId, npc, quest, track):
     av = self.air.doId2do.get(avId)
     if not av:
         return
         
     av.b_setTrackProgress(track, 0)
             
     npc.completeQuest(avId, quest, Quests.getRewardIdFromTrackId(track))
     av.removeQuest(quest)
コード例 #27
0
    def avatarConsiderProgressTier(self, av):
        # Get the avatars current tier.
        currentTier = av.getRewardTier()

        # Check if they have all required rewards.
        if Quests.avatarHasAllRequiredRewards(av, currentTier):
            if currentTier != Quests.ELDER_TIER:
                currentTier += 1
            av.b_setRewardHistory(currentTier, [])
コード例 #28
0
 def hasTailorClothingTicket(self, toon, npc):
     flattenedQuests = toon.getQuests()
     for i in xrange(0, len(flattenedQuests), 5):
         questDesc = flattenedQuests[i : i + 5]
         questClass = Quests.getQuest(questDesc[0])
         if isinstance(questClass, Quests.DeliverItemQuest):
             if questClass.getCompletionStatus(toon, questDesc, npc) == Quests.COMPLETE:
                 return 1
     return 0
コード例 #29
0
 def removeClothingTicket(self, toon, npc):
     flattenedQuests = toon.getQuests()
     questList = []
     for i in xrange(0, len(flattenedQuests), 5):
         questDesc = flattenedQuests[i : i + 5]
         questClass = Quests.getQuest(questDesc[0])
         if isinstance(questClass, Quests.DeliverItemQuest):
             if questClass.getCompletionStatus(toon, questDesc, npc) == Quests.COMPLETE:
                 toon.removeQuest(questDesc[0])
                 break
コード例 #30
0
 def avatarChoseQuest(self, avId, npc, questId, reward, _):
     av = self.air.doId2do.get(avId)
     if not av:
         return
         
     fromNpc = Quests.getQuestFromNpcId(questId)
     toNpc = Quests.getQuestToNpcId(questId)
     
     if reward in (110, 1000):
         toNpc = Quests.ToonTailor
     
     npc.assignQuest(avId, questId, reward, toNpc)
     
     progress = 0
     quest = [questId, fromNpc, toNpc, reward, progress]
     
     av.addQuest(quest, reward, True)
     
     taskMgr.remove(npc.uniqueName('clearMovie'))
コード例 #31
0
    def recoverItems(self, av, suits, zoneId):
        zoneId = ZoneUtil.getBranchZone(zoneId)

        quests = av.getQuests()
        newQuests = []

        recovered = []
        unrecovered = []

        for i in xrange(0, len(quests), 5):
            quest = quests[i:i + 5]
            klass = Quests.getQuest(quest[0])

            if klass.getCompletionStatus(av, quest) == Quests.INCOMPLETE:
                if isinstance(klass, Quests.RecoverItemQuest):
                    if klass.getHolder() != Quests.AnyFish:
                        item = klass.getItem()

                        for suit in suits:
                            if klass.getCompletionStatus(
                                    av, quest) == Quests.COMPLETE:
                                break

                            if klass.doesCogCount(av.doId, suit, zoneId,
                                                  suit['activeToons']):
                                if random.random(
                                ) <= klass.getPercentChance() / 100.0:
                                    quest[4] += 1
                                    recovered.append(item)

                                else:
                                    unrecovered.append(item)

                            else:
                                self.notify.debug(
                                    "Recover: Suit %s at %s does not count" %
                                    (suit, zoneId))

            newQuests.append(quest)

        av.b_setQuests(newQuests)

        return recovered, unrecovered
コード例 #32
0
    def updateQuestInfo(self):
        for marker in self.buildingMarkers:
            marker.destroy()

        self.buildingMarkers = []
        dnaData = base.cr.playGame.dnaData
        for questIndex in self.av.questPage.quests.keys():
            questDesc = self.av.questPage.quests.get(questIndex)
            if questDesc is None:
                continue
            mapIndex = questIndex + 1
            questId, fromNpcId, toNpcId, rewardId, toonProgress = questDesc
            quest = Quests.getQuest(questId)
            fComplete = quest.getCompletionStatus(self.av,
                                                  questDesc) == Quests.COMPLETE
            if not fComplete:
                if quest.getType() == Quests.RecoverItemQuest:
                    if quest.getHolder() == Quests.AnyFish:
                        self.putBuildingMarker(self.fishingSpotInfo,
                                               mapIndex=mapIndex)
                    continue
                elif quest.getType(
                ) != Quests.DeliverGagQuest and quest.getType(
                ) != Quests.DeliverItemQuest and quest.getType(
                ) != Quests.VisitQuest and quest.getType(
                ) != Quests.TrackChoiceQuest:
                    continue
            if toNpcId == Quests.ToonHQ:
                self.putBuildingMarker(self.hqPosInfo, mapIndex=mapIndex)
            else:
                npcZone = NPCToons.getNPCZone(toNpcId)
                hoodId = ZoneUtil.getCanonicalHoodId(npcZone)
                branchId = ZoneUtil.getCanonicalBranchZone(npcZone)
                if self.hoodId == hoodId and self.zoneId == branchId:
                    for blockId, block in dnaData.getBlocks():
                        zone = block.zone
                        branchZone = zone - zone % 100
                        finalZone = branchZone + 500 + blockId
                        if npcZone == finalZone:
                            building = block.node
                            self.putBuildingMarker(Point3(building.getPos()),
                                                   building.getHpr(),
                                                   mapIndex=mapIndex)
コード例 #33
0
    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)
コード例 #34
0
    def toonKilledBuilding(self, av, type, difficulty, floors, zoneId,
                           activeToons):
        avQuests = av.getQuests()
        questList = []
        zoneId = ZoneUtil.getBranchZone(zoneId)
        for i in xrange(0, len(avQuests), 5):
            questDesc = avQuests[i:i + 5]
            questClass = Quests.getQuest(questDesc[QuestIdIndex])
            if questClass.getCompletionStatus(av,
                                              questDesc) == Quests.INCOMPLETE:
                if isinstance(questClass, Quests.BuildingQuest):
                    if questClass.isLocationMatch(zoneId):
                        if questClass.doesBuildingTypeCount(type):
                            if questClass.doesBuildingCount(av, activeToons):
                                if floors >= questClass.getNumFloors():
                                    questDesc[QuestProgressIndex] += 1
            questList.append(questDesc)

        av.b_setQuests(questList)
コード例 #35
0
    def enter(self):
        doneStatus = {}
        questHistory = base.localAvatar.getQuestHistory()
        imgScale = 0.5
        if ((questHistory != []) and (questHistory != [1000])
                and (questHistory != [101, 110])):
            doneStatus['mode'] = 'complete'
            messenger.send(self.doneEvent, [doneStatus])
        elif ((len(base.localAvatar.quests) > 1)
              or (len(base.localAvatar.quests) == 0)):
            doneStatus['mode'] = 'complete'
            messenger.send(self.doneEvent, [doneStatus])
        elif (base.localAvatar.quests[0][0] != Quests.TROLLEY_QUEST_ID):
            doneStatus['mode'] = 'complete'
            messenger.send(self.doneEvent, [doneStatus])
        else:
            # Make the Toon stand still while the panel is up
            base.localAvatar.b_setAnimState('neutral', 1)
            doneStatus['mode'] = 'incomplete'
            self.doneStatus = doneStatus
            imageModel = loader.loadModel("phase_4/models/gui/tfa_images")
            if Quests.avatarHasTrolleyQuest(base.localAvatar):
                if (base.localAvatar.quests[0][4] != 0):
                    imgNodePath = imageModel.find("**/hq-dialog-image")
                    imgPos = (0, 0, -0.02)
                    msg = TTLocalizer.NPCForceAcknowledgeMessage2
                else:
                    imgNodePath = imageModel.find("**/trolley-dialog-image")
                    imgPos = (0, 0, 0.04)
                    msg = TTLocalizer.NPCForceAcknowledgeMessage

            self.dialog = TTDialog.TTDialog(text=msg,
                                            command=self.handleOk,
                                            style=TTDialog.Acknowledge)
            imgLabel = DirectLabel.DirectLabel(
                parent=self.dialog,
                relief=None,
                pos=imgPos,
                scale=TTLocalizer.NPCFimgLabel,
                image=imgNodePath,
                image_scale=imgScale,
            )
コード例 #36
0
ファイル: QuestMap.py プロジェクト: DarthNihilus1/src
    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)
コード例 #37
0
    def __tasksChanged(self):
        # clear out everything from our menu
        self.clearMenu()

        # if local toon has not been created, don't panic
        try:
            lt = base.localAvatar
        except:
            return

        # keep a list of the phrases we've added to the menu, to
        # detect duplicates
        phrases = []
        def addTerminal(terminal, self=self, phrases=phrases):
            displayText = terminal.getDisplayText()
            if displayText not in phrases:
                self.append(terminal)
                phrases.append(displayText)

        # rebuild our menu
        for task in lt.quests:
            taskId, fromNpcId, toNpcId, rewardId, toonProgress = task
            q = Quests.getQuest(taskId)
            if q is None:
                continue
            msgs = q.getSCStrings(toNpcId, toonProgress)
            # getSCStrings might return a list of strings, or just a string
            if type(msgs) != type([]):
                msgs = [msgs]
            for i in range(len(msgs)):
                addTerminal(TTSCToontaskTerminal(msgs[i], taskId, toNpcId,
                                               toonProgress, i))

        # if toon has open task slots, or no task slots,
        # append 'i need a toontask'.
        needToontask = 1
        if hasattr(lt, 'questCarryLimit'):
            needToontask = (len(lt.quests) != lt.questCarryLimit)
        if needToontask:
            # add 'I need to get a ToonTask'
            # see Localizer.SpeedChatStaticText
            addTerminal(SCStaticTextTerminal(1299))
コード例 #38
0
    def toonUsedPhone(self, avId):
        av = self.air.doId2do[avId]

        quests = av.getQuests()
        newQuests = []

        for i in xrange(0, len(quests), 5):
            quest = quests[i:i + 5]
            klass = Quests.getQuest(quest[0])

            if not klass:
                continue

            if isinstance(klass, Quests.PhoneQuest):
                if klass.getCompletionStatus(av, quest) != Quests.COMPLETE:
                    quest[4] += 1

            newQuests.append(quest)

        av.b_setQuests(newQuests)
コード例 #39
0
 def toonKilledBuilding(self, toon, type, difficulty, floors, zoneId,
                        activeToons):
     flattenedQuests = toon.getQuests()
     questList = []  #unflattened
     zoneId = ZoneUtil.getBranchZone(zoneId)
     recoveredItems = []
     unrecoveredItems = []
     for i in xrange(0, len(flattenedQuests), 5):
         questDesc = flattenedQuests[i:i + 5]
         questClass = Quests.getQuest(questDesc[0])
         if questClass.getCompletionStatus(toon,
                                           questDesc) == Quests.INCOMPLETE:
             if isinstance(questClass, Quests.BuildingQuest):
                 if questClass.isLocationMatch(zoneId):
                     if questClass.getBuildingTrack() == type or Quests.Any:
                         if questClass.doesBuildingCount(toon, activeToons):
                             if floors >= questClass.getNumFloors():
                                 questDesc[4] += 1
         questList.append(questDesc)
     toon.b_setQuests(questList)
コード例 #40
0
    def toonKilledCogdo(self, av, type, difficulty, zoneId, activeToons):
        self.notify.debug(
            "toonKilledCogdo(%s, '%s', %s, %d, %s)" %
            (str(av), type, str(difficulty), zoneId, str(activeToons)))
        avQuests = av.getQuests()
        questList = []
        zoneId = ZoneUtil.getBranchZone(zoneId)
        for i in xrange(0, len(avQuests), 5):
            questDesc = avQuests[i:i + 5]
            questClass = Quests.getQuest(questDesc[QuestIdIndex])
            if questClass.getCompletionStatus(av,
                                              questDesc) == Quests.INCOMPLETE:
                if isinstance(questClass, Quests.CogdoQuest):
                    if questClass.isLocationMatch(zoneId):
                        if questClass.doesCogdoTypeCount(type):
                            if questClass.doesCogdoCount(av, activeToons):
                                questDesc[QuestProgressIndex] += 1
            questList.append(questDesc)

        av.b_setQuests(questList)
コード例 #41
0
 def updateQuestInfo(self):
     for marker in self.buildingMarkers:
         marker.destroy()
     
     self.buildingMarkers = []
     dnaStore = base.cr.playGame.dnaStore
     for questIndex in self.av.questPage.quests.keys():
         questDesc = self.av.questPage.quests.get(questIndex)
         if questDesc is None:
             continue
         
         mapIndex = questIndex + 1
         (questId, fromNpcId, toNpcId, rewardId, toonProgress) = questDesc
         quest = Quests.getQuest(questId)
         fComplete = quest.getCompletionStatus(self.av, questDesc) == Quests.COMPLETE
         if not fComplete:
             if quest.getType() == Quests.RecoverItemQuest:
                 if quest.getHolder() == Quests.AnyFish:
                     self.putBuildingMarker(self.fishingSpotInfo, mapIndex = mapIndex)
                     continue
                 continue
             elif quest.getType() != Quests.DeliverGagQuest and quest.getType() != Quests.DeliverItemQuest and quest.getType() != Quests.VisitQuest and quest.getType() != Quests.TrackChoiceQuest:
                 continue
             
         
         if toNpcId == Quests.ToonHQ:
             self.putBuildingMarker(self.hqPosInfo, mapIndex = mapIndex)
             continue
         npcZone = NPCToons.getNPCZone(toNpcId)
         hoodId = ZoneUtil.getCanonicalHoodId(npcZone)
         branchId = ZoneUtil.getCanonicalBranchZone(npcZone)
         if self.hoodId == hoodId and self.zoneId == branchId:
             for blockIndex in range(dnaStore.getNumBlockTitles()):
                 blockNumber = dnaStore.getTitleBlockAt(blockIndex)
                 zone = dnaStore.getZoneFromBlockNumber(blockNumber)
                 branchZone = zone - zone % 100
                 finalZone = branchZone + 500 + blockNumber
                 buildingType = dnaStore.getBlockBuildingType(blockNumber)
                 if npcZone == finalZone:
                     self.putBuildingMarker(dnaStore.getDoorPosHprFromBlockNumber(blockNumber).getPos(), dnaStore.getDoorPosHprFromBlockNumber(blockNumber).getHpr(), mapIndex = mapIndex)
                     continue
コード例 #42
0
    def toonDefeatedMint(self, av, mint, activeToons):
        if self.air.topToonsMgr:
            self.air.topToonsMgr.toonKilledFactory(av, 'mint')

        quests = av.getQuests()
        newQuests = []

        for i in xrange(0, len(quests), 5):
            quest = quests[i:i + 5]
            klass = Quests.getQuest(quest[0])

            if not klass:
                continue

            if isinstance(klass, Quests.MintQuest):
                if klass.getCompletionStatus(av, quest) != Quests.COMPLETE:
                    quest[4] += 1

            newQuests.append(quest)

        av.b_setQuests(newQuests)
コード例 #43
0
    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)
コード例 #44
0
    def toonKilledBoss(self, av, boss):
        if self.air.topToonsMgr:
            self.air.topToonsMgr.toonKilledBoss(av, boss)

        quests = av.getQuests()
        newQuests = []

        for i in xrange(0, len(quests), 5):
            quest = quests[i:i + 5]
            klass = Quests.getQuest(quest[0])

            if not klass:
                continue

            if isinstance(klass, Quests.BossQuest):
                if klass.getCompletionStatus(av, quest) != Quests.COMPLETE:
                    if klass.doesBossCount(boss):
                        quest[4] += 1

            newQuests.append(quest)

        av.b_setQuests(newQuests)
コード例 #45
0
    def toonDefeatedBoss(self, av, zone, dept, activeVictors):
        # Get the avatars current quests.
        avQuests = av.getQuests()
        questList = []
        for i in xrange(0, len(avQuests), 5):
            questDesc = avQuests[i : i + 5]
            questClass = Quests.getQuest(questDesc[QuestIdIndex])
            if isinstance(questClass, Quests.VPQuest):
                if questClass.doesVPCount(av, dept, zone, activeVictors):
                    questDesc[QuestProgressIndex] += 1
            elif isinstance(questClass, Quests.CFOQuest):
                if questClass.doesCFOCount(av, dept, zone, activeVictors):
                    questDesc[QuestProgressIndex] += 1
            elif isinstance(questClass, Quests.CJQuest):
                if questClass.doesCJCount(av, dept, zone, activeVictors):
                    questDesc[QuestProgressIndex] += 1
            elif isinstance(questClass, Quests.CEOQuest):
                if questClass.doesCEOCount(av, dept, zone, activeVictors):
                    questDesc[QuestProgressIndex] += 1
            questList.append(questDesc)

        av.b_setQuests(questList)
コード例 #46
0
    def _TTSCToontaskMenu__tasksChanged(self):
        self.clearMenu()
        
        try:
            lt = base.localAvatar
        except:
            return None

        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
            q = Quests.getQuest(taskId)
            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))
コード例 #47
0
    def toonKilledCogdo(self, av, track, _, numFloors, zoneId, activeToons):
        if self.air.topToonsMgr:
            self.air.topToonsMgr.toonKilledOffice(av, track)

        quests = av.getQuests()
        newQuests = []

        for i in xrange(0, len(quests), 5):
            quest = quests[i:i + 5]
            klass = Quests.getQuest(quest[0])

            if not klass:
                continue

            if isinstance(klass, Quests.CogdoQuest):
                if klass.getCompletionStatus(av, quest) != Quests.COMPLETE:
                    if klass.doesOfficeCount(av.doId, track, zoneId,
                                             activeToons):
                        quest[4] += 1

            newQuests.append(quest)

        av.b_setQuests(newQuests)
コード例 #48
0
    def toonKilledBuilding(self, av, track, _, height, zoneId, activeToons):
        if self.air.topToonsMgr:
            self.air.topToonsMgr.toonKilledBldg(av, track, height)

        quests = av.getQuests()
        newQuests = []

        for i in xrange(0, len(quests), 5):
            quest = quests[i:i + 5]
            klass = Quests.getQuest(quest[0])

            if not klass:
                continue

            if isinstance(klass, Quests.BuildingQuest):
                if klass.getCompletionStatus(av, quest) != Quests.COMPLETE:
                    if klass.doesBuildingCount(av.doId, track, height, zoneId,
                                               activeToons):
                        quest[4] += 1

            newQuests.append(quest)

        av.b_setQuests(newQuests)
コード例 #49
0
 def toonCaughtFishingItem(self, toon):
     print 'QuestManager: %s (AvId: %s) Caught quest Item while fishing.'%(toon.getName(), toon.doId)
     flattenedQuests = toon.getQuests()
     questList = [] #unflattened
     hasPickedQuest = 0
     for i in xrange(0, len(flattenedQuests), 5):
         questDesc = flattenedQuests[i : i + 5]
         questClass = Quests.getQuest(questDesc[0])
         if isinstance(questClass, Quests.RecoverItemQuest):
             if not hasPickedQuest:
                 if isinstance(questClass, Quests.RecoverItemQuest):
                     if questClass.getHolder() == Quests.AnyFish:
                         if not questClass.getCompletionStatus(toon, questDesc) == Quests.COMPLETE:
                             minChance = questClass.getPercentChance()
                             chance = random.randint(minChance - 40, 100)
                             if chance <= minChance:
                                 questDesc[4] += 1
                                 hasPickedQuest = questClass
         questList.append(questDesc)
     toon.b_setQuests(questList)
     if (hasPickedQuest):
         return questClass.getItem()
     else:
         return -1
コード例 #50
0
    def toonCaughtFishingItem(self, av):
        quests = av.getQuests()
        newQuests = []

        itemId = -1
        for i in xrange(0, len(quests), 5):
            quest = quests[i:i + 5]
            klass = Quests.getQuest(quest[0])
            if itemId == -1:
                if klass.__class__ == Quests.RecoverItemQuest and hasattr(
                        klass, 'getItem'):
                    if klass.getHolder() == Quests.AnyFish:
                        if klass.getCompletionStatus(av,
                                                     quest) != Quests.COMPLETE:
                            minChance = klass.getPercentChance()
                            chance = random.randint(minChance - 40, 100)
                            if chance <= minChance:
                                quest[4] += 1
                                itemId = klass.getItem()

            newQuests.append(quest)

        av.b_setQuests(newQuests)
        return itemId
コード例 #51
0
    def toonRodeTrolley(self, avId):
        av = self.air.doId2do[avId]

        rode = False

        quests = av.getQuests()
        newQuests = []

        for i in xrange(0, len(quests), 5):
            quest = quests[i:i + 5]
            klass = Quests.getQuest(quest[0])

            if not klass:
                continue

            if isinstance(klass, Quests.TrolleyQuest):
                if klass.getCompletionStatus(av, quest) != Quests.COMPLETE:
                    quest[4] += 1
                    rode = True

            newQuests.append(quest)

        av.b_setQuests(newQuests)
        return rode
コード例 #52
0
 def isNewbie(self, avId):
     toon = self.air.doId2do.get(avId)
     if not toon:
         return False
     return Quests.avatarHasTrolleyQuest(toon)
コード例 #53
0
    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)
            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)
コード例 #54
0
 def avatarQuestChoice(self, av, npc):
     # Get the best quests for an avatar/npc.
     return Quests.chooseBestQuests(av.getRewardTier(), npc, av)
コード例 #55
0
 def npcGiveTrackChoice(self, av, tier):
     trackQuest = Quests.chooseTrackChoiceQuest(tier, av)
     return [(trackQuest, 400, Quests.ToonHQ)]
コード例 #56
0
    def getQuestIntervalList(self,
                             toon,
                             deathList,
                             toonList,
                             origQuestsList,
                             itemList,
                             helpfulToonsList=[]):
        avId = toon.getDoId()
        tickDelay = 0.2
        intervalList = []
        toonShortList = []
        for t in toonList:
            if t is not None:
                toonShortList.append(t)

        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
            isVP = flags & ToontownBattleGlobals.DLF_VP
            isCFO = flags & ToontownBattleGlobals.DLF_CFO
            isSupervisor = flags & ToontownBattleGlobals.DLF_SUPERVISOR
            isVirtual = flags & ToontownBattleGlobals.DLF_VIRTUAL
            hasRevives = flags & ToontownBattleGlobals.DLF_REVIVES
            if isVP or isCFO:
                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,
                'isVP': isVP,
                'isCFO': isCFO,
                '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:
                        if cogDict['isVP']:
                            num = quest.doesVPCount(avId, cogDict, zoneId,
                                                    toonShortList)
                        elif cogDict['isCFO']:
                            num = quest.doesCFOCount(avId, cogDict, zoneId,
                                                     toonShortList)
                        else:
                            num = quest.doesCogCount(avId, cogDict, zoneId,
                                                     toonShortList)
                        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
コード例 #57
0
 def enterTeleportIn(self, requestStatus):
     imgScale = 0.25
     if self.dialog:
         x, y, z, h, p, r = base.cr.hoodMgr.getPlaygroundCenterFromId(
             self.loader.hood.id)
     elif base.localAvatar.hp < 1:
         requestStatus['nextState'] = 'popup'
         x, y, z, h, p, r = base.cr.hoodMgr.getPlaygroundCenterFromId(
             self.loader.hood.id)
         self.accept('deathAck',
                     self.__handleDeathAck,
                     extraArgs=[requestStatus])
         self.deathAckBox = DeathForceAcknowledge.DeathForceAcknowledge(
             doneEvent='deathAck')
     elif base.localAvatar.hp > 0 and (
             Quests.avatarHasTrolleyQuest(base.localAvatar)
             or Quests.avatarHasFirstCogQuest(base.localAvatar)
             or Quests.avatarHasFriendQuest(base.localAvatar)
             or Quests.avatarHasPhoneQuest(base.localAvatar)
             and Quests.avatarHasCompletedPhoneQuest(base.localAvatar)
     ) and self.loader.hood.id == ToontownGlobals.ToontownCentral:
         requestStatus['nextState'] = 'popup'
         imageModel = loader.loadModel('phase_4/models/gui/tfa_images')
         if base.localAvatar.quests[0][0] == Quests.TROLLEY_QUEST_ID:
             if not Quests.avatarHasCompletedTrolleyQuest(base.localAvatar):
                 x, y, z, h, p, r = base.cr.hoodMgr.getDropPoint(
                     base.cr.hoodMgr.ToontownCentralInitialDropPoints)
                 msg = TTLocalizer.NPCForceAcknowledgeMessage3
                 imgNodePath = imageModel.find('**/trolley-dialog-image')
                 imgPos = (0, 0, 0.04)
                 imgScale = 0.5
             else:
                 x, y, z, h, p, r = base.cr.hoodMgr.getDropPoint(
                     base.cr.hoodMgr.ToontownCentralHQDropPoints)
                 msg = TTLocalizer.NPCForceAcknowledgeMessage4
                 imgNodePath = imageModel.find('**/hq-dialog-image')
                 imgPos = (0, 0, -0.02)
                 imgScale = 0.5
         elif base.localAvatar.quests[0][0] == Quests.FIRST_COG_QUEST_ID:
             if not Quests.avatarHasCompletedFirstCogQuest(
                     base.localAvatar):
                 x, y, z, h, p, r = base.cr.hoodMgr.getDropPoint(
                     base.cr.hoodMgr.ToontownCentralTunnelDropPoints)
                 msg = TTLocalizer.NPCForceAcknowledgeMessage5
                 imgNodePath = imageModel.find('**/tunnelSignA')
                 imgPos = (0, 0, 0.04)
                 imgScale = 0.5
             else:
                 x, y, z, h, p, r = base.cr.hoodMgr.getDropPoint(
                     base.cr.hoodMgr.ToontownCentralHQDropPoints)
                 msg = TTLocalizer.NPCForceAcknowledgeMessage6
                 imgNodePath = imageModel.find('**/hq-dialog-image')
                 imgPos = (0, 0, 0.05)
                 imgScale = 0.5
         elif base.localAvatar.quests[0][0] == Quests.FRIEND_QUEST_ID:
             if not Quests.avatarHasCompletedFriendQuest(base.localAvatar):
                 x, y, z, h, p, r = base.cr.hoodMgr.getDropPoint(
                     base.cr.hoodMgr.ToontownCentralInitialDropPoints)
                 msg = TTLocalizer.NPCForceAcknowledgeMessage7
                 gui = loader.loadModel(
                     'phase_3.5/models/gui/friendslist_gui')
                 imgNodePath = gui.find('**/FriendsBox_Closed')
                 imgPos = (0, 0, 0.04)
                 imgScale = 1.0
                 gui.removeNode()
             else:
                 x, y, z, h, p, r = base.cr.hoodMgr.getDropPoint(
                     base.cr.hoodMgr.ToontownCentralHQDropPoints)
                 msg = TTLocalizer.NPCForceAcknowledgeMessage8
                 imgNodePath = imageModel.find('**/hq-dialog-image')
                 imgPos = (0, 0, 0.05)
                 imgScale = 0.5
         elif base.localAvatar.quests[0][0] == Quests.PHONE_QUEST_ID:
             if Quests.avatarHasCompletedPhoneQuest(base.localAvatar):
                 x, y, z, h, p, r = base.cr.hoodMgr.getDropPoint(
                     base.cr.hoodMgr.ToontownCentralHQDropPoints)
                 msg = TTLocalizer.NPCForceAcknowledgeMessage9
                 imgNodePath = imageModel.find('**/hq-dialog-image')
                 imgPos = (0, 0, 0.05)
                 imgScale = 0.5
         self.dialog = TTDialog.TTDialog(text=msg,
                                         command=self.__cleanupDialog,
                                         style=TTDialog.Acknowledge)
         imgLabel = DirectLabel.DirectLabel(parent=self.dialog,
                                            relief=None,
                                            pos=imgPos,
                                            scale=TTLocalizer.PimgLabel,
                                            image=imgNodePath,
                                            image_scale=imgScale)
         imageModel.removeNode()
     else:
         requestStatus['nextState'] = 'walk'
         x, y, z, h, p, r = base.cr.hoodMgr.getPlaygroundCenterFromId(
             self.loader.hood.id)
     base.localAvatar.detachNode()
     base.localAvatar.setPosHpr(render, x, y, z, h, p, r)
     Place.Place.enterTeleportIn(self, requestStatus)
     return
コード例 #58
0
    def processAvatar(self, av, db):
        self.printSometimes(av)

        changed = av.fixAvatar()
        if changed:
            db2 = DatabaseObject.DatabaseObject(self.air, av.doId)
            db2.storeObject(av, list(db.values.keys()))
            print("%d: %s repaired (account %s)." %
                  (av.doId, av.name, av.accountName))
        return

        numTracks = reduce(lambda a, b: a + b, av.trackArray)
        hp = av.maxHp
        healExp, trapExp, lureExp, soundExp, throwExp, squirtExp, dropExp = av.experience.experience
        trackProgressId, trackProgress = av.getTrackProgress()
        trackAccess = av.getTrackAccess()
        maxMoney = av.getMaxMoney()
        fixed = 0

        for questDesc in av.quests:

            questId = questDesc[0]
            rewardId = questDesc[3]
            toNpc = questDesc[2]

            if (not Quests.questExists(questId)):
                print('WARNING: av has quest that is not in quest dict: ',
                      av.doId, questId)
                continue

            if (questId in [160, 161, 162, 161]):
                if rewardId != 100:
                    print(('WARNING: av has quest: %s with reward: %s' %
                           (questId, rewardId)))
                    questDesc[3] = 100
                    fixed = 1
                    continue

            if (rewardId == 1000):
                if (questId in [
                        1100, 1101, 1102, 1103, 2500, 2501, 3500, 3501, 4500,
                        4501, 5500, 5501, 7500, 7501, 9500, 9501
                ]):
                    # not fixing because this clothing quest is valid
                    break
                av.removeAllTracesOfQuest(questId, rewardId)
                fixed = 1
                continue

            if ((toNpc != 1000)
                    and (NPCToons.NPCToonDict[toNpc][5] == NPCToons.NPC_HQ)):
                print(('WARNING: av has quest: %s to visit NPC_HQ: %s' %
                       (questId, toNpc)))
                print('before: ', av.quests)
                questDesc[2] = Quests.ToonHQ
                print('after: ', av.quests)
                fixed = 1
                continue

        # If there were any quest fixes, broadcast them now
        if fixed:
            av.b_setQuests(av.quests)

        # Make sure they are not training any tracks they have already trained
        if (trackProgressId >= 0) and (trackAccess[trackProgressId] == 1):
            print("WARNING: av training track he already has")
            print("Track progress id: ", trackProgressId)
            print("Track access: ", trackAccess)
            print("Tier: ", av.rewardTier)
            if av.rewardTier in [0, 1]:
                print("ERROR: You should not be here")
            elif av.rewardTier in [2, 3]:
                print('sound or heal')
                if av.trackArray[SOUND_TRACK] and not av.trackArray[HEAL_TRACK]:
                    trackProgressId = HEAL_TRACK
                elif av.trackArray[
                        HEAL_TRACK] and not av.trackArray[SOUND_TRACK]:
                    trackProgressId = SOUND_TRACK
                else:
                    trackProgressId = HEAL_TRACK
                av.b_setTrackProgress(trackProgressId, trackProgress)
                print("Fixed trackProgressId: ", trackProgressId)
                fixed = 1

            elif av.rewardTier in [4]:
                print("ERROR: You should not be here")
            elif av.rewardTier in [5, 6]:
                print('drop or lure')
                if av.trackArray[DROP_TRACK] and not av.trackArray[LURE_TRACK]:
                    trackProgressId = LURE_TRACK
                elif av.trackArray[
                        LURE_TRACK] and not av.trackArray[DROP_TRACK]:
                    trackProgressId = DROP_TRACK
                else:
                    trackProgressId = DROP_TRACK
                av.b_setTrackProgress(trackProgressId, trackProgress)
                print("Fixed trackProgressId: ", trackProgressId)
                fixed = 1
            elif av.rewardTier in [7]:
                print("ERROR: You should not be here")
            elif av.rewardTier in [8]:
                print("ERROR: You should not be here")
            elif av.rewardTier in [9, 10]:
                print('trap or heal, trap or sound')
                if av.trackArray[SOUND_TRACK] and not av.trackArray[HEAL_TRACK]:
                    trackProgressId = HEAL_TRACK
                elif av.trackArray[
                        HEAL_TRACK] and not av.trackArray[SOUND_TRACK]:
                    trackProgressId = SOUND_TRACK
                else:
                    trackProgressId = TRAP_TRACK
                av.b_setTrackProgress(trackProgressId, trackProgress)
                print("Fixed trackProgressId: ", trackProgressId)
                fixed = 1
            elif av.rewardTier in [11]:
                print("ERROR: You should not be here")
            elif av.rewardTier in [12, 13]:
                print('all sort of choices')
                if not av.trackArray[HEAL_TRACK]:
                    trackProgressId = HEAL_TRACK
                elif not av.trackArray[SOUND_TRACK]:
                    trackProgressId = SOUND_TRACK
                elif not av.trackArray[DROP_TRACK]:
                    trackProgressId = DROP_TRACK
                elif not av.trackArray[LURE_TRACK]:
                    trackProgressId = LURE_TRACK
                elif not av.trackArray[TRAP_TRACK]:
                    trackProgressId = TRAP_TRACK
                else:
                    print("ERROR")
                av.b_setTrackProgress(trackProgressId, trackProgress)
                print("Fixed trackProgressId: ", trackProgressId)
                fixed = 1
            else:
                print("ERROR: You should not be here")
            print()

        # clean up track access
        if av.fixTrackAccess():
            fixed = 1

        # This was an unfortunate typo in Quests.py
        if maxMoney == 10:
            print('bad maxMoney limit == 10')
            av.b_setMaxMoney(100)
            # Fill er up cause we feel bad
            av.b_setMoney(100)
            fixed = 1

        if av.rewardTier == 5:
            if hp < 25 or hp > 34:
                print('bad hp: ', end=' ')

            # Somehow they got here without choosing a track
            if trackProgressId == -1:
                print('bad track training in tier 5!')
                print(('avId: %s, trackProgressId: %s, trackProgress: %s' %
                       (av.doId, trackProgressId, trackProgress)))
                av.b_setQuestHistory([])
                av.b_setQuests([])
                # Make them choose again
                av.b_setRewardHistory(4, [])
                av.b_setTrackProgress(-1, 0)
                av.fixAvatar()
                av.inventory.zeroInv()
                av.inventory.maxOutInv()
                av.d_setInventory(av.inventory.makeNetString())
                print('new track access: ', av.trackArray)
                fixed = 1

        elif av.rewardTier == 7:
            if hp < 34 or hp > 43:
                print('bad hp: ', end=' ')
            if trackProgressId != -1:
                print('bad track training in tier 7!')
                av.b_setQuestHistory([])
                av.b_setQuests([])
                av.b_setRewardHistory(7, [])
                av.b_setTrackProgress(-1, 0)
                av.fixAvatar()
                av.inventory.zeroInv()
                av.inventory.maxOutInv()
                av.d_setInventory(av.inventory.makeNetString())
                fixed = 1

        else:
            # Nothing to fix here
            pass

        if fixed:
            db = DatabaseObject.DatabaseObject(self.air, av.doId)
            db.storeObject(av)
            print("Avatar repaired.")
            print()

        return
コード例 #59
0
 def canDeleteQuest(self, questDesc):
     if Quests.isQuestJustForFun(questDesc[0], questDesc[3]):
         pass
     return self.onscreen == 0
コード例 #60
0
 def ringIfHasPhoneQuest(self, task):
     if Quests.avatarHasPhoneQuest(
             base.localAvatar) and not Quests.avatarHasCompletedPhoneQuest(
                 base.localAvatar):
         self.ring()
     return Task.done