Esempio n. 1
0
    def chooseAnimToRun(self):
        result = self.curPhase
        if base.config.GetBool('anim-props-randomized', True):
            pairs = []
            for i in xrange(self.curPhase + 1):
                pairs.append((math.pow(2, i), i))

            sum = math.pow(2, self.curPhase + 1) - 1
            result = weightedChoice(pairs, sum=sum)
            self.notify.debug('chooseAnimToRun curPhase=%s pairs=%s result=%s' % (self.curPhase, pairs, result))
        return result
    def initializeLevel(self, levelSpec):
        self.startTime = globalClock.getRealTime()
        self.startTimestamp = globalClockDelta.localToNetworkTime(self.startTime, bits=32)
        lol = zip([1] * levelSpec.getNumScenarios(), range(levelSpec.getNumScenarios()))
        scenarioIndex = weightedChoice(lol)
        Level.Level.initializeLevel(self, self.doId, levelSpec, scenarioIndex)
        if __dev__:
            self.accept(self.editMgrEntity.getSpecSaveEvent(), self.saveSpec)
        for avId in self.avIdList:
            self.acceptOnce(self.air.getAvatarExitEvent(avId), Functor(self.handleAvatarDisconnect, avId))

        self.allToonsGoneBarrier = self.beginBarrier('allToonsGone', self.avIdList, 3 * 24 * 60 * 60, self.allToonsGone)
Esempio n. 3
0
    def chooseIdleAnimToRun(self):
        result = self.numIdles - 1
        if base.config.GetBool('randomize-interactive-idles', True):
            pairs = []
            for i in range(self.numIdles):
                reversedChance = self.numIdles - i - 1
                pairs.append((math.pow(2, reversedChance), i))

            sum = math.pow(2, self.numIdles) - 1
            result = weightedChoice(pairs, sum=sum)
            self.notify.debug(
                'chooseAnimToRun numIdles=%s pairs=%s result=%s' %
                (str(self.numIdles), pairs, str(result)))
        else:
            result = self.lastPlayingAnimPhase + 1
            if result >= len(self.ZoneToIdles[self.hoodId]):
                result = 0
        return result