def updateMap(self):
     if self.av:
         hoodId = ZoneUtil.getCanonicalHoodId(self.av.getLocation()[1])
         zoneId = ZoneUtil.getCanonicalBranchZone(self.av.getLocation()[1])
         try:
             mapsGeom = loader.loadModel('phase_4/models/questmap/%s_maps' % ToontownGlobals.dnaMap[hoodId])
         except:
             self.stop()
             return
         mapImage = mapsGeom.find('**/%s_%s_english' % (ToontownGlobals.dnaMap[hoodId], zoneId))
         if not mapImage.isEmpty():
             self.container['image'] = mapImage
             self.resetFrameSize()
             self.cornerPosInfo = QuestMapGlobals.CornerPosTable.get('%s_%s_english' % (ToontownGlobals.dnaMap[hoodId], zoneId))
             self.hqPosInfo = QuestMapGlobals.HQPosTable.get('%s_%s_english' % (ToontownGlobals.dnaMap[hoodId], zoneId))
             self.fishingSpotInfo = QuestMapGlobals.FishingSpotPosTable.get('%s_%s_english' % (ToontownGlobals.dnaMap[hoodId], zoneId))
             self.cogInfoPos = QuestMapGlobals.CogInfoPosTable.get('%s_%s_english' % (ToontownGlobals.dnaMap[hoodId], zoneId))
             self.cogInfoFrame.setPos(self.cogInfoPos)
             self.hide()
             self.hoodId = hoodId
             self.zoneId = zoneId
             self.updateQuestInfo()
             self.updateCogInfo()
             taskMgr.add(self.update, 'questMapUpdate')
         else:
             self.stop()
             mapsGeom.removeNode()
 def enteringARace(self, status):
     if not status['where'] == 'racetrack':
         return 0
     if ZoneUtil.isDynamicZone(status['zoneId']):
         return status['hoodId'] == self.hood.hoodId
     else:
         return ZoneUtil.getHoodId(status['zoneId']) == self.hood.hoodId
 def enteringARace(self, status):
     if not status['where'] == 'racetrack':
         return 0
     if ZoneUtil.isDynamicZone(status['zoneId']):
         return status['hoodId'] == self.hood.hoodId
     else:
         return ZoneUtil.getHoodId(status['zoneId']) == self.hood.hoodId
 def enteringAGolfCourse(self, status):
     if not status['where'] == 'golfcourse':
         return 0
     if ZoneUtil.isDynamicZone(status['zoneId']):
         return status['hoodId'] == self.hood.hoodId
     else:
         return ZoneUtil.getHoodId(status['zoneId']) == self.hood.hoodId
Beispiel #5
0
 def kickToPlayground(self, retCode):
     if retCode == 0:
         msg = TTLocalizer.EstateOwnerLeftMessage % HouseGlobals.BOOT_GRACE_PERIOD
         self.__popupKickoutMessage(msg)
     elif retCode == 1:
         zoneId = base.localAvatar.lastHood
         self.doneStatus = {
             'loader': ZoneUtil.getBranchLoaderName(zoneId),
             'where': ZoneUtil.getToonWhereName(zoneId),
             'how': 'teleportIn',
             'hoodId': zoneId,
             'zoneId': zoneId,
             'shardId': None,
             'avId': -1
         }
         messenger.send(self.doneEvent)
     elif retCode == 2:
         zoneId = base.localAvatar.lastHood
         self.doneStatus = {
             'loader': ZoneUtil.getBranchLoaderName(zoneId),
             'where': ZoneUtil.getToonWhereName(zoneId),
             'how': 'teleportIn',
             'hoodId': zoneId,
             'zoneId': zoneId,
             'shardId': None,
             'avId': -1
         }
         messenger.send(self.doneEvent)
     else:
         self.notify.error('unknown reason for exiting estate')
 def enteringAGolfCourse(self, status):
     if not status["where"] == "golfcourse":
         return 0
     if ZoneUtil.isDynamicZone(status["zoneId"]):
         return status["hoodId"] == self.hood.hoodId
     else:
         return ZoneUtil.getHoodId(status["zoneId"]) == self.hood.hoodId
Beispiel #7
0
    def enter(self):
        ShtikerPage.ShtikerPage.enter(self)
        try:
            zone = base.cr.playGame.getPlace().getZoneId()
        except:
            zone = 0

        if base.localAvatar.lastHood >= ToontownGlobals.BossbotHQ:
            self.safeZoneButton['text'] = TTLocalizer.MapPageBackToCogHQ
        else:
            self.safeZoneButton['text'] = TTLocalizer.MapPageBackToPlayground
        if zone and ZoneUtil.isPlayground(zone) or self.book.safeMode:
            self.safeZoneButton.hide()
        else:
            self.safeZoneButton.show()
        if base.cr.playGame.getPlaceId() == ToontownGlobals.MyEstate and base.cr.playGame.hood.loader.atMyEstate() or self.book.safeMode:
            self.goHomeButton.hide()
        elif base.housingEnabled:
            self.goHomeButton.show()
        if base.cr.playGame.getPlaceId() == ToontownGlobals.MyEstate:
            if base.cr.playGame.hood.loader.atMyEstate():
                self.hoodLabel['text'] = TTLocalizer.MapPageYouAreAtHome
                self.hoodLabel.show()
            else:
                avatar = base.cr.identifyAvatar(base.cr.playGame.hood.loader.estateOwnerId)
                if avatar:
                    avName = avatar.getName()
                    self.hoodLabel['text'] = TTLocalizer.MapPageYouAreAtSomeonesHome % TTLocalizer.GetPossesive(avName)
                    self.hoodLabel.show()
        elif zone:
            hoodName = ToontownGlobals.hoodNameMap.get(ZoneUtil.getCanonicalHoodId(zone), ('',))[-1]
            streetName = ToontownGlobals.StreetNames.get(ZoneUtil.getCanonicalBranchZone(zone), ('',))[-1]
            if hoodName:
                self.hoodLabel['text'] = TTLocalizer.MapPageYouAreHere % (hoodName, streetName)
                self.hoodLabel.show()
            else:
                self.hoodLabel.hide()
        else:
            self.hoodLabel.hide()
        hoodsVisited = base.localAvatar.hoodsVisited
        hoodTeleportList = base.localAvatar.getTeleportAccess()
        for hood in self.allZones:
            label = self.labels[self.allZones.index(hood)]
            clouds = self.clouds[self.allZones.index(hood)]
            if not self.book.safeMode and hood in hoodsVisited:
                label['text_fg'] = (0, 0, 0, 1)
                label.show()
                for cloud in clouds:
                    cloud.hide()

                fullname = base.cr.hoodMgr.getFullnameFromId(hood)
                if hood in hoodTeleportList:
                    text = TTLocalizer.MapPageGoTo % fullname
                    label['text'] = ('', text, text)
                else:
                    label['text'] = ('', fullname, fullname)
            else:
                label.hide()
                for cloud in clouds:
                    cloud.show()
Beispiel #8
0
 def updateMap(self):
     if self.av:
         hoodId = ZoneUtil.getCanonicalHoodId(self.av.getLocation()[1])
         zoneId = ZoneUtil.getCanonicalBranchZone(self.av.getLocation()[1])
         try:
             mapsGeom = loader.loadModel('phase_4/models/questmap/%s_maps' %
                                         ToontownGlobals.dnaMap[hoodId])
         except:
             self.stop()
             return
         mapImage = mapsGeom.find('**/%s_%s_english' %
                                  (ToontownGlobals.dnaMap[hoodId], zoneId))
         if not mapImage.isEmpty():
             self.container['image'] = mapImage
             self.resetFrameSize()
             self.cornerPosInfo = QuestMapGlobals.CornerPosTable.get(
                 '%s_%s_english' % (ToontownGlobals.dnaMap[hoodId], zoneId))
             self.hqPosInfo = QuestMapGlobals.HQPosTable.get(
                 '%s_%s_english' % (ToontownGlobals.dnaMap[hoodId], zoneId))
             self.fishingSpotInfo = QuestMapGlobals.FishingSpotPosTable.get(
                 '%s_%s_english' % (ToontownGlobals.dnaMap[hoodId], zoneId))
             self.cogInfoPos = QuestMapGlobals.CogInfoPosTable.get(
                 '%s_%s_english' % (ToontownGlobals.dnaMap[hoodId], zoneId))
             self.cogInfoFrame.setPos(self.cogInfoPos)
             self.hide()
             self.hoodId = hoodId
             self.zoneId = zoneId
             self.updateQuestInfo()
             self.updateCogInfo()
             taskMgr.add(self.update, 'questMapUpdate')
         else:
             self.stop()
             mapsGeom.removeNode()
    def teleportToShop(self, npcId):
        npcZone = NPCToons.getNPCZone(npcId)
        npcHood = ZoneUtil.getCanonicalHoodId(npcZone)
        avZone = base.localAvatar.getZoneId()
        avHood = ZoneUtil.getCanonicalHoodId(avZone)
        avShard = base.localAvatar.defaultShard
        avPlace = base.cr.playGame.getPlace()
        hqZone = {
            2000: 2520,
            1000: 1507,
            3000: 3508,
            4000: 4504,
            5000: 5502,
            7000: 7503,
            9000: 9505
        }

        def callback(flag):
            if flag:
                npcZone = None

        base.cr.buildingQueryMgr.d_isSuit(npcZone, callback)
        if avShard not in base.cr.activeDistrictMap:
            return
        if npcZone in [-1, 0, None]:
            return
        if not ZoneUtil.isInterior(npcZone):
            return
        if ZoneUtil.isHQ(npcZone):
            args = (avHood, hqZone[avHood], avShard, -1)
        else:
            args = (npcHood, npcZone, avShard, -1)
        avPlace.requestTeleport(*args)
 def kickToPlayground(self, retCode):
     if retCode == 0:
         msg = TTLocalizer.EstateOwnerLeftMessage % HouseGlobals.BOOT_GRACE_PERIOD
         self.__popupKickoutMessage(msg)
     elif retCode == 1:
         zoneId = base.localAvatar.lastHood
         self.doneStatus = {'loader': ZoneUtil.getBranchLoaderName(zoneId),
          'where': ZoneUtil.getToonWhereName(zoneId),
          'how': 'teleportIn',
          'hoodId': zoneId,
          'zoneId': zoneId,
          'shardId': None,
          'avId': -1}
         messenger.send(self.doneEvent)
     elif retCode == 2:
         zoneId = base.localAvatar.lastHood
         self.doneStatus = {'loader': ZoneUtil.getBranchLoaderName(zoneId),
          'where': ZoneUtil.getToonWhereName(zoneId),
          'how': 'teleportIn',
          'hoodId': zoneId,
          'zoneId': zoneId,
          'shardId': None,
          'avId': -1}
         messenger.send(self.doneEvent)
     else:
         self.notify.error('unknown reason for exiting estate')
 def genDNAFileName(self):
     zoneId = ZoneUtil.getCanonicalZoneId(self.getZoneId())
     hoodId = ZoneUtil.getCanonicalHoodId(zoneId)
     hood = ToontownGlobals.dnaMap[hoodId]
     phase = ToontownGlobals.streetPhaseMap[hoodId]
     if hoodId == zoneId:
         zoneId = 'sz'
     return 'phase_%s/dna/%s_%s.pdna' % (phase, hood, zoneId)
 def genDNAFileName(self, zoneId):
     zoneId = ZoneUtil.getCanonicalZoneId(zoneId)
     hoodId = ZoneUtil.getCanonicalHoodId(zoneId)
     hood = ToontownGlobals.dnaMap[hoodId]
     phase = ToontownGlobals.streetPhaseMap[hoodId]
     if hoodId == zoneId:
         zoneId = 'sz'
     return 'phase_%s/dna/%s_%s.pdna' % (phase, hood, zoneId)
Beispiel #13
0
 def enterTutorial(self, branchZone, streetZone, shopZone, hqZone):
     base.localAvatar.cantLeaveGame = 1
     ZoneUtil.overrideOn(branch=branchZone,
                         exteriorList=[streetZone],
                         interiorList=[shopZone, hqZone])
     messenger.send('startTutorial', [shopZone])
     self.acceptOnce('stopTutorial', self.__handleStopTutorial)
     self.acceptOnce('toonArrivedTutorial', self.d_toonArrived)
 def lookupDNAFileName(self, zoneId):
     zoneId = ZoneUtil.getCanonicalZoneId(zoneId)
     hoodId = ZoneUtil.getCanonicalHoodId(zoneId)
     hood = ToontownGlobals.dnaMap[hoodId]
     if hoodId == zoneId:
         zoneId = 'sz'
         phaseNum = ToontownGlobals.phaseMap[hoodId]
     else:
         phaseNum = ToontownGlobals.streetPhaseMap[hoodId]
     return 'phase_%s/dna/%s_%s.pdna' % (phaseNum, hood, zoneId)
 def forcedExit(self, avId):
     target_sz = base.localAvatar.defaultZone
     base.cr.playGame.getPlace().fsm.request('teleportOut', [{'loader': ZoneUtil.getLoaderName(target_sz),
       'where': ZoneUtil.getWhereName(target_sz, 1),
       'how': 'teleportIn',
       'hoodId': target_sz,
       'zoneId': target_sz,
       'shardId': None,
       'avId': -1}], force=1)
     return
Beispiel #16
0
 def lookupDNAFileName(self, zoneId):
     zoneId = ZoneUtil.getCanonicalZoneId(zoneId)
     hoodId = ZoneUtil.getCanonicalHoodId(zoneId)
     hood = ToontownGlobals.dnaMap[hoodId]
     if hoodId == zoneId:
         zoneId = 'sz'
         phaseNum = ToontownGlobals.phaseMap[hoodId]
     else:
         phaseNum = ToontownGlobals.streetPhaseMap[hoodId]
     return 'phase_%s/dna/%s_%s.pdna' % (phaseNum, hood, zoneId)
 def handleWaitForSetZoneResponse(self, requestStatus):
     hoodId = requestStatus['hoodId']
     canonicalHoodId = ZoneUtil.getCanonicalZoneId(hoodId)
     toHoodPhrase = ToontownGlobals.hoodNameMap[canonicalHoodId][0]
     hoodName = ToontownGlobals.hoodNameMap[canonicalHoodId][-1]
     zoneId = requestStatus['zoneId']
     requestStatus['loader'] = 'cogHQLoader' if ZoneUtil.isCogHQZone(hoodId) else requestStatus['loader']
     loaderName = requestStatus['loader']
     avId = requestStatus.get('avId', -1)
     ownerId = requestStatus.get('ownerId', avId)
     if base.config.GetBool('want-qa-regression', 0):
         self.notify.info('QA-REGRESSION: NEIGHBORHOODS: Visit %s' % hoodName)
     count = ToontownGlobals.hoodCountMap[canonicalHoodId]
     if loaderName == 'safeZoneLoader':
         count += ToontownGlobals.safeZoneCountMap[canonicalHoodId]
     elif loaderName == 'townLoader':
         count += ToontownGlobals.townCountMap[canonicalHoodId]
     if not loader.inBulkBlock:
         if hoodId == ToontownGlobals.MyEstate:
             if avId == -1:
                 loader.beginBulkLoad('hood', TTLocalizer.HeadingToYourEstate, count, 1, TTLocalizer.TIP_ESTATE, zoneId)
             else:
                 owner = base.cr.identifyAvatar(ownerId)
                 if owner == None:
                     friend = base.cr.identifyAvatar(avId)
                     if friend != None:
                         avName = friend.getName()
                         loader.beginBulkLoad('hood', TTLocalizer.HeadingToFriend % avName, count, 1, TTLocalizer.TIP_ESTATE, zoneId)
                     else:
                         self.notify.warning("we can't perform this teleport")
                         return
                 else:
                     avName = owner.getName()
                     loader.beginBulkLoad('hood', TTLocalizer.HeadingToEstate % avName, count, 1, TTLocalizer.TIP_ESTATE, zoneId)
         elif ZoneUtil.isCogHQZone(zoneId):
             loader.beginBulkLoad('hood', TTLocalizer.HeadingToHood % {'to': toHoodPhrase,
              'hood': hoodName}, count, 1, TTLocalizer.TIP_COGHQ, zoneId)
         elif ZoneUtil.isGoofySpeedwayZone(zoneId):
             loader.beginBulkLoad('hood', TTLocalizer.HeadingToHood % {'to': toHoodPhrase,
              'hood': hoodName}, count, 1, TTLocalizer.TIP_KARTING, zoneId)
         else:
             loader.beginBulkLoad('hood', TTLocalizer.HeadingToHood % {'to': toHoodPhrase,
              'hood': hoodName}, count, 1, TTLocalizer.TIP_GENERAL, zoneId)
     if hoodId == ToontownGlobals.Tutorial:
         self.loadDnaStoreTutorial()
     else:
         if not hasattr(self, 'dnaStore'):
             self.loadDnaStore()
     hoodClass = self.getHoodClassByNumber(canonicalHoodId)
     self.hood = hoodClass(self.fsm, self.hoodDoneEvent, self.dnaStore, hoodId)
     self.hood.load()
     self.hood.loadLoader(requestStatus)
     if not base.placeBeforeObjects:
         loader.endBulkLoad('hood')
     return
Beispiel #18
0
    def addLinkTunnelHooks(self, hoodPart, nodeList):
        tunnelOriginList = []
        for i in nodeList:
            linkTunnelNPC = i.findAllMatches('**/linktunnel*')
            for p in xrange(linkTunnelNPC.getNumPaths()):
                linkTunnel = linkTunnelNPC.getPath(p)
                name = linkTunnel.getName()
                nameParts = name.split('_')
                hoodStr = nameParts[1]
                zoneStr = nameParts[2]
                hoodId = self.getIdFromName(hoodStr)
                zoneId = int(zoneStr)
                linkSphere = linkTunnel.find('**/tunnel_trigger')
                if linkSphere.isEmpty():
                    linkSphere = linkTunnel.find('**/tunnel_sphere')
                if not linkSphere.isEmpty():
                    cnode = linkSphere.node()
                    cnode.setName('tunnel_trigger_' + hoodStr + '_' + zoneStr)
                    cnode.setCollideMask(ToontownGlobals.WallBitmask
                                         | ToontownGlobals.GhostBitmask)
                else:
                    linkSphere = linkTunnel.find('**/tunnel_trigger_' +
                                                 hoodStr + '_' + zoneStr)
                    if linkSphere.isEmpty():
                        self.notify.error('tunnel_trigger not found')
                tunnelOrigin = linkTunnel.find('**/tunnel_origin')
                if tunnelOrigin.isEmpty():
                    self.notify.error('tunnel_origin not found')
                tunnelOriginPlaceHolder = render.attachNewNode('toph_' +
                                                               hoodStr + '_' +
                                                               zoneStr)
                tunnelOriginList.append(tunnelOriginPlaceHolder)
                tunnelOriginPlaceHolder.setPos(tunnelOrigin.getPos(render))
                tunnelOriginPlaceHolder.setHpr(tunnelOrigin.getHpr(render))
                hood = base.localAvatar.cr.playGame.hood
                if ZoneUtil.tutorialDict:
                    how = 'teleportIn'
                    tutorialFlag = 1
                else:
                    how = 'tunnelIn'
                    tutorialFlag = 0
                hoodPart.accept('enter' + linkSphere.getName(),
                                hoodPart.handleEnterTunnel,
                                [{
                                    'loader': ZoneUtil.getLoaderName(zoneId),
                                    'where': ZoneUtil.getToonWhereName(zoneId),
                                    'how': how,
                                    'hoodId': hoodId,
                                    'zoneId': zoneId,
                                    'shardId': None,
                                    'tunnelOrigin': tunnelOriginPlaceHolder,
                                    'tutorial': tutorialFlag
                                }])

        return tunnelOriginList
 def kickToonsOut(self):
     if not self.localToonOnBoard:
         zoneId = self.cr.playGame.hood.hoodId
         self.cr.playGame.getPlace().fsm.request('teleportOut', [{'loader': ZoneUtil.getLoaderName(zoneId),
           'where': ZoneUtil.getToonWhereName(zoneId),
           'how': 'teleportIn',
           'hoodId': zoneId,
           'zoneId': zoneId,
           'shardId': None,
           'avId': -1}])
     return
 def load(self, zoneId):
     self.zoneId = zoneId
     self.parentFSMState.addChild(self.fsm)
     self.loadBattleAnims()
     self.branchZone = ZoneUtil.getBranchZone(zoneId)
     self.canonicalBranchZone = ZoneUtil.getCanonicalBranchZone(zoneId)
     self.music = base.loadMusic(self.musicFile)
     self.activityMusic = base.loadMusic(self.activityMusicFile)
     self.battleMusic = base.loadMusic('phase_3.5/audio/bgm/encntr_general_bg.ogg')
     self.townBattle = TownBattle.TownBattle(self.townBattleDoneEvent)
     self.townBattle.load()
 def getRequestStatus(self):
     zoneId = self.otherZoneId
     request = {'loader': ZoneUtil.getBranchLoaderName(zoneId),
      'where': ZoneUtil.getToonWhereName(zoneId),
      'how': 'doorIn',
      'hoodId': ZoneUtil.getHoodId(zoneId),
      'zoneId': zoneId,
      'shardId': None,
      'avId': -1,
      'allowRedirect': 0,
      'doorDoId': self.otherDoId}
     return request
 def enterReward(self, ts = 0):
     base.localAvatar.b_setParent(ToontownGlobals.SPHidden)
     request = {'loader': ZoneUtil.getBranchLoaderName(self.extZoneId),
      'where': ZoneUtil.getToonWhereName(self.extZoneId),
      'how': 'elevatorIn',
      'hoodId': ZoneUtil.getHoodId(self.extZoneId),
      'zoneId': self.extZoneId,
      'shardId': None,
      'avId': base.localAvatar.doId,
      'bldgDoId': self.distBldgDoId}
     messenger.send('DSIDoneEvent', [request])
     return
Beispiel #23
0
 def load(self, zoneId):
     self.zoneId = zoneId
     self.parentFSMState.addChild(self.fsm)
     self.loadBattleAnims()
     self.branchZone = ZoneUtil.getBranchZone(zoneId)
     self.canonicalBranchZone = ZoneUtil.getCanonicalBranchZone(zoneId)
     self.music = base.loadMusic(self.musicFile)
     self.activityMusic = base.loadMusic(self.activityMusicFile)
     self.battleMusic = base.loadMusic(
         'phase_3.5/audio/bgm/encntr_general_bg.ogg')
     self.townBattle = TownBattle.TownBattle(self.townBattleDoneEvent)
     self.townBattle.load()
 def localToonDied(self):
     target_sz = ZoneUtil.getSafeZoneId(localAvatar.defaultZone)
     place = self.cr.playGame.getPlace()
     place.fsm.request('died', [{'loader': ZoneUtil.getLoaderName(target_sz),
       'where': ZoneUtil.getWhereName(target_sz, 1),
       'how': 'teleportIn',
       'hoodId': target_sz,
       'zoneId': target_sz,
       'shardId': None,
       'avId': -1,
       'battle': 1}])
     return
Beispiel #25
0
    def updateQuestInfo(self):
        for marker in self.buildingMarkers:
            marker.destroy()

        self.buildingMarkers = []

        for (i, questDesc) in enumerate(self.av.quests):
            mapIndex = i + 1
            quest = Quests.getQuest(questDesc[0])
            toNpcId = questDesc[2]

            completed = quest.getCompletionStatus(self.av,
                                                  questDesc) == Quests.COMPLETE
            if not completed:
                if quest.getType() == Quests.RecoverItemQuest:
                    if quest.getHolder() == Quests.AnyFish:
                        self.putBuildingMarker(self.fishingSpotInfo,
                                               mapIndex=mapIndex)
                    continue
                elif quest.getType() not in (Quests.DeliverGagQuest,
                                             Quests.DeliverItemQuest,
                                             Quests.VisitQuest,
                                             Quests.TrackChoiceQuest):
                    continue

            if toNpcId == Quests.ToonHQ:
                self.putBuildingMarker(self.hqPosInfo, mapIndex=mapIndex)
                continue

            npcZoneId = NPCToons.getNPCZone(toNpcId)
            hoodId = ZoneUtil.getCanonicalHoodId(npcZoneId)
            branchId = ZoneUtil.getCanonicalBranchZone(npcZoneId)

            if (self.hoodId != hoodId) or (self.zoneId != branchId):
                continue

            for blockIndex in xrange(
                    base.cr.playGame.dnaStore.getNumBlockNumbers()):
                blockNumber = base.cr.playGame.dnaStore.getBlockNumberAt(
                    blockIndex)
                zoneId = base.cr.playGame.dnaStore.getZoneFromBlockNumber(
                    blockNumber)
                interiorZoneId = (zoneId - (zoneId % 100)) + 500 + blockNumber
                if npcZoneId == interiorZoneId:
                    self.putBuildingMarker(
                        base.cr.playGame.dnaStore.getDoorPosHprFromBlockNumber(
                            blockNumber).getPos(render),
                        base.cr.playGame.dnaStore.getDoorPosHprFromBlockNumber(
                            blockNumber).getHpr(render),
                        mapIndex=mapIndex,
                        zoneId=zoneId)
Beispiel #26
0
 def forcedExit(self, avId):
     target_sz = base.localAvatar.defaultZone
     base.cr.playGame.getPlace().fsm.request(
         'teleportOut', [{
             'loader': ZoneUtil.getLoaderName(target_sz),
             'where': ZoneUtil.getWhereName(target_sz, 1),
             'how': 'teleportIn',
             'hoodId': target_sz,
             'zoneId': target_sz,
             'shardId': None,
             'avId': -1
         }],
         force=1)
     return
Beispiel #27
0
 def localToonDied(self):
     target_sz = ZoneUtil.getSafeZoneId(localAvatar.defaultZone)
     place = self.cr.playGame.getPlace()
     place.fsm.request('died', [{
         'loader': ZoneUtil.getLoaderName(target_sz),
         'where': ZoneUtil.getWhereName(target_sz, 1),
         'how': 'teleportIn',
         'hoodId': target_sz,
         'zoneId': target_sz,
         'shardId': None,
         'avId': -1,
         'battle': 1
     }])
     return
Beispiel #28
0
 def enterReward(self, ts=0):
     base.localAvatar.b_setParent(ToontownGlobals.SPHidden)
     request = {
         'loader': ZoneUtil.getBranchLoaderName(self.extZoneId),
         'where': ZoneUtil.getToonWhereName(self.extZoneId),
         'how': 'elevatorIn',
         'hoodId': ZoneUtil.getHoodId(self.extZoneId),
         'zoneId': self.extZoneId,
         'shardId': None,
         'avId': base.localAvatar.doId,
         'bldgDoId': self.distBldgDoId
     }
     messenger.send('DSIDoneEvent', [request])
     return
 def exitCogdoBuilding(self):
     if base.localAvatar.hp < 0:
         return
     base.localAvatar.b_setParent(ToontownGlobals.SPHidden)
     request = {'loader': ZoneUtil.getBranchLoaderName(self.extZoneId),
      'where': ZoneUtil.getToonWhereName(self.extZoneId),
      'how': 'elevatorIn',
      'hoodId': ZoneUtil.getHoodId(self.extZoneId),
      'zoneId': self.extZoneId,
      'shardId': None,
      'avId': -1,
      'bldgDoId': self.distBldgDoId}
     messenger.send('DSIDoneEvent', [request])
     return
Beispiel #30
0
 def getRequestStatus(self):
     zoneId = self.otherZoneId
     request = {
         'loader': ZoneUtil.getBranchLoaderName(zoneId),
         'where': ZoneUtil.getToonWhereName(zoneId),
         'how': 'doorIn',
         'hoodId': ZoneUtil.getHoodId(zoneId),
         'zoneId': zoneId,
         'shardId': None,
         'avId': -1,
         'allowRedirect': 0,
         'doorDoId': self.otherDoId
     }
     return request
    def spawnTitleText(self, zoneId, floorNum=None):
        if ZoneUtil.isMintInteriorZone(zoneId):
            text = '%s\n%s' % (ToontownGlobals.StreetNames[zoneId][-1], TTLocalizer.MintFloorTitle % (floorNum + 1))
            self.doSpawnTitleText(text)
            return

        CogHood.spawnTitleText(self, zoneId)
 def setup(self):
     self.dnaStore = base.cr.playGame.dnaStore
     self.randomGenerator = random.Random()
     self.randomGenerator.seed(self.zoneId)
     self.interior = loader.loadModel('phase_4/models/modules/PetShopInterior')
     self.interior.reparentTo(render)
     self.fish = Actor.Actor('phase_4/models/props/interiorfish-zero', {'swim': 'phase_4/models/props/interiorfish-swim'})
     self.fish.reparentTo(self.interior)
     self.fish.setColorScale(0.8, 0.9, 1, 0.8)
     self.fish.setScale(0.8)
     self.fish.setPos(0, 6, -4)
     self.fish.setPlayRate(0.7, 'swim')
     self.fish.loop('swim')
     hoodId = ZoneUtil.getCanonicalHoodId(self.zoneId)
     self.colors = ToonInteriorColors.colors[hoodId]
     self.replaceRandomInModel(self.interior)
     door = self.chooseDoor()
     doorOrigin = render.find('**/door_origin;+s')
     doorNP = door.copyTo(doorOrigin)
     doorOrigin.setScale(0.8, 0.8, 0.8)
     doorOrigin.setPos(doorOrigin, 0, -0.25, 0)
     doorColor = self.randomGenerator.choice(self.colors['TI_door'])
     setupDoor(doorNP, self.interior, doorOrigin, self.dnaStore, str(self.block), doorColor)
     doorFrame = doorNP.find('door_*_flat')
     doorFrame.wrtReparentTo(self.interior)
     doorFrame.setColor(doorColor)
     del self.colors
     del self.dnaStore
     del self.randomGenerator
     self.interior.flattenMedium()
     for npcToon in self.cr.doFindAllInstances(DistributedNPCToonBase):
         npcToon.initToonState()
Beispiel #33
0
 def createStartingBlocks(self):
     self.racingPads = []
     self.viewingPads = []
     racingPadGroups = []
     viewingPadGroups = []
     for zoneId in self.getZoneTable():
         dnaData = self.air.dnaDataMap.get(zoneId, None)
         if dnaData.getName() == 'root':
             area = ZoneUtil.getCanonicalZoneId(zoneId)
             (foundRacingPads, foundRacingPadGroups) = self.findRacingPads(
                 dnaData, zoneId, area, padType='racing_pad')
             (foundViewingPads,
              foundViewingPadGroups) = self.findRacingPads(
                  dnaData, zoneId, area, padType='viewing_pad')
             self.racingPads.extend(foundRacingPads)
             racingPadGroups.extend(foundRacingPadGroups)
             self.viewingPads.extend(foundViewingPads)
             viewingPadGroups.extend(foundViewingPadGroups)
     self.startingBlocks = []
     for (dnaGroup, racePad) in zip(racingPadGroups, self.racingPads):
         foundStartingBlocks = self.findStartingBlocks(dnaGroup, racePad)
         self.startingBlocks.extend(foundStartingBlocks)
         for startingBlock in foundStartingBlocks:
             racePad.addStartingBlock(startingBlock)
     self.viewingBlocks = []
     for (dnaGroup, viewPad) in zip(viewingPadGroups, self.viewingPads):
         foundViewingBlocks = self.findStartingBlocks(dnaGroup, viewPad)
         self.viewingBlocks.extend(foundViewingBlocks)
         for viewingBlock in foundViewingBlocks:
             viewPad.addStartingBlock(viewingBlock)
        def makePetList(self):
            self.numPets = len(self.petSeeds)
            self.curPet = 0
            self.petDNA = []
            self.petName = []
            self.petDesc = []
            self.petCost = []
            for i in xrange(self.numPets):
                random.seed(self.petSeeds[i])
                zoneId = ZoneUtil.getCanonicalSafeZoneId(base.localAvatar.getZoneId())
                name, dna, traitSeed = PetUtil.getPetInfoFromSeed(self.petSeeds[i], zoneId)
                cost = PetUtil.getPetCostFromSeed(self.petSeeds[i], zoneId)
                traits = PetTraits.PetTraits(traitSeed, zoneId)
                traitList = traits.getExtremeTraitDescriptions()
                numGenders = len(PetDNA.PetGenders)
                gender = i % numGenders
                PetDNA.setGender(dna, gender)
                self.petDNA.append(dna)
                self.petName.append(TTLocalizer.PetshopUnknownName)
                descList = []
                descList.append(TTLocalizer.PetshopDescGender % PetDNA.getGenderString(gender=gender))
                if traitList:
                    descList.append(TTLocalizer.PetshopDescTrait % traitList[0])
                else:
                    descList.append(TTLocalizer.PetshopDescTrait % TTLocalizer.PetshopDescStandard)
                traitList.extend(['',
                 '',
                 '',
                 ''])
                for trait in traitList[1:4]:
                    descList.append('\t%s' % trait)

                descList.append(TTLocalizer.PetshopDescCost % cost)
                self.petDesc.append('\n'.join(descList))
                self.petCost.append(cost)
 def setup(self):
     self.dnaStore = base.cr.playGame.dnaStore
     self.randomGenerator = random.Random()
     self.randomGenerator.seed(self.zoneId)
     self.interior = loader.loadModel('phase_3.5/models/modules/toon_interior_tutorial')
     self.interior.reparentTo(render)
     dnaStore = DNAStorage()
     node = loader.loadDNAFile(self.cr.playGame.hood.dnaStore, 'phase_3.5/dna/tutorial_street.pdna')
     self.street = render.attachNewNode(node)
     self.street.flattenMedium()
     self.street.setPosHpr(-17, 42, -0.5, 180, 0, 0)
     self.street.find('**/tb2:toon_landmark_TT_A1_DNARoot').stash()
     self.street.find('**/tb1:toon_landmark_hqTT_DNARoot/**/door_flat_0').stash()
     self.street.findAllMatches('**/+CollisionNode').stash()
     self.skyFile = 'phase_3.5/models/props/TT_sky'
     self.sky = loader.loadModel(self.skyFile)
     self.sky.setScale(0.8)
     self.sky.reparentTo(render)
     self.sky.setDepthTest(0)
     self.sky.setDepthWrite(0)
     self.sky.setBin('background', 100)
     self.sky.find('**/Sky').reparentTo(self.sky, -1)
     hoodId = ZoneUtil.getCanonicalHoodId(self.zoneId)
     self.colors = ToonInteriorColors.colors[hoodId]
     self.replaceRandomInModel(self.interior)
     doorModelName = 'door_double_round_ul'
     if doorModelName[-1:] == 'r':
         doorModelName = doorModelName[:-1] + 'l'
     else:
         doorModelName = doorModelName[:-1] + 'r'
     door = self.dnaStore.findNode(doorModelName)
     door_origin = render.find('**/door_origin;+s')
     doorNP = door.copyTo(door_origin)
     door_origin.setScale(0.8, 0.8, 0.8)
     door_origin.setPos(door_origin, 0, -0.025, 0)
     color = self.randomGenerator.choice(self.colors['TI_door'])
     setupDoor(doorNP, self.interior, door_origin, self.dnaStore, str(self.block), color)
     doorFrame = doorNP.find('door_*_flat')
     doorFrame.wrtReparentTo(self.interior)
     doorFrame.setColor(color)
     del self.colors
     del self.dnaStore
     del self.randomGenerator
     self.interior.flattenMedium()
     npcOrigin = self.interior.find('**/npc_origin_' + `(self.cr.doId2do[self.npcId].posIndex)`)
     if not npcOrigin.isEmpty():
         self.cr.doId2do[self.npcId].reparentTo(npcOrigin)
         self.cr.doId2do[self.npcId].clearMat()
     self.createSuit()
     base.localAvatar.setPosHpr(-2, 12, 0, -10, 0, 0)
     self.cr.doId2do[self.npcId].setChatAbsolute(TTLocalizer.QuestScript101_0, CFSpeech)
     place = base.cr.playGame.getPlace()
     if place and hasattr(place, 'fsm') and place.fsm.getCurrentState().getName():
         self.notify.info('Tutorial movie: Place ready.')
         self.playMovie()
     else:
         self.notify.info('Tutorial movie: Waiting for place=%s, has fsm=%s' % (place, hasattr(place, 'fsm')))
         if hasattr(place, 'fsm'):
             self.notify.info('Tutorial movie: place state=%s' % place.fsm.getCurrentState().getName())
         self.acceptOnce('enterTutorialInterior', self.playMovie)
 def enterToon(self):
     self.d_setState('toon')
     (exteriorZoneId, interiorZoneId) = self.getExteriorAndInteriorZoneId()
     if simbase.config.GetBool(
             'want-new-toonhall',
             1) and ZoneUtil.getCanonicalZoneId(interiorZoneId) == ToonHall:
         self.interior = DistributedToonHallInteriorAI.DistributedToonHallInteriorAI(
             self.block, self.air, interiorZoneId, self)
     else:
         self.interior = DistributedToonInteriorAI.DistributedToonInteriorAI(
             self.block, self.air, interiorZoneId, self)
     self.interior.generateWithRequired(interiorZoneId)
     door = self.createExteriorDoor()
     insideDoor = DistributedDoorAI.DistributedDoorAI(
         self.air, self.block, DoorTypes.INT_STANDARD)
     door.setOtherDoor(insideDoor)
     insideDoor.setOtherDoor(door)
     door.zoneId = exteriorZoneId
     insideDoor.zoneId = interiorZoneId
     door.generateWithRequired(exteriorZoneId)
     insideDoor.generateWithRequired(interiorZoneId)
     self.door = door
     self.insideDoor = insideDoor
     self.becameSuitTime = 0
     self.knockKnock = DistributedKnockKnockDoorAI.DistributedKnockKnockDoorAI(
         self.air, self.block)
     self.knockKnock.generateWithRequired(exteriorZoneId)
     self.air.writeServerEvent('building-toon', self.doId,
                               '%s|%s' % (self.zoneId, self.block))
Beispiel #37
0
 def __init__(self, air, zoneId):
     DistributedObjectAI.DistributedObjectAI.__init__(self, air)
     SuitPlannerBase.SuitPlannerBase.__init__(self)
     self.air = air
     self.zoneId = zoneId
     self.canonicalZoneId = ZoneUtil.getCanonicalZoneId(zoneId)
     if simbase.air.wantCogdominiums:
         if not hasattr(self.__class__, 'CogdoPopAdjusted'):
             self.__class__.CogdoPopAdjusted = True
             for index in xrange(len(self.SuitHoodInfo)):
                 SuitBuildingGlobals.buildingMinMax[self.zoneId][0] = int(
                     0.5 + self.CogdoPopFactor *
                     SuitBuildingGlobals.buildingMinMax[self.zoneId][0])
                 SuitBuildingGlobals.buildingMinMax[self.zoneId][1] = int(
                     0.5 + self.CogdoPopFactor *
                     SuitBuildingGlobals.buildingMinMax[self.zoneId][1])
     self.hoodInfoIdx = -1
     for index in xrange(len(self.SuitHoodInfo)):
         currHoodInfo = self.SuitHoodInfo[index]
         if currHoodInfo[self.SUIT_HOOD_INFO_ZONE] == self.canonicalZoneId:
             self.hoodInfoIdx = index
     self.currDesired = None
     self.baseNumSuits = (
         self.SuitHoodInfo[self.hoodInfoIdx][self.SUIT_HOOD_INFO_MIN] +
         self.SuitHoodInfo[self.hoodInfoIdx][self.SUIT_HOOD_INFO_MAX]) / 2
     self.targetNumSuitBuildings = SuitBuildingGlobals.buildingMinMax[
         self.zoneId][0]
     self.pendingBuildingTracks = []
     self.pendingBuildingHeights = []
     self.suitList = []
     self.numFlyInSuits = 0
     self.numBuildingSuits = 0
     self.numAttemptingTakeover = 0
     self.zoneInfo = {}
     self.zoneIdToPointMap = None
     self.cogHQDoors = []
     self.battleList = []
     self.battleMgr = BattleManagerAI.BattleManagerAI(self.air)
     self.setupDNA()
     if self.notify.getDebug():
         self.notify.debug('Creating a building manager AI in zone' +
                           str(self.zoneId))
     self.buildingMgr = self.air.buildingManagers.get(self.zoneId)
     if self.buildingMgr:
         (blocks, hqBlocks, gagshopBlocks, petshopBlocks,
          kartshopBlocks) = self.buildingMgr.getDNABlockLists()
         for currBlock in blocks:
             bldg = self.buildingMgr.getBuilding(currBlock)
             bldg.setSuitPlannerExt(self)
     self.dnaStore.resetBlockNumbers()
     self.initBuildingsAndPoints()
     numSuits = simbase.config.GetInt('suit-count', -1)
     if numSuits >= 0:
         self.currDesired = numSuits
     suitHood = simbase.config.GetInt('suits-only-in-hood', -1)
     if suitHood >= 0:
         if self.SuitHoodInfo[self.hoodInfoIdx][
                 self.SUIT_HOOD_INFO_ZONE] != suitHood:
             self.currDesired = 0
     self.suitCountAdjust = 0
 def __init__(self, doneEvent, petSeed, petNameIndex):
     zoneId = ZoneUtil.getCanonicalSafeZoneId(base.localAvatar.getZoneId())
     name, dna, traitSeed = PetUtil.getPetInfoFromSeed(petSeed, zoneId)
     name = TTLocalizer.getPetName(petNameIndex)
     cost = PetUtil.getPetCostFromSeed(petSeed, zoneId)
     model = loader.loadModel('phase_4/models/gui/AdoptPet')
     modelPos = (0, 0, -0.3)
     modelScale = 0.055
     DirectFrame.__init__(self, relief=None, state='normal', geom=model, geom_color=ToontownGlobals.GlobalDialogColor, geom_scale=modelScale, frameSize=(-1, 1, -1, 1), pos=modelPos, text=TTLocalizer.PetshopAdoptConfirm % (name, cost), text_wordwrap=12, text_scale=0.05, text_pos=(0, 0.55), text_fg=text0Color)
     self.initialiseoptions(PetshopGUI.AdoptPetDlg)
     self.petView = self.attachNewNode('petView')
     self.petView.setPos(-0.13, 0, 0.8)
     self.petModel = Pet.Pet(forGui=1)
     self.petModel.setDNA(dna)
     self.petModel.fitAndCenterHead(0.395, forGui=1)
     self.petModel.reparentTo(self.petView)
     self.petModel.setH(130)
     self.petModel.setScale(0.125)
     self.petModel.enterNeutralHappy()
     self.moneyDisplay = DirectLabel(parent=self, relief=None, text=str(base.localAvatar.getTotalMoney()), text_scale=0.075, text_fg=(0.95, 0.95, 0, 1), text_shadow=(0, 0, 0, 1), text_pos=(0.225, 0.33), text_font=ToontownGlobals.getSignFont())
     self.accept(localAvatar.uniqueName('moneyChange'), self.__moneyChange)
     self.accept(localAvatar.uniqueName('bankMoneyChange'), self.__moneyChange)
     okImageList = (model.find('**/CheckButtonUp'), model.find('**/CheckButtonDown'), model.find('**/CheckButtonRollover'))
     cancelImageList = (model.find('**/CancelButtonUp'), model.find('**/CancelButtonDown'), model.find('**/CancelRollover'))
     cancelIcon = model.find('**/CancelIcon')
     checkIcon = model.find('**/CheckIcon')
     self.cancelButton = DirectButton(parent=self, relief=None, image=cancelImageList, geom=cancelIcon, scale=modelScale, text=('', TTLocalizer.PetshopGoBack), text_pos=(-5.8, 4.4), text_scale=0.7, pressEffect=False, command=lambda : messenger.send(doneEvent, [0]))
     self.okButton = DirectButton(parent=self, relief=None, image=okImageList, geom=checkIcon, scale=modelScale, text=('', TTLocalizer.PetshopAdopt), text_pos=(5.8, 4.4), text_scale=0.7, pressEffect=False, command=lambda : messenger.send(doneEvent, [1]))
     model.removeNode()
     return
    def requestBattle(self, zoneId, suit, toonId):
        self.notify.debug('requestBattle() - zone: %s suit: %s toon: %s' % (zoneId, suit.doId, toonId))
        canonicalZoneId = ZoneUtil.getCanonicalZoneId(zoneId)
        if canonicalZoneId not in self.battlePosDict:
            return 0
        toon = self.air.doId2do.get(toonId)
        if toon.getBattleId() > 0:
            self.notify.warning('We tried to request a battle when the toon was already in battle')
            return 0
        if toon:
            if hasattr(toon, 'doId'):
                toon.b_setBattleId(toonId)

        pos = self.battlePosDict[canonicalZoneId]

        interactivePropTrackBonus = -1
        if config.GetBool('props-buff-battles', True) and canonicalZoneId in self.cellToGagBonusDict:
            interactivePropTrackBonus = self.cellToGagBonusDict[canonicalZoneId]

        self.battleMgr.newBattle(
            zoneId, zoneId, pos, suit, toonId, self.__battleFinished,
            self.SuitHoodInfo[self.hoodInfoIdx][self.SUIT_HOOD_INFO_SMAX],
            interactivePropTrackBonus)
        for currOther in self.zoneInfo[zoneId]:
            self.notify.debug('Found suit %s in this new battle zone %s' % (currOther.getDoId(), zoneId))
            if currOther != suit:
                if currOther.pathState == 1 and currOther.legType == SuitLeg.TWalk:
                    self.checkForBattle(zoneId, currOther)
        return 1
 def handleMintWinEvent(self):
     MintInterior.notify.debug('handleMintWinEvent')
     if base.cr.playGame.getPlace().fsm.getCurrentState().getName() == 'died':
         return
     self.mintDefeated = 1
     if 1:
         zoneId = ZoneUtil.getHoodId(self.zoneId)
     else:
         zoneId = ZoneUtil.getSafeZoneId(base.localAvatar.defaultZone)
     self.fsm.request('teleportOut', [{'loader': ZoneUtil.getLoaderName(zoneId),
                                      'where': ZoneUtil.getToonWhereName(zoneId),
                                      'how': 'teleportIn',
                                      'hoodId': zoneId,
                                      'zoneId': zoneId,
                                      'shardId': None,
                                      'avId': -1}])
 def createStartingBlocks(self):
     self.racingPads = []
     self.viewingPads = []
     racingPadGroups = []
     viewingPadGroups = []
     for zoneId in self.getZoneTable():
         dnaData = self.air.dnaDataMap.get(zoneId, None)
         if dnaData.getName() == 'root':
             area = ZoneUtil.getCanonicalZoneId(zoneId)
             (foundRacingPads, foundRacingPadGroups) = self.findRacingPads(dnaData, zoneId, area, padType='racing_pad')
             (foundViewingPads, foundViewingPadGroups) = self.findRacingPads(dnaData, zoneId, area, padType='viewing_pad')
             self.racingPads.extend(foundRacingPads)
             racingPadGroups.extend(foundRacingPadGroups)
             self.viewingPads.extend(foundViewingPads)
             viewingPadGroups.extend(foundViewingPadGroups)
     self.startingBlocks = []
     for (dnaGroup, racePad) in zip(racingPadGroups, self.racingPads):
         foundStartingBlocks = self.findStartingBlocks(dnaGroup, racePad)
         self.startingBlocks.extend(foundStartingBlocks)
         for startingBlock in foundStartingBlocks:
             racePad.addStartingBlock(startingBlock)
     self.viewingBlocks = []
     for (dnaGroup, viewPad) in zip(viewingPadGroups, self.viewingPads):
         foundViewingBlocks = self.findStartingBlocks(dnaGroup, viewPad)
         self.viewingBlocks.extend(foundViewingBlocks)
         for viewingBlock in foundViewingBlocks:
             viewPad.addStartingBlock(viewingBlock)
    def enter(self, requestStatus):
        CogHQExterior.CogHQExterior.enter(self, requestStatus)

        for train in self.trains:
            train.show()

        # Load the CogHQ DNA file:
        dnaStore = DNAStorage()
        dnaFileName = self.genDNAFileName(self.zoneId)
        loadDNAFileAI(dnaStore, dnaFileName)

        # Collect all of the vis group zone IDs:
        self.zoneVisDict = {}
        for i in xrange(dnaStore.getNumDNAVisGroupsAI()):
            groupFullName = dnaStore.getDNAVisGroupName(i)
            visGroup = dnaStore.getDNAVisGroupAI(i)
            visZoneId = int(base.cr.hoodMgr.extractGroupName(groupFullName))
            visibles = []
            for i in xrange(visGroup.getNumVisibles()):
                visibles.append(int(visGroup.getVisible(i)))
            visibles.append(ZoneUtil.getBranchZone(visZoneId))
            self.zoneVisDict[visZoneId] = visibles

        # Next, we want interest in all vis groups due to this being a Cog HQ:
        base.cr.sendSetZoneMsg(self.zoneId, self.zoneVisDict.values()[0])
    def enter(self, requestStatus):
        CogHQExterior.CogHQExterior.enter(self, requestStatus)

        for train in self.trains:
            train.show()

        # Load the CogHQ DNA file:
        dnaStore = DNAStorage()
        dnaFileName = self.genDNAFileName(self.zoneId)
        loadDNAFileAI(dnaStore, dnaFileName)

        # Collect all of the vis group zone IDs:
        self.zoneVisDict = {}
        for i in xrange(dnaStore.getNumDNAVisGroupsAI()):
            groupFullName = dnaStore.getDNAVisGroupName(i)
            visGroup = dnaStore.getDNAVisGroupAI(i)
            visZoneId = int(base.cr.hoodMgr.extractGroupName(groupFullName))
            visibles = []
            for i in xrange(visGroup.getNumVisibles()):
                visibles.append(int(visGroup.getVisible(i)))
            visibles.append(ZoneUtil.getBranchZone(visZoneId))
            self.zoneVisDict[visZoneId] = visibles

        # Next, we want interest in all vis groups due to this being a Cog HQ:
        base.cr.sendSetZoneMsg(self.zoneId, self.zoneVisDict.values()[0])
    def enter(self, requestStatus, visibilityFlag = 1, arrowsOn = 1):
        teleportDebug(requestStatus, 'Street.enter(%s)' % (requestStatus,))
        self._ttfToken = None
        self.fsm.enterInitialState()
        base.playMusic(self.loader.music, looping=1, volume=0.8)
        self.loader.geom.reparentTo(render)
        if visibilityFlag:
            self.visibilityOn()
        base.localAvatar.setGeom(self.loader.geom)
        base.localAvatar.setOnLevelGround(1)
        self._telemLimiter = TLGatherAllAvs('Street', RotationLimitToH)
        NametagGlobals.setMasterArrowsOn(arrowsOn)
        self.zone = ZoneUtil.getBranchZone(requestStatus['zoneId'])

        def __lightDecorationOn__():
            geom = base.cr.playGame.getPlace().loader.geom
            self.halloweenLights = geom.findAllMatches('**/*light*')
            self.halloweenLights += geom.findAllMatches('**/*lamp*')
            self.halloweenLights += geom.findAllMatches('**/prop_snow_tree*')
            for light in self.halloweenLights:
                light.setColorScaleOff(1)

        if base.cr.newsManager.isHolidayRunning(ToontownGlobals.HALLOWEEN) and self.loader.hood.spookySkyFile:
            lightsOff = Sequence(LerpColorScaleInterval(base.cr.playGame.hood.loader.geom, 0.1, Vec4(0.55, 0.55, 0.65, 1)), Func(self.loader.hood.startSpookySky))
            lightsOff.start()
        else:
            self.loader.hood.startSky()
            lightsOn = LerpColorScaleInterval(base.cr.playGame.hood.loader.geom, 0.1, Vec4(1, 1, 1, 1))
            lightsOn.start()
        self.accept('doorDoneEvent', self.handleDoorDoneEvent)
        self.accept('DistributedDoor_doorTrigger', self.handleDoorTrigger)
        self.enterZone(requestStatus['zoneId'])
        self.tunnelOriginList = base.cr.hoodMgr.addLinkTunnelHooks(self, self.loader.nodeList)
        self.fsm.request(requestStatus['how'], [requestStatus])
Beispiel #45
0
 def exitDoorEnterClosing(self, ts):
     doorFrameHoleLeft = self.findDoorNode('doorFrameHoleLeft')
     if doorFrameHoleLeft.isEmpty():
         self.notify.warning('enterOpening(): did not find flatDoors')
         return
     if ZoneUtil.isInterior(self.zoneId):
         doorFrameHoleLeft.setColor(1.0, 1.0, 1.0, 1.0)
     if self.leftSwing:
         h = -100
     else:
         h = 100
     leftDoor = self.findDoorNode('leftDoor')
     if not leftDoor.isEmpty():
         otherNP = self.getDoorNodePath()
         trackName = 'doorExitTrack-%d' % self.doId
         self.doorExitTrack = Parallel(Sequence(
             LerpHprInterval(nodePath=leftDoor,
                             duration=1.0,
                             hpr=VBase3(0, 0, 0),
                             startHpr=VBase3(h, 0, 0),
                             other=otherNP,
                             blendType='easeInOut'),
             Func(doorFrameHoleLeft.hide), Func(self.hideIfHasFlat,
                                                leftDoor)),
                                       Sequence(
                                           Wait(0.5),
                                           SoundInterval(self.closeSfx,
                                                         node=leftDoor)),
                                       name=trackName)
         self.doorExitTrack.start(ts)
 def setup(self):
     self.dnaStore = base.cr.playGame.dnaStore
     self.randomGenerator = random.Random()
     self.randomGenerator.seed(self.zoneId)
     self.interior = loader.loadModel(
         'phase_4/models/modules/gagShop_interior')
     self.interior.reparentTo(render)
     hoodId = ZoneUtil.getCanonicalHoodId(self.zoneId)
     self.colors = ToonInteriorColors.colors[hoodId]
     self.replaceRandomInModel(self.interior)
     door = self.chooseDoor()
     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.randomGenerator.choice(self.colors['TI_door'])
     setupDoor(doorNP, self.interior, doorOrigin, self.dnaStore,
               str(self.block), doorColor)
     doorFrame = doorNP.find('door_*_flat')
     doorFrame.wrtReparentTo(self.interior)
     doorFrame.setColor(doorColor)
     del self.colors
     del self.dnaStore
     del self.randomGenerator
     self.interior.flattenMedium()
     for npcToon in self.cr.doFindAllInstances(DistributedNPCToonBase):
         npcToon.initToonState()
 def petAdopted(self, petNum, nameIndex):
     avId = self.air.getAvatarIdFromSender()
     if self.busy != avId:
         self.air.writeServerEvent('suspicious', avId, 'DistributedNPCPetshopAI.petAdopted busy with %s' % self.busy)
         self.notify.warning('somebody called petAdopted that I was not busy with! avId: %s' % avId)
         return
     av = simbase.air.doId2do.get(avId)
     if av:
         from src.toontown.hood import ZoneUtil
         zoneId = ZoneUtil.getCanonicalSafeZoneId(self.zoneId)
         if petNum not in xrange(0, len(self.petSeeds)):
             self.air.writeServerEvent('suspicious', avId, 'DistributedNPCPetshopAI.petAdopted and no such pet!')
             self.notify.warning('somebody called petAdopted on a non-existent pet! avId: %s' % avId)
             return
         cost = PetUtil.getPetCostFromSeed(self.petSeeds[petNum], zoneId)
         if cost > av.getTotalMoney():
             self.air.writeServerEvent('suspicious', avId, "DistributedNPCPetshopAI.petAdopted and toon doesn't have enough money!")
             self.notify.warning("somebody called petAdopted and didn't have enough money to adopt! avId: %s" % avId)
             return
         if av.petId != 0:
             simbase.air.petMgr.deleteToonsPet(avId)
         gender = petNum % len(PetDNA.PetGenders)
         if nameIndex not in xrange(0, len(TTLocalizer.PetNameDictionary) - 1):
             self.air.writeServerEvent('avoid_crash', avId, "DistributedNPCPetclerkAI.petAdopted and didn't have valid nameIndex!")
             self.notify.warning("somebody called petAdopted and didn't have valid nameIndex to adopt! avId: %s" % avId)
             return
         simbase.air.petMgr.createNewPetFromSeed(avId, self.petSeeds[petNum], nameIndex=nameIndex, gender=gender, safeZoneId=zoneId)
         self.notify.warning("Created new pet from seed")
         self.transactionType = 'adopt'
         bankPrice = min(av.getBankMoney(), cost)
         walletPrice = cost - bankPrice
         av.b_setBankMoney(av.getBankMoney() - bankPrice)
         av.b_setMoney(av.getMoney() - walletPrice)
Beispiel #48
0
    def requestBattle(self, zoneId, suit, toonId):
        self.notify.debug('requestBattle() - zone: %s suit: %s toon: %s' %
                          (zoneId, suit.doId, toonId))
        canonicalZoneId = ZoneUtil.getCanonicalZoneId(zoneId)
        if canonicalZoneId not in self.battlePosDict:
            return 0
        toon = self.air.doId2do.get(toonId)
        if toon.getBattleId() > 0:
            self.notify.warning(
                'We tried to request a battle when the toon was already in battle'
            )
            return 0
        if toon:
            if hasattr(toon, 'doId'):
                toon.b_setBattleId(toonId)

        pos = self.battlePosDict[canonicalZoneId]

        interactivePropTrackBonus = -1
        if config.GetBool('props-buff-battles',
                          True) and canonicalZoneId in self.cellToGagBonusDict:
            interactivePropTrackBonus = self.cellToGagBonusDict[
                canonicalZoneId]

        self.battleMgr.newBattle(
            zoneId, zoneId, pos, suit, toonId, self.__battleFinished,
            self.SuitHoodInfo[self.hoodInfoIdx][self.SUIT_HOOD_INFO_SMAX],
            interactivePropTrackBonus)
        for currOther in self.zoneInfo[zoneId]:
            self.notify.debug('Found suit %s in this new battle zone %s' %
                              (currOther.getDoId(), zoneId))
            if currOther != suit:
                if currOther.pathState == 1 and currOther.legType == SuitLeg.TWalk:
                    self.checkForBattle(zoneId, currOther)
        return 1
Beispiel #49
0
 def setZoneIdAndBlock(self, zoneId, block):
     self.zoneId = zoneId
     self.block = block
     canonicalZoneId = ZoneUtil.getCanonicalZoneId(zoneId)
     if canonicalZoneId in (ToontownGlobals.BossbotHQ,
                            ToontownGlobals.BossbotLobby):
         self.doorX = 1.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)
     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 setup(self):
        self.dnaStore = base.cr.playGame.dnaStore
        self.randomGenerator = random.Random()
        self.randomGenerator.seed(self.zoneId)
        interior = self.randomDNAItem('TI_hall', self.dnaStore.findNode)
        self.interior = interior.copyTo(render)
        hoodId = ZoneUtil.getCanonicalHoodId(self.zoneId)
        self.colors = ToonInteriorColors.colors[hoodId]
        self.replaceRandomInModel(self.interior)
        doorModelName = 'door_double_round_ul'
        if doorModelName[-1:] == 'r':
            doorModelName = doorModelName[:-1] + 'l'
        else:
            doorModelName = doorModelName[:-1] + 'r'
        door = self.dnaStore.findNode(doorModelName)
        door_origin = render.find('**/door_origin;+s')
        doorNP = door.copyTo(door_origin)
        door_origin.setScale(0.8, 0.8, 0.8)
        door_origin.setPos(door_origin, 0, -0.025, 0)
        color = self.randomGenerator.choice(self.colors['TI_door'])
        setupDoor(doorNP, self.interior, door_origin, self.dnaStore, str(self.block), color)
        doorFrame = doorNP.find('door_*_flat')
        doorFrame.wrtReparentTo(self.interior)
        doorFrame.setColor(color)
        del self.colors
        del self.dnaStore
        del self.randomGenerator
        self.interior.flattenMedium()
        for npcToon in self.cr.doFindAllInstances(DistributedNPCToonBase.DistributedNPCToonBase):
            npcToon.initToonState()

        self.createSillyMeter()
Beispiel #52
0
 def avatarEnter(self):
     avId = self.air.getAvatarIdFromSender()
     if not avId in self.air.doId2do:
         self.notify.warning('Avatar: %s not found' % avId)
         return
     if self.isBusy():
         self.freeAvatar(avId)
         return
     self.petSeeds = self.air.petMgr.getAvailablePets(
         ZoneUtil.getCanonicalHoodId(self.zoneId))
     numGenders = len(PetDNA.PetGenders)
     self.petSeeds *= numGenders
     self.petSeeds.sort()
     self.sendUpdateToAvatarId(avId, 'setPetSeeds', [self.petSeeds])
     self.transactionType = ''
     av = self.air.doId2do[avId]
     self.busy = avId
     self.acceptOnce(self.air.getAvatarExitEvent(avId),
                     self.__handleUnexpectedExit,
                     extraArgs=[avId])
     flag = NPCToons.SELL_MOVIE_START
     self.d_setMovie(avId, flag)
     taskMgr.doMethodLater(PetConstants.PETCLERK_TIMER,
                           self.sendTimeoutMovie,
                           self.uniqueName('clearMovie'))
     DistributedNPCToonBaseAI.avatarEnter(self)
Beispiel #53
0
    def doPostAnnounceGenerate(self):
        flatDoorTypes = [DoorTypes.INT_STANDARD, DoorTypes.INT_HQ]
        if self.doorType in flatDoorTypes:
            self.bHasFlat = True
        else:
            self.bHasFlat = not self.findDoorNode('door*flat', True).isEmpty()
        self.hideDoorParts()
        self.setTriggerName()

        # Check if we are dealing with a DDL HQ door...
        if self.doorType == DoorTypes.EXT_HQ and \
           ZoneUtil.getHoodId(self.zoneId) == ToontownGlobals.DonaldsDreamland:

            # Get the doorTrigger...
            building = self.getBuilding()
            doorTrigger = building.find('**/%s' % self.getTriggerName())

            # Check if the doorTrigger hasn't been 'fixed' already...
            if not doorTrigger.getTag('fixed'):

                # Reposition the doorTrigger based on its index...
                if self.doorIndex == 0:
                    doorTrigger.setY(doorTrigger, 0.25)
                else:
                    doorTrigger.setY(doorTrigger, -0.25)

                # We are done :) Tag the door as fixed.
                doorTrigger.setTag('fixed', 'true')

        self.accept(self.getEnterTriggerEvent(), self.doorTrigger)
        self.acceptOnce('clearOutToonInterior', self.doorTrigger)
        self.setupNametag()
Beispiel #54
0
    def setup(self):
        self.dnaStore = base.cr.playGame.dnaStore
        self.randomGenerator = random.Random()
        self.randomGenerator.seed(self.zoneId)
        interior = self.randomDNAItem('TI_hall', self.dnaStore.findNode)
        self.interior = interior.copyTo(render)
        hoodId = ZoneUtil.getCanonicalHoodId(self.zoneId)
        self.colors = ToonInteriorColors.colors[hoodId]
        self.replaceRandomInModel(self.interior)
        doorModelName = 'door_double_round_ul'
        if doorModelName[-1:] == 'r':
            doorModelName = doorModelName[:-1] + 'l'
        else:
            doorModelName = doorModelName[:-1] + 'r'
        door = self.dnaStore.findNode(doorModelName)
        door_origin = render.find('**/door_origin;+s')
        doorNP = door.copyTo(door_origin)
        door_origin.setScale(0.8, 0.8, 0.8)
        door_origin.setPos(door_origin, 0, -0.025, 0)
        color = self.randomGenerator.choice(self.colors['TI_door'])
        setupDoor(doorNP, self.interior, door_origin, self.dnaStore,
                  str(self.block), color)
        doorFrame = doorNP.find('door_*_flat')
        doorFrame.wrtReparentTo(self.interior)
        doorFrame.setColor(color)
        del self.colors
        del self.dnaStore
        del self.randomGenerator
        self.interior.flattenMedium()
        for npcToon in self.cr.doFindAllInstances(
                DistributedNPCToonBase.DistributedNPCToonBase):
            npcToon.initToonState()

        self.createSillyMeter()
    def spawnTitleText(self, zoneId, floorNum=None):
        if ZoneUtil.isMintInteriorZone(zoneId):
            text = '%s\n%s' % (ToontownGlobals.StreetNames[zoneId][-1],
                               TTLocalizer.MintFloorTitle % (floorNum + 1))
            self.doSpawnTitleText(text)
            return

        CogHood.spawnTitleText(self, zoneId)
 def handleToonInteriorDone(self):
     status = self.place.doneStatus
     if ZoneUtil.getBranchZone(status['zoneId']) == self.hood.hoodId and status['shardId'] == None:
         self.fsm.request('quietZone', [status])
     else:
         self.doneStatus = status
         messenger.send(self.doneEvent)
     return