From 827445d8fa8a9a20899ee2a6a14f91a90063b2e8 Mon Sep 17 00:00:00 2001 From: John Cote Date: Wed, 27 Nov 2019 20:14:30 -0500 Subject: [PATCH] general: current progress progress includes: - cogs appear on streets now - additionally, street interests are setup for astron clients. - cog battles are mostly working - updated some sequences to work with newer panda3d - fixed particle effects search paths so that they load now - handled disconnect reasons for clients that disconnect during cog battles etc. - fleshed out the holiday manager a bit more --- otp/ai/TimeManagerAI.py | 27 +++++++++++++++++----- otp/avatar/DistributedAvatar.py | 17 +++++++------- toontown/ai/HolidayManagerAI.py | 11 ++++++++- toontown/ai/ToontownAIRepository.py | 3 +++ toontown/battle/BattleParticles.py | 19 +++++---------- toontown/battle/DistributedBattle.py | 1 + toontown/battle/DistributedBattleBaseAI.py | 6 ++--- toontown/battle/MovieSuitAttacks.py | 1 + toontown/suit/DistributedSuit.py | 2 ++ toontown/suit/DistributedSuitBase.py | 13 +++++------ toontown/suit/Suit.py | 2 +- toontown/suit/SuitBase.py | 2 +- toontown/toon/DistributedToon.py | 4 ++-- toontown/town/Street.py | 7 +++++- toontown/town/TownLoader.py | 6 +++++ 15 files changed, 77 insertions(+), 44 deletions(-) diff --git a/otp/ai/TimeManagerAI.py b/otp/ai/TimeManagerAI.py index 9c876cb..f131d0f 100644 --- a/otp/ai/TimeManagerAI.py +++ b/otp/ai/TimeManagerAI.py @@ -1,17 +1,32 @@ -from direct.directnotify import DirectNotifyGlobal -from direct.distributed.DistributedObjectAI import DistributedObjectAI -from direct.distributed.ClockDelta import globalClockDelta import time +from direct.directnotify import DirectNotifyGlobal +from direct.distributed.ClockDelta import globalClockDelta +from direct.distributed.DistributedObjectAI import DistributedObjectAI + +from otp.otpbase import OTPGlobals + + class TimeManagerAI(DistributedObjectAI): notify = DirectNotifyGlobal.directNotify.newCategory('TimeManagerAI') + def __init__(self, air): + DistributedObjectAI.__init__(self, air) + self.avId2disconnectcode = {} + def requestServerTime(self, context): avId = self.air.getAvatarIdFromSender() if not avId: return - self.sendUpdateToAvatarId(avId, 'serverTime', [context, globalClockDelta.getRealNetworkTime(bits=32), int(time.time())]) + self.sendUpdateToAvatarId(avId, 'serverTime', + [context, globalClockDelta.getRealNetworkTime(bits=32), int(time.time())]) - def setSignature(self, todo0, todo1, todo2): - pass + def setDisconnectReason(self, disconnectCode): + avId = self.air.getAvatarIdFromSender() + if not avId: + return + + self.avId2disconnectcode[avId] = disconnectCode + self.air.writeServerEvent('disconnect-reason', avId=avId, + reason=OTPGlobals.DisconnectReasons.get(disconnectCode, 'unknown')) diff --git a/otp/avatar/DistributedAvatar.py b/otp/avatar/DistributedAvatar.py index 8001717..456f84d 100644 --- a/otp/avatar/DistributedAvatar.py +++ b/otp/avatar/DistributedAvatar.py @@ -32,6 +32,7 @@ class DistributedAvatar(DistributedActor, Avatar): self.hpText = None self.hp = None self.maxHp = None + self.hpTextSeq = None return def disable(self): @@ -203,8 +204,8 @@ class DistributedAvatar(DistributedActor, Avatar): self.hpText.setBillboardPointEye() self.hpText.setBin('fixed', 100) self.hpText.setPos(0, 0, self.height / 2) - seq = Task.sequence(self.hpText.lerpPos(Point3(0, 0, self.height + 1.5), 1.0, blendType='easeOut'), Task.pause(0.85), self.hpText.lerpColor(Vec4(r, g, b, a), Vec4(r, g, b, 0), 0.1), Task.Task(self.hideHpTextTask)) - taskMgr.add(seq, self.uniqueName('hpText')) + self.hpTextSeq = Sequence(self.hpText.posInterval(1.0, Point3(0, 0, self.height + 1.5), blendType='easeOut'), Wait(0.85), self.hpText.colorInterval(0.1, Vec4(r, g, b, 0)), Func(self.hideHpText)) + self.hpTextSeq.start() def showHpString(self, text, duration = 0.85, scale = 0.7): if self.HpTextEnabled and not self.ghostMode: @@ -223,16 +224,14 @@ class DistributedAvatar(DistributedActor, Avatar): self.hpText.setScale(scale) self.hpText.setBillboardAxis() self.hpText.setPos(0, 0, self.height / 2) - seq = Task.sequence(self.hpText.lerpPos(Point3(0, 0, self.height + 1.5), 1.0, blendType='easeOut'), Task.pause(duration), self.hpText.lerpColor(Vec4(r, g, b, a), Vec4(r, g, b, 0), 0.1), Task.Task(self.hideHpTextTask)) - taskMgr.add(seq, self.uniqueName('hpText')) - - def hideHpTextTask(self, task): - self.hideHpText() - return Task.done + self.hpTextSeq = Sequence(self.hpText.posInterval(1.0, Point3(0, 0, self.height + 1.5), blendType='easeOut'), Wait(duration), self.hpText.colorInterval(0.1, Vec4(r, g, b, 0)), Func(self.hideHpText)) + self.hpTextSeq.start() def hideHpText(self): if self.hpText: - taskMgr.remove(self.uniqueName('hpText')) + if self.hpTextSeq: + self.hpTextSeq.finish() + self.hpTextSeq = None self.hpText.removeNode() self.hpText = None return diff --git a/toontown/ai/HolidayManagerAI.py b/toontown/ai/HolidayManagerAI.py index 78df7bd..9aa3538 100644 --- a/toontown/ai/HolidayManagerAI.py +++ b/toontown/ai/HolidayManagerAI.py @@ -1,7 +1,16 @@ +from direct.directnotify import DirectNotifyGlobal +from toontown.toonbase import ToontownGlobals + + class HolidayManagerAI: + notify = DirectNotifyGlobal.directNotify.newCategory('HolidayManagerAI') + def __init__(self, air): self.air = air self.currentHolidays = {} def isHolidayRunning(self, holidayId): - return False # NO + return holidayId in self.currentHolidays + + def isMoreXpHolidayRunning(self): + return ToontownGlobals.MORE_XP_HOLIDAY in self.currentHolidays diff --git a/toontown/ai/ToontownAIRepository.py b/toontown/ai/ToontownAIRepository.py index 3ecf0b5..2e33b5d 100644 --- a/toontown/ai/ToontownAIRepository.py +++ b/toontown/ai/ToontownAIRepository.py @@ -212,6 +212,9 @@ class ToontownAIRepository(ToontownInternalRepository): def getAvatarExitEvent(self, avId): return 'distObjDelete-%d' % avId + def getAvatarDisconnectReason(self, avId): + return self.timeManager.avId2disconnectcode.get(avId, ToontownGlobals.DisconnectUnknown) + def getZoneDataStore(self): return self.zoneDataStore diff --git a/toontown/battle/BattleParticles.py b/toontown/battle/BattleParticles.py index fb32da0..77992e6 100644 --- a/toontown/battle/BattleParticles.py +++ b/toontown/battle/BattleParticles.py @@ -1,7 +1,6 @@ from direct.particles.ParticleEffect import * import os from direct.directnotify import DirectNotifyGlobal -from direct.showbase import AppRunnerGlobal notify = DirectNotifyGlobal.directNotify.newCategory('BattleParticles') TutorialParticleEffects = ('gearExplosionBig.ptf', 'gearExplosionSmall.ptf', 'gearExplosion.ptf') ParticleNames = ('audit-div', 'audit-five', 'audit-four', 'audit-minus', 'audit-mult', 'audit-one', 'audit-plus', 'audit-six', 'audit-three', 'audit-two', 'blah', 'brainstorm-box', 'brainstorm-env', 'brainstorm-track', 'buzzwords-crash', 'buzzwords-inc', 'buzzwords-main', 'buzzwords-over', 'buzzwords-syn', 'confetti', 'doubletalk-double', 'doubletalk-dup', 'doubletalk-good', 'filibuster-cut', 'filibuster-fiscal', 'filibuster-impeach', 'filibuster-inc', 'jargon-brow', 'jargon-deep', 'jargon-hoop', 'jargon-ipo', 'legalese-hc', 'legalese-qpq', 'legalese-vd', 'mumbojumbo-boiler', 'mumbojumbo-creative', 'mumbojumbo-deben', 'mumbojumbo-high', 'mumbojumbo-iron', 'poundsign', 'schmooze-genius', 'schmooze-instant', 'schmooze-master', 'schmooze-viz', 'roll-o-dex', 'rollodex-card', 'dagger', 'fire', 'snow-particle', 'raindrop', 'gear', 'checkmark', 'dollar-sign', 'spark') @@ -38,18 +37,12 @@ def loadParticleFile(name): global particleSearchPath if particleSearchPath == None: particleSearchPath = DSearchPath() - if AppRunnerGlobal.appRunner: - particleSearchPath.appendDirectory(Filename.expandFrom('$TT_3_5_ROOT/phase_3.5/etc')) - else: - basePath = os.path.expandvars('$TOONTOWN') or './toontown' - particleSearchPath.appendDirectory(Filename.fromOsSpecific(basePath + '/src/battle')) - particleSearchPath.appendDirectory(Filename.fromOsSpecific(basePath + '/src/safezone')) - particleSearchPath.appendDirectory(Filename('phase_3.5/etc')) - particleSearchPath.appendDirectory(Filename('phase_4/etc')) - particleSearchPath.appendDirectory(Filename('phase_5/etc')) - particleSearchPath.appendDirectory(Filename('phase_8/etc')) - particleSearchPath.appendDirectory(Filename('phase_9/etc')) - particleSearchPath.appendDirectory(Filename('.')) + if __debug__: + particleSearchPath.appendDirectory(Filename('resources/phase_3.5/etc')) + particleSearchPath.appendDirectory(Filename('resources/phase_4/etc')) + particleSearchPath.appendDirectory(Filename('resources/phase_5/etc')) + particleSearchPath.appendDirectory(Filename('resources/phase_8/etc')) + particleSearchPath.appendDirectory(Filename('resources/phase_9/etc')) pfile = Filename(name) found = vfs.resolveFilename(pfile, particleSearchPath) diff --git a/toontown/battle/DistributedBattle.py b/toontown/battle/DistributedBattle.py index b0ae897..92b03fc 100644 --- a/toontown/battle/DistributedBattle.py +++ b/toontown/battle/DistributedBattle.py @@ -1,4 +1,5 @@ from pandac.PandaModules import * +from libotp import * from direct.interval.IntervalGlobal import * from BattleBase import * from toontown.toonbase import ToontownGlobals diff --git a/toontown/battle/DistributedBattleBaseAI.py b/toontown/battle/DistributedBattleBaseAI.py index 1089a54..5c570b6 100644 --- a/toontown/battle/DistributedBattleBaseAI.py +++ b/toontown/battle/DistributedBattleBaseAI.py @@ -1,7 +1,7 @@ from otp.ai.AIBase import * from direct.distributed.ClockDelta import * from BattleBase import * -from BattleCalculatorAI import * +import BattleCalculatorAI from toontown.toonbase.ToontownBattleGlobals import * from SuitBattleGlobals import * from pandac.PandaModules import * @@ -47,7 +47,7 @@ class DistributedBattleBaseAI(DistributedObjectAI.DistributedObjectAI, BattleBas self.toonOrigMerits = {} self.toonMerits = {} self.toonParts = {} - self.battleCalc = BattleCalculatorAI(self, tutorialFlag) + self.battleCalc = BattleCalculatorAI.BattleCalculatorAI(self, tutorialFlag) if self.air.suitInvasionManager.getInvading(): mult = getInvasionMultiplier() self.battleCalc.setSkillCreditMultiplier(mult) @@ -263,7 +263,7 @@ class DistributedBattleBaseAI(DistributedObjectAI.DistributedObjectAI, BattleBas for s in self.suits: if s.battleTrap == NO_TRAP: suitTraps += '9' - elif s.battleTrap == BattleCalculatorAI.TRAP_CONFLICT: + elif s.battleTrap == BattleCalculatorAI.BattleCalculatorAI.TRAP_CONFLICT: suitTraps += '9' else: suitTraps += str(s.battleTrap) diff --git a/toontown/battle/MovieSuitAttacks.py b/toontown/battle/MovieSuitAttacks.py index 0dee53a..5a06057 100644 --- a/toontown/battle/MovieSuitAttacks.py +++ b/toontown/battle/MovieSuitAttacks.py @@ -1,3 +1,4 @@ +from libotp import * from toontown.toonbase.ToontownGlobals import * from SuitBattleGlobals import * from direct.interval.IntervalGlobal import * diff --git a/toontown/suit/DistributedSuit.py b/toontown/suit/DistributedSuit.py index 7ddb648..ca8cc97 100644 --- a/toontown/suit/DistributedSuit.py +++ b/toontown/suit/DistributedSuit.py @@ -1,4 +1,6 @@ from pandac.PandaModules import * +from libotp import * +from libtoontown import * from direct.interval.IntervalGlobal import * from direct.distributed.ClockDelta import * from direct.directtools.DirectGeometry import CLAMP diff --git a/toontown/suit/DistributedSuitBase.py b/toontown/suit/DistributedSuitBase.py index 2d50492..ec687ef 100644 --- a/toontown/suit/DistributedSuitBase.py +++ b/toontown/suit/DistributedSuitBase.py @@ -71,12 +71,12 @@ class DistributedSuitBase(DistributedAvatar.DistributedAvatar, Suit.Suit, SuitBa if num > self.maxSkeleRevives: self.maxSkeleRevives = num if self.getSkeleRevives() > 0: - nameInfo = TTLocalizer.SuitBaseNameWithLevel % {'name': self.name, + nameInfo = TTLocalizer.SuitBaseNameWithLevel % {'name': self._name, 'dept': self.getStyleDept(), 'level': '%s%s' % (self.getActualLevel(), TTLocalizer.SkeleRevivePostFix)} self.setDisplayName(nameInfo) else: - nameInfo = TTLocalizer.SuitBaseNameWithLevel % {'name': self.name, + nameInfo = TTLocalizer.SuitBaseNameWithLevel % {'name': self._name, 'dept': self.getStyleDept(), 'level': self.getActualLevel()} self.setDisplayName(nameInfo) @@ -431,16 +431,15 @@ class DistributedSuitBase(DistributedAvatar.DistributedAvatar, Suit.Suit, SuitBa self.nametag3d.setDepthTest(0) self.nametag3d.setBin('fixed', 99) self.hpText.setPos(0, 0, self.height / 2) - seq = Task.sequence(self.hpText.lerpPos(Point3(0, 0, self.height + 1.5), 1.0, blendType='easeOut'), Task.pause(0.85), self.hpText.lerpColor(Vec4(r, g, b, a), Vec4(r, g, b, 0), 0.1), Task.Task(self.hideHpTextTask)) - taskMgr.add(seq, self.uniqueName('hpText')) + self.hpTextSeq = Sequence(self.hpText.posInterval(1.0, Point3(0, 0, self.height + 1.5), blendType='easeOut'), Wait(0.85), self.hpText.colorInterval(0.1, Vec4(r, g, b, 0)), Func(self.hideHpText)) + self.hpTextSeq.start() - def hideHpTextTask(self, task): - self.hideHpText() + def hideHpText(self): + DistributedAvatar.DistributedAvatar.hideHpText(self) if self.sillySurgeText: self.nametag3d.clearDepthTest() self.nametag3d.clearBin() self.sillySurgeText = False - return Task.done def getAvIdName(self): try: diff --git a/toontown/suit/Suit.py b/toontown/suit/Suit.py index 2062895..9dcc510 100644 --- a/toontown/suit/Suit.py +++ b/toontown/suit/Suit.py @@ -972,7 +972,7 @@ class Suit(Avatar.Avatar): bb.setTwoSided(1) self.setName(TTLocalizer.Skeleton) - nameInfo = TTLocalizer.SuitBaseNameWithLevel % {'name': self.name, + nameInfo = TTLocalizer.SuitBaseNameWithLevel % {'name': self._name, 'dept': self.getStyleDept(), 'level': self.getActualLevel()} self.setDisplayName(nameInfo) diff --git a/toontown/suit/SuitBase.py b/toontown/suit/SuitBase.py index 7f78261..399d107 100644 --- a/toontown/suit/SuitBase.py +++ b/toontown/suit/SuitBase.py @@ -46,7 +46,7 @@ class SuitBase: def setLevel(self, level): self.level = level - nameWLevel = TTLocalizer.SuitBaseNameWithLevel % {'name': self.name, + nameWLevel = TTLocalizer.SuitBaseNameWithLevel % {'name': self._name, 'dept': self.getStyleDept(), 'level': self.getActualLevel()} self.setDisplayName(nameWLevel) diff --git a/toontown/toon/DistributedToon.py b/toontown/toon/DistributedToon.py index 22b3ce4..b73c08b 100644 --- a/toontown/toon/DistributedToon.py +++ b/toontown/toon/DistributedToon.py @@ -2522,8 +2522,8 @@ class DistributedToon(DistributedPlayer.DistributedPlayer, Toon.Toon, Distribute self.hpText.setBillboardPointEye() self.hpText.setBin('fixed', 100) self.hpText.setPos(0, 0, self.height / 2) - seq = Task.sequence(self.hpText.lerpPos(Point3(0, 0, self.height + 1.5), 1.0, blendType='easeOut'), Task.pause(0.85), self.hpText.lerpColor(Vec4(r, g, b, a), Vec4(r, g, b, 0), 0.1), Task(self.hideHpTextTask)) - taskMgr.add(seq, self.uniqueName('hpText')) + self.hpTextSeq = Sequence(self.hpText.posInterval(1.0, Point3(0, 0, self.height + 1.5), blendType='easeOut'), Wait(0.85), self.hpText.colorInterval(0.1, Vec4(r, g, b, 0)), Func(self.hideHpText)) + self.hpTextSeq.start() def setName(self, name = 'unknownDistributedAvatar'): DistributedPlayer.DistributedPlayer.setName(self, name) diff --git a/toontown/town/Street.py b/toontown/town/Street.py index b9879be..f3e905f 100644 --- a/toontown/town/Street.py +++ b/toontown/town/Street.py @@ -355,7 +355,12 @@ class Street(BattlePlace.BattlePlace): if newZoneId != None: self.loader.zoneDict[newZoneId].setColor(0, 0, 1, 1, 100) if newZoneId != None: - base.cr.sendSetZoneMsg(newZoneId) + if not base.cr.astronSupport: + base.cr.sendSetZoneMsg(newZoneId) + else: + visZones = [self.loader.node2zone[x] for x in self.loader.nodeDict[newZoneId]] + visZones.append(ZoneUtil.getBranchZone(newZoneId)) + base.cr.sendSetZoneMsg(newZoneId, visZones) self.notify.debug('Entering Zone %d' % newZoneId) self.zoneId = newZoneId geom = base.cr.playGame.getPlace().loader.geom diff --git a/toontown/town/TownLoader.py b/toontown/town/TownLoader.py index e6a1550..5bf3953 100644 --- a/toontown/town/TownLoader.py +++ b/toontown/town/TownLoader.py @@ -73,6 +73,8 @@ class TownLoader(StateData.StateData): del self.hood del self.nodeDict del self.zoneDict + if base.cr.astronSupport: + del self.node2zone del self.fadeInDict del self.fadeOutDict del self.nodeList @@ -227,6 +229,8 @@ class TownLoader(StateData.StateData): def makeDictionaries(self, dnaStore): self.nodeDict = {} self.zoneDict = {} + if base.cr.astronSupport: + self.node2zone = {} self.nodeList = [] self.fadeInDict = {} self.fadeOutDict = {} @@ -250,6 +254,8 @@ class TownLoader(StateData.StateData): self.nodeDict[zoneId] = [] self.nodeList.append(groupNode) self.zoneDict[zoneId] = groupNode + if base.cr.astronSupport: + self.node2zone[groupNode] = zoneId fadeDuration = 0.5 self.fadeOutDict[groupNode] = Sequence(Func(groupNode.setTransparency, 1), LerpColorScaleInterval(groupNode, fadeDuration, a0, startColorScale=a1), Func(groupNode.clearColorScale), Func(groupNode.clearTransparency), Func(groupNode.stash), name='fadeZone-' + str(zoneId), autoPause=1) self.fadeInDict[groupNode] = Sequence(Func(groupNode.unstash), Func(groupNode.setTransparency, 1), LerpColorScaleInterval(groupNode, fadeDuration, a1, startColorScale=a0), Func(groupNode.clearColorScale), Func(groupNode.clearTransparency), name='fadeZone-' + str(zoneId), autoPause=1)