diff --git a/otp/distributed/OTPInternalRepository.py b/otp/distributed/OTPInternalRepository.py index 7be3a75..1f1b574 100644 --- a/otp/distributed/OTPInternalRepository.py +++ b/otp/distributed/OTPInternalRepository.py @@ -18,3 +18,7 @@ class OTPInternalRepository(AstronInternalRepository): def getAvatarIdFromSender(self): return self.getMsgSender() & 0xFFFFFFFF + + def sendSetZone(self, distObj, zoneId): + distObj.setLocation(distObj.parentId, zoneId) + self.sendSetLocation(distObj, distObj.parentId, zoneId) diff --git a/toontown/ai/ToontownAIRepository.py b/toontown/ai/ToontownAIRepository.py index 16fe33c..a1e7b31 100644 --- a/toontown/ai/ToontownAIRepository.py +++ b/toontown/ai/ToontownAIRepository.py @@ -1,3 +1,4 @@ +from libtoontown import * from direct.directnotify import DirectNotifyGlobal from otp.ai.AIZoneData import AIZoneDataStore from otp.distributed.OtpDoGlobals import * @@ -6,8 +7,14 @@ from toontown.distributed.ToontownDistrictAI import ToontownDistrictAI from toontown.distributed.ToontownDistrictStatsAI import ToontownDistrictStatsAI from toontown.ai.HolidayManagerAI import HolidayManagerAI from toontown.ai.NewsManagerAI import NewsManagerAI +from toontown.building.DistributedTrophyMgrAI import DistributedTrophyMgrAI from toontown.catalog.CatalogManagerAI import CatalogManagerAI +from toontown.hood.TTHoodDataAI import TTHoodDataAI +from toontown.hood import ZoneUtil +from toontown.pets.PetManagerAI import PetManagerAI +from toontown.suit.SuitInvasionManagerAI import SuitInvasionManagerAI from toontown.uberdog.DistributedInGameNewsMgrAI import DistributedInGameNewsMgrAI +from toontown.toonbase import ToontownGlobals class ToontownAIRepository(ToontownInternalRepository): notify = DirectNotifyGlobal.directNotify.newCategory('ToontownAIRepository') @@ -16,14 +23,24 @@ class ToontownAIRepository(ToontownInternalRepository): ToontownInternalRepository.__init__(self, baseChannel, serverId, dcSuffix='AI') self.districtName = districtName self.doLiveUpdates = config.GetBool('want-live-updates', True) + self.wantCogdominiums = config.GetBool('want-cogdominiums', True) self.districtId = None self.district = None self.districtStats = None self.holidayManager = None self.zoneDataStore = None + self.petMgr = None + self.suitInvasionManager = None self.newsManager = None self.inGameNewsMgr = None self.catalogManager = None + self.trophyMgr = None + self.zoneTable = {} + self.dnaStoreMap = {} + self.dnaDataMap = {} + self.hoods = [] + self.buildingManagers = {} + self.suitPlanners = {} def handleConnected(self): ToontownInternalRepository.handleConnected(self) @@ -43,6 +60,9 @@ class ToontownAIRepository(ToontownInternalRepository): # Create our global objects. self.createGlobals() + # Create our zones. + self.createZones() + # Make our district available, and we're done. self.district.b_setAvailable(True) self.notify.info('Done.') @@ -58,6 +78,12 @@ class ToontownAIRepository(ToontownInternalRepository): # Create our zone data store... self.zoneDataStore = AIZoneDataStore() + # Create our pet manager... + self.petMgr = PetManagerAI(self) + + # Create our suit invasion manager... + self.suitInvasionManager = SuitInvasionManagerAI(self) + def createGlobals(self): """ Creates "global" (distributed) objects. @@ -81,6 +107,53 @@ class ToontownAIRepository(ToontownInternalRepository): self.catalogManager = CatalogManagerAI(self) self.catalogManager.generateWithRequired(OTP_ZONE_ID_MANAGEMENT) + # Generate our trophy manager... + self.trophyMgr = DistributedTrophyMgrAI(self) + self.trophyMgr.generateWithRequired(OTP_ZONE_ID_MANAGEMENT) + + def generateHood(self, hoodConstructor, zoneId): + # Bossbot HQ doesn't use DNA, so we skip over that. + if zoneId != ToontownGlobals.BossbotHQ: + self.dnaStoreMap[zoneId] = DNAStorage() + self.dnaDataMap[zoneId] = loadDNAFileAI(self.dnaStoreMap[zoneId], self.genDNAFileName(zoneId)) + if zoneId in ToontownGlobals.HoodHierarchy: + for streetId in ToontownGlobals.HoodHierarchy[zoneId]: + self.dnaStoreMap[streetId] = DNAStorage() + self.dnaDataMap[streetId] = loadDNAFileAI(self.dnaStoreMap[streetId], self.genDNAFileName(streetId)) + + hood = hoodConstructor(self, zoneId) + hood.startup() + self.hoods.append(hood) + + def createZones(self): + # Toontown Central + self.zoneTable[ToontownGlobals.ToontownCentral] = ( + (ToontownGlobals.ToontownCentral, 1, 0), (ToontownGlobals.SillyStreet, 1, 1), + (ToontownGlobals.LoopyLane, 1, 1), (ToontownGlobals.PunchlinePlace, 1, 1) + ) + self.generateHood(TTHoodDataAI, ToontownGlobals.ToontownCentral) + + def genDNAFileName(self, zoneId): + canonicalZoneId = ZoneUtil.getCanonicalZoneId(zoneId) + canonicalHoodId = ZoneUtil.getCanonicalHoodId(canonicalZoneId) + hood = ToontownGlobals.dnaMap[canonicalHoodId] + if canonicalHoodId == canonicalZoneId: + canonicalZoneId = 'sz' + phase = ToontownGlobals.phaseMap[canonicalHoodId] + else: + phase = ToontownGlobals.streetPhaseMap[canonicalHoodId] + + return 'phase_%s/dna/%s_%s.dna' % (phase, hood, canonicalZoneId) + + def loadDNAFileAI(self, dnaStore, dnaFileName): + return loadDNAFileAI(dnaStore, dnaFileName) + + def findFishingPonds(self, dnaData, zoneId, area): + return [], [] # TODO + + def findPartyHats(self, dnaData, zoneId): + return [] # TODO + def getTrackClsends(self): return False diff --git a/toontown/building/DistributedTrophyMgrAI.py b/toontown/building/DistributedTrophyMgrAI.py index c862c6e..8849410 100644 --- a/toontown/building/DistributedTrophyMgrAI.py +++ b/toontown/building/DistributedTrophyMgrAI.py @@ -3,3 +3,12 @@ from direct.distributed.DistributedObjectAI import DistributedObjectAI class DistributedTrophyMgrAI(DistributedObjectAI): notify = DirectNotifyGlobal.directNotify.newCategory('DistributedTrophyMgrAI') + + def requestTrophyScore(self): + pass + + def getLeaderInfo(self): + return [], [], [] + + def addTrophy(self, *args, **kwargs): + pass diff --git a/toontown/char/Char.py b/toontown/char/Char.py index 03a9fca..b4a82f4 100644 --- a/toontown/char/Char.py +++ b/toontown/char/Char.py @@ -1,5 +1,6 @@ from otp.avatar import Avatar from pandac.PandaModules import * +from libotp import * from direct.task import Task import random from pandac.PandaModules import * diff --git a/toontown/classicchars/DistributedCCharBase.py b/toontown/classicchars/DistributedCCharBase.py index f5cdd12..d3732a1 100644 --- a/toontown/classicchars/DistributedCCharBase.py +++ b/toontown/classicchars/DistributedCCharBase.py @@ -1,4 +1,5 @@ from pandac.PandaModules import * +from libotp import * from direct.interval.IntervalGlobal import * from otp.avatar import Avatar from libotp import CFQuicktalker diff --git a/toontown/hood/HoodDataAI.py b/toontown/hood/HoodDataAI.py index b9c5ce7..e0fe744 100644 --- a/toontown/hood/HoodDataAI.py +++ b/toontown/hood/HoodDataAI.py @@ -5,6 +5,7 @@ from toontown.suit import DistributedSuitPlannerAI from toontown.safezone import ButterflyGlobals from toontown.safezone import DistributedButterflyAI from pandac.PandaModules import * +from libtoontown import * from toontown.toon import NPCToons class HoodDataAI: diff --git a/toontown/pets/PetManagerAI.py b/toontown/pets/PetManagerAI.py new file mode 100644 index 0000000..1cfa191 --- /dev/null +++ b/toontown/pets/PetManagerAI.py @@ -0,0 +1,10 @@ +from direct.directnotify import DirectNotifyGlobal + +class PetManagerAI: + notify = DirectNotifyGlobal.directNotify.newCategory('PetManagerAI') + + def __init__(self, air): + self.air = air + + def getAvailablePets(self, *args, **kwargs): + return [] diff --git a/toontown/suit/DistributedSuitAI.py b/toontown/suit/DistributedSuitAI.py index f9dc970..218288d 100644 --- a/toontown/suit/DistributedSuitAI.py +++ b/toontown/suit/DistributedSuitAI.py @@ -1,5 +1,6 @@ from otp.ai.AIBaseGlobal import * from pandac.PandaModules import * +from libtoontown import * from direct.distributed.ClockDelta import * from otp.avatar import DistributedAvatarAI import SuitTimings diff --git a/toontown/suit/DistributedSuitPlannerAI.py b/toontown/suit/DistributedSuitPlannerAI.py index ae6db8d..23b6fce 100644 --- a/toontown/suit/DistributedSuitPlannerAI.py +++ b/toontown/suit/DistributedSuitPlannerAI.py @@ -1,3 +1,4 @@ +from libtoontown import * from otp.ai.AIBaseGlobal import * from direct.distributed import DistributedObjectAI import SuitPlannerBase, DistributedSuitAI diff --git a/toontown/suit/SuitBase.py b/toontown/suit/SuitBase.py index f77f71a..7f78261 100644 --- a/toontown/suit/SuitBase.py +++ b/toontown/suit/SuitBase.py @@ -1,4 +1,5 @@ from pandac.PandaModules import * +from libtoontown import * from direct.distributed.ClockDelta import * import math import random diff --git a/toontown/suit/SuitInvasionManagerAI.py b/toontown/suit/SuitInvasionManagerAI.py new file mode 100644 index 0000000..bb1231c --- /dev/null +++ b/toontown/suit/SuitInvasionManagerAI.py @@ -0,0 +1,13 @@ +from direct.directnotify import DirectNotifyGlobal + +class SuitInvasionManagerAI: + notify = DirectNotifyGlobal.directNotify.newCategory('SuitInvasionManagerAI') + + def __init__(self, air): + self.air = air + + def getInvadingCog(self): + return None, 0 + + def getInvading(self): + return False diff --git a/toontown/suit/SuitPlannerBase.py b/toontown/suit/SuitPlannerBase.py index 3ab8008..ebaf252 100644 --- a/toontown/suit/SuitPlannerBase.py +++ b/toontown/suit/SuitPlannerBase.py @@ -1,4 +1,5 @@ from pandac.PandaModules import * +from libtoontown import * import random import string from direct.directnotify import DirectNotifyGlobal @@ -520,7 +521,7 @@ class SuitPlannerBase: self.setupDNA() def extractGroupName(self, groupFullName): - return string.split(groupFullName, ':', 1)[0] + return str(groupFullName).split(':', 1)[0] def initDNAInfo(self): numGraphs = self.dnaStore.discoverContinuity() diff --git a/toontown/toon/DistributedToonAI.py b/toontown/toon/DistributedToonAI.py index bf78bee..ac5877b 100644 --- a/toontown/toon/DistributedToonAI.py +++ b/toontown/toon/DistributedToonAI.py @@ -410,7 +410,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) diff --git a/toontown/toon/TTEmote.py b/toontown/toon/TTEmote.py index bd5f481..e077ccb 100644 --- a/toontown/toon/TTEmote.py +++ b/toontown/toon/TTEmote.py @@ -6,6 +6,7 @@ from otp.otpbase import OTPLocalizer import types from direct.showbase import PythonUtil from pandac.PandaModules import * +from libotp import * from otp.avatar import Emote from direct.directnotify import DirectNotifyGlobal EmoteSleepIndex = 4