示例#1
0
    def cleanup(self):
        self.deleteHoseStuff()
        self.stopParticle()
        self.cleanupWaterBar()
        self.stopSpraySoundIval()
        if self.spraySound:
            base.audio3d.detachSound(self.spraySound)
        self.spraySound = None
        self.lastSprayTime = None
        self.released = None

        BaseHitscan.cleanup(self)
示例#2
0
    def __init__(self):
        BaseHitscan.__init__(self)
        self.sprayParticleRoot = None
        self.waterStreamParent = None
        self.sprayParticle = None
        self.spraySound = base.audio3d.loadSfx(self.spraySoundPath)
        self.spraySound.setVolume(0.0)
        self.lastSprayTime = 0.0
        self.spraySoundIval = None
        
        self.waterBar = None

        self.hydrant = None
        self.hydrantNode = None
        self.hydrantScale = None
        self.hoseJoint = None
        self.released = True
示例#3
0
    def think(self):
        BaseHitscan.think(self)

        if CIGlobals.isNodePathOk(self.hoseJoint):
            hand = self.avatar.getLeftHandNode()
            self.hoseJoint.setHpr(self.avatar, hand.getHpr(self.avatar) + (-5, 5, 0))
            self.hoseJoint.setPos(self.avatar, hand.getPos(self.avatar) + (-0.1, 0.2, 0.1))

        if self.action == self.StateFire:
            self.__updateParticleParent()

        if self.isLocal():

            if self.waterBar:
                perct = self.__updateWaterBar()
                if perct <= 0.3:
                    time = globalClock.getFrameTime()
                    alpha = 0.5 + ((math.sin(time * 7) + 1) / 4)
                    self.waterBar.setBarAlpha(alpha)
示例#4
0
    def unEquip(self):
        if not BaseHitscan.unEquip(self):
            return False

        self.__endSpraying()

        if self.sprayParticleRoot:
            self.sprayParticleRoot.removeNode()
        self.sprayParticleRoot = None
        
        self.deleteHoseStuff()

        if self.isLocal():
            self.cleanupWaterBar()

        return True
示例#5
0
    def equip(self):
        if not BaseHitscan.equip(self):
            return False

        self.sprayParticleRoot = render.attachNewNode('sprayParticleRoot')
        self.sprayParticleRoot.setLightOff(1)
        self.sprayParticleRoot.hide(CIGlobals.ShadowCameraBitmask)

        if self.isLocal():
            self.released = True
            self.waterBar = WaterBar()
            self.__updateWaterBar()
            self.waterBar.reparentTo(base.a2dLeftCenter)
            self.waterBar.setScale(0.6)
            self.waterBar.setX(0.166)

        self.hydrant = loader.loadModel('phase_5/models/props/battle_hydrant.bam')
        self.model.reparentTo(self.hydrant)
        self.model.pose('chan', 2)
        self.hoseJoint = self.model.controlJoint(None, "modelRoot", "joint_x")

        self.hydrantNode = self.avatar.attachNewNode('hydrantNode')
        self.hydrantNode.clearTransform(self.avatar.getGeomNode().getChild(0))
        self.hydrantNode.setHpr(0, 0, 0)
        self.hydrantScale = self.hydrantNode.attachNewNode('hydrantScale')
        self.hydrant.reparentTo(self.hydrantScale)
        self.avatar.pose('firehose', 30)
        self.avatar.update(0)
        torso = self.avatar.getPart('torso')
        if 'dgm' in self.avatar.getTorso():
            self.hydrant.setPos(torso, 0, 0, -1.85)
        else:
            self.hydrant.setPos(torso, 0, 0, -1.45)
        hbase = self.hydrant.find('**/base')
        hbase.setColor(1, 1, 1, 0.5)
        hbase.setPos(self.avatar, 0, 0, 0)

        self.avatar.loop('neutral')

        tAppearDelay = 0.7
        dAnimHold = 5.1
        dHoseHold = 0.7
        tSprayDelay = 2.8
        track = Parallel()
        toonTrack = Sequence(Wait(tAppearDelay),
                             Func(self.avatar.setForcedTorsoAnim, 'firehose'),
                             self.getAnimationTrack('firehose', endFrame = 30),
                             Func(self.__doBob))
        propTrack = Sequence(Func(self.hydrantNode.reparentTo, self.avatar), LerpScaleInterval(self.hydrantScale, tAppearDelay * 0.5, Point3(1, 1, 1.4),
            startScale=Point3(1, 1, 0.01)), LerpScaleInterval(self.hydrantScale, tAppearDelay * 0.3, Point3(1, 1, 0.8), startScale=Point3(1, 1, 1.4)),
            LerpScaleInterval(self.hydrantScale, tAppearDelay * 0.1, Point3(1, 1, 1.2), startScale=Point3(1, 1, 0.8)),
            LerpScaleInterval(self.hydrantScale, tAppearDelay * 0.1, Point3(1, 1, 1), startScale=Point3(1, 1, 1.2)),
            ActorInterval(self.model, 'chan', endFrame = 30))
        track.append(toonTrack)
        track.append(propTrack)
        self.setAnimTrack(track, startNow = True)

        if self.isFirstPerson():
            self.hydrantNode.hide()

        return True
示例#6
0
 def primaryFirePress(self, auto = False):
     if not auto:
         self.released = False
     BaseHitscan.primaryFirePress(self, None)
示例#7
0
 def primaryFireRelease(self, data = None):
     BaseHitscan.primaryFireRelease(self, data)
     self.released = True