diff --git a/etc/toon.dc b/etc/toon.dc index 5c4ed03..ade48bb 100755 --- a/etc/toon.dc +++ b/etc/toon.dc @@ -619,6 +619,7 @@ dclass DistributedToon : DistributedPlayer { setDISLname(string) ram; setDISLid(uint32) ram db airecv; toggleSleep() ownrecv; + magicWordTeleport(uint32) ownrecv; }; dclass DistributedCCharBase : DistributedObject { diff --git a/toontown/spellbook/MagicWordIndex.py b/toontown/spellbook/MagicWordIndex.py index 1e22159..3ac5a78 100644 --- a/toontown/spellbook/MagicWordIndex.py +++ b/toontown/spellbook/MagicWordIndex.py @@ -657,14 +657,12 @@ class GlobalTeleport(MagicWord): class Teleport(MagicWord): aliases = ["tp", "goto"] desc = "Teleport to a specified zone." - execLocation = MagicWordConfig.EXEC_LOC_CLIENT + execLocation = MagicWordConfig.EXEC_LOC_SERVER arguments = [("zoneName", str, False, '')] def handleWord(self, invoker, avId, toon, *args): - from toontown.hood import ZoneUtil from toontown.toonbase import ToontownGlobals zoneName = args[0] - place = base.cr.playGame.getPlace() # Can add stuff like streets to this too if you wanted, but if you do you'll want it to be a valid zone on that street. eg: 2100 is invalid, but any value 2101 to 2156 is fine. # so if you wanted to add a silly street key, theroetically you could do something like this: 'sillystreet': ToontownGlobals.SillyStreet +1, @@ -688,22 +686,10 @@ class Teleport(MagicWord): zone = zoneName2Id[zoneName] except KeyError: return "Unknown zone name!" - - hood = ZoneUtil.getHoodId(zone) - try: - place.requestLeave({'loader': ZoneUtil.getBranchLoaderName(zone), - 'where': ZoneUtil.getToonWhereName(zone), - 'how': 'teleportIn', - 'hoodId': hood, - 'zoneId': zone, - 'shardId': None, - 'avId': -1}) - except Exception: # Most likely cause is the place the person is in has no teleportOut state, for example, boss lobbies. - place.fsm.request('DFAReject') # We have to do this, or the Toon will be stuck. - return f"Unable to teleport {toon.getName()} to zone {zone}." + toon.d_magicWordTeleport(zone) - return f"Successfully teleporting {toon.getName()} to zone {zone}." + return f"Requested to teleport {toon.getName()} to zone {zone}." class ToggleSleep(MagicWord): aliases = ["sleep", "nosleep", "neversleep", "togglesleeping", "insomnia"] diff --git a/toontown/toon/DistributedToon.py b/toontown/toon/DistributedToon.py index 35f1b60..56410d4 100644 --- a/toontown/toon/DistributedToon.py +++ b/toontown/toon/DistributedToon.py @@ -2594,4 +2594,18 @@ class DistributedToon(DistributedPlayer.DistributedPlayer, Toon.Toon, Distribute if base.localAvatar.noSleep: base.localAvatar.noSleep = 0 else: - base.localAvatar.noSleep = 1 \ No newline at end of file + base.localAvatar.noSleep = 1 + + def magicWordTeleport(self, zone): + hood = ZoneUtil.getHoodId(zone) + place = base.cr.playGame.getPlace() + try: + place.requestLeave({'loader': ZoneUtil.getBranchLoaderName(zone), + 'where': ZoneUtil.getToonWhereName(zone), + 'how': 'teleportIn', + 'hoodId': hood, + 'zoneId': zone, + 'shardId': None, + 'avId': -1}) + except Exception: # Most likely cause is the place the person is in has no teleportOut state, for example, boss lobbies. + place.fsm.request('DFAReject') # We have to do this, or the Toon will be stuck. \ No newline at end of file diff --git a/toontown/toon/DistributedToonAI.py b/toontown/toon/DistributedToonAI.py index 79b9990..a1cb233 100644 --- a/toontown/toon/DistributedToonAI.py +++ b/toontown/toon/DistributedToonAI.py @@ -4132,6 +4132,9 @@ class DistributedToonAI(DistributedPlayerAI.DistributedPlayerAI, DistributedSmoo def d_toggleSleep(self): self.sendUpdate('toggleSleep', []) + def d_magicWordTeleport(self, zone): + self.sendUpdate('magicWordTeleport', [zone]) + @staticmethod def staticGetLogicalZoneChangeAllEvent(): return 'DOLogicalChangeZone-all'