From 89da2a88573f1acd8c311764a84f0054011f46c2 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 27 Jul 2016 06:43:12 -0400 Subject: TITANIC: Moved handleQuote data arrays to datafile --- engines/titanic/true_talk/barbot_script.cpp | 94 +------------------ engines/titanic/true_talk/bellbot_script.cpp | 129 +-------------------------- engines/titanic/true_talk/deskbot_script.cpp | 123 +------------------------ engines/titanic/true_talk/doorbot_script.cpp | 4 +- engines/titanic/true_talk/liftbot_script.cpp | 4 +- engines/titanic/true_talk/maitred_script.cpp | 4 +- engines/titanic/true_talk/script_support.cpp | 22 +++++ engines/titanic/true_talk/script_support.h | 12 +++ engines/titanic/true_talk/tt_npc_script.cpp | 53 +++++++++++ engines/titanic/true_talk/tt_npc_script.h | 1 + 10 files changed, 104 insertions(+), 342 deletions(-) (limited to 'engines') diff --git a/engines/titanic/true_talk/barbot_script.cpp b/engines/titanic/true_talk/barbot_script.cpp index a3ab0586b4..7a20ee44ad 100644 --- a/engines/titanic/true_talk/barbot_script.cpp +++ b/engines/titanic/true_talk/barbot_script.cpp @@ -40,55 +40,6 @@ static const uint ARRAY2[] = { 51899, 51900, 51901, 51902, 51903, 51904, 51905, 51906, 51907, 0 }; -static const TThandleQuoteEntry QUOTES[] = { - { 0x00000008, 0x00000000, 0x0003D372 }, - { 0x00000007, 0x00000000, 0x0003D72B }, - { 0x00000004, 0x00000000, 0x0003D722 }, - { 0x00000006, 0x00000000, 0x0003D264 }, - { 0x00000005, 0x00000000, 0x0003D72F }, - { 0x00000001, 0x00000032, 0x00000001 }, - { 0x00000002, 0x00000032, 0x00000001 }, - { 0x00000003, 0x00000032, 0x00000001 }, - { 0x00000010, 0x54524156, 0x0003D2B1 }, - { 0x00000010, 0x0000003C, 0x00000000 }, - { 0x00000011, 0x00000000, 0x0003D484 }, - { 0x00000015, 0x00000032, 0x0003D2B2 }, - { 0x00000012, 0x00000042, 0x0003D499 }, - { 0x00000013, 0x00000021, 0x0003D31E }, - { 0x0000001D, 0x00000021, 0x0003D31E }, - { 0x00000014, 0x00000042, 0x0003D49E }, - { 0x00000016, 0x0000003C, 0x0003D2B6 }, - { 0x00000017, 0x00000028, 0x0003D2B5 }, - { 0x00000018, 0x00000000, 0x0003D35E }, - { 0x00000019, 0x00000000, 0x0003D35E }, - { 0x0000001A, 0x0000003C, 0x0003D38B }, - { 0x0000001B, 0x00000000, 0x0003D2F8 }, - { 0x00000009, 0x00000019, 0x0003D326 }, - { 0x0000000A, 0x00000019, 0x0003D314 }, - { 0x0000000B, 0x00000028, 0x0003D311 }, - { 0x0000001E, 0x00000000, 0x0003D6F2 }, - { 0x0000001F, 0x00000000, 0x0003D26C }, - { 0x0000000C, 0x00000000, 0x0003D2F4 }, - { 0x0000000D, 0x00000000, 0x0003D2F4 }, - { 0x0000000E, 0x00000000, 0x0003D2F4 }, - { 0x0000000F, 0x00000000, 0x0003D2F4 }, - { 0x00000020, 0x00000019, 0x0003D389 }, - { 0x00000021, 0x0000000F, 0x0003D29C }, - { 0x00000022, 0x0000000F, 0x0003D494 }, - { 0x0000001C, 0x00000032, 0x00000000 }, - { 0x00000023, 0x00000000, 0x0003D7F8 }, - { 0x00000024, 0x00000000, 0x0003D7F9 }, - { 0x00000031, 0x00000000, 0x0003D722 }, - { 0x00000032, 0x00000000, 0x0003D722 }, - { 0x00000033, 0x00000000, 0x0003D372 }, - { 0x00000034, 0x00000000, 0x0003D323 }, - { 0x0000003E, 0x00000000, 0x0003D163 }, - { 0x0000003F, 0x00000000, 0x0003D163 }, - { 0x00000040, 0x00000000, 0x0003D163 }, - { 0x00000041, 0x00000000, 0x0003D691 }, - { 0x00000000, 0x00000000, 0x00000000 } -}; - BarbotScript::BarbotScript(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) { @@ -99,6 +50,7 @@ BarbotScript::BarbotScript(int val1, const char *charClass, int v2, loadResponses("Responses/Barbot"); setupSentences(); _tagMappings.load("TagMap/Barbot"); + _quotes.load("Quotes/Barbot"); } void BarbotScript::setupSentences() { @@ -1009,49 +961,7 @@ int BarbotScript::handleQuote(TTroomScript *roomScript, TTsentence *sentence, return setResponse(getDialogueId(222301), -1); } - int loopCounter = 0; - for (const TThandleQuoteEntry *qe = QUOTES; qe->_index && loopCounter < 2; ++qe) { - if (!qe->_index) { - // End of list; start at beginning again - ++loopCounter; - qe = QUOTES; - } - - if (qe->_index == val && ( - (tagId == 0 && loopCounter == 2) || - (qe->_tagId < MKTAG('A', 'A', 'A', 'A')) || - (qe->_tagId == tagId) - )) { - uint foundTagId = qe->_tagId; - if (foundTagId > 0 && foundTagId < 100) { - if (!tagId) - foundTagId >>= 1; - if (getRandomNumber(100) < foundTagId) - return 1; - } - - uint dialogueId = qe->_dialogueId; - if (dialogueId < 1000) { - if (dialogueId >= 3) - error("Invalid dialogue index in BarbotScript"); - const int RANDOM_LIMITS[3] = { 30, 50, 70 }; - int rangeLimit = RANDOM_LIMITS[dialogueId]; - int dialRegion = getDialRegion(0); - - if (dialRegion != 1) { - rangeLimit = MAX(rangeLimit - 20, 20); - } - - dialogueId = (((int)remainder + 25) % 100) >= rangeLimit ? 221376 : 221375; - } - - addResponse(getDialogueId(dialogueId)); - applyResponse(); - return 2; - } - } - - return 1; + return TTnpcScript::handleQuote(roomScript, sentence, val, tagId, remainder); } int BarbotScript::proc21(int v1, int v2, int v3) { diff --git a/engines/titanic/true_talk/bellbot_script.cpp b/engines/titanic/true_talk/bellbot_script.cpp index b91d78b057..988efa940b 100644 --- a/engines/titanic/true_talk/bellbot_script.cpp +++ b/engines/titanic/true_talk/bellbot_script.cpp @@ -27,87 +27,6 @@ namespace Titanic { -static const TThandleQuoteEntry QUOTES[] = { - { 0x00000008, 0x00000000, 0x00031116 }, - { 0x00000007, 0x00000000, 0x00031447 }, - { 0x00000006, 0x00000000, 0x000310F9 }, - { 0x00000005, 0x00000000, 0x000313A1 }, - { 0x00000001, 0x56424144, 0x000313D7 }, - { 0x00000001, 0x52554445, 0x000313D7 }, - { 0x00000001, 0x5052534E, 0x00041EB3 }, - { 0x00000001, 0x424F5953, 0x00041EB3 }, - { 0x00000001, 0x4749524C, 0x00041EB3 }, - { 0x00000001, 0x464F4F44, 0x00041EB3 }, - { 0x00000001, 0x00000032, 0x00041EB1 }, - { 0x0000001C, 0x00000032, 0x00041EB0 }, - { 0x00000010, 0x54524156, 0x000313C6 }, - { 0x00000010, 0x0000003C, 0x00041EB0 }, - { 0x00000011, 0x00000000, 0x0003139E }, - { 0x00000015, 0x00000032, 0x0003139F }, - { 0x00000012, 0x00000042, 0x000313A0 }, - { 0x00000013, 0x00000021, 0x000313A7 }, - { 0x0000001D, 0x00000021, 0x000313A7 }, - { 0x00000014, 0x00000042, 0x000313A4 }, - { 0x0000001B, 0x00000000, 0x0003139B }, - { 0x0000001E, 0x00000000, 0x000313A2 }, - { 0x0000001F, 0x00000000, 0x00030DC0 }, - { 0x0000000C, 0x00000000, 0x000313A9 }, - { 0x0000000D, 0x00000000, 0x000313A9 }, - { 0x0000000E, 0x00000000, 0x000313A8 }, - { 0x0000000F, 0x00000000, 0x000313A8 }, - { 0x00000020, 0x00000019, 0x000313AB }, - { 0x00000021, 0x0000000F, 0x000313AC }, - { 0x00000023, 0x00000000, 0x00031337 }, - { 0x00000024, 0x00000000, 0x0003135A }, - { 0x00000025, 0x00000000, 0x000311AB }, - { 0x00000026, 0x00000000, 0x0003112E }, - { 0x00000030, 0x00000000, 0x0003106C }, - { 0x00000027, 0x424F5953, 0x0003140C }, - { 0x00000027, 0x4749524C, 0x0003140D }, - { 0x00000027, 0x00000000, 0x0003140D }, - { 0x00000028, 0x00000000, 0x00031404 }, - { 0x00000029, 0x00000000, 0x00031405 }, - { 0x0000002A, 0x00000000, 0x00031406 }, - { 0x0000002B, 0x00000000, 0x00031407 }, - { 0x0000002C, 0x00000000, 0x00031408 }, - { 0x0000002D, 0x00000000, 0x00031409 }, - { 0x0000002E, 0x424F5953, 0x0003140A }, - { 0x0000002E, 0x4749524C, 0x0003140B }, - { 0x0000002E, 0x00000000, 0x0003140B }, - { 0x00000032, 0x00000000, 0x000313D6 }, - { 0x00000033, 0x00000000, 0x000313D7 }, - { 0x00000034, 0x00000000, 0x000313D8 }, - { 0x00000035, 0x00000000, 0x0003113D }, - { 0x00000036, 0x00000000, 0x00030DCB }, - { 0x00000031, 0x00000000, 0x00030DB5 }, - { 0x00000037, 0x00000000, 0x000313DD }, - { 0x00000038, 0x00000000, 0x00030EE4 }, - { 0x00000039, 0x00000000, 0x0003160B }, - { 0x0000003A, 0x00000000, 0x000310C4 }, - { 0x0000003B, 0x00000000, 0x000310C5 }, - { 0x0000003C, 0x00000000, 0x0003121C }, - { 0x0000003D, 0x00000000, 0x00031623 }, - { 0x0000003F, 0x00000000, 0x00030D99 }, - { 0x0000003E, 0x00000000, 0x00030D99 }, - { 0x00000040, 0x00000000, 0x000315CE }, - { 0x00000041, 0x00000000, 0x000315DC }, - { 0x00000042, 0x00000000, 0x00031478 }, - { 0x00000043, 0x00000000, 0x00030FC8 }, - { 0x00000044, 0x00000000, 0x0003106D }, - { 0x00000054, 0x00000000, 0x00031514 }, - { 0x00000055, 0x00000000, 0x00031515 }, - { 0x00000056, 0x00000000, 0x000315CF }, - { 0x0000005A, 0x00000000, 0x000310F9 }, - { 0x00000058, 0x00000000, 0x000315DF }, - { 0x0000005B, 0x00000000, 0x00031620 }, - { 0x0000005C, 0x00000000, 0x0003134B }, - { 0x00000059, 0x00000000, 0x0003150F }, - { 0x00000057, 0x00000000, 0x00030D58 }, - { 0x00000045, 0x0000000A, 0x000310C3 }, - { 0x00000046, 0x00000000, 0x00030EAD }, - { 0x00000000, 0x00000000, 0x00000000 } -}; - BellbotScript::BellbotScript(int val1, const char *charClass, int v2, const char *charName, int v3, int val2) : TTnpcScript(val1, charClass, v2, charName, v3, val2, -1, -1, -1, 0), @@ -126,6 +45,7 @@ BellbotScript::BellbotScript(int val1, const char *charClass, int v2, setupSentences(); _tagMappings.load("TagMap/Bellbot"); _words.load("Words/Bellbot"); + _quotes.load("Quotes/Bellbot"); } void BellbotScript::setupSentences() { @@ -258,51 +178,8 @@ int BellbotScript::handleQuote(TTroomScript *roomScript, TTsentence *sentence, default: break; } - - int loopCounter = 0; - for (const TThandleQuoteEntry *qe = QUOTES; qe->_index && loopCounter < 2; ++qe) { - if (!qe->_index) { - // End of list; start at beginning again - ++loopCounter; - qe = QUOTES; - } - - if (qe->_index == val && ( - (tagId == 0 && loopCounter == 2) || - (qe->_tagId < MKTAG('A', 'A', 'A', 'A')) || - (qe->_tagId == tagId) - )) { - uint foundTagId = qe->_tagId; - if (foundTagId > 0 && foundTagId < 100) { - if (!tagId) - foundTagId >>= 1; - if (getRandomNumber(100) < foundTagId) - return 1; - } - - uint dialogueId = qe->_dialogueId; - if (dialogueId >= 270000 && dialogueId <= 275000) { - dialogueId -= 270000; - if (dialogueId >= 3) - error("Invalid dialogue index in BarbotScript"); - const int RANDOM_LIMITS[3] = { 30, 50, 70 }; - int rangeLimit = RANDOM_LIMITS[dialogueId]; - int dialRegion = getDialRegion(0); - - if (dialRegion != 1) { - rangeLimit = MAX(rangeLimit - 20, 20); - } - - dialogueId = (((int)remainder + 25) % 100) >= rangeLimit ? 201687 : 201686; - } - - addResponse(getDialogueId(dialogueId)); - applyResponse(); - return 2; - } - } - - return 1; + + return TTnpcScript::handleQuote(roomScript, sentence, val, tagId, remainder); } int BellbotScript::proc21(int v1, int v2, int v3) { diff --git a/engines/titanic/true_talk/deskbot_script.cpp b/engines/titanic/true_talk/deskbot_script.cpp index 8e92007402..a95e4dffb7 100644 --- a/engines/titanic/true_talk/deskbot_script.cpp +++ b/engines/titanic/true_talk/deskbot_script.cpp @@ -26,84 +26,6 @@ namespace Titanic { -static const TThandleQuoteEntry QUOTES[] = { - { 0x00000008, 0x00000000, 0x0003ACD0 }, - { 0x00000007, 0x00000000, 0x0003ACDC }, - { 0x00000006, 0x00000000, 0x0003ABF9 }, - { 0x00000005, 0x00000000, 0x0003AD04 }, - { 0x00000001, 0x56424144, 0x0003AE27 }, - { 0x00000001, 0x52554445, 0x0003AE27 }, - { 0x00000001, 0x5052534E, 0x00041EB3 }, - { 0x00000001, 0x464F4F44, 0x00041EB3 }, - { 0x00000001, 0x00000032, 0x00041EB1 }, - { 0x00000002, 0x56424144, 0x0003AE27 }, - { 0x00000002, 0x52554445, 0x0003AE27 }, - { 0x00000002, 0x5052534E, 0x00041EB3 }, - { 0x00000002, 0x464F4F44, 0x00041EB3 }, - { 0x00000002, 0x00000032, 0x00041EB1 }, - { 0x00000003, 0x56424144, 0x0003AE0E }, - { 0x00000003, 0x52554445, 0x0003AE0E }, - { 0x00000003, 0x5052534E, 0x00041EB3 }, - { 0x00000003, 0x464F4F44, 0x00041EB3 }, - { 0x00000003, 0x00000032, 0x00041EB1 }, - { 0x00000010, 0x54524156, 0x0003ACFE }, - { 0x00000010, 0x0000003C, 0x00041EB0 }, - { 0x00000011, 0x00000000, 0x0003ABF9 }, - { 0x00000015, 0x00000032, 0x0003AC70 }, - { 0x00000012, 0x00000042, 0x0003AC7E }, - { 0x00000013, 0x00000021, 0x0003AC70 }, - { 0x0000001D, 0x00000021, 0x0003AC09 }, - { 0x00000014, 0x00000042, 0x0003AE07 }, - { 0x0000001B, 0x00000000, 0x00041EB2 }, - { 0x0000001E, 0x00000000, 0x0003ACC1 }, - { 0x0000001F, 0x00000000, 0x0003AC3E }, - { 0x0000000C, 0x00000000, 0x0003AE4C }, - { 0x0000000D, 0x00000000, 0x0003AE4C }, - { 0x0000000E, 0x00000000, 0x0003AE4B }, - { 0x0000000F, 0x00000000, 0x0003AE4B }, - { 0x00000020, 0x00000019, 0x0003AE24 }, - { 0x00000021, 0x0000000F, 0x0003AE10 }, - { 0x0000001C, 0x00000032, 0x00041EB0 }, - { 0x00000023, 0x00000000, 0x0003AC46 }, - { 0x00000024, 0x00000000, 0x0003AE1F }, - { 0x00000025, 0x00000000, 0x0003AE14 }, - { 0x00000026, 0x00000000, 0x0003AC7B }, - { 0x00000030, 0x00000000, 0x0003AE3D }, - { 0x00000027, 0x424F5953, 0x0003AE5D }, - { 0x00000027, 0x4749524C, 0x0003AE5E }, - { 0x00000027, 0x00000000, 0x0003AE5C }, - { 0x00000028, 0x00000000, 0x0003AE5B }, - { 0x00000029, 0x00000000, 0x0003AE58 }, - { 0x0000002A, 0x00000000, 0x0003AE59 }, - { 0x0000002B, 0x00000000, 0x0003AE5A }, - { 0x0000002C, 0x00000000, 0x0003AE57 }, - { 0x0000002D, 0x00000000, 0x0003AE5C }, - { 0x0000002E, 0x424F5953, 0x0003AE5A }, - { 0x0000002E, 0x4749524C, 0x0003AE5A }, - { 0x0000002E, 0x00000000, 0x0003AE5A }, - { 0x00000032, 0x00000000, 0x0003AE0E }, - { 0x00000033, 0x00000000, 0x0003AE27 }, - { 0x00000034, 0x00000000, 0x0003AE24 }, - { 0x00000035, 0x00000000, 0x0003AE3E }, - { 0x00000037, 0x00000000, 0x0003AE26 }, - { 0x00000038, 0x00000000, 0x0003AEC0 }, - { 0x00000039, 0x00000000, 0x0003AEC1 }, - { 0x0000003A, 0x00000000, 0x0003AC7F }, - { 0x0000003B, 0x00000000, 0x0003ADD5 }, - { 0x0000003C, 0x00000000, 0x0003AEC5 }, - { 0x0000003D, 0x00000000, 0x0003AEC9 }, - { 0x0000003F, 0x00000000, 0x0003ABC5 }, - { 0x0000003E, 0x00000000, 0x0003ABC5 }, - { 0x00000040, 0x00000000, 0x0003AFB0 }, - { 0x00000041, 0x00000000, 0x0003AFDC }, - { 0x00000042, 0x00000000, 0x0003AFB5 }, - { 0x00000043, 0x00000000, 0x0003AFDD }, - { 0x00000044, 0x00000000, 0x0003AFDD }, - { 0x00000045, 0x0000000A, 0x0003AC7E }, - { 0x00000046, 0x00000000, 0x0003AF6E }, - { 0x00000000, 0x00000000, 0x00000000 } -}; - DeskbotScript::DeskbotScript(int val1, const char *charClass, int v2, const char *charName, int v3, int val2) : TTnpcScript(val1, charClass, v2, charName, v3, val2, -1, -1, -1, 0) { @@ -123,6 +45,7 @@ DeskbotScript::DeskbotScript(int val1, const char *charClass, int v2, setupSentences(); _tagMappings.load("TagMap/Deskbot"); _words.load("Words/Deskbot"); + _quotes.load("Quotes/Deskbot"); } void DeskbotScript::setupSentences() { @@ -253,50 +176,8 @@ int DeskbotScript::handleQuote(TTroomScript *roomScript, TTsentence *sentence, break; } - int loopCounter = 0; - for (const TThandleQuoteEntry *qe = QUOTES; qe->_index && loopCounter < 2; ++qe) { - if (!qe->_index) { - // End of list; start at beginning again - ++loopCounter; - qe = QUOTES; - } - - if (qe->_index == val && ( - (tagId == 0 && loopCounter == 2) || - (qe->_tagId < MKTAG('A', 'A', 'A', 'A')) || - (qe->_tagId == tagId) - )) { - uint foundTagId = qe->_tagId; - if (foundTagId > 0 && foundTagId < 100) { - if (!tagId) - foundTagId >>= 1; - if (getRandomNumber(100) < foundTagId) - return 1; - } - - uint dialogueId = qe->_dialogueId; - if (dialogueId >= 270000 && dialogueId <= 275000) { - dialogueId -= 270000; - if (dialogueId >= 3) - error("Invalid dialogue index in BarbotScript"); - const int RANDOM_LIMITS[3] = { 30, 50, 70 }; - int rangeLimit = RANDOM_LIMITS[dialogueId]; - int dialRegion = getDialRegion(0); - - if (dialRegion != 1) { - rangeLimit = MAX(rangeLimit - 20, 20); - } - - dialogueId = (((int)remainder + 25) % 100) >= rangeLimit ? 241191 : 241166; - } - - addResponse(getDialogueId(dialogueId)); - applyResponse(); - return 2; - } - } + return TTnpcScript::handleQuote(roomScript, sentence, val, tagId, remainder); - return 1; } int DeskbotScript::proc21(int v1, int v2, int v3) { diff --git a/engines/titanic/true_talk/doorbot_script.cpp b/engines/titanic/true_talk/doorbot_script.cpp index 8ae19666aa..a864141428 100644 --- a/engines/titanic/true_talk/doorbot_script.cpp +++ b/engines/titanic/true_talk/doorbot_script.cpp @@ -59,6 +59,7 @@ DoorbotScript::DoorbotScript(int val1, const char *charClass, int v2, setupSentences(); _tagMappings.load("TagMap/Doorbot"); _words.load("Words/Doorbot"); + _quotes.load("Quotes/Doorbot"); } void DoorbotScript::setupSentences() { @@ -142,7 +143,8 @@ ScriptChangedResult DoorbotScript::scriptChanged(TTscriptBase *roomScript, uint int DoorbotScript::handleQuote(TTroomScript *roomScript, TTsentence *sentence, uint val, uint tagId, uint remainder) { warning("TODO"); - return 0; + + return TTnpcScript::handleQuote(roomScript, sentence, val, tagId, remainder); } int DoorbotScript::proc21(int v1, int v2, int v3) { diff --git a/engines/titanic/true_talk/liftbot_script.cpp b/engines/titanic/true_talk/liftbot_script.cpp index 926d96f658..b6b2428de5 100644 --- a/engines/titanic/true_talk/liftbot_script.cpp +++ b/engines/titanic/true_talk/liftbot_script.cpp @@ -40,6 +40,7 @@ LiftbotScript::LiftbotScript(int val1, const char *charClass, int v2, setupSentences(); _tagMappings.load("TagMap/Liftbot"); _words.load("Words/Liftbot"); + _quotes.load("Quotes/Liftbot"); } void LiftbotScript::setupSentences() { @@ -99,7 +100,8 @@ ScriptChangedResult LiftbotScript::scriptChanged(TTscriptBase *roomScript, uint int LiftbotScript::handleQuote(TTroomScript *roomScript, TTsentence *sentence, uint val, uint tagId, uint remainder) { warning("TODO"); - return 0; + + return TTnpcScript::handleQuote(roomScript, sentence, val, tagId, remainder); } int LiftbotScript::proc21(int v1, int v2, int v3) { diff --git a/engines/titanic/true_talk/maitred_script.cpp b/engines/titanic/true_talk/maitred_script.cpp index 891c66167e..d02a2adc85 100644 --- a/engines/titanic/true_talk/maitred_script.cpp +++ b/engines/titanic/true_talk/maitred_script.cpp @@ -42,6 +42,7 @@ MaitreDScript::MaitreDScript(int val1, const char *charClass, int v2, loadResponses("Responses/MaitreD"); setupSentences(); _tagMappings.load("TagMap/MaitreD"); + _quotes.load("Quotes/MaitreD"); } void MaitreDScript::setupSentences() { @@ -76,7 +77,8 @@ ScriptChangedResult MaitreDScript::scriptChanged(TTscriptBase *roomScript, uint int MaitreDScript::handleQuote(TTroomScript *roomScript, TTsentence *sentence, uint val, uint tagId, uint remainder) { warning("TODO"); - return 0; + + return TTnpcScript::handleQuote(roomScript, sentence, val, tagId, remainder); } int MaitreDScript::proc21(int v1, int v2, int v3) { diff --git a/engines/titanic/true_talk/script_support.cpp b/engines/titanic/true_talk/script_support.cpp index 857d774f82..dd20edd23d 100644 --- a/engines/titanic/true_talk/script_support.cpp +++ b/engines/titanic/true_talk/script_support.cpp @@ -140,4 +140,26 @@ void TTwordEntries::load(const char *name) { delete r; } +/*------------------------------------------------------------------------*/ + +void TThandleQuoteEntries::load(const char *name) { + Common::SeekableReadStream *r = g_vm->_filesManager->getResource(name); + + _tag1 = r->readUint32LE(); + _tag2 = r->readUint32LE(); + _rangeStart = r->readUint32LE(); + _rangeEnd = r->readUint32LE(); + + while (r->pos() < r->size()) { + TThandleQuoteEntry qe; + qe._index = r->readUint32LE(); + qe._tagId = r->readUint32LE(); + qe._dialogueId = r->readUint32LE(); + + push_back(qe); + } + + delete r; +} + } // End of namespace Titanic diff --git a/engines/titanic/true_talk/script_support.h b/engines/titanic/true_talk/script_support.h index 50576cab85..625ae3fed3 100644 --- a/engines/titanic/true_talk/script_support.h +++ b/engines/titanic/true_talk/script_support.h @@ -129,8 +129,20 @@ struct TThandleQuoteEntry { uint _index; uint _tagId; uint _dialogueId; + + TThandleQuoteEntry() : _index(0), _tagId(0), _dialogueId(0) {} }; +class TThandleQuoteEntries : public Common::Array { +public: + uint _tag1, _tag2; + uint _rangeStart, _rangeEnd; +public: + TThandleQuoteEntries() : _tag1(0), _tag2(0), _rangeStart(0), _rangeEnd(0) {} + void load(const char *name); +}; + + } // End of namespace Titanic #endif /* TITANIC_TT_NPC_SCRIPT_H */ diff --git a/engines/titanic/true_talk/tt_npc_script.cpp b/engines/titanic/true_talk/tt_npc_script.cpp index 3fc6d0aec1..3e8564c46c 100644 --- a/engines/titanic/true_talk/tt_npc_script.cpp +++ b/engines/titanic/true_talk/tt_npc_script.cpp @@ -268,7 +268,60 @@ bool TTnpcScript::handleWord(uint id) const { int TTnpcScript::handleQuote(TTroomScript *roomScript, TTsentence *sentence, uint val, uint tagId, uint remainder) { + if (_quotes.empty()) + return 1; + + + int loopCounter = 0; + for (uint idx = 0; idx < _quotes.size() && loopCounter < 2; ++idx) { + const TThandleQuoteEntry *qe = &_quotes[idx]; + + if (!qe->_index) { + // End of list; start at beginning again + ++loopCounter; + idx = 0; + qe = &_quotes[0]; + } + + if (qe->_index == val && ( + (tagId == 0 && loopCounter == 2) || + (qe->_tagId < MKTAG('A', 'A', 'A', 'A')) || + (qe->_tagId == tagId) + )) { + uint foundTagId = qe->_tagId; + if (foundTagId > 0 && foundTagId < 100) { + if (!tagId) + foundTagId >>= 1; + if (getRandomNumber(100) < foundTagId) + return 1; + } + + uint dialogueId = qe->_dialogueId; + if (dialogueId >= _quotes._rangeStart && dialogueId <= _quotes._rangeEnd) { + dialogueId -= _quotes._rangeStart; + if (dialogueId > 3) + error("Invalid dialogue index in BarbotScript"); + + const int RANDOM_LIMITS[4] = { 30, 50, 70, 60 }; + int rangeLimit = RANDOM_LIMITS[dialogueId]; + int dialRegion = getDialRegion(0); + + if (dialRegion != 1) { + rangeLimit = MAX(rangeLimit - 20, 20); + } + + dialogueId = (((int)remainder + 25) % 100) >= rangeLimit + ? _quotes._tag1 : _quotes._tag2; + } + + addResponse(getDialogueId(dialogueId)); + applyResponse(); + return 2; + } + } + return 1; + } uint TTnpcScript::getRangeValue(uint id) { diff --git a/engines/titanic/true_talk/tt_npc_script.h b/engines/titanic/true_talk/tt_npc_script.h index bd5b759480..819de77311 100644 --- a/engines/titanic/true_talk/tt_npc_script.h +++ b/engines/titanic/true_talk/tt_npc_script.h @@ -83,6 +83,7 @@ protected: TTsentenceEntries _entries; TTtagMappings _tagMappings; TTwordEntries _words; + TThandleQuoteEntries _quotes; int _entryCount; int _field68; int _field6C; -- cgit v1.2.3