Ejemplo n.º 1
0
 def placeTrap(trapProp, suit, battle=battle, trapName=trapName):
     if not trapProp or trapProp.isEmpty():
         return
     trapProp.wrtReparentTo(suit)
     trapProp.show()
     if trapName == 'rake':
         trapProp.setPos(0, MovieUtil.SUIT_TRAP_RAKE_DISTANCE, 0)
         trapProp.setHpr(Point3(0, 270, 0))
         trapProp.setScale(Point3(0.7, 0.7, 0.7))
         rakeOffset = MovieUtil.getSuitRakeOffset(suit)
         trapProp.setY(trapProp.getY() + rakeOffset)
     else:
         if trapName == 'banana':
             trapProp.setHpr(0, 0, 0)
             trapProp.setPos(0, MovieUtil.SUIT_TRAP_DISTANCE, -0.35)
             trapProp.pose(trapName, trapProp.getNumFrames(trapName) - 1)
         else:
             if trapName == 'marbles':
                 trapProp.setHpr(Point3(94, 0, 0))
                 trapProp.setPos(0, MovieUtil.SUIT_TRAP_MARBLES_DISTANCE, 0)
                 trapProp.pose(trapName, trapProp.getNumFrames(trapName) - 1)
             else:
                 if trapName == 'tnt':
                     trapProp.setHpr(0, 90, 0)
                     trapProp.setPos(0, MovieUtil.SUIT_TRAP_TNT_DISTANCE, 0.4)
                 else:
                     notify.warning('placeTrap() - Incorrect trap: %s placed on a suit' % trapName)
 def placeTrap(trapProp, suit, battle=battle, trapName=trapName):
     if not trapProp or trapProp.isEmpty():
         return
     trapProp.wrtReparentTo(suit)
     trapProp.show()
     if trapName == 'rake':
         trapProp.setPos(0, MovieUtil.SUIT_TRAP_RAKE_DISTANCE, 0)
         trapProp.setHpr(Point3(0, 270, 0))
         trapProp.setScale(Point3(0.7, 0.7, 0.7))
         rakeOffset = MovieUtil.getSuitRakeOffset(suit)
         trapProp.setY(trapProp.getY() + rakeOffset)
     elif trapName == 'banana':
         trapProp.setHpr(0, 0, 0)
         trapProp.setPos(0, MovieUtil.SUIT_TRAP_DISTANCE, -0.35)
         trapProp.pose(trapName, trapProp.getNumFrames(trapName) - 1)
     elif trapName == 'marbles':
         trapProp.setHpr(Point3(94, 0, 0))
         trapProp.setPos(0, MovieUtil.SUIT_TRAP_MARBLES_DISTANCE, 0)
         trapProp.pose(trapName, trapProp.getNumFrames(trapName) - 1)
     elif trapName == 'tnt':
         trapProp.setHpr(0, 90, 0)
         trapProp.setPos(0, MovieUtil.SUIT_TRAP_TNT_DISTANCE, 0.4)
     else:
         notify.warning(
             'placeTrap() - Incorrect trap: %s placed on a suit' %
             trapName)
Ejemplo n.º 3
0
 def placeTrap(trapProp, suit, battle=battle, trapName=trapName):
     # In case multiple traps are thrown to the same spot, we must return (doing
     # nothing) if the trapProp we have has actually been removed and replaced
     # by another trap (it won't exist anymore)
     if not trapProp or trapProp.isEmpty():
         return
     trapProp.wrtReparentTo(suit)
     trapProp.show()
     # Set the new trap prop
     # All the traps use the default trap distance, except the rake
     if (trapName == 'rake'):
         # The rake will actually be completed replaced with a different rake model
         # which has a different animation on it for when the rake is stepped on
         trapProp.setPos(0, MovieUtil.SUIT_TRAP_RAKE_DISTANCE, 0)
         # reorient the rake correctly to be stepped on
         trapProp.setHpr(Point3(0, 270, 0))
         trapProp.setScale(Point3(0.7, 0.7, 0.7))
         # The rake must be a specific distance from each suit for that
         # suit to be able to walk into the rake
         rakeOffset = MovieUtil.getSuitRakeOffset(suit)
         trapProp.setY(trapProp.getY() + rakeOffset)
     elif (trapName == 'banana'):
         trapProp.setHpr(0, 0, 0)
         trapProp.setPos(0, MovieUtil.SUIT_TRAP_DISTANCE, -0.35)
         trapProp.pose(trapName, trapProp.getNumFrames(trapName) - 1)
     elif (trapName == 'marbles'):
         trapProp.setHpr(Point3(94, 0, 0))
         trapProp.setPos(0, MovieUtil.SUIT_TRAP_MARBLES_DISTANCE, 0)
         trapProp.pose(trapName, trapProp.getNumFrames(trapName) - 1)
     elif (trapName == 'tnt'):
         trapProp.setHpr(0, 90, 0)
         trapProp.setPos(0, MovieUtil.SUIT_TRAP_TNT_DISTANCE, 0.4)
     else:
         notify.warning('placeTrap() - Incorrect trap: %s placed on a suit' \
                         % trapName)
Ejemplo n.º 4
0
def __createSuitDamageTrack(battle, suit, hp, lure, trapProp):
    if trapProp is None or trapProp.isEmpty():
        return Func(suit.loop, 'neutral')
    trapProp.wrtReparentTo(battle)
    trapTrack = ToontownBattleGlobals.TRAP_TRACK
    trapLevel = suit.battleTrap
    trapTrackNames = ToontownBattleGlobals.AvProps[trapTrack]
    trapName = trapTrackNames[trapLevel]
    result = Sequence()

    def reparentTrap(trapProp=trapProp, battle=battle):
        if trapProp and not trapProp.isEmpty():
            trapProp.wrtReparentTo(battle)

    result.append(Func(reparentTrap))
    parent = battle
    if suit.battleTrapIsFresh == 1:
        if trapName == 'quicksand' or trapName == 'trapdoor':
            trapProp.hide()
            trapProp.reparentTo(suit)
            trapProp.setPos(Point3(0, MovieUtil.SUIT_TRAP_DISTANCE, 0))
            trapProp.setHpr(Point3(0, 0, 0))
            trapProp.wrtReparentTo(battle)
        elif trapName == 'rake':
            trapProp.hide()
            trapProp.reparentTo(suit)
            trapProp.setPos(0, MovieUtil.SUIT_TRAP_RAKE_DISTANCE, 0)
            trapProp.setHpr(Point3(0, 270, 0))
            trapProp.setScale(Point3(0.7, 0.7, 0.7))
            rakeOffset = MovieUtil.getSuitRakeOffset(suit)
            trapProp.setY(trapProp.getY() + rakeOffset)
        else:
            parent = render
    if trapName == 'banana':
        slidePos = trapProp.getPos(parent)
        slidePos.setY(slidePos.getY() - 5.1)
        moveTrack = Sequence(
            Wait(0.1), LerpPosInterval(trapProp, 0.1, slidePos, other=battle))
        animTrack = Sequence(
            ActorInterval(trapProp, 'banana', startTime=3.1), Wait(1.1),
            LerpScaleInterval(trapProp, 1, Point3(0.01, 0.01, 0.01)))
        suitTrack = ActorInterval(suit, 'slip-backward')
        damageTrack = Sequence(Wait(0.5),
                               Func(suit.showHpText, -hp, openEnded=0),
                               Func(suit.updateHealthBar, hp))
        soundTrack = Sequence(
            SoundInterval(
                globalBattleSoundCache.getSound('AA_pie_throw_only.ogg'),
                duration=0.55,
                node=suit),
            SoundInterval(
                globalBattleSoundCache.getSound('Toon_bodyfall_synergy.ogg'),
                node=suit))
        result.append(
            Parallel(moveTrack, animTrack, suitTrack, damageTrack, soundTrack))
    elif trapName == 'rake' or trapName == 'rake-react':
        hpr = trapProp.getHpr(parent)
        upHpr = Vec3(hpr[0], 179.9999, hpr[2])
        bounce1Hpr = Vec3(hpr[0], 120, hpr[2])
        bounce2Hpr = Vec3(hpr[0], 100, hpr[2])
        rakeTrack = Sequence(
            Wait(0.5), LerpHprInterval(trapProp, 0.1, upHpr, startHpr=hpr),
            Wait(0.7), LerpHprInterval(trapProp, 0.4, hpr, startHpr=upHpr),
            LerpHprInterval(trapProp, 0.15, bounce1Hpr, startHpr=hpr),
            LerpHprInterval(trapProp, 0.05, hpr, startHpr=bounce1Hpr),
            LerpHprInterval(trapProp, 0.15, bounce2Hpr, startHpr=hpr),
            LerpHprInterval(trapProp, 0.05, hpr, startHpr=bounce2Hpr),
            Wait(0.2),
            LerpScaleInterval(trapProp, 0.2, Point3(0.01, 0.01, 0.01)))
        rakeAnimDuration = 3.125
        suitTrack = ActorInterval(suit,
                                  'rake-react',
                                  duration=rakeAnimDuration)
        damageTrack = Sequence(Wait(0.5),
                               Func(suit.showHpText, -hp, openEnded=0),
                               Func(suit.updateHealthBar, hp))
        soundTrack = getSoundTrack('TL_step_on_rake.ogg', delay=0.6, node=suit)
        result.append(Parallel(rakeTrack, suitTrack, damageTrack, soundTrack))
    elif trapName == 'marbles':
        slidePos = trapProp.getPos(parent)
        slidePos.setY(slidePos.getY() - 6.5)
        moveTrack = Sequence(
            Wait(0.1), LerpPosInterval(trapProp, 0.8, slidePos, other=battle),
            Wait(1.1), LerpScaleInterval(trapProp, 1, Point3(0.01, 0.01,
                                                             0.01)))
        animTrack = ActorInterval(trapProp, 'marbles', startTime=3.1)
        suitTrack = ActorInterval(suit, 'slip-backward')
        damageTrack = Sequence(Wait(0.5),
                               Func(suit.showHpText, -hp, openEnded=0),
                               Func(suit.updateHealthBar, hp))
        soundTrack = Sequence(
            SoundInterval(
                globalBattleSoundCache.getSound('AA_pie_throw_only.ogg'),
                duration=0.55,
                node=suit),
            SoundInterval(
                globalBattleSoundCache.getSound('Toon_bodyfall_synergy.ogg'),
                node=suit))
        result.append(
            Parallel(moveTrack, animTrack, suitTrack, damageTrack, soundTrack))
    elif trapName == 'quicksand':
        sinkPos1 = trapProp.getPos(battle)
        sinkPos2 = trapProp.getPos(battle)
        dropPos = trapProp.getPos(battle)
        landPos = trapProp.getPos(battle)
        sinkPos1.setZ(sinkPos1.getZ() - 3.1)
        sinkPos2.setZ(sinkPos2.getZ() - 9.1)
        dropPos.setZ(dropPos.getZ() + 15)
        if config.GetBool('want-new-cogs', 0):
            nameTag = suit.find('**/def_nameTag')
        else:
            nameTag = suit.find('**/joint_nameTag')
        trapTrack = Sequence(
            Wait(2.4),
            LerpScaleInterval(trapProp, 0.8, Point3(0.01, 0.01, 0.01)))
        moveTrack = Sequence(
            Wait(0.9), LerpPosInterval(suit, 0.9, sinkPos1, other=battle),
            LerpPosInterval(suit, 0.4, sinkPos2, other=battle),
            Func(suit.setPos, battle, dropPos), Func(suit.wrtReparentTo,
                                                     hidden), Wait(1.1),
            Func(suit.wrtReparentTo, battle),
            LerpPosInterval(suit, 0.3, landPos, other=battle))
        animTrack = Sequence(ActorInterval(suit, 'flail'),
                             ActorInterval(suit, 'flail', startTime=1.1),
                             Wait(0.7),
                             ActorInterval(suit, 'slip-forward', duration=2.1))
        damageTrack = Sequence(Wait(3.5),
                               Func(suit.showHpText, -hp, openEnded=0),
                               Func(suit.updateHealthBar, hp))
        soundTrack = Sequence(
            Wait(0.7),
            SoundInterval(globalBattleSoundCache.getSound('TL_quicksand.ogg'),
                          node=suit), Wait(0.1),
            SoundInterval(
                globalBattleSoundCache.getSound('Toon_bodyfall_synergy.ogg'),
                node=suit))
        result.append(
            Parallel(trapTrack, moveTrack, animTrack, damageTrack, soundTrack))
    elif trapName == 'trapdoor':
        sinkPos = trapProp.getPos(battle)
        dropPos = trapProp.getPos(battle)
        landPos = trapProp.getPos(battle)
        sinkPos.setZ(sinkPos.getZ() - 9.1)
        dropPos.setZ(dropPos.getZ() + 15)
        trapTrack = Sequence(
            Wait(2.4),
            LerpScaleInterval(trapProp, 0.8, Point3(0.01, 0.01, 0.01)))
        moveTrack = Sequence(Wait(2.2),
                             LerpPosInterval(suit, 0.4, sinkPos, other=battle),
                             Func(suit.setPos, battle, dropPos),
                             Func(suit.wrtReparentTo, hidden), Wait(1.6),
                             Func(suit.wrtReparentTo, battle),
                             LerpPosInterval(suit, 0.3, landPos, other=battle))
        animTrack = Sequence(
            getSplicedLerpAnimsTrack(suit, 'flail', 0.7, 0.25),
            Func(trapProp.setColor, Vec4(0, 0, 0, 1)),
            ActorInterval(suit, 'flail', startTime=0.7, endTime=0),
            ActorInterval(suit, 'neutral', duration=0.5),
            ActorInterval(suit, 'flail', startTime=1.1), Wait(1.1),
            ActorInterval(suit, 'slip-forward', duration=2.1))
        damageTrack = Sequence(Wait(3.5),
                               Func(suit.showHpText, -hp, openEnded=0),
                               Func(suit.updateHealthBar, hp))
        soundTrack = Sequence(
            Wait(0.8),
            SoundInterval(globalBattleSoundCache.getSound('TL_trap_door.ogg'),
                          node=suit), Wait(0.8),
            SoundInterval(
                globalBattleSoundCache.getSound('Toon_bodyfall_synergy.ogg'),
                node=suit))
        result.append(
            Parallel(trapTrack, moveTrack, animTrack, damageTrack, soundTrack))
    elif trapName == 'tnt':
        tntTrack = ActorInterval(trapProp, 'tnt')
        explosionTrack = Sequence(
            Wait(2.3),
            createTNTExplosionTrack(battle,
                                    trapProp=trapProp,
                                    relativeTo=parent))
        suitTrack = Sequence(
            ActorInterval(suit, 'flail', duration=0.7),
            ActorInterval(suit, 'flail', startTime=0.7, endTime=0.0),
            ActorInterval(suit, 'neutral', duration=0.4),
            ActorInterval(suit, 'flail', startTime=0.6, endTime=0.7),
            Wait(0.4),
            ActorInterval(suit, 'slip-forward', startTime=2.48, duration=0.1),
            Func(battle.movie.needRestoreColor),
            Func(suit.setColorScale, Vec4(0.2, 0.2, 0.2, 1)),
            Func(trapProp.reparentTo, hidden),
            ActorInterval(suit, 'slip-forward', startTime=2.58),
            Func(suit.clearColorScale), Func(trapProp.sparksEffect.cleanup),
            Func(battle.movie.clearRestoreColor))
        damageTrack = Sequence(Wait(2.3),
                               Func(suit.showHpText, -hp, openEnded=0),
                               Func(suit.updateHealthBar, hp))
        explosionSound = base.loadSfx(
            'phase_3.5/audio/sfx/ENC_cogfall_apart.ogg')
        soundTrack = Sequence(
            SoundInterval(globalBattleSoundCache.getSound('TL_dynamite.ogg'),
                          duration=2.0,
                          node=suit),
            SoundInterval(explosionSound, duration=0.6, node=suit))
        result.append(
            Parallel(tntTrack, suitTrack, damageTrack, explosionTrack,
                     soundTrack))
    elif trapName == 'traintrack':
        trainInterval = createIncomingTrainInterval(battle, suit, hp, lure,
                                                    trapProp)
        result.append(trainInterval)
    else:
        notify.warning('unknown trapName: %s detected on suit: %s' %
                       (trapName, suit))
    suit.battleTrapProp = trapProp
    result.append(Func(battle.removeTrap, suit, True))
    result.append(Func(battle.unlureSuit, suit))
    result.append(__createSuitResetPosTrack(suit, battle))
    result.append(Func(suit.loop, 'neutral'))
    if trapName == 'traintrack':
        result.append(Func(MovieUtil.removeProp, trapProp))
    return result
Ejemplo n.º 5
0
def __createSuitDamageTrack(battle, suit, hp, lure, trapProp):
    if trapProp == None or trapProp.isEmpty():
        return Track([FunctionInterval(suit.loop, extraArgs=['neutral'])])
    trapProp.wrtReparentTo(battle)
    trapTrack = ToontownBattleGlobals.TRAP_TRACK
    trapLevel = suit.battleTrap
    trapTrackNames = ToontownBattleGlobals.AvProps[trapTrack]
    trapName = trapTrackNames[trapLevel]
    ivals = []

    def reparentTrap(trapProp=trapProp, battle=battle):
        trapProp.wrtReparentTo(battle)

    ivals.append(FunctionInterval(reparentTrap))
    parent = battle
    if suit.battleTrapIsFresh == 1:
        if trapName == 'quicksand' or trapName == 'trapdoor':
            trapProp.hide()
            trapProp.reparentTo(suit)
            trapProp.setPos(Point3(0, MovieUtil.SUIT_TRAP_DISTANCE, 0))
            trapProp.setHpr(Point3(0, 0, 0))
            trapProp.wrtReparentTo(battle)
        else:
            if trapName == 'rake':
                trapProp.hide()
                trapProp.reparentTo(suit)
                trapProp.setPos(0, MovieUtil.SUIT_TRAP_RAKE_DISTANCE, 0)
                trapProp.setHpr(Point3(0, 270, 0))
                trapProp.setScale(Point3(0.7, 0.7, 0.7))
                rakeOffset = MovieUtil.getSuitRakeOffset(suit)
                trapProp.setY(trapProp.getY() + rakeOffset)
            else:
                parent = render
    if trapName == 'banana':
        slidePos = trapProp.getPos(parent)
        slidePos.setY(slidePos.getY() - 5.1)
        moveTrack = Track([
            WaitInterval(0.1),
            LerpPosInterval(trapProp, 0.1, slidePos, other=battle)
        ])
        animTrack = Track([
            ActorInterval(trapProp, 'banana', startTime=3.1),
            WaitInterval(1.1),
            LerpScaleInterval(trapProp, 1, Point3(0.01, 0.01, 0.01))
        ])
        suitTrack = Track([ActorInterval(suit, 'slip-backward')])
        damageTrack = Track([
            WaitInterval(0.5),
            FunctionInterval(suit.showLaffNumber, openEnded=0,
                             extraArgs=[-hp]),
            FunctionInterval(suit.updateHealthBar, extraArgs=[hp])
        ])
        soundTrack = Track([
            SoundInterval(
                globalBattleSoundCache.getSound('AA_pie_throw_only.mp3'),
                duration=0.55,
                node=suit),
            SoundInterval(
                globalBattleSoundCache.getSound('Toon_bodyfall_synergy.mp3'),
                node=suit)
        ])
        ivals.append(
            MultiTrack(
                [moveTrack, animTrack, suitTrack, damageTrack, soundTrack]))
    else:
        if trapName == 'rake' or trapName == 'rake-react':
            hpr = trapProp.getHpr(parent)
            upHpr = Vec3(hpr[0], 179.9999, hpr[2])
            bounce1Hpr = Vec3(hpr[0], 120, hpr[2])
            bounce2Hpr = Vec3(hpr[0], 100, hpr[2])
            rakeTrack = Track([
                WaitInterval(0.5),
                LerpHprInterval(trapProp, 0.1, upHpr, startHpr=hpr),
                WaitInterval(0.7),
                LerpHprInterval(trapProp, 0.4, hpr, startHpr=upHpr),
                LerpHprInterval(trapProp, 0.15, bounce1Hpr, startHpr=hpr),
                LerpHprInterval(trapProp, 0.05, hpr, startHpr=bounce1Hpr),
                LerpHprInterval(trapProp, 0.15, bounce2Hpr, startHpr=hpr),
                LerpHprInterval(trapProp, 0.05, hpr, startHpr=bounce2Hpr),
                WaitInterval(0.2),
                LerpScaleInterval(trapProp, 0.2, Point3(0.01, 0.01, 0.01))
            ])
            rakeAnimDuration = 3.125
            suitTrack = Track(
                [ActorInterval(suit, 'rake-react', duration=rakeAnimDuration)])
            damageTrack = Track([
                WaitInterval(0.5),
                FunctionInterval(suit.showLaffNumber,
                                 openEnded=0,
                                 extraArgs=[-hp]),
                FunctionInterval(suit.updateHealthBar, extraArgs=[hp])
            ])
            soundTrack = getSoundTrack('TL_step_on_rake.mp3',
                                       delay=0.6,
                                       node=suit)
            ivals.append(
                MultiTrack([rakeTrack, suitTrack, damageTrack, soundTrack]))
        else:
            if trapName == 'marbles':
                slidePos = trapProp.getPos(parent)
                slidePos.setY(slidePos.getY() - 6.5)
                moveTrack = Track([
                    WaitInterval(0.1),
                    LerpPosInterval(trapProp, 0.8, slidePos, other=battle),
                    WaitInterval(1.1),
                    LerpScaleInterval(trapProp, 1, Point3(0.01, 0.01, 0.01))
                ])
                animTrack = Track(
                    [ActorInterval(trapProp, 'marbles', startTime=3.1)])
                suitTrack = Track([ActorInterval(suit, 'slip-backward')])
                damageTrack = Track([
                    WaitInterval(0.5),
                    FunctionInterval(suit.showLaffNumber,
                                     openEnded=0,
                                     extraArgs=[-hp]),
                    FunctionInterval(suit.updateHealthBar, extraArgs=[hp])
                ])
                soundTrack = Track([
                    SoundInterval(globalBattleSoundCache.getSound(
                        'AA_pie_throw_only.mp3'),
                                  duration=0.55,
                                  node=suit),
                    SoundInterval(globalBattleSoundCache.getSound(
                        'Toon_bodyfall_synergy.mp3'),
                                  node=suit)
                ])
                ivals.append(
                    MultiTrack([
                        moveTrack, animTrack, suitTrack, damageTrack,
                        soundTrack
                    ]))
            else:
                if trapName == 'quicksand':
                    sinkPos1 = trapProp.getPos(battle)
                    sinkPos2 = trapProp.getPos(battle)
                    dropPos = trapProp.getPos(battle)
                    landPos = trapProp.getPos(battle)
                    sinkPos1.setZ(sinkPos1.getZ() - 3.1)
                    sinkPos2.setZ(sinkPos2.getZ() - 9.1)
                    dropPos.setZ(dropPos.getZ() + 15)
                    nameTag = suit.find('**/joint-nameTag')
                    trapTrack = Track([
                        WaitInterval(2.4),
                        LerpScaleInterval(trapProp, 0.8,
                                          Point3(0.01, 0.01, 0.01))
                    ])
                    moveTrack = Track([
                        WaitInterval(0.9),
                        LerpPosInterval(suit, 0.9, sinkPos1, other=battle),
                        LerpPosInterval(suit, 0.4, sinkPos2, other=battle),
                        FunctionInterval(suit.setPos,
                                         extraArgs=[battle, dropPos]),
                        FunctionInterval(suit.wrtReparentTo,
                                         extraArgs=[hidden]),
                        WaitInterval(1.1),
                        FunctionInterval(suit.wrtReparentTo,
                                         extraArgs=[battle]),
                        LerpPosInterval(suit, 0.3, landPos, other=battle)
                    ])
                    animTrack = Track([
                        ActorInterval(suit, 'flail'),
                        ActorInterval(suit, 'flail', startTime=1.1),
                        WaitInterval(0.7),
                        ActorInterval(suit, 'slip-forward', duration=2.1)
                    ])
                    damageTrack = Track([
                        WaitInterval(3.5),
                        FunctionInterval(suit.showLaffNumber,
                                         openEnded=0,
                                         extraArgs=[-hp]),
                        FunctionInterval(suit.updateHealthBar, extraArgs=[hp])
                    ])
                    soundTrack = Track([
                        WaitInterval(0.7),
                        SoundInterval(globalBattleSoundCache.getSound(
                            'TL_quicksand.mp3'),
                                      node=suit),
                        WaitInterval(0.1),
                        SoundInterval(globalBattleSoundCache.getSound(
                            'Toon_bodyfall_synergy.mp3'),
                                      node=suit)
                    ])
                    ivals.append(
                        MultiTrack([
                            trapTrack, moveTrack, animTrack, damageTrack,
                            soundTrack
                        ]))
                else:
                    if trapName == 'trapdoor':
                        sinkPos = trapProp.getPos(battle)
                        dropPos = trapProp.getPos(battle)
                        landPos = trapProp.getPos(battle)
                        sinkPos.setZ(sinkPos.getZ() - 9.1)
                        dropPos.setZ(dropPos.getZ() + 15)
                        trapTrack = Track([
                            WaitInterval(2.4),
                            LerpScaleInterval(trapProp, 0.8,
                                              Point3(0.01, 0.01, 0.01))
                        ])
                        moveTrack = Track([
                            WaitInterval(2.2),
                            LerpPosInterval(suit, 0.4, sinkPos, other=battle),
                            FunctionInterval(suit.setPos,
                                             extraArgs=[battle, dropPos]),
                            FunctionInterval(suit.wrtReparentTo,
                                             extraArgs=[hidden]),
                            WaitInterval(1.6),
                            FunctionInterval(suit.wrtReparentTo,
                                             extraArgs=[battle]),
                            LerpPosInterval(suit, 0.3, landPos, other=battle)
                        ])
                        animIvals = []
                        animIvals.extend(
                            getSplicedLerpAnims(suit, 'flail', 0.7, 0.25))
                        animIvals.append(
                            FunctionInterval(trapProp.setColor,
                                             extraArgs=[Vec4(0, 0, 0, 1)]))
                        animIvals.append(
                            ActorInterval(suit,
                                          'flail',
                                          startTime=0.7,
                                          endTime=0))
                        animIvals.append(
                            ActorInterval(suit, 'neutral', duration=0.5))
                        animIvals.append(
                            ActorInterval(suit, 'flail', startTime=1.1))
                        animIvals.append(WaitInterval(1.1))
                        animIvals.append(
                            ActorInterval(suit, 'slip-forward', duration=2.1))
                        animTrack = Track(animIvals)
                        damageTrack = Track([
                            WaitInterval(3.5),
                            FunctionInterval(suit.showLaffNumber,
                                             openEnded=0,
                                             extraArgs=[-hp]),
                            FunctionInterval(suit.updateHealthBar,
                                             extraArgs=[hp])
                        ])
                        soundTrack = Track([
                            WaitInterval(0.8),
                            SoundInterval(globalBattleSoundCache.getSound(
                                'TL_trap_door.mp3'),
                                          node=suit),
                            WaitInterval(0.8),
                            SoundInterval(globalBattleSoundCache.getSound(
                                'Toon_bodyfall_synergy.mp3'),
                                          node=suit)
                        ])
                        ivals.append(
                            MultiTrack([
                                trapTrack, moveTrack, animTrack, damageTrack,
                                soundTrack
                            ]))
                    else:
                        if trapName == 'tnt':
                            tntTrack = Track([ActorInterval(trapProp, 'tnt')])
                            explosionIvals = []
                            explosionIvals.append(WaitInterval(2.3))
                            explosionIvals.extend(
                                createTNTExplosionIvals(battle,
                                                        trapProp=trapProp,
                                                        relativeTo=parent))
                            explosionTrack = Track(explosionIvals)
                            suitTrack = Track([
                                ActorInterval(suit, 'flail', duration=0.7),
                                ActorInterval(suit,
                                              'flail',
                                              startTime=0.7,
                                              endTime=0.0),
                                ActorInterval(suit, 'neutral', duration=0.4),
                                ActorInterval(suit,
                                              'flail',
                                              startTime=0.6,
                                              endTime=0.7),
                                WaitInterval(0.4),
                                ActorInterval(suit,
                                              'slip-forward',
                                              startTime=2.48,
                                              duration=0.1),
                                FunctionInterval(
                                    battle.movie.needRestoreColor),
                                FunctionInterval(suit.setColorScale,
                                                 extraArgs=[Vec4(0, 0, 0, 1)]),
                                FunctionInterval(trapProp.reparentTo,
                                                 extraArgs=[hidden]),
                                ActorInterval(suit,
                                              'slip-forward',
                                              startTime=2.58),
                                FunctionInterval(suit.clearColorScale),
                                FunctionInterval(
                                    trapProp.sparksEffect.cleanup),
                                FunctionInterval(
                                    battle.movie.clearRestoreColor)
                            ])
                            damageTrack = Track([
                                WaitInterval(2.3),
                                FunctionInterval(suit.showLaffNumber,
                                                 openEnded=0,
                                                 extraArgs=[-hp]),
                                FunctionInterval(suit.updateHealthBar,
                                                 extraArgs=[hp])
                            ])
                            explosionSound = base.loadSfx(
                                'phase_3.5/audio/sfx/ENC_cogfall_apart.mp3')
                            soundTrack = Track([
                                SoundInterval(globalBattleSoundCache.getSound(
                                    'TL_dynamite.mp3'),
                                              duration=2.0,
                                              node=suit),
                                SoundInterval(explosionSound,
                                              duration=0.6,
                                              node=suit)
                            ])
                            ivals.append(
                                MultiTrack([
                                    tntTrack, suitTrack, damageTrack,
                                    explosionTrack, soundTrack
                                ]))
                        else:
                            notify.warning(
                                'unknown trapName: %s detected on suit: %s' %
                                trapName, suit)
    suit.battleTrapProp = trapProp
    ivals.append(FunctionInterval(battle.removeTrap, extraArgs=[suit]))
    ivals.append(FunctionInterval(battle.unlureSuit, extraArgs=[suit]))
    ivals.append(__createSuitResetPosTrack(suit, battle))
    ivals.append(FunctionInterval(suit.loop, extraArgs=['neutral']))
    return Track(ivals)
    return
def __createSuitDamageTrack(battle, suit, hp, lure, trapProp):
    if (trapProp is None) or trapProp.isEmpty():
        return Func(suit.loop, 'lured')
    trapProp.wrtReparentTo(battle)
    trapTrack = ToontownBattleGlobals.TRAP_TRACK
    trapLevel = suit.battleTrap
    trapTrackNames = ToontownBattleGlobals.AvProps[trapTrack]
    trapName = trapTrackNames[trapLevel]
    result = Sequence()

    def reparentTrap(trapProp = trapProp, battle = battle):
        if trapProp and not trapProp.isEmpty():
            trapProp.wrtReparentTo(battle)

    result.append(Func(reparentTrap))
    parent = battle
    if suit.battleTrapIsFresh == 1:
        if trapName == 'quicksand' or trapName == 'trapdoor':
            trapProp.hide()
            trapProp.reparentTo(suit)
            trapProp.setPos(Point3(0, MovieUtil.SUIT_TRAP_DISTANCE, 0))
            trapProp.setHpr(Point3(0, 0, 0))
            trapProp.wrtReparentTo(battle)
        elif trapName == 'rake':
            trapProp.hide()
            trapProp.reparentTo(suit)
            trapProp.setPos(0, MovieUtil.SUIT_TRAP_RAKE_DISTANCE, 0)
            trapProp.setHpr(Point3(0, 270, 0))
            trapProp.setScale(Point3(0.7, 0.7, 0.7))
            rakeOffset = MovieUtil.getSuitRakeOffset(suit)
            trapProp.setY(trapProp.getY() + rakeOffset)
        else:
            parent = render
    if trapName == 'banana':
        slidePos = trapProp.getPos(parent)
        slidePos.setY(slidePos.getY() - 5.1)
        moveTrack = Sequence(Wait(0.1), LerpPosInterval(trapProp, 0.1, slidePos, other=battle))
        animTrack = Sequence(ActorInterval(trapProp, 'banana', startTime=3.1), Wait(1.1), LerpScaleInterval(trapProp, 1, Point3(0.01, 0.01, 0.01)))
        suitTrack = ActorInterval(suit, 'slip-backward')
        damageTrack = Sequence(Wait(0.5), Func(suit.showHpText, -hp, openEnded=0), Func(suit.updateHealthBar, hp))
        soundTrack = Sequence(SoundInterval(globalBattleSoundCache.getSound('AA_pie_throw_only.ogg'), duration=0.55, node=suit), SoundInterval(globalBattleSoundCache.getSound('Toon_bodyfall_synergy.ogg'), node=suit))
        result.append(Parallel(moveTrack, animTrack, suitTrack, damageTrack, soundTrack))
    elif trapName == 'rake' or trapName == 'rake-react':
        hpr = trapProp.getHpr(parent)
        upHpr = Vec3(hpr[0], 179.9999, hpr[2])
        bounce1Hpr = Vec3(hpr[0], 120, hpr[2])
        bounce2Hpr = Vec3(hpr[0], 100, hpr[2])
        rakeTrack = Sequence(Wait(0.5), LerpHprInterval(trapProp, 0.1, upHpr, startHpr=hpr), Wait(0.7), LerpHprInterval(trapProp, 0.4, hpr, startHpr=upHpr), LerpHprInterval(trapProp, 0.15, bounce1Hpr, startHpr=hpr), LerpHprInterval(trapProp, 0.05, hpr, startHpr=bounce1Hpr), LerpHprInterval(trapProp, 0.15, bounce2Hpr, startHpr=hpr), LerpHprInterval(trapProp, 0.05, hpr, startHpr=bounce2Hpr), Wait(0.2), LerpScaleInterval(trapProp, 0.2, Point3(0.01, 0.01, 0.01)))
        rakeAnimDuration = 3.125
        suitTrack = ActorInterval(suit, 'rake-react', duration=rakeAnimDuration)
        damageTrack = Sequence(Wait(0.5), Func(suit.showHpText, -hp, openEnded=0), Func(suit.updateHealthBar, hp))
        soundTrack = getSoundTrack('TL_step_on_rake.ogg', delay=0.6, node=suit)
        result.append(Parallel(rakeTrack, suitTrack, damageTrack, soundTrack))
    elif trapName == 'marbles':
        slidePos = trapProp.getPos(parent)
        slidePos.setY(slidePos.getY() - 6.5)
        moveTrack = Sequence(Wait(0.1), LerpPosInterval(trapProp, 0.8, slidePos, other=battle), Wait(1.1), LerpScaleInterval(trapProp, 1, Point3(0.01, 0.01, 0.01)))
        animTrack = ActorInterval(trapProp, 'marbles', startTime=3.1)
        suitTrack = ActorInterval(suit, 'slip-backward')
        damageTrack = Sequence(Wait(0.5), Func(suit.showHpText, -hp, openEnded=0), Func(suit.updateHealthBar, hp))
        soundTrack = Sequence(SoundInterval(globalBattleSoundCache.getSound('AA_pie_throw_only.ogg'), duration=0.55, node=suit), SoundInterval(globalBattleSoundCache.getSound('Toon_bodyfall_synergy.ogg'), node=suit))
        result.append(Parallel(moveTrack, animTrack, suitTrack, damageTrack, soundTrack))
    elif trapName == 'quicksand':
        sinkPos1 = trapProp.getPos(battle)
        sinkPos2 = trapProp.getPos(battle)
        dropPos = trapProp.getPos(battle)
        landPos = trapProp.getPos(battle)
        sinkPos1.setZ(sinkPos1.getZ() - 3.1)
        sinkPos2.setZ(sinkPos2.getZ() - 9.1)
        dropPos.setZ(dropPos.getZ() + 15)
        if base.config.GetBool('want-new-cogs', 0):
            nameTag = suit.find('**/def_nameTag')
        else:
            nameTag = suit.find('**/joint_nameTag')
        trapTrack = Sequence(Wait(2.4), LerpScaleInterval(trapProp, 0.8, Point3(0.01, 0.01, 0.01)))
        moveTrack = Sequence(Wait(0.9), LerpPosInterval(suit, 0.9, sinkPos1, other=battle), LerpPosInterval(suit, 0.4, sinkPos2, other=battle), Func(suit.setPos, battle, dropPos), Func(suit.wrtReparentTo, hidden), Wait(1.1), Func(suit.wrtReparentTo, battle), LerpPosInterval(suit, 0.3, landPos, other=battle))
        animTrack = Sequence(ActorInterval(suit, 'flail'), ActorInterval(suit, 'flail', startTime=1.1), Wait(0.7), ActorInterval(suit, 'slip-forward', duration=2.1))
        damageTrack = Sequence(Wait(3.5), Func(suit.showHpText, -hp, openEnded=0), Func(suit.updateHealthBar, hp))
        soundTrack = Sequence(Wait(0.7), SoundInterval(globalBattleSoundCache.getSound('TL_quicksand.ogg'), node=suit), Wait(0.1), SoundInterval(globalBattleSoundCache.getSound('Toon_bodyfall_synergy.ogg'), node=suit))
        result.append(Parallel(trapTrack, moveTrack, animTrack, damageTrack, soundTrack))
    elif trapName == 'trapdoor':
        sinkPos = trapProp.getPos(battle)
        dropPos = trapProp.getPos(battle)
        landPos = trapProp.getPos(battle)
        sinkPos.setZ(sinkPos.getZ() - 9.1)
        dropPos.setZ(dropPos.getZ() + 15)
        trapTrack = Sequence(Wait(2.4), LerpScaleInterval(trapProp, 0.8, Point3(0.01, 0.01, 0.01)))
        moveTrack = Sequence(
            Wait(2.2),
            LerpPosInterval(suit, 0.4, sinkPos, other=battle),
            Func(suit.setPos, battle, dropPos),
            Func(suit.wrtReparentTo, hidden),
            Wait(1.6), Func(suit.wrtReparentTo, battle), LerpPosInterval(suit, 0.3, landPos, other=battle))
        animTrack = Sequence(
            getSplicedLerpAnimsTrack(suit, 'flail', 0.7, 0.25),
            Func(trapProp.setColor, Vec4(0, 0, 0, 1)),
            ActorInterval(suit, 'flail', startTime=0.7, endTime=0),
            ActorInterval(suit, 'neutral', duration=0.5),
            ActorInterval(suit, 'flail', startTime=1.1),
            Wait(1.1),
            ActorInterval(suit, 'slip-forward', duration=2.1)
        )
        damageTrack = Sequence(Wait(3.5), Func(suit.showHpText, -hp, openEnded=0), Func(suit.updateHealthBar, hp))
        soundTrack = Sequence(Wait(0.8), SoundInterval(globalBattleSoundCache.getSound('TL_trap_door.ogg'), node=suit), Wait(0.8), SoundInterval(globalBattleSoundCache.getSound('Toon_bodyfall_synergy.ogg'), node=suit))
        result.append(Parallel(trapTrack, moveTrack, animTrack, damageTrack, soundTrack))
    elif trapName == 'tnt':
        tntTrack = ActorInterval(trapProp, 'tnt')
        explosionTrack = Sequence(Wait(2.3), createTNTExplosionTrack(battle, trapProp=trapProp, relativeTo=parent))
        flyPos = suit.getPos()
        flyPos.setZ(suit.getZ() + 17)
        dropPos = suit.getPos()
        oldCamera = base.camera.getPos()
        oldHPR = base.camera.getHpr()
        
        # Cog looks down and up
        suitTrack = Sequence(ActorInterval(suit, 'flail', duration=0.7))
        suitTrack.append(ActorInterval(suit, 'flail', startTime=0.7, endTime=0.0))
        suitTrack.append(ActorInterval(suit, 'neutral', duration=0.4))
        suitTrack.append(ActorInterval(suit, 'flail', startTime=0.6, endTime=0.7))
        
        if base.localAvatar in battle.activeToons:
            suitTrack.append(Parallel(base.camera.posHprInterval(
                             0.4, Point3(oldCamera[0], oldCamera[1], oldCamera[2]), Point3(0, 30, 0), blendType='easeInOut'),
                 Func(battle.movie.needRestoreColor),
                 Func(suit.setColorScale, Vec4(0.2, 0.2, 0.2, 1)),
                 Func(trapProp.reparentTo, hidden),
                 ActorInterval(suit, 'flail', startTime=0.9, duration=0.4, endTime=1.3),
                 LerpPosInterval(suit, 0.3, flyPos),
                 ))
        else:
            suitTrack.append(Parallel(
                 Func(battle.movie.needRestoreColor),
                 Func(suit.setColorScale, Vec4(0.2, 0.2, 0.2, 1)),
                 Func(trapProp.reparentTo, hidden),
                 ActorInterval(suit, 'flail', startTime=0.9),
                 LerpPosInterval(suit, 0.3, flyPos),
                 ))
        if suit.maxHP <= 42:
            suitTrack.append(midairSuitExplodeTrack(suit, battle))
            damageTrack = Sequence(Wait(2.4), Func(suit.showHpText, -hp, openEnded=0), Func(suit.updateHealthBar, hp))
            explosionSound = base.loadSfx('phase_3.5/audio/sfx/ENC_cogfall_apart.ogg')
            soundTrack = Sequence(
                SoundInterval(globalBattleSoundCache.getSound('TL_dynamite.ogg'), duration=2.0, node=suit),
                SoundInterval(explosionSound, duration=0.6, node=suit)
            )
        else:
            if base.localAvatar in battle.activeToons:
                suitTrack.append(Parallel(
                         Sequence(
                                  Wait(0.3), 
                                  base.camera.posHprInterval(
                                              0.5, Point3(*oldCamera), Point3(*oldHPR), blendType='easeInOut')
                                  ),
                         ActorInterval(suit, 'slip-backward', playRate=1),
                         LerpPosInterval(suit, 0.7, dropPos),
                    )
                )
            else:
                suitTrack.append(Parallel(
                          ActorInterval(suit, 'slip-backward', playRate=1),
                          LerpPosInterval(suit, 0.7, dropPos),
                          )
                )
            suitTrack.append(Func(suit.clearColorScale))
            suitTrack.append(Func(trapProp.sparksEffect.cleanup))
            suitTrack.append(Func(battle.movie.clearRestoreColor))

            damageTrack = Sequence(Wait(2.3), Func(suit.showHpText, -hp, openEnded=0), Func(suit.updateHealthBar, hp))
            explosionSound = base.loadSfx('phase_3.5/audio/sfx/ENC_cogfall_apart.ogg')
            soundTrack = Sequence(
                SoundInterval(globalBattleSoundCache.getSound('TL_dynamite.ogg'), duration=2.0, node=suit),
                SoundInterval(explosionSound, duration=0.6, node=suit)
            )
        result.append(Parallel(tntTrack, suitTrack, damageTrack, explosionTrack, soundTrack))

        if suit.maxHP <= 42:
            suit.battleTrapProp = trapProp
            result.append(Func(battle.removeTrap, suit, True))
            return result

    elif trapName == 'traintrack':
        trainInterval = createIncomingTrainInterval(battle, suit, hp, lure, trapProp)
        result.append(trainInterval)
    else:
        notify.warning('unknown trapName: %s detected on suit: %s' % (trapName, suit))
    suit.battleTrapProp = trapProp
    result.append(Func(battle.removeTrap, suit, True))
    result.append(Func(battle.unlureSuit, suit))
    result.append(__createSuitResetPosTrack(suit, battle))
    result.append(Func(suit.loop, 'neutral'))
    if trapName == 'traintrack':
        result.append(Func(MovieUtil.removeProp, trapProp))
    return result
Ejemplo n.º 7
0
def __createSuitDamageTrack(battle, suit, hp, lure, trapProp):
    if trapProp == None or trapProp.isEmpty():
        return Track([
            FunctionInterval(suit.loop, extraArgs = [
                'neutral'])])
    
    trapProp.wrtReparentTo(battle)
    trapTrack = ToontownBattleGlobals.TRAP_TRACK
    trapLevel = suit.battleTrap
    trapTrackNames = ToontownBattleGlobals.AvProps[trapTrack]
    trapName = trapTrackNames[trapLevel]
    ivals = []
    
    def reparentTrap(trapProp = trapProp, battle = battle):
        trapProp.wrtReparentTo(battle)

    ivals.append(FunctionInterval(reparentTrap))
    parent = battle
    if suit.battleTrapIsFresh == 1:
        if trapName == 'quicksand' or trapName == 'trapdoor':
            trapProp.hide()
            trapProp.reparentTo(suit)
            trapProp.setPos(Point3(0, MovieUtil.SUIT_TRAP_DISTANCE, 0))
            trapProp.setHpr(Point3(0, 0, 0))
            trapProp.wrtReparentTo(battle)
        elif trapName == 'rake':
            trapProp.hide()
            trapProp.reparentTo(suit)
            trapProp.setPos(0, MovieUtil.SUIT_TRAP_RAKE_DISTANCE, 0)
            trapProp.setHpr(Point3(0, 270, 0))
            trapProp.setScale(Point3(0.69999999999999996, 0.69999999999999996, 0.69999999999999996))
            rakeOffset = MovieUtil.getSuitRakeOffset(suit)
            trapProp.setY(trapProp.getY() + rakeOffset)
        else:
            parent = render
    
    if trapName == 'banana':
        slidePos = trapProp.getPos(parent)
        slidePos.setY(slidePos.getY() - 5.0999999999999996)
        moveTrack = Track([
            WaitInterval(0.10000000000000001),
            LerpPosInterval(trapProp, 0.10000000000000001, slidePos, other = battle)])
        animTrack = Track([
            ActorInterval(trapProp, 'banana', startTime = 3.1000000000000001),
            WaitInterval(1.1000000000000001),
            LerpScaleInterval(trapProp, 1, Point3(0.01, 0.01, 0.01))])
        suitTrack = Track([
            ActorInterval(suit, 'slip-backward')])
        damageTrack = Track([
            WaitInterval(0.5),
            FunctionInterval(suit.showLaffNumber, openEnded = 0, extraArgs = [
                -hp]),
            FunctionInterval(suit.updateHealthBar, extraArgs = [
                hp])])
        soundTrack = Track([
            SoundInterval(globalBattleSoundCache.getSound('AA_pie_throw_only.mp3'), duration = 0.55000000000000004, node = suit),
            SoundInterval(globalBattleSoundCache.getSound('Toon_bodyfall_synergy.mp3'), node = suit)])
        ivals.append(MultiTrack([
            moveTrack,
            animTrack,
            suitTrack,
            damageTrack,
            soundTrack]))
    elif trapName == 'rake' or trapName == 'rake-react':
        hpr = trapProp.getHpr(parent)
        upHpr = Vec3(hpr[0], 179.9999, hpr[2])
        bounce1Hpr = Vec3(hpr[0], 120, hpr[2])
        bounce2Hpr = Vec3(hpr[0], 100, hpr[2])
        rakeTrack = Track([
            WaitInterval(0.5),
            LerpHprInterval(trapProp, 0.10000000000000001, upHpr, startHpr = hpr),
            WaitInterval(0.69999999999999996),
            LerpHprInterval(trapProp, 0.40000000000000002, hpr, startHpr = upHpr),
            LerpHprInterval(trapProp, 0.14999999999999999, bounce1Hpr, startHpr = hpr),
            LerpHprInterval(trapProp, 0.050000000000000003, hpr, startHpr = bounce1Hpr),
            LerpHprInterval(trapProp, 0.14999999999999999, bounce2Hpr, startHpr = hpr),
            LerpHprInterval(trapProp, 0.050000000000000003, hpr, startHpr = bounce2Hpr),
            WaitInterval(0.20000000000000001),
            LerpScaleInterval(trapProp, 0.20000000000000001, Point3(0.01, 0.01, 0.01))])
        rakeAnimDuration = 3.125
        suitTrack = Track([
            ActorInterval(suit, 'rake-react', duration = rakeAnimDuration)])
        damageTrack = Track([
            WaitInterval(0.5),
            FunctionInterval(suit.showLaffNumber, openEnded = 0, extraArgs = [
                -hp]),
            FunctionInterval(suit.updateHealthBar, extraArgs = [
                hp])])
        soundTrack = getSoundTrack('TL_step_on_rake.mp3', delay = 0.59999999999999998, node = suit)
        ivals.append(MultiTrack([
            rakeTrack,
            suitTrack,
            damageTrack,
            soundTrack]))
    elif trapName == 'marbles':
        slidePos = trapProp.getPos(parent)
        slidePos.setY(slidePos.getY() - 6.5)
        moveTrack = Track([
            WaitInterval(0.10000000000000001),
            LerpPosInterval(trapProp, 0.80000000000000004, slidePos, other = battle),
            WaitInterval(1.1000000000000001),
            LerpScaleInterval(trapProp, 1, Point3(0.01, 0.01, 0.01))])
        animTrack = Track([
            ActorInterval(trapProp, 'marbles', startTime = 3.1000000000000001)])
        suitTrack = Track([
            ActorInterval(suit, 'slip-backward')])
        damageTrack = Track([
            WaitInterval(0.5),
            FunctionInterval(suit.showLaffNumber, openEnded = 0, extraArgs = [
                -hp]),
            FunctionInterval(suit.updateHealthBar, extraArgs = [
                hp])])
        soundTrack = Track([
            SoundInterval(globalBattleSoundCache.getSound('AA_pie_throw_only.mp3'), duration = 0.55000000000000004, node = suit),
            SoundInterval(globalBattleSoundCache.getSound('Toon_bodyfall_synergy.mp3'), node = suit)])
        ivals.append(MultiTrack([
            moveTrack,
            animTrack,
            suitTrack,
            damageTrack,
            soundTrack]))
    elif trapName == 'quicksand':
        sinkPos1 = trapProp.getPos(battle)
        sinkPos2 = trapProp.getPos(battle)
        dropPos = trapProp.getPos(battle)
        landPos = trapProp.getPos(battle)
        sinkPos1.setZ(sinkPos1.getZ() - 3.1000000000000001)
        sinkPos2.setZ(sinkPos2.getZ() - 9.0999999999999996)
        dropPos.setZ(dropPos.getZ() + 15)
        nameTag = suit.find('**/joint-nameTag')
        trapTrack = Track([
            WaitInterval(2.3999999999999999),
            LerpScaleInterval(trapProp, 0.80000000000000004, Point3(0.01, 0.01, 0.01))])
        moveTrack = Track([
            WaitInterval(0.90000000000000002),
            LerpPosInterval(suit, 0.90000000000000002, sinkPos1, other = battle),
            LerpPosInterval(suit, 0.40000000000000002, sinkPos2, other = battle),
            FunctionInterval(suit.setPos, extraArgs = [
                battle,
                dropPos]),
            FunctionInterval(suit.wrtReparentTo, extraArgs = [
                hidden]),
            WaitInterval(1.1000000000000001),
            FunctionInterval(suit.wrtReparentTo, extraArgs = [
                battle]),
            LerpPosInterval(suit, 0.29999999999999999, landPos, other = battle)])
        animTrack = Track([
            ActorInterval(suit, 'flail'),
            ActorInterval(suit, 'flail', startTime = 1.1000000000000001),
            WaitInterval(0.69999999999999996),
            ActorInterval(suit, 'slip-forward', duration = 2.1000000000000001)])
        damageTrack = Track([
            WaitInterval(3.5),
            FunctionInterval(suit.showLaffNumber, openEnded = 0, extraArgs = [
                -hp]),
            FunctionInterval(suit.updateHealthBar, extraArgs = [
                hp])])
        soundTrack = Track([
            WaitInterval(0.69999999999999996),
            SoundInterval(globalBattleSoundCache.getSound('TL_quicksand.mp3'), node = suit),
            WaitInterval(0.10000000000000001),
            SoundInterval(globalBattleSoundCache.getSound('Toon_bodyfall_synergy.mp3'), node = suit)])
        ivals.append(MultiTrack([
            trapTrack,
            moveTrack,
            animTrack,
            damageTrack,
            soundTrack]))
    elif trapName == 'trapdoor':
        sinkPos = trapProp.getPos(battle)
        dropPos = trapProp.getPos(battle)
        landPos = trapProp.getPos(battle)
        sinkPos.setZ(sinkPos.getZ() - 9.0999999999999996)
        dropPos.setZ(dropPos.getZ() + 15)
        trapTrack = Track([
            WaitInterval(2.3999999999999999),
            LerpScaleInterval(trapProp, 0.80000000000000004, Point3(0.01, 0.01, 0.01))])
        moveTrack = Track([
            WaitInterval(2.2000000000000002),
            LerpPosInterval(suit, 0.40000000000000002, sinkPos, other = battle),
            FunctionInterval(suit.setPos, extraArgs = [
                battle,
                dropPos]),
            FunctionInterval(suit.wrtReparentTo, extraArgs = [
                hidden]),
            WaitInterval(1.6000000000000001),
            FunctionInterval(suit.wrtReparentTo, extraArgs = [
                battle]),
            LerpPosInterval(suit, 0.29999999999999999, landPos, other = battle)])
        animIvals = []
        animIvals.extend(getSplicedLerpAnims(suit, 'flail', 0.69999999999999996, 0.25))
        animIvals.append(FunctionInterval(trapProp.setColor, extraArgs = [
            Vec4(0, 0, 0, 1)]))
        animIvals.append(ActorInterval(suit, 'flail', startTime = 0.69999999999999996, endTime = 0))
        animIvals.append(ActorInterval(suit, 'neutral', duration = 0.5))
        animIvals.append(ActorInterval(suit, 'flail', startTime = 1.1000000000000001))
        animIvals.append(WaitInterval(1.1000000000000001))
        animIvals.append(ActorInterval(suit, 'slip-forward', duration = 2.1000000000000001))
        animTrack = Track(animIvals)
        damageTrack = Track([
            WaitInterval(3.5),
            FunctionInterval(suit.showLaffNumber, openEnded = 0, extraArgs = [
                -hp]),
            FunctionInterval(suit.updateHealthBar, extraArgs = [
                hp])])
        soundTrack = Track([
            WaitInterval(0.80000000000000004),
            SoundInterval(globalBattleSoundCache.getSound('TL_trap_door.mp3'), node = suit),
            WaitInterval(0.80000000000000004),
            SoundInterval(globalBattleSoundCache.getSound('Toon_bodyfall_synergy.mp3'), node = suit)])
        ivals.append(MultiTrack([
            trapTrack,
            moveTrack,
            animTrack,
            damageTrack,
            soundTrack]))
    elif trapName == 'tnt':
        tntTrack = Track([
            ActorInterval(trapProp, 'tnt')])
        explosionIvals = []
        explosionIvals.append(WaitInterval(2.2999999999999998))
        explosionIvals.extend(createTNTExplosionIvals(battle, trapProp = trapProp, relativeTo = parent))
        explosionTrack = Track(explosionIvals)
        suitTrack = Track([
            ActorInterval(suit, 'flail', duration = 0.69999999999999996),
            ActorInterval(suit, 'flail', startTime = 0.69999999999999996, endTime = 0.0),
            ActorInterval(suit, 'neutral', duration = 0.40000000000000002),
            ActorInterval(suit, 'flail', startTime = 0.59999999999999998, endTime = 0.69999999999999996),
            WaitInterval(0.40000000000000002),
            ActorInterval(suit, 'slip-forward', startTime = 2.48, duration = 0.10000000000000001),
            FunctionInterval(battle.movie.needRestoreColor),
            FunctionInterval(suit.setColorScale, extraArgs = [
                Vec4(0, 0, 0, 1)]),
            FunctionInterval(trapProp.reparentTo, extraArgs = [
                hidden]),
            ActorInterval(suit, 'slip-forward', startTime = 2.5800000000000001),
            FunctionInterval(suit.clearColorScale),
            FunctionInterval(trapProp.sparksEffect.cleanup),
            FunctionInterval(battle.movie.clearRestoreColor)])
        damageTrack = Track([
            WaitInterval(2.2999999999999998),
            FunctionInterval(suit.showLaffNumber, openEnded = 0, extraArgs = [
                -hp]),
            FunctionInterval(suit.updateHealthBar, extraArgs = [
                hp])])
        explosionSound = base.loadSfx('phase_3.5/audio/sfx/ENC_cogfall_apart.mp3')
        soundTrack = Track([
            SoundInterval(globalBattleSoundCache.getSound('TL_dynamite.mp3'), duration = 2.0, node = suit),
            SoundInterval(explosionSound, duration = 0.59999999999999998, node = suit)])
        ivals.append(MultiTrack([
            tntTrack,
            suitTrack,
            damageTrack,
            explosionTrack,
            soundTrack]))
    else:
        notify.warning('unknown trapName: %s detected on suit: %s' % trapName, suit)
    suit.battleTrapProp = trapProp
    ivals.append(FunctionInterval(battle.removeTrap, extraArgs = [
        suit]))
    ivals.append(FunctionInterval(battle.unlureSuit, extraArgs = [
        suit]))
    ivals.append(__createSuitResetPosTrack(suit, battle))
    ivals.append(FunctionInterval(suit.loop, extraArgs = [
        'neutral']))
    return Track(ivals)
Ejemplo n.º 8
0
def __createSuitDamageTrack(battle, suit, hp, lure, trapProp):
    """ __createSuitDamageIvals(suit, hp, battle)
    """
    # This function creates intervals for the suit taking damage
    # If trapProp doesn't exist, do nothing, with no reaction
    #import pdb; pdb.set_trace()
    if ((trapProp == None) or trapProp.isEmpty()):
         return Func(suit.loop, 'neutral')
    
    # Make sure to leave the trapProp in place (not parented to the suit)
    # while the suit performs its animation
    trapProp.wrtReparentTo(battle)

    # Now we learn which level trap we're using to use the appropriate suit reaction
    trapTrack = ToontownBattleGlobals.TRAP_TRACK
    trapLevel = suit.battleTrap
    trapTrackNames = ToontownBattleGlobals.AvProps[trapTrack]
    trapName = trapTrackNames[trapLevel]

    result = Sequence()
    def reparentTrap(trapProp=trapProp, battle=battle):
        if trapProp and not trapProp.isEmpty():
            trapProp.wrtReparentTo(battle)
    result.append(Func(reparentTrap))

    # Now detect if our trap was just thrown in this round, or leftover from before.
    # If just thrown, our cordinates for the banana, marbles, and tnt will be based off of
    # render, not battle, thus we make parent equal to render instead of the default battle.
    # And if the trap is fresh and is the quicksand, trapdoor, or rake, we create a hidden
    # dummy trapProp in the right position to obtain the correct coordinates for those
    # animations.
    parent = battle
    if (suit.battleTrapIsFresh == 1):
        if (trapName == 'quicksand' or trapName == 'trapdoor'):
            trapProp.hide()
            trapProp.reparentTo(suit)
            trapProp.setPos(Point3(0, MovieUtil.SUIT_TRAP_DISTANCE, 0))
            trapProp.setHpr(Point3(0, 0, 0))
            trapProp.wrtReparentTo(battle)
        elif (trapName == 'rake'):
            trapProp.hide()
            trapProp.reparentTo(suit)
            trapProp.setPos(0, MovieUtil.SUIT_TRAP_RAKE_DISTANCE, 0)
            # reorient the rake correctly to be stepped on
            trapProp.setHpr(Point3(0, 270, 0))
            trapProp.setScale(Point3(0.7, 0.7, 0.7))
            # The rake must be a specific distance from each suit for that
            # suit to be able to walk into the rake
            rakeOffset = MovieUtil.getSuitRakeOffset(suit)
            trapProp.setY(trapProp.getY() + rakeOffset)
        else:
            parent = render
    
    # Now decide which trap this is and use the different suit animation reactions
    if (trapName == 'banana'):
        slidePos = trapProp.getPos(parent)
        slidePos.setY(slidePos.getY() - 5.1)
        moveTrack = Sequence(
            Wait(0.1), # Wait before sliding the peel
            LerpPosInterval(trapProp, 0.1, slidePos, other=battle),
            )
        animTrack = Sequence(
            ActorInterval(trapProp, 'banana', startTime=3.1), # Animate banana spinning
            Wait(1.1), # Wait a bit before scaling banana away
            LerpScaleInterval(trapProp, 1, Point3(0.01, 0.01, 0.01)),
            )
        suitTrack = ActorInterval(suit, 'slip-backward')
        damageTrack = Sequence(
            Wait(0.5),
            Func(suit.showHpText, -hp, openEnded=0),
            Func(suit.updateHealthBar, hp),
            )
        soundTrack = Sequence(
            SoundInterval(globalBattleSoundCache.getSound('AA_pie_throw_only.mp3'), duration=0.55, node=suit),
            SoundInterval(globalBattleSoundCache.getSound('Toon_bodyfall_synergy.mp3'), node=suit),
            )
        result.append(Parallel(moveTrack, animTrack, suitTrack, damageTrack, soundTrack))
    elif ((trapName == 'rake') or (trapName == 'rake-react')):
        # Also need to make the rake pop up when stepped on, then fall back down
        hpr = trapProp.getHpr(parent)
        upHpr = Vec3(hpr[0], 179.9999, hpr[2])
        bounce1Hpr = Vec3(hpr[0], 120, hpr[2])
        bounce2Hpr = Vec3(hpr[0], 100, hpr[2])
                    
        rakeTrack = Sequence(
            Wait(0.5),
            LerpHprInterval(trapProp, 0.1, upHpr, startHpr=hpr),
            Wait(0.7),
            LerpHprInterval(trapProp, 0.4, hpr, startHpr=upHpr),
            LerpHprInterval(trapProp, 0.15, bounce1Hpr, startHpr=hpr),
            LerpHprInterval(trapProp, 0.05, hpr, startHpr=bounce1Hpr),
            LerpHprInterval(trapProp, 0.15, bounce2Hpr, startHpr=hpr),
            LerpHprInterval(trapProp, 0.05, hpr, startHpr=bounce2Hpr),
            Wait(0.2),
            LerpScaleInterval(trapProp, 0.2, Point3(0.01, 0.01, 0.01)),
            )
        rakeAnimDuration = 3.125
        suitTrack = ActorInterval(suit, 'rake-react',
                                  duration=rakeAnimDuration)
        damageTrack = Sequence(
            Wait(0.5),
            Func(suit.showHpText, -hp, openEnded=0),
            Func(suit.updateHealthBar, hp),
            )
        soundTrack = getSoundTrack('TL_step_on_rake.mp3', delay=0.6, node=suit)
        result.append(Parallel(rakeTrack, suitTrack, damageTrack, soundTrack))
    elif (trapName == 'marbles'):
        slidePos = trapProp.getPos(parent)
        slidePos.setY(slidePos.getY() - 6.5)
        moveTrack = Sequence(
            Wait(0.1), # Wait a bit before sliding the marbles
            LerpPosInterval(trapProp, 0.8, slidePos, other=battle),
            Wait(1.1),
            LerpScaleInterval(trapProp, 1, Point3(0.01, 0.01, 0.01)),
            )
        animTrack = ActorInterval(trapProp, 'marbles', startTime=3.1)
        suitTrack = ActorInterval(suit, 'slip-backward')
        damageTrack = Sequence(
            Wait(0.5),
            Func(suit.showHpText, -hp, openEnded=0),
            Func(suit.updateHealthBar, hp),
            )
        soundTrack = Sequence(
            SoundInterval(globalBattleSoundCache.getSound('AA_pie_throw_only.mp3'), duration=0.55, node=suit),
            SoundInterval(globalBattleSoundCache.getSound('Toon_bodyfall_synergy.mp3'), node=suit),
            )
        result.append(Parallel(moveTrack, animTrack, suitTrack, damageTrack, soundTrack))
    elif (trapName == 'quicksand'):
        sinkPos1 = trapProp.getPos(battle)
        sinkPos2 = trapProp.getPos(battle)
        dropPos = trapProp.getPos(battle) # Where suit drops from after the quicksand
        landPos = trapProp.getPos(battle) # Where the suit lands from the drop
        sinkPos1.setZ(sinkPos1.getZ() - 3.1)
        sinkPos2.setZ(sinkPos2.getZ() - 9.1)
        dropPos.setZ(dropPos.getZ() + 15)

        # We grab the name tag so we can hide it while the suit is in the quicksand
        nameTag = suit.find("**/joint_nameTag")
        trapTrack = Sequence(
            Wait(2.4),
            LerpScaleInterval(trapProp, 0.8, Point3(0.01, 0.01, 0.01)),
            )
        moveTrack = Sequence(
            Wait(0.9), # Wait before starting to sink
            LerpPosInterval(suit, 0.9, sinkPos1, other=battle), # Start to sink a bit
            LerpPosInterval(suit, 0.4, sinkPos2, other=battle), # Fall in quicksand
            Func(suit.setPos, battle, dropPos),
            Func(suit.wrtReparentTo, hidden),
            Wait(1.1), # Wait while stuck in the quicksand
            Func(suit.wrtReparentTo, battle),
            LerpPosInterval(suit, 0.3, landPos, other=battle), # Drop back down
            )
        animTrack = Sequence(
            ActorInterval(suit, 'flail'),
            ActorInterval(suit, 'flail', startTime=1.1),
            Wait(0.7),
            ActorInterval(suit, 'slip-forward', duration=2.1),
            )
        damageTrack = Sequence(
            Wait(3.5),
            Func(suit.showHpText, -hp, openEnded=0),
            Func(suit.updateHealthBar, hp),
            )
        soundTrack = Sequence(
            Wait(0.7),
            SoundInterval(globalBattleSoundCache.getSound('TL_quicksand.mp3'), node=suit),
            Wait(0.1),
            SoundInterval(globalBattleSoundCache.getSound('Toon_bodyfall_synergy.mp3'), node=suit),
            )
        result.append(Parallel(trapTrack, moveTrack, animTrack, damageTrack, soundTrack))
    elif (trapName == 'trapdoor'):
        sinkPos = trapProp.getPos(battle)
        dropPos = trapProp.getPos(battle) # Where suit drops from after the trap door
        landPos = trapProp.getPos(battle) # Where the suit lands from the drop
        sinkPos.setZ(sinkPos.getZ() - 9.1)
        dropPos.setZ(dropPos.getZ() + 15)
        
        trapTrack = Sequence(
            Wait(2.4),
            LerpScaleInterval(trapProp, 0.8, Point3(0.01, 0.01, 0.01))
            )
        moveTrack = Sequence(
            Wait(2.2), # Wait before falling through the trap door
            LerpPosInterval(suit, 0.4, sinkPos, other=battle), # Fall through trap door
            Func(suit.setPos, battle, dropPos),
            Func(suit.wrtReparentTo, hidden),
            Wait(1.6), # Wait while through the trap door
            Func(suit.wrtReparentTo, battle),
            LerpPosInterval(suit, 0.3, landPos, other=battle), # Drop back down
            )

        animTrack = Sequence(
            # Suit quickly looks down
            getSplicedLerpAnimsTrack(suit, 'flail', 0.7, 0.25),
            # Spring the trap door (make it go black)
            Func(trapProp.setColor, Vec4(0, 0, 0, 1)),
            # Suit slowly looks back up with resignation
            ActorInterval(suit, 'flail', startTime=0.7, endTime=0),
            # Suspenseful wait
            ActorInterval(suit, 'neutral', duration=0.5),
            # Suit falls through the trap door
            ActorInterval(suit, 'flail', startTime=1.1),
            Wait(1.1),
            ActorInterval(suit, 'slip-forward', duration=2.1),
            )

        damageTrack = Sequence(
            Wait(3.5),
            Func(suit.showHpText, -hp, openEnded=0),
            Func(suit.updateHealthBar, hp),
            )
        soundTrack = Sequence(
            Wait(0.8),
            SoundInterval(globalBattleSoundCache.getSound('TL_trap_door.mp3'), node=suit),
            Wait(0.8),
            SoundInterval(globalBattleSoundCache.getSound('Toon_bodyfall_synergy.mp3'), node=suit),
            )
        result.append(Parallel(trapTrack, moveTrack, animTrack, damageTrack, soundTrack))
    elif (trapName == 'tnt'):
        tntTrack = ActorInterval(trapProp, 'tnt')
        explosionTrack = Sequence(
            Wait(2.3),
            createTNTExplosionTrack(battle, trapProp=trapProp,
                                    relativeTo=parent),
            )
        suitTrack = Sequence(
            ActorInterval(suit, 'flail', duration=0.7),
            ActorInterval(suit, 'flail', startTime=0.7, endTime=0.0),
            ActorInterval(suit, 'neutral', duration=0.4),
            ActorInterval(suit, 'flail', startTime=0.6, endTime=0.7),
            Wait(0.4),
            ActorInterval(suit, 'slip-forward', startTime=2.48, duration=0.1),
            Func(battle.movie.needRestoreColor),
            Func(suit.setColorScale, Vec4(0, 0, 0, 1)),
            Func(trapProp.reparentTo, hidden),
            ActorInterval(suit, 'slip-forward', startTime=2.58),
            Func(suit.clearColorScale),
            Func(trapProp.sparksEffect.cleanup),
            Func(battle.movie.clearRestoreColor),
            )
        damageTrack = Sequence(
            Wait(2.3),
            Func(suit.showHpText, -hp, openEnded=0),
            Func(suit.updateHealthBar, hp),
            )
        explosionSound = base.loadSfx("phase_3.5/audio/sfx/ENC_cogfall_apart.mp3")
        soundTrack = Sequence(
            SoundInterval(globalBattleSoundCache.getSound('TL_dynamite.mp3'), duration=2.0, node=suit),
            SoundInterval(explosionSound, duration=0.6, node=suit),
            )
        result.append(Parallel(tntTrack, suitTrack, damageTrack,
                              explosionTrack, soundTrack))

    elif trapName == 'traintrack':
        trainInterval = createIncomingTrainInterval(battle, suit, hp, lure, trapProp)
        result.append(trainInterval) 
    else:
        notify.warning('unknown trapName: %s detected on suit: %s' % (trapName, suit))
        
    suit.battleTrapProp = trapProp
    assert notify.debug('adding battle.removeTrap for suit %d' % suit.doId)
    result.append(Func(battle.removeTrap, suit, True))
    result.append(Func(battle.unlureSuit, suit))
    result.append(__createSuitResetPosTrack(suit, battle))
    result.append(Func(suit.loop, 'neutral'))

    if trapName == 'traintrack':
        #a bit of a hack, when a suit is joining, the train track still stays, really make sure it goes away
        #TODO this nukes the train tunnels shrinking, figure out a better way
        result.append(Func(MovieUtil.removeProp, trapProp))    

    return result