def announceGenerate(self):
        DistributedSmoothNodeAI.DistributedSmoothNodeAI.announceGenerate(self)
        self._hasCleanedUp = False
        self.setHasRequestedDelete(False)
        self.b_setParent(ToontownGlobals.SPHidden)
        self.lockedDown = 0
        self.leashMode = 0
        self.leashAvId = None
        self.leashGoal = None
        self.trickLogger = ServerEventBuffer.ServerEventMultiAccumulator(
            self.air, 'petTricksPerformed', self.doId)
        self.trickFailLogger = ServerEventBuffer.ServerEventMultiAccumulator(
            self.air, 'petTricksFailed', self.doId)
        self.feedLogger = ServerEventBuffer.ServerEventAccumulator(
            self.air, 'petFeedings', self.doId)
        self.scratchLogger = ServerEventBuffer.ServerEventAccumulator(
            self.air, 'petScratchings', self.doId)
        self.traits = PetTraits.PetTraits(self.traitSeed, self.safeZone)
        if not hasattr(self, '_beingCreatedInDB'):
            for i in xrange(len(self.traitList)):
                value = self.traitList[i]
                if value == 0.0:
                    traitName = PetTraits.getTraitNames()[i]
                    traitValue = self.traits.getTraitValue(traitName)
                    DistributedPetAI.notify.info(
                        "%s: initializing new trait '%s' to %s, seed=%s" %
                        (self.doId, traitName, traitValue, self.traitSeed))
                    setterName = self.getSetterName(traitName, 'b_set')
                    self.__dict__[setterName](traitValue)

        self.mood = PetMood.PetMood(self)
        if not self.active:
            return
        self.activated = 1
        self.announceZoneChange(self.zoneId, ToontownGlobals.QuietZone)
        self.b_setParent(ToontownGlobals.SPRender)
        self.setPos(randFloat(-20, 20), randFloat(-20, 20), 0)
        self.setH(randFloat(360))
        if self.initialDNA:
            self.setDNA(self.initialDNA)
        for mood, value in self.requiredMoodComponents.items():
            self.mood.setComponent(mood, value, announce=0)

        self.requiredMoodComponents = {}
        self.brain = PetBrain.PetBrain(self)
        self.mover = Mover.Mover(self)
        self.lockMover = Mover.Mover(self)
        self.createImpulses()
        self.enterPetLook()
        self.actionFSM = PetActionFSM.PetActionFSM(self)
        self.teleportIn()
        self.handleMoodChange(distribute=0)
        taskMgr.doMethodLater(simbase.petMovePeriod * random.random(),
                              self.move, self.getMoveTaskName())
        self.startPosHprBroadcast()
        self.accept(PetObserve.getEventName(self.zoneId), self.brain.observe)
        self.accept(self.mood.getMoodChangeEvent(), self.handleMoodChange)
        self.mood.start()
        self.brain.start()
        return
    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([])
Beispiel #3
0
    def gotOwner(self, toon, pet):
        # this will request another pet if there are more to request
        # this is not called until we get to this point because we need to
        # request the pet's owner after we get the pet, and we don't count
        # the pet as 'processed' until we've got the owner
        self.getNextPet()

        if toon is None:
            # prevent mem leak
            pet.patchDelete()
            return

        minHp = 15
        maxHp = ToontownGlobals.MaxHpLimit
        normHp = (toon.getMaxHp() - minHp) / float(maxHp - minHp)
        normHp = PythonUtil.clampScalar(normHp, 0., 1.)

        maxMoney = toon.getMaxMoney() + toon.getMaxBankMoney()

        print('%s HP, %s, %s, %s, %s' %
              (toon.getMaxHp(), normHp, toon.getMaxMoney(),
               toon.getMaxBankMoney(), maxMoney))

        szList = MinigameGlobals.SafeZones
        numSz = len(szList)
        for i in range(numSz):
            if normHp < (float(i + 1) / numSz):
                break
            # check that they can even afford a pet from the next sz
            if i < (numSz - 1):
                if maxMoney < PetConstants.ZoneToCostRange[szList[i + 1]][0]:
                    print("toon %s can't afford pet from sz %s" %
                          (pet.getOwnerId(), szList[i + 1]))
                    break
        newSz = szList[i]

        # this will hold the names of modified values for the pet
        fields = []

        if newSz != ToontownGlobals.ToontownCentral:
            print('newSafezone: %s' % newSz)
            # recalculate the pet's traits
            newTraits = PetTraits.PetTraits(pet.getTraitSeed(), newSz)
            pet.setTraits(newTraits.getValueList())
            fields.extend(
                list(map(pet.getSetterName, PetTraits.getTraitNames())))

            pet.setSafeZone(newSz)
            fields.append('setSafeZone')

        if len(fields):
            print('== Fixing pet %s' % pet.doId)
            db = DatabaseObject.DatabaseObject(self.air, pet.doId)
            db.storeObject(pet, fields)

        # prevent mem leak
        pet.patchDelete()
        toon.patchDelete()
Beispiel #4
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)
Beispiel #5
0
    def __generateDistTraitFuncs(self):
        for i in xrange(PetTraits.PetTraits.NumTraits):
            traitName = PetTraits.getTraitNames()[i]
            getterName = self.getSetterName(traitName, 'get')
            b_setterName = self.getSetterName(traitName, 'b_set')
            d_setterName = self.getSetterName(traitName, 'd_set')
            setterName = self.getSetterName(traitName)

            def traitGetter(i = i):
                return self.traitList[i]

            def b_traitSetter(value, setterName = setterName, d_setterName = d_setterName):
                self.__dict__[d_setterName](value)
                self.__dict__[setterName](value)

            def d_traitSetter(value, setterName = setterName):
                self.sendUpdate(setterName, [value])

            def traitSetter(value, i = i):
                self.traitList[i] = value

            self.__dict__[getterName] = traitGetter
            self.__dict__[b_setterName] = b_traitSetter
            self.__dict__[d_setterName] = d_traitSetter
            self.__dict__[setterName] = traitSetter
            self.__funcsToDelete.append(getterName)
            self.__funcsToDelete.append(b_setterName)
            self.__funcsToDelete.append(d_setterName)
            self.__funcsToDelete.append(setterName)
Beispiel #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
Beispiel #7
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 __generateDistTraitFuncs(self):
        for i in xrange(PetTraits.PetTraits.NumTraits):
            traitName = PetTraits.getTraitNames()[i]
            getterName = self.getSetterName(traitName, 'get')
            b_setterName = self.getSetterName(traitName, 'b_set')
            d_setterName = self.getSetterName(traitName, 'd_set')
            setterName = self.getSetterName(traitName)

            def traitGetter(i=i):
                return self.traitList[i]

            def b_traitSetter(value,
                              setterName=setterName,
                              d_setterName=d_setterName):
                self.__dict__[d_setterName](value)
                self.__dict__[setterName](value)

            def d_traitSetter(value, setterName=setterName):
                self.sendUpdate(setterName, [value])

            def traitSetter(value, i=i):
                self.traitList[i] = value

            self.__dict__[getterName] = traitGetter
            self.__dict__[b_setterName] = b_traitSetter
            self.__dict__[d_setterName] = d_traitSetter
            self.__dict__[setterName] = traitSetter
            self.__funcsToDelete.append(getterName)
            self.__funcsToDelete.append(b_setterName)
            self.__funcsToDelete.append(d_setterName)
            self.__funcsToDelete.append(setterName)
    def announceGenerate(self):
        DistributedSmoothNodeAI.DistributedSmoothNodeAI.announceGenerate(self)
        self._hasCleanedUp = False
        self.setHasRequestedDelete(False)
        self.b_setParent(ToontownGlobals.SPHidden)
        self.lockedDown = 0
        self.leashMode = 0
        self.leashAvId = None
        self.leashGoal = None
        self.trickLogger = ServerEventBuffer.ServerEventMultiAccumulator(
            self.air, 'petTricksPerformed', self.doId)
        self.trickFailLogger = ServerEventBuffer.ServerEventMultiAccumulator(
            self.air, 'petTricksFailed', self.doId)
        self.feedLogger = ServerEventBuffer.ServerEventAccumulator(
            self.air, 'petFeedings', self.doId)
        self.scratchLogger = ServerEventBuffer.ServerEventAccumulator(
            self.air, 'petScratchings', self.doId)
        self.traits = PetTraits.PetTraits(self.traitSeed, self.safeZone)
        if not hasattr(self, '_beingCreatedInDB'):
            for i in xrange(len(self.traitList)):
                value = self.traitList[i]
                if value == 0.0:
                    traitName = PetTraits.getTraitNames()[i]
                    traitValue = self.traits.getTraitValue(traitName)
                    DistributedPetAI.notify.info(
                        "%s: initializing new trait '%s' to %s, seed=%s" %
                        (self.doId, traitName, traitValue, self.traitSeed))
                    setterName = self.getSetterName(traitName, 'b_set')
                    self.__dict__[setterName](traitValue)

        self.mood = PetMood.PetMood(self)
        if not self.active:
            return
        self.activated = 1
        self.announceZoneChange(self.zoneId, ToontownGlobals.QuietZone)
        self.b_setParent(ToontownGlobals.SPRender)
        self.setPos(randFloat(-20, 20), randFloat(-20, 20), 0)
        self.setH(randFloat(360))
        if self.initialDNA:
            self.setDNA(self.initialDNA)
        for mood, value in self.requiredMoodComponents.items():
            self.mood.setComponent(mood, value, announce=0)

        self.requiredMoodComponents = {}
        self.brain = PetBrain.PetBrain(self)
        self.mover = PetMoverAI(self)
        self.enterPetLook()
        self.actionFSM = PetActionFSM.PetActionFSM(self)
        self.teleportIn()
        self.handleMoodChange(distribute=0)
        taskMgr.doMethodLater(
            simbase.petMovePeriod *
            random.random(),
            self.move,
            self.getMoveTaskName())
        self.startPosHprBroadcast()
        self.accept(PetObserve.getEventName(self.zoneId), self.brain.observe)
        self.accept(self.mood.getMoodChangeEvent(), self.handleMoodChange)
        self.mood.start()
        self.brain.start()
 def __init__(self, avatar):
     self.doId = avatar.doId
     self.name = avatar.name
     self.style = avatar.style
     self.ownerId = avatar.ownerId
     self.bFake = False
     self.cr = avatar.cr
     self.traits = PetTraits.PetTraits(avatar.traitSeed, avatar.safeZone, traitValueList=avatar.traitList)
     self._grabMood(avatar)
    def __generateDistTraitFuncs(self):
        for i in xrange(PetTraits.PetTraits.NumTraits):
            traitName = PetTraits.getTraitNames()[i]
            setterName = self.getSetterName(traitName)

            def traitSetter(value, self = self, i = i):
                self.traitList[i] = value

            self.__dict__[setterName] = traitSetter
            self.__funcsToDelete.append(setterName)
Beispiel #12
0
 def __generateDistTraitFuncs(self):
     # generate a set func for each trait
     for i in range(PetTraits.PetTraits.NumTraits):
         traitName = PetTraits.getTraitNames()[i]
         setterName = self.getSetterName(traitName)
         def traitSetter(value, self=self, i=i):
             self.traitList[i] = value
         # put the func onto self
         self.__dict__[setterName] = traitSetter
         self.__funcsToDelete.append(setterName)
Beispiel #13
0
    def __generateDistTraitFuncs(self):
        for i in xrange(PetTraits.PetTraits.NumTraits):
            traitName = PetTraits.getTraitNames()[i]
            setterName = self.getSetterName(traitName)

            def traitSetter(value, self=self, i=i):
                self.traitList[i] = value

            self.__dict__[setterName] = traitSetter
            self.__funcsToDelete.append(setterName)
Beispiel #14
0
 def createPet(self, ownerId, seed):
     zoneId = self.interiorZone
     safeZoneId = ZoneUtil.getCanonicalSafeZoneId(zoneId)
     name, dna, traitSeed = PetUtil.getPetInfoFromSeed(seed, safeZoneId)
     pet = DistributedPetAI.DistributedPetAI(self.air, dna=dna)
     pet.setOwnerId(ownerId)
     pet.setPetName(name)
     pet.traits = PetTraits.PetTraits(traitSeed=traitSeed, safeZoneId=safeZoneId)
     pet.generateWithRequired(zoneId)
     pet.setPos(0, 0, 0)
     pet.b_setParent(ToontownGlobals.SPRender)
Beispiel #15
0
    def generate(self):
        DistributedObjectAI.DistributedObjectAI.generate(self)

        # calculate our traits
        # don't use the trait values from the DB, this should circumvent
        # the corrupted doodle problem
        self.traits = PetTraits.PetTraits(self.traitSeed, self.safeZone)
        print(self.traits.traits)
        """
        self.traits = PetTraits.PetTraits(
            self.traitSeed, self.safeZone,
            traitValueList=copy.copy(self.traitList))
            """


        # if there are any new traits, we need to set their generated value in
        # the DB.
        for i in range(len(self.traitList)):
            value = self.traitList[i]
            if value == 0.:
                traitName = PetTraits.getTraitNames()[i]
                traitValue = self.traits.getTraitValue(traitName)
                DistributedPetProxyAI.notify.info(
                    '%s: initializing new trait \'%s\' to %s, seed=%s' %
                    (self.doId, traitName, traitValue, self.traitSeed))
                setterName = self.getSetterName(traitName, 'b_set')
                self.__dict__[setterName](traitValue)

        # create our mood manager. we need to have self.traits first.
        self.mood = PetMood.PetMood(self)

        # pass in the cached required mood component values
        for mood, value in list(self.requiredMoodComponents.items()):
            self.mood.setComponent(mood, value, announce=0)
        self.requiredMoodComponents = {}

        # listen for mood changes
        self.accept(self.mood.getMoodChangeEvent(),
                    self.handleMoodChange)

        self.mood.start()
    def generate(self):
        DistributedObjectAI.DistributedObjectAI.generate(self)
        self.traits = PetTraits.PetTraits(self.traitSeed, self.safeZone)
        for i in xrange(len(self.traitList)):
            value = self.traitList[i]
            if value == 0.0:
                traitName = PetTraits.getTraitNames()[i]
                traitValue = self.traits.getTraitValue(traitName)
                DistributedPetProxyAI.notify.info(
                    "%s: initializing new trait '%s' to %s, seed=%s" %
                    (self.doId, traitName, traitValue, self.traitSeed))
                setterName = self.getSetterName(traitName, 'b_set')
                self.__dict__[setterName](traitValue)

        self.mood = PetMood.PetMood(self)
        for mood, value in self.requiredMoodComponents.items():
            self.mood.setComponent(mood, value, announce=0)

        self.requiredMoodComponents = {}
        self.accept(self.mood.getMoodChangeEvent(), self.handleMoodChange)
        self.mood.start()
Beispiel #17
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)
Beispiel #18
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
Beispiel #19
0
    def announceGenerate(self):
        DistributedPet.notify.debug('announceGenerate(), fake=%s' % self.bFake)
        DistributedSmoothNode.DistributedSmoothNode.announceGenerate(self)
        if hasattr(self, 'petName'):
            Pet.Pet.setName(self, self.petName)

        self.traits = PetTraits.PetTraits(self.traitSeed, self.safeZone)
        self.mood = PetMood.PetMood(self)
        for (mood, value) in self.requiredMoodComponents.items():
            self.mood.setComponent(mood, value, announce=0)

        self.requiredMoodComponents = {}
        DistributedPet.notify.debug('time since last seen: %s' %
                                    self.getTimeSinceLastSeen())
        self.setDNA([
            self.head, self.ears, self.nose, self.tail, self.bodyTexture,
            self.color, self.colorScale, self.eyeColor, self.gender
        ])
        av = self.cr.doId2do.get(self.ownerId)
        if av:
            av.petDNA = self.style

        if self.bFake:
            self.lastKnownMood = self.mood.makeCopy()
            self.updateOfflineMood()
        else:
            self._DistributedPet__initCollisions()
            self.startSmooth()
            self.setActiveShadow(1)
        self.setPetName(self.petName)
        if not self.bFake:
            self.addActive()
            self.startBlink()
            if not self.swallowSfx:
                self.swallowSfx = loader.loadSfx(
                    'phase_5.5/audio/sfx/beg_eat_swallow.mp3')

            if not self.callSfx:
                self.callSfx = loader.loadSfx(
                    'phase_5.5/audio/sfx/call_pet.mp3')

            if not self.petSfx:
                self.petSfx = loader.loadSfx(
                    'phase_5.5/audio/sfx/pet_the_pet.mp3')

            self.handleMoodChange()
            self.accept(self.mood.getDominantMoodChangeEvent(),
                        self.handleMoodChange)
            self.accept(self.mood.getMoodChangeEvent(),
                        self.moodComponentChanged)
 def __init__(self, air, avId, petSeed, nameIndex, gender, zoneId):
     name, dna, traitSeed = PetUtil.getPetInfoFromSeed(petSeed, zoneId)
     self.air = air
     self.avId = avId
     self.petSeed = petSeed
     self.traitSeed = traitSeed
     self.nameIndex = nameIndex
     self.dna = dna
     self.zoneId = ZoneUtil.getCanonicalSafeZoneId(zoneId)
     self.traits = PetTraits.PetTraits(traitSeed=traitSeed,
                                       safeZoneId=zoneId)
     self.gender = gender
     self.petId = None
     self.name = None
    def announceGenerate(self):
        DistributedObject.DistributedObject.announceGenerate(self)
        self.traits = PetTraits.PetTraits(self.traitSeed, self.safeZone)
        print self.traits.traits
        self.mood = PetMood.PetMood(self)
        self.lastKnownMood = self.mood.makeCopy()
        for mood, value in self.requiredMoodComponents.items():
            self.mood.setComponent(mood, value, announce=0)

        self.requiredMoodComponents = {}
        self.style = [
            self.head, self.ears, self.nose, self.tail, self.bodyTexture,
            self.color, self.colorScale, self.eyeColor, self.gender
        ]
        self.setLastSeenTimestamp(self.lastSeenTimestamp)
        self.updateOfflineMood()
        self.sendGenerateMessage = 1
    def announceGenerate(self):
        # don't use the trait values from the DB, this should circumvent
        # the corrupted doodle problem
        DistributedObject.DistributedObject.announceGenerate(self)
        self.traits = PetTraits.PetTraits(self.traitSeed, self.safeZone)
        print self.traits.traits
        """
        self.traits = PetTraits.PetTraits(self.traitSeed, self.safeZone,
                                          traitValueList=self.traitList)
                                          """

        # create our mood manager. we need to have self.traits first.
        self.mood = PetMood.PetMood(self)
        self.lastKnownMood = self.mood.makeCopy()

        # pass in the cached required mood component values
        for mood, value in self.requiredMoodComponents.items():
            self.mood.setComponent(mood, value, announce=0)
        self.requiredMoodComponents = {}

        DistributedPetProxy.notify.debug('time since last seen: %s' %
                                         self.getTimeSinceLastSeen())

        self.style = [
            self.head,
            self.ears,
            self.nose,
            self.tail,
            self.bodyTexture,
            self.color,
            self.colorScale,
            self.eyeColor,
            self.gender,
        ]

        self.setLastSeenTimestamp(self.lastSeenTimestamp)
        self.updateOfflineMood()

        # Throw the event that pet info is available
        #proxyGenerateMessage = "petProxy-%d-generated" % self.doId
        #messenger.send(proxyGenerateMessage)
        self.sendGenerateMessage = 1
    def generate(self):
        DistributedObjectAI.DistributedObjectAI.generate(self)
        self.traits = PetTraits.PetTraits(self.traitSeed, self.safeZone)
        for i in xrange(len(self.traitList)):
            value = self.traitList[i]
            if value == 0.0:
                traitName = PetTraits.getTraitNames()[i]
                traitValue = self.traits.getTraitValue(traitName)
                DistributedPetProxyAI.notify.info("%s: initializing new trait '%s' to %s, seed=%s" % (self.doId,
                 traitName,
                 traitValue,
                 self.traitSeed))
                setterName = self.getSetterName(traitName, 'b_set')
                self.__dict__[setterName](traitValue)

        self.mood = PetMood.PetMood(self)
        for mood, value in self.requiredMoodComponents.items():
            self.mood.setComponent(mood, value, announce=0)

        self.requiredMoodComponents = {}
        self.accept(self.mood.getMoodChangeEvent(), self.handleMoodChange)
        self.mood.start()
    def announceGenerate(self):
        DistributedPet.notify.debug('announceGenerate(), fake=%s' % self.bFake)
        DistributedSmoothNode.DistributedSmoothNode.announceGenerate(self)
        if hasattr(self, "petName"):
            Pet.Pet.setName(self, self.petName)

        # don't use the trait values from the DB, this should circumvent
        # the corrupted doodle problem
        self.traits = PetTraits.PetTraits(self.traitSeed, self.safeZone)
        """
        self.traits = PetTraits.PetTraits(self.traitSeed, self.safeZone,
                                          traitValueList=self.traitList)
                                          """

        # create our mood manager. we need to have self.traits first.
        self.mood = PetMood.PetMood(self)

        # pass in the cached required mood component values
        for mood, value in list(self.requiredMoodComponents.items()):
            self.mood.setComponent(mood, value, announce=0)
        self.requiredMoodComponents = {}

        DistributedPet.notify.debug('time since last seen: %s' %
                                    self.getTimeSinceLastSeen())

        self.setDNA([
            self.head,
            self.ears,
            self.nose,
            self.tail,
            self.bodyTexture,
            self.color,
            self.colorScale,
            self.eyeColor,
            self.gender,
        ])

        # Locally store a copy of the pet's DNA on its owner, for
        # convenience.  Really this is just for the catalog system for
        # now, but maybe there will be other applications later.
        av = self.cr.doId2do.get(self.ownerId)
        if av:
            av.petDNA = self.style

        if self.bFake:
            # store a copy of the 'last known' mood state
            self.lastKnownMood = self.mood.makeCopy()
            # and calculate the current mood
            self.updateOfflineMood()
        else:
            self.__initCollisions()
            self.startSmooth()
            self.setActiveShadow(1)

        # make sure the nametag is up-to-date
        self.setPetName(self.petName)
        if not self.bFake:
            self.addActive()

            # start the blink task again because disable stops it
            self.startBlink()

            # only load the sounds for 'real' pets
            if not self.swallowSfx:
                self.swallowSfx = loader.loadSfx(
                    'phase_5.5/audio/sfx/beg_eat_swallow.mp3')
            if not self.callSfx:
                self.callSfx = loader.loadSfx(
                    'phase_5.5/audio/sfx/call_pet.mp3')
            if not self.petSfx:
                self.petSfx = loader.loadSfx(
                    'phase_5.5/audio/sfx/pet_the_pet.mp3')

            # kick-start the emote display
            self.handleMoodChange()
            # and listen for changes
            self.accept(self.mood.getDominantMoodChangeEvent(),
                        self.handleMoodChange)
            # listen for every mood change for debug display
            self.accept(self.mood.getMoodChangeEvent(),
                        self.moodComponentChanged)