def setMovie(self, mode, npcId, avId, quests, timestamp): timeStamp = ClockDelta.globalClockDelta.localElapsedTime(timestamp) isLocalToon = avId == base.localAvatar.doId if mode == NPCToons.QUEST_MOVIE_CLEAR: self.cleanupMovie() return if mode == NPCToons.QUEST_MOVIE_TIMEOUT: self.cleanupMovie() if isLocalToon: self.freeAvatar() self.setPageNumber(0, -1) self.clearChat() self.startLookAround() self.detectAvatars() return av = base.cr.doId2do.get(avId) if av is None: self.notify.warning('Avatar %d not found in doId' % avId) return if mode == NPCToons.QUEST_MOVIE_REJECT: rejectString = Quests.chooseQuestDialogReject() rejectString = Quests.fillInQuestNames(rejectString, avName=av.name) self.setChatAbsolute(rejectString, CFSpeech | CFTimeout) if isLocalToon: base.localAvatar.posCamera(0, 0) base.cr.playGame.getPlace().setState('walk') return if mode == NPCToons.QUEST_MOVIE_TIER_NOT_DONE: rejectString = Quests.chooseQuestDialogTierNotDone() rejectString = Quests.fillInQuestNames(rejectString, avName=av.name) self.setChatAbsolute(rejectString, CFSpeech | CFTimeout) if isLocalToon: base.localAvatar.posCamera(0, 0) base.cr.playGame.getPlace().setState('walk') return self.setupAvatars(av) fullString = '' toNpcId = None if mode == NPCToons.QUEST_MOVIE_COMPLETE: questId, rewardId, toNpcId = quests scriptId = 'quest_complete_' + str(questId) if QuestParser.questDefined(scriptId): self.curQuestMovie = QuestParser.NPCMoviePlayer( scriptId, av, self) self.curQuestMovie.play() return if isLocalToon: self.setupCamera(mode) greetingString = Quests.chooseQuestDialog(questId, Quests.GREETING) if greetingString: fullString += greetingString + '\x07' fullString += Quests.chooseQuestDialog(questId, Quests.COMPLETE) + '\x07' if rewardId: fullString += Quests.getReward(rewardId).getString() leavingString = Quests.chooseQuestDialog(questId, Quests.LEAVING) if leavingString: fullString += '\x07' + leavingString elif mode == NPCToons.QUEST_MOVIE_QUEST_CHOICE_CANCEL: fullString = TTLocalizer.QuestMovieQuestChoiceCancel elif mode == NPCToons.QUEST_MOVIE_TRACK_CHOICE_CANCEL: fullString = TTLocalizer.QuestMovieTrackChoiceCancel elif mode == NPCToons.QUEST_MOVIE_INCOMPLETE: questId, completeStatus, toNpcId = quests scriptId = 'quest_incomplete_' + str(questId) if QuestParser.questDefined(scriptId): if self.curQuestMovie: self.curQuestMovie.timeout() self.curQuestMovie.cleanup() self.curQuestMovie = None self.curQuestMovie = QuestParser.NPCMoviePlayer( scriptId, av, self) self.curQuestMovie.play() return if isLocalToon: self.setupCamera(mode) greetingString = Quests.chooseQuestDialog(questId, Quests.GREETING) if greetingString: fullString += greetingString + '\x07' fullString += Quests.chooseQuestDialog(questId, completeStatus) leavingString = Quests.chooseQuestDialog(questId, Quests.LEAVING) if leavingString: fullString += '\x07' + leavingString elif mode == NPCToons.QUEST_MOVIE_ASSIGN: questId, rewardId, toNpcId = quests scriptId = 'quest_assign_' + str(questId) if QuestParser.questDefined(scriptId): if self.curQuestMovie: self.curQuestMovie.timeout() self.curQuestMovie.cleanup() self.curQuestMovie = None self.curQuestMovie = QuestParser.NPCMoviePlayer( scriptId, av, self) self.curQuestMovie.play() return if isLocalToon: self.setupCamera(mode) fullString += Quests.chooseQuestDialog(questId, Quests.QUEST) leavingString = Quests.chooseQuestDialog(questId, Quests.LEAVING) if leavingString: fullString += '\x07' + leavingString elif mode == NPCToons.QUEST_MOVIE_QUEST_CHOICE: if isLocalToon: self.setupCamera(mode) self.setChatAbsolute(TTLocalizer.QuestMovieQuestChoice, CFSpeech) if isLocalToon: self.acceptOnce('chooseQuest', self.sendChooseQuest) self.questChoiceGui = QuestChoiceGui.QuestChoiceGui() self.questChoiceGui.setQuests(quests, npcId, ChoiceTimeout) return elif mode == NPCToons.QUEST_MOVIE_TRACK_CHOICE: if isLocalToon: self.setupCamera(mode) tracks = quests self.setChatAbsolute(TTLocalizer.QuestMovieTrackChoice, CFSpeech) if isLocalToon: self.acceptOnce('chooseTrack', self.sendChooseTrack) self.trackChoiceGui = TrackChoiceGui.TrackChoiceGui( tracks, ChoiceTimeout) return fullString = Quests.fillInQuestNames(fullString, avName=av.name, fromNpcId=npcId, toNpcId=toNpcId) self.acceptOnce(self.uniqueName('doneChatPage'), self.finishMovie, extraArgs=[av, isLocalToon]) self.clearChat() self.setPageChat(avId, 0, fullString, 1) return
def setMovie(self, mode, npcId, avId, quests, timestamp): """ This is a message from the AI describing a movie between this NPC and a Toon that has approached us. """ timeStamp = ClockDelta.globalClockDelta.localElapsedTime(timestamp) # See if this is the local toon isLocalToon = (avId == base.localAvatar.doId) assert (self.notify.debug( "setMovie: %s %s %s %s %s %s" % (mode, npcId, avId, quests, timeStamp, isLocalToon))) # This is an old movie in the server ram that has been cleared. # Just return and do nothing if (mode == NPCToons.QUEST_MOVIE_CLEAR): assert self.notify.debug("setMovie: movie cleared") self.cleanupMovie() return # This is an old movie in the server ram that has been cleared. # Just return and do nothing if (mode == NPCToons.QUEST_MOVIE_TIMEOUT): assert self.notify.debug("setMovie: movie timeout") self.cleanupMovie() # If we are the local toon and we have simply taken too long # to read through the chat balloons, just free us if isLocalToon: self.freeAvatar() # Act like we finished the chat pages by setting the page number to -1 self.setPageNumber(0, -1) self.clearChat() self.startLookAround() self.detectAvatars() return av = base.cr.doId2do.get(avId) if av is None: self.notify.warning("Avatar %d not found in doId" % (avId)) return # Reject is simpler, so lets get that out of the way if (mode == NPCToons.QUEST_MOVIE_REJECT): rejectString = Quests.chooseQuestDialogReject() rejectString = Quests.fillInQuestNames(rejectString, avName=av.name) # No need for page chat here, just setChatAbsolute self.setChatAbsolute(rejectString, CFSpeech | CFTimeout) if isLocalToon: # Go back into walk mode base.localAvatar.posCamera(0, 0) base.cr.playGame.getPlace().setState("walk") return # Reject is simpler, so lets get that out of the way if (mode == NPCToons.QUEST_MOVIE_TIER_NOT_DONE): rejectString = Quests.chooseQuestDialogTierNotDone() rejectString = Quests.fillInQuestNames(rejectString, avName=av.name) # No need for page chat here, just setChatAbsolute self.setChatAbsolute(rejectString, CFSpeech | CFTimeout) if isLocalToon: # Go back into walk mode base.localAvatar.posCamera(0, 0) base.cr.playGame.getPlace().setState("walk") return self.setupAvatars(av) fullString = "" toNpcId = None if (mode == NPCToons.QUEST_MOVIE_COMPLETE): questId, rewardId, toNpcId = quests # Try out the new quest script system scriptId = "quest_complete_" + str(questId) if QuestParser.questDefined(scriptId): self.curQuestMovie = QuestParser.NPCMoviePlayer( scriptId, av, self) self.curQuestMovie.play() return if isLocalToon: self.setupCamera(mode) greetingString = Quests.chooseQuestDialog(questId, Quests.GREETING) if greetingString: fullString += greetingString + "\a" fullString += Quests.chooseQuestDialog(questId, Quests.COMPLETE) + "\a" if rewardId: fullString += Quests.getReward(rewardId).getString() leavingString = Quests.chooseQuestDialog(questId, Quests.LEAVING) if leavingString: fullString += "\a" + leavingString elif (mode == NPCToons.QUEST_MOVIE_QUEST_CHOICE_CANCEL): fullString = TTLocalizer.QuestMovieQuestChoiceCancel elif (mode == NPCToons.QUEST_MOVIE_TRACK_CHOICE_CANCEL): fullString = TTLocalizer.QuestMovieTrackChoiceCancel elif (mode == NPCToons.QUEST_MOVIE_INCOMPLETE): questId, completeStatus, toNpcId = quests # Try out the new quest script system scriptId = "quest_incomplete_" + str(questId) if QuestParser.questDefined(scriptId): if self.curQuestMovie: self.curQuestMovie.timeout() self.curQuestMovie.cleanup() self.curQuestMovie = None self.curQuestMovie = QuestParser.NPCMoviePlayer( scriptId, av, self) self.curQuestMovie.play() return if isLocalToon: self.setupCamera(mode) greetingString = Quests.chooseQuestDialog(questId, Quests.GREETING) if greetingString: fullString += greetingString + "\a" fullString += Quests.chooseQuestDialog(questId, completeStatus) leavingString = Quests.chooseQuestDialog(questId, Quests.LEAVING) if leavingString: fullString += "\a" + leavingString elif (mode == NPCToons.QUEST_MOVIE_ASSIGN): questId, rewardId, toNpcId = quests # Try out the new quest script system scriptId = "quest_assign_" + str(questId) if QuestParser.questDefined(scriptId): if self.curQuestMovie: self.curQuestMovie.timeout() self.curQuestMovie.cleanup() self.curQuestMovie = None self.curQuestMovie = QuestParser.NPCMoviePlayer( scriptId, av, self) self.curQuestMovie.play() return if isLocalToon: self.setupCamera(mode) #greetingString = Quests.chooseQuestDialog(questId, Quests.GREETING) #if greetingString: # fullString += greetingString + "\a" fullString += Quests.chooseQuestDialog(questId, Quests.QUEST) leavingString = Quests.chooseQuestDialog(questId, Quests.LEAVING) if leavingString: fullString += "\a" + leavingString elif (mode == NPCToons.QUEST_MOVIE_QUEST_CHOICE): # Quest choice movie if isLocalToon: self.setupCamera(mode) assert self.notify.debug("QUEST_MOVIE_QUEST_CHOICE: %s" % quests) self.setChatAbsolute(TTLocalizer.QuestMovieQuestChoice, CFSpeech) if isLocalToon: self.acceptOnce("chooseQuest", self.sendChooseQuest) self.questChoiceGui = QuestChoiceGui.QuestChoiceGui() self.questChoiceGui.setQuests(quests, npcId, ChoiceTimeout) return elif (mode == NPCToons.QUEST_MOVIE_TRACK_CHOICE): # If this is a TrackChoiceQuest, complete simply means we are at the # avatar that will allow us to chose. If the localToon cancels the # choice, we are not really complete yet # In this case, the quests are really the track choices if isLocalToon: self.setupCamera(mode) tracks = quests assert self.notify.debug("QUEST_MOVIE_TRACK_CHOICE: %s" % tracks) self.setChatAbsolute(TTLocalizer.QuestMovieTrackChoice, CFSpeech) if isLocalToon: self.acceptOnce("chooseTrack", self.sendChooseTrack) self.trackChoiceGui = TrackChoiceGui.TrackChoiceGui( tracks, ChoiceTimeout) return fullString = Quests.fillInQuestNames(fullString, avName=av.name, fromNpcId=npcId, toNpcId=toNpcId) self.acceptOnce(self.uniqueName("doneChatPage"), self.finishMovie, extraArgs=[av, isLocalToon]) self.setPageChat(avId, 0, fullString, 1)