def chooseIdleAnimToRun(self):
     """Returns a weighted number between 0 and self.numIdles, inclusive"""
     # e.g. if self.numIdles is 2, we have a 4/7 chance of picking 2
     # a 2/7 chance of picking 1
     # and a 1/7 chance of picking 0
     assert self.notify.debugStateCall(self)
     result = self.numIdles -1
     if base.config.GetBool('randomize-interactive-idles', True):
         pairs = []
         for i in xrange(self.numIdles):
             # actually we want idle2 to have a lower chance of occcurring
             # as it's the niftier idle compared to idle1 and idle0
             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" %
                           (self.numIdles,pairs,result))
     else:
         # this makes debugging a heck of a lot easier
         # takes a really long time for AwesomeIdles to play
         result = self.lastPlayingAnimPhase + 1
         if result >= len(self.ZoneToIdles[self.hoodId]):
             result = 0 
     return result
    def initializeLevel(self, levelSpec):
        # record the level's start time so that we can sync the clients
        self.startTime = globalClock.getRealTime()
        self.startTimestamp = globalClockDelta.localToNetworkTime(
            self.startTime, bits=32)

        # choose a scenario
        # make list of lists: [(weight, scenarioIndex), ...]
        lol = list(
            zip([1] * levelSpec.getNumScenarios(),
                list(range(levelSpec.getNumScenarios()))))
        scenarioIndex = weightedChoice(lol)

        Level.Level.initializeLevel(self, self.doId, levelSpec, scenarioIndex)

        if __dev__:
            # listen for requests to save the spec
            self.accept(self.editMgrEntity.getSpecSaveEvent(), self.saveSpec)

        # listen for avatar disconnects
        for avId in self.avIdList:
            self.acceptOnce(self.air.getAvatarExitEvent(avId),
                            Functor(self.handleAvatarDisconnect, avId))

        # set up a barrier that will clear when all avs have left or
        # disconnected
        self.allToonsGoneBarrier = self.beginBarrier('allToonsGone',
                                                     self.avIdList,
                                                     3 * 24 * 60 * 60,
                                                     self.allToonsGone)
    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)
        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)
    def chooseAnimToRun(self):
        result = self.curPhase
        if 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
Beispiel #5
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
Beispiel #6
0
    def initializeLevel(self, levelSpec):
        self.startTime = globalClock.getRealTime()
        self.startTimestamp = globalClockDelta.localToNetworkTime(self.startTime, bits=32)
        lol = list(zip([1] * levelSpec.getNumScenarios(), list(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)
Beispiel #7
0
    def chooseIdleAnimToRun(self):
        result = self.numIdles - 1
        if config.GetBool('randomize-interactive-idles', True):
            pairs = []
            for i in xrange(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' % (self.numIdles, pairs, result))
        else:
            result = self.lastPlayingAnimPhase + 1
            if result >= len(self.ZoneToIdles[self.hoodId]):
                result = 0
        return result
Beispiel #8
0
 def chooseAnimToRun(self):
     """Returns a weighted number between 0 and self.curPhase, inclusive"""
     # e.g. if self.curPhase is 2, we have a 4/7 chance of picking 2
     # a 2/7 chance of picking 1
     # and a 1/7 chance of picking 0
     assert self.notify.debugStateCall(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