def placeOrder(self): if not self.cart: # TODO: Add error message here return # Create our order order = Order(self.store, self.customer, self.address) # Iterate over all the items in the cart and add them for item in self.cart: code = item[ITEM_CODE] order.add_item(code) # Make sure the order is valid, or else throw an exception result = order.validate() if not result: raise Exception("placeOrder - Invalid Order!") price = order.price() info = price['Order'] breakdown = info['AmountsBreakdown'] subtotal = breakdown['FoodAndBeverage'] total = breakdown['Customer'] if float(subtotal) < 10.0: raise Exception("placeOrder - Subtotal must be at least 10") result = order.place(self.card) print("Order placed with result: {}".format(result)) text = TTLocalizer.PizzaOrderPlaced.format(total) # TODO: this will not work in a non-ttoff source base.localAvatar.setSystemMessage( 0, text, whisperType=WhisperPopup.WTAnnouncement) fanfare = Sequence(Fanfare.makeFanfare(0, base.localAvatar)[0]) fanfare.start() self.exit()
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 getExpTrack(self, toon, origExp, earnedExp, deathList, origQuestsList, itemList, missedItemList, origMeritList, meritList, partList, toonList, uberEntry, helpfulToonsList, noSkip=False): self.notify.debug("getExpTrack() was called!") self.notify.debug("earnedExp = %s" % str(earnedExp)) self.notify.debug("meritList = %s" % str(meritList)) track = Sequence( Func(self.initGagFrame, toon, origExp, origMeritList, noSkip=noSkip), Wait(1.0)) endTracks = [0, 0, 0, 0, 0, 0, 0, 0] trackEnded = 0 self.notify.debug("Appending Track Interval Lists!") for trackIndex in range(len(earnedExp)): if earnedExp[trackIndex] > 0 or origExp[ trackIndex] >= ToontownBattleGlobals.MaxSkill: track += self.getTrackIntervalList( toon, trackIndex, origExp[trackIndex], earnedExp[trackIndex], ToontownBattleGlobals.getUberFlagSafe( uberEntry, trackIndex)) maxExp = ToontownBattleGlobals.MaxSkill - ToontownBattleGlobals.UberSkill if origExp[trackIndex] < maxExp and earnedExp[ trackIndex] + origExp[trackIndex] >= maxExp: endTracks[trackIndex] = 1 trackEnded = 1 self.notify.debug("Appending Merit Interval Lists!") for dept in range(len(SuitDNA.suitDepts)): if meritList[dept]: track += self.getMeritIntervalList(toon, dept, origMeritList[dept], meritList[dept]) track.append(Wait(0.75)) self.notify.debug("Appending Item Interval Lists!") itemInterval = self.getItemIntervalList(toon, itemList) if itemInterval: track.append(Func(self.initItemFrame, toon)) track.append(Wait(0.25)) track += itemInterval track.append(Wait(0.5)) self.notify.debug("Appending Missed Item Interval Lists!") missedItemInterval = self.getMissedItemIntervalList( toon, missedItemList) if missedItemInterval: track.append(Func(self.initMissedItemFrame, toon)) track.append(Wait(0.25)) track += missedItemInterval track.append(Wait(0.5)) self.notify.debug('partList = %s' % partList) newPart = 0 for part in partList: if part != 0: newPart = 1 break if newPart: partList = self.getCogPartIntervalList(toon, partList) if partList: track.append(Func(self.initCogPartFrame, toon)) track.append(Wait(0.25)) track += partList track.append(Wait(0.5)) questList = self.getQuestIntervalList(toon, deathList, toonList, origQuestsList, itemList, helpfulToonsList, earnedExp) if questList: avQuests = [] for i in xrange(0, len(origQuestsList), 5): avQuests.append(origQuestsList[i:i + 5]) track.append( Func(self.initQuestFrame, toon, copy.deepcopy(avQuests))) track.append(Wait(0.25)) track += questList track.append(Wait(0.5)) track.append(Wait(0.25)) if trackEnded: track.append(Func(self.vanishFrames)) track.append(Fanfare.makeFanfare(0, toon)[0]) for i in xrange(len(endTracks)): if endTracks[i] is 1: track += self.getEndTrackIntervalList(toon, toonList, i) track.append(Func(self.cleanupEndTrack)) return track
def doMagicWord(self, word, avId, zoneId): wordIs = Functor(self.wordIs, word) if MagicWordManager.MagicWordManager.doMagicWord(self, word, avId, zoneId) == 1: pass 1 if wordIs('~fanfare'): go = Fanfare.makeFanfareWithMessageImage(0, base.localAvatar, 1, "You just did a ~fanfare. Here's a rake.", Vec2(0, 0.20000000000000001), 0.080000000000000002, 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') elif wordIs('~movie'): try: fsm = base.cr.playGame.getPlace().fsm fsm.forceTransition('movie') elif wordIs('~sit'): try: base.cr.playGame.getPlace().fsm.request('sit') 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() continue 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() continue 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') and 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'): DistributedSuit = DistributedSuit import toontown.suit DistributedSuit.ALLOW_BATTLE_DETECT = 0 elif wordIs('~battle_detect_on'): DistributedSuit = DistributedSuit import toontown.suit 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.10000000000000001, 0.34999999999999998) 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 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 bboard.post(postName, id) elif wordIs('~mintWarp'): args = word.split() if len(args) < 2: self.setMagicWordResponse('Usage: ~mintWarp roomId') return None try: roomNum = int(args[1]) except: self.setMagicWordResponse('roomId not found: %s' % args[1]) return None if not bboard.has('mint'): self.setMagicWordResponse('not in a mint') return None mint = bboard.get('mint') if not mint.warpToRoom(roomNum): self.setMagicWordResponse('invalid roomId or roomId not in this mint: %s' % args[1]) return None elif wordIs('~mintLayouts'): MintLayout = MintLayout import toontown.coghq MintLayout.printAllCashbotInfo() self.setMagicWordResponse('logged mint layouts') elif wordIs('~edit'): if not __dev__: self.setMagicWordResponse('client not running in dev mode') return None EditorGlobals = EditorGlobals import otp.level level = bboard.get(EditorGlobals.EditTargetPostName) if level == None: self.setMagicWordResponse('no level available for editing') return None DistributedInGameEditor = DistributedInGameEditor import toontown.coghq 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 None e.getLevelDoId() == level.doId cmd = '~inGameEdit %s %s' % (level.doId, editUsername) self.b_setMagicWord(cmd) elif wordIs('~fshow'): DistributedFactory = DistributedFactory import toontown.coghq factories = base.cr.doFindAll('DistributedFactory') factory = None for f in factories: if isinstance(f, DistributedFactory.DistributedFactory): factory = f break continue if factory is None: self.setMagicWordResponse('factory not found') return None factory.setColorZones(not (factory.fColorZones)) elif wordIs('~fzone'): args = word.split() if len(args) < 2: self.setMagicWordResponse('Usage: ~fzone <zoneNum>') return None zoneId = int(args[1]) DistributedFactory = DistributedFactory import toontown.coghq factories = base.cr.doFindAll('DistributedFactory') factory = None for f in factories: if isinstance(f, DistributedFactory.DistributedFactory): factory = f break continue if factory is None: self.setMagicWordResponse('factory not found') return None factory.warpToZone(zoneId) elif wordIs('~undead'): try: goons = base.cr.doFindAll('Goon') for goon in goons: goon.undead() self.notify.warning('Error in undead') elif wordIs('~resyncGoons'): try: goons = base.cr.doFindAll('Goon') for goon in goons: goon.resync() 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 None elif wordIs('~party'): self.doParty(word, avId, zoneId) elif wordIs('~news'): self.doNews(word, avId, zoneId) elif wordIs('~bgui'): if not hasattr(self, 'groupPanel'): GroupPanel = GroupPanel import toontown.toon 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)
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
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)