def onBegin(self): bs.TeamGameActivity.onBegin(self) self._updateScoreBoard() self._targets = [] # number of targets is based on player count numTargets = min(5,len(self.initialPlayerInfo)+2) for i in range(numTargets): bs.gameTimer(5000+i*1000,self._spawnTarget) # this wrangles our bots self._bots = bs.BotSet() # start some timers to spawn bots bs.gameTimer(1000,bs.Call(self._bots.spawnBot,bs.ToughGuyBot,pos=(3,3,-2),spawnTime=3000)) #bs.gameTimer(2000,bs.Call(self._bots.spawnBot,bs.ToughGuyBot,pos=(-3,3,-2),spawnTime=3000)) #bs.gameTimer(3000,bs.Call(self._bots.spawnBot,bs.NinjaBot,pos=(5,3,-2),spawnTime=3000)) #bs.gameTimer(4000,bs.Call(self._bots.spawnBot,bs.NinjaBot,pos=(-5,3,-2),spawnTime=3000)) # add a few extras for multiplayer if len(self.initialPlayerInfo) > 2: bs.gameTimer(5000,bs.Call(self._bots.spawnBot,bs.ToughGuyBot,pos=(0,3,-5),spawnTime=3000)) if len(self.initialPlayerInfo) > 3: bs.gameTimer(6000,bs.Call(self._bots.spawnBot,bs.ToughGuyBot,pos=(0,3,1),spawnTime=3000)) # note: if spawns were spread out more we'd probably want to set some sort of flag on the # last spawn to ensure we don't inadvertantly allow a 'win' before every bot is spawned. # (ie: if bot 1, 2, and 3 got killed but 4 hadn't spawned yet, the game might end because # it sees no remaining bots. self._updateTimer = bs.Timer(1000,self._update,repeat=True) self._countdown = bs.OnScreenCountdown(150,endCall=self.endGame) bs.gameTimer(4000,self._countdown.start)
def onBegin(self): self.bombSurvivor = None self.light = None self.set = False #Do normal stuff: calls to the main class to operate everything that usually would be done bs.TeamGameActivity.onBegin(self) self.b = [] self.queueLine = [] self.playerIndex = 0 for player in self.players: player.gameData['dead'] = False if player.actor is not None: player.actor.handleMessage(bs.DieMessage()) player.actor.node.delete() self.queueLine.append(player) self.spawnPlayerSpaz( self.queueLine[self.playerIndex % len(self.queueLine)], (0, 3, -2)) self.lastPrize = 'none' self.currentPlayer = self.queueLine[0] #Declare a set of bots (enemies) that we will use later self._bots = bs.BotSet() #make another scoreboard? IDK why I did this, probably to make it easier to refer to in the future self._scoredis = bs.ScoreBoard() #for each team in the game's directory, give them a score of zero for team in self.teams: team.gameData['score'] = 0 #Now we go ahead and put that on the scoreboard for player in self.queueLine: self._scoredis.setTeamValue(player.getTeam(), player.getTeam().gameData['score']) self.resetFlags()
def __init__(self, settings): bs.TeamGameActivity.__init__(self, settings) if self.settings['Epic Mode']: self._isSlowMotion = True self.info = bs.NodeActor( bs.newNode('text', attrs={ 'vAttach': 'bottom', 'hAlign': 'center', 'vrDepth': 0, 'color': (0, .2, 0), 'shadow': 1.0, 'flatness': 1.0, 'position': (0, 0), 'scale': 0.8, 'text': "Modified by Mr.Smoothy", })) self.possession = True self.heldLast = None self.fouled = False self.firstFoul = False self.jb = True self._bots = bs.BotSet() self.hoop = Hoop((0, 5, -8), (1, 1, 1)) self.threePointLine = ThreePointLine().autoRetain() self._scoredis = bs.ScoreBoard() self.referee = Referee bs.gameTimer( 10, bs.Call(self._bots.spawnBot, self.referee, pos=(-6, 3, -6), spawnTime=1))
def onBegin(self): bs.TeamGameActivity.onBegin(self) # drop a wave every few seconds.. and every so often drop the time between waves # ..lets have things increase faster if we have fewer players #self._meteorTime = 3000 t = 7500 if len(self.players) > 2 else 4000 if self.settings['Epic Mode']: t /= 4 #bs.gameTimer(t,self._decrementMeteorTime,repeat=True) # kick off the first wave in a few seconds t = 3000 if self.settings['Epic Mode']: t /= 4 #bs.gameTimer(t,self._setMeteorTimer) # this wrangles our bots self._bots = bs.BotSet() for i in range(self.settings['Max Bots']): bPos = (-7.3+15.3*random.random(),10,-5.5+2.1*random.random()) bs.gameTimer(4000,bs.Call(self._bots.spawnBot,self._getRandomBotType(),pos=bPos,spawnTime=0)) self._updateTimer = bs.Timer(1000,self._onSpazBotDied,repeat=True) self._timer = bs.OnScreenTimer() bs.gameTimer(4000,self._timer.start)
def onBegin(self): bs.TeamGameActivity.onBegin(self) self._bots = bs.BotSet() pt1 = (6.972673935, 4.380775486, -9.424407061) pt2 = (-6.972673935, 4.380775486, -9.424407061) pt3 = (6.972673935, 4.380775486, 3.424407061) pt4 = (-6.972673935, 4.380775486, 3.424407061) for i in range(self.settings['Bombers']): bs.gameTimer( 1000, bs.Call(self._bots.spawnBot, bs.BomberBotStatic, pos=random.choice([pt1, pt2, pt3, pt4]), spawnTime=3000)) self._scoreRegions = [] self._scoreRegions.append( bs.NodeActor( bs.newNode('region', attrs={ 'position': (0.3, 4.044276501, -2.9), 'scale': (11.7, 15, 9.5), 'type': 'box', 'materials': (self.safeRegionMaterial, ) }))) self._timer = bs.OnScreenTimer() bs.gameTimer(4000, self._timer.start) self._updateTimer = bs.Timer(1000, self._onSpazBotDied, repeat=True)
def onBegin(self): bs.CoopGameActivity.onBegin(self) self.setupStandardPowerupDrops() self._timer = bs.OnScreenTimer() bs.gameTimer(4000, self._timer.start) self._won = False self._pro = self.settings.get('preset') in ('Mad', 'God') self._boss = bs.BotSet() bs.gameTimer( 4000, bs.Call(self._boss.spawnBot, BossBot, pos=(0, 3, -5), spawnTime=3000)) bs.gameTimer(7001, bs.WeakCall(self.setupBoss)) bs.gameTimer(40000, bs.WeakCall(self.angryBoss)) if self._pro: bs.gameTimer(80000 if self.settings.get('preset') == 'Mad' \ else 60000, bs.WeakCall(self.madBoss)) if self.settings.get('preset') == 'God': bs.gameTimer(80000, bs.WeakCall(self.godBoss))
def onBegin(self): bs.TeamGameActivity.onBegin(self) self._won = False isPro = self.settings.get('preset') == 'pro' # in pro mode there's no powerups if not isPro: self.setupStandardPowerupDrops() # make our on-screen timer and start it roughly when our bots appear self._timer = bs.OnScreenTimer() bs.gameTimer(4000, self._timer.start) # spawn some baddies self._bots = bs.BotSet() bs.gameTimer( 1000, bs.Call(self._bots.spawnBot, bs.NinjaBot, pos=(3, 3, -2), spawnTime=3000)) bs.gameTimer( 2000, bs.Call(self._bots.spawnBot, bs.NinjaBot, pos=(-3, 3, -2), spawnTime=3000)) bs.gameTimer( 3000, bs.Call(self._bots.spawnBot, bs.NinjaBot, pos=(5, 3, -2), spawnTime=3000)) bs.gameTimer( 4000, bs.Call(self._bots.spawnBot, bs.NinjaBot, pos=(-5, 3, -2), spawnTime=3000)) # add some extras for multiplayer or pro mode if len(self.initialPlayerInfo) > 2 or isPro: bs.gameTimer( 5000, bs.Call(self._bots.spawnBot, bs.NinjaBot, pos=(0, 3, -5), spawnTime=3000)) if len(self.initialPlayerInfo) > 3 or isPro: bs.gameTimer( 6000, bs.Call(self._bots.spawnBot, bs.NinjaBot, pos=(0, 3, 1), spawnTime=3000))
def onBegin(self): bs.TeamGameActivity.onBegin(self) self._won = False self.setupStandardPowerupDrops() # make our on-screen timer and start it roughly when our bots appear self._timer = bs.OnScreenTimer() bs.gameTimer(4000, self._timer.start) # this wrangles our bots self._bots = bs.BotSet() # spawn some baddies self._bots = bs.BotSet() bs.gameTimer( 1000, bs.Call(self._bots.spawnBot, bs.MelBotStatic, pos=(6, 7, -6), spawnTime=3000)) bs.gameTimer( 2000, bs.Call(self._bots.spawnBot, bs.ToughGuyBotProShielded, pos=(-3, 10, -2), spawnTime=3000)) bs.gameTimer( 3000, bs.Call(self._bots.spawnBot, bs.NinjaBotProShielded, pos=(5, 6, -2), spawnTime=3000)) bs.gameTimer( 4000, bs.Call(self._bots.spawnBot, bs.BomberBotProShielded, pos=(-5, 6, -2), spawnTime=3000)) bs.gameTimer( 5000, bs.Call(self._bots.spawnBot, bs.ChickBotStatic, pos=(-6, 7, -6), spawnTime=3000))
def __init__(self, position=(0, 1, 0), team=None): bs.Actor.__init__(self) self.errorSound = bs.getSound('error') self.position = position self._team = team # Where do we place block? self.loc = bs.newNode('shield', attrs={ 'position': position, 'radius': 0.01, 'color': (-8, -2, -2) }) # Block. self.body = bs.newNode('prop', delegate=self, attrs={ 'body': 'box', 'modelScale': 1, 'bodyScale': 1, 'model': bs.getModel('tnt'), 'colorTexture': bs.getTexture('powerupCurse'), 'materials': [ bs.getSharedObject('footingMaterial'), bs.getSharedObject('objectMaterial') ] }) self.loc.connectAttr('position', self.body, 'position') self.hp = 8000 self.frozen = False # On freeze block don't spawn enemies. self.position = position # For spawn bots. if self._team is None: self._bots = bs.BotSet() self._botSpawnCooldown = 5000 self.spawner = bs.Timer(self._botSpawnCooldown, self._spawnBot, repeat=True) self._scoreText = bs.newNode('text', owner=self.body, attrs={ 'text': 'HP: ' + str(self.hp), 'inWorld': True, 'shadow': 1.0, 'flatness': 1.0, 'color': (0, 1, 0), 'scale': 0.01, 'hAlign': 'center', 'position': self.position }) bs.gameTimer(1000, self._scoreText.delete)
def onBegin(self): bs.TeamGameActivity.onBegin(self) self._won = False self.setupStandardPowerupDrops() # make our on-screen timer and start it roughly when our bots appear self._timer = bs.OnScreenTimer() bs.gameTimer(4000, self._timer.start) # this wrangles our bots self._bots = bs.BotSet() # start some timers to spawn bots bs.gameTimer( 2000, bs.Call(self._bots.spawnBot, bs.MelBot, pos=(3, 3, -2), spawnTime=3000)) bs.gameTimer( 2000, bs.Call(self._bots.spawnBot, bs.ChickBot, pos=(-3, 3, -2), spawnTime=3000)) bs.gameTimer( 2000, bs.Call(self._bots.spawnBot, bs.ToughGuyBotPro, pos=(5, 3, -2), spawnTime=3000)) bs.gameTimer( 2000, bs.Call(self._bots.spawnBot, bs.BomberBotPro, pos=(-5, 3, -2), spawnTime=3000)) bs.gameTimer( 2000, bs.Call(self._bots.spawnBot, bs.BomberBot, pos=(0, 3, -5), spawnTime=3000)) bs.gameTimer( 2000, bs.Call(self._bots.spawnBot, bs.PirateBotNoTimeLimit, pos=(0, 3, 1), spawnTime=10000))
def spawnBots(self): self._gamescore = 0 self._bots = bs.BotSet() # Display a warning message bs.screenMessage('Here come the Bots', color=(1, 0, 0)) # Generate 100 kronks in random positions for i in range(0, 10): # (This is the center) p = [0, 2.5, -3] bs.gameTimer( 1000, bs.Call(self._bots.spawnBot, bs.ToughGuyBotLame, pos=(p[0] + random.randint(-3, 3), 2.5, p[2] + random.randint(-3, 3)), spawnTime=3000))
def onBegin(self): bs.CoopGameActivity.onBegin(self) # spit out a few powerups and start dropping more shortly self._dropPowerups(standardPoints=True) bs.gameTimer(2000,bs.WeakCall(self._startPowerupDrops)) bs.gameTimer(1,bs.WeakCall(self._startBotUpdates)) self.setupLowLifeWarningSound() self._updateScores() self._bots = bs.BotSet() self._dingSound = bs.getSound('dingSmall') self._dingSoundHigh = bs.getSound('dingSmallHigh') # our TNT spawner (if applicable) self._tntSpawner = bs.TNTSpawner(position=self._tntSpawnPosition,respawnTime=10000)
def onBegin(self): # there's a player-wall on the tower-d level to prevent # players from getting up on the stairs.. we wanna kill that self.setupStandardPowerupDrops() bs.TeamGameActivity.onBegin(self) self._updateScoreBoard() self._updateTimer = bs.Timer(250, self._update, repeat=True) self._countdown = bs.OnScreenCountdown(3600, endCall=self.endGame) bs.gameTimer(4000, self._countdown.start) self._bots = bs.BotSet() # spawn evil bunny in co-op only if isinstance(self.getSession(), bs.CoopSession): self._spawnBigMommy()
def onBegin(self): bs.TeamGameActivity.onBegin(self) self._updateScoreBoard() self._bots = bs.BotSet() delay = 4000 for i in range(self.settings['Max Bots']): bPos = (-7.3 + 15.3 * random.random(), 10, -5.5 + 2.1 * random.random()) bs.gameTimer( delay, bs.Call(self._bots.spawnBot, self._getRandomBotType(), pos=bPos, spawnTime=0)) delay += 300
def onBegin(self): bs.TeamGameActivity.onBegin(self) self.setupStandardTimeLimit(self.settings['Time Limit']) bs.gameTimer(5000, self.spawnZone) self._bots = bs.BotSet() bs.gameTimer(3000, bs.Call(self.addBot, 'left')) bs.gameTimer(3000, bs.Call(self.addBot, 'right')) if len(self.initialPlayerInfo) > 4: bs.gameTimer(5000, bs.Call(self.addBot, 'right')) bs.gameTimer(5000, bs.Call(self.addBot, 'left')) self._choseText = bs.newNode('text', attrs={ 'vAttach': 'bottom', 'hAttach': 'left', 'text': ' ', 'opacity': 1.0, 'maxWidth': 150, 'hAlign': 'center', 'vAlign': 'center', 'shadow': 1.0, 'flatness': 1.0, 'color': (1, 1, 1), 'scale': 1, 'position': (50, 155) }) if (isinstance(self.getSession(), bs.TeamsSession) and self.settings['Balance Total Lives'] and len(self.teams[0].players) > 0 and len(self.teams[1].players) > 0): if self._getTotalTeamLives( self.teams[0]) < self._getTotalTeamLives(self.teams[1]): lesserTeam = self.teams[0] greaterTeam = self.teams[1] else: lesserTeam = self.teams[1] greaterTeam = self.teams[0] addIndex = 0 while self._getTotalTeamLives( lesserTeam) < self._getTotalTeamLives(greaterTeam): lesserTeam.players[addIndex].gameData['lives'] += 1 addIndex = (addIndex + 1) % len(lesserTeam.players) self._updateIcons() bs.gameTimer(1000, self._update, repeat=True)
def onBegin(self): # there's a player-wall on the tower-d level to prevent # players from getting up on the stairs.. we wanna kill that self.getMap().playerWall.delete() bs.TeamGameActivity.onBegin(self) self._updateScoreBoard() self._updateTimer = bs.Timer(250, self._update, repeat=True) self._countdown = bs.OnScreenCountdown(60, endCall=self.endGame) bs.gameTimer(4000, self._countdown.start) self._bots = bs.BotSet() # spawn evil bunny in co-op only if isinstance(self.getSession(), bs.CoopSession) and self._proMode: self._spawnEvilBunny()
def onBegin(self): bs.TeamGameActivity.onBegin(self) # bs.gameTimer(t,self._decrementMeteorTime,repeat=True) # kick off the first wave in a few seconds t = self.settings[JungleHunterLanguage.spawnDelay] * 1000 if self.settings['Epic Mode']: t /= 4 # bs.gameTimer(t,self._setMeteorTimer) self._timer = bs.OnScreenTimer() self._timer.start() self._updateScoreBoard() bs.gameTimer(4000, self._checkEndGame) # 4秒之后检测一波 self._bots = bs.BotSet() bs.gameTimer(1000, bs.Call(self._bots.spawnBot, NinjaPrey, pos=self.getMap().getFFAStartPosition(self.players), spawnTime=100), repeat=False) bs.gameTimer(t, bs.WeakCall(self.botsGener), repeat=True)
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)
def onBegin(self): bs.Activity.onBegin(self) if not hasattr(self, "_standardTimeLimitTime") or not hasattr( self, "_standardTimeLimitTimer"): self.setupStandardTimeLimit() if some.floating_landmine: self.flo = floater.Floater(self._mapType()) MapBounds = self.getMap().getDefBoundBox("levelBounds") def snowfall(): for i in range(5): pos = (random.uniform(MapBounds[0], MapBounds[3]), MapBounds[4] - random.uniform(0, 0.3), random.uniform(MapBounds[2], MapBounds[5])) #vel2 = (random.uniform(-2,2),0,random.uniform(-2,2)) #color = (random.uniform(.5,1),random.uniform(0.5,1),random.uniform(.5,1)) # portalObjects.Bubble(position=pos,velocity=vel2,thrust=0,color=color) vel = (0, 0, 0) # (random.uniform(-2,2),0,random.uniform(-2,2)) bs.emitBGDynamics(position=pos, velocity=vel, count=5, scale=0.5, spread=0.2, chunkType="ice") if some.snowfall: bs.gameTimer(100, snowfall, True) def light(): abc = bs.newNode('light', attrs={ 'position': (0, 10, 0), 'color': (0.2, 0.2, 0.4), 'volumeIntensityScale': 1.0, 'radius': 10 }) bsUtils.animate(abc, "intensity", { 0: 1, 50: 10, 150: 5, 250: 0, 260: 10, 410: 5, 510: 0 }) ho = random.random() * 20000 from random import randint ho = (randint(5, 20) * 1000) bs.gameTimer(int(ho), light) def NightMode(): import datetime now = datetime.datetime.now() if now.hour >= 19 or now.hour <= 7: bs.getSharedObject('globals').tint = (0.5, 0.7, 1) light() some.night = True else: some.night = False NightMode() s = self.getSession() try: self._bots = bs.BotSet() self.botTypes = [ bs.BomberBot, bs.BomberBotPro, bs.BomberBotProShielded, bs.ToughGuyBot, bs.ToughGuyBotPro, bs.ToughGuyBotProShielded, bs.ChickBot, bs.ChickBotPro, bs.ChickBotProShielded, bs.NinjaBot, bs.MelBot, bs.PirateBot ] def btspawn(): if len(self.players) == 1: try: if not self._bots.haveLivingBots(): pt = (self.players[0].actor.node.position[0], self.players[0].actor.node.position[1] + 2, self.players[0].actor.node.position[2]) self._bots.spawnBot(random.choice(self.botTypes), pos=pt, spawnTime=500) except: pass else: self.botTimer = None self.botTimer = bs.gameTimer(1000, btspawn, True) if isinstance(s, bs.CoopSession): import bsUI bsInternal._setAnalyticsScreen( 'Coop Game: ' + s._campaign.getName() + ' ' + s._campaign.getLevel(bsUI.gCoopSessionArgs['level']).getName()) bsInternal._incrementAnalyticsCount('Co-op round start') if len(self.players) == 1: bs.screenMessage( 'No Human Player Available, Push Your Rank With Bots Until Someone Comes!' ) bsInternal._incrementAnalyticsCount( 'Co-op round start 1 human player') elif len(self.players) == 2: bsInternal._incrementAnalyticsCount( 'Co-op round start 2 human players') elif len(self.players) == 3: bsInternal._incrementAnalyticsCount( 'Co-op round start 3 human players') elif len(self.players) >= 4: bsInternal._incrementAnalyticsCount( 'Co-op round start 4+ human players') elif isinstance(s, bs.TeamsSession): bsInternal._setAnalyticsScreen('Teams Game: ' + self.getName()) bsInternal._incrementAnalyticsCount('Teams round start') if len(self.players) == 1: bsInternal._incrementAnalyticsCount( 'Teams round start 1 human player') elif len(self.players) > 1 and len(self.players) < 8: bsInternal._incrementAnalyticsCount('Teams round start ' + str(len(self.players)) + ' human players') elif len(self.players) >= 8: bsInternal._incrementAnalyticsCount( 'Teams round start 8+ human players') elif isinstance(s, bs.FreeForAllSession): bsInternal._setAnalyticsScreen('FreeForAll Game: ' + self.getName()) bsInternal._incrementAnalyticsCount('Free-for-all round start') if len(self.players) == 1: bsInternal._incrementAnalyticsCount( 'Free-for-all round start 1 human player') elif len(self.players) > 1 and len(self.players) < 8: bsInternal._incrementAnalyticsCount( 'Free-for-all round start ' + str(len(self.players)) + ' human players') elif len(self.players) >= 8: bsInternal._incrementAnalyticsCount( 'Free-for-all round start 8+ human players') except Exception: bs.printException("error setting analytics screen") # for some analytics tracking on the c layer.. bsInternal._resetGameActivityTracking() # we dont do this in onTransitionIn because it may depend on # players/teams which arent available until now bs.gameTimer(1, bs.WeakCall(self.showScoreBoardInfo)) bs.gameTimer(1000, bs.WeakCall(self.showInfo)) bs.gameTimer(2500, bs.WeakCall(self._showTip)) # store some basic info about players present at start time self.initialPlayerInfo = [{ 'name': p.getName(full=True), 'character': p.character } for p in self.players] # sort this by name so high score lists/etc will be consistent # regardless of player join order.. self.initialPlayerInfo.sort(key=lambda x: x['name']) # if this is a tournament, query info about it such as how much # time is left try: tournamentID = self.getSession()._tournamentID except Exception: tournamentID = None if tournamentID is not None: bsInternal._tournamentQuery(args={ 'tournamentIDs': [tournamentID], 'source': 'in-game time remaining query' }, callback=bs.WeakCall( self._onTournamentQueryResponse))
def opt(self, clientID=None, msg=""): global gEvent, admins, vips, settings global banned, prefixes if gSettingsEnabled: settings = bs.get_settings() admins, vips, banned, prefixes = settings.get("admins", []), settings.get("vips", []), \ settings.get("banned", []), settings.get("prefixes", {}) a = bsInternal._getForegroundHostActivity() roster = bsInternal._getGameRoster() if gEvent is None: gEvent = bsInternal._getAccountMiscReadVal('easter', False) def format_message(msg=''): msg = msg.replace("/", "") mg = msg.split(" ") command = mg[0].lower() if len(mg) > 1: arg = mg[1:] for i in range(len(arg)): key = arg[i] c = is_account(key, True) if c is not None: arg[i] = c else: arg[i] = key.lower() else: arg = [] if self.player is not None and self.player.exists() and command in ['s', 'summon'] and hasattr(self.player.actor.node, 'position'): if ('~' in arg) or ('^' in arg): rng = (2, 5) if len(arg) > 0: if arg[0] in ['f','flag']: rng = (1, 4) for i in range(rng[0], rng[1]): if len(arg) > i and arg[i] in ["~", "^"]: arg[i] = self.player.actor.node.position[i-rng[0]] return msg, command, arg def check_player(): global admins self.is_vip = self.is_admin = self.is_host = False self.player = None host = get_account_string(arg=bsInternal._getAccountDisplayString(True)) if gSettingsEnabled: hosts = bs.get_setting("hosts", []) if host not in hosts: hosts.append(host) bs.set_setting("hosts", hosts) else: hosts = [] if len(roster) > 0: account = None for i in roster: if i['clientID'] == clientID: account = i['displayString'].decode('utf-8') break if account is not None: if account in vips: self.is_vip = True if account in admins: self.is_vip = self.is_admin = True if account == host or (account != host and account in hosts): self.is_host = self.is_admin = self.is_vip = True for i in a.players: if i.exists(): id = i.getInputDevice().getClientID() if id == clientID: self.player = i else: self.is_host = self.is_admin = self.is_vip = True if len(a.players) > 0: self.player = a.players[0] check_player() msg, command, arg = format_message(msg=msg) if a is not None: with bs.Context(a): if command in ["h", "help"] and self.is_vip: commands, num = {1: []}, 1 def add_commands(cmds=[], commands={1: []}, num=1): for i in cmds: if len(commands[num]) < 30: commands[num].append(i) else: num += 1 commands[num] = [] commands[num].append(i) return commands, num commands, num = add_commands(["help - помощь", "time - установить время", \ "skin - изменить облик", "kick - выгнать из игры", \ "end - закончить игру", "sm - замедленный режим игры", \ "rise - возродить", "frozen - заморозить", "shatter - разделить на части"], commands=commands, num=num) if self.is_admin: commands, num = add_commands(['summon - вызвать объект', 'vip - выдать права vip-пользователя', \ 'punch - сила удара', 'hitpoints - очки жизни', 'prefix - выдать префикс', \ 'ban - забанить', 'mp - максимальное кол-во игроков', \ 'pause - остановить/продолжить игру', \ 'sleep - усыпить', 'head - ребят я черешня', \ 'nodes - список всех типов объектов на карте', 'connect - а это че', \ 'curse - проклятие'], commands=commands, num=num) if gEvent: commands, num = add_commands(['flex - хайпово флексить'], commands=commands, num=num) if self.is_admin: commands, num = add_commands(['dance - станцевать брейк', 'dance2 - станцевать лезгинку', 'party - устроить вечеринку'], commands=commands, num=num) if self.is_host: commands, num = add_commands(['default - отобрать права пользователя', \ 'admin - выдать права администратора'], commands=commands, num=num) commands, num = add_commands(['help [номер страницы] - следующий список команд', \ 'команды могут выполняться через спец-символ ;', 'pause;/pause(перед каждой командой /)'], commands=commands, num=num) num = 1 if len(arg) > 0 and bigger_than_zero(arg[0]): num=int(arg[0]) commands = commands.get(num, []) for i in commands: send_message(i) elif command in ["l", "list"] and self.is_vip: if len(roster) > 0: players = [] for i in [[c["id"] for c in k["players"]] for k in roster]: for d in i: players.append(d) players.sort() for i in roster: data = [(", ").join([r["nameFull"] for r in i["players"]]) if len(i["players"]) > 0 else " - ", (", ").join([str(players.index(r)) for r in [c["id"] for c in i["players"]]]) if len(i["players"]) > 0 else " - "] bsInternal._chatMessage(i["displayString"] + " : "+ data[0] + " : " + data[1]) else: if len(a.players) > 0: for i in a.players: bsInternal._chatMessage(i.getInputDevice().getPlayer().getName(True) + " : " + str(a.players.index(i))) else: send_message(" - ") elif command in ['timeset', 'time'] and self.is_vip: if len(arg) > 0: tint = get_tint() self.time.update({"normal": get_normal_tint()}) for i in self.time: if arg[0] == i: bs.getSharedObject("globals").tint = tint = self.time[i] break if arg[0] == 'cycle': bs.getSharedObject('globals').tint = tint = get_normal_tint() set_tint(tint=tint) else: for i in ['time [normal|sunrise|day|noon|sunset|night|cycle]', \ 'timeset cycle - дневной цикл(плавная смена времени)', \ 'timeset noon - середина дня', 'timeset sunset - закат']: send_message(i) elif command in ['summon','s'] and self.is_admin: if len(arg) > 0: if arg[0] in ['bomb','b']: if len(arg) > 1: bombs = [i.lower() for i in gBombs] bombType, pos, count = 'normal', [0, 5, 0], 1 bombType = gBombs[bombs.index(arg[1].lower())] if arg[1].lower() in bombs else 'normal' if len(arg) > 5: count = min(30, int(arg[5])) if bigger_than_zero(arg[5]) else 1 for i in range(2, 5): if len(arg) > i and is_num(arg[i]): pos[i-2] = float(arg[i]) for i in range(count): bs.Bomb(position=tuple(pos), bombType=bombType).autoRetain() else: mg = bs.text_split(words=gBombs) mg += "s bomb [название] [позиция(3 числа)] [кол-во]\ns bomb normal 0 5 0 1" for i in mg.split('\n'): send_message(i) elif arg[0] in ['bot']: if len(arg) > 1: bots = [i.lower() for i in gBots] botType, pos, count = 'BomberBot', [0, 5, 0], 1 botType = gBots[bots.index(arg[1].lower())] if arg[1].lower() in bots else 'BomberBot' if len(arg) > 5: count = min(30, int(arg[5])) if bigger_than_zero(arg[5]) else 1 for i in range(2, 5): if len(arg) > i and is_num(arg[i]): pos[i-2] = float(arg[i]) if hasattr(bsSpaz, botType): bot = eval("bsSpaz."+botType) if not hasattr(self, "_bots") or (hasattr(self, "_bots") and self._bots is None): self._bots = bs.BotSet() for i in range(count): self._bots.spawnBot(bot, pos=tuple(pos), spawnTime=0, onSpawnCall=self._on_spawn) else: mg = bs.text_split(words=gBots, words_count=3) mg += "s bot [название] [позиция(3 числа)] [кол-во]\ns bot BomberBot 0 5 0 1" for i in mg.split('\n'): send_message(i) elif arg[0] in ['flag','f']: if len(arg) > 1: pos, count, time_out, color = [0, 5, 0], 1, 20, [1, 1, 0] if len(arg) > 4: count = min(30, int(arg[4])) if bigger_than_zero(arg[4]) else 1 if len(arg) > 5: time_out = int(arg[5]) if bigger_than_zero(arg[5]) else 20 for i in range(1, 4): if len(arg) > i and is_num(arg[i]): pos[i-1] = float(arg[i]) for i in range(6, 9): if len(arg) > i and is_num(arg[i]): color[i-6] = float(arg[i]) for i in range(count): bs.Flag(position=tuple(pos), droppedTimeout=time_out, color=color).autoRetain() else: for i in ["s flag [позиция(3 числа)] [кол-во] [тайм-аут] [цвет(3 числа)]", \ "s flag 0 5 0", "s flag ~ ~ ~ 10 999 1 0 0"]: send_message(i) elif arg[0] in ['powerup','p']: if len(arg) > 1: powerups = [i.lower() for i in gPowerups] powerupType, pos, count = 'punch', [0, 5, 0], 1 powerupType = gPowerups[powerups.index(arg[1].lower())] if arg[1].lower() in powerups else 'punch' if len(arg) > 5: count = min(30, int(arg[5])) if bigger_than_zero(arg[5]) else 1 for i in range(2, 5): if len(arg) > i and is_num(arg[i]): pos[i-2] = float(arg[i]) for i in range(count): bs.Powerup(position=tuple(pos),powerupType=powerupType).autoRetain() else: mg = bs.text_split(words=gPowerups) mg += "s p [название] [позиция(3 числа)] [кол-во]\ns p punch 0 5 0 1" for i in mg.split('\n'): send_message(i) elif arg[0] in ['box']: if len(arg) > 1: boxTypes = ['s','small','big','b'] boxType, pos, count = 'small', [0, 5, 0], 1 boxType = arg[1].lower() if arg[1].lower() in boxTypes else 'small' if len(arg) > 5: count = min(30, int(arg[5])) if bigger_than_zero(arg[5]) else 1 for i in range(2, 5): if len(arg) > i and is_num(arg[i]): pos[i-2] = float(arg[i]) for i in range(count): Box(pos=tuple(pos), scale=1 if boxType in ["s","small"] else 1.38, owner=None).autoRetain() else: for i in ["s box [small|big] [позиция] [кол-во]", \ "s box small 0 5 0", "s box big ~ ~ ~ 5"]: send_message(i) else: for i in ["summon [bomb|powerup|bot|box|flag]", "bomb - вызвать бомбу.", "powerup - вызвать усилитель.", "bot - вызвать бота.", "box - вызвать коробку."]: send_message(i) elif command in ['skin'] and self.is_vip: if len(arg) > 0: if len(arg) < 2: arg.append(get_account_string(self.player)) if arg[0] in gSkins or arg[0] == 'delete': account = is_account(arg[1], True) if arg[1] == "all": if arg[0] == 'delete': for i in a.players: skins.delete_skin(i) else: skins.change_skin(skin=arg[0], players=[a.players]) elif account is not None: if arg[0] == 'delete': skins.delete_skin(account) else: skins.change_skin(skin=arg[0], players=[account]) elif is_num(arg[1]): if len(a.players) > int(arg[1]) and int(arg[1]) >= 0: if arg[0] == 'delete': skins.delete_skin(int(arg[1])) else: skins.change_skin(skin=arg[0], players=[int(arg[1])]) else: mg = bs.text_split(words=gSkins) mg += "skin [название] [номер игрока]\nskin bunny 0\nskin pixie" for i in mg.split('\n'): send_message(i) elif command in ['ph','punch','hp','hitpoints'] and self.is_admin: if len(arg) > 0 and len(a.players) > 0: if len(arg) < 2: player = [self.player] if len(arg) > 1: if is_num(arg[1]) and len(a.players) > int(arg[1]) and int(arg[1]) >= 0: player = [a.players[int(arg[1])]] elif arg[1] == "all": player = a.players if player is not None: if bigger_than_zero(arg[0]): arg[0] = int(arg[0]) if command in ["punch", "ph"] and arg[0] > 10: arg[0] = 10 for i in player: if i.exists(): if command in ["punch", "ph"]: i.actor._punchPowerScale = arg[0] else: i.actor.hitPointsMax = i.actor.hitPoints = arg[0] else: for i in [command+" [число] [номер игрока | all]", \ command+" 1000 0", command+" 10 all"]: send_message(i) elif (command in ['vip'] and self.is_admin) or (command in ['admin'] and self.is_host): if len(arg) > 0: self.add_admin(True if command == "admin" else False, get_account_string(arg[0])) else: for i in [command+" [номер игрока|имя аккаунта]", \ command+" 0", command+u" \ue030PC123456"]: send_message(i) elif command in ['df','default'] and self.is_host: if len(arg) > 0: self.del_admin(get_account_string(arg[0])) else: for i in [command+" [номер игрока|имя аккаунта]", \ command+" 0", command+u" \ue030PC123456"]: send_message(i) elif command in ['prefix'] and self.is_admin: global prefixes if len(arg) > 0: type = arg[1] if len(arg) > 1 else "spark" prefix = "prefix" if len(arg) < 3 else (" ").join(msg.split(" ")[3:]) if arg[0] == 'delete' and len(arg) > 1: account = get_account_string(arg[1]) elif arg[0] != 'delete': account = get_account_string(arg[0]) else: account = None if arg[0] == 'delete': if account is not None and account in prefixes: prefixes.pop(account) if gSettingsEnabled: bs.set_setting("prefixes", prefixes) else: self.set_prefix(account=account, prefix=prefix, type=type) else: for i in ["prefix [номер игрока | имя аккаунта] [slime|ice|spark|rock|metal] [префикс]", \ "prefix 0 spark клоун сбежал"]: send_message(i) elif command in ['kick'] and self.is_vip: if len(arg) > 0: account = get_account_string(arg[0]) if account is not None and len(roster) > 0: id = None for i in roster: if i['displayString'].decode('utf-8') == account: id = i['clientID'] break if id is not None: bsInternal._disconnectClient(id, 300) else: for i in [command+" [номер игрока|имя аккаунта]", \ command+" 0", command+u" \ue030PC123456"]: send_message(i) elif command in ['ban'] and self.is_admin: if len(arg) > 0: self.ban(account=get_account_string(arg[0])) else: for i in [command+" [номер игрока|имя аккаунта]", \ command+" 0", command+u" \ue030PC123456"]: send_message(i) elif command in ['end'] and self.is_vip: if hasattr(a, "endGame"): a.endGame() else: send_message("Сейчас это недоступно") elif command in ['party','pt'] and self.is_admin: if hasattr(a, 'cameraFlash') and gEvent: time = 1000 def run(time=1000): color = tuple([random.randrange(1,2) for i in range(3)]) a.cameraFlash(duration=time, color=color) if hasattr(a, "_partyFlash") and a._partyFlash is not None: a._partyFlash = None a._cameraFlash = [] else: run(time=time) a._partyFlash = bs.Timer(time, bs.Call(run, time), True) else: send_message("Сейчас это недоступно") elif command in ['sm'] and self.is_vip: bs.getSharedObject("globals").slowMotion = motion = bs.getSharedObject("globals").slowMotion == False set_motion(motion=motion) elif command in ['pause'] and self.is_admin: bs.getSharedObject("globals").paused = bs.getSharedObject("globals").paused == False elif command in ['max_players', 'mp'] and self.is_admin: if bigger_than_zero(arg[0]): bsInternal._setPublicPartyMaxSize(int(arg[0])) else: for i in ["mp [кол-во игроков]", "mp 8", "максимальное кол-во игроков сейчас: "+str(bsInternal._getPublicPartyMaxSize())]: send_message(i) elif command in ['shatter', 'sh'] and self.is_vip: if len(arg) > 0: def shatter(player=None, shatterMultiple=1): if player is not None and player.exists() and player.isAlive(): player.actor.node.shattered = shatterMultiple player.actor.shattered = True if shatterMultiple > 0 else False if bigger_than_zero(arg[0]): if len(arg) > 1: if is_num(arg[1]) and int(arg[1]) < len(a.players): shatter(a.players[int(arg[1])], int(arg[0])) elif arg[1] == "all": for i in a.players: shatter(i, int(arg[0])) elif self.player is not None: shatter(self.player, int(arg[0])) else: for i in [command+" [число] [номер игрока | all]", command+" 2 0", command+" 10"]: send_message(i) elif command in ['frozen', 'fr'] and self.is_vip: if len(arg) > 0: def frozen(player=None): if player is not None and player.exists() and player.isAlive(): player.actor.node.frozen = player.actor.node.frozen == 0 player.actor.frozen = player.actor.frozen == False if is_num(arg[0]) and int(arg[0]) < len(a.players): frozen(a.players[int(arg[0])]) elif arg[0] == "all": for i in a.players: frozen(i) elif self.player is not None: frozen(self.player) else: for i in [command+" [номер игрока | all]", command+" 2", \ command+" me", "введи команду повторно, чтобы её отменить"]: send_message(i) elif command in ['sleep','sl'] and self.is_admin: if len(arg) > 0: def sleep(player=None, sleepTime=5000): def work(player=None, sleepTime=5000): if player is not None and player.exists() and player.isAlive(): player.actor.node.handleMessage('knockout', sleepTime) if not hasattr(player.actor, 'sleepTime') or (hasattr(player.actor, 'sleepTime') and player.actor.sleepTime is None): player.actor.sleepTime = sleepTime else: player.actor.sleepTime -= 500 if player.actor.sleepTime <= 0: player.actor._sleep = player.actor.sleepTime = None if player is not None and player.exists() and player.isAlive(): if sleepTime > 500: if hasattr(player.actor, '_sleep') and player.actor._sleep is not None: player.actor._sleep = None else: player.actor._sleep = bs.Timer(500, bs.Call(work, player, sleepTime), repeat=True) work(player=player, sleepTime=sleepTime) else: work(player=player, sleepTime=sleepTime) if bigger_than_zero(arg[0]): if len(arg) > 1: if is_num(arg[1]) and int(arg[1]) < len(a.players): sleep(a.players[int(arg[1])], int(arg[0])) elif arg[1] == "all": for i in a.players: sleep(i, int(arg[0])) elif self.player is not None: sleep(self.player, int(arg[0])) else: for i in [command+" [число] [номер игрока | all]", command+" 2000 0", \ command+" 5000", "введи команду повторно, чтобы её отменить"]: send_message(i) elif command in ['curse','cr'] and self.is_admin: if len(arg) > 0: def curse(player=None): if player is not None and player.exists() and player.isAlive(): if hasattr(player.actor, 'curse'): player.actor.curse() if is_num(arg[0]) and int(arg[0]) < len(a.players): curse(a.players[int(arg[0])]) elif arg[0] == "all": for i in a.players: curse(i) elif self.player is not None: curse(self.player) else: for i in [command+" [номер игрока | all]", command+" 2", command+" me"]: send_message(i) elif command in ['nodes'] and self.is_admin: if len(arg) > 0: if arg[0] == 'types': nodes = list(set([i.getNodeType() for i in bsInternal.getNodes() if hasattr(i, "getNodeType")])) if arg[0] == 'names': nodes = [i.getName() for i in bsInternal.getNodes() if hasattr(i, 'getName')] if len(arg) > 1: nodes = [i for i in nodes if arg[1].lower() in i.lower()] for i in bs.text_split(words=nodes, stroke_on_end=False).split('\n'): send_message(i) else: for i in [command+' types spaz', command+' types', command+' names']: send_message(i) elif command in ['connect'] and self.is_admin: def connect(node=None, connected_node=None, type='position'): if node is not None and node.exists(): if connected_node is not None and connected_node.exists(): try: node.connectAttr(type, connected_node, type) except: pass if len(arg) > 0: node = [i for i in bsInternal.getNodes() if hasattr(i, 'getName') and i.getName().lower() == arg[0].lower()] if len(node) > 0: node = node[0] if len(arg) < 3: arg[2] = 'position' if is_num(arg[1]) and int(arg[1]) < len(a.players): player = a.players[int(arg[1])] if player.exists(): connect(player.actor.node, node, arg[2]) elif arg[1] == "all": for i in a.players: if i.exists(): connect(i.actor.node, node, arg[2]) elif self.player is not None and self.player.exists(): connect(self.player.actor.node, node, arg[2]) else: for i in [command+' [имя объекта (/nodes names)] [номер игрока | all] [тип присоединения]', \ command+' [email protected]:259 all position']: send_message(i) elif command in ['head'] and self.is_admin: if len(arg) > 0: def head(player=None): if player is not None and player.exists() and player.isAlive(): player.actor.node.holdNode = player.actor.node if is_num(arg[0]) and int(arg[0]) < len(a.players): head(a.players[int(arg[0])]) elif arg[0] == "all": for i in a.players: head(i) elif self.player is not None: head(self.player) else: for i in [command+" [номер игрока | all]", command+" 2", command+" me"]: send_message(i) elif command in ['rise', 'rs'] and self.is_vip: if len(arg) > 0: def respawn(player=None): if player is not None and player.exists() and not player.isAlive(): player.gameData['respawnTimer'] = player.gameData['respawnIcon'] = None with bs.Context(a): a.spawnPlayer(player=player) if is_num(arg[0]) and int(arg[0]) < len(a.players): respawn(a.players[int(arg[0])]) elif arg[0] == "all": for i in a.players: respawn(i) elif self.player is not None: respawn(self.player) else: for i in [command+" [номер игрока | all]", command+" 2", command+" me"]: send_message(i) elif command in ['flex','fl'] and self.is_vip: if not gEvent: send_message("Сейчас это недоступно") return if len(arg) > 0: def flex(actor=None): def work(node=None): if node is not None and node.exists(): node.handleMessage('celebrate', 1000) if actor is not None and actor.exists(): if not hasattr(actor, '_flex') or (hasattr(actor, '_flex') and actor._flex is None): actor._flex = bs.Timer(1000, bs.Call(work, actor.node), repeat=True) work(node=actor.node) else: actor._flex = None if is_num(arg[0]) and int(arg[0]) < len(a.players): flex(a.players[int(arg[0])].actor) elif arg[0] == 'all': for i in find_players_and_bots(): flex(i) elif self.player is not None and self.player.exists(): flex(self.player.actor) else: for i in [command+" [номер игрока|all]", command+" 0", command+" me", "введи команду повторно, чтобы её отменить"]: send_message(i) elif command in ['dn', 'dance'] and self.is_admin: if not gEvent: send_message("Сейчас это недоступно") return if len(arg) > 0: def dance(actor=None): def work(node=None): if node is not None and node.exists(): pos = (node.position[0], node.position[1] + 0.5, node.position[2]) node.handleMessage("impulse", pos[0], pos[1], pos[2], 0, -2, 0, 2000, 0, 1, 0, 0, -2, 0) if actor is not None and actor.exists(): if not hasattr(actor, '_dance') or (hasattr(actor, '_dance') and actor._dance is None): actor._dance = bs.Timer(100, bs.Call(work, actor.node), repeat=True) work(node=actor.node) else: actor._dance = None if is_num(arg[0]) and int(arg[0]) < len(a.players): dance(a.players[int(arg[0])].actor) elif arg[0] == 'all': for i in find_players_and_bots(): dance(i) elif self.player is not None and self.player.exists(): dance(self.player.actor) else: for i in [command+" [номер игрока|all]", command+" 0", command+" me", "введи команду повторно, чтобы её отменить"]: send_message(i) elif command in ['dn2', 'dance2'] and self.is_admin: if not gEvent: send_message("Сейчас это недоступно") return if len(arg) > 0: def dance2(actor=None): def work(node=None): if node is not None and node.exists(): node.jumpPressed = True node.jumpPressed = False if actor is not None and actor.exists(): if not hasattr(actor, '_dance2') or (hasattr(actor, '_dance2') and actor._dance2 is None): actor._dance2 = bs.Timer(500, bs.Call(work, actor.node), repeat=True) work(node=actor.node) else: actor._dance2 = None if is_num(arg[0]) and int(arg[0]) < len(a.players): dance2(a.players[int(arg[0])].actor) elif arg[0] == 'all': for i in find_players_and_bots(): dance2(i) elif self.player is not None and self.player.exists(): dance2(self.player.actor) else: for i in [command+" [номер игрока|all]", command+" 0", command+" me", "введи команду повторно, чтобы её отменить"]: send_message(i)
def onBegin(self): bs.CoopGameActivity.onBegin(self) playerCount = len(self.players) self._dingSound = bs.getSound('dingSmall') self._dingSoundHigh = bs.getSound('dingSmallHigh') hard = False if self._preset in [ 'trainingEasy', 'rookieEasy', 'proEasy', 'uberEasy'] else True if self._preset in ['training', 'trainingEasy']: import bsUtils bsUtils.ControlsHelpOverlay( delay=3000, lifespan=10000, bright=True).autoRetain() self._haveTnt = False self._excludePowerups = ['curse', 'landMines'] self._waves = [ {'baseAngle': 195, 'entries': ([ {'type': bs.BomberBotLame, 'spacing': 5}, ] * playerCount)}, {'baseAngle': 130, 'entries': ([ {'type': bs.ToughGuyBotLame, 'spacing': 5}, ] * playerCount)}, {'baseAngle': 195, 'entries': ([ {'type': bs.BomberBotLame, 'spacing': 10}, ] * (playerCount+1))}, {'baseAngle': 130, 'entries': ([ {'type': bs.ToughGuyBotLame, 'spacing': 10}, ] * (playerCount+1))}, {'baseAngle': 130, 'entries': ([ {'type': bs.ToughGuyBotLame, 'spacing': 5} if playerCount > 1 else None, {'type': bs.ToughGuyBotLame, 'spacing': 5}, {'type': None, 'spacing': 30}, {'type': bs.BomberBotLame, 'spacing': 5} if playerCount > 3 else None, {'type': bs.BomberBotLame, 'spacing': 5}, {'type': None, 'spacing': 30}, {'type': bs.ToughGuyBotLame, 'spacing': 5}, {'type': bs.ToughGuyBotLame, 'spacing': 5} if playerCount > 2 else None, ])}, {'baseAngle': 195, 'entries': ([ {'type': bs.SkeletonBot, 'spacing': 90}, {'type': bs.SkeletonBot, 'spacing': 90} if playerCount > 1 else None ])}, ] elif self._preset in ['rookie', 'rookieEasy']: self._haveTnt = False self._excludePowerups = ['curse'] self._waves = [ {'entries': [ {'type': bs.NinjaBot, 'point': 'LeftUpperMore'} if playerCount > 2 else None, {'type': bs.NinjaBot, 'point': 'LeftUpper'}, ]}, {'entries': [ {'type': bs.BomberBotStaticLame, 'point': 'TurretTopRight'}, {'type': bs.ToughGuyBotLame, 'point': 'RightUpper'}, {'type': bs.ToughGuyBotLame, 'point': 'RightLower'} \ if playerCount > 1 else None, {'type': bs.BomberBotStaticLame, 'point': 'TurretBottomRight'} if playerCount > 2 else None, ]}, {'entries': [ {'type': bs.BomberBotStaticLame, 'point': 'TurretBottomLeft'}, {'type': bs.CallingBot, 'point': 'Left'}, ]}, {'entries': [ {'type': bs.ToughGuyBotLame, 'point': 'TopRight'}, {'type': bs.ToughGuyBot, 'point': 'TopHalfRight'} if playerCount > 1 else None, {'type': bs.ToughGuyBotLame, 'point': 'TopLeft'}, {'type': bs.ToughGuyBotLame, 'point': 'TopHalfLeft'} if playerCount > 2 else None, {'type': bs.ToughGuyBot, 'point': 'Top'}, {'type': bs.BomberBotStaticLame, 'point': 'TurretTopMiddle'}, ]}, {'entries': [ {'type': bs.ChickBotStatic, 'point': 'TurretBottomLeft'}, {'type': bs.ChickBotStatic, 'point': 'TurretBottomRight'}, {'type': bs.ChickBot, 'point': 'Bottom'}, {'type': bs.ChickBot, 'point': 'BottomHalfRight'} if playerCount > 1 else None, {'type': bs.ChickBot, 'point': 'BottomHalfLeft'} if playerCount > 2 else None, ]}, {'entries': [ {'type': bs.BomberBotStaticLame, 'point': 'TurretTopLeft'}, {'type': bs.BomberBotStaticLame, 'point': 'TurretTopRight'}, {'type': bs.NinjaBot, 'point': 'Bottom'}, {'type': bs.NinjaBot, 'point': 'BottomHalfLeft'} if playerCount > 1 else None, {'type': bs.NinjaBot, 'point': 'BottomHalfRight'} if playerCount > 2 else None, ]}, ] elif self._preset in ['pro', 'proEasy']: self._excludePowerups = ['curse'] self._haveTnt = True self._waves = [ {'baseAngle': -50, 'entries': ([ {'type': bs.ToughGuyBot, 'spacing': 12} if playerCount > 3 else None, {'type': bs.ToughGuyBot, 'spacing': 12}, {'type': bs.BomberTNTBot, 'spacing': 1}, {'type': bs.BomberTNTBot, 'spacing': 6}, {'type': bs.BomberBot, 'spacing': 6} if self._preset == 'pro' else None, {'type': bs.BomberBot, 'spacing': 6} if playerCount > 1 else None, {'type': bs.ToughGuyBot, 'spacing': 12}, {'type': bs.ToughGuyBot, 'spacing': 12} if playerCount > 2 else None, ])}, {'baseAngle': 180, 'entries': ([ {'type': bs.ToughGuyBot, 'spacing': 6} if playerCount > 3 else None, {'type': bs.ToughGuyBot, 'spacing': 6} if self._preset == 'pro' else None, {'type': bs.ToughGuyBot, 'spacing': 6}, {'type': bs.SkeletonBot, 'spacing': 45}, {'type': bs.NinjaBot, 'spacing': 45} if playerCount > 1 else None, {'type': bs.SkeletonBot, 'spacing': 6}, {'type': bs.ToughGuyBot, 'spacing': 6} if self._preset == 'pro' else None, {'type': bs.ToughGuyBot, 'spacing': 6} if playerCount > 2 else None, ])}, {'baseAngle': 0, 'entries': ([ {'type': bs.NinjaBot, 'spacing': 30}, {'type': bs.BomberTNTBot, 'spacing': 30}, {'type': bs.BomberTNTBot, 'spacing': 30}, {'type': bs.ChickBot, 'spacing': 30}, {'type': bs.BomberTNTBot, 'spacing': 30} if self._preset == 'pro' else None, {'type': bs.ChickBot, 'spacing': 30} if playerCount > 1 else None, {'type': bs.ChickBot, 'spacing': 30} if playerCount > 3 else None, {'type': bs.NinjaBot, 'spacing': 30}, ])}, {'baseAngle': 90, 'entries': ([ {'type': bs.MelBot, 'spacing': 50}, {'type': bs.MelBot, 'spacing': 50} if self._preset == 'pro' else None, {'type': bs.MelBot, 'spacing': 50}, {'type': bs.MelBot, 'spacing': 50} if playerCount > 1 else None, {'type': bs.MelBot, 'spacing': 50} if playerCount > 3 else None, ])}, {'baseAngle': 0, 'entries': ([ {'type': bs.ChickBot, 'spacing': 72}, {'type': bs.ChickBot, 'spacing': 72}, {'type': bs.ChickBot, 'spacing': 72} if self._preset == 'pro' else None, {'type': bs.ChickBot, 'spacing': 72}, {'type': bs.ChickBot, 'spacing': 72}, {'type': bs.ChickBot, 'spacing': 36} if playerCount > 2 else None, ])}, {'baseAngle': 30, 'entries': ([ {'type': bs.NinjaBotProShielded, 'spacing': 50}, {'type': bs.NinjaBotProShielded, 'spacing': 50}, {'type': bs.NinjaBotProShielded, 'spacing': 50} if self._preset == 'pro' else None, {'type': bs.NinjaBotProShielded, 'spacing': 50} if playerCount > 1 else None, {'type': bs.NinjaBotProShielded, 'spacing': 50} if playerCount > 2 else None, ])}, ] elif self._preset in ['uber', 'uberEasy']: # show controls help in kiosk mode if bs.getEnvironment()['kioskMode']: import bsUtils bsUtils.ControlsHelpOverlay( delay=3000, lifespan=10000, bright=True).autoRetain() self._haveTnt = True self._excludePowerups = [] self._waves = [ {'entries': [ {'type': bs.BomberBotProStatic, 'point': 'TurretTopMiddleLeft'} if hard else None, {'type': bs.BomberBotProStatic, 'point': 'TurretTopMiddleRight'}, {'type': bs.BomberBotProStatic, 'point': 'TurretTopLeft'} if playerCount > 2 else None, {'type': bot.SantaBot, 'point': 'TopRight'}, {'type': 'delay', 'duration': 4000}, {'type': bot.SantaBot, 'point': 'TopLeft'}, ]}, {'entries': [ {'type': bs.SkeletonBot, 'point': 'Left'}, {'type': bs.SkeletonBot, 'point': 'Right'}, {'type': bs.NinjaBot, 'point': 'Right'}, {'type': bs.NinjaBot, 'point': 'RightUpperMore'} if playerCount > 2 else None, {'type': bs.BomberBotProStatic, 'point': 'TurretTopLeft'}, {'type': bs.BomberBotProStatic, 'point': 'TurretTopRight'}, ]}, {'entries': [ {'type': bs.ChickBotPro, 'point': 'TopRight'}, {'type': bs.ChickBotPro, 'point': 'RightUpperMore'} if playerCount > 1 else None, {'type': bs.ChickBotPro, 'point': 'RightUpper'}, {'type': bs.ChickBotPro, 'point': 'RightLower'} if hard else None, {'type': bs.ChickBotPro, 'point': 'RightLowerMore'} if playerCount > 2 else None, {'type': bs.ChickBotPro, 'point': 'BottomRight'}, ]}, {'entries': [ {'type': bs.NinjaBotProShielded, 'point': 'BottomRight'}, {'type': bs.NinjaBotProShielded, 'point': 'Bottom'} if playerCount > 2 else None, {'type': bs.NinjaBotProShielded, 'point': 'BottomLeft'}, {'type': bs.NinjaBotProShielded, 'point': 'Top'} if hard else None, {'type': bs.BomberBotProStatic, 'point': 'TurretTopMiddle'}, ]}, {'entries': [ {'type': bs.PirateBot, 'point': 'LeftUpper'}, {'type': 'delay', 'duration': 1000}, {'type': bs.ToughGuyBotProShielded, 'point': 'LeftLower'}, {'type': bs.ToughGuyBotProShielded, 'point': 'LeftLowerMore'}, {'type': 'delay', 'duration': 4000}, {'type': bs.PirateBot, 'point': 'RightUpper'}, {'type': 'delay', 'duration': 1000}, {'type': bs.ToughGuyBotProShielded, 'point': 'RightLower'}, {'type': bs.ToughGuyBotProShielded, 'point': 'RightUpperMore'}, {'type': 'delay', 'duration': 4000}, {'type': bs.PirateBot, 'point': 'Left'}, {'type': 'delay', 'duration': 5000}, {'type': bs.PirateBot, 'point': 'Right'}, ]}, {'entries': [ {'type': bs.BomberBotProStatic, 'point': 'TurretTopLeft'}, {'type': bs.BomberBotProStatic, 'point': 'TurretTopRight'}, {'type': bs.BomberBotProStatic, 'point': 'TurretBottomLeft'}, {'type': bs.BomberBotProStatic, 'point': 'TurretBottomRight'}, {'type': bs.BomberBotProStatic, 'point': 'TurretTopMiddleLeft'} if hard else None, {'type': bs.BomberBotProStatic, 'point': 'TurretTopMiddleRight'} if hard else None, ]}, ] # we generate these on the fly in endless.. elif self._preset in ['endless', 'endlessTournament']: self._haveTnt = True self._excludePowerups = [] else: raise Exception("Invalid preset: "+str(self._preset)) # FIXME - should migrate to use setupStandardPowerupDrops() # spit out a few powerups and start dropping more shortly self._dropPowerups( standardPoints=True, powerupType='curse' if self._preset in ['uber', 'uberEasy'] else( 'landMines' if self._preset in ['rookie', 'rookieEasy'] else None)) bs.gameTimer(4000, self._startPowerupDrops) # our TNT spawner (if applicable) if self._haveTnt: self._tntSpawner = bs.TNTSpawner(position=self._tntSpawnPosition) self.setupLowLifeWarningSound() self._updateScores() self._bots = bs.BotSet() bs.gameTimer(4000, self._startUpdatingWaves)
def onBegin(self): bs.TeamGameActivity.onBegin(self) self.setupStandardTimeLimit(self.settings['Time Limit']) self.setupStandardPowerupDrops() self.zombieQ = 1 # queue of zombies to spawn. this will increment/decrement if self._soloMode: self._vsText = bs.NodeActor( bs.newNode("text", attrs={ 'position': (0, 105), 'hAttach': "center", 'hAlign': 'center', 'maxWidth': 200, 'shadow': 0.5, 'vrDepth': 390, 'scale': 0.6, 'vAttach': "bottom", 'color': (0.8, 0.8, 0.3, 1.0), 'text': bs.Lstr(resource='vsText') })) # if balance-team-lives is on, add lives to the smaller team until total lives match if (isinstance(self.getSession(), bs.TeamsSession) and self.settings['Balance Total Lives'] and len(self.teams[0].players) > 0 and len(self.teams[1].players) > 0): if self._getTotalTeamLives( self.teams[0]) < self._getTotalTeamLives(self.teams[1]): lesserTeam = self.teams[0] greaterTeam = self.teams[1] else: lesserTeam = self.teams[1] greaterTeam = self.teams[0] addIndex = 0 while self._getTotalTeamLives( lesserTeam) < self._getTotalTeamLives(greaterTeam): lesserTeam.players[addIndex].gameData['lives'] += 1 addIndex = (addIndex + 1) % len(lesserTeam.players) #Let's add a couple of bots # this wrangles our bots self._bots = bs.BotSet() #Load up appearances. We want to make Walkers look crazy! #Since no bots exist yet, we have to load up the factory manually. activity = bs.getActivity() try: myFactory = activity._sharedSpazFactory except Exception: myFactory = activity._sharedSpazFactory = bsSpaz.SpazFactory() #Load up resources for our composite model appears = [ 'Kronk', 'Zoe', 'Pixel', 'Agent Johnson', 'Bones', 'Frosty', 'Kronk2' ] myAppear = copy.copy(bsSpaz.appearances['Kronk']) myAppear.name = 'Kronk2' bsSpaz.appearances['Kronk2'] = myAppear for appear in appears: myFactory._getMedia(appear) #Now all the media is loaded up for the spazzes we are pulling from. #Now edit Kronk2 and set ToughGuyBot character to Kronk2 # Because these are zombies, let's make 'em green. Change the ToughGuyBot colors to green. Reset during end game. med = myFactory.spazMedia head = random.choice(med.keys()) med['Kronk2']['headModel'] = med['Zoe']['headModel'] med['Kronk2']['colorTexture'] = med['Agent Johnson']['colorTexture'] med['Kronk2']['colorMaskTexture'] = med['Pixel']['colorMaskTexture'] med['Kronk2']['torsoModel'] = med['Bones']['torsoModel'] med['Kronk2']['pelvisModel'] = med['Pixel']['pelvisModel'] med['Kronk2']['upperArmModel'] = med['Frosty']['upperArmModel'] med['Kronk2']['foreArmModel'] = med['Frosty']['foreArmModel'] med['Kronk2']['handModel'] = med['Bones']['handModel'] med['Kronk2']['upperLegModel'] = med['Bones']['upperLegModel'] med['Kronk2']['lowerLegModel'] = med['Pixel']['lowerLegModel'] med['Kronk2']['toesModel'] = med['Bones']['toesModel'] setattr(bs.ToughGuyBot, 'color', (0.4, 0.1, 0.05)) setattr(bs.ToughGuyBot, 'highlight', (0.2, 0.4, 0.3)) setattr(bs.ToughGuyBot, 'character', 'Kronk2') # start some timers to spawn bots thePt = self.getMap().getFFAStartPosition(self.players) #bs.gameTimer(1000,bs.Call(self._bots.spawnBot,bs.ToughGuyBot,pos=thePt,spawnTime=3000)) self._updateIcons() self._updateScoreBoard # we could check game-over conditions at explicit trigger points, # but lets just do the simple thing and poll it... bs.gameTimer(1000, self._update, repeat=True)
def onBegin(self): bs.CoopGameActivity.onBegin(self) self.getMap().bg.color = (1,0,0) self.num = 1 self.stop = False self.killed = 0 self._bots = bs.BotSet() self._score2 = 0 self.score = 0 self.pos1 = (3*1.4,3*1.4,-3*1.4) self.pos2 = (5*1.4,3*1.4,-5*1.4) self.pos3 = (5*1.4,3*1.4,-1*1.4) self.pos4 = (-5*1.4,3*1.4,-3*1.4) self.pos5 = (0*1.4,3*1.4,-7*1.4) self.pos6 = (0*1.4,3*1.4,0*1.4) self.pos7 = (-7*1.4,3*1.4,-3*1.4) self.pos8 = (3*1.4,3*1.4,-3*1.4) self.pos9 = (3*1.4,3*1.4,-3*1.4) self.pos10 = (3*1.4,3*1.4,-3*1.4) globals = bs.getSharedObject('globals') globals.tint = (1.1,1,1) globals.vignetteOuter = (0.6,0.6,0.6) globals.vignetteInner = (0.8,0.8,0.8) bs.gameTimer(2000,bs.Call(self.dropPowerup)) self.waves = { 1:[bs.NinjaBot, bs.MelBot, bs.NinjaBot], 2:[bs.BunnyBot, bs.MelBot, bs.ChickBot], 3:[bs.ChickBotPro, bs.SpazBot, bs.BunnyBot], 4:[bs.SpazBot, bs.BunnyBot, bs.BunnyBot, bs.SpazBot], 5:[bs.ChickBot, bs.PirateBot, bs.BunnyBot, bs.BunnyBot], 6:[bs.ChickBot, bs.SkeletonBot, bs.BunnyBot], 7:[bs.SpazBot, bs.SpazBot, bs.ChickBot, bs.SpazBot], 8:[bs.NinjaBotPro, bs.SpazBot, bs.SpazBot, bs.CrayfishBot], 9:[bs.NinjaBotPro, bs.NinjaBotPro, bs.CrayfishBot], 10:[bs.BomzhBotPro, bs.BomzhBotPro, bs.BomzhBotPro, bs.BomzhBotPro, bs.BomzhBotPro, bs.BomzhBotPro, bs.BomzhBotPro, bs.BomzhBotPro, bs.BomzhBotPro, bs.BomzhBotPro], 11:[bs.EricBot, bs.BomzhBotPro, bs.BomzhBotPro, bs.BomzhBotPro, bs.SpazBot]}
def onBegin(self): bs.CoopGameActivity.onBegin(self) self._dingSound = bs.getSound('dingSmall') self._dingSoundHigh = bs.getSound('dingSmallHigh') playerCount = len(self.players) hard = False if self._preset in ['proEasy', 'uberEasy'] else True if self._preset in ['pro', 'proEasy', 'tournament']: self._excludePowerups = ['curse'] self._haveTnt = True self._waves = [ {'entries': [ {'type': bs.BomberBot, 'path': 3 if hard else 2}, {'type': bs.BomberBot, 'path': 2}, {'type': bs.BomberBot, 'path': 2} if hard else None, {'type': bs.BomberBot, 'path': 2} if playerCount > 1 \ else None, {'type': bs.BomberBot, 'path': 1} if hard else None, {'type': bs.BomberBot, 'path': 1} if playerCount > 2 \ else None, {'type': bs.BomberBot, 'path': 1} if playerCount > 3 \ else None, ]}, {'entries': [ {'type': bs.BomberBot, 'path': 1} if hard else None, {'type': bs.BomberBot, 'path': 2} if hard else None, {'type': bs.BomberBot, 'path': 2}, {'type': bs.BomberBot, 'path': 2}, {'type': bs.BomberBot, 'path': 2} if playerCount > 3 \ else None, {'type': bs.ToughGuyBot, 'path': 3}, {'type': bs.ToughGuyBot, 'path': 3}, {'type': bs.ToughGuyBot, 'path': 3} if hard else None, {'type': bs.ToughGuyBot, 'path': 3} if playerCount > 1 \ else None, {'type': bs.ToughGuyBot, 'path': 3} if playerCount > 2 \ else None, ]}, {'entries': [ {'type': bs.NinjaBot, 'path': 2} if hard else None, {'type': bs.NinjaBot, 'path': 2} if playerCount > 2 \ else None, {'type': bs.ChickBot, 'path': 2}, {'type': bs.ChickBot, 'path': 2} if playerCount > 1 \ else None, {'type': 'spacing', 'duration': 3000}, {'type': bs.BomberBot, 'path': 2} if hard else None, {'type': bs.BomberBot, 'path': 2} if hard else None, {'type': bs.BomberBot, 'path': 2}, {'type': bs.BomberBot, 'path': 3} if hard else None, {'type': bs.BomberBot, 'path': 3}, {'type': bs.BomberBot, 'path': 3}, {'type': bs.BomberBot, 'path': 3} if playerCount > 3 \ else None, ]}, {'entries': [ {'type': bs.ChickBot, 'path': 1} if hard else None, {'type': 'spacing', 'duration': 1000} if hard else None, {'type': bs.ChickBot, 'path': 2}, {'type': 'spacing', 'duration': 1000}, {'type': bs.ChickBot, 'path': 3}, {'type': 'spacing', 'duration': 1000}, {'type': bs.ChickBot, 'path': 1} if hard else None, {'type': 'spacing', 'duration': 1000} if hard else None, {'type': bs.ChickBot, 'path': 2}, {'type': 'spacing', 'duration': 1000}, {'type': bs.ChickBot, 'path': 3}, {'type': 'spacing', 'duration': 1000}, {'type': bs.ChickBot, 'path': 1} if (playerCount > 1 \ and hard) else None, {'type': 'spacing', 'duration': 1000}, {'type': bs.ChickBot, 'path': 2} if playerCount > 2 \ else None, {'type': 'spacing', 'duration': 1000}, {'type': bs.ChickBot, 'path': 3} if playerCount > 3 \ else None, {'type': 'spacing', 'duration': 1000}, ]}, {'entries': [ {'type': bs.NinjaBotProShielded if hard else bs.NinjaBot, 'path': 1}, {'type': bs.ToughGuyBot, 'path': 2} if hard else None, {'type': bs.ToughGuyBot, 'path': 2}, {'type': bs.ToughGuyBot, 'path': 2}, {'type': bs.ToughGuyBot, 'path': 3} if hard else None, {'type': bs.ToughGuyBot, 'path': 3}, {'type': bs.ToughGuyBot, 'path': 3}, {'type': bs.ToughGuyBot, 'path': 3} if playerCount > 1 \ else None, {'type': bs.ToughGuyBot, 'path': 3} if playerCount > 2 \ else None, {'type': bs.ToughGuyBot, 'path': 3} if playerCount > 3 \ else None, ]}, {'entries': [ {'type': bs.BomberBotProShielded, 'path': 3}, {'type': 'spacing', 'duration': 1500}, {'type': bs.BomberBotProShielded, 'path': 2}, {'type': 'spacing', 'duration': 1500}, {'type': bs.BomberBotProShielded, 'path': 1} if hard \ else None, {'type': 'spacing', 'duration': 1000} if hard else None, {'type': bs.BomberBotProShielded, 'path': 3}, {'type': 'spacing', 'duration': 1500}, {'type': bs.BomberBotProShielded, 'path': 2}, {'type': 'spacing', 'duration': 1500}, {'type': bs.BomberBotProShielded, 'path': 1} if hard \ else None, {'type': 'spacing', 'duration': 1500} if hard else None, {'type': bs.BomberBotProShielded, 'path': 3} \ if playerCount > 1 else None, {'type': 'spacing', 'duration': 1500}, {'type': bs.BomberBotProShielded, 'path': 2} \ if playerCount > 2 else None, {'type': 'spacing', 'duration': 1500}, {'type': bs.BomberBotProShielded, 'path': 1} \ if playerCount > 3 else None, ]}, ] elif self._preset in ['uberEasy', 'uber', 'tournamentUber']: self._excludePowerups = [] self._haveTnt = True self._waves = [ {'entries': [ {'type': bs.ChickBot, 'path': 1} if hard else None, {'type': bs.ChickBot, 'path': 2}, {'type': bs.ChickBot, 'path': 2}, {'type': bs.ChickBot, 'path': 3}, {'type': bs.ToughGuyBotPro if hard else bs.ToughGuyBot, 'point': 'BottomLeft'}, {'type': bs.ToughGuyBotPro, 'point': 'BottomRight'} \ if playerCount > 2 else None, ]}, {'entries': [ {'type': bs.NinjaBot, 'path': 2}, {'type': bs.NinjaBot, 'path': 3}, {'type': bs.NinjaBot, 'path': 1} if hard else None, {'type': bs.NinjaBot, 'path': 2}, {'type': bs.NinjaBot, 'path': 3}, {'type': bs.NinjaBot, 'path': 1} if playerCount > 2 \ else None, ]}, {'entries': [ {'type': bs.BomberBotProShielded, 'path': 1} if hard \ else None, {'type': bs.BomberBotProShielded, 'path': 2}, {'type': bs.BomberBotProShielded, 'path': 2}, {'type': bs.BomberBotProShielded, 'path': 3}, {'type': bs.BomberBotProShielded, 'path': 3}, {'type': bs.NinjaBot, 'point': 'BottomRight'}, {'type': bs.NinjaBot, 'point': 'BottomLeft'} \ if playerCount > 2 else None, ]}, {'entries': [ {'type': bs.ChickBotPro, 'path': 1} if hard else None, {'type': bs.ChickBotPro, 'path': 1 if hard else 2}, {'type': bs.ChickBotPro, 'path': 1 if hard else 2}, {'type': bs.ChickBotPro, 'path': 1 if hard else 2}, {'type': bs.ChickBotPro, 'path': 1 if hard else 2}, {'type': bs.ChickBotPro, 'path': 1 if hard else 2}, {'type': bs.ChickBotPro, 'path': 1 if hard else 2} \ if playerCount > 1 else None, {'type': bs.ChickBotPro, 'path': 1 if hard else 2} \ if playerCount > 3 else None, ]}, {'entries': [ {'type': bs.ChickBotProShielded if hard else bs.ChickBotPro, 'point': 'BottomLeft'}, {'type': bs.ChickBotProShielded, 'point': 'BottomRight'} \ if hard else None, {'type': bs.ChickBotProShielded, 'point': 'BottomRight'} \ if playerCount > 2 else None, {'type': bs.BomberBot, 'path': 3}, {'type': bs.BomberBot, 'path': 3}, {'type': 'spacing', 'duration': 5000}, {'type': bs.ToughGuyBot, 'path': 2}, {'type': bs.ToughGuyBot, 'path': 2}, {'type': 'spacing', 'duration': 5000}, {'type': bs.ChickBot, 'path': 1} if hard else None, {'type': bs.ChickBot, 'path': 1} if hard else None, ]}, {'entries': [ {'type': bs.BomberBotProShielded, 'path': 2}, {'type': bs.BomberBotProShielded, 'path': 2} if hard \ else None, {'type': bs.MelBot, 'point': 'BottomRight'}, {'type': bs.BomberBotProShielded, 'path': 2}, {'type': bs.BomberBotProShielded, 'path': 2}, {'type': bs.MelBot, 'point': 'BottomRight'} \ if playerCount > 2 else None, {'type': bs.BomberBotProShielded, 'path': 2}, {'type': bs.PirateBot, 'point': 'BottomLeft'}, {'type': bs.BomberBotProShielded, 'path': 2}, {'type': bs.BomberBotProShielded, 'path': 2} \ if playerCount > 1 else None, {'type': 'spacing', 'duration': 5000}, {'type': bs.MelBot, 'point': 'BottomLeft'}, {'type': 'spacing', 'duration': 2000}, {'type': bs.PirateBot, 'point': 'BottomRight'}, ]}, ] elif self._preset in ['endless', 'endlessTournament']: self._excludePowerups = [] self._haveTnt = True # spit out a few powerups and start dropping more shortly self._dropPowerups(standardPoints=True) bs.gameTimer(4000, self._startPowerupDrops) self.setupLowLifeWarningSound() self._updateScores() self._bots = bs.BotSet() # our TNT spawner (if applicable) if self._haveTnt: self._tntSpawner = bs.TNTSpawner(position=self._tntSpawnPosition) # make sure to stay out of the way of menu/party buttons in the corner interfaceType = bs.getEnvironment()['interfaceType'] lOffs = (-80 if interfaceType == 'small' else -40 if interfaceType == 'medium' else 0) self._livesBG = bs.NodeActor( bs.newNode('image', attrs={ 'texture': self._heartTex, 'modelOpaque': self._heartModelOpaque, 'modelTransparent': self._heartModelTransparent, 'attach': 'topRight', 'scale': (90, 90), 'position': (-110 + lOffs, -50), 'color': (1, 0.2, 0.2) })) vr = bs.getEnvironment()['vrMode'] self._startLives = 10 self._lives = self._startLives self._livesText = bs.NodeActor( bs.newNode('text', attrs={ 'vAttach': 'top', 'hAttach': 'right', 'hAlign': 'center', 'color': (1, 1, 1, 1) if vr else (0.8, 0.8, 0.8, 1.0), 'flatness': 1.0 if vr else 0.5, 'shadow': 1.0 if vr else 0.5, 'vrDepth': 10, 'position': (-113 + lOffs, -69), 'scale': 1.3, 'text': str(self._lives) })) bs.gameTimer(2000, self._startUpdatingWaves)
def __init__(self, position, power='random', size=6, breakable=True, moving=False): bs.Actor.__init__(self) factory = self.getFactory() fmodel = factory.model fmodels = factory.modelSimple self.died = False self.breakable = breakable self.moving = moving # move right and left self.lrSig = 1 # left or right signal self.lrSpeedPlus = random.uniform(1 / 2.0, 1 / 0.7) self._npcBots = bs.BotSet() tex = { 'punch': factory.texPunch, 'sticky': factory.texStickyBombs, 'ice': factory.texIceBombs, 'impact': factory.texImpactBombs, 'health': factory.texHealth, 'curse': factory.texCurse, 'shield': factory.texShield, 'landmine': factory.texLandMines, 'tnt': factory.texTNT, }.get(power, factory.texTNT) if power == 'random': random.seed() tex = random.choice(factory.randTex) self.tex = tex self.powerupType = { factory.texPunch: 'punch', factory.texBomb: 'tripleBombs', factory.texIceBombs: 'iceBombs', factory.texImpactBombs: 'impactBombs', factory.texLandMines: 'landMines', factory.texStickyBombs: 'stickyBombs', factory.texShield: 'shield', factory.texHealth: 'health', factory.texCurse: 'curse', factory.texTNT: 'tnt' }.get(self.tex, '') self._spawnPos = (position[0], position[1], position[2]) self.node = bs.newNode('prop', delegate=self, attrs={ 'body': 'landMine', 'position': self._spawnPos, 'model': fmodel, 'lightModel': fmodels, 'shadowSize': 0.5, 'velocity': (0, 0, 0), 'density': 90000000000, 'sticky': False, 'bodyScale': size, 'modelScale': size, 'colorTexture': tex, 'reflection': 'powerup', 'isAreaOfInterest': True, 'gravityScale': 0.0, 'reflectionScale': [0], 'materials': (factory.footholdMaterial, bs.getSharedObject('objectMaterial'), bs.getSharedObject('footingMaterial')) }) self.touchedSpazs = set() self.keepVel()
def onBegin(self): bs.TeamGameActivity.onBegin(self) # drop a wave every few seconds.. and every so often drop the time between waves # ..lets have things increase faster if we have fewer players #self._meteorTime = 3000 t = 7500 if len(self.players) > 2 else 4000 if self.settings['Epic Mode']: t /= 4 #bs.gameTimer(t,self._decrementMeteorTime,repeat=True) # kick off the first wave in a few seconds t = 3000 if self.settings['Epic Mode']: t /= 4 #bs.gameTimer(t,self._setMeteorTimer) bPos = self.getMap().defs.points['flagDefault'] #botSpawnTop # this wrangles our bots self._bots = bs.BotSet() # start some timers to spawn bots bs.gameTimer( 1000, bs.Call(self._bots.spawnBot, bs.PirateBot, pos=bPos, spawnTime=3000)) bs.gameTimer( 1000, bs.Call(self._bots.spawnBot, bs.PirateBot, pos=bPos, spawnTime=5000)) bs.gameTimer( 1000, bs.Call(self._bots.spawnBot, bs.PirateBot, pos=bPos, spawnTime=7000)) #bs.gameTimer(2000,bs.Call(self._bots.spawnBot,bs.PirateBot,pos=(-3,3,-2),spawnTime=3000)) #bs.gameTimer(3000,bs.Call(self._bots.spawnBot,bs.NinjaBot,pos=(5,3,-2),spawnTime=3000)) #bs.gameTimer(4000,bs.Call(self._bots.spawnBot,bs.NinjaBot,pos=(-5,3,-2),spawnTime=3000)) # add a few extras for multiplayer if len(self.initialPlayerInfo) > 2: bs.gameTimer( 1000, bs.Call(self._bots.spawnBot, bs.PirateBot, pos=bPos, spawnTime=9000)) bs.gameTimer( 1000, bs.Call(self._bots.spawnBot, bs.PirateBot, pos=bPos, spawnTime=11000)) if len(self.initialPlayerInfo) > 5: bs.gameTimer( 1000, bs.Call(self._bots.spawnBot, bs.PirateBot, pos=bPos, spawnTime=13000)) bs.gameTimer( 1000, bs.Call(self._bots.spawnBot, bs.PirateBot, pos=bPos, spawnTime=15000)) # note: if spawns were spread out more we'd probably want to set some sort of flag on the # last spawn to ensure we don't inadvertantly allow a 'win' before every bot is spawned. # (ie: if bot 1, 2, and 3 got killed but 4 hadn't spawned yet, the game might end because # it sees no remaining bots. self._updateTimer = bs.Timer(1000, self._onSpazBotDied, repeat=True) self._timer = bs.OnScreenTimer() bs.gameTimer(4000, self._timer.start)