From b4af78209c6606e48530992e1571f2ea55e94db6 Mon Sep 17 00:00:00 2001 From: DenialMC Date: Sat, 4 Apr 2015 12:50:42 +0300 Subject: [PATCH] Add Laughing Man holiday end (everybody loses their head), add Laughing Man to DNA instead of explicitly showing it, add ~dna laughingman [0/1] --- toontown/ai/NewsManager.py | 7 +++++ toontown/battle/Movie.py | 2 +- toontown/battle/MovieNPCSOS.py | 2 -- toontown/cogdominium/CogdoBarrelRoomMovies.py | 2 +- toontown/cogdominium/CogdoElevatorMovie.py | 2 +- .../cogdominium/CogdoExecutiveSuiteMovies.py | 2 +- toontown/cogdominium/CogdoFlyingGameMovies.py | 2 +- toontown/cogdominium/CogdoMazeGameMovies.py | 2 +- toontown/estate/DistributedToonStatuary.py | 2 +- toontown/hood/TTHoodAI.py | 2 +- toontown/safezone/OZSafeZoneLoader.py | 2 +- toontown/toon/DistributedToonAI.py | 10 ++++++ toontown/toon/NPCFriendPanel.py | 2 -- toontown/toon/NPCToons.py | 3 +- toontown/toon/Toon.py | 24 +++++++------- toontown/toon/ToonDNA.py | 31 ++++++++++++++++--- toontown/toon/ToonHead.py | 4 +++ 17 files changed, 70 insertions(+), 31 deletions(-) diff --git a/toontown/ai/NewsManager.py b/toontown/ai/NewsManager.py index c088ba99..fe7cd551 100644 --- a/toontown/ai/NewsManager.py +++ b/toontown/ai/NewsManager.py @@ -371,6 +371,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.setSpookyBlackCatHolidayEnd() + elif holidayId == ToontownGlobals.LAUGHING_MAN: + if hasattr(base, 'localAvatar') and base.localAvatar: + self.setLaughingManHolidayEnd() elif holidayId == ToontownGlobals.TOP_TOONS_MARATHON: if hasattr(base, 'localAvatar') and base.localAvatar and hasattr(base.localAvatar, 'chatMgr') and base.localAvatar.chatMgr: self.setTopToonsMarathonEnd() @@ -544,6 +547,10 @@ class NewsManager(DistributedObject.DistributedObject): for currToon in base.cr.toons.values(): currToon.generateLaughingMan() + def setLaughingManHolidayEnd(self): + for currToon in base.cr.toons.values(): + currToon.swapToonHead(laughingMan=False) + def setTopToonsMarathonStart(self): base.localAvatar.setSystemMessage(0, TTLocalizer.TopToonsMarathonStart) diff --git a/toontown/battle/Movie.py b/toontown/battle/Movie.py index 98ae4a2a..c3b3245b 100644 --- a/toontown/battle/Movie.py +++ b/toontown/battle/Movie.py @@ -338,7 +338,7 @@ class Movie(DirectObject.DirectObject): self.tutorialTom = Toon.Toon() dna = ToonDNA.ToonDNA() - dna.newToonFromProperties(*('dls', 'ms', 'm', 'm', 7, 0, 7, 7, 2, 6, 2, 6, 2, 16)) + dna.newToonFromProperties(*('dls', 'ms', 'm', 'm', 7, 0, 7, 7, 2, 6, 2, 6, 2, 16, 0)) self.tutorialTom.setDNA(dna) self.tutorialTom.setName(TTLocalizer.NPCToonNames[20000]) self.tutorialTom.setPickable(0) diff --git a/toontown/battle/MovieNPCSOS.py b/toontown/battle/MovieNPCSOS.py index 1dd4bee1..932838ae 100644 --- a/toontown/battle/MovieNPCSOS.py +++ b/toontown/battle/MovieNPCSOS.py @@ -91,8 +91,6 @@ def __getSoundTrack(level, delay, duration = None, node = None): def teleportIn(attack, npc, pos = Point3(0, 0, 0), hpr = Vec3(180.0, 0.0, 0.0)): - if npc.getName() == 'Magic Cat': - npc.generateLaughingMan(True) a = Func(npc.reparentTo, attack['battle']) b = Func(npc.setPos, pos) c = Func(npc.setHpr, hpr) diff --git a/toontown/cogdominium/CogdoBarrelRoomMovies.py b/toontown/cogdominium/CogdoBarrelRoomMovies.py index 34a156e8..ba2ba720 100644 --- a/toontown/cogdominium/CogdoBarrelRoomMovies.py +++ b/toontown/cogdominium/CogdoBarrelRoomMovies.py @@ -66,7 +66,7 @@ class CogdoBarrelRoomIntro(CogdoGameMovie): self.frame.hide() backgroundGui.removeNode() self.toonDNA = ToonDNA.ToonDNA() - self.toonDNA.newToonFromProperties('dss', 'ss', 'm', 'm', 2, 0, 2, 2, 1, 8, 1, 8, 1, 14) + self.toonDNA.newToonFromProperties('dss', 'ss', 'm', 'm', 2, 0, 2, 2, 1, 8, 1, 8, 1, 14, 0) self.toonHead = Toon.Toon() self.toonHead.setDNA(self.toonDNA) self.makeSuit('sc') diff --git a/toontown/cogdominium/CogdoElevatorMovie.py b/toontown/cogdominium/CogdoElevatorMovie.py index 03a25933..c78ae53b 100644 --- a/toontown/cogdominium/CogdoElevatorMovie.py +++ b/toontown/cogdominium/CogdoElevatorMovie.py @@ -67,7 +67,7 @@ class CogdoElevatorMovie(CogdoGameMovie): self.frame.hide() backgroundGui.removeNode() self.toonDNA = ToonDNA.ToonDNA() - self.toonDNA.newToonFromProperties('dss', 'ss', 'm', 'm', 2, 0, 2, 2, 1, 8, 1, 8, 1, 14) + self.toonDNA.newToonFromProperties('dss', 'ss', 'm', 'm', 2, 0, 2, 2, 1, 8, 1, 8, 1, 14, 0) self.toonHead = Toon.Toon() self.toonHead.setDNA(self.toonDNA) self.makeSuit('sc') diff --git a/toontown/cogdominium/CogdoExecutiveSuiteMovies.py b/toontown/cogdominium/CogdoExecutiveSuiteMovies.py index 0377ba18..4eb230ec 100644 --- a/toontown/cogdominium/CogdoExecutiveSuiteMovies.py +++ b/toontown/cogdominium/CogdoExecutiveSuiteMovies.py @@ -71,7 +71,7 @@ class CogdoExecutiveSuiteIntro(CogdoGameMovie): self.frame.hide() backgroundGui.removeNode() self.toonDNA = ToonDNA.ToonDNA() - self.toonDNA.newToonFromProperties('dss', 'ss', 'm', 'm', 2, 0, 2, 2, 1, 8, 1, 8, 1, 14) + self.toonDNA.newToonFromProperties('dss', 'ss', 'm', 'm', 2, 0, 2, 2, 1, 8, 1, 8, 1, 14, 0) self.toonHead = Toon.Toon() self.toonHead.setDNA(self.toonDNA) self.makeSuit('sc') diff --git a/toontown/cogdominium/CogdoFlyingGameMovies.py b/toontown/cogdominium/CogdoFlyingGameMovies.py index 1180d58a..4caf0daf 100644 --- a/toontown/cogdominium/CogdoFlyingGameMovies.py +++ b/toontown/cogdominium/CogdoFlyingGameMovies.py @@ -52,7 +52,7 @@ class CogdoFlyingGameIntro(CogdoGameMovie): def load(self): CogdoGameMovie.load(self) self.toonDNA = ToonDNA.ToonDNA() - self.toonDNA.newToonFromProperties('dss', 'ss', 'm', 'm', 2, 0, 2, 2, 1, 8, 1, 8, 1, 14) + self.toonDNA.newToonFromProperties('dss', 'ss', 'm', 'm', 2, 0, 2, 2, 1, 8, 1, 8, 1, 14, 0) self.toonHead = Toon.Toon() self.toonHead.setDNA(self.toonDNA) self.makeSuit('sc') diff --git a/toontown/cogdominium/CogdoMazeGameMovies.py b/toontown/cogdominium/CogdoMazeGameMovies.py index ff9a8efa..d20491ce 100644 --- a/toontown/cogdominium/CogdoMazeGameMovies.py +++ b/toontown/cogdominium/CogdoMazeGameMovies.py @@ -56,7 +56,7 @@ class CogdoMazeGameIntro(CogdoGameMovie): def load(self): CogdoGameMovie.load(self) self.toonDNA = ToonDNA.ToonDNA() - self.toonDNA.newToonFromProperties('dss', 'ss', 'm', 'm', 2, 0, 2, 2, 1, 8, 1, 8, 1, 14) + self.toonDNA.newToonFromProperties('dss', 'ss', 'm', 'm', 2, 0, 2, 2, 1, 8, 1, 8, 1, 14, 0) self.toonHead = Toon.Toon() self.toonHead.setDNA(self.toonDNA) self.makeSuit('sc') diff --git a/toontown/estate/DistributedToonStatuary.py b/toontown/estate/DistributedToonStatuary.py index 3926a79e..18774b6b 100644 --- a/toontown/estate/DistributedToonStatuary.py +++ b/toontown/estate/DistributedToonStatuary.py @@ -46,7 +46,7 @@ class DistributedToonStatuary(DistributedStatuary.DistributedStatuary): self.model.setScale(self.worldScale * 1.5, self.worldScale * 1.5, self.worldScale) self.getToonPropertiesFromOptional() dna = ToonDNA.ToonDNA() - dna.newToonFromProperties(self.headType, self.torsoType, self.legType, self.gender, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) + dna.newToonFromProperties(self.headType, self.torsoType, self.legType, self.gender, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) self.setupStoneToon(dna) self.poseToonFromTypeIndex(self.typeIndex) self.toon.reparentTo(self.model) diff --git a/toontown/hood/TTHoodAI.py b/toontown/hood/TTHoodAI.py index 5509b953..730650d8 100644 --- a/toontown/hood/TTHoodAI.py +++ b/toontown/hood/TTHoodAI.py @@ -30,7 +30,7 @@ class TTHoodAI(HoodAI.HoodAI): if simbase.air.wantGloveNpc: NPCToons.createNPC( simbase.air, 2021, - (ToontownGlobals.ToontownCentral, TTLocalizer.NPCToonNames[2021], ('dss', 'ls', 's', 'm', 13, 41, 13, 13, 1, 6, 1, 6, 0, 18), 'm', 1, NPCToons.NPC_GLOVE), + (ToontownGlobals.ToontownCentral, TTLocalizer.NPCToonNames[2021], ('dss', 'ls', 's', 'm', 13, 41, 13, 13, 1, 6, 1, 6, 0, 18, 0), 'm', 1, NPCToons.NPC_GLOVE), ToontownGlobals.ToontownCentral, posIndex=0) if simbase.air.wantHalloween: diff --git a/toontown/safezone/OZSafeZoneLoader.py b/toontown/safezone/OZSafeZoneLoader.py index e69e9ae1..6ff099a2 100644 --- a/toontown/safezone/OZSafeZoneLoader.py +++ b/toontown/safezone/OZSafeZoneLoader.py @@ -146,7 +146,7 @@ class OZSafeZoneLoader(SafeZoneLoader): self.painterPete.setPlayerType(NametagGlobals.CCNonPlayer) dna = ToonDNA.ToonDNA() - dna.newToonFromProperties('hls', 'ss', 'm', 'm', 18, 0, 13, 9, 0, 0, 0, 0, 2, 15) + dna.newToonFromProperties('hls', 'ss', 'm', 'm', 18, 0, 13, 9, 0, 0, 0, 0, 2, 15, 0) self.painterPete.setDNA(dna) self.painterPete.setHat(43, 0, 0) diff --git a/toontown/toon/DistributedToonAI.py b/toontown/toon/DistributedToonAI.py index d484a7b3..0c56bd11 100644 --- a/toontown/toon/DistributedToonAI.py +++ b/toontown/toon/DistributedToonAI.py @@ -4988,6 +4988,16 @@ def dna(part, value): invoker.b_setDNAString(dna.makeNetString()) return 'Bottom texture color index set to: ' + str(dna.botTexColor) + if part == 'laughingman': + if not value.isdigit(): + return 'Laughing Man can only be 0 or 1.' + value = int(value) + if value != 0 and value != 1: + return 'Laughing Man can only be 0 or 1.' + dna.laughingMan = value + invoker.b_setDNAString(dna.makeNetString()) + return 'Laughing Man set to: ' + str(dna.laughingMan) + if part == 'save': backup = simbase.backups.load('toon', (invoker.doId,), default={}) backup.setdefault('dna', {})[value] = invoker.getDNAString() diff --git a/toontown/toon/NPCFriendPanel.py b/toontown/toon/NPCFriendPanel.py index 3bef07ba..64b83d30 100644 --- a/toontown/toon/NPCFriendPanel.py +++ b/toontown/toon/NPCFriendPanel.py @@ -217,8 +217,6 @@ class NPCFriendCard(DirectFrame): head = ToonHead.ToonHead() head.setupHead(dna, forGui=1) self.fitGeometry(head, fFlip=1, dimension=dimension) - if NPCID == 91917: - LaughingManGlobals.addHeadEffect(head, book=True) return head def fitGeometry(self, geom, fFlip = 0, dimension = 0.5): diff --git a/toontown/toon/NPCToons.py b/toontown/toon/NPCToons.py index 7fe7d3d8..9d469df0 100644 --- a/toontown/toon/NPCToons.py +++ b/toontown/toon/NPCToons.py @@ -11580,7 +11580,8 @@ NPCToonDict = {20000: (-1, 0, 10, 0, - 10), + 10, + 1), 'm', 0, NPC_REGULAR)} diff --git a/toontown/toon/Toon.py b/toontown/toon/Toon.py index 64771676..13a5a4e7 100644 --- a/toontown/toon/Toon.py +++ b/toontown/toon/Toon.py @@ -434,8 +434,6 @@ 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) @@ -552,8 +550,8 @@ class Toon(Avatar.Avatar, ToonHead): def updateToonDNA(self, newDNA, fForce = 0): self.style.gender = newDNA.getGender() oldDNA = self.style - if fForce or newDNA.head != oldDNA.head: - self.swapToonHead(newDNA.head) + if fForce or newDNA.head != oldDNA.head or newDNA.laughingMan != oldDNA.laughingMan: + self.swapToonHead(newDNA.head, newDNA.laughingMan) if fForce or newDNA.torso != oldDNA.torso: self.swapToonTorso(newDNA.torso, genClothes=0) self.loop('neutral') @@ -817,7 +815,7 @@ class Toon(Avatar.Avatar, ToonHead): self.loadAnims(HeadAnimDict[self.style.head], 'head', '500') self.loadAnims(HeadAnimDict[self.style.head], 'head', '250') - def swapToonHead(self, headStyle, copy = 1): + def swapToonHead(self, headStyle=-1, laughingMan=-1, copy = 1): self.stopLookAroundNow() self.eyelids.request('open') self.unparentToonParts() @@ -827,7 +825,10 @@ class Toon(Avatar.Avatar, ToonHead): # Bugfix: Until upstream Panda3D includes this, we have to do it here. if 'head' in self._Actor__commonBundleHandles: del self._Actor__commonBundleHandles['head'] - self.style.head = headStyle + if headStyle > -1: + self.style.head = headStyle + if laughingMan > -1: + self.style.laughingMan = laughingMan self.generateToonHead(copy) self.generateToonColor() self.parentToonParts() @@ -835,6 +836,8 @@ class Toon(Avatar.Avatar, ToonHead): self.resetHeight() self.eyelids.request('open') self.startLookAround() + if self.style.laughingMan: + LaughingManGlobals.addToonEffect(self) def generateToonColor(self): ToonHead.generateToonColor(self, self.style) @@ -969,8 +972,8 @@ class Toon(Avatar.Avatar, ToonHead): return swappedTorso def generateLaughingMan(self, force=False): - if force or (not self.getHasLaughingMan() and self.getWantLaughingMan()): - LaughingManGlobals.addToonEffect(self) + if force or self.getWantLaughingMan(): + self.swapToonHead(laughingMan=True) def generateHat(self, fromRTM = False): hat = self.getHat() @@ -1146,10 +1149,7 @@ class Toon(Avatar.Avatar, ToonHead): 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 + return self.style.laughingMan or (base.cr.newsManager and base.cr.newsManager.isHolidayRunning(ToontownGlobals.LAUGHING_MAN)) def setGlasses(self, glassesIdx, textureIdx, colorIdx, fromRTM = False): self.glasses = (glassesIdx, textureIdx, colorIdx) diff --git a/toontown/toon/ToonDNA.py b/toontown/toon/ToonDNA.py index 1a641e4a..22cafed7 100644 --- a/toontown/toon/ToonDNA.py +++ b/toontown/toon/ToonDNA.py @@ -2510,6 +2510,7 @@ class ToonDNA(AvatarDNA.AvatarDNA): string = string + 'sleeve texture color = %d\n' % self.sleeveTexColor string = string + 'bottom texture = %d\n' % self.botTex string = string + 'bottom texture color = %d\n' % self.botTexColor + string = string + 'laughing man = %d\n' % self.laughingMan return string def clone(self): @@ -2541,16 +2542,23 @@ class ToonDNA(AvatarDNA.AvatarDNA): dg.addUint8(self.gloveColor) dg.addUint8(self.legColor) dg.addUint8(self.headColor) + dg.addUint8(self.laughingMan) elif self.type == 'u': notify.error('undefined avatar') else: notify.error('unknown avatar type: ', self.type) return dg.getMessage() + def getDatagramWithFallback(self, dgi, fallback=0): + try: + return dgi.getUint8() + except: + return fallback + def isValidNetString(self, string): dg = PyDatagram(string) dgi = PyDatagramIterator(dg) - if dgi.getRemainingSize() != 15: + if dgi.getRemainingSize() not in [15, 16]: return False type = dgi.getFixedString(1) if type not in ('t',): @@ -2579,6 +2587,7 @@ class ToonDNA(AvatarDNA.AvatarDNA): gloveColor = dgi.getUint8() legColor = dgi.getUint8() headColor = dgi.getUint8() + laughingMan = self.getDatagramWithFallback(dgi, 0) if topTex >= len(Shirts): return False if topTexColor >= len(ClothesColors): @@ -2597,6 +2606,8 @@ class ToonDNA(AvatarDNA.AvatarDNA): return False if headColor >= len(allColorsList): return False + if laughingMan != 0 and laughingMan != 1: + return False return True def makeFromNetString(self, string): @@ -2625,6 +2636,7 @@ class ToonDNA(AvatarDNA.AvatarDNA): self.gloveColor = dgi.getUint8() self.legColor = dgi.getUint8() self.headColor = dgi.getUint8() + self.laughingMan = self.getDatagramWithFallback(dgi, 0) else: notify.error('unknown avatar type: ', self.type) return None @@ -2658,11 +2670,12 @@ class ToonDNA(AvatarDNA.AvatarDNA): self.legColor = color self.headColor = color self.gloveColor = 0 + self.laughingMan = 0 else: notify.error("tuple must be in format ('%s', '%s', '%s', '%s')") return - def newToonFromProperties(self, head, torso, legs, gender, armColor, gloveColor, legColor, headColor, topTexture, topTextureColor, sleeveTexture, sleeveTextureColor, bottomTexture, bottomTextureColor): + def newToonFromProperties(self, head, torso, legs, gender, armColor, gloveColor, legColor, headColor, topTexture, topTextureColor, sleeveTexture, sleeveTextureColor, bottomTexture, bottomTextureColor, laughingMan=0): self.type = 't' self.head = head self.torso = torso @@ -2678,8 +2691,9 @@ class ToonDNA(AvatarDNA.AvatarDNA): self.sleeveTexColor = sleeveTextureColor self.botTex = bottomTexture self.botTexColor = bottomTextureColor + self.laughingMan = laughingMan - def updateToonProperties(self, head = None, torso = None, legs = None, gender = None, armColor = None, gloveColor = None, legColor = None, headColor = None, topTexture = None, topTextureColor = None, sleeveTexture = None, sleeveTextureColor = None, bottomTexture = None, bottomTextureColor = None, shirt = None, bottom = None): + def updateToonProperties(self, head = None, torso = None, legs = None, gender = None, armColor = None, gloveColor = None, legColor = None, headColor = None, topTexture = None, topTextureColor = None, sleeveTexture = None, sleeveTextureColor = None, bottomTexture = None, bottomTextureColor = None, shirt = None, bottom = None, laughingMan = None): if head: self.head = head if torso: @@ -2708,6 +2722,8 @@ class ToonDNA(AvatarDNA.AvatarDNA): self.botTex = bottomTexture if bottomTextureColor: self.botTexColor = bottomTextureColor + if laughingMan: + self.laughingMan = laughingMan if shirt: str, colorIndex = shirt defn = ShirtStyles[str] @@ -2776,6 +2792,7 @@ class ToonDNA(AvatarDNA.AvatarDNA): self.legColor = color self.headColor = color self.gloveColor = 0 + self.laughingMan = 0 def asTuple(self): return (self.head, @@ -2791,7 +2808,8 @@ class ToonDNA(AvatarDNA.AvatarDNA): self.sleeveTex, self.sleeveTexColor, self.botTex, - self.botTexColor) + self.botTexColor, + self.laughingMan) def getType(self): if self.type == 't': @@ -2903,7 +2921,10 @@ class ToonDNA(AvatarDNA.AvatarDNA): def getWhiteColor(self): return allColorsList[0] - + + def isLaughingMan(self): + return self.laughingMan + def setTemporary(self, newHead, newArmColor, newLegColor, newHeadColor): if not self.cache and self.getArmColor != newArmColor: self.cache = (self.head, diff --git a/toontown/toon/ToonHead.py b/toontown/toon/ToonHead.py index 9696659f..273ba045 100644 --- a/toontown/toon/ToonHead.py +++ b/toontown/toon/ToonHead.py @@ -8,6 +8,8 @@ from direct.interval.IntervalGlobal import * from direct.fsm.ClassicFSM import ClassicFSM from direct.fsm.State import State from direct.directnotify import DirectNotifyGlobal +from toontown.toon import LaughingManGlobals + if not base.config.GetBool('want-new-anims', 1): HeadDict = {'dls': '/models/char/dogMM_Shorts-head-', 'dss': '/models/char/dogMM_Skirt-head-', @@ -194,6 +196,8 @@ class ToonHead(Actor.Actor): self.getGeomNode().setDepthTest(1) if dna.getAnimal() == 'dog': self.loop('neutral') + if dna.laughingMan: + LaughingManGlobals.addHeadEffect(self.getGeomNode(), book=True) def fitAndCenterHead(self, maxDim, forGui = 0): p1 = Point3()