def dropBomb(self): lifespan = 3000 if (self.bombCount <= 0) or self.frozen: return p = self.node.positionForward v = self.node.velocity bombType = "normal" bomb = bs.Bomb(position=(p[0], p[1] - 0.0, p[2]), velocity=(v[0], v[1], v[2]), bombType=bombType, blastRadius=self.blastRadius, sourcePlayer=self.sourcePlayer, owner=self.node).autoRetain() bsUtils.animate(bomb.node, 'modelScale', {0:0.0, lifespan*0.1:1.5, lifespan*0.5:1.0}) self.bombCount -= 1 bomb.node.addDeathAction(bs.WeakCall(self.handleMessage, _BombDiedMessage())) self._pickUp(bomb.node) for meth in self._droppedBombCallbacks: meth(self, bomb) return bomb
def dropBomb(self): lifespan = 3000 if (self.bombCount <= 0) or self.frozen: return p = self.node.positionForward v = self.node.velocity bombType = "normal" bomb = bs.Bomb(position=(p[0], p[1] - 0.0, p[2]), velocity=(v[0], v[1], v[2]), bombType=bombType, blastRadius=self.blastRadius, sourcePlayer=self.sourcePlayer, owner=self.node).autoRetain() bsUtils.animate(bomb.node, 'modelScale', { 0: 0.0, lifespan * 0.1: 1.5, lifespan * 0.5: 1.0 }) self.bombCount -= 1 bomb.node.addDeathAction( bs.WeakCall(self.handleMessage, _BombDiedMessage())) self._pickUp(bomb.node) for meth in self._droppedBombCallbacks: meth(self, bomb) return bomb
def spawnPlayerSpaz(self, player, position=(0, 0, 0), angle=None): name = player.getName() color = player.color highlight = player.highlight lightColor = bsUtils.getNormalizedColor(color) displayColor = bs.getSafeColor(color, targetIntensity=0.75) spaz = AntiGravityPlayerSpaz(color=color, highlight=highlight, character=player.character, player=player) player.setActor(spaz) 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() 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) bs.gameTimer(1000, bs.Call(self.raisePlayer, player)) return spaz
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 spawnPlayer(self, player): position = self.getMap().getFFAStartPosition(self.players) angle = 20 name = player.getName() lightColor = bsUtils.getNormalizedColor(player.color) displayColor = bs.getSafeColor(player.color, targetIntensity=0.75) spaz = BrickMan(color=player.color, highlight=player.highlight, character=player.character, player=player) player.setActor(spaz) spaz.node.name = '建筑师\n'.decode('utf8') + 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) spaz.connectControlsToPlayer(enablePunch=True, enableBomb=True, enablePickUp=False) spaz.playBigDeathSound = True spaz.initArchitect() return spaz
def spawnPlayer(self, player): position = self.getMap().getFFAStartPosition(self.players) angle = None name = player.getName() lightColor = bsUtils.getNormalizedColor(player.color) displayColor = bs.getSafeColor(player.color, targetIntensity=0.75) spaz = NewPlayerSpaz(color=player.color, highlight=player.highlight, character=player.character, player=player) player.setActor(spaz) player.gameData['boxes'] = 0 spaz.node.name = name spaz.node.nameColor = displayColor spaz.connectControlsToPlayer(enablePickUp=False) if self.settings['Equip Boxing Gloves']: spaz.equipBoxingGloves() if self.settings['Equip Shield']: spaz.equipShields() spaz.playBigDeathSound = True self.scoreSet.playerGotNewSpaz(player, spaz) 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 showInfo(playGong=True): activity = bs.getActivity() name = activity.getInstanceDisplayString() bsUtils.ZoomText(name, maxWidth=800, lifespan=2500, jitter=2.0, position=(0, 0), flash=False, color=(0.93 * 1.25, 0.9 * 1.25, 1.0 * 1.25), trailColor=(0.15, 0.05, 1.0, 0.0)).autoRetain() if playGong: bs.gameTimer(200, bs.Call(bs.playSound, bs.getSound('gong'))) desc = activity.getInstanceDescription() if type(desc) in [unicode, str]: desc = [desc] # handle simple string case if type(desc[0]) not in [unicode, str]: raise Exception("Invalid format for instance description") subs = [] for i in range(len(desc) - 1): subs.append(('${ARG' + str(i + 1) + '}', str(desc[i + 1]))) translation = bs.Lstr(translate=('gameDescriptions', desc[0]), subs=subs) if ('Epic Mode' in activity.settings and activity.settings['Epic Mode']): translation = bs.Lstr(resource='epicDescriptionFilterText', subs=[('${DESCRIPTION}', translation)]) vr = bs.getEnvironment()['vrMode'] d = bs.newNode('text', attrs={ 'vAttach': 'center', 'hAttach': 'center', 'hAlign': 'center', 'color': (1, 1, 1, 1), 'shadow': 1.0 if vr else 0.5, 'flatness': 1.0 if vr else 0.5, 'vrDepth': -30, 'position': (0, 80), 'scale': 1.2, 'maxWidth': 700, 'text': translation }) c = bs.newNode("combine", owner=d, attrs={ 'input0': 1.0, 'input1': 1.0, 'input2': 1.0, 'size': 4 }) c.connectAttr('output', d, 'color') keys = {500: 0, 1000: 1.0, 2500: 1.0, 4000: 0.0} bsUtils.animate(c, "input3", keys) bs.gameTimer(4000, d.delete)
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 _disappear(self): self._exploded = True #don't try to damage stuff anymore because we should be melting. if self.exists(): scl = self.node.modelScale bsUtils.animate(self.node, "modelScale", { 0: scl * 1.0, 300: scl * 0.5, 500: 0.0 }) bs.gameTimer(550, bs.WeakCall(self.handleMessage, bs.DieMessage()))
def _disappear(self): self._used = True if self.exists(): scl = self.node.modelScale bsUtils.animate(self.node, "modelScale", { 0: scl * 1.0, 300: scl * 0.5, 500: 0.0 }) bs.gameTimer(550, bs.WeakCall(self.handleMessage, bs.DieMessage()))
def lightningBolt(self,position = (0,10,0),radius = 10): bs.shakeCamera(3) self.tint = bs.getSharedObject('globals').tint light = bs.newNode('light', attrs={'position':position, 'color': (0.2,0.2,0.4), 'volumeIntensityScale': 1.0, 'radius':radius}) bsUtils.animate(light,"intensity",{0:1,50:radius,150:radius/2,250:0,260:radius,410:radius/2,510:0}) bsUtils.animateArray(bs.getSharedObject('globals'),"tint",3,{0:self.tint,200:(0.2,0.2,0.2),510:self.tint}) bs.playSound(bs.getSound('grom'),volume = 10,position = (0,10,0))
def doBust(self): if self.exists(): if not self._exploded: self._exploded = True bs.emitBGDynamics(position=self.node.position,velocity=[v*0.1 for v in self.node.velocity],count=10,spread=0.1,scale=0.4,chunkType='ice') #Do a muffled punch sound sound = self.getFactory().impactSound bs.playSound(sound,1.0,position=self.node.position) scl = self.node.modelScale bsUtils.animate(self.node,"modelScale",{0:scl*1.0, 20:scl*0.5, 50:0.0}) bs.gameTimer(80,bs.WeakCall(self.handleMessage,bs.DieMessage()))
def _disappear(self): if self.node.exists(): scl = self.node.modelScale bsUtils.animate(self.node,"modelScale",{0:scl*1.0, 300:scl*0.5, 500:0.0}) self.maxSpeed = 0 if self.hatch and self.sourcePlayer.exists(): if len(self.sourcePlayer.gameData['bots']) < 3: self.materials = [] p = self.node.position #self.getActivity()._bots.spawnBot(ToughGuyFrostBot,pos=(p[0],p[1]-0.8,p[2]),spawnTime=0, onSpawnCall=self.setupFrosty) self.sourcePlayer.gameData['bset'].spawnBot(ToughGuyFrostBot,pos=(p[0],p[1]-0.8,p[2]),spawnTime=0, onSpawnCall=self.setupFrosty) bs.gameTimer(550,bs.WeakCall(self.handleMessage,bs.DieMessage()))
def __init__(self, position=(0, 1, 0), velocity=(0, 0, 0), bombType='plague', blastRadius=2.0, sourcePlayer=None, owner=None): bs.Actor.__init__(self) factory = self.getFactory() self.bombType = 'plague' self._exploded = False self.blastRadius = self.getActivity().settings["Blast Size"] self._explodeCallbacks = [] self.sourcePlayer = sourcePlayer self.hitType = 'explosion' self.hitSubType = 'plague' if owner is None: owner = bs.Node(None) self.owner = owner fuseTime = 6000 sticky = False model = factory.bombModel rType = 'sharper' rScale = 1.8 materials = (factory.bombMaterial, bs.getSharedObject('objectMaterial')) self.node = bs.newNode('bomb', delegate=self, attrs={ 'position': position, 'velocity': velocity, 'model': model, 'shadowSize': 0.3, 'colorTexture': bs.getTexture("powerupCurse"), 'sticky': sticky, 'owner': owner, 'reflection': rType, 'reflectionScale': [rScale], 'materials': materials }) self.node.addDeathAction( bs.WeakCall(self.handleMessage, _BombDiedMessage())) 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}) bs.gameTimer(fuseTime, bs.Call(self.handleMessage, PlagueMessage()))
def spawnPlayer(self, player): position = self.getMap().getFFAStartPosition(self.players) angle = 20 name = player.getName() lightColor = bsUtils.getNormalizedColor(player.color) displayColor = bs.getSafeColor(player.color, targetIntensity=0.75) spaz = grimPlayer(color=player.color, highlight=player.highlight, character=player.character, player=player, gameProtectionTime=self.settings['Protection Time After Catching'], hitPoints=self.settings['Player HP']) player.setActor(spaz) # For some reason, I can't figure out how to get a list of all spaz. # Therefore, I am making the list here so I can get which spaz belongs # to the player supplied by HitMessage. # self.playerList.append(spaz) spaz.node.name = name spaz.node.nameColor = displayColor spaz.connectControlsToPlayer() self.scoreSet.playerGotNewSpaz(player, spaz) # add landmine spaz.bombTypeDefault = 'landMine' # random.choice(['ice', 'impact', 'landMine', 'normal', 'sticky', 'tnt']) spaz.bombType = spaz.bombTypeDefault # 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) # lets reconnect this player's controls to this # spaz but *without* the ability to attack or pick stuff up spaz.connectControlsToPlayer(enablePunch=False, enableBomb=self.settings['Allow Landmine'], enablePickUp=False) # player.assignInputCall('pickUpPress', lambda: None) # player.assignInputCall('pickUpRelease', lambda: None) # also lets have them make some noise when they die.. spaz.playBigDeathSound = True return spaz
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) spaz = PlayerSpaz_Infection(color=color, highlight=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() 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 setValue(self, score, maxScore=None, countdown=False, flash=True, showValue=True): # if we have no score yet, just set it.. otherwise compare and see if we # should flash if self._score is None: self._score = score else: if score > self._score or (countdown and score < self._score): extraFlash = (maxScore is not None and score >= maxScore and not countdown) or (countdown and score == 0) if flash: self.flash(countdown, extraFlash) self._score = score if maxScore is None: self._barWidth = 0.0 else: if countdown: self._barWidth = max( 2.0 * self._scale, self._width * (1.0 - (float(score) / maxScore))) else: self._barWidth = max( 2.0 * self._scale, self._width * (min(1.0, float(score) / maxScore))) curWidth = self._barScale.input0 bsUtils.animate(self._barScale, 'input0', { 0: curWidth, 250: self._barWidth }) self._barScale.input1 = self._barHeight curX = self._barPosition.input0 bsUtils.animate(self._barPosition, 'input0', { 0: curX, 250: self._pos[0] + self._barWidth / 2 }) self._barPosition.input1 = self._pos[1] - self._barHeight / 2 if showValue: self._scoreText.node.text = str(score) else: self._scoreText.node.text = ''
def __init__(self,position1 = (0,1,0),color = (random.random(),random.random(),random.random()),r = 1.0,activity = None): bs.Actor.__init__(self) self.radius = r if position1 is None: self.position1 = self.getRandomPosition(activity) else : self.position1 = position1 self.position2 = self.getRandomPosition(activity) self.portal1Material = bs.Material() self.portal1Material.addActions(conditions=(('theyHaveMaterial', bs.getSharedObject('playerMaterial'))),actions=(("modifyPartCollision","collide",True), ("modifyPartCollision","physical",False), ("call","atConnect", self.Portal1))) self.portal2Material = bs.Material() self.portal2Material.addActions(conditions=(('theyHaveMaterial', bs.getSharedObject('playerMaterial'))),actions=(("modifyPartCollision","collide",True), ("modifyPartCollision","physical",False), ("call","atConnect", self.Portal2))) # uncomment the following lines to teleport objects also # self.portal1Material.addActions(conditions=(('theyHaveMaterial', bs.getSharedObject('objectMaterial')),'and',('theyDontHaveMaterial', bs.getSharedObject('playerMaterial'))),actions=(("modifyPartCollision","collide",True), # ("modifyPartCollision","physical",False), # ("call","atConnect", self.objPortal1))) # self.portal2Material.addActions(conditions=(('theyHaveMaterial', bs.getSharedObject('objectMaterial')),'and',('theyDontHaveMaterial', bs.getSharedObject('playerMaterial'))),actions=(("modifyPartCollision","collide",True), # ("modifyPartCollision","physical",False), # ("call","atConnect", self.objPortal2))) self.node1 = bs.newNode('region', attrs={'position':(self.position1[0],self.position1[1],self.position1[2]), 'scale':(self.radius,self.radius,self.radius), 'type':'sphere', 'materials':[self.portal1Material]}) self.visualRadius = bs.newNode('shield',attrs={'position':self.position1,'color':color,'radius':0.1}) bsUtils.animate(self.visualRadius,"radius",{0:0,500:self.radius*2}) bsUtils.animateArray(self.node1,"scale",3,{0:(0,0,0),500:(self.radius,self.radius,self.radius)}) self.node2 = bs.newNode('region', attrs={'position':(self.position2[0],self.position2[1],self.position2[2]), 'scale':(self.radius,self.radius,self.radius), 'type':'sphere', 'materials':[self.portal2Material]}) self.visualRadius2 = bs.newNode('shield',attrs={'position':self.position2,'color':color,'radius':0.1}) bsUtils.animate(self.visualRadius2,"radius",{0:0,500:self.radius*2}) bsUtils.animateArray(self.node2,"scale",3,{0:(0,0,0),500:(self.radius,self.radius,self.radius)})
def spawnPlayerSpaz(self, player, position=(0, 0, 0), angle=None): posList = ((0, 5, 0), (9, 11, 0), (0, 12, 0), (-11, 11, 0)) try: pos = posList[player.gameData['lastPoint']] except: pos = (0, 5, 0) position = (pos[0] + random.random() * 2 - 1, pos[1], pos[2]) name = player.getName() color = player.color highlight = player.highlight lightColor = bsUtils.getNormalizedColor(color) displayColor = bs.getSafeColor(color, targetIntensity=0.75) spaz = bs.PlayerSpaz(color=color, highlight=highlight, character=player.character, player=player) player.setActor(spaz) 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 if self._raceStarted: spaz.connectControlsToPlayer() 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) if not self._raceStarted: player.gameData['lastPoint'] = 0 bs.gameTimer(250, bs.Call(self.checkPt, player)) return spaz
def light(): abc = bs.newNode('light', attrs={ 'position': (0, 10, 0), 'color': (0.2, 0.2, 0.4), 'volumeIntensityScale': 1.0, 'radius': 10 }) bsUtils.animate(abc, "intensity", { 0: 1, 50: 10, 150: 5, 250: 0, 260: 10, 410: 5, 510: 0 }) ho = random.random() * 20000 from random import randint ho = (randint(5, 20) * 1000) bs.gameTimer(int(ho), light)
def spawnPlayer(self, player): position = self.getMap().getFFAStartPosition(self.players) angle = 20 name = player.getName() lightColor = bsUtils.getNormalizedColor(player.color) displayColor = bs.getSafeColor(player.color, targetIntensity=0.75) spaz = HunterSpaz(color=player.color, highlight=player.highlight, character=player.character, player=player, force_fly=False, allowAim=self.settings[JungleHunterLanguage.aimHelp]) 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) # lets reconnect this player's controls to this # spaz but *without* the ability to attack or pick stuff up spaz.connectControlsToPlayer(enablePunch=False, enableBomb=True, enablePickUp=False) spaz.initArcher() spaz.playBigDeathSound = True return spaz
def spawnPlayerSpaz(self, player): position = self.init_position if self.teamsOrFFA() == 'teams': position = self.team_init_positions[player.getTeam().getID() % 2] angle = None name = player.getName() color = player.color highlight = player.highlight lightColor = bsUtils.getNormalizedColor(color) displayColor = bs.getSafeColor(color, targetIntensity=0.75) spaz = AbyssPlayerSpaz(color=color, highlight=highlight, character=player.character, player=player) player.setActor(spaz) spaz.node.name = name spaz.node.nameColor = displayColor spaz.connectControlsToPlayer(enablePunch=False, enableBomb=True, enablePickUp=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) spaz.playBigDeathSound = True return spaz
def __init__(self, position=(0, 1, 0), velocity=(0, 0, 0), bombType='normal', blastRadius=2.0, sourcePlayer=None, owner=None): bs.Actor.__init__(self) self.up = False factory = BasketBallFactory() self.bombType = 'basketball' self._exploded = False self.blastRadius = blastRadius self._explodeCallbacks = [] self.sourcePlayer = sourcePlayer self.hitType = 'impact' self.hitSubType = 'basketball' owner = bs.Node(None) self.owner = owner materials = (factory.bombMaterial, bs.getSharedObject('objectMaterial')) materials = materials + (factory.normalSoundMaterial, ) materials = materials + (factory.basketBallMaterial, ) self.node = bs.newNode('prop', delegate=self, attrs={ 'position': position, 'velocity': velocity, 'body': 'sphere', 'model': factory.bombModel, 'shadowSize': 0.3, 'colorTexture': bs.getTexture('bonesColorMask'), 'reflection': 'soft', 'reflectionScale': [1.5], 'materials': materials }) bsUtils.animate(self.node, "modelScale", {0: 0, 200: 1.3, 260: 1})
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 checkForScore(self, box): if box.scored: return player = box.claimedBy if player.actor.isAlive() and player.actor.node.holdNode.exists(): if player.actor.node.holdNode == box.node: box.scored = True player.getTeam().gameData['score'] += 1 bsUtils.animate(box.node, "modelScale", { 0: 1.0, 150: 0.5, 300: 0.0 }) bs.gameTimer(300, bs.WeakCall(box.handleMessage, bs.DieMessage())) self._updateScoreBoard() for playa in player.getTeam().players: try: playa.actor.node.handleMessage('celebrate', 2000) except Exception: pass if player.getTeam( ).gameData['score'] == self.settings['Score to Win']: player.getTeam().gameData['survivalSeconds'] = ( bs.getGameTime() - self._startGameTime) / 1000 self.winners.append(player.getTeam()) for playa in player.getTeam().players: self._flashPlayer(playa, 1.0) playa.actor.handleMessage( bs.DieMessage(immediate=True)) bs.playSound(self._scoreSound) bs.playSound(self._cheerSound) else: #print('nobody scored') box.handleMessage(bs.HitMessage()) else: box.handleMessage(bs.HitMessage())
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 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 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 __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), 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 __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), 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 __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 spawnPlayer(self, player): """This next line is the default spawn line. But we need to spawn our special guy""" #self.spawnPlayerSpaz(player,self._getSpawnPoint(player)) #position = self._getSpawnPoint(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 = 20 #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 = PlayerSpaz_Zom(color=player.color, highlight=player.highlight, character=player.character, player=player) player.setActor(spaz) #For some reason, I can't figure out how to get a list of all spaz. #Therefore, I am making the list here so I can get which spaz belongs #to the player supplied by HitMessage. self.spazList.append(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( enablePickUp=False ) #Unfortunately, I can't figure out how to prevent picking up other player but allow other pickup. 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) #Start code to spawn special guy: #End of code to spawn special guy if not self._soloMode: bs.gameTimer(300, bs.Call(self._printLives, player)) # if we have any icons, update their state for icon in player.gameData['icons']: icon.handlePlayerSpawned()