2015-03-03 16:10:12 -06:00
|
|
|
from pandac.PandaModules import *
|
|
|
|
|
|
|
|
from DistributedNPCToonBase import *
|
|
|
|
from toontown.chat.ChatGlobals import *
|
|
|
|
from toontown.hood import ZoneUtil
|
|
|
|
from toontown.nametag.NametagGlobals import *
|
|
|
|
from toontown.quest import QuestChoiceGui
|
|
|
|
from toontown.quest import QuestParser
|
|
|
|
from toontown.quest import TrackChoiceGui
|
|
|
|
from toontown.toonbase import TTLocalizer
|
|
|
|
|
|
|
|
|
|
|
|
SPAMMING = 1
|
|
|
|
DOUBLE_ENTRY = 2
|
|
|
|
|
|
|
|
class DistributedSmartNPC(DistributedNPCToonBase):
|
|
|
|
|
|
|
|
def __init__(self, cr):
|
|
|
|
DistributedNPCToonBase.__init__(self, cr)
|
2015-05-30 14:47:29 -05:00
|
|
|
self.accept('chatUpdate', self.chatUpdate)
|
|
|
|
|
|
|
|
def disable(self):
|
|
|
|
self.ignoreAll()
|
|
|
|
DistributedNPCToonBase.disable(self)
|
2015-03-03 16:10:12 -06:00
|
|
|
|
|
|
|
def delayDelete(self):
|
|
|
|
DistributedNPCToonBase.delayDelete(self)
|
2015-05-30 14:47:29 -05:00
|
|
|
self.disable()
|
2015-03-03 16:10:12 -06:00
|
|
|
|
|
|
|
def handleCollisionSphereEnter(self, collEntry):
|
|
|
|
self.sendUpdate('avatarEnter', [])
|
|
|
|
|
2015-06-09 11:00:08 -05:00
|
|
|
def chatUpdate(self, message, chatFlags):
|
2015-05-30 14:47:29 -05:00
|
|
|
self.sendUpdate('talkMessage', [base.localAvatar.doId, message])
|
|
|
|
|
2015-03-03 16:10:12 -06:00
|
|
|
def greet(self, npcId, avId):
|
|
|
|
if avId in base.cr.doId2do:
|
|
|
|
avName = base.cr.doId2do.get(avId).getName()
|
|
|
|
self.setChatAbsolute('Hello, %s' % avName + '!', CFSpeech | CFTimeout)
|
|
|
|
|
|
|
|
def dismiss(self, avId, statusCode):
|
|
|
|
if avId in base.cr.doId2do:
|
|
|
|
avName = base.cr.doId2do.get(avId).getName()
|
|
|
|
if statusCode == SPAMMING:
|
|
|
|
self.setChatAbsolute('Slow down there, %s' % avName + '. I can\'t even understand you!', CFSpeech | CFTimeout)
|
|
|
|
elif statusCode == DOUBLE_ENTRY:
|
|
|
|
self.setChatAbsolute('Well hey there %s' % avName + ', didn\'t we JUST talk?', CFSpeech | CFTimeout)
|
|
|
|
|
|
|
|
def respond(self, npcId, message, avId):
|
|
|
|
try:
|
|
|
|
name = base.cr.doId2do.get(avId).getName()
|
|
|
|
self.setChatAbsolute(message, CFSpeech | CFTimeout)
|
|
|
|
except:
|
|
|
|
print 'Responding to non-available character!'
|