spellbook: Fireworks magic word
This commit is contained in:
parent
f7c90dde04
commit
bc5bafbacf
16 changed files with 103 additions and 18 deletions
|
@ -1,5 +1,6 @@
|
||||||
import random
|
import random
|
||||||
from panda3d.core import *
|
from panda3d.core import *
|
||||||
|
from panda3d.physics import *
|
||||||
from direct.interval.IntervalGlobal import Sequence, Func, Parallel, Wait, LerpHprInterval, LerpScaleInterval, LerpFunctionInterval
|
from direct.interval.IntervalGlobal import Sequence, Func, Parallel, Wait, LerpHprInterval, LerpScaleInterval, LerpFunctionInterval
|
||||||
from otp.otpbase import OTPGlobals
|
from otp.otpbase import OTPGlobals
|
||||||
from toontown.toonbase import ToontownGlobals
|
from toontown.toonbase import ToontownGlobals
|
||||||
|
|
|
@ -4,6 +4,7 @@ from direct.interval.IntervalGlobal import LerpFunc, ActorInterval, LerpPosInter
|
||||||
from direct.interval.MetaInterval import Sequence
|
from direct.interval.MetaInterval import Sequence
|
||||||
from direct.directutil import Mopath
|
from direct.directutil import Mopath
|
||||||
from panda3d.core import *
|
from panda3d.core import *
|
||||||
|
from panda3d.physics import *
|
||||||
from toontown.toonbase import ToontownGlobals
|
from toontown.toonbase import ToontownGlobals
|
||||||
from toontown.suit import Suit
|
from toontown.suit import Suit
|
||||||
from toontown.suit import SuitDNA
|
from toontown.suit import SuitDNA
|
||||||
|
|
|
@ -4,24 +4,23 @@ from direct.directnotify import DirectNotifyGlobal
|
||||||
from direct.distributed import ClockDelta
|
from direct.distributed import ClockDelta
|
||||||
from .FireworkShow import FireworkShow
|
from .FireworkShow import FireworkShow
|
||||||
from .FireworkShows import getShowDuration
|
from .FireworkShows import getShowDuration
|
||||||
import random
|
|
||||||
from direct.task import Task
|
from direct.task import Task
|
||||||
|
|
||||||
class DistributedFireworkShowAI(DistributedObjectAI.DistributedObjectAI):
|
class DistributedFireworkShowAI(DistributedObjectAI.DistributedObjectAI):
|
||||||
notify = DirectNotifyGlobal.directNotify.newCategory('DistributedFireworkShowAI')
|
|
||||||
|
|
||||||
def __init__(self, air, fireworkMgr = None):
|
notify = DirectNotifyGlobal.directNotify.newCategory("DistributedFireworkShowAI")
|
||||||
|
def __init__(self, air, fireworkMgr=None):
|
||||||
DistributedObjectAI.DistributedObjectAI.__init__(self, air)
|
DistributedObjectAI.DistributedObjectAI.__init__(self, air)
|
||||||
self.fireworkMgr = fireworkMgr
|
self.fireworkMgr = fireworkMgr
|
||||||
self.eventId = None
|
self.eventId = None # either a holiday name constant from ToontownGlobals
|
||||||
|
# or a FireworkShows from PartyGlobals
|
||||||
self.style = None
|
self.style = None
|
||||||
self.timestamp = None
|
self.timestamp = None
|
||||||
self.throwAwayShow = FireworkShow()
|
self.throwAwayShow = FireworkShow()
|
||||||
return
|
|
||||||
|
|
||||||
def delete(self):
|
def delete(self):
|
||||||
del self.throwAwayShow
|
del self.throwAwayShow
|
||||||
taskMgr.remove(self.taskName('waitForShowDone'))
|
taskMgr.remove(self.taskName("waitForShowDone"))
|
||||||
DistributedObjectAI.DistributedObjectAI.delete(self)
|
DistributedObjectAI.DistributedObjectAI.delete(self)
|
||||||
|
|
||||||
def d_startShow(self, eventId, style):
|
def d_startShow(self, eventId, style):
|
||||||
|
@ -29,34 +28,39 @@ class DistributedFireworkShowAI(DistributedObjectAI.DistributedObjectAI):
|
||||||
self.eventId = eventId
|
self.eventId = eventId
|
||||||
self.style = style
|
self.style = style
|
||||||
self.timestamp = timestamp
|
self.timestamp = timestamp
|
||||||
self.sendUpdate('startShow', (self.eventId, self.style, self.timestamp))
|
self.sendUpdate("startShow",
|
||||||
|
(self.eventId, self.style, self.timestamp))
|
||||||
if simbase.air.config.GetBool('want-old-fireworks', 0):
|
if simbase.air.config.GetBool('want-old-fireworks', 0):
|
||||||
duration = getShowDuration(self.eventId, self.style)
|
duration = getShowDuration(self.eventId, self.style)
|
||||||
taskMgr.doMethodLater(duration, self.fireworkShowDone, self.taskName('waitForShowDone'))
|
taskMgr.doMethodLater(duration, self.fireworkShowDone, self.taskName("waitForShowDone"))
|
||||||
else:
|
else:
|
||||||
|
|
||||||
duration = self.throwAwayShow.getShowDuration(self.eventId)
|
duration = self.throwAwayShow.getShowDuration(self.eventId)
|
||||||
|
|
||||||
|
assert( DistributedFireworkShowAI.notify.debug("startShow: event: %s, networkTime: %s, showDuration: %s" \
|
||||||
|
% (self.eventId, self.timestamp, duration) ) )
|
||||||
|
|
||||||
|
# Add the start and postShow delays and give ample time for postshow to complete
|
||||||
duration += 20.0
|
duration += 20.0
|
||||||
taskMgr.doMethodLater(duration, self.fireworkShowDone, self.taskName('waitForShowDone'))
|
taskMgr.doMethodLater(duration, self.fireworkShowDone, self.taskName("waitForShowDone"))
|
||||||
|
|
||||||
def fireworkShowDone(self, task):
|
def fireworkShowDone(self, task):
|
||||||
self.notify.debug('fireworkShowDone')
|
self.notify.debug("fireworkShowDone")
|
||||||
|
# Tell the firework manager to stop us, we are done
|
||||||
if self.fireworkMgr:
|
if self.fireworkMgr:
|
||||||
self.fireworkMgr.stopShow(self.zoneId)
|
self.fireworkMgr.stopShow(self.zoneId)
|
||||||
return Task.done
|
return Task.done
|
||||||
|
|
||||||
def requestFirework(self, x, y, z, style, color1, color2):
|
def requestFirework(self, x, y, z, style, color1, color2):
|
||||||
avId = self.air.getAvatarIdFromSender()
|
avId = self.air.getAvatarIdFromSender()
|
||||||
self.notify.debug('requestFirework: avId: %s, style: %s' % (avId, style))
|
self.notify.debug("requestFirework: avId: %s, style: %s" % (avId, style))
|
||||||
|
# TODO: check permissions, check cost, etc
|
||||||
if self.fireworkMgr:
|
if self.fireworkMgr:
|
||||||
if self.fireworkMgr.isShowRunning(self.zoneId):
|
if self.fireworkMgr.isShowRunning(self.zoneId):
|
||||||
self.d_shootFirework(x, y, z, style, color1, color2)
|
self.d_shootFirework(x, y, z, style, color1, color2)
|
||||||
|
# Charge the avId some jellybeans
|
||||||
else:
|
else:
|
||||||
self.d_shootFirework(x, y, z, style, color1, color2)
|
self.d_shootFirework(x, y, z, style, color1,color2)
|
||||||
|
|
||||||
def d_shootFirework(self, x, y, z, style, color1, color2):
|
def d_shootFirework(self, x, y, z, style, color1, color2):
|
||||||
self.sendUpdate('shootFirework', (x,
|
self.sendUpdate("shootFirework", (x, y, z, style, color1, color2))
|
||||||
y,
|
|
||||||
z,
|
|
||||||
style,
|
|
||||||
color1,
|
|
||||||
color2))
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
from panda3d.core import *
|
from panda3d.core import *
|
||||||
|
from panda3d.physics import *
|
||||||
from direct.interval.IntervalGlobal import *
|
from direct.interval.IntervalGlobal import *
|
||||||
from direct.particles import ParticleEffect, Particles, ForceGroup
|
from direct.particles import ParticleEffect, Particles, ForceGroup
|
||||||
from .EffectController import EffectController
|
from .EffectController import EffectController
|
||||||
|
|
|
@ -3,6 +3,7 @@ from direct.particles import ParticleEffect
|
||||||
from direct.particles import Particles
|
from direct.particles import Particles
|
||||||
from direct.particles import ForceGroup
|
from direct.particles import ForceGroup
|
||||||
from panda3d.core import *
|
from panda3d.core import *
|
||||||
|
from panda3d.physics import *
|
||||||
import random
|
import random
|
||||||
from .FireworkGlobals import *
|
from .FireworkGlobals import *
|
||||||
colors = {WHITE: Vec4(1, 1, 1, 1),
|
colors = {WHITE: Vec4(1, 1, 1, 1),
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
from panda3d.core import *
|
from panda3d.core import *
|
||||||
|
from panda3d.physics import *
|
||||||
from direct.interval.IntervalGlobal import *
|
from direct.interval.IntervalGlobal import *
|
||||||
from direct.particles import ParticleEffect, Particles, ForceGroup
|
from direct.particles import ParticleEffect, Particles, ForceGroup
|
||||||
from .PooledEffect import PooledEffect
|
from .PooledEffect import PooledEffect
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
from panda3d.core import *
|
from panda3d.core import *
|
||||||
|
from panda3d.physics import *
|
||||||
from direct.interval.IntervalGlobal import *
|
from direct.interval.IntervalGlobal import *
|
||||||
from direct.particles import ParticleEffect, Particles, ForceGroup
|
from direct.particles import ParticleEffect, Particles, ForceGroup
|
||||||
from .EffectController import EffectController
|
from .EffectController import EffectController
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
from panda3d.core import *
|
from panda3d.core import *
|
||||||
|
from panda3d.physics import *
|
||||||
from direct.interval.IntervalGlobal import *
|
from direct.interval.IntervalGlobal import *
|
||||||
from direct.particles import ParticleEffect, Particles, ForceGroup
|
from direct.particles import ParticleEffect, Particles, ForceGroup
|
||||||
from .EffectController import EffectController
|
from .EffectController import EffectController
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
from panda3d.core import *
|
from panda3d.core import *
|
||||||
|
from panda3d.physics import *
|
||||||
from direct.interval.IntervalGlobal import *
|
from direct.interval.IntervalGlobal import *
|
||||||
from direct.particles import ParticleEffect, Particles, ForceGroup
|
from direct.particles import ParticleEffect, Particles, ForceGroup
|
||||||
from .EffectController import EffectController
|
from .EffectController import EffectController
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
from panda3d.core import *
|
from panda3d.core import *
|
||||||
|
from panda3d.physics import *
|
||||||
from direct.interval.IntervalGlobal import *
|
from direct.interval.IntervalGlobal import *
|
||||||
from direct.particles import ParticleEffect, Particles, ForceGroup
|
from direct.particles import ParticleEffect, Particles, ForceGroup
|
||||||
from .EffectController import EffectController
|
from .EffectController import EffectController
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
from panda3d.core import *
|
from panda3d.core import *
|
||||||
|
from panda3d.physics import *
|
||||||
from direct.interval.IntervalGlobal import *
|
from direct.interval.IntervalGlobal import *
|
||||||
from direct.particles import ParticleEffect, Particles, ForceGroup
|
from direct.particles import ParticleEffect, Particles, ForceGroup
|
||||||
from .PooledEffect import PooledEffect
|
from .PooledEffect import PooledEffect
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
from panda3d.core import *
|
from panda3d.core import *
|
||||||
|
from panda3d.physics import *
|
||||||
from direct.interval.IntervalGlobal import *
|
from direct.interval.IntervalGlobal import *
|
||||||
from direct.particles import ParticleEffect, Particles, ForceGroup
|
from direct.particles import ParticleEffect, Particles, ForceGroup
|
||||||
from .PooledEffect import PooledEffect
|
from .PooledEffect import PooledEffect
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
from panda3d.core import *
|
from panda3d.core import *
|
||||||
|
from panda3d.physics import *
|
||||||
from direct.interval.IntervalGlobal import *
|
from direct.interval.IntervalGlobal import *
|
||||||
from direct.particles import ParticleEffect, Particles, ForceGroup
|
from direct.particles import ParticleEffect, Particles, ForceGroup
|
||||||
from .EffectController import EffectController
|
from .EffectController import EffectController
|
||||||
|
|
|
@ -4,6 +4,7 @@ from direct.distributed.ClockDelta import *
|
||||||
from direct.interval.IntervalGlobal import *
|
from direct.interval.IntervalGlobal import *
|
||||||
from direct.gui.DirectGui import *
|
from direct.gui.DirectGui import *
|
||||||
from panda3d.core import *
|
from panda3d.core import *
|
||||||
|
from panda3d.physics import *
|
||||||
from direct.fsm import FSM
|
from direct.fsm import FSM
|
||||||
from direct.distributed import DistributedSmoothNode
|
from direct.distributed import DistributedSmoothNode
|
||||||
from direct.interval.IntervalGlobal import *
|
from direct.interval.IntervalGlobal import *
|
||||||
|
|
|
@ -4,6 +4,7 @@ from direct.showbase.PythonUtil import *
|
||||||
from direct.showbase.DirectObject import DirectObject
|
from direct.showbase.DirectObject import DirectObject
|
||||||
from direct.task import Task
|
from direct.task import Task
|
||||||
from panda3d.core import *
|
from panda3d.core import *
|
||||||
|
from panda3d.physics import *
|
||||||
from direct.fsm import FSM
|
from direct.fsm import FSM
|
||||||
from direct.distributed import DistributedSmoothNode
|
from direct.distributed import DistributedSmoothNode
|
||||||
from otp.avatar import ShadowCaster
|
from otp.avatar import ShadowCaster
|
||||||
|
|
|
@ -554,6 +554,73 @@ class BossBattle(MagicWord):
|
||||||
boss.requestDelete()
|
boss.requestDelete()
|
||||||
self.air.deallocateZone(bossZone)
|
self.air.deallocateZone(bossZone)
|
||||||
|
|
||||||
|
class Fireworks(MagicWord):
|
||||||
|
aliases = ["firework"]
|
||||||
|
desc = "Starts a firework show."
|
||||||
|
execLocation = MagicWordConfig.EXEC_LOC_SERVER
|
||||||
|
arguments = [("name", str, False, "newyear"), ("hood", str, False, "")]
|
||||||
|
|
||||||
|
# List of firework shows currently in progress
|
||||||
|
fireworkShows = {}
|
||||||
|
|
||||||
|
def handleWord(self, invoker, avId, toon, *args):
|
||||||
|
name = args[0]
|
||||||
|
hood = args[1]
|
||||||
|
|
||||||
|
from toontown.toonbase import ToontownGlobals
|
||||||
|
from toontown.parties import PartyGlobals
|
||||||
|
name2showId = {
|
||||||
|
'newyear': ToontownGlobals.NEWYEARS_FIREWORKS,
|
||||||
|
'newyears': ToontownGlobals.NEWYEARS_FIREWORKS,
|
||||||
|
'summer': ToontownGlobals.JULY4_FIREWORKS,
|
||||||
|
'combo': ToontownGlobals.COMBO_FIREWORKS,
|
||||||
|
'party': PartyGlobals.FireworkShows.Summer
|
||||||
|
}
|
||||||
|
|
||||||
|
if name not in name2showId:
|
||||||
|
return f"Unknown firework name \"{name}\". Valid names: {list(name2showId.keys())}"
|
||||||
|
showId = name2showId[name]
|
||||||
|
|
||||||
|
zoneToStyleDict = {
|
||||||
|
ToontownGlobals.DonaldsDock : 5,
|
||||||
|
ToontownGlobals.ToontownCentral : 0,
|
||||||
|
ToontownGlobals.TheBrrrgh : 4,
|
||||||
|
ToontownGlobals.MinniesMelodyland : 3,
|
||||||
|
ToontownGlobals.DaisyGardens : 1,
|
||||||
|
ToontownGlobals.OutdoorZone : 0,
|
||||||
|
ToontownGlobals.GoofySpeedway : 0,
|
||||||
|
ToontownGlobals.DonaldsDreamland : 2
|
||||||
|
}
|
||||||
|
|
||||||
|
from toontown.hood import ZoneUtil
|
||||||
|
zones = []
|
||||||
|
if not hood:
|
||||||
|
zones = (toon.zoneId,)
|
||||||
|
elif hood == "all":
|
||||||
|
zones = zoneToStyleDict.keys()
|
||||||
|
else:
|
||||||
|
return "Missing hood argument."
|
||||||
|
|
||||||
|
# Generate our firework shows
|
||||||
|
from toontown.effects.DistributedFireworkShowAI import DistributedFireworkShowAI
|
||||||
|
count = 0
|
||||||
|
for zone in zones:
|
||||||
|
if zone not in self.fireworkShows:
|
||||||
|
show = DistributedFireworkShowAI(self.air, self)
|
||||||
|
show.generateWithRequired(zone)
|
||||||
|
self.fireworkShows[zone] = show
|
||||||
|
show.d_startShow(showId, zoneToStyleDict.get(zone, 0))
|
||||||
|
count += 1
|
||||||
|
|
||||||
|
return f"Started firework {'show' if count == 1 else 'shows'} in {count} {'zone' if count == 1 else 'zones'}!"
|
||||||
|
|
||||||
|
def stopShow(self, zoneId):
|
||||||
|
if zoneId in self.fireworkShows:
|
||||||
|
show = self.fireworkShows[zoneId]
|
||||||
|
show.requestDelete()
|
||||||
|
del self.fireworkShows[zoneId]
|
||||||
|
|
||||||
|
|
||||||
# Instantiate all classes defined here to register them.
|
# Instantiate all classes defined here to register them.
|
||||||
# A bit hacky, but better than the old system
|
# A bit hacky, but better than the old system
|
||||||
for item in list(globals().values()):
|
for item in list(globals().values()):
|
||||||
|
|
Loading…
Reference in a new issue