diff --git a/etc/toon.dc b/etc/toon.dc index e972695..9e0fef8 100755 --- a/etc/toon.dc +++ b/etc/toon.dc @@ -1409,6 +1409,7 @@ dclass ToontownMagicWordManager : DistributedObject { requestExecuteMagicWord(int8, int8, int16, uint32, string) airecv clsend; executeMagicWord(string, string, uint32[], blob, int8, int8, int16, uint32); generateResponse(string, string, blob, string, int8, int8, int16, uint32, string); + teleportResponse(string loaderId, string whereId, string how, uint32 hoodId, uint32 zoneId, uint32 avId); }; struct weeklyCalendarHoliday { diff --git a/toontown/spellbook/ToontownMagicWordManager.py b/toontown/spellbook/ToontownMagicWordManager.py index bf32b8b..9a53d36 100644 --- a/toontown/spellbook/ToontownMagicWordManager.py +++ b/toontown/spellbook/ToontownMagicWordManager.py @@ -259,3 +259,27 @@ class ToontownMagicWordManager(DistributedObject.DistributedObject): else: self.generateResponse(responseType="SuccessNoResp", magicWord=word, args=args, affectRange=affectRange, affectType=affectType, affectExtra=affectExtra, lastClickedAvId=lastClickedAvId) + + def teleportResponse(self, loaderId, whereId, how, hoodId, zoneId, avId): + # The AI tells the avatar to go somewhere. This is probably in + # response to a magic word requesting transfer to a zone. + + place = base.cr.playGame.getPlace() + if loaderId == "": + loaderId = ZoneUtil.getBranchLoaderName(zoneId) + if whereId == "": + whereId = ZoneUtil.getToonWhereName(zoneId) + if how == "": + how = "teleportIn" + if hoodId == 0: + hoodId = place.loader.hood.id + if avId == 0: + avId = -1 + place.fsm.forceTransition('teleportOut', + [{"loader": loaderId, + "where": whereId, + "how": how, + "hoodId": hoodId, + "zoneId": zoneId, + "shardId": None, + "avId": avId}]) diff --git a/toontown/spellbook/ToontownMagicWordManagerAI.py b/toontown/spellbook/ToontownMagicWordManagerAI.py index 25f50e8..86583df 100644 --- a/toontown/spellbook/ToontownMagicWordManagerAI.py +++ b/toontown/spellbook/ToontownMagicWordManagerAI.py @@ -273,7 +273,15 @@ class ToontownMagicWordManagerAI(DistributedObjectAI.DistributedObjectAI): returnValue = command.executeWord() # If we have a return value, pass it over to the invoker if returnValue: - self.generateResponse(avId=avId, responseType="Success", returnValue=returnValue) + # If the word returns more than one values, assume that the word wants to teleport the target somewhere. + if type(returnValue) is tuple: + teleportingAvId = avId + if len(returnValue) == 3: + teleportingAvId = returnValue[1] + self.sendTeleportResponse(teleportingAvId, *returnValue[-1]) + self.generateResponse(avId=avId, responseType="Success", returnValue=returnValue[0]) + else: + self.generateResponse(avId=avId, responseType="Success", returnValue=returnValue) # Otherwise just throw a default response to them else: self.generateResponse(avId=avId, responseType="SuccessNoResp", magicWord=magicWord, @@ -296,3 +304,6 @@ class ToontownMagicWordManagerAI(DistributedObjectAI.DistributedObjectAI): # Execute the Magic Word on the client, because it's a client-sided Magic Word self.sendUpdateToAvatarId(avId, "executeMagicWord", [word, commandName, targetIds, parsedArgList, affectRange, affectType, affectExtra, lastClickedAvId]) + + def sendTeleportResponse(self, avId, loaderId, whereId, how, hoodId, zoneId, targetAvId): + self.sendUpdateToAvatarId(avId, "teleportResponse", [loaderId, whereId, how, hoodId, zoneId, targetAvId])