def getMaterial(self, i):
        self.materialHealth = bs.Material()
        self.materialFreeze = bs.Material()
        self.materialCurse = bs.Material()

        # Setup Health
        self.materialHealth.addActions(
            conditions=((('theyAreOlderThan', 100), 'and',
                         ('theyHaveMaterial',
                          bs.getSharedObject('playerMaterial')))),
            actions=('message', 'theirNode', 'atConnect',
                     bs.PowerupMessage('health')))
        # Setup Freeze
        self.materialFreeze.addActions(
            conditions=((('theyAreOlderThan', 100), 'and',
                         ('theyHaveMaterial',
                          bs.getSharedObject('playerMaterial')))),
            actions=('message', 'theirNode', 'atConnect', bs.FreezeMessage()))
        # Setup Curse
        self.materialCurse.addActions(
            conditions=((('theyAreOlderThan', 100), 'and',
                         ('theyHaveMaterial',
                          bs.getSharedObject('playerMaterial')))),
            actions=('message', 'theirNode', 'atConnect',
                     bs.PowerupMessage('curse')))
        self.materials = [
            self.materialHealth, self.materialFreeze, self.materialCurse
        ]
        return self.materials[i]
예제 #2
0
    def __init__(self):
        self._lastPowerupType = None

        self.model = bs.getModel("powerup")
        self.modelSimple = bs.getModel("powerupSimple")

        self.texBomb = bs.getTexture("powerupBomb")
        self.texPunch = bs.getTexture("powerupPunch")
        self.texIceBombs = bs.getTexture("powerupIceBombs")
        self.texStickyBombs = bs.getTexture("powerupStickyBombs")
        self.texShield = bs.getTexture("powerupShield")
        self.texImpactBombs = bs.getTexture("powerupImpactBombs")
        self.texHealth = bs.getTexture("powerupHealth")
        self.texLandMines = bs.getTexture("powerupLandMines")
        self.texCurse = bs.getTexture("powerupCurse")
        # Add for Bunnybot:
        self.eggModel = bs.getModel('egg')
        self.texEgg = bs.getTexture('eggTex1')
        # Add for snoBalls:
        self.texSno = bs.getTexture(
            "bunnyColor")  # Bunny is most uniform plain white color.
        self.snoModel = bs.getModel(
            "frostyPelvis")  # Frosty pelvis is very nice and round...
        # Add for randomDoor:
        self.texDoor = bs.getTexture("cyborgColor")
        self.doorModel = bs.getModel("frostyPelvis")

        self.healthPowerupSound = bs.getSound("healthPowerup")
        self.powerupSound = bs.getSound("powerup01")
        self.powerdownSound = bs.getSound("powerdown01")
        self.dropSound = bs.getSound("boxDrop")

        # material for powerups
        self.powerupMaterial = bs.Material()

        # material for anyone wanting to accept powerups
        self.powerupAcceptMaterial = bs.Material()

        # pass a powerup-touched message to applicable stuff
        self.powerupMaterial.addActions(
            conditions=(("theyHaveMaterial", self.powerupAcceptMaterial)),
            actions=(("modifyPartCollision", "collide",
                      True), ("modifyPartCollision", "physical", False),
                     ("message", "ourNode", "atConnect", _TouchedMessage())))

        # we dont wanna be picked up
        self.powerupMaterial.addActions(
            conditions=("theyHaveMaterial",
                        bs.getSharedObject('pickupMaterial')),
            actions=(("modifyPartCollision", "collide", False)))

        self.powerupMaterial.addActions(
            conditions=("theyHaveMaterial",
                        bs.getSharedObject('footingMaterial')),
            actions=(("impactSound", self.dropSound, 0.5, 0.1)))

        self._powerupDist = []
        for p, freq in getDefaultPowerupDistribution():
            for i in range(int(freq)):
                self._powerupDist.append(p)
예제 #3
0
    def __init__(self,settings):
        bs.TeamGameActivity.__init__(self,settings)
        if self.settings['Epic Mode']: self._isSlowMotion = True

        # print messages when players die since it matters here..
        self.announcePlayerDeaths = True
        
        self._scoreBoard = bs.ScoreBoard()
        self._swipSound = bs.getSound("swip")
        self._tickSound = bs.getSound('tick')
        
        self._scoreToWin = self.settings['Capsules to Collect']
        
        self._capsuleModel = bs.getModel('bomb')
        self._capsuleTex = bs.getTexture('bombColor')
        self._capsuleLuckyTex = bs.getTexture('bombStickyColor')
        
        self._collectSound = bs.getSound('powerup01')
        self._luckyCollectSound = bs.getSound('cashRegister2')
        
        self._capsuleMaterial = bs.Material()
        self._capsuleMaterial.addActions(conditions=("theyHaveMaterial",bs.getSharedObject('playerMaterial')),
                                     actions=(("call","atConnect",self._onCapsulePlayerCollide),))
        self._capsules = []
        
        self._flagRegionMaterial = bs.Material()
        self._flagRegionMaterial.addActions(conditions=("theyHaveMaterial",bs.getSharedObject('playerMaterial')),
                                            actions=(("modifyPartCollision","collide",True),
                                                     ("modifyPartCollision","physical",False),
                                                     ("call","atConnect",bs.Call(self._handlePlayerFlagRegionCollide,1)),
                                                     ("call","atDisconnect",bs.Call(self._handlePlayerFlagRegionCollide,0))))
예제 #4
0
    def __init__(self,settings):
        bs.TeamGameActivity.__init__(self,settings)
        self._scoreBoard = bs.ScoreBoard()

        self._cheerSound = bs.getSound("cheer")
        self._chantSound = bs.getSound("crowdChant")
        self._foghornSound = bs.getSound("foghorn")
        self._swipSound = bs.getSound("swip")
        self._whistleSound = bs.getSound("refWhistle")
        self._puckModel = bs.getModel("puck")
        self._puckTex = bs.getTexture("puckColor")
        self._puckSound = bs.getSound("metalHit")

        self._puckMaterial = bs.Material()
        self._puckMaterial.addActions(actions=( ("modifyPartCollision","friction",0.5)))
        self._puckMaterial.addActions(conditions=("theyHaveMaterial",bs.getSharedObject('pickupMaterial')),
                                      actions=( ("modifyPartCollision","collide",False) ) )
        self._puckMaterial.addActions(conditions=( ("weAreYoungerThan",100),'and',
                                                   ("theyHaveMaterial",bs.getSharedObject('objectMaterial')) ),
                                      actions=( ("modifyNodeCollision","collide",False) ) )
        self._puckMaterial.addActions(conditions=("theyHaveMaterial",bs.getSharedObject('footingMaterial')),
                                      actions=(("impactSound",self._puckSound,0.2,5)))
        # keep track of which player last touched the puck
        self._puckMaterial.addActions(conditions=("theyHaveMaterial",bs.getSharedObject('playerMaterial')),
                                      actions=(("call","atConnect",self._handlePuckPlayerCollide),))
        # we want the puck to kill powerups; not get stopped by them
        self._puckMaterial.addActions(conditions=("theyHaveMaterial",bs.Powerup.getFactory().powerupMaterial),
                                      actions=(("modifyPartCollision","physical",False),
                                               ("message","theirNode","atConnect",bs.DieMessage())))
        self._scoreRegionMaterial = bs.Material()
        self._scoreRegionMaterial.addActions(conditions=("theyHaveMaterial",self._puckMaterial),
                                             actions=(("modifyPartCollision","collide",True),
                                                      ("modifyPartCollision","physical",False),
                                                      ("call","atConnect",self._handleScore)))
    def __init__(self):

        self.texColor = bs.getTexture("cyborgColor")
        self.doorModel = bs.getModel("frostyPelvis")
        self.ballMaterial = bs.Material()
        self.impactSound = bs.getSound('impactMedium')
        self.ballMaterial.addActions(
            conditions=((('weAreYoungerThan', 5), 'or', ('theyAreYoungerThan',
                                                         100)), 'and',
                        ('theyHaveMaterial',
                         bs.getSharedObject('objectMaterial'))),
            actions=(('modifyNodeCollision', 'collide', False)))
        self.ballMaterial.addActions(
            conditions=('theyHaveMaterial',
                        bs.getSharedObject('pickupMaterial')),
            actions=(('modifyPartCollision', 'useNodeCollide', False)))
        self.ballMaterial.addActions(actions=('modifyPartCollision',
                                              'friction', 0.3))
        self.ballMaterial.addActions(
            conditions=('theyHaveMaterial',
                        bs.getSharedObject('playerMaterial')),
            actions=(('modifyPartCollision', 'physical',
                      False), ('message', 'ourNode', 'atConnect',
                               doorHitSpazMessage())))

        self.defaultBallTimeout = 300
        self._autoDisappear = True
        self.positionSpan = None
    def __init__(self):
        """
        Instantiate a PowerupFactory.
        You shouldn't need to do this; call bs.Powerup.getFactory() to get a shared instance.
        """

        self._lastPowerupType = None

        self.model = bs.getModel("powerup")
        self.modelSimple = bs.getModel("powerupSimple")

        self.texBomb = bs.getTexture("powerupBomb")
        self.texPunch = bs.getTexture("powerupPunch")
        self.texIceBombs = bs.getTexture("powerupIceBombs")
        self.texStickyBombs = bs.getTexture("powerupStickyBombs")
        self.texShield = bs.getTexture("powerupShield")
        self.texImpactBombs = bs.getTexture("powerupImpactBombs")
        self.texHealth = bs.getTexture("powerupHealth")
        self.texLandMines = bs.getTexture("powerupLandMines")
        self.texCurse = bs.getTexture("powerupCurse")
        self.texHiJump = bs.getTexture("buttonJump")
        self.texInvisibility = bs.getTexture("bonesIcon")
        self.texStar = bs.getTexture("achievementSuperPunch")
        self.textbomb = bs.getTexture("achievementOnslaught")
        self.texweedbomb = bs.getTexture("achievementOffYouGo")
        self.texgluebomb = bs.getTexture("eggTex2")

        self.healthPowerupSound = bs.getSound("healthPowerup")
        self.powerupSound = bs.getSound("powerup01")
        self.powerdownSound = bs.getSound("powerdown01")
        self.dropSound = bs.getSound("boxDrop")

        # material for powerups
        self.powerupMaterial = bs.Material()

        # material for anyone wanting to accept powerups
        self.powerupAcceptMaterial = bs.Material()

        # pass a powerup-touched message to applicable stuff
        self.powerupMaterial.addActions(
            conditions=(("theyHaveMaterial", self.powerupAcceptMaterial)),
            actions=(("modifyPartCollision", "collide",
                      True), ("modifyPartCollision", "physical", False),
                     ("message", "ourNode", "atConnect", _TouchedMessage())))

        # we dont wanna be picked up
        self.powerupMaterial.addActions(
            conditions=("theyHaveMaterial",
                        bs.getSharedObject('pickupMaterial')),
            actions=(("modifyPartCollision", "collide", False)))

        self.powerupMaterial.addActions(
            conditions=("theyHaveMaterial",
                        bs.getSharedObject('footingMaterial')),
            actions=(("impactSound", self.dropSound, 0.5, 0.1)))

        self._powerupDist = []
        for p, freq in getDefaultPowerupDistribution():
            for i in range(int(freq)):
                self._powerupDist.append(p)
    def __init__(self, position=(0, 1, 0), team=None):

        bs.Actor.__init__(self)
        self.errorSound = bs.getSound('error')
        self.position = position
        self._team = team

        # Where do we place block?
        self.loc = bs.newNode('shield',
                              attrs={
                                  'position': position,
                                  'radius': 0.01,
                                  'color': (-8, -2, -2)
                              })

        # Block.
        self.body = bs.newNode('prop',
                               delegate=self,
                               attrs={
                                   'body':
                                   'box',
                                   'modelScale':
                                   1,
                                   'bodyScale':
                                   1,
                                   'model':
                                   bs.getModel('tnt'),
                                   'colorTexture':
                                   bs.getTexture('powerupCurse'),
                                   'materials': [
                                       bs.getSharedObject('footingMaterial'),
                                       bs.getSharedObject('objectMaterial')
                                   ]
                               })
        self.loc.connectAttr('position', self.body, 'position')
        self.hp = 8000
        self.frozen = False  # On freeze block don't spawn enemies.
        self.position = position  # For spawn bots.
        if self._team is None:
            self._bots = bs.BotSet()
            self._botSpawnCooldown = 5000
            self.spawner = bs.Timer(self._botSpawnCooldown,
                                    self._spawnBot,
                                    repeat=True)
        self._scoreText = bs.newNode('text',
                                     owner=self.body,
                                     attrs={
                                         'text': 'HP: ' + str(self.hp),
                                         'inWorld': True,
                                         'shadow': 1.0,
                                         'flatness': 1.0,
                                         'color': (0, 1, 0),
                                         'scale': 0.01,
                                         'hAlign': 'center',
                                         'position': self.position
                                     })
        bs.gameTimer(1000, self._scoreText.delete)
예제 #8
0
    def __init__(self):
        self.model = bs.getModel("landMine")
        self.modelSimple = bs.getModel("powerupSimple")

        self.texBomb = bs.getTexture("powerupBomb")
        self.texPunch = bs.getTexture("powerupPunch")
        self.texIceBombs = bs.getTexture("powerupIceBombs")
        self.texStickyBombs = bs.getTexture("powerupStickyBombs")
        self.texShield = bs.getTexture("powerupShield")
        self.texImpactBombs = bs.getTexture("powerupImpactBombs")
        self.texHealth = bs.getTexture("powerupHealth")
        self.texLandMines = bs.getTexture("powerupLandMines")
        self.texCurse = bs.getTexture("powerupCurse")
        self.texTNT = bs.getTexture("tnt")

        self.powerupDistribution = {
            self.texBomb: 3,
            self.texIceBombs: 2,
            self.texPunch: 3,
            self.texImpactBombs: 3,
            self.texLandMines: 3,
            self.texStickyBombs: 4,
            self.texShield: 4,
            self.texHealth: 3,
            self.texCurse: 1,
            self.texTNT: 2
        }

        self.randTex = []

        for keyTex in self.powerupDistribution:
            for i in range(self.powerupDistribution[keyTex]):
                self.randTex.append(keyTex)

        self.footholdMaterial = bs.Material()
        self.impactSound = bs.getSound('impactMedium')

        self.footholdMaterial.addActions(
            conditions=(('theyDontHaveMaterial',
                         bs.getSharedObject('playerMaterial')), 'and',
                        ('theyHaveMaterial',
                         bs.getSharedObject('objectMaterial')), 'or',
                        ('theyHaveMaterial',
                         bs.getSharedObject('footingMaterial'))),
            actions=(('modifyNodeCollision', 'collide', True), ))

        self.footholdMaterial.addActions(
            conditions=('theyHaveMaterial',
                        bs.getSharedObject('playerMaterial')),
            actions=(('modifyPartCollision', 'physical',
                      True), ('modifyPartCollision', 'stiffness', 0.05),
                     ('message', 'ourNode', 'atConnect', SpazTouchFoothold())))

        self.footholdMaterial.addActions(conditions=(('theyHaveMaterial',
                                                      self.footholdMaterial)),
                                         actions=(('modifyNodeCollision',
                                                   'collide', False)))
    def __init__(self, settings):
        bs.TeamGameActivity.__init__(self, settings)
        self._winSound = bs.getSound("score")
        self._cheerSound = bs.getSound("cheer")
        self._chantSound = bs.getSound("crowdChant")
        self._foghornSound = bs.getSound("foghorn")
        self._swipSound = bs.getSound("swip")
        self._whistleSound = bs.getSound("refWhistle")
        self._puckModel = bs.getModel("puck")
        self._puckTex = bs.getTexture("puckColor")
        self._puckSound = bs.getSound("metalHit")

        self._puckMaterial = bs.Material()
        self._puckMaterial.addActions(actions=(("modifyPartCollision", "friction", 0.1)))
        self._puckMaterial.addActions(
            conditions=("theyHaveMaterial", bs.getSharedObject("pickupMaterial")),
            actions=(("modifyPartCollision", "collide", False)),
        )
        self._puckMaterial.addActions(
            conditions=(("weAreYoungerThan", 100), "and", ("theyHaveMaterial", bs.getSharedObject("objectMaterial"))),
            actions=(("modifyNodeCollision", "collide", False)),
        )
        self._puckMaterial.addActions(
            conditions=("theyHaveMaterial", bs.getSharedObject("footingMaterial")),
            actions=(("impactSound", self._puckSound, 0.2, 5)),
        )
        # keep track of which player last touched the puck
        self._puckMaterial.addActions(
            conditions=("theyHaveMaterial", bs.getSharedObject("playerMaterial")),
            actions=(("call", "atConnect", self._handlePuckPlayerCollide),),
        )

        # we want the puck to kill powerups; not get stopped by them
        self._puckMaterial.addActions(
            conditions=("theyHaveMaterial", bs.Powerup.getFactory().powerupMaterial),
            actions=(
                ("modifyPartCollision", "physical", False),
                ("message", "theirNode", "atConnect", bs.DieMessage()),
            ),
        )

        # dis is kill
        self._puckMaterial.addActions(
            conditions=("theyHaveMaterial", bs.getSharedObject("playerMaterial")),
            actions=(
                ("modifyPartCollision", "physical", False),
                ("message", "ourNode", "atConnect", PuckTouchedMessage()),
            ),
        )

        self._scoreBoard = bs.ScoreBoard()
        self._killsToWin = self.settings["Kills to Win"]
        self._scoreSound = bs.getSound("score")

        self.pucks = []
예제 #10
0
 def __init__(self, position=(0,1,0), velocity=(0,0.5,0),lucky=False):
     bs.Actor.__init__(self)
     self._luckyAppearSound = bs.getSound('ding')
     
     activity = self.getActivity()
     
     # spawn just above the provided point
     self._spawnPos = (position[0], position[1], position[2])
     if lucky:
         bs.playSound(self._luckyAppearSound,1.0,self._spawnPos)
         self.capsule = bs.newNode("prop",
                             attrs={'model': activity._capsuleModel,
                                     'colorTexture': activity._capsuleLuckyTex,
                                     'body':'crate',
                                     'reflection':'powerup',
                                     'modelScale':0.8,
                                     'bodyScale':0.65,
                                     'density':6.0,
                                     'reflectionScale':[0.15],
                                     'shadowSize': 0.65,
                                     'position':self._spawnPos,
                                     'velocity':velocity,
                                     'materials': [bs.getSharedObject('objectMaterial'),activity._capsuleMaterial]
                                     },
                             delegate=self)
         bs.animate(self.capsule,"modelScale",{0:0, 100:0.9, 160:0.8})
         self.lightCapsule = bs.newNode('light',
                                         attrs={'position':self._spawnPos,
                                             'heightAttenuated':False,
                                             'radius':0.5,
                                             'color':(0.2,0.2,0)})
     else:
         self.capsule = bs.newNode("prop",
                             attrs={'model': activity._capsuleModel,
                                     'colorTexture': activity._capsuleTex,
                                     'body':'capsule',
                                     'reflection':'soft',
                                     'modelScale':0.6,
                                     'bodyScale':0.3,
                                     'density':4.0,
                                     'reflectionScale':[0.15],
                                     'shadowSize': 0.6,
                                     'position':self._spawnPos,
                                     'velocity':velocity,
                                     'materials': [bs.getSharedObject('objectMaterial'),activity._capsuleMaterial]
                                     },
                             delegate=self)
         bs.animate(self.capsule,"modelScale",{0:0, 100:0.6, 160:0.5})
         self.lightCapsule = bs.newNode('light',
                                         attrs={'position':self._spawnPos,
                                             'heightAttenuated':False,
                                             'radius':0.1,
                                             'color':(0.2,1,0.2)})
     self.capsule.connectAttr('position',self.lightCapsule,'position')
예제 #11
0
    def __init__(self,
                 position=(0, 1, 0),
                 graphics=2,
                 randomColor=True,
                 mirror=False,
                 form=0):
        bs.Actor.__init__(self)

        if form == 0:
            model = 'tnt'
            body = 'crate'
        elif form == 1:
            model = 'bomb'
            body = 'sphere'
        elif form == 2:
            model = random.choice(['tnt', 'bomb'])
            body = 'sphere' if model == 'bomb' else 'crate'

        self.node = bs.newNode(
            'prop',
            delegate=self,
            attrs={
                'position':
                position,
                'model':
                bs.getModel(model),
                'body':
                body,
                'bodyScale':
                1.3,
                'modelScale':
                1.3,
                'reflection':
                'powerup',
                'reflectionScale': [0.7],
                'colorTexture':
                bs.getTexture('bunnyColor'),
                'materials':
                [bs.getSharedObject('footingMaterial')] if mirror else [
                    bs.getSharedObject('objectMaterial'),
                    bs.getSharedObject('footingMaterial')
                ]
            })

        if graphics == 2:
            self.lightNode = bs.newNode('light', attrs={
                'position': (0, 0, 0),
                'color': ((0.8, 0.2, 0.2) if i < count/2 else (0.2, 0.2, 0.8)) \
                    if not randomColor else ((random.random(), random.random(), random.random())),
                'radius': 0.2,
                'intensity': 1,
                'volumeIntensityScale': 10.0})

            self.node.connectAttr('position', self.lightNode, 'position')
 def __init__(self):
     self.basketBallMaterial = bs.Material()
     self.basketBallMaterial.addActions(
         conditions=(('weAreOlderThan', 200), 'and',
                     ('theyAreOlderThan', 200), 'and', ('evalColliding', ),
                     'and', (('theyHaveMaterial',
                              bs.getSharedObject('footingMaterial')), 'or',
                             ('theyHaveMaterial',
                              bs.getSharedObject('objectMaterial')))),
         actions=(('message', 'ourNode', 'atConnect', ImpactMessage())))
     bs.BombFactory.__init__(self)
예제 #13
0
 def lightningBolt(self,position = (0,10,0),radius = 10):
     bs.shakeCamera(3)
     self.tint = bs.getSharedObject('globals').tint
     light = bs.newNode('light',
                     attrs={'position':position,
                         'color': (0.2,0.2,0.4),
                         'volumeIntensityScale': 1.0,
                         'radius':radius})
     bsUtils.animate(light,"intensity",{0:1,50:radius,150:radius/2,250:0,260:radius,410:radius/2,510:0})
     bsUtils.animateArray(bs.getSharedObject('globals'),"tint",3,{0:self.tint,200:(0.2,0.2,0.2),510:self.tint})
     bs.playSound(bs.getSound('grom'),volume = 10,position = (0,10,0))
예제 #14
0
 def path():
     p = bs.newNode('prop',
                    attrs={
                        'position': (-5.750, 4.3515026107, 2.0),
                        'velocity': (2.0, 1.0, 0),
                        'sticky':
                        False,
                        'body':
                        'landMine',
                        'model':
                        bs.getModel('landMine'),
                        'colorTexture':
                        bs.getTexture('achievementWall'),
                        'bodyScale':
                        1.0,
                        'reflection':
                        'powerup',
                        'density':
                        9999999999999999,
                        'reflectionScale': [1.0],
                        'modelScale':
                        1.0,
                        'gravityScale':
                        0,
                        'shadowSize':
                        0.0,
                        'materials': [
                            bs.getSharedObject('objectMaterial'),
                            bs.getSharedObject('footingMaterial')
                        ]
                    })
     bsUtils.animateArray(
         p,
         "position",
         3, {
             0: (1.830634, 4.830635, 3.830636),
             10000: (4.8306378, 4.83063588, -6.830639),
             20000: (-5.422572086, 4.228850685, 2.803988636),
             25000: (-6.859406739, 4.429165244, -6.588618549),
             30000: (-6.859406739, 4.429165244, -6.588618549),
             35000: (3.148493267, 4.429165244, -6.588618549),
             40000: (1.830377363, 4.228850685, 2.803988636),
             45000: (-5.422572086, 4.228850685, 2.803988636),
             50000: (-5.422572086, 4.228850685, 2.803988636),
             55000: (1.830377363, 4.228850685, 2.803988636),
             60000: (3.148493267, 4.429165244, -6.588618549),
             70000: (1.830377363, 4.228850685, 2.803988636),
             75000: (3.148493267, 4.429165244, -6.588618549),
             80000: (-5.422572086, 4.228850685, 2.803988636),
             90000: (-6.859406739, 4.429165244, -6.588618549),
             95000: (-6.859406739, 4.429165244, -6.588618549)
         },
         loop=True)
예제 #15
0
    def __init__(self, settings):
        bs.TeamGameActivity.__init__(self, settings)
        self._scoreBoard = bs.ScoreBoard()
        if self.settings['Epic Mode']: self._isSlowMotion = True

        self._cheerSound = bs.getSound("cheer")
        self._chantSound = bs.getSound("")
        self._glSound = bs.getSound("orchestraHitBig2")
        self._swipSound = bs.getSound("")
        self._spwnSound = bs.getSound("orchestraHitBig1")
        self._puckModel = bs.getModel("shield")
        self._puckTex = bs.getTexture("levelIcon")
        #self._puckSound = bs.getSound("block")
        self._rollSound = bs.getSound("bombRoll01")
        self._dinkSounds = (bs.getSound('bombDrop01'),
                            bs.getSound('bombDrop02'))

        self._puckMaterial = bs.Material()
        self._puckMaterial.addActions(
            conditions=('theyHaveMaterial',
                        bs.getSharedObject('footingMaterial')),
            actions=(('impactSound', self._dinkSounds, 2, 0.8),
                     ('rollSound', self._rollSound, 3, 6)))
        self._puckMaterial.addActions(actions=(("modifyPartCollision",
                                                "friction", 500.0)))
        self._puckMaterial.addActions(
            conditions=("theyHaveMaterial",
                        bs.getSharedObject('pickupMaterial')),
            actions=(("modifyPartCollision", "collide", True)))
        self._puckMaterial.addActions(
            conditions=(("weAreYoungerThan", 100), 'and',
                        ("theyHaveMaterial",
                         bs.getSharedObject('objectMaterial'))),
            actions=(("modifyNodeCollision", "collide", False)))
        #  self._puckMaterial.addActions(conditions=("theyHaveMaterial",bs.getSharedObject('footingMaterial')),
        #                                actions=(("impactSound",self._puckSound,0.2,2)))
        # keep track of which player last touched the puck
        self._puckMaterial.addActions(
            conditions=("theyHaveMaterial",
                        bs.getSharedObject('playerMaterial')),
            actions=(("call", "atConnect", self._handlePuckPlayerCollide), ))
        # we want physical
        self._puckMaterial.addActions(
            conditions=("theyHaveMaterial",
                        bs.Powerup.getFactory().powerupMaterial),
            actions=(("modifyPartCollision", "physical", True),
                     ("message", "theirNode", "atConnect", bs.DieMessage())))
        self._scoreRegionMaterial = bs.Material()
        self._scoreRegionMaterial.addActions(
            conditions=("theyHaveMaterial", self._puckMaterial),
            actions=(("modifyPartCollision", "collide",
                      True), ("modifyPartCollision", "physical", False),
                     ("call", "atConnect", self._handleScore)))
 def off():
     op = 1
     try:
         bsInternal._getForegroundHostActivity().getMap(
         ).node.opacity = op
     except:
         pass
     try:
         bsInternal._getForegroundHostActivity().getMap(
         ).bg.opacity = op
     except:
         pass
     try:
         bsInternal._getForegroundHostActivity().getMap(
         ).bg.node.opacity = op
     except:
         pass
     try:
         bsInternal._getForegroundHostActivity().getMap(
         ).node1.opacity = op
     except:
         pass
     try:
         bsInternal._getForegroundHostActivity().getMap(
         ).node2.opacity = op
     except:
         pass
     try:
         bsInternal._getForegroundHostActivity().getMap(
         ).node3.opacity = op
     except:
         pass
     try:
         bsInternal._getForegroundHostActivity().getMap(
         ).steps.opacity = op
     except:
         pass
     try:
         bsInternal._getForegroundHostActivity().getMap(
         ).floor.opacity = op
     except:
         pass
     try:
         bsInternal._getForegroundHostActivity().getMap(
         ).center.opacity = op
     except:
         pass
     bsUtils.animateArray(
         bs.getSharedObject('globals'), 'vignetteOuter', 3,
         {
             0: bs.getSharedObject('globals').vignetteOuter,
             100: std
         })
예제 #17
0
    def waveDelay(self):
        bs.playSound(bs.getSound('gong'))
        globals = bs.getSharedObject('globals')
        tint = globals.tint
        bsUtils.animateArray(bs.getSharedObject('globals'),"tint",3,{0:tint,1000:(0.2,0.2,0.2),2500:(1.2,1.2,1.2),4000:(1.3,1.3,1.3),5000:tint})
        bs.Powerup(powerupType = random.choice(['health','shield','punch','impactBombs','curse']),position = self.getRandomPosV(),expire = False).autoRetain()
        if random.random() > 0.3:
            bs.gameTimer(200,bs.Call(bs.Powerup,powerupType = random.choice(['health','shield','punch','impactBombs']),position = self.getRandomPosV(),expire = False))
            bs.Powerup(powerupType = random.choice(['health','shield','punch','impactBombs','curse']),position = self.getRandomPosV(),expire = False).autoRetain()
        if random.random() > 0.6:
            bs.gameTimer(400,bs.Call(bs.Powerup,powerupType = random.choice(['health','shield','punch','impactBombs']),position = self.getRandomPosV(),expire = False))

        bs.gameTimer(5000,bs.Call(self.startNextWave,self.num))
예제 #18
0
def fadeToRed():
    activity = bsInternal._getForegroundHostActivity()
    with bs.Context(activity):
        cExisting = bs.getSharedObject('globals').tint
        c = bs.newNode("combine",
                       attrs={
                           'input0': cExisting[0],
                           'input1': cExisting[1],
                           'input2': cExisting[2],
                           'size': 3
                       })
        bs.animate(c, 'input1', {0: cExisting[1], 2000: 0})
        bs.animate(c, 'input2', {0: cExisting[2], 2000: 0})
        c.connectAttr('output', bs.getSharedObject('globals'), 'tint')
예제 #19
0
 def _doNight(self):
     self._isSleep = False
     self.tint = bs.getSharedObject('globals').tint
     bsUtils.animateArray(bs.getSharedObject('globals'), "tint", 3, {
         0: self.tint,
         1000: (0.3, 0.3, 0.6)
     })
     bs.playSound(bs.getSound('shieldUp'), volume=10, position=(0, 10, 0))
     self._repeaterOne = bs.Timer(450,
                                  bs.WeakCall(self._doSleep),
                                  repeat=True)  #shutdown our spazs
     self._repeaterTwo = bs.Timer(random.randrange(1000, 10000),
                                  bs.WeakCall(
                                      self._doWakeUp))  #wakeup our spazs
 def __init__(self,
              position=(0, 1, 0),
              velocity=(0, 0, 0),
              deathTimeout=(False, 0)):
     bs.Actor.__init__(self)
     activity = self.getActivity()
     self.rType = randint(0, 2)
     self.color = self.getColor(self.rType)
     self.material = self.getMaterial(self.rType)
     self.bodyNode = bs.newNode(
         'prop',
         delegate=self,
         attrs={
             'extraAcceleration': (0, 16, 0),
             'body': 'sphere',
             'position': position,
             'velocity': velocity,
             'materials':
             [bs.getSharedObject('objectMaterial'), self.material]
         })
     self.node = bs.newNode('shield',
                            owner=self.bodyNode,
                            attrs={
                                'color': self.color,
                                'radius': 0.7
                            })
     self.bodyNode.connectAttr('position', self.node, 'position')
     if deathTimeout[0]:
         bs.gameTimer(deathTimeout[1],
                      bs.Call(self.handleMessage, bs.DieMessage()))
예제 #21
0
    def __init__(self, position=(0, 1, 0)):
        bs.Actor.__init__(self)

        activity = self.getActivity()

        # spawn just above the provided point
        self._spawnPos = (position[0], position[1] + 1.0, position[2])
        self.lastPlayersToTouch = {}
        self.node = bs.newNode(
            "prop",
            attrs={
                'model':
                activity._puckModel,
                'colorTexture':
                activity._puckTex,
                'body':
                'puck',
                'reflection':
                'soft',
                'reflectionScale': [0.2],
                'shadowSize':
                1.0,
                'isAreaOfInterest':
                True,
                'position':
                self._spawnPos,
                'materials':
                [bs.getSharedObject('objectMaterial'), activity._puckMaterial]
            },
            delegate=self)
예제 #22
0
    def onBegin(self):

        # test...
        if not all(player.exists() for player in self.players):
            bs.printError("Nonexistant player in onBegin: "+str([str(p) for p in self.players])+': we are '+str(player))

        bs.TeamGameActivity.onBegin(self)
        self.setupStandardTimeLimit(self.settings['Time Limit'])
        self.setupStandardPowerupDrops()
        self._flagSpawnPos = self.getMap().getFlagPosition(None)
        self.projectFlagStand(self._flagSpawnPos)
        self._setChosenOnePlayer(None)

        p = self._flagSpawnPos
        bs.gameTimer(1000,call=self._tick,repeat=True)

        m = self._resetRegionMaterial = bs.Material()
        m.addActions(conditions=('theyHaveMaterial',bs.getSharedObject('playerMaterial')),
                     actions=(('modifyPartCollision','collide',True),
                              ('modifyPartCollision','physical',False),
                              ('call','atConnect',bs.WeakCall(self._handleResetCollide))))

        self._resetRegion = bs.newNode('region',
                                       attrs={'position':(p[0],p[1]+0.75,p[2]),
                                              'scale': (0.5,0.5,0.5),
                                              'type': 'sphere',
                                              'materials':[m]
                                              })
예제 #23
0
    def __init__(self):
        Map.__init__(self, vrOverlayCenterOffset=(0, -3.7, 2.5))

        self.foo = bs.newNode('terrain',
                              attrs={
                                  'model': self.preloadData['bgModel'],
                                  'lighting': False,
                                  'background': True,
                                  'colorTexture': self.preloadData['bgTex']
                              })
        bs.newNode('terrain',
                   attrs={
                       'model': self.preloadData['vrFillMoundModel'],
                       'lighting': False,
                       'vrOnly': True,
                       'color': (0.2, 0.25, 0.2),
                       'background': True,
                       'colorTexture': self.preloadData['vrFillMoundTex']
                   })
        g = bs.getSharedObject('globals')
        g.happyThoughtsMode = True
        g.shadowOffset = (0.0, 8.0, 5.0)
        g.tint = (1.3, 1.23, 1.0)
        g.ambientColor = (1.3, 1.23, 1.0)
        g.vignetteOuter = (0.64, 0.59, 0.69)
        g.vignetteInner = (0.95, 0.95, 0.93)
        g.vrNearClip = 1.0
        self.isFlying = True
예제 #24
0
    def __init__(self, pos=(0, 1, 0), sourcePlayer=None):

        bs.Actor.__init__(self)

        factory = self.getFactory()

        self.targetSound = factory.targetSound
        self.popSound = factory.popSound

        if sourcePlayer is None:
            self.sourcePlayers = [bs.Player(None)]
        else:
            self.sourcePlayers = [sourcePlayer]

        self.node = bs.newNode(
            'prop',
            delegate=self,
            attrs={
                'body': 'sphere',
                'position': pos,
                'velocity': (0, 0, 1),  # Не менять на (0, 0, 0)!
                'model': factory.botModel,
                'colorTexture': factory.botTexture,
                'reflection': u'powerup',
                'reflectionScale': (10, 10, 0),
                'shadowSize': 0.5,
                'extraAcceleration': (0, 20, 0),
                'materials': [bs.getSharedObject("objectMaterial")]
            })
        bs.gameTimer(30000, bs.WeakCall(self.handleMessage, bs.DieMessage()))
        self._updTimer = bs.Timer(500, bs.WeakCall(self._update), repeat=True)
예제 #25
0
    def onBegin(self):
        bs.TeamGameActivity.onBegin(self)
        self.setupStandardTimeLimit(self.settings['Time Limit'])
        self.setupStandardPowerupDrops()
        if len(self.teams) > 0:
            self._scoreToWin = self.settings['Capsules to Collect'] * max(1,max(len(t.players) for t in self.teams))
        else: self._scoreToWin = self.settings['Capsules to Collect']
        self._updateScoreBoard()
        self._dingSound = bs.getSound('dingSmall')
        if isinstance(bs.getActivity().getSession(),bs.FreeForAllSession):
            self._flagNumber = random.randint(0,1)
            self._flagPos = self.getMap().getFlagPosition(self._flagNumber)
        else: self._flagPos = self.getMap().getFlagPosition(None)
        bs.gameTimer(1000,self._tick,repeat=True)
        self._flagState = self.FLAG_NEW
        self.projectFlagStand(self._flagPos)

        self._flag = bs.Flag(position=self._flagPos,
                             touchable=False,
                             color=(1,1,1))
        self._flagLight = bs.newNode('light',
                                     attrs={'position':self._flagPos,
                                            'intensity':0.2,
                                            'heightAttenuated':False,
                                            'radius':0.4,
                                            'color':(0.2,0.2,0.2)})

        # flag region
        bs.newNode('region',
                   attrs={'position':self._flagPos,
                          'scale': (1.8,1.8,1.8),
                          'type': 'sphere',
                          'materials':[self._flagRegionMaterial,bs.getSharedObject('regionMaterial')]})
        self._updateFlagState()
    def __init__(self, position=(0, 1, 0)):

        bs.Actor.__init__(self)

        # Where do we place block?
        self.loc = bs.newNode('shield',
                              attrs={
                                  'position': position,
                                  'radius': 0.01
                              })

        # Block
        self.body = bs.newNode('prop',
                               delegate=self,
                               attrs={
                                   'body':
                                   'box',
                                   'modelScale':
                                   1,
                                   'bodyScale':
                                   1,
                                   'model':
                                   bs.getModel('tnt'),
                                   'colorTexture':
                                   bs.getTexture('tnt'),
                                   'materials':
                                   [bs.getSharedObject('footingMaterial')]
                               })
        self.loc.connectAttr('position', self.body, 'position')
    def __init__(self, position=(0, 1, 0), maxBalls=5):

        bs.Actor.__init__(self)

        self.balls = []

        self.maxBalls = maxBalls

        self.node = bs.newNode('prop',
                               delegate=self,
                               attrs={
                                   'extraAcceleration': (0, 18, 0),
                                   'position':
                                   position,
                                   'model':
                                   bs.getModel('tnt'),
                                   'lightModel':
                                   bs.getModel('tnt'),
                                   'body':
                                   'crate',
                                   'shadowSize':
                                   0.5,
                                   'colorTexture':
                                   bs.getTexture('achievementFlawlessVictory'),
                                   'reflection':
                                   'soft',
                                   'reflectionScale': [1],
                                   'materials':
                                   [bs.getSharedObject('objectMaterial')]
                               })
        self.timer = bs.Timer(5000, bs.Call(self.spawnBall), repeat=True)
예제 #28
0
    def __init__(self, position=(0, 1, 0)):
        bs.Actor.__init__(self)

        activity = self.getActivity()

        # spawn just above the provided point
        self._spawnPos = (position[0], position[1] + 1.0, position[2])
        self.node = bs.newNode(
            "prop",
            attrs={
                'model':
                activity._eggModel,
                'colorTexture': (activity._eggTex1, activity._eggTex2,
                                 activity._eggTex3)[random.randrange(3)],
                'body':
                'sphere',
                'reflection':
                'soft',
                'modelScale':
                0.27,
                'bodyScale':
                2.0,
                'modelScale':
                0.5,
                'density':
                0.075,
                'reflectionScale': [0.15],
                'shadowSize':
                0.6,
                'position':
                self._spawnPos,
                'materials':
                [bs.getSharedObject('objectMaterial'), activity._eggMaterial]
            },
            delegate=self)
예제 #29
0
    def __init__(self, settings):
        bs.TeamGameActivity.__init__(self, settings)
        self._scoreBoard = bs.ScoreBoard()
        self._swipSound = bs.getSound("swip")
        self._tickSound = bs.getSound('tick')
        self._countDownSounds = {
            10: bs.getSound('announceTen'),
            9: bs.getSound('announceNine'),
            8: bs.getSound('announceEight'),
            7: bs.getSound('announceSeven'),
            6: bs.getSound('announceSix'),
            5: bs.getSound('announceFive'),
            4: bs.getSound('announceFour'),
            3: bs.getSound('announceThree'),
            2: bs.getSound('announceTwo'),
            1: bs.getSound('announceOne')
        }

        self._flagRegionMaterial = bs.Material()
        self._flagRegionMaterial.addActions(
            conditions=("theyHaveMaterial",
                        bs.getSharedObject('playerMaterial')),
            actions=(("modifyPartCollision", "collide",
                      True), ("modifyPartCollision", "physical", False),
                     ("call", "atConnect",
                      bs.Call(self._handlePlayerFlagRegionCollide, 1)),
                     ("call", "atDisconnect",
                      bs.Call(self._handlePlayerFlagRegionCollide, 0))))
예제 #30
0
    def onBegin(self):
        bs.TeamGameActivity.onBegin(self)
        self.setupStandardTimeLimit(self.settings['Time Limit'])
        # self.setupStandardPowerupDrops() #no powerups due to boxing
        self._flagPos = self.getMap().getFlagPosition(None)
        bs.gameTimer(1000, self._tick, repeat=True)
        self._flagState = self.FLAG_NEW
        self.projectFlagStand(self._flagPos)

        self._flag = bs.Flag(position=self._flagPos,
                             touchable=False,
                             color=(1, 1, 1))
        self._flagLight = bs.newNode('light',
                                     attrs={
                                         'position': self._flagPos,
                                         'intensity': 0.2,
                                         'heightAttenuated': False,
                                         'radius': 0.4,
                                         'color': (0.2, 0.2, 0.2)
                                     })

        # flag region
        bs.newNode('region',
                   attrs={
                       'position':
                       self._flagPos,
                       'scale': (1.8, 1.8, 1.8),
                       'type':
                       'sphere',
                       'materials': [
                           self._flagRegionMaterial,
                           bs.getSharedObject('regionMaterial')
                       ]
                   })
        self._updateFlagState()
예제 #31
0
    def __init__(self):
        self._lastPowerupType = None

        self.model = bs.getModel("powerup")
        self.modelSimple = bs.getModel("powerupSimple")

        self.texBomb = bs.getTexture("powerupBomb")
        self.texPunch = bs.getTexture("powerupPunch")
        self.texIceBombs = bs.getTexture("powerupIceBombs")
        self.texStickyBombs = bs.getTexture("powerupStickyBombs")
        self.texShield = bs.getTexture("powerupShield")
        self.texImpactBombs = bs.getTexture("powerupImpactBombs")
        self.texHealth = bs.getTexture("powerupHealth")
        self.texLandMines = bs.getTexture("powerupLandMines")
        self.texCurse = bs.getTexture("powerupCurse")
        self.texBlast = bs.getTexture("tnt")
        self.texMix = bs.getTexture("eggTex1")

        self.healthPowerupSound = bs.getSound("healthPowerup")
        self.powerupSound = bs.getSound("powerup01")
        self.powerdownSound = bs.getSound("powerdown01")
        self.dropSound = bs.getSound("boxDrop")

        self.powerupMaterial = bs.Material()

        self.powerupAcceptMaterial = bs.Material()

        self.powerupMaterial.addActions(
            conditions=(("theyHaveMaterial", self.powerupAcceptMaterial)),
            actions=(("modifyPartCollision", "collide",
                      True), ("modifyPartCollision", "physical", False),
                     ("message", "ourNode", "atConnect", _TouchedMessage())))

        self.powerupMaterial.addActions(
            conditions=("theyHaveMaterial",
                        bs.getSharedObject('pickupMaterial')),
            actions=(("modifyPartCollision", "collide", False)))

        self.powerupMaterial.addActions(
            conditions=("theyHaveMaterial",
                        bs.getSharedObject('footingMaterial')),
            actions=(("impactSound", self.dropSound, 0.5, 0.1)))

        self._powerupDist = []
        for p, freq in getDefaultPowerupDistribution():
            for i in range(int(freq)):
                self._powerupDist.append(p)
    def __init__(
        self,
        position=(0, 1, 0),
        velocity=(0, 0, 0),
        blastRadius=2.0,
        blastType="normal",
        sourcePlayer=None,
        hitType="explosion",
        hitSubType="normal",
    ):
        """
		Instantiate with given values.
		"""
        bs.Actor.__init__(self)

        factory = Bomb.getFactory()

        self.blastType = blastType
        self.sourcePlayer = sourcePlayer

        self.hitType = hitType
        self.hitSubType = hitSubType

        # blast radius
        self.radius = blastRadius

        self.node = bs.newNode(
            "region",
            attrs={
                "position": (
                    position[0],
                    position[1] - 0.1,
                    position[2],
                ),  # move down a bit so we throw more stuff upward
                "scale": (self.radius, self.radius, self.radius),
                "type": "sphere",
                "materials": (factory.blastMaterial, bs.getSharedObject("attackMaterial")),
            },
            delegate=self,
        )

        bs.gameTimer(50, self.node.delete)

        # throw in an explosion and flash
        explosion = bs.newNode(
            "explosion",
            attrs={
                "position": position,
                "velocity": (velocity[0], max(-1.0, velocity[1]), velocity[2]),
                "radius": self.radius,
                "big": (self.blastType == "tnt"),
            },
        )
        if self.blastType == "ice":
            explosion.color = (0, 0.05, 0.4)

        bs.gameTimer(1000, explosion.delete)

        if self.blastType != "ice":
            bs.emitBGDynamics(
                position=position,
                velocity=velocity,
                count=int(1.0 + random.random() * 4),
                emitType="tendrils",
                tendrilType="thinSmoke",
            )
        bs.emitBGDynamics(
            position=position,
            velocity=velocity,
            count=int(4.0 + random.random() * 4),
            emitType="tendrils",
            tendrilType="ice" if self.blastType == "ice" else "smoke",
        )
        bs.emitBGDynamics(position=position, emitType="distortion", spread=1.0 if self.blastType == "tnt" else 2.0)

        # and emit some shrapnel..
        if self.blastType == "ice":

            def _doEmit():
                bs.emitBGDynamics(
                    position=position,
                    velocity=velocity,
                    count=30,
                    spread=2.0,
                    scale=0.4,
                    chunkType="ice",
                    emitType="stickers",
                )

            bs.gameTimer(50, _doEmit)  # looks better if we delay a bit

        elif self.blastType == "sticky":

            def _doEmit():
                bs.emitBGDynamics(
                    position=position,
                    velocity=velocity,
                    count=int(4.0 + random.random() * 8),
                    spread=0.7,
                    chunkType="slime",
                )
                bs.emitBGDynamics(
                    position=position,
                    velocity=velocity,
                    count=int(4.0 + random.random() * 8),
                    scale=0.5,
                    spread=0.7,
                    chunkType="slime",
                )
                bs.emitBGDynamics(
                    position=position, velocity=velocity, count=15, scale=0.6, chunkType="slime", emitType="stickers"
                )
                bs.emitBGDynamics(
                    position=position, velocity=velocity, count=20, scale=0.7, chunkType="spark", emitType="stickers"
                )
                bs.emitBGDynamics(
                    position=position,
                    velocity=velocity,
                    count=int(6.0 + random.random() * 12),
                    scale=0.8,
                    spread=1.5,
                    chunkType="spark",
                )

            bs.gameTimer(50, _doEmit)  # looks better if we delay a bit

        elif self.blastType == "impact":  # regular bomb shrapnel

            def _doEmit():
                bs.emitBGDynamics(
                    position=position,
                    velocity=velocity,
                    count=int(4.0 + random.random() * 8),
                    scale=0.8,
                    chunkType="metal",
                )
                bs.emitBGDynamics(
                    position=position,
                    velocity=velocity,
                    count=int(4.0 + random.random() * 8),
                    scale=0.4,
                    chunkType="metal",
                )
                bs.emitBGDynamics(
                    position=position, velocity=velocity, count=20, scale=0.7, chunkType="spark", emitType="stickers"
                )
                bs.emitBGDynamics(
                    position=position,
                    velocity=velocity,
                    count=int(8.0 + random.random() * 15),
                    scale=0.8,
                    spread=1.5,
                    chunkType="spark",
                )

            bs.gameTimer(50, _doEmit)  # looks better if we delay a bit

        else:  # regular or land mine bomb shrapnel

            def _doEmit():
                if self.blastType != "tnt":
                    bs.emitBGDynamics(
                        position=position, velocity=velocity, count=int(4.0 + random.random() * 8), chunkType="rock"
                    )
                    bs.emitBGDynamics(
                        position=position,
                        velocity=velocity,
                        count=int(4.0 + random.random() * 8),
                        scale=0.5,
                        chunkType="rock",
                    )
                bs.emitBGDynamics(
                    position=position,
                    velocity=velocity,
                    count=30,
                    scale=1.0 if self.blastType == "tnt" else 0.7,
                    chunkType="spark",
                    emitType="stickers",
                )
                bs.emitBGDynamics(
                    position=position,
                    velocity=velocity,
                    count=int(18.0 + random.random() * 20),
                    scale=1.0 if self.blastType == "tnt" else 0.8,
                    spread=1.5,
                    chunkType="spark",
                )

                # tnt throws splintery chunks
                if self.blastType == "tnt":

                    def _emitSplinters():
                        bs.emitBGDynamics(
                            position=position,
                            velocity=velocity,
                            count=int(20.0 + random.random() * 25),
                            scale=0.8,
                            spread=1.0,
                            chunkType="splinter",
                        )

                    bs.gameTimer(10, _emitSplinters)

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

                    def _emitExtraSparks():
                        bs.emitBGDynamics(
                            position=position,
                            velocity=velocity,
                            count=int(10.0 + random.random() * 20),
                            scale=0.8,
                            spread=1.5,
                            chunkType="spark",
                        )

                    bs.gameTimer(20, _emitExtraSparks)

            bs.gameTimer(50, _doEmit)  # looks better if we delay a bit

        light = bs.newNode(
            "light",
            attrs={
                "position": position,
                "color": (0.6, 0.6, 1.0) if self.blastType == "ice" else (1, 0.3, 0.1),
                "volumeIntensityScale": 10.0,
            },
        )

        s = random.uniform(0.6, 0.9)
        scorchRadius = lightRadius = self.radius
        if self.blastType == "tnt":
            lightRadius *= 1.4
            scorchRadius *= 1.15
            s *= 3.0

        iScale = 1.6
        bsUtils.animate(
            light,
            "intensity",
            {
                0: 2.0 * iScale,
                int(s * 20): 0.1 * iScale,
                int(s * 25): 0.2 * iScale,
                int(s * 50): 17.0 * iScale,
                int(s * 60): 5.0 * iScale,
                int(s * 80): 4.0 * iScale,
                int(s * 200): 0.6 * iScale,
                int(s * 2000): 0.00 * iScale,
                int(s * 3000): 0.0,
            },
        )
        bsUtils.animate(
            light,
            "radius",
            {
                0: lightRadius * 0.2,
                int(s * 50): lightRadius * 0.55,
                int(s * 100): lightRadius * 0.3,
                int(s * 300): lightRadius * 0.15,
                int(s * 1000): lightRadius * 0.05,
            },
        )
        bs.gameTimer(int(s * 3000), light.delete)

        # make a scorch that fades over time
        scorch = bs.newNode(
            "scorch", attrs={"position": position, "size": scorchRadius * 0.5, "big": (self.blastType == "tnt")}
        )
        if self.blastType == "ice":
            scorch.color = (1, 1, 1.5)

        bsUtils.animate(scorch, "presence", {3000: 1, 13000: 0})
        bs.gameTimer(13000, scorch.delete)

        if self.blastType == "ice":
            bs.playSound(factory.hissSound, position=light.position)

        p = light.position
        bs.playSound(factory.getRandomExplodeSound(), position=p)
        bs.playSound(factory.debrisFallSound, position=p)

        ########
        bs.shakeCamera(intensity=5.0 if self.blastType == "tnt" else 0.05)
        ########

        # tnt is more epic..
        if self.blastType == "tnt":
            bs.playSound(factory.getRandomExplodeSound(), position=p)

            def _extraBoom():
                bs.playSound(factory.getRandomExplodeSound(), position=p)

            bs.gameTimer(250, _extraBoom)

            def _extraDebrisSound():
                bs.playSound(factory.debrisFallSound, position=p)
                bs.playSound(factory.woodDebrisFallSound, position=p)

            bs.gameTimer(400, _extraDebrisSound)
	def __init__(self, position=(0, 1, 0), velocity=(0, 0, 0), bombType='tnt', blastRadius=2.0, sourcePlayer=None, owner=None):
		"""
		Create a new Bomb.

		bombType can be 'ice','impact','landMine','normal','sticky', or 'tnt'.
		Note that for impact or landMine bombs you have to call arm()
		before they will go off.
		"""
		bs.Actor.__init__(self)

		factory = self.getFactory()

		self.bombType = bombType = 'tnt'

		self._exploded = False

		self.blastRadius = blastRadius

		# TNT
		self.blastRadius *= 1.45

		self._explodeCallbacks = []

		# the player this came from
		self.sourcePlayer = sourcePlayer

		# by default our hit type/subtype is our own, but we pick up types of whoever
		# sets us off so we know what caused a chain reaction
		self.hitType = 'explosion'
		self.hitSubType = self.bombType

		# if no owner was provided, use an unconnected node ref
		if owner is None:
			owner = bs.Node(None)

		# the node this came from
		self.owner = owner


		# TNT
		materials = (factory.bombMaterial, bs.getSharedObject('footingMaterial'), bs.getSharedObject('objectMaterial'))
		materials = materials + (factory.normalSoundMaterial,)


		self.node = bs.newNode('prop',
							   delegate=self,
							   attrs={'position':position,
									  'velocity':velocity,
									  'model':factory.tntModel,
									  'lightModel':factory.tntModel,
									  'body':'crate',
									  'shadowSize':0.5,
									  'colorTexture':factory.tntTex,
									  'reflection':'soft',
									  'reflectionScale':[0.23],
									  'materials':materials})


		#self.node.extraAcceleration = (0, 40, 0)
		self.heldBy = 0
		self._isDead = False


		bsUtils.animate(self.node, "modelScale", {0:0, 200:1.3, 260:1})