def toonKilledCogs(self, toon, suitsKilled, zoneId): # Thank you zoneId, very cool! cogStatus = toon.getCogStatus() cogCount = toon.getCogCount() for suit in suitsKilled: if suit['isSkelecog'] or suit['isVP'] or suit['isCFO']: continue if toon.getDoId() in suit['activeToons']: suitIndex = SuitDNA.suitHeadTypes.index(suit['type']) suitDept = SuitDNA.suitDepts.index(suit['track']) cogQuota = COG_QUOTAS[0][SuitDNA.getSuitType(suit['type']) - 1] buildingQuota = COG_QUOTAS[1][SuitDNA.getSuitType(suit['type']) - 1] cogRadar = toon.getCogRadar() if cogRadar[suitDept] == 1: continue cogCount[suitIndex] += 1 cogStatus[suitIndex] = COG_DEFEATED if cogQuota <= cogCount[suitIndex] < buildingQuota: cogStatus[suitIndex] = COG_COMPLETE1 else: cogStatus[suitIndex] = COG_COMPLETE2 toon.b_setCogStatus(cogStatus) toon.b_setCogCount(cogCount) self.updateRadar(toon)
def __init__( self, numFloors, bldgLevel, bldgTrack, zone, respectInvasions=1 ): # when the suit planner interior is created, create information # about all suits that will exist in this building # self.dbg_4SuitsPerFloor = ConfigVariableBool("4-suits-per-floor", 0).getValue() self.dbg_1SuitPerFloor = ConfigVariableBool("1-suit-per-floor", 0).getValue() # formerly called 'wuss-suits' self.zoneId = zone self.numFloors = numFloors # By default, if an invasion is in progress we only generate # suits of that kind. Set this false to turn off this # behavior. self.respectInvasions = respectInvasions # This dbg var forces the creations of all 1 suit type (overrides level/type restrictions) dbg_defaultSuitName = ConfigVariableString('suit-type', 'random').getValue() if (dbg_defaultSuitName == 'random'): self.dbg_defaultSuitType = None else: self.dbg_defaultSuitType = SuitDNA.getSuitType(dbg_defaultSuitName) if (isinstance(bldgLevel, bytes)): self.notify.warning('bldgLevel is a string!') bldgLevel = int(bldgLevel) self._genSuitInfos( numFloors, bldgLevel, bldgTrack ) assert(len(self.suitInfos) > 0)
def __setupSuitInfo( self, suit, bldgTrack, suitLevel, suitType ): """ create dna information for the given suit with the given track and suit type """ suitName, skeleton = simbase.air.suitInvasionManager.getInvadingCog() if suitName and self.respectInvasions: # Override the suit type suitType = SuitDNA.getSuitType(suitName) # Override the building track bldgTrack = SuitDNA.getSuitDept(suitName) # if our type is already specified, we might need to # constrain the level to fit. 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 ) # We can't make a suit a skeleton until after generate. # Pass this info back so we know whether to do it or not return skeleton
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 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 = 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
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 __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 __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 __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 __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 __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 __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 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.0 / 3.0)) 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.wrtReparentTo, base.localAvatar)) camTrack.append(Func(setCamFov, settings['fieldofview'])) 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)
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): # TODO: it looks like we only have the suit that we bumped # into at this point; he may or may not be the boss. # Need to add other suits before battle generate on AI leaderIndex = 0 else: if (self.bossBattle == 1): for suit in self.suits: if suit.boss: leaderIndex = self.suits.index(suit) break else: # otherwise __genSuitInfos ensures nothing, so pick the suit with the highest type to be the leader 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() # Suits stop what they're doing and look at the toons oneSuitTrack.append(Func(suit.loop, 'neutral')) oneSuitTrack.append(Func(suit.headsUp, toonPos)) # Only the suit leader taunts the toons if (self.suits.index(suit) == leaderIndex): suitLeader = suit suitIsLeader = 1 # TODO: have an inside of building taunt here 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)) # Move all suits into position after taunt delay 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) # Do the toons faceoff 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()): # empirical hack to pick a mid-height view, left in to sortof match the old view MidTauntCamHeight = suitHeight * 0.66 MidTauntCamHeightLim = suitHeight - 1.8 if (MidTauntCamHeight < MidTauntCamHeightLim): MidTauntCamHeight = MidTauntCamHeightLim TauntCamY = 18 TauntCamX = 0 TauntCamHeight = random.choice((MidTauntCamHeight, 1, 11)) # Put the camera somewhere camTrack = Sequence() camTrack.append(Func(camera.reparentTo, suitLeader)) camTrack.append(Func(base.camLens.setMinFov, self.camFOFov)) camTrack.append( Func(camera.setPos, TauntCamX, TauntCamY, TauntCamHeight)) camTrack.append(Func(camera.lookAt, suitLeader, suitOffsetPnt)) camTrack.append(Wait(delay)) camTrack.append(Func(base.camLens.setMinFov, self.camFov)) camTrack.append(Func(camera.wrtReparentTo, self)) camTrack.append(Func(camera.setPos, self.camFOPos)) camTrack.append(Func(camera.lookAt, suit)) mtrack = Parallel(suitTrack, toonTrack) if (self.hasLocalToon()): # No arrows - they just get in the way NametagGlobals.setMasterArrowsOn(0) mtrack = Parallel(mtrack, camTrack) done = Func(callback) track = Sequence(mtrack, done, name=name) track.start(ts) self.storeInterval(track, name)
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 # Do the suits faceoff # TODO: get the actual position of the elevator door elevatorPos = self.toons[0].getPos() if (len(self.suits) == 1): leaderIndex = 0 else: if (self.bossBattle == 1): leaderIndex = 1 # __genSuitInfos ensures that multi-suit boss battles will have boss in index 1 (a middle position) else: # otherwise __genSuitInfos ensures nothing, so pick the suit with the highest type to be the leader 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() # Suits stop what they're doing and look at the toons oneSuitTrack.append(Func(suit.loop, 'neutral')) oneSuitTrack.append(Func(suit.headsUp, elevatorPos)) # Only the suit leader taunts the toons if (self.suits.index(suit) == leaderIndex): suitLeader = suit suitIsLeader = 1 # TODO: have an inside of building taunt here if (self.bossBattle == 1): taunt = TTLocalizer.BattleBldgBossTaunt else: taunt = SuitBattleGlobals.getFaceoffTaunt( suit.getStyleName(), suit.doId) oneSuitTrack.append( Func(suit.setChatAbsolute, taunt, CFSpeech | CFTimeout)) # Move all suits into position after taunt delay 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) # Do the toons faceoff 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) # Put the camera somewhere camTrack = Sequence() def setCamFov(fov): base.camLens.setMinFov(fov) camTrack.append(Func(camera.wrtReparentTo, suitLeader)) camTrack.append(Func(setCamFov, self.camFOFov)) suitHeight = suitLeader.getHeight() suitOffsetPnt = Point3(0, 0, suitHeight) # empirical hack to pick a mid-height view, left in to sortof match the old view 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)
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(camera.reparentTo, suitLeader)) camTrack.append(Func(base.camLens.setFov, self.camFOFov)) camTrack.append( Func(camera.setPos, TauntCamX, TauntCamY, TauntCamHeight)) camTrack.append(Func(camera.lookAt, suitLeader, suitOffsetPnt)) camTrack.append(Wait(delay)) camTrack.append(Func(base.camLens.setFov, self.camFov)) camTrack.append(Func(camera.wrtReparentTo, self)) camTrack.append(Func(camera.setPos, self.camFOPos)) camTrack.append(Func(camera.lookAt, suit)) mtrack = Parallel(suitTrack, toonTrack) if self.hasLocalToon(): NametagGlobals.setMasterArrowsOn(0) mtrack = Parallel(mtrack, camTrack) done = Func(callback) track = Sequence(mtrack, done, name=name) track.start(ts) self.storeInterval(track, name) return