diff options
author | Paul Gilbert | 2016-06-02 19:14:59 -0400 |
---|---|---|
committer | Paul Gilbert | 2016-07-15 19:19:02 -0400 |
commit | 6075a8fe4900bb32216099b2f9fd34334dbc281b (patch) | |
tree | 141d8e34cf381f25a4969864724f62b7394bf6a1 /engines/titanic/true_talk | |
parent | 95dc0bc4ccf51de23ab30133d6d1f339936ad413 (diff) | |
download | scummvm-rg350-6075a8fe4900bb32216099b2f9fd34334dbc281b.tar.gz scummvm-rg350-6075a8fe4900bb32216099b2f9fd34334dbc281b.tar.bz2 scummvm-rg350-6075a8fe4900bb32216099b2f9fd34334dbc281b.zip |
TITANIC: Implement TTnpcScript selectResponse
Diffstat (limited to 'engines/titanic/true_talk')
-rw-r--r-- | engines/titanic/true_talk/barbot_script.cpp | 6 | ||||
-rw-r--r-- | engines/titanic/true_talk/liftbot_script.cpp | 2 | ||||
-rw-r--r-- | engines/titanic/true_talk/tt_npc_script.cpp | 23 | ||||
-rw-r--r-- | engines/titanic/true_talk/tt_npc_script.h | 11 |
4 files changed, 29 insertions, 13 deletions
diff --git a/engines/titanic/true_talk/barbot_script.cpp b/engines/titanic/true_talk/barbot_script.cpp index 16bc2447b6..ddb06b156f 100644 --- a/engines/titanic/true_talk/barbot_script.cpp +++ b/engines/titanic/true_talk/barbot_script.cpp @@ -42,7 +42,7 @@ int BarbotScript::chooseResponse(TTroomScript *roomScript, TTsentence *sentence, if (_state < 7) { addResponse(STATE_ARRAY[_state++]); } else { - proc14(51896); + selectResponse(51896); set34(1); _state = 0; } @@ -61,7 +61,7 @@ int BarbotScript::chooseResponse(TTroomScript *roomScript, TTsentence *sentence, } } else if (tag == MKTAG('B', 'A', 'R', 'K') && getRandomNumber(100) > 50) { - proc14(250025); + selectResponse(250025); switch (proc23()) { case 4: case 6: @@ -75,7 +75,7 @@ int BarbotScript::chooseResponse(TTroomScript *roomScript, TTsentence *sentence, return 2; } else if (tag == MKTAG('B', 'A', 'R', 'U') && getRandomNumber(100) > 50) { - proc14(250025); + selectResponse(250025); switch (proc23()) { case 4: case 6: diff --git a/engines/titanic/true_talk/liftbot_script.cpp b/engines/titanic/true_talk/liftbot_script.cpp index dd6203dc62..5ffd6fb8ea 100644 --- a/engines/titanic/true_talk/liftbot_script.cpp +++ b/engines/titanic/true_talk/liftbot_script.cpp @@ -42,7 +42,7 @@ int LiftbotScript::chooseResponse(TTroomScript *roomScript, TTsentence *sentence case MKTAG('H', 'H', 'G', 'Q'): case MKTAG('A', 'N', 'S', 'W'): if (_state >= 7) { - proc14(30918); + selectResponse(30918); set34(2); _state = 0; } else { diff --git a/engines/titanic/true_talk/tt_npc_script.cpp b/engines/titanic/true_talk/tt_npc_script.cpp index 8369d6623a..1f1fceb156 100644 --- a/engines/titanic/true_talk/tt_npc_script.cpp +++ b/engines/titanic/true_talk/tt_npc_script.cpp @@ -66,13 +66,14 @@ TTnpcScript::TTnpcScript(int charId, const char *charClass, int v2, resetFlags(); } -void TTnpcScript::load(const char *name, int valuesPerTag) { +void TTnpcScript::load(const char *name, int valuesPerResponse) { + _valuesPerResponse = valuesPerResponse; Common::SeekableReadStream *r = g_vm->_filesManager->getResource(name); while (r->pos() < r->size()) { TTnpcScriptResponse sr; sr._tag = r->readUint32LE(); - for (int idx = 0; idx < valuesPerTag; ++idx) + for (int idx = 0; idx < valuesPerResponse; ++idx) sr._values[idx] = r->readUint32LE(); _responses.push_back(sr); @@ -99,9 +100,14 @@ int TTnpcScript::chooseResponse(TTroomScript *roomScript, TTsentence *sentence, const TTnpcScriptResponse &response = _responses[idx]; if (response._tag == tag) { - int valIndex = getRandomNumber(response.size()) - 1; - uint diagId = getDialogueId(response._values[valIndex]); - addResponse(diagId); + if (_valuesPerResponse == 1) { + selectResponse(response._values[0]); + } else { + int valIndex = getRandomNumber(response.size()) - 1; + uint diagId = getDialogueId(response._values[valIndex]); + addResponse(diagId); + } + applyResponse(); return 2; } @@ -135,8 +141,11 @@ bool TTnpcScript::proc13() const { return true; } -void TTnpcScript::proc14(int v) { - warning("TODO"); +void TTnpcScript::selectResponse(int id) { + if (id >= 200000 && id <= 290264) + id = getDialogueId(id); + + addResponse(id); } int TTnpcScript::proc15() const { diff --git a/engines/titanic/true_talk/tt_npc_script.h b/engines/titanic/true_talk/tt_npc_script.h index 906489ec3b..239cccea4e 100644 --- a/engines/titanic/true_talk/tt_npc_script.h +++ b/engines/titanic/true_talk/tt_npc_script.h @@ -81,6 +81,7 @@ private: int translateByArray(int id); protected: Common::Array<TTnpcScriptResponse> _responses; + int _valuesPerResponse; byte *_subPtr; int _field60; int _field64; @@ -98,7 +99,7 @@ protected: /** * Loads response data for the NPC from the given resource */ - void load(const char *name, int valuesPerTag = 1); + void load(const char *name, int valuesPerResponse = 1); /** * Reset script flags @@ -163,7 +164,13 @@ public: virtual int proc11() const; virtual int proc12() const; virtual bool proc13() const; - virtual void proc14(int v); + + /** + * Translate a passed Id to a dialogue Id if necessary, + * and adds it to the response + */ + virtual void selectResponse(int id); + virtual int proc15() const; virtual bool proc16() const; virtual bool proc17() const; |