예제 #1
0
    def __setupSuitInfo( self, suit, bldgTrack, suitLevel, suitType ):
        """
        create dna information for the given suit with the given track
        and suit type
        """
        suitName, skeleton = simbase.air.suitInvasionManager.getInvadingCog()
        if suitName and self.respectInvasions:
            # Override the suit type
            suitType = SuitDNA.getSuitType(suitName)
            # Override the building track
            bldgTrack = SuitDNA.getSuitDept(suitName)
            # if our type is already specified, we might need to
            # constrain the level to fit.
            suitLevel = min(max(suitLevel, suitType), suitType + 4)

        dna = SuitDNA.SuitDNA()
        dna.newSuitRandom( suitType, bldgTrack )
        suit.dna = dna
        self.notify.debug("Creating suit type " + suit.dna.name +
                          " of level " + str( suitLevel ) +
                          " from type " + str( suitType ) +
                          " and track " + str( bldgTrack ) )
        suit.setLevel( suitLevel )

        # We can't make a suit a skeleton until after generate.
        # Pass this info back so we know whether to do it or not
        return skeleton
예제 #2
0
def getCogdoTrack(suitName):
    tracks = getAllowedTracks()

    if not tracks:
        return None

    track = SuitDNA.getSuitDept(suitName)

    return track if track in tracks else random.choice(tracks)
예제 #3
0
def getCogdoTrack(suitName):
    tracks = getAllowedTracks()

    if not tracks:
        return None

    track = SuitDNA.getSuitDept(suitName)

    return track if track in tracks else random.choice(tracks)
 def __setupSuitInfo(self, suit, bldgTrack, suitLevel, suitType):
     suitName, skeleton, v2, waiter = simbase.air.suitInvasionManager.getInvadingCog()
     if suitName and self.respectInvasions:
         suitType = SuitDNA.getSuitType(suitName)
         bldgTrack = SuitDNA.getSuitDept(suitName)
         suitLevel = min(max(suitLevel, suitType), suitType + 4)
     dna = SuitDNA.SuitDNA()
     dna.newSuitRandom(suitType, bldgTrack)
     suit.dna = dna
     self.notify.debug('Creating suit type ' + suit.dna.name + ' of level ' + str(suitLevel) + ' from type ' + str(suitType) + ' and track ' + str(bldgTrack))
     suit.setLevel(suitLevel)
     return (skeleton, v2, waiter)
예제 #5
0
    def createStreet(self, streetZone, shopZone, hqZone):
        flunky = DistributedTutorialSuitAI.DistributedTutorialSuitAI(self.air)
        suitType = SuitDNA.getSuitType('f')
        suitTrack = SuitDNA.getSuitDept('f')
        flunky.setupSuitDNA(1, suitType, suitTrack)
        flunky.generateWithRequired(streetZone)

        desc = NPCToons.NPCToonDict.get(20001)
        npc = NPCToons.createNPC(self.air, 20001, desc, streetZone)
        npc.setTutorial(1)
        npc.d_setPos(207.4, 18.81, -0.475)
        npc.d_setHpr(90.0, 0, 0)
    def createStreet(self, streetZone, shopZone, hqZone):
        flunky = DistributedTutorialSuitAI.DistributedTutorialSuitAI(self.air)
        suitType = SuitDNA.getSuitType('f')
        suitTrack = SuitDNA.getSuitDept('f')
        flunky.setupSuitDNA(1, suitType, suitTrack)
        flunky.generateWithRequired(streetZone)

        desc = NPCToons.NPCToonDict.get(20001)
        npc = NPCToons.createNPC(self.air, 20001, desc, streetZone)
        npc.setTutorial(1)
        npc.d_setPos(207.4, 18.81, -0.475)
        npc.d_setHpr(90.0, 0, 0)
예제 #7
0
 def __setupSuitInfo(self, suit, bldgTrack, suitLevel, suitType):
     suitName, skeleton = simbase.air.suitInvasionManager.getInvadingCog()
     if suitName and self.respectInvasions:
         suitType = SuitDNA.getSuitType(suitName)
         bldgTrack = SuitDNA.getSuitDept(suitName)
         suitLevel = min(max(suitLevel, suitType), suitType + 4)
     dna = SuitDNA.SuitDNA()
     dna.newSuitRandom(suitType, bldgTrack)
     suit.dna = dna
     self.notify.debug('Creating suit type ' + suit.dna.name + ' of level ' + str(suitLevel) + ' from type ' + str(suitType) + ' and track ' + str(bldgTrack))
     suit.setLevel(suitLevel)
     return skeleton
 def startTakeOver(self):
     dept = SuitDNA.getSuitDept(self.dna.name)
     if not self.SUIT_BUILDINGS:
         return
     blockNumber = self.buildingDestination
     if self.sp.buildingMgr is None:
         return
     if not self.sp.buildingMgr.isSuitBlock(blockNumber):
         self.notify.debug('Suit %s taking over building %s in %s' %
                           (self.getDoId(), blockNumber, self.zoneId))
         difficulty = self.getActualLevel() - 1
         if self.buildingDestinationIsCogdo:
             self.sp.cogdoTakeOver(blockNumber, difficulty,
                                   self.buildingHeight, dept)
         else:
             self.sp.suitTakeOver(blockNumber, dept, difficulty,
                                  self.buildingHeight)
 def doZoneMovie(self, zoneId):
     if zoneId == self.zoneId:
         avHeight = max(base.localAvatar.getHeight(), 3.0)
         scaleFactor = avHeight * 0.3333333333
         track = Sequence()
         track.append(Wait(1))
         track.append(
             Func(self.setChatAbsolute, TTLocalizer.TutorialSuit1,
                  CFSpeech | CFTimeout))
         track.append(Wait(3))
         track.append(
             Func(
                 self.setChatAbsolute,
                 TTLocalizer.TutorialSuitTaunt.get(
                     SuitDNA.getSuitDept(self.dna.name)),
                 CFSpeech | CFTimeout))
         track.append(Wait(3))
         track.append(
             Func(self.d_requestBattle, self.getPos(), self.getHpr()))
         track.start()
예제 #10
0
    def getQuestIntervalList(self,
                             toon,
                             deathList,
                             toonList,
                             origQuestsList,
                             itemList,
                             helpfulToonsList=[]):
        avId = toon.getDoId()
        tickDelay = 0.2
        intervalList = []
        toonShortList = []
        for t in toonList:
            if t is not None:
                toonShortList.append(t)

        cogList = []
        for i in xrange(0, len(deathList), 4):
            cogIndex = deathList[i]
            cogLevel = deathList[i + 1]
            activeToonBits = deathList[i + 2]
            flags = deathList[i + 3]
            activeToonIds = []
            for j in xrange(8):
                if activeToonBits & 1 << j:
                    if toonList[j] is not None:
                        activeToonIds.append(toonList[j].getDoId())

            isSkelecog = flags & ToontownBattleGlobals.DLF_SKELECOG
            isForeman = flags & ToontownBattleGlobals.DLF_FOREMAN
            isVP = flags & ToontownBattleGlobals.DLF_VP
            isCFO = flags & ToontownBattleGlobals.DLF_CFO
            isSupervisor = flags & ToontownBattleGlobals.DLF_SUPERVISOR
            isVirtual = flags & ToontownBattleGlobals.DLF_VIRTUAL
            hasRevives = flags & ToontownBattleGlobals.DLF_REVIVES
            if isVP or isCFO:
                cogType = None
                cogTrack = SuitDNA.suitDepts[cogIndex]
            else:
                cogType = SuitDNA.suitHeadTypes[cogIndex]
                cogTrack = SuitDNA.getSuitDept(cogType)
            cogList.append({
                'type': cogType,
                'level': cogLevel,
                'track': cogTrack,
                'isSkelecog': isSkelecog,
                'isForeman': isForeman,
                'isVP': isVP,
                'isCFO': isCFO,
                'isSupervisor': isSupervisor,
                'isVirtual': isVirtual,
                'hasRevives': hasRevives,
                'activeToons': activeToonIds
            })

        try:
            zoneId = base.cr.playGame.getPlace().getTaskZoneId()
        except:
            zoneId = 0

        avQuests = []
        for i in xrange(0, len(origQuestsList), 5):
            avQuests.append(origQuestsList[i:i + 5])

        for i in xrange(len(avQuests)):
            questDesc = avQuests[i]
            questId, npcId, toNpcId, rewardId, toonProgress = questDesc
            quest = Quests.getQuest(questId)
            if quest and i < len(self.questLabelList):
                questString = quest.getString()
                progressString = quest.getProgressString(toon, questDesc)
                questLabel = self.questLabelList[i]
                earned = 0
                orig = questDesc[4] & pow(2, 16) - 1
                num = 0
                if quest.getType() == Quests.RecoverItemQuest:
                    questItem = quest.getItem()
                    if questItem in itemList:
                        earned = itemList.count(questItem)
                else:
                    for cogDict in cogList:
                        if cogDict['isVP']:
                            num = quest.doesVPCount(avId, cogDict, zoneId,
                                                    toonShortList)
                        elif cogDict['isCFO']:
                            num = quest.doesCFOCount(avId, cogDict, zoneId,
                                                     toonShortList)
                        else:
                            num = quest.doesCogCount(avId, cogDict, zoneId,
                                                     toonShortList)
                        if num:
                            if base.config.GetBool('battle-passing-no-credit',
                                                   True):
                                if avId in helpfulToonsList:
                                    earned += num
                                else:
                                    self.notify.debug(
                                        'avId=%d not getting %d kill cog quest credit'
                                        % (avId, num))
                            else:
                                earned += num

                if base.localAvatar.tutorialAck:
                    if earned > 0:
                        earned = min(earned,
                                     quest.getNumQuestItems() - questDesc[4])
                if earned > 0 or base.localAvatar.tutorialAck == 0 and num == 1:
                    barTime = 0.5
                    numTicks = int(math.ceil(barTime / tickDelay))
                    for i in xrange(numTicks):
                        t = (i + 1) / float(numTicks)
                        newValue = int(orig + t * earned + 0.5)
                        questDesc[4] = newValue
                        progressString = quest.getProgressString(
                            toon, questDesc)
                        str = '%s : %s' % (questString, progressString)
                        if quest.getCompletionStatus(
                                toon, questDesc) == Quests.COMPLETE:
                            intervalList.append(
                                Func(questLabel.setProp, 'text_fg',
                                     (0, 0.3, 0, 1)))
                        intervalList.append(
                            Func(questLabel.setProp, 'text', str))
                        intervalList.append(Wait(tickDelay))

        return intervalList
예제 #11
0
    def getQuestIntervalList(self, toon, deathList, toonList, origQuestsList, itemList, helpfulToonsList = []):
        avId = toon.getDoId()
        tickDelay = 0.2
        intervalList = []
        toonShortList = []
        for t in toonList:
            if t is not None:
                toonShortList.append(t)

        cogList = []
        for i in xrange(0, len(deathList), 4):
            cogIndex = deathList[i]
            cogLevel = deathList[i + 1]
            activeToonBits = deathList[i + 2]
            flags = deathList[i + 3]
            activeToonIds = []
            for j in xrange(8):
                if activeToonBits & 1 << j:
                    if toonList[j] is not None:
                        activeToonIds.append(toonList[j].getDoId())

            isSkelecog = flags & ToontownBattleGlobals.DLF_SKELECOG
            isForeman = flags & ToontownBattleGlobals.DLF_FOREMAN
            isVP = flags & ToontownBattleGlobals.DLF_VP
            isCFO = flags & ToontownBattleGlobals.DLF_CFO
            isSupervisor = flags & ToontownBattleGlobals.DLF_SUPERVISOR
            isVirtual = flags & ToontownBattleGlobals.DLF_VIRTUAL
            hasRevives = flags & ToontownBattleGlobals.DLF_REVIVES
            if isVP or isCFO:
                cogType = None
                cogTrack = SuitDNA.suitDepts[cogIndex]
            else:
                cogType = SuitDNA.suitHeadTypes[cogIndex]
                cogTrack = SuitDNA.getSuitDept(cogType)
            cogList.append({'type': cogType,
             'level': cogLevel,
             'track': cogTrack,
             'isSkelecog': isSkelecog,
             'isForeman': isForeman,
             'isVP': isVP,
             'isCFO': isCFO,
             'isSupervisor': isSupervisor,
             'isVirtual': isVirtual,
             'hasRevives': hasRevives,
             'activeToons': activeToonIds})

        try:
            zoneId = base.cr.playGame.getPlace().getTaskZoneId()
        except:
            zoneId = 0

        avQuests = []
        for i in xrange(0, len(origQuestsList), 5):
            avQuests.append(origQuestsList[i:i + 5])

        for i in xrange(len(avQuests)):
            questDesc = avQuests[i]
            questId, npcId, toNpcId, rewardId, toonProgress = questDesc
            quest = Quests.getQuest(questId)
            if quest and i < len(self.questLabelList):
                questString = quest.getString()
                progressString = quest.getProgressString(toon, questDesc)
                questLabel = self.questLabelList[i]
                earned = 0
                orig = questDesc[4] & pow(2, 16) - 1
                num = 0
                if quest.getType() == Quests.RecoverItemQuest:
                    questItem = quest.getItem()
                    if questItem in itemList:
                        earned = itemList.count(questItem)
                else:
                    for cogDict in cogList:
                        if cogDict['isVP']:
                            num = quest.doesVPCount(avId, cogDict, zoneId, toonShortList)
                        elif cogDict['isCFO']:
                            num = quest.doesCFOCount(avId, cogDict, zoneId, toonShortList)
                        else:
                            num = quest.doesCogCount(avId, cogDict, zoneId, toonShortList)
                        if num:
                            if base.config.GetBool('battle-passing-no-credit', True):
                                if avId in helpfulToonsList:
                                    earned += num
                                else:
                                    self.notify.debug('avId=%d not getting %d kill cog quest credit' % (avId, num))
                            else:
                                earned += num

                if base.localAvatar.tutorialAck:
                    if earned > 0:
                        earned = min(earned, quest.getNumQuestItems() - questDesc[4])
                if earned > 0 or base.localAvatar.tutorialAck == 0 and num == 1:
                    barTime = 0.5
                    numTicks = int(math.ceil(barTime / tickDelay))
                    for i in xrange(numTicks):
                        t = (i + 1) / float(numTicks)
                        newValue = int(orig + t * earned + 0.5)
                        questDesc[4] = newValue
                        progressString = quest.getProgressString(toon, questDesc)
                        str = '%s : %s' % (questString, progressString)
                        if quest.getCompletionStatus(toon, questDesc) == Quests.COMPLETE:
                            intervalList.append(Func(questLabel.setProp, 'text_fg', (0, 0.3, 0, 1)))
                        intervalList.append(Func(questLabel.setProp, 'text', str))
                        intervalList.append(Wait(tickDelay))

        return intervalList
예제 #12
0
    def getQuestIntervalList(self, toon, deathList, toonList, origQuestsList, itemList, helpfulToonsList = []):
        # This is the battle notifying us that a toon killed some cogs
        # See if this toon has a quest on these cogs. If so, update the
        # progress.
        # Note that toonList corresponds order-wise to the bitmasks in the
        # deathList, and might have 'None' entries for toons that are no
        # longer present.

        avId = toon.getDoId()
        tickDelay = 0.2
        intervalList = []

        # create a non-ordered list of the toons (without the None entries)
        toonShortList = []
        for t in toonList:
            if t is not None:
                toonShortList.append(t)

        cogList = []
        for i in range(0, len(deathList), 4):
            cogIndex = deathList[i]
            cogLevel = deathList[i+1]
            activeToonBits = deathList[i+2]
            flags = deathList[i+3]
            activeToonIds = []
            for j in range(8):
                if activeToonBits & (1 << j):
                    if toonList[j] is not None:
                        activeToonIds.append(toonList[j].getDoId())
            isSkelecog = flags & ToontownBattleGlobals.DLF_SKELECOG
            isForeman = flags & ToontownBattleGlobals.DLF_FOREMAN
            isVP = flags & ToontownBattleGlobals.DLF_VP
            isCFO = flags & ToontownBattleGlobals.DLF_CFO
            isSupervisor = flags & ToontownBattleGlobals.DLF_SUPERVISOR
            isVirtual = flags & ToontownBattleGlobals.DLF_VIRTUAL
            hasRevives = flags & ToontownBattleGlobals.DLF_REVIVES
            if isVP or isCFO:
                cogType = None
                cogTrack = SuitDNA.suitDepts[cogIndex]
            else:
                cogType = SuitDNA.suitHeadTypes[cogIndex]
                cogTrack = SuitDNA.getSuitDept(cogType)
            cogList.append({'type': cogType,
                            'level': cogLevel,
                            'track': cogTrack,
                            'isSkelecog': isSkelecog,
                            'isForeman': isForeman,
                            'isVP': isVP,
                            'isCFO': isCFO,
                            'isSupervisor': isSupervisor,
                            'isVirtual': isVirtual,
                            'hasRevives': hasRevives,
                            'activeToons': activeToonIds,
                            })

        # It would be nice if there were some more elegant way to get the zoneId.
        try:
            zoneId = base.cr.playGame.getPlace().getTaskZoneId()
        except:
            # Maybe the local toon is just teleporting in, and we
            # haven't got a place yet.  This is a band-aid; we should
            # revisit this later.
            zoneId = 0


        # We could not trust the toons quests not to be updated by the AI, so now we pass in original
        # quests, just like we do original experience
        # unflatten orig quest list
        avQuests = []
        for i in range(0, len(origQuestsList), 5):
            avQuests.append(origQuestsList[i:i+5])

        # Now append intervals that will show our quests
        for i in range(len(avQuests)):
            questDesc = avQuests[i]
            questId, npcId, toNpcId, rewardId, toonProgress = questDesc
            quest = Quests.getQuest(questId)
            if quest:
                questString = quest.getString()
                progressString = quest.getProgressString(toon, questDesc)
                questLabel = self.questLabelList[i]
                earned = 0
                orig = questDesc[4] & (pow(2,16) - 1)
                num = 0

                # Did we recovered items?
                if quest.getType() == Quests.RecoverItemQuest:
                    questItem = quest.getItem()
                    if questItem in itemList:
                        earned = itemList.count(questItem)

                # Then we just defeated cogs
                else:
                    for cogDict in cogList:
                        if cogDict['isVP']:
                            num = quest.doesVPCount(avId, cogDict,
                                                    zoneId, toonShortList)
                        elif cogDict['isCFO']:
                            num = quest.doesCFOCount(avId, cogDict,
                                                     zoneId, toonShortList)
                        else:
                            num = quest.doesCogCount(avId, cogDict,
                                                     zoneId, toonShortList)
                        if num:
                            if base.config.GetBool('battle-passing-no-credit', True):
                                if avId in helpfulToonsList:
                                    earned += num
                                else:
                                    self.notify.debug('avId=%d not getting %d kill cog quest credit' % (avId,num))
                            else:
                                earned += num

                # import pdb; pdb.set_trace()

                # if we are not in the tutorial
                if base.localAvatar.tutorialAck:
                    # make sure we still need some items before playing movie
                    if earned > 0:
                        earned = min(earned, quest.getNumQuestItems() - questDesc[4])

                if earned > 0 or (base.localAvatar.tutorialAck==0 and num==1):
                    # See getTrackIntervalList() for timing comments.
                    barTime = math.log(earned + 1)
                    numTicks = int(math.ceil(barTime / tickDelay))

                    for i in range(numTicks):
                        t = (i + 1) / float(numTicks)
                        newValue = int(orig + t * earned + 0.5)

                        # Add num to progress
                        questDesc[4] = newValue
                        progressString = quest.getProgressString(toon, questDesc)
                        str = ("%s : %s" % (questString, progressString))
                        if (quest.getCompletionStatus(toon, questDesc) == Quests.COMPLETE):
                            intervalList.append(Func(questLabel.setProp, 'text_fg', (0, 0.3, 0, 1)))
                        intervalList.append(Func(questLabel.setProp, 'text', str))
                        intervalList.append(Wait(tickDelay))

        return intervalList