spellbook: Server-sided teleportation.

This commit is contained in:
Little Cat 2022-12-28 19:10:34 -04:00
parent 9a95da5bfb
commit 5c0ca00131
No known key found for this signature in database
GPG key ID: 96455BD9C4399BE8
3 changed files with 37 additions and 1 deletions

View file

@ -1409,6 +1409,7 @@ dclass ToontownMagicWordManager : DistributedObject {
requestExecuteMagicWord(int8, int8, int16, uint32, string) airecv clsend; requestExecuteMagicWord(int8, int8, int16, uint32, string) airecv clsend;
executeMagicWord(string, string, uint32[], blob, int8, int8, int16, uint32); executeMagicWord(string, string, uint32[], blob, int8, int8, int16, uint32);
generateResponse(string, string, blob, string, int8, int8, int16, uint32, string); 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 { struct weeklyCalendarHoliday {

View file

@ -259,3 +259,27 @@ class ToontownMagicWordManager(DistributedObject.DistributedObject):
else: else:
self.generateResponse(responseType="SuccessNoResp", magicWord=word, args=args, affectRange=affectRange, self.generateResponse(responseType="SuccessNoResp", magicWord=word, args=args, affectRange=affectRange,
affectType=affectType, affectExtra=affectExtra, lastClickedAvId=lastClickedAvId) 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}])

View file

@ -273,7 +273,15 @@ class ToontownMagicWordManagerAI(DistributedObjectAI.DistributedObjectAI):
returnValue = command.executeWord() returnValue = command.executeWord()
# If we have a return value, pass it over to the invoker # If we have a return value, pass it over to the invoker
if returnValue: 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 # Otherwise just throw a default response to them
else: else:
self.generateResponse(avId=avId, responseType="SuccessNoResp", magicWord=magicWord, 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 # Execute the Magic Word on the client, because it's a client-sided Magic Word
self.sendUpdateToAvatarId(avId, "executeMagicWord", [word, commandName, targetIds, parsedArgList, affectRange, self.sendUpdateToAvatarId(avId, "executeMagicWord", [word, commandName, targetIds, parsedArgList, affectRange,
affectType, affectExtra, lastClickedAvId]) affectType, affectExtra, lastClickedAvId])
def sendTeleportResponse(self, avId, loaderId, whereId, how, hoodId, zoneId, targetAvId):
self.sendUpdateToAvatarId(avId, "teleportResponse", [loaderId, whereId, how, hoodId, zoneId, targetAvId])