def getLocationText(location, objective=None, verbose=True):
    # Let's handle when the location is None, this means we want to go
    # to the objective's assigner. OR if we're looking for an HQ officer.
    if location == 0 or not location and objective:
        # Let's figure out where the assigner is at, fam.
        if location == 0 or objective.assigner == 0:
            return 'Any Street\nAny Neighborhood'
        else:
            return getLocationText(
                NPCGlobals.NPCToonDict[objective.assigner][0], verbose=verbose)

    if location in ZoneUtil.ZoneId2Hood.keys():
        if location == ZoneUtil.MinigameAreaId:
            return ZoneUtil.ZoneId2Hood.get(location)
        return '%s\n%s' % ('Any Street', ZoneUtil.ZoneId2Hood.get(location))
    elif location in ZoneUtil.BranchZone2StreetName.keys():
        streetName = ZoneUtil.BranchZone2StreetName.get(location)
        playground = ZoneUtil.ZoneId2Hood.get(location - (location % 1000))
        return '%s\n%s' % (streetName, playground)
    elif location in ZoneUtil.zone2TitleDict.keys():
        shop = ZoneUtil.zone2TitleDict.get(location)[0]
        streetZone = ZoneUtil.getBranchZone(location)
        if streetZone % 1000 >= 100:
            streetName = ZoneUtil.BranchZone2StreetName[streetZone]
        else:
            streetName = PLAYGROUND
        hoodName = ZoneUtil.getHoodId(streetZone, 1)

        if verbose:
            return '%s\n%s\n%s' % (shop, streetName, hoodName)
        else:
            return shop

    elif not location:
        return 'Any Street\nAny Playground'
Esempio n. 2
0
 def updateInfo(self):
     # Setup the location text.
     if (self.location in CIGlobals.ZoneId2Hood.keys()):
         self.quest.setLocationText(
             '%s\n%s' % (QuestGlobals.ANYWHERE,
                         CIGlobals.ZoneId2Hood.get(self.location)))
         self.quest.setLocationY(0)
     elif (self.location in CIGlobals.BranchZone2StreetName.keys()):
         self.quest.setLocationText(
             '%s\n%s' % (CIGlobals.BranchZone2StreetName.get(self.location),
                         CIGlobals.ZoneId2Hood.get(self.location -
                                                   (self.location % 1000))))
         self.quest.setLocationY(0)
     elif (self.location in CIGlobals.zone2TitleDict.keys()):
         shop = CIGlobals.zone2TitleDict.get(self.location)[0]
         streetZone = ZoneUtil.getBranchZone(self.location)
         if streetZone % 1000 >= 100:
             streetName = CIGlobals.BranchZone2StreetName[streetZone]
         else:
             streetName = QuestGlobals.PLAYGROUND
         hoodName = ZoneUtil.getHoodId(streetZone, 1)
         self.quest.setLocationText('%s\n%s\n%s' %
                                    (shop, streetName, hoodName))
         self.quest.setLocationY(0.025)
     elif not self.location:
         self.quest.setLocationText(QuestGlobals.ANYWHERE)
 def handleToonInteriorDone(self):
     status = self.place.doneStatus
     if (status['loader'] == 'townLoader'
             and ZoneUtil.getBranchZone(status['zoneId']) == self.branchZone
             and status['shardId'] is None or status['how'] == 'doorOut'):
         self.fsm.request('quietZone', [status])
     else:
         self.doneStatus = status
         messenger.send(self.doneEvent)
     return
 def streetDone(self):
     self.requestStatus = self.place.doneStatus
     status = self.place.doneStatus
     if (status['loader'] == 'townLoader'
             and ZoneUtil.getBranchZone(status['zoneId']) == self.branchZone
             and status['shardId'] is None or status['how'] == 'doorOut'
             or status['where'] == 'suitInterior'):
         self.fsm.request('quietZone', [status])
     else:
         self.doneStatus = status
         messenger.send(self.doneEvent)
def getLocationText(location):
    if location in CIGlobals.ZoneId2Hood.keys():
        return '%s\n%s' % ('Any Street', CIGlobals.ZoneId2Hood.get(location))
    elif location in CIGlobals.BranchZone2StreetName.keys():
        streetName = CIGlobals.BranchZone2StreetName.get(location)
        playground = CIGlobals.ZoneId2Hood.get(location - (location % 1000))
        return '%s\n%s' % (streetName, playground)
    elif location in CIGlobals.zone2TitleDict.keys():
        shop = CIGlobals.zone2TitleDict.get(location)[0]
        streetZone = ZoneUtil.getBranchZone(location)
        if streetZone % 1000 >= 100:
            streetName = CIGlobals.BranchZone2StreetName[streetZone]
        else:
            streetName = PLAYGROUND
        hoodName = ZoneUtil.getHoodId(streetZone, 1)
        return '%s\n%s\n%s' % (shop, streetName, hoodName)
    elif not location:
        return 'Any Street\nAny Playground'
    def getNPCLocationSpeech(self, nextObjective = False):
        if nextObjective:
            objective = self.currentQuest.getNextObjectiveData()
        else:
            objective = self.currentQuest.getCurrObjectiveData()

        npcId = objective[Quests.args][0]
        npcZone = NPCGlobals.NPCToonDict[npcId][0]

        name = NPCGlobals.NPCToonNames[npcId]
        shopName = ZoneUtil.zone2TitleDict[npcZone][0]
        chat = random.choice(NPCDialogue.FindNPC)
        if "[p]" in chat:
            chat = chat.replace("[p]", getPossessive(name))
        chat = chat % (name, shopName)
        chat += "\x07"
        locationSpeech = NPCDialogue.WhichIs
        if ZoneUtil.isOnCurrentPlayground(npcZone):
            # The NPC is in the same playground that the quest is being assigned on.
            locationSpeech = locationSpeech % "in this playground."
        elif ZoneUtil.isOnSameStreet(npcZone):
            # The NPC is on the same street that the quest is being assigned on.
            locationSpeech = locationSpeech % "on this street."
        elif ZoneUtil.isAtSamePlaygroundButDifferentBranch(npcZone):
            # The NPC is in the same playground but in a different branch zone.
            locationSpeech = (locationSpeech % "on %s." %
                ZoneUtil.getStreetName(npcZone))
        else:
            # NPC is in a completely different playground from where we are.
            if ZoneUtil.isStreet(ZoneUtil.getBranchZone(npcZone)):
                loc = "on %s" % ZoneUtil.getStreetName(npcZone)
            else:
                loc = "at the playground"
            locationSpeech = (locationSpeech % "%s in %s." %
                (loc, ZoneUtil.getHoodId(npcZone, 1)))
        chat += locationSpeech
        chat += "\x07"

        return chat
 def load(self, zoneId):
     StateData.load(self)
     self.zoneId = zoneId
     self.branchZone = ZoneUtil.getBranchZone(zoneId)
     self.canonicalBranchZone = ZoneUtil.getCanonicalBranchZone(zoneId)
    def makeDictionaries(self, dnaStore):
        self.nodeDict = {}
        self.zoneDict = {}
        self.zoneVisDict = {}
        self.nodeList = []
        self.fadeInDict = {}
        self.fadeOutDict = {}
        a1 = Vec4(1, 1, 1, 1)
        a0 = Vec4(1, 1, 1, 0)
        numVisGroups = dnaStore.getNumDNAVisGroupsAI()
        for i in xrange(numVisGroups):
            groupFullName = dnaStore.getDNAVisGroupName(i)
            visGroup = dnaStore.getDNAVisGroupAI(i)
            groupName = base.cr.hoodMgr.extractGroupName(groupFullName)
            zoneId = int(groupName)
            zoneId = ZoneUtil.getTrueZoneId(zoneId, self.zoneId)
            groupNode = self.geom.find('**/' + groupFullName)
            if groupNode.isEmpty():
                continue
            else:
                if ':' in groupName:
                    groupName = '%s%s' % (zoneId,
                                          groupName[groupName.index(':'):])
                else:
                    groupName = '%s' % zoneId
                groupNode.setName(groupName)

            CIGlobals.replaceDecalEffectsWithDepthOffsetAttrib(groupNode)

            #group all the flat walls

            block2flatwall = {}
            flatwalls = groupNode.findAllMatches("**/tb*:*_DNARoot;+s")
            for flatwall in flatwalls:
                if "toon_landmark" in flatwall.getName():
                    print "Skipping", flatwall.getName()
                    continue
                if flatwall.hasTag("DNACode") and flatwall.hasMat():
                    continue
                block = int(flatwall.getName().split(":")[0][2:])
                if not block2flatwall.has_key(block):
                    block2flatwall[block] = groupNode.attachNewNode(
                        ModelNode('toonBuildingsBlock' + str(block)))
                flatwall.wrtReparentTo(block2flatwall[block])

            for node in block2flatwall.values():
                for child in node.findAllMatches("**"):
                    child.clearEffect(DecalEffect.getClassType())
                    child.clearTag("DNACode")
                    child.clearTag("cam")
                CIGlobals.clearModelNodesBelow(node)
                node.flattenStrong()

            flattenGroup = groupNode.attachNewNode('optim')
            flattens = ['street*_DNARoot']
            removes = ['interactive_prop*_DNARoot']
            for remove in removes:
                for np in groupNode.findAllMatches("**/" + remove):
                    np.removeNode()
            for flatten in flattens:
                for np in groupNode.findAllMatches("**/" + flatten):
                    if np.hasTag("DNACode") and np.hasMat():
                        continue
                    for child in np.findAllMatches("**"):
                        child.clearEffect(DecalEffect.getClassType())
                        child.clearTag("DNACode")
                        child.clearTag("cam")
                    np.wrtReparentTo(flattenGroup)
            flattenGroup.clearModelNodes()
            flattenGroup.flattenStrong()

            CIGlobals.flattenModelNodes(groupNode)
            groupNode.flattenStrong()
            #groupNode.ls()

            self.nodeDict[zoneId] = []
            self.nodeList.append(groupNode)
            self.zoneDict[zoneId] = groupNode
            visibles = []
            for i in xrange(visGroup.getNumVisibles()):
                visibles.append(int(visGroup.get_visible(i)))
            visibles.append(ZoneUtil.getBranchZone(zoneId))
            self.zoneVisDict[zoneId] = visibles
            fadeDuration = 0.5
            self.fadeOutDict[groupNode] = Sequence(
                Func(groupNode.setTransparency, 1),
                LerpColorScaleInterval(groupNode,
                                       fadeDuration,
                                       a0,
                                       startColorScale=a1),
                Func(groupNode.clearColorScale),
                Func(groupNode.clearTransparency),
                Func(groupNode.stash),
                Func(base.disablePhysicsNodes, groupNode),
                name='fadeZone-' + str(zoneId),
                autoPause=1)
            self.fadeInDict[groupNode] = Sequence(
                Func(base.enablePhysicsNodes, groupNode),
                Func(groupNode.unstash),
                Func(groupNode.setTransparency, 1),
                LerpColorScaleInterval(groupNode,
                                       fadeDuration,
                                       a1,
                                       startColorScale=a0),
                Func(groupNode.clearColorScale),
                Func(groupNode.clearTransparency),
                name='fadeZone-' + str(zoneId),
                autoPause=1)

        for i in xrange(numVisGroups):
            groupFullName = dnaStore.getDNAVisGroupName(i)
            zoneId = int(base.cr.hoodMgr.extractGroupName(groupFullName))
            zoneId = ZoneUtil.getTrueZoneId(zoneId, self.zoneId)
            for j in xrange(dnaStore.getNumVisiblesInDNAVisGroup(i)):
                visName = dnaStore.getVisibleName(i, j)
                groupName = base.cr.hoodMgr.extractGroupName(visName)
                nextZoneId = int(groupName)
                nextZoneId = ZoneUtil.getTrueZoneId(nextZoneId, self.zoneId)
                visNode = self.zoneDict[nextZoneId]
                self.nodeDict[zoneId].append(visNode)

        self.hood.dnaStore.resetPlaceNodes()
        self.hood.dnaStore.resetDNAGroups()
        self.hood.dnaStore.resetDNAVisGroups()
        self.hood.dnaStore.resetDNAVisGroupsAI()
Esempio n. 9
0
    def load(self):
        BookPage.load(self)
        # Let's load up the clouds.
        for pos, scale, hpr in self.cloudPos:
            cloud = loader.loadModel('phase_3.5/models/gui/cloud.bam')
            cloud.reparentTo(self)
            cloud.setPos(pos)
            cloud.setScale(scale)
            cloud.setHpr(hpr)
            self.clouds.append(cloud)

        for pos, scale, hpr, hood in self.hoodClouds:
            if not base.localAvatar.hasDiscoveredHood(
                    ZoneUtil.getZoneId(hood)):
                cloud = loader.loadModel('phase_3.5/models/gui/cloud.bam')
                cloud.reparentTo(self)
                cloud.setPos(pos)
                cloud.setScale(scale)
                cloud.setHpr(hpr)
                self.clouds.append(cloud)

        for pos, name in self.labelData:
            if base.localAvatar.hasDiscoveredHood(ZoneUtil.getZoneId(name)):
                text = name
                if base.localAvatar.hasTeleportAccess(
                        ZoneUtil.getZoneId(name)):
                    text = 'Go To\n' + text
                label = DirectButton(
                    parent=self,
                    relief=None,
                    pos=pos,
                    pad=(0.2, 0.16),
                    text=('', text, text, ''),
                    text_bg=Vec4(1, 1, 1, 0.4),
                    text_scale=0.055,
                    text_wordwrap=8,
                    rolloverSound=CIGlobals.getRolloverSound(),
                    clickSound=None,
                    pressEffect=0,
                    sortOrder=1,
                    text_font=CIGlobals.getToonFont())
                if base.localAvatar.hasTeleportAccess(
                        ZoneUtil.getZoneId(name)):
                    label['command'] = self.book.finished
                    label['extraArgs'] = [ZoneUtil.getZoneId(name)]
                label.resetFrameSize()
                self.labels.append(label)

        currHoodName = base.cr.playGame.hood.id
        currLocation = ''
        if base.localAvatar.zoneId == ZoneUtil.MinigameAreaId or base.localAvatar.getBattleZone(
        ) is not None:
            currLocation = ''
        elif ZoneUtil.getWhereName(base.localAvatar.zoneId) == 'playground':
            currLocation = 'Playground'
        elif ZoneUtil.getWhereName(
                base.localAvatar.zoneId) in ['street', 'interior']:
            currLocation = ZoneUtil.BranchZone2StreetName[
                ZoneUtil.getBranchZone(base.localAvatar.zoneId)]
        self.infoLabel = DirectLabel(relief=None,
                                     text='You are in: {0}\n{1}'.format(
                                         currHoodName, currLocation),
                                     scale=0.06,
                                     pos=(-0.4, 0, -0.74),
                                     parent=self,
                                     text_align=TextNode.ACenter)

        if currHoodName in [ZoneUtil.MinigameArea, ZoneUtil.BattleTTC]:
            currHoodName = base.cr.playGame.lastHood
        btpText = 'Back to Playground'
        btpEA = [ZoneUtil.getZoneId(currHoodName)]
        self.BTPButton = DirectButton(relief=None,
                                      text=btpText,
                                      geom=CIGlobals.getDefaultBtnGeom(),
                                      text_pos=(0, -0.018),
                                      geom_scale=(1.3, 1.11, 1.11),
                                      text_scale=0.06,
                                      parent=self,
                                      text_font=CIGlobals.getToonFont(),
                                      pos=(0.25, 0, -0.75),
                                      command=self.book.finished,
                                      extraArgs=btpEA,
                                      scale=0.7)

        icons = loader.loadModel('phase_3.5/models/gui/sos_textures.bam')
        self.icon = icons.find('**/teleportIcon')
        icons.detachNode()