def createStreet(self, streetZone, shopZone, hqZone): flunky = DistributedTutorialSuitAI.DistributedTutorialSuitAI(self.air) suitType = SuitDNA.getSuitType('f') suitTrack = SuitDNA.getSuitDept('f') flunky.setupSuitDNA(1, suitType, suitTrack) flunky.generateWithRequired(streetZone) desc = NPCToons.NPCToonDict.get(20001) npc = NPCToons.createNPC(self.air, 20001, desc, streetZone) npc.setTutorial(1) npc.d_setPos(207.4, 18.81, -0.475) npc.d_setHpr(90.0, 0, 0)
def __setupSuitInfo(self, suit, bldgTrack, suitLevel, suitType): suitName, skeleton, v2, waiter = simbase.air.suitInvasionManager.getInvadingCog() if suitName and self.respectInvasions: suitType = SuitDNA.getSuitType(suitName) bldgTrack = SuitDNA.getSuitDept(suitName) suitLevel = min(max(suitLevel, suitType), suitType + 4) dna = SuitDNA.SuitDNA() dna.newSuitRandom(suitType, bldgTrack) suit.dna = dna self.notify.debug('Creating suit type ' + suit.dna.name + ' of level ' + str(suitLevel) + ' from type ' + str(suitType) + ' and track ' + str(bldgTrack)) suit.setLevel(suitLevel) return (skeleton, v2, waiter)
def __setupSuitInfo(self, suit, bldgTrack, suitLevel, suitType): suitDeptIndex, suitTypeIndex, flags = simbase.air.suitInvasionManager.getInvadingCog() if self.respectInvasions: if suitDeptIndex is not None: bldgTrack = SuitDNA.suitDepts[suitDeptIndex] if suitTypeIndex is not None: suitName = SuitDNA.getSuitName(suitDeptIndex, suitTypeIndex) suitType = SuitDNA.getSuitType(suitName) suitLevel = min(max(suitLevel, suitType), suitType + 4) dna = SuitDNA.SuitDNA() dna.newSuitRandom(suitType, bldgTrack) suit.dna = dna suit.setLevel(suitLevel) return flags
def __setupSuitInfo(self, suit, bldgTrack, suitLevel, suitType): suitDeptIndex, suitTypeIndex, flags = simbase.air.suitInvasionManager.getInvadingCog() if self.respectInvasions: if suitDeptIndex is not None: bldgTrack = SuitDNA.suitDepts[suitDeptIndex] if suitTypeIndex is not None: suitName = SuitDNA.getSuitName(suitDeptIndex, suitTypeIndex) suitType = SuitDNA.getSuitType(suitName) suitLevel = min(max(suitLevel, suitType), suitType + 4) dna = SuitDNA.SuitDNA() dna.newSuitRandom(suitType, bldgTrack) suit.dna = dna self.notify.debug('Creating suit type ' + suit.dna.name + ' of level ' + str(suitLevel) + ' from type ' + str(suitType) + ' and track ' + str(bldgTrack)) suit.setLevel(suitLevel) return flags
def getSuitName(self): if self.suitDeptIndex is not None: if self.suitTypeIndex is not None: return SuitDNA.getSuitName(self.suitDeptIndex, self.suitTypeIndex) else: return SuitDNA.suitDepts[self.suitDeptIndex] else: return SuitDNA.suitHeadTypes[0]
def createDiner(self, i): diner = Suit.Suit() diner.dna = SuitDNA.SuitDNA() level = self.dinerInfo[i][2] level -= 4 diner.dna.newSuitRandom(level=level, dept='c') diner.setDNA(diner.dna) diner.nametag.setNametag2d(None) diner.nametag.setNametag3d(None) if self.useNewAnimations: diner.loop('sit', fromFrame=i) else: diner.pose('landing', 0) locator = self.tableGroup.find('**/chair_%d' % (i + 1)) locatorScale = locator.getNetTransform().getScale()[0] correctHeadingNp = locator.attachNewNode('correctHeading') self.chairLocators[i] = correctHeadingNp heading = self.rotationsPerSeatIndex[i] correctHeadingNp.setH(heading) sitLocator = correctHeadingNp.attachNewNode('sitLocator') base.sitLocator = sitLocator pos = correctHeadingNp.getPos(render) if SuitDNA.getSuitBodyType(diner.dna.name) == 'c': sitLocator.setPos(0.5, 3.65, -3.75) else: sitLocator.setZ(-2.4) sitLocator.setY(2.5) sitLocator.setX(0.5) self.sitLocators[i] = sitLocator diner.setScale(1.0 / locatorScale) diner.reparentTo(sitLocator) newLoc = NodePath('serviceLoc-%d-%d' % (self.index, i)) newLoc.reparentTo(correctHeadingNp) newLoc.setPos(0, 3.0, 1) self.serviceLocs[i] = newLoc base.serviceLoc = newLoc head = diner.find('**/joint_head') newIndicator = DinerStatusIndicator.DinerStatusIndicator(parent=head, pos=Point3( 0, 0, 3.5), scale=5.0) newIndicator.wrtReparentTo(diner) self.dinerStatusIndicators[i] = newIndicator return diner
def getCogdoTrack(suitName): tracks = getAllowedTracks() if not tracks: return None track = SuitDNA.getSuitDept(suitName) return track if track in tracks else random.choice(tracks)
def createCog(cogType, x=0, y=0, z=0, h=0, p=0, r=0, isSkelecog=False, isWaiter=False, isVirtual=False, isSkeleRevive=False, colorType=NametagGroup.CCSuit, anim='neutral', parent=render, name=None, dept=None, level=None, coll=True): newCog = Suit.Suit() newCog.dna = SuitDNA.SuitDNA() newCog.dna.newSuit(cogType) newCog.setDNA(newCog.dna) newCog.setPlayerType(colorType) newCog.setPickable(0) level = level if level != None else newCog.getActualLevel() if isWaiter: newCog.makeWaiter() if isSkelecog: newCog.makeSkeleton() newCog.setName(TTLocalizer.Skeleton) if isVirtual: newCog.makeVirtual() if isSkeleRevive: level = '%s%s' % (level, TTLocalizer.SkeleRevivePostFix) if name != None: newCog.setName(name) if dept is False: nameInfo = TTLocalizer.SuitBaseNameWithoutDept % { 'name': newCog._name, 'level': level } else: nameInfo = TTLocalizer.SuitBaseNameWithLevel % { 'name': newCog._name, 'dept': dept if dept != None else newCog.getStyleDept(), 'level': level } newCog.setPosHpr(x, y, z, h, p, r) newCog.reparentTo(parent) newCog.loop(anim) newCog.setDisplayName(nameInfo) if coll: collTube = CollisionTube(0, 0, 0.5, 0, 0, 4, 2) collNode = CollisionNode('suit') collNode.addSolid(collTube) newCog.attachNewNode(collNode) return newCog
def __setupSuitInfo(self, suit, bldgTrack, suitLevel, suitType): dna = SuitDNA.SuitDNA() dna.newSuitRandom(suitType, bldgTrack) suit.dna = dna self.notify.debug('Creating suit type ' + suit.dna.name + ' of level ' + str(suitLevel) + ' from type ' + str(suitType) + ' and track ' + str(bldgTrack)) suit.setLevel(suitLevel) return False
def __setupSuitInfo(self, suit, bldgTrack, suitLevel, suitType): suitDeptIndex, suitTypeIndex, flags = simbase.air.suitInvasionManager.getInvadingCog( ) if self.respectInvasions: if suitDeptIndex is not None: bldgTrack = SuitDNA.suitDepts[suitDeptIndex] if suitTypeIndex is not None: suitName = SuitDNA.getSuitName(suitDeptIndex, suitTypeIndex) suitType = SuitDNA.getSuitType(suitName) suitLevel = min(max(suitLevel, suitType), suitType + 4) dna = SuitDNA.SuitDNA() dna.newSuitRandom(suitType, bldgTrack) suit.dna = dna self.notify.debug('Creating suit type ' + suit.dna.name + ' of level ' + str(suitLevel) + ' from type ' + str(suitType) + ' and track ' + str(bldgTrack)) suit.setLevel(suitLevel) return flags
def __genSuitObject(self, suitDict, reserve): suit = self.cogCtor(simbase.air, self) dna = SuitDNA.SuitDNA() dna.newSuitRandom(level=SuitDNA.getRandomSuitType(suitDict['level']), dept=suitDict['track']) suit.dna = dna suit.setLevel(suitDict['level']) suit.setSkeleRevives(suitDict.get('revives')) suit.setLevelDoId(self.level.doId) suit.setCogId(suitDict['cogId']) suit.setReserve(reserve) if suitDict['skeleton']: suit.setSkelecog(1) #if random.random() < 0.2 or suitDict['boss']: #suit.setElite(1) suit.generateWithRequired(suitDict['zoneId']) suit.boss = suitDict['boss'] return suit
def createSuit(self): self.suit = Suit.Suit() suitDNA = SuitDNA.SuitDNA() suitDNA.newSuit('f') self.suit.setDNA(suitDNA) self.suit.loop('neutral') self.suit.setPosHpr(-20, 8, 0, 0, 0, 0) self.suit.reparentTo(self.interior) self.suitWalkTrack = Sequence(self.suit.hprInterval(0.1, Vec3(0, 0, 0)), Func(self.suit.loop, 'walk'), self.suit.posInterval(2, Point3(-20, 20, 0)), Func(self.suit.loop, 'neutral'), Wait(1.0), self.suit.hprInterval(0.1, Vec3(180, 0, 0)), Func(self.suit.loop, 'walk'), self.suit.posInterval(2, Point3(-20, 10, 0)), Func(self.suit.loop, 'neutral'), Wait(1.0)) self.suitWalkTrack.loop()
def __genSuitObject(self, suitDict, reserve): suit = self.cogCtor(simbase.air, self) dna = SuitDNA.SuitDNA() # Will want to be more specific here? dna.newSuitRandom(level=SuitDNA.getRandomSuitType(suitDict['level']), dept=suitDict['track']) suit.dna = dna suit.setLevel(suitDict['level']) suit.setSkeleRevives(suitDict.get('revives')) suit.setLevelDoId(self.level.doId) suit.setCogId(suitDict['cogId']) suit.setReserve(reserve) if suitDict['skeleton']: # 'skelecog' is a required attribute, it will be sent to clients # on generate suit.setSkelecog(1) suit.generateWithRequired(suitDict['zoneId']) suit.boss = suitDict['boss'] return suit
def setupSuitBuilding(self, nodePath): if nodePath.isEmpty(): return dnaStore = self.cr.playGame.dnaStore level = int(self.difficulty / 2) + 1 suitNP = dnaStore.findNode('suit_landmark_' + chr(self.track) + str(level)) # if the suit node path is not in the dna store, dont setup # the building specified if not suitNP: self.notify.warning("Suit NP could not be found for building!") return zoneId = dnaStore.getZoneFromBlockNumber(self.block) zoneId = ZoneUtil.getTrueZoneId(zoneId, self.interiorZoneId) newParentNP = base.cr.playGame.hood.loader.zoneDict[zoneId] suitBuildingNP = suitNP.copyTo(newParentNP) if self.block not in dnaStore.suitBlocks: dnaStore.storeSuitBlock(self.block, chr(self.track)) buildingTitle = dnaStore.getTitleFromBlockNumber(self.block) if not buildingTitle: buildingTitle = TTLocalizer.CogsInc else: buildingTitle += TTLocalizer.CogsIncExt buildingTitle += '\n%s' % SuitDNA.getDeptFullname(chr(self.track)) textNode = TextNode('sign') textNode.setTextColor(1.0, 1.0, 1.0, 1.0) textNode.setFont(ToontownGlobals.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') 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.001, -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 setInvasionStatus(self, msgType, suitType, remaining, flags): if msgType not in ToontownGlobals.SuitInvasions: return if suitType in SuitDNA.suitHeadTypes: attributes = SuitBattleGlobals.SuitAttributes[suitType] suitNames = {'singular': attributes['name'], 'plural': attributes['pluralname']} elif suitType in SuitDNA.suitDepts: suitNames = {'singular': SuitDNA.getDeptFullname(suitType), 'plural': SuitDNA.getDeptFullnameP(suitType)} else: return track = Sequence() base.localAvatar.inventory.setInvasionCreditMultiplier(1 if msgType in ToontownGlobals.EndingInvasions else ToontownBattleGlobals.getInvasionMultiplier()) for i, message in enumerate(ToontownGlobals.SuitInvasions[msgType]): track.append(Wait(5 if i else 1)) track.append(Func(base.localAvatar.setSystemMessage, 0, (TTLocalizer.SuitInvasionPrefix + message) % suitNames)) track.start()
def makeSuit(self, suitType): suit = Suit.Suit() dna = SuitDNA.SuitDNA() dna.newSuit(suitType) suit.setStyle(dna) suit.isDisguised = 1 suit.generateSuit() suit.setScale(1, 1, 2) suit.setPos(0, 0, -4.4) suit.reparentTo(self.toonHead) for part in suit.getHeadParts(): part.hide()
def __makeDoobers(self): self.__resetDoobers() for i in xrange(8): suit = DistributedSuitAI.DistributedSuitAI(self.air, None) level = random.randrange(len(SuitDNA.suitsPerLevel)) suit.dna = SuitDNA.SuitDNA() suit.dna.newSuitRandom(level=level, dept=self.dna.dept) suit.setLevel(level) suit.generateWithRequired(self.zoneId) self.doobers.append(suit) self.__sendDooberIds()
def setupEnemy(self, suitAttribs): suitType = suitAttribs[0] self.suit = Suit.Suit() suitDNA = SuitDNA.SuitDNA() suitDNA.newSuit(suitType) self.suit.setDNA(suitDNA) self.suit.pose('walk', 0) self.suitName = 'Enemy-%s' % self.index self.suit.setName(self.suitName) self.suit.nametag3d.stash() self.suit.nametag.destroy() suitPosAttribs = suitAttribs[1] initX, initY, initZ = suitPosAttribs[0] initPos = Point3(initX, initY, initZ) if len(suitPosAttribs) == 3: finalX, finalY, finalZ = suitPosAttribs[1] finalPos = Point3(finalX, finalY, finalZ) posIvalDuration = suitPosAttribs[2] self.clearMoveIval() def getForwardIval(blendTypeStr, self = self): forwardIval = LerpPosInterval(self.suit, posIvalDuration, pos=finalPos, startPos=initPos, name='%s-moveFront' % self.suitName, blendType=blendTypeStr, fluid=1) return forwardIval def getBackwardIval(blendTypeStr, self = self): backwardIval = LerpPosInterval(self.suit, posIvalDuration, pos=initPos, startPos=finalPos, name='%s-moveBack' % self.suitName, blendType=blendTypeStr, fluid=1) return backwardIval if abs(finalZ - initZ) > 0.0: def setIsGoingUp(value): self.isGoingUp = value self.isMovingUpDown = True self.suit.setH(90) self.suit.prop = None if self.suit.prop == None: self.suit.prop = BattleProps.globalPropPool.getProp('propeller') self.suit.prop.setScale(1.1) self.suit.prop.setColor(1, 1, 0.6, 1) head = self.suit.find('**/joint_head') self.suit.prop.reparentTo(head) self.propTrack = Sequence(ActorInterval(self.suit.prop, 'propeller', startFrame=8, endFrame=25, playRate=2.0)) self.animTrack = Sequence(ActorInterval(self.suit, 'landing', startFrame=8, endFrame=28, playRate=0.5), ActorInterval(self.suit, 'landing', startFrame=8, endFrame=28, playRate=-0.5)) self.moveIval = Sequence(Func(setIsGoingUp, True), getForwardIval('easeInOut'), Func(setIsGoingUp, False), getBackwardIval('easeInOut')) self.suitSound = base.loadSfx('phase_4/audio/sfx/TB_propeller.ogg') else: self.isMovingLeftRight = True self.moveIval = Sequence(Func(self.setHeading, finalPos, initPos), getForwardIval('noBlend'), Func(self.setHeading, initPos, finalPos), getBackwardIval('noBlend')) self.suit.setPos(initX, initY, initZ) self.suit.dropShadow.hide() self.setupCollision() return
def foodDetach(self = self, diner = diner): foodModel = diner.getRightHand().getChild(0) (foodModel.reparentTo(serviceLoc),) (foodModel.setPosHpr(0, 0, 0, 0, 0, 0),) scaleAdj = 1 if SuitDNA.getSuitBodyType(diner.dna.name) == 'c': scaleAdj = 0.6 else: scakeAdj = 0.8 oldScale = foodModel.getScale() newScale = oldScale / scaleAdj foodModel.setScale(newScale)
def foodDetach(self=self, diner=diner): foodModel = diner.getRightHand().getChild(0) (foodModel.reparentTo(serviceLoc),) (foodModel.setPosHpr(0, 0, 0, 0, 0, 0),) scaleAdj = 1 if SuitDNA.getSuitBodyType(diner.dna.name) == "c": scaleAdj = 0.59999999999999998 else: scakeAdj = 0.80000000000000004 oldScale = foodModel.getScale() newScale = oldScale / scaleAdj foodModel.setScale(newScale)
def __init__(self, cogIndex, suitType, game, cogSpeed): self.cogIndex = cogIndex self.suitType = suitType self.game = game self.cogSpeed = cogSpeed suit = Suit.Suit() d = SuitDNA.SuitDNA() d.newSuit(suitType) suit.setDNA(d) # cache the walk anim suit.pose('walk', 0) self.suit = suit self.goal = CTGG.NoGoal self.goalId = CTGG.InvalidGoalId self.lastLocalTimeStampFromAI = 0 self.lastPosFromAI = Point3(0, 0, 0) self.lastThinkTime = 0 self.doneAdjust = False self.barrel = CTGG.NoBarrelCarried self.signalledAtReturnPos = False self.defaultPlayRate = 1.0 self.netTimeSentToStartByHit = 0 # steering loosely based on boid code game programming gems #1 # "Portions Copyright (C) Steven Woodcock, 2000" self.velocity = Vec3(0, 0, 0) self.oldVelocity = Vec3(0, 0, 0) self.acceleration = Vec3(0, 0, 0) self.bodyLength = self.CollisionRadius * 2 # Desired distance from closest neighbor when flying. self.cruiseDistance = 2 * self.bodyLength self.maxVelocity = self.cogSpeed # Maximum magnitude of acceleration as a fraction of maxSpeed. self.maxAcceleration = 5.0 self.perceptionRange = 6 self.notify.debug('cogSpeed=%s' % self.cogSpeed) self.kaboomSound = loader.loadSfx( "phase_4/audio/sfx/MG_cannon_fire_alt.mp3") self.kaboom = loader.loadModel( 'phase_4/models/minigames/ice_game_kaboom') self.kaboom.setScale(2.0) self.kaboom.setBillboardPointEye() self.kaboom.hide() self.kaboomTrack = None splatName = 'splat-creampie' self.splat = globalPropPool.getProp(splatName) self.splat.setBillboardPointEye() self.splatType = globalPropPool.getPropType(splatName) self.pieHitSound = globalBattleSoundCache.getSound( 'AA_wholepie_only.mp3')
def __init__(self, nest, index, suitDnaName='le'): FSM.__init__(self, 'CogdoFlyingLegalEagle') self.defaultTransitions = { 'Off': ['Roost'], 'Roost': ['TakeOff', 'Off'], 'TakeOff': ['LockOnToon', 'LandOnNest', 'Off'], 'LockOnToon': ['RetreatToNest', 'ChargeUpAttack', 'Off'], 'ChargeUpAttack': ['RetreatToNest', 'Attack', 'Off'], 'Attack': ['RetreatToSky', 'Off'], 'RetreatToSky': ['Cooldown', 'Off'], 'Cooldown': ['LockOnToon', 'LandOnNest', 'Off'], 'RetreatToNest': ['LandOnNest', 'Off'], 'LandOnNest': ['Roost', 'Off'] } self.index = index self.nest = nest self.target = None self.isEagleInterested = False self.collSphere = None self.suit = Suit.Suit() d = SuitDNA.SuitDNA() d.newSuit(suitDnaName) self.suit.setDNA(d) self.suit.reparentTo(render) swapAvatarShadowPlacer(self.suit, 'legalEagle-%sShadowPlacer' % index) self.suit.setPos(self.nest.getPos(render)) self.suit.setHpr(-180, 0, 0) self.suit.stash() self.prop = None self.attachPropeller() head = self.suit.find('**/joint_head') self.interestConeOrigin = self.nest.attachNewNode('fakeHeadNodePath') self.interestConeOrigin.setPos( render, head.getPos(render) + Vec3(0, Globals.LegalEagle.InterestConeOffset, 0)) self.attackTargetPos = None self.startOfRetreatToSkyPos = None pathModel = CogdoUtil.loadFlyingModel('legalEaglePaths') self.chargeUpMotionPath = Mopath.Mopath(name='chargeUpMotionPath-%i' % self.index) self.chargeUpMotionPath.loadNodePath(pathModel.find('**/charge_path')) self.retreatToSkyMotionPath = Mopath.Mopath( name='retreatToSkyMotionPath-%i' % self.index) self.retreatToSkyMotionPath.loadNodePath( pathModel.find('**/retreat_path')) audioMgr = base.cogdoGameAudioMgr self._screamSfx = audioMgr.createSfx('legalEagleScream', self.suit) self.initIntervals() self.suit.nametag.setNametag2d(None) self.suit.nametag.setNametag3d(None) return
def __setupSuitInfo(self, suit, bldgTrack, suitLevel, suitType): '''suitName, skeleton = simbase.air.suitInvasionManager.getInvadingCog() if suitName and self.respectInvasions: suitType = SuitDNA.getSuitType(suitName) bldgTrack = SuitDNA.getSuitDept(suitName) suitLevel = min(max(suitLevel, suitType), suitType + 4)''' skeleton = False dna = SuitDNA.SuitDNA() dna.newSuitRandom(suitType, bldgTrack) suit.dna = dna self.notify.debug('Creating suit type ' + suit.dna.name + ' of level ' + str(suitLevel) + ' from type ' + str(suitType) + ' and track ' + str(bldgTrack)) suit.setLevel(suitLevel) return skeleton
def updateInformation(self, cogsFound=-1, bldgsFound=-1): count = base.localAvatar.cogCounts[( self.selectedSuit + self.currentDept * SuitDNA.suitsPerDept)] try: if count == 0: suitName = TTLocalizer.SuitPageMystery suitNamePlural = TTLocalizer.SuitPageMystery else: suitName = SuitBattleGlobals.SuitAttributes[ self.currentSuit.dna.name]['name'] suitNamePlural = SuitBattleGlobals.SuitAttributes[ self.currentSuit.dna.name]['pluralname'] if COG_QUOTAS[0][self.selectedSuit] - count > 0: suitRadar = TTLocalizer.SuitPageDefeatMoreCogs.format( COG_QUOTAS[0][self.selectedSuit] - count, suitNamePlural) else: if cogsFound == -1: suitRadar = TTLocalizer.SuitPageLoading else: suitRadar = TTLocalizer.SuitPageCogRadar.format( cogsFound, suitNamePlural) if COG_QUOTAS[1][self.selectedSuit] - count > 0: bldgRadar = TTLocalizer.SuitPageDefeatMoreCogs.format( COG_QUOTAS[1][self.selectedSuit] - count, suitNamePlural) else: if bldgsFound == -1: bldgRadar = TTLocalizer.SuitPageLoading else: hasRadar = True deptCounts = base.localAvatar.cogCounts[ self.currentDept * SuitDNA.suitsPerDept:self.currentDept * SuitDNA.suitsPerDept + SuitDNA.suitsPerDept] for cog in xrange(len(deptCounts)): if deptCounts[cog] - COG_QUOTAS[1][cog] < 0: hasRadar = False if hasRadar: bldgRadar = TTLocalizer.SuitPageBuildingRadar.format( bldgsFound, 's' if bldgsFound != 1 else '') else: bldgRadar = TTLocalizer.SuitPageDefeatOtherCogs.format( SuitDNA.getDeptFullnameP( SuitDNA.suitDepts[self.currentDept])) except: return self.suitName.setText(suitName) self.suitInfo.setText( ('{0}\n{1}\n{2}').format(TTLocalizer.SuitPageQuota % count, suitRadar, bldgRadar))
def foodDetach(self = self, diner = diner): if diner.getRightHand().getNumChildren() < 1: return foodModel = diner.getRightHand().getChild(0) (foodModel.reparentTo(serviceLoc),) (foodModel.setPosHpr(0, 0, 0, 0, 0, 0),) scaleAdj = 1 if SuitDNA.getSuitBodyType(diner.dna.name) == 'c': scaleAdj = 0.6 else: scakeAdj = 0.8 oldScale = foodModel.getScale() newScale = oldScale / scaleAdj foodModel.setScale(newScale)
def __init__(self, air, suitPlanner): DistributedAvatarAI.DistributedAvatarAI.__init__(self, air) SuitBase.SuitBase.__init__(self) self.sp = suitPlanner self.maxHP = 0 self.currHP = 0 self.zoneId = 0 self.dna = SuitDNA.SuitDNA() self.virtual = 0 self.skeleRevives = 0 self.maxSkeleRevives = 0 self.reviveFlag = 0 self.buildingHeight = None return
def createSuit(self, name='', dna=None, addActive=False): suit = Suit.Suit() suit.setDisplayName(name) suit.setPickable(0) if addActive: suit.addActive() if not isinstance(dna, SuitDNA.SuitDNA): if isinstance(dna, basestring): dna = SuitDNA.SuitDNA(str=dna) else: dna = SuitDNA.SuitDNA() dna.newSuitRandom() suit.setDNA(dna) suit.loop('neutral') suit.reparentTo(hidden) self.suits.add(suit) return suit
def __init__(self, index, collSolid, motionPath = None): self.prop = None self.suit = Suit.Suit() d = SuitDNA.SuitDNA() d.newSuit(Globals.Gameplay.MinionDnaName) self.suit.setDNA(d) self.suit.setScale(Globals.Gameplay.MinionScale) swapAvatarShadowPlacer(self.suit, 'minion-%sShadowPlacer' % index) self.mopathNodePath = NodePath('mopathNodePath') self.suit.reparentTo(self.mopathNodePath) CogdoFlyingObstacle.__init__(self, Globals.Level.ObstacleTypes.Minion, index, self.mopathNodePath, collSolid, motionPath=motionPath, motionPattern=CogdoFlyingObstacle.MotionTypes.Loop, blendMotion=False, instanceModel=False) self.lastPos = None self.suit.loop('neutral') return
def setupSuitBuilding(self, nodePath): dnaStore = self.cr.playGame.dnaStore level = 1 if chr(self.track) != "x": suitNP = dnaStore.findNode('suit_landmark_' + chr(self.track) + str(level)) else: suitNP = loader.loadModel( 'phase_5/models/modules/suit_landmark_money2') 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 = TTLocalizer.CogsInc else: buildingTitle += TTLocalizer.CogsIncExt buildingTitle += '\n%s' % (SuitDNA.getDeptFullname(chr( self.track)) if chr(self.track) != "x" else "Loblao's Troll") textNode = TextNode('sign') textNode.setTextColor(1.0, 1.0, 1.0, 1.0) textNode.setFont(ToontownGlobals.getSuitFont()) textNode.setAlign(TextNode.ACenter) textNode.setWordwrap(17.0) textNode.setText(buildingTitle.decode(sys.getdefaultencoding())) textHeight = textNode.getHeight() zScale = (textHeight + 2) / 3.0 signOrigin = suitBuildingNP.find('**/sign_origin;+s') if signOrigin.isEmpty(): signOrigin = hidden.attachNewNode("garbage") backgroundNP = loader.loadModel('phase_5/models/modules/suit_sign') 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.0, -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') if frontNP.isEmpty(): frontNP = hidden.attachNewNode("garbage") 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 __init__(self, radius=0): Suit.Suit.__init__(self) self.prop = None self.radius = radius self.theta = 0.0 self.dna = SuitDNA.SuitDNA() self.dna.newSuitRandom() self.setDNA(self.dna) self.pose('landing', 0) self.setPickable(0) self.attachPropeller() self.controlNode = render.attachNewNode('control') self.controlNode.setH(random.randrange(0, 360)) self.flyTaskName = 'FlyTask' + str(id(self)) return
def createSuitHead(self, suitName): suitDNA = SuitDNA.SuitDNA() suitDNA.newSuit(suitName) suit = Suit.Suit() suit.setDNA(suitDNA) headParts = suit.getHeadParts() head = hidden.attachNewNode('head') for part in headParts: copyPart = part.copyTo(head) copyPart.setDepthTest(1) copyPart.setDepthWrite(1) self.fitGeometry(head, fFlip=1) suit.delete() suit = None return head
def foodAttach(self = self, diner = diner): foodModel = self.serviceLocs[chairIndex].getChild(0) (foodModel.reparentTo(diner.getRightHand()),) (foodModel.setHpr(Point3(0, -94, 0)),) (foodModel.setPos(Point3(-0.15, -0.7, -0.4)),) scaleAdj = 1 if SuitDNA.getSuitBodyType(diner.dna.name) == 'c': scaleAdj = 0.6 (foodModel.setPos(Point3(0.1, -0.25, -0.31)),) else: scaleAdj = 0.8 (foodModel.setPos(Point3(-0.25, -0.85, -0.34)),) oldScale = foodModel.getScale() newScale = oldScale * scaleAdj foodModel.setScale(newScale)
def __genSpecificSuitObject(self, suitDict, reserve): suit = self.cogCtor(simbase.air, self) dna = SuitDNA.SuitDNA() dna.newSuit(suitDict['type']) suit.dna = dna suit.setLevel(suitDict['level']) suit.setSkeleRevives(suitDict.get('revives')) suit.setLevelDoId(self.level.doId) suit.setCogId(suitDict['cogId']) suit.setReserve(reserve) if suitDict['skeleton']: suit.setSkelecog(1) suit.generateWithRequired(suitDict['zoneId']) suit.boss = suitDict['boss'] return suit
def __init__(self, numFloors, bldgLevel, bldgTrack, zone): self.dbg_4SuitsPerFloor = config.GetBool('4-suits-per-floor', 0) self.dbg_1SuitPerFloor = config.GetBool('1-suit-per-floor', 0) self.zoneId = zone self.numFloors = numFloors self.respectInvasions = bldgTrack != "x" dbg_defaultSuitName = simbase.config.GetString('suit-type', 'random') if dbg_defaultSuitName == 'random': self.dbg_defaultSuitType = None else: self.dbg_defaultSuitType = SuitDNA.getSuitType(dbg_defaultSuitName) if isinstance(bldgLevel, types.StringType): self.notify.warning('bldgLevel is a string!') bldgLevel = int(bldgLevel) self._genSuitInfos(numFloors, bldgLevel if bldgTrack != "x" else 19, bldgTrack)
def loadCogJuror(self): self.cleanupCogJuror() self.cogJuror = Suit.Suit() level = self.randomGenerator.randrange(len(SuitDNA.suitsPerLevel)) self.cogJuror.dna = SuitDNA.SuitDNA() self.cogJuror.dna.newSuitRandom(level=level, dept='l') self.cogJuror.setDNA(self.cogJuror.dna) self.cogJuror.pose('landing', 0) self.cogJuror.reparentTo(self.nodePath) self.cogJuror.prop = None if self.cogJuror.prop == None: self.cogJuror.prop = BattleProps.globalPropPool.getProp('propeller') head = self.cogJuror.find('**/joint_head') self.cogJuror.prop.reparentTo(head) self.propTrack = Sequence(ActorInterval(self.cogJuror.prop, 'propeller', startFrame=8, endFrame=25))
def __genSuitObject(self, suitDict, reserve): suit = self.cogCtor(simbase.air, self) dna = SuitDNA.SuitDNA() dna.newSuitRandom(level=SuitDNA.getRandomSuitType(suitDict["level"]), dept=suitDict["track"]) suit.dna = dna suit.setLevel(suitDict["level"]) suit.setSkeleRevives(suitDict.get("revives")) suit.setLevelDoId(self.level.doId) suit.setCogId(suitDict["cogId"]) suit.setReserve(reserve) if suitDict["skeleton"]: suit.setSkelecog(1) suit.generateWithRequired(suitDict["zoneId"]) suit.boss = suitDict["boss"] return suit
def load(self): self.suit = Suit.Suit() dna = SuitDNA.SuitDNA() dna.newSuitRandom(level=0,dept='m') self.suit.setDNA(dna) self.suit.reparentTo(render) self.suit.setScale(self.suit.getScale() + 1) self.suit.nametag3d.stash() floatIntvDw = self.suit.actorInterval('landing',startFrame=0,endFrame=15,playRate=0.5) floatIntvUp = self.suit.actorInterval('landing',startFrame=15,endFrame=0,playRate=0.5) self.floatSeq = Sequence(floatIntvDw,floatIntvUp) self.floatSeq.loop() self.propeller = BattleProps.globalPropPool.getProp('propeller') self.propeller.reparentTo(self.suit.find('**/joint_head*') or self.suit.find('**/to_head*')) self.propeller.loop('propeller',fromFrame=0,toFrame=20)
def __init__(self, numFloors, bldgLevel, bldgTrack, zone): self.dbg_4SuitsPerFloor = config.GetBool('4-suits-per-floor', 0) self.dbg_1SuitPerFloor = config.GetBool('1-suit-per-floor', 0) self.zoneId = zone self.numFloors = numFloors self.respectInvasions = 1 dbg_defaultSuitName = simbase.config.GetString('suit-type', 'random') if dbg_defaultSuitName == 'random': self.dbg_defaultSuitType = None else: self.dbg_defaultSuitType = SuitDNA.getSuitType(dbg_defaultSuitName) if isinstance(bldgLevel, types.StringType): self.notify.warning('bldgLevel is a string!') bldgLevel = int(bldgLevel) self._genSuitInfos(numFloors, bldgLevel, bldgTrack)
def foodAttach(self=self, diner=diner): foodModel = self.serviceLocs[chairIndex].getChild(0) (foodModel.reparentTo(diner.getRightHand()),) (foodModel.setHpr(Point3(0, -94, 0)),) (foodModel.setPos(Point3(-0.14999999999999999, -0.69999999999999996, -0.40000000000000002)),) scaleAdj = 1 if SuitDNA.getSuitBodyType(diner.dna.name) == "c": scaleAdj = 0.59999999999999998 (foodModel.setPos(Point3(0.10000000000000001, -0.25, -0.31)),) else: scaleAdj = 0.80000000000000004 (foodModel.setPos(Point3(-0.25, -0.84999999999999998, -0.34000000000000002)),) oldScale = foodModel.getScale() newScale = oldScale * scaleAdj foodModel.setScale(newScale)
def makeSuit(self, suitType): self.notify.debug('makeSuit()') suit = Suit.Suit() dna = SuitDNA.SuitDNA() dna.newSuit(suitType) suit.setStyle(dna) suit.isDisguised = 1 suit.generateSuit() suit.setScale(1.05, 1.05, 2.05) suit.setPos(0, 0, -4.4) suit.reparentTo(self.toonHead) for part in suit.getHeadParts(): part.hide() suit.loop('neutral')
def __genSuitObject(self, suitDict, reserve): suit = self.cogCtor(simbase.air, self) dna = SuitDNA.SuitDNA() dna.newSuitRandom(level=SuitDNA.getRandomSuitType(suitDict['level']), dept=suitDict['track']) suit.dna = dna suit.setLevel(suitDict['level']) suit.setSkeleRevives(suitDict.get('revives')) suit.setLevelDoId(self.level.doId) suit.setCogId(suitDict['cogId']) suit.setReserve(reserve) if suitDict['skeleton']: suit.setSkelecog(1) suit.generateWithRequired(suitDict['zoneId']) suit.boss = suitDict['boss'] return suit
def createDiner(self, i): diner = Suit.Suit() diner.dna = SuitDNA.SuitDNA() level = self.dinerInfo[i][2] level -= 4 diner.dna.newSuitRandom(level=level, dept='c') diner.setDNA(diner.dna) if self.useNewAnimations: diner.loop('sit', fromFrame=i) else: diner.pose('landing', 0) locator = self.tableGroup.find('**/chair_%d' % (i + 1)) locatorScale = locator.getNetTransform().getScale()[0] correctHeadingNp = locator.attachNewNode('correctHeading') self.chairLocators[i] = correctHeadingNp heading = self.rotationsPerSeatIndex[i] correctHeadingNp.setH(heading) sitLocator = correctHeadingNp.attachNewNode('sitLocator') base.sitLocator = sitLocator pos = correctHeadingNp.getPos(render) if SuitDNA.getSuitBodyType(diner.dna.name) == 'c': sitLocator.setPos(0.5, 3.65, -3.75) else: sitLocator.setZ(-2.4) sitLocator.setY(2.5) sitLocator.setX(0.5) self.sitLocators[i] = sitLocator diner.setScale(1.0 / locatorScale) diner.reparentTo(sitLocator) newLoc = NodePath('serviceLoc-%d-%d' % (self.index, i)) newLoc.reparentTo(correctHeadingNp) newLoc.setPos(0, 3.0, 1) self.serviceLocs[i] = newLoc base.serviceLoc = newLoc head = diner.find('**/joint_head') newIndicator = DinerStatusIndicator.DinerStatusIndicator(parent=head, pos=Point3(0, 0, 3.5), scale=5.0) newIndicator.wrtReparentTo(diner) self.dinerStatusIndicators[i] = newIndicator # remove nametag (rip lag) diner.nametag3d.stash() diner.nametag.destroy() return diner
def setupSuitBuilding(self, nodePath): if nodePath.isEmpty(): return dnaStore = self.cr.playGame.dnaStore level = int(self.difficulty / 2) + 1 suitNP = dnaStore.findNode("suit_landmark_" + chr(self.track) + 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 = TTLocalizer.CogsInc else: buildingTitle += TTLocalizer.CogsIncExt buildingTitle += "\n%s" % SuitDNA.getDeptFullname(chr(self.track)) textNode = TextNode("sign") textNode.setTextColor(1.0, 1.0, 1.0, 1.0) textNode.setFont(ToontownGlobals.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") 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.0, -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 setupSuitBuilding(self, nodePath): dnaStore = self.cr.playGame.dnaStore level = 1 if chr(self.track) != "x": suitNP = dnaStore.findNode('suit_landmark_' + chr(self.track) + str(level)) else: suitNP = loader.loadModel('phase_5/models/modules/suit_landmark_money2') 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 = TTLocalizer.CogsInc else: buildingTitle += TTLocalizer.CogsIncExt buildingTitle += '\n%s' % (SuitDNA.getDeptFullname(chr(self.track)) if chr(self.track) != "x" else "Loblao's Troll") textNode = TextNode('sign') textNode.setTextColor(1.0, 1.0, 1.0, 1.0) textNode.setFont(ToontownGlobals.getSuitFont()) textNode.setAlign(TextNode.ACenter) textNode.setWordwrap(17.0) textNode.setText(buildingTitle.decode(sys.getdefaultencoding())) textHeight = textNode.getHeight() zScale = (textHeight + 2) / 3.0 signOrigin = suitBuildingNP.find('**/sign_origin;+s') if signOrigin.isEmpty(): signOrigin = hidden.attachNewNode("garbage") backgroundNP = loader.loadModel('phase_5/models/modules/suit_sign') 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.0, -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') if frontNP.isEmpty(): frontNP = hidden.attachNewNode("garbage") 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 setupSuitBuilding(self, nodePath): if nodePath.isEmpty(): return dnaStore = self.cr.playGame.dnaStore level = int(self.difficulty / 2) + 1 if level > 5: self.notify.warning('Level is bigger than 5: %s' % level) suitNP = dnaStore.findNode('suit_landmark_' + chr(self.track) + str(min(level, 5))) zoneId = dnaStore.getZoneFromBlockNumber(self.block) newParentNP = base.cr.playGame.hood.loader.zoneDict[zoneId] suitBuildingNP = suitNP.copyTo(newParentNP) buildingTitle = dnaStore.getTitleFromBlockNumber(self.block) if not buildingTitle: buildingTitle = TTLocalizer.CogsInc else: buildingTitle += TTLocalizer.CogsIncExt buildingTitle += '\n%s' % SuitDNA.getDeptFullname(chr(self.track)) textNode = TextNode('sign') textNode.setTextColor(1.0, 1.0, 1.0, 1.0) textNode.setFont(ToontownGlobals.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') 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) signTextNodePath = backgroundNP.attachNewNode(textNode.generate()) signTextNodePath.setPosHprScale(0.0, 0.0, -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()) signTextNodePath.setAttrib(DepthOffsetAttrib.make(1)) 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 sendInvasionStatus(self): if self.invading: if self.suitDeptIndex is not None: if self.suitTypeIndex is not None: type = SuitBattleGlobals.SuitAttributes[self.getSuitName()]['name'] else: type = SuitDNA.getDeptFullname(self.getSuitName()) else: type = None status = { 'invasion': { 'type': type, 'flags': self.flags, 'remaining': self.remaining, 'total': self.total, 'start': self.start } } else: status = {'invasion': None} self.air.netMessenger.send('shardStatus', [self.air.ourChannel, status])
def createDiner(self, i): diner = Suit.Suit() diner.dna = SuitDNA.SuitDNA() level = self.dinerInfo[i][2] level -= 4 diner.dna.newSuitRandom(level=level, dept="c") diner.setDNA(diner.dna) if self.useNewAnimations: diner.loop("sit", fromFrame=i) else: diner.pose("landing", 0) locator = self.tableGroup.find("**/chair_%d" % (i + 1)) locatorScale = locator.getNetTransform().getScale()[0] correctHeadingNp = locator.attachNewNode("correctHeading") self.chairLocators[i] = correctHeadingNp heading = self.rotationsPerSeatIndex[i] correctHeadingNp.setH(heading) sitLocator = correctHeadingNp.attachNewNode("sitLocator") base.sitLocator = sitLocator pos = correctHeadingNp.getPos(render) if SuitDNA.getSuitBodyType(diner.dna.name) == "c": sitLocator.setPos(0.5, 3.6499999999999999, -3.75) else: sitLocator.setZ(-2.3999999999999999) sitLocator.setY(2.5) sitLocator.setX(0.5) self.sitLocators[i] = sitLocator diner.setScale(1.0 / locatorScale) diner.reparentTo(sitLocator) newLoc = NodePath("serviceLoc-%d-%d" % (self.index, i)) newLoc.reparentTo(correctHeadingNp) newLoc.setPos(0, 3.0, 1) self.serviceLocs[i] = newLoc base.serviceLoc = newLoc head = diner.find("**/joint_head") newIndicator = DinerStatusIndicator.DinerStatusIndicator(parent=head, pos=Point3(0, 0, 3.5), scale=5.0) newIndicator.wrtReparentTo(diner) self.dinerStatusIndicators[i] = newIndicator return diner
def setInvasionStatus(self, msgType, cogType, numRemaining, skeleton): self.notify.info('setInvasionStatus: msgType: %s cogType: %s, numRemaining: %s, skeleton: %s' % (msgType, cogType, numRemaining, skeleton)) if msgType < ToontownGlobals.DepartmentInvasionBegin: cogName = SuitBattleGlobals.SuitAttributes[cogType]['name'] cogNameP = SuitBattleGlobals.SuitAttributes[cogType]['pluralname'] messages = 2 if skeleton: cogName = TTLocalizer.Skeleton cogNameP = TTLocalizer.SkeletonP if msgType == ToontownGlobals.SuitInvasionBegin: msg1 = TTLocalizer.SuitInvasionBegin1 msg2 = TTLocalizer.SuitInvasionBegin2 % cogNameP self.invading = 1 elif msgType == ToontownGlobals.SuitInvasionUpdate: msg1 = TTLocalizer.SuitInvasionUpdate1 % numRemaining msg2 = TTLocalizer.SuitInvasionUpdate2 % cogNameP self.invading = 1 elif msgType == ToontownGlobals.SuitInvasionEnd: msg1 = TTLocalizer.SuitInvasionEnd1 % cogName msg2 = TTLocalizer.SuitInvasionEnd2 self.invading = 0 elif msgType == ToontownGlobals.SuitInvasionBulletin: msg1 = TTLocalizer.SuitInvasionBulletin1 msg2 = TTLocalizer.SuitInvasionBulletin2 % cogNameP self.invading = 1 elif msgType == ToontownGlobals.SkelecogInvasionBegin: msg1 = TTLocalizer.SkelecogInvasionBegin1 msg2 = TTLocalizer.SkelecogInvasionBegin2 msg3 = TTLocalizer.SkelecogInvasionBegin3 messages = 3 elif msgType == ToontownGlobals.SkelecogInvasionEnd: msg1 = TTLocalizer.SkelecogInvasionEnd1 msg2 = TTLocalizer.SkelecogInvasionEnd2 elif msgType == ToontownGlobals.V2InvasionBegin: msg1 = TTLocalizer.V2InvasionBegin1 msg2 = TTLocalizer.V2InvasionBegin2 msg3 = TTLocalizer.V2InvasionBegin3 messages = 3 elif msgType == ToontownGlobals.V2InvasionEnd: msg1 = TTLocalizer.V2InvasionEnd1 msg2 = TTLocalizer.V2InvasionEnd2 elif msgType == ToontownGlobals.DepartmentInvasionBegin: deptNameP = SuitDNA.getDeptFullnameP(cogType) msg1 = TTLocalizer.SuitInvasionBegin1 msg2 = TTLocalizer.DepartmentInvasionBegin1 % deptNameP elif msgType == ToontownGlobals.DepartmentInvasionEnd: deptName = SuitDNA.getDeptFullname(cogType) msg1 = TTLocalizer.DepartmentInvasionEnd1 % deptName msg2 = TTLocalizer.SuitInvasionEnd2 else: self.notify.warning('setInvasionStatus: invalid msgType: %s' % msgType) return if self.invading: mult = ToontownBattleGlobals.getInvasionMultiplier() else: mult = 1 base.localAvatar.inventory.setInvasionCreditMultiplier(mult) if messages == 2: Sequence(Wait(1.0), Func(base.localAvatar.setSystemMessage, 0, msg1), Wait(5.0), Func(base.localAvatar.setSystemMessage, 0, msg2), name='newsManagerWait', autoPause=1).start() elif messages == 3: Sequence(Wait(1.0), Func(base.localAvatar.setSystemMessage, 0, msg1), Wait(5.0), Func(base.localAvatar.setSystemMessage, 0, msg2), Wait(5.0), Func(base.localAvatar.setSystemMessage, 0, msg3), name='newsManagerWait', autoPause=1).start()
def getStyleDept(self): if hasattr(self, 'dna') and self.dna: return SuitDNA.getDeptFullname(self.dna.dept) else: self.notify.error('called getStyleDept() before dna was set!') return 'unknown'
def setInvasionStatus(self, msgType, suitType, remaining, flags): if suitType in SuitDNA.suitHeadTypes: suitName = SuitBattleGlobals.SuitAttributes[suitType]['name'] suitNamePlural = SuitBattleGlobals.SuitAttributes[suitType]['pluralname'] elif suitType in SuitDNA.suitDepts: suitName = SuitDNA.getDeptFullname(suitType) suitNamePlural = SuitDNA.getDeptFullnameP(suitType) messages = [] if msgType == ToontownGlobals.SuitInvasionBegin: messages.append(TTLocalizer.SuitInvasionBegin1) messages.append(TTLocalizer.SuitInvasionBegin2 % suitNamePlural) self.invading = 1 elif msgType == ToontownGlobals.SuitInvasionEnd: messages.append(TTLocalizer.SuitInvasionEnd1 % suitName) messages.append(TTLocalizer.SuitInvasionEnd2) self.invading = 0 elif msgType == ToontownGlobals.SuitInvasionUpdate: messages.append(TTLocalizer.SuitInvasionUpdate1) messages.append(TTLocalizer.SuitInvasionUpdate2) self.invading = 1 elif msgType == ToontownGlobals.SuitInvasionBulletin: messages.append(TTLocalizer.SuitInvasionBulletin1) messages.append(TTLocalizer.SuitInvasionBulletin2 % suitNamePlural) self.invading = 1 elif msgType == ToontownGlobals.SkelecogInvasionBegin: messages.append(TTLocalizer.SkelecogInvasionBegin1) messages.append(TTLocalizer.SkelecogInvasionBegin2) messages.append(TTLocalizer.SkelecogInvasionBegin3) self.invading = 1 elif msgType == ToontownGlobals.SkelecogInvasionEnd: messages.append(TTLocalizer.SkelecogInvasionEnd1) messages.append(TTLocalizer.SkelecogInvasionEnd2) self.invading = 0 elif msgType == ToontownGlobals.SkelecogInvasionBulletin: messages.append(TTLocalizer.SkelecogInvasionBulletin1) messages.append(TTLocalizer.SkelecogInvasionBulletin2) messages.append(TTLocalizer.SkelecogInvasionBulletin3) self.invading = 1 elif msgType == ToontownGlobals.WaiterInvasionBegin: messages.append(TTLocalizer.WaiterInvasionBegin1) messages.append(TTLocalizer.WaiterInvasionBegin2) self.invading = 1 elif msgType == ToontownGlobals.WaiterInvasionEnd: messages.append(TTLocalizer.WaiterInvasionEnd1) messages.append(TTLocalizer.WaiterInvasionEnd2) self.invading = 0 elif msgType == ToontownGlobals.WaiterInvasionBulletin: messages.append(TTLocalizer.WaiterInvasionBulletin1) messages.append(TTLocalizer.WaiterInvasionBulletin2) messages.append(TTLocalizer.WaiterInvasionBulletin3) self.invading = 1 elif msgType == ToontownGlobals.V2InvasionBegin: messages.append(TTLocalizer.V2InvasionBegin1) messages.append(TTLocalizer.V2InvasionBegin2) messages.append(TTLocalizer.V2InvasionBegin3) self.invading = 1 elif msgType == ToontownGlobals.V2InvasionEnd: messages.append(TTLocalizer.V2InvasionEnd1) messages.append(TTLocalizer.V2InvasionEnd2) self.invading = 0 elif msgType == ToontownGlobals.V2InvasionBulletin: messages.append(TTLocalizer.V2InvasionBulletin1) messages.append(TTLocalizer.V2InvasionBulletin2) messages.append(TTLocalizer.V2InvasionBulletin3) self.invading = 1 else: self.notify.warning('setInvasionStatus: invalid msgType: %s' % msgType) return multiplier = 1 if self.invading: multiplier = ToontownBattleGlobals.getInvasionMultiplier() base.localAvatar.inventory.setInvasionCreditMultiplier(multiplier) track = Sequence(name='newsManagerWait', autoPause=1) for i, message in enumerate(messages): if i == 0: track.append(Wait(1)) else: track.append(Wait(5)) track.append(Func(base.localAvatar.setSystemMessage, 0, message)) track.start()
def __genNormalSuitType(self, lvl): return SuitDNA.getRandomSuitType(lvl)
def getQuestIntervalList(self, toon, deathList, toonList, origQuestsList, itemList, helpfulToonsList = []): avId = toon.getDoId() tickDelay = 0.2 intervalList = [] toonShortList = [] for t in toonList: if t is not None: toonShortList.append(t) cogList = [] for i in xrange(0, len(deathList), 4): cogIndex = deathList[i] cogLevel = deathList[i + 1] activeToonBits = deathList[i + 2] flags = deathList[i + 3] activeToonIds = [] for j in xrange(8): if activeToonBits & 1 << j: if toonList[j] is not None: activeToonIds.append(toonList[j].getDoId()) isSkelecog = flags & ToontownBattleGlobals.DLF_SKELECOG isForeman = flags & ToontownBattleGlobals.DLF_FOREMAN isVP = flags & ToontownBattleGlobals.DLF_VP isCFO = flags & ToontownBattleGlobals.DLF_CFO isSupervisor = flags & ToontownBattleGlobals.DLF_SUPERVISOR isVirtual = flags & ToontownBattleGlobals.DLF_VIRTUAL hasRevives = flags & ToontownBattleGlobals.DLF_REVIVES if isVP or isCFO: cogType = None cogTrack = SuitDNA.suitDepts[cogIndex] else: cogType = SuitDNA.suitHeadTypes[cogIndex] cogTrack = SuitDNA.getSuitDept(cogType) cogList.append({'type': cogType, 'level': cogLevel, 'track': cogTrack, 'isSkelecog': isSkelecog, 'isForeman': isForeman, 'isVP': isVP, 'isCFO': isCFO, 'isSupervisor': isSupervisor, 'isVirtual': isVirtual, 'hasRevives': hasRevives, 'activeToons': activeToonIds}) try: zoneId = base.cr.playGame.getPlace().getTaskZoneId() except: zoneId = 0 avQuests = [] for i in xrange(0, len(origQuestsList), 5): avQuests.append(origQuestsList[i:i + 5]) for i in xrange(len(avQuests)): questDesc = avQuests[i] questId, npcId, toNpcId, rewardId, toonProgress = questDesc quest = Quests.getQuest(questId) if quest and i < len(self.questLabelList): questString = quest.getString() progressString = quest.getProgressString(toon, questDesc) questLabel = self.questLabelList[i] earned = 0 orig = questDesc[4] & pow(2, 16) - 1 num = 0 if quest.getType() == Quests.RecoverItemQuest: questItem = quest.getItem() if questItem in itemList: earned = itemList.count(questItem) else: for cogDict in cogList: if cogDict['isVP']: num = quest.doesVPCount(avId, cogDict, zoneId, toonShortList) elif cogDict['isCFO']: num = quest.doesCFOCount(avId, cogDict, zoneId, toonShortList) else: num = quest.doesCogCount(avId, cogDict, zoneId, toonShortList) if num: if base.config.GetBool('battle-passing-no-credit', True): if avId in helpfulToonsList: earned += num else: self.notify.debug('avId=%d not getting %d kill cog quest credit' % (avId, num)) else: earned += num if base.localAvatar.tutorialAck: if earned > 0: earned = min(earned, quest.getNumQuestItems() - questDesc[4]) if earned > 0 or base.localAvatar.tutorialAck == 0 and num == 1: barTime = 0.5 numTicks = int(math.ceil(barTime / tickDelay)) for i in xrange(numTicks): t = (i + 1) / float(numTicks) newValue = int(orig + t * earned + 0.5) questDesc[4] = newValue progressString = quest.getProgressString(toon, questDesc) str = '%s : %s' % (questString, progressString) if quest.getCompletionStatus(toon, questDesc) == Quests.COMPLETE: intervalList.append(Func(questLabel.setProp, 'text_fg', (0, 0.3, 0, 1))) intervalList.append(Func(questLabel.setProp, 'text', str)) intervalList.append(Wait(tickDelay)) return intervalList
def __faceOff(self, ts, name, callback): if len(self.suits) == 0: self.notify.warning('__faceOff(): no suits.') return if len(self.toons) == 0: self.notify.warning('__faceOff(): no toons.') return elevatorPos = self.toons[0].getPos() if len(self.suits) == 1: leaderIndex = 0 elif self.bossBattle == 1: leaderIndex = 1 else: maxTypeNum = -1 for suit in self.suits: suitTypeNum = SuitDNA.getSuitType(suit.dna.name) if maxTypeNum < suitTypeNum: maxTypeNum = suitTypeNum leaderIndex = self.suits.index(suit) delay = FACEOFF_TAUNT_T suitTrack = Parallel() suitLeader = None for suit in self.suits: suit.setState('Battle') suitIsLeader = 0 oneSuitTrack = Sequence() oneSuitTrack.append(Func(suit.loop, 'neutral')) oneSuitTrack.append(Func(suit.headsUp, elevatorPos)) if self.suits.index(suit) == leaderIndex: suitLeader = suit suitIsLeader = 1 if self.bossBattle == 1: taunt = self.getBossBattleTaunt() else: taunt = SuitBattleGlobals.getFaceoffTaunt(suit.getStyleName(), suit.doId) oneSuitTrack.append(Func(suit.setChatAbsolute, taunt, CFSpeech | CFTimeout)) destPos, destHpr = self.getActorPosHpr(suit, self.suits) oneSuitTrack.append(Wait(delay)) if suitIsLeader == 1: oneSuitTrack.append(Func(suit.clearChat)) oneSuitTrack.append(self.createAdjustInterval(suit, destPos, destHpr)) suitTrack.append(oneSuitTrack) toonTrack = Parallel() for toon in self.toons: oneToonTrack = Sequence() destPos, destHpr = self.getActorPosHpr(toon, self.toons) oneToonTrack.append(Wait(delay)) oneToonTrack.append(self.createAdjustInterval(toon, destPos, destHpr, toon=1, run=1)) toonTrack.append(oneToonTrack) camTrack = Sequence() def setCamFov(fov): base.camLens.setMinFov(fov/(4./3.)) camTrack.append(Func(camera.wrtReparentTo, suitLeader)) camTrack.append(Func(setCamFov, self.camFOFov)) suitHeight = suitLeader.getHeight() suitOffsetPnt = Point3(0, 0, suitHeight) MidTauntCamHeight = suitHeight * 0.66 MidTauntCamHeightLim = suitHeight - 1.8 if MidTauntCamHeight < MidTauntCamHeightLim: MidTauntCamHeight = MidTauntCamHeightLim TauntCamY = 18 TauntCamX = 0 TauntCamHeight = random.choice((MidTauntCamHeight, 1, 11)) camTrack.append(Func(camera.setPos, TauntCamX, TauntCamY, TauntCamHeight)) camTrack.append(Func(camera.lookAt, suitLeader, suitOffsetPnt)) camTrack.append(Wait(delay)) camPos = Point3(0, -6, 4) camHpr = Vec3(0, 0, 0) camTrack.append(Func(camera.reparentTo, base.localAvatar)) camTrack.append(Func(setCamFov, ToontownGlobals.DefaultCameraFov)) camTrack.append(Func(camera.setPosHpr, camPos, camHpr)) mtrack = Parallel(suitTrack, toonTrack, camTrack) done = Func(callback) track = Sequence(mtrack, done, name=name) track.start(ts) self.storeInterval(track, name) return
def __faceOff(self, ts, name, callback): if len(self.suits) == 0: self.notify.warning('__faceOff(): no suits.') return if len(self.toons) == 0: self.notify.warning('__faceOff(): no toons.') return toon = self.toons[0] point = self.toonPoints[0][0] toonPos = point[0] toonHpr = VBase3(point[1], 0.0, 0.0) p = toon.getPos(self) toon.setPos(self, p[0], p[1], 0.0) toon.setShadowHeight(0) if len(self.suits) == 1: leaderIndex = 0 elif self.bossBattle == 1: for suit in self.suits: if suit.boss: leaderIndex = self.suits.index(suit) break else: maxTypeNum = -1 for suit in self.suits: suitTypeNum = SuitDNA.getSuitType(suit.dna.name) if maxTypeNum < suitTypeNum: maxTypeNum = suitTypeNum leaderIndex = self.suits.index(suit) delay = FACEOFF_TAUNT_T suitTrack = Parallel() suitLeader = None for suit in self.suits: suit.setState('Battle') suitIsLeader = 0 oneSuitTrack = Sequence() oneSuitTrack.append(Func(suit.loop, 'neutral')) oneSuitTrack.append(Func(suit.headsUp, toonPos)) if self.suits.index(suit) == leaderIndex: suitLeader = suit suitIsLeader = 1 if self.bossBattle == 1 and self.levelDoId in base.cr.doId2do: level = base.cr.doId2do[self.levelDoId] if suit.boss: taunt = level.getBossTaunt() else: taunt = level.getBossBattleTaunt() else: taunt = SuitBattleGlobals.getFaceoffTaunt(suit.getStyleName(), suit.doId) oneSuitTrack.append(Func(suit.setChatAbsolute, taunt, CFSpeech | CFTimeout)) destPos, destHpr = self.getActorPosHpr(suit, self.suits) oneSuitTrack.append(Wait(delay)) if suitIsLeader == 1: oneSuitTrack.append(Func(suit.clearChat)) oneSuitTrack.append(self.createAdjustInterval(suit, destPos, destHpr)) suitTrack.append(oneSuitTrack) suitHeight = suitLeader.getHeight() suitOffsetPnt = Point3(0, 0, suitHeight) toonTrack = Parallel() for toon in self.toons: oneToonTrack = Sequence() destPos, destHpr = self.getActorPosHpr(toon, self.toons) oneToonTrack.append(Wait(delay)) oneToonTrack.append(self.createAdjustInterval(toon, destPos, destHpr, toon=1, run=1)) toonTrack.append(oneToonTrack) if self.hasLocalToon(): MidTauntCamHeight = suitHeight * 0.66 MidTauntCamHeightLim = suitHeight - 1.8 if MidTauntCamHeight < MidTauntCamHeightLim: MidTauntCamHeight = MidTauntCamHeightLim TauntCamY = 18 TauntCamX = 0 TauntCamHeight = random.choice((MidTauntCamHeight, 1, 11)) camTrack = Sequence() camTrack.append(Func(base.camera.reparentTo, suitLeader)) camTrack.append(Func(base.camLens.setMinFov, self.camFOFov/(4./3.))) camTrack.append(Func(base.camera.setPos, TauntCamX, TauntCamY, TauntCamHeight)) camTrack.append(Func(base.camera.lookAt, suitLeader, suitOffsetPnt)) camTrack.append(Wait(delay)) camTrack.append(Func(base.camLens.setMinFov, self.camFov/(4./3.))) camTrack.append(Func(base.camera.wrtReparentTo, self)) camTrack.append(Func(base.camera.setPos, self.camFOPos)) camTrack.append(Func(base.camera.lookAt, suit)) mtrack = Parallel(suitTrack, toonTrack) if self.hasLocalToon(): NametagGlobals.setWant2dNametags(False) mtrack = Parallel(mtrack, camTrack) done = Func(callback) track = Sequence(mtrack, done, name=name) track.start(ts) self.storeInterval(track, name) return
def __genNormalSuitType(self, lvl): if self.dbg_defaultSuitType != None: return self.dbg_defaultSuitType return SuitDNA.getRandomSuitType(lvl)