Cleanup many Cogdo files.

This commit is contained in:
John Cote 2015-04-27 19:51:51 -04:00
parent e7b0cb751a
commit cc33dee614
23 changed files with 204 additions and 283 deletions

View file

@ -3,4 +3,3 @@ from toontown.cogdominium.DistCogdoLevelGameAI import DistCogdoLevelGameAI
class DistCogdoBoardroomGameAI(DistCogdoLevelGameAI):
notify = DirectNotifyGlobal.directNotify.newCategory("DistCogdoBoardroomGameAI")

View file

@ -18,4 +18,3 @@ class DistCogdoCraneAI(DistributedObjectAI):
def setCablePos(self, todo0, todo1, todo2, todo3, todo4):
pass

View file

@ -12,4 +12,3 @@ class DistCogdoCraneCogAI(DistributedObjectAI):
def setSpawnInfo(self, todo0, todo1):
pass

View file

@ -25,14 +25,12 @@ class DistCogdoCraneGameAI(DistCogdoLevelGameAI, CogdoCraneGameBase):
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):

View file

@ -9,4 +9,3 @@ class DistCogdoCraneMoneyBagAI(DistributedObjectAI):
def requestInitial(self):
pass

View file

@ -23,49 +23,38 @@ class DistCogdoFlyingGameAI(DistCogdoGameAI):
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)
@ -79,10 +68,8 @@ class DistCogdoFlyingGameAI(DistCogdoGameAI):
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)
@ -125,4 +112,3 @@ def endFly():
game = simbase.air.cogdoGame
game.requestAction(Globals.AI.GameActions.LandOnWinPlatform, 0)
return 'Finished cogdo flying game!'

View file

@ -18,10 +18,8 @@ class DistCogdoGameAI(DistributedObjectAI):
def announceGenerate(self):
DistributedObjectAI.announceGenerate(self)
self.finishEvent = self.uniqueName('CogdoMazeGameDone')
self.gameOverEvent = self.uniqueName('CogdoMazeGameLose')
self.resetRequests()
def d_startIntro(self):
@ -105,4 +103,3 @@ class DistCogdoGameAI(DistributedObjectAI):
def getSafezoneId(self):
return CogdoGameConsts.getSafezoneId(self.exteriorZone)

View file

@ -1,5 +1,4 @@
class DistCogdoGameBase:
def local2GameTime(self, timestamp):

View file

@ -4,4 +4,3 @@ from otp.level.DistributedLevelAI import DistributedLevelAI
class DistCogdoLevelGameAI(DistCogdoGameAI, DistributedLevelAI):
notify = DirectNotifyGlobal.directNotify.newCategory("DistCogdoLevelGameAI")

View file

@ -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
@ -92,7 +92,6 @@ class DistCogdoMazeGameAI(DistCogdoGameAI):
if avId in self.numJokes:
self.numJokes[avId] += 1
else:
self.numJokes[avId] = 1
@ -140,7 +139,6 @@ class DistCogdoMazeGameAI(DistCogdoGameAI):
self.doAction(CogdoMazeGameGlobals.GameActions.OpenDoor, 0)
self.__startTimeout()
return task.done
return task.again
def __startTimeout(self):
@ -150,7 +148,6 @@ class DistCogdoMazeGameAI(DistCogdoGameAI):
for toon in self.toons:
if not toon in self.toonsInDoor:
self.killToon(toon)
self.removeAll()
self.gameDone()
@ -158,7 +155,6 @@ class DistCogdoMazeGameAI(DistCogdoGameAI):
if self.timer.getT() <= CogdoMazeGameGlobals.SecondsForTimeAlert:
self.doAction(CogdoMazeGameGlobals.GameActions.TimeAlert, 0)
return task.done
return task.again
def killToon(self, avId):
@ -174,7 +170,6 @@ class DistCogdoMazeGameAI(DistCogdoGameAI):
toon = self.air.doId2do.get(toonId)
if not toon:
self.__playerDisconnected(toonId)
return task.again
def __playerDisconnected(self, avId):
@ -194,23 +189,19 @@ 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)

View file

@ -32,5 +32,4 @@ class DistributedCogdoBarrelAI(DistributedObjectAI.DistributedObjectAI):
av = self.air.doId2do.get(avId)
if not av:
return
av.toonUp(self.brLaff)

View file

@ -3,4 +3,3 @@ from toontown.battle.DistributedBattleBldgAI import DistributedBattleBldgAI
class DistributedCogdoBattleBldgAI(DistributedBattleBldgAI):
notify = DirectNotifyGlobal.directNotify.newCategory("DistributedCogdoBattleBldgAI")

View file

@ -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 *
@ -13,10 +11,8 @@ class DistributedCogdoElevatorExt(DistributedElevatorExt):
def getElevatorModel(self):
return self.bldg.getCogdoElevatorNodePath()
def getBldgDoorOrigin(self):
return self.bldg.getCogdoDoorOrigin()
def _getDoorsClosedInfo(self):
return ('cogdoInterior', 'cogdoInterior')

View file

@ -1,5 +1,3 @@
# File: D (Python 2.4)
from direct.directnotify import DirectNotifyGlobal
from toontown.building.DistributedElevatorExtAI import DistributedElevatorExtAI
@ -8,5 +6,3 @@ class DistributedCogdoElevatorExtAI(DistributedElevatorExtAI):
def _createInterior(self):
self.bldg.createCogdoInterior()

View file

@ -3,4 +3,3 @@ from toontown.building.DistributedElevatorIntAI import DistributedElevatorIntAI
class DistributedCogdoElevatorIntAI(DistributedElevatorIntAI):
notify = DirectNotifyGlobal.directNotify.newCategory("DistributedCogdoElevatorIntAI")

View file

@ -344,11 +344,10 @@ class DistributedCogdoInterior(DistributedObject.DistributedObject):
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)
@ -468,7 +467,6 @@ class DistributedCogdoInterior(DistributedObject.DistributedObject):
SuitHs = self.BossOffice_SuitHs
SuitPositions = self.BossOffice_SuitPositions
self.__makeShopOwnerNpc()
else:
if self._wantBarrelRoom:
self.barrelRoom.load()
@ -494,18 +492,15 @@ class DistributedCogdoInterior(DistributedObject.DistributedObject):
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)

View file

@ -39,15 +39,12 @@ 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)
@ -63,9 +60,7 @@ 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
@ -167,7 +162,6 @@ class DistributedCogdoInteriorAI(DistributedObjectAI, FSM.FSM):
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)
@ -177,10 +171,8 @@ class DistributedCogdoInteriorAI(DistributedObjectAI, FSM.FSM):
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)
@ -235,11 +227,9 @@ class DistributedCogdoInteriorAI(DistributedObjectAI, FSM.FSM):
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):
@ -248,11 +238,9 @@ class DistributedCogdoInteriorAI(DistributedObjectAI, FSM.FSM):
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))
@ -284,18 +272,14 @@ class DistributedCogdoInteriorAI(DistributedObjectAI, FSM.FSM):
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):
@ -306,7 +290,6 @@ class DistributedCogdoInteriorAI(DistributedObjectAI, FSM.FSM):
if numOfEmptySeats == 4:
self.exterior.deleteSuitInterior()
return
elif not 0 <= numOfEmptySeats <= 3:
self.notify.error('Bad number of empty seats: %s' % numOfEmptySeats)
@ -316,7 +299,6 @@ class DistributedCogdoInteriorAI(DistributedObjectAI, FSM.FSM):
self.toons = filter(None, seats)
self.d_setToons()
self.request('Elevator')
def enterGame(self):
@ -361,9 +343,7 @@ 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):
@ -374,17 +354,14 @@ 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)
@ -489,11 +466,9 @@ class DistributedCogdoInteriorAI(DistributedObjectAI, FSM.FSM):
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))
@ -542,18 +517,17 @@ class DistributedCogdoInteriorAI(DistributedObjectAI, FSM.FSM):
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]

View file

@ -20,7 +20,7 @@ def filterReviveChance(track, revive):
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,7 +32,6 @@ 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):
@ -63,7 +62,6 @@ class SuitPlannerCogdoInteriorAI:
if numActive == 1:
newBossSpot = numActive - 1
else:
newBossSpot = numActive - 2
@ -75,7 +73,6 @@ class SuitPlannerCogdoInteriorAI:
if len(bldgInfo) > SuitBuildingGlobals.SUIT_BLDG_INFO_REVIVES:
revives = bldgInfo[SuitBuildingGlobals.SUIT_BLDG_INFO_REVIVES][0]
else:
revives = 0