spellbook: Fireworks magic word

This commit is contained in:
Little Cat 2022-12-31 05:20:47 -04:00
parent f7c90dde04
commit bc5bafbacf
No known key found for this signature in database
GPG key ID: 96455BD9C4399BE8
16 changed files with 103 additions and 18 deletions

View file

@ -1,5 +1,6 @@
import random
from panda3d.core import *
from panda3d.physics import *
from direct.interval.IntervalGlobal import Sequence, Func, Parallel, Wait, LerpHprInterval, LerpScaleInterval, LerpFunctionInterval
from otp.otpbase import OTPGlobals
from toontown.toonbase import ToontownGlobals

View file

@ -4,6 +4,7 @@ from direct.interval.IntervalGlobal import LerpFunc, ActorInterval, LerpPosInter
from direct.interval.MetaInterval import Sequence
from direct.directutil import Mopath
from panda3d.core import *
from panda3d.physics import *
from toontown.toonbase import ToontownGlobals
from toontown.suit import Suit
from toontown.suit import SuitDNA

View file

@ -4,24 +4,23 @@ from direct.directnotify import DirectNotifyGlobal
from direct.distributed import ClockDelta
from .FireworkShow import FireworkShow
from .FireworkShows import getShowDuration
import random
from direct.task import Task
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)
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.timestamp = None
self.throwAwayShow = FireworkShow()
return
def delete(self):
del self.throwAwayShow
taskMgr.remove(self.taskName('waitForShowDone'))
taskMgr.remove(self.taskName("waitForShowDone"))
DistributedObjectAI.DistributedObjectAI.delete(self)
def d_startShow(self, eventId, style):
@ -29,34 +28,39 @@ class DistributedFireworkShowAI(DistributedObjectAI.DistributedObjectAI):
self.eventId = eventId
self.style = style
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):
duration = getShowDuration(self.eventId, self.style)
taskMgr.doMethodLater(duration, self.fireworkShowDone, self.taskName('waitForShowDone'))
taskMgr.doMethodLater(duration, self.fireworkShowDone, self.taskName("waitForShowDone"))
else:
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
taskMgr.doMethodLater(duration, self.fireworkShowDone, self.taskName('waitForShowDone'))
taskMgr.doMethodLater(duration, self.fireworkShowDone, self.taskName("waitForShowDone"))
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:
self.fireworkMgr.stopShow(self.zoneId)
return Task.done
def requestFirework(self, x, y, z, style, color1, color2):
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.isShowRunning(self.zoneId):
self.d_shootFirework(x, y, z, style, color1, color2)
# Charge the avId some jellybeans
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):
self.sendUpdate('shootFirework', (x,
y,
z,
style,
color1,
color2))
self.sendUpdate("shootFirework", (x, y, z, style, color1, color2))

View file

@ -1,4 +1,5 @@
from panda3d.core import *
from panda3d.physics import *
from direct.interval.IntervalGlobal import *
from direct.particles import ParticleEffect, Particles, ForceGroup
from .EffectController import EffectController

View file

@ -3,6 +3,7 @@ from direct.particles import ParticleEffect
from direct.particles import Particles
from direct.particles import ForceGroup
from panda3d.core import *
from panda3d.physics import *
import random
from .FireworkGlobals import *
colors = {WHITE: Vec4(1, 1, 1, 1),

View file

@ -1,4 +1,5 @@
from panda3d.core import *
from panda3d.physics import *
from direct.interval.IntervalGlobal import *
from direct.particles import ParticleEffect, Particles, ForceGroup
from .PooledEffect import PooledEffect

View file

@ -1,4 +1,5 @@
from panda3d.core import *
from panda3d.physics import *
from direct.interval.IntervalGlobal import *
from direct.particles import ParticleEffect, Particles, ForceGroup
from .EffectController import EffectController

View file

@ -1,4 +1,5 @@
from panda3d.core import *
from panda3d.physics import *
from direct.interval.IntervalGlobal import *
from direct.particles import ParticleEffect, Particles, ForceGroup
from .EffectController import EffectController

View file

@ -1,4 +1,5 @@
from panda3d.core import *
from panda3d.physics import *
from direct.interval.IntervalGlobal import *
from direct.particles import ParticleEffect, Particles, ForceGroup
from .EffectController import EffectController

View file

@ -1,4 +1,5 @@
from panda3d.core import *
from panda3d.physics import *
from direct.interval.IntervalGlobal import *
from direct.particles import ParticleEffect, Particles, ForceGroup
from .EffectController import EffectController

View file

@ -1,4 +1,5 @@
from panda3d.core import *
from panda3d.physics import *
from direct.interval.IntervalGlobal import *
from direct.particles import ParticleEffect, Particles, ForceGroup
from .PooledEffect import PooledEffect

View file

@ -1,4 +1,5 @@
from panda3d.core import *
from panda3d.physics import *
from direct.interval.IntervalGlobal import *
from direct.particles import ParticleEffect, Particles, ForceGroup
from .PooledEffect import PooledEffect

View file

@ -1,4 +1,5 @@
from panda3d.core import *
from panda3d.physics import *
from direct.interval.IntervalGlobal import *
from direct.particles import ParticleEffect, Particles, ForceGroup
from .EffectController import EffectController

View file

@ -4,6 +4,7 @@ from direct.distributed.ClockDelta import *
from direct.interval.IntervalGlobal import *
from direct.gui.DirectGui import *
from panda3d.core import *
from panda3d.physics import *
from direct.fsm import FSM
from direct.distributed import DistributedSmoothNode
from direct.interval.IntervalGlobal import *

View file

@ -4,6 +4,7 @@ from direct.showbase.PythonUtil import *
from direct.showbase.DirectObject import DirectObject
from direct.task import Task
from panda3d.core import *
from panda3d.physics import *
from direct.fsm import FSM
from direct.distributed import DistributedSmoothNode
from otp.avatar import ShadowCaster

View file

@ -554,6 +554,73 @@ class BossBattle(MagicWord):
boss.requestDelete()
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.
# A bit hacky, but better than the old system
for item in list(globals().values()):