Ejemplo n.º 1
0
 def _spawn_bot(self, bot_type: type[SpazBot], pos: Sequence[float],
                on_spawn_call: Optional[Callable[[SpazBot], Any]]) -> None:
     spaz = bot_type()
     ba.playsound(self._spawn_sound, position=pos)
     assert spaz.node
     spaz.node.handlemessage('flash')
     spaz.node.is_area_of_interest = False
     spaz.handlemessage(ba.StandMessage(pos, random.uniform(0, 360)))
     self.add_bot(spaz)
     self._spawning_count -= 1
     if on_spawn_call is not None:
         on_spawn_call(spaz)
Ejemplo n.º 2
0
    def _second_portal_teleportation(self):
        """Teleportation of a node that entered the second portal."""
        node = ba.getcollision().opposingnode
        name = node.getname()

        if self.already_teleported.get(name):
            return

        def wrapper(nodename):
            self.already_teleported[nodename] = False

        hold_node = node.hold_node

        node.handlemessage(ba.StandMessage(position=self.first_node.position))

        if hold_node:
            self._second_portal_handler(hold_node, offset=(0, 1, 0))
            node.hold_node = hold_node

        self.already_teleported[name] = True
        ba.timer(1, ba.Call(wrapper, name))
Ejemplo n.º 3
0
    def _handle_base_collide(self, team: Team) -> None:
        try:
            player = ba.getcollision().opposingnode.getdelegate(
                PlayerSpaz, True).getplayer(Player, True)
        except ba.NotFoundError:
            return

        if not player.is_alive():
            return

        # If its another team's player, they scored.
        player_team = player.team
        if player_team is not team:

            # Prevent multiple simultaneous scores.
            if ba.time() != self._last_score_time:
                self._last_score_time = ba.time()
                self.stats.player_scored(player, 50, big_message=True)
                ba.playsound(self._score_sound)
                self._flash_base(team)

                # Move all players on the scoring team back to their start
                # and add flashes of light so its noticeable.
                for player in player_team.players:
                    if player.is_alive():
                        pos = player.node.position
                        light = ba.newnode('light',
                                           attrs={
                                               'position': pos,
                                               'color': player_team.color,
                                               'height_attenuated': False,
                                               'radius': 0.4
                                           })
                        ba.timer(0.5, light.delete)
                        ba.animate(light, 'intensity', {
                            0: 0,
                            0.1: 1.0,
                            0.5: 0
                        })

                        new_pos = (self.map.get_start_position(player_team.id))
                        light = ba.newnode('light',
                                           attrs={
                                               'position': new_pos,
                                               'color': player_team.color,
                                               'radius': 0.4,
                                               'height_attenuated': False
                                           })
                        ba.timer(0.5, light.delete)
                        ba.animate(light, 'intensity', {
                            0: 0,
                            0.1: 1.0,
                            0.5: 0
                        })
                        if player.actor:
                            player.actor.handlemessage(
                                ba.StandMessage(new_pos,
                                                random.uniform(0, 360)))

                # Have teammates celebrate.
                for player in player_team.players:
                    if player.actor:
                        player.actor.handlemessage(ba.CelebrateMessage(2.0))

                player_team.score += 1
                self._update_scoreboard()
                if player_team.score >= self._score_to_win:
                    self.end_game()
Ejemplo n.º 4
0
    def _handle_base_collide(self, team: ba.Team) -> None:

        # Attempt to pull a living ba.Player from what we hit.
        cnode = ba.get_collision_info('opposing_node')
        assert isinstance(cnode, ba.Node)
        actor = cnode.getdelegate()
        if not isinstance(actor, playerspaz.PlayerSpaz):
            return
        player = actor.getplayer()
        if not player or not player.is_alive():
            return

        # If its another team's player, they scored.
        player_team = player.team
        if player_team is not team:

            # Prevent multiple simultaneous scores.
            if ba.time() != self._last_score_time:
                self._last_score_time = ba.time()
                self.stats.player_scored(player, 50, big_message=True)
                ba.playsound(self._score_sound)
                self._flash_base(team)

                # Move all players on the scoring team back to their start
                # and add flashes of light so its noticeable.
                for player in player_team.players:
                    if player.is_alive():
                        if player.node:
                            pos = player.node.position
                            light = ba.newnode('light',
                                               attrs={
                                                   'position': pos,
                                                   'color': player_team.color,
                                                   'height_attenuated': False,
                                                   'radius': 0.4
                                               })
                            ba.timer(0.5, light.delete)
                            ba.animate(light, 'intensity', {
                                0: 0,
                                0.1: 1.0,
                                0.5: 0
                            })

                        new_pos = (self.map.get_start_position(
                            player_team.get_id()))
                        light = ba.newnode('light',
                                           attrs={
                                               'position': new_pos,
                                               'color': player_team.color,
                                               'radius': 0.4,
                                               'height_attenuated': False
                                           })
                        ba.timer(0.5, light.delete)
                        ba.animate(light, 'intensity', {
                            0: 0,
                            0.1: 1.0,
                            0.5: 0
                        })
                        if player.actor:
                            player.actor.handlemessage(
                                ba.StandMessage(new_pos,
                                                random.uniform(0, 360)))

                # Have teammates celebrate.
                for player in player_team.players:
                    if player.actor:
                        player.actor.handlemessage(ba.CelebrateMessage(2.0))

                player_team.gamedata['score'] += 1
                self._update_scoreboard()
                if (player_team.gamedata['score'] >=
                        self.settings_raw['Score to Win']):
                    self.end_game()