PartyGate: Party gate now works
With help from Anesidora code
This commit is contained in:
parent
e321cc5070
commit
5ae11922bb
|
|
@ -47,6 +47,7 @@ from toontown.racing.DistributedViewPadAI import DistributedViewPadAI
|
|||
from toontown.racing.RaceManagerAI import RaceManagerAI
|
||||
from toontown.uberdog.DistributedPartyManagerAI import DistributedPartyManagerAI
|
||||
from toontown.safezone.SafeZoneManagerAI import SafeZoneManagerAI
|
||||
from toontown.safezone import DistributedPartyGateAI
|
||||
from toontown.shtiker.CogPageManagerAI import CogPageManagerAI
|
||||
from toontown.spellbook.ToontownMagicWordManagerAI import ToontownMagicWordManagerAI
|
||||
from toontown.suit.SuitInvasionManagerAI import SuitInvasionManagerAI
|
||||
|
|
@ -408,7 +409,24 @@ class ToontownAIRepository(ToontownInternalRepository):
|
|||
return [] # TODO
|
||||
|
||||
def findPartyHats(self, dnaData, zoneId):
|
||||
return [] # TODO
|
||||
partyHats = []
|
||||
if 'party_gate' in dnaData.getName():
|
||||
x, y, z = dnaData.getPos()
|
||||
h, p, r = dnaData.getHpr()
|
||||
partyHat = DistributedPartyGateAI.DistributedPartyGateAI(self)
|
||||
partyHat.generateWithRequired(zoneId)
|
||||
partyHats.append(partyHat)
|
||||
else:
|
||||
if isinstance(dnaData, DNAVisGroup):
|
||||
name = dnaData.getName()
|
||||
visId = int(name.split(":", 1)[0]) % 1000
|
||||
zoneId = ZoneUtil.getHoodId(zoneId) + visId
|
||||
|
||||
for i in range(dnaData.getNumChildren()):
|
||||
foundPartyHats = self.findPartyHats(dnaData.at(i), zoneId)
|
||||
partyHats.extend(foundPartyHats)
|
||||
|
||||
return partyHats
|
||||
|
||||
def findRacingPads(self, dnaData, zoneId, area, type='racing_pad', overrideDNAZone=False):
|
||||
kartPads, kartPadGroups = [], []
|
||||
|
|
|
|||
|
|
@ -1,5 +1,76 @@
|
|||
# Referenced Anesidora to help make some functions
|
||||
#-------------------------------------------------------------------------------
|
||||
# Contact: Shawn Patton
|
||||
# Created: Sep 2008
|
||||
#
|
||||
# Purpose: AI side of the party hat which is where toon's go to access public
|
||||
# parties.
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
from direct.directnotify import DirectNotifyGlobal
|
||||
from direct.distributed.DistributedObjectAI import DistributedObjectAI
|
||||
from direct.task import Task
|
||||
from toontown.parties import PartyGlobals
|
||||
|
||||
class DistributedPartyGateAI(DistributedObjectAI):
|
||||
notify = DirectNotifyGlobal.directNotify.newCategory('DistributedPartyGateAI')
|
||||
|
||||
def __init__(self, air):
|
||||
DistributedObjectAI.__init__(self, air)
|
||||
|
||||
def getPartyList(self, avId):
|
||||
"""
|
||||
Retrieves the list of all public parties for the given avatar ID (avId).
|
||||
This method checks if the provided avId matches the sender's avatar ID.
|
||||
If they do not match, it logs a suspicious event and returns without
|
||||
sending the party list. If they match, it sends the list of all public
|
||||
parties to the avatar.
|
||||
Args:
|
||||
avId (int): The avatar ID requesting the party list.
|
||||
Returns:
|
||||
None
|
||||
"""
|
||||
|
||||
senderId = self.air.getAvatarIdFromSender()
|
||||
if avId != senderId:
|
||||
self.air.writeServerEvent('suspicious', avId, 'DistributedPartyGateAI.getPartyList avId: %s does not match sender avId: %s' % (avId, senderId))
|
||||
return
|
||||
self.sendUpdateToAvatarId(avId, 'listAllPublicParties', [self.air.partyManager.getAllPublicParties()])
|
||||
|
||||
def partyChoiceRequest(self, avId, shardId, zoneId):
|
||||
"""
|
||||
This function
|
||||
1. Checks if the avId matches the sender
|
||||
2. Gets all public parties
|
||||
3. Checks if the party is full
|
||||
4. Sends the party information to the avatar
|
||||
"""
|
||||
senderId = self.air.getAvatarIdFromSender()
|
||||
if avId != senderId:
|
||||
self.air.writeServerEvent('suspicious', avId, 'DistributedPartyGateAI.partyChoiceRequest avId: %s does not match sender avId: %s' % (avId, senderId))
|
||||
return
|
||||
allPublicParties = self.air.partyManager.getAllPublicParties()
|
||||
|
||||
if len(allPublicParties) == 0:
|
||||
# No public parties available
|
||||
self.sendUpdateToAvatarId(avId, 'partyRequestDenied', [PartyGlobals.PartyGateDenialReasons.Unavailable])
|
||||
return
|
||||
else:
|
||||
for party in allPublicParties:
|
||||
if party[0] == shardId and party[1] == zoneId:
|
||||
# Party found
|
||||
if party[2] < PartyGlobals.MaxToonsAtAParty:
|
||||
# Party is not full
|
||||
self.sendUpdateToAvatarId(avId, 'setParty', [party])
|
||||
return
|
||||
else:
|
||||
# Party is full
|
||||
self.sendUpdateToAvatarId(avId, 'partyRequestDenied', [PartyGlobals.PartyGateDenialReasons.Full])
|
||||
return
|
||||
break #
|
||||
|
||||
else:
|
||||
# Party not found
|
||||
self.sendUpdateToAvatarId(avId, 'partyRequestDenied', [PartyGlobals.PartyGateDenialReasons.Unavailable])
|
||||
return
|
||||
|
||||
Loading…
Reference in New Issue