diff options
-rw-r--r-- | engines/titanic/true_talk/succubus_script.cpp | 130 | ||||
-rw-r--r-- | engines/titanic/true_talk/succubus_script.h | 7 |
2 files changed, 130 insertions, 7 deletions
diff --git a/engines/titanic/true_talk/succubus_script.cpp b/engines/titanic/true_talk/succubus_script.cpp index e950f549b7..2cbef1e365 100644 --- a/engines/titanic/true_talk/succubus_script.cpp +++ b/engines/titanic/true_talk/succubus_script.cpp @@ -22,13 +22,15 @@ #include "common/textconsole.h" #include "titanic/true_talk/succubus_script.h" +#include "titanic/true_talk/true_talk_manager.h" +#include "titanic/titanic.h" namespace Titanic { SuccUBusScript::SuccUBusScript(int val1, const char *charClass, int v2, const char *charName, int v3, int val2, int v4, int v5, int v6, int v7) : TTnpcScript(val1, charClass, v2, charName, v3, val2, v4, v5, v6, v7), - _field2D0(0) { + _isRoom101(false) { loadRanges("Ranges/SuccUBus"); setupSentences(); @@ -75,13 +77,114 @@ int SuccUBusScript::chooseResponse(const TTroomScript *roomScript, const TTsente } int SuccUBusScript::process(const TTroomScript *roomScript, const TTsentence *sentence) { - // TODO - return 0; + if (!CTrueTalkManager::getStateValue(1)) + return 2; + + if (roomScript && roomScript->_scriptId == 101) + _isRoom101 = true; + + int currState = getState(); + if (currState) { + int currMode = sentence->_field2C; + bool modeFlag1 = currMode == 11 || currMode == 13; + bool modeFlag2 = currMode == 12; + setState(0); + + switch (currState) { + case 1: + if (currMode == 3 || currMode == 10) + return setResponse(70050, 0); + break; + + case 2: + if (modeFlag1 || modeFlag2) + return setResponse(70070 + (getRandomBit() ? 254 : 0), 0); + break; + + case 3: + if (currMode == 3 || currMode == 10) + return setResponse(70074, 0); + break; + + case 4: + if (currMode == 4) + return setResponse(70077, 0); + if (currMode == 3) + return setResponse(getDialogueId(230117), 0); + break; + + case 5: + if (currMode == 3 || currMode == 10) + return setResponse(70089, 0); + break; + + case 6: + if (modeFlag1) + return setResponse(70103, 0); + if (modeFlag2) + return setResponse(70102, 0); + break; + + case 7: + if (modeFlag1) + return setResponse(getDialogueId(230157), 0); + break; + + case 8: + if (modeFlag1) + return setResponse(getDialogueId(230159), 0); + break; + + case 9: + if (modeFlag1) + return setResponse(getDialogueId(230160), 0); + break; + + case 10: + if (modeFlag1) + return setResponse(getDialogueId(230161), 0); + break; + + case 11: + if (modeFlag1) + return setResponse(getDialogueId(230142), 0); + break; + + case 12: + return setResponse(70030, 0); + + default: + break; + } + } + + if (processEntries(&_entries, _entryCount, roomScript, sentence) != 2) { + uint tagId = g_vm->_trueTalkManager->_quotes.find(sentence->_normalizedLine.c_str()); + if (tagId && chooseResponse(roomScript, sentence, tagId) != 2) { + addResponse(getDialogueId(230030)); + applyResponse(); + } + } + + return 2; } ScriptChangedResult SuccUBusScript::scriptChanged(const TTroomScript *roomScript, uint id) { - warning("TODO"); - return SCR_1; + if (id == 148) + CTrueTalkManager::setFlags(3, 1); + else if (id == 150) + CTrueTalkManager::setFlags(2, 1); + + if (id >= 230000 && id <= 230245) { + addResponse(getDialogueId(id)); + applyResponse(); + } + else if (id >= 70000 && id <= 70243) { + addResponse(id); + applyResponse(); + } + + return SCR_2; } int SuccUBusScript::updateState(uint oldId, uint newId, int index) { @@ -90,8 +193,23 @@ int SuccUBusScript::updateState(uint oldId, uint newId, int index) { } int SuccUBusScript::doSentenceEntry(int val1, const int *srcIdP, const TTroomScript *roomScript, const TTsentence *sentence) { - warning("TODO"); + if (val1 == 1 && roomScript && roomScript->_scriptId == 101) { + addResponse(getDialogueId(230239)); + applyResponse(); + return 2; + } + return 0; } +int SuccUBusScript::setResponse(int dialogueId, int state) { + addResponse(dialogueId); + applyResponse(); + + if (state != -1) + setState(state); + + return 2; +} + } // End of namespace Titanic diff --git a/engines/titanic/true_talk/succubus_script.h b/engines/titanic/true_talk/succubus_script.h index 541392eb30..d5cea7e66f 100644 --- a/engines/titanic/true_talk/succubus_script.h +++ b/engines/titanic/true_talk/succubus_script.h @@ -29,12 +29,17 @@ namespace Titanic { class SuccUBusScript : public TTnpcScript { private: - int _field2D0; + bool _isRoom101; private: /** * Setup sentence data */ void setupSentences(); + + /** + * Add a response and optionally set the state + */ + int setResponse(int dialogueId, int state = -1); public: SuccUBusScript(int val1, const char *charClass, int v2, const char *charName, int v3, int val2, int v4, int v5, int v6, int v7); |