Advertisement
Guest User

Untitled

a guest
Mar 31st, 2015
233
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 3.25 KB | None | 0 0
  1. from toontown.toonbase import ToontownGlobals
  2. from SZHoodAI import SZHoodAI
  3. from toontown.classicchars import DistributedMickeyAI
  4. from toontown.classicchars import DistributedVampireMickeyAI
  5. from toontown.safezone import ButterflyGlobals
  6. from toontown.safezone.DistributedButterflyAI import DistributedButterflyAI
  7. from toontown.toon import NPCToons
  8. #from toontown.election.DistributedElectionEventAI import DistributedElectionEventAI
  9. from direct.task import Task
  10. import time
  11.  
  12. class TTHoodAI(SZHoodAI):
  13.     HOOD = ToontownGlobals.ToontownCentral
  14.    
  15.     def createZone(self):
  16.         SZHoodAI.createZone(self)
  17.         self.spawnObjects()
  18.         self.butterflies = []
  19.         self.createButterflies(self)
  20.         self.createClassicChar
  21.  
  22.         if self.air.config.GetBool('want-classic-chars', True):
  23.             self.air.config.GetBool('want-mickey', True)
  24.             self.createClassicChar()
  25.    
  26.     def spawnElection(self):
  27.         election = self.air.doFind('ElectionEvent')
  28.         if election is None:
  29.             election = DistributedElectionEventAI(self.air)
  30.             election.generateWithRequired(self.HOOD)
  31.         election.b_setState('Idle')
  32.         if self.air.config.GetBool('want-hourly-doomsday', False):
  33.             self.__startElectionTick()
  34.        
  35.     def __startElectionTick(self):
  36.         # Check seconds until next hour.
  37.         ts = time.time()
  38.         nextHour = 3600 - (ts % 3600)
  39.         taskMgr.doMethodLater(nextHour, self.__electionTick, 'election-hourly')
  40.        
  41.     def __electionTick(self, task):
  42.         # The next tick will occur in exactly an hour.
  43.         task.delayTime = 3600
  44.         # Check if we have toons in TTC...
  45.         toons = self.air.doFindAll('DistributedToon')
  46.         if not toons:
  47.             # There are no toons online, just wait for the next hour.
  48.             return task.again
  49.         # Is there an invasion currently running?
  50.         election = self.air.doFind('ElectionEvent')
  51.         if election:
  52.             state = election.getState()
  53.             if state[0] == 'Idle':
  54.                 # There's already an Idle invasion, start it!
  55.                 taskMgr.doMethodLater(10, election.b_setState, 'election-start-delay', extraArgs=['Event'])
  56.         if not election:
  57.             # Create a new election object.
  58.             election = DistributedElectionEventAI(self.air)
  59.             election.generateWithRequired(self.HOOD)
  60.             election.b_setState('Idle')
  61.             # Start the election after a 10 second delay.
  62.             taskMgr.doMethodLater(10, election.b_setState, 'election-start-delay', extraArgs=['Event'])
  63.         return task.again
  64.            
  65.    
  66.     def createButterflies(self):
  67.             playground = ButterflyGlobals.TTC
  68.             for area in range(ButterflyGlobals.NUM_BUTTERFLY_AREAS[playground]):
  69.                 for b in range(ButterflyGlobals.NUM_BUTTERFLIES[playground]):
  70.                     butterfly = DistributedButterflyAI(self.air)
  71.                     butterfly.setArea(playground, area)
  72.                     butterfly.setState(0, 0, 0, 1, 1)
  73.                     butterfly.generateWithRequired(self.HOOD)
  74.                     self.butterflies.append(butterfly)
  75.    
  76.     def createClassicChar(self):
  77.         if ToontownGlobals.HALLOWEEN_COSTUMES in self.air.holidayManager.currentHolidays:
  78.             self.classicChar = DistributedVampireMickeyAI.DistributedVampireMickeyAI(self.air)
  79.             self.classicChar.generateWithRequired(self.zoneId)
  80.             self.classicChar.start()
  81.         else:
  82.             self.classicChar = DistributedMickeyAI.DistributedMickeyAI(self.air)
  83.             self.classicChar.generateWithRequired(self.zoneId)
  84.             self.classicChar.start()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement