Esempio n. 1
0
 def __init__(self, air, dispatch=None):
     DistributedEntityAI.__init__(self, air, dispatch)
     self.hp = 100
     self.maxHp = 100
     self.avId = None
     self.lastGive = 0.0
     self.giveIval = 0.09
 def delete(self):
     taskMgr.remove(self.taskName("doRespawn"))
     self.pickupState = None
     self.gagId = None
     self.oneTimePickup = None
     self.random = None
     DistributedEntityAI.delete(self)
Esempio n. 3
0
    def handleLogicalZoneChange(self, newZoneId, oldZoneId):
        """Make sure the avatar lists are updated with our new zone."""

        self.air.removeAvatar(self)
        self.air.addAvatar(self, newZoneId)

        DistributedEntityAI.handleLogicalZoneChange(self, newZoneId, oldZoneId)
Esempio n. 4
0
 def __init__(self, air, dispatch):
     DistributedEntityAI.__init__(self, air, dispatch)
     self.numbers = []
     self.code = []
     self.setModel("models/keypad.bam")
     self.entityState = self.CodeEntry
     self.codeWasCorrect = False
Esempio n. 5
0
    def load(self):
        DistributedEntityAI.load(self)

        self.setModel("models/cage.bam", True)
        self.setModelScale(self.getEntityValueVector("scale"))
        self.optimizeModel()
        self.enableModelCollisions()
Esempio n. 6
0
    def setEntityState(self, state):
        DistributedEntityAI.setEntityState(self, state)

        if state == self.StateDown:
            self.stomped = False
            self.clearSequence()
            self.setPos(self.cEntity.getOrigin())
            self.dispatchOutput("OnStomp")

        elif state == self.StateUp:
            self.clearSequence()
            self.setPos(self.cEntity.getOrigin() + self.getUpPosition())
            self.dispatchOutput("OnRaise")

        elif state == self.StateStomp:
            self.damaged = []
            self.setSequence(
                LerpPosInterval(
                    self, self.height / self.stompSpeed,
                    self.cEntity.getOrigin(),
                    self.cEntity.getOrigin() + self.getUpPosition()))

        elif state == self.StateRaise:
            self.setSequence(
                LerpPosInterval(
                    self, self.height / self.raiseSpeed,
                    self.cEntity.getOrigin() + self.getUpPosition(),
                    self.cEntity.getOrigin()))
 def __init__(self, air, dispatch):
     DistributedEntityAI.__init__(self, air, dispatch)
     self.pickupState = 1
     self.gagId = self.__pickGagId()
     self.oneTimePickup = False
     self.random = True
     self.cost = self.air.attackMgr.getAttackClassByID(self.gagId).Cost
Esempio n. 8
0
 def unload(self):
     self.sndFile = None
     self.looping = None
     self.volume = None
     self.randomDelay = None
     self.randomDelayMin = None
     self.randomDelayMax = None
     DistributedEntityAI.unload(self)
Esempio n. 9
0
    def loadEntityValues(self):
        DistributedEntityAI.loadEntityValues(self)
        #codeStr = self.getEntityValue("code")
        #for numStr in codeStr:
        #    self.code.append(int(numStr))

        for i in range(4):
            self.code.append(random.randint(0, 9))
Esempio n. 10
0
 def __init__(self, air, dispatch):
     DistributedEntityAI.__init__(self, air, dispatch)
     self.scriptFilename = ""
     self.scriptSrc = ""
     self.target = None
     self.scriptTasks = {}
     self.scriptEnvirons = []
     self.clientSide = False
Esempio n. 11
0
    def load(self):
        DistributedEntityAI.load(self)

        from panda3d.core import VirtualFileSystem
        vfs = VirtualFileSystem.getGlobalPtr()
        self.scriptSrc = vfs.readFile(self.scriptFilename, True)

        self.target = self.bspLoader.getPyEntityByTargetName(
            self.getEntityValue("scriptTarget"))
Esempio n. 12
0
 def delete(self):
     for task in self.scriptTasks.values():
         task.remove()
     self.FinishScript(sendOp=False)
     self.scriptEnvirons = None
     self.scriptTasks = None
     self.target = None
     self.scriptFilename = None
     self.scriptSrc = None
     DistributedEntityAI.delete(self)
Esempio n. 13
0
    def think(self):
        DistributedEntityAI.think(self)

        state = self.getEntityState()
        elapsed = self.getEntityStateElapsed()

        if state == self.StateAlive:
            if self.aliveTime != -1 and elapsed >= self.aliveTime:
                print("ok now stop")
                self.Stop()
Esempio n. 14
0
    def announceGenerate(self):
        DistributedEntityAI.announceGenerate(self)
        DistributedNodeAI.announceGenerate(self)

        assert self.cEntity
        self.setPos(self.cEntity.getOrigin())
        self.setHpr(self.cEntity.getAngles())
        pos = self.getPos()
        hpr = self.getHpr()
        self.d_setPosHpr(pos[0], pos[1], pos[2], hpr[0], hpr[1], hpr[2])
Esempio n. 15
0
 def unload(self):
     self.dispatch.getPhysicsWorld().remove(self.floorColl.node())
     self.damaged = None
     self.height = None
     self.stompSpeed = None
     self.raiseSpeed = None
     self.timeOnGround = None
     self.timeInAir = None
     self.damage = None
     self.startDelay = None
     DistributedEntityAI.unload(self)
Esempio n. 16
0
    def __init__(self, air, dispatch):
        DistributedEntityAI.__init__(self, air, dispatch)

        self.entState = self.StateStopped

        self.sndFile = ""
        self.looping = self.LoopNo
        self.volume = 1.0

        self.randomDelayMin = 1
        self.randomDelayMax = 20
        self.randomDelay = 0.0
Esempio n. 17
0
    def announceGenerate(self):
        DistributedEntityAI.announceGenerate(self)

        self.b_setModel("phase_14/models/props/creampie_gib.bam")
        self.setMass(5.0)
        self.setSolid(self.SOLID_MESH)
        self.initPhysics()
        self.getPhysNode().setFriction(50.0)
        #self.getPhysNode().setLinearDamping(3.0)
        #self.getPhysNode().setAngularDamping(3.0)
        self.startPosHprBroadcast()
        self.setNextThink(3.0)
Esempio n. 18
0
    def think(self):
        DistributedEntityAI.think(self)

        state = self.getEntityState()
        elapsed = self.getEntityStateElapsed()
        if state == self.CodeResponse and elapsed >= 0.5:
            if self.codeWasCorrect:
                self.dispatchOutput("OnCodeCorrect")
                self.dispatch.codeUsed()
            else:
                self.dispatchOutput("OnCodeIncorrect")
            self.b_setNumbers([])
            self.setEntityState(self.CodeEntry)
            self.codeWasCorrect = False
Esempio n. 19
0
 def __init__(self, air, dispatch):
     DistributedEntityAI.__init__(self, air, dispatch)
     self.height = 1.0
     self.stompSpeed = 1
     self.raiseSpeed = 1
     self.timeOnGround = 0.0
     self.timeInAir = 0.0
     self.damage = 20
     self.scale = Vec3(1)
     self.floorColl = None
     self.damaged = []
     self.moveDir = Vec3.up()
     self.stomped = False
     self.startDelay = 0.0
Esempio n. 20
0
    def announceGenerate(self):
        DistributedEntityAI.announceGenerate(self)
        AvatarShared.announceGenerate(self)

        self.accept('globalrule', self.handleRule)

        self.setupPhysics()

        # Add ourself to the avatar list for the zone
        # But if we somehow are already in there, remove us.
        base.air.removeAvatar(self)
        base.air.addAvatar(self)

        if self.Moving:
            self.lastPos = self.getPos(render)
            taskMgr.add(self.__avatarTick, self.uniqueName('avatarTick'))
Esempio n. 21
0
    def delete(self):
        self.ignore('globalrule')
        self.__stopActivityTask()
        base.air.removeAvatar(self)

        if self.Moving:
            taskMgr.remove(self.uniqueName('avatarTick'))

        self.movementVector = None
        self.movementDelta = None
        self.lastPos = None
        self.blockAIChat = None
        self.latestDamage = None
        self.attackFinished = None

        AvatarShared.delete(self)
        DistributedEntityAI.delete(self)
Esempio n. 22
0
    def __init__(self, air, dispatch=None):
        DistributedEntityAI.__init__(self, air, dispatch)
        AvatarShared.__init__(self)

        self.latestDamage = None

        self.blockAIChat = False

        # Activity translations
        self.actTable = {}

        self.lastPos = Point3(0)
        self.movementDelta = Vec3(0)
        self.movementVector = Vec3(0)
        self.attackFinished = False

        return
Esempio n. 23
0
 def setEntityState(self, state):
     DistributedEntityAI.setEntityState(self, state)
     
     self.clearMoveTrack()
     
     if state == self.StateMoving:
         
         if (not self.startPoint) or (not self.endPoint):
             print("FuncElevatorAI ERROR: Missing either start or end point")
             return
             
         startPos = self.startPoint.cEntity.getOrigin()
         endPos = self.endPoint.cEntity.getOrigin()
         dist = (endPos - startPos).length()
         duration = (dist * 16) / self.speed
         self.moveTrack = LerpPosInterval(self, duration, endPos, startPos)
         self.moveTrack.start()
         
         self.dispatchOutput("OnStartMove")
Esempio n. 24
0
    def think(self):
        DistributedEntityAI.think(self)

        now = globalClock.getFrameTime()
        state = self.getEntityState()
        elapsed = self.getEntityStateElapsed()
        if state == self.StateGiving:
            giveElapsed = now - self.lastGive
            if giveElapsed >= self.giveIval:
                if self.avId:
                    self.sendUpdate('giveLaffTo', [self.avId])
                    av = self.air.doId2do.get(self.avId, None)
                    if av:
                        av.heal(1)
                        self.hp -= 1
                        self.lastGive = now
                        if not self.hasHP():
                            self.setIdleState()
                            return
                    else:
                        self.setIdleState()
                        return
Esempio n. 25
0
    def load(self):
        DistributedEntityAI.load(self)
        self.setHpr(self.cEntity.getAngles())
        self.setPos(self.cEntity.getOrigin())

        self.setModel("phase_9/models/cogHQ/square_stomper.bam")
        self.setModelScale(self.scale)
        self.getModelNP().find("**/shaft").setSy(self.height / 16.0)

        self.optimizeModel()

        box = BulletBoxShape((self.scale[1], 1.0, self.scale[0]))
        gh = BulletGhostNode('trigger_hurt')
        gh.addShape(box, TransformState.makePos((0, -0.5, 0)))
        self.floorColl = self.getModelNP().attachNewNode(gh)
        self.floorColl.setCollideMask(CIGlobals.WallGroup
                                      | CIGlobals.CharacterGroup)

        self.enableModelCollisions()

        for bNP in self.getModelNP().findAllMatches("**/+BulletRigidBodyNode"):
            bNP.setSurfaceProp("metal")

        self.b_setEntityState(self.StateUp)
 def delete(self):
     base.taskMgr.remove(self.uniqueName('closingTask'))
     self.index = None
     DistributedElevatorAI.delete(self)
     DistributedEntityAI.delete(self)
Esempio n. 27
0
 def announceGenerate(self):
     DistributedEntityAI.announceGenerate(self)
     print(self.getEntityValueBool("playnow"))
     if self.getEntityValueBool("playnow"):
         print("Play now!")
         self.Play()
Esempio n. 28
0
 def setEntityState(self, state):
     DistributedEntityAI.setEntityState(self, state)
     if state == self.StateOpened:
         self.dispatchOutput("OnOpenCage")
Esempio n. 29
0
 def announceGenerate(self):
     DistributedEntityAI.announceGenerate(self)
     if self.hasSpawnFlags(self.SF_ExecuteImmediately):
         self.ExecuteScript()
Esempio n. 30
0
 def __init__(self, air, dispatch):
     DistributedEntityAI.__init__(self, air, dispatch)
     self.entState = self.StateClosed