def announceGenerate(self):
     self.notify.debug('announceGenerate')
     DistributedObject.DistributedObject.announceGenerate(self)
     if self.editorIsLocalToon():
         from otp.level import EditorGlobals
         EditorGlobals.assertReadyToEdit()
         self.notify.debug('requesting an up-to-date copy of the level spec')
         self.sendUpdate('requestCurrentLevelSpec')
Exemple #2
0
    def announceGenerate(self):
        self.notify.debug('announceGenerate')
        DistributedObject.DistributedObject.announceGenerate(self)

        # load stuff
        if self.editorIsLocalToon():
            # make sure we're set up for editing
            from otp.level import EditorGlobals
            EditorGlobals.assertReadyToEdit()
            assert self.editUsername == EditorGlobals.getEditUsername()
            
            # ask for the current spec; it will arrive in pieces, since
            # it's so large
            self.notify.debug('requesting an up-to-date copy of the level spec')
            self.sendUpdate('requestCurrentLevelSpec')
    def doMagicWord(self, word, avId, zoneId):
        wordIs = Functor(self.wordIs, word)
        if MagicWordManager.MagicWordManager.doMagicWord(
                self, word, avId, zoneId) == 1:
            pass
        elif wordIs('~fanfare'):
            go = Fanfare.makeFanfareWithMessageImage(
                0, base.localAvatar, 1,
                "You just did a ~fanfare.  Here's a rake.", Vec2(0, 0.2), 0.08,
                base.localAvatar.inventory.buttonLookup(1, 1), Vec3(0, 0,
                                                                    0), 4)
            Sequence(
                go[0], Func(go[1].show),
                LerpColorScaleInterval(go[1],
                                       duration=0.5,
                                       startColorScale=Vec4(1, 1, 1, 0),
                                       colorScale=Vec4(1, 1, 1, 1)), Wait(2),
                LerpColorScaleInterval(go[1],
                                       duration=0.5,
                                       startColorScale=Vec4(1, 1, 1, 1),
                                       colorScale=Vec4(1, 1, 1, 0)),
                Func(go[1].remove)).start()
        elif wordIs('~endgame'):
            print('Requesting minigame abort...')
            messenger.send('minigameAbort')
        elif wordIs('~wingame'):
            print('Requesting minigame victory...')
            messenger.send('minigameVictory')
        elif wordIs('~walk'):
            try:
                fsm = base.cr.playGame.getPlace().fsm
                fsm.forceTransition('walk')
            except:
                pass

        elif wordIs('~movie'):
            try:
                fsm = base.cr.playGame.getPlace().fsm
                fsm.forceTransition('movie')
            except:
                pass

        elif wordIs('~sit'):
            try:
                base.cr.playGame.getPlace().fsm.request('sit')
            except:
                pass

        elif wordIs('~rogues'):
            suitname = None
            if len(word) > 7:
                suitname = word[7:].split(' ')[1]
            self.rogues = RoguesGallery.RoguesGallery(suitname)
            self.rogues.enter()
            if suitname != None:
                self.rogues.animate()
            self.acceptOnce('mouse1', self.exit_rogues)
        elif wordIs('~showPaths'):
            for obj in list(self.cr.doId2do.values()):
                if isinstance(obj,
                              DistributedSuitPlanner.DistributedSuitPlanner):
                    obj.showPaths()

            place = base.cr.playGame.getPlace()
            if hasattr(place, 'showPaths'):
                place.showPaths()
        elif wordIs('~hidePaths'):
            for obj in list(self.cr.doId2do.values()):
                if isinstance(obj,
                              DistributedSuitPlanner.DistributedSuitPlanner):
                    obj.hidePaths()

            place = base.cr.playGame.getPlace()
            if hasattr(place, 'hidePaths'):
                place.hidePaths()
        elif wordIs('~raceForever'):
            base.raceForever = True
        elif wordIs('~listen'):
            base.localAvatar.garbleChat = 0
        elif wordIs('~nochat') or wordIs('~chat') or wordIs('~superchat'):
            base.localAvatar.garbleChat = 1
        elif wordIs('~exec'):
            ChatManager.ChatManager.execChat = 1
        elif wordIs('~photoshoot'):
            base.cr.playGame.hood.sky.hide()
            base.cr.playGame.getPlace().loader.geom.hide()
            base.win.setClearColor(VBase4(1, 1, 1, 1))
            base.localAvatar.stopLookAroundNow()
            base.localAvatar.stopBlink()
            base.localAvatar.setNameVisible(0)
        elif wordIs('~hideAttack'):
            TownBattleAttackPanel.hideAttackPanel(1)
        elif wordIs('~showAttack'):
            TownBattleAttackPanel.hideAttackPanel(0)
        elif wordIs('~collisions_on'):
            base.localAvatar.collisionsOn()
        elif wordIs('~collisions_off'):
            base.localAvatar.collisionsOff()
        elif wordIs('~battle_detect_off'):
            from toontown.suit import DistributedSuit
            DistributedSuit.ALLOW_BATTLE_DETECT = 0
        elif wordIs('~battle_detect_on'):
            from toontown.suit import DistributedSuit
            DistributedSuit.ALLOW_BATTLE_DETECT = 1
        elif wordIs('~battles'):
            base.localAvatar.setWantBattles(not base.localAvatar.wantBattles)
            if base.localAvatar.wantBattles:
                response = 'battles ON'
            else:
                response = 'battles OFF'
            self.setMagicWordResponse(response)
        elif wordIs('~skipBattleMovie') or wordIs('~sbm'):
            ToontownBattleGlobals.SkipMovie = not ToontownBattleGlobals.SkipMovie
            if ToontownBattleGlobals.SkipMovie:
                response = 'battle movies will be skipped'
            else:
                response = 'battle movies will be played'
            self.setMagicWordResponse(response)
        elif wordIs('~addCameraPosition'):
            base.localAvatar.addCameraPosition()
        elif wordIs('~removeCameraPosition'):
            base.localAvatar.removeCameraPosition()
        elif wordIs('~printCameraPosition'):
            base.localAvatar.printCameraPosition(base.localAvatar.cameraIndex)
        elif wordIs('~printCameraPositions'):
            base.localAvatar.printCameraPositions()
        elif wordIs('~worldCam') or wordIs('~wc'):
            myCam = render.find('**/camera')
            if not myCam.isEmpty():
                camParent = myCam.getParent()
                myCam.wrtReparentTo(render)
                pos = myCam.getPos()
                hpr = myCam.getHpr()
                response = '(%.2f, %.2f, %.2f,) (%.2f, %.2f, %.2f)' % (
                    pos[0], pos[1], pos[2], hpr[0], hpr[1], hpr[2])
                if not camParent.isEmpty():
                    myCam.wrtReparentTo(camParent)
                self.setMagicWordResponse(response)
                print(response)
        elif wordIs('~sync'):
            tm = base.cr.timeManager
            if tm == None:
                response = 'No TimeManager.'
                self.setMagicWordResponse(response)
            else:
                tm.extraSkew = 0.0
                skew = string.strip(word[5:])
                if skew != '':
                    tm.extraSkew = float(skew)
                globalClockDelta.clear()
                tm.handleHotkey()
        elif wordIs('~period'):
            timeout = string.strip(word[7:])
            if timeout != '':
                seconds = int(timeout)
                base.cr.stopPeriodTimer()
                base.cr.resetPeriodTimer(seconds)
                base.cr.startPeriodTimer()
            if base.cr.periodTimerExpired:
                response = 'Period timer has expired.'
            elif base.cr.periodTimerStarted:
                elapsed = globalClock.getFrameTime(
                ) - base.cr.periodTimerStarted
                secondsRemaining = base.cr.periodTimerSecondsRemaining - elapsed
                response = 'Period timer expires in %s seconds.' % int(
                    secondsRemaining)
            else:
                response = 'Period timer not set.'
            self.setMagicWordResponse(response)
        elif wordIs('~net'):
            if base.cr.networkPlugPulled():
                base.cr.restoreNetworkPlug()
                base.cr.startHeartbeat()
                response = 'Network restored.'
            else:
                base.cr.pullNetworkPlug()
                base.cr.stopHeartbeat()
                response = 'Network disconnected.'
            self.setMagicWordResponse(response)
        elif wordIs('~lag'):
            if not hasattr(base.cr, 'magicLag'):
                base.cr.startDelay(0.1, 0.35)
                base.cr.magicLag = None
                response = 'Simulated Lag On'
            else:
                base.cr.stopDelay()
                del base.cr.magicLag
                response = 'Simulated Lag Off'
            self.setMagicWordResponse(response)
        elif wordIs('~endlessquietzone'):
            base.endlessQuietZone = not base.endlessQuietZone
            response = 'endless quiet zone %s' % choice(
                base.endlessQuietZone, 'ON', 'OFF')
            self.setMagicWordResponse(response)
        elif wordIs('~cogPageFull'):
            base.localAvatar.suitPage.updateAllCogs(3)
        elif wordIs('~mintId'):
            args = word.split()
            postName = 'mintIdOverride'
            if len(args) < 2:
                if bboard.has(postName):
                    bboard.remove(postName)
            else:
                try:
                    id = int(args[1])
                    foo = ToontownGlobals.MintNumRooms[id]
                except:
                    pass
                else:
                    bboard.post(postName, id)

        elif wordIs('~mintRoom'):
            args = word.split()
            postName = 'mintRoom'
            if len(args) < 2:
                if bboard.has(postName):
                    bboard.remove(postName)
            else:
                try:
                    id = int(args[1])
                except:
                    pass
                else:
                    bboard.post(postName, id)

        elif wordIs('~mintWarp'):
            args = word.split()
            if len(args) < 2:
                self.setMagicWordResponse('Usage: ~mintWarp roomId')
                return
            try:
                roomNum = int(args[1])
            except:
                self.setMagicWordResponse('roomId not found: %s' % args[1])
                return

            if not bboard.has('mint'):
                self.setMagicWordResponse('not in a mint')
                return
            mint = bboard.get('mint')
            if not mint.warpToRoom(roomNum):
                self.setMagicWordResponse(
                    'invalid roomId or roomId not in this mint: %s' % args[1])
                return
        elif wordIs('~mintLayouts'):
            from toontown.coghq import MintLayout
            MintLayout.printAllCashbotInfo()
            self.setMagicWordResponse('logged mint layouts')
        elif wordIs('~edit'):
            if not __dev__:
                self.setMagicWordResponse('client not running in dev mode')
                return
            from otp.level import EditorGlobals
            level = bboard.get(EditorGlobals.EditTargetPostName)
            if level == None:
                self.setMagicWordResponse('no level available for editing')
                return
            from toontown.coghq import DistributedInGameEditor
            EditorGlobals.assertReadyToEdit()
            editUsername = EditorGlobals.getEditUsername()
            editors = base.cr.doFindAll('DistributedInGameEditor')
            for e in editors:
                if isinstance(e,
                              DistributedInGameEditor.DistributedInGameEditor):
                    if e.getLevelDoId() == level.doId:
                        if e.editorIsLocalToon() or e.getEditUsername(
                        ) == editUsername:
                            self.setMagicWordResponse(
                                "you ('%s') are already editing this level" %
                                editUsername)
                            return

            cmd = '~inGameEdit %s %s' % (level.doId, editUsername)
            self.b_setMagicWord(cmd)
        elif wordIs('~fshow'):
            from toontown.coghq import DistributedFactory
            factories = base.cr.doFindAll('DistributedFactory')
            factory = None
            for f in factories:
                if isinstance(f, DistributedFactory.DistributedFactory):
                    factory = f
                    break

            if factory is None:
                self.setMagicWordResponse('factory not found')
                return
            factory.setColorZones(not factory.fColorZones)
        elif wordIs('~fzone'):
            args = word.split()
            if len(args) < 2:
                self.setMagicWordResponse('Usage: ~fzone <zoneNum>')
                return
            zoneId = int(args[1])
            from toontown.coghq import DistributedFactory
            factories = base.cr.doFindAll('DistributedFactory')
            factory = None
            for f in factories:
                if isinstance(f, DistributedFactory.DistributedFactory):
                    factory = f
                    break

            if factory is None:
                self.setMagicWordResponse('factory not found')
                return
            factory.warpToZone(zoneId)
        elif wordIs('~undead'):
            try:
                goons = base.cr.doFindAll('Goon')
                for goon in goons:
                    goon.undead()

            except:
                self.notify.warning('Error in undead')

        elif wordIs('~resyncGoons'):
            try:
                goons = base.cr.doFindAll('Goon')
                for goon in goons:
                    goon.resync()

            except:
                self.notify.warning('Error in resyncing')

        elif wordIs('~catalog'):
            self.doCatalog(word)
        elif wordIs('~petCam') and base.wantPets:
            if hasattr(base, 'petCamPrevParent'):
                base.cam.reparentTo(base.petCamPrevParent)
                del base.petCamPrevParent
            else:
                petId = base.localAvatar.getPetId()
                pet = self.cr.doId2do.get(petId)
                if pet:
                    if not hasattr(pet, 'camNode'):
                        pet.camNode = pet.attachNewNode('camNode')
                        pet.camNode.setPos(0, 0, 2.5)
                    base.petCamPrevParent = base.cam.getParent()
                    base.cam.reparentTo(pet.camNode)
        elif wordIs('~lockPet') and base.wantPets:
            petId = base.localAvatar.getPetId()
            pet = self.cr.doId2do.get(petId)
            if pet:
                if not pet.isLockedDown():
                    pet.lockPet()
        elif wordIs('~unlockPet') and base.wantPets:
            petId = base.localAvatar.getPetId()
            pet = self.cr.doId2do.get(petId)
            if pet:
                if pet.isLockedDown():
                    pet.unlockPet()
        elif wordIs('~resetPetTutorial') and base.wantPets:
            base.localAvatar.setPetTutorialDone(False)
            response = 'Pet Tutorial flag reset'
            self.setMagicWordResponse(response)
        elif wordIs('~bossBattle'):
            self.doBossBattle(word)
        elif wordIs('~RaceChat'):
            base.localAvatar.chatMgr.chatInputSpeedChat.addKartRacingMenu()
        elif wordIs('~BuyKart'):
            if base.wantKarts:

                def doShtikerLater(task):
                    base.localAvatar.addKartPage()
                    return 0

                if base.localAvatar.hasKart():
                    response = 'Returning Kart %s' % base.localAvatar.getKartBodyType(
                    )
                    base.localAvatar.requestKartDNAFieldUpdate(
                        KartDNA.bodyType, InvalidEntry)
                    self.setMagicWordResponse(response)
                else:
                    base.localAvatar.requestKartDNAFieldUpdate(
                        KartDNA.rimsType, getDefaultRim())
                    taskMgr.doMethodLater(1.0, doShtikerLater,
                                          'doShtikerLater')
                response = 'Kart %s has been purchased with body and accessory color %s.' % (
                    word[9], getDefaultColor())
                base.localAvatar.requestKartDNAFieldUpdate(
                    KartDNA.bodyType, int(word[9]))
                self.setMagicWordResponse(response)
            else:
                self.setMagicWordResponse('Enable wantKarts in Config.prc')
        elif wordIs('~leaveRace'):
            messenger.send('leaveRace')
        elif wordIs('~kartParticles'):
            b = ConfigVariableBool('want-kart-particles', 0)
            b.setValue(not b)
        elif wordIs('~gardenGame'):
            messenger.send('gardenGame')
            response = 'You must be on your estate'
            self.setMagicWordResponse(response)
        elif wordIs('~verboseState'):
            base.localAvatar.verboseState()
        elif wordIs('~golf'):
            self.doGolf(word)
        elif wordIs('~whiteList'):
            base.localAvatar.chatMgr.chatInputSpeedChat.addWhiteList()
        elif wordIs('~updateWhiteList'):
            self.notify.info('Updating WhiteList')
            base.whiteList.redownloadWhitelist()
        elif wordIs('~noWhiteList'):
            base.localAvatar.chatMgr.chatInputSpeedChat.removeWhiteList()
        elif wordIs('~setPaid'):
            args = word.split()
            if len(args) > 1:
                paid = int(args[1])
                statusString = base.config.GetString('force-paid-status',
                                                     'none')
                if paid:
                    paid = 1
                    if statusString != 'none':
                        if statusString == 'VELVET':
                            ConfigVariableString('force-paid-status').setValue(
                                'FULL')
                        elif statusString == 'unpaid':
                            ConfigVariableString('force-paid-status').setValue(
                                'paid')
                    base.cr.setIsPaid(1)
                else:
                    paid = 0
                    if statusString != 'none':
                        if statusString == 'FULL':
                            ConfigVariableString('force-paid-status').setValue(
                                'VELVET')
                        elif statusString == 'paid':
                            ConfigVariableString('force-paid-status').setValue(
                                'unpaid')
                    base.cr.setIsPaid(0)
            else:
                return
        elif wordIs('~party'):
            self.doParty(word, avId, zoneId)
        elif wordIs('~news'):
            self.doNews(word, avId, zoneId)
        elif wordIs('~bgui'):
            if not hasattr(self, 'groupPanel'):
                from toontown.toon import GroupPanel
                self.groupPanel = GroupPanel.GroupPanel(
                    base.localAvatar.boardingParty)
                self.groupPanel.frame.show()
            else:
                self.groupPanel.frame.hide()
                self.groupPanel.cleanup()
                del self.groupPanel
        elif wordIs('~generateOrder'):
            args = word.split()
            if len(args) > 1:
                newOrder = int(args[1])
                if newOrder >= 0 and newOrder <= 2:
                    datagram = PyDatagram.PyDatagram()
                    datagram.addUint16(
                        MsgName2Id['CLIENT_CHANGE_GENERATE_ORDER'])
                    datagram.addUint32(newOrder)
                    base.cr.send(datagram)
                    response = 'changing generate order to %s' % newOrder
                    self.setMagicWordResponse(response)
            else:
                response = 'args: 0 default, 1 reversed, 2 shuffled'
                self.setMagicWordResponse(response)
        elif wordIs('~ruler'):
            response = 'Each unit is equal to one foot'
            self.setMagicWordResponse(response)
            if self.ruler:
                self.ruler.detachNode()
                del self.ruler
            self.ruler = loader.loadModel('phase_3/models/props/xyzAxis')
            self.ruler.reparentTo(render)
            self.ruler.setPos(base.localAvatar.getPos())
            self.ruler.place()
        elif wordIs('~toonIdTags'):
            otherToons = base.cr.doFindAllOfType('DistributedToon')
            if otherToons:
                for toon in otherToons[0]:
                    toon.setNametagStyle(0)

            messenger.send('nameTagShowAvId', [])
            base.idTags = 1
        elif wordIs('~code'):
            args = word.split()
            if len(args) > 1:
                code = word[len(args[0]) + 1:]
                base.codeRedemptionMgr.redeemCode(
                    code, self._handleCodeRedemptionResponse)
                response = 'sending code %s to server...' % code
            else:
                response = '~code <code>'
            self.setMagicWordResponse(response)
        return
    def doMagicWord(self, word, avId, zoneId):
        wordIs = Functor(self.wordIs, word)
        if MagicWordManager.MagicWordManager.doMagicWord(self, word, avId, zoneId) == 1:
            pass
        elif wordIs("~fanfare"):
            go = Fanfare.makeFanfareWithMessageImage(
                0,
                base.localAvatar,
                1,
                "You just did a ~fanfare.  Here's a rake.",
                Vec2(0, 0.2),
                0.08,
                base.localAvatar.inventory.buttonLookup(1, 1),
                Vec3(0, 0, 0),
                4,
            )
            Sequence(
                go[0],
                Func(go[1].show),
                LerpColorScaleInterval(
                    go[1], duration=0.5, startColorScale=Vec4(1, 1, 1, 0), colorScale=Vec4(1, 1, 1, 1)
                ),
                Wait(2),
                LerpColorScaleInterval(
                    go[1], duration=0.5, startColorScale=Vec4(1, 1, 1, 1), colorScale=Vec4(1, 1, 1, 0)
                ),
                Func(go[1].remove),
            ).start()
        elif wordIs("~endgame"):
            print "Requesting minigame abort..."
            messenger.send("minigameAbort")
        elif wordIs("~wingame"):
            print "Requesting minigame victory..."
            messenger.send("minigameVictory")
        elif wordIs("~walk"):
            try:
                fsm = base.cr.playGame.getPlace().fsm
                fsm.forceTransition("walk")
            except:
                pass

        elif wordIs("~movie"):
            try:
                fsm = base.cr.playGame.getPlace().fsm
                fsm.forceTransition("movie")
            except:
                pass

        elif wordIs("~sit"):
            try:
                base.cr.playGame.getPlace().fsm.request("sit")
            except:
                pass

        elif wordIs("~rogues"):
            suitname = None
            if len(word) > 7:
                suitname = word[7:].split(" ")[1]
            self.rogues = RoguesGallery.RoguesGallery(suitname)
            self.rogues.enter()
            if suitname != None:
                self.rogues.animate()
            self.acceptOnce("mouse1", self.exit_rogues)
        elif wordIs("~showPaths"):
            for obj in self.cr.doId2do.values():
                if isinstance(obj, DistributedSuitPlanner.DistributedSuitPlanner):
                    obj.showPaths()

            place = base.cr.playGame.getPlace()
            if hasattr(place, "showPaths"):
                place.showPaths()
        elif wordIs("~hidePaths"):
            for obj in self.cr.doId2do.values():
                if isinstance(obj, DistributedSuitPlanner.DistributedSuitPlanner):
                    obj.hidePaths()

            place = base.cr.playGame.getPlace()
            if hasattr(place, "hidePaths"):
                place.hidePaths()
        elif wordIs("~raceForever"):
            base.raceForever = True
        elif wordIs("~listen"):
            base.localAvatar.garbleChat = 0
        elif wordIs("~nochat") or wordIs("~chat") or wordIs("~superchat"):
            base.localAvatar.garbleChat = 1
        elif wordIs("~exec"):
            ChatManager.ChatManager.execChat = 1
        elif wordIs("~photoshoot"):
            base.cr.playGame.hood.sky.hide()
            base.cr.playGame.getPlace().loader.geom.hide()
            base.win.setClearColor(VBase4(1, 1, 1, 1))
            base.localAvatar.stopLookAroundNow()
            base.localAvatar.stopBlink()
            base.localAvatar.setNameVisible(0)
        elif wordIs("~hideAttack"):
            TownBattleAttackPanel.hideAttackPanel(1)
        elif wordIs("~showAttack"):
            TownBattleAttackPanel.hideAttackPanel(0)
        elif wordIs("~collisions_on"):
            base.localAvatar.collisionsOn()
        elif wordIs("~collisions_off"):
            base.localAvatar.collisionsOff()
        elif wordIs("~battle_detect_off"):
            from toontown.suit import DistributedSuit

            DistributedSuit.ALLOW_BATTLE_DETECT = 0
        elif wordIs("~battle_detect_on"):
            from toontown.suit import DistributedSuit

            DistributedSuit.ALLOW_BATTLE_DETECT = 1
        elif wordIs("~battles"):
            base.localAvatar.setWantBattles(not base.localAvatar.wantBattles)
            if base.localAvatar.wantBattles:
                response = "battles ON"
            else:
                response = "battles OFF"
            self.setMagicWordResponse(response)
        elif wordIs("~skipBattleMovie") or wordIs("~sbm"):
            ToontownBattleGlobals.SkipMovie = not ToontownBattleGlobals.SkipMovie
            if ToontownBattleGlobals.SkipMovie:
                response = "battle movies will be skipped"
            else:
                response = "battle movies will be played"
            self.setMagicWordResponse(response)
        elif wordIs("~addCameraPosition"):
            base.localAvatar.addCameraPosition()
        elif wordIs("~removeCameraPosition"):
            base.localAvatar.removeCameraPosition()
        elif wordIs("~printCameraPosition"):
            base.localAvatar.printCameraPosition(base.localAvatar.cameraIndex)
        elif wordIs("~printCameraPositions"):
            base.localAvatar.printCameraPositions()
        elif wordIs("~worldCam") or wordIs("~wc"):
            myCam = render.find("**/camera")
            if not myCam.isEmpty():
                camParent = myCam.getParent()
                myCam.wrtReparentTo(render)
                pos = myCam.getPos()
                hpr = myCam.getHpr()
                response = "(%.2f, %.2f, %.2f,) (%.2f, %.2f, %.2f)" % (pos[0], pos[1], pos[2], hpr[0], hpr[1], hpr[2])
                if not camParent.isEmpty():
                    myCam.wrtReparentTo(camParent)
                self.setMagicWordResponse(response)
                print response
        elif wordIs("~sync"):
            tm = base.cr.timeManager
            if tm == None:
                response = "No TimeManager."
                self.setMagicWordResponse(response)
            else:
                tm.extraSkew = 0.0
                skew = string.strip(word[5:])
                if skew != "":
                    tm.extraSkew = float(skew)
                globalClockDelta.clear()
                tm.handleHotkey()
        elif wordIs("~period"):
            timeout = string.strip(word[7:])
            if timeout != "":
                seconds = int(timeout)
                base.cr.stopPeriodTimer()
                base.cr.resetPeriodTimer(seconds)
                base.cr.startPeriodTimer()
            if base.cr.periodTimerExpired:
                response = "Period timer has expired."
            elif base.cr.periodTimerStarted:
                elapsed = globalClock.getFrameTime() - base.cr.periodTimerStarted
                secondsRemaining = base.cr.periodTimerSecondsRemaining - elapsed
                response = "Period timer expires in %s seconds." % int(secondsRemaining)
            else:
                response = "Period timer not set."
            self.setMagicWordResponse(response)
        elif wordIs("~net"):
            if base.cr.networkPlugPulled():
                base.cr.restoreNetworkPlug()
                base.cr.startHeartbeat()
                response = "Network restored."
            else:
                base.cr.pullNetworkPlug()
                base.cr.stopHeartbeat()
                response = "Network disconnected."
            self.setMagicWordResponse(response)
        elif wordIs("~lag"):
            if not hasattr(base.cr, "magicLag"):
                base.cr.startDelay(0.1, 0.35)
                base.cr.magicLag = None
                response = "Simulated Lag On"
            else:
                base.cr.stopDelay()
                del base.cr.magicLag
                response = "Simulated Lag Off"
            self.setMagicWordResponse(response)
        elif wordIs("~endlessquietzone"):
            base.endlessQuietZone = not base.endlessQuietZone
            response = "endless quiet zone %s" % choice(base.endlessQuietZone, "ON", "OFF")
            self.setMagicWordResponse(response)
        elif wordIs("~cogPageFull"):
            base.localAvatar.suitPage.updateAllCogs(3)
        elif wordIs("~mintId"):
            args = word.split()
            postName = "mintIdOverride"
            if len(args) < 2:
                if bboard.has(postName):
                    bboard.remove(postName)
            else:
                try:
                    id = int(args[1])
                    foo = ToontownGlobals.MintNumRooms[id]
                except:
                    pass
                else:
                    bboard.post(postName, id)

        elif wordIs("~mintRoom"):
            args = word.split()
            postName = "mintRoom"
            if len(args) < 2:
                if bboard.has(postName):
                    bboard.remove(postName)
            else:
                try:
                    id = int(args[1])
                except:
                    pass
                else:
                    bboard.post(postName, id)

        elif wordIs("~mintWarp"):
            args = word.split()
            if len(args) < 2:
                self.setMagicWordResponse("Usage: ~mintWarp roomId")
                return
            try:
                roomNum = int(args[1])
            except:
                self.setMagicWordResponse("roomId not found: %s" % args[1])
                return

            if not bboard.has("mint"):
                self.setMagicWordResponse("not in a mint")
                return
            mint = bboard.get("mint")
            if not mint.warpToRoom(roomNum):
                self.setMagicWordResponse("invalid roomId or roomId not in this mint: %s" % args[1])
                return
        elif wordIs("~mintLayouts"):
            from toontown.coghq import MintLayout

            MintLayout.printAllCashbotInfo()
            self.setMagicWordResponse("logged mint layouts")
        elif wordIs("~edit"):
            if not __dev__:
                self.setMagicWordResponse("client not running in dev mode")
                return
            from otp.level import EditorGlobals

            level = bboard.get(EditorGlobals.EditTargetPostName)
            if level == None:
                self.setMagicWordResponse("no level available for editing")
                return
            from toontown.coghq import DistributedInGameEditor

            EditorGlobals.assertReadyToEdit()
            editUsername = EditorGlobals.getEditUsername()
            editors = base.cr.doFindAll("DistributedInGameEditor")
            for e in editors:
                if isinstance(e, DistributedInGameEditor.DistributedInGameEditor):
                    if e.getLevelDoId() == level.doId:
                        if e.editorIsLocalToon() or e.getEditUsername() == editUsername:
                            self.setMagicWordResponse("you ('%s') are already editing this level" % editUsername)
                            return

            cmd = "~inGameEdit %s %s" % (level.doId, editUsername)
            self.b_setMagicWord(cmd)
        elif wordIs("~fshow"):
            from toontown.coghq import DistributedFactory

            factories = base.cr.doFindAll("DistributedFactory")
            factory = None
            for f in factories:
                if isinstance(f, DistributedFactory.DistributedFactory):
                    factory = f
                    break

            if factory is None:
                self.setMagicWordResponse("factory not found")
                return
            factory.setColorZones(not factory.fColorZones)
        elif wordIs("~fzone"):
            args = word.split()
            if len(args) < 2:
                self.setMagicWordResponse("Usage: ~fzone <zoneNum>")
                return
            zoneId = int(args[1])
            from toontown.coghq import DistributedFactory

            factories = base.cr.doFindAll("DistributedFactory")
            factory = None
            for f in factories:
                if isinstance(f, DistributedFactory.DistributedFactory):
                    factory = f
                    break

            if factory is None:
                self.setMagicWordResponse("factory not found")
                return
            factory.warpToZone(zoneId)
        elif wordIs("~undead"):
            try:
                goons = base.cr.doFindAll("Goon")
                for goon in goons:
                    goon.undead()

            except:
                self.notify.warning("Error in undead")

        elif wordIs("~resyncGoons"):
            try:
                goons = base.cr.doFindAll("Goon")
                for goon in goons:
                    goon.resync()

            except:
                self.notify.warning("Error in resyncing")

        elif wordIs("~catalog"):
            self.doCatalog(word)
        elif wordIs("~petCam") and base.wantPets:
            if hasattr(base, "petCamPrevParent"):
                base.cam.reparentTo(base.petCamPrevParent)
                del base.petCamPrevParent
            else:
                petId = base.localAvatar.getPetId()
                pet = self.cr.doId2do.get(petId)
                if pet:
                    if not hasattr(pet, "camNode"):
                        pet.camNode = pet.attachNewNode("camNode")
                        pet.camNode.setPos(0, 0, 2.5)
                    base.petCamPrevParent = base.cam.getParent()
                    base.cam.reparentTo(pet.camNode)
        elif wordIs("~lockPet") and base.wantPets:
            petId = base.localAvatar.getPetId()
            pet = self.cr.doId2do.get(petId)
            if pet:
                if not pet.isLockedDown():
                    pet.lockPet()
        elif wordIs("~unlockPet") and base.wantPets:
            petId = base.localAvatar.getPetId()
            pet = self.cr.doId2do.get(petId)
            if pet:
                if pet.isLockedDown():
                    pet.unlockPet()
        elif wordIs("~resetPetTutorial") and base.wantPets:
            base.localAvatar.setPetTutorialDone(False)
            response = "Pet Tutorial flag reset"
            self.setMagicWordResponse(response)
        elif wordIs("~bossBattle"):
            self.doBossBattle(word)
        elif wordIs("~RaceChat"):
            base.localAvatar.chatMgr.chatInputSpeedChat.addKartRacingMenu()
        elif wordIs("~BuyKart"):
            if base.wantKarts:

                def doShtikerLater(task):
                    base.localAvatar.addKartPage()
                    return 0

                if base.localAvatar.hasKart():
                    response = "Returning Kart %s" % base.localAvatar.getKartBodyType()
                    base.localAvatar.requestKartDNAFieldUpdate(KartDNA.bodyType, InvalidEntry)
                    self.setMagicWordResponse(response)
                else:
                    base.localAvatar.requestKartDNAFieldUpdate(KartDNA.rimsType, getDefaultRim())
                    taskMgr.doMethodLater(1.0, doShtikerLater, "doShtikerLater")
                response = "Kart %s has been purchased with body and accessory color %s." % (word[9], getDefaultColor())
                base.localAvatar.requestKartDNAFieldUpdate(KartDNA.bodyType, int(word[9]))
                self.setMagicWordResponse(response)
            else:
                self.setMagicWordResponse("Enable wantKarts in Config.prc")
        elif wordIs("~leaveRace"):
            messenger.send("leaveRace")
        elif wordIs("~kartParticles"):
            b = ConfigVariableBool("want-kart-particles", 0)
            b.setValue(not b)
        elif wordIs("~gardenGame"):
            messenger.send("gardenGame")
            response = "You must be on your estate"
            self.setMagicWordResponse(response)
        elif wordIs("~verboseState"):
            base.localAvatar.verboseState()
        elif wordIs("~golf"):
            self.doGolf(word)
        elif wordIs("~whiteList"):
            base.localAvatar.chatMgr.chatInputSpeedChat.addWhiteList()
        elif wordIs("~updateWhiteList"):
            self.notify.info("Updating WhiteList")
            base.whiteList.redownloadWhitelist()
        elif wordIs("~noWhiteList"):
            base.localAvatar.chatMgr.chatInputSpeedChat.removeWhiteList()
        elif wordIs("~setPaid"):
            args = word.split()
            if len(args) > 1:
                paid = int(args[1])
                statusString = base.config.GetString("force-paid-status", "none")
                if paid:
                    paid = 1
                    if statusString != "none":
                        if statusString == "VELVET":
                            ConfigVariableString("force-paid-status").setValue("FULL")
                        elif statusString == "unpaid":
                            ConfigVariableString("force-paid-status").setValue("paid")
                    base.cr.setIsPaid(1)
                else:
                    paid = 0
                    if statusString != "none":
                        if statusString == "FULL":
                            ConfigVariableString("force-paid-status").setValue("VELVET")
                        elif statusString == "paid":
                            ConfigVariableString("force-paid-status").setValue("unpaid")
                    base.cr.setIsPaid(0)
            else:
                return
        elif wordIs("~party"):
            self.doParty(word, avId, zoneId)
        elif wordIs("~news"):
            self.doNews(word, avId, zoneId)
        elif wordIs("~bgui"):
            if not hasattr(self, "groupPanel"):
                from toontown.toon import GroupPanel

                self.groupPanel = GroupPanel.GroupPanel(base.localAvatar.boardingParty)
                self.groupPanel.frame.show()
            else:
                self.groupPanel.frame.hide()
                self.groupPanel.cleanup()
                del self.groupPanel
        elif wordIs("~generateOrder"):
            args = word.split()
            if len(args) > 1:
                newOrder = int(args[1])
                if newOrder >= 0 and newOrder <= 2:
                    datagram = PyDatagram.PyDatagram()
                    datagram.addUint16(MsgName2Id["CLIENT_CHANGE_GENERATE_ORDER"])
                    datagram.addUint32(newOrder)
                    base.cr.send(datagram)
                    response = "changing generate order to %s" % newOrder
                    self.setMagicWordResponse(response)
            else:
                response = "args: 0 default, 1 reversed, 2 shuffled"
                self.setMagicWordResponse(response)
        elif wordIs("~ruler"):
            response = "Each unit is equal to one foot"
            self.setMagicWordResponse(response)
            if self.ruler:
                self.ruler.detachNode()
                del self.ruler
            self.ruler = loader.loadModel("phase_3/models/props/xyzAxis")
            self.ruler.reparentTo(render)
            self.ruler.setPos(base.localAvatar.getPos())
            self.ruler.place()
        elif wordIs("~toonIdTags"):
            otherToons = base.cr.doFindAllOfType("DistributedToon")
            if otherToons:
                for toon in otherToons[0]:
                    toon.setNametagStyle(0)

            messenger.send("nameTagShowAvId", [])
            base.idTags = 1
        elif wordIs("~code"):
            args = word.split()
            if len(args) > 1:
                code = word[len(args[0]) + 1 :]
                base.codeRedemptionMgr.redeemCode(code, self._handleCodeRedemptionResponse)
                response = "sending code %s to server..." % code
            else:
                response = "~code <code>"
            self.setMagicWordResponse(response)
        return
Exemple #5
0
    def doMagicWord(self, word, avId, zoneId):
        wordIs = Functor(self.wordIs, word)

        if (MagicWordManager.MagicWordManager.doMagicWord(
                self, word, avId, zoneId) == 1):
            pass
        elif wordIs("~fanfare"):
            go = Fanfare.makeFanfareWithMessageImage(
                0, base.localAvatar, 1,
                "You just did a ~fanfare.  Here's a rake.", Vec2(0, 0.2), 0.08,
                base.localAvatar.inventory.buttonLookup(1, 1), Vec3(0, 0,
                                                                    0), 4)
            Sequence(
                go[0], Func(go[1].show),
                LerpColorScaleInterval(go[1],
                                       duration=.5,
                                       startColorScale=Vec4(1, 1, 1, 0),
                                       colorScale=Vec4(1, 1, 1, 1)), Wait(2),
                LerpColorScaleInterval(go[1],
                                       duration=.5,
                                       startColorScale=Vec4(1, 1, 1, 1),
                                       colorScale=Vec4(1, 1, 1, 0)),
                Func(go[1].remove)).start()
            #go[0].start()
            #Fanfare.makeFanfareWithMessageImage(0, base.localAvatar, 1, "This is the message", Vec2(0,0.2), 0.08, base.localAvatar.inventory.buttonLookup(1, 1), Vec3(0,0,0), 4)[0].start()
            #Fanfare.makeFanfare(0, base.localAvatar).start()
        elif wordIs("~endgame"):
            print("Requesting minigame abort...")
            messenger.send("minigameAbort")
        elif wordIs("~wingame"):
            print("Requesting minigame victory...")
            messenger.send("minigameVictory")
        elif wordIs("~walk"):
            try:
                fsm = base.cr.playGame.getPlace().fsm
                fsm.forceTransition('walk')
            except:
                pass
        elif wordIs("~movie"):
            try:
                fsm = base.cr.playGame.getPlace().fsm
                fsm.forceTransition('movie')
            except:
                pass
        elif wordIs("~sit"):
            try:
                base.cr.playGame.getPlace().fsm.request('sit')
            except:
                pass
        elif wordIs("~rogues"):
            suitname = None
            if (len(word) > 7):
                suitname = word[7:].split(' ')[1]
            self.rogues = RoguesGallery.RoguesGallery(suitname)
            self.rogues.enter()
            if suitname != None:
                self.rogues.animate()
            self.acceptOnce('mouse1', self.exit_rogues)
            # no longer keep rogues obj around after creation, so we can make a different one

        elif wordIs("~showPaths"):
            for obj in list(self.cr.doId2do.values()):
                if isinstance(obj,
                              DistributedSuitPlanner.DistributedSuitPlanner):
                    obj.showPaths()
            place = base.cr.playGame.getPlace()
            if hasattr(place, "showPaths"):
                place.showPaths()

        elif wordIs("~hidePaths"):
            for obj in list(self.cr.doId2do.values()):
                if isinstance(obj,
                              DistributedSuitPlanner.DistributedSuitPlanner):
                    obj.hidePaths()
            place = base.cr.playGame.getPlace()
            if hasattr(place, "hidePaths"):
                place.hidePaths()
        elif wordIs("~raceForever"):
            base.raceForever = True
        elif wordIs("~listen"):
            base.localAvatar.garbleChat = 0

        elif wordIs("~nochat") or wordIs("~chat") or wordIs("~superchat"):
            base.localAvatar.garbleChat = 1

        elif wordIs("~exec"):
            # Enable execChat.
            ChatManager.ChatManager.execChat = 1

        elif wordIs("~photoshoot"):
            # Empty the world for screenshots of the localToon
            base.cr.playGame.hood.sky.hide()
            base.cr.playGame.getPlace().loader.geom.hide()
            base.win.setClearColor(VBase4(1, 1, 1, 1))
            base.localAvatar.stopLookAroundNow()
            base.localAvatar.stopBlink()
            base.localAvatar.setNameVisible(0)

        elif wordIs("~hideAttack"):
            # Hide the attack panel so we can see around it.
            TownBattleAttackPanel.hideAttackPanel(1)

        elif wordIs("~showAttack"):
            # Reveal the attack panel again.
            TownBattleAttackPanel.hideAttackPanel(0)

        elif wordIs("~collisions_on"):
            base.localAvatar.collisionsOn()

        elif wordIs("~collisions_off"):
            base.localAvatar.collisionsOff()

        elif wordIs('~battle_detect_off'):
            from toontown.suit import DistributedSuit
            DistributedSuit.ALLOW_BATTLE_DETECT = 0

        elif wordIs('~battle_detect_on'):
            from toontown.suit import DistributedSuit
            DistributedSuit.ALLOW_BATTLE_DETECT = 1

        elif wordIs('~battles'):
            base.localAvatar.setWantBattles(not base.localAvatar.wantBattles)
            if base.localAvatar.wantBattles:
                response = 'battles ON'
            else:
                response = 'battles OFF'
            self.setMagicWordResponse(response)

        elif wordIs('~skipBattleMovie') or wordIs('~sbm'):
            ToontownBattleGlobals.SkipMovie = not ToontownBattleGlobals.SkipMovie
            if ToontownBattleGlobals.SkipMovie:
                response = "battle movies will be skipped"
            else:
                response = "battle movies will be played"
            self.setMagicWordResponse(response)

        elif wordIs('~addCameraPosition'):
            base.localAvatar.addCameraPosition()

        elif wordIs('~removeCameraPosition'):
            base.localAvatar.removeCameraPosition()

        elif wordIs('~printCameraPosition'):
            base.localAvatar.printCameraPosition(base.localAvatar.cameraIndex)

        elif wordIs('~printCameraPositions'):
            base.localAvatar.printCameraPositions()

        elif wordIs('~worldCam') or wordIs('~wc'):
            #print the camera position and hpr in world coordinates
            myCam = render.find('**/camera')
            if not myCam.isEmpty():
                camParent = myCam.getParent()
                myCam.wrtReparentTo(render)
                pos = myCam.getPos()
                hpr = myCam.getHpr()
                response = "(%.2f, %.2f, %.2f,) (%.2f, %.2f, %.2f)" % (
                    pos[0], pos[1], pos[2], hpr[0], hpr[1], hpr[2])
                if not camParent.isEmpty():
                    myCam.wrtReparentTo(camParent)
                self.setMagicWordResponse(response)
                print(response)

        elif wordIs("~sync"):
            # Sync with the AI, like F6, but rather than accumulating
            # sync informatoin, throw away whatever information was
            # there from before.  If a second parameter is supplied,
            # it is a number of seconds of temporary extra skew to
            # apply; the default is 0.

            tm = base.cr.timeManager
            if tm == None:
                response = "No TimeManager."
                self.setMagicWordResponse(response)

            else:
                tm.extraSkew = 0.0
                skew = string.strip(word[5:])
                if skew != "":
                    tm.extraSkew = float(skew)
                globalClockDelta.clear()
                tm.handleHotkey()

        elif wordIs("~period"):
            # Reset the period timer to expire in the indicated number
            # of seconds, or with no parameter, report the number of
            # seconds remaining.

            timeout = string.strip(word[7:])
            if timeout != "":
                seconds = int(timeout)
                base.cr.stopPeriodTimer()
                base.cr.resetPeriodTimer(seconds)
                base.cr.startPeriodTimer()

            # Now report the number of seconds remaining.
            if base.cr.periodTimerExpired:
                response = "Period timer has expired."

            elif base.cr.periodTimerStarted:
                elapsed = globalClock.getFrameTime(
                ) - base.cr.periodTimerStarted
                secondsRemaining = base.cr.periodTimerSecondsRemaining - elapsed
                response = "Period timer expires in %s seconds." % (
                    int(secondsRemaining))
            else:
                response = "Period timer not set."

            self.setMagicWordResponse(response)

        elif wordIs("~net"):
            # Simulate pulling or restoring the network plug.
            if base.cr.networkPlugPulled():
                base.cr.restoreNetworkPlug()
                base.cr.startHeartbeat()
                response = "Network restored."
            else:
                base.cr.pullNetworkPlug()
                base.cr.stopHeartbeat()
                response = "Network disconnected."
            self.setMagicWordResponse(response)

        elif wordIs("~lag"):
            if not hasattr(base.cr, "magicLag"):
                base.cr.startDelay(0.1, 0.35)
                base.cr.magicLag = None
                response = "Simulated Lag On"
            else:
                base.cr.stopDelay()
                del base.cr.magicLag
                response = "Simulated Lag Off"
            self.setMagicWordResponse(response)

        elif wordIs("~cogPageFull"):
            # show all panels on cog page of Shticker book
            base.localAvatar.suitPage.updateAllCogs(3)

        elif wordIs('~mintId'):
            # the AI is going to listen for this also, but let's keep a local
            # copy
            args = word.split()
            postName = 'mintIdOverride'
            if len(args) < 2:
                if bboard.has(postName):
                    bboard.remove(postName)
            else:
                try:
                    id = int(args[1])
                    # make sure it's a valid id
                    foo = ToontownGlobals.MintNumRooms[id]
                except:
                    pass
                else:
                    bboard.post(postName, id)

        elif wordIs('~mintRoom'):
            # the AI is going to listen for this also, but let's keep a local
            # copy
            args = word.split()
            postName = 'mintRoom'
            if len(args) < 2:
                if bboard.has(postName):
                    bboard.remove(postName)
            else:
                try:
                    id = int(args[1])
                except:
                    pass
                else:
                    bboard.post(postName, id)

        elif wordIs('~mintWarp'):
            args = word.split()
            if len(args) < 2:
                self.setMagicWordResponse('Usage: ~mintWarp roomId')
                return
            try:
                roomNum = int(args[1])
            except:
                self.setMagicWordResponse('roomId not found: %s' % args[1])
                return
            if not bboard.has('mint'):
                self.setMagicWordResponse('not in a mint')
                return
            mint = bboard.get('mint')
            if not mint.warpToRoom(roomNum):
                self.setMagicWordResponse(
                    'invalid roomId or roomId not in this mint: %s' % args[1])
                return

        elif wordIs('~mintLayouts'):
            from toontown.coghq import MintLayout
            MintLayout.printAllCashbotInfo()
            self.setMagicWordResponse('logged mint layouts')

        elif wordIs("~edit"):
            if not __dev__:
                self.setMagicWordResponse("client not running in dev mode")
                return

            from otp.level import EditorGlobals
            # Is there a level that has made itself available for editing?
            level = bboard.get(EditorGlobals.EditTargetPostName)
            if level == None:
                self.setMagicWordResponse('no level available for editing')
                return

            from toontown.coghq import DistributedInGameEditor
            EditorGlobals.assertReadyToEdit()
            editUsername = EditorGlobals.getEditUsername()
            # make sure we're not already editing this level
            editors = base.cr.doFindAll('DistributedInGameEditor')
            for e in editors:
                if isinstance(e,
                              DistributedInGameEditor.DistributedInGameEditor):
                    if e.getLevelDoId() == level.doId:
                        if (e.editorIsLocalToon()
                                or e.getEditUsername() == editUsername):
                            self.setMagicWordResponse(
                                "you ('%s') are already editing this level" %
                                editUsername)
                            return
            cmd = "~inGameEdit %s %s" % (level.doId, editUsername)
            # Now send the real magic word with the doId etc. also
            self.b_setMagicWord(cmd)

        elif wordIs('~fshow'):
            from toontown.coghq import DistributedFactory
            factories = base.cr.doFindAll("DistributedFactory")
            factory = None
            for f in factories:
                if isinstance(f, DistributedFactory.DistributedFactory):
                    factory = f
                    break
            if factory is None:
                self.setMagicWordResponse('factory not found')
                return
            factory.setColorZones(not factory.fColorZones)

        elif wordIs('~fzone'):
            args = word.split()
            if len(args) < 2:
                self.setMagicWordResponse('Usage: ~fzone <zoneNum>')
                return
            zoneId = int(args[1])

            from toontown.coghq import DistributedFactory
            factories = base.cr.doFindAll("DistributedFactory")
            factory = None
            for f in factories:
                if isinstance(f, DistributedFactory.DistributedFactory):
                    factory = f
                    break
            if factory is None:
                self.setMagicWordResponse('factory not found')
                return
            factory.warpToZone(zoneId)

        elif wordIs("~undead"):
            # regenerate dead goons
            try:
                goons = base.cr.doFindAll("Goon")
                for goon in goons:
                    goon.undead()
            except:
                self.notify.warning("Error in undead")
        elif wordIs("~resyncGoons"):
            try:
                goons = base.cr.doFindAll("Goon")
                for goon in goons:
                    goon.resync()
            except:
                self.notify.warning("Error in resyncing")
        elif wordIs("~catalog"):
            self.doCatalog(word)

        elif wordIs('~petCam') and base.wantPets:
            if hasattr(base, 'petCamPrevParent'):
                base.cam.reparentTo(base.petCamPrevParent)
                del base.petCamPrevParent
            else:
                petId = base.localAvatar.getPetId()
                pet = self.cr.doId2do.get(petId)
                if pet:
                    if not hasattr(pet, 'camNode'):
                        pet.camNode = pet.attachNewNode('camNode')
                        pet.camNode.setPos(0, 0, 2.5)
                    base.petCamPrevParent = base.cam.getParent()
                    base.cam.reparentTo(pet.camNode)

        elif wordIs('~lockPet') and base.wantPets:
            petId = base.localAvatar.getPetId()
            pet = self.cr.doId2do.get(petId)
            if pet:
                if not pet.isLockedDown():
                    pet.lockPet()

        elif wordIs('~unlockPet') and base.wantPets:
            petId = base.localAvatar.getPetId()
            pet = self.cr.doId2do.get(petId)
            if pet:
                if pet.isLockedDown():
                    pet.unlockPet()

        elif wordIs('~resetPetTutorial') and base.wantPets:
            base.localAvatar.setPetTutorialDone(False)
            response = "Pet Tutorial flag reset"
            self.setMagicWordResponse(response)

        elif wordIs('~bossBattle'):
            self.doBossBattle(word)

        elif wordIs("~RaceChat"):
            #loadup chat phrases
            base.localAvatar.chatMgr.chatInputSpeedChat.addKartRacingMenu()
        elif wordIs('~BuyKart'):
            if base.wantKarts:

                def doShtikerLater(task):
                    base.localAvatar.addKartPage()
                    return 0

                if (base.localAvatar.hasKart()):
                    response = "Returning Kart %s" % (
                        base.localAvatar.getKartBodyType())
                    base.localAvatar.requestKartDNAFieldUpdate(
                        KartDNA.bodyType, InvalidEntry)
                    self.setMagicWordResponse(response)
                else:
                    base.localAvatar.requestKartDNAFieldUpdate(
                        KartDNA.rimsType, getDefaultRim())
                    taskMgr.doMethodLater(1.0, doShtikerLater,
                                          "doShtikerLater")

                # NOTE - BE SURE TO CHECK AI VERSION OF THIS AS IT SETS ACCESSSORIES OWNED FOR THE TOONAI.
                response = "Kart %s has been purchased with body and accessory color %s." % (
                    word[9], getDefaultColor())
                base.localAvatar.requestKartDNAFieldUpdate(
                    KartDNA.bodyType, int(word[9]))
                self.setMagicWordResponse(response)
            else:
                self.setMagicWordResponse("Enable wantKarts in Config.prc")
        elif wordIs('~leaveRace'):
            messenger.send('leaveRace')
        elif wordIs('~kartParticles'):
            b = ConfigVariableBool('want-kart-particles', 0)
            b.setValue(not b)
        elif wordIs('~gardenGame'):
            messenger.send("gardenGame")
            response = "You must be on your estate"
            self.setMagicWordResponse(response)

        elif wordIs("~verboseState"):
            # show all panels on cog page of Shticker book
            base.localAvatar.verboseState()

        elif wordIs('~golf'):
            self.doGolf(word)

        elif wordIs('~whiteList'):
            base.localAvatar.chatMgr.chatInputSpeedChat.addWhiteList()

        elif wordIs('~noWhiteList'):
            base.localAvatar.chatMgr.chatInputSpeedChat.removeWhiteList()

        elif wordIs("~setPaid"):
            args = word.split()
            if len(args) > 1:
                paid = int(args[1])
                statusString = base.config.GetString('force-paid-status',
                                                     'none')
                if paid:
                    paid = 1
                    if statusString != 'none':
                        if statusString == 'VELVET':
                            ConfigVariableString('force-paid-status').setValue(
                                "FULL")
                        elif statusString == 'unpaid':
                            ConfigVariableString('force-paid-status').setValue(
                                "paid")
                    base.cr.setIsPaid(1)
                else:
                    paid = 0
                    if statusString != 'none':
                        if statusString == 'FULL':
                            ConfigVariableString('force-paid-status').setValue(
                                "VELVET")
                        elif statusString == 'paid':
                            ConfigVariableString('force-paid-status').setValue(
                                "unpaid")
                    base.cr.setIsPaid(0)
            else:
                #self.setMagicWordResponse(senderId, "0 for unpaid 1 for paid")
                return

        # Parties
        elif wordIs("~party"):
            self.doParty(word, avId, zoneId)

        # In Game News
        elif wordIs("~news"):
            self.doNews(word, avId, zoneId)

        # Boarding Party GUI
        elif wordIs('~bgui'):
            if not hasattr(self, 'groupPanel'):
                from toontown.toon import GroupPanel
                self.groupPanel = GroupPanel.GroupPanel(
                    base.localAvatar.boardingParty)
                self.groupPanel.frame.show()
            else:
                self.groupPanel.frame.hide()
                self.groupPanel.cleanup()
                del self.groupPanel

        elif wordIs('~generateOrder'):
            args = word.split()
            if len(args) > 1:
                newOrder = int(args[1])
                if newOrder >= 0 and newOrder <= 2:
                    datagram = PyDatagram.PyDatagram()
                    datagram.addUint16(
                        MsgName2Id["CLIENT_CHANGE_GENERATE_ORDER"])
                    datagram.addUint32(newOrder)
                    base.cr.send(datagram)
                    response = "changing generate order to %s" % newOrder
                    self.setMagicWordResponse(response)
            else:
                response = "args: 0 default, 1 reversed, 2 shuffled"
                self.setMagicWordResponse(response)

        # Ruler
        elif wordIs('~ruler'):
            response = "Each unit is equal to one foot"
            self.setMagicWordResponse(response)
            if self.ruler:
                self.ruler.detachNode()
                del self.ruler

            self.ruler = loader.loadModel("phase_3/models/props/xyzAxis")
            self.ruler.reparentTo(render)
            self.ruler.setPos(base.localAvatar.getPos())
            self.ruler.place()

        elif wordIs("~toonIdTags"):
            otherToons = base.cr.doFindAllOfType('DistributedToon')
            if otherToons:
                for toon in otherToons[0]:
                    # this forces the nametag font to be the basic font that has numbers
                    toon.setNametagStyle(0)
            messenger.send('nameTagShowAvId', [])
            base.idTags = 1

        elif wordIs('~code'):
            # code redemption
            args = word.split()
            if len(args) > 1:
                code = word[len(args[0]) + 1:]
                base.codeRedemptionMgr.redeemCode(
                    code, self._handleCodeRedemptionResponse)
                response = 'sending code %s to server...' % code
            else:
                response = '~code <code>'
            self.setMagicWordResponse(response)