spellbook: Update Teleport magic word to be server-sided
This commit is contained in:
parent
48d88e1afe
commit
e16f614b39
4 changed files with 22 additions and 18 deletions
|
@ -619,6 +619,7 @@ dclass DistributedToon : DistributedPlayer {
|
||||||
setDISLname(string) ram;
|
setDISLname(string) ram;
|
||||||
setDISLid(uint32) ram db airecv;
|
setDISLid(uint32) ram db airecv;
|
||||||
toggleSleep() ownrecv;
|
toggleSleep() ownrecv;
|
||||||
|
magicWordTeleport(uint32) ownrecv;
|
||||||
};
|
};
|
||||||
|
|
||||||
dclass DistributedCCharBase : DistributedObject {
|
dclass DistributedCCharBase : DistributedObject {
|
||||||
|
|
|
@ -657,14 +657,12 @@ class GlobalTeleport(MagicWord):
|
||||||
class Teleport(MagicWord):
|
class Teleport(MagicWord):
|
||||||
aliases = ["tp", "goto"]
|
aliases = ["tp", "goto"]
|
||||||
desc = "Teleport to a specified zone."
|
desc = "Teleport to a specified zone."
|
||||||
execLocation = MagicWordConfig.EXEC_LOC_CLIENT
|
execLocation = MagicWordConfig.EXEC_LOC_SERVER
|
||||||
arguments = [("zoneName", str, False, '')]
|
arguments = [("zoneName", str, False, '')]
|
||||||
|
|
||||||
def handleWord(self, invoker, avId, toon, *args):
|
def handleWord(self, invoker, avId, toon, *args):
|
||||||
from toontown.hood import ZoneUtil
|
|
||||||
from toontown.toonbase import ToontownGlobals
|
from toontown.toonbase import ToontownGlobals
|
||||||
zoneName = args[0]
|
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.
|
# 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,
|
# so if you wanted to add a silly street key, theroetically you could do something like this: 'sillystreet': ToontownGlobals.SillyStreet +1,
|
||||||
|
@ -689,21 +687,9 @@ class Teleport(MagicWord):
|
||||||
except KeyError:
|
except KeyError:
|
||||||
return "Unknown zone name!"
|
return "Unknown zone name!"
|
||||||
|
|
||||||
hood = ZoneUtil.getHoodId(zone)
|
toon.d_magicWordTeleport(zone)
|
||||||
|
|
||||||
try:
|
return f"Requested to teleport {toon.getName()} to zone {zone}."
|
||||||
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}."
|
|
||||||
|
|
||||||
return f"Successfully teleporting {toon.getName()} to zone {zone}."
|
|
||||||
|
|
||||||
class ToggleSleep(MagicWord):
|
class ToggleSleep(MagicWord):
|
||||||
aliases = ["sleep", "nosleep", "neversleep", "togglesleeping", "insomnia"]
|
aliases = ["sleep", "nosleep", "neversleep", "togglesleeping", "insomnia"]
|
||||||
|
|
|
@ -2595,3 +2595,17 @@ class DistributedToon(DistributedPlayer.DistributedPlayer, Toon.Toon, Distribute
|
||||||
base.localAvatar.noSleep = 0
|
base.localAvatar.noSleep = 0
|
||||||
else:
|
else:
|
||||||
base.localAvatar.noSleep = 1
|
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.
|
|
@ -4132,6 +4132,9 @@ class DistributedToonAI(DistributedPlayerAI.DistributedPlayerAI, DistributedSmoo
|
||||||
def d_toggleSleep(self):
|
def d_toggleSleep(self):
|
||||||
self.sendUpdate('toggleSleep', [])
|
self.sendUpdate('toggleSleep', [])
|
||||||
|
|
||||||
|
def d_magicWordTeleport(self, zone):
|
||||||
|
self.sendUpdate('magicWordTeleport', [zone])
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def staticGetLogicalZoneChangeAllEvent():
|
def staticGetLogicalZoneChangeAllEvent():
|
||||||
return 'DOLogicalChangeZone-all'
|
return 'DOLogicalChangeZone-all'
|
||||||
|
|
Loading…
Reference in a new issue