From 33d7391f4a3cd5ee457e29eef0072634cbda8922 Mon Sep 17 00:00:00 2001 From: Jaromir Wysoglad Date: Thu, 20 Jun 2019 21:21:24 +0200 Subject: SUPERNOVA: Move part 1 files to it's own directory --- engines/supernova/console.cpp | 2 +- engines/supernova/game-manager.h | 2 +- engines/supernova/module.mk | 4 +- engines/supernova/room.cpp | 2 +- engines/supernova/rooms.cpp | 4164 -------------------------------- engines/supernova/rooms.h | 486 ---- engines/supernova/screen.cpp | 2 +- engines/supernova/state.cpp | 1623 ------------- engines/supernova/state.h | 124 - engines/supernova/supernova.cpp | 2 +- engines/supernova/supernova.h | 2 +- engines/supernova/supernova1/rooms.cpp | 4164 ++++++++++++++++++++++++++++++++ engines/supernova/supernova1/rooms.h | 486 ++++ engines/supernova/supernova1/state.cpp | 1623 +++++++++++++ engines/supernova/supernova1/state.h | 124 + 15 files changed, 6405 insertions(+), 6405 deletions(-) delete mode 100644 engines/supernova/rooms.cpp delete mode 100644 engines/supernova/rooms.h delete mode 100644 engines/supernova/state.cpp delete mode 100644 engines/supernova/state.h create mode 100644 engines/supernova/supernova1/rooms.cpp create mode 100644 engines/supernova/supernova1/rooms.h create mode 100644 engines/supernova/supernova1/state.cpp create mode 100644 engines/supernova/supernova1/state.h diff --git a/engines/supernova/console.cpp b/engines/supernova/console.cpp index 9e7c15ca77..39cbf7368f 100644 --- a/engines/supernova/console.cpp +++ b/engines/supernova/console.cpp @@ -23,7 +23,7 @@ #include "gui/debugger.h" #include "supernova/supernova.h" -#include "supernova/state.h" +#include "supernova/game-manager.h" #include "supernova/console.h" namespace Supernova { diff --git a/engines/supernova/game-manager.h b/engines/supernova/game-manager.h index 585d9d2f82..26c7a9eba4 100644 --- a/engines/supernova/game-manager.h +++ b/engines/supernova/game-manager.h @@ -27,7 +27,7 @@ #include "common/rect.h" #include "common/keyboard.h" #include "common/error.h" -#include "supernova/rooms.h" +#include "supernova/room.h" #include "supernova/sound.h" namespace Supernova { diff --git a/engines/supernova/module.mk b/engines/supernova/module.mk index 3eb2259b38..2665af4848 100644 --- a/engines/supernova/module.mk +++ b/engines/supernova/module.mk @@ -6,11 +6,11 @@ MODULE_OBJS := \ graphics.o \ resman.o \ room.o \ - rooms.o \ + supernova1/rooms.o \ screen.o \ sound.o \ game-manager.o \ - state.o \ + supernova1/state.o \ supernova.o MODULE_DIRS += \ diff --git a/engines/supernova/room.cpp b/engines/supernova/room.cpp index 24e1aa567c..5ac00f1529 100644 --- a/engines/supernova/room.cpp +++ b/engines/supernova/room.cpp @@ -26,7 +26,7 @@ #include "supernova/screen.h" #include "supernova/supernova.h" -#include "supernova/state.h" +#include "supernova/game-manager.h" namespace Supernova { diff --git a/engines/supernova/rooms.cpp b/engines/supernova/rooms.cpp deleted file mode 100644 index 04d8e8df98..0000000000 --- a/engines/supernova/rooms.cpp +++ /dev/null @@ -1,4164 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -#include "common/system.h" -#include "graphics/palette.h" -#include "graphics/cursorman.h" - -#include "supernova/screen.h" -#include "supernova/supernova.h" -#include "supernova/state.h" - -namespace Supernova { - -Intro::Intro(SupernovaEngine *vm, GameManager1 *gm) { - _vm = vm; - _gm = gm; - - _fileNumber = -1; - _id = INTRO; - _shown[0] = kShownFalse; - - _objectState[0] = - Object(_id, kStringKeycard, kStringKeycardDescription, KEYCARD, - TAKE | CARRIED | COMBINABLE, 255, 255, 0, NULLROOM, 0); - _objectState[1] = - Object(_id, kStringKnife, kStringKnifeDescription, KNIFE, - TAKE | CARRIED | COMBINABLE, 255, 255, 0, NULLROOM, 0); - _objectState[2] = - Object(_id, kStringWatch, kStringDefaultDescription, WATCH, - TAKE | COMBINABLE | CARRIED, 255, 255, 8, NULLROOM, 0); - _objectState[3] = - Object(_id, kStringDiscman, kStringDiscmanDescription, DISCMAN, - TAKE | COMBINABLE, 255, 255, 0, NULLROOM, 0); - _objectState[4] = - Object(_id, kStringInventoryMoney, kStringDefaultDescription, MONEY, - TAKE | COMBINABLE, 255, 255, 0); - - _shouldExit = false; - - _introText = - _vm->getGameString(kStringIntro1) + '\0' + - _vm->getGameString(kStringIntro2) + '\0' + - _vm->getGameString(kStringIntro3) + '\0' + - _vm->getGameString(kStringIntro4) + '\0' + - _vm->getGameString(kStringIntro5) + '\0' + - _vm->getGameString(kStringIntro6) + '\0' + - _vm->getGameString(kStringIntro7) + '\0' + - _vm->getGameString(kStringIntro8) + '\0' + - _vm->getGameString(kStringIntro9) + '\0' + - _vm->getGameString(kStringIntro10) + '\0' + - _vm->getGameString(kStringIntro11) + '\0' + - _vm->getGameString(kStringIntro12) + '\0' + - _vm->getGameString(kStringIntro13) + '\0'; -} - -void Intro::onEntrance() { - _gm->_guiEnabled = false; - _vm->_allowSaveGame = false; - _vm->_allowLoadGame = false; - titleScreen(); - cutscene(); - leaveCutscene(); -} - -void Intro::titleScreen() { - // Newspaper - CursorMan.showMouse(false); - _vm->_screen->setViewportBrightness(0); - _vm->_screen->setGuiBrightness(0); - _vm->paletteBrightness(); - _vm->setCurrentImage(1); - _vm->renderImage(0); - _vm->paletteFadeIn(); - _gm->getInput(); - _vm->paletteFadeOut(); - - // Title Screen - _vm->setCurrentImage(31); - _vm->renderImage(0); - _vm->paletteFadeIn(); - _gm->wait(1); - _vm->playSound(kAudioVoiceSupernova); - while (_vm->_sound->isPlaying()) - _gm->wait(1); - titleFadeIn(); - _vm->renderText(kStringTitleVersion, 295, 190, kColorWhite44); - const Common::String& title1 = _vm->getGameString(kStringTitle1); - const Common::String& title2 = _vm->getGameString(kStringTitle2); - const Common::String& title3 = _vm->getGameString(kStringTitle3); - _vm->_screen->renderText(title1, 78 - Screen::textWidth(title1) / 2, 120, kColorLightBlue); - _vm->_screen->renderText(title2, 78 - Screen::textWidth(title2) / 2, 132, kColorWhite99); - _vm->_screen->renderText(title3, 78 - Screen::textWidth(title3) / 2, 142, kColorWhite99); - _gm->wait(1); - CursorMan.showMouse(true); - _vm->playSound(kMusicIntro); - - Marquee marquee(_vm->_screen, Marquee::kMarqueeIntro, _introText.c_str()); - while (!_vm->shouldQuit()) { - _gm->updateEvents(); - marquee.renderCharacter(); - if (_gm->_mouseClicked || _gm->_keyPressed) - break; - g_system->updateScreen(); - g_system->delayMillis(_vm->_delay); - } - _vm->playSound(kAudioVoiceYeah); - while (_vm->_sound->isPlaying()) - _gm->wait(1); - _vm->paletteFadeOut(); -} - -void Intro::titleFadeIn() { - byte titlePaletteColor[] = {0xfe, 0xeb}; - byte titleNewColor[2][3] = {{255, 255, 255}, {199, 21, 21}}; - byte newColors[2][3]; - - for (int brightness = 1; brightness <= 40; ++brightness) { - for (int colorIndex = 0; colorIndex < 2; ++colorIndex) { - for (int i = 0; i < 3; ++i) { - newColors[colorIndex][i] = (titleNewColor[colorIndex][i] * brightness) / 40; - } - } - - _vm->_system->getPaletteManager()->setPalette(newColors[0], titlePaletteColor[0], 1); - _vm->_system->getPaletteManager()->setPalette(newColors[1], titlePaletteColor[1], 1); - _vm->_system->updateScreen(); - _vm->_system->delayMillis(_vm->_delay); - } -} - -bool Intro::animate(int section1, int section2, int duration) { - Common::KeyCode key = Common::KEYCODE_INVALID; - while (duration) { - _vm->renderImage(section1); - if (_gm->waitOnInput(2, key)) - return key != Common::KEYCODE_ESCAPE; - _vm->renderImage(section2); - if (_gm->waitOnInput(2, key)) - return key != Common::KEYCODE_ESCAPE; - --duration; - } - return true; -} - -bool Intro::animate(int section1, int section2, int duration, - MessagePosition position, StringId textId) { - Common::KeyCode key = Common::KEYCODE_INVALID; - const Common::String& text = _vm->getGameString(textId); - _vm->renderMessage(text, position); - int delay = (MIN(text.size(), (uint)512) + 20) * (10 - duration) * _vm->_textSpeed / 400; - while (delay) { - if (section1) - _vm->renderImage(section1); - if (_gm->waitOnInput(2, key)) { - _vm->removeMessage(); - return key != Common::KEYCODE_ESCAPE; - } - if (section2) - _vm->renderImage(section2); - if (_gm->waitOnInput(2, key)) { - _vm->removeMessage(); - return key != Common::KEYCODE_ESCAPE; - } - --delay; - } - _vm->removeMessage(); - return true; -} - -bool Intro::animate(int section1, int section2, int section3, int section4, - int duration, MessagePosition position, StringId textId) { - Common::KeyCode key = Common::KEYCODE_INVALID; - const Common::String& text = _vm->getGameString(textId); - _vm->renderMessage(text, position); - if (duration == 0) - duration = (MIN(text.size(), (uint)512) + 20) * _vm->_textSpeed / 40; - - while(duration) { - _vm->renderImage(section1); - _vm->renderImage(section3); - if (_gm->waitOnInput(2, key)) { - _vm->removeMessage(); - return key != Common::KEYCODE_ESCAPE; - } - _vm->renderImage(section2); - _vm->renderImage(section4); - if (_gm->waitOnInput(2, key)) { - _vm->removeMessage(); - return key != Common::KEYCODE_ESCAPE; - } - duration--; - } - _vm->removeMessage(); - return true; -} - -void Intro::cutscene() { -#define exitOnEscape(X) do { \ - Common::KeyCode key = Common::KEYCODE_INVALID; \ - if ((_gm->waitOnInput(X, key) && key == Common::KEYCODE_ESCAPE) || _vm->shouldQuit()) { \ - CursorMan.showMouse(true); \ - return; \ - } \ -} while (0); - - _vm->_system->fillScreen(kColorBlack); - _vm->setCurrentImage(31); - _vm->_screen->setGuiBrightness(255); - _vm->paletteBrightness(); - if (!animate(0, 0, 0, kMessageNormal, kStringIntroCutscene1)) - return; - _vm->_screen->setGuiBrightness(0); - _vm->paletteBrightness(); - exitOnEscape(1); - - _vm->setCurrentImage(9); - _vm->renderImage(0); - _vm->renderImage(1); - _vm->renderImage(9); - _vm->paletteFadeIn(); - if (!animate(11, 10, 6, kMessageRight, kStringIntroCutscene2)) - return; - _vm->renderImage(3); - exitOnEscape(4); - _vm->renderImage(4); - if (!animate(11, 10, 3)) {// test duration - _vm->removeMessage(); - return; - } - _vm->removeMessage(); - if (!animate(5, 4, 0, kMessageLeft, kStringIntroCutscene3)) - return; - _vm->renderImage(3); - exitOnEscape(3); - _vm->renderImage(2); - exitOnEscape(3); - _vm->renderImage(7); - exitOnEscape(6); - _vm->renderImage(6); - exitOnEscape(6); - if (!animate(0, 0, 0, kMessageLeft, kStringIntroCutscene4)) - return; - _vm->renderMessage(kStringIntroCutscene5, kMessageLeft); - exitOnEscape(28); - _vm->removeMessage(); - _vm->renderMessage(kStringIntroCutscene6, kMessageLeft); - exitOnEscape(28); - _vm->removeMessage(); - - StringId textCounting[4] = - {kStringIntroCutscene7, kStringIntroCutscene8, kStringIntroCutscene9, kStringIntroCutscene10}; - _vm->setCurrentImage(31); - _vm->renderImage(0); - _vm->paletteBrightness(); - for (int i = 0; i < 4; ++i){ - _vm->renderMessage(textCounting[i], kMessageLeft); - for (int j = 0; j < 28; ++j) { - _vm->renderImage((j % 3) + 1); - Common::KeyCode key = Common::KEYCODE_INVALID; - if (_gm->waitOnInput(1, key)) { - if (key == Common::KEYCODE_ESCAPE) - return; - break; - } - } - _vm->removeMessage(); - } - _vm->renderMessage(kStringIntroCutscene11, kMessageLeft); - _vm->renderImage(6); - exitOnEscape(3); - _vm->renderImage(3); - exitOnEscape(3); - _vm->renderImage(4); - exitOnEscape(3); - _vm->renderImage(5); - exitOnEscape(3); - _vm->renderImage(_gm->invertSection(5)); - exitOnEscape(18); - _vm->removeMessage(); - - _vm->setCurrentImage(9); - _vm->renderImage(0); - _vm->renderImage(1); - _vm->renderImage(9); - _vm->paletteBrightness(); - _vm->renderBox(0, 138, 320, 62, kColorBlack); - _vm->paletteBrightness(); - if (!animate(11, 10, 0, kMessageRight, kStringIntroCutscene12)) - return; - _vm->renderImage(3); - exitOnEscape(3); - _vm->renderImage(4); - if (!animate(5, 4, 0, kMessageLeft, kStringIntroCutscene13)) - return; - if (!animate(0, 0, 0, kMessageCenter, kStringIntroCutscene14)) - return; - _vm->renderImage(12); - exitOnEscape(2); - _vm->renderImage(13); - exitOnEscape(2); - _vm->renderImage(14); - if (!animate(19, 20, 0, kMessageRight, kStringIntroCutscene15)) - return; - if (!animate(0, 0, 0, kMessageCenter, kStringIntroCutscene16)) - return; - exitOnEscape(20); - if (!animate(0, 0, 0, kMessageCenter, kStringIntroCutscene17)) - return; - if (!animate(19, 20, 0, kMessageRight, kStringIntroCutscene18)) - return; - if (!animate(0, 0, 0, kMessageCenter, kStringIntroCutscene19)) - return; - _vm->renderImage(16); - exitOnEscape(3); - _vm->renderImage(17); - if (!animate(19, 20, 18, 17, 0, kMessageRight, kStringIntroCutscene20)) - return; - if (!animate(19, 20, 18, 17, 0, kMessageRight, kStringIntroCutscene21)) - return; - if (!animate(5, 4, 0, kMessageLeft, kStringIntroCutscene3)) - return; - _vm->renderImage(3); - exitOnEscape(3); - _vm->renderImage(2); - exitOnEscape(3); - _vm->renderImage(8); - exitOnEscape(6); - _vm->renderImage(6); - _vm->playSound(kAudioSiren); - - exitOnEscape(6); - _vm->renderImage(3); - exitOnEscape(3); - _vm->renderImage(4); - _vm->renderImage(16); - exitOnEscape(3); - _vm->renderImage(15); - if (!animate(19, 20, 0, kMessageRight, kStringIntroCutscene22)) - return; - if (!animate(19, 20, 0, kMessageRight, kStringIntroCutscene23)) - return; - exitOnEscape(10); - _vm->renderImage(13); - exitOnEscape(2); - _vm->renderImage(12); - exitOnEscape(2); - _vm->renderImage(9); - if (!animate(11, 10, 0, kMessageRight, kStringIntroCutscene24)) - return; - if (!animate(5, 4, 0, kMessageLeft, kStringIntroCutscene3)) - return; - _vm->paletteFadeOut(); - - while (_vm->_sound->isPlaying()) - exitOnEscape(1); - - _vm->_system->fillScreen(kColorBlack); - _vm->_screen->setGuiBrightness(255); - _vm->paletteBrightness(); - if (!animate(0, 0, 0, kMessageNormal, kStringIntroCutscene25)) - return; - _vm->_screen->setGuiBrightness(5); - _vm->paletteBrightness(); - - _vm->setCurrentImage(31); - _vm->renderImage(0); - _vm->paletteFadeIn(); - if (!animate(0, 0, 0, kMessageNormal, kStringIntroCutscene26)) - return; - if (!animate(0, 0, 0, kMessageNormal, kStringIntroCutscene27)) - return; - if (!animate(0, 0, 0, kMessageNormal, kStringIntroCutscene28)) - return; - if (!animate(0, 0, 0, kMessageNormal, kStringIntroCutscene29)) - return; - exitOnEscape(54); - if (!animate(0, 0, 0, kMessageNormal, kStringIntroCutscene30)) - return; - if (!animate(0, 0, 0, kMessageNormal, kStringIntroCutscene31)) - return; - if (!animate(0, 0, 0, kMessageNormal, kStringIntroCutscene32)) - return; - - CursorMan.showMouse(false); - _vm->_screen->setViewportBrightness(0); - _vm->paletteBrightness(); - exitOnEscape(10); - _vm->playSound(kAudioSnoring); - while (_vm->_sound->isPlaying()) - _gm->wait(1); - exitOnEscape(10); - _vm->playSound(kAudioSnoring); - while (_vm->_sound->isPlaying()) - _gm->wait(1); - exitOnEscape(10); - _vm->playSound(kAudioSnoring); - while (_vm->_sound->isPlaying()) - _gm->wait(1); - exitOnEscape(30); - CursorMan.showMouse(true); - - _vm->setCurrentImage(22); - if (!animate(0, 0, 0, kMessageNormal, kStringIntroCutscene33)) - return; - exitOnEscape(18); - if (!animate(0, 0, 0, kMessageNormal, kStringIntroCutscene34)) - return; - if (!animate(0, 0, 0, kMessageNormal, kStringIntroCutscene35)) - return; - if (!animate(0, 0, 0, kMessageNormal, kStringIntroCutscene36)) - return; - if (!animate(0, 0, 0, kMessageNormal, kStringIntroCutscene37)) - return; - exitOnEscape(18); - if (!animate(0, 0, 0, kMessageNormal, kStringIntroCutscene38)) - return; - if (!animate(0, 0, 0, kMessageNormal, kStringIntroCutscene39)) - return; - exitOnEscape(18); - if (!animate(0, 0, 0, kMessageNormal, kStringIntroCutscene40)) - return; - if (!animate(0, 0, 0, kMessageNormal, kStringIntroCutscene41)) - return; - exitOnEscape(36); - animate(0, 0, 0, kMessageNormal, kStringIntroCutscene42); - _vm->removeMessage(); - -#undef exitOnEscape -} - -void Intro::leaveCutscene() { - _vm->_screen->setViewportBrightness(255); - _vm->removeMessage(); - _gm->changeRoom(CABIN_R3); - _gm->_guiEnabled = true; - _vm->_allowSaveGame = true; - _vm->_allowLoadGame = true; -} - -ShipCorridor::ShipCorridor(SupernovaEngine *vm, GameManager1 *gm) { - _vm = vm; - _gm = gm; - - _fileNumber = 17; - _id = CORRIDOR; - _shown[0] = kShownTrue; - _shown[4] = kShownTrue; - - _objectState[0] = Object(_id, kStringHatch, kStringDefaultDescription, HATCH1, OPENABLE | EXIT, 0, 6, 1, CABIN_L1, 15); - _objectState[1] = Object(_id, kStringHatch, kStringDefaultDescription, NULLOBJECT, OPENABLE | EXIT, 1, 7, 2, CABIN_L2, 10); - _objectState[2] = Object(_id, kStringHatch, kStringDefaultDescription, NULLOBJECT, OPENABLE | EXIT, 2, 8, 3, CABIN_L3, 5); - _objectState[3] = Object(_id, kStringHatch, kStringDefaultDescription, NULLOBJECT, OPENABLE | EXIT, 5, 11, 6, CABIN_R1, 19); - _objectState[4] = Object(_id, kStringHatch, kStringDefaultDescription, NULLOBJECT, OPENABLE | EXIT, 4, 10, 5, CABIN_R2, 14); - _objectState[5] = Object(_id, kStringHatch, kStringDefaultDescription, NULLOBJECT, OPENABLE | EXIT | OPENED, 9, 3, 4, CABIN_R3, 9); - _objectState[6] = Object(_id, kStringHatch, kStringDefaultDescription, NULLOBJECT, OPENABLE | CLOSED | EXIT, 12, 12, 0, AIRLOCK, 2); - _objectState[7] = Object(_id, kStringButton, kStringHatchButtonDescription, BUTTON, PRESS, 13, 13, 0, NULLROOM, 0); - _objectState[8] = Object(_id, kStringLadder, kStringDefaultDescription, NULLOBJECT, NULLTYPE, 14, 14, 0, NULLROOM, 0); - _objectState[9] = Object(_id, kStringExit, kStringDefaultDescription, NULLOBJECT, EXIT, 15, 15, 0, HALL, 22); -} - -bool ShipCorridor::interact(Action verb, Object &obj1, Object &obj2) { - if ((verb == ACTION_PRESS) && (obj1._id == BUTTON)) { - if (_objectState[6].hasProperty(OPENED)) { - _vm->playSound(kAudioSlideDoor); - _objectState[6].disableProperty(OPENED); - _vm->renderImage(8); - setSectionVisible(9, false); - _gm->wait(2); - _vm->renderImage(7); - setSectionVisible(8, false); - _gm->wait(2); - _vm->renderImage(_gm->invertSection(7)); - } else { - _vm->playSound(kAudioSlideDoor); - _objectState[6].setProperty(OPENED); - _vm->renderImage(7); - _gm->wait(2); - _vm->renderImage(8); - setSectionVisible(7, false); - _gm->wait(2); - _vm->renderImage(9); - setSectionVisible(8, false); - } - return true; - } - return false; -} - -ShipHall::ShipHall(SupernovaEngine *vm, GameManager1 *gm) { - _vm = vm; - _gm = gm; - - _fileNumber = 15; - _id = HALL; - _shown[0] = kShownTrue; - - _objectState[0] = Object(_id, kStringHatch, kStringCockpitHatchDescription, NULLOBJECT, OPENABLE | EXIT, 4, 5, 1, COCKPIT, 10); - _objectState[1] = Object(_id, kStringHatch, kStringKitchenHatchDescription, KITCHEN_HATCH, OPENABLE | EXIT, 0, 0, 0, NULLROOM, 1); - _objectState[2] = Object(_id, kStringHatch, kStringStasisHatchDescription, NULLOBJECT, OPENABLE | CLOSED | EXIT, 1, 1, 2, SLEEP, 8); - _objectState[3] = Object(_id, kStringSlot, kStringSlotDescription, SLEEP_SLOT, COMBINABLE, 2, 2, 0, NULLROOM, 0); - _objectState[4] = Object(_id, kStringLadder, kStringDefaultDescription, NULLOBJECT, NULLTYPE, 3, SLEEP, 0, NULLROOM, 0); - _objectState[5] = Object(_id, kStringCorridor, kStringDefaultDescription, NULLOBJECT, EXIT, 6, 6, 0, CORRIDOR, 19); -} - -bool ShipHall::interact(Action verb, Object &obj1, Object &obj2) { - if ((verb == ACTION_OPEN) && (obj1._id == KITCHEN_HATCH)) { - _vm->renderMessage(kStringShipHall1); - } else if ((verb == ACTION_USE) && Object::combine(obj1,obj2,KEYCARD2,SLEEP_SLOT)) { - if (_objectState[2].hasProperty(OPENED)) { - _objectState[2].disableProperty(OPENED); - _vm->renderImage(3); - setSectionVisible(4, false); - _gm->wait(2); - _vm->renderImage(2); - setSectionVisible(3, false); - _gm->wait(2); - _vm->renderImage(_gm->invertSection(2)); - } else { - _objectState[2].setProperty(OPENED); - _vm->renderImage(2); - _gm->wait(2); - _vm->renderImage(3); - setSectionVisible(2, false); - _gm->wait(2); - _vm->renderImage(4); - setSectionVisible(3, false); - _gm->great(1); - } - } else { - return false; - } - - return true; -} - -ShipSleepCabin::ShipSleepCabin(SupernovaEngine *vm, GameManager1 *gm) { - _vm = vm; - _gm = gm; - - _fileNumber = 33; - _id = SLEEP; - _shown[0] = kShownTrue; - _color = kColorBlack; - - _objectState[0] = Object(_id, kStringHatch, kStringStasisHatchDescription2, CABINS, NULLTYPE, 0, 0, 0, NULLROOM, 0); - _objectState[1] = Object(_id, kStringHatch, kStringStasisHatchDescription2, CABIN, NULLTYPE, 1, 1, 0, NULLROOM, 0); - _objectState[2] = Object(_id, kStringComputer, kStringDefaultDescription, COMPUTER, NULLTYPE, 2, 2, 0, NULLROOM, 0); - _objectState[3] = Object(_id, kStringExit, kStringDefaultDescription, NULLOBJECT, EXIT, 255, 255, 0, HALL, 22); -} - -bool ShipSleepCabin::interact(Action verb, Object &obj1, Object &obj2) { - Room *room; - Common::String input; - - if (((verb == ACTION_LOOK) || (verb == ACTION_USE)) && (obj1._id == COMPUTER)) { - _gm->_guiEnabled = false; - setSectionVisible(4, false); - g_system->fillScreen(kColorDarkBlue); - if (_gm->_state._arrivalDaysLeft == 0) { - // Destination reached - _vm->renderText(kStringShipSleepCabin1, 60, 95, kColorWhite99); - _gm->getInput(); - } else if (_gm->_state._powerOff) { - // Energy depleted - _vm->renderText(kStringShipSleepCabin2, 60, 95, kColorWhite99); - // Artificial coma interrupted - _vm->renderText(kStringShipSleepCabin3, 60, 115, kColorWhite99); - _gm->getInput(); - } else if (isSectionVisible(5)) { - // Sleep duration in days - _vm->renderText(kStringShipSleepCabin4, 30, 85, kColorWhite99); - _vm->renderText(Common::String::format("%d",_gm->_state._timeSleep).c_str(), - 150, 85, kColorWhite99); - _vm->renderText(kStringShipSleepCabin5, 30, 105, kColorWhite99); - _gm->getInput(); - } else { - _vm->renderText(kStringShipSleepCabin6, 100, 85, kColorWhite99); - _gm->edit(input, 100, 105, 30); - - input.toUppercase(); - if (_gm->_key.keycode != Common::KEYCODE_ESCAPE) { - if (input == _vm->getGameString(kStringComputerPassword)) { - _gm->great(6); - g_system->fillScreen(kColorDarkBlue); - _vm->renderText(kStringShipSleepCabin7, 30, 85, kColorWhite99); - uint daysSleep = 0; - do { - input.clear(); - _vm->renderBox(150, 85, 150, 8, kColorDarkBlue); - _gm->edit(input, 150, 85, 10); - - if (_gm->_key.keycode == Common::KEYCODE_ESCAPE) { - break; - } else { - daysSleep = input.asUint64(); - for (uint i = 0; i < input.size(); i++) { - if (!Common::isDigit(input[i])) { - daysSleep = 0; - break; - } - } - } - if (daysSleep != 0) { - _gm->_state._timeSleep = daysSleep; - _vm->renderText(kStringShipSleepCabin8, 30, 105, kColorWhite99); - _gm->wait(18); - setSectionVisible(5, true); - } - } while (daysSleep == 0); - } else { - _vm->renderText(kStringShipSleepCabin9, 100, 125, kColorLightRed); - _gm->wait(18); - } - } - } - - _gm->_guiEnabled = true; - input.clear(); - } else if (((verb == ACTION_WALK) || (verb == ACTION_USE)) && - ((obj1._id == CABINS) || (obj1._id == CABIN))) { - room = _gm->_rooms[AIRLOCK]; - if (!(obj1._id == CABIN) || !isSectionVisible(5)) { - _vm->renderMessage(kStringShipSleepCabin10); - } else if (room->getObject(5)->hasProperty(WORN)) { - _vm->renderMessage(kStringShipSleepCabin11); - } else { - _vm->paletteFadeOut(); - _vm->renderImage(_gm->invertSection(5)); - _vm->renderImage(_gm->invertSection(4)); - room = _gm->_rooms[GENERATOR]; - int32 *energyDaysLeft; - if (room->isSectionVisible(9)) { - energyDaysLeft = &_gm->_state._landingModuleEnergyDaysLeft; - } else { - energyDaysLeft = &_gm->_state._shipEnergyDaysLeft; - } - if (_gm->_state._timeSleep > _gm->_state._arrivalDaysLeft) { - _gm->_state._timeSleep = _gm->_state._arrivalDaysLeft; - } - if (_gm->_state._timeSleep >= *energyDaysLeft) { - _gm->_state._timeSleep = *energyDaysLeft; - if (room->isSectionVisible(9)) { - room = _gm->_rooms[LANDINGMODULE]; // Monitors off - room->setSectionVisible(2, false); - room->setSectionVisible(7, false); - room->setSectionVisible(8, false); - room->setSectionVisible(9, false); - room->setSectionVisible(10, false); - } - } - if (_gm->_state._timeSleep == _gm->_state._arrivalDaysLeft) { - _vm->renderImage(3); - room = _gm->_rooms[COCKPIT]; - room->setSectionVisible(23, true); - room = _gm->_rooms[CABIN_R2]; - room->setSectionVisible(5, false); - room->setSectionVisible(6, true); - room->getObject(2)->_click = 10; - room = _gm->_rooms[HOLD]; - room->setSectionVisible(0, false); - room->setSectionVisible(1, true); - room->getObject(1)->_click = 255; - room->getObject(3)->_click = 255; - room = _gm->_rooms[GENERATOR]; - room->setSectionVisible(6, false); - room->setSectionVisible(7, true); - room->getObject(1)->_click = 14; - if (room->isSectionVisible(1)) { - room->setSectionVisible(10, true); - } - if (room->isSectionVisible(12)) { - room->setSectionVisible(12, false); - room->setSectionVisible(11, true); - } - } - _gm->_state._arrivalDaysLeft -= _gm->_state._timeSleep; - *energyDaysLeft -= _gm->_state._timeSleep; - _gm->_time = ticksToMsec(786520); // 12pm - _gm->_state._alarmOn = (_gm->_state._timeAlarm > _gm->_time); - if (*energyDaysLeft == 0) { - _gm->turnOff(); - room = _gm->_rooms[GENERATOR]; - room->setSectionVisible(4, room->isSectionVisible(2)); - } - if (_gm->_state._arrivalDaysLeft == 0) { - _gm->saveTime(); - if (!_vm->saveGame(kSleepAutosaveSlot, "Sleep autosave")) - _vm->errorTempSave(true); - _gm->_state._dream = true; - _gm->loadTime(); - } - _gm->wait(18); - _vm->paletteFadeIn(); - if (_gm->_state._arrivalDaysLeft == 0) { - _vm->playSound(kAudioCrash); - _gm->screenShake(); - _gm->wait(18); - _vm->renderMessage(kStringShipSleepCabin12); - } - } - } else { - return false; - } - - return true; -} - -void ShipSleepCabin::animation() { - if (_gm->_state._powerOff && _gm->_state._arrivalDaysLeft) { - if (_gm->_guiEnabled) { - if (isSectionVisible(1)) { - _vm->renderImage(2); - setSectionVisible(1, false); - } else { - _vm->renderImage(1); - setSectionVisible(2, false); - } - } else { - if (_color == kColorLightRed) { - _color = kColorDarkBlue; - } else { - _color = kColorLightRed; - } - - _vm->renderText(kStringShipSleepCabin13, 60, 75, _color); - } - } else if (isSectionVisible(5) && _gm->_guiEnabled) { - if (isSectionVisible(4)) - _vm->renderImage(_gm->invertSection(4)); - else - _vm->renderImage(4); - } - - _gm->setAnimationTimer(6); -} -void ShipSleepCabin::onEntrance() { - if (_gm->_state._dream && (_gm->_rooms[CAVE]->getObject(1)->_exitRoom == MEETUP3)) { - _vm->renderMessage(kStringShipSleepCabin14); - _gm->waitOnInput(_gm->_messageDuration); - _vm->removeMessage(); - _vm->renderMessage(kStringShipSleepCabin15); - _gm->waitOnInput(_gm->_messageDuration); - _vm->removeMessage(); - _vm->renderMessage(kStringShipSleepCabin16); - _gm->_state._dream = false; - } -} - -ShipCockpit::ShipCockpit(SupernovaEngine *vm, GameManager1 *gm) { - _vm = vm; - _gm = gm; - - _fileNumber = 9; - _id = COCKPIT; - _shown[0] = kShownTrue; - _color = kColorBlack; - - _objectState[0] = Object(_id, kStringInstruments, kStringInstrumentsDescription1, INSTRUMENTS, NULLTYPE, 2, 2, 0, NULLROOM, 0); - _objectState[1] = Object(_id, kStringMonitor, kStringDefaultDescription, MONITOR, NULLTYPE, 0, 0, 0, NULLROOM, 0); - _objectState[2] = Object(_id, kStringMonitor, kStringMonitorDescription, NULLOBJECT, TAKE, 1, 0, 0, NULLROOM, 0); - _objectState[3] = Object(_id, kStringExit, kStringDefaultDescription, NULLOBJECT, EXIT, 255, 255, 0, HALL, 22); -} - -bool ShipCockpit::interact(Action verb, Object &obj1, Object &obj2) { - // TODO: distance and remaining time not accurate - - if ((verb == ACTION_LOOK) && (obj1._id == MONITOR)) { - char c[2] = {0, 0}; - _gm->_guiEnabled = false; - _vm->renderBox(0, 0, 320, 200, kColorBlack); - _vm->renderText(kStringShipCockpit1, 50, 50, kColorLightYellow); - if (_gm->_state._arrivalDaysLeft) - _vm->renderText(kStringShipCockpit2); - else - _vm->renderText(kStringShipCockpit3); - _vm->renderText(kStringShipCockpit4, 50, 70, kColorLightYellow); - _vm->renderText(kStringShipCockpit5, 50, 90, kColorLightYellow); - _vm->renderText(Common::String::format("%d", _gm->_state._arrivalDaysLeft / 400).c_str()); - _vm->renderText(","); - c[0] = (_gm->_state._arrivalDaysLeft / 40) % 10 + '0'; - _vm->renderText(c); - c[0] = (_gm->_state._arrivalDaysLeft / 4) % 10 + '0'; - _vm->renderText(c); - _vm->renderText(kStringShipCockpit6); - _vm->renderText(kStringShipCockpit7, 50, 110, kColorLightYellow); - _vm->renderText(Common::String::format("%d", _gm->_state._arrivalDaysLeft).c_str(), - 50, 120, kColorLightYellow); - _vm->renderText(kStringShipCockpit8); - - _gm->getInput(); - _gm->_guiEnabled = true; - } else if ((verb == ACTION_USE) && (obj1._id == INSTRUMENTS)) - _vm->renderMessage(kStringShipCockpit9); - else - return false; - - return true; -} -void ShipCockpit::animation() { - if (!_gm->_guiEnabled) { - if (_color) { - _color = kColorBlack; - _gm->setAnimationTimer(5); - } else { - _color = kColorLightYellow; - _gm->setAnimationTimer(10); - } - _vm->renderText(kStringShipCockpit10, 50, 145, _color); - } else if (isSectionVisible(21)) { - _vm->renderImage(_gm->invertSection(21)); - _gm->setAnimationTimer(5); - } else { - _vm->renderImage(21); - _gm->setAnimationTimer(10); - } - - if (_gm->_state._powerOff) { - if (!_gm->_guiEnabled) { - _vm->renderText(kStringShipCockpit11, 97, 165, _color); - _vm->renderText(kStringShipCockpit12, 97, 175, _color); - } else if (isSectionVisible(21)) - _vm->renderImage(22); - else - _vm->renderImage(_gm->invertSection(22)); - } -} - -void ShipCockpit::onEntrance() { - if (!hasSeen()) - _vm->renderMessage(kStringShipCockpit13); - setRoomSeen(true); -} - -ShipCabinL1::ShipCabinL1(SupernovaEngine *vm, GameManager1 *gm) { - _vm = vm; - _gm = gm; - - _fileNumber = 21; - _id = CABIN_L1; - _shown[0] = kShownTrue; - _shown[1] = kShownTrue; - _shown[2] = kShownTrue; - _shown[3] = kShownTrue; - _shown[4] = kShownTrue; - _shown[5] = kShownTrue; - - _objectState[0] = Object(_id, kStringImage, kStringGenericDescription1, NULLOBJECT, UNNECESSARY, 5, 5, 0, NULLROOM, 0); - _objectState[1] = Object(_id, kStringImage, kStringGenericDescription2, NULLOBJECT, UNNECESSARY, 6, 6, 0, NULLROOM, 0); - _objectState[2] = Object(_id, kStringImage, kStringGenericDescription3, NULLOBJECT, UNNECESSARY, 7, 7, 0, NULLROOM, 0); - _objectState[3] = Object(_id, kStringMagnete, kStringMagneteDescription, NULLOBJECT, UNNECESSARY, 8, 8, 0, NULLROOM, 0); - _objectState[4] = Object(_id, kStringImage, kStringGenericDescription4, NULLOBJECT, UNNECESSARY, 9, 9, 0); - _objectState[5] = Object(_id, kStringPen, kStringPenDescription, PEN, TAKE | COMBINABLE, 10, 10, 5 | 128); - _objectState[6] = Object(_id, kStringHatch, kStringDefaultDescription, NULLOBJECT, OPENABLE | OPENED | EXIT, 3, 3, 24 | 128, CORRIDOR, 9); - _objectState[7] = Object(_id, kStringSlot, kStringSlotDescription, NULLOBJECT, COMBINABLE, 0, 0, 0); - _objectState[8] = Object(_id, kStringShelf, kStringDefaultDescription, NULLOBJECT, OPENABLE | CLOSED, 1, 1, 0); - _objectState[9] = Object(_id, kStringCompartment, kStringDefaultDescription, NULLOBJECT, OPENABLE | CLOSED, 2, 2, 0); - _objectState[10] = Object(_id, kStringSocket, kStringDefaultDescription, SOCKET, COMBINABLE, 4, 4, 0); - _objectState[11] = Object(_id, kStringToilet, kStringDefaultDescription, BATHROOM_DOOR, EXIT, 255, 255, 0, BATHROOM, 22); -} - -ShipCabinL2::ShipCabinL2(SupernovaEngine *vm, GameManager1 *gm) { - _vm = vm; - _gm = gm; - - _fileNumber = 21; - _id = CABIN_L2; - _shown[0] = kShownTrue; - _shown[16] = kShownTrue; - - _objectState[0] = Object(_id, kStringSlot,kStringSlotDescription,SLOT_KL1,COMBINABLE,31,31,0); - _objectState[1] = Object(_id, kStringSlot,kStringSlotDescription,SLOT_KL2,COMBINABLE,32,32,0); - _objectState[2] = Object(_id, kStringSlot,kStringSlotDescription,SLOT_KL3,COMBINABLE,33,33,0); - _objectState[3] = Object(_id, kStringSlot,kStringSlotDescription,SLOT_KL4,COMBINABLE,45,45,0); - _objectState[4] = Object(_id, kStringShelf,kStringDefaultDescription,SHELF_L1,OPENABLE | CLOSED,25,26,17); - _objectState[5] = Object(_id, kStringPistol,kStringPistolDescription,PISTOL,TAKE,39,39,20); - _objectState[6] = Object(_id, kStringCompartment,kStringDefaultDescription,SHELF_L2,OPENABLE | CLOSED,27,28,18); - _objectState[7] = Object(_id, kStringBooks,kStringBooksDescription,NULLOBJECT,UNNECESSARY,40,40,0); - _objectState[8] = Object(_id, kStringCompartment,kStringDefaultDescription,SHELF_L3,OPENABLE | CLOSED,29,30,19); - _objectState[9] = Object(_id, kStringSpool,kStringSpoolDescription, SPOOL,TAKE | COMBINABLE,41,41,21); - _objectState[10] = Object(_id, kStringCompartment,kStringDefaultDescription,SHELF_L4,OPENABLE | CLOSED,43,44,22); - _objectState[11] = Object(_id, kStringBook,kStringDefaultDescription,BOOK2,TAKE,46,46,23); - _objectState[12] = Object(_id, kStringUnderwear,kStringUnderwearDescription,NULLOBJECT,UNNECESSARY,34,34,0); - _objectState[13] = Object(_id, kStringUnderwear,kStringUnderwearDescription,NULLOBJECT,UNNECESSARY,35,35,0); - _objectState[14] = Object(_id, kStringClothes,kStringDefaultDescription,NULLOBJECT,UNNECESSARY,36,36,0); - _objectState[15] = Object(_id, kStringJunk,kStringJunkDescription,NULLOBJECT,UNNECESSARY,37,37,0); - _objectState[16] = Object(_id, kStringJunk,kStringJunkDescription,NULLOBJECT,UNNECESSARY,38,38,0); - _objectState[17] = Object(_id, kStringMagnete,kStringMagneteDescription,NULLOBJECT,UNNECESSARY,23,23,0); - _objectState[18] = Object(_id, kStringToilet,kStringDefaultDescription,BATHROOM_DOOR,EXIT,255,255,0,BATHROOM,22); - _objectState[19] = Object(_id, kStringHatch,kStringDefaultDescription,NULLOBJECT,OPENABLE | OPENED | EXIT,3,3,24 | 128,CORRIDOR,9); - _objectState[20] = Object(_id, kStringSlot,kStringSlotDescription,NULLOBJECT,COMBINABLE,0,0,0); - _objectState[21] = Object(_id, kStringShelf,kStringDefaultDescription,NULLOBJECT,OPENABLE | CLOSED,1,1,0); - _objectState[22] = Object(_id, kStringCompartment,kStringDefaultDescription,NULLOBJECT,OPENABLE | CLOSED,2,2,0); - _objectState[23] = Object(_id, kStringSocket,kStringDefaultDescription,SOCKET,COMBINABLE,4,4,0); - _objectState[24] = Object(_id, kStringFolders,kStringFoldersDescription,NULLOBJECT,UNNECESSARY,49,49,0); -} - -bool ShipCabinL2::interact(Action verb, Object &obj1, Object &obj2) { - if ((verb == ACTION_USE) && Object::combine(obj1, obj2, SLOT_KL1, KEYCARD2)) { - _gm->openLocker(this, getObject(4), getObject(0), 17); - if (getObject(5)->_click == 255) - _vm->renderImage(20); // Remove Pistol - _gm->great(2); - } else if ((verb == ACTION_USE) && Object::combine(obj1, obj2, SLOT_KL2, KEYCARD2)) { - _gm->openLocker(this, getObject(6), getObject(1), 18); - _gm->great(2); - } else if ((verb == ACTION_USE) && Object::combine(obj1, obj2, SLOT_KL3, KEYCARD2)) { - _gm->openLocker(this, getObject(8), getObject(2), 19); - if (getObject(9)->_click == 255) - _vm->renderImage(21); // Remove cable spool - _gm->great(2); - } else if ((verb == ACTION_USE) && Object::combine(obj1, obj2, SLOT_KL4, KEYCARD2)) { - _gm->openLocker(this, getObject(10), getObject(3), 22); - if (getObject(11)->_click == 255) - _vm->renderImage(23); // Remove book - _gm->great(2); - } else if ((verb == ACTION_CLOSE) && (obj1._id == SHELF_L1)) { - _gm->closeLocker(this, getObject(4), getObject(0), 17); - setSectionVisible(20, false); - } else if ((verb == ACTION_CLOSE) && (obj1._id == SHELF_L2)) - _gm->closeLocker(this, getObject(6), getObject(1), 18); - else if ((verb == ACTION_CLOSE) && (obj1._id == SHELF_L3)) { - _gm->closeLocker(this, getObject(8), getObject(2), 19); - setSectionVisible(21, false); - } else if ((verb == ACTION_CLOSE) && (obj1._id == SHELF_L4)) { - _gm->closeLocker(this, getObject(10), getObject(3), 22); - setSectionVisible(23, false); - } else if ((verb == ACTION_TAKE) && (obj1._id == SPOOL) && !obj1.hasProperty(CARRIED)) { - getObject(8)->_click = 42; // empty shelf - return false; - } else if ((verb == ACTION_TAKE) && (obj1._id == BOOK2) && !obj1.hasProperty(CARRIED)) { - getObject(10)->_click = 47; // empty shelf - return false; - } else - return false; - - return true; -} - -ShipCabinL3::ShipCabinL3(SupernovaEngine *vm, GameManager1 *gm) { - _vm = vm; - _gm = gm; - - _fileNumber = 21; - _id = CABIN_L3; - _shown[0] = kShownTrue; - _shown[6] = kShownTrue; - _shown[7] = kShownTrue; - _shown[8] = kShownTrue; - _shown[9] = kShownTrue; - _shown[12] = kShownTrue; - - _objectState[0] = Object(_id, kStringPoster,kStringPosterDescription1,NULLOBJECT,UNNECESSARY,11,11,0); - _objectState[1] = Object(_id, kStringPoster,kStringPosterDescription2,NULLOBJECT,UNNECESSARY,12,12,0); - _objectState[2] = Object(_id, kStringSpeaker,kStringDefaultDescription,NULLOBJECT,NULLTYPE,13,13,0); - _objectState[3] = Object(_id, kStringMagnete,kStringMagneteDescription,NULLOBJECT,UNNECESSARY,14,14,0); - _objectState[4] = Object(_id, kStringRecord,kStringRecordDescription,RECORD,TAKE | COMBINABLE,15,15,8 | 128); - _objectState[5] = Object(_id, kStringRecordStand,kStringRecordStandDescription,NULLOBJECT,UNNECESSARY,16,16,0); - _objectState[6] = Object(_id, kStringButton,kStringDefaultDescription,TURNTABLE_BUTTON,PRESS,22,22,0); - _objectState[7] = Object(_id, kStringTurntable,kStringTurntableDescription,TURNTABLE,UNNECESSARY | COMBINABLE,17,17,0); - _objectState[8] = Object(_id, kStringWire,kStringDefaultDescription,WIRE,COMBINABLE,18,18,0); - _objectState[9] = Object(_id, kStringWire,kStringDefaultDescription,WIRE2,COMBINABLE,19,19,0); - _objectState[10] = Object(_id, kStringPlug,kStringDefaultDescription,PLUG,COMBINABLE,20,20,0); - _objectState[11] = Object(_id, kStringHatch,kStringDefaultDescription,NULLOBJECT,OPENABLE | OPENED | EXIT,3,3,24 | 128,CORRIDOR,9); - _objectState[12] = Object(_id, kStringSlot,kStringSlotDescription,NULLOBJECT,COMBINABLE,0,0,0); - _objectState[13] = Object(_id, kStringShelf,kStringDefaultDescription,NULLOBJECT,OPENABLE | CLOSED,1,1,0); - _objectState[14] = Object(_id, kStringCompartment,kStringDefaultDescription,NULLOBJECT,OPENABLE | CLOSED,2,2,0); - _objectState[15] = Object(_id, kStringSocket,kStringDefaultDescription,SOCKET,COMBINABLE,4,4,0); - _objectState[16] = Object(_id, kStringToilet,kStringDefaultDescription,BATHROOM_DOOR,EXIT,255,255,0,BATHROOM,22); -} - -bool ShipCabinL3::interact(Action verb, Object &obj1, Object &obj2) { - Room *r; - - if ((verb == ACTION_USE) && Object::combine(obj1, obj2, RECORD, TURNTABLE)) { - if (!_gm->_guiEnabled || isSectionVisible(15)) - _vm->renderMessage(kStringShipCabinL3_1); - else { - if (!getObject(4)->hasProperty(CARRIED)) - _vm->renderImage(_gm->invertSection(8)); - else - _gm->_inventory.remove(*getObject(4)); - _vm->renderImage(15); - getObject(4)->_click = 48; - } - } else if ((verb == ACTION_PRESS) && (obj1._id == TURNTABLE_BUTTON)) { - if (!isSectionVisible(15)) { - _vm->renderMessage(kStringShipCabinL3_2); - } else if (!isSectionVisible(10) && !isSectionVisible(11) && isSectionVisible(12)) { - _vm->renderImage(14); - setSectionVisible(15, false); - for (int i = 3; i; i--) { - _vm->playSound(kAudioTurntable); - while (_vm->_sound->isPlaying()) { - if (isSectionVisible(13)) { - _vm->renderImage(14); - setSectionVisible(13, false); - } else { - _vm->renderImage(13); - setSectionVisible(14, false); - } - _gm->wait(3); - } - } - - _vm->renderImage(15); - setSectionVisible(14, false); - setSectionVisible(13, false); - _vm->renderMessage(kStringShipCabinL3_3); - } - } else if ((verb == ACTION_TAKE) && (obj1._id == RECORD) && (obj1._click != 15)) { - _vm->renderImage(9); - setSectionVisible(13, false); - setSectionVisible(14, false); - setSectionVisible(15, false); - obj1._section = 0; - _gm->takeObject(obj1); - } else if ((verb == ACTION_PULL) && (obj1._id == PLUG)) { - _vm->renderImage(10); - setSectionVisible(7, false); - obj1._click = 21; - } else if ((verb == ACTION_USE) && Object::combine(obj1, obj2, PLUG, SOCKET)) { - _vm->renderImage(7); - setSectionVisible(10, false); - getObject(10)->_click = 20; - } else if ((verb == ACTION_USE) && Object::combine(obj1, obj2, KNIFE, WIRE2)) - _vm->renderMessage(kStringShipCabinL3_4); // cutting near plug - else if ((verb == ACTION_USE) && Object::combine(obj1, obj2, KNIFE, WIRE)) { - r = _gm->_rooms[AIRLOCK]; - if (!isSectionVisible(10) && !r->getObject(5)->hasProperty(WORN)) { - _vm->renderImage(25); - _gm->shock(); - } - _vm->renderImage(11); - _vm->renderImage(26); - setSectionVisible(12, false); - } else if ((verb == ACTION_TAKE) && ((obj1._id == WIRE) || (obj1._id == WIRE2) || (obj1._id == PLUG))) { - if (isSectionVisible(10) && isSectionVisible(11)) { - _vm->renderImage(_gm->invertSection(10)); - _vm->renderImage(_gm->invertSection(11)); - getObject(8)->_name = kStringWireAndPlug; - _gm->takeObject(*getObject(8)); - getObject(9)->_click = 255; - getObject(10)->_click = 255; - } else - _vm->renderMessage(kStringShipCabinL3_5); - } else - return false; - - return true; -} - -ShipCabinR1::ShipCabinR1(SupernovaEngine *vm, GameManager1 *gm) { - _vm = vm; - _gm = gm; - - _fileNumber = 22; - _id = CABIN_R1; - _shown[0] = kShownTrue; - _shown[1] = kShownTrue; - _shown[2] = kShownTrue; - - _objectState[0] = Object(_id, kStringImage,kStringImageDescription1,NULLOBJECT,UNNECESSARY,5,5,0); - _objectState[1] = Object(_id, kStringDrawingInstruments,kStringDrawingInstrumentsDescription,NULLOBJECT,UNNECESSARY,6,6,0); - _objectState[2] = Object(_id, kStringMagnete,kStringMagneteDescription,NULLOBJECT,UNNECESSARY,7,7,0); - _objectState[3] = Object(_id, kStringHatch,kStringDefaultDescription,NULLOBJECT,OPENABLE | OPENED | EXIT,3,3,15 | 128,CORRIDOR,5); - _objectState[4] = Object(_id, kStringSlot,kStringSlotDescription,NULLOBJECT,COMBINABLE,0,0,0); - _objectState[5] = Object(_id, kStringShelf,kStringDefaultDescription,NULLOBJECT,OPENABLE | CLOSED,1,1,0); - _objectState[6] = Object(_id, kStringCompartment,kStringDefaultDescription,NULLOBJECT,OPENABLE | CLOSED,2,2,0); - _objectState[7] = Object(_id, kStringSocket,kStringDefaultDescription,SOCKET,COMBINABLE,4,4,0); - _objectState[8] = Object(_id, kStringToilet,kStringDefaultDescription,BATHROOM_DOOR,EXIT,255,255,0,BATHROOM,22); -} - -ShipCabinR2::ShipCabinR2(SupernovaEngine *vm, GameManager1 *gm) { - _vm = vm; - _gm = gm; - - _fileNumber = 22; - _id = CABIN_R2; - _shown[0] = kShownTrue; - _shown[3] = kShownTrue; - _shown[4] = kShownTrue; - _shown[5] = kShownTrue; - - _objectState[0] = Object(_id, kStringChessGame,kStringChessGameDescription1,NULLOBJECT,UNNECESSARY,11,11,0); - _objectState[1] = Object(_id, kStringTennisRacket,kStringTennisRacketDescription,NULLOBJECT,UNNECESSARY,8,8,0); - _objectState[2] = Object(_id, kStringTennisBall,kStringGenericDescription2,NULLOBJECT,UNNECESSARY,9,9,0); - _objectState[3] = Object(_id, kStringHatch,kStringDefaultDescription,NULLOBJECT,OPENABLE | OPENED | EXIT,3,3,15 | 128,CORRIDOR,5); - _objectState[4] = Object(_id, kStringSlot,kStringSlotDescription,NULLOBJECT,COMBINABLE,0,0,0); - _objectState[5] = Object(_id, kStringShelf,kStringDefaultDescription,NULLOBJECT,OPENABLE | CLOSED,1,1,0); - _objectState[6] = Object(_id, kStringCompartment,kStringDefaultDescription,NULLOBJECT,OPENABLE | CLOSED,2,2,0); - _objectState[7] = Object(_id, kStringSocket,kStringDefaultDescription,SOCKET,COMBINABLE,4,4,0); - _objectState[8] = Object(_id, kStringToilet,kStringDefaultDescription,BATHROOM_DOOR,EXIT,255,255,0,BATHROOM,22); -} - -ShipCabinR3::ShipCabinR3(SupernovaEngine *vm, GameManager1 *gm) { - _vm = vm; - _gm = gm; - - _fileNumber = 22; - _id = CABIN_R3; - _shown[0] = kShownTrue; - _shown[7] = kShownTrue; - _shown[8] = kShownTrue; - _shown[15] = kShownTrue; - - _objectState[0] = Object(_id, kStringChessGame,kStringChessGameDescription2,CHESS,TAKE | COMBINABLE,12,12,7 | 128); - _objectState[1] = Object(_id, kStringBed,kStringBedDescription,NULLOBJECT,NULLTYPE,13,13,0); - _objectState[2] = Object(_id, kStringSlot,kStringSlotDescription,SLOT_K1,COMBINABLE,27,27,0); - _objectState[3] = Object(_id, kStringSlot,kStringSlotDescription,SLOT_K2,COMBINABLE,28,28,0); - _objectState[4] = Object(_id, kStringSlot,kStringSlotDescription,SLOT_K3,COMBINABLE,29,29,0); - _objectState[5] = Object(_id, kStringSlot,kStringSlotDescription,SLOT_K4,COMBINABLE,30,30,0); - _objectState[6] = Object(_id, kStringCompartment,kStringCompartmentDescription,SHELF1,OPENABLE | CLOSED,14,18,9); - _objectState[7] = Object(_id, kStringAlbums,kStringAlbumsDescription,NULLOBJECT,UNNECESSARY,14,14,0); - _objectState[8] = Object(_id, kStringCompartment,kStringCompartmentDescription,SHELF2,OPENABLE | CLOSED,15,19,10); - _objectState[9] = Object(_id, kStringRope,kStringRopeDescription,ROPE,TAKE | COMBINABLE,15,15,12); - _objectState[10] = Object(_id, kStringShelf,kStringShelfDescription,SHELF3,OPENABLE | CLOSED,16,17,11); - _objectState[11] = Object(_id, kStringJunk,kStringJunkDescription,NULLOBJECT,UNNECESSARY,20,20,0); - _objectState[12] = Object(_id, kStringClothes,kStringClothesDescription,NULLOBJECT,UNNECESSARY,21,21,0); - _objectState[13] = Object(_id, kStringUnderwear,kStringDefaultDescription,NULLOBJECT,UNNECESSARY,22,22,0); - _objectState[14] = Object(_id, kStringSocks,kStringDefaultDescription,NULLOBJECT,UNNECESSARY,23,23,0); - _objectState[15] = Object(_id, kStringCompartment,kStringCompartmentDescription,SHELF4,OPENABLE | CLOSED,24,25,13); - _objectState[16] = Object(_id, kStringBook,kStringBookHitchhiker,BOOK,TAKE,26,26,14); - _objectState[17] = Object(_id, kStringDiscman,kStringDiscmanDescription,DISCMAN,TAKE | COMBINABLE,33,33,16); - _objectState[18] = Object(_id, kStringHatch,kStringDefaultDescription,NULLOBJECT,OPENABLE | EXIT,3,3,15 | 128,CORRIDOR,5); - _objectState[19] = Object(_id, kStringSlot,kStringSlotDescription,NULLOBJECT,COMBINABLE,0,0,0); - _objectState[20] = Object(_id, kStringShelf,kStringDefaultDescription,NULLOBJECT,OPENABLE | CLOSED,1,1,0); - _objectState[21] = Object(_id, kStringCompartment,kStringDefaultDescription,NULLOBJECT,OPENABLE | CLOSED,2,2,0); - _objectState[22] = Object(_id, kStringSocket,kStringDefaultDescription,SOCKET,COMBINABLE,4,4,0); - _objectState[23] = Object(_id, kStringToilet,kStringDefaultDescription,BATHROOM_DOOR,EXIT,255,255,0,BATHROOM,22); -} - -bool ShipCabinR3::interact(Action verb, Object &obj1, Object &obj2) { - if ((verb == ACTION_USE) && Object::combine(obj1, obj2, SLOT_K1, KEYCARD)) - _gm->openLocker(this, getObject(6), getObject(2), 9); - else if ((verb == ACTION_USE) && Object::combine(obj1, obj2, SLOT_K2, KEYCARD)) { - _gm->openLocker(this, getObject(8), getObject(3), 10); - if (getObject(9)->_click == 255) - _vm->renderImage(12); // Remove rope - } else if ((verb == ACTION_USE) && Object::combine(obj1, obj2, SLOT_K3, KEYCARD)) { - _gm->openLocker(this, getObject(10), getObject(4), 11); - if (getObject(17)->_click == 255) - _vm->renderImage(16); // Remove Discman - } else if ((verb == ACTION_USE) && Object::combine(obj1, obj2, SLOT_K4, KEYCARD)) { - _gm->openLocker(this, getObject(15), getObject(5), 13); - if (getObject(16)->_click == 255) - _vm->renderImage(14); // Remove Book - } else if ((verb == ACTION_CLOSE) && (obj1._id == SHELF1)) - _gm->closeLocker(this, getObject(6), getObject(2), 9); - else if ((verb == ACTION_CLOSE) && (obj1._id == SHELF2)) { - setSectionVisible(12, false); - _gm->closeLocker(this, getObject(8), getObject(3), 10); - } else if ((verb == ACTION_CLOSE) && (obj1._id == SHELF3)) { - setSectionVisible(16, false); - _gm->closeLocker(this, getObject(10), getObject(4), 11); - } else if ((verb == ACTION_CLOSE) && (obj1._id == SHELF4)) { - setSectionVisible(14, false); - setSectionVisible(14, false); - _gm->closeLocker(this, getObject(15), getObject(5), 13); - } else if ((verb == ACTION_TAKE) && (obj1._id == DISCMAN) && !_gm->_rooms[0]->getObject(3)->hasProperty(CARRIED)) { - getObject(10)->_click = 34; // Locker empty - obj1._click = 255; - _gm->takeObject(*_gm->_rooms[0]->getObject(3)); - _vm->renderImage(16); - } else if ((verb == ACTION_TAKE) && (obj1._id == ROPE) && obj1.hasProperty(CARRIED)) { - getObject(8)->_click = 31; // Shelf empty - return false; - } else if ((verb == ACTION_TAKE) && (obj1._id == BOOK) && !obj1.hasProperty(CARRIED)) { - getObject(15)->_click = 32; // Shelf empty - return false; - } else - return false; - - return true; -} - -void ShipCabinR3::onEntrance() { - for (int i = 0; i < 3; ++i) - _gm->_inventory.add(*_gm->_rooms[INTRO]->getObject(i)); - - setRoomSeen(true); -} - -ShipCabinBathroom::ShipCabinBathroom(SupernovaEngine *vm, GameManager1 *gm) { - _vm = vm; - _gm = gm; - - _fileNumber = 23; - _id = BATHROOM; - _shown[0] = kShownTrue; - - _objectState[0] = Object(_id, kStringBathroom,kStringBathroomDescription,TOILET,NULLTYPE,0,0,0); - _objectState[1] = Object(_id, kStringShower,kStringDefaultDescription,SHOWER,NULLTYPE,1,1,0); - _objectState[2] = Object(_id, kStringExit,kStringDefaultDescription,BATHROOM_EXIT,EXIT,255,255,0,CABIN_R3,2); -} - -ShipAirlock::ShipAirlock(SupernovaEngine *vm, GameManager1 *gm) { - _vm = vm; - _gm = gm; - - _fileNumber = 34; - _id = AIRLOCK; - _shown[0] = kShownTrue; - _shown[6] = kShownTrue; - - _objectState[0] = Object(_id, kStringHatch,kStringHatchDescription1,NULLOBJECT,EXIT | OPENABLE | OPENED | CLOSED,0,0,0,CORRIDOR,10); - _objectState[1] = Object(_id, kStringHatch,kStringHatchDescription2,NULLOBJECT,EXIT | OPENABLE | CLOSED,1,1,0,HOLD,14); - _objectState[2] = Object(_id, kStringButton,kStringDefaultDescription,BUTTON1,PRESS,2,2,0); - _objectState[3] = Object(_id, kStringButton,kStringDefaultDescription,BUTTON2,PRESS,3,3,0); - _objectState[4] = Object(_id, kStringHelmet,kStringHelmetDescription,HELMET,TAKE,4,4,7); - _objectState[5] = Object(_id, kStringSuit,kStringSuitDescription,SUIT,TAKE,5,5,8); - _objectState[6] = Object(_id, kStringLifeSupport,kStringLifeSupportDescription,LIFESUPPORT,TAKE,6,6,9); -} - -bool ShipAirlock::interact(Action verb, Object &obj1, Object &obj2) { - Room *r; - - if ((verb == ACTION_PRESS) && (obj1._id == BUTTON1)) { - if (!getObject(1)->hasProperty(OPENED)) { - _vm->renderImage(10); - _vm->playSound(kAudioSlideDoor); - if (getObject(0)->hasProperty(OPENED)) { - getObject(0)->disableProperty(OPENED); - _vm->renderImage(1); - _gm->wait(2); - _vm->renderImage(2); - setSectionVisible(1, false); - _gm->wait(2); - _vm->renderImage(3); - setSectionVisible(2, false); - } else { - getObject(0)->setProperty(OPENED); - _vm->renderImage(2); - setSectionVisible(3, false); - _gm->wait(2); - _vm->renderImage(1); - setSectionVisible(2, false); - _gm->wait(2); - _vm->renderImage(_gm->invertSection(1)); - } - _vm->renderImage(_gm->invertSection(10)); - } - } else if ((verb == ACTION_PRESS) && (obj1._id == BUTTON2)) { - if (!getObject(0)->hasProperty(OPENED)) { - _vm->renderImage(11); - if (getObject(1)->hasProperty(OPENED)) { - _vm->playSound(kAudioSlideDoor); - getObject(1)->disableProperty(OPENED); - _vm->renderImage(4); - _gm->wait(2); - _vm->renderImage(5); - setSectionVisible(4, false); - _gm->wait(2); - _vm->renderImage(6); - setSectionVisible(5, false); - _vm->renderImage(16); - setSectionVisible(17, false); - _gm->wait(3); - _vm->renderImage(15); - setSectionVisible(16, false); - _gm->wait(3); - _vm->renderImage(14); - setSectionVisible(15, false); - _gm->wait(3); - _vm->renderImage(13); - setSectionVisible(14, false); - _gm->wait(3); - _vm->renderImage(12); - setSectionVisible(13, false); - _gm->wait(3); - _vm->renderImage(_gm->invertSection(12)); - } else { - getObject(1)->setProperty(OPENED); - _vm->renderImage(12); - _gm->wait(3); - _vm->renderImage(13); - setSectionVisible(12, false); - _gm->wait(3); - _vm->renderImage(14); - setSectionVisible(13, false); - _gm->wait(3); - _vm->renderImage(15); - setSectionVisible(14, false); - _gm->wait(3); - _vm->renderImage(16); - setSectionVisible(15, false); - _gm->wait(3); - _vm->renderImage(17); - setSectionVisible(16, false); - _vm->playSound(kAudioSlideDoor); - _vm->renderImage(5); - setSectionVisible(6, false); - _gm->wait(2); - _vm->renderImage(4); - setSectionVisible(5, false); - _gm->wait(2); - _vm->renderImage(_gm->invertSection(4)); - r = _gm->_rooms[AIRLOCK]; - if (!r->getObject(4)->hasProperty(WORN) || - !r->getObject(5)->hasProperty(WORN) || - !r->getObject(6)->hasProperty(WORN)) { - _gm->dead(kStringShipAirlock1); - return true; - } - } - _vm->renderImage(_gm->invertSection(11)); - } - } else if ((verb == ACTION_LOOK) && (obj1._id == MANOMETER)) - _vm->renderMessage(getObject(1)->hasProperty(OPENED) ? kStringShipAirlock2 : kStringShipAirlock3); - else - return false; - - return true; -} - -void ShipAirlock::onEntrance() { - if (!hasSeen()) - _vm->renderMessage(kStringShipAirlock4); - - setRoomSeen(true); -} - -ShipHold::ShipHold(SupernovaEngine *vm, GameManager1 *gm) { - _vm = vm; - _gm = gm; - - _fileNumber = 24; - _id = HOLD; - _shown[0] = kShownTrue; - - _objectState[0] = Object(_id, kNoString,kStringDefaultDescription,HOLD_WIRE,COMBINABLE,255,255,0); - _objectState[1] = Object(_id, kStringScrap,kStringScrapDescription1,SCRAP_LK,NULLTYPE,4,4,0); - _objectState[2] = Object(_id, kStringTerminalStrip,kStringDefaultDescription,TERMINALSTRIP,COMBINABLE,255,255,0); - _objectState[3] = Object(_id, kStringScrap,kStringScrapDescription2,NULLOBJECT,NULLTYPE,5,5,0); - _objectState[4] = Object(_id, kStringReactor,kStringReactorDescription,NULLOBJECT,NULLTYPE,6,6,0); - _objectState[5] = Object(_id, kStringNozzle,kStringDefaultDescription,NULLOBJECT,NULLTYPE,7,7,0); - _objectState[6] = Object(_id, kStringPumpkin,kStringPumpkinDescription,NULLOBJECT,NULLTYPE,8,8,0); - _objectState[7] = Object(_id, kStringHatch,kStringDefaultDescription,LANDINGMOD_OUTERHATCH,EXIT | OPENABLE,1,2,2,LANDINGMODULE,6); - _objectState[8] = Object(_id, kStringLandingModule,kStringLandingModuleDescription,NULLOBJECT,NULLTYPE,0,0,0); - _objectState[9] = Object(_id, kStringExit,kStringDefaultDescription,NULLOBJECT,EXIT,255,255,0,AIRLOCK,22); - _objectState[10] = Object(_id, kStringHatch,kStringHatchDescription3,OUTERHATCH_TOP,EXIT | OPENABLE | OPENED,3,3,0,GENERATOR,8); - _objectState[11] = Object(_id, kStringGenerator,kStringGeneratorDescription,GENERATOR_TOP,EXIT,12,12,0,GENERATOR,8); -} - -bool ShipHold::interact(Action verb, Object &obj1, Object &obj2) { - Room *room; - - if ((verb == ACTION_LOOK) && (obj1._id == SCRAP_LK) && (obj1._description != kStringScrapDescription3)) { - _vm->renderMessage(obj1._description); - obj1._description = kStringScrapDescription3; - _gm->takeObject(*getObject(2)); - } else if (((verb == ACTION_OPEN) || (verb == ACTION_CLOSE)) && (obj1._id == OUTERHATCH_TOP)) - _vm->renderMessage(kStringShipHold1); - else if ((verb == ACTION_CLOSE) && (obj1._id == LANDINGMOD_HATCH) && (isSectionVisible(4) || isSectionVisible(6))) - _vm->renderMessage(kStringCable1); - else if (((verb == ACTION_TAKE) && (obj1._id == HOLD_WIRE)) || - ((verb == ACTION_USE) && Object::combine(obj1, obj2, HOLD_WIRE, LANDINGMOD_HATCH))) - _vm->renderMessage(kStringCable2); - else if ((verb == ACTION_USE) && Object::combine(obj1, obj2, TERMINALSTRIP, HOLD_WIRE)) { - getObject(0)->_name = kStringWireAndClip; - _gm->_inventory.remove(*getObject(2)); - _gm->_state._terminalStripConnected = true; - _gm->_state._terminalStripWire = true; - _vm->renderMessage(kStringOk); - } else if ((verb == ACTION_USE) && Object::combine(obj1, obj2, HOLD_WIRE, SPOOL)) { - if (!_gm->_state._terminalStripConnected) - _vm->renderMessage(kStringCable3); - else { - _vm->renderImage(5); - getObject(0)->_name = kStringWireAndPlug2; - getObject(0)->_click = 10; - room = _gm->_rooms[CABIN_L2]; - _gm->_inventory.remove(*getObject(9)); - } - } else if ((verb == ACTION_USE) && Object::combine(obj1, obj2, HOLD_WIRE, GENERATOR_TOP)) { - if (isSectionVisible(5)) { - room = _gm->_rooms[GENERATOR]; - room->getObject(0)->_click = 15; - room->getObject(1)->_click = 13; - room->setSectionVisible(6, true); - room->setSectionVisible(8, true); - _vm->renderImage(_gm->invertSection(5)); - _vm->renderImage(6); - setSectionVisible(4, false); - getObject(0)->_click = 11; - } else - _vm->renderMessage(kStringCable4); - } else - return false; - - return true; -} - -void ShipHold::onEntrance() { - if (!hasSeen()) - _vm->renderMessage(kStringShipHold2); - setRoomSeen(true); - _gm->_rooms[COCKPIT]->setRoomSeen(true); -} - -ShipLandingModule::ShipLandingModule(SupernovaEngine *vm, GameManager1 *gm) { - _vm = vm; - _gm = gm; - - _fileNumber = 25; - _id = LANDINGMODULE; - _shown[0] = kShownTrue; - - _objectState[0] = Object(_id, kStringSocket,kStringDefaultDescription,LANDINGMOD_SOCKET,COMBINABLE,1,1,0); - _objectState[1] = Object(_id, kStringButton,kSafetyButtonDescription,LANDINGMOD_BUTTON,PRESS | COMBINABLE,2,2,0); - _objectState[2] = Object(_id, kStringMonitor,kStringDefaultDescription,LANDINGMOD_MONITOR,NULLTYPE,3,3,0); - _objectState[3] = Object(_id, kStringKeyboard,kStringDefaultDescription,KEYBOARD,NULLTYPE,4,4,0); - _objectState[4] = Object(_id, kNoString,kStringDefaultDescription,LANDINGMOD_WIRE,COMBINABLE,255,255,0); - _objectState[5] = Object(_id, kStringHatch,kStringDefaultDescription,LANDINGMOD_HATCH,EXIT | OPENABLE | OPENED | COMBINABLE, 0,0,1 | 128,HOLD,10); -} - -bool ShipLandingModule::interact(Action verb, Object &obj1, Object &obj2) { - if ((verb == ACTION_PRESS) && (obj1._id == LANDINGMOD_BUTTON)) - _vm->renderMessage(obj1._description); - else if ((verb == ACTION_USE) && Object::combine(obj1, obj2, PEN, LANDINGMOD_BUTTON)) { - if (_gm->_state._landingModuleEnergyDaysLeft) { - Room *r = _gm->_rooms[GENERATOR]; - if (isSectionVisible(7)) { - _vm->renderImage(_gm->invertSection(9)); - _vm->renderImage(_gm->invertSection(2)); - _vm->renderImage(_gm->invertSection(8)); - _vm->renderImage(_gm->invertSection(7)); - _vm->renderImage(_gm->invertSection(10)); - if (r->isSectionVisible(9)) - _gm->_state._powerOff = true; - _gm->roomBrightness(); - } else { - _vm->renderImage(7); - if (r->isSectionVisible(9)) - _gm->_state._powerOff = false; - _gm->roomBrightness(); - r = _gm->_rooms[SLEEP]; - r->setSectionVisible(1, false); - r->setSectionVisible(2, false); - _gm->wait(2); - _vm->renderImage(2); - _gm->wait(3); - _vm->renderImage(8); - _gm->wait(2); - _vm->renderImage(9); - _gm->wait(1); - _vm->renderImage(10); - } - } - } else if ((verb == ACTION_USE) && Object::combine(obj1, obj2, KNIFE, LANDINGMOD_BUTTON)) - _vm->renderMessage(kStringShipHold3); - else if ((verb == ACTION_LOOK) && (obj1._id == LANDINGMOD_MONITOR) && isSectionVisible(7)) - _vm->renderMessage(kStringShipHold4); - else if ((verb == ACTION_USE) && (obj1._id == KEYBOARD)) - _vm->renderMessage(kStringShipHold5); - else if ((verb == ACTION_USE) && Object::combine(obj1, obj2, WIRE, LANDINGMOD_SOCKET)) { - Room *r = _gm->_rooms[CABIN_L3]; - _gm->_inventory.remove(*r->getObject(8)); - getObject(4)->_name = r->getObject(8)->_name; - _vm->renderImage(4); - if (_gm->_state._cableConnected) { - _vm->renderImage(5); - getObject(4)->_click = 6; - } else { - getObject(4)->_click = 5; - if (_gm->_state._terminalStripWire) - _vm->renderImage(11); - } - } else if ((verb == ACTION_USE) && Object::combine(obj1, obj2, SPOOL, LANDINGMOD_SOCKET)) - _vm->renderMessage(kStringShipHold8); - else if ((verb == ACTION_USE) && Object::combine(obj1, obj2, LANDINGMOD_WIRE, TERMINALSTRIP)) { - _vm->renderImage(11); - getObject(4)->_name = kStringWireAndClip; - Room *r = _gm->_rooms[HOLD]; - _gm->_inventory.remove(*r->getObject(2)); - _gm->_state._terminalStripConnected = true; - _gm->_state._terminalStripWire = true; - } else if ((verb == ACTION_USE) && Object::combine(obj1, obj2, LANDINGMOD_WIRE, SPOOL)) { - if (!_gm->_state._terminalStripConnected) - _vm->renderMessage(kStringCable3); - else { - _vm->renderImage(5); - getObject(4)->_name = kStringWireAndPlug2; - getObject(4)->_click = 6; - _gm->_inventory.remove(*_gm->_rooms[CABIN_L2]->getObject(9)); - } - } else if ((verb == ACTION_USE) && Object::combine(obj1, obj2, LANDINGMOD_WIRE, LANDINGMOD_HATCH)) { - if (getObject(5)->hasProperty(OPENED)) { - Room *r = _gm->_rooms[HOLD]; - if (isSectionVisible(5)) { - r->setSectionVisible(5, true); - r->getObject(0)->_click = 10; - } else - r->getObject(0)->_click = 9; - - r->setSectionVisible(4, true); - r->getObject(0)->_name = getObject(4)->_name; - _vm->renderImage(_gm->invertSection(5)); - _vm->renderImage(_gm->invertSection(4)); - setSectionVisible(11, false); - _vm->renderImage(6); - getObject(4)->_click = 7; - } else - _vm->renderMessage(kStringShipHold6); - } else if ((verb == ACTION_CLOSE) && (obj1._id == LANDINGMOD_HATCH) && isSectionVisible(6)) - _vm->renderMessage(kStringCable1); - else if (((verb == ACTION_TAKE) || (verb == ACTION_PULL)) && (obj1._id == LANDINGMOD_WIRE)) - _vm->renderMessage(kStringCable2); - else - return false; - - return true; -} - -ShipGenerator::ShipGenerator(SupernovaEngine *vm, GameManager1 *gm) { - _vm = vm; - _gm = gm; - - _fileNumber = 18; - _id = GENERATOR; - _shown[0] = kShownTrue; - _shown[5] = kShownTrue; - - _objectState[0] = Object(_id, kStringGeneratorWire,kStringDefaultDescription,GENERATOR_WIRE,COMBINABLE,255,255,0); - _objectState[1] = Object(_id, kStringEmptySpool,kStringDefaultDescription,NULLOBJECT,UNNECESSARY,255,255,0); - _objectState[2] = Object(_id, kStringKeycard2,kStringKeycard2Description,KEYCARD2,COMBINABLE | TAKE,12,12,5 | 128); - _objectState[3] = Object(_id, kStringRope,kStringDefaultDescription,GENERATOR_ROPE,COMBINABLE,255,255,0); - _objectState[4] = Object(_id, kStringHatch,kStringHatchDescription3,OUTERHATCH,EXIT | OPENABLE,1,2,1,OUTSIDE,22); - _objectState[5] = Object(_id, kStringHatch,kStringDefaultDescription,NULLOBJECT,OPENABLE | CLOSED,3,3,0); - _objectState[6] = Object(_id, kStringSlot,kStringSlotDescription,NULLOBJECT,COMBINABLE,4,4,0); - _objectState[7] = Object(_id, kStringTrap,kStringDefaultDescription,TRAP,OPENABLE,5,6,2); - _objectState[8] = Object(_id, kStringWire,kStringDefaultDescription,NULLOBJECT,NULLTYPE,7,7,0); - _objectState[9] = Object(_id, kStringVoltmeter,kStringDefaultDescription,VOLTMETER,NULLTYPE,9,9,0,NULLROOM,0); - _objectState[10] = Object(_id, kStringClip,kStringDefaultDescription,CLIP,COMBINABLE,8,8,0); - _objectState[11] = Object(_id, kStringWire,kStringWireDescription,SHORT_WIRE,COMBINABLE,10,10,0); - _objectState[12] = Object(_id, kStringLadder,kStringDefaultDescription,LADDER,EXIT,0,0,0,HOLD,1); -} - -bool ShipGenerator::interact(Action verb, Object &obj1, Object &obj2) { - if ((verb == ACTION_OPEN) && (obj1._id == OUTERHATCH)) { - if (obj1.hasProperty(OPENED)) - return false; - _vm->playSound(kAudioSlideDoor); - _vm->renderImage(1); - if (isSectionVisible(7)) - _vm->renderImage(10); - if (isSectionVisible(13)) - _vm->renderImage(13); - _gm->_rooms[HOLD]->setSectionVisible(3, true); - obj1.setProperty(OPENED); - obj1._click = 2; - _vm->playSound(kAudioDoorOpen); - } else if ((verb == ACTION_CLOSE) && (obj1._id == OUTERHATCH)) { - if (!obj1.hasProperty(OPENED)) - return false; - if (isSectionVisible(11) || isSectionVisible(12)) - _vm->renderMessage(kStringShipHold7); - else { - _vm->playSound(kAudioSlideDoor); - _vm->renderImage(_gm->invertSection(1)); - setSectionVisible(10, false); - if (isSectionVisible(13)) - _vm->renderImage(13); - _gm->_rooms[HOLD]->setSectionVisible(3, false); - obj1.disableProperty(OPENED); - obj1._click = 1; - _vm->playSound(kAudioDoorClose); - } - } else if ((verb == ACTION_WALK) && (obj1._id == OUTERHATCH) && - isSectionVisible(7)) { - if (!obj1.hasProperty(OPENED)) - _vm->renderMessage(kStringShipHold9); - else if (!isSectionVisible(11)) - _vm->renderMessage(kStringShipHold10); - else { - obj1._exitRoom = ROCKS; - return false; - } - } else if ((verb == ACTION_TAKE) && (obj1._id == GENERATOR_WIRE)) - _vm->renderMessage(kStringCable2); - else if ((verb == ACTION_PULL) && (obj1._id == SHORT_WIRE) && - (obj1._click != 11)) { - _vm->renderImage(3); - _vm->renderImage(4); - obj1._click = 11; - _gm->turnOff(); - } else if ((verb == ACTION_USE) && Object::combine(obj1, obj2, SHORT_WIRE, CLIP) && - (getObject(11)->_click == 11) && !isSectionVisible(9)) { - _vm->renderImage(2); - setSectionVisible(3, false); - setSectionVisible(4, false); - getObject(11)->_click = 10; - if (_gm->_state._shipEnergyDaysLeft) - _gm->turnOn(); - else - _vm->renderImage(4); - } else if ((verb == ACTION_OPEN) && (obj1._id == TRAP)) { - _vm->playSound(kAudioSlideDoor); - _vm->renderImage(2); - if (getObject(11)->_click == 11) - _vm->renderImage(3); - if (_gm->_state._powerOff) - _vm->renderImage(4); - obj1.setProperty(OPENED); - obj1._click = 6; - - obj1._click2 = 5; - _vm->playSound(kAudioDoorOpen); - } else if ((verb == ACTION_CLOSE) && (obj1._id == TRAP)) { - if (isSectionVisible(9)) - _vm->renderMessage(kStringCable1); - else { - setSectionVisible(3, false); - return false; - } - } else if ((verb == ACTION_USE) && Object::combine(obj1, obj2, GENERATOR_WIRE, CLIP) && - isSectionVisible(3) && (getObject(0)->_click != 16)) { - _vm->renderImage(_gm->invertSection(8)); - _vm->renderImage(2); - setSectionVisible(4, false); - _vm->renderImage(3); - _vm->renderImage(9); - getObject(0)->_click = 16; - Room *r = _gm->_rooms[LANDINGMODULE]; - if (_gm->_state._landingModuleEnergyDaysLeft && r->isSectionVisible(7)) - _gm->turnOn(); - else - _vm->renderImage(4); - _gm->_rooms[HOLD]->setSectionVisible(7, true); - _gm->great(3); - } else if ((verb == ACTION_PULL) && (obj1._id == GENERATOR_WIRE) && (obj1._click == 16)) { - _vm->renderImage(_gm->invertSection(9)); - _vm->renderImage(2); - _vm->renderImage(3); - _vm->renderImage(4); - _vm->renderImage(8); - obj1._click = 15; - _gm->turnOff(); - _gm->_rooms[HOLD]->setSectionVisible(7, false); - } else if ((verb == ACTION_USE) && - (Object::combine(obj1, obj2, WIRE, CLIP) || - Object::combine(obj1, obj2, SPOOL, CLIP)) && - isSectionVisible(3)) { - _vm->renderMessage(kStringShipHold11); - } else if ((verb == ACTION_LOOK) && (obj1._id == VOLTMETER)) { - if (_gm->_state._powerOff) - _vm->renderMessage(kStringShipHold12); - else - _vm->renderMessage(kStringShipHold13); - } else if ((verb == ACTION_USE) && Object::combine(obj1, obj2, LADDER, ROPE)) { - _vm->renderImage(13); - Room *r = _gm->_rooms[CABIN_R3]; - _gm->_inventory.remove(*r->getObject(9)); - getObject(3)->_click = 18; - } else if ((verb == ACTION_USE) && Object::combine(obj1, obj2, OUTERHATCH, GENERATOR_ROPE)) { - if (!isSectionVisible(1)) - _vm->renderMessage(kStringShipHold14); - else { - _vm->renderImage(_gm->invertSection(13)); - _vm->renderImage(1); - if (isSectionVisible(7)) { - _vm->renderImage(10); - _vm->renderImage(11); - } else - _vm->renderImage(12); - - Room *r = _gm->_rooms[OUTSIDE]; - r->setSectionVisible(1, true); - r->getObject(1)->_click = 1; - getObject(3)->_click = 17; - } - } else if ((verb == ACTION_TAKE) && (obj1._id == GENERATOR_ROPE)) - _vm->renderMessage(kStringShipHold15); - else if ((verb == ACTION_USE) && Object::combine(obj1, obj2, OUTERHATCH, GENERATOR_WIRE) && isSectionVisible(1)) - _vm->renderMessage(kStringShipHold16); - else - return false; - - return true; -} - -ShipOuterSpace::ShipOuterSpace(SupernovaEngine *vm, GameManager1 *gm) { - _vm = vm; - _gm = gm; - - _fileNumber = 4; - _id = OUTSIDE; - _shown[0] = kShownTrue; - - _objectState[0] = Object(_id, kStringHatch,kStringDefaultDescription,NULLOBJECT,EXIT,0,0,0,GENERATOR,3); - _objectState[1] = Object(_id, kStringRope,kStringDefaultDescription,NULLOBJECT,UNNECESSARY,255,255,0); -} - - -// Arsano -ArsanoRocks::ArsanoRocks(SupernovaEngine *vm, GameManager1 *gm) { - _vm = vm; - _gm = gm; - - _fileNumber = 12; - _id = OUTSIDE; - _shown[0] = kShownTrue; - - _objectState[0] = Object(_id, kStringRope,kStringDefaultDescription,NULLOBJECT,UNNECESSARY | EXIT,0,0,0,GENERATOR,12); - _objectState[1] = Object(_id, kStringStone,kStringDefaultDescription,STONE,NULLTYPE,1,1,0); - _objectState[2] = Object(_id, kStringStone,kStringDefaultDescription,NULLOBJECT,NULLTYPE,2,2,0); - _objectState[3] = Object(_id, kStringCaveOpening,kStringCaveOpeningDescription,NULLOBJECT,NULLTYPE,255,255,0,CAVE,1); -} - -void ArsanoRocks::onEntrance() { - _gm->great(8); -} - -bool ArsanoRocks::interact(Action verb, Object &obj1, Object &obj2) { - if (((verb == ACTION_PULL) || (verb == ACTION_PRESS)) && - (obj1._id == STONE) && !isSectionVisible(3)) { - _vm->renderImage(1); - _gm->wait(2); - _vm->renderImage(2); - _gm->wait(2); - _vm->renderImage(3); - _vm->playSound(kAudioRocks); - obj1._click = 3; - getObject(3)->_click = 4; - getObject(3)->setProperty(EXIT); - return true; - } - return false; -} - -ArsanoCave::ArsanoCave(SupernovaEngine *vm, GameManager1 *gm) { - _vm = vm; - _gm = gm; - - _fileNumber = 12; - _id = CAVE; - - _objectState[0] = Object(_id, kStringExit,kStringExitDescription,NULLOBJECT,EXIT,255,255,0,ROCKS,22); - _objectState[1] = Object(_id, kStringExit,kStringDefaultDescription,NULLOBJECT,EXIT,255,255,0,MEETUP,2); -} - -ArsanoMeetup::ArsanoMeetup(SupernovaEngine *vm, GameManager1 *gm) { - _vm = vm; - _gm = gm; - - _fileNumber = 37; - _id = MEETUP; - _shown[0] = kShownTrue; - _sign = 0; - _beacon = 0; - - _objectState[0] = Object(_id, kStringCave,kStringDefaultDescription,NULLOBJECT,EXIT,255,255,0,CAVE,22); - _objectState[1] = Object(_id, kStringSign,kStringSignDescription,MEETUP_SIGN,NULLTYPE,0,0,0); - _objectState[2] = Object(_id, kStringEntrance,kStringDefaultDescription,DOOR,EXIT,1,1,0,ENTRANCE,7); - _objectState[3] = Object(_id, kStringStar,kStringDefaultDescription,STAR,NULLTYPE,2,2,0); - _objectState[4] = Object(_id, kStringSpaceshift,kStringDefaultDescription,SPACESHIPS,COMBINABLE,3,3,0); - _objectState[5] = Object(_id, kStringSpaceshift,kStringDefaultDescription,SPACESHIP,COMBINABLE,4,4,0); -} - -void ArsanoMeetup::onEntrance() { - if (isSectionVisible(7)) { - _gm->wait(3); - _vm->renderImage(6); - setSectionVisible(7, false); - _gm->wait(3); - _vm->renderImage(_gm->invertSection(6)); - } - if (!(_gm->_state._greatFlag & 0x8000)) { - _vm->playSound(kAudioFoundLocation); - _gm->_state._greatFlag |= 0x8000; - } -} - -void ArsanoMeetup::animation() { - _vm->renderImage(_gm->invertSection(1) + _beacon); - _beacon = (_beacon + 1) % 5; - _vm->renderImage(_beacon + 1); - _vm->renderImage(_beacon + 8); - if (isSectionVisible(_sign + 13)) - _vm->renderImage(_gm->invertSection(13) + _sign); - else - _vm->renderImage(13 + _sign); - - _sign = (_sign + 1) % 14; - _gm->setAnimationTimer(3); -} - -bool ArsanoMeetup::interact(Action verb, Object &obj1, Object &obj2) { - if ((verb == ACTION_WALK) && - ((obj1._id == SPACESHIPS) || - ((obj1._id == SPACESHIP) && !obj1.hasProperty(OPENED)))) { - _vm->renderMessage(kStringArsanoMeetup1); - } else if ((verb == ACTION_WALK) && (obj1._id == SPACESHIP)) - _gm->changeRoom(GLIDER); - else if ((verb == ACTION_WALK) && (obj1._id == STAR)) - _vm->renderMessage(kStringArsanoMeetup2); - else if ((verb == ACTION_LOOK) && (obj1._id == STAR)) { - _vm->setCurrentImage(26); - _vm->renderImage(0); - _vm->paletteBrightness(); - _gm->animationOff(); - _gm->getInput(); - _gm->animationOn(); - g_system->fillScreen(kColorBlack); - _vm->renderRoom(*this); - _vm->paletteBrightness(); - } else if ((verb == ACTION_WALK) && (obj1._id == DOOR)) { - _vm->renderImage(6); - _gm->wait(3); - _vm->renderImage(7); - setSectionVisible(6, false); - _gm->wait(3); - - return false; - } else if ((verb == ACTION_LOOK) && (obj1._id == MEETUP_SIGN) && _gm->_state._language) { - if (_gm->_state._language == 2) - _vm->renderMessage(kStringArsanoMeetup3); - - obj1._description = kStringSignDescription2; - if (_gm->_state._language == 1) - return false; - - _gm->_state._language = 1; - } else if ((verb == ACTION_USE) && Object::combine(obj1, obj2, KEYCARD_R, SPACESHIP)) { - getObject(5)->setProperty(OPENED); - _gm->changeRoom(GLIDER); - } else - return false; - - return true; -} - -ArsanoEntrance::ArsanoEntrance(SupernovaEngine *vm, GameManager1 *gm) { - _vm = vm; - _gm = gm; - - _fileNumber = 10; - _id = ENTRANCE; - _shown[0] = kShownTrue; - - _objectState[0] = Object(_id, kStringPorter,kStringPorterDescription,PORTER,TALK,0,0,0); - _objectState[1] = Object(_id, kStringDoor,kStringDefaultDescription,NULLOBJECT,EXIT | OPENABLE | CLOSED,1,1,0,NULLROOM,5); - _objectState[2] = Object(_id, kStringSign,kStringSignDescription,KITCHEN_SIGN,NULLTYPE,2,2,0); - _objectState[3] = Object(_id, kStringChewingGum,kStringDefaultDescription,SCHNUCK,TAKE,255,255,10+128); - _objectState[4] = Object(_id, kStringGummyBears,kStringDefaultDescription,SCHNUCK,TAKE,255,255,11+128); - _objectState[5] = Object(_id, kStringChocolateBall,kStringDefaultDescription,SCHNUCK,TAKE,255,255,12+128); - _objectState[6] = Object(_id, kStringEgg,kStringDefaultDescription,EGG,TAKE,255,255,13+128); - _objectState[7] = Object(_id, kStringLiquorice,kStringDefaultDescription,SCHNUCK,TAKE,255,255,14+128); - _objectState[8] = Object(_id, kStringPill,kStringPillDescription,PILL,TAKE,255,255,0); - _objectState[9] = Object(_id, kStringSlot,kStringDefaultDescription,CAR_SLOT,COMBINABLE,6,6,0); - _objectState[10] = Object(_id, kStringVendingMachine,kStringVendingMachineDescription,NULLOBJECT,NULLTYPE,5,5,0); - _objectState[11] = Object(_id, kStringToilet,kStringToiletDescription,ARSANO_BATHROOM,NULLTYPE,255,255,0); - _objectState[12] = Object(_id, kStringButton,kStringDefaultDescription,BATHROOM_BUTTON,PRESS,3,3,0); - _objectState[13] = Object(_id, kStringSign,kStringSignDescription,BATHROOM_SIGN,NULLTYPE,4,4,0); - _objectState[14] = Object(_id, kStringStaircase,kStringDefaultDescription,STAIRCASE,EXIT,8,8,0,REST,3); - _objectState[15] = Object(_id, kStringExit,kStringDefaultDescription,MEETUP_EXIT,EXIT,255,255,0,MEETUP,22); - _objectState[16] = Object(_id, kStringCoins,kStringCoinsDescription,COINS,TAKE|COMBINABLE,255,255,0); - _objectState[17] = Object(_id, kStringTabletPackage,kStringTabletPackageDescription,PILL_HULL,TAKE,255,255,0); - - _dialog1[0] = kStringArsanoDialog7; - _dialog1[1] = kStringArsanoDialog1; - _dialog1[2] = kStringArsanoDialog8; - _dialog1[3] = kStringArsanoDialog9; - _dialog1[4] = kStringDialogSeparator; - - _dialog2[0] = kStringArsanoDialog1; - _dialog2[1] = kStringArsanoDialog2; - _dialog2[2] = kStringArsanoDialog3; - _dialog2[3] = kStringArsanoDialog4; - _dialog2[4] = kStringDialogSeparator; - - _dialog3[0] = kStringArsanoDialog5; - _dialog3[1] = kStringArsanoDialog6; - - _eyewitness = 5; -} - -void ArsanoEntrance::animation() { - if (!_vm->_screen->isMessageShown() && isSectionVisible(kMaxSection - 5)) { - _gm->animationOff(); // to avoid recursive call - _vm->playSound(kAudioSlideDoor); - _vm->renderImage(8); - setSectionVisible(9, false); - _gm->wait(2); - _vm->renderImage(7); - setSectionVisible(8, false); - _gm->wait(2); - _vm->renderImage(6); - setSectionVisible(7, false); - _gm->wait(2); - _vm->renderImage(5); - setSectionVisible(6, false); - _gm->wait(2); - _vm->renderImage(_gm->invertSection(5)); - getObject(11)->_click = 255; - setSectionVisible(kMaxSection - 5, false); - _gm->animationOn(); - } - if (isSectionVisible(2)) - _vm->renderImage(_gm->invertSection(2)); - else if (_eyewitness) - --_eyewitness; - else { - _eyewitness = 20; - _vm->renderImage(2); - } - - _gm->setAnimationTimer(4); -} - -bool ArsanoEntrance::interact(Action verb, Object &obj1, Object &obj2) { - static byte row1[6] = {1, 1, 1, 1, 1, 0}; - static byte row2[6] = {1, 1, 1, 1, 1, 0}; - static byte row3[6] = {1, 1, 0, 0, 0, 0}; - - if ((verb == ACTION_TALK) && (obj1._id == PORTER)) { - if (_gm->_rooms[AIRLOCK]->getObject(4)->hasProperty(WORN)) - _vm->renderMessage(kStringArsanoEntrance1); - else { - if (_gm->_state._language) { - int e; - do { - if (_gm->_state._shoes == 1) { - _dialog2[2] = kStringArsanoEntrance2; - addSentence(2, 2); - } else if (_gm->_state._shoes > 1) - removeSentence(2, 2); - - switch (e = _gm->dialog(5, row2, _dialog2, 2)) { - case 0: - _gm->reply(kStringArsanoEntrance3, 1, _gm->invertSection(1)); - _gm->reply(kStringArsanoEntrance4, 1, _gm->invertSection(1)); - _gm->reply(kStringArsanoEntrance5, 1, _gm->invertSection(1)); - removeSentence(1, 1); - break; - case 1: - _gm->reply(kStringArsanoEntrance6, 1, _gm->invertSection(1)); - addSentence(1, 2); - break; - case 2: - if (_gm->_state._shoes == 1) { - _gm->reply(kStringArsanoEntrance7, 1, _gm->invertSection(1)); - _gm->_state._shoes = 2; - } else { - _gm->reply(kStringArsanoEntrance8, 1, _gm->invertSection(1)); - _gm->_state._shoes = 1; - } - break; - case 3: - _gm->reply(kStringArsanoEntrance9, 1, _gm->invertSection(1)); - } - } while (e != 4); - } else if (_gm->dialog(5, row2, _dialog2, 0) != 4) - _gm->reply(kStringArsanoEntrance10, 1, _gm->invertSection(1)); - } - } else if ((verb == ACTION_WALK) && (obj1._id == STAIRCASE) && (_gm->_state._shoes != 3)) { - _vm->renderImage(3); - _gm->wait(2); - _vm->renderImage(4); - setSectionVisible(3, false); - if (_gm->_rooms[AIRLOCK]->getObject(4)->hasProperty(WORN)) - _gm->reply(kStringDialogSeparator, 1, _gm->invertSection(1)); - else if (_gm->_state._language) - _gm->reply(kStringArsanoEntrance11, 1, _gm->invertSection(1)); - else - _gm->reply(kStringArsanoEntrance12, 1, _gm->invertSection(1)); - _vm->renderImage(3); - setSectionVisible(4, false); - _gm->wait(2); - _vm->renderImage(_gm->invertSection(3)); - if (!_gm->_rooms[AIRLOCK]->getObject(4)->hasProperty(WORN)) { - if (_gm->_state._language) { - if (_gm->_state._shoes) - _gm->reply(kStringArsanoEntrance13, 1, _gm->invertSection(1)); - else - _gm->reply(kStringArsanoEntrance14, 1, _gm->invertSection(1)); - int e = 0; - while ((e < 3) && (!allSentencesRemoved(4, 1))) { - switch (e = _gm->dialog(5, row1, _dialog1, 1)) { - case 0: - _gm->reply(kStringArsanoEntrance15, 1, 1 + 128); - break; - case 1: - _gm->reply(kStringArsanoEntrance3, 1, 1 + 128); - _gm->reply(kStringArsanoEntrance4, 1, 1 + 128); - _gm->reply(kStringArsanoEntrance5, 1, 1 + 128); - removeSentence(0, 2); - break; - case 2: - _gm->reply(kStringArsanoEntrance7, 1, 1 + 128); - _gm->_state._shoes = 2; - break; - case 3: - _vm->renderImage(3); - _gm->wait(2); - _vm->renderImage(4); - setSectionVisible(3, false); - _gm->reply(kStringArsanoEntrance16, 1, 1 + 128); - _vm->renderImage(3); - setSectionVisible(4, false); - _gm->wait(2); - _vm->renderImage(_gm->invertSection(3)); - break; - } - removeSentence(0, 1); - } - } else { - _gm->dialog(2, row3, _dialog3, 0); - _gm->reply(kStringArsanoEntrance10, 1, 1 + 128); - } - } - } else if ((verb == ACTION_PRESS) && (obj1._id == BATHROOM_BUTTON)) { - _vm->playSound(kAudioSlideDoor); - _vm->renderImage(5); - _gm->wait(2); - _vm->renderImage(6); - setSectionVisible(5, false); - _gm->wait(2); - _vm->renderImage(7); - setSectionVisible(6, false); - _gm->wait(2); - _vm->renderImage(8); - setSectionVisible(7, false); - _gm->wait(2); - _vm->renderImage(9); - setSectionVisible(8, false); - getObject(11)->_click = 9; - } else if ((verb == ACTION_WALK) && (obj1._id == ARSANO_BATHROOM)) { - if (_gm->_state._coins) { - if (_gm->_state._shoes == 2) { - _vm->renderMessage(kStringArsanoEntrance17); - _gm->_state._shoes = 3; - removeSentence(2, 2); - removeSentence(3, 2); - } else if (_gm->_state._shoes == 3) { - _vm->renderMessage(kStringArsanoEntrance18); - _gm->_state._shoes = 2; - } else - _vm->renderMessage(kStringArsanoEntrance19); - } else { - if (_gm->_rooms[AIRLOCK]->getObject(5)->hasProperty(WORN)) - _vm->renderMessage(kStringArsanoEntrance20); - else { - _vm->renderMessage(kStringArsanoEntrance21); - _gm->waitOnInput(_gm->_messageDuration); - _vm->removeMessage(); - _vm->renderMessage(kStringArsanoEntrance22); - _gm->takeObject(*getObject(16)); - _gm->_state._coins = 5; - } - } - // This shown object is an abuse in the original engine as it's not a real shown variable - // It's an internal (boolean) status - _shown[kMaxSection - 5] = kShownTrue; - } else if ((verb == ACTION_USE) && Object::combine(obj1, obj2, COINS, CAR_SLOT)) { - if ((_gm->_state._coins < 5) && (getObject(7 - _gm->_state._coins)->_click == 7)) - _vm->renderMessage(kStringArsanoEntrance23); - else { - _vm->renderImage(15 - _gm->_state._coins); - getObject(8 - _gm->_state._coins)->_click = 7; - --_gm->_state._coins; - if (_gm->_state._coins == 1) - getObject(16)->_name = kStringCoin; - - if (_gm->_state._coins == 0) { - _gm->_inventory.remove(*getObject(16)); - _gm->_state._coins = 255; - } - } - } else if ((verb == ACTION_LOOK) && (obj1._id == KITCHEN_SIGN) && _gm->_state._language) { - if (_gm->_state._language == 2) - _vm->renderMessage(kStringArsanoEntrance24); - obj1._description = kStringDoorDescription5; - if (_gm->_state._language == 1) - return false; - _gm->_state._language = 1; - } else if ((verb == ACTION_LOOK) && (obj1._id == BATHROOM_SIGN) && _gm->_state._language) { - if (_gm->_state._language == 2) - _vm->renderMessage(kStringArsanoEntrance25); - obj1._description = kStringDoorDescription6; - if (_gm->_state._language == 1) - return false; - _gm->_state._language = 1; - } else if ((verb == ACTION_WALK) && (obj1._id == MEETUP_EXIT)) { - if (!((_gm->_rooms[AIRLOCK]->getObject(4)->hasProperty(WORN)) && - (_gm->_rooms[AIRLOCK]->getObject(5)->hasProperty(WORN)) && - (_gm->_rooms[AIRLOCK]->getObject(6)->hasProperty(WORN)))) { - _vm->renderMessage(kStringArsanoEntrance26); - _gm->_rooms[AIRLOCK]->getObject(4)->setProperty(WORN); - _gm->_rooms[AIRLOCK]->getObject(5)->setProperty(WORN); - _gm->_rooms[AIRLOCK]->getObject(6)->setProperty(WORN); - _gm->waitOnInput(_gm->_messageDuration); - _vm->removeMessage(); - } - return false; - } else if ((verb == ACTION_USE) && Object::combine(obj1, obj2, KNIFE, PORTER)) - _vm->renderMessage(kStringArsanoEntrance27); - else - return false; - - return true; -} - -ArsanoRemaining::ArsanoRemaining(SupernovaEngine *vm, GameManager1 *gm) { - _vm = vm; - _gm = gm; - - _fileNumber = 28; - _id = REST; - _shown[0] = kShownTrue; - - _objectState[0] = Object(_id, kStringStaircase,kStringDefaultDescription,NULLOBJECT,EXIT,0,0,0,ENTRANCE,17); - _objectState[1] = Object(_id, kStringChair,kStringDefaultDescription,NULLOBJECT,EXIT,1,1,0,ROGER,2); - _objectState[2] = Object(_id, kStringShoes,kStringShoesDescription,NULLOBJECT,NULLTYPE,2,2,0); - - _chewing = kShownTrue; - _i = 0; -} - -void ArsanoRemaining::animation() { - switch (_i) { - case 0: - _vm->renderImage(1); - _vm->renderImage(_gm->invertSection(4)); - break; - case 1: - _vm->renderImage(_gm->invertSection(1)); - _vm->renderImage(4); - break; - case 2: - _vm->renderImage(2); - _vm->renderImage(_gm->invertSection(4)); - break; - - case 3: - _vm->renderImage(7); // Dragon - _vm->renderImage(_gm->invertSection(2)); - _vm->renderImage(4); - break; - case 4: - _vm->renderImage(8); - setSectionVisible(7, false); - _vm->renderImage(2); - _vm->renderImage(_gm->invertSection(4)); - break; - case 5: - _vm->renderImage(_gm->invertSection(8)); - _vm->renderImage(_gm->invertSection(2)); - break; - case 6: - _vm->renderImage(3); - _vm->renderImage(2); - break; - case 7: - _vm->renderImage(_gm->invertSection(3)); - _vm->renderImage(_gm->invertSection(2)); - break; - case 8: - _vm->renderImage(3); - break; - case 9: - _vm->renderImage(14); // Card Player 1 - _vm->renderImage(4); - _vm->renderImage(_gm->invertSection(3)); - break; - case 10: - _vm->renderImage(15); - _vm->renderImage(14); - _vm->renderImage(_gm->invertSection(4)); - _vm->renderImage(3); - break; - case 11: - _vm->renderImage(16); - setSectionVisible(15, false); - _vm->renderImage(4); - _vm->renderImage(_gm->invertSection(3)); - break; - case 12: - _vm->renderImage(17); - setSectionVisible(16, false); - _vm->renderImage(_gm->invertSection(4)); - _vm->renderImage(3); - break; - case 13: - _vm->renderImage(_gm->invertSection(17)); - _vm->renderImage(4); - _vm->renderImage(_gm->invertSection(3)); - break; - case 14: - _vm->renderImage(_gm->invertSection(4)); - break; - case 15: - _vm->renderImage(6); - break; - case 16: - _vm->renderImage(18); // Card Player 2 - _vm->renderImage(5); - break; - case 17: - _vm->renderImage(19); - setSectionVisible(18, false); - _vm->renderImage(_gm->invertSection(5)); - break; - case 18: - _vm->renderImage(20); - setSectionVisible(19, false); - _vm->renderImage(5); - break; - case 19: - _vm->renderImage(21); - setSectionVisible(20, false); - _vm->renderImage(_gm->invertSection(5)); - break; - case 20: - _vm->renderImage(_gm->invertSection(21)); - _vm->renderImage(5); - break; - case 21: - _vm->renderImage(_gm->invertSection(5)); - break; - case 22: - _vm->renderImage(5); - break; - case 23: - _vm->renderImage(10); - _chewing = false; - _vm->renderImage(_gm->invertSection(5)); - break; - case 24: - _vm->renderImage(11); - setSectionVisible(10, false); - break; - case 25: - _vm->renderImage(12); - setSectionVisible(11, false); - break; - case 26: - _vm->renderImage(13); - setSectionVisible(12, false); - break; - case 27: - _vm->renderImage(12); - setSectionVisible(13, false); - break; - case 28: - _vm->renderImage(11); - setSectionVisible(12, false); - break; - case 29: - _vm->renderImage(10); - setSectionVisible(11, false); - break; - case 30: - _vm->renderImage(_gm->invertSection(10)); - _chewing = true; - break; - case 31: - _vm->renderImage(22); // Card Player 3 - break; - case 32: - _vm->renderImage(_gm->invertSection(22)); - break; - case 33: - _vm->renderImage(_gm->invertSection(6)); - break; - case 34: - _vm->renderImage(4); - } - - _i = (_i + 1) % 35; - if (_chewing) { - if (isSectionVisible(9)) - _vm->renderImage(_gm->invertSection(9)); - else - _vm->renderImage(9); - } - _gm->setAnimationTimer(3); -} - -ArsanoRoger::ArsanoRoger(SupernovaEngine *vm, GameManager1 *gm) { - _vm = vm; - _gm = gm; - - _fileNumber = 29; - _id = ROGER; - _shown[0] = kShownTrue; - - _objectState[0] = Object(_id, kStringExit,kStringDefaultDescription,NULLOBJECT,EXIT,255,255,0,REST,19); - _objectState[1] = Object(_id, kStringFrogFace,kStringDefaultDescription,ROGER_W,TALK,0,0,0); - _objectState[2] = Object(_id, kStringScrible,kStringScribleDescription,NULLOBJECT,NULLTYPE,3,3,0); - _objectState[3] = Object(_id, kStringWallet,kStringDefaultDescription,WALLET,TAKE,1,1,4); - _objectState[4] = Object(_id, kStringMenu,kStringMenuDescription,NULLOBJECT,UNNECESSARY,2,2,0); - _objectState[5] = Object(_id, kStringCup,kStringCupDescription,CUP,UNNECESSARY,4,4,0); - _objectState[6] = Object(_id, kStringChessGame,kStringDefaultDescription,NULLOBJECT,UNNECESSARY,255,255,0); - _objectState[7] = Object(_id, kStringBill,kStringBillDescription,NULLOBJECT,TAKE|COMBINABLE,255,255,0); - _objectState[8] = Object(_id, kStringKeycard3,kStringDefaultDescription,KEYCARD_R,TAKE|COMBINABLE,255,255,0); - - _dialog1[0] = kStringDialogArsanoRoger1; - _dialog1[1] = kStringDialogArsanoRoger2; - _dialog1[2] = kStringDialogArsanoRoger3; - _dialog1[3] = kStringDialogSeparator; - - _eyewitness = 5; - _hands = 0; -} - -void ArsanoRoger::onEntrance() { - if (!sentenceRemoved(0, 2)) { - _gm->say(kStringArsanoRoger1); - _gm->reply(kStringArsanoRoger2, 2, 2 + 128); - removeSentence(0, 2); - } -} - -void ArsanoRoger::animation() { - if (isSectionVisible(1)) - _vm->renderImage(_gm->invertSection(1)); - else if (isSectionVisible(10)) { - _vm->renderImage(12); - setSectionVisible(10, false); - setSectionVisible(12, false); - } else if (_eyewitness) { - --_eyewitness; - } else { - _eyewitness = 20; - if (isSectionVisible(3)) - _vm->renderImage(10); - else - _vm->renderImage(1); - } - - if (isSectionVisible(3)) { - setSectionVisible(5 + _hands, false); - _hands = (_hands + 1) % 5; - _vm->renderImage(5 + _hands); - } - _gm->setAnimationTimer(4); -} - -bool ArsanoRoger::interact(Action verb, Object &obj1, Object &obj2) { - static byte row1[6] = {1, 1, 1, 1, 0, 0}; - - if ((verb == ACTION_TAKE) && (obj1._id == WALLET)) { - if (isSectionVisible(3)) { - _gm->great(0); - return false; - } - _gm->reply(kStringArsanoRoger3, 2, 2 + 128); - } else if ((verb == ACTION_USE) && (obj1._id == CUP)) - _vm->renderMessage(kStringArsanoRoger4); - else if ((verb == ACTION_TALK) && (obj1._id == ROGER_W)) { - if (isSectionVisible(3)) - _vm->renderMessage(kStringArsanoRoger5); - else { - switch (_gm->dialog(4, row1, _dialog1, 1)) { - case 0: - _gm->reply(kStringArsanoRoger6, 2, 2 + 128); - _gm->reply(kStringArsanoRoger7, 2, 2 + 128); - break; - case 1: - _gm->reply(kStringArsanoRoger8, 2, 2 + 128); - _gm->reply(kStringArsanoRoger9, 2, 2 + 128); - _gm->say(kStringArsanoRoger10); - break; - case 2: - _gm->reply(kStringArsanoRoger11, 2, 2 + 128); - _gm->say(kStringArsanoRoger12); - _gm->reply(kStringArsanoRoger13, 2, 2 + 128); - _gm->say(kStringArsanoRoger14); - _gm->reply(kStringArsanoRoger15, 2, 2 + 128); - _gm->reply(kStringArsanoRoger16, 2, 2 + 128); - _gm->say(kStringArsanoRoger17); - _gm->say(kStringArsanoRoger18); - _gm->reply(kStringArsanoRoger19, 2, 2 + 128); - _gm->say(kStringArsanoRoger20); - _gm->say(kStringArsanoRoger21); - _gm->reply(kStringArsanoRoger22, 2, 2 + 128); - _gm->say(kStringArsanoRoger23); - _gm->reply(kStringArsanoRoger24, 2, 2 + 128); - _gm->reply(kStringArsanoRoger25, 2, 2 + 128); - _gm->say(kStringArsanoRoger26); - _gm->reply(kStringArsanoRoger27, 2, 2 + 128); - _gm->reply(kStringArsanoRoger28, 2, 2 + 128); - _gm->say(kStringArsanoRoger29); - _gm->reply(kStringArsanoRoger30, 2, 2 + 128); - _gm->reply(kStringArsanoRoger31, 2, 2 + 128); - _gm->say(kStringArsanoRoger32); - _gm->reply(kStringArsanoRoger33, 2, 2 + 128); - _gm->say(kStringArsanoRoger34); - _gm->reply(kStringArsanoRoger35, 2, 2 + 128); - } - } - } else if (((verb == ACTION_USE) && Object::combine(obj1, obj2, CHESS, ROGER_W)) || - ((verb == ACTION_GIVE) && (obj1._id == CHESS) && (obj2._id == ROGER_W))) { - _vm->renderImage(11); - _gm->great(0); - _gm->say(kStringArsanoRoger36); - _gm->reply(kStringArsanoRoger37, 2, 2 + 128); - _gm->say(kStringArsanoRoger38); - _vm->paletteFadeOut(); - _gm->_inventory.remove(*_gm->_rooms[CABIN_R3]->getObject(0)); // Chess board - g_system->fillScreen(kColorBlack); - _vm->_screen->setGuiBrightness(255); - _vm->paletteBrightness(); - _vm->renderMessage(kStringArsanoRoger39); - _gm->waitOnInput(_gm->_messageDuration); - _vm->removeMessage(); - _vm->_screen->setGuiBrightness(0); - _vm->paletteBrightness(); - _gm->_time += ticksToMsec(125000); // 2 hours - _gm->_state._alarmOn = (_gm->_state._timeAlarm > _gm->_time); - _gm->_state._eventTime = _gm->_time + ticksToMsec(4000); - _gm->_state._eventCallback = kSupernovaFn; - setSectionVisible(11, false); - setSectionVisible(1, false); - _vm->renderRoom(*this); - _vm->renderImage(3); - getObject(3)->_click = 5; - getObject(5)->_click = 6; - getObject(6)->_click = 7; - _vm->paletteFadeIn(); - _vm->renderMessage(kStringArsanoRoger40); - _gm->waitOnInput(_gm->_messageDuration); - _vm->removeMessage(); - } else - return false; - - return true; -} - -ArsanoGlider::ArsanoGlider(SupernovaEngine *vm, GameManager1 *gm) { - _vm = vm; - _gm = gm; - - _fileNumber = 19; - _id = GLIDER; - _shown[0] = kShownTrue; - _sinus = 0; - - _objectState[0] = Object(_id, kStringExit,kStringDefaultDescription,NULLOBJECT,EXIT,255,255,0,MEETUP,15); - _objectState[1] = Object(_id, kStringButton,kStringDefaultDescription,GLIDER_BUTTON1,PRESS,0,0,0); - _objectState[2] = Object(_id, kStringButton,kStringDefaultDescription,GLIDER_BUTTON2,PRESS,1,1,0); - _objectState[3] = Object(_id, kStringButton,kStringDefaultDescription,GLIDER_BUTTON3,PRESS,2,2,0); - _objectState[4] = Object(_id, kStringButton,kStringDefaultDescription,GLIDER_BUTTON4,PRESS,3,3,0); - _objectState[5] = Object(_id, kStringKeycard,kStringDefaultDescription,GLIDER_KEYCARD,TAKE|COMBINABLE,255,255,0); - _objectState[6] = Object(_id, kStringSlot,kStringDefaultDescription,GLIDER_SLOT,COMBINABLE,4,4,0); - _objectState[7] = Object(_id, kStringCompartment,kStringDefaultDescription,NULLOBJECT,OPENABLE,5,6,6); - _objectState[8] = Object(_id, kStringKeyboard,kStringDefaultDescription,GLIDER_BUTTONS,NULLTYPE,7,7,0); - _objectState[9] = Object(_id, kStringAnnouncement,kStringAnnouncementDescription,GLIDER_DISPLAY,NULLTYPE,8,8,0); - _objectState[10] = Object(_id, kStringInstruments,kStringAnnouncementDescription,GLIDER_INSTRUMENTS,NULLTYPE,9,9,0); -} - -void ArsanoGlider::animation() { - if (isSectionVisible(8)) { - setSectionVisible(24 + _sinus, false); - _sinus = (_sinus + 1) % 14; - _vm->renderImage(24 + _sinus); - } else if (isSectionVisible(24 + _sinus)) - _vm->renderImage(_gm->invertSection(24 + _sinus)); - - _gm->setAnimationTimer(2); -} - -bool ArsanoGlider::interact(Action verb, Object &obj1, Object &obj2) { - static char l, r; - if ((verb == ACTION_USE) && Object::combine(obj1, obj2, KEYCARD_R, GLIDER_SLOT)) { - _vm->renderImage(5); - _gm->wait(7); - _vm->renderImage(8); - getObject(5)->_click = 10; - _gm->_inventory.remove(*_gm->_rooms[ROGER]->getObject(8)); - } else if (((verb == ACTION_TAKE) || (verb == ACTION_PULL)) && - (obj1._id == GLIDER_KEYCARD)) { - _vm->renderImage(_gm->invertSection(5)); - _vm->renderImage(_gm->invertSection(8)); - getObject(5)->_click = 255; - _gm->takeObject(*_gm->_rooms[ROGER]->getObject(8)); - for (int i = 9; i <= 22; i++) - _vm->renderImage(_gm->invertSection(i)); - l = r = 0; - } else if ((verb == ACTION_PRESS) && - (obj1._id >= GLIDER_BUTTON1) && (obj1._id <= GLIDER_BUTTON4)) { - int i = obj1._id - GLIDER_BUTTON1 + 1; - _vm->renderImage(i); - if (isSectionVisible(8)) { - l = 0; - r = 0; - for (int j = 1; j < 8; j++) { - if (isSectionVisible(j + 8)) - l = j; - if (isSectionVisible(j + 15)) - r = j; - } - switch (i) { - case 1: - if (l < 7) { - l++; - _vm->renderImage(l + 8); - } - break; - case 3: - if (r < 7) { - r++; - _vm->renderImage(r + 15); - } - break; - case 2: - if (l) { - _vm->renderImage(_gm->invertSection(l + 8)); - l--; - } - break; - case 4: - if (r) { - _vm->renderImage(_gm->invertSection(r + 15)); - r--; - } - } - } - _gm->wait(4); - _vm->renderImage(_gm->invertSection(i)); - } else if ((verb == ACTION_USE) && (obj1._id == GLIDER_BUTTONS)) - _vm->renderMessage(kStringArsanoGlider1); - else - return false; - - return true; -} - -ArsanoMeetup2::ArsanoMeetup2(SupernovaEngine *vm, GameManager1 *gm) { - _vm = vm; - _gm = gm; - - _fileNumber = 38; - _id = MEETUP2; - _shown[0] = kShownTrue; - - _objectState[0] = Object(_id, kStringRoger, kStringDefaultDescription, ROGER_W, TALK, 255, 255, 0); - _objectState[1] = Object(_id, kStringSpaceshift, kStringDefaultDescription, SPACESHIP, COMBINABLE, 255, 255, 0); - _objectState[2] = Object(_id, kStringCave, kStringDefaultDescription, NULLOBJECT, EXIT, 255, 255, 0, CAVE, 22); - - _dialog1[0] = kStringDialogArsanoMeetup2_1; - _dialog1[1] = kStringDialogArsanoMeetup2_2; - _dialog2[0] = kStringDialogArsanoMeetup2_3; - _dialog2[1] = kStringDialogArsanoMeetup2_4; - _dialog3[0] = kStringDialogArsanoMeetup2_5; - _dialog3[1] = kStringDialogArsanoMeetup2_6; - _dialog3[2] = kStringDialogArsanoMeetup2_7; - _dialog3[3] = kStringDialogArsanoMeetup2_8; - _dialog4[0] = kStringDialogArsanoMeetup2_9; - _dialog4[1] = kStringDialogArsanoMeetup2_10; - _dialog4[2] = kStringDialogArsanoMeetup2_11; -} - -void ArsanoMeetup2::onEntrance() { - if (sentenceRemoved(0, 1)) { - if (sentenceRemoved(1, 1)) - _vm->renderMessage(kStringArsanoMeetup2_2); // All spaceships have left the planet, except one ... - else - shipStart(); - } else if (sentenceRemoved(1, 1)) - _vm->renderMessage(kStringArsanoMeetup2_1); // All spaceships have left the planet - - addAllSentences(1); -} - -bool ArsanoMeetup2::interact(Action verb, Object &obj1, Object &obj2) { - static byte row1[6] = {1, 1, 0, 0, 0, 0}; - static byte row2[6] = {1, 1, 0, 0, 0, 0}; - static byte row3[6] = {1, 1, 1, 1, 0, 0}; - static byte row4[6] = {2, 1, 0, 0, 0, 0}; - - if (((verb == ACTION_WALK) && - ((obj1._id == SPACESHIP) || (obj1._id == ROGER_W))) || - ((verb == ACTION_TALK) && (obj1._id == ROGER_W))) { - _gm->changeRoom(INTRO); - _vm->setCurrentImage(30); - _vm->renderImage(0); - _vm->paletteBrightness(); - bool found; - if (sentenceRemoved(0, 2) || sentenceRemoved(1, 2)) { - _gm->reply(kStringArsanoMeetup2_3, 1, 1 + 128); - found = !_gm->dialog(2, row4, _dialog4, 0); - if (!(found)) - _gm->reply(kStringArsanoMeetup2_4, 1, 1 + 128); - } else { - _gm->reply(kStringArsanoMeetup2_5, 1, 1 + 128); - _gm->reply(kStringArsanoMeetup2_6, 1, 1 + 128); - found = !_gm->dialog(2, row1, _dialog1, 0); - removeSentence(0, 2); - } - if (found) { - _gm->_inventory.remove(*_gm->_rooms[ROGER]->getObject(3)); - _gm->_inventory.remove(*_gm->_rooms[ROGER]->getObject(7)); - _gm->_inventory.remove(*_gm->_rooms[ROGER]->getObject(8)); - _gm->reply(kStringArsanoMeetup2_7, 1, 1 + 128); - _gm->reply(kStringArsanoMeetup2_8, 1, 1 + 128); - bool flight = _gm->dialog(2, row2, _dialog2, 0); - if (flight) { - _gm->reply(kStringArsanoMeetup2_9, 1, 1 + 128); - _gm->dialog(4, row3, _dialog3, 0); - _gm->reply(kStringArsanoMeetup2_10, 1, 1 + 128); - } else - _gm->reply(kStringArsanoMeetup2_11, 1, 1 + 128); - - _gm->changeRoom(MEETUP2); - _gm->_rooms[MEETUP2]->setSectionVisible(12, false); - _gm->_rooms[MEETUP2]->getObject(0)->_click = 255; - _gm->_rooms[MEETUP2]->getObject(1)->_click = 255; - _vm->renderRoom(*this); - _vm->paletteBrightness(); - shipStart(); - if (flight) { - _vm->setCurrentImage(13); - _vm->renderImage(0); - _vm->paletteBrightness(); - _gm->wait(36); - for (int i = 1; i <= 13; i++) { - if (i > 1) - _vm->renderImage(_gm->invertSection(i - 1)); - _vm->renderImage(i); - _gm->wait(2); - } - _vm->renderImage(_gm->invertSection(13)); - _gm->wait(20); - _vm->setCurrentImage(14); - _vm->renderImage(0); - _vm->paletteBrightness(); - _gm->wait(36); - for (int i = 1; i <= 13; i++) { - if (i > 1) - _vm->renderImage(_gm->invertSection(i - 1)); - _vm->renderImage(i); - _gm->wait(2); - } - _vm->renderImage(_gm->invertSection(13)); - _gm->wait(9); - _vm->playSound(kAudioCrash); - for (int i = 14; i <= 19; i++) { - _vm->renderImage(i); - _gm->wait(3); - } - _vm->paletteFadeOut(); - _vm->setCurrentImage(11); - _vm->renderImage(0); - _vm->paletteFadeIn(); - _gm->wait(18); - _vm->renderMessage(kStringArsanoMeetup2_12); - _gm->great(0); - _gm->waitOnInput(_gm->_messageDuration); - _vm->removeMessage(); - _vm->paletteFadeOut(); - g_system->fillScreen(kColorBlack); - _gm->_state._dream = false; - if (!_vm->loadGame(kSleepAutosaveSlot)) - _vm->errorTempSave(false); - _gm->loadTime(); - _gm->_rooms[CAVE]->getObject(1)->_exitRoom = MEETUP3; - _gm->_state._dream = true; - } - } else { - _gm->changeRoom(MEETUP2); - _vm->renderRoom(*this); - } - } else if ((verb == ACTION_USE) && Object::combine(obj1, obj2, KEYCARD_R, SPACESHIP)) - _vm->renderMessage(kStringArsanoMeetup2_13); - else - return false; - - return true; -} - -void ArsanoMeetup2::shipStart() { - _gm->wait(12); - for (int i = 2; i <= 11; ++i) { - if (i >= 9) - _vm->renderImage(i - 1 + 128); - else - setSectionVisible(i - 1, false); - _vm->renderImage(i); - _gm->wait(2); - } - _vm->renderImage(11 + 128); -} - -ArsanoMeetup3::ArsanoMeetup3(SupernovaEngine *vm, GameManager1 *gm) { - _vm = vm; - _gm = gm; - - _fileNumber = 39; - _id = MEETUP3; - _shown[0] = kShownTrue; - - _objectState[0] = Object(_id, kStringUfo,kStringUfoDescription,UFO,EXIT,0,0,0,NULLROOM,3); - _objectState[1] = Object(_id, kStringStar,kStringDefaultDescription,STAR,NULLTYPE,1,1,0); - _objectState[2] = Object(_id, kStringCave,kStringDefaultDescription,NULLOBJECT,EXIT,255,255,0,CAVE,22); - - _dialog2[0] = kStringArsanoDialog1; - _dialog2[1] = kStringDialogArsanoMeetup3_1; - _dialog2[2] = kStringDialogArsanoMeetup3_2; - _dialog2[3] = kStringDialogArsanoMeetup3_3; - _dialog3[0] = kStringDialogArsanoMeetup3_4; - _dialog3[1] = kStringDialogArsanoMeetup3_5; - - _dialogsX[0] = kStringDialogX1; - _dialogsX[1] = kStringDialogX2; - _dialogsX[2] = kStringDialogX3; -} - -bool ArsanoMeetup3::interact(Action verb, Object &obj1, Object &obj2) { - byte row2[6] = {1, 1, 1, 1, 0, 0}; - byte row3[6] = {1, 1, 0, 0, 0, 0}; - byte rowsX[6] = {1, 1, 1, 0, 0, 0}; - - if ((verb == ACTION_WALK) && (obj1._id == STAR)) - _vm->renderMessage(kStringArsanoMeetup2); - else if ((verb == ACTION_LOOK) && (obj1._id == STAR)) { - _vm->setCurrentImage(26); - _vm->renderImage(0); - _vm->paletteBrightness(); - _gm->getInput(); - g_system->fillScreen(kColorBlack); - _vm->renderRoom(*this); - } else if ((verb == ACTION_WALK) && (obj1._id == UFO)) { - g_system->fillScreen(kColorBlack); - _vm->setCurrentImage(36); - _vm->renderImage(0); - _vm->paletteBrightness(); - _gm->dialog(3, rowsX, _dialogsX, 0); - _vm->renderImage(1); - _gm->wait(3); - _vm->renderImage(2); - _gm->wait(3); - _vm->renderImage(3); - _gm->wait(6); - _vm->renderImage(4); - _vm->playSound(kAudioGunShot); - - while (_vm->_sound->isPlaying()) - _gm->wait(1); - - _vm->renderImage(5); - _gm->wait(3); - _vm->renderImage(4); - _vm->playSound(kAudioGunShot); - - while (_vm->_sound->isPlaying()) - _gm->wait(1); - - _vm->renderImage(5); - _vm->paletteFadeOut(); - _gm->wait(12); - _vm->setCurrentImage(0); - _vm->renderImage(0); - _vm->paletteFadeIn(); - _gm->wait(18); - _gm->reply(kStringArsanoMeetup3_1, 2, 2 + 128); - _gm->wait(10); - _gm->reply(kStringArsanoMeetup3_2, 1, 1 + 128); - - do { - int i = _gm->dialog(4, row2, _dialog2, 2); - switch (i) { - case 0: - _gm->reply(kStringArsanoMeetup3_3, 1, 1 + 128); - _gm->reply(kStringArsanoMeetup3_4, 1, 1 + 128); - break; - case 1: - _gm->reply(kStringArsanoMeetup3_5, 2, 2 + 128); - _gm->say(kStringArsanoMeetup3_6); - _gm->reply(kStringArsanoMeetup3_7, 2, 2 + 128); - _gm->reply(kStringArsanoMeetup3_8, 2, 2 + 128); - _gm->reply(kStringArsanoMeetup3_9, 2, 2 + 128); - _gm->reply(kStringArsanoMeetup3_10, 2, 2 + 128); - _gm->reply(kStringArsanoMeetup3_11, 2, 2 + 128); - if (_gm->dialog(2, row3, _dialog3, 0)) { - _gm->reply(kStringArsanoMeetup3_12, 2, 2 + 128); - _gm->say(kStringArsanoMeetup3_13); - } - _gm->reply(kStringArsanoMeetup3_14, 2, 2 + 128); - _gm->reply(kStringArsanoMeetup3_15, 2, 2 + 128); - _gm->reply(kStringArsanoMeetup3_16, 2, 2 + 128); - _gm->reply(kStringArsanoMeetup3_17, 2, 2 + 128); - if (_gm->dialog(2, row3, _dialog3, 0)) { - _gm->reply(kStringArsanoMeetup3_12, 2, 2 + 128); - _gm->say(kStringArsanoMeetup3_13); - } - _gm->reply(kStringArsanoMeetup3_18, 2, 2 + 128); - break; - case 2: - _gm->reply(kStringArsanoMeetup3_19, 2, 2 + 128); - _gm->reply(kStringArsanoMeetup3_20, 2, 2 + 128); - break; - case 3: - _gm->reply(kStringArsanoMeetup3_21, 1, 1 + 128); - _gm->reply(kStringArsanoMeetup3_22, 1, 1 + 128); - _gm->say(kStringArsanoMeetup3_23); - _gm->reply(kStringArsanoMeetup3_24, 1, 1 + 128); - _gm->reply(kStringArsanoMeetup3_25, 1, 1 + 128); - } - removeSentence(2, 2); - } while (!allSentencesRemoved(4, 2)); - _gm->say(kStringArsanoMeetup3_26); - _gm->reply(kStringArsanoMeetup3_27, 1, 1 + 128); - _gm->reply(kStringArsanoMeetup3_28, 1, 1 + 128); - _vm->paletteFadeOut(); - // Remove all objects from the inventory except the Knife, Watch and Discman - bool has_knife = _gm->_rooms[INTRO]->getObject(1)->hasProperty(CARRIED); - bool has_watch = _gm->_rooms[INTRO]->getObject(2)->hasProperty(CARRIED); - bool has_discman = _gm->_rooms[INTRO]->getObject(3)->hasProperty(CARRIED); - _gm->_inventory.clear(); - _gm->_inventoryScroll = 0; - if (has_knife) - _gm->_inventory.add(*_gm->_rooms[INTRO]->getObject(1)); - if (has_watch) - _gm->_inventory.add(*_gm->_rooms[INTRO]->getObject(2)); - if (has_discman) - _gm->_inventory.add(*_gm->_rooms[INTRO]->getObject(3)); - _gm->changeRoom(CELL); - _gm->_state._dream = true; - } else - return false; - - return true; -} - -// Axacuss -AxacussCell::AxacussCell(SupernovaEngine *vm, GameManager1 *gm) { - _vm = vm; - _gm = gm; - - _fileNumber = 43; - _id = CELL; - _shown[0] = kShownTrue; - _shown[1] = kShownTrue; - _shown[31] = kShownTrue; - - _objectState[0] = Object(_id, kStringButton,kStringDefaultDescription,CELL_BUTTON,PRESS,1,1,0); - _objectState[1] = Object(_id, kStringDoor,kStringDefaultDescription,CELL_DOOR,EXIT|OPENABLE|CLOSED,0,0,31+128,CORRIDOR4,1); - _objectState[2] = Object(_id, kStringTray,kStringTrayDescription,TRAY,UNNECESSARY,255,255,0); - _objectState[3] = Object(_id, kStringLamp,kStringLampDescription,NULLOBJECT,COMBINABLE,3,3,0); - _objectState[4] = Object(_id, kStringEyes,kStringEyesDescription,NULLOBJECT,NULLTYPE,4,4,0); - _objectState[5] = Object(_id, kStringWire,kStringDefaultDescription,CELL_WIRE,COMBINABLE|TAKE,6,6,0); - _objectState[6] = Object(_id, kStringSocket,kStringSocketDescription,SOCKET,COMBINABLE,5,5,0); - _objectState[7] = Object(_id, kStringMetalBlock,kStringMetalBlockDescription,MAGNET,TAKE|COMBINABLE,255,255,30); - _objectState[8] = Object(_id, kStringRobot,kStringRobotDescription,NULLOBJECT,NULLTYPE,255,255,0); - _objectState[9] = Object(_id, kStringTable,kStringTableDescription,CELL_TABLE,COMBINABLE,2,2,0); -} - -void AxacussCell::onEntrance() { - if (_gm->_state._dream) { - _vm->renderMessage(kStringAxacussCell_1); - _gm->_time = ticksToMsec(500000); - _gm->_state._alarmOn = (_gm->_state._timeAlarm > _gm->_time); - _gm->_state._powerOff = false; - _gm->_state._dream = false; - } -} - -void AxacussCell::animation() { - ++_gm->_state._timeRobot; - - if (_gm->_state._timeRobot == 299) { - _vm->renderImage(_gm->invertSection(31)); - _vm->renderImage(28); - getObject(0)->_click = 255; - getObject(1)->resetProperty(EXIT | OPENABLE | OPENED | CLOSED); - } else if ((_gm->_state._timeRobot >= 301) && (_gm->_state._timeRobot <= 320)) { - _vm->renderImage(_gm->invertSection(329 - _gm->_state._timeRobot)); - _vm->renderImage(328 - _gm->_state._timeRobot); - } else if (_gm->_state._timeRobot == 321) { - _vm->renderImage(31); - setSectionVisible(8, false); - getObject(0)->_click = 1; - getObject(1)->resetProperty(EXIT | OPENABLE | CLOSED); - } - - if (_gm->_state._timeRobot == 599) { - _vm->renderImage(_gm->invertSection(31)); - _vm->renderImage(8); - getObject(0)->_click = 255; - getObject(1)->resetProperty(EXIT | OPENABLE | OPENED | CLOSED); - } else if ((_gm->_state._timeRobot >= 601) && (_gm->_state._timeRobot <= 620)) { - _vm->renderImage(_gm->_state._timeRobot - 593 + 128); - _vm->renderImage(_gm->_state._timeRobot - 592); - } else if (_gm->_state._timeRobot == 621) { - _vm->renderImage(31); - setSectionVisible(28, false); - getObject(0)->_click = 1; - getObject(1)->resetProperty(EXIT | OPENABLE | CLOSED); - } else if (_gm->_state._timeRobot == 700) - _gm->_state._timeRobot = 0; - else if (_gm->_state._timeRobot == 10002) { - _vm->renderImage(18 + 128); - _vm->renderImage(29); - _vm->renderImage(7); - getObject(2)->_click = 13; - } else if (_gm->_state._timeRobot == 10003) { - setSectionVisible(29, false); - _vm->renderImage(30); - getObject(8)->_click = 12; - getObject(7)->_click = 14; - _vm->playSound(kAudioRobotBreaks); - } else if (_gm->_state._timeRobot == 10010) - --_gm->_state._timeRobot; - - if (_gm->_state._timeRobot == 312) { - _vm->renderImage(7); - getObject(2)->_click = 13; - } else if (_gm->_state._timeRobot == 610) { - setSectionVisible(7, false); - getObject(2)->_click = 255; - } - - if ((isSectionVisible(6)) && - ((_gm->_state._timeRobot == 310) || (_gm->_state._timeRobot == 610))) { - _vm->playSound(kAudioRobotShock); - _gm->_state._timeRobot = 10000; - } - - _gm->setAnimationTimer(3); -} - -bool AxacussCell::interact(Action verb, Object &obj1, Object &obj2) { - if ((verb == ACTION_PRESS) && (obj1._id == CELL_BUTTON)) - _vm->renderMessage(kStringAxacussCell_2); - else if ((verb == ACTION_PULL) && (obj1._id == CELL_WIRE) && - !isSectionVisible(2) && - !isSectionVisible(3) && - !isSectionVisible(5)) { - if (isSectionVisible(1)) { - _vm->renderImage(_gm->invertSection(1)); - _vm->renderImage(2); - getObject(5)->_click = 7; - } else if (isSectionVisible(4)) { - _vm->renderImage(_gm->invertSection(4)); - _vm->renderImage(3); - getObject(5)->_click = 8; - } else if (isSectionVisible(6)) { - _vm->renderImage(_gm->invertSection(6)); - _vm->renderImage(5); - getObject(5)->_click = 10; - } - } else if ((verb == ACTION_USE) && Object::combine(obj1, obj2, CELL_WIRE, SOCKET) && - !isSectionVisible(1) && !isSectionVisible(4) && !isSectionVisible(6)) { - if (isSectionVisible(2)) { - _vm->renderImage(_gm->invertSection(2)); - _vm->renderImage(1); - getObject(5)->_click = 6; - } else if (isSectionVisible(3)) { - _vm->renderImage(_gm->invertSection(3)); - _vm->renderImage(4); - getObject(5)->_click = 9; - } else if (isSectionVisible(5)) { - _vm->renderImage(_gm->invertSection(5)); - _vm->renderImage(6); - getObject(5)->_click = 11; - } else { - _gm->_inventory.remove(*getObject(5)); - _vm->renderImage(4); - getObject(5)->_click = 9; - } - } else if ((verb == ACTION_USE) && Object::combine(obj1, obj2, CELL_WIRE, KNIFE) && - ((isSectionVisible(1)) || (isSectionVisible(2)))) { - if (isSectionVisible(1)) - _gm->shock(); - else { - _vm->renderImage(_gm->invertSection(2)); - _vm->renderImage(3); - getObject(5)->_click = 8; - } - } else if ((verb == ACTION_USE) && Object::combine(obj1, obj2, CELL_WIRE, CELL_TABLE) && - !isSectionVisible(1) && - !isSectionVisible(2) && - !isSectionVisible(5) && - !isSectionVisible(6)) { - if (isSectionVisible(3)) { - _vm->renderImage(_gm->invertSection(3)); - _vm->renderImage(5); - getObject(5)->_click = 10; - } else if (isSectionVisible(4)) { - _vm->renderImage(_gm->invertSection(4)); - _vm->renderImage(6); - _gm->shock(); - } else { - _gm->_inventory.remove(*getObject(5)); - _vm->renderImage(5); - getObject(5)->_click = 10; - } - } else if ((verb == ACTION_TAKE) && (obj1._id == CELL_WIRE) && !(obj1.hasProperty(CARRIED))) { - if (isSectionVisible(3)) { - _vm->renderImage(_gm->invertSection(3)); - _gm->takeObject(obj1); - } else if (isSectionVisible(5)) { - _vm->renderImage(_gm->invertSection(5)); - _gm->takeObject(obj1); - } else - _vm->renderMessage(kStringAxacussCell_3); - } else if ((verb == ACTION_WALK) && (obj1._id == CELL_DOOR) && (obj1.hasProperty(OPENED))) { - if (isSectionVisible(30) || isSectionVisible(29)) - return false; - _vm->playSound(kAudioGunShot); - - while (_vm->_sound->isPlaying()) - _gm->wait(1); - - _vm->playSound(kAudioGunShot); - _vm->playSound(kAudioGunShot); - _gm->dead(kStringAxacussCell_4); - } else if ((verb == ACTION_USE) && (obj1._id == TRAY)) - _vm->renderMessage(kStringAxacussCell_5); - else if ((verb == ACTION_TAKE) && (obj1._id == MAGNET)) { - if (isSectionVisible(6)) - _gm->shock(); - _gm->takeObject(obj1); - _vm->renderMessage(kStringOk); - } else - return false; - - return true; -} - -AxacussCorridor1::AxacussCorridor1(SupernovaEngine *vm, GameManager1 *gm) { - _vm = vm; - _gm = gm; - - _fileNumber = 16; - _id = CORRIDOR1; - _shown[0] = kShownTrue; - _shown[3] = kShownTrue; - _shown[4] = kShownTrue; - _shown[5] = kShownTrue; - _shown[13] = kShownTrue; - _shown[21] = kShownTrue; - _shown[23] = kShownTrue; - _shown[25] = kShownTrue; - - _objectState[0] = Object(_id, kStringExit,kStringDefaultDescription,NULLOBJECT,EXIT,2,2,0,GUARD3,2); - _objectState[1] = Object(_id, kStringExit,kStringDefaultDescription,NULLOBJECT,EXIT,3,3,0,CORRIDOR2,22); -} - -void AxacussCorridor1::onEntrance() { - _gm->corridorOnEntrance(); -} - - -AxacussCorridor2::AxacussCorridor2(SupernovaEngine *vm, GameManager1 *gm) { - _vm = vm; - _gm = gm; - - _fileNumber = 16; - _id = CORRIDOR2; - _shown[0] = kShownTrue; - _shown[2] = kShownTrue; - _shown[3] = kShownTrue; - _shown[4] = kShownTrue; - _shown[5] = kShownTrue; - _shown[17] = kShownTrue; - _shown[21] = kShownTrue; - _shown[24] = kShownTrue; - - _objectState[0] = Object(_id, kStringExit,kStringDefaultDescription,NULLOBJECT,EXIT,2,2,0,CORRIDOR1,2); - _objectState[1] = Object(_id, kStringExit,kStringDefaultDescription,NULLOBJECT,EXIT,3,3,0,CORRIDOR3,22); - _objectState[2] = Object(_id, kStringExit,kStringDefaultDescription,NULLOBJECT,EXIT,1,1,0,CORRIDOR4,14); -} - -void AxacussCorridor2::onEntrance() { - _gm->corridorOnEntrance(); -} - -AxacussCorridor3::AxacussCorridor3(SupernovaEngine *vm, GameManager1 *gm) { - _vm = vm; - _gm = gm; - - _fileNumber = 16; - _id = CORRIDOR3; - _shown[0] = kShownTrue; - _shown[3] = kShownTrue; - _shown[5] = kShownTrue; - _shown[19] = kShownTrue; - _shown[23] = kShownTrue; - - _objectState[0] = Object(_id, kStringExit,kStringDefaultDescription,NULLOBJECT,EXIT,2,2,0,CORRIDOR2,2); -} - -void AxacussCorridor3::onEntrance() { - _gm->corridorOnEntrance(); -} - -void AxacussCorridor4::onEntrance() { - _gm->great(4); - _gm->corridorOnEntrance(); - if (_gm->_rooms[GUARD]->isSectionVisible(1)) - _gm->busted(0); -} - -AxacussCorridor4::AxacussCorridor4(SupernovaEngine *vm, GameManager1 *gm) { - _vm = vm; - _gm = gm; - - _fileNumber = 16; - _id = CORRIDOR4; - _shown[0] = kShownTrue; - _shown[1] = kShownTrue; - _shown[2] = kShownTrue; - _shown[8] = kShownTrue; - _shown[9] = kShownTrue; - _shown[11] = kShownTrue; - _shown[15] = kShownTrue; - _shown[18] = kShownTrue; - _shown[20] = kShownTrue; - _shown[26] = kShownTrue; - - _objectState[0] = Object(_id, kStringExit,kStringDefaultDescription,NULLOBJECT,EXIT,0,0,0,CORRIDOR2,10); - _objectState[1] = Object(_id, kStringExit,kStringDefaultDescription,NULLOBJECT,EXIT,1,1,0,GUARD,14); - _objectState[2] = Object(_id, kStringCellDoor,kStringCellDoorDescription,DOOR,EXIT|OPENABLE|OPENED|CLOSED,7,7,0,CELL,16); - _objectState[3] = Object(_id, kStringLaptop,kStringDefaultDescription,NEWSPAPER,TAKE,6,6,8); - _objectState[4] = Object(_id, kStringWristwatch,kStringDefaultDescription,WATCH,TAKE|COMBINABLE,255,255,8); - _objectState[5] = Object(_id, kStringTable,kStringDefaultDescription,TABLE,COMBINABLE,5,5,0); -} - -void AxacussCorridor4::animation() { -} - -bool AxacussCorridor4::interact(Action verb, Object &obj1, Object &obj2) { - if ((verb == ACTION_TAKE) && (obj1._id == NEWSPAPER)) { - setSectionVisible(9, false); - _gm->takeObject(obj1); - if (isSectionVisible(29)) - _vm->renderImage(29); - } else if (((verb == ACTION_USE) && Object::combine(obj1, obj2, TABLE, WATCH)) || - ((verb == ACTION_GIVE) && (obj1._id == WATCH) && (obj2._id == TABLE))) { - if (obj1._id == WATCH) - _gm->_inventory.remove(obj1); - else - _gm->_inventory.remove(obj2); - - _vm->renderImage(29); - getObject(4)->_click = 8; - } else if ((verb == ACTION_TAKE) && (obj1._id == WATCH) && !obj1.hasProperty(CARRIED)) { - setSectionVisible(29, false); - getObject(4)->_click = 255; - _gm->takeObject(*_gm->_rooms[INTRO]->getObject(2)); - if (isSectionVisible(9)) - _vm->renderImage(9); - } else - return false; - - return true; -} - -AxacussCorridor5::AxacussCorridor5(SupernovaEngine *vm, GameManager1 *gm) { - _vm = vm; - _gm = gm; - - _fileNumber = 16; - _id = CORRIDOR5; - _shown[0] = kShownTrue; - _shown[3] = kShownTrue; - _shown[4] = kShownTrue; - _shown[5] = kShownTrue; - _shown[12] = kShownTrue; - _shown[22] = kShownTrue; - _shown[23] = kShownTrue; - _shown[24] = kShownTrue; - - _objectState[0] = Object(_id, kStringExit,kStringDefaultDescription,DOOR,EXIT,2,2,0,NULLROOM,2); - _objectState[1] = Object(_id, kStringExit,kStringDefaultDescription,NULLOBJECT,EXIT,3,3,0,CORRIDOR6,22); - - _dialog1[0] = kStringDialogAxacussCorridor5_1; - _dialog1[1] = kStringDialogAxacussCorridor5_2; - _dialog2[0] = kStringDialogAxacussCorridor5_3; - _dialog2[1] = kStringDialogAxacussCorridor5_4; - _dialog3[0] = kStringDialogAxacussCorridor5_5; - _dialog3[1] = kStringDialogAxacussCorridor5_6; - _dialog3[2] = kStringDialogAxacussCorridor5_7; - _dialog3[3] = kStringDialogAxacussCorridor5_7; - - _rows[0] = 1; - _rows[1] = 1; - _rows[2] = 1; - _rows[3] = 1; - _rows[4] = 0; - _rows[5] = 0; -} - -void AxacussCorridor5::onEntrance() { - _gm->corridorOnEntrance(); -} - -bool AxacussCorridor5::handleMoneyDialog() { - if (_gm->dialog(2, _rows, _dialog2, 0) == 0) { - _gm->reply(kStringAxacussCorridor5_5, 1, 1 + 128); - addAllSentences(2); - if (_gm->_state._money == 0) { - removeSentence(2, 2); - removeSentence(3, 2); - } else { - Common::String string = _vm->getGameString(kStringDialogAxacussCorridor5_7); - _vm->setGameString(kStringPlaceholder1, Common::String::format(string.c_str(), _gm->_state._money - 200)); - _vm->setGameString(kStringPlaceholder2, Common::String::format(string.c_str(), _gm->_state._money)); - _dialog3[2] = kStringPlaceholder1; - _dialog3[3] = kStringPlaceholder2; - } - switch (_gm->dialog(4, _rows, _dialog3, 2)) { - case 1: - _gm->wait(3); - _vm->renderImage(1); - _vm->playSound(kAudioVoiceHalt); - _vm->renderImage(_gm->invertSection(1)); - _gm->wait(5); - _vm->renderImage(2); - _gm->wait(2); - _gm->shot(3, _gm->invertSection(3)); - break; - case 2: - if (_gm->_state._money > 1100) { - stopInteract(_gm->_state._money - 200); - return true; - } - _gm->reply(kStringAxacussCorridor5_6, 1, 1 + 128); - break; - case 3: - if (_gm->_state._money >= 900) { - stopInteract(_gm->_state._money); - return true; - } - _gm->reply(kStringAxacussCorridor5_6, 1, 1 + 128); - break; - } - } - return false; -} - -void AxacussCorridor5::stopInteract(int sum) { - _gm->reply(kStringAxacussCorridor5_7, 1, 1 + 128); - _gm->great(0); - _gm->changeRoom(ELEVATOR); - _gm->takeMoney(-sum); -} - -bool AxacussCorridor5::interact(Action verb, Object &obj1, Object &obj2) { - if ((verb == ACTION_WALK) && (obj1._id == DOOR)) { - g_system->fillScreen(kColorBlack); - _vm->setCurrentImage(41); - _vm->renderImage(0); - _vm->paletteBrightness(); - if (_gm->_guiEnabled) { - _gm->reply(kStringAxacussCorridor5_1, 1, 1 + 128); - if (handleMoneyDialog()) - return true; - } else { - _gm->_guiEnabled = true; - _gm->reply(kStringAxacussCorridor5_2, 1, 1 + 128); - if (_gm->dialog(2, _rows, _dialog1, 0)) - _gm->reply(kStringAxacussCorridor5_3, 1, 1 + 128); - else { - _gm->reply(kStringAxacussCorridor5_4, 1, 1 + 128); - if (handleMoneyDialog()) - return true; - } - } - g_system->fillScreen(kColorBlack); - return true; - } - return false; -} - -AxacussCorridor6::AxacussCorridor6(SupernovaEngine *vm, GameManager1 *gm) { - _vm = vm; - _gm = gm; - - _fileNumber = 16; - _id = CORRIDOR6; - _shown[0] = kShownTrue; - _shown[3] = kShownTrue; - _shown[4] = kShownTrue; - _shown[5] = kShownTrue; - _shown[6] = kShownTrue; - _shown[22] = kShownTrue; - _shown[24] = kShownTrue; - _shown[25] = kShownTrue; - - _objectState[0] = Object(_id, kStringExit,kStringDefaultDescription,NULLOBJECT,EXIT,2,2,0,CORRIDOR5,2); - _objectState[1] = Object(_id, kStringExit,kStringDefaultDescription,NULLOBJECT,EXIT,3,3,0,CORRIDOR7,22); - _objectState[2] = Object(_id, kStringDoor,kStringDefaultDescription,DOOR,OPENABLE|CLOSED,255,255,0,CORRIDOR8,13); -} - -void AxacussCorridor6::onEntrance() { - _gm->corridorOnEntrance(); -} - -bool AxacussCorridor6::interact(Action verb, Object &obj1, Object &obj2) { - if ((verb == ACTION_CLOSE) && (obj1._id == DOOR) && - (obj1.hasProperty(OPENED))) { - _vm->renderImage(6); - setSectionVisible(7, false); - obj1.resetProperty(EXIT | OPENABLE | CLOSED); - _gm->_rooms[CORRIDOR8]->setSectionVisible(27, false); - _gm->_rooms[CORRIDOR8]->setSectionVisible(28, true); - _gm->_rooms[CORRIDOR8]->getObject(0)->disableProperty(OPENED); - _vm->playSound(kAudioDoorClose); - } else - return false; - - return true; -} - -AxacussCorridor7::AxacussCorridor7(SupernovaEngine *vm, GameManager1 *gm) { - _vm = vm; - _gm = gm; - - _fileNumber = 16; - _id = CORRIDOR7; - _shown[0] = kShownTrue; - _shown[3] = kShownTrue; - _shown[4] = kShownTrue; - _shown[5] = kShownTrue; - _shown[10] = kShownTrue; - _shown[21] = kShownTrue; - _shown[24] = kShownTrue; - _shown[25] = kShownTrue; - - _objectState[0] = Object(_id, kStringExit,kStringDefaultDescription,NULLOBJECT,EXIT,2,2,0,CORRIDOR6,2); - _objectState[1] = Object(_id, kStringExit,kStringDefaultDescription,NULLOBJECT,EXIT,3,3,0,GUARD,22); -} - -void AxacussCorridor7::onEntrance() { - _gm->corridorOnEntrance(); -} - -AxacussCorridor8::AxacussCorridor8(SupernovaEngine *vm, GameManager1 *gm) { - _vm = vm; - _gm = gm; - - _fileNumber = 16; - _id = CORRIDOR8; - _shown[0] = kShownTrue; - _shown[1] = kShownTrue; - _shown[4] = kShownTrue; - _shown[15] = kShownTrue; - _shown[20] = kShownTrue; - _shown[22] = kShownTrue; - _shown[28] = kShownTrue; - - _objectState[0] = Object(_id, kStringDoor,kStringDefaultDescription,DOOR,EXIT|OPENABLE,0,0,0,CORRIDOR6,10); - _objectState[1] = Object(_id, kStringExit,kStringDefaultDescription,NULLOBJECT,EXIT,3,3,0,BCORRIDOR,22); -} - -void AxacussCorridor8::onEntrance() { - _gm->corridorOnEntrance(); -} - -bool AxacussCorridor8::interact(Action verb, Object &obj1, Object &obj2) { - if ((verb == ACTION_OPEN) && (obj1._id == DOOR) && !obj1.hasProperty(OPENED)) { - _vm->renderImage(27); - setSectionVisible(28, false); - obj1.setProperty(OPENED); - _gm->_rooms[CORRIDOR6]->setSectionVisible(6, false); - _gm->_rooms[CORRIDOR6]->setSectionVisible(7, true); - _gm->_rooms[CORRIDOR6]->getObject(2)->resetProperty(EXIT | OPENED | OPENABLE); - _gm->_rooms[CORRIDOR6]->getObject(2)->_click = 4; - _vm->playSound(kAudioDoorOpen); - } else if ((verb == ACTION_CLOSE) && (obj1._id == DOOR) && (obj1._type & OPENED)) { - _vm->renderImage(28); - setSectionVisible(27, false); - obj1.disableProperty(OPENED); - _gm->_rooms[CORRIDOR6]->setSectionVisible(6, true); - _gm->_rooms[CORRIDOR6]->setSectionVisible(7, false); - _gm->_rooms[CORRIDOR6]->getObject(2)->resetProperty(EXIT | CLOSED | OPENABLE); - _vm->playSound(kAudioDoorClose); - } else - return false; - - return true; -} - -AxacussCorridor9::AxacussCorridor9(SupernovaEngine *vm, GameManager1 *gm) { - _vm = vm; - _gm = gm; - - _fileNumber = 16; - _id = CORRIDOR9; - _shown[0] = kShownTrue; - _shown[1] = kShownTrue; - _shown[3] = kShownTrue; - _shown[14] = kShownTrue; - _shown[19] = kShownTrue; - _shown[23] = kShownTrue; - _shown[28] = kShownTrue; - - _objectState[0] = Object(_id, kStringExit,kStringDefaultDescription,NULLOBJECT,EXIT,2,2,0,BCORRIDOR,2); - _objectState[1] = Object(_id, kStringDoor,kStringDefaultDescription,DOOR,EXIT|OPENABLE,0,0,0,GUARD,10); -} - -void AxacussCorridor9::onEntrance() { - _gm->corridorOnEntrance(); -} - -bool AxacussCorridor9::interact(Action verb, Object &obj1, Object &obj2) { - if ((verb == ACTION_CLOSE) && (obj1._id == DOOR) && (obj1.hasProperty(OPENED))) { - _vm->renderImage(28); - setSectionVisible(27, false); - obj1.disableProperty(OPENED); - _gm->_rooms[GUARD]->setSectionVisible(6, false); - _gm->_rooms[GUARD]->getObject(2)->disableProperty(OPENED); - _vm->playSound(kAudioDoorClose); - } else if ((verb == ACTION_OPEN) && (obj1._id == DOOR) && !obj1.hasProperty(OPENED)) { - _vm->renderImage(27); - setSectionVisible(28, false); - obj1.setProperty(OPENED); - _gm->_rooms[GUARD]->setSectionVisible(6, true); - _gm->_rooms[GUARD]->getObject(2)->setProperty(OPENED); - _vm->playSound(kAudioDoorOpen); - if (!_gm->_rooms[GUARD]->isSectionVisible(1)) - _gm->busted(0); - } else - return false; - - return true; -} - -AxacussBcorridor::AxacussBcorridor(SupernovaEngine *vm, GameManager1 *gm) { - _vm = vm; - _gm = gm; - - _fileNumber = 6; - _id = BCORRIDOR; - _shown[0] = kShownTrue; - _shown[3] = kShownTrue; - - _objectState[0] = Object(_id, kStringPillar,kStringDefaultDescription,PILLAR1,NULLTYPE,4,4,0); - _objectState[1] = Object(_id, kStringPillar,kStringDefaultDescription,PILLAR2,NULLTYPE,5,5,0); - _objectState[2] = Object(_id, kStringExit,kStringDefaultDescription,NULLOBJECT,EXIT,6,6,0,CORRIDOR8,2); - _objectState[3] = Object(_id, kStringExit,kStringDefaultDescription,NULLOBJECT,EXIT,7,7,0,CORRIDOR9,22); - _objectState[4] = Object(_id, kStringDoor,kStringDoorDescription1,DOOR1,EXIT|OPENABLE|CLOSED|OCCUPIED,0,0,1,OFFICE_L1,6); - _objectState[5] = Object(_id, kStringDoor,kStringDoorDescription2,DOOR2,EXIT|OPENABLE|CLOSED|OCCUPIED,1,1,2,OFFICE_L2,16); - _objectState[6] = Object(_id, kStringDoor,kStringDoorDescription3,DOOR3,EXIT|OPENABLE|OPENED,2,2,3,OFFICE_R1,8); - _objectState[7] = Object(_id, kStringDoor,kStringDoorDescription4,DOOR4,EXIT|OPENABLE|CLOSED|OCCUPIED,3,3,4,OFFICE_R2,18); -} - -void AxacussBcorridor::onEntrance() { - _gm->corridorOnEntrance(); - if (isSectionVisible(7)) - _gm->busted(-1); -} - -bool AxacussBcorridor::interact(Action verb, Object &obj1, Object &obj2) { - if (obj1.hasProperty(EXIT) || - ((verb == ACTION_USE) && obj1.hasProperty(COMBINABLE) && obj2.hasProperty(EXIT))) { - _gm->_state._playerHidden = false; - } - - if ((verb == ACTION_CLOSE) && (obj1._id >= DOOR1) && (obj1._id <= DOOR4) && obj1.hasProperty(OPENED)) { - _vm->renderImage(_gm->invertSection(obj1._id - DOOR1 + 1)); - _vm->playSound(kAudioDoorClose); - obj1.disableProperty(OPENED); - obj1.setProperty(CLOSED); - if (obj1.hasProperty(OCCUPIED)) { - _gm->_state._destination = 255; - obj1.disableProperty(OCCUPIED); - obj1.setProperty(CAUGHT); - if (!_gm->_rooms[OFFICE_L1 + obj1._id - DOOR1]->isSectionVisible(4)) - _gm->search(180); - else - _gm->_state._eventTime = kMaxTimerValue; - } - } else if (((verb == ACTION_WALK) || ((verb == ACTION_OPEN) && !obj1.hasProperty(OPENED))) && - (obj1._id >= DOOR1) && (obj1._id <= DOOR4) && - obj1.hasProperty(OCCUPIED)) { - _vm->renderMessage(kStringDontEnter); - } else if ((verb == ACTION_USE) && Object::combine(obj1, obj2, MASTERKEYCARD, DOOR1) && - !getObject(4)->hasProperty(OPENED)) { - if (getObject(4)->hasProperty(OCCUPIED)) - _vm->renderMessage(kStringDontEnter); - else { - _vm->renderImage(1); - _vm->playSound(kAudioDoorOpen); - if (getObject(4)->hasProperty(CAUGHT)) - _gm->busted(11); - getObject(4)->resetProperty(EXIT | OPENABLE | OPENED); - } - } else if ((verb == ACTION_USE) && Object::combine(obj1, obj2, MASTERKEYCARD, DOOR2) && !getObject(5)->hasProperty(OPENED)) { - if (getObject(5)->hasProperty(OCCUPIED)) - _vm->renderMessage(kStringDontEnter); - else { - _vm->renderImage(2); - _vm->playSound(kAudioDoorOpen); - if (getObject(5)->hasProperty(CAUGHT)) - _gm->busted(16); - getObject(5)->resetProperty(EXIT | OPENABLE | OPENED); - } - } else if ((verb == ACTION_USE) && Object::combine(obj1, obj2, MASTERKEYCARD, DOOR3) && !getObject(6)->hasProperty(OPENED)) { - if (getObject(6)->hasProperty(OCCUPIED)) - _vm->renderMessage(kStringDontEnter); - else { - _vm->renderImage(3); - _vm->playSound(kAudioDoorOpen); - if (getObject(6)->hasProperty(CAUGHT)) - _gm->busted(15); - getObject(6)->resetProperty(EXIT | OPENABLE | OPENED); - } - } else if ((verb == ACTION_USE) && Object::combine(obj1, obj2, MASTERKEYCARD, DOOR4) && !getObject(7)->hasProperty(OPENED)) { - if (getObject(7)->hasProperty(OCCUPIED)) { - _vm->renderMessage(kStringDontEnter); - } else { - _vm->renderImage(4); - _vm->playSound(kAudioDoorOpen); - if (getObject(7)->hasProperty(CAUGHT)) - _gm->busted(20); - getObject(7)->resetProperty(EXIT | OPENABLE | OPENED); - } - } else if ((verb == ACTION_LOOK) && (obj1._id >= DOOR1) && (obj1._id <= DOOR4)) { - _gm->_state._nameSeen[obj1._id - DOOR1] = true; - return false; - } else if ((verb == ACTION_WALK) && ((obj1._id == PILLAR1) || (obj1._id == PILLAR2))) { - _vm->renderMessage(kStringAxacussBcorridor_1); - _gm->_state._playerHidden = true; - } else - return false; - - return true; -} - -AxacussIntersection::AxacussIntersection(SupernovaEngine *vm, GameManager1 *gm) { - _vm = vm; - _gm = gm; - - _fileNumber = 40; - _id = GUARD; - _shown[0] = kShownTrue; - - _objectState[0] = Object(_id, kStringExit, kStringDefaultDescription, NULLOBJECT, EXIT, 255, 255, 0, CORRIDOR4, 21); - _objectState[1] = Object(_id, kStringCorridor, kStringDefaultDescription, NULLOBJECT, EXIT, 3, 3, 0, CORRIDOR7, 5); - _objectState[2] = Object(_id, kStringDoor, kStringDefaultDescription, DOOR, EXIT | OPENABLE, 1, 1, 6, CORRIDOR9, 3); - _objectState[3] = Object(_id, kStringAxacussan, kStringAxacussanDescription, GUARDIAN, TALK, 0, 0, 0); - _objectState[4] = Object(_id, kStringImage, kStringImageDescription2, NULLOBJECT, NULLTYPE, 2, 2, 0); - _objectState[5] = Object(_id, kStringMastercard, kStringMastercardDescription, MASTERKEYCARD, TAKE | COMBINABLE, 255, 255, 1); - - _dialogsX[0] = kStringDialogX1; - _dialogsX[1] = kStringDialogX2; - _dialogsX[2] = kStringDialogX3; -} - -bool AxacussIntersection::interact(Action verb, Object &obj1, Object &obj2) { - byte rowsX[6] = {1, 1, 1, 0, 0, 0}; - - if (((verb == ACTION_WALK) || (verb == ACTION_OPEN)) && (obj1._id == DOOR) && !isSectionVisible(1)) - _gm->guardShot(); - else if ((verb == ACTION_OPEN) && (obj1._id == DOOR) && !obj1.hasProperty(OPENED)) { - _gm->_rooms[CORRIDOR9]->setSectionVisible(27, true); - _gm->_rooms[CORRIDOR9]->setSectionVisible(28, false); - _gm->_rooms[CORRIDOR9]->getObject(1)->setProperty(OPENED); - return false; - } else if ((verb == ACTION_CLOSE) && (obj1._id == DOOR) && obj1.hasProperty(OPENED)) { - _gm->_rooms[CORRIDOR9]->setSectionVisible(27, false); - _gm->_rooms[CORRIDOR9]->setSectionVisible(28, true); - _gm->_rooms[CORRIDOR9]->getObject(1)->disableProperty(OPENED); - return false; - } else if ((verb == ACTION_TALK) && (obj1._id == GUARDIAN)) { - _gm->dialog(3, rowsX, _dialogsX, 0); - _gm->guardShot(); - } else if ((verb == ACTION_TAKE) && (obj1._id == MASTERKEYCARD)) { - _gm->great(0); - setSectionVisible(7, false); - return false; - } else if ((verb == ACTION_USE) && (Object::combine(obj1, obj2, MAGNET, GUARDIAN) || Object::combine(obj1, obj2, KNIFE, GUARDIAN))) - _vm->renderMessage(kStringArsanoEntrance27); - else - return false; - - return true; -} - -AxacussExit::AxacussExit(SupernovaEngine *vm, GameManager1 *gm) { - _vm = vm; - _gm = gm; - - _fileNumber = 42; - _id = GUARD3; - _shown[0] = kShownTrue; - - _objectState[0] = Object(_id, kStringExit,kStringDefaultDescription,NULLOBJECT,EXIT,255,255,0,CORRIDOR1,22); - _objectState[1] = Object(_id, kStringDoor,kStringDefaultDescription,NULLOBJECT,EXIT|OPENABLE|CLOSED,0,0,0,NULLROOM,20); - _objectState[2] = Object(_id, kStringDoor,kStringDefaultDescription,NULLOBJECT,EXIT|OPENABLE|CLOSED,1,1,0,NULLROOM,15); - _objectState[3] = Object(_id, kStringDoor,kStringDefaultDescription,DOOR,EXIT|OPENABLE,2,2,11,OFFICE_L,0); - _objectState[4] = Object(_id, kStringLamp2,kStringDefaultDescription,LAMP,COMBINABLE,3,3,0); - _objectState[5] = Object(_id, kStringAxacussan,kStringDefaultDescription,GUARDIAN,TALK,5,5,0); - _objectState[6] = Object(_id, kStringImage,kStringGenericDescription5,NULLOBJECT,NULLTYPE,4,4,0); - - _dialogsX[0] = kStringDialogX1; - _dialogsX[1] = kStringDialogX2; - _dialogsX[2] = kStringDialogX3; -} - -bool AxacussExit::interact(Action verb, Object &obj1, Object &obj2) { - byte rowsX[6] = {1, 1, 1, 0, 0, 0}; - - if (((verb == ACTION_WALK) || (verb == ACTION_OPEN)) && (obj1._id == DOOR) && !_gm->_state._powerOff) - _gm->guard3Shot(); - else if ((verb == ACTION_TALK) && (obj1._id == GUARDIAN)) { - _gm->dialog(3, rowsX, _dialogsX,0); - _gm->guard3Shot(); - } else if ((verb == ACTION_USE) && Object::combine(obj1, obj2, LAMP, MAGNET)) { - _gm->_inventory.remove(*_gm->_rooms[CELL]->getObject(7)); - for (int i = 4; i <= 11; i++) { - _vm->renderImage(i); - if (i == 11) - _vm->playSound(kAudioSmash); // 046/4020 - _gm->wait(1); - _vm->renderImage(i + 128); - } - _gm->_state._powerOff = true; - _objectState[5]._click = 255; - - _gm->search(450); - _gm->roomBrightness(); - } else if ((verb == ACTION_USE) && (Object::combine(obj1,obj2,MAGNET,GUARDIAN) || Object::combine(obj1,obj2,KNIFE,GUARDIAN))) - _vm->renderMessage(kStringArsanoEntrance27); - else - return false; - - return true; -} - -AxacussOffice1::AxacussOffice1(SupernovaEngine *vm, GameManager1 *gm) { - _vm = vm; - _gm = gm; - - _fileNumber = 7; - _id = OFFICE_L1; - _shown[0] = kShownTrue; - _shown[2] = kShownTrue; - _shown[7] = kShownTrue; - _shown[9] = kShownTrue; - _shown[16] = kShownTrue; - - _objectState[0] = Object(_id, kStringDoor,kStringDefaultDescription,DOOR,EXIT|OPENABLE|OPENED,6,6,9,BCORRIDOR,9); - _objectState[1] = Object(_id, kStringComputer,kStringDefaultDescription,COMPUTER,COMBINABLE,4,4,0); - _objectState[2] = Object(_id, kStringMoney,kStringMoneyDescription1,MONEY,TAKE,255,255,0); - _objectState[3] = Object(_id, kStringLocker,kStringLockerDescription,LOCKER,OPENABLE|CLOSED,5,5,0); - _objectState[4] = Object(_id, kStringLetter,kStringDefaultDescription,LETTER,UNNECESSARY,3,3,0); -} - -bool AxacussOffice1::interact(Action verb, Object &obj1, Object &obj2) { - Common::String input; - if ((verb == ACTION_CLOSE) && (obj1._id == DOOR) && - obj1.hasProperty(OPENED)) { - _vm->renderImage(_gm->invertSection(9)); - obj1.disableProperty(OPENED); - obj1.setProperty(CLOSED); - _vm->playSound(kAudioDoorClose); - } else if ((verb == ACTION_USE) && Object::combine(obj1, obj2, MASTERKEYCARD, DOOR) && - !getObject(0)->hasProperty(OPENED)) { - _vm->renderImage(9); - getObject(0)->disableProperty(CLOSED); - getObject(0)->setProperty(OPENED); - _vm->playSound(kAudioDoorOpen); - } else if ((verb == ACTION_USE) && Object::combine(obj1, obj2, COMPUTER, MAGNET)) { - _vm->renderImage(4); - setSectionVisible(16, false); - _vm->playSound(kAudioSmash); - } else if ((verb == ACTION_LOOK) && (obj1._id == COMPUTER)) { - if (isSectionVisible(4)) - _vm->renderMessage(kStringBroken); - else - _gm->telomat(0); - } else if (((verb == ACTION_OPEN) || (verb == ACTION_USE)) && - (obj1._id == LOCKER) && - !obj1.hasProperty(OPENED)) { - _vm->renderMessage(kStringAxacussOffice1_1); - _vm->renderBox(160, 70, 70, 10, kColorDarkBlue); - _gm->edit(input, 161, 71, 10); - - _vm->removeMessage(); - if (_gm->_key.keycode != Common::KEYCODE_ESCAPE) { - if (!input.equals("89814")) { - if (input.equals("41898")) - _vm->renderMessage(kStringAxacussOffice1_2); - else - _vm->renderMessage(kStringAxacussOffice1_3); - } else { - _vm->renderImage(6); - setSectionVisible(7, false); - obj1.resetProperty(OPENABLE | OPENED); - if (getObject(2)->hasProperty(TAKE)) { - _vm->renderImage(8); - getObject(2)->_click = 9; - } - _vm->playSound(kAudioDoorOpen); - _gm->great(7); - } - } - } else if ((verb == ACTION_CLOSE) && (obj1._id == LOCKER) && obj1.hasProperty(OPENED)) { - _vm->renderImage(7); - setSectionVisible(6, false); - obj1.resetProperty(OPENABLE | CLOSED); - setSectionVisible(8, false); - getObject(2)->_click = 255; - _vm->playSound(kAudioDoorClose); - } else if ((verb == ACTION_TAKE) && (obj1._id == MONEY)) { - _vm->renderImage(6); - setSectionVisible(8, false); - getObject(2)->_click = 255; - getObject(2)->resetProperty(); - _gm->takeMoney(500); - } else if ((verb == ACTION_LOOK) && (obj1._id == LETTER)) { - g_system->fillScreen(kColorBlack); - _vm->renderText(kStringAxacussOffice1_4, 10, 10, 4); - _vm->renderText(kStringAxacussOffice1_5, 270, 10, 4); - _vm->renderText(kStringAxacussOffice1_6, 10, 60, 4); - _vm->renderText(kStringAxacussOffice1_7, 10, 75, 4); - _vm->renderText(kStringAxacussOffice1_8, 10, 86, 4); - _vm->renderText(kStringAxacussOffice1_9, 10, 97, 4); - _vm->renderText(kStringAxacussOffice1_10, 10, 108, 4); - _vm->renderText(kStringAxacussOffice1_11, 10, 119, 4); - _vm->renderText(kStringAxacussOffice1_12, 10, 130, 4); - _vm->renderText(kStringAxacussOffice1_13, 10, 147, 4); - _vm->renderText(kStringAxacussOffice1_14, 200, 170, 4); - _vm->renderText(kStringAxacussOffice1_15, 200, 181, 4); - _gm->getInput(); - g_system->fillScreen(kColorBlack); - _vm->renderMessage(kStringAxacussOffice1_16); - } else - return false; - - return true; -} - -AxacussOffice2::AxacussOffice2(SupernovaEngine *vm, GameManager1 *gm) { - _vm = vm; - _gm = gm; - - _fileNumber = 7; - _id = OFFICE_L2; - _shown[0] = kShownTrue; - _shown[1] = kShownTrue; - _shown[9] = kShownTrue; - _shown[16] = kShownTrue; - - _objectState[0] = Object(_id, kStringDoor,kStringDefaultDescription,DOOR,EXIT|OPENABLE|OPENED,6,6,9,BCORRIDOR,9); - _objectState[1] = Object(_id, kStringComputer,kStringDefaultDescription,COMPUTER,COMBINABLE,4,4,0); - _objectState[2] = Object(_id, kStringCube,kStringGenericDescription6,NULLOBJECT,NULLTYPE,0,0,0); - _objectState[3] = Object(_id, kStringImage,kStringGenericDescription7,NULLOBJECT,NULLTYPE,1,1,0); - _objectState[4] = Object(_id, kStringStrangeThing,kStringGenericDescription8,NULLOBJECT,UNNECESSARY,2,2,0); -} - -bool AxacussOffice2::interact(Action verb, Object &obj1, Object &obj2) { - if ((verb == ACTION_CLOSE) && (obj1._id == DOOR) && - obj1.hasProperty(OPENED)) { - _vm->renderImage(_gm->invertSection(9)); - obj1.disableProperty(OPENED); - obj1.setProperty(CLOSED); - _vm->playSound(kAudioDoorClose); - } else if ((verb == ACTION_USE) && Object::combine(obj1, obj2, MASTERKEYCARD, DOOR) && !getObject(0)->hasProperty(OPENED)) { - _vm->renderImage(9); - getObject(0)->disableProperty(CLOSED); - getObject(0)->setProperty(OPENED); - _vm->playSound(kAudioDoorOpen); - } else if ((verb == ACTION_USE) && Object::combine(obj1, obj2, COMPUTER, MAGNET)) { - _vm->renderImage(4); - setSectionVisible(16, false); - _vm->playSound(kAudioSmash); - } else if ((verb == ACTION_LOOK) && (obj1._id == COMPUTER)) { - if (isSectionVisible(4)) - _vm->renderMessage(kStringBroken); - else - _gm->telomat(1); - } else - return false; - - return true; -} - -AxacussOffice3::AxacussOffice3(SupernovaEngine *vm, GameManager1 *gm) { - _vm = vm; - _gm = gm; - - _fileNumber = 8; - _id = OFFICE_R1; - _shown[0] = kShownTrue; - _shown[1] = kShownTrue; - _shown[3] = kShownTrue; - - _objectState[0] = Object(_id, kStringDoor,kStringDefaultDescription,DOOR,EXIT|OPENABLE|OPENED,0,0,3,BCORRIDOR,5); - _objectState[1] = Object(_id, kStringComputer,kStringDefaultDescription,COMPUTER,COMBINABLE,4,4,0); - _objectState[2] = Object(_id, kStringImage,kStringImageDescription2,NULLOBJECT,UNNECESSARY,1,1,0); - _objectState[3] = Object(_id, kStringImage,kStringImageDescription2,PAINTING,UNNECESSARY,2,2,0); - _objectState[4] = Object(_id, kStringPlant,kStringDefaultDescription,NULLOBJECT,UNNECESSARY,3,3,0); - _objectState[5] = Object(_id, kNoString,kStringDefaultDescription,MONEY,TAKE|COMBINABLE,255,255,0); -} - -bool AxacussOffice3::interact(Action verb, Object &obj1, Object &obj2) { - if ((verb == ACTION_CLOSE) && (obj1._id == DOOR) && - obj1.hasProperty(OPENED)) { - _vm->renderImage(_gm->invertSection(3)); - obj1.disableProperty(OPENED); - obj1.setProperty(CLOSED); - _vm->playSound(kAudioDoorClose); - } else if ((verb == ACTION_USE) && Object::combine(obj1, obj2, MASTERKEYCARD, DOOR) && - !getObject(0)->hasProperty(OPENED)) { - _vm->renderImage(3); - getObject(0)->disableProperty(CLOSED); - getObject(0)->setProperty(OPENED); - _vm->playSound(kAudioDoorOpen); - } else if ((verb == ACTION_USE) && Object::combine(obj1, obj2, COMPUTER, MAGNET)) { - _vm->renderImage(4); - _vm->playSound(kAudioSmash); - } else if ((verb == ACTION_LOOK) && (obj1._id == COMPUTER)) { - if (isSectionVisible(4)) - _vm->renderMessage(kStringBroken); - else - _gm->telomat(2); - } else if ((verb == ACTION_LOOK) && (obj1._id == PAINTING)) { - _vm->renderMessage(kStringAxacussOffice3_1); - _gm->takeMoney(300); - obj1._id = NULLOBJECT; - } else - return false; - - return true; -} - -AxacussOffice4::AxacussOffice4(SupernovaEngine *vm, GameManager1 *gm) { - _vm = vm; - _gm = gm; - - _fileNumber = 8; - _id = OFFICE_R2; - _shown[0] = kShownTrue; - _shown[2] = kShownTrue; - _shown[3] = kShownTrue; - - _objectState[0] = Object(_id, kStringDoor,kStringDefaultDescription,DOOR,EXIT|OPENABLE|OPENED,0,0,3,BCORRIDOR,5); - _objectState[1] = Object(_id, kStringComputer,kStringDefaultDescription,COMPUTER,COMBINABLE,4,4,0); - _objectState[2] = Object(_id, kStringStatue,kStringStatueDescription,NULLOBJECT,UNNECESSARY,6,6,0); - _objectState[3] = Object(_id, kStringPlant,kStringPlantDescription,NULLOBJECT,UNNECESSARY,5,5,0); -} - -bool AxacussOffice4::interact(Action verb, Object &obj1, Object &obj2) { - if ((verb == ACTION_CLOSE) && (obj1._id == DOOR) && obj1.hasProperty(OPENED)) { - _vm->renderImage(_gm->invertSection(3)); - obj1.disableProperty(OPENED); - obj1.setProperty(CLOSED); - _vm->playSound(kAudioDoorClose); - } else if ((verb == ACTION_USE) && Object::combine(obj1, obj2, MASTERKEYCARD, DOOR) && - !getObject(0)->hasProperty(OPENED)) { - _vm->renderImage(3); - getObject(0)->disableProperty(CLOSED); - getObject(0)->setProperty(OPENED); - _vm->playSound(kAudioDoorOpen); - } else if ((verb == ACTION_USE) && Object::combine(obj1, obj2, COMPUTER, MAGNET)) { - _vm->renderImage(4); - _vm->playSound(kAudioSmash); - } else if ((verb == ACTION_LOOK) && (obj1._id == COMPUTER)) { - if (isSectionVisible(4)) - _vm->renderMessage(kStringBroken); - else - _gm->telomat(3); - } else - return false; - - return true; -} - -AxacussOffice5::AxacussOffice5(SupernovaEngine *vm, GameManager1 *gm) { - _vm = vm; - _gm = gm; - - _fileNumber = 7; - _id = OFFICE_L; - _shown[0] = kShownTrue; - _shown[3] = kShownTrue; - _shown[5] = kShownTrue; - _shown[17] = kShownTrue; - - _objectState[0] = Object(_id, kStringDoor,kStringDefaultDescription,DOOR,EXIT|OPENABLE|OPENED,6,6,17,GUARD3,9); - _objectState[1] = Object(_id, kStringComputer,kStringComputerDescription,COMPUTER,COMBINABLE,4,4,0); - _objectState[2] = Object(_id, kStringGraffiti,kStringGraffitiDescription,NULLOBJECT,NULLTYPE,7,7,0); - _objectState[3] = Object(_id, kStringMoney,kStringMoneyDescription2,MONEY,TAKE,8,8,0); -} - -void AxacussOffice5::onEntrance() { - _gm->great(5); -} - -bool AxacussOffice5::interact(Action verb, Object &obj1, Object &obj2) { - if ((verb == ACTION_USE) && Object::combine(obj1, obj2, COMPUTER, MAGNET)) { - _vm->renderImage(4); - _vm->playSound(kAudioSmash); - } else if ((verb == ACTION_TAKE) && (obj1._id == MONEY)) { - _vm->renderImage(_gm->invertSection(5)); - obj1._click = 255; - _gm->takeMoney(350); - } else - return false; - - return true; -} - -AxacussElevator::AxacussElevator(SupernovaEngine *vm, GameManager1 *gm) { - _vm = vm; - _gm = gm; - - _fileNumber = 3; - _id = ELEVATOR; - _shown[0] = kShownTrue; - - _objectState[0] = Object(_id, kStringButton,kStringDefaultDescription,BUTTON1,PRESS,0,0,0); - _objectState[1] = Object(_id, kStringButton,kStringDefaultDescription,BUTTON2,PRESS,1,1,0); - _objectState[2] = Object(_id, kStringExit,kStringDefaultDescription,DOOR,EXIT,255,255,0,NULLROOM,22); - _objectState[3] = Object(_id, kStringJungle,kStringJungleDescription,JUNGLE,NULLTYPE,255,255,0,STATION,2); -} - -bool AxacussElevator::interact(Action verb, Object &obj1, Object &obj2) { - if ((verb == ACTION_WALK) && (obj1._id == DOOR)) { - g_system->fillScreen(kColorBlack); - _vm->setCurrentImage(41); - _vm->renderImage(0); - _vm->paletteBrightness(); - _gm->reply(kStringAxacussElevator_1, 1, 1 + 128); - _gm->say(kStringAxacussElevator_2); - g_system->fillScreen(kColorBlack); - } else if ((verb == ACTION_PRESS) && (obj1._id == BUTTON1)) { - if (!isSectionVisible(3)) { - _vm->renderImage(1); - getObject(2)->resetProperty(); - _vm->playSound(kAudioSlideDoor); - _gm->wait(25); - for (int i = 3; i <= 7; i++) { - _gm->wait(2); - _vm->renderImage(i); - } - getObject(3)->resetProperty(EXIT); - getObject(3)->_click = 2; - _vm->renderImage(_gm->invertSection(1)); - if (!(_gm->_state._greatFlag & 0x4000)) { - _vm->playSound(kAudioFoundLocation); - _gm->_state._greatFlag |= 0x4000; - } - } - } else if ((verb == ACTION_PRESS) && (obj1._id == BUTTON2)) { - if (isSectionVisible(3)) { - _vm->renderImage(2); - getObject(3)->resetProperty(); - getObject(3)->_click = 255; - _vm->playSound(kAudioSlideDoor); - for (int i = 7; i >= 3; i--) { - _gm->wait(2); - _vm->renderImage(_gm->invertSection(i)); - } - _gm->wait(25); - _vm->playSound(kAudioSlideDoor); - getObject(2)->resetProperty(EXIT); - _vm->renderImage(_gm->invertSection(2)); - } - } else if ((verb == ACTION_WALK) && (obj1._id == JUNGLE)) { - _vm->paletteFadeOut(); - g_system->fillScreen(kColorBlack); - _vm->_screen->setGuiBrightness(255); - _vm->paletteBrightness(); - _vm->renderMessage(kStringAxacussElevator_3); - _gm->waitOnInput(_gm->_messageDuration); - _vm->removeMessage(); - _vm->_screen->setGuiBrightness(0); - _vm->paletteBrightness(); - _gm->_time += ticksToMsec(125000); // 2 hours - _gm->_state._alarmOn = (_gm->_state._timeAlarm > _gm->_time); - return false; - } else - return false; - - return true; -} - -AxacussStation::AxacussStation(SupernovaEngine *vm, GameManager1 *gm) { - _vm = vm; - _gm = gm; - - _fileNumber = 5; - _id = STATION; - _shown[0] = kShownTrue; - _objectState[0] = Object(_id, kStringSign,kStringDefaultDescription,STATION_SIGN,NULLTYPE,0,0,0); - _objectState[1] = Object(_id, kStringDoor,kStringDefaultDescription,DOOR,EXIT|OPENABLE|CLOSED,1,1,0,NULLROOM,7); -} - -bool AxacussStation::interact(Action verb, Object &obj1, Object &obj2) { - if ((verb == ACTION_LOOK) && (obj1._id == STATION_SIGN)) { - _gm->changeRoom(SIGN); - } else if ((verb == ACTION_WALK) && (obj1._id == DOOR) && obj1.hasProperty(OPENED)) { - _gm->great(0); - _gm->_guiEnabled = false; - _vm->paletteFadeOut(); - _vm->_system->fillScreen(kColorBlack); - _gm->changeRoom(OUTRO); - } else - return false; - - return true; -} - -AxacussSign::AxacussSign(SupernovaEngine *vm, GameManager1 *gm) { - _vm = vm; - _gm = gm; - - _fileNumber = 32; - _id = SIGN; - _shown[0] = kShownTrue; - _shown[1] = kShownTrue; - - _objectState[0] = Object(_id, kStringExit,kStringDefaultDescription,NULLOBJECT,EXIT,255,255,0,STATION,22); - _objectState[1] = Object(_id, kStringSlot,kStringDefaultDescription,STATION_SLOT,COMBINABLE,0,0,0); -} - -bool AxacussSign::interact(Action verb, Object &obj1, Object &obj2) { - if ((verb == ACTION_USE) && Object::combine(obj1, obj2, STATION_SLOT, MONEY) && - isSectionVisible(1)) { - _gm->takeMoney(-180); - _vm->renderImage(2); - setSectionVisible(1, false); - _gm->_state._eventTime = _gm->_time + ticksToMsec(600); - _gm->_state._eventCallback = kTaxiFn; - return true; - } - return false; -} - - -Outro::Outro(SupernovaEngine *vm, GameManager1 *gm) { - _vm = vm; - _gm = gm; - - _fileNumber = -1; - _id = OUTRO; - _shown[0] = kShownFalse; - - _outroText = - _vm->getGameString(kStringOutro1) + '\0' + - _vm->getGameString(kStringOutro2) + '\0' + - _vm->getGameString(kStringOutro3) + '\0' + - _vm->getGameString(kStringOutro4) + '\0' + - _vm->getGameString(kStringOutro5) + '\0' + - _vm->getGameString(kStringOutro6) + '\0' + - _vm->getGameString(kStringOutro7) + '\0' + - _vm->getGameString(kStringOutro8) + '\0' + - _vm->getGameString(kStringOutro9) + '\0' + - _vm->getGameString(kStringOutro10) + '\0' + - _vm->getGameString(kStringOutro11) + '\0' + - _vm->getGameString(kStringOutro12) + '\0' + - _vm->getGameString(kStringOutro13) + '\0' + - _vm->getGameString(kStringOutro14) + '\0'; -} - -void Outro::onEntrance() { - _vm->setCurrentImage(35); - _vm->renderImage(0); - _vm->renderImage(1); - _vm->paletteFadeIn(); - _gm->wait(10); - for (int i = 8; i <= 21; i++) { - _vm->renderImage(i); - _gm->wait(2); - _vm->renderImage(_gm->invertSection(i)); - } - _gm->wait(18); - _vm->renderImage(_gm->invertSection(1)); - for (int i = 2; i <= 7; i++) { - _vm->renderImage(i); - _gm->wait(3); - _vm->renderImage(_gm->invertSection(i)); - } - - _vm->playSound(kMusicOutro); - Marquee marquee(_vm->_screen, Marquee::kMarqueeOutro, _outroText.c_str()); - while (!_vm->shouldQuit()) { - _gm->updateEvents(); - marquee.renderCharacter(); - if (_gm->_mouseClicked || _gm->_keyPressed) - break; - g_system->updateScreen(); - g_system->delayMillis(_vm->_delay); - } - _vm->paletteFadeOut(); - _vm->setCurrentImage(55); - _vm->renderImage(0); - _vm->paletteFadeIn(); - _gm->getInput(); - _vm->paletteFadeOut(); - _vm->_screen->setViewportBrightness(1); - - Common::Event event; - event.type = Common::EVENT_RTL; - _vm->getEventManager()->pushEvent(event); -} - -void Outro::animation() { -} - -void Outro::animate(int filenumber, int section1, int section2, int duration) { - _vm->setCurrentImage(filenumber); - while (duration) { - _vm->renderImage(section1); - _gm->wait(2); - _vm->renderImage(section2); - _gm->wait(2); - --duration; - } -} - -void Outro::animate(int filenumber, int section1, int section2, int duration, - MessagePosition position, const char *text) { - _vm->renderMessage(text, position); - int delay = (Common::strnlen(text, 512) + 20) * (10 - duration) * _vm->_textSpeed / 400; - _vm->setCurrentImage(filenumber); - while (delay) { - if (section1) - _vm->renderImage(section1); - _gm->wait(2); - if (section2) - _vm->renderImage(section2); - _gm->wait(2); - --delay; - } - _vm->removeMessage(); -} - -void Outro::animate(int filenumber, int section1, int section2, int section3, int section4, - int duration, MessagePosition position, const char *text) { - _vm->renderMessage(text, position); - if (duration == 0) - duration = (Common::strnlen(text, 512) + 20) * _vm->_textSpeed / 40; - - _vm->setCurrentImage(filenumber); - while(duration) { - _vm->renderImage(section1); - _vm->renderImage(section3); - _gm->wait(2); - _vm->renderImage(section2); - _vm->renderImage(section4); - _gm->wait(2); - duration--; - } - _vm->removeMessage(); -} - -} diff --git a/engines/supernova/rooms.h b/engines/supernova/rooms.h deleted file mode 100644 index c49e8356c9..0000000000 --- a/engines/supernova/rooms.h +++ /dev/null @@ -1,486 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -#ifndef SUPERNOVA_ROOMS_H -#define SUPERNOVA_ROOMS_H - -#include "common/str.h" - -#include "supernova/msn_def.h" -#include "supernova/room.h" - -namespace Common { -class ReadStream; -class WriteStream; -} - -namespace Supernova { - -class GameManager1; -class SupernovaEngine; - -// Room 0 -class Intro : public Room { -public: - Intro(SupernovaEngine *vm, GameManager1 *gm); - virtual void onEntrance(); - -private: - bool animate(int section1, int section2, int duration); - bool animate(int section1, int section2, int duration, MessagePosition position, - StringId text); - bool animate(int section1, int section2, int section3, int section4, int duration, - MessagePosition position, StringId text); - - void titleScreen(); - void titleFadeIn(); - void cutscene(); - void leaveCutscene(); - - bool _shouldExit; - Common::String _introText; -}; - -// Spaceship -class ShipCorridor : public Room { -public: - ShipCorridor(SupernovaEngine *vm, GameManager1 *gm); - - virtual bool interact(Action verb, Object &obj1, Object &obj2); -}; - -class ShipHall: public Room { -public: - ShipHall(SupernovaEngine *vm, GameManager1 *gm); - - virtual bool interact(Action verb, Object &obj1, Object &obj2); -}; - -class ShipSleepCabin: public Room { -public: - ShipSleepCabin(SupernovaEngine *vm, GameManager1 *gm); - - virtual bool interact(Action verb, Object &obj1, Object &obj2); - virtual void animation(); - virtual void onEntrance(); - -private: - byte _color; -}; - -class ShipCockpit : public Room { -public: - ShipCockpit(SupernovaEngine *vm, GameManager1 *gm); - - virtual bool interact(Action verb, Object &obj1, Object &obj2); - virtual void animation(); - virtual void onEntrance(); - -private: - byte _color; -}; - -class ShipCabinL1: public Room { -public: - ShipCabinL1(SupernovaEngine *vm, GameManager1 *gm); -}; - -class ShipCabinL2 : public Room { -public: - ShipCabinL2(SupernovaEngine *vm, GameManager1 *gm); - - virtual bool interact(Action verb, Object &obj1, Object &obj2); -}; - -class ShipCabinL3 : public Room { -public: - ShipCabinL3(SupernovaEngine *vm, GameManager1 *gm); - - virtual bool interact(Action verb, Object &obj1, Object &obj2); -}; - -class ShipCabinR1 : public Room { -public: - ShipCabinR1(SupernovaEngine *vm, GameManager1 *gm); -}; - -class ShipCabinR2 : public Room { -public: - ShipCabinR2(SupernovaEngine *vm, GameManager1 *gm); -}; - -class ShipCabinR3 : public Room { -public: - ShipCabinR3(SupernovaEngine *vm, GameManager1 *gm); - - virtual bool interact(Action verb, Object &obj1, Object &obj2); - virtual void onEntrance(); -}; - -class ShipCabinBathroom : public Room { -public: - ShipCabinBathroom(SupernovaEngine *vm, GameManager1 *gm); -}; - -class ShipAirlock : public Room { -public: - ShipAirlock(SupernovaEngine *vm, GameManager1 *gm); - - virtual bool interact(Action verb, Object &obj1, Object &obj2); - virtual void onEntrance(); -}; - -class ShipHold : public Room { -public: - ShipHold(SupernovaEngine *vm, GameManager1 *gm); - - virtual bool interact(Action verb, Object &obj1, Object &obj2); - virtual void onEntrance(); -}; - -class ShipLandingModule : public Room { -public: - ShipLandingModule(SupernovaEngine *vm, GameManager1 *gm); - - virtual bool interact(Action verb, Object &obj1, Object &obj2); -}; - -class ShipGenerator : public Room { -public: - ShipGenerator(SupernovaEngine *vm, GameManager1 *gm); - - virtual bool interact(Action verb, Object &obj1, Object &obj2); -}; - -class ShipOuterSpace : public Room { -public: - ShipOuterSpace(SupernovaEngine *vm, GameManager1 *gm); -}; - - -// Arsano -class ArsanoRocks : public Room { -public: - ArsanoRocks(SupernovaEngine *vm, GameManager1 *gm); - - virtual void onEntrance(); - virtual bool interact(Action verb, Object &obj1, Object &obj2); -}; - -class ArsanoCave : public Room { -public: - ArsanoCave(SupernovaEngine *vm, GameManager1 *gm); -}; - -class ArsanoMeetup : public Room { -public: - ArsanoMeetup(SupernovaEngine *vm, GameManager1 *gm); - - virtual void onEntrance(); - virtual void animation(); - virtual bool interact(Action verb, Object &obj1, Object &obj2); - -private: - byte _sign; - byte _beacon; -}; - -class ArsanoEntrance : public Room { -public: - ArsanoEntrance(SupernovaEngine *vm, GameManager1 *gm); - - virtual bool interact(Action verb, Object &obj1, Object &obj2); - virtual void animation(); - -private: - StringId _dialog1[5]; - StringId _dialog2[5]; - StringId _dialog3[5]; - byte _eyewitness; -}; - -class ArsanoRemaining : public Room { -public: - ArsanoRemaining(SupernovaEngine *vm, GameManager1 *gm); - - virtual void animation(); - -private: - bool _chewing; - int _i; -}; - -class ArsanoRoger : public Room { -public: - ArsanoRoger(SupernovaEngine *vm, GameManager1 *gm); - - virtual void animation(); - virtual void onEntrance(); - virtual bool interact(Action verb, Object &obj1, Object &obj2); - -private: - StringId _dialog1[4]; - byte _eyewitness; - byte _hands; -}; - -class ArsanoGlider : public Room { -public: - ArsanoGlider(SupernovaEngine *vm, GameManager1 *gm); - - virtual void animation(); - virtual bool interact(Action verb, Object &obj1, Object &obj2); - -private: - byte _sinus; -}; - -class ArsanoMeetup2 : public Room { -public: - ArsanoMeetup2(SupernovaEngine *vm, GameManager1 *gm); - - virtual void onEntrance(); - virtual bool interact(Action verb, Object &obj1, Object &obj2); - - void shipStart(); - -private: - // TODO: change to 6, fix initialization - StringId _dialog1[2]; - StringId _dialog2[2]; - StringId _dialog3[4]; - StringId _dialog4[3]; - - // FIXME: Remove following unused bool variables? - //bool _found; - //bool _flug; -}; - -class ArsanoMeetup3 : public Room { -public: - ArsanoMeetup3(SupernovaEngine *vm, GameManager1 *gm); - - virtual bool interact(Action verb, Object &obj1, Object &obj2); - -private: - StringId _dialog2[4]; - StringId _dialog3[2]; - - // TODO: Hack, to be move away and renamed when the other uses are found - StringId _dialogsX[6]; -}; - - -// Axacuss -class AxacussCell : public Room { -public: - AxacussCell(SupernovaEngine *vm, GameManager1 *gm); - - virtual bool interact(Action verb, Object &obj1, Object &obj2); - virtual void animation(); - virtual void onEntrance(); -}; - -class AxacussCorridor1 : public Room { -public: - AxacussCorridor1(SupernovaEngine *vm, GameManager1 *gm); - - virtual void onEntrance(); -}; - -class AxacussCorridor2 : public Room { -public: - AxacussCorridor2(SupernovaEngine *vm, GameManager1 *gm); - - virtual void onEntrance(); -}; - -class AxacussCorridor3 : public Room { -public: - AxacussCorridor3(SupernovaEngine *vm, GameManager1 *gm); - - virtual void onEntrance(); -}; - -class AxacussCorridor4 : public Room { -public: - AxacussCorridor4(SupernovaEngine *vm, GameManager1 *gm); - - virtual void onEntrance(); - virtual void animation(); - virtual bool interact(Action verb, Object &obj1, Object &obj2); -}; - -class AxacussCorridor5 : public Room { -public: - AxacussCorridor5(SupernovaEngine *vm, GameManager1 *gm); - - virtual void onEntrance(); - virtual bool interact(Action verb, Object &obj1, Object &obj2); - -private: - void stopInteract(int sum); - bool handleMoneyDialog(); - - // TODO: Change to 6, or change struct, and fix initialization - StringId _dialog1[2]; - StringId _dialog2[2]; - StringId _dialog3[4]; - - byte _rows[6]; -}; - -class AxacussCorridor6 : public Room { -public: - AxacussCorridor6(SupernovaEngine *vm, GameManager1 *gm); - - virtual void onEntrance(); - virtual bool interact(Action verb, Object &obj1, Object &obj2); -}; - -class AxacussCorridor7 : public Room { -public: - AxacussCorridor7(SupernovaEngine *vm, GameManager1 *gm); - - virtual void onEntrance(); -}; - -class AxacussCorridor8 : public Room { -public: - AxacussCorridor8(SupernovaEngine *vm, GameManager1 *gm); - - virtual void onEntrance(); - virtual bool interact(Action verb, Object &obj1, Object &obj2); -}; - -class AxacussCorridor9 : public Room { -public: - AxacussCorridor9(SupernovaEngine *vm, GameManager1 *gm); - - virtual void onEntrance(); - virtual bool interact(Action verb, Object &obj1, Object &obj2); -}; - -class AxacussBcorridor : public Room { -public: - AxacussBcorridor(SupernovaEngine *vm, GameManager1 *gm); - - virtual void onEntrance(); - virtual bool interact(Action verb, Object &obj1, Object &obj2); -}; - -class AxacussIntersection : public Room { -public: - AxacussIntersection(SupernovaEngine *vm, GameManager1 *gm); - - virtual bool interact(Action verb, Object &obj1, Object &obj2); - -private: - StringId _dialogsX[6]; -}; - -class AxacussExit : public Room { -public: - AxacussExit(SupernovaEngine *vm, GameManager1 *gm); - - virtual bool interact(Action verb, Object &obj1, Object &obj2); - -private: - StringId _dialogsX[6]; -}; - -class AxacussOffice1 : public Room { -public: - AxacussOffice1(SupernovaEngine *vm, GameManager1 *gm); - - virtual bool interact(Action verb, Object &obj1, Object &obj2); -}; - -class AxacussOffice2 : public Room { -public: - AxacussOffice2(SupernovaEngine *vm, GameManager1 *gm); - - virtual bool interact(Action verb, Object &obj1, Object &obj2); -}; - -class AxacussOffice3 : public Room { -public: - AxacussOffice3(SupernovaEngine *vm, GameManager1 *gm); - - virtual bool interact(Action verb, Object &obj1, Object &obj2); -}; - -class AxacussOffice4 : public Room { -public: - AxacussOffice4(SupernovaEngine *vm, GameManager1 *gm); - - virtual bool interact(Action verb, Object &obj1, Object &obj2); -}; - -class AxacussOffice5 : public Room { -public: - AxacussOffice5(SupernovaEngine *vm, GameManager1 *gm); - - virtual void onEntrance(); - virtual bool interact(Action verb, Object &obj1, Object &obj2); -}; - -class AxacussElevator : public Room { -public: - AxacussElevator(SupernovaEngine *vm, GameManager1 *gm); - - virtual bool interact(Action verb, Object &obj1, Object &obj2); -}; - -class AxacussStation : public Room { -public: - AxacussStation(SupernovaEngine *vm, GameManager1 *gm); - - virtual bool interact(Action verb, Object &obj1, Object &obj2); -}; - -class AxacussSign : public Room { -public: - AxacussSign(SupernovaEngine *vm, GameManager1 *gm); - - virtual bool interact(Action verb, Object &obj1, Object &obj2); -}; - -class Outro : public Room { -public: - Outro(SupernovaEngine *vm, GameManager1 *gm); - - virtual void onEntrance(); - virtual void animation(); - -private: - void animate(int filenumber, int section1, int section2, int duration); - void animate(int filenumber, int section1, int section2, int duration, MessagePosition position, - const char *text); - void animate(int filenumber, int section1, int section2, int section3, int section4, int duration, - MessagePosition position, const char *text); - - Common::String _outroText; -}; - -} -#endif // SUPERNOVA_ROOMS_H diff --git a/engines/supernova/screen.cpp b/engines/supernova/screen.cpp index 0240a7619e..5a89b40882 100644 --- a/engines/supernova/screen.cpp +++ b/engines/supernova/screen.cpp @@ -30,7 +30,7 @@ #include "supernova/imageid.h" #include "supernova/resman.h" -#include "supernova/state.h" +#include "supernova/game-manager.h" #include "supernova/screen.h" #include "supernova/supernova.h" diff --git a/engines/supernova/state.cpp b/engines/supernova/state.cpp deleted file mode 100644 index 3e0ba6132a..0000000000 --- a/engines/supernova/state.cpp +++ /dev/null @@ -1,1623 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -#include "common/system.h" -#include "graphics/cursorman.h" -#include "graphics/palette.h" -#include "gui/message.h" - -#include "supernova/screen.h" -#include "supernova/supernova.h" -#include "supernova/state.h" - -namespace Supernova { - -bool GameManager1::serialize(Common::WriteStream *out) { - if (out->err()) - return false; - - // GameState - out->writeSint32LE(_time); - out->writeSint32LE(_state._timeSleep); - out->writeSint32LE(_state._timeAlarm); - out->writeSint32LE(_state._eventTime); - out->writeSint32LE(_state._eventCallback); - out->writeSint32LE(_state._arrivalDaysLeft); - out->writeSint32LE(_state._shipEnergyDaysLeft); - out->writeSint32LE(_state._landingModuleEnergyDaysLeft); - out->writeUint16LE(_state._greatFlag); - out->writeSint16LE(_state._timeRobot); - out->writeSint16LE(_state._money); - out->writeByte(_state._coins); - out->writeByte(_state._shoes); - out->writeByte(_state._origin); - out->writeByte(_state._destination); - out->writeByte(_state._language); - out->writeByte(_state._corridorSearch); - out->writeByte(_state._alarmOn); - out->writeByte(_state._terminalStripConnected); - out->writeByte(_state._terminalStripWire); - out->writeByte(_state._cableConnected); - out->writeByte(_state._powerOff); - out->writeByte(_state._dream); - for (int i = 0; i < 4; i++) - out->writeByte(_state._nameSeen[i]); - out->writeByte(_state._playerHidden); - - // Inventory - out->writeSint32LE(_inventory.getSize()); - out->writeSint32LE(_inventoryScroll); - for (int i = 0; i < _inventory.getSize(); ++i) { - Object *objectStateBegin = _rooms[_inventory.get(i)->_roomId]->getObject(0); - byte objectIndex = _inventory.get(i) - objectStateBegin; - out->writeSint32LE(_inventory.get(i)->_roomId); - out->writeSint32LE(objectIndex); - } - - // Rooms - out->writeByte(_currentRoom->getId()); - for (int i = 0; i < NUMROOMS; ++i) { - _rooms[i]->serialize(out); - } - - return !out->err(); -} - -bool GameManager1::deserialize(Common::ReadStream *in, int version) { - if (in->err()) - return false; - - // GameState - _time = in->readSint32LE(); - _state._timeSleep = in->readSint32LE(); - _state._timeAlarm = in->readSint32LE(); - _state._eventTime = in->readSint32LE(); - if (version >= 4) - _state._eventCallback = (EventFunction)in->readSint32LE(); - else - _state._eventCallback = kNoFn; - _state._arrivalDaysLeft = in->readSint32LE(); - _state._shipEnergyDaysLeft = in->readSint32LE(); - _state._landingModuleEnergyDaysLeft = in->readSint32LE(); - _state._greatFlag = in->readUint16LE(); - _state._timeRobot = in->readSint16LE(); - _state._money = in->readSint16LE(); - _vm->setGameString(kStringInventoryMoney, Common::String::format("%d Xa", _state._money)); - _state._coins = in->readByte(); - _state._shoes = in->readByte(); - if (version >= 6) - _state._origin = in->readByte(); - else - _state._origin = 0; - _state._destination = in->readByte(); - _state._language = in->readByte(); - _state._corridorSearch = in->readByte(); - _state._alarmOn = in->readByte(); - _state._terminalStripConnected = in->readByte(); - _state._terminalStripWire = in->readByte(); - _state._cableConnected = in->readByte(); - _state._powerOff = in->readByte(); - _state._dream = in->readByte(); - - for (int i = 0; i < 4; i++) { - if (version >= 7) - _state._nameSeen[i] = in->readByte(); - else - _state._nameSeen[i] = false; - } - - if (version >= 8) - _state._playerHidden = in->readByte(); - else - _state._playerHidden = false; - - _oldTime = g_system->getMillis(); - - // Inventory - int inventorySize = in->readSint32LE(); - _inventoryScroll = in->readSint32LE(); - _inventory.clear(); - for (int i = 0; i < inventorySize; ++i) { - RoomId objectRoom = static_cast(in->readSint32LE()); - int objectIndex = in->readSint32LE(); - _inventory.add(*_rooms[objectRoom]->getObject(objectIndex)); - } - - // Rooms - RoomId curRoomId = static_cast(in->readByte()); - for (int i = 0; i < NUMROOMS; ++i) { - _rooms[i]->deserialize(in, version); - } - changeRoom(curRoomId); - - // Some additional variables - _guiEnabled = true; - _animationEnabled = true; - - return !in->err(); -} - -// Used by Look Watch (when it's fixed). Do not remove. -static Common::String timeToString(int msec) { - char s[9] = " 0:00:00"; - msec /= 1000; - s[7] = msec % 10 + '0'; - msec /= 10; - s[6] = msec % 6 + '0'; - msec /= 6; - s[4] = msec % 10 + '0'; - msec /= 10; - s[3] = msec % 6 + '0'; - msec /= 6; - s[1] = msec % 10 + '0'; - msec /= 10; - if (msec) - s[0] = msec + '0'; - - return Common::String(s); -} - -GameManager1::GameManager1(SupernovaEngine *vm, Sound *sound) - : GameManager(vm, sound) { - initRooms(); - changeRoom(INTRO); - initState(); -} - -GameManager1::~GameManager1() { - destroyRooms(); -} - -void GameManager1::destroyRooms() { - delete _rooms[INTRO]; - delete _rooms[CORRIDOR]; - delete _rooms[HALL]; - delete _rooms[SLEEP]; - delete _rooms[COCKPIT]; - delete _rooms[AIRLOCK]; - delete _rooms[HOLD]; - delete _rooms[LANDINGMODULE]; - delete _rooms[GENERATOR]; - delete _rooms[OUTSIDE]; - delete _rooms[CABIN_R1]; - delete _rooms[CABIN_R2]; - delete _rooms[CABIN_R3]; - delete _rooms[CABIN_L1]; - delete _rooms[CABIN_L2]; - delete _rooms[CABIN_L3]; - delete _rooms[BATHROOM]; - - delete _rooms[ROCKS]; - delete _rooms[CAVE]; - delete _rooms[MEETUP]; - delete _rooms[ENTRANCE]; - delete _rooms[REST]; - delete _rooms[ROGER]; - delete _rooms[GLIDER]; - delete _rooms[MEETUP2]; - delete _rooms[MEETUP3]; - - delete _rooms[CELL]; - delete _rooms[CORRIDOR1]; - delete _rooms[CORRIDOR2]; - delete _rooms[CORRIDOR3]; - delete _rooms[CORRIDOR4]; - delete _rooms[CORRIDOR5]; - delete _rooms[CORRIDOR6]; - delete _rooms[CORRIDOR7]; - delete _rooms[CORRIDOR8]; - delete _rooms[CORRIDOR9]; - delete _rooms[BCORRIDOR]; - delete _rooms[GUARD]; - delete _rooms[GUARD3]; - delete _rooms[OFFICE_L1]; - delete _rooms[OFFICE_L2]; - delete _rooms[OFFICE_R1]; - delete _rooms[OFFICE_R2]; - delete _rooms[OFFICE_L]; - delete _rooms[ELEVATOR]; - delete _rooms[STATION]; - delete _rooms[SIGN]; - delete _rooms[OUTRO]; -} - -void GameManager1::initState() { - _currentInputObject = &_nullObject; - _inputObject[0] = &_nullObject; - _inputObject[1] = &_nullObject; - _inputVerb = ACTION_WALK; - _processInput = false; - _guiEnabled = true; - _animationEnabled = true; - _roomBrightness = 255; - _mouseClicked = false; - _keyPressed = false; - _mouseX = -1; - _mouseY = -1; - _mouseField = -1; - _inventoryScroll = 0; - _oldTime = g_system->getMillis(); - _timerPaused = 0; - _timePaused = false; - _messageDuration = 0; - _animationTimer = 0; - - _currentSentence = -1; - for (int i = 0 ; i < 6 ; ++i) { - _sentenceNumber[i] = -1; - _texts[i] = kNoString; - _rows[i] = 0; - _rowsStart[i] = 0; - } - - _time = ticksToMsec(916364); // 2 pm - _state._timeSleep = 0; - _state._timeAlarm = ticksToMsec(458182); // 7 am - _state._eventTime = kMaxTimerValue; - _state._eventCallback = kNoFn; - _state._arrivalDaysLeft = 2840; - _state._shipEnergyDaysLeft = 2135; - _state._landingModuleEnergyDaysLeft = 923; - _state._greatFlag = 0; - _state._timeRobot = 0; - _state._money = 0; - _state._coins = 0; - _state._shoes = 0; - _state._origin = 0; - _state._destination = 255; - _state._language = 0; - _state._corridorSearch = false; - _state._alarmOn = false; - _state._terminalStripConnected = false; - _state._terminalStripWire = false; - _state._cableConnected = false; - _state._powerOff = false; - _state._dream = false; - - _prevImgId = 0; -} - -void GameManager1::initRooms() { - _rooms[INTRO] = new Intro(_vm, this); - _rooms[CORRIDOR] = new ShipCorridor(_vm, this); - _rooms[HALL] = new ShipHall(_vm, this); - _rooms[SLEEP] = new ShipSleepCabin(_vm, this); - _rooms[COCKPIT] = new ShipCockpit(_vm, this); - _rooms[AIRLOCK] = new ShipAirlock(_vm, this); - _rooms[HOLD] = new ShipHold(_vm, this); - _rooms[LANDINGMODULE] = new ShipLandingModule(_vm, this); - _rooms[GENERATOR] = new ShipGenerator(_vm, this); - _rooms[OUTSIDE] = new ShipOuterSpace(_vm, this); - _rooms[CABIN_R1] = new ShipCabinR1(_vm, this); - _rooms[CABIN_R2] = new ShipCabinR2(_vm, this); - _rooms[CABIN_R3] = new ShipCabinR3(_vm, this); - _rooms[CABIN_L1] = new ShipCabinL1(_vm, this); - _rooms[CABIN_L2] = new ShipCabinL2(_vm, this); - _rooms[CABIN_L3] = new ShipCabinL3(_vm, this); - _rooms[BATHROOM] = new ShipCabinBathroom(_vm, this); - - _rooms[ROCKS] = new ArsanoRocks(_vm, this); - _rooms[CAVE] = new ArsanoCave(_vm, this); - _rooms[MEETUP] = new ArsanoMeetup(_vm, this); - _rooms[ENTRANCE] = new ArsanoEntrance(_vm, this); - _rooms[REST] = new ArsanoRemaining(_vm, this); - _rooms[ROGER] = new ArsanoRoger(_vm, this); - _rooms[GLIDER] = new ArsanoGlider(_vm, this); - _rooms[MEETUP2] = new ArsanoMeetup2(_vm, this); - _rooms[MEETUP3] = new ArsanoMeetup3(_vm, this); - - _rooms[CELL] = new AxacussCell(_vm, this); - _rooms[CORRIDOR1] = new AxacussCorridor1(_vm, this); - _rooms[CORRIDOR2] = new AxacussCorridor2(_vm, this); - _rooms[CORRIDOR3] = new AxacussCorridor3(_vm, this); - _rooms[CORRIDOR4] = new AxacussCorridor4(_vm, this); - _rooms[CORRIDOR5] = new AxacussCorridor5(_vm, this); - _rooms[CORRIDOR6] = new AxacussCorridor6(_vm, this); - _rooms[CORRIDOR7] = new AxacussCorridor7(_vm, this); - _rooms[CORRIDOR8] = new AxacussCorridor8(_vm, this); - _rooms[CORRIDOR9] = new AxacussCorridor9(_vm, this); - _rooms[BCORRIDOR] = new AxacussBcorridor(_vm, this); - _rooms[GUARD] = new AxacussIntersection(_vm, this); - _rooms[GUARD3] = new AxacussExit(_vm, this); - _rooms[OFFICE_L1] = new AxacussOffice1(_vm, this); - _rooms[OFFICE_L2] = new AxacussOffice2(_vm, this); - _rooms[OFFICE_R1] = new AxacussOffice3(_vm, this); - _rooms[OFFICE_R2] = new AxacussOffice4(_vm, this); - _rooms[OFFICE_L] = new AxacussOffice5(_vm, this); - _rooms[ELEVATOR] = new AxacussElevator(_vm, this); - _rooms[STATION] = new AxacussStation(_vm, this); - _rooms[SIGN] = new AxacussSign(_vm, this); - _rooms[OUTRO] = new Outro(_vm, this); -} - -bool GameManager1::canSaveGameStateCurrently() { - return _animationEnabled && _guiEnabled; -} - -void GameManager1::updateEvents() { - handleTime(); - if (_animationEnabled && !_vm->_screen->isMessageShown() && _animationTimer == 0) - _currentRoom->animation(); - - if (_state._eventCallback != kNoFn && _time >= _state._eventTime) { - _vm->_allowLoadGame = false; - _vm->_allowSaveGame = false; - _state._eventTime = kMaxTimerValue; - EventFunction fn = _state._eventCallback; - _state._eventCallback = kNoFn; - switch (fn) { - case kNoFn: - break; - case kSupernovaFn: - supernovaEvent(); - break; - case kGuardReturnedFn: - guardReturnedEvent(); - break; - case kGuardWalkFn: - guardWalkEvent(); - break; - case kTaxiFn: - taxiEvent(); - break; - case kSearchStartFn: - searchStartEvent(); - break; - default: - break; //shouldn't happen - } - _vm->_allowLoadGame = true; - _vm->_allowSaveGame = true; - return; - } - - if (_state._alarmOn && _state._timeAlarm <= _time) { - _state._alarmOn = false; - alarm(); - return; - } - - _mouseClicked = false; - _keyPressed = false; - Common::Event event; - while (g_system->getEventManager()->pollEvent(event)) { - switch (event.type) { - case Common::EVENT_KEYDOWN: - _keyPressed = true; - processInput(event.kbd); - break; - case Common::EVENT_LBUTTONUP: - // fallthrough - case Common::EVENT_RBUTTONUP: - if (_currentRoom->getId() != INTRO && _sound->isPlaying()) - return; - _mouseClicked = true; - // fallthrough - case Common::EVENT_MOUSEMOVE: - _mouseClickType = event.type; - _mouseX = event.mouse.x; - _mouseY = event.mouse.y; - if (_guiEnabled) - processInput(); - break; - default: - break; - } - } -} - -void GameManager1::corridorOnEntrance() { - if (_state._corridorSearch) - busted(0); -} - -void GameManager1::telomat(int nr) { - static Common::String name[8] = { - "DR. ALAB HANSI", - "ALAB HANSI", - "SAVAL LUN", - "x", - "PROF. DR. UGNUL TSCHABB", - "UGNUL TSCHABB", - "ALGA HURZ LI", - "x" - }; - - static Common::String name2[4] = { - "Alab Hansi", - "Saval Lun", - "Ugnul Tschabb", - "Alga Hurz Li" - }; - - StringId dial1[4]; - dial1[0] = kStringTelomat1; - dial1[1] = kNoString; - dial1[2] = kStringTelomat3; - dial1[3] = kStringDialogSeparator; - - static byte rows1[3] = {1, 2, 1}; - - StringId dial2[4]; - dial2[0] = kStringTelomat4; - dial2[1] = kStringTelomat5; - dial2[2] = kStringTelomat6; - dial2[3] = kStringDialogSeparator; - - static byte rows2[4] = {1, 1, 1, 1}; - - _vm->renderBox(0, 0, 320, 200, kColorBlack); - _vm->renderText(kStringTelomat7, 100, 70, kColorGreen); - _vm->renderText(kStringTelomat8, 100, 81, kColorGreen); - _vm->renderText(kStringTelomat9, 100, 92, kColorGreen); - _vm->renderText(kStringTelomat10, 100, 103, kColorGreen); - _vm->renderText(kStringTelomat11, 100, 120, kColorDarkGreen); - Common::String input; - do { - getInput(); - - switch (_key.keycode) { - case Common::KEYCODE_2: { - _vm->renderBox(0, 0, 320, 200, kColorDarkBlue); - _vm->renderText(kStringTelomat12, 50, 80, kColorGreen); - _vm->renderText(kStringTelomat13, 50, 91, kColorGreen); - do { - edit(input, 50, 105, 30); - } while ((_key.keycode != Common::KEYCODE_RETURN) && (_key.keycode != Common::KEYCODE_ESCAPE)); - - if (_key.keycode == Common::KEYCODE_ESCAPE) { - _vm->renderBox(0, 0, 320, 200, kColorBlack); - _vm->renderRoom(*_currentRoom); - _vm->paletteBrightness(); - _guiEnabled = true; - drawMapExits(); - return; - } - - input.toUppercase(); - - int i = 0; - while ((i < 8) && (input != name[i])) - i++; - i >>= 1; - if (i == 4) { - _vm->renderText(kStringTelomat14, 50, 120, kColorGreen); - wait(10); - _vm->renderBox(0, 0, 320, 200, kColorBlack); - _vm->renderRoom(*_currentRoom); - _vm->paletteBrightness(); - _guiEnabled = true; - drawMapExits(); - return; - } - - if ((i == nr) || _rooms[BCORRIDOR]->getObject(4 + i)->hasProperty(CAUGHT)) { - _vm->renderText(kStringTelomat15, 50, 120, kColorGreen); - wait(10); - _vm->renderBox(0, 0, 320, 200, kColorBlack); - _vm->renderRoom(*_currentRoom); - _vm->paletteBrightness(); - _guiEnabled = true; - drawMapExits(); - return; - } - - _vm->renderText(kStringTelomat16, 50, 120, kColorGreen); - wait(10); - _vm->renderBox(0, 0, 320, 200, kColorBlack); - _vm->renderRoom(*_currentRoom); - _vm->paletteBrightness(); - _vm->renderMessage(kStringTelomat17, kMessageTop, name2[i]); - waitOnInput(_messageDuration); - _vm->removeMessage(); - if (_state._nameSeen[nr]) { - Common::String string = _vm->getGameString(kStringTelomat2); - _vm->setGameString(kStringPlaceholder1, Common::String::format(string.c_str(), name2[nr].c_str())); - dial1[1] = kStringPlaceholder1; - _currentRoom->addSentence(1, 1); - } else - _currentRoom->removeSentence(1, 1); - - switch (dialog(3, rows1, dial1, 1)) { - case 1: _vm->renderMessage(kStringTelomat18, kMessageTop); - waitOnInput(_messageDuration); - _vm->removeMessage(); - if ((_state._destination == 255) && !_rooms[BCORRIDOR]->isSectionVisible(7)) { - _state._eventTime = _time + ticksToMsec(150); - _state._eventCallback = kGuardWalkFn; - _state._origin = i; - _state._destination = nr; - } - break; - case 0: _vm->renderMessage(kStringTelomat19, kMessageTop); - waitOnInput(_messageDuration); - _vm->removeMessage(); - if (dialog(4, rows2, dial2, 0) != 3) { - wait(10); - say(kStringTelomat20); - } - _rooms[BCORRIDOR]->setSectionVisible(7, true); - _rooms[BCORRIDOR]->setSectionVisible(i + 1, true); - _state._eventTime = kMaxTimerValue; - _currentRoom->addSentence(0, 1); - } - _guiEnabled = true; - drawMapExits(); - return; - } - case Common::KEYCODE_1: - case Common::KEYCODE_3: - case Common::KEYCODE_4: - _vm->renderBox(0, 0, 320, 200, kColorDarkBlue); - _vm->renderText(kStringTelomat21, 100, 90, kColorGreen); - input = ""; - do { - edit(input, 100, 105, 30); - } while ((_key.keycode != Common::KEYCODE_RETURN) && (_key.keycode != Common::KEYCODE_ESCAPE)); - - if (_key.keycode == Common::KEYCODE_RETURN) { - _vm->renderText(kStringShipSleepCabin9, 100, 120, kColorGreen); - wait(10); - } - // fallthrough - case Common::KEYCODE_ESCAPE: - _vm->renderBox(0, 0, 320, 200, kColorBlack); - _vm->renderRoom(*_currentRoom); - _vm->paletteBrightness(); - _guiEnabled = true; - drawMapExits(); - return; - default: - break; - } - } while (true); -} - -void GameManager1::startSearch() { - if ((_currentRoom->getId() >= CORRIDOR1) && (_currentRoom->getId() <= BCORRIDOR)) - busted(0); - - _state._corridorSearch = true; -} - -void GameManager1::search(int time) { - _state._eventTime = _time + ticksToMsec(time); - _state._eventCallback = kSearchStartFn; -} - -void GameManager1::guardNoticed() { - _vm->paletteFadeOut(); - Room *r = _currentRoom; - _currentRoom = _rooms[GUARD]; - _vm->setCurrentImage(40); - _vm->renderBox(0, 0, 320, 200, 0); - _vm->renderImage(0); - _vm->paletteFadeIn(); - _vm->renderImage(2); - reply(kStringGuardNoticed1, 2, 5); - wait(2); - reply(kStringGuardNoticed2, 2, 5); - _vm->paletteFadeOut(); - _currentRoom->setSectionVisible(2, false); - _currentRoom->setSectionVisible(5, false); - _currentRoom = r; - _guiEnabled = true; - drawMapExits(); -} - -void GameManager1::busted(int i) { - if (i > 0) - _vm->renderImage(i); - if (i == 0) { - if ((_currentRoom->getId() >= OFFICE_L1) && (_currentRoom->getId() <= OFFICE_R2)) { - if (_currentRoom->getId() < OFFICE_R1) - i = 10; - else - i = 5; - if (!_currentRoom->getObject(0)->hasProperty(OPENED)) { - _vm->renderImage(i - 1); - _sound->play(kAudioDoorOpen); - wait(2); - } - _vm->renderImage(i); - wait(3); - _vm->renderImage(i + 3); - _sound->play(kAudioVoiceHalt); - _vm->renderImage(i); - wait(5); - if (_currentRoom->getId() == OFFICE_L2) - i = 13; - _vm->renderImage(i + 1); - wait(3); - _vm->renderImage(i + 2); - shot(0, 0); - } else if (_currentRoom->getId() == BCORRIDOR) - _vm->renderImage(21); - else if (_currentRoom->isSectionVisible(4)) - _vm->renderImage(32); // below - else if (_currentRoom->isSectionVisible(2)) - _vm->renderImage(30); // right - else if (_currentRoom->isSectionVisible(1)) - _vm->renderImage(31); // left - else - _vm->renderImage(33); // above - } - _sound->play(kAudioVoiceHalt); - wait(3); - shot(0, 0); -} - -void GameManager1::novaScroll() { - static byte planet_f[6] = {0xeb,0xec,0xf0,0xed,0xf1,0xf2}; - static byte nova_f[13] = {0xea,0xe9,0xf5,0xf3,0xf7,0xf4,0xf6, - 0xf9,0xfb,0xfc,0xfd,0xfe,0xfa}; - static byte rgb[65][3] = { - { 5, 0, 0},{10, 0, 0},{15, 0, 0},{20, 0, 0},{25, 0, 0}, - {30, 0, 0},{35, 0, 0},{40, 0, 0},{45, 0, 0},{50, 0, 0}, - {55, 0, 0},{60, 0, 0},{63,10, 5},{63,20,10},{63,30,15}, - {63,40,20},{63,50,25},{63,60,30},{63,63,33},{63,63,30}, - {63,63,25},{63,63,20},{63,63,15},{63,63,10},{60,60,15}, - {57,57,20},{53,53,25},{50,50,30},{47,47,35},{43,43,40}, - {40,40,45},{37,37,50},{33,33,53},{30,30,56},{27,27,59}, - {23,23,61},{20,20,63},{21,25,63},{22,30,63},{25,35,63}, - {30,40,63},{35,45,63},{40,50,63},{45,55,63},{50,60,63}, - {55,63,63},{59,63,63},{63,63,63},{63,60,63},{60,50,60}, - {55,40,55},{50,30,50},{45,20,45},{40,10,40},{42,15,42}, - {45,20,45},{47,25,47},{50,30,50},{52,35,52},{55,40,55}, - {57,45,57},{60,50,60},{62,55,62},{63,60,63},{63,63,63}}; - - byte palette[768]; - _vm->_system->getPaletteManager()->grabPalette(palette, 0, 255); - - for (int t = 0; t < 65; ++t) { - for (int i = 0; i < 6; ++i) { - int idx = 3 * (planet_f[i] - 1); - for (int c = 0 ; c < 3 ; ++c) { - if (palette[idx+c] < rgb[t][c]) - palette[idx+c] = rgb[t][c]; - } - } - for (int cycle = 0; cycle < t && cycle < 13; ++cycle) { - int idx = 3 * (nova_f[cycle] - 1); - for (int c = 0 ; c < 3 ; ++c) - palette[idx + c] = rgb[t - cycle - 1][c]; - } - - _vm->_system->getPaletteManager()->setPalette(palette, 0, 255); - _vm->_system->updateScreen(); - _vm->_system->delayMillis(_vm->_delay); - } -} - -void GameManager1::supernovaEvent() { - _vm->removeMessage(); - CursorMan.showMouse(false); - if (_currentRoom->getId() <= CAVE) { - _vm->renderMessage(kStringSupernova1); - waitOnInput(_messageDuration); - _vm->removeMessage(); - _vm->paletteFadeOut(); - changeRoom(MEETUP); - _rooms[AIRLOCK]->getObject(0)->disableProperty(OPENED); - _rooms[AIRLOCK]->setSectionVisible(3, true); - _rooms[AIRLOCK]->getObject(1)->setProperty(OPENED); - _rooms[AIRLOCK]->setSectionVisible(17, true); - _rooms[AIRLOCK]->setSectionVisible(6, false); - _vm->renderRoom(*_currentRoom); - _vm->paletteFadeIn(); - } - _vm->renderMessage(kStringSupernova2); - waitOnInput(_messageDuration); - _vm->removeMessage(); - _vm->setCurrentImage(26); - _vm->renderImage(0); - _vm->paletteBrightness(); - novaScroll(); - _vm->paletteFadeOut(); - _vm->renderBox(0, 0, 320, 200, kColorBlack); - _vm->_screen->setGuiBrightness(255); - _vm->paletteBrightness(); - - if (_currentRoom->getId() == GLIDER) { - _vm->renderMessage(kStringSupernova3); - waitOnInput(_messageDuration); - _vm->removeMessage(); - _vm->_screen->setGuiBrightness(0); - _vm->paletteBrightness(); - _vm->renderRoom(*_currentRoom); - _vm->paletteFadeIn(); - _vm->renderMessage(kStringSupernova4, kMessageTop); - waitOnInput(_messageDuration); - _vm->removeMessage(); - _vm->renderMessage(kStringSupernova5, kMessageTop); - waitOnInput(_messageDuration); - _vm->removeMessage(); - _vm->renderMessage(kStringSupernova6, kMessageTop); - waitOnInput(_messageDuration); - _vm->removeMessage(); - _vm->renderMessage(kStringSupernova7, kMessageTop); - waitOnInput(_messageDuration); - _vm->removeMessage(); - changeRoom(MEETUP2); - _rooms[MEETUP2]->setSectionVisible(1, true); - _rooms[MEETUP2]->removeSentence(0, 1); - _inventory.remove(*(_rooms[ROGER]->getObject(3))); - _inventory.remove(*(_rooms[ROGER]->getObject(7))); - _inventory.remove(*(_rooms[ROGER]->getObject(8))); - } else { - _vm->renderMessage(kStringSupernova8); - waitOnInput(_messageDuration); - _vm->removeMessage(); - _vm->_screen->setGuiBrightness(0); - _vm->paletteBrightness(); - changeRoom(MEETUP2); - if (_rooms[ROGER]->getObject(3)->hasProperty(CARRIED) && !_rooms[GLIDER]->isSectionVisible(5)) { - _rooms[MEETUP2]->setSectionVisible(1, true); - _rooms[MEETUP2]->setSectionVisible(12, true); - _rooms[MEETUP2]->getObject(1)->_click = 0; - _rooms[MEETUP2]->getObject(0)->_click = 1; - _rooms[MEETUP2]->removeSentence(0, 1); - } - _rooms[MEETUP2]->removeSentence(1, 1); - } - _rooms[AIRLOCK]->getObject(4)->setProperty(WORN); - _rooms[AIRLOCK]->getObject(5)->setProperty(WORN); - _rooms[AIRLOCK]->getObject(6)->setProperty(WORN); - _rooms[CAVE]->getObject(1)->_exitRoom = MEETUP2; - _guiEnabled = true; - CursorMan.showMouse(true); -} - -void GameManager1::guardReturnedEvent() { - if (_currentRoom->getId() == GUARD) - busted(-1); - else if ((_currentRoom->getId() == CORRIDOR9) && (_currentRoom->isSectionVisible(27))) - busted(0); - - _rooms[GUARD]->setSectionVisible(1, false); - _rooms[GUARD]->getObject(3)->_click = 0; - _rooms[GUARD]->setSectionVisible(6, false); - _rooms[GUARD]->getObject(2)->disableProperty(OPENED); - _rooms[GUARD]->setSectionVisible(7, false); - _rooms[GUARD]->getObject(5)->_click = 255; - _rooms[CORRIDOR9]->setSectionVisible(27, false); - _rooms[CORRIDOR9]->setSectionVisible(28, true); - _rooms[CORRIDOR9]->getObject(1)->disableProperty(OPENED); -} - -void GameManager1::walk(int imgId) { - if (_prevImgId) - _vm->renderImage(_prevImgId + 128); - _vm->renderImage(imgId); - _prevImgId = imgId; - wait(3); -} - -void GameManager1::guardWalkEvent() { - _prevImgId = 0; - bool behind = (!_rooms[BCORRIDOR]->getObject(_state._origin + 4)->hasProperty(OCCUPIED) || - _rooms[BCORRIDOR]->getObject(_state._origin + 4)->hasProperty(OPENED)); - _rooms[BCORRIDOR]->getObject(_state._origin + 4)->disableProperty(OCCUPIED); - if (_currentRoom == _rooms[BCORRIDOR]) { - if (_vm->_screen->isMessageShown()) - _vm->removeMessage(); - - if (!behind) { - _vm->renderImage(_state._origin + 1); - _prevImgId = _state._origin + 1; - _sound->play(kAudioDoorOpen); - wait(3); - } - - int imgId; - switch (_state._origin) { - case 0: - imgId = 11; - break; - case 1: - imgId = 16; - break; - case 2: - imgId = 15; - break; - case 3: - default: - imgId = 20; - break; - } - _vm->renderImage(imgId); - if (!behind) { - wait(3); - _vm->renderImage(_prevImgId + 128); - _sound->play(kAudioDoorClose); - } - - _prevImgId = imgId; - wait(3); - switch (_state._origin) { - case 0: - walk(12); - walk(13); - break; - case 1: - walk(17); - walk(18); - break; - case 2: - walk(14); - walk(13); - break; - case 3: - walk(19); - walk(18); - } - - if (!_state._playerHidden) { - if (_state._origin & 1) - walk(10); - else - walk(5); - busted(-1); - } - - if ((_state._origin & 1) && !(_state._destination & 1)) { - for (int i = 10; i >= 5; i--) - walk(i); - walk(13); - } else if (!(_state._origin & 1) && (_state._destination & 1)) { - for (int i = 5; i <= 10; i++) - walk(i); - walk(18); - } - - switch (_state._destination) { - case 0: - for (int i = 13; i >= 11; i--) - walk(i); - break; - case 1: - for (int i = 18; i >= 16; i--) - walk(i); - break; - case 2: - for (int i = 13; i <= 15; i++) - walk(i); - break; - case 3: - for (int i = 18; i <= 20; i++) - walk(i); - } - - if (behind) { - _vm->renderImage(_state._destination + 1); - _sound->play(kAudioDoorOpen); - wait(3); - _vm->renderImage(_prevImgId + 128); - wait(3); - _vm->renderImage(_state._destination + 1 + 128); - _sound->play(kAudioDoorClose); - _rooms[BCORRIDOR]->getObject(_state._destination + 4)->setProperty(OCCUPIED); - _state._destination = 255; - } else if (_rooms[BCORRIDOR]->isSectionVisible(_state._destination + 1)) { - _vm->renderImage(_prevImgId + 128); - _rooms[BCORRIDOR]->getObject(_state._destination + 4)->setProperty(OCCUPIED); - SWAP(_state._origin, _state._destination); - _state._eventTime = _time + ticksToMsec(60); - _state._eventCallback = kGuardWalkFn; - } else { - wait(18); - SWAP(_state._origin, _state._destination); - _state._eventCallback = kGuardWalkFn; - } - } else if (behind) { - _rooms[BCORRIDOR]->getObject(_state._destination + 4)->setProperty(OCCUPIED); - if (_currentRoom == _rooms[OFFICE_L1 + _state._destination]) - busted(0); - _state._destination = 255; - } else if (_rooms[BCORRIDOR]->isSectionVisible(_state._destination + 1) && _rooms[OFFICE_L1 + _state._destination]->getObject(0)->hasProperty(OPENED)) { - _rooms[BCORRIDOR]->getObject(_state._destination + 4)->setProperty(OCCUPIED); - if (_currentRoom == _rooms[OFFICE_L1 + _state._destination]) - busted(0); - SWAP(_state._origin, _state._destination); - _state._eventTime = _time + ticksToMsec(60); - _state._eventCallback = kGuardWalkFn; - } else { - SWAP(_state._origin, _state._destination); - _state._eventCallback = kGuardWalkFn; - } -} - -void GameManager1::taxiEvent() { - if (_currentRoom->getId() == SIGN) { - changeRoom(STATION); - _vm->renderRoom(*_currentRoom); - } - - _vm->renderImage(1); - _vm->renderImage(2); - _sound->play(kAudioRocks); - screenShake(); - _vm->renderImage(9); - _currentRoom->getObject(1)->setProperty(OPENED); - _vm->renderImage(1); - _currentRoom->setSectionVisible(2, false); - _vm->renderImage(3); - for (int i = 4; i <= 8; i++) { - wait(2); - _vm->renderImage(invertSection(i - 1)); - _vm->renderImage(i); - } - _rooms[SIGN]->setSectionVisible(2, false); - _rooms[SIGN]->setSectionVisible(3, true); -} - -void GameManager1::searchStartEvent() { - if ((_currentRoom >= _rooms[CORRIDOR1]) && (_currentRoom <= _rooms[BCORRIDOR])) - busted(0); - _state._corridorSearch = true; -} - -void GameManager1::great(uint number) { - if (number && (_state._greatFlag & (1 << number))) - return; - - _sound->play(kAudioSuccess); - _state._greatFlag |= 1 << number; -} - -bool GameManager1::airless() { - return (_currentRoom->getId() == HOLD || - _currentRoom->getId() == LANDINGMODULE || - _currentRoom->getId() == GENERATOR || - _currentRoom->getId() == OUTSIDE || - _currentRoom->getId() == ROCKS || - _currentRoom->getId() == CAVE || - _currentRoom->getId() == MEETUP || - _currentRoom->getId() == MEETUP2 || - _currentRoom->getId() == MEETUP3 || - (_currentRoom->getId() == AIRLOCK && _rooms[AIRLOCK]->getObject(1)->hasProperty(OPENED))); -} - -void GameManager1::turnOff() { - if (_state._powerOff) - return; - - _state._powerOff = true; - roomBrightness(); -} - -void GameManager1::turnOn() { - if (!_state._powerOff) - return; - - _state._powerOff = false; - _vm->_screen->setViewportBrightness(255); - _rooms[SLEEP]->setSectionVisible(1, false); - _rooms[SLEEP]->setSectionVisible(2, false); - _rooms[COCKPIT]->setSectionVisible(22, false); -} - -void GameManager1::roomBrightness() { - _roomBrightness = 255; - if ((_currentRoom->getId() != OUTSIDE) && (_currentRoom->getId() < ROCKS) && _state._powerOff) - _roomBrightness = 153; - else if (_currentRoom->getId() == CAVE) - _roomBrightness = 0; - else if ((_currentRoom->getId() == GUARD3) && _state._powerOff) - _roomBrightness = 0; - - if (_vm->_screen->getViewportBrightness() != 0) - _vm->_screen->setViewportBrightness(_roomBrightness); - - _vm->paletteBrightness(); -} - -void GameManager1::handleTime() { - if (_timerPaused) - return; - int32 newTime = g_system->getMillis(); - int32 delta = newTime - _oldTime; - _time += delta; - if (_time > 86400000) { - _time -= 86400000; // 24h wrap around - _state._alarmOn = (_state._timeAlarm > _time); - } - if (_animationTimer > delta) - _animationTimer -= delta; - else - _animationTimer = 0; - - _oldTime = newTime; -} - -void GameManager1::loadTime() { - pauseTimer(false); -} - -void GameManager1::saveTime() { - pauseTimer(true); -} - -void GameManager1::shock() { - _sound->play(kAudioShock); - dead(kStringShock); -} - -void GameManager1::drawMapExits() { -// TODO: Preload _exitList on room entry instead on every call - _vm->renderBox(281, 161, 39, 39, kColorWhite25); - - for (int i = 0; i < 25; i++) - _exitList[i] = -1; - for (int i = 0; i < kMaxObject; i++) { - if (_currentRoom->getObject(i)->hasProperty(EXIT)) { - byte r = _currentRoom->getObject(i)->_direction; - _exitList[r] = i; - int x = 284 + 7 * (r % 5); - int y = 164 + 7 * (r / 5); - _vm->renderBox(x, y, 5, 5, kColorDarkRed); - } - } -} - -void GameManager1::shot(int a, int b) { - if (a) - _vm->renderImage(a); - _sound->play(kAudioGunShot); - wait(2); - if (b) - _vm->renderImage(b); - wait(2); - if (a) - _vm->renderImage(a); - _sound->play(kAudioGunShot); - wait(2); - if (b) - _vm->renderImage(b); - - dead(kStringShot); -} - -void GameManager1::takeMoney(int amount) { - Object *moneyObject = _rooms[INTRO]->getObject(4); - _state._money += amount; - _vm->setGameString(kStringInventoryMoney, Common::String::format("%d Xa", _state._money)); - - if (_state._money > 0) { - takeObject(*moneyObject); - if (amount > 0) - great(0); - } else { - _inventory.remove(*moneyObject); - } -} - -void GameManager1::openLocker(const Room *room, Object *obj, Object *lock, int section) { - _vm->renderImage(section); - obj->setProperty(OPENED); - lock->_click = 255; - SWAP(obj->_click, obj->_click2); -} - -void GameManager1::closeLocker(const Room *room, Object *obj, Object *lock, int section) { - if (!obj->hasProperty(OPENED)) - _vm->renderMessage(kStringCloseLocker_1); - else { - _vm->renderImage(invertSection(section)); - obj->disableProperty(OPENED); - lock->_click = lock->_click2; - SWAP(obj->_click, obj->_click2); - } -} - -bool GameManager1::isHelmetOff() { - Object *helmet = _inventory.get(HELMET); - if (helmet && helmet->hasProperty(WORN)) { - _vm->renderMessage(kStringIsHelmetOff_1); - return false; - } - - return true; -} - -bool GameManager1::genericInteract(Action verb, Object &obj1, Object &obj2) { - if ((verb == ACTION_USE) && (obj1._id == SCHNUCK)) { - if (isHelmetOff()) { - takeObject(obj1); - _vm->renderMessage(kStringGenericInteract_1); - _inventory.remove(obj1); - } - } else if ((verb == ACTION_USE) && (obj1._id == EGG)) { - if (isHelmetOff()) { - takeObject(obj1); - if (obj1.hasProperty(OPENED)) - _vm->renderMessage(kStringGenericInteract_1); - else - _vm->renderMessage(kStringGenericInteract_2); - - _inventory.remove(obj1); - } - } else if ((verb == ACTION_OPEN) && (obj1._id == EGG)) { - takeObject(obj1); - if (obj1.hasProperty(OPENED)) - _vm->renderMessage(kStringGenericInteract_3); - else { - takeObject(*_rooms[ENTRANCE]->getObject(8)); - _vm->renderMessage(kStringGenericInteract_4); - obj1.setProperty(OPENED); - } - } else if ((verb == ACTION_USE) && (obj1._id == PILL)) { - if (isHelmetOff()) { - _vm->renderMessage(kStringGenericInteract_5); - great(0); - _inventory.remove(obj1); - _state._language = 2; - takeObject(*_rooms[ENTRANCE]->getObject(17)); - } - } else if ((verb == ACTION_LOOK) && (obj1._id == PILL_HULL) && - (_state._language == 2)) { - _vm->renderMessage(kStringGenericInteract_6); - _state._language = 1; - } else if ((verb == ACTION_OPEN) && (obj1._id == WALLET)) { - if (!_rooms[ROGER]->getObject(3)->hasProperty(CARRIED)) - _vm->renderMessage(kStringGenericInteract_7); - else if (_rooms[ROGER]->getObject(7)->hasProperty(CARRIED)) - _vm->renderMessage(kStringGenericInteract_8); - else { - _vm->renderMessage(kStringGenericInteract_9); - takeObject(*_rooms[ROGER]->getObject(7)); - takeObject(*_rooms[ROGER]->getObject(8)); - } - } else if ((verb == ACTION_LOOK) && (obj1._id == NEWSPAPER)) { - animationOff(); - saveTime(); - - _vm->renderMessage(kStringGenericInteract_10); - waitOnInput(_messageDuration); - _vm->removeMessage(); - _vm->renderMessage(kStringGenericInteract_11); - waitOnInput(_messageDuration); - _vm->removeMessage(); - _vm->setCurrentImage(2); - _vm->renderImage(0); - _vm->setColor63(40); - getInput(); - _vm->renderRoom(*_currentRoom); - roomBrightness(); - _vm->renderMessage(kStringGenericInteract_12); - - loadTime(); - animationOn(); - } else if ((verb == ACTION_LOOK) && (obj1._id == KEYCARD2)) { - _vm->renderMessage(obj1._description); - obj1._description = kStringKeycard2Description2; - } else if ((verb == ACTION_LOOK) && (obj1._id == WATCH)) - _vm->renderMessage(kStringGenericInteract_13, kMessageNormal, timeToString(_time), timeToString(_state._timeAlarm)); - else if ((verb == ACTION_PRESS) && (obj1._id == WATCH)) { - bool validInput = true; - int hours = 0; - int minutes = 0; - - animationOff(); - _vm->saveScreen(88, 87, 144, 24); - _vm->renderBox(88, 87, 144, 24, kColorWhite35); - _vm->renderText(kStringGenericInteract_14, 91, 90, kColorWhite99); - Common::String input; - do { - validInput = true; - input.clear(); - _vm->renderBox(91, 99, 138, 9, kColorDarkBlue); - edit(input, 91, 100, 5); - - int seperator = -1; - for (uint i = 0; i < input.size(); ++i) { - if (input[i] == ':') { - seperator = i; - break; - } - } - if ((seperator == -1) || (seperator > 2)) { - validInput = false; - continue; - } - - int decimalPlace = 1; - for (int i = 0; i < seperator; ++i) { - if (Common::isDigit(input[i])) { - hours = hours * decimalPlace + (input[i] - '0'); - decimalPlace *= 10; - } else { - validInput = false; - break; - } - } - decimalPlace = 1; - for (uint i = seperator + 1; i < input.size(); ++i) { - if (Common::isDigit(input[i])) { - minutes = minutes * decimalPlace + (input[i] - '0'); - decimalPlace *= 10; - } else { - validInput = false; - break; - } - } - if ((hours > 23) || (minutes > 59)) - validInput = false; - - animationOn(); - } while (!validInput && (_key.keycode != Common::KEYCODE_ESCAPE)); - - _vm->restoreScreen(); - if (_key.keycode != Common::KEYCODE_ESCAPE) { - _state._timeAlarm = (hours * 60 + minutes) * 60 * 1000; - _state._alarmOn = (_state._timeAlarm > _time); - } - } else if ((verb == ACTION_USE) && Object::combine(obj1, obj2, TERMINALSTRIP, WIRE)) { - Room *r = _rooms[CABIN_L3]; - if (!r->getObject(8)->hasProperty(CARRIED)) { - if (r->isSectionVisible(26)) - _vm->renderMessage(kStringTakeMessage); - else - return false; - } else { - r->getObject(8)->_name = kStringWireAndClip; - r = _rooms[HOLD]; - _inventory.remove(*r->getObject(2)); - _state._terminalStripConnected = true; - _state._terminalStripWire = true; - _vm->renderMessage(kStringOk); - } - } else if ((verb == ACTION_USE) && Object::combine(obj1, obj2, TERMINALSTRIP, SPOOL)) { - Room *r = _rooms[CABIN_L2]; - takeObject(*r->getObject(9)); - r->getObject(9)->_name = kSringSpoolAndClip; - r = _rooms[HOLD]; - _inventory.remove(*r->getObject(2)); - _state._terminalStripConnected = true; - _vm->renderMessage(kStringOk); - } else if ((verb == ACTION_USE) && Object::combine(obj1, obj2, WIRE, SPOOL)) { - Room *r = _rooms[CABIN_L3]; - if (!_state._terminalStripConnected) { - if (r->isSectionVisible(26)) - _vm->renderMessage(kStringCable3); - else - return false; - } else { - if (!r->getObject(8)->hasProperty(CARRIED)) - _vm->renderMessage(kStringTakeMessage); - else { - r = _rooms[CABIN_L2]; - takeObject(*r->getObject(9)); - r = _rooms[CABIN_L3]; - r->getObject(8)->_name = kStringGeneratorWire; - r = _rooms[CABIN_L2]; - _inventory.remove(*r->getObject(9)); - _state._cableConnected = true; - _vm->renderMessage(kStringOk); - } - } - } else if ((verb == ACTION_USE) && (obj1._id == SUIT)) { - takeObject(obj1); - if ((_currentRoom->getId() >= ENTRANCE) && (_currentRoom->getId() <= ROGER)) { - if (obj1.hasProperty(WORN)) { - _vm->renderMessage(kStringGenericInteract_15); - _rooms[AIRLOCK]->getObject(4)->disableProperty(WORN); - _rooms[AIRLOCK]->getObject(5)->disableProperty(WORN); - _rooms[AIRLOCK]->getObject(6)->disableProperty(WORN); - } else - _vm->renderMessage(kStringGenericInteract_16); - } else { - if (obj1.hasProperty(WORN)) { - Room *r = _rooms[AIRLOCK]; - if (r->getObject(4)->hasProperty(WORN)) - _vm->renderMessage(kStringGenericInteract_17); - else if (r->getObject(6)->hasProperty(WORN)) - _vm->renderMessage(kStringGenericInteract_18); - else { - obj1.disableProperty(WORN); - _vm->renderMessage(kStringGenericInteract_19); - } - } else { - obj1.setProperty(WORN); - _vm->renderMessage(kStringGenericInteract_20); - } - } - } else if ((verb == ACTION_USE) && (obj1._id == HELMET)) { - takeObject(obj1); - if ((_currentRoom->getId() >= ENTRANCE) && (_currentRoom->getId() <= ROGER)) { - if (obj1.hasProperty(WORN)) { - _vm->renderMessage(kStringGenericInteract_21); - _rooms[AIRLOCK]->getObject(4)->disableProperty(WORN); - _rooms[AIRLOCK]->getObject(5)->disableProperty(WORN); - _rooms[AIRLOCK]->getObject(6)->disableProperty(WORN); - } else - _vm->renderMessage(kStringGenericInteract_22); - } else if (obj1.hasProperty(WORN)) { - obj1.disableProperty(WORN); - _vm->renderMessage(kStringGenericInteract_24); - getInput(); - if (airless()) - dead(kStringGenericInteract_23); - } else { - Room *r = _rooms[AIRLOCK]; - if (r->getObject(5)->hasProperty(WORN)) { - obj1.setProperty(WORN); - _vm->renderMessage(kStringGenericInteract_25); - } else - _vm->renderMessage(kStringGenericInteract_26); - } - } else if ((verb == ACTION_USE) && (obj1._id == LIFESUPPORT)) { - takeObject(obj1); - if ((_currentRoom->getId() >= ENTRANCE) && (_currentRoom->getId() <= ROGER)) { - if (obj1.hasProperty(WORN)) { - _vm->renderMessage(kStringGenericInteract_21); - _rooms[AIRLOCK]->getObject(4)->disableProperty(WORN); - _rooms[AIRLOCK]->getObject(5)->disableProperty(WORN); - _rooms[AIRLOCK]->getObject(6)->disableProperty(WORN); - } else - _vm->renderMessage(kStringGenericInteract_22); - } else if (obj1.hasProperty(WORN)) { - obj1.disableProperty(WORN); - _vm->renderMessage(kStringGenericInteract_28); - getInput(); - if (airless()) - dead(kStringGenericInteract_27); - } else { - Room *r = _rooms[AIRLOCK]; - if (r->getObject(5)->hasProperty(WORN)) { - obj1.setProperty(WORN); - _vm->renderMessage(kStringGenericInteract_29); - } else - _vm->renderMessage(kStringGenericInteract_26); - } - } else if ((verb == ACTION_WALK) && (obj1._id == BATHROOM_DOOR)) { - _rooms[BATHROOM]->getObject(2)->_exitRoom = _currentRoom->getId(); - return false; - } else if ((verb == ACTION_USE) && Object::combine(obj1, obj2, WIRE, SOCKET)) - _vm->renderMessage(kStringGenericInteract_30); - else if ((verb == ACTION_LOOK) && (obj1._id == BOOK2)) { - _vm->renderMessage(kStringGenericInteract_31); - waitOnInput(_messageDuration); - _vm->removeMessage(); - _vm->renderMessage(kStringGenericInteract_32); - } else - return false; - - return true; -} - -void GameManager1::handleInput() { - bool validCommand = genericInteract(_inputVerb, *_inputObject[0], *_inputObject[1]); - if (!validCommand) - validCommand = _currentRoom->interact(_inputVerb, *_inputObject[0], *_inputObject[1]); - if (!validCommand) { - switch (_inputVerb) { - case ACTION_LOOK: - _vm->renderMessage(_inputObject[0]->_description); - break; - - case ACTION_WALK: - if (_inputObject[0]->hasProperty(CARRIED)) { - // You already carry this. - _vm->renderMessage(kStringGenericInteract_33); - } else if (!_inputObject[0]->hasProperty(EXIT)) { - // You're already there. - _vm->renderMessage(kStringGenericInteract_34); - } else if (_inputObject[0]->hasProperty(OPENABLE) && !_inputObject[0]->hasProperty(OPENED)) { - // This is closed - _vm->renderMessage(kStringShipHold9); - } else - changeRoom(_inputObject[0]->_exitRoom); - - break; - - case ACTION_TAKE: - if (_inputObject[0]->hasProperty(OPENED)) { - // You already have that - _vm->renderMessage(kStringGenericInteract_35); - } else if (_inputObject[0]->hasProperty(UNNECESSARY)) { - // You do not need that. - _vm->renderMessage(kStringGenericInteract_36); - } else if (!_inputObject[0]->hasProperty(TAKE)) { - // You can't take that. - _vm->renderMessage(kStringGenericInteract_37); - } else - takeObject(*_inputObject[0]); - - break; - - case ACTION_OPEN: - if (!_inputObject[0]->hasProperty(OPENABLE)) { - // This can't be opened - _vm->renderMessage(kStringGenericInteract_38); - } else if (_inputObject[0]->hasProperty(OPENED)) { - // This is already opened. - _vm->renderMessage(kStringGenericInteract_39); - } else if (_inputObject[0]->hasProperty(CLOSED)) { - // This is locked. - _vm->renderMessage(kStringGenericInteract_40); - } else { - _vm->renderImage(_inputObject[0]->_section); - _inputObject[0]->setProperty(OPENED); - byte i = _inputObject[0]->_click; - _inputObject[0]->_click = _inputObject[0]->_click2; - _inputObject[0]->_click2 = i; - _sound->play(kAudioDoorOpen); - } - break; - - case ACTION_CLOSE: - if (!_inputObject[0]->hasProperty(OPENABLE) || - (_inputObject[0]->hasProperty(CLOSED) && - _inputObject[0]->hasProperty(OPENED))) { - // This can't be closed. - _vm->renderMessage(kStringGenericInteract_41); - } else if (!_inputObject[0]->hasProperty(OPENED)) { - // This is already closed. - _vm->renderMessage(kStringCloseLocker_1); - } else { - _vm->renderImage(invertSection(_inputObject[0]->_section)); - _inputObject[0]->disableProperty(OPENED); - byte i = _inputObject[0]->_click; - _inputObject[0]->_click = _inputObject[0]->_click2; - _inputObject[0]->_click2 = i; - _sound->play(kAudioDoorClose); - } - break; - - case ACTION_GIVE: - if (_inputObject[0]->hasProperty(CARRIED)) { - // Better keep it! - _vm->renderMessage(kStringGenericInteract_42); - } - break; - - default: - // This is not possible. - _vm->renderMessage(kStringGenericInteract_43); - } - } -} - -void GameManager1::executeRoom() { - if (_processInput && !_vm->_screen->isMessageShown() && _guiEnabled) { - handleInput(); - if (_mouseClicked) { - Common::Event event; - event.type = Common::EVENT_MOUSEMOVE; - event.mouse = Common::Point(0, 0); - _vm->getEventManager()->pushEvent(event); - event.type = Common::EVENT_MOUSEMOVE; - event.mouse = Common::Point(_mouseX, _mouseY); - _vm->getEventManager()->pushEvent(event); - } - - resetInputState(); - } - - if (_guiEnabled) { - if (!_vm->_screen->isMessageShown()) { - g_system->fillScreen(kColorBlack); - _vm->renderRoom(*_currentRoom); - } - drawMapExits(); - drawInventory(); - drawStatus(); - drawCommandBox(); - } - - roomBrightness(); - if (_vm->_screen->getViewportBrightness() == 0) - _vm->paletteFadeIn(); - - if (!_currentRoom->hasSeen() && _newRoom) { - _newRoom = false; - _currentRoom->onEntrance(); - } -} - -void GameManager1::guardShot() { - _vm->renderImage(2); - _vm->renderImage(5); - wait(3); - _vm->renderImage(2); - - _sound->play(kAudioVoiceHalt); - while (_sound->isPlaying()) - wait(1); - - _vm->renderImage(5); - wait(5); - _vm->renderImage(3); - wait(3); - - shot(4, 3); -} - -void GameManager1::guard3Shot() { - _vm->renderImage(1); - wait(3); - _sound->play(kAudioVoiceHalt); // 46/0 - while (_sound->isPlaying()) - wait(1); - - wait(5); - _vm->renderImage(2); - wait(3); - shot(3,2); -} - -void GameManager1::alarm() { - if (_rooms[INTRO]->getObject(2)->hasProperty(CARRIED)) { - alarmSound(); - if (_currentRoom->getId() == GUARD) - guardShot(); - else if (_currentRoom->getId() == CORRIDOR4 || _currentRoom->getId() == CORRIDOR7) { - guardNoticed(); - _state._corridorSearch = true; - } else if (_currentRoom->getId() == GUARD3) - guard3Shot(); - else if (_currentRoom->getId() == CORRIDOR1) - busted(33); - } else { - if (_currentRoom->getId() == CORRIDOR2 || _currentRoom->getId() == CORRIDOR4 || - _currentRoom->getId() == GUARD || _currentRoom->getId() == CORRIDOR7 || - _currentRoom->getId() == CELL) - { - alarmSound(); - if (_currentRoom->getId() == GUARD) - guardShot(); - guardNoticed(); - if (_currentRoom->getId() == CORRIDOR4) - _state._corridorSearch = true; - } - _rooms[GUARD]->setSectionVisible(1, true); - _rooms[GUARD]->getObject(3)->_click = 255; - if (!_rooms[GUARD]->getObject(5)->hasProperty(CARRIED)) { - _rooms[GUARD]->setSectionVisible(7, true); - _rooms[GUARD]->getObject(5)->_click = 4; - } - _state._eventTime = _time + ticksToMsec(180); - _state._eventCallback = kGuardReturnedFn; - } -} - -void GameManager1::alarmSound() { - animationOff(); - _vm->removeMessage(); - _vm->renderMessage(kStringAlarm); - - int32 end = _time + ticksToMsec(_messageDuration); - do { - _sound->play(kAudioAlarm); - while (_sound->isPlaying()) { - g_system->delayMillis(_vm->_delay); - updateEvents(); - g_system->updateScreen(); - } - } while (_time < end && !_vm->shouldQuit()); - - _vm->removeMessage(); - animationOn(); -} - -} diff --git a/engines/supernova/state.h b/engines/supernova/state.h deleted file mode 100644 index cb38c2ae1d..0000000000 --- a/engines/supernova/state.h +++ /dev/null @@ -1,124 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -#ifndef SUPERNOVA_STATE_H -#define SUPERNOVA_STATE_H - -#include "common/error.h" -#include "common/events.h" -#include "common/rect.h" -#include "common/keyboard.h" -#include "supernova/rooms.h" -#include "supernova/room.h" -#include "supernova/sound.h" -#include "supernova/game-manager.h" - -namespace Supernova { - -class GameManager; - -class GameState { - public: - int32 _timeSleep; - int32 _timeAlarm; - int32 _eventTime; - EventFunction _eventCallback; - int32 _arrivalDaysLeft; - int32 _shipEnergyDaysLeft; - int32 _landingModuleEnergyDaysLeft; - uint16 _greatFlag; - int16 _timeRobot; - int16 _money; - byte _coins; - byte _shoes; - byte _origin; - byte _destination; - byte _language; - bool _corridorSearch; - bool _alarmOn; - bool _terminalStripConnected; - bool _terminalStripWire; - bool _cableConnected; - bool _powerOff; - bool _dream; - bool _nameSeen[4]; - bool _playerHidden; -}; - -class GameManager1 : public GameManager { -public: - GameManager1(SupernovaEngine *vm, Sound *sound); - virtual ~GameManager1(); - - GameState _state; - - virtual void updateEvents(); - virtual void executeRoom(); - virtual bool serialize(Common::WriteStream *out); - virtual bool deserialize(Common::ReadStream *in, int version); - - virtual void initState(); - virtual void initRooms(); - virtual void destroyRooms(); - virtual bool canSaveGameStateCurrently(); - virtual bool genericInteract(Action verb, Object &obj1, Object &obj2); - bool isHelmetOff(); - void great(uint number); - bool airless(); - void shock(); - void turnOff(); - void turnOn(); - virtual void roomBrightness(); - void openLocker(const Room *room, Object *obj, Object *lock, int section); - void closeLocker(const Room *room, Object *obj, Object *lock, int section); - virtual void drawMapExits(); - virtual void handleInput(); - virtual void handleTime(); - virtual void loadTime(); - virtual void saveTime(); - void shot(int a, int b); - virtual void takeMoney(int amount); - void search(int time); - void startSearch(); - void guardNoticed(); - void busted(int i); - void corridorOnEntrance(); - void telomat(int number); - void novaScroll(); - void supernovaEvent(); - void guardReturnedEvent(); - void walk(int a); - void guardWalkEvent(); - void taxiEvent(); - void searchStartEvent(); - void guardShot(); - void guard3Shot(); - void alarm(); - void alarmSound(); - -private: - int _prevImgId; -}; - -} - -#endif // SUPERNOVA_STATE_H diff --git a/engines/supernova/supernova.cpp b/engines/supernova/supernova.cpp index 79d64cdf5d..9c7cdde545 100644 --- a/engines/supernova/supernova.cpp +++ b/engines/supernova/supernova.cpp @@ -45,7 +45,7 @@ #include "supernova/screen.h" #include "supernova/sound.h" #include "supernova/supernova.h" -#include "supernova/state.h" +#include "supernova/supernova1/state.h" #include "supernova/game-manager.h" namespace Supernova { diff --git a/engines/supernova/supernova.h b/engines/supernova/supernova.h index 9655d005bf..d50fe6a2e1 100644 --- a/engines/supernova/supernova.h +++ b/engines/supernova/supernova.h @@ -33,7 +33,7 @@ #include "supernova/console.h" #include "supernova/graphics.h" #include "supernova/msn_def.h" -#include "supernova/rooms.h" +#include "supernova/room.h" #include "supernova/sound.h" #include "supernova/imageid.h" #include "supernova/game-manager.h" diff --git a/engines/supernova/supernova1/rooms.cpp b/engines/supernova/supernova1/rooms.cpp new file mode 100644 index 0000000000..4c5290308d --- /dev/null +++ b/engines/supernova/supernova1/rooms.cpp @@ -0,0 +1,4164 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "common/system.h" +#include "graphics/palette.h" +#include "graphics/cursorman.h" + +#include "supernova/screen.h" +#include "supernova/supernova.h" +#include "supernova/supernova1/state.h" + +namespace Supernova { + +Intro::Intro(SupernovaEngine *vm, GameManager1 *gm) { + _vm = vm; + _gm = gm; + + _fileNumber = -1; + _id = INTRO; + _shown[0] = kShownFalse; + + _objectState[0] = + Object(_id, kStringKeycard, kStringKeycardDescription, KEYCARD, + TAKE | CARRIED | COMBINABLE, 255, 255, 0, NULLROOM, 0); + _objectState[1] = + Object(_id, kStringKnife, kStringKnifeDescription, KNIFE, + TAKE | CARRIED | COMBINABLE, 255, 255, 0, NULLROOM, 0); + _objectState[2] = + Object(_id, kStringWatch, kStringDefaultDescription, WATCH, + TAKE | COMBINABLE | CARRIED, 255, 255, 8, NULLROOM, 0); + _objectState[3] = + Object(_id, kStringDiscman, kStringDiscmanDescription, DISCMAN, + TAKE | COMBINABLE, 255, 255, 0, NULLROOM, 0); + _objectState[4] = + Object(_id, kStringInventoryMoney, kStringDefaultDescription, MONEY, + TAKE | COMBINABLE, 255, 255, 0); + + _shouldExit = false; + + _introText = + _vm->getGameString(kStringIntro1) + '\0' + + _vm->getGameString(kStringIntro2) + '\0' + + _vm->getGameString(kStringIntro3) + '\0' + + _vm->getGameString(kStringIntro4) + '\0' + + _vm->getGameString(kStringIntro5) + '\0' + + _vm->getGameString(kStringIntro6) + '\0' + + _vm->getGameString(kStringIntro7) + '\0' + + _vm->getGameString(kStringIntro8) + '\0' + + _vm->getGameString(kStringIntro9) + '\0' + + _vm->getGameString(kStringIntro10) + '\0' + + _vm->getGameString(kStringIntro11) + '\0' + + _vm->getGameString(kStringIntro12) + '\0' + + _vm->getGameString(kStringIntro13) + '\0'; +} + +void Intro::onEntrance() { + _gm->_guiEnabled = false; + _vm->_allowSaveGame = false; + _vm->_allowLoadGame = false; + titleScreen(); + cutscene(); + leaveCutscene(); +} + +void Intro::titleScreen() { + // Newspaper + CursorMan.showMouse(false); + _vm->_screen->setViewportBrightness(0); + _vm->_screen->setGuiBrightness(0); + _vm->paletteBrightness(); + _vm->setCurrentImage(1); + _vm->renderImage(0); + _vm->paletteFadeIn(); + _gm->getInput(); + _vm->paletteFadeOut(); + + // Title Screen + _vm->setCurrentImage(31); + _vm->renderImage(0); + _vm->paletteFadeIn(); + _gm->wait(1); + _vm->playSound(kAudioVoiceSupernova); + while (_vm->_sound->isPlaying()) + _gm->wait(1); + titleFadeIn(); + _vm->renderText(kStringTitleVersion, 295, 190, kColorWhite44); + const Common::String& title1 = _vm->getGameString(kStringTitle1); + const Common::String& title2 = _vm->getGameString(kStringTitle2); + const Common::String& title3 = _vm->getGameString(kStringTitle3); + _vm->_screen->renderText(title1, 78 - Screen::textWidth(title1) / 2, 120, kColorLightBlue); + _vm->_screen->renderText(title2, 78 - Screen::textWidth(title2) / 2, 132, kColorWhite99); + _vm->_screen->renderText(title3, 78 - Screen::textWidth(title3) / 2, 142, kColorWhite99); + _gm->wait(1); + CursorMan.showMouse(true); + _vm->playSound(kMusicIntro); + + Marquee marquee(_vm->_screen, Marquee::kMarqueeIntro, _introText.c_str()); + while (!_vm->shouldQuit()) { + _gm->updateEvents(); + marquee.renderCharacter(); + if (_gm->_mouseClicked || _gm->_keyPressed) + break; + g_system->updateScreen(); + g_system->delayMillis(_vm->_delay); + } + _vm->playSound(kAudioVoiceYeah); + while (_vm->_sound->isPlaying()) + _gm->wait(1); + _vm->paletteFadeOut(); +} + +void Intro::titleFadeIn() { + byte titlePaletteColor[] = {0xfe, 0xeb}; + byte titleNewColor[2][3] = {{255, 255, 255}, {199, 21, 21}}; + byte newColors[2][3]; + + for (int brightness = 1; brightness <= 40; ++brightness) { + for (int colorIndex = 0; colorIndex < 2; ++colorIndex) { + for (int i = 0; i < 3; ++i) { + newColors[colorIndex][i] = (titleNewColor[colorIndex][i] * brightness) / 40; + } + } + + _vm->_system->getPaletteManager()->setPalette(newColors[0], titlePaletteColor[0], 1); + _vm->_system->getPaletteManager()->setPalette(newColors[1], titlePaletteColor[1], 1); + _vm->_system->updateScreen(); + _vm->_system->delayMillis(_vm->_delay); + } +} + +bool Intro::animate(int section1, int section2, int duration) { + Common::KeyCode key = Common::KEYCODE_INVALID; + while (duration) { + _vm->renderImage(section1); + if (_gm->waitOnInput(2, key)) + return key != Common::KEYCODE_ESCAPE; + _vm->renderImage(section2); + if (_gm->waitOnInput(2, key)) + return key != Common::KEYCODE_ESCAPE; + --duration; + } + return true; +} + +bool Intro::animate(int section1, int section2, int duration, + MessagePosition position, StringId textId) { + Common::KeyCode key = Common::KEYCODE_INVALID; + const Common::String& text = _vm->getGameString(textId); + _vm->renderMessage(text, position); + int delay = (MIN(text.size(), (uint)512) + 20) * (10 - duration) * _vm->_textSpeed / 400; + while (delay) { + if (section1) + _vm->renderImage(section1); + if (_gm->waitOnInput(2, key)) { + _vm->removeMessage(); + return key != Common::KEYCODE_ESCAPE; + } + if (section2) + _vm->renderImage(section2); + if (_gm->waitOnInput(2, key)) { + _vm->removeMessage(); + return key != Common::KEYCODE_ESCAPE; + } + --delay; + } + _vm->removeMessage(); + return true; +} + +bool Intro::animate(int section1, int section2, int section3, int section4, + int duration, MessagePosition position, StringId textId) { + Common::KeyCode key = Common::KEYCODE_INVALID; + const Common::String& text = _vm->getGameString(textId); + _vm->renderMessage(text, position); + if (duration == 0) + duration = (MIN(text.size(), (uint)512) + 20) * _vm->_textSpeed / 40; + + while(duration) { + _vm->renderImage(section1); + _vm->renderImage(section3); + if (_gm->waitOnInput(2, key)) { + _vm->removeMessage(); + return key != Common::KEYCODE_ESCAPE; + } + _vm->renderImage(section2); + _vm->renderImage(section4); + if (_gm->waitOnInput(2, key)) { + _vm->removeMessage(); + return key != Common::KEYCODE_ESCAPE; + } + duration--; + } + _vm->removeMessage(); + return true; +} + +void Intro::cutscene() { +#define exitOnEscape(X) do { \ + Common::KeyCode key = Common::KEYCODE_INVALID; \ + if ((_gm->waitOnInput(X, key) && key == Common::KEYCODE_ESCAPE) || _vm->shouldQuit()) { \ + CursorMan.showMouse(true); \ + return; \ + } \ +} while (0); + + _vm->_system->fillScreen(kColorBlack); + _vm->setCurrentImage(31); + _vm->_screen->setGuiBrightness(255); + _vm->paletteBrightness(); + if (!animate(0, 0, 0, kMessageNormal, kStringIntroCutscene1)) + return; + _vm->_screen->setGuiBrightness(0); + _vm->paletteBrightness(); + exitOnEscape(1); + + _vm->setCurrentImage(9); + _vm->renderImage(0); + _vm->renderImage(1); + _vm->renderImage(9); + _vm->paletteFadeIn(); + if (!animate(11, 10, 6, kMessageRight, kStringIntroCutscene2)) + return; + _vm->renderImage(3); + exitOnEscape(4); + _vm->renderImage(4); + if (!animate(11, 10, 3)) {// test duration + _vm->removeMessage(); + return; + } + _vm->removeMessage(); + if (!animate(5, 4, 0, kMessageLeft, kStringIntroCutscene3)) + return; + _vm->renderImage(3); + exitOnEscape(3); + _vm->renderImage(2); + exitOnEscape(3); + _vm->renderImage(7); + exitOnEscape(6); + _vm->renderImage(6); + exitOnEscape(6); + if (!animate(0, 0, 0, kMessageLeft, kStringIntroCutscene4)) + return; + _vm->renderMessage(kStringIntroCutscene5, kMessageLeft); + exitOnEscape(28); + _vm->removeMessage(); + _vm->renderMessage(kStringIntroCutscene6, kMessageLeft); + exitOnEscape(28); + _vm->removeMessage(); + + StringId textCounting[4] = + {kStringIntroCutscene7, kStringIntroCutscene8, kStringIntroCutscene9, kStringIntroCutscene10}; + _vm->setCurrentImage(31); + _vm->renderImage(0); + _vm->paletteBrightness(); + for (int i = 0; i < 4; ++i){ + _vm->renderMessage(textCounting[i], kMessageLeft); + for (int j = 0; j < 28; ++j) { + _vm->renderImage((j % 3) + 1); + Common::KeyCode key = Common::KEYCODE_INVALID; + if (_gm->waitOnInput(1, key)) { + if (key == Common::KEYCODE_ESCAPE) + return; + break; + } + } + _vm->removeMessage(); + } + _vm->renderMessage(kStringIntroCutscene11, kMessageLeft); + _vm->renderImage(6); + exitOnEscape(3); + _vm->renderImage(3); + exitOnEscape(3); + _vm->renderImage(4); + exitOnEscape(3); + _vm->renderImage(5); + exitOnEscape(3); + _vm->renderImage(_gm->invertSection(5)); + exitOnEscape(18); + _vm->removeMessage(); + + _vm->setCurrentImage(9); + _vm->renderImage(0); + _vm->renderImage(1); + _vm->renderImage(9); + _vm->paletteBrightness(); + _vm->renderBox(0, 138, 320, 62, kColorBlack); + _vm->paletteBrightness(); + if (!animate(11, 10, 0, kMessageRight, kStringIntroCutscene12)) + return; + _vm->renderImage(3); + exitOnEscape(3); + _vm->renderImage(4); + if (!animate(5, 4, 0, kMessageLeft, kStringIntroCutscene13)) + return; + if (!animate(0, 0, 0, kMessageCenter, kStringIntroCutscene14)) + return; + _vm->renderImage(12); + exitOnEscape(2); + _vm->renderImage(13); + exitOnEscape(2); + _vm->renderImage(14); + if (!animate(19, 20, 0, kMessageRight, kStringIntroCutscene15)) + return; + if (!animate(0, 0, 0, kMessageCenter, kStringIntroCutscene16)) + return; + exitOnEscape(20); + if (!animate(0, 0, 0, kMessageCenter, kStringIntroCutscene17)) + return; + if (!animate(19, 20, 0, kMessageRight, kStringIntroCutscene18)) + return; + if (!animate(0, 0, 0, kMessageCenter, kStringIntroCutscene19)) + return; + _vm->renderImage(16); + exitOnEscape(3); + _vm->renderImage(17); + if (!animate(19, 20, 18, 17, 0, kMessageRight, kStringIntroCutscene20)) + return; + if (!animate(19, 20, 18, 17, 0, kMessageRight, kStringIntroCutscene21)) + return; + if (!animate(5, 4, 0, kMessageLeft, kStringIntroCutscene3)) + return; + _vm->renderImage(3); + exitOnEscape(3); + _vm->renderImage(2); + exitOnEscape(3); + _vm->renderImage(8); + exitOnEscape(6); + _vm->renderImage(6); + _vm->playSound(kAudioSiren); + + exitOnEscape(6); + _vm->renderImage(3); + exitOnEscape(3); + _vm->renderImage(4); + _vm->renderImage(16); + exitOnEscape(3); + _vm->renderImage(15); + if (!animate(19, 20, 0, kMessageRight, kStringIntroCutscene22)) + return; + if (!animate(19, 20, 0, kMessageRight, kStringIntroCutscene23)) + return; + exitOnEscape(10); + _vm->renderImage(13); + exitOnEscape(2); + _vm->renderImage(12); + exitOnEscape(2); + _vm->renderImage(9); + if (!animate(11, 10, 0, kMessageRight, kStringIntroCutscene24)) + return; + if (!animate(5, 4, 0, kMessageLeft, kStringIntroCutscene3)) + return; + _vm->paletteFadeOut(); + + while (_vm->_sound->isPlaying()) + exitOnEscape(1); + + _vm->_system->fillScreen(kColorBlack); + _vm->_screen->setGuiBrightness(255); + _vm->paletteBrightness(); + if (!animate(0, 0, 0, kMessageNormal, kStringIntroCutscene25)) + return; + _vm->_screen->setGuiBrightness(5); + _vm->paletteBrightness(); + + _vm->setCurrentImage(31); + _vm->renderImage(0); + _vm->paletteFadeIn(); + if (!animate(0, 0, 0, kMessageNormal, kStringIntroCutscene26)) + return; + if (!animate(0, 0, 0, kMessageNormal, kStringIntroCutscene27)) + return; + if (!animate(0, 0, 0, kMessageNormal, kStringIntroCutscene28)) + return; + if (!animate(0, 0, 0, kMessageNormal, kStringIntroCutscene29)) + return; + exitOnEscape(54); + if (!animate(0, 0, 0, kMessageNormal, kStringIntroCutscene30)) + return; + if (!animate(0, 0, 0, kMessageNormal, kStringIntroCutscene31)) + return; + if (!animate(0, 0, 0, kMessageNormal, kStringIntroCutscene32)) + return; + + CursorMan.showMouse(false); + _vm->_screen->setViewportBrightness(0); + _vm->paletteBrightness(); + exitOnEscape(10); + _vm->playSound(kAudioSnoring); + while (_vm->_sound->isPlaying()) + _gm->wait(1); + exitOnEscape(10); + _vm->playSound(kAudioSnoring); + while (_vm->_sound->isPlaying()) + _gm->wait(1); + exitOnEscape(10); + _vm->playSound(kAudioSnoring); + while (_vm->_sound->isPlaying()) + _gm->wait(1); + exitOnEscape(30); + CursorMan.showMouse(true); + + _vm->setCurrentImage(22); + if (!animate(0, 0, 0, kMessageNormal, kStringIntroCutscene33)) + return; + exitOnEscape(18); + if (!animate(0, 0, 0, kMessageNormal, kStringIntroCutscene34)) + return; + if (!animate(0, 0, 0, kMessageNormal, kStringIntroCutscene35)) + return; + if (!animate(0, 0, 0, kMessageNormal, kStringIntroCutscene36)) + return; + if (!animate(0, 0, 0, kMessageNormal, kStringIntroCutscene37)) + return; + exitOnEscape(18); + if (!animate(0, 0, 0, kMessageNormal, kStringIntroCutscene38)) + return; + if (!animate(0, 0, 0, kMessageNormal, kStringIntroCutscene39)) + return; + exitOnEscape(18); + if (!animate(0, 0, 0, kMessageNormal, kStringIntroCutscene40)) + return; + if (!animate(0, 0, 0, kMessageNormal, kStringIntroCutscene41)) + return; + exitOnEscape(36); + animate(0, 0, 0, kMessageNormal, kStringIntroCutscene42); + _vm->removeMessage(); + +#undef exitOnEscape +} + +void Intro::leaveCutscene() { + _vm->_screen->setViewportBrightness(255); + _vm->removeMessage(); + _gm->changeRoom(CABIN_R3); + _gm->_guiEnabled = true; + _vm->_allowSaveGame = true; + _vm->_allowLoadGame = true; +} + +ShipCorridor::ShipCorridor(SupernovaEngine *vm, GameManager1 *gm) { + _vm = vm; + _gm = gm; + + _fileNumber = 17; + _id = CORRIDOR; + _shown[0] = kShownTrue; + _shown[4] = kShownTrue; + + _objectState[0] = Object(_id, kStringHatch, kStringDefaultDescription, HATCH1, OPENABLE | EXIT, 0, 6, 1, CABIN_L1, 15); + _objectState[1] = Object(_id, kStringHatch, kStringDefaultDescription, NULLOBJECT, OPENABLE | EXIT, 1, 7, 2, CABIN_L2, 10); + _objectState[2] = Object(_id, kStringHatch, kStringDefaultDescription, NULLOBJECT, OPENABLE | EXIT, 2, 8, 3, CABIN_L3, 5); + _objectState[3] = Object(_id, kStringHatch, kStringDefaultDescription, NULLOBJECT, OPENABLE | EXIT, 5, 11, 6, CABIN_R1, 19); + _objectState[4] = Object(_id, kStringHatch, kStringDefaultDescription, NULLOBJECT, OPENABLE | EXIT, 4, 10, 5, CABIN_R2, 14); + _objectState[5] = Object(_id, kStringHatch, kStringDefaultDescription, NULLOBJECT, OPENABLE | EXIT | OPENED, 9, 3, 4, CABIN_R3, 9); + _objectState[6] = Object(_id, kStringHatch, kStringDefaultDescription, NULLOBJECT, OPENABLE | CLOSED | EXIT, 12, 12, 0, AIRLOCK, 2); + _objectState[7] = Object(_id, kStringButton, kStringHatchButtonDescription, BUTTON, PRESS, 13, 13, 0, NULLROOM, 0); + _objectState[8] = Object(_id, kStringLadder, kStringDefaultDescription, NULLOBJECT, NULLTYPE, 14, 14, 0, NULLROOM, 0); + _objectState[9] = Object(_id, kStringExit, kStringDefaultDescription, NULLOBJECT, EXIT, 15, 15, 0, HALL, 22); +} + +bool ShipCorridor::interact(Action verb, Object &obj1, Object &obj2) { + if ((verb == ACTION_PRESS) && (obj1._id == BUTTON)) { + if (_objectState[6].hasProperty(OPENED)) { + _vm->playSound(kAudioSlideDoor); + _objectState[6].disableProperty(OPENED); + _vm->renderImage(8); + setSectionVisible(9, false); + _gm->wait(2); + _vm->renderImage(7); + setSectionVisible(8, false); + _gm->wait(2); + _vm->renderImage(_gm->invertSection(7)); + } else { + _vm->playSound(kAudioSlideDoor); + _objectState[6].setProperty(OPENED); + _vm->renderImage(7); + _gm->wait(2); + _vm->renderImage(8); + setSectionVisible(7, false); + _gm->wait(2); + _vm->renderImage(9); + setSectionVisible(8, false); + } + return true; + } + return false; +} + +ShipHall::ShipHall(SupernovaEngine *vm, GameManager1 *gm) { + _vm = vm; + _gm = gm; + + _fileNumber = 15; + _id = HALL; + _shown[0] = kShownTrue; + + _objectState[0] = Object(_id, kStringHatch, kStringCockpitHatchDescription, NULLOBJECT, OPENABLE | EXIT, 4, 5, 1, COCKPIT, 10); + _objectState[1] = Object(_id, kStringHatch, kStringKitchenHatchDescription, KITCHEN_HATCH, OPENABLE | EXIT, 0, 0, 0, NULLROOM, 1); + _objectState[2] = Object(_id, kStringHatch, kStringStasisHatchDescription, NULLOBJECT, OPENABLE | CLOSED | EXIT, 1, 1, 2, SLEEP, 8); + _objectState[3] = Object(_id, kStringSlot, kStringSlotDescription, SLEEP_SLOT, COMBINABLE, 2, 2, 0, NULLROOM, 0); + _objectState[4] = Object(_id, kStringLadder, kStringDefaultDescription, NULLOBJECT, NULLTYPE, 3, SLEEP, 0, NULLROOM, 0); + _objectState[5] = Object(_id, kStringCorridor, kStringDefaultDescription, NULLOBJECT, EXIT, 6, 6, 0, CORRIDOR, 19); +} + +bool ShipHall::interact(Action verb, Object &obj1, Object &obj2) { + if ((verb == ACTION_OPEN) && (obj1._id == KITCHEN_HATCH)) { + _vm->renderMessage(kStringShipHall1); + } else if ((verb == ACTION_USE) && Object::combine(obj1,obj2,KEYCARD2,SLEEP_SLOT)) { + if (_objectState[2].hasProperty(OPENED)) { + _objectState[2].disableProperty(OPENED); + _vm->renderImage(3); + setSectionVisible(4, false); + _gm->wait(2); + _vm->renderImage(2); + setSectionVisible(3, false); + _gm->wait(2); + _vm->renderImage(_gm->invertSection(2)); + } else { + _objectState[2].setProperty(OPENED); + _vm->renderImage(2); + _gm->wait(2); + _vm->renderImage(3); + setSectionVisible(2, false); + _gm->wait(2); + _vm->renderImage(4); + setSectionVisible(3, false); + _gm->great(1); + } + } else { + return false; + } + + return true; +} + +ShipSleepCabin::ShipSleepCabin(SupernovaEngine *vm, GameManager1 *gm) { + _vm = vm; + _gm = gm; + + _fileNumber = 33; + _id = SLEEP; + _shown[0] = kShownTrue; + _color = kColorBlack; + + _objectState[0] = Object(_id, kStringHatch, kStringStasisHatchDescription2, CABINS, NULLTYPE, 0, 0, 0, NULLROOM, 0); + _objectState[1] = Object(_id, kStringHatch, kStringStasisHatchDescription2, CABIN, NULLTYPE, 1, 1, 0, NULLROOM, 0); + _objectState[2] = Object(_id, kStringComputer, kStringDefaultDescription, COMPUTER, NULLTYPE, 2, 2, 0, NULLROOM, 0); + _objectState[3] = Object(_id, kStringExit, kStringDefaultDescription, NULLOBJECT, EXIT, 255, 255, 0, HALL, 22); +} + +bool ShipSleepCabin::interact(Action verb, Object &obj1, Object &obj2) { + Room *room; + Common::String input; + + if (((verb == ACTION_LOOK) || (verb == ACTION_USE)) && (obj1._id == COMPUTER)) { + _gm->_guiEnabled = false; + setSectionVisible(4, false); + g_system->fillScreen(kColorDarkBlue); + if (_gm->_state._arrivalDaysLeft == 0) { + // Destination reached + _vm->renderText(kStringShipSleepCabin1, 60, 95, kColorWhite99); + _gm->getInput(); + } else if (_gm->_state._powerOff) { + // Energy depleted + _vm->renderText(kStringShipSleepCabin2, 60, 95, kColorWhite99); + // Artificial coma interrupted + _vm->renderText(kStringShipSleepCabin3, 60, 115, kColorWhite99); + _gm->getInput(); + } else if (isSectionVisible(5)) { + // Sleep duration in days + _vm->renderText(kStringShipSleepCabin4, 30, 85, kColorWhite99); + _vm->renderText(Common::String::format("%d",_gm->_state._timeSleep).c_str(), + 150, 85, kColorWhite99); + _vm->renderText(kStringShipSleepCabin5, 30, 105, kColorWhite99); + _gm->getInput(); + } else { + _vm->renderText(kStringShipSleepCabin6, 100, 85, kColorWhite99); + _gm->edit(input, 100, 105, 30); + + input.toUppercase(); + if (_gm->_key.keycode != Common::KEYCODE_ESCAPE) { + if (input == _vm->getGameString(kStringComputerPassword)) { + _gm->great(6); + g_system->fillScreen(kColorDarkBlue); + _vm->renderText(kStringShipSleepCabin7, 30, 85, kColorWhite99); + uint daysSleep = 0; + do { + input.clear(); + _vm->renderBox(150, 85, 150, 8, kColorDarkBlue); + _gm->edit(input, 150, 85, 10); + + if (_gm->_key.keycode == Common::KEYCODE_ESCAPE) { + break; + } else { + daysSleep = input.asUint64(); + for (uint i = 0; i < input.size(); i++) { + if (!Common::isDigit(input[i])) { + daysSleep = 0; + break; + } + } + } + if (daysSleep != 0) { + _gm->_state._timeSleep = daysSleep; + _vm->renderText(kStringShipSleepCabin8, 30, 105, kColorWhite99); + _gm->wait(18); + setSectionVisible(5, true); + } + } while (daysSleep == 0); + } else { + _vm->renderText(kStringShipSleepCabin9, 100, 125, kColorLightRed); + _gm->wait(18); + } + } + } + + _gm->_guiEnabled = true; + input.clear(); + } else if (((verb == ACTION_WALK) || (verb == ACTION_USE)) && + ((obj1._id == CABINS) || (obj1._id == CABIN))) { + room = _gm->_rooms[AIRLOCK]; + if (!(obj1._id == CABIN) || !isSectionVisible(5)) { + _vm->renderMessage(kStringShipSleepCabin10); + } else if (room->getObject(5)->hasProperty(WORN)) { + _vm->renderMessage(kStringShipSleepCabin11); + } else { + _vm->paletteFadeOut(); + _vm->renderImage(_gm->invertSection(5)); + _vm->renderImage(_gm->invertSection(4)); + room = _gm->_rooms[GENERATOR]; + int32 *energyDaysLeft; + if (room->isSectionVisible(9)) { + energyDaysLeft = &_gm->_state._landingModuleEnergyDaysLeft; + } else { + energyDaysLeft = &_gm->_state._shipEnergyDaysLeft; + } + if (_gm->_state._timeSleep > _gm->_state._arrivalDaysLeft) { + _gm->_state._timeSleep = _gm->_state._arrivalDaysLeft; + } + if (_gm->_state._timeSleep >= *energyDaysLeft) { + _gm->_state._timeSleep = *energyDaysLeft; + if (room->isSectionVisible(9)) { + room = _gm->_rooms[LANDINGMODULE]; // Monitors off + room->setSectionVisible(2, false); + room->setSectionVisible(7, false); + room->setSectionVisible(8, false); + room->setSectionVisible(9, false); + room->setSectionVisible(10, false); + } + } + if (_gm->_state._timeSleep == _gm->_state._arrivalDaysLeft) { + _vm->renderImage(3); + room = _gm->_rooms[COCKPIT]; + room->setSectionVisible(23, true); + room = _gm->_rooms[CABIN_R2]; + room->setSectionVisible(5, false); + room->setSectionVisible(6, true); + room->getObject(2)->_click = 10; + room = _gm->_rooms[HOLD]; + room->setSectionVisible(0, false); + room->setSectionVisible(1, true); + room->getObject(1)->_click = 255; + room->getObject(3)->_click = 255; + room = _gm->_rooms[GENERATOR]; + room->setSectionVisible(6, false); + room->setSectionVisible(7, true); + room->getObject(1)->_click = 14; + if (room->isSectionVisible(1)) { + room->setSectionVisible(10, true); + } + if (room->isSectionVisible(12)) { + room->setSectionVisible(12, false); + room->setSectionVisible(11, true); + } + } + _gm->_state._arrivalDaysLeft -= _gm->_state._timeSleep; + *energyDaysLeft -= _gm->_state._timeSleep; + _gm->_time = ticksToMsec(786520); // 12pm + _gm->_state._alarmOn = (_gm->_state._timeAlarm > _gm->_time); + if (*energyDaysLeft == 0) { + _gm->turnOff(); + room = _gm->_rooms[GENERATOR]; + room->setSectionVisible(4, room->isSectionVisible(2)); + } + if (_gm->_state._arrivalDaysLeft == 0) { + _gm->saveTime(); + if (!_vm->saveGame(kSleepAutosaveSlot, "Sleep autosave")) + _vm->errorTempSave(true); + _gm->_state._dream = true; + _gm->loadTime(); + } + _gm->wait(18); + _vm->paletteFadeIn(); + if (_gm->_state._arrivalDaysLeft == 0) { + _vm->playSound(kAudioCrash); + _gm->screenShake(); + _gm->wait(18); + _vm->renderMessage(kStringShipSleepCabin12); + } + } + } else { + return false; + } + + return true; +} + +void ShipSleepCabin::animation() { + if (_gm->_state._powerOff && _gm->_state._arrivalDaysLeft) { + if (_gm->_guiEnabled) { + if (isSectionVisible(1)) { + _vm->renderImage(2); + setSectionVisible(1, false); + } else { + _vm->renderImage(1); + setSectionVisible(2, false); + } + } else { + if (_color == kColorLightRed) { + _color = kColorDarkBlue; + } else { + _color = kColorLightRed; + } + + _vm->renderText(kStringShipSleepCabin13, 60, 75, _color); + } + } else if (isSectionVisible(5) && _gm->_guiEnabled) { + if (isSectionVisible(4)) + _vm->renderImage(_gm->invertSection(4)); + else + _vm->renderImage(4); + } + + _gm->setAnimationTimer(6); +} +void ShipSleepCabin::onEntrance() { + if (_gm->_state._dream && (_gm->_rooms[CAVE]->getObject(1)->_exitRoom == MEETUP3)) { + _vm->renderMessage(kStringShipSleepCabin14); + _gm->waitOnInput(_gm->_messageDuration); + _vm->removeMessage(); + _vm->renderMessage(kStringShipSleepCabin15); + _gm->waitOnInput(_gm->_messageDuration); + _vm->removeMessage(); + _vm->renderMessage(kStringShipSleepCabin16); + _gm->_state._dream = false; + } +} + +ShipCockpit::ShipCockpit(SupernovaEngine *vm, GameManager1 *gm) { + _vm = vm; + _gm = gm; + + _fileNumber = 9; + _id = COCKPIT; + _shown[0] = kShownTrue; + _color = kColorBlack; + + _objectState[0] = Object(_id, kStringInstruments, kStringInstrumentsDescription1, INSTRUMENTS, NULLTYPE, 2, 2, 0, NULLROOM, 0); + _objectState[1] = Object(_id, kStringMonitor, kStringDefaultDescription, MONITOR, NULLTYPE, 0, 0, 0, NULLROOM, 0); + _objectState[2] = Object(_id, kStringMonitor, kStringMonitorDescription, NULLOBJECT, TAKE, 1, 0, 0, NULLROOM, 0); + _objectState[3] = Object(_id, kStringExit, kStringDefaultDescription, NULLOBJECT, EXIT, 255, 255, 0, HALL, 22); +} + +bool ShipCockpit::interact(Action verb, Object &obj1, Object &obj2) { + // TODO: distance and remaining time not accurate + + if ((verb == ACTION_LOOK) && (obj1._id == MONITOR)) { + char c[2] = {0, 0}; + _gm->_guiEnabled = false; + _vm->renderBox(0, 0, 320, 200, kColorBlack); + _vm->renderText(kStringShipCockpit1, 50, 50, kColorLightYellow); + if (_gm->_state._arrivalDaysLeft) + _vm->renderText(kStringShipCockpit2); + else + _vm->renderText(kStringShipCockpit3); + _vm->renderText(kStringShipCockpit4, 50, 70, kColorLightYellow); + _vm->renderText(kStringShipCockpit5, 50, 90, kColorLightYellow); + _vm->renderText(Common::String::format("%d", _gm->_state._arrivalDaysLeft / 400).c_str()); + _vm->renderText(","); + c[0] = (_gm->_state._arrivalDaysLeft / 40) % 10 + '0'; + _vm->renderText(c); + c[0] = (_gm->_state._arrivalDaysLeft / 4) % 10 + '0'; + _vm->renderText(c); + _vm->renderText(kStringShipCockpit6); + _vm->renderText(kStringShipCockpit7, 50, 110, kColorLightYellow); + _vm->renderText(Common::String::format("%d", _gm->_state._arrivalDaysLeft).c_str(), + 50, 120, kColorLightYellow); + _vm->renderText(kStringShipCockpit8); + + _gm->getInput(); + _gm->_guiEnabled = true; + } else if ((verb == ACTION_USE) && (obj1._id == INSTRUMENTS)) + _vm->renderMessage(kStringShipCockpit9); + else + return false; + + return true; +} +void ShipCockpit::animation() { + if (!_gm->_guiEnabled) { + if (_color) { + _color = kColorBlack; + _gm->setAnimationTimer(5); + } else { + _color = kColorLightYellow; + _gm->setAnimationTimer(10); + } + _vm->renderText(kStringShipCockpit10, 50, 145, _color); + } else if (isSectionVisible(21)) { + _vm->renderImage(_gm->invertSection(21)); + _gm->setAnimationTimer(5); + } else { + _vm->renderImage(21); + _gm->setAnimationTimer(10); + } + + if (_gm->_state._powerOff) { + if (!_gm->_guiEnabled) { + _vm->renderText(kStringShipCockpit11, 97, 165, _color); + _vm->renderText(kStringShipCockpit12, 97, 175, _color); + } else if (isSectionVisible(21)) + _vm->renderImage(22); + else + _vm->renderImage(_gm->invertSection(22)); + } +} + +void ShipCockpit::onEntrance() { + if (!hasSeen()) + _vm->renderMessage(kStringShipCockpit13); + setRoomSeen(true); +} + +ShipCabinL1::ShipCabinL1(SupernovaEngine *vm, GameManager1 *gm) { + _vm = vm; + _gm = gm; + + _fileNumber = 21; + _id = CABIN_L1; + _shown[0] = kShownTrue; + _shown[1] = kShownTrue; + _shown[2] = kShownTrue; + _shown[3] = kShownTrue; + _shown[4] = kShownTrue; + _shown[5] = kShownTrue; + + _objectState[0] = Object(_id, kStringImage, kStringGenericDescription1, NULLOBJECT, UNNECESSARY, 5, 5, 0, NULLROOM, 0); + _objectState[1] = Object(_id, kStringImage, kStringGenericDescription2, NULLOBJECT, UNNECESSARY, 6, 6, 0, NULLROOM, 0); + _objectState[2] = Object(_id, kStringImage, kStringGenericDescription3, NULLOBJECT, UNNECESSARY, 7, 7, 0, NULLROOM, 0); + _objectState[3] = Object(_id, kStringMagnete, kStringMagneteDescription, NULLOBJECT, UNNECESSARY, 8, 8, 0, NULLROOM, 0); + _objectState[4] = Object(_id, kStringImage, kStringGenericDescription4, NULLOBJECT, UNNECESSARY, 9, 9, 0); + _objectState[5] = Object(_id, kStringPen, kStringPenDescription, PEN, TAKE | COMBINABLE, 10, 10, 5 | 128); + _objectState[6] = Object(_id, kStringHatch, kStringDefaultDescription, NULLOBJECT, OPENABLE | OPENED | EXIT, 3, 3, 24 | 128, CORRIDOR, 9); + _objectState[7] = Object(_id, kStringSlot, kStringSlotDescription, NULLOBJECT, COMBINABLE, 0, 0, 0); + _objectState[8] = Object(_id, kStringShelf, kStringDefaultDescription, NULLOBJECT, OPENABLE | CLOSED, 1, 1, 0); + _objectState[9] = Object(_id, kStringCompartment, kStringDefaultDescription, NULLOBJECT, OPENABLE | CLOSED, 2, 2, 0); + _objectState[10] = Object(_id, kStringSocket, kStringDefaultDescription, SOCKET, COMBINABLE, 4, 4, 0); + _objectState[11] = Object(_id, kStringToilet, kStringDefaultDescription, BATHROOM_DOOR, EXIT, 255, 255, 0, BATHROOM, 22); +} + +ShipCabinL2::ShipCabinL2(SupernovaEngine *vm, GameManager1 *gm) { + _vm = vm; + _gm = gm; + + _fileNumber = 21; + _id = CABIN_L2; + _shown[0] = kShownTrue; + _shown[16] = kShownTrue; + + _objectState[0] = Object(_id, kStringSlot,kStringSlotDescription,SLOT_KL1,COMBINABLE,31,31,0); + _objectState[1] = Object(_id, kStringSlot,kStringSlotDescription,SLOT_KL2,COMBINABLE,32,32,0); + _objectState[2] = Object(_id, kStringSlot,kStringSlotDescription,SLOT_KL3,COMBINABLE,33,33,0); + _objectState[3] = Object(_id, kStringSlot,kStringSlotDescription,SLOT_KL4,COMBINABLE,45,45,0); + _objectState[4] = Object(_id, kStringShelf,kStringDefaultDescription,SHELF_L1,OPENABLE | CLOSED,25,26,17); + _objectState[5] = Object(_id, kStringPistol,kStringPistolDescription,PISTOL,TAKE,39,39,20); + _objectState[6] = Object(_id, kStringCompartment,kStringDefaultDescription,SHELF_L2,OPENABLE | CLOSED,27,28,18); + _objectState[7] = Object(_id, kStringBooks,kStringBooksDescription,NULLOBJECT,UNNECESSARY,40,40,0); + _objectState[8] = Object(_id, kStringCompartment,kStringDefaultDescription,SHELF_L3,OPENABLE | CLOSED,29,30,19); + _objectState[9] = Object(_id, kStringSpool,kStringSpoolDescription, SPOOL,TAKE | COMBINABLE,41,41,21); + _objectState[10] = Object(_id, kStringCompartment,kStringDefaultDescription,SHELF_L4,OPENABLE | CLOSED,43,44,22); + _objectState[11] = Object(_id, kStringBook,kStringDefaultDescription,BOOK2,TAKE,46,46,23); + _objectState[12] = Object(_id, kStringUnderwear,kStringUnderwearDescription,NULLOBJECT,UNNECESSARY,34,34,0); + _objectState[13] = Object(_id, kStringUnderwear,kStringUnderwearDescription,NULLOBJECT,UNNECESSARY,35,35,0); + _objectState[14] = Object(_id, kStringClothes,kStringDefaultDescription,NULLOBJECT,UNNECESSARY,36,36,0); + _objectState[15] = Object(_id, kStringJunk,kStringJunkDescription,NULLOBJECT,UNNECESSARY,37,37,0); + _objectState[16] = Object(_id, kStringJunk,kStringJunkDescription,NULLOBJECT,UNNECESSARY,38,38,0); + _objectState[17] = Object(_id, kStringMagnete,kStringMagneteDescription,NULLOBJECT,UNNECESSARY,23,23,0); + _objectState[18] = Object(_id, kStringToilet,kStringDefaultDescription,BATHROOM_DOOR,EXIT,255,255,0,BATHROOM,22); + _objectState[19] = Object(_id, kStringHatch,kStringDefaultDescription,NULLOBJECT,OPENABLE | OPENED | EXIT,3,3,24 | 128,CORRIDOR,9); + _objectState[20] = Object(_id, kStringSlot,kStringSlotDescription,NULLOBJECT,COMBINABLE,0,0,0); + _objectState[21] = Object(_id, kStringShelf,kStringDefaultDescription,NULLOBJECT,OPENABLE | CLOSED,1,1,0); + _objectState[22] = Object(_id, kStringCompartment,kStringDefaultDescription,NULLOBJECT,OPENABLE | CLOSED,2,2,0); + _objectState[23] = Object(_id, kStringSocket,kStringDefaultDescription,SOCKET,COMBINABLE,4,4,0); + _objectState[24] = Object(_id, kStringFolders,kStringFoldersDescription,NULLOBJECT,UNNECESSARY,49,49,0); +} + +bool ShipCabinL2::interact(Action verb, Object &obj1, Object &obj2) { + if ((verb == ACTION_USE) && Object::combine(obj1, obj2, SLOT_KL1, KEYCARD2)) { + _gm->openLocker(this, getObject(4), getObject(0), 17); + if (getObject(5)->_click == 255) + _vm->renderImage(20); // Remove Pistol + _gm->great(2); + } else if ((verb == ACTION_USE) && Object::combine(obj1, obj2, SLOT_KL2, KEYCARD2)) { + _gm->openLocker(this, getObject(6), getObject(1), 18); + _gm->great(2); + } else if ((verb == ACTION_USE) && Object::combine(obj1, obj2, SLOT_KL3, KEYCARD2)) { + _gm->openLocker(this, getObject(8), getObject(2), 19); + if (getObject(9)->_click == 255) + _vm->renderImage(21); // Remove cable spool + _gm->great(2); + } else if ((verb == ACTION_USE) && Object::combine(obj1, obj2, SLOT_KL4, KEYCARD2)) { + _gm->openLocker(this, getObject(10), getObject(3), 22); + if (getObject(11)->_click == 255) + _vm->renderImage(23); // Remove book + _gm->great(2); + } else if ((verb == ACTION_CLOSE) && (obj1._id == SHELF_L1)) { + _gm->closeLocker(this, getObject(4), getObject(0), 17); + setSectionVisible(20, false); + } else if ((verb == ACTION_CLOSE) && (obj1._id == SHELF_L2)) + _gm->closeLocker(this, getObject(6), getObject(1), 18); + else if ((verb == ACTION_CLOSE) && (obj1._id == SHELF_L3)) { + _gm->closeLocker(this, getObject(8), getObject(2), 19); + setSectionVisible(21, false); + } else if ((verb == ACTION_CLOSE) && (obj1._id == SHELF_L4)) { + _gm->closeLocker(this, getObject(10), getObject(3), 22); + setSectionVisible(23, false); + } else if ((verb == ACTION_TAKE) && (obj1._id == SPOOL) && !obj1.hasProperty(CARRIED)) { + getObject(8)->_click = 42; // empty shelf + return false; + } else if ((verb == ACTION_TAKE) && (obj1._id == BOOK2) && !obj1.hasProperty(CARRIED)) { + getObject(10)->_click = 47; // empty shelf + return false; + } else + return false; + + return true; +} + +ShipCabinL3::ShipCabinL3(SupernovaEngine *vm, GameManager1 *gm) { + _vm = vm; + _gm = gm; + + _fileNumber = 21; + _id = CABIN_L3; + _shown[0] = kShownTrue; + _shown[6] = kShownTrue; + _shown[7] = kShownTrue; + _shown[8] = kShownTrue; + _shown[9] = kShownTrue; + _shown[12] = kShownTrue; + + _objectState[0] = Object(_id, kStringPoster,kStringPosterDescription1,NULLOBJECT,UNNECESSARY,11,11,0); + _objectState[1] = Object(_id, kStringPoster,kStringPosterDescription2,NULLOBJECT,UNNECESSARY,12,12,0); + _objectState[2] = Object(_id, kStringSpeaker,kStringDefaultDescription,NULLOBJECT,NULLTYPE,13,13,0); + _objectState[3] = Object(_id, kStringMagnete,kStringMagneteDescription,NULLOBJECT,UNNECESSARY,14,14,0); + _objectState[4] = Object(_id, kStringRecord,kStringRecordDescription,RECORD,TAKE | COMBINABLE,15,15,8 | 128); + _objectState[5] = Object(_id, kStringRecordStand,kStringRecordStandDescription,NULLOBJECT,UNNECESSARY,16,16,0); + _objectState[6] = Object(_id, kStringButton,kStringDefaultDescription,TURNTABLE_BUTTON,PRESS,22,22,0); + _objectState[7] = Object(_id, kStringTurntable,kStringTurntableDescription,TURNTABLE,UNNECESSARY | COMBINABLE,17,17,0); + _objectState[8] = Object(_id, kStringWire,kStringDefaultDescription,WIRE,COMBINABLE,18,18,0); + _objectState[9] = Object(_id, kStringWire,kStringDefaultDescription,WIRE2,COMBINABLE,19,19,0); + _objectState[10] = Object(_id, kStringPlug,kStringDefaultDescription,PLUG,COMBINABLE,20,20,0); + _objectState[11] = Object(_id, kStringHatch,kStringDefaultDescription,NULLOBJECT,OPENABLE | OPENED | EXIT,3,3,24 | 128,CORRIDOR,9); + _objectState[12] = Object(_id, kStringSlot,kStringSlotDescription,NULLOBJECT,COMBINABLE,0,0,0); + _objectState[13] = Object(_id, kStringShelf,kStringDefaultDescription,NULLOBJECT,OPENABLE | CLOSED,1,1,0); + _objectState[14] = Object(_id, kStringCompartment,kStringDefaultDescription,NULLOBJECT,OPENABLE | CLOSED,2,2,0); + _objectState[15] = Object(_id, kStringSocket,kStringDefaultDescription,SOCKET,COMBINABLE,4,4,0); + _objectState[16] = Object(_id, kStringToilet,kStringDefaultDescription,BATHROOM_DOOR,EXIT,255,255,0,BATHROOM,22); +} + +bool ShipCabinL3::interact(Action verb, Object &obj1, Object &obj2) { + Room *r; + + if ((verb == ACTION_USE) && Object::combine(obj1, obj2, RECORD, TURNTABLE)) { + if (!_gm->_guiEnabled || isSectionVisible(15)) + _vm->renderMessage(kStringShipCabinL3_1); + else { + if (!getObject(4)->hasProperty(CARRIED)) + _vm->renderImage(_gm->invertSection(8)); + else + _gm->_inventory.remove(*getObject(4)); + _vm->renderImage(15); + getObject(4)->_click = 48; + } + } else if ((verb == ACTION_PRESS) && (obj1._id == TURNTABLE_BUTTON)) { + if (!isSectionVisible(15)) { + _vm->renderMessage(kStringShipCabinL3_2); + } else if (!isSectionVisible(10) && !isSectionVisible(11) && isSectionVisible(12)) { + _vm->renderImage(14); + setSectionVisible(15, false); + for (int i = 3; i; i--) { + _vm->playSound(kAudioTurntable); + while (_vm->_sound->isPlaying()) { + if (isSectionVisible(13)) { + _vm->renderImage(14); + setSectionVisible(13, false); + } else { + _vm->renderImage(13); + setSectionVisible(14, false); + } + _gm->wait(3); + } + } + + _vm->renderImage(15); + setSectionVisible(14, false); + setSectionVisible(13, false); + _vm->renderMessage(kStringShipCabinL3_3); + } + } else if ((verb == ACTION_TAKE) && (obj1._id == RECORD) && (obj1._click != 15)) { + _vm->renderImage(9); + setSectionVisible(13, false); + setSectionVisible(14, false); + setSectionVisible(15, false); + obj1._section = 0; + _gm->takeObject(obj1); + } else if ((verb == ACTION_PULL) && (obj1._id == PLUG)) { + _vm->renderImage(10); + setSectionVisible(7, false); + obj1._click = 21; + } else if ((verb == ACTION_USE) && Object::combine(obj1, obj2, PLUG, SOCKET)) { + _vm->renderImage(7); + setSectionVisible(10, false); + getObject(10)->_click = 20; + } else if ((verb == ACTION_USE) && Object::combine(obj1, obj2, KNIFE, WIRE2)) + _vm->renderMessage(kStringShipCabinL3_4); // cutting near plug + else if ((verb == ACTION_USE) && Object::combine(obj1, obj2, KNIFE, WIRE)) { + r = _gm->_rooms[AIRLOCK]; + if (!isSectionVisible(10) && !r->getObject(5)->hasProperty(WORN)) { + _vm->renderImage(25); + _gm->shock(); + } + _vm->renderImage(11); + _vm->renderImage(26); + setSectionVisible(12, false); + } else if ((verb == ACTION_TAKE) && ((obj1._id == WIRE) || (obj1._id == WIRE2) || (obj1._id == PLUG))) { + if (isSectionVisible(10) && isSectionVisible(11)) { + _vm->renderImage(_gm->invertSection(10)); + _vm->renderImage(_gm->invertSection(11)); + getObject(8)->_name = kStringWireAndPlug; + _gm->takeObject(*getObject(8)); + getObject(9)->_click = 255; + getObject(10)->_click = 255; + } else + _vm->renderMessage(kStringShipCabinL3_5); + } else + return false; + + return true; +} + +ShipCabinR1::ShipCabinR1(SupernovaEngine *vm, GameManager1 *gm) { + _vm = vm; + _gm = gm; + + _fileNumber = 22; + _id = CABIN_R1; + _shown[0] = kShownTrue; + _shown[1] = kShownTrue; + _shown[2] = kShownTrue; + + _objectState[0] = Object(_id, kStringImage,kStringImageDescription1,NULLOBJECT,UNNECESSARY,5,5,0); + _objectState[1] = Object(_id, kStringDrawingInstruments,kStringDrawingInstrumentsDescription,NULLOBJECT,UNNECESSARY,6,6,0); + _objectState[2] = Object(_id, kStringMagnete,kStringMagneteDescription,NULLOBJECT,UNNECESSARY,7,7,0); + _objectState[3] = Object(_id, kStringHatch,kStringDefaultDescription,NULLOBJECT,OPENABLE | OPENED | EXIT,3,3,15 | 128,CORRIDOR,5); + _objectState[4] = Object(_id, kStringSlot,kStringSlotDescription,NULLOBJECT,COMBINABLE,0,0,0); + _objectState[5] = Object(_id, kStringShelf,kStringDefaultDescription,NULLOBJECT,OPENABLE | CLOSED,1,1,0); + _objectState[6] = Object(_id, kStringCompartment,kStringDefaultDescription,NULLOBJECT,OPENABLE | CLOSED,2,2,0); + _objectState[7] = Object(_id, kStringSocket,kStringDefaultDescription,SOCKET,COMBINABLE,4,4,0); + _objectState[8] = Object(_id, kStringToilet,kStringDefaultDescription,BATHROOM_DOOR,EXIT,255,255,0,BATHROOM,22); +} + +ShipCabinR2::ShipCabinR2(SupernovaEngine *vm, GameManager1 *gm) { + _vm = vm; + _gm = gm; + + _fileNumber = 22; + _id = CABIN_R2; + _shown[0] = kShownTrue; + _shown[3] = kShownTrue; + _shown[4] = kShownTrue; + _shown[5] = kShownTrue; + + _objectState[0] = Object(_id, kStringChessGame,kStringChessGameDescription1,NULLOBJECT,UNNECESSARY,11,11,0); + _objectState[1] = Object(_id, kStringTennisRacket,kStringTennisRacketDescription,NULLOBJECT,UNNECESSARY,8,8,0); + _objectState[2] = Object(_id, kStringTennisBall,kStringGenericDescription2,NULLOBJECT,UNNECESSARY,9,9,0); + _objectState[3] = Object(_id, kStringHatch,kStringDefaultDescription,NULLOBJECT,OPENABLE | OPENED | EXIT,3,3,15 | 128,CORRIDOR,5); + _objectState[4] = Object(_id, kStringSlot,kStringSlotDescription,NULLOBJECT,COMBINABLE,0,0,0); + _objectState[5] = Object(_id, kStringShelf,kStringDefaultDescription,NULLOBJECT,OPENABLE | CLOSED,1,1,0); + _objectState[6] = Object(_id, kStringCompartment,kStringDefaultDescription,NULLOBJECT,OPENABLE | CLOSED,2,2,0); + _objectState[7] = Object(_id, kStringSocket,kStringDefaultDescription,SOCKET,COMBINABLE,4,4,0); + _objectState[8] = Object(_id, kStringToilet,kStringDefaultDescription,BATHROOM_DOOR,EXIT,255,255,0,BATHROOM,22); +} + +ShipCabinR3::ShipCabinR3(SupernovaEngine *vm, GameManager1 *gm) { + _vm = vm; + _gm = gm; + + _fileNumber = 22; + _id = CABIN_R3; + _shown[0] = kShownTrue; + _shown[7] = kShownTrue; + _shown[8] = kShownTrue; + _shown[15] = kShownTrue; + + _objectState[0] = Object(_id, kStringChessGame,kStringChessGameDescription2,CHESS,TAKE | COMBINABLE,12,12,7 | 128); + _objectState[1] = Object(_id, kStringBed,kStringBedDescription,NULLOBJECT,NULLTYPE,13,13,0); + _objectState[2] = Object(_id, kStringSlot,kStringSlotDescription,SLOT_K1,COMBINABLE,27,27,0); + _objectState[3] = Object(_id, kStringSlot,kStringSlotDescription,SLOT_K2,COMBINABLE,28,28,0); + _objectState[4] = Object(_id, kStringSlot,kStringSlotDescription,SLOT_K3,COMBINABLE,29,29,0); + _objectState[5] = Object(_id, kStringSlot,kStringSlotDescription,SLOT_K4,COMBINABLE,30,30,0); + _objectState[6] = Object(_id, kStringCompartment,kStringCompartmentDescription,SHELF1,OPENABLE | CLOSED,14,18,9); + _objectState[7] = Object(_id, kStringAlbums,kStringAlbumsDescription,NULLOBJECT,UNNECESSARY,14,14,0); + _objectState[8] = Object(_id, kStringCompartment,kStringCompartmentDescription,SHELF2,OPENABLE | CLOSED,15,19,10); + _objectState[9] = Object(_id, kStringRope,kStringRopeDescription,ROPE,TAKE | COMBINABLE,15,15,12); + _objectState[10] = Object(_id, kStringShelf,kStringShelfDescription,SHELF3,OPENABLE | CLOSED,16,17,11); + _objectState[11] = Object(_id, kStringJunk,kStringJunkDescription,NULLOBJECT,UNNECESSARY,20,20,0); + _objectState[12] = Object(_id, kStringClothes,kStringClothesDescription,NULLOBJECT,UNNECESSARY,21,21,0); + _objectState[13] = Object(_id, kStringUnderwear,kStringDefaultDescription,NULLOBJECT,UNNECESSARY,22,22,0); + _objectState[14] = Object(_id, kStringSocks,kStringDefaultDescription,NULLOBJECT,UNNECESSARY,23,23,0); + _objectState[15] = Object(_id, kStringCompartment,kStringCompartmentDescription,SHELF4,OPENABLE | CLOSED,24,25,13); + _objectState[16] = Object(_id, kStringBook,kStringBookHitchhiker,BOOK,TAKE,26,26,14); + _objectState[17] = Object(_id, kStringDiscman,kStringDiscmanDescription,DISCMAN,TAKE | COMBINABLE,33,33,16); + _objectState[18] = Object(_id, kStringHatch,kStringDefaultDescription,NULLOBJECT,OPENABLE | EXIT,3,3,15 | 128,CORRIDOR,5); + _objectState[19] = Object(_id, kStringSlot,kStringSlotDescription,NULLOBJECT,COMBINABLE,0,0,0); + _objectState[20] = Object(_id, kStringShelf,kStringDefaultDescription,NULLOBJECT,OPENABLE | CLOSED,1,1,0); + _objectState[21] = Object(_id, kStringCompartment,kStringDefaultDescription,NULLOBJECT,OPENABLE | CLOSED,2,2,0); + _objectState[22] = Object(_id, kStringSocket,kStringDefaultDescription,SOCKET,COMBINABLE,4,4,0); + _objectState[23] = Object(_id, kStringToilet,kStringDefaultDescription,BATHROOM_DOOR,EXIT,255,255,0,BATHROOM,22); +} + +bool ShipCabinR3::interact(Action verb, Object &obj1, Object &obj2) { + if ((verb == ACTION_USE) && Object::combine(obj1, obj2, SLOT_K1, KEYCARD)) + _gm->openLocker(this, getObject(6), getObject(2), 9); + else if ((verb == ACTION_USE) && Object::combine(obj1, obj2, SLOT_K2, KEYCARD)) { + _gm->openLocker(this, getObject(8), getObject(3), 10); + if (getObject(9)->_click == 255) + _vm->renderImage(12); // Remove rope + } else if ((verb == ACTION_USE) && Object::combine(obj1, obj2, SLOT_K3, KEYCARD)) { + _gm->openLocker(this, getObject(10), getObject(4), 11); + if (getObject(17)->_click == 255) + _vm->renderImage(16); // Remove Discman + } else if ((verb == ACTION_USE) && Object::combine(obj1, obj2, SLOT_K4, KEYCARD)) { + _gm->openLocker(this, getObject(15), getObject(5), 13); + if (getObject(16)->_click == 255) + _vm->renderImage(14); // Remove Book + } else if ((verb == ACTION_CLOSE) && (obj1._id == SHELF1)) + _gm->closeLocker(this, getObject(6), getObject(2), 9); + else if ((verb == ACTION_CLOSE) && (obj1._id == SHELF2)) { + setSectionVisible(12, false); + _gm->closeLocker(this, getObject(8), getObject(3), 10); + } else if ((verb == ACTION_CLOSE) && (obj1._id == SHELF3)) { + setSectionVisible(16, false); + _gm->closeLocker(this, getObject(10), getObject(4), 11); + } else if ((verb == ACTION_CLOSE) && (obj1._id == SHELF4)) { + setSectionVisible(14, false); + setSectionVisible(14, false); + _gm->closeLocker(this, getObject(15), getObject(5), 13); + } else if ((verb == ACTION_TAKE) && (obj1._id == DISCMAN) && !_gm->_rooms[0]->getObject(3)->hasProperty(CARRIED)) { + getObject(10)->_click = 34; // Locker empty + obj1._click = 255; + _gm->takeObject(*_gm->_rooms[0]->getObject(3)); + _vm->renderImage(16); + } else if ((verb == ACTION_TAKE) && (obj1._id == ROPE) && obj1.hasProperty(CARRIED)) { + getObject(8)->_click = 31; // Shelf empty + return false; + } else if ((verb == ACTION_TAKE) && (obj1._id == BOOK) && !obj1.hasProperty(CARRIED)) { + getObject(15)->_click = 32; // Shelf empty + return false; + } else + return false; + + return true; +} + +void ShipCabinR3::onEntrance() { + for (int i = 0; i < 3; ++i) + _gm->_inventory.add(*_gm->_rooms[INTRO]->getObject(i)); + + setRoomSeen(true); +} + +ShipCabinBathroom::ShipCabinBathroom(SupernovaEngine *vm, GameManager1 *gm) { + _vm = vm; + _gm = gm; + + _fileNumber = 23; + _id = BATHROOM; + _shown[0] = kShownTrue; + + _objectState[0] = Object(_id, kStringBathroom,kStringBathroomDescription,TOILET,NULLTYPE,0,0,0); + _objectState[1] = Object(_id, kStringShower,kStringDefaultDescription,SHOWER,NULLTYPE,1,1,0); + _objectState[2] = Object(_id, kStringExit,kStringDefaultDescription,BATHROOM_EXIT,EXIT,255,255,0,CABIN_R3,2); +} + +ShipAirlock::ShipAirlock(SupernovaEngine *vm, GameManager1 *gm) { + _vm = vm; + _gm = gm; + + _fileNumber = 34; + _id = AIRLOCK; + _shown[0] = kShownTrue; + _shown[6] = kShownTrue; + + _objectState[0] = Object(_id, kStringHatch,kStringHatchDescription1,NULLOBJECT,EXIT | OPENABLE | OPENED | CLOSED,0,0,0,CORRIDOR,10); + _objectState[1] = Object(_id, kStringHatch,kStringHatchDescription2,NULLOBJECT,EXIT | OPENABLE | CLOSED,1,1,0,HOLD,14); + _objectState[2] = Object(_id, kStringButton,kStringDefaultDescription,BUTTON1,PRESS,2,2,0); + _objectState[3] = Object(_id, kStringButton,kStringDefaultDescription,BUTTON2,PRESS,3,3,0); + _objectState[4] = Object(_id, kStringHelmet,kStringHelmetDescription,HELMET,TAKE,4,4,7); + _objectState[5] = Object(_id, kStringSuit,kStringSuitDescription,SUIT,TAKE,5,5,8); + _objectState[6] = Object(_id, kStringLifeSupport,kStringLifeSupportDescription,LIFESUPPORT,TAKE,6,6,9); +} + +bool ShipAirlock::interact(Action verb, Object &obj1, Object &obj2) { + Room *r; + + if ((verb == ACTION_PRESS) && (obj1._id == BUTTON1)) { + if (!getObject(1)->hasProperty(OPENED)) { + _vm->renderImage(10); + _vm->playSound(kAudioSlideDoor); + if (getObject(0)->hasProperty(OPENED)) { + getObject(0)->disableProperty(OPENED); + _vm->renderImage(1); + _gm->wait(2); + _vm->renderImage(2); + setSectionVisible(1, false); + _gm->wait(2); + _vm->renderImage(3); + setSectionVisible(2, false); + } else { + getObject(0)->setProperty(OPENED); + _vm->renderImage(2); + setSectionVisible(3, false); + _gm->wait(2); + _vm->renderImage(1); + setSectionVisible(2, false); + _gm->wait(2); + _vm->renderImage(_gm->invertSection(1)); + } + _vm->renderImage(_gm->invertSection(10)); + } + } else if ((verb == ACTION_PRESS) && (obj1._id == BUTTON2)) { + if (!getObject(0)->hasProperty(OPENED)) { + _vm->renderImage(11); + if (getObject(1)->hasProperty(OPENED)) { + _vm->playSound(kAudioSlideDoor); + getObject(1)->disableProperty(OPENED); + _vm->renderImage(4); + _gm->wait(2); + _vm->renderImage(5); + setSectionVisible(4, false); + _gm->wait(2); + _vm->renderImage(6); + setSectionVisible(5, false); + _vm->renderImage(16); + setSectionVisible(17, false); + _gm->wait(3); + _vm->renderImage(15); + setSectionVisible(16, false); + _gm->wait(3); + _vm->renderImage(14); + setSectionVisible(15, false); + _gm->wait(3); + _vm->renderImage(13); + setSectionVisible(14, false); + _gm->wait(3); + _vm->renderImage(12); + setSectionVisible(13, false); + _gm->wait(3); + _vm->renderImage(_gm->invertSection(12)); + } else { + getObject(1)->setProperty(OPENED); + _vm->renderImage(12); + _gm->wait(3); + _vm->renderImage(13); + setSectionVisible(12, false); + _gm->wait(3); + _vm->renderImage(14); + setSectionVisible(13, false); + _gm->wait(3); + _vm->renderImage(15); + setSectionVisible(14, false); + _gm->wait(3); + _vm->renderImage(16); + setSectionVisible(15, false); + _gm->wait(3); + _vm->renderImage(17); + setSectionVisible(16, false); + _vm->playSound(kAudioSlideDoor); + _vm->renderImage(5); + setSectionVisible(6, false); + _gm->wait(2); + _vm->renderImage(4); + setSectionVisible(5, false); + _gm->wait(2); + _vm->renderImage(_gm->invertSection(4)); + r = _gm->_rooms[AIRLOCK]; + if (!r->getObject(4)->hasProperty(WORN) || + !r->getObject(5)->hasProperty(WORN) || + !r->getObject(6)->hasProperty(WORN)) { + _gm->dead(kStringShipAirlock1); + return true; + } + } + _vm->renderImage(_gm->invertSection(11)); + } + } else if ((verb == ACTION_LOOK) && (obj1._id == MANOMETER)) + _vm->renderMessage(getObject(1)->hasProperty(OPENED) ? kStringShipAirlock2 : kStringShipAirlock3); + else + return false; + + return true; +} + +void ShipAirlock::onEntrance() { + if (!hasSeen()) + _vm->renderMessage(kStringShipAirlock4); + + setRoomSeen(true); +} + +ShipHold::ShipHold(SupernovaEngine *vm, GameManager1 *gm) { + _vm = vm; + _gm = gm; + + _fileNumber = 24; + _id = HOLD; + _shown[0] = kShownTrue; + + _objectState[0] = Object(_id, kNoString,kStringDefaultDescription,HOLD_WIRE,COMBINABLE,255,255,0); + _objectState[1] = Object(_id, kStringScrap,kStringScrapDescription1,SCRAP_LK,NULLTYPE,4,4,0); + _objectState[2] = Object(_id, kStringTerminalStrip,kStringDefaultDescription,TERMINALSTRIP,COMBINABLE,255,255,0); + _objectState[3] = Object(_id, kStringScrap,kStringScrapDescription2,NULLOBJECT,NULLTYPE,5,5,0); + _objectState[4] = Object(_id, kStringReactor,kStringReactorDescription,NULLOBJECT,NULLTYPE,6,6,0); + _objectState[5] = Object(_id, kStringNozzle,kStringDefaultDescription,NULLOBJECT,NULLTYPE,7,7,0); + _objectState[6] = Object(_id, kStringPumpkin,kStringPumpkinDescription,NULLOBJECT,NULLTYPE,8,8,0); + _objectState[7] = Object(_id, kStringHatch,kStringDefaultDescription,LANDINGMOD_OUTERHATCH,EXIT | OPENABLE,1,2,2,LANDINGMODULE,6); + _objectState[8] = Object(_id, kStringLandingModule,kStringLandingModuleDescription,NULLOBJECT,NULLTYPE,0,0,0); + _objectState[9] = Object(_id, kStringExit,kStringDefaultDescription,NULLOBJECT,EXIT,255,255,0,AIRLOCK,22); + _objectState[10] = Object(_id, kStringHatch,kStringHatchDescription3,OUTERHATCH_TOP,EXIT | OPENABLE | OPENED,3,3,0,GENERATOR,8); + _objectState[11] = Object(_id, kStringGenerator,kStringGeneratorDescription,GENERATOR_TOP,EXIT,12,12,0,GENERATOR,8); +} + +bool ShipHold::interact(Action verb, Object &obj1, Object &obj2) { + Room *room; + + if ((verb == ACTION_LOOK) && (obj1._id == SCRAP_LK) && (obj1._description != kStringScrapDescription3)) { + _vm->renderMessage(obj1._description); + obj1._description = kStringScrapDescription3; + _gm->takeObject(*getObject(2)); + } else if (((verb == ACTION_OPEN) || (verb == ACTION_CLOSE)) && (obj1._id == OUTERHATCH_TOP)) + _vm->renderMessage(kStringShipHold1); + else if ((verb == ACTION_CLOSE) && (obj1._id == LANDINGMOD_HATCH) && (isSectionVisible(4) || isSectionVisible(6))) + _vm->renderMessage(kStringCable1); + else if (((verb == ACTION_TAKE) && (obj1._id == HOLD_WIRE)) || + ((verb == ACTION_USE) && Object::combine(obj1, obj2, HOLD_WIRE, LANDINGMOD_HATCH))) + _vm->renderMessage(kStringCable2); + else if ((verb == ACTION_USE) && Object::combine(obj1, obj2, TERMINALSTRIP, HOLD_WIRE)) { + getObject(0)->_name = kStringWireAndClip; + _gm->_inventory.remove(*getObject(2)); + _gm->_state._terminalStripConnected = true; + _gm->_state._terminalStripWire = true; + _vm->renderMessage(kStringOk); + } else if ((verb == ACTION_USE) && Object::combine(obj1, obj2, HOLD_WIRE, SPOOL)) { + if (!_gm->_state._terminalStripConnected) + _vm->renderMessage(kStringCable3); + else { + _vm->renderImage(5); + getObject(0)->_name = kStringWireAndPlug2; + getObject(0)->_click = 10; + room = _gm->_rooms[CABIN_L2]; + _gm->_inventory.remove(*getObject(9)); + } + } else if ((verb == ACTION_USE) && Object::combine(obj1, obj2, HOLD_WIRE, GENERATOR_TOP)) { + if (isSectionVisible(5)) { + room = _gm->_rooms[GENERATOR]; + room->getObject(0)->_click = 15; + room->getObject(1)->_click = 13; + room->setSectionVisible(6, true); + room->setSectionVisible(8, true); + _vm->renderImage(_gm->invertSection(5)); + _vm->renderImage(6); + setSectionVisible(4, false); + getObject(0)->_click = 11; + } else + _vm->renderMessage(kStringCable4); + } else + return false; + + return true; +} + +void ShipHold::onEntrance() { + if (!hasSeen()) + _vm->renderMessage(kStringShipHold2); + setRoomSeen(true); + _gm->_rooms[COCKPIT]->setRoomSeen(true); +} + +ShipLandingModule::ShipLandingModule(SupernovaEngine *vm, GameManager1 *gm) { + _vm = vm; + _gm = gm; + + _fileNumber = 25; + _id = LANDINGMODULE; + _shown[0] = kShownTrue; + + _objectState[0] = Object(_id, kStringSocket,kStringDefaultDescription,LANDINGMOD_SOCKET,COMBINABLE,1,1,0); + _objectState[1] = Object(_id, kStringButton,kSafetyButtonDescription,LANDINGMOD_BUTTON,PRESS | COMBINABLE,2,2,0); + _objectState[2] = Object(_id, kStringMonitor,kStringDefaultDescription,LANDINGMOD_MONITOR,NULLTYPE,3,3,0); + _objectState[3] = Object(_id, kStringKeyboard,kStringDefaultDescription,KEYBOARD,NULLTYPE,4,4,0); + _objectState[4] = Object(_id, kNoString,kStringDefaultDescription,LANDINGMOD_WIRE,COMBINABLE,255,255,0); + _objectState[5] = Object(_id, kStringHatch,kStringDefaultDescription,LANDINGMOD_HATCH,EXIT | OPENABLE | OPENED | COMBINABLE, 0,0,1 | 128,HOLD,10); +} + +bool ShipLandingModule::interact(Action verb, Object &obj1, Object &obj2) { + if ((verb == ACTION_PRESS) && (obj1._id == LANDINGMOD_BUTTON)) + _vm->renderMessage(obj1._description); + else if ((verb == ACTION_USE) && Object::combine(obj1, obj2, PEN, LANDINGMOD_BUTTON)) { + if (_gm->_state._landingModuleEnergyDaysLeft) { + Room *r = _gm->_rooms[GENERATOR]; + if (isSectionVisible(7)) { + _vm->renderImage(_gm->invertSection(9)); + _vm->renderImage(_gm->invertSection(2)); + _vm->renderImage(_gm->invertSection(8)); + _vm->renderImage(_gm->invertSection(7)); + _vm->renderImage(_gm->invertSection(10)); + if (r->isSectionVisible(9)) + _gm->_state._powerOff = true; + _gm->roomBrightness(); + } else { + _vm->renderImage(7); + if (r->isSectionVisible(9)) + _gm->_state._powerOff = false; + _gm->roomBrightness(); + r = _gm->_rooms[SLEEP]; + r->setSectionVisible(1, false); + r->setSectionVisible(2, false); + _gm->wait(2); + _vm->renderImage(2); + _gm->wait(3); + _vm->renderImage(8); + _gm->wait(2); + _vm->renderImage(9); + _gm->wait(1); + _vm->renderImage(10); + } + } + } else if ((verb == ACTION_USE) && Object::combine(obj1, obj2, KNIFE, LANDINGMOD_BUTTON)) + _vm->renderMessage(kStringShipHold3); + else if ((verb == ACTION_LOOK) && (obj1._id == LANDINGMOD_MONITOR) && isSectionVisible(7)) + _vm->renderMessage(kStringShipHold4); + else if ((verb == ACTION_USE) && (obj1._id == KEYBOARD)) + _vm->renderMessage(kStringShipHold5); + else if ((verb == ACTION_USE) && Object::combine(obj1, obj2, WIRE, LANDINGMOD_SOCKET)) { + Room *r = _gm->_rooms[CABIN_L3]; + _gm->_inventory.remove(*r->getObject(8)); + getObject(4)->_name = r->getObject(8)->_name; + _vm->renderImage(4); + if (_gm->_state._cableConnected) { + _vm->renderImage(5); + getObject(4)->_click = 6; + } else { + getObject(4)->_click = 5; + if (_gm->_state._terminalStripWire) + _vm->renderImage(11); + } + } else if ((verb == ACTION_USE) && Object::combine(obj1, obj2, SPOOL, LANDINGMOD_SOCKET)) + _vm->renderMessage(kStringShipHold8); + else if ((verb == ACTION_USE) && Object::combine(obj1, obj2, LANDINGMOD_WIRE, TERMINALSTRIP)) { + _vm->renderImage(11); + getObject(4)->_name = kStringWireAndClip; + Room *r = _gm->_rooms[HOLD]; + _gm->_inventory.remove(*r->getObject(2)); + _gm->_state._terminalStripConnected = true; + _gm->_state._terminalStripWire = true; + } else if ((verb == ACTION_USE) && Object::combine(obj1, obj2, LANDINGMOD_WIRE, SPOOL)) { + if (!_gm->_state._terminalStripConnected) + _vm->renderMessage(kStringCable3); + else { + _vm->renderImage(5); + getObject(4)->_name = kStringWireAndPlug2; + getObject(4)->_click = 6; + _gm->_inventory.remove(*_gm->_rooms[CABIN_L2]->getObject(9)); + } + } else if ((verb == ACTION_USE) && Object::combine(obj1, obj2, LANDINGMOD_WIRE, LANDINGMOD_HATCH)) { + if (getObject(5)->hasProperty(OPENED)) { + Room *r = _gm->_rooms[HOLD]; + if (isSectionVisible(5)) { + r->setSectionVisible(5, true); + r->getObject(0)->_click = 10; + } else + r->getObject(0)->_click = 9; + + r->setSectionVisible(4, true); + r->getObject(0)->_name = getObject(4)->_name; + _vm->renderImage(_gm->invertSection(5)); + _vm->renderImage(_gm->invertSection(4)); + setSectionVisible(11, false); + _vm->renderImage(6); + getObject(4)->_click = 7; + } else + _vm->renderMessage(kStringShipHold6); + } else if ((verb == ACTION_CLOSE) && (obj1._id == LANDINGMOD_HATCH) && isSectionVisible(6)) + _vm->renderMessage(kStringCable1); + else if (((verb == ACTION_TAKE) || (verb == ACTION_PULL)) && (obj1._id == LANDINGMOD_WIRE)) + _vm->renderMessage(kStringCable2); + else + return false; + + return true; +} + +ShipGenerator::ShipGenerator(SupernovaEngine *vm, GameManager1 *gm) { + _vm = vm; + _gm = gm; + + _fileNumber = 18; + _id = GENERATOR; + _shown[0] = kShownTrue; + _shown[5] = kShownTrue; + + _objectState[0] = Object(_id, kStringGeneratorWire,kStringDefaultDescription,GENERATOR_WIRE,COMBINABLE,255,255,0); + _objectState[1] = Object(_id, kStringEmptySpool,kStringDefaultDescription,NULLOBJECT,UNNECESSARY,255,255,0); + _objectState[2] = Object(_id, kStringKeycard2,kStringKeycard2Description,KEYCARD2,COMBINABLE | TAKE,12,12,5 | 128); + _objectState[3] = Object(_id, kStringRope,kStringDefaultDescription,GENERATOR_ROPE,COMBINABLE,255,255,0); + _objectState[4] = Object(_id, kStringHatch,kStringHatchDescription3,OUTERHATCH,EXIT | OPENABLE,1,2,1,OUTSIDE,22); + _objectState[5] = Object(_id, kStringHatch,kStringDefaultDescription,NULLOBJECT,OPENABLE | CLOSED,3,3,0); + _objectState[6] = Object(_id, kStringSlot,kStringSlotDescription,NULLOBJECT,COMBINABLE,4,4,0); + _objectState[7] = Object(_id, kStringTrap,kStringDefaultDescription,TRAP,OPENABLE,5,6,2); + _objectState[8] = Object(_id, kStringWire,kStringDefaultDescription,NULLOBJECT,NULLTYPE,7,7,0); + _objectState[9] = Object(_id, kStringVoltmeter,kStringDefaultDescription,VOLTMETER,NULLTYPE,9,9,0,NULLROOM,0); + _objectState[10] = Object(_id, kStringClip,kStringDefaultDescription,CLIP,COMBINABLE,8,8,0); + _objectState[11] = Object(_id, kStringWire,kStringWireDescription,SHORT_WIRE,COMBINABLE,10,10,0); + _objectState[12] = Object(_id, kStringLadder,kStringDefaultDescription,LADDER,EXIT,0,0,0,HOLD,1); +} + +bool ShipGenerator::interact(Action verb, Object &obj1, Object &obj2) { + if ((verb == ACTION_OPEN) && (obj1._id == OUTERHATCH)) { + if (obj1.hasProperty(OPENED)) + return false; + _vm->playSound(kAudioSlideDoor); + _vm->renderImage(1); + if (isSectionVisible(7)) + _vm->renderImage(10); + if (isSectionVisible(13)) + _vm->renderImage(13); + _gm->_rooms[HOLD]->setSectionVisible(3, true); + obj1.setProperty(OPENED); + obj1._click = 2; + _vm->playSound(kAudioDoorOpen); + } else if ((verb == ACTION_CLOSE) && (obj1._id == OUTERHATCH)) { + if (!obj1.hasProperty(OPENED)) + return false; + if (isSectionVisible(11) || isSectionVisible(12)) + _vm->renderMessage(kStringShipHold7); + else { + _vm->playSound(kAudioSlideDoor); + _vm->renderImage(_gm->invertSection(1)); + setSectionVisible(10, false); + if (isSectionVisible(13)) + _vm->renderImage(13); + _gm->_rooms[HOLD]->setSectionVisible(3, false); + obj1.disableProperty(OPENED); + obj1._click = 1; + _vm->playSound(kAudioDoorClose); + } + } else if ((verb == ACTION_WALK) && (obj1._id == OUTERHATCH) && + isSectionVisible(7)) { + if (!obj1.hasProperty(OPENED)) + _vm->renderMessage(kStringShipHold9); + else if (!isSectionVisible(11)) + _vm->renderMessage(kStringShipHold10); + else { + obj1._exitRoom = ROCKS; + return false; + } + } else if ((verb == ACTION_TAKE) && (obj1._id == GENERATOR_WIRE)) + _vm->renderMessage(kStringCable2); + else if ((verb == ACTION_PULL) && (obj1._id == SHORT_WIRE) && + (obj1._click != 11)) { + _vm->renderImage(3); + _vm->renderImage(4); + obj1._click = 11; + _gm->turnOff(); + } else if ((verb == ACTION_USE) && Object::combine(obj1, obj2, SHORT_WIRE, CLIP) && + (getObject(11)->_click == 11) && !isSectionVisible(9)) { + _vm->renderImage(2); + setSectionVisible(3, false); + setSectionVisible(4, false); + getObject(11)->_click = 10; + if (_gm->_state._shipEnergyDaysLeft) + _gm->turnOn(); + else + _vm->renderImage(4); + } else if ((verb == ACTION_OPEN) && (obj1._id == TRAP)) { + _vm->playSound(kAudioSlideDoor); + _vm->renderImage(2); + if (getObject(11)->_click == 11) + _vm->renderImage(3); + if (_gm->_state._powerOff) + _vm->renderImage(4); + obj1.setProperty(OPENED); + obj1._click = 6; + + obj1._click2 = 5; + _vm->playSound(kAudioDoorOpen); + } else if ((verb == ACTION_CLOSE) && (obj1._id == TRAP)) { + if (isSectionVisible(9)) + _vm->renderMessage(kStringCable1); + else { + setSectionVisible(3, false); + return false; + } + } else if ((verb == ACTION_USE) && Object::combine(obj1, obj2, GENERATOR_WIRE, CLIP) && + isSectionVisible(3) && (getObject(0)->_click != 16)) { + _vm->renderImage(_gm->invertSection(8)); + _vm->renderImage(2); + setSectionVisible(4, false); + _vm->renderImage(3); + _vm->renderImage(9); + getObject(0)->_click = 16; + Room *r = _gm->_rooms[LANDINGMODULE]; + if (_gm->_state._landingModuleEnergyDaysLeft && r->isSectionVisible(7)) + _gm->turnOn(); + else + _vm->renderImage(4); + _gm->_rooms[HOLD]->setSectionVisible(7, true); + _gm->great(3); + } else if ((verb == ACTION_PULL) && (obj1._id == GENERATOR_WIRE) && (obj1._click == 16)) { + _vm->renderImage(_gm->invertSection(9)); + _vm->renderImage(2); + _vm->renderImage(3); + _vm->renderImage(4); + _vm->renderImage(8); + obj1._click = 15; + _gm->turnOff(); + _gm->_rooms[HOLD]->setSectionVisible(7, false); + } else if ((verb == ACTION_USE) && + (Object::combine(obj1, obj2, WIRE, CLIP) || + Object::combine(obj1, obj2, SPOOL, CLIP)) && + isSectionVisible(3)) { + _vm->renderMessage(kStringShipHold11); + } else if ((verb == ACTION_LOOK) && (obj1._id == VOLTMETER)) { + if (_gm->_state._powerOff) + _vm->renderMessage(kStringShipHold12); + else + _vm->renderMessage(kStringShipHold13); + } else if ((verb == ACTION_USE) && Object::combine(obj1, obj2, LADDER, ROPE)) { + _vm->renderImage(13); + Room *r = _gm->_rooms[CABIN_R3]; + _gm->_inventory.remove(*r->getObject(9)); + getObject(3)->_click = 18; + } else if ((verb == ACTION_USE) && Object::combine(obj1, obj2, OUTERHATCH, GENERATOR_ROPE)) { + if (!isSectionVisible(1)) + _vm->renderMessage(kStringShipHold14); + else { + _vm->renderImage(_gm->invertSection(13)); + _vm->renderImage(1); + if (isSectionVisible(7)) { + _vm->renderImage(10); + _vm->renderImage(11); + } else + _vm->renderImage(12); + + Room *r = _gm->_rooms[OUTSIDE]; + r->setSectionVisible(1, true); + r->getObject(1)->_click = 1; + getObject(3)->_click = 17; + } + } else if ((verb == ACTION_TAKE) && (obj1._id == GENERATOR_ROPE)) + _vm->renderMessage(kStringShipHold15); + else if ((verb == ACTION_USE) && Object::combine(obj1, obj2, OUTERHATCH, GENERATOR_WIRE) && isSectionVisible(1)) + _vm->renderMessage(kStringShipHold16); + else + return false; + + return true; +} + +ShipOuterSpace::ShipOuterSpace(SupernovaEngine *vm, GameManager1 *gm) { + _vm = vm; + _gm = gm; + + _fileNumber = 4; + _id = OUTSIDE; + _shown[0] = kShownTrue; + + _objectState[0] = Object(_id, kStringHatch,kStringDefaultDescription,NULLOBJECT,EXIT,0,0,0,GENERATOR,3); + _objectState[1] = Object(_id, kStringRope,kStringDefaultDescription,NULLOBJECT,UNNECESSARY,255,255,0); +} + + +// Arsano +ArsanoRocks::ArsanoRocks(SupernovaEngine *vm, GameManager1 *gm) { + _vm = vm; + _gm = gm; + + _fileNumber = 12; + _id = OUTSIDE; + _shown[0] = kShownTrue; + + _objectState[0] = Object(_id, kStringRope,kStringDefaultDescription,NULLOBJECT,UNNECESSARY | EXIT,0,0,0,GENERATOR,12); + _objectState[1] = Object(_id, kStringStone,kStringDefaultDescription,STONE,NULLTYPE,1,1,0); + _objectState[2] = Object(_id, kStringStone,kStringDefaultDescription,NULLOBJECT,NULLTYPE,2,2,0); + _objectState[3] = Object(_id, kStringCaveOpening,kStringCaveOpeningDescription,NULLOBJECT,NULLTYPE,255,255,0,CAVE,1); +} + +void ArsanoRocks::onEntrance() { + _gm->great(8); +} + +bool ArsanoRocks::interact(Action verb, Object &obj1, Object &obj2) { + if (((verb == ACTION_PULL) || (verb == ACTION_PRESS)) && + (obj1._id == STONE) && !isSectionVisible(3)) { + _vm->renderImage(1); + _gm->wait(2); + _vm->renderImage(2); + _gm->wait(2); + _vm->renderImage(3); + _vm->playSound(kAudioRocks); + obj1._click = 3; + getObject(3)->_click = 4; + getObject(3)->setProperty(EXIT); + return true; + } + return false; +} + +ArsanoCave::ArsanoCave(SupernovaEngine *vm, GameManager1 *gm) { + _vm = vm; + _gm = gm; + + _fileNumber = 12; + _id = CAVE; + + _objectState[0] = Object(_id, kStringExit,kStringExitDescription,NULLOBJECT,EXIT,255,255,0,ROCKS,22); + _objectState[1] = Object(_id, kStringExit,kStringDefaultDescription,NULLOBJECT,EXIT,255,255,0,MEETUP,2); +} + +ArsanoMeetup::ArsanoMeetup(SupernovaEngine *vm, GameManager1 *gm) { + _vm = vm; + _gm = gm; + + _fileNumber = 37; + _id = MEETUP; + _shown[0] = kShownTrue; + _sign = 0; + _beacon = 0; + + _objectState[0] = Object(_id, kStringCave,kStringDefaultDescription,NULLOBJECT,EXIT,255,255,0,CAVE,22); + _objectState[1] = Object(_id, kStringSign,kStringSignDescription,MEETUP_SIGN,NULLTYPE,0,0,0); + _objectState[2] = Object(_id, kStringEntrance,kStringDefaultDescription,DOOR,EXIT,1,1,0,ENTRANCE,7); + _objectState[3] = Object(_id, kStringStar,kStringDefaultDescription,STAR,NULLTYPE,2,2,0); + _objectState[4] = Object(_id, kStringSpaceshift,kStringDefaultDescription,SPACESHIPS,COMBINABLE,3,3,0); + _objectState[5] = Object(_id, kStringSpaceshift,kStringDefaultDescription,SPACESHIP,COMBINABLE,4,4,0); +} + +void ArsanoMeetup::onEntrance() { + if (isSectionVisible(7)) { + _gm->wait(3); + _vm->renderImage(6); + setSectionVisible(7, false); + _gm->wait(3); + _vm->renderImage(_gm->invertSection(6)); + } + if (!(_gm->_state._greatFlag & 0x8000)) { + _vm->playSound(kAudioFoundLocation); + _gm->_state._greatFlag |= 0x8000; + } +} + +void ArsanoMeetup::animation() { + _vm->renderImage(_gm->invertSection(1) + _beacon); + _beacon = (_beacon + 1) % 5; + _vm->renderImage(_beacon + 1); + _vm->renderImage(_beacon + 8); + if (isSectionVisible(_sign + 13)) + _vm->renderImage(_gm->invertSection(13) + _sign); + else + _vm->renderImage(13 + _sign); + + _sign = (_sign + 1) % 14; + _gm->setAnimationTimer(3); +} + +bool ArsanoMeetup::interact(Action verb, Object &obj1, Object &obj2) { + if ((verb == ACTION_WALK) && + ((obj1._id == SPACESHIPS) || + ((obj1._id == SPACESHIP) && !obj1.hasProperty(OPENED)))) { + _vm->renderMessage(kStringArsanoMeetup1); + } else if ((verb == ACTION_WALK) && (obj1._id == SPACESHIP)) + _gm->changeRoom(GLIDER); + else if ((verb == ACTION_WALK) && (obj1._id == STAR)) + _vm->renderMessage(kStringArsanoMeetup2); + else if ((verb == ACTION_LOOK) && (obj1._id == STAR)) { + _vm->setCurrentImage(26); + _vm->renderImage(0); + _vm->paletteBrightness(); + _gm->animationOff(); + _gm->getInput(); + _gm->animationOn(); + g_system->fillScreen(kColorBlack); + _vm->renderRoom(*this); + _vm->paletteBrightness(); + } else if ((verb == ACTION_WALK) && (obj1._id == DOOR)) { + _vm->renderImage(6); + _gm->wait(3); + _vm->renderImage(7); + setSectionVisible(6, false); + _gm->wait(3); + + return false; + } else if ((verb == ACTION_LOOK) && (obj1._id == MEETUP_SIGN) && _gm->_state._language) { + if (_gm->_state._language == 2) + _vm->renderMessage(kStringArsanoMeetup3); + + obj1._description = kStringSignDescription2; + if (_gm->_state._language == 1) + return false; + + _gm->_state._language = 1; + } else if ((verb == ACTION_USE) && Object::combine(obj1, obj2, KEYCARD_R, SPACESHIP)) { + getObject(5)->setProperty(OPENED); + _gm->changeRoom(GLIDER); + } else + return false; + + return true; +} + +ArsanoEntrance::ArsanoEntrance(SupernovaEngine *vm, GameManager1 *gm) { + _vm = vm; + _gm = gm; + + _fileNumber = 10; + _id = ENTRANCE; + _shown[0] = kShownTrue; + + _objectState[0] = Object(_id, kStringPorter,kStringPorterDescription,PORTER,TALK,0,0,0); + _objectState[1] = Object(_id, kStringDoor,kStringDefaultDescription,NULLOBJECT,EXIT | OPENABLE | CLOSED,1,1,0,NULLROOM,5); + _objectState[2] = Object(_id, kStringSign,kStringSignDescription,KITCHEN_SIGN,NULLTYPE,2,2,0); + _objectState[3] = Object(_id, kStringChewingGum,kStringDefaultDescription,SCHNUCK,TAKE,255,255,10+128); + _objectState[4] = Object(_id, kStringGummyBears,kStringDefaultDescription,SCHNUCK,TAKE,255,255,11+128); + _objectState[5] = Object(_id, kStringChocolateBall,kStringDefaultDescription,SCHNUCK,TAKE,255,255,12+128); + _objectState[6] = Object(_id, kStringEgg,kStringDefaultDescription,EGG,TAKE,255,255,13+128); + _objectState[7] = Object(_id, kStringLiquorice,kStringDefaultDescription,SCHNUCK,TAKE,255,255,14+128); + _objectState[8] = Object(_id, kStringPill,kStringPillDescription,PILL,TAKE,255,255,0); + _objectState[9] = Object(_id, kStringSlot,kStringDefaultDescription,CAR_SLOT,COMBINABLE,6,6,0); + _objectState[10] = Object(_id, kStringVendingMachine,kStringVendingMachineDescription,NULLOBJECT,NULLTYPE,5,5,0); + _objectState[11] = Object(_id, kStringToilet,kStringToiletDescription,ARSANO_BATHROOM,NULLTYPE,255,255,0); + _objectState[12] = Object(_id, kStringButton,kStringDefaultDescription,BATHROOM_BUTTON,PRESS,3,3,0); + _objectState[13] = Object(_id, kStringSign,kStringSignDescription,BATHROOM_SIGN,NULLTYPE,4,4,0); + _objectState[14] = Object(_id, kStringStaircase,kStringDefaultDescription,STAIRCASE,EXIT,8,8,0,REST,3); + _objectState[15] = Object(_id, kStringExit,kStringDefaultDescription,MEETUP_EXIT,EXIT,255,255,0,MEETUP,22); + _objectState[16] = Object(_id, kStringCoins,kStringCoinsDescription,COINS,TAKE|COMBINABLE,255,255,0); + _objectState[17] = Object(_id, kStringTabletPackage,kStringTabletPackageDescription,PILL_HULL,TAKE,255,255,0); + + _dialog1[0] = kStringArsanoDialog7; + _dialog1[1] = kStringArsanoDialog1; + _dialog1[2] = kStringArsanoDialog8; + _dialog1[3] = kStringArsanoDialog9; + _dialog1[4] = kStringDialogSeparator; + + _dialog2[0] = kStringArsanoDialog1; + _dialog2[1] = kStringArsanoDialog2; + _dialog2[2] = kStringArsanoDialog3; + _dialog2[3] = kStringArsanoDialog4; + _dialog2[4] = kStringDialogSeparator; + + _dialog3[0] = kStringArsanoDialog5; + _dialog3[1] = kStringArsanoDialog6; + + _eyewitness = 5; +} + +void ArsanoEntrance::animation() { + if (!_vm->_screen->isMessageShown() && isSectionVisible(kMaxSection - 5)) { + _gm->animationOff(); // to avoid recursive call + _vm->playSound(kAudioSlideDoor); + _vm->renderImage(8); + setSectionVisible(9, false); + _gm->wait(2); + _vm->renderImage(7); + setSectionVisible(8, false); + _gm->wait(2); + _vm->renderImage(6); + setSectionVisible(7, false); + _gm->wait(2); + _vm->renderImage(5); + setSectionVisible(6, false); + _gm->wait(2); + _vm->renderImage(_gm->invertSection(5)); + getObject(11)->_click = 255; + setSectionVisible(kMaxSection - 5, false); + _gm->animationOn(); + } + if (isSectionVisible(2)) + _vm->renderImage(_gm->invertSection(2)); + else if (_eyewitness) + --_eyewitness; + else { + _eyewitness = 20; + _vm->renderImage(2); + } + + _gm->setAnimationTimer(4); +} + +bool ArsanoEntrance::interact(Action verb, Object &obj1, Object &obj2) { + static byte row1[6] = {1, 1, 1, 1, 1, 0}; + static byte row2[6] = {1, 1, 1, 1, 1, 0}; + static byte row3[6] = {1, 1, 0, 0, 0, 0}; + + if ((verb == ACTION_TALK) && (obj1._id == PORTER)) { + if (_gm->_rooms[AIRLOCK]->getObject(4)->hasProperty(WORN)) + _vm->renderMessage(kStringArsanoEntrance1); + else { + if (_gm->_state._language) { + int e; + do { + if (_gm->_state._shoes == 1) { + _dialog2[2] = kStringArsanoEntrance2; + addSentence(2, 2); + } else if (_gm->_state._shoes > 1) + removeSentence(2, 2); + + switch (e = _gm->dialog(5, row2, _dialog2, 2)) { + case 0: + _gm->reply(kStringArsanoEntrance3, 1, _gm->invertSection(1)); + _gm->reply(kStringArsanoEntrance4, 1, _gm->invertSection(1)); + _gm->reply(kStringArsanoEntrance5, 1, _gm->invertSection(1)); + removeSentence(1, 1); + break; + case 1: + _gm->reply(kStringArsanoEntrance6, 1, _gm->invertSection(1)); + addSentence(1, 2); + break; + case 2: + if (_gm->_state._shoes == 1) { + _gm->reply(kStringArsanoEntrance7, 1, _gm->invertSection(1)); + _gm->_state._shoes = 2; + } else { + _gm->reply(kStringArsanoEntrance8, 1, _gm->invertSection(1)); + _gm->_state._shoes = 1; + } + break; + case 3: + _gm->reply(kStringArsanoEntrance9, 1, _gm->invertSection(1)); + } + } while (e != 4); + } else if (_gm->dialog(5, row2, _dialog2, 0) != 4) + _gm->reply(kStringArsanoEntrance10, 1, _gm->invertSection(1)); + } + } else if ((verb == ACTION_WALK) && (obj1._id == STAIRCASE) && (_gm->_state._shoes != 3)) { + _vm->renderImage(3); + _gm->wait(2); + _vm->renderImage(4); + setSectionVisible(3, false); + if (_gm->_rooms[AIRLOCK]->getObject(4)->hasProperty(WORN)) + _gm->reply(kStringDialogSeparator, 1, _gm->invertSection(1)); + else if (_gm->_state._language) + _gm->reply(kStringArsanoEntrance11, 1, _gm->invertSection(1)); + else + _gm->reply(kStringArsanoEntrance12, 1, _gm->invertSection(1)); + _vm->renderImage(3); + setSectionVisible(4, false); + _gm->wait(2); + _vm->renderImage(_gm->invertSection(3)); + if (!_gm->_rooms[AIRLOCK]->getObject(4)->hasProperty(WORN)) { + if (_gm->_state._language) { + if (_gm->_state._shoes) + _gm->reply(kStringArsanoEntrance13, 1, _gm->invertSection(1)); + else + _gm->reply(kStringArsanoEntrance14, 1, _gm->invertSection(1)); + int e = 0; + while ((e < 3) && (!allSentencesRemoved(4, 1))) { + switch (e = _gm->dialog(5, row1, _dialog1, 1)) { + case 0: + _gm->reply(kStringArsanoEntrance15, 1, 1 + 128); + break; + case 1: + _gm->reply(kStringArsanoEntrance3, 1, 1 + 128); + _gm->reply(kStringArsanoEntrance4, 1, 1 + 128); + _gm->reply(kStringArsanoEntrance5, 1, 1 + 128); + removeSentence(0, 2); + break; + case 2: + _gm->reply(kStringArsanoEntrance7, 1, 1 + 128); + _gm->_state._shoes = 2; + break; + case 3: + _vm->renderImage(3); + _gm->wait(2); + _vm->renderImage(4); + setSectionVisible(3, false); + _gm->reply(kStringArsanoEntrance16, 1, 1 + 128); + _vm->renderImage(3); + setSectionVisible(4, false); + _gm->wait(2); + _vm->renderImage(_gm->invertSection(3)); + break; + } + removeSentence(0, 1); + } + } else { + _gm->dialog(2, row3, _dialog3, 0); + _gm->reply(kStringArsanoEntrance10, 1, 1 + 128); + } + } + } else if ((verb == ACTION_PRESS) && (obj1._id == BATHROOM_BUTTON)) { + _vm->playSound(kAudioSlideDoor); + _vm->renderImage(5); + _gm->wait(2); + _vm->renderImage(6); + setSectionVisible(5, false); + _gm->wait(2); + _vm->renderImage(7); + setSectionVisible(6, false); + _gm->wait(2); + _vm->renderImage(8); + setSectionVisible(7, false); + _gm->wait(2); + _vm->renderImage(9); + setSectionVisible(8, false); + getObject(11)->_click = 9; + } else if ((verb == ACTION_WALK) && (obj1._id == ARSANO_BATHROOM)) { + if (_gm->_state._coins) { + if (_gm->_state._shoes == 2) { + _vm->renderMessage(kStringArsanoEntrance17); + _gm->_state._shoes = 3; + removeSentence(2, 2); + removeSentence(3, 2); + } else if (_gm->_state._shoes == 3) { + _vm->renderMessage(kStringArsanoEntrance18); + _gm->_state._shoes = 2; + } else + _vm->renderMessage(kStringArsanoEntrance19); + } else { + if (_gm->_rooms[AIRLOCK]->getObject(5)->hasProperty(WORN)) + _vm->renderMessage(kStringArsanoEntrance20); + else { + _vm->renderMessage(kStringArsanoEntrance21); + _gm->waitOnInput(_gm->_messageDuration); + _vm->removeMessage(); + _vm->renderMessage(kStringArsanoEntrance22); + _gm->takeObject(*getObject(16)); + _gm->_state._coins = 5; + } + } + // This shown object is an abuse in the original engine as it's not a real shown variable + // It's an internal (boolean) status + _shown[kMaxSection - 5] = kShownTrue; + } else if ((verb == ACTION_USE) && Object::combine(obj1, obj2, COINS, CAR_SLOT)) { + if ((_gm->_state._coins < 5) && (getObject(7 - _gm->_state._coins)->_click == 7)) + _vm->renderMessage(kStringArsanoEntrance23); + else { + _vm->renderImage(15 - _gm->_state._coins); + getObject(8 - _gm->_state._coins)->_click = 7; + --_gm->_state._coins; + if (_gm->_state._coins == 1) + getObject(16)->_name = kStringCoin; + + if (_gm->_state._coins == 0) { + _gm->_inventory.remove(*getObject(16)); + _gm->_state._coins = 255; + } + } + } else if ((verb == ACTION_LOOK) && (obj1._id == KITCHEN_SIGN) && _gm->_state._language) { + if (_gm->_state._language == 2) + _vm->renderMessage(kStringArsanoEntrance24); + obj1._description = kStringDoorDescription5; + if (_gm->_state._language == 1) + return false; + _gm->_state._language = 1; + } else if ((verb == ACTION_LOOK) && (obj1._id == BATHROOM_SIGN) && _gm->_state._language) { + if (_gm->_state._language == 2) + _vm->renderMessage(kStringArsanoEntrance25); + obj1._description = kStringDoorDescription6; + if (_gm->_state._language == 1) + return false; + _gm->_state._language = 1; + } else if ((verb == ACTION_WALK) && (obj1._id == MEETUP_EXIT)) { + if (!((_gm->_rooms[AIRLOCK]->getObject(4)->hasProperty(WORN)) && + (_gm->_rooms[AIRLOCK]->getObject(5)->hasProperty(WORN)) && + (_gm->_rooms[AIRLOCK]->getObject(6)->hasProperty(WORN)))) { + _vm->renderMessage(kStringArsanoEntrance26); + _gm->_rooms[AIRLOCK]->getObject(4)->setProperty(WORN); + _gm->_rooms[AIRLOCK]->getObject(5)->setProperty(WORN); + _gm->_rooms[AIRLOCK]->getObject(6)->setProperty(WORN); + _gm->waitOnInput(_gm->_messageDuration); + _vm->removeMessage(); + } + return false; + } else if ((verb == ACTION_USE) && Object::combine(obj1, obj2, KNIFE, PORTER)) + _vm->renderMessage(kStringArsanoEntrance27); + else + return false; + + return true; +} + +ArsanoRemaining::ArsanoRemaining(SupernovaEngine *vm, GameManager1 *gm) { + _vm = vm; + _gm = gm; + + _fileNumber = 28; + _id = REST; + _shown[0] = kShownTrue; + + _objectState[0] = Object(_id, kStringStaircase,kStringDefaultDescription,NULLOBJECT,EXIT,0,0,0,ENTRANCE,17); + _objectState[1] = Object(_id, kStringChair,kStringDefaultDescription,NULLOBJECT,EXIT,1,1,0,ROGER,2); + _objectState[2] = Object(_id, kStringShoes,kStringShoesDescription,NULLOBJECT,NULLTYPE,2,2,0); + + _chewing = kShownTrue; + _i = 0; +} + +void ArsanoRemaining::animation() { + switch (_i) { + case 0: + _vm->renderImage(1); + _vm->renderImage(_gm->invertSection(4)); + break; + case 1: + _vm->renderImage(_gm->invertSection(1)); + _vm->renderImage(4); + break; + case 2: + _vm->renderImage(2); + _vm->renderImage(_gm->invertSection(4)); + break; + + case 3: + _vm->renderImage(7); // Dragon + _vm->renderImage(_gm->invertSection(2)); + _vm->renderImage(4); + break; + case 4: + _vm->renderImage(8); + setSectionVisible(7, false); + _vm->renderImage(2); + _vm->renderImage(_gm->invertSection(4)); + break; + case 5: + _vm->renderImage(_gm->invertSection(8)); + _vm->renderImage(_gm->invertSection(2)); + break; + case 6: + _vm->renderImage(3); + _vm->renderImage(2); + break; + case 7: + _vm->renderImage(_gm->invertSection(3)); + _vm->renderImage(_gm->invertSection(2)); + break; + case 8: + _vm->renderImage(3); + break; + case 9: + _vm->renderImage(14); // Card Player 1 + _vm->renderImage(4); + _vm->renderImage(_gm->invertSection(3)); + break; + case 10: + _vm->renderImage(15); + _vm->renderImage(14); + _vm->renderImage(_gm->invertSection(4)); + _vm->renderImage(3); + break; + case 11: + _vm->renderImage(16); + setSectionVisible(15, false); + _vm->renderImage(4); + _vm->renderImage(_gm->invertSection(3)); + break; + case 12: + _vm->renderImage(17); + setSectionVisible(16, false); + _vm->renderImage(_gm->invertSection(4)); + _vm->renderImage(3); + break; + case 13: + _vm->renderImage(_gm->invertSection(17)); + _vm->renderImage(4); + _vm->renderImage(_gm->invertSection(3)); + break; + case 14: + _vm->renderImage(_gm->invertSection(4)); + break; + case 15: + _vm->renderImage(6); + break; + case 16: + _vm->renderImage(18); // Card Player 2 + _vm->renderImage(5); + break; + case 17: + _vm->renderImage(19); + setSectionVisible(18, false); + _vm->renderImage(_gm->invertSection(5)); + break; + case 18: + _vm->renderImage(20); + setSectionVisible(19, false); + _vm->renderImage(5); + break; + case 19: + _vm->renderImage(21); + setSectionVisible(20, false); + _vm->renderImage(_gm->invertSection(5)); + break; + case 20: + _vm->renderImage(_gm->invertSection(21)); + _vm->renderImage(5); + break; + case 21: + _vm->renderImage(_gm->invertSection(5)); + break; + case 22: + _vm->renderImage(5); + break; + case 23: + _vm->renderImage(10); + _chewing = false; + _vm->renderImage(_gm->invertSection(5)); + break; + case 24: + _vm->renderImage(11); + setSectionVisible(10, false); + break; + case 25: + _vm->renderImage(12); + setSectionVisible(11, false); + break; + case 26: + _vm->renderImage(13); + setSectionVisible(12, false); + break; + case 27: + _vm->renderImage(12); + setSectionVisible(13, false); + break; + case 28: + _vm->renderImage(11); + setSectionVisible(12, false); + break; + case 29: + _vm->renderImage(10); + setSectionVisible(11, false); + break; + case 30: + _vm->renderImage(_gm->invertSection(10)); + _chewing = true; + break; + case 31: + _vm->renderImage(22); // Card Player 3 + break; + case 32: + _vm->renderImage(_gm->invertSection(22)); + break; + case 33: + _vm->renderImage(_gm->invertSection(6)); + break; + case 34: + _vm->renderImage(4); + } + + _i = (_i + 1) % 35; + if (_chewing) { + if (isSectionVisible(9)) + _vm->renderImage(_gm->invertSection(9)); + else + _vm->renderImage(9); + } + _gm->setAnimationTimer(3); +} + +ArsanoRoger::ArsanoRoger(SupernovaEngine *vm, GameManager1 *gm) { + _vm = vm; + _gm = gm; + + _fileNumber = 29; + _id = ROGER; + _shown[0] = kShownTrue; + + _objectState[0] = Object(_id, kStringExit,kStringDefaultDescription,NULLOBJECT,EXIT,255,255,0,REST,19); + _objectState[1] = Object(_id, kStringFrogFace,kStringDefaultDescription,ROGER_W,TALK,0,0,0); + _objectState[2] = Object(_id, kStringScrible,kStringScribleDescription,NULLOBJECT,NULLTYPE,3,3,0); + _objectState[3] = Object(_id, kStringWallet,kStringDefaultDescription,WALLET,TAKE,1,1,4); + _objectState[4] = Object(_id, kStringMenu,kStringMenuDescription,NULLOBJECT,UNNECESSARY,2,2,0); + _objectState[5] = Object(_id, kStringCup,kStringCupDescription,CUP,UNNECESSARY,4,4,0); + _objectState[6] = Object(_id, kStringChessGame,kStringDefaultDescription,NULLOBJECT,UNNECESSARY,255,255,0); + _objectState[7] = Object(_id, kStringBill,kStringBillDescription,NULLOBJECT,TAKE|COMBINABLE,255,255,0); + _objectState[8] = Object(_id, kStringKeycard3,kStringDefaultDescription,KEYCARD_R,TAKE|COMBINABLE,255,255,0); + + _dialog1[0] = kStringDialogArsanoRoger1; + _dialog1[1] = kStringDialogArsanoRoger2; + _dialog1[2] = kStringDialogArsanoRoger3; + _dialog1[3] = kStringDialogSeparator; + + _eyewitness = 5; + _hands = 0; +} + +void ArsanoRoger::onEntrance() { + if (!sentenceRemoved(0, 2)) { + _gm->say(kStringArsanoRoger1); + _gm->reply(kStringArsanoRoger2, 2, 2 + 128); + removeSentence(0, 2); + } +} + +void ArsanoRoger::animation() { + if (isSectionVisible(1)) + _vm->renderImage(_gm->invertSection(1)); + else if (isSectionVisible(10)) { + _vm->renderImage(12); + setSectionVisible(10, false); + setSectionVisible(12, false); + } else if (_eyewitness) { + --_eyewitness; + } else { + _eyewitness = 20; + if (isSectionVisible(3)) + _vm->renderImage(10); + else + _vm->renderImage(1); + } + + if (isSectionVisible(3)) { + setSectionVisible(5 + _hands, false); + _hands = (_hands + 1) % 5; + _vm->renderImage(5 + _hands); + } + _gm->setAnimationTimer(4); +} + +bool ArsanoRoger::interact(Action verb, Object &obj1, Object &obj2) { + static byte row1[6] = {1, 1, 1, 1, 0, 0}; + + if ((verb == ACTION_TAKE) && (obj1._id == WALLET)) { + if (isSectionVisible(3)) { + _gm->great(0); + return false; + } + _gm->reply(kStringArsanoRoger3, 2, 2 + 128); + } else if ((verb == ACTION_USE) && (obj1._id == CUP)) + _vm->renderMessage(kStringArsanoRoger4); + else if ((verb == ACTION_TALK) && (obj1._id == ROGER_W)) { + if (isSectionVisible(3)) + _vm->renderMessage(kStringArsanoRoger5); + else { + switch (_gm->dialog(4, row1, _dialog1, 1)) { + case 0: + _gm->reply(kStringArsanoRoger6, 2, 2 + 128); + _gm->reply(kStringArsanoRoger7, 2, 2 + 128); + break; + case 1: + _gm->reply(kStringArsanoRoger8, 2, 2 + 128); + _gm->reply(kStringArsanoRoger9, 2, 2 + 128); + _gm->say(kStringArsanoRoger10); + break; + case 2: + _gm->reply(kStringArsanoRoger11, 2, 2 + 128); + _gm->say(kStringArsanoRoger12); + _gm->reply(kStringArsanoRoger13, 2, 2 + 128); + _gm->say(kStringArsanoRoger14); + _gm->reply(kStringArsanoRoger15, 2, 2 + 128); + _gm->reply(kStringArsanoRoger16, 2, 2 + 128); + _gm->say(kStringArsanoRoger17); + _gm->say(kStringArsanoRoger18); + _gm->reply(kStringArsanoRoger19, 2, 2 + 128); + _gm->say(kStringArsanoRoger20); + _gm->say(kStringArsanoRoger21); + _gm->reply(kStringArsanoRoger22, 2, 2 + 128); + _gm->say(kStringArsanoRoger23); + _gm->reply(kStringArsanoRoger24, 2, 2 + 128); + _gm->reply(kStringArsanoRoger25, 2, 2 + 128); + _gm->say(kStringArsanoRoger26); + _gm->reply(kStringArsanoRoger27, 2, 2 + 128); + _gm->reply(kStringArsanoRoger28, 2, 2 + 128); + _gm->say(kStringArsanoRoger29); + _gm->reply(kStringArsanoRoger30, 2, 2 + 128); + _gm->reply(kStringArsanoRoger31, 2, 2 + 128); + _gm->say(kStringArsanoRoger32); + _gm->reply(kStringArsanoRoger33, 2, 2 + 128); + _gm->say(kStringArsanoRoger34); + _gm->reply(kStringArsanoRoger35, 2, 2 + 128); + } + } + } else if (((verb == ACTION_USE) && Object::combine(obj1, obj2, CHESS, ROGER_W)) || + ((verb == ACTION_GIVE) && (obj1._id == CHESS) && (obj2._id == ROGER_W))) { + _vm->renderImage(11); + _gm->great(0); + _gm->say(kStringArsanoRoger36); + _gm->reply(kStringArsanoRoger37, 2, 2 + 128); + _gm->say(kStringArsanoRoger38); + _vm->paletteFadeOut(); + _gm->_inventory.remove(*_gm->_rooms[CABIN_R3]->getObject(0)); // Chess board + g_system->fillScreen(kColorBlack); + _vm->_screen->setGuiBrightness(255); + _vm->paletteBrightness(); + _vm->renderMessage(kStringArsanoRoger39); + _gm->waitOnInput(_gm->_messageDuration); + _vm->removeMessage(); + _vm->_screen->setGuiBrightness(0); + _vm->paletteBrightness(); + _gm->_time += ticksToMsec(125000); // 2 hours + _gm->_state._alarmOn = (_gm->_state._timeAlarm > _gm->_time); + _gm->_state._eventTime = _gm->_time + ticksToMsec(4000); + _gm->_state._eventCallback = kSupernovaFn; + setSectionVisible(11, false); + setSectionVisible(1, false); + _vm->renderRoom(*this); + _vm->renderImage(3); + getObject(3)->_click = 5; + getObject(5)->_click = 6; + getObject(6)->_click = 7; + _vm->paletteFadeIn(); + _vm->renderMessage(kStringArsanoRoger40); + _gm->waitOnInput(_gm->_messageDuration); + _vm->removeMessage(); + } else + return false; + + return true; +} + +ArsanoGlider::ArsanoGlider(SupernovaEngine *vm, GameManager1 *gm) { + _vm = vm; + _gm = gm; + + _fileNumber = 19; + _id = GLIDER; + _shown[0] = kShownTrue; + _sinus = 0; + + _objectState[0] = Object(_id, kStringExit,kStringDefaultDescription,NULLOBJECT,EXIT,255,255,0,MEETUP,15); + _objectState[1] = Object(_id, kStringButton,kStringDefaultDescription,GLIDER_BUTTON1,PRESS,0,0,0); + _objectState[2] = Object(_id, kStringButton,kStringDefaultDescription,GLIDER_BUTTON2,PRESS,1,1,0); + _objectState[3] = Object(_id, kStringButton,kStringDefaultDescription,GLIDER_BUTTON3,PRESS,2,2,0); + _objectState[4] = Object(_id, kStringButton,kStringDefaultDescription,GLIDER_BUTTON4,PRESS,3,3,0); + _objectState[5] = Object(_id, kStringKeycard,kStringDefaultDescription,GLIDER_KEYCARD,TAKE|COMBINABLE,255,255,0); + _objectState[6] = Object(_id, kStringSlot,kStringDefaultDescription,GLIDER_SLOT,COMBINABLE,4,4,0); + _objectState[7] = Object(_id, kStringCompartment,kStringDefaultDescription,NULLOBJECT,OPENABLE,5,6,6); + _objectState[8] = Object(_id, kStringKeyboard,kStringDefaultDescription,GLIDER_BUTTONS,NULLTYPE,7,7,0); + _objectState[9] = Object(_id, kStringAnnouncement,kStringAnnouncementDescription,GLIDER_DISPLAY,NULLTYPE,8,8,0); + _objectState[10] = Object(_id, kStringInstruments,kStringAnnouncementDescription,GLIDER_INSTRUMENTS,NULLTYPE,9,9,0); +} + +void ArsanoGlider::animation() { + if (isSectionVisible(8)) { + setSectionVisible(24 + _sinus, false); + _sinus = (_sinus + 1) % 14; + _vm->renderImage(24 + _sinus); + } else if (isSectionVisible(24 + _sinus)) + _vm->renderImage(_gm->invertSection(24 + _sinus)); + + _gm->setAnimationTimer(2); +} + +bool ArsanoGlider::interact(Action verb, Object &obj1, Object &obj2) { + static char l, r; + if ((verb == ACTION_USE) && Object::combine(obj1, obj2, KEYCARD_R, GLIDER_SLOT)) { + _vm->renderImage(5); + _gm->wait(7); + _vm->renderImage(8); + getObject(5)->_click = 10; + _gm->_inventory.remove(*_gm->_rooms[ROGER]->getObject(8)); + } else if (((verb == ACTION_TAKE) || (verb == ACTION_PULL)) && + (obj1._id == GLIDER_KEYCARD)) { + _vm->renderImage(_gm->invertSection(5)); + _vm->renderImage(_gm->invertSection(8)); + getObject(5)->_click = 255; + _gm->takeObject(*_gm->_rooms[ROGER]->getObject(8)); + for (int i = 9; i <= 22; i++) + _vm->renderImage(_gm->invertSection(i)); + l = r = 0; + } else if ((verb == ACTION_PRESS) && + (obj1._id >= GLIDER_BUTTON1) && (obj1._id <= GLIDER_BUTTON4)) { + int i = obj1._id - GLIDER_BUTTON1 + 1; + _vm->renderImage(i); + if (isSectionVisible(8)) { + l = 0; + r = 0; + for (int j = 1; j < 8; j++) { + if (isSectionVisible(j + 8)) + l = j; + if (isSectionVisible(j + 15)) + r = j; + } + switch (i) { + case 1: + if (l < 7) { + l++; + _vm->renderImage(l + 8); + } + break; + case 3: + if (r < 7) { + r++; + _vm->renderImage(r + 15); + } + break; + case 2: + if (l) { + _vm->renderImage(_gm->invertSection(l + 8)); + l--; + } + break; + case 4: + if (r) { + _vm->renderImage(_gm->invertSection(r + 15)); + r--; + } + } + } + _gm->wait(4); + _vm->renderImage(_gm->invertSection(i)); + } else if ((verb == ACTION_USE) && (obj1._id == GLIDER_BUTTONS)) + _vm->renderMessage(kStringArsanoGlider1); + else + return false; + + return true; +} + +ArsanoMeetup2::ArsanoMeetup2(SupernovaEngine *vm, GameManager1 *gm) { + _vm = vm; + _gm = gm; + + _fileNumber = 38; + _id = MEETUP2; + _shown[0] = kShownTrue; + + _objectState[0] = Object(_id, kStringRoger, kStringDefaultDescription, ROGER_W, TALK, 255, 255, 0); + _objectState[1] = Object(_id, kStringSpaceshift, kStringDefaultDescription, SPACESHIP, COMBINABLE, 255, 255, 0); + _objectState[2] = Object(_id, kStringCave, kStringDefaultDescription, NULLOBJECT, EXIT, 255, 255, 0, CAVE, 22); + + _dialog1[0] = kStringDialogArsanoMeetup2_1; + _dialog1[1] = kStringDialogArsanoMeetup2_2; + _dialog2[0] = kStringDialogArsanoMeetup2_3; + _dialog2[1] = kStringDialogArsanoMeetup2_4; + _dialog3[0] = kStringDialogArsanoMeetup2_5; + _dialog3[1] = kStringDialogArsanoMeetup2_6; + _dialog3[2] = kStringDialogArsanoMeetup2_7; + _dialog3[3] = kStringDialogArsanoMeetup2_8; + _dialog4[0] = kStringDialogArsanoMeetup2_9; + _dialog4[1] = kStringDialogArsanoMeetup2_10; + _dialog4[2] = kStringDialogArsanoMeetup2_11; +} + +void ArsanoMeetup2::onEntrance() { + if (sentenceRemoved(0, 1)) { + if (sentenceRemoved(1, 1)) + _vm->renderMessage(kStringArsanoMeetup2_2); // All spaceships have left the planet, except one ... + else + shipStart(); + } else if (sentenceRemoved(1, 1)) + _vm->renderMessage(kStringArsanoMeetup2_1); // All spaceships have left the planet + + addAllSentences(1); +} + +bool ArsanoMeetup2::interact(Action verb, Object &obj1, Object &obj2) { + static byte row1[6] = {1, 1, 0, 0, 0, 0}; + static byte row2[6] = {1, 1, 0, 0, 0, 0}; + static byte row3[6] = {1, 1, 1, 1, 0, 0}; + static byte row4[6] = {2, 1, 0, 0, 0, 0}; + + if (((verb == ACTION_WALK) && + ((obj1._id == SPACESHIP) || (obj1._id == ROGER_W))) || + ((verb == ACTION_TALK) && (obj1._id == ROGER_W))) { + _gm->changeRoom(INTRO); + _vm->setCurrentImage(30); + _vm->renderImage(0); + _vm->paletteBrightness(); + bool found; + if (sentenceRemoved(0, 2) || sentenceRemoved(1, 2)) { + _gm->reply(kStringArsanoMeetup2_3, 1, 1 + 128); + found = !_gm->dialog(2, row4, _dialog4, 0); + if (!(found)) + _gm->reply(kStringArsanoMeetup2_4, 1, 1 + 128); + } else { + _gm->reply(kStringArsanoMeetup2_5, 1, 1 + 128); + _gm->reply(kStringArsanoMeetup2_6, 1, 1 + 128); + found = !_gm->dialog(2, row1, _dialog1, 0); + removeSentence(0, 2); + } + if (found) { + _gm->_inventory.remove(*_gm->_rooms[ROGER]->getObject(3)); + _gm->_inventory.remove(*_gm->_rooms[ROGER]->getObject(7)); + _gm->_inventory.remove(*_gm->_rooms[ROGER]->getObject(8)); + _gm->reply(kStringArsanoMeetup2_7, 1, 1 + 128); + _gm->reply(kStringArsanoMeetup2_8, 1, 1 + 128); + bool flight = _gm->dialog(2, row2, _dialog2, 0); + if (flight) { + _gm->reply(kStringArsanoMeetup2_9, 1, 1 + 128); + _gm->dialog(4, row3, _dialog3, 0); + _gm->reply(kStringArsanoMeetup2_10, 1, 1 + 128); + } else + _gm->reply(kStringArsanoMeetup2_11, 1, 1 + 128); + + _gm->changeRoom(MEETUP2); + _gm->_rooms[MEETUP2]->setSectionVisible(12, false); + _gm->_rooms[MEETUP2]->getObject(0)->_click = 255; + _gm->_rooms[MEETUP2]->getObject(1)->_click = 255; + _vm->renderRoom(*this); + _vm->paletteBrightness(); + shipStart(); + if (flight) { + _vm->setCurrentImage(13); + _vm->renderImage(0); + _vm->paletteBrightness(); + _gm->wait(36); + for (int i = 1; i <= 13; i++) { + if (i > 1) + _vm->renderImage(_gm->invertSection(i - 1)); + _vm->renderImage(i); + _gm->wait(2); + } + _vm->renderImage(_gm->invertSection(13)); + _gm->wait(20); + _vm->setCurrentImage(14); + _vm->renderImage(0); + _vm->paletteBrightness(); + _gm->wait(36); + for (int i = 1; i <= 13; i++) { + if (i > 1) + _vm->renderImage(_gm->invertSection(i - 1)); + _vm->renderImage(i); + _gm->wait(2); + } + _vm->renderImage(_gm->invertSection(13)); + _gm->wait(9); + _vm->playSound(kAudioCrash); + for (int i = 14; i <= 19; i++) { + _vm->renderImage(i); + _gm->wait(3); + } + _vm->paletteFadeOut(); + _vm->setCurrentImage(11); + _vm->renderImage(0); + _vm->paletteFadeIn(); + _gm->wait(18); + _vm->renderMessage(kStringArsanoMeetup2_12); + _gm->great(0); + _gm->waitOnInput(_gm->_messageDuration); + _vm->removeMessage(); + _vm->paletteFadeOut(); + g_system->fillScreen(kColorBlack); + _gm->_state._dream = false; + if (!_vm->loadGame(kSleepAutosaveSlot)) + _vm->errorTempSave(false); + _gm->loadTime(); + _gm->_rooms[CAVE]->getObject(1)->_exitRoom = MEETUP3; + _gm->_state._dream = true; + } + } else { + _gm->changeRoom(MEETUP2); + _vm->renderRoom(*this); + } + } else if ((verb == ACTION_USE) && Object::combine(obj1, obj2, KEYCARD_R, SPACESHIP)) + _vm->renderMessage(kStringArsanoMeetup2_13); + else + return false; + + return true; +} + +void ArsanoMeetup2::shipStart() { + _gm->wait(12); + for (int i = 2; i <= 11; ++i) { + if (i >= 9) + _vm->renderImage(i - 1 + 128); + else + setSectionVisible(i - 1, false); + _vm->renderImage(i); + _gm->wait(2); + } + _vm->renderImage(11 + 128); +} + +ArsanoMeetup3::ArsanoMeetup3(SupernovaEngine *vm, GameManager1 *gm) { + _vm = vm; + _gm = gm; + + _fileNumber = 39; + _id = MEETUP3; + _shown[0] = kShownTrue; + + _objectState[0] = Object(_id, kStringUfo,kStringUfoDescription,UFO,EXIT,0,0,0,NULLROOM,3); + _objectState[1] = Object(_id, kStringStar,kStringDefaultDescription,STAR,NULLTYPE,1,1,0); + _objectState[2] = Object(_id, kStringCave,kStringDefaultDescription,NULLOBJECT,EXIT,255,255,0,CAVE,22); + + _dialog2[0] = kStringArsanoDialog1; + _dialog2[1] = kStringDialogArsanoMeetup3_1; + _dialog2[2] = kStringDialogArsanoMeetup3_2; + _dialog2[3] = kStringDialogArsanoMeetup3_3; + _dialog3[0] = kStringDialogArsanoMeetup3_4; + _dialog3[1] = kStringDialogArsanoMeetup3_5; + + _dialogsX[0] = kStringDialogX1; + _dialogsX[1] = kStringDialogX2; + _dialogsX[2] = kStringDialogX3; +} + +bool ArsanoMeetup3::interact(Action verb, Object &obj1, Object &obj2) { + byte row2[6] = {1, 1, 1, 1, 0, 0}; + byte row3[6] = {1, 1, 0, 0, 0, 0}; + byte rowsX[6] = {1, 1, 1, 0, 0, 0}; + + if ((verb == ACTION_WALK) && (obj1._id == STAR)) + _vm->renderMessage(kStringArsanoMeetup2); + else if ((verb == ACTION_LOOK) && (obj1._id == STAR)) { + _vm->setCurrentImage(26); + _vm->renderImage(0); + _vm->paletteBrightness(); + _gm->getInput(); + g_system->fillScreen(kColorBlack); + _vm->renderRoom(*this); + } else if ((verb == ACTION_WALK) && (obj1._id == UFO)) { + g_system->fillScreen(kColorBlack); + _vm->setCurrentImage(36); + _vm->renderImage(0); + _vm->paletteBrightness(); + _gm->dialog(3, rowsX, _dialogsX, 0); + _vm->renderImage(1); + _gm->wait(3); + _vm->renderImage(2); + _gm->wait(3); + _vm->renderImage(3); + _gm->wait(6); + _vm->renderImage(4); + _vm->playSound(kAudioGunShot); + + while (_vm->_sound->isPlaying()) + _gm->wait(1); + + _vm->renderImage(5); + _gm->wait(3); + _vm->renderImage(4); + _vm->playSound(kAudioGunShot); + + while (_vm->_sound->isPlaying()) + _gm->wait(1); + + _vm->renderImage(5); + _vm->paletteFadeOut(); + _gm->wait(12); + _vm->setCurrentImage(0); + _vm->renderImage(0); + _vm->paletteFadeIn(); + _gm->wait(18); + _gm->reply(kStringArsanoMeetup3_1, 2, 2 + 128); + _gm->wait(10); + _gm->reply(kStringArsanoMeetup3_2, 1, 1 + 128); + + do { + int i = _gm->dialog(4, row2, _dialog2, 2); + switch (i) { + case 0: + _gm->reply(kStringArsanoMeetup3_3, 1, 1 + 128); + _gm->reply(kStringArsanoMeetup3_4, 1, 1 + 128); + break; + case 1: + _gm->reply(kStringArsanoMeetup3_5, 2, 2 + 128); + _gm->say(kStringArsanoMeetup3_6); + _gm->reply(kStringArsanoMeetup3_7, 2, 2 + 128); + _gm->reply(kStringArsanoMeetup3_8, 2, 2 + 128); + _gm->reply(kStringArsanoMeetup3_9, 2, 2 + 128); + _gm->reply(kStringArsanoMeetup3_10, 2, 2 + 128); + _gm->reply(kStringArsanoMeetup3_11, 2, 2 + 128); + if (_gm->dialog(2, row3, _dialog3, 0)) { + _gm->reply(kStringArsanoMeetup3_12, 2, 2 + 128); + _gm->say(kStringArsanoMeetup3_13); + } + _gm->reply(kStringArsanoMeetup3_14, 2, 2 + 128); + _gm->reply(kStringArsanoMeetup3_15, 2, 2 + 128); + _gm->reply(kStringArsanoMeetup3_16, 2, 2 + 128); + _gm->reply(kStringArsanoMeetup3_17, 2, 2 + 128); + if (_gm->dialog(2, row3, _dialog3, 0)) { + _gm->reply(kStringArsanoMeetup3_12, 2, 2 + 128); + _gm->say(kStringArsanoMeetup3_13); + } + _gm->reply(kStringArsanoMeetup3_18, 2, 2 + 128); + break; + case 2: + _gm->reply(kStringArsanoMeetup3_19, 2, 2 + 128); + _gm->reply(kStringArsanoMeetup3_20, 2, 2 + 128); + break; + case 3: + _gm->reply(kStringArsanoMeetup3_21, 1, 1 + 128); + _gm->reply(kStringArsanoMeetup3_22, 1, 1 + 128); + _gm->say(kStringArsanoMeetup3_23); + _gm->reply(kStringArsanoMeetup3_24, 1, 1 + 128); + _gm->reply(kStringArsanoMeetup3_25, 1, 1 + 128); + } + removeSentence(2, 2); + } while (!allSentencesRemoved(4, 2)); + _gm->say(kStringArsanoMeetup3_26); + _gm->reply(kStringArsanoMeetup3_27, 1, 1 + 128); + _gm->reply(kStringArsanoMeetup3_28, 1, 1 + 128); + _vm->paletteFadeOut(); + // Remove all objects from the inventory except the Knife, Watch and Discman + bool has_knife = _gm->_rooms[INTRO]->getObject(1)->hasProperty(CARRIED); + bool has_watch = _gm->_rooms[INTRO]->getObject(2)->hasProperty(CARRIED); + bool has_discman = _gm->_rooms[INTRO]->getObject(3)->hasProperty(CARRIED); + _gm->_inventory.clear(); + _gm->_inventoryScroll = 0; + if (has_knife) + _gm->_inventory.add(*_gm->_rooms[INTRO]->getObject(1)); + if (has_watch) + _gm->_inventory.add(*_gm->_rooms[INTRO]->getObject(2)); + if (has_discman) + _gm->_inventory.add(*_gm->_rooms[INTRO]->getObject(3)); + _gm->changeRoom(CELL); + _gm->_state._dream = true; + } else + return false; + + return true; +} + +// Axacuss +AxacussCell::AxacussCell(SupernovaEngine *vm, GameManager1 *gm) { + _vm = vm; + _gm = gm; + + _fileNumber = 43; + _id = CELL; + _shown[0] = kShownTrue; + _shown[1] = kShownTrue; + _shown[31] = kShownTrue; + + _objectState[0] = Object(_id, kStringButton,kStringDefaultDescription,CELL_BUTTON,PRESS,1,1,0); + _objectState[1] = Object(_id, kStringDoor,kStringDefaultDescription,CELL_DOOR,EXIT|OPENABLE|CLOSED,0,0,31+128,CORRIDOR4,1); + _objectState[2] = Object(_id, kStringTray,kStringTrayDescription,TRAY,UNNECESSARY,255,255,0); + _objectState[3] = Object(_id, kStringLamp,kStringLampDescription,NULLOBJECT,COMBINABLE,3,3,0); + _objectState[4] = Object(_id, kStringEyes,kStringEyesDescription,NULLOBJECT,NULLTYPE,4,4,0); + _objectState[5] = Object(_id, kStringWire,kStringDefaultDescription,CELL_WIRE,COMBINABLE|TAKE,6,6,0); + _objectState[6] = Object(_id, kStringSocket,kStringSocketDescription,SOCKET,COMBINABLE,5,5,0); + _objectState[7] = Object(_id, kStringMetalBlock,kStringMetalBlockDescription,MAGNET,TAKE|COMBINABLE,255,255,30); + _objectState[8] = Object(_id, kStringRobot,kStringRobotDescription,NULLOBJECT,NULLTYPE,255,255,0); + _objectState[9] = Object(_id, kStringTable,kStringTableDescription,CELL_TABLE,COMBINABLE,2,2,0); +} + +void AxacussCell::onEntrance() { + if (_gm->_state._dream) { + _vm->renderMessage(kStringAxacussCell_1); + _gm->_time = ticksToMsec(500000); + _gm->_state._alarmOn = (_gm->_state._timeAlarm > _gm->_time); + _gm->_state._powerOff = false; + _gm->_state._dream = false; + } +} + +void AxacussCell::animation() { + ++_gm->_state._timeRobot; + + if (_gm->_state._timeRobot == 299) { + _vm->renderImage(_gm->invertSection(31)); + _vm->renderImage(28); + getObject(0)->_click = 255; + getObject(1)->resetProperty(EXIT | OPENABLE | OPENED | CLOSED); + } else if ((_gm->_state._timeRobot >= 301) && (_gm->_state._timeRobot <= 320)) { + _vm->renderImage(_gm->invertSection(329 - _gm->_state._timeRobot)); + _vm->renderImage(328 - _gm->_state._timeRobot); + } else if (_gm->_state._timeRobot == 321) { + _vm->renderImage(31); + setSectionVisible(8, false); + getObject(0)->_click = 1; + getObject(1)->resetProperty(EXIT | OPENABLE | CLOSED); + } + + if (_gm->_state._timeRobot == 599) { + _vm->renderImage(_gm->invertSection(31)); + _vm->renderImage(8); + getObject(0)->_click = 255; + getObject(1)->resetProperty(EXIT | OPENABLE | OPENED | CLOSED); + } else if ((_gm->_state._timeRobot >= 601) && (_gm->_state._timeRobot <= 620)) { + _vm->renderImage(_gm->_state._timeRobot - 593 + 128); + _vm->renderImage(_gm->_state._timeRobot - 592); + } else if (_gm->_state._timeRobot == 621) { + _vm->renderImage(31); + setSectionVisible(28, false); + getObject(0)->_click = 1; + getObject(1)->resetProperty(EXIT | OPENABLE | CLOSED); + } else if (_gm->_state._timeRobot == 700) + _gm->_state._timeRobot = 0; + else if (_gm->_state._timeRobot == 10002) { + _vm->renderImage(18 + 128); + _vm->renderImage(29); + _vm->renderImage(7); + getObject(2)->_click = 13; + } else if (_gm->_state._timeRobot == 10003) { + setSectionVisible(29, false); + _vm->renderImage(30); + getObject(8)->_click = 12; + getObject(7)->_click = 14; + _vm->playSound(kAudioRobotBreaks); + } else if (_gm->_state._timeRobot == 10010) + --_gm->_state._timeRobot; + + if (_gm->_state._timeRobot == 312) { + _vm->renderImage(7); + getObject(2)->_click = 13; + } else if (_gm->_state._timeRobot == 610) { + setSectionVisible(7, false); + getObject(2)->_click = 255; + } + + if ((isSectionVisible(6)) && + ((_gm->_state._timeRobot == 310) || (_gm->_state._timeRobot == 610))) { + _vm->playSound(kAudioRobotShock); + _gm->_state._timeRobot = 10000; + } + + _gm->setAnimationTimer(3); +} + +bool AxacussCell::interact(Action verb, Object &obj1, Object &obj2) { + if ((verb == ACTION_PRESS) && (obj1._id == CELL_BUTTON)) + _vm->renderMessage(kStringAxacussCell_2); + else if ((verb == ACTION_PULL) && (obj1._id == CELL_WIRE) && + !isSectionVisible(2) && + !isSectionVisible(3) && + !isSectionVisible(5)) { + if (isSectionVisible(1)) { + _vm->renderImage(_gm->invertSection(1)); + _vm->renderImage(2); + getObject(5)->_click = 7; + } else if (isSectionVisible(4)) { + _vm->renderImage(_gm->invertSection(4)); + _vm->renderImage(3); + getObject(5)->_click = 8; + } else if (isSectionVisible(6)) { + _vm->renderImage(_gm->invertSection(6)); + _vm->renderImage(5); + getObject(5)->_click = 10; + } + } else if ((verb == ACTION_USE) && Object::combine(obj1, obj2, CELL_WIRE, SOCKET) && + !isSectionVisible(1) && !isSectionVisible(4) && !isSectionVisible(6)) { + if (isSectionVisible(2)) { + _vm->renderImage(_gm->invertSection(2)); + _vm->renderImage(1); + getObject(5)->_click = 6; + } else if (isSectionVisible(3)) { + _vm->renderImage(_gm->invertSection(3)); + _vm->renderImage(4); + getObject(5)->_click = 9; + } else if (isSectionVisible(5)) { + _vm->renderImage(_gm->invertSection(5)); + _vm->renderImage(6); + getObject(5)->_click = 11; + } else { + _gm->_inventory.remove(*getObject(5)); + _vm->renderImage(4); + getObject(5)->_click = 9; + } + } else if ((verb == ACTION_USE) && Object::combine(obj1, obj2, CELL_WIRE, KNIFE) && + ((isSectionVisible(1)) || (isSectionVisible(2)))) { + if (isSectionVisible(1)) + _gm->shock(); + else { + _vm->renderImage(_gm->invertSection(2)); + _vm->renderImage(3); + getObject(5)->_click = 8; + } + } else if ((verb == ACTION_USE) && Object::combine(obj1, obj2, CELL_WIRE, CELL_TABLE) && + !isSectionVisible(1) && + !isSectionVisible(2) && + !isSectionVisible(5) && + !isSectionVisible(6)) { + if (isSectionVisible(3)) { + _vm->renderImage(_gm->invertSection(3)); + _vm->renderImage(5); + getObject(5)->_click = 10; + } else if (isSectionVisible(4)) { + _vm->renderImage(_gm->invertSection(4)); + _vm->renderImage(6); + _gm->shock(); + } else { + _gm->_inventory.remove(*getObject(5)); + _vm->renderImage(5); + getObject(5)->_click = 10; + } + } else if ((verb == ACTION_TAKE) && (obj1._id == CELL_WIRE) && !(obj1.hasProperty(CARRIED))) { + if (isSectionVisible(3)) { + _vm->renderImage(_gm->invertSection(3)); + _gm->takeObject(obj1); + } else if (isSectionVisible(5)) { + _vm->renderImage(_gm->invertSection(5)); + _gm->takeObject(obj1); + } else + _vm->renderMessage(kStringAxacussCell_3); + } else if ((verb == ACTION_WALK) && (obj1._id == CELL_DOOR) && (obj1.hasProperty(OPENED))) { + if (isSectionVisible(30) || isSectionVisible(29)) + return false; + _vm->playSound(kAudioGunShot); + + while (_vm->_sound->isPlaying()) + _gm->wait(1); + + _vm->playSound(kAudioGunShot); + _vm->playSound(kAudioGunShot); + _gm->dead(kStringAxacussCell_4); + } else if ((verb == ACTION_USE) && (obj1._id == TRAY)) + _vm->renderMessage(kStringAxacussCell_5); + else if ((verb == ACTION_TAKE) && (obj1._id == MAGNET)) { + if (isSectionVisible(6)) + _gm->shock(); + _gm->takeObject(obj1); + _vm->renderMessage(kStringOk); + } else + return false; + + return true; +} + +AxacussCorridor1::AxacussCorridor1(SupernovaEngine *vm, GameManager1 *gm) { + _vm = vm; + _gm = gm; + + _fileNumber = 16; + _id = CORRIDOR1; + _shown[0] = kShownTrue; + _shown[3] = kShownTrue; + _shown[4] = kShownTrue; + _shown[5] = kShownTrue; + _shown[13] = kShownTrue; + _shown[21] = kShownTrue; + _shown[23] = kShownTrue; + _shown[25] = kShownTrue; + + _objectState[0] = Object(_id, kStringExit,kStringDefaultDescription,NULLOBJECT,EXIT,2,2,0,GUARD3,2); + _objectState[1] = Object(_id, kStringExit,kStringDefaultDescription,NULLOBJECT,EXIT,3,3,0,CORRIDOR2,22); +} + +void AxacussCorridor1::onEntrance() { + _gm->corridorOnEntrance(); +} + + +AxacussCorridor2::AxacussCorridor2(SupernovaEngine *vm, GameManager1 *gm) { + _vm = vm; + _gm = gm; + + _fileNumber = 16; + _id = CORRIDOR2; + _shown[0] = kShownTrue; + _shown[2] = kShownTrue; + _shown[3] = kShownTrue; + _shown[4] = kShownTrue; + _shown[5] = kShownTrue; + _shown[17] = kShownTrue; + _shown[21] = kShownTrue; + _shown[24] = kShownTrue; + + _objectState[0] = Object(_id, kStringExit,kStringDefaultDescription,NULLOBJECT,EXIT,2,2,0,CORRIDOR1,2); + _objectState[1] = Object(_id, kStringExit,kStringDefaultDescription,NULLOBJECT,EXIT,3,3,0,CORRIDOR3,22); + _objectState[2] = Object(_id, kStringExit,kStringDefaultDescription,NULLOBJECT,EXIT,1,1,0,CORRIDOR4,14); +} + +void AxacussCorridor2::onEntrance() { + _gm->corridorOnEntrance(); +} + +AxacussCorridor3::AxacussCorridor3(SupernovaEngine *vm, GameManager1 *gm) { + _vm = vm; + _gm = gm; + + _fileNumber = 16; + _id = CORRIDOR3; + _shown[0] = kShownTrue; + _shown[3] = kShownTrue; + _shown[5] = kShownTrue; + _shown[19] = kShownTrue; + _shown[23] = kShownTrue; + + _objectState[0] = Object(_id, kStringExit,kStringDefaultDescription,NULLOBJECT,EXIT,2,2,0,CORRIDOR2,2); +} + +void AxacussCorridor3::onEntrance() { + _gm->corridorOnEntrance(); +} + +void AxacussCorridor4::onEntrance() { + _gm->great(4); + _gm->corridorOnEntrance(); + if (_gm->_rooms[GUARD]->isSectionVisible(1)) + _gm->busted(0); +} + +AxacussCorridor4::AxacussCorridor4(SupernovaEngine *vm, GameManager1 *gm) { + _vm = vm; + _gm = gm; + + _fileNumber = 16; + _id = CORRIDOR4; + _shown[0] = kShownTrue; + _shown[1] = kShownTrue; + _shown[2] = kShownTrue; + _shown[8] = kShownTrue; + _shown[9] = kShownTrue; + _shown[11] = kShownTrue; + _shown[15] = kShownTrue; + _shown[18] = kShownTrue; + _shown[20] = kShownTrue; + _shown[26] = kShownTrue; + + _objectState[0] = Object(_id, kStringExit,kStringDefaultDescription,NULLOBJECT,EXIT,0,0,0,CORRIDOR2,10); + _objectState[1] = Object(_id, kStringExit,kStringDefaultDescription,NULLOBJECT,EXIT,1,1,0,GUARD,14); + _objectState[2] = Object(_id, kStringCellDoor,kStringCellDoorDescription,DOOR,EXIT|OPENABLE|OPENED|CLOSED,7,7,0,CELL,16); + _objectState[3] = Object(_id, kStringLaptop,kStringDefaultDescription,NEWSPAPER,TAKE,6,6,8); + _objectState[4] = Object(_id, kStringWristwatch,kStringDefaultDescription,WATCH,TAKE|COMBINABLE,255,255,8); + _objectState[5] = Object(_id, kStringTable,kStringDefaultDescription,TABLE,COMBINABLE,5,5,0); +} + +void AxacussCorridor4::animation() { +} + +bool AxacussCorridor4::interact(Action verb, Object &obj1, Object &obj2) { + if ((verb == ACTION_TAKE) && (obj1._id == NEWSPAPER)) { + setSectionVisible(9, false); + _gm->takeObject(obj1); + if (isSectionVisible(29)) + _vm->renderImage(29); + } else if (((verb == ACTION_USE) && Object::combine(obj1, obj2, TABLE, WATCH)) || + ((verb == ACTION_GIVE) && (obj1._id == WATCH) && (obj2._id == TABLE))) { + if (obj1._id == WATCH) + _gm->_inventory.remove(obj1); + else + _gm->_inventory.remove(obj2); + + _vm->renderImage(29); + getObject(4)->_click = 8; + } else if ((verb == ACTION_TAKE) && (obj1._id == WATCH) && !obj1.hasProperty(CARRIED)) { + setSectionVisible(29, false); + getObject(4)->_click = 255; + _gm->takeObject(*_gm->_rooms[INTRO]->getObject(2)); + if (isSectionVisible(9)) + _vm->renderImage(9); + } else + return false; + + return true; +} + +AxacussCorridor5::AxacussCorridor5(SupernovaEngine *vm, GameManager1 *gm) { + _vm = vm; + _gm = gm; + + _fileNumber = 16; + _id = CORRIDOR5; + _shown[0] = kShownTrue; + _shown[3] = kShownTrue; + _shown[4] = kShownTrue; + _shown[5] = kShownTrue; + _shown[12] = kShownTrue; + _shown[22] = kShownTrue; + _shown[23] = kShownTrue; + _shown[24] = kShownTrue; + + _objectState[0] = Object(_id, kStringExit,kStringDefaultDescription,DOOR,EXIT,2,2,0,NULLROOM,2); + _objectState[1] = Object(_id, kStringExit,kStringDefaultDescription,NULLOBJECT,EXIT,3,3,0,CORRIDOR6,22); + + _dialog1[0] = kStringDialogAxacussCorridor5_1; + _dialog1[1] = kStringDialogAxacussCorridor5_2; + _dialog2[0] = kStringDialogAxacussCorridor5_3; + _dialog2[1] = kStringDialogAxacussCorridor5_4; + _dialog3[0] = kStringDialogAxacussCorridor5_5; + _dialog3[1] = kStringDialogAxacussCorridor5_6; + _dialog3[2] = kStringDialogAxacussCorridor5_7; + _dialog3[3] = kStringDialogAxacussCorridor5_7; + + _rows[0] = 1; + _rows[1] = 1; + _rows[2] = 1; + _rows[3] = 1; + _rows[4] = 0; + _rows[5] = 0; +} + +void AxacussCorridor5::onEntrance() { + _gm->corridorOnEntrance(); +} + +bool AxacussCorridor5::handleMoneyDialog() { + if (_gm->dialog(2, _rows, _dialog2, 0) == 0) { + _gm->reply(kStringAxacussCorridor5_5, 1, 1 + 128); + addAllSentences(2); + if (_gm->_state._money == 0) { + removeSentence(2, 2); + removeSentence(3, 2); + } else { + Common::String string = _vm->getGameString(kStringDialogAxacussCorridor5_7); + _vm->setGameString(kStringPlaceholder1, Common::String::format(string.c_str(), _gm->_state._money - 200)); + _vm->setGameString(kStringPlaceholder2, Common::String::format(string.c_str(), _gm->_state._money)); + _dialog3[2] = kStringPlaceholder1; + _dialog3[3] = kStringPlaceholder2; + } + switch (_gm->dialog(4, _rows, _dialog3, 2)) { + case 1: + _gm->wait(3); + _vm->renderImage(1); + _vm->playSound(kAudioVoiceHalt); + _vm->renderImage(_gm->invertSection(1)); + _gm->wait(5); + _vm->renderImage(2); + _gm->wait(2); + _gm->shot(3, _gm->invertSection(3)); + break; + case 2: + if (_gm->_state._money > 1100) { + stopInteract(_gm->_state._money - 200); + return true; + } + _gm->reply(kStringAxacussCorridor5_6, 1, 1 + 128); + break; + case 3: + if (_gm->_state._money >= 900) { + stopInteract(_gm->_state._money); + return true; + } + _gm->reply(kStringAxacussCorridor5_6, 1, 1 + 128); + break; + } + } + return false; +} + +void AxacussCorridor5::stopInteract(int sum) { + _gm->reply(kStringAxacussCorridor5_7, 1, 1 + 128); + _gm->great(0); + _gm->changeRoom(ELEVATOR); + _gm->takeMoney(-sum); +} + +bool AxacussCorridor5::interact(Action verb, Object &obj1, Object &obj2) { + if ((verb == ACTION_WALK) && (obj1._id == DOOR)) { + g_system->fillScreen(kColorBlack); + _vm->setCurrentImage(41); + _vm->renderImage(0); + _vm->paletteBrightness(); + if (_gm->_guiEnabled) { + _gm->reply(kStringAxacussCorridor5_1, 1, 1 + 128); + if (handleMoneyDialog()) + return true; + } else { + _gm->_guiEnabled = true; + _gm->reply(kStringAxacussCorridor5_2, 1, 1 + 128); + if (_gm->dialog(2, _rows, _dialog1, 0)) + _gm->reply(kStringAxacussCorridor5_3, 1, 1 + 128); + else { + _gm->reply(kStringAxacussCorridor5_4, 1, 1 + 128); + if (handleMoneyDialog()) + return true; + } + } + g_system->fillScreen(kColorBlack); + return true; + } + return false; +} + +AxacussCorridor6::AxacussCorridor6(SupernovaEngine *vm, GameManager1 *gm) { + _vm = vm; + _gm = gm; + + _fileNumber = 16; + _id = CORRIDOR6; + _shown[0] = kShownTrue; + _shown[3] = kShownTrue; + _shown[4] = kShownTrue; + _shown[5] = kShownTrue; + _shown[6] = kShownTrue; + _shown[22] = kShownTrue; + _shown[24] = kShownTrue; + _shown[25] = kShownTrue; + + _objectState[0] = Object(_id, kStringExit,kStringDefaultDescription,NULLOBJECT,EXIT,2,2,0,CORRIDOR5,2); + _objectState[1] = Object(_id, kStringExit,kStringDefaultDescription,NULLOBJECT,EXIT,3,3,0,CORRIDOR7,22); + _objectState[2] = Object(_id, kStringDoor,kStringDefaultDescription,DOOR,OPENABLE|CLOSED,255,255,0,CORRIDOR8,13); +} + +void AxacussCorridor6::onEntrance() { + _gm->corridorOnEntrance(); +} + +bool AxacussCorridor6::interact(Action verb, Object &obj1, Object &obj2) { + if ((verb == ACTION_CLOSE) && (obj1._id == DOOR) && + (obj1.hasProperty(OPENED))) { + _vm->renderImage(6); + setSectionVisible(7, false); + obj1.resetProperty(EXIT | OPENABLE | CLOSED); + _gm->_rooms[CORRIDOR8]->setSectionVisible(27, false); + _gm->_rooms[CORRIDOR8]->setSectionVisible(28, true); + _gm->_rooms[CORRIDOR8]->getObject(0)->disableProperty(OPENED); + _vm->playSound(kAudioDoorClose); + } else + return false; + + return true; +} + +AxacussCorridor7::AxacussCorridor7(SupernovaEngine *vm, GameManager1 *gm) { + _vm = vm; + _gm = gm; + + _fileNumber = 16; + _id = CORRIDOR7; + _shown[0] = kShownTrue; + _shown[3] = kShownTrue; + _shown[4] = kShownTrue; + _shown[5] = kShownTrue; + _shown[10] = kShownTrue; + _shown[21] = kShownTrue; + _shown[24] = kShownTrue; + _shown[25] = kShownTrue; + + _objectState[0] = Object(_id, kStringExit,kStringDefaultDescription,NULLOBJECT,EXIT,2,2,0,CORRIDOR6,2); + _objectState[1] = Object(_id, kStringExit,kStringDefaultDescription,NULLOBJECT,EXIT,3,3,0,GUARD,22); +} + +void AxacussCorridor7::onEntrance() { + _gm->corridorOnEntrance(); +} + +AxacussCorridor8::AxacussCorridor8(SupernovaEngine *vm, GameManager1 *gm) { + _vm = vm; + _gm = gm; + + _fileNumber = 16; + _id = CORRIDOR8; + _shown[0] = kShownTrue; + _shown[1] = kShownTrue; + _shown[4] = kShownTrue; + _shown[15] = kShownTrue; + _shown[20] = kShownTrue; + _shown[22] = kShownTrue; + _shown[28] = kShownTrue; + + _objectState[0] = Object(_id, kStringDoor,kStringDefaultDescription,DOOR,EXIT|OPENABLE,0,0,0,CORRIDOR6,10); + _objectState[1] = Object(_id, kStringExit,kStringDefaultDescription,NULLOBJECT,EXIT,3,3,0,BCORRIDOR,22); +} + +void AxacussCorridor8::onEntrance() { + _gm->corridorOnEntrance(); +} + +bool AxacussCorridor8::interact(Action verb, Object &obj1, Object &obj2) { + if ((verb == ACTION_OPEN) && (obj1._id == DOOR) && !obj1.hasProperty(OPENED)) { + _vm->renderImage(27); + setSectionVisible(28, false); + obj1.setProperty(OPENED); + _gm->_rooms[CORRIDOR6]->setSectionVisible(6, false); + _gm->_rooms[CORRIDOR6]->setSectionVisible(7, true); + _gm->_rooms[CORRIDOR6]->getObject(2)->resetProperty(EXIT | OPENED | OPENABLE); + _gm->_rooms[CORRIDOR6]->getObject(2)->_click = 4; + _vm->playSound(kAudioDoorOpen); + } else if ((verb == ACTION_CLOSE) && (obj1._id == DOOR) && (obj1._type & OPENED)) { + _vm->renderImage(28); + setSectionVisible(27, false); + obj1.disableProperty(OPENED); + _gm->_rooms[CORRIDOR6]->setSectionVisible(6, true); + _gm->_rooms[CORRIDOR6]->setSectionVisible(7, false); + _gm->_rooms[CORRIDOR6]->getObject(2)->resetProperty(EXIT | CLOSED | OPENABLE); + _vm->playSound(kAudioDoorClose); + } else + return false; + + return true; +} + +AxacussCorridor9::AxacussCorridor9(SupernovaEngine *vm, GameManager1 *gm) { + _vm = vm; + _gm = gm; + + _fileNumber = 16; + _id = CORRIDOR9; + _shown[0] = kShownTrue; + _shown[1] = kShownTrue; + _shown[3] = kShownTrue; + _shown[14] = kShownTrue; + _shown[19] = kShownTrue; + _shown[23] = kShownTrue; + _shown[28] = kShownTrue; + + _objectState[0] = Object(_id, kStringExit,kStringDefaultDescription,NULLOBJECT,EXIT,2,2,0,BCORRIDOR,2); + _objectState[1] = Object(_id, kStringDoor,kStringDefaultDescription,DOOR,EXIT|OPENABLE,0,0,0,GUARD,10); +} + +void AxacussCorridor9::onEntrance() { + _gm->corridorOnEntrance(); +} + +bool AxacussCorridor9::interact(Action verb, Object &obj1, Object &obj2) { + if ((verb == ACTION_CLOSE) && (obj1._id == DOOR) && (obj1.hasProperty(OPENED))) { + _vm->renderImage(28); + setSectionVisible(27, false); + obj1.disableProperty(OPENED); + _gm->_rooms[GUARD]->setSectionVisible(6, false); + _gm->_rooms[GUARD]->getObject(2)->disableProperty(OPENED); + _vm->playSound(kAudioDoorClose); + } else if ((verb == ACTION_OPEN) && (obj1._id == DOOR) && !obj1.hasProperty(OPENED)) { + _vm->renderImage(27); + setSectionVisible(28, false); + obj1.setProperty(OPENED); + _gm->_rooms[GUARD]->setSectionVisible(6, true); + _gm->_rooms[GUARD]->getObject(2)->setProperty(OPENED); + _vm->playSound(kAudioDoorOpen); + if (!_gm->_rooms[GUARD]->isSectionVisible(1)) + _gm->busted(0); + } else + return false; + + return true; +} + +AxacussBcorridor::AxacussBcorridor(SupernovaEngine *vm, GameManager1 *gm) { + _vm = vm; + _gm = gm; + + _fileNumber = 6; + _id = BCORRIDOR; + _shown[0] = kShownTrue; + _shown[3] = kShownTrue; + + _objectState[0] = Object(_id, kStringPillar,kStringDefaultDescription,PILLAR1,NULLTYPE,4,4,0); + _objectState[1] = Object(_id, kStringPillar,kStringDefaultDescription,PILLAR2,NULLTYPE,5,5,0); + _objectState[2] = Object(_id, kStringExit,kStringDefaultDescription,NULLOBJECT,EXIT,6,6,0,CORRIDOR8,2); + _objectState[3] = Object(_id, kStringExit,kStringDefaultDescription,NULLOBJECT,EXIT,7,7,0,CORRIDOR9,22); + _objectState[4] = Object(_id, kStringDoor,kStringDoorDescription1,DOOR1,EXIT|OPENABLE|CLOSED|OCCUPIED,0,0,1,OFFICE_L1,6); + _objectState[5] = Object(_id, kStringDoor,kStringDoorDescription2,DOOR2,EXIT|OPENABLE|CLOSED|OCCUPIED,1,1,2,OFFICE_L2,16); + _objectState[6] = Object(_id, kStringDoor,kStringDoorDescription3,DOOR3,EXIT|OPENABLE|OPENED,2,2,3,OFFICE_R1,8); + _objectState[7] = Object(_id, kStringDoor,kStringDoorDescription4,DOOR4,EXIT|OPENABLE|CLOSED|OCCUPIED,3,3,4,OFFICE_R2,18); +} + +void AxacussBcorridor::onEntrance() { + _gm->corridorOnEntrance(); + if (isSectionVisible(7)) + _gm->busted(-1); +} + +bool AxacussBcorridor::interact(Action verb, Object &obj1, Object &obj2) { + if (obj1.hasProperty(EXIT) || + ((verb == ACTION_USE) && obj1.hasProperty(COMBINABLE) && obj2.hasProperty(EXIT))) { + _gm->_state._playerHidden = false; + } + + if ((verb == ACTION_CLOSE) && (obj1._id >= DOOR1) && (obj1._id <= DOOR4) && obj1.hasProperty(OPENED)) { + _vm->renderImage(_gm->invertSection(obj1._id - DOOR1 + 1)); + _vm->playSound(kAudioDoorClose); + obj1.disableProperty(OPENED); + obj1.setProperty(CLOSED); + if (obj1.hasProperty(OCCUPIED)) { + _gm->_state._destination = 255; + obj1.disableProperty(OCCUPIED); + obj1.setProperty(CAUGHT); + if (!_gm->_rooms[OFFICE_L1 + obj1._id - DOOR1]->isSectionVisible(4)) + _gm->search(180); + else + _gm->_state._eventTime = kMaxTimerValue; + } + } else if (((verb == ACTION_WALK) || ((verb == ACTION_OPEN) && !obj1.hasProperty(OPENED))) && + (obj1._id >= DOOR1) && (obj1._id <= DOOR4) && + obj1.hasProperty(OCCUPIED)) { + _vm->renderMessage(kStringDontEnter); + } else if ((verb == ACTION_USE) && Object::combine(obj1, obj2, MASTERKEYCARD, DOOR1) && + !getObject(4)->hasProperty(OPENED)) { + if (getObject(4)->hasProperty(OCCUPIED)) + _vm->renderMessage(kStringDontEnter); + else { + _vm->renderImage(1); + _vm->playSound(kAudioDoorOpen); + if (getObject(4)->hasProperty(CAUGHT)) + _gm->busted(11); + getObject(4)->resetProperty(EXIT | OPENABLE | OPENED); + } + } else if ((verb == ACTION_USE) && Object::combine(obj1, obj2, MASTERKEYCARD, DOOR2) && !getObject(5)->hasProperty(OPENED)) { + if (getObject(5)->hasProperty(OCCUPIED)) + _vm->renderMessage(kStringDontEnter); + else { + _vm->renderImage(2); + _vm->playSound(kAudioDoorOpen); + if (getObject(5)->hasProperty(CAUGHT)) + _gm->busted(16); + getObject(5)->resetProperty(EXIT | OPENABLE | OPENED); + } + } else if ((verb == ACTION_USE) && Object::combine(obj1, obj2, MASTERKEYCARD, DOOR3) && !getObject(6)->hasProperty(OPENED)) { + if (getObject(6)->hasProperty(OCCUPIED)) + _vm->renderMessage(kStringDontEnter); + else { + _vm->renderImage(3); + _vm->playSound(kAudioDoorOpen); + if (getObject(6)->hasProperty(CAUGHT)) + _gm->busted(15); + getObject(6)->resetProperty(EXIT | OPENABLE | OPENED); + } + } else if ((verb == ACTION_USE) && Object::combine(obj1, obj2, MASTERKEYCARD, DOOR4) && !getObject(7)->hasProperty(OPENED)) { + if (getObject(7)->hasProperty(OCCUPIED)) { + _vm->renderMessage(kStringDontEnter); + } else { + _vm->renderImage(4); + _vm->playSound(kAudioDoorOpen); + if (getObject(7)->hasProperty(CAUGHT)) + _gm->busted(20); + getObject(7)->resetProperty(EXIT | OPENABLE | OPENED); + } + } else if ((verb == ACTION_LOOK) && (obj1._id >= DOOR1) && (obj1._id <= DOOR4)) { + _gm->_state._nameSeen[obj1._id - DOOR1] = true; + return false; + } else if ((verb == ACTION_WALK) && ((obj1._id == PILLAR1) || (obj1._id == PILLAR2))) { + _vm->renderMessage(kStringAxacussBcorridor_1); + _gm->_state._playerHidden = true; + } else + return false; + + return true; +} + +AxacussIntersection::AxacussIntersection(SupernovaEngine *vm, GameManager1 *gm) { + _vm = vm; + _gm = gm; + + _fileNumber = 40; + _id = GUARD; + _shown[0] = kShownTrue; + + _objectState[0] = Object(_id, kStringExit, kStringDefaultDescription, NULLOBJECT, EXIT, 255, 255, 0, CORRIDOR4, 21); + _objectState[1] = Object(_id, kStringCorridor, kStringDefaultDescription, NULLOBJECT, EXIT, 3, 3, 0, CORRIDOR7, 5); + _objectState[2] = Object(_id, kStringDoor, kStringDefaultDescription, DOOR, EXIT | OPENABLE, 1, 1, 6, CORRIDOR9, 3); + _objectState[3] = Object(_id, kStringAxacussan, kStringAxacussanDescription, GUARDIAN, TALK, 0, 0, 0); + _objectState[4] = Object(_id, kStringImage, kStringImageDescription2, NULLOBJECT, NULLTYPE, 2, 2, 0); + _objectState[5] = Object(_id, kStringMastercard, kStringMastercardDescription, MASTERKEYCARD, TAKE | COMBINABLE, 255, 255, 1); + + _dialogsX[0] = kStringDialogX1; + _dialogsX[1] = kStringDialogX2; + _dialogsX[2] = kStringDialogX3; +} + +bool AxacussIntersection::interact(Action verb, Object &obj1, Object &obj2) { + byte rowsX[6] = {1, 1, 1, 0, 0, 0}; + + if (((verb == ACTION_WALK) || (verb == ACTION_OPEN)) && (obj1._id == DOOR) && !isSectionVisible(1)) + _gm->guardShot(); + else if ((verb == ACTION_OPEN) && (obj1._id == DOOR) && !obj1.hasProperty(OPENED)) { + _gm->_rooms[CORRIDOR9]->setSectionVisible(27, true); + _gm->_rooms[CORRIDOR9]->setSectionVisible(28, false); + _gm->_rooms[CORRIDOR9]->getObject(1)->setProperty(OPENED); + return false; + } else if ((verb == ACTION_CLOSE) && (obj1._id == DOOR) && obj1.hasProperty(OPENED)) { + _gm->_rooms[CORRIDOR9]->setSectionVisible(27, false); + _gm->_rooms[CORRIDOR9]->setSectionVisible(28, true); + _gm->_rooms[CORRIDOR9]->getObject(1)->disableProperty(OPENED); + return false; + } else if ((verb == ACTION_TALK) && (obj1._id == GUARDIAN)) { + _gm->dialog(3, rowsX, _dialogsX, 0); + _gm->guardShot(); + } else if ((verb == ACTION_TAKE) && (obj1._id == MASTERKEYCARD)) { + _gm->great(0); + setSectionVisible(7, false); + return false; + } else if ((verb == ACTION_USE) && (Object::combine(obj1, obj2, MAGNET, GUARDIAN) || Object::combine(obj1, obj2, KNIFE, GUARDIAN))) + _vm->renderMessage(kStringArsanoEntrance27); + else + return false; + + return true; +} + +AxacussExit::AxacussExit(SupernovaEngine *vm, GameManager1 *gm) { + _vm = vm; + _gm = gm; + + _fileNumber = 42; + _id = GUARD3; + _shown[0] = kShownTrue; + + _objectState[0] = Object(_id, kStringExit,kStringDefaultDescription,NULLOBJECT,EXIT,255,255,0,CORRIDOR1,22); + _objectState[1] = Object(_id, kStringDoor,kStringDefaultDescription,NULLOBJECT,EXIT|OPENABLE|CLOSED,0,0,0,NULLROOM,20); + _objectState[2] = Object(_id, kStringDoor,kStringDefaultDescription,NULLOBJECT,EXIT|OPENABLE|CLOSED,1,1,0,NULLROOM,15); + _objectState[3] = Object(_id, kStringDoor,kStringDefaultDescription,DOOR,EXIT|OPENABLE,2,2,11,OFFICE_L,0); + _objectState[4] = Object(_id, kStringLamp2,kStringDefaultDescription,LAMP,COMBINABLE,3,3,0); + _objectState[5] = Object(_id, kStringAxacussan,kStringDefaultDescription,GUARDIAN,TALK,5,5,0); + _objectState[6] = Object(_id, kStringImage,kStringGenericDescription5,NULLOBJECT,NULLTYPE,4,4,0); + + _dialogsX[0] = kStringDialogX1; + _dialogsX[1] = kStringDialogX2; + _dialogsX[2] = kStringDialogX3; +} + +bool AxacussExit::interact(Action verb, Object &obj1, Object &obj2) { + byte rowsX[6] = {1, 1, 1, 0, 0, 0}; + + if (((verb == ACTION_WALK) || (verb == ACTION_OPEN)) && (obj1._id == DOOR) && !_gm->_state._powerOff) + _gm->guard3Shot(); + else if ((verb == ACTION_TALK) && (obj1._id == GUARDIAN)) { + _gm->dialog(3, rowsX, _dialogsX,0); + _gm->guard3Shot(); + } else if ((verb == ACTION_USE) && Object::combine(obj1, obj2, LAMP, MAGNET)) { + _gm->_inventory.remove(*_gm->_rooms[CELL]->getObject(7)); + for (int i = 4; i <= 11; i++) { + _vm->renderImage(i); + if (i == 11) + _vm->playSound(kAudioSmash); // 046/4020 + _gm->wait(1); + _vm->renderImage(i + 128); + } + _gm->_state._powerOff = true; + _objectState[5]._click = 255; + + _gm->search(450); + _gm->roomBrightness(); + } else if ((verb == ACTION_USE) && (Object::combine(obj1,obj2,MAGNET,GUARDIAN) || Object::combine(obj1,obj2,KNIFE,GUARDIAN))) + _vm->renderMessage(kStringArsanoEntrance27); + else + return false; + + return true; +} + +AxacussOffice1::AxacussOffice1(SupernovaEngine *vm, GameManager1 *gm) { + _vm = vm; + _gm = gm; + + _fileNumber = 7; + _id = OFFICE_L1; + _shown[0] = kShownTrue; + _shown[2] = kShownTrue; + _shown[7] = kShownTrue; + _shown[9] = kShownTrue; + _shown[16] = kShownTrue; + + _objectState[0] = Object(_id, kStringDoor,kStringDefaultDescription,DOOR,EXIT|OPENABLE|OPENED,6,6,9,BCORRIDOR,9); + _objectState[1] = Object(_id, kStringComputer,kStringDefaultDescription,COMPUTER,COMBINABLE,4,4,0); + _objectState[2] = Object(_id, kStringMoney,kStringMoneyDescription1,MONEY,TAKE,255,255,0); + _objectState[3] = Object(_id, kStringLocker,kStringLockerDescription,LOCKER,OPENABLE|CLOSED,5,5,0); + _objectState[4] = Object(_id, kStringLetter,kStringDefaultDescription,LETTER,UNNECESSARY,3,3,0); +} + +bool AxacussOffice1::interact(Action verb, Object &obj1, Object &obj2) { + Common::String input; + if ((verb == ACTION_CLOSE) && (obj1._id == DOOR) && + obj1.hasProperty(OPENED)) { + _vm->renderImage(_gm->invertSection(9)); + obj1.disableProperty(OPENED); + obj1.setProperty(CLOSED); + _vm->playSound(kAudioDoorClose); + } else if ((verb == ACTION_USE) && Object::combine(obj1, obj2, MASTERKEYCARD, DOOR) && + !getObject(0)->hasProperty(OPENED)) { + _vm->renderImage(9); + getObject(0)->disableProperty(CLOSED); + getObject(0)->setProperty(OPENED); + _vm->playSound(kAudioDoorOpen); + } else if ((verb == ACTION_USE) && Object::combine(obj1, obj2, COMPUTER, MAGNET)) { + _vm->renderImage(4); + setSectionVisible(16, false); + _vm->playSound(kAudioSmash); + } else if ((verb == ACTION_LOOK) && (obj1._id == COMPUTER)) { + if (isSectionVisible(4)) + _vm->renderMessage(kStringBroken); + else + _gm->telomat(0); + } else if (((verb == ACTION_OPEN) || (verb == ACTION_USE)) && + (obj1._id == LOCKER) && + !obj1.hasProperty(OPENED)) { + _vm->renderMessage(kStringAxacussOffice1_1); + _vm->renderBox(160, 70, 70, 10, kColorDarkBlue); + _gm->edit(input, 161, 71, 10); + + _vm->removeMessage(); + if (_gm->_key.keycode != Common::KEYCODE_ESCAPE) { + if (!input.equals("89814")) { + if (input.equals("41898")) + _vm->renderMessage(kStringAxacussOffice1_2); + else + _vm->renderMessage(kStringAxacussOffice1_3); + } else { + _vm->renderImage(6); + setSectionVisible(7, false); + obj1.resetProperty(OPENABLE | OPENED); + if (getObject(2)->hasProperty(TAKE)) { + _vm->renderImage(8); + getObject(2)->_click = 9; + } + _vm->playSound(kAudioDoorOpen); + _gm->great(7); + } + } + } else if ((verb == ACTION_CLOSE) && (obj1._id == LOCKER) && obj1.hasProperty(OPENED)) { + _vm->renderImage(7); + setSectionVisible(6, false); + obj1.resetProperty(OPENABLE | CLOSED); + setSectionVisible(8, false); + getObject(2)->_click = 255; + _vm->playSound(kAudioDoorClose); + } else if ((verb == ACTION_TAKE) && (obj1._id == MONEY)) { + _vm->renderImage(6); + setSectionVisible(8, false); + getObject(2)->_click = 255; + getObject(2)->resetProperty(); + _gm->takeMoney(500); + } else if ((verb == ACTION_LOOK) && (obj1._id == LETTER)) { + g_system->fillScreen(kColorBlack); + _vm->renderText(kStringAxacussOffice1_4, 10, 10, 4); + _vm->renderText(kStringAxacussOffice1_5, 270, 10, 4); + _vm->renderText(kStringAxacussOffice1_6, 10, 60, 4); + _vm->renderText(kStringAxacussOffice1_7, 10, 75, 4); + _vm->renderText(kStringAxacussOffice1_8, 10, 86, 4); + _vm->renderText(kStringAxacussOffice1_9, 10, 97, 4); + _vm->renderText(kStringAxacussOffice1_10, 10, 108, 4); + _vm->renderText(kStringAxacussOffice1_11, 10, 119, 4); + _vm->renderText(kStringAxacussOffice1_12, 10, 130, 4); + _vm->renderText(kStringAxacussOffice1_13, 10, 147, 4); + _vm->renderText(kStringAxacussOffice1_14, 200, 170, 4); + _vm->renderText(kStringAxacussOffice1_15, 200, 181, 4); + _gm->getInput(); + g_system->fillScreen(kColorBlack); + _vm->renderMessage(kStringAxacussOffice1_16); + } else + return false; + + return true; +} + +AxacussOffice2::AxacussOffice2(SupernovaEngine *vm, GameManager1 *gm) { + _vm = vm; + _gm = gm; + + _fileNumber = 7; + _id = OFFICE_L2; + _shown[0] = kShownTrue; + _shown[1] = kShownTrue; + _shown[9] = kShownTrue; + _shown[16] = kShownTrue; + + _objectState[0] = Object(_id, kStringDoor,kStringDefaultDescription,DOOR,EXIT|OPENABLE|OPENED,6,6,9,BCORRIDOR,9); + _objectState[1] = Object(_id, kStringComputer,kStringDefaultDescription,COMPUTER,COMBINABLE,4,4,0); + _objectState[2] = Object(_id, kStringCube,kStringGenericDescription6,NULLOBJECT,NULLTYPE,0,0,0); + _objectState[3] = Object(_id, kStringImage,kStringGenericDescription7,NULLOBJECT,NULLTYPE,1,1,0); + _objectState[4] = Object(_id, kStringStrangeThing,kStringGenericDescription8,NULLOBJECT,UNNECESSARY,2,2,0); +} + +bool AxacussOffice2::interact(Action verb, Object &obj1, Object &obj2) { + if ((verb == ACTION_CLOSE) && (obj1._id == DOOR) && + obj1.hasProperty(OPENED)) { + _vm->renderImage(_gm->invertSection(9)); + obj1.disableProperty(OPENED); + obj1.setProperty(CLOSED); + _vm->playSound(kAudioDoorClose); + } else if ((verb == ACTION_USE) && Object::combine(obj1, obj2, MASTERKEYCARD, DOOR) && !getObject(0)->hasProperty(OPENED)) { + _vm->renderImage(9); + getObject(0)->disableProperty(CLOSED); + getObject(0)->setProperty(OPENED); + _vm->playSound(kAudioDoorOpen); + } else if ((verb == ACTION_USE) && Object::combine(obj1, obj2, COMPUTER, MAGNET)) { + _vm->renderImage(4); + setSectionVisible(16, false); + _vm->playSound(kAudioSmash); + } else if ((verb == ACTION_LOOK) && (obj1._id == COMPUTER)) { + if (isSectionVisible(4)) + _vm->renderMessage(kStringBroken); + else + _gm->telomat(1); + } else + return false; + + return true; +} + +AxacussOffice3::AxacussOffice3(SupernovaEngine *vm, GameManager1 *gm) { + _vm = vm; + _gm = gm; + + _fileNumber = 8; + _id = OFFICE_R1; + _shown[0] = kShownTrue; + _shown[1] = kShownTrue; + _shown[3] = kShownTrue; + + _objectState[0] = Object(_id, kStringDoor,kStringDefaultDescription,DOOR,EXIT|OPENABLE|OPENED,0,0,3,BCORRIDOR,5); + _objectState[1] = Object(_id, kStringComputer,kStringDefaultDescription,COMPUTER,COMBINABLE,4,4,0); + _objectState[2] = Object(_id, kStringImage,kStringImageDescription2,NULLOBJECT,UNNECESSARY,1,1,0); + _objectState[3] = Object(_id, kStringImage,kStringImageDescription2,PAINTING,UNNECESSARY,2,2,0); + _objectState[4] = Object(_id, kStringPlant,kStringDefaultDescription,NULLOBJECT,UNNECESSARY,3,3,0); + _objectState[5] = Object(_id, kNoString,kStringDefaultDescription,MONEY,TAKE|COMBINABLE,255,255,0); +} + +bool AxacussOffice3::interact(Action verb, Object &obj1, Object &obj2) { + if ((verb == ACTION_CLOSE) && (obj1._id == DOOR) && + obj1.hasProperty(OPENED)) { + _vm->renderImage(_gm->invertSection(3)); + obj1.disableProperty(OPENED); + obj1.setProperty(CLOSED); + _vm->playSound(kAudioDoorClose); + } else if ((verb == ACTION_USE) && Object::combine(obj1, obj2, MASTERKEYCARD, DOOR) && + !getObject(0)->hasProperty(OPENED)) { + _vm->renderImage(3); + getObject(0)->disableProperty(CLOSED); + getObject(0)->setProperty(OPENED); + _vm->playSound(kAudioDoorOpen); + } else if ((verb == ACTION_USE) && Object::combine(obj1, obj2, COMPUTER, MAGNET)) { + _vm->renderImage(4); + _vm->playSound(kAudioSmash); + } else if ((verb == ACTION_LOOK) && (obj1._id == COMPUTER)) { + if (isSectionVisible(4)) + _vm->renderMessage(kStringBroken); + else + _gm->telomat(2); + } else if ((verb == ACTION_LOOK) && (obj1._id == PAINTING)) { + _vm->renderMessage(kStringAxacussOffice3_1); + _gm->takeMoney(300); + obj1._id = NULLOBJECT; + } else + return false; + + return true; +} + +AxacussOffice4::AxacussOffice4(SupernovaEngine *vm, GameManager1 *gm) { + _vm = vm; + _gm = gm; + + _fileNumber = 8; + _id = OFFICE_R2; + _shown[0] = kShownTrue; + _shown[2] = kShownTrue; + _shown[3] = kShownTrue; + + _objectState[0] = Object(_id, kStringDoor,kStringDefaultDescription,DOOR,EXIT|OPENABLE|OPENED,0,0,3,BCORRIDOR,5); + _objectState[1] = Object(_id, kStringComputer,kStringDefaultDescription,COMPUTER,COMBINABLE,4,4,0); + _objectState[2] = Object(_id, kStringStatue,kStringStatueDescription,NULLOBJECT,UNNECESSARY,6,6,0); + _objectState[3] = Object(_id, kStringPlant,kStringPlantDescription,NULLOBJECT,UNNECESSARY,5,5,0); +} + +bool AxacussOffice4::interact(Action verb, Object &obj1, Object &obj2) { + if ((verb == ACTION_CLOSE) && (obj1._id == DOOR) && obj1.hasProperty(OPENED)) { + _vm->renderImage(_gm->invertSection(3)); + obj1.disableProperty(OPENED); + obj1.setProperty(CLOSED); + _vm->playSound(kAudioDoorClose); + } else if ((verb == ACTION_USE) && Object::combine(obj1, obj2, MASTERKEYCARD, DOOR) && + !getObject(0)->hasProperty(OPENED)) { + _vm->renderImage(3); + getObject(0)->disableProperty(CLOSED); + getObject(0)->setProperty(OPENED); + _vm->playSound(kAudioDoorOpen); + } else if ((verb == ACTION_USE) && Object::combine(obj1, obj2, COMPUTER, MAGNET)) { + _vm->renderImage(4); + _vm->playSound(kAudioSmash); + } else if ((verb == ACTION_LOOK) && (obj1._id == COMPUTER)) { + if (isSectionVisible(4)) + _vm->renderMessage(kStringBroken); + else + _gm->telomat(3); + } else + return false; + + return true; +} + +AxacussOffice5::AxacussOffice5(SupernovaEngine *vm, GameManager1 *gm) { + _vm = vm; + _gm = gm; + + _fileNumber = 7; + _id = OFFICE_L; + _shown[0] = kShownTrue; + _shown[3] = kShownTrue; + _shown[5] = kShownTrue; + _shown[17] = kShownTrue; + + _objectState[0] = Object(_id, kStringDoor,kStringDefaultDescription,DOOR,EXIT|OPENABLE|OPENED,6,6,17,GUARD3,9); + _objectState[1] = Object(_id, kStringComputer,kStringComputerDescription,COMPUTER,COMBINABLE,4,4,0); + _objectState[2] = Object(_id, kStringGraffiti,kStringGraffitiDescription,NULLOBJECT,NULLTYPE,7,7,0); + _objectState[3] = Object(_id, kStringMoney,kStringMoneyDescription2,MONEY,TAKE,8,8,0); +} + +void AxacussOffice5::onEntrance() { + _gm->great(5); +} + +bool AxacussOffice5::interact(Action verb, Object &obj1, Object &obj2) { + if ((verb == ACTION_USE) && Object::combine(obj1, obj2, COMPUTER, MAGNET)) { + _vm->renderImage(4); + _vm->playSound(kAudioSmash); + } else if ((verb == ACTION_TAKE) && (obj1._id == MONEY)) { + _vm->renderImage(_gm->invertSection(5)); + obj1._click = 255; + _gm->takeMoney(350); + } else + return false; + + return true; +} + +AxacussElevator::AxacussElevator(SupernovaEngine *vm, GameManager1 *gm) { + _vm = vm; + _gm = gm; + + _fileNumber = 3; + _id = ELEVATOR; + _shown[0] = kShownTrue; + + _objectState[0] = Object(_id, kStringButton,kStringDefaultDescription,BUTTON1,PRESS,0,0,0); + _objectState[1] = Object(_id, kStringButton,kStringDefaultDescription,BUTTON2,PRESS,1,1,0); + _objectState[2] = Object(_id, kStringExit,kStringDefaultDescription,DOOR,EXIT,255,255,0,NULLROOM,22); + _objectState[3] = Object(_id, kStringJungle,kStringJungleDescription,JUNGLE,NULLTYPE,255,255,0,STATION,2); +} + +bool AxacussElevator::interact(Action verb, Object &obj1, Object &obj2) { + if ((verb == ACTION_WALK) && (obj1._id == DOOR)) { + g_system->fillScreen(kColorBlack); + _vm->setCurrentImage(41); + _vm->renderImage(0); + _vm->paletteBrightness(); + _gm->reply(kStringAxacussElevator_1, 1, 1 + 128); + _gm->say(kStringAxacussElevator_2); + g_system->fillScreen(kColorBlack); + } else if ((verb == ACTION_PRESS) && (obj1._id == BUTTON1)) { + if (!isSectionVisible(3)) { + _vm->renderImage(1); + getObject(2)->resetProperty(); + _vm->playSound(kAudioSlideDoor); + _gm->wait(25); + for (int i = 3; i <= 7; i++) { + _gm->wait(2); + _vm->renderImage(i); + } + getObject(3)->resetProperty(EXIT); + getObject(3)->_click = 2; + _vm->renderImage(_gm->invertSection(1)); + if (!(_gm->_state._greatFlag & 0x4000)) { + _vm->playSound(kAudioFoundLocation); + _gm->_state._greatFlag |= 0x4000; + } + } + } else if ((verb == ACTION_PRESS) && (obj1._id == BUTTON2)) { + if (isSectionVisible(3)) { + _vm->renderImage(2); + getObject(3)->resetProperty(); + getObject(3)->_click = 255; + _vm->playSound(kAudioSlideDoor); + for (int i = 7; i >= 3; i--) { + _gm->wait(2); + _vm->renderImage(_gm->invertSection(i)); + } + _gm->wait(25); + _vm->playSound(kAudioSlideDoor); + getObject(2)->resetProperty(EXIT); + _vm->renderImage(_gm->invertSection(2)); + } + } else if ((verb == ACTION_WALK) && (obj1._id == JUNGLE)) { + _vm->paletteFadeOut(); + g_system->fillScreen(kColorBlack); + _vm->_screen->setGuiBrightness(255); + _vm->paletteBrightness(); + _vm->renderMessage(kStringAxacussElevator_3); + _gm->waitOnInput(_gm->_messageDuration); + _vm->removeMessage(); + _vm->_screen->setGuiBrightness(0); + _vm->paletteBrightness(); + _gm->_time += ticksToMsec(125000); // 2 hours + _gm->_state._alarmOn = (_gm->_state._timeAlarm > _gm->_time); + return false; + } else + return false; + + return true; +} + +AxacussStation::AxacussStation(SupernovaEngine *vm, GameManager1 *gm) { + _vm = vm; + _gm = gm; + + _fileNumber = 5; + _id = STATION; + _shown[0] = kShownTrue; + _objectState[0] = Object(_id, kStringSign,kStringDefaultDescription,STATION_SIGN,NULLTYPE,0,0,0); + _objectState[1] = Object(_id, kStringDoor,kStringDefaultDescription,DOOR,EXIT|OPENABLE|CLOSED,1,1,0,NULLROOM,7); +} + +bool AxacussStation::interact(Action verb, Object &obj1, Object &obj2) { + if ((verb == ACTION_LOOK) && (obj1._id == STATION_SIGN)) { + _gm->changeRoom(SIGN); + } else if ((verb == ACTION_WALK) && (obj1._id == DOOR) && obj1.hasProperty(OPENED)) { + _gm->great(0); + _gm->_guiEnabled = false; + _vm->paletteFadeOut(); + _vm->_system->fillScreen(kColorBlack); + _gm->changeRoom(OUTRO); + } else + return false; + + return true; +} + +AxacussSign::AxacussSign(SupernovaEngine *vm, GameManager1 *gm) { + _vm = vm; + _gm = gm; + + _fileNumber = 32; + _id = SIGN; + _shown[0] = kShownTrue; + _shown[1] = kShownTrue; + + _objectState[0] = Object(_id, kStringExit,kStringDefaultDescription,NULLOBJECT,EXIT,255,255,0,STATION,22); + _objectState[1] = Object(_id, kStringSlot,kStringDefaultDescription,STATION_SLOT,COMBINABLE,0,0,0); +} + +bool AxacussSign::interact(Action verb, Object &obj1, Object &obj2) { + if ((verb == ACTION_USE) && Object::combine(obj1, obj2, STATION_SLOT, MONEY) && + isSectionVisible(1)) { + _gm->takeMoney(-180); + _vm->renderImage(2); + setSectionVisible(1, false); + _gm->_state._eventTime = _gm->_time + ticksToMsec(600); + _gm->_state._eventCallback = kTaxiFn; + return true; + } + return false; +} + + +Outro::Outro(SupernovaEngine *vm, GameManager1 *gm) { + _vm = vm; + _gm = gm; + + _fileNumber = -1; + _id = OUTRO; + _shown[0] = kShownFalse; + + _outroText = + _vm->getGameString(kStringOutro1) + '\0' + + _vm->getGameString(kStringOutro2) + '\0' + + _vm->getGameString(kStringOutro3) + '\0' + + _vm->getGameString(kStringOutro4) + '\0' + + _vm->getGameString(kStringOutro5) + '\0' + + _vm->getGameString(kStringOutro6) + '\0' + + _vm->getGameString(kStringOutro7) + '\0' + + _vm->getGameString(kStringOutro8) + '\0' + + _vm->getGameString(kStringOutro9) + '\0' + + _vm->getGameString(kStringOutro10) + '\0' + + _vm->getGameString(kStringOutro11) + '\0' + + _vm->getGameString(kStringOutro12) + '\0' + + _vm->getGameString(kStringOutro13) + '\0' + + _vm->getGameString(kStringOutro14) + '\0'; +} + +void Outro::onEntrance() { + _vm->setCurrentImage(35); + _vm->renderImage(0); + _vm->renderImage(1); + _vm->paletteFadeIn(); + _gm->wait(10); + for (int i = 8; i <= 21; i++) { + _vm->renderImage(i); + _gm->wait(2); + _vm->renderImage(_gm->invertSection(i)); + } + _gm->wait(18); + _vm->renderImage(_gm->invertSection(1)); + for (int i = 2; i <= 7; i++) { + _vm->renderImage(i); + _gm->wait(3); + _vm->renderImage(_gm->invertSection(i)); + } + + _vm->playSound(kMusicOutro); + Marquee marquee(_vm->_screen, Marquee::kMarqueeOutro, _outroText.c_str()); + while (!_vm->shouldQuit()) { + _gm->updateEvents(); + marquee.renderCharacter(); + if (_gm->_mouseClicked || _gm->_keyPressed) + break; + g_system->updateScreen(); + g_system->delayMillis(_vm->_delay); + } + _vm->paletteFadeOut(); + _vm->setCurrentImage(55); + _vm->renderImage(0); + _vm->paletteFadeIn(); + _gm->getInput(); + _vm->paletteFadeOut(); + _vm->_screen->setViewportBrightness(1); + + Common::Event event; + event.type = Common::EVENT_RTL; + _vm->getEventManager()->pushEvent(event); +} + +void Outro::animation() { +} + +void Outro::animate(int filenumber, int section1, int section2, int duration) { + _vm->setCurrentImage(filenumber); + while (duration) { + _vm->renderImage(section1); + _gm->wait(2); + _vm->renderImage(section2); + _gm->wait(2); + --duration; + } +} + +void Outro::animate(int filenumber, int section1, int section2, int duration, + MessagePosition position, const char *text) { + _vm->renderMessage(text, position); + int delay = (Common::strnlen(text, 512) + 20) * (10 - duration) * _vm->_textSpeed / 400; + _vm->setCurrentImage(filenumber); + while (delay) { + if (section1) + _vm->renderImage(section1); + _gm->wait(2); + if (section2) + _vm->renderImage(section2); + _gm->wait(2); + --delay; + } + _vm->removeMessage(); +} + +void Outro::animate(int filenumber, int section1, int section2, int section3, int section4, + int duration, MessagePosition position, const char *text) { + _vm->renderMessage(text, position); + if (duration == 0) + duration = (Common::strnlen(text, 512) + 20) * _vm->_textSpeed / 40; + + _vm->setCurrentImage(filenumber); + while(duration) { + _vm->renderImage(section1); + _vm->renderImage(section3); + _gm->wait(2); + _vm->renderImage(section2); + _vm->renderImage(section4); + _gm->wait(2); + duration--; + } + _vm->removeMessage(); +} + +} diff --git a/engines/supernova/supernova1/rooms.h b/engines/supernova/supernova1/rooms.h new file mode 100644 index 0000000000..c49e8356c9 --- /dev/null +++ b/engines/supernova/supernova1/rooms.h @@ -0,0 +1,486 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef SUPERNOVA_ROOMS_H +#define SUPERNOVA_ROOMS_H + +#include "common/str.h" + +#include "supernova/msn_def.h" +#include "supernova/room.h" + +namespace Common { +class ReadStream; +class WriteStream; +} + +namespace Supernova { + +class GameManager1; +class SupernovaEngine; + +// Room 0 +class Intro : public Room { +public: + Intro(SupernovaEngine *vm, GameManager1 *gm); + virtual void onEntrance(); + +private: + bool animate(int section1, int section2, int duration); + bool animate(int section1, int section2, int duration, MessagePosition position, + StringId text); + bool animate(int section1, int section2, int section3, int section4, int duration, + MessagePosition position, StringId text); + + void titleScreen(); + void titleFadeIn(); + void cutscene(); + void leaveCutscene(); + + bool _shouldExit; + Common::String _introText; +}; + +// Spaceship +class ShipCorridor : public Room { +public: + ShipCorridor(SupernovaEngine *vm, GameManager1 *gm); + + virtual bool interact(Action verb, Object &obj1, Object &obj2); +}; + +class ShipHall: public Room { +public: + ShipHall(SupernovaEngine *vm, GameManager1 *gm); + + virtual bool interact(Action verb, Object &obj1, Object &obj2); +}; + +class ShipSleepCabin: public Room { +public: + ShipSleepCabin(SupernovaEngine *vm, GameManager1 *gm); + + virtual bool interact(Action verb, Object &obj1, Object &obj2); + virtual void animation(); + virtual void onEntrance(); + +private: + byte _color; +}; + +class ShipCockpit : public Room { +public: + ShipCockpit(SupernovaEngine *vm, GameManager1 *gm); + + virtual bool interact(Action verb, Object &obj1, Object &obj2); + virtual void animation(); + virtual void onEntrance(); + +private: + byte _color; +}; + +class ShipCabinL1: public Room { +public: + ShipCabinL1(SupernovaEngine *vm, GameManager1 *gm); +}; + +class ShipCabinL2 : public Room { +public: + ShipCabinL2(SupernovaEngine *vm, GameManager1 *gm); + + virtual bool interact(Action verb, Object &obj1, Object &obj2); +}; + +class ShipCabinL3 : public Room { +public: + ShipCabinL3(SupernovaEngine *vm, GameManager1 *gm); + + virtual bool interact(Action verb, Object &obj1, Object &obj2); +}; + +class ShipCabinR1 : public Room { +public: + ShipCabinR1(SupernovaEngine *vm, GameManager1 *gm); +}; + +class ShipCabinR2 : public Room { +public: + ShipCabinR2(SupernovaEngine *vm, GameManager1 *gm); +}; + +class ShipCabinR3 : public Room { +public: + ShipCabinR3(SupernovaEngine *vm, GameManager1 *gm); + + virtual bool interact(Action verb, Object &obj1, Object &obj2); + virtual void onEntrance(); +}; + +class ShipCabinBathroom : public Room { +public: + ShipCabinBathroom(SupernovaEngine *vm, GameManager1 *gm); +}; + +class ShipAirlock : public Room { +public: + ShipAirlock(SupernovaEngine *vm, GameManager1 *gm); + + virtual bool interact(Action verb, Object &obj1, Object &obj2); + virtual void onEntrance(); +}; + +class ShipHold : public Room { +public: + ShipHold(SupernovaEngine *vm, GameManager1 *gm); + + virtual bool interact(Action verb, Object &obj1, Object &obj2); + virtual void onEntrance(); +}; + +class ShipLandingModule : public Room { +public: + ShipLandingModule(SupernovaEngine *vm, GameManager1 *gm); + + virtual bool interact(Action verb, Object &obj1, Object &obj2); +}; + +class ShipGenerator : public Room { +public: + ShipGenerator(SupernovaEngine *vm, GameManager1 *gm); + + virtual bool interact(Action verb, Object &obj1, Object &obj2); +}; + +class ShipOuterSpace : public Room { +public: + ShipOuterSpace(SupernovaEngine *vm, GameManager1 *gm); +}; + + +// Arsano +class ArsanoRocks : public Room { +public: + ArsanoRocks(SupernovaEngine *vm, GameManager1 *gm); + + virtual void onEntrance(); + virtual bool interact(Action verb, Object &obj1, Object &obj2); +}; + +class ArsanoCave : public Room { +public: + ArsanoCave(SupernovaEngine *vm, GameManager1 *gm); +}; + +class ArsanoMeetup : public Room { +public: + ArsanoMeetup(SupernovaEngine *vm, GameManager1 *gm); + + virtual void onEntrance(); + virtual void animation(); + virtual bool interact(Action verb, Object &obj1, Object &obj2); + +private: + byte _sign; + byte _beacon; +}; + +class ArsanoEntrance : public Room { +public: + ArsanoEntrance(SupernovaEngine *vm, GameManager1 *gm); + + virtual bool interact(Action verb, Object &obj1, Object &obj2); + virtual void animation(); + +private: + StringId _dialog1[5]; + StringId _dialog2[5]; + StringId _dialog3[5]; + byte _eyewitness; +}; + +class ArsanoRemaining : public Room { +public: + ArsanoRemaining(SupernovaEngine *vm, GameManager1 *gm); + + virtual void animation(); + +private: + bool _chewing; + int _i; +}; + +class ArsanoRoger : public Room { +public: + ArsanoRoger(SupernovaEngine *vm, GameManager1 *gm); + + virtual void animation(); + virtual void onEntrance(); + virtual bool interact(Action verb, Object &obj1, Object &obj2); + +private: + StringId _dialog1[4]; + byte _eyewitness; + byte _hands; +}; + +class ArsanoGlider : public Room { +public: + ArsanoGlider(SupernovaEngine *vm, GameManager1 *gm); + + virtual void animation(); + virtual bool interact(Action verb, Object &obj1, Object &obj2); + +private: + byte _sinus; +}; + +class ArsanoMeetup2 : public Room { +public: + ArsanoMeetup2(SupernovaEngine *vm, GameManager1 *gm); + + virtual void onEntrance(); + virtual bool interact(Action verb, Object &obj1, Object &obj2); + + void shipStart(); + +private: + // TODO: change to 6, fix initialization + StringId _dialog1[2]; + StringId _dialog2[2]; + StringId _dialog3[4]; + StringId _dialog4[3]; + + // FIXME: Remove following unused bool variables? + //bool _found; + //bool _flug; +}; + +class ArsanoMeetup3 : public Room { +public: + ArsanoMeetup3(SupernovaEngine *vm, GameManager1 *gm); + + virtual bool interact(Action verb, Object &obj1, Object &obj2); + +private: + StringId _dialog2[4]; + StringId _dialog3[2]; + + // TODO: Hack, to be move away and renamed when the other uses are found + StringId _dialogsX[6]; +}; + + +// Axacuss +class AxacussCell : public Room { +public: + AxacussCell(SupernovaEngine *vm, GameManager1 *gm); + + virtual bool interact(Action verb, Object &obj1, Object &obj2); + virtual void animation(); + virtual void onEntrance(); +}; + +class AxacussCorridor1 : public Room { +public: + AxacussCorridor1(SupernovaEngine *vm, GameManager1 *gm); + + virtual void onEntrance(); +}; + +class AxacussCorridor2 : public Room { +public: + AxacussCorridor2(SupernovaEngine *vm, GameManager1 *gm); + + virtual void onEntrance(); +}; + +class AxacussCorridor3 : public Room { +public: + AxacussCorridor3(SupernovaEngine *vm, GameManager1 *gm); + + virtual void onEntrance(); +}; + +class AxacussCorridor4 : public Room { +public: + AxacussCorridor4(SupernovaEngine *vm, GameManager1 *gm); + + virtual void onEntrance(); + virtual void animation(); + virtual bool interact(Action verb, Object &obj1, Object &obj2); +}; + +class AxacussCorridor5 : public Room { +public: + AxacussCorridor5(SupernovaEngine *vm, GameManager1 *gm); + + virtual void onEntrance(); + virtual bool interact(Action verb, Object &obj1, Object &obj2); + +private: + void stopInteract(int sum); + bool handleMoneyDialog(); + + // TODO: Change to 6, or change struct, and fix initialization + StringId _dialog1[2]; + StringId _dialog2[2]; + StringId _dialog3[4]; + + byte _rows[6]; +}; + +class AxacussCorridor6 : public Room { +public: + AxacussCorridor6(SupernovaEngine *vm, GameManager1 *gm); + + virtual void onEntrance(); + virtual bool interact(Action verb, Object &obj1, Object &obj2); +}; + +class AxacussCorridor7 : public Room { +public: + AxacussCorridor7(SupernovaEngine *vm, GameManager1 *gm); + + virtual void onEntrance(); +}; + +class AxacussCorridor8 : public Room { +public: + AxacussCorridor8(SupernovaEngine *vm, GameManager1 *gm); + + virtual void onEntrance(); + virtual bool interact(Action verb, Object &obj1, Object &obj2); +}; + +class AxacussCorridor9 : public Room { +public: + AxacussCorridor9(SupernovaEngine *vm, GameManager1 *gm); + + virtual void onEntrance(); + virtual bool interact(Action verb, Object &obj1, Object &obj2); +}; + +class AxacussBcorridor : public Room { +public: + AxacussBcorridor(SupernovaEngine *vm, GameManager1 *gm); + + virtual void onEntrance(); + virtual bool interact(Action verb, Object &obj1, Object &obj2); +}; + +class AxacussIntersection : public Room { +public: + AxacussIntersection(SupernovaEngine *vm, GameManager1 *gm); + + virtual bool interact(Action verb, Object &obj1, Object &obj2); + +private: + StringId _dialogsX[6]; +}; + +class AxacussExit : public Room { +public: + AxacussExit(SupernovaEngine *vm, GameManager1 *gm); + + virtual bool interact(Action verb, Object &obj1, Object &obj2); + +private: + StringId _dialogsX[6]; +}; + +class AxacussOffice1 : public Room { +public: + AxacussOffice1(SupernovaEngine *vm, GameManager1 *gm); + + virtual bool interact(Action verb, Object &obj1, Object &obj2); +}; + +class AxacussOffice2 : public Room { +public: + AxacussOffice2(SupernovaEngine *vm, GameManager1 *gm); + + virtual bool interact(Action verb, Object &obj1, Object &obj2); +}; + +class AxacussOffice3 : public Room { +public: + AxacussOffice3(SupernovaEngine *vm, GameManager1 *gm); + + virtual bool interact(Action verb, Object &obj1, Object &obj2); +}; + +class AxacussOffice4 : public Room { +public: + AxacussOffice4(SupernovaEngine *vm, GameManager1 *gm); + + virtual bool interact(Action verb, Object &obj1, Object &obj2); +}; + +class AxacussOffice5 : public Room { +public: + AxacussOffice5(SupernovaEngine *vm, GameManager1 *gm); + + virtual void onEntrance(); + virtual bool interact(Action verb, Object &obj1, Object &obj2); +}; + +class AxacussElevator : public Room { +public: + AxacussElevator(SupernovaEngine *vm, GameManager1 *gm); + + virtual bool interact(Action verb, Object &obj1, Object &obj2); +}; + +class AxacussStation : public Room { +public: + AxacussStation(SupernovaEngine *vm, GameManager1 *gm); + + virtual bool interact(Action verb, Object &obj1, Object &obj2); +}; + +class AxacussSign : public Room { +public: + AxacussSign(SupernovaEngine *vm, GameManager1 *gm); + + virtual bool interact(Action verb, Object &obj1, Object &obj2); +}; + +class Outro : public Room { +public: + Outro(SupernovaEngine *vm, GameManager1 *gm); + + virtual void onEntrance(); + virtual void animation(); + +private: + void animate(int filenumber, int section1, int section2, int duration); + void animate(int filenumber, int section1, int section2, int duration, MessagePosition position, + const char *text); + void animate(int filenumber, int section1, int section2, int section3, int section4, int duration, + MessagePosition position, const char *text); + + Common::String _outroText; +}; + +} +#endif // SUPERNOVA_ROOMS_H diff --git a/engines/supernova/supernova1/state.cpp b/engines/supernova/supernova1/state.cpp new file mode 100644 index 0000000000..fff5ad7993 --- /dev/null +++ b/engines/supernova/supernova1/state.cpp @@ -0,0 +1,1623 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "common/system.h" +#include "graphics/cursorman.h" +#include "graphics/palette.h" +#include "gui/message.h" + +#include "supernova/screen.h" +#include "supernova/supernova.h" +#include "supernova/supernova1/state.h" + +namespace Supernova { + +bool GameManager1::serialize(Common::WriteStream *out) { + if (out->err()) + return false; + + // GameState + out->writeSint32LE(_time); + out->writeSint32LE(_state._timeSleep); + out->writeSint32LE(_state._timeAlarm); + out->writeSint32LE(_state._eventTime); + out->writeSint32LE(_state._eventCallback); + out->writeSint32LE(_state._arrivalDaysLeft); + out->writeSint32LE(_state._shipEnergyDaysLeft); + out->writeSint32LE(_state._landingModuleEnergyDaysLeft); + out->writeUint16LE(_state._greatFlag); + out->writeSint16LE(_state._timeRobot); + out->writeSint16LE(_state._money); + out->writeByte(_state._coins); + out->writeByte(_state._shoes); + out->writeByte(_state._origin); + out->writeByte(_state._destination); + out->writeByte(_state._language); + out->writeByte(_state._corridorSearch); + out->writeByte(_state._alarmOn); + out->writeByte(_state._terminalStripConnected); + out->writeByte(_state._terminalStripWire); + out->writeByte(_state._cableConnected); + out->writeByte(_state._powerOff); + out->writeByte(_state._dream); + for (int i = 0; i < 4; i++) + out->writeByte(_state._nameSeen[i]); + out->writeByte(_state._playerHidden); + + // Inventory + out->writeSint32LE(_inventory.getSize()); + out->writeSint32LE(_inventoryScroll); + for (int i = 0; i < _inventory.getSize(); ++i) { + Object *objectStateBegin = _rooms[_inventory.get(i)->_roomId]->getObject(0); + byte objectIndex = _inventory.get(i) - objectStateBegin; + out->writeSint32LE(_inventory.get(i)->_roomId); + out->writeSint32LE(objectIndex); + } + + // Rooms + out->writeByte(_currentRoom->getId()); + for (int i = 0; i < NUMROOMS; ++i) { + _rooms[i]->serialize(out); + } + + return !out->err(); +} + +bool GameManager1::deserialize(Common::ReadStream *in, int version) { + if (in->err()) + return false; + + // GameState + _time = in->readSint32LE(); + _state._timeSleep = in->readSint32LE(); + _state._timeAlarm = in->readSint32LE(); + _state._eventTime = in->readSint32LE(); + if (version >= 4) + _state._eventCallback = (EventFunction)in->readSint32LE(); + else + _state._eventCallback = kNoFn; + _state._arrivalDaysLeft = in->readSint32LE(); + _state._shipEnergyDaysLeft = in->readSint32LE(); + _state._landingModuleEnergyDaysLeft = in->readSint32LE(); + _state._greatFlag = in->readUint16LE(); + _state._timeRobot = in->readSint16LE(); + _state._money = in->readSint16LE(); + _vm->setGameString(kStringInventoryMoney, Common::String::format("%d Xa", _state._money)); + _state._coins = in->readByte(); + _state._shoes = in->readByte(); + if (version >= 6) + _state._origin = in->readByte(); + else + _state._origin = 0; + _state._destination = in->readByte(); + _state._language = in->readByte(); + _state._corridorSearch = in->readByte(); + _state._alarmOn = in->readByte(); + _state._terminalStripConnected = in->readByte(); + _state._terminalStripWire = in->readByte(); + _state._cableConnected = in->readByte(); + _state._powerOff = in->readByte(); + _state._dream = in->readByte(); + + for (int i = 0; i < 4; i++) { + if (version >= 7) + _state._nameSeen[i] = in->readByte(); + else + _state._nameSeen[i] = false; + } + + if (version >= 8) + _state._playerHidden = in->readByte(); + else + _state._playerHidden = false; + + _oldTime = g_system->getMillis(); + + // Inventory + int inventorySize = in->readSint32LE(); + _inventoryScroll = in->readSint32LE(); + _inventory.clear(); + for (int i = 0; i < inventorySize; ++i) { + RoomId objectRoom = static_cast(in->readSint32LE()); + int objectIndex = in->readSint32LE(); + _inventory.add(*_rooms[objectRoom]->getObject(objectIndex)); + } + + // Rooms + RoomId curRoomId = static_cast(in->readByte()); + for (int i = 0; i < NUMROOMS; ++i) { + _rooms[i]->deserialize(in, version); + } + changeRoom(curRoomId); + + // Some additional variables + _guiEnabled = true; + _animationEnabled = true; + + return !in->err(); +} + +// Used by Look Watch (when it's fixed). Do not remove. +static Common::String timeToString(int msec) { + char s[9] = " 0:00:00"; + msec /= 1000; + s[7] = msec % 10 + '0'; + msec /= 10; + s[6] = msec % 6 + '0'; + msec /= 6; + s[4] = msec % 10 + '0'; + msec /= 10; + s[3] = msec % 6 + '0'; + msec /= 6; + s[1] = msec % 10 + '0'; + msec /= 10; + if (msec) + s[0] = msec + '0'; + + return Common::String(s); +} + +GameManager1::GameManager1(SupernovaEngine *vm, Sound *sound) + : GameManager(vm, sound) { + initRooms(); + changeRoom(INTRO); + initState(); +} + +GameManager1::~GameManager1() { + destroyRooms(); +} + +void GameManager1::destroyRooms() { + delete _rooms[INTRO]; + delete _rooms[CORRIDOR]; + delete _rooms[HALL]; + delete _rooms[SLEEP]; + delete _rooms[COCKPIT]; + delete _rooms[AIRLOCK]; + delete _rooms[HOLD]; + delete _rooms[LANDINGMODULE]; + delete _rooms[GENERATOR]; + delete _rooms[OUTSIDE]; + delete _rooms[CABIN_R1]; + delete _rooms[CABIN_R2]; + delete _rooms[CABIN_R3]; + delete _rooms[CABIN_L1]; + delete _rooms[CABIN_L2]; + delete _rooms[CABIN_L3]; + delete _rooms[BATHROOM]; + + delete _rooms[ROCKS]; + delete _rooms[CAVE]; + delete _rooms[MEETUP]; + delete _rooms[ENTRANCE]; + delete _rooms[REST]; + delete _rooms[ROGER]; + delete _rooms[GLIDER]; + delete _rooms[MEETUP2]; + delete _rooms[MEETUP3]; + + delete _rooms[CELL]; + delete _rooms[CORRIDOR1]; + delete _rooms[CORRIDOR2]; + delete _rooms[CORRIDOR3]; + delete _rooms[CORRIDOR4]; + delete _rooms[CORRIDOR5]; + delete _rooms[CORRIDOR6]; + delete _rooms[CORRIDOR7]; + delete _rooms[CORRIDOR8]; + delete _rooms[CORRIDOR9]; + delete _rooms[BCORRIDOR]; + delete _rooms[GUARD]; + delete _rooms[GUARD3]; + delete _rooms[OFFICE_L1]; + delete _rooms[OFFICE_L2]; + delete _rooms[OFFICE_R1]; + delete _rooms[OFFICE_R2]; + delete _rooms[OFFICE_L]; + delete _rooms[ELEVATOR]; + delete _rooms[STATION]; + delete _rooms[SIGN]; + delete _rooms[OUTRO]; +} + +void GameManager1::initState() { + _currentInputObject = &_nullObject; + _inputObject[0] = &_nullObject; + _inputObject[1] = &_nullObject; + _inputVerb = ACTION_WALK; + _processInput = false; + _guiEnabled = true; + _animationEnabled = true; + _roomBrightness = 255; + _mouseClicked = false; + _keyPressed = false; + _mouseX = -1; + _mouseY = -1; + _mouseField = -1; + _inventoryScroll = 0; + _oldTime = g_system->getMillis(); + _timerPaused = 0; + _timePaused = false; + _messageDuration = 0; + _animationTimer = 0; + + _currentSentence = -1; + for (int i = 0 ; i < 6 ; ++i) { + _sentenceNumber[i] = -1; + _texts[i] = kNoString; + _rows[i] = 0; + _rowsStart[i] = 0; + } + + _time = ticksToMsec(916364); // 2 pm + _state._timeSleep = 0; + _state._timeAlarm = ticksToMsec(458182); // 7 am + _state._eventTime = kMaxTimerValue; + _state._eventCallback = kNoFn; + _state._arrivalDaysLeft = 2840; + _state._shipEnergyDaysLeft = 2135; + _state._landingModuleEnergyDaysLeft = 923; + _state._greatFlag = 0; + _state._timeRobot = 0; + _state._money = 0; + _state._coins = 0; + _state._shoes = 0; + _state._origin = 0; + _state._destination = 255; + _state._language = 0; + _state._corridorSearch = false; + _state._alarmOn = false; + _state._terminalStripConnected = false; + _state._terminalStripWire = false; + _state._cableConnected = false; + _state._powerOff = false; + _state._dream = false; + + _prevImgId = 0; +} + +void GameManager1::initRooms() { + _rooms[INTRO] = new Intro(_vm, this); + _rooms[CORRIDOR] = new ShipCorridor(_vm, this); + _rooms[HALL] = new ShipHall(_vm, this); + _rooms[SLEEP] = new ShipSleepCabin(_vm, this); + _rooms[COCKPIT] = new ShipCockpit(_vm, this); + _rooms[AIRLOCK] = new ShipAirlock(_vm, this); + _rooms[HOLD] = new ShipHold(_vm, this); + _rooms[LANDINGMODULE] = new ShipLandingModule(_vm, this); + _rooms[GENERATOR] = new ShipGenerator(_vm, this); + _rooms[OUTSIDE] = new ShipOuterSpace(_vm, this); + _rooms[CABIN_R1] = new ShipCabinR1(_vm, this); + _rooms[CABIN_R2] = new ShipCabinR2(_vm, this); + _rooms[CABIN_R3] = new ShipCabinR3(_vm, this); + _rooms[CABIN_L1] = new ShipCabinL1(_vm, this); + _rooms[CABIN_L2] = new ShipCabinL2(_vm, this); + _rooms[CABIN_L3] = new ShipCabinL3(_vm, this); + _rooms[BATHROOM] = new ShipCabinBathroom(_vm, this); + + _rooms[ROCKS] = new ArsanoRocks(_vm, this); + _rooms[CAVE] = new ArsanoCave(_vm, this); + _rooms[MEETUP] = new ArsanoMeetup(_vm, this); + _rooms[ENTRANCE] = new ArsanoEntrance(_vm, this); + _rooms[REST] = new ArsanoRemaining(_vm, this); + _rooms[ROGER] = new ArsanoRoger(_vm, this); + _rooms[GLIDER] = new ArsanoGlider(_vm, this); + _rooms[MEETUP2] = new ArsanoMeetup2(_vm, this); + _rooms[MEETUP3] = new ArsanoMeetup3(_vm, this); + + _rooms[CELL] = new AxacussCell(_vm, this); + _rooms[CORRIDOR1] = new AxacussCorridor1(_vm, this); + _rooms[CORRIDOR2] = new AxacussCorridor2(_vm, this); + _rooms[CORRIDOR3] = new AxacussCorridor3(_vm, this); + _rooms[CORRIDOR4] = new AxacussCorridor4(_vm, this); + _rooms[CORRIDOR5] = new AxacussCorridor5(_vm, this); + _rooms[CORRIDOR6] = new AxacussCorridor6(_vm, this); + _rooms[CORRIDOR7] = new AxacussCorridor7(_vm, this); + _rooms[CORRIDOR8] = new AxacussCorridor8(_vm, this); + _rooms[CORRIDOR9] = new AxacussCorridor9(_vm, this); + _rooms[BCORRIDOR] = new AxacussBcorridor(_vm, this); + _rooms[GUARD] = new AxacussIntersection(_vm, this); + _rooms[GUARD3] = new AxacussExit(_vm, this); + _rooms[OFFICE_L1] = new AxacussOffice1(_vm, this); + _rooms[OFFICE_L2] = new AxacussOffice2(_vm, this); + _rooms[OFFICE_R1] = new AxacussOffice3(_vm, this); + _rooms[OFFICE_R2] = new AxacussOffice4(_vm, this); + _rooms[OFFICE_L] = new AxacussOffice5(_vm, this); + _rooms[ELEVATOR] = new AxacussElevator(_vm, this); + _rooms[STATION] = new AxacussStation(_vm, this); + _rooms[SIGN] = new AxacussSign(_vm, this); + _rooms[OUTRO] = new Outro(_vm, this); +} + +bool GameManager1::canSaveGameStateCurrently() { + return _animationEnabled && _guiEnabled; +} + +void GameManager1::updateEvents() { + handleTime(); + if (_animationEnabled && !_vm->_screen->isMessageShown() && _animationTimer == 0) + _currentRoom->animation(); + + if (_state._eventCallback != kNoFn && _time >= _state._eventTime) { + _vm->_allowLoadGame = false; + _vm->_allowSaveGame = false; + _state._eventTime = kMaxTimerValue; + EventFunction fn = _state._eventCallback; + _state._eventCallback = kNoFn; + switch (fn) { + case kNoFn: + break; + case kSupernovaFn: + supernovaEvent(); + break; + case kGuardReturnedFn: + guardReturnedEvent(); + break; + case kGuardWalkFn: + guardWalkEvent(); + break; + case kTaxiFn: + taxiEvent(); + break; + case kSearchStartFn: + searchStartEvent(); + break; + default: + break; //shouldn't happen + } + _vm->_allowLoadGame = true; + _vm->_allowSaveGame = true; + return; + } + + if (_state._alarmOn && _state._timeAlarm <= _time) { + _state._alarmOn = false; + alarm(); + return; + } + + _mouseClicked = false; + _keyPressed = false; + Common::Event event; + while (g_system->getEventManager()->pollEvent(event)) { + switch (event.type) { + case Common::EVENT_KEYDOWN: + _keyPressed = true; + processInput(event.kbd); + break; + case Common::EVENT_LBUTTONUP: + // fallthrough + case Common::EVENT_RBUTTONUP: + if (_currentRoom->getId() != INTRO && _sound->isPlaying()) + return; + _mouseClicked = true; + // fallthrough + case Common::EVENT_MOUSEMOVE: + _mouseClickType = event.type; + _mouseX = event.mouse.x; + _mouseY = event.mouse.y; + if (_guiEnabled) + processInput(); + break; + default: + break; + } + } +} + +void GameManager1::corridorOnEntrance() { + if (_state._corridorSearch) + busted(0); +} + +void GameManager1::telomat(int nr) { + static Common::String name[8] = { + "DR. ALAB HANSI", + "ALAB HANSI", + "SAVAL LUN", + "x", + "PROF. DR. UGNUL TSCHABB", + "UGNUL TSCHABB", + "ALGA HURZ LI", + "x" + }; + + static Common::String name2[4] = { + "Alab Hansi", + "Saval Lun", + "Ugnul Tschabb", + "Alga Hurz Li" + }; + + StringId dial1[4]; + dial1[0] = kStringTelomat1; + dial1[1] = kNoString; + dial1[2] = kStringTelomat3; + dial1[3] = kStringDialogSeparator; + + static byte rows1[3] = {1, 2, 1}; + + StringId dial2[4]; + dial2[0] = kStringTelomat4; + dial2[1] = kStringTelomat5; + dial2[2] = kStringTelomat6; + dial2[3] = kStringDialogSeparator; + + static byte rows2[4] = {1, 1, 1, 1}; + + _vm->renderBox(0, 0, 320, 200, kColorBlack); + _vm->renderText(kStringTelomat7, 100, 70, kColorGreen); + _vm->renderText(kStringTelomat8, 100, 81, kColorGreen); + _vm->renderText(kStringTelomat9, 100, 92, kColorGreen); + _vm->renderText(kStringTelomat10, 100, 103, kColorGreen); + _vm->renderText(kStringTelomat11, 100, 120, kColorDarkGreen); + Common::String input; + do { + getInput(); + + switch (_key.keycode) { + case Common::KEYCODE_2: { + _vm->renderBox(0, 0, 320, 200, kColorDarkBlue); + _vm->renderText(kStringTelomat12, 50, 80, kColorGreen); + _vm->renderText(kStringTelomat13, 50, 91, kColorGreen); + do { + edit(input, 50, 105, 30); + } while ((_key.keycode != Common::KEYCODE_RETURN) && (_key.keycode != Common::KEYCODE_ESCAPE)); + + if (_key.keycode == Common::KEYCODE_ESCAPE) { + _vm->renderBox(0, 0, 320, 200, kColorBlack); + _vm->renderRoom(*_currentRoom); + _vm->paletteBrightness(); + _guiEnabled = true; + drawMapExits(); + return; + } + + input.toUppercase(); + + int i = 0; + while ((i < 8) && (input != name[i])) + i++; + i >>= 1; + if (i == 4) { + _vm->renderText(kStringTelomat14, 50, 120, kColorGreen); + wait(10); + _vm->renderBox(0, 0, 320, 200, kColorBlack); + _vm->renderRoom(*_currentRoom); + _vm->paletteBrightness(); + _guiEnabled = true; + drawMapExits(); + return; + } + + if ((i == nr) || _rooms[BCORRIDOR]->getObject(4 + i)->hasProperty(CAUGHT)) { + _vm->renderText(kStringTelomat15, 50, 120, kColorGreen); + wait(10); + _vm->renderBox(0, 0, 320, 200, kColorBlack); + _vm->renderRoom(*_currentRoom); + _vm->paletteBrightness(); + _guiEnabled = true; + drawMapExits(); + return; + } + + _vm->renderText(kStringTelomat16, 50, 120, kColorGreen); + wait(10); + _vm->renderBox(0, 0, 320, 200, kColorBlack); + _vm->renderRoom(*_currentRoom); + _vm->paletteBrightness(); + _vm->renderMessage(kStringTelomat17, kMessageTop, name2[i]); + waitOnInput(_messageDuration); + _vm->removeMessage(); + if (_state._nameSeen[nr]) { + Common::String string = _vm->getGameString(kStringTelomat2); + _vm->setGameString(kStringPlaceholder1, Common::String::format(string.c_str(), name2[nr].c_str())); + dial1[1] = kStringPlaceholder1; + _currentRoom->addSentence(1, 1); + } else + _currentRoom->removeSentence(1, 1); + + switch (dialog(3, rows1, dial1, 1)) { + case 1: _vm->renderMessage(kStringTelomat18, kMessageTop); + waitOnInput(_messageDuration); + _vm->removeMessage(); + if ((_state._destination == 255) && !_rooms[BCORRIDOR]->isSectionVisible(7)) { + _state._eventTime = _time + ticksToMsec(150); + _state._eventCallback = kGuardWalkFn; + _state._origin = i; + _state._destination = nr; + } + break; + case 0: _vm->renderMessage(kStringTelomat19, kMessageTop); + waitOnInput(_messageDuration); + _vm->removeMessage(); + if (dialog(4, rows2, dial2, 0) != 3) { + wait(10); + say(kStringTelomat20); + } + _rooms[BCORRIDOR]->setSectionVisible(7, true); + _rooms[BCORRIDOR]->setSectionVisible(i + 1, true); + _state._eventTime = kMaxTimerValue; + _currentRoom->addSentence(0, 1); + } + _guiEnabled = true; + drawMapExits(); + return; + } + case Common::KEYCODE_1: + case Common::KEYCODE_3: + case Common::KEYCODE_4: + _vm->renderBox(0, 0, 320, 200, kColorDarkBlue); + _vm->renderText(kStringTelomat21, 100, 90, kColorGreen); + input = ""; + do { + edit(input, 100, 105, 30); + } while ((_key.keycode != Common::KEYCODE_RETURN) && (_key.keycode != Common::KEYCODE_ESCAPE)); + + if (_key.keycode == Common::KEYCODE_RETURN) { + _vm->renderText(kStringShipSleepCabin9, 100, 120, kColorGreen); + wait(10); + } + // fallthrough + case Common::KEYCODE_ESCAPE: + _vm->renderBox(0, 0, 320, 200, kColorBlack); + _vm->renderRoom(*_currentRoom); + _vm->paletteBrightness(); + _guiEnabled = true; + drawMapExits(); + return; + default: + break; + } + } while (true); +} + +void GameManager1::startSearch() { + if ((_currentRoom->getId() >= CORRIDOR1) && (_currentRoom->getId() <= BCORRIDOR)) + busted(0); + + _state._corridorSearch = true; +} + +void GameManager1::search(int time) { + _state._eventTime = _time + ticksToMsec(time); + _state._eventCallback = kSearchStartFn; +} + +void GameManager1::guardNoticed() { + _vm->paletteFadeOut(); + Room *r = _currentRoom; + _currentRoom = _rooms[GUARD]; + _vm->setCurrentImage(40); + _vm->renderBox(0, 0, 320, 200, 0); + _vm->renderImage(0); + _vm->paletteFadeIn(); + _vm->renderImage(2); + reply(kStringGuardNoticed1, 2, 5); + wait(2); + reply(kStringGuardNoticed2, 2, 5); + _vm->paletteFadeOut(); + _currentRoom->setSectionVisible(2, false); + _currentRoom->setSectionVisible(5, false); + _currentRoom = r; + _guiEnabled = true; + drawMapExits(); +} + +void GameManager1::busted(int i) { + if (i > 0) + _vm->renderImage(i); + if (i == 0) { + if ((_currentRoom->getId() >= OFFICE_L1) && (_currentRoom->getId() <= OFFICE_R2)) { + if (_currentRoom->getId() < OFFICE_R1) + i = 10; + else + i = 5; + if (!_currentRoom->getObject(0)->hasProperty(OPENED)) { + _vm->renderImage(i - 1); + _sound->play(kAudioDoorOpen); + wait(2); + } + _vm->renderImage(i); + wait(3); + _vm->renderImage(i + 3); + _sound->play(kAudioVoiceHalt); + _vm->renderImage(i); + wait(5); + if (_currentRoom->getId() == OFFICE_L2) + i = 13; + _vm->renderImage(i + 1); + wait(3); + _vm->renderImage(i + 2); + shot(0, 0); + } else if (_currentRoom->getId() == BCORRIDOR) + _vm->renderImage(21); + else if (_currentRoom->isSectionVisible(4)) + _vm->renderImage(32); // below + else if (_currentRoom->isSectionVisible(2)) + _vm->renderImage(30); // right + else if (_currentRoom->isSectionVisible(1)) + _vm->renderImage(31); // left + else + _vm->renderImage(33); // above + } + _sound->play(kAudioVoiceHalt); + wait(3); + shot(0, 0); +} + +void GameManager1::novaScroll() { + static byte planet_f[6] = {0xeb,0xec,0xf0,0xed,0xf1,0xf2}; + static byte nova_f[13] = {0xea,0xe9,0xf5,0xf3,0xf7,0xf4,0xf6, + 0xf9,0xfb,0xfc,0xfd,0xfe,0xfa}; + static byte rgb[65][3] = { + { 5, 0, 0},{10, 0, 0},{15, 0, 0},{20, 0, 0},{25, 0, 0}, + {30, 0, 0},{35, 0, 0},{40, 0, 0},{45, 0, 0},{50, 0, 0}, + {55, 0, 0},{60, 0, 0},{63,10, 5},{63,20,10},{63,30,15}, + {63,40,20},{63,50,25},{63,60,30},{63,63,33},{63,63,30}, + {63,63,25},{63,63,20},{63,63,15},{63,63,10},{60,60,15}, + {57,57,20},{53,53,25},{50,50,30},{47,47,35},{43,43,40}, + {40,40,45},{37,37,50},{33,33,53},{30,30,56},{27,27,59}, + {23,23,61},{20,20,63},{21,25,63},{22,30,63},{25,35,63}, + {30,40,63},{35,45,63},{40,50,63},{45,55,63},{50,60,63}, + {55,63,63},{59,63,63},{63,63,63},{63,60,63},{60,50,60}, + {55,40,55},{50,30,50},{45,20,45},{40,10,40},{42,15,42}, + {45,20,45},{47,25,47},{50,30,50},{52,35,52},{55,40,55}, + {57,45,57},{60,50,60},{62,55,62},{63,60,63},{63,63,63}}; + + byte palette[768]; + _vm->_system->getPaletteManager()->grabPalette(palette, 0, 255); + + for (int t = 0; t < 65; ++t) { + for (int i = 0; i < 6; ++i) { + int idx = 3 * (planet_f[i] - 1); + for (int c = 0 ; c < 3 ; ++c) { + if (palette[idx+c] < rgb[t][c]) + palette[idx+c] = rgb[t][c]; + } + } + for (int cycle = 0; cycle < t && cycle < 13; ++cycle) { + int idx = 3 * (nova_f[cycle] - 1); + for (int c = 0 ; c < 3 ; ++c) + palette[idx + c] = rgb[t - cycle - 1][c]; + } + + _vm->_system->getPaletteManager()->setPalette(palette, 0, 255); + _vm->_system->updateScreen(); + _vm->_system->delayMillis(_vm->_delay); + } +} + +void GameManager1::supernovaEvent() { + _vm->removeMessage(); + CursorMan.showMouse(false); + if (_currentRoom->getId() <= CAVE) { + _vm->renderMessage(kStringSupernova1); + waitOnInput(_messageDuration); + _vm->removeMessage(); + _vm->paletteFadeOut(); + changeRoom(MEETUP); + _rooms[AIRLOCK]->getObject(0)->disableProperty(OPENED); + _rooms[AIRLOCK]->setSectionVisible(3, true); + _rooms[AIRLOCK]->getObject(1)->setProperty(OPENED); + _rooms[AIRLOCK]->setSectionVisible(17, true); + _rooms[AIRLOCK]->setSectionVisible(6, false); + _vm->renderRoom(*_currentRoom); + _vm->paletteFadeIn(); + } + _vm->renderMessage(kStringSupernova2); + waitOnInput(_messageDuration); + _vm->removeMessage(); + _vm->setCurrentImage(26); + _vm->renderImage(0); + _vm->paletteBrightness(); + novaScroll(); + _vm->paletteFadeOut(); + _vm->renderBox(0, 0, 320, 200, kColorBlack); + _vm->_screen->setGuiBrightness(255); + _vm->paletteBrightness(); + + if (_currentRoom->getId() == GLIDER) { + _vm->renderMessage(kStringSupernova3); + waitOnInput(_messageDuration); + _vm->removeMessage(); + _vm->_screen->setGuiBrightness(0); + _vm->paletteBrightness(); + _vm->renderRoom(*_currentRoom); + _vm->paletteFadeIn(); + _vm->renderMessage(kStringSupernova4, kMessageTop); + waitOnInput(_messageDuration); + _vm->removeMessage(); + _vm->renderMessage(kStringSupernova5, kMessageTop); + waitOnInput(_messageDuration); + _vm->removeMessage(); + _vm->renderMessage(kStringSupernova6, kMessageTop); + waitOnInput(_messageDuration); + _vm->removeMessage(); + _vm->renderMessage(kStringSupernova7, kMessageTop); + waitOnInput(_messageDuration); + _vm->removeMessage(); + changeRoom(MEETUP2); + _rooms[MEETUP2]->setSectionVisible(1, true); + _rooms[MEETUP2]->removeSentence(0, 1); + _inventory.remove(*(_rooms[ROGER]->getObject(3))); + _inventory.remove(*(_rooms[ROGER]->getObject(7))); + _inventory.remove(*(_rooms[ROGER]->getObject(8))); + } else { + _vm->renderMessage(kStringSupernova8); + waitOnInput(_messageDuration); + _vm->removeMessage(); + _vm->_screen->setGuiBrightness(0); + _vm->paletteBrightness(); + changeRoom(MEETUP2); + if (_rooms[ROGER]->getObject(3)->hasProperty(CARRIED) && !_rooms[GLIDER]->isSectionVisible(5)) { + _rooms[MEETUP2]->setSectionVisible(1, true); + _rooms[MEETUP2]->setSectionVisible(12, true); + _rooms[MEETUP2]->getObject(1)->_click = 0; + _rooms[MEETUP2]->getObject(0)->_click = 1; + _rooms[MEETUP2]->removeSentence(0, 1); + } + _rooms[MEETUP2]->removeSentence(1, 1); + } + _rooms[AIRLOCK]->getObject(4)->setProperty(WORN); + _rooms[AIRLOCK]->getObject(5)->setProperty(WORN); + _rooms[AIRLOCK]->getObject(6)->setProperty(WORN); + _rooms[CAVE]->getObject(1)->_exitRoom = MEETUP2; + _guiEnabled = true; + CursorMan.showMouse(true); +} + +void GameManager1::guardReturnedEvent() { + if (_currentRoom->getId() == GUARD) + busted(-1); + else if ((_currentRoom->getId() == CORRIDOR9) && (_currentRoom->isSectionVisible(27))) + busted(0); + + _rooms[GUARD]->setSectionVisible(1, false); + _rooms[GUARD]->getObject(3)->_click = 0; + _rooms[GUARD]->setSectionVisible(6, false); + _rooms[GUARD]->getObject(2)->disableProperty(OPENED); + _rooms[GUARD]->setSectionVisible(7, false); + _rooms[GUARD]->getObject(5)->_click = 255; + _rooms[CORRIDOR9]->setSectionVisible(27, false); + _rooms[CORRIDOR9]->setSectionVisible(28, true); + _rooms[CORRIDOR9]->getObject(1)->disableProperty(OPENED); +} + +void GameManager1::walk(int imgId) { + if (_prevImgId) + _vm->renderImage(_prevImgId + 128); + _vm->renderImage(imgId); + _prevImgId = imgId; + wait(3); +} + +void GameManager1::guardWalkEvent() { + _prevImgId = 0; + bool behind = (!_rooms[BCORRIDOR]->getObject(_state._origin + 4)->hasProperty(OCCUPIED) || + _rooms[BCORRIDOR]->getObject(_state._origin + 4)->hasProperty(OPENED)); + _rooms[BCORRIDOR]->getObject(_state._origin + 4)->disableProperty(OCCUPIED); + if (_currentRoom == _rooms[BCORRIDOR]) { + if (_vm->_screen->isMessageShown()) + _vm->removeMessage(); + + if (!behind) { + _vm->renderImage(_state._origin + 1); + _prevImgId = _state._origin + 1; + _sound->play(kAudioDoorOpen); + wait(3); + } + + int imgId; + switch (_state._origin) { + case 0: + imgId = 11; + break; + case 1: + imgId = 16; + break; + case 2: + imgId = 15; + break; + case 3: + default: + imgId = 20; + break; + } + _vm->renderImage(imgId); + if (!behind) { + wait(3); + _vm->renderImage(_prevImgId + 128); + _sound->play(kAudioDoorClose); + } + + _prevImgId = imgId; + wait(3); + switch (_state._origin) { + case 0: + walk(12); + walk(13); + break; + case 1: + walk(17); + walk(18); + break; + case 2: + walk(14); + walk(13); + break; + case 3: + walk(19); + walk(18); + } + + if (!_state._playerHidden) { + if (_state._origin & 1) + walk(10); + else + walk(5); + busted(-1); + } + + if ((_state._origin & 1) && !(_state._destination & 1)) { + for (int i = 10; i >= 5; i--) + walk(i); + walk(13); + } else if (!(_state._origin & 1) && (_state._destination & 1)) { + for (int i = 5; i <= 10; i++) + walk(i); + walk(18); + } + + switch (_state._destination) { + case 0: + for (int i = 13; i >= 11; i--) + walk(i); + break; + case 1: + for (int i = 18; i >= 16; i--) + walk(i); + break; + case 2: + for (int i = 13; i <= 15; i++) + walk(i); + break; + case 3: + for (int i = 18; i <= 20; i++) + walk(i); + } + + if (behind) { + _vm->renderImage(_state._destination + 1); + _sound->play(kAudioDoorOpen); + wait(3); + _vm->renderImage(_prevImgId + 128); + wait(3); + _vm->renderImage(_state._destination + 1 + 128); + _sound->play(kAudioDoorClose); + _rooms[BCORRIDOR]->getObject(_state._destination + 4)->setProperty(OCCUPIED); + _state._destination = 255; + } else if (_rooms[BCORRIDOR]->isSectionVisible(_state._destination + 1)) { + _vm->renderImage(_prevImgId + 128); + _rooms[BCORRIDOR]->getObject(_state._destination + 4)->setProperty(OCCUPIED); + SWAP(_state._origin, _state._destination); + _state._eventTime = _time + ticksToMsec(60); + _state._eventCallback = kGuardWalkFn; + } else { + wait(18); + SWAP(_state._origin, _state._destination); + _state._eventCallback = kGuardWalkFn; + } + } else if (behind) { + _rooms[BCORRIDOR]->getObject(_state._destination + 4)->setProperty(OCCUPIED); + if (_currentRoom == _rooms[OFFICE_L1 + _state._destination]) + busted(0); + _state._destination = 255; + } else if (_rooms[BCORRIDOR]->isSectionVisible(_state._destination + 1) && _rooms[OFFICE_L1 + _state._destination]->getObject(0)->hasProperty(OPENED)) { + _rooms[BCORRIDOR]->getObject(_state._destination + 4)->setProperty(OCCUPIED); + if (_currentRoom == _rooms[OFFICE_L1 + _state._destination]) + busted(0); + SWAP(_state._origin, _state._destination); + _state._eventTime = _time + ticksToMsec(60); + _state._eventCallback = kGuardWalkFn; + } else { + SWAP(_state._origin, _state._destination); + _state._eventCallback = kGuardWalkFn; + } +} + +void GameManager1::taxiEvent() { + if (_currentRoom->getId() == SIGN) { + changeRoom(STATION); + _vm->renderRoom(*_currentRoom); + } + + _vm->renderImage(1); + _vm->renderImage(2); + _sound->play(kAudioRocks); + screenShake(); + _vm->renderImage(9); + _currentRoom->getObject(1)->setProperty(OPENED); + _vm->renderImage(1); + _currentRoom->setSectionVisible(2, false); + _vm->renderImage(3); + for (int i = 4; i <= 8; i++) { + wait(2); + _vm->renderImage(invertSection(i - 1)); + _vm->renderImage(i); + } + _rooms[SIGN]->setSectionVisible(2, false); + _rooms[SIGN]->setSectionVisible(3, true); +} + +void GameManager1::searchStartEvent() { + if ((_currentRoom >= _rooms[CORRIDOR1]) && (_currentRoom <= _rooms[BCORRIDOR])) + busted(0); + _state._corridorSearch = true; +} + +void GameManager1::great(uint number) { + if (number && (_state._greatFlag & (1 << number))) + return; + + _sound->play(kAudioSuccess); + _state._greatFlag |= 1 << number; +} + +bool GameManager1::airless() { + return (_currentRoom->getId() == HOLD || + _currentRoom->getId() == LANDINGMODULE || + _currentRoom->getId() == GENERATOR || + _currentRoom->getId() == OUTSIDE || + _currentRoom->getId() == ROCKS || + _currentRoom->getId() == CAVE || + _currentRoom->getId() == MEETUP || + _currentRoom->getId() == MEETUP2 || + _currentRoom->getId() == MEETUP3 || + (_currentRoom->getId() == AIRLOCK && _rooms[AIRLOCK]->getObject(1)->hasProperty(OPENED))); +} + +void GameManager1::turnOff() { + if (_state._powerOff) + return; + + _state._powerOff = true; + roomBrightness(); +} + +void GameManager1::turnOn() { + if (!_state._powerOff) + return; + + _state._powerOff = false; + _vm->_screen->setViewportBrightness(255); + _rooms[SLEEP]->setSectionVisible(1, false); + _rooms[SLEEP]->setSectionVisible(2, false); + _rooms[COCKPIT]->setSectionVisible(22, false); +} + +void GameManager1::roomBrightness() { + _roomBrightness = 255; + if ((_currentRoom->getId() != OUTSIDE) && (_currentRoom->getId() < ROCKS) && _state._powerOff) + _roomBrightness = 153; + else if (_currentRoom->getId() == CAVE) + _roomBrightness = 0; + else if ((_currentRoom->getId() == GUARD3) && _state._powerOff) + _roomBrightness = 0; + + if (_vm->_screen->getViewportBrightness() != 0) + _vm->_screen->setViewportBrightness(_roomBrightness); + + _vm->paletteBrightness(); +} + +void GameManager1::handleTime() { + if (_timerPaused) + return; + int32 newTime = g_system->getMillis(); + int32 delta = newTime - _oldTime; + _time += delta; + if (_time > 86400000) { + _time -= 86400000; // 24h wrap around + _state._alarmOn = (_state._timeAlarm > _time); + } + if (_animationTimer > delta) + _animationTimer -= delta; + else + _animationTimer = 0; + + _oldTime = newTime; +} + +void GameManager1::loadTime() { + pauseTimer(false); +} + +void GameManager1::saveTime() { + pauseTimer(true); +} + +void GameManager1::shock() { + _sound->play(kAudioShock); + dead(kStringShock); +} + +void GameManager1::drawMapExits() { +// TODO: Preload _exitList on room entry instead on every call + _vm->renderBox(281, 161, 39, 39, kColorWhite25); + + for (int i = 0; i < 25; i++) + _exitList[i] = -1; + for (int i = 0; i < kMaxObject; i++) { + if (_currentRoom->getObject(i)->hasProperty(EXIT)) { + byte r = _currentRoom->getObject(i)->_direction; + _exitList[r] = i; + int x = 284 + 7 * (r % 5); + int y = 164 + 7 * (r / 5); + _vm->renderBox(x, y, 5, 5, kColorDarkRed); + } + } +} + +void GameManager1::shot(int a, int b) { + if (a) + _vm->renderImage(a); + _sound->play(kAudioGunShot); + wait(2); + if (b) + _vm->renderImage(b); + wait(2); + if (a) + _vm->renderImage(a); + _sound->play(kAudioGunShot); + wait(2); + if (b) + _vm->renderImage(b); + + dead(kStringShot); +} + +void GameManager1::takeMoney(int amount) { + Object *moneyObject = _rooms[INTRO]->getObject(4); + _state._money += amount; + _vm->setGameString(kStringInventoryMoney, Common::String::format("%d Xa", _state._money)); + + if (_state._money > 0) { + takeObject(*moneyObject); + if (amount > 0) + great(0); + } else { + _inventory.remove(*moneyObject); + } +} + +void GameManager1::openLocker(const Room *room, Object *obj, Object *lock, int section) { + _vm->renderImage(section); + obj->setProperty(OPENED); + lock->_click = 255; + SWAP(obj->_click, obj->_click2); +} + +void GameManager1::closeLocker(const Room *room, Object *obj, Object *lock, int section) { + if (!obj->hasProperty(OPENED)) + _vm->renderMessage(kStringCloseLocker_1); + else { + _vm->renderImage(invertSection(section)); + obj->disableProperty(OPENED); + lock->_click = lock->_click2; + SWAP(obj->_click, obj->_click2); + } +} + +bool GameManager1::isHelmetOff() { + Object *helmet = _inventory.get(HELMET); + if (helmet && helmet->hasProperty(WORN)) { + _vm->renderMessage(kStringIsHelmetOff_1); + return false; + } + + return true; +} + +bool GameManager1::genericInteract(Action verb, Object &obj1, Object &obj2) { + if ((verb == ACTION_USE) && (obj1._id == SCHNUCK)) { + if (isHelmetOff()) { + takeObject(obj1); + _vm->renderMessage(kStringGenericInteract_1); + _inventory.remove(obj1); + } + } else if ((verb == ACTION_USE) && (obj1._id == EGG)) { + if (isHelmetOff()) { + takeObject(obj1); + if (obj1.hasProperty(OPENED)) + _vm->renderMessage(kStringGenericInteract_1); + else + _vm->renderMessage(kStringGenericInteract_2); + + _inventory.remove(obj1); + } + } else if ((verb == ACTION_OPEN) && (obj1._id == EGG)) { + takeObject(obj1); + if (obj1.hasProperty(OPENED)) + _vm->renderMessage(kStringGenericInteract_3); + else { + takeObject(*_rooms[ENTRANCE]->getObject(8)); + _vm->renderMessage(kStringGenericInteract_4); + obj1.setProperty(OPENED); + } + } else if ((verb == ACTION_USE) && (obj1._id == PILL)) { + if (isHelmetOff()) { + _vm->renderMessage(kStringGenericInteract_5); + great(0); + _inventory.remove(obj1); + _state._language = 2; + takeObject(*_rooms[ENTRANCE]->getObject(17)); + } + } else if ((verb == ACTION_LOOK) && (obj1._id == PILL_HULL) && + (_state._language == 2)) { + _vm->renderMessage(kStringGenericInteract_6); + _state._language = 1; + } else if ((verb == ACTION_OPEN) && (obj1._id == WALLET)) { + if (!_rooms[ROGER]->getObject(3)->hasProperty(CARRIED)) + _vm->renderMessage(kStringGenericInteract_7); + else if (_rooms[ROGER]->getObject(7)->hasProperty(CARRIED)) + _vm->renderMessage(kStringGenericInteract_8); + else { + _vm->renderMessage(kStringGenericInteract_9); + takeObject(*_rooms[ROGER]->getObject(7)); + takeObject(*_rooms[ROGER]->getObject(8)); + } + } else if ((verb == ACTION_LOOK) && (obj1._id == NEWSPAPER)) { + animationOff(); + saveTime(); + + _vm->renderMessage(kStringGenericInteract_10); + waitOnInput(_messageDuration); + _vm->removeMessage(); + _vm->renderMessage(kStringGenericInteract_11); + waitOnInput(_messageDuration); + _vm->removeMessage(); + _vm->setCurrentImage(2); + _vm->renderImage(0); + _vm->setColor63(40); + getInput(); + _vm->renderRoom(*_currentRoom); + roomBrightness(); + _vm->renderMessage(kStringGenericInteract_12); + + loadTime(); + animationOn(); + } else if ((verb == ACTION_LOOK) && (obj1._id == KEYCARD2)) { + _vm->renderMessage(obj1._description); + obj1._description = kStringKeycard2Description2; + } else if ((verb == ACTION_LOOK) && (obj1._id == WATCH)) + _vm->renderMessage(kStringGenericInteract_13, kMessageNormal, timeToString(_time), timeToString(_state._timeAlarm)); + else if ((verb == ACTION_PRESS) && (obj1._id == WATCH)) { + bool validInput = true; + int hours = 0; + int minutes = 0; + + animationOff(); + _vm->saveScreen(88, 87, 144, 24); + _vm->renderBox(88, 87, 144, 24, kColorWhite35); + _vm->renderText(kStringGenericInteract_14, 91, 90, kColorWhite99); + Common::String input; + do { + validInput = true; + input.clear(); + _vm->renderBox(91, 99, 138, 9, kColorDarkBlue); + edit(input, 91, 100, 5); + + int seperator = -1; + for (uint i = 0; i < input.size(); ++i) { + if (input[i] == ':') { + seperator = i; + break; + } + } + if ((seperator == -1) || (seperator > 2)) { + validInput = false; + continue; + } + + int decimalPlace = 1; + for (int i = 0; i < seperator; ++i) { + if (Common::isDigit(input[i])) { + hours = hours * decimalPlace + (input[i] - '0'); + decimalPlace *= 10; + } else { + validInput = false; + break; + } + } + decimalPlace = 1; + for (uint i = seperator + 1; i < input.size(); ++i) { + if (Common::isDigit(input[i])) { + minutes = minutes * decimalPlace + (input[i] - '0'); + decimalPlace *= 10; + } else { + validInput = false; + break; + } + } + if ((hours > 23) || (minutes > 59)) + validInput = false; + + animationOn(); + } while (!validInput && (_key.keycode != Common::KEYCODE_ESCAPE)); + + _vm->restoreScreen(); + if (_key.keycode != Common::KEYCODE_ESCAPE) { + _state._timeAlarm = (hours * 60 + minutes) * 60 * 1000; + _state._alarmOn = (_state._timeAlarm > _time); + } + } else if ((verb == ACTION_USE) && Object::combine(obj1, obj2, TERMINALSTRIP, WIRE)) { + Room *r = _rooms[CABIN_L3]; + if (!r->getObject(8)->hasProperty(CARRIED)) { + if (r->isSectionVisible(26)) + _vm->renderMessage(kStringTakeMessage); + else + return false; + } else { + r->getObject(8)->_name = kStringWireAndClip; + r = _rooms[HOLD]; + _inventory.remove(*r->getObject(2)); + _state._terminalStripConnected = true; + _state._terminalStripWire = true; + _vm->renderMessage(kStringOk); + } + } else if ((verb == ACTION_USE) && Object::combine(obj1, obj2, TERMINALSTRIP, SPOOL)) { + Room *r = _rooms[CABIN_L2]; + takeObject(*r->getObject(9)); + r->getObject(9)->_name = kSringSpoolAndClip; + r = _rooms[HOLD]; + _inventory.remove(*r->getObject(2)); + _state._terminalStripConnected = true; + _vm->renderMessage(kStringOk); + } else if ((verb == ACTION_USE) && Object::combine(obj1, obj2, WIRE, SPOOL)) { + Room *r = _rooms[CABIN_L3]; + if (!_state._terminalStripConnected) { + if (r->isSectionVisible(26)) + _vm->renderMessage(kStringCable3); + else + return false; + } else { + if (!r->getObject(8)->hasProperty(CARRIED)) + _vm->renderMessage(kStringTakeMessage); + else { + r = _rooms[CABIN_L2]; + takeObject(*r->getObject(9)); + r = _rooms[CABIN_L3]; + r->getObject(8)->_name = kStringGeneratorWire; + r = _rooms[CABIN_L2]; + _inventory.remove(*r->getObject(9)); + _state._cableConnected = true; + _vm->renderMessage(kStringOk); + } + } + } else if ((verb == ACTION_USE) && (obj1._id == SUIT)) { + takeObject(obj1); + if ((_currentRoom->getId() >= ENTRANCE) && (_currentRoom->getId() <= ROGER)) { + if (obj1.hasProperty(WORN)) { + _vm->renderMessage(kStringGenericInteract_15); + _rooms[AIRLOCK]->getObject(4)->disableProperty(WORN); + _rooms[AIRLOCK]->getObject(5)->disableProperty(WORN); + _rooms[AIRLOCK]->getObject(6)->disableProperty(WORN); + } else + _vm->renderMessage(kStringGenericInteract_16); + } else { + if (obj1.hasProperty(WORN)) { + Room *r = _rooms[AIRLOCK]; + if (r->getObject(4)->hasProperty(WORN)) + _vm->renderMessage(kStringGenericInteract_17); + else if (r->getObject(6)->hasProperty(WORN)) + _vm->renderMessage(kStringGenericInteract_18); + else { + obj1.disableProperty(WORN); + _vm->renderMessage(kStringGenericInteract_19); + } + } else { + obj1.setProperty(WORN); + _vm->renderMessage(kStringGenericInteract_20); + } + } + } else if ((verb == ACTION_USE) && (obj1._id == HELMET)) { + takeObject(obj1); + if ((_currentRoom->getId() >= ENTRANCE) && (_currentRoom->getId() <= ROGER)) { + if (obj1.hasProperty(WORN)) { + _vm->renderMessage(kStringGenericInteract_21); + _rooms[AIRLOCK]->getObject(4)->disableProperty(WORN); + _rooms[AIRLOCK]->getObject(5)->disableProperty(WORN); + _rooms[AIRLOCK]->getObject(6)->disableProperty(WORN); + } else + _vm->renderMessage(kStringGenericInteract_22); + } else if (obj1.hasProperty(WORN)) { + obj1.disableProperty(WORN); + _vm->renderMessage(kStringGenericInteract_24); + getInput(); + if (airless()) + dead(kStringGenericInteract_23); + } else { + Room *r = _rooms[AIRLOCK]; + if (r->getObject(5)->hasProperty(WORN)) { + obj1.setProperty(WORN); + _vm->renderMessage(kStringGenericInteract_25); + } else + _vm->renderMessage(kStringGenericInteract_26); + } + } else if ((verb == ACTION_USE) && (obj1._id == LIFESUPPORT)) { + takeObject(obj1); + if ((_currentRoom->getId() >= ENTRANCE) && (_currentRoom->getId() <= ROGER)) { + if (obj1.hasProperty(WORN)) { + _vm->renderMessage(kStringGenericInteract_21); + _rooms[AIRLOCK]->getObject(4)->disableProperty(WORN); + _rooms[AIRLOCK]->getObject(5)->disableProperty(WORN); + _rooms[AIRLOCK]->getObject(6)->disableProperty(WORN); + } else + _vm->renderMessage(kStringGenericInteract_22); + } else if (obj1.hasProperty(WORN)) { + obj1.disableProperty(WORN); + _vm->renderMessage(kStringGenericInteract_28); + getInput(); + if (airless()) + dead(kStringGenericInteract_27); + } else { + Room *r = _rooms[AIRLOCK]; + if (r->getObject(5)->hasProperty(WORN)) { + obj1.setProperty(WORN); + _vm->renderMessage(kStringGenericInteract_29); + } else + _vm->renderMessage(kStringGenericInteract_26); + } + } else if ((verb == ACTION_WALK) && (obj1._id == BATHROOM_DOOR)) { + _rooms[BATHROOM]->getObject(2)->_exitRoom = _currentRoom->getId(); + return false; + } else if ((verb == ACTION_USE) && Object::combine(obj1, obj2, WIRE, SOCKET)) + _vm->renderMessage(kStringGenericInteract_30); + else if ((verb == ACTION_LOOK) && (obj1._id == BOOK2)) { + _vm->renderMessage(kStringGenericInteract_31); + waitOnInput(_messageDuration); + _vm->removeMessage(); + _vm->renderMessage(kStringGenericInteract_32); + } else + return false; + + return true; +} + +void GameManager1::handleInput() { + bool validCommand = genericInteract(_inputVerb, *_inputObject[0], *_inputObject[1]); + if (!validCommand) + validCommand = _currentRoom->interact(_inputVerb, *_inputObject[0], *_inputObject[1]); + if (!validCommand) { + switch (_inputVerb) { + case ACTION_LOOK: + _vm->renderMessage(_inputObject[0]->_description); + break; + + case ACTION_WALK: + if (_inputObject[0]->hasProperty(CARRIED)) { + // You already carry this. + _vm->renderMessage(kStringGenericInteract_33); + } else if (!_inputObject[0]->hasProperty(EXIT)) { + // You're already there. + _vm->renderMessage(kStringGenericInteract_34); + } else if (_inputObject[0]->hasProperty(OPENABLE) && !_inputObject[0]->hasProperty(OPENED)) { + // This is closed + _vm->renderMessage(kStringShipHold9); + } else + changeRoom(_inputObject[0]->_exitRoom); + + break; + + case ACTION_TAKE: + if (_inputObject[0]->hasProperty(OPENED)) { + // You already have that + _vm->renderMessage(kStringGenericInteract_35); + } else if (_inputObject[0]->hasProperty(UNNECESSARY)) { + // You do not need that. + _vm->renderMessage(kStringGenericInteract_36); + } else if (!_inputObject[0]->hasProperty(TAKE)) { + // You can't take that. + _vm->renderMessage(kStringGenericInteract_37); + } else + takeObject(*_inputObject[0]); + + break; + + case ACTION_OPEN: + if (!_inputObject[0]->hasProperty(OPENABLE)) { + // This can't be opened + _vm->renderMessage(kStringGenericInteract_38); + } else if (_inputObject[0]->hasProperty(OPENED)) { + // This is already opened. + _vm->renderMessage(kStringGenericInteract_39); + } else if (_inputObject[0]->hasProperty(CLOSED)) { + // This is locked. + _vm->renderMessage(kStringGenericInteract_40); + } else { + _vm->renderImage(_inputObject[0]->_section); + _inputObject[0]->setProperty(OPENED); + byte i = _inputObject[0]->_click; + _inputObject[0]->_click = _inputObject[0]->_click2; + _inputObject[0]->_click2 = i; + _sound->play(kAudioDoorOpen); + } + break; + + case ACTION_CLOSE: + if (!_inputObject[0]->hasProperty(OPENABLE) || + (_inputObject[0]->hasProperty(CLOSED) && + _inputObject[0]->hasProperty(OPENED))) { + // This can't be closed. + _vm->renderMessage(kStringGenericInteract_41); + } else if (!_inputObject[0]->hasProperty(OPENED)) { + // This is already closed. + _vm->renderMessage(kStringCloseLocker_1); + } else { + _vm->renderImage(invertSection(_inputObject[0]->_section)); + _inputObject[0]->disableProperty(OPENED); + byte i = _inputObject[0]->_click; + _inputObject[0]->_click = _inputObject[0]->_click2; + _inputObject[0]->_click2 = i; + _sound->play(kAudioDoorClose); + } + break; + + case ACTION_GIVE: + if (_inputObject[0]->hasProperty(CARRIED)) { + // Better keep it! + _vm->renderMessage(kStringGenericInteract_42); + } + break; + + default: + // This is not possible. + _vm->renderMessage(kStringGenericInteract_43); + } + } +} + +void GameManager1::executeRoom() { + if (_processInput && !_vm->_screen->isMessageShown() && _guiEnabled) { + handleInput(); + if (_mouseClicked) { + Common::Event event; + event.type = Common::EVENT_MOUSEMOVE; + event.mouse = Common::Point(0, 0); + _vm->getEventManager()->pushEvent(event); + event.type = Common::EVENT_MOUSEMOVE; + event.mouse = Common::Point(_mouseX, _mouseY); + _vm->getEventManager()->pushEvent(event); + } + + resetInputState(); + } + + if (_guiEnabled) { + if (!_vm->_screen->isMessageShown()) { + g_system->fillScreen(kColorBlack); + _vm->renderRoom(*_currentRoom); + } + drawMapExits(); + drawInventory(); + drawStatus(); + drawCommandBox(); + } + + roomBrightness(); + if (_vm->_screen->getViewportBrightness() == 0) + _vm->paletteFadeIn(); + + if (!_currentRoom->hasSeen() && _newRoom) { + _newRoom = false; + _currentRoom->onEntrance(); + } +} + +void GameManager1::guardShot() { + _vm->renderImage(2); + _vm->renderImage(5); + wait(3); + _vm->renderImage(2); + + _sound->play(kAudioVoiceHalt); + while (_sound->isPlaying()) + wait(1); + + _vm->renderImage(5); + wait(5); + _vm->renderImage(3); + wait(3); + + shot(4, 3); +} + +void GameManager1::guard3Shot() { + _vm->renderImage(1); + wait(3); + _sound->play(kAudioVoiceHalt); // 46/0 + while (_sound->isPlaying()) + wait(1); + + wait(5); + _vm->renderImage(2); + wait(3); + shot(3,2); +} + +void GameManager1::alarm() { + if (_rooms[INTRO]->getObject(2)->hasProperty(CARRIED)) { + alarmSound(); + if (_currentRoom->getId() == GUARD) + guardShot(); + else if (_currentRoom->getId() == CORRIDOR4 || _currentRoom->getId() == CORRIDOR7) { + guardNoticed(); + _state._corridorSearch = true; + } else if (_currentRoom->getId() == GUARD3) + guard3Shot(); + else if (_currentRoom->getId() == CORRIDOR1) + busted(33); + } else { + if (_currentRoom->getId() == CORRIDOR2 || _currentRoom->getId() == CORRIDOR4 || + _currentRoom->getId() == GUARD || _currentRoom->getId() == CORRIDOR7 || + _currentRoom->getId() == CELL) + { + alarmSound(); + if (_currentRoom->getId() == GUARD) + guardShot(); + guardNoticed(); + if (_currentRoom->getId() == CORRIDOR4) + _state._corridorSearch = true; + } + _rooms[GUARD]->setSectionVisible(1, true); + _rooms[GUARD]->getObject(3)->_click = 255; + if (!_rooms[GUARD]->getObject(5)->hasProperty(CARRIED)) { + _rooms[GUARD]->setSectionVisible(7, true); + _rooms[GUARD]->getObject(5)->_click = 4; + } + _state._eventTime = _time + ticksToMsec(180); + _state._eventCallback = kGuardReturnedFn; + } +} + +void GameManager1::alarmSound() { + animationOff(); + _vm->removeMessage(); + _vm->renderMessage(kStringAlarm); + + int32 end = _time + ticksToMsec(_messageDuration); + do { + _sound->play(kAudioAlarm); + while (_sound->isPlaying()) { + g_system->delayMillis(_vm->_delay); + updateEvents(); + g_system->updateScreen(); + } + } while (_time < end && !_vm->shouldQuit()); + + _vm->removeMessage(); + animationOn(); +} + +} diff --git a/engines/supernova/supernova1/state.h b/engines/supernova/supernova1/state.h new file mode 100644 index 0000000000..ba02b012a5 --- /dev/null +++ b/engines/supernova/supernova1/state.h @@ -0,0 +1,124 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef SUPERNOVA_STATE_H +#define SUPERNOVA_STATE_H + +#include "common/error.h" +#include "common/events.h" +#include "common/rect.h" +#include "common/keyboard.h" +#include "supernova/supernova1/rooms.h" +#include "supernova/room.h" +#include "supernova/sound.h" +#include "supernova/game-manager.h" + +namespace Supernova { + +class GameManager; + +class GameState { + public: + int32 _timeSleep; + int32 _timeAlarm; + int32 _eventTime; + EventFunction _eventCallback; + int32 _arrivalDaysLeft; + int32 _shipEnergyDaysLeft; + int32 _landingModuleEnergyDaysLeft; + uint16 _greatFlag; + int16 _timeRobot; + int16 _money; + byte _coins; + byte _shoes; + byte _origin; + byte _destination; + byte _language; + bool _corridorSearch; + bool _alarmOn; + bool _terminalStripConnected; + bool _terminalStripWire; + bool _cableConnected; + bool _powerOff; + bool _dream; + bool _nameSeen[4]; + bool _playerHidden; +}; + +class GameManager1 : public GameManager { +public: + GameManager1(SupernovaEngine *vm, Sound *sound); + virtual ~GameManager1(); + + GameState _state; + + virtual void updateEvents(); + virtual void executeRoom(); + virtual bool serialize(Common::WriteStream *out); + virtual bool deserialize(Common::ReadStream *in, int version); + + virtual void initState(); + virtual void initRooms(); + virtual void destroyRooms(); + virtual bool canSaveGameStateCurrently(); + virtual bool genericInteract(Action verb, Object &obj1, Object &obj2); + bool isHelmetOff(); + void great(uint number); + bool airless(); + void shock(); + void turnOff(); + void turnOn(); + virtual void roomBrightness(); + void openLocker(const Room *room, Object *obj, Object *lock, int section); + void closeLocker(const Room *room, Object *obj, Object *lock, int section); + virtual void drawMapExits(); + virtual void handleInput(); + virtual void handleTime(); + virtual void loadTime(); + virtual void saveTime(); + void shot(int a, int b); + virtual void takeMoney(int amount); + void search(int time); + void startSearch(); + void guardNoticed(); + void busted(int i); + void corridorOnEntrance(); + void telomat(int number); + void novaScroll(); + void supernovaEvent(); + void guardReturnedEvent(); + void walk(int a); + void guardWalkEvent(); + void taxiEvent(); + void searchStartEvent(); + void guardShot(); + void guard3Shot(); + void alarm(); + void alarmSound(); + +private: + int _prevImgId; +}; + +} + +#endif // SUPERNOVA_STATE_H -- cgit v1.2.3