Beispiel #1
0
    def getTaskInfo(self, objective, speech=False):
        """
        Returns a string that could be used as speech or for a quest note.
        It gives information about the quest and what you have to do.
        """

        taskInfo = ""

        if speech:
            # If it's speech, add the objective's header (e.g Defeat, Recover, Deliver) to the beginning of the sentence.
            taskInfo += objective.Header + " "

        # Add objective specific task info
        taskInfo += objective.getTaskInfo(speech)

        if objective.AreaSpecific:
            # This objective is sometimes area specific.
            if objective.area == QuestGlobals.Anywhere:
                taskInfo += "\nAnywhere" if not speech else " anywhere"
            else:
                # Say what area the objective must be completed in.
                taskInfo += "\nin " + ZoneUtil.getHoodId(
                    objective.area
                ) if not speech else " in " + ZoneUtil.getHoodId(
                    objective.area)

        if speech:
            # Always put a period at the end of the sentence if it's speech!
            taskInfo += "."

        return taskInfo
Beispiel #2
0
    def headOff(self):
        if self.index == 1:
            zoneId = base.localAvatar.getLastHood()
            hoodId = ZoneUtil.getHoodId(zoneId)
        else:
            zoneId = self.toZone
            hoodId = ZoneUtil.getHoodId(self.toZone)

        requestStatus = {'zoneId': zoneId,
                    'hoodId': hoodId,
                    'where': 'playground',
                    'avId': base.localAvatar.doId,
                    'loader': 'safeZoneLoader',
                    'shardId': None,
                    'wantLaffMeter': 1,
                    'how': 'teleportIn',
                    'prevZoneId': base.localAvatar.zoneId,
                    'slot': self.mySlot}
        self.cr.playGame.getPlace().doneStatus = requestStatus
        messenger.send(self.cr.playGame.getPlace().doneEvent)
        base.localAvatar.reparentTo(render)
        base.localAvatar.setPos(0, 0, 0)
        base.localAvatar.setHpr(0, 0, 0)
        base.localAvatar.walkControls.setCollisionsActive(1)
        self.localAvOnTrolley = False
Beispiel #3
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 makeMoreDetailsPanel(self):
     self.actionFSM.request('off')
     self.removeMoreDetailsPanel()
     self.removeActionPanel()
     self.makeActionPanel()
     zoneId = self.avatarInfo[5]
     shardId = self.avatarInfo[6]
     isOnline = self.avatarInfo[7]
     shardName = 'Unknown District'
     hoodName = ZoneUtil.getHoodId(zoneId, 1)
     for district in base.cr.activeDistricts.values():
         if district.doId == shardId:
             shardName = district.getDistrictName()
             break
     if not isOnline:
         hoodName = 'Offline'
         shardName = 'Offline'
     self.locationText = OnscreenText('Location: {0}'.format(hoodName),
                                      parent=self.actionFrame,
                                      pos=(-0.3, 0.05, 0),
                                      align=TextNode.ALeft,
                                      scale=0.04)
     self.shardText = OnscreenText('District: {0}'.format(shardName),
                                   parent=self.actionFrame,
                                   pos=(-0.3, 0.0, 0),
                                   align=TextNode.ALeft,
                                   scale=0.04)
     self.detailsExitBtn = DirectButton(geom=CIGlobals.getCancelBtnGeom(),
                                        parent=self.actionFrame,
                                        relief=None,
                                        scale=0.8,
                                        pos=(-0.3, 0.0, -0.175),
                                        command=self.removeMoreDetailsPanel)
 def makeInterior(self, roomIndex=None):
     self.dnaStore = self.cr.playGame.dnaStore
     self.generator = random.Random()
     self.generator.seed(self.zoneId)
     self.interior = loader.loadModel(
         'phase_4/models/modules/gagShop_interior.bam')
     self.interior.reparentTo(render)
     hoodId = ZoneUtil.getHoodId(self.zoneId, 1)
     self.colors = ToonInteriorColors.colors[hoodId]
     self.replaceRandomInModel(self.interior)
     door = self.dnaStore.findNode('door_double_round_ur')
     doorOrigin = render.find('**/door_origin;+s')
     doorNP = door.copyTo(doorOrigin)
     doorOrigin.setScale(0.8, 0.8, 0.8)
     doorOrigin.setPos(doorOrigin, 0, -0.025, 0)
     doorColor = self.generator.choice(self.colors['TI_door'])
     DNADoor.setupDoor(doorNP, self.interior, doorOrigin, self.dnaStore,
                       self.block, doorColor)
     doorFrame = doorNP.find('door_*_flat')
     doorFrame.wrtReparentTo(self.interior)
     doorFrame.setColor(doorColor)
     del self.colors
     del self.dnaStore
     del self.generator
     self.addLightsForLamps()
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'
Beispiel #7
0
 def onPlayerDied(self):
     """
     Called upon the local avatar dying.
     """
     from src.coginvasion.hood import ZoneUtil
     if (base.cr.playGame.hood.id != ZoneUtil.getHoodId(
             base.localAvatar.zoneId)):
         base.cr.playGame.getPlace().fsm.request(
             'died', [{}, base.localAvatar.diedStateDone])
Beispiel #8
0
 def handleToonData(self, avatarList):
     for av in avatarList:
         avId = av[0]
         dna = av[1]
         name = av[2]
         slot = av[3]
         lastHood = av[4]
         choice = AvChoice(dna, name, slot, avId,
                           ZoneUtil.getHoodId(lastHood))
         self.avChoices.append(choice)
     self.avChooseFSM.request('avChoose')
 def handleTeleportResponse(self, avatarId, shardId, zoneId):
     if self.avatarInfo[0] == avatarId:
         requestStatus = {}
         whereName = ZoneUtil.getWhereName(zoneId)
         loaderName = ZoneUtil.getLoaderName(zoneId)
         requestStatus['zoneId'] = zoneId
         if base.localAvatar.parentId == shardId:
             requestStatus['shardId'] = None
         else:
             requestStatus['shardId'] = shardId
         requestStatus['hoodId'] = ZoneUtil.getHoodId(zoneId, 1)
         requestStatus['where'] = whereName
         requestStatus['loader'] = loaderName
         requestStatus['how'] = 'teleportIn'
         requestStatus['avId'] = avatarId
         base.cr.playGame.getPlace().fsm.request('teleportOut',
                                                 [requestStatus])
         self.cleanup()
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'
Beispiel #11
0
 def onDoorCloseFinish(self):
     if self.index == 1:
         if self.localAvOnElevator:
             self.thebldg.d_readyForNextFloor()
             self.localAvOnElevator = False
         else:
             # NOTE: we can't use self.zoneId because the elevator is in the ent zone, not the branch zone
             zoneId = ZoneUtil.getZoneId(
                 ZoneUtil.getHoodId(base.localAvatar.zoneId, street=1))
             requestStatus = {
                 'zoneId': zoneId,
                 'hoodId': self.cr.playGame.hood.hoodId,
                 'where': 'playground',
                 'avId': base.localAvatar.doId,
                 'loader': 'safeZoneLoader',
                 'shardId': None,
                 'wantLaffMeter': 1,
                 'world': base.cr.playGame.getCurrentWorldName(),
                 'how': 'teleportIn'
             }
             self.cr.playGame.getPlace().doneStatus = requestStatus
             messenger.send(self.cr.playGame.getPlace().doneEvent)
    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 enterPlayingGame(self):
     zoneId = localAvatar.getLastHood()
     hoodId = ZoneUtil.getHoodId(zoneId)
     status = {"hoodId": hoodId, "zoneId": zoneId, "avId": self.localAvId}
     shardId = self.myDistrict.doId
     self.gameFSM.request('waitForGameEnterResponse', [status, shardId])
 def isValidLocation(self, hood):
     return (self.area == QuestGlobals.Anywhere or
         ZoneUtil.getHoodId(self.area, 1) == hood or
         ZoneUtil.getHoodId(self.area, 1) == ZoneUtil.ToontownCentral and
         hood == ZoneUtil.BattleTTC)