def __createPlacedGroupTrapTrack(
        trap,
        prop,
        propName,
        centerSuit,
        propPos=None,
        propHpr=None,
        explode=0):
    toon = trap['toon']
    if 'npc' in trap:
        toon = trap['npc']
    level = trap['level']
    battle = trap['battle']
    origHpr = toon.getHpr(battle)
    trapPoint = Point3(0, 5 - MovieUtil.SUIT_TRAP_DISTANCE, 0.025)
    trapDelay = 2.5
    hands = toon.getLeftHands()

    def placeDustExplosion(dustNode, trapProp, battle):
        dustNode.reparentTo(battle)
        dustNode.setPos(trapProp.getPos(battle))

    trapTracks = Parallel()
    firstTime = 1
    targets = trap['target']
    if True:
        suit = centerSuit
        suitPos = suit.getPos(battle)
        targetPos = suitPos
        trapProp = MovieUtil.copyProp(prop)
        showThisTrap = True
        trapTrack = Sequence()
        trapTrack.append(Wait(trapDelay))
        if showThisTrap:
            notify.debug(
                'showing trap %s for %d' %
                (trapProp.getName(), suit.doId))
            trapTrack.append(Func(trapProp.show))
        else:
            notify.debug(
                'hiding trap %s for %d' %
                (trapProp.getName(), suit.doId))
            trapTrack.append(Func(trapProp.hide))
        trapTrack.append(Func(trapProp.setScale, Point3(0.1, 0.1, 0.1)))
        trapTrack.append(Func(trapProp.reparentTo, battle))
        trapTrack.append(Func(trapProp.setPos, trapPoint))
        trapTrack.append(Func(trapProp.setH, 0))
        trapTrack.append(
            LerpScaleInterval(
                trapProp, 1.2, Point3(
                    1.0, 1.0, 1.0)))
        if explode == 1:
            dustNode = hidden.attachNewNode('DustNode')
            removeTrapsParallel = Parallel()
            oneTrapTrack = Sequence()
            oneTrapTrack.append(Func(trapProp.wrtReparentTo, hidden))
            oneTrapTrack.append(
                Func(
                    placeDustExplosion,
                    dustNode,
                    trapProp,
                    battle))
            oneTrapTrack.append(
                createCartoonExplosionTrack(
                    dustNode, 'dust', explosionPoint=Point3(
                        0, 0, 0)))
            oneTrapTrack.append(Func(MovieUtil.removeProp, trapProp))
            removeTrapsParallel.append(oneTrapTrack)
            for target in trap['target']:
                otherSuit = target['suit']
                if otherSuit.battleTrapProp:
                    otherDustNode = hidden.attachNewNode('DustNodeOtherSuit')
                    otherTrapTrack = Sequence()
                    otherTrapTrack.append(
                        Func(
                            otherSuit.battleTrapProp.wrtReparentTo,
                            hidden))
                    otherTrapTrack.append(
                        Func(
                            placeDustExplosion,
                            dustNode,
                            otherSuit.battleTrapProp,
                            battle))
                    otherTrapTrack.append(
                        createCartoonExplosionTrack(
                            otherDustNode, 'dust',
                            explosionPoint=Point3(0, 0, 0)))
                    otherTrapTrack.append(Func(battle.removeTrap, otherSuit))
                    removeTrapsParallel.append(otherTrapTrack)

            trapTrack.append(removeTrapsParallel)
        else:
            if suit.battleTrap != NO_TRAP:
                notify.debug(
                    'trapSuit() - trap: %d destroyed existing trap: %d' %
                    (level, suit.battleTrap))
                battle.removeTrap(suit)
            suit.battleTrapProp = trapProp
            suit.battleTrap = level
            suit.battleTrapIsFresh = 1
            unlureSuits = Parallel()
            for target in targets:
                kbbonus = target['kbbonus']
                if kbbonus == 0:
                    unluredSuit = target['suit']
                    suitTrack = Sequence()
                    suitTrack.append(
                        createSuitResetPosTrack(
                            unluredSuit, battle))
                    suitTrack.append(Func(battle.unlureSuit, unluredSuit))
                    unlureSuits.append(suitTrack)

            trapTrack.append(unlureSuits)
            for otherSuit in battle.suits:
                if not otherSuit == suit:
                    if otherSuit.battleTrap != NO_TRAP:
                        notify.debug(
                            'trapSuit() - trap: %d destroyed existing trap: %d' %
                            (level, suit.battleTrap))
                        battle.removeTrap(otherSuit)
                    otherSuit.battleTrapProp = trapProp
                    otherSuit.battleTrap = level
                    otherSuit.battleTrapIsFresh = 1

        trapTracks.append(trapTrack)
    button = globalPropPool.getProp('button')
    button2 = MovieUtil.copyProp(button)
    buttons = [button, button2]
    toonTrack = Sequence()
    toonTrack.append(Func(MovieUtil.showProps, buttons, hands))
    toonTrack.append(Func(toon.headsUp, battle, suitPos))
    toonTrack.append(ActorInterval(toon, 'pushbutton'))
    toonTrack.append(Func(MovieUtil.removeProps, buttons))
    toonTrack.append(Func(toon.loop, 'neutral'))
    toonTrack.append(Func(toon.setHpr, battle, origHpr))
    if propName == 'quicksand':
        propSound = globalBattleSoundCache.getSound('TL_quicksand.ogg')
    elif propName == 'traintrack':
        propSound = globalBattleSoundCache.getSound(
            'TL_train_track_appear.ogg')
    else:
        propSound = globalBattleSoundCache.getSound('TL_trap_door.ogg')
    buttonSound = globalBattleSoundCache.getSound('AA_drop_trigger_box.ogg')
    soundTrack = Sequence(
        Wait(2.3), Parallel(
            SoundInterval(
                buttonSound, duration=0.67, node=toon), SoundInterval(
                propSound, node=toon)))
    return Parallel(trapTracks, toonTrack, soundTrack)
Beispiel #2
0
def __createPlacedGroupTrapTrack(trap, prop, propName, centerSuit, propPos=None, propHpr=None, explode=0):
    toon = trap['toon']
    if trap.has_key('npc'):
        toon = trap['npc']
    level = trap['level']
    battle = trap['battle']
    origHpr = toon.getHpr(battle)
    trapPoint = Point3(0, 5 - MovieUtil.SUIT_TRAP_DISTANCE, 0.025)
    trapDelay = 2.5
    if toon.isDisguised:
        hands = toon.suit.getLeftHands()
    else:
        hands = toon.getLeftHands()

    def placeDustExplosion(dustNode, trapProp, battle):
        dustNode.reparentTo(battle)
        dustNode.setPos(trapProp.getPos(battle))

    trapTracks = Parallel()
    firstTime = 1
    targets = trap['target']
    scale = 1
    if len(targets) >= 5 and propName == 'traintrack':
        scale = 2
    if True:
        suit = centerSuit
        suitPos = suit.getPos(battle)
        targetPos = suitPos
        trapProp = MovieUtil.copyProp(prop)
        showThisTrap = True
        trapTrack = Sequence()
        trapTrack.append(Wait(trapDelay))
        if showThisTrap:
            notify.debug('showing trap %s for %d' % (trapProp.getName(), suit.doId))
            trapTrack.append(Func(trapProp.show))
        else:
            notify.debug('hiding trap %s for %d' % (trapProp.getName(), suit.doId))
            trapTrack.append(Func(trapProp.hide))
        trapTrack.append(Func(trapProp.setScale, Point3(0.1, 0.1, 0.1) * scale))
        trapTrack.append(Func(trapProp.reparentTo, battle))
        trapTrack.append(Func(trapProp.setPos, trapPoint))
        trapTrack.append(Func(trapProp.setH, 0))
        trapTrack.append(LerpScaleInterval(trapProp, 1.2, Point3(1.0, 1.0, 1.0) * scale))
        if explode == 1:
            dustNode = hidden.attachNewNode('DustNode')
            removeTrapsParallel = Parallel()
            oneTrapTrack = Sequence()
            oneTrapTrack.append(Func(trapProp.wrtReparentTo, hidden))
            oneTrapTrack.append(Func(placeDustExplosion, dustNode, trapProp, battle))
            oneTrapTrack.append(createCartoonExplosionTrack(dustNode, 'dust', explosionPoint=Point3(0, 0, 0)))
            oneTrapTrack.append(Func(MovieUtil.removeProp, trapProp))
            removeTrapsParallel.append(oneTrapTrack)
            for target in trap['target']:
                otherSuit = target['suit']
                if otherSuit.battleTrapProp:
                    otherDustNode = hidden.attachNewNode('DustNodeOtherSuit')
                    otherTrapTrack = Sequence()
                    otherTrapTrack.append(Func(otherSuit.battleTrapProp.wrtReparentTo, hidden))
                    otherTrapTrack.append(Func(placeDustExplosion, dustNode, otherSuit.battleTrapProp, battle))
                    otherTrapTrack.append(createCartoonExplosionTrack(otherDustNode, 'dust', explosionPoint=Point3(0, 0, 0)))
                    otherTrapTrack.append(Func(battle.removeTrap, otherSuit))
                    removeTrapsParallel.append(otherTrapTrack)

            trapTrack.append(removeTrapsParallel)
        else:
            if suit.battleTrap != NO_TRAP:
                notify.debug('trapSuit() - trap: %d destroyed existing trap: %d' % (level, suit.battleTrap))
                battle.removeTrap(suit)
            suit.battleTrapProp = trapProp
            suit.battleTrap = level
            suit.battleTrapIsFresh = 1
            unlureSuits = Parallel()
            for target in targets:
                kbbonus = target['kbbonus']
                if kbbonus == 0:
                    unluredSuit = target['suit']
                    suitTrack = Sequence()
                    suitTrack.append(createSuitResetPosTrack(unluredSuit, battle))
                    suitTrack.append(Func(battle.unlureSuit, unluredSuit))
                    unlureSuits.append(suitTrack)

        trapTrack.append(unlureSuits)
        for otherSuit in battle.suits:
            if not otherSuit == suit:
                if otherSuit.battleTrap != NO_TRAP:
                    notify.debug('trapSuit() - trap: %d destroyed existing trap: %d' % (level, suit.battleTrap))
                    battle.removeTrap(otherSuit)
                otherSuit.battleTrapProp = trapProp
                otherSuit.battleTrap = level
                otherSuit.battleTrapIsFresh = 1

        trapTracks.append(trapTrack)
    button = globalPropPool.getProp('button')
    button2 = MovieUtil.copyProp(button)
    buttons = [button, button2]
    if toon.isDisguised:
        for b in buttons:
            b.setP(180)

    toonTrack = Sequence()
    toonTrack.append(Func(MovieUtil.showProps, buttons, hands))
    toonTrack.append(Func(toon.headsUp, battle, suitPos))
    if toon.isDisguised:
        if toon.suit.style.body == 'c':
            toonTrack.append(Func(toon.suit.pose, 'phone', 0))
        if toon.suit.style.body == 'a':
            toonTrack.append(Sequence(Wait(1), ActorInterval(toon.suit, 'phone', endFrame=26, playRate=0.8), ActorInterval(toon.suit, 'phone', startFrame=26, endFrame=0)))
        elif toon.suit.style.body == 'b':
            toonTrack.append(Sequence(Wait(1), ActorInterval(toon.suit, 'phone', endFrame=32), ActorInterval(toon.suit, 'phone', startFrame=32, endFrame=0)))
        else:
            toonTrack.append(Sequence(Wait(1), ActorInterval(toon.suit, 'phone', endFrame=29), ActorInterval(toon.suit, 'phone', startFrame=29, endFrame=0)))
    else:
        toonTrack.append(ActorInterval(toon, 'pushbutton'))
    toonTrack.append(Func(MovieUtil.removeProps, buttons))
    if toon.isDisguised:
        toonTrack.append(Func(toon.suit.loop, 'neutral'))
    else:
        toonTrack.append(Func(toon.loop, 'neutral'))
    toonTrack.append(Func(toon.setHpr, battle, origHpr))
    if propName == 'quicksand':
        propSound = globalBattleSoundCache.getSound('TL_quicksand.ogg')
    else:
        if propName == 'traintrack':
            propSound = globalBattleSoundCache.getSound('TL_train_track_appear.ogg')
        else:
            propSound = globalBattleSoundCache.getSound('TL_trap_door.ogg')
    buttonSound = globalBattleSoundCache.getSound('AA_drop_trigger_box.ogg')
    soundTrack = Sequence(Wait(2.3), Parallel(SoundInterval(buttonSound, duration=0.67, node=toon), SoundInterval(propSound, node=toon)))
    return Parallel(trapTracks, toonTrack, soundTrack)
Beispiel #3
0
def __createPlacedGroupTrapTrack(
    trap,
    prop,
    propName,
    centerSuit,
    propPos=None,
    propHpr=None,
    explode=0,
):
    """
    mainly to make the train track appear.  We only want one, and parented to the battle
    """
    toon = trap['toon']
    if (trap.has_key('npc')):
        toon = trap['npc']
    level = trap['level']
    battle = trap['battle']
    origHpr = toon.getHpr(battle)
    #5 was determined empirically
    trapPoint = Point3(0, 5 - MovieUtil.SUIT_TRAP_DISTANCE, 0.025)
    trapDelay = 2.5
    hands = toon.getLeftHands()

    def placeDustExplosion(dustNode, trapProp, battle):
        dustNode.reparentTo(battle)
        dustNode.setPos(trapProp.getPos(battle))

    trapTracks = Parallel()

    firstTime = 1
    targets = trap['target']
    #for target in targets:
    if True:
        suit = centerSuit  # target['suit']
        suitPos = suit.getPos(battle)
        targetPos = suitPos
        trapProp = MovieUtil.copyProp(prop)

        showThisTrap = True
        #if visibleOnlyForThisSuitId and visibleOnlyForThisSuitId != suit.doId :
        #    showThisTrap = False

        trapTrack = Sequence()
        trapTrack.append(Wait(trapDelay))
        if showThisTrap:
            notify.debug('showing trap %s for %d' %
                         (trapProp.getName(), suit.doId))
            trapTrack.append(Func(trapProp.show))
        else:
            notify.debug('hiding trap %s for %d' %
                         (trapProp.getName(), suit.doId))
            trapTrack.append(Func(trapProp.hide))
        trapTrack.append(Func(trapProp.setScale, Point3(0.1, 0.1, 0.1)))
        trapTrack.append(Func(trapProp.reparentTo, battle))
        trapTrack.append(Func(trapProp.setPos, trapPoint))
        trapTrack.append(Func(trapProp.setH, 0))
        trapTrack.append(
            LerpScaleInterval(trapProp, 1.2, Point3(1.0, 1.0, 1.0)))

        if (explode == 1
            ):  # If the trap prop collides with another trap, destroy it
            # Need hidden node to take the place of the exploding trap prop,
            # we'll parent the explosion itself to this hidden node
            dustNode = hidden.attachNewNode("DustNode")

            removeTrapsParallel = Parallel()

            oneTrapTrack = Sequence()
            oneTrapTrack.append(Func(trapProp.wrtReparentTo, hidden))
            oneTrapTrack.append(
                Func(placeDustExplosion, dustNode, trapProp, battle))
            oneTrapTrack.append(
                createCartoonExplosionTrack(dustNode,
                                            'dust',
                                            explosionPoint=Point3(0, 0, 0)))
            oneTrapTrack.append(Func(MovieUtil.removeProp, trapProp))
            #oneTrapTrack.append(Func(battle.removeTrap, suit))

            removeTrapsParallel.append(oneTrapTrack)

            #we need to remove the battle traps of the other suits too
            for target in trap['target']:
                otherSuit = target['suit']
                #if otherSuit != suit and otherSuit.battleTrapProp:
                if otherSuit.battleTrapProp:
                    otherDustNode = hidden.attachNewNode("DustNodeOtherSuit")
                    otherTrapTrack = Sequence()
                    otherTrapTrack.append(
                        Func(otherSuit.battleTrapProp.wrtReparentTo, hidden))
                    otherTrapTrack.append(
                        Func(placeDustExplosion, dustNode,
                             otherSuit.battleTrapProp, battle))
                    otherTrapTrack.append(
                        createCartoonExplosionTrack(otherDustNode,
                                                    'dust',
                                                    explosionPoint=Point3(
                                                        0, 0, 0)))
                    otherTrapTrack.append(Func(battle.removeTrap, otherSuit))
                    removeTrapsParallel.append(otherTrapTrack)

            trapTrack.append(removeTrapsParallel)
        else:
            # Set the trap prop as the suit's trap prop
            if (suit.battleTrap != NO_TRAP):
                notify.debug(
                    'trapSuit() - trap: %d destroyed existing trap: %d' %
                    (level, suit.battleTrap))
                battle.removeTrap(suit)
            suit.battleTrapProp = trapProp
            suit.battleTrap = level
            suit.battleTrapIsFresh = 1

            #check if we have a case of a train trap appearing under a lured suit
            unlureSuits = Parallel()
            for target in targets:
                kbbonus = target['kbbonus']
                if (kbbonus == 0):
                    unluredSuit = target['suit']
                    suitTrack = Sequence()
                    suitTrack.append(
                        createSuitResetPosTrack(unluredSuit, battle))
                    suitTrack.append(Func(battle.unlureSuit, unluredSuit))
                    unlureSuits.append(suitTrack)
            trapTrack.append(unlureSuits)

            #also set up the other suits
            for otherSuit in battle.suits:
                if not otherSuit == suit:
                    if (otherSuit.battleTrap != NO_TRAP):
                        notify.debug(
                            'trapSuit() - trap: %d destroyed existing trap: %d'
                            % (level, suit.battleTrap))
                        battle.removeTrap(otherSuit)
                    otherSuit.battleTrapProp = trapProp
                    otherSuit.battleTrap = level
                    otherSuit.battleTrapIsFresh = 1
        trapTracks.append(trapTrack)

    button = globalPropPool.getProp('button')
    button2 = MovieUtil.copyProp(button)
    buttons = [button, button2]

    toonTrack = Sequence()
    toonTrack.append(Func(MovieUtil.showProps, buttons, hands))
    toonTrack.append(Func(toon.headsUp, battle, suitPos))
    toonTrack.append(ActorInterval(toon, 'pushbutton'))
    toonTrack.append(Func(MovieUtil.removeProps, buttons))
    toonTrack.append(Func(toon.loop, 'neutral'))
    toonTrack.append(Func(toon.setHpr, battle, origHpr))

    if (propName == 'quicksand'):
        propSound = globalBattleSoundCache.getSound('TL_quicksand.mp3')
    elif (propName == 'traintrack'):
        propSound = globalBattleSoundCache.getSound(
            'TL_train_track_appear.mp3')
    else:
        propSound = globalBattleSoundCache.getSound('TL_trap_door.mp3')

    buttonSound = globalBattleSoundCache.getSound('AA_drop_trigger_box.mp3')
    #timing of prop sound is from the start of the button press
    soundTrack = Sequence(
        Wait(2.3),
        Parallel(SoundInterval(buttonSound, duration=0.67, node=toon),
                 SoundInterval(propSound, node=toon)),
    )

    return Parallel(trapTracks, toonTrack, soundTrack)