def setScoreText(self, text): """ Utility func to show a message over the flag; handy for scores. """ if not self.node.exists(): return try: exists = self._scoreText.exists() except Exception: exists = False if not exists: startScale = 0.0 math = bs.newNode('math', owner=self.node, attrs={'input1': (0, 0.6, 0), 'operation':'add'}) self.node.connectAttr('position', math, 'input2') self._scoreText = bs.newNode('text', owner=self.node, attrs={'text':text, 'inWorld':True, 'scale':0.02, 'shadow':0.5, 'flatness':1.0, 'hAlign':'center'}) math.connectAttr('output', self._scoreText, 'position') else: startScale = self._scoreText.scale self._scoreText.text = text self._scoreText.color = bs.getSafeColor((1.0, 1.0, 0.4)) bs.animate(self._scoreText, 'scale', {0: startScale, 200: 0.02}) self._scoreTextHideTimer = bs.Timer(1000, bs.WeakCall(self._hideScoreText))
def setPowText(self, color=(1, 1, 0.4)): m = bs.newNode('math', owner=self.node, attrs={'input1': (0, 0.7, 0), 'operation': 'add'}) self.node.connectAttr('position', m, 'input2') self._powText = bs.newNode('text', owner=self.node, attrs={'text':'POW!', 'inWorld':True, 'shadow':1.0, 'flatness':1.0, 'color':color, 'scale':0.0, 'hAlign':'center'}) m.connectAttr('output', self._powText, 'position') bs.animate(self._powText, 'scale', {0: 0.0, 1000: 0.01})
def __init__(self, incTime=1000): lightY = 150 self.pos = 0 self._beep1Sound = bs.getSound('raceBeep1') self._beep2Sound = bs.getSound('raceBeep2') self.lights = [] for i in range(4): l = bs.newNode('image', attrs={'texture':bs.getTexture('nub'), 'opacity':1.0, 'absoluteScale':True, 'position':(-75+i*50, lightY), 'scale':(50, 50), 'attach':'center'}) bs.animate(l, 'opacity', {10:0, 1000:1.0}) self.lights.append(l) self.lights[0].color = (0.2, 0, 0) self.lights[1].color = (0.2, 0, 0) self.lights[2].color = (0.2, 0.05, 0) self.lights[3].color = (0.0, 0.3, 0) self.cases = {1: self._doLight1, 2: self._doLight2, 3: self._doLight3, 4: self._doLight4} self.incTimer = None self.incTime = incTime
def __init__(self, position, team): bsHockey.Puck.__init__(self, position) self.team = team self.tickrate = 100 self._timeout = 5000 / self.tickrate self._count = self._timeout self._tickTimer = bs.Timer(self.tickrate, call=bs.WeakCall(self._tick), repeat=True) self._counter = bs.newNode( "text", owner=self.node, attrs={ "inWorld": True, "color": (1, 1, 1, 0.7), "scale": 0.015, "shadow": 0.5, "flatness": 1.0, "hAlign": "center", }, ) self.age = 0 self.scored = False self.lastHoldingPlayer = None self.light = None self.movedSinceSpawn = False
def _setChosenOnePlayer(self, player): try: for p in self.players: p.gameData['FrozenLight'] = None bs.playSound(self._swipSound) if player is None or not player.exists(): self._flag = bs.Flag(color=(1,0.9,0.2), position=self._flagSpawnPos, touchable=False) self._chosenOnePlayer = None l = bs.newNode('light', owner=self._flag.node, attrs={'position': self._flagSpawnPos, 'intensity':0.6, 'heightAttenuated':False, 'volumeIntensityScale':0.1, 'radius':0.1, 'color': (1.2,1.2,0.4)}) self._flashFlagSpawn() else: if player.actor is not None: self._flag = None self._chosenOnePlayer = player if player.actor.node.exists(): if self.settings['Frozen One Gets Gloves']: player.actor.handleMessage(bs.PowerupMessage('punch')) player.actor.frozen = True player.actor.node.frozen = 1 # use a color that's partway between their team color and white color = [0.3+c*0.7 for c in bs.getNormalizedColor(player.getTeam().color)] l = player.gameData['FrozenLight'] = bs.NodeActor(bs.newNode('light', attrs={"intensity":0.6, "heightAttenuated":False, "volumeIntensityScale":0.1, "radius":0.13, "color": color})) bs.animate(l.node, 'intensity', {0:1.0, 200:0.4, 400:1.0}, loop=True) player.actor.node.connectAttr('position',l.node,'position') except Exception, e: import traceback print 'EXC in _setChosenOnePlayer' traceback.print_exc(e) traceback.print_stack()
def spawnPlayer(self, player): if isinstance(self.getSession(), bs.TeamsSession): position = self.getMap().getStartPosition(player.getTeam().getID()) else: # otherwise do free-for-all spawn locations position = self.getMap().getFFAStartPosition(self.players) angle = None # spaz = self.spawnPlayerSpaz(player) # lets reconnect this player's controls to this # spaz but *without* the ability to attack or pick stuff up # spaz.connectControlsToPlayer(enablePunch=False, # enableBomb=False, # enablePickUp=False) # also lets have them make some noise when they die.. # spaz.playBigDeathSound = True name = player.getName() lightColor = bsUtils.getNormalizedColor(player.color) displayColor = bs.getSafeColor(player.color, targetIntensity=0.75) spaz = Player(color=player.color, highlight=player.highlight, character=player.character, player=player) player.setActor(spaz) # we want a bigger area-of-interest in co-op mode # if isinstance(self.getSession(),bs.CoopSession): spaz.node.areaOfInterestRadius = 5.0 # else: spaz.node.areaOfInterestRadius = 5.0 # if this is co-op and we're on Courtyard or Runaround, add the material that allows us to # collide with the player-walls # FIXME; need to generalize this if isinstance(self.getSession(), bs.CoopSession) and self.getMap().getName() in ["Courtyard", "Tower D"]: mat = self.getMap().preloadData["collideWithWallMaterial"] spaz.node.materials += (mat,) spaz.node.rollerMaterials += (mat,) spaz.node.name = name spaz.node.nameColor = displayColor spaz.connectControlsToPlayer( enableJump=True, enablePunch=True, enablePickUp=False, enableBomb=True, enableRun=True, enableFly=False ) self.scoreSet.playerGotNewSpaz(player, spaz) # move to the stand position and add a flash of light spaz.handleMessage(bs.StandMessage(position, angle if angle is not None else random.uniform(0, 360))) t = bs.getGameTime() bs.playSound(self._spawnSound, 1, position=spaz.node.position) light = bs.newNode("light", attrs={"color": lightColor}) spaz.node.connectAttr("position", light, "position") bsUtils.animate(light, "intensity", {0: 0, 250: 1, 500: 0}) bs.gameTimer(500, light.delete)
def _spawnBox(self): bs.playSound(self._swipSound) self._flashBoxSpawn() self._box = MagicBox(position=self._boxSpawnPos) self._boxState = self.BOX_NEW self._box.light = bs.newNode('light', owner=self._box.node, attrs={'intensity':0.2, 'radius':0.3, 'color': (0.2, 0.2, 0.2)}) self._box.node.connectAttr('position', self._box.light, 'position') self._updateBoxState()
def _spawnPuck(self, team): puckPos = self.getMap().getStartPosition(team.getID()) lightcolor = team.color bs.playSound(self._swipSound) bs.playSound(self._whistleSound) self._flashPuckSpawn(puckPos) puck = Puck(position=puckPos, team=team) puck.light = bs.newNode( "light", owner=puck.node, attrs={"intensity": 0.3, "heightAttenuated": False, "radius": 0.2, "color": lightcolor}, ) puck.node.connectAttr("position", puck.light, "position") self.pucks.append(puck)
def _dropBombCluster(self): # random note: code like this is a handy way to plot out extents and debug things if False: bs.newNode('locator',attrs={'position':(8,6,-5.5)}) bs.newNode('locator',attrs={'position':(8,6,-2.3)}) bs.newNode('locator',attrs={'position':(-7.3,6,-5.5)}) bs.newNode('locator',attrs={'position':(-7.3,6,-2.3)}) # drop several bombs in series.. delay = 0 for i in range(random.randrange(1,3)): # drop them somewhere within our bounds with velocity pointing toward the opposite side pos = (-7.3+15.3*random.random(),11,-5.5+2.1*random.random()) vel = ((-5.0+random.random()*30.0) * (-1.0 if pos[0] > 0 else 1.0), -4.0,0) bs.gameTimer(delay,bs.Call(self._dropBomb,pos,vel)) delay += 100 self._setMeteorTimer()
def __init__(self, position=(0, 1.5, 0)): bs.Actor.__init__(self) activity = self.getActivity() # spawn just above the provided point self._spawnPos = (position[0], position[1] + 0.3, position[2]) self.node = bs.newNode("prop", attrs={ 'model': activity._nightModel, 'colorTexture': activity._nightTex, 'body': 'sphere', 'reflection': 'soft', 'bodyScale': 0.1, 'modelScale': 0.001, 'density': 0.010, 'reflectionScale': [0.23], 'shadowSize': 999999.0, 'isAreaOfInterest': True, 'position': self._spawnPos, 'materials': [ bs.getSharedObject('objectMaterial'), activity._nightMaterial ] }, delegate=self)
def equipShields(self, decay=False): """ Give this spaz a nice energy shield. """ if not self.node.exists(): bs.printError('Can\'t equip shields; no node.') return factory = self.getFactory() if self.shield is None: self.shield = bs.newNode('shield', owner=self.node, attrs={'color':self.node.color, 'radius':1.3}) self.node.connectAttr('positionCenter', self.shield, 'position') self.shieldHitPoints = self.shieldHitPointsMax = 650 self.shieldDecayRate = factory.shieldDecayRate if decay else 0 self.shield.hurt = 0 bs.playSound(factory.shieldUpSound, 1.0, position=self.node.position) if self.shieldDecayRate > 0: self.shieldDecayTimer = bs.Timer(500, bs.WeakCall(self.shieldDecay), repeat=True) self.shield.alwaysShowHealthBar = True # so user can see the decay
def __init__(self, position=(0,1,0), sourcePlayer=None, owner=None): bs.Actor.__init__(self) activity = self.getActivity() # spawn just above the provided point self._spawnPos = (position[0], position[1]+1.0, position[2]) #This line was replaced by 'color' belwo: 'colorTexture': bsBomb.BombFactory().impactTex, self.node = bs.newNode("prop", attrs={'model': activity._ballModel, 'body':'sphere', 'colorTexture': bs.getTexture("frostyColor"), 'reflection':'soft', 'modelScale':2.0, 'bodyScale':2.0, 'density':0.08, 'reflectionScale':[0.15], 'shadowSize': 0.6, 'position':self._spawnPos, 'materials': [bs.getSharedObject('objectMaterial'),activity._bombMat] }, delegate=self) self.sourcePlayer = sourcePlayer self.owner = owner
def __init__(self, settings): self._raceStarted = False bs.TeamGameActivity.__init__(self, settings) for player in self.players: player.gameData['lastPoint'] = 0 self._scoreBoard = bs.ScoreBoard() if self.settings['Epic Mode']: self._isSlowMotion = True self._scoreSound = bs.getSound("score") self._swipSound = bs.getSound("swip") self._lastTeamTime = None self._frontRaceRegion = None 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': "Created by MattZ45986 on Github", }))
def spawnPlayerSpaz(self, player, position=(.5, 5, -4), angle=0): s = self.settings name = player.getName() color = player.color highlight = player.highlight players = self.players num = len(players) i = 0 position = (-.5 + random.random() * 2, 3 + random.random() * 2, -5 + random.random() * 2) angle = 0 spaz = bs.PlayerSpaz(color=color, highlight=highlight, character=player.character, player=player) player.setActor(spaz) spaz.connectControlsToPlayer(enableBomb=False, enableRun=s["Enable Running"], enablePunch=s["Enable Punching"]) spaz.handleMessage(bs.StandMessage(position, angle)) spaz.node.name = name spaz.node.nameColor = color self.scoreSet.playerGotNewSpaz(player, spaz) # move to the stand position and add a flash of light spaz.handleMessage( bs.StandMessage( position, angle if angle is not None else random.uniform(0, 360))) t = bs.getGameTime() bs.playSound(self._spawnSound, 1, position=spaz.node.position) light = bs.newNode('light', attrs={'color': color}) spaz.node.connectAttr('position', light, 'position') bsUtils.animate(light, 'intensity', {0: 0, 250: 1, 500: 0}) bs.gameTimer(500, light.delete) return spaz
def spawnPlayer(self, player): spaz = self.spawnPlayerSpaz(player) spaz.connectControlsToPlayer() if self.settings["Speed"]: spaz.node.hockey = True if self.settings["Night Mode"]: bs.getSharedObject('globals').tint = (0.5, 0.7, 1) spaz.spazLight = bs.newNode('light', attrs={ 'position': (0, 0, 0), 'color': spaz.node.color, 'radius': 0.10, 'intensity': 1, 'volumeIntensityScale': 10.0 }) spaz.node.connectAttr('position', spaz.spazLight, 'position') def checkExistsSpaz(): if spaz.node.exists(): bs.gameTimer(10, bs.Call(checkExistsSpaz)) else: spaz.spazLight.delete() checkExistsSpaz()
def __init__(self, pos=(0, 5, 0), scale=1.35, owner=None): self.owner = owner bs.Actor.__init__(self) box_material = bs.Material() box_material.addActions( conditions=((('weAreYoungerThan', 0),'or',('theyAreYoungerThan', 0)), 'and', ('theyHaveMaterial', bs.getSharedObject('objectMaterial'))), actions=(('modifyNodeCollision', 'collide', True))) box_material.addActions(conditions=('theyHaveMaterial', bs.getSharedObject('pickupMaterial')), actions=(('modifyPartCollision', 'useNodeCollide', False))) box_material.addActions(actions=('modifyPartCollision','friction', 1000)) self.node = bs.newNode('prop', delegate=self, attrs={ 'position': pos, 'velocity': (0, 0, 0), 'model': bs.getModel('tnt'), 'modelScale': scale, 'body': 'crate', 'bodyScale': scale, 'shadowSize': 0.26 * scale, 'colorTexture': bs.getTexture(random.choice(["flagColor", "frameInset"])), 'reflection': 'soft', 'reflectionScale': [0.23], 'materials': (bs.getSharedObject('footingMaterial'), bs.getSharedObject('objectMaterial'))})
def spawnPlayerSpaz(self, player, position=(0, 0, 0), angle=None): """ Create and wire up a bs.PlayerSpaz for the provide bs.Player. """ position = self.getMap().getFFAStartPosition(self.players) name = player.getName() color = player.color highlight = player.highlight lightColor = bsUtils.getNormalizedColor(color) displayColor = bs.getSafeColor(color, targetIntensity=0.75) bt = random.choice([ 'Jumper', 'Hopper', 'Bomber', 'Stronger', 'Flash', 'Frozenman', 'Shieldman' ]) if bt == 'Jumper': bt = PlayerSpazTeleporter name += '\nJUMPER' elif bt == 'Hopper': bt = PlayerSpazJumper name += '\nHOPPER' elif bt == 'Bomber': bt = PlayerSpazBomber name += '\nBOMBER' elif bt == 'Stronger': extra = 'strong' bt = PlayerSpazNormal name += '\nHULK' elif bt == 'Flash': extra = 'speed' bt = PlayerSpazNormal name += '\nFLASH' elif bt == 'Frozenman': bt = PlayerSpazFrozenman name += '\nICEMAN' elif bt == 'Shieldman': extra = 'shield' bt = PlayerSpazNormal name += '\nSHIELDMAN' s = spaz = bt(color=color, highlight=highlight, character=player.character, player=player) if bt == PlayerSpazFrozenman: spaz.bombType = 'ice' if bt == PlayerSpazNormal and extra == 'speed': spaz.equipSpeed() if bt == PlayerSpazNormal and extra == 'shield': spaz.equipShields() if bt == PlayerSpazNormal and extra == 'strong': s._punchPowerScale = 5 player.setActor(spaz) spaz.node.name = name spaz.node.nameColor = displayColor spaz.connectControlsToPlayer() self.scoreSet.playerGotNewSpaz(player, spaz) # move to the stand position and add a flash of light spaz.handleMessage( bs.StandMessage( position, angle if angle is not None else random.uniform(0, 360))) t = bs.getGameTime() bs.playSound(self._spawnSound, 1, position=spaz.node.position) light = bs.newNode('light', attrs={'color': lightColor}) spaz.node.connectAttr('position', light, 'position') bsUtils.animate(light, 'intensity', {0: 0, 250: 1, 500: 0}) bs.gameTimer(500, light.delete) return spaz
def handleMessage(self, m): bs.Actor.handleMessage(self, m) if isinstance(m, ArrowTouchAnything): node = bs.getCollisionInfo("opposingNode") if node is not None and node.exists(): v = self.node.velocity t = self.node.position hitDir = self.node.velocity m = self.node self.calcMagByDistance() node.handleMessage(bs.HitMessage(pos=t, velocity=v, magnitude=self.arrowMag, velocityMagnitude=self.arrowMag, radius=0, srcNode=self.node, sourcePlayer=self.sourcePlayer, forceDirection=hitDir)) self.node.handleMessage(bs.DieMessage()) elif isinstance(m, bs.DieMessage): if self.node.exists(): velocity = self.node.velocity explosion = bs.newNode("explosion", attrs={'position': self.node.position, 'velocity': (velocity[0], max(-1.0, velocity[1]), velocity[2]), 'radius': 1, 'big': False}) bs.playSound(sound=bs.getSound(random.choice(['impactHard', 'impactHard2', 'impactHard3'])), position=self.node.position) self.node.delete() self.lightNode.delete() self._emit = None elif isinstance(m, bs.OutOfBoundsMessage): self.handleMessage(bs.DieMessage()) elif isinstance(m, bs.HitMessage): self.node.handleMessage("impulse", m.pos[0], m.pos[1], m.pos[2], m.velocity[0], m.velocity[1], m.velocity[2], 1.0 * m.magnitude, 1.0 * m.velocityMagnitude, m.radius, 0, m.forceDirection[0], m.forceDirection[1], m.forceDirection[2]) elif isinstance(m, ArrowTouchSpaz): node = bs.getCollisionInfo("opposingNode") if node is not None and node.exists(): # node.handleMessage(bs.FreezeMessage()) v = self.node.velocity t = self.node.position hitDir = self.node.velocity self.calcMagByDistance() hitType = 'hunter' if self.lifeDist > 5: hitType = 'hunterGod' # self.sourcePlayer.actor.setScoreText('狙击精英') node.handleMessage(bs.HitMessage(pos=t, velocity=(10, 10, 10), magnitude=self.arrowMag, velocityMagnitude=self.arrowMag, radius=0, srcNode=self.node, sourcePlayer=self.sourcePlayer, forceDirection=hitDir, hitType=hitType)) self.node.handleMessage(bs.DieMessage()) elif isinstance(m, ArrowTouchFootingMaterial): self.calcMagByDistance() bs.Blast(position=self.node.position, velocity=self.node.velocity, blastRadius=self.arrowBlast, blastType='normal', sourcePlayer=self.sourcePlayer, hitType='hunterBlast').autoRetain() self.handleMessage(bs.DieMessage()) # bs.playSound(sound=bs.getSound("blip"), position=self.node.position) elif isinstance(m, bs.PickedUpMessage): self.handleMessage(bs.DieMessage())
def onBegin(self): bs.TeamGameActivity.onBegin(self) scoreList = [] kdList = [] if os.path.exists(statsfile): with open(statsfile) as f: data = json.loads(f.read()) for i in data: #check if player never were killed # check if player played at least 20 games else make all scores zero / names -- check id none avgScore = data[i]['name_full'] if data[i]['played'] > 19 else \ '--', float(data[i]['scores']) / (data[i]['played']) if data[i]['played'] > 19 else \ 0, i if data[i]['played'] > 19 else 'null' kdRatio = data[i]['name_full'] if data[i]['played'] > 19 else \ '--', float(data[i]['kills']) / ( 1 if data[i]['killed'] == 0 else data[i]['killed']) if data[i]['played'] > 19 else \ 0, i if data[i]['played'] > 19 else 'null' #sorted(ortList,key=itemgetter(2)) #ortListy = sorted(ortList, key=itemgetter(2), reverse=True) #print ortList #0nick 2ortkill 4 ortkilled 6ort score scoreList.append(avgScore) kdList.append(kdRatio) else: kdList = [] scoreList = [] print('statsfile not exists') kdListSorted = sorted(kdList, key=lambda x: float(x[1]), reverse=True) scoreListSorted = sorted(scoreList, key=lambda x: float(x[1]), reverse=True) fighter1list = [] fighter2and3list = [] fighter15list = [] scorer1list = [] scorer2and3list = [] scorer15list = [] fighter1list.append( (str(kdListSorted[0][2]) if len(kdListSorted) > 0 else 'null')) fighter2and3list.append( (str(kdListSorted[1][2]) if len(kdListSorted) > 1 else 'null')) fighter2and3list.append( (str(kdListSorted[2][2]) if len(kdListSorted) > 2 else 'null')) scorer1list.append((str(scoreListSorted[0][2]) if len(scoreListSorted) > 0 else 'null')) scorer2and3list.append((str(scoreListSorted[1][2]) if len(scoreListSorted) > 1 else 'null')) scorer2and3list.append((str(scoreListSorted[2][2]) if len(scoreListSorted) > 2 else 'null')) fighter15list.append( (str(kdListSorted[3][2]) if len(kdListSorted) > 3 else 'null')) fighter15list.append( (str(kdListSorted[4][2]) if len(kdListSorted) > 4 else 'null')) fighter15list.append( (str(kdListSorted[5][2]) if len(kdListSorted) > 5 else 'null')) fighter15list.append( (str(kdListSorted[6][2]) if len(kdListSorted) > 6 else 'null')) fighter15list.append( (str(kdListSorted[7][2]) if len(kdListSorted) > 7 else 'null')) fighter15list.append( (str(kdListSorted[8][2]) if len(kdListSorted) > 8 else 'null')) fighter15list.append( (str(kdListSorted[9][2]) if len(kdListSorted) > 9 else 'null')) fighter15list.append( (str(kdListSorted[10][2]) if len(kdListSorted) > 10 else 'null')) fighter15list.append( (str(kdListSorted[11][2]) if len(kdListSorted) > 11 else 'null')) fighter15list.append( (str(kdListSorted[12][2]) if len(kdListSorted) > 12 else 'null')) fighter15list.append( (str(kdListSorted[13][2]) if len(kdListSorted) > 13 else 'null')) fighter15list.append( (str(kdListSorted[14][2]) if len(kdListSorted) > 14 else 'null')) scorer15list.append((str(scoreListSorted[3][2]) if len(scoreListSorted) > 3 else 'null')) scorer15list.append((str(scoreListSorted[4][2]) if len(scoreListSorted) > 4 else 'null')) scorer15list.append((str(scoreListSorted[5][2]) if len(scoreListSorted) > 5 else 'null')) scorer15list.append((str(scoreListSorted[6][2]) if len(scoreListSorted) > 6 else 'null')) scorer15list.append((str(scoreListSorted[7][2]) if len(scoreListSorted) > 7 else 'null')) scorer15list.append((str(scoreListSorted[8][2]) if len(scoreListSorted) > 8 else 'null')) scorer15list.append((str(scoreListSorted[9][2]) if len(scoreListSorted) > 9 else 'null')) scorer15list.append((str(scoreListSorted[10][2]) if len(scoreListSorted) > 10 else 'null')) scorer15list.append((str(scoreListSorted[11][2]) if len(scoreListSorted) > 11 else 'null')) scorer15list.append((str(scoreListSorted[12][2]) if len(scoreListSorted) > 12 else 'null')) scorer15list.append((str(scoreListSorted[13][2]) if len(scoreListSorted) > 13 else 'null')) scorer15list.append((str(scoreListSorted[14][2]) if len(scoreListSorted) > 14 else 'null')) with open(bs.getEnvironment()['systemScriptsDirectory'] + "/MythBAdminList.py") as file: s = [row for row in file] s[1] = 'Fighter1stList = ' + str(fighter1list) + '\n' s[2] = 'Fighter2nd3rd = ' + str(fighter2and3list) + '\n' s[3] = 'FighterTop15List = ' + str(fighter15list) + '\n' s[4] = 'Scorer1stList = ' + str(scorer1list) + '\n' s[5] = 'Scorer2nd3rdList = ' + str(scorer2and3list) + '\n' s[6] = 'ScorerTop15List = ' + str(scorer15list) + '\n' f = open( bs.getEnvironment()['systemScriptsDirectory'] + "/MythBAdminList.py", 'w') for updates in s: f.write(updates) f.close() reload(mbal) #mbal.AdminList[1] = str(kdListSorted[0][2]) #print mbal.AdminList #background self._backgroundLogo = bs.newNode('image', delegate=self, attrs={ 'fillScreen': True, 'texture': bs.getTexture('menuBG'), 'tiltTranslate': -0.3, 'hasAlphaChannel': False, 'color': (1, 1, 1) }) #top10score textTopScore = ScreenLanguage.top15scoreLang posTopScore = (180, 210) scaleTopScore = 1.0 colorTopScore = (1.0, 0.6, 0.8, 1) maxWidthTopScore = 300 self.powerUpText(textTopScore, posTopScore, scaleTopScore, colorTopScore, maxWidthTopScore) #top10Fighter textTopFighter = ScreenLanguage.top15fighterLang posTopFighter = (-230, 210) scaleTopFighter = 1.0 colorTopFighter = (1.0, 0.6, 0.8, 1) maxWidthTopFighter = 300 self.powerUpText(textTopFighter, posTopFighter, scaleTopFighter, colorTopFighter, maxWidthTopFighter) #top10scoreRanktext textTopScoreRank = ScreenLanguage.rankLang posTopScoreRank = (180, 175) scaleTopScoreRank = 0.9 colorTopScoreRank = (0.9, 0.8, 1, 1) maxWidthTopScoreRank = 300 self.powerUpText(textTopScoreRank, posTopScoreRank, scaleTopScoreRank, colorTopScoreRank, maxWidthTopScoreRank) #top10ScoreAvgtext textTopScoreAVG = ScreenLanguage.avgPtsLang posTopScoreAVG = (490, 175) scaleTopScoreAVG = 0.9 colorTopScoreAVG = (0.9, 0.8, 1, 1) maxWidthTopScoreAVG = 300 self.powerUpText(textTopScoreAVG, posTopScoreAVG, scaleTopScoreAVG, colorTopScoreAVG, maxWidthTopScoreAVG) #top10FighterRanktext textTopFighterRank = ScreenLanguage.rankLang posTopFighterRank = (-230, 175) scaleTopFighterRank = 0.9 colorTopFighterRank = (0.9, 0.8, 1, 1) maxWidthTopFighterRank = 300 self.powerUpText(textTopFighterRank, posTopFighterRank, scaleTopFighterRank, colorTopFighterRank, maxWidthTopFighterRank) #top10FighterKDtext textTopFighterKD = ScreenLanguage.kdLang posTopFighterKD = (90, 175) scaleTopFighterKD = 0.9 colorTopFighterKD = (0.9, 0.8, 1, 1) maxWidthTopFighterKD = 300 self.powerUpText(textTopFighterKD, posTopFighterKD, scaleTopFighterKD, colorTopFighterKD, maxWidthTopFighterKD) #rank fighter fighterRank1 = bs.getSpecialChar('trophy4') + '1. ' + ( kdListSorted[0][0] if len(kdListSorted) > 0 else '--') fighterRank2 = bs.getSpecialChar('trophy3') + '2. ' + ( kdListSorted[1][0] if len(kdListSorted) > 1 else '--') fighterRank3 = bs.getSpecialChar('trophy3') + '3. ' + ( kdListSorted[2][0] if len(kdListSorted) > 2 else '--') fighterRank4 = bs.getSpecialChar('trophy2') + '4. ' + ( kdListSorted[3][0] if len(kdListSorted) > 3 else '--') fighterRank5 = bs.getSpecialChar('trophy2') + '5. ' + ( kdListSorted[4][0] if len(kdListSorted) > 4 else '--') fighterRank6 = bs.getSpecialChar('trophy2') + '6. ' + ( kdListSorted[5][0] if len(kdListSorted) > 5 else '--') fighterRank7 = bs.getSpecialChar('trophy2') + '7. ' + ( kdListSorted[6][0] if len(kdListSorted) > 6 else '--') fighterRank8 = bs.getSpecialChar('trophy2') + '8. ' + ( kdListSorted[7][0] if len(kdListSorted) > 7 else '--') fighterRank9 = bs.getSpecialChar('trophy2') + '9. ' + ( kdListSorted[8][0] if len(kdListSorted) > 8 else '--') fighterRank10 = bs.getSpecialChar('trophy2') + '10. ' + ( kdListSorted[9][0] if len(kdListSorted) > 9 else '--') fighterRank11 = bs.getSpecialChar('trophy2') + '11. ' + ( kdListSorted[10][0] if len(kdListSorted) > 10 else '--') fighterRank12 = bs.getSpecialChar('trophy2') + '12. ' + ( kdListSorted[11][0] if len(kdListSorted) > 11 else '--') fighterRank13 = bs.getSpecialChar('trophy2') + '13. ' + ( kdListSorted[12][0] if len(kdListSorted) > 12 else '--') fighterRank14 = bs.getSpecialChar('trophy2') + '14. ' + ( kdListSorted[13][0] if len(kdListSorted) > 13 else '--') fighterRank15 = bs.getSpecialChar('trophy2') + '15. ' + ( kdListSorted[14][0] if len(kdListSorted) > 14 else '--') #K/D ratio fighterKD1 = str("{0:.2f}".format(kdListSorted[0][1] ) if len(kdListSorted) > 0 else '--') fighterKD2 = str("{0:.2f}".format(kdListSorted[1][1] ) if len(kdListSorted) > 1 else '--') fighterKD3 = str("{0:.2f}".format(kdListSorted[2][1] ) if len(kdListSorted) > 2 else '--') fighterKD4 = str("{0:.2f}".format(kdListSorted[3][1] ) if len(kdListSorted) > 3 else '--') fighterKD5 = str("{0:.2f}".format(kdListSorted[4][1] ) if len(kdListSorted) > 4 else '--') fighterKD6 = str("{0:.2f}".format(kdListSorted[5][1] ) if len(kdListSorted) > 5 else '--') fighterKD7 = str("{0:.2f}".format(kdListSorted[6][1] ) if len(kdListSorted) > 6 else '--') fighterKD8 = str("{0:.2f}".format(kdListSorted[7][1] ) if len(kdListSorted) > 7 else '--') fighterKD9 = str("{0:.2f}".format(kdListSorted[8][1] ) if len(kdListSorted) > 8 else '--') fighterKD10 = str("{0:.2f}".format(kdListSorted[9][1]) if len(kdListSorted) > 9 else '--') fighterKD11 = str("{0:.2f}".format(kdListSorted[10][1]) if len(kdListSorted) > 10 else '--') fighterKD12 = str("{0:.2f}".format(kdListSorted[11][1]) if len(kdListSorted) > 11 else '--') fighterKD13 = str("{0:.2f}".format(kdListSorted[12][1]) if len(kdListSorted) > 12 else '--') fighterKD14 = str("{0:.2f}".format(kdListSorted[13][1]) if len(kdListSorted) > 13 else '--') fighterKD15 = str("{0:.2f}".format(kdListSorted[14][1]) if len(kdListSorted) > 14 else '--') #rank score scoreRank1 = bs.getSpecialChar('trophy4') + '1. ' + ( scoreListSorted[0][0] if len(scoreListSorted) > 0 else '--') scoreRank2 = bs.getSpecialChar('trophy3') + '2. ' + ( scoreListSorted[1][0] if len(scoreListSorted) > 1 else '--') scoreRank3 = bs.getSpecialChar('trophy3') + '3. ' + ( scoreListSorted[2][0] if len(scoreListSorted) > 2 else '--') scoreRank4 = bs.getSpecialChar('trophy2') + '4. ' + ( scoreListSorted[3][0] if len(scoreListSorted) > 3 else '--') scoreRank5 = bs.getSpecialChar('trophy2') + '5. ' + ( scoreListSorted[4][0] if len(scoreListSorted) > 4 else '--') scoreRank6 = bs.getSpecialChar('trophy2') + '6. ' + ( scoreListSorted[5][0] if len(scoreListSorted) > 5 else '--') scoreRank7 = bs.getSpecialChar('trophy2') + '7. ' + ( scoreListSorted[6][0] if len(scoreListSorted) > 6 else '--') scoreRank8 = bs.getSpecialChar('trophy2') + '8. ' + ( scoreListSorted[7][0] if len(scoreListSorted) > 7 else '--') scoreRank9 = bs.getSpecialChar('trophy2') + '9. ' + ( scoreListSorted[8][0] if len(scoreListSorted) > 8 else '--') scoreRank10 = bs.getSpecialChar('trophy2') + '10. ' + ( scoreListSorted[9][0] if len(scoreListSorted) > 9 else '--') scoreRank11 = bs.getSpecialChar('trophy2') + '11. ' + ( scoreListSorted[10][0] if len(scoreListSorted) > 10 else '--') scoreRank12 = bs.getSpecialChar('trophy2') + '12. ' + ( scoreListSorted[11][0] if len(scoreListSorted) > 11 else '--') scoreRank13 = bs.getSpecialChar('trophy2') + '13. ' + ( scoreListSorted[12][0] if len(scoreListSorted) > 12 else '--') scoreRank14 = bs.getSpecialChar('trophy2') + '14. ' + ( scoreListSorted[13][0] if len(scoreListSorted) > 13 else '--') scoreRank15 = bs.getSpecialChar('trophy2') + '15. ' + ( scoreListSorted[14][0] if len(scoreListSorted) > 14 else '--') #AVG score AVGscore1 = str("{0:.1f}".format(scoreListSorted[0][1]) if len(scoreListSorted) > 0 else '--') AVGscore2 = str("{0:.1f}".format(scoreListSorted[1][1]) if len(scoreListSorted) > 1 else '--') AVGscore3 = str("{0:.1f}".format(scoreListSorted[2][1]) if len(scoreListSorted) > 2 else '--') AVGscore4 = str("{0:.1f}".format(scoreListSorted[3][1]) if len(scoreListSorted) > 3 else '--') AVGscore5 = str("{0:.1f}".format(scoreListSorted[4][1]) if len(scoreListSorted) > 4 else '--') AVGscore6 = str("{0:.1f}".format(scoreListSorted[5][1]) if len(scoreListSorted) > 5 else '--') AVGscore7 = str("{0:.1f}".format(scoreListSorted[6][1]) if len(scoreListSorted) > 6 else '--') AVGscore8 = str("{0:.1f}".format(scoreListSorted[7][1]) if len(scoreListSorted) > 7 else '--') AVGscore9 = str("{0:.1f}".format(scoreListSorted[8][1]) if len(scoreListSorted) > 8 else '--') AVGscore10 = str("{0:.1f}".format(scoreListSorted[9][1]) if len(scoreListSorted) > 9 else '--') AVGscore11 = str("{0:.1f}".format(scoreListSorted[10][1]) if len(scoreListSorted) > 10 else '--') AVGscore12 = str("{0:.1f}".format(scoreListSorted[11][1]) if len(scoreListSorted) > 11 else '--') AVGscore13 = str("{0:.1f}".format(scoreListSorted[12][1]) if len(scoreListSorted) > 12 else '--') AVGscore14 = str("{0:.1f}".format(scoreListSorted[13][1]) if len(scoreListSorted) > 13 else '--') AVGscore15 = str("{0:.1f}".format(scoreListSorted[14][1]) if len(scoreListSorted) > 14 else '--') #fighter fighterPos1 = (-230, 130) fighterPos2 = (-230, 100) fighterPos3 = (-230, 70) fighterPos4 = (-230, 40) fighterPos5 = (-230, 10) fighterPos6 = (-230, -20) fighterPos7 = (-230, -50) fighterPos8 = (-230, -80) fighterPos9 = (-230, -110) fighterPos10 = (-230, -140) fighterPos11 = (-230, -170) fighterPos12 = (-230, -200) fighterPos13 = (-230, -230) fighterPos14 = (-230, -260) fighterPos15 = (-230, -290) #KD KDpos1 = (90, 130) KDpos2 = (90, 100) KDpos3 = (90, 70) KDpos4 = (90, 40) KDpos5 = (90, 10) KDpos6 = (90, -20) KDpos7 = (90, -50) KDpos8 = (90, -80) KDpos9 = (90, -110) KDpos10 = (90, -140) KDpos11 = (90, -170) KDpos12 = (90, -200) KDpos13 = (90, -230) KDpos14 = (90, -260) KDpos15 = (90, -290) #score scorePos1 = (180, 130) scorePos2 = (180, 100) scorePos3 = (180, 70) scorePos4 = (180, 40) scorePos5 = (180, 10) scorePos6 = (180, -20) scorePos7 = (180, -50) scorePos8 = (180, -80) scorePos9 = (180, -110) scorePos10 = (180, -140) scorePos11 = (180, -170) scorePos12 = (180, -200) scorePos13 = (180, -230) scorePos14 = (180, -260) scorePos15 = (180, -290) #AVGpos AVGpos1 = (490, 130) AVGpos2 = (490, 100) AVGpos3 = (490, 70) AVGpos4 = (490, 40) AVGpos5 = (490, 10) AVGpos6 = (490, -20) AVGpos7 = (490, -50) AVGpos8 = (490, -80) AVGpos9 = (490, -110) AVGpos10 = (490, -140) AVGpos11 = (490, -170) AVGpos12 = (490, -200) AVGpos13 = (490, -230) AVGpos14 = (490, -260) AVGpos15 = (490, -290) #call fighters list self.ranklists(fighterRank1, fighterPos1) self.ranklists(fighterRank2, fighterPos2) self.ranklists(fighterRank3, fighterPos3) self.ranklists(fighterRank4, fighterPos4) self.ranklists(fighterRank5, fighterPos5) self.ranklists(fighterRank6, fighterPos6) self.ranklists(fighterRank7, fighterPos7) self.ranklists(fighterRank8, fighterPos8) self.ranklists(fighterRank9, fighterPos9) self.ranklists(fighterRank10, fighterPos10) self.ranklists(fighterRank11, fighterPos11) self.ranklists(fighterRank12, fighterPos12) self.ranklists(fighterRank13, fighterPos13) self.ranklists(fighterRank14, fighterPos14) self.ranklists(fighterRank15, fighterPos15) #call KD list self.ranklists(fighterKD1, KDpos1) self.ranklists(fighterKD2, KDpos2) self.ranklists(fighterKD3, KDpos3) self.ranklists(fighterKD4, KDpos4) self.ranklists(fighterKD5, KDpos5) self.ranklists(fighterKD6, KDpos6) self.ranklists(fighterKD7, KDpos7) self.ranklists(fighterKD8, KDpos8) self.ranklists(fighterKD9, KDpos9) self.ranklists(fighterKD10, KDpos10) self.ranklists(fighterKD11, KDpos11) self.ranklists(fighterKD12, KDpos12) self.ranklists(fighterKD13, KDpos13) self.ranklists(fighterKD14, KDpos14) self.ranklists(fighterKD15, KDpos15) #call score list self.ranklists(scoreRank1, scorePos1) self.ranklists(scoreRank2, scorePos2) self.ranklists(scoreRank3, scorePos3) self.ranklists(scoreRank4, scorePos4) self.ranklists(scoreRank5, scorePos5) self.ranklists(scoreRank6, scorePos6) self.ranklists(scoreRank7, scorePos7) self.ranklists(scoreRank8, scorePos8) self.ranklists(scoreRank9, scorePos9) self.ranklists(scoreRank10, scorePos10) self.ranklists(scoreRank11, scorePos11) self.ranklists(scoreRank12, scorePos12) self.ranklists(scoreRank13, scorePos13) self.ranklists(scoreRank14, scorePos14) self.ranklists(scoreRank15, scorePos15) #call AVGscore List self.ranklists(AVGscore1, AVGpos1) self.ranklists(AVGscore2, AVGpos2) self.ranklists(AVGscore3, AVGpos3) self.ranklists(AVGscore4, AVGpos4) self.ranklists(AVGscore5, AVGpos5) self.ranklists(AVGscore6, AVGpos6) self.ranklists(AVGscore7, AVGpos7) self.ranklists(AVGscore8, AVGpos8) self.ranklists(AVGscore9, AVGpos9) self.ranklists(AVGscore10, AVGpos10) self.ranklists(AVGscore11, AVGpos11) self.ranklists(AVGscore12, AVGpos12) self.ranklists(AVGscore13, AVGpos13) self.ranklists(AVGscore14, AVGpos14) self.ranklists(AVGscore15, AVGpos15) #dönenler self.starlogo = bs.newNode( 'image', delegate=self, attrs={ 'texture': bs.getTexture( 'achievementOutline'), ##storeCharacter frameInset logo 'position': (470, 280), #(300,90) 'scale': (100, 100), 'tiltTranslate': 0, 'hasAlphaChannel': True, 'opacity': 1.0, 'color': (1, 1, 0) }) bsUtils.animate(self.starlogo, 'rotate', { 0: 0.0, 350: 360.0 }, loop=True) #dönenler self.starlogo2 = bs.newNode('image', delegate=self, attrs={ 'texture': bs.getTexture('achievementOutline'), 'position': (-470, 280), 'scale': (100, 100), 'tiltTranslate': 0, 'hasAlphaChannel': True, 'opacity': 1.0, 'color': (1, 1, 0) }) bsUtils.animate(self.starlogo2, 'rotate', { 0: 0.0, 350: -360.0 }, loop=True) #speed image imageTextSpeed = bs.getTexture('powerupSpeed') imagePosSpeed = (-560, 145) imageColorSpeed = (1, 1, 1) imageAlphaSpeed = True self.powerUpImage(imageTextSpeed, imagePosSpeed, imageColorSpeed, imageAlphaSpeed) #superStar image imageTextSuperStar = bs.getTexture('levelIcon') imagePosSuperStar = (-560, 45) imageColorSuperStar = (1, 1, 1) imageAlphaSuperStar = True self.powerUpImage(imageTextSuperStar, imagePosSuperStar, imageColorSuperStar, imageAlphaSuperStar) #iceCube image imageTextIceCube = bs.getTexture('softRect') imagePosIceCube = (-560, -50) imageColorIceCube = (0.9, 0.9, 1) imageAlphaIceCube = True self.powerUpImage(imageTextIceCube, imagePosIceCube, imageColorIceCube, imageAlphaIceCube) #surprise image imageTextSurprise = bs.getTexture('powerupHealth') imagePosSurprise = (-560, -150) imageColorSurprise = (1, 1, 1) imageAlphaSurprise = True self.powerUpImage(imageTextSurprise, imagePosSurprise, imageColorSurprise, imageAlphaSurprise) #martyrdom image imageTextMarty = bs.getTexture('achievementCrossHair') imagePosMarty = (-560, -255) imageColorMarty = (1, 1, 1) imageAlphaMarty = True self.powerUpImage(imageTextMarty, imagePosMarty, imageColorMarty, imageAlphaMarty) #custom Powerups #bsUtils.animate(self.customPowerUps, 'scale', {0: 1,120: 1,120: 1,120: 0.99},loop=True) textPowerUp = ScreenLanguage.customLang posPowerUp = (-560, 210) scalePowerUp = 1.0 colorPowerUp = (1.0, 0.6, 0.8, 1) maxWidthPowerUp = 180 self.powerUpText(textPowerUp, posPowerUp, scalePowerUp, colorPowerUp, maxWidthPowerUp) #info for players textTyFor = ScreenLanguage.infoLang posTyFor = (0, -320) scaleTyFor = 1.0 colorTyFor = (1.0, 0.6, 0.8, 1) maxWidthTyFor = 300 self.powerUpText(textTyFor, posTyFor, scaleTyFor, colorTyFor, maxWidthTyFor) #speed textSpeedInfo = ScreenLanguage.speedInfoLang posSpeedInfo = (-500, 135) scaleSpeedInfo = 0.8 colorSpeedInfo = (0.9, 0.9, 0.9, 1) maxWidthSpeedInfo = 250 textSpeed = ScreenLanguage.speedTextLang posSpeed = (-500, 170) scaleSpeed = 0.7 colorSpeed = (0.9, 0.8, 1, 1) maxWidthSpeed = 180 self.powerUpText(textSpeed, posSpeed, scaleSpeed, colorSpeed, maxWidthSpeed) self.powerUpText(textSpeedInfo, posSpeedInfo, scaleSpeedInfo, colorSpeedInfo, maxWidthSpeedInfo) #superStar textSuperStarInfo = ScreenLanguage.superStarInfoLang posSuperStarInfo = (-500, 35) scaleSuperStarInfo = 0.8 colorSuperStarInfo = (0.9, 0.9, 0.9, 1) maxWidthSuperStarInfo = 250 textSuperStar = ScreenLanguage.superStarTextLang posSuperStar = (-500, 70) scaleSuperStar = 0.7 colorSuperStar = (0.9, 0.8, 1, 1) maxWidthSuperStar = 180 self.powerUpText(textSuperStar, posSuperStar, scaleSuperStar, colorSuperStar, maxWidthSuperStar) self.powerUpText(textSuperStarInfo, posSuperStarInfo, scaleSuperStarInfo, colorSuperStarInfo, maxWidthSuperStarInfo) #iceCube textIceCubeInfo = ScreenLanguage.iceCubeInfoLang posIceCubeInfo = (-500, -63) scaleIceCubeInfo = 0.8 colorIceCubeInfo = (0.9, 0.9, 0.9, 1) maxWidthIceCubeInfo = 250 textIceCube = ScreenLanguage.iceCubeTextLang posIceCube = (-500, -23) scaleIceCube = 0.7 colorIceCube = (0.9, 0.8, 1, 1) maxWidthIceCube = 180 self.powerUpText(textIceCube, posIceCube, scaleIceCube, colorIceCube, maxWidthIceCube) self.powerUpText(textIceCubeInfo, posIceCubeInfo, scaleIceCubeInfo, colorIceCubeInfo, maxWidthIceCubeInfo) #surprise textSurpriseInfo = ScreenLanguage.surpriseInfoLang posSurpriseInfo = (-500, -165) scaleSurpriseInfo = 0.75 colorSurpriseInfo = (0.9, 0.9, 0.9, 1) maxWidthSurpriseInfo = 250 textSurprise = ScreenLanguage.surpriseTextLang posSurprise = (-500, -115) scaleSurprise = 0.7 colorSurprise = (0.9, 0.8, 1, 1) maxWidthSurprise = 180 self.powerUpText(textSurprise, posSurprise, scaleSurprise, colorSurprise, maxWidthSurprise) self.powerUpText(textSurpriseInfo, posSurpriseInfo, scaleSurpriseInfo, colorSurpriseInfo, maxWidthSurpriseInfo) #martyrdom textMartyInfo = ScreenLanguage.martyInfoLang posMartyInfo = (-500, -270) scaleMartyInfo = 0.75 colorMartyInfo = (0.9, 0.9, 0.9, 1) maxWidthMartyInfo = 250 textMarty = ScreenLanguage.martyTextLang posMarty = (-500, -220) scaleMarty = 0.7 colorMarty = (0.9, 0.8, 1, 1) maxWidthMarty = 180 self.powerUpText(textMarty, posMarty, scaleMarty, colorMarty, maxWidthMarty) self.powerUpText(textMartyInfo, posMartyInfo, scaleMartyInfo, colorMartyInfo, maxWidthMartyInfo) self._sound = bs.newNode('sound', attrs={ 'sound': bs.getSound('victoryMusic'), 'volume': 1.0 }) self._endGameTimer = bs.Timer(20000, bs.WeakCall(self.endGame)) #bsUtils.ZoomText('MYTHB', lifespan=22000, jitter=2.0, #position=(100,120), scale=0.6, maxWidth=800, #trail=True, color=(0.5,0.5,1)).autoRetain() bsUtils.ZoomText(ScreenLanguage.welcomeTextLang, lifespan=999000, jitter=2.0, position=(0, 270), scale=1.1, maxWidth=800, trail=False, color=(0.6, 0.6, 1)).autoRetain()
def __init__(self, position=(0,1,0), velocity=(0,0,0), bombType='normal', blastRadius=1.8, sourcePlayer=None, owner=None): """ Create a new Bomb. bombType can be 'ice','impact','landMine','normal','sticky', or 'tnt'. Note that for impact or landMine bombs you have to call arm() before they will go off. """ bs.Actor.__init__(self) factory = self.getFactory() if not bombType in ('ice','impact','landMine','normal','sticky','tnt', 'atom'): raise Exception("invalid bomb type: " + bombType) self.bombType = bombType self._exploded = False if self.bombType == 'sticky': self._lastStickySoundTime = 0 self.blastRadius = blastRadius if self.bombType == 'ice': self.blastRadius *= 1.0 elif self.bombType == 'impact': self.blastRadius *= 1.2 elif self.bombType == 'landMine': self.blastRadius *= 0.7 elif self.bombType == 'tnt': self.blastRadius *= 1.75 elif self.bombType == 'atom' : self.blastRadius *= 3.0 self._explodeCallbacks = [] # the player this came from self.sourcePlayer = sourcePlayer # by default our hit type/subtype is our own, but we pick up types of whoever # sets us off so we know what caused a chain reaction self.hitType = 'explosion' self.hitSubType = self.bombType # if no owner was provided, use an unconnected node ref if owner is None: owner = bs.Node(None) # the node this came from self.owner = owner # adding footing-materials to things can screw up jumping and flying since players carrying those things # and thus touching footing objects will think they're on solid ground.. # perhaps we don't wanna add this even in the tnt case?.. if self.bombType == 'tnt': materials = (factory.bombMaterial, bs.getSharedObject('footingMaterial'), bs.getSharedObject('objectMaterial')) else: materials = (factory.bombMaterial, bs.getSharedObject('objectMaterial')) if self.bombType == 'impact': materials = materials + (factory.impactBlastMaterial,) elif self.bombType == 'landMine': materials = materials + (factory.landMineNoExplodeMaterial,) if self.bombType == 'sticky': materials = materials + (factory.stickyMaterial,) else: materials = materials + (factory.normalSoundMaterial,) if self.bombType == 'landMine': self.node = bs.newNode('prop', delegate=self, attrs={'position':position, 'velocity':velocity, 'model':factory.landMineModel, 'lightModel':factory.landMineModel, 'body':'landMine', 'shadowSize':0.44, 'colorTexture':factory.landMineTex, 'reflection':'powerup', 'reflectionScale':[1.0], 'materials':materials}) elif self.bombType == 'tnt': self.node = bs.newNode('prop', delegate=self, attrs={'position':position, 'velocity':velocity, 'model':factory.tntModel, 'lightModel':factory.tntModel, 'body':'crate', 'shadowSize':0.5, 'colorTexture':factory.tntTex, 'reflection':'soft', 'reflectionScale':[0.23], 'materials':materials}) elif self.bombType == 'impact': fuseTime = 20000 self.node = bs.newNode('prop', delegate=self, attrs={'position':position, 'velocity':velocity, 'body':'sphere', 'model':factory.impactBombModel, 'shadowSize':0.3, 'colorTexture':factory.impactTex, 'reflection':'powerup', 'reflectionScale':[1.5], 'materials':materials}) self.armTimer = bs.Timer(200,bs.WeakCall(self.handleMessage, ArmMessage())) self.warnTimer = bs.Timer(fuseTime-1700,bs.WeakCall(self.handleMessage, WarnMessage())) elif self.bombType == 'atom': fuseTime = 20000 self.node = bs.newNode('prop', delegate=self, attrs={'position':position, 'velocity':velocity, 'body':'sphere', 'model':factory.impactBombModel, 'shadowSize':1.0, 'colorTexture':factory.atomTex, 'reflection':'powerup', 'reflectionScale':[2.5], 'materials':materials}) self.armTimer = bs.Timer(200,bs.WeakCall(self.handleMessage, ArmMessage())) self.warnTimer = bs.Timer(fuseTime-1700,bs.WeakCall(self.handleMessage, WarnMessage())) else: fuseTime = 3000 if self.bombType == 'sticky': sticky = True model = factory.stickyBombModel rType = 'sharper' rScale = 1.8 else: sticky = False model = factory.bombModel rType = 'sharper' rScale = 1.8 if self.bombType == 'ice': tex = factory.iceTex elif self.bombType == 'sticky': tex = factory.stickyTex else: tex = factory.regularTex self.node = bs.newNode('bomb', delegate=self, attrs={'position':position, 'velocity':velocity, 'model':model, 'shadowSize':0.3, 'colorTexture':tex, 'sticky':sticky, 'owner':owner, 'reflection':rType, 'reflectionScale':[rScale], 'materials':materials}) sound = bs.newNode('sound',owner=self.node,attrs={'sound':factory.fuseSound,'volume':0.25}) self.node.connectAttr('position',sound,'position') bsUtils.animate(self.node,'fuseLength',{0:1,fuseTime:0}) # light the fuse!!! if self.bombType not in ('landMine','tnt'): bs.gameTimer(fuseTime,bs.WeakCall(self.handleMessage, ExplodeMessage())) bsUtils.animate(self.node,"modelScale",{0:0, 200:1.3, 260:1})
def _makeWord(self, word, x, y, scale=1.0, delay=0, vrDepthOffset=0, shadow=True): wordShadowObj = bs.NodeActor( bs.newNode( 'text', attrs={ 'position': (x, y), 'big': True, 'color': (0.95, 1.55, 0.6 + random.random() / 2 if random.random() > 0.6 else 0.6, 0.65), 'tiltTranslate': 0.11, 'tiltTranslate': 0.09, 'opacityScalesShadow': False, 'shadow': 0.01, 'vrDepth': -130, 'vAlign': 'center', 'projectScale': 0.97 * scale, 'scale': 1.0, 'text': word })) self._wordActors.append(wordShadowObj) if not bs.getEnvironment()['vrMode']: if not shadow: c = bs.newNode("combine", owner=wordObj.node, attrs={'size': 2}) else: c = None if shadow: c2 = bs.newNode("combine", owner=wordShadowObj.node, attrs={'size': 2}) else: c2 = None if not shadow: c.connectAttr('output', wordObj.node, 'position') if shadow: c2.connectAttr('output', wordShadowObj.node, 'position') keys = {} keys2 = {} timeV = 0 for i in range(10): val = x + random.uniform(0, 1) val2 = x + random.uniform(-1, 0) keys[timeV * self._ts] = val keys2[timeV * self._ts] = val2 timeV += 720 if c is not None: bs.animate(c, "input0", keys, loop=True) if c2 is not None: bs.animate(c2, "input0", keys2, loop=True) keys = {} keys2 = {} timeV = 0 for i in range(10): val = y + random.uniform(0, 1) val2 = y + random.uniform(-1, 0) keys[timeV * self._ts] = val keys2[timeV * self._ts] = val2 timeV += 1000 if c is not None: bs.animate(c, "input1", keys, loop=True) if c2 is not None: bs.animate(c2, "input1", keys2, loop=True) if not shadow: bs.animate(wordObj.node, "projectScale", { delay: scale * 0, delay + 210: scale }) else: bs.animate(wordShadowObj.node, "projectScale", { delay: scale * 0, delay + 210: scale })
def onTransitionIn(self): bs.Activity.onTransitionIn(self) global gDidInitialTransition random.seed(123) try: import install except ImportError: pass else: # check needed methods if hasattr(bs, "get_setting") and hasattr(install, "update_modpack"): if bs.get_setting("auto-update", False): install.update_modpack(True) self._logoNode = None self._customLogoTexName = None self._wordActors = [] env = bs.getEnvironment() vrMode = bs.getEnvironment()['vrMode'] if not bs.getEnvironment().get('toolbarTest', True): self.myName = bs.NodeActor( bs.newNode( 'text', attrs={ 'vAttach': 'bottom', 'hAlign': 'center', 'color': (1, 1, 1, 1) if vrMode else (1, 1, 1, 1), 'flatness': 1.0, 'shadow': 1.0 if vrMode else 0.5, 'scale': (0.65 if (env['interfaceType'] == 'small' or vrMode) else 0.7), # FIXME need a node attr for this 'position': (0, 25), 'vrDepth': -10, 'text': u'\xa9 2019 Eric Froemling' })) fullScreen = bsInternal._getSetting("TV Border") if env['interfaceType'] != 'small' or env['vrMode']: if fullScreen: position = (0, -10) else: position = (-425, 10) else: if fullScreen: position = (0, -10) else: position = (-425, 35) self.moderName = bs.NodeActor( bs.newNode( 'text', attrs={ 'vAttach': 'bottom', 'hAlign': 'center', 'color': (0.8, 0.8, 0.8, 0.8) if vrMode else (0.8, 0.8, 0.8, 0.8), 'flatness': 1.0, 'shadow': 1.0 if vrMode else 0.5, 'scale': (0.55 if (env['interfaceType'] == 'small' or vrMode) else 0.7), # FIXME need a node attr for this 'position': position, 'vrDepth': -10, 'text': u'\xa9 ModPack is created by Daniil Rakhov' })) self._hostIsNavigatingText = bs.NodeActor( bs.newNode('text', attrs={ 'text': bs.Lstr(resource='hostIsNavigatingMenusText', subs=[ ('${HOST}', bsInternal._getAccountDisplayString()) ]), 'clientOnly': True, 'position': (0, -200), 'flatness': 1.0, 'hAlign': 'center' })) if not gDidInitialTransition: if hasattr(self, 'myName'): bs.animate(self.myName.node, 'opacity', {2300: 0, 3000: 1.0}) if hasattr(self, 'moderName'): bs.animate(self.moderName.node, 'opacity', { 2300: 0, 3300: 1.0 }) # FIXME - shouldn't be doing things conditionally based on whether # the host is vr mode or not (clients may not be or vice versa) # - any differences need to happen at the engine level # so everyone sees things in their own optimal way vrMode = env['vrMode'] interfaceType = env['interfaceType'] # in cases where we're doing lots of dev work lets # always show the build number forceShowBuildNumber = True if not bs.getEnvironment().get('toolbarTest', True): text = "BROODYs WORLD" try: from multiversion import get_version except ImportError: path = os.path.join(env["userScriptsDirectory"], "about_modpack.json") if os.path.exists(path): try: data = json.load(open(path)) except Exception: pass else: text += " v." + str( data.get("version", { "v": "???" }).get("v")) else: text += " v." + str(get_version()) if env['debugBuild'] or env['testBuild']: if env['debugBuild']: text += " [debug]" else: text += " [test]" if forceShowBuildNumber: text = "based on " + str(env['version']) + "\n" + text self.version = bs.NodeActor( bs.newNode('text', attrs={ 'vAttach': 'bottom', 'hAttach': 'right', 'hAlign': 'right', 'flatness': 1.0, 'vrDepth': -10, 'shadow': 0.5, 'color': (0.5, 0.6, 0.5, 0.7), 'scale': 0.7 if (interfaceType == 'small' or vrMode) else 0.85, 'position': (-260, 10) if vrMode else (-10, 30), 'text': text })) if not gDidInitialTransition: bs.animate(self.version.node, 'opacity', { 0: 0, 3000: 0, 4000: 1.0 }) # throw in beta info.. self.betaInfo = self.betaInfo2 = None if env['testBuild'] and not env['kioskMode']: self.betaInfo = bs.NodeActor( bs.newNode('text', attrs={ 'vAttach': 'center', 'hAlign': 'center', 'color': (1, 1, 1, 1), 'shadow': 0.5, 'flatness': 0.5, 'scale': 1, 'vrDepth': -60, 'position': (230, 125) if env['kioskMode'] else (230, 35), 'text': bs.Lstr(resource="testBuildText") })) if not gDidInitialTransition: bs.animate(self.betaInfo.node, 'opacity', {1300: 0, 1800: 1.0}) model = bs.getModel('thePadLevel') treesModel = bs.getModel('trees') bottomModel = bs.getModel('thePadLevelBottom') borModel = bs.getCollideModel('thePadLevelCollide') testColorTexture = bs.getTexture('thePadLevelColor') treesTexture = bs.getTexture('treesColor') bgTex = bs.getTexture('alwaysLandBGColor') bgModel = bs.getModel('alwaysLandBG') vrBottomFillModel = bs.getModel('thePadVRFillBottom') vrTopFillModel = bs.getModel('thePadVRFillTop') bsGlobals = bs.getSharedObject('globals') bsGlobals.cameraMode = 'rotate' bsGlobals.tint = (1.1, 1.1, 1.0) self.bottom = bs.NodeActor( bs.newNode('terrain', attrs={ 'model': bottomModel, 'lighting': False, 'reflection': 'soft', 'reflectionScale': [0.45], 'colorTexture': testColorTexture })) self.node = bs.newNode('terrain', delegate=self, attrs={ 'collideModel': borModel, 'model': model, 'colorTexture': testColorTexture, 'materials': [bs.getSharedObject('footingMaterial')] }) self.vrBottomFill = bs.NodeActor( bs.newNode('terrain', attrs={ 'model': vrBottomFillModel, 'lighting': False, 'vrOnly': True, 'colorTexture': testColorTexture })) self.vrTopFill = bs.NodeActor( bs.newNode('terrain', attrs={ 'model': vrTopFillModel, 'vrOnly': True, 'lighting': False, 'colorTexture': bgTex })) self.terrain = bs.NodeActor( bs.newNode('terrain', attrs={ 'model': model, 'colorTexture': testColorTexture, 'reflection': 'soft', 'reflectionScale': [0.3] })) self.trees = bs.NodeActor( bs.newNode('terrain', attrs={ 'model': treesModel, 'lighting': False, 'reflection': 'char', 'reflectionScale': [0.1], 'colorTexture': treesTexture })) self.bg = bs.NodeActor( bs.newNode('terrain', attrs={ 'model': bgModel, 'color': (0.92, 0.91, 0.9), 'lighting': False, 'background': True, 'colorTexture': bgTex })) textOffsetV = 0 self._ts = 0.86 self._language = None self._updateTimer = bs.Timer(2000, bs.Call(self._update, False), repeat=True) self._update(True) bs.gameTimer(55000, bs.Call(self.fireworks)) bsUtils.animateArray(bs.getSharedObject("globals"), "tint", 3, {0:(1.1,1.1,1.0), 7500:(1.25, 1.21, 1.075), 30000:(1.25, 1.21, 1.075), \ 57500:(1.1, 0.86, 0.74), 67500:(1.1, 0.86, 0.74), \ 90000:(0, 0.27, 0.51), 120000:(0, 0.27, 0.51), 142500:(1.3, 1.06, 1.02), \ 157500:(1.3, 1.06, 1.02), 180000:(1.3, 1.25, 1.2), 195500:(1.3, 1.25, 1.2), \ 220000:(1.1,1.1,1.0)}) bsInternal._addCleanFrameCallback(bs.WeakCall(self._startPreloads)) random.seed() class News(object): def __init__(self, activity): self._valid = True self._messageDuration = 10000 self._messageSpacing = 2000 self._text = None self._activity = weakref.ref(activity) self._fetchTimer = bs.Timer(1000, bs.WeakCall(self._tryFetchingNews), repeat=True) self._tryFetchingNews() def _tryFetchingNews(self): if bsInternal._getAccountState() == 'SIGNED_IN': self._fetchNews() self._fetchTimer = None def _fetchNews(self): try: launchCount = bs.getConfig()['launchCount'] except Exception: launchCount = None global gLastNewsFetchTime gLastNewsFetchTime = time.time() # UPDATE - we now just pull news from MRVs news = bsInternal._getAccountMiscReadVal('n', None) if news is not None: self._gotNews(news) def _changePhrase(self): global gLastNewsFetchTime if time.time() - gLastNewsFetchTime > 100.0: self._fetchNews() self._text = None else: if self._text is not None: if len(self._phrases) == 0: for p in self._usedPhrases: self._phrases.insert(0, p) val = self._phrases.pop() if val == '__ACH__': vr = bs.getEnvironment()['vrMode'] bsUtils.Text( bs.Lstr(resource='nextAchievementsText'), color=(1,1,1,1) if vr else (0.95,0.9,1,0.4), hostOnly=True, maxWidth=200, position=(-300, -35), hAlign='right', transition='fadeIn', scale=0.9 if vr else 0.7, flatness=1.0 if vr else 0.6, shadow=1.0 if vr else 0.5, hAttach="center", vAttach="top", transitionDelay=1000, transitionOutDelay=self._messageDuration)\ .autoRetain() import bsAchievement achs = [ a for a in bsAchievement.gAchievements if not a.isComplete() ] if len(achs) > 0: a = achs.pop( random.randrange(min(4, len(achs)))) a.createDisplay(-180, -35, 1000, outDelay=self._messageDuration, style='news') if len(achs) > 0: a = achs.pop( random.randrange(min(8, len(achs)))) a.createDisplay(180, -35, 1250, outDelay=self._messageDuration, style='news') else: s = self._messageSpacing keys = { s: 0, s + 1000: 1.0, s + self._messageDuration - 1000: 1.0, s + self._messageDuration: 0.0 } bs.animate(self._text.node, "opacity", dict([[k, v] for k, v in keys.items()])) self._text.node.text = val def _gotNews(self, news): # run this stuff in the context of our activity since we need # to make nodes and stuff.. should fix the serverGet call so it activity = self._activity() if activity is None or activity.isFinalized(): return with bs.Context(activity): self._phrases = [] # show upcoming achievements in non-vr versions # (currently too hard to read in vr) self._usedPhrases = ( ['__ACH__'] if not bs.getEnvironment()['vrMode'] else []) + [s for s in news.split('<br>\n') if s != ''] self._phraseChangeTimer = bs.Timer( self._messageDuration + self._messageSpacing, bs.WeakCall(self._changePhrase), repeat=True) sc = 1.2 if ( bs.getEnvironment()['interfaceType'] == 'small' or bs.getEnvironment()['vrMode']) else 0.8 self._text = bs.NodeActor( bs.newNode( 'text', attrs={ 'vAttach': 'top', 'hAttach': 'center', 'hAlign': 'center', 'vrDepth': -20, 'shadow': 1.0 if bs.getEnvironment()['vrMode'] else 0.4, 'flatness': 0.8, 'vAlign': 'top', 'color': ((1, 1, 1, 1) if bs.getEnvironment()['vrMode'] else (0.7, 0.65, 0.75, 1.0)), 'scale': sc, 'maxWidth': 900.0 / sc, 'position': (0, -10) })) self._changePhrase() if not env['kioskMode'] and not env.get('toolbarTest', True): self._news = News(self) # bring up the last place we were, or start at the main menu otherwise with bs.Context('UI'): try: mainWindow = bsUI.gMainWindow except Exception: mainWindow = None # when coming back from a kiosk-mode game, jump to # the kiosk start screen.. if bsUtils.gRunningKioskModeGame: if bs.getEnvironment()['kioskMode']: bsUI.uiGlobals['mainMenuWindow'] = \ bsUI.KioskWindow().getRootWidget() # ..or in normal cases go back to the main menu else: if mainWindow == 'Gather': bsUI.uiGlobals['mainMenuWindow'] = \ bsUI.GatherWindow(transition=None).getRootWidget() elif mainWindow == 'Watch': bsUI.uiGlobals['mainMenuWindow'] = \ bsUI.WatchWindow(transition=None).getRootWidget() elif mainWindow == 'Team Game Select': bsUI.uiGlobals['mainMenuWindow'] = \ bsUI.TeamsWindow(sessionType=bs.TeamsSession, transition=None).getRootWidget() elif mainWindow == 'Free-for-All Game Select': bsUI.uiGlobals['mainMenuWindow'] = \ bsUI.TeamsWindow(sessionType=bs.FreeForAllSession, transition=None).getRootWidget() elif mainWindow == 'Coop Select': bsUI.uiGlobals['mainMenuWindow'] = \ bsUI.CoopWindow(transition=None).getRootWidget() else: bsUI.uiGlobals['mainMenuWindow'] = \ bsUI.MainMenuWindow(transition=None).getRootWidget() # attempt to show any pending offers immediately. # If that doesn't work, try again in a few seconds # (we may not have heard back from the server) # ..if that doesn't work they'll just have to wait # until the next opportunity. if not bsUI._showOffer(): def tryAgain(): if not bsUI._showOffer(): # try one last time.. bs.realTimer(2000, bsUI._showOffer) bs.realTimer(2000, tryAgain) gDidInitialTransition = True
def showCompletionBanner(self, sound=True): global gLastAchievementDisplayTime gLastAchievementDisplayTime = bs.getRealTime() # just piggy-back onto any current activity... # (should we use the session instead?..) activity = bs.getActivity(exceptionOnNone=False) # if this gets called while this achievement is occupying a slot already, ignore it.. # (probably should never happen in real life but whatevs..) if self._completionBannerSlot is not None: return if activity is None: print 'showCompletionBanner() called with no current activity!' return if sound: bs.playSound(bs.getSound('achievement'), hostOnly=True) else: bs.gameTimer( 500, bs.Call(bs.playSound, bs.getSound('ding'), hostOnly=True)) yOffs = 0 inTime = 300 outTime = 3500 baseVRDepth = 200 # find the first free slot i = 0 while True: if not i in gCompletionBannerSlots: #print 'ADDING SLOT',i,'FOR',self gCompletionBannerSlots.add(i) self._completionBannerSlot = i # remove us from that slot when we close.. # use a real-timer in the UI context so the removal runs even if our activity/session dies with bs.Context('UI'): bs.realTimer(inTime + outTime, self._removeBannerSlot) break i += 1 yOffs = 110 * self._completionBannerSlot objs = [] obj = bsUtils.Image(bs.getTexture('shadow'), position=(-30, 30 + yOffs), front=True, attach='bottomCenter', transition='inBottom', vrDepth=baseVRDepth - 100, transitionDelay=inTime, transitionOutDelay=outTime, color=(0.0, 0.1, 0, 1), scale=(1000, 300)).autoRetain() objs.append(obj) obj.node.hostOnly = True obj = bsUtils.Image(bs.getTexture('light'), position=(-180, 60 + yOffs), front=True, attach='bottomCenter', vrDepth=baseVRDepth, transition='inBottom', transitionDelay=inTime, transitionOutDelay=outTime, color=(1.8, 1.8, 1.0, 0.0), scale=(40, 300)).autoRetain() objs.append(obj) obj.node.hostOnly = True obj.node.premultiplied = True c = bs.newNode('combine', owner=obj.node, attrs={'size': 2}) bsUtils.animate( c, 'input0', { inTime: 0, inTime + 400: 30, inTime + 500: 40, inTime + 600: 30, inTime + 2000: 0 }) bsUtils.animate( c, 'input1', { inTime: 0, inTime + 400: 200, inTime + 500: 500, inTime + 600: 200, inTime + 2000: 0 }) c.connectAttr('output', obj.node, 'scale') bsUtils.animate(obj.node, 'rotate', {0: 0.0, 350: 360.0}, loop=True) obj = bsUtils.Image(self.getIconTexture(True), position=(-180, 60 + yOffs), attach='bottomCenter', front=True, vrDepth=baseVRDepth - 10, transition='inBottom', transitionDelay=inTime, transitionOutDelay=outTime, scale=(100, 100)).autoRetain() objs.append(obj) obj.node.hostOnly = True # flash color = self.getIconColor(True) c = bs.newNode('combine', owner=obj.node, attrs={'size': 3}) keys = { inTime: 1.0 * color[0], inTime + 400: 1.5 * color[0], inTime + 500: 6.0 * color[0], inTime + 600: 1.5 * color[0], inTime + 2000: 1.0 * color[0] } bsUtils.animate(c, 'input0', keys) keys = { inTime: 1.0 * color[1], inTime + 400: 1.5 * color[1], inTime + 500: 6.0 * color[1], inTime + 600: 1.5 * color[1], inTime + 2000: 1.0 * color[1] } bsUtils.animate(c, 'input1', keys) keys = { inTime: 1.0 * color[2], inTime + 400: 1.5 * color[2], inTime + 500: 6.0 * color[2], inTime + 600: 1.5 * color[2], inTime + 2000: 1.0 * color[2] } bsUtils.animate(c, 'input2', keys) c.connectAttr('output', obj.node, 'color') obj = bsUtils.Image(bs.getTexture('achievementOutline'), modelTransparent=bs.getModel('achievementOutline'), position=(-180, 60 + yOffs), front=True, attach='bottomCenter', vrDepth=baseVRDepth, transition='inBottom', transitionDelay=inTime, transitionOutDelay=outTime, scale=(100, 100)).autoRetain() obj.node.hostOnly = True # flash color = (2, 1.4, 0.4, 1) c = bs.newNode('combine', owner=obj.node, attrs={'size': 3}) keys = { inTime: 1.0 * color[0], inTime + 400: 1.5 * color[0], inTime + 500: 6.0 * color[0], inTime + 600: 1.5 * color[0], inTime + 2000: 1.0 * color[0] } bsUtils.animate(c, 'input0', keys) keys = { inTime: 1.0 * color[1], inTime + 400: 1.5 * color[1], inTime + 500: 6.0 * color[1], inTime + 600: 1.5 * color[1], inTime + 2000: 1.0 * color[1] } bsUtils.animate(c, 'input1', keys) keys = { inTime: 1.0 * color[2], inTime + 400: 1.5 * color[2], inTime + 500: 6.0 * color[2], inTime + 600: 1.5 * color[2], inTime + 2000: 1.0 * color[2] } bsUtils.animate(c, 'input2', keys) c.connectAttr('output', obj.node, 'color') objs.append(obj) obj = bsUtils.Text(bs.Lstr(value='${A}:', subs=[('${A}', bs.Lstr(resource='achievementText')) ]), position=(-120, 91 + yOffs), front=True, vAttach='bottom', vrDepth=baseVRDepth - 10, transition='inBottom', flatness=0.5, transitionDelay=inTime, transitionOutDelay=outTime, color=(1, 1, 1, 0.8), scale=0.65).autoRetain() objs.append(obj) obj.node.hostOnly = True obj = bsUtils.Text(self.getDisplayString(), position=(-120, 50 + yOffs), front=True, vAttach='bottom', transition='inBottom', vrDepth=baseVRDepth, flatness=0.5, transitionDelay=inTime, transitionOutDelay=outTime, flash=True, color=(1, 0.8, 0, 1.0), scale=1.5).autoRetain() objs.append(obj) obj.node.hostOnly = True obj = bsUtils.Text(bs.getSpecialChar('ticket'), position=(-120 - 170 + 5, 75 + yOffs - 20), front=True, vAttach='bottom', hAlign='center', vAlign='center', transition='inBottom', vrDepth=baseVRDepth, transitionDelay=inTime, transitionOutDelay=outTime, flash=True, color=(0.5, 0.5, 0.5, 1), scale=3.0).autoRetain() objs.append(obj) obj.node.hostOnly = True obj = bsUtils.Text('+' + str(self.getAwardTicketValue()), position=(-120 - 180 + 5, 80 + yOffs - 20), vAttach='bottom', front=True, hAlign='center', vAlign='center', transition='inBottom', vrDepth=baseVRDepth, flatness=0.5, shadow=1.0, transitionDelay=inTime, transitionOutDelay=outTime, flash=True, color=(0, 1, 0, 1), scale=1.5).autoRetain() objs.append(obj) obj.node.hostOnly = True # add the 'x 2' if we've got pro if bsUtils._havePro(): obj = bsUtils.Text('x 2', position=(-120 - 180 + 45, 80 + yOffs - 50), vAttach='bottom', front=True, hAlign='center', vAlign='center', transition='inBottom', vrDepth=baseVRDepth, flatness=0.5, shadow=1.0, transitionDelay=inTime, transitionOutDelay=outTime, flash=True, color=(0.4, 0, 1, 1), scale=0.9).autoRetain() objs.append(obj) obj.node.hostOnly = True obj = bsUtils.Text( self.getDescriptionComplete(), # self.getDescriptionCompleteLocalized(), position=(-120, 30 + yOffs), front=True, vAttach='bottom', transition='inBottom', vrDepth=baseVRDepth - 10, flatness=0.5, transitionDelay=inTime, transitionOutDelay=outTime, color=(1.0, 0.7, 0.5, 1.0), scale=0.8).autoRetain() objs.append(obj) obj.node.hostOnly = True for obj in objs: bs.gameTimer(outTime + 1000, bs.WeakCall(obj.handleMessage, bs.DieMessage()))
def onBegin(self): bs.TeamGameActivity.onBegin(self) self.setupStandardTimeLimit(self.settings['Time Limit']) self.setupStandardPowerupDrops() self._teamFinishPts = 100 # throw a timer up on-screen 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.4, 'text': '' })) self._timer = bs.OnScreenTimer() if self.settings['Mine Spawning'] != 0: self._raceMines = [{ 'point': p, 'mine': None } for p in self.getMap().getDefPoints('raceMine')] if len(self._raceMines) > 0: self._raceMineTimer = bs.Timer(self.settings['Mine Spawning'], self._updateRaceMine, repeat=True) self._scoreBoardTimer = bs.Timer(250, self._updateScoreBoard, repeat=True) self._playerOrderUpdateTimer = bs.Timer(250, self._updatePlayerOrder, repeat=True) if self._isSlowMotion: tScale = 0.4 lightY = 50 else: tScale = 1.0 lightY = 150 lStart = int(7100 * tScale) inc = int(1250 * tScale) bs.gameTimer(lStart, self._doLight1) bs.gameTimer(lStart + inc, self._doLight2) bs.gameTimer(lStart + 2 * inc, self._doLight3) bs.gameTimer(lStart + 3 * inc, self._startRace) self._startLights = [] for i in range(4): l = bs.newNode('image', attrs={ 'texture': bs.getTexture('nub'), 'opacity': 1.0, 'absoluteScale': True, 'position': (-75 + i * 50, lightY), 'scale': (50, 50), 'attach': 'center' }) bs.animate( l, 'opacity', { 4000 * tScale: 0, 5000 * tScale: 1.0, 12000 * tScale: 1.0, 12500 * tScale: 0.0 }) bs.gameTimer(int(13000 * tScale), l.delete) self._startLights.append(l) self._startLights[0].color = (0.2, 0, 0) self._startLights[1].color = (0.2, 0, 0) self._startLights[2].color = (0.2, 0.05, 0) self._startLights[3].color = (0.0, 0.3, 0) self._organizer()
def stats_shower(): global num global scr p_list = [] n_list = [] s_list = [] s_itr = iter(s_list) for i in bsInternal._getForegroundHostSession().players: Name = i.getName() n_list.append(Name) pb_id = i.get_account_id() p_list.append(pb_id) f = open( bs.getEnvironment()['systemScriptsDirectory'] + "/pStats.json", "r") stats = json.loads(f.read()) for p in range(int(len(p_list))): if p_list[p] in stats: player_stat = stats[str(p_list[p])] s_msg = str(n_list[p].encode( "utf-8")) + "'s Stats This Season:\n" + "Rank " + str( player_stat["rank"]) + ", " + str( player_stat["scores"]) + " scores, " + str( player_stat["kills"]) + " kills, " + str( player_stat["deaths"]) + " deaths." s_list.append(s_msg) else: s_msg = str((n_list[p].encode("utf-8"))) + "Is not Registered" s_list.append(s_msg) t = bs.newNode('text', attrs={ 'text': s_list[num], 'scale': 1.0, 'maxWidth': 0, 'position': (250, 650), 'shadow': 0.5, 'flatness': 1.0, 'color': ((0 + random.random() * 1.0), (0 + random.random() * 1.0), (0 + random.random() * 1.0)), 'hAlign': 'center', 'vAttach': 'bottom' }) bs.animate(t, 'opacity', {0: 0.0, 500: 1.0, 6500: 1.0, 7000: 0.0}) bs.gameTimer(7000, t.delete) p = bs.newNode('text', attrs={ 'text': cmdsetg.credit, 'scale': 1.0, 'maxWidth': 0, 'position': (-100, 50), 'shadow': 0.5, 'flatness': 1.0, 'color': ((0 + random.random() * 1.0), (0 + random.random() * 1.0), (0 + random.random() * 1.0)), 'hAlign': 'center', 'vAttach': 'bottom' }) bs.animate(p, 'opacity', {0: 0.0, 500: 1.0, 6500: 1.0, 7000: 0.0}) bs.gameTimer(7000, p.delete) if num < len(s_list): num += 1 if num == len(s_list): num *= 0 if num > len(s_list): num *= 0
def __init__(self, lobby): canSwitchTeams = (len(lobby._teams) > 1) self._state = 0 pressToPunch = bs.getSpecialChar('leftButton') pressToPickup = bs.getSpecialChar('topButton') pressToBomb = bs.getSpecialChar('rightButton') # if we have a keyboard, grab keys for punch and pickup # FIXME - this of course is only correct locally; # will need to change this for net games kb = bsInternal._getInputDevice('Keyboard', '#1', exceptionOnNone=False) if kb is not None: punchKey = kb.getButtonName( bsUI.getControllerValue(kb, 'buttonPunch')) pressToPunch = bs.Lstr(resource='orText', subs=[('${A}', bs.Lstr(value='\'${K}\'', subs=[('${K}', punchKey) ])), ('${B}', pressToPunch)]) bombKey = kb.getButtonName( bsUI.getControllerValue(kb, 'buttonBomb')) pressToBomb = bs.Lstr(resource='orText', subs=[('${A}', bs.Lstr(value='\'${K}\'', subs=[('${K}', bombKey) ])), ('${B}', pressToBomb)]) joinStr = bs.Lstr( value='${A} < ${B} >', subs=[('${A}', bs.Lstr(resource='pressPunchToJoinText')), ('${B}', pressToPunch)]) else: joinStr = bs.Lstr(resource='pressAnyButtonToJoinText') self._text = bs.NodeActor( bs.newNode('text', attrs={ 'position': (0, -40), 'hAttach': 'center', 'vAttach': 'top', 'hAlign': 'center', 'color': gLobbyTextColor, 'flatness': 1.0 if bs.getEnvironment()['vrMode'] else 0.0, 'text': joinStr })) if bsUtils.gRunningKioskModeGame: self._messages = [joinStr] else: m1 = bs.Lstr(resource='pressToSelectProfileText', subs=[ ('${BUTTONS}', bs.getSpecialChar('upArrow') + ' ' + bs.getSpecialChar('downArrow')) ]) m2 = bs.Lstr(resource='pressToOverrideCharacterText', subs=[('${BUTTONS}', bs.Lstr(resource='bombBoldText'))]) m3 = bs.Lstr(value='${A} < ${B} >', subs=[('${A}', m2), ('${B}', pressToBomb)]) self._messages = (([ bs.Lstr(resource='pressToSelectTeamText', subs=[('${BUTTONS}', bs.getSpecialChar('leftArrow') + ' ' + bs.getSpecialChar('rightArrow'))]) ] if canSwitchTeams else []) + [m1] + [m3] + [joinStr]) self._timer = bs.Timer(4000, bs.WeakCall(self._update), repeat=True)
def __init__(self, position=(0, 1, 0), graphics=2, randomColor=True, mirror=False, form=0): bs.Actor.__init__(self) if form == 0: model = 'tnt' body = 'crate' elif form == 1: model = 'bomb' body = 'sphere' elif form == 2: model = random.choice(['tnt', 'bomb']) body = 'sphere' if model == 'bomb' else 'crate' self.node = bs.newNode( 'prop', delegate=self, attrs={ 'position': position, 'model': bs.getModel(model), 'body': body, 'bodyScale': 1.3, 'modelScale': 1.3, 'reflection': 'powerup', 'reflectionScale': [0.7], 'colorTexture': bs.getTexture("bunnyColor"), 'materials': [bs.getSharedObject('footingMaterial')] if mirror else [ bs.getSharedObject('objectMaterial'), bs.getSharedObject('footingMaterial') ] }) if graphics == 2: self.lightNode = bs.newNode( 'light', attrs={ 'position': (0, 0, 0), 'color': ((0.8, 0.2, 0.2) if i < count / 2 else (0.2, 0.2, 0.8)) if not randomColor else ((random.random(), random.random(), random.random())), 'radius': 0.2, 'intensity': 1, 'volumeIntensityScale': 10.0 }) self.node.connectAttr('position', self.lightNode, 'position')
def __init__(self,position=(0,1,0),velocity=(0,0,0),blastRadius=2.0,blastType="normal",sourcePlayer=None,hitType='explosion',hitSubType='normal'): """ Instantiate with given values. """ bs.Actor.__init__(self) factory = Bomb.getFactory() self.blastType = blastType self.sourcePlayer = sourcePlayer self.hitType = hitType; self.hitSubType = hitSubType; # blast radius self.radius = blastRadius self.node = bs.newNode('region', attrs={'position':(position[0],position[1]-0.1,position[2]), # move down a bit so we throw more stuff upward 'scale':(self.radius,self.radius,self.radius), 'type':'sphere', 'materials':(factory.blastMaterial,bs.getSharedObject('attackMaterial'))}, delegate=self) bs.gameTimer(50,self.node.delete) # throw in an explosion and flash explosion = bs.newNode("explosion", attrs={'position':position, 'velocity':(velocity[0],max(-1.0,velocity[1]),velocity[2]), 'radius':self.radius, 'big':(self.blastType == 'tnt')}) if self.blastType == "ice": explosion.color = (0,0.05,0.4) bs.gameTimer(1000,explosion.delete) if self.blastType != 'ice': bs.emitBGDynamics(position=position,velocity=velocity,count=int(1.0+random.random()*4),emitType='tendrils',tendrilType='thinSmoke') bs.emitBGDynamics(position=position,velocity=velocity,count=int(4.0+random.random()*4),emitType='tendrils',tendrilType='ice' if self.blastType == 'ice' else 'smoke') bs.emitBGDynamics(position=position,emitType='distortion',spread=1.0 if self.blastType == 'tnt' else 2.0) # and emit some shrapnel.. if self.blastType == 'ice': def _doEmit(): bs.emitBGDynamics(position=position,velocity=velocity,count=30,spread=2.0,scale=0.4,chunkType='ice',emitType='stickers'); bs.gameTimer(50,_doEmit) # looks better if we delay a bit elif self.blastType == 'sticky': def _doEmit(): bs.emitBGDynamics(position=position,velocity=velocity,count=int(4.0+random.random()*8),spread=0.7,chunkType='slime'); bs.emitBGDynamics(position=position,velocity=velocity,count=int(4.0+random.random()*8),scale=0.5, spread=0.7,chunkType='slime'); bs.emitBGDynamics(position=position,velocity=velocity,count=15,scale=0.6,chunkType='slime',emitType='stickers'); bs.emitBGDynamics(position=position,velocity=velocity,count=20,scale=0.7,chunkType='spark',emitType='stickers'); bs.emitBGDynamics(position=position,velocity=velocity,count=int(6.0+random.random()*12),scale=0.8,spread=1.5,chunkType='spark'); bs.gameTimer(50,_doEmit) # looks better if we delay a bit elif self.blastType == 'impact': # regular bomb shrapnel def _doEmit(): bs.emitBGDynamics(position=position,velocity=velocity,count=int(4.0+random.random()*8),scale=0.8,chunkType='metal'); bs.emitBGDynamics(position=position,velocity=velocity,count=int(4.0+random.random()*8),scale=0.4,chunkType='metal'); bs.emitBGDynamics(position=position,velocity=velocity,count=20,scale=0.7,chunkType='spark',emitType='stickers'); bs.emitBGDynamics(position=position,velocity=velocity,count=int(8.0+random.random()*15),scale=0.8,spread=1.5,chunkType='spark'); bs.gameTimer(50,_doEmit) # looks better if we delay a bit else: # regular or land mine bomb shrapnel def _doEmit(): if self.blastType != 'tnt': bs.emitBGDynamics(position=position,velocity=velocity,count=int(4.0+random.random()*8),chunkType='rock'); bs.emitBGDynamics(position=position,velocity=velocity,count=int(4.0+random.random()*8),scale=0.5,chunkType='rock'); bs.emitBGDynamics(position=position,velocity=velocity,count=30,scale=1.0 if self.blastType=='tnt' else 0.7,chunkType='spark',emitType='stickers'); bs.emitBGDynamics(position=position,velocity=velocity,count=int(18.0+random.random()*20),scale=1.0 if self.blastType == 'tnt' else 0.8,spread=1.5,chunkType='spark'); # tnt throws splintery chunks if self.blastType == 'tnt': def _emitSplinters(): bs.emitBGDynamics(position=position,velocity=velocity,count=int(20.0+random.random()*25),scale=0.8,spread=1.0,chunkType='splinter'); bs.gameTimer(10,_emitSplinters) # every now and then do a sparky one if self.blastType == 'tnt' or random.random() < 0.1: def _emitExtraSparks(): bs.emitBGDynamics(position=position,velocity=velocity,count=int(10.0+random.random()*20),scale=0.8,spread=1.5,chunkType='spark'); bs.gameTimer(20,_emitExtraSparks) bs.gameTimer(50,_doEmit) # looks better if we delay a bit light = bs.newNode('light', attrs={'position':position, 'color': (0.6,0.6,1.0) if self.blastType == 'ice' else (1,0.3,0.1), 'volumeIntensityScale': 10.0}) s = random.uniform(0.6,0.9) scorchRadius = lightRadius = self.radius if self.blastType == 'tnt': lightRadius *= 1.4 scorchRadius *= 1.15 s *= 3.0 iScale = 1.6 bsUtils.animate(light,"intensity",{0:2.0*iScale, int(s*20):0.1*iScale, int(s*25):0.2*iScale, int(s*50):17.0*iScale, int(s*60):5.0*iScale, int(s*80):4.0*iScale, int(s*200):0.6*iScale, int(s*2000):0.00*iScale, int(s*3000):0.0}) bsUtils.animate(light,"radius",{0:lightRadius*0.2, int(s*50):lightRadius*0.55, int(s*100):lightRadius*0.3, int(s*300):lightRadius*0.15, int(s*1000):lightRadius*0.05}) bs.gameTimer(int(s*3000),light.delete) # make a scorch that fades over time scorch = bs.newNode('scorch', attrs={'position':position,'size':scorchRadius*0.5,'big':(self.blastType == 'tnt')}) if self.blastType == 'ice': scorch.color = (1,1,1.5) bsUtils.animate(scorch,"presence",{3000:1, 13000:0}) bs.gameTimer(13000,scorch.delete) if self.blastType == 'ice': bs.playSound(factory.hissSound,position=light.position) p = light.position bs.playSound(factory.getRandomExplodeSound(),position=p) bs.playSound(factory.debrisFallSound,position=p) ######## bs.shakeCamera(intensity=5.0 if self.blastType == 'tnt' else 0.05) ######## # tnt is more epic.. if self.blastType == 'tnt': bs.playSound(factory.getRandomExplodeSound(),position=p) def _extraBoom(): bs.playSound(factory.getRandomExplodeSound(),position=p) bs.gameTimer(250,_extraBoom) def _extraDebrisSound(): bs.playSound(factory.debrisFallSound,position=p) bs.playSound(factory.woodDebrisFallSound,position=p) bs.gameTimer(400,_extraDebrisSound)
def __init__( self, position=(0, 1, 0), velocity=(0, 0, 0), blastRadius=2.0, blastType="normal", sourcePlayer=None, hitType="explosion", hitSubType="normal", ): """ Instantiate with given values. """ bs.Actor.__init__(self) factory = Bomb.getFactory() self.blastType = blastType self.sourcePlayer = sourcePlayer self.hitType = hitType self.hitSubType = hitSubType # blast radius self.radius = blastRadius self.node = bs.newNode( "region", attrs={ "position": ( position[0], position[1] - 0.1, position[2], ), # move down a bit so we throw more stuff upward "scale": (self.radius, self.radius, self.radius), "type": "sphere", "materials": (factory.blastMaterial, bs.getSharedObject("attackMaterial")), }, delegate=self, ) bs.gameTimer(50, self.node.delete) # throw in an explosion and flash explosion = bs.newNode( "explosion", attrs={ "position": position, "velocity": (velocity[0], max(-1.0, velocity[1]), velocity[2]), "radius": self.radius, "big": (self.blastType == "tnt"), }, ) if self.blastType == "ice": explosion.color = (0, 0.05, 0.4) bs.gameTimer(1000, explosion.delete) if self.blastType != "ice": bs.emitBGDynamics( position=position, velocity=velocity, count=int(1.0 + random.random() * 4), emitType="tendrils", tendrilType="thinSmoke", ) bs.emitBGDynamics( position=position, velocity=velocity, count=int(4.0 + random.random() * 4), emitType="tendrils", tendrilType="ice" if self.blastType == "ice" else "smoke", ) bs.emitBGDynamics(position=position, emitType="distortion", spread=1.0 if self.blastType == "tnt" else 2.0) # and emit some shrapnel.. if self.blastType == "ice": def _doEmit(): bs.emitBGDynamics( position=position, velocity=velocity, count=30, spread=2.0, scale=0.4, chunkType="ice", emitType="stickers", ) bs.gameTimer(50, _doEmit) # looks better if we delay a bit elif self.blastType == "sticky": def _doEmit(): bs.emitBGDynamics( position=position, velocity=velocity, count=int(4.0 + random.random() * 8), spread=0.7, chunkType="slime", ) bs.emitBGDynamics( position=position, velocity=velocity, count=int(4.0 + random.random() * 8), scale=0.5, spread=0.7, chunkType="slime", ) bs.emitBGDynamics( position=position, velocity=velocity, count=15, scale=0.6, chunkType="slime", emitType="stickers" ) bs.emitBGDynamics( position=position, velocity=velocity, count=20, scale=0.7, chunkType="spark", emitType="stickers" ) bs.emitBGDynamics( position=position, velocity=velocity, count=int(6.0 + random.random() * 12), scale=0.8, spread=1.5, chunkType="spark", ) bs.gameTimer(50, _doEmit) # looks better if we delay a bit elif self.blastType == "impact": # regular bomb shrapnel def _doEmit(): bs.emitBGDynamics( position=position, velocity=velocity, count=int(4.0 + random.random() * 8), scale=0.8, chunkType="metal", ) bs.emitBGDynamics( position=position, velocity=velocity, count=int(4.0 + random.random() * 8), scale=0.4, chunkType="metal", ) bs.emitBGDynamics( position=position, velocity=velocity, count=20, scale=0.7, chunkType="spark", emitType="stickers" ) bs.emitBGDynamics( position=position, velocity=velocity, count=int(8.0 + random.random() * 15), scale=0.8, spread=1.5, chunkType="spark", ) bs.gameTimer(50, _doEmit) # looks better if we delay a bit else: # regular or land mine bomb shrapnel def _doEmit(): if self.blastType != "tnt": bs.emitBGDynamics( position=position, velocity=velocity, count=int(4.0 + random.random() * 8), chunkType="rock" ) bs.emitBGDynamics( position=position, velocity=velocity, count=int(4.0 + random.random() * 8), scale=0.5, chunkType="rock", ) bs.emitBGDynamics( position=position, velocity=velocity, count=30, scale=1.0 if self.blastType == "tnt" else 0.7, chunkType="spark", emitType="stickers", ) bs.emitBGDynamics( position=position, velocity=velocity, count=int(18.0 + random.random() * 20), scale=1.0 if self.blastType == "tnt" else 0.8, spread=1.5, chunkType="spark", ) # tnt throws splintery chunks if self.blastType == "tnt": def _emitSplinters(): bs.emitBGDynamics( position=position, velocity=velocity, count=int(20.0 + random.random() * 25), scale=0.8, spread=1.0, chunkType="splinter", ) bs.gameTimer(10, _emitSplinters) # every now and then do a sparky one if self.blastType == "tnt" or random.random() < 0.1: def _emitExtraSparks(): bs.emitBGDynamics( position=position, velocity=velocity, count=int(10.0 + random.random() * 20), scale=0.8, spread=1.5, chunkType="spark", ) bs.gameTimer(20, _emitExtraSparks) bs.gameTimer(50, _doEmit) # looks better if we delay a bit light = bs.newNode( "light", attrs={ "position": position, "color": (0.6, 0.6, 1.0) if self.blastType == "ice" else (1, 0.3, 0.1), "volumeIntensityScale": 10.0, }, ) s = random.uniform(0.6, 0.9) scorchRadius = lightRadius = self.radius if self.blastType == "tnt": lightRadius *= 1.4 scorchRadius *= 1.15 s *= 3.0 iScale = 1.6 bsUtils.animate( light, "intensity", { 0: 2.0 * iScale, int(s * 20): 0.1 * iScale, int(s * 25): 0.2 * iScale, int(s * 50): 17.0 * iScale, int(s * 60): 5.0 * iScale, int(s * 80): 4.0 * iScale, int(s * 200): 0.6 * iScale, int(s * 2000): 0.00 * iScale, int(s * 3000): 0.0, }, ) bsUtils.animate( light, "radius", { 0: lightRadius * 0.2, int(s * 50): lightRadius * 0.55, int(s * 100): lightRadius * 0.3, int(s * 300): lightRadius * 0.15, int(s * 1000): lightRadius * 0.05, }, ) bs.gameTimer(int(s * 3000), light.delete) # make a scorch that fades over time scorch = bs.newNode( "scorch", attrs={"position": position, "size": scorchRadius * 0.5, "big": (self.blastType == "tnt")} ) if self.blastType == "ice": scorch.color = (1, 1, 1.5) bsUtils.animate(scorch, "presence", {3000: 1, 13000: 0}) bs.gameTimer(13000, scorch.delete) if self.blastType == "ice": bs.playSound(factory.hissSound, position=light.position) p = light.position bs.playSound(factory.getRandomExplodeSound(), position=p) bs.playSound(factory.debrisFallSound, position=p) ######## bs.shakeCamera(intensity=5.0 if self.blastType == "tnt" else 0.05) ######## # tnt is more epic.. if self.blastType == "tnt": bs.playSound(factory.getRandomExplodeSound(), position=p) def _extraBoom(): bs.playSound(factory.getRandomExplodeSound(), position=p) bs.gameTimer(250, _extraBoom) def _extraDebrisSound(): bs.playSound(factory.debrisFallSound, position=p) bs.playSound(factory.woodDebrisFallSound, position=p) bs.gameTimer(400, _extraDebrisSound)
def handleMessage(self, m): if isinstance(m, bs.HitMessage): if not self.node.exists(): return if self.node.invincible == True: bs.playSound(self.getFactory().blockSound, 1.0, position=self.node.position) return True # if we were recently hit, don't count this as another # (so punch flurries and bomb pileups essentially count as 1 hit) gameTime = bs.getGameTime() if self._lastHitTime is None or gameTime - self._lastHitTime > 1000: self._numTimesHit += 1 self._lastHitTime = gameTime mag = m.magnitude * self._impactScale velocityMag = m.velocityMagnitude * self._impactScale damageScale = 0.22 # if they've got a shield, deliver it to that instead.. if self.shield is not None: if m.flatDamage: damage = m.flatDamage * self._impactScale else: # hit our spaz with an impulse but tell it to only return theoretical damage; not apply the impulse.. self.node.handleMessage("impulse", m.pos[0], m.pos[1], m.pos[2], m.velocity[0], m.velocity[1], m.velocity[2], mag, velocityMag, m.radius, 1, m.forceDirection[0], m.forceDirection[1], m.forceDirection[2]) damage = damageScale * self.node.damage self.shieldHitPoints -= damage self.shield.hurt = 1.0 - self.shieldHitPoints / self.shieldHitPointsMax # its a cleaner event if a hit just kills the shield without damaging the player.. # however, massive damage events should still be able to damage the player.. # this hopefully gives us a happy medium. maxSpillover = 500 if self.shieldHitPoints <= 0: # fixme - transition out perhaps?.. self.shield.delete() self.shield = None bs.playSound(self.getFactory().shieldDownSound, 1.0, position=self.node.position) # emit some cool lookin sparks when the shield dies t = self.node.position bs.emitBGDynamics(position=(t[0], t[1]+0.9, t[2]), velocity=self.node.velocity, count=random.randrange(20, 30), scale=1.0, spread=0.6, chunkType='spark') else: bs.playSound(self.getFactory().shieldHitSound, 0.5, position=self.node.position) # emit some cool lookin sparks on shield hit bs.emitBGDynamics(position=m.pos, velocity=(m.forceDirection[0]*1.0, m.forceDirection[1]*1.0, m.forceDirection[2]*1.0), count=min(30, 5+int(damage*0.005)), scale=0.5, spread=0.3, chunkType='spark') # if they passed our spillover threshold, pass damage along to spaz if self.shieldHitPoints <= -maxSpillover: leftoverDamage = -maxSpillover - self.shieldHitPoints shieldLeftoverRatio = leftoverDamage / damage # scale down the magnitudes applied to spaz accordingly.. mag *= shieldLeftoverRatio velocityMag *= shieldLeftoverRatio else: return True # good job shield! else: shieldLeftoverRatio = 1.0 if m.flatDamage: damage = m.flatDamage * self._impactScale * shieldLeftoverRatio else: # hit it with an impulse and get the resulting damage #bs.screenMessage(str(velocityMag)) if self.multiplyer > 3.0: # at about 8.0 the physics glitch out velocityMag *= min((3.0 + (self.multiplyer-3.0)/4), 7.5) ** 1.9 else: velocityMag *= self.multiplyer ** 1.9 self.node.handleMessage("impulse", m.pos[0], m.pos[1], m.pos[2], m.velocity[0], m.velocity[1], m.velocity[2], mag, velocityMag, m.radius, 0, m.forceDirection[0], m.forceDirection[1], m.forceDirection[2]) damage = damageScale * self.node.damage self.node.handleMessage("hurtSound") # play punch impact sound based on damage if it was a punch if m.hitType == 'punch': self.onPunched(damage) # if damage was significant, lets show it #if damage > 350: bsUtils.showDamageCount('-'+str(int(damage/10))+"%",m.pos,m.forceDirection) # lets always add in a super-punch sound with boxing gloves just to differentiate them if m.hitSubType == 'superPunch': bs.playSound(self.getFactory().punchSoundStronger, 1.0, position=self.node.position) if damage > 500: sounds = self.getFactory().punchSoundsStrong sound = sounds[random.randrange(len(sounds))] else: sound = self.getFactory().punchSound bs.playSound(sound, 1.0, position=self.node.position) # throw up some chunks bs.emitBGDynamics(position=m.pos, velocity=(m.forceDirection[0]*0.5, m.forceDirection[1]*0.5, m.forceDirection[2]*0.5), count=min(10, 1+int(damage*0.0025)), scale=0.3, spread=0.03) bs.emitBGDynamics(position=m.pos, chunkType='sweat', velocity=(m.forceDirection[0]*1.3, m.forceDirection[1]*1.3+5.0, m.forceDirection[2]*1.3), count=min(30, 1 + int(damage * 0.04)), scale=0.9, spread=0.28) # momentary flash hurtiness = damage*0.003 hurtiness = min(hurtiness, 750 * 0.003) punchPos = (m.pos[0]+m.forceDirection[0]*0.02, m.pos[1]+m.forceDirection[1]*0.02, m.pos[2]+m.forceDirection[2]*0.02) flashColor = (1.0, 0.8, 0.4) light = bs.newNode("light", attrs={'position':punchPos, 'radius':0.12+hurtiness*0.12, 'intensity':0.3*(1.0+1.0*hurtiness), 'heightAttenuated':False, 'color':flashColor}) bs.gameTimer(60, light.delete) flash = bs.newNode("flash", attrs={'position':punchPos, 'size':0.17+0.17*hurtiness, 'color':flashColor}) bs.gameTimer(60, flash.delete) if m.hitType == 'impact': bs.emitBGDynamics(position=m.pos, velocity=(m.forceDirection[0]*2.0, m.forceDirection[1]*2.0, m.forceDirection[2]*2.0), count=min(10, 1 + int(damage * 0.01)), scale=0.4, spread=0.1) if self.hitPoints > 0: # its kinda crappy to die from impacts, so lets reduce impact damage # by a reasonable amount if it'll keep us alive if m.hitType == 'impact' and damage > self.hitPoints: # drop damage to whatever puts us at 10 hit points, or 200 less than it used to be # whichever is greater (so it *can* still kill us if its high enough) newDamage = max(damage-200, self.hitPoints-10) damage = newDamage self.node.handleMessage("flash") # if we're holding something, drop it if damage > 0.0 and self.node.holdNode.exists(): self.node.holdNode = bs.Node(None) #self.hitPoints -= damage self.multiplyer += min(damage / 2000, 0.15) if damage/2000 > 0.05: self.setScoreText(str(int((self.multiplyer-1)*100))+"%") #self.node.hurt = 1.0 - self.hitPoints/self.hitPointsMax self.node.hurt = 0.0 # if we're cursed, *any* damage blows us up if self._cursed and damage > 0: bs.gameTimer(50, bs.WeakCall(self.curseExplode, m.sourcePlayer)) # if we're frozen, shatter.. otherwise die if we hit zero #if self.frozen and (damage > 200 or self.hitPoints <= 0): # self.shatter() #elif self.hitPoints <= 0: # self.node.handleMessage(bs.DieMessage(how='impact')) # if we're dead, take a look at the smoothed damage val # (which gives us a smoothed average of recent damage) and shatter # us if its grown high enough #if self.hitPoints <= 0: # damageAvg = self.node.damageSmoothed * damageScale # if damageAvg > 1000: # self.shatter() elif isinstance(m, bs.DieMessage): self.oob_effect() super(self.__class__, self).handleMessage(m) elif isinstance(m, bs.PowerupMessage): if m.powerupType == 'health': if self.multiplyer > 2: self.multiplyer *= 0.5 else: self.multiplyer *= 0.75 self.multiplyer = max(1, self.multiplyer) self.setScoreText(str(int((self.multiplyer-1)*100))+"%") super(self.__class__, self).handleMessage(m) else: super(self.__class__, self).handleMessage(m)
def _flashPuckSpawn(self, pos): light = bs.newNode("light", attrs={"position": pos, "heightAttenuated": False, "color": (1, 0, 0)}) bs.animate(light, "intensity", {0: 0, 250: 1, 500: 0}, loop=True) bs.gameTimer(1000, light.delete)
def _flashBoxSpawn(self): light = bs.newNode('light', attrs={'position':self._boxSpawnPos, 'color':(1, 1, 1), 'radius':0.3, 'heightAttenuated':False}) bs.animate(light, 'intensity', {0:0, 250:0.5, 500:0}, loop=True) bs.gameTimer(1000, light.delete)
def __init__(self, position=(0, 1, 0), powerupType='tripleBombs', expire=True): bs.Actor.__init__(self) factory = self.getFactory() if gSettingsEnabled: settings = bs.get_settings() else: settings = {} self.powerupType = powerupType self._powersGiven = False if powerupType == 'tripleBombs': tex = factory.texBomb name = 'TripleBombs' elif powerupType == 'multiBombs': tex = factory.texMultiBombs name = 'MultiBombs' elif powerupType == 'punch': tex = factory.texPunch name = 'Gloves' elif powerupType == 'speedPunch': tex = factory.texSpeedPunch name = 'Gloves 2.0' elif powerupType == 'fireworkBombs': tex = factory.texFireworkBomb name = 'FireWorks' elif powerupType == 'killLaKillBombs': tex = factory.texKillLaKillBomb name = 'KillAll' elif powerupType == 'poisonBombs': tex = factory.texPoisonBomb name = 'PoisonBomb' elif powerupType == 'pandoraBox': tex = factory.texPandoraBox name = 'PandoraBox' elif powerupType == 'yellowShield': tex = factory.texYellowShield name = 'YellowShield' elif powerupType == 'jumpingBombs': tex = factory.texJumpingBomb name = 'JumpingBomb' elif powerupType == 'tpBombs': tex = factory.texTpBombs name = 'TPBomb' elif powerupType == 'iceBombs': tex = factory.texIceBombs name = 'IcyBombs' elif powerupType == 'impactBombs': tex = factory.texImpactBombs name = 'ImpactBombs' elif powerupType == 'landMines': tex = factory.texLandMines name = 'LandMines' elif powerupType == 'stickyBombs': tex = factory.texStickyBombs name = 'StickyBombs' elif powerupType == 'shield': tex = factory.texShield name = 'Bubble' elif powerupType == 'health': tex = factory.texHealth name = 'Health' elif powerupType == 'curse': tex = factory.texCurse name = 'Pls Touch Me' elif powerupType == 'unbreakable': tex = factory.texUnb name = 'Unbreakable' elif powerupType == 'dirtBombs': tex = factory.texDirt name = 'DirtBomb' elif powerupType == 'speed': tex = factory.texSpeed # new powerups begin elif powerupType == 'alan': tex = factory.texAlan name = 'Boss' elif powerupType == 'rdm': tex = factory.texRDM name = 'RandomBomb' elif powerupType == 'randomCharacter': tex = factory.RandomCharacter name = 'Random Char' elif powerupType == 'troll': tex = factory.Troll name = 'FunPack' elif powerupType == 'mj': tex = factory.texmj name = 'MJ' elif powerupType == 'impactMess': tex = factory.teximpactMess name = 'ImpactMess' elif powerupType == 'Motion': tex = factory.texMotion name = 'Motion' elif powerupType == 'invisibility': tex = factory.texInvisibility name = 'Invisibile' elif powerupType == 'hijump': tex = factory.texHiJump name = 'Hi-Jump' elif powerupType == 'ballon': tex = factory.texBallon name = 'Ballon' elif powerupType == 'BlockPowerup': tex = factory.texBlock name = 'Block' elif powerupType == 'iceImpact': tex = factory.texiceImpact name = 'IceImpact' elif powerupType == 'goldenBomb': tex = factory.texGoldenBomb name = 'BlastyBomb' elif powerupType == 'tbomb': tex = factory.textbomb name = 'TBomb' elif powerupType == 'gluebomb': tex = factory.texgluebomb name = 'Broken Glue' elif powerupType == 'weedbomb': tex = factory.texweedbomb name = 'WeedBomb' elif powerupType == 'bot': tex = factory.texBot name = 'Buddy Bot' elif powerupType == 'celebrate': tex = factory.texcelebrate name = 'Celebrate' elif powerupType == 'FloatingMine': tex = factory.texFloatingMine name = 'LandMines' elif powerupType == 'TouchMe': tex = factory.texTouchMe name = 'TouchMe' elif powerupType == 'radius': tex = factory.texRadius name = 'Radius' elif powerupType == 'sleep': tex = factory.texSleep name = 'Sleepy' elif powerupType == 'night': tex = factory.texNight name = 'NiteNite' elif powerupType == 'spazBomb': tex = factory.texSpazBomb name = 'SpazBomb' elif powerupType == 'curseBomb': tex = factory.texcurseBomb name = 'CurseBomb' elif powerupType == 'characterBomb': tex = factory.texcharacterBomb name = 'CharBomb' elif powerupType == 'mjBomb': tex = factory.texmjBomb name = 'MJBomb' elif powerupType == 'trioBomb': tex = factory.textrioBomb name = 'ImpactTrio' elif powerupType == 'speedBomb': tex = factory.texspeedBomb name = 'ShockWave' elif powerupType == 'healBomb': tex = factory.texhealBomb name = 'HealthBomb' elif powerupType == 'nightBomb': tex = factory.texNightBomb name = 'AtomBomb' elif powerupType == 'revengeBomb': tex = factory.texrevengeBomb name = 'RevengeBomb' elif powerupType == 'blastBomb': tex = factory.texblastBomb name = 'blastBomb' elif powerupType == 'knockBomb': tex = factory.texknockBomb name = 'KnockBomb' elif powerupType == 'stickyIce': tex = factory.texstickyIce name = 'StickyIce' elif powerupType == 'stickyIceTrio': tex = factory.texstickyIceTrio name = 'StickyIceTrio' elif powerupType == 'stickyIceMess': tex = factory.texstickyIceMess name = 'StickyIceMess' elif powerupType == 'stickyMess': tex = factory.texStickyMess name = 'StickyMess' elif powerupType == 'icyMess': tex = factory.texIcyMess name = 'IcyMess' elif powerupType == 'icyTrio': tex = factory.texicyTrio name = 'IcyTrio' elif powerupType == 'weee': tex = factory.texWeee name = 'Health' elif powerupType == 'tnt': tex = factory.texTnt name = 'TNT' elif powerupType == 'boomBomb': tex = factory.texboomBomb name = 'KaboomBomb' elif powerupType == 'name': tex = factory.texName name = 'NewName' elif powerupType == 'highlight': tex = factory.texHighlight name = 'HighLight' elif powerupType == 'spotlight': tex = factory.texSpotlight name = 'Spotlight' elif powerupType == 'jumpFly': tex = factory.texjumpFly name = 'FlyJump' elif powerupType == 'use': tex = factory.texuse name = 'FlyBomb' elif powerupType == "antiGrav": tex = factory.texAntiGrav name = 'AntiGrav' elif powerupType == "BlackHole": tex = factory.texBlackHole name = 'BlackHole' elif powerupType == "Slippery": tex = factory.texSlippery name = 'LuckyBlock' elif powerupType == "Box": tex = factory.texBox name = 'Box' elif powerupType == 'snoball': tex = factory.texSno mod = factory.snoModel name = "shieldBall" elif powerupType == 'pass': return else: raise Exception("invalid powerupType: " + str(powerupType)) if len(position) != 3: raise Exception("expected 3 floats for position") if powerupType == 'poisonBombs': refScale = (0, 3, 0) ref = 'soft' elif powerupType == 'pandoraBox': ref = 'soft' refScale = (1, 1, 1) elif powerupType == 'dirtBombs': ref = 'soft' refScale = (1, 0.4, 0.16) else: refScale = [0.95] ref = 'powerup' self.node = bs.newNode('prop', delegate=self, attrs={ 'body': 'box', 'position': position, 'model': factory.model, 'lightModel': factory.modelSimple, 'shadowSize': 0.48, 'colorTexture': tex, 'reflection': ref, 'reflectionScale': refScale, 'materials': (factory.powerupMaterial, bs.getSharedObject('objectMaterial')) }) prefixAnim = { 0: (1, 0, 0), 250: (1, 1, 0), 250 * 2: (0, 1, 0), 250 * 3: (0, 1, 1), 250 * 4: (1, 0, 1), 250 * 5: (0, 0, 1), 250 * 6: (1, 0, 0) } color = (0, 0, 1) if don.powerupName: m = bs.newNode('math', owner=self.node, attrs={ 'input1': (0, 0.7, 0), 'operation': 'add' }) self.node.connectAttr('position', m, 'input2') self.nodeText = bs.newNode('text', owner=self.node, attrs={ 'text': str(name), 'inWorld': True, 'shadow': 1.0, 'flatness': 1.0, 'color': color, 'scale': 0.0, 'hAlign': 'center' }) m.connectAttr('output', self.nodeText, 'position') bs.animate(self.nodeText, 'scale', {0: 0, 140: 0.016, 200: 0.01}) bs.animateArray( self.nodeText, 'color', 3, { 0: (0, 0, 2), 500: (0, 2, 0), 1000: (2, 0, 0), 1500: (2, 2, 0), 2000: (2, 0, 2), 2500: (0, 1, 6), 3000: (1, 2, 0) }, True) bs.emitBGDynamics(position=self.nodeText.position, velocity=self.node.position, count=200, scale=1.4, spread=2.01, chunkType='sweat') if don.shieldOnPowerUps: self.nodeShield = bs.newNode('shield', owner=self.node, attrs={ 'color': color, 'position': (self.node.position[0], self.node.position[1], self.node.position[2] + 0.5), 'radius': 1.2 }) self.node.connectAttr('position', self.nodeShield, 'position') bsUtils.animateArray(self.nodeShield, 'color', 3, prefixAnim, True) if don.discoLights: self.nodeLight = bs.newNode('light', attrs={ 'position': self.node.position, 'color': color, 'radius': 0.2, 'volumeIntensityScale': 0.5 }) self.node.connectAttr('position', self.nodeLight, 'position') bsUtils.animateArray(self.nodeLight, 'color', 3, prefixAnim, True) bs.animate(self.nodeLight, "intensity", { 0: 1.0, 1000: 1.8, 2000: 1.0 }, loop=True) bs.gameTimer(8000, self.nodeLight.delete) if don.powerupTimer: self.powerupHurt = bs.newNode('shield', owner=self.node, attrs={ 'color': (1, 1, 1), 'radius': 0.1, 'hurt': 1, 'alwaysShowHealthBar': True }) self.node.connectAttr('position', self.powerupHurt, 'position') bs.animate(self.powerupHurt, 'hurt', { 0: 0, defaultPowerupInterval - 1000: 1 }) bs.gameTimer(defaultPowerupInterval - 1000, bs.Call(self.do_delete)) curve = bs.animate(self.node, "modelScale", {0: 0, 140: 1.6, 200: 1}) bs.gameTimer(200, curve.delete) if expire: bs.gameTimer(defaultPowerupInterval - 2500, bs.WeakCall(self._startFlashing)) bs.gameTimer(defaultPowerupInterval - 1000, bs.WeakCall(self.handleMessage, bs.DieMessage()))
def __init__(self, position=(0, 1, 0), velocity=(0, 0, 0), bombType='tnt', blastRadius=2.0, sourcePlayer=None, owner=None): """ Create a new Bomb. bombType can be 'ice','impact','landMine','normal','sticky', or 'tnt'. Note that for impact or landMine bombs you have to call arm() before they will go off. """ bs.Actor.__init__(self) factory = self.getFactory() self.bombType = bombType = 'tnt' self._exploded = False self.blastRadius = blastRadius # TNT self.blastRadius *= 1.45 self._explodeCallbacks = [] # the player this came from self.sourcePlayer = sourcePlayer # by default our hit type/subtype is our own, but we pick up types of whoever # sets us off so we know what caused a chain reaction self.hitType = 'explosion' self.hitSubType = self.bombType # if no owner was provided, use an unconnected node ref if owner is None: owner = bs.Node(None) # the node this came from self.owner = owner # TNT materials = (factory.bombMaterial, bs.getSharedObject('footingMaterial'), bs.getSharedObject('objectMaterial')) materials = materials + (factory.normalSoundMaterial,) self.node = bs.newNode('prop', delegate=self, attrs={'position':position, 'velocity':velocity, 'model':factory.tntModel, 'lightModel':factory.tntModel, 'body':'crate', 'shadowSize':0.5, 'colorTexture':factory.tntTex, 'reflection':'soft', 'reflectionScale':[0.23], 'materials':materials}) #self.node.extraAcceleration = (0, 40, 0) self.heldBy = 0 self._isDead = False bsUtils.animate(self.node, "modelScale", {0:0, 200:1.3, 260:1})
def onBegin(self): bs.TeamGameActivity.onBegin(self) self.dropShield() self._shieldDropper = bs.Timer(8001, bs.WeakCall(self.dropShield), repeat=True) self.setupStandardTimeLimit(self.settings['Time Limit']) bsGlobals = bs.getSharedObject("globals") if self.settings["Obstacles"]: count = self.settings["Obstacles count"] map = bs.getActivity()._map.getName() for i in range(count): if map == 'Football Stadium': radius = (random.uniform(-10, 1), 6, random.uniform(-4.5, 4.5)) if i > count / 2 else ( random.uniform(10, 1), 6, random.uniform(-4.5, 4.5)) else: radius = (random.uniform(-10, 1), 6, random.uniform( -8, 8)) if i > count / 2 else (random.uniform(10, 1), 6, random.uniform(-8, 8)) Boxes(position=radius, graphics=self.settings["Graphics"], randomColor=self.settings["Random obstacles color"], mirror=self.settings["Obstacles mirror shots"], form=self.settings["Obstacles form"]).autoRetain() if self.settings["Graphics"] == 2: bsGlobals.tint = (bsGlobals.tint[0] - 0.6, bsGlobals.tint[1] - 0.6, bsGlobals.tint[2] - 0.6) light = bs.newNode('light', attrs={ 'position': (9, 10, 0) if map == 'Football Stadium' else (6, 7, -2) if not map == 'Rampage' else (6, 11, -2) if not map == 'The Pad' else (6, 8.5, -2), 'color': (0.4, 0.4, 0.45), 'radius': 1, 'intensity': 6, 'volumeIntensityScale': 10.0 }) light2 = bs.newNode( 'light', attrs={ 'position': (-9, 10, 0) if map == 'Football Stadium' else (-6, 7, -2) if not map == 'Rampage' else (-6, 11, -2) if not map == 'The Pad' else (-6, 8.5, -2), 'color': (0.4, 0.4, 0.45), 'radius': 1, 'intensity': 6, 'volumeIntensityScale': 10.0 }) if len(self.teams) > 0: self._scoreToWin = self.settings['Kills to Win Per Player'] * max( 1, max(len(t.players) for t in self.teams)) else: self._scoreToWin = self.settings['Kills to Win Per Player'] self._updateScoreBoard() self._dingSound = bs.getSound('dingSmall')
def __init__(self, position=(0, 1, 0), powerupType='tripleBombs', expire=True): """ Create a powerup-box of the requested type at the requested position. see bs.Powerup.powerupType for valid type strings. """ bs.Actor.__init__(self) factory = self.getFactory() self.powerupType = powerupType self._powersGiven = False mod = factory.model mScl = 1 if powerupType == 'tripleBombs': tex = factory.texBomb elif powerupType == 'punch': tex = factory.texPunch elif powerupType == 'iceBombs': tex = factory.texIceBombs elif powerupType == 'impactBombs': tex = factory.texImpactBombs elif powerupType == 'landMines': tex = factory.texLandMines elif powerupType == 'stickyBombs': tex = factory.texStickyBombs elif powerupType == 'shield': tex = factory.texShield elif powerupType == 'health': tex = factory.texHealth elif powerupType == 'curse': tex = factory.texCurse elif powerupType == 'bunny': tex = factory.texEgg mod = factory.eggModel mScl = 0.7 elif powerupType == 'snoball': tex = factory.texSno mod = factory.snoModel elif powerupType == 'randomDoor': tex = factory.texDoor mod = factory.doorModel mScl = 1.2 else: raise Exception("invalid powerupType: " + str(powerupType)) if len(position) != 3: raise Exception("expected 3 floats for position") self.node = bs.newNode('prop', delegate=self, attrs={ 'body': 'box', 'position': position, 'model': mod, 'lightModel': factory.modelSimple, 'shadowSize': 0.5, 'colorTexture': tex, 'reflection': 'powerup', 'reflectionScale': [1.0], 'materials': (factory.powerupMaterial, bs.getSharedObject('objectMaterial')) }) # animate in.. curve = bs.animate(self.node, "modelScale", { 0: 0, 140: 1.6, 200: mScl }) bs.gameTimer(200, curve.delete) if expire: bs.gameTimer(defaultPowerupInterval - 2500, bs.WeakCall(self._startFlashing)) bs.gameTimer(defaultPowerupInterval - 1000, bs.WeakCall(self.handleMessage, bs.DieMessage()))
def __init__(self, vPos, player, lobby): import bsInternal self._deekSound = bs.getSound('deek') self._clickSound = bs.getSound('click01') self._punchSound = bs.getSound('punch01') self._swishSound = bs.getSound('punchSwish') self._errorSound = bs.getSound('error') self._maskTexture = bs.getTexture('characterIconMask') self._vPos = vPos self._lobby = weakref.ref(lobby) self._player = player self._inited = False self._dead = False # load available profiles either from the local config or from the # remote device.. self.reloadProfiles() # note: this is just our local index out of available teams; *not* # the team ID! self._selectedTeamIndex = self.getLobby().nextAddTeam # store a persistent random character index; we'll use this for the # '_random' profile. Let's use their inputDevice id to seed it.. this # will give a persistent character for them between games and will # distribute characters nicely if everyone is random try: inputDeviceID = self._player.getInputDevice().getID() except Exception as e: print 'ERROR: exc getting inputDeviceID for chooser creation:', e inputDeviceID = 0 import traceback traceback.print_stack() # we want the first device that asks for a chooser to always get # spaz as a random character.. global gRandomCharIndexOffset if gRandomCharIndexOffset is None: # scratch that.. we now kinda accomplish the same thing with # account profiles so lets just be fully random here.. gRandomCharIndexOffset = random.randrange(1000) # to calc our random index we pick a random character out of our # unlocked list and then locate that character's index in the full list self._randomCharacterIndex = ( (inputDeviceID + gRandomCharIndexOffset) % len(self.characterNames)) self._randomColor, self._randomHighlight = \ bsUtils.getPlayerProfileColors(None) global gAccountProfileDeviceID # attempt to pick an initial profile based on what's been stored # for this input device try: inputDevice = self._player.getInputDevice() name = inputDevice.getName() uniqueID = inputDevice.getUniqueIdentifier() self.profileName = ( bs.getConfig()['Default Player Profiles'][name + ' ' + uniqueID]) self.profileIndex = self.profileNames.index(self.profileName) # if this one is __account__ and is local and we havn't marked # anyone as the account-profile device yet, mark this guy as it. # (prevents the next joiner from getting the account profile too) if (self.profileName == '__account__' and not inputDevice.isRemoteClient() and gAccountProfileDeviceID is None): gAccountProfileDeviceID = inputDeviceID # well hmm that didn't work.. pick __account__, _random, or some # other random profile.. except Exception: profileNames = self.profileNames # we want the first local input-device in the game to latch on to # the account profile if (not inputDevice.isRemoteClient() and not inputDevice.isControllerApp()): if (gAccountProfileDeviceID is None and '__account__' in profileNames): gAccountProfileDeviceID = inputDeviceID # if this is the designated account-profile-device, try to default # to the account profile if (inputDeviceID == gAccountProfileDeviceID and '__account__' in profileNames): self.profileIndex = profileNames.index('__account__') else: # if this is the controller app, it defaults to using a random # profile (since we can pull the random name from the app) if inputDevice.isControllerApp(): self.profileIndex = profileNames.index('_random') else: # if its a client connection, for now just force the account # profile if possible.. (need to provide a way for clients # to specify/remember their default profile) if (inputDevice.isRemoteClient() and '__account__' in profileNames): self.profileIndex = profileNames.index('__account__') else: global gRandProfileIndex # cycle through our non-random profiles once; after # that, everyone gets random. while (gRandProfileIndex < len(profileNames) and profileNames[gRandProfileIndex] in ('_random', '__account__', '_edit')): gRandProfileIndex += 1 if gRandProfileIndex < len(profileNames): self.profileIndex = gRandProfileIndex gRandProfileIndex += 1 else: self.profileIndex = profileNames.index('_random') self.profileName = profileNames[self.profileIndex] self.characterIndex = self._randomCharacterIndex self._color = self._randomColor self._highlight = self._randomHighlight self.ready = False self._textNode = bs.newNode('text', delegate=self, attrs={ 'position': (-100, self._vPos), 'maxWidth': 160, 'shadow': 0.5, 'vrDepth': -20, 'hAlign': 'left', 'vAlign': 'center', 'vAttach': 'top' }) bsUtils.animate(self._textNode, 'scale', {0: 0, 100: 1.0}) self.icon = bs.newNode('image', owner=self._textNode, attrs={ 'position': (-130, self._vPos + 20), 'maskTexture': self._maskTexture, 'vrDepth': -10, 'attach': 'topCenter' }) bsUtils.animateArray(self.icon, 'scale', 2, {0: (0, 0), 100: (45, 45)}) self._setReady(False) # set our initial name to '<choosing player>' in case anyone asks.. self._player.setName(bs.Lstr(resource='choosingPlayerText').evaluate(), real=False) self.updateFromPlayerProfile() self.updatePosition() self._inited = True
def _flashFlag(self,flag,length=1000): light = bs.newNode('light',attrs={'position': flag.node.position,'heightAttenuated':False,'color': flag.light.color}) bs.animate(light,"intensity",{0:0,250:1,500:0},loop=True) bs.gameTimer(length,light.delete)
def _handleRacePointCollide(self): regionNode, playerNode = bs.getCollisionInfo('sourceNode', 'opposingNode') try: player = playerNode.getDelegate().getPlayer() except Exception: player = None region = regionNode.getDelegate() if player is None or not player.exists() or region is None: return lastRegion = player.gameData['lastRegion'] thisRegion = region._index if lastRegion != thisRegion: # if a player tries to skip regions, smite them # ..allow a one region leeway though (its plausable players can get # blown over a region, etc) if thisRegion > lastRegion + 2: if player.isAlive(): player.actor.handleMessage(bs.DieMessage()) bs.screenMessage(bs.Lstr(translate=( 'statements', "Killing ${NAME} for skipping part of the track!"), subs=[('${NAME}', player.getName(full=True)) ]), color=(1, 0, 0)) else: # if this player is in first, note that this is the # front-most race-point if player.gameData['rank'] == 0: self._frontRaceRegion = thisRegion player.gameData['lastRegion'] = thisRegion if lastRegion >= len(self._regions) - 2 and thisRegion == 0: team = player.getTeam() player.gameData['lap'] = min(self.settings['Laps'], player.gameData['lap'] + 1) # in teams mode with all-must-finish on, the team lap # value is the min of all team players # ..otherwise its the max if isinstance(self.getSession(), bs.TeamsSession) and self.settings.get( 'Entire Team Must Finish'): team.gameData['lap'] = min( [p.gameData['lap'] for p in team.players]) else: team.gameData['lap'] = max( [p.gameData['lap'] for p in team.players]) # a player is finishing if player.gameData['lap'] == self.settings['Laps']: # in teams mode, hand out points based on the order # players come in if isinstance(self.getSession(), bs.TeamsSession): if self._teamFinishPts > 0: self.scoreSet.playerScored(player, self._teamFinishPts, screenMessage=False) self._teamFinishPts -= 25 # flash where the player is self._flashPlayer(player, 1.0) player.gameData['finished'] = True player.actor.handleMessage( bs.DieMessage(immediate=True)) # makes sure noone behind them passes them in rank # while finishing.. player.gameData['distance'] = 9999.0 # if the whole team has finished the race.. if team.gameData['lap'] == self.settings['Laps']: bs.playSound(self._scoreSound) player.getTeam().gameData['finished'] = True self._lastTeamTime = player.getTeam( ).gameData['time'] = \ bs.getGameTime()-self._timer.getStartTime() self._checkEndGame() # team has yet to finish.. else: bs.playSound(self._swipSound) # they've just finished a lap but not the race.. else: bs.playSound(self._swipSound) self._flashPlayer(player, 0.3) # print their lap number over their head.. try: m = bs.newNode('math', owner=player.actor.node, attrs={ 'input1': (0, 1.9, 0), 'operation': 'add' }) player.actor.node.connectAttr( 'torsoPosition', m, 'input2') t = bs.newNode( 'text', owner=m, attrs={ 'text': bs.Lstr(resource='lapNumberText', subs=[('${CURRENT}', str(player.gameData['lap'] + 1)), ('${TOTAL}', str(self.settings['Laps'])) ]), 'inWorld': True, 'color': (1, 1, 0, 1), 'scale': 0.015, 'hAlign': 'center' }) m.connectAttr('output', t, 'position') bs.animate(t, 'scale', { 0: 0, 200: 0.019, 2000: 0.019, 2200: 0 }) bs.gameTimer(2300, m.delete) except Exception, e: print 'Exception printing lap:', e
def onBegin(self): bs.TeamGameActivity.onBegin(self) s = self.settings for player in self.players: player.actor.connectControlsToPlayer( enableBomb=False, enableRun=s["Enable Running"], enableJump=s["Enable Jumping"]) player.sessionData['fouls'] = 0 player.sessionData['fouledOut'] = False self.respawnBall(None) self.teams[0].gameData['score'] = 0 self.teams[1].gameData['score'] = 0 self.blueBench1 = bs.newNode('light', attrs={ 'color': (0, 0, 1), 'intensity': .6, 'position': (-6.5, 3, -4), 'radius': 0.4 }) self.blueBench2 = bs.newNode('light', attrs={ 'color': (0, 0, 1), 'intensity': .6, 'position': (-6.5, 3, -2), 'radius': 0.4 }) self.blueBench3 = bs.newNode('light', attrs={ 'color': (0, 0, 1), 'intensity': .6, 'position': (-6.5, 3, 0), 'radius': 0.4 }) self.redBench1 = bs.newNode('light', attrs={ 'color': (1, 0, 0), 'intensity': .5, 'position': (6.5, 3, -4), 'radius': 0.4 }) self.redBench2 = bs.newNode('light', attrs={ 'color': (1, 0, 0), 'intensity': .5, 'position': (6.5, 3, -2), 'radius': 0.4 }) self.redBench3 = bs.newNode('light', attrs={ 'color': (1, 0, 0), 'intensity': .5, 'position': (6.5, 3, 0), 'radius': 0.4 }) bs.animate(self.blueBench1, "intensity", {0: 0, 100: .5}) bs.animate(self.blueBench2, "intensity", {0: 0, 100: .5}) bs.animate(self.blueBench3, "intensity", {0: 0, 100: .5}) bs.animate(self.redBench1, "intensity", {0: 0, 100: .5}) bs.animate(self.redBench2, "intensity", {0: 0, 100: .5}) bs.animate(self.redBench3, "intensity", {0: 0, 100: .5}) self._scoredis.setTeamValue(self.teams[0], self.teams[1].gameData['score']) self._scoredis.setTeamValue(self.teams[1], self.teams[1].gameData['score']) self.updateScore() self.checkEnd()
def text(): #bySoby t = bs.newNode('text', attrs={ 'text': u'Message 1', 'scale': 1, 'maxWidth': 0, 'position': (35, 615), 'shadow': 0.5, 'flatness': 1.2, 'color': ((0 + random.random() * 1.0), (0 + random.random() * 1.0), (0 + random.random() * 1.0)), 'hAlign': 'right', 'vAttach': 'bottom' }) bs.animate(t, 'opacity', {0: 0.0, 500: 1.0, 6500: 1.0, 7000: 0.0}) bs.gameTimer(7000, t.delete) ## t = bs.newNode('text', attrs={ 'text': u'Message 2', 'scale': 1.3, 'maxWidth': 0, 'position': (0, 138), 'shadow': 0.5, 'flatness': 0.0, 'color': ((0 + random.random() * 1.0), (0 + random.random() * 1.0), (0 + random.random() * 1.0)), 'hAlign': 'center', 'vAttach': 'bottom' }) bs.animate(t, 'opacity', { 8500: 0.0, 9000: 1.0, 14500: 1.0, 15000: 0.0 }) bs.gameTimer(15000, t.delete) #bySoby t = bs.newNode('text', attrs={ 'text': u'Message 3', 'scale': 1, 'maxWidth': 0, 'position': (0, 138), 'color': ((0 + random.random() * 1.0), (0 + random.random() * 1.0), (0 + random.random() * 1.0)), 'shadow': 0.5, 'flatness': 1.0, 'hAlign': 'center', 'vAttach': 'bottom' }) bs.animate(t, 'opacity', { 17500: 0.0, 18500: 1.0, 24500: 1.0, 25000: 0.0 }) bs.gameTimer(25000, t.delete) #bySoby..............................Dont Edit This t = bs.newNode( 'text', attrs={ 'text': u'\ue04c/em To Use Emotes , /perk To Get Special Abilities\ue04c', 'scale': 1.2, 'maxWidth': 0, 'position': (0, 139), 'shadow': 0.5, 'color': ((0 + random.random() * 1.0), (0 + random.random() * 1.0), (0 + random.random() * 1.0)), 'flatness': 0.0, 'hAlign': 'center', 'vAttach': 'bottom' }) bs.animate(t, 'opacity', { 27000: 0.0, 27500: 1.0, 33500: 1.0, 34000: 0.0 }) bs.gameTimer(34000, t.delete) t = bs.newNode('text', attrs={ 'text': u'Message 4', 'scale': 0.8, 'maxWidth': 0, 'position': (0, 138), 'shadow': 0.5, 'flatness': 1.0, 'color': ((0 + random.random() * 1.0), (0 + random.random() * 1.0), (0 + random.random() * 1.0)), 'hAlign': 'center', 'vAttach': 'bottom' }) bs.animate(t, 'opacity', { 36000: 0.0, 36500: 1.0, 42500: 1.0, 43000: 0.0 }) bs.gameTimer(43000, t.delete) ## t = bs.newNode('text', attrs={ 'text': u'\ue047| Happy Bombsquading|\ue047', 'scale': 1, 'maxWidth': 0, 'position': (0, 138), 'shadow': 0.5, 'flatness': 1.0, 'color': ((0 + random.random() * 1.0), (0 + random.random() * 1.0), (0 + random.random() * 1.0)), 'hAlign': 'center', 'vAttach': 'bottom' }) bs.animate(t, 'opacity', { 45000: 0.0, 45500: 1.0, 50500: 1.0, 51000: 0.0 }) bs.gameTimer(51000, t.delete)
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 __init__(self, player, position, scale, showLives=True, showDeath=True, nameScale=1.0, nameMaxWidth=115.0, flatness=1.0, shadow=1.0): bs.Actor.__init__(self) self._player = player self._showLives = showLives self._showDeath = showDeath self._nameScale = nameScale self._outlineTex = bs.getTexture('characterIconMask') icon = player.getIcon() self.node = bs.newNode('image', owner=self, attrs={ 'texture': icon['texture'], 'tintTexture': icon['tintTexture'], 'tintColor': icon['tintColor'], 'vrDepth': 400, 'tint2Color': icon['tint2Color'], 'maskTexture': self._outlineTex, 'opacity': 1.0, 'absoluteScale': True, 'attach': 'bottomCenter' }) self._nameText = bs.newNode('text', owner=self.node, attrs={ 'text': player.getName(), 'color': bs.getSafeColor( player.getTeam().color), 'hAlign': 'center', 'vAlign': 'center', 'vrDepth': 410, 'maxWidth': nameMaxWidth, 'shadow': shadow, 'flatness': flatness, 'hAttach': 'center', 'vAttach': 'bottom' }) if self._showLives: self._livesText = bs.newNode('text', owner=self.node, attrs={ 'text': 'x0', 'color': (1, 1, 0.5), 'hAlign': 'left', 'vrDepth': 430, 'shadow': 1.0, 'flatness': 1.0, 'hAttach': 'center', 'vAttach': 'bottom' }) self.setPositionAndScale(position, scale)
def bsScoreBoardinit(self, scoreboard, team, doCover, scale, label, flashLength): self._scoreboard = weakref.ref(scoreboard) self._doCover = False self._scale = scale self._flashLength = flashLength self._width = 140.0 * self._scale self._height = 32.0 * self._scale self._barWidth = 2.0 * self._scale self._barHeight = 32.0 * self._scale self._barTex = self._backingTex = bs.getTexture('bar') self._coverTex = bs.getTexture('uiAtlas') self._model = bs.getModel('meterTransparent') safeTeamColor = bs.getSafeColor(team.color, targetIntensity=1.0) vr = bs.getEnvironment()['vrMode'] if self._doCover: if vr: self._backingColor = [0.1 + c * 0.1 for c in safeTeamColor] else: self._backingColor = [0.05 + c * 0.17 for c in safeTeamColor] else: self._backingColor = [0.05 + c * 0.1 for c in safeTeamColor] self._backing = bs.NodeActor( bs.newNode('image', attrs={ 'scale': (self._width, self._height), 'opacity': (0.8 if vr else 0.8) if self._doCover else 0.5, 'color': self._backingColor, 'vrDepth': -3, 'attach': 'topLeft', 'texture': self._backingTex })) self._barColor = safeTeamColor self._bar = bs.NodeActor( bs.newNode('image', attrs={ 'opacity': 0.7, 'color': self._barColor, 'attach': 'topLeft', 'texture': self._barTex })) self._barScale = bs.newNode('combine', owner=self._bar.node, attrs={ 'size': 2, 'input0': self._barWidth, 'input1': self._barHeight }) self._barScale.connectAttr('output', self._bar.node, 'scale') self._barPosition = bs.newNode('combine', owner=self._bar.node, attrs={ 'size': 2, 'input0': 0, 'input1': 0 }) self._barPosition.connectAttr('output', self._bar.node, 'position') self._coverColor = safeTeamColor if self._doCover: self._cover = bs.NodeActor( bs.newNode('image', attrs={ 'scale': (self._width * 1.15, self._height * 1.6), 'opacity': 1.0, 'color': self._coverColor, 'vrDepth': 2, 'attach': 'topLeft', 'texture': self._coverTex, 'modelTransparent': self._model })) c = safeTeamColor self._scoreText = bs.NodeActor( bs.newNode('text', attrs={ 'hAttach': 'left', 'vAttach': 'top', 'hAlign': 'right', 'vAlign': 'center', 'maxWidth': 130.0 * (1.0 - scoreboard._scoreSplit), 'vrDepth': 2, 'scale': self._scale * 0.9, 'text': '', 'shadow': 1.0 if vr else 0.5, 'flatness': (1.0 if vr else 0.5) if self._doCover else 1.0, 'color': c })) c = safeTeamColor if label is not None: teamNameLabel = label else: teamNameLabel = team.name # we do our own clipping here; should probably try to tap into some # existing functionality if type(teamNameLabel) is bs.Lstr: # hmmm; if the team-name is a non-translatable value lets go # ahead and clip it otherwise we leave it as-is so # translation can occur.. if teamNameLabel.isFlatValue(): v = teamNameLabel.evaluate() # in python < 3.5 some unicode chars can have length 2, # so we need to convert to raw int vals for safer trimming vChars = bs.uniToInts(v) if len(vChars) > 10: teamNameLabel = bs.Lstr(value=bs.uniFromInts(vChars[:10]) + '...') else: # in python < 3.5 some unicode chars can have length 2, # so we need to convert to raw int vals for safe trimming teamNameLabelChars = bs.uniToInts(teamNameLabel) if len(teamNameLabelChars) > 10: teamNameLabel = bs.uniFromInts(teamNameLabelChars[:10]) + '...' teamNameLabel = bs.Lstr(value=teamNameLabel) self._nameText = bs.NodeActor( bs.newNode('text', attrs={ 'hAttach': 'left', 'vAttach': 'top', 'hAlign': 'left', 'vAlign': 'center', 'vrDepth': 2, 'scale': self._scale * 0.9, 'shadow': 1.0 if vr else 0.5, 'flatness': (1.0 if vr else 0.5) if self._doCover else 1.0, 'maxWidth': 130 * scoreboard._scoreSplit, 'text': teamNameLabel, 'color': c + (1.0, ) })) self._score = None