コード例 #1
0
 def _doEmit():
     bs.emitBGDynamics(position=position, velocity=velocity,
                       count=int(4.0+random.random()*8), scale=0.8,
                       chunkType='sweat');
     bs.emitBGDynamics(position=position, velocity=velocity,
                       count=int(4.0+random.random()*8), scale=0.8,
                       chunkType='sweat');
コード例 #2
0
 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')
コード例 #3
0
 def _emitExtraSparks():
     bs.emitBGDynamics(position=position,
                       velocity=velocity,
                       count=int(10.0 + random.random() * 20),
                       scale=0.8,
                       spread=1.5,
                       chunkType='spark')
コード例 #4
0
 def _emitSplinters():
     bs.emitBGDynamics(position=position,
                       velocity=velocity,
                       count=int(20.0 + random.random() * 25),
                       scale=0.8,
                       spread=1.0,
                       chunkType='splinter')
コード例 #5
0
    def handleMessage(self, m):
        if isinstance(m, bs.DieMessage):
            if self.node is not None and self.node.exists():
                bs.playSound(bs.getSound('shatter'),
                             position=self.node.position)
                bs.emitBGDynamics(position=self.node.position,
                                  velocity=(0, 4, 0),
                                  count=14,
                                  scale=0.8,
                                  chunkType='spark',
                                  spread=1.5)
            self.node.delete()
            self.bodyNode.delete()

        elif isinstance(m, bs.OutOfBoundsMessage):
            self.node.delete()
            self.bodyNode.delete()

        elif isinstance(m, bs.HitMessage):
            self.node.handleMessage("impulse", m.pos[0], m.pos[1], m.pos[2],
                                    m.velocity[0], m.velocity[1],
                                    m.velocity[2], 1.0 * m.magnitude,
                                    1.0 * m.velocityMagnitude, m.radius, 0,
                                    m.forceDirection[0], m.forceDirection[1],
                                    m.forceDirection[2])

        else:
            bs.Actor.handleMessage(self, m)
コード例 #6
0
ファイル: bsBomb.py プロジェクト: Delitel-WEB/Delitel_ModPACK
    def _handleHit(self, msg):
        isPunch = (msg.srcNode.exists() and msg.srcNode.getNodeType() == 'spaz')
        if self.bombType == 'qq':
            bs.emitBGDynamics(position=msg.pos, velocity=(1 + random.random(), 1 + random.random(), 1 + random.random()), count = 50 + random.randrange(10,100), spread=0.8, scale=0.6, chunkType = 'spark');
        # normal bombs are triggered by non-punch impacts..
        # impact-bombs by all impacts
        if (not self._exploded and not isPunch
            or self.bombType in ['impact', 'landMine']):
            # also lets change the owner of the bomb to whoever is setting
            # us off.. (this way points for big chain reactions go to the
            # person causing them)
            if msg.sourcePlayer not in [None]:
                self.sourcePlayer = msg.sourcePlayer

                # also inherit the hit type (if a landmine sets off by a bomb,
                # the credit should go to the mine)
                # the exception is TNT.  TNT always gets credit.
                if self.bombType != 'tnt':
                    self.hitType = msg.hitType
                    self.hitSubType = msg.hitSubType

            bs.gameTimer(100+int(random.random()*100),
                         bs.WeakCall(self.handleMessage, ExplodeMessage()))
        self.node.handleMessage(
            "impulse", msg.pos[0], msg.pos[1], msg.pos[2],
            msg.velocity[0], msg.velocity[1], msg.velocity[2],
            msg.magnitude, msg.velocityMagnitude, msg.radius, 0,
            msg.velocity[0], msg.velocity[1], msg.velocity[2])

        if msg.srcNode.exists():
            pass
コード例 #7
0
ファイル: bsBomb.py プロジェクト: Delitel-WEB/Delitel_ModPACK
 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');
コード例 #8
0
 def emit(self):
     bs.emitBGDynamics(position=self.node.position,
                       velocity=self.node.velocity,
                       count=10,
                       scale=0.4,
                       spread=0.01,
                       chunkType='spark')
コード例 #9
0
 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",
     )
コード例 #10
0
 def _onCapsulePlayerCollide(self):
     if not self.hasEnded():
         capsuleNode, playerNode = bs.getCollisionInfo('sourceNode','opposingNode')
         if capsuleNode is not None and playerNode is not None:
             capsule = capsuleNode.getDelegate()
             spaz = playerNode.getDelegate()
             player = spaz.getPlayer() if hasattr(spaz,'getPlayer') else None
             if player is not None and player.exists() and capsule is not None:
                 if player.isAlive():
                     if capsuleNode.colorTexture == self._capsuleLuckyTex:
                         player.gameData['capsules'] += 4
                         bsUtils.PopupText('BONUS!',
                                           color=(1,1,0),
                                           scale=1.5,
                                           position=(capsuleNode.position)).autoRetain()
                         bs.playSound(self._luckyCollectSound,1.0,position=capsuleNode.position)
                         bs.emitBGDynamics(position=capsuleNode.position,velocity=(0,0,0),count=int(6.4+random.random()*24),scale=1.2, spread=2.0,chunkType='spark');
                         bs.emitBGDynamics(position=capsuleNode.position,velocity=(0,0,0),count=int(4.0+random.random()*6),emitType='tendrils');
                     else:
                         player.gameData['capsules'] += 1
                         bs.playSound(self._collectSound,0.6,position=capsuleNode.position)
                     # create a flash
                     light = bs.newNode('light',
                                     attrs={'position': capsuleNode.position,
                                             'heightAttenuated':False,
                                             'radius':0.1,
                                             'color':(1,1,0)})
                     
                     # Create a short text informing about your inventory
                     self._handleCapsuleStorage(playerNode.position,player)
                     
                     bs.animate(light,'intensity',{0:0,100:0.5,200:0},loop=False)
                     bs.gameTimer(200,light.delete)
                     capsule.handleMessage(bs.DieMessage())
コード例 #11
0
 def spurt(self):
     bomb = bs.Bomb(position=(self.position[0], self.position[1] + 2,
                              self.position[2]),
                    velocity=(6 * random.random() - 3, 8,
                              6 * random.random() - 3),
                    sourcePlayer=self.player).autoRetain()
     bs.emitBGDynamics(position=self.position, velocity=(0, 8, 0), count=10)
コード例 #12
0
 def _doEmit():
     bs.emitBGDynamics(position=position,
                       velocity=velocity,
                       count=30,
                       spread=2.0,
                       scale=0.4,
                       chunkType='ice',
                       emitType='stickers')
コード例 #13
0
 def emit(self):
     if self.owner.exists():
         vel = 4
         bs.emitBGDynamics(position=(self.owner.torsoPosition[0]-0.25+random.random()*0.5,self.owner.torsoPosition[1]-0.25+random.random()*0.5,self.owner.torsoPosition[2]-0.25+random.random()*0.5),
                           velocity=((-vel+(random.random()*(vel*2)))+self.owner.velocity[0]*2,(-vel+(random.random()*(vel*2)))+self.owner.velocity[1]*4,(-vel+(random.random()*(vel*2)))+self.owner.velocity[2]*2),
                           count=10,
                           scale=0.3+random.random()*1.1,
                           spread=0.1,
                           chunkType='sweat')
コード例 #14
0
 def _emitExtraSparks():
     bs.emitBGDynamics(
         position=position,
         velocity=velocity,
         count=int(10.0 + random.random() * 20),
         scale=0.8,
         spread=1.5,
         chunkType="spark",
     )
コード例 #15
0
 def _emitSplinters():
     bs.emitBGDynamics(
         position=position,
         velocity=velocity,
         count=int(20.0 + random.random() * 25),
         scale=0.8,
         spread=1.0,
         chunkType="splinter",
     )
コード例 #16
0
 def _doEmit():
     bs.emitBGDynamics(
         position=position,
         velocity=velocity,
         count=30,
         spread=2.0,
         scale=0.4,
         chunkType="ice",
         emitType="stickers",
     )
コード例 #17
0
 def doBust(self):
     if self.exists():
         if not self._exploded:
             self._exploded = True
             bs.emitBGDynamics(position=self.node.position,velocity=[v*0.1 for v in self.node.velocity],count=10,spread=0.1,scale=0.4,chunkType='ice')
             #Do a muffled punch sound
             sound = self.getFactory().impactSound
             bs.playSound(sound,1.0,position=self.node.position)
             scl = self.node.modelScale
             bsUtils.animate(self.node,"modelScale",{0:scl*1.0, 20:scl*0.5, 50:0.0})
             bs.gameTimer(80,bs.WeakCall(self.handleMessage,bs.DieMessage()))
コード例 #18
0
ファイル: prefix.py プロジェクト: Delitel-WEB/Delitel_ModPACK
 def emit(self):
     if self.owner.exists():
         bs.emitBGDynamics(position=tuple([
             self.owner.position[i] + random.uniform(-0.3, 0.3)
             for i in range(3)
         ]),
                           velocity=(0, 0, 0),
                           count=10,
                           scale=0.385 + random.uniform(-0.2, 0.2),
                           spread=0.05,
                           chunkType=self.particles_type)
コード例 #19
0
 def run():
     pos = (random.randint(-10, 10), random.randrange(14, 15),
            random.randint(-10, 10))
     bs.emitBGDynamics(position=pos,
                       velocity=tuple([
                           1.0 * random.randrange(1, 2)
                           for i in range(3)
                       ]),
                       count=random.randint(1000, 1200),
                       scale=1,
                       spread=0.8,
                       chunkType='spark')
コード例 #20
0
ファイル: bsBomb.py プロジェクト: xencodes/bombsquad
 def _doEmit():
     bs.emitBGDynamics(position=position,
                       velocity=velocity,
                       count=30,
                       scale=1.0,
                       chunkType='spark',
                       emitType='stickers')
     bs.emitBGDynamics(position=position,
                       velocity=velocity,
                       count=int(18.0 + random.random() * 30),
                       scale=1.0,
                       spread=2.5,
                       chunkType='spark')
コード例 #21
0
def newPlayerSpazDeathMessageInit(self, spaz, wasKilled, killerPlayer, how):
        """
        Instantiate a message with the given values.
        """
        self.spaz = spaz
        self.killed = wasKilled
        self.killerPlayer = killerPlayer
        self.how = how

        deff = bs.getConfig()["effectsMod"]["deathEffect"]

        if deff == "none": pass
        elif deff == "bones":
                #self.node.dead = False
            char = 'Bones'
            factory = self.spaz.getFactory()
            media = factory._getMedia(char)
            self.spaz.node.colorTexture=media['colorTexture']
            self.spaz.node.colorMaskTexture=media['colorMaskTexture']
            self.spaz.node.headModel=media['headModel']
            self.spaz.node.torsoModel=media['torsoModel']
            self.spaz.node.pelvisModel=media['pelvisModel']
            self.spaz.node.upperArmModel=media['upperArmModel']
            self.spaz.node.foreArmModel=media['foreArmModel']
            self.spaz.node.handModel=media['handModel']
            self.spaz.node.upperLegModel=media['upperLegModel']
            self.spaz.node.lowerLegModel=media['lowerLegModel']
            self.spaz.node.toesModel=media['toesModel']
            self.spaz.node.style=factory._getStyle(char)
        
        elif deff == 'show':doRing(self,deff)
        elif deff == 'xplode':doRing(self,deff)
        elif deff == 'fly':
            if self.spaz.shattered: pass
            def update():
                pos = self.spaz.node.position
                self.spaz.node.handleMessage("impulse",pos[0],pos[1]+0.5,pos[2],0,5,0,3,10,0,0, 0,5,0)
            delay = 0
            for i in range(40):
                bs.gameTimer(delay,bs.Call(update))
                delay += 50
        elif deff == 'skull':
            pos = self.spaz.node.position
            bsUtils.PopupText(bs.getSpecialChar('skull'),color=(1,1,1),scale=5,position=(pos[0],pos[1]-2,pos[2])).autoRetain()
            bs.emitBGDynamics(position=self.spaz.node.position,velocity=self.spaz.node.velocity,count=int(4.0+random.random()*30),emitType='tendrils');
            #bs.emitBGDynamics(position=self.node.position,velocity=(0,10,0),count=100,spread=0.3,scale=3,chunkType='sweat');
        else:
            delay = 0
            for i in range(5):
                bs.gameTimer(delay,bs.Call(doRing,self,deff))
                delay += 300
コード例 #22
0
 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",
     )
コード例 #23
0
ファイル: bsBomb.py プロジェクト: xencodes/bombsquad
 def _emitSplinters():
     bs.emitBGDynamics(position=position,
                       velocity=(0, 0, 0),
                       count=400,
                       spread=1.7,
                       chunkType='rock')
     bs.getSharedObject('globals').slowMotion = True
     bs.emitBGDynamics(position=position,
                       velocity=velocity,
                       count=int(20.0 +
                                 random.random() * 25),
                       scale=0.8,
                       spread=1.0,
                       chunkType='splinter')
コード例 #24
0
            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)
コード例 #25
0
 def snowfall():
     for i in range(5):
         pos = (random.uniform(MapBounds[0], MapBounds[3]),
                MapBounds[4] - random.uniform(0, 0.3),
                random.uniform(MapBounds[2], MapBounds[5]))
         #vel2 = (random.uniform(-2,2),0,random.uniform(-2,2))
         #color = (random.uniform(.5,1),random.uniform(0.5,1),random.uniform(.5,1))
         # portalObjects.Bubble(position=pos,velocity=vel2,thrust=0,color=color)
         vel = (0, 0, 0)  # (random.uniform(-2,2),0,random.uniform(-2,2))
         bs.emitBGDynamics(position=pos,
                           velocity=vel,
                           count=5,
                           scale=0.5,
                           spread=0.2,
                           chunkType="ice")
コード例 #26
0
            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)
コード例 #27
0
 def buffedSparks():
     if self.node.exists() and self.bombType not in [
             'forceBomb', 'tnt', 'impact', 'curseBomb'
     ]:
         bs.emitBGDynamics(position=(self.node.position[0],
                                     self.node.position[1],
                                     self.node.position[2]),
                           velocity=self.node.velocity,
                           count=random.randrange(3, 5),
                           scale=0.4,
                           spread=0.1,
                           chunkType='spark')
         bs.gameTimer(10, bs.Call(buffedSparks))
         self.blastBuffed = True
     else:
         self.blastBuffed = False
コード例 #28
0
 def spawnParticles():
     sin = math.sin(self.s)*self.r
     cos = math.cos(self.s)*self.r
     self.s += 0.1
     
     if self.r < 0:
         self.revers = True
     elif self.r > self.maxR:
         self.revers = False
      
     if not self.revers:
         self.r -= 0.003
         self.y += 0.008
     else:
         self.r += 0.003
         self.y -= 0.008
         
     bs.emitBGDynamics(position=(self.x + cos, self.y, self.z + sin),count=5,scale=1,spread=0,chunkType='spark')
コード例 #29
0
 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');
コード例 #30
0
    def handleMessage(self, m):
        if isinstance(m, bs.DieMessage):
            self.node.delete()
            self.timer = None

        elif isinstance(m, bs.OutOfBoundsMessage):
            self.node.delete()
            self.timer = None

        elif isinstance(m, bs.HitMessage):
            bs.playSound(bs.getSound('shatter'), position=self.node.position)
            bs.emitBGDynamics(position=self.node.position,
                              velocity=(0, 4, 0),
                              count=14,
                              scale=0.8,
                              chunkType='spark',
                              spread=1.5)
            self.node.delete()
            self.timer = None

        else:
            bs.Actor.handleMessage(self, m)
コード例 #31
0
	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)
コード例 #32
0
 def emit(self):
     bs.emitBGDynamics(position=self.node.position, velocity=self.node.velocity, count=4, scale=2, spread=0.1,
                       chunkType='sweat')
コード例 #33
0
    def __init__(self,
                 position=(0, 1, 0),
                 powerupType='tripleBombs',
                 expire=True):

        bs.Actor.__init__(self)
        factory = self.getFactory()

        if gSettingsEnabled: settings = bs.get_settings()
        else: settings = {}

        self.powerupType = powerupType
        self._powersGiven = False
        if powerupType == 'tripleBombs':
            tex = factory.texBomb
            name = 'TripleBombs'
        elif powerupType == 'multiBombs':
            tex = factory.texMultiBombs
            name = 'MultiBombs'
        elif powerupType == 'punch':
            tex = factory.texPunch
            name = 'Gloves'
        elif powerupType == 'speedPunch':
            tex = factory.texSpeedPunch
            name = 'Gloves 2.0'
        elif powerupType == 'fireworkBombs':
            tex = factory.texFireworkBomb
            name = 'FireWorks'
        elif powerupType == 'killLaKillBombs':
            tex = factory.texKillLaKillBomb
            name = 'KillAll'
        elif powerupType == 'poisonBombs':
            tex = factory.texPoisonBomb
            name = 'PoisonBomb'
        elif powerupType == 'pandoraBox':
            tex = factory.texPandoraBox
            name = 'PandoraBox'
        elif powerupType == 'yellowShield':
            tex = factory.texYellowShield
            name = 'YellowShield'
        elif powerupType == 'jumpingBombs':
            tex = factory.texJumpingBomb
            name = 'JumpingBomb'
        elif powerupType == 'tpBombs':
            tex = factory.texTpBombs
            name = 'TPBomb'
        elif powerupType == 'iceBombs':
            tex = factory.texIceBombs
            name = 'IcyBombs'
        elif powerupType == 'impactBombs':
            tex = factory.texImpactBombs
            name = 'ImpactBombs'
        elif powerupType == 'landMines':
            tex = factory.texLandMines
            name = 'LandMines'
        elif powerupType == 'stickyBombs':
            tex = factory.texStickyBombs
            name = 'StickyBombs'
        elif powerupType == 'shield':
            tex = factory.texShield
            name = 'Bubble'
        elif powerupType == 'health':
            tex = factory.texHealth
            name = 'Health'
        elif powerupType == 'curse':
            tex = factory.texCurse
            name = 'Pls Touch Me'
        elif powerupType == 'unbreakable':
            tex = factory.texUnb
            name = 'Unbreakable'
        elif powerupType == 'dirtBombs':
            tex = factory.texDirt
            name = 'DirtBomb'
        elif powerupType == 'speed':
            tex = factory.texSpeed  # new powerups begin
        elif powerupType == 'alan':
            tex = factory.texAlan
            name = 'Boss'
        elif powerupType == 'rdm':
            tex = factory.texRDM
            name = 'RandomBomb'
        elif powerupType == 'randomCharacter':
            tex = factory.RandomCharacter
            name = 'Random Char'
        elif powerupType == 'troll':
            tex = factory.Troll
            name = 'FunPack'
        elif powerupType == 'mj':
            tex = factory.texmj
            name = 'MJ'
        elif powerupType == 'impactMess':
            tex = factory.teximpactMess
            name = 'ImpactMess'
        elif powerupType == 'Motion':
            tex = factory.texMotion
            name = 'Motion'
        elif powerupType == 'invisibility':
            tex = factory.texInvisibility
            name = 'Invisibile'
        elif powerupType == 'hijump':
            tex = factory.texHiJump
            name = 'Hi-Jump'
        elif powerupType == 'ballon':
            tex = factory.texBallon
            name = 'Ballon'
        elif powerupType == 'BlockPowerup':
            tex = factory.texBlock
            name = 'Block'
        elif powerupType == 'iceImpact':
            tex = factory.texiceImpact
            name = 'IceImpact'
        elif powerupType == 'goldenBomb':
            tex = factory.texGoldenBomb
            name = 'BlastyBomb'
        elif powerupType == 'tbomb':
            tex = factory.textbomb
            name = 'TBomb'
        elif powerupType == 'gluebomb':
            tex = factory.texgluebomb
            name = 'Broken Glue'
        elif powerupType == 'weedbomb':
            tex = factory.texweedbomb
            name = 'WeedBomb'
        elif powerupType == 'bot':
            tex = factory.texBot
            name = 'Buddy Bot'
        elif powerupType == 'celebrate':
            tex = factory.texcelebrate
            name = 'Celebrate'
        elif powerupType == 'FloatingMine':
            tex = factory.texFloatingMine
            name = 'LandMines'
        elif powerupType == 'TouchMe':
            tex = factory.texTouchMe
            name = 'TouchMe'
        elif powerupType == 'radius':
            tex = factory.texRadius
            name = 'Radius'
        elif powerupType == 'sleep':
            tex = factory.texSleep
            name = 'Sleepy'
        elif powerupType == 'night':
            tex = factory.texNight
            name = 'NiteNite'
        elif powerupType == 'spazBomb':
            tex = factory.texSpazBomb
            name = 'SpazBomb'
        elif powerupType == 'curseBomb':
            tex = factory.texcurseBomb
            name = 'CurseBomb'
        elif powerupType == 'characterBomb':
            tex = factory.texcharacterBomb
            name = 'CharBomb'
        elif powerupType == 'mjBomb':
            tex = factory.texmjBomb
            name = 'MJBomb'
        elif powerupType == 'trioBomb':
            tex = factory.textrioBomb
            name = 'ImpactTrio'
        elif powerupType == 'speedBomb':
            tex = factory.texspeedBomb
            name = 'ShockWave'
        elif powerupType == 'healBomb':
            tex = factory.texhealBomb
            name = 'HealthBomb'
        elif powerupType == 'nightBomb':
            tex = factory.texNightBomb
            name = 'AtomBomb'
        elif powerupType == 'revengeBomb':
            tex = factory.texrevengeBomb
            name = 'RevengeBomb'
        elif powerupType == 'blastBomb':
            tex = factory.texblastBomb
            name = 'blastBomb'
        elif powerupType == 'knockBomb':
            tex = factory.texknockBomb
            name = 'KnockBomb'
        elif powerupType == 'stickyIce':
            tex = factory.texstickyIce
            name = 'StickyIce'
        elif powerupType == 'stickyIceTrio':
            tex = factory.texstickyIceTrio
            name = 'StickyIceTrio'
        elif powerupType == 'stickyIceMess':
            tex = factory.texstickyIceMess
            name = 'StickyIceMess'
        elif powerupType == 'stickyMess':
            tex = factory.texStickyMess
            name = 'StickyMess'
        elif powerupType == 'icyMess':
            tex = factory.texIcyMess
            name = 'IcyMess'
        elif powerupType == 'icyTrio':
            tex = factory.texicyTrio
            name = 'IcyTrio'
        elif powerupType == 'weee':
            tex = factory.texWeee
            name = 'Health'
        elif powerupType == 'tnt':
            tex = factory.texTnt
            name = 'TNT'
        elif powerupType == 'boomBomb':
            tex = factory.texboomBomb
            name = 'KaboomBomb'
        elif powerupType == 'name':
            tex = factory.texName
            name = 'NewName'
        elif powerupType == 'highlight':
            tex = factory.texHighlight
            name = 'HighLight'
        elif powerupType == 'spotlight':
            tex = factory.texSpotlight
            name = 'Spotlight'
        elif powerupType == 'jumpFly':
            tex = factory.texjumpFly
            name = 'FlyJump'
        elif powerupType == 'use':
            tex = factory.texuse
            name = 'FlyBomb'
        elif powerupType == "antiGrav":
            tex = factory.texAntiGrav
            name = 'AntiGrav'
        elif powerupType == "BlackHole":
            tex = factory.texBlackHole
            name = 'BlackHole'
        elif powerupType == "Slippery":
            tex = factory.texSlippery
            name = 'LuckyBlock'
        elif powerupType == "Box":
            tex = factory.texBox
            name = 'Box'
        elif powerupType == 'snoball':
            tex = factory.texSno
            mod = factory.snoModel
            name = "shieldBall"
        elif powerupType == 'pass':
            return
        else:
            raise Exception("invalid powerupType: " + str(powerupType))

        if len(position) != 3:
            raise Exception("expected 3 floats for position")

        if powerupType == 'poisonBombs':
            refScale = (0, 3, 0)
            ref = 'soft'
        elif powerupType == 'pandoraBox':
            ref = 'soft'
            refScale = (1, 1, 1)
        elif powerupType == 'dirtBombs':
            ref = 'soft'
            refScale = (1, 0.4, 0.16)
        else:
            refScale = [0.95]
            ref = 'powerup'
        self.node = bs.newNode('prop',
                               delegate=self,
                               attrs={
                                   'body':
                                   'box',
                                   'position':
                                   position,
                                   'model':
                                   factory.model,
                                   'lightModel':
                                   factory.modelSimple,
                                   'shadowSize':
                                   0.48,
                                   'colorTexture':
                                   tex,
                                   'reflection':
                                   ref,
                                   'reflectionScale':
                                   refScale,
                                   'materials':
                                   (factory.powerupMaterial,
                                    bs.getSharedObject('objectMaterial'))
                               })
        prefixAnim = {
            0: (1, 0, 0),
            250: (1, 1, 0),
            250 * 2: (0, 1, 0),
            250 * 3: (0, 1, 1),
            250 * 4: (1, 0, 1),
            250 * 5: (0, 0, 1),
            250 * 6: (1, 0, 0)
        }
        color = (0, 0, 1)

        if don.powerupName:
            m = bs.newNode('math',
                           owner=self.node,
                           attrs={
                               'input1': (0, 0.7, 0),
                               'operation': 'add'
                           })
            self.node.connectAttr('position', m, 'input2')
            self.nodeText = bs.newNode('text',
                                       owner=self.node,
                                       attrs={
                                           'text': str(name),
                                           'inWorld': True,
                                           'shadow': 1.0,
                                           'flatness': 1.0,
                                           'color': color,
                                           'scale': 0.0,
                                           'hAlign': 'center'
                                       })
            m.connectAttr('output', self.nodeText, 'position')
            bs.animate(self.nodeText, 'scale', {0: 0, 140: 0.016, 200: 0.01})
            bs.animateArray(
                self.nodeText, 'color', 3, {
                    0: (0, 0, 2),
                    500: (0, 2, 0),
                    1000: (2, 0, 0),
                    1500: (2, 2, 0),
                    2000: (2, 0, 2),
                    2500: (0, 1, 6),
                    3000: (1, 2, 0)
                }, True)
            bs.emitBGDynamics(position=self.nodeText.position,
                              velocity=self.node.position,
                              count=200,
                              scale=1.4,
                              spread=2.01,
                              chunkType='sweat')

        if don.shieldOnPowerUps:
            self.nodeShield = bs.newNode('shield',
                                         owner=self.node,
                                         attrs={
                                             'color':
                                             color,
                                             'position':
                                             (self.node.position[0],
                                              self.node.position[1],
                                              self.node.position[2] + 0.5),
                                             'radius':
                                             1.2
                                         })
            self.node.connectAttr('position', self.nodeShield, 'position')
            bsUtils.animateArray(self.nodeShield, 'color', 3, prefixAnim, True)

        if don.discoLights:
            self.nodeLight = bs.newNode('light',
                                        attrs={
                                            'position': self.node.position,
                                            'color': color,
                                            'radius': 0.2,
                                            'volumeIntensityScale': 0.5
                                        })
            self.node.connectAttr('position', self.nodeLight, 'position')
            bsUtils.animateArray(self.nodeLight, 'color', 3, prefixAnim, True)
            bs.animate(self.nodeLight,
                       "intensity", {
                           0: 1.0,
                           1000: 1.8,
                           2000: 1.0
                       },
                       loop=True)
            bs.gameTimer(8000, self.nodeLight.delete)

        if don.powerupTimer:
            self.powerupHurt = bs.newNode('shield',
                                          owner=self.node,
                                          attrs={
                                              'color': (1, 1, 1),
                                              'radius': 0.1,
                                              'hurt': 1,
                                              'alwaysShowHealthBar': True
                                          })
            self.node.connectAttr('position', self.powerupHurt, 'position')
            bs.animate(self.powerupHurt, 'hurt', {
                0: 0,
                defaultPowerupInterval - 1000: 1
            })
        bs.gameTimer(defaultPowerupInterval - 1000, bs.Call(self.do_delete))

        curve = bs.animate(self.node, "modelScale", {0: 0, 140: 1.6, 200: 1})
        bs.gameTimer(200, curve.delete)

        if expire:
            bs.gameTimer(defaultPowerupInterval - 2500,
                         bs.WeakCall(self._startFlashing))
            bs.gameTimer(defaultPowerupInterval - 1000,
                         bs.WeakCall(self.handleMessage, bs.DieMessage()))
コード例 #34
0
    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)
コード例 #35
0
	def handleMessage(self, m):
		if isinstance(m, bs.HitMessage):
			if not self.node.exists():
				return
			if self.node.invincible == True:
				bs.playSound(self.getFactory().blockSound, 1.0, position=self.node.position)
				return True

			# if we were recently hit, don't count this as another
			# (so punch flurries and bomb pileups essentially count as 1 hit)
			gameTime = bs.getGameTime()
			if self._lastHitTime is None or gameTime - self._lastHitTime > 1000:
				self._numTimesHit += 1
				self._lastHitTime = gameTime

			mag = m.magnitude * self._impactScale
			velocityMag = m.velocityMagnitude * self._impactScale

			damageScale = 0.22

			# if they've got a shield, deliver it to that instead..
			if self.shield is not None:
				if m.flatDamage:
					damage = m.flatDamage * self._impactScale
				else:
					# hit our spaz with an impulse but tell it to only return theoretical damage; not apply the impulse..
					self.node.handleMessage("impulse", m.pos[0], m.pos[1], m.pos[2],
											m.velocity[0], m.velocity[1], m.velocity[2],
											mag, velocityMag, m.radius, 1,
											m.forceDirection[0], m.forceDirection[1], m.forceDirection[2])
					damage = damageScale * self.node.damage

				self.shieldHitPoints -= damage

				self.shield.hurt = 1.0 - self.shieldHitPoints / self.shieldHitPointsMax
				# its a cleaner event if a hit just kills the shield without damaging the player..
				# however, massive damage events should still be able to damage the player..
				# this hopefully gives us a happy medium.
				maxSpillover = 500
				if self.shieldHitPoints <= 0:
					# fixme - transition out perhaps?..
					self.shield.delete()
					self.shield = None
					bs.playSound(self.getFactory().shieldDownSound, 1.0, position=self.node.position)
					# emit some cool lookin sparks when the shield dies
					t = self.node.position
					bs.emitBGDynamics(position=(t[0], t[1]+0.9, t[2]),
									  velocity=self.node.velocity,
									  count=random.randrange(20, 30), scale=1.0,
									  spread=0.6, chunkType='spark')

				else:
					bs.playSound(self.getFactory().shieldHitSound, 0.5, position=self.node.position)

				# emit some cool lookin sparks on shield hit
				bs.emitBGDynamics(position=m.pos,
								  velocity=(m.forceDirection[0]*1.0,
											m.forceDirection[1]*1.0,
											m.forceDirection[2]*1.0),
								  count=min(30, 5+int(damage*0.005)), scale=0.5, spread=0.3, chunkType='spark')


				# if they passed our spillover threshold, pass damage along to spaz
				if self.shieldHitPoints <= -maxSpillover:
					leftoverDamage = -maxSpillover - self.shieldHitPoints
					shieldLeftoverRatio = leftoverDamage / damage

					# scale down the magnitudes applied to spaz accordingly..
					mag *= shieldLeftoverRatio
					velocityMag *= shieldLeftoverRatio
				else:
					return True # good job shield!
			else: shieldLeftoverRatio = 1.0

			if m.flatDamage:
				damage = m.flatDamage * self._impactScale * shieldLeftoverRatio
			else:
				# hit it with an impulse and get the resulting damage
				#bs.screenMessage(str(velocityMag))
				if self.multiplyer > 3.0:
					# at about 8.0 the physics glitch out
					velocityMag *= min((3.0 + (self.multiplyer-3.0)/4), 7.5) ** 1.9
				else:
					velocityMag *= self.multiplyer ** 1.9
				self.node.handleMessage("impulse", m.pos[0], m.pos[1], m.pos[2],
										m.velocity[0], m.velocity[1], m.velocity[2],
										mag, velocityMag, m.radius, 0,
										m.forceDirection[0], m.forceDirection[1], m.forceDirection[2])

				damage = damageScale * self.node.damage
			self.node.handleMessage("hurtSound")

			# play punch impact sound based on damage if it was a punch
			if m.hitType == 'punch':

				self.onPunched(damage)

				# if damage was significant, lets show it
				#if damage > 350: bsUtils.showDamageCount('-'+str(int(damage/10))+"%",m.pos,m.forceDirection)

				# lets always add in a super-punch sound with boxing gloves just to differentiate them
				if m.hitSubType == 'superPunch':
					bs.playSound(self.getFactory().punchSoundStronger, 1.0,
								 position=self.node.position)

				if damage > 500:
					sounds = self.getFactory().punchSoundsStrong
					sound = sounds[random.randrange(len(sounds))]
				else: sound = self.getFactory().punchSound
				bs.playSound(sound, 1.0, position=self.node.position)

				# throw up some chunks
				bs.emitBGDynamics(position=m.pos,
								  velocity=(m.forceDirection[0]*0.5,
											m.forceDirection[1]*0.5,
											m.forceDirection[2]*0.5),
								  count=min(10, 1+int(damage*0.0025)), scale=0.3, spread=0.03)

				bs.emitBGDynamics(position=m.pos,
								  chunkType='sweat',
								  velocity=(m.forceDirection[0]*1.3,
											m.forceDirection[1]*1.3+5.0,
											m.forceDirection[2]*1.3),
								  count=min(30, 1 + int(damage * 0.04)),
								  scale=0.9,
								  spread=0.28)
				# momentary flash
				hurtiness = damage*0.003
				hurtiness = min(hurtiness, 750 * 0.003)
				punchPos = (m.pos[0]+m.forceDirection[0]*0.02,
							m.pos[1]+m.forceDirection[1]*0.02,
							m.pos[2]+m.forceDirection[2]*0.02)
				flashColor = (1.0, 0.8, 0.4)
				light = bs.newNode("light",
								   attrs={'position':punchPos,
										  'radius':0.12+hurtiness*0.12,
										  'intensity':0.3*(1.0+1.0*hurtiness),
										  'heightAttenuated':False,
										  'color':flashColor})
				bs.gameTimer(60, light.delete)


				flash = bs.newNode("flash",
								   attrs={'position':punchPos,
										  'size':0.17+0.17*hurtiness,
										  'color':flashColor})
				bs.gameTimer(60, flash.delete)

			if m.hitType == 'impact':
				bs.emitBGDynamics(position=m.pos,
								  velocity=(m.forceDirection[0]*2.0,
											m.forceDirection[1]*2.0,
											m.forceDirection[2]*2.0),
								  count=min(10, 1 + int(damage * 0.01)), scale=0.4, spread=0.1)

			if self.hitPoints > 0:

				# its kinda crappy to die from impacts, so lets reduce impact damage
				# by a reasonable amount if it'll keep us alive
				if m.hitType == 'impact' and damage > self.hitPoints:
					# drop damage to whatever puts us at 10 hit points, or 200 less than it used to be
					# whichever is greater (so it *can* still kill us if its high enough)
					newDamage = max(damage-200, self.hitPoints-10)
					damage = newDamage

				self.node.handleMessage("flash")
				# if we're holding something, drop it
				if damage > 0.0 and self.node.holdNode.exists():
					self.node.holdNode = bs.Node(None)
				#self.hitPoints -= damage
				self.multiplyer += min(damage / 2000, 0.15)
				if damage/2000 > 0.05:
					self.setScoreText(str(int((self.multiplyer-1)*100))+"%")
				#self.node.hurt = 1.0 - self.hitPoints/self.hitPointsMax
				self.node.hurt = 0.0
				# if we're cursed, *any* damage blows us up
				if self._cursed and damage > 0:
					bs.gameTimer(50, bs.WeakCall(self.curseExplode, m.sourcePlayer))
				# if we're frozen, shatter.. otherwise die if we hit zero
				#if self.frozen and (damage > 200 or self.hitPoints <= 0):
				#	self.shatter()
				#elif self.hitPoints <= 0:
				#	self.node.handleMessage(bs.DieMessage(how='impact'))

			# if we're dead, take a look at the smoothed damage val
			# (which gives us a smoothed average of recent damage) and shatter
			# us if its grown high enough
			#if self.hitPoints <= 0:
			#	damageAvg = self.node.damageSmoothed * damageScale
			#	if damageAvg > 1000:
			#		self.shatter()
		elif isinstance(m, bs.DieMessage):
			self.oob_effect()
			super(self.__class__, self).handleMessage(m)
		elif isinstance(m, bs.PowerupMessage):
			if m.powerupType == 'health':
				if self.multiplyer > 2:
					self.multiplyer *= 0.5
				else:
					self.multiplyer *= 0.75
				self.multiplyer = max(1, self.multiplyer)
				self.setScoreText(str(int((self.multiplyer-1)*100))+"%")
			super(self.__class__, self).handleMessage(m)
		else:
			super(self.__class__, self).handleMessage(m)
コード例 #36
0
    def handleMessage(self, m):

        if isinstance(m, bs.DieMessage):
            self.body.delete()
            self.loc.delete()
            self.spawner = None
            activity = self._activity()
            if activity and not m.immediate:
                activity.handleMessage(BaseDestroyedMessage())

        elif isinstance(m, bs.OutOfBoundsMessage):
            self.body.delete()
            self.loc.delete()

        elif isinstance(m, bs.FreezeMessage):
            if not self.body.exists(): return
            if not self.frozen:
                self.frozen = True
                bs.gameTimer(10000,
                             bs.WeakCall(self.handleMessage, bs.ThawMessage()))

        elif isinstance(m, bs.ThawMessage):
            if self.frozen and self.body.exists():
                self.frozen = False

        elif isinstance(m, bs.HitMessage):
            if not self.body.exists(): return
            if m.flatDamage: damage = m.flatDamage
            if m.hitType == 'punch':
                damage = randint(1, 3) * 150
                #bs.screenMessage('hitted')
            elif m.hitSubType in ('normal', 'tnt', 'block', 'landMine',
                                  'sticky', 'impact', 'cineticTrap'):
                damage = randint(1, 3) * 300
                #bs.screenMessage('exploded')
            elif m.hitSubType in ('ice', 'iceImpact'):
                damage = randint(1, 3) * 100
                #bs.screenMessage('freezed')
                self.handleMessage(bs.FreezeMessage())
            else:
                bs.playSound(self.errorSound)
                bs.screenMessage('Unknown hit: ' + m.hitSubType)
                damage = 200

            self._onPunched(damage)
            bs.emitBGDynamics(position=self.position,
                              velocity=(0, 0, 0),
                              count=35,
                              scale=0.7,
                              chunkType='spark',
                              emitType='stickers')
            bs.playSound(bs.getSound('punch01'), 1.0, position=self.position)

            # if damage was significant, lets show it
            if damage > 350:
                bs.playSound(bs.getSound('punchStrong01'),
                             1.0,
                             position=self.position)
                bsUtils.showDamageCount('-' + str(int(damage / 10)) + "%",
                                        m.pos, m.forceDirection)

        else:
            bs.Actor.handleMessage(self, m)
コード例 #37
0
    def __init__(self, position=(0,1,0), velocity=(5,0,5), sourcePlayer=None, owner=None, explode=False):
        bs.Actor.__init__(self)

        activity = bs.getActivity()
        factory = self.getFactory()
        # spawn at the provided point
        #random = randint(0,2)
        self._spawnPos = (position[0], position[1]+0.1, position[2])
        self.node = bs.newNode("prop",
                               attrs={'model': factory.snoModel,
                                      'body':'sphere',
                                      'colorTexture': factory.texSno,
                                      'reflection':'soft',
                                      'modelScale':0.0,
                                      'bodyScale':0.8,
                                      'density':1,
                                      'reflectionScale':(0,0,1),
                                      'shadowSize': 0.6,
                                      'position':self._spawnPos,
                                      'velocity':velocity,
                                      'materials': [bs.getSharedObject('objectMaterial'), factory.ballMaterial]
                                      },
                               delegate=self)
        self.sourcePlayer = sourcePlayer
        self.owner = owner
        if factory._ballsMelt: #defaults to True.
            #Snowballs should melt after some time
            bs.gameTimer(1500, bs.WeakCall(self._disappear))
        self._hitNodes = set()
        self._exploded = False
        if factory._ballsBust:
            self.shouldBust = True
        else:
            self.shouldBust = False
        if explode:
            self.shouldExplode = True
        else:
            self.shouldExplode = False
        prefixAnim = {0: (1, 0, 0), 250: (1, 1, 0), 250 * 2: (0, 1, 0), 250 * 3: (0, 1, 1), 250 * 4: (1, 0, 1),
                      250 * 5: (0, 0, 1), 250 * 6: (1, 0, 0)}
            
        self.nodeShield = bs.newNode('shield', owner=self.node, attrs={'color': ((0+random.random()*4.5),(0+random.random()*4.5),(0+random.random()*4.5)),
                                                                       'position': (
                                                                           self.node.position[0],
                                                                           self.node.position[1],
                                                                           self.node.position[2] + 0.5),
                                                                       'radius': 0.65})
        self.node.connectAttr('position', self.nodeShield, 'position')
        bs.animate(self.nodeShield,'radius',{0:0.9,200:1,400:0.9},True)
        
        self.nodeShield2 = bs.newNode('shield', owner=self.node, attrs={'color': ((0+random.random()*4.5),(0+random.random()*4.5),(0+random.random()*4.5)),
                                                                       'position': (
                                                                           self.node.position[0],
                                                                           self.node.position[1],
                                                                           self.node.position[2] + 0.5),
                                                                       'radius': 0.65})
        self.node.connectAttr('position', self.nodeShield2, 'position')
        
        m = bs.newNode('math', owner=self.node, attrs={'input1': (0, 0.7, 0), 'operation': 'add'})
        self.node.connectAttr('position', m, 'input2')
        self.nodeText = bs.newNode('text',
                                   owner=self.node,
                                   attrs={'text': 'ShieldBall',
                                          'inWorld': True,
                                          'shadow': 1.0,
                                          'flatness': 1.0,
                                          'color': (0,0,1),
                                          'scale': 0.0,
                                          'hAlign': 'center'})
        m.connectAttr('output', self.nodeText, 'position')
        bs.animate(self.nodeText, 'scale', {0: 0, 140: 0.016, 200: 0.01})
        bs.animateArray(self.nodeText,'color',3,{0:(0,0,2),500:(0,2,0),1000:(2,0,0),1500:(2,2,0),2000:(2,0,2),2500:(0,1,6),3000:(1,2,0)},True)
        bs.emitBGDynamics(position=self.nodeText.position, velocity=self.node.position, count=200, scale=1.4, spread=2.01, chunkType='sweat')
        
        self.nodeLight = bs.newNode('light',
                                    attrs={'position': self.node.position,
                                           'color': (0,0,1),
                                           'radius': 0.4,
                                           'volumeIntensityScale': 0.5})
        self.node.connectAttr('position', self.nodeLight, 'position')
        bs.gameTimer(7000,self.nodeLight.delete)   
        bsUtils.animateArray(self.nodeLight, 'color', 3, prefixAnim, True)
        bs.animate(self.nodeLight, "intensity", {0:1.0, 1000:1.8, 2000:1.0}, loop = True)
コード例 #38
0
    def _DrunkPlayerCollide(self):
        self._whoisDrunk = {}
        playerNode = bs.getCollisionInfo('opposingNode')
        player = playerNode.getDelegate().getPlayer()
        self._whoisDrunk = player
        Pos1 = self._whoisDrunk.actor.node.positionCenter
        Posf2 = self._whoisDrunk.actor.node.positionForward
        self.cameraFlash(duration=10)
        velocity = (0, 0, 0)
        #print ('sarhos olan',self._whoisDrunk.getName())
        #mythbrk pos get pos
        bs.emitBGDynamics(
            position=(Pos1[0], Pos1[1], Pos1[2]),
            velocity=velocity,  #emitType= stickers,slime,tendrils,distortion
            count=random.randrange(0, 2),
            scale=1.0,
            chunkType='slime',
            emitType='stickers')  #slime,spark,splinter,ice,metal,rock,sweat

        direction = [
            Pos1[0] - Posf2[0], Posf2[1] - Pos1[1], Pos1[2] - Posf2[2]
        ]
        direction[1] *= 10
        t = 0.4

        star1 = bs.newNode("flash",
                           attrs={
                               'position': (Pos1[0] + random.uniform(-t, t),
                                            Pos1[1] + random.uniform(-t, t),
                                            Pos1[2] + random.uniform(-t, t)),
                               'size':
                               0.1,
                               'color': (2, 0.8, 0.4)
                           })
        bs.gameTimer(60, star1.delete)

        star2 = bs.newNode("flash",
                           attrs={
                               'position': (Pos1[0] + random.uniform(-t, t),
                                            Pos1[1] + random.uniform(-t, t),
                                            Pos1[2] + random.uniform(-t, t)),
                               'size':
                               0.06,
                               'color': (1, 0.8, 0.4)
                           })
        bs.gameTimer(60, star2.delete)

        star3 = bs.newNode("flash",
                           attrs={
                               'position': (Pos1[0] + random.uniform(-t, t),
                                            Pos1[1] + random.uniform(-t, t),
                                            Pos1[2] + random.uniform(-t, t)),
                               'size':
                               0.02,
                               'color': (1, 0.8, 2.4)
                           })
        bs.gameTimer(60, star3.delete)

        star4 = bs.newNode("flash",
                           attrs={
                               'position': (Pos1[0] + random.uniform(-t, t),
                                            Pos1[1] + random.uniform(-t, t),
                                            Pos1[2] + random.uniform(-t, t)),
                               'size':
                               0.03,
                               'color': (2, 0.8, 0.4)
                           })
        bs.gameTimer(60, star4.delete)

        star5 = bs.newNode("flash",
                           attrs={
                               'position': (Pos1[0] + random.uniform(-t, t),
                                            Pos1[1] + random.uniform(-t, t),
                                            Pos1[2] + random.uniform(-t, t)),
                               'size':
                               0.01,
                               'color': (2, 0.8, 0.4)
                           })
        bs.gameTimer(60, star5.delete)