Exemplo n.º 1
0
        def makePetList(self):
            self.numPets = len(self.petSeeds)
            self.curPet = 0
            self.petDNA = []
            self.petName = []
            self.petDesc = []
            self.petCost = []
            for i in xrange(self.numPets):
                random.seed(self.petSeeds[i])
                zoneId = ZoneUtil.getCanonicalSafeZoneId(base.localAvatar.getZoneId())
                name, dna, traitSeed = PetUtil.getPetInfoFromSeed(self.petSeeds[i], zoneId)
                cost = PetUtil.getPetCostFromSeed(self.petSeeds[i], zoneId)
                traits = PetTraits.PetTraits(traitSeed, zoneId)
                traitList = traits.getExtremeTraitDescriptions()
                numGenders = len(PetDNA.PetGenders)
                gender = i % numGenders
                PetDNA.setGender(dna, gender)
                self.petDNA.append(dna)
                self.petName.append(TTLocalizer.PetshopUnknownName)
                descList = []
                descList.append(TTLocalizer.PetshopDescGender % PetDNA.getGenderString(gender=gender))
                if traitList:
                    descList.append(TTLocalizer.PetshopDescTrait % traitList[0])
                else:
                    descList.append(TTLocalizer.PetshopDescTrait % TTLocalizer.PetshopDescStandard)
                traitList.extend(['',
                 '',
                 '',
                 ''])
                for trait in traitList[1:4]:
                    descList.append('\t%s' % trait)

                descList.append(TTLocalizer.PetshopDescCost % cost)
                self.petDesc.append('\n'.join(descList))
                self.petCost.append(cost)
Exemplo n.º 2
0
        def makePetList(self):
            self.numPets = len(self.petSeeds)
            self.curPet = 0
            self.petDNA = []
            self.petName = []
            self.petDesc = []
            self.petCost = []
            for i in xrange(self.numPets):
                random.seed(self.petSeeds[i])
                zoneId = ZoneUtil.getCanonicalSafeZoneId(base.localAvatar.getZoneId())
                name, dna, traitSeed = PetUtil.getPetInfoFromSeed(self.petSeeds[i], zoneId)
                cost = PetUtil.getPetCostFromSeed(self.petSeeds[i], zoneId)
                traits = PetTraits.PetTraits(traitSeed, zoneId)
                traitList = traits.getExtremeTraitDescriptions()
                numGenders = len(PetDNA.PetGenders)
                gender = i % numGenders
                PetDNA.setGender(dna, gender)
                self.petDNA.append(dna)
                self.petName.append(TTLocalizer.PetshopUnknownName)
                descList = []
                descList.append(TTLocalizer.PetshopDescGender % PetDNA.getGenderString(gender=gender))
                if traitList:
                    descList.append(TTLocalizer.PetshopDescTrait % traitList[0])
                else:
                    descList.append(TTLocalizer.PetshopDescTrait % TTLocalizer.PetshopDescStandard)
                traitList.extend(['',
                 '',
                 '',
                 ''])
                for trait in traitList[1:4]:
                    descList.append('\t%s' % trait)

                descList.append(TTLocalizer.PetshopDescCost % cost)
                self.petDesc.append(string.join(descList, '\n'))
                self.petCost.append(cost)
Exemplo n.º 3
0
def getPetInfoFromSeed(seed, safezoneId):
    S = random.getstate()
    random.seed(seed)
    dnaArray = PetDNA.getRandomPetDNA(safezoneId)
    gender = PetDNA.getGender(dnaArray)
    nameString = TTLocalizer.getRandomPetName(gender=gender, seed=seed)
    traitSeed = PythonUtil.randUint31()
    random.setstate(S)
    return (nameString, dnaArray, traitSeed)
Exemplo n.º 4
0
        def makePetList(self):
            """
            This should get called when we first enter the PetChooser.
            It creates the list of toons that are available here.
            """

            self.numPets = len(self.petSeeds)
            self.curPet = 0

            self.petDNA = []
            self.petName = []
            self.petDesc = []
            self.petCost = []

            for i in range(self.numPets):
                random.seed(self.petSeeds[i])
                zoneId = ZoneUtil.getCanonicalSafeZoneId(
                    base.localAvatar.getZoneId())
                name, dna, traitSeed = PetUtil.getPetInfoFromSeed(
                    self.petSeeds[i], zoneId)
                cost = PetUtil.getPetCostFromSeed(self.petSeeds[i], zoneId)
                traits = PetTraits.PetTraits(traitSeed, zoneId)
                traitList = traits.getExtremeTraitDescriptions()

                numGenders = len(PetDNA.PetGenders)
                gender = i % numGenders
                PetDNA.setGender(dna, gender)

                self.petDNA.append(dna)
                self.petName.append(TTLocalizer.PetshopUnknownName)

                #build the 'description' strings
                descList = []
                descList.append(TTLocalizer.PetshopDescGender %
                                PetDNA.getGenderString(gender=gender))
                if traitList:
                    descList.append(TTLocalizer.PetshopDescTrait %
                                    traitList[0])
                else:
                    descList.append(TTLocalizer.PetshopDescTrait %
                                    TTLocalizer.PetshopDescStandard)

                #buffer the list so there are at least 4 items
                traitList.extend(["", "", "", ""])
                for trait in traitList[1:4]:
                    descList.append("\t%s" % trait)

                descList.append(TTLocalizer.PetshopDescCost % cost)

                self.petDesc.append("\n".join(descList))

                self.petCost.append(cost)
    def _initDBVals(self,
                    ownerId,
                    name=None,
                    traitSeed=0,
                    dna=None,
                    safeZone=ToontownGlobals.ToontownCentral):
        self.b_setOwnerId(ownerId)
        if name is None:
            name = 'pet%s' % self.doId
        self.b_setPetName(name)
        self.b_setTraitSeed(traitSeed)
        self.b_setSafeZone(safeZone)
        traits = PetTraits.PetTraits(traitSeed, safeZone)
        for traitName in PetTraits.getTraitNames():
            setter = self.getSetterName(traitName, 'b_set')
            self.__dict__[setter](traits.getTraitValue(traitName))

        self.traits = traits
        for component in PetMood.PetMood.Components:
            setterName = self.getSetterName(component, 'b_set')
            self.__dict__[setterName](0.0)

        if not dna:
            dna = PetDNA.getRandomPetDNA()
        self.setDNA(dna)
        self.b_setLastSeenTimestamp(self.getCurEpochTimestamp())
        for component in PetMood.PetMood.Components:
            self.setMoodComponent(component, 0.0)

        self.b_setTrickAptitudes([])
Exemplo n.º 6
0
    def _initDBVals(self, ownerId, name = None, traitSeed = 0, dna = None, safeZone = ToontownGlobals.ToontownCentral):
        self.b_setOwnerId(ownerId)
        if name is None:
            name = 'pet%s' % self.doId
        self.b_setPetName(name)
        self.b_setTraitSeed(traitSeed)
        self.b_setSafeZone(safeZone)
        traits = PetTraits.PetTraits(traitSeed, safeZone)
        for traitName in PetTraits.getTraitNames():
            setter = self.getSetterName(traitName, 'b_set')
            self.__dict__[setter](traits.getTraitValue(traitName))

        self.traits = traits
        for component in PetMood.PetMood.Components:
            setterName = self.getSetterName(component, 'b_set')
            self.__dict__[setterName](0.0)

        if not dna:
            dna = PetDNA.getRandomPetDNA()
        self.setDNA(dna)
        self.b_setLastSeenTimestamp(self.getCurEpochTimestamp())
        for component in PetMood.PetMood.Components:
            self.setMoodComponent(component, 0.0)

        self.b_setTrickAptitudes([])
        return
 def load(self):
     SafeZoneLoader.load(self)
     self.flippy = NPCToons.createLocalNPC(2001)
     self.flippy.reparentTo(render)
     self.flippy.setPickable(0)
     self.flippy.setPos(188, -260, 11.187)
     self.flippy.setH(108.411)
     self.flippy.initializeBodyCollisions('toon')
     self.flippy.addActive()
     self.flippy.startBlink()
     # Just keeping things relevant to 2.5.2, keeping away from TTR and TTO phrases...
     self.flippyBlatherSequence = Sequence(Wait(10), Func(self.flippy.setChatAbsolute, 'Hello and welcome Toons, far and wide!', CFSpeech | CFTimeout), Func(self.flippy.play, 'wave'), Func(self.flippy.loop, 'neutral'), Wait(12), Func(self.flippy.setChatAbsolute, "It's been a great time at Toontown, with you helping us stop the Cogs from ruining the experience with their destructive bugs, and we're glad you could join us!", CFSpeech | CFTimeout), Wait(10), Func(self.flippy.setChatAbsolute, "Oh, don't mind the little guy back there. That's my new-found lovable yet mysterious pet, Fluffy. That's what he calls himself.", CFSpeech | CFTimeout), Wait(8), Func(self.flippy.setChatAbsolute, "He came out of nowhere...", CFSpeech | CFTimeout), Wait(13), Func(self.flippy.setChatAbsolute,  "Just when I thought Toontown couldn't be any sillier! He's a real rascal, but he already has the Cog-fighting down to a science!", CFSpeech | CFTimeout), Wait(12), Func(self.flippy.setChatAbsolute, 'Doctor Surlee says he\'s some sort of creature called a "Doodle". Funny name, right?', CFSpeech | CFTimeout), Wait(16), Func(self.flippy.setChatAbsolute, "He also says Fluffy might have some friends and we may learn more about them soon.", CFSpeech | CFTimeout), Wait(8), Func(self.flippy.setChatAbsolute, 'Anyway, what are you waiting for?', CFSpeech | CFTimeout), Wait(8), Func(self.flippy.setChatAbsolute, 'Grab some pies and go for a spin. ToonFest is in full swing!', CFSpeech | CFTimeout), Wait(13), Func(self.flippy.setChatAbsolute, 'Buddy over there has made a few mistakes at the office so I have asked him to manage the balloon ride.', CFSpeech | CFTimeout), Wait(13), Func(self.flippy.setChatAbsolute, 'Hop in the balloon with Buddy and have a ride.', CFSpeech | CFTimeout))
     self.flippyBlatherSequence.loop()
     self.fluffy = Pet.Pet()
     self.fluffy.addActive()
     self.flippy.startBlink()
     self.fluffy.setDNA(PetDNA.getRandomPetDNA())
     self.fluffy.setName('Fluffy')
     self.fluffy.setPickable(0)
     self.fluffy.reparentTo(render)
     self.fluffy.setPos(191, -263, 11.382)
     self.fluffy.setH(829)
     self.fluffy.enterNeutralHappy()
     self.fluffy.initializeBodyCollisions('pet')
     try:
         self.towerGeom = self.geom.find('**/toonfest_tower_DNARoot')
         self.base1 = self.towerGeom.find('**/base1')
         self.base2 = self.towerGeom.find('**/base2')
         self.base3 = self.towerGeom.find('**/base3')
     except:
         self.notify.warning('Something messed up loading the tower bases!')
Exemplo n.º 8
0
def getPetCostFromSeed(seed, safezoneId):
    name, dna, traitSeed = getPetInfoFromSeed(seed, safezoneId)
    traits = PetTraits.PetTraits(traitSeed, safezoneId)
    traitValue = traits.getOverallValue()

    #hack val so we have more '200' jelly bean pets
    traitValue -= 0.3
    traitValue = max(0, traitValue)  #clamp to 0
    """ TRAITFIX -- replace traitValue calculation with:
    traitValue = (traitValue - .3) / .7
    traitValue = PythonUtil.clampScalar(traitValue, 0., 1.)
    """

    # DNA rarity is in the range 0(rare) to 1(common)
    rarity = PetDNA.getRarity(dna)

    # traitValue is in the range 0(worthless) to 1(valuable)
    rarity *= (1.0 - traitValue)

    #this will give us a nice curve between .999(rare) and 0(common)
    rarity = pow(0.001, rarity) - 0.001

    minCost, maxCost = PetConstants.ZoneToCostRange[safezoneId]

    # scale this between min and max cost
    cost = (rarity * (maxCost - minCost)) + minCost

    cost = int(cost)

    return (cost)
 def getPicture(self, avatar):
     from toontown.pets import PetDNA, Pet
     pet = Pet.Pet(forGui=1)
     dna = PetDNA.getRandomPetDNA()
     pet.setDNA(dna)
     pet.setH(180)
     model, ival = self.makeFrameModel(pet, 0)
     pet.setScale(2.0)
     pet.setP(-40)
     track = PetTricks.getTrickIval(pet, self.trickId)
     name = 'petTrick-item-%s' % self.sequenceNumber
     CatalogPetTrickItem.sequenceNumber += 1
     if track is not None:
         track = Sequence(
             Sequence(track),
             ActorInterval(
                 pet,
                 'neutral',
                 duration=2),
             name=name)
     else:
         pet.animFSM.request('neutral')
         track = Sequence(Wait(4), name=name)
     self.petPicture = pet
     self.hasPicture = True
     return model, track
Exemplo n.º 10
0
def getPetCostFromSeed(seed, safezoneId):
    name, dna, traitSeed = getPetInfoFromSeed(seed, safezoneId)
    traits = PetTraits.PetTraits(traitSeed, safezoneId)
    traitValue = traits.getOverallValue()
    traitValue -= 0.3
    traitValue = max(0, traitValue)
    rarity = PetDNA.getRarity(dna)
    rarity *= 1.0 - traitValue
    rarity = pow(0.001, rarity) - 0.001
    minCost, maxCost = PetConstants.ZoneToCostRange[safezoneId]
    cost = rarity * (maxCost - minCost) + minCost
    cost = int(cost)
    return cost
Exemplo n.º 11
0
def getPetCostFromSeed(seed, safezoneId):
    name, dna, traitSeed = getPetInfoFromSeed(seed, safezoneId)
    traits = PetTraits.PetTraits(traitSeed, safezoneId)
    traitValue = traits.getOverallValue()
    traitValue -= 0.3
    traitValue = max(0, traitValue)
    rarity = PetDNA.getRarity(dna)
    rarity *= 1.0 - traitValue
    rarity = pow(0.001, rarity) - 0.001
    minCost, maxCost = PetConstants.ZoneToCostRange[safezoneId]
    cost = rarity * (maxCost - minCost) + minCost
    cost = int(cost)
    return cost
Exemplo n.º 12
0
    def getPicture(self, avatar):
        # Returns a (DirectWidget, Interval) pair to draw and animate a
        # little representation of the item, or (None, None) if the
        # item has no representation.  This method is only called on
        # the client.

        # Don't import this at the top of the file, since this code
        # must run on the AI.
        from toontown.pets import PetDNA, Pet

        pet = Pet.Pet(forGui = 1)

        # We use the avatar's own pet if he/she has a pet (and we know
        # its DNA), otherwise use a random pet.
        dna = avatar.petDNA
        if dna == None:
            dna = PetDNA.getRandomPetDNA()
        pet.setDNA(dna)
        
        pet.setH(180)
        model, ival = self.makeFrameModel(pet, 0)
        pet.setScale(2.0)
        pet.setP(-40)

        # Discard the ival from makeFrameModel, since we don't want to
        # spin.

        track = PetTricks.getTrickIval(pet, self.trickId)
        name = "petTrick-item-%s" % (self.sequenceNumber)
        CatalogPetTrickItem.sequenceNumber += 1
        if track != None:
            track = Sequence(Sequence(track),
                             ActorInterval(pet, 'neutral', duration = 2),
                             name = name)
        else:
            pet.animFSM.request('neutral')
            track = Sequence(Wait(4),
                             name = name)
        self.petPicture = pet

        assert (not self.hasPicture)
        self.hasPicture=True
        
        return (model, track)
Exemplo n.º 13
0
 def makeRandomPet(self):
     dna = PetDNA.getRandomPetDNA()
     self.setDNA(dna)
Exemplo n.º 14
0
 def makeRandomPet(self):
     dna = PetDNA.getRandomPetDNA()
     self.setDNA(dna)