Пример #1
0
 def _inspectSpot(self, spot = None):
     if spot is None:
         spot = NodePath('randomSpot')
         spot.setPos(randFloat(-20, 20), randFloat(-20, 20), 0)
     self.setFocus(spot)
     self.pet.actionFSM.request('InspectSpot', spot)
     return 1
    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.lockMover = PetMoverAI(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()
Пример #3
0
 def _process(self, dt):
     self.targetMoveCountdown -= dt
     if self.targetMoveCountdown <= 0.0:
         distance = normalDistrib(3.0, 30.0)
         heading = normalDistrib(-135, 135)
         if self.gotCollision:
             self.gotCollision = False
             heading = heading + 180
         target = self.getTarget()
         target.setPos(self.getNodePath().getPos())
         target.setH(target, heading)
         target.setY(target, distance)
         duration = distance / self.mover.getFwdSpeed()
         self.targetMoveCountdown = duration * randFloat(1.2, 3.0)
     PetChase.process(self, dt)
def uniform(min, max, rng):
    return randFloat(min, max, rng.random)