def createTrack(self):
     self.trails = []
     self.trailEffects = []
     self.trailIval = Parallel()
     vels = None
     if self.numTrails >= 3 and self.numTrails <= 5:
         vels = self.trailsVel[self.numTrails - 3]
     
     for i in range(self.numTrails):
         self.trails.append(self.attachNewNode('trail'))
         vel = Vec3(0, 0, 0)
         if vels:
             vel = Vec3(vels[i][0] + random.randint(-20, 20), vels[i][1] + random.randint(-20, 20), vels[i][2] + random.randint(0, 50))
         else:
             vel = Vec3(random.randint(-200, 200), random.randint(-200, 200), random.randint(80, 150))
         vel *= self.effectScale
         dur = 2.0 + random.random() / 4.0
         self.trailIval.append(ProjectileInterval(self.trails[i], startVel = vel, duration = dur, gravityMult = 0.59999999999999998))
         self.trailEffects.append(SparksTrailLong.getEffect())
         if self.trailEffects[i]:
             self.trailEffects[i].reparentTo(self.trails[i])
             self.trailEffects[i].setLifespan(2.0)
             self.trailEffects[i].setEffectColor(self.effectColor)
             self.trailEffects[i].setEffectScale(self.effectScale)
             self.trailIval.append(Sequence(Func(self.trailEffects[i].startLoop), Wait(dur), Func(self.trailEffects[i].stopLoop)))
             continue
     
     self.track = Sequence(self.trailIval, Func(self.cleanUpEffect))
    def createTrack(self):
        self.trails = []
        self.trailEffects = []
        self.trailIval = Parallel()
        vels = None
        if self.numTrails >= 3 and self.numTrails <= 5:
            vels = self.trailsVel[self.numTrails - 3]
        for i in xrange(self.numTrails):
            self.trails.append(self.attachNewNode('trail'))
            vel = Vec3(0, 0, 0)
            if vels:
                vel = Vec3(vels[i][0] + random.randint(-20, 20),
                           vels[i][1] + random.randint(-20, 20),
                           vels[i][2] + random.randint(0, 50))
            else:
                vel = Vec3(random.randint(-200, 200),
                           random.randint(-200, 200), random.randint(80, 150))
            vel *= self.effectScale
            dur = 2.0 + random.random() / 4.0
            self.trailIval.append(
                ProjectileInterval(self.trails[i],
                                   startVel=vel,
                                   duration=dur,
                                   gravityMult=0.6))
            self.trailEffects.append(SparksTrailLong.getEffect())
            if self.trailEffects[i]:
                self.trailEffects[i].reparentTo(self.trails[i])
                self.trailEffects[i].setLifespan(2.0)
                self.trailEffects[i].setEffectColor(self.effectColor)
                self.trailEffects[i].setEffectScale(self.effectScale)
                self.trailIval.append(
                    Sequence(Func(self.trailEffects[i].startLoop), Wait(dur),
                             Func(self.trailEffects[i].stopLoop)))

        self.track = Sequence(self.trailIval, Func(self.cleanUpEffect))
 def getTrailEffectsIval(self):
     if not self.trailEffectsIval:
         if self.trailTypeId is None:
             self.effectNode.setPos(self.velocity)
             self.trailEffectsIval = Wait(self.burstDelay)
             return self.trailEffectsIval
         self.trailEffectsIval = Parallel()
         self.trailEffectsIval.append(
             ProjectileInterval(self.effectsNode,
                                startVel=self.velocity,
                                duration=self.burstDelay,
                                gravityMult=self.gravityMult))
         if self.trailTypeId is None:
             return self.trailEffectsIval
         self.trailEffectsIval.append(
             Func(random.choice(self.trailSfx).play))
         if base.config.GetInt('toontown-sfx-setting', 1) == 0:
             if self.trailTypeId != FireworkTrailType.LongGlowSparkle:
                 self.trailTypeId = FireworkTrailType.Default
         if self.trailTypeId == FireworkTrailType.Default:
             glowEffect = Glow.getEffect()
             if glowEffect:
                 glowEffect.reparentTo(self.effectsNode)
                 glowEffect.setColorScale(Vec4(1, 1, 1, 1))
                 glowEffect.setScale(10.0)
                 self.trailEffects.append(glowEffect)
                 self.trailEffectsIval.append(Func(glowEffect.startLoop))
         elif self.trailTypeId == FireworkTrailType.Polygonal:
             r = 0.75
             mColor = Vec4(1, 1, 1, 1)
             vertex_list = [
                 Vec4(r, 0.0, r, 1.0),
                 Vec4(r, 0.0, -r, 1.0),
                 Vec4(-r, 0.0, -r, 1.0),
                 Vec4(-r, 0.0, r, 1.0),
                 Vec4(r, 0.0, r, 1.0)
             ]
             motion_color = [mColor, mColor, mColor, mColor, mColor]
             trailEffect = PolyTrail(None, vertex_list, motion_color, 0.5)
             trailEffect.setUnmodifiedVertexColors(motion_color)
             trailEffect.reparentTo(self.effectsNode)
             trailEffect.motion_trail.geom_node_path.setTwoSided(False)
             trailEffect.setBlendModeOn()
             trailEffect.setLightOff()
             self.trailEffects.append(trailEffect)
             self.trailEffectsIval.append(Func(trailEffect.beginTrail))
         elif self.trailTypeId == FireworkTrailType.Glow:
             trailEffect = GlowTrail.getEffect()
             if trailEffect:
                 trailEffect.reparentTo(self.effectsNode)
                 trailEffect.setEffectScale(self.scale * 0.75)
                 trailEffect.setEffectColor(Vec4(1, 1, 1, 1))
                 trailEffect.setLifespan(0.25)
                 self.trailEffects.append(trailEffect)
                 self.trailEffectsIval.append(Func(trailEffect.startLoop))
         elif self.trailTypeId == FireworkTrailType.Sparkle:
             trailEffect = SparksTrail.getEffect()
             if trailEffect:
                 trailEffect.reparentTo(self.effectsNode)
                 trailEffect.setEffectScale(self.scale)
                 trailEffect.setEffectColor(Vec4(1, 1, 1, 1))
                 self.trailEffects.append(trailEffect)
                 self.trailEffectsIval.append(Func(trailEffect.startLoop))
         elif self.trailTypeId == FireworkTrailType.GlowSparkle:
             glowEffect = Glow.getEffect()
             if glowEffect:
                 glowEffect.reparentTo(self.effectsNode)
                 glowEffect.setColorScale(Vec4(1, 1, 1, 1))
                 glowEffect.setScale(15.0)
                 self.trailEffects.append(glowEffect)
                 self.trailEffectsIval.append(Func(glowEffect.startLoop))
             trailEffect = SparksTrail.getEffect()
             if trailEffect:
                 trailEffect.reparentTo(self.effectsNode)
                 trailEffect.setEffectScale(self.scale)
                 trailEffect.setEffectColor(Vec4(1, 1, 1, 1))
                 self.trailEffects.append(trailEffect)
                 self.trailEffectsIval.append(Func(trailEffect.startLoop))
         elif self.trailTypeId == FireworkTrailType.LongSparkle:
             trailEffect = SparksTrailLong.getEffect()
             if trailEffect:
                 trailEffect.reparentTo(self.effectsNode)
                 trailEffect.setEffectScale(self.scale)
                 trailEffect.setEffectColor(Vec4(1, 1, 1, 1))
                 trailEffect.setLifespan(4.0)
                 self.trailEffects.append(trailEffect)
                 self.trailEffectsIval.append(Func(trailEffect.startLoop))
         elif self.trailTypeId == FireworkTrailType.LongGlowSparkle:
             trailEffect = SparksTrailLong.getEffect()
             if trailEffect:
                 trailEffect.reparentTo(self.effectsNode)
                 trailEffect.setEffectScale(self.scale)
                 trailEffect.setEffectColor(self.secondaryColor)
                 trailEffect.setLifespan(3.5)
                 self.trailEffects.append(trailEffect)
                 self.trailEffectsIval.append(Func(trailEffect.startLoop))
             if base.config.GetInt('toontown-sfx-setting', 1) >= 1:
                 trailEffect = GlowTrail.getEffect()
                 if trailEffect:
                     trailEffect.reparentTo(self.effectsNode)
                     trailEffect.setEffectScale(self.scale)
                     trailEffect.setEffectColor(self.primaryColor)
                     trailEffect.setLifespan(1.0)
                     self.trailEffects.append(trailEffect)
                     self.trailEffectsIval.append(
                         Func(trailEffect.startLoop))
     return self.trailEffectsIval
 def getTrailEffectsIval(self):
     if not self.trailEffectsIval:
         if self.trailTypeId is None:
             self.effectNode.setPos(self.velocity)
             self.trailEffectsIval = Wait(self.burstDelay)
             return self.trailEffectsIval
         self.trailEffectsIval = Parallel()
         self.trailEffectsIval.append(ProjectileInterval(self.effectsNode, startVel=self.velocity, duration=self.burstDelay, gravityMult=self.gravityMult))
         if self.trailTypeId is None:
             return self.trailEffectsIval
         self.trailEffectsIval.append(Func(random.choice(self.trailSfx).play))
         if config.GetInt('toontown-sfx-setting', 1) == 0:
             if self.trailTypeId != FireworkTrailType.LongGlowSparkle:
                 self.trailTypeId = FireworkTrailType.Default
         if self.trailTypeId == FireworkTrailType.Default:
             glowEffect = Glow.getEffect()
             if glowEffect:
                 glowEffect.reparentTo(self.effectsNode)
                 glowEffect.setColorScale(Vec4(1, 1, 1, 1))
                 glowEffect.setScale(10.0)
                 self.trailEffects.append(glowEffect)
                 self.trailEffectsIval.append(Func(glowEffect.startLoop))
         elif self.trailTypeId == FireworkTrailType.Polygonal:
             r = 0.75
             mColor = Vec4(1, 1, 1, 1)
             vertex_list = [Vec4(r, 0.0, r, 1.0), Vec4(r, 0.0, -r, 1.0), Vec4(-r, 0.0, -r, 1.0), Vec4(-r, 0.0, r, 1.0), Vec4(r, 0.0, r, 1.0)]
             motion_color = [mColor, mColor, mColor, mColor, mColor]
         elif self.trailTypeId == FireworkTrailType.Glow:
             trailEffect = GlowTrail.getEffect()
             if trailEffect:
                 trailEffect.reparentTo(self.effectsNode)
                 trailEffect.setEffectScale(self.scale * 0.75)
                 trailEffect.setEffectColor(Vec4(1, 1, 1, 1))
                 trailEffect.setLifespan(0.25)
                 self.trailEffects.append(trailEffect)
                 self.trailEffectsIval.append(Func(trailEffect.startLoop))
         elif self.trailTypeId == FireworkTrailType.Sparkle:
             trailEffect = SparksTrail.getEffect()
             if trailEffect:
                 trailEffect.reparentTo(self.effectsNode)
                 trailEffect.setEffectScale(self.scale)
                 trailEffect.setEffectColor(Vec4(1, 1, 1, 1))
                 self.trailEffects.append(trailEffect)
                 self.trailEffectsIval.append(Func(trailEffect.startLoop))
         elif self.trailTypeId == FireworkTrailType.GlowSparkle:
             glowEffect = Glow.getEffect()
             if glowEffect:
                 glowEffect.reparentTo(self.effectsNode)
                 glowEffect.setColorScale(Vec4(1, 1, 1, 1))
                 glowEffect.setScale(15.0)
                 self.trailEffects.append(glowEffect)
                 self.trailEffectsIval.append(Func(glowEffect.startLoop))
             trailEffect = SparksTrail.getEffect()
             if trailEffect:
                 trailEffect.reparentTo(self.effectsNode)
                 trailEffect.setEffectScale(self.scale)
                 trailEffect.setEffectColor(Vec4(1, 1, 1, 1))
                 self.trailEffects.append(trailEffect)
                 self.trailEffectsIval.append(Func(trailEffect.startLoop))
         elif self.trailTypeId == FireworkTrailType.LongSparkle:
             trailEffect = SparksTrailLong.getEffect()
             if trailEffect:
                 trailEffect.reparentTo(self.effectsNode)
                 trailEffect.setEffectScale(self.scale)
                 trailEffect.setEffectColor(Vec4(1, 1, 1, 1))
                 trailEffect.setLifespan(4.0)
                 self.trailEffects.append(trailEffect)
                 self.trailEffectsIval.append(Func(trailEffect.startLoop))
         elif self.trailTypeId == FireworkTrailType.LongGlowSparkle:
             trailEffect = SparksTrailLong.getEffect()
             if trailEffect:
                 trailEffect.reparentTo(self.effectsNode)
                 trailEffect.setEffectScale(self.scale)
                 trailEffect.setEffectColor(self.secondaryColor)
                 trailEffect.setLifespan(3.5)
                 self.trailEffects.append(trailEffect)
                 self.trailEffectsIval.append(Func(trailEffect.startLoop))
             if config.GetInt('toontown-sfx-setting', 1) >= 1:
                 trailEffect = GlowTrail.getEffect()
                 if trailEffect:
                     trailEffect.reparentTo(self.effectsNode)
                     trailEffect.setEffectScale(self.scale)
                     trailEffect.setEffectColor(self.primaryColor)
                     trailEffect.setLifespan(1.0)
                     self.trailEffects.append(trailEffect)
                     self.trailEffectsIval.append(Func(trailEffect.startLoop))
     return self.trailEffectsIval
Exemple #5
0
    def getTrailEffectsIval(self):
        if not self.trailEffectsIval:

            if self.trailTypeId is None:
                # if trail is not needed, use velocity as explosion's position
                self.effectNode.setPos(self.velocity)
                self.trailEffectsIval = Wait(self.burstDelay)
                return self.trailEffectsIval

            self.trailEffectsIval = Parallel()

            self.trailEffectsIval.append(
                ProjectileInterval(self.effectsNode,
                                   startVel=self.velocity,
                                   duration=self.burstDelay,
                                   gravityMult=self.gravityMult))
            if self.trailTypeId is None:
                return self.trailEffectsIval

            # Add trail Sound Interval
            self.trailEffectsIval.append(
                Func(random.choice(self.trailSfx).play))

            # For low effects settings do a simple trail
            ##            if base.options.getSpecialEffectsSetting() == base.options.SpecialEffectsLow:
            # Config variable toontown-sfx-setting 0 = Low Special Effect Setting
            # Config variable toontown-sfx-setting 1 = Medium Special Effect Setting
            # Config variable toontown-sfx-setting 2 = High Special Effect Setting
            if (base.config.GetInt('toontown-sfx-setting', 1) == 0):
                if self.trailTypeId != FireworkTrailType.LongGlowSparkle:
                    self.trailTypeId = FireworkTrailType.Default

            # Default - basic glow
            # --------------------------------------------------------------------
            if (self.trailTypeId == FireworkTrailType.Default):
                glowEffect = Glow.getEffect()
                if glowEffect:
                    glowEffect.reparentTo(self.effectsNode)
                    glowEffect.setColorScale(Vec4(1, 1, 1, 1))
                    glowEffect.setScale(10.0)
                    self.trailEffects.append(glowEffect)
                    self.trailEffectsIval.append(Func(glowEffect.startLoop))

            # Polygonal
            # --------------------------------------------------------------------
            elif (self.trailTypeId == FireworkTrailType.Polygonal):
                r = 0.75
                mColor = Vec4(1, 1, 1, 1)
                vertex_list = [
                    Vec4(r, 0.0, r, 1.0),
                    Vec4(r, 0.0, -r, 1.0),
                    Vec4(-r, 0.0, -r, 1.0),
                    Vec4(-r, 0.0, r, 1.0),
                    Vec4(r, 0.0, r, 1.0)
                ]
                motion_color = [mColor, mColor, mColor, mColor, mColor]
                trailEffect = PolyTrail(None, vertex_list, motion_color, .5)
                trailEffect.setUnmodifiedVertexColors(motion_color)
                trailEffect.reparentTo(self.effectsNode)
                trailEffect.motion_trail.geom_node_path.setTwoSided(False)
                trailEffect.setBlendModeOn()
                trailEffect.setLightOff()
                self.trailEffects.append(trailEffect)
                self.trailEffectsIval.append(Func(trailEffect.beginTrail))

            # Glow - glowing particle trail
            # --------------------------------------------------------------------
            elif (self.trailTypeId == FireworkTrailType.Glow):
                trailEffect = GlowTrail.getEffect()
                if trailEffect:
                    trailEffect.reparentTo(self.effectsNode)
                    trailEffect.setEffectScale(self.scale * 0.75)
                    trailEffect.setEffectColor(Vec4(1, 1, 1, 1))
                    trailEffect.setLifespan(0.25)
                    self.trailEffects.append(trailEffect)
                    self.trailEffectsIval.append(Func(trailEffect.startLoop))

            # Sparkle - sparkles
            # --------------------------------------------------------------------
            elif (self.trailTypeId == FireworkTrailType.Sparkle):
                trailEffect = SparksTrail.getEffect()
                if trailEffect:
                    trailEffect.reparentTo(self.effectsNode)
                    trailEffect.setEffectScale(self.scale)
                    trailEffect.setEffectColor(Vec4(1, 1, 1, 1))
                    self.trailEffects.append(trailEffect)
                    self.trailEffectsIval.append(Func(trailEffect.startLoop))

            # GlowSparkle - basic glow and sparkles
            # --------------------------------------------------------------------
            elif (self.trailTypeId == FireworkTrailType.GlowSparkle):
                glowEffect = Glow.getEffect()
                if glowEffect:
                    glowEffect.reparentTo(self.effectsNode)
                    glowEffect.setColorScale(Vec4(1, 1, 1, 1))
                    glowEffect.setScale(15.0)
                    self.trailEffects.append(glowEffect)
                    self.trailEffectsIval.append(Func(glowEffect.startLoop))
                trailEffect = SparksTrail.getEffect()
                if trailEffect:
                    trailEffect.reparentTo(self.effectsNode)
                    trailEffect.setEffectScale(self.scale)
                    trailEffect.setEffectColor(Vec4(1, 1, 1, 1))
                    self.trailEffects.append(trailEffect)
                    self.trailEffectsIval.append(Func(trailEffect.startLoop))

            # LongSparkle
            # --------------------------------------------------------------------
            elif (self.trailTypeId == FireworkTrailType.LongSparkle):
                trailEffect = SparksTrailLong.getEffect()
                if trailEffect:
                    trailEffect.reparentTo(self.effectsNode)
                    trailEffect.setEffectScale(self.scale)
                    trailEffect.setEffectColor(Vec4(1, 1, 1, 1))
                    trailEffect.setLifespan(4.0)
                    self.trailEffects.append(trailEffect)
                    self.trailEffectsIval.append(Func(trailEffect.startLoop))

            # LongGlowSparkle
            # --------------------------------------------------------------------
            elif (self.trailTypeId == FireworkTrailType.LongGlowSparkle):
                trailEffect = SparksTrailLong.getEffect()
                if trailEffect:
                    trailEffect.reparentTo(self.effectsNode)
                    trailEffect.setEffectScale(self.scale)
                    trailEffect.setEffectColor(self.secondaryColor)
                    trailEffect.setLifespan(3.5)
                    self.trailEffects.append(trailEffect)
                    self.trailEffectsIval.append(Func(trailEffect.startLoop))
                # Medium setting
                if (base.config.GetInt('toontown-sfx-setting', 1) >= 1):
                    trailEffect = GlowTrail.getEffect()
                    if trailEffect:
                        trailEffect.reparentTo(self.effectsNode)
                        trailEffect.setEffectScale(self.scale)
                        trailEffect.setEffectColor(self.primaryColor)
                        trailEffect.setLifespan(1.0)
                        self.trailEffects.append(trailEffect)
                        self.trailEffectsIval.append(
                            Func(trailEffect.startLoop))

        return self.trailEffectsIval