Pets will work in battle now.

This commit is contained in:
John Cote 2015-05-09 02:21:07 -04:00
parent 6bd6420254
commit ab3072fb84
4 changed files with 12 additions and 8 deletions

View file

@ -1090,7 +1090,6 @@ class DistributedBattleBase(DistributedNode.DistributedNode, BattleBase):
def __handleLocalToonBattleEvent(self, response):
mode = response['mode']
print(response)
noAttack = 0
if mode == 'Attack':
self.notify.debug('got an attack')

View file

@ -1136,7 +1136,7 @@ class DistributedBattleBaseAI(DistributedObjectAI.DistributedObjectAI, BattleBas
petProxy.setSurprise(pet.getSurprise())
pet.requestDelete()
def deleted(task):
petProxy.dbObject = 1
petProxy.doNotDeallocateChannel = True
petProxy.generateWithRequiredAndId(petId, self.air.districtId, self.zoneId)
petProxy.broadcastDominantMood()
self.pets[toonId] = petProxy

View file

@ -108,7 +108,7 @@ class LoadPetFSM(FSM):
self.estate = estate
self.toon = toon
self.callback = callback
self.pet = None
self.done = False
def start(self):
@ -229,7 +229,7 @@ class LoadEstateFSM(FSM):
def __gotEstate(self, estate):
self.estate = estate
self.estate.pets = []
estate.pets = []
self.estate.toons = self.toonIds
self.estate.updateToons()
@ -268,17 +268,16 @@ class LoadEstateFSM(FSM):
fsm = LoadPetFSM(self.mgr, self.estate, toon, self.__petDone)
self.petFSMs.append(fsm)
fsm.start()
else:
continue
if not self.petFSMs:
self.demand('Finished')
taskMgr.doMethodLater(0, lambda: self.demand('Finished'), 'nopets', extraArgs=[])
def __petDone(self, pet):
if self.state != 'LoadPets':
pet.requestDelete()
return
# A petFSM just finished! Let's see if all of them are done:
if all(petFSM.done for petFSM in self.petFSMs):
self.demand('Finished')
@ -429,6 +428,12 @@ class EstateManagerAI(DistributedObjectAI):
estate.destroy()
estate.owner.estate = None
# Destroy pets:
for pet in estate.pets:
pet.requestDelete()
estate.pets = []
# Free estate's zone:
self.air.deallocateZone(estate.zoneId)

View file

@ -89,7 +89,7 @@ def angle(A, B):
return math.atan2(by-ay, bx-ax)
class PetMoverAI(FSM):
class PetMoverAI(FSM):
def __init__(self, pet):
self.pet = pet
FSM.__init__(self, 'PetMoverAI-%d' % self.pet.doId)