From 3660d305cd95cc15c8c157c74a58a9302404d9aa Mon Sep 17 00:00:00 2001 From: John Date: Tue, 30 Jun 2015 21:50:15 +0300 Subject: [PATCH] NewsManager setInvasionStatus --- dependencies/astron/dclass/stride.dc | 34 +-------- toontown/ai/NewsManager.py | 30 ++++++-- toontown/ai/NewsManagerAI.py | 7 +- toontown/battle/DistributedBattleBase.py | 4 +- toontown/toonbase/TTLocalizerEnglish.py | 89 +++++++++++++++--------- toontown/toonbase/ToontownGlobals.py | 16 +++++ 6 files changed, 109 insertions(+), 71 deletions(-) diff --git a/dependencies/astron/dclass/stride.dc b/dependencies/astron/dclass/stride.dc index 63d74107..a1909d2f 100644 --- a/dependencies/astron/dclass/stride.dc +++ b/dependencies/astron/dclass/stride.dc @@ -1488,43 +1488,11 @@ dclass GroupManager : DistributedObject { removePlayerFromGroup(uint32, uint32) clsend airecv; }; -struct weeklyCalendarHoliday { - uint8 holidayId; - uint8 dayOfTheWeek; -}; - -struct yearlyCalendarHoliday { - uint8 holidayId; - uint8[] firstStartTime; - uint8[] lastEndTime; -}; - -struct oncelyCalendarHoliday { - uint8 holidayId; - uint16[] firstStartTime; - uint16[] lastEndTime; -}; - -struct relativelyCalendarHoliday { - uint8 holidayId; - uint16[] firstStartTime; - uint16[] lastEndTime; -}; - -struct startAndEndTime { - uint16[] startTime; - uint16[] endTime; -}; - -struct multipleStartHoliday { - uint8 holidayId; - startAndEndTime times[]; -}; - dclass NewsManager : DistributedObject { startHoliday(uint8) broadcast; endHoliday(uint8) broadcast; setActiveHolidays(uint8[]); + setInvasionStatus(uint8, string, uint32, uint8) broadcast; }; dclass PurchaseManager : DistributedObject { diff --git a/toontown/ai/NewsManager.py b/toontown/ai/NewsManager.py index 8f796e01..367c48e6 100755 --- a/toontown/ai/NewsManager.py +++ b/toontown/ai/NewsManager.py @@ -1,6 +1,9 @@ from direct.distributed.DistributedObject import DistributedObject +from direct.interval.IntervalGlobal import * +from toontown.battle import SuitBattleGlobals from toontown.estate import Estate -from toontown.toonbase import ToontownGlobals +from toontown.toonbase import ToontownGlobals, ToontownBattleGlobals, TTLocalizer +from toontown.suit import SuitDNA import HolidayGlobals class NewsManager(DistributedObject): @@ -8,7 +11,6 @@ class NewsManager(DistributedObject): def __init__(self, cr): DistributedObject.__init__(self, cr) - print 'NewsMgr - GEN!' self.invading = False self.activeHolidays = [] base.localAvatar.inventory.setInvasionCreditMultiplier(1) @@ -22,7 +24,6 @@ class NewsManager(DistributedObject): return id in self.activeHolidays def setActiveHolidays(self, ids): - print 'set active holidays %s' % ids for id in ids: self.startHoliday(id, True) @@ -80,4 +81,25 @@ class NewsManager(DistributedObject): elif id == ToontownGlobals.HALLOWEEN: base.localAvatar.chatMgr.chatInputSpeedChat.removeHalloweenMenu() elif id == ToontownGlobals.CHRISTMAS: - base.localAvatar.chatMgr.chatInputSpeedChat.removeWinterMenu() \ No newline at end of file + base.localAvatar.chatMgr.chatInputSpeedChat.removeWinterMenu() + + def setInvasionStatus(self, msgType, suitType, remaining, flags): + if msgType not in ToontownGlobals.SuitInvasions: + return + + if suitType in SuitDNA.suitHeadTypes: + attributes = SuitBattleGlobals.SuitAttributes[suitType] + suitNames = {'singular': attributes['name'], 'plural': attributes['pluralname']} + elif suitType in SuitDNA.suitDepts: + suitNames = {'singular': SuitDNA.getDeptFullname(suitType), 'plural': SuitDNA.getDeptFullnameP(suitType)} + else: + return + + track = Sequence() + base.localAvatar.inventory.setInvasionCreditMultiplier(1 if msgType in ToontownGlobals.EndingInvasions else ToontownBattleGlobals.getInvasionMultiplier()) + + for i, message in enumerate(ToontownGlobals.SuitInvasions[msgType]): + track.append(Wait(5 if i else 1)) + track.append(Func(base.localAvatar.setSystemMessage, 0, (TTLocalizer.SuitInvasionPrefix + message) % suitNames)) + + track.start() \ No newline at end of file diff --git a/toontown/ai/NewsManagerAI.py b/toontown/ai/NewsManagerAI.py index 9377d16d..b7bcf648 100755 --- a/toontown/ai/NewsManagerAI.py +++ b/toontown/ai/NewsManagerAI.py @@ -32,7 +32,12 @@ class NewsManagerAI(DistributedObjectAI): self.fireworkTask = None def __handleAvatarEntered(self, av): - self.sendUpdateToAvatarId(av.getDoId(), 'setActiveHolidays', [self.activeHolidays]) + avId = av.getDoId() + + if self.air.suitInvasionManager.getInvading(): + self.air.suitInvasionManager.notifyInvasionBulletin(avId) + + self.sendUpdateToAvatarId(avId, 'setActiveHolidays', [self.activeHolidays]) def getActiveHolidays(self): return self.activeHolidays diff --git a/toontown/battle/DistributedBattleBase.py b/toontown/battle/DistributedBattleBase.py index 1da2e29a..1d300ff1 100755 --- a/toontown/battle/DistributedBattleBase.py +++ b/toontown/battle/DistributedBattleBase.py @@ -574,10 +574,10 @@ class DistributedBattleBase(DistributedNode.DistributedNode, BattleBase): def setChosenToonAttacks(self, ids, tracks, levels, targets): if self.__battleCleanedUp: return - self.notify.debug('setChosenToonAttacks() - (%s), (%s), (%s), (%s)' % (ids, + print 'setChosenToonAttacks() - (%s), (%s), (%s), (%s)' % (ids, tracks, levels, - targets)) + targets) toonIndices = [] targetIndices = [] unAttack = 0 diff --git a/toontown/toonbase/TTLocalizerEnglish.py b/toontown/toonbase/TTLocalizerEnglish.py index 0195a64d..b85f7754 100755 --- a/toontown/toonbase/TTLocalizerEnglish.py +++ b/toontown/toonbase/TTLocalizerEnglish.py @@ -4605,37 +4605,64 @@ STOREOWNER_CONFIRM_LOSS = 'Your closet is full. You will lose the clothes you w STOREOWNER_OK = lOK STOREOWNER_CANCEL = lCancel STOREOWNER_TROPHY = 'Wow! You collected %s of %s fish. That deserves a trophy and a Laff boost!' -SuitInvasionBegin1 = lToonHQ + ': A Cog invasion has begun!!!' -SuitInvasionBegin2 = lToonHQ + ': %s have taken over Toontown!!!' -SuitInvasionEnd1 = lToonHQ + ': The %s invasion has ended!!!' -SuitInvasionEnd2 = lToonHQ + ': The Toons have saved the day once again!!!' -SuitInvasionUpdate1 = lToonHQ + ': Keep it up, Toons!!!' -SuitInvasionUpdate2 = lToonHQ + ': The Cogs appear to be decreasing in numbers!!!' -SuitInvasionBulletin1 = lToonHQ + ': There is a Cog invasion in progress!!!' -SuitInvasionBulletin2 = lToonHQ + ': %s have taken over Toontown!!!' -SkelecogInvasionBegin1 = lToonHQ + ": Hmm... We're getting a strange reading over here..." -SkelecogInvasionBegin2 = lToonHQ + ': The Cog factories are running out of parts to build new Cogs!' -SkelecogInvasionBegin3 = lToonHQ + ': Skelecogs have taken over Toontown!!!' -SkelecogInvasionEnd1 = lToonHQ + ': The Skelecog invasion has ended!!!' -SkelecogInvasionEnd2 = lToonHQ + ': The Toons have saved the day once again!!!' -SkelecogInvasionBulletin1 = lToonHQ + ': There is a Cog invasion in progress!!!' -SkelecogInvasionBulletin2 = lToonHQ + ': The Cog factories are running out of parts to build new Cogs!' -SkelecogInvasionBulletin3 = lToonHQ + ': Skelecogs have taken over Toontown!!!' -WaiterInvasionBegin1 = lToonHQ + ': It appears that the C.E.O. has fired all his waiters...' -WaiterInvasionBegin2 = lToonHQ + ': The unemployed waiters are invading Toontown!!!' -WaiterInvasionEnd1 = lToonHQ + ': The unemployed waiters have been defeated!!!' -WaiterInvasionEnd2 = lToonHQ + ': The Toons have saved the day once again!!!' -WaiterInvasionBulletin1 = lToonHQ + ': There is a Cog invasion in progress!!!' -WaiterInvasionBulletin2 = lToonHQ + ': The C.E.O. has fired all of his waiters!!!' -WaiterInvasionBulletin3 = lToonHQ + ": The unemployed waiters are invading Toontown!!!" -V2InvasionBegin1 = lToonHQ + ": Yikes!!! This isn't good, Toons!" -V2InvasionBegin2 = lToonHQ + ': A major firmware update has been released to the Cogs!!!' -V2InvasionBegin3 = lToonHQ + ': Version 2.0 %s have taken over Toontown!!!' -V2InvasionEnd1 = lToonHQ + ': The version 2.0 Cog invasion has ended!!!' -V2InvasionEnd2 = lToonHQ + ': The Toons have saved the day once again!!!' -V2InvasionBulletin1 = lToonHQ + ': There is a Cog invasion in progress!!!' -V2InvasionBulletin2 = lToonHQ + ': A major firmware update has been released to the Cogs!!!' -V2InvasionBulletin3 = lToonHQ + ': Version 2.0 %s have taken over Toontown!!!' +SuitInvasionPrefix = '%s: ' % lToonHQ +SuitInvasionBegin = [ + 'A Cog invasion has begun!!!', + '%(plural)s have taken over Toontown!!!' +] +SuitInvasionEnd = [ + 'The %(singular)s invasion has ended!!!', + 'The Toons have saved the day once again!!!' +] +SuitInvasionUpdate = [ + 'Keep it up, Toons!!!', + 'The Cogs appear to be decreasing in numbers!!!' +] +SuitInvasionBulletin = [ + 'There is a Cog invasion in progress!!!', + '%(plural)s have taken over Toontown!!!' +] +SkelecogInvasionBegin = [ + "Hmm... We're getting a strange reading over here...", + 'The Cog factories are running out of parts to build new Cogs!', + 'Skelecogs have taken over Toontown!!!' +] +SkelecogInvasionEnd = [ + 'The Skelecog invasion has ended!!!', + 'The Toons have saved the day once again!!!' +] +SkelecogInvasionBulletin = [ + 'There is a Cog invasion in progress!!!', + 'The Cog factories are running out of parts to build new Cogs!', + 'Skelecogs have taken over Toontown!!!' +] +WaiterInvasionBegin = [ + 'It appears that the C.E.O. has fired all his waiters...', + 'The unemployed waiters are invading Toontown!!!' +] +WaiterInvasionEnd = [ + 'The unemployed waiters have been defeated!!!', + 'The Toons have saved the day once again!!!' +] +WaiterInvasionBulletin = [ + 'There is a Cog invasion in progress!!!', + 'The C.E.O. has fired all of his waiters!!!', + 'The unemployed waiters are invading Toontown!!!' +] +V2InvasionBegin = [ + "Yikes!!! This isn't good, Toons!", + 'A major firmware update has been released to the Cogs!!!', + 'Version 2.0 %(plural)s have taken over Toontown!!!' +] +V2InvasionEnd = [ + 'The Version 2.0 %(singular)s invasion has ended!!!', + 'The Toons have saved the day once again!!!' +] +V2InvasionBulletin = [ + 'There is a Cog invasion in progress!!!', + 'A major firmware update has been released to the Cogs!!!', + 'Version 2.0 %(plural)s have taken over Toontown!!!' +] LeaderboardTitle = 'Toon Platoon' QuestScript101_0 = 'Come here! Use the arrow keys to move.' QuestScript101_1 = 'These are Cogs. They are robots that are trying to take over Toontown.' diff --git a/toontown/toonbase/ToontownGlobals.py b/toontown/toonbase/ToontownGlobals.py index 5335e9ba..c7e1a7a0 100755 --- a/toontown/toonbase/ToontownGlobals.py +++ b/toontown/toonbase/ToontownGlobals.py @@ -824,6 +824,22 @@ WaiterInvasionBulletin = 9 V2InvasionBegin = 10 V2InvasionEnd = 11 V2InvasionBulletin = 12 +EndingInvasions = [SuitInvasionEnd, SkelecogInvasionEnd, WaiterInvasionEnd, V2InvasionEnd] +SuitInvasions = { + SuitInvasionBegin: TTLocalizer.SuitInvasionBegin, + SuitInvasionEnd: TTLocalizer.SuitInvasionEnd, + SuitInvasionUpdate: TTLocalizer.SuitInvasionUpdate, + SuitInvasionBulletin: TTLocalizer.SuitInvasionBulletin, + SkelecogInvasionBegin: TTLocalizer.SkelecogInvasionBegin, + SkelecogInvasionEnd: TTLocalizer.SkelecogInvasionEnd, + SkelecogInvasionBulletin: TTLocalizer.SkelecogInvasionBulletin, + WaiterInvasionBegin: TTLocalizer.WaiterInvasionBegin, + WaiterInvasionEnd: TTLocalizer.WaiterInvasionEnd, + WaiterInvasionBulletin: TTLocalizer.WaiterInvasionBulletin, + V2InvasionBegin: TTLocalizer.V2InvasionBegin, + V2InvasionEnd: TTLocalizer.V2InvasionEnd, + V2InvasionBulletin: TTLocalizer.V2InvasionBulletin +} SUMMER_FIREWORKS = 1 NEW_YEAR_FIREWORKS = 2 HALLOWEEN = 3