From e0df87ac48e23487e7f7f1b42d1e7b3bea6088ff Mon Sep 17 00:00:00 2001 From: DenialMC Date: Sat, 4 Apr 2015 11:20:42 +0300 Subject: [PATCH] Holiday stuff - cleanup, add Laughing Man holiday (everybody gets Laughing Man heads, including NPCs), add ~startHoliday and ~endHoliday magic word, clean up Laughing Man effect, remove Secret NPC --- toontown/ai/HolidayManagerAI.py | 3 +- toontown/ai/NewsManager.py | 54 ++++++++++++++++++++++++- toontown/toon/DistributedNPCSecret.py | 27 ------------- toontown/toon/DistributedNPCSecretAI.py | 22 ---------- toontown/toon/DistributedNPCToonBase.py | 1 + toontown/toon/LaughingManGlobals.py | 10 ++--- toontown/toon/Toon.py | 17 +++++++- toontown/toonbase/TTLocalizerEnglish.py | 1 + toontown/toonbase/ToontownGlobals.py | 1 + 9 files changed, 75 insertions(+), 61 deletions(-) delete mode 100644 toontown/toon/DistributedNPCSecret.py delete mode 100644 toontown/toon/DistributedNPCSecretAI.py diff --git a/toontown/ai/HolidayManagerAI.py b/toontown/ai/HolidayManagerAI.py index fb780557..576034f2 100644 --- a/toontown/ai/HolidayManagerAI.py +++ b/toontown/ai/HolidayManagerAI.py @@ -17,8 +17,7 @@ class HolidayManagerAI: simbase.air.newsManager.setHolidayIdList([self.currentHolidays]) def isHolidayRunning(self, holidayId): - if holidayId in self.currentHolidays: - return True + return holidayId in self.currentHolidays def isMoreXpHolidayRunning(self): if ToontownGlobals.MORE_XP_HOLIDAY in self.currentHolidays: diff --git a/toontown/ai/NewsManager.py b/toontown/ai/NewsManager.py index efa25389..c088ba99 100644 --- a/toontown/ai/NewsManager.py +++ b/toontown/ai/NewsManager.py @@ -12,6 +12,7 @@ from direct.interval.IntervalGlobal import * import calendar from copy import deepcopy from toontown.suit import SuitDNA +from otp.ai.MagicWordGlobal import * decorationHolidays = [ToontownGlobals.WINTER_DECORATIONS, @@ -258,6 +259,9 @@ class NewsManager(DistributedObject.DistributedObject): elif holidayId == ToontownGlobals.SPOOKY_BLACK_CAT: if hasattr(base, 'localAvatar') and base.localAvatar and hasattr(base.localAvatar, 'chatMgr') and base.localAvatar.chatMgr: self.setSpookyBlackCatHolidayStart() + elif holidayId == ToontownGlobals.LAUGHING_MAN: + if hasattr(base, 'localAvatar') and base.localAvatar: + self.setLaughingManHolidayStart() elif holidayId == ToontownGlobals.TOP_TOONS_MARATHON: if hasattr(base, 'localAvatar') and base.localAvatar and hasattr(base.localAvatar, 'chatMgr') and base.localAvatar.chatMgr: self.setTopToonsMarathonStart() @@ -275,6 +279,8 @@ class NewsManager(DistributedObject.DistributedObject): self.setExpandedClosetsStart() elif holidayId == ToontownGlobals.KARTING_TICKETS_HOLIDAY: self.setKartingTicketsHolidayStart() + return True + return False def endHoliday(self, holidayId): if holidayId in self.holidayIdList: @@ -377,6 +383,8 @@ class NewsManager(DistributedObject.DistributedObject): elif holidayId == ToontownGlobals.IDES_OF_MARCH: if hasattr(base, 'localAvatar') and base.localAvatar and hasattr(base.localAvatar, 'chatMgr') and base.localAvatar.chatMgr: base.localAvatar.chatMgr.chatInputSpeedChat.removeIdesOfMarchMenu() + return True + return False def setHolidayIdList(self, holidayIdList): @@ -531,6 +539,11 @@ class NewsManager(DistributedObject.DistributedObject): for currToon in base.cr.toons.values(): currToon.setDNA(currToon.style.clone()) + def setLaughingManHolidayStart(self): + base.localAvatar.setSystemMessage(0, TTLocalizer.LaughingManHolidayStart) + for currToon in base.cr.toons.values(): + currToon.generateLaughingMan() + def setTopToonsMarathonStart(self): base.localAvatar.setSystemMessage(0, TTLocalizer.TopToonsMarathonStart) @@ -725,5 +738,42 @@ class NewsManager(DistributedObject.DistributedObject): startingWeekDay = (startingWeekDay + 1) % 7 def isHolidayRunning(self, holidayId): - result = holidayId in self.holidayIdList - return result + return holidayId in self.holidayIdList + +def getHoliday(id): + if id.isdigit(): + return int(id) + elif hasattr(ToontownGlobals, id): + return getattr(ToontownGlobals, id) + + return -1 + +@magicWord(category=CATEGORY_PROGRAMMER, types=[str]) +def startHoliday(id): + """ + Start a holiday. + """ + holiday = getHoliday(id.upper()) + + if holiday < 0: + return "Couldn't find holiday " + id + '!' + + if base.cr.newsManager.startHoliday(holiday): + return 'Successfully started holiday ' + id + '!' + else: + return id + ' is already running!' + +@magicWord(category=CATEGORY_PROGRAMMER, types=[str]) +def endHoliday(id): + """ + End a holiday. + """ + holiday = getHoliday(id.upper()) + + if holiday < 0: + return "Couldn't find holiday " + id + '!' + + if base.cr.newsManager.endHoliday(holiday): + return 'Successfully stopped holiday ' + id + '!' + else: + return id + ' is not running!' \ No newline at end of file diff --git a/toontown/toon/DistributedNPCSecret.py b/toontown/toon/DistributedNPCSecret.py deleted file mode 100644 index 228b06aa..00000000 --- a/toontown/toon/DistributedNPCSecret.py +++ /dev/null @@ -1,27 +0,0 @@ -from DistributedNPCToonBase import * -from toontown.chat.ChatGlobals import * -from toontown.nametag.NametagGlobals import * - - -class DistributedNPCSecret(DistributedNPCToonBase): - - def __init__(self, cr): - DistributedNPCToonBase.__init__(self, cr) - - def delayDelete(self): - DistributedNPCToonBase.delayDelete(self) - DistributedNPCToonBase.disable(self) - - def handleCollisionSphereEnter(self, collEntry): - self.sendUpdate('avatarEnter', []) - - def createBot(self, chatPhraseId): - chatPhrases = [ - "I'm Kyle, AKA the chicken lord, and I like to make bots!", - 'I love the smell of fresh bots in the morning...', - 'Bots... bots... bots...', - "Patch the Injector, or we'll continue...", - "All the kids who sweat it out... it's unbelievable! Let's give them more bots!", - "Master Milton is sweaty. Here's another bot!" - ] - self.setChatAbsolute(chatPhrases[chatPhraseId], CFSpeech|CFTimeout) \ No newline at end of file diff --git a/toontown/toon/DistributedNPCSecretAI.py b/toontown/toon/DistributedNPCSecretAI.py deleted file mode 100644 index f97181e9..00000000 --- a/toontown/toon/DistributedNPCSecretAI.py +++ /dev/null @@ -1,22 +0,0 @@ -from otp.ai.AIBaseGlobal import * -from DistributedNPCToonBaseAI import * -from ToonDNA import * -from DistributedBotAI import * -import random - -class DistributedNPCSecretAI(DistributedNPCToonBaseAI): - - def __init__(self, air, npcId, questCallback=None, hq=0): - DistributedNPCToonBaseAI.__init__(self, air, npcId, questCallback) - self.air = air - - def avatarEnter(self): - self.sendUpdate('createBot', [random.randrange(6)]) - dna = ToonDNA() - dna.newToonRandom() - newToon = DistributedBotAI(self.cr) - newToon.b_setDNAString(dna.makeNetString()) - x = (random.random()*10) + 10 - y = (random.random()*10) + 10 - z = 4 - newToon.sendUpdate('setPos', [x, y, z]) \ No newline at end of file diff --git a/toontown/toon/DistributedNPCToonBase.py b/toontown/toon/DistributedNPCToonBase.py index c0d41408..e0b2df98 100644 --- a/toontown/toon/DistributedNPCToonBase.py +++ b/toontown/toon/DistributedNPCToonBase.py @@ -55,6 +55,7 @@ class DistributedNPCToonBase(DistributedToon.DistributedToon): self.parentToonParts() self.rescaleToon() self.resetHeight() + self.generateLaughingMan() self.rightHands = [] self.leftHands = [] self.headParts = [] diff --git a/toontown/toon/LaughingManGlobals.py b/toontown/toon/LaughingManGlobals.py index 6f3e0016..c2aab0fd 100644 --- a/toontown/toon/LaughingManGlobals.py +++ b/toontown/toon/LaughingManGlobals.py @@ -1,6 +1,5 @@ from pandac.PandaModules import * - def makeCard(book=False): cardMaker = CardMaker('laughing-man-cm') cardMaker.setHasUvs(1) @@ -27,17 +26,16 @@ def makeCard(book=False): return nodePath - def addHeadEffect(head, book=False): card = makeCard(book=book) card.setScale(1.45 if book else 2.5) card.setZ(0.05 if book else 0.5) + for nodePath in head.getChildren(): - nodePath.removeNode() + nodePath.hide() + card.instanceTo(head) - def addToonEffect(toon): - toon.getDialogueArray = lambda *args, **kwargs: [] for lod in toon.getLODNames(): - addHeadEffect(toon.getPart('head', lod)) + addHeadEffect(toon.getPart('head', lod)) \ No newline at end of file diff --git a/toontown/toon/Toon.py b/toontown/toon/Toon.py index bd09bb77..064b933d 100644 --- a/toontown/toon/Toon.py +++ b/toontown/toon/Toon.py @@ -27,7 +27,7 @@ from toontown.nametag.NametagGlobals import * from toontown.suit import SuitDNA from toontown.toonbase import TTLocalizer from toontown.toonbase import ToontownGlobals - +from toontown.toon import LaughingManGlobals def teleportDebug(requestStatus, msg, onlyIfToAv = True): if teleportNotify.getDebug(): @@ -434,6 +434,8 @@ class Toon(Avatar.Avatar, ToonHead): self.hatNodes = [] self.glassesNodes = [] self.backpackNodes = [] + self.wantLaughingMan = False + self.hasLaughingMan = False self.hat = (0, 0, 0) self.glasses = (0, 0, 0) self.backpack = (0, 0, 0) @@ -630,6 +632,7 @@ class Toon(Avatar.Avatar, ToonHead): self.rescaleToon() self.resetHeight() self.setupToonNodes() + self.generateLaughingMan() def setupToonNodes(self): rightHand = NodePath('rightHand') @@ -965,6 +968,10 @@ class Toon(Avatar.Avatar, ToonHead): return swappedTorso + def generateLaughingMan(self): + if not self.getHasLaughingMan() and self.getWantLaughingMan(): + LaughingManGlobals.addToonEffect(self) + def generateHat(self, fromRTM = False): hat = self.getHat() if hat[0] >= len(ToonDNA.HatModels): @@ -1137,7 +1144,13 @@ class Toon(Avatar.Avatar, ToonHead): def getHat(self): return self.hat - + + def getWantLaughingMan(self): + return self.wantLaughingMan or (base.cr.newsManager and base.cr.newsManager.isHolidayRunning(ToontownGlobals.LAUGHING_MAN)) + + def getHasLaughingMan(self): + return self.hasLaughingMan + def setGlasses(self, glassesIdx, textureIdx, colorIdx, fromRTM = False): self.glasses = (glassesIdx, textureIdx, colorIdx) self.generateGlasses(fromRTM=fromRTM) diff --git a/toontown/toonbase/TTLocalizerEnglish.py b/toontown/toonbase/TTLocalizerEnglish.py index 63d8fca3..9a4a5813 100644 --- a/toontown/toonbase/TTLocalizerEnglish.py +++ b/toontown/toonbase/TTLocalizerEnglish.py @@ -8579,6 +8579,7 @@ SpookyPropsHolidayStart = 'Silly Meter spins Toontown into spooky mode!' BlackCatHolidayStart = 'Create a Black Cat - Today only!' BlackCatHolidayEnd = 'Black Cat day has ended!' SpookyBlackCatHolidayStart = 'Friday 13th means a Black Cat blast!' +LaughingManHolidayStart = 'Today is the day of the Laughing Man!' TopToonsMarathonStart = "The Top Toons New Year's Day Marathon has begun!" TopToonsMarathonEnd = "The Top Toons New Year's Day Marathon has ended." WinterDecorationsStart = "It's Winter Holiday time in Toontown!" diff --git a/toontown/toonbase/ToontownGlobals.py b/toontown/toonbase/ToontownGlobals.py index cfad1f72..575d9839 100644 --- a/toontown/toonbase/ToontownGlobals.py +++ b/toontown/toonbase/ToontownGlobals.py @@ -962,6 +962,7 @@ SPOOKY_PROPS = 119 SPOOKY_COSTUMES = 120 WACKY_WINTER_DECORATIONS = 121 WACKY_WINTER_CAROLING = 122 +LAUGHING_MAN = 123 TOT_REWARD_JELLYBEAN_AMOUNT = 100 TOT_REWARD_END_OFFSET_AMOUNT = 0 LawbotBossMaxDamage = 2700