def enterShowScores(self):
        self.notify.debug('enterShowScores')
        lerpTrack = Parallel()
        lerpDur = 0.5
        lerpTrack.append(Parallel(LerpPosInterval(self.goalBar, lerpDur, Point3(0, 0, -.6), blendType='easeInOut'), LerpScaleInterval(self.goalBar, lerpDur, Vec3(self.goalBar.getScale()) * 2.0, blendType='easeInOut')))
        tY = 0.6
        bY = -.05
        lX = -.5
        cX = 0
        rX = 0.5
        scorePanelLocs = (((cX, bY),),
         ((lX, bY), (rX, bY)),
         ((cX, tY), (lX, bY), (rX, bY)),
         ((lX, tY),
          (rX, tY),
          (lX, bY),
          (rX, bY)))
        scorePanelLocs = scorePanelLocs[self.numPlayers - 1]
        for i in xrange(self.numPlayers):
            panel = self.scorePanels[i]
            pos = scorePanelLocs[i]
            lerpTrack.append(Parallel(LerpPosInterval(panel, lerpDur, Point3(pos[0], 0, pos[1]), blendType='easeInOut'), LerpScaleInterval(panel, lerpDur, Vec3(panel.getScale()) * 2.0, blendType='easeInOut')))

        self.showScoreTrack = Parallel(lerpTrack, Sequence(Wait(MazeGameGlobals.SHOWSCORES_DURATION), Func(self.gameOver)))
        self.showScoreTrack.start()
 def onActivate(self, entity, suit):
     x, y, z = entity.getPos(render)
     sinkPos = Point3(x, y, z - 9.1)
     dropPos = Point3(x, y, z + 15)
     landPos = Point3(x, y, z)
     suit.d_disableMovement()
     suit.setPos(x, y, z)
     entTrack = Sequence(Wait(0.4), Func(entity.setColor, Vec4(0, 0, 0, 1)), Wait(0.4), LerpScaleInterval(entity, 0.8, GagGlobals.PNT3NEAR0))
     suitTrack = Sequence(
         self.getSplicedLerpAnimsTrack(suit, 'flail', 0.7, 0.25),
         Wait(0.2), 
         LerpPosInterval(suit, 0.4, sinkPos), 
         Func(suit.setPos, dropPos),
         Func(suit.hide),
         ActorInterval(suit, 'neutral', duration=0.5), 
         Wait(0.75), 
         Func(suit.show),
         Parallel(LerpPosInterval(suit, 0.3, landPos), Func(suit.play, 'slip-forward')),
         SoundInterval(self.activateSfx, node = suit), 
         Func(self.damageSuit, suit),
         Func(suit.d_enableMovement) 
     )
     soundTrack = Sequence(SoundInterval(self.hitSfx, node = suit), Wait(0.8))
     Parallel(entTrack, suitTrack, soundTrack).start()
     ActivateTrapGag.onActivate(self, entity, suit)
Ejemplo n.º 3
0
 def enterTakeOver(self, ts = 0):
     if not self.door:
         return
     self.stopSmooth()
     self.hasSpawned = False
     self.reparentTo(self.door.doorNode)
     self.setHpr(0, 0, 0)
     self.takeOverTrack = Parallel(
         Sequence(
             Func(self.animFSM.request, 'flyDown', [ts]),
             Wait(6.834),
             Func(self.setAnimState, 'neutral'),
             Wait(0.5),
             Func(self.setAnimState, 'walk'),
             LerpPosInterval(self, duration = 2.0, pos = DistributedTakeOverSuit.AtDoorPos,
                             startPos = DistributedTakeOverSuit.StartPosFromDoor),
             Func(self.setAnimState, 'neutral'),
             Wait(0.3),
             Func(self.setAnimState, 'walk'),
             LerpPosInterval(self, duration = 0.5, pos = self.door.enterDoorWalkBackNode.getPos(),
                             startPos = DistributedTakeOverSuit.AtDoorPos),
             Func(self.setAnimState, 'neutral'),
             Wait(1.0),
             Func(self.setAnimState, 'walk'),
             LerpPosInterval(self, duration = 1.0, pos = self.door.enterDoorWalkInNode.getPos(),
                             startPos = self.door.enterDoorWalkBackNode.getPos())),
         LerpPosInterval(self,
                         duration = 4.375,
                         pos = DistributedTakeOverSuit.StartPosFromDoor,
                         startPos = DistributedTakeOverSuit.StartPosFromDoor + (0, 0, 6.5 * 4.8))
     )
     self.takeOverTrack.start(ts)
Ejemplo n.º 4
0
    def setEntityState(self, state):
        DistributedEntityAI.setEntityState(self, state)

        if state == self.StateDown:
            self.stomped = False
            self.clearSequence()
            self.setPos(self.cEntity.getOrigin())
            self.dispatchOutput("OnStomp")

        elif state == self.StateUp:
            self.clearSequence()
            self.setPos(self.cEntity.getOrigin() + self.getUpPosition())
            self.dispatchOutput("OnRaise")

        elif state == self.StateStomp:
            self.damaged = []
            self.setSequence(
                LerpPosInterval(
                    self, self.height / self.stompSpeed,
                    self.cEntity.getOrigin(),
                    self.cEntity.getOrigin() + self.getUpPosition()))

        elif state == self.StateRaise:
            self.setSequence(
                LerpPosInterval(
                    self, self.height / self.raiseSpeed,
                    self.cEntity.getOrigin() + self.getUpPosition(),
                    self.cEntity.getOrigin()))
Ejemplo n.º 5
0
 def throwObject(self, projectile = True):
     if not self.weapon:
         return
     self.acceptOnce('enter' + self.wsnp.node().getName(), self.handleWeaponCollision)
     self.playWeaponSound()
     if self.weapon:
         self.weapon.wrtReparentTo(render)
         self.weapon.setHpr(Vec3(0, 0, 0))
     if self.attack not in ('glowerpower',):
         parent = self.suit.find('**/joint_Rhold')
     else:
         parent = self.suit.find('**/joint_head')
     startNP = parent.attachNewNode('startNp')
     startNP.lookAt(render, self.targetX, self.targetY, self.targetZ)
     pathNP = NodePath('throwPath')
     pathNP.reparentTo(startNP)
     pathNP.setScale(render, 1.0)
     pathNP.setPos(0, 50, 0)
     if self.attack in ('clipontie', 'powertie', 'halfwindsor'):
         self.weapon.setHpr(pathNP.getHpr(render))
     if projectile == True:
         self.throwTrajectory = ProjectileInterval(self.weapon, startPos=self.suit.find('**/joint_Rhold').getPos(render), endPos=pathNP.getPos(render), gravityMult=0.7, duration=1.0)
     else:
         self.weapon.setH(pathNP.getH(render))
         self.throwTrajectory = LerpPosInterval(self.weapon, duration=0.5, pos=pathNP.getPos(render), startPos=startNP.getPos(render) + (0, 3, 0))
     self.throwTrajectory.start()
     self.weapon_state = 'released'
     startNP.removeNode()
     del startNP
     pathNP.removeNode()
     del pathNP
Ejemplo n.º 6
0
    def _jump_and_explode(self, task):
        """Jump to the Adjutant and self-explode."""
        if self.current_part is None:
            return task.done

        for char in base.world.enemy.active_units.values():  # noqa: F821
            if type(char
                    ) == Kamikaze and char.id != self.id and char.is_jumping:
                return task.again

        self.is_jumping = True
        self._stop_tasks("_float_move")
        self._move_int.pause()

        Sequence(
            LerpPosInterval(self.node,
                            2.5, (self._y_pos, -0.5, 0),
                            blendType="easeInOut"),
            Func(self._ignite_the_wick),
            LerpPosInterval(
                self.node,
                4.5,
                (-0.45 if self._y_pos < 0 else 0.45, -0.8, 0),
                blendType="easeInOut",
            ),
            Func(self._jump_snd.play),
            MopathInterval(self._jump_path,
                           self.model,
                           duration=0.8,
                           name=self.id + "_jump"),
            Func(self._die, True),
        ).start()
        return task.done
Ejemplo n.º 7
0
    def _drop_brake(self, brake):
        """Drop braking shoes to slow down the locomotive.

        Args:
            brake (panda3d.core.NodePath): Brake model to drop.
        """
        brake.wrtReparentTo(base.train.model)  # noqa: F821

        if not base.train.r_brake:  # noqa: F821
            pos = 0.058
            base.train.r_brake = True  # noqa: F821
            side = "r"
        else:
            base.train.l_brake = True  # noqa: F821
            pos = -0.058
            side = "l"

        Sequence(
            Parallel(
                LerpPosInterval(brake, 0.5, (pos, 0.7, 0.025)),
                LerpHprInterval(brake, 0.5, (0, 0, 0)),
            ),
            LerpPosInterval(brake, 0.35, (pos, 0.38, 0.025)),
            Func(base.train.brake, side, brake),  # noqa: F821
        ).start()
 def initIntervals(self):
     dur = Globals.RobberBaron.LiftOffTime
     nestPos = self.nest.getPos(render)
     airPos = nestPos + Vec3(0.0, 0.0, Globals.RobberBaron.LiftOffHeight)
     self.takeOffSeq = Sequence(Parallel(Sequence(Wait(dur * 0.6), LerpPosInterval(self.suit, dur * 0.4, startPos=nestPos, pos=airPos, blendType='easeInOut'))), Wait(1.5), Func(self.request, 'next'), name='%s.takeOffSeq-%i' % (self.__class__.__name__, self.index))
     self.landOnNestPosLerp = LerpPosInterval(self.suit, 1.0, startPos=airPos, pos=nestPos, blendType='easeInOut')
     self.landingSeq = Sequence(Func(self.updateLandOnNestPosLerp), Parallel(self.landOnNestPosLerp), Func(self.request, 'next'), name='%s.landingSeq-%i' % (self.__class__.__name__, self.index))
     dur = Globals.RobberBaron.ChargeUpTime
     self.chargeUpPosLerp = LerpFunc(self.moveAlongChargeUpMopathFunc, fromData=0.0, toData=self.chargeUpMotionPath.getMaxT(), duration=dur, blendType='easeInOut')
     self.chargeUpAttackSeq = Sequence(Func(self.updateChargeUpPosLerp), self.chargeUpPosLerp, Func(self.request, 'next'), name='%s.chargeUpAttackSeq-%i' % (self.__class__.__name__, self.index))
     dur = Globals.RobberBaron.RetreatToNestTime
     self.retreatToNestPosLerp = LerpPosInterval(self.suit, dur, startPos=Vec3(0, 0, 0), pos=airPos, blendType='easeInOut')
     self.retreatToNestSeq = Sequence(Func(self.updateRetreatToNestPosLerp), self.retreatToNestPosLerp, Func(self.request, 'next'), name='%s.retreatToNestSeq-%i' % (self.__class__.__name__, self.index))
     dur = Globals.RobberBaron.RetreatToSkyTime
     self.retreatToSkyPosLerp = LerpFunc(self.moveAlongRetreatMopathFunc, fromData=0.0, toData=self.retreatToSkyMotionPath.getMaxT(), duration=dur, blendType='easeOut')
     self.retreatToSkySeq = Sequence(Func(self.updateRetreatToSkyPosLerp), self.retreatToSkyPosLerp, Func(self.request, 'next'), name='%s.retreatToSkySeq-%i' % (self.__class__.__name__, self.index))
     dur = Globals.RobberBaron.PreAttackTime
     self.preAttackLerpXY = LerpFunc(self.updateAttackXY, fromData=0.0, toData=1.0, duration=dur)
     self.preAttackLerpZ = LerpFunc(self.updateAttackZ, fromData=0.0, toData=1.0, duration=dur, blendType='easeOut')
     dur = Globals.RobberBaron.PostAttackTime
     self.postAttackPosLerp = LerpPosInterval(self.suit, dur, startPos=Vec3(0, 0, 0), pos=Vec3(0, 0, 0))
     self.attackSeq = Sequence(Parallel(self.preAttackLerpXY, self.preAttackLerpZ), Func(self.updatePostAttackPosLerp), self.postAttackPosLerp, Func(self.request, 'next'), name='%s.attackSeq-%i' % (self.__class__.__name__, self.index))
     dur = Globals.RobberBaron.CooldownTime
     self.cooldownSeq = Sequence(Wait(dur), Func(self.request, 'next'), name='%s.cooldownSeq-%i' % (self.__class__.__name__, self.index))
     self.propTrack = Sequence(ActorInterval(self.prop, 'propeller', startFrame=0, endFrame=14))
     self.hoverOverNestSeq = Sequence(ActorInterval(self.suit, 'landing', startFrame=10, endFrame=20, playRate=0.5), ActorInterval(self.suit, 'landing', startFrame=20, endFrame=10, playRate=0.5))
 def enterShoot(self):
     self.shoot.play()
     if self.weaponName == "pistol":
         self.track = ActorInterval(self.v_model, 'pshoot', playRate = 2, name = 'shootTrack')
     elif self.weaponName == "shotgun":
         self.track = Parallel(
             Sequence(
                 LerpQuatInterval(self.v_model, duration = 0.05, quat = (0, 3, 0), startHpr = (0, 0, 0)),
                 LerpQuatInterval(self.v_model, duration = 0.1, quat = (0, 0, 0), startHpr = (0, 3, 0))
             ),
             Sequence(
                 LerpPosInterval(self.v_model, duration = 0.05, pos = (0, -0.3, 0), startPos = (0, 0, 0)),
                 LerpPosInterval(self.v_model, duration = 0.1, pos = (0, 0, 0), startPos = (0, -0.3, 0)),
                 Wait(0.1)
             ),
         )
     elif self.weaponName == "sniper":
         self.track = Parallel(
             Sequence(
                 LerpQuatInterval(self.v_model, duration = 0.05, quat = (0, 3, 0), startHpr = (0, 0, 0)),
                 LerpQuatInterval(self.v_model, duration = 0.1, quat = (0, 0, 0), startHpr = (0, 3, 0))
             ),
             Sequence(
                 LerpPosInterval(self.v_model, duration = 0.05, pos = (0, -0.3, 0), startPos = (0, 0, 0)),
                 LerpPosInterval(self.v_model, duration = 0.1, pos = (0, 0, 0), startPos = (0, -0.3, 0)),
                 Wait(0.1)
             ),
         )
     self.track.setDoneEvent('shootTrack')
     self.acceptOnce(self.track.getDoneEvent(), self.aliveFSM.request, ['idle'])
     self.track.start()
     self.ammo -= 1
     self.gui.adjustAmmoGui()
     self.mg.makeSmokeEffect(self.weapon.find('**/joint_nozzle').getPos(render))
     self.traverse()
    def enterScrollBy(self):
        BLUE_START_POS = Point3(-20, 0, 4)
        BLUE_END_POS = Point3(20, 0, 4)
        BLUE_HPR = Vec3(0, 0, 0)

        RED_START_POS = Point3(20, 0, 4)
        RED_END_POS = Point3(-20, 0, 4)
        RED_HPR = Vec3(180, 0, 0)

        self.playMinigameMusic()

        self.scrollBySeq = Sequence(
            Func(camera.setHpr, BLUE_HPR),
            LerpPosInterval(
                camera, duration = 5.0, pos = BLUE_END_POS, startPos = BLUE_START_POS, blendType = 'easeOut'),
            Func(base.transitions.fadeOut, 0.4),
            Wait(0.5),
            Func(base.transitions.fadeIn, 0.4),
            Func(camera.setHpr, RED_HPR),
            LerpPosInterval(
                camera, duration = 5.0, pos = RED_END_POS, startPos = RED_START_POS, blendType = 'easeOut'),
            name = "SCROLLBYSEQ")
        self.scrollBySeq.setDoneEvent(self.scrollBySeq.getName())
        self.acceptOnce(self.scrollBySeq.getDoneEvent(), self.__handleScrollByDone)
        self.scrollBySeq.start()
Ejemplo n.º 11
0
    def __get_reset_interval(self):

        interval1 = LerpPosInterval(self.cam.pivot,
                                    .5,
                                    self.home_pos,
                                    blendType="easeInOut")

        if self.cam.lens_type == "persp":
            interval2 = LerpQuatInterval(self.cam.target,
                                         .5,
                                         self.home_quat,
                                         blendType="easeInOut")
            interval3 = LerpPosInterval(self.cam.origin,
                                        .5,
                                        Point3(0., self.home_zoom, 0.),
                                        blendType="easeInOut")
            lerp_interval = Parallel(interval1, interval2, interval3)
        else:
            interval2 = LerpQuatScaleInterval(self.cam.target,
                                              .5,
                                              self.home_quat,
                                              self.home_zoom,
                                              blendType="easeInOut")
            lerp_interval = Parallel(interval1, interval2)

        return lerp_interval
Ejemplo n.º 12
0
 def __init__(self, index, motionPath=None):
     radius = Globals.Gameplay.FlyingMinionCollisionRadius
     offset = Globals.Gameplay.FlyingMinionCollisionHeightOffset
     collSolid = CollisionSphere(0, 0, offset, radius)
     CogdoFlyingMinion.__init__(self, index, collSolid, motionPath)
     self.attachPropeller()
     self.propTrack = Sequence(
         ActorInterval(self.prop, 'propeller', startFrame=0, endFrame=14))
     dur = Globals.Gameplay.FlyingMinionFloatTime
     offset = Globals.Gameplay.FlyingMinionFloatOffset
     suitPos = self.suit.getPos()
     upperPos = suitPos + Point3(0.0, 0.0, offset / 2.0)
     lowerPos = suitPos + Point3(0.0, 0.0, -offset / 2.0)
     self.floatSequence = Sequence(LerpPosInterval(self.suit,
                                                   dur / 4.0,
                                                   startPos=suitPos,
                                                   pos=upperPos,
                                                   blendType='easeInOut'),
                                   LerpPosInterval(self.suit,
                                                   dur / 2.0,
                                                   startPos=upperPos,
                                                   pos=lowerPos,
                                                   blendType='easeInOut'),
                                   LerpPosInterval(self.suit,
                                                   dur / 4.0,
                                                   startPos=lowerPos,
                                                   pos=suitPos,
                                                   blendType='easeInOut'),
                                   name='%s.floatSequence%i' %
                                   (self.__class__.__name__, self.index))
Ejemplo n.º 13
0
 def doMolePop(self, startTime, timeToMoveUp, timeToStayUp, timeToMoveDown,
               moleType):
     if self.hillType == MoleFieldBase.HILL_WHACKED or self.hillType == MoleFieldBase.HILL_COGWHACKED:
         return
     if self.popIval:
         self.popIval.pause()
     if self.downIval:
         self.downIval.pause()
         self.downIval = None
     moleColor = None
     self.switchUp()
     self.popupNum += 1
     if self.hillType == MoleFieldBase.HILL_BOMB:
         self.popIval = Sequence(
             Func(self.setHillType, moleType),
             Func(self.moleColNodePath.unstash),
             LerpPosInterval(self.mole, timeToMoveUp, Point3(0, 0, 0.0)),
             Wait(timeToStayUp),
             LerpPosInterval(self.mole, timeToMoveDown, Point3(0, 0, -2.5)),
             Func(self.stashMoleCollision), Func(self.switchDown))
     else:
         self.popIval = Sequence(
             Func(self.setHillType, moleType),
             LerpPosInterval(self.mole, timeToMoveUp, Point3(0, 0, 0.0)),
             Func(self.moleColNodePath.unstash), Wait(timeToStayUp),
             Func(self.stashMoleCollision),
             LerpPosInterval(self.mole, timeToMoveDown, Point3(0, 0, -2.5)),
             Func(self.switchDown))
     self.popIval.start()
     return
    def openRestockDoors(self):
        lDoorOpen = -3.9
        rDoorOpen = 3.5
        closed = 0.0

        leftDoor = self.gagDoor.find('**/left_door')
        rightDoor = self.gagDoor.find('**/right_door')

        # Delete the invisible one-piece wall blocking the doorway.
        # John, fix this!
        self.gagDoor.find('**/door_collisions').removeNode()

        ival = Parallel(LerpPosInterval(leftDoor, 2.0, (lDoorOpen, 0, 0),
                                        (closed, 0, 0), blendType = 'easeOut'),
                        LerpPosInterval(rightDoor, 2.0, (rDoorOpen, 0, 0),
                                        (closed, 0, 0), blendType = 'easeOut'))
        ival.start()


        loadout = base.localAvatar.backpack.getLoadout()
        sendLoadout = []
        for gag in loadout:
            sendLoadout.append(gag.getID())

        base.localAvatar.sendUpdate('requestSetLoadout', [sendLoadout])
    def releaseAttack(self, releaseFromJoint, onlyMoveColl=True, blendType='noBlend'):
        startNP = releaseFromJoint.attachNewNode('startNP')
        if None not in [self.targetX, self.targetY, self.targetZ]:
            startNP.lookAt(render, self.targetX, self.targetY, self.targetZ + 2)
            pathNP = NodePath('path')
            pathNP.reparentTo(startNP)
            pathNP.setScale(render, 1.0)
            pathNP.setPos(0, self.shooterDistance, 0)
            for particle in self.particles:
                if not onlyMoveColl:
                    particle.start(render)
                else:
                    particle.start(self.suit)
                particle.lookAt(pathNP)
                if self.attack == 'razzledazzle':
                    particle.setP(particle, 90)

            if onlyMoveColl:
                target = self.shootOutCollNP
                target.wrtReparentTo(render)
            else:
                target = self.particles[0]
            self.particleMoveIval = LerpPosInterval(target, duration=self.particleIvalDur, pos=pathNP.getPos(render), startPos=startNP.getPos(render), blendType=blendType)
            self.particleMoveIval.start()
            self.acceptOnce('enter' + self.shootOutCollNP.node().getName(), self.handleCollision)
            pathNP.removeNode()
            startNP.removeNode()
            del pathNP
            del startNP
        self.playParticleSound()
        return
Ejemplo n.º 16
0
    def enterShowScores(self):
        self.notify.debug('enterShowScores')
        lerpTrack = Parallel()
        lerpDur = 0.5
        lerpTrack.append(Parallel(LerpPosInterval(self.goalBar, lerpDur, Point3(0, 0, -.6), blendType='easeInOut'), LerpScaleInterval(self.goalBar, lerpDur, Vec3(self.goalBar.getScale()) * 2.0, blendType='easeInOut')))
        tY = 0.6
        bY = -.05
        lX = -.5
        cX = 0
        rX = 0.5
        scorePanelLocs = (((cX, bY),),
         ((lX, bY), (rX, bY)),
         ((cX, tY), (lX, bY), (rX, bY)),
         ((lX, tY),
          (rX, tY),
          (lX, bY),
          (rX, bY)))
        scorePanelLocs = scorePanelLocs[self.numPlayers - 1]
        for i in xrange(self.numPlayers):
            panel = self.scorePanels[i]
            pos = scorePanelLocs[i]
            panel.wrtReparentTo(aspect2d)
            lerpTrack.append(Parallel(LerpPosInterval(panel, lerpDur, Point3(pos[0], 0, pos[1]), blendType='easeInOut'), LerpScaleInterval(panel, lerpDur, Vec3(panel.getScale()) * 2.0, blendType='easeInOut')))

        self.showScoreTrack = Parallel(lerpTrack, Sequence(Wait(MazeGameGlobals.SHOWSCORES_DURATION), Func(self.gameOver)))
        self.showScoreTrack.start()

        #For the Alpha Blueprint ARG
        if base.config.GetBool('want-blueprint4-ARG', False):
            MinigameGlobals.generateDebugARGPhrase()
 def throwObject(self, projectile=True):
     if not self.weapon:
         return
     self.acceptOnce('enter' + self.wsnp.node().getName(), self.handleWeaponCollision)
     self.playWeaponSound()
     if self.weapon:
         self.weapon.wrtReparentTo(render)
         self.weapon.setHpr(Vec3(0, 0, 0))
     if self.attack not in ('glowerpower', ):
         parent = self.suit.find('**/joint_Rhold')
     else:
         parent = self.suit.find('**/joint_head')
     startNP = parent.attachNewNode('startNp')
     startNP.lookAt(render, self.targetX, self.targetY, self.targetZ)
     pathNP = NodePath('throwPath')
     pathNP.reparentTo(startNP)
     pathNP.setScale(render, 1.0)
     pathNP.setPos(0, 50, 0)
     if self.attack in ('clipontie', 'powertie', 'halfwindsor'):
         self.weapon.setHpr(pathNP.getHpr(render))
     if projectile == True:
         self.throwTrajectory = ProjectileInterval(self.weapon, startPos=self.suit.find('**/joint_Rhold').getPos(render), endPos=pathNP.getPos(render), gravityMult=0.7, duration=1.0)
     else:
         self.weapon.setH(pathNP.getH(render))
         self.throwTrajectory = LerpPosInterval(self.weapon, duration=0.5, pos=pathNP.getPos(render), startPos=startNP.getPos(render) + (0,
                                                                                                                                         3,
                                                                                                                                         0))
     self.throwTrajectory.start()
     self.weapon_state = 'released'
     startNP.removeNode()
     del startNP
     pathNP.removeNode()
     del pathNP
Ejemplo n.º 18
0
 def announceGenerate(self):
     DistributedElevatorExt.DistributedElevatorExt.announceGenerate(self)
     angle = self.startingHpr[0]
     angle -= 90
     radAngle = deg2Rad(angle)
     unitVec = Vec3(math.cos(radAngle), math.sin(radAngle), 0)
     unitVec *= 11.25
     self.endPos = self.startingPos + unitVec
     self.endPos.setZ(0.5)
     dist = Vec3(self.endPos - self.enteringPos).length()
     wheelAngle = dist / (6.72 * math.pi) * 360
     self.kartEnterAnimateInterval = Parallel(
         LerpHprInterval(
             self.wheels[0], 5.0,
             Vec3(self.wheels[0].getH(), wheelAngle,
                  self.wheels[0].getR())),
         LerpHprInterval(
             self.wheels[1], 5.0,
             Vec3(self.wheels[1].getH(), wheelAngle,
                  self.wheels[1].getR())),
         LerpHprInterval(
             self.wheels[2], 5.0,
             Vec3(self.wheels[2].getH(), wheelAngle,
                  self.wheels[2].getR())),
         LerpHprInterval(
             self.wheels[3], 5.0,
             Vec3(self.wheels[3].getH(), wheelAngle,
                  self.wheels[3].getR())),
         name='SwagKartAnimate')
     trolleyExitTrack1 = Parallel(
         Sequence(
             Wait(1.25),
             Func(self.mole.doMolePop, 0, 0.75, 5, 0.75,
                  MoleFieldBase.HILL_MOLE)),
         Sequence(
             LerpPosInterval(self.golfKart, 2.5, self.endPos),
             Func(self.mole.setHillType, MoleFieldBase.HILL_WHACKED),
             Func(self.soundBomb.play), Func(self.soundBomb2.play),
             Func(self.soundUp.play),
             Parallel(
                 ProjectileInterval(self.golfKart,
                                    startPos=self.endPos,
                                    endPos=self.flyToPos,
                                    duration=2,
                                    gravityMult=2.5),
                 self.golfKart.hprInterval(
                     2, (self.golfKart.getH(), self.golfKart.getP() + 720,
                         0)))),
         self.kartEnterAnimateInterval,
         name='SwagKartExitTrack')
     self.trolleyExitTrack = Sequence(trolleyExitTrack1)
     self.trolleyEnterTrack = Sequence(
         Func(self.golfKart.setP, 0),
         LerpPosInterval(self.golfKart,
                         5.0,
                         self.startingPos,
                         startPos=self.enteringPos))
     self.closeDoors = Sequence(self.trolleyExitTrack,
                                Func(self.onDoorCloseFinish))
     self.openDoors = Sequence(self.trolleyEnterTrack)
 def onActivate(self, entity, suit):
     ActivateTrapGag.onActivate(self, entity, suit)
     x, y, z = entity.getPos(render)
     sinkPos01 = Point3(x, y, z - 3.1)
     sinkPos02 = Point3(x, y, z - 9.1)
     dropPos = Point3(x, y, z + 15)
     landPos = Point3(x, y, z)
     suit.d_disableMovement()
     suit.setPos(x, y, z)
     entTrack = Sequence(
         Wait(2.4), LerpScaleInterval(entity, 0.8, GagGlobals.PNT3NEAR0))
     suitTrack = Sequence(
         Wait(0.9), LerpPosInterval(suit, 0.9, sinkPos01),
         LerpPosInterval(suit, 0.4, sinkPos02), Func(suit.setPos, dropPos),
         Func(suit.hide), Wait(1.1), Func(suit.show),
         Func(suit.setPos, dropPos),
         Parallel(LerpPosInterval(suit, 0.3, landPos),
                  Func(suit.play, 'slip-forward')),
         Func(self.damageSuit, suit), Func(suit.d_enableMovement))
     animTrack = Sequence(ActorInterval(suit, 'flail'),
                          ActorInterval(suit, 'flail', startTime=1.1),
                          Wait(0.7),
                          ActorInterval(suit, 'slip-forward', duration=2.1))
     soundTrack = Sequence(Wait(0.7), SoundInterval(self.hitSfx, node=suit),
                           Wait(0.1),
                           SoundInterval(self.activateSfx, node=suit))
     Parallel(entTrack, suitTrack, animTrack, soundTrack).start()
Ejemplo n.º 20
0
 def doActivity(self):
     pr = 5.0
     jump = ActorInterval(self.avatar,
                          'land',
                          startFrame=50,
                          endFrame=20,
                          playRate=pr * 2)
     jumpDur = jump.getDuration()
     curr = self.avatar.getPos(render)
     return Sequence(
         ActorInterval(self.avatar,
                       'land',
                       startFrame=60,
                       endFrame=50,
                       playRate=pr),
         Parallel(
             Sequence(
                 LerpPosInterval(self.avatar, jumpDur / 2, curr + (0, 0, 1),
                                 curr),
                 LerpPosInterval(self.avatar, jumpDur / 2, curr,
                                 curr + (0, 0, 1))), jump),
         ActorInterval(self.avatar,
                       'land',
                       startFrame=20,
                       endFrame=60,
                       playRate=pr))
Ejemplo n.º 21
0
    def enterSwim(self, ts=0, callback=None, extraArgs=[]):
        self.playingAnim = 'swim'
        self.loop("swim")

        self.resetTorsoRotation()

        toon = self.getGeomNode()
        toon.setP(-89.0)

        if self.shadow:
            self.shadow.hide()

        self.swimBobTrack = Sequence(
            LerpPosInterval(toon,
                            duration=1,
                            pos=(0, -3, 3),
                            startPos=(0, -3, 4),
                            blendType='easeInOut'),
            LerpPosInterval(toon,
                            duration=1,
                            pos=(0, -3, 4),
                            startPos=(0, -3, 3),
                            blendType='easeInOut'))
        self.swimBobTrack.loop()
        self.nametag3d.setZ(5.0)
 def startPosInterval(self, startX, startY, startZ, endX, endY, endZ, duration, blendType, ts=0.0):
     if ts != 0.0:
         ts = globalClockDelta.localElapsedTime(ts)
     self.stopMoveInterval()
     startPos = Point3(startX, startY, startZ)
     endPos = Point3(endX, endY, endZ)
     self.moveIval = LerpPosInterval(self, duration=duration, pos=endPos, startPos=startPos, blendType=blendType)
     self.moveIval.start(ts)
 def enterEagleFall(self, startIndex, endIndex, ts = 0.0):
     self.moveIval = LerpPosInterval(
         self,
         duration = 4.0,
         pos = self.getPos(render) - (0, 0, 75),
         startPos = self.getPos(render),
         blendType = 'easeIn'
     )
     self.moveIval.start(ts)
Ejemplo n.º 24
0
 def _initIntervals(self):
     self.bgIntroLerp = LerpPosInterval(self.staticElements['bg'], duration = 1.0, pos = self.staticElements['bg'].getPos(), startPos = (0.0, 0.0, 2.0))
     self.pickerIntroLerp = LerpPosInterval(self.repairGamePicker, duration = 1.0, pos = self.repairGamePicker.getPos(), startPos = (0.0, 0.0, -1.0))
     self.introSequence = Sequence(Func(self.repairGamePicker.setEnabled, False), Parallel(Sequence(Wait(0.25), Func(self.guiDownSound.play)), self.bgIntroLerp, self.pickerIntroLerp), Func(self.repairGamePicker.setEnabled, True), Func(self.repairGame.gameFSM.request, 'Idle'), name = 'RepairGame.introSequence')
     self.pickerOutroLerp = LerpPosInterval(self.repairGamePicker, duration = 1.0, startPos = self.repairGamePicker.getPos(), pos = (0.0, 0.0, -1.0))
     self.bgOutroLerp = LerpPosInterval(self.staticElements['bg'], duration = 1.0, startPos = self.repairGamePicker.getPos(), pos = (0.0, 0.0, 2.0))
     self.outroSequence = Sequence(Func(self.repairGamePicker.stashTab), Func(self.closeButton.stash), Parallel(Func(self.guiUpSound.play), Func(self.setPickerOutroStartPos), Func(self.setBGOutroStartPos), self.pickerOutroLerp, self.bgOutroLerp), Func(self.repairGame.cleanup), name = 'RepairGame.outroSequence')
     self.cycleCompleteSequence = Sequence(Func(self.showCycleCompleteMessage), Func(self.repairGamePicker.stashTab), Wait(self.getCycleCompleteWaitTime()), Func(self.completeSound.play), Func(self.hideCycleCompleteMessage), LerpPosInterval(self.repairGamePicker, duration = 0.5, pos = self.repairGamePicker.getPos() - (0, 0, 1.0)), Func(self.repairGame.resetMincroGameProgress), LerpPosInterval(self.repairGamePicker, duration = 0.5, pos = self.repairGamePicker.getPos()), Func(self.repairGame.gameFSM.request, 'Idle'), name = 'RepairGame.cycleCompleteSequence')
     self.shakeSequence = Sequence(name = 'RepairGameGUI.shakeSequence')
 def enterVisible2Hidden(self):
     self.moveIval = LerpPosInterval(self.inventoryFrame,
                                     duration=InventoryGui.SwitchTime,
                                     pos=InventoryGui.HiddenPos,
                                     startPos=InventoryGui.VisiblePos)
     self.moveIval.setDoneEvent('visible2hidden')
     self.acceptOnce('visible2hidden', self.visibilityFSM.request,
                     ['hidden'])
     self.moveIval.start()
 def shootOut(self):
     pathNode = NodePath('path')
     pathNode.reparentTo(self.suit)
     pathNode.setPos(0, 50, self.phone.getZ(self.suit))
     self.collNP.reparentTo(render)
     self.shootIval = LerpPosInterval(self.collNP, duration=1.0, pos=pathNode.getPos(render), startPos=self.phone.getPos(render))
     self.shootIval.start()
     pathNode.removeNode()
     del pathNode
 def enterHidden2Visible(self, autoShow=False):
     self.inventoryFrame.show()
     self.moveIval = LerpPosInterval(self.inventoryFrame,
                                     duration=InventoryGui.SwitchTime,
                                     pos=InventoryGui.VisiblePos,
                                     startPos=InventoryGui.HiddenPos)
     self.moveIval.setDoneEvent('hidden2visible')
     self.acceptOnce('hidden2visible', self.visibilityFSM.request,
                     ['visible', [autoShow]])
     self.moveIval.start()
 def moveCameraToToon(self):
     camPInt = LerpPosInterval(camera,
                               duration=3.0,
                               pos=self.localAv.getPos(render) + (0, 15, 3),
                               startPos=(camera.getPos(render)),
                               blendType="easeInOut")
     camQInt = camera.quatInterval(3.0,
                                   hpr=Vec3(180, 0, 0),
                                   blendType="easeInOut")
     camPInt.start()
     camQInt.start()
Ejemplo n.º 29
0
    def announceGenerate(self):
        """Setup other fields dependent on the required fields."""
        DistributedElevatorExt.DistributedElevatorExt.announceGenerate(self)

        angle = self.startingHpr[0]
        angle -= 90
        radAngle = deg2Rad(angle)
        unitVec = Vec3(math.cos(radAngle), math.sin(radAngle), 0)
        unitVec *= 45.0
        self.endPos = self.startingPos + unitVec
        self.endPos.setZ(0.5)

        dist = Vec3(self.endPos - self.enteringPos).length()
        wheelAngle = (dist / (4.8 * 1.4 * math.pi)) * 360

        self.kartEnterAnimateInterval = Parallel(
            # start a lerp HPR for each wheel
            LerpHprInterval(
                self.wheels[0], 5.0,
                Vec3(self.wheels[0].getH(), wheelAngle,
                     self.wheels[0].getR())),
            LerpHprInterval(
                self.wheels[1], 5.0,
                Vec3(self.wheels[1].getH(), wheelAngle,
                     self.wheels[1].getR())),
            LerpHprInterval(
                self.wheels[2], 5.0,
                Vec3(self.wheels[2].getH(), wheelAngle,
                     self.wheels[2].getR())),
            LerpHprInterval(
                self.wheels[3], 5.0,
                Vec3(self.wheels[3].getH(), wheelAngle,
                     self.wheels[3].getR())),
            name="CogKartAnimate")

        trolleyExitTrack1 = Parallel(LerpPosInterval(self.golfKart, 5.0,
                                                     self.endPos),
                                     self.kartEnterAnimateInterval,
                                     name="CogKartExitTrack")
        self.trolleyExitTrack = Sequence(
            trolleyExitTrack1,
            # Func(self.hideSittingToons), # we may not need this
        )

        self.trolleyEnterTrack = Sequence(
            LerpPosInterval(self.golfKart,
                            5.0,
                            self.startingPos,
                            startPos=self.enteringPos))

        self.closeDoors = Sequence(self.trolleyExitTrack,
                                   Func(self.onDoorCloseFinish))
        self.openDoors = Sequence(self.trolleyEnterTrack)
 def fillSlot(self, index, avId):
     toon = self.cr.doId2do.get(avId)
     toon.stopSmooth()
     if toon:
         toon.wrtReparentTo(self.trolleyCar)
         if index <= 3:
             slotPos = Point3(-5, -4.5 + index * 3, 1.4)
             sitStartDuration = toon.getDuration('start-sit')
             toon.headsUp(slotPos)
             track = Sequence(
                 Func(toon.setAnimState, 'run'),
                 LerpPosInterval(toon, 0.75,
                                 Point3(-5, -4.5 + index * 3, 1.4)),
                 LerpHprInterval(toon, 0.25, Point3(90, 0, 0)),
                 Parallel(
                     ActorInterval(toon, 'start-sit'),
                     Sequence(
                         Wait(sitStartDuration * 0.25),
                         LerpPosInterval(
                             toon, sitStartDuration * 0.25,
                             Point3(-3.9, -4.5 + index * 3, 3.0)))),
                 Func(toon.loop, 'sit'))
         else:
             slotPos = self.STAND_POSITIONS[index]
             toon.headsUp(slotPos)
             track = Sequence(
                 Func(toon.setAnimState, 'run'),
                 LerpPosInterval(toon,
                                 duration=1.0,
                                 pos=slotPos,
                                 startPos=toon.getPos()),
                 Func(toon.setAnimState, 'neutral'),
                 Func(toon.setHpr, 90, 0, 0))
         track.start()
     if avId == base.localAvatar.doId:
         self.localAvOnTrolley = True
         base.localAvatar.stopSmartCamera()
         base.camera.wrtReparentTo(self.trolleyCar)
         camTrack = Sequence(
             Parallel(
                 LerpPosInterval(base.camera,
                                 duration=1.5,
                                 pos=self.CAM_POS,
                                 startPos=base.camera.getPos(),
                                 blendType='easeOut'),
                 LerpQuatInterval(base.camera,
                                  duration=1.5,
                                  hpr=self.CAM_HPR,
                                  startHpr=base.camera.getHpr(),
                                  blendType='easeOut')),
             Func(self.enableExitButton))
         camTrack.start()
 def spawn(self, startIndex, endIndex, spawnMode=SpawnMode.FLYDOWN):
     if spawnMode == SpawnMode.FLYDOWN:
         startPoint = CIGlobals.SuitSpawnPoints[self.getHood()].keys()[startIndex]
         startPos = CIGlobals.SuitSpawnPoints[self.getHood()][startPoint] + (0,
                                                                             0,
                                                                             50)
         endPoint = CIGlobals.SuitSpawnPoints[self.getHood()].keys()[endIndex]
         endPos = CIGlobals.SuitSpawnPoints[self.getHood()][endPoint]
         if self.moveIval:
             self.moveIval.finish()
             self.moveIval = None
         self.moveIval = LerpPosInterval(self, duration=3, pos=endPos, startPos=startPos, fluid=1)
     return
        def __getCogTrack():
            def handleHit():
                if self.isLocal():
                    cog.sendUpdate('hitByGag', [self.getID()])

            startPos = cog.getPos(render)
            cogFloat = Point3(0, 0, 14)
            cogEndPos = Point3(startPos[0] + cogFloat[0],
                               startPos[1] + cogFloat[1],
                               startPos[2] + cogFloat[2])
            suitType = cog.suitPlan.getSuitType()
            if suitType == 'A':
                startFlailFrame = 16
                endFlailFrame = 16
            else:
                startFlailFrame = 15
                endFlailFrame = 15
            track = Sequence()
            track.append(Func(cog.d_disableMovement))
            track.append(Wait(0.5))
            slipIval = Sequence(
                ActorInterval(cog,
                              'slip-backward',
                              playRate=0.5,
                              startFrame=0,
                              endFrame=startFlailFrame - 1),
                Func(cog.pingpong,
                     'slip-backward',
                     fromFrame=startFlailFrame,
                     toFrame=endFlailFrame), Wait(0.5),
                Parallel(
                    ActorInterval(cog,
                                  'slip-backward',
                                  playRate=1.0,
                                  startFrame=endFlailFrame),
                    Func(cog.startRay), Func(handleHit)))
            slipUp = LerpPosInterval(cog,
                                     1.1,
                                     cogEndPos,
                                     startPos=startPos,
                                     fluid=1)
            slipDn = LerpPosInterval(cog,
                                     0.6,
                                     startPos,
                                     startPos=cogEndPos,
                                     fluid=1)
            geyserMotion = Sequence(slipUp, slipDn)
            track.append(Parallel(slipIval, geyserMotion))
            if cog.getHealth() - self.getDamage() <= 0:
                track.append(Func(cog.d_enableMovement))
            return track
Ejemplo n.º 33
0
    def releaseAttack(self, releaseFromJoint, onlyMoveColl = True, blendType = 'noBlend'):
        startNP = releaseFromJoint.attachNewNode('startNP')
        if None not in [self.targetX, self.targetY, self.targetZ]:
            startNP.lookAt(render, self.targetX, self.targetY, self.targetZ + 2)
            pathNP = NodePath('path')
            pathNP.reparentTo(startNP)
            pathNP.setScale(render, 1.0)
            pathNP.setPos(0, self.shooterDistance, 0)
            for particle in self.particles:
                if not onlyMoveColl:
                    particle.start(render)
                else:
                    particle.start(self.suit)
                particle.lookAt(pathNP)
                if self.attack == 'razzledazzle':
                    particle.setP(particle, 90)

            if onlyMoveColl:
                target = self.shootOutCollNP
                target.wrtReparentTo(render)
            else:
                target = self.particles[0]
            self.particleMoveIval = LerpPosInterval(target, duration=self.particleIvalDur, pos=pathNP.getPos(render), startPos=startNP.getPos(render), blendType=blendType)
            self.particleMoveIval.start()
            self.acceptOnce('enter' + self.shootOutCollNP.node().getName(), self.handleCollision)
            pathNP.removeNode()
            startNP.removeNode()
            del pathNP
            del startNP
        self.playParticleSound()
        return
Ejemplo n.º 34
0
Archivo: gunit.py Proyecto: onze/goLive
 def update_move(self):
    '''called every frame during while a move.'''
    if len(self.path)==0:
       out('WARNING in GUnit.update_move: path is empty, but method still called. removing it.')
       update_list.remove(self.update_move)
       return
    if not hasattr(self,'move_interval'):
       #start moving
       #first 3 args=model,duration,pos, the duration=1/... is relative to server side tile side size
       self.move_interval=LerpPosInterval(self.p3dobject,
                                  (1/(self.move_speed*ConfigVariableDouble('clock-frame-rate').getValue())),
                                  self.path[0].p3dobject.getPos(),
                                  name='interval_unit_move_'+str(self.eid)
                                  )
       self.p3dobject.lookAt(self.path[0].p3dobject.getPos())
       self.p3dobject.loop('run')
       self.move_interval.start()
    else:
       #is move ~over ?
       #t=self.move_interval.getT()
       #d=self.move_interval.getDuration()
       #d=d-t
       d=dist3(self.p3dobject,self.path[0].p3dobject)
       #out('client '+str(t*100./d)+'%')
       #arrived
       if d<self.move_speed:
          #out('client '+str(self.path[0].eid)+'@'+str(self.frame_no))
          self.p3dobject.setPos(self.path[0].p3dobject,0,0,0)
          self.path.pop(0)
          if len(self.path)==0:
             self.p3dobject.stop()
             self.move_interval.finish()
             del self.move_interval
             update_list.remove(self.update_move)
             if self.popout_when_move_over:
                self.popout()
          else:
             #first 3 args=model,duration,pos
             self.move_interval.finish()
             self.move_interval=LerpPosInterval(self.p3dobject,
                                        (1/(self.move_speed*ConfigVariableDouble('clock-frame-rate').getValue())),
                                        self.path[0].p3dobject.getPos(),
                                        name='interval_unit_move_'+str(self.eid)
                                        )
             self.p3dobject.lookAt(self.path[0].p3dobject.getPos())
             self.move_interval.start()
Ejemplo n.º 35
0
 def shootOut(self):
     pathNode = NodePath('path')
     pathNode.reparentTo(self.suit)
     pathNode.setPos(0, 50, self.phone.getZ(self.suit))
     self.collNP.reparentTo(render)
     self.shootIval = LerpPosInterval(self.collNP, duration=1.0, pos=pathNode.getPos(render), startPos=self.phone.getPos(render))
     self.shootIval.start()
     pathNode.removeNode()
     del pathNode
Ejemplo n.º 36
0
 def enterEagleFly(self, startIndex, endIndex, ts = 0.0):
     durationFactor = self.getFlySpeed()
     if startIndex > -1:
         startPos = EGG.EAGLE_FLY_POINTS[startIndex]
     else:
         startPos = self.getPos(render)
     endPos = EGG.EAGLE_FLY_POINTS[endIndex]
     if self.moveIval:
         self.moveIval.pause()
         self.moveIval = None
     self.moveIval = NPCWalkInterval(self, endPos, durationFactor=durationFactor, startPos=startPos, fluid=1)
     self.moveIval.start(ts)
     return
Ejemplo n.º 37
0
    def setProjectile(self, _from, _to):
        self.bullet.reparentTo(render)#self.model)
        # setup the projectile interval
        #self.bulletProjectile = ProjectileInterval(self.bullet,
        #                                startPos = Point3(_from),
        #                                duration = 1,
        #                                endPos = Point3(_to))
        #self.bulletProjectile = self.bullet.posInterval(1.0, Point3(_to), startPos=Point3(_from))
        #self.bulletProjectile = LerpPosInterval(self.bullet, 2.0, _to, _from)
        print "POSITIONS:"
        print _to
        print _from
        frm = render.getPos(self.main.player.model)
        print frm

        self.bulletProjectile = LerpPosInterval(self.bullet, 1.0, _to, _from)
        self.bulletProjectile.start()
Ejemplo n.º 38
0
class ParticleAttack(Attack):
    notify = directNotify.newCategory('ParticleAttack')
    attack = 'particleattack'
    particleIvalDur = 1
    shooterDistance = 50

    def __init__(self, attacksClass, suit):
        Attack.__init__(self, attacksClass, suit)
        self.particles = []
        self.handObj = None
        self.shootOutCollNP = None
        self.particleSound = None
        self.particleMoveIval = None
        self.targetX = None
        self.targetY = None
        self.targetZ = None
        return

    def handleWeaponTouch(self):
        pass

    def handleCollision(self, entry):
        if self.suit:
            self.suit.sendUpdate('toonHitByWeapon', [self.getAttackId(self.attack), base.localAvatar.doId])
            base.localAvatar.b_handleSuitAttack(self.getAttackId(self.attack), self.suit.doId)

    def doAttack(self, particlePaths, track_name, particleCollId, animation_name, delayUntilRelease, animationSpeed = 1, handObjPath = None, handObjParent = None, startRightAway = True, ts = 0):
        for path in particlePaths:
            particle = ParticleLoader.loadParticleEffect(path)
            self.particles.append(particle)

        sphere = CollisionSphere(0, 0, 0, 1)
        sphere.setTangible(0)
        node = CollisionNode(particleCollId)
        node.addSolid(sphere)
        node.setCollideMask(CIGlobals.WallBitmask)
        self.targetX = self.attacksClass.target.getX(render)
        self.targetY = self.attacksClass.target.getY(render)
        self.targetZ = self.attacksClass.target.getZ(render)
        if len(self.particles) == 1:
            self.shootOutCollNP = self.particles[0].attachNewNode(node)
        else:
            self.shootOutCollNP = self.suit.attachNewNode(node)
        if handObjPath and handObjParent:
            self.handObj = loader.loadModel(handObjPath)
            self.handObj.reparentTo(handObjParent)
        self.suit.setPlayRate(animationSpeed, animation_name)
        self.suit.play(animation_name)
        if hasattr(self.suit, 'uniqueName'):
            track_name = self.suit.uniqueName(track_name)
            particleCollId = self.suit.uniqueName(particleCollId)
        self.suitTrack = Sequence(name=track_name)
        self.suitTrack.append(Wait(delayUntilRelease))
        self.suitTrack.append(Func(self.releaseAttack))
        self.suitTrack.append(Wait(self.particleIvalDur))
        self.suitTrack.setDoneEvent(self.suitTrack.getName())
        self.acceptOnce(self.suitTrack.getDoneEvent(), self.finishedAttack)
        if startRightAway:
            self.suitTrack.start(ts)

    def releaseAttack(self, releaseFromJoint, onlyMoveColl = True, blendType = 'noBlend'):
        startNP = releaseFromJoint.attachNewNode('startNP')
        if None not in [self.targetX, self.targetY, self.targetZ]:
            startNP.lookAt(render, self.targetX, self.targetY, self.targetZ + 2)
            pathNP = NodePath('path')
            pathNP.reparentTo(startNP)
            pathNP.setScale(render, 1.0)
            pathNP.setPos(0, self.shooterDistance, 0)
            for particle in self.particles:
                if not onlyMoveColl:
                    particle.start(render)
                else:
                    particle.start(self.suit)
                particle.lookAt(pathNP)
                if self.attack == 'razzledazzle':
                    particle.setP(particle, 90)

            if onlyMoveColl:
                target = self.shootOutCollNP
                target.wrtReparentTo(render)
            else:
                target = self.particles[0]
            self.particleMoveIval = LerpPosInterval(target, duration=self.particleIvalDur, pos=pathNP.getPos(render), startPos=startNP.getPos(render), blendType=blendType)
            self.particleMoveIval.start()
            self.acceptOnce('enter' + self.shootOutCollNP.node().getName(), self.handleCollision)
            pathNP.removeNode()
            startNP.removeNode()
            del pathNP
            del startNP
        self.playParticleSound()
        return

    def playParticleSound(self):
        if self.particleSound:
            base.audio3d.attachSoundToObject(self.particleSound, self.suit)
            base.playSfx(self.particleSound)

    def cleanup(self):
        Attack.cleanup(self)
        self.targetX = None
        self.targetY = None
        self.targetZ = None
        if self.particles:
            for particle in self.particles:
                particle.cleanup()

        self.particles = None
        if self.handObj:
            self.handObj.removeNode()
            self.handObj = None
        if self.shootOutCollNP:
            self.ignore('enter' + self.shootOutCollNP.node().getName())
            self.shootOutCollNP.removeNode()
            self.shootOutCollNP = None
        if self.particleMoveIval:
            self.particleMoveIval.pause()
            self.particleMoveIval = None
        self.particleSound = None
        self.particleIvalDur = None
        return
Ejemplo n.º 39
0
class HangUpAttack(Attack):
    notify = directNotify.newCategory('HangUpAttack')
    attack = 'hangup'

    def __init__(self, attacksClass, suit):
        Attack.__init__(self, attacksClass, suit)
        self.phone = None
        self.receiver = None
        self.collNP = None
        self.phoneSfx = None
        self.hangupSfx = None
        self.shootIval = None
        self.cord = None
        self.receiverOutCord = None
        self.phoneOutCord = None
        return

    def loadAttack(self):
        self.phone = loader.loadModel('phase_3.5/models/props/phone.bam')
        self.phone.setHpr(0, 0, 180)
        if self.suit.type == 'B':
            self.phone.setPos(0.7, 0.15, 0)
        elif self.suit.type == 'C':
            self.phone.setPos(0.25, 0, 0)
        self.receiver = loader.loadModel('phase_3.5/models/props/receiver.bam')
        self.receiver.reparentTo(self.phone)
        self.cord = Rope()
        self.cord.ropeNode.setUseVertexColor(1)
        self.cord.ropeNode.setUseVertexThickness(1)
        self.cord.setup(3, ({'node': self.phone,
          'point': (0.8, 0, 0.2),
          'color': (0, 0, 0, 1),
          'thickness': 1000}, {'node': self.phone,
          'point': (2, 0, 0),
          'color': (0, 0, 0, 1),
          'thickness': 1000}, {'node': self.receiver,
          'point': (1.1, 0.25, 0.5),
          'color': (0, 0, 0, 1),
          'thickness': 1000}), [])
        self.cord.setH(180)
        self.phoneSfx = base.audio3d.loadSfx('phase_3.5/audio/sfx/SA_hangup.mp3')
        base.audio3d.attachSoundToObject(self.phoneSfx, self.phone)
        self.hangupSfx = base.audio3d.loadSfx('phase_3.5/audio/sfx/SA_hangup_place_down.mp3')
        base.audio3d.attachSoundToObject(self.hangupSfx, self.phone)
        collSphere = CollisionSphere(0, 0, 0, 2)
        collSphere.setTangible(0)
        collNode = CollisionNode('phone_shootout')
        collNode.addSolid(collSphere)
        collNode.setCollideMask(CIGlobals.WallBitmask)
        self.collNP = self.phone.attachNewNode(collNode)

    def doAttack(self, ts = 0):
        self.loadAttack()
        if hasattr(self.suit, 'uniqueName'):
            name = self.suit.uniqueName('doHangupAttack')
        else:
            name = 'doHangupAttack'
        if self.suit.type == 'A':
            delay2playSound = 1.0
            delayAfterSoundToPlaceDownReceiver = 0.2
            delayAfterShootToIgnoreCollisions = 1.0
            delay2PickUpReceiver = 1.0
            receiverInHandPos = Point3(-0.5, 0.5, -1)
        elif self.suit.type == 'B':
            delay2playSound = 1.5
            delayAfterSoundToPlaceDownReceiver = 0.7
            delayAfterShootToIgnoreCollisions = 1.0
            delay2PickUpReceiver = 1.5
            receiverInHandPos = Point3(-0.3, 0.5, -0.8)
        elif self.suit.type == 'C':
            delay2playSound = 1.0
            delayAfterSoundToPlaceDownReceiver = 1.15
            delayAfterShootToIgnoreCollisions = 1.0
            delay2PickUpReceiver = 1.5
            receiverInHandPos = Point3(-0.3, 0.5, -0.8)
        self.suitTrack = Parallel(name=name)
        self.suitTrack.append(ActorInterval(self.suit, 'phone'))
        self.suitTrack.append(Sequence(Wait(delay2playSound), SoundInterval(self.phoneSfx, duration=2.1), Wait(delayAfterSoundToPlaceDownReceiver), Func(self.receiver.setPos, 0, 0, 0), Func(self.receiver.setH, 0.0), Func(self.receiver.reparentTo, self.phone), Func(self.acceptOnce, 'enter' + self.collNP.node().getName(), self.handleCollision), Func(self.shootOut), Parallel(SoundInterval(self.hangupSfx), Sequence(Wait(delayAfterShootToIgnoreCollisions), Func(self.ignore, 'enter' + self.collNP.node().getName())))))
        self.suitTrack.append(Sequence(Func(self.phone.reparentTo, self.suit.find('**/joint_Lhold')), Func(self.cord.reparentTo, render), Wait(delay2PickUpReceiver), Func(self.receiver.reparentTo, self.suit.find('**/joint_Rhold')), Func(self.receiver.setPos, receiverInHandPos), Func(self.receiver.setH, 270.0)))
        self.suitTrack.setDoneEvent(self.suitTrack.getName())
        self.acceptOnce(self.suitTrack.getDoneEvent(), self.finishedAttack)
        self.suitTrack.delayDelete = DelayDelete.DelayDelete(self.suit, name)
        self.suitTrack.start(ts)

    def handleCollision(self, entry):
        if self.suit:
            self.suit.sendUpdate('toonHitByWeapon', [self.getAttackId(self.attack), base.localAvatar.doId])
            base.localAvatar.b_handleSuitAttack(self.getAttackId(self.attack), self.suit.doId)

    def shootOut(self):
        pathNode = NodePath('path')
        pathNode.reparentTo(self.suit)
        pathNode.setPos(0, 50, self.phone.getZ(self.suit))
        self.collNP.reparentTo(render)
        self.shootIval = LerpPosInterval(self.collNP, duration=1.0, pos=pathNode.getPos(render), startPos=self.phone.getPos(render))
        self.shootIval.start()
        pathNode.removeNode()
        del pathNode

    def cleanup(self):
        Attack.cleanup(self)
        if self.shootIval:
            self.shootIval.pause()
            self.shootIval = None
        if self.cord:
            self.cord.removeNode()
            self.cord = None
        if self.phone:
            self.phone.removeNode()
            self.phone = None
        if self.receiver:
            self.receiver.removeNode()
            self.receiver = None
        if self.collNP:
            self.collNP.node().clearSolids()
            self.collNP.removeNode()
            self.collNP = None
        if self.phoneSfx:
            self.phoneSfx.stop()
            self.phoneSfx = None
        return
Ejemplo n.º 40
0
class ThrowAttack(Attack):
    notify = directNotify.newCategory('ThrowAttack')
    attack = 'throw'

    def __init__(self, attacksClass, suit):
        Attack.__init__(self, attacksClass, suit)
        self.weapon_state = None
        self.weapon = None
        self.wss = None
        self.wsnp = None
        self.suitTrack = None
        self.weaponSfx = None
        self.throwTrajectory = None
        self.targetX = None
        self.targetY = None
        self.targetZ = None
        self.startNP = None
        return

    def handleWeaponCollision(self, entry):
        if self.suit:
            self.suit.sendUpdate('toonHitByWeapon', [self.getAttackId(self.attack), base.localAvatar.doId])
            base.localAvatar.b_handleSuitAttack(self.getAttackId(self.attack), self.suit.doId)
            self.suit.b_handleWeaponTouch()

    def doAttack(self, weapon_path, weapon_scale, track_name, animation_name, collsphere_radius, weapon_coll_id, weapon_h = 0, weapon_p = 0, weapon_r = 0, weapon_x = 0, weapon_y = 0, weapon_z = 0, ts = 0):
        self.weapon_state = 'start'
        if hasattr(self.suit, 'uniqueName'):
            track_name = self.suit.uniqueName(track_name)
            weapon_coll_id = self.suit.uniqueName(weapon_coll_id)
        self.weapon = loader.loadModel(weapon_path)
        self.weapon.setScale(weapon_scale)
        self.weapon.setHpr(weapon_h, weapon_p, weapon_r)
        self.weapon.setPos(weapon_x, weapon_y, weapon_z)
        self.wss = CollisionSphere(0, 0, 0, collsphere_radius)
        self.wss.setTangible(0)
        self.targetX = self.attacksClass.target.getX(render)
        self.targetY = self.attacksClass.target.getY(render)
        self.targetZ = self.attacksClass.target.getZ(render)
        self.suitTrack = Sequence(name=track_name)
        if self.attack not in ('glowerpower',):
            self.weapon.reparentTo(self.suit.find('**/joint_Rhold'))
            self.suitTrack.append(Wait(1.2))
            self.suitTrack.append(Func(self.suit.setPlayRate, 1.0, animation_name))
            if self.suit.type == 'C':
                self.suitTrack.append(Wait(0))
            else:
                self.suitTrack.append(Wait(0.7))
            self.suit.setPlayRate(2.0, animation_name)
            self.suitTrack.append(Func(self.throwObject))
            self.suitTrack.append(Wait(1.0))
            self.suitTrack.append(Func(self.delWeapon))
        else:
            self.suitTrack.append(Wait(1))
            self.suitTrack.append(Func(self.throwObject))
            self.suitTrack.append(Wait(0.5))
            self.suitTrack.append(Func(self.delWeapon))
        self.suit.play(animation_name)
        wsnode = CollisionNode(weapon_coll_id)
        wsnode.addSolid(self.wss)
        wsnode.setCollideMask(CIGlobals.WallBitmask)
        self.wsnp = self.weapon.attachNewNode(wsnode)
        self.suitTrack.setDoneEvent(self.suitTrack.getName())
        self.acceptOnce(self.suitTrack.getDoneEvent(), self.finishedAttack)
        self.suitTrack.delayDelete = DelayDelete.DelayDelete(self.suit, track_name)
        self.suitTrack.start(ts)

    def playWeaponSound(self):
        if self.weapon and self.weaponSfx:
            base.audio3d.attachSoundToObject(self.weaponSfx, self.suit)
            self.weaponSfx.play()

    def throwObject(self, projectile = True):
        if not self.weapon:
            return
        self.acceptOnce('enter' + self.wsnp.node().getName(), self.handleWeaponCollision)
        self.playWeaponSound()
        if self.weapon:
            self.weapon.wrtReparentTo(render)
            self.weapon.setHpr(Vec3(0, 0, 0))
        if self.attack not in ('glowerpower',):
            parent = self.suit.find('**/joint_Rhold')
        else:
            parent = self.suit.find('**/joint_head')
        startNP = parent.attachNewNode('startNp')
        startNP.lookAt(render, self.targetX, self.targetY, self.targetZ)
        pathNP = NodePath('throwPath')
        pathNP.reparentTo(startNP)
        pathNP.setScale(render, 1.0)
        pathNP.setPos(0, 50, 0)
        if self.attack in ('clipontie', 'powertie', 'halfwindsor'):
            self.weapon.setHpr(pathNP.getHpr(render))
        if projectile == True:
            self.throwTrajectory = ProjectileInterval(self.weapon, startPos=self.suit.find('**/joint_Rhold').getPos(render), endPos=pathNP.getPos(render), gravityMult=0.7, duration=1.0)
        else:
            self.weapon.setH(pathNP.getH(render))
            self.throwTrajectory = LerpPosInterval(self.weapon, duration=0.5, pos=pathNP.getPos(render), startPos=startNP.getPos(render) + (0, 3, 0))
        self.throwTrajectory.start()
        self.weapon_state = 'released'
        startNP.removeNode()
        del startNP
        pathNP.removeNode()
        del pathNP

    def interruptAttack(self):
        if self.throwTrajectory:
            if self.throwTrajectory.isStopped():
                self.delWeapon()

    def handleWeaponTouch(self):
        if self.throwTrajectory:
            self.throwTrajectory.pause()
            self.throwTrajectory = None
        self.delWeapon()
        return

    def delWeapon(self):
        if self.weapon:
            self.weapon.removeNode()
            self.weapon = None
        return

    def cleanup(self):
        Attack.cleanup(self)
        self.targetX = None
        self.targetY = None
        self.targetZ = None
        self.weapon_state = None
        if self.weaponSfx:
            self.weaponSfx.stop()
            self.weaponSfx = None
        if self.throwTrajectory:
            self.throwTrajectory.pause()
            self.throwTrajectory = None
        self.delWeapon()
        self.wss = None
        if self.wsnp:
            self.wsnp.node().clearSolids()
            self.wsnp.removeNode()
            self.wsnp = None
        return
class RepairGridPiece(DirectButton, FSM.FSM):

    def __init__(self, name, parent, allWoodSquaresGeom, selectedOutlineGeom, command, location, **kw):
        optiondefs = ()
        self.defineoptions(kw, optiondefs)
        DirectButton.__init__(self, parent)
        self.initialiseoptions(RepairGridPiece)
        FSM.FSM.__init__(self, 'RepairGridPiece_%sFSM' % name)
        self.name = name
        self.allWoodSquaresGeom = allWoodSquaresGeom
        self.selectedOutlineGeom = selectedOutlineGeom
        self.command = command
        self.location = location
        self._initVars()
        self._initGUI()
        self._initIntervals()
        self.accept(self.guiItem.getEnterEvent(), self.onMouseEnter)
        self.accept(self.guiItem.getExitEvent(), self.onMouseExit)
        self.bind(DGG.B1PRESS, self.onMouseDown)
        self.bind(DGG.B1RELEASE, self.onMouseUp)
        self.bind(DGG.B2PRESS, self.onMouseUp)
        self.bind(DGG.B2RELEASE, self.onMouseUp)
        self.bind(DGG.B3PRESS, self.onMouseUp)
        self.bind(DGG.B3RELEASE, self.onMouseUp)
        self.idleGeom = NodePath('idleGeom')
        self.highlightedGeom = NodePath('highlightedGeom')
        self.haveMoved = False
        self.grabPoint = None
        self.setType(GOAL_NONE)


    def _initVars(self):
        self.pieceType = GOAL_NONE
        self.enabled = True
        self.isMouseDown = False
        self.isMouseInButton = False


    def _initGUI(self):
        self.selectedOutlineGeom.reparentTo(self)
        self.selectedOutlineGeom.hide()
        self.selectedOutlineGeom.setBin('fixed', 38)


    def _initIntervals(self):
        self.moveInterval = LerpPosInterval(self, duration = RepairGlobals.Bracing.moveTime, pos = self.getPos(), name = 'RepairGridPiece_%s.moveInterval' % self.name)


    def destroy(self):
        taskMgr.remove(self.uniqueName('RepairGridPiece.updateTask'))
        taskMgr.remove(DGG.B1PRESS)
        taskMgr.remove(DGG.B1RELEASE)
        taskMgr.remove(DGG.B2PRESS)
        taskMgr.remove(DGG.B2RELEASE)
        taskMgr.remove(DGG.B3PRESS)
        taskMgr.remove(DGG.B3RELEASE)
        self.idleGeom.detachNode()
        self.idleGeom = None
        self.highlightedGeom.detachNode()
        self.highlightedGeom = None
        self.ignore(self.guiItem.getEnterEvent())
        self.ignore(self.guiItem.getExitEvent())
        self.moveInterval.clearToInitial()
        del self.moveInterval
        DirectFrame.destroy(self)
        self.clearPiece()
        self.allWoodSquaresGeom.removeNode()
        del self.allWoodSquaresGeom


    def setGeomState(self, state):
        if state == 'idle':
            self.idleGeom.show()
            self.highlightedGeom.hide()
        elif state == 'highlighted':
            self.highlightedGeom.show()
            self.idleGeom.hide()



    def onMouseEnter(self, event):
        self.isMouseInButton = True
        if self.isMouseDown:
            self.setGeomState('idle')
        else:
            self.setGeomState('highlighted')


    def onMouseExit(self, event):
        self.isMouseInButton = False
        self.setGeomState('idle')


    def onMouseDown(self, event):
        if self.isMouseInButton:
            self.selectedOutlineGeom.show()
            self.setGeomState('idle')
            self.isMouseDown = True
            self.haveMoved = False
            screenx = base.mouseWatcherNode.getMouseX()
            screeny = base.mouseWatcherNode.getMouseY()
            self.grabPoint = aspect2d.getRelativePoint(render2d, (screenx, 0, screeny))
            taskMgr.add(self.updateTask, self.uniqueName('RepairGridPiece.updateTask'), extraArgs = [])



    def onMouseUp(self, event):
        if self.isMouseDown:
            self.isMouseDown = False
            if not self.haveMoved:
                self.checkMovePiece(True)

            self.grabPoint = None
            if self.isMouseInButton:
                self.setGeomState('highlighted')
            else:
                self.setGeomState('idle')
            self.selectedOutlineGeom.hide()
            taskMgr.remove(self.uniqueName('RepairGridPiece.updateTask'))



    def onMoveButtonPressed(self, dir1, dir2):
        if not self.moveInterval.isPlaying():
            self.haveMoved = True
            args = self.location[:]
            args.append((dir1, dir2))
            return self.command(*args)



    def updateTask(self):
        if not (self.isMouseInButton) and not self.moveInterval.isPlaying():
            self.checkMovePiece()

        return Task.cont


    def checkMovePiece(self, isPush = False):
        directions = [
            (0, 1),
            (0, -1),
            (-1, 0),
            (1, 0)]
        if self.grabPoint is None:
            self.grabPoint = self.getPos(aspect2d)

        screenx = base.mouseWatcherNode.getMouseX()
        screeny = base.mouseWatcherNode.getMouseY()
        cursorPos = aspect2d.getRelativePoint(render2d, (screenx, 0, screeny))
        diff = self.grabPoint - cursorPos
        absX = math.fabs(diff.getX())
        absZ = math.fabs(diff.getZ())
        moveDirection = None
        if isPush:
            threshold = RepairGlobals.Bracing.pushPieceThreshold
        else:
            threshold = RepairGlobals.Bracing.movePieceThreshold
        if absZ > absX and diff.getZ() > 0.0 and absZ > threshold:
            moveDirection = directions[1]
        elif absZ > absX and diff.getZ() < 0.0 and absZ > threshold:
            moveDirection = directions[0]
        elif absX > absZ and diff.getX() > 0.0 and absX > threshold:
            moveDirection = directions[2]
        elif absX > absZ and diff.getX() < 0.0 and absX > threshold:
            moveDirection = directions[3]

        if moveDirection:
            if self.onMoveButtonPressed(*moveDirection) and self.grabPoint is not None:
                self.grabPoint += VBase3(SPACING * moveDirection[0], 0.0, SPACING * moveDirection[1])




    def setType(self, type):
        self.pieceType = type
        activeWoodSquareGeom = self.allWoodSquaresGeom.find('**/%s' % GOAL_TO_TEXTURE[type])
        self.idleGeom.detachNode()
        self.idleGeom = None
        self.highlightedGeom.detachNode()
        self.highlightedGeom = None
        self.idleGeom = NodePath('idleGeom')
        self.highlightedGeom = NodePath('highlightedGeom')
        self.idleGeom.reparentTo(self)
        self.highlightedGeom.reparentTo(self)
        if activeWoodSquareGeom.isEmpty():
            self.stash()
        else:
            activeWoodSquareGeom.find('**/idle').copyTo(self.idleGeom)
            activeWoodSquareGeom.find('**/over').copyTo(self.highlightedGeom)
            self.setGeomState('idle')
            self.unstash()


    def setEnabled(self, enabled):
        self.onMouseUp(None)
        self.enabled = enabled
        if not enabled:
            self['state'] = DGG.DISABLED
        else:
            self['state'] = DGG.NORMAL


    def isGoalPiece(self):
        if self.pieceType != GOAL_NONE:
            pass
        return self.pieceType != GOAL_EMPTY


    def isEmptyPiece(self):
        return self.pieceType == GOAL_EMPTY


    def setGridLocation(self, location, pos):
        self.location = location
        self.setPos(pos)


    def enterIdle(self):
        self.stash()
        self.setEnabled(False)


    def exitIdle(self):
        self.unstash()


    def enterBlank(self):
        self.setType(GOAL_NONE)


    def exitBlank(self):
        self.unstash()


    def enterGoal(self, pieceType):
        self.setType(pieceType)


    def exitGoal(self):
        self.unstash()


    def enterEmpty(self):
        self.setEnabled(False)
        self.setType(GOAL_EMPTY)


    def exitEmpty(self):
        self.unstash()
 def _initIntervals(self):
     self.moveInterval = LerpPosInterval(self, duration = RepairGlobals.Bracing.moveTime, pos = self.getPos(), name = 'RepairGridPiece_%s.moveInterval' % self.name)
Ejemplo n.º 43
0
class DistributedEagleSuit(DistributedSuit):
    notify = directNotify.newCategory('DistributedEagleSuit')

    def __init__(self, cr):
        DistributedSuit.__init__(self, cr)
        self.eagleCry = base.audio3d.loadSfx('phase_5/audio/sfx/tt_s_ara_cfg_eagleCry.mp3')
        base.audio3d.attachSoundToObject(self.eagleCry, self)
        self.fallWhistle = base.audio3d.loadSfx('phase_5/audio/sfx/incoming_whistleALT.mp3')
        base.audio3d.attachSoundToObject(self.fallWhistle, self)
        self.explode = base.audio3d.loadSfx('phase_3.5/audio/sfx/ENC_cogfall_apart.mp3')
        base.audio3d.attachSoundToObject(self.explode, self)
        self.eventSphereNodePath = None
        self.fallingPropeller = None
        self.fallingPropProjectile = None
        self.mg = None
        self.flySpeed = 0.0
        return

    def enterNeutral(self, ts = 0):
        self.show()
        self.timestampAnimTrack = Sequence(Wait(ts), Func(self.loop, 'flyNeutral'))
        self.timestampAnimTrack.start()

    def makeStateDict(self):
        self.suitFSM.addState(State('eagleFly', self.enterEagleFly, self.exitEagleFly))
        self.suitFSM.addState(State('eagleFall', self.enterEagleFall, self.exitEagleFall))
        self.stateIndex2suitState = {0: self.suitFSM.getStateNamed('off'),
         1: self.suitFSM.getStateNamed('walking'),
         2: self.suitFSM.getStateNamed('flyingDown'),
         3: self.suitFSM.getStateNamed('flyingUp'),
         4: self.suitFSM.getStateNamed('lured'),
         5: self.suitFSM.getStateNamed('eagleFly'),
         6: self.suitFSM.getStateNamed('eagleFall')}
        self.suitState2stateIndex = {}
        for stateId, state in self.stateIndex2suitState.items():
            self.suitState2stateIndex[state.getName()] = stateId

    def setFlySpeed(self, value):
        self.flySpeed = value

    def getFlySpeed(self):
        return self.flySpeed

    def enterEagleFly(self, startIndex, endIndex, ts = 0.0):
        durationFactor = self.getFlySpeed()
        if startIndex > -1:
            startPos = EGG.EAGLE_FLY_POINTS[startIndex]
        else:
            startPos = self.getPos(render)
        endPos = EGG.EAGLE_FLY_POINTS[endIndex]
        if self.moveIval:
            self.moveIval.pause()
            self.moveIval = None
        self.moveIval = NPCWalkInterval(self, endPos, durationFactor=durationFactor, startPos=startPos, fluid=1)
        self.moveIval.start(ts)
        return

    def exitEagleFly(self):
        if self.moveIval:
            self.moveIval.pause()
            self.moveIval = None
        return

    def enterEagleFall(self, startIndex, endIndex, ts = 0.0):
        self.moveIval = LerpPosInterval(self, duration=4.0, pos=self.getPos(render) - (0, 0, 75), startPos=self.getPos(render), blendType='easeIn')
        self.moveIval.start(ts)

    def exitEagleFall(self):
        if self.moveIval:
            self.moveIval.finish()
            self.moveIval = None
        return

    def fallAndExplode(self):
        self.cleanupPropeller()
        self.fallingPropeller = Actor('phase_4/models/props/propeller-mod.bam', {'chan': 'phase_4/models/props/propeller-chan.bam'})
        self.fallingPropeller.reparentTo(render)
        self.fallingPropeller.loop('chan', fromFrame=0, toFrame=3)
        parentNode = self.attachNewNode('fallingPropParentNode')
        h = random.randint(0, 359)
        parentNode.setH(h)
        dummyNode = parentNode.attachNewNode('dummyNode')
        dummyNode.setPos(0, 10, -50)
        self.fallingPropProjectile = FlightProjectileInterval(self.fallingPropeller, startPos=self.find('**/joint_head').getPos(render), endPos=dummyNode.getPos(render), duration=5.0, gravityMult=0.25)
        self.fallingPropProjectile.start()
        dummyNode.removeNode()
        del dummyNode
        parentNode.removeNode()
        del parentNode
        self.updateHealthBar(0)
        self.ignoreHit()
        self.fallWhistle.play()
        taskMgr.doMethodLater(4.0, self.doExplodeSound, self.uniqueName('DEagleSuit-doExplodeSound'))

    def doExplodeSound(self, task):
        self.explode.play()
        return Task.done

    def __initializeEventSphere(self):
        sphere = CollisionSphere(0, 0, 0, 2)
        sphere.setTangible(0)
        node = CollisionNode(self.uniqueName('DEagleSuit-eventSphere'))
        node.addSolid(sphere)
        node.setCollideMask(CIGlobals.WallBitmask)
        np = self.attachNewNode(node)
        np.setSz(2.5)
        np.setZ(5.5)
        self.eventSphereNodePath = np

    def removeEventSphere(self):
        if self.eventSphereNodePath:
            self.eventSphereNodePath.removeNode()
            self.eventSphereNodePath = None
        return

    def acceptHit(self):
        self.acceptOnce('enter' + self.eventSphereNodePath.node().getName(), self.__handleHit)

    def ignoreHit(self):
        self.ignore('enter' + self.eventSphereNodePath.node().getName())

    def __handleHit(self, entry):
        messenger.send(EGG.EAGLE_HIT_EVENT, [self.doId])

    def setSuit(self, arg, variant):
        DistributedSuit.setSuit(self, arg, 3)
        self.deleteShadow()
        self.disableBodyCollisions()
        self.disableRay()
        self.__initializeEventSphere()
        self.show()
        self.setAnimState('flyNeutral')

    def __doEagleCry(self, task):
        self.eagleCry.play()
        task.delayTime = random.uniform(3, 30)
        return Task.again

    def announceGenerate(self):
        DistributedSuit.announceGenerate(self)
        taskMgr.doMethodLater(random.uniform(5, 25), self.__doEagleCry, self.uniqueName('DEagleSuit-doEagleCry'))
        self.acceptHit()

    def disable(self):
        self.ignoreHit()
        self.removeEventSphere()
        taskMgr.remove(self.uniqueName('DEagleSuit-doExplodeSound'))
        taskMgr.remove(self.uniqueName('DEagleSuit-doEagleCry'))
        if self.fallingPropProjectile:
            self.fallingPropProjectile.finish()
            self.fallingPropProjectile = None
        if self.fallingPropeller:
            self.fallingPropeller.cleanup()
            self.fallingPropeller = None
        base.audio3d.detachSound(self.fallWhistle)
        del self.fallWhistle
        base.audio3d.detachSound(self.explode)
        del self.explode
        base.audio3d.detachSound(self.eagleCry)
        del self.eagleCry
        self.mg = None
        DistributedSuit.disable(self)
        return
Ejemplo n.º 44
0
 def enterEagleFall(self, startIndex, endIndex, ts = 0.0):
     self.moveIval = LerpPosInterval(self, duration=4.0, pos=self.getPos(render) - (0, 0, 75), startPos=self.getPos(render), blendType='easeIn')
     self.moveIval.start(ts)
Ejemplo n.º 45
0
Archivo: gunit.py Proyecto: onze/goLive
class GUnit(GEntity):
   
   def __init__(self,conf):
      GEntity.__init__(self,conf)
      self.p3dobject.reparentTo(self.gmap.units_node)
      self.p3dobject.setTransparency(TransparencyAttrib.MAlpha)
      #to be put under condition for non pickable units (bonuses npc for instance)
      self.p3dobject.setTag('GUnit-pickable','1')
      self.p3dobject.setPos(self.gmap.root.find('**/tile_'+str(conf['tileid'])),0,0,0)
      #supposedly already a float, but will screw up if not, so just making sure.
      self.move_speed=float(conf['move_speed'])
      self.path=[]
      self.popout_when_move_over=False
      self.pid=conf['pid']
      #highlight
      self.ts_highlighted=TextureStage('ts_highlighted')
      self.ts_highlighted.setMode(TextureStage.MDecal)
      self.ts_highlighted.setSort(2)
      #highlight
      self.ts_selected=TextureStage('ts_selected')
      self.ts_selected.setMode(TextureStage.MDecal)
      self.ts_selected.setSort(3)
               
   @staticmethod
   def load_resources():
      GUnit.textures={   'highlighted':loader.loadTexture('data/models/highlighted.tex.png'),
                        'selected':loader.loadTexture('data/models/selected.tex.png'),
                     }
      
   def dispose(self):
      '''del method'''
      GEntity.dispose(self)
      self.popout_sequence.finish()
      del self.popout_sequence

   def add_path(self,data):
      '''
      adds tile to pass by.
      '''
      #check for data completeness
      if not 'path' in data:
         out('WARNING in GUnit.add_path: incomplete data:\n'+str(data))
         return
      elif not isinstance(data['path'],list):
         out('WARNING in GUnit.add_path: invalid data:\n'+str(data))
         return
      #data considered valid
      self.path.extend([self.instances[eid] for eid in data['path']])
      if not self.update_move in update_list: 
         update_list.append(self.update_move)
      #out('GUnit.add_path:'+str(data))
   
   def finish_move_to(self,data):
      '''triggered by server side unit, to indicate the need to popout at end of move.'''
      out('GUnit.finish_move_to()'+str(data))
      if self.update_move in update_list:
         self.popout_when_move_over=True
      else:
         self.popout()
         
   def popout(self):
      '''sets up the popout animation at end of unit's mission'''
      scale=self.p3dobject.scaleInterval(.5,(.1,.1,.1))
      finish=Func(lambda:dispose_list.append(self))
      self.popout_sequence=Sequence(scale,finish)
      self.popout_sequence.start()
      
   def set_highlighted(self):
      self.p3dobject.setTexture(self.ts_highlighted,self.textures['highlighted'])
      
   def unset_highlighted(self):
      self.p3dobject.clearTexture(self.ts_highlighted)
      
   def set_selected(self):
      self.p3dobject.setTexture(self.ts_selected,self.textures['selected'])
      
   def unset_selected(self):
      self.p3dobject.clearTexture(self.ts_selected)
      
   def update_move(self):
      '''called every frame during while a move.'''
      if len(self.path)==0:
         out('WARNING in GUnit.update_move: path is empty, but method still called. removing it.')
         update_list.remove(self.update_move)
         return
      if not hasattr(self,'move_interval'):
         #start moving
         #first 3 args=model,duration,pos, the duration=1/... is relative to server side tile side size
         self.move_interval=LerpPosInterval(self.p3dobject,
                                    (1/(self.move_speed*ConfigVariableDouble('clock-frame-rate').getValue())),
                                    self.path[0].p3dobject.getPos(),
                                    name='interval_unit_move_'+str(self.eid)
                                    )
         self.p3dobject.lookAt(self.path[0].p3dobject.getPos())
         self.p3dobject.loop('run')
         self.move_interval.start()
      else:
         #is move ~over ?
         #t=self.move_interval.getT()
         #d=self.move_interval.getDuration()
         #d=d-t
         d=dist3(self.p3dobject,self.path[0].p3dobject)
         #out('client '+str(t*100./d)+'%')
         #arrived
         if d<self.move_speed:
            #out('client '+str(self.path[0].eid)+'@'+str(self.frame_no))
            self.p3dobject.setPos(self.path[0].p3dobject,0,0,0)
            self.path.pop(0)
            if len(self.path)==0:
               self.p3dobject.stop()
               self.move_interval.finish()
               del self.move_interval
               update_list.remove(self.update_move)
               if self.popout_when_move_over:
                  self.popout()
            else:
               #first 3 args=model,duration,pos
               self.move_interval.finish()
               self.move_interval=LerpPosInterval(self.p3dobject,
                                          (1/(self.move_speed*ConfigVariableDouble('clock-frame-rate').getValue())),
                                          self.path[0].p3dobject.getPos(),
                                          name='interval_unit_move_'+str(self.eid)
                                          )
               self.p3dobject.lookAt(self.path[0].p3dobject.getPos())
               self.move_interval.start()
Ejemplo n.º 46
0
class Weapon(DirectObject):
    def __init__(self, _main, _name, _fireRate, _dmg=20,_mountSlot=0, weaponType="Pistol"):
        self.main = _main
        self.name = _name
        self.fireRate = _fireRate
        self.dmg = _dmg
        self.weaponType = weaponType
        self.mountSlot = _mountSlot

        self.muzzleFlash = loader.loadModel("muzzleflash")
        if weaponType == "Pistol":
            self.style = "OneHand"
            self.model = loader.loadModel("Pistol")
            self.muzzleFlash.setZ(0.65)
            self.muzzleFlash.setX(-0.04)
            self.muzzleFlash.setScale(0.25)
            self.muzzleFlash.find('**/+SequenceNode').node().setFrameRate(20)
        else:
            self.style = "TwoHand"
            self.model = loader.loadModel("MG")
            self.muzzleFlash.setZ(0.65)
            self.muzzleFlash.setX(0.08)
            self.muzzleFlash.setScale(0.3)
            self.muzzleFlash.find('**/+SequenceNode').node().setFrameRate(20)
        self.model.setY(2)
        self.muzzleFlash.reparentTo(self.model)
        self.muzzleFlash.find('**/+SequenceNode').node().stop()
        self.muzzleFlash.hide()

        # Load bullet model
        self.bullet = loader.loadModel("Bullet")
        self.bullet.setP(-90)
        self.bullet.setH(180)
        #self.bullet.setPos(0, 0.5, 0)

        # Control
        self.isFiring = False

        # Collision Stuff
        self.wepRay = None
        # Make weapon ray
        self.setupRay()
        self.model.show()

    def setAmmo(self):
        pass

    def setupRay(self):
        self.shootTraverser = CollisionTraverser()
        self.shootingQH = CollisionHandlerQueue()
        #self.shootingEH = CollisionHandlerEvent()
        #self.shootingEH.addInPattern('into-%in')
        # Create a collision Node
        shootNode = CollisionNode('WeaponRay')
        # set the nodes collision bitmask
        shootNode.setFromCollideMask(BitMask32.bit(1))
        # create a collision segment (ray like)
        self.shootRay = CollisionSegment()
        shootNode.addSolid(self.shootRay)
        #self.pickerNP = self.main.player.model.attachNewNode(pickerNode)
        self.shootNP = render.attachNewNode(shootNode)
        #self.shootTraverser.addCollider(self.shootNP, self.shootingEH)
        self.shootTraverser.addCollider(self.shootNP, self.shootingQH)
        #self.shootNP.show()

    def doFire(self, _toPos=(0, 0, 0)):
        self.isFiring = True

        if self.weaponType == "Pistol":
            self.muzzleFlash.find('**/+SequenceNode').node().play(0, 1)
        else:
            self.muzzleFlash.find('**/+SequenceNode').node().loop(True)
        self.muzzleFlash.show()

        # For some reason the mouse ray end up at posZ -1 (which causes a problem when we make the enemy spheres smaller in radius)
        # so here for now.. ill make a quick fix.
        adjustedZ = (_toPos[0], _toPos[1], 0)

        self.shootRay.setPointA(self.main.player.model.getPos())
        self.shootRay.setPointB(adjustedZ)

        fromPos = self.main.player.model.getPos() #self.model.getPos()
        #self.setProjectile(fromPos, adjustedZ)#_toPos)

        self.shootTraverser.traverse(self.main.enemyParent)
        if self.shootingQH.getNumEntries() > 0:
            self.shootingQH.sortEntries()
            enemyCol = self.shootingQH.getEntry(0).getIntoNodePath().node().getName()
            base.messenger.send("into-" + enemyCol, [self.dmg])

    def stopFire(self):
        if self.weaponType == "Pistol" and \
               self.muzzleFlash.find('**/+SequenceNode').node().isPlaying():
            taskMgr.add(self.waitForFrame, "waitForFrame")
            return
        self.muzzleFlash.find('**/+SequenceNode').node().stop()
        self.muzzleFlash.hide()

    def waitForFrame(self, task):
        if self.muzzleFlash.find('**/+SequenceNode').node().isPlaying():
            return task.cont
        self.muzzleFlash.find('**/+SequenceNode').node().stop()
        self.muzzleFlash.hide()

    def reload(self):
        pass

    def setProjectile(self, _from, _to):
        self.bullet.reparentTo(render)#self.model)
        # setup the projectile interval
        #self.bulletProjectile = ProjectileInterval(self.bullet,
        #                                startPos = Point3(_from),
        #                                duration = 1,
        #                                endPos = Point3(_to))
        #self.bulletProjectile = self.bullet.posInterval(1.0, Point3(_to), startPos=Point3(_from))
        #self.bulletProjectile = LerpPosInterval(self.bullet, 2.0, _to, _from)
        print "POSITIONS:"
        print _to
        print _from
        frm = render.getPos(self.main.player.model)
        print frm

        self.bulletProjectile = LerpPosInterval(self.bullet, 1.0, _to, _from)
        self.bulletProjectile.start()
class CogdoFlyingRobberBaron(DirectObject, FSM):
    CollSphereName = 'CogdoFlyingRobberBaronSphere'
    CollisionEventName = 'CogdoFlyingRobberBaronCollision'
    InterestCollName = 'CogdoFlyingRobberBaronInterestCollision'
    RequestAddTargetEventName = 'CogdoFlyingRobberBaronRequestTargetEvent'
    RequestAddTargetAgainEventName = 'CogdoFlyingRobberBaronRequestTargetAgainEvent'
    RequestRemoveTargetEventName = 'CogdoFlyingRobberBaronRemoveTargetEvent'
    ForceRemoveTargetEventName = 'CogdoFlyingRobberBaronForceRemoveTargetEvent'
    EnterRobberBaron = 'CogdoFlyingRobberBaronDamageToon'
    ChargingToAttackEventName = 'RobberBaronChargingToAttack'
    LockOnToonEventName = 'RobberBaronLockOnToon'
    CooldownEventName = 'RobberBaronCooldown'
    notify = DirectNotifyGlobal.directNotify.newCategory('CogdoFlyingRobberBaron')

    def __init__(self, nest, index, suitDnaName = 'le'):
        FSM.__init__(self, 'CogdoFlyingRobberBaron')
        self.defaultTransitions = {'Off': ['Roost'],
         'Roost': ['TakeOff', 'Off'],
         'TakeOff': ['LockOnToon', 'LandOnNest', 'Off'],
         'LockOnToon': ['RetreatToNest', 'ChargeUpAttack', 'Off'],
         'ChargeUpAttack': ['RetreatToNest', 'Attack', 'Off'],
         'Attack': ['RetreatToSky', 'Off'],
         'RetreatToSky': ['Cooldown', 'Off'],
         'Cooldown': ['LockOnToon', 'LandOnNest', 'Off'],
         'RetreatToNest': ['LandOnNest', 'Off'],
         'LandOnNest': ['Roost', 'Off']}
        self.index = index
        self.nest = nest
        self.target = None
        self.isBaronInterested = False
        self.collSphere = None
        self.suit = Suit.Suit()
        d = SuitDNA.SuitDNA()
        d.newSuit(suitDnaName)
        self.suit.setDNA(d)
        self.suit.reparentTo(render)
        swapAvatarShadowPlacer(self.suit, 'RobberBaron-%sShadowPlacer' % index)
        self.suit.setPos(self.nest.getPos(render))
        self.suit.setHpr(-180, 0, 0)
        self.suit.stash()
        self.prop = None
        self.attachPropeller()
        head = self.suit.find('**/joint_head')
        self.interestConeOrigin = self.nest.attachNewNode('fakeHeadNodePath')
        self.interestConeOrigin.setPos(render, head.getPos(render) + Vec3(0, Globals.RobberBaron.InterestConeOffset, 0))
        self.attackTargetPos = None
        self.startOfRetreatToSkyPos = None
        pathModel = CogdoUtil.loadFlyingModel('RobberBaronPaths')
        self.chargeUpMotionPath = Mopath.Mopath(name='chargeUpMotionPath-%i' % self.index)
        self.chargeUpMotionPath.loadNodePath(pathModel.find('**/charge_path'))
        self.retreatToSkyMotionPath = Mopath.Mopath(name='retreatToSkyMotionPath-%i' % self.index)
        self.retreatToSkyMotionPath.loadNodePath(pathModel.find('**/retreat_path'))
        audioMgr = base.cogdoGameAudioMgr
        self._screamSfx = audioMgr.createSfx('RobberBaronScream', self.suit)
        self.initIntervals()
        self.suit.nametag3d.stash()
        self.suit.nametag.destroy()
        return

    def attachPropeller(self):
        if self.prop == None:
            self.prop = BattleProps.globalPropPool.getProp('propeller')
            head = self.suit.find('**/joint_head')
            self.prop.reparentTo(head)
        return

    def detachPropeller(self):
        if self.prop:
            self.prop.cleanup()
            self.prop.removeNode()
            self.prop = None
        return

    def _getAnimationIval(self, animName, startFrame = 0, endFrame = None, duration = 1):
        if endFrame == None:
            self.suit.getNumFrames(animName) - 1
        frames = endFrame - startFrame
        frameRate = self.suit.getFrameRate(animName)
        newRate = frames / duration
        playRate = newRate / frameRate
        ival = Sequence(ActorInterval(self.suit, animName, playRate=playRate))
        return ival

    def initIntervals(self):
        dur = Globals.RobberBaron.LiftOffTime
        nestPos = self.nest.getPos(render)
        airPos = nestPos + Vec3(0.0, 0.0, Globals.RobberBaron.LiftOffHeight)
        self.takeOffSeq = Sequence(Parallel(Sequence(Wait(dur * 0.6), LerpPosInterval(self.suit, dur * 0.4, startPos=nestPos, pos=airPos, blendType='easeInOut'))), Wait(1.5), Func(self.request, 'next'), name='%s.takeOffSeq-%i' % (self.__class__.__name__, self.index))
        self.landOnNestPosLerp = LerpPosInterval(self.suit, 1.0, startPos=airPos, pos=nestPos, blendType='easeInOut')
        self.landingSeq = Sequence(Func(self.updateLandOnNestPosLerp), Parallel(self.landOnNestPosLerp), Func(self.request, 'next'), name='%s.landingSeq-%i' % (self.__class__.__name__, self.index))
        dur = Globals.RobberBaron.ChargeUpTime
        self.chargeUpPosLerp = LerpFunc(self.moveAlongChargeUpMopathFunc, fromData=0.0, toData=self.chargeUpMotionPath.getMaxT(), duration=dur, blendType='easeInOut')
        self.chargeUpAttackSeq = Sequence(Func(self.updateChargeUpPosLerp), self.chargeUpPosLerp, Func(self.request, 'next'), name='%s.chargeUpAttackSeq-%i' % (self.__class__.__name__, self.index))
        dur = Globals.RobberBaron.RetreatToNestTime
        self.retreatToNestPosLerp = LerpPosInterval(self.suit, dur, startPos=Vec3(0, 0, 0), pos=airPos, blendType='easeInOut')
        self.retreatToNestSeq = Sequence(Func(self.updateRetreatToNestPosLerp), self.retreatToNestPosLerp, Func(self.request, 'next'), name='%s.retreatToNestSeq-%i' % (self.__class__.__name__, self.index))
        dur = Globals.RobberBaron.RetreatToSkyTime
        self.retreatToSkyPosLerp = LerpFunc(self.moveAlongRetreatMopathFunc, fromData=0.0, toData=self.retreatToSkyMotionPath.getMaxT(), duration=dur, blendType='easeOut')
        self.retreatToSkySeq = Sequence(Func(self.updateRetreatToSkyPosLerp), self.retreatToSkyPosLerp, Func(self.request, 'next'), name='%s.retreatToSkySeq-%i' % (self.__class__.__name__, self.index))
        dur = Globals.RobberBaron.PreAttackTime
        self.preAttackLerpXY = LerpFunc(self.updateAttackXY, fromData=0.0, toData=1.0, duration=dur)
        self.preAttackLerpZ = LerpFunc(self.updateAttackZ, fromData=0.0, toData=1.0, duration=dur, blendType='easeOut')
        dur = Globals.RobberBaron.PostAttackTime
        self.postAttackPosLerp = LerpPosInterval(self.suit, dur, startPos=Vec3(0, 0, 0), pos=Vec3(0, 0, 0))
        self.attackSeq = Sequence(Parallel(self.preAttackLerpXY, self.preAttackLerpZ), Func(self.updatePostAttackPosLerp), self.postAttackPosLerp, Func(self.request, 'next'), name='%s.attackSeq-%i' % (self.__class__.__name__, self.index))
        dur = Globals.RobberBaron.CooldownTime
        self.cooldownSeq = Sequence(Wait(dur), Func(self.request, 'next'), name='%s.cooldownSeq-%i' % (self.__class__.__name__, self.index))
        self.propTrack = Sequence(ActorInterval(self.prop, 'propeller', startFrame=0, endFrame=14))
        self.hoverOverNestSeq = Sequence(ActorInterval(self.suit, 'landing', startFrame=10, endFrame=20, playRate=0.5), ActorInterval(self.suit, 'landing', startFrame=20, endFrame=10, playRate=0.5))

    def initCollision(self):
        self.collSphere = CollisionSphere(0, 0, 0, 0)
        self.collSphere.setTangible(0)
        self.collNode = CollisionNode('%s-%s' % (self.CollSphereName, self.index))
        self.collNode.setIntoCollideMask(ToontownGlobals.WallBitmask)
        self.collNode.addSolid(self.collSphere)
        self.collNodePath = self.suit.attachNewNode(self.collNode)
        self.collNodePath.hide()
        self.accept('enter%s-%s' % (self.CollSphereName, self.index), self.handleEnterSphere)
        self.setCollSphereToNest()

    def getInterestConeLength(self):
        return Globals.RobberBaron.InterestConeLength + Globals.RobberBaron.InterestConeOffset

    def isToonInView(self, toon):
        distanceThreshold = self.getInterestConeLength()
        angleThreshold = Globals.RobberBaron.InterestConeAngle
        toonPos = toon.getPos(render)
        nestPos = self.nest.getPos(render)
        distance = toon.getDistance(self.interestConeOrigin)
        if distance > distanceThreshold:
            return False
        if toonPos[1] > nestPos[1]:
            return False
        a = toon.getPos(render) - self.interestConeOrigin.getPos(render)
        a.normalize()
        b = Vec3(0, -1, 0)
        dotProduct = a.dot(b)
        angle = math.degrees(math.acos(dotProduct))
        if angle <= angleThreshold / 2.0:
            return True
        else:
            return False

    def update(self, dt, localPlayer):
        if Globals.Dev.NoRobberBaronAttacks:
            return
        inView = self.isToonInView(localPlayer.toon)
        if inView and not self.isBaronInterested:
            self.handleEnterInterest()
        elif inView and self.isBaronInterested:
            self.handleAgainInterest()
        elif not inView and self.isBaronInterested:
            self.handleExitInterest()

    def updateLockOnTask(self):
        dt = globalClock.getDt()
        targetPos = self.target.getPos(render)
        suitPos = self.suit.getPos(render)
        nestPos = self.nest.getPos(render)
        attackPos = Vec3(targetPos)
        attackPos[1] = nestPos[1] + Globals.RobberBaron.LockOnDistanceFromNest
        attackPos[2] += Globals.RobberBaron.VerticalOffset
        if attackPos[2] < nestPos[2]:
            attackPos[2] = nestPos[2]
        attackChangeVec = (attackPos - suitPos) * Globals.RobberBaron.LockOnSpeed
        self.suit.setPos(suitPos + attackChangeVec * dt)
        return Task.cont

    def updateAttackXY(self, value):
        if Globals.RobberBaron.BaronAttackShouldXCorrect:
            x = self.readyToAttackPos.getX() + (self.attackTargetPos.getX() - self.readyToAttackPos.getX()) * value
            self.suit.setX(x)
        y = self.readyToAttackPos.getY() + (self.attackTargetPos.getY() - self.readyToAttackPos.getY()) * value
        self.suit.setY(y)

    def updateAttackZ(self, value):
        z = self.readyToAttackPos.getZ() + (self.attackTargetPos.getZ() - self.readyToAttackPos.getZ()) * value
        self.suit.setZ(z)

    def moveAlongChargeUpMopathFunc(self, value):
        self.chargeUpMotionPath.goTo(self.suit, value)
        self.suit.setPos(self.suit.getPos() + self.startOfChargeUpPos)

    def moveAlongRetreatMopathFunc(self, value):
        self.retreatToSkyMotionPath.goTo(self.suit, value)
        self.suit.setPos(self.suit.getPos() + self.startOfRetreatToSkyPos)

    def updateChargeUpPosLerp(self):
        self.startOfChargeUpPos = self.suit.getPos(render)

    def updateLandOnNestPosLerp(self):
        self.landOnNestPosLerp.setStartPos(self.suit.getPos())

    def updateRetreatToNestPosLerp(self):
        self.retreatToNestPosLerp.setStartPos(self.suit.getPos())

    def updateRetreatToSkyPosLerp(self):
        self.startOfRetreatToSkyPos = self.suit.getPos(render)

    def updatePostAttackPosLerp(self):
        suitPos = self.suit.getPos(render)
        finalPos = suitPos + Vec3(0, -Globals.RobberBaron.PostAttackLength, 0)
        self.postAttackPosLerp.setStartPos(suitPos)
        self.postAttackPosLerp.setEndPos(finalPos)

    def handleEnterSphere(self, collEntry):
        self.notify.debug('handleEnterSphere:%i' % self.index)
        messenger.send(CogdoFlyingRobberBaron.EnterRobberBaron, [self, collEntry])

    def handleEnterInterest(self):
        self.notify.debug('handleEnterInterestColl:%i' % self.index)
        self.isBaronInterested = True
        messenger.send(CogdoFlyingRobberBaron.RequestAddTargetEventName, [self.index])

    def handleAgainInterest(self):
        self.isBaronInterested = True
        messenger.send(CogdoFlyingRobberBaron.RequestAddTargetAgainEventName, [self.index])

    def handleExitInterest(self):
        self.notify.debug('handleExitInterestSphere:%i' % self.index)
        self.isBaronInterested = False
        messenger.send(CogdoFlyingRobberBaron.RequestRemoveTargetEventName, [self.index])

    def hasTarget(self):
        if self.target != None:
            return True
        else:
            return False
        return

    def setTarget(self, toon, elapsedTime = 0.0):
        self.notify.debug('Setting Baron %i to target: %s, elapsed time: %s' % (self.index, toon.getName(), elapsedTime))
        self.target = toon
        if self.state == 'Roost':
            self.request('next', elapsedTime)
        if self.state == 'ChargeUpAttack':
            messenger.send(CogdoFlyingRobberBaron.ChargingToAttackEventName, [self.target.doId])

    def clearTarget(self, elapsedTime = 0.0):
        self.notify.debug('Clearing target from Baron %i, elapsed time: %s' % (self.index, elapsedTime))
        messenger.send(CogdoFlyingRobberBaron.CooldownEventName, [self.target.doId])
        self.target = None
        if self.state in ['LockOnToon']:
            self.request('next', elapsedTime)
        return

    def leaveCooldown(self, elapsedTime = 0.0):
        if self.state in ['Cooldown']:
            self.request('next', elapsedTime)

    def shouldBeInFrame(self):
        if self.state in ['TakeOff', 'LockOnToon', 'ChargeUpAttack']:
            return True
        elif self.state == 'Attack':
            distance = self.suit.getDistance(self.target)
            threshold = Globals.RobberBaron.BaronAndTargetDistCameraTrackThreshold
            suitPos = self.suit.getPos(render)
            targetPos = self.target.getPos(render)
            if distance > threshold and suitPos[1] > targetPos[1]:
                return True
        return False

    def getTarget(self):
        return self.target

    def onstage(self):
        self.suit.unstash()
        self.request('Roost')

    def offstage(self):
        self.suit.stash()
        self.request('Off')

    def gameStart(self, gameStartTime):
        self.gameStartTime = gameStartTime
        self.initCollision()

    def gameEnd(self):
        self.shutdownCollisions()

    def shutdownCollisions(self):
        self.ignoreAll()
        if self.collSphere != None:
            del self.collSphere
            self.collSphere = None
        if self.collNodePath != None:
            self.collNodePath.removeNode()
            del self.collNodePath
            self.collNodePath = None
        if self.collNode != None:
            del self.collNode
            self.collNode = None
        return

    def destroy(self):
        self.request('Off')
        self.detachPropeller()
        del self._screamSfx
        self.suit.cleanup()
        self.suit.removeNode()
        self.suit.delete()
        self.interestConeOrigin.removeNode()
        del self.interestConeOrigin
        self.nest = None
        self.target = None
        taskMgr.remove('updateLockOnTask-%i' % self.index)
        taskMgr.remove('exitLockOnToon-%i' % self.index)
        self.propTrack.clearToInitial()
        del self.propTrack
        del self.chargeUpMotionPath
        del self.retreatToSkyMotionPath
        self.takeOffSeq.clearToInitial()
        del self.takeOffSeq
        del self.landOnNestPosLerp
        self.landingSeq.clearToInitial()
        del self.landingSeq
        del self.chargeUpPosLerp
        self.chargeUpAttackSeq.clearToInitial()
        del self.chargeUpAttackSeq
        del self.retreatToNestPosLerp
        self.retreatToNestSeq.clearToInitial()
        del self.retreatToNestSeq
        del self.retreatToSkyPosLerp
        self.retreatToSkySeq.clearToInitial()
        del self.retreatToSkySeq
        del self.postAttackPosLerp
        self.attackSeq.clearToInitial()
        del self.attackSeq
        self.cooldownSeq.clearToInitial()
        del self.cooldownSeq
        self.hoverOverNestSeq.clearToInitial()
        del self.hoverOverNestSeq
        del self.preAttackLerpXY
        del self.preAttackLerpZ
        return

    def requestNext(self):
        self.request('next')

    def setCollSphereToNest(self):
        if hasattr(self, 'collSphere') and self.collSphere is not None:
            radius = Globals.RobberBaron.OnNestDamageSphereRadius
            self.collSphere.setCenter(Point3(0.0, -Globals.Level.LaffPowerupNestOffset[1], self.suit.getHeight() / 2.0))
            self.collSphere.setRadius(radius)
        return

    def setCollSphereToTargeting(self):
        if hasattr(self, 'collSphere') and self.collSphere is not None:
            radius = Globals.RobberBaron.DamageSphereRadius
            self.collSphere.setCenter(Point3(0, 0, radius * 2))
            self.collSphere.setRadius(radius)
        return

    def enterRoost(self):
        self.notify.info("enter%s: '%s' -> '%s'" % (self.newState, self.oldState, self.newState))
        self.hoverOverNestSeq.loop()
        self.propTrack.loop()
        self.setCollSphereToNest()

    def filterRoost(self, request, args):
        self.notify.debug("filter%s( '%s', '%s' )" % (self.state, request, args))
        if request == self.state:
            return None
        elif request == 'next':
            return 'TakeOff'
        else:
            return self.defaultFilter(request, args)
        return None

    def exitRoost(self):
        self.notify.debug("exit%s: '%s' -> '%s'" % (self.oldState, self.oldState, self.newState))
        self.hoverOverNestSeq.pause()
        self.setCollSphereToTargeting()

    def enterTakeOff(self, elapsedTime = 0.0):
        self.notify.info("enter%s: '%s' -> '%s', elapsedTime:%s" % (self.newState,
         self.oldState,
         self.newState,
         elapsedTime))
        self.takeOffSeq.start(elapsedTime)
        self.hoverOverNestSeq.loop()

    def filterTakeOff(self, request, args):
        self.notify.debug("filter%s( '%s', '%s' )" % (self.state, request, args))
        if request == self.state:
            return None
        elif request == 'next':
            if self.hasTarget():
                return 'LockOnToon'
            else:
                return 'LandOnNest'
        else:
            return self.defaultFilter(request, args)
        return None

    def exitTakeOff(self):
        self.notify.debug("exit%s: '%s' -> '%s'" % (self.oldState, self.oldState, self.newState))
        self.takeOffSeq.clearToInitial()
        self.hoverOverNestSeq.pause()

    def enterLockOnToon(self, elapsedTime = 0.0):
        self.notify.info("enter%s: '%s' -> '%s', elapsedTime:%s" % (self.newState,
         self.oldState,
         self.newState,
         elapsedTime))
        taskName = 'updateLockOnTask-%i' % self.index
        taskMgr.add(self.updateLockOnTask, taskName, 45, extraArgs=[])
        messenger.send(CogdoFlyingRobberBaron.LockOnToonEventName, [self.target.doId])
        range = self.target.getDistance(self.interestConeOrigin) / self.getInterestConeLength()
        range = clamp(range, 0.0, 1.0)
        dur = Globals.RobberBaron.LockOnTime
        if self.oldState == 'TakeOff':
            dur *= range
        else:
            dur += Globals.RobberBaron.ExtraPostCooldownTime
        taskName = 'exitLockOnToon-%i' % self.index
        taskMgr.doMethodLater(dur, self.requestNext, taskName, extraArgs=[])

    def filterLockOnToon(self, request, args):
        self.notify.debug("filter%s( '%s', '%s' )" % (self.state, request, args))
        if request == self.state:
            return None
        elif request == 'next':
            if self.hasTarget():
                return 'ChargeUpAttack'
            else:
                return 'RetreatToNest'
        else:
            return self.defaultFilter(request, args)
        return None

    def exitLockOnToon(self):
        self.notify.debug("exit%s: '%s' -> '%s'" % (self.oldState, self.oldState, self.newState))
        taskMgr.remove('updateLockOnTask-%i' % self.index)
        taskMgr.remove('exitLockOnToon-%i' % self.index)

    def enterChargeUpAttack(self, elapsedTime = 0.0):
        self.notify.info("enter%s: '%s' -> '%s', elapsedTime:%s" % (self.newState,
         self.oldState,
         self.newState,
         elapsedTime))
        self.chargeUpAttackSeq.start(elapsedTime)
        messenger.send(CogdoFlyingRobberBaron.ChargingToAttackEventName, [self.target.doId])

    def filterChargeUpAttack(self, request, args):
        self.notify.debug("filter%s( '%s', '%s' )" % (self.state, request, args))
        if request == self.state:
            return None
        elif request == 'next':
            if self.hasTarget():
                return 'Attack'
            else:
                return 'RetreatToNest'
        else:
            return self.defaultFilter(request, args)
        return None

    def exitChargeUpAttack(self):
        self.notify.debug("exit%s: '%s' -> '%s'" % (self.oldState, self.oldState, self.newState))
        self.chargeUpAttackSeq.clearToInitial()

    def enterAttack(self, elapsedTime = 0.0):
        self.notify.info("enter%s: '%s' -> '%s', elapsedTime:%s" % (self.newState,
         self.oldState,
         self.newState,
         elapsedTime))
        self.attackTargetPos = self.target.getPos(render)
        targetState = self.target.animFSM.getCurrentState().getName()
        self._screamSfx.play()
        if targetState == 'jumpAirborne':
            self.attackTargetPos[2] += Globals.RobberBaron.VerticalOffset
        else:
            self.attackTargetPos[2] += Globals.RobberBaron.PlatformVerticalOffset
        self.readyToAttackPos = self.suit.getPos(render)
        self.attackSeq.start(elapsedTime)

    def filterAttack(self, request, args):
        self.notify.debug("filter%s( '%s', '%s' )" % (self.state, request, args))
        if request == self.state:
            return None
        elif request == 'next':
            return 'RetreatToSky'
        else:
            return self.defaultFilter(request, args)
        return None

    def exitAttack(self):
        self.notify.debug("exit%s: '%s' -> '%s'" % (self.oldState, self.oldState, self.newState))
        self.attackSeq.clearToInitial()
        taskMgr.remove('updateAttackPosTask-%i' % self.index)

    def enterRetreatToSky(self, elapsedTime = 0.0):
        self.notify.info("enter%s: '%s' -> '%s', elapsedTime:%s" % (self.newState,
         self.oldState,
         self.newState,
         elapsedTime))
        self.retreatToSkySeq.start(elapsedTime)

    def filterRetreatToSky(self, request, args):
        self.notify.debug("filter%s( '%s', '%s' )" % (self.state, request, args))
        if request == self.state:
            return None
        elif request == 'next':
            return 'Cooldown'
        else:
            return self.defaultFilter(request, args)
        return None

    def exitRetreatToSky(self):
        self.notify.debug("exit%s: '%s' -> '%s'" % (self.oldState, self.oldState, self.newState))
        self.retreatToSkySeq.clearToInitial()

    def enterCooldown(self):
        if self.target != None:
            messenger.send(CogdoFlyingRobberBaron.CooldownEventName, [self.target.doId])
        self.suit.stash()
        self.notify.info("enter%s: '%s' -> '%s'" % (self.newState, self.oldState, self.newState))
        return

    def filterCooldown(self, request, args):
        self.notify.debug("filter%s( '%s', '%s' )" % (self.state, request, args))
        if request == self.state:
            return None
        elif request == 'next':
            if self.hasTarget():
                return 'LockOnToon'
            else:
                return 'LandOnNest'
        else:
            return self.defaultFilter(request, args)
        return None

    def exitCooldown(self):
        self.notify.debug("exit%s: '%s' -> '%s'" % (self.oldState, self.oldState, self.newState))
        self.suit.unstash()
        self.cooldownSeq.clearToInitial()
        if self.newState != 'Off':
            heightOffNest = Globals.RobberBaron.PostCooldownHeightOffNest
            nestPos = self.nest.getPos(render)
            if self.newState in ['LandOnNest']:
                self.suit.setPos(nestPos + Vec3(0, 0, heightOffNest))
            else:
                targetPos = self.target.getPos(render)
                attackPos = Vec3(targetPos)
                attackPos[1] = nestPos[1]
                attackPos[2] = nestPos[2] + heightOffNest
                self.suit.setPos(attackPos)

    def enterRetreatToNest(self, elapsedTime = 0.0):
        self.notify.info("enter%s: '%s' -> '%s', elapsedTime:%s" % (self.newState,
         self.oldState,
         self.newState,
         elapsedTime))
        self.retreatToNestSeq.start(elapsedTime)

    def filterRetreatToNest(self, request, args):
        self.notify.debug("filter%s( '%s', '%s' )" % (self.state, request, args))
        if request == self.state:
            return None
        elif request == 'next':
            return 'LandOnNest'
        else:
            return self.defaultFilter(request, args)
        return None

    def exitRetreatToNest(self):
        self.retreatToNestSeq.clearToInitial()

    def enterLandOnNest(self, elapsedTime = 0.0):
        self.notify.info("enter%s: '%s' -> '%s', elapsedTime:%s" % (self.newState,
         self.oldState,
         self.newState,
         elapsedTime))
        self.landingSeq.start(elapsedTime)

    def filterLandOnNest(self, request, args):
        self.notify.debug("filter%s( '%s', '%s' )" % (self.state, request, args))
        if request == self.state:
            return None
        elif request == 'next':
            if self.hasTarget():
                return 'TakeOff'
            else:
                return 'Roost'
        else:
            return self.defaultFilter(request, args)
        return None

    def exitLandOnNest(self):
        self.landingSeq.clearToInitial()