def initQuestFrame(self, toon, avQuests): self.gagExpFrame.hide() self.newGagFrame.hide() self.questFrame.show() self.itemFrame.hide() self.missedItemFrame.hide() for i in range(ToontownGlobals.MaxQuestCarryLimit): questLabel = self.questLabelList[i] questLabel.hide() for i in range(len(avQuests)): questDesc = avQuests[i] questId, npcId, toNpcId, rewardId, toonProgress = questDesc quest = Quests.getQuest(questId) 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() questLabel['text'] = rewardString if completed: questLabel['text_fg'] = (0, 0.3, 0, 1)
def toonPlayedMinigame(self, av, avList): # This is notifying us that a toon has entered a minigame. # See if this toon has a minigame quest. If so, update the progress. avQuests = av.quests avId = av.getDoId() changed = 0 for questDesc in avQuests: questClass = Quests.getQuestClass(questDesc[0]) if (questClass == Quests.MinigameNewbieQuest): quest = Quests.getQuest(questDesc[0]) num = quest.doesMinigameCount(av, avList) if (num > 0): # Set progress questDesc[4] += num changed = 1 # Now send the quests back to the avatar if the status changed if changed: self.notify.debug("toonPlayedMinigame: av %s made progress" % (avId)) av.b_setQuests(avQuests) else: self.notify.debug("toonPlayedMinigame: av %s made NO progress" % (avId)) return
def removeClothingTicket(self, av, npc): for questDesc in av.quests: questId, fromNpcId, toNpcId, rewardId, toonProgress = questDesc questClass = Quests.getQuestClass(questId) # See if this NPC is the one we are supposed to deliver to # You by definition have the item if (questClass == Quests.DeliverItemQuest): if Quests.npcMatches(toNpcId, npc): rewardId = Quests.getAvatarRewardId(av, questId) rewardClass = Quests.getRewardClass(rewardId) if (rewardClass == Quests.ClothingTicketReward or rewardClass == Quests.TIPClothingTicketReward): # This section is much like completeQuest() av.removeQuest(questId) # Update the toon with the reward. This reward does nothing right # now but it may in the future, so it is the right thing to do reward = Quests.getReward(rewardId) reward.sendRewardAI(av) # Bump the reward self.incrementReward(av) return 1 else: # Reward was not a clothing ticket continue else: # NPC does not match continue else: # Not a deliver item quest continue # Did not find it, avId does not have clothing ticket on this tailor return 0
def avatarChoseQuest(self, toonId, npc, questId, rewardId, toNpcId): """ This method is called by an NPCToon to tell the quest system that a toon has chosen a quest from the list supplied. """ # Get the avatar. toon = self.air.doId2do.get(toonId) if not toon: return # Get the npcIds fromNpcId = npc.npcId if npc else 0 if toNpcId == 0: toNpcId = Quests.getQuestToNpcId(questId) # Add the quest to the avatars list. transformedRewardId = Quests.transformReward(rewardId, toon) toon.addQuest([questId, fromNpcId, toNpcId, rewardId, 0], transformedRewardId) if not npc: return # Remove the tasks for timeout. taskMgr.remove(npc.uniqueName('clearMovie')) # Assign the quest. npc.assignQuest(toonId, questId, rewardId, toNpcId)
def assignQuest(self, avId, npcId, questId, rewardId, toNpcId, startingQuest=1): self.notify.info( "assignQuest: avId: %s npcId: %s questId: %s rewardId: %s toNpcId: %s startingQuest: %s" % (avId, npcId, questId, rewardId, toNpcId, startingQuest)) # assign quest to avatar # A quest is a list with (questId, npcId, toNpcId, rewardId, progress) av = self.air.doId2do.get(avId) if av: if startingQuest: # Since the first parts or multipart quests have NA for their # rewardIds, we need to get the final reward of this quest by searching # down the chain. If this questId is not the start of a multipart # quest, finalRewardId will come back None, and addQuest will handle it if rewardId == Quests.NA: finalRewardId = Quests.getFinalRewardId(questId) else: # Do not count the end of multipart quests, even though they # have a valid rewardId. That rewardId would have been counted # when the initial quest was given out if not Quests.isStartingQuest(questId): finalRewardId = None else: finalRewardId = rewardId # If this was not handed out as a starting quest, make sure you do not # count the reward twice else: finalRewardId = None # 0 for initial progress initialProgress = 0 # To make it easy for testing purposes. # This should never be on in production if self.QuestCheat: # Quest is already compelte initialProgress = 1000 # Clothing quests must be handled by the Tailor. if ((rewardId == Quests.NA) or (Quests.getRewardClass(rewardId) != Quests.ClothingTicketReward)): # Visit npc is the HQ toNpcId = Quests.ToonHQ if Quests.isLoopingFinalTier(av.getRewardTier()): # Do not record the history if this is the final looping tier recordHistory = 0 else: recordHistory = 1 av.addQuest((questId, npcId, toNpcId, rewardId, initialProgress), finalRewardId, recordHistory) # if this was a requested quest, clear it if self.NextQuestDict.get(avId) == questId: del self.NextQuestDict[avId] else: self.notify.warning("assignQuest: avatar not found: avId: %s" % (avId)) return
def toonMadeFriend(self, av, otherAv): # This is notifying us that a toon has made a friend. # See if this toon has a friend quest. # If so, update the progress. avQuests = av.quests avId = av.getDoId() changed = 0 for questDesc in avQuests: questClass = Quests.getQuestClass(questDesc[0]) if ((questClass == Quests.FriendQuest) or (questClass == Quests.FriendNewbieQuest)): quest = Quests.getQuest(questDesc[0]) if (quest.doesFriendCount(av, otherAv)): # Set progress questDesc[4] += 1 changed = 1 else: # Do not care about this quest here continue # Now send the quests back to the avatar if the status changed if changed: self.notify.debug("toonMadeFriend: av %s made progress" % (avId)) av.b_setQuests(avQuests) else: self.notify.debug("toonMadeFriend: av %s made NO progress" % (avId))
def setRewardIndex(self, tier, rewardIds, rewardHistory): self.reset() for tierNum in range(tier): for rewardId in Quests.getRewardsInTier(tierNum): reward = Quests.getReward(rewardId) reward.countReward(self) self.notify.debug('Assigning reward %d' % rewardId) print 'rewardHistory: ', rewardHistory for rewardId in rewardHistory: if rewardId in Quests.getRewardsInTier(tier): if rewardIds.count(rewardId) != 0: print 'before: ', rewardIds rewardIds.remove(rewardId) self.notify.debug('Ignoring reward %d' % rewardId) print 'after: ', rewardIds else: reward = Quests.getReward(rewardId) reward.countReward(self) self.notify.debug('Assigning reward %d' % rewardId) self.notify.debug('Remaining rewardIds %s' % rewardIds) self.maxHp = min(ToontownGlobals.MaxHpLimit, self.maxHp)
def hasTailorClothingTicket(self, av, npc): for questDesc in av.quests: questId, fromNpcId, toNpcId, rewardId, toonProgress = questDesc questType = Quests.getQuestClass(questId) # See if this NPC is the one we are supposed to deliver to # You by definition have the item if (questType == Quests.DeliverItemQuest): if Quests.npcMatches(toNpcId, npc): rewardId = Quests.getAvatarRewardId(av, questId) rewardType = Quests.getRewardClass(rewardId) if (rewardType == Quests.ClothingTicketReward): return 1 elif (rewardType == Quests.TIPClothingTicketReward): return 2 else: # Reward was not a clothing ticket continue else: # NPC does not match continue else: # Not a deliver item quest continue # Did not find it, avId does not have clothing ticket on this tailor return 0
def findItemInWater(self, av, zoneId): # Similar to recoverItems, but this is called from the # DistributedFishingSpot to see if there are any quest items # in the water. No cogs are involved; hence, the only valid # questCogType is Quests.AnyFish. # Only one item at a time is returned by this function; the # function either returns the item found, or None. # Note: this does not support two quests with same item avQuests = av.quests avId = av.getDoId() for questDesc in avQuests: questClass = Quests.getQuestClass(questDesc[0]) if (questClass == Quests.RecoverItemQuest): quest = Quests.getQuest(questDesc[0]) if ((quest.getType() == Quests.RecoverItemQuest) and (quest.getHolder() == Quests.AnyFish) and ((random.random() * 100) <= quest.getPercentChance()) and (questDesc[4] < quest.getNumItems()) and quest.isLocationMatch(zoneId)): # FOUND IT! Increment progress by one item questDesc[4] += 1 self.notify.debug("findItemInWater: av %s made progress" % (avId)) av.b_setQuests(avQuests) # Return the item recovered return quest.getItem() else: # Do not care about this quest here continue self.notify.debug("findItemInWater: av %s made NO progress" % (avId)) return None
def incrementReward(self, av): # See if we finished a tier rewardTier = av.getRewardTier() # Make sure all the rewards have been handed out and # Make sure we have completed them all # First, make sure that the list is at least as big as the number of rewards # Then, make sure we have completed them all # Then, make sure all the rewards in the tier are in our history rewardHistory = av.getRewardHistory()[1] if ( # We cannot do this short-circuit test anymore because having # cog suit parts counts as a reward in cashbot # HQ. Unfortunately we are losing a pretty nice optimization # here. TODO: revisit and optimize. # (len(rewardHistory) >= Quests.getNumRewardsInTier(rewardTier)) and # We cannot do this because they might still be working on a few # optional quests from the old tier. # (len(av.quests) == 0) and # Make sure they have all the required rewards (Quests.avatarHasAllRequiredRewards(av, rewardTier)) and # Make sure they are not still working on required rewards (not Quests.avatarWorkingOnRequiredRewards(av))): if not Quests.rewardTierExists(rewardTier + 1): self.notify.info( "incrementReward: avId %s, at end of rewards" % (av.getDoId())) return 0 rewardTier += 1 self.notify.info("incrementReward: avId %s, new rewardTier: %s" % (av.getDoId(), rewardTier)) # If we have just moved on to the next tier, blow away the # old history, which is no longer needed. av.b_setQuestHistory([]) av.b_setRewardHistory(rewardTier, []) # The above will clear the quest history the *first* time # we cross into the next tier. There may still be some # quest id's hiding behind visit quests that belong to the # previous tier; these will find their way onto the quest # history when we eventually reveal them, but they will # still be associated with the previous tier. This does # no harm, so we won't worry about it; but it does mean # that the questHistory list is not guaranteed to only # list quests on the current tier. It is simply # guaranteed to list all the completed and in-progress # quests on the current tier, with maybe one or two others # thrown in. return 1 else: self.notify.debug( "incrementReward: avId %s, not ready for new tier" % (av.getDoId())) return 0
def showChoicePoster(self, questId, fromNpcId, toNpcId, rewardId, callback): self.update((questId, fromNpcId, toNpcId, rewardId, 0)) quest = Quests.getQuest(questId) self.rewardText.show() self.rewardText.setZ(-0.205) self.questProgress.hide() if not hasattr(self, 'chooseButton'): guiButton = loader.loadModel('phase_3/models/gui/quit_button') self.chooseButton = DirectButton(parent=self.questFrame, relief=None, image=(guiButton.find('**/QuitBtn_UP'), guiButton.find('**/QuitBtn_DN'), guiButton.find('**/QuitBtn_RLVR')), image_scale=(0.7, 1, 1), text=TTLocalizer.QuestPageChoose, text_scale=0.06, text_pos=(0, -0.02), pos=(0.285, 0, 0.245), scale=0.65) guiButton.removeNode() npcZone = NPCToons.getNPCZone(toNpcId) hoodId = ZoneUtil.getCanonicalHoodId(npcZone) if not base.cr.isPaid() and (questId == 401 or hasattr(quest, 'getLocation') and quest.getLocation() == 1000 or hoodId == 1000): def showTeaserPanel(): TeaserPanel(pageName='getGags') self.chooseButton['command'] = showTeaserPanel else: self.chooseButton['command'] = callback self.chooseButton['extraArgs'] = [questId] self.unbind(DGG.WITHIN) self.unbind(DGG.WITHOUT) if not quest.getType() == Quests.TrackChoiceQuest: self.questInfo.setZ(-0.0625) return
def toonRodeTrolleyFirstTime(self, av): # This is notifying us that a toon has gotten on the # trolley for the first time. See if this toon has a # trolley quest. If so, update the progress. avQuests = av.quests avId = av.getDoId() changed = 0 for questDesc in avQuests: questClass = Quests.getQuestClass(questDesc[0]) if (questClass == Quests.TrolleyQuest): # Set progress questDesc[4] = 1 changed = 1 else: # Do not care about this quest here pass # Now send the quests back to the avatar if the status changed if changed: self.notify.debug("toonRodeTrolleyFirstTime: av %s made progress" % (avId)) av.b_setQuests(avQuests) # log this event self.air.writeServerEvent('firstTrolleyGame', avId, '') else: self.notify.debug( "toonRodeTrolleyFirstTime: av %s made NO progress" % (avId)) return
def toonKilledCogs(self, av, cogList, zoneId, avList): # This is the battle notifying us that a toon killed some cogs # See if this toon has a quest on these cogs. If so, update the progress. avQuests = av.quests avId = av.getDoId() changed = 0 self.notify.debug( "toonKilledCogs: avId: %s, avQuests: %s, cogList: %s, zoneId: %s" % (avId, avQuests, cogList, zoneId)) for questDesc in avQuests: quest = Quests.getQuest(questDesc[0]) if quest != None: for cogDict in cogList: if cogDict['isVP']: num = quest.doesVPCount(avId, cogDict, zoneId, avList) elif cogDict['isCFO']: num = quest.doesCFOCount(avId, cogDict, zoneId, avList) else: num = quest.doesCogCount(avId, cogDict, zoneId, avList) if (num > 0): questDesc[4] += num changed = 1 # Now send the quests back to the avatar if the status changed if changed: self.notify.debug("toonKilledCogs: av %s made progress" % (avId)) av.b_setQuests(avQuests) else: self.notify.debug("toonKilledCogs: av %s made NO progress" % (avId)) return
def showChoicePoster(self, questId, fromNpcId, toNpcId, rewardId, callback): self.update((questId, fromNpcId, toNpcId, rewardId, 0)) quest = Quests.getQuest(questId) self.rewardText.show() self.rewardText.setZ(-0.205) self.questProgress.hide() if not hasattr(self, 'chooseButton'): guiButton = loader.loadModel('phase_3/models/gui/quit_button') self.chooseButton = DirectButton( parent=self.questFrame, relief=None, image=(guiButton.find('**/QuitBtn_UP'), guiButton.find('**/QuitBtn_DN'), guiButton.find('**/QuitBtn_RLVR')), image_scale=(0.7, 1, 1), text=TTLocalizer.QuestPageChoose, text_scale=0.06, text_pos=(0, -0.02), pos=(0.285, 0, 0.245), scale=0.65) guiButton.removeNode() npcZone = NPCToons.getNPCZone(toNpcId) hoodId = ZoneUtil.getCanonicalHoodId(npcZone) self.chooseButton['command'] = callback self.chooseButton['extraArgs'] = [questId] self.unbind(DGG.WITHIN) self.unbind(DGG.WITHOUT) if not quest.getType() == Quests.TrackChoiceQuest: self.questInfo.setZ(-0.0625) return
def showChoicePoster(self, questId, fromNpcId, toNpcId, rewardId, callback): self.update((questId, fromNpcId, toNpcId, rewardId, 0)) quest = Quests.getQuest(questId) self.rewardText.show() self.rewardText.setZ(-0.205) self.questProgress.hide() if not hasattr(self, 'chooseButton'): guiButton = loader.loadModelOnce('phase_3/models/gui/quit_button') self.chooseButton = DirectButton( parent=self.questFrame, relief=None, image=(guiButton.find('**/QuitBtn_UP'), guiButton.find('**/QuitBtn_DN'), guiButton.find('**/QuitBtn_RLVR')), image_scale=(0.7, 1, 1), text=Localizer.QuestPageChoose, text_scale=0.06, text_pos=(0, -0.02), pos=(0.27, 0, 0.24), scale=0.65) guiButton.removeNode() self.chooseButton['command'] = callback self.chooseButton['extraArgs'] = [questId] self.unbind(WITHIN) self.unbind(WITHOUT) return
def setFromAvatar(self, av): rewardIds = [] for q in av.quests: questId, fromNpcId, toNpcId, rewardId, toonProgress = q if rewardId == Quests.NA: rewardId = Quests.getFinalRewardId(questId, fAll=1) rewardIds.append(rewardId) self.notify.debug('Ignoring rewards: %s' % rewardIds) self.setRewardIndex(av.rewardTier, rewardIds, av.rewardHistory) fishHp = int(len(av.fishCollection) / FishGlobals.FISH_PER_BONUS) self.notify.debug('Adding %s hp for fish collection' % fishHp) self.maxHp += fishHp flowerHp = int(len(av.flowerCollection) / GardenGlobals.FLOWERS_PER_BONUS) self.notify.debug('Adding %s hp for fish collection' % flowerHp) self.maxHp += flowerHp HQdepts = (ToontownGlobals.cogHQZoneId2deptIndex(ToontownGlobals.SellbotHQ), ToontownGlobals.cogHQZoneId2deptIndex(ToontownGlobals.LawbotHQ), ToontownGlobals.cogHQZoneId2deptIndex(ToontownGlobals.CashbotHQ)) levels = av.getCogLevels() cogTypes = av.getCogTypes() suitHp = 0 for dept in HQdepts: suitHp += levels[dept] self.notify.debug('Adding %s hp for cog suits' % suitHp) self.maxHp += suitHp kartingHp = int(av.kartingTrophies.count(1) / RaceGlobals.TrophiesPerCup) self.notify.debug('Adding %s hp for karting trophies' % kartingHp) self.maxHp += kartingHp golfHp = int(av.golfTrophies.count(True) / GolfGlobals.TrophiesPerCup) self.notify.debug('Adding %s hp for golf trophies' % golfHp) self.maxHp += golfHp
def updatePage(self): newQuests = toonbase.localToon.quests carryLimit = toonbase.localToon.getQuestCarryLimit() for i in range(ToontownGlobals.MaxQuestCarryLimit): if i < carryLimit: self.questFrames[i].show() else: self.questFrames[i].hide() for (index, questDesc) in self.quests.items(): if questDesc is not None and list(questDesc) not in newQuests: self.clearQuestFrame(index) for questDesc in newQuests: newQuestDesc = tuple(questDesc) if newQuestDesc not in self.quests.values(): index = self.getLowestUnusedIndex() self.fillQuestFrame(newQuestDesc, index) for i in self.quests.keys(): questDesc = self.quests[i] if questDesc: questId = questDesc[0] if Quests.getQuestClass(questId) == Quests.FriendQuest: self.questFrames[i].update(questDesc)
def updatePage(self): newQuests = toonbase.localToon.quests carryLimit = toonbase.localToon.getQuestCarryLimit() for i in range(ToontownGlobals.MaxQuestCarryLimit): if i < carryLimit: self.questFrames[i].show() else: self.questFrames[i].hide() for index, questDesc in self.quests.items(): if questDesc is not None and list(questDesc) not in newQuests: self.clearQuestFrame(index) for questDesc in newQuests: newQuestDesc = tuple(questDesc) if newQuestDesc not in self.quests.values(): index = self.getLowestUnusedIndex() self.fillQuestFrame(newQuestDesc, index) for i in self.quests.keys(): questDesc = self.quests[i] if questDesc: questId = questDesc[0] if Quests.getQuestClass(questId) == Quests.FriendQuest: self.questFrames[i].update(questDesc) return
def requestInteract(self, toonId, npc): toon = self.air.doId2do.get(toonId) if not toon: return for index, quest in enumerate(self.__toonQuestsList2Quests(toon.quests)): questId, fromNpcId, toNpcId, rewardId, toonProgress = toon.quests[index] isComplete = quest.getCompletionStatus(toon, toon.quests[index], npc) if isComplete != Quests.COMPLETE: continue if toonId in self.air.tutorialManager.avId2fsm.keys(): self.air.tutorialManager.avId2fsm[toonId].demand('Tunnel') if isinstance(quest, Quests.DeliverGagQuest): track, level = quest.getGagType() toon.inventory.setItem(track, level, toon.inventory.numItem(track, level) - quest.getNumGags()) toon.b_setInventory(toon.inventory.makeNetString()) nextQuest = Quests.getNextQuest(questId, npc, toon) if nextQuest == (Quests.NA, Quests.NA): if isinstance(quest, Quests.TrackChoiceQuest): npc.presentTrackChoice(toonId, questId, quest.getChoices()) return rewardId = Quests.getAvatarRewardId(toon, questId) npc.completeQuest(toonId, questId, rewardId) self.completeQuest(toon, questId) self.giveReward(toon, rewardId) return self.completeQuest(toon, questId) nextQuestId = nextQuest[0] nextRewardId = Quests.getFinalRewardId(questId, 1) nextToNpcId = nextQuest[1] self.npcGiveQuest(npc, toon, nextQuestId, nextRewardId, nextToNpcId) return if len(self.__toonQuestsList2Quests(toon.quests)) >= toon.getQuestCarryLimit(): self.notify.debug('Rejecting toonId %d because their quest inventory is full.' % toonId) npc.rejectAvatar(toonId) return if toonId in self.air.tutorialManager.avId2fsm.keys(): if toon.getRewardHistory()[0] == 0: self.npcGiveQuest(npc, toon, 101, Quests.findFinalRewardId(101)[0], Quests.getQuestToNpcId(101), storeReward=True) self.air.tutorialManager.avId2fsm[toonId].demand('Battle') return tier = toon.getRewardHistory()[0] if Quests.avatarHasAllRequiredRewards(toon, tier): if not Quests.avatarWorkingOnRequiredRewards(toon): if tier != Quests.LOOPING_FINAL_TIER: tier += 1 toon.b_setRewardHistory(tier, []) else: self.notify.debug('Rejecting toonId %d because they are still working on their current tier.' % toonId) npc.rejectAvatarTierNotDone(toonId) return suitableQuests = Quests.chooseBestQuests(tier, npc, toon) if not suitableQuests: self.notify.debug('Rejecting toonId %d because there are no quests available!' % toonId) npc.rejectAvatar(toonId) return npc.presentQuestChoice(toonId, suitableQuests)
def isQuestComplete(self, av, npc, questDesc): # The quest in question quest = Quests.getQuest(questDesc[0]) if quest == None: return 0 self.notify.debug("isQuestComplete: avId: %s, quest: %s" % (av.getDoId(), quest)) return quest.getCompletionStatus(av, questDesc, npc)
def assignReward(self, rewardId, rewardIds): if rewardIds.count(rewardId) != 0: rewardIds.remove(rewardId) self.notify.debug('Ignoring reward %d' % rewardId) else: reward = Quests.getReward(rewardId) reward.countReward(self) self.notify.debug('Assigning reward %d' % rewardId)
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
def assignReward(self, rewardId, rewardIds): if rewardIds.count(rewardId) != 0: # This is a reward we're still working on. rewardIds.remove(rewardId) self.notify.debug("Ignoring reward %d" % (rewardId)) else: reward = Quests.getReward(rewardId) reward.countReward(self) self.notify.debug("Assigning reward %d" % (rewardId))
def giveReward(self, toon, rewardId): """ This is called when a toon completes a whole toontask. This grabs the reward from Quests via rewardId and issues the reward to the toon. """ reward = Quests.getReward(rewardId) if reward: reward.sendRewardAI(toon)
def setFromAvatar(self, av): rewardIds = [] for q in av.quests: questId, fromNpcId, toNpcId, rewardId, toonProgress = q if rewardId == Quests.NA: rewardId = Quests.getFinalRewardId(questId, fAll=1) rewardIds.append(rewardId) self.notify.debug('Ignoring rewards: %s' % rewardIds) self.setRewardIndex(av.rewardTier, rewardIds, av.rewardHistory)
def setFromAvatar(self, av): rewardIds = [] for q in av.quests: (questId, fromNpcId, toNpcId, rewardId, toonProgress) = q if rewardId == Quests.NA: rewardId = Quests.getFinalRewardId(questId, fAll = 1) rewardIds.append(rewardId) self.notify.debug('Ignoring rewards: %s' % rewardIds) self.setRewardIndex(av.rewardTier, rewardIds, av.rewardHistory)
def setRewardIndex(self, tier, rewardIds, rewardHistory): self.reset() for tierNum in xrange(tier): for rewardId in Quests.getRewardsInTier(tierNum): reward = Quests.getReward(rewardId) reward.countReward(self) self.notify.debug('Assigning reward %d' % rewardId) for rewardId in rewardHistory: if rewardId in Quests.getRewardsInTier(tier): if rewardIds.count(rewardId) != 0: rewardIds.remove(rewardId) self.notify.debug('Ignoring reward %d' % rewardId) else: reward = Quests.getReward(rewardId) reward.countReward(self) self.notify.debug('Assigning reward %d' % rewardId) self.notify.debug('Remaining rewardIds %s' % rewardIds) self.maxHp = min(ToontownGlobals.MaxHpLimit, self.maxHp)
def avatarChoseTrack(self, avId, npc, questId, trackId): # This is a message that came from the client, through the NPCToonAI. # It is in response to the avatar picking from a multiple choice menu # of track options, along with a cancel option self.notify.info("avatarChoseTrack: avId: %s trackId: %s" % (avId, trackId)) av = self.air.doId2do.get(avId) if av: # Remove the track choice quest av.removeQuest(questId) # Update the toon with the reward rewardId = Quests.getRewardIdFromTrackId(trackId) reward = Quests.getReward(rewardId) reward.sendRewardAI(av) # Tell the npc to deliver the movie which will # complete the quest, display the reward, and do nothing else npc.completeQuest(av.getDoId(), questId, rewardId) self.incrementReward(av) else: self.notify.warning("avatarChoseTrack: av is gone.")
def npcGiveQuest(self, npc, toon, questId, rewardId, toNpcId, storeReward=False): """ This is called when an NPC wants to assign a quest to the toon. """ rewardId = Quests.transformReward(rewardId, toon) # If non-zero, this indicates this is the first quest in the whole ToonTask. # This means we want to store the reward in the toons setRewardHistory. finalReward = rewardId if storeReward else 0 progress = 0 toon.addQuest((questId, npc.getDoId(), toNpcId, rewardId, progress), finalReward) # Tell the NPC that we assigned this quest to the given toon. npc.assignQuest(toon.getDoId(), questId, rewardId, toNpcId)
def makeQuestsFromData(self, avatar): for quest in self.quests.values(): quest.cleanup() self.quests = {} questData = avatar.getQuests() for i in xrange(len(questData[0])): questId = questData[0][i] currentObjectiveIndex = questData[1][i] currentObjectiveProg = questData[2][i] quest = Quests.Quest(questId, currentObjectiveIndex, currentObjectiveProg, i) self.quests[questId] = quest
def _QTQuestNode__questsChanged(self): try: lt = toonbase.localToon except: return None self.phraseList = [] self.encodedMsgList = [] def addMsg(msg, packet): for phrase in self.phraseList: if msg == phrase[0]: return None self.phraseList.append([ msg, QTQuestSend, QTNode.QT_TEXT_NODE]) self.encodedMsgList.append(packet) for quest in lt.quests: (questId, fromNpcId, toNpcId, rewardId, toonProgress) = quest q = Quests.getQuest(questId) if q is None: continue msgs = q.getQTStrings(toNpcId, toonProgress) if type(msgs) != type([]): msgs = [ msgs] for i in xrange(len(msgs)): addMsg(msgs[i], [ questId, toNpcId, toonProgress, i]) needToontask = 1 try: needToontask = len(lt.quests) != lt.questCarryLimit except: pass if needToontask: addMsg(Localizer.QTQuestNodeNeedATask, []) self.createMenu()
def setRewardIndex(self, tier, rewardIds, rewardHistory): self.reset() # Fill in all the tiers up to this one unconditionally for tierNum in range(tier): for rewardId in Quests.getRewardsInTier(tierNum): # TODO: what about rewards on the previous tier? #if ((rewardIds.count(rewardId) != 0) and # (rewardId is not in [100, 101, 102, 103, 104, 105, 106, 107, 108, 109])): # # This is a reward we're still working on. # rewardIds.remove(rewardId) # self.notify.debug("Ignoring reward %d" % (rewardId)) reward = Quests.getReward(rewardId) reward.countReward(self) self.notify.debug("Assigning reward %d" % (rewardId)) # For the current tier, only give credit for rewards we have completed #print 'rewardHistory: ', rewardHistory for rewardId in rewardHistory: # Only count required rewards if rewardId in Quests.getRewardsInTier(tier): if rewardIds.count(rewardId) != 0: # This is a reward we're still working on. #print 'before: ', rewardIds rewardIds.remove(rewardId) self.notify.debug("Ignoring reward %d" % (rewardId)) #print 'after: ', rewardIds else: reward = Quests.getReward(rewardId) reward.countReward(self) self.notify.debug("Assigning reward %d" % (rewardId)) self.notify.debug("Remaining rewardIds %s" % (rewardIds)) # Make sure maxHp does not exceed its maximum. self.maxHp = min(ToontownGlobals.MaxHpLimit, self.maxHp)
def toonKilledBuilding(self, av, track, difficulty, numFloors, zoneId, avList): # This is the battle notifying us that a toon has defeated a # building. See if this toon has a quest on this building. # If so, update the progress. avQuests = av.quests avId = av.getDoId() changed = 0 #self.notify.debug("toonKilledBuilding: avId: %s, track: %s, diff: %s, numFloors: %s, zoneId: %s" % # (avId, track, difficulty, numFloors, zoneId)) for questDesc in avQuests: questClass = Quests.getQuestClass(questDesc[0]) if ((questClass == Quests.BuildingQuest) or (questClass == Quests.BuildingNewbieQuest)): quest = Quests.getQuest(questDesc[0]) matchedTrack = ((quest.getBuildingTrack() == Quests.Any) or (quest.getBuildingTrack() == track)) matchedNumFloors = (quest.getNumFloors() <= numFloors) matchedLocation = quest.isLocationMatch(zoneId) if matchedTrack and matchedNumFloors and matchedLocation: num = quest.doesBuildingCount(avId, avList) if (num > 0): questDesc[4] += num changed = 1 else: # Do not care about this quest here continue # Now send the quests back to the avatar if the status changed if changed: self.notify.debug("toonKilledBuilding: av made progress") av.b_setQuests(avQuests) else: self.notify.debug("toonKilledBuilding: av made NO progress") return
def getQuestIntervalList(self, toon, deathList, toonList=[]): avQuests = copy.deepcopy(toon.quests) avId = toon.getDoId() changed = 0 tickDelay = 0.5 intervalList = [] cogList = [] for i in range(0, len(deathList), 2): cogIndex = deathList[i] cogLevel = deathList[i + 1] cogType = AvatarDNA.suitHeadTypes[cogIndex] cogTrack = AvatarDNA.getSuitDept(cogType) cogList.append({ 'type': cogType, 'level': cogLevel, 'track': cogTrack, 'activeToons': [avId] }) try: zoneId = toonbase.tcr.playGame.getPlace().getZoneId() except: zoneId = 0 else: for i in range(len(avQuests)): questDesc = avQuests[i] questId, npcId, toNpcId, rewardId, toonProgress = questDesc quest = Quests.getQuest(questId) questString = quest.getString() progressString = quest.getProgressString(toon, questDesc) questLabel = self.questLabelList[i] for cogDict in cogList: if quest.doesCogCount(avId, cogDict, zoneId, toonList): questDesc[4] += 1 changed = 1 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 showChoicePoster(self, questId, fromNpcId, toNpcId, rewardId, callback): self.update((questId, fromNpcId, toNpcId, rewardId, 0)) quest = Quests.getQuest(questId) self.rewardText.show() self.rewardText.setZ(-0.20499999999999999) self.questProgress.hide() if not hasattr(self, 'chooseButton'): guiButton = loader.loadModelOnce('phase_3/models/gui/quit_button') self.chooseButton = DirectButton(parent = self.questFrame, relief = None, image = (guiButton.find('**/QuitBtn_UP'), guiButton.find('**/QuitBtn_DN'), guiButton.find('**/QuitBtn_RLVR')), image_scale = (0.69999999999999996, 1, 1), text = Localizer.QuestPageChoose, text_scale = 0.059999999999999998, text_pos = (0, -0.02), pos = (0.27000000000000002, 0, 0.23999999999999999), scale = 0.65000000000000002) guiButton.removeNode() self.chooseButton['command'] = callback self.chooseButton['extraArgs'] = [ questId] self.unbind(WITHIN) self.unbind(WITHOUT)
def decodeQTQuestMsg(msg): if len(msg) == 0: return Localizer.QTQuestNodeNeedATask if len(msg) != 4: return None questId, toNpcId, toonProgress, index = msg quest = Quests.getQuest(questId) if not quest: return None msgs = quest.getQTStrings(toNpcId, toonProgress) if type(msgs) != type([]): msgs = [msgs] if index >= len(msgs): return None return msgs[index] return
def decodeQTQuestMsg(msg): if len(msg) == 0: return Localizer.QTQuestNodeNeedATask if len(msg) != 4: return None (questId, toNpcId, toonProgress, index) = msg quest = Quests.getQuest(questId) if not quest: return None msgs = quest.getQTStrings(toNpcId, toonProgress) if type(msgs) != type([]): msgs = [ msgs] if index >= len(msgs): return None return msgs[index]
def update(self, questDesc): questId, fromNpcId, toNpcId, rewardId, toonProgress = questDesc quest = Quests.getQuest(questId) if quest == None: self.notify.warning('Tried to display poster for unknown quest %s' % questId) return if rewardId == Quests.NA: finalReward = Quests.getFinalRewardId(questId, fAll=1) transformedReward = Quests.transformReward(finalReward, base.localAvatar) reward = Quests.getReward(transformedReward) else: reward = Quests.getReward(rewardId) if reward and questId not in Quests.NoRewardTierZeroQuests: rewardString = reward.getPosterString() else: rewardString = '' self.rewardText['text'] = rewardString self.fitLabel(self.rewardText) if Quests.isQuestJustForFun(questId, rewardId): self.funQuest.show() else: self.funQuest.hide() if self._deleteCallback: self.showDeleteButton(questDesc) else: self.hideDeleteButton() fComplete = quest.getCompletionStatus(base.localAvatar, questDesc) == Quests.COMPLETE if Quests.isQuestJustForFun(questId, rewardId): if fComplete: self.funQuest.hide() if toNpcId == Quests.ToonHQ: toNpcName = TTLocalizer.QuestPosterHQOfficer toNpcBuildingName = TTLocalizer.QuestPosterHQBuildingName toNpcStreetName = TTLocalizer.QuestPosterHQStreetName toNpcLocationName = TTLocalizer.QuestPosterHQLocationName elif toNpcId == Quests.ToonTailor: toNpcName = TTLocalizer.QuestPosterTailor toNpcBuildingName = TTLocalizer.QuestPosterTailorBuildingName toNpcStreetName = TTLocalizer.QuestPosterTailorStreetName toNpcLocationName = TTLocalizer.QuestPosterTailorLocationName else: toNpcName = NPCToons.getNPCName(toNpcId) toNpcZone = NPCToons.getNPCZone(toNpcId) toNpcHoodId = ZoneUtil.getCanonicalHoodId(toNpcZone) toNpcLocationName = base.cr.hoodMgr.getFullnameFromId(toNpcHoodId) toNpcBuildingName = NPCToons.getBuildingTitle(toNpcZone) toNpcBranchId = ZoneUtil.getBranchZone(toNpcZone) toNpcStreetName = ZoneUtil.getStreetName(toNpcBranchId) lPos = Vec3(0, 0, 0.13) lIconGeom = None lIconGeomScale = 1 rIconGeom = None rIconGeomScale = 1 infoText = '' infoZ = TTLocalizer.QPinfoZ auxText = None auxTextPos = Vec3(0, 0, 0.12) headlineString = quest.getHeadlineString() objectiveStrings = quest.getObjectiveStrings() captions = map(lambda x: str(x).title(), quest.getObjectiveStrings()) imageColor = Vec4(*self.colors['white']) if quest.getType() == Quests.DeliverGagQuest or quest.getType() == Quests.DeliverItemQuest: frameBgColor = 'red' if quest.getType() == Quests.DeliverGagQuest: invModel = loader.loadModel('phase_3.5/models/gui/inventory_icons') track, item = quest.getGagType() lIconGeom = invModel.find('**/' + AvPropsNew[track][item]) invModel.removeNode() else: bookModel = loader.loadModel('phase_3.5/models/gui/stickerbook_gui') lIconGeom = bookModel.find('**/package') lIconGeomScale = 0.12 bookModel.removeNode() if not fComplete: captions.append(toNpcName) auxText = TTLocalizer.QuestPosterAuxTo auxTextPos.setZ(0.12) lPos.setX(-0.18) infoText = TTLocalizer.QuestPageDestination % (toNpcBuildingName, toNpcStreetName, toNpcLocationName) rIconGeom = self.createNpcToonHead(toNpcId) rIconGeomScale = IMAGE_SCALE_SMALL elif quest.getType() == Quests.RecoverItemQuest: frameBgColor = 'green' bookModel = loader.loadModel('phase_3.5/models/gui/stickerbook_gui') lIconGeom = bookModel.find('**/package') lIconGeomScale = 0.12 bookModel.removeNode() if not fComplete: rIconGeomScale = IMAGE_SCALE_SMALL holder = quest.getHolder() holderType = quest.getHolderType() if holder == Quests.Any: cogIcons = loader.loadModel('phase_3/models/gui/cog_icons') rIconGeom = cogIcons.find('**/cog') cogIcons.removeNode() lPos.setX(-0.18) auxText = TTLocalizer.QuestPosterAuxFrom elif holder == Quests.AnyFish: headlineString = TTLocalizer.QuestPosterFishing auxText = TTLocalizer.QuestPosterAuxFor auxTextPos.setX(-0.18) captions = captions[:1] else: if holderType == 'track': cogIcons = loader.loadModel('phase_3/models/gui/cog_icons') if holder == 'c': icon = cogIcons.find('**/CorpIcon') elif holder == 's': icon = cogIcons.find('**/SalesIcon') elif holder == 'l': icon = cogIcons.find('**/LegalIcon') elif holder == 'm': icon = cogIcons.find('**/MoneyIcon') rIconGeom = icon.copyTo(hidden) rIconGeom.setColor(Suit.Suit.medallionColors[holder]) rIconGeomScale = 0.12 cogIcons.removeNode() elif holderType == 'level': cogIcons = loader.loadModel('phase_3/models/gui/cog_icons') rIconGeom = cogIcons.find('**/cog') rIconGeomScale = IMAGE_SCALE_SMALL cogIcons.removeNode() else: rIconGeom = self.createSuitHead(holder) lPos.setX(-0.18) auxText = TTLocalizer.QuestPosterAuxFrom infoText = quest.getLocationName() if infoText == '': infoText = TTLocalizer.QuestPosterAnywhere elif quest.getType() == Quests.VisitQuest: frameBgColor = 'brown' captions[0] = '%s' % toNpcName lIconGeom = self.createNpcToonHead(toNpcId) lIconGeomScale = IMAGE_SCALE_SMALL if not fComplete: infoText = TTLocalizer.QuestPageDestination % (toNpcBuildingName, toNpcStreetName, toNpcLocationName) elif quest.getType() == Quests.TrackChoiceQuest: frameBgColor = 'green' invModel = loader.loadModel('phase_3.5/models/gui/inventory_icons') track1, track2 = quest.getChoices() lIconGeom = invModel.find('**/' + AvPropsNew[track1][1]) if not fComplete: auxText = TTLocalizer.QuestPosterAuxOr lPos.setX(-0.18) rIconGeom = invModel.find('**/' + AvPropsNew[track2][1]) infoText = TTLocalizer.QuestPageNameAndDestination % (toNpcName, toNpcBuildingName, toNpcStreetName, toNpcLocationName) infoZ = -0.02 invModel.removeNode() elif quest.getType() == Quests.BuildingQuest: frameBgColor = 'blue' track = quest.getBuildingTrack() numFloors = quest.getNumFloors() if track == 'c': lIconGeom = loader.loadModel('phase_4/models/modules/suit_landmark_corp') elif track == 'l': lIconGeom = loader.loadModel('phase_4/models/modules/suit_landmark_legal') elif track == 'm': lIconGeom = loader.loadModel('phase_4/models/modules/suit_landmark_money') elif track == 's': lIconGeom = loader.loadModel('phase_4/models/modules/suit_landmark_sales') else: bookModel = loader.loadModel('phase_3.5/models/gui/stickerbook_gui') lIconGeom = bookModel.find('**/COG_building') bookModel.removeNode() if lIconGeom and track != Quests.Any: self.loadElevator(lIconGeom, numFloors) lIconGeom.setH(180) self.fitGeometry(lIconGeom, fFlip=0) lIconGeomScale = IMAGE_SCALE_SMALL else: lIconGeomScale = 0.13 if not fComplete: infoText = quest.getLocationName() if infoText == '': infoText = TTLocalizer.QuestPosterAnywhere # cogdo quest elif quest.getType() == Quests.CogdoQuest: frameBgColor = 'lightGreen' track = quest.getBuildingTrack() if track == 'c': lIconGeom = loader.loadModel('phase_4/models/modules/suit_landmark_corp') elif track == 'l': lIconGeom = loader.loadModel('phase_4/models/modules/suit_landmark_legal') elif track == 'm': lIconGeom = loader.loadModel('phase_4/models/modules/suit_landmark_money') elif track == 's': lIconGeom = loader.loadModel('phase_4/models/modules/suit_landmark_sales') else: lIconGeom = loader.loadModel('phase_5/models/cogdominium/tt_m_ara_cbe_fieldOfficeMoverShaker') if lIconGeom and track != Quests.Any: lIconGeom.setH(180) else: lIconGeom.setH(180) self.fitGeometry(lIconGeom) lIconGeomScale = IMAGE_SCALE_SMALL if not fComplete: infoText = quest.getLocationName() if infoText == '': infoText = TTLocalizer.QuestPosterAnywhere elif quest.getType() == Quests.FactoryQuest: frameBgColor = 'blue' bookModel = loader.loadModel('phase_3.5/models/gui/stickerbook_gui') lIconGeom = bookModel.find('**/factoryIcon2') bookModel.removeNode() lIconGeomScale = 0.13 if not fComplete: infoText = quest.getLocationName() if infoText == '': infoText = TTLocalizer.QuestPosterAnywhere elif quest.getType() == Quests.MintQuest: frameBgColor = 'blue' bookModel = loader.loadModel('phase_3.5/models/gui/stickerbook_gui') lIconGeom = bookModel.find('**/CashBotMint') bookModel.removeNode() lIconGeomScale = 0.13 if not fComplete: infoText = quest.getLocationName() if infoText == '': infoText = TTLocalizer.QuestPosterAnywhere elif quest.getType() == Quests.ForemanQuest or quest.getType() == Quests.SupervisorQuest: frameBgColor = 'blue' bookModel = loader.loadModel('phase_3.5/models/gui/stickerbook_gui') lIconGeom = bookModel.find('**/skelecog5') bookModel.removeNode() lIconGeomScale = 0.13 if not fComplete: infoText = quest.getLocationName() if infoText == '': infoText = TTLocalizer.QuestPosterAnywhere elif quest.getType() == Quests.BossQuest: frameBgColor = 'blue' cogIcons = loader.loadModel('phase_3/models/gui/cog_icons') lIconGeom = cogIcons.find('**/cog') lIconGeomScale = IMAGE_SCALE_SMALL cogIcons.removeNode() if not fComplete: infoText = quest.getLocationName() if infoText == '': infoText = TTLocalizer.QuestPosterAnywhere elif quest.getType() == Quests.VPQuest: frameBgColor = 'blue' lIconGeom = loader.loadModel('phase_9/models/char/sellbotBoss-head-zero') lIconGeomPos = [0, 0, -0.055] lIconGeomHpr = [-90, 0, -90] lIconGeomScale = 0.015 if not fComplete: infoText = quest.getLocationName() if infoText == '': infoText = TTLocalizer.QuestPosterAnywhere elif quest.getType() == Quests.CFOQuest: frameBgColor = 'blue' lIconGeom = loader.loadModel('phase_10/models/char/cashbotBoss-head-zero') lIconGeomPos = [0, 0, -0.055] lIconGeomHpr = [90, 0, -90] lIconGeomScale = 0.015 if not fComplete: infoText = quest.getLocationName() if infoText == '': infoText = TTLocalizer.QuestPosterAnywhere elif quest.getType() == Quests.CJQuest: frameBgColor = 'blue' lIconGeom = loader.loadModel('phase_11/models/char/lawbotBoss-head-zero') lIconGeomPos = [0, 0, -0.055] lIconGeomHpr = [90, 0, -90] lIconGeomScale = 0.025 if not fComplete: infoText = quest.getLocationName() if infoText == '': infoText = TTLocalizer.QuestPosterAnywhere elif quest.getType() == Quests.CEOQuest: frameBgColor = 'blue' lIconGeom = loader.loadModel('phase_12/models/char/bossbotBoss-head-zero') lIconGeomPos = [0, 0, -0.065] lIconGeomHpr = [90, 0, -90] lIconGeomScale = 0.0125 if not fComplete: infoText = quest.getLocationName() if infoText == '': infoText = TTLocalizer.QuestPosterAnywhere elif 0:#quest.getType() == Quests.FriendQuest: frameBgColor = 'brown' gui = loader.loadModel('phase_3.5/models/gui/friendslist_gui') lIconGeom = gui.find('**/FriendsBox_Closed') lIconGeomScale = 0.45 gui.removeNode() infoText = TTLocalizer.QuestPosterAnywhere elif quest.getType() == Quests.TrolleyQuest: frameBgColor = 'lightBlue' gui = loader.loadModel('phase_3.5/models/gui/stickerbook_gui') lIconGeom = gui.find('**/trolley') lIconGeomScale = 0.13 gui.removeNode() infoText = TTLocalizer.QuestPosterPlayground elif quest.getType() == Quests.MailboxQuest: frameBgColor = 'lightBlue' bookModel = loader.loadModel('phase_3.5/models/gui/stickerbook_gui') lIconGeom = bookModel.find('**/package') lIconGeomScale = 0.12 bookModel.removeNode() infoText = TTLocalizer.QuestPosterAtHome elif quest.getType() == Quests.PhoneQuest: frameBgColor = 'lightBlue' bookModel = loader.loadModel('phase_3.5/models/gui/stickerbook_gui') lIconGeom = bookModel.find('**/clarabelleCow') lIconGeomScale = 0.12 bookModel.removeNode() infoText = TTLocalizer.QuestPosterOnPhone else: frameBgColor = 'blue' if quest.getType() == Quests.CogTrackQuest: dept = quest.getCogTrack() cogIcons = loader.loadModel('phase_3/models/gui/cog_icons') lIconGeomScale = 0.13 if dept == 'c': icon = cogIcons.find('**/CorpIcon') elif dept == 's': icon = cogIcons.find('**/SalesIcon') elif dept == 'l': icon = cogIcons.find('**/LegalIcon') elif dept == 'm': icon = cogIcons.find('**/MoneyIcon') lIconGeom = icon.copyTo(hidden) lIconGeom.setColor(Suit.Suit.medallionColors[dept]) cogIcons.removeNode() elif quest.getType() == Quests.CogQuest: if quest.getCogType() != Quests.Any: lIconGeom = self.createSuitHead(quest.getCogType()) lIconGeomScale = IMAGE_SCALE_SMALL else: cogIcons = loader.loadModel('phase_3/models/gui/cog_icons') lIconGeom = cogIcons.find('**/cog') lIconGeomScale = IMAGE_SCALE_SMALL cogIcons.removeNode() elif quest.getType() == Quests.CogLevelQuest: cogIcons = loader.loadModel('phase_3/models/gui/cog_icons') lIconGeom = cogIcons.find('**/cog') lIconGeomScale = IMAGE_SCALE_SMALL cogIcons.removeNode() elif quest.getType() == Quests.SkelecogTrackQuest: dept = quest.getCogTrack() cogIcons = loader.loadModel('phase_3/models/gui/cog_icons') lIconGeomScale = 0.13 if dept == 'c': icon = cogIcons.find('**/CorpIcon') elif dept == 's': icon = cogIcons.find('**/SalesIcon') elif dept == 'l': icon = cogIcons.find('**/LegalIcon') elif dept == 'm': icon = cogIcons.find('**/MoneyIcon') lIconGeom = icon.copyTo(hidden) lIconGeom.setColor(Suit.Suit.medallionColors[dept]) cogIcons.removeNode() elif quest.getType() == Quests.SkelecogQuest: cogIcons = loader.loadModel('phase_3.5/models/gui/stickerbook_gui') lIconGeom = cogIcons.find('**/skelecog5') lIconGeomScale = IMAGE_SCALE_SMALL cogIcons.removeNode() elif quest.getType() == Quests.SkelecogLevelQuest: cogIcons = loader.loadModel('phase_3.5/models/gui/stickerbook_gui') lIconGeom = cogIcons.find('**/skelecog5') lIconGeomScale = IMAGE_SCALE_SMALL cogIcons.removeNode() elif quest.getType() == Quests.SkeleReviveQuest: cogIcons = loader.loadModel('phase_3.5/models/gui/stickerbook_gui') lIconGeom = cogIcons.find('**/skelecog5') lIconGeomScale = IMAGE_SCALE_SMALL cogIcons.removeNode() if not fComplete: infoText = quest.getLocationName() if infoText == '': infoText = TTLocalizer.QuestPosterAnywhere if fComplete: textColor = (0, 0.3, 0, 1) imageColor = Vec4(*self.colors['lightGreen']) lPos.setX(-0.18) rIconGeom = self.createNpcToonHead(toNpcId) rIconGeomScale = IMAGE_SCALE_SMALL captions = captions[:1] captions.append(toNpcName) auxText = TTLocalizer.QuestPosterAuxReturnTo headlineString = TTLocalizer.QuestPosterComplete infoText = TTLocalizer.QuestPageDestination % (toNpcBuildingName, toNpcStreetName, toNpcLocationName) if self.laffMeter != None: self.laffMeter.reparentTo(hidden) self.laffMeter.destroy() self.laffMeter = None else: textColor = self.normalTextColor self.show() self['image_color'] = imageColor self.headline['text_fg'] = textColor self.headline['text'] = headlineString self.lPictureFrame.show() self.lPictureFrame.setPos(lPos) self.lPictureFrame['text_scale'] = TEXT_SCALE if lPos[0] != 0: self.lPictureFrame['text_scale'] = 0.0325 self.lPictureFrame['text'] = captions[0] self.lPictureFrame['image_color'] = Vec4(*self.colors[frameBgColor]) if len(captions) > 1: self.rPictureFrame.show() self.rPictureFrame['text'] = captions[1] self.rPictureFrame['text_scale'] = 0.0325 self.rPictureFrame['image_color'] = Vec4(*self.colors[frameBgColor]) else: self.rPictureFrame.hide() self._deleteGeoms() self.lQuestIcon['geom'] = lIconGeom self.lQuestIcon['geom_pos'] = (0, 10, 0) if lIconGeom: try: self.lQuestIcon['geom_scale'] = lIconGeomScale except: pass try: self.lQuestIcon['geom_pos'] = Point3(lIconGeomPos[0], lIconGeomPos[1], lIconGeomPos[2]) except: pass try: self.lQuestIcon['geom_hpr'] = Point3(lIconGeomHpr[0], lIconGeomHpr[1], lIconGeomHpr[2]) except: pass if self.laffMeter != None: self.laffMeter.reparentTo(self.lQuestIcon) self.rQuestIcon['geom'] = rIconGeom self.rQuestIcon['geom_pos'] = (0, 10, 0) if rIconGeom: self.rQuestIcon['geom_scale'] = rIconGeomScale if auxText: self.auxText.show() self.auxText['text'] = auxText self.auxText.setPos(auxTextPos) else: self.auxText.hide() self.bind(DGG.WITHIN, self.mouseEnterPoster) self.bind(DGG.WITHOUT, self.mouseExitPoster) numQuestItems = quest.getNumQuestItems() if fComplete or numQuestItems <= 1: self.questProgress.hide() if not quest.getType() == Quests.TrackChoiceQuest: infoZ = -0.075 else: self.questProgress.show() self.questProgress['value'] = toonProgress & pow(2, 16) - 1 self.questProgress['range'] = numQuestItems self.questProgress['text'] = quest.getProgressString(base.localAvatar, questDesc) self.questInfo['text'] = infoText self.questInfo.setZ(infoZ) self.fitLabel(self.questInfo) return
def _DistributedFishingSpot__showQuestItem(self, itemId): self._DistributedFishingSpot__makeGui() itemName = Quests.getItemName(itemId) self.itemLabel['text'] = itemName self.itemGui.reparentTo(aspect2d)
def update(self, questDesc): questId, fromNpcId, toNpcId, rewardId, toonProgress = questDesc quest = Quests.getQuest(questId) self.teleportButton['command'] = self.teleportToShop self.teleportButton['extraArgs'] = [toNpcId] if quest == None: self.notify.warning('Tried to display poster for unknown quest %s' % questId) return if rewardId == Quests.NA: finalReward = Quests.getFinalRewardId(questId, fAll=1) transformedReward = Quests.transformReward(finalReward, base.localAvatar) reward = Quests.getReward(transformedReward) else: reward = Quests.getReward(rewardId) if reward and questId not in Quests.NoRewardTierZeroQuests: rewardString = reward.getPosterString() else: rewardString = '' self.rewardText['text'] = rewardString self.fitLabel(self.rewardText) if Quests.isQuestJustForFun(questId, rewardId): self.funQuest.show() else: self.funQuest.hide() if self._deleteCallback: self.showDeleteButton(questDesc) else: self.hideDeleteButton() if self.laffMeter: self.laffMeter.destroy() fComplete = quest.getCompletionStatus(base.localAvatar, questDesc) == Quests.COMPLETE if Quests.isQuestJustForFun(questId, rewardId): if fComplete: self.funQuest.hide() self.teleportButton.show() else: self.teleportButton.hide() if toNpcId == Quests.ToonHQ: self.teleportButton.show() self.teleportButton.setPos(0.285, 0, -0.15) toNpcName = TTLocalizer.QuestPosterHQOfficer toNpcBuildingName = TTLocalizer.QuestPosterHQBuildingName toNpcStreetName = TTLocalizer.QuestPosterHQStreetName toNpcLocationName = TTLocalizer.QuestPosterHQLocationName elif toNpcId == Quests.ToonTailor: self.teleportButton.show() self.teleportButton.setPos(0.285, 0, -0.15) toNpcName = TTLocalizer.QuestPosterTailor toNpcBuildingName = TTLocalizer.QuestPosterTailorBuildingName toNpcStreetName = TTLocalizer.QuestPosterTailorStreetName toNpcLocationName = TTLocalizer.QuestPosterTailorLocationName else: self.teleportButton.show() self.teleportButton.setPos(0.285, 0, -0.15) toNpcName = NPCToons.getNPCName(toNpcId) toNpcZone = NPCToons.getNPCZone(toNpcId) toNpcHoodId = ZoneUtil.getCanonicalHoodId(toNpcZone) toNpcLocationName = base.cr.hoodMgr.getFullnameFromId(toNpcHoodId) toNpcBuildingName = NPCToons.getBuildingTitle(toNpcZone) toNpcBranchId = ZoneUtil.getBranchZone(toNpcZone) toNpcStreetName = ZoneUtil.getStreetName(toNpcBranchId) lPos = Vec3(0, 0, 0.13) lIconGeom = None lIconGeomScale = 1 rIconGeom = None rIconGeomScale = 1 infoText = '' infoZ = TTLocalizer.QPinfoZ auxText = None auxTextPos = Vec3(0, 0, 0.12) headlineString = quest.getHeadlineString() objectiveStrings = quest.getObjectiveStrings() captions = map(string.capwords, quest.getObjectiveStrings()) imageColor = Vec4(*self.colors['white']) if isinstance(quest, Quests.TexturedQuest) and quest.hasFrame(): self.teleportButton.hide() frame = quest.getFrame() frameBgColor = frame[1] lIconGeom = frame[0] lIconGeomScale = 0.13 if not fComplete: infoText = quest.getLocationName() if infoText == '': infoText = TTLocalizer.QuestPosterAnywhere elif quest.getType() == Quests.DeliverGagQuest or quest.getType() == Quests.DeliverItemQuest: frameBgColor = 'red' if fComplete: self.teleportButton.show() self.teleportButton.setPos(0.175, 0, -0.125) if quest.getType() == Quests.DeliverGagQuest: invModel = loader.loadModel('phase_3.5/models/gui/inventory_icons') track, item = quest.getGagType() lIconGeom = invModel.find('**/' + AvPropsNew[track][item]) invModel.removeNode() else: bookModel = loader.loadModel('phase_3.5/models/gui/stickerbook_gui') lIconGeom = bookModel.find('**/package') lIconGeomScale = 0.12 bookModel.removeNode() if not fComplete: captions.append(toNpcName) auxText = TTLocalizer.QuestPosterAuxTo auxTextPos.setZ(0.12) lPos.setX(-0.18) infoText = TTLocalizer.QuestPageDestination % (toNpcBuildingName, toNpcStreetName, toNpcLocationName) rIconGeom = self.createNpcToonHead(toNpcId) rIconGeomScale = IMAGE_SCALE_SMALL self.teleportButton.setPos(0.285, 0, -0.15) elif quest.getType() == Quests.RecoverItemQuest: frameBgColor = 'green' bookModel = loader.loadModel('phase_3.5/models/gui/stickerbook_gui') lIconGeom = bookModel.find('**/package') lIconGeomScale = 0.12 bookModel.removeNode() if not fComplete: rIconGeomScale = IMAGE_SCALE_SMALL holder = quest.getHolder() holderType = quest.getHolderType() if holder == Quests.Any: cogIcons = loader.loadModel('phase_3/models/gui/cog_icons') rIconGeom = cogIcons.find('**/cog') cogIcons.removeNode() lPos.setX(-0.18) auxText = TTLocalizer.QuestPosterAuxFrom elif holder == Quests.AnyFish: headlineString = TTLocalizer.QuestPosterFishing auxText = TTLocalizer.QuestPosterAuxFor auxTextPos.setX(-0.18) captions = captions[:1] else: if holderType == 'track': cogIcons = loader.loadModel('phase_3/models/gui/cog_icons') if holder in SuitDNA.suitDeptModelPaths: icon = cogIcons.find(SuitDNA.suitDeptModelPaths[holder]) rIconGeom = icon.copyTo(hidden) rIconGeom.setColor(Suit.Suit.medallionColors[holder]) rIconGeomScale = 0.12 cogIcons.removeNode() elif holderType == 'level': cogIcons = loader.loadModel('phase_3/models/gui/cog_icons') rIconGeom = cogIcons.find('**/cog') rIconGeomScale = IMAGE_SCALE_SMALL cogIcons.removeNode() else: rIconGeom = self.createSuitHead(holder) lPos.setX(-0.18) auxText = TTLocalizer.QuestPosterAuxFrom infoText = quest.getLocationName() if infoText == '': infoText = TTLocalizer.QuestPosterAnywhere else: self.teleportButton.show() elif quest.getType() == Quests.VisitQuest: self.teleportButton.show() frameBgColor = 'brown' captions[0] = '%s' % toNpcName lIconGeom = self.createNpcToonHead(toNpcId) lIconGeomScale = IMAGE_SCALE_SMALL if not fComplete: infoText = TTLocalizer.QuestPageDestination % (toNpcBuildingName, toNpcStreetName, toNpcLocationName) elif quest.getType() == Quests.TrackChoiceQuest: frameBgColor = 'green' filmstrip = loader.loadModel('phase_3.5/models/gui/filmstrip') lIconGeom = DirectFrame(parent=self, relief=None, image=filmstrip, image_scale=.5) self.question = DirectLabel(parent=lIconGeom, relief=None, pos=(0, 0, 0), text='?', text_scale=0.2, text_pos=(0, -0.04), text_fg=(0.72, 0.72, 0.72, 1)) lIconGeom['image_color'] = Vec4(0.7, 0.7, 0.7, 1) self.question['text_fg'] = Vec4(0.6, 0.6, 0.6, 1) rIconGeom = None filmstrip.removeNode() elif quest.getType() == Quests.BuildingQuest: self.teleportButton.hide() frameBgColor = 'blue' track = quest.getBuildingTrack() numFloors = quest.getNumFloors() if track == 'c': lIconGeom = loader.loadModel('phase_4/models/modules/suit_landmark_corp') elif track == 'l': lIconGeom = loader.loadModel('phase_4/models/modules/suit_landmark_legal') elif track == 'm': lIconGeom = loader.loadModel('phase_4/models/modules/suit_landmark_money') elif track == 's': lIconGeom = loader.loadModel('phase_4/models/modules/suit_landmark_sales') else: bookModel = loader.loadModel('phase_3.5/models/gui/stickerbook_gui') lIconGeom = bookModel.find('**/COG_building') bookModel.removeNode() if lIconGeom and track != Quests.Any: self.loadElevator(lIconGeom, numFloors) lIconGeom.setH(180) self.fitGeometry(lIconGeom, fFlip=0) lIconGeomScale = IMAGE_SCALE_SMALL else: lIconGeomScale = 0.13 if not fComplete: infoText = quest.getLocationName() if infoText == '': infoText = TTLocalizer.QuestPosterAnywhere elif quest.getType() == Quests.FactoryQuest: self.teleportButton.hide() frameBgColor = 'blue' bookModel = loader.loadModel('phase_3.5/models/gui/stickerbook_gui') lIconGeom = bookModel.find('**/factoryIcon2') bookModel.removeNode() lIconGeomScale = 0.13 if not fComplete: infoText = quest.getLocationName() if infoText == '': infoText = TTLocalizer.QuestPosterAnywhere elif quest.getType() == Quests.MintQuest: self.teleportButton.hide() frameBgColor = 'blue' bookModel = loader.loadModel('phase_3.5/models/gui/stickerbook_gui') lIconGeom = bookModel.find('**/CashBotMint') bookModel.removeNode() lIconGeomScale = 0.13 if not fComplete: infoText = quest.getLocationName() if infoText == '': infoText = TTLocalizer.QuestPosterAnywhere elif quest.getType() == Quests.CogPartQuest: self.teleportButton.hide() frameBgColor = 'green' bookModel = loader.loadModel('phase_3.5/models/gui/stickerbook_gui') lIconGeom = bookModel.find('**/CogArmIcon2') bookModel.removeNode() lIconGeomScale = 0.13 if not fComplete: infoText = quest.getLocationName() if infoText == '': infoText = TTLocalizer.QuestPosterAnywhere elif quest.getType() == Quests.ForemanQuest or quest.getType() == Quests.SupervisorQuest: self.teleportButton.hide() frameBgColor = 'blue' bookModel = loader.loadModel('phase_3.5/models/gui/stickerbook_gui') lIconGeom = bookModel.find('**/skelecog5') bookModel.removeNode() lIconGeomScale = 0.13 if not fComplete: infoText = quest.getLocationName() if infoText == '': infoText = TTLocalizer.QuestPosterAnywhere elif quest.getType() == Quests.RescueQuest: self.teleportButton.hide() frameBgColor = 'blue' lIconGeom = self.createNpcToonHead(random.choice(NPCToons.HQnpcFriends.keys())) lIconGeomScale = 0.13 infoText = quest.getLocationName().strip() elif quest.getType() == Quests.FriendQuest: self.teleportButton.hide() frameBgColor = 'brown' gui = loader.loadModel('phase_3.5/models/gui/friendslist_gui') lIconGeom = gui.find('**/FriendsBox_Closed') lIconGeomScale = 0.45 gui.removeNode() infoText = TTLocalizer.QuestPosterAnywhere elif quest.getType() == Quests.TrolleyQuest: self.teleportButton.hide() frameBgColor = 'lightBlue' gui = loader.loadModel('phase_3.5/models/gui/stickerbook_gui') lIconGeom = gui.find('**/trolley') lIconGeomScale = 0.13 gui.removeNode() infoText = TTLocalizer.QuestPosterPlayground elif quest.getType() == Quests.MailboxQuest: self.teleportButton.hide() frameBgColor = 'lightBlue' bookModel = loader.loadModel('phase_3.5/models/gui/stickerbook_gui') lIconGeom = bookModel.find('**/package') lIconGeomScale = 0.12 bookModel.removeNode() infoText = TTLocalizer.QuestPosterAtHome elif quest.getType() == Quests.PhoneQuest: self.teleportButton.hide() frameBgColor = 'lightBlue' bookModel = loader.loadModel('phase_3.5/models/gui/stickerbook_gui') lIconGeom = bookModel.find('**/clarabelleCow') lIconGeomScale = 0.12 bookModel.removeNode() infoText = TTLocalizer.QuestPosterOnPhone else: self.teleportButton.hide() frameBgColor = 'blue' if quest.getType() == Quests.CogTrackQuest: dept = quest.getCogTrack() cogIcons = loader.loadModel('phase_3/models/gui/cog_icons') lIconGeomScale = 0.13 if dept in SuitDNA.suitDeptModelPaths: icon = cogIcons.find(SuitDNA.suitDeptModelPaths[dept]) lIconGeom = icon.copyTo(hidden) lIconGeom.setColor(Suit.Suit.medallionColors[dept]) cogIcons.removeNode() elif quest.getType() == Quests.CogQuest: if quest.getCogType() != Quests.Any: lIconGeom = self.createSuitHead(quest.getCogType()) lIconGeomScale = IMAGE_SCALE_SMALL else: cogIcons = loader.loadModel('phase_3/models/gui/cog_icons') lIconGeom = cogIcons.find('**/cog') lIconGeomScale = IMAGE_SCALE_SMALL cogIcons.removeNode() elif quest.getType() == Quests.CogLevelQuest: cogIcons = loader.loadModel('phase_3/models/gui/cog_icons') lIconGeom = cogIcons.find('**/cog') lIconGeomScale = IMAGE_SCALE_SMALL cogIcons.removeNode() elif quest.getType() == Quests.SkelecogTrackQuest: dept = quest.getCogTrack() cogIcons = loader.loadModel('phase_3/models/gui/cog_icons') lIconGeomScale = 0.13 if dept in SuitDNA.suitDeptModelPaths: icon = cogIcons.find(SuitDNA.suitDeptModelPaths[dept]) lIconGeom = icon.copyTo(hidden) lIconGeom.setColor(Suit.Suit.medallionColors[dept]) cogIcons.removeNode() elif quest.getType() == Quests.SkelecogQuest: cogIcons = loader.loadModel('phase_3.5/models/gui/stickerbook_gui') lIconGeom = cogIcons.find('**/skelecog5') lIconGeomScale = IMAGE_SCALE_SMALL cogIcons.removeNode() elif quest.getType() == Quests.SkelecogLevelQuest: cogIcons = loader.loadModel('phase_3.5/models/gui/stickerbook_gui') lIconGeom = cogIcons.find('**/skelecog5') lIconGeomScale = IMAGE_SCALE_SMALL cogIcons.removeNode() elif quest.getType() == Quests.SkeleReviveQuest: cogIcons = loader.loadModel('phase_3.5/models/gui/stickerbook_gui') lIconGeom = cogIcons.find('**/skelecog5') lIconGeomScale = IMAGE_SCALE_SMALL cogIcons.removeNode() if not fComplete: infoText = quest.getLocationName() if infoText == '': infoText = TTLocalizer.QuestPosterAnywhere if fComplete: self.teleportButton.show() textColor = (0, 0.3, 0, 1) imageColor = Vec4(*self.colors['lightGreen']) lPos.setX(-0.18) rIconGeom = self.createNpcToonHead(toNpcId) rIconGeomScale = IMAGE_SCALE_SMALL captions = captions[:1] captions.append(toNpcName) auxText = TTLocalizer.QuestPosterAuxReturnTo headlineString = TTLocalizer.QuestPosterComplete infoText = TTLocalizer.QuestPageDestination % (toNpcBuildingName, toNpcStreetName, toNpcLocationName) if self.laffMeter is not None: self.laffMeter.reparentTo(hidden) self.laffMeter.destroy() self.laffMeter = None else: textColor = self.normalTextColor self.show() self['image_color'] = imageColor self.headline['text_fg'] = textColor self.headline['text'] = headlineString if quest.getType() != Quests.TrackChoiceQuest: self.lPictureFrame.show() self.lPictureFrame.setPos(lPos) self.lPictureFrame['text_scale'] = TEXT_SCALE if lPos[0] != 0: self.lPictureFrame['text_scale'] = 0.0325 self.lPictureFrame['text'] = captions[0] self.lPictureFrame['image_color'] = Vec4(*self.colors[frameBgColor]) else: self.lPictureFrame['text'] = 'Track Choice' self.lPictureFrame['image_color'] = Vec4(*self.colors[frameBgColor]) if len(captions) > 1 and quest.getType() != Quests.TrackChoiceQuest: self.rPictureFrame['text'] = captions[1] self.rPictureFrame['text_scale'] = 0.0325 self.rPictureFrame['image_color'] = Vec4(*self.colors[frameBgColor]) else: self.rPictureFrame.hide() self._deleteGeoms() self.lQuestIcon['geom'] = lIconGeom self.lQuestIcon['geom_pos'] = (0, 10, 0) if lIconGeom: try: self.lQuestIcon['geom_scale'] = lIconGeomScale except: pass try: self.lQuestIcon['geom_pos'] = Point3(lIconGeomPos[0], lIconGeomPos[1], lIconGeomPos[2]) except: pass try: self.lQuestIcon['geom_hpr'] = Point3(lIconGeomHpr[0], lIconGeomHpr[1], lIconGeomHpr[2]) except: pass if self.laffMeter != None: self.laffMeter.reparentTo(self.lQuestIcon) self.rQuestIcon['geom'] = rIconGeom self.rQuestIcon['geom_pos'] = (0, 10, 0) if rIconGeom: self.rQuestIcon['geom_scale'] = rIconGeomScale if auxText: self.auxText.show() self.auxText['text'] = auxText self.auxText.setPos(auxTextPos) else: self.auxText.hide() self.bind(DGG.WITHIN, self.mouseEnterPoster) self.bind(DGG.WITHOUT, self.mouseExitPoster) numQuestItems = quest.getNumQuestItems() if fComplete or numQuestItems <= 1: self.questProgress.hide() if not quest.getType() == Quests.TrackChoiceQuest: infoZ = -0.075 else: self.questProgress.show() self.questProgress['value'] = toonProgress & pow(2, 16) - 1 self.questProgress['range'] = numQuestItems self.questProgress['text'] = quest.getProgressString(base.localAvatar, questDesc) self.questInfo['text'] = infoText self.questInfo.setZ(infoZ) self.fitLabel(self.questInfo) if not Quests.QuestDict[questId][0] >= 11: self.teleportButton.hide() return
def update(self, questDesc): (questId, fromNpcId, toNpcId, rewardId, toonProgress) = questDesc quest = Quests.getQuest(questId) if rewardId == Quests.NA: finalReward = Quests.getFinalRewardId(questId, fAll = 1) transformedReward = Quests.transformReward(finalReward, toonbase.localToon) reward = Quests.getReward(transformedReward) else: reward = Quests.getReward(rewardId) if reward: rewardString = reward.getPosterString() else: rewardString = '' self.rewardText['text'] = rewardString self.fitLabel(self.rewardText) questEntry = Quests.QuestDict.get(questId) if questEntry: tier = questEntry[0] fOptional = Quests.isRewardOptional(tier, rewardId) else: fOptional = 0 if fOptional: self.funQuest.show() else: self.funQuest.hide() fComplete = quest.getCompletionStatus(toonbase.localToon, questDesc) == Quests.COMPLETE fromNpcName = NPCToons.getNPCName(fromNpcId) npcZone = NPCToons.getNPCZone(fromNpcId) hoodId = ZoneUtil.getHoodId(npcZone) branchId = ZoneUtil.getBranchZone(npcZone) if fromNpcId == Quests.ToonHQ: locationName = Localizer.QuestPosterHQLocationName buildingName = Localizer.QuestPosterHQBuildingName streetName = Localizer.QuestPosterHQStreetName elif fromNpcId == Quests.ToonTailor: locationName = Localizer.QuestPosterTailorLocationName buildingName = Localizer.QuestPosterTailorBuildingName streetName = Localizer.QuestPosterTailorStreetName else: locationName = toonbase.tcr.hoodMgr.getFullnameFromId(hoodId) buildingName = NPCToons.getBuildingTitle(npcZone) streetName = ZoneUtil.getStreetName(branchId) if toNpcId == Quests.ToonHQ: toNpcName = Localizer.QuestPosterHQOfficer toNpcBuildingName = Localizer.QuestPosterHQBuildingName toNpcStreetName = Localizer.QuestPosterHQStreetName toNpcLocationName = Localizer.QuestPosterHQLocationName elif toNpcId == Quests.ToonTailor: toNpcName = Localizer.QuestPosterTailor toNpcBuildingName = Localizer.QuestPosterTailorBuildingName toNpcStreetName = Localizer.QuestPosterTailorStreetName toNpcLocationName = Localizer.QuestPosterTailorLocationName else: toNpcName = NPCToons.getNPCName(toNpcId) toNpcZone = NPCToons.getNPCZone(toNpcId) toNpcHoodId = ZoneUtil.getHoodId(toNpcZone) toNpcLocationName = toonbase.tcr.hoodMgr.getFullnameFromId(toNpcHoodId) toNpcBuildingName = NPCToons.getBuildingTitle(toNpcZone) toNpcBranchId = ZoneUtil.getBranchZone(toNpcZone) toNpcStreetName = ZoneUtil.getStreetName(toNpcBranchId) lPos = Vec3(0, 0, 0.13) lIconGeom = None lIconGeomScale = 1 rIconGeom = None rIconGeomScale = 1 infoText = '' infoZ = -0.0625 auxText = None auxTextPos = Vec3(0, 0, 0.12) headlineString = quest.getHeadlineString() captions = map(string.capwords, quest.getObjectiveStrings()) imageColor = Vec4(*self.colors['white']) if quest.getType() == Quests.DeliverGagQuest or quest.getType() == Quests.DeliverItemQuest: frameBgColor = 'red' if quest.getType() == Quests.DeliverGagQuest: invModel = loader.loadModelOnce('phase_3.5/models/gui/inventory_icons') (track, item) = quest.getGagType() lIconGeom = invModel.find('**/' + AvPropsNew[track][item]) invModel.removeNode() else: bookModel = loader.loadModelOnce('phase_3.5/models/gui/stickerbook_gui') lIconGeom = bookModel.find('**/package') lIconGeomScale = 0.12 bookModel.removeNode() if not fComplete: captions.append(toNpcName) auxText = Localizer.QuestPosterAuxTo auxTextPos.setZ(0.12) lPos.setX(-0.17999999999999999) infoText = Localizer.QuestPageDestination % (toNpcBuildingName, toNpcStreetName, toNpcLocationName) rIconGeom = self.createNpcToonHead(toNpcId) rIconGeomScale = IMAGE_SCALE_SMALL elif quest.getType() == Quests.RecoverItemQuest: frameBgColor = 'green' bookModel = loader.loadModelOnce('phase_3.5/models/gui/stickerbook_gui') lIconGeom = bookModel.find('**/package') lIconGeomScale = 0.12 bookModel.removeNode() if not fComplete: rIconGeomScale = IMAGE_SCALE_SMALL holder = quest.getHolder() holderType = quest.getHolderType() if holder == Quests.Any: cogIcons = loader.loadModelOnce('phase_3/models/gui/cog_icons') rIconGeom = cogIcons.find('**/cog') cogIcons.removeNode() lPos.setX(-0.17999999999999999) auxText = Localizer.QuestPosterAuxFrom elif holder == Quests.AnyFish: headlineString = 'GO FISHING' auxText = Localizer.QuestPosterAuxFor auxTextPos.setX(-0.17999999999999999) captions = captions[:1] elif holderType == 'track': cogIcons = loader.loadModelOnce('phase_3/models/gui/cog_icons') if holder == 'c': icon = cogIcons.find('**/CorpIcon') elif holder == 's': icon = cogIcons.find('**/SalesIcon') elif holder == 'l': icon = cogIcons.find('**/LegalIcon') elif holder == 'm': icon = cogIcons.find('**/MoneyIcon') rIconGeom = icon.copyTo(hidden) rIconGeom.setColor(Suit.Suit.medallionColors[holder]) rIconGeomScale = 0.12 cogIcons.removeNode() elif holderType == 'level': cogIcons = loader.loadModelOnce('phase_3/models/gui/cog_icons') rIconGeom = cogIcons.find('**/cog') rIconGeomScale = IMAGE_SCALE_SMALL cogIcons.removeNode() else: rIconGeom = self.createSuitHead(holder) lPos.setX(-0.17999999999999999) auxText = Localizer.QuestPosterAuxFrom infoText = string.capwords(quest.getLocationName()) if infoText == '': infoText = Localizer.QuestPosterAnywhere elif quest.getType() == Quests.VisitQuest: frameBgColor = 'brown' captions[0] = '%s' % toNpcName lIconGeom = self.createNpcToonHead(toNpcId) lIconGeomScale = IMAGE_SCALE_SMALL if not fComplete: infoText = Localizer.QuestPageDestination % (toNpcBuildingName, toNpcStreetName, toNpcLocationName) elif quest.getType() == Quests.TrackChoiceQuest: frameBgColor = 'green' invModel = loader.loadModelOnce('phase_3.5/models/gui/inventory_icons') (track1, track2) = quest.getChoices() lIconGeom = invModel.find('**/' + AvPropsNew[track1][1]) if not fComplete: auxText = Localizer.QuestPosterAuxOr lPos.setX(-0.17999999999999999) rIconGeom = invModel.find('**/' + AvPropsNew[track2][1]) infoText = Localizer.QuestPageNameAndDestination % (toNpcName, toNpcBuildingName, toNpcStreetName, toNpcLocationName) infoZ = -0.02 invModel.removeNode() elif quest.getType() == Quests.BuildingQuest: frameBgColor = 'blue' track = quest.getBuildingTrack() numFloors = quest.getNumFloors() if track == 'c': lIconGeom = loader.loadModelCopy('phase_5/models/modules/suit_landmark_corp') elif track == 'l': lIconGeom = loader.loadModelCopy('phase_5/models/modules/suit_landmark_legal') elif track == 'm': lIconGeom = loader.loadModelCopy('phase_5/models/modules/suit_landmark_money') elif track == 's': lIconGeom = loader.loadModelCopy('phase_5/models/modules/suit_landmark_sales') else: bookModel = loader.loadModelCopy('phase_3.5/models/gui/stickerbook_gui') lIconGeom = bookModel.find('**/COG_building') bookModel.removeNode() if lIconGeom and track != Quests.Any: self.loadElevator(lIconGeom, numFloors) self.fitGeometry(lIconGeom, fFlip = 1) lIconGeomScale = IMAGE_SCALE_SMALL else: lIconGeomScale = 0.13 if not fComplete: infoText = quest.getLocationName() if infoText == '': infoText = Localizer.QuestPosterAnywhere elif quest.getType() == Quests.BuildingNewbieQuest: frameBgColor = 'blue' track = quest.getBuildingTrack() numFloors = quest.getNumFloors() if track == 'c': rIconGeom = loader.loadModelCopy('phase_5/models/modules/suit_landmark_corp') elif track == 'l': rIconGeom = loader.loadModelCopy('phase_5/models/modules/suit_landmark_legal') elif track == 'm': rIconGeom = loader.loadModelCopy('phase_5/models/modules/suit_landmark_money') elif track == 's': rIconGeom = loader.loadModelCopy('phase_5/models/modules/suit_landmark_sales') else: bookModel = loader.loadModelCopy('phase_3.5/models/gui/stickerbook_gui') rIconGeom = bookModel.find('**/COG_building') bookModel.removeNode() if rIconGeom and track != Quests.Any: self.loadElevator(rIconGeom, numFloors) self.fitGeometry(rIconGeom, fFlip = 1) rIconGeomScale = IMAGE_SCALE_SMALL else: rIconGeomScale = 0.13 if not fComplete: headlineString = Localizer.QuestsNewbieQuestHeadline captions = [ Localizer.QuestsCogNewbieQuestCaption % quest.getNewbieLevel()] captions.append(map(string.capwords, quest.getObjectiveStrings())) auxText = Localizer.QuestsCogNewbieQuestAux lPos.setX(-0.17999999999999999) self.laffMeter = self.createLaffMeter(quest.getNewbieLevel()) self.laffMeter.setScale(0.040000000000000001) lIconGeom = None infoText = quest.getLocationName() if infoText == '': infoText = Localizer.QuestPosterAnywhere else: lIconGeom = rIconGeom lIconGeomScale = rIconGeomScale elif quest.getType() == Quests.FriendQuest: frameBgColor = 'brown' gui = loader.loadModelOnce('phase_3.5/models/gui/friendslist_gui') lIconGeom = gui.find('**/FriendsBox_Closed') lIconGeomScale = 0.45000000000000001 gui.removeNode() infoText = Localizer.QuestPosterAnywhere elif quest.getType() == Quests.FriendNewbieQuest: frameBgColor = 'brown' gui = loader.loadModelOnce('phase_3.5/models/gui/friendslist_gui') lIconGeom = gui.find('**/FriendsBox_Closed') lIconGeomScale = 0.45000000000000001 gui.removeNode() infoText = Localizer.QuestPosterAnywhere elif quest.getType() == Quests.TrolleyQuest: frameBgColor = 'lightBlue' gui = loader.loadModelOnce('phase_3.5/models/gui/stickerbook_gui') lIconGeom = gui.find('**/trolley') lIconGeomScale = 0.13 gui.removeNode() infoText = Localizer.QuestPosterPlayground elif quest.getType() == Quests.MinigameNewbieQuest: frameBgColor = 'lightBlue' gui = loader.loadModelOnce('phase_3.5/models/gui/stickerbook_gui') rIconGeom = gui.find('**/trolley') rIconGeomScale = 0.13 gui.removeNode() infoText = Localizer.QuestPosterPlayground if not fComplete: captions = [ Localizer.QuestsMinigameNewbieQuestCaption % quest.getNewbieLevel()] captions.append(map(string.capwords, quest.getObjectiveStrings())) auxText = Localizer.QuestsMinigameNewbieQuestAux lPos.setX(-0.17999999999999999) self.laffMeter = self.createLaffMeter(quest.getNewbieLevel()) self.laffMeter.setScale(0.040000000000000001) lIconGeom = None else: lIconGeom = rIconGeom lIconGeomScale = rIconGeomScale else: frameBgColor = 'blue' if quest.getType() == Quests.CogTrackQuest: dept = quest.getCogTrack() cogIcons = loader.loadModelOnce('phase_3/models/gui/cog_icons') lIconGeomScale = 0.13 if dept == 'c': icon = cogIcons.find('**/CorpIcon') elif dept == 's': icon = cogIcons.find('**/SalesIcon') elif dept == 'l': icon = cogIcons.find('**/LegalIcon') elif dept == 'm': icon = cogIcons.find('**/MoneyIcon') lIconGeom = icon.copyTo(hidden) lIconGeom.setColor(Suit.Suit.medallionColors[dept]) cogIcons.removeNode() elif quest.getType() == Quests.CogQuest: if quest.getCogType() != Quests.Any: lIconGeom = self.createSuitHead(quest.getCogType()) lIconGeomScale = IMAGE_SCALE_SMALL else: cogIcons = loader.loadModelOnce('phase_3/models/gui/cog_icons') lIconGeom = cogIcons.find('**/cog') lIconGeomScale = IMAGE_SCALE_SMALL cogIcons.removeNode() elif quest.getType() == Quests.CogLevelQuest: cogIcons = loader.loadModelOnce('phase_3/models/gui/cog_icons') lIconGeom = cogIcons.find('**/cog') lIconGeomScale = IMAGE_SCALE_SMALL cogIcons.removeNode() elif quest.getType() == Quests.CogNewbieQuest: if quest.getCogType() != Quests.Any: rIconGeom = self.createSuitHead(quest.getCogType()) rIconGeomScale = IMAGE_SCALE_SMALL else: cogIcons = loader.loadModelOnce('phase_3/models/gui/cog_icons') rIconGeom = cogIcons.find('**/cog') rIconGeomScale = IMAGE_SCALE_SMALL cogIcons.removeNode() if not fComplete: headlineString = Localizer.QuestsNewbieQuestHeadline captions = [ Localizer.QuestsCogNewbieQuestCaption % quest.getNewbieLevel()] captions.append(map(string.capwords, quest.getObjectiveStrings())) auxText = Localizer.QuestsCogNewbieQuestAux lPos.setX(-0.17999999999999999) self.laffMeter = self.createLaffMeter(quest.getNewbieLevel()) self.laffMeter.setScale(0.040000000000000001) lIconGeom = None else: lIconGeom = rIconGeom lIconGeomScale = rIconGeomScale if not fComplete: infoText = string.capwords(quest.getLocationName()) if infoText == '': infoText = Localizer.QuestPosterAnywhere if fComplete: textColor = (0, 0.29999999999999999, 0, 1) imageColor = Vec4(*self.colors['lightGreen']) lPos.setX(-0.17999999999999999) rIconGeom = self.createNpcToonHead(toNpcId) rIconGeomScale = IMAGE_SCALE_SMALL captions = captions[:1] captions.append(toNpcName) auxText = Localizer.QuestPosterAuxReturnTo headlineString = 'COMPLETE' infoText = Localizer.QuestPageDestination % (toNpcBuildingName, toNpcStreetName, toNpcLocationName) if self.laffMeter != None: self.laffMeter.reparentTo(hidden) self.laffMeter.destroy() self.laffMeter = None else: textColor = self.normalTextColor self.show() self['image_color'] = imageColor self.headline['text_fg'] = textColor self.headline['text'] = headlineString self.lPictureFrame.show() self.lPictureFrame.setPos(lPos) self.lPictureFrame['text'] = captions[0] self.lPictureFrame['image_color'] = Vec4(*self.colors[frameBgColor]) if len(captions) > 1: self.rPictureFrame.show() self.rPictureFrame['text'] = captions[1] self.rPictureFrame['image_color'] = Vec4(*self.colors[frameBgColor]) else: self.rPictureFrame.hide() self.lQuestIcon['geom'] = lIconGeom self.lQuestIcon['geom_pos'] = (0, 10, 0) if lIconGeom: self.lQuestIcon['geom_scale'] = lIconGeomScale if self.laffMeter != None: self.laffMeter.reparentTo(self.lQuestIcon) self.rQuestIcon['geom'] = rIconGeom self.rQuestIcon['geom_pos'] = (0, 10, 0) if rIconGeom: self.rQuestIcon['geom_scale'] = rIconGeomScale self.questInfo['text'] = infoText self.questInfo.setZ(infoZ) self.fitLabel(self.questInfo) if auxText: self.auxText.show() self.auxText['text'] = auxText self.auxText.setPos(auxTextPos) else: self.auxText.hide() self.bind(WITHIN, self.mouseEnterPoster) self.bind(WITHOUT, self.mouseExitPoster) numQuestItems = quest.getNumQuestItems() if fComplete or numQuestItems <= 1: self.questProgress.hide() else: self.questProgress.show() self.questProgress['value'] = toonProgress self.questProgress['range'] = numQuestItems self.questProgress['text'] = quest.getProgressString(toonbase.localToon, questDesc)
def requestInteract(self, toonId, npc): toon = self.air.doId2do.get(toonId) if not toon: # TODO: Flag suspicious. They shouldn't have got this far. return # Check if the toon has any quests to turn in. for index, quest in enumerate(self.__toonQuestsList2Quests(toon.quests)): questId, fromNpcId, toNpcId, rewardId, toonProgress = toon.quests[index] isComplete = quest.getCompletionStatus(toon, toon.quests[index], npc) if isComplete != Quests.COMPLETE: # This quest isn't complete, skip. continue # If we're in the Toontorial, move to the next step. if toonId in self.air.tutorialManager.avId2fsm.keys(): self.air.tutorialManager.avId2fsm[toonId].demand('Tunnel') # Take away gags if it's a DeliverGagQuest. if isinstance(quest, Quests.DeliverGagQuest): track, level = quest.getGagType() toon.inventory.setItem(track, level, toon.inventory.numItem(track, level) - quest.getNumGags()) toon.b_setInventory(toon.inventory.makeNetString()) # Check if the ToonTask has more quests to complete. nextQuest = Quests.getNextQuest(questId, npc, toon) if nextQuest == (Quests.NA, Quests.NA): # No more quests in the current ToonTask! if isinstance(quest, Quests.TrackChoiceQuest): # TrackTrainingRewards are a little different, as we now # have to display the gag track selection menu. npc.presentTrackChoice(toonId, questId, quest.getChoices()) return # This function is pretty weird... not sure why it's even here... # But I'll include it just in case... (TMS says: "idk about this # one, maybe a single quest can have different rewards?") rewardId = Quests.getAvatarRewardId(toon, questId) npc.completeQuest(toonId, questId, rewardId) self.completeQuest(toon, questId) self.giveReward(toon, rewardId) return else: # We have another quest to go, sigh. self.completeQuest(toon, questId) nextQuestId = nextQuest[0] nextRewardId = Quests.getFinalRewardId(questId, 1) nextToNpcId = nextQuest[1] self.npcGiveQuest(npc, toon, nextQuestId, nextRewardId, nextToNpcId) return # We had no quests to hand in, maybe they want to take out a new ToonTask? if len(self.__toonQuestsList2Quests(toon.quests)) >= toon.getQuestCarryLimit(): # Nope, they already have the maximum amount of concurring quests they # can carry. Reject them. self.notify.debug("Rejecting toonId %d because their quest inventory is full." % toonId) npc.rejectAvatar(toonId) return # Are we in the Toontorial? if toonId in self.air.tutorialManager.avId2fsm.keys(): # Are we speaking to Tom? if toon.getRewardHistory()[0] == 0: self.npcGiveQuest(npc, toon, 101, Quests.findFinalRewardId(101)[0], Quests.getQuestToNpcId(101), storeReward=True) # FIXME please, i have no idea if this is correct self.air.tutorialManager.avId2fsm[toonId].demand('Battle') return # Are they eligible for a tier upgrade? tier = toon.getRewardHistory()[0] if Quests.avatarHasAllRequiredRewards(toon, tier): # They have all the rewards needed for the next tier. if not Quests.avatarWorkingOnRequiredRewards(toon): # Check to make sure they are not on the LOOPING_FINAL_TIER if tier != Quests.LOOPING_FINAL_TIER: tier += 1 # Set the tier toon.b_setRewardHistory(tier, []) else: # They're eligible for a tier upgrade, but haven't finished all # of their required ToonTasks yet. self.notify.debug("Rejecting toonId %d because they are still working on their current tier." % toonId) npc.rejectAvatarTierNotDone(toonId) return # Time to give them a list of "suitable" tasks! suitableQuests = Quests.chooseBestQuests(tier, npc, toon) if not suitableQuests: # Uh oh! There's no suitable quests for them at the moment... reject. self.notify.debug("Rejecting toonId %d because there are no quests available!" % toonId) npc.rejectAvatar(toonId) return # Tell the NPC to select some quests from the generated list. npc.presentQuestChoice(toonId, suitableQuests) return
def __toonQuestsList2Quests(self, quests): return [Quests.getQuest(x[0]) for x in quests]
def update(self, questDesc): questId, fromNpcId, toNpcId, rewardId, toonProgress = questDesc quest = Quests.getQuest(questId) if quest == None: self.notify.warning("Tried to display poster for unknown quest %s" % questId) return if rewardId == Quests.NA: finalReward = Quests.getFinalRewardId(questId, fAll=1) transformedReward = Quests.transformReward(finalReward, base.localAvatar) reward = Quests.getReward(transformedReward) else: reward = Quests.getReward(rewardId) if reward and questId not in Quests.NoRewardTierZeroQuests: rewardString = reward.getPosterString() else: rewardString = "" self.rewardText["text"] = rewardString self.fitLabel(self.rewardText) if Quests.isQuestJustForFun(questId, rewardId): self.funQuest.show() else: self.funQuest.hide() if self._deleteCallback: self.showDeleteButton(questDesc) else: self.hideDeleteButton() fComplete = quest.getCompletionStatus(base.localAvatar, questDesc) == Quests.COMPLETE if toNpcId == Quests.ToonHQ: toNpcName = TTLocalizer.QuestPosterHQOfficer toNpcBuildingName = TTLocalizer.QuestPosterHQBuildingName toNpcStreetName = TTLocalizer.QuestPosterHQStreetName toNpcLocationName = TTLocalizer.QuestPosterHQLocationName elif toNpcId == Quests.ToonTailor: toNpcName = TTLocalizer.QuestPosterTailor toNpcBuildingName = TTLocalizer.QuestPosterTailorBuildingName toNpcStreetName = TTLocalizer.QuestPosterTailorStreetName toNpcLocationName = TTLocalizer.QuestPosterTailorLocationName else: toNpcName = NPCToons.getNPCName(toNpcId) toNpcZone = NPCToons.getNPCZone(toNpcId) toNpcHoodId = ZoneUtil.getCanonicalHoodId(toNpcZone) toNpcLocationName = base.cr.hoodMgr.getFullnameFromId(toNpcHoodId) toNpcBuildingName = NPCToons.getBuildingTitle(toNpcZone) toNpcBranchId = ZoneUtil.getBranchZone(toNpcZone) toNpcStreetName = ZoneUtil.getStreetName(toNpcBranchId) lPos = Vec3(0, 0, 0.13) lIconGeom = None lIconGeomScale = 1 rIconGeom = None rIconGeomScale = 1 infoText = "" infoZ = TTLocalizer.QPinfoZ auxText = None auxTextPos = Vec3(0, 0, 0.12) headlineString = quest.getHeadlineString() objectiveStrings = quest.getObjectiveStrings() captions = map(string.capwords, quest.getObjectiveStrings()) imageColor = Vec4(*self.colors["white"]) if quest.getType() == Quests.DeliverGagQuest or quest.getType() == Quests.DeliverItemQuest: frameBgColor = "red" if quest.getType() == Quests.DeliverGagQuest: invModel = loader.loadModel("phase_3.5/models/gui/inventory_icons") track, item = quest.getGagType() lIconGeom = invModel.find("**/" + AvPropsNew[track][item]) invModel.removeNode() else: bookModel = loader.loadModel("phase_3.5/models/gui/stickerbook_gui") lIconGeom = bookModel.find("**/package") lIconGeomScale = 0.12 bookModel.removeNode() if not fComplete: captions.append(toNpcName) auxText = TTLocalizer.QuestPosterAuxTo auxTextPos.setZ(0.12) lPos.setX(-0.18) infoText = TTLocalizer.QuestPageDestination % (toNpcBuildingName, toNpcStreetName, toNpcLocationName) rIconGeom = self.createNpcToonHead(toNpcId) rIconGeomScale = IMAGE_SCALE_SMALL elif quest.getType() == Quests.RecoverItemQuest: frameBgColor = "green" bookModel = loader.loadModel("phase_3.5/models/gui/stickerbook_gui") lIconGeom = bookModel.find("**/package") lIconGeomScale = 0.12 bookModel.removeNode() if not fComplete: rIconGeomScale = IMAGE_SCALE_SMALL holder = quest.getHolder() holderType = quest.getHolderType() if holder == Quests.Any: cogIcons = loader.loadModel("phase_3/models/gui/cog_icons") rIconGeom = cogIcons.find("**/cog") cogIcons.removeNode() lPos.setX(-0.18) auxText = TTLocalizer.QuestPosterAuxFrom elif holder == Quests.AnyFish: headlineString = TTLocalizer.QuestPosterFishing auxText = TTLocalizer.QuestPosterAuxFor auxTextPos.setX(-0.18) captions = captions[:1] else: if holderType == "track": cogIcons = loader.loadModel("phase_3/models/gui/cog_icons") if holder == "c": icon = cogIcons.find("**/CorpIcon") elif holder == "s": icon = cogIcons.find("**/SalesIcon") elif holder == "l": icon = cogIcons.find("**/LegalIcon") elif holder == "m": icon = cogIcons.find("**/MoneyIcon") rIconGeom = icon.copyTo(hidden) rIconGeom.setColor(Suit.Suit.medallionColors[holder]) rIconGeomScale = 0.12 cogIcons.removeNode() elif holderType == "level": cogIcons = loader.loadModel("phase_3/models/gui/cog_icons") rIconGeom = cogIcons.find("**/cog") rIconGeomScale = IMAGE_SCALE_SMALL cogIcons.removeNode() else: rIconGeom = self.createSuitHead(holder) lPos.setX(-0.18) auxText = TTLocalizer.QuestPosterAuxFrom infoText = string.capwords(quest.getLocationName()) if infoText == "": infoText = TTLocalizer.QuestPosterAnywhere elif quest.getType() == Quests.VisitQuest: frameBgColor = "brown" captions[0] = "%s" % toNpcName lIconGeom = self.createNpcToonHead(toNpcId) lIconGeomScale = IMAGE_SCALE_SMALL if not fComplete: infoText = TTLocalizer.QuestPageDestination % (toNpcBuildingName, toNpcStreetName, toNpcLocationName) elif quest.getType() == Quests.TrackChoiceQuest: frameBgColor = "green" invModel = loader.loadModel("phase_3.5/models/gui/inventory_icons") track1, track2 = quest.getChoices() lIconGeom = invModel.find("**/" + AvPropsNew[track1][1]) if not fComplete: auxText = TTLocalizer.QuestPosterAuxOr lPos.setX(-0.18) rIconGeom = invModel.find("**/" + AvPropsNew[track2][1]) infoText = TTLocalizer.QuestPageNameAndDestination % ( toNpcName, toNpcBuildingName, toNpcStreetName, toNpcLocationName, ) infoZ = -0.02 invModel.removeNode() elif quest.getType() == Quests.BuildingQuest: frameBgColor = "blue" track = quest.getBuildingTrack() numFloors = quest.getNumFloors() if track == "c": lIconGeom = loader.loadModel("phase_4/models/modules/suit_landmark_corp") elif track == "l": lIconGeom = loader.loadModel("phase_4/models/modules/suit_landmark_legal") elif track == "m": lIconGeom = loader.loadModel("phase_4/models/modules/suit_landmark_money") elif track == "s": lIconGeom = loader.loadModel("phase_4/models/modules/suit_landmark_sales") else: bookModel = loader.loadModel("phase_3.5/models/gui/stickerbook_gui") lIconGeom = bookModel.find("**/COG_building") bookModel.removeNode() if lIconGeom and track != Quests.Any: self.loadElevator(lIconGeom, numFloors) lIconGeom.setH(180) self.fitGeometry(lIconGeom, fFlip=0) lIconGeomScale = IMAGE_SCALE_SMALL else: lIconGeomScale = 0.13 if not fComplete: infoText = quest.getLocationName() if infoText == "": infoText = TTLocalizer.QuestPosterAnywhere elif quest.getType() == Quests.BuildingNewbieQuest: frameBgColor = "blue" track = quest.getBuildingTrack() numFloors = quest.getNumFloors() if track == "c": rIconGeom = loader.loadModel("phase_4/models/modules/suit_landmark_corp") elif track == "l": rIconGeom = loader.loadModel("phase_4/models/modules/suit_landmark_legal") elif track == "m": rIconGeom = loader.loadModel("phase_4/models/modules/suit_landmark_money") elif track == "s": rIconGeom = loader.loadModel("phase_4/models/modules/suit_landmark_sales") else: bookModel = loader.loadModel("phase_3.5/models/gui/stickerbook_gui") rIconGeom = bookModel.find("**/COG_building") bookModel.removeNode() if rIconGeom and track != Quests.Any: self.loadElevator(rIconGeom, numFloors) rIconGeom.setH(180) self.fitGeometry(rIconGeom, fFlip=0) rIconGeomScale = IMAGE_SCALE_SMALL else: rIconGeomScale = 0.13 if not fComplete: headlineString = TTLocalizer.QuestsNewbieQuestHeadline captions = [quest.getCaption()] captions.append(map(string.capwords, quest.getObjectiveStrings())) auxText = TTLocalizer.QuestsCogNewbieQuestAux lPos.setX(-0.18) self.laffMeter = self.createLaffMeter(quest.getNewbieLevel()) self.laffMeter.setScale(0.04) lIconGeom = None infoText = quest.getLocationName() if infoText == "": infoText = TTLocalizer.QuestPosterAnywhere else: lIconGeom = rIconGeom rIconGeom = None lIconGeomScale = rIconGeomScale rIconGeomScale = 1 elif quest.getType() == Quests.FactoryQuest: frameBgColor = "blue" bookModel = loader.loadModel("phase_3.5/models/gui/stickerbook_gui") lIconGeom = bookModel.find("**/factoryIcon2") bookModel.removeNode() lIconGeomScale = 0.13 if not fComplete: infoText = quest.getLocationName() if infoText == "": infoText = TTLocalizer.QuestPosterAnywhere elif quest.getType() == Quests.FactoryNewbieQuest: frameBgColor = "blue" bookModel = loader.loadModel("phase_3.5/models/gui/stickerbook_gui") rIconGeom = bookModel.find("**/factoryIcon2") bookModel.removeNode() rIconGeomScale = 0.13 if not fComplete: headlineString = TTLocalizer.QuestsNewbieQuestHeadline captions = [quest.getCaption()] captions.append(map(string.capwords, quest.getObjectiveStrings())) auxText = TTLocalizer.QuestsCogNewbieQuestAux lPos.setX(-0.18) self.laffMeter = self.createLaffMeter(quest.getNewbieLevel()) self.laffMeter.setScale(0.04) lIconGeom = None infoText = quest.getLocationName() if infoText == "": infoText = TTLocalizer.QuestPosterAnywhere else: lIconGeom = rIconGeom rIconGeom = None lIconGeomScale = rIconGeomScale rIconGeomScale = 1 elif quest.getType() == Quests.MintQuest: frameBgColor = "blue" bookModel = loader.loadModel("phase_3.5/models/gui/stickerbook_gui") lIconGeom = bookModel.find("**/CashBotMint") bookModel.removeNode() lIconGeomScale = 0.13 if not fComplete: infoText = quest.getLocationName() if infoText == "": infoText = TTLocalizer.QuestPosterAnywhere elif quest.getType() == Quests.MintNewbieQuest: frameBgColor = "blue" bookModel = loader.loadModel("phase_3.5/models/gui/stickerbook_gui") rIconGeom = bookModel.find("**/CashBotMint") bookModel.removeNode() rIconGeomScale = 0.13 if not fComplete: headlineString = TTLocalizer.QuestsNewbieQuestHeadline captions = [quest.getCaption()] captions.append(map(string.capwords, quest.getObjectiveStrings())) auxText = TTLocalizer.QuestsCogNewbieQuestAux lPos.setX(-0.18) self.laffMeter = self.createLaffMeter(quest.getNewbieLevel()) self.laffMeter.setScale(0.04) lIconGeom = None infoText = quest.getLocationName() if infoText == "": infoText = TTLocalizer.QuestPosterAnywhere else: lIconGeom = rIconGeom rIconGeom = None lIconGeomScale = rIconGeomScale rIconGeomScale = 1 elif quest.getType() == Quests.CogPartQuest: frameBgColor = "green" bookModel = loader.loadModel("phase_3.5/models/gui/stickerbook_gui") lIconGeom = bookModel.find("**/CogArmIcon2") bookModel.removeNode() lIconGeomScale = 0.13 if not fComplete: infoText = quest.getLocationName() if infoText == "": infoText = TTLocalizer.QuestPosterAnywhere elif quest.getType() == Quests.CogPartNewbieQuest: frameBgColor = "green" bookModel = loader.loadModel("phase_3.5/models/gui/stickerbook_gui") rIconGeom = bookModel.find("**/CogArmIcon2") bookModel.removeNode() rIconGeomScale = 0.13 if not fComplete: headlineString = TTLocalizer.QuestsNewbieQuestHeadline captions = [quest.getCaption()] captions.append(map(string.capwords, quest.getObjectiveStrings())) auxText = TTLocalizer.QuestsCogPartQuestAux lPos.setX(-0.18) self.laffMeter = self.createLaffMeter(quest.getNewbieLevel()) self.laffMeter.setScale(0.04) lIconGeom = None infoText = quest.getLocationName() if infoText == "": infoText = TTLocalizer.QuestPosterAnywhere else: lIconGeom = rIconGeom rIconGeom = None lIconGeomScale = rIconGeomScale rIconGeomScale = 1 elif quest.getType() == Quests.ForemanQuest or quest.getType() == Quests.SupervisorQuest: frameBgColor = "blue" bookModel = loader.loadModel("phase_3.5/models/gui/stickerbook_gui") lIconGeom = bookModel.find("**/skelecog5") bookModel.removeNode() lIconGeomScale = 0.13 if not fComplete: infoText = quest.getLocationName() if infoText == "": infoText = TTLocalizer.QuestPosterAnywhere elif quest.getType() == Quests.ForemanNewbieQuest or quest.getType() == Quests.SupervisorNewbieQuest: frameBgColor = "blue" bookModel = loader.loadModel("phase_3.5/models/gui/stickerbook_gui") rIconGeom = bookModel.find("**/skelecog5") bookModel.removeNode() rIconGeomScale = 0.13 if not fComplete: headlineString = TTLocalizer.QuestsNewbieQuestHeadline captions = [quest.getCaption()] captions.append(map(string.capwords, quest.getObjectiveStrings())) auxText = TTLocalizer.QuestsCogNewbieQuestAux lPos.setX(-0.18) self.laffMeter = self.createLaffMeter(quest.getNewbieLevel()) self.laffMeter.setScale(0.04) lIconGeom = None infoText = quest.getLocationName() if infoText == "": infoText = TTLocalizer.QuestPosterAnywhere else: lIconGeom = rIconGeom rIconGeom = None lIconGeomScale = rIconGeomScale rIconGeomScale = 1 elif quest.getType() == Quests.VPQuest: frameBgColor = "blue" bookModel = loader.loadModel("phase_3.5/models/gui/stickerbook_gui") lIconGeom = bookModel.find("**/BossHead3Icon") bookModel.removeNode() lIconGeomScale = 0.13 if not fComplete: infoText = quest.getLocationName() if infoText == "": infoText = TTLocalizer.QuestPosterAnywhere elif quest.getType() == Quests.VPNewbieQuest: frameBgColor = "blue" bookModel = loader.loadModel("phase_3.5/models/gui/stickerbook_gui") rIconGeom = bookModel.find("**/BossHead3Icon") bookModel.removeNode() rIconGeomScale = 0.13 if not fComplete: headlineString = TTLocalizer.QuestsNewbieQuestHeadline captions = [quest.getCaption()] captions.append(map(string.capwords, quest.getObjectiveStrings())) auxText = TTLocalizer.QuestsCogNewbieQuestAux lPos.setX(-0.18) self.laffMeter = self.createLaffMeter(quest.getNewbieLevel()) self.laffMeter.setScale(0.04) lIconGeom = None infoText = quest.getLocationName() if infoText == "": infoText = TTLocalizer.QuestPosterAnywhere else: lIconGeom = rIconGeom rIconGeom = None lIconGeomScale = rIconGeomScale rIconGeomScale = 1 elif quest.getType() == Quests.CFOQuest: frameBgColor = "blue" bookModel = loader.loadModel("phase_3.5/models/gui/stickerbook_gui") lIconGeom = bookModel.find("**/CashBotBossHeadIcon") bookModel.removeNode() lIconGeomScale = 0.13 if not fComplete: infoText = quest.getLocationName() if infoText == "": infoText = TTLocalizer.QuestPosterAnywhere elif quest.getType() == Quests.CFONewbieQuest: frameBgColor = "blue" bookModel = loader.loadModel("phase_3.5/models/gui/stickerbook_gui") rIconGeom = bookModel.find("**/CashBotBossHeadIcon") bookModel.removeNode() rIconGeomScale = 0.13 if not fComplete: headlineString = TTLocalizer.QuestsNewbieQuestHeadline captions = [quest.getCaption()] captions.append(map(string.capwords, quest.getObjectiveStrings())) auxText = TTLocalizer.QuestsCogNewbieQuestAux lPos.setX(-0.18) self.laffMeter = self.createLaffMeter(quest.getNewbieLevel()) self.laffMeter.setScale(0.04) lIconGeom = None infoText = quest.getLocationName() if infoText == "": infoText = TTLocalizer.QuestPosterAnywhere else: lIconGeom = rIconGeom rIconGeom = None lIconGeomScale = rIconGeomScale rIconGeomScale = 1 elif quest.getType() == Quests.RescueQuest: frameBgColor = "blue" lIconGeom = self.createNpcToonHead(2001) lIconGeomScale = 0.13 if not fComplete: infoText = quest.getLocationName() if infoText == "": infoText = TTLocalizer.QuestPosterAnywhere elif quest.getType() == Quests.RescueNewbieQuest: frameBgColor = "blue" rIconGeom = self.createNpcToonHead(2001) rIconGeomScale = 0.13 if not fComplete: headlineString = TTLocalizer.QuestsNewbieQuestHeadline captions = [quest.getCaption()] captions.append(map(string.capwords, quest.getObjectiveStrings())) auxText = TTLocalizer.QuestsRescueQuestAux lPos.setX(-0.18) self.laffMeter = self.createLaffMeter(quest.getNewbieLevel()) self.laffMeter.setScale(0.04) lIconGeom = None infoText = quest.getLocationName() if infoText == "": infoText = TTLocalizer.QuestPosterAnywhere else: lIconGeom = rIconGeom rIconGeom = None lIconGeomScale = rIconGeomScale rIconGeomScale = 1 elif quest.getType() == Quests.FriendQuest: frameBgColor = "brown" gui = loader.loadModel("phase_3.5/models/gui/friendslist_gui") lIconGeom = gui.find("**/FriendsBox_Closed") lIconGeomScale = 0.45 gui.removeNode() infoText = TTLocalizer.QuestPosterAnywhere elif quest.getType() == Quests.FriendNewbieQuest: frameBgColor = "brown" gui = loader.loadModel("phase_3.5/models/gui/friendslist_gui") lIconGeom = gui.find("**/FriendsBox_Closed") lIconGeomScale = 0.45 gui.removeNode() infoText = TTLocalizer.QuestPosterAnywhere elif quest.getType() == Quests.TrolleyQuest: frameBgColor = "lightBlue" gui = loader.loadModel("phase_3.5/models/gui/stickerbook_gui") lIconGeom = gui.find("**/trolley") lIconGeomScale = 0.13 gui.removeNode() infoText = TTLocalizer.QuestPosterPlayground elif quest.getType() == Quests.MailboxQuest: frameBgColor = "lightBlue" bookModel = loader.loadModel("phase_3.5/models/gui/stickerbook_gui") lIconGeom = bookModel.find("**/package") lIconGeomScale = 0.12 bookModel.removeNode() infoText = TTLocalizer.QuestPosterAtHome elif quest.getType() == Quests.PhoneQuest: frameBgColor = "lightBlue" bookModel = loader.loadModel("phase_3.5/models/gui/stickerbook_gui") lIconGeom = bookModel.find("**/clarabelleCow") lIconGeomScale = 0.12 bookModel.removeNode() infoText = TTLocalizer.QuestPosterOnPhone elif quest.getType() == Quests.MinigameNewbieQuest: frameBgColor = "lightBlue" gui = loader.loadModel("phase_3.5/models/gui/stickerbook_gui") rIconGeom = gui.find("**/trolley") rIconGeomScale = 0.13 gui.removeNode() infoText = TTLocalizer.QuestPosterPlayground if not fComplete: captions = [TTLocalizer.QuestsMinigameNewbieQuestCaption % quest.getNewbieLevel()] captions.append(map(string.capwords, quest.getObjectiveStrings())) auxText = TTLocalizer.QuestsMinigameNewbieQuestAux lPos.setX(-0.18) self.laffMeter = self.createLaffMeter(quest.getNewbieLevel()) self.laffMeter.setScale(0.04) lIconGeom = None else: lIconGeom = rIconGeom rIconGeom = None lIconGeomScale = rIconGeomScale rIconGeomScale = 1 else: frameBgColor = "blue" if quest.getType() == Quests.CogTrackQuest: dept = quest.getCogTrack() cogIcons = loader.loadModel("phase_3/models/gui/cog_icons") lIconGeomScale = 0.13 if dept == "c": icon = cogIcons.find("**/CorpIcon") elif dept == "s": icon = cogIcons.find("**/SalesIcon") elif dept == "l": icon = cogIcons.find("**/LegalIcon") elif dept == "m": icon = cogIcons.find("**/MoneyIcon") lIconGeom = icon.copyTo(hidden) lIconGeom.setColor(Suit.Suit.medallionColors[dept]) cogIcons.removeNode() elif quest.getType() == Quests.CogQuest: if quest.getCogType() != Quests.Any: lIconGeom = self.createSuitHead(quest.getCogType()) lIconGeomScale = IMAGE_SCALE_SMALL else: cogIcons = loader.loadModel("phase_3/models/gui/cog_icons") lIconGeom = cogIcons.find("**/cog") lIconGeomScale = IMAGE_SCALE_SMALL cogIcons.removeNode() elif quest.getType() == Quests.CogLevelQuest: cogIcons = loader.loadModel("phase_3/models/gui/cog_icons") lIconGeom = cogIcons.find("**/cog") lIconGeomScale = IMAGE_SCALE_SMALL cogIcons.removeNode() elif quest.getType() == Quests.CogNewbieQuest: if quest.getCogType() != Quests.Any: rIconGeom = self.createSuitHead(quest.getCogType()) rIconGeomScale = IMAGE_SCALE_SMALL else: cogIcons = loader.loadModel("phase_3/models/gui/cog_icons") rIconGeom = cogIcons.find("**/cog") rIconGeomScale = IMAGE_SCALE_SMALL cogIcons.removeNode() if not fComplete: headlineString = TTLocalizer.QuestsNewbieQuestHeadline captions = [quest.getCaption()] captions.append(map(string.capwords, quest.getObjectiveStrings())) auxText = TTLocalizer.QuestsCogNewbieQuestAux lPos.setX(-0.18) self.laffMeter = self.createLaffMeter(quest.getNewbieLevel()) self.laffMeter.setScale(0.04) lIconGeom = None else: lIconGeom = rIconGeom rIconGeom = None lIconGeomScale = rIconGeomScale rIconGeomScale = 1 elif quest.getType() == Quests.SkelecogTrackQuest: dept = quest.getCogTrack() cogIcons = loader.loadModel("phase_3/models/gui/cog_icons") lIconGeomScale = 0.13 if dept == "c": icon = cogIcons.find("**/CorpIcon") elif dept == "s": icon = cogIcons.find("**/SalesIcon") elif dept == "l": icon = cogIcons.find("**/LegalIcon") elif dept == "m": icon = cogIcons.find("**/MoneyIcon") lIconGeom = icon.copyTo(hidden) lIconGeom.setColor(Suit.Suit.medallionColors[dept]) cogIcons.removeNode() elif quest.getType() == Quests.SkelecogQuest: cogIcons = loader.loadModel("phase_3.5/models/gui/stickerbook_gui") lIconGeom = cogIcons.find("**/skelecog5") lIconGeomScale = IMAGE_SCALE_SMALL cogIcons.removeNode() elif quest.getType() == Quests.SkelecogLevelQuest: cogIcons = loader.loadModel("phase_3.5/models/gui/stickerbook_gui") lIconGeom = cogIcons.find("**/skelecog5") lIconGeomScale = IMAGE_SCALE_SMALL cogIcons.removeNode() elif quest.getType() == Quests.SkelecogNewbieQuest: cogIcons = loader.loadModel("phase_3.5/models/gui/stickerbook_gui") rIconGeom = cogIcons.find("**/skelecog5") rIconGeomScale = IMAGE_SCALE_SMALL cogIcons.removeNode() if not fComplete: headlineString = TTLocalizer.QuestsNewbieQuestHeadline captions = [quest.getCaption()] captions.append(map(string.capwords, quest.getObjectiveStrings())) auxText = TTLocalizer.QuestsCogNewbieQuestAux lPos.setX(-0.18) self.laffMeter = self.createLaffMeter(quest.getNewbieLevel()) self.laffMeter.setScale(0.04) lIconGeom = None else: lIconGeom = rIconGeom rIconGeom = None lIconGeomScale = rIconGeomScale rIconGeomScale = 1 elif quest.getType() == Quests.SkeleReviveQuest: cogIcons = loader.loadModel("phase_3.5/models/gui/stickerbook_gui") lIconGeom = cogIcons.find("**/skelecog5") lIconGeomScale = IMAGE_SCALE_SMALL cogIcons.removeNode() if not fComplete: infoText = string.capwords(quest.getLocationName()) if infoText == "": infoText = TTLocalizer.QuestPosterAnywhere if fComplete: textColor = (0, 0.3, 0, 1) imageColor = Vec4(*self.colors["lightGreen"]) lPos.setX(-0.18) rIconGeom = self.createNpcToonHead(toNpcId) rIconGeomScale = IMAGE_SCALE_SMALL captions = captions[:1] captions.append(toNpcName) auxText = TTLocalizer.QuestPosterAuxReturnTo headlineString = TTLocalizer.QuestPosterComplete infoText = TTLocalizer.QuestPageDestination % (toNpcBuildingName, toNpcStreetName, toNpcLocationName) if self.laffMeter != None: self.laffMeter.reparentTo(hidden) self.laffMeter.destroy() self.laffMeter = None else: textColor = self.normalTextColor self.show() self["image_color"] = imageColor self.headline["text_fg"] = textColor self.headline["text"] = headlineString self.lPictureFrame.show() self.lPictureFrame.setPos(lPos) self.lPictureFrame["text_scale"] = TEXT_SCALE if lPos[0] != 0: self.lPictureFrame["text_scale"] = 0.0325 self.lPictureFrame["text"] = captions[0] self.lPictureFrame["image_color"] = Vec4(*self.colors[frameBgColor]) if len(captions) > 1: self.rPictureFrame.show() self.rPictureFrame["text"] = captions[1] self.rPictureFrame["text_scale"] = 0.0325 self.rPictureFrame["image_color"] = Vec4(*self.colors[frameBgColor]) else: self.rPictureFrame.hide() self._deleteGeoms() self.lQuestIcon["geom"] = lIconGeom self.lQuestIcon["geom_pos"] = (0, 10, 0) if lIconGeom: self.lQuestIcon["geom_scale"] = lIconGeomScale if self.laffMeter != None: self.laffMeter.reparentTo(self.lQuestIcon) self.rQuestIcon["geom"] = rIconGeom self.rQuestIcon["geom_pos"] = (0, 10, 0) if rIconGeom: self.rQuestIcon["geom_scale"] = rIconGeomScale if auxText: self.auxText.show() self.auxText["text"] = auxText self.auxText.setPos(auxTextPos) else: self.auxText.hide() self.bind(DGG.WITHIN, self.mouseEnterPoster) self.bind(DGG.WITHOUT, self.mouseExitPoster) numQuestItems = quest.getNumQuestItems() if fComplete or numQuestItems <= 1: self.questProgress.hide() if not quest.getType() == Quests.TrackChoiceQuest: infoZ = -0.075 else: self.questProgress.show() self.questProgress["value"] = toonProgress & pow(2, 16) - 1 self.questProgress["range"] = numQuestItems self.questProgress["text"] = quest.getProgressString(base.localAvatar, questDesc) self.questInfo["text"] = infoText self.questInfo.setZ(infoZ) self.fitLabel(self.questInfo) return