def onDoorCloseFinish(self): if self.index == 1: if self.localAvOnElevator: base.transitions.fadeScreen(1) self.thebldg.d_readyForNextFloor() self.localAvOnElevator = False else: requestStatus = { 'zoneId': ZoneUtil.getZoneId( ZoneUtil.getHoodId(self.zoneId, street=1)), '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 finished(self, zone, shardId=None): if base.localAvatar.getHealth() < 1 and type(zone) == type(1): return doneStatus = {} if zone in [ CIGlobals.ToontownCentralId, CIGlobals.MinigameAreaId, CIGlobals.TheBrrrghId, CIGlobals.DonaldsDreamlandId, CIGlobals.MinniesMelodylandId, CIGlobals.DaisyGardensId, CIGlobals.DonaldsDockId ]: doneStatus['mode'] = 'teleport' doneStatus['zoneId'] = zone doneStatus['hoodId'] = ZoneUtil.getHoodId(zone) doneStatus['where'] = ZoneUtil.getWhereName(zone) doneStatus['how'] = 'teleportIn' doneStatus['avId'] = base.localAvatar.doId doneStatus['shardId'] = None doneStatus['loader'] = ZoneUtil.getLoaderName(zone) else: doneStatus['mode'] = zone if zone == 'switchShard': doneStatus['shardId'] = shardId self.doneStatus = doneStatus messenger.send(self.doneEvent) return
def finished(self, zone, shardId = None): if base.localAvatar.getHealth() < 1 and type(zone) == type(1): return else: doneStatus = {} if zone in [CIGlobals.ToontownCentralId, CIGlobals.MinigameAreaId, CIGlobals.TheBrrrghId, CIGlobals.DonaldsDreamlandId, CIGlobals.MinniesMelodylandId, CIGlobals.DaisyGardensId, CIGlobals.DonaldsDockId]: doneStatus['mode'] = 'teleport' doneStatus['zoneId'] = zone doneStatus['hoodId'] = ZoneUtil.getHoodId(zone) doneStatus['where'] = ZoneUtil.getWhereName(zone) doneStatus['how'] = 'teleportIn' doneStatus['avId'] = base.localAvatar.doId doneStatus['shardId'] = None doneStatus['loader'] = ZoneUtil.getLoaderName(zone) else: doneStatus['mode'] = zone if zone == 'switchShard': doneStatus['shardId'] = shardId self.doneStatus = doneStatus messenger.send(self.doneEvent) return
def headBackToMinigameArea(self): whereName = ZoneUtil.getWhereName(CIGlobals.MinigameAreaId) loaderName = ZoneUtil.getLoaderName(CIGlobals.MinigameAreaId) requestStatus = {'zoneId': CIGlobals.MinigameAreaId, 'hoodId': CIGlobals.MinigameArea, 'where': whereName, 'how': 'teleportIn', 'avId': base.localAvatar.doId, 'shardId': None, 'loader': loaderName} self.cr.playGame.hood.fsm.request('quietZone', [requestStatus])
def enter(self, hoodId, zoneId, avId): StateData.enter(self) whereName = ZoneUtil.getWhereName(zoneId) loaderName = ZoneUtil.getLoaderName(zoneId) self.fsm.request('quietZone', [ {'zoneId': zoneId, 'hoodId': hoodId, 'where': whereName, 'how': 'teleportIn', 'avId': avId, 'shardId': None, 'loader': loaderName}]) return
def headBackToMinigameArea(self): whereName = ZoneUtil.getWhereName(CIGlobals.MinigameAreaId) loaderName = ZoneUtil.getLoaderName(CIGlobals.MinigameAreaId) requestStatus = {'zoneId': CIGlobals.MinigameAreaId, 'hoodId': CIGlobals.MinigameArea, 'where': whereName, 'how': 'teleportIn', 'avId': base.localAvatar.doId, 'shardId': None, 'loader': loaderName} self.cr.playGame.hood.fsm.request('quietZone', [requestStatus]) return
def teleportToCT(self): toZone = CIGlobals.CogTropolisId hood = CIGlobals.CogTropolis requestStatus = {'zoneId': toZone, 'hoodId': hood, 'where': ZoneUtil.getWhereName(toZone), 'avId': self.doId, 'loader': ZoneUtil.getLoaderName(toZone), 'shardId': None, 'wantLaffMeter': 1, 'how': 'teleportIn'} self.cr.playGame.getPlace().fsm.request('teleportOut', [requestStatus]) return
def tournamentDefeated(self, hood): for questId in self.quests.keys(): quest = self.quests[questId] objective = quest.getCurrentObjective() if objective.type == Quests.DefeatCogTournament: if not objective.isComplete(): if (objective.area == Quests.Any or ZoneUtil.getHoodId(objective.area, 1) == hood or ZoneUtil.getHoodId( objective.area, 1) == CIGlobals.ToontownCentral and hood == CIGlobals.BattleTTC): self.incrementQuestObjectiveProgress(questId) self.checkIfObjectiveIsComplete(questId)
def teleportToCT(self): toZone = CIGlobals.CogTropolisId hood = CIGlobals.CogTropolis requestStatus = { 'zoneId': toZone, 'hoodId': hood, 'where': ZoneUtil.getWhereName(toZone), 'avId': self.doId, 'loader': ZoneUtil.getLoaderName(toZone), 'shardId': None, 'wantLaffMeter': 1, 'how': 'teleportIn', 'world': CIGlobals.OToontown } self.cr.playGame.getPlace().fsm.request('teleportOut', [requestStatus])
def monitorHealth(self, task): if self.isDead(): base.taskMgr.remove('LT.attackReactionDone') if self.cr.playGame.hood.id != ZoneUtil.getHoodId(self.zoneId): self.cr.playGame.getPlace().fsm.request('died', [{}, self.diedStateDone]) return task.done return task.cont
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 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 monitorHealth(self, task): if self.isDead(): base.taskMgr.remove('LT.attackReactionDone') if self.cr.playGame.hood.id != ZoneUtil.getHoodId(self.zoneId): self.cr.playGame.getPlace().fsm.request( 'died', [{}, self.diedStateDone]) return task.done return task.cont
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 tournamentDefeated(self, hood): for questId in self.quests.keys(): quest = self.quests[questId] objective = quest.getCurrentObjective() if objective.type == Quests.DefeatCogTournament: if not objective.isComplete(): if ZoneUtil.getHoodId(objective.area, 1) == hood or objective.area == Quests.Any: self.incrementQuestObjectiveProgress(questId) self.checkIfObjectiveIsComplete(questId)
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() return
def monitorHealth(self, task): if self.isDead(): base.taskMgr.remove("LT.attackReactionDone") if (self.cr.playGame.hood.id != ZoneUtil.getHoodId(self.zoneId)): self.cr.playGame.getPlace().fsm.request( 'died', [{}, self.diedStateDone]) messenger.send(PCTMM.getLocalAvDiedEvent()) return task.done return task.cont
def diedStateDone(self, requestStatus): hood = self.cr.playGame.hood.id if hood == CIGlobals.BattleTTC: hood = CIGlobals.ToontownCentral toZone = ZoneUtil.getZoneId(hood) if self.zoneId != toZone: requestStatus = {'zoneId': toZone, 'hoodId': hood, 'where': ZoneUtil.getWhereName(toZone), 'avId': self.doId, 'loader': ZoneUtil.getLoaderName(toZone), 'shardId': None, 'wantLaffMeter': 1, 'how': 'teleportIn'} self.cr.playGame.getPlace().doneStatus = requestStatus messenger.send(self.cr.playGame.getPlace().doneEvent) else: return return
def diedStateDone(self, requestStatus): hood = self.cr.playGame.hood.id if hood == CIGlobals.BattleTTC: hood = CIGlobals.ToontownCentral toZone = ZoneUtil.getZoneId(hood) if self.zoneId != toZone: requestStatus = { 'zoneId': toZone, 'hoodId': hood, 'where': ZoneUtil.getWhereName(toZone), 'avId': self.doId, 'loader': ZoneUtil.getLoaderName(toZone), 'shardId': None, 'wantLaffMeter': 1, 'how': 'teleportIn' } self.cr.playGame.getPlace().doneStatus = requestStatus messenger.send(self.cr.playGame.getPlace().doneEvent) else: return
def cogDefeated(self, cog): for questId in self.quests.keys(): quest = self.quests[questId] objective = quest.getCurrentObjective() if objective.type in Quests.DefeatCogObjectives: if not objective.isComplete(): if objective.type == Quests.DefeatCog: if objective.subject == Quests.Any: if objective.area == Quests.Any or ZoneUtil.getHoodId(objective.area, 1) == cog.getHood(): self.incrementQuestObjectiveProgress(questId) elif objective.subject == cog.head: if objective.area == Quests.Any or ZoneUtil.getHoodId(objective.area, 1) == cog.getHood(): self.incrementQuestObjectiveProgress(questId) elif objective.type == Quests.DefeatCogLevel: if cog.getLevel() >= objective.minCogLevel: if objective.area == Quests.Any or ZoneUtil.getHoodId(objective.area, 1) == cog.getHood(): self.incrementQuestObjectiveProgress(questId) elif objective.type == Quests.DefeatCogDept: if objective.subject == cog.team: if objective.area == Quests.Any or ZoneUtil.getHoodId(objective.area, 1) == cog.getHood(): self.incrementQuestObjectiveProgress(questId) self.checkIfObjectiveIsComplete(questId)
def cogDefeated(self, cog): for questId in self.quests.keys(): quest = self.quests[questId] objective = quest.getCurrentObjective() if objective.type in Quests.DefeatCogObjectives: if not objective.isComplete(): if objective.type == Quests.DefeatCog: if objective.subject == Quests.Any: if (objective.area == Quests.Any or ZoneUtil.getHoodId(objective.area, 1) == cog.getHood() or ZoneUtil.getHoodId(objective.area, 1) == CIGlobals.ToontownCentral and cog.getHood() == CIGlobals.BattleTTC): self.incrementQuestObjectiveProgress(questId) elif objective.subject == cog.head: if (objective.area == Quests.Any or ZoneUtil.getHoodId(objective.area, 1) == cog.getHood() or ZoneUtil.getHoodId(objective.area, 1) == CIGlobals.ToontownCentral and cog.getHood() == CIGlobals.BattleTTC): self.incrementQuestObjectiveProgress(questId) elif objective.type == Quests.DefeatCogLevel: if cog.getLevel() >= objective.minCogLevel: if (objective.area == Quests.Any or ZoneUtil.getHoodId(objective.area, 1) == cog.getHood() or ZoneUtil.getHoodId(objective.area, 1) == CIGlobals.ToontownCentral and cog.getHood() == CIGlobals.BattleTTC): self.incrementQuestObjectiveProgress(questId) elif objective.type == Quests.DefeatCogDept: if objective.subject == cog.team: if (objective.area == Quests.Any or ZoneUtil.getHoodId(objective.area, 1) == cog.getHood() or ZoneUtil.getHoodId(objective.area, 1) == CIGlobals.ToontownCentral and cog.getHood() == CIGlobals.BattleTTC): self.incrementQuestObjectiveProgress(questId) self.checkIfObjectiveIsComplete(questId)
def setupSuitBuilding(self, nodePath): if nodePath.isEmpty(): return dnaStore = self.cr.playGame.dnaStore level = int(self.difficulty / 2) + 1 suitNP = dnaStore.findNode('suit_landmark_' + self.getDeptClassFromAbbr(self.suitDept).getClothingPrefix() + str(level)) zoneId = dnaStore.getZoneFromBlockNumber(self.block) zoneId = ZoneUtil.getTrueZoneId(zoneId, self.interiorZoneId) newParentNP = base.cr.playGame.hood.loader.zoneDict[zoneId] suitBuildingNP = suitNP.copyTo(newParentNP) buildingTitle = dnaStore.getTitleFromBlockNumber(self.block) if not buildingTitle: buildingTitle = "Cogs, Inc." else: buildingTitle += ", Inc." buildingTitle += "\n%s" % self.getDeptClassFromAbbr(self.suitDept).getName() textNode = TextNode('sign') textNode.setTextColor(1.0, 1.0, 1.0, 1.0) textNode.setFont(CIGlobals.getSuitFont()) textNode.setAlign(TextNode.ACenter) textNode.setWordwrap(17.0) textNode.setText(buildingTitle) textHeight = textNode.getHeight() zScale = (textHeight + 2) / 3.0 signOrigin = suitBuildingNP.find('**/sign_origin;+s') backgroundNP = loader.loadModel('phase_5/models/modules/suit_sign.bam') backgroundNP.reparentTo(signOrigin) backgroundNP.setPosHprScale(0.0, 0.0, textHeight * 0.8 / zScale, 0.0, 0.0, 0.0, 8.0, 8.0, 8.0 * zScale) #backgroundNP.node().setEffect(DecalEffect.make()) signTextNodePath = backgroundNP.attachNewNode(textNode.generate()) signTextNodePath.setPosHprScale(0.0, -0.02, -0.21 + textHeight * 0.1 / zScale, 0.0, 0.0, 0.0, 0.1, 0.1, 0.1 / zScale) signTextNodePath.setColor(1.0, 1.0, 1.0, 1.0) frontNP = suitBuildingNP.find('**/*_front/+GeomNode;+s') backgroundNP.wrtReparentTo(frontNP) frontNP.node().setEffect(DecalEffect.make()) suitBuildingNP.setName('sb' + str(self.block) + ':_landmark__DNARoot') suitBuildingNP.setPosHprScale(nodePath, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0) suitBuildingNP.flattenMedium() self.loadElevator(suitBuildingNP) return suitBuildingNP
def getExteriorAndInteriorZoneId(self): dnaStore = self.air.dnaStoreMap[self.canonicalZoneId] zoneId = dnaStore.getZoneFromBlockNumber(self.block) zoneId = ZoneUtil.getTrueZoneId(zoneId, self.zoneId) interiorZoneId = (zoneId - (zoneId % 100)) + 500 + self.block return (zoneId, interiorZoneId)
def enterMapPage(self): if base.localAvatar.getAdminToken() > -1: self.createPageButtons('inventoryPage', 'adminPage') else: self.createPageButtons('inventoryPage', None) self.setTitle("") themap = loader.loadModel('phase_3.5/models/gui/toontown_map.bam') self.frame = DirectFrame(parent=aspect2d, relief=None, image=themap, image_scale=(1.8, 1, 1.35), scale=0.97, pos=(0, 0, 0.0775)) cloudpos = [[(-0.61, 0, 0.18), (0.55, 0.25, 0.37), (180, 0, 0)], [(-0.54, 0, 0.34), (0.76, 0.4, 0.55), (180, 0, 0)], [(-0.55, 0, -0.09), (0.72, 0.4, 0.55), (0, 0, 0)], [(-0.67, 0, -0.51), (0.5, 0.29, 0.38), (180, 0, 0)], [(-0.67, 0, 0.51), (0.50, 0.29, 0.38), (0, 0, 0)], [(0.67, 0, 0.51), (0.5, 0.29, 0.38), (0, 0, 0)], [(0.35, 0, -0.46), (0.63, 0.35, 0.45), (0, 0, 0)], [(0.18, 0, -0.45), (0.52, 0.27, 0.32), (0, 0, 0)], [(0.67, 0, -0.44), (0.63, 0.35, 0.48), (180, 0, 0)]] hoodclouds = [ #[(0.02, 0, -0.17), (0.63, 0.35, 0.48), (180, 0, 0), CIGlobals.ToontownCentral], [(0.63, 0, -0.13), (0.63, 0.35, 0.40), (0, 0, 0), CIGlobals.DonaldsDock], [(0.51, 0, 0.25), (0.57, 0.35, 0.40), (0, 0, 0), CIGlobals.TheBrrrgh], [(0.03, 0, 0.19), (0.63, 0.35, 0.40), (180, 0, 0), CIGlobals.MinniesMelodyland], [(-0.08, 0, 0.46), (0.54, 0.35, 0.40), (0, 0, 0), CIGlobals.DonaldsDreamland], [(-0.28, 0, -0.49), (0.60, 0.35, 0.45), (0, 0, 0), CIGlobals.DaisyGardens] ] self.clouds = [] self.labels = [] for pos, scale, hpr in cloudpos: cloud = loader.loadModel('phase_3.5/models/gui/cloud.bam') cloud.reparentTo(self.frame) cloud.setPos(pos) cloud.setScale(scale) cloud.setHpr(hpr) self.clouds.append(cloud) for pos, scale, hpr, hood in hoodclouds: if not base.localAvatar.hasDiscoveredHood( ZoneUtil.getZoneId(hood)): cloud = loader.loadModel('phase_3.5/models/gui/cloud.bam') cloud.reparentTo(self.frame) cloud.setPos(pos) cloud.setScale(scale) cloud.setHpr(hpr) self.clouds.append(cloud) labeldata = [[(0, 0, -0.2), CIGlobals.ToontownCentral], [(0.65, 0, -0.125), CIGlobals.DonaldsDock], [(0.07, 0, 0.18), CIGlobals.MinniesMelodyland], [(-0.1, 0, 0.45), CIGlobals.DonaldsDreamland], [(0.5, 0, 0.25), CIGlobals.TheBrrrgh], [(-0.37, 0, -0.525), CIGlobals.DaisyGardens]] for pos, name in 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.frame, 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=None, clickSound=None, pressEffect=0, sortOrder=1, text_font=CIGlobals.getToonFont()) if base.localAvatar.hasTeleportAccess( ZoneUtil.getZoneId(name)): label['command'] = self.finished label['extraArgs'] = [ZoneUtil.getZoneId(name)] label.resetFrameSize() self.labels.append(label) currHoodName = base.cr.playGame.hood.id currLocation = '' if base.localAvatar.zoneId == CIGlobals.MinigameAreaId or base.localAvatar.getMyBattle( ) is not None: currLocation = '' elif ZoneUtil.getWhereName(base.localAvatar.zoneId) == 'playground': currLocation = 'Playground' elif ZoneUtil.getWhereName( base.localAvatar.zoneId) in ['street', 'interior']: currLocation = CIGlobals.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.frame, text_align=TextNode.ACenter) if currHoodName in [CIGlobals.MinigameArea, CIGlobals.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.frame, text_font=CIGlobals.getToonFont(), pos=(0.25, 0, -0.75), command=self.finished, extraArgs=btpEA, scale=0.7) if base.localAvatar.zoneId != CIGlobals.MinigameAreaId: self.MGAButton = DirectButton(relief=None, text="Minigame Area", geom=CIGlobals.getDefaultBtnGeom(), text_pos=(0, -0.018), geom_scale=(1, 1.11, 1.11), text_scale=0.06, parent=self.frame, text_font=CIGlobals.getToonFont(), pos=(0.625, 0, -0.75), command=self.finished, extraArgs=[CIGlobals.MinigameAreaId], scale=0.7)
# Embedded file name: lib.coginvasion.suit.CogBattleGlobals from lib.coginvasion.globals.CIGlobals import BattleTTC, TheBrrrgh, DonaldsDreamland, DonaldsDock from lib.coginvasion.hood import ZoneUtil HoodId2HoodIndex = {BattleTTC: 0, TheBrrrgh: 1, DonaldsDreamland: 2, DonaldsDock: 5} HoodIndex2HoodName = {v:k for k, v in HoodId2HoodIndex.items()} HoodIndex2HoodId = None if HoodIndex2HoodId == None: HoodIndex2HoodId = {} for hoodName in HoodId2HoodIndex.keys(): index = HoodId2HoodIndex[hoodName] zone = ZoneUtil.getZoneId(hoodName) HoodIndex2HoodId[index] = zone hi2hi = HoodId2HoodIndex HoodIndex2LevelRange = {hi2hi[BattleTTC]: list(range(1, 6)), hi2hi[TheBrrrgh]: list(range(5, 10)), hi2hi[DonaldsDreamland]: list(range(6, 10)), hi2hi[DonaldsDock]: range(2, 7)} HoodIndex2TotalCogs = {hi2hi[BattleTTC]: 40, hi2hi[TheBrrrgh]: 45, hi2hi[DonaldsDreamland]: 50, hi2hi[DonaldsDock]: 45} WaiterHoodIndex = hi2hi[TheBrrrgh] SkeletonHoodIndex = 10
HoodId2HoodIndex = { BattleTTC: 0, TheBrrrgh: 1, DonaldsDreamland: 2, MinniesMelodyland: 3, DaisyGardens: 4, DonaldsDock: 5 } HoodIndex2HoodName = {v: k for k, v in HoodId2HoodIndex.items()} HoodIndex2HoodId = None if HoodIndex2HoodId == None: HoodIndex2HoodId = {} for hoodName in HoodId2HoodIndex.keys(): index = HoodId2HoodIndex[hoodName] zone = ZoneUtil.getZoneId(hoodName) HoodIndex2HoodId[index] = zone hi2hi = HoodId2HoodIndex HoodIndex2LevelRange = { hi2hi[BattleTTC]: list(range(1, 3 + 1)), hi2hi[TheBrrrgh]: list(range(5, 9 + 1)), hi2hi[DonaldsDreamland]: list(range(6, 9 + 1)), hi2hi[MinniesMelodyland]: range(2, 6 + 1), hi2hi[DaisyGardens]: range(2, 6 + 1), hi2hi[DonaldsDock]: range(2, 6 + 1) } HoodId2WantBattles = { BattleTTC: True,
def makeQuestNotes(self, quests = None): notes = [] if not quests: quests = self.quests.values() for quest in quests: objective = quest.currentObjective note = QuestNote.QuestNote(quest.index) isDefeatObjective = objective.type in (Quests.DefeatCog, Quests.DefeatCogDept, Quests.DefeatCogInvasion, Quests.DefeatCogTournament, Quests.DefeatCogLevel) heading = None if isDefeatObjective: heading = Quests.DefeatText elif objective.type in [Quests.VisitNPC, Quests.VisitHQOfficer]: heading = Quests.VisitText note.setHeading(heading) taskInfo = None if isDefeatObjective: if objective.goal > 1: taskInfo = "%d " % objective.goal else: taskInfo = "a " if objective.type == Quests.DefeatCog: if objective.subject == Quests.Any: taskInfo += CIGlobals.Suits else: if objective.goal > 1: taskInfo += QuestGlobals.makePlural(CIGlobals.SuitNames[objective.subject]) else: taskInfo += CIGlobals.SuitNames[objective.subject] elif objective.type in (Quests.DefeatCogInvasion, Quests.DefeatCogTournament, Quests.DefeatCogDept): if objective.goal > 1: if objective.type == Quests.DefeatCogDept: taskInfo += QuestGlobals.AbbrToDept[objective.subject] elif objective.type == Quests.DefeatCogInvasion: taskInfo += QuestGlobals.QuestSubjects[1] elif objective.type == Quests.DefeatCogTournament: taskInfo += QuestGlobals.QuestSubjects[6] else: if objective.type == Quests.DefeatCogDept: taskInfo += QuestGlobals.makeSingular(QuestGlobals.AbbrToDept[objective.subject]) elif objective.type == Quests.DefeatCogInvasion: taskInfo += QuestGlobals.makeSingular(QuestGlobals.QuestSubjects[1]) elif objective.type == Quests.DefeatCogTournament: taskInfo += QuestGlobals.makeSingular(QuestGlobals.QuestSubjects[6]) elif objective.type == Quests.DefeatCogLevel: if objective.goal > 1: taskInfo += "Level %d+ %s" % (objective.minCogLevel, CIGlobals.Suits) else: taskInfo += "Level %d+ %s" % (objective.minCogLevel, CIGlobals.Suit) if objective.area == Quests.Any: taskInfo += "\nAnywhere" else: taskInfo += "\nin " + ZoneUtil.getHoodId(objective.area) elif objective.type == Quests.VisitNPC: nameOfNPC = CIGlobals.NPCToonNames[objective.npcId] placeOfNPC = CIGlobals.zone2TitleDict[objective.npcZone][0] taskInfo = nameOfNPC + "\nat " + placeOfNPC elif objective.type == Quests.VisitHQOfficer: taskInfo = "an HQ Officer\nat a Toon HQ" note.setTaskInfo(taskInfo) progress = "" if isDefeatObjective: if not objective.isComplete(): if isDefeatObjective: progress = "%d of %d " % (objective.progress, objective.goal) + QuestGlobals.makePastTense(Quests.DefeatText) note.setProgress(progress) else: note.setCompleted(1) elif objective.type == Quests.VisitNPC: streetZone = ZoneUtil.getBranchZone(objective.npcZone) if streetZone % 1000 >= 100: streetName = CIGlobals.BranchZone2StreetName[streetZone] else: streetName = "the Playground" hoodName = ZoneUtil.getHoodId(streetZone, 1) progress = "on %s\nin %s" % (streetName, hoodName) note.setProgress(progress) elif objective.type == Quests.VisitHQOfficer: progress = "Any Street\nAny Playground" note.setProgress(progress) reward = "" if quest.rewardType == Quests.RewardJellybeans: reward = "For %d jellybeans" elif quest.rewardType == Quests.RewardHealth: reward = "For a %d point Laff boost" elif quest.rewardType == Quests.RewardAccess: reward = "For access to %s" elif quest.rewardType == Quests.RewardNone: reward = "For no reward" if '%s' in reward or '%d' in reward: note.setReward(reward % quest.rewardValue) else: note.setReward(reward) notes.append(note) return notes
def getVisZoneId(self): exteriorZoneId = self.cr.playGame.dnaStore.getZoneFromBlockNumber(self.block) visZoneId = ZoneUtil.getTrueZoneId(exteriorZoneId, self.zoneId) return visZoneId
def makeQuestNotes(self, quests = None): notes = [] if not quests: quests = self.quests.values() for quest in quests: objective = quest.currentObjective note = QuestNote.QuestNote(quest.index) isDefeatObjective = objective.type in (Quests.DefeatCog, Quests.DefeatCogDept, Quests.DefeatCogInvasion, Quests.DefeatCogTournament, Quests.DefeatCogLevel) heading = None if isDefeatObjective: heading = Quests.DefeatText elif objective.type in [Quests.VisitNPC, Quests.VisitHQOfficer]: heading = Quests.VisitText note.setHeading(heading) taskInfo = None if isDefeatObjective: if objective.goal > 1: taskInfo = '%d ' % objective.goal else: taskInfo = 'a ' if objective.type == Quests.DefeatCog: if objective.subject == Quests.Any: taskInfo += CIGlobals.Suits elif objective.goal > 1: taskInfo += QuestGlobals.makePlural(CIGlobals.SuitNames[objective.subject]) else: taskInfo += CIGlobals.SuitNames[objective.subject] elif objective.type in (Quests.DefeatCogInvasion, Quests.DefeatCogTournament, Quests.DefeatCogDept): if objective.goal > 1: if objective.type == Quests.DefeatCogDept: taskInfo += QuestGlobals.AbbrToDept[objective.subject] else: taskInfo += QuestGlobals.makePlural(objective.subject) elif objective.type == Quests.DefeatCogDept: taskInfo += QuestGlobals.makeSingular(QuestGlobals.AbbrToDept[objective.subject]) else: taskInfo += objective.subject elif objective.type == Quests.DefeatCogLevel: if objective.goal > 1: taskInfo += 'Level %d+ %s' % (objective.minCogLevel, CIGlobals.Suits) else: taskInfo += 'Level %d+ %s' % (objective.minCogLevel, CIGlobals.Suit) if objective.area == Quests.Any: taskInfo += '\nAnywhere' else: taskInfo += '\nin ' + ZoneUtil.getHoodId(objective.area) elif objective.type == Quests.VisitNPC: nameOfNPC = CIGlobals.NPCToonNames[objective.npcId] placeOfNPC = CIGlobals.zone2TitleDict[objective.npcZone][0] taskInfo = nameOfNPC + '\nat ' + placeOfNPC elif objective.type == Quests.VisitHQOfficer: taskInfo = 'an HQ Officer\nat a Toon HQ' note.setTaskInfo(taskInfo) progress = '' if isDefeatObjective: if not objective.isComplete(): if isDefeatObjective: progress = '%d of %d ' % (objective.progress, objective.goal) + QuestGlobals.makePastTense(Quests.DefeatText) note.setProgress(progress) else: note.setCompleted(1) elif objective.type == Quests.VisitNPC: streetZone = ZoneUtil.getBranchZone(objective.npcZone) if streetZone % 1000 >= 100: streetName = CIGlobals.BranchZone2StreetName[streetZone] else: streetName = 'the Playground' hoodName = ZoneUtil.getHoodId(streetZone, 1) progress = 'on %s\nin %s' % (streetName, hoodName) note.setProgress(progress) elif objective.type == Quests.VisitHQOfficer: progress = 'Any Street\nAny Playground' note.setProgress(progress) reward = '' if quest.rewardType == Quests.RewardJellybeans: reward = 'For %d jellybeans' elif quest.rewardType == Quests.RewardHealth: reward = 'For a %d point Laff boost' elif quest.rewardType == Quests.RewardAccess: reward = 'For access to %s' elif quest.rewardType == Quests.RewardNone: reward = 'For no reward' if '%s' in reward or '%d' in reward: note.setReward(reward % quest.rewardValue) else: note.setReward(reward) notes.append(note) return notes
def enterMapPage(self): self.createPageButtons('inventoryPage', 'releaseNotesPage') self.setTitle('') themap = loader.loadModel('phase_3.5/models/gui/toontown_map.bam') self.frame = DirectFrame(parent=aspect2d, relief=None, image=themap, image_scale=(1.8, 1, 1.35), scale=0.97, pos=(0, 0, 0.0775)) cloudpos = [[(-0.61, 0, 0.18), (0.55, 0.25, 0.37), (180, 0, 0)], [(-0.54, 0, 0.34), (0.76, 0.4, 0.55), (180, 0, 0)], [(-0.55, 0, -0.09), (0.72, 0.4, 0.55), (0, 0, 0)], [(-0.67, 0, -0.51), (0.5, 0.29, 0.38), (180, 0, 0)], [(-0.67, 0, 0.51), (0.5, 0.29, 0.38), (0, 0, 0)], [(0.67, 0, 0.51), (0.5, 0.29, 0.38), (0, 0, 0)], [(0.35, 0, -0.46), (0.63, 0.35, 0.45), (0, 0, 0)], [(0.18, 0, -0.45), (0.52, 0.27, 0.32), (0, 0, 0)], [(0.67, 0, -0.44), (0.63, 0.35, 0.48), (180, 0, 0)]] hoodclouds = [[(0.63, 0, -0.13), (0.63, 0.35, 0.4), (0, 0, 0), CIGlobals.DonaldsDock], [(0.51, 0, 0.25), (0.57, 0.35, 0.4), (0, 0, 0), CIGlobals.TheBrrrgh], [(0.03, 0, 0.19), (0.63, 0.35, 0.4), (180, 0, 0), CIGlobals.MinniesMelodyland], [(-0.08, 0, 0.46), (0.54, 0.35, 0.4), (0, 0, 0), CIGlobals.DonaldsDreamland], [(-0.28, 0, -0.49), (0.6, 0.35, 0.45), (0, 0, 0), CIGlobals.DaisyGardens]] self.clouds = [] self.labels = [] for pos, scale, hpr in cloudpos: cloud = loader.loadModel('phase_3.5/models/gui/cloud.bam') cloud.reparentTo(self.frame) cloud.setPos(pos) cloud.setScale(scale) cloud.setHpr(hpr) self.clouds.append(cloud) for pos, scale, hpr, hood in hoodclouds: if not base.localAvatar.hasDiscoveredHood(ZoneUtil.getZoneId(hood)): cloud = loader.loadModel('phase_3.5/models/gui/cloud.bam') cloud.reparentTo(self.frame) cloud.setPos(pos) cloud.setScale(scale) cloud.setHpr(hpr) self.clouds.append(cloud) labeldata = [[(0, 0, -0.2), CIGlobals.ToontownCentral], [(0.65, 0, -0.125), CIGlobals.DonaldsDock], [(0.07, 0, 0.18), CIGlobals.MinniesMelodyland], [(-0.1, 0, 0.45), CIGlobals.DonaldsDreamland], [(0.5, 0, 0.25), CIGlobals.TheBrrrgh], [(-0.37, 0, -0.525), CIGlobals.DaisyGardens]] for pos, name in 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.frame, 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=None, clickSound=None, pressEffect=0, sortOrder=1, text_font=CIGlobals.getToonFont()) if base.localAvatar.hasTeleportAccess(ZoneUtil.getZoneId(name)): label['command'] = self.finished label['extraArgs'] = [ZoneUtil.getZoneId(name)] label.resetFrameSize() self.labels.append(label) currHoodName = base.cr.playGame.hood.id currLocation = '' if base.localAvatar.zoneId == CIGlobals.MinigameAreaId: currLocation = '' elif base.localAvatar.getMyBattle() != None: currLocation = 'CogTropolis' elif ZoneUtil.getWhereName(base.localAvatar.zoneId) == 'playground': currLocation = 'Playground' elif ZoneUtil.getWhereName(base.localAvatar.zoneId) in ('street', 'interior'): currLocation = CIGlobals.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.frame, text_align=TextNode.ACenter) if currHoodName in [CIGlobals.MinigameArea, CIGlobals.BattleTTC]: currHoodName = base.cr.playGame.lastHood self.BTPButton = DirectButton(relief=None, text='Back to Playground', geom=CIGlobals.getDefaultBtnGeom(), text_pos=(0, -0.018), geom_scale=(1.3, 1.11, 1.11), text_scale=0.06, parent=self.frame, text_font=CIGlobals.getToonFont(), pos=(0.25, 0, -0.75), command=self.finished, extraArgs=[ZoneUtil.getZoneId(currHoodName)], scale=0.7) if base.localAvatar.zoneId != CIGlobals.MinigameAreaId: self.MGAButton = DirectButton(relief=None, text='Minigame Area', geom=CIGlobals.getDefaultBtnGeom(), text_pos=(0, -0.018), geom_scale=(1, 1.11, 1.11), text_scale=0.06, parent=self.frame, text_font=CIGlobals.getToonFont(), pos=(0.625, 0, -0.75), command=self.finished, extraArgs=[CIGlobals.MinigameAreaId], scale=0.7) return