def getThrowInterval(self, gag, x, y, z, h, p, r): toon = self.toon flyGag = self.createThrowGag(gag) throwSoundIval = self._throwSfx if throwSoundIval.isPlaying(): throwSoundIval.finish() throwSoundIval.node = toon toonThrowIval1 = ActorInterval( toon, "throw", startFrame=Globals.ThrowStartFrame, endFrame=Globals.ThrowEndFrame, playRate=Globals.ThrowPlayRate, partName="torso", ) toss = Track( ( 0, Sequence( Func(toon.setPosHpr, x, y, z, h, p, r), Func(gag.reparentTo, toon.rightHand), Func(gag.setPosHpr, 0, 0, 0, 0, 0, 0), toonThrowIval1, ), ), ( toonThrowIval1.getDuration(), Parallel( Func(gag.detachNode), Sequence( ActorInterval( toon, "throw", startFrame=Globals.ThrowEndFrame + 1, playRate=Globals.ThrowPlayRate, partName="torso", ), Func(self.completeThrow), ), ), ), ) def getEndPos(toon=toon): return render.getRelativePoint(toon, Point3(0, Globals.ThrowDistance, 0)) fly = Track( (0, throwSoundIval), ( toonThrowIval1.getDuration(), Sequence( Func(flyGag.reparentTo, render), Func(flyGag.setPosHpr, toon, 0.52, 0.97, 2.24, 0, -45, 0), ProjectileInterval(flyGag, endPos=getEndPos, duration=Globals.ThrowDuration), Func(flyGag.detachNode), ), ), ) return (toss, fly, flyGag)
def getToonPullingLeverInterval(self, toon): walkTime = 0.2 reach = ActorInterval(toon, 'leverReach', playRate=2.0) pull = ActorInterval(toon, 'leverPull', startFrame=6) origPos = toon.getPos(render) origHpr = toon.getHpr(render) newPos = self.lever.getPos(render) newHpr = self.lever.getHpr(render) origHpr.setX(PythonUtil.fitSrcAngle2Dest(origHpr[0], newHpr[0])) toon.setPosHpr(origPos, origHpr) reachAndPull = Sequence(ActorInterval(toon, 'walk', loop=True, duration=walkTime - reach.getDuration()), reach, pull) leverSeq = Sequence(Wait(walkTime + reach.getDuration() - 0.1), self.stick.hprInterval(0.55, Point3(0.0, 25.0, 0.0), Point3(0.0, 0.0, 0.0)), Wait(0.3), self.stick.hprInterval(0.4, Point3(0.0, 0.0, 0.0), Point3(0.0, 25.0, 0.0))) returnSeq = Sequence(Parallel(toon.posInterval(walkTime, newPos, origPos), toon.hprInterval(walkTime, newHpr, origHpr), leverSeq, reachAndPull)) return returnSeq
def actorInterval(self, *args, **kwargs): mixingWanted = kwargs.pop('mixingWanted', bool(self.__mixer)) if mixingWanted and self.__mixer: defaultBlendT = self.__mixer.defaultBlendT else: if mixingWanted and self.animationMixer: defaultBlendT = self.animationMixer.defaultBlendT else: defaultBlendT = 0 blendInT = kwargs.pop('blendInT', defaultBlendT) blendOutT = kwargs.pop('blendOutT', defaultBlendT) blendInto = kwargs.pop('blendInto', None) if mixingWanted: partName = kwargs.get('partName', None) return self.__mixer.actorInterval( ActorInterval(self, *args, **kwargs), partName, blendInT, blendOutT, blendInto) return ActorInterval(self, *args, **kwargs)
def setSwingInfo(self, power, angle, sequenceNum): av = base.cr.doId2do.get(self.avId) self.swingInterval = Sequence() if av: self.stopAdjustClubTask() self.swingInterval = Sequence(ActorInterval(av, 'swing-putt', startFrame = 0, endFrame = GolfGlobals.BALL_CONTACT_FRAME), Func(self.startBallPlayback, power, angle, sequenceNum), Func(self.ballModel.hide), ActorInterval(av, 'swing-putt', startFrame = GolfGlobals.BALL_CONTACT_FRAME, endFrame = 24), Func(self.ballModel.setScale, 0.10000000000000001), Func(self.ballModel.show), LerpScaleInterval(self.ballModel, 1.0, Point3(1, 1, 1)), Func(self.enableControlKey)) if av == localAvatar: self.swingInterval.append(Func(self.switchToAnimState, 'GolfPuttLoop', True)) self.swingInterval.start()
def createIdleInterval(self): result = Sequence() if self.numIdles >= 3: numberOfAnimsAbove2 = self.numIdles - 2 for rareIdle in range(2, self.numIdles): for i in range(2): result.append(ActorInterval(self.node, 'idle0')) result.append(Wait(self.IdlePauseTime)) result.append(ActorInterval(self.node, 'idle1')) result.append(Wait(self.IdlePauseTime)) result.append(ActorInterval(self.node, 'idle%d' % rareIdle)) result.append(Wait(self.IdlePauseTime)) else: for i in range(self.numIdles): result.append(ActorInterval(self.node, 'idle%d' % i)) self.notify.debug('idle interval=%s' % result) return result
def enterDie(self, ts=0): self.show() self.generateCog(isLose=1) self.nametag.clearChatText() self.deleteNameTag() deathSound = base.audio3d.loadSfx( 'phase_3.5/audio/sfx/Cog_Death_Full.ogg') base.audio3d.attachSoundToObject(deathSound, self) trackName = self.uniqueName('enterDie') smallGears = ParticleLoader.loadParticleEffect( 'phase_3.5/etc/gearExplosionSmall.ptf') smallGears.getParticlesNamed('particles-1').setPoolSize(30) singleGear = ParticleLoader.loadParticleEffect( 'phase_3.5/etc/gearExplosion.ptf') singleGear.getParticlesNamed('particles-1').setPoolSize(1) smallGearExplosion = ParticleLoader.loadParticleEffect( 'phase_3.5/etc/gearExplosion.ptf') smallGearExplosion.getParticlesNamed('particles-1').setPoolSize(10) bigGearExplosion = ParticleLoader.loadParticleEffect( 'phase_3.5/etc/gearExplosionBig.ptf') bigGearExplosion.getParticlesNamed('particles-1').setPoolSize(30) smallGears.setDepthWrite(False) singleGear.setDepthWrite(False) smallGearExplosion.setDepthWrite(False) bigGearExplosion.setDepthWrite(False) self.smallGears = smallGears self.smallGears.setPos(self.find('**/joint_head').getPos() + (0, 0, 2)) self.singleGear = singleGear self.smallGearExp = smallGearExplosion self.bigGearExp = bigGearExplosion gearTrack = Sequence(Wait(0.7), Func(self.doSingleGear), Wait(1.5), Func(self.doSmallGears), Wait(3.0), Func(self.doBigExp)) self.suitTrack = Parallel(Sequence( Wait(0.8), SoundInterval(deathSound, node=self, duration=deathSound.length() / 2)), Sequence(Wait(0.7), Func(self.doSingleGear), Wait(4.3), Func(self.suitExplode), Wait(1.0), Func(self.disableBodyCollisions), Func(self.__cleanupExplosion)), gearTrack, Sequence( ActorInterval(self, 'lose', duration=6), Func(self.getGeomNode().hide)), name=trackName) self.suitTrack.setDoneEvent(self.suitTrack.getName()) self.acceptOnce(self.suitTrack.getName(), self.exitDie) self.suitTrack.delayDelete = DelayDelete.DelayDelete(self, trackName) self.suitTrack.start(ts) del deathSound
def __doDustClear(self, entity): dustTrack = Sequence() dust = self.buildDust() dust.setBillboardPointEye() dust.setScale(Point3(0.1, 0.9, 1)) dust.setPos(entity.getPos(render)) entity.removeNode() self.removeEntity(entity) dustTrack.append(Func(dust.reparentTo, render)) dustTrack.append(ActorInterval(dust, 'chan')) dustTrack.append(Func(dust.cleanup)) dustTrack.start()
def makeToonReleaseInterval(self, toon): def getSlideToPos(toon = toon): return render.getRelativePoint(toon, Point3(0, -5, 0)) if self.gotHitByBoss: grabIval = Sequence(Func(self.detachClub), name='makeToonReleaseInterval-gotHitByBoss') if not toon.isEmpty(): toonIval = Sequence(Func(toon.wrtReparentTo, render), Parallel(ActorInterval(toon, 'slip-backward'), toon.posInterval(0.5, getSlideToPos, fluid=1)), name='makeToonReleaseInterval-toonIval') grabIval.append(toonIval) else: grabIval = Sequence(Func(self.detachClub)) if not toon.isEmpty(): toonIval = Sequence(Parallel(ActorInterval(toon, 'walk', duration=1.0, playRate=-1.0), LerpPosInterval(toon, duration=1.0, pos=Point3(-10, 0, 0))), Func(toon.wrtReparentTo, render)) grabIval.append(toonIval) if localAvatar.doId == toon.doId: if not self.goingToReward and toon.hp > 0: grabIval.append(Func(self.goToFinalBattle)) grabIval.append(Func(self.notify.debug, 'goingToFinalBattlemode')) grabIval.append(Func(self.safeBossToFinalBattleMode)) return grabIval
def onSetAction_firstPerson(self, action): track = Sequence() vm = self.getViewModel() fpsCam = self.getFPSCam() if action == self.StateIdle: track.append(Func(vm.loop, "idle")) elif action == self.StateDraw: track.append(ActorInterval(vm, "draw", playRate=self.Speed)) elif action == self.StateReload: track.append(Func(self.reloadSound.play)) track.append(ActorInterval(vm, "reload", playRate=self.Speed)) elif action == self.StateFire: CIGlobals.makeMuzzleFlash(self.fpMuzzleAttach, (0, 0, 0), (-90, 0, 0), 7) fpsCam.resetViewPunch() fpsCam.addViewPunch( Vec3(random.uniform(-0.6, 0.6), random.uniform(-0.25, -0.5), 0.0)) track.append(Func(self.fireSound.play)) track.append(ActorInterval(vm, "fire", playRate=self.Speed)) fpsCam.setVMAnimTrack(track)
def getSplicedLerpAnimsTrack(self, av, animName, origDuration, newDuration, startTime=0, fps=30): track = Sequence() addition = 0 numIvals = int(origDuration * fps) timeInterval = newDuration / numIvals animInterval = origDuration / numIvals for _ in range(0, numIvals): track.append(Wait(timeInterval)) track.append(ActorInterval(av, animName, startTime=startTime + addition, duration=animInterval)) addition += animInterval return track
def __init__(self, parent): FloorBase.__init__(self, parent) actor = self.actor actor.make_subpart('sky', ['sky']) actor.make_subpart('cube', ['cube']) actor.make_subpart('elevator', ['elevator', 'elevator opening', 'elevator door right', 'elevator door left']) actor.make_subpart('bells', ['bell0', 'bell1', 'bell2', 'bell3']) self.actor.pose('sky_scroll', 1, partName='sky') # Contains last four bells that Hobot smacked self.sequence = () self.cube_landed = False self.song_delay = globalClock.frame_time self.cube_idle_loop = Sequence( ActorInterval(self.actor, 'cube idle', partName='cube'), ActorInterval(self.actor, 'cube idle', partName='cube'), ActorInterval(self.actor, 'cube idle', partName='cube'), Func(self.sfx['cubesong'].play), ActorInterval(self.actor, 'cube singing', partName='cube'), ActorInterval(self.actor, 'cube singing', partName='cube'), ActorInterval(self.actor, 'cube idle', partName='cube'), )
def getToonPullingLeverInterval(self, toon): walkTime = 0.2 reach = ActorInterval(toon, 'leverReach', playRate=2.0) pull = ActorInterval(toon, 'leverPull', startFrame=6) origPos = toon.getPos(render) origHpr = toon.getHpr(render) newPos = self.lever.getPos(render) newHpr = self.lever.getHpr(render) origHpr.setX(PythonUtil.fitSrcAngle2Dest(origHpr[0], newHpr[0])) toon.setPosHpr(origPos, origHpr) reachAndPull = Sequence( ActorInterval(toon, 'walk', loop=True, duration=walkTime - reach.getDuration()), reach, pull) leverSeq = Sequence( Wait(walkTime + reach.getDuration() - 0.1), self.stick.hprInterval(0.55, Point3(0.0, 25.0, 0.0), Point3(0.0, 0.0, 0.0)), Wait(0.3), self.stick.hprInterval(0.4, Point3(0.0, 0.0, 0.0), Point3(0.0, 25.0, 0.0))) returnSeq = Sequence( Parallel(toon.posInterval(walkTime, newPos, origPos), toon.hprInterval(walkTime, newHpr, origHpr), leverSeq, reachAndPull)) return returnSeq
def changeDinerToEating(self, chairIndex): indicator = self.dinerStatusIndicators.get(chairIndex) eatingDuration = self.dinerInfo[chairIndex][1] if indicator: indicator.request('Eating', eatingDuration) diner = self.diners[chairIndex] intervalName = 'eating-%d-%d' % (self.index, chairIndex) eatInTime = 32.0 / 24.0 eatOutTime = 21.0 / 24.0 eatLoopTime = 19 / 24.0 rightHand = diner.getRightHand() waitTime = 5 loopDuration = eatingDuration - eatInTime - eatOutTime - waitTime serviceLoc = self.serviceLocs[chairIndex] def foodAttach(self=self, diner=diner): if self.serviceLocs[chairIndex].getNumChildren() < 1: return foodModel = self.serviceLocs[chairIndex].getChild(0) (foodModel.reparentTo(diner.getRightHand()), ) (foodModel.setHpr(Point3(0, -94, 0)), ) (foodModel.setPos(Point3(-0.15, -0.7, -0.4)), ) scaleAdj = 1 if SuitDNA.getSuitBodyType(diner.dna.name) == 'c': scaleAdj = 0.6 (foodModel.setPos(Point3(0.1, -0.25, -0.31)), ) else: scaleAdj = 0.8 (foodModel.setPos(Point3(-0.25, -0.85, -0.34)), ) oldScale = foodModel.getScale() newScale = oldScale * scaleAdj foodModel.setScale(newScale) def foodDetach(self=self, diner=diner): if diner.getRightHand().getNumChildren() < 1: return foodModel = diner.getRightHand().getChild(0) (foodModel.reparentTo(serviceLoc), ) (foodModel.setPosHpr(0, 0, 0, 0, 0, 0), ) scaleAdj = 1 if SuitDNA.getSuitBodyType(diner.dna.name) == 'c': scaleAdj = 0.6 else: scakeAdj = 0.8 oldScale = foodModel.getScale() newScale = oldScale / scaleAdj foodModel.setScale(newScale) eatIval = Sequence( ActorInterval(diner, 'sit', duration=waitTime), ActorInterval(diner, 'sit-eat-in', startFrame=0, endFrame=6), Func(foodAttach), ActorInterval(diner, 'sit-eat-in', startFrame=6, endFrame=32), ActorInterval(diner, 'sit-eat-loop', duration=loopDuration, loop=1), ActorInterval(diner, 'sit-eat-out', startFrame=0, endFrame=12), Func(foodDetach), ActorInterval(diner, 'sit-eat-out', startFrame=12, endFrame=21)) eatIval.start() self.activeIntervals[intervalName] = eatIval
def fillSlot(self, index, avId): toon = self.cr.doId2do.get(avId) toon.stopSmooth() if toon: toon.wrtReparentTo(self.trolleyCar) if index <= 3: slotPos = Point3(-5, -4.5 + index * 3, 1.4) sitStartDuration = toon.getDuration('start-sit') toon.headsUp(slotPos) track = Sequence( Func(toon.setAnimState, 'run'), LerpPosInterval(toon, 0.75, Point3(-5, -4.5 + index * 3, 1.4)), LerpHprInterval(toon, 0.25, Point3(90, 0, 0)), Parallel( ActorInterval(toon, 'start-sit'), Sequence( Wait(sitStartDuration * 0.25), LerpPosInterval( toon, sitStartDuration * 0.25, Point3(-3.9, -4.5 + index * 3, 3.0)))), Func(toon.loop, 'sit')) else: slotPos = self.STAND_POSITIONS[index] toon.headsUp(slotPos) track = Sequence( Func(toon.setAnimState, 'run'), LerpPosInterval(toon, duration=1.0, pos=slotPos, startPos=toon.getPos()), Func(toon.setAnimState, 'neutral'), Func(toon.setHpr, 90, 0, 0)) track.start() if avId == base.localAvatar.doId: self.localAvOnTrolley = True base.localAvatar.stopSmartCamera() base.camera.wrtReparentTo(self.trolleyCar) camTrack = Sequence( Parallel( LerpPosInterval(base.camera, duration=1.5, pos=self.CAM_POS, startPos=base.camera.getPos(), blendType='easeOut'), LerpQuatInterval(base.camera, duration=1.5, hpr=self.CAM_HPR, startHpr=base.camera.getHpr(), blendType='easeOut')), Func(self.enableExitButton)) camTrack.start()
def enterWalking(self, pointLetter, startPointLetter, ts): if self.walkIval: self.walkIval.finish() self.walkIval = None self.nametag.clearChatText() self.loop('walk') point = WALK_POINTS[self.charId][pointLetter][0] lastPoint = WALK_POINTS[self.charId][startPointLetter][0] seq = Sequence(name=self.uniqueName('DCharWalkIval')) if self.charId == PLUTO: seq.append(ActorInterval(self, 'stand')) else: if self.charId == SLEEP_DONALD: seq.append(ActorInterval(self, 'neutral2walk')) seq.append(Func(self.loop, 'walk')) ival = NPCWalkInterval(self, point, startPos=lastPoint, fluid=1) seq.append(ival) seq.append(Func(self.loop, 'neutral')) seq.start(ts) self.currentPointLetter = pointLetter self.walkIval = ival return
def enterStunned(self, animB4Stun, ts = 0): self.show() animB4Stun = SuitGlobals.getAnimById(animB4Stun).getName() self.stunnedSound = base.loadSfxOnNode("phase_4/audio/sfx/SZ_TC_bird1.ogg", self) self.stunnedSound.setLoop(True) self.stunnedSound.play() self.stunnedIval = Parallel(Sequence(ActorInterval(self, animB4Stun), Func(self.loop, 'stunned')), SuitGlobals.createStunInterval(self, 0, 100)) self.stunnedIval.start()
def _getAnimationIval(self, animName, startFrame=0, endFrame=None, duration=1): if endFrame == None: self.suit.getNumFrames(animName) - 1 frames = endFrame - startFrame frameRate = self.suit.getFrameRate(animName) newRate = frames / duration playRate = newRate / frameRate ival = Sequence(ActorInterval(self.suit, animName, playRate=playRate)) return ival
def doAttack(self, ts=0): self.dollar = loader.loadModel('phase_5/models/props/1dollar-bill-mod.bam') self.dollar.setY(0.22) self.dollar.setHpr(289.18, 252.75, 0.0) if hasattr(self.suit, 'uniqueName'): name = self.suit.uniqueName('doPickPocketAttack') else: name = 'doPickPocketAttack' self.suitTrack = Parallel(ActorInterval(self.suit, 'pickpocket'), Sequence(Wait(0.4), Func(self.attemptDamage)), name=name) self.suitTrack.setDoneEvent(self.suitTrack.getName()) self.acceptOnce(self.suitTrack.getDoneEvent(), self.finishedAttack) self.suitTrack.delayDelete = DelayDelete.DelayDelete(self.suit, name) self.suitTrack.start(ts)
def __init__(self, index, motionPath = None): radius = Globals.Gameplay.FlyingMinionCollisionRadius offset = Globals.Gameplay.FlyingMinionCollisionHeightOffset collSolid = CollisionSphere(0, 0, offset, radius) CogdoFlyingMinion.__init__(self, index, collSolid, motionPath) self.attachPropeller() self.propTrack = Sequence(ActorInterval(self.prop, 'propeller', startFrame=0, endFrame=14)) dur = Globals.Gameplay.FlyingMinionFloatTime offset = Globals.Gameplay.FlyingMinionFloatOffset suitPos = self.suit.getPos() upperPos = suitPos + Point3(0.0, 0.0, offset / 2.0) lowerPos = suitPos + Point3(0.0, 0.0, -offset / 2.0) self.floatSequence = Sequence(LerpPosInterval(self.suit, dur / 4.0, startPos=suitPos, pos=upperPos, blendType='easeInOut'), LerpPosInterval(self.suit, dur / 2.0, startPos=upperPos, pos=lowerPos, blendType='easeInOut'), LerpPosInterval(self.suit, dur / 4.0, startPos=lowerPos, pos=suitPos, blendType='easeInOut'), name='%s.floatSequence%i' % (self.__class__.__name__, self.index))
def doAttack(self, ts=0): self.loadAttack() if hasattr(self.suit, 'uniqueName'): name = self.suit.uniqueName('doFountainPenAttack') else: name = 'doFountainPenAttack' self.suitTrack = Parallel(name=name) self.suitTrack.append(ActorInterval(self.suit, 'fountainpen')) self.suitTrack.append(Sequence(Wait(1.2), Func(self.acceptOnce, 'enter' + self.wsnp.node().getName(), self.handleSprayCollision), Func(self.playWeaponSound), Func(self.attachSpray), Func(self.sprayParticle.start, self.pen.find('**/joint_toSpray'), self.pen.find('**/joint_toSpray')), self.sprayScaleIval, Wait(0.5), Func(self.sprayParticle.cleanup), Func(self.spray.setScale, 1), Func(self.spray.reparentTo, hidden), Func(self.ignore, 'enter' + self.wsnp.node().getName()))) self.suitTrack.setDoneEvent(self.suitTrack.getName()) self.acceptOnce(self.suitTrack.getDoneEvent(), self.finishedAttack) self.suitTrack.delayDelete = DelayDelete.DelayDelete(self.suit, name) self.suitTrack.start(ts)
def doInspect(self, task): task.delayTime = random.uniform(*self.InspectIval) cam = self.getFPSCam() if cam.vmAnimTrack and cam.vmAnimTrack.isPlaying(): return task.again vm = self.getViewModel() cam.setVMAnimTrack( Sequence(ActorInterval(vm, "sg_inspect"), Func(vm.loop, "sg_idle"))) return task.again
def throwTeamInWater(self, losingTeam): self.notify.debug("throwTeamInWater( %s )" % PartyGlobals.TeamActivityTeams.getString(losingTeam)) splashSet = False for toonId in self.toonIds[losingTeam]: # throw toon in water self.fallenToons.append(toonId) toon = self.getAvatar(toonId) # getting a a crash of popping from empty list #fallenPosIndex = self.unusedFallenPositionsIndices.pop(0) fallenPosIndex = self.toonIds[losingTeam].index(toonId) if (fallenPosIndex < 0) or (fallenPosIndex >= 4): fallenPosIndex = 0 newPos = self.fallenPositions[fallenPosIndex] # animate the toons falling into the water if self.toonIdsToAnimIntervals[toonId] is not None: if self.toonIdsToAnimIntervals[toonId].isPlaying(): self.toonIdsToAnimIntervals[toonId].finish() # Fall into water if toon: parallel = Parallel( ActorInterval(actor=toon, animName='slip-forward', duration=2.0), LerpPosInterval(toon, duration=2.0, pos=newPos, other=self.root), ) else: self.notify.warning("toon %d is none, skipping slip-forward" % toonId) parallel = Parallel() # only setup splash for the first toon if not splashSet: splashSet = True parallel.append(self.splashInterval) if toon: self.toonIdsToAnimIntervals[toonId] = Sequence( parallel, Func(toon.loop, 'neutral'), ) else: self.notify.warning( "toon %d is none, skipping toon.loop(neutral)" % toonId) self.toonIdsToAnimIntervals[toonId] = parallel self.toonIdsToAnimIntervals[toonId].start()
def buildTracks(self, mode=0): if not self.avatar: return self.cleanupTracks() if mode == 0: self.actorTrack = Sequence( ActorInterval(self.avatar, self.buttonAnim, startFrame=self.chooseLocFrame, endFrame=self.completeFrame, playRate=self.playRate)) self.soundTrack = Sequence( Wait(self.buttonHold), SoundInterval(self.buttonSfx, node=self.avatar))
def _getToonAnimationIval(self, animName, startFrame=0, duration=1, nextState=None): totalFrames = self.toon.getNumFrames(animName) frames = totalFrames - 1 - startFrame frameRate = self.toon.getFrameRate(animName) newRate = frames / duration playRate = newRate / frameRate ival = Sequence(ActorInterval(self.toon, animName, startTime=startFrame / newRate, endTime=totalFrames / newRate, playRate=playRate)) if nextState is not None: def done(): self.request(nextState) ival.append(Func(done)) return ival
def enterReload(self): self.gui.deleteNoAmmoLabel() if self.weaponName == 'pistol': self.track = Parallel(Sequence(Wait(0.3), Func(self.reload.play), Func(self.resetAmmo)), ActorInterval(self.v_model, 'preload', playRate=1.5), name='reloadTrack') else: if self.weaponName == 'shotgun': self.track = Sequence(Func(self.draw.play), LerpQuatInterval(self.v_model, duration=0.5, quat=(70, -50, 0), startHpr=(0, 0, 0), blendType='easeIn'), SoundInterval(self.cockBack), SoundInterval(self.cockFwd), Func(self.resetAmmo), Func(self.draw.play), LerpQuatInterval(self.v_model, duration=0.5, quat=(0, 0, 0), startHpr=(70, -50, 0), blendType='easeOut'), name='reloadTrack') else: if self.weaponName == 'sniper': self.track = Sequence(Func(self.draw.play), LerpQuatInterval(self.v_model, duration=0.5, quat=(70, -50, 0), startHpr=(0, 0, 0), blendType='easeIn'), SoundInterval(self.cockBack), SoundInterval(self.cockFwd), Func(self.resetAmmo), Func(self.draw.play), LerpQuatInterval( self.v_model, duration=0.5, quat=(0, 0, 0), startHpr=(70, -50, 0), blendType='easeOut'), name='reloadTrack') self.track.setDoneEvent('reloadTrack') self.acceptOnce(self.track.getDoneEvent(), self.aliveFSM.request, ['idle']) self.track.start()
def onSetAction_firstPerson(self, action): vm = self.getViewModel() vm.show() vmGag = self.getVMGag() vmGag.show() fpsCam = self.getFPSCam() if action == self.StateThrow: if self.throwSound: self.throwSound.play() vmGag.hide() fpsCam.setVMAnimTrack( Sequence(ActorInterval(vm, "tnt_throw", startFrame=27), Func(vm.hide))) fpsCam.addViewPunch(self.getViewPunch()) elif action == self.StateDraw: fpsCam.setVMAnimTrack(Sequence(ActorInterval(vm, "pie_draw"))) elif action == self.StateIdle: fpsCam.setVMAnimTrack(Sequence(Func(vm.loop, "pie_idle")))
def enterShoot(self, target=None): if not target: target = base.localAvatar self.pose("collapse", 1) self.shootTrack = Sequence( Parallel( Sequence( LerpFunc(self.blendAnimFromBase, fromData=0, toData=1, duration=0.25, extraArgs=['collapse']), ActorInterval(self, "collapse", startFrame=1, endFrame=5, playRate=0.8), ActorInterval(self, "collapse", startFrame=5, endFrame=22, playRate=0.7), ActorInterval(self, "collapse", startFrame=22, endFrame=5, playRate=0.7), LerpFunc(self.blendAnimFromBase, fromData=1, toData=0, duration=0.25, extraArgs=['collapse'])), Sequence(Wait(0.1), SoundInterval(self.whipSound, node=self)), Sequence(Wait(0.55), SoundInterval(self.shootSound, node=self)), Sequence(Wait(0.635), Func(self.fireLaser, target)))) self.shootTrack.start()
def equip(self): TossTrapGag.equip(self) if not self.gag: self.build() self.gag.show() if self.isLocal(): vm = self.getViewModel() cam = self.getFPSCam() cam.setVMGag(self.gag, pos = (-0.23, 0.26, 0.05), hpr = (321.45, 55.74, 120.67), scale = 0.5, animate = False) cam.setVMAnimTrack(Sequence(ActorInterval(vm, "tnt_draw"), Func(vm.loop, "tnt_idle"))) self.doDrawAndHold('toss', 0, 30, 1.0, 30, 30, 1.0)
def release(self): if self.isLocal(): self.startTimeout() def doSpray(): if self.avatar.isEmpty(): return self.sprayRange = self.avatar.getPos(render) + Point3(0, GagGlobals.SELTZER_RANGE, 0) self.doSpray(self.sprayScale, self.holdTime, self.sprayScale, horizScale=0.5, vertScale=0.5) if self.isLocal(): base.localAvatar.sendUpdate('usedGag', [self.id]) track = Parallel(Sequence(ActorInterval(self.avatar, 'squirt', startFrame=48, endFrame=58), Wait(1.0), ActorInterval(self.avatar, 'squirt', startFrame=107, endFrame=126, playRate=3)), Sequence(Wait(0.1), Func(doSpray))) track.start() self.tracks = track
def onSetAction_firstPerson(self, action): fpsCam = self.getFPSCam() vm = self.getViewModel() if action == self.StateFire: fpsCam.addViewPunch(self.getViewPunch()) fpsCam.setVMAnimTrack( Parallel(Func(self.fireSound.play), ActorInterval(vm, 'slap_hit'))) elif action == self.StateIdle: fpsCam.setVMAnimTrack(Func(vm.loop, 'slap_idle')) elif action == self.StateDraw: fpsCam.setVMAnimTrack(Func(vm.play, 'slap_idle'))
def equip(self): Gag.equip(self) if self.isLocal(): vmGag = base.localAvatar.getFPSCam().vmGag if vmGag: vmGag.setPosHpr(0.07, 0.17, -0.01, 0, -100, -10) vmGag.setScale(self.gag.getScale() * 0.567) vm = base.localAvatar.getViewModel() fpsCam = base.localAvatar.getFPSCam() fpsCam.setVMAnimTrack( Sequence(ActorInterval(vm, "pie_draw"), Func(vm.loop, "pie_idle"))) self.__doDraw()
def onSetAction_firstPerson(self, action): vm = self.getViewModel() fpsCam = self.getFPSCam() vm.hide() if action == self.StateFire: sound = random.randint(0, len(self.appearSfx) - 1) appearSfx = self.appearSfx[sound] soundSfx = self.soundSfx[sound] fpsCam.setVMAnimTrack( Parallel( Sequence(Func(fpsCam.vmRoot2.setY, 0.5), Wait(0.75), Func(vm.show), ActorInterval(vm, "sound"), Func(fpsCam.vmRoot2.setY, 0.0), Func(vm.hide)), Sequence(Wait(1.0), Func(appearSfx.play), Wait(1.5), Func(soundSfx.play))))