def __init__(self, air, furnitureMgr, catalogItem): DistributedFurnitureItemAI.__init__(self, air, furnitureMgr, catalogItem) self.ownerId = 0 self.currAvId = 0 self.currAvDNA = None self.inUse = False self.timer = Timer('DistributedClosetAITimer')
def __init__(self): """ __init__() """ self.pos = Point3(0, 0, 0) self.initialSuitPos = Point3(0, 1, 0) self.timer = Timer() self.resetLists()
def activate(self): self.collectTimer = Timer.Timer() self.collectTimer.startCallback(CogdoBarrelRoomConsts.CollectionTime, self.__endCollectionPhase) for barrel in self.spawnedBarrels: barrel.interactive = True taskMgr.remove(self.allBarrelsCollectedTask) taskMgr.doMethodLater(CogdoBarrelRoomConsts.AllBarrelsCollectedTime, self.__checkAllBarrelsCollected, self.allBarrelsCollectedTask)
def __init__(self, air, exterior): DistributedObjectAI.__init__(self, air) FSM.FSM.__init__(self, 'CogdoInteriorAIFSM') self.toons = filter(None, exterior.elevator.seats[:]) self.responses = {} self.bldgDoId = exterior.doId self.numFloors = NUM_FLOORS_DICT[exterior.track] self.sosNPC = self.__generateSOS(exterior.difficulty) self.shopOwnerNpcId = 0 self.extZoneId, self.zoneId = exterior.getExteriorAndInteriorZoneId() npcIdList = NPCToons.zone2NpcDict.get(self.zoneId, []) if len(npcIdList) == 0: self.notify.info('No NPC in taken cogdo at %s' % self.zoneId) else: if len(npcIdList) > 1: self.notify.warning('Multiple NPCs in taken cogdo at %s' % self.zoneId) self.shopOwnerNpcId = npcIdList[0] self.gameDone = 0 self.bossBattleDone = 0 self.curFloor = 0 self.topFloor = 2 self.timer = Timer.Timer() self.exterior = exterior self.planner = self.exterior.planner self.savedByMap = {} self.battle = None self.FOType = exterior.track self.gameFloor = 1 self.battleFloor = 2 self.barrelFloor = -1 if self.FOType == 'l': self.battleFloor = 3 self.barrelFloor = 2 self.topFloor += 1 self.toonSkillPtsGained = {} self.toonExp = {} self.toonOrigQuests = {} self.toonItems = {} self.toonOrigMerits = {} self.toonMerits = {} self.toonParts = {} self.helpfulToons = [] self.barrels = [] self.suits = [] self.activeSuits = [] self.reserveSuits = [] self.joinedReserves = [] self.suitsKilled = [] self.suitsKilledPerFloor = [] self.ignoreResponses = 0 self.ignoreElevatorDone = 0 self.ignoreReserveJoinDone = 0
def __init__(self, air, elevator): self.air = air DistributedObjectAI.DistributedObjectAI.__init__(self, air) self.extZoneId, self.zoneId = elevator.bldg.getExteriorAndInteriorZoneId() self.numFloors = elevator.bldg.planner.numFloors self.avatarExitEvents = [] self.toons = [] self.toonSkillPtsGained = {} self.toonExp = {} self.toonOrigQuests = {} self.toonItems = {} self.toonOrigMerits = {} self.toonMerits = {} self.toonParts = {} self.helpfulToons = [] self.currentFloor = 0 self.topFloor = self.numFloors - 1 self.bldg = elevator.bldg self.elevator = elevator self.suits = [] self.activeSuits = [] self.reserveSuits = [] self.joinedReserves = [] self.suitsKilled = [] self.suitsKilledPerFloor = [] self.battle = None self.timer = Timer.Timer() self.responses = {} self.ignoreResponses = 0 self.ignoreElevatorDone = 0 self.ignoreReserveJoinDone = 0 self.toonIds = copy.copy(elevator.seats) for toonId in self.toonIds: if toonId != None: self.__addToon(toonId) self.savedByMap = {} self.fsm = ClassicFSM.ClassicFSM('DistributedSuitInteriorAI', [ State.State('WaitForAllToonsInside', self.enterWaitForAllToonsInside, self.exitWaitForAllToonsInside, [ 'Elevator']), State.State('Elevator', self.enterElevator, self.exitElevator, [ 'Battle']), State.State('Battle', self.enterBattle, self.exitBattle, [ 'ReservesJoining', 'BattleDone']), State.State('ReservesJoining', self.enterReservesJoining, self.exitReservesJoining, [ 'Battle']), State.State('BattleDone', self.enterBattleDone, self.exitBattleDone, [ 'Resting', 'Reward']), State.State('Resting', self.enterResting, self.exitResting, [ 'Elevator']), State.State('Reward', self.enterReward, self.exitReward, [ 'Off']), State.State('Off', self.enterOff, self.exitOff, [ 'WaitForAllToonsInside'])], 'Off', 'Off', onUndefTransition=ClassicFSM.ClassicFSM.ALLOW) self.fsm.enterInitialState() return
def __init__(self, air): DistCogdoGameAI.__init__(self, air) self.numSuits = (0, 0, 0) self.timer = Timer.Timer() self.doorRevealed = False self.toonsInDoor = [] self.bosses = {} self.fastMinions = {} self.slowMinions = {} self.suitTypes = [self.bosses, self.fastMinions, self.slowMinions] self.numJokes = {}
def __init__(self, air, elevator): self.air = air DistributedObjectAI.DistributedObjectAI.__init__(self, air) (self.extZoneId, self.zoneId) = elevator.bldg.getExteriorAndInteriorZoneId() self._numFloors = elevator.bldg.planner.numFloors self.layout = elevator.bldg._cogdoLayout self.avatarExitEvents = [] self.toons = [] self.toonSkillPtsGained = {} self.toonExp = {} self.toonOrigQuests = {} self.toonItems = {} self.toonOrigMerits = {} self.toonMerits = {} self.toonParts = {} self.helpfulToons = [] self.shopOwnerNpcId = 0 npcDesc = NPCToons.zone2NpcDict.get(self.zoneId) if npcDesc: self.shopOwnerNpcId = npcDesc[0] if not self.shopOwnerNpcId: self.notify.warning('No npcs found for current cogdo building') self.currentFloor = 0 self.bldg = elevator.bldg self.elevator = elevator self._game = None self._CogdoGameRepeat = config.GetBool('cogdo-game-repeat', 0) self.suits = [] self.activeSuits = [] self.reserveSuits = [] self.joinedReserves = [] self.suitsKilled = [] self.suitsKilledPerFloor = [] self.battle = None self.timer = Timer.Timer() self._wantBarrelRoom = config.GetBool('cogdo-want-barrel-room', 1) self.barrelRoom = None self.responses = {} self.ignoreResponses = 0 self.ignoreElevatorDone = 0 self.ignoreReserveJoinDone = 0 self.toonIds = copy.copy(elevator.seats) for toonId in self.toonIds: if toonId != None: self.__addToon(toonId) self.savedByMap = {} self.fsm = ClassicFSM.ClassicFSM( 'DistributedCogdoInteriorAI', [ State.State('WaitForAllToonsInside', self.enterWaitForAllToonsInside, self.exitWaitForAllToonsInside, ['Elevator']), State.State('Elevator', self.enterElevator, self.exitElevator, ['Game']), State.State('Game', self.enterGame, self.exitGame, ['Resting', 'Failed', 'BattleIntro', 'Off']), State.State('BarrelRoomIntro', self.enterBarrelRoomIntro, self.exitBarrelRoomIntro, ['CollectBarrels', 'Off']), State.State('CollectBarrels', self.enterCollectBarrels, self.exitCollectBarrels, ['BarrelRoomReward', 'Off']), State.State( 'BarrelRoomReward', self.enterBarrelRoomReward, self.exitBarrelRoomReward, ['Battle', 'ReservesJoining', 'BattleIntro', 'Off']), State.State( 'BattleIntro', self.enterBattleIntro, self.exitBattleIntro, ['Battle', 'ReservesJoining', 'Off']), State.State('Battle', self.enterBattle, self.exitBattle, ['ReservesJoining', 'BattleDone', 'Off']), State.State('ReservesJoining', self.enterReservesJoining, self.exitReservesJoining, ['Battle', 'Off']), State.State('BattleDone', self.enterBattleDone, self.exitBattleDone, ['Resting', 'Reward', 'Off']), State.State('Resting', self.enterResting, self.exitResting, ['Elevator', 'Off', 'BarrelRoomIntro']), State.State('Reward', self.enterReward, self.exitReward, ['Off']), State.State('Failed', self.enterFailed, self.exitFailed, ['Off']), State.State('Off', self.enterOff, self.exitOff, ['WaitForAllToonsInside']) ], 'Off', 'Off', onUndefTransition=ClassicFSM.ClassicFSM.ALLOW) self.fsm.enterInitialState() safeZone = ZoneUtil.getCanonicalHoodId(self.extZoneId) self.difficulty = SafeZones.index(safeZone) self.SOSCard = self.chooseSOSCard(self.difficulty) self.barrelRoomDone = False self.intElevator = None self.memoCount = 0
class DistributedClosetAI(DistributedFurnitureItemAI): notify = DirectNotifyGlobal.directNotify.newCategory("DistributedClosetAI") def __init__(self, air, furnitureMgr, catalogItem): DistributedFurnitureItemAI.__init__(self, air, furnitureMgr, catalogItem) self.ownerId = 0 self.currAvId = 0 self.currAvDNA = None self.inUse = False self.timer = Timer('DistributedClosetAITimer') def setOwnerId(self, id): self.ownerId = id def getOwnerId(self): return self.ownerId def enterAvatar(self): avId = self.air.getAvatarIdFromSender() if self.inUse: self.sendUpdateToAvatarId(avId, 'freeAvatar', []) return ownerAv = self.air.doId2do.get(self.ownerId) topList, botList = ([], []) if ownerAv: topList = ownerAv.getClothesTopsList() botList = ownerAv.getClothesBottomsList() av = self.air.doId2do.get(avId) if av: avDna = ToonDNA(av.getDNAString()) self.d_setState(OPEN, avId, avDna.gender, topList, botList) self.setInUse(avId) self.resetTimeout() def setInUse(self, avId): av = self.air.doId2do.get(avId) if av: self.inUse = True self.currAvId = avId event = self.air.getAvatarExitEvent(avId) self.accept(event, self.__handleUnexpectedExit, [avId]) self.currAvDNA = av.getDNAString() def __handleUnexpectedExit(self, avId): self.notify.info('Avatar %s unexpected exit! Setting closet free...' % avId) self.setFree() def setFree(self): self.inUse = False self.currAvId = 0 self.currAvDNA = None def d_setState(self, mode, avId, gender='', topList=[], botList=[]): self.sendUpdate('setState', [mode, avId, self.ownerId, gender, topList, botList]) def d_setMovie(self, mode, avId): self.sendUpdate( 'setMovie', [mode, avId, globalClockDelta.getRealNetworkTime()]) def resetTimeout(self): self.timer.stop() self.timer.startCallback(TIMEOUT_TIME + 10, self.handleTimeout) def handleTimeout(self): self.d_setMovie(CLOSET_MOVIE_TIMEOUT, self.currAvId) self.d_setState(CLOSED, self.currAvId) self.setFree() def setDNA(self, dnaStr, definitive, which): self.resetTimeout() if self.currAvId: currAv = self.air.doId2do.get(self.currAvId) if currAv: if definitive == 2 and which > 0: dna = ToonDNA(self.currAvDNA) newDNA = ToonDNA(dnaStr) if which & SHIRT: if currAv.replaceItemInClothesTopsList( newDNA.topTex, newDNA.topTexColor, newDNA.sleeveTex, newDNA.sleeveTexColor, dna.topTex, dna.topTexColor, dna.sleeveTex, dna.sleeveTexColor) == 1: currAv.b_setClothesTopsList( currAv.getClothesTopsList()) if which & SHORTS: if currAv.replaceItemInClothesBottomsList( newDNA.botTex, newDNA.botTexColor, dna.botTex, dna.botTexColor) == 1: currAv.b_setClothesBottomsList( currAv.getClothesBottomsList()) currAv.b_setDNAString(dnaStr) self.d_setMovie(CLOSET_MOVIE_COMPLETE, self.currAvId) self.d_setState(CLOSED, self.currAvId) self.setFree() self.timer.stop() elif definitive == 1: currAv.b_setDNAString(self.currAvDNA) self.d_setMovie(CLOSET_MOVIE_COMPLETE, self.currAvId) self.d_setState(CLOSED, self.currAvId) self.setFree() self.timer.stop() else: self.sendUpdate('setCustomerDNA', [self.currAvId, self.currAvDNA]) def removeItem(self, dna, t_or_b): dna = ToonDNA(dna) currAv = self.air.doId2do.get(self.currAvId) if currAv: if t_or_b == SHIRT: if currAv.removeItemInClothesTopsList(dna.topTex, dna.topTexColor, dna.sleeveTex, dna.sleeveTexColor) == 1: currAv.b_setClothesTopsList(currAv.getClothesTopsList()) elif t_or_b == SHORTS: if currAv.removeItemInClothesBottomsList( dna.botTex, dna.botTexColor) == 1: currAv.b_setClothesBottomsList( currAv.getClothesBottomsList())
def __init__(self, air, elevator): self.air = air DistributedObjectAI.DistributedObjectAI.__init__(self, air) self.extZoneId, self.zoneId = elevator.bldg.getExteriorAndInteriorZoneId( ) self.numFloors = elevator.bldg.planner.numFloors assert (len(elevator.seats) == 4) self.avatarExitEvents = [] self.toons = [] self.toonSkillPtsGained = {} self.toonExp = {} self.toonOrigQuests = {} self.toonItems = {} self.toonOrigMerits = {} self.toonMerits = {} self.toonParts = {} self.helpfulToons = [] self.currentFloor = 0 self.topFloor = self.numFloors - 1 self.bldg = elevator.bldg self.elevator = elevator self.suits = [] self.activeSuits = [] self.reserveSuits = [] self.joinedReserves = [] self.suitsKilled = [] self.suitsKilledPerFloor = [] self.battle = None self.timer = Timer.Timer() self.responses = {} self.ignoreResponses = 0 self.ignoreElevatorDone = 0 self.ignoreReserveJoinDone = 0 # Register all the toons self.toonIds = copy.copy(elevator.seats) for toonId in self.toonIds: if (toonId != None): self.__addToon(toonId) assert (len(self.toons) > 0) # Build a map of id:(name, style) pairs to have around for the # end in case the toons are successful. These elements are # filled in as each toon registers with the building. self.savedByMap = {} self.fsm = ClassicFSM.ClassicFSM( 'DistributedSuitInteriorAI', [ State.State('WaitForAllToonsInside', self.enterWaitForAllToonsInside, self.exitWaitForAllToonsInside, ['Elevator']), State.State('Elevator', self.enterElevator, self.exitElevator, ['Battle']), State.State('Battle', self.enterBattle, self.exitBattle, ['ReservesJoining', 'BattleDone']), State.State('ReservesJoining', self.enterReservesJoining, self.exitReservesJoining, ['Battle']), State.State('BattleDone', self.enterBattleDone, self.exitBattleDone, ['Resting', 'Reward']), State.State('Resting', self.enterResting, self.exitResting, ['Elevator']), State.State('Reward', self.enterReward, self.exitReward, ['Off']), State.State('Off', self.enterOff, self.exitOff, ['WaitForAllToonsInside']) ], # Initial state 'Off', # Final state 'Off', onUndefTransition=ClassicFSM.ClassicFSM.ALLOW) self.fsm.enterInitialState()
def __init__(self, air, elevator): self.air = air DistributedObjectAI.DistributedObjectAI.__init__(self, air) self.extZoneId, self.zoneId = elevator.bldg.getExteriorAndInteriorZoneId() self._numFloors = elevator.bldg.planner.numFloors self.layout = elevator.bldg._cogdoLayout assert(len(elevator.seats) == 4) self.avatarExitEvents = [] self.toons = [] self.toonSkillPtsGained = {} self.toonExp = {} self.toonOrigQuests = {} self.toonItems = {} self.toonOrigMerits = {} self.toonMerits = {} self.toonParts = {} self.helpfulToons = [] self.shopOwnerNpcId = 0 npcDesc = NPCToons.zone2NpcDict.get(self.zoneId) if npcDesc: self.shopOwnerNpcId = npcDesc[0] if not self.shopOwnerNpcId: self.notify.warning('No npcs found for current cogdo building') self.currentFloor = 0 self.bldg = elevator.bldg self.elevator = elevator self._game = None self._CogdoGameRepeat = ConfigVariableBool('cogdo-game-repeat', 0).getValue() self.suits = [] self.activeSuits = [] self.reserveSuits = [] self.joinedReserves = [] self.suitsKilled = [] self.suitsKilledPerFloor = [] self.battle = None self.timer = Timer.Timer() self._wantBarrelRoom = ConfigVariableBool('cogdo-want-barrel-room', 0).getValue() self.barrelRoom = None self.responses = {} self.ignoreResponses = 0 self.ignoreElevatorDone = 0 self.ignoreReserveJoinDone = 0 # Register all the toons self.toonIds = copy.copy(elevator.seats) for toonId in self.toonIds: if (toonId != None): self.__addToon(toonId) assert(len(self.toons) > 0) # Build a map of id:(name, style) pairs to have around for the # end in case the toons are successful. These elements are # filled in as each toon registers with the building. self.savedByMap = {} self.fsm = ClassicFSM.ClassicFSM( 'DistributedCogdoInteriorAI', [State.State('WaitForAllToonsInside', self.enterWaitForAllToonsInside, self.exitWaitForAllToonsInside, ['Elevator']), State.State('Elevator', self.enterElevator, self.exitElevator, ['Game']), State.State('Game', self.enterGame, self.exitGame, ['Resting', 'Failed', 'BattleIntro', 'Off']), State.State('BarrelRoomIntro', self.enterBarrelRoomIntro, self.exitBarrelRoomIntro, ['CollectBarrels', 'Off']), State.State('CollectBarrels', self.enterCollectBarrels, self.exitCollectBarrels, ['BarrelRoomReward', 'Off']), State.State('BarrelRoomReward', self.enterBarrelRoomReward, self.exitBarrelRoomReward, ['Battle', 'ReservesJoining', 'BattleIntro', 'Off']), State.State('BattleIntro', self.enterBattleIntro, self.exitBattleIntro, ['Battle', 'ReservesJoining', 'Off']), State.State('Battle', self.enterBattle, self.exitBattle, ['ReservesJoining', 'BattleDone']), State.State('ReservesJoining', self.enterReservesJoining, self.exitReservesJoining, ['Battle']), State.State('BattleDone', self.enterBattleDone, self.exitBattleDone, ['Resting', 'Reward']), State.State('Resting', self.enterResting, self.exitResting, ['Elevator']), State.State('Reward', self.enterReward, self.exitReward, ['Off']), State.State('Failed', self.enterFailed, self.exitFailed, [ 'Off']), State.State('Off', self.enterOff, self.exitOff, ['WaitForAllToonsInside'])], # Initial state 'Off', # Final state 'Off', onUndefTransition = ClassicFSM.ClassicFSM.ALLOW) self.fsm.enterInitialState() safeZone = ZoneUtil.getCanonicalHoodId(self.extZoneId) difficulty = SafeZones.index(safeZone) self.SOSCard = self.chooseSOSCard(difficulty)
class DistributedClosetAI(DistributedFurnitureItemAI): notify = DirectNotifyGlobal.directNotify.newCategory("DistributedClosetAI") def __init__(self, air, furnitureMgr, catalogItem): DistributedFurnitureItemAI.__init__(self, air, furnitureMgr, catalogItem) self.ownerId = 0 self.currAvId = 0 self.currAvDNA = None self.inUse = False self.timer = Timer('DistributedClosetAITimer') def setOwnerId(self, id): self.ownerId = id def getOwnerId(self): return self.ownerId def enterAvatar(self): avId = self.air.getAvatarIdFromSender() if self.inUse: self.sendUpdateToAvatarId(avId, 'freeAvatar', []) return ownerAv = self.air.doId2do.get(self.ownerId) topList,botList = ([],[]) if ownerAv: topList = ownerAv.getClothesTopsList() botList = ownerAv.getClothesBottomsList() av = self.air.doId2do.get(avId) if av: avDna = ToonDNA(av.getDNAString()) self.d_setState(OPEN, avId, avDna.gender, topList, botList) self.setInUse(avId) self.resetTimeout() def setInUse(self, avId): av = self.air.doId2do.get(avId) if av: self.inUse = True self.currAvId = avId event = self.air.getAvatarExitEvent(avId) self.accept(event, self.__handleUnexpectedExit, [avId]) self.currAvDNA = av.getDNAString() def __handleUnexpectedExit(self, avId): self.notify.info('Avatar %s unexpected exit! Setting closet free...' %avId) self.setFree() def setFree(self): self.inUse = False self.currAvId = 0 self.currAvDNA = None def d_setState(self, mode, avId, gender = '', topList = [], botList = []): self.sendUpdate('setState', [mode, avId, self.ownerId, gender, topList, botList]) def d_setMovie(self, mode, avId): self.sendUpdate('setMovie', [mode, avId, globalClockDelta.getRealNetworkTime()]) def resetTimeout(self): self.timer.stop() self.timer.startCallback(TIMEOUT_TIME + 10, self.handleTimeout) def handleTimeout(self): self.d_setMovie(CLOSET_MOVIE_TIMEOUT, self.currAvId) self.d_setState(CLOSED, self.currAvId) self.setFree() def setDNA(self, dnaStr, definitive, which): self.resetTimeout() if self.currAvId: currAv = self.air.doId2do.get(self.currAvId) if currAv: if definitive == 2 and which > 0: if which & SHIRT: dna = ToonDNA(self.currAvDNA) newDNA = ToonDNA(dnaStr) if currAv.replaceItemInClothesTopsList(newDNA.topTex, newDNA.topTexColor, newDNA.sleeveTex, newDNA.sleeveTexColor, dna.topTex, dna.topTexColor, dna.sleeveTex, dna.sleeveTexColor) == 1: currAv.b_setClothesTopsList(currAv.getClothesTopsList()) if which & SHORTS: if currAv.replaceItemInClothesBottomsList(newDNA.botTex, newDNA.botTexColor, dna.botTex, dna.botTexColor) == 1: currAv.b_setClothesBottomsList(currAv.getClothesBottomsList()) currAv.b_setDNAString(dnaStr) self.d_setMovie(CLOSET_MOVIE_COMPLETE, self.currAvId) self.d_setState(CLOSED, self.currAvId) self.setFree() self.timer.stop() elif definitive == 1: currAv.b_setDNAString(self.currAvDNA) self.d_setMovie(CLOSET_MOVIE_COMPLETE, self.currAvId) self.d_setState(CLOSED, self.currAvId) self.setFree() self.timer.stop() else: self.sendUpdate('setCustomerDNA', [self.currAvId, self.currAvDNA]) def removeItem(self, dna, t_or_b): dna = ToonDNA(dna) currAv = self.air.doId2do.get(self.currAvId) if currAv: if t_or_b == SHIRT: if currAv.removeItemInClothesTopsList(dna.topTex, dna.topTexColor, dna.sleeveTex, dna.sleeveTexColor) == 1: currAv.b_setClothesTopsList(currAv.getClothesTopsList()) elif t_or_b == SHORTS: if currAv.removeItemInClothesBottomsList(dna.botTex, dna.botTexColor) == 1: currAv.b_setClothesBottomsList(currAv.getClothesBottomsList()) #self.sendUpdate('resetItemLists')