Esempio n. 1
0
    def setAction(self, action):
        BaseGagAI.setAction(self, action)

        if action == self.StateThrow:
            if not isinstance(self.avatar, BaseNPCAI):
                self.takeAmmo(-1)

            throwVector = PhysicsUtils.getThrowVector(
                self.avatar.getViewOrigin(), self.traceVector,
                self.avatar.getViewOrigin(), self.avatar,
                self.avatar.getBattleZone().getPhysicsWorld())
            endPos = CIGlobals.extrude(self.avatar.getViewOrigin(),
                                       self.ThrowPower,
                                       throwVector) - (0, 0, 90)

            proj = WholeCreamPieProjectileAI(base.air)
            proj.setProjectile(2.5, self.avatar.getViewOrigin(), endPos, 1.07,
                               globalClockDelta.getFrameNetworkTime())
            proj.generateWithRequired(self.avatar.getBattleZone().zoneId)
            proj.addHitCallback(self.onProjectileHit)
            proj.addExclusion(self.avatar)

            self.avatar.emitSound(SOUND_COMBAT,
                                  self.avatar.getViewOrigin(),
                                  duration=0.5)

            self.throwTime = globalClock.getFrameTime()
Esempio n. 2
0
    def onSetAction(self, action):
        if action == self.StateThrow:
            self.takeAmmo(-1)

            av = self.getAvatar()

            throwVector = PhysicsUtils.getThrowVector(
                self.traceOrigin, self.traceVector, self.throwOrigin, av,
                av.getBattleZone().getPhysicsWorld()) + (0, 0, 0.1)

            proj = TNTProjectileAI(base.air, self.avatar, self)
            proj.generateWithRequired(self.avatar.getBattleZone().zoneId)
            proj.setPos(self.throwOrigin)
            proj.lookAt(throwVector)
            proj.node().setLinearVelocity(throwVector * self.ThrowPower)
            proj.d_clearSmoothing()
            proj.d_broadcastPosHpr()
Esempio n. 3
0
    def think(self):
        BaseHitscanAI.think(self)

        if self.action == self.StateFire:

            if self.isAIUser():
                if CIGlobals.isNodePathOk(self.target):
                    self.avatar.headsUp(self.target)
                    self.calibrate(self.target)
                else:
                    return

            if (self.gumballsToFire > 0
                    and globalClock.getFrameTime() >= self.nextFireTime):

                throwVector = PhysicsUtils.getThrowVector(
                    self.traceOrigin, self.traceVector, self.fireOrigin,
                    self.avatar,
                    self.avatar.getBattleZone().getPhysicsWorld())

                endPos = CIGlobals.extrude(self.fireOrigin, self.FirePower,
                                           throwVector) - (0, 0, 90)

                if self.isAIUser():
                    endPos = endPos + Point3(random.uniform(-2.5, 2.5),
                                             random.uniform(-2.5, 2.5),
                                             random.uniform(-2.5, 2.5))

                self.takeAmmo(-1)
                self.fireProjectile(endPos)
                self.gumballsToFire = self.gumballsToFire - 1

                if (self.gumballsToFire > 0):
                    self.nextFireTime = globalClock.getFrameTime(
                    ) + random.uniform(self.MIN_BURST_DELAY,
                                       self.MAX_BURST_DELAY)