spellbook: Teleport directly to a minigame.
This commit is contained in:
parent
8051c15e89
commit
d40ac6840b
3 changed files with 65 additions and 18 deletions
|
@ -319,6 +319,7 @@ class DistributedDivingGame(DistributedMinigame):
|
||||||
for crab in self.crabs:
|
for crab in self.crabs:
|
||||||
crab.moveLerp.finish()
|
crab.moveLerp.finish()
|
||||||
crab.moveLerp = None
|
crab.moveLerp = None
|
||||||
|
crab.cleanup()
|
||||||
crab.removeNode()
|
crab.removeNode()
|
||||||
del crab
|
del crab
|
||||||
|
|
||||||
|
@ -766,6 +767,7 @@ class DistributedDivingGame(DistributedMinigame):
|
||||||
fish.moveLerp.finish()
|
fish.moveLerp.finish()
|
||||||
fish.specialLerp = None
|
fish.specialLerp = None
|
||||||
fish.moveLerp = None
|
fish.moveLerp = None
|
||||||
|
fish.cleanup()
|
||||||
fish.removeNode()
|
fish.removeNode()
|
||||||
del fish
|
del fish
|
||||||
del self.spawners[spawnerId].fishArray[spawnId]
|
del self.spawners[spawnerId].fishArray[spawnId]
|
||||||
|
|
|
@ -111,6 +111,7 @@ class DivingFishSpawn(DirectObject):
|
||||||
fish.sound = None
|
fish.sound = None
|
||||||
fish.moveLerp = None
|
fish.moveLerp = None
|
||||||
fish.specialLerp = None
|
fish.specialLerp = None
|
||||||
|
fish.cleanup()
|
||||||
fish.removeNode()
|
fish.removeNode()
|
||||||
del fish
|
del fish
|
||||||
|
|
||||||
|
|
|
@ -285,7 +285,7 @@ class MaxToon(MagicWord):
|
||||||
return f"Successfully maxed {toon.getName()}!"
|
return f"Successfully maxed {toon.getName()}!"
|
||||||
|
|
||||||
class AbortMinigame(MagicWord):
|
class AbortMinigame(MagicWord):
|
||||||
aliases = ["exitgame", "exitminigame", "quitgame", "quitminigame"]
|
aliases = ["exitgame", "exitminigame", "quitgame", "quitminigame", "skipgame", "skipminigame"]
|
||||||
desc = "Aborts an ongoing minigame."
|
desc = "Aborts an ongoing minigame."
|
||||||
execLocation = MagicWordConfig.EXEC_LOC_CLIENT
|
execLocation = MagicWordConfig.EXEC_LOC_CLIENT
|
||||||
arguments = []
|
arguments = []
|
||||||
|
@ -294,22 +294,49 @@ class AbortMinigame(MagicWord):
|
||||||
messenger.send("minigameAbort")
|
messenger.send("minigameAbort")
|
||||||
return "Requested minigame abort."
|
return "Requested minigame abort."
|
||||||
|
|
||||||
class RequestMinigame(MagicWord):
|
class Minigame(MagicWord):
|
||||||
aliases = ["minigame"]
|
aliases = ["mg"]
|
||||||
desc = "Requests a specified trolley minigame to be loaded."
|
desc = "Teleport to or request the next trolley minigame."
|
||||||
execLocation = MagicWordConfig.EXEC_LOC_SERVER
|
execLocation = MagicWordConfig.EXEC_LOC_SERVER
|
||||||
arguments = [("minigame", str, True), ("difficulty", float, False, 0)]
|
arguments = [("command", str, True), ("minigame", str, False, ''), ("difficulty", float, False, 0)]
|
||||||
|
|
||||||
def handleWord(self, invoker, avId, toon, *args):
|
def handleWord(self, invoker, avId, toon, *args):
|
||||||
minigame = args[0]
|
command = args[0]
|
||||||
difficulty = args[1]
|
minigame = args[1]
|
||||||
|
difficulty = args[2]
|
||||||
mgId = None
|
|
||||||
mgDiff = None if args[1] == 0 else args[1]
|
|
||||||
mgKeep = None
|
|
||||||
mgSzId = None
|
|
||||||
|
|
||||||
from toontown.toonbase import ToontownGlobals
|
from toontown.toonbase import ToontownGlobals
|
||||||
|
from toontown.hood import ZoneUtil
|
||||||
|
from toontown.minigame import MinigameCreatorAI
|
||||||
|
if command in ToontownGlobals.MinigameNames:
|
||||||
|
# Shortcut
|
||||||
|
minigame = args[0]
|
||||||
|
try:
|
||||||
|
difficulty = float(args[2])
|
||||||
|
except ValueError:
|
||||||
|
difficulty = 0
|
||||||
|
|
||||||
|
if toon.zoneId in MinigameCreatorAI.MinigameZoneRefs:
|
||||||
|
# Already in minigame zone, assume request
|
||||||
|
command = "request"
|
||||||
|
elif toon.zoneId == ZoneUtil.getSafeZoneId(toon.zoneId):
|
||||||
|
# Assume teleport
|
||||||
|
command = "teleport"
|
||||||
|
else:
|
||||||
|
# Request by default
|
||||||
|
command = "request"
|
||||||
|
|
||||||
|
isTeleport = command in ('teleport', 'tp')
|
||||||
|
isRequest = command in ('request', 'next')
|
||||||
|
|
||||||
|
mgId = None
|
||||||
|
mgDiff = None if difficulty == 0 else difficulty
|
||||||
|
mgKeep = None
|
||||||
|
mgSzId = ZoneUtil.getSafeZoneId(toon.zoneId) if isTeleport else None
|
||||||
|
|
||||||
|
if not any ((isTeleport, isRequest)):
|
||||||
|
return f"Unknown command or minigame \"{command}\". Valid commands: \"teleport\", \"request\", or a minigame to automatically teleport or request"
|
||||||
|
|
||||||
try:
|
try:
|
||||||
mgId = int(minigame)
|
mgId = int(minigame)
|
||||||
if mgId not in ToontownGlobals.MinigameIDs:
|
if mgId not in ToontownGlobals.MinigameIDs:
|
||||||
|
@ -319,12 +346,29 @@ class RequestMinigame(MagicWord):
|
||||||
return f"Unknown minigame name \"{minigame}\"."
|
return f"Unknown minigame name \"{minigame}\"."
|
||||||
mgId = ToontownGlobals.MinigameNames.get(minigame)
|
mgId = ToontownGlobals.MinigameNames.get(minigame)
|
||||||
|
|
||||||
from toontown.minigame import MinigameCreatorAI
|
if any((isTeleport, isRequest)):
|
||||||
MinigameCreatorAI.RequestMinigame[avId] = (mgId, mgKeep, mgDiff, mgSzId)
|
if isTeleport and (ZoneUtil.isDynamicZone(toon.zoneId) or not toon.zoneId == mgSzId):
|
||||||
retStr = f"Successfully requested minigame \"{minigame}\""
|
return "Target needs to be in a playground to teleport to a minigame."
|
||||||
if mgDiff:
|
MinigameCreatorAI.RequestMinigame[avId] = (mgId, mgKeep, mgDiff, mgSzId)
|
||||||
retStr += f" with difficulty {mgDiff}"
|
if isTeleport:
|
||||||
return retStr + "."
|
try:
|
||||||
|
result = MinigameCreatorAI.createMinigame(self.air, [avId], mgSzId)
|
||||||
|
except:
|
||||||
|
return f"Unable to create \"{minigame}\" minigame"
|
||||||
|
|
||||||
|
minigameZone = result['minigameZone']
|
||||||
|
retStr = f"Teleporting {toon.getName()} to minigame \"{minigame}\""
|
||||||
|
if mgDiff:
|
||||||
|
retStr += f" with difficulty {mgDiff}"
|
||||||
|
return retStr + "...", avId, ["minigame", "minigame", "", mgSzId, minigameZone, 0]
|
||||||
|
|
||||||
|
# isRequest
|
||||||
|
retStr = f"Successfully requested minigame \"{minigame}\""
|
||||||
|
if mgDiff:
|
||||||
|
retStr += f" with difficulty {mgDiff}"
|
||||||
|
return retStr + "."
|
||||||
|
|
||||||
|
return f"Unknown command or minigame \"{command}\". Valid commands: \"teleport\", \"request\", or a minigame to automatically teleport or request"
|
||||||
|
|
||||||
class Quests(MagicWord):
|
class Quests(MagicWord):
|
||||||
aliases = ["quest", "tasks", "task", "toontasks"]
|
aliases = ["quest", "tasks", "task", "toontasks"]
|
||||||
|
|
Loading…
Reference in a new issue