Esempio n. 1
0
    def setInvasionStatus(self, msgType, suitType, remaining, flags):
        if msgType not in ToontownGlobals.SuitInvasions:
            return

        if suitType in SuitDNA.suitHeadTypes:
            attributes = SuitBattleGlobals.SuitAttributes[suitType]
            suitNames = {
                'singular': attributes['name'],
                'plural': attributes['pluralname']
            }
        elif suitType in SuitDNA.suitDepts:
            suitNames = {
                'singular': SuitDNA.getDeptFullname(suitType),
                'plural': SuitDNA.getDeptFullnameP(suitType)
            }
        else:
            return

        track = Sequence()
        base.localAvatar.inventory.setInvasionCreditMultiplier(
            1 if msgType in ToontownGlobals.
            EndingInvasions else ToontownBattleGlobals.getInvasionMultiplier())

        for i, message in enumerate(ToontownGlobals.SuitInvasions[msgType]):
            track.append(Wait(5 if i else 1))
            track.append(
                Func(base.localAvatar.setSystemMessage, 0,
                     (TTLocalizer.SuitInvasionPrefix + message) % suitNames))

        track.start()
 def __setupSuitInfo(self, suit, bldgTrack, suitLevel, suitType):
     suitDeptIndex, suitTypeIndex, flags = simbase.air.suitInvasionManager.getInvadingCog()
     if self.respectInvasions:
         if suitDeptIndex is not None:
             bldgTrack = SuitDNA.suitDepts[suitDeptIndex]
         if suitTypeIndex is not None:
             suitName = SuitDNA.getSuitName(suitDeptIndex, suitTypeIndex)
             suitType = SuitDNA.getSuitType(suitName)
             suitLevel = min(max(suitLevel, suitType), suitType + 4)
     dna = SuitDNA.SuitDNA()
     dna.newSuitRandom(suitType, bldgTrack)
     suit.dna = dna
     suit.setLevel(suitLevel)
     return flags
 def __setupSuitInfo(self, suit, bldgTrack, suitLevel, suitType):
     suitDeptIndex, suitTypeIndex, flags = simbase.air.suitInvasionManager.getInvadingCog()
     if self.respectInvasions:
         if suitDeptIndex is not None:
             bldgTrack = SuitDNA.suitDepts[suitDeptIndex]
         if suitTypeIndex is not None:
             suitName = SuitDNA.getSuitName(suitDeptIndex, suitTypeIndex)
             suitType = SuitDNA.getSuitType(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 flags
Esempio n. 4
0
 def __setupSuitInfo(self, suit, bldgTrack, suitLevel, suitType):
     suitDeptIndex, suitTypeIndex, flags = simbase.air.suitInvasionManager.getInvadingCog(
     )
     if self.respectInvasions:
         if suitDeptIndex is not None:
             bldgTrack = SuitDNA.suitDepts[suitDeptIndex]
         if suitTypeIndex is not None:
             suitName = SuitDNA.getSuitName(suitDeptIndex, suitTypeIndex)
             suitType = SuitDNA.getSuitType(suitName)
             suitLevel = min(max(suitLevel, suitType), suitType + 4)
     dna = SuitDNA.SuitDNA()
     dna.newSuitRandom(suitType, bldgTrack)
     suit.dna = dna
     suit.setLevel(suitLevel)
     return flags
Esempio n. 5
0
 def __init__(self, index, collSolid, motionPath=None):
     self.prop = None
     self.suit = Suit.Suit()
     d = SuitDNA.SuitDNA()
     d.newSuit(Globals.Gameplay.MinionDnaName)
     self.suit.setDNA(d)
     self.suit.setScale(Globals.Gameplay.MinionScale)
     self.suit.nametag3d.stash()
     self.suit.nametag.destroy()
     swapAvatarShadowPlacer(self.suit, 'minion-%sShadowPlacer' % index)
     self.mopathNodePath = NodePath('mopathNodePath')
     self.suit.reparentTo(self.mopathNodePath)
     CogdoFlyingObstacle.__init__(
         self,
         Globals.Level.ObstacleTypes.Minion,
         index,
         self.mopathNodePath,
         collSolid,
         motionPath=motionPath,
         motionPattern=CogdoFlyingObstacle.MotionTypes.Loop,
         blendMotion=False,
         instanceModel=False)
     self.lastPos = None
     self.suit.loop('neutral')
     return
Esempio n. 6
0
 def parseLoadSuit(self, line):
     token, name, suitType = line
     suit = Suit.Suit()
     dna = SuitDNA.SuitDNA()
     dna.newSuit(suitType)
     suit.setDNA(dna)
     self.setVar(name, suit)
Esempio n. 7
0
    def __init__(self, air):
        DistributedSuitBaseAI.__init__(self, air, None)

        suitDNA = SuitDNA.SuitDNA()
        suitDNA.newSuit('f')
        self.dna = suitDNA
        self.setLevel(1)
 def createDiner(self, i):
     diner = Suit.Suit()
     diner.dna = SuitDNA.SuitDNA()
     level = self.dinerInfo[i][2]
     level -= 4
     dept = self.dinerInfo[i][3][i]
     diner.dna.newSuitRandom(level=level, dept=dept)
     diner.setDNA(diner.dna)
     diner.nametag3d.stash()
     diner.nametag.destroy()
     if self.useNewAnimations:
         diner.loop('sit', fromFrame=i)
     else:
         diner.pose('landing', 0)
     locator = self.tableGroup.find('**/chair_%d' % (i + 1))
     locatorScale = locator.getNetTransform().getScale()[0]
     correctHeadingNp = locator.attachNewNode('correctHeading')
     self.chairLocators[i] = correctHeadingNp
     heading = self.rotationsPerSeatIndex[i]
     correctHeadingNp.setH(heading)
     sitLocator = correctHeadingNp.attachNewNode('sitLocator')
     base.sitLocator = sitLocator
     pos = correctHeadingNp.getPos(render)
     if SuitDNA.getSuitBodyType(diner.dna.name) == 'c':
         sitLocator.setPos(0.5, 3.65, -3.75)
     else:
         sitLocator.setZ(-2.4)
         sitLocator.setY(2.5)
         sitLocator.setX(0.5)
     self.sitLocators[i] = sitLocator
     diner.setScale(1.0 / locatorScale)
     diner.reparentTo(sitLocator)
     newLoc = NodePath('serviceLoc-%d-%d' % (self.index, i))
     newLoc.reparentTo(correctHeadingNp)
     newLoc.setPos(0, 3.0, 1)
     self.serviceLocs[i] = newLoc
     base.serviceLoc = newLoc
     head = diner.find('**/joint_head')
     newIndicator = DinerStatusIndicator.DinerStatusIndicator(parent=head,
                                                              pos=Point3(
                                                                  0, 0,
                                                                  3.5),
                                                              scale=5.0)
     newIndicator.wrtReparentTo(diner)
     self.dinerStatusIndicators[i] = newIndicator
     return diner
 def getSuitName(self):
     if self.suitDeptIndex is not None:
         if self.suitTypeIndex is not None:
             return SuitDNA.getSuitName(self.suitDeptIndex, self.suitTypeIndex)
         else:
             return SuitDNA.suitDepts[self.suitDeptIndex]
     else:
         return SuitDNA.suitHeadTypes[0]
Esempio n. 10
0
 def getSuitName(self):
     if self.suitDeptIndex is not None:
         if self.suitTypeIndex is not None:
             return SuitDNA.getSuitName(self.suitDeptIndex, self.suitTypeIndex)
         else:
             return SuitDNA.suitDepts[self.suitDeptIndex]
     else:
         return SuitDNA.suitHeadTypes[0]
Esempio n. 11
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)
Esempio n. 12
0
 def __setupSuitInfo(self, suit, bldgTrack, suitLevel, suitType):
     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 False
    def setInvasionStatus(self, msgType, suitType, remaining, flags):
        if msgType not in ToontownGlobals.SuitInvasions:
            return

        if suitType in SuitDNA.suitHeadTypes:
            attributes = SuitBattleGlobals.SuitAttributes[suitType]
            suitNames = {'singular': attributes['name'], 'plural': attributes['pluralname']}
        elif suitType in SuitDNA.suitDepts:
            suitNames = {'singular': SuitDNA.getDeptFullname(suitType), 'plural': SuitDNA.getDeptFullnameP(suitType)}
        else:
            return

        track = Sequence()
        base.localAvatar.inventory.setInvasionCreditMultiplier(1 if msgType in ToontownGlobals.EndingInvasions else ToontownBattleGlobals.getInvasionMultiplier())

        for i, message in enumerate(ToontownGlobals.SuitInvasions[msgType]):
            track.append(Wait(5 if i else 1))
            track.append(Func(base.localAvatar.setSystemMessage, 0, (TTLocalizer.SuitInvasionPrefix + message) % suitNames))

        track.start()
Esempio n. 14
0
    def setupEnemy(self, suitAttribs):
        suitType = suitAttribs[0]
        self.suit = Suit.Suit()
        suitDNA = SuitDNA.SuitDNA()
        suitDNA.newSuit(suitType)
        self.suit.setDNA(suitDNA)
        self.suit.pose('walk', 0)
        self.suitName = 'Enemy-%s' % self.index
        self.suit.setName(self.suitName)
        self.suit.nametag3d.stash()
        self.suit.nametag.destroy()
        suitPosAttribs = suitAttribs[1]
        initX, initY, initZ = suitPosAttribs[0]
        initPos = Point3(initX, initY, initZ)
        if len(suitPosAttribs) == 3:
            finalX, finalY, finalZ = suitPosAttribs[1]
            finalPos = Point3(finalX, finalY, finalZ)
            posIvalDuration = suitPosAttribs[2]
            self.clearMoveIval()

            def getForwardIval(blendTypeStr, self = self):
                forwardIval = LerpPosInterval(self.suit, posIvalDuration, pos=finalPos, startPos=initPos, name='%s-moveFront' % self.suitName, blendType=blendTypeStr, fluid=1)
                return forwardIval

            def getBackwardIval(blendTypeStr, self = self):
                backwardIval = LerpPosInterval(self.suit, posIvalDuration, pos=initPos, startPos=finalPos, name='%s-moveBack' % self.suitName, blendType=blendTypeStr, fluid=1)
                return backwardIval

            if abs(finalZ - initZ) > 0.0:

                def setIsGoingUp(value):
                    self.isGoingUp = value

                self.isMovingUpDown = True
                self.suit.setH(90)
                self.suit.prop = None
                if self.suit.prop == None:
                    self.suit.prop = BattleProps.globalPropPool.getProp('propeller')
                    self.suit.prop.setScale(1.1)
                    self.suit.prop.setColor(1, 1, 0.6, 1)
                head = self.suit.find('**/joint_head')
                self.suit.prop.reparentTo(head)
                self.propTrack = Sequence(ActorInterval(self.suit.prop, 'propeller', startFrame=8, endFrame=25, playRate=2.0))
                self.animTrack = Sequence(ActorInterval(self.suit, 'landing', startFrame=8, endFrame=28, playRate=0.5), ActorInterval(self.suit, 'landing', startFrame=8, endFrame=28, playRate=-0.5))
                self.moveIval = Sequence(Func(setIsGoingUp, True), getForwardIval('easeInOut'), Func(setIsGoingUp, False), getBackwardIval('easeInOut'))
                self.suitSound = base.loadSfx('phase_4/audio/sfx/TB_propeller.ogg')
            else:
                self.isMovingLeftRight = True
                self.moveIval = Sequence(Func(self.setHeading, finalPos, initPos), getForwardIval('noBlend'), Func(self.setHeading, initPos, finalPos), getBackwardIval('noBlend'))
        self.suit.setPos(initX, initY, initZ)
        self.suit.dropShadow.hide()
        self.setupCollision()
        return
Esempio n. 15
0
    def makeSuit(self, suitType):
        suit = Suit.Suit()
        dna = SuitDNA.SuitDNA()
        dna.newSuit(suitType)
        suit.setStyle(dna)
        suit.isDisguised = 1
        suit.generateSuit()
        suit.setScale(1.05, 1.05, 2.05)
        suit.setPos(0, 0, -4.4)
        suit.reparentTo(self.toonHead)
        for part in suit.getHeadParts():
            part.hide()

        suit.loop('neutral')
 def foodDetach(self = self, diner = diner):
     if diner.getRightHand().getNumChildren() < 1:
         return
     foodModel = diner.getRightHand().getChild(0)
     (foodModel.reparentTo(serviceLoc),)
     (foodModel.setPosHpr(0, 0, 0, 0, 0, 0),)
     scaleAdj = 1
     if SuitDNA.getSuitBodyType(diner.dna.name) == 'c':
         scaleAdj = 0.6
     else:
         scakeAdj = 0.8
     oldScale = foodModel.getScale()
     newScale = oldScale / scaleAdj
     foodModel.setScale(newScale)
 def foodDetach(self=self, diner=diner):
     if diner.getRightHand().getNumChildren() < 1:
         return
     foodModel = diner.getRightHand().getChild(0)
     (foodModel.reparentTo(serviceLoc), )
     (foodModel.setPosHpr(0, 0, 0, 0, 0, 0), )
     scaleAdj = 1
     if SuitDNA.getSuitBodyType(diner.dna.name) == 'c':
         scaleAdj = 0.6
     else:
         scakeAdj = 0.8
     oldScale = foodModel.getScale()
     newScale = oldScale / scaleAdj
     foodModel.setScale(newScale)
Esempio n. 18
0
 def createSuitHead(self, suitName):
     suitDNA = SuitDNA.SuitDNA()
     suitDNA.newSuit(suitName)
     suit = Suit.Suit()
     suit.setDNA(suitDNA)
     headParts = suit.getHeadParts()
     head = hidden.attachNewNode('head')
     for part in headParts:
         copyPart = part.copyTo(head)
         copyPart.setDepthTest(1)
         copyPart.setDepthWrite(1)
     self.fitGeometry(head, fFlip=1)
     suit.delete()
     suit = None
     return head
 def __genSuitObject(self, suitDict, reserve):
     suit = self.cogCtor(simbase.air, self)
     dna = SuitDNA.SuitDNA()
     dna.newSuitRandom(level=SuitDNA.getRandomSuitType(suitDict["level"]), dept=suitDict["track"])
     suit.dna = dna
     suit.setLevel(suitDict["level"])
     suit.setSkeleRevives(suitDict.get("revives"))
     suit.setLevelDoId(self.level.doId)
     suit.setCogId(suitDict["cogId"])
     suit.setReserve(reserve)
     if suitDict["skeleton"]:
         suit.setSkelecog(1)
     suit.generateWithRequired(suitDict["zoneId"])
     suit.boss = suitDict["boss"]
     return suit
Esempio n. 20
0
 def __init__(self, numFloors, bldgLevel, bldgTrack, zone):
     self.dbg_4SuitsPerFloor = config.GetBool('4-suits-per-floor', 0)
     self.dbg_1SuitPerFloor = config.GetBool('1-suit-per-floor', 0)
     self.zoneId = zone
     self.numFloors = numFloors
     self.respectInvasions = 1
     dbg_defaultSuitName = simbase.config.GetString('suit-type', 'random')
     if dbg_defaultSuitName == 'random':
         self.dbg_defaultSuitType = None
     else:
         self.dbg_defaultSuitType = SuitDNA.getSuitType(dbg_defaultSuitName)
     if isinstance(bldgLevel, types.StringType):
         self.notify.warning('bldgLevel is a string!')
         bldgLevel = int(bldgLevel)
     self._genSuitInfos(numFloors, bldgLevel, bldgTrack)
     return
 def __init__(self, numFloors, bldgLevel, bldgTrack, zone):
     self.dbg_4SuitsPerFloor = config.GetBool('4-suits-per-floor', 0)
     self.dbg_1SuitPerFloor = config.GetBool('1-suit-per-floor', 0)
     self.zoneId = zone
     self.numFloors = numFloors
     self.respectInvasions = 1
     dbg_defaultSuitName = simbase.config.GetString('suit-type', 'random')
     if dbg_defaultSuitName == 'random':
         self.dbg_defaultSuitType = None
     else:
         self.dbg_defaultSuitType = SuitDNA.getSuitType(dbg_defaultSuitName)
     if isinstance(bldgLevel, types.StringType):
         self.notify.warning('bldgLevel is a string!')
         bldgLevel = int(bldgLevel)
     self._genSuitInfos(numFloors, bldgLevel, bldgTrack)
     return
 def foodAttach(self=self, diner=diner):
     if self.serviceLocs[chairIndex].getNumChildren() < 1:
         return
     foodModel = self.serviceLocs[chairIndex].getChild(0)
     (foodModel.reparentTo(diner.getRightHand()), )
     (foodModel.setHpr(Point3(0, -94, 0)), )
     (foodModel.setPos(Point3(-0.15, -0.7, -0.4)), )
     scaleAdj = 1
     if SuitDNA.getSuitBodyType(diner.dna.name) == 'c':
         scaleAdj = 0.6
         (foodModel.setPos(Point3(0.1, -0.25, -0.31)), )
     else:
         scaleAdj = 0.8
         (foodModel.setPos(Point3(-0.25, -0.85, -0.34)), )
     oldScale = foodModel.getScale()
     newScale = oldScale * scaleAdj
     foodModel.setScale(newScale)
 def foodAttach(self = self, diner = diner):
     if self.serviceLocs[chairIndex].getNumChildren() < 1:
         return
     foodModel = self.serviceLocs[chairIndex].getChild(0)
     (foodModel.reparentTo(diner.getRightHand()),)
     (foodModel.setHpr(Point3(0, -94, 0)),)
     (foodModel.setPos(Point3(-0.15, -0.7, -0.4)),)
     scaleAdj = 1
     if SuitDNA.getSuitBodyType(diner.dna.name) == 'c':
         scaleAdj = 0.6
         (foodModel.setPos(Point3(0.1, -0.25, -0.31)),)
     else:
         scaleAdj = 0.8
         (foodModel.setPos(Point3(-0.25, -0.85, -0.34)),)
     oldScale = foodModel.getScale()
     newScale = oldScale * scaleAdj
     foodModel.setScale(newScale)
Esempio n. 24
0
 def __init__(self, cogIndex, suitType, game, cogSpeed):
     self.cogIndex = cogIndex
     self.suitType = suitType
     self.game = game
     self.cogSpeed = cogSpeed
     suit = Suit.Suit()
     d = SuitDNA.SuitDNA()
     d.newSuit(suitType)
     suit.setDNA(d)
     suit.pose('walk', 0)
     self.suit = suit
     self.goal = CTGG.NoGoal
     self.goalId = CTGG.InvalidGoalId
     self.lastLocalTimeStampFromAI = 0
     self.lastPosFromAI = Point3(0, 0, 0)
     self.lastThinkTime = 0
     self.doneAdjust = False
     self.barrel = CTGG.NoBarrelCarried
     self.signalledAtReturnPos = False
     self.defaultPlayRate = 1.0
     self.netTimeSentToStartByHit = 0
     self.velocity = Vec3(0, 0, 0)
     self.oldVelocity = Vec3(0, 0, 0)
     self.acceleration = Vec3(0, 0, 0)
     self.bodyLength = self.CollisionRadius * 2
     self.cruiseDistance = 2 * self.bodyLength
     self.maxVelocity = self.cogSpeed
     self.maxAcceleration = 5.0
     self.perceptionRange = 6
     self.notify.debug('cogSpeed=%s' % self.cogSpeed)
     self.kaboomSound = loader.loadSfx(
         'phase_4/audio/sfx/MG_cannon_fire_alt.ogg')
     self.kaboom = loader.loadModel(
         'phase_4/models/minigames/ice_game_kaboom')
     self.kaboom.setScale(2.0)
     self.kaboom.setBillboardPointEye()
     self.kaboom.hide()
     self.kaboomTrack = None
     splatName = 'splat-creampie'
     self.splat = globalPropPool.getProp(splatName)
     self.splat.setBillboardPointEye()
     self.splatType = globalPropPool.getPropType(splatName)
     self.pieHitSound = globalBattleSoundCache.getSound(
         'AA_wholepie_only.ogg')
     return
Esempio n. 25
0
 def setupSuitBuilding(self, nodePath):
     if nodePath.isEmpty():
         return
     dnaStore = self.cr.playGame.dnaStore
     level = int(self.difficulty / 2) + 1
     suitNP = dnaStore.findNode('suit_landmark_' + chr(self.track) +
                                str(level))
     zoneId = dnaStore.getZoneFromBlockNumber(self.block)
     newParentNP = base.cr.playGame.hood.loader.zoneDict[zoneId]
     suitBuildingNP = suitNP.copyTo(newParentNP)
     buildingTitle = dnaStore.getTitleFromBlockNumber(self.block)
     if not buildingTitle:
         buildingTitle = TTLocalizer.CogsInc
     else:
         buildingTitle += TTLocalizer.CogsIncExt
     buildingTitle += '\n%s' % SuitDNA.getDeptFullname(chr(self.track))
     textNode = TextNode('sign')
     textNode.setTextColor(1.0, 1.0, 1.0, 1.0)
     textNode.setFont(ToontownGlobals.getSuitFont())
     textNode.setAlign(TextNode.ACenter)
     textNode.setWordwrap(17.0)
     textNode.setText(buildingTitle)
     textHeight = textNode.getHeight()
     zScale = (textHeight + 2) / 3.0
     signOrigin = suitBuildingNP.find('**/sign_origin;+s')
     backgroundNP = loader.loadModel('phase_5/models/modules/suit_sign')
     backgroundNP.reparentTo(signOrigin)
     backgroundNP.setPosHprScale(0.0, 0.0, textHeight * 0.8 / zScale, 0.0,
                                 0.0, 0.0, 8.0, 8.0, 8.0 * zScale)
     signTextNodePath = backgroundNP.attachNewNode(textNode.generate())
     signTextNodePath.setPosHprScale(0.0, 0.0,
                                     -0.21 + textHeight * 0.1 / zScale, 0.0,
                                     0.0, 0.0, 0.1, 0.1, 0.1 / zScale)
     signTextNodePath.setColor(1.0, 1.0, 1.0, 1.0)
     frontNP = suitBuildingNP.find('**/*_front/+GeomNode;+s')
     backgroundNP.wrtReparentTo(frontNP)
     frontNP.node().setEffect(DecalEffect.make())
     signTextNodePath.setAttrib(DepthOffsetAttrib.make(1))
     suitBuildingNP.setName('sb' + str(self.block) + ':_landmark__DNARoot')
     suitBuildingNP.setPosHprScale(nodePath, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
                                   1.0, 1.0, 1.0)
     suitBuildingNP.flattenMedium()
     self.loadElevator(suitBuildingNP)
     return suitBuildingNP
Esempio n. 26
0
 def __init__(self, nest, index, suitDnaName = 'le'):
     FSM.__init__(self, 'CogdoFlyingLegalEagle')
     self.defaultTransitions = {'Off': ['Roost'],
      'Roost': ['TakeOff', 'Off'],
      'TakeOff': ['LockOnToon', 'LandOnNest', 'Off'],
      'LockOnToon': ['RetreatToNest', 'ChargeUpAttack', 'Off'],
      'ChargeUpAttack': ['RetreatToNest', 'Attack', 'Off'],
      'Attack': ['RetreatToSky', 'Off'],
      'RetreatToSky': ['Cooldown', 'Off'],
      'Cooldown': ['LockOnToon', 'LandOnNest', 'Off'],
      'RetreatToNest': ['LandOnNest', 'Off'],
      'LandOnNest': ['Roost', 'Off']}
     self.index = index
     self.nest = nest
     self.target = None
     self.isEagleInterested = False
     self.collSphere = None
     self.suit = Suit.Suit()
     d = SuitDNA.SuitDNA()
     d.newSuit(suitDnaName)
     self.suit.setDNA(d)
     self.suit.reparentTo(render)
     swapAvatarShadowPlacer(self.suit, 'legalEagle-%sShadowPlacer' % index)
     self.suit.setPos(self.nest.getPos(render))
     self.suit.setHpr(-180, 0, 0)
     self.suit.stash()
     self.prop = None
     self.attachPropeller()
     head = self.suit.find('**/joint_head')
     self.interestConeOrigin = self.nest.attachNewNode('fakeHeadNodePath')
     self.interestConeOrigin.setPos(render, head.getPos(render) + Vec3(0, Globals.LegalEagle.InterestConeOffset, 0))
     self.attackTargetPos = None
     self.startOfRetreatToSkyPos = None
     pathModel = CogdoUtil.loadFlyingModel('legalEaglePaths')
     self.chargeUpMotionPath = Mopath.Mopath(name='chargeUpMotionPath-%i' % self.index)
     self.chargeUpMotionPath.loadNodePath(pathModel.find('**/charge_path'))
     self.retreatToSkyMotionPath = Mopath.Mopath(name='retreatToSkyMotionPath-%i' % self.index)
     self.retreatToSkyMotionPath.loadNodePath(pathModel.find('**/retreat_path'))
     audioMgr = base.cogdoGameAudioMgr
     self._screamSfx = audioMgr.createSfx('legalEagleScream', self.suit)
     self.initIntervals()
     self.suit.nametag3d.stash()
     self.suit.nametag.destroy()
     return
Esempio n. 27
0
 def __init__(
         self,
         serialNum,
         maze,
         randomNumGen,
         cellWalkPeriod,
         difficulty,
         suitDnaName='f',
         startTile=None,
         ticFreq=MazeGameGlobals.SUIT_TIC_FREQ,
         walkSameDirectionProb=MazeGameGlobals.WALK_SAME_DIRECTION_PROB,
         walkTurnAroundProb=MazeGameGlobals.WALK_TURN_AROUND_PROB,
         uniqueRandomNumGen=True,
         walkAnimName=None):
     self.serialNum = serialNum
     self.maze = maze
     if uniqueRandomNumGen:
         self.rng = RandomNumGen(randomNumGen)
     else:
         self.rng = randomNumGen
     self.difficulty = difficulty
     self._walkSameDirectionProb = walkSameDirectionProb
     self._walkTurnAroundProb = walkTurnAroundProb
     self._walkAnimName = walkAnimName or 'walk'
     self.suit = Suit.Suit()
     d = SuitDNA.SuitDNA()
     d.newSuit(suitDnaName)
     self.suit.setDNA(d)
     self.suit.nametag3d.stash()
     self.suit.nametag.destroy()
     if startTile is None:
         defaultStartPos = MazeGameGlobals.SUIT_START_POSITIONS[
             self.serialNum]
         self.startTile = (defaultStartPos[0] * self.maze.width,
                           defaultStartPos[1] * self.maze.height)
     else:
         self.startTile = startTile
     self.ticFreq = ticFreq
     self.ticPeriod = int(cellWalkPeriod)
     self.cellWalkDuration = float(self.ticPeriod) / float(self.ticFreq)
     self.turnDuration = 0.6 * self.cellWalkDuration
     return
 def createDiner(self, i):
     diner = Suit.Suit()
     diner.dna = SuitDNA.SuitDNA()
     level = self.dinerInfo[i][2]
     level -= 4
     dept = self.dinerInfo[i][3][i]
     diner.dna.newSuitRandom(level=level, dept=dept)
     diner.setDNA(diner.dna)
     diner.nametag3d.stash()
     diner.nametag.destroy()
     if self.useNewAnimations:
         diner.loop('sit', fromFrame=i)
     else:
         diner.pose('landing', 0)
     locator = self.tableGroup.find('**/chair_%d' % (i + 1))
     locatorScale = locator.getNetTransform().getScale()[0]
     correctHeadingNp = locator.attachNewNode('correctHeading')
     self.chairLocators[i] = correctHeadingNp
     heading = self.rotationsPerSeatIndex[i]
     correctHeadingNp.setH(heading)
     sitLocator = correctHeadingNp.attachNewNode('sitLocator')
     base.sitLocator = sitLocator
     pos = correctHeadingNp.getPos(render)
     if SuitDNA.getSuitBodyType(diner.dna.name) == 'c':
         sitLocator.setPos(0.5, 3.65, -3.75)
     else:
         sitLocator.setZ(-2.4)
         sitLocator.setY(2.5)
         sitLocator.setX(0.5)
     self.sitLocators[i] = sitLocator
     diner.setScale(1.0 / locatorScale)
     diner.reparentTo(sitLocator)
     newLoc = NodePath('serviceLoc-%d-%d' % (self.index, i))
     newLoc.reparentTo(correctHeadingNp)
     newLoc.setPos(0, 3.0, 1)
     self.serviceLocs[i] = newLoc
     base.serviceLoc = newLoc
     head = diner.find('**/joint_head')
     newIndicator = DinerStatusIndicator.DinerStatusIndicator(parent=head, pos=Point3(0, 0, 3.5), scale=5.0)
     newIndicator.wrtReparentTo(diner)
     self.dinerStatusIndicators[i] = newIndicator
     return diner
Esempio n. 29
0
 def createSuit(self):
     self.suit = Suit.Suit()
     suitDNA = SuitDNA.SuitDNA()
     suitDNA.newSuit('f')
     self.suit.setDNA(suitDNA)
     self.suit.nametag3d.stash()
     self.suit.nametag.destroy()
     self.suit.loop('neutral')
     self.suit.setPosHpr(-20, 8, 0, 0, 0, 0)
     self.suit.reparentTo(self.interior)
     self.suitWalkTrack = Sequence(
         self.suit.hprInterval(0.1, Vec3(0, 0, 0)),
         Func(self.suit.loop, 'walk'),
         self.suit.posInterval(2, Point3(-20, 20, 0)),
         Func(self.suit.loop, 'neutral'), Wait(1.0),
         self.suit.hprInterval(0.1, Vec3(180, 0, 0)),
         Func(self.suit.loop, 'walk'),
         self.suit.posInterval(2, Point3(-20, 10, 0)),
         Func(self.suit.loop, 'neutral'), Wait(1.0))
     self.suitWalkTrack.loop()
 def setupSuitBuilding(self, nodePath):
     if nodePath.isEmpty():
         return
     dnaStore = self.cr.playGame.dnaStore
     level = int(self.difficulty / 2) + 1
     suitNP = dnaStore.findNode("suit_landmark_" + chr(self.track) + str(level))
     zoneId = dnaStore.getZoneFromBlockNumber(self.block)
     newParentNP = base.cr.playGame.hood.loader.zoneDict[zoneId]
     suitBuildingNP = suitNP.copyTo(newParentNP)
     buildingTitle = dnaStore.getTitleFromBlockNumber(self.block)
     if not buildingTitle:
         buildingTitle = TTLocalizer.CogsInc
     else:
         buildingTitle += TTLocalizer.CogsIncExt
     buildingTitle += "\n%s" % SuitDNA.getDeptFullname(chr(self.track))
     textNode = TextNode("sign")
     textNode.setTextColor(1.0, 1.0, 1.0, 1.0)
     textNode.setFont(ToontownGlobals.getSuitFont())
     textNode.setAlign(TextNode.ACenter)
     textNode.setWordwrap(17.0)
     textNode.setText(buildingTitle)
     textHeight = textNode.getHeight()
     zScale = (textHeight + 2) / 3.0
     signOrigin = suitBuildingNP.find("**/sign_origin;+s")
     backgroundNP = loader.loadModel("phase_5/models/modules/suit_sign")
     backgroundNP.reparentTo(signOrigin)
     backgroundNP.setPosHprScale(0.0, 0.0, textHeight * 0.8 / zScale, 0.0, 0.0, 0.0, 8.0, 8.0, 8.0 * zScale)
     signTextNodePath = backgroundNP.attachNewNode(textNode.generate())
     signTextNodePath.setPosHprScale(
         0.0, 0.0, -0.21 + textHeight * 0.1 / zScale, 0.0, 0.0, 0.0, 0.1, 0.1, 0.1 / zScale
     )
     signTextNodePath.setColor(1.0, 1.0, 1.0, 1.0)
     frontNP = suitBuildingNP.find("**/*_front/+GeomNode;+s")
     backgroundNP.wrtReparentTo(frontNP)
     frontNP.node().setEffect(DecalEffect.make())
     signTextNodePath.setAttrib(DepthOffsetAttrib.make(1))
     suitBuildingNP.setName("sb" + str(self.block) + ":_landmark__DNARoot")
     suitBuildingNP.setPosHprScale(nodePath, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0)
     suitBuildingNP.flattenMedium()
     self.loadElevator(suitBuildingNP)
     return suitBuildingNP
 def sendInvasionStatus(self):
     if self.invading:
         if self.suitDeptIndex is not None:
             if self.suitTypeIndex is not None:
                 type = SuitBattleGlobals.SuitAttributes[self.getSuitName()]["name"]
             else:
                 type = SuitDNA.getDeptFullname(self.getSuitName())
         else:
             type = None
         status = {
             "invasion": {
                 "type": type,
                 "flags": self.flags,
                 "remaining": self.remaining,
                 "total": self.total,
                 "start": self.start,
             }
         }
     else:
         status = {"invasion": None}
     self.air.sendNetEvent("shardStatus", [self.air.ourChannel, status])
 def loadCogJuror(self):
     self.cleanupCogJuror()
     self.cogJuror = Suit.Suit()
     level = self.randomGenerator.randrange(len(SuitDNA.suitsPerLevel))
     self.cogJuror.dna = SuitDNA.SuitDNA()
     self.cogJuror.dna.newSuitRandom(level=level, dept='l')
     self.cogJuror.setDNA(self.cogJuror.dna)
     self.cogJuror.pose('landing', 0)
     self.cogJuror.reparentTo(self.nodePath)
     self.cogJuror.prop = None
     if self.cogJuror.prop == None:
         self.cogJuror.prop = BattleProps.globalPropPool.getProp(
             'propeller')
     head = self.cogJuror.find('**/joint_head')
     self.cogJuror.prop.reparentTo(head)
     self.propTrack = Sequence(
         ActorInterval(self.cogJuror.prop,
                       'propeller',
                       startFrame=8,
                       endFrame=25))
     return
Esempio n. 33
0
 def sendInvasionStatus(self):
     if self.invading:
         if self.suitDeptIndex is not None:
             if self.suitTypeIndex is not None:
                 type = SuitBattleGlobals.SuitAttributes[self.getSuitName()]['name']
             else:
                 type = SuitDNA.getDeptFullname(self.getSuitName())
         else:
             type = None
         status = {
             'invasion': {
                 'type': type,
                 'flags': self.flags,
                 'remaining': self.remaining,
                 'total': self.total,
                 'start': self.start
             }
         }
     else:
         status = {'invasion': None}
     self.air.sendNetEvent('shardStatus', [self.air.ourChannel, status])
Esempio n. 34
0
    def load(self):
        self.notify.debug('load')
        DistributedMinigame.load(self)
        self.defineConstants()
        groundModels = [
            'phase_4/models/minigames/treehouse_2players',
            'phase_4/models/minigames/treehouse_2players',
            'phase_4/models/minigames/treehouse_3players',
            'phase_4/models/minigames/treehouse_4players'
        ]
        index = self.getNumPlayers() - 1
        self.ground = loader.loadModel(groundModels[index])
        self.ground.setHpr(180, -90, 0)
        self.dropShadow = loader.loadModel('phase_3/models/props/drop_shadow')
        self.dropObjModels = {}
        for objType in DropObjectTypes:
            if objType.name not in ['anvil', self.fruitName]:
                continue
            model = loader.loadModel(objType.modelPath)
            self.dropObjModels[objType.name] = model
            modelScales = {
                'apple': 0.7,
                'orange': 0.7,
                'pear': 0.5,
                'coconut': 0.7,
                'watermelon': 0.6,
                'pineapple': 0.45
            }
            if objType.name in modelScales:
                model.setScale(modelScales[objType.name])
            if objType == Name2DropObjectType['pear']:
                model.setZ(-.6)
            if objType == Name2DropObjectType['coconut']:
                model.setP(180)
            if objType == Name2DropObjectType['watermelon']:
                model.setH(135)
                model.setZ(-.5)
            if objType == Name2DropObjectType['pineapple']:
                model.setZ(-1.7)
            if objType == Name2DropObjectType['anvil']:
                model.setZ(-self.ObjRadius)
            model.flattenMedium()

        self.music = base.loadMusic('phase_4/audio/bgm/MG_toontag.ogg')
        self.sndGoodCatch = base.loadSfx(
            'phase_4/audio/sfx/SZ_DD_treasure.ogg')
        self.sndOof = base.loadSfx('phase_4/audio/sfx/MG_cannon_hit_dirt.ogg')
        self.sndAnvilLand = base.loadSfx(
            'phase_4/audio/sfx/AA_drop_anvil_miss.ogg')
        self.sndPerfect = base.loadSfx('phase_4/audio/sfx/ring_perfect.ogg')
        self.toonSDs = {}
        avId = self.localAvId
        toonSD = CatchGameToonSD.CatchGameToonSD(avId, self)
        self.toonSDs[avId] = toonSD
        toonSD.load()
        if self.WantSuits:
            suitTypes = ['f', 'tm', 'pp', 'dt']
            self.suits = []
            for type in suitTypes:
                suit = Suit.Suit()
                d = SuitDNA.SuitDNA()
                d.newSuit(type)
                suit.setDNA(d)
                suit.nametag3d.stash()
                suit.nametag.destroy()
                suit.pose('walk', 0)
                self.suits.append(suit)

        self.__textGen = TextNode('ringGame')
        self.__textGen.setFont(ToontownGlobals.getSignFont())
        self.__textGen.setAlign(TextNode.ACenter)
        self.introMovie = self.getIntroMovie()
Esempio n. 35
0
    def getQuestIntervalList(self,
                             toon,
                             deathList,
                             toonList,
                             origQuestsList,
                             itemList,
                             helpfulToonsList=[]):
        avId = toon.getDoId()
        tickDelay = 0.2
        intervalList = []

        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
            isBoss = flags & ToontownBattleGlobals.DLF_BOSS
            isSupervisor = flags & ToontownBattleGlobals.DLF_SUPERVISOR
            isVirtual = flags & ToontownBattleGlobals.DLF_VIRTUAL
            hasRevives = flags & ToontownBattleGlobals.DLF_REVIVES
            if isBoss > 0:
                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,
                'isBoss': isBoss,
                '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:
                        num = quest.doesCogCount(avId, cogDict, zoneId)

                        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
    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.reparentTo, base.localAvatar))
        camTrack.append(Func(setCamFov, settings["fov"]))
        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)
        return
 def __genNormalSuitType(self, lvl):
     if self.dbg_defaultSuitType != None:
         return self.dbg_defaultSuitType
     return SuitDNA.getRandomSuitType(lvl)
 def __genNormalSuitType(self, lvl):
     return SuitDNA.getRandomSuitType(lvl)
    def getQuestIntervalList(self, toon, deathList, toonList, origQuestsList, itemList, helpfulToonsList = []):
        avId = toon.getDoId()
        tickDelay = 0.2
        intervalList = []

        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
            isBoss = flags & ToontownBattleGlobals.DLF_BOSS
            isSupervisor = flags & ToontownBattleGlobals.DLF_SUPERVISOR
            isVirtual = flags & ToontownBattleGlobals.DLF_VIRTUAL
            hasRevives = flags & ToontownBattleGlobals.DLF_REVIVES
            if isBoss > 0:
                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,
             'isBoss': isBoss,
             '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:
                        num = quest.doesCogCount(avId, cogDict, zoneId)

                        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
    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.setMinFov, self.camFOFov / (4. / 3.)))
            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 / (4. / 3.)))
            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
Esempio n. 41
0
 def __genNormalSuitType(self, lvl):
     if self.dbg_defaultSuitType != None:
         return self.dbg_defaultSuitType
     return SuitDNA.getRandomSuitType(lvl)
    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.setMinFov, self.camFOFov/(4./3.)))
            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/(4./3.)))
            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
Esempio n. 43
0
    def load(self):
        CogdoGameMovie.load(self)
        self.toonDNA = ToonDNA.ToonDNA()
        self.toonDNA.newToonFromProperties('dss', 'ss', 'm', 'm', 2, 0, 2, 2,
                                           1, 8, 1, 8, 1, 14, 0)
        self.toonHead = Toon.Toon()
        self.toonHead.setDNA(self.toonDNA)
        self.makeSuit('sc')
        self.toonHead.getGeomNode().setDepthWrite(1)
        self.toonHead.getGeomNode().setDepthTest(1)
        self.toonHead.loop('neutral')
        self.toonHead.setPosHprScale(-0.73, 0, -1.27, 180, 0, 0, 0.18, 0.18,
                                     0.18)
        self.toonHead.reparentTo(hidden)
        self.toonHead.startBlink()
        self.cogHead = Suit.Suit()
        self.cogDNA = SuitDNA.SuitDNA()
        self.cogDNA.newSuit('ms')
        self.cogHead.setDNA(self.cogDNA)
        self.cogHead.getGeomNode().setDepthWrite(1)
        self.cogHead.getGeomNode().setDepthTest(1)
        self.cogHead.loop('neutral')
        self.cogHead.setPosHprScale(-0.73, 0, -1.46, 180, 0, 0, 0.14, 0.14,
                                    0.14)
        self.cogHead.reparentTo(hidden)
        self.cogHead.nametag3d.hide()
        self.clipPlane = self.toonHead.attachNewNode(PlaneNode('clip'))
        self.clipPlane.node().setPlane(Plane(0, 0, 1, 0))
        self.clipPlane.setPos(0, 0, 2.45)
        audioMgr = base.cogdoGameAudioMgr
        self._cogDialogueSfx = audioMgr.createSfx('cogDialogue')
        self._toonDialogueSfx = audioMgr.createSfx('toonDialogue')
        suitData = Globals.SuitData[Globals.SuitTypes.Boss]
        bossSuit = Suit.Suit()
        d = SuitDNA.SuitDNA()
        d.newSuit(suitData['dnaName'])
        bossSuit.setDNA(d)
        bossSuit.nametag3d.stash()
        bossSuit.nametag.destroy()
        bossSuit.setScale(suitData['scale'])
        bossSuit.loop('neutral')
        bossSuit.reparentTo(render)
        bossSuit.setPos(self._exit, -5, -5, 0)
        bossSuit.lookAt(self._exit)
        self._suits.append(bossSuit)
        self._camHelperNode = NodePath('CamHelperNode')
        self._camHelperNode.reparentTo(render)
        dialogue = TTLocalizer.CogdoMazeIntroMovieDialogue
        introDuration = Globals.IntroDurationSeconds
        waitDuration = introDuration / len(dialogue)

        def start():
            camera.wrtReparentTo(render)
            self._exit.open(animate=False)

        def showBoss():
            self._setCamTarget(bossSuit,
                               20,
                               offset=Point3(0, 0, 7),
                               angle=Point3(0, 15, 0))
            bossSuit.loop('victory')
            self._state = 1

        def showExit():
            self._setCamTarget(self._exit,
                               10,
                               offset=Point3(0, 0, 0),
                               angle=Point3(0, 60, 0))
            self._exit.close()
            self._state = 2

        showExitIval = Parallel(
            camera.posInterval(waitDuration * 0.5, (10, -25, 20),
                               other=self._exit,
                               blendType='easeInOut'),
            Sequence(
                Wait(waitDuration * 0.25), Func(bossSuit.play, 'effort'),
                camera.hprInterval(waitDuration * 0.25, (30, -30, 0),
                                   blendType='easeInOut'),
                Func(self._exit.close), Wait(waitDuration * 0.5)))

        def showWaterCooler():
            wc = self._maze.getWaterCoolers()[0]
            self._setCamTarget(wc, 25, angle=Point3(-30, 60, 0))
            camera.wrtReparentTo(self._camHelperNode)
            self._state = 3

        def end():
            self._stopUpdateTask()

        self._ival = Sequence(
            Func(start),
            Func(self.displayLine, 'toon', self._getRandomLine(dialogue[0])),
            showExitIval, Func(showWaterCooler),
            Func(self.displayLine, 'toon', self._getRandomLine(dialogue[1])),
            Wait(waitDuration), Func(showBoss),
            bossSuit.hprInterval(1.0,
                                 bossSuit.getHpr() + Point3(180, 0, 0),
                                 blendType='easeInOut'),
            Func(self.displayLine, 'toon', self._getRandomLine(dialogue[2])),
            Wait(waitDuration - 1.0), Func(end))
        self._startUpdateTask()
    def load(self):
        CogdoGameMovie.load(self)
        self.toonDNA = ToonDNA.ToonDNA()
        self.toonDNA.newToonFromProperties('dss', 'ss', 'm', 'm', 2, 0, 2, 2,
                                           1, 8, 1, 8, 1, 14, 0)
        self.toonHead = Toon.Toon()
        self.toonHead.setDNA(self.toonDNA)
        self.makeSuit('sc')
        self.toonHead.getGeomNode().setDepthWrite(1)
        self.toonHead.getGeomNode().setDepthTest(1)
        self.toonHead.loop('neutral')
        self.toonHead.setPosHprScale(-0.73, 0, -1.27, 180, 0, 0, 0.18, 0.18,
                                     0.18)
        self.toonHead.reparentTo(hidden)
        self.toonHead.startBlink()
        self.cogHead = Suit.Suit()
        self.cogDNA = SuitDNA.SuitDNA()
        self.cogDNA.newSuit('le')
        self.cogHead.setDNA(self.cogDNA)
        self.cogHead.getGeomNode().setDepthWrite(1)
        self.cogHead.getGeomNode().setDepthTest(1)
        self.cogHead.loop('neutral')
        self.cogHead.setPosHprScale(-0.74, 0, -1.79, 180, 0, 0, 0.12, 0.14,
                                    0.14)
        self.cogHead.reparentTo(hidden)
        self.cogHead.nametag3d.hide()
        self.clipPlane = self.toonHead.attachNewNode(PlaneNode('clip'))
        self.clipPlane.node().setPlane(Plane(0, 0, 1, 0))
        self.clipPlane.setPos(0, 0, 2.45)
        audioMgr = base.cogdoGameAudioMgr
        self._cogDialogueSfx = audioMgr.createSfx('cogDialogue')
        self._toonDialogueSfx = audioMgr.createSfx('toonDialogue')

        def start():
            camera.wrtReparentTo(render)
            self._startUpdateTask()

        def end():
            self._stopUpdateTask()

        introDuration = Globals.Gameplay.IntroDurationSeconds
        dialogue = TTLocalizer.CogdoFlyingIntroMovieDialogue
        waitDur = introDuration / len(dialogue)
        flyDur = introDuration - waitDur * 0.5
        flyThroughIval = Parallel(
            camera.posInterval(flyDur,
                               self._exit.getPos(render) + Point3(0, -22, 1),
                               blendType='easeInOut'),
            camera.hprInterval(flyDur, Point3(0, 5, 0), blendType='easeInOut'))
        self._ival = Sequence(
            Func(start),
            Parallel(
                flyThroughIval,
                Sequence(
                    Func(self.displayLine, 'cog',
                         self._getRandomLine(dialogue[0])), Wait(waitDur),
                    Func(self.displayLine, 'toon',
                         self._getRandomLine(dialogue[1])), Wait(waitDur),
                    Func(self.displayLine, 'cog',
                         self._getRandomLine(dialogue[2])), Wait(waitDur))),
            Func(end))