def avatarEnter(self):
     self.sendUpdate('createBot', [random.randrange(6)])
     dna = ToonDNA()
     dna.newToonRandom()
     newToon = DistributedBotAI(self.cr)
     newToon.b_setDNAString(dna.makeNetString())
     x = (random.random()*10) + 10
     y = (random.random()*10) + 10
     z = 4
     newToon.sendUpdate('setPos', [x, y, z])
    def setupScrollInterface(self):
        self.dna = self.toon.getStyle()
        gender = self.dna.getGender()
        if self.swapEvent != None:
            self.tops = ToonDNA.getTops(gender, tailorId=self.tailorId)
            self.bottoms = ToonDNA.getBottoms(gender, tailorId=self.tailorId)
            self.gender = gender
            self.topChoice = -1
            self.bottomChoice = -1

        self.setupButtons()
Exemple #3
0
def getSingingNote(toon, note, volume=1):
    """
    Returns a track of the toon singing the requested note.
    note is a string in small letters. Eg - g1, a, b, c, d, e, f, g2
    """
    sfx = None
    filePath = "phase_3.5/audio/dial/"
    filePrefix = "tt_s_dlg_sng_"
    fileSuffix = ".mp3"
    speciesName = ToonDNA.getSpeciesName(toon.style.head)
    sfx = base.loadSfx(filePath + filePrefix + speciesName + "_" + note +
                       fileSuffix)

    # Need to use a Func interval since DoEmote expects a 0 duration track
    def playSfx(volume=1):
        base.playSfx(sfx, volume=volume, node=toon)

    def playAnim():
        toon.loop('neutral')

    def stopAnim():
        toon.setPlayRate(1, 'neutral')

    track = Sequence(Func(toon.showSurpriseMuzzle),
                     Parallel(Func(playAnim), Func(playSfx, volume)))

    exitTrack = Sequence(Func(toon.hideSurpriseMuzzle), Func(stopAnim))

    return track, 0.1, exitTrack
Exemple #4
0
 def setDNA(self, blob, finished, which):
     avId = self.air.getAvatarIdFromSender()
     if avId != self.customerId:
         if self.customerId:
             self.air.writeServerEvent('suspicious', avId=avId, issue='DistributedNPCTailorAI.setDNA customer is %s' % self.customerId)
             self.notify.warning('customerId: %s, but got setDNA for: %s' % (self.customerId, avId))
         return
     testDNA = ToonDNA.ToonDNA()
     if not testDNA.isValidNetString(blob):
         self.air.writeServerEvent('suspicious', avId=avId, issue='DistributedNPCTailorAI.setDNA: invalid dna: %s' % blob)
         return
     testDNA.makeFromNetString(blob)
     if self.air.doId2do.has_key(avId):
         av = self.air.doId2do[avId]
         if not self.__verifyAvatarInMyZone(av):
             self.air.writeServerEvent('suspicious', avId=av.getDoId(), issue='Tried to setDNA without being in same location.')
             taskMgr.doMethodLater(0.1, self.sendTimeoutMovie, self.uniqueName('clearMovie'))
             return
         if not self.__checkValidDNAChange(av, testDNA):
             self.air.writeServerEvent('suspicious', avId=av.getDoId(), issue="Avatar tried to modify parts of their DNA that isn't clothing!")
             taskMgr.doMethodLater(0.1, self.sendTimeoutMovie, self.uniqueName('clearMovie'))
             return
         if finished == 2 and which > 0:
             if self.freeClothes or self.air.questManager.removeClothingTicket(av, self) or av.takeMoney(self.jbCost, bUseBank=True):
                 av.b_setDNAString(blob)
                 if which & ClosetGlobals.SHIRT:
                     if av.addToClothesTopsList(self.customerDNA.topTex, self.customerDNA.topTexColor, self.customerDNA.sleeveTex, self.customerDNA.sleeveTexColor) == 1:
                         av.b_setClothesTopsList(av.getClothesTopsList())
                     else:
                         self.notify.warning('NPCTailor: setDNA() - unable to save old tops - we exceeded the tops list length')
                 if which & ClosetGlobals.SHORTS:
                     if av.addToClothesBottomsList(self.customerDNA.botTex, self.customerDNA.botTexColor) == 1:
                         av.b_setClothesBottomsList(av.getClothesBottomsList())
                     else:
                         self.notify.warning('NPCTailor: setDNA() - unable to save old bottoms - we exceeded the bottoms list length')
                 self.air.writeServerEvent('boughtTailorClothes', avId=avId, tailorId=self.doId, item=which, dna=self.customerDNA.makeNetString())
             elif self.useJellybeans:
                 self.air.writeServerEvent('suspicious', avId=avId, issue='DistributedNPCTailorAI.setDNA tried to purchase with insufficient jellybeans')
                 self.notify.warning('NPCTailor: setDNA() - client tried to purchase with insufficient jellybeans!')
             else:
                 self.air.writeServerEvent('suspicious', avId=avId, issue='DistributedNPCTailorAI.setDNA bogus clothing ticket')
                 self.notify.warning('NPCTailor: setDNA() - client tried to purchase with bogus clothing ticket!')
                 if self.customerDNA:
                     av.b_setDNAString(self.customerDNA.makeNetString())
         elif finished == 1:
             if self.customerDNA:
                 av.b_setDNAString(self.customerDNA.makeNetString())
         else:
             self.sendUpdate('setCustomerDNA', [avId, blob])
     else:
         self.notify.warning('no av for avId: %d' % avId)
     if self.timedOut == 1 or finished == 0:
         return
     if self.busy == avId:
         taskMgr.remove(self.uniqueName('clearMovie'))
         self.completePurchase(avId)
     else:
         if self.busy:
             self.air.writeServerEvent('suspicious', avId=avId, issue='DistributedNPCTailorAI.setDNA busy with %s' % self.busy)
             self.notify.warning('setDNA from unknown avId: %s busy: %s' % (avId, self.busy))
Exemple #5
0
    def avatarEnter(self):
        avId = self.air.getAvatarIdFromSender()

        if not self.air.doId2do.has_key(avId):
            self.notify.warning('Avatar: %s not found' % avId)
            return

        av = self.air.doId2do[avId]

        if self.isBusy():
            self.freeAvatar(avId)
            return

        flag = NPCToons.PURCHASE_MOVIE_START_BROWSE
        if self.freeClothes:
            flag = NPCToons.PURCHASE_MOVIE_START

        elif self.air.questManager.hasTailorClothingTicket(av, self):
            flag = NPCToons.PURCHASE_MOVIE_START

        if flag != NPCToons.PURCHASE_MOVIE_START_BROWSE and self.housingEnabled and self.isClosetAlmostFull(
                av):
            flag = NPCToons.PURCHASE_MOVIE_START_NOROOM

        self.customerDNA = ToonDNA.ToonDNA()
        self.customerDNA.makeFromNetString(av.getDNAString())
        self.customerId = avId
        av.b_setDNAString(self.customerDNA.makeNetString())
        self.acceptOnce(self.air.getAvatarExitEvent(avId),
                        self.__handleUnexpectedExit,
                        extraArgs=[avId])

        self.sendShoppingMovie(avId, flag)
        DistributedNPCToonBaseAI.avatarEnter(self)
Exemple #6
0
    def changeGlove(self, color):
        avId = self.air.getAvatarIdFromSender()
        av = self.air.doId2do.get(avId)

        if av is None or not hasattr(av, 'dna'):
            return
        elif len(ToonDNA.allColorsList) <= color:
            self.sendUpdate('changeGloveResult',
                            [avId, GloveNPCGlobals.INVALID_COLOR])
            return
        elif av.dna.gloveColor == color:
            self.sendUpdate('changeGloveResult',
                            [avId, GloveNPCGlobals.SAME_COLOR])
            return
        elif av.getTotalMoney() < ToontownGlobals.GloveCost:
            self.sendUpdate('changeGloveResult',
                            [avId, GloveNPCGlobals.NOT_ENOUGH_MONEY])
            return

        av.takeMoney(ToontownGlobals.GloveCost)
        newDNA = ToonDNA.ToonDNA()
        newDNA.makeFromNetString(av.getDNAString())
        newDNA.gloveColor = color
        taskMgr.doMethodLater(
            1.0, lambda task: av.b_setDNAString(newDNA.makeNetString()),
            'transform-%d' % avId)
        self.sendUpdate('changeGloveResult',
                        [avId, GloveNPCGlobals.CHANGE_SUCCESSFUL])
Exemple #7
0
 def setDNA(self, blob, finished, which):
     avId = self.air.getAvatarIdFromSender()
     if avId != self.customerId:
         if self.customerId:
             self.air.writeServerEvent('suspicious', avId, 'DistributedNPCTailorAI.setDNA customer is %s' % self.customerId)
             self.notify.warning('customerId: %s, but got setDNA for: %s' % (self.customerId, avId))
         return
     testDNA = ToonDNA.ToonDNA()
     if not testDNA.isValidNetString(blob):
         self.air.writeServerEvent('suspicious', avId, 'DistributedNPCTailorAI.setDNA: invalid dna: %s' % blob)
         return
     if avId in self.air.doId2do:
         av = self.air.doId2do.get(avId)
         if finished == 2 and which > 0:
             if self.freeClothes or av.takeMoney(self.jbCost, bUseBank = True):
                 av.b_setDNAString(blob)
                 if which & ClosetGlobals.SHIRT:
                     if av.addToClothesTopsList(self.customerDNA.topTex, self.customerDNA.topTexColor, self.customerDNA.sleeveTex, self.customerDNA.sleeveTexColor) == 1:
                         av.b_setClothesTopsList(av.getClothesTopsList())
                     else:
                         self.notify.warning('NPCTailor: setDNA() - unable to save old tops - we exceeded the tops list length')
                 if which & ClosetGlobals.SHORTS:
                     if av.addToClothesBottomsList(self.customerDNA.botTex, self.customerDNA.botTexColor) == 1:
                         av.b_setClothesBottomsList(av.getClothesBottomsList())
                     else:
                         self.notify.warning('NPCTailor: setDNA() - unable to save old bottoms - we exceeded the bottoms list length')
                 self.air.writeServerEvent('boughtTailorClothes', avId, '%s|%s|%s' % (self.doId, which, self.customerDNA.asTuple()))
             elif self.useJellybeans:
                 self.air.writeServerEvent('suspicious', avId, 'DistributedNPCTailorAI.setDNA tried to purchase with insufficient jellybeans')
                 self.notify.warning('NPCTailor: setDNA() - client tried to purchase with insufficient jellybeans!')
             elif self.air.questManager.hasTailorClothingTicket(av, self):
                 self.air.questManager.removeClothingTicket(av, self)
                 av.b_setDNAString(blob)
                 if which & ClosetGlobals.SHIRT:
                     if av.addToClothesTopsList(self.customerDNA.topTex, self.customerDNA.topTexColor, self.customerDNA.sleeveTex, self.customerDNA.sleeveTexColor) == 1:
                         av.b_setClothesTopsList(av.getClothesTopsList())
                     else:
                         self.notify.warning('NPCTailor: setDNA() - unable to save old tops - we exceeded the tops list length')
                 if which & ClosetGlobals.SHORTS:
                     if av.addToClothesBottomsList(self.customerDNA.botTex, self.customerDNA.botTexColor) == 1:
                         av.b_setClothesBottomsList(av.getClothesBottomsList())
                     else:
                         self.notify.warning('NPCTailor: setDNA() - unable to save old bottoms - we exceeded the bottoms list length')
                 self.air.writeServerEvent('boughtTailorClothes', avId, '%s|%s|%s' % (self.doId, which, self.customerDNA.asTuple()))
         elif finished == 1:
             if self.customerDNA:
                 av.b_setDNAString(self.customerDNA.makeNetString())
         else:
             self.sendUpdate('setCustomerDNA', [avId, blob])
     else:
         self.notify.warning('no av for avId: %d' % avId)
     if self.timedOut == 1 or finished == 0:
         return
     if self.busy == avId:
         taskMgr.remove(self.uniqueName('clearMovie'))
         self.completePurchase(avId)
     elif self.busy:
         self.air.writeServerEvent('suspicious', avId, 'DistributedNPCTailorAI.setDNA busy with %s' % self.busy)
         self.notify.warning('setDNA from unknown avId: %s busy: %s' % (avId, self.busy))
 def setupScrollInterface(self):
     self.dna = self.toon.getStyle()
     gender = self.dna.getGender()
     if self.swapEvent != None:
         self.topStyles = ToonDNA.getTopStyles(gender, tailorId=self.tailorId)
         self.tops = ToonDNA.getTops(gender, tailorId=self.tailorId)
         self.bottomStyles = ToonDNA.getBottomStyles(gender, tailorId=self.tailorId)
         self.bottoms = ToonDNA.getBottoms(gender, tailorId=self.tailorId)
         self.gender = gender
         self.topChoice = -1
         self.topStyleChoice = -1
         self.topColorChoice = -1
         self.bottomChoice = -1
         self.bottomStyleChoice = -1
         self.bottomColorChoice = -1
     self.setupButtons()
     return
Exemple #9
0
    def setupScrollInterface(self):
        self.dna = self.toon.getStyle()
        gender = self.dna.getGender()

        # Handle the case where we're in a shop (clothes aren't randomized,
        # we can't be changing gender, etc.
        if (self.swapEvent != None):
            self.tops = ToonDNA.getTops(gender, tailorId=self.tailorId)
            self.bottoms = ToonDNA.getBottoms(gender, tailorId=self.tailorId)
            self.gender = gender
            # We're off the wheel of choices to start with because we're
            # wearing clothes purchased elsewhere
            self.topChoice = -1
            self.bottomChoice = -1

        # setup the buttons
        self.setupButtons()
Exemple #10
0
def updateToon(DNAString):
    dna = ToonDNA.ToonDNA()
    dna.makeFromNetString(convertServerDNAString(DNAString))
    tt.setDNA(dna)
    tt.pose('neutral', 0)
    tt.stopLookAroundNow()
    tt.stopBlink()
    head = tt.getPart('head', '1000')
    head.setHpr(headAngle, pitchAngle, rollAngle)
 def createNPCToonHead(self, NPCID, dimension=0.5):
     NPCInfo = NPCToons.NPCToonDict[NPCID]
     dnaList = NPCInfo[2]
     gender = NPCInfo[3]
     if dnaList == 'r':
         dnaList = NPCToons.getRandomDNA(NPCID, gender)
     dna = ToonDNA.ToonDNA()
     dna.newToonFromProperties(*dnaList)
     head = ToonHead.ToonHead()
     head.setupHead(dna, forGui=1)
     self.fitGeometry(head, fFlip=1, dimension=dimension)
     return head
Exemple #12
0
 def createNPCToonHead(self, NPCID, dimension = 0.5):
     # Given an NPC id create a toon head suitable for framing
     NPCInfo = NPCToons.NPCToonDict[NPCID]
     dnaList = NPCInfo[2]
     gender = NPCInfo[3]
     if dnaList == 'r':
         dnaList = NPCToons.getRandomDNA(NPCID, gender)
     dna = ToonDNA.ToonDNA()
     dna.newToonFromProperties(*dnaList)
     head = ToonHead.ToonHead()
     head.setupHead(dna, forGui = 1)
     # Insert xform with gets head to uniform size
     self.fitGeometry(head, fFlip = 1, dimension = dimension)
     return head
Exemple #13
0
def doMelt(toon, volume=1):
    speciesName = ToonDNA.getSpeciesName(toon.style.head)

    sfx = base.loadSfx('phase_3.5/audio/dial/AV_' + speciesName +
                       '_exclaim.ogg')
    sfx2 = base.loadSfx('phase_5/audio/sfx/TL_quicksand.ogg')

    track = Sequence(Func(toon.blinkEyes), Func(toon.sadEyes),
                     Func(toon.play, 'melt'), Wait(1),
                     Func(base.playSfx, sfx, volume=volume, node=toon),
                     Func(base.playSfx, sfx2, volume=volume, node=toon))
    duration = toon.getDuration('melt')
    exitTrack = Sequence(Func(toon.normalEyes), Func(toon.blinkEyes))
    return (track, duration, exitTrack)
 def createNPCToonHead(self, NPCID, dimension=0.5):
     NPCInfo = NPCToons.NPCToonDict[NPCID]
     dnaList = NPCInfo[2]
     gender = NPCInfo[3]
     if dnaList == 'r':
         dnaList = NPCToons.getRandomDNA(NPCID, gender)
     dna = ToonDNA.ToonDNA()
     dna.newToonFromProperties(*dnaList)
     head = ToonHead.ToonHead()
     head.setupHead(dna, forGui=1)
     self.fitGeometry(head, fFlip=1, dimension=dimension)
     if NPCID == 91917:
         LaughingManGlobals.addHeadEffect(head, book=True)
     return head
Exemple #15
0
def doMelt(toon, volume=1):
    speciesName = ToonDNA.getSpeciesName(toon.style.head)
	
    sfx = base.loadSfx('phase_3.5/audio/dial/AV_' + speciesName + '_exclaim.ogg')
    sfx2 = base.loadSfx('phase_5/audio/sfx/TL_quicksand.ogg')
	
    track = Sequence(
        Func(toon.blinkEyes),
        Func(toon.sadEyes), 
        Func(toon.play, 'melt'),
        Wait(1),
        Func(base.playSfx, sfx, volume=volume, node=toon),
        Func(base.playSfx, sfx2, volume=volume, node=toon)
    )
    duration = toon.getDuration('melt')
    exitTrack = Sequence(Func(toon.normalEyes), Func(toon.blinkEyes))
    return (track, duration, exitTrack)
    def __init__(self, air):
        DistributedObjectUD.__init__(self, air)
        self.dna = ToonDNA.ToonDNA()
        self.clothesTopsList = []
        self.clothesBottomsList = []
        self.emoteAccess = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
        self.fishingRod = 0
        
        if simbase.wantPets:
            self.petTrickPhrases = []
            
        if simbase.wantBingo:
            self.bingoCheat = False

        self.customMessages = []
        
        self.mailboxContents = CatalogItemList.CatalogItemList(store = CatalogItem.Customization)
Exemple #17
0
def getSingingNote(toon, note, volume = 1):
    sfx = None
    filePath = 'phase_3.5/audio/dial/'
    filePrefix = 'tt_s_dlg_sng_'
    fileSuffix = '.ogg'
    speciesName = ToonDNA.getSpeciesName(toon.style.head)
    sfx = base.loadSfx(filePath + filePrefix + speciesName + '_' + note + fileSuffix)

    def playSfx(volume = 1):
        base.playSfx(sfx, volume=volume, node=toon)

    def playAnim():
        toon.loop('neutral')

    def stopAnim():
        toon.setPlayRate(1, 'neutral')

    track = Sequence(Func(toon.showSurpriseMuzzle), Parallel(Func(playAnim), Func(playSfx, volume)))
    exitTrack = Sequence(Func(toon.hideSurpriseMuzzle), Func(stopAnim))
    return (track, 0.1, exitTrack)
Exemple #18
0
def getSingingNote(toon, note, volume = 1):
    sfx = None
    filePath = 'phase_3.5/audio/dial/'
    filePrefix = 'tt_s_dlg_sng_'
    fileSuffix = '.ogg'
    speciesName = ToonDNA.getSpeciesName(toon.style.head)
    sfx = base.loadSfx(filePath + filePrefix + speciesName + '_' + note + fileSuffix)

    def playSfx(volume = 1):
        base.playSfx(sfx, volume=volume, node=toon)

    def playAnim():
        toon.loop('neutral')

    def stopAnim():
        toon.setPlayRate(1, 'neutral')

    track = Sequence(Func(toon.showSurpriseMuzzle), Parallel(Func(playAnim), Func(playSfx, volume)))
    exitTrack = Sequence(Func(toon.hideSurpriseMuzzle), Func(stopAnim))
    return (track, 0.1, exitTrack)
    def avatarEnter(self):
        avId = self.air.getAvatarIdFromSender()
        # this avatar has come within range
        assert self.notify.debug("avatar enter " + str(avId))

        if (not self.air.doId2do.has_key(avId)):
            self.notify.warning("Avatar: %s not found" % (avId))
            return

        if (self.isBusy()):
            self.freeAvatar(avId)
            return

        # Store the original customer DNA so we can revert if a disconnect
        # happens
        av = self.air.doId2do[avId]
        self.customerDNA = ToonDNA.ToonDNA()
        self.customerDNA.makeFromNetString(av.getDNAString())
        self.customerId = avId

        # Handle unexpected exit
        self.acceptOnce(self.air.getAvatarExitEvent(avId),
                        self.__handleUnexpectedExit,
                        extraArgs=[avId])

        flag = NPCToons.PURCHASE_MOVIE_START_BROWSE
        if self.freeClothes:
            flag = NPCToons.PURCHASE_MOVIE_START
            if self.housingEnabled and self.isClosetAlmostFull(av):
                flag = NPCToons.PURCHASE_MOVIE_START_NOROOM
        elif (self.air.questManager.hasTailorClothingTicket(av, self) == 1):
            flag = NPCToons.PURCHASE_MOVIE_START
            if self.housingEnabled and self.isClosetAlmostFull(av):
                flag = NPCToons.PURCHASE_MOVIE_START_NOROOM
        elif (self.air.questManager.hasTailorClothingTicket(av, self) == 2):
            flag = NPCToons.PURCHASE_MOVIE_START
            if self.housingEnabled and self.isClosetAlmostFull(av):
                flag = NPCToons.PURCHASE_MOVIE_START_NOROOM

        self.sendShoppingMovie(avId, flag)
        DistributedNPCToonBaseAI.avatarEnter(self)
    def avatarEnter(self):
        avId = self.air.getAvatarIdFromSender()
        if not self.air.doId2do.has_key(avId):
            self.notify.warning('Avatar: %s not found' % avId)
            return
        if self.isBusy():
            self.freeAvatar(avId)
            return
        av = self.air.doId2do[avId]
        if not self.__verifyAvatarInMyZone(av):
            self.air.writeServerEvent(
                'suspicious',
                avId=av.getDoId(),
                issue='Tried to avatarEnter without being in same location.')
            return
        self.customerDNA = ToonDNA.ToonDNA()
        self.customerDNA.makeFromNetString(av.getDNAString())
        self.customerId = avId
        av.b_setDNAString(self.customerDNA.makeNetString())
        self.acceptOnce(self.air.getAvatarExitEvent(avId),
                        self.__handleUnexpectedExit,
                        extraArgs=[avId])

        if self.useJellybeans:
            flag = NPCToons.PURCHASE_MOVIE_START_BROWSE_JBS
        else:
            flag = NPCToons.PURCHASE_MOVIE_START_BROWSE

        if self.freeClothes:
            flag = NPCToons.PURCHASE_MOVIE_START
        elif self.air.questManager.hasTailorClothingTicket(av, self):
            flag = NPCToons.PURCHASE_MOVIE_START
        elif self.useJellybeans and self.hasEnoughJbs(av):
            flag = NPCToons.PURCHASE_MOVIE_START

        if self.housingEnabled and self.isClosetAlmostFull(av):
            flag = NPCToons.PURCHASE_MOVIE_START_NOROOM

        self.sendShoppingMovie(avId, flag)
        DistributedNPCToonBaseAI.avatarEnter(self)
Exemple #21
0
 def updateDNA(self, description):
     # Create dna
     if isinstance(description, ToonDNA.ToonDNA):
         dna = description
     else:
         dna = ToonDNA.ToonDNA()
         if (isinstance(description, types.ListType)
                 or isinstance(description, types.TupleType)):
             # Assume it is a property list
             dna.newToonFromProperties(*description)
         elif isinstance(description, Datagram):
             # Create dna straight from datagram
             dna.makeFromNetString(description)
         elif isinstance(description, types.StringType):
             # Assume it is a server string description
             # Convert to datagram then create dna
             dna.makeFromNetString(self.convertServerDNAString(description))
         elif isinstance(description, types.IntType):
             # Assume it is an NPC id
             npcInfo = NPCToons.NPCToonDict[description]
             properties = npcInfo[2]
             if properties == 'r':
                 gender = npcInfo[3]
                 properties = NPCToons.getRandomDNA(description, gender)
             dna.newToonFromProperties(*properties)
         else:
             if random() < 0.5:
                 gender = 'm'
             else:
                 gender = 'f'
             dna.newToonRandom(gender=gender)
     if not self.style:
         # New toon, need to initialize style
         self.setDNA(dna)
     else:
         # Just jump straight to the update function
         self.updateToonDNA(dna, fForce=1)
    def setDNA(self, blob, finished, which):
        assert self.notify.debug('setDNA(): %s' % self.timedOut)
        avId = self.air.getAvatarIdFromSender()
        if avId != self.customerId:
            if self.customerId:
                self.air.writeServerEvent(
                    'suspicious', avId,
                    'DistributedNPCTailorAI.setDNA customer is %s' %
                    (self.customerId))
                self.notify.warning("customerId: %s, but got setDNA for: %s" %
                                    (self.customerId, avId))
            return

        # make sure the DNA is valid
        testDNA = ToonDNA.ToonDNA()
        if not testDNA.isValidNetString(blob):
            self.air.writeServerEvent(
                'suspicious', avId,
                'DistributedNPCTailorAI.setDNA: invalid dna: %s' % blob)
            return

        if (self.air.doId2do.has_key(avId)):
            av = self.air.doId2do[avId]
            if (finished == 2 and which > 0):
                # Make sure client was actually able to purchase
                if (self.air.questManager.removeClothingTicket(av, self) == 1
                        or self.freeClothes):
                    assert self.notify.debug('Successful purchase')
                    # No need to set the dna, it should already be set
                    av.b_setDNAString(blob)
                    # SDN:  only add clothes if they have been changed (i.e. if (which & n) == 1)
                    if which & ClosetGlobals.SHIRT:
                        if (av.addToClothesTopsList(
                                self.customerDNA.topTex,
                                self.customerDNA.topTexColor,
                                self.customerDNA.sleeveTex,
                                self.customerDNA.sleeveTexColor) == 1):
                            av.b_setClothesTopsList(av.getClothesTopsList())
                        else:
                            self.notify.warning(
                                'NPCTailor: setDNA() - unable to save old tops - we exceeded the tops list length'
                            )
                    if which & ClosetGlobals.SHORTS:
                        if (av.addToClothesBottomsList(
                                self.customerDNA.botTex,
                                self.customerDNA.botTexColor) == 1):
                            av.b_setClothesBottomsList(
                                av.getClothesBottomsList())
                        else:
                            self.notify.warning(
                                'NPCTailor: setDNA() - unable to save old bottoms - we exceeded the bottoms list length'
                            )

                    self.air.writeServerEvent(
                        'boughtTailorClothes', avId, "%s|%s|%s" %
                        (self.doId, which, self.customerDNA.asTuple()))

                else:
                    self.air.writeServerEvent(
                        'suspicious', avId,
                        'DistributedNPCTailorAI.setDNA bogus clothing ticket')
                    self.notify.warning(
                        'NPCTailor: setDNA() - client tried to purchase with bogus clothing ticket!'
                    )
                    if self.customerDNA:
                        av.b_setDNAString(self.customerDNA.makeNetString())
            elif (finished == 1):
                # Purchase cancelled - make sure DNA gets reset, but don't
                # burn the clothing ticket
                if self.customerDNA:
                    av.b_setDNAString(self.customerDNA.makeNetString())
            else:
                # Warning - we are trusting the client to set their DNA here
                # This is a big security hole. Either the client should just send
                # indexes into the clothing choices or the tailor should verify
                #av.b_setDNAString(blob)
                # Don't set the avatars DNA.  Instead, send a message back to the
                # all the clients in this zone telling them them the dna of the localToon
                # so they can set it themselves.
                self.sendUpdate("setCustomerDNA", [avId, blob])
        else:
            self.notify.warning('no av for avId: %d' % avId)
        if (self.timedOut == 1 or finished == 0):
            return
        if (self.busy == avId):
            taskMgr.remove(self.uniqueName('clearMovie'))
            self.completePurchase(avId)
        elif self.busy:
            self.air.writeServerEvent(
                'suspicious', avId,
                'DistributedNPCTailorAI.setDNA busy with %s' % (self.busy))
            self.notify.warning('setDNA from unknown avId: %s busy: %s' %
                                (avId, self.busy))
 def setMovie(self, mode, npcId, avId, timestamp):
     timeStamp = ClockDelta.globalClockDelta.localElapsedTime(timestamp)
     self.remain = NPCToons.CLERK_COUNTDOWN_TIME - timeStamp
     self.npcId = npcId
     self.isLocalToon = avId == base.localAvatar.doId
     if mode == NPCToons.PURCHASE_MOVIE_CLEAR:
         return
     if mode == NPCToons.PURCHASE_MOVIE_TIMEOUT:
         if self.lerpCameraSeq:
             self.lerpCameraSeq.finish()
             self.lerpCameraSeq = None
         if self.isLocalToon:
             self.ignore(self.purchaseDoneEvent)
             self.ignore(self.swapEvent)
             if self.popupInfo:
                 self.popupInfo.reparentTo(hidden)
         if self.clothesGUI:
             self.clothesGUI.resetClothes(self.oldStyle)
             self.__handlePurchaseDone(timeout=1)
         self.setChatAbsolute(TTLocalizer.STOREOWNER_TOOKTOOLONG, CFSpeech | CFTimeout)
         self.resetTailor()
     elif mode == NPCToons.PURCHASE_MOVIE_START or mode == NPCToons.PURCHASE_MOVIE_START_BROWSE or mode == NPCToons.PURCHASE_MOVIE_START_NOROOM:
         if mode == NPCToons.PURCHASE_MOVIE_START:
             self.browsing = 0
             self.roomAvailable = 1
         elif mode == NPCToons.PURCHASE_MOVIE_START_BROWSE:
             self.browsing = 1
             self.roomAvailable = 1
         elif mode == NPCToons.PURCHASE_MOVIE_START_NOROOM:
             self.browsing = 0
             self.roomAvailable = 0
         self.av = base.cr.doId2do.get(avId)
         if self.av is None:
             self.notify.warning('Avatar %d not found in doId' % avId)
             return
         else:
             self.accept(self.av.uniqueName('disable'), self.__handleUnexpectedExit)
         style = self.av.getStyle()
         self.oldStyle = ToonDNA.ToonDNA()
         self.oldStyle.makeFromNetString(style.makeNetString())
         self.setupAvatars(self.av)
         if self.isLocalToon:
             camera.wrtReparentTo(render)
             self.lerpCameraSeq = camera.posQuatInterval(1, Point3(-5, 9, self.getHeight() - 0.5), Point3(-150, -2, 0), other=self, blendType='easeOut', name=self.uniqueName('lerpCamera'))
             self.lerpCameraSeq.start()
         if self.browsing == 0:
             if self.roomAvailable == 0:
                 self.setChatAbsolute(TTLocalizer.STOREOWNER_NOROOM, CFSpeech | CFTimeout)
             else:
                 self.setChatAbsolute(TTLocalizer.STOREOWNER_GREETING, CFSpeech | CFTimeout)
         else:
             self.setChatAbsolute(TTLocalizer.STOREOWNER_BROWSING, CFSpeech | CFTimeout)
         if self.isLocalToon:
             taskMgr.doMethodLater(3.0, self.popupPurchaseGUI, self.uniqueName('popupPurchaseGUI'))
             print '-----------Starting tailor interaction-----------'
             print 'avid: %s, gender: %s' % (self.av.doId, self.av.style.gender)
             print 'current top = %s,%s,%s,%s and  bot = %s,%s,' % (self.av.style.topTex,
              self.av.style.topTexColor,
              self.av.style.sleeveTex,
              self.av.style.sleeveTexColor,
              self.av.style.botTex,
              self.av.style.botTexColor)
             print 'topsList = %s' % self.av.getClothesTopsList()
             print 'bottomsList = %s' % self.av.getClothesBottomsList()
             print '-------------------------------------------------'
     elif mode == NPCToons.PURCHASE_MOVIE_COMPLETE:
         self.setChatAbsolute(TTLocalizer.STOREOWNER_GOODBYE, CFSpeech | CFTimeout)
         if self.av and self.isLocalToon:
             print '-----------ending tailor interaction-----------'
             print 'avid: %s, gender: %s' % (self.av.doId, self.av.style.gender)
             print 'current top = %s,%s,%s,%s and  bot = %s,%s,' % (self.av.style.topTex,
              self.av.style.topTexColor,
              self.av.style.sleeveTex,
              self.av.style.sleeveTexColor,
              self.av.style.botTex,
              self.av.style.botTexColor)
             print 'topsList = %s' % self.av.getClothesTopsList()
             print 'bottomsList = %s' % self.av.getClothesBottomsList()
             print '-------------------------------------------------'
         self.resetTailor()
     elif mode == NPCToons.PURCHASE_MOVIE_NO_MONEY:
         self.notify.warning('PURCHASE_MOVIE_NO_MONEY should not be called')
         self.resetTailor()
     return
Exemple #24
0
    def setMovie(self, mode, npcId, avId, timestamp):
        """
        This is a message from the AI describing a movie between this NPC
        and a Toon that has approached us. 
        """
        timeStamp = ClockDelta.globalClockDelta.localElapsedTime(timestamp)
        self.remain = NPCToons.CLERK_COUNTDOWN_TIME - timeStamp

        self.npcId = npcId

        # See if this is the local toon
        self.isLocalToon = (avId == base.localAvatar.doId)

        assert (self.notify.debug("setMovie: %s %s %s %s" %
                                  (mode, avId, timeStamp, self.isLocalToon)))

        # This is an old movie in the server ram that has been cleared.
        # Just return and do nothing
        if (mode == NPCToons.PURCHASE_MOVIE_CLEAR):
            assert self.notify.debug('PURCHASE_MOVIE_CLEAR')
            return

        if (mode == NPCToons.PURCHASE_MOVIE_TIMEOUT):
            assert self.notify.debug('PURCHASE_MOVIE_TIMEOUT')
            # In case the GUI hasn't popped up yet
            taskMgr.remove(self.uniqueName('lerpCamera'))
            # Stop listening for the GUI
            if (self.isLocalToon):
                self.ignore(self.purchaseDoneEvent)
                self.ignore(self.swapEvent)
                # hide the popupInfo
                if self.popupInfo:
                    self.popupInfo.reparentTo(hidden)
            # See if a button was pressed first
            if self.clothesGUI:
                self.clothesGUI.resetClothes(self.oldStyle)
                self.__handlePurchaseDone(timeout=1)
            self.setChatAbsolute(TTLocalizer.STOREOWNER_TOOKTOOLONG,
                                 CFSpeech | CFTimeout)
            self.resetTailor()

        elif (mode == NPCToons.PURCHASE_MOVIE_START
              or mode == NPCToons.PURCHASE_MOVIE_START_BROWSE
              or mode == NPCToons.PURCHASE_MOVIE_START_NOROOM):
            assert self.notify.debug('PURCHASE_MOVIE_START')

            if (mode == NPCToons.PURCHASE_MOVIE_START):
                self.browsing = 0
                self.roomAvailable = 1
            elif (mode == NPCToons.PURCHASE_MOVIE_START_BROWSE):
                self.browsing = 1
                self.roomAvailable = 1
            elif (mode == NPCToons.PURCHASE_MOVIE_START_NOROOM):
                self.browsing = 0
                self.roomAvailable = 0

            self.av = base.cr.doId2do.get(avId)
            if self.av is None:
                self.notify.warning("Avatar %d not found in doId" % (avId))
                return
            else:
                self.accept(self.av.uniqueName('disable'),
                            self.__handleUnexpectedExit)

            style = self.av.getStyle()
            self.oldStyle = ToonDNA.ToonDNA()
            self.oldStyle.makeFromNetString(style.makeNetString())
            self.setupAvatars(self.av)

            if (self.isLocalToon):
                camera.wrtReparentTo(render)
                camera.lerpPosHpr(-5,
                                  9,
                                  self.getHeight() - 0.5,
                                  -150,
                                  -2,
                                  0,
                                  1,
                                  other=self,
                                  blendType="easeOut",
                                  task=self.uniqueName('lerpCamera'))

            if (self.browsing == 0):
                if (self.roomAvailable == 0):
                    self.setChatAbsolute(TTLocalizer.STOREOWNER_NOROOM,
                                         CFSpeech | CFTimeout)
                else:
                    self.setChatAbsolute(TTLocalizer.STOREOWNER_GREETING,
                                         CFSpeech | CFTimeout)
            else:
                self.setChatAbsolute(TTLocalizer.STOREOWNER_BROWSING,
                                     CFSpeech | CFTimeout)

            if (self.isLocalToon):
                taskMgr.doMethodLater(3.0, self.popupPurchaseGUI,
                                      self.uniqueName('popupPurchaseGUI'))
                # print out our clothes and closet information before we start
                print("-----------Starting tailor interaction-----------")
                print "avid: %s, gender: %s" % (self.av.doId,
                                                self.av.style.gender)
                print "current top = %s,%s,%s,%s and  bot = %s,%s," % (
                    self.av.style.topTex, self.av.style.topTexColor,
                    self.av.style.sleeveTex, self.av.style.sleeveTexColor,
                    self.av.style.botTex, self.av.style.botTexColor)
                print "topsList = %s" % self.av.getClothesTopsList()
                print "bottomsList = %s" % self.av.getClothesBottomsList()
                print("-------------------------------------------------")

        elif (mode == NPCToons.PURCHASE_MOVIE_COMPLETE):
            assert self.notify.debug('PURCHASE_MOVIE_COMPLETE')
            self.setChatAbsolute(TTLocalizer.STOREOWNER_GOODBYE,
                                 CFSpeech | CFTimeout)

            if self.av and self.isLocalToon:
                # print out our clothes and closet information before we start
                print("-----------ending tailor interaction-----------")
                print "avid: %s, gender: %s" % (self.av.doId,
                                                self.av.style.gender)
                print "current top = %s,%s,%s,%s and  bot = %s,%s," % (
                    self.av.style.topTex, self.av.style.topTexColor,
                    self.av.style.sleeveTex, self.av.style.sleeveTexColor,
                    self.av.style.botTex, self.av.style.botTexColor)
                print "topsList = %s" % self.av.getClothesTopsList()
                print "bottomsList = %s" % self.av.getClothesBottomsList()
                print("-------------------------------------------------")

            self.resetTailor()

        elif (mode == NPCToons.PURCHASE_MOVIE_NO_MONEY):
            self.notify.warning('PURCHASE_MOVIE_NO_MONEY should not be called')
            self.resetTailor()

        return
Exemple #25
0
def lookAtToon():
    if lookAtTarget == 'head':
        c,height = calcHeadBounds()
    else:
        c,height = calcBodyBounds()
    # Move camera there
    camera.setHpr(render, -180, 0, 0)
    camera.setPos(render, c)
    # Move it back to fit around the target
    offset = ((height/2.0)/
              tan(deg2Rad((fillFactor * effectiveFOV)/2.0)))
    camera.setY(camera, -offset)
    
tt = Toon()
dna = ToonDNA.ToonDNA()
dna.newToonRandom(gender = 'f')
tt.setDNA(dna)
tt.reparentTo(render)

base.disableMouse()
base.camLens.setFov(fov,fov)

def convertServerDNAString(serverString):
    # Strip out blank space and take last 30 characters
    serverString = serverString.replace(' ', '')
    stringLen = 30
    serverString = serverString[-stringLen:]
    # Create a datagram from server string
    dg = PyDatagram()
    for i in range(0,len(serverString),2):
 def setMovie(self, mode, npcId, avId, timestamp):
     timeStamp = ClockDelta.globalClockDelta.localElapsedTime(timestamp)
     self.remain = NPCToons.CLERK_COUNTDOWN_TIME - timeStamp
     self.npcId = npcId
     self.isLocalToon = avId == base.localAvatar.doId
     if mode == NPCToons.PURCHASE_MOVIE_CLEAR:
         return
     if mode == NPCToons.PURCHASE_MOVIE_TIMEOUT:
         #taskMgr.remove(self.uniqueName('lerpCamera'))
         if self.isLocalToon:
             self.ignore(self.purchaseDoneEvent)
             self.ignore(self.swapEvent)
             if self.popupInfo:
                 self.popupInfo.reparentTo(hidden)
         if self.clothesGUI:
             self.clothesGUI.resetClothes(self.oldStyle)
             self.__handlePurchaseDone(timeout=1)
         self.setChatAbsolute(TTLocalizer.STOREOWNER_TOOKTOOLONG,
                              CFSpeech | CFTimeout)
         self.resetTailor()
     elif mode == NPCToons.PURCHASE_MOVIE_START or mode == NPCToons.PURCHASE_MOVIE_START_BROWSE or mode == NPCToons.PURCHASE_MOVIE_START_NOROOM or mode == NPCToons.PURCHASE_MOVIE_START_BROWSE_JBS:
         if mode == NPCToons.PURCHASE_MOVIE_START:
             self.browsing = 0
             self.roomAvailable = 1
         elif mode == NPCToons.PURCHASE_MOVIE_START_BROWSE or mode == NPCToons.PURCHASE_MOVIE_START_BROWSE_JBS:
             self.browsing = 1
             self.roomAvailable = 1
         elif mode == NPCToons.PURCHASE_MOVIE_START_NOROOM:
             self.browsing = 0
             self.roomAvailable = 0
         self.av = base.cr.doId2do.get(avId)
         if self.av is None:
             self.notify.warning('Avatar %d not found in doId' % avId)
             return
         else:
             self.accept(self.av.uniqueName('disable'),
                         self.__handleUnexpectedExit)
         style = self.av.getStyle()
         self.oldStyle = ToonDNA.ToonDNA()
         self.oldStyle.makeFromNetString(style.makeNetString())
         self.setupAvatars(self.av)
         if self.isLocalToon:
             #base.camera.wrtReparentTo(render)
             #base.camera.lerpPosHpr(-5, 9, self.getHeight() - 0.5, -150, -2, 0, 1, other=self, blendType='easeOut', task=self.uniqueName('lerpCamera'))
             self.cameraWork = base.camera.posHprInterval(
                 2,
                 Point3(-5, 9,
                        self.getHeight() - 0.5),
                 Point3(-150, -2, 0),
                 blendType='easeOut')
             self.cameraWork.start()
         if self.browsing == 0:
             if self.roomAvailable == 0:
                 self.setChatAbsolute(TTLocalizer.STOREOWNER_NOROOM,
                                      CFSpeech | CFTimeout)
             else:
                 self.setChatAbsolute(TTLocalizer.STOREOWNER_GREETING,
                                      CFSpeech | CFTimeout)
         elif mode == NPCToons.PURCHASE_MOVIE_START_BROWSE_JBS:
             self.setChatAbsolute(TTLocalizer.STOREOWNER_BROWSING_JBS,
                                  CFSpeech | CFTimeout)
         else:
             self.setChatAbsolute(TTLocalizer.STOREOWNER_BROWSING,
                                  CFSpeech | CFTimeout)
         if self.isLocalToon:
             taskMgr.doMethodLater(3.0, self.popupPurchaseGUI,
                                   self.uniqueName('popupPurchaseGUI'))
     elif mode == NPCToons.PURCHASE_MOVIE_COMPLETE:
         self.setChatAbsolute(TTLocalizer.STOREOWNER_GOODBYE,
                              CFSpeech | CFTimeout)
         self.resetTailor()
     elif mode == NPCToons.PURCHASE_MOVIE_NO_MONEY:
         self.notify.warning('PURCHASE_MOVIE_NO_MONEY should not be called')
         self.resetTailor()
     return