From 378c5b199f07d2b4ba7c0e8453b22c10f03e3109 Mon Sep 17 00:00:00 2001 From: LittleNed Date: Sun, 15 Nov 2015 13:32:01 -0800 Subject: [PATCH] Fix cog bosses like vp , cfo, cj and ceo credit goes to @mgracer48 for fixing it --- toontown/ai/AIZoneData.py | 209 ++++++++++++++++++ toontown/ai/AIZoneData.pyc | Bin 0 -> 8892 bytes toontown/ai/CogPageManagerAI.pyc | Bin 2156 -> 2156 bytes toontown/ai/CogSuitManagerAI.pyc | Bin 1107 -> 1107 bytes toontown/ai/DistributedBlackCatMgr.pyc | Bin 1665 -> 1665 bytes toontown/ai/DistributedBlackCatMgrAI.pyc | Bin 1738 -> 1738 bytes toontown/ai/DistributedEffectMgr.pyc | Bin 2201 -> 2201 bytes toontown/ai/DistributedEffectMgrAI.pyc | Bin 1871 -> 1871 bytes .../ai/DistributedPolarPlaceEffectMgr.pyc | Bin 2233 -> 2233 bytes .../ai/DistributedPolarPlaceEffectMgrAI.pyc | Bin 1561 -> 1561 bytes toontown/ai/DistributedReportMgr.pyc | Bin 1192 -> 1192 bytes toontown/ai/DistributedReportMgrAI.pyc | Bin 1911 -> 1911 bytes toontown/ai/DistributedResistanceEmoteMgr.pyc | Bin 2406 -> 2406 bytes .../ai/DistributedResistanceEmoteMgrAI.pyc | Bin 1617 -> 1617 bytes toontown/ai/FishManagerAI.pyc | Bin 4547 -> 4547 bytes toontown/ai/HolidayGlobals.pyc | Bin 3858 -> 3858 bytes toontown/ai/NewsManager.pyc | Bin 4743 -> 4743 bytes toontown/ai/NewsManagerAI.pyc | Bin 6886 -> 6886 bytes toontown/ai/PromotionManagerAI.pyc | Bin 3123 -> 3123 bytes toontown/ai/QuestManagerAI.pyc | Bin 17737 -> 17737 bytes toontown/ai/ReportGlobals.pyc | Bin 686 -> 686 bytes toontown/ai/ToonBarrier.pyc | Bin 3451 -> 3451 bytes toontown/ai/ToontownAIRepository.py | 2 + toontown/ai/ToontownAIRepository.pyc | Bin 12407 -> 12424 bytes toontown/ai/__init__.pyc | Bin 110 -> 110 bytes 25 files changed, 211 insertions(+) create mode 100644 toontown/ai/AIZoneData.py create mode 100644 toontown/ai/AIZoneData.pyc diff --git a/toontown/ai/AIZoneData.py b/toontown/ai/AIZoneData.py new file mode 100644 index 00000000..560ab7fb --- /dev/null +++ b/toontown/ai/AIZoneData.py @@ -0,0 +1,209 @@ +from panda3d.core import * +from direct.distributed import ParentMgr +from direct.directnotify.DirectNotifyGlobal import directNotify +from direct.task import Task +from src.otp.otpbase import OTPGlobals +import random + +class AIZoneData: + notify = directNotify.newCategory('AIZoneData') + + def __init__(self, air, parentId, zoneId): + self._air = air + self._parentId = parentId + self._zoneId = zoneId + self._data = self._air.getZoneDataStore().getDataForZone(self._parentId, self._zoneId) + + def destroy(self): + del self._data + self._air.getZoneDataStore().releaseDataForZone(self._parentId, self._zoneId) + del self._zoneId + del self._parentId + del self._air + + def __getattr__(self, attr): + return getattr(self._data, attr) + + +class AIZoneDataObj: + notify = directNotify.newCategory('AIZoneDataObj') + DefaultCTravName = 'default' + + def __init__(self, parentId, zoneId): + self._parentId = parentId + self._zoneId = zoneId + self._refCount = 0 + self._collTravs = {} + self._collTravsStarted = set() + + def __str__(self): + output = str(self._collTravs) + output += '\n' + totalColliders = 0 + totalTraversers = 0 + for currCollTrav in self._collTravs.values(): + totalTraversers += 1 + totalColliders += currCollTrav.getNumColliders() + + output += 'Num traversers: %s Num total colliders: %s' % (totalTraversers, totalColliders) + return output + + def _incRefCount(self): + self._refCount += 1 + + def _decRefCount(self): + self._refCount -= 1 + + def _getRefCount(self): + return self._refCount + + def destroy(self): + for name in list(self._collTravsStarted): + self.stopCollTrav(cTravName=name) + + del self._collTravsStarted + del self._collTravs + if hasattr(self, '_nonCollidableParent'): + self._nonCollidableParent.removeNode() + del self._nonCollidableParent + if hasattr(self, '_render'): + self._render.removeNode() + del self._render + if hasattr(self, '_parentMgr'): + self._parentMgr.destroy() + del self._parentMgr + del self._zoneId + del self._parentId + + def getLocation(self): + return (self._parentId, self._zoneId) + + def getRender(self): + if not hasattr(self, '_render'): + self._render = NodePath('render-%s-%s' % (self._parentId, self._zoneId)) + return self._render + + def getNonCollidableParent(self): + if not hasattr(self, '_nonCollidableParent'): + render = self.getRender() + self._nonCollidableParent = render.attachNewNode('nonCollidables') + return self._nonCollidableParent + + def getParentMgr(self): + if not hasattr(self, '_parentMgr'): + self._parentMgr = ParentMgr.ParentMgr() + self._parentMgr.registerParent(OTPGlobals.SPHidden, hidden) + self._parentMgr.registerParent(OTPGlobals.SPRender, self.getRender()) + return self._parentMgr + + def hasCollTrav(self, name = None): + if name is None: + name = AIZoneDataObj.DefaultCTravName + return name in self._collTravs + + def getCollTrav(self, name = None): + if name is None: + name = AIZoneDataObj.DefaultCTravName + if name not in self._collTravs: + self._collTravs[name] = CollisionTraverser('cTrav-%s-%s-%s' % (name, self._parentId, self._zoneId)) + return self._collTravs[name] + + def removeCollTrav(self, name): + if name in self._collTravs: + del self._collTravs[name] + + def _getCTravTaskName(self, name = None): + if name is None: + name = AIZoneDataObj.DefaultCTravName + return 'collTrav-%s-%s-%s' % (name, self._parentId, self._zoneId) + + def _doCollisions(self, task = None, topNode = None, cTravName = None): + render = self.getRender() + curTime = globalClock.getFrameTime() + render.setTag('lastTraverseTime', str(curTime)) + if topNode is not None: + if not render.isAncestorOf(topNode): + self.notify.warning('invalid topNode for collision traversal in %s: %s' % (self.getLocation(), topNode)) + else: + topNode = render + if cTravName is None: + cTravName = AIZoneDataObj.DefaultCTravName + collTrav = self._collTravs[cTravName] + messenger.send('preColl-' + collTrav.getName()) + collTrav.traverse(topNode) + messenger.send('postColl-' + collTrav.getName()) + return Task.cont + + def doCollTrav(self, topNode = None, cTravName = None): + self.getCollTrav(cTravName) + self._doCollisions(topNode=topNode, cTravName=cTravName) + + def startCollTrav(self, respectPrevTransform = 1, cTravName = None): + if cTravName is None: + cTravName = AIZoneDataObj.DefaultCTravName + if cTravName not in self._collTravsStarted: + self.getCollTrav(name=cTravName) + taskMgr.add(self._doCollisions, self._getCTravTaskName(name=cTravName), priority=OTPGlobals.AICollisionPriority, extraArgs=[self._zoneId]) + self._collTravsStarted.add(cTravName) + self.setRespectPrevTransform(respectPrevTransform, cTravName=cTravName) + return + + def stopCollTrav(self, cTravName = None): + if cTravName is None: + cTravName = AIZoneDataObj.DefaultCTravName + self.notify.debug('stopCollTrav(%s, %s, %s)' % (cTravName, self._parentId, self._zoneId)) + if cTravName in self._collTravsStarted: + self.notify.info('removing %s collision traversal for (%s, %s)' % (cTravName, self._parentId, self._zoneId)) + taskMgr.remove(self._getCTravTaskName(name=cTravName)) + self._collTravsStarted.remove(cTravName) + return + + def setRespectPrevTransform(self, flag, cTravName = None): + if cTravName is None: + cTravName = AIZoneDataObj.DefaultCTravName + self._collTravs[cTravName].setRespectPrevTransform(flag) + return + + def getRespectPrevTransform(self, cTravName = None): + if cTravName is None: + cTravName = AIZoneDataObj.DefaultCTravName + return self._collTravs[cTravName].getRespectPrevTransform() + + +class AIZoneDataStore: + notify = directNotify.newCategory('AIZoneDataStore') + + def __init__(self): + self._zone2data = {} + + def destroy(self): + for zone, data in self._zone2data.items(): + data.destroy() + + del self._zone2data + + def hasDataForZone(self, parentId, zoneId): + key = (parentId, zoneId) + return key in self._zone2data + + def getDataForZone(self, parentId, zoneId): + key = (parentId, zoneId) + if key not in self._zone2data: + self._zone2data[key] = AIZoneDataObj(parentId, zoneId) + self.printStats() + data = self._zone2data[key] + data._incRefCount() + return data + + def releaseDataForZone(self, parentId, zoneId): + key = (parentId, zoneId) + data = self._zone2data[key] + data._decRefCount() + refCount = data._getRefCount() + if refCount == 0: + del self._zone2data[key] + data.destroy() + self.printStats() + + def printStats(self): + self.notify.debug('%s zones have zone data allocated' % len(self._zone2data)) diff --git a/toontown/ai/AIZoneData.pyc b/toontown/ai/AIZoneData.pyc new file mode 100644 index 0000000000000000000000000000000000000000..2f310aa16cda0b7ad7ad6ab4eaf88159b0f838cc GIT binary patch literal 8892 zcmcIqO>-P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da8b7abb46d4253b7794896a828d6..ab0956aae1af87cd9de3c95b06faab2349ab04a5 100644 GIT binary patch delta 17 YcmaDO@J4`x`7;mz^3*+SBS$4004yH`5C8xG delta 17 YcmZqVZRF)({>;lIS@Jq`BS$4004#$AHvj+t diff --git a/toontown/ai/DistributedBlackCatMgrAI.pyc b/toontown/ai/DistributedBlackCatMgrAI.pyc index 7e799855e1b5ecbe1878692c44afb79efd8a25a2..d4cc322042cc1f0aec725eff6b90905931057bfc 100644 GIT binary patch delta 17 YcmX@bdy1EX`7i_@% delta 17 YcmX@bdy1EX`7058b}VgLXD delta 17 YcmbO!I8%^=`705B~Di2wiq diff --git a/toontown/ai/DistributedEffectMgrAI.pyc b/toontown/ai/DistributedEffectMgrAI.pyc index e842937712c3e573681b788eb85806a28018ddde..6884d2fb01ab65d06be8d9bcd37b45357a6053e8 100644 GIT binary patch delta 17 YcmX@lcb<=f`7}05k~&!T}05oj{=>Px# diff --git a/toontown/ai/DistributedPolarPlaceEffectMgrAI.pyc b/toontown/ai/DistributedPolarPlaceEffectMgrAI.pyc index 41adf1f6afc242aa68b43f8647f842db5baae4dc..22ec1897e6fcd9f4da60c0cb283a069a88d0b7ba 100644 GIT binary patch delta 17 YcmbQqGn0pd`7 delta 17 Ycmey)_nnV}`7;mz^3*+SBS*au058V{UH||9 delta 17 YcmZoyZCB-B{>;lIS@Jq`BS*au05B^Bg#Z8m diff --git a/toontown/ai/NewsManagerAI.pyc b/toontown/ai/NewsManagerAI.pyc index 36cf947238237e1119fe567f092b4aad0e04f6e0..8b82a5251d2dee0badd6b1e3e8c2122b5e6adae3 100644 GIT binary patch delta 17 YcmaE6`plGr`72TK3| diff --git a/toontown/ai/PromotionManagerAI.pyc b/toontown/ai/PromotionManagerAI.pyc index 45893ef18a89fdbd1d80c6732cd75223961bff9d..0c4f151496240cf19b06012cdaff3212b070ae47 100644 GIT binary patch delta 17 Ycmdliu~~wH`7LI3~& delta 17 Ycmdliu~~wH`7(GrHj;;Vm5(dfu diff --git a/toontown/ai/ReportGlobals.pyc b/toontown/ai/ReportGlobals.pyc index ad47ce73545bfe347c9ab069be031e26b1de290a..3539b07e6e680b45ca9b01e43869cdfb7652d2ef 100644 GIT binary patch delta 17 YcmZ3-x{j5D`7k delta 17 YcmZ3-x{j5D`7OV delta 17 Ycmew@^;?RA`7$JUAC)1}^S;T8{i`!&Z zyXir61=avGJ7@yTArujiiC~P3&d{s`Oa_hWqDo7WBog0n|?%qv*;Q08m8f ze+g&K8w>90x2`<_kM*>t4e>(HDB~@7rI&rvh>yD9KR~R|Vc-Z~NDYn9MsOeBjP4w( xBt;Z@53OR2dZP+$hPUv;n3b?@XoBt|Df~7_8GlUv94(?i^RYV|*5iE>t-k`JHrkyYcF5gMFB6!Co~;3 z0L1}{1vbbVkm+9VNK61l01ebp&!Q6;eF*`luDT2rb%ZqPoZeHsPzOWv0rP|6H!aG* z0-ywXLJ(NUM8kTmgiRN+hzUmx95rEGkAeDxEZ+CBP)tDCcz}`wwT&#*XHZP{PzF>R zg+w1N(WE#pZ&}!cNz3)LJgDb%D8BOM$QZiD0e}tZQQ0n3D&?JplFIL-DHK<;T^K>+mY#3zwoth%LH`o!}cqQWBNp57_>% z61179;k(w!^qZ*S2UU~D_^I^`>}r{#R;qyC+Ek{+bOV2ks*~3Kf_5{HnCCOuIolsI CVR^Cu diff --git a/toontown/ai/__init__.pyc b/toontown/ai/__init__.pyc index c4b95c7e3d075606542b601d51a544854e29d9dd..4bd3470c4e04a1d41adea4d7d01bbe5b47b80f49 100644 GIT binary patch delta 14 Vcmd1H<6!>G%cb(vJ!~RJ8UP`x1eX8+ delta 14 Vcmd1H<6!>G%OzRzI&>mO8UP{Z1ik