mirror of
https://github.com/Sneed-Group/Poodletooth-iLand
synced 2025-01-09 17:53:50 +00:00
Holocaust Talkative Tyler
This commit is contained in:
parent
57cb06e3fa
commit
7ad94d8034
8 changed files with 2 additions and 319 deletions
8
dependencies/astron/dclass/stride.dc
vendored
8
dependencies/astron/dclass/stride.dc
vendored
|
@ -255,7 +255,6 @@ from toontown.coghq import DistributedCogHQDoor/AI
|
|||
from toontown.coghq import DistributedSellbotHQDoor/AI
|
||||
from toontown.toon import DistributedNPCToonBase/AI
|
||||
from toontown.toon import DistributedNPCToon/AI
|
||||
from toontown.toon import DistributedSmartNPC/AI
|
||||
from toontown.toon import DistributedNPCSpecialQuestGiver/AI
|
||||
from toontown.toon import DistributedNPCFlippyInToonHall/AI
|
||||
from toontown.toon import DistributedNPCScientist/AI
|
||||
|
@ -1745,13 +1744,6 @@ dclass DistributedNPCToon : DistributedNPCToonBase {
|
|||
chooseTrack(int8) airecv clsend;
|
||||
};
|
||||
|
||||
dclass DistributedSmartNPC : DistributedNPCToonBase {
|
||||
greet(uint32, uint32) broadcast ram;
|
||||
talkMessage(uint32, string) airecv clsend;
|
||||
respond(uint32, string, uint32) broadcast ram;
|
||||
dismiss(uint32, uint16) broadcast ram;
|
||||
};
|
||||
|
||||
dclass DistributedNPCSpecialQuestGiver : DistributedNPCToonBase {
|
||||
setMovie(uint8, uint32, uint32, uint16[], int16) broadcast ram;
|
||||
setMovieDone() airecv clsend;
|
||||
|
|
1
dependencies/config/general.prc
vendored
1
dependencies/config/general.prc
vendored
|
@ -99,7 +99,6 @@ want-cogbuildings #t
|
|||
# Optional:
|
||||
show-total-population #t
|
||||
want-mat-all-tailors #t
|
||||
want-talkative-tyler #f
|
||||
estate-day-night #t
|
||||
want-garden-game #f
|
||||
want-language-selection #t
|
||||
|
|
|
@ -1,53 +0,0 @@
|
|||
from panda3d.core import *
|
||||
|
||||
from DistributedNPCToonBase import *
|
||||
from toontown.hood import ZoneUtil
|
||||
from otp.nametag.NametagConstants 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)
|
||||
self.accept('chatUpdate', self.chatUpdate)
|
||||
|
||||
def disable(self):
|
||||
self.ignoreAll()
|
||||
DistributedNPCToonBase.disable(self)
|
||||
|
||||
def delayDelete(self):
|
||||
DistributedNPCToonBase.delayDelete(self)
|
||||
self.disable()
|
||||
|
||||
def handleCollisionSphereEnter(self, collEntry):
|
||||
self.sendUpdate('avatarEnter', [])
|
||||
|
||||
def chatUpdate(self, message, chatFlags):
|
||||
self.sendUpdate('talkMessage', [base.localAvatar.doId, message])
|
||||
|
||||
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!'
|
|
@ -1,76 +0,0 @@
|
|||
from otp.ai.AIBaseGlobal import *
|
||||
from direct.task.Task import Task
|
||||
from panda3d.core import *
|
||||
from DistributedNPCToonBaseAI import *
|
||||
from toontown.quest import Quests
|
||||
import time
|
||||
from QuestionMgr import ChatterBotFactory, ChatterBotType
|
||||
from direct.task import Task
|
||||
|
||||
class DistributedSmartNPCAI(DistributedNPCToonBaseAI):
|
||||
|
||||
def __init__(self, air, npcId, questCallback = None, hq = 0):
|
||||
DistributedNPCToonBaseAI.__init__(self, air, npcId, questCallback)
|
||||
self.air = air
|
||||
self.personOfInterest = 0
|
||||
self.stopDouble = 0
|
||||
self.nameOfInterest = ''
|
||||
self.factory = ChatterBotFactory()
|
||||
self.engine = self.factory.create(ChatterBotType.CLEVERBOT)
|
||||
self.brain = self.engine.create_session()
|
||||
self.myTask = taskMgr.doMethodLater(0.5, self.tylerTask, 'tylerTask')
|
||||
self.index = 0
|
||||
|
||||
def tylerTask(self, task):
|
||||
if task.time >= 5:
|
||||
self.index = 0
|
||||
if task.time <= 25:
|
||||
return task.cont
|
||||
self.response('I guess you don\'t want to talk anymore %s' % self.nameOfInterest + '...', self.personOfInterest)
|
||||
self.stopDouble = self.personOfInterest
|
||||
self.personOfInterest = 0
|
||||
self.nameOfInterest = ''
|
||||
return task.done
|
||||
|
||||
def restartTask(self):
|
||||
taskMgr.remove(self.myTask)
|
||||
taskMgr.add(self.myTask)
|
||||
|
||||
def avatarEnter(self):
|
||||
if not self.personOfInterest:
|
||||
sender = self.air.getAvatarIdFromSender()
|
||||
if not sender == self.stopDouble:
|
||||
name = self.air.doId2do.get(sender).getName()
|
||||
self.personOfInterest = sender
|
||||
self.nameOfInterest = name
|
||||
self.sendUpdate('greet', [self.npcId, sender])
|
||||
self.brain = self.engine.create_session()
|
||||
else:
|
||||
self.sendUpdate('dismiss', [sender, 2])
|
||||
pass
|
||||
else:
|
||||
#Tyler is busy!
|
||||
pass
|
||||
|
||||
def talkMessage(self, sender, message):
|
||||
if sender == self.personOfInterest:
|
||||
self.index += 1
|
||||
if self.index >= 4:
|
||||
self.stopDouble = self.personOfInterest
|
||||
self.personOfInterest = 0
|
||||
self.nameOfInterest = ''
|
||||
taskMgr.remove(self.myTask)
|
||||
self.index = 0
|
||||
self.sendUpdate('dismiss', [sender, 1])
|
||||
return
|
||||
self.restartTask()
|
||||
self.generateAnswer(message, sender)
|
||||
|
||||
def generateAnswer(self, message, sender):
|
||||
name = self.air.doId2do.get(sender).getName()
|
||||
answer = self.brain.think(message)
|
||||
self.response(answer, sender)
|
||||
|
||||
def response(self, response, sendTo):
|
||||
self.sendUpdate('respond', [self.npcId, response, sendTo])
|
||||
self.restartTask()
|
|
@ -67,9 +67,8 @@ NPC_PARTYPERSON = 8
|
|||
NPC_SPECIALQUESTGIVER = 9
|
||||
NPC_FLIPPYTOONHALL = 10
|
||||
NPC_SCIENTIST = 11
|
||||
NPC_SMART = 12
|
||||
NPC_GLOVE = 13
|
||||
NPC_LAFF_RESTOCK = 14
|
||||
NPC_GLOVE = 12
|
||||
NPC_LAFF_RESTOCK = 13
|
||||
CLERK_COUNTDOWN_TIME = 120
|
||||
TAILOR_COUNTDOWN_TIME = 300
|
||||
|
||||
|
@ -90,7 +89,6 @@ def createNPC(air, npcId, desc, zoneId, posIndex = 0, questCallback = None):
|
|||
import DistributedNPCSpecialQuestGiverAI
|
||||
import DistributedNPCFlippyInToonHallAI
|
||||
import DistributedNPCScientistAI
|
||||
import DistributedSmartNPCAI
|
||||
import DistributedNPCGloveAI
|
||||
import DistributedNPCLaffRestockAI
|
||||
canonicalZoneId, name, dnaType, gender, protected, type = desc
|
||||
|
@ -118,8 +116,6 @@ def createNPC(air, npcId, desc, zoneId, posIndex = 0, questCallback = None):
|
|||
npc = DistributedNPCFlippyInToonHallAI.DistributedNPCFlippyInToonHallAI(air, npcId)
|
||||
elif type == NPC_SCIENTIST:
|
||||
npc = DistributedNPCScientistAI.DistributedNPCScientistAI(air, npcId)
|
||||
elif type == NPC_SMART:
|
||||
npc = DistributedSmartNPCAI.DistributedSmartNPCAI(air, npcId)
|
||||
elif type == NPC_GLOVE:
|
||||
npc = DistributedNPCGloveAI.DistributedNPCGloveAI(air, npcId)
|
||||
elif type == NPC_LAFF_RESTOCK:
|
||||
|
@ -161,9 +157,6 @@ def createNpcsInZone(air, zoneId):
|
|||
if npcDesc[5] == NPC_PARTYPERSON:
|
||||
if not air.wantParties:
|
||||
continue
|
||||
if npcDesc[5] == NPC_SMART:
|
||||
if not config.GetBool('want-talkative-tyler', False):
|
||||
continue
|
||||
npcs.append(createNPC(air, npcId, npcDesc, zoneId, posIndex=i))
|
||||
return npcs
|
||||
|
||||
|
@ -225,12 +218,6 @@ NPCToonDict = {20000: (-1,
|
|||
'm',
|
||||
1,
|
||||
NPC_SPECIALQUESTGIVER),
|
||||
998: (2000,
|
||||
lnames[998],
|
||||
'r',
|
||||
'm',
|
||||
1,
|
||||
NPC_SMART),
|
||||
999: (-1,
|
||||
lnames[999],
|
||||
'r',
|
||||
|
|
|
@ -1,139 +0,0 @@
|
|||
# Embedded file name: /Users/pierredavidbelanger/Dev/chatter-bot-api/python/chatterbotapi.py
|
||||
import md5
|
||||
import urllib
|
||||
import urllib2
|
||||
import uuid
|
||||
import xml.dom.minidom
|
||||
|
||||
class ChatterBotType:
|
||||
CLEVERBOT = 1
|
||||
JABBERWACKY = 2
|
||||
PANDORABOTS = 3
|
||||
|
||||
|
||||
class ChatterBotFactory:
|
||||
|
||||
def create(self, type, arg = None):
|
||||
if type == ChatterBotType.CLEVERBOT:
|
||||
return _Cleverbot('http://www.cleverbot.com/webservicemin', 35)
|
||||
elif type == ChatterBotType.JABBERWACKY:
|
||||
return _Cleverbot('http://jabberwacky.com/webservicemin', 29)
|
||||
elif type == ChatterBotType.PANDORABOTS:
|
||||
if arg == None:
|
||||
raise Exception('PANDORABOTS needs a botid arg')
|
||||
return _Pandorabots(arg)
|
||||
else:
|
||||
return
|
||||
|
||||
|
||||
class ChatterBot:
|
||||
|
||||
def create_session(self):
|
||||
return None
|
||||
|
||||
|
||||
class ChatterBotSession:
|
||||
|
||||
def think_thought(self, thought):
|
||||
return thought
|
||||
|
||||
def think(self, text):
|
||||
thought = ChatterBotThought()
|
||||
thought.text = text
|
||||
return self.think_thought(thought).text
|
||||
|
||||
|
||||
class ChatterBotThought:
|
||||
pass
|
||||
|
||||
|
||||
class _Cleverbot(ChatterBot):
|
||||
|
||||
def __init__(self, url, endIndex):
|
||||
self.url = url
|
||||
self.endIndex = endIndex
|
||||
|
||||
def create_session(self):
|
||||
return _CleverbotSession(self)
|
||||
|
||||
|
||||
class _CleverbotSession(ChatterBotSession):
|
||||
|
||||
def __init__(self, bot):
|
||||
self.bot = bot
|
||||
self.vars = {}
|
||||
self.vars['start'] = 'y'
|
||||
self.vars['icognoid'] = 'wsf'
|
||||
self.vars['fno'] = '0'
|
||||
self.vars['sub'] = 'Say'
|
||||
self.vars['islearning'] = '1'
|
||||
self.vars['cleanslate'] = 'false'
|
||||
|
||||
def think_thought(self, thought):
|
||||
self.vars['stimulus'] = thought.text
|
||||
data = urllib.urlencode(self.vars)
|
||||
data_to_digest = data[9:self.bot.endIndex]
|
||||
data_digest = md5.new(data_to_digest).hexdigest()
|
||||
data = data + '&icognocheck=' + data_digest
|
||||
url_response = urllib2.urlopen(self.bot.url, data)
|
||||
response = url_response.read()
|
||||
response_values = response.split('\r')
|
||||
self.vars['sessionid'] = _utils_string_at_index(response_values, 1)
|
||||
self.vars['logurl'] = _utils_string_at_index(response_values, 2)
|
||||
self.vars['vText8'] = _utils_string_at_index(response_values, 3)
|
||||
self.vars['vText7'] = _utils_string_at_index(response_values, 4)
|
||||
self.vars['vText6'] = _utils_string_at_index(response_values, 5)
|
||||
self.vars['vText5'] = _utils_string_at_index(response_values, 6)
|
||||
self.vars['vText4'] = _utils_string_at_index(response_values, 7)
|
||||
self.vars['vText3'] = _utils_string_at_index(response_values, 8)
|
||||
self.vars['vText2'] = _utils_string_at_index(response_values, 9)
|
||||
self.vars['prevref'] = _utils_string_at_index(response_values, 10)
|
||||
self.vars['emotionalhistory'] = _utils_string_at_index(response_values, 12)
|
||||
self.vars['ttsLocMP3'] = _utils_string_at_index(response_values, 13)
|
||||
self.vars['ttsLocTXT'] = _utils_string_at_index(response_values, 14)
|
||||
self.vars['ttsLocTXT3'] = _utils_string_at_index(response_values, 15)
|
||||
self.vars['ttsText'] = _utils_string_at_index(response_values, 16)
|
||||
self.vars['lineRef'] = _utils_string_at_index(response_values, 17)
|
||||
self.vars['lineURL'] = _utils_string_at_index(response_values, 18)
|
||||
self.vars['linePOST'] = _utils_string_at_index(response_values, 19)
|
||||
self.vars['lineChoices'] = _utils_string_at_index(response_values, 20)
|
||||
self.vars['lineChoicesAbbrev'] = _utils_string_at_index(response_values, 21)
|
||||
self.vars['typingData'] = _utils_string_at_index(response_values, 22)
|
||||
self.vars['divert'] = _utils_string_at_index(response_values, 23)
|
||||
response_thought = ChatterBotThought()
|
||||
response_thought.text = _utils_string_at_index(response_values, 16)
|
||||
return response_thought
|
||||
|
||||
|
||||
class _Pandorabots(ChatterBot):
|
||||
|
||||
def __init__(self, botid):
|
||||
self.botid = botid
|
||||
|
||||
def create_session(self):
|
||||
return _PandorabotsSession(self)
|
||||
|
||||
|
||||
class _PandorabotsSession(ChatterBotSession):
|
||||
|
||||
def __init__(self, bot):
|
||||
self.vars = {}
|
||||
self.vars['botid'] = bot.botid
|
||||
self.vars['custid'] = uuid.uuid1()
|
||||
|
||||
def think_thought(self, thought):
|
||||
self.vars['input'] = thought.text
|
||||
data = urllib.urlencode(self.vars)
|
||||
url_response = urllib2.urlopen('http://www.pandorabots.com/pandora/talk-xml', data)
|
||||
response = url_response.read()
|
||||
response_dom = xml.dom.minidom.parseString(response)
|
||||
response_thought = ChatterBotThought()
|
||||
response_thought.text = response_dom.getElementsByTagName('that')[0].childNodes[0].data.strip()
|
||||
return response_thought
|
||||
|
||||
|
||||
def _utils_string_at_index(strings, index):
|
||||
if len(strings) > index:
|
||||
return strings[index]
|
||||
else:
|
||||
return ''
|
|
@ -1,26 +0,0 @@
|
|||
import random
|
||||
|
||||
|
||||
class QuestionMgr:
|
||||
|
||||
def __init__(self):
|
||||
self.greetings = ['hi', 'hello', 'hey', 'sup', 'howdy', 'yo']
|
||||
self.greetingResp = ['Hello there, ', 'Howdy there, ', 'Hows it hanging, ', 'How do you do, ', 'Whats up, ', 'Woah! You scared me there ']
|
||||
self.response = ''
|
||||
self.confused = 1
|
||||
|
||||
def ask(self, message, sender):
|
||||
msg = message.lower()
|
||||
vbls = msg.split()
|
||||
for i in xrange(0, len(vbls)):
|
||||
if vbls[i] in self.greetings:
|
||||
index = random.randint(0, len(self.greetingResp) -1)
|
||||
helloResp = self.greetingResp[index]
|
||||
respFinal = helloResp + '%s' % sender + '!'
|
||||
self.response += helloResp
|
||||
self.confused = 0
|
||||
else:
|
||||
if self.confused:
|
||||
self.response += 'Dang, I really don\'t understand you.'
|
||||
self.confused = 1
|
||||
return self.response
|
|
@ -5591,7 +5591,6 @@ CatalogExitButtonText = 'Hang Up'
|
|||
CatalogPastButtonText = 'To Past Items'
|
||||
TutorialHQOfficerName = 'HQ Harry'
|
||||
NPCToonNames = {20000: 'Tutorial Tom',
|
||||
998: 'Talkative Tyler',
|
||||
999: 'Toon Tailor',
|
||||
1000: lToonHQ,
|
||||
20001: Flippy,
|
||||
|
|
Loading…
Reference in a new issue