def announceZoneChange(self, newZoneId, oldZoneId):
     DistributedPetAI.notify.debug('%s.announceZoneChange: %s->%s' %
                                   (self.doId, oldZoneId, newZoneId))
     broadcastZones = list2dict([newZoneId, oldZoneId])
     PetObserve.send(
         broadcastZones.keys(),
         PetObserve.PetActionObserve(PetObserve.Actions.CHANGE_ZONE,
                                     self.doId, (oldZoneId, newZoneId)))
예제 #2
0
 def announceZoneChange(self, newZoneId, oldZoneId):
     DistributedPetAI.notify.debug('%s.announceZoneChange: %s->%s' % (self.doId, oldZoneId, newZoneId))
     broadcastZones = list2dict([newZoneId, oldZoneId])
     self.estateOwnerId = simbase.air.estateManager.getOwnerFromZone(newZoneId)
     if self.estateOwnerId:
         self.inEstate = 1
         self.estateZones = simbase.air.estateManager.getEstateZones(self.estateOwnerId)
     else:
         self.inEstate = 0
         self.estateZones = []
     PetObserve.send(broadcastZones.keys(), PetObserve.PetActionObserve(PetObserve.Actions.CHANGE_ZONE, self.doId, (oldZoneId, newZoneId)))
예제 #3
0
 def announceZoneChange(self, newZoneId, oldZoneId):
     DistributedPetAI.notify.debug('%s.announceZoneChange: %s->%s' % (self.doId, oldZoneId, newZoneId))
     broadcastZones = list2dict([newZoneId, oldZoneId])
     self.estateOwnerId = simbase.air.estateMgr.getOwnerFromZone(newZoneId)
     if self.estateOwnerId:
         if __dev__:
             pass
         self.inEstate = 1
         self.estateZones = simbase.air.estateMgr.getEstateZones(self.estateOwnerId)
     else:
         self.inEstate = 0
         self.estateZones = []
     PetObserve.send(broadcastZones.keys(), PetObserve.PetActionObserve(PetObserve.Actions.CHANGE_ZONE, self.doId, (oldZoneId, newZoneId)))
 def feed(self, avatar):
     if avatar.takeMoney(PetConstants.FEED_AMOUNT):
         self.startLockPetMove(avatar.doId)
         self.brain.observe(
             PetObserve.PetActionObserve(PetObserve.Actions.FEED,
                                         avatar.doId))
         self.feedLogger.addEvent()
    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 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()
예제 #7
0
 def _handleLookedAtByOtherStop(self, avId):
     if avId not in self.lookers:
         PetBrain.notify.warning('%s: av %s not looking at me' %
                                 (self.pet.doId, avId))
         return
     del self.lookers[avId]
     self.observe(
         PetObserve.PetActionObserve(PetObserve.Actions.ATTENDED_STOP,
                                     avId))
예제 #8
0
 def _handleLookingAtOtherStop(self, avId):
     if avId not in self.lookees:
         PetBrain.notify.warning('%s: not looking at av %s' %
                                 (self.pet.doId, avId))
         return
     del self.lookees[avId]
     self.observe(
         PetObserve.PetActionObserve(PetObserve.Actions.ATTENDING_STOP,
                                     avId))
예제 #9
0
 def _handleLookedAtByOtherStart(self, avId):
     if avId in self.lookers:
         PetBrain.notify.warning('%s: av %s already looking at me' %
                                 (self.pet.doId, avId))
         return
     self.lookers[avId] = avId
     self.observe(
         PetObserve.PetActionObserve(PetObserve.Actions.ATTENDED_START,
                                     avId))
예제 #10
0
 def _handleLookingAtOtherStart(self, avId):
     if avId in self.lookees:
         PetBrain.notify.warning('%s: already looking at av %s' %
                                 (self.pet.doId, avId))
         return
     self.lookees[avId] = avId
     self.observe(
         PetObserve.PetActionObserve(PetObserve.Actions.ATTENDING_START,
                                     avId))
 def call(self, avatar):
     self.brain.observe(
         PetObserve.PetPhraseObserve(PetObserve.Phrases.COME, avatar.doId))
     self.__petMovieStart(avatar.doId)
 def handleShoo(self, avatar):
     self.brain.observe(
         PetObserve.PetPhraseObserve(PetObserve.Phrases.GO_AWAY,
                                     avatar.doId))
 def handleStay(self, avatar):
     self.brain.observe(
         PetObserve.PetPhraseObserve(PetObserve.Phrases.STAY, avatar.doId))
 def scratch(self, avatar):
     self.startLockPetMove(avatar.doId)
     self.brain.observe(
         PetObserve.PetActionObserve(PetObserve.Actions.SCRATCH,
                                     avatar.doId))
     self.scratchLogger.addEvent()
예제 #15
0
 def handleZoneChange(self, newZoneId, oldZoneId):
     DistributedSmoothNodeAI.DistributedSmoothNodeAI.handleZoneChange(self, newZoneId, oldZoneId)
     self.ignore(PetObserve.getEventName(oldZoneId))
     self.accept(PetObserve.getEventName(newZoneId), self.brain.observe)
예제 #16
0
 def scratch(self, avatar):
     #self.startLockPetMove(avatar.doId) # Put new locking mechanism here
     self.brain.observe(
         PetObserve.PetActionObserve(PetObserve.Actions.SCRATCH,
                                     avatar.doId))
     self.scratchLogger.addEvent()
 def handleZoneChange(self, newZoneId, oldZoneId):
     DistributedSmoothNodeAI.DistributedSmoothNodeAI.handleZoneChange(
         self, newZoneId, oldZoneId)
     self.ignore(PetObserve.getEventName(oldZoneId))
     self.accept(PetObserve.getEventName(newZoneId), self.brain.observe)