Пример #1
0
 def setLevel(self, lvl=None):
     attributes = SuitBattleGlobals.SuitAttributes[self.dna.name]
     if lvl:
         self.level = lvl - attributes['level'] - 1
     else:
         self.level = SuitBattleGlobals.pickFromFreqList(attributes['freq'])
     self.notify.debug('Assigning level ' + str(lvl))
     if hasattr(self, 'doId'):
         self.d_setLevelDist(self.level)
     hp = SuitBattleGlobals.calculateHp(attributes, self.level + 1)
     self.maxHP = hp
     self.currHP = hp
Пример #2
0
 def getActualLevel(self):
     if hasattr(self, 'dna'):
         return SuitBattleGlobals.getActualFromRelativeLevel(
             self.getStyleName(), self.level) + 1
     self.notify.warning(
         'called getActualLevel with no DNA, returning 1 for level')
     return 1
Пример #3
0
 def sayFaceoffTaunt(self, custom = False, phrase = "", dialogue = None):
     if custom:
         self.setChatAbsolute(phrase, CFSpeech | CFTimeout, dialogue)
     elif not custom:
         if random.random() < 0.2:
             taunt = SuitBattleGlobals.getFaceoffTaunt(self.getStyleName(), self.doId, randomChoice = True)
             self.setChatAbsolute(taunt, CFSpeech | CFTimeout)
 def getActualLevel(self):
     if hasattr(self, 'dna'):
         return SuitBattleGlobals.getActualFromRelativeLevel(
             self.getStyleName(), self.level) + 1
     else:
         self.notify.warning(
             'called getActualLevel with no DNA, returning 1 for level')
         return 1
Пример #5
0
 def getActualLevel(self):
     if hasattr(self, 'dna'):
         lv = SuitBattleGlobals.getActualFromRelativeLevel(self.getStyleName(), self.level)
         if lv == 49:
             lv = 15  # HACK
         return ToontownGlobals.SuitLevels[lv]
     else:
         self.notify.warning('called getActualLevel with no DNA, returning 1 for level')
         return 1
Пример #6
0
 def getActualLevel(self):
     if hasattr(self, 'dna'):
         if hasattr(self, 'level'):
             lv = SuitBattleGlobals.getActualFromRelativeLevel(
                 self.getStyleName(), self.level)
         else:
             lv = SuitBattleGlobals.getActualFromRelativeLevel(
                 self.getStyleName(),
                 SuitDNA.suitDepts.index(SuitDNA.getSuitDept(
                     self.dna.name)))
         try:
             goodRet = ToontownGlobals.SuitLevels[lv]
         except IndexError:
             goodRet = 50
         return goodRet
     else:
         self.notify.warning(
             'called getActualLevel with no DNA, returning 1 for level')
         return 1
Пример #7
0
 def setLevel(self, level):
     self.level = level
     nameWLevel = TTLocalizer.SuitBaseNameWithLevel % {
         'name': self.name,
         'dept': self.getStyleDept(),
         'level': self.getActualLevel()
     }
     self.setDisplayName(nameWLevel)
     attributes = SuitBattleGlobals.SuitAttributes[self.dna.name]
     self.maxHP = SuitBattleGlobals.calculateHp(attributes, self.level + 1)
     self.currHP = self.maxHP
 def pickLevelTypeAndTrack(self, level=None, type=None, track=None):
     if level is None:
         level = random.choice(self.SuitHoodInfo[self.hoodInfoIdx][self.SUIT_HOOD_INFO_LVL])
     if type is None:
         typeChoices = range(max(level - 4, 1), min(level, self.MAX_SUIT_TYPES) + 1)
         type = random.choice(typeChoices)
     else:
         level = min(max(level, type), type + 4)
     if track is None:
         track = SuitDNA.suitDepts[SuitBattleGlobals.pickFromFreqList(self.SuitHoodInfo[self.hoodInfoIdx][self.SUIT_HOOD_INFO_TRACK])]
     self.notify.debug('pickLevelTypeAndTrack: %s %s %s' % (level, type, track))
     return (level, type, track)
 def setLevel(self, lvl = None):
     attributes = SuitBattleGlobals.SuitAttributes[self.dna.name]
     if lvl is not None:
         self.level = lvl - attributes['level'] - 1
     else:
         self.level = SuitBattleGlobals.pickFromFreqList(attributes['freq'])
     self.notify.debug('Assigning level ' + str(lvl))
     if hasattr(self, 'doId'):
         self.d_setLevelDist(self.level)
     hp = attributes['hp'][self.level]
     self.maxHP = hp
     self.currHP = hp
 def setLevel(self, lvl=None):
     attributes = SuitBattleGlobals.SuitAttributes[self.dna.name]
     if lvl is not None:
         self.level = lvl - attributes["level"] - 1
     else:
         self.level = SuitBattleGlobals.pickFromFreqList(attributes["freq"])
     self.notify.debug("Assigning level " + str(lvl))
     if hasattr(self, "doId"):
         self.d_setLevelDist(self.level)
     hp = attributes["hp"][self.level]
     self.maxHP = hp
     self.currHP = hp
 def pickLevelTypeAndTrack(self, level=None, type=None, track=None):
     if level is None:
         level = random.choice(self.SuitHoodInfo[self.hoodInfoIdx][self.SUIT_HOOD_INFO_LVL])
     if type is None:
         typeChoices = range(max(level - 4, 1), min(level, self.MAX_SUIT_TYPES) + 1)
         type = random.choice(typeChoices)
     else:
         level = min(max(level, type), type + 4)
     if track is None:
         track = SuitDNA.suitDepts[SuitBattleGlobals.pickFromFreqList(self.SuitHoodInfo[self.hoodInfoIdx][self.SUIT_HOOD_INFO_TRACK])]
     self.notify.debug('pickLevelTypeAndTrack: %s %s %s' % (level, type, track))
     return (level, type, track)
Пример #12
0
    def updateRolloverBind(self):
        if not self.suit:
            return

        attributes = SuitBattleGlobals.SuitAttributes[self.suit.getStyleName()]
        groupAttacks, singleAttacks = SuitBattleGlobals.getAttacksByType(attributes)
        level = self.suit.getLevel()
        info = TTLocalizer.BattleCogPopup % (self.getAttackStrings(groupAttacks, level), self.getAttackStrings(singleAttacks, level))
        
        if TTLocalizer.BattleCogPopupDangerColor in info:
            info = TTLocalizer.BattleCogPopupDanger + info

        self.hoverButton.bind(DGG.ENTER, self.battle.showRolloverFrame, extraArgs=[self, TTLocalizer.BattleHoverCog, info])
Пример #13
0
    def setPanelStatus(self, panel, status):
        index = self.panels.index(panel)
        if status == COG_UNSEEN:
            panel['text'] = TTLocalizer.SuitPageMystery
        elif status == COG_BATTLED:
            suitName = SuitDNA.suitHeadTypes[index]
            suitFullName = SuitBattleGlobals.SuitAttributes[suitName]['name']
            panel['text'] = suitFullName
            if panel.quotaLabel:
                panel.quotaLabel.show()
            else:
                self.addQuotaLabel(panel)
            if panel.head and panel.shadow:
                panel.head.show()
                panel.shadow.show()
            else:
                self.addSuitHead(panel, suitName)
            if base.localAvatar.hasCogSummons(index):
                if panel.summonButton:
                    panel.summonButton.show()
                else:
                    self.addSummonButton(panel)
        elif status == COG_DEFEATED:
            count = str(base.localAvatar.cogCounts[index])
            if base.localAvatar.cogs[index] < COG_COMPLETE1:
                quota = str(COG_QUOTAS[0][index % SuitDNA.suitsPerDept])
            else:
                quota = str(COG_QUOTAS[1][index % SuitDNA.suitsPerDept])
            panel.quotaLabel['text'] = TTLocalizer.SuitPageQuota % (count,
                                                                    quota)
        elif status == COG_COMPLETE1:
            panel['image_color'] = PANEL_COLORS_COMPLETE1[index /
                                                          SuitDNA.suitsPerDept]
        elif status == COG_COMPLETE2:
            panel['image_color'] = PANEL_COLORS_COMPLETE2[index /
                                                          SuitDNA.suitsPerDept]
        if status in (COG_DEFEATED, COG_COMPLETE1, COG_COMPLETE2):
            name = SuitDNA.suitHeadTypes[index]
            attributes = SuitBattleGlobals.SuitAttributes[name]
            level = attributes['level']
            groupAttacks, singleAttacks = SuitBattleGlobals.getAttacksByType(
                attributes)
            info = TTLocalizer.SuitPageAttackFormat % (
                level + 1, level + 5, self.getAttackStrings(groupAttacks),
                self.getAttackStrings(singleAttacks))

            panel.hoverButton.bind(DGG.ENTER,
                                   self.showInfo,
                                   extraArgs=[panel, info])
            panel.hoverButton.bind(DGG.EXIT, self.hideInfo)
	def setLevel(self, lvl = None):
		attributes = SuitBattleGlobals.SuitAttributes[self.dna.name]
		if lvl is not None:
			self.level = lvl - attributes['level'] - 1
		else:
			self.level = SuitBattleGlobals.pickFromFreqList(attributes['freq'])
		self.notify.debug('Assigning level ' + str(lvl))
		if hasattr(self, 'doId'):
			self.d_setLevelDist(self.level)
		if len(attributes['hp'])<=self.level:
			print "HP is less then level, Oops!"
			raise Exception("invalid list index: len(attributes['hp') = %d, self.level=%d" % (len(attributes['hp']), self.level))
		hp = attributes['hp'][self.level]
		self.maxHP = hp
		self.currHP = hp
Пример #15
0
 def doAction(self, task):
     if not self.currentSuit:
         return Task.done
     if self.actSeq:
         self.actSeq.finish()
     self.setSuitChat(
         SuitBattleGlobals.getFaceoffTaunt(self.currentSuit.dna.name, 0,
                                           True))
     anim = random.choice([
         'victory', 'slip-backward', 'slip-forward', 'reach', 'hypnotized',
         'lured', 'neutral', 'neutral'
     ])
     self.actSeq = Sequence(ActorInterval(self.currentSuit, anim),
                            Func(self.currentSuit.loop, 'neutral'))
     self.actSeq.start()
     task.delayTime = random.randrange(ACT_DELAY_MIN, ACT_DELAY_MAX)
     return Task.again
 def setLevel(self, lvl=None):
     attributes = SuitBattleGlobals.SuitAttributes[self.dna.name]
     if lvl is not None:
         self.level = lvl - attributes['level'] - 1
     else:
         self.level = SuitBattleGlobals.pickFromFreqList(attributes['freq'])
     self.notify.debug('Assigning level ' + str(lvl))
     if hasattr(self, 'doId'):
         self.d_setLevelDist(self.level)
     if len(attributes['hp']) <= self.level:
         print "HP is less then level, Oops!"
         raise Exception(
             "invalid list index: len(attributes['hp') = %d, self.level=%d"
             % (len(attributes['hp']), self.level))
     hp = attributes['hp'][self.level]
     self.maxHP = hp
     self.currHP = hp
Пример #17
0
 def getActualLevel(self):
     """
     ////////////////////////////////////////////////////////////////////
     // Function:   from the suit's 'relative' level (relative to the
     //             type of suit that this guy is) figure out the suit's
     //             actual level (1-12)
     // Parameters: none
     // Changes:
     ////////////////////////////////////////////////////////////////////
     """
     if hasattr(self, "dna"):
         return SuitBattleGlobals.getActualFromRelativeLevel(
             self.getStyleName(), self.level) + 1
     else:
         self.notify.warning(
             'called getActualLevel with no DNA, returning 1 for level')
         return 1
Пример #18
0
 def setPanelStatus(self, panel, status):
     index = self.panels.index(panel)
     if status == COG_UNSEEN:
         panel['text'] = TTLocalizer.SuitPageMystery
     elif status == COG_BATTLED:
         suitName = SuitDNA.suitHeadTypes[index]
         suitFullName = SuitBattleGlobals.SuitAttributes[suitName]['name']
         panel['text'] = suitFullName
         if panel.quotaLabel:
             panel.quotaLabel.show()
         else:
             self.addQuotaLabel(panel)
         if panel.head and panel.shadow:
             panel.head.show()
             panel.shadow.show()
         else:
             self.addSuitHead(panel, suitName)
         if base.localAvatar.hasCogSummons(index):
             if panel.summonButton:
                 panel.summonButton.show()
             else:
                 self.addSummonButton(panel)
     elif status == COG_DEFEATED:
         count = str(base.localAvatar.cogCounts[index])
         if base.localAvatar.cogs[index] < COG_COMPLETE1:
             quota = str(COG_QUOTAS[0][index % SuitDNA.suitsPerDept])
         else:
             quota = str(COG_QUOTAS[1][index % SuitDNA.suitsPerDept])
         panel.quotaLabel['text'] = TTLocalizer.SuitPageQuota % (count, quota)
     elif status == COG_COMPLETE1:
         panel['image_color'] = PANEL_COLORS_COMPLETE1[index / SuitDNA.suitsPerDept]
     elif status == COG_COMPLETE2:
         panel['image_color'] = PANEL_COLORS_COMPLETE2[index / SuitDNA.suitsPerDept]
     if status in (COG_DEFEATED, COG_COMPLETE1, COG_COMPLETE2):
         name = SuitDNA.suitHeadTypes[index]
         attributes = SuitBattleGlobals.SuitAttributes[name]
         level = attributes['level']
         groupAttacks, singleAttacks = SuitBattleGlobals.getAttacksByType(attributes)
         info = TTLocalizer.SuitPageAttackFormat % (level + 1, level + 5, self.getAttackStrings(groupAttacks), self.getAttackStrings(singleAttacks))
         
         panel.hoverButton.bind(DGG.ENTER, self.showInfo, extraArgs=[panel, info])
         panel.hoverButton.bind(DGG.EXIT, self.hideInfo)
 def sayFaceoffTaunt(self, custom=False, phrase="", dialogue=None):
     if custom:
         self.virtualSuit.setChatAbsolute(phrase, CFSpeech | CFTimeout, dialogue)
     else:
         if self.attackProp == 'teeth':
             taunt = SuitBattleGlobals.getAttackTaunt(random.choice(['Bite', 'Chomp']))
         elif self.attackProp == 'synergy':
             taunt = SuitBattleGlobals.getAttackTaunt('Synergy')
         elif self.attackProp == 'golf-ball':
             taunt = SuitBattleGlobals.getAttackTaunt('TeeOff')
         elif self.attackProp == 'baseball':
             taunt = SuitBattleGlobals.getAttackTaunt('PlayHardball')
         elif self.attackProp == 'write-off':
             taunt = SuitBattleGlobals.getAttackTaunt('WriteOff')
         elif self.attackProp == 'crunch':
             taunt = SuitBattleGlobals.getAttackTaunt('Crunch')
         else:
             taunt = SuitBattleGlobals.getFaceoffTaunt(self.virtualSuit.style.name, self.doId)
         self.virtualSuit.setChatAbsolute(taunt, CFSpeech | CFTimeout)
Пример #20
0
    def setLevel(self, lvl=None):
        attributes = SuitBattleGlobals.SuitAttributes[self.dna.name]
        if lvl is not None:
            self.level = lvl - attributes['level'] - 1
        else:
            self.level = SuitBattleGlobals.pickFromFreqList(attributes['freq'])
        self.notify.debug('Assigning level ' + str(lvl))
        if hasattr(self, 'doId'):
            self.d_setLevelDist(self.level)
        try:
            hp = attributes['hp'][self.level]
        except:
            self.notify.warning(
                ("We're going down! Tried to spawn a {0} level {1}").format(
                    self.dna.name, self.level))
            raise IndexError(
                'An issue with Extra Cogs has occured!  DNA Name: %s, Level: %d'
                % (self.dna.name, self.level))

        self.maxHP = hp
        self.currHP = hp
        return
Пример #21
0
    def setLevel(self, lvl=None):
        """
        Function:    randomly choose a level for this suit based on the
                     type of the suit (such as yesman, flunky, etc) or
                     set the level to be the one specified
        Parameters:  lvl, level the suit should be
        """
        attributes = SuitBattleGlobals.SuitAttributes[self.dna.name]
        if lvl:
            self.level = lvl - attributes['level'] - 1
        else:
            self.level = SuitBattleGlobals.pickFromFreqList(attributes['freq'])
        self.notify.debug("Assigning level " + str(lvl))
        if hasattr(self, "doId"):
            self.d_setLevelDist(self.level)

        # be sure to set the hp to proper values based on the suit's
        # new level
        #
        hp = attributes['hp'][self.level]
        self.maxHP = hp
        self.currHP = hp
        assert self.notify.debug("Assigning hp " + str(self.currHP))
Пример #22
0
 def sayFaceoffTaunt(self, custom=False, phrase="", dialogue=None):
     if custom:
         self.virtualSuit.setChatAbsolute(phrase, CFSpeech | CFTimeout,
                                          dialogue)
     else:
         if self.attackProp == 'teeth':
             taunt = SuitBattleGlobals.getAttackTaunt(
                 random.choice(['Bite', 'Chomp']))
         elif self.attackProp == 'synergy':
             taunt = SuitBattleGlobals.getAttackTaunt('Synergy')
         elif self.attackProp == 'golf-ball':
             taunt = SuitBattleGlobals.getAttackTaunt('TeeOff')
         elif self.attackProp == 'baseball':
             taunt = SuitBattleGlobals.getAttackTaunt('PlayHardball')
         elif self.attackProp == 'write-off':
             taunt = SuitBattleGlobals.getAttackTaunt('WriteOff')
         elif self.attackProp == 'crunch':
             taunt = SuitBattleGlobals.getAttackTaunt('Crunch')
         else:
             taunt = SuitBattleGlobals.getFaceoffTaunt(
                 self.virtualSuit.style.name, self.doId)
         self.virtualSuit.setChatAbsolute(taunt, CFSpeech | CFTimeout)
    def __faceOff(self, ts, name, callback):
        if len(self.suits) == 0:
            self.notify.warning('__faceOff(): no suits.')
            return
        if len(self.toons) == 0:
            self.notify.warning('__faceOff(): no toons.')
            return
        toon = self.toons[0]
        point = self.toonPoints[0][0]
        toonPos = point[0]
        toonHpr = VBase3(point[1], 0.0, 0.0)
        p = toon.getPos(self)
        toon.setPos(self, p[0], p[1], 0.0)
        toon.setShadowHeight(0)
        if len(self.suits) == 1:
            leaderIndex = 0
        elif self.bossBattle == 1:
            for suit in self.suits:
                if suit.boss:
                    leaderIndex = self.suits.index(suit)
                    break

        else:
            maxTypeNum = -1
            for suit in self.suits:
                suitTypeNum = SuitDNA.getSuitType(suit.dna.name)
                if maxTypeNum < suitTypeNum:
                    maxTypeNum = suitTypeNum
                    leaderIndex = self.suits.index(suit)

        delay = FACEOFF_TAUNT_T
        suitTrack = Parallel()
        suitLeader = None
        for suit in self.suits:
            suit.setState('Battle')
            suitIsLeader = 0
            oneSuitTrack = Sequence()
            oneSuitTrack.append(Func(suit.loop, 'neutral'))
            oneSuitTrack.append(Func(suit.headsUp, toonPos))
            if self.suits.index(suit) == leaderIndex:
                suitLeader = suit
                suitIsLeader = 1
                if self.bossBattle == 1 and self.levelDoId in base.cr.doId2do:
                    level = base.cr.doId2do[self.levelDoId]
                    if suit.boss:
                        taunt = level.getBossTaunt()
                    else:
                        taunt = level.getBossBattleTaunt()
                else:
                    taunt = SuitBattleGlobals.getFaceoffTaunt(suit.getStyleName(), suit.doId)
                oneSuitTrack.append(Func(suit.setChatAbsolute, taunt, CFSpeech | CFTimeout))
            destPos, destHpr = self.getActorPosHpr(suit, self.suits)
            oneSuitTrack.append(Wait(delay))
            if suitIsLeader == 1:
                oneSuitTrack.append(Func(suit.clearChat))
            oneSuitTrack.append(self.createAdjustInterval(suit, destPos, destHpr))
            suitTrack.append(oneSuitTrack)

        suitHeight = suitLeader.getHeight()
        suitOffsetPnt = Point3(0, 0, suitHeight)
        toonTrack = Parallel()
        for toon in self.toons:
            oneToonTrack = Sequence()
            destPos, destHpr = self.getActorPosHpr(toon, self.toons)
            oneToonTrack.append(Wait(delay))
            oneToonTrack.append(self.createAdjustInterval(toon, destPos, destHpr, toon=1, run=1))
            toonTrack.append(oneToonTrack)

        if self.hasLocalToon():
            MidTauntCamHeight = suitHeight * 0.66
            MidTauntCamHeightLim = suitHeight - 1.8
            if MidTauntCamHeight < MidTauntCamHeightLim:
                MidTauntCamHeight = MidTauntCamHeightLim
            TauntCamY = 18
            TauntCamX = 0
            TauntCamHeight = random.choice((MidTauntCamHeight, 1, 11))
            camTrack = Sequence()
            camTrack.append(Func(base.camera.reparentTo, suitLeader))
            camTrack.append(Func(base.camLens.setMinFov, self.camFOFov/(4./3.)))
            camTrack.append(Func(base.camera.setPos, TauntCamX, TauntCamY, TauntCamHeight))
            camTrack.append(Func(base.camera.lookAt, suitLeader, suitOffsetPnt))
            camTrack.append(Wait(delay))
            camTrack.append(Func(base.camLens.setMinFov, self.camFov/(4./3.)))
            camTrack.append(Func(base.camera.wrtReparentTo, self))
            camTrack.append(Func(base.camera.setPos, self.camFOPos))
            camTrack.append(Func(base.camera.lookAt, suit))
        mtrack = Parallel(suitTrack, toonTrack)
        if self.hasLocalToon():
            NametagGlobals.setWant2dNametags(False)
            mtrack = Parallel(mtrack, camTrack)
        done = Func(callback)
        track = Sequence(mtrack, done, name=name)
        track.start(ts)
        self.storeInterval(track, name)
        return
Пример #24
0
    def __faceOff(self, ts, name, callback):
        if len(self.suits) == 0:
            self.notify.warning('__faceOff(): no suits.')
            return
        if len(self.toons) == 0:
            self.notify.warning('__faceOff(): no toons.')
            return
        elevatorPos = self.toons[0].getPos()
        if len(self.suits) == 1:
            leaderIndex = 0
        elif self.bossBattle == 1:
            leaderIndex = 1
        else:
            maxTypeNum = -1
            for suit in self.suits:
                suitTypeNum = SuitDNA.getSuitType(suit.dna.name)
                if maxTypeNum < suitTypeNum:
                    maxTypeNum = suitTypeNum
                    leaderIndex = self.suits.index(suit)

        delay = FACEOFF_TAUNT_T
        suitTrack = Parallel()
        suitLeader = None
        for suit in self.suits:
            suit.setState('Battle')
            suitIsLeader = 0
            oneSuitTrack = Sequence()
            oneSuitTrack.append(Func(suit.loop, 'neutral'))
            oneSuitTrack.append(Func(suit.headsUp, elevatorPos))
            if self.suits.index(suit) == leaderIndex:
                suitLeader = suit
                suitIsLeader = 1
                if self.bossBattle == 1:
                    taunt = self.getBossBattleTaunt()
                else:
                    taunt = SuitBattleGlobals.getFaceoffTaunt(
                        suit.getStyleName(), suit.doId)
                oneSuitTrack.append(
                    Func(suit.setChatAbsolute, taunt, CFSpeech | CFTimeout))
            destPos, destHpr = self.getActorPosHpr(suit, self.suits)
            oneSuitTrack.append(Wait(delay))
            if suitIsLeader == 1:
                oneSuitTrack.append(Func(suit.clearChat))
            oneSuitTrack.append(
                self.createAdjustInterval(suit, destPos, destHpr))
            suitTrack.append(oneSuitTrack)

        toonTrack = Parallel()
        for toon in self.toons:
            oneToonTrack = Sequence()
            destPos, destHpr = self.getActorPosHpr(toon, self.toons)
            oneToonTrack.append(Wait(delay))
            oneToonTrack.append(
                self.createAdjustInterval(toon,
                                          destPos,
                                          destHpr,
                                          toon=1,
                                          run=1))
            toonTrack.append(oneToonTrack)

        camTrack = Sequence()

        def setCamFov(fov):
            base.camLens.setMinFov(fov / (4.0 / 3.0))

        camTrack.append(Func(camera.wrtReparentTo, suitLeader))
        camTrack.append(Func(setCamFov, self.camFOFov))
        suitHeight = suitLeader.getHeight()
        suitOffsetPnt = Point3(0, 0, suitHeight)
        MidTauntCamHeight = suitHeight * 0.66
        MidTauntCamHeightLim = suitHeight - 1.8
        if MidTauntCamHeight < MidTauntCamHeightLim:
            MidTauntCamHeight = MidTauntCamHeightLim
        TauntCamY = 18
        TauntCamX = 0
        TauntCamHeight = random.choice((MidTauntCamHeight, 1, 11))
        camTrack.append(
            Func(camera.setPos, TauntCamX, TauntCamY, TauntCamHeight))
        camTrack.append(Func(camera.lookAt, suitLeader, suitOffsetPnt))
        camTrack.append(Wait(delay))
        camPos = Point3(0, -6, 4)
        camHpr = Vec3(0, 0, 0)
        camTrack.append(Func(camera.wrtReparentTo, base.localAvatar))
        camTrack.append(Func(setCamFov, settings['fieldofview']))
        camTrack.append(Func(camera.setPosHpr, camPos, camHpr))
        mtrack = Parallel(suitTrack, toonTrack, camTrack)
        done = Func(callback)
        track = Sequence(mtrack, done, name=name)
        track.start(ts)
        self.storeInterval(track, name)
Пример #25
0
    def __faceOff(self, ts, name, callback):
        if (len(self.suits) == 0):
            self.notify.warning('__faceOff(): no suits.')
            return
        if (len(self.toons) == 0):
            self.notify.warning('__faceOff(): no toons.')
            return

        toon = self.toons[0]
        point = self.toonPoints[0][0]
        toonPos = point[0]
        toonHpr = VBase3(point[1], 0.0, 0.0)

        p = toon.getPos(self)
        toon.setPos(self, p[0], p[1], 0.0)
        toon.setShadowHeight(0)

        if (len(self.suits) == 1):
            # TODO: it looks like we only have the suit that we bumped
            # into at this point; he may or may not be the boss.
            # Need to add other suits before battle generate on AI
            leaderIndex = 0
        else:
            if (self.bossBattle == 1):
                for suit in self.suits:
                    if suit.boss:
                        leaderIndex = self.suits.index(suit)
                        break
            else:
                # otherwise __genSuitInfos ensures nothing, so pick the suit with the highest type to be the leader
                maxTypeNum = -1
                for suit in self.suits:
                    suitTypeNum = SuitDNA.getSuitType(suit.dna.name)
                    if (maxTypeNum < suitTypeNum):
                        maxTypeNum = suitTypeNum
                        leaderIndex = self.suits.index(suit)

        delay = FACEOFF_TAUNT_T
        suitTrack = Parallel()
        suitLeader = None

        for suit in self.suits:
            suit.setState('Battle')
            suitIsLeader = 0
            oneSuitTrack = Sequence()
            # Suits stop what they're doing and look at the toons
            oneSuitTrack.append(Func(suit.loop, 'neutral'))
            oneSuitTrack.append(Func(suit.headsUp, toonPos))

            # Only the suit leader taunts the toons
            if (self.suits.index(suit) == leaderIndex):
                suitLeader = suit
                suitIsLeader = 1

                # TODO: have an inside of building taunt here
                if (self.bossBattle
                        == 1) and self.levelDoId in base.cr.doId2do:
                    level = base.cr.doId2do[self.levelDoId]
                    if suit.boss:
                        taunt = level.getBossTaunt()
                    else:
                        taunt = level.getBossBattleTaunt()
                else:
                    taunt = SuitBattleGlobals.getFaceoffTaunt(
                        suit.getStyleName(), suit.doId)

                oneSuitTrack.append(
                    Func(suit.setChatAbsolute, taunt, CFSpeech | CFTimeout))

            # Move all suits into position after taunt delay
            destPos, destHpr = self.getActorPosHpr(suit, self.suits)
            oneSuitTrack.append(Wait(delay))
            if (suitIsLeader == 1):
                oneSuitTrack.append(Func(suit.clearChat))
            oneSuitTrack.append(
                self.createAdjustInterval(suit, destPos, destHpr))
            suitTrack.append(oneSuitTrack)

        suitHeight = suitLeader.getHeight()
        suitOffsetPnt = Point3(0, 0, suitHeight)

        # Do the toons faceoff
        toonTrack = Parallel()
        for toon in self.toons:
            oneToonTrack = Sequence()
            destPos, destHpr = self.getActorPosHpr(toon, self.toons)
            oneToonTrack.append(Wait(delay))
            oneToonTrack.append(
                self.createAdjustInterval(toon,
                                          destPos,
                                          destHpr,
                                          toon=1,
                                          run=1))
            toonTrack.append(oneToonTrack)

        if (self.hasLocalToon()):
            # empirical hack to pick a mid-height view, left in to sortof match the old view
            MidTauntCamHeight = suitHeight * 0.66
            MidTauntCamHeightLim = suitHeight - 1.8
            if (MidTauntCamHeight < MidTauntCamHeightLim):
                MidTauntCamHeight = MidTauntCamHeightLim
            TauntCamY = 18
            TauntCamX = 0
            TauntCamHeight = random.choice((MidTauntCamHeight, 1, 11))

            # Put the camera somewhere
            camTrack = Sequence()
            camTrack.append(Func(camera.reparentTo, suitLeader))
            camTrack.append(Func(base.camLens.setMinFov, self.camFOFov))
            camTrack.append(
                Func(camera.setPos, TauntCamX, TauntCamY, TauntCamHeight))
            camTrack.append(Func(camera.lookAt, suitLeader, suitOffsetPnt))
            camTrack.append(Wait(delay))
            camTrack.append(Func(base.camLens.setMinFov, self.camFov))
            camTrack.append(Func(camera.wrtReparentTo, self))
            camTrack.append(Func(camera.setPos, self.camFOPos))
            camTrack.append(Func(camera.lookAt, suit))

        mtrack = Parallel(suitTrack, toonTrack)

        if (self.hasLocalToon()):
            # No arrows - they just get in the way
            NametagGlobals.setMasterArrowsOn(0)
            mtrack = Parallel(mtrack, camTrack)

        done = Func(callback)
        track = Sequence(mtrack, done, name=name)
        track.start(ts)
        self.storeInterval(track, name)
Пример #26
0
    def __faceOff(self, ts, name, callback):
        if len(self.suits) == 0:
            self.notify.warning('__faceOff(): no suits.')
            return
        if len(self.toons) == 0:
            self.notify.warning('__faceOff(): no toons.')
            return
        toon = self.toons[0]
        point = self.toonPoints[0][0]
        toonPos = point[0]
        toonHpr = VBase3(point[1], 0.0, 0.0)
        p = toon.getPos(self)
        toon.setPos(self, p[0], p[1], 0.0)
        toon.setShadowHeight(0)
        if len(self.suits) == 1:
            leaderIndex = 0
        elif self.bossBattle == 1:
            for suit in self.suits:
                if suit.boss:
                    leaderIndex = self.suits.index(suit)
                    break

        else:
            maxTypeNum = -1
            for suit in self.suits:
                suitTypeNum = SuitDNA.getSuitType(suit.dna.name)
                if maxTypeNum < suitTypeNum:
                    maxTypeNum = suitTypeNum
                    leaderIndex = self.suits.index(suit)

        delay = FACEOFF_TAUNT_T
        suitTrack = Parallel()
        suitLeader = None
        for suit in self.suits:
            suit.setState('Battle')
            suitIsLeader = 0
            oneSuitTrack = Sequence()
            oneSuitTrack.append(Func(suit.loop, 'neutral'))
            oneSuitTrack.append(Func(suit.headsUp, toonPos))
            if self.suits.index(suit) == leaderIndex:
                suitLeader = suit
                suitIsLeader = 1
                if self.bossBattle == 1 and self.levelDoId in base.cr.doId2do:
                    level = base.cr.doId2do[self.levelDoId]
                    if suit.boss:
                        taunt = level.getBossTaunt()
                    else:
                        taunt = level.getBossBattleTaunt()
                else:
                    taunt = SuitBattleGlobals.getFaceoffTaunt(
                        suit.getStyleName(), suit.doId)
                oneSuitTrack.append(
                    Func(suit.setChatAbsolute, taunt, CFSpeech | CFTimeout))
            destPos, destHpr = self.getActorPosHpr(suit, self.suits)
            oneSuitTrack.append(Wait(delay))
            if suitIsLeader == 1:
                oneSuitTrack.append(Func(suit.clearChat))
            oneSuitTrack.append(
                self.createAdjustInterval(suit, destPos, destHpr))
            suitTrack.append(oneSuitTrack)

        suitHeight = suitLeader.getHeight()
        suitOffsetPnt = Point3(0, 0, suitHeight)
        toonTrack = Parallel()
        for toon in self.toons:
            oneToonTrack = Sequence()
            destPos, destHpr = self.getActorPosHpr(toon, self.toons)
            oneToonTrack.append(Wait(delay))
            oneToonTrack.append(
                self.createAdjustInterval(toon,
                                          destPos,
                                          destHpr,
                                          toon=1,
                                          run=1))
            toonTrack.append(oneToonTrack)

        if self.hasLocalToon():
            MidTauntCamHeight = suitHeight * 0.66
            MidTauntCamHeightLim = suitHeight - 1.8
            if MidTauntCamHeight < MidTauntCamHeightLim:
                MidTauntCamHeight = MidTauntCamHeightLim
            TauntCamY = 18
            TauntCamX = 0
            TauntCamHeight = random.choice((MidTauntCamHeight, 1, 11))
            camTrack = Sequence()
            camTrack.append(Func(camera.reparentTo, suitLeader))
            camTrack.append(Func(base.camLens.setFov, self.camFOFov))
            camTrack.append(
                Func(camera.setPos, TauntCamX, TauntCamY, TauntCamHeight))
            camTrack.append(Func(camera.lookAt, suitLeader, suitOffsetPnt))
            camTrack.append(Wait(delay))
            camTrack.append(Func(base.camLens.setFov, self.camFov))
            camTrack.append(Func(camera.wrtReparentTo, self))
            camTrack.append(Func(camera.setPos, self.camFOPos))
            camTrack.append(Func(camera.lookAt, suit))
        mtrack = Parallel(suitTrack, toonTrack)
        if self.hasLocalToon():
            NametagGlobals.setMasterArrowsOn(0)
            mtrack = Parallel(mtrack, camTrack)
        done = Func(callback)
        track = Sequence(mtrack, done, name=name)
        track.start(ts)
        self.storeInterval(track, name)
        return
Пример #27
0
 def __faceOff(self, ts, name, callback):
     if len(self.suits) == 0:
         self.notify.warning('__faceOff(): no suits.')
         return
     if len(self.toons) == 0:
         self.notify.warning('__faceOff(): no toons.')
         return
     suit = self.suits[0]
     point = self.suitPoints[0][0]
     suitPos = point[0]
     suitHpr = VBase3(point[1], 0.0, 0.0)
     toon = self.toons[0]
     point = self.toonPoints[0][0]
     toonPos = point[0]
     toonHpr = VBase3(point[1], 0.0, 0.0)
     p = toon.getPos(self)
     toon.setPos(self, p[0], p[1], 0.0)
     toon.setShadowHeight(0)
     suit.setState('Battle')
     suitTrack = Sequence()
     toonTrack = Sequence()
     suitTrack.append(Func(suit.loop, 'neutral'))
     suitTrack.append(Func(suit.headsUp, toon))
     taunt = SuitBattleGlobals.getFaceoffTaunt(suit.getStyleName(),
                                               suit.doId)
     suitTrack.append(
         Func(suit.setChatAbsolute, taunt, CFSpeech | CFTimeout))
     toonTrack.append(Func(toon.loop, 'neutral'))
     toonTrack.append(Func(toon.headsUp, suit))
     suitHeight = suit.getHeight()
     suitOffsetPnt = Point3(0, 0, suitHeight)
     faceoffTime = self.calcFaceoffTime(self.getPos(), self.initialSuitPos)
     faceoffTime = max(faceoffTime, BATTLE_SMALL_VALUE)
     delay = FACEOFF_TAUNT_T
     if self.hasLocalToon():
         MidTauntCamHeight = suitHeight * 0.66
         MidTauntCamHeightLim = suitHeight - 1.8
         if MidTauntCamHeight < MidTauntCamHeightLim:
             MidTauntCamHeight = MidTauntCamHeightLim
         TauntCamY = 16
         TauntCamX = random.choice((-5, 5))
         TauntCamHeight = random.choice((MidTauntCamHeight, 1, 11))
         camTrack = Sequence()
         camTrack.append(Func(camera.wrtReparentTo, suit))
         camTrack.append(
             Func(base.camLens.setMinFov, self.camFOFov / (4.0 / 3.0)))
         camTrack.append(
             Func(camera.setPos, TauntCamX, TauntCamY, TauntCamHeight))
         camTrack.append(Func(camera.lookAt, suit, suitOffsetPnt))
         camTrack.append(Wait(delay))
         camTrack.append(
             Func(base.camLens.setMinFov, self.camFov / (4.0 / 3.0)))
         camTrack.append(Func(camera.wrtReparentTo, self))
         camTrack.append(Func(camera.setPos, self.camFOPos))
         camTrack.append(Func(camera.lookAt, suit.getPos(self)))
         camTrack.append(Wait(faceoffTime))
         if self.interactiveProp:
             camTrack.append(
                 Func(camera.lookAt,
                      self.interactiveProp.node.getPos(self)))
             camTrack.append(Wait(FACEOFF_LOOK_AT_PROP_T))
     suitTrack.append(Wait(delay))
     toonTrack.append(Wait(delay))
     suitTrack.append(Func(suit.headsUp, self, suitPos))
     suitTrack.append(Func(suit.clearChat))
     toonTrack.append(Func(toon.headsUp, self, toonPos))
     suitTrack.append(Func(suit.loop, 'walk'))
     suitTrack.append(
         LerpPosInterval(suit, faceoffTime, suitPos, other=self))
     suitTrack.append(Func(suit.loop, 'neutral'))
     suitTrack.append(Func(suit.setHpr, self, suitHpr))
     toonTrack.append(Func(toon.loop, 'run'))
     toonTrack.append(
         LerpPosInterval(toon, faceoffTime, toonPos, other=self))
     toonTrack.append(Func(toon.loop, 'neutral'))
     toonTrack.append(Func(toon.setHpr, self, toonHpr))
     if base.localAvatar == toon:
         soundTrack = Sequence(
             Wait(delay),
             SoundInterval(base.localAvatar.soundRun,
                           loop=1,
                           duration=faceoffTime,
                           node=base.localAvatar))
     else:
         soundTrack = Wait(delay + faceoffTime)
     mtrack = Parallel(suitTrack, toonTrack, soundTrack)
     if self.hasLocalToon():
         NametagGlobals.setWant2dNametags(False)
         mtrack = Parallel(mtrack, camTrack)
     done = Func(callback)
     track = Sequence(mtrack, done, name=name)
     track.delayDeletes = [
         DelayDelete.DelayDelete(toon, '__faceOff'),
         DelayDelete.DelayDelete(suit, '__faceOff')
     ]
     track.start(ts)
     self.storeInterval(track, name)