aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/titanic/true_talk/barbot_script.cpp449
-rw-r--r--engines/titanic/true_talk/barbot_script.h2
-rw-r--r--engines/titanic/true_talk/tt_npc_script.cpp117
-rw-r--r--engines/titanic/true_talk/tt_npc_script.h5
-rw-r--r--engines/titanic/true_talk/tt_script_base.h1
5 files changed, 574 insertions, 0 deletions
diff --git a/engines/titanic/true_talk/barbot_script.cpp b/engines/titanic/true_talk/barbot_script.cpp
index cfde44df9f..89dfe0ae51 100644
--- a/engines/titanic/true_talk/barbot_script.cpp
+++ b/engines/titanic/true_talk/barbot_script.cpp
@@ -192,6 +192,434 @@ int BarbotScript::process(TTroomScript *roomScript, TTsentence *sentence) {
return 2;
}
+ CTrueTalkManager::setFlags(29, getValue(29) - 1);
+ CTrueTalkManager::setFlags(30, getValue(30) - 1);
+ CTrueTalkManager::setFlags(31, getValue(31) - 1);
+ CTrueTalkManager::setFlags(32, getValue(32) - 1);
+ CTrueTalkManager::setFlags(33, getValue(33) - 1);
+ CTrueTalkManager::setFlags(34, getValue(34) - 1);
+
+ int val34 = get34();
+ set34(0);
+
+ int val2C = sentence->_field2C;
+ bool flag = val2C == 11 || val2C == 13;
+ bool flag2 = val2C == 12;
+
+ if (!val34) {
+ goto done;
+ } else if (val34 > 50357) {
+ goto done;
+ } else if (val34 == 50357) {
+ return applySentenceIds(50358, -1);
+ }
+
+ switch (val34) {
+ case 1:
+ if (flag)
+ return applySentenceIds(51898, 2);
+ if (flag2)
+ return applySentenceIds(51897);
+ break;
+ case 2:
+ if (flag)
+ return applySentenceIds(51897);
+ break;
+ case 3:
+ if (sentence->localWord("useless") || sentence->contains("useless"))
+ return applySentenceIds(50824);
+ break;
+ case 4:
+ if (flag)
+ return applySentenceIds(getRandomBit() ? 50512 : 51642);
+ else if (flag2)
+ return applySentenceIds(getRandomBit() ? 50511 : 51643);
+ break;
+ case 5:
+ if (flag)
+ return applySentenceIds(50829, 6);
+ if (flag2)
+ return applySentenceIds(50828);
+ break;
+ case 6:
+ if (flag)
+ return applySentenceIds(50831);
+ if (flag2)
+ return applySentenceIds(50830);
+ break;
+ case 7:
+ if (flag2 || sentence->contains("never"))
+ return applySentenceIds(51553);
+ if (flag || sentence->contains("nicest"))
+ return applySentenceIds(51554);
+ break;
+ case 8:
+ if (flag)
+ return applySentenceIds(50961);
+ if (flag2)
+ return applySentenceIds(50960);
+ break;
+ case 9:
+ if (flag)
+ return applySentenceIds(getDialogueId(251858));
+ break;
+ case 10:
+ if (flag)
+ return applySentenceIds(getDialogueId(251014));
+ else if (flag2)
+ return applySentenceIds(getDialogueId(251013));
+ break;
+ case 11:
+ if (flag)
+ return applySentenceIds(getDialogueId(251008));
+ else if (flag2)
+ return applySentenceIds(getDialogueId(251007));
+ break;
+ case 12:
+ if (flag)
+ return applySentenceIds(getDialogueId(250656));
+ else if (flag2)
+ return applySentenceIds(getDialogueId(250655));
+ break;
+ case 13:
+ if (flag)
+ return applySentenceIds(getDialogueId(250614));
+ else if (flag2)
+ return applySentenceIds(getDialogueId(250613));
+ break;
+ case 14:
+ if (val2C == 6)
+ return applySentenceIds(getDialogueId(250946));
+ break;
+ case 15:
+ /* TODO
+ if (flag || sentence->contains("or")) {
+ return applySentenceIds(getDialogueId(250526), 16);
+ } else {
+ TTtreeResult treeResult;
+ if (TTquotesTree::search(sentence->_normalizedLine.c_str(),
+ &TTnpcScript_BTREE_3, &treeResult, 0, 0) != -1) {
+ id = getDialogueId(250526);
+ return applySentenceIds(id, 16);
+ }
+ }
+ */
+ break;
+ case 17:
+ if (flag) {
+ return applySentenceIds(50382);
+ } else if (flag2) {
+ return applySentenceIds(51423);
+ }
+ // Deliberate fall-through
+
+ case 16:
+ if (val2C == 7 || val2C == 10)
+ return applySentenceIds(getDialogueId(250525));
+ break;
+ case 18:
+ return applySentenceIds(getDialogueId(250589));
+ case 19:
+ return applySentenceIds(getDialogueId(250565), 20);
+ case 20:
+ if (flag)
+ return applySentenceIds(50307);
+ if (flag2)
+ return applySentenceIds(50306);
+ break;
+ case 21:
+ if (flag)
+ return applySentenceIds(50359);
+ if (flag2)
+ return applySentenceIds(50357);
+ break;
+ case 23:
+ if (val2C == 6 || val2C == 10)
+ return applySentenceIds(getDialogueId(250551));
+ break;
+ case 24:
+ if (sentence->contains("do not know")
+ || sentence->contains("no idea")
+ || sentence->contains("a clue")) {
+ return applySentenceIds(getDialogueId(250553));
+ } else {
+ return applySentenceIds(getDialogueId(250552));
+ }
+ break;
+ case 25:
+ if (flag || val2C == 10)
+ applySentenceIds(getDialogueId(251899), 26);
+ else if (flag2)
+ return applySentenceIds(50215);
+ break;
+ case 26:
+ /* TODO
+ v43 = TTstring_cstr(&sentence->normalizedLine);
+ if (TTquotesTree_Search(v43, &TTnpcScript_BTREE_3, &buffer, 0, 0) == -1)
+ break;
+ */
+ return applySentenceIds(getDialogueId(251899), 26);
+
+ case 27:
+ if (flag)
+ return applySentenceIds(getDialogueId(250766));
+ else if (flag2)
+ return applySentenceIds(getDialogueId(250764));
+ break;
+ case 28:
+ return applySentenceIds(getDialogueId(250765));
+ case 29:
+ return applySentenceIds(getDialogueId(250652));
+ case 30:
+ return applySentenceIds(getDialogueId(250653));
+ case 31:
+ if (flag)
+ return applySentenceIds(getDialogueId(250664));
+ else if (flag2)
+ return applySentenceIds(getDialogueId(250663));
+ break;
+ case 32:
+ if (flag)
+ return applySentenceIds(getDialogueId(250643));
+ else if (flag2)
+ return applySentenceIds(getDialogueId(250642));
+ break;
+ case 33:
+ return applySentenceIds(50763);
+ case 34:
+ if (flag)
+ return applySentenceIds(getDialogueId(251622));
+ else if (flag2)
+ return applySentenceIds(getDialogueId(251624));
+ break;
+ case 35:
+ if (val2C == 6 || val2C == 10)
+ return applySentenceIds(getDialogueId(251623));
+ break;
+ case 36:
+ if (flag)
+ return applySentenceIds(50335);
+ if (flag2)
+ return applySentenceIds(50334);
+ break;
+ case 37:
+ if (flag)
+ return applySentenceIds(50217);
+ if (flag2)
+ return applySentenceIds(50153);
+ break;
+ case 38:
+ return applySentenceIds(getDialogueId(250637));
+ case 39:
+ return applySentenceIds(getDialogueId(250638));
+ case 40:
+ return applySentenceIds(getDialogueId(250639));
+ case 41:
+ return applySentenceIds(getDialogueId(250640));
+ case 42:
+ if (flag)
+ return applySentenceIds(getDialogueId(250676));
+ else if (flag2)
+ return applySentenceIds(getDialogueId(250673));
+ break;
+ case 43:
+ if (flag)
+ return applySentenceIds(50416, -1);
+ if (flag2)
+ return applySentenceIds(50415, -1);
+ break;
+ case 44:
+ if (flag)
+ return applySentenceIds(getDialogueId(250468));
+ else if (flag2)
+ return applySentenceIds(getDialogueId(250413));
+
+ if (val2C == 6 || val2C == 10)
+ return applySentenceIds(getDialogueId(251649));
+ break;
+ case 45:
+ if (sentence->localWord("summer")
+ || sentence->contains("summer")
+ || sentence->localWord("autumn")
+ || sentence->contains("autumn")) {
+ return applySentenceIds(50743);
+ } else if (sentence->localWord("winter") || sentence->contains("winter")) {
+ return applySentenceIds(50696);
+ } else {
+ return applySentenceIds(50225);
+ }
+ break;
+ case 46:
+ if (val2C == 7 || val2C == 10)
+ return applySentenceIds(50698);
+ break;
+ case 47:
+ if (flag || flag2 || val2C == 6)
+ return applySentenceIds(50717);
+ break;
+ case 48:
+ if (flag)
+ return applySentenceIds(50710);
+ if (flag2)
+ return applySentenceIds(50225);
+ break;
+ case 49:
+ if (sentence->localWord("scraliontis") || sentence->contains("scraliontis"))
+ return applySentenceIds(50711);
+ if (sentence->localWord("brobostigon") || sentence->contains("brobostigon"))
+ return applySentenceIds(50712);
+ break;
+ case 50:
+ return applySentenceIds(50713);
+ case 51:
+ if (flag)
+ return applySentenceIds(50715);
+ if (flag2)
+ return applySentenceIds(50714);
+ break;
+ case 52:
+ if (sentence->localWord("note") || sentence->contains("note"))
+ return applySentenceIds(50716);
+ return applySentenceIds(50210);
+ case 53:
+ return applySentenceIds(50210);
+ case 54:
+ if (getDialRegion(0) != 0) {
+ if (val2C == 12)
+ return applySentenceIds(50174);
+ else
+ return applySentenceIds(50300);
+ } else if (val2C == 7 || val2C == 10) {
+ return applySentenceIds(50871);
+ }
+ break;
+ case 55:
+ if (flag)
+ return applySentenceIds(50302);
+ if (flag2)
+ return applySentenceIds(50301);
+ break;
+ case 56:
+ if (flag)
+ return applySentenceIds(50304);
+ if (flag2)
+ return applySentenceIds(50303);
+ break;
+ case 57:
+ if (sentence->localWord("mustard")
+ || sentence->contains("mustard")
+ || sentence->localWord("tomato")
+ || sentence->contains("tomato"))
+ return applySentenceIds(50320);
+ if (sentence->localWord("sauce")
+ || sentence->localWord("puree")
+ || sentence->contains("sauce")
+ || sentence->contains("puree")
+ || sentence->contains("bird")
+ || sentence->contains("starling")) {
+ applySentenceIds(50321);
+ CTrueTalkManager::triggerAction(30, 0);
+ return 2;
+ }
+
+ return applySentenceIds(50320);
+ case 58:
+ if (val2C == 6 || val2C == 10)
+ return applySentenceIds(50880);
+ break;
+ case 59:
+ if (flag) {
+ if (addRandomResponse(true)) {
+ set34(59);
+ return 2;
+ }
+ } else if (flag2) {
+ return applySentenceIds(getDialogueId(251754));
+ }
+ break;
+ case 60:
+ if (flag && addRandomResponse(true)) {
+ set34(59);
+ return 2;
+ } else if (flag2 || val2C == 7 || val2C == 10) {
+ return applySentenceIds(getDialogueId(251712));
+ }
+ break;
+ case 61:
+ if (val2C == 3) {
+ if (sentence->localWord("loop"))
+ return applySentenceIds(getDialogueId(250269));
+ else if (sentence->localWord("do"))
+ return applySentenceIds(getDialogueId(250270));
+ } else if (val2C == 7) {
+ return applySentenceIds(getDialogueId(250270));
+ } else if (flag) {
+ return applySentenceIds(getDialogueId(250270));
+ }
+
+ return applySentenceIds(getDialogueId(250272));
+ case 62:
+ if (flag
+ || (val2C == 3 && sentence->localWord("do"))
+ || val2C == 7
+ || sentence->localWord("help"))
+ return applySentenceIds(getDialogueId(250270));
+
+ return applySentenceIds(getDialogueId(2570272));
+ case 63:
+ if (flag
+ || (val2C == 3 || sentence->localWord("do"))
+ || val2C == 7
+ || sentence->localWord("help"))
+ return applySentenceIds(getDialogueId(250271));
+
+ return applySentenceIds(getDialogueId(250272));
+ case 64:
+ if (flag || val2C == 3 || val2C == 8)
+ return applySentenceIds(getDialogueId(250631));
+ break;
+ case 65:
+ if (sentence->localWord("now") || sentence->localWord("soonh"))
+ return applySentenceIds(getDialogueId(250424));
+ return applySentenceIds(getDialogueId(250506));
+ case 66:
+ if (flag || sentence->localWord("good") || sentence->localWord("well"))
+ return applySentenceIds(getDialogueId(251027));
+ return applySentenceIds(getDialogueId(251021));
+ case 67:
+ if (flag || val2C == 6 || val2C == 10) {
+ setDial(0, getDialLevel(0, false) - 8);
+ return applySentenceIds(getDialogueId(251589));
+ }
+ break;
+ case 68:
+ if (flag || val2C == 6 || val2C == 10) {
+ setDial(0, getDialLevel(0, false) - 12);
+ return applySentenceIds(getDialogueId(251590));
+ }
+ break;
+ case 69:
+ if (flag || val2C == 6 || val2C == 10) {
+ setDial(0, getDialLevel(0, false) - 25);
+ return applySentenceIds(getDialogueId(251591));
+ }
+ break;
+ default:
+ break;
+ }
+
+done:
+ // Adjust primary dial
+ set34(0);
+ if (sentence->get58() != 5) {
+ adjustDial(0, sentence->get58() * 4 - 20);
+ } else if (getDialLevel(0, false) > 65) {
+ adjustDial(0, -2 - getRandomNumber(7));
+ } else if (getDialLevel(0, false) < 35) {
+ adjustDial(0, 2 + getRandomNumber(7));
+ }
+
+ // TODO: Remainder of method
// TODO
@@ -255,4 +683,25 @@ bool BarbotScript::isState9() const {
return CTrueTalkManager::getStateValue(9) != 0;
}
+int BarbotScript::applySentenceIds(int dialogueId, int v34) {
+ addResponse(dialogueId);
+ applyResponse();
+
+ if (v34 != -1) {
+ set34(v34);
+ } else {
+ for (uint idx = 0; idx < _mappings.size(); ++idx) {
+ const TTscriptMapping &m = _mappings[idx];
+ for (int vidx = 0; vidx < _mappings._valuesPerMapping; ++idx) {
+ if (m._values[vidx] == (uint)dialogueId) {
+ proc21(m._id, m._id, vidx);
+ break;
+ }
+ }
+ }
+ }
+
+ return -2;
+}
+
} // End of namespace Titanic
diff --git a/engines/titanic/true_talk/barbot_script.h b/engines/titanic/true_talk/barbot_script.h
index 1d73094660..3d2a5133ac 100644
--- a/engines/titanic/true_talk/barbot_script.h
+++ b/engines/titanic/true_talk/barbot_script.h
@@ -43,6 +43,8 @@ private:
void setupSentences();
bool isState9() const;
+
+ int applySentenceIds(int dialogueId, int v34 = -1);
public:
BarbotScript(int val1, const char *charClass, int v2,
const char *charName, int v3, int val2, int v4, int v5, int v6, int v7);
diff --git a/engines/titanic/true_talk/tt_npc_script.cpp b/engines/titanic/true_talk/tt_npc_script.cpp
index 8cce90ebff..647523bc32 100644
--- a/engines/titanic/true_talk/tt_npc_script.cpp
+++ b/engines/titanic/true_talk/tt_npc_script.cpp
@@ -37,6 +37,69 @@ static const char *const ITEMS[] = {
"longstick", "bomb", "lemon", "puree", "television", "hammer", nullptr
};
+struct ItemRec {
+ const char *const _name;
+ uint _id;
+};
+static const ItemRec ARRAY1[] = {
+ { ITEMS[0], 290138 },
+ { ITEMS[1], 290139 },
+ { ITEMS[2], 290141 },
+ { ITEMS[3], 290142 },
+ { ITEMS[4], 290153 },
+ { ITEMS[5], 290158 },
+ { ITEMS[6], 290159 },
+ { ITEMS[7], 290160 },
+ { ITEMS[8], 290161 },
+ { ITEMS[9], 290162 },
+ { ITEMS[10], 290163 },
+ { ITEMS[11], 290164 },
+ { ITEMS[12], 290165 },
+ { ITEMS[13], 290166 },
+ { ITEMS[14], 290166 },
+ { ITEMS[15], 290178 },
+ { ITEMS[16], 290174 },
+ { ITEMS[17], 290175 },
+ { ITEMS[18], 290176 },
+ { ITEMS[19], 290179 },
+ { nullptr, 0 }
+};
+static const uint ARRAY2[] = {
+ 290167, 290178, 290183, 290144, 290148, 290151, 290154, 290156, 290158, 290159, 290160, 290161,
+ 290162, 290163, 290164, 290165, 290177, 290181, 0
+};
+static const uint RANDOM1[] = {
+ 290184, 290185, 290187, 290188, 290190, 290191, 290193, 290195, 290196, 290197, 290198, 290199,
+ 290202, 290205, 0
+};
+static const uint RANDOM2[] = {
+ 290186, 290187, 290188, 290190, 290191, 290193, 290194, 290195, 290196, 290197, 290198, 290199,
+ 290200, 290201, 290202, 290204, 290205, 0
+};
+static const uint RANDOM3[] = {
+ 290188, 290190, 290192, 290194, 290197, 290200, 290201, 290202, 290204, 290205, 0
+};
+static const uint RANDOM4[] = {
+ 290206, 290207, 290209, 290210, 290211, 290212, 290216, 290217, 290218, 290219, 290222, 290223, 0
+};
+static const uint RANDOM5[] = {
+ 290208, 290209, 290210, 290211, 290212, 290214, 290215, 290216, 290217, 290218, 290219, 290221,
+ 290222, 290223, 0
+};
+static const uint RANDOM6[] = {
+ 290210, 290211, 290213, 290214, 290215, 290220, 290221, 290222, 290223, 0
+};
+static const uint RANDOM7[] = {
+ 290225, 290226, 290228, 290229, 290230, 290232, 290231, 290235, 290236, 290237, 290238, 290241, 0
+};
+static const uint RANDOM8[] = {
+ 290227, 290228, 290229, 290230, 290231, 290232, 290233, 290234, 290235, 290236, 290237, 290238,
+ 290240, 290241, 0
+};
+static const uint RANDOM9[] = {
+ 290228, 290229, 290230, 290232, 290233, 290234, 290239, 290240, 290241, 0
+};
+
/*------------------------------------------------------------------------*/
int TTnpcScriptResponse::size() const {
@@ -775,4 +838,58 @@ void TTnpcScript::checkItems(TTroomScript *roomScript, TTsentence *sentence) {
}
}
+bool TTnpcScript::addRandomResponse(bool flag) {
+ if (getValue(1) > 3)
+ return false;
+
+ const uint *data;
+ if (flag) {
+ if (getValue(1) == 2)
+ data = RANDOM8;
+ else if (getValue(1) == 1)
+ data = RANDOM7;
+ else
+ data = RANDOM9;
+ } else if (getRandomBit()) {
+ if (getValue(1) == 2)
+ data = RANDOM2;
+ else if (getValue(1) == 1)
+ data = RANDOM1;
+ else
+ data = RANDOM3;
+ } else {
+ if (getValue(1) == 2)
+ data = RANDOM5;
+ else if (getValue(1) == 1)
+ data = RANDOM4;
+ else
+ data = RANDOM6;
+ }
+
+ // Pick a random entry
+ uint count = 0;
+ while (data[count])
+ ++count;
+ uint id = data[getRandomNumber(count - 1)];
+
+ if (id == 290188 && getRoom54(101))
+ id = 290189;
+ else if (id == 290202 && getRoom54(123))
+ id = 290203;
+
+ if (!id)
+ return false;
+ id = getDialogueId(id);
+ if (id == 4)
+ return true;
+ if (!id)
+ return false;
+
+ if (flag)
+ addResponse(getDialogueId(290224));
+
+ addResponse(id);
+ applyResponse();
+}
+
} // 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 d7cec8d6d8..43764d89c4 100644
--- a/engines/titanic/true_talk/tt_npc_script.h
+++ b/engines/titanic/true_talk/tt_npc_script.h
@@ -251,6 +251,11 @@ protected:
bool defaultProcess(TTroomScript *roomScript, TTsentence *sentence);
void checkItems(TTroomScript *roomScript, TTsentence *sentence);
+
+ /**
+ * Adds a random conversation response
+ */
+ bool addRandomResponse(bool flag);
public:
TTnpcScript(int charId, const char *charClass, int v2,
const char *charName, int v3, int val2, int v4,
diff --git a/engines/titanic/true_talk/tt_script_base.h b/engines/titanic/true_talk/tt_script_base.h
index e855fefb2c..e94bab3277 100644
--- a/engines/titanic/true_talk/tt_script_base.h
+++ b/engines/titanic/true_talk/tt_script_base.h
@@ -73,6 +73,7 @@ protected:
}
void set34(int val) { _field34 = val; }
+ int get34() const { return _field34; }
public:
int _id;
public: