def createMotionTrails(self, parent, vertex_list = small_vertex_list, motion_color = default_motion_color): self.mtrail = PolyTrail(None, vertex_list, motion_color, 0.29999999999999999) self.mtrail.setUnmodifiedVertexColors(motion_color) self.mtrail.reparentTo(parent) self.mtrail.motion_trail.geom_node_path.setTwoSided(False) self.mtrail.setBlendModeOn() self.mtrail.setTimeWindow(0.29999999999999999) self.mtrail.beginTrail()
class CannonballProjectile(ProjectileAmmo): default_motion_color = [ Vec4(0.10000000000000001, 0.20000000000000001, 0.40000000000000002, 1.0), Vec4(0.10000000000000001, 0.20000000000000001, 0.40000000000000002, 1.0), Vec4(0.10000000000000001, 0.20000000000000001, 0.40000000000000002, 1.0), Vec4(0.10000000000000001, 0.20000000000000001, 0.40000000000000002, 1.0), Vec4(0.10000000000000001, 0.20000000000000001, 0.40000000000000002, 1.0) ] fire_motion_color = [ Vec4(1.0, 0.0, 0.0, 1.0), Vec4(1.0, 0.5, 0.0, 1.0), Vec4(1.0, 0.5, 0.0, 1.0), Vec4(1.0, 0.5, 0.0, 1.0), Vec4(1.0, 0.5, 0.0, 1.0) ] r = 0.80000000000000004 small_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) ] r = 2.0 large_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) ] r = 1.0 chainshot_vertex_list = [ Vec4(-r, 0, 0, 1), Vec4(r, 0, 0, 1), Vec4(-r, 0, 0, 1) ] def __init__(self, cr, ammoSkillId, event, buffs=[]): self.trailEffect = None self.buffs = buffs self.glowA = None self.glowB = None self.glowATrack = None self.glowBTrack = None self.rotateIval = None ProjectileAmmo.__init__(self, cr, ammoSkillId, event, True) self.effectFlag = WeaponGlobals.getSkillEffectFlag(ammoSkillId) self.effectIval = None def removeNode(self): self.cleanupMotionTrails() ProjectileAmmo.removeNode(self) def loadModel(self): self.mtrail = None self.strail = None self.scaleIval = None maxGlowScale = 8 minGlowScale = 7 if not base.config.GetBool('want-special-effects', 1): cannonball = loader.loadModel('models/ammunition/cannonball') elif self.ammoSkillId in (InventoryType.CannonRoundShot, InventoryType.CannonGrapeShot): cannonball = loader.loadModel('models/ammunition/cannonball') if base.options.getSpecialEffectsSetting( ) >= base.options.SpecialEffectsMedium: self.createMotionTrails(self) if base.options.getSpecialEffectsSetting( ) == base.options.SpecialEffectsLow: self.createSimpleMotionTrail(self) elif self.ammoSkillId == InventoryType.CannonChainShot: cannonball = loader.loadModel('models/ammunition/chainShot') ball1 = cannonball.find('**/ball_0') ball1.setBillboardPointEye() ball2 = cannonball.find('**/ball_1') ball2.setBillboardPointEye() if base.options.getSpecialEffectsSetting( ) >= base.options.SpecialEffectsLow: randVal = random.uniform(-180.0, 180.0) randSpeed = random.uniform(-0.10000000000000001, 0.10000000000000001) randDirection = 1 self.effectIval = cannonball.hprInterval( 0.40000000000000002 + randSpeed, Point3(randVal, 360 * randDirection, 0), startHpr=Point3(randVal, 0, 0)) self.effectIval.loop() if base.options.getSpecialEffectsSetting( ) >= base.options.SpecialEffectsMedium: self.createMotionTrails(self, self.chainshot_vertex_list) if base.options.getSpecialEffectsSetting( ) == base.options.SpecialEffectsLow: self.createSimpleMotionTrail(self) elif self.ammoSkillId == InventoryType.CannonFirebrand: cannonball = loader.loadModel('models/ammunition/cannonball') if base.options.getSpecialEffectsSetting( ) >= base.options.SpecialEffectsLow: self.trailEffect = FireTrail.getEffect() if self.trailEffect: self.trailEffect.reparentTo(cannonball) self.trailEffect.startLoop() elif self.ammoSkillId == InventoryType.CannonFlamingSkull or self.ammoSkillId == InventoryType.CannonFirebrand: maxGlowScale = 28 minGlowScale = 24 cannonball = loader.loadModel('models/ammunition/cannonball') if base.options.getSpecialEffectsSetting( ) >= base.options.SpecialEffectsLow: self.trailEffect = FireTrail.getEffect() if self.trailEffect: self.trailEffect.wantGlow = base.options.getSpecialEffectsSetting( ) >= base.options.SpecialEffectsMedium self.trailEffect.reparentTo(cannonball) self.trailEffect.startLoop() elif self.ammoSkillId == InventoryType.CannonFury: maxGlowScale = 40 minGlowScale = 30 cannonball = self.attachNewNode('cannonball') if base.options.getSpecialEffectsSetting( ) >= base.options.SpecialEffectsLow: self.trailEffect = FuryTrail.getEffect() if self.trailEffect: self.trailEffect.wantGlow = base.options.getSpecialEffectsSetting( ) >= base.options.SpecialEffectsMedium self.trailEffect.wantBlur = base.options.getSpecialEffectsSetting( ) >= base.options.SpecialEffectsHigh self.trailEffect.reparentTo(cannonball) self.trailEffect.startLoop() elif self.ammoSkillId == InventoryType.CannonComet: cannonball = self.attachNewNode('cannonball') cannonball1 = loader.loadModel('models/ammunition/cannonball') self.trailEffect = FireTrail.getEffect() if self.trailEffect: self.trailEffect.wantGlow = base.options.getSpecialEffectsSetting( ) >= base.options.SpecialEffectsMedium self.trailEffect.reparentTo(cannonball1) self.trailEffect.startLoop() self.createMotionTrails(self, self.small_vertex_list, self.fire_motion_color) cannonball2 = loader.loadModel('models/ammunition/cannonball') self.trailEffect = FireTrail.getEffect() if self.trailEffect: self.trailEffect.wantGlow = base.options.getSpecialEffectsSetting( ) >= base.options.SpecialEffectsMedium self.trailEffect.reparentTo(cannonball2) self.trailEffect.startLoop() self.createMotionTrails(self, self.small_vertex_list, self.fire_motion_color) cannonball3 = loader.loadModel('models/ammunition/cannonball') self.trailEffect = FireTrail.getEffect() if self.trailEffect: self.trailEffect.wantGlow = base.options.getSpecialEffectsSetting( ) >= base.options.SpecialEffectsMedium self.trailEffect.reparentTo(cannonball3) self.trailEffect.startLoop() self.createMotionTrails(self, self.small_vertex_list, self.fire_motion_color) cannonball1.reparentTo(cannonball) cannonball1.setPos(0, 4, -4) cannonball2.reparentTo(cannonball) cannonball2.setPos(0, -4, -4) cannonball3.reparentTo(cannonball) cannonball3.setPos(0, 0, 4) self.effectIval = cannonball.hprInterval(1.0, Point3(0, 0, 360), startHpr=Point3(0, 0, 0)) self.effectIval.loop() elif self.ammoSkillId == InventoryType.CannonGrappleHook: cannonball = loader.loadModel('models/ammunition/GrapplingHook') cannonball.flattenStrong() prop = cannonball.getChild(0) if base.options.getSpecialEffectsSetting( ) >= base.options.SpecialEffectsLow: self.effectIval = Sequence( LerpHprInterval(prop, 2.0, Point3(0, 0, 360), startHpr=Point3(0, 0, 0))) self.effectIval.loop() if base.options.getSpecialEffectsSetting( ) >= base.options.SpecialEffectsHigh: self.createMotionTrails(self, self.small_vertex_list) if base.options.getSpecialEffectsSetting( ) <= base.options.SpecialEffectsMedium: self.createSimpleMotionTrail(self) elif self.ammoSkillId == InventoryType.CannonThunderbolt: maxGlowScale = 19 minGlowScale = 15 cannonball = self.attachNewNode('cannonball') if base.options.getSpecialEffectsSetting( ) >= base.options.SpecialEffectsLow: self.trailEffect = ThunderBallGlow.getEffect() if self.trailEffect: self.trailEffect.reparentTo(cannonball) self.trailEffect.setScale(0.5) self.trailEffect.startLoop() if base.options.getSpecialEffectsSetting( ) >= base.options.SpecialEffectsHigh: self.glowA = loader.loadModel('models/effects/flareRing') self.glowA.node().setAttrib( ColorBlendAttrib.make(ColorBlendAttrib.MAdd)) self.glowA.setDepthWrite(0) self.glowA.setFogOff() self.glowA.setLightOff() self.glowA.setBin('fixed', 120) self.glowA.setColorScale(0.5, 0.80000000000000004, 1, 0.5) self.glowA.reparentTo(cannonball) self.glowA.setBillboardPointEye() scaleUp = self.glowA.scaleInterval(0.10000000000000001, 4.5, startScale=3.5, blendType='easeInOut') scaleDown = self.glowA.scaleInterval(0.10000000000000001, 3.5, startScale=4.5, blendType='easeInOut') self.glowATrack = Sequence(scaleUp, scaleDown) self.glowATrack.loop() if base.options.getSpecialEffectsSetting( ) >= base.options.SpecialEffectsMedium: self.createMotionTrails(self) if base.options.getSpecialEffectsSetting( ) == base.options.SpecialEffectsLow: self.createSimpleMotionTrail(self) elif self.ammoSkillId == InventoryType.CannonExplosive: cannonball = loader.loadModel('models/ammunition/cannonball') else: cannonball = loader.loadModel('models/ammunition/cannonball') if self.ammoSkillId == InventoryType.CannonBullet: cannonball.setColor(0.84999999999999998, 0.84999999999999998, 0.66000000000000003, 1.0) elif self.ammoSkillId == InventoryType.CannonGasCloud: cannonball.setColor(0.55000000000000004, 1.0, 0.57999999999999996, 1.0) elif self.ammoSkillId == InventoryType.CannonSkull: cannonball.setColor(1.0, 0.55000000000000004, 0.55000000000000004, 1.0) elif self.ammoSkillId == InventoryType.CannonFlameCloud: cannonball.setColor(1.0, 0.10000000000000001, 0.90000000000000002, 1.0) elif self.ammoSkillId == InventoryType.CannonBarShot: cannonball.setColor(0.0, 0.10000000000000001, 0.75, 1.0) elif self.ammoSkillId == InventoryType.CannonKnives: cannonball.setColor(0.97999999999999998, 1.0, 0.34999999999999998, 1.0) elif self.ammoSkillId == InventoryType.CannonMine: cannonball.setColor(0.68999999999999995, 0.52000000000000002, 0.19, 1.0) elif self.ammoSkillId == InventoryType.CannonBarnacles: cannonball.setColor(0.050000000000000003, 0.65000000000000002, 0.029999999999999999, 1.0) if self.ammoSkillId == InventoryType.CannonGrapeShot: cannonball.setScale(0.80000000000000004) else: cannonball.setScale(2.0) if WeaponConstants.C_OPENFIRE in self.buffs: if base.options.getSpecialEffectsSetting( ) >= base.options.SpecialEffectsLow: self.glowB = loader.loadModel('models/effects/lanternGlow') self.glowB.node().setAttrib( ColorBlendAttrib.make(ColorBlendAttrib.MAdd)) self.glowB.setDepthWrite(0) self.glowB.setFogOff() self.glowB.setLightOff() self.glowB.setBin('fixed', 120) self.glowB.setColorScale(1, 0.80000000000000004, 0.5, 0.90000000000000002) self.glowB.reparentTo(cannonball) self.glowB.setBillboardPointEye() scaleUp = self.glowB.scaleInterval(0.10000000000000001, maxGlowScale, startScale=minGlowScale, blendType='easeInOut') scaleDown = self.glowB.scaleInterval(0.10000000000000001, minGlowScale, startScale=maxGlowScale, blendType='easeInOut') self.glowBTrack = Sequence(scaleUp, scaleDown) self.glowBTrack.loop() return cannonball def destroy(self): self.cleanupMotionTrails() if self.trailEffect: self.trailEffect.stopLoop() self.trailEffect = None if self.effectIval: self.effectIval.finish() self.effectIval = None if self.glowATrack: self.glowATrack.finish() self.glowATrack = None if self.glowBTrack: self.glowBTrack.finish() self.glowBTrack = None if self.rotateIval: self.rotateIval.finish() self.rotateIval = None ProjectileAmmo.destroy(self) def createMotionTrails(self, parent, vertex_list=small_vertex_list, motion_color=default_motion_color): self.mtrail = PolyTrail(None, vertex_list, motion_color, 0.29999999999999999) self.mtrail.setUnmodifiedVertexColors(motion_color) self.mtrail.reparentTo(parent) self.mtrail.motion_trail.geom_node_path.setTwoSided(False) self.mtrail.setBlendModeOn() self.mtrail.setTimeWindow(0.29999999999999999) self.mtrail.beginTrail() def createSimpleMotionTrail(self, parent): self.strail = loader.loadModel('models/effects/cannonTrail') self.strail.node().setAttrib( ColorBlendAttrib.make(ColorBlendAttrib.MAdd, ColorBlendAttrib.OIncomingAlpha, ColorBlendAttrib.OOne)) self.scaleIval = LerpScaleInterval( self.strail, 0.25, Vec3(3.2999999999999998, 16, 3.2999999999999998), startScale=Vec3(3.2999999999999998, 3, 3.2999999999999998)) self.scaleIval.start() self.strail.setColorScale(0.20000000000000001, 0.29999999999999999, 0.5, 1.0) self.strail.reparentTo(parent) def cleanupMotionTrails(self): if self.mtrail: self.mtrail.destroy() self.mtrail = None if self.strail: self.strail.detachNode() self.strail = None if self.scaleIval: self.scaleIval.pause() self.scaleIval = None
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 theSoundInterval = SoundInterval(random.choice(self.trailSfx), node=self.effectsNode, cutOff=3000) self.trailEffectsIval.append( Func(self.setupSoundVolume, theSoundInterval)) self.trailEffectsIval.append(theSoundInterval) if base.options.getSpecialEffectsSetting( ) == base.options.SpecialEffectsLow: 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(30.0) self.trailEffects.append(glowEffect) self.trailEffectsIval.append(Func(glowEffect.startLoop)) elif self.trailTypeId == FireworkTrailType.Polygonal: r = 2.5 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(50.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.options.getSpecialEffectsSetting( ) >= base.options.SpecialEffectsMedium: 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 theSoundInterval = SoundInterval(random.choice(self.trailSfx), node = self.effectsNode, cutOff = 3000) self.trailEffectsIval.append(Func(self.setupSoundVolume, theSoundInterval)) self.trailEffectsIval.append(theSoundInterval) if base.options.getSpecialEffectsSetting() == base.options.SpecialEffectsLow: 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(30.0) self.trailEffects.append(glowEffect) self.trailEffectsIval.append(Func(glowEffect.startLoop)) elif self.trailTypeId == FireworkTrailType.Polygonal: r = 2.5 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(50.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.options.getSpecialEffectsSetting() >= base.options.SpecialEffectsMedium: 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
class CannonballProjectile(ProjectileAmmo): default_motion_color = [ Vec4(0.10000000000000001, 0.20000000000000001, 0.40000000000000002, 1.0), Vec4(0.10000000000000001, 0.20000000000000001, 0.40000000000000002, 1.0), Vec4(0.10000000000000001, 0.20000000000000001, 0.40000000000000002, 1.0), Vec4(0.10000000000000001, 0.20000000000000001, 0.40000000000000002, 1.0), Vec4(0.10000000000000001, 0.20000000000000001, 0.40000000000000002, 1.0)] fire_motion_color = [ Vec4(1.0, 0.0, 0.0, 1.0), Vec4(1.0, 0.5, 0.0, 1.0), Vec4(1.0, 0.5, 0.0, 1.0), Vec4(1.0, 0.5, 0.0, 1.0), Vec4(1.0, 0.5, 0.0, 1.0)] r = 0.80000000000000004 small_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)] r = 2.0 large_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)] r = 1.0 chainshot_vertex_list = [ Vec4(-r, 0, 0, 1), Vec4(r, 0, 0, 1), Vec4(-r, 0, 0, 1)] def __init__(self, cr, ammoSkillId, event, buffs = []): self.trailEffect = None self.buffs = buffs self.glowA = None self.glowB = None self.glowATrack = None self.glowBTrack = None self.rotateIval = None ProjectileAmmo.__init__(self, cr, ammoSkillId, event, True) self.effectFlag = WeaponGlobals.getSkillEffectFlag(ammoSkillId) self.effectIval = None def removeNode(self): self.cleanupMotionTrails() ProjectileAmmo.removeNode(self) def loadModel(self): self.mtrail = None self.strail = None self.scaleIval = None maxGlowScale = 8 minGlowScale = 7 if not base.config.GetBool('want-special-effects', 1): cannonball = loader.loadModel('models/ammunition/cannonball') elif self.ammoSkillId in (InventoryType.CannonRoundShot, InventoryType.CannonGrapeShot): cannonball = loader.loadModel('models/ammunition/cannonball') if base.options.getSpecialEffectsSetting() >= base.options.SpecialEffectsMedium: self.createMotionTrails(self) if base.options.getSpecialEffectsSetting() == base.options.SpecialEffectsLow: self.createSimpleMotionTrail(self) elif self.ammoSkillId == InventoryType.CannonChainShot: cannonball = loader.loadModel('models/ammunition/chainShot') ball1 = cannonball.find('**/ball_0') ball1.setBillboardPointEye() ball2 = cannonball.find('**/ball_1') ball2.setBillboardPointEye() if base.options.getSpecialEffectsSetting() >= base.options.SpecialEffectsLow: randVal = random.uniform(-180.0, 180.0) randSpeed = random.uniform(-0.10000000000000001, 0.10000000000000001) randDirection = 1 self.effectIval = cannonball.hprInterval(0.40000000000000002 + randSpeed, Point3(randVal, 360 * randDirection, 0), startHpr = Point3(randVal, 0, 0)) self.effectIval.loop() if base.options.getSpecialEffectsSetting() >= base.options.SpecialEffectsMedium: self.createMotionTrails(self, self.chainshot_vertex_list) if base.options.getSpecialEffectsSetting() == base.options.SpecialEffectsLow: self.createSimpleMotionTrail(self) elif self.ammoSkillId == InventoryType.CannonFirebrand: cannonball = loader.loadModel('models/ammunition/cannonball') if base.options.getSpecialEffectsSetting() >= base.options.SpecialEffectsLow: self.trailEffect = FireTrail.getEffect() if self.trailEffect: self.trailEffect.reparentTo(cannonball) self.trailEffect.startLoop() elif self.ammoSkillId == InventoryType.CannonFlamingSkull or self.ammoSkillId == InventoryType.CannonFirebrand: maxGlowScale = 28 minGlowScale = 24 cannonball = loader.loadModel('models/ammunition/cannonball') if base.options.getSpecialEffectsSetting() >= base.options.SpecialEffectsLow: self.trailEffect = FireTrail.getEffect() if self.trailEffect: self.trailEffect.wantGlow = base.options.getSpecialEffectsSetting() >= base.options.SpecialEffectsMedium self.trailEffect.reparentTo(cannonball) self.trailEffect.startLoop() elif self.ammoSkillId == InventoryType.CannonFury: maxGlowScale = 40 minGlowScale = 30 cannonball = self.attachNewNode('cannonball') if base.options.getSpecialEffectsSetting() >= base.options.SpecialEffectsLow: self.trailEffect = FuryTrail.getEffect() if self.trailEffect: self.trailEffect.wantGlow = base.options.getSpecialEffectsSetting() >= base.options.SpecialEffectsMedium self.trailEffect.wantBlur = base.options.getSpecialEffectsSetting() >= base.options.SpecialEffectsHigh self.trailEffect.reparentTo(cannonball) self.trailEffect.startLoop() elif self.ammoSkillId == InventoryType.CannonComet: cannonball = self.attachNewNode('cannonball') cannonball1 = loader.loadModel('models/ammunition/cannonball') self.trailEffect = FireTrail.getEffect() if self.trailEffect: self.trailEffect.wantGlow = base.options.getSpecialEffectsSetting() >= base.options.SpecialEffectsMedium self.trailEffect.reparentTo(cannonball1) self.trailEffect.startLoop() self.createMotionTrails(self, self.small_vertex_list, self.fire_motion_color) cannonball2 = loader.loadModel('models/ammunition/cannonball') self.trailEffect = FireTrail.getEffect() if self.trailEffect: self.trailEffect.wantGlow = base.options.getSpecialEffectsSetting() >= base.options.SpecialEffectsMedium self.trailEffect.reparentTo(cannonball2) self.trailEffect.startLoop() self.createMotionTrails(self, self.small_vertex_list, self.fire_motion_color) cannonball3 = loader.loadModel('models/ammunition/cannonball') self.trailEffect = FireTrail.getEffect() if self.trailEffect: self.trailEffect.wantGlow = base.options.getSpecialEffectsSetting() >= base.options.SpecialEffectsMedium self.trailEffect.reparentTo(cannonball3) self.trailEffect.startLoop() self.createMotionTrails(self, self.small_vertex_list, self.fire_motion_color) cannonball1.reparentTo(cannonball) cannonball1.setPos(0, 4, -4) cannonball2.reparentTo(cannonball) cannonball2.setPos(0, -4, -4) cannonball3.reparentTo(cannonball) cannonball3.setPos(0, 0, 4) self.effectIval = cannonball.hprInterval(1.0, Point3(0, 0, 360), startHpr = Point3(0, 0, 0)) self.effectIval.loop() elif self.ammoSkillId == InventoryType.CannonGrappleHook: cannonball = loader.loadModel('models/ammunition/GrapplingHook') cannonball.flattenStrong() prop = cannonball.getChild(0) if base.options.getSpecialEffectsSetting() >= base.options.SpecialEffectsLow: self.effectIval = Sequence(LerpHprInterval(prop, 2.0, Point3(0, 0, 360), startHpr = Point3(0, 0, 0))) self.effectIval.loop() if base.options.getSpecialEffectsSetting() >= base.options.SpecialEffectsHigh: self.createMotionTrails(self, self.small_vertex_list) if base.options.getSpecialEffectsSetting() <= base.options.SpecialEffectsMedium: self.createSimpleMotionTrail(self) elif self.ammoSkillId == InventoryType.CannonThunderbolt: maxGlowScale = 19 minGlowScale = 15 cannonball = self.attachNewNode('cannonball') if base.options.getSpecialEffectsSetting() >= base.options.SpecialEffectsLow: self.trailEffect = ThunderBallGlow.getEffect() if self.trailEffect: self.trailEffect.reparentTo(cannonball) self.trailEffect.setScale(0.5) self.trailEffect.startLoop() if base.options.getSpecialEffectsSetting() >= base.options.SpecialEffectsHigh: self.glowA = loader.loadModel('models/effects/flareRing') self.glowA.node().setAttrib(ColorBlendAttrib.make(ColorBlendAttrib.MAdd)) self.glowA.setDepthWrite(0) self.glowA.setFogOff() self.glowA.setLightOff() self.glowA.setBin('fixed', 120) self.glowA.setColorScale(0.5, 0.80000000000000004, 1, 0.5) self.glowA.reparentTo(cannonball) self.glowA.setBillboardPointEye() scaleUp = self.glowA.scaleInterval(0.10000000000000001, 4.5, startScale = 3.5, blendType = 'easeInOut') scaleDown = self.glowA.scaleInterval(0.10000000000000001, 3.5, startScale = 4.5, blendType = 'easeInOut') self.glowATrack = Sequence(scaleUp, scaleDown) self.glowATrack.loop() if base.options.getSpecialEffectsSetting() >= base.options.SpecialEffectsMedium: self.createMotionTrails(self) if base.options.getSpecialEffectsSetting() == base.options.SpecialEffectsLow: self.createSimpleMotionTrail(self) elif self.ammoSkillId == InventoryType.CannonExplosive: cannonball = loader.loadModel('models/ammunition/cannonball') else: cannonball = loader.loadModel('models/ammunition/cannonball') if self.ammoSkillId == InventoryType.CannonBullet: cannonball.setColor(0.84999999999999998, 0.84999999999999998, 0.66000000000000003, 1.0) elif self.ammoSkillId == InventoryType.CannonGasCloud: cannonball.setColor(0.55000000000000004, 1.0, 0.57999999999999996, 1.0) elif self.ammoSkillId == InventoryType.CannonSkull: cannonball.setColor(1.0, 0.55000000000000004, 0.55000000000000004, 1.0) elif self.ammoSkillId == InventoryType.CannonFlameCloud: cannonball.setColor(1.0, 0.10000000000000001, 0.90000000000000002, 1.0) elif self.ammoSkillId == InventoryType.CannonBarShot: cannonball.setColor(0.0, 0.10000000000000001, 0.75, 1.0) elif self.ammoSkillId == InventoryType.CannonKnives: cannonball.setColor(0.97999999999999998, 1.0, 0.34999999999999998, 1.0) elif self.ammoSkillId == InventoryType.CannonMine: cannonball.setColor(0.68999999999999995, 0.52000000000000002, 0.19, 1.0) elif self.ammoSkillId == InventoryType.CannonBarnacles: cannonball.setColor(0.050000000000000003, 0.65000000000000002, 0.029999999999999999, 1.0) if self.ammoSkillId == InventoryType.CannonGrapeShot: cannonball.setScale(0.80000000000000004) else: cannonball.setScale(2.0) if WeaponConstants.C_OPENFIRE in self.buffs: if base.options.getSpecialEffectsSetting() >= base.options.SpecialEffectsLow: self.glowB = loader.loadModel('models/effects/lanternGlow') self.glowB.node().setAttrib(ColorBlendAttrib.make(ColorBlendAttrib.MAdd)) self.glowB.setDepthWrite(0) self.glowB.setFogOff() self.glowB.setLightOff() self.glowB.setBin('fixed', 120) self.glowB.setColorScale(1, 0.80000000000000004, 0.5, 0.90000000000000002) self.glowB.reparentTo(cannonball) self.glowB.setBillboardPointEye() scaleUp = self.glowB.scaleInterval(0.10000000000000001, maxGlowScale, startScale = minGlowScale, blendType = 'easeInOut') scaleDown = self.glowB.scaleInterval(0.10000000000000001, minGlowScale, startScale = maxGlowScale, blendType = 'easeInOut') self.glowBTrack = Sequence(scaleUp, scaleDown) self.glowBTrack.loop() return cannonball def destroy(self): self.cleanupMotionTrails() if self.trailEffect: self.trailEffect.stopLoop() self.trailEffect = None if self.effectIval: self.effectIval.finish() self.effectIval = None if self.glowATrack: self.glowATrack.finish() self.glowATrack = None if self.glowBTrack: self.glowBTrack.finish() self.glowBTrack = None if self.rotateIval: self.rotateIval.finish() self.rotateIval = None ProjectileAmmo.destroy(self) def createMotionTrails(self, parent, vertex_list = small_vertex_list, motion_color = default_motion_color): self.mtrail = PolyTrail(None, vertex_list, motion_color, 0.29999999999999999) self.mtrail.setUnmodifiedVertexColors(motion_color) self.mtrail.reparentTo(parent) self.mtrail.motion_trail.geom_node_path.setTwoSided(False) self.mtrail.setBlendModeOn() self.mtrail.setTimeWindow(0.29999999999999999) self.mtrail.beginTrail() def createSimpleMotionTrail(self, parent): self.strail = loader.loadModel('models/effects/cannonTrail') self.strail.node().setAttrib(ColorBlendAttrib.make(ColorBlendAttrib.MAdd, ColorBlendAttrib.OIncomingAlpha, ColorBlendAttrib.OOne)) self.scaleIval = LerpScaleInterval(self.strail, 0.25, Vec3(3.2999999999999998, 16, 3.2999999999999998), startScale = Vec3(3.2999999999999998, 3, 3.2999999999999998)) self.scaleIval.start() self.strail.setColorScale(0.20000000000000001, 0.29999999999999999, 0.5, 1.0) self.strail.reparentTo(parent) def cleanupMotionTrails(self): if self.mtrail: self.mtrail.destroy() self.mtrail = None if self.strail: self.strail.detachNode() self.strail = None if self.scaleIval: self.scaleIval.pause() self.scaleIval = None