coghq: Lawbot HQ with DA offices and CJ
This commit is contained in:
parent
b0d30b4054
commit
1d08c31de1
22 changed files with 2518 additions and 256 deletions
|
@ -9,7 +9,7 @@ from toontown.ai.FishManagerAI import FishManagerAI
|
|||
from toontown.distributed.ToontownInternalRepository import ToontownInternalRepository
|
||||
from toontown.toon import NPCToons
|
||||
from toontown.hood import TTHoodAI, DDHoodAI, DGHoodAI, BRHoodAI, MMHoodAI, DLHoodAI, OZHoodAI, GSHoodAI, GZHoodAI, ZoneUtil
|
||||
from toontown.hood import SellbotHQAI, CashbotHQAI
|
||||
from toontown.hood import SellbotHQAI, CashbotHQAI, LawbotHQAI
|
||||
from toontown.toonbase import ToontownGlobals
|
||||
from direct.distributed.PyDatagram import *
|
||||
from otp.ai.AIZoneData import *
|
||||
|
@ -44,6 +44,7 @@ from toontown.building.DistributedTrophyMgrAI import DistributedTrophyMgrAI
|
|||
from toontown.shtiker.CogPageManagerAI import CogPageManagerAI
|
||||
from toontown.coghq.FactoryManagerAI import FactoryManagerAI
|
||||
from toontown.coghq.MintManagerAI import MintManagerAI
|
||||
from toontown.coghq.LawOfficeManagerAI import LawOfficeManagerAI
|
||||
from toontown.coghq.PromotionManagerAI import PromotionManagerAI
|
||||
from toontown.coghq.CogSuitManagerAI import CogSuitManagerAI
|
||||
|
||||
|
@ -79,6 +80,7 @@ class ToontownAIRepository(ToontownInternalRepository):
|
|||
self.cogPageManager = CogPageManagerAI()
|
||||
self.factoryMgr = FactoryManagerAI(self)
|
||||
self.mintMgr = MintManagerAI(self)
|
||||
self.lawOfficeMgr = LawOfficeManagerAI(self)
|
||||
self.promotionMgr = PromotionManagerAI(self)
|
||||
self.cogSuitMgr = CogSuitManagerAI(self)
|
||||
self.suitInvasionManager = SuitInvasionManagerAI(self)
|
||||
|
@ -198,6 +200,8 @@ class ToontownAIRepository(ToontownInternalRepository):
|
|||
clearQueue()
|
||||
self.hoods.append(CashbotHQAI.CashbotHQAI(self))
|
||||
clearQueue()
|
||||
self.hoods.append(LawbotHQAI.LawbotHQAI(self))
|
||||
clearQueue()
|
||||
|
||||
for sp in self.suitPlanners.values():
|
||||
sp.assignInitialSuitBuildings()
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
from direct.directnotify import DirectNotifyGlobal
|
||||
from toontown.building.DistributedBossElevatorAI import DistributedBossElevatorAI
|
||||
from ElevatorConstants import *
|
||||
import DistributedBossElevatorAI
|
||||
|
||||
class DistributedCJElevatorAI(DistributedBossElevatorAI):
|
||||
notify = DirectNotifyGlobal.directNotify.newCategory("DistributedCJElevatorAI")
|
||||
class DistributedCJElevatorAI(DistributedBossElevatorAI.DistributedBossElevatorAI):
|
||||
|
||||
def __init__(self, air, bldg, zone, antiShuffle = 0, minLaff = 0):
|
||||
DistributedBossElevatorAI.DistributedBossElevatorAI.__init__(self, air, bldg, zone, antiShuffle=antiShuffle, minLaff=0)
|
||||
self.type = ELEVATOR_CJ
|
||||
self.countdownTime = ElevatorData[self.type]['countdown']
|
||||
|
|
|
@ -1,78 +1,284 @@
|
|||
from otp.ai.AIBase import *
|
||||
from toontown.toonbase import ToontownGlobals
|
||||
from direct.distributed.ClockDelta import *
|
||||
from ElevatorConstants import *
|
||||
from direct.distributed import DistributedObjectAI
|
||||
from direct.task import Task
|
||||
from direct.directnotify import DirectNotifyGlobal
|
||||
from direct.distributed.DistributedObjectAI import DistributedObjectAI
|
||||
from direct.fsm.FSM import FSM
|
||||
|
||||
class DistributedElevatorFSMAI(DistributedObjectAI):
|
||||
notify = DirectNotifyGlobal.directNotify.newCategory("DistributedElevatorFSMAI")
|
||||
class DistributedElevatorFSMAI(DistributedObjectAI.DistributedObjectAI, FSM):
|
||||
notify = DirectNotifyGlobal.directNotify.newCategory('DistributedElevatorFSMAI')
|
||||
defaultTransitions = {'Off': ['Opening', 'Closed'],
|
||||
'Opening': ['WaitEmpty',
|
||||
'WaitCountdown',
|
||||
'Opening',
|
||||
'Closing'],
|
||||
'WaitEmpty': ['WaitCountdown', 'Closing'],
|
||||
'WaitCountdown': ['WaitEmpty', 'AllAboard', 'Closing'],
|
||||
'AllAboard': ['WaitEmpty', 'Closing'],
|
||||
'Closing': ['Closed',
|
||||
'WaitEmpty',
|
||||
'Closing',
|
||||
'Opening'],
|
||||
'Closed': ['Opening']}
|
||||
id = 0
|
||||
|
||||
def setBldgDoId(self, todo0):
|
||||
def __init__(self, air, bldg, numSeats = 4, antiShuffle = 0, minLaff = 0):
|
||||
DistributedObjectAI.DistributedObjectAI.__init__(self, air)
|
||||
FSM.__init__(self, 'Elevator_%s_FSM' % self.id)
|
||||
self.type = ELEVATOR_NORMAL
|
||||
self.countdownTime = ElevatorData[self.type]['countdown']
|
||||
self.bldg = bldg
|
||||
self.bldgDoId = bldg.getDoId()
|
||||
self.seats = []
|
||||
for seat in range(numSeats):
|
||||
self.seats.append(None)
|
||||
|
||||
self.accepting = 0
|
||||
self.setAntiShuffle(antiShuffle)
|
||||
self.setMinLaff(minLaff)
|
||||
if self.antiShuffle:
|
||||
if not hasattr(simbase.air, 'elevatorTripId'):
|
||||
simbase.air.elevatorTripId = 1
|
||||
self.elevatorTripId = simbase.air.elevatorTripId
|
||||
simbase.air.elevatorTripId += 1
|
||||
else:
|
||||
self.elevatorTripId = 0
|
||||
return
|
||||
|
||||
def delete(self):
|
||||
del self.bldg
|
||||
self.ignoreAll()
|
||||
DistributedObjectAI.DistributedObjectAI.delete(self)
|
||||
|
||||
def generate(self):
|
||||
DistributedObjectAI.DistributedObjectAI.generate(self)
|
||||
self.start()
|
||||
|
||||
def getBldgDoId(self):
|
||||
return self.bldgDoId
|
||||
|
||||
def findAvailableSeat(self):
|
||||
for i in range(len(self.seats)):
|
||||
if self.seats[i] == None:
|
||||
return i
|
||||
|
||||
return
|
||||
|
||||
def findAvatar(self, avId):
|
||||
for i in range(len(self.seats)):
|
||||
if self.seats[i] == avId:
|
||||
return i
|
||||
|
||||
return None
|
||||
|
||||
def countFullSeats(self):
|
||||
avCounter = 0
|
||||
for i in self.seats:
|
||||
if i:
|
||||
avCounter += 1
|
||||
|
||||
return avCounter
|
||||
|
||||
def countOpenSeats(self):
|
||||
openSeats = 0
|
||||
for i in range(len(self.seats)):
|
||||
if self.seats[i] == None:
|
||||
openSeats += 1
|
||||
|
||||
return openSeats
|
||||
|
||||
def rejectingBoardersHandler(self, avId, reason = 0):
|
||||
self.rejectBoarder(avId, reason)
|
||||
|
||||
def rejectBoarder(self, avId, reason = 0):
|
||||
self.sendUpdateToAvatarId(avId, 'rejectBoard', [avId, reason])
|
||||
|
||||
def acceptingBoardersHandler(self, avId, reason = 0):
|
||||
self.notify.debug('acceptingBoardersHandler')
|
||||
seatIndex = self.findAvailableSeat()
|
||||
if seatIndex == None:
|
||||
self.rejectBoarder(avId, REJECT_NOSEAT)
|
||||
else:
|
||||
self.acceptBoarder(avId, seatIndex)
|
||||
return
|
||||
|
||||
def acceptBoarder(self, avId, seatIndex):
|
||||
self.notify.debug('acceptBoarder')
|
||||
if self.findAvatar(avId) != None:
|
||||
return
|
||||
self.seats[seatIndex] = avId
|
||||
self.timeOfBoarding = globalClock.getRealTime()
|
||||
self.sendUpdate('fillSlot' + str(seatIndex), [avId])
|
||||
return
|
||||
|
||||
def rejectingExitersHandler(self, avId):
|
||||
self.rejectExiter(avId)
|
||||
|
||||
def rejectExiter(self, avId):
|
||||
pass
|
||||
|
||||
def setState(self, todo0, todo1):
|
||||
def acceptingExitersHandler(self, avId):
|
||||
self.acceptExiter(avId)
|
||||
|
||||
def clearEmptyNow(self, seatIndex):
|
||||
self.sendUpdate('emptySlot' + str(seatIndex), [0, 0, globalClockDelta.getRealNetworkTime()])
|
||||
|
||||
def clearFullNow(self, seatIndex):
|
||||
avId = self.seats[seatIndex]
|
||||
if avId == None:
|
||||
self.notify.warning('Clearing an empty seat index: ' + str(seatIndex) + ' ... Strange...')
|
||||
else:
|
||||
self.seats[seatIndex] = None
|
||||
self.sendUpdate('fillSlot' + str(seatIndex), [0])
|
||||
self.ignore(self.air.getAvatarExitEvent(avId))
|
||||
return
|
||||
|
||||
def d_setState(self, state):
|
||||
self.sendUpdate('setState', [state, globalClockDelta.getRealNetworkTime()])
|
||||
|
||||
def getState(self):
|
||||
return self.state
|
||||
|
||||
def avIsOKToBoard(self, av):
|
||||
return av.hp > self.minLaff and self.accepting
|
||||
|
||||
def checkBoard(self, av):
|
||||
if av.hp < self.minLaff:
|
||||
return REJECT_MINLAFF
|
||||
return 0
|
||||
|
||||
def requestBoard(self, *args):
|
||||
self.notify.debug('requestBoard')
|
||||
avId = self.air.getAvatarIdFromSender()
|
||||
if self.findAvatar(avId) != None:
|
||||
self.notify.warning('Ignoring multiple requests from %s to board.' % avId)
|
||||
return
|
||||
av = self.air.doId2do.get(avId)
|
||||
if av:
|
||||
newArgs = (avId,) + args
|
||||
boardResponse = self.checkBoard(av)
|
||||
newArgs = (avId,) + args + (boardResponse,)
|
||||
if boardResponse == 0:
|
||||
self.acceptingBoardersHandler(*newArgs)
|
||||
else:
|
||||
self.rejectingBoardersHandler(*newArgs)
|
||||
else:
|
||||
self.notify.warning('avid: %s does not exist, but tried to board an elevator' % avId)
|
||||
return
|
||||
|
||||
def requestExit(self, *args):
|
||||
if hasattr(self, 'air'):
|
||||
self.notify.debug('requestExit')
|
||||
avId = self.air.getAvatarIdFromSender()
|
||||
av = self.air.doId2do.get(avId)
|
||||
if av:
|
||||
newArgs = (avId,) + args
|
||||
if self.accepting:
|
||||
self.acceptingExitersHandler(*newArgs)
|
||||
else:
|
||||
self.rejectingExitersHandler(*newArgs)
|
||||
else:
|
||||
self.notify.warning('avId: %s does not exist, but tried to exit an elevator' % avId)
|
||||
|
||||
def start(self):
|
||||
self.open()
|
||||
|
||||
def enterOff(self):
|
||||
self.accepting = 0
|
||||
self.timeOfBoarding = None
|
||||
if hasattr(self, 'doId'):
|
||||
for seatIndex in range(len(self.seats)):
|
||||
taskMgr.remove(self.uniqueName('clearEmpty-' + str(seatIndex)))
|
||||
|
||||
return
|
||||
|
||||
def exitOff(self):
|
||||
self.accepting = 0
|
||||
|
||||
def open(self):
|
||||
self.request('Opening')
|
||||
|
||||
def enterOpening(self):
|
||||
self.d_setState('Opening')
|
||||
self.accepting = 0
|
||||
for seat in self.seats:
|
||||
seat = None
|
||||
|
||||
return
|
||||
|
||||
def exitOpening(self):
|
||||
self.accepting = 0
|
||||
taskMgr.remove(self.uniqueName('opening-timer'))
|
||||
|
||||
def enterWaitCountdown(self):
|
||||
self.d_setState('WaitCountdown')
|
||||
self.accepting = 1
|
||||
|
||||
def exitWaitCountdown(self):
|
||||
print 'exit wait countdown'
|
||||
self.accepting = 0
|
||||
taskMgr.remove(self.uniqueName('countdown-timer'))
|
||||
self.newTrip()
|
||||
|
||||
def enterAllAboard(self):
|
||||
self.accepting = 0
|
||||
|
||||
def exitAllAboard(self):
|
||||
self.accepting = 0
|
||||
taskMgr.remove(self.uniqueName('waitForAllAboard'))
|
||||
|
||||
def enterClosing(self):
|
||||
self.d_setState('Closing')
|
||||
self.accepting = 0
|
||||
|
||||
def exitClosing(self):
|
||||
self.accepting = 0
|
||||
taskMgr.remove(self.uniqueName('closing-timer'))
|
||||
|
||||
def enterClosed(self):
|
||||
if hasattr(self, 'doId'):
|
||||
print self.doId
|
||||
self.d_setState('Closed')
|
||||
|
||||
def exitClosed(self):
|
||||
pass
|
||||
|
||||
def fillSlot0(self, todo0):
|
||||
pass
|
||||
def enterWaitEmpty(self):
|
||||
for i in range(len(self.seats)):
|
||||
self.seats[i] = None
|
||||
|
||||
def fillSlot1(self, todo0):
|
||||
pass
|
||||
print self.seats
|
||||
self.d_setState('WaitEmpty')
|
||||
self.accepting = 1
|
||||
return
|
||||
|
||||
def fillSlot2(self, todo0):
|
||||
pass
|
||||
def exitWaitEmpty(self):
|
||||
self.accepting = 0
|
||||
|
||||
def fillSlot3(self, todo0):
|
||||
pass
|
||||
def setElevatorTripId(self, id):
|
||||
self.elevatorTripId = id
|
||||
|
||||
def fillSlot4(self, todo0):
|
||||
pass
|
||||
def getElevatorTripId(self):
|
||||
return self.elevatorTripId
|
||||
|
||||
def fillSlot5(self, todo0):
|
||||
pass
|
||||
def newTrip(self):
|
||||
if self.antiShuffle:
|
||||
self.elevatorTripId = simbase.air.elevatorTripId
|
||||
if simbase.air.elevatorTripId > 2100000000:
|
||||
simbase.air.elevatorTripId = 1
|
||||
simbase.air.elevatorTripId += 1
|
||||
self.sendUpdate('setElevatorTripId', [self.elevatorTripId])
|
||||
|
||||
def fillSlot6(self, todo0):
|
||||
pass
|
||||
def setAntiShuffle(self, antiShuffle):
|
||||
self.antiShuffle = antiShuffle
|
||||
|
||||
def fillSlot7(self, todo0):
|
||||
pass
|
||||
def getAntiShuffle(self):
|
||||
return self.antiShuffle
|
||||
|
||||
def emptySlot0(self, todo0, todo1, todo2):
|
||||
pass
|
||||
|
||||
def emptySlot1(self, todo0, todo1, todo2):
|
||||
pass
|
||||
|
||||
def emptySlot2(self, todo0, todo1, todo2):
|
||||
pass
|
||||
|
||||
def emptySlot3(self, todo0, todo1, todo2):
|
||||
pass
|
||||
|
||||
def emptySlot4(self, todo0, todo1, todo2):
|
||||
pass
|
||||
|
||||
def emptySlot5(self, todo0, todo1, todo2):
|
||||
pass
|
||||
|
||||
def emptySlot6(self, todo0, todo1, todo2):
|
||||
pass
|
||||
|
||||
def emptySlot7(self, todo0, todo1, todo2):
|
||||
pass
|
||||
|
||||
def requestBoard(self):
|
||||
pass
|
||||
|
||||
def rejectBoard(self, todo0, todo1):
|
||||
pass
|
||||
|
||||
def requestExit(self):
|
||||
pass
|
||||
|
||||
def setElevatorTripId(self, todo0):
|
||||
pass
|
||||
|
||||
def setAntiShuffle(self, todo0):
|
||||
pass
|
||||
|
||||
def setMinLaff(self, todo0):
|
||||
pass
|
||||
def setMinLaff(self, minLaff):
|
||||
self.minLaff = minLaff
|
||||
|
||||
def getMinLaff(self):
|
||||
return self.minLaff
|
||||
|
|
|
@ -1,21 +1,286 @@
|
|||
from otp.ai.AIBase import *
|
||||
from toontown.toonbase import ToontownGlobals
|
||||
from direct.distributed.ClockDelta import *
|
||||
from ElevatorConstants import *
|
||||
import DistributedElevatorFSMAI
|
||||
from direct.task import Task
|
||||
from direct.directnotify import DirectNotifyGlobal
|
||||
from toontown.building.DistributedElevatorFSMAI import DistributedElevatorFSMAI
|
||||
from direct.fsm.FSM import FSM
|
||||
|
||||
class DistributedElevatorFloorAI(DistributedElevatorFSMAI):
|
||||
notify = DirectNotifyGlobal.directNotify.newCategory("DistributedElevatorFloorAI")
|
||||
class DistributedElevatorFloorAI(DistributedElevatorFSMAI.DistributedElevatorFSMAI):
|
||||
notify = DirectNotifyGlobal.directNotify.newCategory('DistributedElevatorFloorAI')
|
||||
defaultTransitions = {'Off': ['Opening', 'Closed'],
|
||||
'Opening': ['WaitEmpty',
|
||||
'WaitCountdown',
|
||||
'Opening',
|
||||
'Closing'],
|
||||
'WaitEmpty': ['WaitCountdown', 'Closing', 'WaitEmpty'],
|
||||
'WaitCountdown': ['WaitEmpty',
|
||||
'AllAboard',
|
||||
'Closing',
|
||||
'WaitCountdown'],
|
||||
'AllAboard': ['WaitEmpty', 'Closing'],
|
||||
'Closing': ['Closed',
|
||||
'WaitEmpty',
|
||||
'Closing',
|
||||
'Opening'],
|
||||
'Closed': ['Opening']}
|
||||
id = 0
|
||||
|
||||
def setFloor(self, todo0):
|
||||
def __init__(self, air, lawOfficeId, bldg, avIds, markerId = None, numSeats = 4, antiShuffle = 0, minLaff = 0):
|
||||
DistributedElevatorFSMAI.DistributedElevatorFSMAI.__init__(self, air, bldg, numSeats, antiShuffle=antiShuffle, minLaff=minLaff)
|
||||
FSM.__init__(self, 'ElevatorFloor_%s_FSM' % self.id)
|
||||
self.type = ELEVATOR_STAGE
|
||||
self.countdownTime = ElevatorData[self.type]['countdown']
|
||||
self.lawOfficeId = lawOfficeId
|
||||
self.anyToonsBailed = 0
|
||||
self.avIds = avIds
|
||||
self.isEntering = 0
|
||||
self.isLocked = 0
|
||||
self.setLocked(0)
|
||||
self.wantState = None
|
||||
self.latchRoom = None
|
||||
self.setLatch(markerId)
|
||||
self.zoneId = bldg.zoneId
|
||||
return
|
||||
|
||||
def generate(self):
|
||||
DistributedElevatorFSMAI.DistributedElevatorFSMAI.generate(self)
|
||||
|
||||
def generateWithRequired(self, zoneId):
|
||||
self.zoneId = zoneId
|
||||
DistributedElevatorFSMAI.DistributedElevatorFSMAI.generateWithRequired(self, self.zoneId)
|
||||
|
||||
def delete(self):
|
||||
for seatIndex in range(len(self.seats)):
|
||||
avId = self.seats[seatIndex]
|
||||
if avId:
|
||||
self.clearFullNow(seatIndex)
|
||||
self.clearEmptyNow(seatIndex)
|
||||
|
||||
DistributedElevatorFSMAI.DistributedElevatorFSMAI.delete(self)
|
||||
|
||||
def getEntranceId(self):
|
||||
return self.entranceId
|
||||
|
||||
def d_setFloor(self, floorNumber):
|
||||
self.sendUpdate('setFloor', [floorNumber])
|
||||
|
||||
def avIsOKToBoard(self, av):
|
||||
return av.hp > 0 and self.accepting and not self.isLocked
|
||||
|
||||
def acceptBoarder(self, avId, seatIndex):
|
||||
DistributedElevatorFSMAI.DistributedElevatorFSMAI.acceptBoarder(self, avId, seatIndex)
|
||||
self.acceptOnce(self.air.getAvatarExitEvent(avId), self.__handleUnexpectedExit, extraArgs=[avId])
|
||||
if self.state == 'WaitEmpty' and self.countFullSeats() < self.countAvsInZone():
|
||||
self.request('WaitCountdown')
|
||||
self.bldg.elevatorAlert(avId)
|
||||
elif self.state in ('WaitCountdown', 'WaitEmpty') and self.countFullSeats() >= self.countAvsInZone():
|
||||
taskMgr.doMethodLater(TOON_BOARD_ELEVATOR_TIME, self.goAllAboard, self.quickBoardTask)
|
||||
|
||||
def countAvsInZone(self):
|
||||
matchingZones = 0
|
||||
for avId in self.bldg.avIds:
|
||||
av = self.air.doId2do.get(avId)
|
||||
if av:
|
||||
if av.zoneId == self.bldg.zoneId:
|
||||
matchingZones += 1
|
||||
|
||||
return matchingZones
|
||||
|
||||
def goAllAboard(self, throwAway = 1):
|
||||
self.request('Closing')
|
||||
return Task.done
|
||||
|
||||
def __handleUnexpectedExit(self, avId):
|
||||
self.notify.warning('Avatar: ' + str(avId) + ' has exited unexpectedly')
|
||||
seatIndex = self.findAvatar(avId)
|
||||
if seatIndex == None:
|
||||
pass
|
||||
else:
|
||||
self.clearFullNow(seatIndex)
|
||||
self.clearEmptyNow(seatIndex)
|
||||
if self.countFullSeats() == 0:
|
||||
self.request('WaitEmpty')
|
||||
return
|
||||
|
||||
def acceptExiter(self, avId):
|
||||
seatIndex = self.findAvatar(avId)
|
||||
if seatIndex == None:
|
||||
pass
|
||||
else:
|
||||
self.clearFullNow(seatIndex)
|
||||
bailFlag = 0
|
||||
if self.anyToonsBailed == 0:
|
||||
bailFlag = 1
|
||||
self.resetCountdown()
|
||||
self.anyToonsBailed = 1
|
||||
self.sendUpdate('emptySlot' + str(seatIndex), [avId, bailFlag, globalClockDelta.getRealNetworkTime()])
|
||||
if self.countFullSeats() == 0:
|
||||
self.request('WaitEmpty')
|
||||
taskMgr.doMethodLater(TOON_EXIT_ELEVATOR_TIME, self.clearEmptyNow, self.uniqueName('clearEmpty-%s' % seatIndex), extraArgs=(seatIndex,))
|
||||
return
|
||||
|
||||
def enterOpening(self):
|
||||
self.d_setState('Opening')
|
||||
DistributedElevatorFSMAI.DistributedElevatorFSMAI.enterOpening(self)
|
||||
taskMgr.doMethodLater(ElevatorData[ELEVATOR_NORMAL]['openTime'], self.waitEmptyTask, self.uniqueName('opening-timer'))
|
||||
|
||||
def exitOpening(self):
|
||||
DistributedElevatorFSMAI.DistributedElevatorFSMAI.exitOpening(self)
|
||||
if self.isLocked:
|
||||
self.wantState = 'closed'
|
||||
if self.wantState == 'closed':
|
||||
self.demand('Closing')
|
||||
|
||||
def waitEmptyTask(self, task):
|
||||
self.request('WaitEmpty')
|
||||
return Task.done
|
||||
|
||||
def enterWaitEmpty(self):
|
||||
self.lastState = self.state
|
||||
for i in range(len(self.seats)):
|
||||
self.seats[i] = None
|
||||
|
||||
print self.seats
|
||||
if self.wantState == 'closed':
|
||||
self.demand('Closing')
|
||||
else:
|
||||
self.d_setState('WaitEmpty')
|
||||
self.accepting = 1
|
||||
return
|
||||
|
||||
def enterWaitCountdown(self):
|
||||
self.lastState = self.state
|
||||
DistributedElevatorFSMAI.DistributedElevatorFSMAI.enterWaitCountdown(self)
|
||||
taskMgr.doMethodLater(self.countdownTime, self.timeToGoTask, self.uniqueName('countdown-timer'))
|
||||
if self.lastState == 'WaitCountdown':
|
||||
pass
|
||||
|
||||
def timeToGoTask(self, task):
|
||||
if self.countFullSeats() > 0:
|
||||
self.request('AllAboard')
|
||||
else:
|
||||
self.request('WaitEmpty')
|
||||
return Task.done
|
||||
|
||||
def resetCountdown(self):
|
||||
taskMgr.remove(self.uniqueName('countdown-timer'))
|
||||
taskMgr.doMethodLater(self.countdownTime, self.timeToGoTask, self.uniqueName('countdown-timer'))
|
||||
|
||||
def enterAllAboard(self):
|
||||
DistributedElevatorFSMAI.DistributedElevatorFSMAI.enterAllAboard(self)
|
||||
currentTime = globalClock.getRealTime()
|
||||
elapsedTime = currentTime - self.timeOfBoarding
|
||||
self.notify.debug('elapsed time: ' + str(elapsedTime))
|
||||
waitTime = max(TOON_BOARD_ELEVATOR_TIME - elapsedTime, 0)
|
||||
taskMgr.doMethodLater(waitTime, self.closeTask, self.uniqueName('waitForAllAboard'))
|
||||
|
||||
def closeTask(self, task):
|
||||
if self.countFullSeats() >= 1:
|
||||
self.request('Closing')
|
||||
else:
|
||||
self.request('WaitEmpty')
|
||||
return Task.done
|
||||
|
||||
def enterClosing(self):
|
||||
if self.countFullSeats() > 0:
|
||||
self.sendUpdate('kickToonsOut')
|
||||
DistributedElevatorFSMAI.DistributedElevatorFSMAI.enterClosing(self)
|
||||
taskMgr.doMethodLater(ElevatorData[ELEVATOR_STAGE]['closeTime'], self.elevatorClosedTask, self.uniqueName('closing-timer'))
|
||||
self.d_setState('Closing')
|
||||
|
||||
def elevatorClosedTask(self, task):
|
||||
self.elevatorClosed()
|
||||
return Task.done
|
||||
|
||||
def elevatorClosed(self):
|
||||
if self.isLocked:
|
||||
self.request('Closed')
|
||||
return
|
||||
numPlayers = self.countFullSeats()
|
||||
if numPlayers > 0:
|
||||
players = []
|
||||
for i in self.seats:
|
||||
if i not in [None, 0]:
|
||||
players.append(i)
|
||||
|
||||
sittingAvIds = []
|
||||
for seatIndex in range(len(self.seats)):
|
||||
avId = self.seats[seatIndex]
|
||||
if avId:
|
||||
sittingAvIds.append(avId)
|
||||
|
||||
for avId in self.avIds:
|
||||
if avId not in sittingAvIds:
|
||||
pass
|
||||
|
||||
self.bldg.startNextFloor()
|
||||
else:
|
||||
self.notify.warning('The elevator left, but was empty.')
|
||||
self.request('Closed')
|
||||
return
|
||||
|
||||
def setLocked(self, locked):
|
||||
self.isLocked = locked
|
||||
if locked:
|
||||
if self.state == 'WaitEmpty':
|
||||
self.request('Closing')
|
||||
if self.countFullSeats() == 0:
|
||||
self.wantState = 'closed'
|
||||
else:
|
||||
self.wantState = 'opening'
|
||||
else:
|
||||
self.wantState = 'waitEmpty'
|
||||
if self.state == 'Closed':
|
||||
self.request('Opening')
|
||||
|
||||
def getLocked(self):
|
||||
return self.isLocked
|
||||
|
||||
def unlock(self):
|
||||
if self.isLocked:
|
||||
self.setLocked(0)
|
||||
|
||||
def lock(self):
|
||||
if not self.isLocked:
|
||||
self.setLocked(1)
|
||||
|
||||
def start(self):
|
||||
self.quickBoardTask = self.uniqueName('quickBoard')
|
||||
self.request('Opening')
|
||||
|
||||
def beClosed(self):
|
||||
pass
|
||||
|
||||
def setLocked(self, todo0):
|
||||
pass
|
||||
def setEntering(self, entering):
|
||||
self.isEntering = entering
|
||||
|
||||
def setEntering(self, todo0):
|
||||
pass
|
||||
def getEntering(self):
|
||||
return self.isEntering
|
||||
|
||||
def kickToonsOut(self):
|
||||
pass
|
||||
def enterClosed(self):
|
||||
DistributedElevatorFSMAI.DistributedElevatorFSMAI.enterClosed(self)
|
||||
if self.wantState == 'closed':
|
||||
pass
|
||||
else:
|
||||
self.demand('Opening')
|
||||
|
||||
def setLatch(self, todo0):
|
||||
pass
|
||||
def enterOff(self):
|
||||
self.lastState = self.state
|
||||
if self.wantState == 'closed':
|
||||
self.demand('Closing')
|
||||
elif self.wantState == 'waitEmpty':
|
||||
self.demand('WaitEmpty')
|
||||
|
||||
def setPos(self, pointPos):
|
||||
self.sendUpdate('setPos', [pointPos[0], pointPos[1], pointPos[2]])
|
||||
|
||||
def setH(self, H):
|
||||
self.sendUpdate('setH', [H])
|
||||
|
||||
def setLatch(self, markerId):
|
||||
self.latch = markerId
|
||||
|
||||
def getLatch(self):
|
||||
return self.latch
|
||||
|
|
|
@ -1,15 +1,49 @@
|
|||
from direct.directnotify import DirectNotifyGlobal
|
||||
from toontown.building.DistributedElevatorExtAI import DistributedElevatorExtAI
|
||||
from otp.ai.AIBase import *
|
||||
from toontown.toonbase import ToontownGlobals
|
||||
from direct.distributed.ClockDelta import *
|
||||
from toontown.building.ElevatorConstants import *
|
||||
from toontown.building import DistributedElevatorExtAI
|
||||
from direct.fsm import ClassicFSM
|
||||
from direct.fsm import State
|
||||
from direct.task import Task
|
||||
|
||||
class DistributedLawOfficeElevatorExtAI(DistributedElevatorExtAI):
|
||||
notify = DirectNotifyGlobal.directNotify.newCategory("DistributedLawOfficeElevatorExtAI")
|
||||
class DistributedLawOfficeElevatorExtAI(DistributedElevatorExtAI.DistributedElevatorExtAI):
|
||||
|
||||
def setEntranceId(self, todo0):
|
||||
pass
|
||||
def __init__(self, air, bldg, lawOfficeId, entranceId, antiShuffle = 0, minLaff = 0):
|
||||
DistributedElevatorExtAI.DistributedElevatorExtAI.__init__(self, air, bldg, antiShuffle=antiShuffle, minLaff=minLaff)
|
||||
self.lawOfficeId = lawOfficeId
|
||||
self.entranceId = entranceId
|
||||
|
||||
def setLawOfficeInteriorZone(self, todo0):
|
||||
pass
|
||||
def getEntranceId(self):
|
||||
return self.entranceId
|
||||
|
||||
def setLawOfficeInteriorZoneForce(self, todo0):
|
||||
pass
|
||||
def elevatorClosed(self):
|
||||
numPlayers = self.countFullSeats()
|
||||
if numPlayers > 0:
|
||||
players = []
|
||||
for i in self.seats:
|
||||
if i not in [None, 0]:
|
||||
players.append(i)
|
||||
|
||||
lawOfficeZone = self.bldg.createLawOffice(self.lawOfficeId, self.entranceId, players)
|
||||
for seatIndex in range(len(self.seats)):
|
||||
avId = self.seats[seatIndex]
|
||||
if avId:
|
||||
self.sendUpdateToAvatarId(avId, 'setLawOfficeInteriorZone', [lawOfficeZone])
|
||||
self.clearFullNow(seatIndex)
|
||||
|
||||
else:
|
||||
self.notify.warning('The elevator left, but was empty.')
|
||||
self.fsm.request('closed')
|
||||
return
|
||||
|
||||
def enterClosed(self):
|
||||
DistributedElevatorExtAI.DistributedElevatorExtAI.enterClosed(self)
|
||||
self.fsm.request('opening')
|
||||
|
||||
def sendAvatarsToDestination(self, avIdList):
|
||||
if len(avIdList) > 0:
|
||||
officeZone = self.bldg.createLawOffice(self.lawOfficeId, self.entranceId, avIdList)
|
||||
for avId in avIdList:
|
||||
if avId:
|
||||
self.sendUpdateToAvatarId(avId, 'setLawOfficeInteriorZoneForce', [officeZone])
|
||||
|
|
|
@ -1,15 +1,98 @@
|
|||
from direct.directnotify import DirectNotifyGlobal
|
||||
from direct.distributed.DistributedObjectAI import DistributedObjectAI
|
||||
from pandac.PandaModules import *
|
||||
from direct.distributed import DistributedObjectAI
|
||||
from toontown.toonbase import ToontownGlobals
|
||||
from otp.otpbase import OTPGlobals
|
||||
from direct.fsm import FSM
|
||||
|
||||
class DistributedLawbotBossGavelAI(DistributedObjectAI):
|
||||
notify = DirectNotifyGlobal.directNotify.newCategory("DistributedLawbotBossGavelAI")
|
||||
class DistributedLawbotBossGavelAI(DistributedObjectAI.DistributedObjectAI, FSM.FSM):
|
||||
notify = DirectNotifyGlobal.directNotify.newCategory('DistributedLawbotBossGavelAI')
|
||||
|
||||
def setBossCogId(self, todo0):
|
||||
def __init__(self, air, boss, index):
|
||||
DistributedObjectAI.DistributedObjectAI.__init__(self, air)
|
||||
FSM.FSM.__init__(self, 'DistributedLawbotBossGavelAI')
|
||||
self.boss = boss
|
||||
self.index = index
|
||||
cn = CollisionNode('controls')
|
||||
cs = CollisionSphere(0, -6, 0, 6)
|
||||
cn.addSolid(cs)
|
||||
self.goonShield = NodePath(cn)
|
||||
self.goonShield.setPosHpr(*ToontownGlobals.LawbotBossGavelPosHprs[self.index])
|
||||
self.avId = 0
|
||||
self.objectId = 0
|
||||
|
||||
def getBossCogId(self):
|
||||
return self.boss.doId
|
||||
|
||||
def getIndex(self):
|
||||
return self.index
|
||||
|
||||
def setState(self, state):
|
||||
self.request(state)
|
||||
|
||||
def d_setState(self, state):
|
||||
newState = state
|
||||
if state == 'On':
|
||||
newState = 'N'
|
||||
elif state == 'Off':
|
||||
newState = 'F'
|
||||
self.sendUpdate('setState', [newState])
|
||||
|
||||
def b_setState(self, state):
|
||||
self.request(state)
|
||||
self.d_setState(state)
|
||||
|
||||
def turnOn(self):
|
||||
self.b_setState('On')
|
||||
|
||||
def requestControl(self):
|
||||
avId = self.air.getAvatarIdFromSender()
|
||||
if avId in self.boss.involvedToons and self.avId == 0:
|
||||
craneId = self.__getCraneId(avId)
|
||||
if craneId == 0:
|
||||
self.request('Controlled', avId)
|
||||
|
||||
def requestFree(self):
|
||||
avId = self.air.getAvatarIdFromSender()
|
||||
if avId == self.avId:
|
||||
self.request('Free')
|
||||
|
||||
def removeToon(self, avId):
|
||||
if avId == self.avId:
|
||||
self.request('Free')
|
||||
|
||||
def __getCraneId(self, avId):
|
||||
if self.boss and self.boss.cranes != None:
|
||||
for crane in self.boss.cranes:
|
||||
if crane.avId == avId:
|
||||
return crane.doId
|
||||
|
||||
return 0
|
||||
|
||||
def enterOn(self):
|
||||
pass
|
||||
|
||||
def setIndex(self, todo0):
|
||||
def exitOn(slef):
|
||||
pass
|
||||
|
||||
def setState(self, todo0):
|
||||
def enterOff(self):
|
||||
self.goonShield.detachNode()
|
||||
|
||||
def exitOff(self):
|
||||
pass
|
||||
|
||||
def enterControlled(self, avId):
|
||||
self.avId = avId
|
||||
self.d_setState('C')
|
||||
|
||||
def exitControlled(self):
|
||||
if self.objectId:
|
||||
obj = self.air.doId2do[self.objectId]
|
||||
obj.request('Dropped', self.avId, self.doId)
|
||||
|
||||
def enterFree(self):
|
||||
self.avId = 0
|
||||
self.d_setState('F')
|
||||
|
||||
def exitFree(self):
|
||||
pass
|
||||
|
|
|
@ -14,6 +14,7 @@ from toontown.toon import ToonHead
|
|||
from toontown.toonbase import TTLocalizer
|
||||
from toontown.minigame import Trajectory
|
||||
from toontown.effects import DustCloud
|
||||
from otp.nametag import NametagGlobals
|
||||
GROUND_PLANE_MIN = -15
|
||||
CANNON_ROTATION_MIN = -55
|
||||
CANNON_ROTATION_MAX = 50
|
||||
|
|
|
@ -1,39 +1,108 @@
|
|||
from direct.directnotify import DirectNotifyGlobal
|
||||
from direct.distributed.DistributedObjectAI import DistributedObjectAI
|
||||
from direct.distributed.ClockDelta import *
|
||||
from direct.distributed import DistributedObjectAI
|
||||
from toontown.minigame import Trajectory
|
||||
from toontown.estate import DistributedCannonAI
|
||||
from toontown.estate import CannonGlobals
|
||||
from toontown.minigame import CannonGameGlobals
|
||||
|
||||
class DistributedLawbotCannonAI(DistributedObjectAI):
|
||||
notify = DirectNotifyGlobal.directNotify.newCategory("DistributedLawbotCannonAI")
|
||||
class DistributedLawbotCannonAI(DistributedObjectAI.DistributedObjectAI):
|
||||
notify = directNotify.newCategory('DistributedLawbotCannonAI')
|
||||
|
||||
def setBossCogId(self, todo0):
|
||||
pass
|
||||
def __init__(self, air, lawbotBoss, index, x, y, z, h, p, r):
|
||||
DistributedObjectAI.DistributedObjectAI.__init__(self, air)
|
||||
self.index = index
|
||||
self.posHpr = [x,
|
||||
y,
|
||||
z,
|
||||
h,
|
||||
p,
|
||||
r]
|
||||
self.boss = lawbotBoss
|
||||
self.bossId = lawbotBoss.doId
|
||||
self.avId = 0
|
||||
|
||||
def setIndex(self, todo0):
|
||||
pass
|
||||
def delete(self):
|
||||
self.ignoreAll()
|
||||
DistributedObjectAI.DistributedObjectAI.delete(self)
|
||||
|
||||
def setPosHpr(self, todo0, todo1, todo2, todo3, todo4, todo5):
|
||||
pass
|
||||
def getBossCogId(self):
|
||||
return self.boss.doId
|
||||
|
||||
def getIndex(self):
|
||||
return self.index
|
||||
|
||||
def getPosHpr(self):
|
||||
return self.posHpr
|
||||
|
||||
def canEnterCannon(self):
|
||||
avId = self.air.getAvatarIdFromSender()
|
||||
if self.boss.getCannonBallsLeft(avId) == 0:
|
||||
return False
|
||||
if not self.boss.state == 'BattleTwo':
|
||||
return False
|
||||
if not (self.avId == 0 or self.avId == avId):
|
||||
return False
|
||||
return True
|
||||
|
||||
def requestEnter(self):
|
||||
pass
|
||||
avId = self.air.getAvatarIdFromSender()
|
||||
if not self.canEnterCannon():
|
||||
return
|
||||
if self.avId == 0 or self.avId == avId:
|
||||
self.avId = avId
|
||||
self.boss.toonEnteredCannon(self.avId, self.index)
|
||||
cannonBallsLeft = self.boss.getCannonBallsLeft(avId)
|
||||
self.setMovie(CannonGlobals.CANNON_MOVIE_LOAD, self.avId, cannonBallsLeft)
|
||||
self.acceptOnce(self.air.getAvatarExitEvent(avId), self.__handleUnexpectedExit, extraArgs=[avId])
|
||||
else:
|
||||
self.air.writeServerEvent('suspicious', avId, 'DistributedCannonAI.requestEnter cannon already occupied')
|
||||
self.notify.warning('requestEnter() - cannon already occupied')
|
||||
|
||||
def setMovie(self, todo0, todo1, todo2):
|
||||
pass
|
||||
def setMovie(self, mode, avId, extraInfo):
|
||||
self.avId = avId
|
||||
self.sendUpdate('setMovie', [mode, avId, extraInfo])
|
||||
|
||||
def setCannonPosition(self, todo0, todo1):
|
||||
pass
|
||||
def __handleUnexpectedExit(self, avId):
|
||||
self.notify.warning('avatar:' + str(avId) + ' has exited unexpectedly')
|
||||
self.__doExit()
|
||||
|
||||
def updateCannonPosition(self, todo0, todo1, todo2):
|
||||
pass
|
||||
|
||||
def setCannonLit(self, todo0, todo1):
|
||||
pass
|
||||
|
||||
def setCannonWillFire(self, todo0, todo1, todo2, todo3, todo4):
|
||||
pass
|
||||
|
||||
def setLanded(self):
|
||||
pass
|
||||
def __doExit(self):
|
||||
self.setMovie(CannonGlobals.CANNON_MOVIE_FORCE_EXIT, self.avId, 0)
|
||||
self.avId = 0
|
||||
|
||||
def requestLeave(self):
|
||||
pass
|
||||
avId = self.air.getAvatarIdFromSender()
|
||||
if self.avId != 0:
|
||||
self.__doExit()
|
||||
else:
|
||||
self.air.writeServerEvent('suspicious', avId, 'DistributedCannonAI.requestLeave cannon not occupied')
|
||||
self.notify.warning('requestLeave() - cannon not occupied')
|
||||
|
||||
def setCannonPosition(self, zRot, angle):
|
||||
avId = self.air.getAvatarIdFromSender()
|
||||
self.notify.debug('setCannonPosition: ' + str(avId) + ': zRot=' + str(zRot) + ', angle=' + str(angle))
|
||||
self.sendUpdate('updateCannonPosition', [avId, zRot, angle])
|
||||
|
||||
def setLanded(self):
|
||||
self.ignore(self.air.getAvatarExitEvent(self.avId))
|
||||
if self.canEnterCannon():
|
||||
self.requestEnter()
|
||||
else:
|
||||
self.setMovie(CannonGlobals.CANNON_MOVIE_LANDED, 0, 0)
|
||||
|
||||
def setCannonLit(self, zRot, angle):
|
||||
if not self.boss.state == 'BattleTwo':
|
||||
self.notify.debug('ignoring setCannonList since boss in state %s' % self.boss.state)
|
||||
return
|
||||
avId = self.air.getAvatarIdFromSender()
|
||||
if self.boss.getCannonBallsLeft(avId) == 0:
|
||||
self.notify.debug('ignoring setCannonList since no balls left for %s' % avId)
|
||||
return
|
||||
self.notify.debug('setCannonLit: ' + str(avId) + ': zRot=' + str(zRot) + ', angle=' + str(angle))
|
||||
fireTime = CannonGameGlobals.FUSE_TIME
|
||||
self.sendUpdate('setCannonWillFire', [avId,
|
||||
fireTime,
|
||||
zRot,
|
||||
angle,
|
||||
globalClockDelta.getRealNetworkTime()])
|
||||
self.boss.decrementCannonBallsLeft(avId)
|
||||
|
|
|
@ -1,21 +1,183 @@
|
|||
from direct.directnotify import DirectNotifyGlobal
|
||||
from direct.distributed.DistributedObjectAI import DistributedObjectAI
|
||||
from pandac.PandaModules import *
|
||||
from direct.distributed import DistributedObjectAI
|
||||
from toontown.toonbase import ToontownGlobals
|
||||
from otp.otpbase import OTPGlobals
|
||||
from direct.fsm import FSM
|
||||
import random
|
||||
|
||||
class DistributedLawbotChairAI(DistributedObjectAI):
|
||||
notify = DirectNotifyGlobal.directNotify.newCategory("DistributedLawbotChairAI")
|
||||
class DistributedLawbotChairAI(DistributedObjectAI.DistributedObjectAI, FSM.FSM):
|
||||
notify = DirectNotifyGlobal.directNotify.newCategory('DistributedLawbotChairAI')
|
||||
|
||||
def setBossCogId(self, todo0):
|
||||
def __init__(self, air, boss, index):
|
||||
DistributedObjectAI.DistributedObjectAI.__init__(self, air)
|
||||
FSM.FSM.__init__(self, 'DistributedLawbotBossChairAI')
|
||||
self.boss = boss
|
||||
self.index = index
|
||||
cn = CollisionNode('controls')
|
||||
cs = CollisionSphere(0, -6, 0, 6)
|
||||
cn.addSolid(cs)
|
||||
self.goonShield = NodePath(cn)
|
||||
self.goonShield.setPosHpr(*ToontownGlobals.LawbotBossChairPosHprs[self.index])
|
||||
self.avId = 0
|
||||
self.objectId = 0
|
||||
self.changeToCogTask = None
|
||||
self.startCogFlyTask = None
|
||||
self.toonJurorIndex = -1
|
||||
return
|
||||
|
||||
def delete(self):
|
||||
self.ignoreAll()
|
||||
DistributedObjectAI.DistributedObjectAI.delete(self)
|
||||
taskName = self.uniqueName('startCogFlyTask')
|
||||
taskMgr.remove(taskName)
|
||||
changeTaskName = self.uniqueName('changeToCogJuror')
|
||||
taskMgr.remove(changeTaskName)
|
||||
|
||||
def stopCogs(self):
|
||||
taskName = self.uniqueName('startCogFlyTask')
|
||||
taskMgr.remove(taskName)
|
||||
changeTaskName = self.uniqueName('changeToCogJuror')
|
||||
taskMgr.remove(changeTaskName)
|
||||
|
||||
def getBossCogId(self):
|
||||
return self.boss.doId
|
||||
|
||||
def getIndex(self):
|
||||
return self.index
|
||||
|
||||
def getToonJurorIndex(self):
|
||||
return self.toonJurorIndex
|
||||
|
||||
def setToonJurorIndex(self, newVal):
|
||||
self.toonJurorIndex = newVal
|
||||
|
||||
def b_setToonJurorIndex(self, newVal):
|
||||
self.setToonJurorIndex(newVal)
|
||||
self.d_setToonJurorIndex(newVal)
|
||||
|
||||
def d_setToonJurorIndex(self, newVal):
|
||||
self.sendUpdate('setToonJurorIndex', [newVal])
|
||||
|
||||
def setState(self, state):
|
||||
self.request(state)
|
||||
|
||||
def d_setState(self, state):
|
||||
newState = state
|
||||
if state == 'On':
|
||||
newState = 'N'
|
||||
elif state == 'Off':
|
||||
newState = 'F'
|
||||
elif state == 'ToonJuror':
|
||||
newState = 'T'
|
||||
elif state == 'SuitJuror':
|
||||
newState = 'S'
|
||||
elif state == 'EmptyJuror':
|
||||
newState = 'E'
|
||||
elif state == 'StopCogs':
|
||||
newState = 'C'
|
||||
self.sendUpdate('setState', [newState])
|
||||
|
||||
def b_setState(self, state):
|
||||
self.request(state)
|
||||
self.d_setState(state)
|
||||
|
||||
def turnOn(self):
|
||||
self.b_setState('On')
|
||||
|
||||
def requestStopCogs(self):
|
||||
self.b_setState('StopCogs')
|
||||
|
||||
def requestControl(self):
|
||||
avId = self.air.getAvatarIdFromSender()
|
||||
if avId in self.boss.involvedToons and self.avId == 0:
|
||||
craneId = self.__getCraneId(avId)
|
||||
if craneId == 0:
|
||||
self.request('Controlled', avId)
|
||||
|
||||
def requestFree(self):
|
||||
avId = self.air.getAvatarIdFromSender()
|
||||
if avId == self.avId:
|
||||
self.request('Free')
|
||||
|
||||
def removeToon(self, avId):
|
||||
if avId == self.avId:
|
||||
self.request('Free')
|
||||
|
||||
def __getCraneId(self, avId):
|
||||
if self.boss and self.boss.cranes != None:
|
||||
for crane in self.boss.cranes:
|
||||
if crane.avId == avId:
|
||||
return crane.doId
|
||||
|
||||
return 0
|
||||
|
||||
def requestToonJuror(self):
|
||||
self.b_setState('ToonJuror')
|
||||
if self.changeToCogTask == None:
|
||||
if self.startCogFlyTask == None:
|
||||
delayTime = random.randrange(9, 19)
|
||||
self.startCogFlyTask = taskMgr.doMethodLater(delayTime, self.cogFlyAndSit, self.uniqueName('startCogFlyTask'))
|
||||
return
|
||||
|
||||
def requestSuitJuror(self):
|
||||
self.b_setState('SuitJuror')
|
||||
|
||||
def requestEmptyJuror(self):
|
||||
self.b_setState('EmptyJuror')
|
||||
delayTime = random.randrange(1, 20)
|
||||
self.startCogFlyTask = taskMgr.doMethodLater(delayTime, self.cogFlyAndSit, self.uniqueName('startCogFlyTask'))
|
||||
|
||||
def cogFlyAndSit(self, taskName = None):
|
||||
self.notify.debug('cogFlyAndSit')
|
||||
self.sendUpdate('showCogJurorFlying', [])
|
||||
self.changeToCogTask = taskMgr.doMethodLater(ToontownGlobals.LawbotBossCogJurorFlightTime, self.changeToCogJuror, self.uniqueName('changeToCogJuror'))
|
||||
if self.startCogFlyTask:
|
||||
self.startCogFlyTask = None
|
||||
return
|
||||
|
||||
def changeToCogJuror(self, task):
|
||||
self.notify.debug('changeToCogJuror')
|
||||
self.requestSuitJuror()
|
||||
self.changeToCogTask = None
|
||||
return
|
||||
|
||||
def enterOn(self):
|
||||
pass
|
||||
|
||||
def setIndex(self, todo0):
|
||||
def exitOn(slef):
|
||||
pass
|
||||
|
||||
def setState(self, todo0):
|
||||
def enterOff(self):
|
||||
self.goonShield.detachNode()
|
||||
|
||||
def exitOff(self):
|
||||
pass
|
||||
|
||||
def showCogJurorFlying(self):
|
||||
def enterControlled(self, avId):
|
||||
self.avId = avId
|
||||
self.d_setState('C')
|
||||
|
||||
def exitControlled(self):
|
||||
if self.objectId:
|
||||
obj = self.air.doId2do[self.objectId]
|
||||
obj.request('Dropped', self.avId, self.doId)
|
||||
|
||||
def enterFree(self):
|
||||
self.avId = 0
|
||||
self.d_setState('F')
|
||||
|
||||
def exitFree(self):
|
||||
pass
|
||||
|
||||
def setToonJurorIndex(self, todo0):
|
||||
def enterToonJuror(self):
|
||||
pass
|
||||
|
||||
def exitToonJuror(self):
|
||||
pass
|
||||
|
||||
def enterStopCogs(self):
|
||||
self.__stopCogs()
|
||||
|
||||
def exitStopCogs(self):
|
||||
pass
|
||||
|
|
|
@ -26,7 +26,7 @@ def circleY(angle, radius, centerX, centerY):
|
|||
|
||||
def getCirclePoints(segCount, centerX, centerY, radius, wideX = 1.0, wideY = 1.0):
|
||||
returnShape = []
|
||||
for seg in range(0, segCount):
|
||||
for seg in range(0, int(segCount)):
|
||||
coordX = wideX * circleX(pi * 2.0 * float(float(seg) / float(segCount)), radius, centerX, centerY)
|
||||
coordY = wideY * circleY(pi * 2.0 * float(float(seg) / float(segCount)), radius, centerX, centerY)
|
||||
returnShape.append((coordX, coordY, 1))
|
||||
|
|
|
@ -1,27 +1,131 @@
|
|||
from direct.distributed import DistributedObjectAI
|
||||
from otp.level import DistributedLevelAI
|
||||
from direct.directnotify import DirectNotifyGlobal
|
||||
from direct.distributed.DistributedObjectAI import DistributedObjectAI
|
||||
from toontown.toonbase import ToontownGlobals
|
||||
from toontown.coghq import StageLayout, DistributedStageRoomAI
|
||||
from toontown.coghq import BattleExperienceAggregatorAI
|
||||
from toontown.building import DistributedElevatorFloorAI
|
||||
from pandac.PandaModules import *
|
||||
|
||||
class DistributedStageAI(DistributedObjectAI):
|
||||
notify = DirectNotifyGlobal.directNotify.newCategory("DistributedStageAI")
|
||||
class DistributedStageAI(DistributedObjectAI.DistributedObjectAI):
|
||||
notify = DirectNotifyGlobal.directNotify.newCategory('DistributedStageAI')
|
||||
|
||||
def setZoneId(self, todo0):
|
||||
pass
|
||||
def __init__(self, air, stageId, zoneId, floorNum, avIds, layoutIndex, battleExpAggreg = None):
|
||||
DistributedObjectAI.DistributedObjectAI.__init__(self, air)
|
||||
self.stageId = stageId
|
||||
self.zoneId = zoneId
|
||||
self.floorNum = floorNum
|
||||
self.avIds = avIds
|
||||
self.elevatorList = []
|
||||
self.setLayoutIndex(layoutIndex)
|
||||
self.battleExpAggreg = battleExpAggreg
|
||||
self.puzzelReward = 5
|
||||
|
||||
def setStageId(self, todo0):
|
||||
pass
|
||||
def generate(self):
|
||||
DistributedObjectAI.DistributedObjectAI.generate(self)
|
||||
self.notify.info('generate %s, id=%s, floor=%s' % (self.doId, self.stageId, self.floorNum))
|
||||
self.layout = StageLayout.StageLayout(self.stageId, self.floorNum, self.layoutIndex)
|
||||
self.rooms = []
|
||||
if self.battleExpAggreg is None:
|
||||
self.battleExpAggreg = BattleExperienceAggregatorAI.BattleExperienceAggregatorAI()
|
||||
for i in range(self.layout.getNumRooms()):
|
||||
room = DistributedStageRoomAI.DistributedStageRoomAI(self.air, self.stageId, self.doId, self.zoneId, self.layout.getRoomId(i), i * 2, self.avIds, self.battleExpAggreg)
|
||||
room.generateWithRequired(self.zoneId)
|
||||
self.rooms.append(room)
|
||||
|
||||
def setLayoutIndex(self, todo0):
|
||||
pass
|
||||
roomDoIds = []
|
||||
for room in self.rooms:
|
||||
roomDoIds.append(room.doId)
|
||||
|
||||
def setFloorNum(self, todo0):
|
||||
pass
|
||||
self.sendUpdate('setRoomDoIds', [roomDoIds])
|
||||
self.placeElevatorsOnMarkers()
|
||||
if __dev__:
|
||||
simbase.stage = self
|
||||
description = '%s|%s|%s' % (self.stageId, self.floorNum, self.avIds)
|
||||
for avId in self.avIds:
|
||||
self.air.writeServerEvent('stageEntered', avId, description)
|
||||
|
||||
def setRoomDoIds(self, todo0):
|
||||
pass
|
||||
return
|
||||
|
||||
def setStageZone(self, todo0):
|
||||
pass
|
||||
def requestDelete(self):
|
||||
self.notify.info('requestDelete: %s' % self.doId)
|
||||
if hasattr(self, 'rooms'):
|
||||
for room in self.rooms:
|
||||
room.requestDelete()
|
||||
|
||||
def elevatorAlert(self, todo0):
|
||||
pass
|
||||
if hasattr(self, 'elevatorList'):
|
||||
for elevator in self.elevatorList:
|
||||
elevator.requestDelete()
|
||||
|
||||
DistributedObjectAI.DistributedObjectAI.requestDelete(self)
|
||||
|
||||
def delete(self):
|
||||
self.notify.info('delete: %s' % self.doId)
|
||||
if __dev__:
|
||||
if hasattr(simbase, 'stage') and simbase.stage is self:
|
||||
del simbase.stage
|
||||
self.air.deallocateZone(self.zoneId)
|
||||
if hasattr(self, 'elevatorList'):
|
||||
del self.elevatorList
|
||||
if hasattr(self, 'rooms'):
|
||||
del self.rooms
|
||||
if hasattr(self, 'layout'):
|
||||
del self.layout
|
||||
if hasattr(self, 'battleExpAggreg'):
|
||||
del self.battleExpAggreg
|
||||
DistributedObjectAI.DistributedObjectAI.delete(self)
|
||||
|
||||
def getTaskZoneId(self):
|
||||
return self.stageId
|
||||
|
||||
def placeElevatorsOnMarkers(self):
|
||||
for room in self.rooms:
|
||||
if room.entType2ids['elevatorMarker']:
|
||||
for markerId in room.entType2ids['elevatorMarker']:
|
||||
marker = room.getEntity(markerId)
|
||||
newElevator = DistributedElevatorFloorAI.DistributedElevatorFloorAI(self.air, self.doId, self, self.avIds, marker.doId)
|
||||
newElevator.generateWithRequired(self.zoneId)
|
||||
self.elevatorList.append(newElevator)
|
||||
|
||||
def allToonsGone(self):
|
||||
self.notify.info('allToonsGone')
|
||||
self.requestDelete()
|
||||
|
||||
def getZoneId(self):
|
||||
return self.zoneId
|
||||
|
||||
def getStageId(self):
|
||||
return self.stageId
|
||||
|
||||
def getFloorNum(self):
|
||||
return self.floorNum
|
||||
|
||||
def setLayoutIndex(self, layoutIndex):
|
||||
self.layoutIndex = layoutIndex
|
||||
|
||||
def getLayoutIndex(self):
|
||||
return self.layoutIndex
|
||||
|
||||
def startNextFloor(self):
|
||||
floor = self.floorNum + 1
|
||||
StageZone = self.air.allocateZone()
|
||||
Stage = DistributedStageAI(self.air, self.stageId, StageZone, floor, self.avIds, self.layoutIndex, self.battleExpAggreg)
|
||||
Stage.generateWithRequired(StageZone)
|
||||
for avId in self.avIds:
|
||||
self.sendUpdateToAvatarId(avId, 'setStageZone', [StageZone])
|
||||
|
||||
self.requestDelete()
|
||||
|
||||
def elevatorAlert(self, avId):
|
||||
self.sendUpdate('elevatorAlert', [avId])
|
||||
|
||||
def increasePuzzelReward(self):
|
||||
self.puzzelReward += 5
|
||||
if self.puzzelReward > 10:
|
||||
self.puzzelReward = 10
|
||||
|
||||
def resetPuzzelReward(self):
|
||||
self.puzzelReward = 5
|
||||
|
||||
def getPuzzelReward(self):
|
||||
return self.puzzelReward
|
||||
|
|
|
@ -1,6 +1,78 @@
|
|||
from toontown.toonbase import ToontownGlobals
|
||||
from toontown.coghq import DistributedLevelBattleAI
|
||||
from direct.directnotify import DirectNotifyGlobal
|
||||
from direct.distributed.DistributedObjectAI import DistributedObjectAI
|
||||
from direct.fsm import State
|
||||
from direct.fsm import ClassicFSM, State
|
||||
from toontown.battle.BattleBase import *
|
||||
import CogDisguiseGlobals
|
||||
from toontown.toonbase.ToontownBattleGlobals import getStageCreditMultiplier
|
||||
from direct.showbase.PythonUtil import addListsByValue, enumerate
|
||||
|
||||
class DistributedStageBattleAI(DistributedObjectAI):
|
||||
notify = DirectNotifyGlobal.directNotify.newCategory("DistributedStageBattleAI")
|
||||
class DistributedStageBattleAI(DistributedLevelBattleAI.DistributedLevelBattleAI):
|
||||
notify = DirectNotifyGlobal.directNotify.newCategory('DistributedStageBattleAI')
|
||||
|
||||
def __init__(self, air, battleMgr, pos, suit, toonId, zoneId, level, battleCellId, roundCallback = None, finishCallback = None, maxSuits = 4):
|
||||
DistributedLevelBattleAI.DistributedLevelBattleAI.__init__(self, air, battleMgr, pos, suit, toonId, zoneId, level, battleCellId, 'StageReward', roundCallback, finishCallback, maxSuits)
|
||||
self.battleCalc.setSkillCreditMultiplier(1)
|
||||
if self.bossBattle:
|
||||
self.level.d_setBossConfronted(toonId)
|
||||
self.fsm.addState(State.State('StageReward', self.enterStageReward, self.exitStageReward, ['Resume']))
|
||||
playMovieState = self.fsm.getStateNamed('PlayMovie')
|
||||
playMovieState.addTransition('StageReward')
|
||||
|
||||
def getTaskZoneId(self):
|
||||
return self.level.stageId
|
||||
|
||||
def storeSuitsKilledThisBattle(self):
|
||||
floor = self.level.getFloorNum()
|
||||
if len(self.suitsKilledPerFloor) < floor + 1:
|
||||
self.suitsKilledPerFloor.append(self.suitsKilledThisBattle)
|
||||
else:
|
||||
self.suitsKilledPerFloor[floor].extend(self.suitsKilledThisBattle)
|
||||
|
||||
def handleToonsWon(self, toons):
|
||||
extraMerits = [0,
|
||||
0,
|
||||
0,
|
||||
0]
|
||||
amount = ToontownGlobals.StageNoticeRewards[self.level.stageId]
|
||||
index = ToontownGlobals.cogHQZoneId2deptIndex(self.level.stageId)
|
||||
extraMerits[index] = amount
|
||||
for toon in toons:
|
||||
mult = 1.0
|
||||
meritArray = self.air.promotionMgr.recoverMerits(toon, [], self.getTaskZoneId(), mult, extraMerits=extraMerits)
|
||||
if toon.doId in self.helpfulToons:
|
||||
self.toonMerits[toon.doId] = addListsByValue(self.toonMerits[toon.doId], meritArray)
|
||||
else:
|
||||
self.notify.debug('toon %d not helpful list, skipping merits' % toon.doId)
|
||||
|
||||
for floorNum, cogsThisFloor in enumerate(self.suitsKilledPerFloor):
|
||||
self.notify.info('merits for floor %s' % floorNum)
|
||||
for toon in toons:
|
||||
recovered, notRecovered = self.air.questManager.recoverItems(toon, cogsThisFloor, self.getTaskZoneId())
|
||||
self.toonItems[toon.doId][0].extend(recovered)
|
||||
self.toonItems[toon.doId][1].extend(notRecovered)
|
||||
meritArray = self.air.promotionMgr.recoverMerits(toon, cogsThisFloor, self.getTaskZoneId(), getStageCreditMultiplier(floorNum))
|
||||
self.notify.info('toon %s: %s' % (toon.doId, meritArray))
|
||||
if toon.doId in self.helpfulToons:
|
||||
self.toonMerits[toon.doId] = addListsByValue(self.toonMerits[toon.doId], meritArray)
|
||||
else:
|
||||
self.notify.debug('toon %d not helpful list, skipping merits' % toon.doId)
|
||||
|
||||
def enterStageReward(self):
|
||||
self.joinableFsm.request('Unjoinable')
|
||||
self.runableFsm.request('Unrunable')
|
||||
self.resetResponses()
|
||||
self.assignRewards()
|
||||
self.bossDefeated = 1
|
||||
self.level.setVictors(self.activeToons[:])
|
||||
self.timer.startCallback(BUILDING_REWARD_TIMEOUT, self.serverRewardDone)
|
||||
return None
|
||||
|
||||
def exitStageReward(self):
|
||||
return None
|
||||
|
||||
def enterResume(self):
|
||||
DistributedLevelBattleAI.DistributedLevelBattleAI.enterResume(self)
|
||||
if self.bossBattle and self.bossDefeated:
|
||||
self.battleMgr.level.b_setDefeated()
|
||||
|
|
|
@ -1,24 +1,144 @@
|
|||
from otp.level import DistributedLevelAI, LevelSpec
|
||||
from direct.directnotify import DirectNotifyGlobal
|
||||
from otp.level.DistributedLevelAI import DistributedLevelAI
|
||||
from direct.task import Task
|
||||
from otp.level import LevelSpec
|
||||
from toontown.toonbase import ToontownGlobals, ToontownBattleGlobals
|
||||
from toontown.coghq import FactoryEntityCreatorAI, StageRoomSpecs
|
||||
from toontown.coghq import StageRoomBase, LevelSuitPlannerAI
|
||||
from toontown.coghq import DistributedStageBattleAI
|
||||
from toontown.suit import DistributedStageSuitAI
|
||||
|
||||
class DistributedStageRoomAI(DistributedLevelAI):
|
||||
notify = DirectNotifyGlobal.directNotify.newCategory("DistributedStageRoomAI")
|
||||
class DistributedStageRoomAI(DistributedLevelAI.DistributedLevelAI, StageRoomBase.StageRoomBase):
|
||||
notify = DirectNotifyGlobal.directNotify.newCategory('DistributedStageRoomAI')
|
||||
|
||||
def setStageId(self, todo0):
|
||||
pass
|
||||
def __init__(self, air, stageId, stageDoId, zoneId, roomId, roomNum, avIds, battleExpAggreg):
|
||||
DistributedLevelAI.DistributedLevelAI.__init__(self, air, zoneId, 0, avIds)
|
||||
StageRoomBase.StageRoomBase.__init__(self)
|
||||
self.setStageId(stageId)
|
||||
self.setRoomId(roomId)
|
||||
self.roomNum = roomNum
|
||||
self.stageDoId = stageDoId
|
||||
self.battleExpAggreg = battleExpAggreg
|
||||
|
||||
def setRoomId(self, todo0):
|
||||
pass
|
||||
def createEntityCreator(self):
|
||||
return FactoryEntityCreatorAI.FactoryEntityCreatorAI(level=self)
|
||||
|
||||
def setRoomNum(self, todo0):
|
||||
pass
|
||||
def getBattleCreditMultiplier(self):
|
||||
return ToontownBattleGlobals.getStageCreditMultiplier(self.getFloorNum())
|
||||
|
||||
def setSuits(self, todo0, todo1):
|
||||
pass
|
||||
def getFloorNum(self):
|
||||
stage = self.air.getDo(self.stageDoId)
|
||||
if stage is None:
|
||||
self.notify.warning('getFloorNum: could not find stage %s' % self.stageDoId)
|
||||
return 0
|
||||
return stage.floorNum
|
||||
|
||||
def setBossConfronted(self, todo0):
|
||||
pass
|
||||
def generate(self):
|
||||
self.notify.debug('generate %s: room=%s' % (self.doId, self.roomId))
|
||||
self.notify.debug('loading spec')
|
||||
specModule = StageRoomSpecs.getStageRoomSpecModule(self.roomId)
|
||||
roomSpec = LevelSpec.LevelSpec(specModule)
|
||||
if __dev__:
|
||||
self.notify.debug('creating entity type registry')
|
||||
typeReg = self.getStageEntityTypeReg()
|
||||
roomSpec.setEntityTypeReg(typeReg)
|
||||
self.notify.debug('creating entities')
|
||||
DistributedLevelAI.DistributedLevelAI.generate(self, roomSpec)
|
||||
self.notify.debug('creating cogs')
|
||||
cogSpecModule = StageRoomSpecs.getCogSpecModule(self.roomId)
|
||||
self.planner = LevelSuitPlannerAI.LevelSuitPlannerAI(self.air, self, DistributedStageSuitAI.DistributedStageSuitAI, DistributedStageBattleAI.DistributedStageBattleAI, cogSpecModule.CogData, cogSpecModule.ReserveCogData, cogSpecModule.BattleCells, battleExpAggreg=self.battleExpAggreg)
|
||||
suitHandles = self.planner.genSuits()
|
||||
messenger.send('plannerCreated-' + str(self.doId))
|
||||
self.suits = suitHandles['activeSuits']
|
||||
self.reserveSuits = suitHandles['reserveSuits']
|
||||
self.d_setSuits()
|
||||
self.notify.debug('finish stage room %s %s creation' % (self.roomId, self.doId))
|
||||
|
||||
def delete(self):
|
||||
self.notify.debug('delete: %s' % self.doId)
|
||||
suits = self.suits
|
||||
for reserve in self.reserveSuits:
|
||||
suits.append(reserve[0])
|
||||
|
||||
self.planner.destroy()
|
||||
del self.planner
|
||||
for suit in suits:
|
||||
if not suit.isDeleted():
|
||||
suit.factoryIsGoingDown()
|
||||
suit.requestDelete()
|
||||
|
||||
del self.battleExpAggreg
|
||||
DistributedLevelAI.DistributedLevelAI.delete(self, deAllocZone=False)
|
||||
|
||||
def getStageId(self):
|
||||
return self.stageId
|
||||
|
||||
def getRoomId(self):
|
||||
return self.roomId
|
||||
|
||||
def getRoomNum(self):
|
||||
return self.roomNum
|
||||
|
||||
def getCogLevel(self):
|
||||
return self.cogLevel
|
||||
|
||||
def d_setSuits(self):
|
||||
self.sendUpdate('setSuits', [self.getSuits(), self.getReserveSuits()])
|
||||
|
||||
def getSuits(self):
|
||||
suitIds = []
|
||||
for suit in self.suits:
|
||||
suitIds.append(suit.doId)
|
||||
|
||||
return suitIds
|
||||
|
||||
def getReserveSuits(self):
|
||||
suitIds = []
|
||||
for suit in self.reserveSuits:
|
||||
suitIds.append(suit[0].doId)
|
||||
|
||||
return suitIds
|
||||
|
||||
def d_setBossConfronted(self, toonId):
|
||||
if toonId not in self.avIdList:
|
||||
self.notify.warning('d_setBossConfronted: %s not in list of participants' % toonId)
|
||||
return
|
||||
self.sendUpdate('setBossConfronted', [toonId])
|
||||
|
||||
def setVictors(self, victorIds):
|
||||
activeVictors = []
|
||||
activeVictorIds = []
|
||||
for victorId in victorIds:
|
||||
toon = self.air.doId2do.get(victorId)
|
||||
if toon is not None:
|
||||
activeVictors.append(toon)
|
||||
activeVictorIds.append(victorId)
|
||||
|
||||
description = '%s|%s' % (self.stageId, activeVictorIds)
|
||||
for avId in activeVictorIds:
|
||||
self.air.writeServerEvent('stageDefeated', avId, description)
|
||||
|
||||
for toon in activeVictors:
|
||||
simbase.air.questManager.toonDefeatedStage(toon, self.stageId, activeVictors)
|
||||
|
||||
return
|
||||
|
||||
def b_setDefeated(self):
|
||||
self.d_setDefeated()
|
||||
self.setDefeated()
|
||||
|
||||
def d_setDefeated(self):
|
||||
self.sendUpdate('setDefeated')
|
||||
|
||||
def setDefeated(self):
|
||||
pass
|
||||
|
||||
def allToonsGone(self, toonsThatCleared):
|
||||
DistributedLevelAI.DistributedLevelAI.allToonsGone(self, toonsThatCleared)
|
||||
if self.roomNum == 0:
|
||||
stage = simbase.air.doId2do.get(self.stageDoId)
|
||||
if stage is not None:
|
||||
stage.allToonsGone()
|
||||
else:
|
||||
self.notify.warning('no stage %s in allToonsGone' % self.stageDoId)
|
||||
return
|
||||
|
|
|
@ -4,12 +4,14 @@ from direct.task import Task
|
|||
import random
|
||||
|
||||
class LaserGameAvoid(LaserGameBase.LaserGameBase):
|
||||
counter = 0
|
||||
|
||||
def __init__(self, funcSuccess, funcFail, funcSendGrid, funcSetGrid):
|
||||
LaserGameBase.LaserGameBase.__init__(self, funcSuccess, funcFail, funcSendGrid, funcSetGrid)
|
||||
self.setGridSize(8, 8)
|
||||
self.blankGrid()
|
||||
self.cycleName = simbase.air.trueUniqueName('AvoidGame')
|
||||
self.cycleName = 'AvoidGame-%d' % self.counter
|
||||
self.counter += 1
|
||||
|
||||
|
||||
def delete(self):
|
||||
|
|
|
@ -35,11 +35,8 @@ class LaserGameDrag(LaserGameBase.LaserGameBase):
|
|||
for row in range(0, self.gridNumY):
|
||||
tile = 0
|
||||
self.gridData[column][row] = tile
|
||||
|
||||
|
||||
for column in range(0, self.gridNumX):
|
||||
self.gridData[column][self.gridNumY - 1] = 12
|
||||
|
||||
for symbol in self.symbolList:
|
||||
finished = 0
|
||||
while finished == 0:
|
||||
|
@ -54,38 +51,30 @@ class LaserGameDrag(LaserGameBase.LaserGameBase):
|
|||
if self.gridData[column][row] == 0:
|
||||
self.gridData[column][row] = symbol
|
||||
tris += 1
|
||||
continue
|
||||
|
||||
if self.checkFor3(symbol):
|
||||
self.clearIndex(symbol)
|
||||
finished = 0
|
||||
continue
|
||||
finished = 1
|
||||
|
||||
else:
|
||||
finished = 1
|
||||
|
||||
|
||||
def hit(self, hitX, hitY, oldx = -1, oldy = -1):
|
||||
if self.finshed:
|
||||
return None
|
||||
|
||||
return
|
||||
if oldx >= 0 and oldy >= 0:
|
||||
if self.gridData[hitX][hitY] == 0:
|
||||
if self.gridData[oldx][oldy] in self.symbolList:
|
||||
self.gridData[hitX][hitY] = self.gridData[oldx][oldy]
|
||||
self.gridData[oldx][oldy] = 0
|
||||
|
||||
|
||||
|
||||
else:
|
||||
pass
|
||||
for index in self.symbolList:
|
||||
if self.checkFor3(index):
|
||||
self.clearIndex(index)
|
||||
continue
|
||||
|
||||
if self.checkForWin():
|
||||
self.win()
|
||||
else:
|
||||
self.funcSendGrid()
|
||||
|
||||
|
||||
def checkFor3(self, index):
|
||||
numInARow = 0
|
||||
|
@ -95,12 +84,10 @@ class LaserGameDrag(LaserGameBase.LaserGameBase):
|
|||
numInARow += 1
|
||||
if numInARow >= 3:
|
||||
return 1
|
||||
|
||||
numInARow >= 3
|
||||
numInARow = 0
|
||||
|
||||
else:
|
||||
numInARow = 0
|
||||
numInARow = 0
|
||||
|
||||
|
||||
numInARow = 0
|
||||
for posY in range(0, self.gridNumY):
|
||||
for posX in range(0, self.gridNumX):
|
||||
|
@ -108,21 +95,17 @@ class LaserGameDrag(LaserGameBase.LaserGameBase):
|
|||
numInARow += 1
|
||||
if numInARow >= 3:
|
||||
return 1
|
||||
|
||||
numInARow >= 3
|
||||
numInARow = 0
|
||||
|
||||
else:
|
||||
numInARow = 0
|
||||
numInARow = 0
|
||||
|
||||
return 0
|
||||
|
||||
|
||||
def clearIndex(self, index):
|
||||
for posX in range(0, self.gridNumX):
|
||||
for posY in range(0, self.gridNumY):
|
||||
if self.gridData[posX][posY] == index:
|
||||
self.gridData[posX][posY] = 0
|
||||
continue
|
||||
|
||||
|
||||
|
||||
|
@ -132,7 +115,6 @@ class LaserGameDrag(LaserGameBase.LaserGameBase):
|
|||
for posY in range(0, self.gridNumY):
|
||||
if self.gridData[posX][posY] == index:
|
||||
return 0
|
||||
continue
|
||||
|
||||
|
||||
return 1
|
||||
|
@ -142,7 +124,7 @@ class LaserGameDrag(LaserGameBase.LaserGameBase):
|
|||
for symbol in self.symbolList:
|
||||
if not self.checkForClear(symbol):
|
||||
return 0
|
||||
continue
|
||||
|
||||
|
||||
return 1
|
||||
|
||||
|
|
52
toontown/coghq/LawOfficeManagerAI.py
Normal file
52
toontown/coghq/LawOfficeManagerAI.py
Normal file
|
@ -0,0 +1,52 @@
|
|||
from direct.directnotify import DirectNotifyGlobal
|
||||
import DistributedLawOfficeAI
|
||||
import DistributedStageAI
|
||||
from toontown.coghq import StageLayout
|
||||
from toontown.toonbase import ToontownGlobals
|
||||
from direct.showbase import DirectObject
|
||||
import random
|
||||
StageId2Layouts = {ToontownGlobals.LawbotStageIntA: (0, 1, 2),
|
||||
ToontownGlobals.LawbotStageIntB: (3, 4, 5),
|
||||
ToontownGlobals.LawbotStageIntC: (6, 7, 8),
|
||||
ToontownGlobals.LawbotStageIntD: (9, 10, 11)}
|
||||
|
||||
class LawOfficeManagerAI(DirectObject.DirectObject):
|
||||
notify = DirectNotifyGlobal.directNotify.newCategory('LawOfficeManagerAI')
|
||||
lawOfficeId = None
|
||||
|
||||
def __init__(self, air):
|
||||
DirectObject.DirectObject.__init__(self)
|
||||
self.air = air
|
||||
|
||||
def getDoId(self):
|
||||
return 0
|
||||
|
||||
def createLawOffice(self, StageId, entranceId, players):
|
||||
for avId in players:
|
||||
if bboard.has('StageId-%s' % avId):
|
||||
StageId = bboard.get('StageId-%s' % avId)
|
||||
break
|
||||
|
||||
floor = 0
|
||||
layoutIndex = None
|
||||
for avId in players:
|
||||
if bboard.has('stageRoom-%s' % avId):
|
||||
roomId = bboard.get('stageRoom-%s' % avId)
|
||||
for lt in StageId2Layouts[StageId]:
|
||||
for i in xrange(StageLayout.getNumFloors(lt)):
|
||||
layout = StageLayout.StageLayout(StageId, i, stageLayout=lt)
|
||||
if roomId in layout.getRoomIds():
|
||||
layoutIndex = lt
|
||||
floor = i
|
||||
|
||||
else:
|
||||
from toontown.coghq import StageRoomSpecs
|
||||
roomName = StageRoomSpecs.CashbotStageRoomId2RoomName[roomId]
|
||||
LawOfficeManagerAI.notify.warning('room %s (%s) not found in any floor of Stage %s' % (roomId, roomName, StageId))
|
||||
|
||||
StageZone = self.air.allocateZone()
|
||||
if layoutIndex is None:
|
||||
layoutIndex = random.choice(StageId2Layouts[StageId])
|
||||
Stage = DistributedStageAI.DistributedStageAI(self.air, StageId, StageZone, floor, players, layoutIndex)
|
||||
Stage.generateWithRequired(StageZone)
|
||||
return StageZone
|
|
@ -13,6 +13,7 @@ from toontown.toontowngui import TTDialog
|
|||
from toontown.toonbase import ToontownBattleGlobals
|
||||
from toontown.coghq import DistributedStage
|
||||
from toontown.building import Elevator
|
||||
from otp.nametag import NametagGlobals
|
||||
|
||||
class StageInterior(BattlePlace.BattlePlace):
|
||||
notify = DirectNotifyGlobal.directNotify.newCategory('StageInterior')
|
||||
|
|
67
toontown/hood/LawbotHQAI.py
Normal file
67
toontown/hood/LawbotHQAI.py
Normal file
|
@ -0,0 +1,67 @@
|
|||
from CogHoodAI import CogHoodAI
|
||||
from toontown.toonbase import ToontownGlobals
|
||||
from toontown.suit.DistributedLawbotBossAI import DistributedLawbotBossAI
|
||||
from toontown.coghq.DistributedLawOfficeElevatorExtAI import DistributedLawOfficeElevatorExtAI
|
||||
from toontown.building.DistributedCJElevatorAI import DistributedCJElevatorAI
|
||||
from toontown.coghq.DistributedCogHQDoorAI import DistributedCogHQDoorAI
|
||||
from toontown.building import DoorTypes
|
||||
from toontown.building.DistributedDoorAI import DistributedDoorAI
|
||||
from toontown.building import FADoorCodes
|
||||
|
||||
|
||||
class LawbotHQAI(CogHoodAI):
|
||||
HOOD = ToontownGlobals.LawbotHQ
|
||||
|
||||
def __init__(self, air):
|
||||
CogHoodAI.__init__(self, air)
|
||||
self.createZone()
|
||||
|
||||
def createDoor(self):
|
||||
daInteriorDoor = DistributedCogHQDoorAI(self.air, 0, DoorTypes.INT_COGHQ, self.HOOD)
|
||||
daExteriorDoor = DistributedCogHQDoorAI(self.air, 0, DoorTypes.EXT_COGHQ, ToontownGlobals.LawbotOfficeExt)
|
||||
daExteriorDoor.setOtherDoor(daInteriorDoor)
|
||||
daExteriorDoor.zoneId = self.HOOD
|
||||
daExteriorDoor.generateWithRequired(self.HOOD)
|
||||
daExteriorDoor.sendUpdate('setDoorIndex', [0])
|
||||
self.doors.append(daExteriorDoor)
|
||||
daInteriorDoor.setOtherDoor(daExteriorDoor)
|
||||
daInteriorDoor.zoneId = ToontownGlobals.LawbotOfficeExt
|
||||
daInteriorDoor.generateWithRequired(ToontownGlobals.LawbotOfficeExt)
|
||||
daInteriorDoor.sendUpdate('setDoorIndex', [0])
|
||||
self.doors.append(daInteriorDoor)
|
||||
|
||||
interiorDoor = DistributedCogHQDoorAI(self.air, 0, DoorTypes.INT_COGHQ, self.HOOD, doorIndex=0)
|
||||
exteriorDoor = DistributedCogHQDoorAI(self.air, 0, DoorTypes.EXT_COGHQ, ToontownGlobals.LawbotLobby, doorIndex=1, lockValue=FADoorCodes.LB_DISGUISE_INCOMPLETE)
|
||||
exteriorDoor.setOtherDoor(interiorDoor)
|
||||
exteriorDoor.zoneId = self.HOOD
|
||||
exteriorDoor.generateWithRequired(self.HOOD)
|
||||
exteriorDoor.sendUpdate('setDoorIndex', [1])
|
||||
self.doors.append(exteriorDoor)
|
||||
interiorDoor.setOtherDoor(exteriorDoor)
|
||||
interiorDoor.zoneId = ToontownGlobals.LawbotLobby
|
||||
interiorDoor.generateWithRequired(ToontownGlobals.LawbotLobby)
|
||||
interiorDoor.sendUpdate('setDoorIndex', [0])
|
||||
self.doors.append(interiorDoor)
|
||||
|
||||
|
||||
def createZone(self):
|
||||
CogHoodAI.createZone(self)
|
||||
|
||||
# Create lobby manager...
|
||||
self.createLobbyManager(DistributedLawbotBossAI, ToontownGlobals.LawbotLobby)
|
||||
|
||||
# Create CFO elevator.
|
||||
self.createElevator(DistributedCJElevatorAI, self.lobbyMgr, ToontownGlobals.LawbotLobby, ToontownGlobals.LawbotLobby, boss=True)
|
||||
|
||||
# Make our doors.
|
||||
self.createDoor()
|
||||
|
||||
# Create Suit Planners in the cog playground
|
||||
self.createSuitPlanner(self.HOOD)
|
||||
|
||||
# Create mint elevators.
|
||||
mins = ToontownGlobals.FactoryLaffMinimums[2]
|
||||
self.createElevator(DistributedLawOfficeElevatorExtAI, self.air.lawOfficeMgr, ToontownGlobals.LawbotOfficeExt, ToontownGlobals.LawbotOfficeInt, 0, minLaff=mins[0])
|
||||
self.createElevator(DistributedLawOfficeElevatorExtAI, self.air.lawOfficeMgr, ToontownGlobals.LawbotOfficeExt, ToontownGlobals.LawbotOfficeInt, 1, minLaff=mins[1])
|
||||
self.createElevator(DistributedLawOfficeElevatorExtAI, self.air.lawOfficeMgr, ToontownGlobals.LawbotOfficeExt, ToontownGlobals.LawbotOfficeInt, 2, minLaff=mins[2])
|
||||
self.createElevator(DistributedLawOfficeElevatorExtAI, self.air.lawOfficeMgr, ToontownGlobals.LawbotOfficeExt, ToontownGlobals.LawbotOfficeInt, 3, minLaff=mins[3])
|
|
@ -30,6 +30,9 @@ import math
|
|||
from toontown.coghq import CogDisguiseGlobals
|
||||
from toontown.building import ElevatorConstants
|
||||
from toontown.toonbase import ToontownTimer
|
||||
from otp.nametag import NametagGroup
|
||||
from otp.nametag.NametagConstants import *
|
||||
from otp.nametag import NametagGlobals
|
||||
OneBossCog = None
|
||||
|
||||
class DistributedLawbotBoss(DistributedBossCog.DistributedBossCog, FSM.FSM):
|
||||
|
@ -283,8 +286,8 @@ class DistributedLawbotBoss(DistributedBossCog.DistributedBossCog, FSM.FSM):
|
|||
battleHpr = VBase3(ToontownGlobals.LawbotBossBattleTwoPosHpr[3], ToontownGlobals.LawbotBossBattleTwoPosHpr[4], ToontownGlobals.LawbotBossBattleTwoPosHpr[5])
|
||||
bossTrack = Sequence()
|
||||
self.notify.debug('calling setPosHpr')
|
||||
myInterval = camera.posHprInterval(8, Point3(-22, -100, 35), Point3(-10, -13, 0), startPos=Point3(-22, -90, 35), startHpr=Point3(-10, -13, 0), blendType='easeInOut')
|
||||
chatTrack = Sequence(Func(self.setChatAbsolute, TTLocalizer.LawbotBossTempJury1, CFSpeech), Func(camera.reparentTo, localAvatar), Func(camera.setPos, localAvatar.cameraPositions[0][0]), Func(camera.setHpr, 0, 0, 0), Func(self.releaseToons, 1))
|
||||
myInterval = base.camera.posHprInterval(8, Point3(-22, -100, 35), Point3(-10, -13, 0), startPos=Point3(-22, -90, 35), startHpr=Point3(-10, -13, 0), blendType='easeInOut')
|
||||
chatTrack = Sequence(Func(self.setChatAbsolute, TTLocalizer.LawbotBossTempJury1, CFSpeech), Func(base.camera.reparentTo, localAvatar), Func(base.camera.setPos, localAvatar.cameraPositions[0][0]), Func(base.camera.setHpr, 0, 0, 0), Func(self.releaseToons, 1))
|
||||
bossTrack.append(Func(self.getGeomNode().setH, 180))
|
||||
track, hpr = self.rollBossToPoint(startPos, None, battlePos, None, 0)
|
||||
bossTrack.append(track)
|
||||
|
@ -299,8 +302,8 @@ class DistributedLawbotBoss(DistributedBossCog.DistributedBossCog, FSM.FSM):
|
|||
battlePos = Point3(ToontownGlobals.LawbotBossBattleThreePosHpr[0], ToontownGlobals.LawbotBossBattleThreePosHpr[1], ToontownGlobals.LawbotBossBattleThreePosHpr[2])
|
||||
battleHpr = VBase3(ToontownGlobals.LawbotBossBattleThreePosHpr[3], ToontownGlobals.LawbotBossBattleThreePosHpr[4], ToontownGlobals.LawbotBossBattleThreePosHpr[5])
|
||||
bossTrack = Sequence()
|
||||
myInterval = camera.posHprInterval(8, Point3(-22, -100, 35), Point3(-10, -13, 0), startPos=Point3(-22, -90, 35), startHpr=Point3(-10, -13, 0), blendType='easeInOut')
|
||||
chatTrack = Sequence(Func(self.setChatAbsolute, TTLocalizer.LawbotBossTrialChat1, CFSpeech), Func(camera.reparentTo, localAvatar), Func(camera.setPos, localAvatar.cameraPositions[0][0]), Func(camera.setHpr, 0, 0, 0), Func(self.releaseToons, 1))
|
||||
myInterval = base.camera.posHprInterval(8, Point3(-22, -100, 35), Point3(-10, -13, 0), startPos=Point3(-22, -90, 35), startHpr=Point3(-10, -13, 0), blendType='easeInOut')
|
||||
chatTrack = Sequence(Func(self.setChatAbsolute, TTLocalizer.LawbotBossTrialChat1, CFSpeech), Func(base.camera.reparentTo, localAvatar), Func(base.camera.setPos, localAvatar.cameraPositions[0][0]), Func(base.camera.setHpr, 0, 0, 0), Func(self.releaseToons, 1))
|
||||
bossTrack.append(Func(self.getGeomNode().setH, 180))
|
||||
bossTrack.append(Func(self.loop, 'Ff_neutral'))
|
||||
track, hpr = self.rollBossToPoint(startPos, None, battlePos, None, 0)
|
||||
|
@ -336,9 +339,9 @@ class DistributedLawbotBoss(DistributedBossCog.DistributedBossCog, FSM.FSM):
|
|||
seq += [Wait(0.0)]
|
||||
if hasLocalToon:
|
||||
seq += [Func(self.show),
|
||||
Func(camera.reparentTo, localAvatar),
|
||||
Func(camera.setPos, localAvatar.cameraPositions[0][0]),
|
||||
Func(camera.setHpr, 0, 0, 0)]
|
||||
Func(base.camera.reparentTo, localAvatar),
|
||||
Func(base.camera.setPos, localAvatar.cameraPositions[0][0]),
|
||||
Func(base.camera.setHpr, 0, 0, 0)]
|
||||
seq.append(Func(self.setChatAbsolute, TTLocalizer.LawbotBossPassExam, CFSpeech))
|
||||
seq.append(Wait(5.0))
|
||||
seq.append(Func(self.clearChat))
|
||||
|
@ -692,8 +695,8 @@ class DistributedLawbotBoss(DistributedBossCog.DistributedBossCog, FSM.FSM):
|
|||
self.mainDoor.stash()
|
||||
if not self.reflectedMainDoor.isEmpty():
|
||||
self.reflectedMainDoor.stash()
|
||||
camera.reparentTo(self.elevatorModel)
|
||||
camera.setPosHpr(0, 30, 8, 180, 0, 0)
|
||||
base.camera.reparentTo(self.elevatorModel)
|
||||
base.camera.setPosHpr(0, 30, 8, 180, 0, 0)
|
||||
|
||||
def exitElevator(self):
|
||||
self.notify.debug('----- exitElevator')
|
||||
|
@ -791,7 +794,7 @@ class DistributedLawbotBoss(DistributedBossCog.DistributedBossCog, FSM.FSM):
|
|||
base.playMusic(self.stingMusic, looping=0, volume=1.0)
|
||||
|
||||
def __showCannonsAppearing(self, elapsedTime = 0):
|
||||
allCannonsAppear = Sequence(Func(self.__positionToonsInFrontOfCannons), Func(camera.reparentTo, localAvatar), Func(camera.setPos, localAvatar.cameraPositions[2][0]), Func(camera.lookAt, localAvatar))
|
||||
allCannonsAppear = Sequence(Func(self.__positionToonsInFrontOfCannons), Func(base.camera.reparentTo, localAvatar), Func(base.camera.setPos, localAvatar.cameraPositions[2][0]), Func(base.camera.lookAt, localAvatar))
|
||||
multiCannons = Parallel()
|
||||
index = 0
|
||||
self.involvedToons.sort()
|
||||
|
@ -933,9 +936,9 @@ class DistributedLawbotBoss(DistributedBossCog.DistributedBossCog, FSM.FSM):
|
|||
DistributedBossCog.DistributedBossCog.enterBattleThree(self)
|
||||
self.scaleNodePath.unstash()
|
||||
localAvatar.setPos(-3, 0, 0)
|
||||
camera.reparentTo(localAvatar)
|
||||
camera.setPos(localAvatar.cameraPositions[0][0])
|
||||
camera.setHpr(0, 0, 0)
|
||||
base.camera.reparentTo(localAvatar)
|
||||
base.camera.setPos(localAvatar.cameraPositions[0][0])
|
||||
base.camera.setHpr(0, 0, 0)
|
||||
self.clearChat()
|
||||
self.witnessToon.clearChat()
|
||||
self.reparentTo(render)
|
||||
|
@ -1136,9 +1139,9 @@ class DistributedLawbotBoss(DistributedBossCog.DistributedBossCog, FSM.FSM):
|
|||
self.witnessToon.setPosHpr(*ToontownGlobals.LawbotBossWitnessEpiloguePosHpr)
|
||||
self.witnessToon.loop('Sit')
|
||||
self.__arrangeToonsAroundWitnessToon()
|
||||
camera.reparentTo(render)
|
||||
camera.setPos(self.witnessToon, -9, 12, 6)
|
||||
camera.lookAt(self.witnessToon, 0, 0, 3)
|
||||
base.camera.reparentTo(render)
|
||||
base.camera.setPos(self.witnessToon, -9, 12, 6)
|
||||
base.camera.lookAt(self.witnessToon, 0, 0, 3)
|
||||
intervalName = 'EpilogueMovie'
|
||||
seq = Sequence(self.makeEpilogueMovie(), name=intervalName)
|
||||
seq.start()
|
||||
|
@ -1561,12 +1564,12 @@ class DistributedLawbotBoss(DistributedBossCog.DistributedBossCog, FSM.FSM):
|
|||
bossTrack = Track(
|
||||
(0.5, Sequence(
|
||||
Func(self.clearChat),
|
||||
Func(camera.reparentTo, render),
|
||||
Func(camera.setPos, -3, 45, 25),
|
||||
Func(camera.setHpr, 0, 10, 0))),
|
||||
Func(base.camera.reparentTo, render),
|
||||
Func(base.camera.setPos, -3, 45, 25),
|
||||
Func(base.camera.setHpr, 0, 10, 0))),
|
||||
(1.0, Func(self.setChatAbsolute, TTLocalizer.LawbotBossDefenseWins1, CFSpeech)),
|
||||
(5.5, Func(self.setChatAbsolute, TTLocalizer.LawbotBossDefenseWins2, CFSpeech)),
|
||||
(9.5, Sequence(Func(camera.wrtReparentTo, render))),
|
||||
(9.5, Sequence(Func(base.camera.wrtReparentTo, render))),
|
||||
(9.6, Parallel(
|
||||
rollTrack,
|
||||
Func(self.setChatAbsolute, TTLocalizer.LawbotBossDefenseWins3, CFSpeech),
|
||||
|
@ -1686,7 +1689,7 @@ class DistributedLawbotBoss(DistributedBossCog.DistributedBossCog, FSM.FSM):
|
|||
|
||||
def __makePrepareBattleTwoMovie(self):
|
||||
chatString = TTLocalizer.WitnessToonPrepareBattleTwo % ToontownGlobals.LawbotBossJurorsForBalancedScale
|
||||
movie = Sequence(Func(camera.reparentTo, self.witnessToon), Func(camera.setPos, 0, 8, 2), Func(camera.setHpr, 180, 10, 0), Func(self.witnessToon.setLocalPageChat, chatString, 0))
|
||||
movie = Sequence(Func(base.camera.reparentTo, self.witnessToon), Func(base.camera.setPos, 0, 8, 2), Func(base.camera.setHpr, 180, 10, 0), Func(self.witnessToon.setLocalPageChat, chatString, 0))
|
||||
return movie
|
||||
|
||||
def __doWitnessPrepareBattleThreeChat(self):
|
||||
|
@ -1719,7 +1722,7 @@ class DistributedLawbotBoss(DistributedBossCog.DistributedBossCog, FSM.FSM):
|
|||
self.witnessToon.setLocalPageChat(trialSpeech, 0)
|
||||
|
||||
def __makePrepareBattleThreeMovie(self):
|
||||
movie = Sequence(Func(camera.reparentTo, render), Func(camera.setPos, -15, 15, 20), Func(camera.setHpr, -90, 0, 0), Wait(3), Func(camera.reparentTo, self.witnessToon), Func(camera.setPos, 0, 8, 2), Func(camera.setHpr, 180, 10, 0), Func(self.__doWitnessPrepareBattleThreeChat))
|
||||
movie = Sequence(Func(base.camera.reparentTo, render), Func(base.camera.setPos, -15, 15, 20), Func(base.camera.setHpr, -90, 0, 0), Wait(3), Func(base.camera.reparentTo, self.witnessToon), Func(base.camera.setPos, 0, 8, 2), Func(base.camera.setHpr, 180, 10, 0), Func(self.__doWitnessPrepareBattleThreeChat))
|
||||
return movie
|
||||
|
||||
def countToonJurors(self):
|
||||
|
|
|
@ -1,48 +1,895 @@
|
|||
from otp.ai.AIBaseGlobal import *
|
||||
from direct.distributed.ClockDelta import *
|
||||
import DistributedBossCogAI
|
||||
from direct.directnotify import DirectNotifyGlobal
|
||||
from direct.distributed.DistributedObjectAI import DistributedObjectAI
|
||||
from otp.avatar import DistributedAvatarAI
|
||||
import DistributedSuitAI
|
||||
from toontown.battle import BattleExperienceAI
|
||||
from direct.fsm import FSM
|
||||
from toontown.toonbase import ToontownGlobals
|
||||
from toontown.toon import InventoryBase
|
||||
from toontown.toonbase import TTLocalizer
|
||||
from toontown.battle import BattleBase
|
||||
from toontown.toon import NPCToons
|
||||
from toontown.building import SuitBuildingGlobals
|
||||
import SuitDNA
|
||||
import random
|
||||
from toontown.coghq import DistributedLawbotBossGavelAI
|
||||
from toontown.suit import DistributedLawbotBossSuitAI
|
||||
from toontown.coghq import DistributedLawbotCannonAI
|
||||
from toontown.coghq import DistributedLawbotChairAI
|
||||
from toontown.toonbase import ToontownBattleGlobals
|
||||
|
||||
class DistributedLawbotBossAI(DistributedObjectAI):
|
||||
notify = DirectNotifyGlobal.directNotify.newCategory("DistributedLawbotBossAI")
|
||||
class DistributedLawbotBossAI(DistributedBossCogAI.DistributedBossCogAI, FSM.FSM):
|
||||
notify = DirectNotifyGlobal.directNotify.newCategory('DistributedLawbotBossAI')
|
||||
limitHitCount = 6
|
||||
hitCountDamage = 35
|
||||
numPies = 10
|
||||
maxToonLevels = 77
|
||||
|
||||
def setState(self, todo0):
|
||||
pass
|
||||
def __init__(self, air):
|
||||
DistributedBossCogAI.DistributedBossCogAI.__init__(self, air, 'l')
|
||||
FSM.FSM.__init__(self, 'DistributedLawbotBossAI')
|
||||
self.lawyers = []
|
||||
self.cannons = None
|
||||
self.chairs = None
|
||||
self.gavels = None
|
||||
self.cagedToonNpcId = random.choice(NPCToons.npcFriends.keys())
|
||||
self.bossMaxDamage = ToontownGlobals.LawbotBossMaxDamage
|
||||
self.recoverRate = 0
|
||||
self.recoverStartTime = 0
|
||||
self.bossDamage = ToontownGlobals.LawbotBossInitialDamage
|
||||
self.useCannons = 1
|
||||
self.numToonJurorsSeated = 0
|
||||
self.cannonBallsLeft = {}
|
||||
self.toonLevels = 0
|
||||
if 'Defeat' not in self.keyStates:
|
||||
self.keyStates.append('Defeat')
|
||||
self.toonupValue = 1
|
||||
self.bonusState = False
|
||||
self.bonusTimeStarted = 0
|
||||
self.numBonusStates = 0
|
||||
self.battleThreeTimeStarted = 0
|
||||
self.battleThreeTimeInMin = 0
|
||||
self.numAreaAttacks = 0
|
||||
self.lastAreaAttackTime = 0
|
||||
self.weightPerToon = {}
|
||||
self.cannonIndexPerToon = {}
|
||||
self.battleDifficulty = 0
|
||||
return
|
||||
|
||||
def setBossDamage(self, todo0, todo1, todo2):
|
||||
pass
|
||||
def delete(self):
|
||||
self.notify.debug('DistributedLawbotBossAI.delete')
|
||||
self.__deleteBattleThreeObjects()
|
||||
self.__deleteBattleTwoObjects()
|
||||
taskName = self.uniqueName('clearBonus')
|
||||
taskMgr.remove(taskName)
|
||||
return DistributedBossCogAI.DistributedBossCogAI.delete(self)
|
||||
|
||||
def getHoodId(self):
|
||||
return ToontownGlobals.LawbotHQ
|
||||
|
||||
def getCagedToonNpcId(self):
|
||||
return self.cagedToonNpcId
|
||||
|
||||
def magicWordHit(self, damage, avId):
|
||||
if self.attackCode != ToontownGlobals.BossCogDizzyNow:
|
||||
self.hitBossInsides()
|
||||
self.hitBoss(damage)
|
||||
|
||||
def hitBoss(self, bossDamage):
|
||||
avId = self.air.getAvatarIdFromSender()
|
||||
if not self.validate(avId, avId in self.involvedToons, 'hitBoss from unknown avatar'):
|
||||
return
|
||||
self.validate(avId, bossDamage == 1, 'invalid bossDamage %s' % bossDamage)
|
||||
if bossDamage < 1:
|
||||
return
|
||||
currState = self.getCurrentOrNextState()
|
||||
if currState != 'BattleThree':
|
||||
return
|
||||
if bossDamage <= 12:
|
||||
newWeight = self.weightPerToon.get(avId)
|
||||
if newWeight:
|
||||
bossDamage = newWeight
|
||||
if self.bonusState and bossDamage <= 12:
|
||||
bossDamage *= ToontownGlobals.LawbotBossBonusWeightMultiplier
|
||||
bossDamage = min(self.getBossDamage() + bossDamage, self.bossMaxDamage)
|
||||
self.b_setBossDamage(bossDamage, 0, 0)
|
||||
if self.bossDamage >= self.bossMaxDamage:
|
||||
self.b_setState('Victory')
|
||||
else:
|
||||
self.__recordHit()
|
||||
|
||||
def healBoss(self, bossHeal):
|
||||
bossDamage = -bossHeal
|
||||
avId = self.air.getAvatarIdFromSender()
|
||||
currState = self.getCurrentOrNextState()
|
||||
if currState != 'BattleThree':
|
||||
return
|
||||
bossDamage = min(self.getBossDamage() + bossDamage, self.bossMaxDamage)
|
||||
bossDamage = max(bossDamage, 0)
|
||||
self.b_setBossDamage(bossDamage, 0, 0)
|
||||
if self.bossDamage == 0:
|
||||
self.b_setState('Defeat')
|
||||
else:
|
||||
self.__recordHit()
|
||||
|
||||
def hitBossInsides(self):
|
||||
avId = self.air.getAvatarIdFromSender()
|
||||
if not self.validate(avId, avId in self.involvedToons, 'hitBossInsides from unknown avatar'):
|
||||
return
|
||||
currState = self.getCurrentOrNextState()
|
||||
if currState != 'BattleThree':
|
||||
return
|
||||
self.b_setAttackCode(ToontownGlobals.BossCogDizzyNow)
|
||||
self.b_setBossDamage(self.getBossDamage(), 0, 0)
|
||||
|
||||
def hitToon(self, toonId):
|
||||
avId = self.air.getAvatarIdFromSender()
|
||||
if not self.validate(avId, avId != toonId, 'hitToon on self'):
|
||||
return
|
||||
if avId not in self.involvedToons or toonId not in self.involvedToons:
|
||||
return
|
||||
toon = self.air.doId2do.get(toonId)
|
||||
if toon:
|
||||
self.healToon(toon, self.toonupValue)
|
||||
self.sendUpdate('toonGotHealed', [toonId])
|
||||
|
||||
def touchCage(self):
|
||||
avId = self.air.getAvatarIdFromSender()
|
||||
currState = self.getCurrentOrNextState()
|
||||
if currState != 'BattleThree' and currState != 'NearVictory':
|
||||
return
|
||||
if not self.validate(avId, avId in self.involvedToons, 'touchCage from unknown avatar'):
|
||||
return
|
||||
toon = simbase.air.doId2do.get(avId)
|
||||
if toon:
|
||||
toon.b_setNumPies(self.numPies)
|
||||
toon.__touchedCage = 1
|
||||
|
||||
def touchWitnessStand(self):
|
||||
self.touchCage()
|
||||
|
||||
def finalPieSplat(self):
|
||||
self.notify.debug('finalPieSplat')
|
||||
if self.state != 'NearVictory':
|
||||
return
|
||||
self.b_setState('Victory')
|
||||
|
||||
def doTaunt(self):
|
||||
if not self.state == 'BattleThree':
|
||||
return
|
||||
tauntIndex = random.randrange(len(TTLocalizer.LawbotBossTaunts))
|
||||
extraInfo = 0
|
||||
if tauntIndex == 0 and self.involvedToons:
|
||||
extraInfo = random.randrange(len(self.involvedToons))
|
||||
self.sendUpdate('setTaunt', [tauntIndex, extraInfo])
|
||||
|
||||
def doNextAttack(self, task):
|
||||
for lawyer in self.lawyers:
|
||||
lawyer.doNextAttack(self)
|
||||
|
||||
self.waitForNextAttack(ToontownGlobals.LawbotBossLawyerCycleTime)
|
||||
timeSinceLastAttack = globalClock.getFrameTime() - self.lastAreaAttackTime
|
||||
allowedByTime = 15 < timeSinceLastAttack or self.lastAreaAttackTime == 0
|
||||
doAttack = random.randrange(1,101)
|
||||
self.notify.debug('allowedByTime=%d doAttack=%d' % (allowedByTime, doAttack))
|
||||
if doAttack <= ToontownGlobals.LawbotBossChanceToDoAreaAttack and allowedByTime:
|
||||
self.__doAreaAttack()
|
||||
self.numAreaAttacks += 1
|
||||
self.lastAreaAttackTime = globalClock.getFrameTime()
|
||||
else:
|
||||
chanceToDoTaunt = ToontownGlobals.LawbotBossChanceForTaunt
|
||||
action = random.randrange(1,101)
|
||||
if action <= chanceToDoTaunt:
|
||||
self.doTaunt()
|
||||
pass
|
||||
return
|
||||
if self.attackCode == ToontownGlobals.BossCogDizzyNow:
|
||||
attackCode = ToontownGlobals.BossCogRecoverDizzyAttack
|
||||
else:
|
||||
attackCode = random.choice([ToontownGlobals.BossCogAreaAttack,
|
||||
ToontownGlobals.BossCogFrontAttack,
|
||||
ToontownGlobals.BossCogDirectedAttack,
|
||||
ToontownGlobals.BossCogDirectedAttack,
|
||||
ToontownGlobals.BossCogDirectedAttack,
|
||||
ToontownGlobals.BossCogDirectedAttack])
|
||||
if attackCode == ToontownGlobals.BossCogAreaAttack:
|
||||
self.__doAreaAttack()
|
||||
elif attackCode == ToontownGlobals.BossCogDirectedAttack:
|
||||
self.__doDirectedAttack()
|
||||
else:
|
||||
self.b_setAttackCode(attackCode)
|
||||
def __doAreaAttack(self):
|
||||
self.b_setAttackCode(ToontownGlobals.BossCogAreaAttack)
|
||||
|
||||
def __doDirectedAttack(self):
|
||||
if self.nearToons:
|
||||
toonId = random.choice(self.nearToons)
|
||||
self.b_setAttackCode(ToontownGlobals.BossCogDirectedAttack, toonId)
|
||||
else:
|
||||
self.__doAreaAttack()
|
||||
|
||||
def b_setBossDamage(self, bossDamage, recoverRate, recoverStartTime):
|
||||
self.d_setBossDamage(bossDamage, recoverRate, recoverStartTime)
|
||||
self.setBossDamage(bossDamage, recoverRate, recoverStartTime)
|
||||
|
||||
def setBossDamage(self, bossDamage, recoverRate, recoverStartTime):
|
||||
self.bossDamage = bossDamage
|
||||
self.recoverRate = recoverRate
|
||||
self.recoverStartTime = recoverStartTime
|
||||
|
||||
def getBossDamage(self):
|
||||
now = globalClock.getFrameTime()
|
||||
elapsed = now - self.recoverStartTime
|
||||
return int(max(self.bossDamage - self.recoverRate * elapsed / 60.0, 0))
|
||||
|
||||
def d_setBossDamage(self, bossDamage, recoverRate, recoverStartTime):
|
||||
timestamp = globalClockDelta.localToNetworkTime(recoverStartTime)
|
||||
self.sendUpdate('setBossDamage', [bossDamage, recoverRate, timestamp])
|
||||
|
||||
def waitForNextStrafe(self, delayTime):
|
||||
currState = self.getCurrentOrNextState()
|
||||
if currState == 'BattleThree':
|
||||
taskName = self.uniqueName('NextStrafe')
|
||||
taskMgr.remove(taskName)
|
||||
taskMgr.doMethodLater(delayTime, self.doNextStrafe, taskName)
|
||||
|
||||
def stopStrafes(self):
|
||||
taskName = self.uniqueName('NextStrafe')
|
||||
taskMgr.remove(taskName)
|
||||
|
||||
def doNextStrafe(self, task):
|
||||
if self.attackCode != ToontownGlobals.BossCogDizzyNow:
|
||||
side = random.choice([0, 1])
|
||||
direction = random.choice([0, 1])
|
||||
self.sendUpdate('doStrafe', [side, direction])
|
||||
delayTime = 9
|
||||
self.waitForNextStrafe(delayTime)
|
||||
|
||||
def __sendLawyerIds(self):
|
||||
lawyerIds = []
|
||||
for suit in self.lawyers:
|
||||
lawyerIds.append(suit.doId)
|
||||
|
||||
self.sendUpdate('setLawyerIds', [lawyerIds])
|
||||
|
||||
def d_cagedToonBattleThree(self, index, avId):
|
||||
self.sendUpdate('cagedToonBattleThree', [index, avId])
|
||||
|
||||
def formatReward(self):
|
||||
return str(self.cagedToonNpcId)
|
||||
|
||||
def makeBattleOneBattles(self):
|
||||
self.postBattleState = 'RollToBattleTwo'
|
||||
self.initializeBattles(1, ToontownGlobals.LawbotBossBattleOnePosHpr)
|
||||
|
||||
def generateSuits(self, battleNumber):
|
||||
if battleNumber == 1:
|
||||
weakenedValue = ((1, 1),
|
||||
(2, 2),
|
||||
(2, 2),
|
||||
(1, 1),
|
||||
(1, 1, 1, 1, 1))
|
||||
listVersion = list(SuitBuildingGlobals.SuitBuildingInfo)
|
||||
if simbase.config.GetBool('lawbot-boss-cheat', 0):
|
||||
listVersion[13] = weakenedValue
|
||||
SuitBuildingGlobals.SuitBuildingInfo = tuple(listVersion)
|
||||
return self.invokeSuitPlanner(13, 0)
|
||||
else:
|
||||
return self.invokeSuitPlanner(13, 1)
|
||||
|
||||
def removeToon(self, avId):
|
||||
toon = simbase.air.doId2do.get(avId)
|
||||
if toon:
|
||||
toon.b_setNumPies(0)
|
||||
DistributedBossCogAI.DistributedBossCogAI.removeToon(self, avId)
|
||||
|
||||
def enterOff(self):
|
||||
self.notify.debug('enterOff')
|
||||
DistributedBossCogAI.DistributedBossCogAI.enterOff(self)
|
||||
self.__deleteBattleThreeObjects()
|
||||
self.__resetLawyers()
|
||||
|
||||
def enterElevator(self):
|
||||
self.notify.debug('enterElevatro')
|
||||
DistributedBossCogAI.DistributedBossCogAI.enterElevator(self)
|
||||
self.b_setBossDamage(ToontownGlobals.LawbotBossInitialDamage, 0, 0)
|
||||
|
||||
def enterIntroduction(self):
|
||||
self.notify.debug('enterIntroduction')
|
||||
DistributedBossCogAI.DistributedBossCogAI.enterIntroduction(self)
|
||||
self.b_setBossDamage(ToontownGlobals.LawbotBossInitialDamage, 0, 0)
|
||||
self.__makeChairs()
|
||||
|
||||
def exitIntroduction(self):
|
||||
self.notify.debug('exitIntroduction')
|
||||
DistributedBossCogAI.DistributedBossCogAI.exitIntroduction(self)
|
||||
|
||||
def enterRollToBattleTwo(self):
|
||||
self.divideToons()
|
||||
self.__makeCannons()
|
||||
self.barrier = self.beginBarrier('RollToBattleTwo', self.involvedToons, 50, self.__doneRollToBattleTwo)
|
||||
|
||||
def __doneRollToBattleTwo(self, avIds):
|
||||
self.b_setState('PrepareBattleTwo')
|
||||
|
||||
def exitRollToBattleTwo(self):
|
||||
self.ignoreBarrier(self.barrier)
|
||||
|
||||
def enterPrepareBattleTwo(self):
|
||||
self.__makeCannons()
|
||||
self.barrier = self.beginBarrier('PrepareBattleTwo', self.involvedToons, 45, self.__donePrepareBattleTwo)
|
||||
self.makeBattleTwoBattles()
|
||||
|
||||
def __donePrepareBattleTwo(self, avIds):
|
||||
self.b_setState('BattleTwo')
|
||||
|
||||
def exitPrepareBattleTwo(self):
|
||||
self.ignoreBarrier(self.barrier)
|
||||
|
||||
def __makeCannons(self):
|
||||
if self.cannons == None:
|
||||
self.cannons = []
|
||||
startPt = Point3(*ToontownGlobals.LawbotBossCannonPosA)
|
||||
endPt = Point3(*ToontownGlobals.LawbotBossCannonPosB)
|
||||
totalDisplacement = endPt - startPt
|
||||
self.notify.debug('totalDisplacement=%s' % totalDisplacement)
|
||||
numToons = len(self.involvedToons)
|
||||
stepDisplacement = totalDisplacement / (numToons + 1)
|
||||
for index in range(numToons):
|
||||
newPos = stepDisplacement * (index + 1)
|
||||
self.notify.debug('curDisplacement = %s' % newPos)
|
||||
newPos += startPt
|
||||
self.notify.debug('newPos = %s' % newPos)
|
||||
cannon = DistributedLawbotCannonAI.DistributedLawbotCannonAI(self.air, self, index, newPos[0], newPos[1], newPos[2], -90, 0, 0)
|
||||
cannon.generateWithRequired(self.zoneId)
|
||||
self.cannons.append(cannon)
|
||||
|
||||
return
|
||||
|
||||
def __makeChairs(self):
|
||||
if self.chairs == None:
|
||||
self.chairs = []
|
||||
for index in range(12):
|
||||
chair = DistributedLawbotChairAI.DistributedLawbotChairAI(self.air, self, index)
|
||||
chair.generateWithRequired(self.zoneId)
|
||||
self.chairs.append(chair)
|
||||
|
||||
return
|
||||
|
||||
def __makeBattleTwoObjects(self):
|
||||
self.__makeCannons()
|
||||
self.__makeChairs()
|
||||
|
||||
def __deleteCannons(self):
|
||||
if self.cannons != None:
|
||||
for cannon in self.cannons:
|
||||
cannon.requestDelete()
|
||||
|
||||
self.cannons = None
|
||||
return
|
||||
|
||||
def __deleteChairs(self):
|
||||
if self.chairs != None:
|
||||
for chair in self.chairs:
|
||||
chair.requestDelete()
|
||||
|
||||
self.chairs = None
|
||||
return
|
||||
|
||||
def __stopChairs(self):
|
||||
if self.chairs != None:
|
||||
for chair in self.chairs:
|
||||
chair.stopCogs()
|
||||
|
||||
return
|
||||
|
||||
def __deleteBattleTwoObjects(self):
|
||||
self.__deleteCannons()
|
||||
self.__deleteChairs()
|
||||
|
||||
def getCannonBallsLeft(self, avId):
|
||||
if self.cannonBallsLeft.has_key(avId):
|
||||
return self.cannonBallsLeft[avId]
|
||||
else:
|
||||
self.notify.warning('getCannonBalsLeft invalid avId: %d' % avId)
|
||||
return 0
|
||||
|
||||
def decrementCannonBallsLeft(self, avId):
|
||||
if self.cannonBallsLeft.has_key(avId):
|
||||
self.cannonBallsLeft[avId] -= 1
|
||||
if self.cannonBallsLeft[avId] < 0:
|
||||
self.notify.warning('decrementCannonBallsLeft <0 cannonballs for %d' % avId)
|
||||
self.cannonBallsLeft[avId] = 0
|
||||
else:
|
||||
self.notify.warning('decrementCannonBallsLeft invalid avId: %d' % avId)
|
||||
|
||||
def makeBattleTwoBattles(self):
|
||||
self.postBattleState = 'RollToBattleThree'
|
||||
if self.useCannons:
|
||||
self.__makeBattleTwoObjects()
|
||||
else:
|
||||
self.initializeBattles(2, ToontownGlobals.LawbotBossBattleTwoPosHpr)
|
||||
|
||||
def enterBattleTwo(self):
|
||||
if self.useCannons:
|
||||
self.cannonBallsLeft = {}
|
||||
for toonId in self.involvedToons:
|
||||
self.cannonBallsLeft[toonId] = ToontownGlobals.LawbotBossCannonBallMax
|
||||
|
||||
for chair in self.chairs:
|
||||
chair.requestEmptyJuror()
|
||||
|
||||
self.barrier = self.beginBarrier('BattleTwo', self.involvedToons, ToontownGlobals.LawbotBossJuryBoxMoveTime + 1, self.__doneBattleTwo)
|
||||
if not self.useCannons:
|
||||
if self.battleA:
|
||||
self.battleA.startBattle(self.toonsA, self.suitsA)
|
||||
if self.battleB:
|
||||
self.battleB.startBattle(self.toonsB, self.suitsB)
|
||||
|
||||
def __doneBattleTwo(self, avIds):
|
||||
if self.useCannons:
|
||||
self.b_setState('PrepareBattleThree')
|
||||
else:
|
||||
self.b_setState('RollToBattleThree')
|
||||
|
||||
def exitBattleTwo(self):
|
||||
self.resetBattles()
|
||||
self.numToonJurorsSeated = 0
|
||||
for chair in self.chairs:
|
||||
self.notify.debug('chair.state==%s' % chair.state)
|
||||
if chair.state == 'ToonJuror':
|
||||
self.numToonJurorsSeated += 1
|
||||
|
||||
self.notify.debug('numToonJurorsSeated=%d' % self.numToonJurorsSeated)
|
||||
self.air.writeServerEvent('jurorsSeated', self.doId, '%s|%s|%s' % (self.dept, self.involvedToons, self.numToonJurorsSeated))
|
||||
self.__deleteCannons()
|
||||
self.__stopChairs()
|
||||
|
||||
def enterRollToBattleThree(self):
|
||||
self.divideToons()
|
||||
self.barrier = self.beginBarrier('RollToBattleThree', self.involvedToons, 20, self.__doneRollToBattleThree)
|
||||
|
||||
def __doneRollToBattleThree(self, avIds):
|
||||
self.b_setState('PrepareBattleThree')
|
||||
|
||||
def exitRollToBattleThree(self):
|
||||
self.ignoreBarrier(self.barrier)
|
||||
|
||||
def enterPrepareBattleThree(self):
|
||||
self.calcAndSetBattleDifficulty()
|
||||
self.barrier = self.beginBarrier('PrepareBattleThree', self.involvedToons, 45, self.__donePrepareBattleThree)
|
||||
|
||||
def __donePrepareBattleThree(self, avIds):
|
||||
self.b_setState('BattleThree')
|
||||
|
||||
def exitPrepareBattleThree(self):
|
||||
self.ignoreBarrier(self.barrier)
|
||||
|
||||
def enterBattleThree(self):
|
||||
self.battleThreeTimeStarted = globalClock.getFrameTime()
|
||||
self.calcAndSetBattleDifficulty()
|
||||
self.calculateWeightPerToon()
|
||||
diffSettings = ToontownGlobals.LawbotBossDifficultySettings[self.battleDifficulty]
|
||||
self.ammoCount = diffSettings[0]
|
||||
self.numGavels = diffSettings[1]
|
||||
if self.numGavels >= len(ToontownGlobals.LawbotBossGavelPosHprs):
|
||||
self.numGavels = len(ToontownGlobals.LawbotBossGavelPosHprs)
|
||||
self.numLawyers = diffSettings[2]
|
||||
if self.numLawyers >= len(ToontownGlobals.LawbotBossLawyerPosHprs):
|
||||
self.numLawyers = len(ToontownGlobals.LawbotBossLawyerPosHprs)
|
||||
self.toonupValue = diffSettings[3]
|
||||
self.notify.debug('diffLevel=%d ammoCount=%d gavels=%d lawyers = %d, toonup=%d' % (self.battleDifficulty,
|
||||
self.ammoCount,
|
||||
self.numGavels,
|
||||
self.numLawyers,
|
||||
self.toonupValue))
|
||||
self.air.writeServerEvent('lawbotBossSettings', self.doId, '%s|%s|%s|%s|%s|%s' % (self.dept,
|
||||
self.battleDifficulty,
|
||||
self.ammoCount,
|
||||
self.numGavels,
|
||||
self.numLawyers,
|
||||
self.toonupValue))
|
||||
self.__makeBattleThreeObjects()
|
||||
self.__makeLawyers()
|
||||
self.numPies = self.ammoCount
|
||||
self.resetBattles()
|
||||
self.setPieType()
|
||||
jurorsOver = self.numToonJurorsSeated - ToontownGlobals.LawbotBossJurorsForBalancedScale
|
||||
dmgAdjust = jurorsOver * ToontownGlobals.LawbotBossDamagePerJuror
|
||||
self.b_setBossDamage(ToontownGlobals.LawbotBossInitialDamage + dmgAdjust, 0, 0)
|
||||
if simbase.config.GetBool('lawbot-boss-cheat', 0):
|
||||
self.b_setBossDamage(ToontownGlobals.LawbotBossMaxDamage - 1, 0, 0)
|
||||
self.battleThreeStart = globalClock.getFrameTime()
|
||||
for toonId in self.involvedToons:
|
||||
toon = simbase.air.doId2do.get(toonId)
|
||||
if toon:
|
||||
toon.__touchedCage = 0
|
||||
|
||||
for aGavel in self.gavels:
|
||||
aGavel.turnOn()
|
||||
|
||||
self.waitForNextAttack(5)
|
||||
self.notify.debug('battleDifficulty = %d' % self.battleDifficulty)
|
||||
self.numToonsAtStart = len(self.involvedToons)
|
||||
|
||||
def getToonDifficulty(self):
|
||||
highestCogSuitLevel = 0
|
||||
totalCogSuitLevels = 0.0
|
||||
totalNumToons = 0.0
|
||||
for toonId in self.involvedToons:
|
||||
toon = simbase.air.doId2do.get(toonId)
|
||||
if toon:
|
||||
toonLevel = toon.getNumPromotions(self.dept)
|
||||
totalCogSuitLevels += toonLevel
|
||||
totalNumToons += 1
|
||||
if toon.cogLevels > highestCogSuitLevel:
|
||||
highestCogSuitLevel = toonLevel
|
||||
|
||||
if not totalNumToons:
|
||||
totalNumToons = 1.0
|
||||
averageLevel = totalCogSuitLevels / totalNumToons
|
||||
self.notify.debug('toons average level = %f, highest level = %d' % (averageLevel, highestCogSuitLevel))
|
||||
retval = min(averageLevel, self.maxToonLevels)
|
||||
return retval
|
||||
|
||||
def __saySomething(self, task = None):
|
||||
index = None
|
||||
avId = 0
|
||||
if len(self.involvedToons) == 0:
|
||||
return
|
||||
avId = random.choice(self.involvedToons)
|
||||
toon = simbase.air.doId2do.get(avId)
|
||||
if toon.__touchedCage:
|
||||
if self.cagedToonDialogIndex <= TTLocalizer.CagedToonBattleThreeMaxAdvice:
|
||||
index = self.cagedToonDialogIndex
|
||||
self.cagedToonDialogIndex += 1
|
||||
elif random.random() < 0.2:
|
||||
index = random.randrange(100, TTLocalizer.CagedToonBattleThreeMaxAdvice + 1)
|
||||
else:
|
||||
index = random.randrange(20, TTLocalizer.CagedToonBattleThreeMaxTouchCage + 1)
|
||||
if index:
|
||||
self.d_cagedToonBattleThree(index, avId)
|
||||
self.__saySomethingLater()
|
||||
return
|
||||
|
||||
def __saySomethingLater(self, delayTime = 15):
|
||||
taskName = self.uniqueName('CagedToonSaySomething')
|
||||
taskMgr.remove(taskName)
|
||||
taskMgr.doMethodLater(delayTime, self.__saySomething, taskName)
|
||||
|
||||
def __goodJump(self, avId):
|
||||
currState = self.getCurrentOrNextState()
|
||||
if currState != 'BattleThree':
|
||||
return
|
||||
index = random.randrange(10, TTLocalizer.CagedToonBattleThreeMaxGivePies + 1)
|
||||
self.d_cagedToonBattleThree(index, avId)
|
||||
self.__saySomethingLater()
|
||||
|
||||
def __makeBattleThreeObjects(self):
|
||||
if self.gavels == None:
|
||||
self.gavels = []
|
||||
for index in range(self.numGavels):
|
||||
gavel = DistributedLawbotBossGavelAI.DistributedLawbotBossGavelAI(self.air, self, index)
|
||||
gavel.generateWithRequired(self.zoneId)
|
||||
self.gavels.append(gavel)
|
||||
|
||||
return
|
||||
|
||||
def __deleteBattleThreeObjects(self):
|
||||
if self.gavels != None:
|
||||
for gavel in self.gavels:
|
||||
gavel.request('Off')
|
||||
gavel.requestDelete()
|
||||
|
||||
self.gavels = None
|
||||
return
|
||||
|
||||
def doBattleThreeInfo(self):
|
||||
didTheyWin = 0
|
||||
if self.bossDamage == ToontownGlobals.LawbotBossMaxDamage:
|
||||
didTheyWin = 1
|
||||
self.battleThreeTimeInMin = globalClock.getFrameTime() - self.battleThreeTimeStarted
|
||||
self.battleThreeTimeInMin /= 60.0
|
||||
self.numToonsAtEnd = 0
|
||||
toonHps = []
|
||||
for toonId in self.involvedToons:
|
||||
toon = simbase.air.doId2do.get(toonId)
|
||||
if toon:
|
||||
self.numToonsAtEnd += 1
|
||||
toonHps.append(toon.hp)
|
||||
|
||||
self.air.writeServerEvent('b3Info', self.doId, '%d|%.2f|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%s|%s' % (didTheyWin,
|
||||
self.battleThreeTimeInMin,
|
||||
self.numToonsAtStart,
|
||||
self.numToonsAtEnd,
|
||||
self.numToonJurorsSeated,
|
||||
self.battleDifficulty,
|
||||
self.ammoCount,
|
||||
self.numGavels,
|
||||
self.numLawyers,
|
||||
self.toonupValue,
|
||||
self.numBonusStates,
|
||||
self.numAreaAttacks,
|
||||
toonHps,
|
||||
self.weightPerToon))
|
||||
|
||||
def exitBattleThree(self):
|
||||
self.doBattleThreeInfo()
|
||||
self.stopAttacks()
|
||||
self.stopStrafes()
|
||||
taskName = self.uniqueName('CagedToonSaySomething')
|
||||
taskMgr.remove(taskName)
|
||||
self.__resetLawyers()
|
||||
self.__deleteBattleThreeObjects()
|
||||
|
||||
def enterNearVictory(self):
|
||||
self.resetBattles()
|
||||
|
||||
def exitNearVictory(self):
|
||||
pass
|
||||
|
||||
def hitBoss(self, todo0):
|
||||
pass
|
||||
def enterVictory(self):
|
||||
self.resetBattles()
|
||||
self.suitsKilled.append({'type': None,
|
||||
'level': None,
|
||||
'track': self.dna.dept,
|
||||
'isSkelecog': 0,
|
||||
'isForeman': 0,
|
||||
'isVP': 1,
|
||||
'isCFO': 0,
|
||||
'isSupervisor': 0,
|
||||
'isVirtual': 0,
|
||||
'activeToons': self.involvedToons[:]})
|
||||
self.barrier = self.beginBarrier('Victory', self.involvedToons, 30, self.__doneVictory)
|
||||
return
|
||||
|
||||
def healBoss(self, todo0):
|
||||
pass
|
||||
def __doneVictory(self, avIds):
|
||||
self.d_setBattleExperience()
|
||||
self.b_setState('Reward')
|
||||
BattleExperienceAI.assignRewards(self.involvedToons, self.toonSkillPtsGained, self.suitsKilled, ToontownGlobals.dept2cogHQ(self.dept), self.helpfulToons)
|
||||
preferredDept = random.randrange(len(SuitDNA.suitDepts))
|
||||
typeWeights = ['single'] * 70 + ['building'] * 27 + ['invasion'] * 3
|
||||
preferredSummonType = random.choice(typeWeights)
|
||||
for toonId in self.involvedToons:
|
||||
toon = self.air.doId2do.get(toonId)
|
||||
if toon:
|
||||
self.giveCogSummonReward(toon, preferredDept, preferredSummonType)
|
||||
toon.b_promote(self.deptIndex)
|
||||
|
||||
def hitToon(self, todo0):
|
||||
pass
|
||||
def giveCogSummonReward(self, toon, prefDeptIndex, prefSummonType):
|
||||
cogLevel = int(self.toonLevels / self.maxToonLevels * SuitDNA.suitsPerDept)
|
||||
cogLevel = min(cogLevel, SuitDNA.suitsPerDept - 1)
|
||||
deptIndex = prefDeptIndex
|
||||
summonType = prefSummonType
|
||||
hasSummon = toon.hasParticularCogSummons(prefDeptIndex, cogLevel, prefSummonType)
|
||||
if hasSummon:
|
||||
self.notify.debug('trying to find another reward')
|
||||
if not toon.hasParticularCogSummons(prefDeptIndex, cogLevel, 'single'):
|
||||
summonType = 'single'
|
||||
elif not toon.hasParticularCogSummons(prefDeptIndex, cogLevel, 'building'):
|
||||
summonType = 'building'
|
||||
elif not toon.hasParticularCogSummons(prefDeptIndex, cogLevel, 'invasion'):
|
||||
summonType = 'invasion'
|
||||
else:
|
||||
foundOne = False
|
||||
for curDeptIndex in range(len(SuitDNA.suitDepts)):
|
||||
if not toon.hasParticularCogSummons(curDeptIndex, cogLevel, prefSummonType):
|
||||
deptIndex = curDeptIndex
|
||||
foundOne = True
|
||||
break
|
||||
elif not toon.hasParticularCogSummons(curDeptIndex, cogLevel, 'single'):
|
||||
deptIndex = curDeptIndex
|
||||
summonType = 'single'
|
||||
foundOne = True
|
||||
break
|
||||
elif not toon.hasParticularCogSummons(curDeptIndex, cogLevel, 'building'):
|
||||
deptIndex = curDeptIndex
|
||||
summonType = 'building'
|
||||
foundOne = True
|
||||
break
|
||||
elif not toon.hasParticularCogSummons(curDeptIndex, cogLevel, 'invasion'):
|
||||
summonType = 'invasion'
|
||||
deptIndex = curDeptIndex
|
||||
foundOne = True
|
||||
break
|
||||
|
||||
def hitDefensePan(self):
|
||||
pass
|
||||
possibleCogLevel = range(SuitDNA.suitsPerDept)
|
||||
possibleDeptIndex = range(len(SuitDNA.suitDepts))
|
||||
possibleSummonType = ['single', 'building', 'invasion']
|
||||
typeWeights = ['single'] * 70 + ['building'] * 27 + ['invasion'] * 3
|
||||
if not foundOne:
|
||||
for i in range(5):
|
||||
randomCogLevel = random.choice(possibleCogLevel)
|
||||
randomSummonType = random.choice(typeWeights)
|
||||
randomDeptIndex = random.choice(possibleDeptIndex)
|
||||
if not toon.hasParticularCogSummons(randomDeptIndex, randomCogLevel, randomSummonType):
|
||||
foundOne = True
|
||||
cogLevel = randomCogLevel
|
||||
summonType = randomSummonType
|
||||
deptIndex = randomDeptIndex
|
||||
break
|
||||
|
||||
def hitProsecutionPan(self):
|
||||
pass
|
||||
for curType in possibleSummonType:
|
||||
if foundOne:
|
||||
break
|
||||
for curCogLevel in possibleCogLevel:
|
||||
if foundOne:
|
||||
break
|
||||
for curDeptIndex in possibleDeptIndex:
|
||||
if foundOne:
|
||||
break
|
||||
if not toon.hasParticularCogSummons(curDeptIndex, curCogLevel, curType):
|
||||
foundOne = True
|
||||
cogLevel = curCogLevel
|
||||
summonType = curType
|
||||
deptIndex = curDeptIndex
|
||||
|
||||
def hitChair(self, todo0, todo1):
|
||||
pass
|
||||
if not foundOne:
|
||||
cogLevel = None
|
||||
summonType = None
|
||||
deptIndex = None
|
||||
toon.assignNewCogSummons(cogLevel, summonType, deptIndex)
|
||||
return
|
||||
|
||||
def setLawyerIds(self, todo0):
|
||||
pass
|
||||
def exitVictory(self):
|
||||
self.takeAwayPies()
|
||||
|
||||
def setTaunt(self, todo0, todo1):
|
||||
pass
|
||||
def enterDefeat(self):
|
||||
self.resetBattles()
|
||||
self.barrier = self.beginBarrier('Defeat', self.involvedToons, 10, self.__doneDefeat)
|
||||
|
||||
def toonGotHealed(self, todo0):
|
||||
pass
|
||||
def __doneDefeat(self, avIds):
|
||||
for toonId in self.involvedToons:
|
||||
toon = self.air.doId2do.get(toonId)
|
||||
if toon:
|
||||
toon.b_setHp(0)
|
||||
|
||||
def enteredBonusState(self):
|
||||
pass
|
||||
def exitDefeat(self):
|
||||
self.takeAwayPies()
|
||||
|
||||
def setBattleDifficulty(self, todo0):
|
||||
pass
|
||||
def enterFrolic(self):
|
||||
DistributedBossCogAI.DistributedBossCogAI.enterFrolic(self)
|
||||
self.b_setBossDamage(0, 0, 0)
|
||||
|
||||
def setPieType(self):
|
||||
for toonId in self.involvedToons:
|
||||
toon = simbase.air.doId2do.get(toonId)
|
||||
if toon:
|
||||
toon.d_setPieType(ToontownBattleGlobals.MAX_TRACK_INDEX + 1)
|
||||
|
||||
def takeAwayPies(self):
|
||||
for toonId in self.involvedToons:
|
||||
toon = simbase.air.doId2do.get(toonId)
|
||||
if toon:
|
||||
toon.b_setNumPies(0)
|
||||
|
||||
def __recordHit(self):
|
||||
now = globalClock.getFrameTime()
|
||||
self.hitCount += 1
|
||||
if self.hitCount < self.limitHitCount or self.bossDamage < self.hitCountDamage:
|
||||
return
|
||||
|
||||
def __resetLawyers(self):
|
||||
for suit in self.lawyers:
|
||||
suit.requestDelete()
|
||||
|
||||
self.lawyers = []
|
||||
|
||||
def __makeLawyers(self):
|
||||
self.__resetLawyers()
|
||||
lawCogChoices = ['b',
|
||||
'dt',
|
||||
'ac',
|
||||
'bs',
|
||||
'sd',
|
||||
'le',
|
||||
'bw']
|
||||
for i in range(self.numLawyers):
|
||||
suit = DistributedLawbotBossSuitAI.DistributedLawbotBossSuitAI(self.air, None)
|
||||
suit.dna = SuitDNA.SuitDNA()
|
||||
lawCog = random.choice(lawCogChoices)
|
||||
suit.dna.newSuit(lawCog)
|
||||
suit.setPosHpr(*ToontownGlobals.LawbotBossLawyerPosHprs[i])
|
||||
suit.setBoss(self)
|
||||
suit.generateWithRequired(self.zoneId)
|
||||
self.lawyers.append(suit)
|
||||
|
||||
self.__sendLawyerIds()
|
||||
return
|
||||
|
||||
def hitChair(self, chairIndex, npcToonIndex):
|
||||
avId = self.air.getAvatarIdFromSender()
|
||||
if not self.validate(avId, avId in self.involvedToons, 'hitChair from unknown avatar'):
|
||||
return
|
||||
if not self.chairs:
|
||||
return
|
||||
if chairIndex < 0 or chairIndex >= len(self.chairs):
|
||||
self.notify.warning('invalid chairIndex = %d' % chairIndex)
|
||||
return
|
||||
if not self.state == 'BattleTwo':
|
||||
return
|
||||
self.chairs[chairIndex].b_setToonJurorIndex(npcToonIndex)
|
||||
self.chairs[chairIndex].requestToonJuror()
|
||||
|
||||
def clearBonus(self, taskName):
|
||||
if self and hasattr(self, 'bonusState'):
|
||||
self.bonusState = False
|
||||
|
||||
def startBonusState(self):
|
||||
self.notify.debug('startBonusState')
|
||||
self.bonusTimeStarted = globalClock.getFrameTime()
|
||||
self.bonusState = True
|
||||
self.numBonusStates += 1
|
||||
for toonId in self.involvedToons:
|
||||
toon = self.air.doId2do.get(toonId)
|
||||
if toon:
|
||||
self.healToon(toon, ToontownGlobals.LawbotBossBonusToonup)
|
||||
|
||||
taskMgr.doMethodLater(ToontownGlobals.LawbotBossBonusDuration, self.clearBonus, self.uniqueName('clearBonus'))
|
||||
self.sendUpdate('enteredBonusState', [])
|
||||
|
||||
def areAllLawyersStunned(self):
|
||||
for lawyer in self.lawyers:
|
||||
if not lawyer.stunned:
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
def checkForBonusState(self):
|
||||
if self.bonusState:
|
||||
return
|
||||
if not self.areAllLawyersStunned():
|
||||
return
|
||||
curTime = globalClock.getFrameTime()
|
||||
delta = curTime - self.bonusTimeStarted
|
||||
if ToontownGlobals.LawbotBossBonusWaitTime < delta:
|
||||
self.startBonusState()
|
||||
|
||||
def toonEnteredCannon(self, toonId, cannonIndex):
|
||||
self.cannonIndexPerToon[toonId] = cannonIndex
|
||||
|
||||
def numJurorsSeatedByCannon(self, cannonIndex):
|
||||
retVal = 0
|
||||
for chair in self.chairs:
|
||||
if chair.state == 'ToonJuror':
|
||||
if chair.toonJurorIndex == cannonIndex:
|
||||
retVal += 1
|
||||
|
||||
return retVal
|
||||
|
||||
def calculateWeightPerToon(self):
|
||||
for toonId in self.involvedToons:
|
||||
defaultWeight = 1
|
||||
bonusWeight = 0
|
||||
cannonIndex = self.cannonIndexPerToon.get(toonId)
|
||||
if not cannonIndex == None:
|
||||
diffSettings = ToontownGlobals.LawbotBossDifficultySettings[self.battleDifficulty]
|
||||
if diffSettings[4]:
|
||||
bonusWeight = self.numJurorsSeatedByCannon(cannonIndex) - diffSettings[5]
|
||||
if bonusWeight < 0:
|
||||
bonusWeight = 0
|
||||
newWeight = defaultWeight + bonusWeight
|
||||
self.weightPerToon[toonId] = newWeight
|
||||
self.notify.debug('toon %d has weight of %d' % (toonId, newWeight))
|
||||
|
||||
return
|
||||
|
||||
def b_setBattleDifficulty(self, batDiff):
|
||||
self.setBattleDifficulty(batDiff)
|
||||
self.d_setBattleDifficulty(batDiff)
|
||||
|
||||
def setBattleDifficulty(self, batDiff):
|
||||
self.battleDifficulty = batDiff
|
||||
|
||||
def d_setBattleDifficulty(self, batDiff):
|
||||
self.sendUpdate('setBattleDifficulty', [batDiff])
|
||||
|
||||
def calcAndSetBattleDifficulty(self):
|
||||
self.toonLevels = self.getToonDifficulty()
|
||||
numDifficultyLevels = len(ToontownGlobals.LawbotBossDifficultySettings)
|
||||
battleDifficulty = int(self.toonLevels / self.maxToonLevels * numDifficultyLevels)
|
||||
if battleDifficulty >= numDifficultyLevels:
|
||||
battleDifficulty = numDifficultyLevels - 1
|
||||
self.b_setBattleDifficulty(battleDifficulty)
|
||||
|
|
|
@ -1,21 +1,198 @@
|
|||
from otp.ai.AIBaseGlobal import *
|
||||
from direct.distributed.ClockDelta import *
|
||||
from direct.directnotify import DirectNotifyGlobal
|
||||
from toontown.suit.DistributedSuitBaseAI import DistributedSuitBaseAI
|
||||
from toontown.battle import SuitBattleGlobals
|
||||
from toontown.toonbase import ToontownGlobals
|
||||
import DistributedSuitBaseAI
|
||||
import random
|
||||
from direct.fsm import ClassicFSM, State
|
||||
from direct.fsm import State
|
||||
|
||||
class DistributedLawbotBossSuitAI(DistributedSuitBaseAI):
|
||||
notify = DirectNotifyGlobal.directNotify.newCategory("DistributedLawbotBossSuitAI")
|
||||
class DistributedLawbotBossSuitAI(DistributedSuitBaseAI.DistributedSuitBaseAI):
|
||||
notify = DirectNotifyGlobal.directNotify.newCategory('DistributedLawbotBossSuitAI')
|
||||
|
||||
def setPosHpr(self, todo0, todo1, todo2, todo3, todo4, todo5):
|
||||
def __init__(self, air, suitPlanner):
|
||||
DistributedSuitBaseAI.DistributedSuitBaseAI.__init__(self, air, suitPlanner)
|
||||
self.stunned = False
|
||||
self.timeToRelease = 3.15
|
||||
self.timeProsecuteStarted = 0
|
||||
self.fsm = ClassicFSM.ClassicFSM('DistributedLawbotBossSuitAI', [State.State('Off', self.enterOff, self.exitOff, ['neutral']),
|
||||
State.State('neutral', self.enterNeutral, self.exitNeutral, ['PreThrowProsecute', 'PreThrowAttack', 'Stunned']),
|
||||
State.State('PreThrowProsecute', self.enterPreThrowProsecute, self.exitPreThrowProsecute, ['PostThrowProsecute', 'neutral', 'Stunned']),
|
||||
State.State('PostThrowProsecute', self.enterPostThrowProsecute, self.exitPostThrowProsecute, ['neutral', 'Stunned']),
|
||||
State.State('PreThrowAttack', self.enterPreThrowAttack, self.exitPreThrowAttack, ['PostThrowAttack', 'neutral', 'Stunned']),
|
||||
State.State('PostThrowAttack', self.enterPostThrowAttack, self.exitPostThrowAttack, ['neutral', 'Stunned']),
|
||||
State.State('Stunned', self.enterStunned, self.exitStunned, ['neutral'])], 'Off', 'Off')
|
||||
self.fsm.enterInitialState()
|
||||
|
||||
def delete(self):
|
||||
self.notify.debug('delete %s' % self.doId)
|
||||
self.ignoreAll()
|
||||
DistributedSuitBaseAI.DistributedSuitBaseAI.delete(self)
|
||||
self.notify.debug('setting self.boss to None')
|
||||
self.boss = None
|
||||
taskName = self.uniqueName('ProsecutionHealsBoss')
|
||||
if taskMgr.hasTaskNamed(taskName):
|
||||
self.notify.debug('still has task %s' % taskName)
|
||||
taskMgr.remove(taskName)
|
||||
taskName = self.uniqueName('unstun')
|
||||
if taskMgr.hasTaskNamed(taskName):
|
||||
self.notify.debug('still has task %s' % taskName)
|
||||
taskMgr.remove(taskName)
|
||||
self.fsm = None
|
||||
return
|
||||
|
||||
def requestBattle(self, x, y, z, h, p, r):
|
||||
toonId = self.air.getAvatarIdFromSender()
|
||||
if self.notify.getDebug():
|
||||
self.notify.debug(str(self.getDoId()) + str(self.zoneId) + ': request battle with toon: %d' % toonId)
|
||||
self.confrontPos = Point3(x, y, z)
|
||||
self.confrontHpr = Vec3(h, p, r)
|
||||
if self.sp.requestBattle(self.zoneId, self, toonId):
|
||||
self.acceptOnce(self.getDeathEvent(), self._logDeath, [toonId])
|
||||
if self.notify.getDebug():
|
||||
self.notify.debug('Suit %d requesting battle in zone %d' % (self.getDoId(), self.zoneId))
|
||||
else:
|
||||
if self.notify.getDebug():
|
||||
self.notify.debug('requestBattle from suit %d - denied by battle manager' % self.getDoId())
|
||||
self.b_setBrushOff(SuitDialog.getBrushOffIndex(self.getStyleName()))
|
||||
self.d_denyBattle(toonId)
|
||||
|
||||
def getPosHpr(self):
|
||||
return (self.getX(),
|
||||
self.getY(),
|
||||
self.getZ(),
|
||||
self.getH(),
|
||||
self.getP(),
|
||||
self.getR())
|
||||
|
||||
def getConfrontPosHpr(self):
|
||||
return (self.confrontPos, self.confrontHpr)
|
||||
|
||||
def _logDeath(self, toonId):
|
||||
pass
|
||||
|
||||
def doAttack(self, todo0, todo1, todo2, todo3, todo4, todo5):
|
||||
pass
|
||||
def doNextAttack(self, lawbotBoss):
|
||||
if self.stunned:
|
||||
return
|
||||
chanceToDoAttack = ToontownGlobals.LawbotBossLawyerChanceToAttack
|
||||
action = random.randrange(1, 101)
|
||||
if action > chanceToDoAttack:
|
||||
self.doProsecute()
|
||||
else:
|
||||
if not lawbotBoss.involvedToons:
|
||||
return
|
||||
toonToAttackId = random.choice(lawbotBoss.involvedToons)
|
||||
toon = self.air.doId2do.get(toonToAttackId)
|
||||
if not toon:
|
||||
self.doProsecute()
|
||||
return
|
||||
toonPos = toon.getPos()
|
||||
z2 = toonPos[2] + 1.3
|
||||
toonPos = Point3(toonPos.getX(), toonPos.getY(), 0)
|
||||
lawyerPos = self.getPos()
|
||||
lawyerPos = Point3(self.getPos().getX(), self.getPos().getY(), 0)
|
||||
dirVector = toonPos - lawyerPos
|
||||
dirVector.normalize()
|
||||
dirVector *= 200
|
||||
destPos = Point3(lawyerPos[0] + dirVector[0], lawyerPos[1] + dirVector[1], lawyerPos[2] + dirVector[2] + 1.3)
|
||||
self.d_doAttack(lawyerPos[0], lawyerPos[1], lawyerPos[2], destPos[0], destPos[1], destPos[2])
|
||||
|
||||
def doProsecute(self):
|
||||
pass
|
||||
self.notify.debug('doProsecute')
|
||||
self.timeProsecuteStarted = globalClockDelta.getRealNetworkTime()
|
||||
self.d_doProsecute()
|
||||
taskName = self.uniqueName('ProsecutionHealsBoss')
|
||||
duration = 5.65
|
||||
taskMgr.doMethodLater(duration, self.__prosecutionHeal, taskName)
|
||||
|
||||
def __prosecutionHeal(self, extraArg):
|
||||
self.notify.debug('__prosecutionHeal extraArg %s' % extraArg)
|
||||
if self.boss:
|
||||
self.boss.healBoss(ToontownGlobals.LawbotBossLawyerHeal)
|
||||
|
||||
def d_doProsecute(self):
|
||||
self.notify.debug('d_doProsecute')
|
||||
self.sendUpdate('doProsecute', [])
|
||||
|
||||
def d_doAttack(self, x1, y1, z1, x2, y2, z2):
|
||||
self.notify.debug('doAttack: x1=%.2f y1=%.2f z2=%.2f x2=%.2f y2=%.2f z2=%.2f' % (x1,
|
||||
y1,
|
||||
z1,
|
||||
x2,
|
||||
y2,
|
||||
z2))
|
||||
self.sendUpdate('doAttack', [x1,
|
||||
y1,
|
||||
z1,
|
||||
x2,
|
||||
y2,
|
||||
z2])
|
||||
|
||||
def setBoss(self, lawbotBoss):
|
||||
self.boss = lawbotBoss
|
||||
|
||||
def hitByToon(self):
|
||||
self.notify.debug('I got hit by a toon')
|
||||
if not self.stunned:
|
||||
curTime = globalClockDelta.getRealNetworkTime()
|
||||
deltaTime = curTime - self.timeProsecuteStarted
|
||||
deltaTime /= 100.0
|
||||
self.notify.debug('deltaTime = %f, curTime=%f, prosecuteStarted=%f' % (deltaTime, curTime, self.timeProsecuteStarted))
|
||||
if deltaTime < self.timeToRelease:
|
||||
taskName = self.uniqueName('ProsecutionHealsBoss')
|
||||
taskMgr.remove(taskName)
|
||||
self.sendUpdate('doStun', [])
|
||||
self.setStun(True)
|
||||
taskName = self.uniqueName('unstun')
|
||||
taskMgr.doMethodLater(ToontownGlobals.LawbotBossLawyerStunTime, self.unStun, taskName)
|
||||
if self.boss:
|
||||
self.boss.checkForBonusState()
|
||||
|
||||
def setStun(self, val):
|
||||
self.stunned = val
|
||||
|
||||
def unStun(self, taskName):
|
||||
self.setStun(False)
|
||||
|
||||
def enterPreThrowProsecute(self):
|
||||
pass
|
||||
|
||||
def doStun(self):
|
||||
def exitPreThrowProsecute(self):
|
||||
pass
|
||||
|
||||
def enterPostThrowProsecute(self):
|
||||
pass
|
||||
|
||||
def exitPostThrowProsecute(self):
|
||||
pass
|
||||
|
||||
def enterPreThrowAttack(self):
|
||||
pass
|
||||
|
||||
def exitPreThrowAttack(self):
|
||||
pass
|
||||
|
||||
def enterPostThrowAttack(self):
|
||||
pass
|
||||
|
||||
def exitPostThrowAttack(self):
|
||||
pass
|
||||
|
||||
def enterStunned(self):
|
||||
pass
|
||||
|
||||
def exitStunned(self):
|
||||
pass
|
||||
|
||||
def enterOff(self):
|
||||
pass
|
||||
|
||||
def exitOff(self):
|
||||
pass
|
||||
|
||||
def enterNeutral(self):
|
||||
pass
|
||||
|
||||
def exitNeutral(self):
|
||||
pass
|
||||
|
|
|
@ -1,6 +1,14 @@
|
|||
from toontown.suit import DistributedFactorySuitAI
|
||||
from direct.directnotify import DirectNotifyGlobal
|
||||
from toontown.suit.DistributedFactorySuitAI import DistributedFactorySuitAI
|
||||
|
||||
class DistributedStageSuitAI(DistributedFactorySuitAI):
|
||||
notify = DirectNotifyGlobal.directNotify.newCategory("DistributedStageSuitAI")
|
||||
class DistributedStageSuitAI(DistributedFactorySuitAI.DistributedFactorySuitAI):
|
||||
notify = DirectNotifyGlobal.directNotify.newCategory('DistributedStageSuitAI')
|
||||
|
||||
def isForeman(self):
|
||||
return 0
|
||||
|
||||
def isSupervisor(self):
|
||||
return self.boss
|
||||
|
||||
def isVirtual(self):
|
||||
return self.virtual
|
||||
|
|
Loading…
Reference in a new issue