def on_begin(self) -> None: super().on_begin() self.setup_standard_time_limit(self.settings['Time Limit']) self.setup_standard_powerup_drops() self._flag_pos = self.map.get_flag_position(None) ba.timer(1.0, self._tick, repeat=True) self._flag_state = self.FLAG_NEW self.project_flag_stand(self._flag_pos) self._flag = stdflag.Flag(position=self._flag_pos, touchable=False, color=(1, 1, 1)) self._flag_light = ba.newnode('light', attrs={ 'position': self._flag_pos, 'intensity': 0.2, 'height_attenuated': False, 'radius': 0.4, 'color': (0.2, 0.2, 0.2) }) # Flag region. flagmats = [ self._flag_region_material, ba.sharedobj('region_material') ] ba.newnode('region', attrs={ 'position': self._flag_pos, 'scale': (1.8, 1.8, 1.8), 'type': 'sphere', 'materials': flagmats }) self._update_flag_state()
def _spawn_flag(self) -> None: ba.playsound(self._swipsound) self._flash_flag_spawn() assert self._flag_spawn_pos is not None self._flag = stdflag.Flag(dropped_timeout=20, position=self._flag_spawn_pos) self._flag_state = self.FLAG_NEW self._flag_light = ba.newnode('light', owner=self._flag.node, attrs={ 'intensity': 0.2, 'radius': 0.3, 'color': (0.2, 0.2, 0.2) }) assert self._flag.node self._flag.node.connectattr('position', self._flag_light, 'position') self._update_flag_state()
def _set_chosen_one_player(self, player: Optional[ba.Player]) -> None: try: for p_other in self.players: p_other.gamedata['chosen_light'] = None ba.playsound(self._swipsound) if not player: assert self._flag_spawn_pos is not None self._flag = flag.Flag(color=(1, 0.9, 0.2), position=self._flag_spawn_pos, touchable=False) self._chosen_one_player = None # Create a light to highlight the flag; # this will go away when the flag dies. ba.newnode('light', owner=self._flag.node, attrs={ 'position': self._flag_spawn_pos, 'intensity': 0.6, 'height_attenuated': False, 'volume_intensity_scale': 0.1, 'radius': 0.1, 'color': (1.2, 1.2, 0.4) }) # Also an extra momentary flash. self._flash_flag_spawn() else: if player.actor is not None: self._flag = None self._chosen_one_player = player if player.actor: if self.settings['Chosen One Gets Shield']: player.actor.handlemessage( ba.PowerupMessage('shield')) if self.settings['Chosen One Gets Gloves']: player.actor.handlemessage( ba.PowerupMessage('punch')) # Use a color that's partway between their team color # and white. color = [ 0.3 + c * 0.7 for c in ba.normalized_color(player.team.color) ] light = player.gamedata['chosen_light'] = ba.NodeActor( ba.newnode('light', attrs={ 'intensity': 0.6, 'height_attenuated': False, 'volume_intensity_scale': 0.1, 'radius': 0.13, 'color': color })) assert light.node ba.animate(light.node, 'intensity', { 0: 1.0, 0.2: 0.4, 0.4: 1.0 }, loop=True) assert isinstance(player.actor, playerspaz.PlayerSpaz) player.actor.node.connectattr('position', light.node, 'position') except Exception: ba.print_exception('EXC in _set_chosen_one_player')