def endGame(self): # tell our bots to celebrate just to rub it in self._bots.finalCelebrate() self._gameOver = True self.doEnd('defeat', delay=2000) bs.playMusic(None)
def powerupAccepted(self): self.setupStandardPowerupDrops() self.p.node.delete() bs.playMusic('doomsday') self.lightningBolt() self.updateScore() bs.gameTimer(1000,bs.Call(self.startNextWave,self.num))
def onTransitionIn(self): bs.CoopGameActivity.onTransitionIn(self) # show special landmine tip on rookie preset if self._preset in ['rookie', 'rookieEasy']: # show once per session only (then we revert to regular tips) if not hasattr(bs.getSession(), '_gShowedOnslaughtLandMineTip'): bs.getSession()._gShowedOnslaughtLandMineTip = True self.tips = [ {'tip': "Land-mines are a good way to stop speedy enemies.", 'icon': bs.getTexture('powerupLandMines'), 'sound': bs.getSound('ding')}] # show special tnt tip on pro preset if self._preset in ['pro', 'proEasy']: # show once per session only (then we revert to regular tips) if not hasattr(bs.getSession(), '_gShowedOnslaughtTntTip'): bs.getSession()._gShowedOnslaughtTntTip = True self.tips = [{ 'tip': "Take out a group of enemies by\nsetting" " off a bomb near a TNT box.", 'icon': bs.getTexture('tnt'), 'sound': bs.getSound('ding')}] # show special curse tip on uber preset if self._preset in ['uber', 'uberEasy']: # show once per session only (then we revert to regular tips) if not hasattr(bs.getSession(), '_gShowedOnslaughtCurseTip'): bs.getSession()._gShowedOnslaughtCurseTip = True self.tips = [{ 'tip': "Curse boxes turn you into a ticking time bomb.\n" "The only cure is to quickly grab a health-pack.", 'icon': bs.getTexture('powerupCurse'), 'sound': bs.getSound('ding')}] self._spawnInfoText = bs.NodeActor( bs.newNode( "text", attrs={'position': (15, -130), 'hAttach': "left", 'vAttach': "top", 'scale': 0.55, 'color': (0.3, 0.8, 0.3, 1.0), 'text': ''})) bs.playMusic('Onslaught') self._scoreBoard = bs.ScoreBoard( label=bs.Lstr(resource='scoreText'), scoreSplit=0.5) self._gameOver = False self._wave = 0 self._canEndWave = True # we use this in place of a regular int to make it harder to hack scores self._score = bs.SecureInt(0) self._timeBonus = 0
def endGame(self): # FIXME FIXME FIXME - if we don't start our bots moving again we get # stuck this is because the bot-set never prunes itself while movement # is off and onFinalize never gets called for some bots because # _pruneDeadObjects() saw them as dead and pulled them off the # weak-ref lists. this is an architectural issue; can hopefully fix # this by having _actorWeakRefs not look at exists() self._bots.startMoving() bs.gameTimer(1, bs.Call(self.doEnd, 'defeat')) bs.playMusic(None) bs.playSound(self._playerDeathSound)
def updateScores(self): """ update scoreboard and check for winners """ haveScoringTeam = False winScore = self._scoreToWin for team in [self.teams[0], self._botTeam]: self._scoreBoard.setTeamValue(team, team.gameData['score'], winScore) if team.gameData['score'] >= winScore: if not haveScoringTeam: self.scoringTeam = team if team is self._botTeam: self.continueOrEndGame() #self.endGame() else: bs.playMusic('Victory') # completion achievements if self._preset in ['rookie', 'rookieEasy']: self._awardAchievement('Rookie Football Victory', sound=False) if self._botTeam.gameData['score'] == 0: self._awardAchievement( 'Rookie Football Shutout', sound=False) elif self._preset in ['pro', 'proEasy']: self._awardAchievement('Pro Football Victory', sound=False) if self._botTeam.gameData['score'] == 0: self._awardAchievement('Pro Football Shutout', sound=False) elif self._preset in ['uber', 'uberEasy']: self._awardAchievement('Uber Football Victory', sound=False) if self._botTeam.gameData['score'] == 0: self._awardAchievement('Uber Football Shutout', sound=False) if not self._playerHasDroppedBomb and not self._playerHasPunched: self._awardAchievement('Got the Moves', sound=False) self._bots.stopMoving() self.showZoomMessage(bs.Lstr(resource='victoryText'), scale=1.0, duration=4000) self.celebrate(10000) self._finalTime = (bs.getGameTime() - self._startTime) self._timeTextTimer = None self._timeTextInput.node.timeMax = self._finalTime # self._updateTime(forceValue=self._finalTime) # make sure our timer shows the final time bs.gameTimer(1, bs.Call(self.doEnd, 'victory'))
def _startPreloads(self): # FIXME - the func that calls us back doesn't save/restore state # or check for a dead activity so we have to do that ourself.. if self.isFinalized(): return with bs.Context(self): _preload1() bs.gameTimer(500,lambda: bs.playMusic('Menu'))
def _startPreloads(self): # FIXME - the func that calls us back doesn't save/restore state # or check for a dead activity so we have to do that ourself.. if self.isFinalized(): return with bs.Context(self): _preload1() numb = random.randint(1, 101) if numb <= 30: bs.gameTimer(500,lambda: bs.playMusic('Menu')) elif numb <= 50: bs.gameTimer(500, lambda: bs.playMusic("rick_and_morty")) elif numb <= 70: bs.gameTimer(500, lambda: bs.playMusic("the_last_of_us")) elif numb <= 90: bs.gameTimer(500, lambda: bs.playMusic("naz_march")) else: bs.gameTimer(500,lambda: bs.playMusic('seny_seny'))
def doEnd(self,outcome): bs.playMusic(None) if self._score2 > 500: outcome = 'defeat' self._score2 = 0 self.end(results={'outcome':outcome,'score':self._score2,'playerInfo':self.initialPlayerInfo},delay = 3000) if outcome == 'defeat': self._bots.finalCelebrate() self.fadeToRed() elif outcome == 'victory': tint = bs.getSharedObject('globals').tint bsUtils.animateArray(bs.getSharedObject('globals'),"tint",3,{0:tint,1000:(1.4,1.4,1.4)}) self.cameraFlash() import bsAchievement bsAchievement._awardLocalAchievement('Boss') import settings settings.bolt = True settings.duck = True settings.saveSettings()
def endGame(self): self._timer.stop() results = bs.TeamGameResults() if self._won: bs.playMusic('Victory') self._awardAchievement( self.settings.get("preset") + " Boss Fight completed") elapsedTime = bs.getGameTime() - self._timer.getStartTime() self.cameraFlash() bs.playSound(self._winSound) for team in self.teams: team.celebrate() # woooo! par-tay! results.setTeamScore(team, elapsedTime) else: self._boss.finalCelebrate() self.fadeToRed() bs.playMusic(None) bs.netTimer(3000, bs.WeakCall(self.end, results))
def endGame(self): # tell our bots to celebrate just to rub it in self._bots.finalCelebrate() bs.gameTimer(1, bs.WeakCall(self.doEnd, 'defeat')) bs.playMusic(None)
def onTransitionIn(self, music=None): """ Method override; optionally can be passed a 'music' string which is the suggested type of music to play during the game. Note that in some cases music may be overridden by the map or other factors, which is why you should pass it in here instead of simply playing it yourself. """ bs.Activity.onTransitionIn(self) colo = (random.uniform(0.5, 3), random.uniform(0.5, 3), random.uniform(0.5, 3)) if some.show_texts: m = [ ("Scripts Made By: Logic\nHosting Provider: {}").format(some.host), ("Asking For Adminship Can Get You Kicked"), (u"Mail Your Suggestions/Contributions On \n [email protected]" ), (u"All Chats, Name & ID's Are Being Logged..."), ("This Party Has An Abusive Filter\nWith Over 600 Filtered Words"), ("Stats Get Reset Every Monday!\nPoints Are Not Affected"), (u"Join RAGE On Discord To Get Server Address!\nLink: https://bit.ly/awesomelogic" ), (u"For The Best Gaming Experience,\nNight Mode Will Automatically Turn On At 8PM Till 7AM" ), ("Swipe From Punch To Jump To Perform A Backflip\nLong Press Bomb Button To Toggle It!" ), ("Thanks For Playing!\nHave Fun And Play Ethically!") ] else: m = [''] self.myName = bsUtils.Text( random.choice(m), vAttach='bottom', hAlign='center', shadow=1.0, position=(0, 140) if self.getName() == "Elimination" else (0, 100) if self.getName() == "BombSpot" else (0, 50), color=colo, maxWidth=350) po = self.myName.node.position obj = bsUtils.Text(bs.getSpecialChar('logoFlat'), position=(po[0] + 325, po[1] + 0), vAttach='bottom', color=colo, hAlign='center', vAlign='center', scale=1.5 if some.show_texts else 0).autoRetain() obj1 = bsUtils.Text(bs.getSpecialChar('logoFlat'), position=(po[0] - 325, po[1] + 0), vAttach='bottom', color=colo, hAlign='center', vAlign='center', scale=1.5 if some.show_texts else 0).autoRetain() def animate(): self.myName.node.text = random.choice(m) def animate3(): bs.animate(self.myName.node, 'opacity', {0: 1, 1000: 0, 2000: 1}) bs.animate(obj.node, 'opacity', {0: 1, 1000: 0, 2000: 1}) bs.animate(obj1.node, 'opacity', {0: 1, 1000: 0, 2000: 1}) bs.gameTimer(1000, animate) animate3() bs.animate(obj.node, 'rotate', {0: 0.0, 3000: 360.0}, loop=True) bs.animate(obj1.node, 'rotate', {0: 0.0, 3000: 360.0}, loop=True) bs.animate(self.myName.node, 'scale', { 0: 1.25, 1000: 1.30, 2000: 1.25 }, loop=True) bs.gameTimer(9000, animate3, repeat=True) self.version = bs.NodeActor( bs.newNode( 'text', attrs={ 'vAttach': 'bottom', 'vAlign': 'bottom', 'hAttach': 'left', 'hAlign': 'left', 'flatness': 1.0, 'opacity': 1.0, 'shadow': 0.5, 'color': (0.5, 0.5, 0.5, 0.7), 'scale': 0.7, 'position': (10, 10), 'text': bsUtils._gServerConfig.get('partyName', '') + ('\n' + 'Scripts Available At: https://github.com/Awesome-Logic/' ) #if some.is_logic else '' })) self.version2 = bs.NodeActor( bs.newNode('text', attrs={ 'vAttach': 'bottom', 'vAlign': 'bottom', 'hAttach': 'right', 'hAlign': 'right', 'flatness': 1.0, 'opacity': 1.0, 'shadow': 0.5, 'color': (0.5, 0.5, 0.5, 0.7), 'scale': 0.7, 'position': (-10, 10), 'text': 'Scripts By: Logic\nHosting By: {}'.format(some.host) })) txt = '\n'.join(open(some.flyfile).read().split('\n')) animateText = bsUtils.Text(txt, position=(0, 285), hAlign='center', vAlign='top', flatness=1.0, maxWidth=180, color=colo, transition='inLeft', scale=3.0, transitionOutDelay=8000, shadow=1.0, transitionDelay=5000).autoRetain() # make our map self._map = self._mapType() # give our map a chance to override the music # (for happy-thoughts and other such themed maps) overrideMusic = self._mapType.getMusicType() if overrideMusic is not None: music = overrideMusic if music is not None: bs.playMusic(music)
def _updateWaves(self): # if we have no living bots, go to the next wave if (self._canEndWave and not self._bots.haveLivingBots() and not self._gameOver): self._canEndWave = False self._timeBonusTimer = None self._timeBonusText = None if self._preset in ['endless', 'endlessTournament']: won = False else: won = (self._wave == len(self._waves)) # reward time bonus baseDelay = 4000 if won else 0 if self._timeBonus > 0: bs.gameTimer(0, lambda: bs.playSound(self._cashRegisterSound)) bs.gameTimer(baseDelay, bs.WeakCall( self._awardTimeBonus, self._timeBonus)) baseDelay += 1000 # reward flawless bonus if self._wave > 0: haveFlawless = False for player in self.players: if (player.isAlive() and player.gameData['hasBeenHurt'] == False): haveFlawless = True bs.gameTimer(baseDelay, bs.WeakCall( self._awardFlawlessBonus, player)) player.gameData['hasBeenHurt'] = False # reset if haveFlawless: baseDelay += 1000 if won: self.showZoomMessage( bs.Lstr(resource='victoryText'), scale=1.0, duration=4000) self.celebrate(20000) # rookie onslaught completion if self._preset in ['training', 'trainingEasy']: self._awardAchievement( 'Onslaught Training Victory', sound=False) if not self._playerHasDroppedBomb: self._awardAchievement('Boxer', sound=False) elif self._preset in ['rookie', 'rookieEasy']: self._awardAchievement( 'Rookie Onslaught Victory', sound=False) if not self._aPlayerHasBeenHurt: self._awardAchievement('Flawless Victory', sound=False) elif self._preset in ['pro', 'proEasy']: self._awardAchievement('Pro Onslaught Victory', sound=False) if not self._playerHasDroppedBomb: self._awardAchievement('Pro Boxer', sound=False) elif self._preset in ['uber', 'uberEasy']: self._awardAchievement( 'Uber Onslaught Victory', sound=False) bs.gameTimer(baseDelay, bs.WeakCall(self._awardCompletionBonus)) baseDelay += 850 bs.playSound(self._winSound) self.cameraFlash() bs.playMusic('Victory') self._gameOver = True # cant just pass delay to doEnd because our extra bonuses # havnt been added yet (once we call doEnd the score # gets locked in) bs.gameTimer(baseDelay, bs.WeakCall(self.doEnd, 'victory')) return self._wave += 1 # short celebration after waves if self._wave > 1: self.celebrate(500) bs.gameTimer(baseDelay, bs.WeakCall(self._startNextWave))
def endGame(self): bs.playMusic(None) self._bots.finalCelebrate() bs.gameTimer(1, bs.Call(self.doEnd, 'defeat'))
def _updateWaves(self): # if we have no living bots, go to the next wave if (self._canEndWave and not self._bots.haveLivingBots() and not self._gameOver and self._lives > 0): self._canEndWave = False self._timeBonusTimer = None self._timeBonusText = None if self._preset in ['endless', 'endlessTournament']: won = False else: won = (self._wave == len(self._waves)) # reward time bonus baseDelay = 4000 if won else 0 if self._timeBonus > 0: bs.gameTimer(0, bs.Call(bs.playSound, self._cashRegisterSound)) bs.gameTimer(baseDelay, bs.Call(self._awardTimeBonus, self._timeBonus)) baseDelay += 1000 # reward flawless bonus if self._wave > 0 and self._flawless: bs.gameTimer(baseDelay, self._awardFlawlessBonus) baseDelay += 1000 self._flawless = True # reset if won: # completion achievements if self._preset in ['pro', 'proEasy']: self._awardAchievement('Pro Runaround Victory', sound=False) if self._lives == self._startLives: self._awardAchievement('The Wall', sound=False) if not self._playerHasPickedUpPowerup: self._awardAchievement('Precision Bombing', sound=False) elif self._preset in ['uber', 'uberEasy']: self._awardAchievement('Uber Runaround Victory', sound=False) if self._lives == self._startLives: self._awardAchievement('The Great Wall', sound=False) if not self._aPlayerHasBeenKilled: self._awardAchievement('Stayin\' Alive', sound=False) # give remaining players some points and have them celebrate self.showZoomMessage(bs.Lstr(resource='victoryText'), scale=1.0, duration=4000) self.celebrate(10000) bs.gameTimer(baseDelay, self._awardLivesBonus) baseDelay += 1000 bs.gameTimer(baseDelay, self._awardCompletionBonus) baseDelay += 850 bs.playSound(self._winSound) self.cameraFlash() bs.playMusic('Victory') self._gameOver = True bs.gameTimer(baseDelay, bs.Call(self.doEnd, 'victory')) return self._wave += 1 # short celebration after waves if self._wave > 1: self.celebrate(500) bs.gameTimer(baseDelay, self._startNextWave)