def unload(self): self.unloadBattleAnims() globalPropPool.unloadProps() globalBattleSoundCache.clear() BattleParticles.unloadParticles() self.parentFSMState.removeChild(self.fsm) del self.parentFSMState del self.fsm del self.streetClass self.landmarkBlocks.removeNode() del self.landmarkBlocks self.hood.dnaStore.resetSuitPoints() self.hood.dnaStore.resetBattleCells() del self.hood del self.nodeDict del self.zoneDict del self.fadeInDict del self.fadeOutDict del self.nodeList self.geom.removeNode() del self.geom self.townBattle.unload() self.townBattle.cleanup() del self.townBattle del self.battleMusic del self.music del self.activityMusic del self.holidayPropTransforms self.deleteAnimatedProps() cleanupDialog('globalDialog') ModelPool.garbageCollect() TexturePool.garbageCollect()
def createGoonExplosion(parent, explosionPoint, scale): BattleParticles.loadParticles() deathNode = NodePath('goonDeath') deathNode.setPos(explosionPoint) explosion = createExplosionTrack(parent, deathNode, scale) smallGearExplosion = BattleParticles.createParticleEffect('GearExplosion', numParticles=10) bigGearExplosion = BattleParticles.createParticleEffect('WideGearExplosion', numParticles=30) deathSound = base.loadSfx('phase_3.5/audio/sfx/ENC_cogfall_apart.ogg') return Parallel(explosion, SoundInterval(deathSound), ParticleInterval(smallGearExplosion, deathNode, worldRelative=0, duration=4.3, cleanup=True), ParticleInterval(bigGearExplosion, deathNode, worldRelative=0, duration=1.0, cleanup=True), name='gears2MTrack')
def __init__(self, serialNum, maze, randomNumGen, difficulty, startTile, cogdoSuitType, walkAnimName = None): data = Globals.SuitData[cogdoSuitType] MazeSuit.__init__(self, serialNum, maze, randomNumGen, data['cellWalkPeriod'], difficulty, data['dnaName'], startTile=startTile, walkSameDirectionProb=Globals.SuitWalkSameDirectionProb, walkTurnAroundProb=Globals.SuitWalkTurnAroundProb, uniqueRandomNumGen=False, walkAnimName=walkAnimName) FSM.__init__(self, 'CogdoMazeSuit') CogdoMazeSplattable.__init__(self, self.suit, '%s-%i' % (Globals.SuitCollisionName, self.serialNum), 1.5) if 'scale' in data: self.suit.setScale(data['scale']) self.hp = data['hp'] self.type = cogdoSuitType self.memos = data['memos'] self.deathSuit = self.suit.getLoseActor() self.deathSuit.pose('lose', 0) BattleParticles.loadParticles() self._initSfx()
def createSnow(geom): snow = BattleParticles.loadParticleFile('snowdisk.ptf') snow.setPos(0, 0, 5) snowRender = geom.attachNewNode('snowRender') snowRender.setDepthWrite(0) snowRender.setBin('fixed', 1) return snow, snowRender
def __init__(self, parent, smokeParent): NodePath.__init__(self) notify = DirectNotifyGlobal.directNotify.newCategory('RocketExplosionParticles') self.effectNode = parent.attachNewNode('RocketExplosion') self.effectNode.setBin('fixed', 1) self.effectNode.setDepthWrite(1) self.smokeEffectNode = smokeParent.attachNewNode('RocketSmoke') self.smokeEffectNode.setBin('fixed', 1) self.smokeEffectNode.setDepthWrite(0) self.effect = BattleParticles.loadParticleFile('tt_p_efx_rocketLaunchFire.ptf') self.smokeEffect = BattleParticles.loadParticleFile('tt_p_efx_rocketLaunchSmoke.ptf') ren = self.effect.getParticlesNamed('particles-1').getRenderer() ren.setTextureFromNode('phase_4/models/props/tt_m_efx_fireball', '**/*') ren = self.smokeEffect.getParticlesNamed('particles-1').getRenderer() ren.setTextureFromNode('phase_4/models/props/tt_m_efx_smoke', '**/*') self.endSeq = None self.cleanupCompleted = 0 return
def __init__(self, parent, renderParent): NodePath.__init__(self) notify = DirectNotifyGlobal.directNotify.newCategory('SparkParticles') self.renderParent = renderParent.attachNewNode('sparkRenderParent') self.renderParent.setBin('fixed', 0) self.renderParent.setDepthWrite(0) self.assign(parent.attachNewNode('sparks')) self.effect = BattleParticles.loadParticleFile('sparks.ptf') ren = self.effect.getParticlesNamed('particles-1').getRenderer() ren.setTextureFromNode('phase_6/models/karting/particleSpark', '**/*')
def __init__(self, parent, renderParent): NodePath.__init__(self) notify = DirectNotifyGlobal.directNotify.newCategory("DriftParticles") self.renderParent = renderParent.attachNewNode("driftRenderParent") self.renderParent.setBin("fixed", 0) self.renderParent.setDepthWrite(0) self.assign(parent.attachNewNode("drift")) self.effect = BattleParticles.loadParticleFile("drift.ptf") ren = self.effect.getParticlesNamed("particles-1").getRenderer() ren.setTextureFromNode("phase_6/models/karting/driftSmoke", "**/*")
def __init__(self, enemyMgr, index, suitAttribs): self.enemyMgr = enemyMgr self.game = self.enemyMgr.section.sectionMgr.game self.index = index self.moveIval = None self.propTrack = None self.animTrack = None self.shotTrack = None self.deathTrack = None self.deathSuit = None self.suitSound = None self.deleteMeCallback = None self.isMovingUpDown = False self.isMovingLeftRight = False self.showCollSpheres = False self.isDestroyed = False self.isGoingUp = False self.setupEnemy(suitAttribs) BattleParticles.loadParticles() return
def load(self, zoneId): TownLoader.TownLoader.load(self, zoneId) Suit.loadSuits(3) dnaFile = 'phase_8/dna/the_burrrgh_' + str(self.canonicalBranchZone) + '.pdna' self.createHood(dnaFile) self.windSound = map(base.loadSfx, ['phase_8/audio/sfx/SZ_TB_wind_1.ogg', 'phase_8/audio/sfx/SZ_TB_wind_2.ogg', 'phase_8/audio/sfx/SZ_TB_wind_3.ogg']) self.snow = BattleParticles.loadParticleFile('snowdisk.ptf') self.snow.setPos(0, 0, 5) self.snowRender = self.geom.attachNewNode('snowRender') self.snowRender.setDepthWrite(0) self.snowRender.setBin('fixed', 1)
def doDeathTrack(self): def removeDeathSuit(suit, deathSuit): if not deathSuit.isEmpty(): deathSuit.detachNode() suit.cleanupLoseActor() self.deathSuit.reparentTo(self.suit.getParent()) self.deathSuit.setScale(self.suit.getScale()) self.deathSuit.setPos(render, self.suit.getPos(render)) self.deathSuit.setHpr(render, self.suit.getHpr(render)) self.suit.hide() self.collNodePath.reparentTo(self.deathSuit) gearPoint = Point3(0, 0, self.suit.height / 2.0 + 2.0) smallGears = BattleParticles.createParticleEffect(file='gearExplosionSmall') singleGear = BattleParticles.createParticleEffect('GearExplosion', numParticles=1) smallGearExplosion = BattleParticles.createParticleEffect('GearExplosion', numParticles=10) bigGearExplosion = BattleParticles.createParticleEffect('BigGearExplosion', numParticles=30) smallGears.setPos(gearPoint) singleGear.setPos(gearPoint) smallGearExplosion.setPos(gearPoint) bigGearExplosion.setPos(gearPoint) smallGears.setDepthWrite(False) singleGear.setDepthWrite(False) smallGearExplosion.setDepthWrite(False) bigGearExplosion.setDepthWrite(False) suitTrack = Sequence(Func(self.collNodePath.stash), ActorInterval(self.deathSuit, 'lose', startFrame=80, endFrame=140), Func(removeDeathSuit, self.suit, self.deathSuit, name='remove-death-suit')) explosionTrack = Sequence(Wait(1.5), MovieUtil.createKapowExplosionTrack(self.deathSuit, explosionPoint=gearPoint)) gears1Track = Sequence(ParticleInterval(smallGears, self.deathSuit, worldRelative=0, duration=4.3, cleanup=True), name='gears1Track') gears2MTrack = Track((0.0, explosionTrack), (0.7, ParticleInterval(singleGear, self.deathSuit, worldRelative=0, duration=5.7, cleanup=True)), (5.2, ParticleInterval(smallGearExplosion, self.deathSuit, worldRelative=0, duration=1.2, cleanup=True)), (5.4, ParticleInterval(bigGearExplosion, self.deathSuit, worldRelative=0, duration=1.0, cleanup=True)), name='gears2MTrack') def removeParticle(particle): if particle and hasattr(particle, 'renderParent'): particle.cleanup() del particle removeParticles = Sequence(Func(removeParticle, smallGears), Func(removeParticle, singleGear), Func(removeParticle, smallGearExplosion), Func(removeParticle, bigGearExplosion)) self.deathTrack = Sequence(Parallel(suitTrack, gears2MTrack, gears1Track, self._deathSoundIval), removeParticles) self.deathTrack.start()
def setHillType(self, type): if self.isUp and (self.hillType == MoleFieldBase.HILL_MOLE and type == MoleFieldBase.HILL_BOMB or self.hillType == MoleFieldBase.HILL_BOMB and type == MoleFieldBase.HILL_MOLE): return self.hillType = type self.moleHead.removeNode() if type == MoleFieldBase.HILL_MOLE: self.moleHead = loader.loadModel('phase_12/models/bossbotHQ/mole_norm') self.moleColNodePath.setScale(3.0) self.moleHead.setH(0) self.mole.setBillboardAxis(localAvatar, 0) if type == MoleFieldBase.HILL_BOMB or type == MoleFieldBase.HILL_COGWHACKED: self.moleHead = loader.loadModel('phase_12/models/bossbotHQ/mole_cog') self.moleColNodePath.setScale(1.0) self.mole.setBillboardAxis(localAvatar, 0) if type == MoleFieldBase.HILL_COGWHACKED: self.doMoleDown() BattleParticles.loadParticles() singleGear = BattleParticles.createParticleEffect('GearExplosion', numParticles=1) smallGearExplosion = BattleParticles.createParticleEffect('GearExplosion', numParticles=10) bigGearExplosion = BattleParticles.createParticleEffect('BigGearExplosion', numParticles=30) gears2MTrack = Track((0.0, ParticleInterval(singleGear, self.hill, worldRelative=1, duration=5.7, cleanup=True)), (0.0, ParticleInterval(smallGearExplosion, self.hill, worldRelative=0, duration=1.2, cleanup=True)), (0.3, ParticleInterval(bigGearExplosion, self.hill, worldRelative=0, duration=1.0, cleanup=True)), name='gears2MTrack') gears2MTrack.start() self.popIval = Sequence(Parallel(Sequence(LerpPosInterval(self.moleHead, 0.05, Point3(0.28, 0.0, 0.0)), LerpPosInterval(self.moleHead, 0.05, Point3(0.0, -0.23, 0.0)), LerpPosInterval(self.moleHead, 0.05, Point3(0.0, 0.0, 0.28)), LerpPosInterval(self.moleHead, 0.05, Point3(-0.35, 0.0, 0.0)), LerpPosInterval(self.moleHead, 0.05, Point3(0.0, 0.28, 0.0)), LerpPosInterval(self.moleHead, 0.05, Point3(0.31, 0.0, 0.0)), LerpPosInterval(self.moleHead, 0.05, Point3(0.0, -0.32, 0.0)), LerpPosInterval(self.moleHead, 0.05, Point3(0.0, 0.0, 0.48)), LerpPosInterval(self.moleHead, 0.05, Point3(-0.28, 0.0, 0.0)), LerpPosInterval(self.moleHead, 0.05, Point3(0.0, 0.29, 0.0)))), LerpPosInterval(self.mole, 0.5, Point3(0, 0, -2.5)), Func(self.setHillType, MoleFieldBase.HILL_BOMB)) self.popIval.start() else: self.moleHead.setH(0) if type == MoleFieldBase.HILL_WHACKED: self.moleHead = loader.loadModel('phase_12/models/bossbotHQ/mole_hit') self.mole.setBillboardAxis(0) self.moleColNodePath.setScale(0.0) if self.popIval: self.popIval.finish() if self.downIval: self.downIval.finish() self.mole.setPos(0.0, 0.0, 0.0) self.popIval = Sequence(Parallel(Sequence(LerpPosInterval(self.moleHead, 0.05, Point3(0.18, 0.0, 0.0)), LerpPosInterval(self.moleHead, 0.05, Point3(0.0, -0.13, 0.0)), LerpPosInterval(self.moleHead, 0.05, Point3(0.0, 0.0, 0.18)), LerpPosInterval(self.moleHead, 0.05, Point3(-0.15, 0.0, 0.0)), LerpPosInterval(self.moleHead, 0.05, Point3(0.0, 0.18, 0.0)), LerpPosInterval(self.moleHead, 0.05, Point3(0.11, 0.0, 0.0)), LerpPosInterval(self.moleHead, 0.05, Point3(0.0, -0.12, 0.0)), LerpPosInterval(self.moleHead, 0.05, Point3(0.0, 0.0, 0.18)), LerpPosInterval(self.moleHead, 0.05, Point3(-0.18, 0.0, 0.0)), LerpPosInterval(self.moleHead, 0.05, Point3(0.0, 0.13, 0.0)), LerpPosInterval(self.moleHead, 0.05, Point3(0.18, 0.0, 0.0)), LerpPosInterval(self.moleHead, 0.05, Point3(0.0, -0.15, 0.0)), LerpPosInterval(self.moleHead, 0.05, Point3(0.0, 0.0, 0.18)), LerpPosInterval(self.moleHead, 0.05, Point3(-0.16, 0.0, 0.0)), LerpPosInterval(self.moleHead, 0.05, Point3(0.0, 0.18, 0.0)), LerpPosInterval(self.moleHead, 0.05, Point3(0.11, 0.0, 0.0)), LerpPosInterval(self.moleHead, 0.05, Point3(0.0, -0.18, 0.0)), LerpPosInterval(self.moleHead, 0.05, Point3(0.0, 0.0, 0.17)), LerpPosInterval(self.moleHead, 0.05, Point3(-0.18, 0.0, 0.0)), LerpPosInterval(self.moleHead, 0.05, Point3(0.0, 0.0, 0.0))), Sequence(LerpScaleInterval(self.moleHead, 0.5, 3.5), LerpScaleInterval(self.moleHead, 0.5, 1.0))), LerpPosInterval(self.mole, 0.5, Point3(0, 0, -2.5)), Func(self.setHillType, MoleFieldBase.HILL_MOLE)) self.popIval.start() self.moleHead.reparentTo(self.mole)
def enter(self, requestStatus): self.fsm.enterInitialState() messenger.send('enterPlayground') self.accept('doorDoneEvent', self.handleDoorDoneEvent) self.accept('DistributedDoor_doorTrigger', self.handleDoorTrigger) base.playMusic(self.loader.music, looping=1, volume=0.8) self.loader.geom.reparentTo(render) for i in self.loader.nodeList: self.loader.enterAnimatedProps(i) self._telemLimiter = TLGatherAllAvs('Playground', RotationLimitToH) def __lightDecorationOn__(): geom = base.cr.playGame.hood.loader.geom self.loader.hood.eventLights = geom.findAllMatches('**/*light*') self.loader.hood.eventLights += geom.findAllMatches('**/*lamp*') self.loader.hood.eventLights += geom.findAllMatches('**/prop_snow_tree*') self.loader.hood.eventLights += geom.findAllMatches('**/prop_tree*') self.loader.hood.eventLights += geom.findAllMatches('**/*christmas*') for light in self.loader.hood.eventLights: light.setColorScaleOff(0) if base.cr.newsManager.isHolidayRunning(ToontownGlobals.HALLOWEEN) and self.loader.hood.spookySkyFile: lightsOff = Sequence(LerpColorScaleInterval(base.cr.playGame.hood.loader.geom, 0.1, Vec4(0.55, 0.55, 0.65, 1)), Func(self.loader.hood.startSpookySky), Func(__lightDecorationOn__)) lightsOff.start() elif base.cr.newsManager.isHolidayRunning(ToontownGlobals.CHRISTMAS) and self.loader.hood.snowySkyFile: lightsOff = Sequence(LerpColorScaleInterval(base.cr.playGame.hood.loader.geom, 0.1, Vec4(0.7, 0.7, 0.8, 1)), Func(self.loader.hood.startSnowySky), Func(__lightDecorationOn__)) lightsOff.start() self.snowEvent = BattleParticles.loadParticleFile('snowdisk.ptf') self.snowEvent.setPos(0, 30, 10) self.snowEventRender = base.cr.playGame.hood.loader.geom.attachNewNode('snowRender') self.snowEventRender.setDepthWrite(2) self.snowEventRender.setBin('fixed', 1) self.snowEventFade = None self.snowEvent.start(camera, self.snowEventRender) else: self.loader.hood.startSky() lightsOn = LerpColorScaleInterval(base.cr.playGame.hood.loader.geom, 0.1, Vec4(1, 1, 1, 1)) lightsOn.start() NametagGlobals.setMasterArrowsOn(1) self.zoneId = requestStatus['zoneId'] self.tunnelOriginList = base.cr.hoodMgr.addLinkTunnelHooks(self, self.loader.nodeList) how = requestStatus['how'] if how == 'teleportIn': how = 'deathAck' self.fsm.request(how, [requestStatus])
def destroy(self): if self.isDestroyed: return self.isDestroyed = True if hasattr(self.suit, 'prop') and self.suit.prop: self.suit.prop.stash() if self.propTrack: self.propTrack.finish() self.propTrack = None if self.suitSound: self.suitSound.stop() del self.suitSound if self.animTrack: self.animTrack.finish() self.animTrack = None if self.shotTrack != None: self.shotTrack.finish() self.shotTrack = None if self.deathTrack != None: self.deathTrack.finish() self.deathTrack = None if self.deathSuit: self.deathSuit.detachNode() self.suit.cleanupLoseActor() self.deathSuit = None if self.moveIval: self.moveIval.pause() del self.moveIval if self.suit: self.suit.delete() self.suit = None BattleParticles.unloadParticles() self.ignore(self.game.uniqueName('enter' + self.suitName)) self.game = None self.enemyMgr = None return
def __init__(self, parent = hidden, wantParticles = 1): NodePath.__init__(self, parent) self.assign(parent.attachNewNode('splash')) self.splashdown = globalPropPool.getProp('splashdown') self.splashdown.reparentTo(self) self.splashdown.setZ(-0.01) self.splashdown.setScale(0.4) ta = TransparencyAttrib.make(TransparencyAttrib.MBinary) self.splashdown.node().setAttrib(ta, 1) self.splashdown.setBin('fixed', 130, 1) self.ripples = Ripples(self) self.ripples.setBin('fixed', 120, 1) self.wantParticles = 1 if self.wantParticles: self.pSystem = BattleParticles.createParticleEffect('SplashLines') self.pSystem.setScale(0.4) self.pSystem.setBin('fixed', 150, 1) self.particles = self.pSystem.particlesDict.get('particles-1') self.track = None self.trackId = Splash.splashCount Splash.splashCount += 1 self.setBin('fixed', 100, 1) self.hide() return
def __init__(self, model, pos, serialNum, gameId, penalty = False): self.serialNum = serialNum self.penalty = penalty center = model.getBounds().getCenter() center = Point3(0, 0, 0) self.nodePath = model.copyTo(render) self.nodePath.setPos(pos[0] - center[0], pos[1] - center[1], pos[2] - center[2]) self.nodePath.setZ(0) self.notify.debug('newPos = %s' % self.nodePath.getPos()) if self.penalty: self.sphereName = 'penaltySphere-%s-%s' % (gameId, self.serialNum) else: self.sphereName = 'treasureSphere-%s-%s' % (gameId, self.serialNum) self.collSphere = CollisionSphere(center[0], center[1], center[2], self.RADIUS) self.collSphere.setTangible(0) self.collNode = CollisionNode(self.sphereName) self.collNode.setIntoCollideMask(ToontownGlobals.PieBitmask) self.collNode.addSolid(self.collSphere) self.collNodePath = render.attachNewNode(self.collNode) self.collNodePath.setPos(pos[0] - center[0], pos[1] - center[1], pos[2] - center[2]) self.collNodePath.hide() self.track = None if self.penalty: self.tip = self.nodePath.find('**/fusetip') sparks = BattleParticles.createParticleEffect(file='icetnt') self.sparksEffect = sparks sparks.start(self.tip) self.penaltyGrabSound = loader.loadSfx('phase_4/audio/sfx/MG_cannon_fire_alt.ogg') self.penaltyGrabSound.setVolume(0.75) kaboomAttachPoint = self.nodePath.attachNewNode('kaboomAttach') kaboomAttachPoint.setZ(3) self.kaboom = loader.loadModel('phase_4/models/minigames/ice_game_kaboom') self.kaboom.reparentTo(kaboomAttachPoint) self.kaboom.setScale(2.0) self.kaboom.setBillboardPointEye() return
def doDeathTrack(self): def removeDeathSuit(suit, deathSuit): if not deathSuit.isEmpty(): deathSuit.detachNode() suit.cleanupLoseActor() if self.suitSound: self.suitSound.stop() self.deathSuit = self.suit.getLoseActor() self.deathSuit.reparentTo(self.enemyMgr.enemiesNP) self.deathSuit.setPos(render, self.suit.getPos(render)) self.deathSuit.setHpr(render, self.suit.getHpr(render)) self.suit.hide() self.collNodePath.reparentTo(self.deathSuit) treasureSpawnPoint = Point3(self.suit.getX(), self.suit.getY(), self.suit.getZ() + self.suit.height / 2.0) gearPoint = Point3(0, 0, self.suit.height / 2.0 + 2.0) spinningSound = base.loadSfx('phase_3.5/audio/sfx/Cog_Death.ogg') deathSound = base.loadSfx('phase_3.5/audio/sfx/ENC_cogfall_apart.ogg') smallGears = BattleParticles.createParticleEffect(file='gearExplosionSmall') singleGear = BattleParticles.createParticleEffect('GearExplosion', numParticles=1) smallGearExplosion = BattleParticles.createParticleEffect('GearExplosion', numParticles=10) bigGearExplosion = BattleParticles.createParticleEffect('BigGearExplosion', numParticles=30) smallGears.setPos(gearPoint) singleGear.setPos(gearPoint) smallGearExplosion.setPos(gearPoint) bigGearExplosion.setPos(gearPoint) smallGears.setDepthWrite(False) singleGear.setDepthWrite(False) smallGearExplosion.setDepthWrite(False) bigGearExplosion.setDepthWrite(False) if self.isMovingLeftRight: self.enterPause() suitTrack = Sequence(Func(self.collNodePath.stash), ActorInterval(self.deathSuit, 'lose', startFrame=80, endFrame=140), Func(removeDeathSuit, self.suit, self.deathSuit, name='remove-death-suit')) explosionTrack = Sequence(Wait(1.5), MovieUtil.createKapowExplosionTrack(self.deathSuit, explosionPoint=gearPoint)) soundTrack = Sequence(SoundInterval(spinningSound, duration=1.6, startTime=0.6, volume=0.8, node=self.deathSuit), SoundInterval(deathSound, volume=0.32, node=self.deathSuit)) gears1Track = Sequence(ParticleInterval(smallGears, self.deathSuit, worldRelative=0, duration=4.3, cleanup=True), name='gears1Track') gears2MTrack = Track((0.0, explosionTrack), (0.7, ParticleInterval(singleGear, self.deathSuit, worldRelative=0, duration=5.7, cleanup=True)), (5.2, ParticleInterval(smallGearExplosion, self.deathSuit, worldRelative=0, duration=1.2, cleanup=True)), (5.4, ParticleInterval(bigGearExplosion, self.deathSuit, worldRelative=0, duration=1.0, cleanup=True)), name='gears2MTrack') elif self.isMovingUpDown: def getFinalPos(): if self.isGoingUp: direction = 1.0 else: direction = -1.0 pos = Point3(self.deathSuit.getX(), self.deathSuit.getY(), self.deathSuit.getZ() + 2.0 * direction) return pos deathMoveIval = LerpPosInterval(self.deathSuit, 1.5, pos=getFinalPos(), name='%s-deathSuitMove' % self.suitName, blendType='easeInOut', fluid=1) suitTrack = Sequence(Func(self.collNodePath.stash), Parallel(ActorInterval(self.deathSuit, 'lose', startFrame=80, endFrame=140), deathMoveIval), Func(removeDeathSuit, self.suit, self.deathSuit, name='remove-death-suit')) explosionTrack = Sequence(Wait(1.5), MovieUtil.createKapowExplosionTrack(self.deathSuit, explosionPoint=gearPoint)) soundTrack = Sequence(SoundInterval(spinningSound, duration=1.6, startTime=0.6, volume=0.8, node=self.deathSuit), SoundInterval(deathSound, volume=0.32, node=self.deathSuit)) gears1Track = Sequence(ParticleInterval(smallGears, self.deathSuit, worldRelative=0, duration=4.3, cleanup=True), name='gears1Track') gears2MTrack = Track((0.0, explosionTrack), (0.0, ParticleInterval(singleGear, self.deathSuit, worldRelative=0, duration=5.7, cleanup=True)), (2.7, ParticleInterval(smallGearExplosion, self.deathSuit, worldRelative=0, duration=1.2, cleanup=True)), (2.9, ParticleInterval(bigGearExplosion, self.deathSuit, worldRelative=0, duration=1.0, cleanup=True)), name='gears2MTrack') def removeParticle(particle): if particle and hasattr(particle, 'renderParent'): particle.cleanup() del particle removeParticles = Parallel(Func(removeParticle, smallGears), Func(removeParticle, singleGear), Func(removeParticle, smallGearExplosion), Func(removeParticle, bigGearExplosion)) self.deathTrack = Sequence(Parallel(suitTrack, gears2MTrack, gears1Track, soundTrack), removeParticles, Func(self.destroy)) self.deathTrack.start()
def doEffect(textId, speakingToon, nearbyToons): menuIndex, _ = decodeId(textId) itemValue = getItemValue(textId) if menuIndex == RESISTANCE_TOONUP: effect = BattleParticles.loadParticleFile('resistanceEffectSparkle.ptf') fadeColor = VBase4(1, 0.5, 1, 1) elif menuIndex == RESISTANCE_MONEY: effect = BattleParticles.loadParticleFile('resistanceEffectBean.ptf') bean = loader.loadModel('phase_4/models/props/jellybean4.bam') bean = bean.find('**/jellybean') colors = { 'particles-1': (1, 1, 0, 1), 'particles-2': (1, 0, 0, 1), 'particles-3': (0, 1, 0, 1), 'particles-4': (0, 0, 1, 1), 'particles-5': (1, 0, 1, 1) } for name, color in colors.items(): node = bean.copyTo(NodePath()) node.setColorScale(*color) p = effect.getParticlesNamed(name) p.renderer.setGeomNode(node.node()) fadeColor = VBase4(0, 1, 0, 1) elif menuIndex == RESISTANCE_RESTOCK: effect = BattleParticles.loadParticleFile('resistanceEffectSprite.ptf') invModel = loader.loadModel('phase_3.5/models/gui/inventory_icons') invModel.setScale(4) invModel.flattenLight() icons = [] if itemValue != -1: for item in xrange(6): iconName = ToontownBattleGlobals.AvPropsNew[itemValue][item] icons.append(invModel.find('**/%s' % iconName)) else: tracks = range(7) random.shuffle(tracks) for i in xrange(6): track = tracks[i] item = random.randint(0, 5) iconName = ToontownBattleGlobals.AvPropsNew[track][item] icons.append(invModel.find('**/%s' % iconName)) iconDict = { 'particles-1': icons[0], 'particles-2': icons[1], 'particles-3': icons[2], 'particles-4': icons[3], 'particles-5': icons[4], 'particles-6': icons[5] } for name, icon in iconDict.items(): p = effect.getParticlesNamed(name) p.renderer.setFromNode(icon) fadeColor = VBase4(0, 0, 1, 1) elif menuIndex == RESISTANCE_MERITS: effect = BattleParticles.loadParticleFile('resistanceEffectSprite.ptf') cogModel = loader.loadModel('phase_3/models/gui/cog_icons') cogModel.setScale(0.75) cogModel.flattenLight() if itemValue != -1: iconDict = {'particles-1': cogModel.find(SuitDNA.suitDeptModelPaths[itemValue])} else: iconDict = {} for i in xrange(len(SuitDNA.suitDepts)): iconDict['particles-%s' % (i + 1)] = cogModel.find(SuitDNA.suitDeptModelPaths[i]) for name, icon in iconDict.items(): p = effect.getParticlesNamed(name) p.renderer.setFromNode(icon) fadeColor = VBase4(0.7, 0.7, 0.7, 1.0) cogModel.removeNode() elif menuIndex == RESISTANCE_TICKETS: effect = BattleParticles.loadParticleFile('resistanceEffectSprite.ptf') model = loader.loadModel('phase_6/models/karting/tickets') model.flattenLight() iconDict = {'particles-1': model} for name, icon in iconDict.items(): p = effect.getParticlesNamed(name) p.renderer.setFromNode(icon) fadeColor = VBase4(1, 1, 0, 1) else: return recolorToons = Parallel() for toonId in nearbyToons: toon = base.cr.doId2do.get(toonId) if toon and (not toon.ghostMode): i = Sequence( toon.doToonColorScale(fadeColor, 0.3), toon.doToonColorScale(toon.defaultColorScale, 0.3), Func(toon.restoreDefaultColorScale) ) recolorToons.append(i) i = Parallel( ParticleInterval(effect, speakingToon, worldRelative=0, duration=3, cleanup=True), Sequence(Wait(0.2), recolorToons), autoFinish=1 ) i.start()
def doDeathTrack(self): def removeDeathSuit(suit, deathSuit): if not deathSuit.isEmpty(): deathSuit.detachNode() suit.cleanupLoseActor() self.deathSuit.reparentTo(self.suit.getParent()) self.deathSuit.setScale(self.suit.getScale()) self.deathSuit.setPos(render, self.suit.getPos(render)) self.deathSuit.setHpr(render, self.suit.getHpr(render)) self.suit.hide() self.collNodePath.reparentTo(self.deathSuit) gearPoint = Point3(0, 0, self.suit.height / 2.0 + 2.0) smallGears = BattleParticles.createParticleEffect( file='gearExplosionSmall') singleGear = BattleParticles.createParticleEffect('GearExplosion', numParticles=1) smallGearExplosion = BattleParticles.createParticleEffect( 'GearExplosion', numParticles=10) bigGearExplosion = BattleParticles.createParticleEffect( 'BigGearExplosion', numParticles=30) smallGears.setPos(gearPoint) singleGear.setPos(gearPoint) smallGearExplosion.setPos(gearPoint) bigGearExplosion.setPos(gearPoint) smallGears.setDepthWrite(False) singleGear.setDepthWrite(False) smallGearExplosion.setDepthWrite(False) bigGearExplosion.setDepthWrite(False) suitTrack = Sequence( Func(self.collNodePath.stash), ActorInterval(self.deathSuit, 'lose', startFrame=80, endFrame=140), Func(removeDeathSuit, self.suit, self.deathSuit, name='remove-death-suit')) explosionTrack = Sequence( Wait(1.5), MovieUtil.createKapowExplosionTrack(self.deathSuit, explosionPoint=gearPoint)) gears1Track = Sequence(ParticleInterval(smallGears, self.deathSuit, worldRelative=0, duration=4.3, cleanup=True), name='gears1Track') gears2MTrack = Track((0.0, explosionTrack), (0.7, ParticleInterval(singleGear, self.deathSuit, worldRelative=0, duration=5.7, cleanup=True)), (5.2, ParticleInterval(smallGearExplosion, self.deathSuit, worldRelative=0, duration=1.2, cleanup=True)), (5.4, ParticleInterval(bigGearExplosion, self.deathSuit, worldRelative=0, duration=1.0, cleanup=True)), name='gears2MTrack') def removeParticle(particle): if particle and hasattr(particle, 'renderParent'): particle.cleanup() del particle removeParticles = Sequence(Func(removeParticle, smallGears), Func(removeParticle, singleGear), Func(removeParticle, smallGearExplosion), Func(removeParticle, bigGearExplosion)) self.deathTrack = Sequence( Parallel(suitTrack, gears2MTrack, gears1Track, self._deathSoundIval), removeParticles) self.deathTrack.start()
def destroy(self): BattleParticles.unloadParticles() self.ignoreAll() self._destroySfx() CogdoMazeSplattable.destroy(self) MazeSuit.destroy(self)
def getAnim(self, anim): ival = None if anim == None: partName = None if self.happy: animName = 'Ff_neutral' else: animName = 'Fb_neutral' if self.raised: ival = ActorInterval(self, animName) else: ival = Parallel(ActorInterval(self, animName, partName=['torso', 'head']), ActorInterval(self, 'Fb_downNeutral', partName='legs')) if not self.forward: ival = Sequence(Func(self.reverseBody), ival, Func(self.forwardBody)) elif anim == 'down2Up': ival = Parallel(SoundInterval(self.upSfx, node=self), self.getAngryActorInterval('Fb_down2Up')) self.raised = 1 elif anim == 'up2Down': ival = Parallel(SoundInterval(self.downSfx, node=self), self.getAngryActorInterval('Fb_down2Up', playRate=-1)) self.raised = 0 elif anim == 'throw': self.doAnimate(None, raised=1, happy=0, queueNeutral=0) ival = Parallel(Sequence(SoundInterval(self.throwSfx, node=self), duration=0), self.getAngryActorInterval('Fb_UpThrow')) elif anim == 'hit': if self.raised: self.raised = 0 ival = self.getAngryActorInterval('Fb_firstHit') else: ival = self.getAngryActorInterval('Fb_downHit') ival = Parallel(SoundInterval(self.reelSfx, node=self), ival) elif anim == 'ltSwing' or anim == 'rtSwing': self.doAnimate(None, raised=0, happy=0, queueNeutral=0) if anim == 'ltSwing': ival = Sequence(Track((0, self.getAngryActorInterval('Fb_downLtSwing')), (0.9, SoundInterval(self.swingSfx, node=self)), (1, Func(self.bubbleL.unstash))), Func(self.bubbleL.stash)) else: ival = Sequence(Track((0, self.getAngryActorInterval('Fb_downRtSwing')), (0.9, SoundInterval(self.swingSfx, node=self)), (1, Func(self.bubbleR.unstash))), Func(self.bubbleR.stash)) elif anim == 'frontAttack': self.doAnimate(None, raised=1, happy=0, queueNeutral=0) pe = BattleParticles.loadParticleFile('bossCogFrontAttack.ptf') ival = Sequence(Func(self.reverseHead), ActorInterval(self, 'Bb2Ff_spin'), Func(self.forwardHead)) if self.forward: ival = Sequence(Func(self.reverseBody), ParallelEndTogether(ival, self.pelvis.hprInterval(0.5, self.pelvisForwardHpr, blendType='easeInOut'))) ival = Sequence(Track((0, ival), (0, Sequence(Func(self.setChatAbsolute, random.choice(TTLocalizer.VPSpinMessages), CFSpeech | CFTimeout), SoundInterval(self.spinSfx, node=self))), (0.9, Parallel(SoundInterval(self.rainGearsSfx, node=self), ParticleInterval(pe, self.frontAttack, worldRelative=0, duration=1.5, cleanup=True), duration=0)), (1.9, Func(self.bubbleF.unstash))), Func(self.bubbleF.stash)) self.forward = 1 self.happy = 0 self.raised = 1 elif anim == 'areaAttack': if self.twoFaced: self.doAnimate(None, raised=1, happy=0, queueNeutral=0) else: self.doAnimate(None, raised=1, happy=1, queueNeutral=1) ival = Parallel(ActorInterval(self, 'Fb_jump'), Sequence(Func(self.setChatAbsolute, random.choice(TTLocalizer.JumpBossTaunts[self.dna.dept]), CFSpeech | CFTimeout), SoundInterval(self.swishSfx, duration=1.1, node=self), SoundInterval(self.boomSfx, duration=1.9)), Sequence(Wait(1.21), Func(self.announceAreaAttack))) if self.twoFaced: self.happy = 0 else: self.happy = 1 self.raised = 1 elif anim == 'Fb_fall': ival = Parallel(ActorInterval(self, 'Fb_fall'), Sequence(SoundInterval(self.reelSfx, node=self), SoundInterval(self.deathSfx))) elif isinstance(anim, types.StringType): ival = ActorInterval(self, anim) else: ival = anim return ival