Moved TMS' Toontorial to a more current branch

This commit is contained in:
Anthony Castelli 2014-05-11 11:42:14 -07:00
parent 726bfe14ab
commit cb479b0e67
6 changed files with 149 additions and 27 deletions

View file

@ -51,6 +51,9 @@ from toontown.coghq.CountryClubManagerAI import CountryClubManagerAI
# Suits.
from toontown.suit.SuitInvasionManagerAI import SuitInvasionManagerAI
# Toontorial
from toontown.tutorial.TutorialManagerAI import TutorialManagerAI
import time
class ToontownAIRepository(ToontownInternalRepository):
@ -169,6 +172,9 @@ class ToontownAIRepository(ToontownInternalRepository):
self.trophyMgr = DistributedTrophyMgrAI(self)
self.trophyMgr.generateWithRequired(2)
self.tutorialManager = TutorialManagerAI(self)
self.tutorialManager.generateWithRequired(2)
def createZones(self):
"""
Spawn safezone objects, streets, doors, NPCs, etc.

View file

@ -13,6 +13,8 @@ from toontown.char import Char
from toontown.suit import SuitDNA
from toontown.suit import Suit
from toontown.quest import QuestParser
from toontown.dna.DNAStorage import DNAStorage
from toontown.dna.DNADoor import DNADoor
class DistributedTutorialInterior(DistributedObject.DistributedObject):
@ -86,7 +88,7 @@ class DistributedTutorialInterior(DistributedObject.DistributedObject):
self.interior = loader.loadModel('phase_3.5/models/modules/toon_interior_tutorial')
self.interior.reparentTo(render)
dnaStore = DNAStorage()
node = loader.loadDNAFile(self.cr.playGame.hood.dnaStore, 'phase_3.5/dna/tutorial_street.xml')
node = loader.loadDNA('phase_3.5/dna/tutorial_street.xml').generate(self.dnaStore)
self.street = render.attachNewNode(node)
self.street.flattenMedium()
self.street.setPosHpr(-17, 42, -0.5, 180, 0, 0)

View file

@ -4,9 +4,15 @@ from direct.distributed.DistributedObjectAI import DistributedObjectAI
class DistributedTutorialInteriorAI(DistributedObjectAI):
notify = DirectNotifyGlobal.directNotify.newCategory("DistributedTutorialInteriorAI")
def setZoneIdAndBlock(self, todo0, todo1):
pass
def __init__(self, air, zoneId, npcId):
DistributedObjectAI.__init__(self, air)
self.zoneId = zoneId
self.block = 0
self.npcId = npcId
def setTutorialNpcId(self, todo0):
pass
def getZoneIdAndBlock(self):
return (self.zoneId, self.block)
def getTutorialNpcId(self):
return self.npcId

View file

@ -20,6 +20,8 @@ from otp.nametag.NametagConstants import *
from toontown.ai import DistributedBlackCatMgr
from direct.showbase import PythonUtil
from direct.interval.IntervalGlobal import *
from otp.nametag.NametagConstants import *
notify = DirectNotifyGlobal.directNotify.newCategory('QuestParser')
lineDict = {}
globalVarDict = {}
@ -130,6 +132,10 @@ class NPCMoviePlayer(DirectObject.DirectObject):
return
def getVar(self, varName):
if varName[0] == '"':
varName = varName[1:-1]
return globals()[varName]
if self.privateVarDict.has_key(varName):
return self.privateVarDict[varName]
elif globalVarDict.has_key(varName):
@ -463,10 +469,17 @@ class NPCMoviePlayer(DirectObject.DirectObject):
def parseLoad(self, line):
if len(line) == 3:
token, varName, modelPath = line
node = loader.loadModel(modelPath)
modelPath = modelPath[1:-1]
fn = Filename(modelPath)
fn.setExtension('bam')
node = loader.loadModel(fn)
elif len(line) == 4:
token, varName, modelPath, subNodeName = line
node = loader.loadModel(modelPath).find('**/' + subNodeName)
modelPath = modelPath[1:-1]
fn = Filename(modelPath)
fn.setExtension('bam')
subNodeName = subNodeName[1:-1]
node = loader.loadModel(fn).find('**/' + subNodeName)
else:
notify.error('invalid parseLoad command')
self.setVar(varName, node)
@ -572,6 +585,7 @@ class NPCMoviePlayer(DirectObject.DirectObject):
subNodeName = None
elif len(line) == 4:
token, childNodeName, parentNodeName, subNodeName = line
subNodeName = subNodeName[1:-1]
childNode = self.getVar(childNodeName)
if subNodeName:
parentNode = self.getVar(parentNodeName).find(subNodeName)
@ -663,8 +677,8 @@ class NPCMoviePlayer(DirectObject.DirectObject):
extraChatFlags = None
dialogueList = []
for arg in args:
if type(arg) == type(0):
quitButton = arg
if type(arg) == type(0) or type(arg) == type(1.0):
quitButton = int(arg)
elif type(arg) == type(''):
if len(arg) > 2 and arg[:2] == 'CF':
extraChatFlags = eval(arg)
@ -722,9 +736,9 @@ class NPCMoviePlayer(DirectObject.DirectObject):
avatarName = line[1]
avatar = self.getVar(avatarName)
if self.toon.getStyle().gender == 'm':
chatString = eval('TTLocalizer.' + line[2] % 'Mickey')
chatString = getattr(TTLocalizer, line[2][1:-1] % 'Mickey')
else:
chatString = eval('TTLocalizer.' + line[2] % 'Minnie')
chatString = getattr(TTLocalizer, line[2][1:-1] % 'Minnie')
quitButton, extraChatFlags, dialogueList = self.parseExtraChatArgs(line[3:])
return Func(avatar.setLocalPageChat, chatString, quitButton, extraChatFlags, dialogueList)
@ -737,9 +751,9 @@ class NPCMoviePlayer(DirectObject.DirectObject):
localizerAvatarName = toAvatar.getName().capitalize()
toAvatarName = eval('TTLocalizer.' + localizerAvatarName)
if self.toon.getStyle().gender == 'm':
chatString = eval('TTLocalizer.' + line[3] % 'Mickey')
chatString = getattr(TTLocalizer, line[3][1:-1] % 'Mickey')
else:
chatString = eval('TTLocalizer.' + line[3] % 'Minnie')
chatString = getattr(TTLocalizer, line[3][1:-1] % 'Minnie')
chatString = chatString.replace('%s', toAvatarName)
quitButton, extraChatFlags, dialogueList = self.parseExtraChatArgs(line[4:])
return Func(avatar.setLocalPageChat, chatString, quitButton, extraChatFlags, dialogueList)
@ -857,8 +871,13 @@ class NPCMoviePlayer(DirectObject.DirectObject):
def parseFunction(self, line):
token, objectName, functionName = line
object = self.getVar(objectName)
cfunc = compile('object' + '.' + functionName, '<string>', 'eval')
return Func(eval(cfunc))
# cfunc = compile('object' + '.' + functionName, '<string>', 'eval')
# return Func(eval(cfunc))
functionName = functionName[1:-1]
func = object
for fn in functionName.split('.'):
func = getattr(func, fn)
return Func(func)
def parseAddLaffMeter(self, line):
token, maxHpDelta = line
@ -880,17 +899,17 @@ class NPCMoviePlayer(DirectObject.DirectObject):
token, track, level, number = line
inventory = self.getVar('inventory')
countSound = base.loadSfx('phase_3.5/audio/sfx/tick_counter.ogg')
return Sequence(Func(base.playSfx, countSound), Func(inventory.buttonBoing, track, level), Func(inventory.addItems, track, level, number), Func(inventory.updateGUI, track, level))
return Sequence(Func(base.playSfx, countSound), Func(inventory.buttonBoing, int(track), int(level)), Func(inventory.addItems, int(track), int(level), int(number)), Func(inventory.updateGUI, int(track), int(level)))
def parseSetInventory(self, line):
token, track, level, number = line
inventory = self.getVar('inventory')
return Sequence(Func(inventory.setItem, track, level, number), Func(inventory.updateGUI, track, level))
return Sequence(Func(inventory.setItem, int(track), int(level), int(number)), Func(inventory.updateGUI, int(track), int(level)))
def parseSetInventoryYPos(self, line):
token, track, level, yPos = line
inventory = self.getVar('inventory')
button = inventory.buttons[track][level].stateNodePath[0]
button = inventory.buttons[int(track)][int(level)].stateNodePath[0]
text = button.find('**/+TextNode')
return Sequence(Func(text.setY, yPos))
@ -907,7 +926,7 @@ class NPCMoviePlayer(DirectObject.DirectObject):
elif val == 0:
return Func(inventory.hideDetail)
elif val == 1:
return Func(inventory.showDetail, track, level)
return Func(inventory.showDetail, int(track), int(level))
else:
notify.error('invalid inventory detail level: %s' % val)

View file

@ -1,9 +1,33 @@
from direct.directnotify import DirectNotifyGlobal
from toontown.suit.DistributedSuitBaseAI import DistributedSuitBaseAI
from toontown.tutorial.DistributedBattleTutorialAI import DistributedBattleTutorialAI
from panda3d.core import *
import SuitDNA
class FakeBattleManager:
def destroy(self, battle):
pass
class DistributedTutorialSuitAI(DistributedSuitBaseAI):
notify = DirectNotifyGlobal.directNotify.newCategory("DistributedTutorialSuitAI")
def requestBattle(self, todo0, todo1, todo2, todo3, todo4, todo5):
def __init__(self, air):
DistributedSuitBaseAI.__init__(self, air, None)
suitDNA = SuitDNA.SuitDNA()
suitDNA.newSuit('f')
self.dna = suitDNA
self.setLevel(0)
def destroy(self):
del self.dna
def requestBattle(self, x, y, z, h, p, r):
self.confrontPosHpr = (LPoint3f(x, y, z), LPoint3f(h, p, r))
avId = self.air.getAvatarIdFromSender()
battle = DistributedBattleTutorialAI(self.air, FakeBattleManager(), LPoint3f(x,y,z), self, avId, 20001, maxSuits=1, tutorialFlag=1)
battle.generateWithRequired(self.zoneId)
battle.battleCellId = 0
pass
def getConfrontPosHpr(self):
return self.confrontPosHpr

View file

@ -1,11 +1,67 @@
from direct.directnotify import DirectNotifyGlobal
from direct.distributed.DistributedObjectAI import DistributedObjectAI
from toontown.building.DistributedTutorialInteriorAI import DistributedTutorialInteriorAI
from toontown.toon import NPCToons
from toontown.building import DoorTypes
from toontown.building import DistributedDoorAI
from toontown.building.DistributedBuildingAI import DistributedBuildingAI
from toontown.suit.DistributedTutorialSuitAI import DistributedTutorialSuitAI
from toontown.toonbase import ToontownBattleGlobals
import types
class TZoneStruct:
branch = 0
street = 0
shop = 0
hq = 0
class TutorialManagerAI(DistributedObjectAI):
notify = DirectNotifyGlobal.directNotify.newCategory("TutorialManagerAI")
def __init__(self, air):
DistributedObjectAI.__init__(self, air)
self.avId2Zones = {}
def requestTutorial(self):
pass
avId = self.air.getAvatarIdFromSender()
zones = TZoneStruct()
zones.branch = 20000
zones.street = self.air.allocateZone()
zones.shop = self.air.allocateZone()
zones.hq = self.air.allocateZone()
npcDesc = NPCToons.NPCToonDict.get(20000)
npc = NPCToons.createNPC(self.air, 20000, npcDesc, zones.shop, 0)
npc.setTutorial(1)
int = DistributedTutorialInteriorAI(self.air, zones.shop, npc.getDoId())
int.generateWithRequired(zones.shop)
door0 = DistributedDoorAI.DistributedDoorAI(self.air, 2, DoorTypes.EXT_STANDARD, doorIndex=0)
insideDoor0 = DistributedDoorAI.DistributedDoorAI(self.air, 0, DoorTypes.INT_STANDARD, doorIndex=0)
door0.setOtherDoor(insideDoor0)
insideDoor0.setOtherDoor(door0)
door0.zoneId = zones.street
insideDoor0.zoneId = zones.shop
door0.generateWithRequired(zones.street)
door0.sendUpdate('setDoorIndex', [door0.getDoorIndex()])
insideDoor0.generateWithRequired(zones.shop)
insideDoor0.sendUpdate('setDoorIndex', [insideDoor0.getDoorIndex()])
def getExteriorAndInteriorZoneId(self):
return (self.zoneId, 0)
bldg = DistributedBuildingAI(self.air, 2, zones.street, self.air.trophyMgr)
#hack alert
bldg.getExteriorAndInteriorZoneId = types.MethodType(getExteriorAndInteriorZoneId, bldg)
bldg.generateWithRequired(zones.street)
bldg.setState('toon')
suit = DistributedTutorialSuitAI(self.air)
suit.generateWithRequired(zones.street)
self.d_enterTutorial(avId, zones.branch, zones.street, zones.shop, zones.hq)
def rejectTutorial(self):
pass
@ -13,15 +69,24 @@ class TutorialManagerAI(DistributedObjectAI):
def requestSkipTutorial(self):
pass
def skipTutorialResponse(self, todo0):
pass
def d_skipTutorialResponse(self, avId, allOk):
self.sendUpdateToAvatarId(avId, 'skipTutorialResponse', [allOk])
def enterTutorial(self, todo0, todo1, todo2, todo3):
pass
def d_enterTutorial(self, avId, branchZone, streetZone, shopZone, hqZone):
self.sendUpdateToAvatarId(avId, 'enterTutorial', [branchZone, streetZone, shopZone, hqZone])
def allDone(self):
pass
def toonArrived(self):
pass
avId = self.air.getAvatarIdFromSender()
av = self.air.doId2do[avId]
av.b_setQuests([])
av.b_setQuestHistory([])
av.b_setRewardHistory(0, [])
av.setHp(15)
if av.inventory.numItem(ToontownBattleGlobals.THROW_TRACK, 0) == 0:
av.inventory.addItem(ToontownBattleGlobals.THROW_TRACK, 0)
if av.inventory.numItem(ToontownBattleGlobals.SQUIRT_TRACK, 0) == 0:
av.inventory.addItem(ToontownBattleGlobals.SQUIRT_TRACK, 0)
av.d_setInventory(av.inventory.makeNetString())