aboutsummaryrefslogtreecommitdiff
path: root/engines/titanic
diff options
context:
space:
mode:
authorPaul Gilbert2016-07-24 19:44:19 -0400
committerPaul Gilbert2016-07-24 19:44:19 -0400
commit6e2a4edd2a9cbb5c44be1a930e27d607e744361d (patch)
tree2a33003572b75b9ac2579b50536daa72449b2cd6 /engines/titanic
parent773bfca60551c519a3bf1989724bafe77390a728 (diff)
downloadscummvm-rg350-6e2a4edd2a9cbb5c44be1a930e27d607e744361d.tar.gz
scummvm-rg350-6e2a4edd2a9cbb5c44be1a930e27d607e744361d.tar.bz2
scummvm-rg350-6e2a4edd2a9cbb5c44be1a930e27d607e744361d.zip
TITANIC: Finish TTbarbotScript process method
Diffstat (limited to 'engines/titanic')
-rw-r--r--engines/titanic/titanic.cpp3
-rw-r--r--engines/titanic/true_talk/barbot_script.cpp137
-rw-r--r--engines/titanic/true_talk/barbot_script.h1
-rw-r--r--engines/titanic/true_talk/deskbot_script.cpp4
-rw-r--r--engines/titanic/true_talk/tt_npc_script.cpp53
-rw-r--r--engines/titanic/true_talk/tt_npc_script.h14
6 files changed, 196 insertions, 16 deletions
diff --git a/engines/titanic/titanic.cpp b/engines/titanic/titanic.cpp
index dfb68fd9d5..66d4e46546 100644
--- a/engines/titanic/titanic.cpp
+++ b/engines/titanic/titanic.cpp
@@ -41,6 +41,7 @@
#include "titanic/moves/enter_exit_sec_class_mini_lift.h"
#include "titanic/moves/exit_pellerator.h"
#include "titanic/support/simple_file.h"
+#include "titanic/true_talk/tt_npc_script.h"
namespace Titanic {
@@ -93,6 +94,7 @@ void TitanicEngine::initialize() {
CExitPellerator::init();
CEnterExitSecClassMiniLift::init();
CTelevision::init();
+ TTnpcScript::init();
OSVideoSurface::setup();
_debugger = new Debugger(this);
@@ -119,6 +121,7 @@ void TitanicEngine::deinitialize() {
CEnterExitSecClassMiniLift::deinit();
CGameObject::deinit();
CTelevision::deinit();
+ TTnpcScript::deinit();
}
Common::Error TitanicEngine::run() {
diff --git a/engines/titanic/true_talk/barbot_script.cpp b/engines/titanic/true_talk/barbot_script.cpp
index 89dfe0ae51..03aa1cdaae 100644
--- a/engines/titanic/true_talk/barbot_script.cpp
+++ b/engines/titanic/true_talk/barbot_script.cpp
@@ -57,11 +57,12 @@ void BarbotScript::setupSentences() {
CTrueTalkManager::setFlags(idx, 0);
setupDials(100, 100, 100);
- if (!_field74)
- _field74 = 2;
+ if (!_currentDialNum)
+ _currentDialNum = 2;
_mappings.load("Mappings/Barbot", 8);
_entries.load("Sentences/Barbot");
+ _entries2.load("Sentences/Barbot2");
}
int BarbotScript::chooseResponse(TTroomScript *roomScript, TTsentence *sentence, uint tag) {
@@ -619,10 +620,138 @@ done:
adjustDial(0, 2 + getRandomNumber(7));
}
- // TODO: Remainder of method
+ updateCurrentDial(true);
+ if (sentence->contains("goldfish")) {
+ addResponse(250184);
+ } else if ((sentence->localWord("puree") || sentence->localWord("pureed"))
+ && sentence->localWord("parrot")) {
+ addResponse(250021);
+ } else if (sentence->localWord("starling")) {
+ addResponse(250024);
+ } else {
+ if (getRandomNumber(100) > 95 && getDialRegion(2) == 0) {
+ addResponse(getDialogueId(250210));
+ }
+
+ if (processEntries(&_entries, _entryCount, roomScript, sentence) == 2)
+ return 2;
+ if (processEntries(_defaultEntries, 0, roomScript, sentence) != 2
+ && !defaultProcess(roomScript, sentence)) {
+ int dval = 0;
+ flag = getRandomNumber(100) > 50;
+ int val;
+
+ switch (_field2C) {
+ case 2:
+ val = getValue(29);
+ if (val < 16)
+ val += 4;
+ if (val < 9) {
+ val = val / 2;
+ dval = 250081 + flag ? 0 : 267;
+ }
+ CTrueTalkManager::setFlags(29, val);
+ break;
+
+ case 3:
+ val = getValue(30);
+ if (val < 16)
+ val += 4;
+ if (val < 9) {
+ val = val / 2;
+ dval = 250081 + flag ? 0 : 243;
+ }
+ CTrueTalkManager::setFlags(30, val);
+ break;
+
+ case 4:
+ val = getValue(31);
+ if (val < 16)
+ val += 4;
+ if (val < 9) {
+ val = val / 2;
+ dval = 250081 + flag ? 0 : 256;
+ }
+ CTrueTalkManager::setFlags(31, val);
+ break;
+
+ case 5:
+ val = getValue(32);
+ if (val < 16)
+ val += 4;
+ if (val < 9) {
+ val = val / 2;
+ dval = 250081 + flag ? 0 : 251;
+ }
+ CTrueTalkManager::setFlags(32, val);
+ break;
+
+ case 6:
+ val = getValue(33);
+ if (val < 16)
+ val += 4;
+ if (val < 9) {
+ val = val / 2;
+ dval = 250081 + flag ? 0 : 273;
+ }
+ CTrueTalkManager::setFlags(33, val);
+ break;
+
+ case 7:
+ val = getValue(34);
+ if (val < 16)
+ val += 4;
+ if (val < 9) {
+ val = val / 2;
+ dval = 250081 + flag ? 0 : 236;
+ }
+ CTrueTalkManager::setFlags(34, val);
+ break;
+
+
+ case 11:
+ addResponse(getDialogueId(250463));
+ applyResponse();
+ return 2;
+
+ case 12:
+ addResponse(getDialogueId(250455));
+ applyResponse();
+ return 2;
+
+ case 13:
+ addResponse(getDialogueId(250447));
+ applyResponse();
+ return 2;
+
+ case 19:
+ return applySentenceIds(getDialogueId(getDialRegion(0) ? 250062 : 250200));
- // TODO
+ default:
+ break;
+ }
+
+ if (dval) {
+ adjustDial(0, -9);
+ adjustDial(1, -2);
+
+ if (dval != 250081) {
+ selectResponse(250286);
+ selectResponse(250296);
+ selectResponse(250307);
+ applyResponse();
+ return 2;
+ }
+ } else if (processEntries(&_entries2, 0, roomScript, sentence) == 2) {
+ return 2;
+ }
+
+ addResponse(getDialogueId(250082 + getRandomNumber(100) <= 89 ? 128 : 0));
+ }
+ }
+
+ applyResponse();
return 2;
}
diff --git a/engines/titanic/true_talk/barbot_script.h b/engines/titanic/true_talk/barbot_script.h
index 3d2a5133ac..94491491c0 100644
--- a/engines/titanic/true_talk/barbot_script.h
+++ b/engines/titanic/true_talk/barbot_script.h
@@ -31,6 +31,7 @@ class BarbotScript : public TTnpcScript {
private:
int _state;
int _arrIndex;
+ TTsentenceEntries _entries2;
private:
/**
* Adjust a given dial number by a given delta amount
diff --git a/engines/titanic/true_talk/deskbot_script.cpp b/engines/titanic/true_talk/deskbot_script.cpp
index ca000a4c28..61e1f717c9 100644
--- a/engines/titanic/true_talk/deskbot_script.cpp
+++ b/engines/titanic/true_talk/deskbot_script.cpp
@@ -37,8 +37,8 @@ DeskbotScript::DeskbotScript(int val1, const char *charClass, int v2,
setupDials(0, 0, 0);
_array[0] = 100;
- if (_field74 == 1)
- _field74 = 0;
+ if (_currentDialNum == 1)
+ _currentDialNum = 0;
loadRanges("Ranges/Deskbot");
loadResponses("Responses/Deskbot", 4);
diff --git a/engines/titanic/true_talk/tt_npc_script.cpp b/engines/titanic/true_talk/tt_npc_script.cpp
index 647523bc32..f673cc0313 100644
--- a/engines/titanic/true_talk/tt_npc_script.cpp
+++ b/engines/titanic/true_talk/tt_npc_script.cpp
@@ -31,6 +31,8 @@
namespace Titanic {
+TTsentenceEntries *TTnpcScript::_defaultEntries;
+
static const char *const ITEMS[] = {
"chicken", "napkin", "parrot", "moth", "fuse", "eye", "nose", "ear", "mouth",
"auditorycenter", "visioncenter", "olfactorycenter", "speechcenter", "stick",
@@ -211,11 +213,21 @@ TTnpcScriptBase::TTnpcScriptBase(int charId, const char *charClass, int v2,
/*------------------------------------------------------------------------*/
+void TTnpcScript::init() {
+ _defaultEntries = new TTsentenceEntries();
+ _defaultEntries->load("Sentences/Default");
+}
+
+void TTnpcScript::deinit() {
+ delete _defaultEntries;
+ _defaultEntries = nullptr;
+}
+
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), _itemStringP(nullptr), _field2CC(false) {
+ _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);
@@ -274,11 +286,11 @@ void TTnpcScript::setupDials(int dial1, int dial2, int dial3) {
_dialValues[0] = dial1;
_dialValues[1] = dial2;
_dialValues[2] = dial3;
- _field74 = getRandomNumber(3) - 1;
- _field78 = getRandomNumber(5) + 6;
+ _currentDialNum = getRandomNumber(3) - 1;
+ _dialDelta = getRandomNumber(5) + 6;
if (_dialValues[0] > 70)
- _field78 = -_field78;
+ _dialDelta = -_dialDelta;
}
void TTnpcScript::addResponse(int id) {
@@ -425,8 +437,8 @@ void TTnpcScript::save(SimpleFile *file) {
file->writeNumber(4);
file->writeNumber(_rangeResetCtr);
- file->writeNumber(_field74);
- file->writeNumber(_field78);
+ file->writeNumber(_currentDialNum);
+ file->writeNumber(_dialDelta);
file->writeNumber(_field7C);
file->writeNumber(10);
@@ -439,8 +451,8 @@ void TTnpcScript::load(SimpleFile *file) {
int count = file->readNumber();
_rangeResetCtr = file->readNumber();
- _field74 = file->readNumber();
- _field78 = file->readNumber();
+ _currentDialNum = file->readNumber();
+ _dialDelta = file->readNumber();
_field7C = file->readNumber();
for (int idx = count; idx > 4; --idx)
@@ -890,6 +902,31 @@ bool TTnpcScript::addRandomResponse(bool flag) {
addResponse(id);
applyResponse();
+ return true;
+}
+
+void TTnpcScript::updateCurrentDial(bool changeDial) {
+ int dialLevel = CLIP(getDialLevel(_currentDialNum) + _dialDelta, 0, 100);
+ setDial(_currentDialNum, dialLevel);
+
+ bool edgeFlag = false;
+ if (_dialDelta < 0) {
+ if (dialLevel < 10 || getRandomNumber(100) > 93)
+ edgeFlag = true;
+ } else {
+ if (dialLevel > 90 || getRandomNumber(100) > 93)
+ edgeFlag = true;
+ }
+
+ if (edgeFlag) {
+ if (changeDial)
+ _currentDialNum = getRandomNumber(3);
+
+ _dialDelta = getRandomNumber(12) + 3;
+ dialLevel = getDialLevel(_currentDialNum, false);
+ if (dialLevel > 50)
+ _dialDelta = -_dialDelta;
+ }
}
} // 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 43764d89c4..8a17064034 100644
--- a/engines/titanic/true_talk/tt_npc_script.h
+++ b/engines/titanic/true_talk/tt_npc_script.h
@@ -159,6 +159,8 @@ class TTnpcScript : public TTnpcScriptBase {
private:
int translateByArray(int id);
protected:
+ static TTsentenceEntries *_defaultEntries;
+protected:
Common::Array<TTnpcScriptResponse> _responses;
int _valuesPerResponse;
Common::Array<TTscriptRange> _ranges;
@@ -169,8 +171,8 @@ protected:
int _field68;
int _field6C;
int _rangeResetCtr;
- int _field74;
- int _field78;
+ int _currentDialNum;
+ int _dialDelta;
int _field7C;
const char *_itemStringP;
int _dialValues[DIALS_ARRAY_COUNT];
@@ -256,6 +258,14 @@ protected:
* Adds a random conversation response
*/
bool addRandomResponse(bool flag);
+
+ /**
+ * Updates the current dial with the given delta
+ */
+ void updateCurrentDial(bool changeDial);
+public:
+ static void init();
+ static void deinit();
public:
TTnpcScript(int charId, const char *charClass, int v2,
const char *charName, int v3, int val2, int v4,