mirror of
https://github.com/Sneed-Group/Poodletooth-iLand
synced 2024-12-23 11:42:39 -06:00
Cleanup many Cogdo files.
This commit is contained in:
parent
e7b0cb751a
commit
cc33dee614
23 changed files with 204 additions and 283 deletions
|
@ -44,4 +44,4 @@ class DistCogdoBoardroomGame(CogdoBoardroomGameBase, DistCogdoLevelGame):
|
|||
self.timer.unstash()
|
||||
|
||||
def timerExpired(self):
|
||||
pass
|
||||
pass
|
||||
|
|
|
@ -3,4 +3,3 @@ from toontown.cogdominium.DistCogdoLevelGameAI import DistCogdoLevelGameAI
|
|||
|
||||
class DistCogdoBoardroomGameAI(DistCogdoLevelGameAI):
|
||||
notify = DirectNotifyGlobal.directNotify.newCategory("DistCogdoBoardroomGameAI")
|
||||
|
||||
|
|
|
@ -869,4 +869,4 @@ class DistCogdoCrane(DistributedObject.DistributedObject, FSM.FSM):
|
|||
|
||||
def exitMovie(self):
|
||||
self.__deactivatePhysics()
|
||||
self.__straightenCable()
|
||||
self.__straightenCable()
|
||||
|
|
|
@ -18,4 +18,3 @@ class DistCogdoCraneAI(DistributedObjectAI):
|
|||
|
||||
def setCablePos(self, todo0, todo1, todo2, todo3, todo4):
|
||||
pass
|
||||
|
||||
|
|
|
@ -12,4 +12,3 @@ class DistCogdoCraneCogAI(DistributedObjectAI):
|
|||
|
||||
def setSpawnInfo(self, todo0, todo1):
|
||||
pass
|
||||
|
||||
|
|
|
@ -174,4 +174,4 @@ class DistCogdoCraneGame(CogdoCraneGameBase, DistCogdoLevelGame):
|
|||
self.timer.unstash()
|
||||
|
||||
def timerExpired(self):
|
||||
pass
|
||||
pass
|
||||
|
|
|
@ -6,58 +6,56 @@ from toontown.cogdominium.CogdoCraneGameBase import CogdoCraneGameBase
|
|||
|
||||
class DistCogdoCraneGameAI(DistCogdoLevelGameAI, CogdoCraneGameBase):
|
||||
notify = directNotify.newCategory('DistCogdoCraneGameAI')
|
||||
|
||||
|
||||
def __init__(self, air, interior):
|
||||
DistCogdoLevelGameAI.__init__(self, air, interior)
|
||||
self._cranes = [
|
||||
None] * self.MaxPlayers
|
||||
|
||||
|
||||
def enterLoaded(self):
|
||||
DistCogdoLevelGameAI.enterLoaded(self)
|
||||
for i in xrange(self.MaxPlayers):
|
||||
crane = DistCogdoCraneAI(self.air, self, i)
|
||||
crane.generateWithRequired(self.zoneId)
|
||||
self._cranes[i] = crane
|
||||
|
||||
|
||||
def exitLoaded(self):
|
||||
for i in xrange(self.MaxPlayers):
|
||||
if self._cranes[i]:
|
||||
self._cranes[i].requestDelete()
|
||||
self._cranes[i] = None
|
||||
continue
|
||||
|
||||
DistCogdoLevelGameAI.exitLoaded(self)
|
||||
|
||||
|
||||
def enterGame(self):
|
||||
DistCogdoLevelGameAI.enterGame(self)
|
||||
for i in xrange(self.getNumPlayers()):
|
||||
self._cranes[i].request('Controlled', self.getToonIds()[i])
|
||||
|
||||
self._scheduleGameDone()
|
||||
|
||||
|
||||
def _scheduleGameDone(self):
|
||||
timeLeft = GameConsts.Settings.GameDuration.get() - globalClock.getRealTime() - self.getStartTime()
|
||||
if timeLeft > 0:
|
||||
self._gameDoneEvent = taskMgr.doMethodLater(timeLeft, self._gameDoneDL, self.uniqueName('boardroomGameDone'))
|
||||
else:
|
||||
self._gameDoneDL()
|
||||
|
||||
|
||||
def exitGame(self):
|
||||
taskMgr.remove(self._gameDoneEvent)
|
||||
self._gameDoneEvent = None
|
||||
|
||||
|
||||
def _gameDoneDL(self, task = None):
|
||||
self._handleGameFinished()
|
||||
return task.done
|
||||
|
||||
|
||||
def enterFinish(self):
|
||||
DistCogdoLevelGameAI.enterFinish(self)
|
||||
self._finishDoneEvent = taskMgr.doMethodLater(10.0, self._finishDoneDL, self.uniqueName('boardroomFinishDone'))
|
||||
|
||||
|
||||
def exitFinish(self):
|
||||
taskMgr.remove(self._finishDoneEvent)
|
||||
self._finishDoneEvent = None
|
||||
|
||||
|
||||
def _finishDoneDL(self, task):
|
||||
self.announceGameDone()
|
||||
return task.done
|
||||
return task.done
|
||||
|
|
|
@ -80,4 +80,4 @@ class DistCogdoCraneMoneyBag(DistCogdoCraneObject):
|
|||
self.showShadows()
|
||||
|
||||
def exitInitial(self):
|
||||
pass
|
||||
pass
|
||||
|
|
|
@ -9,4 +9,3 @@ class DistCogdoCraneMoneyBagAI(DistributedObjectAI):
|
|||
|
||||
def requestInitial(self):
|
||||
pass
|
||||
|
||||
|
|
|
@ -5,67 +5,56 @@ import CogdoFlyingGameGlobals as Globals
|
|||
|
||||
class DistCogdoFlyingGameAI(DistCogdoGameAI):
|
||||
notify = DirectNotifyGlobal.directNotify.newCategory("DistCogdoFlyingGameAI")
|
||||
|
||||
|
||||
def __init__(self, air):
|
||||
DistCogdoGameAI.__init__(self, air)
|
||||
self.completed = []
|
||||
self.eagles = {}
|
||||
self.totalMemos = 0
|
||||
|
||||
|
||||
def requestAction(self, action, data):
|
||||
avId = self.air.getAvatarIdFromSender()
|
||||
av = self.air.doId2do.get(avId)
|
||||
if not av:
|
||||
return
|
||||
|
||||
|
||||
if action == Globals.AI.GameActions.LandOnWinPlatform:
|
||||
self.completed.append(avId)
|
||||
for toon in self.toons:
|
||||
if toon not in self.completed:
|
||||
return
|
||||
|
||||
self.gameDone()
|
||||
|
||||
|
||||
elif action == Globals.AI.GameActions.BladeLost:
|
||||
self.sendUpdate("toonBladeLost", [avId])
|
||||
|
||||
elif action == Globals.AI.GameActions.SetBlades:
|
||||
self.sendUpdate("toonSetBlades", [avId, data])
|
||||
|
||||
elif action == Globals.AI.GameActions.Died:
|
||||
damage = Globals.AI.SafezoneId2DeathDamage[self.getSafezoneId()]
|
||||
self.__damage(av, damage)
|
||||
self.sendUpdate("toonDied", [avId, globalClockDelta.getRealNetworkTime()])
|
||||
|
||||
elif action == Globals.AI.GameActions.Spawn:
|
||||
self.sendUpdate("toonSpawn", [avId, globalClockDelta.getRealNetworkTime()])
|
||||
|
||||
elif action == Globals.AI.GameActions.RequestEnterEagleInterest:
|
||||
if not self.eagles.get(data):
|
||||
self.eagles[data] = avId
|
||||
self.sendUpdate("toonSetAsEagleTarget", [avId, data, globalClockDelta.getRealNetworkTime()])
|
||||
|
||||
elif action == Globals.AI.GameActions.RequestExitEagleInterest:
|
||||
if self.eagles.get(data) == avId:
|
||||
self.eagles[data] = 0
|
||||
self.sendUpdate("toonClearAsEagleTarget", [avId, data, globalClockDelta.getRealNetworkTime()])
|
||||
|
||||
elif action == Globals.AI.GameActions.HitLegalEagle:
|
||||
damage = Globals.AI.SafezoneId2LegalEagleDamage[self.getSafezoneId()]
|
||||
self.__damage(av, damage)
|
||||
|
||||
elif action == Globals.AI.GameActions.HitMinion:
|
||||
damage = Globals.AI.SafezoneId2MinionDamage[self.getSafezoneId()]
|
||||
self.__damage(av, damage)
|
||||
|
||||
elif action == Globals.AI.GameActions.HitWhirlwind:
|
||||
damage = Globals.AI.SafezoneId2WhirlwindDamage[self.getSafezoneId()]
|
||||
self.__damage(av, damage)
|
||||
|
||||
elif action == Globals.AI.GameActions.RanOutOfTimePenalty:
|
||||
damage = int(20 * self.getDifficulty())
|
||||
self.__damage(av, damage)
|
||||
|
||||
else:
|
||||
self.notify.warning('Client requested unknown action \'%s\'' %action)
|
||||
|
||||
|
@ -74,22 +63,20 @@ class DistCogdoFlyingGameAI(DistCogdoGameAI):
|
|||
av = self.air.doId2do.get(avId)
|
||||
if not av:
|
||||
return
|
||||
|
||||
|
||||
if pickupType <= len(Globals.Level.GatherableTypes):
|
||||
self.sendUpdate("pickUp", [avId, pickupNum, globalClockDelta.getRealNetworkTime()])
|
||||
if pickupType == Globals.Level.GatherableTypes.LaffPowerup:
|
||||
av.toonUp(int(27 * self.getDifficulty()) + 3)
|
||||
|
||||
if pickupType == Globals.Level.GatherableTypes.Memo:
|
||||
self.totalMemos += 1
|
||||
|
||||
else:
|
||||
self.notify.warning('Client requested unknown pickup \'%s\'' % pickupType)
|
||||
|
||||
def handleStart(self):
|
||||
for toon in self.toons:
|
||||
self.acceptOnce(self.air.getAvatarExitEvent(toon), self.__handleAvExit, [toon])
|
||||
|
||||
|
||||
def __handleAvExit(self, toon):
|
||||
if self.air:
|
||||
if toon in self.toons:
|
||||
|
@ -97,24 +84,24 @@ class DistCogdoFlyingGameAI(DistCogdoGameAI):
|
|||
self.ignore(self.air.getAvatarExitEvent(toon))
|
||||
if not self.toons:
|
||||
self.gameDone(failed=True)
|
||||
|
||||
|
||||
def requestDelete(self):
|
||||
DistCogdoGameAI.requestDelete(self)
|
||||
self.ignoreAll()
|
||||
|
||||
|
||||
def __removeToon(self, avId):
|
||||
if avId not in self.toons:
|
||||
return
|
||||
|
||||
|
||||
self.toons.pop(self.toons.index(avId))
|
||||
if len(self.toons) == 0:
|
||||
self.gameDone(failed=True)
|
||||
|
||||
|
||||
def __damage(self, av, damage):
|
||||
av.takeDamage(damage)
|
||||
if av.getHp() < 1:
|
||||
self.__removeToon(av.doId)
|
||||
|
||||
|
||||
def getTotalMemos(self):
|
||||
return self.totalMemos
|
||||
|
||||
|
@ -125,4 +112,3 @@ def endFly():
|
|||
game = simbase.air.cogdoGame
|
||||
game.requestAction(Globals.AI.GameActions.LandOnWinPlatform, 0)
|
||||
return 'Finished cogdo flying game!'
|
||||
|
|
@ -6,7 +6,7 @@ import CogdoGameConsts
|
|||
class DistCogdoGameAI(DistributedObjectAI):
|
||||
notify = DirectNotifyGlobal.directNotify.newCategory("DistCogdoGameAI")
|
||||
delayIntro = .1
|
||||
|
||||
|
||||
def __init__(self, air):
|
||||
DistributedObjectAI.__init__(self, air)
|
||||
air.cogdoGame = self
|
||||
|
@ -15,33 +15,31 @@ class DistCogdoGameAI(DistributedObjectAI):
|
|||
self.difficultyOverrides = [2147483647, -1]
|
||||
self.requests = {}
|
||||
self.toons = []
|
||||
|
||||
|
||||
def announceGenerate(self):
|
||||
DistributedObjectAI.announceGenerate(self)
|
||||
|
||||
self.finishEvent = self.uniqueName('CogdoMazeGameDone')
|
||||
self.gameOverEvent = self.uniqueName('CogdoMazeGameLose')
|
||||
|
||||
self.resetRequests()
|
||||
|
||||
|
||||
def d_startIntro(self):
|
||||
self.sendUpdate('setVisible', [])
|
||||
taskMgr.doMethodLater(self.delayIntro, self.__startIntro, self.taskName('CogdoStartIntro'))
|
||||
|
||||
|
||||
def getInterior(self):
|
||||
return self.air.doId2do.get(self.interiorId)
|
||||
|
||||
|
||||
def resetRequests(self):
|
||||
interior = self.getInterior()
|
||||
toons = interior.getToons()[0]
|
||||
for toon in toons:
|
||||
self.requests[toon] = 0
|
||||
|
||||
|
||||
def __startIntro(self, task = None):
|
||||
self.sendUpdate('setIntroStart', [])
|
||||
if task:
|
||||
return task.done
|
||||
|
||||
|
||||
def setAvatarReady(self):
|
||||
avId = self.air.getAvatarIdFromSender()
|
||||
self.requests[avId] = 1
|
||||
|
@ -49,7 +47,7 @@ class DistCogdoGameAI(DistributedObjectAI):
|
|||
if self.allToonsReady():
|
||||
self.handleStart()
|
||||
self.sendUpdate('setGameStart', [globalClockDelta.getRealNetworkTime()])
|
||||
|
||||
|
||||
def allToonsReady(self):
|
||||
interior = self.getInterior()
|
||||
toons = interior.getToons()[0]
|
||||
|
@ -57,52 +55,51 @@ class DistCogdoGameAI(DistributedObjectAI):
|
|||
if self.requests.get(toon, 0) == 0:
|
||||
return 0
|
||||
return 1
|
||||
|
||||
|
||||
def handleStart(self):
|
||||
pass
|
||||
|
||||
def setInteriorId(self, id):
|
||||
self.interiorId = id
|
||||
|
||||
|
||||
def getInteriorId(self):
|
||||
return self.interiorId
|
||||
|
||||
def setExteriorZone(self, zone):
|
||||
self.exteriorZone = zone
|
||||
|
||||
|
||||
def getExteriorZone(self):
|
||||
return self.exteriorZone
|
||||
|
||||
def setDifficultyOverrides(self, difficulty, exteriorDifficulty):
|
||||
self.difficultyOverrides = [difficulty, exteriorDifficulty]
|
||||
|
||||
|
||||
def getDifficultyOverrides(self):
|
||||
return self.difficultyOverrides
|
||||
|
||||
def toonWentSad(self, avId):
|
||||
self.sendUpdate('setToonSad', [avId])
|
||||
|
||||
|
||||
def setToons(self, toons):
|
||||
self.toons = toons
|
||||
|
||||
|
||||
def disable(self):
|
||||
DistributedObjectAI.disable(self)
|
||||
self.air.cogdoGame = None
|
||||
del self.air.cogdoGame
|
||||
|
||||
|
||||
def gameDone(self, failed=False):
|
||||
if not failed:
|
||||
if len(self.toons) == 0:
|
||||
failed = True
|
||||
|
||||
|
||||
if not failed:
|
||||
messenger.send(self.finishEvent, [self.toons])
|
||||
else:
|
||||
messenger.send(self.gameOverEvent)
|
||||
|
||||
|
||||
def getDifficulty(self):
|
||||
return CogdoGameConsts.getDifficulty(self.getSafezoneId())
|
||||
|
||||
def getSafezoneId(self):
|
||||
def getSafezoneId(self):
|
||||
return CogdoGameConsts.getSafezoneId(self.exteriorZone)
|
||||
|
|
@ -1,5 +1,4 @@
|
|||
|
||||
|
||||
class DistCogdoGameBase:
|
||||
|
||||
def local2GameTime(self, timestamp):
|
||||
|
|
|
@ -42,4 +42,4 @@ class DistCogdoLevelGame(DistCogdoGame, DistributedLevel):
|
|||
|
||||
def delete(self):
|
||||
DistCogdoGame.delete(self)
|
||||
DistributedLevel.delete(self)
|
||||
DistributedLevel.delete(self)
|
||||
|
|
|
@ -4,4 +4,3 @@ from otp.level.DistributedLevelAI import DistributedLevelAI
|
|||
|
||||
class DistCogdoLevelGameAI(DistCogdoGameAI, DistributedLevelAI):
|
||||
notify = DirectNotifyGlobal.directNotify.newCategory("DistCogdoLevelGameAI")
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ from direct.task import Timer
|
|||
from toontown.battle import BattleBase
|
||||
from toontown.building.ElevatorConstants import *
|
||||
|
||||
ALL_ABOARD_LAG = .7
|
||||
ALL_ABOARD_LAG = 3.7
|
||||
|
||||
BASE_TOON_UP = 10
|
||||
JOKE_TOON_UP = 5
|
||||
|
@ -14,7 +14,7 @@ JOKE_TOON_UP = 5
|
|||
class DistCogdoMazeGameAI(DistCogdoGameAI):
|
||||
notify = DirectNotifyGlobal.directNotify.newCategory("DistCogdoMazeGameAI")
|
||||
delayIntro = BattleBase.ELEVATOR_T + ElevatorData[ELEVATOR_NORMAL]['openTime'] + BattleBase.SERVER_BUFFER_TIME
|
||||
|
||||
|
||||
def __init__(self, air):
|
||||
DistCogdoGameAI.__init__(self, air)
|
||||
self.numSuits = (0,0,0)
|
||||
|
@ -26,16 +26,16 @@ class DistCogdoMazeGameAI(DistCogdoGameAI):
|
|||
self.slowMinions = {}
|
||||
self.suitTypes = [self.bosses, self.fastMinions, self.slowMinions]
|
||||
self.numJokes = {}
|
||||
|
||||
|
||||
def announceGenerate(self):
|
||||
DistCogdoGameAI.announceGenerate(self)
|
||||
self.setupSuitsAI()
|
||||
|
||||
|
||||
def setupSuitsAI(self):
|
||||
bossHp = CogdoMazeGameGlobals.SuitData[0]['hp']
|
||||
fastMiniHp = CogdoMazeGameGlobals.SuitData[1]['hp']
|
||||
slowMiniHp = CogdoMazeGameGlobals.SuitData[2]['hp']
|
||||
|
||||
|
||||
serialNum = 0
|
||||
for i in range(self.numSuits[0]):
|
||||
self.bosses[serialNum] = bossHp
|
||||
|
@ -46,17 +46,17 @@ class DistCogdoMazeGameAI(DistCogdoGameAI):
|
|||
for i in range(self.numSuits[2]):
|
||||
self.slowMinions[serialNum] = slowMiniHp
|
||||
serialNum += 1
|
||||
|
||||
|
||||
def setNumSuits(self, num):
|
||||
self.numSuits = num
|
||||
|
||||
|
||||
def getNumSuits(self):
|
||||
return self.numSuits
|
||||
|
||||
|
||||
def requestUseGag(self, x, y, h, timestamp):
|
||||
avId = self.air.getAvatarIdFromSender()
|
||||
self.sendUpdate('toonUsedGag', [avId, x, y, h, globalClockDelta.getRealNetworkTime()])
|
||||
|
||||
|
||||
def requestSuitHitByGag(self, suitType, suitNum):
|
||||
hitAI = self.hitSuitAI(suitType, suitNum)
|
||||
if not hitAI:
|
||||
|
@ -64,7 +64,7 @@ class DistCogdoMazeGameAI(DistCogdoGameAI):
|
|||
return
|
||||
avId = self.air.getAvatarIdFromSender()
|
||||
self.sendUpdate('suitHitByGag', [avId, suitType, suitNum])
|
||||
|
||||
|
||||
def requestHitBySuit(self, suitType, suitNum, nettime):
|
||||
avId = self.air.getAvatarIdFromSender()
|
||||
av = self.air.doId2do.get(avId)
|
||||
|
@ -75,7 +75,7 @@ class DistCogdoMazeGameAI(DistCogdoGameAI):
|
|||
self.sendUpdate('toonHitBySuit', [avId, suitType, suitNum, networkTime])
|
||||
if av.getHp() < 1:
|
||||
self.toonWentSad(avId)
|
||||
|
||||
|
||||
def requestHitByDrop(self):
|
||||
avId = self.air.getAvatarIdFromSender()
|
||||
av = self.air.doId2do.get(avId)
|
||||
|
@ -83,25 +83,24 @@ class DistCogdoMazeGameAI(DistCogdoGameAI):
|
|||
lostHp = CogdoMazeGameGlobals.DropDamage
|
||||
av.takeDamage(lostHp)
|
||||
self.sendUpdate('toonHitByDrop', [avId])
|
||||
|
||||
|
||||
def requestPickUp(self, pickupNum):
|
||||
avId = self.air.getAvatarIdFromSender()
|
||||
av = self.air.doId2do.get(avId)
|
||||
if av:
|
||||
now = globalClockDelta.getRealNetworkTime()
|
||||
|
||||
|
||||
if avId in self.numJokes:
|
||||
self.numJokes[avId] += 1
|
||||
|
||||
else:
|
||||
self.numJokes[avId] = 1
|
||||
|
||||
|
||||
self.sendUpdate('pickUp', [avId, pickupNum, now])
|
||||
|
||||
|
||||
def requestGag(self, coolerIndex):
|
||||
avId = self.air.getAvatarIdFromSender()
|
||||
self.sendUpdate('hasGag', [avId, globalClockDelta.getRealNetworkTime()])
|
||||
|
||||
|
||||
def hitSuitAI(self, suitType, suitNum):
|
||||
cogKey = None
|
||||
for cogNum in self.suitTypes[suitType].keys():
|
||||
|
@ -116,7 +115,7 @@ class DistCogdoMazeGameAI(DistCogdoGameAI):
|
|||
if cogHp <= 0:
|
||||
del self.suitTypes[suitType][cogKey]
|
||||
return 1
|
||||
|
||||
|
||||
def handleStart(self):
|
||||
taskMgr.add(self.__checkGameDone, self.taskName('check-game-done'))
|
||||
taskMgr.add(self.__checkPlayersTask, self.taskName('check-players-task'))
|
||||
|
@ -124,15 +123,15 @@ class DistCogdoMazeGameAI(DistCogdoGameAI):
|
|||
self.timer.startCallback(CogdoMazeGameGlobals.SecondsUntilTimeout + serverDelay, self.__handleGameOver)
|
||||
taskMgr.doMethodLater(serverDelay, self.clientCountdown, self.taskName('client_countdown'))
|
||||
taskMgr.add(self.__timeWarningTask, self.taskName('time-warning-task'))
|
||||
|
||||
|
||||
def clientCountdown(self, task):
|
||||
self.doAction(CogdoMazeGameGlobals.GameActions.Countdown, 0)
|
||||
return task.done
|
||||
|
||||
|
||||
def __handleGameOver(self):
|
||||
self.removeAll()
|
||||
self.gameDone(failed=True)
|
||||
|
||||
|
||||
def __checkGameDone(self, task):
|
||||
bossesLeft = self.bosses
|
||||
if len(bossesLeft) == 0:
|
||||
|
@ -140,27 +139,24 @@ class DistCogdoMazeGameAI(DistCogdoGameAI):
|
|||
self.doAction(CogdoMazeGameGlobals.GameActions.OpenDoor, 0)
|
||||
self.__startTimeout()
|
||||
return task.done
|
||||
|
||||
return task.again
|
||||
|
||||
|
||||
def __startTimeout(self):
|
||||
self.timer.startCallback(CogdoMazeGameGlobals.SecondsUntilGameEnds, self.__handleTimeout)
|
||||
|
||||
|
||||
def __handleTimeout(self):
|
||||
for toon in self.toons:
|
||||
if not toon in self.toonsInDoor:
|
||||
self.killToon(toon)
|
||||
|
||||
self.removeAll()
|
||||
self.gameDone()
|
||||
|
||||
|
||||
def __timeWarningTask(self, task):
|
||||
if self.timer.getT() <= CogdoMazeGameGlobals.SecondsForTimeAlert:
|
||||
self.doAction(CogdoMazeGameGlobals.GameActions.TimeAlert, 0)
|
||||
return task.done
|
||||
|
||||
return task.again
|
||||
|
||||
|
||||
def killToon(self, avId):
|
||||
av = self.air.doId2do.get(avId)
|
||||
if av:
|
||||
|
@ -168,25 +164,24 @@ class DistCogdoMazeGameAI(DistCogdoGameAI):
|
|||
av.takeDamage(av.getHp())
|
||||
self.toonWentSad(avId)
|
||||
self.__playerDisconnected(avId)
|
||||
|
||||
|
||||
def __checkPlayersTask(self, task):
|
||||
for toonId in self.toons:
|
||||
toon = self.air.doId2do.get(toonId)
|
||||
if not toon:
|
||||
self.__playerDisconnected(toonId)
|
||||
|
||||
return task.again
|
||||
|
||||
|
||||
def __playerDisconnected(self, avId):
|
||||
self.sendUpdate('setToonDisconnect', [avId])
|
||||
self.toons.pop(self.toons.index(avId))
|
||||
if len(self.toons) == 0:
|
||||
self.removeAll()
|
||||
self.gameDone(failed=True)
|
||||
|
||||
|
||||
def doAction(self, action, data):
|
||||
self.sendUpdate('doAction', [action, data, globalClockDelta.getRealNetworkTime()])
|
||||
|
||||
|
||||
def requestAction(self, action, data):
|
||||
Globals = CogdoMazeGameGlobals
|
||||
avId = self.air.getAvatarIdFromSender()
|
||||
|
@ -194,47 +189,43 @@ class DistCogdoMazeGameAI(DistCogdoGameAI):
|
|||
if not self.doorRevealed:
|
||||
self.doAction(action, avId)
|
||||
self.doorRevealed = True
|
||||
|
||||
else:
|
||||
self.notify.warning('Toon tried to reveal door but it\'s already revealed! Ignoring.')
|
||||
|
||||
elif action == Globals.GameActions.EnterDoor:
|
||||
if not avId in self.toonsInDoor:
|
||||
self.doAction(action, avId)
|
||||
self.toonsInDoor.append(avId)
|
||||
self.toonUpToon(avId)
|
||||
|
||||
else:
|
||||
self.notify.warning('Toon tried to enter into door but already entered! Ignoring.')
|
||||
return
|
||||
|
||||
|
||||
if len(self.toonsInDoor) >= len(self.toons):
|
||||
self.__handleAllAboard()
|
||||
|
||||
else:
|
||||
self.notify.warning('Client requested unknown action \'%s\'' %action)
|
||||
|
||||
|
||||
def __handleAllAboard(self):
|
||||
if len(self.toonsInDoor) != len(self.toons):
|
||||
self.notify.warning('__handleAllAboard expect all toons aboard!')
|
||||
return
|
||||
self.removeAll()
|
||||
taskMgr.doMethodLater(ALL_ABOARD_LAG, lambda t: self.gameDone(), self.taskName('all-aboard-delay'))
|
||||
|
||||
|
||||
def toonUpToon(self, toonId):
|
||||
if toonId in self.toonsInDoor:
|
||||
toon = self.air.doId2do.get(toonId)
|
||||
if toon:
|
||||
val = min(BASE_TOON_UP + JOKE_TOON_UP * self.numJokes.get(toonId, 0), toon.getMaxHp())
|
||||
toon.toonUp(val)
|
||||
|
||||
|
||||
def removeAll(self):
|
||||
taskMgr.remove(self.taskName('check-game-done'))
|
||||
taskMgr.remove(self.taskName('check-players-task'))
|
||||
taskMgr.remove(self.taskName('time-warning-task'))
|
||||
taskMgr.remove(self.taskName('all-aboard-delay'))
|
||||
self.timer.stop()
|
||||
|
||||
|
||||
def disable(self):
|
||||
DistCogdoGameAI.disable(self)
|
||||
self.removeAll()
|
||||
|
|
|
@ -5,13 +5,13 @@ import random
|
|||
|
||||
class DistributedCogdoBarrelAI(DistributedObjectAI.DistributedObjectAI):
|
||||
notify = DirectNotifyGlobal.directNotify.newCategory("DistributedCogdoBarrelAI")
|
||||
|
||||
|
||||
def __init__(self, air, index):
|
||||
DistributedObjectAI.DistributedObjectAI.__init__(self, air)
|
||||
self.index = index
|
||||
self.state = CogdoBarrelRoomConsts.StateAvailable
|
||||
self.brLaff = 0
|
||||
|
||||
|
||||
def requestGrab(self):
|
||||
toonup = CogdoBarrelRoomConsts.ToonUp
|
||||
if self.state == CogdoBarrelRoomConsts.StateAvailable:
|
||||
|
@ -20,17 +20,16 @@ class DistributedCogdoBarrelAI(DistributedObjectAI.DistributedObjectAI):
|
|||
self.sendUpdate("setGrab", [self.air.getAvatarIdFromSender()])
|
||||
self.brLaff = random.randint(toonup[0], toonup[1])
|
||||
self.recieveToonUp()
|
||||
|
||||
|
||||
def getIndex(self):
|
||||
return self.index
|
||||
|
||||
|
||||
def getState(self):
|
||||
return self.state
|
||||
|
||||
|
||||
def recieveToonUp(self):
|
||||
avId = self.air.getAvatarIdFromSender()
|
||||
av = self.air.doId2do.get(avId)
|
||||
if not av:
|
||||
return
|
||||
|
||||
av.toonUp(self.brLaff)
|
||||
|
|
|
@ -3,4 +3,3 @@ from toontown.battle.DistributedBattleBldgAI import DistributedBattleBldgAI
|
|||
|
||||
class DistributedCogdoBattleBldgAI(DistributedBattleBldgAI):
|
||||
notify = DirectNotifyGlobal.directNotify.newCategory("DistributedCogdoBattleBldgAI")
|
||||
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
# File: D (Python 2.4)
|
||||
|
||||
from toontown.building.DistributedElevatorExt import DistributedElevatorExt
|
||||
from toontown.building.ElevatorConstants import *
|
||||
from toontown.building.ElevatorUtils import *
|
||||
|
@ -9,14 +7,12 @@ class DistributedCogdoElevatorExt(DistributedElevatorExt):
|
|||
def __init__(self, cr):
|
||||
DistributedElevatorExt.__init__(self, cr)
|
||||
self.type = ELEVATOR_FIELD
|
||||
|
||||
|
||||
def getElevatorModel(self):
|
||||
return self.bldg.getCogdoElevatorNodePath()
|
||||
|
||||
|
||||
def getBldgDoorOrigin(self):
|
||||
return self.bldg.getCogdoDoorOrigin()
|
||||
|
||||
|
||||
def _getDoorsClosedInfo(self):
|
||||
return ('cogdoInterior', 'cogdoInterior')
|
||||
|
|
|
@ -1,12 +1,8 @@
|
|||
# File: D (Python 2.4)
|
||||
|
||||
from direct.directnotify import DirectNotifyGlobal
|
||||
from toontown.building.DistributedElevatorExtAI import DistributedElevatorExtAI
|
||||
|
||||
class DistributedCogdoElevatorExtAI(DistributedElevatorExtAI):
|
||||
notify = DirectNotifyGlobal.directNotify.newCategory('DistributedCogdoElevatorExtAI')
|
||||
|
||||
|
||||
def _createInterior(self):
|
||||
self.bldg.createCogdoInterior()
|
||||
|
||||
|
||||
|
|
|
@ -3,4 +3,3 @@ from toontown.building.DistributedElevatorIntAI import DistributedElevatorIntAI
|
|||
|
||||
class DistributedCogdoElevatorIntAI(DistributedElevatorIntAI):
|
||||
notify = DirectNotifyGlobal.directNotify.newCategory("DistributedCogdoElevatorIntAI")
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ PAINTING_DICT = {'s': 'tt_m_ara_crg_paintingMoverShaker',
|
|||
'l': 'tt_m_ara_crg_paintingLegalEagle',
|
||||
'm': 'tt_m_ara_crg_paintingMoverShaker',
|
||||
'c': 'tt_m_ara_crg_paintingMoverShaker'}
|
||||
|
||||
|
||||
from toontown.nametag.NametagGlobals import *
|
||||
from toontown.chat.ChatGlobals import *
|
||||
|
||||
|
@ -342,13 +342,12 @@ class DistributedCogdoInterior(DistributedObject.DistributedObject):
|
|||
suit.reparentTo(render)
|
||||
if oldsuits.count(suit) == 0:
|
||||
self.joiningReserves.append(suit)
|
||||
|
||||
|
||||
if 'Elevator' in repr(self.fsm):
|
||||
# fix the pos
|
||||
# Fix the position.
|
||||
pos, h = BattleBase.BattleBase.suitPoints[len(suitIds) - 1][suitIds.index(suitId)]
|
||||
suit.setPos(pos)
|
||||
suit.setH(h)
|
||||
|
||||
else:
|
||||
self.notify.warning('setSuits() - no suit: %d' % suitId)
|
||||
|
||||
|
@ -420,14 +419,14 @@ class DistributedCogdoInterior(DistributedObject.DistributedObject):
|
|||
def __playElevator(self, ts, name, callback):
|
||||
SuitHs = []
|
||||
SuitPositions = []
|
||||
|
||||
|
||||
if self.floorModel:
|
||||
self.floorModel.removeNode()
|
||||
self.floorModel = None
|
||||
|
||||
|
||||
if self.cage:
|
||||
self.cage = None
|
||||
|
||||
|
||||
if self.currentFloor == 0:
|
||||
SuitHs = self.BottomFloor_SuitHs
|
||||
SuitPositions = self.BottomFloor_SuitPositions
|
||||
|
@ -468,14 +467,13 @@ class DistributedCogdoInterior(DistributedObject.DistributedObject):
|
|||
SuitHs = self.BossOffice_SuitHs
|
||||
SuitPositions = self.BossOffice_SuitPositions
|
||||
self.__makeShopOwnerNpc()
|
||||
|
||||
else:
|
||||
if self._wantBarrelRoom:
|
||||
self.barrelRoom.load()
|
||||
self.barrelRoom.hide()
|
||||
SuitHs = self.Cubicle_SuitHs
|
||||
SuitPositions = self.Cubicle_SuitPositions
|
||||
|
||||
|
||||
if self.floorModel:
|
||||
self.floorModel.reparentTo(render)
|
||||
if self.isBossFloor(self.currentFloor):
|
||||
|
@ -483,35 +481,32 @@ class DistributedCogdoInterior(DistributedObject.DistributedObject):
|
|||
elevIn = self.floorModel.find(CogdoGameConsts.PenthouseElevatorInPath).copyTo(render)
|
||||
elevOut = self.floorModel.find(CogdoGameConsts.PenthouseElevatorOutPath)
|
||||
frame = self.elevatorModelOut.find('**/frame')
|
||||
|
||||
|
||||
if not frame.isEmpty():
|
||||
frame.hide()
|
||||
|
||||
|
||||
frame = self.elevatorModelIn.find('**/frame')
|
||||
|
||||
|
||||
if not frame.isEmpty():
|
||||
frame.hide()
|
||||
|
||||
|
||||
self.elevatorModelOut.reparentTo(elevOut)
|
||||
self.elevatorModelOut.setY(0)
|
||||
|
||||
else:
|
||||
elevIn = self.floorModel.find('**/elevator-in')
|
||||
elevOut = self.floorModel.find('**/elevator-out')
|
||||
|
||||
elif self._wantBarrelRoom and self.barrelRoom.isLoaded() and self.currentFloor == 2 and self.FOType == 'l': #i know this is really ugly
|
||||
elevIn = self.barrelRoom.model.find(CogdoBarrelRoomConsts.BarrelRoomElevatorInPath)
|
||||
elevOut = self.barrelRoom.model.find(CogdoBarrelRoomConsts.BarrelRoomElevatorOutPath)
|
||||
y = elevOut.getY(render)
|
||||
elevOut = elevOut.copyTo(render)
|
||||
elevOut.setY(render, y - 0.75)
|
||||
|
||||
else:
|
||||
floorModel = loader.loadModel('phase_7/models/modules/boss_suit_office')
|
||||
elevIn = floorModel.find('**/elevator-in').copyTo(render)
|
||||
elevOut = floorModel.find('**/elevator-out').copyTo(render)
|
||||
floorModel.removeNode()
|
||||
|
||||
|
||||
self.elevIn = elevIn
|
||||
self.elevOut = elevOut
|
||||
self._haveEntranceElevator.set(True)
|
||||
|
@ -805,13 +800,13 @@ class DistributedCogdoInterior(DistributedObject.DistributedObject):
|
|||
trackName = '__outroPenthouse-%d' % avatar.doId
|
||||
track = Parallel(name=trackName)
|
||||
base.cr.playGame.getPlace().fsm.request('stopped')
|
||||
|
||||
|
||||
if self.FOType == "l":
|
||||
speech = TTLocalizer.CogdoExecutiveSuiteToonThankYouLawbot
|
||||
|
||||
else:
|
||||
speech = TTLocalizer.CogdoExecutiveSuiteToonThankYou % self.SOSToonName
|
||||
|
||||
|
||||
track.append(Sequence(Func(camera.wrtReparentTo, localAvatar),
|
||||
Func(camera.setPos, 0, -9, 9),
|
||||
Func(camera.lookAt, Point3(5, 15, 0)),
|
||||
|
|
|
@ -22,7 +22,7 @@ NUM_FLOORS_DICT = {
|
|||
'm':1,
|
||||
'c': 1
|
||||
}
|
||||
|
||||
|
||||
BATTLE_INTRO_DURATION = 10
|
||||
BARREL_INTRO_DURATION = 12
|
||||
BARREL_ROOM_DURATION = 30
|
||||
|
@ -30,7 +30,7 @@ BARREL_ROOM_REWARD_DURATION = 7
|
|||
|
||||
class DistributedCogdoInteriorAI(DistributedObjectAI, FSM.FSM):
|
||||
notify = DirectNotifyGlobal.directNotify.newCategory("DistributedCogdoInteriorAI")
|
||||
|
||||
|
||||
def __init__(self, air, exterior):
|
||||
DistributedObjectAI.__init__(self, air)
|
||||
FSM.FSM.__init__(self, 'CogdoInteriorAIFSM')
|
||||
|
@ -39,19 +39,16 @@ class DistributedCogdoInteriorAI(DistributedObjectAI, FSM.FSM):
|
|||
self.bldgDoId = exterior.doId
|
||||
self.numFloors = NUM_FLOORS_DICT[exterior.track]
|
||||
self.sosNPC = self.__generateSOS(exterior.difficulty)
|
||||
|
||||
self.shopOwnerNpcId = 0
|
||||
|
||||
self.extZoneId, self.zoneId = exterior.getExteriorAndInteriorZoneId()
|
||||
npcIdList = NPCToons.zone2NpcDict.get(self.zoneId, [])
|
||||
|
||||
|
||||
if len(npcIdList) == 0:
|
||||
self.notify.info('No NPC in taken cogdo at %s' % self.zoneId)
|
||||
|
||||
else:
|
||||
if len(npcIdList) > 1:
|
||||
self.notify.warning('Multiple NPCs in taken cogdo at %s' % self.zoneId)
|
||||
|
||||
|
||||
self.shopOwnerNpcId = npcIdList[0]
|
||||
|
||||
self.gameDone = 0
|
||||
|
@ -63,18 +60,16 @@ class DistributedCogdoInteriorAI(DistributedObjectAI, FSM.FSM):
|
|||
self.planner = self.exterior.planner
|
||||
self.savedByMap = { }
|
||||
self.battle = None
|
||||
|
||||
self.FOType = exterior.track
|
||||
|
||||
self.gameFloor = 1
|
||||
self.battleFloor = 2
|
||||
self.barrelFloor = -1
|
||||
|
||||
|
||||
if self.FOType == 'l':
|
||||
self.battleFloor = 3
|
||||
self.barrelFloor = 2
|
||||
self.topFloor += 1
|
||||
|
||||
|
||||
self.toonSkillPtsGained = { }
|
||||
self.toonExp = { }
|
||||
self.toonOrigQuests = { }
|
||||
|
@ -93,63 +88,63 @@ class DistributedCogdoInteriorAI(DistributedObjectAI, FSM.FSM):
|
|||
self.ignoreResponses = 0
|
||||
self.ignoreElevatorDone = 0
|
||||
self.ignoreReserveJoinDone = 0
|
||||
|
||||
|
||||
def __generateSOS(self, difficulty):
|
||||
g = lambda: random.choice(NPCToons.FOnpcFriends.keys())
|
||||
v = g()
|
||||
|
||||
|
||||
getStars = lambda x: NPCToons.getNPCTrackLevelHpRarity(x)[-1]
|
||||
|
||||
|
||||
maxStars = min(2, int(math.ceil(difficulty / 5.)))
|
||||
minStars = max(0, maxStars - 1)
|
||||
|
||||
|
||||
while not (minStars <= getStars(v) <= maxStars):
|
||||
v = g()
|
||||
|
||||
|
||||
self.notify.info('selected SOS %s (stars = %s)' % (v, getStars(v)))
|
||||
return v
|
||||
|
||||
|
||||
def setZoneId(self, zoneId):
|
||||
self.zoneId = zoneId
|
||||
|
||||
|
||||
def getZoneId(self):
|
||||
return self.zoneId
|
||||
|
||||
def setExtZoneId(self, extZoneId):
|
||||
self.extZoneId = extZoneId
|
||||
|
||||
|
||||
def getExtZoneId(self):
|
||||
return self.extZoneId
|
||||
|
||||
|
||||
def setDistBldgDoId(self, bldgDoId):
|
||||
self.bldgDoId = bldgDoId
|
||||
|
||||
|
||||
def getDistBldgDoId(self):
|
||||
return self.bldgDoId
|
||||
|
||||
def setNumFloors(self, numFloors):
|
||||
self.numFloors = numFloors
|
||||
|
||||
|
||||
def getNumFloors(self):
|
||||
return self.numFloors
|
||||
|
||||
def setShopOwnerNpcId(self, id):
|
||||
self.shopOwnerNpcId = id
|
||||
|
||||
|
||||
def getShopOwnerNpcId(self):
|
||||
return self.shopOwnerNpcId
|
||||
|
||||
|
||||
def setState(self, state, timestamp):
|
||||
self.request(state)
|
||||
|
||||
|
||||
def getState(self):
|
||||
timestamp = globalClockDelta.getRealNetworkTime()
|
||||
return [self.state, timestamp]
|
||||
|
||||
|
||||
def b_setState(self, state):
|
||||
self.setState(state, 0)
|
||||
self.d_setState(state)
|
||||
|
||||
|
||||
def d_setState(self, state):
|
||||
timestamp = globalClockDelta.getRealNetworkTime()
|
||||
self.sendUpdate('setState', [state, timestamp])
|
||||
|
@ -162,35 +157,32 @@ class DistributedCogdoInteriorAI(DistributedObjectAI, FSM.FSM):
|
|||
self.notify.warning('reserveJoinDone() - toon not in list: %d' % toonId)
|
||||
return None
|
||||
self.b_setState('Battle')
|
||||
|
||||
|
||||
def elevatorDone(self):
|
||||
toonId = self.air.getAvatarIdFromSender()
|
||||
if self.ignoreResponses == 1:
|
||||
return None
|
||||
|
||||
elif self.toons.count(toonId) == 0:
|
||||
self.notify.warning('elevatorDone() - toon not in toon list: %d' % toonId)
|
||||
|
||||
|
||||
def enterWaitForAllToonsInside(self):
|
||||
self.resetResponses()
|
||||
|
||||
|
||||
if self.FOType == "s":
|
||||
self.game = DistCogdoMazeGameAI.DistCogdoMazeGameAI(self.air)
|
||||
self.game.setNumSuits(CogdoMazeGameGlobals.NumSuits)
|
||||
|
||||
elif self.FOType == "l":
|
||||
self.game = DistCogdoFlyingGameAI.DistCogdoFlyingGameAI(self.air)
|
||||
|
||||
elif self.FOType == "m":
|
||||
self.game = DistCogdoCraneGameAI.DistCogdoCraneGameAI(self.air)
|
||||
|
||||
self.sendUpdate("setSOSNpcId", [self.sosNPC])
|
||||
self.sendUpdate("setFOType", [ord(self.FOType)])
|
||||
|
||||
|
||||
def resetResponses(self):
|
||||
for toon in self.toons:
|
||||
self.responses[toon] = 0
|
||||
|
||||
|
||||
def setAvatarJoined(self):
|
||||
avId = self.air.getAvatarIdFromSender()
|
||||
self.responses[avId] = 1
|
||||
|
@ -200,15 +192,15 @@ class DistributedCogdoInteriorAI(DistributedObjectAI, FSM.FSM):
|
|||
self.addToon(avId)
|
||||
if self.allToonsJoined():
|
||||
self.request('Elevator')
|
||||
|
||||
|
||||
def addToon(self, avId):
|
||||
if not avId in self.toons:
|
||||
self.toons.append(avId)
|
||||
|
||||
|
||||
if self.air.doId2do.has_key(avId):
|
||||
event = self.air.getAvatarExitEvent(avId)
|
||||
self.accept(event, self.__handleUnexpectedExit, [avId])
|
||||
|
||||
|
||||
def __handleUnexpectedExit(self, avId):
|
||||
self.removeToon(avId)
|
||||
if len(self.toons) == 0:
|
||||
|
@ -216,55 +208,51 @@ class DistributedCogdoInteriorAI(DistributedObjectAI, FSM.FSM):
|
|||
if self.battle:
|
||||
self.battle.requestDelete()
|
||||
self.battle = None
|
||||
|
||||
|
||||
def removeToon(self, avId):
|
||||
if avId in self.toons: self.toons.pop(avId)
|
||||
|
||||
|
||||
def enterElevator(self):
|
||||
self.curFloor += 1
|
||||
self.d_setToons()
|
||||
self.resetResponses()
|
||||
|
||||
|
||||
if self.curFloor == self.gameFloor:
|
||||
self.enterGame()
|
||||
|
||||
|
||||
self.d_setState('Elevator')
|
||||
self.timer.stop()
|
||||
self.timer.startCallback(BattleBase.ELEVATOR_T + ElevatorData[ELEVATOR_NORMAL]['openTime'] + BattleBase.SERVER_BUFFER_TIME, self.serverElevatorDone)
|
||||
|
||||
|
||||
if self.curFloor == self.battleFloor:
|
||||
self.planner.myPrint()
|
||||
suitHandles = self.planner.genFloorSuits(0)
|
||||
|
||||
self.suits = suitHandles['activeSuits']
|
||||
self.activeSuits = self.suits[:]
|
||||
self.reserveSuits = suitHandles['reserveSuits']
|
||||
|
||||
self.d_setSuits()
|
||||
|
||||
|
||||
def exitElevator(self):
|
||||
self.timer.stop()
|
||||
|
||||
|
||||
def serverElevatorDone(self):
|
||||
if self.curFloor == self.gameFloor:
|
||||
self.d_setState('Game')
|
||||
|
||||
elif self.curFloor == self.battleFloor:
|
||||
self.b_setState('BattleIntro')
|
||||
self.timer.startCallback(BATTLE_INTRO_DURATION, self.battleIntroDone)
|
||||
|
||||
else:
|
||||
self.notify.warning('Unknown floor %s (track=%s)' % (self.curFloor, self.FOType))
|
||||
|
||||
|
||||
def battleIntroDone(self):
|
||||
if self.air:
|
||||
self.createBattle()
|
||||
self.b_setState('Battle')
|
||||
|
||||
|
||||
def barrelIntroDone(self):
|
||||
if not self.air:
|
||||
return
|
||||
|
||||
|
||||
self.b_setState('CollectBarrels')
|
||||
for i in xrange(len(CogdoBarrelRoomConsts.BarrelProps)):
|
||||
barrel = DistributedCogdoBarrelAI.DistributedCogdoBarrelAI(self.air, i)
|
||||
|
@ -275,50 +263,44 @@ class DistributedCogdoInteriorAI(DistributedObjectAI, FSM.FSM):
|
|||
def barrelReward(self):
|
||||
if not self.air:
|
||||
return
|
||||
|
||||
|
||||
self.b_setState('BarrelRoomReward')
|
||||
for i in self.barrels:
|
||||
i.requestDelete()
|
||||
self.timer.startCallback(BARREL_ROOM_REWARD_DURATION, self.barrelRewardDone)
|
||||
|
||||
|
||||
def barrelRewardDone(self):
|
||||
if not self.air:
|
||||
return
|
||||
|
||||
barrelPlanner = SuitPlannerCogdoInteriorAI(self.exterior._cogdoLayout, max(0, self.exterior.difficulty - 5),
|
||||
self.FOType, self.exterior.getExteriorAndInteriorZoneId()[1])
|
||||
barrelPlanner.myPrint()
|
||||
suitHandles = barrelPlanner.genFloorSuits(0)
|
||||
|
||||
self.suits = suitHandles['activeSuits']
|
||||
self.activeSuits = self.suits[:]
|
||||
self.reserveSuits = suitHandles['reserveSuits']
|
||||
|
||||
self.d_setSuits()
|
||||
|
||||
self.battleIntroDone()
|
||||
|
||||
|
||||
def handleAllAboard(self, seats):
|
||||
if not hasattr(self, 'air') or not self.air:
|
||||
return None
|
||||
|
||||
|
||||
numOfEmptySeats = seats.count(None)
|
||||
if numOfEmptySeats == 4:
|
||||
self.exterior.deleteSuitInterior()
|
||||
return
|
||||
|
||||
elif not 0 <= numOfEmptySeats <= 3:
|
||||
self.notify.error('Bad number of empty seats: %s' % numOfEmptySeats)
|
||||
|
||||
|
||||
for toon in self.toons:
|
||||
if toon not in seats:
|
||||
self.removeToon(toon)
|
||||
|
||||
|
||||
self.toons = filter(None, seats)
|
||||
self.d_setToons()
|
||||
|
||||
self.request('Elevator')
|
||||
|
||||
|
||||
def enterGame(self):
|
||||
self.game.setToons(self.toons)
|
||||
self.game.setInteriorId(self.doId)
|
||||
|
@ -328,7 +310,7 @@ class DistributedCogdoInteriorAI(DistributedObjectAI, FSM.FSM):
|
|||
self.game.d_startIntro()
|
||||
self.accept(self.game.finishEvent, self.__handleGameDone)
|
||||
self.accept(self.game.gameOverEvent, self.__handleGameOver)
|
||||
|
||||
|
||||
def __handleGameDone(self, toons):
|
||||
self.game.requestDelete()
|
||||
self.gameDone = 1
|
||||
|
@ -341,11 +323,11 @@ class DistributedCogdoInteriorAI(DistributedObjectAI, FSM.FSM):
|
|||
self.timer.startCallback(BARREL_INTRO_DURATION, self.barrelIntroDone)
|
||||
else:
|
||||
self.request('Elevator')
|
||||
|
||||
|
||||
def __handleGameOver(self):
|
||||
self.game.requestDelete()
|
||||
self.exterior.deleteSuitInterior()
|
||||
|
||||
|
||||
def createBattle(self):
|
||||
isBoss = self.curFloor == self.topFloor
|
||||
self.battle = DistributedCogdoBattleBldgAI(self.air, self.zoneId, self.__handleRoundDone, self.__handleBattleDone, bossBattle = isBoss)
|
||||
|
@ -361,11 +343,9 @@ class DistributedCogdoInteriorAI(DistributedObjectAI, FSM.FSM):
|
|||
self.battle.helpfulToons = self.helpfulToons
|
||||
self.battle.setInitialMembers(self.toons, self.suits)
|
||||
self.battle.generateWithRequired(self.zoneId)
|
||||
|
||||
mult = getCreditMultiplier(self.curFloor)
|
||||
|
||||
self.battle.battleCalc.setSkillCreditMultiplier(self.battle.battleCalc.getSkillCreditMultiplier() * mult)
|
||||
|
||||
|
||||
def enterBattleDone(self, toonIds):
|
||||
toonIds = toonIds[0]
|
||||
if len(toonIds) != len(self.toons):
|
||||
|
@ -374,49 +354,46 @@ class DistributedCogdoInteriorAI(DistributedObjectAI, FSM.FSM):
|
|||
if toonIds.count(toon) == 0:
|
||||
deadToons.append(toon)
|
||||
continue
|
||||
|
||||
for toon in deadToons:
|
||||
self.removeToon(toon)
|
||||
|
||||
|
||||
self.d_setToons()
|
||||
if len(self.toons) == 0:
|
||||
self.exterior.deleteSuitInterior()
|
||||
|
||||
elif self.curFloor == self.topFloor:
|
||||
self.battle.resume(self.curFloor, topFloor = 1)
|
||||
|
||||
else:
|
||||
self.battle.resume(self.curFloor, topFloor = 0)
|
||||
|
||||
|
||||
def __doDeleteInterior(self, task):
|
||||
self.exterior.deleteSuitInterior()
|
||||
return task.done
|
||||
|
||||
|
||||
def exitBattleDone(self):
|
||||
self.cleanupFloorBattle()
|
||||
|
||||
|
||||
def cleanupFloorBattle(self):
|
||||
for suit in self.suits:
|
||||
if suit.isDeleted():
|
||||
continue
|
||||
suit.requestDelete()
|
||||
|
||||
|
||||
self.suits = []
|
||||
self.reserveSuits = []
|
||||
self.activeSuits = []
|
||||
if self.battle != None:
|
||||
self.battle.requestDelete()
|
||||
|
||||
|
||||
self.battle = None
|
||||
|
||||
|
||||
def __handleRoundDone(self, toonIds, totalHp, deadSuits):
|
||||
totalMaxHp = 0
|
||||
for suit in self.suits:
|
||||
totalMaxHp += suit.maxHP
|
||||
|
||||
|
||||
for suit in deadSuits:
|
||||
self.activeSuits.remove(suit)
|
||||
|
||||
|
||||
if len(self.reserveSuits) > 0 and len(self.activeSuits) < 4:
|
||||
self.joinedReserves = []
|
||||
hpPercent = 100 - (totalHp / totalMaxHp) * 100.0
|
||||
|
@ -426,21 +403,21 @@ class DistributedCogdoInteriorAI(DistributedObjectAI, FSM.FSM):
|
|||
self.activeSuits.append(info[0])
|
||||
self.joinedReserves.append(info)
|
||||
continue
|
||||
|
||||
|
||||
for info in self.joinedReserves:
|
||||
self.reserveSuits.remove(info)
|
||||
|
||||
|
||||
if len(self.joinedReserves) > 0:
|
||||
self.d_setSuits()
|
||||
self.request('ReservesJoining')
|
||||
return
|
||||
|
||||
|
||||
if len(self.activeSuits) == 0:
|
||||
self.request('BattleDone', [
|
||||
toonIds])
|
||||
else:
|
||||
self.battle.resume()
|
||||
|
||||
|
||||
def enterReservesJoining(self):
|
||||
self.resetResponses()
|
||||
self.timer.startCallback(ElevatorData[ELEVATOR_NORMAL]['openTime'] + SUIT_HOLD_ELEVATOR_TIME + BattleBase.SERVER_BUFFER_TIME, self.serverReserveJoinDone)
|
||||
|
@ -450,14 +427,14 @@ class DistributedCogdoInteriorAI(DistributedObjectAI, FSM.FSM):
|
|||
self.resetResponses()
|
||||
for info in self.joinedReserves:
|
||||
self.battle.suitRequestJoin(info[0])
|
||||
|
||||
|
||||
self.battle.resume()
|
||||
self.joinedReserves = []
|
||||
|
||||
|
||||
def serverReserveJoinDone(self):
|
||||
self.ignoreReserveJoinDone = 1
|
||||
self.b_setState('Battle')
|
||||
|
||||
|
||||
def __handleBattleDone(self, zoneId, toonIds):
|
||||
if len(toonIds) == 0:
|
||||
taskMgr.doMethodLater(10, self.__doDeleteInterior, self.taskName('deleteInterior'))
|
||||
|
@ -465,14 +442,14 @@ class DistributedCogdoInteriorAI(DistributedObjectAI, FSM.FSM):
|
|||
self.request('Reward')
|
||||
else:
|
||||
self.b_setState('Resting')
|
||||
|
||||
|
||||
def enterResting(self):
|
||||
self.intElevator = DistributedCogdoElevatorIntAI.DistributedCogdoElevatorIntAI(self.air, self, self.toons)
|
||||
self.intElevator.generateWithRequired(self.zoneId)
|
||||
|
||||
|
||||
def exitResting(self):
|
||||
self.intElevator.requestDelete()
|
||||
|
||||
|
||||
def enterReward(self):
|
||||
victors = self.toons[:]
|
||||
savedBy = []
|
||||
|
@ -483,54 +460,52 @@ class DistributedCogdoInteriorAI(DistributedObjectAI, FSM.FSM):
|
|||
v,
|
||||
tuple[0],
|
||||
tuple[1]])
|
||||
|
||||
|
||||
toon = self.air.doId2do.get(v)
|
||||
if toon:
|
||||
if self.FOType == 's':
|
||||
if not toon.attemptAddNPCFriend(self.sosNPC):
|
||||
self.notify.info('%s unable to add NPCFriend %s to %s.' % (self.doId, self.sosNPC, v))
|
||||
|
||||
elif self.FOType == 'l':
|
||||
reward = self.getEmblemsReward()
|
||||
toon.addEmblems(reward)
|
||||
|
||||
else:
|
||||
self.notify.warning('%s unable to reward %s: unknown reward for track %s' % (self.doId, v, self.FOType))
|
||||
|
||||
|
||||
self.exterior.fsm.request('waitForVictorsFromCogdo', [
|
||||
victors,
|
||||
savedBy])
|
||||
self.d_setState('Reward')
|
||||
|
||||
|
||||
def removeToon(self, toonId):
|
||||
if self.toons.count(toonId):
|
||||
self.toons.remove(toonId)
|
||||
|
||||
|
||||
def d_setToons(self):
|
||||
self.sendUpdate('setToons', self.getToons())
|
||||
|
||||
|
||||
def getToons(self):
|
||||
return [self.toons, 0]
|
||||
|
||||
|
||||
def d_setSuits(self):
|
||||
self.sendUpdate('setSuits', self.getSuits())
|
||||
|
||||
|
||||
def getSuits(self):
|
||||
suitIds = []
|
||||
for suit in self.activeSuits:
|
||||
suitIds.append(suit.doId)
|
||||
|
||||
|
||||
reserveIds = []
|
||||
values = []
|
||||
for info in self.reserveSuits:
|
||||
reserveIds.append(info[0].doId)
|
||||
values.append(info[1])
|
||||
|
||||
|
||||
return [
|
||||
suitIds,
|
||||
reserveIds,
|
||||
values]
|
||||
|
||||
|
||||
def allToonsJoined(self):
|
||||
for toon in self.toons:
|
||||
if self.responses[toon] == 0:
|
||||
|
@ -540,20 +515,19 @@ class DistributedCogdoInteriorAI(DistributedObjectAI, FSM.FSM):
|
|||
def delete(self):
|
||||
DistributedObjectAI.delete(self)
|
||||
self.timer.stop()
|
||||
|
||||
|
||||
def getEmblemsReward(self):
|
||||
hoodIdMap = {2: .5, # ttc
|
||||
1: 1., # dd
|
||||
5: 1.5, # dg
|
||||
4: 2., # mm
|
||||
3: 2.7, # br
|
||||
9: 3.5, # dl
|
||||
7: 4 # ff
|
||||
hoodIdMap = {2: .5, # Toontown Central
|
||||
1: 1., # Donald's Dock
|
||||
5: 1.5, # Daisy Gardens
|
||||
4: 2., # Minnie's Melodyland
|
||||
3: 2.7, # The Brrrgh
|
||||
9: 3.5, # Donald's Dreamland
|
||||
7: 4 # Funny Farm
|
||||
}
|
||||
|
||||
|
||||
hoodValue = hoodIdMap[int(self.exterior.zoneId // 1000)]
|
||||
diff = max(self.exterior.difficulty, 1)
|
||||
memos = self.game.getTotalMemos()
|
||||
|
||||
E = (hoodValue * max(memos, 1) * diff) / 2.5
|
||||
return divmod(E, 100)[::-1]
|
||||
|
|
|
@ -18,10 +18,10 @@ MAX_RESERVES = {
|
|||
def filterReviveChance(track, revive):
|
||||
if revive >= 0:
|
||||
return revive
|
||||
|
||||
|
||||
return random.randint(config.GetInt('min-lt-vs', 0), config.GetInt('max-lt-vs', 2))
|
||||
# implements difficulty 19 / LT
|
||||
|
||||
# Implements difficulty 19 / LT.
|
||||
|
||||
def getMaxReserves(track):
|
||||
return int(math.ceil(MAX_RESERVES[track]))
|
||||
|
||||
|
@ -32,13 +32,12 @@ class SuitPlannerCogdoInteriorAI:
|
|||
self.zoneId = zoneId
|
||||
self.numFloors = layout.getNumFloors()
|
||||
difficulty = min(difficulty + 4, len(SuitBuildingGlobals.SuitBuildingInfo) - 1)
|
||||
|
||||
self.respectInvasions = 1
|
||||
|
||||
|
||||
if isinstance(difficulty, types.StringType):
|
||||
self.notify.warning('difficulty is a string!')
|
||||
difficulty = int(difficulty)
|
||||
|
||||
|
||||
self._genSuitInfos(numFloors, difficulty, track)
|
||||
|
||||
def __genJoinChances(self, num):
|
||||
|
@ -57,28 +56,26 @@ class SuitPlannerCogdoInteriorAI:
|
|||
lvls = self.__genLevelList(difficulty, currFloor, numFloors)
|
||||
activeDicts = []
|
||||
numActive = random.randint(1, min(4, len(lvls)))
|
||||
|
||||
|
||||
if currFloor + 1 == numFloors and len(lvls) > 1:
|
||||
origBossSpot = len(lvls) - 1
|
||||
|
||||
|
||||
if numActive == 1:
|
||||
newBossSpot = numActive - 1
|
||||
|
||||
else:
|
||||
newBossSpot = numActive - 2
|
||||
|
||||
|
||||
tmp = lvls[newBossSpot]
|
||||
lvls[newBossSpot] = lvls[origBossSpot]
|
||||
lvls[origBossSpot] = tmp
|
||||
|
||||
|
||||
bldgInfo = SuitBuildingGlobals.SuitBuildingInfo[difficulty]
|
||||
|
||||
|
||||
if len(bldgInfo) > SuitBuildingGlobals.SUIT_BLDG_INFO_REVIVES:
|
||||
revives = bldgInfo[SuitBuildingGlobals.SUIT_BLDG_INFO_REVIVES][0]
|
||||
|
||||
else:
|
||||
revives = 0
|
||||
|
||||
|
||||
for currActive in range(numActive - 1, -1, -1):
|
||||
level = lvls[currActive]
|
||||
type = self.__genNormalSuitType(level)
|
||||
|
@ -172,18 +169,18 @@ class SuitPlannerCogdoInteriorAI:
|
|||
|
||||
for floor, currInfo in enumerate(self.suitInfos):
|
||||
floor += 1
|
||||
|
||||
|
||||
actives = currInfo['activeSuits']
|
||||
reserves = currInfo['reserveSuits']
|
||||
|
||||
|
||||
print ' Floor %d has %d active suits.' % (floor, len(actives))
|
||||
print ' Floor %d has %d reserve suits.' % (floor, len(reserves))
|
||||
|
||||
|
||||
for idx, currActive in enumerate(actives):
|
||||
type, track, level, revives = map(lambda x: currActive[x], ('type', 'track', 'level', 'revives'))
|
||||
|
||||
|
||||
print '-- Active suit %d is %s, %s and level %d and revives is %d' % (idx, type, track, level, revives)
|
||||
|
||||
|
||||
for idx, currReserve in enumerate(reserves):
|
||||
type, track, level, revives, res = map(lambda x: currReserve[x], ('type', 'track', 'level', 'revives', 'joinChance'))
|
||||
print '- Reserve suit %d is %s, %s and level %d and JC = %d and revives is %d' % (idx, type, track, level, res, revives)
|
||||
|
|
Loading…
Reference in a new issue