diff --git a/toontown/ai/ToontownAIRepository.py b/toontown/ai/ToontownAIRepository.py index 3b0c060..08ee3ed 100644 --- a/toontown/ai/ToontownAIRepository.py +++ b/toontown/ai/ToontownAIRepository.py @@ -7,6 +7,7 @@ from otp.ai.TimeManagerAI import TimeManagerAI from otp.distributed.OtpDoGlobals import * from toontown.ai.HolidayManagerAI import HolidayManagerAI from toontown.ai.NewsManagerAI import NewsManagerAI +from toontown.ai.WelcomeValleyManagerAI import WelcomeValleyManagerAI from toontown.building.DistributedTrophyMgrAI import DistributedTrophyMgrAI from toontown.catalog.CatalogManagerAI import CatalogManagerAI from toontown.coghq.PromotionManagerAI import PromotionManagerAI @@ -50,6 +51,7 @@ class ToontownAIRepository(ToontownInternalRepository): self.cogPageManager = None self.timeManager = None self.newsManager = None + self.welcomeValleyManager = None self.inGameNewsMgr = None self.catalogManager = None self.trophyMgr = None @@ -130,6 +132,10 @@ class ToontownAIRepository(ToontownInternalRepository): self.newsManager = NewsManagerAI(self) self.newsManager.generateWithRequired(OTP_ZONE_ID_MANAGEMENT) + # Generate our Welcome Valley manager... + self.welcomeValleyManager = WelcomeValleyManagerAI(self) + self.welcomeValleyManager.generateWithRequired(OTP_ZONE_ID_MANAGEMENT) + # Generate our in-game news manager... self.inGameNewsMgr = DistributedInGameNewsMgrAI(self) self.inGameNewsMgr.generateWithRequired(OTP_ZONE_ID_MANAGEMENT) @@ -208,6 +214,9 @@ class ToontownAIRepository(ToontownInternalRepository): ) self.generateHood(DLHoodDataAI, ToontownGlobals.DonaldsDreamland) + # Welcome Valley zones + self.welcomeValleyManager.createWelcomeValleyZones() + # Assign the initial suit buildings. for suitPlanner in self.suitPlanners.values(): suitPlanner.assignInitialSuitBuildings() diff --git a/toontown/ai/WelcomeValleyManagerAI.py b/toontown/ai/WelcomeValleyManagerAI.py index 557b4ce..6f2afa8 100644 --- a/toontown/ai/WelcomeValleyManagerAI.py +++ b/toontown/ai/WelcomeValleyManagerAI.py @@ -1,5 +1,41 @@ from direct.directnotify import DirectNotifyGlobal from direct.distributed.DistributedObjectAI import DistributedObjectAI +from toontown.hood import ZoneUtil +from toontown.hood.GSHoodDataAI import GSHoodDataAI +from toontown.hood.TTHoodDataAI import TTHoodDataAI +from toontown.toonbase import ToontownGlobals + + class WelcomeValleyManagerAI(DistributedObjectAI): notify = DirectNotifyGlobal.directNotify.newCategory('WelcomeValleyManagerAI') + + def requestZoneIdMessage(self, zoneId, context): + avId = self.air.getAvatarIdFromSender() + if zoneId == 0: + zoneId = ToontownGlobals.WelcomeValleyBegin + + self.toonSetZone(avId, zoneId) + self.sendUpdateToAvatarId(avId, 'requestZoneIdResponse', [zoneId, context]) + + def toonSetZone(self, doId, zoneId): + event = self.staticGetLogicalZoneChangeEvent(doId) + inWelcomeValley = self.isAccepting(event) + if not ZoneUtil.isDynamicZone(zoneId): + if ZoneUtil.isWelcomeValley(zoneId) and not inWelcomeValley: + self.air.districtStats.b_setNewAvatarCount(self.air.districtStats.getNewAvatarCount() + 1) + self.accept(event, lambda newZoneId, _: self.toonSetZone(doId, newZoneId)) + self.accept(self.air.getAvatarExitEvent(doId), self.toonSetZone, extraArgs=[doId, 123]) + elif (not ZoneUtil.isWelcomeValley(zoneId)) and inWelcomeValley: + self.air.districtStats.b_setNewAvatarCount(self.air.districtStats.getNewAvatarCount() - 1) + self.ignore(event) + self.ignore(self.air.getAvatarExitEvent(doId)) + + def createWelcomeValleyZones(self): + self.notify.info('Creating Welcome Valley zones...') + + # Toontown Central + self.air.generateHood(TTHoodDataAI, 22000) + + # Goofy Speedway + self.air.generateHood(GSHoodDataAI, 23000) diff --git a/toontown/hood/QuietZoneState.py b/toontown/hood/QuietZoneState.py index ef9ab71..34de2d4 100644 --- a/toontown/hood/QuietZoneState.py +++ b/toontown/hood/QuietZoneState.py @@ -165,16 +165,28 @@ class QuietZoneState(StateData.StateData): else: base.cr.handlePlayGame(msgType, di) - def handleWaitForZoneRedirect(self, msgType, di): - self.notify.debug('handleWaitForZoneRedirect(' + 'msgType=' + str(msgType) + ', di=' + str(di) + ')') - if msgType == CLIENT_CREATE_OBJECT_REQUIRED: - base.cr.handleQuietZoneGenerateWithRequired(di) - elif msgType == CLIENT_CREATE_OBJECT_REQUIRED_OTHER: - base.cr.handleQuietZoneGenerateWithRequiredOther(di) - elif msgType == CLIENT_OBJECT_UPDATE_FIELD: - base.cr.handleQuietZoneUpdateField(di) - else: - base.cr.handlePlayGame(msgType, di) + if not config.GetBool('astron-support', True): + def handleWaitForZoneRedirect(self, msgType, di): + self.notify.debug('handleWaitForZoneRedirect(' + 'msgType=' + str(msgType) + ', di=' + str(di) + ')') + if msgType == CLIENT_CREATE_OBJECT_REQUIRED: + base.cr.handleQuietZoneGenerateWithRequired(di) + elif msgType == CLIENT_CREATE_OBJECT_REQUIRED_OTHER: + base.cr.handleQuietZoneGenerateWithRequiredOther(di) + elif msgType == CLIENT_OBJECT_UPDATE_FIELD: + base.cr.handleQuietZoneUpdateField(di) + else: + base.cr.handlePlayGame(msgType, di) + else: + def handleWaitForZoneRedirect(self, msgType, di): + self.notify.debug('handleWaitForZoneRedirect(' + 'msgType=' + str(msgType) + ', di=' + str(di) + ')') + if msgType == CLIENT_ENTER_OBJECT_REQUIRED: + base.cr.handleQuietZoneGenerateWithRequired(di) + elif msgType == CLIENT_ENTER_OBJECT_REQUIRED_OTHER: + base.cr.handleQuietZoneGenerateWithRequiredOther(di) + elif msgType == CLIENT_OBJECT_SET_FIELD: + base.cr.handleQuietZoneUpdateField(di) + else: + base.cr.handlePlayGame(msgType, di) def enterOff(self): self.notify.debug('enterOff()') diff --git a/toontown/toon/DistributedToonAI.py b/toontown/toon/DistributedToonAI.py index d400d9d..9e99a6e 100644 --- a/toontown/toon/DistributedToonAI.py +++ b/toontown/toon/DistributedToonAI.py @@ -433,7 +433,7 @@ class DistributedToonAI(DistributedPlayerAI.DistributedPlayerAI, DistributedSmoo def announceZoneChange(self, newZoneId, oldZoneId): from toontown.pets import PetObserve - #self.air.welcomeValleyManager.toonSetZone(self.doId, newZoneId) + self.air.welcomeValleyManager.toonSetZone(self.doId, newZoneId) broadcastZones = [oldZoneId, newZoneId] if self.isInEstate() or self.wasInEstate(): broadcastZones = union(broadcastZones, self.estateZones)