aboutsummaryrefslogtreecommitdiff
path: root/engines/titanic/true_talk
diff options
context:
space:
mode:
authorPaul Gilbert2016-05-31 21:47:12 -0400
committerPaul Gilbert2016-07-15 19:18:31 -0400
commitba5e13d479f3c8615e8c0984c58e86421499f1b3 (patch)
tree17c5ed855aeb143ddc43b109b48737ba778ee033 /engines/titanic/true_talk
parentf51a428f8b32323a4328d69dff7c5afd48630224 (diff)
downloadscummvm-rg350-ba5e13d479f3c8615e8c0984c58e86421499f1b3.tar.gz
scummvm-rg350-ba5e13d479f3c8615e8c0984c58e86421499f1b3.tar.bz2
scummvm-rg350-ba5e13d479f3c8615e8c0984c58e86421499f1b3.zip
TITANIC: Set up loading of deskbot & bellbot script response lists
Diffstat (limited to 'engines/titanic/true_talk')
-rw-r--r--engines/titanic/true_talk/barbot_script.cpp4
-rw-r--r--engines/titanic/true_talk/barbot_script.h6
-rw-r--r--engines/titanic/true_talk/bellbot_script.cpp5
-rw-r--r--engines/titanic/true_talk/bellbot_script.h1
-rw-r--r--engines/titanic/true_talk/deskbot_script.cpp17
-rw-r--r--engines/titanic/true_talk/deskbot_script.h3
-rw-r--r--engines/titanic/true_talk/doorbot_script.cpp4
-rw-r--r--engines/titanic/true_talk/doorbot_script.h6
-rw-r--r--engines/titanic/true_talk/liftbot_script.cpp4
-rw-r--r--engines/titanic/true_talk/liftbot_script.h6
-rw-r--r--engines/titanic/true_talk/maitred_script.cpp4
-rw-r--r--engines/titanic/true_talk/maitred_script.h6
-rw-r--r--engines/titanic/true_talk/parrot_script.cpp4
-rw-r--r--engines/titanic/true_talk/parrot_script.h6
-rw-r--r--engines/titanic/true_talk/script_handler.cpp2
-rw-r--r--engines/titanic/true_talk/succubus_script.cpp4
-rw-r--r--engines/titanic/true_talk/succubus_script.h6
-rw-r--r--engines/titanic/true_talk/tt_npc_script.cpp33
-rw-r--r--engines/titanic/true_talk/tt_npc_script.h27
19 files changed, 101 insertions, 47 deletions
diff --git a/engines/titanic/true_talk/barbot_script.cpp b/engines/titanic/true_talk/barbot_script.cpp
index 2bb3a1876f..2c82949990 100644
--- a/engines/titanic/true_talk/barbot_script.cpp
+++ b/engines/titanic/true_talk/barbot_script.cpp
@@ -25,9 +25,9 @@
namespace Titanic {
-int BarbotScript::proc6(TTnpcScript *npcScript, TTsentence *sentence, uint tag) {
+int BarbotScript::chooseResponse(TTroomScript *roomScript, TTsentence *sentence, uint tag) {
warning("TODO");
- return 2;
+ return SS_2;
}
void BarbotScript::proc7(int v1, int v2) {
diff --git a/engines/titanic/true_talk/barbot_script.h b/engines/titanic/true_talk/barbot_script.h
index a55c12bc71..45681874df 100644
--- a/engines/titanic/true_talk/barbot_script.h
+++ b/engines/titanic/true_talk/barbot_script.h
@@ -33,7 +33,11 @@ public:
const char *charName, int v3, int val2, int v4, int v5, int v6, int v7) :
TTnpcScript(val1, charClass, v2, charName, v3, val2, v4, v5, v6, v7) {}
- virtual int proc6(TTnpcScript *npcScript, TTsentence *sentence, uint tag);
+ /**
+ * Chooses and adds a conversation response based on a specified tag Id.
+ */
+ virtual int chooseResponse(TTroomScript *roomScript, TTsentence *sentence, uint tag);
+
virtual void proc7(int v1, int v2);
virtual int proc10() const;
virtual int proc15() const;
diff --git a/engines/titanic/true_talk/bellbot_script.cpp b/engines/titanic/true_talk/bellbot_script.cpp
index 794e67130f..0e11aeaddf 100644
--- a/engines/titanic/true_talk/bellbot_script.cpp
+++ b/engines/titanic/true_talk/bellbot_script.cpp
@@ -38,11 +38,8 @@ BellbotScript::BellbotScript(int val1, const char *charClass, int v2,
randomizeFlags();
_array[0] = 100;
_array[1] = 0;
-}
-int BellbotScript::proc6(TTnpcScript *npcScript, TTsentence *sentence, uint tag) {
- warning("TODO");
- return 2;
+ load("Responses/Bellbot");
}
void BellbotScript::proc7(int v1, int v2) {
diff --git a/engines/titanic/true_talk/bellbot_script.h b/engines/titanic/true_talk/bellbot_script.h
index d7fbab3a8f..86e9165d01 100644
--- a/engines/titanic/true_talk/bellbot_script.h
+++ b/engines/titanic/true_talk/bellbot_script.h
@@ -38,7 +38,6 @@ public:
BellbotScript(int val1, const char *charClass, int v2,
const char *charName, int v3, int val2);
- virtual int proc6(TTnpcScript *npcScript, TTsentence *sentence, uint tag);
virtual void proc7(int v1, int v2);
virtual int proc10() const;
virtual int proc15() const;
diff --git a/engines/titanic/true_talk/deskbot_script.cpp b/engines/titanic/true_talk/deskbot_script.cpp
index dbe2664e99..319175f40a 100644
--- a/engines/titanic/true_talk/deskbot_script.cpp
+++ b/engines/titanic/true_talk/deskbot_script.cpp
@@ -39,23 +39,8 @@ DeskbotScript::DeskbotScript(int val1, const char *charClass, int v2,
_array[0] = 100;
if (_field74 == 1)
_field74 = 0;
-}
-
-int DeskbotScript::proc6(TTnpcScript *npcScript, TTsentence *sentence, uint tag) {
- for (uint idx = 0; idx < _tags.size(); ++idx) {
- const TTnpcScriptTag &scriptTag = _tags[idx];
- uint currTag = (idx == 0) ? MKTAG('P', 'K', 'U', 'P') : scriptTag._tag;
-
- if (currTag == tag) {
- int valIndex = getRandomNumber(scriptTag.size()) - 1;
- uint diagId = getDialogueId(scriptTag._values[valIndex]);
- addResponse(diagId);
- applyResponse();
- break;
- }
- }
- return SS_1;
+ load("Responses/Deskbot");
}
void DeskbotScript::proc7(int v1, int v2) {
diff --git a/engines/titanic/true_talk/deskbot_script.h b/engines/titanic/true_talk/deskbot_script.h
index f2de881777..3dda552571 100644
--- a/engines/titanic/true_talk/deskbot_script.h
+++ b/engines/titanic/true_talk/deskbot_script.h
@@ -29,13 +29,10 @@
namespace Titanic {
class DeskbotScript : public TTnpcScript {
-private:
- Common::Array<TTnpcScriptTag> _tags;
public:
DeskbotScript(int val1, const char *charClass, int v2,
const char *charName, int v3, int val2);
- virtual int proc6(TTnpcScript *npcScript, TTsentence *sentence, uint tag);
virtual void proc7(int v1, int v2);
virtual int proc10() const;
virtual int proc15() const;
diff --git a/engines/titanic/true_talk/doorbot_script.cpp b/engines/titanic/true_talk/doorbot_script.cpp
index 9d35f697f9..d1638eeff3 100644
--- a/engines/titanic/true_talk/doorbot_script.cpp
+++ b/engines/titanic/true_talk/doorbot_script.cpp
@@ -25,9 +25,9 @@
namespace Titanic {
-int DoorbotScript::proc6(TTnpcScript *npcScript, TTsentence *sentence, uint tag) {
+int DoorbotScript::chooseResponse(TTroomScript *roomScript, TTsentence *sentence, uint tag) {
warning("TODO");
- return 2;
+ return SS_2;
}
void DoorbotScript::proc7(int v1, int v2) {
diff --git a/engines/titanic/true_talk/doorbot_script.h b/engines/titanic/true_talk/doorbot_script.h
index 82897b7bfc..3158ef07d2 100644
--- a/engines/titanic/true_talk/doorbot_script.h
+++ b/engines/titanic/true_talk/doorbot_script.h
@@ -35,7 +35,11 @@ public:
const char *charName, int v3, int val2, int v4, int v5, int v6, int v7) :
TTnpcScript(val1, charClass, v2, charName, v3, val2, v4, v5, v6, v7) {}
- virtual int proc6(TTnpcScript *npcScript, TTsentence *sentence, uint tag);
+ /**
+ * Chooses and adds a conversation response based on a specified tag Id.
+ */
+ virtual int chooseResponse(TTroomScript *roomScript, TTsentence *sentence, uint tag);
+
virtual void proc7(int v1, int v2);
virtual int proc10() const;
virtual int proc15() const;
diff --git a/engines/titanic/true_talk/liftbot_script.cpp b/engines/titanic/true_talk/liftbot_script.cpp
index b1577b3979..b627df658f 100644
--- a/engines/titanic/true_talk/liftbot_script.cpp
+++ b/engines/titanic/true_talk/liftbot_script.cpp
@@ -25,9 +25,9 @@
namespace Titanic {
-int LiftbotScript::proc6(TTnpcScript *npcScript, TTsentence *sentence, uint tag) {
+int LiftbotScript::chooseResponse(TTroomScript *roomScript, TTsentence *sentence, uint tag) {
warning("TODO");
- return 2;
+ return SS_2;
}
void LiftbotScript::proc7(int v1, int v2) {
diff --git a/engines/titanic/true_talk/liftbot_script.h b/engines/titanic/true_talk/liftbot_script.h
index 8c2ae3210c..9e7d72f012 100644
--- a/engines/titanic/true_talk/liftbot_script.h
+++ b/engines/titanic/true_talk/liftbot_script.h
@@ -33,7 +33,11 @@ public:
const char *charName, int v3, int val2, int v4, int v5, int v6, int v7) :
TTnpcScript(val1, charClass, v2, charName, v3, val2, v4, v5, v6, v7) {}
- virtual int proc6(TTnpcScript *npcScript, TTsentence *sentence, uint tag);
+ /**
+ * Chooses and adds a conversation response based on a specified tag Id.
+ */
+ virtual int chooseResponse(TTroomScript *roomScript, TTsentence *sentence, uint tag);
+
virtual void proc7(int v1, int v2);
virtual int proc9() const;
virtual int proc10() const;
diff --git a/engines/titanic/true_talk/maitred_script.cpp b/engines/titanic/true_talk/maitred_script.cpp
index 5581c6b605..717dbca779 100644
--- a/engines/titanic/true_talk/maitred_script.cpp
+++ b/engines/titanic/true_talk/maitred_script.cpp
@@ -39,9 +39,9 @@ MaitreDScript::MaitreDScript(int val1, const char *charClass, int v2,
CTrueTalkManager::setFlags(16, 0);
}
-int MaitreDScript::proc6(TTnpcScript *npcScript, TTsentence *sentence, uint tag) {
+int MaitreDScript::chooseResponse(TTroomScript *roomScript, TTsentence *sentence, uint tag) {
warning("TODO");
- return 2;
+ return SS_2;
}
void MaitreDScript::proc7(int v1, int v2) {
diff --git a/engines/titanic/true_talk/maitred_script.h b/engines/titanic/true_talk/maitred_script.h
index 14505ca616..d638dee52b 100644
--- a/engines/titanic/true_talk/maitred_script.h
+++ b/engines/titanic/true_talk/maitred_script.h
@@ -32,7 +32,11 @@ public:
MaitreDScript(int val1, const char *charClass, int v2,
const char *charName, int v3, int val2);
- virtual int proc6(TTnpcScript *npcScript, TTsentence *sentence, uint tag);
+ /**
+ * Chooses and adds a conversation response based on a specified tag Id.
+ */
+ virtual int chooseResponse(TTroomScript *roomScript, TTsentence *sentence, uint tag);
+
virtual void proc7(int v1, int v2);
virtual int proc10() const;
virtual bool proc16() const;
diff --git a/engines/titanic/true_talk/parrot_script.cpp b/engines/titanic/true_talk/parrot_script.cpp
index a6b37bfc57..6e90bbc0b1 100644
--- a/engines/titanic/true_talk/parrot_script.cpp
+++ b/engines/titanic/true_talk/parrot_script.cpp
@@ -25,9 +25,9 @@
namespace Titanic {
-int ParrotScript::proc6(TTnpcScript *npcScript, TTsentence *sentence, uint tag) {
+int ParrotScript::chooseResponse(TTroomScript *roomScript, TTsentence *sentence, uint tag) {
warning("TODO");
- return 2;
+ return SS_2;
}
void ParrotScript::proc7(int v1, int v2) {
diff --git a/engines/titanic/true_talk/parrot_script.h b/engines/titanic/true_talk/parrot_script.h
index 0add5d9dfe..abf8042c37 100644
--- a/engines/titanic/true_talk/parrot_script.h
+++ b/engines/titanic/true_talk/parrot_script.h
@@ -33,7 +33,11 @@ public:
const char *charName, int v3, int val2, int v4, int v5, int v6, int v7) :
TTnpcScript(val1, charClass, v2, charName, v3, val2, v4, v5, v6, v7) {}
- virtual int proc6(TTnpcScript *npcScript, TTsentence *sentence, uint tag);
+ /**
+ * Chooses and adds a conversation response based on a specified tag Id.
+ */
+ virtual int chooseResponse(TTroomScript *roomScript, TTsentence *sentence, uint tag);
+
virtual void proc7(int v1, int v2);
virtual int proc10() const;
virtual bool proc17() const;
diff --git a/engines/titanic/true_talk/script_handler.cpp b/engines/titanic/true_talk/script_handler.cpp
index b689aba031..f5db6eb5de 100644
--- a/engines/titanic/true_talk/script_handler.cpp
+++ b/engines/titanic/true_talk/script_handler.cpp
@@ -89,7 +89,7 @@ int CScriptHandler::processInput(TTroomScript *roomScript, TTnpcScript *npcScrip
if (result) {
sentence->set34(result);
if (roomScript->proc6(npcScript, sentence, result)) {
- canProcess = npcScript->proc6(roomScript, sentence, result);
+ canProcess = npcScript->chooseResponse(roomScript, sentence, result);
}
}
diff --git a/engines/titanic/true_talk/succubus_script.cpp b/engines/titanic/true_talk/succubus_script.cpp
index 436b779432..60e3abbd65 100644
--- a/engines/titanic/true_talk/succubus_script.cpp
+++ b/engines/titanic/true_talk/succubus_script.cpp
@@ -25,9 +25,9 @@
namespace Titanic {
-int SuccUBusScript::proc6(TTnpcScript *npcScript, TTsentence *sentence, uint tag) {
+int SuccUBusScript::chooseResponse(TTroomScript *roomScript, TTsentence *sentence, uint tag) {
warning("TODO");
- return 2;
+ return SS_2;
}
void SuccUBusScript::proc7(int v1, int v2) {
diff --git a/engines/titanic/true_talk/succubus_script.h b/engines/titanic/true_talk/succubus_script.h
index 8a078c2639..43249999a5 100644
--- a/engines/titanic/true_talk/succubus_script.h
+++ b/engines/titanic/true_talk/succubus_script.h
@@ -36,7 +36,11 @@ public:
TTnpcScript(val1, charClass, v2, charName, v3, val2, v4, v5, v6, v7),
_field2D0(0) {}
- virtual int proc6(TTnpcScript *npcScript, TTsentence *sentence, uint tag);
+ /**
+ * Chooses and adds a conversation response based on a specified tag Id.
+ */
+ virtual int chooseResponse(TTroomScript *roomScript, TTsentence *sentence, uint tag);
+
virtual void proc7(int v1, int v2);
virtual int proc10() const;
virtual bool proc17() const;
diff --git a/engines/titanic/true_talk/tt_npc_script.cpp b/engines/titanic/true_talk/tt_npc_script.cpp
index bbd75a4854..59212cba55 100644
--- a/engines/titanic/true_talk/tt_npc_script.cpp
+++ b/engines/titanic/true_talk/tt_npc_script.cpp
@@ -27,7 +27,7 @@
namespace Titanic {
-int TTnpcScriptTag::size() const {
+int TTnpcScriptResponse::size() const {
for (int idx = 0; idx < 4; ++idx) {
if (_values[idx] == 0)
return idx;
@@ -63,6 +63,21 @@ TTnpcScript::TTnpcScript(int charId, const char *charClass, int v2,
resetFlags();
}
+void TTnpcScript::load(const char *name) {
+ Common::SeekableReadStream *r = g_vm->_filesManager->getResource(name);
+
+ while (r->pos() < r->size()) {
+ TTnpcScriptResponse sr;
+ sr._tag = r->readUint32LE();
+ for (int idx = 0; idx < 4; ++idx)
+ sr._values[idx] = r->readUint32LE();
+
+ _responses.push_back(sr);
+ }
+
+ delete r;
+}
+
void TTnpcScript::resetFlags() {
Common::fill(&_array[20], &_array[140], 0);
_field2CC = false;
@@ -76,6 +91,22 @@ void TTnpcScript::proc4(int v) {
warning("TODO");
}
+int TTnpcScript::chooseResponse(TTroomScript *roomScript, TTsentence *sentence, uint tag) {
+ for (uint idx = 0; idx < _responses.size(); ++idx) {
+ const TTnpcScriptResponse &response = _responses[idx];
+
+ if (response._tag == tag) {
+ int valIndex = getRandomNumber(response.size()) - 1;
+ uint diagId = getDialogueId(response._values[valIndex]);
+ addResponse(diagId);
+ applyResponse();
+ return 2;
+ }
+ }
+
+ return 1;
+}
+
void TTnpcScript::proc7(int v1, int v2) {
warning("TODO");
}
diff --git a/engines/titanic/true_talk/tt_npc_script.h b/engines/titanic/true_talk/tt_npc_script.h
index d52da2ed73..407b3648da 100644
--- a/engines/titanic/true_talk/tt_npc_script.h
+++ b/engines/titanic/true_talk/tt_npc_script.h
@@ -31,7 +31,7 @@ namespace Titanic {
class TTroomScript;
class TTsentence;
-struct TTnpcScriptTag {
+struct TTnpcScriptResponse {
uint _tag;
uint _values[4];
@@ -52,7 +52,11 @@ public:
const char *charName, int v3, int val2, int v4,
int v5, int v6, int v7);
- virtual int proc6(TTroomScript *roomScript, TTsentence *sentence, int val) const = 0;
+ /**
+ * Chooses and adds a conversation response based on a specified tag Id.
+ */
+ virtual int chooseResponse(TTroomScript *roomScript, TTsentence *sentence, uint tag) = 0;
+
virtual void proc7(int v1, int v2) = 0;
virtual int proc8() const = 0;
virtual int proc9() const = 0;
@@ -70,6 +74,8 @@ public:
class TTnpcScript : public TTnpcScriptBase {
private:
+ Common::Array<TTnpcScriptResponse> _responses;
+private:
int translateByArray(int id);
protected:
byte *_subPtr;
@@ -85,6 +91,14 @@ protected:
int _array[146];
bool _field2CC;
protected:
+ /**
+ * Loads response data for the NPC from the given resource
+ */
+ void load(const char *name);
+
+ /**
+ * Reset script flags
+ */
void resetFlags();
void randomizeFlags();
@@ -111,7 +125,14 @@ public:
int v5, int v6, int v7);
virtual void proc4(int v);
- virtual int proc6(TTroomScript *roomScript, TTsentence *sentence, int val) const { return 1; }
+
+ /**
+ * Chooses and adds a conversation response based on a specified tag Id.
+ * This default implementation does a lookup into a list of known tags,
+ * and chooses a random dialogue Id from the available ones for that tag
+ */
+ virtual int chooseResponse(TTroomScript *roomScript, TTsentence *sentence, uint tag);
+
virtual void proc7(int v1, int v2);
virtual int proc8() const;
virtual int proc9() const;