def __init__(self): session = bs.getSession() teams = session.teams if session._useTeams else None self._useTeamColors = session._useTeamColors if teams is not None: self._teams = [weakref.ref(team) for team in teams] else: self._dummyTeam = bs.Team() self._teams = [weakref.ref(self._dummyTeam)] vOffset = -150 if isinstance(session, bs.CoopSession) else -50 self.choosers = [] self.baseVOffset = vOffset self.updatePositions() self.nextAddTeam = 0 # grab available profiles self.reloadProfiles() self._joinInfoText = None
def onBegin(self): bs.CoopGameActivity.onBegin(self) # show controls help in kiosk mode if bs.getEnvironment()['kioskMode']: import bsUtils bsUtils.ControlsHelpOverlay(delay=3000, lifespan=10000, bright=True).autoRetain() if self._preset in ['rookie', 'rookieEasy']: self._excludePowerups = ['curse'] self._haveTnt = False tgb = bs.ToughGuyBotLame if self._preset == 'rookieEasy' else bs.ToughGuyBot self._botTypesInitial = [tgb] * len(self.initialPlayerInfo) bb = bs.BomberBotLame if self._preset == 'rookieEasy' else bs.BomberBot self._botTypes7 = [bb] * (1 if len(self.initialPlayerInfo) < 3 else 2) cb = bs.BomberBot if self._preset == 'rookieEasy' else bs.ChickBot self._botTypes14 = [cb] * (1 if len(self.initialPlayerInfo) < 3 else 2) elif self._preset == 'tournament': self._excludePowerups = [] self._haveTnt = True self._botTypesInitial = [bs.ToughGuyBot] * ( 1 if len(self.initialPlayerInfo) < 2 else 2) self._botTypes7 = [bs.ChickBot] * ( 1 if len(self.initialPlayerInfo) < 3 else 2) self._botTypes14 = [bs.NinjaBot] * ( 1 if len(self.initialPlayerInfo) < 4 else 2) elif self._preset in ['pro', 'proEasy', 'tournamentPro']: self._excludePowerups = ['curse'] self._haveTnt = True self._botTypesInitial = [bs.NinjaBot] * len(self.initialPlayerInfo) tgb = bs.ToughGuyBot if self._preset == 'pro' else bs.ToughGuyBotLame self._botTypes7 = [ tgb ] + [bs.BomberBot] * (1 if len(self.initialPlayerInfo) < 3 else 2) cb = bs.ChickBotPro if self._preset == 'pro' else bs.ChickBot self._botTypes14 = [cb] * (1 if len(self.initialPlayerInfo) < 3 else 2) elif self._preset in ['uber', 'uberEasy']: self._excludePowerups = [] self._haveTnt = True tgb = bs.ToughGuyBotPro if self._preset == 'uber' else bs.ToughGuyBot cb = bs.ChickBotPro if self._preset == 'uber' else bs.ChickBot self._botTypesInitial = [bs.MelBot ] + [tgb] * len(self.initialPlayerInfo) self._botTypes7 = [cb] * (1 if len(self.initialPlayerInfo) < 3 else 2) self._botTypes14 = [bs.PirateBot] * ( 1 if len(self.initialPlayerInfo) < 3 else 2) else: raise Exception() self.setupLowLifeWarningSound() self._dropPowerups(standardPoints=True) bs.gameTimer(4000, self._startPowerupDrops) # make a bogus team for our bots # badTeamName = self.getTeamNameLocalized('Bad Guys') badTeamName = self.getTeamDisplayString('Bad Guys') self._botTeam = bs.Team(1, badTeamName, (0.5, 0.4, 0.4)) for team in [self.teams[0], self._botTeam]: team.gameData['score'] = 0 self.updateScores() # time self._startTime = bs.getGameTime() self._timeText = bs.NodeActor( bs.newNode('text', attrs={ 'vAttach': 'top', 'hAttach': 'center', 'hAlign': 'center', 'color': (1, 1, 0.5, 1), 'flatness': 0.5, 'shadow': 0.5, 'position': (0, -50), 'scale': 1.3, 'text': '' })) self._timeTextInput = bs.NodeActor( bs.newNode('timeDisplay', attrs={'showSubSeconds': True})) bs.getSharedObject('globals').connectAttr('gameTime', self._timeTextInput.node, 'time2') self._timeTextInput.node.connectAttr('output', self._timeText.node, 'text') # self._updateTime() # update fast enough so it looks continuous # self._timeTextTimer = bs.Timer(43,self._updateTime,repeat=True) # our TNT spawner (if applicable) if self._haveTnt: self._tntSpawner = bs.TNTSpawner(position=(0, 1, -1)) self._bots = bs.BotSet() self._botSpawnTimer = bs.Timer(1000, self._updateBots, repeat=True) for b in self._botTypesInitial: self._spawnBot(b)