def __createMagnetMultiTrack(lure, magnet, pos, hpr, scale, isSmallMagnet = 1, npcs = []): toon = lure['toon'] if 'npc' in lure: toon = lure['npc'] battle = lure['battle'] sidestep = lure['sidestep'] targets = lure['target'] tracks = Parallel() tracks.append(Sequence(ActorInterval(toon, 'hold-magnet'), Func(toon.loop, 'neutral'))) hands = toon.getLeftHands() magnet2 = MovieUtil.copyProp(magnet) magnets = [magnet, magnet2] magnetTrack = Sequence(Wait(0.7), Func(MovieUtil.showProps, magnets, hands, pos, hpr, scale), Wait(6.3), Func(MovieUtil.removeProps, magnets)) tracks.append(magnetTrack) for target in targets: suit = target['suit'] trapProp = suit.battleTrapProp if sidestep == 0: hp = target['hp'] kbbonus = target['kbbonus'] died = target['died'] revived = target['revived'] if kbbonus == 1 or hp > 0: suitDelay = 2.6 suitMoveDuration = 0.8 suitTrack = Sequence() opos, ohpr = battle.getActorPosHpr(suit) reachDist = MovieUtil.SUIT_LURE_DISTANCE reachPos = Point3(opos[0], opos[1] - reachDist, opos[2]) numShakes = 3 shakeTotalDuration = 0.8 shakeDuration = shakeTotalDuration / float(numShakes) suitTrack.append(Func(suit.loop, 'neutral')) suitTrack.append(Wait(suitDelay)) suitTrack.append(ActorInterval(suit, 'landing', startTime=2.37, endTime=1.82)) for i in xrange(0, numShakes): suitTrack.append(ActorInterval(suit, 'landing', startTime=1.82, endTime=1.16, duration=shakeDuration)) suitTrack.append(ActorInterval(suit, 'landing', startTime=1.16, endTime=0.7)) suitTrack.append(ActorInterval(suit, 'landing', startTime=0.7, duration=1.3)) suitTrack.append(Func(suit.loop, 'lured')) suitTrack.append(Func(battle.lureSuit, suit)) if hp > 0: suitTrack.append(__createSuitDamageTrack(battle, suit, hp, lure, trapProp)) if revived != 0: suitTrack.append(MovieUtil.createSuitReviveTrack(suit, toon, battle, npcs)) elif died != 0: if trapProp: if not (trapProp.getName() == 'tnt' and suit.maxHP <= 42): suitTrack.append(MovieUtil.createSuitDeathTrack(suit, toon, battle, npcs)) tracks.append(suitTrack) tracks.append(lerpSuit(suit, suitDelay + 0.55 + shakeTotalDuration, suitMoveDuration, reachPos, battle, trapProp)) else: tracks.append(Sequence(Wait(3.7), Func(MovieUtil.indicateMissed, suit))) if isSmallMagnet == 1: tracks.append(getSoundTrack('TL_small_magnet.ogg', delay=0.7, node=toon)) else: tracks.append(getSoundTrack('TL_large_magnet.ogg', delay=0.7, node=toon)) return tracks
def setupPistol(self): self.pistol = globalPropPool.getProp('water-gun') hands = self.toon.getRightHands() self.hand_jointpath0 = hands[0].attachNewNode('handJoint0-path') pistolPos = Point3(0.28, 0.1, 0.08) pistolHpr = VBase3(85.6, -4.44, 94.43) MovieUtil.showProp(self.pistol, self.hand_jointpath0, pistolPos, pistolHpr)
def __doBugle(sound, delay, toon, targets, level): tracks = Parallel() instrMin = Vec3(0.001, 0.001, 0.001) instrMax = Vec3(0.4, 0.4, 0.4) instrMax *= INSTRUMENT_SCALE_MODIFIER instrStretch = Vec3(0.5, 0.5, 0.5) instrStretch *= INSTRUMENT_SCALE_MODIFIER megaphone = globalPropPool.getProp('megaphone') megaphone2 = MovieUtil.copyProp(megaphone) megaphones = [megaphone, megaphone2] instrument = globalPropPool.getProp('bugle') instrument2 = MovieUtil.copyProp(instrument) instruments = [instrument, instrument2] def setInstrumentStats(instrument = instrument, instrument2 = instrument2): instrument.setPos(-1.3, -1.4, 0.1) instrument.setHpr(145, 0, 85) instrument.setScale(instrMin) instrument2.setPos(-1.3, -1.4, 0.1) instrument2.setHpr(145, 0, 85) instrument2.setScale(instrMin) def longshake(models, num): inShake = getScaleBlendIntervals(models, duration=0.2, startScale=instrMax, endScale=instrStretch, blendType='easeInOut') outShake = getScaleBlendIntervals(models, duration=0.2, startScale=instrStretch, endScale=instrMax, blendType='easeInOut') i = 1 seq = Sequence() while i < num: if i % 2 == 0: seq.append(inShake) else: seq.append(outShake) i += 1 seq.start() hands = toon.getRightHands() megaphoneShow = Sequence(Func(MovieUtil.showProps, megaphones, hands), Func(MovieUtil.showProps, instruments, hands), Func(setInstrumentStats)) megaphoneHide = Sequence(Func(MovieUtil.removeProps, megaphones), Func(MovieUtil.removeProps, instruments)) instrumentAppearSfx = globalBattleSoundCache.getSound(appearSoundFiles[level]) grow = getScaleBlendIntervals(instruments, duration=1, startScale=instrMin, endScale=instrMax, blendType='easeInOut') instrumentshrink = getScaleIntervals(instruments, duration=0.1, startScale=instrMax, endScale=instrMin) instrumentAppear = Sequence(grow, Wait(0), Func(longshake, instruments, 5)) hasLuredSuits = __hasLuredSuits(sound) delayTime = delay if hasLuredSuits: delayTime += TIME_TO_WALK_BACK soundEffect = globalBattleSoundCache.getSound(soundFiles[level]) megaphoneTrack = Parallel(Sequence(Wait(delay + 1.7), SoundInterval(soundEffect, node=toon)), Sequence(Wait(delayTime), megaphoneShow, Wait(1.7), instrumentAppear, Wait(1), instrumentshrink, Wait(1.5), megaphoneHide)) tracks.append(megaphoneTrack) toonTrack = __createToonInterval(sound, delay, toon) tracks.append(toonTrack) if soundEffect: delayTime = delay + tSound if hasLuredSuits: delayTime += TIME_TO_WALK_BACK soundTrack = Wait(delayTime) tracks.append(soundTrack) return tracks
def __getSuitTrack(sound, lastSoundThatHit, delay, hitCount, targets, totalDamage, hpbonus, toon, npcs): tracks = Parallel() attacks = 0 uberDelay = 0.0 isUber = 0 if sound['level'] >= ToontownBattleGlobals.UBER_GAG_LEVEL_INDEX: uberDelay = 3.0 isUber = 1 for target in targets: suit = target['suit'] if totalDamage > 0 and sound == lastSoundThatHit: hp = target['hp'] died = target['died'] battle = sound['battle'] kbbonus = target['kbbonus'] suitTrack = Sequence() showDamage = Func(suit.showHpText, -totalDamage, openEnded=0) updateHealthBar = Func(suit.updateHealthBar, totalDamage) if isUber: breakEffect = BattleParticles.createParticleEffect(file='soundBreak') breakEffect.setDepthWrite(0) breakEffect.setDepthTest(0) breakEffect.setTwoSided(1) soundEffect = globalBattleSoundCache.getSound(hitSoundFiles[0]) suitTrack.append(Wait(delay + tSuitReact)) if isUber: delayTime = random.random() suitTrack.append(Wait(delayTime + 2.0)) suitTrack.append(Func(setPosFromOther, breakEffect, suit, Point3(0, 0.0, suit.getHeight() - 1.0))) #suitTrack.append(Parallel(showDamage, updateHealthBar, SoundInterval(soundEffect, node=suit), __getPartTrack(breakEffect, 0.0, 1.0, [breakEffect, suit, 0], softStop=-0.5))) THIS CRASHES PANDA WITH A BOUNDING SPHERE ERROR suitTrack.append(Sequence(showDamage, updateHealthBar, SoundInterval(soundEffect, node=suit))) if died and not suit.getSkelecog(): suitTrack.append(headExplodeTrack(suit, battle)) else: suitTrack.append(showDamage) suitTrack.append(updateHealthBar) if hitCount == 1: suitTrack.append(Parallel(ActorInterval(suit, 'squirt-small-react'), MovieUtil.createSuitStunInterval(suit, 0.5, 1.8))) else: suitTrack.append(ActorInterval(suit, 'squirt-small-react')) if kbbonus == 0: suitTrack.append(__createSuitResetPosTrack(suit, battle)) suitTrack.append(Func(battle.unlureSuit, suit)) bonusTrack = None if hpbonus > 0: bonusTrack = Sequence(Wait(delay + tSuitReact + delay + 0.75 + uberDelay), Func(suit.showHpText, -hpbonus, 1, openEnded=0), Func(suit.updateHealthBar, hpbonus)) suitTrack.append(Func(suit.loop, 'neutral')) if bonusTrack == None: tracks.append(suitTrack) else: tracks.append(Parallel(suitTrack, bonusTrack)) elif totalDamage <= 0: tracks.append(Sequence(Wait(2.9), Func(MovieUtil.indicateMissed, suit, 1.0))) tracks.append(MovieUtil.createSuitTeaseMultiTrack(suit, delay + tSuitReact)) return tracks
def __doElephant(sound, delay, toon, targets, level): tracks = Parallel() instrMin = Vec3(0.001, 0.001, 0.001) instrMax1 = Vec3(0.3, 0.4, 0.2) instrMax1 *= INSTRUMENT_SCALE_MODIFIER instrMax2 = Vec3(0.3, 0.3, 0.3) instrMax2 *= INSTRUMENT_SCALE_MODIFIER instrStretch1 = Vec3(0.3, 0.5, 0.25) instrStretch1 *= INSTRUMENT_SCALE_MODIFIER instrStretch2 = Vec3(0.3, 0.7, 0.3) instrStretch2 *= INSTRUMENT_SCALE_MODIFIER megaphone = globalPropPool.getProp('megaphone') megaphone2 = MovieUtil.copyProp(megaphone) megaphones = [megaphone, megaphone2] instrument = globalPropPool.getProp('elephant') instrument2 = MovieUtil.copyProp(instrument) instruments = [instrument, instrument2] def setInstrumentStats(instrument = instrument, instrument2 = instrument2): instrument.setPos(-.6, -.9, 0.15) instrument.setHpr(145, 0, 85) instrument.setScale(instrMin) instrument2.setPos(-.6, -.9, 0.15) instrument2.setHpr(145, 0, 85) instrument2.setScale(instrMin) hands = toon.getRightHands() megaphoneShow = Sequence(Func(MovieUtil.showProps, megaphones, hands), Func(MovieUtil.showProps, instruments, hands), Func(setInstrumentStats)) megaphoneHide = Sequence(Func(MovieUtil.removeProps, megaphones), Func(MovieUtil.removeProps, instruments)) instrumentAppearSfx = globalBattleSoundCache.getSound(appearSoundFiles[level]) grow1 = getScaleIntervals(instruments, duration=0.3, startScale=instrMin, endScale=instrMax1) grow2 = getScaleIntervals(instruments, duration=0.3, startScale=instrMax1, endScale=instrMax2) instrumentAppear = Parallel(Sequence(grow1, grow2), Sequence(Wait(0.05), SoundInterval(instrumentAppearSfx, node=toon))) stretchInstr1 = getScaleBlendIntervals(instruments, duration=0.1, startScale=instrMax2, endScale=instrStretch1, blendType='easeOut') stretchInstr2 = getScaleBlendIntervals(instruments, duration=0.1, startScale=instrStretch1, endScale=instrStretch2, blendType='easeOut') stretchInstr = Sequence(stretchInstr1, stretchInstr2) backInstr = getScaleBlendIntervals(instruments, duration=0.1, startScale=instrStretch2, endScale=instrMax2, blendType='easeOut') attackTrack = Sequence(stretchInstr, Wait(1), backInstr) hasLuredSuits = __hasLuredSuits(sound) delayTime = delay if hasLuredSuits: delayTime += TIME_TO_WALK_BACK megaphoneTrack = Sequence(Wait(delayTime), megaphoneShow, Wait(1.0), instrumentAppear, Wait(3.0), megaphoneHide) tracks.append(megaphoneTrack) toonTrack = __createToonInterval(sound, delay, toon) tracks.append(toonTrack) soundEffect = globalBattleSoundCache.getSound(soundFiles[level]) instrumentshrink = getScaleIntervals(instruments, duration=0.1, startScale=instrMax2, endScale=instrMin) if soundEffect: delayTime = delay + tSound if hasLuredSuits: delayTime += TIME_TO_WALK_BACK soundTrack = Sequence(Wait(delayTime), Parallel(attackTrack, SoundInterval(soundEffect, node=toon), Sequence(Wait(1.5), instrumentshrink))) tracks.append(soundTrack) return tracks
def __createHypnoGogglesMultiTrack(lure, npcs = []): toon = lure['toon'] if 'npc' in lure: toon = lure['npc'] targets = lure['target'] battle = lure['battle'] sidestep = lure['sidestep'] goggles = globalPropPool.getProp('hypno-goggles') goggles2 = MovieUtil.copyProp(goggles) bothGoggles = [goggles, goggles2] pos = Point3(-1.03, 1.04, -0.3) hpr = Point3(-96.55, 36.14, -170.59) scale = Point3(1.5, 1.5, 1.5) hands = toon.getLeftHands() gogglesTrack = Sequence(Wait(0.6), Func(MovieUtil.showProps, bothGoggles, hands, pos, hpr, scale), ActorInterval(goggles, 'hypno-goggles', duration=2.2), Func(MovieUtil.removeProps, bothGoggles)) toonTrack = Sequence(ActorInterval(toon, 'hypnotize'), Func(toon.loop, 'neutral')) tracks = Parallel(gogglesTrack, toonTrack) for target in targets: suit = target['suit'] trapProp = suit.battleTrapProp if sidestep == 0: hp = target['hp'] kbbonus = target['kbbonus'] died = target['died'] revived = target['revived'] if kbbonus == 1 or hp > 0: suitTrack = Sequence() suitDelay = 1.6 suitAnimDuration = 1.5 opos, ohpr = battle.getActorPosHpr(suit) reachDist = MovieUtil.SUIT_LURE_DISTANCE reachPos = Point3(opos[0], opos[1] - reachDist, opos[2]) suitTrack.append(Func(suit.loop, 'neutral')) suitTrack.append(Wait(suitDelay)) suitTrack.append(ActorInterval(suit, 'hypnotized', duration=3.1)) suitTrack.append(Func(suit.setPos, battle, reachPos)) suitTrack.append(Func(suit.loop, 'lured')) suitTrack.append(Func(battle.lureSuit, suit)) if hp > 0: suitTrack.append(__createSuitDamageTrack(battle, suit, hp, lure, trapProp)) if revived != 0: suitTrack.append(MovieUtil.createSuitReviveTrack(suit, toon, battle, npcs)) elif died != 0: print trapProp print suit if trapProp: if not (trapProp.getName() == 'tnt' and suit.maxHP <= 42): suitTrack.append(MovieUtil.createSuitDeathTrack(suit, toon, battle, npcs)) tracks.append(suitTrack) tracks.append(lerpSuit(suit, suitDelay + 1.7, 0.7, reachPos, battle, trapProp)) else: tracks.append(Sequence(Wait(2.3), Func(MovieUtil.indicateMissed, suit, 1.1))) tracks.append(getSoundTrack('TL_hypnotize.ogg', delay=0.5, node=toon)) return tracks
def __doOpera(sound, delay, toon, targets, level): tracks = Parallel() delay = delay instrMin = Vec3(0.001, 0.001, 0.001) instrMax1 = Vec3(1.7, 1.7, 1.7) instrMax1 *= INSTRUMENT_SCALE_MODIFIER instrMax2 = Vec3(2.2, 2.2, 2.2) instrMax2 *= INSTRUMENT_SCALE_MODIFIER instrStretch = Vec3(0.4, 0.4, 0.4) instrStretch *= INSTRUMENT_SCALE_MODIFIER megaphone = globalPropPool.getProp('megaphone') megaphone2 = MovieUtil.copyProp(megaphone) megaphones = [megaphone, megaphone2] instrument = globalPropPool.getProp('singing') instrument2 = MovieUtil.copyProp(instrument) instruments = [instrument, instrument2] head = instrument2.find('**/opera_singer') head.setPos(0, 0, 0) def setInstrumentStats(instrument = instrument, instrument2 = instrument2): notify.debug('setInstrumentStats') newPos = Vec3(-0.8, -0.9, 0.2) newPos *= 1.3 instrument.setPos(newPos[0], newPos[1], newPos[2]) instrument.setHpr(145, 0, 90) instrument.setScale(instrMin) instrument2.setPos(newPos[0], newPos[1], newPos[2]) instrument2.setHpr(145, 0, 90) instrument2.setScale(instrMin) hands = toon.getRightHands() megaphoneShow = Sequence(Func(MovieUtil.showProps, megaphones, hands), Func(MovieUtil.showProps, instruments, hands), Func(setInstrumentStats)) megaphoneHide = Sequence(Func(MovieUtil.removeProps, megaphones), Func(MovieUtil.removeProps, instruments)) instrumentAppearSfx = globalBattleSoundCache.getSound(appearSoundFiles[level]) grow1 = getScaleBlendIntervals(instruments, duration=1, startScale=instrMin, endScale=instrMax1, blendType='easeOut') grow2 = getScaleBlendIntervals(instruments, duration=1.1, startScale=instrMax1, endScale=instrMax2, blendType='easeIn') shrink2 = getScaleIntervals(instruments, duration=0.1, startScale=instrMax2, endScale=instrMin) instrumentAppear = Parallel(Sequence(grow1, grow2, Wait(6.0), shrink2), Sequence(Wait(0.0), SoundInterval(instrumentAppearSfx, node=toon))) hasLuredSuits = __hasLuredSuits(sound) delayTime = delay if hasLuredSuits: delayTime += TIME_TO_WALK_BACK megaphoneTrack = Sequence(Wait(delayTime), megaphoneShow, Wait(1.0), instrumentAppear, Wait(2.0), megaphoneHide) tracks.append(megaphoneTrack) toonTrack = __createToonInterval(sound, delay, toon, operaInstrument=instrument) tracks.append(toonTrack) soundEffect = globalBattleSoundCache.getSound(soundFiles[level]) if soundEffect: delayTime = delay + tSound - 0.3 if hasLuredSuits: delayTime += TIME_TO_WALK_BACK soundTrack = Sequence(Wait(delayTime), SoundInterval(soundEffect, node=toon)) tracks.append(Sequence(Wait(0))) tracks.append(soundTrack) return tracks
def __doSoundsLevel(sounds, delay, hitCount, npcs): lastSoundThatHit = None totalDamage = 0 for sound in sounds: for target in sound['target']: if target['hp'] > 0: lastSoundThatHit = sound totalDamage += target['hp'] break mainTrack = Sequence() tracks = Parallel() deathTracks = Parallel() for sound in sounds: toon = sound['toon'] if 'npc' in sound: toon = sound['npc'] level = sound['level'] targets = sound['target'] hpbonus = sound['hpbonus'] attackMTrack = soundfn_array[sound['level']](sound, delay, toon, targets, level) tracks.append(Sequence(Wait(delay), attackMTrack)) tracks.append( __getSuitTrack(sound, lastSoundThatHit, delay, hitCount, targets, totalDamage, hpbonus, toon, npcs)) for target in targets: battle = sound['battle'] suit = target['suit'] died = target['died'] revived = target['revived'] if revived: deathTracks.append( MovieUtil.createSuitReviveTrack(suit, toon, battle, npcs)) elif died: if (sound['level'] >= ToontownBattleGlobals.UBER_GAG_LEVEL_INDEX) and ( totalDamage >= target['hp']): deathTracks.append( MovieUtil.createSuitDeathTrack(suit, toon, battle, npcs, headless=True)) else: deathTracks.append( MovieUtil.createSuitDeathTrack(suit, toon, battle, npcs)) mainTrack.append(tracks) mainTrack.append(deathTracks) return mainTrack
def setupPistol(self): # prepare the water pistol self.pistol = globalPropPool.getProp('water-gun') hands = self.toon.getRightHands() # scale gun only once, use instances to create nodepaths attaching # all LOD hand joints to the 1 gun self.hand_jointpath0 = hands[0].attachNewNode('handJoint0-path') pistolPos = Point3(0.28, 0.10, 0.08) pistolHpr = VBase3(85.60, -4.44, 94.43) MovieUtil.showProp(self.pistol, self.hand_jointpath0, pistolPos, pistolHpr)
def __healDance(heal, hasInteractivePropHealBonus): npcId = 0 if 'npcId' in heal: npcId = heal['npcId'] toon = NPCToons.createLocalNPC(npcId) if toon == None: return else: toon = heal['toon'] targets = heal['target'] ineffective = heal['sidestep'] level = heal['level'] if npcId != 0: track = Sequence(MovieNPCSOS.teleportIn(heal, toon)) else: track = Sequence(__runToHealSpot(heal)) delay = 3.0 first = 1 targetTrack = Sequence() for target in targets: targetToon = target['toon'] hp = target['hp'] reactIval = Func(__healToon, targetToon, hp, ineffective, hasInteractivePropHealBonus) if first: targetTrack.append(Wait(delay)) first = 0 targetTrack.append(reactIval) hat = globalPropPool.getProp('hat') hat2 = MovieUtil.copyProp(hat) hats = [hat, hat2] cane = globalPropPool.getProp('cane') cane2 = MovieUtil.copyProp(cane) canes = [cane, cane2] leftHands = toon.getLeftHands() rightHands = toon.getRightHands() dScale = 0.5 propTrack = Sequence(Func(MovieUtil.showProps, hats, rightHands, Point3(0.23, 0.09, 0.69), Point3(180, 0, 0)), Func(MovieUtil.showProps, canes, leftHands, Point3(-0.28, 0.0, 0.14), Point3(0.0, 0.0, -150.0)), MovieUtil.getScaleIntervals(hats + canes, dScale, MovieUtil.PNT3_NEARZERO, MovieUtil.PNT3_ONE), Wait(toon.getDuration('happy-dance') - 2.0 * dScale), MovieUtil.getScaleIntervals(hats + canes, dScale, MovieUtil.PNT3_ONE, MovieUtil.PNT3_NEARZERO), Func(MovieUtil.removeProps, hats + canes)) mtrack = Parallel(propTrack, ActorInterval(toon, 'happy-dance'), __getSoundTrack(level, 0.2, duration=6.4, node=toon), targetTrack) track.append(Func(toon.loop, 'neutral')) track.append(Wait(0.1)) track.append(mtrack) if npcId != 0: track.append(MovieNPCSOS.teleportOut(heal, toon)) else: track.append(__returnToBase(heal)) for target in targets: targetToon = target['toon'] track.append(Func(targetToon.clearChat)) return track
def __doBikehorn(sound, delay, toon, targets, level): tracks = Parallel() instrMin = Vec3(0.001, 0.001, 0.001) instrMax = Vec3(0.65, 0.65, 0.65) instrMax *= INSTRUMENT_SCALE_MODIFIER instrStretch = Vec3(0.6, 1.1, 0.6) instrStretch *= INSTRUMENT_SCALE_MODIFIER megaphone = globalPropPool.getProp('megaphone') megaphone2 = MovieUtil.copyProp(megaphone) megaphones = [megaphone, megaphone2] instrument = globalPropPool.getProp('bikehorn') instrument2 = MovieUtil.copyProp(instrument) instruments = [instrument, instrument2] def setInstrumentStats(instrument = instrument, instrument2 = instrument2): instrument.setPos(-1.1, -1.4, 0.1) instrument.setHpr(145, 0, 0) instrument.setScale(instrMin) instrument2.setPos(-1.1, -1.4, 0.1) instrument2.setHpr(145, 0, 0) instrument2.setScale(instrMin) hands = toon.getRightHands() megaphoneShow = Sequence(Func(MovieUtil.showProps, megaphones, hands), Func(MovieUtil.showProps, instruments, hands), Func(setInstrumentStats)) megaphoneHide = Sequence(Func(MovieUtil.removeProps, megaphones), Func(MovieUtil.removeProps, instruments)) instrumentAppearSfx = globalBattleSoundCache.getSound(appearSoundFiles[level]) grow = getScaleIntervals(instruments, duration=0.2, startScale=instrMin, endScale=instrMax) instrumentAppear = Parallel(grow, Sequence(Wait(0.15), SoundInterval(instrumentAppearSfx, node=toon))) stretchInstr = getScaleBlendIntervals(instruments, duration=0.2, startScale=instrMax, endScale=instrStretch, blendType='easeOut') backInstr = getScaleBlendIntervals(instruments, duration=0.2, startScale=instrStretch, endScale=instrMax, blendType='easeIn') stretchMega = getScaleBlendIntervals(megaphones, duration=0.2, startScale=megaphone.getScale(), endScale=0.9, blendType='easeOut') backMega = getScaleBlendIntervals(megaphones, duration=0.2, startScale=0.9, endScale=megaphone.getScale(), blendType='easeIn') attackTrack = Parallel(Sequence(stretchInstr, backInstr), Sequence(stretchMega, backMega)) hasLuredSuits = __hasLuredSuits(sound) delayTime = delay if hasLuredSuits: delayTime += TIME_TO_WALK_BACK megaphoneTrack = Sequence(Wait(delayTime), megaphoneShow, Wait(1.0), instrumentAppear, Wait(3.0), megaphoneHide) tracks.append(megaphoneTrack) toonTrack = __createToonInterval(sound, delay, toon) tracks.append(toonTrack) soundEffect = globalBattleSoundCache.getSound(soundFiles[level]) instrumentshrink = getScaleIntervals(instruments, duration=0.1, startScale=instrMax, endScale=instrMin) if soundEffect: delayTime = delay + tSound if hasLuredSuits: delayTime += TIME_TO_WALK_BACK soundTrack = Sequence(Wait(delayTime), Parallel(attackTrack, SoundInterval(soundEffect, node=toon)), Wait(0.2), instrumentshrink) tracks.append(soundTrack) return tracks
def enterStunned(self): self.loop('lured', 0) stunSequence = MovieUtil.createSuitStunInterval(self, 0, ToontownGlobals.LawbotBossLawyerStunTime) seqName = stunSequence.getName() stunSequence.append(Func(self.fsm.request, 'neutral')) self.activeIntervals[seqName] = stunSequence stunSequence.start()
def enterStunned(self): stunSequence = MovieUtil.createSuitStunInterval( self, 0, ToontownGlobals.LawbotBossLawyerStunTime) seqName = stunSequence.getName() stunSequence.append(Func(self.fsm.request, 'neutral')) self.activeIntervals[seqName] = stunSequence stunSequence.start()
def __healSmooch(heal, hasInteractivePropHealBonus): toon = heal['toon'] target = heal['target']['toon'] level = heal['level'] hp = heal['target']['hp'] ineffective = heal['sidestep'] track = Sequence(__runToHealSpot(heal)) lipstick = globalPropPool.getProp('lipstick') lipstick2 = MovieUtil.copyProp(lipstick) lipsticks = [lipstick, lipstick2] rightHands = toon.getRightHands() dScale = 0.5 lipstickTrack = Sequence(Func(MovieUtil.showProps, lipsticks, rightHands, Point3(-0.27, -0.24, -0.95), Point3(-118, -10.6, -25.9)), MovieUtil.getScaleIntervals(lipsticks, dScale, MovieUtil.PNT3_NEARZERO, MovieUtil.PNT3_ONE), Wait(toon.getDuration('smooch') - 2.0 * dScale), MovieUtil.getScaleIntervals(lipsticks, dScale, MovieUtil.PNT3_ONE, MovieUtil.PNT3_NEARZERO), Func(MovieUtil.removeProps, lipsticks)) lips = globalPropPool.getProp('lips') dScale = 0.5 tLips = 2.5 tThrow = 115.0 / toon.getFrameRate('smooch') dThrow = 0.5 def getLipPos(toon = toon): toon.pose('smooch', 57) toon.update(0) hand = toon.getRightHands()[0] return hand.getPos(render) lipsTrack = Sequence(Wait(tLips), Func(MovieUtil.showProp, lips, render, getLipPos), Func(lips.setBillboardPointWorld), LerpScaleInterval(lips, dScale, Point3(3, 3, 3), startScale=MovieUtil.PNT3_NEARZERO), Wait(tThrow - tLips - dScale), LerpPosInterval(lips, dThrow, Point3(target.getPos() + Point3(0, 0, target.getHeight()))), Func(MovieUtil.removeProp, lips)) delay = tThrow + dThrow mtrack = Parallel(lipstickTrack, lipsTrack, __getSoundTrack(level, 2, node=toon), Sequence(ActorInterval(toon, 'smooch'), *__returnToBase(heal)), Sequence(Wait(delay), ActorInterval(target, 'conked')), Sequence(Wait(delay), Func(__healToon, target, hp, ineffective, hasInteractivePropHealBonus))) track.append(mtrack) track.append(Func(target.clearChat)) return track
def placeTrap(trapProp, suit, battle=battle, trapName=trapName): if not trapProp or trapProp.isEmpty(): return trapProp.wrtReparentTo(suit) trapProp.show() if trapName == 'rake': trapProp.setPos(0, MovieUtil.SUIT_TRAP_RAKE_DISTANCE, 0) trapProp.setHpr(Point3(0, 270, 0)) trapProp.setScale(Point3(0.7, 0.7, 0.7)) rakeOffset = MovieUtil.getSuitRakeOffset(suit) trapProp.setY(trapProp.getY() + rakeOffset) elif trapName == 'banana': trapProp.setHpr(0, 0, 0) trapProp.setPos(0, MovieUtil.SUIT_TRAP_DISTANCE, -0.35) trapProp.pose(trapName, trapProp.getNumFrames(trapName) - 1) elif trapName == 'marbles': trapProp.setHpr(Point3(94, 0, 0)) trapProp.setPos(0, MovieUtil.SUIT_TRAP_MARBLES_DISTANCE, 0) trapProp.pose(trapName, trapProp.getNumFrames(trapName) - 1) elif trapName == 'tnt': trapProp.setHpr(0, 90, 0) trapProp.setPos(0, MovieUtil.SUIT_TRAP_TNT_DISTANCE, 0.4) else: notify.warning( 'placeTrap() - Incorrect trap: %s placed on a suit' % trapName)
def shortCircuitTrack(suit, battle): if suit.isHidden(): return Sequence() else: suitTrack = Sequence() suitPos, suitHpr = battle.getActorPosHpr(suit) suitTrack.append(Wait(0.15)) suitTrack.append(Func(MovieUtil.avatarHide, suit)) deathSound = base.loader.loadSfx('phase_3.5/audio/sfx/ENC_cogfall_apart.ogg') deathSoundTrack = Sequence(Wait(0.5), SoundInterval(deathSound, volume=0.8)) BattleParticles.loadParticles() smallGears = BattleParticles.createParticleEffect(file='gearExplosionSmall') singleGear = BattleParticles.createParticleEffect('GearExplosion', numParticles=1) smallGearExplosion = BattleParticles.createParticleEffect('GearExplosion', numParticles=10) bigGearExplosion = BattleParticles.createParticleEffect('BigGearExplosion', numParticles=30) gearPoint = Point3(suitPos.getX(), suitPos.getY(), suitPos.getZ() + suit.height - 0.2) smallGears.setPos(gearPoint) singleGear.setPos(gearPoint) smallGears.setDepthWrite(False) singleGear.setDepthWrite(False) smallGearExplosion.setPos(gearPoint) bigGearExplosion.setPos(gearPoint) smallGearExplosion.setDepthWrite(False) bigGearExplosion.setDepthWrite(False) explosionTrack = Sequence() explosionTrack.append(MovieUtil.createKapowExplosionTrack(battle, explosionPoint=gearPoint)) gears1Track = Sequence(Wait(0.5), ParticleInterval(smallGears, battle, worldRelative=0, duration=1.0, cleanup=True), name='gears1Track') gears2MTrack = Track((0.1, ParticleInterval(singleGear, battle, worldRelative=0, duration=0.4, cleanup=True)), (0.5, ParticleInterval(smallGearExplosion, battle, worldRelative=0, duration=0.5, cleanup=True)), (0.9, ParticleInterval(bigGearExplosion, battle, worldRelative=0, duration=2.0, cleanup=True)), name='gears2MTrack') return Parallel(suitTrack, explosionTrack, deathSoundTrack, gears1Track, gears2MTrack)
def destroy(self): if self.toon == base.localAvatar: if self.waterBulletIval: self.waterBulletIval.finish() del self.waterBulletIval self.waterBulletIval = None self.ignore('enter' + self.collSphereName) base.localAvatar.controlManager.currentControls.cTrav.removeCollider(self.waterBullet) self.waterBullet.removeNode() del self.waterBullet self.hand_jointpath0.removeNode() MovieUtil.removeProp(self.pistol) if self.shootTrack != None: self.shootTrack.finish() self.shootTrack = None self.game = None self.toon = None return
def __healJuggle(heal, hasInteractivePropHealBonus): npcId = 0 if 'npcId' in heal: npcId = heal['npcId'] toon = NPCToons.createLocalNPC(npcId) if toon == None: return else: toon = heal['toon'] targets = heal['target'] ineffective = heal['sidestep'] level = heal['level'] if npcId != 0: track = Sequence(MovieNPCSOS.teleportIn(heal, toon)) else: track = Sequence(__runToHealSpot(heal)) delay = 4.0 first = 1 targetTrack = Sequence() for target in targets: targetToon = target['toon'] hp = target['hp'] reactIval = Func(__healToon, targetToon, hp, ineffective, hasInteractivePropHealBonus) if first == 1: targetTrack.append(Wait(delay)) first = 0 targetTrack.append(reactIval) cube = globalPropPool.getProp('cubes') cube2 = MovieUtil.copyProp(cube) cubes = [cube, cube2] hips = [toon.getLOD(toon.getLODNames()[0]).find('**/joint_hips'), toon.getLOD(toon.getLODNames()[1]).find('**/joint_hips')] cubeTrack = Sequence(Func(MovieUtil.showProps, cubes, hips), MovieUtil.getActorIntervals(cubes, 'cubes'), Func(MovieUtil.removeProps, cubes)) mtrack = Parallel(cubeTrack, __getSoundTrack(level, 0.7, duration=7.7, node=toon), ActorInterval(toon, 'juggle'), targetTrack) track.append(mtrack) if npcId != 0: track.append(MovieNPCSOS.teleportOut(heal, toon)) else: track.append(__returnToBase(heal)) for target in targets: targetToon = target['toon'] track.append(Func(targetToon.clearChat)) return track
def __doJoybuzzer(zap, delay, fShowStun, npcs = []): toon = zap['toon'] level = zap['level'] hpbonus = zap['hpbonus'] target = zap['target'] suit = target['suit'] hp = target['hp'] kbbonus = target['kbbonus'] died = target['died'] revived = target['revived'] leftSuits = target['leftSuits'] rightSuits = target['rightSuits'] battle = zap['battle'] suitPos = suit.getPos(battle) origHpr = toon.getHpr(battle) hitSuit = hp > 0 scale = sprayScales[level] tTotalFlowerToonAnimationTime = 2 tFlowerFirstAppears = 1.0 dFlowerScaleTime = 0.5 tSprayStarts = tTotalFlowerToonAnimationTime dSprayScale = 0.2 dSprayHold = 0.1 tContact = tSprayStarts + dSprayScale tSuitDodges = tTotalFlowerToonAnimationTime tracks = Parallel() button = globalPropPool.getProp('joybuzz') button2 = MovieUtil.copyProp(button) buttons = [button, button2] hands = toon.getRightHands() toonTrack = Sequence(Func(MovieUtil.showProps, buttons, hands, Vec3((0.3, 0, 0)), Vec3((-10, -60, 0))), Func(toon.headsUp, battle, suitPos), ActorInterval(toon, 'water-gun'), Func(MovieUtil.removeProps, buttons), Func(toon.loop, 'neutral'), Func(toon.setHpr, battle, origHpr)) tracks.append(toonTrack) tracks.append(__getSoundTrack(level, hitSuit, tTotalFlowerToonAnimationTime, toon)) targetPoint = lambda suit = suit: __suitTargetPoint(suit) def getSprayStartPos(toon = toon): toon.update(0) p = button2.getPos(toon) return p sprayTrack = MovieUtil.getZapTrack(battle, WaterSprayColor, getSprayStartPos, targetPoint, dSprayScale, dSprayHold, dSprayScale, horizScale=scale, vertScale=scale) if hp > 0 or delay <= 0: tracks.append(__getSuitTrack(suit, tContact, tSuitDodges, hp, hpbonus, kbbonus, 'shock', died, leftSuits, rightSuits, battle, toon, fShowStun, revived=revived)) return tracks
def __doBalloon(zap, delay, fShowStun, npcs = []): toon = zap['toon'] level = zap['level'] hpbonus = zap['hpbonus'] target = zap['target'] suit = target['suit'] hp = target['hp'] kbbonus = target['kbbonus'] died = target['died'] revived = target['revived'] leftSuits = target['leftSuits'] rightSuits = target['rightSuits'] battle = zap['battle'] suitPos = suit.getPos(battle) origHpr = toon.getHpr(battle) hitSuit = hp > 0 scale = sprayScales[level] tPistol = 0.0 dPistolScale = 3 dPistolHold = 1.8 tSpray = 3 sprayPoseFrame = 63 dSprayScale = 0.1 dSprayHold = 0.3 tContact = tSpray + dSprayScale tSuitDodges = 1.1 tracks = Parallel() toonTrack = Sequence(Func(toon.headsUp, battle, suitPos), Func(toon.pingpong, 'smooch', fromFrame=40, toFrame=45), Wait(2.5), Func(toon.stop), Func(toon.pingpong, 'cast', fromFrame=30, toFrame=40), Wait(2), Func(toon.stop), Func(toon.loop, 'neutral'), Func(toon.setHpr, battle, origHpr)) tracks.append(toonTrack) soundTrack = __getSoundTrack(level, hitSuit, 0.2, toon) tracks.append(soundTrack) pistol = globalPropPool.getProp('balloon') hands = toon.getRightHands() hand_jointpath0 = hands[0].attachNewNode('handJoint0-path') hand_jointpath1 = hand_jointpath0.instanceTo(hands[1]) targetPoint = lambda suit = suit: __suitTargetPoint(suit) def getSprayStartPos(pistol = pistol, toon = toon): toon.update(0) p = pistol.getPos(render) return p sprayTrack = MovieUtil.getSprayTrack(battle, WaterSprayColor, getSprayStartPos, targetPoint, dSprayScale, dSprayHold, dSprayScale, horizScale=scale, vertScale=scale) pistolPos = Point3(0.28, 0.1, 0.08) pistolHpr = VBase3(85.6, -4.44, 94.43) pistolTrack = Sequence(Func(MovieUtil.showProp, pistol, hand_jointpath0, pistolPos, pistolHpr), LerpScaleInterval(pistol, dPistolScale, dPistolScale, startScale=MovieUtil.PNT3_NEARZERO), Wait(tSpray - dPistolScale)) pistolTrack.append(sprayTrack) pistolTrack.append(Wait(dPistolHold)) pistolTrack.append(LerpScaleInterval(pistol, 0.4, MovieUtil.PNT3_NEARZERO, dPistolScale)) pistolTrack.append(Func(hand_jointpath1.removeNode)) pistolTrack.append(Func(hand_jointpath0.removeNode)) pistolTrack.append(Func(MovieUtil.removeProp, pistol)) tracks.append(pistolTrack) if hp > 0 or delay <= 0: tracks.append(__getSuitTrack(suit, tContact, tSuitDodges, hp, hpbonus, kbbonus, 'shock', died, leftSuits, rightSuits, battle, toon, fShowStun, revived=revived)) return tracks
def __doRug(zap, delay, fShowStun, npcs = []): toon = zap['toon'] level = zap['level'] hpbonus = zap['hpbonus'] target = zap['target'] suit = target['suit'] hp = target['hp'] kbbonus = target['kbbonus'] died = target['died'] revived = target['revived'] leftSuits = target['leftSuits'] rightSuits = target['rightSuits'] battle = zap['battle'] suitPos = suit.getPos(battle) origHpr = toon.getHpr(battle) hitSuit = hp > 0 scale = sprayScales[level] tSpray = 5.2 sprayPoseFrame = 88 dSprayScale = 0.1 dSprayHold = 0.1 tContact = tSpray + dSprayScale tSuitDodges = max(tSpray - 0.5, 0.0) tracks = Parallel() tracks.append(ActorInterval(toon, 'run')) soundTrack = __getSoundTrack(level, hitSuit, 0, toon) tracks.append(soundTrack) rug = globalPropPool.getProp('zapRug') rugPos = Point3(0, 0, 0.025) rugHpr = Point3(0, 0, 0) if hp > 0: glassTrack = Sequence(Func(MovieUtil.showProp, rug, toon, rugPos, rugHpr), ActorInterval(toon, 'walk', playRate=0.7), ActorInterval(toon, 'run'), ActorInterval(toon, 'run', playRate=1.1), ActorInterval(toon, 'run', playRate=1.2), ActorInterval(toon, 'run', playRate=1.3), ActorInterval(toon, 'run', playRate=1.4), ActorInterval(toon, 'water', playRate=1, startFrame=0, endFrame=36), Wait(1), Func(MovieUtil.removeProp, rug), Func(toon.loop, 'neutral'), Func(toon.setHpr, battle, origHpr)) else: glassTrack = Sequence(Func(MovieUtil.showProp, rug, toon, rugPos, rugHpr), ActorInterval(toon, 'walk', playRate=0.7), ActorInterval(toon, 'run'), ActorInterval(toon, 'run', playRate=1.1), ActorInterval(toon, 'run', playRate=1.2), ActorInterval(toon, 'run', playRate=1.3), ActorInterval(toon, 'run', playRate=1.4), ActorInterval(toon, 'slip-forward', playRate=1, startFrame=0, endFrame=36), Wait(1), Func(MovieUtil.removeProp, rug), Func(toon.loop, 'neutral'), Func(toon.setHpr, battle, origHpr)) tracks.append(glassTrack) targetPoint = lambda suit = suit: __suitTargetPoint(suit) def getSprayStartPos(toon = toon): toon.update(0) lod0 = toon.getLOD(toon.getLODNames()[0]) if base.config.GetBool('want-new-anims', 1): if not lod0.find('**/def_joint_right_hold').isEmpty(): joint = lod0.find('**/def_joint_right_hold') else: joint = lod0.find('**/joint_Rhold') else: joint = lod0.find('**/joint_Rhold') p = joint.getPos(render) return p if hp > 0: sprayTrack = MovieUtil.getZapTrack(battle, WaterSprayColor, getSprayStartPos, targetPoint, dSprayScale, dSprayHold, dSprayScale, horizScale=scale, vertScale=scale) tracks.append(Sequence(Wait(tSpray), sprayTrack)) if hp > 0 or delay <= 0: tracks.append(__getSuitTrack(suit, tContact, tSuitDodges, hp, hpbonus, kbbonus, 'shock', died, leftSuits, rightSuits, battle, toon, fShowStun, revived=revived, dodge=False)) return tracks
def __healJoke(heal, hasInteractivePropHealBonus): npcId = 0 if 'npcId' in heal: npcId = heal['npcId'] toon = NPCToons.createLocalNPC(npcId) if toon == None: return else: toon = heal['toon'] targets = heal['target'] ineffective = heal['sidestep'] level = heal['level'] jokeIndex = heal['hpbonus'] % len(HealJokes.toonHealJokes) if npcId != 0: track = Sequence(MovieNPCSOS.teleportIn(heal, toon)) else: track = Sequence(__runToHealSpot(heal)) tracks = Parallel() fSpeakPunchline = 58 tSpeakSetup = 0.0 tSpeakPunchline = 3.0 dPunchLine = 3.0 tTargetReact = tSpeakPunchline + 1.0 dTargetLaugh = 1.5 tRunBack = tSpeakPunchline + dPunchLine tDoSoundAnimation = tSpeakPunchline - float(fSpeakPunchline) / toon.getFrameRate('sound') megaphone = globalPropPool.getProp('megaphone') megaphone2 = MovieUtil.copyProp(megaphone) megaphones = [megaphone, megaphone2] hands = toon.getRightHands() dMegaphoneScale = 0.5 tracks.append(Sequence(Wait(tDoSoundAnimation), Func(MovieUtil.showProps, megaphones, hands), MovieUtil.getScaleIntervals(megaphones, dMegaphoneScale, MovieUtil.PNT3_NEARZERO, MovieUtil.PNT3_ONE), Wait(toon.getDuration('sound') - 2.0 * dMegaphoneScale), MovieUtil.getScaleIntervals(megaphones, dMegaphoneScale, MovieUtil.PNT3_ONE, MovieUtil.PNT3_NEARZERO), Func(MovieUtil.removeProps, megaphones))) tracks.append(Sequence(Wait(tDoSoundAnimation), ActorInterval(toon, 'sound'))) soundTrack = __getSoundTrack(level, 2.0, node=toon) tracks.append(soundTrack) joke = HealJokes.toonHealJokes[jokeIndex] tracks.append(Sequence(Wait(tSpeakSetup), Func(toon.setChatAbsolute, joke[0], CFSpeech | CFTimeout))) tracks.append(Sequence(Wait(tSpeakPunchline), Func(toon.setChatAbsolute, joke[1], CFSpeech | CFTimeout))) reactTrack = Sequence(Wait(tTargetReact)) for target in targets: targetToon = target['toon'] hp = target['hp'] reactTrack.append(Func(__healToon, targetToon, hp, ineffective, hasInteractivePropHealBonus)) reactTrack.append(Wait(dTargetLaugh)) for target in targets: targetToon = target['toon'] reactTrack.append(Func(targetToon.clearChat)) tracks.append(reactTrack) if npcId != 0: track.append(Sequence(Wait(tRunBack), Func(toon.clearChat), *MovieNPCSOS.teleportOut(heal, toon))) else: tracks.append(Sequence(Wait(tRunBack), Func(toon.clearChat), *__returnToBase(heal))) track.append(tracks) return track
def reset(self, finish=0): if self.hasBeenReset == 1: return self.hasBeenReset = 1 self.stop() self._deleteTrack() if finish == 1: self.restore() self.toonAttackDicts = [] self.suitAttackDicts = [] self.restoreColor = 0 self.restoreHips = 0 self.restoreHeadScale = 0 self.restoreToonScale = 0 self.specialParticleEffects = [] for prop in self.renderProps: MovieUtil.removeProp(prop) self.renderProps = []
def __propPreflight(props, suit, toon, battle): prop = props[0] toon.update(0) prop.wrtReparentTo(battle) props[1].reparentTo(hidden) for ci in xrange(prop.getNumChildren()): prop.getChild(ci).setHpr(0, -90, 0) targetPnt = MovieUtil.avatarFacePoint(suit, other=battle) prop.lookAt(targetPnt)
def getGeyserTrack(geyser, suit, geyserPosPoint, scaleUpPoint, rainEffects, rainDelay, effectDelay, geyserHold, useEffect, battle=battle): geyserMound = MovieUtil.copyProp(geyser) geyserRemoveM = geyserMound.findAllMatches('**/Splash*') geyserRemoveM.addPathsFrom(geyserMound.findAllMatches('**/spout')) for i in xrange(geyserRemoveM.getNumPaths()): geyserRemoveM[i].removeNode() geyserWater = MovieUtil.copyProp(geyser) geyserRemoveW = geyserWater.findAllMatches('**/hole') geyserRemoveW.addPathsFrom(geyserWater.findAllMatches('**/shadow')) for i in xrange(geyserRemoveW.getNumPaths()): geyserRemoveW[i].removeNode() track = Sequence( Wait(rainDelay), Func(MovieUtil.showProp, geyserMound, battle, suit.getPos(battle)), Func(MovieUtil.showProp, geyserWater, battle, suit.getPos(battle)), LerpScaleInterval(geyserWater, 1.0, scaleUpPoint, startScale=MovieUtil.PNT3_NEARZERO), Wait(geyserHold * 0.5), LerpScaleInterval(geyserWater, 0.5, MovieUtil.PNT3_NEARZERO, startScale=scaleUpPoint)) track.append( LerpScaleInterval(geyserMound, 0.5, MovieUtil.PNT3_NEARZERO)) track.append(Func(MovieUtil.removeProp, geyserMound)) track.append(Func(MovieUtil.removeProp, geyserWater)) track.append(Func(MovieUtil.removeProp, geyser)) return track
def __doTazer(zap, delay, fShowStun, npcs = []): toon = zap['toon'] level = zap['level'] hpbonus = zap['hpbonus'] target = zap['target'] suit = target['suit'] hp = target['hp'] kbbonus = target['kbbonus'] died = target['died'] revived = target['revived'] leftSuits = target['leftSuits'] rightSuits = target['rightSuits'] battle = zap['battle'] suitPos = suit.getPos(battle) origHpr = toon.getHpr(battle) origPos = toon.getPos(battle) tazer = globalPropPool.getProp('tazer') tazer.setHpr(180, 0, 0) runBackHpr = Vec3(0, 0, 0) hands = toon.getRightHands() hand_jointpath0 = hands[0].attachNewNode('handJoint0-path') hand_jointpath1 = hand_jointpath0.instanceTo(hands[1]) hitSuit = hp > 0 scale = 0.3 tAppearDelay = 0.7 dHoseHold = 0.7 midPos = Point3(toon.getX(battle) * 0.5, 0, 0) runDur = 1 tSprayDelay = 2 tSpray = 1 dSprayScale = 0.1 dSprayHold = 1.8 tContact = 2 tSuitDodges = 2.1 tracks = Parallel() toonTrack = Sequence(Wait(tAppearDelay), Func(MovieUtil.showProp, tazer, hand_jointpath0), Func(toon.headsUp, battle, suitPos), Func(toon.loop, 'run'), Wait(1), Func(toon.pingpong, 'cast', fromFrame=30, toFrame=40), Wait(3), Func(toon.stop), Func(toon.setHpr, battle, runBackHpr), Func(toon.loop, 'run'), Wait(1), Func(toon.stop), Func(toon.loop, 'neutral'), Func(MovieUtil.removeProp, tazer), Func(toon.setHpr, battle, origHpr)) moveTrack = Sequence(Wait(tAppearDelay), LerpPosInterval(toon, runDur, midPos, other=battle), Wait(3), LerpPosInterval(toon, runDur, origPos, other=battle)) tracks.append(toonTrack) tracks.append(moveTrack) soundTrack = __getSoundTrack(level, hitSuit, tSprayDelay, toon) tracks.append(soundTrack) targetPoint = lambda suit = suit: __suitTargetPoint(suit) def getSprayStartPos(tazer = tazer, toon = toon): toon.update(0) p = tazer.getPos(render) return p sprayTrack = Sequence() sprayTrack.append(Wait(tSprayDelay)) sprayTrack.append(MovieUtil.getZapTrack(battle, WaterSprayColor, getSprayStartPos, targetPoint, dSprayScale, dSprayHold, dSprayScale, horizScale=scale, vertScale=scale)) tracks.append(sprayTrack) if hp > 0 or delay <= 0: tracks.append(__getSuitTrack(suit, tContact, tSuitDodges, hp, hpbonus, kbbonus, 'shock', died, leftSuits, rightSuits, battle, toon, fShowStun, revived=revived)) return tracks
def enterStunned(self): assert(self.notify.debug('enterStunned')) stunSequence = MovieUtil.createSuitStunInterval(self, 0, ToontownGlobals.LawbotBossLawyerStunTime) #seqName = self.uniqueName('stunSequence') seqName = stunSequence.getName() stunSequence.append(Func(self.fsm.request,'neutral')) self.activeIntervals[seqName] = stunSequence stunSequence.start() return
def __healTickle(heal, hasInteractivePropHealBonus): toon = heal['toon'] target = heal['target']['toon'] hp = heal['target']['hp'] ineffective = heal['sidestep'] level = heal['level'] track = Sequence(__runToHealSpot(heal)) feather = globalPropPool.getProp('feather') feather2 = MovieUtil.copyProp(feather) feathers = [feather, feather2] hands = toon.getRightHands() def scaleFeathers(feathers, toon = toon, target = target): toon.pose('tickle', 63) toon.update(0) hand = toon.getRightHands()[0] horizDistance = Vec3(hand.getPos(render) - target.getPos(render)) horizDistance.setZ(0) distance = horizDistance.length() if target.style.torso[0] == 's': distance -= 0.5 else: distance -= 0.3 featherLen = 2.4 scale = distance / (featherLen * hand.getScale(render)[0]) for feather in feathers: feather.setScale(scale) tFeatherScaleUp = 0.5 dFeatherScaleUp = 0.5 dFeatherScaleDown = 0.5 featherTrack = Parallel(MovieUtil.getActorIntervals(feathers, 'feather'), Sequence(Wait(tFeatherScaleUp), Func(MovieUtil.showProps, feathers, hands), Func(scaleFeathers, feathers), MovieUtil.getScaleIntervals(feathers, dFeatherScaleUp, MovieUtil.PNT3_NEARZERO, feathers[0].getScale)), Sequence(Wait(toon.getDuration('tickle') - dFeatherScaleDown), MovieUtil.getScaleIntervals(feathers, dFeatherScaleDown, None, MovieUtil.PNT3_NEARZERO))) tHeal = 3.0 mtrack = Parallel(featherTrack, ActorInterval(toon, 'tickle'), __getSoundTrack(level, 1, node=toon), Sequence(Wait(tHeal), Func(__healToon, target, hp, ineffective, hasInteractivePropHealBonus), ActorInterval(target, 'cringe', startTime=20.0 / target.getFrameRate('cringe')))) track.append(mtrack) track.append(Func(MovieUtil.removeProps, feathers)) track.append(__returnToBase(heal)) track.append(Func(target.clearChat)) return track
def __doSmooch(attack, hp = 0): toon = NPCToons.createLocalNPC(attack['npcId']) if toon == None: return targets = attack['toons'] level = 2 battle = attack['battle'] track = Sequence(teleportIn(attack, toon)) lipstick = globalPropPool.getProp('lipstick') lipstick2 = MovieUtil.copyProp(lipstick) lipsticks = [lipstick, lipstick2] rightHands = toon.getRightHands() dScale = 0.5 lipstickTrack = Sequence(Func(MovieUtil.showProps, lipsticks, rightHands, Point3(-0.27, -0.24, -0.95), Point3(-118, -10.6, -25.9)), MovieUtil.getScaleIntervals(lipsticks, dScale, MovieUtil.PNT3_NEARZERO, MovieUtil.PNT3_ONE), Wait(toon.getDuration('smooch') - 2.0 * dScale), MovieUtil.getScaleIntervals(lipsticks, dScale, MovieUtil.PNT3_ONE, MovieUtil.PNT3_NEARZERO)) lips = globalPropPool.getProp('lips') dScale = 0.5 tLips = 2.5 tThrow = 115.0 / toon.getFrameRate('smooch') dThrow = 0.5 def getLipPos(toon = toon): toon.pose('smooch', 57) toon.update(0) hand = toon.getRightHands()[0] return hand.getPos(render) effectTrack = Sequence() for target in targets: lipcopy = MovieUtil.copyProp(lips) lipsTrack = Sequence(Wait(tLips), Func(MovieUtil.showProp, lipcopy, render, getLipPos), Func(lipcopy.setBillboardPointWorld), LerpScaleInterval(lipcopy, dScale, Point3(3, 3, 3), startScale=MovieUtil.PNT3_NEARZERO), Wait(tThrow - tLips - dScale), LerpPosInterval(lipcopy, dThrow, Point3(target.getPos() + Point3(0, 0, target.getHeight()))), Func(MovieUtil.removeProp, lipcopy)) delay = tThrow + dThrow mtrack = Parallel(lipstickTrack, lipsTrack, __getSoundTrack(level, 2, node=toon), Sequence(ActorInterval(toon, 'smooch')), Sequence(Wait(delay), ActorInterval(target, 'conked')), Sequence(Wait(delay), Func(__healToon, target, hp))) effectTrack.append(mtrack) effectTrack.append(Func(MovieUtil.removeProps, lipsticks)) track.append(effectTrack) track.append(teleportOut(attack, toon)) track.append(Func(target.clearChat)) return track
def __propPreflightGroup(props, suits, toon, battle): prop = props[0] toon.update(0) prop.wrtReparentTo(battle) props[1].reparentTo(hidden) for ci in xrange(prop.getNumChildren()): prop.getChild(ci).setHpr(0, -90, 0) avgTargetPt = Point3(0, 0, 0) for suit in suits: avgTargetPt += MovieUtil.avatarFacePoint(suit, other=battle) avgTargetPt /= len(suits) prop.lookAt(avgTargetPt)
def __getSuitTrack(suit, tContact, tDodge, hp, hpbonus, kbbonus, anim, died, leftSuits, rightSuits, battle, toon, fShowStun, beforeStun = 0.5, afterStun = 1.8, uberRepeat = 0, revived = 0, npcs = [], dodge = True): if hp > 0: suitTrack = Sequence() sival = ActorInterval(suit, anim) sival = [] if fShowStun == 1: sival = Parallel(Func(suit.loop, anim), MovieUtil.zapCog(suit, beforeStun, afterStun, battle)) else: sival = ActorInterval(suit, anim) showDamage = Func(suit.showHpText, -hp, openEnded=0, attackTrack=ZAP_TRACK) updateHealthBar = Func(suit.updateHealthBar, hp) suitTrack.append(Wait(tContact)) suitTrack.append(showDamage) suitTrack.append(updateHealthBar) suitTrack.append(sival) bonusTrack = Sequence(Wait(tContact)) if kbbonus == 0: suitTrack.append(__createSuitResetPosTrack(suit, battle)) suitTrack.append(Func(battle.unlureSuit, suit)) if hpbonus > 0: bonusTrack.append(Wait(0.75)) bonusTrack.append(Func(suit.showHpText, -hpbonus, 1, openEnded=0, attackTrack=ZAP_TRACK)) bonusTrack.append(updateHealthBar) if died != 0: if hp == suit.currHP: suitTrack.append(shortCircuitTrack(suit, battle)) else: suitTrack.append(MovieUtil.createSuitDeathTrack(suit, toon, battle, npcs)) else: suitTrack.append(Func(suit.loop, 'neutral')) if revived != 0: suitTrack.append(MovieUtil.createSuitReviveTrack(suit, toon, battle, npcs)) return Parallel(suitTrack, bonusTrack) elif dodge: return MovieUtil.createSuitDodgeMultitrack(tDodge, suit, leftSuits, rightSuits) else: return Sequence(Wait(tDodge), Func(MovieUtil.indicateMissed, toon))
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 hideSpray(spray, sprayScale, sprayRot, sprayProp, propPool): sprayProp.detachNode() MovieUtil.removeProp(sprayProp) sprayRot.removeNode() sprayScale.removeNode()
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.mp3') deathSound = base.loadSfx('phase_3.5/audio/sfx/ENC_cogfall_apart.mp3') 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()