diff options
author | Paul Gilbert | 2016-07-24 22:13:55 -0400 |
---|---|---|
committer | Paul Gilbert | 2016-07-24 22:13:55 -0400 |
commit | cf805b07d33adb7809f88e8e5d297831d75df166 (patch) | |
tree | 1d01865660c4f81514a5f1f976ce7f9be4a27751 /engines | |
parent | 13ce0156ff16cddbdfe108b92fbcf83a28c090e7 (diff) | |
download | scummvm-rg350-cf805b07d33adb7809f88e8e5d297831d75df166.tar.gz scummvm-rg350-cf805b07d33adb7809f88e8e5d297831d75df166.tar.bz2 scummvm-rg350-cf805b07d33adb7809f88e8e5d297831d75df166.zip |
TITANIC: Adding NPC Script support methods
Diffstat (limited to 'engines')
-rw-r--r-- | engines/titanic/true_talk/barbot_script.cpp | 83 | ||||
-rw-r--r-- | engines/titanic/true_talk/script_handler.cpp | 22 | ||||
-rw-r--r-- | engines/titanic/true_talk/script_handler.h | 5 | ||||
-rw-r--r-- | engines/titanic/true_talk/tt_npc_script.cpp | 43 | ||||
-rw-r--r-- | engines/titanic/true_talk/tt_npc_script.h | 3 |
5 files changed, 154 insertions, 2 deletions
diff --git a/engines/titanic/true_talk/barbot_script.cpp b/engines/titanic/true_talk/barbot_script.cpp index 03aa1cdaae..cd44d631b4 100644 --- a/engines/titanic/true_talk/barbot_script.cpp +++ b/engines/titanic/true_talk/barbot_script.cpp @@ -756,8 +756,87 @@ done: } ScriptChangedResult BarbotScript::scriptChanged(TTscriptBase *roomScript, uint id) { - warning("TODO"); - return SCR_1; + switch (id) { + case 1: + case 100: + if (!isState9()) { + selectResponse(250210); + applyResponse(); + } + + adjustDial(0, getRandomBit() ? getRandomNumber(5) * 4 : + -getRandomNumber(5) * 4); + break; + + case 3: + if (isState9()) { + selectResponse(250244); + applyResponse(); + resetFlags(); + } else { + if (!getValue(28) || !fn10(true)) { + addResponse(getDialogueId(251627 + getValue(28) ? -1034 : 0)); + applyResponse(); + } + + CTrueTalkManager::setFlags(28, 1); + resetFlags(); + } + break; + + case 4: + selectResponse(isState9() ? 250141 : 250140); + applyResponse(); + adjustDial(2, getDialLevel(2, false) < 50 ? -15 - getRandomNumber(30) : + 15 + getRandomNumber(30)); + + if (getDialRegion(1) != 0 && getRandomNumber(100) > 75) + adjustDial(1, -35); + break; + + case 143: + addResponse(getDialogueId(isState9() ? 250577 : 250576)); + break; + + case 144: + addResponse(getDialogueId(isState9() ? 250577 : 250584)); + break; + + case 145: + if (isState9()) { + addResponse(getDialogueId(250577)); + applyResponse(); + } else { + set34(57); + } + break; + + case 146: + addResponse(getDialogueId(isState9() ? 250577 : 250574)); + break; + + case 147: + addResponse(getDialogueId(250579)); + break; + + } + + if (id >= 250000 && id <= 251900) { + if (id > 250571) { + if (id != 250575 && (id == 250586 || id == 251858 || !isState9())) { + addResponse(getDialogueId(id)); + applyResponse(); + } + } else if (id == 250571 || (id != 250244 && !isState9()) || isState9()) { + addResponse(getDialogueId(id)); + applyResponse(); + } else { + addResponse(getDialogueId(251018)); + applyResponse(); + } + } + + return SCR_2; } int BarbotScript::proc15() const { diff --git a/engines/titanic/true_talk/script_handler.cpp b/engines/titanic/true_talk/script_handler.cpp index cd06d71796..c4665465da 100644 --- a/engines/titanic/true_talk/script_handler.cpp +++ b/engines/titanic/true_talk/script_handler.cpp @@ -24,6 +24,7 @@ #include "titanic/true_talk/tt_concept.h" #include "titanic/true_talk/tt_sentence.h" #include "titanic/true_talk/tt_parser.h" +#include "titanic/true_talk/tt_word.h" #include "titanic/titanic.h" namespace Titanic { @@ -117,4 +118,25 @@ int CScriptHandler::setResponse(TTscriptBase *script, TTresponse *response) { return _owner->setResponse(script, response); } +void CScriptHandler::handleWord(TTstring &str) { + handleWord1(str); + handleWord2(str); +} + +void CScriptHandler::handleWord1(TTstring &str) { + if (_concept2P) + delete _concept2P; + + TTword word(str, WC_UNKNOWN, 0); + _concept2P = new TTconcept(&word); +} + +void CScriptHandler::handleWord2(TTstring &str) { + if (_concept1P) + delete _concept1P; + + TTword word(str, WC_UNKNOWN, 0); + _concept1P = new TTconcept(&word); +} + } // End of namespace Titanic diff --git a/engines/titanic/true_talk/script_handler.h b/engines/titanic/true_talk/script_handler.h index 93abbc3d3a..11976d902d 100644 --- a/engines/titanic/true_talk/script_handler.h +++ b/engines/titanic/true_talk/script_handler.h @@ -42,6 +42,9 @@ private: int _field10; int _inputCtr; int _field30; +private: + void handleWord1(TTstring &str); + void handleWord2(TTstring &str); public: TTparser _parser; TTvocab *_vocab; @@ -77,6 +80,8 @@ public: * Sets a conversation reponse */ int setResponse(TTscriptBase *script, TTresponse *response); + + void handleWord(TTstring &str); }; } // 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 f673cc0313..70be472d79 100644 --- a/engines/titanic/true_talk/tt_npc_script.cpp +++ b/engines/titanic/true_talk/tt_npc_script.cpp @@ -929,4 +929,47 @@ void TTnpcScript::updateCurrentDial(bool changeDial) { } } +bool TTnpcScript::fn10(bool flag) { + if (_itemStringP) { + for (const ItemRec *ir = ARRAY1; ir->_id; ++ir) { + if (!strcmp(ir->_name, _itemStringP)) { + _itemStringP = nullptr; + uint id = getDialogueId(ir->_id); + if (id == 4) { + return true; + } else if (id != 0) { + addResponse(id); + applyResponse(); + return true; + } + break; + } + } + + _itemStringP = nullptr; + } + + if (flag && getRandomNumber(100) > 60) { + int val = getRandomNumber(18) - 1; + + if (val == 0 && !getRoom54(101) && !getRoom54(132)) + val = -1; + else if ((val == 1 && !_field7C) || val == 2) + val = -1; + + if (val >= 0) { + val = getDialogueId(ARRAY2[val]); + if (val == 4) { + return true; + } else { + addResponse(val); + applyResponse(); + return true; + } + } + } + + return false; +} + } // 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 8a17064034..2bd4e6dae3 100644 --- a/engines/titanic/true_talk/tt_npc_script.h +++ b/engines/titanic/true_talk/tt_npc_script.h @@ -263,6 +263,9 @@ protected: * Updates the current dial with the given delta */ void updateCurrentDial(bool changeDial); + + bool fn10(bool flag); + public: static void init(); static void deinit(); |