From bc5bafbacfce394417b9217b1ca8f9960bb521f6 Mon Sep 17 00:00:00 2001 From: Little Cat Date: Sat, 31 Dec 2022 05:20:47 -0400 Subject: [PATCH] spellbook: Fireworks magic word --- toontown/cogdominium/CogdoFlyingObjects.py | 1 + toontown/cogdominium/CogdoFlyingObstacles.py | 1 + toontown/effects/DistributedFireworkShowAI.py | 40 ++++++----- toontown/effects/FireworkSparkles.py | 1 + toontown/effects/Fireworks.py | 1 + toontown/effects/GlowTrail.py | 1 + toontown/effects/IceCream.py | 1 + toontown/effects/NoiseSparkles.py | 1 + toontown/effects/RingEffect.py | 1 + toontown/effects/SimpleSparkles.py | 1 + toontown/effects/SparksTrail.py | 1 + toontown/effects/SparksTrailLong.py | 1 + toontown/effects/StarBurst.py | 1 + toontown/racing/DistributedVehicle.py | 1 + toontown/racing/Piejectile.py | 1 + toontown/spellbook/MagicWordIndex.py | 67 +++++++++++++++++++ 16 files changed, 103 insertions(+), 18 deletions(-) diff --git a/toontown/cogdominium/CogdoFlyingObjects.py b/toontown/cogdominium/CogdoFlyingObjects.py index 73ac609..98fae9f 100644 --- a/toontown/cogdominium/CogdoFlyingObjects.py +++ b/toontown/cogdominium/CogdoFlyingObjects.py @@ -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 diff --git a/toontown/cogdominium/CogdoFlyingObstacles.py b/toontown/cogdominium/CogdoFlyingObstacles.py index c189998..7072ad0 100644 --- a/toontown/cogdominium/CogdoFlyingObstacles.py +++ b/toontown/cogdominium/CogdoFlyingObstacles.py @@ -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 diff --git a/toontown/effects/DistributedFireworkShowAI.py b/toontown/effects/DistributedFireworkShowAI.py index c305233..a1a6701 100644 --- a/toontown/effects/DistributedFireworkShowAI.py +++ b/toontown/effects/DistributedFireworkShowAI.py @@ -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)) diff --git a/toontown/effects/FireworkSparkles.py b/toontown/effects/FireworkSparkles.py index a35325d..41b26a1 100644 --- a/toontown/effects/FireworkSparkles.py +++ b/toontown/effects/FireworkSparkles.py @@ -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 diff --git a/toontown/effects/Fireworks.py b/toontown/effects/Fireworks.py index ee0f7ae..f628c64 100644 --- a/toontown/effects/Fireworks.py +++ b/toontown/effects/Fireworks.py @@ -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), diff --git a/toontown/effects/GlowTrail.py b/toontown/effects/GlowTrail.py index a049897..c0e9eb4 100644 --- a/toontown/effects/GlowTrail.py +++ b/toontown/effects/GlowTrail.py @@ -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 diff --git a/toontown/effects/IceCream.py b/toontown/effects/IceCream.py index 0f67fd6..d0afda9 100644 --- a/toontown/effects/IceCream.py +++ b/toontown/effects/IceCream.py @@ -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 diff --git a/toontown/effects/NoiseSparkles.py b/toontown/effects/NoiseSparkles.py index 5a6b262..e9822c1 100644 --- a/toontown/effects/NoiseSparkles.py +++ b/toontown/effects/NoiseSparkles.py @@ -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 diff --git a/toontown/effects/RingEffect.py b/toontown/effects/RingEffect.py index 1c844d2..27f7ed1 100644 --- a/toontown/effects/RingEffect.py +++ b/toontown/effects/RingEffect.py @@ -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 diff --git a/toontown/effects/SimpleSparkles.py b/toontown/effects/SimpleSparkles.py index 8e40a22..38e3a42 100644 --- a/toontown/effects/SimpleSparkles.py +++ b/toontown/effects/SimpleSparkles.py @@ -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 diff --git a/toontown/effects/SparksTrail.py b/toontown/effects/SparksTrail.py index 35323fb..dfa8420 100644 --- a/toontown/effects/SparksTrail.py +++ b/toontown/effects/SparksTrail.py @@ -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 diff --git a/toontown/effects/SparksTrailLong.py b/toontown/effects/SparksTrailLong.py index b16fa58..aaf9f45 100644 --- a/toontown/effects/SparksTrailLong.py +++ b/toontown/effects/SparksTrailLong.py @@ -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 diff --git a/toontown/effects/StarBurst.py b/toontown/effects/StarBurst.py index e37ac57..a68520e 100644 --- a/toontown/effects/StarBurst.py +++ b/toontown/effects/StarBurst.py @@ -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 diff --git a/toontown/racing/DistributedVehicle.py b/toontown/racing/DistributedVehicle.py index e3a303e..26c6c4d 100644 --- a/toontown/racing/DistributedVehicle.py +++ b/toontown/racing/DistributedVehicle.py @@ -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 * diff --git a/toontown/racing/Piejectile.py b/toontown/racing/Piejectile.py index d991f96..daf603b 100644 --- a/toontown/racing/Piejectile.py +++ b/toontown/racing/Piejectile.py @@ -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 diff --git a/toontown/spellbook/MagicWordIndex.py b/toontown/spellbook/MagicWordIndex.py index 94e77ef..8ee1667 100644 --- a/toontown/spellbook/MagicWordIndex.py +++ b/toontown/spellbook/MagicWordIndex.py @@ -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()):