Exemple #1
0
 def disable(self):
     self.request('Off')
     base.taskMgr.remove(self.taskName('guard'))
     base.taskMgr.remove(self.diedTaskName)
     base.taskMgr.remove(self.viewDistanceTaskName)
     self.trav = None
     if self.rayNP:
         self.rayNP.removeNode()
         self.rayNP = None
     self.queue = None
     self.currentPathIndex = None
     if self.eyeNode:
         self.eyeNode.removeNode()
         self.eyeNode = None
         self.eyeLens = None
         self.eyeLight = None
     self.viewDistanceTaskName = None
     self.guardKey = None
     self.gameWorld = None
     self.pathQueue = None
     if self.walkTrack:
         self.ignore(self.walkTrack.getDoneEvent())
         self.walkTrack.finish()
         self.walkTrack = None
     Suit.disable(self)
     return
Exemple #2
0
 def generate(self):
     data = CIGlobals.SuitBodyData[self.SUIT]
     type = data[0]
     team = data[1]
     self.team = team
     self.level = 12
     self.suit = type
     Suit.generate(self, SuitBank.MrHollywood, 0, hideFirst=False)
     self.suit = type
     base.taskMgr.add(self.__viewDistance, self.viewDistanceTaskName)
     self.setPythonTag('guard', self)
     self.eyeLight = Spotlight('eyes')
     self.eyeLens = PerspectiveLens()
     self.eyeLens.setMinFov(90.0 / (4.0 / 3.0))
     self.eyeLight.setLens(self.eyeLens)
     self.eyeNode = self.headModel.attachNewNode(self.eyeLight)
     self.eyeNode.setZ(-5)
     self.eyeNode.setY(-4.5)
     self.trav = CollisionTraverser(self.uniqueName('eyeTrav'))
     ray = CollisionRay(0, 0, 0, 0, 1, 0)
     rayNode = CollisionNode('ToonFPS.rayNode')
     rayNode.addSolid(ray)
     rayNode.setFromCollideMask(CGG.GuardBitmask | CIGlobals.WallBitmask)
     rayNode.setIntoCollideMask(BitMask32.allOff())
     self.rayNP = base.camera.attachNewNode(rayNode)
     self.rayNP.setZ(3)
     self.queue = CollisionHandlerQueue()
     self.trav.addCollider(self.rayNP, self.queue)
     self.trav.addCollider(self.gameWorld.mg.avatarBody, self.queue)
     self.request('Guard')
 def disable(self):
     base.taskMgr.remove(self.diedTaskName)
     base.taskMgr.remove(self.viewDistanceTaskName)
     if self.eyeNode:
         self.eyeNode.removeNode()
         self.eyeNode = None
         self.eyeLens = None
         self.eyeLight = None
     self.viewDistanceTaskName = None
     self.guardKey = None
     self.gameWorld = None
     Suit.disable(self)
     return
 def __init__(self, world, guardKey):
     Suit.__init__(self)
     FSM.__init__(self, 'FactorySneakGuardSuit')
     self.gameWorld = world
     self.guardKey = guardKey
     self.viewDistanceTaskName = self.VIEW_DISTANCE_TASK_NAME + '-' + str(id(self))
     self.diedTaskName = 'GuardDied-' + str(id(self))
     self.health = 0
     self.maxHealth = self.MAX_HP
     self.eyeLight = None
     self.eyeLens = None
     self.eyeNode = None
     self.moveTrack = None
     return
 def __init__(self, world, guardKey):
     Suit.__init__(self)
     FSM.__init__(self, 'FactorySneakGuardSuit')
     self.gameWorld = world
     self.guardKey = guardKey
     self.viewDistanceTaskName = self.VIEW_DISTANCE_TASK_NAME + "-" + str(
         id(self))
     self.diedTaskName = "GuardDied-" + str(id(self))
     self.health = 0
     self.maxHealth = self.MAX_HP
     self.eyeLight = None
     self.eyeLens = None
     self.eyeNode = None
     self.moveTrack = None
     self.trav = None
     self.rayNP = None
     self.queue = None
     self.currentKey = self.guardKey
     self.firstPoint = CGG.GuardPointData[self.guardKey]
     self.walkTrack = None
     self.pathQueue = []
     self.currentPathIndex = 0
 def generate(self):
     DistributedNode.generate(self)
     self.cart = loader.loadModel(self.cartModelPath)
     self.cart.reparentTo(self)
     self.cart.setH(180)
     heads = []
     for head in CIGlobals.SuitBodyData.keys():
         if CIGlobals.SuitBodyData[head][0] != 'B':
             heads.append(head)
     head = random.choice(heads)
     suitType = CIGlobals.SuitBodyData[head][0]
     suitDept = CIGlobals.SuitBodyData[head][1]
     self.suitInCar = Suit()
     self.suitInCar.generateSuit(suitType, head, suitDept, 137, 0, False)
     self.suitInCar.loop('sit')
     self.suitInCar.disableRay()
     self.suitInCar.setScale(0.7)
     self.suitInCar.setH(180)
     self.suitInCar.setPos(0, -1, -1.5)
     self.suitInCar.reparentTo(self.cart.find('**/seat1'))
     self.soundEngineLoop = base.audio3d.loadSfx('phase_6/audio/sfx/KART_Engine_loop_0.ogg')
     base.audio3d.attachSoundToObject(self.soundEngineLoop, self)
     base.playSfx(self.soundEngineLoop, looping = 1)
     self.soundDriveByHorn = base.audio3d.loadSfx(self.honkSfxPath)
     base.audio3d.attachSoundToObject(self.soundDriveByHorn, self)
     self.soundDriveBy = base.audio3d.loadSfx('phase_14/audio/sfx/cogtropolis_citycar_driveby.ogg')
     base.audio3d.attachSoundToObject(self.soundDriveBy, self)
     sphere = CollisionSphere(0, 0, 0, 2.5)
     sphere.setTangible(0)
     node = CollisionNode(self.uniqueName('cartSphere'))
     node.setCollideMask(CIGlobals.WallBitmask)
     node.addSolid(sphere)
     self.collNodePath = self.attachNewNode(node)
     self.collNodePath.setZ(1.5)
     self.collNodePath.setSy(2.0)
     self.collNodePath.setSx(1.75)
    def generate(self):
        DistributedNode.generate(self)
        self.cart = loader.loadModel(self.cartModelPath)
        self.cart.reparentTo(self)
        self.cart.setH(180)
        heads = []
        for head in CIGlobals.SuitBodyData.keys():
            if CIGlobals.SuitBodyData[head][0] != 'B':
                heads.append(head)

        head = random.choice(heads)
        suitType = CIGlobals.SuitBodyData[head][0]
        suitDept = CIGlobals.SuitBodyData[head][1]
        self.suitInCar = Suit()
        self.suitInCar.generateSuit(suitType, head, suitDept, 137, 0, False)
        self.suitInCar.loop('sit')
        self.suitInCar.disableRay()
        self.suitInCar.setScale(0.7)
        self.suitInCar.setH(180)
        self.suitInCar.setPos(0, -1, -1.5)
        self.suitInCar.reparentTo(self.cart.find('**/seat1'))
        self.soundEngineLoop = base.audio3d.loadSfx('phase_6/audio/sfx/KART_Engine_loop_0.wav')
        base.audio3d.attachSoundToObject(self.soundEngineLoop, self)
        base.playSfx(self.soundEngineLoop, looping=1)
        self.soundDriveByHorn = base.audio3d.loadSfx(self.honkSfxPath)
        base.audio3d.attachSoundToObject(self.soundDriveByHorn, self)
        self.soundDriveBy = base.audio3d.loadSfx('phase_14/audio/sfx/cogtropolis_citycar_driveby.mp3')
        base.audio3d.attachSoundToObject(self.soundDriveBy, self)
        sphere = CollisionSphere(0, 0, 0, 2.5)
        sphere.setTangible(0)
        node = CollisionNode(self.uniqueName('cartSphere'))
        node.setCollideMask(CIGlobals.WallBitmask)
        node.addSolid(sphere)
        self.collNodePath = self.attachNewNode(node)
        self.collNodePath.setZ(1.5)
        self.collNodePath.setSy(2.0)
        self.collNodePath.setSx(1.75)
class DistributedCityCart(DistributedNode):
    notify = directNotify.newCategory('DistributedCityCart')

    def __init__(self, cr):
        DistributedNode.__init__(self, cr)
        self.fsm = ClassicFSM('DistributedCityCart', [State('off', self.enterOff, self.exitOff), State('pathFollow', self.enterPathFollow, self.exitPathFollow), State('collision', self.enterCollision, self.exitCollision)], 'off', 'off')
        self.fsm.enterInitialState()
        self.suitInCar = None
        self.cart = None
        self.honkSfxPath = 'phase_14/audio/sfx/cogtropolis_citycar_driveby_horn.mp3'
        self.cartModelPath = 'phase_12/models/bossbotHQ/Coggolf_cart3.bam'
        self.moPaths = ['phase_14/models/paths/ct-citycar-drivepath-1.egg',
         'phase_14/models/paths/ct-citycar-drivepath-2.egg',
         'phase_14/models/paths/ct-citycar-drivepath-3.egg',
         'phase_14/models/paths/ct-citycar-drivepath-4.egg',
         'phase_14/models/paths/ct-citycar-drivepath-5.egg',
         'phase_14/models/paths/ct-citycar-drivepath-6.egg']
        self.moPath = None
        self.soundEngineLoop = None
        self.soundDriveByHorn = None
        self.ivalTDisplace = None
        self.pathIndex = None
        self.wheelSpinTrack = None
        self.collNodePath = None
        self.soundDriveBy = None
        return

    def setIvalTDisplace(self, displace):
        self.ivalTDisplace = displace

    def setPathIndex(self, index):
        self.pathIndex = index

    def setState(self, state, timestamp):
        ts = ClockDelta.globalClockDelta.localElapsedTime(timestamp)
        self.fsm.request(state, [ts])

    def enterOff(self):
        pass

    def exitOff(self):
        pass

    def enterPathFollow(self, ts):
        duration = CityCartGlobals.index2Duration[self.pathIndex]
        self.moPath = NURBSMopath.NURBSMopath(self.moPaths[self.pathIndex], name=self.uniqueName('DCityCart_moPath'))
        startT = 0.0
        if ts > 0.0:
            startT = ts % duration * (1.0 / duration)
        self.moPath.play(self, loop=True, duration=duration, startT=startT)
        base.taskMgr.add(self.__drive, self.uniqueName('DCityCart.drive'))
        self.wheelSpinTrack = Parallel()
        for name in ['leftFrontWheel',
         'rightBackWheel',
         'rightFrontWheel',
         'leftBackWheel']:
            wheel = self.find('**/' + name)
            self.wheelSpinTrack.append(LerpHprInterval(wheel, duration=0.1, hpr=(0, 360, 0), startHpr=(0, 0, 0)))

        self.wheelSpinTrack.loop()
        self.accept('enter' + self.collNodePath.node().getName(), self.__handleRanOver)

    def __handleRanOver(self, entry):
        self.suitInCar.setChat(CityCartGlobals.SuitRanOverTaunt)
        self.sendUpdate('hitByCar')
        self.cr.playGame.getPlace().fsm.request('stop')
        base.localAvatar.b_setAnimState('squish', callback=self.cr.playGame.getPlace().fsm.request, extraArgs=['walk'])

    def __drive(self, task):
        if base.localAvatar.getDistance(self) < 10.0:
            if self.soundDriveByHorn.status() == self.soundDriveByHorn.READY:
                wantsToHonk = random.randint(0, 3)
                if wantsToHonk == 3:
                    base.playSfx(self.soundDriveByHorn)
                return task.cont
        elif base.localAvatar.getDistance(self) < 20.0:
            if self.soundDriveBy.status() == self.soundDriveBy.READY:
                base.playSfx(self.soundDriveBy)
                return task.cont
        return task.cont

    def exitPathFollow(self):
        self.ignore('enter' + self.collNodePath.node().getName())
        if self.wheelSpinTrack:
            self.wheelSpinTrack.finish()
            self.wheelSpinTrack = None
        if self.moPath:
            self.moPath.stop()
            self.moPath = None
        return

    def enterCollision(self, ts):
        pass

    def exitCollision(self):
        pass

    def generate(self):
        DistributedNode.generate(self)
        self.cart = loader.loadModel(self.cartModelPath)
        self.cart.reparentTo(self)
        self.cart.setH(180)
        heads = []
        for head in CIGlobals.SuitBodyData.keys():
            if CIGlobals.SuitBodyData[head][0] != 'B':
                heads.append(head)

        head = random.choice(heads)
        suitType = CIGlobals.SuitBodyData[head][0]
        suitDept = CIGlobals.SuitBodyData[head][1]
        self.suitInCar = Suit()
        self.suitInCar.generateSuit(suitType, head, suitDept, 137, 0, False)
        self.suitInCar.loop('sit')
        self.suitInCar.disableRay()
        self.suitInCar.setScale(0.7)
        self.suitInCar.setH(180)
        self.suitInCar.setPos(0, -1, -1.5)
        self.suitInCar.reparentTo(self.cart.find('**/seat1'))
        self.soundEngineLoop = base.audio3d.loadSfx('phase_6/audio/sfx/KART_Engine_loop_0.wav')
        base.audio3d.attachSoundToObject(self.soundEngineLoop, self)
        base.playSfx(self.soundEngineLoop, looping=1)
        self.soundDriveByHorn = base.audio3d.loadSfx(self.honkSfxPath)
        base.audio3d.attachSoundToObject(self.soundDriveByHorn, self)
        self.soundDriveBy = base.audio3d.loadSfx('phase_14/audio/sfx/cogtropolis_citycar_driveby.mp3')
        base.audio3d.attachSoundToObject(self.soundDriveBy, self)
        sphere = CollisionSphere(0, 0, 0, 2.5)
        sphere.setTangible(0)
        node = CollisionNode(self.uniqueName('cartSphere'))
        node.setCollideMask(CIGlobals.WallBitmask)
        node.addSolid(sphere)
        self.collNodePath = self.attachNewNode(node)
        self.collNodePath.setZ(1.5)
        self.collNodePath.setSy(2.0)
        self.collNodePath.setSx(1.75)

    def disable(self):
        self.fsm.requestFinalState()
        if self.moPath:
            self.moPath.stop()
            self.moPath = None
        self.moPaths = None
        self.honkSfxPath = None
        self.cartModelPath = None
        self.soundEngineLoop = None
        self.soundDriveBy = None
        if self.suitInCar:
            self.suitInCar.disable()
            self.suitInCar.delete()
            self.suitInCar = None
        if self.cart:
            self.cart.removeNode()
            self.cart = None
        del self.fsm
        DistributedNode.disable(self)
        return
class DistributedCityCart(DistributedNode):
    notify = directNotify.newCategory('DistributedCityCart')

    def __init__(self, cr):
        DistributedNode.__init__(self, cr)
        self.fsm = ClassicFSM('DistributedCityCart', [State('off', self.enterOff, self.exitOff),
         State('pathFollow', self.enterPathFollow, self.exitPathFollow),
         State('collision', self.enterCollision, self.exitCollision)], 'off', 'off')
        self.fsm.enterInitialState()
        self.suitInCar = None
        self.cart = None
        self.honkSfxPath = 'phase_14/audio/sfx/cogtropolis_citycar_driveby_horn.ogg'
        self.cartModelPath = 'phase_12/models/bossbotHQ/Coggolf_cart3.bam'
        self.moPaths = ['phase_14/models/paths/ct-citycar-drivepath-1.egg',
            'phase_14/models/paths/ct-citycar-drivepath-2.egg',
            'phase_14/models/paths/ct-citycar-drivepath-3.egg',
            'phase_14/models/paths/ct-citycar-drivepath-4.egg',
            'phase_14/models/paths/ct-citycar-drivepath-5.egg',
            'phase_14/models/paths/ct-citycar-drivepath-6.egg']
        self.moPath = None
        self.soundEngineLoop = None
        self.soundDriveByHorn = None
        self.ivalTDisplace = None
        self.pathIndex = None
        self.wheelSpinTrack = None
        self.collNodePath = None
        self.soundDriveBy = None

    def setIvalTDisplace(self, displace):
        self.ivalTDisplace = displace

    def setPathIndex(self, index):
        self.pathIndex = index

    def setState(self, state, timestamp):
        ts = ClockDelta.globalClockDelta.localElapsedTime(timestamp)
        self.fsm.request(state, [ts])

    def enterOff(self):
        pass

    def exitOff(self):
        pass

    def enterPathFollow(self, ts):
        duration = CityCartGlobals.index2Duration[self.pathIndex]
        self.moPath = NURBSMopath.NURBSMopath(self.moPaths[self.pathIndex], name = self.uniqueName('DCityCart_moPath'))
        startT = 0.0
        if ts > 0.0:
            startT = (ts % duration) * (1.0 / duration)
        self.moPath.play(self, loop = True, duration = duration, startT = startT)
        base.taskMgr.add(self.__drive, self.uniqueName('DCityCart.drive'))
        self.wheelSpinTrack = Parallel()
        for name in ['leftFrontWheel', 'rightBackWheel', 'rightFrontWheel', 'leftBackWheel']:
            wheel = self.find('**/' + name)
            self.wheelSpinTrack.append(LerpHprInterval(wheel, duration = 0.1, hpr = (0, 360, 0), startHpr = (0, 0, 0)))
        self.wheelSpinTrack.loop()
        self.accept('enter' + self.collNodePath.node().getName(), self.__handleRanOver)

    def __handleRanOver(self, entry):
        self.suitInCar.setChat(CityCartGlobals.SuitRanOverTaunt)
        self.sendUpdate('hitByCar')
        self.cr.playGame.getPlace().fsm.request('stop')
        base.localAvatar.b_setAnimState('squish', callback = self.cr.playGame.getPlace().fsm.request, extraArgs = ['walk'])

    def __drive(self, task):
        if base.localAvatar.getDistance(self) < 10.0:
            if self.soundDriveByHorn.status() == self.soundDriveByHorn.READY:
                wantsToHonk = random.randint(0, 3)
                if wantsToHonk == 3:
                    base.playSfx(self.soundDriveByHorn)
                return task.cont
        elif base.localAvatar.getDistance(self) < 20.0:
            if self.soundDriveBy.status() == self.soundDriveBy.READY:
                base.playSfx(self.soundDriveBy)
                return task.cont
        return task.cont

    def exitPathFollow(self):
        self.ignore('enter' + self.collNodePath.node().getName())
        #base.taskMgr.remove(self.uniqueName('DCityCart.drive'))
        if self.wheelSpinTrack:
            self.wheelSpinTrack.finish()
            self.wheelSpinTrack = None
        if self.moPath:
            self.moPath.stop()
            self.moPath = None

    def enterCollision(self, ts):
        pass

    def exitCollision(self):
        pass

    def generate(self):
        DistributedNode.generate(self)
        self.cart = loader.loadModel(self.cartModelPath)
        self.cart.reparentTo(self)
        self.cart.setH(180)
        heads = []
        for head in CIGlobals.SuitBodyData.keys():
            if CIGlobals.SuitBodyData[head][0] != 'B':
                heads.append(head)
        head = random.choice(heads)
        suitType = CIGlobals.SuitBodyData[head][0]
        suitDept = CIGlobals.SuitBodyData[head][1]
        self.suitInCar = Suit()
        self.suitInCar.generateSuit(suitType, head, suitDept, 137, 0, False)
        self.suitInCar.loop('sit')
        self.suitInCar.disableRay()
        self.suitInCar.setScale(0.7)
        self.suitInCar.setH(180)
        self.suitInCar.setPos(0, -1, -1.5)
        self.suitInCar.reparentTo(self.cart.find('**/seat1'))
        self.soundEngineLoop = base.audio3d.loadSfx('phase_6/audio/sfx/KART_Engine_loop_0.ogg')
        base.audio3d.attachSoundToObject(self.soundEngineLoop, self)
        base.playSfx(self.soundEngineLoop, looping = 1)
        self.soundDriveByHorn = base.audio3d.loadSfx(self.honkSfxPath)
        base.audio3d.attachSoundToObject(self.soundDriveByHorn, self)
        self.soundDriveBy = base.audio3d.loadSfx('phase_14/audio/sfx/cogtropolis_citycar_driveby.ogg')
        base.audio3d.attachSoundToObject(self.soundDriveBy, self)
        sphere = CollisionSphere(0, 0, 0, 2.5)
        sphere.setTangible(0)
        node = CollisionNode(self.uniqueName('cartSphere'))
        node.setCollideMask(CIGlobals.WallBitmask)
        node.addSolid(sphere)
        self.collNodePath = self.attachNewNode(node)
        self.collNodePath.setZ(1.5)
        self.collNodePath.setSy(2.0)
        self.collNodePath.setSx(1.75)

    def disable(self):
        self.fsm.requestFinalState()
        if self.moPath:
            self.moPath.stop()
            self.moPath = None
        self.moPaths = None
        self.honkSfxPath = None
        self.cartModelPath = None
        self.soundEngineLoop = None
        self.soundDriveBy = None
        if self.suitInCar:
            self.suitInCar.disable()
            self.suitInCar.delete()
            self.suitInCar = None
        if self.cart:
            self.cart.removeNode()
            self.cart = None
        del self.fsm
        DistributedNode.disable(self)
from lib.coginvasion.cthood.ElevatorUtils import *

leftDoor = elevator1.find('**/left-door')
rightDoor = elevator1.find('**/right-door')
closeDoors(leftDoor, rightDoor)

ival = getRideElevatorInterval()
ival.append(getOpenInterval(base.localAvatar, leftDoor, rightDoor, base.loadSfx('phase_5/audio/sfx/elevator_door_open.mp3'), None))
#ival.start()
"""
from lib.coginvasion.cog import Variant

receptionistPosHpr = (0.91, 16.92, 0, 149.53, 0, 0)

base.disableMouse()
suit = Suit()
suit.level = 12
suit.generate(SuitBank.ColdCaller, Variant.NORMAL, hideFirst=False)
suit.setName('Cold Caller', 'Cold Caller')
suit.reparentTo(render)
suit.loop('sit')
suit.cleanupPropeller()
suit.setPosHpr(*receptionistPosHpr)


def printPosHpr():
    print 'Pos: {0}'.format(base.localAvatar.getPos(render))
    print 'Hpr: {0}'.format(base.localAvatar.getHpr(render))


base.accept('p', printPosHpr)