SOS head is now shown when you choose a NPC sos.

This commit is contained in:
John 2015-06-30 17:51:50 +03:00
parent 2463b5cff8
commit 4990317c41
4 changed files with 54 additions and 40 deletions

View file

@ -599,7 +599,7 @@ class DistributedBattleBase(DistributedNode.DistributedNode, BattleBase):
if track == SOS:
targetIndex = -1
elif track == NPCSOS:
targetIndex = -1
targetIndex = targets[i]
elif track == PETSOS:
targetIndex = -1
elif track == PASS:

View file

@ -2,6 +2,38 @@ from direct.gui.DirectGui import *
from toontown.toonbase import TTLocalizer, ToontownGlobals, ToontownBattleGlobals
import NPCToons, ToonDNA, ToonHead
def createNPCToonHead(NPCID, dimension = 0.5):
NPCInfo = NPCToons.NPCToonDict[NPCID]
dnaList = NPCInfo[2]
gender = NPCInfo[3]
if dnaList == 'r':
dnaList = NPCToons.getRandomDNA(NPCID, gender)
dna = ToonDNA.ToonDNA()
dna.newToonFromProperties(*dnaList)
head = ToonHead.ToonHead()
head.setupHead(dna, forGui=1)
fitGeometry(head, fFlip=1, dimension=dimension)
return head
def fitGeometry(geom, fFlip = 0, dimension = 0.5):
p1 = Point3()
p2 = Point3()
geom.calcTightBounds(p1, p2)
if fFlip:
t = p1[0]
p1.setX(-p2[0])
p2.setX(-t)
d = p2 - p1
biggest = max(d[0], d[2])
s = dimension / biggest
mid = (p1 + d / 2.0) * s
geomXform = hidden.attachNewNode('geomXform')
for child in geom.getChildren():
child.reparentTo(geomXform)
geomXform.setPosHprScale(-mid[0], -mid[1] + 1, -mid[2], 180, 0, 0, s, s, s)
geomXform.reparentTo(geom)
class NPCFriendPanel(DirectFrame):
def __init__(self, parent = aspect2d, callable = False, **kw):
@ -138,7 +170,7 @@ class NPCFriendCard(DirectFrame):
self.front.show()
self.back.hide()
self.NPCName['text'] = TTLocalizer.NPCToonNames[NPCID]
self.NPCHead = self.createNPCToonHead(NPCID, dimension=1.2)
self.NPCHead = createNPCToonHead(NPCID, dimension=1.2)
self.NPCHead.reparentTo(self.front)
self.NPCHead.setZ(0.45)
track, level, hp, rarity = NPCToons.getNPCTrackLevelHpRarity(NPCID)
@ -184,35 +216,3 @@ class NPCFriendCard(DirectFrame):
def showBack(self):
self.front.hide()
self.back.show()
def createNPCToonHead(self, NPCID, dimension = 0.5):
NPCInfo = NPCToons.NPCToonDict[NPCID]
dnaList = NPCInfo[2]
gender = NPCInfo[3]
if dnaList == 'r':
dnaList = NPCToons.getRandomDNA(NPCID, gender)
dna = ToonDNA.ToonDNA()
dna.newToonFromProperties(*dnaList)
head = ToonHead.ToonHead()
head.setupHead(dna, forGui=1)
self.fitGeometry(head, fFlip=1, dimension=dimension)
return head
def fitGeometry(self, geom, fFlip = 0, dimension = 0.5):
p1 = Point3()
p2 = Point3()
geom.calcTightBounds(p1, p2)
if fFlip:
t = p1[0]
p1.setX(-p2[0])
p2.setX(-t)
d = p2 - p1
biggest = max(d[0], d[2])
s = dimension / biggest
mid = (p1 + d / 2.0) * s
geomXform = hidden.attachNewNode('geomXform')
for child in geom.getChildren():
child.reparentTo(geomXform)
geomXform.setPosHprScale(-mid[0], -mid[1] + 1, -mid[2], 180, 0, 0, s, s, s)
geomXform.reparentTo(geom)

View file

@ -313,7 +313,10 @@ class TownBattle(StateData.StateData):
elif tracks[i] == BattleBase.PASS_ATTACK:
numTargets = 0
target = -2
elif tracks[i] == BattleBase.SOS or tracks[i] == BattleBase.NPCSOS or tracks[i] == BattleBase.PETSOS:
elif tracks[i] == BattleBase.NPCSOS:
numTargets = 0
target = targets[i]
elif tracks[i] == BattleBase.SOS or tracks[i] == BattleBase.PETSOS:
numTargets = 0
target = -2
elif tracks[i] == HEAL_TRACK:
@ -332,8 +335,6 @@ class TownBattle(StateData.StateData):
numTargets = None
self.toonPanels[battleIndices[i]].setValues(battleIndices[i], tracks[i], levels[i], numTargets, target, self.localNum)
return
def chooseDefaultTarget(self):
if self.track > -1:
response = {}

View file

@ -8,6 +8,7 @@ from toontown.battle import BattleBase
from direct.gui.DirectGui import *
from pandac.PandaModules import *
from toontown.toonbase import TTLocalizer
from toontown.toon.NPCFriendPanel import createNPCToonHead
class TownBattleToonPanel(DirectFrame):
notify = DirectNotifyGlobal.directNotify.newCategory('TownBattleToonPanel')
@ -22,6 +23,7 @@ class TownBattleToonPanel(DirectFrame):
self.sosText.hide()
self.fireText = DirectLabel(parent=self, relief=None, pos=(0.1, 0, 0.015), text=TTLocalizer.TownBattleToonFire, text_scale=0.06)
self.fireText.hide()
self.sosHead = None
self.undecidedText = DirectLabel(parent=self, relief=None, pos=(0.1, 0, 0.015), text=TTLocalizer.TownBattleUndecided, text_scale=0.1)
self.healthText = DirectLabel(parent=self, text='', pos=(-0.06, 0, -0.075), text_scale=0.055)
self.hpChangeEvent = None
@ -93,6 +95,7 @@ class TownBattleToonPanel(DirectFrame):
self.gagNode.hide()
self.whichText.hide()
self.passNode.hide()
self.cleanupSosHead()
if self.hasGag:
self.gag.removeNode()
self.hasGag = 0
@ -104,7 +107,12 @@ class TownBattleToonPanel(DirectFrame):
self.fireText.show()
self.whichText.show()
self.whichText['text'] = self.determineWhichText(numTargets, targetIndex, localNum, index)
elif track == BattleBase.SOS or track == BattleBase.NPCSOS or track == BattleBase.PETSOS:
elif track == BattleBase.NPCSOS:
self.sosHead = createNPCToonHead(targetIndex)
self.sosHead.reparentTo(self)
self.sosHead.setPos(0.1, 0, 0.045)
self.sosHead.setScale(0.24)
elif track == BattleBase.SOS or track == BattleBase.PETSOS:
self.sosText.show()
elif track >= MIN_TRACK_INDEX and track <= MAX_TRACK_INDEX:
self.undecidedText.hide()
@ -120,7 +128,6 @@ class TownBattleToonPanel(DirectFrame):
self.whichText['text'] = self.determineWhichText(numTargets, targetIndex, localNum, index)
else:
self.notify.error('Bad track value: %s' % track)
return
def determineWhichText(self, numTargets, targetIndex, localNum, index):
returnStr = ''
@ -152,8 +159,14 @@ class TownBattleToonPanel(DirectFrame):
del self.gag
self.gagNode.removeNode()
del self.gagNode
self.cleanupSosHead()
DirectFrame.destroy(self)
def cleanupSosHead(self):
if self.sosHead:
self.sosHead.removeNode()
self.sosHead = None
def cleanupLaffMeter(self):
self.notify.debug('Cleaning up laffmeter!')
self.ignore(self.hpChangeEvent)