Пример #1
0
    def doMoveTrack(self,
                    path,
                    turnToFirstWP=True,
                    speed=3.0,
                    doWalkAnims=True):
        self.goon.d_doMoveTrack(path, turnToFirstWP, speed, doWalkAnims)

        self.clearMoveTrack()

        self.moveTrack = CIGlobals.getMoveIvalFromPath(self.goon, path, speed)

        if turnToFirstWP:
            turnHpr = CIGlobals.getHeadsUpAngle(self.goon, path[1])
            turnHpr[0] = PythonUtil.fitDestAngle2Src(self.goon.getHpr()[0],
                                                     turnHpr[0])
            turnDist = CIGlobals.getHeadsUpDistance(self.goon, path[1])
            self.moveTrack.insert(
                1,
                LerpHprInterval(self.goon,
                                duration=turnDist / (speed * 30),
                                hpr=turnHpr))

        self.moveTrack.append(Func(self._moveTrackFinished))
        self.moveTrack.start()
        self.moving = True
 def rollBossToPoint(self, fromPos, fromHpr, toPos, toHpr, reverse):
     vector = Vec3(toPos - fromPos)
     distance = vector.length()
     if toHpr == None:
         mat = Mat3(0, 0, 0, 0, 0, 0, 0, 0, 0)
         headsUp(mat, vector, CSDefault)
         scale = VBase3(0, 0, 0)
         shear = VBase3(0, 0, 0)
         toHpr = VBase3(0, 0, 0)
         decomposeMatrix(mat, scale, shear, toHpr, CSDefault)
     if fromHpr:
         newH = PythonUtil.fitDestAngle2Src(fromHpr[0], toHpr[0])
         toHpr = VBase3(newH, 0, 0)
     else:
         fromHpr = toHpr
     turnTime = abs(toHpr[0] - fromHpr[0]) / ToontownGlobals.BossCogTurnSpeed
     if toHpr[0] < fromHpr[0]:
         leftRate = ToontownGlobals.BossCogTreadSpeed
     else:
         leftRate = -ToontownGlobals.BossCogTreadSpeed
     if reverse:
         rollTreadRate = -ToontownGlobals.BossCogTreadSpeed
     else:
         rollTreadRate = ToontownGlobals.BossCogTreadSpeed
     rollTime = distance / ToontownGlobals.BossCogRollSpeed
     deltaPos = toPos - fromPos
     track = Sequence(Func(self.setPos, fromPos), Func(self.headsUp, toPos), Parallel(self.hprInterval(turnTime, toHpr, fromHpr), self.rollLeftTreads(turnTime, leftRate), self.rollRightTreads(turnTime, -leftRate)), Parallel(LerpFunctionInterval(self.rollBoss, duration=rollTime, extraArgs=[fromPos, deltaPos]), self.rollLeftTreads(rollTime, rollTreadRate), self.rollRightTreads(rollTime, rollTreadRate)))
     return (track, toHpr)
Пример #3
0
    def moveCamera(self, seatIndex):
        self.oldCameraPos = camera.getPos()
        self.oldCameraHpr = camera.getHpr()
        camera.wrtReparentTo(self.picnicTable)
        heading = PythonUtil.fitDestAngle2Src(camera.getH(), 90)
        #Need to check the seat index so the cameras *down
        #is towards the player so he is not facing his own character
        #rather he feels he is a bit above him
        if seatIndex < 3:
            self.cameraBoardTrack = LerpPosHprInterval(camera, 2.0,
                                                       Point3(0, 0, 17),
                                                       Point3(0, -90, 0))
        else:
            #needed for camera orientation
            #If test is not here, the camera may often flip around
            #spinning ~340 degrees to the destination
            #instead of turning the 20 degrees towards the table
            if (camera.getH() < 0):  #(turned left)
                self.cameraBoardTrack = LerpPosHprInterval(
                    camera, 2.0, Point3(0, 0, 17), Point3(-180, -90, 0))

            else:  #(turned right)
                self.cameraBoardTrack = LerpPosHprInterval(
                    camera, 2.0, Point3(0, 0, 17), Point3(180, -90, 0))

        self.cameraBoardTrack.start()
 def generateToonMoveTrack(self, toon):
     node = NodePath('tempNode')
     displacement = Vec3(toon.getPos(render) - self.getPos(render))
     displacement.setZ(0)
     displacement.normalize()
     movieDistance = self.movieNode.getDistance(self.rotateNode)
     displacement *= movieDistance
     node.reparentTo(render)
     node.setPos(displacement + self.getPos(render))
     node.lookAt(self)
     heading = PythonUtil.fitDestAngle2Src(toon.getH(render),
                                           node.getH(render))
     hpr = toon.getHpr(render)
     hpr.setX(heading)
     finalX = node.getX(render)
     finalY = node.getY(render)
     finalZ = node.getZ(render)
     node.removeNode()
     toonTrack = Sequence(
         Parallel(
             ActorInterval(toon, 'walk', loop=True, duration=1),
             Parallel(
                 LerpPosInterval(toon,
                                 1.0,
                                 Point3(finalX, finalY, toon.getZ(render)),
                                 fluid=True,
                                 bakeInStart=False)),
             LerpHprInterval(toon, 1.0, hpr=hpr)),
         Func(toon.loop, 'neutral'))
     return toonTrack
 def generateToonMoveTrack(self, toon):
     node = NodePath("tempNode")
     displacement = Vec3(toon.getPos(render) - self.getPos(render))
     displacement.setZ(0)
     displacement.normalize()
     movieDistance = self.movieNode.getDistance(self.rotateNode)
     displacement *= movieDistance
     node.reparentTo(render)
     node.setPos(displacement + self.getPos(render))
     node.lookAt(self)
     heading = PythonUtil.fitDestAngle2Src(toon.getH(render), node.getH(render))
     hpr = toon.getHpr(render)
     hpr.setX(heading)
     finalX = node.getX(render)
     finalY = node.getY(render)
     finalZ = node.getZ(render)
     node.removeNode()
     toonTrack = Sequence(
         Parallel(
             ActorInterval(toon, "walk", loop=True, duration=1),
             Parallel(
                 LerpPosInterval(toon, 1.0, Point3(finalX, finalY, toon.getZ(render)), fluid=True, bakeInStart=False)
             ),
             LerpHprInterval(toon, 1.0, hpr=hpr),
         ),
         Func(toon.loop, "neutral"),
     )
     return toonTrack
Пример #6
0
 def generateToonMoveTrack(self):
     hpr = self.movieNode.getHpr(render)
     heading = PythonUtil.fitDestAngle2Src(self.av.getH(render), hpr[0])
     hpr.setX(heading)
     self.av.setAnimState('run', 1.0)
     toonTrack = Sequence(Wait(0.5), Parallel(LerpPosInterval(self.av, 1.0, Point3(self.movieNode.getX(self.avParent), self.movieNode.getY(self.avParent), 0)), LerpHprInterval(self.av, 1.0, hpr=hpr, other=render)), Func(self.av.loop, 'neutral'))
     return toonTrack
Пример #7
0
 def __chooseTarget(self, extraDelay=0):
     direction = self.__chooseDirection()
     if direction is None:
         self.target = None
         self.arrivalTime = None
         self.b_destroyGoon()
         return
     heading, dist = direction
     dist = min(dist, self.legLength)
     targetH = PythonUtil.reduceAngle(self.getH() + heading)
     origH = self.getH()
     h = PythonUtil.fitDestAngle2Src(origH, targetH)
     delta = abs(h - origH)
     turnTime = delta / (self.velocity * 5)
     walkTime = dist / self.velocity
     self.setH(targetH)
     self.target = self.boss.scene.getRelativePoint(
         self, Point3(0, dist, 0))
     self.departureTime = globalClock.getFrameTime()
     self.arrivalTime = self.departureTime + turnTime + walkTime + extraDelay
     self.d_setTarget(
         self.target[0],
         self.target[1],
         h,
         globalClockDelta.localToNetworkTime(
             self.arrivalTime))
     return
 def generateToonMoveTrack(self):
     hpr = self.movieNode.getHpr(render)
     heading = PythonUtil.fitDestAngle2Src(self.av.getH(render), hpr[0])
     hpr.setX(heading)
     self.av.setAnimState('run', 1.0)
     toonTrack = Sequence(Wait(0.5), Parallel(LerpPosInterval(self.av, 1.0, Point3(self.movieNode.getX(self.avParent), self.movieNode.getY(self.avParent), 0)), LerpHprInterval(self.av, 1.0, hpr=hpr, other=render)), Func(self.av.loop, 'neutral'))
     return toonTrack
 def enterBoarding(self, nodePath, side):
     camera.wrtReparentTo(nodePath)
     heading = PythonUtil.fitDestAngle2Src(camera.getH(nodePath), 90 * side)
     self.cameraBoardTrack = LerpPosHprInterval(
         camera, 1.5, Point3(14.4072 * side, 0, 3.8666999999999998), Point3(heading, -15, 0)
     )
     self.cameraBoardTrack.start()
Пример #10
0
    def __chooseTarget(self, extraDelay = 0):
        # Chooses a random point to walk towards.
        direction = self.__chooseDirection()
        if direction == None:
            # No place to go; just blow up.
            self.target = None
            self.arrivalTime = None
            self.b_destroyGoon()
            return

        heading, dist = direction
        dist = min(dist, self.legLength)
        targetH = PythonUtil.reduceAngle(self.getH() + heading)

        # How long will it take to rotate to position?
        origH = self.getH()
        h = PythonUtil.fitDestAngle2Src(origH, targetH)
        delta = abs(h - origH)
        turnTime = delta / (self.velocity * 5)

        # And how long will it take to walk to position?
        walkTime = dist / self.velocity

        self.setH(targetH)
        self.target = self.boss.scene.getRelativePoint(self, Point3(0, dist, 0))

        self.departureTime = globalClock.getFrameTime()
        self.arrivalTime = self.departureTime + turnTime + walkTime + extraDelay

        self.d_setTarget(self.target[0], self.target[1], h,
                         globalClockDelta.localToNetworkTime(self.arrivalTime))
 def enterBoarding(self, nodePath):
     camera.wrtReparentTo(nodePath)
     heading = PythonUtil.fitDestAngle2Src(camera.getH(nodePath), 180)
     self.cameraBoardTrack = LerpPosHprInterval(camera, 1.5,
                                                Point3(0, 18, 8),
                                                Point3(heading, -10, 0))
     self.cameraBoardTrack.start()
 def __startWalk(self):
     self.__stopWalk()
     if self.target:
         now = globalClock.getFrameTime()
         availableTime = self.arrivalTime - now
         if availableTime > 0:
             origH = self.getH()
             h = PythonUtil.fitDestAngle2Src(origH, self.targetH)
             delta = abs(h - origH)
             turnTime = delta / (self.velocity * 5)
             dist = Vec3(self.target - self.getPos()).length()
             walkTime = dist / self.velocity
             denom = turnTime + walkTime
             if denom != 0:
                 timeCompress = availableTime / denom
                 self.walkTrack = Sequence(
                     self.hprInterval(
                         turnTime *
                         timeCompress,
                         VBase3(
                             h,
                             0,
                             0)),
                     self.posInterval(
                         walkTime *
                         timeCompress,
                         self.target))
                 self.walkTrack.start()
         else:
             self.setPos(self.target)
             self.setH(self.targetH)
Пример #13
0
 def rollBossToPoint(self, fromPos, fromHpr, toPos, toHpr, reverse):
     vector = Vec3(toPos - fromPos)
     distance = vector.length()
     if toHpr == None:
         mat = Mat3(0, 0, 0, 0, 0, 0, 0, 0, 0)
         headsUp(mat, vector, CSDefault)
         scale = VBase3(0, 0, 0)
         shear = VBase3(0, 0, 0)
         toHpr = VBase3(0, 0, 0)
         decomposeMatrix(mat, scale, shear, toHpr, CSDefault)
     if fromHpr:
         newH = PythonUtil.fitDestAngle2Src(fromHpr[0], toHpr[0])
         toHpr = VBase3(newH, 0, 0)
     else:
         fromHpr = toHpr
     turnTime = abs(toHpr[0] - fromHpr[0]) / ToontownGlobals.BossCogTurnSpeed
     if toHpr[0] < fromHpr[0]:
         leftRate = ToontownGlobals.BossCogTreadSpeed
     else:
         leftRate = -ToontownGlobals.BossCogTreadSpeed
     if reverse:
         rollTreadRate = -ToontownGlobals.BossCogTreadSpeed
     else:
         rollTreadRate = ToontownGlobals.BossCogTreadSpeed
     rollTime = distance / ToontownGlobals.BossCogRollSpeed
     deltaPos = toPos - fromPos
     track = Sequence(Func(self.setPos, fromPos), Func(self.headsUp, toPos), Parallel(self.hprInterval(turnTime, toHpr, fromHpr), self.rollLeftTreads(turnTime, leftRate), self.rollRightTreads(turnTime, -leftRate)), Parallel(LerpFunctionInterval(self.rollBoss, duration=rollTime, extraArgs=[fromPos, deltaPos]), self.rollLeftTreads(rollTime, rollTreadRate), self.rollRightTreads(rollTime, rollTreadRate)))
     return (track, toHpr)
Пример #14
0
    def __startWalk(self):
        # Generate an interval to walk the goon to his target square
        # by the specified time.
        self.__stopWalk()

        if self.target:
            now = globalClock.getFrameTime()
            availableTime = self.arrivalTime - now
            if availableTime > 0:
                # How long will it take to rotate to position?
                origH = self.getH()
                h = PythonUtil.fitDestAngle2Src(origH, self.targetH)
                delta = abs(h - origH)
                turnTime = delta / (self.velocity * 5)

                # And how long will it take to walk to position?
                dist = Vec3(self.target - self.getPos()).length()
                walkTime = dist / self.velocity

                denom = turnTime + walkTime
                if denom != 0:
                    # Fit that within our available time.
                    timeCompress = availableTime / denom

                    self.walkTrack = Sequence(
                        self.hprInterval(turnTime * timeCompress,
                                         VBase3(h, 0, 0)),
                        self.posInterval(walkTime * timeCompress, self.target))
                    self.walkTrack.start()
            else:
                self.setPos(self.target)
                self.setH(self.targetH)
 def enterBoarding(self, nodePath):
     base.camera.wrtReparentTo(nodePath)
     if self.reverseBoardingCamera:
         heading = PythonUtil.fitDestAngle2Src(base.camera.getH(nodePath), 180)
         self.cameraBoardTrack = LerpPosHprInterval(base.camera, 1.5, Point3(0, 18, 8), Point3(heading, -10, 0))
     else:
         self.cameraBoardTrack = LerpPosHprInterval(base.camera, 1.5, Point3(0, -16, 5.5), Point3(0, 0, 0))
     self.cameraBoardTrack.start()
Пример #16
0
 def enterBoarding(self, nodePath, side):
     camera.wrtReparentTo(nodePath)
     heading = PythonUtil.fitDestAngle2Src(camera.getH(nodePath), 90 * side)
     self.cameraBoardTrack = LerpPosHprInterval(
         camera, 1.5, Point3(14.4072 * side, 0, 3.8667),
         Point3(heading, -15, 0))
     self.cameraBoardTrack.start()
     return None
Пример #17
0
 def getJumpHpr(av=av, node=self.tablecloth):
     hpr = self.seats[seatIndex].getHpr(av.getParent())
     #if(seatIndex < 2):
     #hpr.setX( hpr.getX() + 180)
     #else:
     #    hpr.setX( hpr.getX() )
     angle = PythonUtil.fitDestAngle2Src(av.getH(), hpr.getX())
     hpr.setX(angle)
     return hpr
Пример #18
0
    def doDirectedAttack(self, avId, attackCode):
        toon = base.cr.doId2do.get(avId)
        if toon:
            gearRoot = self.rotateNode.attachNewNode('gearRoot')
            gearRoot.setZ(10)
            gearRoot.setTag('attackCode', str(attackCode))
            gearModel = self.getGearFrisbee()
            gearModel.setScale(0.2)
            gearRoot.headsUp(toon)
            toToonH = PythonUtil.fitDestAngle2Src(0, gearRoot.getH() + 180)
            gearRoot.lookAt(toon)
            neutral = 'Fb_neutral'
            if not self.twoFaced:
                neutral = 'Ff_neutral'
            gearTrack = Parallel()
            for i in range(4):
                node = gearRoot.attachNewNode(str(i))
                node.hide()
                node.setPos(0, 5.85, 4.0)
                gear = gearModel.instanceTo(node)
                x = random.uniform(-5, 5)
                z = random.uniform(-3, 3)
                h = random.uniform(-720, 720)
                gearTrack.append(
                    Sequence(
                        Wait(i * 0.15), Func(node.show),
                        Parallel(
                            node.posInterval(1, Point3(x, 50, z), fluid=1),
                            node.hprInterval(1, VBase3(h, 0, 0), fluid=1)),
                        Func(node.detachNode)))

            if not self.raised:
                neutral1Anim = self.getAnim('down2Up')
                self.raised = 1
            else:
                neutral1Anim = ActorInterval(self, neutral, startFrame=48)
            throwAnim = self.getAnim('throw')
            neutral2Anim = ActorInterval(self, neutral)
            extraAnim = Sequence()
            if attackCode == ToontownGlobals.BossCogSlowDirectedAttack:
                extraAnim = ActorInterval(self, neutral)
            seq = Sequence(
                ParallelEndTogether(
                    self.pelvis.hprInterval(1, VBase3(toToonH, 0, 0)),
                    neutral1Anim), extraAnim,
                Parallel(
                    Sequence(Wait(0.19), gearTrack, Func(gearRoot.detachNode),
                             self.pelvis.hprInterval(0.2, VBase3(0, 0, 0))),
                    Sequence(
                        Func(
                            self.setChatAbsolute,
                            random.choice(TTLocalizer.DirectedAttackBossTaunts[
                                self.dna.dept]) % {'toon': toon.getName()},
                            CFSpeech | CFTimeout), throwAnim, neutral2Anim)))
            self.doAnimate(seq, now=1, raised=1)
 def moveCamera(self, seatIndex):
     self.oldCameraPos = camera.getPos()
     self.oldCameraHpr = camera.getHpr()
     camera.wrtReparentTo(self.picnicTable)
     heading = PythonUtil.fitDestAngle2Src(camera.getH(), 90)
     if seatIndex < 3:
         self.cameraBoardTrack = LerpPosHprInterval(camera, 2.0, Point3(0, 0, 17), Point3(0, -90, 0))
     elif camera.getH() < 0:
         self.cameraBoardTrack = LerpPosHprInterval(camera, 2.0, Point3(0, 0, 17), Point3(-180, -90, 0))
     else:
         self.cameraBoardTrack = LerpPosHprInterval(camera, 2.0, Point3(0, 0, 17), Point3(180, -90, 0))
     self.cameraBoardTrack.start()
 def moveCamera(self, seatIndex):
     self.oldCameraPos = camera.getPos()
     self.oldCameraHpr = camera.getHpr()
     camera.wrtReparentTo(self.picnicTable)
     heading = PythonUtil.fitDestAngle2Src(camera.getH(), 90)
     if seatIndex < 3:
         self.cameraBoardTrack = LerpPosHprInterval(camera, 2.0, Point3(0, 0, 17), Point3(0, -90, 0))
     elif camera.getH() < 0:
         self.cameraBoardTrack = LerpPosHprInterval(camera, 2.0, Point3(0, 0, 17), Point3(-180, -90, 0))
     else:
         self.cameraBoardTrack = LerpPosHprInterval(camera, 2.0, Point3(0, 0, 17), Point3(180, -90, 0))
     self.cameraBoardTrack.start()
 def enterBoarding(self, nodePath):
     base.camera.wrtReparentTo(nodePath)
     if self.reverseBoardingCamera:
         heading = PythonUtil.fitDestAngle2Src(base.camera.getH(nodePath),
                                               180)
         self.cameraBoardTrack = LerpPosHprInterval(base.camera, 1.5,
                                                    Point3(0, 18, 8),
                                                    Point3(heading, -10, 0))
     else:
         self.cameraBoardTrack = LerpPosHprInterval(base.camera, 1.5,
                                                    Point3(0, -16, 5.5),
                                                    Point3(0, 0, 0))
     self.cameraBoardTrack.start()
Пример #22
0
 def getJumpHpr(av=av, node=self.golfKart):
     hpr = Point3(0, 0, 0)
     if hasattr(self, 'golfKart') and self.golfKart:
         hpr = self.golfKart.getHpr(av.getParent())
         if seatIndex < 2:
             hpr.setX(hpr.getX() + 180)
         else:
             hpr.setX(hpr.getX())
         angle = PythonUtil.fitDestAngle2Src(av.getH(), hpr.getX())
         hpr.setX(angle)
     else:
         self.notify.warning('getJumpHpr invalid golfKart, returning (0,0,0)')
     return hpr
 def getJumpHpr(av = av, node = self.golfKart):
     hpr = Point3(0, 0, 0)
     if hasattr(self, 'golfKart') and self.golfKart:
         hpr = self.golfKart.getHpr(av.getParent())
         if seatIndex < 2:
             hpr.setX(hpr.getX() + 180)
         else:
             hpr.setX(hpr.getX())
         angle = PythonUtil.fitDestAngle2Src(av.getH(), hpr.getX())
         hpr.setX(angle)
     else:
         self.notify.warning('getJumpHpr invalid golfKart, returning (0,0,0)')
     return hpr
Пример #24
0
    def generateToonMoveTrack(self, toon):
        """
        """

        #create a temp node that has the same position as
        # the toon that we tell to 'lookAt' the plant
        #import pdb; pdb.set_trace()
        node = NodePath('tempNode')

        displacement = Vec3(toon.getPos(render) - self.getPos(render))
        displacement.setZ(0)  #hmmm should we set this to zero?
        displacement.normalize()

        movieDistance = self.movieNode.getDistance(self.rotateNode)
        displacement *= movieDistance

        node.reparentTo(render)
        node.setPos(displacement + self.getPos(render))
        node.lookAt(self)

        # find the best H to turn the toon
        heading = PythonUtil.fitDestAngle2Src(toon.getH(render),
                                              node.getH(render))
        #heading = PythonUtil.closestDestAngle( toon.getH( render ), node.getH(render) )
        hpr = toon.getHpr(render)
        hpr.setX(heading)

        finalX = node.getX(render)
        finalY = node.getY(render)
        finalZ = node.getZ(render)
        node.removeNode()

        toonTrack = Sequence(
            Parallel(
                ActorInterval(toon, "walk", loop=True, duration=1),
                Parallel(
                    LerpPosInterval(
                        toon,
                        1.,
                        Point3(finalX, finalY, toon.getZ(render)),  #finalZ ),
                        fluid=True,
                        bakeInStart=False,
                    ),
                    #Func(self.unprint, "generateToonMoveTrack LerpPosInterval")
                ),
                LerpHprInterval(toon, 1., hpr=hpr),
            ),
            Func(toon.loop, 'neutral'),
        )
        return toonTrack
Пример #25
0
    def enterWalkToGrid(self):
        pos = self.getGridPos()
        targetHpr = GameUtils.getHeadsUpHpr(self.getPos(render), pos)
        targetHpr[0] = PythonUtil.fitDestAngle2Src(self.getH(), targetHpr[0])
        hqHpr = GameUtils.getHeadsUpHpr(pos, self.arena.tempHQ.getPos(render))
        hqHpr[0] = PythonUtil.fitDestAngle2Src(targetHpr[0], hqHpr[0])

        distance = (self.getPos() - pos).length()
        hDiff = abs(self.getH() - targetHpr.getX())
        hqHDiff = abs(targetHpr.getX() - hqHpr.getX())

        self.tunnelSequence = Sequence(
            Func(self.loop, 'walk'),
            self.hprInterval(hDiff / GameGlobals.EnemyTurnSpeed,
                             targetHpr,
                             blendType='easeInOut'),
            self.posInterval(distance / GameGlobals.EnemyForwardSpeed,
                             pos,
                             blendType='easeInOut'),
            self.hprInterval(hqHDiff / GameGlobals.EnemyTurnSpeed,
                             hqHpr,
                             blendType='easeInOut'),
            Func(self.loop, 'neutral'), Func(self.__reachedGrid))
        self.tunnelSequence.start()
    def doDirectedAttack(self, avId, attackCode):
        toon = base.cr.doId2do.get(avId)
        if toon:
            gearRoot = self.rotateNode.attachNewNode('gearRoot')
            gearRoot.setZ(10)
            gearRoot.setTag('attackCode', str(attackCode))
            gearModel = self.getGearFrisbee()
            gearModel.setScale(0.2)
            gearRoot.headsUp(toon)
            toToonH = PythonUtil.fitDestAngle2Src(0, gearRoot.getH() + 180)
            gearRoot.lookAt(toon)
            neutral = 'Fb_neutral'
            if not self.twoFaced:
                neutral = 'Ff_neutral'
            gearTrack = Parallel()
            for i in range(4):
                node = gearRoot.attachNewNode(str(i))
                node.hide()
                node.setPos(0, 5.85, 4.0)
                gear = gearModel.instanceTo(node)
                x = random.uniform(-5, 5)
                z = random.uniform(-3, 3)
                h = random.uniform(-720, 720)
                gearTrack.append(
                    Sequence(
                        Wait(i * 0.15),
                        Func(node.show),
                        Parallel(
                            node.posInterval(
                                1, Point3(x, 50, z),
                                fluid=1),
                            node.hprInterval(
                                1, VBase3(h, 0, 0),
                                fluid=1)),
                        Func(node.detachNode)))

            if not self.raised:
                neutral1Anim = self.getAnim('down2Up')
                self.raised = 1
            else:
                neutral1Anim = ActorInterval(self, neutral, startFrame=48)
            throwAnim = self.getAnim('throw')
            neutral2Anim = ActorInterval(self, neutral)
            extraAnim = Sequence()
            if attackCode == ToontownGlobals.BossCogSlowDirectedAttack:
                extraAnim = ActorInterval(self, neutral)
            seq = Sequence(ParallelEndTogether(self.pelvis.hprInterval(1, VBase3(toToonH, 0, 0)), neutral1Anim), extraAnim, Parallel(Sequence(Wait(0.19), gearTrack, Func(gearRoot.detachNode), self.pelvis.hprInterval(0.2, VBase3(0, 0, 0))), Sequence(Func(self.setChatAbsolute, random.choice(TTLocalizer.DirectedAttackBossTaunts[self.dna.dept]) % {'toon': toon.getName()}, CFSpeech | CFTimeout), throwAnim, neutral2Anim)))
            self.doAnimate(seq, now=1, raised=1)
Пример #27
0
 def addPoint(self, pos, hpr=None):
     if hpr:
         eggVtx = egg.EggVertex()
         
         if len(self.myrotverts) > 0:
             prev = self.myrotverts[-1].getPos3()
             hpr = [directutil.fitDestAngle2Src(old, new)
                    for old,new in zip(prev, hpr)]
         
         eggVtx.setPos(p3d.Point3D(hpr[0], hpr[1], hpr[2]))
         self.myrotverts.append(eggVtx)
         self.vtxPool.addVertex(eggVtx)
     if self.myrotverts and not hpr:
         print "you started to add rotations.. you better see it through now!"
     
     eggVtx = egg.EggVertex()
     eggVtx.setPos(p3d.Point3D(pos[0], pos[1], pos[2]))
     self.myverts.append(eggVtx)
     self.vtxPool.addVertex(eggVtx)
 def __startWalk(self):
     self.__stopWalk()
     if self.target:
         now = globalClock.getFrameTime()
         availableTime = self.arrivalTime - now
         if availableTime > 0:
             origH = self.getH()
             h = PythonUtil.fitDestAngle2Src(origH, self.targetH)
             delta = abs(h - origH)
             turnTime = delta / (self.velocity * 5)
             dist = Vec3(self.target - self.getPos()).length()
             walkTime = dist / self.velocity
             denom = turnTime + walkTime
             if denom != 0:
                 timeCompress = availableTime / denom
                 self.walkTrack = Sequence(self.hprInterval(turnTime * timeCompress, VBase3(h, 0, 0)), self.posInterval(walkTime * timeCompress, self.target))
                 self.walkTrack.start()
         else:
             self.setPos(self.target)
             self.setH(self.targetH)
 def __chooseTarget(self, extraDelay = 0):
     direction = self.__chooseDirection()
     if direction == None:
         self.target = None
         self.arrivalTime = None
         self.b_destroyGoon()
         return
     heading, dist = direction
     dist = min(dist, self.legLength)
     targetH = PythonUtil.reduceAngle(self.getH() + heading)
     origH = self.getH()
     h = PythonUtil.fitDestAngle2Src(origH, targetH)
     delta = abs(h - origH)
     turnTime = delta / (self.velocity * 5)
     walkTime = dist / self.velocity
     self.setH(targetH)
     self.target = self.boss.scene.getRelativePoint(self, Point3(0, dist, 0))
     self.departureTime = globalClock.getFrameTime()
     self.arrivalTime = self.departureTime + turnTime + walkTime + extraDelay
     self.d_setTarget(self.target[0], self.target[1], h, globalClockDelta.localToNetworkTime(self.arrivalTime))
     return
 def getJumpHpr(av = av, node = destNode):
     hpr = node.getHpr(av.getParent())
     hpr.setX(hpr.getX() + 180)
     angle = PythonUtil.fitDestAngle2Src(av.getH(), hpr.getX())
     hpr.setX(angle)
     return hpr
 def getJumpHpr(av = av, node = destNode):
     hpr = node.getHpr(av.getParent())
     hpr.setX(hpr.getX() + 180)
     angle = PythonUtil.fitDestAngle2Src(av.getH(), hpr.getX())
     hpr.setX(angle)
     return hpr
Пример #32
0
 def enterBoarding(self, nodePath):
     camera.wrtReparentTo(nodePath)
     heading = PythonUtil.fitDestAngle2Src(camera.getH(nodePath), 180)
     self.cameraBoardTrack = LerpPosHprInterval(camera, 1.5, Point3(0, 18, 8), Point3(heading, -10, 0))
     self.cameraBoardTrack.start()
     return None
Пример #33
0
 def noticeLocalAvatar(self):
     if self.isInInvasion():
         return
     if not self.shouldNotice(
     ) or self.isMovingDontNotice or self.noticeFlag:
         return
     if self.getDistance(localAvatar) > self.getEffectiveNoticeDistance(
     ) + 2.0 or not self.stateOkayForNotice():
         if self.gameFSM:
             pass
         self.endNotice()
         return
     heading = self.getHpr()
     self.headsUp(localAvatar)
     if self.needNoticeGroundTracking:
         self.trackTerrain()
     noticeHeading = self.getHpr()
     self.setHpr(heading)
     angle = PythonUtil.fitDestAngle2Src(heading[0], noticeHeading[0])
     if self.needNoticeGroundTracking:
         newHpr = Vec3(angle, noticeHeading[1], noticeHeading[2])
     else:
         newHpr = Vec3(angle, heading[1], heading[2])
     noticeDif = abs(angle - heading[0])
     turnAnim = self.getTurnAnim(noticeDif)
     if self.noticeIval:
         self.noticeFlag = 1
         self.noticeIval.finish()
         self.noticeFlag = 0
         self.noticeIval = None
     self.noticeIval = Sequence(Wait(self.noticeSpeed),
                                Func(self.noticeLocalAvatar))
     self.noticeIval.start()
     if not self.isFlying:
         self.startFlying()
     return
     if self.getDistance(localAvatar) > self.closeNoticeDistance + 2.0:
         if self.hasTurnedToNotice:
             self.endNotice()
         else:
             self.noticeIval = Sequence(Wait(self.noticeSpeed),
                                        Func(self.noticeLocalAvatar))
             self.noticeIval.start()
     elif abs(noticeDif) > 15.0 and self.shouldTurnToNotice:
         if turnAnim:
             self.noticeIval = Sequence(
                 Func(self.startShuffle, turnAnim),
                 LerpHprInterval(self,
                                 duration=self.noticeSpeed,
                                 hpr=newHpr), Func(self.midShuffle),
                 Wait(self.noticeSpeed), Func(self.endShuffle),
                 Func(self.noticeLocalAvatar))
             self.noticeIval.start()
         else:
             self.noticeIval = Sequence(
                 LerpHprInterval(self,
                                 duration=self.noticeSpeed,
                                 hpr=newHpr), Wait(self.noticeSpeed),
                 Func(self.noticeLocalAvatar))
             self.noticeIval.start()
         self.doNoticeFX()
         self.hasTurnedToNotice = 1
     elif abs(noticeDif) < 45.0:
         duration = self.presetNoticeAnimation()
         if duration == None or self.doneThreat == 1:
             duration = self.noticeSpeed
         self.noticeIval = Sequence(Func(self.startNoticeLoop),
                                    Func(self.playNoticeAnim),
                                    Wait(duration),
                                    Func(self.endNoticeLoop),
                                    Func(self.noticeLocalAvatar))
         self.noticeIval.start()
         self.doNoticeFX()
     return
    def noticeLocalAvatar(self):
        if self.isInInvasion() or self.getGameState() in [
            'Emote']:
            return None

        if not self.shouldNotice() and self.isMovingDontNotice or self.noticeFlag:
            return None

        if self.getDistance(localAvatar) > self.getEffectiveNoticeDistance() + 2.0 or not self.stateOkayForNotice():
            if self.gameFSM:
                pass
            1
            self.endNotice()
            return None

        heading = self.getHpr()
        if base.localAvatar.getGameState() == 'NPCInteract':
            if hasattr(self, 'dialogProcessMaster'):
                pass
            if not (self.dialogProcessMaster):
                self.headsUp(base.camera)
            else:
                self.headsUp(localAvatar)
        if self.needNoticeGroundTracking:
            self.trackTerrain()

        noticeHeading = self.getHpr()
        self.setHpr(heading)
        angle = PythonUtil.fitDestAngle2Src(heading[0], noticeHeading[0])
        if self.needNoticeGroundTracking:
            newHpr = Vec3(angle, noticeHeading[1], noticeHeading[2])
        else:
            newHpr = Vec3(angle, heading[1], heading[2])
        noticeDif = abs(angle - heading[0])
        turnAnim = self.getTurnAnim(noticeDif)
        if self.noticeIval:
            self.noticeFlag = 1
            self.noticeIval.finish()
            self.noticeFlag = 0
            self.noticeIval = None

        if self.getDistance(localAvatar) > self.getEffectiveNoticeDistance() + 2.0:
            if self.hasTurnedToNotice:
                self.endNotice()
            else:
                self.noticeIval = Sequence(Wait(self.noticeSpeed), Func(self.noticeLocalAvatar))
                self.noticeIval.start()
        elif abs(noticeDif) > 15.0 and self.shouldTurnToNotice:
            if turnAnim:
                self.noticeIval = Sequence(Func(self.startShuffle, turnAnim), LerpHprInterval(self, duration = self.noticeSpeed, hpr = newHpr), Func(self.midShuffle), Wait(self.noticeSpeed), Func(self.endShuffle), Func(self.noticeLocalAvatar))
                self.noticeIval.start()
            else:
                self.noticeIval = Sequence(LerpHprInterval(self, duration = self.noticeSpeed, hpr = newHpr), Wait(self.noticeSpeed), Func(self.noticeLocalAvatar))
                self.noticeIval.start()
            self.doNoticeFX()
            self.hasTurnedToNotice = 1
        elif abs(noticeDif) < 45.0:
            duration = self.presetNoticeAnimation()
            if duration == None or self.doneThreat == 1:
                duration = self.noticeSpeed

            self.noticeIval = Sequence(Func(self.startNoticeLoop), Func(self.playNoticeAnim), Wait(duration), Func(self.endNoticeLoop), Func(self.noticeLocalAvatar))
            self.noticeIval.start()
            self.doNoticeFX()
 def getJumpHpr(av = av, node = self.tablecloth):
     hpr = self.seats[seatIndex].getHpr(av.getParent())
     angle = PythonUtil.fitDestAngle2Src(av.getH(), hpr.getX())
     hpr.setX(angle)
     return hpr