Example #1
0
def doSounds(sounds):
    if len(sounds) == 0:
        return (None, None)
    npcArrivals, npcDepartures, npcs = MovieNPCSOS.doNPCTeleports(sounds)
    mtrack = Parallel() 
    hitCount = 0
    prevLevel = 0
    prevSounds = [[],
     [],
     [],
     [],
     [],
     [],
     []]
    for sound in sounds:
        level = sound['level']
        prevSounds[level].append(sound)
        for target in sound['target']:
            if target['hp'] > 0:
                hitCount += 1
                break

    delay = 0.0
    for soundList in prevSounds:
        if len(soundList) > 0:
            mtrack.append(__doSoundsLevel(soundList, delay, hitCount, npcs))
            delay += TOON_SOUND_DELAY

    soundTrack = Sequence(npcArrivals, mtrack, npcDepartures)
    targets = sounds[0]['target']
    camDuration = mtrack.getDuration()
    enterDuration = npcArrivals.getDuration()
    exitDuration = npcDepartures.getDuration()
    camTrack = MovieCamera.chooseSoundShot(sounds, targets, camDuration, enterDuration, exitDuration)
    return (soundTrack, camTrack)
Example #2
0
def doSounds(sounds):
    if len(sounds) == 0:
        return (None, None)
    npcArrivals, npcDepartures, npcs = MovieNPCSOS.doNPCTeleports(sounds)
    mtrack = Parallel()
    hitCount = 0
    prevLevel = 0
    prevSounds = [[], [], [], [], [], [], []]
    for sound in sounds:
        level = sound['level']
        prevSounds[level].append(sound)
        for target in sound['target']:
            if target['hp'] > 0:
                hitCount += 1
                break

    delay = 0.0
    for soundList in prevSounds:
        if len(soundList) > 0:
            mtrack.append(__doSoundsLevel(soundList, delay, hitCount, npcs))
            delay += TOON_SOUND_DELAY

    soundTrack = Sequence(npcArrivals, mtrack, npcDepartures)
    targets = sounds[0]['target']
    camDuration = mtrack.getDuration()
    enterDuration = npcArrivals.getDuration()
    exitDuration = npcDepartures.getDuration()
    camTrack = MovieCamera.chooseSoundShot(sounds, targets, camDuration,
                                           enterDuration, exitDuration)
    return (soundTrack, camTrack)
Example #3
0
def doLures(lures):
    """ doLures(lures)
        Lures occur in the following order:
        1) level 1 lures one at a time, from right to left
        2) level 2 lures one at a time, from right to left
        etc.
    """
    if (len(lures) == 0):
        return (None, None)

    npcArrivals, npcDepartures, npcs = MovieNPCSOS.doNPCTeleports(lures)

    mtrack = Parallel()
    for l in lures:
        ival = __doLureLevel(l, npcs)
        if (ival):
            mtrack.append(ival)

    lureTrack = Sequence(npcArrivals, mtrack, npcDepartures)

    camDuration = mtrack.getDuration()
    enterDuration = npcArrivals.getDuration()
    exitDuration = npcDepartures.getDuration()
    camTrack = MovieCamera.chooseLureShot(lures, camDuration, enterDuration,
                                                              exitDuration)
    return (lureTrack, camTrack)
def doZaps(zaps):
    if len(zaps) == 0:
        return (None, None)

    suitZapsDict = {}
    doneUber = 0
    skip = 0
    for zap in zaps:
        skip = 0
        if skip:
            pass
        elif type(zap['target']) == type([]):
            if 1:
                target = zap['target'][0]
                suitId = target['suit'].doId
                if suitId in suitZapsDict:
                    suitZapsDict[suitId].append(zap)
                else:
                    suitZapsDict[suitId] = [zap]
        else:
            suitId = zap['target']['suit'].doId
            if suitId in suitZapsDict:
                suitZapsDict[suitId].append(zap)
            else:
                suitZapsDict[suitId] = [zap]

    suitZaps = suitZapsDict.values()

    def compFunc(a, b):
        if len(a) > len(b):
            return 1
        elif len(a) < len(b):
            return -1
        return 0

    suitZaps.sort(compFunc)

    delay = 0.0

    mtrack = Parallel()
    for st in suitZaps:
        if len(st) > 0:
            ival = __doSuitZaps(st)
            if ival:
                mtrack.append(Sequence(Wait(delay), ival))
            delay = delay + TOON_ZAP_SUIT_DELAY
    npcArrivals, npcDepartures, npcs = MovieNPCSOS.doNPCTeleports(zaps)
    enterDuration = npcArrivals.getDuration()
    exitDuration = npcDepartures.getDuration()
    camDuration = mtrack.getDuration()
    camTrack = MovieCamera.chooseLureShot(zaps, camDuration, enterDuration,
                                          exitDuration)
    return (mtrack, camTrack)
def doLures(lures):
    if len(lures) == 0:
        return (None, None)
    npcArrivals, npcDepartures, npcs = MovieNPCSOS.doNPCTeleports(lures)
    mtrack = Parallel()
    for l in lures:
        ival = __doLureLevel(l, npcs)
        if ival:
            mtrack.append(ival)

    lureTrack = Sequence(npcArrivals, mtrack, npcDepartures)
    camDuration = mtrack.getDuration()
    enterDuration = npcArrivals.getDuration()
    exitDuration = npcDepartures.getDuration()
    camTrack = MovieCamera.chooseLureShot(lures, camDuration, enterDuration, exitDuration)
    return (lureTrack, camTrack)
Example #6
0
def doTraps(traps):
    if len(traps) == 0:
        return (None, None)
    npcArrivals, npcDepartures, npcs = MovieNPCSOS.doNPCTeleports(traps)
    hasUberTrapConflict = False
    suitTrapsDict = {}
    for trap in traps:
        targets = trap['target']
        if len(targets) == 1:
            suitId = targets[0]['suit'].doId
            if suitTrapsDict.has_key(suitId):
                suitTrapsDict[suitId].append(trap)
            else:
                suitTrapsDict[suitId] = [
                 trap]
        else:
            for target in targets:
                suitId = target['suit'].doId
                if not suitTrapsDict.has_key(suitId):
                    suitTrapsDict[suitId] = [
                     trap]
                    break

            if trap['level'] == UBER_GAG_LEVEL_INDEX:
                if len(traps) > 1:
                    hasUberTrapConflict = True
                for oneTarget in trap['target']:
                    suit = oneTarget['suit']
                    if suit.battleTrap != NO_TRAP:
                        hasUberTrapConflict = True

    suitTrapLists = suitTrapsDict.values()
    mtrack = Parallel()
    for trapList in suitTrapLists:
        trapPropList = []
        for i in range(len(trapList)):
            trap = trapList[i]
            level = trap['level']
            if level == 0:
                banana = globalPropPool.getProp('banana')
                banana2 = MovieUtil.copyProp(banana)
                trapPropList.append([banana, banana2])
            elif level == 1:
                rake = globalPropPool.getProp('rake')
                rake2 = MovieUtil.copyProp(rake)
                rake.pose('rake', 0)
                rake2.pose('rake', 0)
                trapPropList.append([rake, rake2])
            elif level == 2:
                marbles = globalPropPool.getProp('marbles')
                marbles2 = MovieUtil.copyProp(marbles)
                trapPropList.append([marbles, marbles2])
            elif level == 3:
                trapPropList.append([globalPropPool.getProp('quicksand')])
            elif level == 4:
                trapPropList.append([globalPropPool.getProp('trapdoor')])
            elif level == 5:
                tnt = globalPropPool.getProp('tnt')
                tnt2 = MovieUtil.copyProp(tnt)
                trapPropList.append([tnt, tnt2])
            elif level == 6:
                tnt = globalPropPool.getProp('traintrack')
                tnt2 = MovieUtil.copyProp(tnt)
                trapPropList.append([tnt, tnt2])
            else:
                notify.warning('__doTraps() - Incorrect trap level:                 %d' % level)

        if len(trapList) == 1 and not hasUberTrapConflict:
            ival = __doTrapLevel(trapList[0], trapPropList[0])
            if ival:
                mtrack.append(ival)
        else:
            subMtrack = Parallel()
            for i in range(len(trapList)):
                trap = trapList[i]
                trapProps = trapPropList[i]
                ival = __doTrapLevel(trap, trapProps, explode=1)
                if ival:
                    subMtrack.append(ival)

            mtrack.append(subMtrack)

    trapTrack = Sequence(npcArrivals, mtrack, npcDepartures)
    camDuration = mtrack.getDuration()
    enterDuration = npcArrivals.getDuration()
    exitDuration = npcDepartures.getDuration()
    camTrack = MovieCamera.chooseTrapShot(traps, camDuration, enterDuration, exitDuration)
    return (
     trapTrack, camTrack)
Example #7
0
def doDrops(drops):
    """ Drops occur in the following order:
        a) by suit, in order of increasing number of drops per suit
          1) level 1 drops, right to left, (TOON_DROP_DELAY later)
          2) level 2 drops, right to left, (TOON_DROP_DELAY later)
          3) level 3 drops, right to left, (TOON_DROP_DELAY later)
          etc.
        b) next suit, (TOON_DROP_SUIT_DELAY later)
    """
    if (len(drops) == 0):
        return (None, None)

    npcArrivals, npcDepartures, npcs = MovieNPCSOS.doNPCTeleports(drops)

    # Group the drops by targeted suit
    suitDropsDict = {}
    groupDrops = []
    for drop in drops:
        track = drop['track']
        level = drop['level']
        targets = drop['target']
        if (len(targets) == 1):
            suitId = targets[0]['suit'].doId
            if (suitDropsDict.has_key(suitId)):
                suitDropsDict[suitId].append((drop, targets[0]))
            else:
                suitDropsDict[suitId] = [(drop, targets[0])]
        elif level <= MAX_LEVEL_INDEX and attackAffectsGroup(track, level):
            groupDrops.append(drop)
        else:
            # We're dealing with an NPC drop, which can have multiple
            # targets
            for target in targets:
                suitId = target['suit'].doId
                if (suitDropsDict.has_key(suitId)):
                    otherDrops = suitDropsDict[suitId]
                    alreadyInList = 0
                    for oDrop in otherDrops:
                        if (oDrop[0]['toon'] == drop['toon']):
                            alreadyInList = 1
                    if (alreadyInList == 0):
                        suitDropsDict[suitId].append((drop, target))
                else:
                    suitDropsDict[suitId] = [(drop, target)]
    suitDrops = suitDropsDict.values()

    # Sort the suits based on the number of drops per suit
    def compFunc(a, b):
        if (len(a) > len(b)):
            return 1
        elif (len(a) < len(b)):
            return -1
        return 0

    suitDrops.sort(compFunc)
    delay = 0.0
    mtrack = Parallel(name='toplevel-drop')
    npcDrops = {}
    for st in suitDrops:
        if (len(st) > 0):
            ival = __doSuitDrops(st, npcs, npcDrops)
            if (ival):
                mtrack.append(Sequence(Wait(delay), ival))
            delay = delay + TOON_DROP_SUIT_DELAY

    dropTrack = Sequence(npcArrivals, mtrack, npcDepartures)
    camDuration = mtrack.getDuration()

    #we do the group drops after all the single drops have gone
    if groupDrops:
        ival = __doGroupDrops(groupDrops)
        dropTrack.append(ival)
        camDuration += ival.getDuration()

    enterDuration = npcArrivals.getDuration()
    exitDuration = npcDepartures.getDuration()
    camTrack = MovieCamera.chooseDropShot(drops, suitDropsDict, camDuration,
                                          enterDuration, exitDuration)

    return (dropTrack, camTrack)
Example #8
0
def doDrops(drops):
    if len(drops) == 0:
        return (None, None)
    npcArrivals, npcDepartures, npcs = MovieNPCSOS.doNPCTeleports(drops)
    suitDropsDict = {}
    groupDrops = []
    for drop in drops:
        track = drop['track']
        level = drop['level']
        targets = drop['target']
        if len(targets) == 1:
            suitId = targets[0]['suit'].doId
            if suitDropsDict.has_key(suitId):
                suitDropsDict[suitId].append((drop, targets[0]))
            else:
                suitDropsDict[suitId] = [(drop, targets[0])]
        elif level <= MAX_LEVEL_INDEX and attackAffectsGroup(track, level):
            groupDrops.append(drop)
        else:
            for target in targets:
                suitId = target['suit'].doId
                if suitDropsDict.has_key(suitId):
                    otherDrops = suitDropsDict[suitId]
                    alreadyInList = 0
                    for oDrop in otherDrops:
                        if oDrop[0]['toon'] == drop['toon']:
                            alreadyInList = 1

                    if alreadyInList == 0:
                        suitDropsDict[suitId].append((drop, target))
                else:
                    suitDropsDict[suitId] = [(drop, target)]

    suitDrops = suitDropsDict.values()

    def compFunc(a, b):
        if len(a) > len(b):
            return 1
        elif len(a) < len(b):
            return -1
        return 0

    suitDrops.sort(compFunc)
    delay = 0.0
    mtrack = Parallel(name='toplevel-drop')
    npcDrops = {}
    for st in suitDrops:
        if len(st) > 0:
            ival = __doSuitDrops(st, npcs, npcDrops)
            if ival:
                mtrack.append(Sequence(Wait(delay), ival))
            delay = delay + TOON_DROP_SUIT_DELAY

    dropTrack = Sequence(npcArrivals, mtrack, npcDepartures)
    camDuration = mtrack.getDuration()
    if groupDrops:
        ival = __doGroupDrops(groupDrops)
        dropTrack.append(ival)
        camDuration += ival.getDuration()
    enterDuration = npcArrivals.getDuration()
    exitDuration = npcDepartures.getDuration()
    camTrack = MovieCamera.chooseDropShot(drops, suitDropsDict, camDuration,
                                          enterDuration, exitDuration)
    return (dropTrack, camTrack)
def doTraps(traps):
    if len(traps) == 0:
        return None, None
    npcArrivals, npcDepartures, npcs = MovieNPCSOS.doNPCTeleports(traps)
    hasUberTrapConflict = False
    suitTrapsDict = {}
    for trap in traps:
        targets = trap['target']
        if len(targets) == 1:
            suitId = targets[0]['suit'].doId
            if suitId in suitTrapsDict:
                suitTrapsDict[suitId].append(trap)
            else:
                suitTrapsDict[suitId] = [trap]
        else:
            for target in targets:
                suitId = target['suit'].doId
                if suitId not in suitTrapsDict:
                    suitTrapsDict[suitId] = [trap]
                    break

            if trap['level'] == UBER_GAG_LEVEL_INDEX:
                if len(traps) > 1:
                    hasUberTrapConflict = True
                for oneTarget in trap['target']:
                    suit = oneTarget['suit']
                    if suit.battleTrap != NO_TRAP:
                        hasUberTrapConflict = True

    suitTrapLists = suitTrapsDict.values()
    mtrack = Parallel()
    for trapList in suitTrapLists:
        trapPropList = []
        for i in range(len(trapList)):
            trap = trapList[i]
            level = trap['level']
            if level == 0:
                banana = globalPropPool.getProp('banana')
                banana2 = MovieUtil.copyProp(banana)
                trapPropList.append([banana, banana2])
            elif level == 1:
                rake = globalPropPool.getProp('rake')
                rake2 = MovieUtil.copyProp(rake)
                rake.pose('rake', 0)
                rake2.pose('rake', 0)
                trapPropList.append([rake, rake2])
            elif level == 2:
                marbles = globalPropPool.getProp('marbles')
                marbles2 = MovieUtil.copyProp(marbles)
                trapPropList.append([marbles, marbles2])
            elif level == 3:
                trapPropList.append([globalPropPool.getProp('quicksand')])
            elif level == 4:
                trapPropList.append([globalPropPool.getProp('trapdoor')])
            elif level == 5:
                tnt = globalPropPool.getProp('tnt')
                tnt2 = MovieUtil.copyProp(tnt)
                trapPropList.append([tnt, tnt2])
            elif level == 6:
                tnt = globalPropPool.getProp('traintrack')
                tnt2 = MovieUtil.copyProp(tnt)
                trapPropList.append([tnt, tnt2])
            else:
                notify.warning(
                    '__doTraps() - Incorrect trap level:                 %d' %
                    level)

        if len(trapList) == 1 and not hasUberTrapConflict:
            ival = __doTrapLevel(trapList[0], trapPropList[0])
            if ival:
                mtrack.append(ival)
        else:
            subMtrack = Parallel()
            for i in range(len(trapList)):
                trap = trapList[i]
                trapProps = trapPropList[i]
                ival = __doTrapLevel(trap, trapProps, explode=1)
                if ival:
                    subMtrack.append(ival)

            mtrack.append(subMtrack)

    trapTrack = Sequence(npcArrivals, mtrack, npcDepartures)
    camDuration = mtrack.getDuration()
    enterDuration = npcArrivals.getDuration()
    exitDuration = npcDepartures.getDuration()
    camTrack = MovieCamera.chooseTrapShot(
        traps, camDuration, enterDuration, exitDuration)
    return trapTrack, camTrack
def doDrops(drops):
    if len(drops) == 0:
        return (None, None)
    npcArrivals, npcDepartures, npcs = MovieNPCSOS.doNPCTeleports(drops)
    suitDropsDict = {}
    groupDrops = []
    for drop in drops:
        track = drop['track']
        level = drop['level']
        targets = drop['target']
        if len(targets) == 1:
            suitId = targets[0]['suit'].doId
            if suitId in suitDropsDict:
                suitDropsDict[suitId].append((drop, targets[0]))
            else:
                suitDropsDict[suitId] = [(drop, targets[0])]
        elif level <= MAX_LEVEL_INDEX and attackAffectsGroup(track, level):
            groupDrops.append(drop)
        else:
            for target in targets:
                suitId = target['suit'].doId
                if suitId in suitDropsDict:
                    otherDrops = suitDropsDict[suitId]
                    alreadyInList = 0
                    for oDrop in otherDrops:
                        if oDrop[0]['toon'] == drop['toon']:
                            alreadyInList = 1

                    if alreadyInList == 0:
                        suitDropsDict[suitId].append((drop, target))
                else:
                    suitDropsDict[suitId] = [(drop, target)]

    suitDrops = suitDropsDict.values()

    def compFunc(a, b):
        if len(a) > len(b):
            return 1
        elif len(a) < len(b):
            return -1
        return 0

    suitDrops.sort(compFunc)
    delay = 0.0
    mtrack = Parallel(name='toplevel-drop')
    npcDrops = {}
    for st in suitDrops:
        if len(st) > 0:
            ival = __doSuitDrops(st, npcs, npcDrops)
            if ival:
                mtrack.append(Sequence(Wait(delay), ival))
            delay = delay + TOON_DROP_SUIT_DELAY

    dropTrack = Sequence(npcArrivals, mtrack, npcDepartures)
    camDuration = mtrack.getDuration()
    if groupDrops:
        ival = __doGroupDrops(groupDrops)
        dropTrack.append(ival)
        camDuration += ival.getDuration()
    enterDuration = npcArrivals.getDuration()
    exitDuration = npcDepartures.getDuration()
    camTrack = MovieCamera.chooseDropShot(drops, suitDropsDict, camDuration, enterDuration, exitDuration)
    return (dropTrack, camTrack)
Example #11
0
def doTraps(traps):
    """ Traps occur simultaneously - if more than one trap is
        thrown at the same suit, they explode
    """
    if (len(traps) == 0):
        return (None, None)

    npcArrivals, npcDepartures, npcs = MovieNPCSOS.doNPCTeleports(traps)

    hasUberTrapConflict = False

    # Group the traps by targeted suit
    suitTrapsDict = {}
    for trap in traps:
        targets = trap['target']
        if (len(targets) == 1):
            suitId = targets[0]['suit'].doId
            if (suitTrapsDict.has_key(suitId)):
                suitTrapsDict[suitId].append(trap)
            else:
                suitTrapsDict[suitId] = [trap]
        else:
            # We're dealing with an NPC trap, which can have multiple
            # targets - we only want to use the first valid target,
            # however, to avoid tossing too many traps
            for target in targets:
                suitId = target['suit'].doId
                if (not suitTrapsDict.has_key(suitId)):
                    suitTrapsDict[suitId] = [trap]
                    break
            if trap['level'] == UBER_GAG_LEVEL_INDEX:
                if len(traps) > 1:
                    hasUberTrapConflict = True
                for oneTarget in trap['target']:
                    suit = oneTarget['suit']
                    if suit.battleTrap != NO_TRAP:
                        #we can get here in a 3 suit battle, by placing quicksand then doing train
                        hasUberTrapConflict = True

    suitTrapLists = suitTrapsDict.values()

    mtrack = Parallel()
    for trapList in suitTrapLists:
        # Set the appropriate trapProps for use with this trap
        trapPropList = []
        for i in range(len(trapList)):
            trap = trapList[i]
            level = trap['level']
            if (level == 0):  # banana
                banana = globalPropPool.getProp('banana')
                banana2 = MovieUtil.copyProp(banana)
                trapPropList.append([banana, banana2])
            elif (level == 1):  # rake
                rake = globalPropPool.getProp('rake')
                rake2 = MovieUtil.copyProp(rake)
                rake.pose('rake', 0)
                rake2.pose('rake', 0)
                trapPropList.append([rake, rake2])
            elif (level == 2):  # marbles
                marbles = globalPropPool.getProp('marbles')
                marbles2 = MovieUtil.copyProp(marbles)
                trapPropList.append([marbles, marbles2])
            elif (level == 3):  # quicksand
                trapPropList.append([globalPropPool.getProp('quicksand')])
            elif (level == 4):  # trapdoor
                trapPropList.append([globalPropPool.getProp('trapdoor')])
            elif (level == 5):  # tnt
                tnt = globalPropPool.getProp('tnt')
                tnt2 = MovieUtil.copyProp(tnt)
                trapPropList.append([tnt, tnt2])
            elif (level == 6):  # tnt #UBER
                tnt = globalPropPool.getProp('traintrack')  #('trapdoor')
                tnt2 = MovieUtil.copyProp(tnt)
                trapPropList.append([tnt, tnt2])
            else:
                notify.warning('__doTraps() - Incorrect trap level: \
                %d' % level)

        if (len(trapList) == 1) and not hasUberTrapConflict:
            # Trap is successfully placed
            ival = __doTrapLevel(trapList[0], trapPropList[0])
            if (ival):
                mtrack.append(ival)
        else:
            assert (len(trapList) > 1 or hasUberTrapConflict)
            subMtrack = Parallel()
            for i in range(len(trapList)):
                trap = trapList[i]
                trapProps = trapPropList[i]
                ival = __doTrapLevel(trap, trapProps, explode=1)
                if (ival):
                    subMtrack.append(ival)
            mtrack.append(subMtrack)

    trapTrack = Sequence(npcArrivals, mtrack, npcDepartures)

    camDuration = mtrack.getDuration()
    enterDuration = npcArrivals.getDuration()
    exitDuration = npcDepartures.getDuration()
    camTrack = MovieCamera.chooseTrapShot(traps, camDuration, enterDuration,
                                          exitDuration)
    return (trapTrack, camTrack)