コード例 #1
0
def creep(arguments):

    if arguments == [] or arguments == ['']:
        return

    elif arguments[0] == 'all':

        activity = _ba.get_foreground_host_activity()

        for players in activity.players:
            node = players.actor.node

            if node.head_model != None:
                node.head_model = None
                node.handlemessage(ba.PowerupMessage(poweruptype='punch'))
                node.handlemessage(ba.PowerupMessage(poweruptype='shield'))

    else:
        try:
            player = int(arguments[0])
            activity = _ba.get_foreground_host_activity()

            node = activity.players[player].actor.node

            if node.head_model != None:
                node.head_model = None
                node.handlemessage(ba.PowerupMessage(poweruptype='punch'))
                node.handlemessage(ba.PowerupMessage(poweruptype='shield'))
        except:
            return
コード例 #2
0
def curse(arguments, clientid):

    if arguments == [] or arguments == ['']:
        myself = clientid_to_myself(clientid)
        handlemsg(myself, ba.PowerupMessage(poweruptype='curse'))

    elif arguments[0] == 'all':
        handlemsg_all(ba.PowerupMessage(poweruptype='curse'))

    else:
        try:
            req_player = int(arguments[0])
            handlemsg(req_player, ba.PowerupMessage(poweruptype='curse'))
        except:
            return
コード例 #3
0
    def _touch_handler(self):
        """The action handler of an item if it touches a target."""
        node: ba.Node = ba.getcollision().opposingnode
        if node not in self.cured_nodes:
            node.handlemessage(ba.PowerupMessage(poweruptype='health'))

            self.cured_nodes.append(node)
コード例 #4
0
def heal_callback(playerdata: PlayerData, args):
    activity = ba.getactivity()
    if len(args) < 2:
        chatmessage(get_locale('chat_command_not_args_error'))
    elif args[1] == 'all':
        for i in activity.players:
            if i.actor and hasattr(i.actor, 'node'):
                assert isinstance(i.actor.node, ba.Node)
                i.actor.node.handlemessage(
                    ba.PowerupMessage(poweruptype='health'))
    else:
        player = activity.players[int(args[0])]
        if player.actor and hasattr(player.actor, 'node'):
            assert isinstance(player.actor.node, ba.Node)
            player.actor.node.handlemessage(
                ba.PowerupMessage(poweruptype='health'))
コード例 #5
0
ファイル: powerupbox.py プロジェクト: ShifengHuGit/ballistica
    def handlemessage(self, msg: Any) -> Any:
        # pylint: disable=too-many-branches
        if __debug__:
            self._handlemessage_sanity_check()

        if isinstance(msg, ba.PowerupAcceptMessage):
            factory = get_factory()
            assert self.node
            if self.poweruptype == 'health':
                ba.playsound(factory.health_powerup_sound,
                             3,
                             position=self.node.position)
            ba.playsound(factory.powerup_sound, 3, position=self.node.position)
            self._powersgiven = True
            self.handlemessage(ba.DieMessage())

        elif isinstance(msg, _TouchedMessage):
            if not self._powersgiven:
                node = ba.get_collision_info('opposing_node')
                if node:
                    node.handlemessage(
                        ba.PowerupMessage(self.poweruptype,
                                          source_node=self.node))

        elif isinstance(msg, ba.DieMessage):
            if self.node:
                if msg.immediate:
                    self.node.delete()
                else:
                    ba.animate(self.node, 'model_scale', {0: 1, 0.1: 0})
                    ba.timer(0.1, self.node.delete)

        elif isinstance(msg, ba.OutOfBoundsMessage):
            self.handlemessage(ba.DieMessage())

        elif isinstance(msg, ba.HitMessage):
            # Don't die on punches (that's annoying).
            if msg.hit_type != 'punch':
                self.handlemessage(ba.DieMessage())
        else:
            super().handlemessage(msg)
コード例 #6
0
    def handlemessage(self, msg: Any) -> Any:
        assert not self.expired

        if isinstance(msg, ba.PowerupAcceptMessage):
            factory = PowerupBoxFactory.get()
            assert self.node
            if self.poweruptype == 'health':
                ba.playsound(factory.health_powerup_sound,
                             3,
                             position=self.node.position)
            ba.playsound(factory.powerup_sound, 3, position=self.node.position)
            self._powersgiven = True
            self.handlemessage(ba.DieMessage())

        elif isinstance(msg, _TouchedMessage):
            if not self._powersgiven:
                node = ba.getcollision().opposingnode
                node.handlemessage(
                    ba.PowerupMessage(self.poweruptype, sourcenode=self.node))

        elif isinstance(msg, ba.DieMessage):
            if self.node:
                if msg.immediate:
                    self.node.delete()
                else:
                    ba.animate(self.node, 'model_scale', {0: 1, 0.1: 0})
                    ba.timer(0.1, self.node.delete)

        elif isinstance(msg, ba.OutOfBoundsMessage):
            self.handlemessage(ba.DieMessage())

        elif isinstance(msg, ba.HitMessage):
            # Don't die on punches (that's annoying).
            if msg.hit_type != 'punch':
                self.handlemessage(ba.DieMessage())
        else:
            return super().handlemessage(msg)
        return None
コード例 #7
0
ファイル: callbacks.py プロジェクト: BombDash/BombDash-server
def lucky_block_callback(self: stdspaz.Spaz, msg: ba.PowerupMessage):
    event_number = random.randint(1, 15)

    if event_number in (1, 2, 3):
        powerup_type = stdpowerup.PowerupBoxFactory().get_random_powerup_type()

        self.node.handlemessage(ba.PowerupMessage(poweruptype=powerup_type))
    elif event_number == 4:
        ba.camerashake(1)
        ba.emitfx(position=(self.node.position[0], self.node.position[1] + 4,
                            self.node.position[2]),
                  velocity=(0, 0, 0),
                  count=700,
                  spread=0.7,
                  chunk_type='spark')

        powerup_type = stdpowerup.PowerupBoxFactory.get(
        ).get_random_powerup_type()

        stdpowerup.PowerupBox(position=(self.node.position[0],
                                        self.node.position[1] + 4,
                                        self.node.position[2]),
                              poweruptype=powerup_type,
                              expire=True).autoretain()

        powerup_type = stdpowerup.PowerupBoxFactory.get(
        ).get_random_powerup_type()

        stdpowerup.PowerupBox(position=(self.node.position[0],
                                        self.node.position[1] + 4,
                                        self.node.position[2]),
                              poweruptype=powerup_type,
                              expire=True).autoretain()

        powerup_type = stdpowerup.PowerupBoxFactory.get(
        ).get_random_powerup_type()

        stdpowerup.PowerupBox(position=(self.node.position[0],
                                        self.node.position[1] + 4,
                                        self.node.position[2]),
                              poweruptype=powerup_type,
                              expire=True).autoretain()
    elif event_number == 5:
        stdbomb.Bomb(position=(self.node.position[0],
                               self.node.position[1] + 3,
                               self.node.position[2]),
                     source_player=self.source_player,
                     owner=self.node,
                     blast_radius=6).autoretain()
    elif event_number == 6:
        self.node.handlemessage(ba.FreezeMessage())
    elif event_number == 7:
        chunk_type = ('ice', 'rock', 'metal', 'spark', 'splinter', 'slime')

        ba.emitfx(position=self.node.position,
                  velocity=(random.random() * 2, random.random() * 2,
                            random.random() * 2),
                  count=600,
                  spread=random.random(),
                  chunk_type=random.choice(chunk_type))

        ba.camerashake(1)
        ba.playsound(ba.getsound('corkPop'))  # position=self.node.position?
    elif event_number == 8:
        position = self.node.position

        def rain_wrapper():
            p_type = stdpowerup.PowerupBoxFactory.get(
            ).get_random_powerup_type()

            new_position = (-10 + position[0] + random.random() * 20,
                            position[1] + 6,
                            -10 + position[2] + random.random() * 20)

            stdpowerup.PowerupBox(poweruptype=p_type,
                                  position=new_position).autoretain()

            if random.random() > 0.04:
                ba.timer(0.1, rain_wrapper)

        rain_wrapper()
    elif event_number == 9:
        stdbomb.Blast(position=self.node.position,
                      velocity=self.node.velocity,
                      blast_radius=1.0,
                      blast_type='normal',
                      source_player=None,
                      hit_type='punch',
                      hit_subtype='normal')
    elif event_number == 10:

        def blast(x: int, y: int, z: int) -> None:
            # add sound
            ba.NodeActor(node=ba.newnode('scorch',
                                         attrs={
                                             'position': (x, z, y),
                                             'size': 0.2,
                                             'big': False,
                                         })).autoretain()

        def smoke(x: int, y: int, z: int) -> None:
            ba.emitfx(position=(x, z, y),
                      velocity=(0, 2, 0),
                      count=1,
                      emit_type='tendrils',
                      tendril_type='smoke')
            ba.emitfx(position=(x, z, y),
                      velocity=(0, 2, 0),
                      count=int(1.0 + random.random() * 2),
                      scale=0.8,
                      spread=1.5,
                      chunk_type='spark')

        star_positions = [
            (2, 0),
            (0, 2),
            (-1.2, -1.6),
            (1.82, 0.83),
            (-1.83, 0.82),
            (1.23, -1.57),
            (-1.25, 1.56),
            (-0.65, 1.89),
            (0.82, 1.82),
            (1.27, 1.55),
            (1.82, -0.84),
            (0.31, -1.98),
            (-0.42, -1.96),
            (-1.75, -0.96),
            (-2, -0.14),
            (-0.69, -0.07),
            (-0.39, 0.82),
            (0.41, 0.82),
            (0.71, -0.06),
            (0.01, -0.62),
            (-0.99, 0.82),
            (-1.26, 0.37),
            (-0.89, -0.65),
            (-0.52, -1.05),
            (0.59, -1.07),
            (0.96, -0.8),
            (1.22, 0.35),
            (1.07, 0.82),
            (0.21, 1.39),
            (-0.17, 1.48),
            # ---
            (-1.94, 0.47),
            (-1.51, 1.31),
            (-0.95, 1.76),
            (-0.38, 1.96),
            (0.45, 1.95),
            (1.05, 1.7),
            (1.57, 1.24),
            (1.94, 0.49),
            (1.96, -0.42),
            (1.62, -1.17),
            (0.84, -1.82),
            (-0.78, -1.84),
            (-1.5, -1.33),
            (-1.91, -0.59),
            (-1.99, 0.17),
            (-1, 0.17),
            (-0.7, 0.82),
            (-0.27, 1.19),
            (0.29, 1.15),
            (0.77, 0.82),
            (1, 0.17),
            (0.84, -0.42),
            (0.31, -0.85),
            (-0.8, -1.27),
            (-1, -1),
            (-0.56, 0.33),
            (-0.47, 0.61),
            (0.52, 0.51),
            (-0.1, 0.82),
            (0.13, 0.82),
            (0.6, 0.27),
            (0.46, -0.27),
            (0.29, -0.4),
            (-0.44, -0.27),
            (-0.24, -0.42),
            (-1.36, 0.82),
            (-1.53, 0.59),
            (1.35, 0.83),
            (1.55, 0.61),
            (0.85, -1.28),
            (1.08, -1.13),
            (0.78, -0.34),
            (-0.21, -0.8),
            (0.11, 1.68)
        ]

        class Sparkling(ba.Actor):
            def __init__(self, position: Sequence[float], target: ba.Node):
                super().__init__()
                # nah; nodes not needed
                self.position = position
                self.position = (self.position[0], self.position[1] + 0.5,
                                 self.position[2])
                self.target = target

                ba.timer(0.001, ba.WeakCall(self._update))

            def _sparkle(self):
                ba.emitfx(position=self.position,
                          velocity=(0, 1, 0),
                          count=int(random.random() * 5 + 5),
                          scale=0.8,
                          spread=0.3,
                          chunk_type='spark')

            def _blast(self):
                stdbomb.Blast(position=self.position,
                              velocity=self.target.velocity,
                              blast_radius=2,
                              blast_type='normal',
                              source_player=None,
                              hit_type='punch',
                              hit_subtype='normal').autoretain()

            def _update(self):
                if not self.target:
                    del self  # commit suicide because we have no goal in our existing :(
                    return
                d = ba.Vec3(self.target.position) - ba.Vec3(self.position)

                if d.length() < 0.1:
                    self._blast()
                    del self
                    return

                d = d.normalized() * 0.04

                from math import sin, cos

                self.position = (self.position[0] + d.x +
                                 sin(ba.time() * 2) * 0.03,
                                 self.position[1] + d.y, self.position[2] +
                                 d.z + cos(ba.time() * 2) * 0.03)
                self._sparkle()

                ba.timer(0.001, ba.WeakCall(self._update))

        def sparkling(x, y, z):
            Sparkling(position=(x, z, y), target=self.node).autoretain()

        def summon_tnt(x, y, z):
            stdbomb.Bomb(bomb_type='tnt',
                         blast_radius=3,
                         position=(x, z + 4, y),
                         velocity=(0, -10, 0)).autoretain()

        scale = 1
        delta = 0.02

        op = self.node.position
        for i, (x, y) in enumerate(star_positions):
            ba.timer(
                i * delta,
                ba.Call(blast, self.node.position[0] + x * scale,
                        self.node.position[2] + y * scale,
                        self.node.position[1]))
        for i in range(4):
            ba.timer((len(star_positions)) * delta + i * 0.2,
                     ba.Call(summon_tnt, op[0], op[2], op[1]))
        ba.timer((len(star_positions)) * delta + 1.0,
                 ba.Call(sparkling, self.node.position[0],
                         self.node.position[2], self.node.position[1]))

        def last_blast():
            stdbomb.Blast(position=self.node.position,
                          velocity=(self.node.velocity[0],
                                    self.node.velocity[1] + 10,
                                    self.node.velocity[2]),
                          blast_radius=2,
                          blast_type='normal',
                          source_player=None,
                          hit_type='punch',
                          hit_subtype='normal').autoretain()

        # ba.timer(
        #     2 * len(star_positions) * delta + 0.2,
        #     last_blast)

    elif event_number == 11:
        offset = -15
        case = 1 if random.random() < 0.5 else -1
        while offset < 15:
            velocity = (case * (12 + 8 * random.random()), -0.1, 0)
            stdbomb.Bomb(bomb_type='tnt',
                         position=(self.node.position[0] - case * 10,
                                   self.node.position[1] + 3,
                                   self.node.position[2] + offset),
                         velocity=velocity).autoretain()

            offset += 1.5
    elif event_number == 12:
        color = {
            0.0: (0, 0, 3),
            0.5: (0, 3, 0),
            1.0: (3, 0, 0),
            1.5: (0, 0, 3)
        }

        # FIXME
        # ba.animate_array(self.node, 'color', 3, color, True)
        # self.node.handlemessage('celebrate', 100000000)
    elif event_number == 13:
        CompanionCube(position=(self.node.position[0],
                                self.node.position[1] + 1,
                                self.node.position[2]),
                      velocity=(0, 10, 0)).autoretain()
    elif event_number == 14:
        ba.emitfx(position=self.node.position,
                  count=100,
                  emit_type='tendrils',
                  tendril_type='smoke')

    elif event_number == 15:

        def drop_man():
            botset: stdbot.SpazBotSet
            activity = ba.getactivity()
            if not hasattr(activity, 'botset'):
                activity.botset = botset = stdbot.SpazBotSet()
            botset = activity.botset
            aoi_bounds = self.activity.globalsnode.area_of_interest_bounds
            botset.spawn_bot(
                stdbot.BrawlerBotLite,
                (random.randrange(int(aoi_bounds[0]),
                                  int(aoi_bounds[3]) + 1), aoi_bounds[4] - 1,
                 random.randrange(int(aoi_bounds[2]),
                                  int(aoi_bounds[5]) + 1)),
                spawn_time=0.001)

        def lightning_bolt(position, radius=1):
            ba.camerashake(4)
            vignette_outer = self.activity.globalsnode.vignette_outer
            # if ba.getactivity().tint is None:
            #     ba.getactivity().std_tint = ba.sharedobj('globals').vignette_outer
            #     vignette_outer = ba.sharedobj('globals').vignette_outer
            # else:
            #     vignette_outer = ba.getactivity().tint

            light = ba.newnode('light',
                               attrs={
                                   'position': position,
                                   'color': (0.4, 0.4, 0.8),
                                   'volume_intensity_scale': 1.0,
                                   'radius': radius
                               })

            ba.animate(light,
                       'intensity', {
                           0: 1,
                           50: radius,
                           150: radius / 2,
                           250: 0,
                           260: radius,
                           410: radius / 2,
                           510: 0
                       },
                       timeformat=ba.TimeFormat.MILLISECONDS,
                       suppress_format_warning=True)

            ba.animate_array(self.activity.globalsnode, 'vignette_outer', 3, {
                0: vignette_outer,
                0.2: (0.2, 0.2, 0.2),
                0.51: vignette_outer
            })

            # ba.playsound(
            #     ba.getsound('grom'),
            #     volume=10,
            #     position=(0, 10, 0))

        lightning_bolt(self.node.position)

        for time in range(15):
            ba.timer(time, drop_man)
コード例 #8
0
    def _set_chosen_one_player(self, player: Optional[Player]) -> None:
        existing = self._get_chosen_one_player()
        if existing:
            existing.chosen_light = None
        ba.playsound(self._swipsound)
        if not player:
            assert self._flag_spawn_pos is not None
            self._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:
                self._flag = None
                self._chosen_one_player = player

                if self._chosen_one_gets_shield:
                    player.actor.handlemessage(ba.PowerupMessage('shield'))
                if self._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.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)
                player.actor.node.connectattr('position', light.node,
                                              'position')
コード例 #9
0
ファイル: callbacks.py プロジェクト: egorkAh/BombDash-server
def lucky_block_callback(self: stdspaz.Spaz, msg: ba.PowerupMessage):
    event_number = random.randint(1, 15)

    if event_number in (1, 2, 3):
        powerup_type = stdpowerup.PowerupBoxFactory().get_random_powerup_type()

        self.node.handlemessage(ba.PowerupMessage(poweruptype=powerup_type))
    elif event_number == 4:
        ba.camerashake(1)
        ba.emitfx(position=(self.node.position[0], self.node.position[1] + 4,
                            self.node.position[2]),
                  velocity=(0, 0, 0),
                  count=700,
                  spread=0.7,
                  chunk_type='spark')

        powerup_type = stdpowerup.PowerupBoxFactory.get(
        ).get_random_powerup_type()

        stdpowerup.PowerupBox(position=(self.node.position[0],
                                        self.node.position[1] + 4,
                                        self.node.position[2]),
                              poweruptype=powerup_type,
                              expire=True).autoretain()

        powerup_type = stdpowerup.PowerupBoxFactory.get(
        ).get_random_powerup_type()

        stdpowerup.PowerupBox(position=(self.node.position[0],
                                        self.node.position[1] + 4,
                                        self.node.position[2]),
                              poweruptype=powerup_type,
                              expire=True).autoretain()

        powerup_type = stdpowerup.PowerupBoxFactory.get(
        ).get_random_powerup_type()

        stdpowerup.PowerupBox(position=(self.node.position[0],
                                        self.node.position[1] + 4,
                                        self.node.position[2]),
                              poweruptype=powerup_type,
                              expire=True).autoretain()
    elif event_number == 5:
        stdbomb.Bomb(position=(self.node.position[0],
                               self.node.position[1] + 3,
                               self.node.position[2]),
                     source_player=self.source_player,
                     owner=self.node,
                     blast_radius=6).autoretain()
    elif event_number == 6:
        self.node.handlemessage(ba.FreezeMessage())
    elif event_number == 7:
        chunk_type = ('ice', 'rock', 'metal', 'spark', 'splinter', 'slime')

        ba.emitfx(position=self.node.position,
                  velocity=(random.random() * 2, random.random() * 2,
                            random.random() * 2),
                  count=600,
                  spread=random.random(),
                  chunk_type=random.choice(chunk_type))

        ba.camerashake(1)
        ba.playsound(ba.getsound('corkPop'))  # position=self.node.position?
    elif event_number == 8:
        position = self.node.position

        def rain_wrapper():
            p_type = stdpowerup.PowerupBoxFactory.get(
            ).get_random_powerup_type()

            new_position = (-10 + position[0] + random.random() * 20,
                            position[1] + 6,
                            -10 + position[2] + random.random() * 20)

            stdpowerup.PowerupBox(poweruptype=p_type,
                                  position=new_position).autoretain()

            if random.random() > 0.04:
                ba.timer(0.1, rain_wrapper)

        rain_wrapper()
    elif event_number == 9:
        stdbomb.Blast(position=self.node.position,
                      velocity=self.node.velocity,
                      blast_radius=1.0,
                      blast_type='normal',
                      source_player=None,
                      hit_type='punch',
                      hit_subtype='normal')
    elif event_number == 10:  # Blast-square under spaz
        x = self.node.position[0] - 2
        while x < self.node.position[0] + 2:
            y = self.node.position[2] - 2
            while y < self.node.position[2] + 2:
                stdbomb.Blast(position=(x, self.node.position[1], y),
                              velocity=(self.node.velocity[0],
                                        self.node.velocity[1] + 10,
                                        self.node.velocity[2]),
                              blast_radius=0.5,
                              blast_type='normal',
                              source_player=None,
                              hit_type='punch',
                              hit_subtype='normal')

                y += 1

            x += 1
    elif event_number == 11:
        offset = -15
        case = 1 if random.random() < 0.5 else -1
        while offset < 15:
            velocity = (case * (12 + 8 * random.random()), -0.1, 0)
            stdbomb.Bomb(bomb_type='tnt',
                         position=(self.node.position[0] - case * 10,
                                   self.node.position[1] + 3,
                                   self.node.position[2] + offset),
                         velocity=velocity).autoretain()

            offset += 1.5
    elif event_number == 12:
        color = {
            0.0: (0, 0, 3),
            0.5: (0, 3, 0),
            1.0: (3, 0, 0),
            1.5: (0, 0, 3)
        }

        # FIXME
        # ba.animate_array(self.node, 'color', 3, color, True)
        # self.node.handlemessage('celebrate', 100000000)
    elif event_number == 13:
        CompanionCube(position=(self.node.position[0],
                                self.node.position[1] + 1,
                                self.node.position[2]),
                      velocity=(0, 10, 0)).autoretain()
    elif event_number == 14:
        ba.emitfx(position=self.node.position,
                  count=100,
                  emit_type='tendrils',
                  tendril_type='smoke')

    elif event_number == 15:

        def drop_man():
            botset: stdbot.SpazBotSet
            activity = ba.getactivity()
            if not hasattr(activity, 'botset'):
                activity.botset = botset = stdbot.SpazBotSet()
            botset = activity.botset
            aoi_bounds = self.activity.globalsnode.area_of_interest_bounds
            botset.spawn_bot(
                stdbot.BrawlerBotLite,
                (random.randrange(int(aoi_bounds[0]),
                                  int(aoi_bounds[3]) + 1), aoi_bounds[4] - 1,
                 random.randrange(int(aoi_bounds[2]),
                                  int(aoi_bounds[5]) + 1)),
                spawn_time=0.001)

        def lightning_bolt(position, radius=1):
            ba.camerashake(4)
            vignette_outer = self.activity.globalsnode.vignette_outer
            # if ba.getactivity().tint is None:
            #     ba.getactivity().std_tint = ba.sharedobj('globals').vignette_outer
            #     vignette_outer = ba.sharedobj('globals').vignette_outer
            # else:
            #     vignette_outer = ba.getactivity().tint

            light = ba.newnode('light',
                               attrs={
                                   'position': position,
                                   'color': (0.4, 0.4, 0.8),
                                   'volume_intensity_scale': 1.0,
                                   'radius': radius
                               })

            ba.animate(light,
                       'intensity', {
                           0: 1,
                           50: radius,
                           150: radius / 2,
                           250: 0,
                           260: radius,
                           410: radius / 2,
                           510: 0
                       },
                       timeformat=ba.TimeFormat.MILLISECONDS,
                       suppress_format_warning=True)

            ba.animate_array(self.activity.globalsnode, 'vignette_outer', 3, {
                0: vignette_outer,
                0.2: (0.2, 0.2, 0.2),
                0.51: vignette_outer
            })

            # ba.playsound(
            #     ba.getsound('grom'),
            #     volume=10,
            #     position=(0, 10, 0))

        lightning_bolt(self.node.position)

        for time in range(15):
            ba.timer(time, drop_man)
コード例 #10
0
ファイル: chosenone.py プロジェクト: Dmitry450/ballistica
    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')