def requestBattle(self, zoneId, suit, toonId):
        self.notify.debug('requestBattle() - zone: %s suit: %s toon: %s' % (zoneId, suit.doId, toonId))
        canonicalZoneId = ZoneUtil.getCanonicalZoneId(zoneId)
        if canonicalZoneId not in self.battlePosDict:
            return 0
        toon = self.air.doId2do.get(toonId)
        if toon.getBattleId() > 0:
            self.notify.warning('We tried to request a battle when the toon was already in battle')
            return 0
        if toon:
            if hasattr(toon, 'doId'):
                toon.b_setBattleId(toonId)

        pos = self.battlePosDict[canonicalZoneId]

        interactivePropTrackBonus = -1
        if config.GetBool('props-buff-battles', True) and canonicalZoneId in self.cellToGagBonusDict:
            interactivePropTrackBonus = self.cellToGagBonusDict[canonicalZoneId]

        self.battleMgr.newBattle(
            zoneId, zoneId, pos, suit, toonId, self.__battleFinished,
            self.SuitHoodInfo[self.hoodInfoIdx][self.SUIT_HOOD_INFO_SMAX],
            interactivePropTrackBonus)
        for currOther in self.zoneInfo[zoneId]:
            self.notify.debug('Found suit %s in this new battle zone %s' % (currOther.getDoId(), zoneId))
            if currOther != suit:
                if currOther.pathState == 1 and currOther.legType == SuitLeg.TWalk:
                    self.checkForBattle(zoneId, currOther)
        return 1
 def createStartingBlocks(self):
     self.racingPads = []
     self.viewingPads = []
     racingPadGroups = []
     viewingPadGroups = []
     for zoneId in self.getZoneTable():
         dnaData = self.air.dnaDataMap.get(zoneId, None)
         if dnaData.getName() == 'root':
             area = ZoneUtil.getCanonicalZoneId(zoneId)
             (foundRacingPads, foundRacingPadGroups) = self.findRacingPads(dnaData, zoneId, area, padType='racing_pad')
             (foundViewingPads, foundViewingPadGroups) = self.findRacingPads(dnaData, zoneId, area, padType='viewing_pad')
             self.racingPads.extend(foundRacingPads)
             racingPadGroups.extend(foundRacingPadGroups)
             self.viewingPads.extend(foundViewingPads)
             viewingPadGroups.extend(foundViewingPadGroups)
     self.startingBlocks = []
     for (dnaGroup, racePad) in zip(racingPadGroups, self.racingPads):
         foundStartingBlocks = self.findStartingBlocks(dnaGroup, racePad)
         self.startingBlocks.extend(foundStartingBlocks)
         for startingBlock in foundStartingBlocks:
             racePad.addStartingBlock(startingBlock)
     self.viewingBlocks = []
     for (dnaGroup, viewPad) in zip(viewingPadGroups, self.viewingPads):
         foundViewingBlocks = self.findStartingBlocks(dnaGroup, viewPad)
         self.viewingBlocks.extend(foundViewingBlocks)
         for viewingBlock in foundViewingBlocks:
             viewPad.addStartingBlock(viewingBlock)
Example #3
0
 def setZoneIdAndBlock(self, zoneId, block):
     self.zoneId = zoneId
     self.block = block
     canonicalZoneId = ZoneUtil.getCanonicalZoneId(zoneId)
     if canonicalZoneId in (ToontownGlobals.BossbotHQ,
                            ToontownGlobals.BossbotLobby):
         self.doorX = 1.0
 def enterToon(self):
     self.d_setState('toon')
     (exteriorZoneId, interiorZoneId) = self.getExteriorAndInteriorZoneId()
     if simbase.config.GetBool(
             'want-new-toonhall',
             1) and ZoneUtil.getCanonicalZoneId(interiorZoneId) == ToonHall:
         self.interior = DistributedToonHallInteriorAI.DistributedToonHallInteriorAI(
             self.block, self.air, interiorZoneId, self)
     else:
         self.interior = DistributedToonInteriorAI.DistributedToonInteriorAI(
             self.block, self.air, interiorZoneId, self)
     self.interior.generateWithRequired(interiorZoneId)
     door = self.createExteriorDoor()
     insideDoor = DistributedDoorAI.DistributedDoorAI(
         self.air, self.block, DoorTypes.INT_STANDARD)
     door.setOtherDoor(insideDoor)
     insideDoor.setOtherDoor(door)
     door.zoneId = exteriorZoneId
     insideDoor.zoneId = interiorZoneId
     door.generateWithRequired(exteriorZoneId)
     insideDoor.generateWithRequired(interiorZoneId)
     self.door = door
     self.insideDoor = insideDoor
     self.becameSuitTime = 0
     self.knockKnock = DistributedKnockKnockDoorAI.DistributedKnockKnockDoorAI(
         self.air, self.block)
     self.knockKnock.generateWithRequired(exteriorZoneId)
     self.air.writeServerEvent('building-toon', self.doId,
                               '%s|%s' % (self.zoneId, self.block))
Example #5
0
 def createStartingBlocks(self):
     self.racingPads = []
     self.viewingPads = []
     racingPadGroups = []
     viewingPadGroups = []
     for zoneId in self.getZoneTable():
         dnaData = self.air.dnaDataMap.get(zoneId, None)
         if dnaData.getName() == 'root':
             area = ZoneUtil.getCanonicalZoneId(zoneId)
             (foundRacingPads, foundRacingPadGroups) = self.findRacingPads(
                 dnaData, zoneId, area, padType='racing_pad')
             (foundViewingPads,
              foundViewingPadGroups) = self.findRacingPads(
                  dnaData, zoneId, area, padType='viewing_pad')
             self.racingPads.extend(foundRacingPads)
             racingPadGroups.extend(foundRacingPadGroups)
             self.viewingPads.extend(foundViewingPads)
             viewingPadGroups.extend(foundViewingPadGroups)
     self.startingBlocks = []
     for (dnaGroup, racePad) in zip(racingPadGroups, self.racingPads):
         foundStartingBlocks = self.findStartingBlocks(dnaGroup, racePad)
         self.startingBlocks.extend(foundStartingBlocks)
         for startingBlock in foundStartingBlocks:
             racePad.addStartingBlock(startingBlock)
     self.viewingBlocks = []
     for (dnaGroup, viewPad) in zip(viewingPadGroups, self.viewingPads):
         foundViewingBlocks = self.findStartingBlocks(dnaGroup, viewPad)
         self.viewingBlocks.extend(foundViewingBlocks)
         for viewingBlock in foundViewingBlocks:
             viewPad.addStartingBlock(viewingBlock)
Example #6
0
    def requestBattle(self, zoneId, suit, toonId):
        self.notify.debug('requestBattle() - zone: %s suit: %s toon: %s' %
                          (zoneId, suit.doId, toonId))
        canonicalZoneId = ZoneUtil.getCanonicalZoneId(zoneId)
        if canonicalZoneId not in self.battlePosDict:
            return 0
        toon = self.air.doId2do.get(toonId)
        if toon.getBattleId() > 0:
            self.notify.warning(
                'We tried to request a battle when the toon was already in battle'
            )
            return 0
        if toon:
            if hasattr(toon, 'doId'):
                toon.b_setBattleId(toonId)

        pos = self.battlePosDict[canonicalZoneId]

        interactivePropTrackBonus = -1
        if config.GetBool('props-buff-battles',
                          True) and canonicalZoneId in self.cellToGagBonusDict:
            interactivePropTrackBonus = self.cellToGagBonusDict[
                canonicalZoneId]

        self.battleMgr.newBattle(
            zoneId, zoneId, pos, suit, toonId, self.__battleFinished,
            self.SuitHoodInfo[self.hoodInfoIdx][self.SUIT_HOOD_INFO_SMAX],
            interactivePropTrackBonus)
        for currOther in self.zoneInfo[zoneId]:
            self.notify.debug('Found suit %s in this new battle zone %s' %
                              (currOther.getDoId(), zoneId))
            if currOther != suit:
                if currOther.pathState == 1 and currOther.legType == SuitLeg.TWalk:
                    self.checkForBattle(zoneId, currOther)
        return 1
Example #7
0
 def __init__(self, air, zoneId):
     DistributedObjectAI.DistributedObjectAI.__init__(self, air)
     SuitPlannerBase.SuitPlannerBase.__init__(self)
     self.air = air
     self.zoneId = zoneId
     self.canonicalZoneId = ZoneUtil.getCanonicalZoneId(zoneId)
     if simbase.air.wantCogdominiums:
         if not hasattr(self.__class__, 'CogdoPopAdjusted'):
             self.__class__.CogdoPopAdjusted = True
             for index in xrange(len(self.SuitHoodInfo)):
                 SuitBuildingGlobals.buildingMinMax[self.zoneId][0] = int(
                     0.5 + self.CogdoPopFactor *
                     SuitBuildingGlobals.buildingMinMax[self.zoneId][0])
                 SuitBuildingGlobals.buildingMinMax[self.zoneId][1] = int(
                     0.5 + self.CogdoPopFactor *
                     SuitBuildingGlobals.buildingMinMax[self.zoneId][1])
     self.hoodInfoIdx = -1
     for index in xrange(len(self.SuitHoodInfo)):
         currHoodInfo = self.SuitHoodInfo[index]
         if currHoodInfo[self.SUIT_HOOD_INFO_ZONE] == self.canonicalZoneId:
             self.hoodInfoIdx = index
     self.currDesired = None
     self.baseNumSuits = (
         self.SuitHoodInfo[self.hoodInfoIdx][self.SUIT_HOOD_INFO_MIN] +
         self.SuitHoodInfo[self.hoodInfoIdx][self.SUIT_HOOD_INFO_MAX]) / 2
     self.targetNumSuitBuildings = SuitBuildingGlobals.buildingMinMax[
         self.zoneId][0]
     self.pendingBuildingTracks = []
     self.pendingBuildingHeights = []
     self.suitList = []
     self.numFlyInSuits = 0
     self.numBuildingSuits = 0
     self.numAttemptingTakeover = 0
     self.zoneInfo = {}
     self.zoneIdToPointMap = None
     self.cogHQDoors = []
     self.battleList = []
     self.battleMgr = BattleManagerAI.BattleManagerAI(self.air)
     self.setupDNA()
     if self.notify.getDebug():
         self.notify.debug('Creating a building manager AI in zone' +
                           str(self.zoneId))
     self.buildingMgr = self.air.buildingManagers.get(self.zoneId)
     if self.buildingMgr:
         (blocks, hqBlocks, gagshopBlocks, petshopBlocks,
          kartshopBlocks) = self.buildingMgr.getDNABlockLists()
         for currBlock in blocks:
             bldg = self.buildingMgr.getBuilding(currBlock)
             bldg.setSuitPlannerExt(self)
     self.dnaStore.resetBlockNumbers()
     self.initBuildingsAndPoints()
     numSuits = simbase.config.GetInt('suit-count', -1)
     if numSuits >= 0:
         self.currDesired = numSuits
     suitHood = simbase.config.GetInt('suits-only-in-hood', -1)
     if suitHood >= 0:
         if self.SuitHoodInfo[self.hoodInfoIdx][
                 self.SUIT_HOOD_INFO_ZONE] != suitHood:
             self.currDesired = 0
     self.suitCountAdjust = 0
 def genDNAFileName(self):
     zoneId = ZoneUtil.getCanonicalZoneId(self.getZoneId())
     hoodId = ZoneUtil.getCanonicalHoodId(zoneId)
     hood = ToontownGlobals.dnaMap[hoodId]
     phase = ToontownGlobals.streetPhaseMap[hoodId]
     if hoodId == zoneId:
         zoneId = 'sz'
     return 'phase_%s/dna/%s_%s.pdna' % (phase, hood, zoneId)
 def __init__(self, air, branchId, dnaStore, trophyMgr):
     self.air = air
     self.branchId = branchId
     self.canonicalBranchId = ZoneUtil.getCanonicalZoneId(self.branchId)
     self.dnaStore = dnaStore
     self.trophyMgr = trophyMgr
     self.__buildings = {}
     self.findAllLandmarkBuildings()
 def __init__(self, air, branchId, dnaStore, trophyMgr):
     self.air = air
     self.branchId = branchId
     self.canonicalBranchId = ZoneUtil.getCanonicalZoneId(self.branchId)
     self.dnaStore = dnaStore
     self.trophyMgr = trophyMgr
     self.__buildings = {}
     self.findAllLandmarkBuildings()
 def genDNAFileName(self, zoneId):
     zoneId = ZoneUtil.getCanonicalZoneId(zoneId)
     hoodId = ZoneUtil.getCanonicalHoodId(zoneId)
     hood = ToontownGlobals.dnaMap[hoodId]
     phase = ToontownGlobals.streetPhaseMap[hoodId]
     if hoodId == zoneId:
         zoneId = 'sz'
     return 'phase_%s/dna/%s_%s.pdna' % (phase, hood, zoneId)
 def createGameTables(self):
     self.gameTables = []
     for zoneId in self.getZoneTable():
         dnaData = self.air.dnaDataMap.get(zoneId, None)
         if dnaData.getName() == 'root':
             area = ZoneUtil.getCanonicalZoneId(zoneId)
             foundGameTables = self.findGameTables(
                 dnaData, zoneId, area, overrideDNAZone=True)
             self.gameTables.extend(foundGameTables)
 def lookupDNAFileName(self, zoneId):
     zoneId = ZoneUtil.getCanonicalZoneId(zoneId)
     hoodId = ZoneUtil.getCanonicalHoodId(zoneId)
     hood = ToontownGlobals.dnaMap[hoodId]
     if hoodId == zoneId:
         zoneId = 'sz'
         phaseNum = ToontownGlobals.phaseMap[hoodId]
     else:
         phaseNum = ToontownGlobals.streetPhaseMap[hoodId]
     return 'phase_%s/dna/%s_%s.pdna' % (phaseNum, hood, zoneId)
Example #14
0
 def lookupDNAFileName(self, zoneId):
     zoneId = ZoneUtil.getCanonicalZoneId(zoneId)
     hoodId = ZoneUtil.getCanonicalHoodId(zoneId)
     hood = ToontownGlobals.dnaMap[hoodId]
     if hoodId == zoneId:
         zoneId = 'sz'
         phaseNum = ToontownGlobals.phaseMap[hoodId]
     else:
         phaseNum = ToontownGlobals.streetPhaseMap[hoodId]
     return 'phase_%s/dna/%s_%s.pdna' % (phaseNum, hood, zoneId)
 def handleWaitForSetZoneResponse(self, requestStatus):
     hoodId = requestStatus['hoodId']
     canonicalHoodId = ZoneUtil.getCanonicalZoneId(hoodId)
     toHoodPhrase = ToontownGlobals.hoodNameMap[canonicalHoodId][0]
     hoodName = ToontownGlobals.hoodNameMap[canonicalHoodId][-1]
     zoneId = requestStatus['zoneId']
     requestStatus['loader'] = 'cogHQLoader' if ZoneUtil.isCogHQZone(hoodId) else requestStatus['loader']
     loaderName = requestStatus['loader']
     avId = requestStatus.get('avId', -1)
     ownerId = requestStatus.get('ownerId', avId)
     if base.config.GetBool('want-qa-regression', 0):
         self.notify.info('QA-REGRESSION: NEIGHBORHOODS: Visit %s' % hoodName)
     count = ToontownGlobals.hoodCountMap[canonicalHoodId]
     if loaderName == 'safeZoneLoader':
         count += ToontownGlobals.safeZoneCountMap[canonicalHoodId]
     elif loaderName == 'townLoader':
         count += ToontownGlobals.townCountMap[canonicalHoodId]
     if not loader.inBulkBlock:
         if hoodId == ToontownGlobals.MyEstate:
             if avId == -1:
                 loader.beginBulkLoad('hood', TTLocalizer.HeadingToYourEstate, count, 1, TTLocalizer.TIP_ESTATE, zoneId)
             else:
                 owner = base.cr.identifyAvatar(ownerId)
                 if owner == None:
                     friend = base.cr.identifyAvatar(avId)
                     if friend != None:
                         avName = friend.getName()
                         loader.beginBulkLoad('hood', TTLocalizer.HeadingToFriend % avName, count, 1, TTLocalizer.TIP_ESTATE, zoneId)
                     else:
                         self.notify.warning("we can't perform this teleport")
                         return
                 else:
                     avName = owner.getName()
                     loader.beginBulkLoad('hood', TTLocalizer.HeadingToEstate % avName, count, 1, TTLocalizer.TIP_ESTATE, zoneId)
         elif ZoneUtil.isCogHQZone(zoneId):
             loader.beginBulkLoad('hood', TTLocalizer.HeadingToHood % {'to': toHoodPhrase,
              'hood': hoodName}, count, 1, TTLocalizer.TIP_COGHQ, zoneId)
         elif ZoneUtil.isGoofySpeedwayZone(zoneId):
             loader.beginBulkLoad('hood', TTLocalizer.HeadingToHood % {'to': toHoodPhrase,
              'hood': hoodName}, count, 1, TTLocalizer.TIP_KARTING, zoneId)
         else:
             loader.beginBulkLoad('hood', TTLocalizer.HeadingToHood % {'to': toHoodPhrase,
              'hood': hoodName}, count, 1, TTLocalizer.TIP_GENERAL, zoneId)
     if hoodId == ToontownGlobals.Tutorial:
         self.loadDnaStoreTutorial()
     else:
         if not hasattr(self, 'dnaStore'):
             self.loadDnaStore()
     hoodClass = self.getHoodClassByNumber(canonicalHoodId)
     self.hood = hoodClass(self.fsm, self.hoodDoneEvent, self.dnaStore, hoodId)
     self.hood.load()
     self.hood.loadLoader(requestStatus)
     if not base.placeBeforeObjects:
         loader.endBulkLoad('hood')
     return
Example #16
0
 def createGameTables(self):
     self.gameTables = []
     for zoneId in self.getZoneTable():
         dnaData = self.air.dnaDataMap.get(zoneId, None)
         if dnaData.getName() == 'root':
             area = ZoneUtil.getCanonicalZoneId(zoneId)
             foundGameTables = self.findGameTables(dnaData,
                                                   zoneId,
                                                   area,
                                                   overrideDNAZone=True)
             self.gameTables.extend(foundGameTables)
 def __init__(self, air, zoneId):
     DistributedObjectAI.DistributedObjectAI.__init__(self, air)
     SuitPlannerBase.SuitPlannerBase.__init__(self)
     self.air = air
     self.zoneId = zoneId
     self.canonicalZoneId = ZoneUtil.getCanonicalZoneId(zoneId)
     if simbase.air.wantCogdominiums:
         if not hasattr(self.__class__, 'CogdoPopAdjusted'):
             self.__class__.CogdoPopAdjusted = True
             for index in xrange(len(self.SuitHoodInfo)):
                 SuitBuildingGlobals.buildingMinMax[self.zoneId][0] = int(0.5 + self.CogdoPopFactor * SuitBuildingGlobals.buildingMinMax[self.zoneId][0])
                 SuitBuildingGlobals.buildingMinMax[self.zoneId][1] = int(0.5 + self.CogdoPopFactor * SuitBuildingGlobals.buildingMinMax[self.zoneId][1])
     self.hoodInfoIdx = -1
     for index in xrange(len(self.SuitHoodInfo)):
         currHoodInfo = self.SuitHoodInfo[index]
         if currHoodInfo[self.SUIT_HOOD_INFO_ZONE] == self.canonicalZoneId:
             self.hoodInfoIdx = index
     self.currDesired = None
     self.baseNumSuits = (
         self.SuitHoodInfo[self.hoodInfoIdx][self.SUIT_HOOD_INFO_MIN] +
         self.SuitHoodInfo[self.hoodInfoIdx][self.SUIT_HOOD_INFO_MAX]) / 2
     self.targetNumSuitBuildings = SuitBuildingGlobals.buildingMinMax[self.zoneId][0]
     self.pendingBuildingTracks = []
     self.pendingBuildingHeights = []
     self.suitList = []
     self.numFlyInSuits = 0
     self.numBuildingSuits = 0
     self.numAttemptingTakeover = 0
     self.zoneInfo = {}
     self.zoneIdToPointMap = None
     self.cogHQDoors = []
     self.battleList = []
     self.battleMgr = BattleManagerAI.BattleManagerAI(self.air)
     self.setupDNA()
     if self.notify.getDebug():
         self.notify.debug('Creating a building manager AI in zone' + str(self.zoneId))
     self.buildingMgr = self.air.buildingManagers.get(self.zoneId)
     if self.buildingMgr:
         (blocks, hqBlocks, gagshopBlocks, petshopBlocks, kartshopBlocks) = self.buildingMgr.getDNABlockLists()
         for currBlock in blocks:
             bldg = self.buildingMgr.getBuilding(currBlock)
             bldg.setSuitPlannerExt(self)
     self.dnaStore.resetBlockNumbers()
     self.initBuildingsAndPoints()
     numSuits = simbase.config.GetInt('suit-count', -1)
     if numSuits >= 0:
         self.currDesired = numSuits
     suitHood = simbase.config.GetInt('suits-only-in-hood', -1)
     if suitHood >= 0:
         if self.SuitHoodInfo[self.hoodInfoIdx][self.SUIT_HOOD_INFO_ZONE] != suitHood:
             self.currDesired = 0
     self.suitCountAdjust = 0
 def __init__(self, air, blockNumber, zoneId, trophyMgr):
     DistributedObjectAI.DistributedObjectAI.__init__(self, air)
     self.block = blockNumber
     self.zoneId = zoneId
     self.canonicalZoneId = ZoneUtil.getCanonicalZoneId(zoneId)
     self.trophyMgr = trophyMgr
     self.victorResponses = None
     self.fsm = ClassicFSM.ClassicFSM('DistributedBuildingAI', [
         State.State('off', self.enterOff, self.exitOff, [
             'waitForVictors', 'becomingToon', 'toon',
             'clearOutToonInterior', 'becomingSuit', 'suit',
             'clearOutToonInteriorForCogdo', 'becomingCogdo', 'cogdo'
         ]),
         State.State('waitForVictors', self.enterWaitForVictors,
                     self.exitWaitForVictors, ['becomingToon']),
         State.State(
             'waitForVictorsFromCogdo', self.enterWaitForVictorsFromCogdo,
             self.exitWaitForVictorsFromCogdo, ['becomingToonFromCogdo']),
         State.State('becomingToon', self.enterBecomingToon,
                     self.exitBecomingToon, ['toon']),
         State.State('becomingToonFromCogdo',
                     self.enterBecomingToonFromCogdo,
                     self.exitBecomingToonFromCogdo, ['toon']),
         State.State(
             'toon',
             self.enterToon, self.exitToon,
             ['clearOutToonInterior', 'clearOutToonInteriorForCogdo']),
         State.State('clearOutToonInterior', self.enterClearOutToonInterior,
                     self.exitClearOutToonInterior, ['becomingSuit']),
         State.State('becomingSuit', self.enterBecomingSuit,
                     self.exitBecomingSuit, ['suit']),
         State.State('suit', self.enterSuit, self.exitSuit,
                     ['waitForVictors', 'becomingToon']),
         State.State('clearOutToonInteriorForCogdo',
                     self.enterClearOutToonInteriorForCogdo,
                     self.exitClearOutToonInteriorForCogdo,
                     ['becomingCogdo']),
         State.State('becomingCogdo', self.enterBecomingCogdo,
                     self.exitBecomingCogdo, ['cogdo']),
         State.State('cogdo', self.enterCogdo, self.exitCogdo,
                     ['waitForVictorsFromCogdo', 'becomingToonFromCogdo'])
     ], 'off', 'off')
     self.fsm.enterInitialState()
     self.track = 'c'
     self.realTrack = 'c'
     self.difficulty = 1
     self.numFloors = 0
     self.savedBy = None
     self.becameSuitTime = 0
     self.frontDoorPoint = None
     self.suitPlannerExt = None
 def createFishingPonds(self):
     self.fishingPonds = []
     fishingPondGroups = []
     for zoneId in self.getZoneTable():
         dnaData = self.air.dnaDataMap.get(zoneId, None)
         if dnaData.getName() == 'root':
             area = ZoneUtil.getCanonicalZoneId(zoneId)
             (foundFishingPonds, foundFishingPondGroups) = self.findFishingPonds(dnaData, zoneId, area)
             self.fishingPonds.extend(foundFishingPonds)
             fishingPondGroups.extend(foundFishingPondGroups)
     for fishingPond in self.fishingPonds:
         NPCToons.createNpcsInZone(self.air, fishingPond.zoneId)
     fishingSpots = []
     for (dnaGroup, fishingPond) in zip(fishingPondGroups, self.fishingPonds):
         fishingSpots.extend(self.findFishingSpots(dnaGroup, fishingPond))
 def __init__(self, air, blockNumber, zoneId, trophyMgr):
     DistributedObjectAI.DistributedObjectAI.__init__(self, air)
     self.block = blockNumber
     self.zoneId = zoneId
     self.canonicalZoneId = ZoneUtil.getCanonicalZoneId(zoneId)
     self.trophyMgr = trophyMgr
     self.victorResponses = None
     self.fsm = ClassicFSM.ClassicFSM(
         'DistributedBuildingAI',
         [
             State.State('off', self.enterOff, self.exitOff,
                         ['waitForVictors', 'becomingToon', 'toon',
                          'clearOutToonInterior', 'becomingSuit', 'suit',
                          'clearOutToonInteriorForCogdo', 'becomingCogdo',
                          'cogdo']),
             State.State('waitForVictors', self.enterWaitForVictors, self.exitWaitForVictors,
                         ['becomingToon']),
             State.State('waitForVictorsFromCogdo', self.enterWaitForVictorsFromCogdo, self.exitWaitForVictorsFromCogdo,
                         ['becomingToonFromCogdo']),
             State.State('becomingToon', self.enterBecomingToon, self.exitBecomingToon,
                         ['toon']),
             State.State('becomingToonFromCogdo', self.enterBecomingToonFromCogdo, self.exitBecomingToonFromCogdo,
                         ['toon']),
             State.State('toon', self.enterToon, self.exitToon,
                         ['clearOutToonInterior', 'clearOutToonInteriorForCogdo']),
             State.State('clearOutToonInterior', self.enterClearOutToonInterior, self.exitClearOutToonInterior,
                         ['becomingSuit']),
             State.State('becomingSuit', self.enterBecomingSuit, self.exitBecomingSuit,
                         ['suit']),
             State.State('suit', self.enterSuit, self.exitSuit,
                         ['waitForVictors', 'becomingToon']),
             State.State('clearOutToonInteriorForCogdo', self.enterClearOutToonInteriorForCogdo, self.exitClearOutToonInteriorForCogdo,
                         ['becomingCogdo']),
             State.State('becomingCogdo', self.enterBecomingCogdo, self.exitBecomingCogdo,
                         ['cogdo']),
             State.State('cogdo', self.enterCogdo, self.exitCogdo,
                         ['waitForVictorsFromCogdo', 'becomingToonFromCogdo'])
         ], 'off', 'off')
     self.fsm.enterInitialState()
     self.track = 'c'
     self.realTrack = 'c'
     self.difficulty = 1
     self.numFloors = 0
     self.savedBy = None
     self.becameSuitTime = 0
     self.frontDoorPoint = None
     self.suitPlannerExt = None
Example #21
0
 def createFishingPonds(self):
     self.fishingPonds = []
     fishingPondGroups = []
     for zoneId in self.getZoneTable():
         dnaData = self.air.dnaDataMap.get(zoneId, None)
         if dnaData.getName() == 'root':
             area = ZoneUtil.getCanonicalZoneId(zoneId)
             (foundFishingPonds,
              foundFishingPondGroups) = self.findFishingPonds(
                  dnaData, zoneId, area)
             self.fishingPonds.extend(foundFishingPonds)
             fishingPondGroups.extend(foundFishingPondGroups)
     for fishingPond in self.fishingPonds:
         NPCToons.createNpcsInZone(self.air, fishingPond.zoneId)
     fishingSpots = []
     for (dnaGroup, fishingPond) in zip(fishingPondGroups,
                                        self.fishingPonds):
         fishingSpots.extend(self.findFishingSpots(dnaGroup, fishingPond))
    def moveToNextLeg(self, task):
        now = globalClock.getFrameTime()
        elapsed = now - self.pathStartTime
        nextLeg = self.legList.getLegIndexAtTime(elapsed, self.currentLeg)
        numLegs = self.legList.getNumLegs()
        if self.currentLeg != nextLeg:
            if nextLeg >= numLegs:
                self.flyAwayNow()
                return Task.done
            self.currentLeg = nextLeg
            self.__beginLegType(self.legList.getType(nextLeg))
            zoneId = self.legList.getZoneId(nextLeg)
            if zoneId:
                self.__enterZone(zoneId)
            self.notify.debug('Suit %s reached leg %s of %s in zone %s.' % (self.getDoId(),
             nextLeg,
             numLegs - 1,
             self.zoneId))
            if self.DEBUG_SUIT_POSITIONS:
                leg = self.legList.getLeg(nextLeg)
                pos = leg.getPosAtTime(elapsed - leg.getStartTime())
                self.d_debugSuitPosition(elapsed, nextLeg, pos[0], pos[1], now)
        if now - self.pathPositionTimestamp > self.UPDATE_TIMESTAMP_INTERVAL:
            self.resync()
        if self.pathState != 1:
            return Task.done
        nextLeg += 1
        while nextLeg + 1 < numLegs and self.legList.getZoneId(nextLeg) == ZoneUtil.getCanonicalZoneId(self.zoneId) and self.legList.getType(nextLeg) == self.legType:
            nextLeg += 1

        if nextLeg < numLegs:
            nextTime = self.legList.getStartTime(nextLeg)
            delay = nextTime - elapsed
            taskMgr.remove(self.taskName('move'))
            taskMgr.doMethodLater(delay, self.moveToNextLeg, self.taskName('move'))
        else:
            if simbase.config.GetBool('want-cogbuildings', True):
                self.startTakeOver()
            self.requestRemoval()
        return Task.done
 def enterToon(self):
     self.d_setState('toon')
     (exteriorZoneId, interiorZoneId) = self.getExteriorAndInteriorZoneId()
     if simbase.config.GetBool('want-new-toonhall', 1) and ZoneUtil.getCanonicalZoneId(interiorZoneId) == ToonHall:
         self.interior = DistributedToonHallInteriorAI.DistributedToonHallInteriorAI(self.block, self.air, interiorZoneId, self)
     else:
         self.interior = DistributedToonInteriorAI.DistributedToonInteriorAI(self.block, self.air, interiorZoneId, self)
     self.interior.generateWithRequired(interiorZoneId)
     door = self.createExteriorDoor()
     insideDoor = DistributedDoorAI.DistributedDoorAI(self.air, self.block, DoorTypes.INT_STANDARD)
     door.setOtherDoor(insideDoor)
     insideDoor.setOtherDoor(door)
     door.zoneId = exteriorZoneId
     insideDoor.zoneId = interiorZoneId
     door.generateWithRequired(exteriorZoneId)
     insideDoor.generateWithRequired(interiorZoneId)
     self.door = door
     self.insideDoor = insideDoor
     self.becameSuitTime = 0
     self.knockKnock = DistributedKnockKnockDoorAI.DistributedKnockKnockDoorAI(self.air, self.block)
     self.knockKnock.generateWithRequired(exteriorZoneId)
     self.air.writeServerEvent('building-toon', self.doId, '%s|%s' % (self.zoneId, self.block))
Example #24
0
 def enterTeleport(self, shardId, hoodId, zoneId):
     shardName = base.cr.getShardName(shardId)
     if shardName is None:
         shardName = 'unknown'
     hoodsVisited = base.localAvatar.hoodsVisited
     canonicalHoodId = ZoneUtil.getCanonicalZoneId(hoodId)
     if hoodId == ToontownGlobals.MyEstate:
         teleportNotify.debug('enterTeleport: estate')
         if shardId == base.localAvatar.defaultShard:
             shardId = None
         place = base.cr.playGame.getPlace()
         place.requestTeleport(hoodId, zoneId, shardId, self.avId)
         unloadTeleportPanel()
     elif canonicalHoodId not in hoodsVisited + ToontownGlobals.HoodsAlwaysVisited:
         teleportNotify.debug('enterTeleport: unknownHood')
         self.fsm.request('unknownHood', [hoodId])
     else:
         if shardId == base.localAvatar.defaultShard:
             shardId = None
         teleportNotify.debug('enterTeleport: requesting teleport')
         place = base.cr.playGame.getPlace()
         place.requestTeleport(hoodId, zoneId, shardId, self.avId)
         unloadTeleportPanel()
     return
 def setZoneIdAndBlock(self, zoneId, block):
     self.zoneId = zoneId
     self.block = block
     canonicalZoneId = ZoneUtil.getCanonicalZoneId(zoneId)
     if canonicalZoneId in (ToontownGlobals.BossbotHQ, ToontownGlobals.BossbotLobby):
         self.doorX = 1.0
Example #26
0
 def announceGenerate(self):
     canonicalZoneId = ZoneUtil.getCanonicalZoneId(self.zoneId)
     self.notify.debug('canonicalZoneId = %s' % canonicalZoneId)
     localAvatar.chatMgr.chatInputSpeedChat.addBoardingGroupMenu(
         canonicalZoneId)
 def announceGenerate(self):
     canonicalZoneId = ZoneUtil.getCanonicalZoneId(self.zoneId)
     self.notify.debug('canonicalZoneId = %s' % canonicalZoneId)
     localAvatar.chatMgr.chatInputSpeedChat.addBoardingGroupMenu(canonicalZoneId)
 def handleLeftQuietZone(self):
     status = self.quietZoneStateData.getRequestStatus()
     hoodId = ZoneUtil.getCanonicalZoneId(status['hoodId'])
     hoodState = self.getHoodStateByNumber(hoodId)
     self.fsm.request(hoodState, [status])
 def getFullnameFromId(self, hoodId):
     hoodId = ZoneUtil.getCanonicalZoneId(hoodId)
     return ToontownGlobals.hoodNameMap[hoodId][-1]
Example #30
0
 def getFullnameFromId(self, hoodId):
     hoodId = ZoneUtil.getCanonicalZoneId(hoodId)
     return ToontownGlobals.hoodNameMap[hoodId][-1]
Example #31
0
 def handleLeftQuietZone(self):
     status = self.quietZoneStateData.getRequestStatus()
     hoodId = ZoneUtil.getCanonicalZoneId(status['hoodId'])
     hoodState = self.getHoodStateByNumber(hoodId)
     self.fsm.request(hoodState, [status])
Example #32
0
 def handleWaitForSetZoneResponse(self, requestStatus):
     hoodId = requestStatus['hoodId']
     canonicalHoodId = ZoneUtil.getCanonicalZoneId(hoodId)
     toHoodPhrase = ToontownGlobals.hoodNameMap[canonicalHoodId][0]
     hoodName = ToontownGlobals.hoodNameMap[canonicalHoodId][-1]
     zoneId = requestStatus['zoneId']
     requestStatus['loader'] = 'cogHQLoader' if ZoneUtil.isCogHQZone(
         hoodId) else requestStatus['loader']
     loaderName = requestStatus['loader']
     avId = requestStatus.get('avId', -1)
     ownerId = requestStatus.get('ownerId', avId)
     if base.config.GetBool('want-qa-regression', 0):
         self.notify.info('QA-REGRESSION: NEIGHBORHOODS: Visit %s' %
                          hoodName)
     count = ToontownGlobals.hoodCountMap[canonicalHoodId]
     if loaderName == 'safeZoneLoader':
         count += ToontownGlobals.safeZoneCountMap[canonicalHoodId]
     elif loaderName == 'townLoader':
         count += ToontownGlobals.townCountMap[canonicalHoodId]
     if not loader.inBulkBlock:
         if hoodId == ToontownGlobals.MyEstate:
             if avId == -1:
                 loader.beginBulkLoad('hood',
                                      TTLocalizer.HeadingToYourEstate,
                                      count, 1, TTLocalizer.TIP_ESTATE,
                                      zoneId)
             else:
                 owner = base.cr.identifyAvatar(ownerId)
                 if owner == None:
                     friend = base.cr.identifyAvatar(avId)
                     if friend != None:
                         avName = friend.getName()
                         loader.beginBulkLoad(
                             'hood', TTLocalizer.HeadingToFriend % avName,
                             count, 1, TTLocalizer.TIP_ESTATE, zoneId)
                     else:
                         self.notify.warning(
                             "we can't perform this teleport")
                         return
                 else:
                     avName = owner.getName()
                     loader.beginBulkLoad(
                         'hood', TTLocalizer.HeadingToEstate % avName,
                         count, 1, TTLocalizer.TIP_ESTATE, zoneId)
         elif ZoneUtil.isCogHQZone(zoneId):
             loader.beginBulkLoad(
                 'hood', TTLocalizer.HeadingToHood % {
                     'to': toHoodPhrase,
                     'hood': hoodName
                 }, count, 1, TTLocalizer.TIP_COGHQ, zoneId)
         elif ZoneUtil.isGoofySpeedwayZone(zoneId):
             loader.beginBulkLoad(
                 'hood', TTLocalizer.HeadingToHood % {
                     'to': toHoodPhrase,
                     'hood': hoodName
                 }, count, 1, TTLocalizer.TIP_KARTING, zoneId)
         else:
             loader.beginBulkLoad(
                 'hood', TTLocalizer.HeadingToHood % {
                     'to': toHoodPhrase,
                     'hood': hoodName
                 }, count, 1, TTLocalizer.TIP_GENERAL, zoneId)
     if hoodId == ToontownGlobals.Tutorial:
         self.loadDnaStoreTutorial()
     else:
         if not hasattr(self, 'dnaStore'):
             self.loadDnaStore()
     hoodClass = self.getHoodClassByNumber(canonicalHoodId)
     self.hood = hoodClass(self.fsm, self.hoodDoneEvent, self.dnaStore,
                           hoodId)
     self.hood.load()
     self.hood.loadLoader(requestStatus)
     if not base.placeBeforeObjects:
         loader.endBulkLoad('hood')
     return