Silly Meter with magic word! Scientists are still missing though.

This commit is contained in:
DenialMC 2015-05-10 21:24:32 +03:00
parent effdeab749
commit d0fbe172e2

View file

@ -1,65 +1,22 @@
from toontown.toonbase.ToonBaseGlobal import *
from direct.interval.IntervalGlobal import * from direct.interval.IntervalGlobal import *
from direct.distributed.ClockDelta import * from direct.distributed.ClockDelta import *
from direct.showbase import Audio3DManager from direct.showbase import Audio3DManager
from toontown.toonbase import ToontownGlobals
from toontown.dna.DNAParser import *
import cPickle
from DistributedToonInterior import DistributedToonInterior from DistributedToonInterior import DistributedToonInterior
from direct.directnotify import DirectNotifyGlobal from direct.directnotify import DirectNotifyGlobal
from direct.fsm import ClassicFSM, State from direct.fsm import ClassicFSM, State
from direct.distributed import DistributedObject from direct.distributed import DistributedObject
from direct.fsm import State from direct.fsm import State
from direct.actor import Actor from direct.actor import Actor
import random from otp.ai.MagicWordGlobal import *
import time from toontown.toonbase import ToontownGlobals
import ToonInteriorColors from toontown.toonbase.ToonBaseGlobal import *
from toontown.dna.DNAParser import *
from toontown.hood import ZoneUtil from toontown.hood import ZoneUtil
from toontown.toon import ToonDNA
from toontown.toon import ToonHead
from toontown.toon.DistributedNPCToonBase import DistributedNPCToonBase from toontown.toon.DistributedNPCToonBase import DistributedNPCToonBase
import ToonInteriorColors, random
class DistributedToonHallInterior(DistributedToonInterior): class DistributedToonHallInterior(DistributedToonInterior):
def __init__(self, cr):
DistributedToonInterior.__init__(self, cr)
self.sillyFSM = ClassicFSM.ClassicFSM('SillyOMeter', [State.State('Setup', self.enterSetup, self.exitSetup, ['Phase0',
'Phase1',
'Phase2',
'Phase3',
'Phase4',
'Phase5',
'Phase6',
'Phase7',
'Phase8',
'Phase9',
'Phase10',
'Phase11',
'Phase12',
'Phase13',
'Phase14',
'Phase15',
'Flat',
'Off']),
State.State('Phase0', self.enterPhase0, self.exitPhase0, ['Phase1', 'Flat', 'Off']),
State.State('Phase1', self.enterPhase1, self.exitPhase1, ['Phase2', 'Flat', 'Off']),
State.State('Phase2', self.enterPhase2, self.exitPhase2, ['Phase3', 'Flat', 'Off']),
State.State('Phase3', self.enterPhase3, self.exitPhase3, ['Phase4', 'Flat', 'Off']),
State.State('Phase4', self.enterPhase4, self.exitPhase4, ['Phase5', 'Flat', 'Off']),
State.State('Phase5', self.enterPhase5, self.exitPhase5, ['Phase6', 'Flat', 'Off']),
State.State('Phase6', self.enterPhase6, self.exitPhase6, ['Phase7', 'Flat', 'Off']),
State.State('Phase7', self.enterPhase7, self.exitPhase7, ['Phase8', 'Flat', 'Off']),
State.State('Phase8', self.enterPhase8, self.exitPhase8, ['Phase9', 'Flat', 'Off']),
State.State('Phase9', self.enterPhase9, self.exitPhase9, ['Phase10', 'Flat', 'Off']),
State.State('Phase10', self.enterPhase10, self.exitPhase10, ['Phase11', 'Flat', 'Off']),
State.State('Phase11', self.enterPhase11, self.exitPhase11, ['Phase12', 'Flat', 'Off']),
State.State('Phase12', self.enterPhase12, self.exitPhase12, ['Phase13', 'Flat', 'Off']),
State.State('Phase13', self.enterPhase13, self.exitPhase13, ['Phase14', 'Flat', 'Off']),
State.State('Phase14', self.enterPhase14, self.exitPhase14, ['Phase15', 'Flat', 'Off']),
State.State('Phase15', self.enterPhase15, self.exitPhase15, ['Flat', 'Off']),
State.State('Flat', self.enterFlat, self.exitFlat, ['Off', 'Phase0']),
State.State('Off', self.enterOff, self.exitOff, [])], 'Setup', 'Off')
def setup(self): def setup(self):
self.dnaStore = base.cr.playGame.dnaStore self.dnaStore = base.cr.playGame.dnaStore
self.randomGenerator = random.Random() self.randomGenerator = random.Random()
@ -88,95 +45,12 @@ class DistributedToonHallInterior(DistributedToonInterior):
del self.dnaStore del self.dnaStore
del self.randomGenerator del self.randomGenerator
self.interior.flattenMedium() self.interior.flattenMedium()
self.sillyFSM.enterInitialState()
for npcToon in self.cr.doFindAllInstances(DistributedNPCToonBase): for npcToon in self.cr.doFindAllInstances(DistributedNPCToonBase):
npcToon.initToonState() npcToon.initToonState()
def sillyMeterIsRunning(self, isRunning): self.createSillyMeter()
if isRunning:
self.sillyFSM.request('Phase0')
else:
self.sillyFSM.request('Flat')
def selectPhase(self, newPhase): def createSillyMeter(self):
try:
gotoPhase = 'Phase' + str(newPhase)
if self.sillyFSM.hasStateNamed(gotoPhase) and not self.sillyFSM.getCurrentState() == self.sillyFSM.getStateNamed(gotoPhase):
self.sillyFSM.request(gotoPhase)
except:
self.notify.warning('Illegal phase transition requested %s' % newPhase)
def startIfNeeded(self):
try:
self.curPhase = self.getPhaseToRun()
if self.curPhase >= 0:
self.sillyFSM.request('Phase' + str(self.curPhase))
else:
self.sillyFSM.request('Flat')
except:
pass
def getPhaseToRun(self):
result = -1
enoughInfoToRun = False
if base.cr.newsManager.isHolidayRunning(ToontownGlobals.SILLYMETER_HOLIDAY) or base.cr.newsManager.isHolidayRunning(ToontownGlobals.SILLYMETER_EXT_HOLIDAY):
if hasattr(base.cr, 'SillyMeterMgr') and not base.cr.SillyMeterMgr.isDisabled():
enoughInfoToRun = True
elif hasattr(base.cr, 'SillyMeterMgr'):
self.notify.debug('isDisabled = %s' % base.cr.SillyMeterMgr.isDisabled())
else:
self.notify.debug('base.cr does not have SillyMeterMgr')
else:
self.notify.debug('holiday is not running')
self.notify.debug('enoughInfoToRun = %s' % enoughInfoToRun)
if enoughInfoToRun and base.cr.SillyMeterMgr.getIsRunning():
result = base.cr.SillyMeterMgr.getCurPhase()
return result
def calculatePhaseDuration(self):
result = -1
valid = False
if base.cr.newsManager.isHolidayRunning(ToontownGlobals.SILLYMETER_HOLIDAY) or base.cr.newsManager.isHolidayRunning(ToontownGlobals.SILLYMETER_EXT_HOLIDAY):
if hasattr(base.cr, 'SillyMeterMgr') and not base.cr.SillyMeterMgr.isDisabled():
valid = True
elif hasattr(base.cr, 'SillyMeterMgr'):
self.notify.debug('isDisabled = %s' % base.cr.SillyMeterMgr.isDisabled())
else:
self.notify.debug('base.cr does not have SillyMeterMgr')
else:
self.notify.debug('holiday is not running')
self.notify.debug('valid = %s' % valid)
if valid and base.cr.SillyMeterMgr.getIsRunning():
result = base.cr.SillyMeterMgr.getCurPhaseDuration()
return result
def calculateFrameOffset(self, phaseDuration, numFrames):
result = -1
valid = False
if base.cr.newsManager.isHolidayRunning(ToontownGlobals.SILLYMETER_HOLIDAY) or base.cr.newsManager.isHolidayRunning(ToontownGlobals.SILLYMETER_EXT_HOLIDAY):
if hasattr(base.cr, 'SillyMeterMgr') and not base.cr.SillyMeterMgr.isDisabled():
valid = True
elif hasattr(base.cr, 'SillyMeterMgr'):
self.notify.debug('isDisabled = %s' % base.cr.SillyMeterMgr.isDisabled())
else:
self.notify.debug('base.cr does not have SillyMeterMgr')
else:
self.notify.debug('holiday is not running')
self.notify.debug('valid = %s' % valid)
if valid and base.cr.SillyMeterMgr.getIsRunning():
startTime = time.mktime(base.cr.SillyMeterMgr.getCurPhaseStartDate().timetuple())
serverTime = time.mktime(base.cr.toontownTimeManager.getCurServerDateTime().timetuple())
offset = (serverTime - startTime) / phaseDuration
if offset < 0:
result = -1
else:
result = offset * numFrames
return result
def calculateFrameRange(self, frameNo):
pass
def enterSetup(self):
ropes = loader.loadModel('phase_4/models/modules/tt_m_ara_int_ropes') ropes = loader.loadModel('phase_4/models/modules/tt_m_ara_int_ropes')
ropes.reparentTo(self.interior) ropes.reparentTo(self.interior)
self.sillyMeter = Actor.Actor('phase_4/models/props/tt_a_ara_ttc_sillyMeter_default', {'arrowTube': 'phase_4/models/props/tt_a_ara_ttc_sillyMeter_arrowFluid', self.sillyMeter = Actor.Actor('phase_4/models/props/tt_a_ara_ttc_sillyMeter_default', {'arrowTube': 'phase_4/models/props/tt_a_ara_ttc_sillyMeter_arrowFluid',
@ -187,24 +61,6 @@ class DistributedToonHallInterior(DistributedToonInterior):
'phaseFourToFive': 'phase_4/models/props/tt_a_ara_ttc_sillyMeter_phaseFourToFive', 'phaseFourToFive': 'phase_4/models/props/tt_a_ara_ttc_sillyMeter_phaseFourToFive',
'phaseFive': 'phase_4/models/props/tt_a_ara_ttc_sillyMeter_phaseFive'}) 'phaseFive': 'phase_4/models/props/tt_a_ara_ttc_sillyMeter_phaseFive'})
self.sillyMeter.reparentTo(self.interior) self.sillyMeter.reparentTo(self.interior)
self.flatSillyMeter = loader.loadModel('phase_3.5/models/modules/tt_m_ara_int_sillyMeterFlat')
self.flatSillyMeter.reparentTo(self.interior)
self.flatSillyMeter.hide()
self.flatDuck = loader.loadModel('phase_3.5/models/modules/tt_m_ara_int_scientistDuckFlat')
loc1 = self.interior.find('**/npc_origin_1')
if loc1:
self.flatDuck.reparentTo(loc1)
self.flatDuck.hide()
self.flatMonkey = loader.loadModel('phase_3.5/models/modules/tt_m_ara_int_scientistMonkeyFlat')
loc1 = self.interior.find('**/npc_origin_2')
if loc1:
self.flatMonkey.reparentTo(loc1)
self.flatMonkey.hide()
self.flatHorse = loader.loadModel('phase_3.5/models/modules/tt_m_ara_int_scientistHorseFlat')
loc1 = self.interior.find('**/npc_origin_3')
if loc1:
self.flatHorse.reparentTo(loc1)
self.flatHorse.hide()
self.smPhase1 = self.sillyMeter.find('**/stage1') self.smPhase1 = self.sillyMeter.find('**/stage1')
self.smPhase2 = self.sillyMeter.find('**/stage2') self.smPhase2 = self.sillyMeter.find('**/stage2')
self.smPhase3 = self.sillyMeter.find('**/stage3') self.smPhase3 = self.sillyMeter.find('**/stage3')
@ -234,21 +90,25 @@ class DistributedToonHallInterior(DistributedToonInterior):
self.arrowSfx = self.audio3d.loadSfx('phase_4/audio/sfx/tt_s_prp_sillyMeterArrow.ogg') self.arrowSfx = self.audio3d.loadSfx('phase_4/audio/sfx/tt_s_prp_sillyMeterArrow.ogg')
self.arrowSfx.setLoop(False) self.arrowSfx.setLoop(False)
self.audio3d.setDropOffFactor(0.1) self.audio3d.setDropOffFactor(0.1)
self.accept('SillyMeterPhase', self.selectPhase)
self.accept('SillyMeterIsRunning', self.sillyMeterIsRunning)
self.startIfNeeded()
def exitSetup(self): self.startSillyMeter(config.GetInt('silly-meter-phase', 12))
self.ignore('SillyMeterPhase')
def startSillyMeter(self, phase):
self.stopSillyMeter()
if hasattr(self, 'enterPhase%s' % phase):
getattr(self, 'enterPhase%s' % phase)()
self.phase = phase
def stopSillyMeter(self):
if hasattr(self, 'phase') and hasattr(self, 'exitPhase%s' % self.phase):
getattr(self, 'exitPhase%s' % self.phase)()
def enterPhase0(self): def enterPhase0(self):
phaseDuration = self.calculatePhaseDuration() self.animSeq = Parallel(ActorInterval(self.sillyMeter, 'arrowTube', partName='arrow', duration=604800, constrainedLoop=1, startFrame=1, endFrame=30), Sequence(Func(self.phase1Sfx.play), Func(self.audio3d.attachSoundToObject, self.phase1Sfx, self.sillyMeter)))
if phaseDuration < 0:
phaseDuration = 604800
self.animSeq = Parallel(ActorInterval(self.sillyMeter, 'arrowTube', partName='arrow', duration=phaseDuration, constrainedLoop=1, startFrame=1, endFrame=30), Sequence(Func(self.phase1Sfx.play), Func(self.audio3d.attachSoundToObject, self.phase1Sfx, self.sillyMeter)))
self.animSeq.start() self.animSeq.start()
self.sillyMeter.loop('phaseOne', partName='meter') self.sillyMeter.loop('phaseOne', partName='meter')
self.accept('SillyMeterPhase', self.selectPhase) self.accept('SillyMeterPhase', self.startSillyMeter)
def exitPhase0(self): def exitPhase0(self):
self.animSeq.finish() self.animSeq.finish()
@ -259,14 +119,11 @@ class DistributedToonHallInterior(DistributedToonInterior):
self.ignore('SillyMeterPhase') self.ignore('SillyMeterPhase')
def enterPhase1(self): def enterPhase1(self):
phaseDuration = self.calculatePhaseDuration()
if phaseDuration < 0:
phaseDuration = 604800
self.audio3d.attachSoundToObject(self.phase1Sfx, self.sillyMeter) self.audio3d.attachSoundToObject(self.phase1Sfx, self.sillyMeter)
self.animSeq = Sequence(Sequence(ActorInterval(self.sillyMeter, 'arrowTube', partName='arrow', constrainedLoop=0, startFrame=31, endFrame=42), Func(self.arrowSfx.play)), Parallel(ActorInterval(self.sillyMeter, 'arrowTube', partName='arrow', duration=phaseDuration, constrainedLoop=1, startFrame=42, endFrame=71), Sequence(Func(self.phase1Sfx.play), Func(self.audio3d.attachSoundToObject, self.phase1Sfx, self.sillyMeter)))) self.animSeq = Sequence(Sequence(ActorInterval(self.sillyMeter, 'arrowTube', partName='arrow', constrainedLoop=0, startFrame=31, endFrame=42), Func(self.arrowSfx.play)), Parallel(ActorInterval(self.sillyMeter, 'arrowTube', partName='arrow', duration=604800, constrainedLoop=1, startFrame=42, endFrame=71), Sequence(Func(self.phase1Sfx.play), Func(self.audio3d.attachSoundToObject, self.phase1Sfx, self.sillyMeter))))
self.animSeq.start() self.animSeq.start()
self.sillyMeter.loop('phaseOne', partName='meter') self.sillyMeter.loop('phaseOne', partName='meter')
self.accept('SillyMeterPhase', self.selectPhase) self.accept('SillyMeterPhase', self.startSillyMeter)
def exitPhase1(self): def exitPhase1(self):
self.audio3d.detachSound(self.phase1Sfx) self.audio3d.detachSound(self.phase1Sfx)
@ -277,14 +134,11 @@ class DistributedToonHallInterior(DistributedToonInterior):
self.ignore('SillyMeterPhase') self.ignore('SillyMeterPhase')
def enterPhase2(self): def enterPhase2(self):
phaseDuration = self.calculatePhaseDuration() self.animSeq = Parallel(ActorInterval(self.sillyMeter, 'arrowTube', partName='arrow', duration=604800, constrainedLoop=1, startFrame=42, endFrame=71), Sequence(Func(self.phase1Sfx.play), Func(self.audio3d.attachSoundToObject, self.phase1Sfx, self.sillyMeter)))
if phaseDuration < 0:
phaseDuration = 604800
self.animSeq = Parallel(ActorInterval(self.sillyMeter, 'arrowTube', partName='arrow', duration=phaseDuration, constrainedLoop=1, startFrame=42, endFrame=71), Sequence(Func(self.phase1Sfx.play), Func(self.audio3d.attachSoundToObject, self.phase1Sfx, self.sillyMeter)))
self.animSeq.start() self.animSeq.start()
self.smPhase2.show() self.smPhase2.show()
self.sillyMeter.loop('phaseOne', partName='meter') self.sillyMeter.loop('phaseOne', partName='meter')
self.accept('SillyMeterPhase', self.selectPhase) self.accept('SillyMeterPhase', self.startSillyMeter)
def exitPhase2(self): def exitPhase2(self):
self.animSeq.finish() self.animSeq.finish()
@ -296,14 +150,11 @@ class DistributedToonHallInterior(DistributedToonInterior):
self.ignore('SillyMeterPhase') self.ignore('SillyMeterPhase')
def enterPhase3(self): def enterPhase3(self):
phaseDuration = self.calculatePhaseDuration() self.animSeq = Sequence(Sequence(ActorInterval(self.sillyMeter, 'arrowTube', partName='arrow', constrainedLoop=0, startFrame=72, endFrame=83), Func(self.arrowSfx.play)), Parallel(ActorInterval(self.sillyMeter, 'arrowTube', partName='arrow', duration=604800, constrainedLoop=1, startFrame=83, endFrame=112), Sequence(Func(self.phase1Sfx.play), Func(self.audio3d.attachSoundToObject, self.phase1Sfx, self.sillyMeter))))
if phaseDuration < 0:
phaseDuration = 604800
self.animSeq = Sequence(Sequence(ActorInterval(self.sillyMeter, 'arrowTube', partName='arrow', constrainedLoop=0, startFrame=72, endFrame=83), Func(self.arrowSfx.play)), Parallel(ActorInterval(self.sillyMeter, 'arrowTube', partName='arrow', duration=phaseDuration, constrainedLoop=1, startFrame=83, endFrame=112), Sequence(Func(self.phase1Sfx.play), Func(self.audio3d.attachSoundToObject, self.phase1Sfx, self.sillyMeter))))
self.animSeq.start() self.animSeq.start()
self.smPhase2.show() self.smPhase2.show()
self.sillyMeter.loop('phaseOne', partName='meter') self.sillyMeter.loop('phaseOne', partName='meter')
self.accept('SillyMeterPhase', self.selectPhase) self.accept('SillyMeterPhase', self.startSillyMeter)
def exitPhase3(self): def exitPhase3(self):
self.animSeq.finish() self.animSeq.finish()
@ -315,14 +166,11 @@ class DistributedToonHallInterior(DistributedToonInterior):
self.ignore('SillyMeterPhase') self.ignore('SillyMeterPhase')
def enterPhase4(self): def enterPhase4(self):
phaseDuration = self.calculatePhaseDuration() self.animSeq = Sequence(Sequence(ActorInterval(self.sillyMeter, 'arrowTube', partName='arrow', constrainedLoop=0, startFrame=113, endFrame=124), Func(self.arrowSfx.play)), Parallel(ActorInterval(self.sillyMeter, 'arrowTube', partName='arrow', duration=604800, constrainedLoop=1, startFrame=124, endFrame=153), Sequence(Func(self.phase1Sfx.play), Func(self.audio3d.attachSoundToObject, self.phase1Sfx, self.sillyMeter))))
if phaseDuration < 0:
phaseDuration = 604800
self.animSeq = Sequence(Sequence(ActorInterval(self.sillyMeter, 'arrowTube', partName='arrow', constrainedLoop=0, startFrame=113, endFrame=124), Func(self.arrowSfx.play)), Parallel(ActorInterval(self.sillyMeter, 'arrowTube', partName='arrow', duration=phaseDuration, constrainedLoop=1, startFrame=124, endFrame=153), Sequence(Func(self.phase1Sfx.play), Func(self.audio3d.attachSoundToObject, self.phase1Sfx, self.sillyMeter))))
self.animSeq.start() self.animSeq.start()
self.smPhase2.show() self.smPhase2.show()
self.sillyMeter.loop('phaseOne', partName='meter') self.sillyMeter.loop('phaseOne', partName='meter')
self.accept('SillyMeterPhase', self.selectPhase) self.accept('SillyMeterPhase', self.startSillyMeter)
def exitPhase4(self): def exitPhase4(self):
self.animSeq.finish() self.animSeq.finish()
@ -334,14 +182,11 @@ class DistributedToonHallInterior(DistributedToonInterior):
self.ignore('SillyMeterPhase') self.ignore('SillyMeterPhase')
def enterPhase5(self): def enterPhase5(self):
phaseDuration = self.calculatePhaseDuration() self.animSeq = Sequence(Sequence(ActorInterval(self.sillyMeter, 'arrowTube', partName='arrow', constrainedLoop=0, startFrame=154, endFrame=165), Func(self.arrowSfx.play)), Parallel(ActorInterval(self.sillyMeter, 'arrowTube', partName='arrow', duration=604800, constrainedLoop=1, startFrame=165, endFrame=194), Sequence(Func(self.phase2Sfx.play), Func(self.audio3d.attachSoundToObject, self.phase2Sfx, self.sillyMeter))))
if phaseDuration < 0:
phaseDuration = 604800
self.animSeq = Sequence(Sequence(ActorInterval(self.sillyMeter, 'arrowTube', partName='arrow', constrainedLoop=0, startFrame=154, endFrame=165), Func(self.arrowSfx.play)), Parallel(ActorInterval(self.sillyMeter, 'arrowTube', partName='arrow', duration=phaseDuration, constrainedLoop=1, startFrame=165, endFrame=194), Sequence(Func(self.phase2Sfx.play), Func(self.audio3d.attachSoundToObject, self.phase2Sfx, self.sillyMeter))))
self.animSeq.start() self.animSeq.start()
self.smPhase2.show() self.smPhase2.show()
self.sillyMeter.loop('phaseTwo', partName='meter') self.sillyMeter.loop('phaseTwo', partName='meter')
self.accept('SillyMeterPhase', self.selectPhase) self.accept('SillyMeterPhase', self.startSillyMeter)
def exitPhase5(self): def exitPhase5(self):
self.animSeq.finish() self.animSeq.finish()
@ -353,14 +198,11 @@ class DistributedToonHallInterior(DistributedToonInterior):
self.ignore('SillyMeterPhase') self.ignore('SillyMeterPhase')
def enterPhase6(self): def enterPhase6(self):
phaseDuration = self.calculatePhaseDuration() self.animSeq = Sequence(Sequence(ActorInterval(self.sillyMeter, 'arrowTube', partName='arrow', constrainedLoop=0, startFrame=195, endFrame=206), Func(self.arrowSfx.play)), Parallel(ActorInterval(self.sillyMeter, 'arrowTube', partName='arrow', duration=604800, constrainedLoop=1, startFrame=206, endFrame=235), Sequence(Func(self.phase2Sfx.play), Func(self.audio3d.attachSoundToObject, self.phase2Sfx, self.sillyMeter))))
if phaseDuration < 0:
phaseDuration = 604800
self.animSeq = Sequence(Sequence(ActorInterval(self.sillyMeter, 'arrowTube', partName='arrow', constrainedLoop=0, startFrame=195, endFrame=206), Func(self.arrowSfx.play)), Parallel(ActorInterval(self.sillyMeter, 'arrowTube', partName='arrow', duration=phaseDuration, constrainedLoop=1, startFrame=206, endFrame=235), Sequence(Func(self.phase2Sfx.play), Func(self.audio3d.attachSoundToObject, self.phase2Sfx, self.sillyMeter))))
self.animSeq.start() self.animSeq.start()
self.smPhase2.show() self.smPhase2.show()
self.sillyMeter.loop('phaseTwo', partName='meter') self.sillyMeter.loop('phaseTwo', partName='meter')
self.accept('SillyMeterPhase', self.selectPhase) self.accept('SillyMeterPhase', self.startSillyMeter)
def exitPhase6(self): def exitPhase6(self):
self.animSeq.finish() self.animSeq.finish()
@ -372,15 +214,12 @@ class DistributedToonHallInterior(DistributedToonInterior):
self.ignore('SillyMeterPhase') self.ignore('SillyMeterPhase')
def enterPhase7(self): def enterPhase7(self):
phaseDuration = self.calculatePhaseDuration() self.animSeq = Sequence(Sequence(ActorInterval(self.sillyMeter, 'arrowTube', partName='arrow', constrainedLoop=0, startFrame=236, endFrame=247), Func(self.arrowSfx.play)), Parallel(ActorInterval(self.sillyMeter, 'arrowTube', partName='arrow', duration=604800, constrainedLoop=1, startFrame=247, endFrame=276), Sequence(Func(self.phase3Sfx.play), Func(self.audio3d.attachSoundToObject, self.phase3Sfx, self.sillyMeter))))
if phaseDuration < 0:
phaseDuration = 604800
self.animSeq = Sequence(Sequence(ActorInterval(self.sillyMeter, 'arrowTube', partName='arrow', constrainedLoop=0, startFrame=236, endFrame=247), Func(self.arrowSfx.play)), Parallel(ActorInterval(self.sillyMeter, 'arrowTube', partName='arrow', duration=phaseDuration, constrainedLoop=1, startFrame=247, endFrame=276), Sequence(Func(self.phase3Sfx.play), Func(self.audio3d.attachSoundToObject, self.phase3Sfx, self.sillyMeter))))
self.animSeq.start() self.animSeq.start()
self.smPhase2.show() self.smPhase2.show()
self.smPhase3.show() self.smPhase3.show()
self.sillyMeter.loop('phaseThree', partName='meter') self.sillyMeter.loop('phaseThree', partName='meter')
self.accept('SillyMeterPhase', self.selectPhase) self.accept('SillyMeterPhase', self.startSillyMeter)
def exitPhase7(self): def exitPhase7(self):
self.animSeq.finish() self.animSeq.finish()
@ -393,15 +232,12 @@ class DistributedToonHallInterior(DistributedToonInterior):
self.ignore('SillyMeterPhase') self.ignore('SillyMeterPhase')
def enterPhase8(self): def enterPhase8(self):
phaseDuration = self.calculatePhaseDuration() self.animSeq = Sequence(Sequence(ActorInterval(self.sillyMeter, 'arrowTube', partName='arrow', constrainedLoop=0, startFrame=277, endFrame=288), Func(self.arrowSfx.play)), Parallel(ActorInterval(self.sillyMeter, 'arrowTube', partName='arrow', duration=604800, constrainedLoop=1, startFrame=288, endFrame=317), Sequence(Func(self.phase3Sfx.play), Func(self.audio3d.attachSoundToObject, self.phase3Sfx, self.sillyMeter))))
if phaseDuration < 0:
phaseDuration = 604800
self.animSeq = Sequence(Sequence(ActorInterval(self.sillyMeter, 'arrowTube', partName='arrow', constrainedLoop=0, startFrame=277, endFrame=288), Func(self.arrowSfx.play)), Parallel(ActorInterval(self.sillyMeter, 'arrowTube', partName='arrow', duration=phaseDuration, constrainedLoop=1, startFrame=288, endFrame=317), Sequence(Func(self.phase3Sfx.play), Func(self.audio3d.attachSoundToObject, self.phase3Sfx, self.sillyMeter))))
self.animSeq.start() self.animSeq.start()
self.smPhase2.show() self.smPhase2.show()
self.smPhase3.show() self.smPhase3.show()
self.sillyMeter.loop('phaseThree', partName='meter') self.sillyMeter.loop('phaseThree', partName='meter')
self.accept('SillyMeterPhase', self.selectPhase) self.accept('SillyMeterPhase', self.startSillyMeter)
def exitPhase8(self): def exitPhase8(self):
self.animSeq.finish() self.animSeq.finish()
@ -414,15 +250,12 @@ class DistributedToonHallInterior(DistributedToonInterior):
self.ignore('SillyMeterPhase') self.ignore('SillyMeterPhase')
def enterPhase9(self): def enterPhase9(self):
phaseDuration = self.calculatePhaseDuration() self.animSeq = Sequence(Sequence(ActorInterval(self.sillyMeter, 'arrowTube', partName='arrow', constrainedLoop=0, startFrame=318, endFrame=329), Func(self.arrowSfx.play)), Parallel(ActorInterval(self.sillyMeter, 'arrowTube', partName='arrow', duration=604800, constrainedLoop=1, startFrame=329, endFrame=358), Sequence(Func(self.phase3Sfx.play), Func(self.audio3d.attachSoundToObject, self.phase3Sfx, self.sillyMeter))))
if phaseDuration < 0:
phaseDuration = 604800
self.animSeq = Sequence(Sequence(ActorInterval(self.sillyMeter, 'arrowTube', partName='arrow', constrainedLoop=0, startFrame=318, endFrame=329), Func(self.arrowSfx.play)), Parallel(ActorInterval(self.sillyMeter, 'arrowTube', partName='arrow', duration=phaseDuration, constrainedLoop=1, startFrame=329, endFrame=358), Sequence(Func(self.phase3Sfx.play), Func(self.audio3d.attachSoundToObject, self.phase3Sfx, self.sillyMeter))))
self.animSeq.start() self.animSeq.start()
self.smPhase2.show() self.smPhase2.show()
self.smPhase3.show() self.smPhase3.show()
self.sillyMeter.loop('phaseThree', partName='meter') self.sillyMeter.loop('phaseThree', partName='meter')
self.accept('SillyMeterPhase', self.selectPhase) self.accept('SillyMeterPhase', self.startSillyMeter)
def exitPhase9(self): def exitPhase9(self):
self.animSeq.finish() self.animSeq.finish()
@ -435,16 +268,13 @@ class DistributedToonHallInterior(DistributedToonInterior):
self.ignore('SillyMeterPhase') self.ignore('SillyMeterPhase')
def enterPhase10(self): def enterPhase10(self):
phaseDuration = self.calculatePhaseDuration() self.animSeq = Sequence(Sequence(ActorInterval(self.sillyMeter, 'arrowTube', partName='arrow', constrainedLoop=0, startFrame=359, endFrame=370), Func(self.arrowSfx.play)), Parallel(ActorInterval(self.sillyMeter, 'arrowTube', partName='arrow', duration=604800, constrainedLoop=1, startFrame=370, endFrame=399), Sequence(Func(self.phase4Sfx.play), Func(self.audio3d.attachSoundToObject, self.phase4Sfx, self.sillyMeter))))
if phaseDuration < 0:
phaseDuration = 604800
self.animSeq = Sequence(Sequence(ActorInterval(self.sillyMeter, 'arrowTube', partName='arrow', constrainedLoop=0, startFrame=359, endFrame=370), Func(self.arrowSfx.play)), Parallel(ActorInterval(self.sillyMeter, 'arrowTube', partName='arrow', duration=phaseDuration, constrainedLoop=1, startFrame=370, endFrame=399), Sequence(Func(self.phase4Sfx.play), Func(self.audio3d.attachSoundToObject, self.phase4Sfx, self.sillyMeter))))
self.animSeq.start() self.animSeq.start()
self.smPhase2.show() self.smPhase2.show()
self.smPhase3.show() self.smPhase3.show()
self.smPhase4.show() self.smPhase4.show()
self.sillyMeter.loop('phaseFour', partName='meter') self.sillyMeter.loop('phaseFour', partName='meter')
self.accept('SillyMeterPhase', self.selectPhase) self.accept('SillyMeterPhase', self.startSillyMeter)
def exitPhase10(self): def exitPhase10(self):
self.animSeq.finish() self.animSeq.finish()
@ -458,16 +288,13 @@ class DistributedToonHallInterior(DistributedToonInterior):
self.ignore('SillyMeterPhase') self.ignore('SillyMeterPhase')
def enterPhase11(self): def enterPhase11(self):
phaseDuration = self.calculatePhaseDuration() self.animSeq = Sequence(Sequence(ActorInterval(self.sillyMeter, 'arrowTube', partName='arrow', constrainedLoop=0, startFrame=400, endFrame=411), Func(self.arrowSfx.play)), Parallel(ActorInterval(self.sillyMeter, 'arrowTube', partName='arrow', duration=604800, constrainedLoop=1, startFrame=411, endFrame=440), Sequence(Func(self.phase4Sfx.play), Func(self.audio3d.attachSoundToObject, self.phase4Sfx, self.sillyMeter))))
if phaseDuration < 0:
phaseDuration = 604800
self.animSeq = Sequence(Sequence(ActorInterval(self.sillyMeter, 'arrowTube', partName='arrow', constrainedLoop=0, startFrame=400, endFrame=411), Func(self.arrowSfx.play)), Parallel(ActorInterval(self.sillyMeter, 'arrowTube', partName='arrow', duration=phaseDuration, constrainedLoop=1, startFrame=411, endFrame=440), Sequence(Func(self.phase4Sfx.play), Func(self.audio3d.attachSoundToObject, self.phase4Sfx, self.sillyMeter))))
self.animSeq.start() self.animSeq.start()
self.smPhase2.show() self.smPhase2.show()
self.smPhase3.show() self.smPhase3.show()
self.smPhase4.show() self.smPhase4.show()
self.sillyMeter.loop('phaseFour', partName='meter') self.sillyMeter.loop('phaseFour', partName='meter')
self.accept('SillyMeterPhase', self.selectPhase) self.accept('SillyMeterPhase', self.startSillyMeter)
def exitPhase11(self): def exitPhase11(self):
self.animSeq.finish() self.animSeq.finish()
@ -481,18 +308,13 @@ class DistributedToonHallInterior(DistributedToonInterior):
self.ignore('SillyMeterPhase') self.ignore('SillyMeterPhase')
def enterPhase12(self): def enterPhase12(self):
phaseDuration = self.calculatePhaseDuration() self.animSeq = Sequence(Sequence(ActorInterval(self.sillyMeter, 'arrowTube', partName='arrow', constrainedLoop=0, startFrame=441, endFrame=452), Func(self.arrowSfx.play)), Parallel(ActorInterval(self.sillyMeter, 'arrowTube', partName='arrow', duration=604800, constrainedLoop=1, startFrame=452, endFrame=481), Sequence(Func(self.phase4Sfx.play), Func(self.audio3d.attachSoundToObject, self.phase4Sfx, self.sillyMeter))))
if phaseDuration < 0:
phaseDuration = 604800
elif phaseDuration > 2000000:
phaseDuration = 2000000
self.animSeq = Sequence(Sequence(ActorInterval(self.sillyMeter, 'arrowTube', partName='arrow', constrainedLoop=0, startFrame=441, endFrame=452), Func(self.arrowSfx.play)), Parallel(ActorInterval(self.sillyMeter, 'arrowTube', partName='arrow', duration=phaseDuration, constrainedLoop=1, startFrame=452, endFrame=481), Sequence(Func(self.phase4Sfx.play), Func(self.audio3d.attachSoundToObject, self.phase4Sfx, self.sillyMeter))))
self.animSeq.start() self.animSeq.start()
self.smPhase2.show() self.smPhase2.show()
self.smPhase3.show() self.smPhase3.show()
self.smPhase4.show() self.smPhase4.show()
self.sillyMeter.loop('phaseFour', partName='meter') self.sillyMeter.loop('phaseFour', partName='meter')
self.accept('SillyMeterPhase', self.selectPhase) self.accept('SillyMeterPhase', self.startSillyMeter)
def exitPhase12(self): def exitPhase12(self):
self.animSeq.finish() self.animSeq.finish()
@ -506,15 +328,12 @@ class DistributedToonHallInterior(DistributedToonInterior):
self.ignore('SillyMeterPhase') self.ignore('SillyMeterPhase')
def enterPhase13(self): def enterPhase13(self):
phaseDuration = self.calculatePhaseDuration() self.animSeq = Sequence(Parallel(Func(self.phase4To5Sfx.play), ActorInterval(self.sillyMeter, 'phaseFourToFive', constrainedLoop=0, startFrame=1, endFrame=120)), Parallel(ActorInterval(self.sillyMeter, 'phaseFive', duration=604800, constrainedLoop=1, startFrame=1, endFrame=48), Sequence(Func(self.phase5Sfx.play), Func(self.audio3d.attachSoundToObject, self.phase5Sfx, self.sillyMeter))))
if phaseDuration < 0:
phaseDuration = 604800
self.animSeq = Sequence(Parallel(Func(self.phase4To5Sfx.play), ActorInterval(self.sillyMeter, 'phaseFourToFive', constrainedLoop=0, startFrame=1, endFrame=120)), Parallel(ActorInterval(self.sillyMeter, 'phaseFive', duration=phaseDuration, constrainedLoop=1, startFrame=1, endFrame=48), Sequence(Func(self.phase5Sfx.play), Func(self.audio3d.attachSoundToObject, self.phase5Sfx, self.sillyMeter))))
self.animSeq.start() self.animSeq.start()
self.smPhase2.show() self.smPhase2.show()
self.smPhase3.show() self.smPhase3.show()
self.smPhase4.show() self.smPhase4.show()
self.accept('SillyMeterPhase', self.selectPhase) self.accept('SillyMeterPhase', self.startSillyMeter)
def exitPhase13(self): def exitPhase13(self):
self.animSeq.finish() self.animSeq.finish()
@ -528,15 +347,12 @@ class DistributedToonHallInterior(DistributedToonInterior):
self.ignore('SillyMeterPhase') self.ignore('SillyMeterPhase')
def enterPhase14(self): def enterPhase14(self):
phaseDuration = self.calculatePhaseDuration() self.animSeq = Parallel(ActorInterval(self.sillyMeter, 'phaseFive', duration=604800, constrainedLoop=1, startFrame=1, endFrame=48), Sequence(Func(self.phase5Sfx.play), Func(self.audio3d.attachSoundToObject, self.phase5Sfx, self.sillyMeter)))
if phaseDuration < 0:
phaseDuration = 604800
self.animSeq = Parallel(ActorInterval(self.sillyMeter, 'phaseFive', duration=phaseDuration, constrainedLoop=1, startFrame=1, endFrame=48), Sequence(Func(self.phase5Sfx.play), Func(self.audio3d.attachSoundToObject, self.phase5Sfx, self.sillyMeter)))
self.animSeq.start() self.animSeq.start()
self.smPhase2.show() self.smPhase2.show()
self.smPhase3.show() self.smPhase3.show()
self.smPhase4.show() self.smPhase4.show()
self.accept('SillyMeterPhase', self.selectPhase) self.accept('SillyMeterPhase', self.startSillyMeter)
def exitPhase14(self): def exitPhase14(self):
self.animSeq.finish() self.animSeq.finish()
@ -550,15 +366,12 @@ class DistributedToonHallInterior(DistributedToonInterior):
self.ignore('SillyMeterPhase') self.ignore('SillyMeterPhase')
def enterPhase15(self): def enterPhase15(self):
phaseDuration = self.calculatePhaseDuration() self.animSeq = Parallel(ActorInterval(self.sillyMeter, 'phaseFive', duration=604800, constrainedLoop=1, startFrame=1, endFrame=48), Sequence(Func(self.phase5Sfx.play), Func(self.audio3d.attachSoundToObject, self.phase5Sfx, self.sillyMeter)))
if phaseDuration < 0:
phaseDuration = 604800
self.animSeq = Parallel(ActorInterval(self.sillyMeter, 'phaseFive', duration=phaseDuration, constrainedLoop=1, startFrame=1, endFrame=48), Sequence(Func(self.phase5Sfx.play), Func(self.audio3d.attachSoundToObject, self.phase5Sfx, self.sillyMeter)))
self.animSeq.start() self.animSeq.start()
self.smPhase2.show() self.smPhase2.show()
self.smPhase3.show() self.smPhase3.show()
self.smPhase4.show() self.smPhase4.show()
self.accept('SillyMeterPhase', self.selectPhase) self.accept('SillyMeterPhase', self.startSillyMeter)
def exitPhase15(self): def exitPhase15(self):
self.animSeq.finish() self.animSeq.finish()
@ -569,25 +382,8 @@ class DistributedToonHallInterior(DistributedToonInterior):
self.audio3d.detachSound(self.phase5Sfx) self.audio3d.detachSound(self.phase5Sfx)
self.phase5Sfx.stop() self.phase5Sfx.stop()
self.sillyMeter.stop() self.sillyMeter.stop()
self.ignore('SillyMeterPhase')
def enterFlat(self):
self.sillyMeter.hide()
self.flatSillyMeter.show()
self.flatDuck.show()
self.flatMonkey.show()
self.flatHorse.show()
def exitFlat(self):
self.sillyMeter.show()
self.flatSillyMeter.hide()
self.flatDuck.hide()
self.flatMonkey.hide()
self.flatHorse.hide()
def enterOff(self): def enterOff(self):
if hasattr(self, 'animSeq') and self.animSeq:
self.animSeq.finish()
self.ignore('SillyMeterPhase') self.ignore('SillyMeterPhase')
if hasattr(self, 'sillyMeter'): if hasattr(self, 'sillyMeter'):
del self.sillyMeter del self.sillyMeter
@ -708,10 +504,21 @@ class DistributedToonHallInterior(DistributedToonInterior):
self.restoreCam() self.restoreCam()
self.ignoreAll() self.ignoreAll()
self.cleanUpCollisions() self.cleanUpCollisions()
if hasattr(self, 'sillyFSM'): self.stopSillyMeter()
self.sillyFSM.requestFinalState() self.enterOff()
del self.sillyFSM
DistributedToonInterior.disable(self) DistributedToonInterior.disable(self)
def delete(self): def delete(self):
DistributedToonInterior.delete(self) DistributedToonInterior.delete(self)
@magicWord(category=CATEGORY_CREATIVE, types=[int])
def sillyPhase(phase):
"""
Set the silly meter phase.
"""
if phase < -1 or phase > 15:
return 'Phase number must be between 0 and 15!'
messenger.send('SillyMeterPhase', [phase])
return 'Successfully set the silly meter phase!'