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 _setChosenOnePlayer(self,player): try: for p in self.players: p.gameData['chosenLight'] = 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['Chosen One Gets Shield']: player.actor.handleMessage(bs.PowerupMessage('shield')) if self.settings['Chosen One Gets Gloves']: player.actor.handleMessage(bs.PowerupMessage('punch')) # 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['chosenLight'] = 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 _updateFlagState(self): holdingTeams = set(player.getTeam() for player in self.players if player.gameData['atFlag']) prevState = self._flagState if len(holdingTeams) > 1: self._flagState = self.FLAG_CONTESTED self._scoringTeam = None self._flagLight.color = (0.6,0.6,0.1) self._flag.node.color = (1.0,1.0,0.4) elif len(holdingTeams) == 1: holdingTeam = list(holdingTeams)[0] self._flagState = self.FLAG_HELD self._scoringTeam = weakref.ref(holdingTeam) self._flagLight.color = bs.getNormalizedColor(holdingTeam.color) self._flag.node.color = holdingTeam.color else: self._flagState = self.FLAG_UNCONTESTED self._scoringTeam = None self._flagLight.color = (0.2,0.2,0.2) self._flag.node.color = (1,1,1) if self._flagState != prevState: bs.playSound(self._swipSound)
def _updateFlagState(self): for team in self.teams: team.gameData['holdingFlag'] = False self._holdingPlayers = [] for player in self.players: try: if player.actor.isAlive( ) and player.actor.node.holdNode.exists(): holdingFlag = ( player.actor.node.holdNode.getNodeType() == 'flag') else: holdingFlag = False except Exception: bs.printException("exception checking hold flag") if holdingFlag: self._holdingPlayers.append(player) player.getTeam().gameData['holdingFlag'] = True holdingTeams = set(t for t in self.teams if t.gameData['holdingFlag']) prevState = self._flagState if len(holdingTeams) > 1: self._flagState = self.FLAG_CONTESTED self._scoringTeam = None self._flag.light.color = (0.6, 0.6, 0.1) self._flag.node.color = (1.0, 1.0, 0.4) elif len(holdingTeams) == 1: holdingTeam = list(holdingTeams)[0] self._flagState = self.FLAG_HELD self._scoringTeam = holdingTeam self._flag.light.color = bs.getNormalizedColor(holdingTeam.color) self._flag.node.color = holdingTeam.color else: self._flagState = self.FLAG_UNCONTESTED self._scoringTeam = None self._flag.light.color = (0.2, 0.2, 0.2) self._flag.node.color = (1, 1, 1) if self._flagState != prevState: bs.playSound(self._swipSound)