Beispiel #1
0
    def __faceOff(self, ts, name, callback):
        if len(self.suits) == 0:
            self.notify.warning('__faceOff(): no suits.')
            return
        if len(self.toons) == 0:
            self.notify.warning('__faceOff(): no toons.')
            return
        suit = self.suits[0]
        point = self.suitPoints[0][0]
        suitPos = point[0]
        suitHpr = VBase3(point[1], 0.0, 0.0)
        toon = self.toons[0]
        point = self.toonPoints[0][0]
        toonPos = point[0]
        toonHpr = VBase3(point[1], 0.0, 0.0)
        p = toon.getPos(self)
        toon.setPos(self, p[0], p[1], 0.0)
        toon.setShadowHeight(0)
        suit.setState('Battle')
        suitTrack = Sequence()
        toonTrack = Sequence()
        suitTrack.append(Func(suit.loop, 'neutral'))
        suitTrack.append(Func(suit.headsUp, toon))
        taunt = SuitBattleGlobals.getFaceoffTaunt(suit.getStyleName(),
                                                  suit.doId)
        suitTrack.append(
            Func(suit.setChatAbsolute, taunt, CFSpeech | CFTimeout))
        toonTrack.append(Func(toon.loop, 'neutral'))
        toonTrack.append(Func(toon.headsUp, suit))
        suitHeight = suit.getHeight()
        suitOffsetPnt = Point3(0, 0, suitHeight)
        faceoffTime = self.calcFaceoffTime(self.getPos(), self.initialSuitPos)
        faceoffTime = max(faceoffTime, BATTLE_SMALL_VALUE)
        delay = FACEOFF_TAUNT_T
        if self.hasLocalToon():
            MidTauntCamHeight = suitHeight * 0.66
            MidTauntCamHeightLim = suitHeight - 1.8
            if MidTauntCamHeight < MidTauntCamHeightLim:
                MidTauntCamHeight = MidTauntCamHeightLim
            TauntCamY = 16
            TauntCamX = random.choice((-5, 5))
            TauntCamHeight = random.choice((MidTauntCamHeight, 1, 11))
            camTrack = Sequence()
            camTrack.append(Func(camera.wrtReparentTo, suit))
            camTrack.append(
                Func(base.camLens.setMinFov, self.camFOFov / (4. / 3.)))
            camTrack.append(
                Func(camera.setPos, TauntCamX, TauntCamY, TauntCamHeight))
            camTrack.append(Func(camera.lookAt, suit, suitOffsetPnt))
            camTrack.append(Wait(delay))
            camTrack.append(
                Func(base.camLens.setMinFov, self.camFov / (4. / 3.)))
            camTrack.append(Func(camera.wrtReparentTo, self))
            camTrack.append(Func(camera.setPos, self.camFOPos))
            camTrack.append(Func(camera.lookAt, suit.getPos(self)))
            camTrack.append(Wait(faceoffTime))
            if self.interactiveProp:
                camTrack.append(
                    Func(camera.lookAt,
                         self.interactiveProp.node.getPos(self)))
                camTrack.append(Wait(FACEOFF_LOOK_AT_PROP_T))
        suitTrack.append(Wait(delay))
        toonTrack.append(Wait(delay))
        suitTrack.append(Func(suit.headsUp, self, suitPos))
        suitTrack.append(Func(suit.clearChat))
        toonTrack.append(Func(toon.headsUp, self, toonPos))
        suitTrack.append(Func(suit.loop, 'walk'))
        suitTrack.append(
            LerpPosInterval(suit, faceoffTime, suitPos, other=self))
        suitTrack.append(Func(suit.loop, 'neutral'))
        suitTrack.append(Func(suit.setHpr, self, suitHpr))
        toonTrack.append(Func(toon.loop, 'run'))
        toonTrack.append(
            LerpPosInterval(toon, faceoffTime, toonPos, other=self))
        toonTrack.append(Func(toon.loop, 'neutral'))
        toonTrack.append(Func(toon.setHpr, self, toonHpr))
        if base.localAvatar == toon:
            soundTrack = Sequence(
                Wait(delay),
                SoundInterval(base.localAvatar.soundRun,
                              loop=1,
                              duration=faceoffTime,
                              node=base.localAvatar))
        else:
            soundTrack = Wait(delay + faceoffTime)

        mtrack = Parallel(suitTrack, toonTrack, soundTrack)

        if self.hasLocalToon():
            NametagGlobals.setMasterArrowsOn(0)
            mtrack = Parallel(mtrack, camTrack)

        done = Func(callback)
        track = Sequence(mtrack, done, name=name)
        track.delayDeletes = [
            DelayDelete.DelayDelete(toon, '__faceOff'),
            DelayDelete.DelayDelete(suit, '__faceOff')
        ]
        track.start(ts)
        self.storeInterval(track, name)
    def __faceOff(self, ts, name, callback):
        if len(self.suits) == 0:
            self.notify.warning('__faceOff(): no suits.')
            return
        if len(self.toons) == 0:
            self.notify.warning('__faceOff(): no toons.')
            return
        elevatorPos = self.toons[0].getPos()
        if len(self.suits) == 1:
            leaderIndex = 0
        elif self.bossBattle == 1:
            leaderIndex = 1
        else:
            maxTypeNum = -1
            for suit in self.suits:
                suitTypeNum = SuitDNA.getSuitType(suit.dna.name)
                if maxTypeNum < suitTypeNum:
                    maxTypeNum = suitTypeNum
                    leaderIndex = self.suits.index(suit)

        delay = FACEOFF_TAUNT_T
        suitTrack = Parallel()
        suitLeader = None
        for suit in self.suits:
            suit.setState('Battle')
            suitIsLeader = 0
            oneSuitTrack = Sequence()
            oneSuitTrack.append(Func(suit.loop, 'neutral'))
            oneSuitTrack.append(Func(suit.headsUp, elevatorPos))
            if self.suits.index(suit) == leaderIndex:
                suitLeader = suit
                suitIsLeader = 1
                if self.bossBattle == 1:
                    taunt = self.getBossBattleTaunt()
                else:
                    taunt = SuitBattleGlobals.getFaceoffTaunt(suit.getStyleName(), suit.doId)
                oneSuitTrack.append(Func(suit.setChatAbsolute, taunt, CFSpeech | CFTimeout))
            destPos, destHpr = self.getActorPosHpr(suit, self.suits)
            oneSuitTrack.append(Wait(delay))
            if suitIsLeader == 1:
                oneSuitTrack.append(Func(suit.clearChat))
            oneSuitTrack.append(self.createAdjustInterval(suit, destPos, destHpr))
            suitTrack.append(oneSuitTrack)

        toonTrack = Parallel()
        for toon in self.toons:
            oneToonTrack = Sequence()
            destPos, destHpr = self.getActorPosHpr(toon, self.toons)
            oneToonTrack.append(Wait(delay))
            oneToonTrack.append(self.createAdjustInterval(toon, destPos, destHpr, toon=1, run=1))
            toonTrack.append(oneToonTrack)

        camTrack = Sequence()

        def setCamFov(fov):
            base.camLens.setMinFov(fov/(4./3.))

        camTrack.append(Func(camera.wrtReparentTo, suitLeader))
        camTrack.append(Func(setCamFov, self.camFOFov))
        suitHeight = suitLeader.getHeight()
        suitOffsetPnt = Point3(0, 0, suitHeight)
        MidTauntCamHeight = suitHeight * 0.66
        MidTauntCamHeightLim = suitHeight - 1.8
        if MidTauntCamHeight < MidTauntCamHeightLim:
            MidTauntCamHeight = MidTauntCamHeightLim
        TauntCamY = 18
        TauntCamX = 0
        TauntCamHeight = random.choice((MidTauntCamHeight, 1, 11))
        camTrack.append(Func(camera.setPos, TauntCamX, TauntCamY, TauntCamHeight))
        camTrack.append(Func(camera.lookAt, suitLeader, suitOffsetPnt))
        camTrack.append(Wait(delay))
        camPos = Point3(0, -6, 4)
        camHpr = Vec3(0, 0, 0)
        camTrack.append(Func(camera.reparentTo, base.localAvatar))
        camTrack.append(Func(setCamFov, ToontownGlobals.DefaultCameraFov))
        camTrack.append(Func(camera.setPosHpr, camPos, camHpr))
        mtrack = Parallel(suitTrack, toonTrack, camTrack)
        done = Func(callback)
        track = Sequence(mtrack, done, name=name)
        track.start(ts)
        self.storeInterval(track, name)
        return
Beispiel #3
0
    def _DistributedBattle__faceOff(self, ts, name, callback):
        if len(self.suits) == 0:
            self.notify.warning('__faceOff(): no suits.')
            return None

        if len(self.toons) == 0:
            self.notify.warning('__faceOff(): no toons.')
            return None

        suit = self.suits[0]
        point = self.suitPoints[0][0]
        suitPos = point[0]
        suitHpr = VBase3(point[1], 0.0, 0.0)
        toon = self.toons[0]
        point = self.toonPoints[0][0]
        toonPos = point[0]
        toonHpr = VBase3(point[1], 0.0, 0.0)
        suit.setState('Battle')
        suitIvals = []
        toonIvals = []
        camIvals = []
        suitIvals.append(FunctionInterval(suit.loop, extraArgs=['neutral']))
        suitIvals.append(
            FunctionInterval(suit.headsUp, extraArgs=[toon.getPos()]))
        taunt = SuitBattleGlobals.getFaceoffTaunt(suit.getStyleName(),
                                                  suit.doId)
        suitIvals.append(
            FunctionInterval(suit.setChatAbsolute,
                             extraArgs=[taunt, CFSpeech | CFTimeout]))
        toonIvals.append(FunctionInterval(toon.loop, extraArgs=['neutral']))
        toonIvals.append(
            FunctionInterval(toon.headsUp, extraArgs=[suit.getPos()]))

        def setCamFov(fov):
            base.camLens.setFov(fov)

        camIvals.append(
            FunctionInterval(camera.wrtReparentTo, extraArgs=[suit]))
        camIvals.append(FunctionInterval(setCamFov, extraArgs=[self.camFOFov]))
        suitHeight = suit.getHeight()
        suitOffsetPnt = Point3(0, 0, suitHeight)
        MidTauntCamHeight = suitHeight * 0.66000000000000003
        MidTauntCamHeightLim = suitHeight - 1.8
        if MidTauntCamHeight < MidTauntCamHeightLim:
            MidTauntCamHeight = MidTauntCamHeightLim

        TauntCamY = 16
        TauntCamX = whrandom.choice((-5, 5))
        TauntCamHeight = whrandom.choice((MidTauntCamHeight, 1, 11))
        camIvals.append(
            FunctionInterval(camera.setPos,
                             extraArgs=[TauntCamX, TauntCamY, TauntCamHeight]))
        camIvals.append(
            FunctionInterval(camera.lookAt, extraArgs=[suit, suitOffsetPnt]))
        delay = FACEOFF_TAUNT_T
        camIvals.append(WaitInterval(delay))
        sFaceSpot = FunctionInterval(suit.headsUp, extraArgs=[self, suitPos])
        suitIvals.append((delay, sFaceSpot))
        suitIvals.append(FunctionInterval(suit.clearChat))
        tFaceSpot = FunctionInterval(toon.headsUp, extraArgs=[self, toonPos])
        toonIvals.append((delay, tFaceSpot))
        faceoffTime = self.calcFaceoffTime(self.getPos(), self.initialSuitPos)
        fromBattle = Vec3(self.getPos() - self.initialSuitPos)
        distance = fromBattle.length()
        if distance > MAX_EXPECTED_DISTANCE_FROM_BATTLE:

            try:
                zoneId = toonbase.tcr.playGame.getPlace().getZoneId()
                zoneStr = str(zoneId)
            except:
                zoneStr = 'Unknown'

            self.notify.warning(
                'WARNING: Possible missing battle cell in zone ' + zoneStr +
                '!!')
            toonbase.tcr.timeManager.synchronize(
                'Suit is %0.1f ft from battle cell.' % distance)

        suitIvals.append(FunctionInterval(suit.loop, extraArgs=['walk']))
        suitIvals.append(
            LerpPosInterval(suit, faceoffTime, suitPos, other=self))
        suitIvals.append(FunctionInterval(suit.loop, extraArgs=['neutral']))
        suitIvals.append(
            FunctionInterval(suit.setHpr, extraArgs=[self, suitHpr]))
        toonIvals.append(FunctionInterval(toon.loop, extraArgs=['run']))
        toonIvals.append(
            LerpPosInterval(toon, faceoffTime, toonPos, other=self))
        toonIvals.append(FunctionInterval(toon.loop, extraArgs=['neutral']))
        toonIvals.append(
            FunctionInterval(toon.setHpr, extraArgs=[self, toonHpr]))
        camIvals.append(FunctionInterval(setCamFov, extraArgs=[self.camFov]))
        camIvals.append(
            FunctionInterval(camera.wrtReparentTo, extraArgs=[self]))
        camIvals.append(
            FunctionInterval(camera.setPos, extraArgs=[self.camFOPos]))
        camIvals.append(
            FunctionInterval(camera.lookAt, extraArgs=[suit.getPos(self)]))
        camIvals.append(WaitInterval(faceoffTime))
        if toonbase.localToon == toon:
            soundTrack = Track((WaitInterval(delay),
                                SoundInterval(toonbase.localToon.soundRun,
                                              loop=1,
                                              duration=faceoffTime,
                                              node=toonbase.localToon)))
        else:
            soundTrack = WaitInterval(faceoffTime + delay)
        suitTrack = Track(suitIvals)
        toonTrack = Track(toonIvals)
        camTrack = Track(camIvals)
        mtrack = MultiTrack([suitTrack, toonTrack, soundTrack])
        done = FunctionInterval(callback)
        track = Track([mtrack, done], name)
        track.start(ts)
        self.activeIntervals[name] = track
        if self.hasLocalToon():
            NametagGlobals.setMasterArrowsOn(0)
            camTrack.start(ts)
    def __faceOff(self, ts, name, callback):
        if len(self.suits) == 0:
            self.notify.warning('__faceOff(): no suits.')
            return
        if len(self.toons) == 0:
            self.notify.warning('__faceOff(): no toons.')
            return
        elevatorPos = self.toons[0].getPos()
        if len(self.suits) == 1:
            leaderIndex = 0
        elif self.bossBattle == 1:
            leaderIndex = 1
        else:
            maxTypeNum = -1
            for suit in self.suits:
                suitTypeNum = SuitDNA.getSuitType(suit.dna.name)
                if maxTypeNum < suitTypeNum:
                    maxTypeNum = suitTypeNum
                    leaderIndex = self.suits.index(suit)

        delay = FACEOFF_TAUNT_T
        suitTrack = Parallel()
        suitLeader = None
        for suit in self.suits:
            suit.setState('Battle')
            suitIsLeader = 0
            oneSuitTrack = Sequence()
            oneSuitTrack.append(Func(suit.loop, 'neutral'))
            oneSuitTrack.append(Func(suit.headsUp, elevatorPos))
            if self.suits.index(suit) == leaderIndex:
                suitLeader = suit
                suitIsLeader = 1
                if self.bossBattle == 1:
                    taunt = self.getBossBattleTaunt()
                else:
                    taunt = SuitBattleGlobals.getFaceoffTaunt(
                        suit.getStyleName(), suit.doId)
                oneSuitTrack.append(
                    Func(suit.setChatAbsolute, taunt, CFSpeech | CFTimeout))
            destPos, destHpr = self.getActorPosHpr(suit, self.suits)
            oneSuitTrack.append(Wait(delay))
            if suitIsLeader == 1:
                oneSuitTrack.append(Func(suit.clearChat))
            oneSuitTrack.append(
                self.createAdjustInterval(suit, destPos, destHpr))
            suitTrack.append(oneSuitTrack)

        toonTrack = Parallel()
        for toon in self.toons:
            oneToonTrack = Sequence()
            destPos, destHpr = self.getActorPosHpr(toon, self.toons)
            oneToonTrack.append(Wait(delay))
            oneToonTrack.append(
                self.createAdjustInterval(toon,
                                          destPos,
                                          destHpr,
                                          toon=1,
                                          run=1))
            toonTrack.append(oneToonTrack)

        camTrack = Sequence()

        def setCamFov(fov):
            base.camLens.setMinFov(fov / (4. / 3.))

        camTrack.append(Func(camera.wrtReparentTo, suitLeader))
        camTrack.append(Func(setCamFov, self.camFOFov))
        suitHeight = suitLeader.getHeight()
        suitOffsetPnt = Point3(0, 0, suitHeight)
        MidTauntCamHeight = suitHeight * 0.66
        MidTauntCamHeightLim = suitHeight - 1.8
        if MidTauntCamHeight < MidTauntCamHeightLim:
            MidTauntCamHeight = MidTauntCamHeightLim
        TauntCamY = 18
        TauntCamX = 0
        TauntCamHeight = random.choice((MidTauntCamHeight, 1, 11))
        camTrack.append(
            Func(camera.setPos, TauntCamX, TauntCamY, TauntCamHeight))
        camTrack.append(Func(camera.lookAt, suitLeader, suitOffsetPnt))
        camTrack.append(Wait(delay))
        camPos = Point3(0, -6, 4)
        camHpr = Vec3(0, 0, 0)
        camTrack.append(Func(camera.reparentTo, base.localAvatar))
        camTrack.append(Func(setCamFov, ToontownGlobals.DefaultCameraFov))
        camTrack.append(Func(camera.setPosHpr, camPos, camHpr))
        mtrack = Parallel(suitTrack, toonTrack, camTrack)
        done = Func(callback)
        track = Sequence(mtrack, done, name=name)
        track.start(ts)
        self.storeInterval(track, name)
        return
Beispiel #5
0
 def getActualLevel(self):
     return SuitBattleGlobals.getActualFromRelativeLevel(
         self.getStyleName(), self.level) + 1
 def __faceOff(self, ts, name, callback):
     if len(self.suits) == 0:
         self.notify.warning('__faceOff(): no suits.')
         return
     if len(self.toons) == 0:
         self.notify.warning('__faceOff(): no toons.')
         return
     suit = self.suits[0]
     point = self.suitPoints[0][0]
     suitPos = point[0]
     suitHpr = VBase3(point[1], 0.0, 0.0)
     toon = self.toons[0]
     point = self.toonPoints[0][0]
     toonPos = point[0]
     toonHpr = VBase3(point[1], 0.0, 0.0)
     p = toon.getPos(self)
     toon.setPos(self, p[0], p[1], 0.0)
     toon.setShadowHeight(0)
     suit.setState('Battle')
     suitTrack = Sequence()
     toonTrack = Sequence()
     suitTrack.append(Func(suit.loop, 'neutral'))
     suitTrack.append(Func(suit.headsUp, toon))
     taunt = SuitBattleGlobals.getFaceoffTaunt(suit.getStyleName(), suit.doId)
     suitTrack.append(Func(suit.setChatAbsolute, taunt, CFSpeech | CFTimeout))
     toonTrack.append(Func(toon.loop, 'neutral'))
     toonTrack.append(Func(toon.headsUp, suit))
     suitHeight = suit.getHeight()
     suitOffsetPnt = Point3(0, 0, suitHeight)
     faceoffTime = self.calcFaceoffTime(self.getPos(), self.initialSuitPos)
     faceoffTime = max(faceoffTime, BATTLE_SMALL_VALUE)
     delay = FACEOFF_TAUNT_T
     if self.hasLocalToon():
         MidTauntCamHeight = suitHeight * 0.66
         MidTauntCamHeightLim = suitHeight - 1.8
         if MidTauntCamHeight < MidTauntCamHeightLim:
             MidTauntCamHeight = MidTauntCamHeightLim
         TauntCamY = 16
         TauntCamX = random.choice((-5, 5))
         TauntCamHeight = random.choice((MidTauntCamHeight, 1, 11))
         camTrack = Sequence()
         camTrack.append(Func(camera.wrtReparentTo, suit))
         camTrack.append(Func(base.camLens.setMinFov, self.camFOFov/(4./3.)))
         camTrack.append(Func(camera.setPos, TauntCamX, TauntCamY, TauntCamHeight))
         camTrack.append(Func(camera.lookAt, suit, suitOffsetPnt))
         camTrack.append(Wait(delay))
         camTrack.append(Func(base.camLens.setMinFov, self.camFov/(4./3.)))
         camTrack.append(Func(camera.wrtReparentTo, self))
         camTrack.append(Func(camera.setPos, self.camFOPos))
         camTrack.append(Func(camera.lookAt, suit.getPos(self)))
         camTrack.append(Wait(faceoffTime))
         if self.interactiveProp:
             camTrack.append(Func(camera.lookAt, self.interactiveProp.node.getPos(self)))
             camTrack.append(Wait(FACEOFF_LOOK_AT_PROP_T))
     suitTrack.append(Wait(delay))
     toonTrack.append(Wait(delay))
     suitTrack.append(Func(suit.headsUp, self, suitPos))
     suitTrack.append(Func(suit.clearChat))
     toonTrack.append(Func(toon.headsUp, self, toonPos))
     suitTrack.append(Func(suit.loop, 'walk'))
     suitTrack.append(LerpPosInterval(suit, faceoffTime, suitPos, other=self))
     suitTrack.append(Func(suit.loop, 'neutral'))
     suitTrack.append(Func(suit.setHpr, self, suitHpr))
     toonTrack.append(Func(toon.loop, 'run'))
     toonTrack.append(LerpPosInterval(toon, faceoffTime, toonPos, other=self))
     toonTrack.append(Func(toon.loop, 'neutral'))
     toonTrack.append(Func(toon.setHpr, self, toonHpr))
     if base.localAvatar == toon:
         soundTrack = Sequence(Wait(delay), SoundInterval(base.localAvatar.soundRun, loop=1, duration=faceoffTime, node=base.localAvatar))
     else:
         soundTrack = Wait(delay + faceoffTime)
         
     mtrack = Parallel(suitTrack, toonTrack, soundTrack)
     
     if self.hasLocalToon():
         NametagGlobals.setMasterArrowsOn(0)
         mtrack = Parallel(mtrack, camTrack)
         
     done = Func(callback)
     track = Sequence(mtrack, done, name=name)
     track.delayDeletes = [DelayDelete.DelayDelete(toon, '__faceOff'), DelayDelete.DelayDelete(suit, '__faceOff')]
     track.start(ts)
     self.storeInterval(track, name)
Beispiel #7
0
 def getActualLevel(self):
     return SuitBattleGlobals.getActualFromRelativeLevel(self.getStyleName(), self.level) + 1
    def _DistributedBattle__faceOff(self, ts, name, callback):
        if len(self.suits) == 0:
            self.notify.warning('__faceOff(): no suits.')
            return None
        
        if len(self.toons) == 0:
            self.notify.warning('__faceOff(): no toons.')
            return None
        
        suit = self.suits[0]
        point = self.suitPoints[0][0]
        suitPos = point[0]
        suitHpr = VBase3(point[1], 0.0, 0.0)
        toon = self.toons[0]
        point = self.toonPoints[0][0]
        toonPos = point[0]
        toonHpr = VBase3(point[1], 0.0, 0.0)
        suit.setState('Battle')
        suitIvals = []
        toonIvals = []
        camIvals = []
        suitIvals.append(FunctionInterval(suit.loop, extraArgs = [
            'neutral']))
        suitIvals.append(FunctionInterval(suit.headsUp, extraArgs = [
            toon.getPos()]))
        taunt = SuitBattleGlobals.getFaceoffTaunt(suit.getStyleName(), suit.doId)
        suitIvals.append(FunctionInterval(suit.setChatAbsolute, extraArgs = [
            taunt,
            CFSpeech | CFTimeout]))
        toonIvals.append(FunctionInterval(toon.loop, extraArgs = [
            'neutral']))
        toonIvals.append(FunctionInterval(toon.headsUp, extraArgs = [
            suit.getPos()]))
        
        def setCamFov(fov):
            base.camLens.setFov(fov)

        camIvals.append(FunctionInterval(camera.wrtReparentTo, extraArgs = [
            suit]))
        camIvals.append(FunctionInterval(setCamFov, extraArgs = [
            self.camFOFov]))
        suitHeight = suit.getHeight()
        suitOffsetPnt = Point3(0, 0, suitHeight)
        MidTauntCamHeight = suitHeight * 0.66000000000000003
        MidTauntCamHeightLim = suitHeight - 1.8
        if MidTauntCamHeight < MidTauntCamHeightLim:
            MidTauntCamHeight = MidTauntCamHeightLim
        
        TauntCamY = 16
        TauntCamX = whrandom.choice((-5, 5))
        TauntCamHeight = whrandom.choice((MidTauntCamHeight, 1, 11))
        camIvals.append(FunctionInterval(camera.setPos, extraArgs = [
            TauntCamX,
            TauntCamY,
            TauntCamHeight]))
        camIvals.append(FunctionInterval(camera.lookAt, extraArgs = [
            suit,
            suitOffsetPnt]))
        delay = FACEOFF_TAUNT_T
        camIvals.append(WaitInterval(delay))
        sFaceSpot = FunctionInterval(suit.headsUp, extraArgs = [
            self,
            suitPos])
        suitIvals.append((delay, sFaceSpot))
        suitIvals.append(FunctionInterval(suit.clearChat))
        tFaceSpot = FunctionInterval(toon.headsUp, extraArgs = [
            self,
            toonPos])
        toonIvals.append((delay, tFaceSpot))
        faceoffTime = self.calcFaceoffTime(self.getPos(), self.initialSuitPos)
        fromBattle = Vec3(self.getPos() - self.initialSuitPos)
        distance = fromBattle.length()
        if distance > MAX_EXPECTED_DISTANCE_FROM_BATTLE:
            
            try:
                zoneId = toonbase.tcr.playGame.getPlace().getZoneId()
                zoneStr = str(zoneId)
            except:
                zoneStr = 'Unknown'

            self.notify.warning('WARNING: Possible missing battle cell in zone ' + zoneStr + '!!')
            toonbase.tcr.timeManager.synchronize('Suit is %0.1f ft from battle cell.' % distance)
        
        suitIvals.append(FunctionInterval(suit.loop, extraArgs = [
            'walk']))
        suitIvals.append(LerpPosInterval(suit, faceoffTime, suitPos, other = self))
        suitIvals.append(FunctionInterval(suit.loop, extraArgs = [
            'neutral']))
        suitIvals.append(FunctionInterval(suit.setHpr, extraArgs = [
            self,
            suitHpr]))
        toonIvals.append(FunctionInterval(toon.loop, extraArgs = [
            'run']))
        toonIvals.append(LerpPosInterval(toon, faceoffTime, toonPos, other = self))
        toonIvals.append(FunctionInterval(toon.loop, extraArgs = [
            'neutral']))
        toonIvals.append(FunctionInterval(toon.setHpr, extraArgs = [
            self,
            toonHpr]))
        camIvals.append(FunctionInterval(setCamFov, extraArgs = [
            self.camFov]))
        camIvals.append(FunctionInterval(camera.wrtReparentTo, extraArgs = [
            self]))
        camIvals.append(FunctionInterval(camera.setPos, extraArgs = [
            self.camFOPos]))
        camIvals.append(FunctionInterval(camera.lookAt, extraArgs = [
            suit.getPos(self)]))
        camIvals.append(WaitInterval(faceoffTime))
        if toonbase.localToon == toon:
            soundTrack = Track((WaitInterval(delay), SoundInterval(toonbase.localToon.soundRun, loop = 1, duration = faceoffTime, node = toonbase.localToon)))
        else:
            soundTrack = WaitInterval(faceoffTime + delay)
        suitTrack = Track(suitIvals)
        toonTrack = Track(toonIvals)
        camTrack = Track(camIvals)
        mtrack = MultiTrack([
            suitTrack,
            toonTrack,
            soundTrack])
        done = FunctionInterval(callback)
        track = Track([
            mtrack,
            done], name)
        track.start(ts)
        self.activeIntervals[name] = track
        if self.hasLocalToon():
            NametagGlobals.setMasterArrowsOn(0)
            camTrack.start(ts)
Beispiel #9
0
    def __faceOff(self, ts, name, callback):
        if (len(self.suits) == 0):
            self.notify.warning('__faceOff(): no suits.')
            return
        if (len(self.toons) == 0):
            self.notify.warning('__faceOff(): no toons.')
            return

        # Pick only the first suit for the faceoff, if there happen to
        # be more than one.
        suit = self.suits[0]
        point = self.suitPoints[0][0]
        suitPos = point[0]
        suitHpr = VBase3(point[1], 0.0, 0.0)

        # And ditto for the first toon.
        toon = self.toons[0]
        point = self.toonPoints[0][0]
        toonPos = point[0]
        toonHpr = VBase3(point[1], 0.0, 0.0)

        p = toon.getPos(self)
        toon.setPos(self, p[0], p[1], 0.0)
        toon.setShadowHeight(0)

        suit.setState('Battle')

        suitTrack = Sequence()
        toonTrack = Sequence()

        # Make suit and toon face each other (and exchange taunts)
        suitTrack.append(Func(suit.loop, 'neutral'))
        suitTrack.append(Func(suit.headsUp, toon))
        taunt = SuitBattleGlobals.getFaceoffTaunt(suit.getStyleName(),
                                                  suit.doId)
        suitTrack.append(
            Func(suit.setChatAbsolute, taunt, CFSpeech | CFTimeout))
        toonTrack.append(Func(toon.loop, 'neutral'))
        toonTrack.append(Func(toon.headsUp, suit))

        suitHeight = suit.getHeight()
        suitOffsetPnt = Point3(0, 0, suitHeight)

        # Determine the battle positions based on initial angle
        # between the suit and the battle center (we want the suit to walk
        # as short a distance as possible)
        faceoffTime = self.calcFaceoffTime(self.getPos(), self.initialSuitPos)
        #assert(faceoffTime > BATTLE_SMALL_VALUE)
        # make sure the faceoff time is non-zero
        faceoffTime = max(faceoffTime, BATTLE_SMALL_VALUE)
        delay = FACEOFF_TAUNT_T

        if (self.hasLocalToon()):
            # empirical hack to pick a mid-height view, left in to sortof match the old view
            MidTauntCamHeight = suitHeight * 0.66
            MidTauntCamHeightLim = suitHeight - 1.8
            if (MidTauntCamHeight < MidTauntCamHeightLim):
                MidTauntCamHeight = MidTauntCamHeightLim

            TauntCamY = 16
            TauntCamX = random.choice((-5, 5))
            TauntCamHeight = random.choice((MidTauntCamHeight, 1, 11))

            camTrack = Sequence()
            camTrack.append(Func(camera.wrtReparentTo, suit))
            camTrack.append(Func(base.camLens.setFov, self.camFOFov))
            camTrack.append(
                Func(camera.setPos, TauntCamX, TauntCamY, TauntCamHeight))
            camTrack.append(Func(camera.lookAt, suit, suitOffsetPnt))
            camTrack.append(Wait(delay))
            camTrack.append(Func(base.camLens.setFov, self.camFov))
            camTrack.append(Func(camera.wrtReparentTo, self))
            camTrack.append(Func(camera.setPos, self.camFOPos))
            camTrack.append(Func(camera.lookAt, suit.getPos(self)))
            camTrack.append(Wait(faceoffTime))
            if self.interactiveProp:
                camTrack.append(
                    Func(camera.lookAt,
                         self.interactiveProp.node.getPos(self)))
                camTrack.append(Wait(FACEOFF_LOOK_AT_PROP_T))

        suitTrack.append(Wait(delay))
        toonTrack.append(Wait(delay))

        # Make suit and toon face their destination spots in the battle
        suitTrack.append(Func(suit.headsUp, self, suitPos))
        suitTrack.append(Func(suit.clearChat))
        toonTrack.append(Func(toon.headsUp, self, toonPos))

        # Make suit and toon walk to their battle spots
        suitTrack.append(Func(suit.loop, 'walk'))
        suitTrack.append(
            LerpPosInterval(suit, faceoffTime, suitPos, other=self))
        suitTrack.append(Func(suit.loop, 'neutral'))
        suitTrack.append(Func(suit.setHpr, self, suitHpr))

        toonTrack.append(Func(toon.loop, 'run'))
        toonTrack.append(
            LerpPosInterval(toon, faceoffTime, toonPos, other=self))
        toonTrack.append(Func(toon.loop, 'neutral'))
        toonTrack.append(Func(toon.setHpr, self, toonHpr))

        if base.localAvatar == toon:
            soundTrack = Sequence(
                Wait(delay),
                SoundInterval(base.localAvatar.soundRun,
                              loop=1,
                              duration=faceoffTime,
                              node=base.localAvatar),
            )
        else:
            soundTrack = Wait(delay + faceoffTime)
        mtrack = Parallel(suitTrack, toonTrack, soundTrack)

        if (self.hasLocalToon()):
            # No arrows - they just get in the way
            NametagGlobals.setMasterArrowsOn(0)
            mtrack = Parallel(mtrack, camTrack)

        done = Func(callback)
        track = Sequence(mtrack, done, name=name)
        track.delayDeletes = [
            DelayDelete.DelayDelete(toon, '__faceOff'),
            DelayDelete.DelayDelete(suit, '__faceOff')
        ]
        track.start(ts)
        self.storeInterval(track, name)
Beispiel #10
0
    def __faceOff(self, ts, name, callback):
        elevatorPos = self.toons[0].getPos()
        if len(self.suits) == 1:
            leaderIndex = 0
        if self.bossBattle == 1:
            leaderIndex = 1
        maxTypeNum = -1
        for suit in self.suits:
            suitTypeNum = AvatarDNA.getSuitType(suit.dna.name)
            if maxTypeNum < suitTypeNum:
                maxTypeNum = suitTypeNum
                leaderIndex = self.suits.index(suit)

        delay = FACEOFF_TAUNT_T
        suitTracks = []
        suitLeader = None
        for suit in self.suits:
            suit.setState('Battle')
            suitIsLeader = 0
            suitIvals = []
            suitIvals.append(FunctionInterval(suit.loop,
                                              extraArgs=['neutral']))
            suitIvals.append(
                FunctionInterval(suit.headsUp, extraArgs=[elevatorPos]))
            if self.suits.index(suit) == leaderIndex:
                suitLeader = suit
                suitIsLeader = 1
                if self.bossBattle == 1:
                    taunt = Localizer.BattleBldgBossTaunt
                else:
                    taunt = SuitBattleGlobals.getFaceoffTaunt(
                        suit.getStyleName(), suit.doId)
                suitIvals.append(
                    FunctionInterval(suit.setChatAbsolute,
                                     extraArgs=[taunt, CFSpeech | CFTimeout]))
            destPos, destHpr = self.getActorPosHpr(suit, self.suits)
            suitIvals.append(WaitInterval(delay))
            if suitIsLeader == 1:
                suitIvals.append(FunctionInterval(suit.clearChat))
            suitIvals.append(self.createAdjustInterval(suit, destPos, destHpr))
            suitTracks.append(Track(suitIvals))

        suitTrack = Track([MultiTrack(suitTracks)])
        toonTracks = []
        for toon in self.toons:
            toonIvals = []
            destPos, destHpr = self.getActorPosHpr(toon, self.toons)
            toonIvals.append((delay,
                              self.createAdjustInterval(toon,
                                                        destPos,
                                                        destHpr,
                                                        toon=1,
                                                        run=1)))
            toonTracks.append(Track(toonIvals))

        toonTrack = Track([MultiTrack(toonTracks)])
        camIvals = []

        def setCamFov(fov):
            base.camLens.setFov(fov)

        camIvals.append(
            FunctionInterval(camera.wrtReparentTo, extraArgs=[suitLeader]))
        camIvals.append(FunctionInterval(setCamFov, extraArgs=[self.camFOFov]))
        suitHeight = suitLeader.getHeight()
        suitOffsetPnt = Point3(0, 0, suitHeight)
        MidTauntCamHeight = suitHeight * 0.66
        MidTauntCamHeightLim = suitHeight - 1.8
        if MidTauntCamHeight < MidTauntCamHeightLim:
            MidTauntCamHeight = MidTauntCamHeightLim
        TauntCamY = 18
        TauntCamX = 0
        TauntCamHeight = whrandom.choice((MidTauntCamHeight, 1, 11))
        camIvals.append(
            FunctionInterval(camera.setPos,
                             extraArgs=[TauntCamX, TauntCamY, TauntCamHeight]))
        camIvals.append(
            FunctionInterval(camera.lookAt,
                             extraArgs=[suitLeader, suitOffsetPnt]))
        camIvals.append(WaitInterval(delay))
        camPos = Point3(0, -6, 4)
        camHpr = Vec3(0, 0, 0)
        camIvals.append(
            FunctionInterval(camera.reparentTo,
                             extraArgs=[toonbase.localToon]))
        camIvals.append(
            FunctionInterval(setCamFov, extraArgs=[DefaultCameraFov]))
        camIvals.append(
            FunctionInterval(camera.setPosHpr, extraArgs=[camPos, camHpr]))
        camTrack = Track(camIvals)
        mtrack = MultiTrack([suitTrack, toonTrack, camTrack])
        done = FunctionInterval(callback)
        track = Track([mtrack, done], name)
        track.start(ts)
        self.activeIntervals[name] = track
        return
Beispiel #11
0
    def __faceOff(self, ts, name, callback):
        if (len(self.suits) == 0):
            self.notify.warning('__faceOff(): no suits.')
            return
        if (len(self.toons) == 0):
            self.notify.warning('__faceOff(): no toons.')
            return

        # Do the suits faceoff
        # TODO: get the actual position of the elevator door
        elevatorPos = self.toons[0].getPos()

        if (len(self.suits) == 1):
            leaderIndex = 0
        else:
            if (self.bossBattle == 1):
                leaderIndex = 1 # __genSuitInfos ensures that multi-suit boss battles will have boss in index 1 (a middle position)
            else:
                # otherwise __genSuitInfos ensures nothing, so pick the suit with the highest type to be the leader
                maxTypeNum = -1
                for suit in self.suits:
                    suitTypeNum = SuitDNA.getSuitType(suit.dna.name)
                    if (maxTypeNum < suitTypeNum):
                        maxTypeNum = suitTypeNum
                        leaderIndex = self.suits.index(suit)

        delay = FACEOFF_TAUNT_T
        suitTrack = Parallel()
        suitLeader = None

        for suit in self.suits:
            suit.setState('Battle')
            suitIsLeader = 0
            oneSuitTrack = Sequence()
            # Suits stop what they're doing and look at the toons
            oneSuitTrack.append(Func(suit.loop, 'neutral'))
            oneSuitTrack.append(Func(suit.headsUp, elevatorPos))

            # Only the suit leader taunts the toons
            if (self.suits.index(suit) == leaderIndex):
                suitLeader = suit
                suitIsLeader = 1

                # TODO: have an inside of building taunt here
                if (self.bossBattle == 1):
                    taunt = TTLocalizer.BattleBldgBossTaunt
                else:
                    taunt = SuitBattleGlobals.getFaceoffTaunt(suit.getStyleName(), suit.doId)

                oneSuitTrack.append(Func(suit.setChatAbsolute,
                                         taunt, CFSpeech | CFTimeout))

            # Move all suits into position after taunt delay
            destPos, destHpr = self.getActorPosHpr(suit, self.suits)
            oneSuitTrack.append(Wait(delay))
            if (suitIsLeader == 1):
                oneSuitTrack.append(Func(suit.clearChat))
            oneSuitTrack.append(self.createAdjustInterval(suit, destPos, destHpr))
            suitTrack.append(oneSuitTrack)


        # Do the toons faceoff 
        toonTrack = Parallel()
        for toon in self.toons:
            oneToonTrack = Sequence()
            destPos, destHpr = self.getActorPosHpr(toon, self.toons)
            oneToonTrack.append(Wait(delay))
            oneToonTrack.append(self.createAdjustInterval(
                toon, destPos, destHpr, toon=1, run=1))
            toonTrack.append(oneToonTrack)

        # Put the camera somewhere
        camTrack = Sequence()
        def setCamFov(fov):
            base.camLens.setFov(fov)
        camTrack.append(Func(camera.wrtReparentTo, suitLeader))

        camTrack.append(Func(setCamFov, self.camFOFov))

        suitHeight = suitLeader.getHeight()
        suitOffsetPnt = Point3(0, 0, suitHeight)

        # empirical hack to pick a mid-height view, left in to sortof match the old view
        MidTauntCamHeight = suitHeight*0.66
        MidTauntCamHeightLim = suitHeight-1.8
        if (MidTauntCamHeight < MidTauntCamHeightLim):
           MidTauntCamHeight = MidTauntCamHeightLim

        TauntCamY = 18
        TauntCamX = 0
        TauntCamHeight = random.choice((MidTauntCamHeight, 1, 11))

        camTrack.append(Func(camera.setPos,
                             TauntCamX, TauntCamY, TauntCamHeight))
        camTrack.append(Func(camera.lookAt, suitLeader, suitOffsetPnt))

        camTrack.append(Wait(delay))
        camPos = Point3(0, -6, 4)
        camHpr = Vec3(0, 0, 0)
        camTrack.append(Func(camera.reparentTo, base.localAvatar))
        camTrack.append(Func(setCamFov, ToontownGlobals.DefaultCameraFov))
        camTrack.append(Func(camera.setPosHpr, camPos, camHpr))

        mtrack = Parallel(suitTrack, toonTrack, camTrack)
        done = Func(callback)
        track = Sequence(mtrack, done, name = name)
        track.start(ts)
        self.storeInterval(track, name)