Exemplo n.º 1
0
        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
            })
Exemplo n.º 2
0
    def __init__(self,
                 position=(0, 5, 0),
                 velocity=(1, 0, 0),
                 source_player=None,
                 owner=None,
                 color=(1.0, 0.2, 0.2)) -> None:
        super().__init__()
        self.source_player = source_player
        self.owner = owner
        self._color = color
        factory = RocketFactory.get()

        self.node = ba.newnode('prop',
                               delegate=self,
                               attrs={
                                   'position': position,
                                   'velocity': velocity,
                                   'model': ba.getmodel('impactBomb'),
                                   'body': 'sphere',
                                   'color_texture': ba.gettexture(
                                       'bunnyColor'),
                                   'model_scale': 0.2,
                                   'is_area_of_interest': True,
                                   'body_scale': 0.8,
                                   'materials': [
                                       SharedObjects.get().object_material,
                                       factory.ball_material]
                               })  # yapf: disable
        self.node.extra_acceleration = (self.node.velocity[0] * 200, 0,
                                        self.node.velocity[2] * 200)

        self._life_timer = ba.Timer(
            5, ba.WeakCall(self.handlemessage, ba.DieMessage()))

        self._emit_timer = ba.Timer(0.001, ba.WeakCall(self.emit), repeat=True)
        self.base_pos_y = self.node.position[1]

        ba.camerashake(5.0)
Exemplo n.º 3
0
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)
Exemplo n.º 4
0
    def __init__(self,
                 position: Sequence[float] = (0.0, 1.0, 0.0),
                 velocity: Sequence[float] = (0.0, 0.0, 0.0),
                 blast_radius: float = 2.0,
                 blast_type: str = 'normal',
                 source_player: ba.Player = None,
                 hit_type: str = 'explosion',
                 hit_subtype: str = 'normal'):
        """Instantiate with given values."""

        # bah; get off my lawn!
        # pylint: disable=too-many-locals
        # pylint: disable=too-many-statements

        super().__init__()

        factory = get_factory()

        self.blast_type = blast_type
        self.source_player = source_player
        self.hit_type = hit_type
        self.hit_subtype = hit_subtype
        self.radius = blast_radius

        # set our position a bit lower so we throw more things upward
        rmats = (factory.blast_material, ba.sharedobj('attack_material'))
        self.node = ba.newnode('region',
                               delegate=self,
                               attrs={
                                   'position': (position[0], position[1] - 0.1,
                                                position[2]),
                                   'scale':
                                   (self.radius, self.radius, self.radius),
                                   'type':
                                   'sphere',
                                   'materials':
                                   rmats
                               })

        ba.timer(0.05, self.node.delete)

        # throw in an explosion and flash
        evel = (velocity[0], max(-1.0, velocity[1]), velocity[2])
        explosion = ba.newnode('explosion',
                               attrs={
                                   'position': position,
                                   'velocity': evel,
                                   'radius': self.radius,
                                   'big': (self.blast_type == 'tnt')
                               })
        if self.blast_type == 'ice':
            explosion.color = (0, 0.05, 0.4)

        ba.timer(1.0, explosion.delete)

        if self.blast_type != 'ice':
            ba.emitfx(position=position,
                      velocity=velocity,
                      count=int(1.0 + random.random() * 4),
                      emit_type='tendrils',
                      tendril_type='thin_smoke')
        ba.emitfx(position=position,
                  velocity=velocity,
                  count=int(4.0 + random.random() * 4),
                  emit_type='tendrils',
                  tendril_type='ice' if self.blast_type == 'ice' else 'smoke')
        ba.emitfx(position=position,
                  emit_type='distortion',
                  spread=1.0 if self.blast_type == 'tnt' else 2.0)

        # and emit some shrapnel..
        if self.blast_type == 'ice':

            def emit() -> None:
                ba.emitfx(position=position,
                          velocity=velocity,
                          count=30,
                          spread=2.0,
                          scale=0.4,
                          chunk_type='ice',
                          emit_type='stickers')

            # looks better if we delay a bit
            ba.timer(0.05, emit)

        elif self.blast_type == 'sticky':

            def emit() -> None:
                ba.emitfx(position=position,
                          velocity=velocity,
                          count=int(4.0 + random.random() * 8),
                          spread=0.7,
                          chunk_type='slime')
                ba.emitfx(position=position,
                          velocity=velocity,
                          count=int(4.0 + random.random() * 8),
                          scale=0.5,
                          spread=0.7,
                          chunk_type='slime')
                ba.emitfx(position=position,
                          velocity=velocity,
                          count=15,
                          scale=0.6,
                          chunk_type='slime',
                          emit_type='stickers')
                ba.emitfx(position=position,
                          velocity=velocity,
                          count=20,
                          scale=0.7,
                          chunk_type='spark',
                          emit_type='stickers')
                ba.emitfx(position=position,
                          velocity=velocity,
                          count=int(6.0 + random.random() * 12),
                          scale=0.8,
                          spread=1.5,
                          chunk_type='spark')

            # looks better if we delay a bit
            ba.timer(0.05, emit)

        elif self.blast_type == 'impact':  # regular bomb shrapnel

            def emit() -> None:
                ba.emitfx(position=position,
                          velocity=velocity,
                          count=int(4.0 + random.random() * 8),
                          scale=0.8,
                          chunk_type='metal')
                ba.emitfx(position=position,
                          velocity=velocity,
                          count=int(4.0 + random.random() * 8),
                          scale=0.4,
                          chunk_type='metal')
                ba.emitfx(position=position,
                          velocity=velocity,
                          count=20,
                          scale=0.7,
                          chunk_type='spark',
                          emit_type='stickers')
                ba.emitfx(position=position,
                          velocity=velocity,
                          count=int(8.0 + random.random() * 15),
                          scale=0.8,
                          spread=1.5,
                          chunk_type='spark')

            # looks better if we delay a bit
            ba.timer(0.05, emit)

        else:  # regular or land mine bomb shrapnel

            def emit() -> None:
                if self.blast_type != 'tnt':
                    ba.emitfx(position=position,
                              velocity=velocity,
                              count=int(4.0 + random.random() * 8),
                              chunk_type='rock')
                    ba.emitfx(position=position,
                              velocity=velocity,
                              count=int(4.0 + random.random() * 8),
                              scale=0.5,
                              chunk_type='rock')
                ba.emitfx(position=position,
                          velocity=velocity,
                          count=30,
                          scale=1.0 if self.blast_type == 'tnt' else 0.7,
                          chunk_type='spark',
                          emit_type='stickers')
                ba.emitfx(position=position,
                          velocity=velocity,
                          count=int(18.0 + random.random() * 20),
                          scale=1.0 if self.blast_type == 'tnt' else 0.8,
                          spread=1.5,
                          chunk_type='spark')

                # tnt throws splintery chunks
                if self.blast_type == 'tnt':

                    def emit_splinters() -> None:
                        ba.emitfx(position=position,
                                  velocity=velocity,
                                  count=int(20.0 + random.random() * 25),
                                  scale=0.8,
                                  spread=1.0,
                                  chunk_type='splinter')

                    ba.timer(0.01, emit_splinters)

                # every now and then do a sparky one
                if self.blast_type == 'tnt' or random.random() < 0.1:

                    def emit_extra_sparks() -> None:
                        ba.emitfx(position=position,
                                  velocity=velocity,
                                  count=int(10.0 + random.random() * 20),
                                  scale=0.8,
                                  spread=1.5,
                                  chunk_type='spark')

                    ba.timer(0.02, emit_extra_sparks)

            # looks better if we delay a bit
            ba.timer(0.05, emit)

        lcolor = ((0.6, 0.6, 1.0) if self.blast_type == 'ice' else
                  (1, 0.3, 0.1))
        light = ba.newnode('light',
                           attrs={
                               'position': position,
                               'volume_intensity_scale': 10.0,
                               'color': lcolor
                           })

        scl = random.uniform(0.6, 0.9)
        scorch_radius = light_radius = self.radius
        if self.blast_type == 'tnt':
            light_radius *= 1.4
            scorch_radius *= 1.15
            scl *= 3.0

        iscale = 1.6
        ba.animate(
            light, 'intensity', {
                0: 2.0 * iscale,
                scl * 0.02: 0.1 * iscale,
                scl * 0.025: 0.2 * iscale,
                scl * 0.05: 17.0 * iscale,
                scl * 0.06: 5.0 * iscale,
                scl * 0.08: 4.0 * iscale,
                scl * 0.2: 0.6 * iscale,
                scl * 2.0: 0.00 * iscale,
                scl * 3.0: 0.0
            })
        ba.animate(
            light, 'radius', {
                0: light_radius * 0.2,
                scl * 0.05: light_radius * 0.55,
                scl * 0.1: light_radius * 0.3,
                scl * 0.3: light_radius * 0.15,
                scl * 1.0: light_radius * 0.05
            })
        ba.timer(scl * 3.0, light.delete)

        # make a scorch that fades over time
        scorch = ba.newnode('scorch',
                            attrs={
                                'position': position,
                                'size': scorch_radius * 0.5,
                                'big': (self.blast_type == 'tnt')
                            })
        if self.blast_type == 'ice':
            scorch.color = (1, 1, 1.5)

        ba.animate(scorch, 'presence', {3.000: 1, 13.000: 0})
        ba.timer(13.0, scorch.delete)

        if self.blast_type == 'ice':
            ba.playsound(factory.hiss_sound, position=light.position)

        lpos = light.position
        ba.playsound(factory.random_explode_sound(), position=lpos)
        ba.playsound(factory.debris_fall_sound, position=lpos)

        ba.camerashake(intensity=5.0 if self.blast_type == 'tnt' else 1.0)

        # tnt is more epic..
        if self.blast_type == 'tnt':
            ba.playsound(factory.random_explode_sound(), position=lpos)

            def _extra_boom() -> None:
                ba.playsound(factory.random_explode_sound(), position=lpos)

            ba.timer(0.25, _extra_boom)

            def _extra_debris_sound() -> None:
                ba.playsound(factory.debris_fall_sound, position=lpos)
                ba.playsound(factory.wood_debris_fall_sound, position=lpos)

            ba.timer(0.4, _extra_debris_sound)
Exemplo n.º 5
0
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)
Exemplo n.º 6
0
    def __init__(self, old_function: Callable,
                 position: Sequence[float] = (0.0, 1.0, 0.0),
                 velocity: Sequence[float] = (0.0, 0.0, 0.0),
                 blast_radius: float = 2.0,
                 blast_type: str = 'normal',
                 source_player: ba.Player = None,
                 hit_type: str = 'explosion',
                 hit_subtype: str = 'normal'):
        meblast = _blasts.get(blast_type)
        if meblast is None:
            old_function(self, position=position, velocity=velocity, blast_radius=blast_radius,
                         blast_type=blast_type, source_player=source_player, hit_type=hit_type,
                         hit_subtype=hit_subtype)
            return
        """Instantiate with given values."""

        # bah; get off my lawn!
        # pylint: disable=too-many-locals
        # pylint: disable=too-many-statements

        ba.Actor.__init__(self)

        factory = BombFactory.get()

        self.blast_type = blast_type
        self._source_player = source_player
        self.hit_type = hit_type
        self.hit_subtype = hit_subtype
        self.radius = blast_radius

        # Do we need to light?
        # lcolor = ((0.6, 0.6, 1.0) if self.blast_type == 'ice' else
        #           (1, 0.3, 0.1))
        # light = ba.newnode('light',
        #                    attrs={
        #                        'position': position,
        #                        'volume_intensity_scale': 10.0,
        #                        'color': lcolor
        #                    })

        # scl = random.uniform(0.6, 0.9)
        # scorch_radius = light_radius = self.radius
        # if self.blast_type == 'tnt':
        #     light_radius *= 1.4
        #     scorch_radius *= 1.15
        #     scl *= 3.0
        #
        # iscale = 1.6
        # ba.animate(
        #     light, 'intensity', {
        #         0: 2.0 * iscale,
        #         scl * 0.02: 0.1 * iscale,
        #         scl * 0.025: 0.2 * iscale,
        #         scl * 0.05: 17.0 * iscale,
        #         scl * 0.06: 5.0 * iscale,
        #         scl * 0.08: 4.0 * iscale,
        #         scl * 0.2: 0.6 * iscale,
        #         scl * 2.0: 0.00 * iscale,
        #         scl * 3.0: 0.0
        #     })
        # ba.animate(
        #     light, 'radius', {
        #         0: light_radius * 0.2,
        #         scl * 0.05: light_radius * 0.55,
        #         scl * 0.1: light_radius * 0.3,
        #         scl * 0.3: light_radius * 0.15,
        #         scl * 1.0: light_radius * 0.05
        #     })
        # ba.timer(scl * 3.0, light.delete)

        # make a scorch that fades over time

        # if self.blast_type == 'ice':
        #     ba.playsound(factory.hiss_sound, position=light.position)

        # lpos = light.position
        # ba.playsound(factory.random_explode_sound(), position=lpos)
        # ba.playsound(factory.debris_fall_sound, position=lpos)

        ba.camerashake(intensity=5.0 if self.blast_type == 'tnt' else 1.0)

        _blasts[blast_type](self,
                            position=position,
                            velocity=velocity,
                            blast_radius=blast_radius,
                            hit_type=hit_type,
                            hit_subtype=hit_subtype)