diff options
Diffstat (limited to 'engines/drascula/converse.cpp')
| -rw-r--r-- | engines/drascula/converse.cpp | 359 |
1 files changed, 179 insertions, 180 deletions
diff --git a/engines/drascula/converse.cpp b/engines/drascula/converse.cpp index 1c3831e4ca..cef1a17486 100644 --- a/engines/drascula/converse.cpp +++ b/engines/drascula/converse.cpp @@ -27,38 +27,128 @@ namespace Drascula { +void DrasculaEngine::playTalkSequence(int sequence) { + bool seen = false; + + for (int i = 0; i < _talkSequencesSize; i++) { + if (_talkSequences[i].chapter == currentChapter && + _talkSequences[i].sequence == sequence) { + seen = true; + + doTalkSequenceCommand(_talkSequences[i]); + } else if (seen) // Stop searching down the list + break; + } +} + +void DrasculaEngine::doTalkSequenceCommand(TalkSequenceCommand cmd) { + switch (cmd.commandType) { + case kPause: + pause(cmd.action); + break; + case kSetFlag: + flags[cmd.action] = 1; + break; + case kClearFlag: + flags[cmd.action] = 0; + break; + case kPickObject: + pickObject(cmd.action); + break; + case kAddObject: + addObject(cmd.action); + break; + case kBreakOut: + breakOut = 1; + break; + case kConverse: + converse(cmd.action); + break; + case kPlaceVB: + placeVonBraun(cmd.action); + break; + case kUpdateRoom: + updateRoom(); + break; + case kUpdateScreen: + updateScreen(); + break; + case kTrackProtagonist: + trackProtagonist = cmd.action; + break; + case kPlaySound: + playSound(cmd.action); + break; + case kFinishSound: + finishSound(); + break; + case kTalkerGeneral: + talk(cmd.action); + break; + case kTalkerDrunk: + talk_drunk(cmd.action); + break; + case kTalkerPianist: + talk_pianist(cmd.action); + break; + case kTalkerBJ: + talk_bj(cmd.action); + break; + case kTalkerVBNormal: + talk_vonBraun(cmd.action, kVonBraunNormal); + break; + case kTalkerVBDoor: + talk_vonBraun(cmd.action, kVonBraunDoor); + break; + case kTalkerIgorSeated: + talk_igor(cmd.action, kIgorSeated); + break; + case kTalkerWerewolf: + talk_werewolf(cmd.action); + break; + case kTalkerMus: + talk_mus(cmd.action); + break; + case kTalkerDrascula: + talk_drascula(cmd.action, 1); + break; + case kTalkerBartender0: + talk_bartender(cmd.action, 0); + break; + case kTalkerBartender1: + talk_bartender(cmd.action, 1); + break; + default: + error("doTalkSequenceCommand: Unknown command: %d", cmd.commandType); + } +} + +void DrasculaEngine::cleanupString(char *string) { + uint len = strlen(string); + for (uint h = 0; h < len; h++) + if (string[h] == (char)0xa7) + string[h] = ' '; +} + void DrasculaEngine::converse(int index) { char fileName[20]; sprintf(fileName, "op_%d.cal", index); - uint h; - int game1 = 1, game2 = 1, game3 = 1, game4 = 1; - char phrase1[78]; - char phrase2[78]; - char phrase3[87]; - char phrase4[78]; - char sound1[13]; - char sound2[13]; - char sound3[13]; - char sound4[13]; - int answer1; - int answer2; - int answer3; - int used1 = 0; - int used2 = 0; - int used3 = 0; + _arj.open(fileName); + if (!_arj.isOpen()) + error("missing data file %s", fileName); + + int size = _arj.size(); + int game1 = kDialogOptionUnselected, + game2 = kDialogOptionUnselected, + game3 = kDialogOptionUnselected; + char phrase1[78], phrase2[78], phrase3[78], phrase4[78]; + char sound1[13], sound2[13], sound3[13], sound4[13]; + int answer1, answer2, answer3; char buffer[256]; - uint len; breakOut = 0; - if (currentChapter == 5) - withoutVerb(); - - _arj.open(fileName); - if (!_arj.isOpen()) { - error("missing data file %s", fileName); - } - int size = _arj.size(); + selectVerb(0); getStringFromLine(buffer, size, phrase1); getStringFromLine(buffer, size, phrase2); @@ -75,222 +165,131 @@ void DrasculaEngine::converse(int index) { _arj.close(); if (currentChapter == 2 && !strcmp(fileName, "op_5.cal") && flags[38] == 1 && flags[33] == 1) { - strcpy(phrase3, _text[_lang][405]); + strcpy(phrase3, _text[405]); strcpy(sound3, "405.als"); answer3 = 31; } if (currentChapter == 6 && !strcmp(fileName, "op_12.cal") && flags[7] == 1) { - strcpy(phrase3, _text[_lang][273]); + strcpy(phrase3, _text[273]); strcpy(sound3, "273.als"); answer3 = 14; } if (currentChapter == 6 && !strcmp(fileName, "op_12.cal") && flags[10] == 1) { - strcpy(phrase3, _text[_lang][274]); + strcpy(phrase3, _text[274]); strcpy(sound3, "274.als"); answer3 = 15; } - len = strlen(phrase1); - for (h = 0; h < len; h++) - if (phrase1[h] == (char)0xa7) - phrase1[h] = ' '; - - len = strlen(phrase2); - for (h = 0; h < len; h++) - if (phrase2[h] == (char)0xa7) - phrase2[h] = ' '; - - len = strlen(phrase3); - for (h = 0; h < len; h++) - if (phrase3[h] == (char)0xa7) - phrase3[h] = ' '; - - len = strlen(phrase4); - for (h = 0; h < len; h++) - if (phrase4[h] == (char)0xa7) - phrase4[h] = ' '; + cleanupString(phrase1); + cleanupString(phrase2); + cleanupString(phrase3); + cleanupString(phrase4); loadPic("car.alg", backSurface); // TODO code here should limit y position for mouse in dialog menu, - // but we can't implement this due lack backend functionality + // but we can't implement this as there is lack in backend functionality // from 1(top) to 31 color_abc(kColorLightGreen); while (breakOut == 0) { updateRoom(); - if (currentChapter == 1 || currentChapter == 4 || currentChapter == 6) { - if (musicStatus() == 0 && flags[11] == 0) - playMusic(roomMusic); - } else if (currentChapter == 2) { - if (musicStatus() == 0 && flags[11] == 0 && roomMusic != 0) - playMusic(roomMusic); - } else if (currentChapter == 3 || currentChapter == 5) { - if (musicStatus() == 0) + if (musicStatus() == 0 && roomMusic != 0) { + if (currentChapter == 3 || currentChapter == 5) { playMusic(roomMusic); + } else { // chapters 1, 2, 4, 6 + if (flags[11] == 0) + playMusic(roomMusic); + } } updateEvents(); + print_abc_opc(phrase1, 2, game1); + print_abc_opc(phrase2, 10, game2); + print_abc_opc(phrase3, 18, game3); + print_abc_opc(phrase4, 26, kDialogOptionUnselected); + if (mouseY > 0 && mouseY < 9) { - if (used1 == 1 && _color != kColorWhite) + if (game1 == kDialogOptionClicked && _color != kColorWhite) color_abc(kColorWhite); - else if (used1 == 0 && _color != kColorLightGreen) + else if (game1 != kDialogOptionClicked && _color != kColorLightGreen) color_abc(kColorLightGreen); + + print_abc_opc(phrase1, 2, kDialogOptionSelected); + + if (leftMouseButton == 1) { + delay(100); + game1 = kDialogOptionClicked; + talk(phrase1, sound1); + response(answer1); + } } else if (mouseY > 8 && mouseY < 17) { - if (used2 == 1 && _color != kColorWhite) + if (game2 == kDialogOptionClicked && _color != kColorWhite) color_abc(kColorWhite); - else if (used2 == 0 && _color != kColorLightGreen) + else if (game2 != kDialogOptionClicked && _color != kColorLightGreen) color_abc(kColorLightGreen); + + print_abc_opc(phrase2, 10, kDialogOptionSelected); + + if (leftMouseButton == 1) { + delay(100); + game2 = kDialogOptionClicked; + talk(phrase2, sound2); + response(answer2); + } } else if (mouseY > 16 && mouseY < 25) { - if (used3 == 1 && _color != kColorWhite) + if (game3 == kDialogOptionClicked && _color != kColorWhite) color_abc(kColorWhite); - else if (used3 == 0 && _color != kColorLightGreen) + else if (game3 != kDialogOptionClicked && _color != kColorLightGreen) color_abc(kColorLightGreen); - } else if (_color != kColorLightGreen) - color_abc(kColorLightGreen); - if (mouseY > 0 && mouseY < 9) - game1 = 2; - else if (mouseY > 8 && mouseY < 17) - game2 = 2; - else if (mouseY > 16 && mouseY < 25) - game3 = 2; - else if (mouseY > 24 && mouseY < 33) - game4 = 2; + print_abc_opc(phrase3, 18, kDialogOptionSelected); - print_abc_opc(phrase1, 1, 2, game1); - print_abc_opc(phrase2, 1, 10, game2); - print_abc_opc(phrase3, 1, 18, game3); - print_abc_opc(phrase4, 1, 26, game4); - - updateScreen(); - - if ((leftMouseButton == 1) && (game1 == 2)) { - delay(100); - used1 = 1; - talk(phrase1, sound1); - if (currentChapter == 3) - grr(); - else - response(answer1); - } else if ((leftMouseButton == 1) && (game2 == 2)) { - delay(100); - used2 = 1; - talk(phrase2, sound2); - if (currentChapter == 3) - grr(); - else - response(answer2); - } else if ((leftMouseButton == 1) && (game3 == 2)) { - delay(100); - used3 = 1; - talk(phrase3, sound3); - if (currentChapter == 3) - grr(); - else + if (leftMouseButton == 1) { + delay(100); + game3 = kDialogOptionClicked; + talk(phrase3, sound3); response(answer3); - } else if ((leftMouseButton == 1) && (game4 == 2)) { - delay(100); - talk(phrase4, sound4); - breakOut = 1; - } + } + } else if (mouseY > 24 && mouseY < 33) { + print_abc_opc(phrase4, 26, kDialogOptionSelected); - if (leftMouseButton == 1) { - delay(100); + if (leftMouseButton == 1) { + delay(100); + talk(phrase4, sound4); + breakOut = 1; + } + } else if (_color != kColorLightGreen) color_abc(kColorLightGreen); - } - game1 = (used1 == 0) ? 1 : 3; - game2 = (used2 == 0) ? 1 : 3; - game3 = (used3 == 0) ? 1 : 3; - game4 = 1; + updateScreen(); } // while (breakOut == 0) if (currentChapter == 2) loadPic(menuBackground, backSurface); else loadPic(99, backSurface); - if (currentChapter != 5) - withoutVerb(); } void DrasculaEngine::response(int function) { - if (currentChapter == 1) { - if (function >= 10 && function <= 12) - talk_drunk(function - 9); - } else if (currentChapter == 2) { - if (function == 8) - animation_8_2(); - else if (function == 9) - animation_9_2(); - else if (function == 10) - animation_10_2(); - else if (function == 15) - animation_15_2(); - else if (function == 16) + playTalkSequence(function); + + if (currentChapter == 2) { + if (function == 16) animation_16_2(); - else if (function == 17) - animation_17_2(); - else if (function == 19) - animation_19_2(); else if (function == 20) animation_20_2(); - else if (function == 21) - animation_21_2(); else if (function == 23) animation_23_2(); - else if (function == 28) - animation_28_2(); else if (function == 29) animation_29_2(); - else if (function == 30) - animation_30_2(); else if (function == 31) animation_31_2(); - } else if (currentChapter == 4) { - if (function == 2) - animation_2_4(); - else if (function == 3) - animation_3_4(); - else if (function == 4) - animation_4_4(); - } else if (currentChapter == 5) { - if (function == 2) - animation_2_5(); - else if (function == 3) - animation_3_5(); - else if (function == 6) - animation_6_5(); - else if (function == 7) - animation_7_5(); - else if (function == 8) - animation_8_5(); - else if (function == 15) - animation_15_5(); - else if (function == 16) - animation_16_5(); - else if (function == 17) - animation_17_5(); - } else if (currentChapter == 6) { - if (function == 2) - animation_2_6(); - else if (function == 3) - animation_3_6(); - else if (function == 4) - animation_4_6(); - else if (function == 11) - animation_11_6(); - else if (function == 12) - animation_12_6(); - else if (function == 13) - animation_13_6(); - else if (function == 14) - animation_14_6(); - else if (function == 15) - animation_15_6(); + } else if (currentChapter == 3) { + grr(); } } |
