Beispiel #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
            })
Beispiel #2
0
def tint_callback(playerdata: PlayerData, args):
    if len(args) < 2 or (len(args) < 4 and args[1] != 'r'):
        chatmessage(get_locale('chat_command_not_args_error'))
    elif args[1] == 'r':
        m = 1.30 if len(args) < 3 else float(args[2])
        s = 1000 if len(args) < 4 else float(args[3])
        if m > 3 and playerdata.status != Status.ADMIN:
            chatmessage(get_locale('too_big_arg_error'))
            return
        tint = {
            s * 0: (m, 0, 0),
            s * 1: (0, m, 0),
            s * 2: (0, 0, m),
            s * 3: (m, 0, 0),
        }

        ba.animate_array(ba.getactivity().globalsnode,
                         'tint',
                         3,
                         tint,
                         True,
                         suppress_format_warning=True,
                         timeformat=ba.TimeFormat.MILLISECONDS)
    else:
        color = (float(args[1]), float(args[2]), float(args[3]))
        if max(map(abs, color)) > 3 and playerdata.status != Status.ADMIN:
            chatmessage(get_locale('too_big_arg_error'))
            return
        ba.getactivity().globalsnode.tint = color
Beispiel #3
0
    def lightning_bolt(self, position=(0, 10, 0), radius=10):
        tint = self.activity.globalsnode.tint

        sounds = ('impactHard', 'impactHard2', 'impactHard3')
        ba.playsound(ba.getsound(random.choice(sounds)), volume=2)

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

        intensity = {
            0: 1,
            0.05: radius,
            0.15: radius / 2,
            0.25: 0,
            0.26: radius,
            0.41: radius / 2,
            0.51: 0
        }

        ba.animate(light, 'intensity', intensity)
        ba.animate_array(self.activity.globalsnode, 'tint', 3, {
            0: tint,
            0.2: (0.2, 0.2, 0.2),
            0.51: tint
        })
Beispiel #4
0
    def __init__(self, m, random_col):
        super().__init__()
        shared = SharedObjects.get()

        if random_col:
            col = (random.uniform(0, 1.2), random.uniform(0, 1.2),
                   random.uniform(0, 1.2))
        else:
            col = (0.9, 0.7, 0.0)
        self.mat = ba.Material()
        self.mat.add_actions(actions=(
            ('modify_part_collision', 'collide', False),
            ('modify_part_collision', 'physical', False),
        ))

        self.node = ba.newnode('prop',
                               delegate=self,
                               attrs={
                                   'model': ba.getmodel('bomb'),
                                   'position': (2, 4, 2),
                                   'body': 'capsule',
                                   'shadow_size': 0.0,
                                   'color_texture': ba.gettexture('coin'),
                                   'reflection': 'soft',
                                   'reflection_scale': [1.5],
                                   'materials':
                                   [shared.object_material, self.mat]
                               })
        ba.animate(self.node,
                   'model_scale', {
                       0: 0,
                       1: 0.19,
                       5: 0.10,
                       10: 0.0
                   },
                   loop=True)
        ba.animate_array(self.node,
                         'position',
                         3,
                         self.generateKeys(m),
                         loop=True)

        self.light = ba.newnode('light',
                                owner=self.node,
                                attrs={
                                    'intensity': 0.6,
                                    'height_attenuated': True,
                                    'radius': 0.2,
                                    'color': col
                                })
        ba.animate(self.light,
                   'radius', {
                       0: 0.0,
                       20: 0.4,
                       70: 0.1,
                       100: 0.3,
                       150: 0
                   },
                   loop=True)
        self.node.connectattr('position', self.light, 'position')
Beispiel #5
0
    def __init__(self, item: ba.Node, owner: ba.Node):
        self.item = item
        self.owner = owner

        self.node: ba.Node
        self.target: Optional[ba.Node] = None

        self.aim_zone: ba.Material = ba.Material()
        shared = SharedObjects.get()
        self.aim_zone.add_actions(
            conditions=(('they_have_material',
                         shared.player_material)),
            actions=(('modify_part_collision', 'collide', True),
                     ('modify_part_collision', 'physical', False),
                     ('call', 'at_connect', self._touch_handler)))

        # raise the item a little
        self.item.extra_acceleration = (0, 20, 0)
        # if the item exists, then take its position,
        # else "turn the bench"
        if self.item.exists():
            position = self.item.position
        else:
            return

        self.node = ba.newnode('region', attrs={
            'type': 'sphere',
            'position': position,
            'materials': [self.aim_zone]})

        # aiming effect
        ba.animate_array(self.node, 'scale', 3,
                         {0: (0.1, 0.1, 0.1), 1: (60, 60, 60)})
 def update_Scorch(self):
     spaz = self.spazRef()
     if spaz is not None and spaz.is_alive() and spaz.node.exists():
         color = (random.random(),random.random(),random.random())
         if not hasattr(self,"scorchNode") or self.scorchNode == None:
             self.scorchNode = None
             self.scorchNode = ba.newnode("scorch",attrs={"position":(spaz.node.position),"size":1.17,"big":True})
             spaz.node.connectattr("position",self.scorchNode,"position")
         ba.animate_array(self.scorchNode,"color",3,{0:self.scorchNode.color,500:color}, timetype=tt, timeformat=tf)
     else:
         self.scorchTimer = None
         self.scorchNode.delete()
         self.handlemessage(ba.DieMessage())
Beispiel #7
0
    def init(self, actor: stdbomb.Bomb, position, velocity, materials):
        factory = stdbomb.BombFactory.get()
        actor.node = ba.newnode('prop',
                                delegate=actor,
                                attrs={
                                    'body': 'sphere',
                                    'body_scale': 0.85,
                                    'position': position,
                                    'velocity': velocity,
                                    'materials': materials
                                })

        actor.first_shield = ba.newnode('shield',
                                        owner=actor.node,
                                        attrs={
                                            'color': (1, 1, 1),
                                            'radius': 0.6
                                        })

        actor.node.connectattr('position', actor.first_shield, 'position')

        actor.second_shield = ba.newnode('shield',
                                         owner=actor.node,
                                         attrs={
                                             'color': (0, 0, 20),
                                             'radius': 0.4
                                         })

        actor.node.connectattr('position', actor.second_shield, 'position')

        color = {
            0: (1, 1, 1),
            1: (20, 0, 0),
            2: (20, 10, 0),
            3: (20, 20, 0),
            4: (0, 20, 0),
            5: (0, 10, 20),
            6: (0, 0, 20),
            7: (10, 0, 20),
            8: (1, 1, 1)
        }

        ba.animate_array(actor.second_shield, 'color', 3, color, True)
Beispiel #8
0
def ac_callback(playerdata: PlayerData, args):
    if not args:
        chatmessage(get_locale('chat_command_not_args_error'))
    elif args[1] == 'r':
        m = 1.30 if len(args) < 3 else float(args[2])
        s = 1000 if len(args) < 4 else float(args[3])
        ambient_color = {
            s * 0: (m, 0, 0),
            s * 1: (0, m, 0),
            s * 2: (0, 0, m),
            s * 3: (m, 0, 0)
        }

        ba.animate_array(ba.getactivity().globalsnode,
                         'ambient_color',
                         3,
                         ambient_color,
                         True,
                         suppress_format_warning=True,
                         timeformat=ba.TimeFormat.MILLISECONDS)
    else:
        ba.getactivity().globalsnode.ambientColor = (float(args[1]),
                                                     float(args[2]),
                                                     float(args[3]))
 def neonLightSwitch(self,shine,Highlight,NameColor):
     spaz = self.spazRef()
     if spaz is not None and spaz.is_alive() and spaz.node.exists():
         color = (random.random(),random.random(),random.random())
         if NameColor: ba.animate_array(spaz.node,"nameColor",3,{0:spaz.node.nameColor,500:ba.safecolor(color)}, timetype=tt, timeformat=tf)
         if shine:color = tuple([min(10., 10 * x) for x in color])
         ba.animate_array(spaz.node,"color",3,{0:spaz.node.color,500:color}, timetype=tt, timeformat=tf)
         if Highlight:
             #print spaz.node.highlight
             color = (random.random(),random.random(),random.random())
             if shine:color = tuple([min(10., 10 * x) for x in color])
             ba.animate_array(spaz.node,"highlight",3,{0:spaz.node.highlight,500:color}, timetype=tt, timeformat=tf)
     else:
         self.neroLightTimer = None
         self.handlemessage(ba.DieMessage())
    def __init__(self, position: Sequence[float]):
        self._r1 = 0.45
        self._r2 = 1.1
        self._r3 = 2.0
        self._rfudge = 0.15
        super().__init__()
        self._position = ba.Vec3(position)
        self._hit = False

        # It can be handy to test with this on to make sure the projection
        # isn't too far off from the actual object.
        show_in_space = False
        loc1 = ba.newnode('locator',
                          attrs={
                              'shape': 'circle',
                              'position': position,
                              'color': (0, 1, 0),
                              'opacity': 0.5,
                              'draw_beauty': show_in_space,
                              'additive': True
                          })
        loc2 = ba.newnode('locator',
                          attrs={
                              'shape': 'circleOutline',
                              'position': position,
                              'color': (0, 1, 0),
                              'opacity': 0.3,
                              'draw_beauty': False,
                              'additive': True
                          })
        loc3 = ba.newnode('locator',
                          attrs={
                              'shape': 'circleOutline',
                              'position': position,
                              'color': (0, 1, 0),
                              'opacity': 0.1,
                              'draw_beauty': False,
                              'additive': True
                          })
        self._nodes = [loc1, loc2, loc3]
        ba.animate_array(loc1, 'size', 1, {0: [0.0], 0.2: [self._r1 * 2.0]})
        ba.animate_array(loc2, 'size', 1, {
            0.05: [0.0],
            0.25: [self._r2 * 2.0]
        })
        ba.animate_array(loc3, 'size', 1, {0.1: [0.0], 0.3: [self._r3 * 2.0]})
        ba.playsound(ba.getsound('laserReverse'))
Beispiel #11
0
    def __init__(self,
                 owner: Optional[ba.Node] = None,
                 prefix_text='Admin',
                 prefix_speed=250,
                 prefix_offset=(0, 1.75, 0),
                 prefix_animation=(-65528, -16713473, -15335680),
                 emit_type='body',
                 particle_type='spark'):
        super().__init__()
        self.owner = owner
        self.prefix_text = prefix_text
        self.prefix_speed = prefix_speed
        self.prefix_offset = prefix_offset
        self.prefix_animation = prefix_animation
        self.emit_type = emit_type
        self.particle_type = particle_type

        # for handle the effect of the third type
        self._offset = 0
        self._radius = 1

        emit_time = 0.06 if emit_type in ('sweat', 'spark') else 0.11
        if emit_type != 'off':
            self.type_selection_handler_timer = ba.Timer(
                emit_time, self._type_selection_handler, repeat=True)

        self.math_node = ba.newnode('math',
                                    owner=self.owner,
                                    attrs={
                                        'input1': prefix_offset,
                                        'operation': 'add'
                                    })

        self.owner.connectattr('torso_position', self.math_node, 'input2')
        self.prefix_node = ba.newnode('text',
                                      owner=self.owner,
                                      attrs={
                                          'text': prefix_text,
                                          'scale': 0.01,
                                          'shadow': 0.5,
                                          'flatness': 0,
                                          'in_world': True,
                                          'h_align': 'center'
                                      })

        self.math_node.connectattr('output', self.prefix_node, 'position')
        # prefix color change animation
        prefix_animation = [[((i >> 16) & 255) / 255, ((i >> 8) & 255) / 255,
                             (i & 255) / 255] for i in prefix_animation]
        animation = {}
        count = 0
        for c in prefix_animation:
            animation[prefix_speed * count] = c
            count += 1
        animation[prefix_speed * count] = prefix_animation[0]
        # print(animation)

        ba.animate_array(self.prefix_node,
                         'color',
                         3,
                         animation,
                         True,
                         timeformat=ba.TimeFormat.MILLISECONDS)
    def do_hit_at_position(self, pos: Sequence[float],
                           player: ba.Player) -> bool:
        """Handle a bomb hit at the given position."""
        # pylint: disable=too-many-statements
        from bastd.actor import popuptext
        activity = self.activity

        # Ignore hits if the game is over or if we've already been hit
        if activity.has_ended() or self._hit or not self._nodes:
            return False

        diff = (ba.Vec3(pos) - self._position)

        # Disregard Y difference. Our target point probably isn't exactly
        # on the ground anyway.
        diff[1] = 0.0
        dist = diff.length()

        bullseye = False
        if dist <= self._r3 + self._rfudge:
            # Inform our activity that we were hit
            self._hit = True
            activity.handlemessage(self.TargetHitMessage())
            keys: Dict[float, Sequence[float]] = {
                0.0: (1.0, 0.0, 0.0),
                0.049: (1.0, 0.0, 0.0),
                0.05: (1.0, 1.0, 1.0),
                0.1: (0.0, 1.0, 0.0)
            }
            cdull = (0.3, 0.3, 0.3)
            popupcolor: Sequence[float]
            if dist <= self._r1 + self._rfudge:
                bullseye = True
                self._nodes[1].color = cdull
                self._nodes[2].color = cdull
                ba.animate_array(self._nodes[0], 'color', 3, keys, loop=True)
                popupscale = 1.8
                popupcolor = (1, 1, 0, 1)
                streak = player.gamedata['streak']
                points = 10 + min(20, streak * 2)
                ba.playsound(ba.getsound('bellHigh'))
                if streak > 0:
                    ba.playsound(
                        ba.getsound(
                            'orchestraHit4' if streak > 3 else
                            'orchestraHit3' if streak > 2 else
                            'orchestraHit2' if streak > 1 else 'orchestraHit'))
            elif dist <= self._r2 + self._rfudge:
                self._nodes[0].color = cdull
                self._nodes[2].color = cdull
                ba.animate_array(self._nodes[1], 'color', 3, keys, loop=True)
                popupscale = 1.25
                popupcolor = (1, 0.5, 0.2, 1)
                points = 4
                ba.playsound(ba.getsound('bellMed'))
            else:
                self._nodes[0].color = cdull
                self._nodes[1].color = cdull
                ba.animate_array(self._nodes[2], 'color', 3, keys, loop=True)
                popupscale = 1.0
                popupcolor = (0.8, 0.3, 0.3, 1)
                points = 2
                ba.playsound(ba.getsound('bellLow'))

            # Award points/etc.. (technically should probably leave this up
            # to the activity).
            popupstr = '+' + str(points)

            # If there's more than 1 player in the game, include their
            # names and colors so they know who got the hit.
            if len(activity.players) > 1:
                popupcolor = ba.safecolor(player.color, target_intensity=0.75)
                popupstr += ' ' + player.get_name()
            popuptext.PopupText(popupstr,
                                position=self._position,
                                color=popupcolor,
                                scale=popupscale).autoretain()

            # Give this player's team points and update the score-board.
            player.team.gamedata['score'] += points
            assert isinstance(activity, TargetPracticeGame)
            activity.update_scoreboard()

            # Also give this individual player points
            # (only applies in teams mode).
            assert activity.stats is not None
            activity.stats.player_scored(player,
                                         points,
                                         showpoints=False,
                                         screenmessage=False)

            ba.animate_array(self._nodes[0], 'size', 1, {
                0.8: self._nodes[0].size,
                1.0: [0.0]
            })
            ba.animate_array(self._nodes[1], 'size', 1, {
                0.85: self._nodes[1].size,
                1.05: [0.0]
            })
            ba.animate_array(self._nodes[2], 'size', 1, {
                0.9: self._nodes[2].size,
                1.1: [0.0]
            })
            ba.timer(1.1, ba.Call(self.handlemessage, ba.DieMessage()))

        return bullseye
 def add_multicolor_effect(self):
     if spaz.node: ba.animate_array(spaz.node, 'color', 3, multicolor, True, timetype=tt, timeformat=tf)
Beispiel #14
0
    def _new_init(self,
                  color: Sequence[float] = (1.0, 1.0, 1.0),
                  highlight: Sequence[float] = (0.5, 0.5, 0.5),
                  character: str = 'Spaz',
                  source_player: ba.Player = None,
                  start_invincible: bool = True,
                  can_accept_powerups: bool = True,
                  powerups_expire: bool = False,
                  demo_mode: bool = False):
        self._old_init(color, highlight, character, source_player,
                       start_invincible, can_accept_powerups, powerups_expire,
                       demo_mode)

        if don.light:
            self.light = ba.newnode(
                'light',
                owner=self.node,
                attrs={
                    'position':
                    self.node.position,
                    'radius':
                    0.1,  #ahem pc was here
                    'volume_intensity_scale':
                    0.1,
                    'height_attenuated':
                    False,
                    'color':
                    ((0 + random.random() * 6.0), (0 + random.random() * 6.0),
                     (0 + random.random() * 6.0))
                })
            self.node.connectattr('position', self.light, 'position')
            ba.animate_array(
                self.light, 'color', 3, {
                    0: (1, 0, 0),
                    0.2: (1, 0.5, 0),
                    0.4: (1, 1, 0),
                    0.6: (0, 1, 0),
                    0.8: (0, 1, 1),
                    1.0: (0, 0, 1),
                    1.2: (1, 0, 0)
                }, True)

        def _new_hp():
            if not self.node:
                return
            hp = ba.newnode('math',
                            owner=self.node,
                            attrs={
                                'input1': (0, 0.65, 0),
                                'operation': 'add'
                            })
            self.node.connectattr('torso_position', hp, 'input2')
            self.hp = ba.newnode('text',
                                 owner=self.node,
                                 attrs={
                                     'text': '',
                                     'in_world': True,
                                     'shadow': 1.0,
                                     'flatness': 1.0,
                                     'scale': 0.008,
                                     'h_align': 'center',
                                 })
            hp.connectattr('output', self.hp, 'position')
            #ba.animate(self.hp, 'scale', {0:0, 0.2:0, 0.6:0.018, 0.8:0.012})
            activity = get_foreground_host_activity()
            if don.tint:
                activity.globalsnode.tint = (tintColor)

            def _update():
                if not self.hp:
                    return
                if self.shield:
                    hptext = int(
                        (self.shield_hitpoints / self.shield_hitpoints_max) *
                        100)
                else:
                    hptext = int(self.hitpoints * 0.1)
                if hptext >= 75:
                    color = (1, 1, 1)
                elif hptext >= 50:
                    color = (1, 1, 1)
                elif hptext >= 25:
                    color = (1, 1, 1)
                else:
                    color = (1, 1, 1)
                self.hp.text = 'HP:' + str(hptext)
                self.hp.color = (0.2, 1.0, 0.8) if self.shield else color

            ba.timer(0.05, _update, repeat=True)

        _new_hp()
        app = _ba.app
        cfg = app.config
        new_hp = cfg.get('New HP', True)
        if new_hp:
            _new_hp()
Beispiel #15
0
def dv_callback(playerdata: PlayerData, args):
    tint = {0: ba.getactivity().globalsnode.tint, 1: (1.0, 1.0, 1.0)}

    ba.animate_array(ba.getactivity().globalsnode, 'tint', 3, tint)
Beispiel #16
0
def nv_callback(playerdata: PlayerData, args):
    activity = ba.getactivity()
    tint = {0: activity.globalsnode.tint, 1: (0.5, 0.7, 1.0)}
    ba.animate_array(activity.globalsnode, 'tint', 3, tint)
Beispiel #17
0
 def do_rainbow(player):
     if player and player.actor and player.actor.node:
         ba.animate_array(player.actor.node, 'color', 3, color, True)
         ba.animate_array(player.actor.node, 'highlight', 3, highlight,
                          True)
         player.actor.node.handlemessage('celebrate', 6000)