spellbook: Fix Teleport command redundancies, add support for BossBattle targeting

This commit is contained in:
Samuel T 2023-11-09 03:46:35 +00:00
parent ff220f7f5f
commit ecf87d34b3
5 changed files with 16 additions and 32 deletions

View file

@ -619,7 +619,6 @@ 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 {

View file

@ -555,7 +555,7 @@ class BossBattle(MagicWord):
if not start: if not start:
respText += " in Frolic state" respText += " in Frolic state"
return respText + ", teleporting...", ["cogHQLoader", "cogHQBossBattle", "movie" if start else "teleportIn", boss.getHoodId(), boss.zoneId, 0] return respText + ", teleporting...", toon.doId, ["cogHQLoader", "cogHQBossBattle", "movie" if start else "teleportIn", boss.getHoodId(), boss.zoneId, 0]
elif command == "list": elif command == "list":
# List all the ongoing boss battles. # List all the ongoing boss battles.
@ -597,7 +597,7 @@ class BossBattle(MagicWord):
return "Index out of range!" return "Index out of range!"
boss = AllBossCogs[index] boss = AllBossCogs[index]
return "Teleporting to boss battle...", ["cogHQLoader", "cogHQBossBattle", "", boss.getHoodId(), boss.zoneId, 0] return "Teleporting to boss battle...", toon.doId, ["cogHQLoader", "cogHQBossBattle", "", boss.getHoodId(), boss.zoneId, 0]
# The following commands needs the invoker to be in a boss battle. # The following commands needs the invoker to be in a boss battle.
@ -661,6 +661,7 @@ class Teleport(MagicWord):
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]
@ -686,10 +687,8 @@ class Teleport(MagicWord):
zone = zoneName2Id[zoneName] zone = zoneName2Id[zoneName]
except KeyError: except KeyError:
return "Unknown zone name!" return "Unknown zone name!"
toon.d_magicWordTeleport(zone)
return f"Requested to teleport {toon.getName()} to zone {zone}." return f"Requested to teleport {toon.getName()} to zone {zone}.", toon.doId, [ZoneUtil.getBranchLoaderName(zone), ZoneUtil.getToonWhereName(zone), "", ZoneUtil.getHoodId(zone), zone, 0]
class ToggleSleep(MagicWord): class ToggleSleep(MagicWord):
aliases = ["sleep", "nosleep", "neversleep", "togglesleeping", "insomnia"] aliases = ["sleep", "nosleep", "neversleep", "togglesleeping", "insomnia"]

View file

@ -275,11 +275,14 @@ class ToontownMagicWordManager(DistributedObject.DistributedObject):
hoodId = place.loader.hood.id hoodId = place.loader.hood.id
if avId == 0: if avId == 0:
avId = -1 avId = -1
place.fsm.forceTransition('teleportOut', try:
[{"loader": loaderId, place.fsm.forceTransition('teleportOut',
"where": whereId, [{"loader": loaderId,
"how": how, "where": whereId,
"hoodId": hoodId, "how": how,
"zoneId": zoneId, "hoodId": hoodId,
"shardId": None, "zoneId": zoneId,
"avId": avId}]) "shardId": None,
"avId": avId}])
except Exception: # Most likely cause is the place the avatar is in has no teleportOut state, for example, boss lobbies.
place.fsm.request('DFAReject') # We have to do this, or the avatar will be stuck.

View file

@ -2591,18 +2591,4 @@ class DistributedToon(DistributedPlayer.DistributedPlayer, Toon.Toon, Distribute
return self.transitioning return self.transitioning
def toggleSleep(self): def toggleSleep(self):
base.localAvatar.noSleep = not base.localAvatar.noSleep base.localAvatar.noSleep = not base.localAvatar.noSleep
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.

View file

@ -4136,9 +4136,6 @@ 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'