aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/titanic/true_talk/barbot_script.cpp4
-rw-r--r--engines/titanic/true_talk/barbot_script.h2
-rw-r--r--engines/titanic/true_talk/bellbot_script.cpp21
-rw-r--r--engines/titanic/true_talk/bellbot_script.h7
-rw-r--r--engines/titanic/true_talk/deskbot_script.cpp18
-rw-r--r--engines/titanic/true_talk/deskbot_script.h5
-rw-r--r--engines/titanic/true_talk/doorbot_script.cpp38
-rw-r--r--engines/titanic/true_talk/doorbot_script.h5
-rw-r--r--engines/titanic/true_talk/tt_npc_script.cpp59
-rw-r--r--engines/titanic/true_talk/tt_npc_script.h23
10 files changed, 141 insertions, 41 deletions
diff --git a/engines/titanic/true_talk/barbot_script.cpp b/engines/titanic/true_talk/barbot_script.cpp
index fbda55425c..cc987f00b9 100644
--- a/engines/titanic/true_talk/barbot_script.cpp
+++ b/engines/titanic/true_talk/barbot_script.cpp
@@ -1158,10 +1158,6 @@ void BarbotScript::setDialRegion(int dialNum, int region) {
applyResponse();
}
-int BarbotScript::proc36(int tagId) const {
- return 0;
-}
-
void BarbotScript::adjustDial(int dialNum, int amount) {
int level = CLIP(getDialLevel(dialNum) + amount, 0, 100);
setDial(dialNum, level);
diff --git a/engines/titanic/true_talk/barbot_script.h b/engines/titanic/true_talk/barbot_script.h
index 77c7cce857..cf53e66b3d 100644
--- a/engines/titanic/true_talk/barbot_script.h
+++ b/engines/titanic/true_talk/barbot_script.h
@@ -99,8 +99,6 @@ public:
* Sets a given dial to be pointing in a specified region (0 to 2)
*/
virtual void setDialRegion(int dialNum, int region);
-
- virtual int proc36(int val) const;
};
} // End of namespace Titanic
diff --git a/engines/titanic/true_talk/bellbot_script.cpp b/engines/titanic/true_talk/bellbot_script.cpp
index 3149439b1f..7472111014 100644
--- a/engines/titanic/true_talk/bellbot_script.cpp
+++ b/engines/titanic/true_talk/bellbot_script.cpp
@@ -72,11 +72,6 @@ ScriptChangedResult BellbotScript::scriptChanged(TTscriptBase *roomScript, uint
return SCR_1;
}
-int BellbotScript::proc15() const {
- warning("TODO");
- return 0;
-}
-
int BellbotScript::handleQuote(TTroomScript *roomScript, TTsentence *sentence,
uint val, uint tagId, uint remainder) {
switch (tagId) {
@@ -402,9 +397,19 @@ int BellbotScript::doSentenceEntry(int val1, const int *srcIdP, TTroomScript *ro
return 0;
}
-int BellbotScript::proc36(int id) const {
- warning("TODO");
- return 0;
+bool BellbotScript::randomResponse(int index) {
+ if (getRandomNumber(100) > 10 || getRandomNumber(10) <= index)
+ return 0;
+
+ if (getRandomNumber(100) > 95) {
+ deleteResponses();
+ addResponse(getDialogueId(201695));
+ applyResponse();
+ } else {
+ setResponseFromArray(index, 201696);
+ }
+
+ return true;
}
int BellbotScript::addLocation() {
diff --git a/engines/titanic/true_talk/bellbot_script.h b/engines/titanic/true_talk/bellbot_script.h
index 8b43e32005..a006bb6d08 100644
--- a/engines/titanic/true_talk/bellbot_script.h
+++ b/engines/titanic/true_talk/bellbot_script.h
@@ -71,8 +71,6 @@ public:
*/
virtual ScriptChangedResult scriptChanged(TTscriptBase *roomScript, uint id);
- virtual int proc15() const;
-
virtual int handleQuote(TTroomScript *roomScript, TTsentence *sentence,
uint val, uint tagId, uint remainder);
@@ -91,7 +89,10 @@ public:
*/
virtual int doSentenceEntry(int val1, const int *srcIdP, TTroomScript *roomScript, TTsentence *sentence);
- virtual int proc36(int val) const;
+ /**
+ * Handles a randomzied response
+ */
+ virtual bool randomResponse(int index);
};
} // End of namespace Titanic
diff --git a/engines/titanic/true_talk/deskbot_script.cpp b/engines/titanic/true_talk/deskbot_script.cpp
index debd6ea7ba..c06e138332 100644
--- a/engines/titanic/true_talk/deskbot_script.cpp
+++ b/engines/titanic/true_talk/deskbot_script.cpp
@@ -38,7 +38,7 @@ DeskbotScript::DeskbotScript(int val1, const char *charClass, int v2,
CTrueTalkManager::setFlags(22, 0);
setupDials(0, 0, 0);
- _array[0] = 100;
+ _data[0] = 100;
if (_currentDialNum == 1)
_currentDialNum = 0;
@@ -314,9 +314,19 @@ int DeskbotScript::doSentenceEntry(int val1, const int *srcIdP, TTroomScript *ro
return 0;
}
-int DeskbotScript::proc36(int id) const {
- warning("TODO");
- return 0;
+bool DeskbotScript::randomResponse(int index) {
+ if (getValue(1) == 1 || getRandomNumber(100) > 10 || getRandomNumber(2) <= index)
+ return 0;
+
+ if (getRandomNumber(100) > 95) {
+ deleteResponses();
+ addResponse(getDialogueId(241195));
+ applyResponse();
+ } else {
+ setResponseFromArray(index, 241193);
+ }
+
+ return true;
}
bool DeskbotScript::isDial0Medium() const {
diff --git a/engines/titanic/true_talk/deskbot_script.h b/engines/titanic/true_talk/deskbot_script.h
index 7a09c28d76..02a1126481 100644
--- a/engines/titanic/true_talk/deskbot_script.h
+++ b/engines/titanic/true_talk/deskbot_script.h
@@ -99,7 +99,10 @@ public:
*/
virtual int doSentenceEntry(int val1, const int *srcIdP, TTroomScript *roomScript, TTsentence *sentence);
- virtual int proc36(int val) const;
+ /**
+ * Handles a randomzied response
+ */
+ virtual bool randomResponse(int index);
/**
* Returns true if dial 1 is the medium (1) region
diff --git a/engines/titanic/true_talk/doorbot_script.cpp b/engines/titanic/true_talk/doorbot_script.cpp
index 8b837341b3..fa1078fe31 100644
--- a/engines/titanic/true_talk/doorbot_script.cpp
+++ b/engines/titanic/true_talk/doorbot_script.cpp
@@ -525,9 +525,41 @@ void DoorbotScript::setDialRegion(int dialNum, int region) {
}
}
-int DoorbotScript::proc36(int id) const {
- warning("TODO");
- return 0;
+bool DoorbotScript::randomResponse(int index) {
+ static const int DIALOGUE_IDS[] = {
+ 220133, 220074, 220000, 220008, 220009, 220010, 220011,
+ 220012, 220013, 220014, 220015, 220016, 221053, 221054,
+ 221055, 221056, 221057, 221058, 221059, 221060, 221061,
+ 221173, 221174, 221175, 221176, 221177, 222415, 222416,
+ 221157, 221165, 221166, 221167, 221168, 221169, 221170,
+ 221171, 221172, 221158, 221159, 221356, 221364, 221365,
+ 221366, 221367, 221368, 221369, 221370, 221371, 221357,
+ 221358, 221359, 221360, 221252, 221019, 221355, 220952,
+ 220996, 220916, 220924, 220926, 220931, 220948, 220956,
+ 220965, 220967, 220968, 220980, 220981, 220982, 220983,
+ 220984, 220988, 220903, 221095, 222202, 222239, 221758,
+ 221759, 221762, 221763, 221766, 221767, 221768, 0
+ };
+
+ int *dataP = _data.getSlot(index);
+ bool flag = false;
+ for (const int *idP = DIALOGUE_IDS; *idP && !flag; ++idP) {
+ flag = *idP == *dataP;
+ }
+
+ if (flag || (getDialRegion(1) != 1 && getRandomNumber(100) > 33)
+ || getRandomNumber(8) <= index)
+ return false;
+
+ if (getRandomNumber(100) > 40) {
+ deleteResponses();
+ addResponse(getDialogueId(221242));
+ applyResponse();
+ } else {
+ setResponseFromArray(index, 221245);
+ }
+
+ return true;
}
int DoorbotScript::setResponse(int dialogueId, int v34) {
diff --git a/engines/titanic/true_talk/doorbot_script.h b/engines/titanic/true_talk/doorbot_script.h
index 4c3c9eddd2..c84af8c9f0 100644
--- a/engines/titanic/true_talk/doorbot_script.h
+++ b/engines/titanic/true_talk/doorbot_script.h
@@ -98,7 +98,10 @@ public:
*/
virtual void setDialRegion(int dialNum, int region);
- virtual int proc36(int val) const;
+ /**
+ * Handles a randomzied response
+ */
+ virtual bool randomResponse(int index);
};
} // End of namespace Titanic
diff --git a/engines/titanic/true_talk/tt_npc_script.cpp b/engines/titanic/true_talk/tt_npc_script.cpp
index 3e9af6583e..dd32114563 100644
--- a/engines/titanic/true_talk/tt_npc_script.cpp
+++ b/engines/titanic/true_talk/tt_npc_script.cpp
@@ -105,6 +105,16 @@ static const uint RANDOM9[] = {
/*------------------------------------------------------------------------*/
+TTnpcData::TTnpcData() {
+ Common::fill(&_array[0], &_array[136], 0);
+}
+
+void TTnpcData::resetFlags() {
+ Common::fill(&_array[20], &_array[136], 0);
+}
+
+/*------------------------------------------------------------------------*/
+
TTnpcScriptBase::TTnpcScriptBase(int charId, const char *charClass, int v2,
const char *charName, int v3, int val2, int v4, int v5, int v6, int v7) :
TTscriptBase(0, charClass, v2, charName, v3, v4, v5, v6, v7),
@@ -130,7 +140,6 @@ TTnpcScript::TTnpcScript(int charId, const char *charClass, int v2,
_currentDialNum(0), _dialDelta(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);
if (!CTrueTalkManager::_v10) {
Common::fill(&CTrueTalkManager::_v11[0], &CTrueTalkManager::_v11[41], 0);
@@ -178,7 +187,7 @@ void TTnpcScript::loadRanges(const char *name) {
}
void TTnpcScript::resetFlags() {
- Common::fill(&_array[20], &_array[136], 0);
+ _data.resetFlags();
_field2CC = false;
}
@@ -402,7 +411,7 @@ void TTnpcScript::save(SimpleFile *file) {
file->writeNumber(10);
for (int idx = 0; idx < 10; ++idx)
- file->writeNumber(_array[idx]);
+ file->writeNumber(_data[idx]);
}
void TTnpcScript::load(SimpleFile *file) {
@@ -421,7 +430,7 @@ void TTnpcScript::load(SimpleFile *file) {
for (int idx = 0; idx < count; ++idx) {
int v = file->readNumber();
if (idx < 10)
- _array[idx] = v;
+ _data[idx] = v;
}
}
@@ -533,8 +542,8 @@ int TTnpcScript::getDialLevel(uint dialNum, bool randomizeFlag) {
return result;
}
-int TTnpcScript::proc36(int id) const {
- return 0;
+bool TTnpcScript::randomResponse(int index) {
+ return false;
}
uint TTnpcScript::translateId(uint id) const {
@@ -624,7 +633,7 @@ uint TTnpcScript::getDialogueId(uint tagId) {
_field2CC = true;
int val = translateByArray(tagId);
if (val > 0) {
- if (proc36(val))
+ if (randomResponse(val))
return 4;
}
}
@@ -651,28 +660,32 @@ uint TTnpcScript::getDialogueId(uint tagId) {
}
uint newVal = tableP->_values[oldTagId];
+ // First slot dialogue Ids
idx = 0;
- int *arrP = &_array[26];
+ int *arrP = _data.getSlot(0);
while (idx < 4 && arrP[idx])
++idx;
+
if (idx == 4)
return newVal;
-
- _array[26] = origId;
+ arrP[idx] = origId;
+
+ // Second slot dialogue Ids
idx = 0;
- arrP = &_array[30];
+ arrP = _data.getSlot(1);
while (idx < 4 && arrP[idx])
++idx;
+
if (idx == 4)
return newVal;
-
arrP[idx] = newVal;
+
return newVal;
}
int TTnpcScript::translateByArray(int id) {
for (uint idx = 1, arrIndex = 35; idx < 15; ++idx, arrIndex += 8) {
- if (_array[idx - 1] == id && _array[idx] == 0)
+ if (_data[idx - 1] == id && _data[idx] == 0)
return idx;
}
@@ -977,4 +990,24 @@ void TTnpcScript::getAssignedRoom(int *roomNum, int *floorNum, int *elevatorNum)
*elevatorNum = CLIP(*elevatorNum, 1, 4);
}
+void TTnpcScript::setResponseFromArray(int index, int id) {
+ if (index >= 0 && index <= 15) {
+ deleteResponses();
+ if (id)
+ addResponse(getDialogueId(id));
+
+ // Add any loaded responses
+ int *vals = _data.getSlot(index + 1);
+ for (int idx = 0; idx < 4; ++idx) {
+ if (vals[idx])
+ addResponse(vals[idx]);
+ }
+ applyResponse();
+
+ // Clear out the values used
+ if (index)
+ Common::fill(vals, vals + 4, 0);
+ }
+}
+
} // 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 e758cff737..4f83f271ff 100644
--- a/engines/titanic/true_talk/tt_npc_script.h
+++ b/engines/titanic/true_talk/tt_npc_script.h
@@ -35,6 +35,16 @@ class CGameManager;
class CPetControl;
class TTroomScript;
+struct TTnpcData {
+private:
+ int _array[136];
+public:
+ TTnpcData();
+ int &operator[](int idx) { return _array[idx]; }
+ int *getSlot(int idx) { return &_array[16 + idx * 4]; }
+ void resetFlags();
+};
+
class TTnpcScriptBase : public TTscriptBase {
protected:
int _field54;
@@ -93,7 +103,7 @@ protected:
int _field7C;
const char *_itemStringP;
int _dialValues[DIALS_ARRAY_COUNT];
- int _array[136];
+ TTnpcData _data;
bool _field2CC;
protected:
/**
@@ -194,6 +204,11 @@ protected:
* Gets the assigned room's room, floor, and elevator number
*/
void getAssignedRoom(int *roomNum, int *floorNum, int *elevatorNum) const;
+
+ /**
+ * Uses a porition of the state _array to set up a new response
+ */
+ void setResponseFromArray(int index, int id);
public:
static void init();
static void deinit();
@@ -308,7 +323,11 @@ public:
*/
virtual int getDialLevel(uint dialNum, bool randomizeFlag = true);
- virtual int proc36(int val) const;
+ /**
+ * Handles a randomzied response
+ */
+ virtual bool randomResponse(int index);
+
virtual uint translateId(uint id) const;
void preLoad();