def setup(self): self.dnaStore = base.cr.playGame.dnaStore self.randomGenerator = random.Random() self.randomGenerator.seed(self.zoneId) self.interior = loader.loadModel('phase_4/models/modules/gagShop_interior') self.interior.reparentTo(render) hoodId = ZoneUtil.getCanonicalHoodId(self.zoneId) self.colors = ToonInteriorColors.colors[hoodId] self.replaceRandomInModel(self.interior) door = self.chooseDoor() doorOrigin = render.find('**/door_origin;+s') doorNP = door.copyTo(doorOrigin) doorOrigin.setScale(0.8, 0.8, 0.8) doorOrigin.setPos(doorOrigin, 0, -0.025, 0) doorColor = self.randomGenerator.choice(self.colors['TI_door']) DNADoor.setupDoor(doorNP, self.interior, doorOrigin, self.dnaStore, str(self.block), doorColor) doorFrame = doorNP.find('door_*_flat') doorFrame.wrtReparentTo(self.interior) doorFrame.setColor(doorColor) del self.colors del self.dnaStore del self.randomGenerator self.interior.flattenMedium() for npcToon in self.cr.doFindAllInstances(DistributedNPCToonBase): npcToon.initToonState()
def setupDoors(self): self.randomGenerator = random.Random() self.randomGenerator.seed(self.zoneId) self.colors = ToonInteriorColors.colors[ToontownCentral] door = self.chooseDoor() doorOrigins = render.findAllMatches('**/door_origin*') numDoorOrigins = doorOrigins.getNumPaths() for npIndex in range(numDoorOrigins): doorOrigin = doorOrigins[npIndex] doorOriginNPName = doorOrigin.getName() doorOriginIndexStr = doorOriginNPName[len('door_origin_'):] newNode = ModelNode('door_' + doorOriginIndexStr) newNodePath = NodePath(newNode) newNodePath.reparentTo(self.interior) doorNP = door.copyTo(newNodePath) doorOrigin.setScale(0.8, 0.8, 0.8) doorOrigin.setPos(doorOrigin, 0, -0.025, 0) doorColor = self.randomGenerator.choice(self.colors['TI_door']) triggerId = str(self.block) + '_' + doorOriginIndexStr DNADoor.setupDoor(doorNP, newNodePath, doorOrigin, self.dnaStore, triggerId, doorColor) doorFrame = doorNP.find('door_*_flat') doorFrame.setColor(doorColor) del self.dnaStore del self.randomGenerator
def setup(self): self.dnaStore = base.cr.playGame.dnaStore self.randomGenerator = random.Random() self.randomGenerator.seed(self.zoneId) self.interior = loader.loadModel( 'phase_4/models/modules/gagShop_interior') self.interior.reparentTo(render) hoodId = ZoneUtil.getCanonicalHoodId(self.zoneId) self.colors = ToonInteriorColors.colors[hoodId] self.replaceRandomInModel(self.interior) door = self.chooseDoor() doorOrigin = render.find('**/door_origin;+s') doorNP = door.copyTo(doorOrigin) doorOrigin.setScale(0.8, 0.8, 0.8) doorOrigin.setPos(doorOrigin, 0, -0.025, 0) doorColor = self.randomGenerator.choice(self.colors['TI_door']) DNADoor.setupDoor(doorNP, self.interior, doorOrigin, self.dnaStore, str(self.block), doorColor) doorFrame = doorNP.find('door_*_flat') doorFrame.wrtReparentTo(self.interior) doorFrame.setColor(doorColor) del self.colors del self.dnaStore del self.randomGenerator self.interior.flattenMedium() for npcToon in self.cr.doFindAllInstances(DistributedNPCToonBase): npcToon.initToonState()
def announceGenerate(self): DistributedObject.announceGenerate(self) self.interior = loader.loadModel('phase_4/models/modules/ttc_library_interior.bam') self.interior.reparentTo(render) generator = random.Random() generator.seed(self.zoneId) self.replaceRandom(self.interior, generator=generator) doorOrigin = self.interior.find('**/door_origin;+s') doorOrigin.setScale(0.8) doorOrigin.setY(doorOrigin, -0.025) door = self.cr.playGame.dnaStore.findNode('door_double_round_ur') doorNodePath = door.copyTo(doorOrigin) hoodId = ZoneUtil.getCanonicalHoodId(self.zoneId) doorColor = ToonInteriorColors.colors[hoodId]['TI_door'][0] DNADoor.setupDoor( doorNodePath, self.interior, doorOrigin, self.cr.playGame.dnaStore, str(self.block), doorColor) doorFrame = doorNodePath.find('door_double_round_ur_flat') doorFrame.wrtReparentTo(self.interior) doorFrame.setColor(doorColor) for npcToon in self.cr.doFindAllInstances(DistributedNPCToonBase): npcToon.initToonState()
def setup(self): self.dnaStore = base.cr.playGame.dnaStore self.randomGenerator = random.Random() self.randomGenerator.seed(self.zoneId) interior = self.randomDNAItem('TI_hall', self.dnaStore.findNode) self.interior = interior.copyTo(render) hoodId = ZoneUtil.getCanonicalHoodId(self.zoneId) self.colors = ToonInteriorColors.colors[hoodId] self.replaceRandomInModel(self.interior) doorModelName = 'door_double_round_ul' if doorModelName[-1:] == 'r': doorModelName = doorModelName[:-1] + 'l' else: doorModelName = doorModelName[:-1] + 'r' door = self.dnaStore.findNode(doorModelName) door_origin = render.find('**/door_origin;+s') doorNP = door.copyTo(door_origin) door_origin.setScale(0.8, 0.8, 0.8) door_origin.setPos(door_origin, 0, -0.025, 0) color = self.randomGenerator.choice(self.colors['TI_door']) DNADoor.setupDoor(doorNP, self.interior, door_origin, self.dnaStore, str(self.block), color) doorFrame = doorNP.find('door_*_flat') doorFrame.wrtReparentTo(self.interior) doorFrame.setColor(color) del self.colors del self.dnaStore del self.randomGenerator self.interior.flattenMedium() self.sillyFSM.enterInitialState() for npcToon in self.cr.doFindAllInstances(DistributedNPCToonBase): npcToon.initToonState()
def announceGenerate(self): DistributedObject.announceGenerate(self) self.interior = loader.loadModel( 'phase_4/models/modules/ttc_library_interior.bam') self.interior.reparentTo(render) generator = random.Random() generator.seed(self.zoneId) self.replaceRandom(self.interior, generator=generator) doorOrigin = self.interior.find('**/door_origin;+s') doorOrigin.setScale(0.8) doorOrigin.setY(doorOrigin, -0.025) door = self.cr.playGame.dnaStore.findNode('door_double_round_ur') doorNodePath = door.copyTo(doorOrigin) hoodId = ZoneUtil.getCanonicalHoodId(self.zoneId) doorColor = ToonInteriorColors.colors[hoodId]['TI_door'][0] DNADoor.setupDoor(doorNodePath, self.interior, doorOrigin, self.cr.playGame.dnaStore, str(self.block), doorColor) doorFrame = doorNodePath.find('door_double_round_ur_flat') doorFrame.wrtReparentTo(self.interior) doorFrame.setColor(doorColor) for npcToon in self.cr.doFindAllInstances(DistributedNPCToonBase): npcToon.initToonState()
def setup(self): self.dnaStore = base.cr.playGame.dnaStore self.randomGenerator = random.Random() self.randomGenerator.seed(self.zoneId) interior = self.randomDNAItem('TI_room', self.dnaStore.findNode) self.interior = interior.copyTo(render) hoodId = ZoneUtil.getCanonicalHoodId(self.zoneId) self.colors = ToonInteriorColors.colors[hoodId] self.replaceRandomInModel(self.interior) doorModelName = 'door_double_round_ul' if doorModelName[-1:] == 'r': doorModelName = doorModelName[:-1] + 'l' else: doorModelName = doorModelName[:-1] + 'r' door = self.dnaStore.findNode(doorModelName) door_origin = render.find('**/door_origin;+s') doorNP = door.copyTo(door_origin) door_origin.setScale(0.8, 0.8, 0.8) door_origin.setPos(door_origin, 0, -0.025, 0) color = self.randomGenerator.choice(self.colors['TI_door']) DNADoor.setupDoor(doorNP, self.interior, door_origin, self.dnaStore, str(self.block), color) doorFrame = doorNP.find('door_*_flat') doorFrame.wrtReparentTo(self.interior) doorFrame.setColor(color) sign = hidden.find('**/tb%s:*_landmark_*_DNARoot/**/sign;+s' % (self.block,)) if not sign.isEmpty(): signOrigin = self.interior.find('**/sign_origin;+s') newSignNP = sign.copyTo(signOrigin) newSignNP.setDepthWrite(1, 1) #TODO: getSignTransform #mat = self.dnaStore.getSignTransformFromBlockNumber(int(self.block)) inv = Mat4(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) #inv.invertFrom(mat) newSignNP.setMat(inv) newSignNP.flattenLight() ll = Point3() ur = Point3() newSignNP.calcTightBounds(ll, ur) width = ur[0] - ll[0] height = ur[2] - ll[2] if width != 0 and height != 0: xScale = (SIGN_RIGHT - SIGN_LEFT) / width zScale = (SIGN_TOP - SIGN_BOTTOM) / height scale = min(xScale, zScale) xCenter = (ur[0] + ll[0]) / 2.0 zCenter = (ur[2] + ll[2]) / 2.0 newSignNP.setPosHprScale((SIGN_RIGHT + SIGN_LEFT) / 2.0 - xCenter * scale, -0.1, (SIGN_TOP + SIGN_BOTTOM) / 2.0 - zCenter * scale, 0.0, 0.0, 0.0, scale, scale, scale) trophyOrigin = self.interior.find('**/trophy_origin') trophy = self.buildTrophy() if trophy: trophy.reparentTo(trophyOrigin) del self.colors del self.dnaStore del self.randomGenerator self.interior.flattenMedium() for npcToon in self.cr.doFindAllInstances(DistributedNPCToonBase): npcToon.initToonState()
def setup(self): self.dnaStore = base.cr.playGame.dnaStore self.randomGenerator = random.Random() self.randomGenerator.seed(self.zoneId) interior = self.randomDNAItem('TI_room', self.dnaStore.findNode) self.interior = interior.copyTo(render) hoodId = ZoneUtil.getCanonicalHoodId(self.zoneId) self.colors = ToonInteriorColors.colors[hoodId] self.replaceRandomInModel(self.interior) doorModelName = 'door_double_round_ul' if doorModelName[-1:] == 'r': doorModelName = doorModelName[:-1] + 'l' else: doorModelName = doorModelName[:-1] + 'r' door = self.dnaStore.findNode(doorModelName) door_origin = render.find('**/door_origin;+s') doorNP = door.copyTo(door_origin) door_origin.setScale(0.8, 0.8, 0.8) door_origin.setPos(door_origin, 0, -0.025, 0) color = self.randomGenerator.choice(self.colors['TI_door']) DNADoor.setupDoor(doorNP, self.interior, door_origin, self.dnaStore, str(self.block), color) doorFrame = doorNP.find('door_*_flat') doorFrame.wrtReparentTo(self.interior) doorFrame.setColor(color) sign = hidden.find('**/tb%s:*_landmark_*_DNARoot/**/sign;+s' % (self.block,)) if not sign.isEmpty(): signOrigin = self.interior.find('**/sign_origin;+s') newSignNP = sign.copyTo(signOrigin) newSignNP.setDepthWrite(1, 1) mat = self.interior.getNetTransform().getMat() inv = Mat4(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) inv.invertFrom(mat) newSignNP.setMat(inv) newSignNP.flattenLight() ll = Point3() ur = Point3() newSignNP.calcTightBounds(ll, ur) width = ur[0] - ll[0] height = ur[2] - ll[2] if width != 0 and height != 0: xScale = (SIGN_RIGHT - SIGN_LEFT) / width zScale = (SIGN_TOP - SIGN_BOTTOM) / height scale = min(xScale, zScale) xCenter = (ur[0] + ll[0]) / 2.0 zCenter = (ur[2] + ll[2]) / 2.0 newSignNP.setPosHprScale((SIGN_RIGHT + SIGN_LEFT) / 2.0 - xCenter * scale, -0.1, (SIGN_TOP + SIGN_BOTTOM) / 2.0 - zCenter * scale, 0.0, 0.0, 0.0, scale, scale, scale) trophyOrigin = self.interior.find('**/trophy_origin') trophy = self.buildTrophy() if trophy: trophy.reparentTo(trophyOrigin) del self.colors del self.dnaStore del self.randomGenerator self.interior.flattenMedium() for npcToon in self.cr.doFindAllInstances(DistributedNPCToonBase): npcToon.initToonState()
def setup(self): self.dnaStore = base.cr.playGame.dnaStore self.randomGenerator = random.Random() self.randomGenerator.seed(self.zoneId) self.interior = loader.loadModel( 'phase_4/models/modules/ttc_bank_interior.bam') self.interior.reparentTo(render) self.vaultOpenSfx = loader.loadSfx( 'phase_4/audio/sfx/vault_door_open.ogg') self.vaultCloseSfx = loader.loadSfx( 'phase_4/audio/sfx/vault_door_close.ogg') hoodId = ZoneUtil.getCanonicalHoodId(self.zoneId) self.colors = ToonInteriorColors.colors[hoodId] self.replaceRandomInModel(self.interior) door = self.chooseDoor() doorOrigin = render.find('**/door_origin;+s') doorNP = door.copyTo(doorOrigin) doorOrigin.setScale(0.8, 0.8, 0.8) doorOrigin.setPos(doorOrigin, 0, -0.025, 0) doorColor = self.randomGenerator.choice(self.colors['TI_door']) DNADoor.setupDoor(doorNP, self.interior, doorOrigin, self.dnaStore, str(self.block), doorColor) doorFrame = doorNP.find('door_*_flat') doorFrame.wrtReparentTo(self.interior) doorFrame.setColor(doorColor) del self.colors del self.dnaStore del self.randomGenerator room = render.find('**/vault_walls') minPoint, maxPoint = room.getTightBounds() offset = 1 # We want a slight offset maxPoint -= offset collBox = CollisionBox(minPoint, maxPoint) collBox.setTangible(0) collNode = CollisionNode(self.uniqueName('vaultBox')) collNode.setIntoCollideMask(BitMask32(1)) collNode.addSolid(collBox) self.collNodePath = render.attachNewNode(collNode) radius = ((maxPoint - minPoint) / 2).getZ() self.collNodePath.setPos(-11.2 + (offset / 2), 14 + radius + offset, 0) for npcToon in self.cr.doFindAllInstances(DistributedNPCToonBase): npcToon.initToonState() self.accept(self.uniqueName('entervaultBox'), self.__handleEnterVaultBox) self.accept(self.uniqueName('exitvaultBox'), self.__handleExitVaultBox)
def setup(self): self.dnaStore = base.cr.playGame.dnaStore self.randomGenerator = random.Random() self.randomGenerator.seed(self.zoneId) self.interior = loader.loadModel('phase_4/models/modules/ttc_bank_interior.bam') self.interior.reparentTo(render) self.vaultOpenSfx = loader.loadSfx('phase_4/audio/sfx/vault_door_open.ogg') self.vaultCloseSfx = loader.loadSfx('phase_4/audio/sfx/vault_door_close.ogg') hoodId = ZoneUtil.getCanonicalHoodId(self.zoneId) self.colors = ToonInteriorColors.colors[hoodId] self.replaceRandomInModel(self.interior) door = self.chooseDoor() doorOrigin = render.find('**/door_origin;+s') doorNP = door.copyTo(doorOrigin) doorOrigin.setScale(0.8, 0.8, 0.8) doorOrigin.setPos(doorOrigin, 0, -0.025, 0) doorColor = self.randomGenerator.choice(self.colors['TI_door']) DNADoor.setupDoor(doorNP, self.interior, doorOrigin, self.dnaStore, str(self.block), doorColor) doorFrame = doorNP.find('door_*_flat') doorFrame.wrtReparentTo(self.interior) doorFrame.setColor(doorColor) del self.colors del self.dnaStore del self.randomGenerator room = render.find('**/vault_walls') minPoint, maxPoint = room.getTightBounds() offset = 1 # We want a slight offset maxPoint -= offset collBox = CollisionBox(minPoint, maxPoint) collBox.setTangible(0) collNode = CollisionNode(self.uniqueName('vaultBox')) collNode.setIntoCollideMask(BitMask32(1)) collNode.addSolid(collBox) self.collNodePath = render.attachNewNode(collNode) radius = ((maxPoint-minPoint) / 2).getZ() self.collNodePath.setPos(-11.2 + (offset/2), 14 + radius + offset, 0) for npcToon in self.cr.doFindAllInstances(DistributedNPCToonBase): npcToon.initToonState() self.accept(self.uniqueName('entervaultBox'), self.__handleEnterVaultBox) self.accept(self.uniqueName('exitvaultBox'), self.__handleExitVaultBox)
def setup(self): dnaStore = base.cr.playGame.dnaStore self.interior = loader.loadModel( HouseInteriorGlobals.Models[self.getInteriorLayout()]) self.interior.reparentTo(render) self.roomNames = HouseInteriorGlobals.RoomNames[ self.getInteriorLayout()] doorModelName = 'door_double_round_ur' door = dnaStore.findNode(doorModelName) door_origin = self.interior.find('**/door_origin') door_origin.setHpr(180, 0, 0) door_origin.setScale(0.8, 0.8, 0.8) door_origin.setPos(door_origin, 0, -0.025, 0) doorNP = door.copyTo(door_origin) houseColor = HouseGlobals.atticWood color = Vec4(houseColor[0], houseColor[1], houseColor[2], 1) DNADoor.setupDoor(doorNP, door_origin, door_origin, dnaStore, str(self.houseId), color) doorFrame = doorNP.find('door_*_flat') doorFrame.setColor(color) self.interior.flattenMedium() self.windowSlots = [] for name in WindowPlugNames: plugNodes = self.interior.findAllMatches(name) if plugNodes.isEmpty(): self.windowSlots.append((None, None)) else: viewBase = plugNodes[0].getParent().attachNewNode('view') viewBase.setTransform(plugNodes[0].getTransform()) plug = plugNodes[0].getParent().attachNewNode('plug') plugNodes.reparentTo(plug) plug.flattenLight() self.windowSlots.append((plug, viewBase)) self.windowSlots[2][1].setPosHpr(16.0, -12.0, 5.51, -90, 0, 0) self.windowSlots[4][1].setPosHpr(-12.0, 26.0, 5.51, 0, 0, 0) self.__colorWalls() self.__setupWindows() messenger.send('houseInteriorLoaded-%d' % self.zoneId) return None
def __setupDoor(self): self.notify.debug("setupDoor") self.dnaStore = self.cr.playGame.dnaStore doorModelName = "door_double_round_ul" if doorModelName[-1:] == "r": doorModelName = doorModelName[:-1] + "l" else: doorModelName = doorModelName[:-1] + "r" door = self.dnaStore.findNode(doorModelName) door_origin = self.house.find("**/door_origin") door_origin.setHpr(90, 0, 0) door_origin.setScale(0.6, 0.6, 0.8) door_origin.setPos(door_origin, 0.5, 0, 0.0) doorNP = door.copyTo(door_origin) self.door_origin = door_origin self.randomGenerator = random.Random() self.randomGenerator.seed(self.doId) houseColor = HouseGlobals.stairWood color = Vec4(houseColor[0], houseColor[1], houseColor[2], 1) DNADoor.setupDoor(doorNP, door_origin, door_origin, self.dnaStore, str(self.doId), color) self.__setupNamePlate() self.__setupFloorMat() self.__setupNametag()
def __setupDoor(self): self.notify.debug('setupDoor') self.dnaStore = self.cr.playGame.dnaStore doorModelName = 'door_double_round_ul' if doorModelName[-1:] == 'r': doorModelName = doorModelName[:-1] + 'l' else: doorModelName = doorModelName[:-1] + 'r' door = self.dnaStore.findNode(doorModelName) door_origin = self.house.find('**/door_origin') door_origin.setHpr(90, 0, 0) door_origin.setScale(0.6, 0.6, 0.8) door_origin.setPos(door_origin, 0.5, 0, 0.0) doorNP = door.copyTo(door_origin) self.door_origin = door_origin self.randomGenerator = random.Random() self.randomGenerator.seed(self.doId) houseColor = HouseGlobals.stairWood color = Vec4(houseColor[0], houseColor[1], houseColor[2], 1) DNADoor.setupDoor(doorNP, door_origin, door_origin, self.dnaStore, str(self.doId), color) self.__setupNamePlate() self.__setupFloorMat() self.__setupNametag()
def setup(self): dnaStore = base.cr.playGame.dnaStore self.interior = loader.loadModel('phase_5.5/models/estate/tt_m_ara_int_estateHouseA') self.interior.reparentTo(render) doorModelName = 'door_double_round_ur' door = dnaStore.findNode(doorModelName) door_origin = self.interior.find('**/door_origin') door_origin.setHpr(180, 0, 0) door_origin.setScale(0.8, 0.8, 0.8) door_origin.setPos(door_origin, 0, -0.025, 0) doorNP = door.copyTo(door_origin) houseColor = HouseGlobals.atticWood color = Vec4(houseColor[0], houseColor[1], houseColor[2], 1) DNADoor.setupDoor(doorNP, door_origin, door_origin, dnaStore, str(self.houseId), color) doorFrame = doorNP.find('door_*_flat') doorFrame.setColor(color) self.interior.flattenMedium() self.windowSlots = [] for name in WindowPlugNames: plugNodes = self.interior.findAllMatches(name) if plugNodes.isEmpty(): self.windowSlots.append((None, None)) else: viewBase = plugNodes[0].getParent().attachNewNode('view') viewBase.setTransform(plugNodes[0].getTransform()) plug = plugNodes[0].getParent().attachNewNode('plug') plugNodes.reparentTo(plug) plug.flattenLight() self.windowSlots.append((plug, viewBase)) self.windowSlots[2][1].setPosHpr(16.0, -12.0, 5.51, -90, 0, 0) self.windowSlots[4][1].setPosHpr(-12.0, 26.0, 5.51, 0, 0, 0) self.__colorWalls() self.__setupWindows() messenger.send('houseInteriorLoaded-%d' % self.zoneId) return None
def setupDoors(self): self.randomGenerator = random.Random() self.randomGenerator.seed(self.zoneId) self.colors = ToonInteriorColors.colors[ToontownCentral] door = self.chooseDoor() doorOrigins = render.findAllMatches('**/door_origin*') numDoorOrigins = doorOrigins.getNumPaths() for npIndex in xrange(numDoorOrigins): doorOrigin = doorOrigins[npIndex] doorOriginNPName = doorOrigin.getName() doorOriginIndexStr = doorOriginNPName[len('door_origin_'):] newNode = ModelNode('door_' + doorOriginIndexStr) newNodePath = NodePath(newNode) newNodePath.reparentTo(self.interior) doorNP = door.copyTo(newNodePath) doorOrigin.setScale(0.8, 0.8, 0.8) doorOrigin.setPos(doorOrigin, 0, -0.025, 0) doorColor = self.randomGenerator.choice(self.colors['TI_door']) triggerId = str(self.block) + '_' + doorOriginIndexStr DNADoor.setupDoor(doorNP, newNodePath, doorOrigin, self.dnaStore, triggerId, doorColor) doorFrame = doorNP.find('door_*_flat') doorFrame.setColor(doorColor) del self.dnaStore del self.randomGenerator
def setup(self): self.dnaStore = base.cr.playGame.dnaStore self.randomGenerator = random.Random() self.randomGenerator.seed(self.zoneId) #custom Lullaby Library :D if base.localAvatar.getZoneId() == 9501: self.interior = loader.loadModel('phase_4/models/modules/ttc_library_interior.bam') self.interior.reparentTo(render) generator = random.Random() generator.seed(self.zoneId) self.replaceRandom(self.interior, generator=generator) doorOrigin = self.interior.find('**/door_origin;+s') doorOrigin.setScale(0.8) doorOrigin.setY(doorOrigin, -0.025) door = self.cr.playGame.dnaStore.findNode('door_double_round_ur') doorNodePath = door.copyTo(doorOrigin) hoodId = ZoneUtil.getCanonicalHoodId(self.zoneId) doorColor = ToonInteriorColors.colors[hoodId]['TI_door'][0] DNADoor.setupDoor( doorNodePath, self.interior, doorOrigin, self.cr.playGame.dnaStore, str(self.block), doorColor) doorFrame = doorNodePath.find('door_double_round_ur_flat') doorFrame.wrtReparentTo(self.interior) doorFrame.setColor(doorColor) else: interior = self.randomDNAItem('TI_room', self.dnaStore.findNode) self.interior = interior.copyTo(render) hoodId = ZoneUtil.getCanonicalHoodId(self.zoneId) self.colors = ToonInteriorColors.colors[hoodId] self.replaceRandomInModel(self.interior) doorModelName = 'door_double_round_ul' if doorModelName[-1:] == 'r': doorModelName = doorModelName[:-1] + 'l' else: doorModelName = doorModelName[:-1] + 'r' door = self.dnaStore.findNode(doorModelName) door_origin = render.find('**/door_origin;+s') doorNP = door.copyTo(door_origin) door_origin.setScale(0.8, 0.8, 0.8) door_origin.setPos(door_origin, 0, -0.025, 0) color = self.randomGenerator.choice(self.colors['TI_door']) DNADoor.setupDoor(doorNP, self.interior, door_origin, self.dnaStore, str(self.block), color) doorFrame = doorNP.find('door_*_flat') doorFrame.wrtReparentTo(self.interior) doorFrame.setColor(color) sign = hidden.find('**/tb%s:*_landmark_*_DNARoot/**/sign;+s' % (self.block,)) if not sign.isEmpty(): signOrigin = self.interior.find('**/sign_origin;+s') newSignNP = sign.copyTo(signOrigin) newSignNP.setDepthWrite(1, 1) #TODO: getSignTransform #mat = self.dnaStore.getSignTransformFromBlockNumber(int(self.block)) inv = Mat4(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) #inv.invertFrom(mat) newSignNP.setMat(inv) newSignNP.flattenLight() ll = Point3() ur = Point3() newSignNP.calcTightBounds(ll, ur) width = ur[0] - ll[0] height = ur[2] - ll[2] if width != 0 and height != 0: xScale = (SIGN_RIGHT - SIGN_LEFT) / width zScale = (SIGN_TOP - SIGN_BOTTOM) / height scale = min(xScale, zScale) xCenter = (ur[0] + ll[0]) / 2.0 zCenter = (ur[2] + ll[2]) / 2.0 newSignNP.setPosHprScale((SIGN_RIGHT + SIGN_LEFT) / 2.0 - xCenter * scale, -0.1, (SIGN_TOP + SIGN_BOTTOM) / 2.0 - zCenter * scale, 0.0, 0.0, 0.0, scale, scale, scale) trophyOrigin = self.interior.find('**/trophy_origin') trophy = self.buildTrophy() if trophy: trophy.reparentTo(trophyOrigin) del self.colors del self.dnaStore del self.randomGenerator self.interior.flattenMedium() for npcToon in self.cr.doFindAllInstances(DistributedNPCToonBase): npcToon.initToonState() #theme Library: if base.localAvatar.getZoneId() == 9501: bldg = base.cr.doFindAll("DistributedToonInterior") for bldg in base.cr.doFindAll("DistributedToonInterior"): bldg.interior.find('**/wallpaper').setColor(.1,.05,.3) bldg.interior.find('**/wallpaper_border').setColor(.2,.1,.6) bldg.interior.find('**/wainscotting').setColor(.4,.2,1.2) bldg.interior.find('**/random_mo1_TI_counter').setColor(.4,.3,.8) bldg.interior.find('**/ceiling').setColor(.2,.1,.8) bldg.interior.find('**/floor').setColor(.5,.4,.7) bldg.interior.find('**/wood_beams').setColor(.4,.2,.8) bldg.interior.find('**/random_mo1_TI_rug').removeNode() bldg.interior.find('**/random_mo1_TI_lamp_short').setZ(2) bldg.interior.find('**/external').setColor(.5,.5,.5) bldg.interior.find('**/random_mo1_TI_chair').removeNode() bldg.interior.find('**/decal_base').removeNode() bldg.interior.find('**/desk').setColor(.5,.5,.5) bldg.interior.find('**/lampShade').setX(0.15) bldg.interior.find('**/lampShade').setColor(1,1,1) bldg.interior.find('**/lamp_shade').setColor(1,1,1) bldg.interior.find('**/hanging_light_lightRay').setColor(1,1,1) bldg.interior.find('**/hanging_light_lightLense').setColor(1,1,1) bldg.interior.find('**/random_mo2_TI_chair').setColor(.8,.8,.8) bldg.interior.find('**/bookshelf_6_cubby_LowPoly_bookshelf').setHpr(90,0,0) bldg.interior.find('**/bookshelf_6_cubby_LowPoly_bookshelf').setPos(-49, 15, 3.1) bldg.interior.find('**/bookshelf_6_cubby_LowPoly_bookshelf1').setHpr(90,0,0) bldg.interior.find('**/bookshelf_6_cubby_LowPoly_bookshelf1').setPos(-39, 15, 3.1) bldg.interior.find('**/bookshelf_6_cubby_LowPoly_bookshelf2').setHpr(90,0,0) bldg.interior.find('**/bookshelf_6_cubby_LowPoly_bookshelf2').setPos(-29, 15, 3.1) #custom Snooze Bar :D if base.localAvatar.getZoneId() == 9503: try: self.p.removeNode() self.bar.removeNode() self.table.removeNode() self.table2.removeNode() self.bartender1.cleanup() self.bartender1.removeNode() self.bartender2.cleanup() self.bartender2.removeNode() self.stripper.cleanup() self.stripper.removeNode() self.bottle1.removeNode() self.bottle2.removeNode() self.bottle3.removeNode() self.mug.removeNode() except: pass base.localAvatar.setSystemMessage(0, "You're in the Snooze bar!") self.bar = loader.loadModel('phase_4/models/potco_files/interior_tavern_vip.bam') self.bar.find('**/storageframebar').setX(self.bar.find('**/storageframebar').getX()+1.5) self.bar.find('**/barcounterwall1').removeNode() self.bar.find('**/barcounterwall').removeNode() self.bar.find('**/int_vip_room:floor').setZ(self.bar.find('**/int_vip_room:floor').getZ()+1) self.bar.find('**/door_1').removeNode() self.bar.find('**/col_doors').removeNode() self.bar.find('**/door_locator').removeNode() self.bar.reparentTo(render) self.bar.setPos(-17.200, 16.95, 0) self.bar.setScale(.65) self.p = loader.loadModel('phase_11/models/lawbotHQ/LB_torch_lampB.bam') self.p.reparentTo(render) self.p.setPos(-49, 58, .5) self.p.setScale(.8,.8,1) self.p.setColor(.6,.6,.6) self.table = loader.loadModel('phase_5.5/models/estate/UWtable.bam') self.table.reparentTo(render) self.table.setPos(-43.920, 11, .675) self.table.setScale(1.25,1.25,.75) self.table2 = loader.loadModel('phase_5.5/models/estate/UWtable.bam') self.table2.reparentTo(render) self.table2.setPos(-24.340, 10, .675) self.table2.setScale(1.25,1.25,.75) self.mug = loader.loadModel('phase_4/models/potco_files/mug_zero.bam') self.mug.reparentTo(render) self.mug.setPos(-12.973, 38.274, 3) self.mug.setScale(1.5) self.bottle1 = loader.loadModel('phase_4/models/potco_files/bottle_high.bam') self.bottle1.reparentTo(render) self.bottle1.setPos(-15.973, 44, 3.8) self.bottle1.setScale(2.5) self.bottle1.setHpr(0,90,0) self.bottle1.setColor(1,.8,1) self.bottle2 = loader.loadModel('phase_4/models/potco_files/bottle_high.bam') self.bottle2.reparentTo(render) self.bottle2.setPos(-14.973, 44, 3.75) self.bottle2.setScale(2.2) self.bottle2.setHpr(0,90,0) self.bottle2.setColor(1,.3,.8) self.bottle3 = loader.loadModel('phase_4/models/potco_files/bottle_high.bam') self.bottle3.reparentTo(render) self.bottle3.setPos(-16.973, 43.8, 3.7) self.bottle3.setScale(2) self.bottle3.setHpr(0,90,0) self.bottle3.setColor(.4,.4,.4) #remove toon int, broken gets rid of npc too bldg = base.cr.doFindAll("DistributedToonInterior") for bldg in base.cr.doFindAll("DistributedToonInterior"): bldg.interior.find('**/ceiling').removeNode() bldg.interior.find('**/random_tc1_TI_wallpaper').removeNode() bldg.interior.find('**/random_to1_TI_molding').removeNode() bldg.interior.find('**/random_tc1_TI_floor').removeNode() bldg.interior.find('**/walls_1').removeNode() bldg.interior.find('**/floor').removeNode() bldg.interior.find('**/random_mo1_TI_counter').removeNode() bldg.interior.find('**/random_mr1_TI_couch_1person').removeNode() bldg.interior.find('**/random_mr1_TI_couch_2person').removeNode() bldg.interior.find('**/random_mr2_TI_couch_2person').removeNode() bldg.interior.find('**/external').removeNode() bldg.interior.find('**/random_tc1_TI_wallpaper_border').removeNode() bldg.interior.find('**/random_tc1_TI_wainscotting').removeNode() bldg.interior.find('**/picture').removeNode() bldg.interior.find('**/arch').removeNode() bldg.interior.find('**/door').removeNode() bldg.interior.find('**/arch2').removeNode() bldg.interior.find('**/random_tc2_TI_floor').removeNode() bldg.interior.find('**/door_double_round_ur_flat').setX(0.68) bldg.interior.find('**/npc_origin_0').setPos(2.5, 19.597, 0.525) bldg.interior.find('**/npc_origin_0').setHpr(175,0,0) #move npc to behind counter, if it ever works # stuff = base.cr.doFindAll('render/toon') # for stuff in base.cr.doFindAll('render/toon'): # stuff.setPos(10.5, 14.222, -1.7) # stuff.setScale(1.4) # stuff.setHpr(90,0,0) def talk0(): name = base.localAvatar.getName() self.bartender1.displayTalk('Hey, %s!' % name) def talk01(): name = base.localAvatar.getName() self.bartender2.displayTalk('Hey, %s! What can I getcha\'?' % name) def talk1(): self.bartender1.displayTalk('Welcome to the Snooze Bar!') def talk2(): self.bartender1.displayTalk('I\'m a bot!') def bartender1Talk(): seq = Sequence() seq.append(Func(talk0)) seq.append(Wait(4)) seq.append(Func(talk1)) seq.append(Wait(4)) seq.append(Func(talk2)) seq.append(Wait(4)) seq.start() def bartender2Talk(): seq = Sequence() seq.append(Wait(4)) seq.append(Func(talk01)) seq.append(Wait(4)) seq.start() def createToon(instName, toonName, toonPos, toonHpr, toonScale=1, anim='neutral'): try: newToon.cleanup() newToon.removeNode() except: pass newToon = instName newToon = Toon.Toon() newToon.reparentTo(render) newToon.doId = base.localAvatar.doId newToon.setupToonNodes() newToon.setName(toonName) newToon.setPos(toonPos) newToon.setHpr(toonHpr) newToon.setScale(toonScale) newToon.startBlink() newToon.showNametag2d() newToon.startLookAround() newToon.initializeBodyCollisions('FD_NPC-Collisions_' + str(newToon.doId)) newToon.setDNAString('t\x01\x01\x00\x00\x50\x1b\x45\x1b\x21\x1b\x08\x02\x08\x08') newToon.loop(anim) pos = newToon.getPos() hpr = newToon.getHpr() strPos = '(%.3f' % pos[0] + '\n %.3f' % pos[1] + '\n %.3f)' % pos[2] strHpr = '(%.3f' % hpr[0] + '\n %.3f' % hpr[1] + '\n %.3f)' % hpr[2] print "%s = Toon.Toon()" % instName print "%s.reparentTo(render)" % instName print "%s.doId = base.localAvatar.doId" % instName print "%s.setupToonNodes()" % instName print "%s.setName('%s')" % (instName, toonName) print '%s.setPos' % instName, strPos.replace('\n', ',') print '%s.setHpr' % instName, strHpr.replace('\n', ',') print "%s.setScale(%d)" % (instName, toonScale) print "%s.startBlink()" % instName print "%s.showNametag2d()" % instName print "%s.startLookAround()" % instName print "%s.initializeBodyCollisions('FD_NPC-Collisions_' + str(%s.doId))" % (instName, instName) print '%s.setDNAString("t\x01\x01\x00\x00\x50\x1b\x45\x1b\x21\x1b\x08\x02\x08\x08")' % instName print "%s.loop('%s')" % (instName, anim) self.bartender1 = Toon.Toon() self.bartender1.reparentTo(render) self.bartender1.doId = base.localAvatar.doId self.bartender1.setupToonNodes() self.bartender1.setName('Bartender\nBri') self.bartender1.setPos(-13.579, 41, 1.5) self.bartender1.setHpr(180,0,0) self.bartender1.setScale(1) self.bartender1.startBlink() self.bartender1.showNametag2d() self.bartender1.startLookAround() self.bartender1.initializeBodyCollisions('FD_NPC-Collisions_' + str(self.bartender1.doId)) self.bartender1.setDNAString('t\x01\x01\x00\x00\x50\x1b\x45\x1b\x21\x1b\x08\x02\x08\x08') bartender1Talk() #bartender1.displayTalk('Welcome to the Snooze Bar!') self.bartender1.loop('neutral') self.bartender2 = Toon.Toon() self.bartender2.reparentTo(render) self.bartender2.doId = base.localAvatar.doId self.bartender2.setupToonNodes() self.bartender2.setName('Bartender\nBrad') self.bartender2.setPos(-29.579, 41, 1.26) self.bartender2.setHpr(220,0,0) self.bartender2.setScale(1) self.bartender2.startBlink() self.bartender2.showNametag2d() self.bartender2.startLookAround() self.bartender2.initializeBodyCollisions('FD_NPC-Collisions_' + str(self.bartender1.doId)) self.bartender2.setDNAString('t\x05\x02\x00\x01\x83\x1b\x76\x1b\x0d\x1b\x0d\x00\x0d\x0d') bartender2Talk() #bartender2.displayTalk('Welcome to the Snooze Bar!') self.bartender2.loop('neutral') self.stripper = Toon.Toon() self.stripper.reparentTo(render) self.stripper.doId = base.localAvatar.doId self.stripper.setupToonNodes() self.stripper.setName('Crystal') self.stripper.setPos(-49.5, 57.85, 1.1) self.stripper.setHpr(220,0,0) self.stripper.setScale(.85) self.stripper.startBlink() self.stripper.showNametag2d() self.stripper.startLookAround() self.stripper.initializeBodyCollisions('FD_NPC-Collisions_' + str(self.stripper.doId)) self.stripper.setDNAString('t\x01\x07\x00\x00\x29\x1b\x1e\x1b\x25\x1b\x24\x1a\x24\x24') #stripper.displayTalk('Welcome to the Snooze Bar!') self.stripper.loop('swing') else: try: p.removeNode() self.bar.removeNode() self.table.removeNode() self.table2.removeNode() self.bartender1.cleanup() self.bartender1.removeNode() self.bartender2.cleanup() self.bartender2.removeNode() self.stripper.cleanup() self.stripper.removeNode() self.bottle1.removeNode() self.bottle2.removeNode() self.bottle3.removeNode() self.mug.removeNode() except: pass
def setup(self): self.dnaStore = base.cr.playGame.dnaStore self.randomBldg = False self.strZoneId = str(self.zoneId) seedDict = self.loadJSONInteriors() # Open bin file with legacy loader if self.strZoneId in seedDict: # Building is predefined self.interiorItemList = ( seedDict[self.strZoneId][INTERIOR_ITEM_LIST]) self.interiorColorList = (seedDict[self.strZoneId][COLOR_LIST]) self.interiorDoorColorList = (seedDict[self.strZoneId][DOOR_LIST]) else: # Building not in predefined seed dict self.randomBldg = True self.randomGenerator = random.Random() self.randomGenerator.seed(self.strZoneId) self.interior = loader.loadModel( 'phase_4/models/modules/gagShop_interior') self.interior.reparentTo(render) hoodId = ZoneUtil.getCanonicalHoodId(self.zoneId) self.colors = ToonInteriorColors.colors[hoodId] self.replaceRandomInModel(self.interior) door = self.chooseDoor() doorOrigin = render.find('**/door_origin;+s') doorNP = door.copyTo(doorOrigin) doorOrigin.setScale(0.8, 0.8, 0.8) doorOrigin.setPos(doorOrigin, 0, -0.025, 0) if not self.randomBldg: # Building is not random colorList = self.colors['TI_door'] colorIndex = self.interiorDoorColorList.pop( ) # Pop off value we want doorColor = colorList[colorIndex] else: # Building is random colorList = self.colors['TI_door'] doorColor = self.randomGenerator.choice(colorList) DNADoor.setupDoor(doorNP, self.interior, doorOrigin, self.dnaStore, str(self.block), doorColor) doorFrame = doorNP.find('door_*_flat') doorFrame.wrtReparentTo(self.interior) doorFrame.setColor(doorColor) del self.colors del self.dnaStore del self.strZoneId del self.randomBldg if getattr(self, "randomGenerator", None): del self.randomGenerator if getattr(self, "interiorItemList", None): del self.interiorItemList if getattr(self, "interiorColorList", None): del self.interiorColorList if getattr(self, "interiorDoorColorList", None): del self.interiorDoorColorList self.interior.flattenMedium() for npcToon in self.cr.doFindAllInstances(DistributedNPCToonBase): npcToon.initToonState()
def setup(self): self.dnaStore = base.cr.playGame.dnaStore self.randomBldg = False self.strZoneId = str(self.zoneId) seedDict = self.loadJSONInteriors() # Open bin file with legacy loader if self.strZoneId in seedDict: # Building is predefined self.interiorItemList = ( seedDict[self.strZoneId][INTERIOR_ITEM_LIST]) self.interiorColorList = (seedDict[self.strZoneId][COLOR_LIST]) self.interiorDoorColorList = (seedDict[self.strZoneId][DOOR_LIST]) else: # Building not in predefined seed dict self.randomBldg = True self.randomGenerator = random.Random() self.randomGenerator.seed(self.strZoneId) if not self.randomBldg: # Building is not random interior = self.produceDNAItem('TI_room', self.dnaStore.findNode) else: # Building is random interior = self.randomDNAItem('TI_room', self.dnaStore.findNode) self.interior = interior.copyTo(render) hoodId = ZoneUtil.getCanonicalHoodId(self.zoneId) self.colors = ToonInteriorColors.colors[hoodId] self.replaceRandomInModel(self.interior) doorModelName = 'door_double_round_ul' if doorModelName[-1:] == 'r': doorModelName = doorModelName[:-1] + 'l' else: doorModelName = doorModelName[:-1] + 'r' door = self.dnaStore.findNode(doorModelName) door_origin = render.find('**/door_origin;+s') doorNP = door.copyTo(door_origin) door_origin.setScale(0.8, 0.8, 0.8) door_origin.setPos(door_origin, 0, -0.025, 0) if not self.randomBldg: # Building is not random colorList = self.colors['TI_door'] colorIndex = self.interiorDoorColorList.pop( ) # Pop off value we want color = colorList[colorIndex] else: # Building is random colorList = self.colors['TI_door'] color = self.randomGenerator.choice(colorList) DNADoor.setupDoor(doorNP, self.interior, door_origin, self.dnaStore, str(self.block), color) doorFrame = doorNP.find('door_*_flat') doorFrame.wrtReparentTo(self.interior) doorFrame.setColor(color) sign = hidden.find('**/tb%s:*_landmark_*_DNARoot/**/sign_origin;+s' % (self.block)) if not sign.isEmpty(): signOrigin = self.interior.find('**/sign_origin;+s') newSignNP = sign.copyTo(signOrigin) newSignNP.setDepthWrite(1, 1) mat = self.dnaStore.getSignTransformFromNodePath(self.interior) inv = Mat4(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) inv.invertFrom(mat) newSignNP.setMat(inv) newSignNP.flattenLight() ll = Point3() ur = Point3() newSignNP.calcTightBounds(ll, ur) width = ur[0] - ll[0] height = ur[2] - ll[2] if width != 0 and height != 0: xScale = (SIGN_RIGHT - SIGN_LEFT) / width zScale = (SIGN_TOP - SIGN_BOTTOM) / height scale = min(xScale, zScale) xCenter = (ur[0] + ll[0]) / 2.0 zCenter = (ur[2] + ll[2]) / 2.0 newSignNP.setPosHprScale( (SIGN_RIGHT + SIGN_LEFT) / 2.0 - xCenter * scale, -0.1, (SIGN_TOP + SIGN_BOTTOM) / 2.0 - zCenter * scale, 0.0, 0.0, 0.0, scale, scale, scale) trophyOrigin = self.interior.find('**/trophy_origin') trophy = self.buildTrophy() if trophy: trophy.reparentTo(trophyOrigin) del self.colors del self.dnaStore del self.strZoneId del self.randomBldg if getattr(self, "randomGenerator", None): del self.randomGenerator if getattr(self, "interiorItemList", None): del self.interiorItemList if getattr(self, "interiorColorList", None): del self.interiorColorList if getattr(self, "interiorDoorColorList", None): del self.interiorDoorColorList self.interior.flattenMedium() for npcToon in self.cr.doFindAllInstances(DistributedNPCToonBase): npcToon.initToonState()