diff options
Diffstat (limited to 'engines/titanic/true_talk')
-rw-r--r-- | engines/titanic/true_talk/barbot_script.cpp | 11 | ||||
-rw-r--r-- | engines/titanic/true_talk/barbot_script.h | 8 | ||||
-rw-r--r-- | engines/titanic/true_talk/bellbot_script.cpp | 22 | ||||
-rw-r--r-- | engines/titanic/true_talk/bellbot_script.h | 9 | ||||
-rw-r--r-- | engines/titanic/true_talk/deskbot_script.cpp | 22 | ||||
-rw-r--r-- | engines/titanic/true_talk/deskbot_script.h | 16 | ||||
-rw-r--r-- | engines/titanic/true_talk/doorbot_script.cpp | 13 | ||||
-rw-r--r-- | engines/titanic/true_talk/doorbot_script.h | 7 | ||||
-rw-r--r-- | engines/titanic/true_talk/liftbot_script.cpp | 12 | ||||
-rw-r--r-- | engines/titanic/true_talk/liftbot_script.h | 7 | ||||
-rw-r--r-- | engines/titanic/true_talk/maitred_script.cpp | 12 | ||||
-rw-r--r-- | engines/titanic/true_talk/maitred_script.h | 10 | ||||
-rw-r--r-- | engines/titanic/true_talk/script_support.cpp | 18 | ||||
-rw-r--r-- | engines/titanic/true_talk/script_support.h | 17 | ||||
-rw-r--r-- | engines/titanic/true_talk/tt_npc_script.cpp | 4 | ||||
-rw-r--r-- | engines/titanic/true_talk/tt_npc_script.h | 5 |
16 files changed, 135 insertions, 58 deletions
diff --git a/engines/titanic/true_talk/barbot_script.cpp b/engines/titanic/true_talk/barbot_script.cpp index 1c652faf11..81682a2f7e 100644 --- a/engines/titanic/true_talk/barbot_script.cpp +++ b/engines/titanic/true_talk/barbot_script.cpp @@ -52,6 +52,7 @@ BarbotScript::BarbotScript(int val1, const char *charClass, int v2, _tagMappings.load("TagMap/Barbot"); _quotes.load("Quotes/Barbot"); _states.load("States/Barbot"); + _preResponses.load("PreResponses/Barbot"); } void BarbotScript::setupSentences() { @@ -975,7 +976,7 @@ int BarbotScript::updateState(uint oldId, uint newId, int index) { } for (uint idx = 0; idx < _states.size(); ++idx) { - const TTupdateState3 &us = _states[idx]; + const TTupdateState &us = _states[idx]; if (us._newId == newId) { if ((us._dialBits & 1) && !getDialRegion(0)) continue; @@ -998,9 +999,11 @@ int BarbotScript::updateState(uint oldId, uint newId, int index) { return newId; } -int BarbotScript::proc22(int id) const { - warning("TODO"); - return 0; +int BarbotScript::preResponse(uint id) { + if (getDialRegion(0) == 0 && getRandomNumber(100) > 80) + return 251250; + + return _preResponses.find(id); } uint BarbotScript::getDialsBitset() const { diff --git a/engines/titanic/true_talk/barbot_script.h b/engines/titanic/true_talk/barbot_script.h index c8b2962667..8a81099fd4 100644 --- a/engines/titanic/true_talk/barbot_script.h +++ b/engines/titanic/true_talk/barbot_script.h @@ -32,7 +32,8 @@ private: int _state; int _arrIndex; TTsentenceEntries _entries2; - TTupdateState3Array _states; + TTupdateStateArray _states; + TTmapEntryArray _preResponses; private: /** * Adjust a given dial number by a given delta amount @@ -79,7 +80,10 @@ public: */ virtual int updateState(uint oldId, uint newId, int index); - virtual int proc22(int id) const; + /** + * Handles getting a pre-response + */ + virtual int preResponse(uint id); /** * Returns a bitset of the first three dialgs being on or not diff --git a/engines/titanic/true_talk/bellbot_script.cpp b/engines/titanic/true_talk/bellbot_script.cpp index 1a9a607e6b..88f13cc351 100644 --- a/engines/titanic/true_talk/bellbot_script.cpp +++ b/engines/titanic/true_talk/bellbot_script.cpp @@ -51,6 +51,7 @@ BellbotScript::BellbotScript(int val1, const char *charClass, int v2, _words.load("Words/Bellbot"); _quotes.load("Quotes/Bellbot"); _states.load("States/Bellbot"); + _preResponses.load("PreResponses/Bellbot"); } void BellbotScript::setupSentences() { @@ -299,9 +300,22 @@ int BellbotScript::updateState(uint oldId, uint newId, int index) { return newId; } -int BellbotScript::proc22(int id) const { - warning("TODO"); - return 0; +int BellbotScript::preResponse(uint id) { + int newId = _preResponses.find(id); + + if (newId == 202277) { + applyResponse(); + CTrueTalkManager::triggerAction(1, 0); + } + if (newId == 200769) { + applyResponse(); + CTrueTalkManager::triggerAction(18, 0); + } + + if (id == 21790) + CTrueTalkManager::triggerAction(13, 0); + + return newId; } int BellbotScript::proc23() const { @@ -427,7 +441,7 @@ int BellbotScript::getStateDialogueId() const { void BellbotScript::setValue23(uint id) { uint val = 0; for (uint idx = 0; idx < _states.size() && !val; ++idx) { - TTupdateState2 &us = _states[idx]; + TTmapEntry &us = _states[idx]; if (us._src == id) val = us._dest; } diff --git a/engines/titanic/true_talk/bellbot_script.h b/engines/titanic/true_talk/bellbot_script.h index 798eecb99d..60459651cf 100644 --- a/engines/titanic/true_talk/bellbot_script.h +++ b/engines/titanic/true_talk/bellbot_script.h @@ -30,7 +30,8 @@ namespace Titanic { class BellbotScript : public TTnpcScript { private: static uint _oldId; - TTupdateState2Array _states; + TTmapEntryArray _states; + TTmapEntryArray _preResponses; int _array[150]; int _field2D0; int _field2D4; @@ -80,7 +81,11 @@ public: */ virtual int updateState(uint oldId, uint newId, int index); - virtual int proc22(int id) const; + /** + * Handles getting a pre-response + */ + virtual int preResponse(uint id); + virtual int proc23() const; virtual int proc25(int val1, const int *srcIdP, TTroomScript *roomScript, TTsentence *sentence); diff --git a/engines/titanic/true_talk/deskbot_script.cpp b/engines/titanic/true_talk/deskbot_script.cpp index 1e3eaae26a..90fab86111 100644 --- a/engines/titanic/true_talk/deskbot_script.cpp +++ b/engines/titanic/true_talk/deskbot_script.cpp @@ -251,9 +251,15 @@ exit: return newId; } -int DeskbotScript::proc22(int id) const { - warning("TODO"); - return 0; +int DeskbotScript::preResponse(uint id) { + int newId = 0; + if (getValue(1) >= 3 && (id == 41176 || id == 41738 || id == 41413 || id == 41740)) + newId = 241601; + + if (id == 42114) + CTrueTalkManager::triggerAction(20, 0); + + return newId; } int DeskbotScript::proc23() const { @@ -330,7 +336,7 @@ bool DeskbotScript::isDial1Low() const { return getDialRegion(1) == 0; } -int DeskbotScript::addAssignedRoomDialogue() { +uint DeskbotScript::addAssignedRoomDialogue() { if (isDial1Medium()) { addResponse(getDialogueId(240407)); addResponse(getDialogueId(241510)); @@ -351,7 +357,7 @@ int DeskbotScript::addAssignedRoomDialogue() { } } -int DeskbotScript::addAssignedRoomDialogue2() { +uint DeskbotScript::addAssignedRoomDialogue2() { addResponse(getDialogueId(241355)); int roomNum = 0, floorNum = 0, elevatorNum = 0; getAssignedRoom(&roomNum, &floorNum, &elevatorNum); @@ -385,7 +391,7 @@ void DeskbotScript::addAssignedRoomDialogue3() { applyResponse(); } -int DeskbotScript::getStateDialogueId() const { +uint DeskbotScript::getStateDialogueId() const { switch (getValue(1)) { case 1: return 241503; @@ -396,11 +402,11 @@ int DeskbotScript::getStateDialogueId() const { } } -void DeskbotScript::setFlags17(int newId, int index) { +void DeskbotScript::setFlags17(uint newId, uint index) { int newValue = getValue(17); for (uint idx = 0; idx < _states.size(); ++idx) { - const TTupdateState3 &us = _states[idx]; + const TTupdateState &us = _states[idx]; if (newId == (idx == 0 ? 0 : us._newId)) { uint bits = us._dialBits; diff --git a/engines/titanic/true_talk/deskbot_script.h b/engines/titanic/true_talk/deskbot_script.h index be12b52509..09ae9c839e 100644 --- a/engines/titanic/true_talk/deskbot_script.h +++ b/engines/titanic/true_talk/deskbot_script.h @@ -31,7 +31,7 @@ namespace Titanic { class DeskbotScript : public TTnpcScript { private: static int _oldId; - TTupdateState3Array _states; + TTupdateStateArray _states; private: /** * Setup sentence data @@ -41,12 +41,12 @@ private: /** * Adds dialogue for the player's assigned room */ - int addAssignedRoomDialogue(); + uint addAssignedRoomDialogue(); /** * Adds dialogue for the player's assigned room */ - int addAssignedRoomDialogue2(); + uint addAssignedRoomDialogue2(); /** * Adds dialogue for the player's assigned room @@ -56,12 +56,12 @@ private: /** * Gets a dialogue Id based on the NPC's state */ - int getStateDialogueId() const; + uint getStateDialogueId() const; /** * Sets state data in flags 17 */ - void setFlags17(int newId, int index); + void setFlags17(uint newId, uint index); public: DeskbotScript(int val1, const char *charClass, int v2, const char *charName, int v3, int val2); @@ -84,7 +84,11 @@ public: */ virtual int updateState(uint oldId, uint newId, int index); - virtual int proc22(int id) const; + /** + * Handles getting a pre-response + */ + virtual int preResponse(uint id); + virtual int proc23() const; virtual int proc25(int val1, const int *srcIdP, TTroomScript *roomScript, TTsentence *sentence); virtual void proc26(int v1, const TTsentenceEntry *entry, TTroomScript *roomScript, TTsentence *sentence); diff --git a/engines/titanic/true_talk/doorbot_script.cpp b/engines/titanic/true_talk/doorbot_script.cpp index 3dc1e7fa61..d4c18cfc60 100644 --- a/engines/titanic/true_talk/doorbot_script.cpp +++ b/engines/titanic/true_talk/doorbot_script.cpp @@ -302,7 +302,7 @@ int DoorbotScript::updateState(uint oldId, uint newId, int index) { } for (uint idx = 0; idx < _states.size(); ++idx) { - TTupdateState3 &us = _states[idx]; + TTupdateState &us = _states[idx]; if (us._newId == newId) { uint bits = us._dialBits; @@ -320,9 +320,14 @@ int DoorbotScript::updateState(uint oldId, uint newId, int index) { return newId; } -int DoorbotScript::proc22(int id) const { - warning("TODO"); - return 0; +int DoorbotScript::preResponse(uint id) { + uint newId = 0; + if (getDialRegion(0) != 1 && getRandomNumber(100) > 60) { + addResponse(11195); + newId = 222193; + } + + return newId; } uint DoorbotScript::getDialsBitset() const { diff --git a/engines/titanic/true_talk/doorbot_script.h b/engines/titanic/true_talk/doorbot_script.h index 15463d5326..7aac6b2a98 100644 --- a/engines/titanic/true_talk/doorbot_script.h +++ b/engines/titanic/true_talk/doorbot_script.h @@ -29,7 +29,7 @@ namespace Titanic { class DoorbotScript : public TTnpcScript { private: - TTupdateState3Array _states; + TTupdateStateArray _states; int _stateIndex; private: /** @@ -78,7 +78,10 @@ public: */ virtual int updateState(uint oldId, uint newId, int index); - virtual int proc22(int id) const; + /** + * Handles getting a pre-response + */ + virtual int preResponse(uint id); /** * Returns a bitset of the dials being off or not diff --git a/engines/titanic/true_talk/liftbot_script.cpp b/engines/titanic/true_talk/liftbot_script.cpp index 66e2042ee3..0f582154cf 100644 --- a/engines/titanic/true_talk/liftbot_script.cpp +++ b/engines/titanic/true_talk/liftbot_script.cpp @@ -213,7 +213,7 @@ int LiftbotScript::handleQuote(TTroomScript *roomScript, TTsentence *sentence, int LiftbotScript::updateState(uint oldId, uint newId, int index) { for (uint idx = 0; idx < _states.size(); ++idx) { - TTupdateState2 &us = _states[idx]; + TTmapEntry &us = _states[idx]; if (us._src == newId) { setState(us._dest); break; @@ -223,8 +223,14 @@ int LiftbotScript::updateState(uint oldId, uint newId, int index) { return newId; } -int LiftbotScript::proc22(int id) const { - warning("TODO"); +int LiftbotScript::preResponse(uint id) { + if (id == 30565 || id == 30566 || id == 30567 || id == 30568 + || id == 30569 || id == 30570 || id == 30571) + return 210901; + + if (getDialRegion(0) == 0 && getRandomNumber(100) > 60) + return 210830; + return 0; } diff --git a/engines/titanic/true_talk/liftbot_script.h b/engines/titanic/true_talk/liftbot_script.h index ee8dbc14f5..33da983323 100644 --- a/engines/titanic/true_talk/liftbot_script.h +++ b/engines/titanic/true_talk/liftbot_script.h @@ -29,7 +29,7 @@ namespace Titanic { class LiftbotScript : public TTnpcScript { private: - TTupdateState2Array _states; + TTmapEntryArray _states; static int _stateIndex; private: /** @@ -75,7 +75,10 @@ public: */ virtual int updateState(uint oldId, uint newId, int index); - virtual int proc22(int id) const; + /** + * Handles getting a pre-response + */ + virtual int preResponse(uint id); /** * Returns a bitset of the dials being off or not diff --git a/engines/titanic/true_talk/maitred_script.cpp b/engines/titanic/true_talk/maitred_script.cpp index 6eabcb4017..c6ceca89c7 100644 --- a/engines/titanic/true_talk/maitred_script.cpp +++ b/engines/titanic/true_talk/maitred_script.cpp @@ -254,7 +254,7 @@ int MaitreDScript::updateState(uint oldId, uint newId, int index) { } if (!getValue(12)) { - static const int FLAG_IDS[] = { + static const uint FLAG_IDS[] = { 260080, 260066, 260067, 260062, 260050, 260087, 260090, 260171, 260173, 260184, 260193, 260202, 260205, 260220, 260221, 260223, 260231, 260232, 260365, 260373, 260374, 260387, 260421, 260622, 260695, 0 @@ -294,8 +294,10 @@ int MaitreDScript::updateState(uint oldId, uint newId, int index) { return newId; } -int MaitreDScript::proc22(int id) const { - warning("TODO"); +int MaitreDScript::preResponse(uint id) { + if (id == 60911) + return 260101; + return 0; } @@ -376,10 +378,10 @@ void MaitreDScript::setFlags12() { } } -void MaitreDScript::setFlags10(int newId, int index) { +void MaitreDScript::setFlags10(uint newId, uint index) { int val = 28; for (uint idx = 0; idx < _states.size(); ++idx) { - TTupdateState2 &us = _states[idx]; + TTmapEntry &us = _states[idx]; if (us._src == newId) { val = us._dest; break; diff --git a/engines/titanic/true_talk/maitred_script.h b/engines/titanic/true_talk/maitred_script.h index 7195fb2b4a..60113b82dc 100644 --- a/engines/titanic/true_talk/maitred_script.h +++ b/engines/titanic/true_talk/maitred_script.h @@ -29,7 +29,7 @@ namespace Titanic { class MaitreDScript : public TTnpcScript { private: - TTupdateState2Array _states; + TTmapEntryArray _states; private: /** * Setup sentence data @@ -50,7 +50,7 @@ private: * Sets flags 10 to different values based on the passed * dialogue Id */ - void setFlags10(int newId, int index); + void setFlags10(uint newId, uint index); /** * Trigers 12 @@ -83,7 +83,11 @@ public: */ virtual int updateState(uint oldId, uint newId, int index); - virtual int proc22(int id) const; + /** + * Handles getting a pre-response + */ + virtual int preResponse(uint id); + virtual int proc23() const; virtual int proc25(int val1, const int *srcIdP, TTroomScript *roomScript, TTsentence *sentence); virtual void proc26(int v1, const TTsentenceEntry *entry, TTroomScript *roomScript, TTsentence *sentence); diff --git a/engines/titanic/true_talk/script_support.cpp b/engines/titanic/true_talk/script_support.cpp index af5ef05283..f2c473d883 100644 --- a/engines/titanic/true_talk/script_support.cpp +++ b/engines/titanic/true_talk/script_support.cpp @@ -164,11 +164,11 @@ void TThandleQuoteEntries::load(const char *name) { /*------------------------------------------------------------------------*/ -void TTupdateState2Array::load(const char *name) { +void TTmapEntryArray::load(const char *name) { Common::SeekableReadStream *r = g_vm->_filesManager->getResource(name); while (r->pos() < r->size()) { - TTupdateState2 us; + TTmapEntry us; us._src = r->readUint32LE(); us._dest = r->readUint32LE(); @@ -178,13 +178,23 @@ void TTupdateState2Array::load(const char *name) { delete r; } +int TTmapEntryArray::find(uint id) const { + for (uint idx = 0; idx < size(); ++idx) { + const TTmapEntry &me = (*this)[idx]; + if (me._src == id) + return me._dest; + } + + return 0; +} + /*------------------------------------------------------------------------*/ -void TTupdateState3Array::load(const char *name) { +void TTupdateStateArray::load(const char *name) { Common::SeekableReadStream *r = g_vm->_filesManager->getResource(name); while (r->pos() < r->size()) { - TTupdateState3 ue; + TTupdateState ue; ue._newId = r->readUint32LE(); ue._newValue = r->readUint32LE(); ue._dialBits = r->readUint32LE(); diff --git a/engines/titanic/true_talk/script_support.h b/engines/titanic/true_talk/script_support.h index 6a60563202..ca70b09a62 100644 --- a/engines/titanic/true_talk/script_support.h +++ b/engines/titanic/true_talk/script_support.h @@ -142,27 +142,32 @@ public: void load(const char *name); }; -struct TTupdateState2 { +struct TTmapEntry { uint _src; uint _dest; - TTupdateState2() : _src(0), _dest(0) {} + TTmapEntry() : _src(0), _dest(0) {} }; -class TTupdateState2Array : public Common::Array<TTupdateState2> { +class TTmapEntryArray : public Common::Array<TTmapEntry> { public: void load(const char *name); + + /** + * Finds a record by Id, and returns it's associated value + */ + int find(uint id) const; }; -struct TTupdateState3 { +struct TTupdateState { uint _newId; uint _newValue; uint _dialBits; - TTupdateState3() : _newId(0), _newValue(0), _dialBits(0) {} + TTupdateState() : _newId(0), _newValue(0), _dialBits(0) {} }; -class TTupdateState3Array : public Common::Array<TTupdateState3> { +class TTupdateStateArray : public Common::Array<TTupdateState> { public: void load(const char *name); }; diff --git a/engines/titanic/true_talk/tt_npc_script.cpp b/engines/titanic/true_talk/tt_npc_script.cpp index 18ade0cba6..4cd964d57b 100644 --- a/engines/titanic/true_talk/tt_npc_script.cpp +++ b/engines/titanic/true_talk/tt_npc_script.cpp @@ -376,7 +376,7 @@ int TTnpcScript::updateState(uint oldId, uint newId, int index) { return newId; } -int TTnpcScript::proc22(int id) const { +int TTnpcScript::preResponse(uint id) { return 0; } @@ -742,7 +742,7 @@ int TTnpcScript::processEntries(const TTsentenceEntries *entries, uint entryCoun return 2; addResponse(dialogueId); - id = proc22(dialogueId); + id = preResponse(dialogueId); if (id) addResponse(getDialogueId(id)); applyResponse(); diff --git a/engines/titanic/true_talk/tt_npc_script.h b/engines/titanic/true_talk/tt_npc_script.h index eb53dc9bb2..f52df351b3 100644 --- a/engines/titanic/true_talk/tt_npc_script.h +++ b/engines/titanic/true_talk/tt_npc_script.h @@ -261,7 +261,10 @@ public: */ virtual int updateState(uint oldId, uint newId, int index); - virtual int proc22(int id) const; + /** + * Handles getting a pre-response + */ + virtual int preResponse(uint id); /** * Returns a bitset of the dials being off or not |