Laff meter above head in bosses

This commit is contained in:
John 2015-06-07 20:27:42 +03:00 committed by Loudrob
parent def7ca4372
commit e9842a8b65
5 changed files with 71 additions and 6 deletions

View file

@ -70,7 +70,7 @@ class NametagGroup:
taskMgr.remove(self.tickTask)
self.tickTask = None
self.clearChatText()
self.clearChatText(timeout=False)
for nametag in list(self.nametags):
self.remove(nametag)
@ -280,14 +280,14 @@ class NametagGroup:
# other words, we need to clear the current chat text, pause for a
# brief moment, and then display the new chat text:
if self.getChatText():
self.clearChatText()
self.clearChatText(timeout=False)
self.stompChatText = chatText
self.stompTask = taskMgr.doMethodLater(
self.CHAT_STOMP_DELAY, self.__chatStomp, self.stompTaskName,
extraArgs=[timeout])
return
self.clearChatText()
self.clearChatText(timeout=False)
self.chatPages = chatText.split('\x07')
self.setChatPageIndex(0)
@ -306,7 +306,7 @@ class NametagGroup:
return ''
return self.chatPages[self.chatPageIndex]
def clearChatText(self, task=None):
def clearChatText(self, task=None, timeout=True):
if self.stompTask is not None:
taskMgr.remove(self.stompTask)
self.stompTask = None
@ -324,6 +324,9 @@ class NametagGroup:
nametag.setChatText('')
nametag.update()
if timeout:
messenger.send(self.chatTimeoutTaskName)
if task is not None:
return Task.done

View file

@ -120,6 +120,7 @@ class DistributedBossCog(DistributedAvatar.DistributedAvatar, BossCog.BossCog):
def disable(self):
DistributedAvatar.DistributedAvatar.disable(self)
self.removeHeadMeters()
self.battleAId = None
self.battleBId = None
self.battleA = None
@ -399,6 +400,7 @@ class DistributedBossCog(DistributedAvatar.DistributedAvatar, BossCog.BossCog):
place = self.cr.playGame.getPlace()
if place and hasattr(place, 'fsm'):
place.setState('finalBattle')
self.createHeadMeters()
def releaseToons(self, finalBattle = 0):
for toonId in self.involvedToons:
@ -418,6 +420,20 @@ class DistributedBossCog(DistributedAvatar.DistributedAvatar, BossCog.BossCog):
else:
self.toWalkMode()
def createHeadMeters(self):
for toonId in self.involvedToons:
toon = self.cr.doId2do.get(toonId)
if toon:
toon.createHeadMeter()
def removeHeadMeters(self):
for toonId in self.involvedToons:
toon = self.cr.doId2do.get(toonId)
if toon:
toon.removeHeadMeter()
def stickToonsToFloor(self):
self.unstickToons()
rayNode = CollisionNode('stickToonsToFloor')

View file

@ -2140,6 +2140,8 @@ class DistributedToon(DistributedPlayer.DistributedPlayer, Toon.Toon, Distribute
def displayTalk(self, chatString):
flags = CFSpeech | CFTimeout
self.nametag.setChatType(NametagGlobals.CHAT)
self.hideHeadMeter()
self.accept(self.nametag.chatTimeoutTaskName, self.showHeadMeter)
if ChatUtil.isThought(chatString):
flags = CFThought
self.nametag.setChatBalloonType(NametagGlobals.THOUGHT_BALLOON)

View file

@ -6,7 +6,7 @@ from toontown.toonbase import ToontownIntervals
class LaffMeter(DirectFrame):
deathColor = Vec4(0.58039216, 0.80392157, 0.34117647, 1.0)
def __init__(self, avdna, hp, maxHp):
def __init__(self, avdna, hp, maxHp, hideFull=False):
DirectFrame.__init__(self, relief=None, sortOrder=50)
self.initialiseoptions(LaffMeter)
self.container = DirectFrame(parent=self, relief=None)
@ -14,6 +14,7 @@ class LaffMeter(DirectFrame):
self.av = None
self.hp = hp
self.maxHp = maxHp
self.hideFull = hideFull
self.__obscured = 0
if self.style.type == 't':
self.isToon = 1
@ -165,7 +166,14 @@ class LaffMeter(DirectFrame):
self.adjustText()
if not quietly:
self.animatedEffect(delta)
return
self.checkVisibility()
def checkVisibility(self):
if self.hideFull:
if self.hp >= self.maxHp:
self.hide()
else:
self.show()
def start(self):
if self.av:

View file

@ -11,6 +11,7 @@ import AccessoryGlobals
import Motion
import TTEmote
import ToonDNA
import LaffMeter
from ToonHead import *
from otp.avatar import Avatar
from otp.avatar import Emote
@ -442,6 +443,7 @@ class Toon(Avatar.Avatar, ToonHead):
self.isDisguised = 0
self.defaultColorScale = None
self.jar = None
self.headMeter = None
self.setTag('pieCode', str(ToontownGlobals.PieCodeToon))
self.setFont(ToontownGlobals.getToonFont())
self.soundChatBubble = base.loadSfx('phase_3/audio/sfx/GUI_balloon_popup.ogg')
@ -3008,5 +3010,39 @@ class Toon(Avatar.Avatar, ToonHead):
return sequence
def createHeadMeter(self):
if self.headMeter:
return
self.headMeter = LaffMeter.LaffMeter(self.style, self.getHp(), self.getMaxHp(), True)
self.headMeter.av = self
self.headMeter.reparentTo(self)
self.headMeter.setPos(0, 0, self.getHeight() + 1.3)
self.headMeter.setScale(0.3)
self.headMeter.setBin("fixed", 40)
self.headMeter.setDepthTest(False)
self.headMeter.setDepthWrite(False)
self.headMeter.setBillboardPointWorld()
self.headMeter.start()
def removeHeadMeter(self):
if not self.headMeter:
return
self.headMeter.destroy()
self.headMeter = None
def hideHeadMeter(self):
if not self.headMeter:
return
self.headMeter.hide()
def showHeadMeter(self):
if not self.headMeter:
return
self.headMeter.show()
loadModels()
compileGlobalAnimList()