aboutsummaryrefslogtreecommitdiff
path: root/engines/titanic
diff options
context:
space:
mode:
Diffstat (limited to 'engines/titanic')
-rw-r--r--engines/titanic/true_talk/barbot_script.cpp8
-rw-r--r--engines/titanic/true_talk/barbot_script.h6
-rw-r--r--engines/titanic/true_talk/tt_npc_script.cpp36
-rw-r--r--engines/titanic/true_talk/tt_npc_script.h19
-rw-r--r--engines/titanic/true_talk/tt_sentence.cpp5
-rw-r--r--engines/titanic/true_talk/tt_sentence.h2
6 files changed, 64 insertions, 12 deletions
diff --git a/engines/titanic/true_talk/barbot_script.cpp b/engines/titanic/true_talk/barbot_script.cpp
index f768885088..ba3ca03282 100644
--- a/engines/titanic/true_talk/barbot_script.cpp
+++ b/engines/titanic/true_talk/barbot_script.cpp
@@ -114,8 +114,12 @@ int BarbotScript::chooseResponse(TTroomScript *roomScript, TTsentence *sentence,
return TTnpcScript::chooseResponse(roomScript, sentence, tag);
}
-void BarbotScript::proc7(int v1, int v2) {
- warning("TODO");
+int BarbotScript::process(TTroomScript *roomScript, TTsentence *sentence) {
+ if (roomScript->_scriptId != 112)
+ return 2;
+
+ // TODO
+ return 2;
}
int BarbotScript::proc10() const {
diff --git a/engines/titanic/true_talk/barbot_script.h b/engines/titanic/true_talk/barbot_script.h
index c5f7800de4..4be978cda6 100644
--- a/engines/titanic/true_talk/barbot_script.h
+++ b/engines/titanic/true_talk/barbot_script.h
@@ -49,7 +49,11 @@ public:
*/
virtual int chooseResponse(TTroomScript *roomScript, TTsentence *sentence, uint tag);
- virtual void proc7(int v1, int v2);
+ /**
+ * Does NPC specific processing of the parsed sentence
+ */
+ virtual int process(TTroomScript *roomScript, TTsentence *sentence);
+
virtual int proc10() const;
virtual int proc15() const;
virtual bool proc16() const;
diff --git a/engines/titanic/true_talk/tt_npc_script.cpp b/engines/titanic/true_talk/tt_npc_script.cpp
index e06184a0a0..1f9bb83be1 100644
--- a/engines/titanic/true_talk/tt_npc_script.cpp
+++ b/engines/titanic/true_talk/tt_npc_script.cpp
@@ -23,12 +23,21 @@
#include "common/textconsole.h"
#include "titanic/pet_control/pet_control.h"
#include "titanic/true_talk/tt_npc_script.h"
+#include "titanic/true_talk/tt_sentence.h"
#include "titanic/true_talk/true_talk_manager.h"
#include "titanic/game_manager.h"
#include "titanic/titanic.h"
namespace Titanic {
+static const char *const ITEMS[] = {
+ "chicken", "napkin", "parrot", "moth", "fuse", "eye", "nose", "ear", "mouth",
+ "auditorycenter", "visioncenter", "olfactorycenter", "speechcenter", "stick",
+ "longstick", "bomb", "lemon", "puree", "television", "hammer", nullptr
+};
+
+/*------------------------------------------------------------------------*/
+
int TTnpcScriptResponse::size() const {
for (int idx = 0; idx < 4; ++idx) {
if (_values[idx] == 0)
@@ -127,7 +136,7 @@ TTnpcScript::TTnpcScript(int charId, const char *charClass, int v2,
const char *charName, int v3, int val2, int v4, int v5, int v6, int v7) :
TTnpcScriptBase(charId, charClass, v2, charName, v3, val2, v4, v5, v6, v7),
_entryCount(0), _field68(0), _field6C(0), _rangeResetCtr(0),
- _field74(0), _field78(0), _field7C(0), _field80(0), _field2CC(false) {
+ _field74(0), _field78(0), _field7C(0), _itemStringP(nullptr), _field2CC(false) {
CTrueTalkManager::_v2 = 0;
Common::fill(&_dialValues[0], &_dialValues[DIALS_ARRAY_COUNT], 0);
Common::fill(&_array[0], &_array[136], 0);
@@ -218,8 +227,8 @@ int TTnpcScript::chooseResponse(TTroomScript *roomScript, TTsentence *sentence,
return 1;
}
-void TTnpcScript::process(TTroomScript *roomScript, TTsentence *sentence) {
- processSentence(&_entries, _entryCount, roomScript, sentence);
+int TTnpcScript::process(TTroomScript *roomScript, TTsentence *sentence) {
+ return processEntries(&_entries, _entryCount, roomScript, sentence);
}
int TTnpcScript::proc8() const {
@@ -618,7 +627,7 @@ CPetControl *TTnpcScript::getPetControl(CGameManager *gameManager) {
return nullptr;
}
-int TTnpcScript::processSentence(const TTsentenceEntries *entries, uint entryCount, TTroomScript *roomScript, TTsentence *sentence) {
+int TTnpcScript::processEntries(const TTsentenceEntries *entries, uint entryCount, TTroomScript *roomScript, TTsentence *sentence) {
if (!entries)
return SS_1;
if (!entryCount)
@@ -723,4 +732,23 @@ TTscriptRange *TTnpcScript::findRange(uint id) {
return nullptr;
}
+void TTnpcScript::checkItems(TTroomScript *roomScript, TTsentence *sentence) {
+ _field2CC = 0;
+ ++CTrueTalkManager::_v2;
+
+ if (sentence) {
+ if (!_itemStringP || getRandomNumber(100) > 80) {
+ for (const char *const *strP = &ITEMS[0]; *strP; ++strP) {
+ if (sentence->localWord(*strP)) {
+ _itemStringP = *strP;
+ break;
+ }
+ }
+ }
+
+ if (sentence->localWord("bomb"))
+ _field7C = 1;
+ }
+}
+
} // End of namespace Titanic
diff --git a/engines/titanic/true_talk/tt_npc_script.h b/engines/titanic/true_talk/tt_npc_script.h
index 3a4ac570b7..f31a769665 100644
--- a/engines/titanic/true_talk/tt_npc_script.h
+++ b/engines/titanic/true_talk/tt_npc_script.h
@@ -125,7 +125,11 @@ public:
*/
virtual int chooseResponse(TTroomScript *roomScript, TTsentence *sentence, uint tag) = 0;
- virtual void proc7(int v1, int v2) = 0;
+ /**
+ * Does NPC specific processing of the parsed sentence
+ */
+ virtual int process(TTroomScript *roomScript, TTsentence *sentence) = 0;
+
virtual int proc8() const = 0;
virtual int proc9() const = 0;
@@ -156,7 +160,7 @@ protected:
int _field74;
int _field78;
int _field7C;
- int _field80;
+ const char *_itemStringP;
int _dialValues[DIALS_ARRAY_COUNT];
int _array[136];
bool _field2CC;
@@ -220,9 +224,14 @@ protected:
*/
TTscriptRange *findRange(uint id);
- int processSentence(const TTsentenceEntries *entries, uint entryCount, TTroomScript *roomScript, TTsentence *sentence);
+ /**
+ * Scans through a list of sentence entries for a matching standardized response
+ */
+ int processEntries(const TTsentenceEntries *entries, uint entryCount, TTroomScript *roomScript, TTsentence *sentence);
bool defaultProcess(TTroomScript *roomScript, TTsentence *sentence);
+
+ void checkItems(TTroomScript *roomScript, TTsentence *sentence);
public:
TTnpcScript(int charId, const char *charClass, int v2,
const char *charName, int v3, int val2, int v4,
@@ -238,9 +247,9 @@ public:
virtual int chooseResponse(TTroomScript *roomScript, TTsentence *sentence, uint tag);
/**
- * Does further NPC specific processing of the sentence
+ * Does NPC specific processing of the parsed sentence
*/
- virtual void process(TTroomScript *roomScript, TTsentence *sentence);
+ virtual int process(TTroomScript *roomScript, TTsentence *sentence);
virtual int proc8() const;
virtual int proc9() const;
diff --git a/engines/titanic/true_talk/tt_sentence.cpp b/engines/titanic/true_talk/tt_sentence.cpp
index b11912d5e1..54c66446f3 100644
--- a/engines/titanic/true_talk/tt_sentence.cpp
+++ b/engines/titanic/true_talk/tt_sentence.cpp
@@ -261,4 +261,9 @@ bool TTsentence::isConcept34(int slotIndex, TTconceptNode *node) {
return concept && concept->get34();
}
+bool TTsentence::localWord(const char *str) const {
+ // TODO
+ return false;
+}
+
} // End of namespace Titanic
diff --git a/engines/titanic/true_talk/tt_sentence.h b/engines/titanic/true_talk/tt_sentence.h
index f26dd35ce7..c9e8de9a7a 100644
--- a/engines/titanic/true_talk/tt_sentence.h
+++ b/engines/titanic/true_talk/tt_sentence.h
@@ -117,6 +117,8 @@ public:
bool fn4(int mode, int wordId, TTconceptNode *node);
bool isConcept34(int slotIndex, TTconceptNode *node = nullptr);
+
+ bool localWord(const char *str) const;
};
} // End of namespace Titanic