mirror of
https://github.com/Sneed-Group/Poodletooth-iLand
synced 2024-12-23 19:52:37 -06:00
Pushed what I have so far for grand prix
This commit is contained in:
parent
62d1aed98a
commit
cc283ad32b
7 changed files with 84 additions and 20 deletions
BIN
dependencies/astron/astrond.exe
vendored
BIN
dependencies/astron/astrond.exe
vendored
Binary file not shown.
|
@ -119,6 +119,9 @@ class NewsManagerAI(DistributedObjectAI):
|
||||||
|
|
||||||
return Task.again
|
return Task.again
|
||||||
|
|
||||||
|
def isGrandPrixRunning(self):
|
||||||
|
return self.isHolidayRunning(ToontownGlobals.SILLY_SATURDAY, ToontownGlobals.GRAND_PRIX) or True
|
||||||
|
|
||||||
@magicWord(category=CATEGORY_PROGRAMMER)
|
@magicWord(category=CATEGORY_PROGRAMMER)
|
||||||
def newsShutdown():
|
def newsShutdown():
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -41,6 +41,8 @@ class DistributedRace(DistributedObject.DistributedObject):
|
||||||
SFX_Applause = SFX_BaseDir + 'KART_Applause_%d.ogg'
|
SFX_Applause = SFX_BaseDir + 'KART_Applause_%d.ogg'
|
||||||
|
|
||||||
def __init__(self, cr):
|
def __init__(self, cr):
|
||||||
|
if hasattr(base, 'race') and base.race:
|
||||||
|
base.race.delete()
|
||||||
self.qbox = loader.loadModel('phase_6/models/karting/qbox')
|
self.qbox = loader.loadModel('phase_6/models/karting/qbox')
|
||||||
self.boostArrowTexture = loader.loadTexture('phase_6/maps/boost_arrow.jpg', 'phase_6/maps/boost_arrow_a.rgb')
|
self.boostArrowTexture = loader.loadTexture('phase_6/maps/boost_arrow.jpg', 'phase_6/maps/boost_arrow_a.rgb')
|
||||||
self.boostArrowTexture.setMinfilter(Texture.FTLinear)
|
self.boostArrowTexture.setMinfilter(Texture.FTLinear)
|
||||||
|
@ -182,6 +184,8 @@ class DistributedRace(DistributedObject.DistributedObject):
|
||||||
del i
|
del i
|
||||||
|
|
||||||
self.piejectileManager.delete()
|
self.piejectileManager.delete()
|
||||||
|
if not hasattr(base, 'race'):
|
||||||
|
return
|
||||||
if self.curveTs:
|
if self.curveTs:
|
||||||
del self.curveTs
|
del self.curveTs
|
||||||
if self.curvePoints:
|
if self.curvePoints:
|
||||||
|
@ -194,13 +198,12 @@ class DistributedRace(DistributedObject.DistributedObject):
|
||||||
del self.anvilFall
|
del self.anvilFall
|
||||||
del self.bananaSound
|
del self.bananaSound
|
||||||
del self.localKart
|
del self.localKart
|
||||||
DistributedObject.DistributedObject.delete(self)
|
|
||||||
taskMgr.remove(self.uniqueName('countdownTimerTask'))
|
taskMgr.remove(self.uniqueName('countdownTimerTask'))
|
||||||
taskMgr.remove('raceWatcher')
|
taskMgr.remove('raceWatcher')
|
||||||
bboard.remove('race')
|
bboard.remove('race')
|
||||||
self.ignoreAll()
|
self.ignoreAll()
|
||||||
|
DistributedObject.DistributedObject.delete(self)
|
||||||
del base.race
|
del base.race
|
||||||
return
|
|
||||||
|
|
||||||
def d_requestThrow(self, x, y, z):
|
def d_requestThrow(self, x, y, z):
|
||||||
self.sendUpdate('requestThrow', [x, y, z])
|
self.sendUpdate('requestThrow', [x, y, z])
|
||||||
|
@ -721,6 +724,7 @@ class DistributedRace(DistributedObject.DistributedObject):
|
||||||
if self.trackId in (RaceGlobals.RT_Urban_2, RaceGlobals.RT_Urban_2_rev):
|
if self.trackId in (RaceGlobals.RT_Urban_2, RaceGlobals.RT_Urban_2_rev):
|
||||||
dnaFile = 'phase_6/dna/urban_track_town_B.pdna'
|
dnaFile = 'phase_6/dna/urban_track_town_B.pdna'
|
||||||
node = loader.loadDNAFile(self.dnaStore, dnaFile)
|
node = loader.loadDNAFile(self.dnaStore, dnaFile)
|
||||||
|
self.geomNode = node
|
||||||
self.townGeom = self.geom.attachNewNode(node)
|
self.townGeom = self.geom.attachNewNode(node)
|
||||||
self.townGeom.findAllMatches('**/+CollisionNode').stash()
|
self.townGeom.findAllMatches('**/+CollisionNode').stash()
|
||||||
self.buildingGroups = {}
|
self.buildingGroups = {}
|
||||||
|
@ -1219,8 +1223,8 @@ class DistributedRace(DistributedObject.DistributedObject):
|
||||||
|
|
||||||
def setRaceZone(self, zoneId, trackId):
|
def setRaceZone(self, zoneId, trackId):
|
||||||
hoodId = self.cr.playGame.hood.hoodId
|
hoodId = self.cr.playGame.hood.hoodId
|
||||||
base.loader.endBulkLoad('atRace')
|
#base.loader.endBulkLoad('atRace')
|
||||||
self.kartCleanup()
|
#self.kartCleanup()
|
||||||
self.doneBarrier('waitingForExit')
|
self.doneBarrier('waitingForExit')
|
||||||
self.sendUpdate('racerLeft', [localAvatar.doId])
|
self.sendUpdate('racerLeft', [localAvatar.doId])
|
||||||
out = {'loader': 'racetrack',
|
out = {'loader': 'racetrack',
|
||||||
|
|
|
@ -15,7 +15,7 @@ from toontown.toonbase import TTLocalizer, ToontownGlobals
|
||||||
class DistributedRaceAI(DistributedObjectAI, FSM):
|
class DistributedRaceAI(DistributedObjectAI, FSM):
|
||||||
notify = DirectNotifyGlobal.directNotify.newCategory("DistributedRaceAI")
|
notify = DirectNotifyGlobal.directNotify.newCategory("DistributedRaceAI")
|
||||||
|
|
||||||
def __init__(self, air):
|
def __init__(self, air, circuitPoints=[], circuitWinnings=[]):
|
||||||
DistributedObjectAI.__init__(self, air)
|
DistributedObjectAI.__init__(self, air)
|
||||||
FSM.__init__(self, 'DistributedRaceAI')
|
FSM.__init__(self, 'DistributedRaceAI')
|
||||||
self.air = air
|
self.air = air
|
||||||
|
@ -33,6 +33,11 @@ class DistributedRaceAI(DistributedObjectAI, FSM):
|
||||||
self.livingGags = []
|
self.livingGags = []
|
||||||
self.currentlyAffectedByAnvil = {}
|
self.currentlyAffectedByAnvil = {}
|
||||||
self.avatarProgress = {}
|
self.avatarProgress = {}
|
||||||
|
print 'circuit points %s' % (circuitPoints,)
|
||||||
|
print 'circuit winnings %s' % (circuitWinnings,)
|
||||||
|
self.circuitPoints = circuitPoints
|
||||||
|
self.circuitWinnings = circuitWinnings
|
||||||
|
self.quitAvatars = []
|
||||||
self.startTime = globalClockDelta.networkToLocalTime(globalClockDelta.getRealNetworkTime()) + 3
|
self.startTime = globalClockDelta.networkToLocalTime(globalClockDelta.getRealNetworkTime()) + 3
|
||||||
|
|
||||||
def generate(self):
|
def generate(self):
|
||||||
|
@ -46,9 +51,11 @@ class DistributedRaceAI(DistributedObjectAI, FSM):
|
||||||
kart.requestDelete()
|
kart.requestDelete()
|
||||||
for gag in self.livingGags:
|
for gag in self.livingGags:
|
||||||
gag.requestDelete()
|
gag.requestDelete()
|
||||||
self.air.deallocateZone(self.zoneId)
|
if not self.circuitLoop:
|
||||||
|
self.air.deallocateZone(self.zoneId)
|
||||||
for i in xrange(len(self.gags)):
|
for i in xrange(len(self.gags)):
|
||||||
taskMgr.remove('regenGag%i-%i' % (i, self.doId))
|
taskMgr.remove('regenGag%i-%i' % (i, self.doId))
|
||||||
|
taskMgr.remove(self.uniqueName('next-race'))
|
||||||
DistributedObjectAI.delete(self)
|
DistributedObjectAI.delete(self)
|
||||||
|
|
||||||
def enterJoin(self):
|
def enterJoin(self):
|
||||||
|
@ -131,6 +138,9 @@ class DistributedRaceAI(DistributedObjectAI, FSM):
|
||||||
|
|
||||||
def setCircuitLoop(self, circuitLoop):
|
def setCircuitLoop(self, circuitLoop):
|
||||||
self.circuitLoop = circuitLoop
|
self.circuitLoop = circuitLoop
|
||||||
|
if self.circuitLoop and not self.circuitPoints:
|
||||||
|
self.circuitPoints = [0] * len(self.avatars)
|
||||||
|
self.circuitWinnings = [0] * len(self.avatars)
|
||||||
|
|
||||||
def getCircuitLoop(self):
|
def getCircuitLoop(self):
|
||||||
return self.circuitLoop
|
return self.circuitLoop
|
||||||
|
@ -271,9 +281,36 @@ class DistributedRaceAI(DistributedObjectAI, FSM):
|
||||||
if not avId in self.avatars:
|
if not avId in self.avatars:
|
||||||
self.air.writeServerEvent('suspicious', avId, 'Toon tried to leave race they\'re not in!')
|
self.air.writeServerEvent('suspicious', avId, 'Toon tried to leave race they\'re not in!')
|
||||||
return
|
return
|
||||||
self.avatars.remove(avId)
|
|
||||||
if set(self.finishedAvatars) == set(self.avatars) or len(self.avatars) == 0:
|
if self.circuitLoop and self.finishedAvatars:
|
||||||
self.requestDelete()
|
if avId in self.quitAvatars:
|
||||||
|
return
|
||||||
|
|
||||||
|
self.quitAvatars.append(avId)
|
||||||
|
self.checkForNextRace()
|
||||||
|
else:
|
||||||
|
self.avatars.remove(avId)
|
||||||
|
if avId in self.quitAvatars:
|
||||||
|
self.quitAvatars.remove(avId)
|
||||||
|
if set(self.finishedAvatars) == set(self.avatars) or len(self.avatars) == 0:
|
||||||
|
self.requestDelete()
|
||||||
|
|
||||||
|
def checkForNextRace(self):
|
||||||
|
if len(self.quitAvatars) >= len(self.avatars):
|
||||||
|
trackId = self.circuitLoop[0]
|
||||||
|
self.nextRace = DistributedRaceAI(self.air, self.circuitPoints, self.circuitWinnings)
|
||||||
|
self.nextRace.setZoneId(self.zoneId)
|
||||||
|
self.nextRace.setTrackId(trackId)
|
||||||
|
self.nextRace.setRaceType(self.raceType)
|
||||||
|
self.nextRace.setAvatars(self.avatars)
|
||||||
|
self.nextRace.setCircuitLoop(self.circuitLoop)
|
||||||
|
self.nextRace.setStartingPlaces(range(len(self.avatars)))
|
||||||
|
self.nextRace.setLapCount(3)
|
||||||
|
taskMgr.doMethodLater(3, self.startNewRace, self.uniqueName('next-race'), extraArgs=[trackId])
|
||||||
|
|
||||||
|
def startNewRace(self, trackId, task=None):
|
||||||
|
self.nextRace.generateWithRequired(self.zoneId)
|
||||||
|
self.sendUpdate('setRaceZone', [self.zoneId, trackId])
|
||||||
|
|
||||||
def heresMyT(self, avId, laps, currentLapT, timestamp):
|
def heresMyT(self, avId, laps, currentLapT, timestamp):
|
||||||
realAvId = self.air.getAvatarIdFromSender()
|
realAvId = self.air.getAvatarIdFromSender()
|
||||||
|
@ -299,6 +336,7 @@ class DistributedRaceAI(DistributedObjectAI, FSM):
|
||||||
|
|
||||||
av = self.air.doId2do.get(avId)
|
av = self.air.doId2do.get(avId)
|
||||||
place = len(self.finishedAvatars)
|
place = len(self.finishedAvatars)
|
||||||
|
listPlace = place + (4 - len(self.avatarProgress)) - 1
|
||||||
entryFee = RaceGlobals.getEntryFee(self.trackId, self.raceType)
|
entryFee = RaceGlobals.getEntryFee(self.trackId, self.raceType)
|
||||||
bonus = 0
|
bonus = 0
|
||||||
totalTime = globalClockDelta.networkToLocalTime(globalClockDelta.getRealNetworkTime()) - self.startTime
|
totalTime = globalClockDelta.networkToLocalTime(globalClockDelta.getRealNetworkTime()) - self.startTime
|
||||||
|
@ -310,8 +348,7 @@ class DistributedRaceAI(DistributedObjectAI, FSM):
|
||||||
winnings = RaceGlobals.PracticeWinnings
|
winnings = RaceGlobals.PracticeWinnings
|
||||||
trophies = []
|
trophies = []
|
||||||
elif qualify:
|
elif qualify:
|
||||||
offset = 4 - len(self.avatarProgress) # self.avatarProgress contains the amount of STARTING players.
|
winnings = entryFee * RaceGlobals.Winnings[listPlace]
|
||||||
winnings = entryFee * RaceGlobals.Winnings[(place+offset)-1]
|
|
||||||
trophies = self.calculateTrophies(avId, place == 1, qualify, totalTime)
|
trophies = self.calculateTrophies(avId, place == 1, qualify, totalTime)
|
||||||
else:
|
else:
|
||||||
winnings = 0
|
winnings = 0
|
||||||
|
@ -320,7 +357,18 @@ class DistributedRaceAI(DistributedObjectAI, FSM):
|
||||||
if av.getTickets() > RaceGlobals.MaxTickets:
|
if av.getTickets() > RaceGlobals.MaxTickets:
|
||||||
av.b_setTickets(RaceGlobals.MaxTickets)
|
av.b_setTickets(RaceGlobals.MaxTickets)
|
||||||
av.addStat(ToontownGlobals.STAT_RACING)
|
av.addStat(ToontownGlobals.STAT_RACING)
|
||||||
self.sendUpdate('setPlace', [avId, totalTime, place, entryFee, qualify, max((winnings-entryFee), 0), bonus, trophies, [], 0])
|
if self.circuitPoints:
|
||||||
|
avIndex = self.avatars.index(avId)
|
||||||
|
self.circuitPoints[avIndex] += RaceGlobals.CircuitPoints[place - 1]
|
||||||
|
self.sendUpdate('setPlace', [avId, totalTime, place, entryFee, qualify, max((winnings-entryFee), 0), bonus, trophies, self.circuitPoints, 0])
|
||||||
|
if self.circuitPoints:
|
||||||
|
self.circuitWinnings[avIndex] += winnings
|
||||||
|
del self.circuitLoop[0]
|
||||||
|
self.sendUpdate('setCircuitLoop', [self.circuitLoop])
|
||||||
|
self.sendUpdate('setCircuitPlace', [avId, place, entryFee, self.circuitWinnings[avIndex], bonus, trophies])
|
||||||
|
|
||||||
|
if len(self.finishedAvatars) == len(self.avatars):
|
||||||
|
self.sendUpdate('endCircuitRace')
|
||||||
|
|
||||||
def calculateTrophies(self, avId, won, qualify, time):
|
def calculateTrophies(self, avId, won, qualify, time):
|
||||||
if won:
|
if won:
|
||||||
|
@ -436,6 +484,8 @@ class DistributedRaceAI(DistributedObjectAI, FSM):
|
||||||
count += 1
|
count += 1
|
||||||
if len(self.avatars) == 0:
|
if len(self.avatars) == 0:
|
||||||
self.requestDelete()
|
self.requestDelete()
|
||||||
|
else:
|
||||||
|
self.checkForNextRace()
|
||||||
|
|
||||||
def requestKart(self):
|
def requestKart(self):
|
||||||
pass
|
pass
|
||||||
|
|
|
@ -50,7 +50,7 @@ class DistributedRacePadAI(DistributedKartPadAI, FSM):
|
||||||
taskMgr.remove('changeTrack%i' % self.doId)
|
taskMgr.remove('changeTrack%i' % self.doId)
|
||||||
|
|
||||||
def enterWaitCountdown(self):
|
def enterWaitCountdown(self):
|
||||||
taskMgr.doMethodLater(30, DistributedRacePadAI.startRace, 'startRace%i' % self.doId, [self])
|
taskMgr.doMethodLater(11, DistributedRacePadAI.startRace, 'startRace%i' % self.doId, [self])
|
||||||
|
|
||||||
def exitWaitCountdown(self):
|
def exitWaitCountdown(self):
|
||||||
taskMgr.remove('startRace%i' % self.doId)
|
taskMgr.remove('startRace%i' % self.doId)
|
||||||
|
@ -100,7 +100,7 @@ class DistributedRacePadAI(DistributedKartPadAI, FSM):
|
||||||
if self.runningMovie:
|
if self.runningMovie:
|
||||||
self.request('WaitBoarding')
|
self.request('WaitBoarding')
|
||||||
return
|
return
|
||||||
if self.trackType != RaceGlobals.Practice:
|
if self.trackType != RaceGlobals.Practice and False:
|
||||||
count = 0
|
count = 0
|
||||||
for block in self.startingBlocks:
|
for block in self.startingBlocks:
|
||||||
if block.avId != 0:
|
if block.avId != 0:
|
||||||
|
@ -124,8 +124,13 @@ class DistributedRacePadAI(DistributedKartPadAI, FSM):
|
||||||
race.setZoneId(self.raceZone)
|
race.setZoneId(self.raceZone)
|
||||||
race.setTrackId(self.trackId)
|
race.setTrackId(self.trackId)
|
||||||
race.setRaceType(self.trackType)
|
race.setRaceType(self.trackType)
|
||||||
race.setCircuitLoop([])
|
|
||||||
race.setAvatars(avatars)
|
race.setAvatars(avatars)
|
||||||
|
if self.trackType == RaceGlobals.Circuit:
|
||||||
|
print 'Circuit!'
|
||||||
|
print 'circuit loop: %s' % (RaceGlobals.getCircuitLoop(self.trackId),)
|
||||||
|
race.setCircuitLoop(RaceGlobals.getCircuitLoop(self.trackId))
|
||||||
|
else:
|
||||||
|
race.setCircuitLoop([])
|
||||||
race.setStartingPlaces(range(len(avatars)))
|
race.setStartingPlaces(range(len(avatars)))
|
||||||
race.setLapCount(3)
|
race.setLapCount(3)
|
||||||
race.generateWithRequired(self.raceZone)
|
race.generateWithRequired(self.raceZone)
|
||||||
|
|
|
@ -129,7 +129,7 @@ class RaceResultsPanel(DirectFrame):
|
||||||
displayPar = Parallel(bonusSeq, ticketSeq)
|
displayPar = Parallel(bonusSeq, ticketSeq)
|
||||||
displayPar.start()
|
displayPar.start()
|
||||||
self.entryListSeqs.append(displayPar)
|
self.entryListSeqs.append(displayPar)
|
||||||
if not circuitPoints == []:
|
if circuitPoints:
|
||||||
self.pointsLabel.show()
|
self.pointsLabel.show()
|
||||||
newPoints = circuitPoints[:].pop()
|
newPoints = circuitPoints[:].pop()
|
||||||
currentPoints = sum(circuitPoints[:-1])
|
currentPoints = sum(circuitPoints[:-1])
|
||||||
|
@ -376,8 +376,7 @@ class RaceEndPanel(DirectFrame):
|
||||||
def updateWinningsFromCircuit(self, place, entryFee, winnings, bonus, trophies = ()):
|
def updateWinningsFromCircuit(self, place, entryFee, winnings, bonus, trophies = ()):
|
||||||
print 'updateWinningsFromCircuit'
|
print 'updateWinningsFromCircuit'
|
||||||
self.seq.finish()
|
self.seq.finish()
|
||||||
totalTickets = winnings + entryFee + bonus
|
self.results.updateWinnings(place, winnings + entryFee + bonus)
|
||||||
self.results.updateWinnings(place, totalTickets)
|
|
||||||
self.startWinningsPanel(entryFee, winnings, 0, bonus, trophies, True)
|
self.startWinningsPanel(entryFee, winnings, 0, bonus, trophies, True)
|
||||||
|
|
||||||
def startWinningsPanel(self, entryFee, winnings, track, bonus = None, trophies = (), endOfCircuitRace = False):
|
def startWinningsPanel(self, entryFee, winnings, track, bonus = None, trophies = (), endOfCircuitRace = False):
|
||||||
|
|
|
@ -205,7 +205,7 @@ def getTunnelSignName(genreId, padId):
|
||||||
RacePadId2RaceInfo = {0: (0, Practice, 3),
|
RacePadId2RaceInfo = {0: (0, Practice, 3),
|
||||||
1: (1, Practice, 3),
|
1: (1, Practice, 3),
|
||||||
2: (0, ToonBattle, 3),
|
2: (0, ToonBattle, 3),
|
||||||
3: (1, ToonBattle, 3)}
|
3: (1, Circuit, 3)}
|
||||||
|
|
||||||
def getGenreFromString(string):
|
def getGenreFromString(string):
|
||||||
if string == 'town':
|
if string == 'town':
|
||||||
|
@ -236,6 +236,9 @@ def getNextRaceInfo(prevTrackId, genreString, padId):
|
||||||
genre = getGenreFromString(genreString)
|
genre = getGenreFromString(genreString)
|
||||||
cPadId = getCanonicalPadId(padId)
|
cPadId = getCanonicalPadId(padId)
|
||||||
raceInfo = RacePadId2RaceInfo.get(cPadId)
|
raceInfo = RacePadId2RaceInfo.get(cPadId)
|
||||||
|
raceType = raceInfo[1]
|
||||||
|
if raceType == Circuit and not simbase.air.newsManager.isGrandPrixRunning():
|
||||||
|
raceType = ToonBattle
|
||||||
trackList = getTrackListByType(genre, raceInfo[0])
|
trackList = getTrackListByType(genre, raceInfo[0])
|
||||||
if trackList.count(prevTrackId) == 0:
|
if trackList.count(prevTrackId) == 0:
|
||||||
trackId = trackList[1]
|
trackId = trackList[1]
|
||||||
|
@ -244,7 +247,7 @@ def getNextRaceInfo(prevTrackId, genreString, padId):
|
||||||
index += 1
|
index += 1
|
||||||
index %= len(trackList)
|
index %= len(trackList)
|
||||||
trackId = trackList[index]
|
trackId = trackList[index]
|
||||||
return (trackId, raceInfo[1], raceInfo[2])
|
return (trackId, raceType, raceInfo[2])
|
||||||
|
|
||||||
|
|
||||||
TrackPath = 'phase_6/models/karting/'
|
TrackPath = 'phase_6/models/karting/'
|
||||||
|
|
Loading…
Reference in a new issue