Ejemplo n.º 1
0
 def givePowers(self):
     for player in self.players:
         if not player.actor is None:
             if player.actor.isAlive():
                 #This teleport the player
                 if player.actor.landMineCount == 1:
                     pos = self.getMap().getFFAStartPosition(self.players)
                     player.actor.handleMessage(bs.StandMessage(pos))
                     bs.Blast(position=pos,
                              blastRadius=1.0,
                              blastType='smoke').autoRetain()
                     bs.playSound(bs.getSound('shieldDown'))
                     player.actor.landMineCount = 0
                 #The player will be fly with the explosions
                 elif player.actor.landMineCount == 2:
                     pos = player.actor.node.position
                     bs.Blast(position=(pos[0], pos[1] - 0.5, pos[2]),
                              blastRadius=1.0,
                              blastType='smoke').autoRetain()
                     player.actor.handleMessage(bs.PowerupMessage('health'))
                     player.actor.landMineCount = 0
                 elif player.actor.landMineCount == 3:
                     mPlayer = player.actor
                     self.freezeAll(mPlayer)
                     player.actor.landMineCount = 0
    def handleMessage(self, m):
        if not self.node.exists(): return
        if isinstance(m, bs.OutOfBoundsMessage):
            self.node.delete()
        elif isinstance(m, bs.DieMessage):
            self.node.delete()

        # TODO - add functoional for speed-up on picked up
        elif isinstance(m, bs.PickedUpMessage):
            bs.Blast(position=self.node.position,
                     blastType='impact',
                     blastRadius=0.8).autoRetain()
            bs.playSound(self.touchedSound,
                         position=self.node.position,
                         volume=4)
            self.x, self.y, self.z = m.node.position
            # I SAID DON'T TOUCH!
            self.speedMul = 3.0
            self.hp -= 10 + random.randint(-3, 3)
            if self.hp < 0:
                bs.Blast(position=self.node.position,
                         blastRadius=0.5,
                         blastType='tnt')
                self.handleMessage(bs.DieMessage())
        elif isinstance(m, bs.DroppedMessage):
            self.speedMul = 1.0
        else:
            bs.Actor.handleMessage(self, m)
    def handleMessage(self, m):
        super(self.__class__, self).handleMessage(m)

        if isinstance(m, bs.DieMessage):
            self.node.delete()
        elif isinstance(m, bs.OutOfBoundsMessage):
            self.handleMessage(bs.DieMessage())
        elif isinstance(m, bs.DroppedMessage):
            bs.gameTimer(
                200, bs.WeakCall(self.handleMessage, doorStartUseMessage()))
        elif isinstance(m, doorStartUseMessage):
            self.canUse = True
        elif isinstance(m, doorHitSpazMessage):
            if not self.canUse:
                return
            if self._used:
                return
            oppoNode = bs.getCollisionInfo("opposingNode")
            if oppoNode is not None and oppoNode.exists():
                activity = self._activity()
                pos = self.getFactory().getRandomPosition(activity)
                oppoNode.handleMessage(bs.StandMessage(pos))
                bs.Blast(position=pos, blastRadius=1.0,
                         blastType='smoke').autoRetain()
                bs.playSound(bs.getSound('shieldDown'))

            self._disappear()
Ejemplo n.º 4
0
    def curseExplodeNoShrapnel(self, sourcePlayer=None):
        """
        Explode the poor spaz as happens when
        a curse timer runs out. Less shrapnel for surviveCurse, just explode.
        Otherwise, shrapnel hits other players too much. Player shrapnel causes instant
        curse explosion of other players.  Over too quickly.
        I could probably figure out how to prevent.  However, too lazy.
        Making immediate=True in the DieMessage prevents shrapnel. 
        However, spaz node disappears instantly and no cleanup happens.
        """
        # convert None to an empty player-ref
        if sourcePlayer is None: sourcePlayer = bs.Player(None)

        if self._cursed and self.node.exists():
            #self.shatter(extreme=True)
            self.handleMessage(bs.DieMessage(immediate=False))
            activity = self._activity()
            if activity:
                bs.Blast(position=self.node.position,
                         velocity=self.node.velocity,
                         blastRadius=3.0,
                         blastType='normal',
                         sourcePlayer=sourcePlayer if sourcePlayer.exists()
                         else self.sourcePlayer).autoRetain()
            self._cursed = False
Ejemplo n.º 5
0
    def oob_effect(self):
        if self.isDead:
            return
        self.isDead = True
        if self.multiplyer > 1.25:
            blastType = 'tnt'
            radius = min(self.multiplyer * 5, 20)
        else:
            # penalty for killing people with low multiplyer
            blastType = 'ice'
            radius = 7.5

        bs.Blast(position=self.node.position, blastRadius=radius, blastType=blastType).autoRetain()
 def explode(self):
     if self._exploded: return
     self._exploded = True
     activity = self.getActivity()
     if activity is not None and self.node.exists():
         blast = bs.Blast(position=self.node.position,
                          velocity=self.node.velocity,
                          blastRadius=self.blastRadius,
                          blastType=self.bombType,
                          sourcePlayer=self.sourcePlayer,
                          hitType=self.hitType,
                          hitSubType=self.hitSubType).autoRetain()
         for c in self._explodeCallbacks:
             c(self, blast)
     bs.gameTimer(1, bs.WeakCall(self.handleMessage, bs.DieMessage()))
Ejemplo n.º 7
0
 def makeBlastRing(self, length):
     if length == 0:
         self.setupNextRound()
         self._prizeRecipient.getTeam().gameData['score'] += 50
         self.updateScore()
         return
     for angle in range(0, 360, 45):
         angle += random.randint(0, 45)
         angle %= 360
         x = length * math.cos(math.radians(angle))
         z = length * math.sin(math.radians(angle))
         blast = bs.Blast(position=(x, 2.2, z - 2), blastRadius=3.5)
     if self._prizeRecipient.isAlive():
         bs.gameTimer(750, bs.Call(self.makeBlastRing, length - 1))
     else:
         self.setupNextRound()
Ejemplo n.º 8
0
    def _update(self):
        minXDist = minYDist = minZDist = 999999
        mtx, mty, mtz = (0, 0, 0)
        xdist = ydist = zdist = 0
        ox, oy, oz = self.node.position
        for node in bs.getNodes():
            if node.getNodeType() == 'spaz':
                if node.getDelegate() is None:
                    continue
                if node.getDelegate().sourcePlayer in self.sourcePlayers:
                    continue
                tx, ty, tz = node.position
                xdist = abs(tx - ox)
                ydist = abs(ty - oy)
                zdist = abs(tz - oz)
                if xdist < minXDist and ydist < minYDist and zdist < minZDist:
                    minXDist, minYDist, minZDist = xdist, ydist, zdist
                    ntx, nty, ntz = tx, ty, tz
        if minXDist > 8:
            return  # Далеко(((
        if minYDist > 8:
            return  # Далеко(((
        if minZDist > 8:
            return  # Далеко(((
        self.getSourcePlayers()
        vel = [0, 0, 0]

        if ntx > ox:
            vel[0] = 5
        else:
            vel[0] = -5
        if nty > oy:
            vel[1] = 5
        else:
            vel[1] = -5
        if ntz > oz:
            vel[2] = 5
        else:
            vel[2] = -5
        bs.playSound(self.targetSound, position=self.node.position)
        bs.Blast(position=self.node.position,
                 hitType='punch',
                 sourcePlayer=self.sourcePlayers[0],
                 blastRadius=1.2).autoRetain()
        self.node.velocity = vel
Ejemplo n.º 9
0
    def handleMessage(self, msg):
        self._handleMessageSanityCheck()

        if isinstance(msg, PowerupAcceptMessage):
            factory = self.getFactory()
            if self.powerupType == 'health':
                bs.playSound(factory.healthPowerupSound,
                             3,
                             position=self.node.position)
            bs.playSound(factory.powerupSound, 3, position=self.node.position)
            self._powersGiven = True
            self.handleMessage(bs.DieMessage())

        elif isinstance(msg, _TouchedMessage):
            if not self._powersGiven:
                node = bs.getCollisionInfo("opposingNode")
                if node is not None and node.exists():
                    node.handleMessage(
                        PowerupMessage(self.powerupType, sourceNode=self.node))

        elif isinstance(msg, bs.DieMessage):
            if self.node.exists():
                if (msg.immediate): self.node.delete()
                else:
                    curve = bs.animate(self.node, "modelScale", {0: 1, 100: 0})
                    bs.gameTimer(100, self.node.delete)

        elif isinstance(msg, bs.OutOfBoundsMessage):
            self.handleMessage(bs.DieMessage())

        elif isinstance(msg, bs.HitMessage):
            if msg.hitType == 'punch':
                if self.powerupType == 'curse':
                    bs.Blast(position=self.node.position,
                             velocity=(0, 0, 0),
                             blastRadius=1,
                             blastType="normal",
                             sourcePlayer=None,
                             hitType='explosion',
                             hitSubType='normal').autoRetain()
                    self.handleMessage(bs.DieMessage())
            else:
                self.handleMessage(bs.DieMessage())
        else:
            bs.Actor.handleMessage(self, msg)
 def _onPunched(self, damage):
     if not self.exists(): return
     self.hp -= damage
     if self.hp <= 0:
         b = bs.Blast(self.position, (0, 0, 0), 3.0, 'normal', None,
                      'punch').autoRetain()
         bs.screenMessage('Enemies\'s base were destroyed!',
                          color=(0, 1, 0))
         self.handleMessage(bs.DieMessage())
     self._scoreText.delete()
     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)
Ejemplo n.º 11
0
    def handleMessage(self, msg):
        self._handleMessageSanityCheck()

        if isinstance(msg, PowerupAcceptMessage):
            factory = self.getFactory()
            if self.powerupType == 'health':
                bs.playSound(factory.healthPowerupSound,
                             3,
                             position=self.node.position)
            bs.playSound(factory.powerupSound, 3, position=self.node.position)
            self._powersGiven = True
            self.handleMessage(bs.DieMessage())

        elif isinstance(msg, _TouchedMessage):
            if not self._powersGiven:
                node = bs.getCollisionInfo("opposingNode")
                if node is not None and node.exists():
                    bs.gameTimer(100, self.nodeLight.delete)
                    if self.powerupType == 'snoball':
                        spaz = node.getDelegate()
                        SnoBallz.snoBall().getFactory().giveBallz(spaz)
                        self._powersGiven = True
                        self.handleMessage(bs.DieMessage())
                    elif self.powerupType == 'TouchMe':
                        p = node.positionForward
                        self._powersGiven = True
                        self.handleMessage(bs.DieMessage())
                        bsSomething.Something(
                            (p[0], p[1] + 2, p[2])).autoRetain()
                    elif self.powerupType == 'BlackHole':
                        p = node.positionForward
                        self._powersGiven = True
                        self.handleMessage(bs.DieMessage())
                        bsSomething.BlackHole(
                            (p[0], p[1] + 2, p[2])).autoRetain()
                    elif self.powerupType == 'Slippery':
                        p = node.positionForward
                        self._powersGiven = True
                        self.handleMessage(bs.DieMessage())
                        bsSomething.MagicSpell(
                            (p[0], p[1] + 2, p[2])).autoRetain()
                    elif self.powerupType == 'Box':
                        self._powersGiven = True
                        self.handleMessage(bs.DieMessage())
                        node.handleMessage(
                            bs.PowerupMessage(powerupType='Box'))
                    else:
                        node.handleMessage(
                            PowerupMessage(self.powerupType,
                                           sourceNode=self.node))

        elif isinstance(msg, bs.DieMessage):
            if self.node.exists():
                if (msg.immediate): self.node.delete()
                else:
                    curve = bs.animate(self.node, "modelScale", {0: 1, 100: 0})
                    bs.gameTimer(100, self.node.delete)

        elif isinstance(msg, bs.OutOfBoundsMessage):
            self.handleMessage(bs.DieMessage())

        elif isinstance(msg, bs.HitMessage):
            if msg.hitType == 'punch':
                if self.powerupType == 'curse':
                    bs.Blast(position=self.node.position,
                             velocity=(0, 0, 0),
                             blastRadius=1,
                             blastType="normal",
                             sourcePlayer=None,
                             hitType='explosion',
                             hitSubType='normal').autoRetain()
                    self.handleMessage(bs.DieMessage())
                elif self.powerupType == 'health':
                    bs.Blast(position=self.node.position,
                             velocity=(0, 0, 0),
                             blastRadius=1,
                             blastType="normal",
                             sourcePlayer=None,
                             hitType='explosion',
                             hitSubType='normal').autoRetain()
                    self.handleMessage(bs.DieMessage())
            else:
                self.handleMessage(bs.DieMessage())
        else:
            bs.Actor.handleMessage(self, msg)
Ejemplo n.º 12
0
    def handleMessage(self, m):
        bs.Actor.handleMessage(self, m)
        if isinstance(m, ArrowTouchAnything):
            node = bs.getCollisionInfo("opposingNode")

            if node is not None and node.exists():
                v = self.node.velocity
                t = self.node.position
                hitDir = self.node.velocity
                m = self.node
                self.calcMagByDistance()
                node.handleMessage(bs.HitMessage(pos=t,
                                                 velocity=v,
                                                 magnitude=self.arrowMag,
                                                 velocityMagnitude=self.arrowMag,
                                                 radius=0,
                                                 srcNode=self.node,
                                                 sourcePlayer=self.sourcePlayer,
                                                 forceDirection=hitDir))

            self.node.handleMessage(bs.DieMessage())

        elif isinstance(m, bs.DieMessage):
            if self.node.exists():
                velocity = self.node.velocity
                explosion = bs.newNode("explosion",
                                       attrs={'position': self.node.position,
                                              'velocity': (velocity[0], max(-1.0, velocity[1]), velocity[2]),
                                              'radius': 1,
                                              'big': False})
                bs.playSound(sound=bs.getSound(random.choice(['impactHard', 'impactHard2', 'impactHard3'])),
                             position=self.node.position)
                self.node.delete()
                self.lightNode.delete()
                self._emit = None

        elif isinstance(m, bs.OutOfBoundsMessage):
            self.handleMessage(bs.DieMessage())

        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])

        elif isinstance(m, ArrowTouchSpaz):
            node = bs.getCollisionInfo("opposingNode")
            if node is not None and node.exists():
                # node.handleMessage(bs.FreezeMessage())

                v = self.node.velocity
                t = self.node.position
                hitDir = self.node.velocity

                self.calcMagByDistance()
                hitType = 'hunter'
                if self.lifeDist > 5:
                    hitType = 'hunterGod'
                    # self.sourcePlayer.actor.setScoreText('狙击精英')
                node.handleMessage(bs.HitMessage(pos=t,
                                                 velocity=(10, 10, 10),
                                                 magnitude=self.arrowMag,
                                                 velocityMagnitude=self.arrowMag,
                                                 radius=0,
                                                 srcNode=self.node,
                                                 sourcePlayer=self.sourcePlayer,
                                                 forceDirection=hitDir,
                                                 hitType=hitType))

            self.node.handleMessage(bs.DieMessage())

        elif isinstance(m, ArrowTouchFootingMaterial):
            self.calcMagByDistance()
            bs.Blast(position=self.node.position,
                     velocity=self.node.velocity,
                     blastRadius=self.arrowBlast, blastType='normal',
                     sourcePlayer=self.sourcePlayer, hitType='hunterBlast').autoRetain()
            self.handleMessage(bs.DieMessage())
            # bs.playSound(sound=bs.getSound("blip"), position=self.node.position)
        elif isinstance(m, bs.PickedUpMessage):
            self.handleMessage(bs.DieMessage())
Ejemplo n.º 13
0
def _blast(pos = (0,0,0), r = 1):
    bs.Blast(position = pos, blastRadius = r).autoRetain()
Ejemplo n.º 14
0
    def handleMessage(self, msg):
        self._handleMessageSanityCheck()

        if isinstance(msg, PowerupAcceptMessage):
            factory = self.getFactory()
            if self.powerupType == 'health':
                bs.playSound(factory.healthPowerupSound,
                             3,
                             position=self.node.position)
            bs.playSound(factory.powerupSound, 3, position=self.node.position)
            self._powersGiven = True
            self.handleMessage(bs.DieMessage())

            if self.powerupType == 'blast':
                radius = random.choice([0.5, 1.0, 1.5, 2.0])
                type = random.choice(['ice', 'normal', 'sticky', 'tnt'])
                pos = self.node.position
                bs.Blast(position=pos, blastRadius=radius,
                         blastType=type).autoRetain()
                self._blast = True
                if self._blast == True:
                    if type == 'ice':
                        bs.screenMessage("Type: Ice", color=(3.5, 0, 0))
                    if type == 'normal':
                        bs.screenMessage("Type: Normal", color=(3.5, 0, 0))
                    if type == 'sticky':
                        bs.screenMessage("Type: Sticky", color=(3.5, 0, 0))
                    if type == 'tnt':
                        bs.screenMessage("Type: Tnt", color=(3.5, 0, 0))
                    if radius == 0.5:
                        bs.screenMessage("Radius: 0.5", color=(0, 0, 3.5))
                    if radius == 1.0:
                        bs.screenMessage("Radius: 1.0", color=(0, 0, 3.5))
                    if radius == 1.5:
                        bs.screenMessage("Radius: 1.5", color=(0, 0, 3.5))
                    if radius == 2.0:
                        bs.screenMessage("Radius: 2.0", color=(0, 0, 3.5))

            if self.powerupType == 'mix':
                pow = random.choice([
                    'tripleBombs', 'iceBombs', 'punch', 'impactBombs',
                    'landMines', 'stickyBombs', 'shield', 'health', 'curse'
                ])
                pos = self.node.position
                bs.Powerup(position=pos, powerupType=pow).autoRetain()
                bs.emitBGDynamics(position=self.node.position,
                                  velocity=self.node.velocity,
                                  count=int(14.0 + random.random() * 70),
                                  scale=1.4,
                                  spread=3.5,
                                  chunkType='spark')
                self._mix = True
                if self._mix == True:
                    if pow == 'tripleBombs':
                        bs.screenMessage("Triple Bombs", color=(1, 1, 0))
                    if pow == 'iceBombs':
                        bs.screenMessage("Ice Bombs", color=(0, 0.2, 1))
                    if pow == 'punch':
                        bs.screenMessage("Boxing Gloves", color=(1, 0.3, 0.3))
                    if pow == 'impactBombs':
                        bs.screenMessage("Impact Bombs", color=(0.3, 0.3, 0.3))
                    if pow == 'landMines':
                        bs.screenMessage("Land Mines", color=(0.1, 0.7, 0))
                    if pow == 'stickyBombs':
                        bs.screenMessage("Sticky Bombs", color=(0, 1, 0))
                    if pow == 'shield':
                        bs.screenMessage("Energy Shield", color=(0.7, 0.5, 1))
                    if pow == 'health':
                        bs.screenMessage("Health Kit", color=(1, 1, 1))
                    if pow == 'curse':
                        bs.screenMessage("Curse", color=(0.1, 0.1, 0.1))
                    self._light = True
                if self._light == True:
                    color = random.choice([(5.0, 0.2, 0.2), (0.2, 5.0, 0.2),
                                           (0.2, 0.2, 5.0)])
                    self.light = bs.newNode('light',
                                            attrs={
                                                'position': self.node.position,
                                                'color': color,
                                                'volumeIntensityScale': 0.35
                                            })
                    bs.animate(self.light,
                               'intensity', {
                                   0: 0,
                                   70: 0.5,
                                   350: 0
                               },
                               loop=False)
                    bs.gameTimer(500, self.light.delete)

        elif isinstance(msg, _TouchedMessage):
            if not self._powersGiven:
                node = bs.getCollisionInfo("opposingNode")
                if node is not None and node.exists():
                    node.handleMessage(
                        PowerupMessage(self.powerupType, sourceNode=self.node))

        elif isinstance(msg, bs.DieMessage):
            if self.node.exists():
                if (msg.immediate):
                    self.node.delete()
                else:
                    curve = bs.animate(self.node, "modelScale", {0: 1, 100: 0})
                    bs.gameTimer(100, self.node.delete)

        elif isinstance(msg, bs.OutOfBoundsMessage):
            self.handleMessage(bs.DieMessage())

        elif isinstance(msg, bs.HitMessage):
            if msg.hitType != 'punch':
                self.handleMessage(bs.DieMessage())
        else:
            bs.Actor.handleMessage(self, msg)
Ejemplo n.º 15
0
 def tntExplode(self):
     pos = self.node.position
     bs.Blast(position=pos,
              blastRadius=6.0,
              blastType='tnt',
              sourcePlayer=None).autoRetain()