diff options
Diffstat (limited to 'engines/mads/phantom')
-rw-r--r-- | engines/mads/phantom/game_phantom.cpp | 772 | ||||
-rw-r--r-- | engines/mads/phantom/game_phantom.h | 51 | ||||
-rw-r--r-- | engines/mads/phantom/globals_phantom.cpp | 5 | ||||
-rw-r--r-- | engines/mads/phantom/globals_phantom.h | 16 | ||||
-rw-r--r-- | engines/mads/phantom/phantom_scenes.cpp | 111 | ||||
-rw-r--r-- | engines/mads/phantom/phantom_scenes.h | 45 | ||||
-rw-r--r-- | engines/mads/phantom/phantom_scenes1.cpp | 9426 | ||||
-rw-r--r-- | engines/mads/phantom/phantom_scenes1.h | 337 | ||||
-rw-r--r-- | engines/mads/phantom/phantom_scenes2.cpp | 7001 | ||||
-rw-r--r-- | engines/mads/phantom/phantom_scenes2.h | 307 | ||||
-rw-r--r-- | engines/mads/phantom/phantom_scenes3.cpp | 2774 | ||||
-rw-r--r-- | engines/mads/phantom/phantom_scenes3.h | 248 | ||||
-rw-r--r-- | engines/mads/phantom/phantom_scenes4.cpp | 4975 | ||||
-rw-r--r-- | engines/mads/phantom/phantom_scenes4.h | 265 | ||||
-rw-r--r-- | engines/mads/phantom/phantom_scenes5.cpp | 4309 | ||||
-rw-r--r-- | engines/mads/phantom/phantom_scenes5.h | 219 |
16 files changed, 30675 insertions, 186 deletions
diff --git a/engines/mads/phantom/game_phantom.cpp b/engines/mads/phantom/game_phantom.cpp index 592a108aea..7e61241182 100644 --- a/engines/mads/phantom/game_phantom.cpp +++ b/engines/mads/phantom/game_phantom.cpp @@ -35,10 +35,109 @@ namespace MADS { namespace Phantom { -GamePhantom::GamePhantom(MADSEngine *vm) - : Game(vm) { + Catacombs _easyCatacombs[32] = { + { 401, { -1, 1, 2, 6 }, { 2, 3, 0, 1 }, MAZE_EVENT_BRICK }, + { 404, { 10, 11, 3, 0 }, { 2, 3, 0, 1 }, MAZE_EVENT_PUDDLE }, + { 404, { 0, 3, 4, -2 }, { 2, 3, 0, 1 }, MAZE_EVENT_BLOCK }, + { 401, { 1, 14, 5, 2 }, { 2, 3, 0, 1 }, MAZE_EVENT_POT }, + { 453, { 2, 4, -1, 4 }, { 2, 3, 0, 1 }, MAZE_EVENT_DRAIN }, + { 403, { 3, 6, -1, -1 }, { 2, 3, 0, 1 }, MAZE_EVENT_BRICK | MAZE_EVENT_PLANK }, + { 406, { -1, 0, -1, 5 }, { 2, 3, 0, 1 }, MAZE_EVENT_NONE }, + { 453, { -1, 8, -1, -1 }, { 2, 3, 0, 1 }, MAZE_EVENT_BRICK }, + { 406, { -1, 9, -1, 7 }, { 2, 3, 0, 1 }, MAZE_EVENT_NONE }, + { 401, { 1, -1, 10, 8 }, { 2, 3, 0, 1 }, MAZE_EVENT_RAT_NEST | MAZE_EVENT_SKULL }, + { 408, { 9, -1, 1, -1 }, { 2, 3, 0, 1 }, MAZE_EVENT_NONE }, + { 453, { 12, -1, -1, 1 }, { 2, 3, 0, 1 }, MAZE_EVENT_BRICK | MAZE_EVENT_STONE }, + { 408, { 13, -1, 11, -1 }, { 2, 3, 0, 1 }, MAZE_EVENT_BRICK }, + { 401, { 13, 20, 12, 13 }, { 3, 3, 0, 0 }, MAZE_EVENT_BRICK }, + { 453, { 16, 15, -1, 3 }, { 2, 3, 0, 1 }, MAZE_EVENT_BRICK | MAZE_EVENT_RAT_NEST }, + { 456, { -1, -1, -1, 14 }, { 2, 3, 0, 1 }, MAZE_EVENT_NONE }, + { 404, { -1, 17, 14, -1 }, { 2, 3, 0, 1 }, MAZE_EVENT_WEB | MAZE_EVENT_POT }, + { 401, { 18, -1, 19, 16 }, { 2, 3, 0, 1 }, MAZE_EVENT_BRICK }, + { 408, { -1, -1, 17, -1 }, { 2, 3, 0, 1 }, MAZE_EVENT_BRICK }, + { 403, { 17, -1, -1, -1 }, { 2, 3, 0, 1 }, MAZE_EVENT_HOLE | MAZE_EVENT_WEB }, + { 403, { 21, 22, -1, 13 }, { 2, 3, 0, 1 }, MAZE_EVENT_WEB | MAZE_EVENT_SKULL }, + { 404, { -1, -1, 20, -1 }, { 2, 3, 0, 1 }, MAZE_EVENT_NONE }, + { 406, { -1, 23, -1, 20 }, { 2, 3, 0, 1 }, MAZE_EVENT_NONE }, + { 404, { 24, 23, 23, 22 }, { 2, 2, 1, 1 }, MAZE_EVENT_RAT_NEST | MAZE_EVENT_BRICK }, + { 401, { -1, 1, 23, 25 }, { 2, 1, 0, 1 }, MAZE_EVENT_PUDDLE | MAZE_EVENT_POT | MAZE_EVENT_BRICK }, + { 407, { 29, 24, 28, 26 }, { 3, 3, 1, 1 }, MAZE_EVENT_NONE }, + { 401, { 27, 25, 23, -1 }, { 2, 3, 0, 1 }, MAZE_EVENT_SKULL }, + { 404, { -1, 28, 26, -1 }, { 2, 3, 0, 1 }, MAZE_EVENT_WEB | MAZE_EVENT_FALLEN_BLOCK }, + { 456, { -1, 25, -1, 27 }, { 2, 2, 0, 1 }, MAZE_EVENT_NONE }, + { 406, { -1, 30, -1, 25 }, { 2, 3, 0, 0 }, MAZE_EVENT_NONE }, + { 453, { -3, 30, -1, 29 }, { 2, 3, 0, 1 }, MAZE_EVENT_STONE | MAZE_EVENT_RAT_NEST | MAZE_EVENT_WEB }, + { 408, { -5, -1, -4, -1 }, { 2, 3, 0, 1 }, MAZE_EVENT_WEB | MAZE_EVENT_BRICK } + }; + + Catacombs _hardCatacombs[62] = { + { 401, { -1, 1, 2, 6 }, { 2, 3, 0, 1 }, MAZE_EVENT_BRICK }, + { 404, { 10, 11, 3, 0 }, { 2, 3, 0, 1 }, MAZE_EVENT_PUDDLE }, + { 404, { 0, 3, 4, -2 }, { 2, 3, 0, 1 }, MAZE_EVENT_BLOCK }, + { 401, { 1, 20, 5, 2 }, { 2, 0, 0, 1 }, MAZE_EVENT_POT }, + { 453, { 2, 4, -1, 4 }, { 2, 3, 0, 1 }, MAZE_EVENT_DRAIN }, + { 403, { 3, 6, -1, 4 }, { 2, 3, 0, 1 }, MAZE_EVENT_BRICK | MAZE_EVENT_PLANK }, + { 406, { -1, 0, -1, 5 }, { 2, 3, 0, 1 }, MAZE_EVENT_NONE }, + { 453, { -1, 8, -1, -1 }, { 2, 3, 0, 1 }, MAZE_EVENT_BRICK }, + { 406, { -1, 9, -1, 7 }, { 2, 3, 0, 1 }, MAZE_EVENT_NONE }, + { 401, { 1, -1, 10, 8 }, { 0, 3, 0, 1 }, MAZE_EVENT_RAT_NEST | MAZE_EVENT_SKULL }, + { 408, { 9, -1, 1, -1 }, { 2, 3, 0, 1 }, MAZE_EVENT_NONE }, + { 453, { 12, -1, -1, 1 }, { 2, 3, 0, 1 }, MAZE_EVENT_BRICK | MAZE_EVENT_STONE }, + { 408, { 13, -1, 11, -1 }, { 2, 3, 0, 1 }, MAZE_EVENT_BRICK }, + { 401, { 13, 21, 12, 13 }, { 3, 3, 0, 0 }, MAZE_EVENT_BRICK }, + { 453, { 16, 15, -1, 20 }, { 2, 3, 0, 2 }, MAZE_EVENT_RAT_NEST | MAZE_EVENT_BRICK }, + { 456, { -1, -1, -1, 14 }, { 2, 3, 0, 1 }, MAZE_EVENT_NONE }, + { 404, { -1, 17, 14, -1 }, { 2, 3, 0, 1 }, MAZE_EVENT_WEB | MAZE_EVENT_POT }, + { 401, { 18, -1, 19, 16 }, { 2, 3, 0, 1 }, MAZE_EVENT_BRICK }, + { 408, { -1, -1, 17, -1 }, { 2, 3, 0, 1 }, MAZE_EVENT_BRICK }, + { 403, { 17, -1, -1, -1 }, { 2, 3, 0, 1 }, MAZE_EVENT_HOLE | MAZE_EVENT_WEB }, + { 408, { 3, -1, 14, -1 }, { 1, 3, 3, 1 }, MAZE_EVENT_NONE }, + { 404, { 9, 30, 22, 13 }, { 0, 3, 0, 1 }, MAZE_EVENT_RAT_NEST }, + { 403, { 21, 23, -1, -1 }, { 2, 3, 0, 1 }, MAZE_EVENT_HOLE | MAZE_EVENT_WEB }, + { 401, { -1, -1, 24, 22 }, { 2, 3, 3, 1 }, MAZE_EVENT_BRICK }, + { 406, { -1, 26, -1, 23 }, { 2, 0, 0, 2 }, MAZE_EVENT_NONE }, + { 407, { 36, 33, 35, 34 }, { 3, 3, 1, 1 }, MAZE_EVENT_NONE }, + { 453, { 24, 27, -1, -1 }, { 1, 0, 0, 1 }, MAZE_EVENT_BRICK }, + { 403, { 26, -1, -1, 28 }, { 1, 3, 0, 0 }, MAZE_EVENT_BRICK | MAZE_EVENT_SKULL }, + { 404, { 27, 28, 28, 29 }, { 3, 2, 1, 2 }, MAZE_EVENT_NONE }, + { 408, { -1, -1, 28, -1 }, { 2, 3, 3, 1 }, MAZE_EVENT_BRICK }, + { 406, { -1, 31, -1, 21 }, { 2, 0, 0, 1 }, MAZE_EVENT_NONE }, + { 401, { 30, 33, 1, -1 }, { 1, 2, 1, 1 }, MAZE_EVENT_PUDDLE | MAZE_EVENT_POT }, + { 456, { -1, 31, -1, 33 }, { 2, 1, 0, 0 }, MAZE_EVENT_NONE }, + { 404, { 32, -1, 31, 25 }, { 3, 3, 1, 1 }, MAZE_EVENT_NONE }, + { 401, { 46, 25, 31, -1 }, { 2, 3, 0, 1 }, MAZE_EVENT_SKULL }, + { 401, { -1, 25, 41, -1 }, { 2, 2, 1, 1 }, MAZE_EVENT_BRICK | MAZE_EVENT_POT }, + { 406, { -1, 37, -1, 25 }, { 2, 3, 0, 0 }, MAZE_EVENT_NONE }, + { 453, { -3, 37, -1, 36 }, { 2, 3, 0, 1 }, MAZE_EVENT_STONE | MAZE_EVENT_RAT_NEST | MAZE_EVENT_WEB }, + { 408, { 57, -1, 54, -1 }, { 2, 3, 0, 1 }, MAZE_EVENT_NONE }, + { 408, { 40, -1, -4, -1 }, { 2, 3, 0, 1 }, MAZE_EVENT_BRICK | MAZE_EVENT_WEB }, + { 404, { 40, 40, 39, 53 }, { 1, 0, 0, 1 }, MAZE_EVENT_BLOCK | MAZE_EVENT_FALLEN_BLOCK }, + { 456, { -1, 35, -1, 42 }, { 2, 2, 0, 2 }, MAZE_EVENT_NONE }, + { 408, { 43, -1, 41, -1 }, { 1, 3, 3, 1 }, MAZE_EVENT_BRICK }, + { 406, { -1, 42, -1, 61 }, { 2, 0, 0, 1 }, MAZE_EVENT_NONE }, + { 403, { 58, 45, -1, -1 }, { 2, 3, 0, 1 }, MAZE_EVENT_BRICK | MAZE_EVENT_RAT_NEST }, + { 401, { 34, -1, 46, 44 }, { 0, 3, 0, 1 }, MAZE_EVENT_RAT_NEST | MAZE_EVENT_BRICK }, + { 404, { 45, -1, 34, 47 }, { 2, 3, 0, 1 }, MAZE_EVENT_WEB | MAZE_EVENT_FALLEN_BLOCK }, + { 406, { -1, 46, -1, 48 }, { 2, 3, 0, 1 }, MAZE_EVENT_NONE }, + { 403, { 49, 47, -1, -1 }, { 2, 3, 0, 1 }, MAZE_EVENT_BRICK | MAZE_EVENT_SKULL | MAZE_EVENT_WEB }, + { 408, { 50, -1, 48, -1 }, { 2, 3, 0, 1 }, MAZE_EVENT_BRICK }, + { 408, { 51, -1, 49, -1 }, { 2, 3, 0, 1 }, MAZE_EVENT_NONE }, + { 408, { 52, -1, 50, -1 }, { 2, 3, 0, 1 }, MAZE_EVENT_BRICK }, + { 408, { -1, -1, 51, -1 }, { 2, 3, 0, 1 }, MAZE_EVENT_BRICK }, + { 406, { -1, 40, -1, 54 }, { 2, 3, 0, 1 }, MAZE_EVENT_NONE }, + { 403, { 38, 53, -1, 55 }, { 2, 3, 0, 1 }, MAZE_EVENT_SKULL }, + { 453, { 56, 54, -1, -1 }, { 2, 3, 0, 1 }, MAZE_EVENT_BRICK | MAZE_EVENT_WEB }, + { 401, { 56, -5, 55, 56 }, { 3, 3, 0, 0 }, MAZE_EVENT_BRICK | MAZE_EVENT_SKULL }, + { 404, { -1, 57, 38, 57 }, { 2, 3, 0, 1 }, MAZE_EVENT_POT | MAZE_EVENT_BLOCK }, + { 404, { 59, 59, 44, 60 }, { 2, 3, 0, 1 }, MAZE_EVENT_NONE }, + { 404, { 59, 60, 59, 58 }, { 2, 3, 0, 1 }, MAZE_EVENT_NONE }, + { 404, { 61, 58, 59, 59 }, { 2, 3, 0, 1 }, MAZE_EVENT_NONE }, + { 404, { 34, 43, 60, 44 }, { 0, 3, 0, 1 }, MAZE_EVENT_NONE } + }; + +GamePhantom::GamePhantom(MADSEngine *vm) : Game(vm) { _surface = new MSurface(MADS_SCREEN_WIDTH, MADS_SCENE_HEIGHT); - _storyMode = STORYMODE_NAUGHTY; + _difficulty = DIFFICULTY_HARD; } void GamePhantom::startGame() { @@ -51,8 +150,7 @@ void GamePhantom::startGame() { void GamePhantom::initializeGlobals() { _globals.reset(); - - // TODO: Catacombs setup + setupCatacombs(); _player._facing = FACING_NORTH; _player._turnToFacing = FACING_NORTH; @@ -104,7 +202,7 @@ void GamePhantom::initializeGlobals() { _globals[kChristineToldEnvelope] = false; _globals[kLeaveAngelMusicOn] = false; _globals[kDoorIn409IsOpen] = false; - _globals[kUnknown] = false; + _globals[kPriestPistonPuke] = false; _globals[kCobwebIsCut] = false; _globals[kChristineIsInBoat] = false; _globals[kRightDoorIsOpen504] = false; @@ -161,27 +259,561 @@ void GamePhantom::checkShowDialog() { } } +void GamePhantom::genericObjectExamine() { + MADSAction &action = _scene._action; + int id = _objects.getIdFromDesc(action._activeAction._objectNameId); + + if (action.isAction(VERB_LOOK, NOUN_RED_FRAME)) + _vm->_dialogs->showItem(id, (_globals[kCurrentYear] == 1993) ? 802 : 842, 0); + else if (action.isAction(VERB_LOOK, NOUN_YELLOW_FRAME)) + _vm->_dialogs->showItem(id, (_globals[kCurrentYear] == 1993) ? 804 : 843, 0); + else if (action.isAction(VERB_LOOK, NOUN_BLUE_FRAME)) + _vm->_dialogs->showItem(id, (_globals[kCurrentYear] == 1993) ? 817 : 844, 0); + else if (action.isAction(VERB_LOOK, NOUN_GREEN_FRAME)) + _vm->_dialogs->showItem(id, (_globals[kCurrentYear] == 1993) ? 819 : 845, 0); + else if (action.isAction(VERB_LOOK, NOUN_LANTERN)) + _vm->_dialogs->showItem(id, (_globals[kLanternStatus] == 1) ? 831 : 801, 0); + else if (action.isAction(VERB_LOOK, NOUN_SMALL_NOTE)) + _vm->_dialogs->showItem(OBJ_SMALL_NOTE, 846, 2); + else if (action.isAction(VERB_LOOK, NOUN_PARCHMENT)) + _vm->_dialogs->showItem(OBJ_PARCHMENT, 812, 3); + else if (action.isAction(VERB_LOOK, NOUN_LETTER)) + _vm->_dialogs->showItem(OBJ_LETTER, 813, 4); + else if (action.isAction(VERB_LOOK, NOUN_NOTICE)) + _vm->_dialogs->showItem(OBJ_NOTICE, 814, 5); + else if (action.isAction(VERB_LOOK, NOUN_CRUMPLED_NOTE)) + _vm->_dialogs->showItem(OBJ_CRUMPLED_NOTE, 816, 6); + else if (action.isAction(VERB_LOOK, NOUN_LARGE_NOTE)) + _vm->_dialogs->showItem(OBJ_LARGE_NOTE, 818, 7); + else + _vm->_dialogs->showItem(id, 800 + id, 0); +} + void GamePhantom::doObjectAction() { - // TODO: Copied from Nebular - //Scene &scene = _scene; MADSAction &action = _scene._action; - //Dialogs &dialogs = *_vm->_dialogs; - //int id; - action._inProgress = false; + if ((_scene._currentSceneId >= 401) && (_scene._currentSceneId <= 456) + && (action.isObject(NOUN_RED_FRAME) || action.isObject(NOUN_YELLOW_FRAME) || action.isObject(NOUN_GREEN_FRAME) || action.isObject(NOUN_BLUE_FRAME)) + && action.isAction(VERB_PUT)) { + if (action.isTarget(NOUN_UNLUCKY_ADVENTURER)) { + _vm->_dialogs->show(35); + action._inProgress = false; + return; + } else if (action.isTarget(NOUN_HOLE)) { + _vm->_dialogs->show(36); + action._inProgress = false; + return; + } else if (action.isTarget(NOUN_GRATE)) { + _vm->_dialogs->show(37); + action._inProgress = false; + return; + } else if (action.isTarget(NOUN_WALL)) { + _vm->_dialogs->show(38); + action._inProgress = false; + return; + } + } + + if (action._lookFlag) { + _vm->_dialogs->show(810); + action._inProgress = false; + return; + } + + if (action.isAction(VERB_PUT, NOUN_RED_FRAME) || action.isAction(VERB_PUT, NOUN_BLUE_FRAME) || action.isAction(VERB_PUT, NOUN_YELLOW_FRAME) || action.isAction(VERB_PUT, NOUN_GREEN_FRAME)) { + _vm->_dialogs->show((action.isTarget(NOUN_PUDDLE)) ? 40124 : 40125); + action._inProgress = false; + return; + } + + if (action.isAction(VERB_WEAR, NOUN_WEDDING_RING)) { + if (_globals[kRingIsOnFinger]) + _vm->_dialogs->show(849); + else { + _vm->_dialogs->show(835); + _globals[kRingIsOnFinger] = true; + } + action._inProgress = false; + return; + } + + if (action.isAction(VERB_REMOVE, NOUN_WEDDING_RING)) { + if (!_globals[kRingIsOnFinger]) + _vm->_dialogs->show(848); + else { + _vm->_dialogs->show(836); + _globals[kRingIsOnFinger] = false; + } + action._inProgress = false; + return; + } + + if (action.isAction(VERB_LOOK, NOUN_ARCHWAY_TO_WEST) || action.isAction(VERB_LOOK, NOUN_ARCHWAY_TO_EAST) || action.isAction(VERB_LOOK, NOUN_ARCHWAY_TO_NORTH)) { + _vm->_dialogs->show(34); + action._inProgress = false; + return; + } + + if (action.isAction(VERB_ATTACK, NOUN_CHRISTINE)) { + _vm->_dialogs->show(33); + action._inProgress = false; + return; + } + + if (action.isAction(VERB_LOOK, NOUN_KEY)) { + _vm->_dialogs->showItem(OBJ_KEY, 800, 0); + action._inProgress = false; + return; + } + + if (action.isAction(VERB_LOOK, NOUN_SANDBAG)) { + _vm->_dialogs->showItem(OBJ_SANDBAG, 803, 0); + action._inProgress = false; + return; + } + + if (action.isAction(VERB_LOOK, NOUN_SMALL_NOTE) || action.isAction(VERB_READ, NOUN_SMALL_NOTE)) { + _vm->_dialogs->showItem(OBJ_SMALL_NOTE, 806, 2); + action._inProgress = false; + return; + } + + if (action.isAction(VERB_LOOK, NOUN_ROPE)) { + _vm->_dialogs->showItem(OBJ_ROPE, 807, 0); + action._inProgress = false; + return; + } + + if (action.isAction(VERB_LOOK, NOUN_SWORD)) { + _vm->_dialogs->showItem(OBJ_SWORD, 808, 0); + action._inProgress = false; + return; + } + + if (action.isAction(VERB_LOOK, NOUN_ENVELOPE) || action.isAction(VERB_READ, NOUN_ENVELOPE)) { + _vm->_dialogs->showItem(OBJ_ENVELOPE, 809, 0); + action._inProgress = false; + return; + } + + if (action.isAction(VERB_LOOK, NOUN_TICKET) || action.isAction(VERB_READ, NOUN_TICKET)) { + _vm->_dialogs->showItem(OBJ_TICKET, 810, 0); + action._inProgress = false; + return; + } + + if (action.isAction(VERB_LOOK, NOUN_PIECE_OF_PAPER) || action.isAction(VERB_READ, NOUN_PIECE_OF_PAPER)) { + _vm->_dialogs->showItem(OBJ_PIECE_OF_PAPER, 811, 1); + action._inProgress = false; + return; + } + + if (action.isAction(VERB_LOOK, NOUN_PARCHMENT) || action.isAction(VERB_READ, NOUN_PARCHMENT)) { + _vm->_dialogs->showItem(OBJ_PARCHMENT, 812, 3); + action._inProgress = false; + return; + } + + if (action.isAction(VERB_LOOK, NOUN_LETTER) || action.isAction(VERB_READ, NOUN_LETTER)) { + _vm->_dialogs->showItem(OBJ_LETTER, 813, 4); + action._inProgress = false; + return; + } + + if (action.isAction(VERB_LOOK, NOUN_NOTICE) || action.isAction(VERB_READ, NOUN_NOTICE)) { + _vm->_dialogs->showItem(OBJ_NOTICE, 814, 5); + action._inProgress = false; + return; + } + + if (action.isAction(VERB_LOOK, NOUN_BOOK) || action.isAction(VERB_READ, NOUN_BOOK)) { + _vm->_dialogs->showItem(OBJ_BOOK, 815, 0); + action._inProgress = false; + return; + } + + if (action.isAction(VERB_LOOK, NOUN_CRUMPLED_NOTE) || action.isAction(VERB_READ, NOUN_CRUMPLED_NOTE)) { + _vm->_dialogs->showItem(OBJ_CRUMPLED_NOTE, 816, 6); + action._inProgress = false; + return; + } + + if (action.isAction(VERB_LOOK, NOUN_LARGE_NOTE) || action.isAction(VERB_READ, NOUN_LARGE_NOTE)) { + _vm->_dialogs->showItem(OBJ_LARGE_NOTE, 818, 7); + action._inProgress = false; + return; + } + + if (action.isAction(VERB_LOOK, NOUN_MUSIC_SCORE) || action.isAction(VERB_READ, NOUN_MUSIC_SCORE)) { + _vm->_dialogs->showItem(OBJ_MUSIC_SCORE, 820, 0); + action._inProgress = false; + return; + } + + if (action.isAction(VERB_LOOK, NOUN_WEDDING_RING)) { + _vm->_dialogs->showItem(OBJ_WEDDING_RING, 821, 0); + action._inProgress = false; + return; + } + + if (action.isAction(VERB_LOOK, NOUN_CABLE_HOOK)) { + _vm->_dialogs->showItem(OBJ_CABLE_HOOK, 822, 0); + action._inProgress = false; + return; + } + + if (action.isAction(VERB_LOOK, NOUN_ROPE_WITH_HOOK)) { + _vm->_dialogs->showItem(OBJ_ROPE_WITH_HOOK, 823, 0); + action._inProgress = false; + return; + } + + if (action.isAction(VERB_LOOK, NOUN_OAR)) { + _vm->_dialogs->showItem(OBJ_OAR, 824, 0); + action._inProgress = false; + return; + } + + if (action.isAction(VERB_LOOK) && _objects.isInInventory(_objects.getIdFromDesc(action._activeAction._objectNameId))) { + genericObjectExamine(); + action._inProgress = false; + return; + } + + if (action.isAction(VERB_TURN_ON, NOUN_LANTERN)) { + if ((_globals[kLanternStatus] == 1) && !_trigger) + _vm->_dialogs->show(828); + else { + switch (_trigger) { + case 0: + _scene._sequences.addTimer(4, 1); + _globals[kLanternStatus] = 1; + _vm->_dialogs->spinObject(OBJ_LANTERN); + break; + + case 1: + _vm->_dialogs->show(825); + break; + + default: + break; + } + } + action._inProgress = false; + return; + } + + if (action.isAction(VERB_TURN_OFF, NOUN_LANTERN)) { + if ((_globals[kLanternStatus] == 0) && !_trigger) + _vm->_dialogs->show(829); + else if ((_scene._currentSceneId / 100) == 4) + _vm->_dialogs->show(826); + else { + switch (_trigger) { + case 0: + _scene._sequences.addTimer(4, 1); + _globals[kLanternStatus] = 0; + _vm->_dialogs->spinObject(OBJ_LANTERN); + break; + + case 1: + _vm->_dialogs->show(827); + break; + + default: + break; + } + } + action._inProgress = false; + return; + } + + if (action.isAction(VERB_OPEN, NOUN_ENVELOPE)) { + _objects.setRoom(OBJ_ENVELOPE, NOWHERE); + _objects.addToInventory(OBJ_TICKET); + _objects.addToInventory(OBJ_PIECE_OF_PAPER); + _vm->_dialogs->show(833); + action._inProgress = false; + return; + } + + if (action.isAction(VERB_ATTACH, NOUN_CABLE_HOOK, NOUN_ROPE)) { + if (!_objects.isInInventory(OBJ_ROPE)) + _vm->_dialogs->show(11438); + else { + _objects.setRoom(OBJ_CABLE_HOOK, NOWHERE); + _objects.setRoom(OBJ_ROPE, NOWHERE); + _objects.addToInventory(OBJ_ROPE_WITH_HOOK); + _vm->_dialogs->showItem(OBJ_ROPE_WITH_HOOK, 823, 0); + } + action._inProgress = false; + } } void GamePhantom::unhandledAction() { - // TODO + int messageId = 0; + int rndNum = _vm->getRandomNumber(1, 1000); + MADSAction &action = _scene._action; + + if (action.isAction(VERB_PUT, NOUN_CHANDELIER, NOUN_SEATS)) + _vm->_dialogs->show(10123); + else if (action.isAction(VERB_TAKE)) { + if (_objects.isInInventory(_objects.getIdFromDesc(action._activeAction._objectNameId))) + messageId = 25; + else { + if (rndNum <= 333) + messageId = 1; + else if (rndNum <= 666) + messageId = 2; + else + messageId = 3; + } + } else if (action.isAction(VERB_PUSH)) { + if (rndNum < 750) + messageId = 4; + else + messageId = 5; + } else if (action.isAction(VERB_PULL)) { + if (rndNum < 750) + messageId = 6; + else + messageId = 7; + } else if (action.isAction(VERB_OPEN)) { + if (rndNum <= 500) + messageId = 8; + else if (rndNum <= 750) + messageId = 9; + else + messageId = 10; + } else if (action.isAction(VERB_CLOSE)) { + if (rndNum <= 500) + messageId = 11; + else if (rndNum <= 750) + messageId = 12; + else + messageId = 13; + } else if (action.isAction(VERB_PUT)) { + if (_objects.isInInventory(_objects.getIdFromDesc(action._activeAction._objectNameId))) + messageId = 26; + else if (rndNum < 500) + messageId = 14; + else + messageId = 15; + } else if (action.isAction(VERB_TALK_TO)) { + if (rndNum <= 500) + messageId = 16; + else + messageId = 17; + } else if (action.isAction(VERB_GIVE)) { + if (_objects.isInInventory(_objects.getIdFromDesc(action._activeAction._objectNameId))) + messageId = 27; + else + messageId = 18; + } else if (action.isAction(VERB_THROW)) { + if (_objects.isInInventory(_objects.getIdFromDesc(action._activeAction._objectNameId))) + messageId = 19; + else + messageId = 28; + } else if (action.isAction(VERB_LOOK)) { + if (rndNum <= 333) + messageId = 20; + else if (rndNum <= 666) + messageId = 21; + else + messageId = 22; + } else if ((action.isAction(VERB_UNLOCK) || action.isAction(VERB_LOCK)) + && (action.isObject(NOUN_DOOR) || action.isObject(NOUN_LEFT_DOOR) || action.isObject(NOUN_MIDDLE_DOOR) || action.isObject(NOUN_RIGHT_DOOR) || action.isObject(NOUN_TRAP_DOOR))) + messageId = 32; + else if (!action.isAction(VERB_WALK_TO) && !action.isAction(VERB_WALK_ACROSS) && !action.isAction(VERB_WALK_DOWN) && !action.isAction(VERB_WALK_UP)) { + if (rndNum < 500) + messageId = 23; + else + messageId = 24; + } + + if (messageId) + _vm->_dialogs->show(messageId); +} + +void GamePhantom::stopWalker() { + int state = _globals[kWalkerConverseState]; + int command = _globals[kWalkerConverse]; + + _globals[kWalkerConverseNow] = state; + + if ((_player._facing != FACING_NORTHEAST) && (_player._facing != FACING_NORTHWEST)) { + state = 0; + command = 0; + } + + switch (state) { + case 1: + switch (command) { + case 1: + _player.addWalker(3, 0); + break; + + case 2: + case 3: + _player.addWalker(6, 0); + _player.addWalker(5, 0); + _player.addWalker(4, 0); + state = 2; + break; + + case 4: + _player.addWalker(8, 0); + _player.addWalker(4, 0); + state = 4; + break; + + default: + _player.addWalker(-2, 0); + state = 0; + break; + } + break; + + case 2: + case 3: + switch (command) { + case 2: + case 3: + if (state == 2) { + if (_vm->getRandomNumber(1, 30000) < 2000) { + _player.addWalker(10, 0); + _player.addWalker(7, 0); + state = 3; + } else + _player.addWalker(6, 0); + } else { + if (_vm->getRandomNumber(1, 30000) < 1000) { + _player.addWalker(6, 0); + _player.addWalker(7, 0); + state = 2; + } else + _player.addWalker(10, 0); + } + break; + + default: + _player.addWalker(-4, 0); + _player.addWalker(-5, 0); + if (state == 3) { + _player.addWalker(6, 0); + _player.addWalker(7, 0); + } + state = 1; + break; + } + break; + + case 4: + if (command == 4) + _player.addWalker(9, 0); + else { + _player.addWalker(-4, 0); + _player.addWalker(-8, 0); + state = 1; + } + break; + + case 0: + default: + switch (command) { + case 1: + case 2: + case 3: + case 4: + _player.addWalker(2, 0); + state = 1; + break; + + default: + stopWalkerBasic(); + break; + } + break; + } + + _globals[kWalkerConverse] = command; + _globals[kWalkerConverseState] = state; } void GamePhantom::step() { - if (_player._visible && _player._stepEnabled && !_player._moving && - (_player._facing == _player._turnToFacing)) { + if (_player._visible && !_globals[kStopWalkerDisabled] + && (_player._stepEnabled || (_vm->_gameConv->_running >= 0)) + && !_player._moving && (_player._facing == _player._turnToFacing) + && (_scene._frameStartTime >= (uint32)_globals[kWalkerTiming])) { + if (!_player._stopWalkerIndex) + stopWalker(); - // TODO + _globals[kWalkerTiming] += 6; } +} + +void GamePhantom::stopWalkerBasic() { + int rndVal = _vm->getRandomNumber(1, 30000); + + switch (_player._facing) { + case FACING_SOUTH: + if (rndVal < 500) { + int maxSteps = _vm->getRandomNumber(4, 10); + for (int i = 0; i < maxSteps; i++) + _player.addWalker((rndVal < 250) ? 1 : 2, 0); + } else if (rndVal < 750) { + for (int i = 0; i < 4; i++) + _player.addWalker(1, 0); + + _player.addWalker(0, 0); + + for (int i = 0; i < 4; i++) + _player.addWalker(2, 0); + + _player.addWalker(0, 0); + } + break; + + case FACING_SOUTHEAST: + case FACING_SOUTHWEST: + case FACING_NORTHEAST: + case FACING_NORTHWEST: + if (rndVal < 150) { + _player.addWalker(-1, 0); + _player.addWalker(1, 0); + for (int i = 0; i < 6; i++) + _player.addWalker(0, 0); + } + break; + + case FACING_EAST: + case FACING_WEST: + if (rndVal < 250) { + _player.addWalker(-1, 0); + int maxSteps = _vm->getRandomNumber(2, 6); + for (int i = 0; i < maxSteps; i++) + _player.addWalker(2, 0); + _player.addWalker(1, 0); + _player.addWalker(0, 0); + _player.addWalker(0, 0); + } else if (rndVal < 500) + _globals[kWalkerTiming] = (int)_scene._frameStartTime; + break; + + case FACING_NORTH: + if (rndVal < 250) { + _player.addWalker(-1, 0); + int maxSteps = _vm->getRandomNumber(3, 7); + for (int i = 0; i < maxSteps; i++) + _player.addWalker(2, 0); + _player.addWalker(1, 0); + _player.addWalker(0, 0); + } + break; + default: + break; + } } void GamePhantom::synchronize(Common::Serializer &s, bool phase1) { @@ -193,6 +825,116 @@ void GamePhantom::synchronize(Common::Serializer &s, bool phase1) { } } +void GamePhantom::enterCatacombs(bool val) { + setupCatacombs(); + + int var4, var2; + if (_scene._currentSceneId == 409) { + if (val) { + var4 = _globals[kCatacombs409b]; + var2 = _globals[kCatacombs409bFrom]; + } else { + var4 = _globals[kCatacombs409a]; + var2 = _globals[kCatacombs409aFrom]; + } + } else if (_scene._currentSceneId == 501) { + var4 = _globals[kCatacombs501]; + var2 = _globals[kCatacombs501From]; + } else { + var4 = _globals[kCatacombs309]; + var2 = _globals[kCatacombs309From]; + } + + newCatacombRoom(var4, var2); +} + +void GamePhantom::initCatacombs() { + _globals[kCatacombsRoom] = _globals[kCatacombsNextRoom]; +} + +void GamePhantom::setupCatacombs() { + switch (_difficulty) { + case DIFFICULTY_EASY: + _catacombs = _easyCatacombs; + _catacombSize = 32; + + _globals[kCatacombs309] = 2; + _globals[kCatacombs309From] = 3; + _globals[kCatacombs409a] = 30; + _globals[kCatacombs409aFrom] = 0; + _globals[kCatacombs409b] = 31; + _globals[kCatacombs409bFrom] = 2; + _globals[kCatacombs501] = 31; + _globals[kCatacombs501From] = 0; + break; + + case DIFFICULTY_HARD: + _catacombs = _hardCatacombs; + _catacombSize = 62; + + _globals[kCatacombs309] = 2; + _globals[kCatacombs309From] = 3; + _globals[kCatacombs409a] = 37; + _globals[kCatacombs409aFrom] = 0; + _globals[kCatacombs409b] = 39; + _globals[kCatacombs409bFrom] = 2; + _globals[kCatacombs501] = 56; + _globals[kCatacombs501From] = 1; + break; + } +} + +int GamePhantom::exitCatacombs(int dir) { + int scene = _globals[kCatacombsRoom]; + assert ((scene < _catacombSize) && (dir < 4)); + return (_catacombs[scene]._exit[dir]); +}; + +void GamePhantom::moveCatacombs(int dir) { + assert(_globals[kCatacombsRoom] = CLIP(_globals[kCatacombsRoom], 0, _catacombSize)); + assert(dir = CLIP(dir, 0, 3)); + + newCatacombRoom(_catacombs[_globals[kCatacombsRoom]]._fromDirection[dir], _catacombs[_globals[kCatacombsRoom]]._exit[dir]); +}; + +void GamePhantom::newCatacombRoom(int toRoom, int fromExit) { + _globals[kCatacombsNextRoom] = toRoom; + _globals[kCatacombsFrom] = fromExit & 0x03; + _globals[kCatacombsFlag] = fromExit & 0xFC; + + int newSceneNum = -1; + + if (toRoom < 0) { + switch (toRoom) { + case -5: + newSceneNum = 501; + break; + + case -4: + case -3: + newSceneNum = 409; + break; + + case -2: + newSceneNum = 309; + break; + + default: + error("Unexpected room in newCatacombRoom"); + } + } else { + newSceneNum = _catacombs[toRoom]._sceneNum; + _globals[81] = _catacombs[toRoom]._flags; + } + + if (_triggerSetupMode == SEQUENCE_TRIGGER_PREPARE) { + _player._walkOffScreenSceneId = newSceneNum; + } else { + _scene._reloadSceneFlag = true; + _scene._nextSceneId = newSceneNum; + } +} + } // End of namespace Phantom } // End of namespace MADS diff --git a/engines/mads/phantom/game_phantom.h b/engines/mads/phantom/game_phantom.h index 44b2321f42..2f0204f331 100644 --- a/engines/mads/phantom/game_phantom.h +++ b/engines/mads/phantom/game_phantom.h @@ -32,8 +32,9 @@ namespace MADS { namespace Phantom { -// TODO: Adapt for Phantom's difficulty setting -enum StoryMode { STORYMODE_NAUGHTY = 1, STORYMODE_NICE = 2 }; +enum Difficulty { + DIFFICULTY_HARD = 1, DIFFICULTY_MEDIUM = 2, DIFFICULTY_EASY = 3 +}; enum InventoryObject { OBJ_NONE = -1, @@ -64,8 +65,40 @@ enum InventoryObject { OBJ_OAR = 24 }; +enum MazeEvent { + MAZE_EVENT_NONE = 0, + MAZE_EVENT_PUDDLE = 0x0001, + MAZE_EVENT_RAT_NEST = 0x0002, + MAZE_EVENT_SKULL = 0x0004, + MAZE_EVENT_POT = 0x0008, + MAZE_EVENT_BRICK = 0x0010, + MAZE_EVENT_HOLE = 0x0020, + MAZE_EVENT_WEB = 0x0040, + MAZE_EVENT_PLANK = 0x0080, + MAZE_EVENT_DRAIN = 0x0100, + MAZE_EVENT_STONE = 0x0200, + MAZE_EVENT_BLOCK = 0x0400, + MAZE_EVENT_FALLEN_BLOCK = 0x0800 +}; + +struct Catacombs { + int _sceneNum; + int _exit[4]; + int _fromDirection[4]; + int _flags; +}; + class GamePhantom : public Game { friend class Game; + +private: + void genericObjectExamine(); + void stopWalker(); + void stopWalkerBasic(); + + Catacombs *_catacombs; + int _catacombSize; + protected: GamePhantom(MADSEngine *vm); @@ -78,7 +111,8 @@ protected: virtual void checkShowDialog(); public: PhantomGlobals _globals; - StoryMode _storyMode; + Difficulty _difficulty; + virtual Globals &globals() { return _globals; } @@ -89,20 +123,25 @@ public: virtual void step(); virtual void synchronize(Common::Serializer &s, bool phase1); -}; + void setupCatacombs(); + void enterCatacombs(bool val); + void initCatacombs(); + void moveCatacombs(int dir); + int exitCatacombs(int dir); + void newCatacombRoom(int fromRoom, int fromExit); +}; +// Section handlers aren't needed in ScummVM implementation class Section1Handler : public SectionHandler { public: Section1Handler(MADSEngine *vm) : SectionHandler(vm) {} - // TODO: Properly implement handler methods virtual void preLoadSection() {} virtual void sectionPtr2() {} virtual void postLoadSection() {} }; -// TODO: Properly implement handler classes typedef Section1Handler Section2Handler; typedef Section1Handler Section3Handler; typedef Section1Handler Section4Handler; diff --git a/engines/mads/phantom/globals_phantom.cpp b/engines/mads/phantom/globals_phantom.cpp index e0db0a1bb0..eea84762fe 100644 --- a/engines/mads/phantom/globals_phantom.cpp +++ b/engines/mads/phantom/globals_phantom.cpp @@ -28,12 +28,12 @@ namespace MADS { namespace Phantom { -PhantomGlobals::PhantomGlobals() - : Globals() { +PhantomGlobals::PhantomGlobals() : Globals() { // Initialize lists resize(210); _spriteIndexes.resize(30); _sequenceIndexes.resize(30); + _animationIndexes.resize(30); } void PhantomGlobals::synchronize(Common::Serializer &s) { @@ -41,6 +41,7 @@ void PhantomGlobals::synchronize(Common::Serializer &s) { _spriteIndexes.synchronize(s); _sequenceIndexes.synchronize(s); + _animationIndexes.synchronize(s); } diff --git a/engines/mads/phantom/globals_phantom.h b/engines/mads/phantom/globals_phantom.h index c23b53cdf5..f120df3c47 100644 --- a/engines/mads/phantom/globals_phantom.h +++ b/engines/mads/phantom/globals_phantom.h @@ -99,9 +99,20 @@ enum GlobalId { // Section #4 Variables kCatacombsRoom = 80, - // TODO + kCatacombsMisc = 81, + kCatacombsFlag = 82, + kCatacombsFrom = 83, + kCatacombs309 = 84, + kCatacombs409a = 85, + kCatacombs409b = 86, + kCatacombs501 = 87, + kCatacombs309From = 88, + kCatacombs409aFrom = 89, + kCatacombs409bFrom = 90, + kCatacombs501From = 91, + kCatacombsNextRoom = 92, kDoorIn409IsOpen = 93, - kUnknown = 94, // TODO + kPriestPistonPuke = 94, kCobwebIsCut = 95, // Section #5 Variables @@ -124,6 +135,7 @@ class PhantomGlobals : public Globals { public: SynchronizedList _spriteIndexes; SynchronizedList _sequenceIndexes; + SynchronizedList _animationIndexes; public: /** * Constructor diff --git a/engines/mads/phantom/phantom_scenes.cpp b/engines/mads/phantom/phantom_scenes.cpp index f7f4d154df..f7a7153fbe 100644 --- a/engines/mads/phantom/phantom_scenes.cpp +++ b/engines/mads/phantom/phantom_scenes.cpp @@ -29,6 +29,10 @@ #include "mads/phantom/game_phantom.h" #include "mads/phantom/phantom_scenes.h" #include "mads/phantom/phantom_scenes1.h" +#include "mads/phantom/phantom_scenes2.h" +#include "mads/phantom/phantom_scenes3.h" +#include "mads/phantom/phantom_scenes4.h" +#include "mads/phantom/phantom_scenes5.h" namespace MADS { @@ -37,8 +41,9 @@ namespace Phantom { SceneLogic *SceneFactory::createScene(MADSEngine *vm) { Scene &scene = vm->_game->_scene; - // TODO - //scene.addActiveVocab(NOUN_DROP); + // When changing from one section to the other, set the scaling velocity + if ((scene._nextSceneId / 100) != (scene._priorSceneId / 100)) + vm->_game->_player._scalingVelocity = true; switch (scene._nextSceneId) { // Scene group #1 (theater, stage and dressing rooms) @@ -47,107 +52,107 @@ SceneLogic *SceneFactory::createScene(MADSEngine *vm) { case 102: // music stands return new Scene102(vm); case 103: // below stage - return new DummyScene(vm); // TODO + return new Scene103(vm); case 104: // stage - return new DummyScene(vm); // TODO + return new Scene104(vm); case 105: // ground floor, storage room - return new DummyScene(vm); // TODO + return new Scene105(vm); case 106: // behind stage - return new DummyScene(vm); // TODO + return new Scene106(vm); case 107: // stage right wing - return new DummyScene(vm); // TODO + return new Scene107(vm); case 108: // stage left wing - return new DummyScene(vm); // TODO + return new Scene108(vm); case 109: // upper floor, staircase - return new DummyScene(vm); // TODO + return new Scene109(vm); case 110: // outside dressing rooms 1 - return new DummyScene(vm); // TODO + return new Scene110(vm); case 111: // outside dressing rooms 2 - return new DummyScene(vm); // TODO + return new Scene111(vm); case 112: // inside dressing room 1 - return new DummyScene(vm); // TODO + return new Scene112(vm); case 113: // inside dressing room 2 - return new DummyScene(vm); // TODO + return new Scene113(vm); case 114: // lower floor, storage room - return new DummyScene(vm); // TODO + return new Scene114(vm); case 150: // cutscene - return new DummyScene(vm); // TODO + return new Scene150(vm); // Scene group #2 (theater entrance, offices, balcony) case 201: // entrance / ticket office - return new DummyScene(vm); // TODO + return new Scene201(vm); case 202: // outside offices / paintings room - return new DummyScene(vm); // TODO + return new Scene202(vm); case 203: // office - return new DummyScene(vm); // TODO + return new Scene203(vm); case 204: // library - return new DummyScene(vm); // TODO + return new Scene204(vm); case 205: // upper floor, outside balcony boxes - return new DummyScene(vm); // TODO + return new Scene205(vm); case 206: // balcony box #1 - return new DummyScene(vm); // TODO + return new Scene206(vm); case 207: // balcony box #2 - return new DummyScene(vm); // TODO + return new Scene207(vm); case 208: // stage and balcony view - return new DummyScene(vm); // TODO + return new Scene208(vm); case 250: // cutscene - return new DummyScene(vm); // TODO + return new Scene250(vm); // Scene group #3 (catwalks, chandelier, lake / catacombs entrance) case 301: // catwalk #1 above stage - return new DummyScene(vm); // TODO + return new Scene301(vm); case 302: // catwalk #2 above stage - return new DummyScene(vm); // TODO + return new Scene302(vm); case 303: // above chandelier - return new DummyScene(vm); // TODO + return new Scene303(vm); case 304: // chandelier - return new DummyScene(vm); // TODO + return new Scene304(vm); case 305: // chandelier fight, phantom closeup - return new DummyScene(vm); // TODO + return new Scene305(vm); case 306: // chandelier #2 - return new DummyScene(vm); // TODO + return new Scene306(vm); case 307: // catwalk #3 above stage - return new DummyScene(vm); // TODO + return new Scene307(vm); case 308: // hidden staircase behind balcony box - return new DummyScene(vm); // TODO + return new Scene308(vm); case 309: // lake and archway - return new DummyScene(vm); // TODO + return new Scene309(vm); case 310: // lake - return new DummyScene(vm); // TODO + return new Scene310(vm); // Scene group #4 (labyrinth) case 401: // labyrinth room, 3 exits - return new DummyScene(vm); // TODO + return new Scene401(vm); case 403: // labyrinth room (big), 4 exits + 1 bricked door, left - return new DummyScene(vm); // TODO + return new Scene403(vm); case 404: // labyrinth room, 3 exits - return new DummyScene(vm); // TODO + return new Scene404(vm); case 406: // labyrinth room, 2 exits - return new DummyScene(vm); // TODO + return new Scene406(vm); case 407: // catacomb room / lake - return new DummyScene(vm); // TODO + return new Scene407(vm); case 408: // catacomb corridor - return new DummyScene(vm); // TODO + return new Scene408(vm); case 409: // catacomb room, door with switch panel - return new DummyScene(vm); // TODO + return new Scene409(vm); case 410: // skull switch panel - return new DummyScene(vm); // TODO + return new Scene410(vm); case 453: // Labyrinth room (big), 4 exits + 1 bricked door, right - return new DummyScene(vm); // TODO + return new Scene453(vm); case 456: // Labyrinth room, 2 exits - return new DummyScene(vm); // TODO + return new Scene456(vm); // Scene group #5 (Phantom's hideout) case 501: // catacombs, outside phantom's hideout, lake and boat - return new DummyScene(vm); // TODO + return new Scene501(vm); case 502: // push panel trap - return new DummyScene(vm); // TODO + return new Scene502(vm); case 504: // Phantom's hideout, church organ - return new DummyScene(vm); // TODO + return new Scene504(vm); case 505: // Phantom's hideout, sarcophagus - return new DummyScene(vm); // TODO + return new Scene505(vm); case 506: // catacomb room with ramp - return new DummyScene(vm); // TODO + return new Scene506(vm); default: error("Invalid scene %d called", scene._nextSceneId); @@ -170,12 +175,12 @@ Common::String PhantomScene::formAnimName(char sepChar, int suffixNum) { /*------------------------------------------------------------------------*/ void SceneInfoPhantom::loadCodes(MSurface &depthSurface, int variant) { - // The intro scenes do not have any codes - if (_sceneId >= 900) + Common::String ext = Common::String::format(".WW%d", variant); + Common::String fileName = Resources::formatName(RESPREFIX_RM, _sceneId, ext); + if (!Common::File::exists(fileName)) return; - Common::String ext = Common::String::format(".WW%d", variant); - File f(Resources::formatName(RESPREFIX_RM, _sceneId, ext)); + File f(fileName); MadsPack codesPack(&f); Common::SeekableReadStream *stream = codesPack.getItemStream(0); diff --git a/engines/mads/phantom/phantom_scenes.h b/engines/mads/phantom/phantom_scenes.h index c0a823ae06..a6a8395a2c 100644 --- a/engines/mads/phantom/phantom_scenes.h +++ b/engines/mads/phantom/phantom_scenes.h @@ -46,13 +46,19 @@ enum Verb { VERB_CLOSE = 0xB, VERB_THROW = 0xC, VERB_WALK_TO = 0xD, + VERB_ATTACK = 0x14, VERB_CLIMB_DOWN = 0x21, VERB_CLIMB_INTO = 0x22, VERB_CLIMB_THROUGH = 0x23, + VERB_EXIT = 0x34, VERB_EXIT_TO = 0x37, VERB_JUMP_INTO = 0x53, + VERB_LASSO = 0x59, + VERB_LOCK = 0x5D, VERB_LOOK_AT = 0x60, VERB_LOOK_THROUGH = 0x61, + VERB_READ = 0x7A, + VERB_REMOVE = 0x7C, VERB_TURN_OFF = 0x95, VERB_TURN_ON = 0x96, VERB_UNLOCK = 0x97, @@ -60,9 +66,18 @@ enum Verb { VERB_WALK_DOWN = 0x9A, VERB_WALK_THROUGH = 0x9B, VERB_WALK_UP = 0x9C, + VERB_WEAR = 0xA1, VERB_CLIMB_UP = 0xA5, VERB_WALK_ONTO = 0xA6, - VERB_WALK = 0xA7 + VERB_WALK = 0xA7, + VERB_ENTER = 0xEC, + VERB_WALK_BEHIND = 0xF3, + VERB_CLIMB = 0x120, + VERB_ATTACH = 0x131, + VERB_GRAPPLE = 0x133, + VERB_SIT_ON = 0x138, + VERB_SIT_IN = 0x13A, + VERB_WALK_DOWN_STAIRS_TO = 0x153 }; enum Noun { @@ -74,7 +89,6 @@ enum Noun { NOUN_ACT_CURTAIN = 0x11, NOUN_AISLE = 0x12, NOUN_APRON = 0x13, - NOUN_ATTACK = 0x14, NOUN_BACKSTAGE = 0x15, NOUN_BEAR_PROP = 0x16, NOUN_BLUE_FRAME = 0x17, @@ -103,7 +117,6 @@ enum Noun { NOUN_DRESSING_TABLE = 0x31, NOUN_ELEPHANT_PROP = 0x32, NOUN_ENVELOPE = 0x33, - NOUN_EXIT = 0x34, NOUN_EXIT_DOWN = 0x35, NOUN_EXIT_SIGN = 0x36, NOUN_EXIT_TO_BACKSTAGE = 0x38, @@ -138,11 +151,9 @@ enum Noun { NOUN_LAMP = 0x56, NOUN_LANTERN = 0x57, NOUN_LARGE_NOTE = 0x58, - NOUN_LASSO = 0x59, NOUN_LEG = 0x5A, NOUN_LETTER = 0x5B, NOUN_LIGHT_FIXTURE = 0x5C, - NOUN_LOCK = 0x5D, NOUN_LOCKING_RAIL = 0x5E, NOUN_LOCKRAIL = 0x5F, NOUN_MANNEQUINS = 0x62, @@ -169,9 +180,7 @@ enum Noun { NOUN_PROSCENIUM_ARCH = 0x77, NOUN_PURCHASE_LINES = 0x78, NOUN_RAILING = 0x79, - NOUN_READ = 0x7A, NOUN_RED_FRAME = 0x7B, - NOUN_REMOVE = 0x7C, NOUN_ROPE = 0x7D, NOUN_RUG = 0x7E, NOUN_SANDBAG = 0x7F, @@ -201,7 +210,6 @@ enum Noun { NOUN_WARDROBE = 0x9E, NOUN_WASTE_BASKET = 0x9F, NOUN_WATER_PIPE = 0xA0, - NOUN_WEAR = 0xA1, NOUN_WEDDING_RING = 0xA2, NOUN_YELLOW_FRAME = 0xA3, NOUN_PROP = 0xA4, @@ -273,14 +281,12 @@ enum Noun { NOUN_DECORATIVE_VASE = 0xE9, NOUN_MARBLE_COLUMN = 0xEA, NOUN_BOX_FIVE = 0xEB, - NOUN_ENTER = 0xEC, NOUN_BOX_SIX = 0xED, NOUN_BOX_SEVEN = 0xEE, NOUN_BOX_EIGHT = 0xEF, NOUN_BOX_NINE = 0xF0, NOUN_STEP = 0xF1, NOUN_PANEL = 0xF2, - NOUN_WALK_BEHIND = 0xF3, NOUN_MIDDLE_DOORWAY = 0xF4, NOUN_LIGHT = 0xF5, NOUN_CANDLE = 0xF6, @@ -325,7 +331,6 @@ enum Noun { NOUN_MIDDLE_LEVEL = 0x11D, NOUN_LOWER_LEVEL = 0x11E, NOUN_LADDER = 0x11F, - NOUN_CLIMB = 0x120, NOUN_CHANDELIER_TRAP = 0x121, NOUN_PIECE_OF_WOOD = 0x122, NOUN_CUT_HEMP = 0x123, @@ -342,16 +347,12 @@ enum Noun { NOUN_MONSIEUR_RICHARD = 0x12E, NOUN_JULIE2 = 0x12F, NOUN_CABLE_HOOK = 0x130, - NOUN_ATTACH = 0x131, NOUN_ROPE_WITH_HOOK = 0x132, - NOUN_GRAPPLE = 0x133, NOUN_OAR = 0x134, NOUN_ORGAN = 0x135, NOUN_SIT_AT = 0x136, NOUN_ORGAN_BENCH = 0x137, - NOUN_SIT_ON = 0x138, NOUN_LARGE_CHAIR = 0x139, - NOUN_SIT_IN = 0x13A, NOUN_SARCOPHAGUS = 0x13B, NOUN_SKULL = 0x13C, NOUN_SKULLS = 0x13D, @@ -376,7 +377,6 @@ enum Noun { NOUN_BOX_TEN = 0x150, NOUN_FOYER = 0x151, NOUN_WALK_DOWN_STAIRCASE = 0x152, - NOUN_WALK_DOWN_STAIRS_TO = 0x153, NOUN_HAT_RACK = 0x154, NOUN_VASE = 0x155, NOUN_CLOTHES_DUMMY = 0x156, @@ -484,20 +484,7 @@ protected: SceneInfoPhantom(MADSEngine *vm) : SceneInfo(vm) {} }; -// TODO: Temporary, remove once implemented properly -class DummyScene : public PhantomScene { -public: - DummyScene(MADSEngine *vm) : PhantomScene(vm) { - warning("Unimplemented scene"); - } - - virtual void setup() {} - virtual void enter() {} - virtual void actions() {} -}; - } // End of namespace Phantom - } // End of namespace MADS #endif /* MADS_PHANTOM_SCENES_H */ diff --git a/engines/mads/phantom/phantom_scenes1.cpp b/engines/mads/phantom/phantom_scenes1.cpp index 2d991fd3bc..f42b3e64b5 100644 --- a/engines/mads/phantom/phantom_scenes1.cpp +++ b/engines/mads/phantom/phantom_scenes1.cpp @@ -11,7 +11,7 @@ * 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 + * 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 @@ -22,6 +22,7 @@ #include "common/scummsys.h" #include "mads/mads.h" +#include "mads/conversations.h" #include "mads/scene.h" #include "mads/phantom/phantom_scenes.h" #include "mads/phantom/phantom_scenes1.h" @@ -31,72 +32,284 @@ namespace MADS { namespace Phantom { void Scene1xx::setAAName() { - // TODO - //int idx = 0; - //_game._aaName = Resources::formatAAName(idx); + _game._aaName = Resources::formatAAName(_globals[kTempInterface]); + _vm->_palette->setEntry(254, 43, 47, 51); } void Scene1xx::sceneEntrySound() { - // TODO + if (!_vm->_musicFlag) + return; + + if (_globals[kDoneBrieConv203] == 3) { + _vm->_sound->command(39); + } else { + switch (_scene->_nextSceneId) { + case 101: + if (!_game._visitedScenes._sceneRevisited) + _vm->_sound->command(38); + else + _vm->_sound->command(16); + break; + + case 102: + if (_scene->_priorSceneId == 104) + _vm->_sound->command(27); + else + _vm->_sound->command(16); + break; + + case 103: + if ((_globals[kJacquesStatus] == 2)) { + _vm->_sound->command(32); + _globals[kJacquesStatus] = 3; + } else + _vm->_sound->command(16); + break; + + case 104: + if ((_vm->_gameConv->_restoreRunning == 7) || (_scene->_priorSceneId == 301)) { + _vm->_sound->command(33); + } else if (!_globals[kRoom103104Transition] && !_globals[kObservedPhan104]) { + _vm->_sound->command(37); + _globals[kObservedPhan104] = true; + } else + _vm->_sound->command(16); + break; + + case 111: + if (_scene->_priorSceneId == 150) + _vm->_sound->command(38); + else if (_globals[kLeaveAngelMusicOn]) + _vm->_sound->command(34); + else + _vm->_sound->command(16); + break; + case 113: + if (_globals[kLeaveAngelMusicOn]) + _vm->_sound->command(34); + else if (_globals[kCurrentYear] == 1993) + _vm->_sound->command(36); + else + _vm->_sound->command(35); + break; + + default: + if ((_scene->_priorSceneId != 204) && (_scene->_nextSceneId != 150)) + _vm->_sound->command(16); + break; + } + } +} + +void Scene1xx::setPlayerSpritesPrefix() { + _vm->_sound->command(5); + + Common::String oldName = _game._player._spritesPrefix; + + if (!_game._player._forcePrefix) + _game._player._spritesPrefix = "RAL"; + + if (oldName != _game._player._spritesPrefix) + _game._player._spritesChanged = true; + + _game._player._scalingVelocity = true; } /*------------------------------------------------------------------------*/ Scene101::Scene101(MADSEngine *vm) : Scene1xx(vm) { - + _chanStatus = -1; + _wipeStatus = -1; + _callingStatus = -1; + _chandelierStatus = -1; + _callingFrame = -1; + _chandelierFrame = -1; + _convCounter = 0; + _talkCounter = -1; + _brieAnimId = 0; + _startWalkingFl = false; + _startWalking0Fl = false; + _anim0Running = false; + _anim1Running = false; + _startSittingFl = false; } void Scene101::synchronize(Common::Serializer &s) { Scene1xx::synchronize(s); - + s.syncAsSint16LE(_chanStatus); + s.syncAsSint16LE(_wipeStatus); + s.syncAsSint16LE(_callingStatus); + s.syncAsSint16LE(_chandelierStatus); + s.syncAsSint16LE(_callingFrame); + s.syncAsSint16LE(_chandelierFrame); + s.syncAsSint16LE(_convCounter); + s.syncAsSint16LE(_talkCounter); + s.syncAsSint16LE(_brieAnimId); + s.syncAsByte(_startWalkingFl); + s.syncAsByte(_startWalking0Fl); + s.syncAsByte(_anim0Running); + s.syncAsByte(_anim1Running); + s.syncAsByte(_startSittingFl); } void Scene101::setup() { - //setPlayerSpritesPrefix(); + setPlayerSpritesPrefix(); setAAName(); + _scene->addActiveVocab(NOUN_MONSIEUR_BRIE); } void Scene101::enter() { - // TODO + _vm->_disableFastwalk = true; + + if (_scene->_priorSceneId != RETURNING_FROM_DIALOG) { + _chanStatus = _wipeStatus = -1; + _startWalkingFl = _startWalking0Fl = false; + _anim0Running = _anim1Running = false; + _startSittingFl = false; + } + + // Load Dialogs + _vm->_gameConv->get(0); + _vm->_gameConv->get(1); if (_globals[kCurrentYear] == 1993) { _globals._spriteIndexes[0] = _scene->_sprites.addSprites(formAnimName('z', -1)); - // TODO - //_scene->_sequences.setDepth(_globals._sequenceIndexes[0], 14); + _globals._sequenceIndexes[0] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[0], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[0], 14); } else { - // TODO + _scene->_hotspots.activate(NOUN_CHANDELIER, false); + } + + if (_globals[kBrieTalkStatus] == 0) { + _game._player.firstWalk(Common::Point(-20, 75), FACING_EAST, Common::Point(18, 79), FACING_EAST, true); + _callingStatus = 0; + _chandelierStatus = 3; + _game._player.setWalkTrigger(50); + + _globals._animationIndexes[1] = _scene->loadAnimation(formAnimName('b', 9), 1); + _globals._animationIndexes[0] = _scene->loadAnimation(formAnimName('b', 8), 1); + + _anim0Running = true; + _anim1Running = true; + + _brieAnimId = _scene->_dynamicHotspots.add(NOUN_MONSIEUR_BRIE, VERB_WALKTO, SYNTAX_SINGULAR_MASC, EXT_NONE, Common::Rect(0, 0, 0, 0)); + _scene->_dynamicHotspots[_brieAnimId]._articleNumber = PREP_ON; + _scene->_dynamicHotspots.setPosition(_brieAnimId, Common::Point(490, 119), FACING_NONE); + _scene->setDynamicAnim(_brieAnimId, _globals._animationIndexes[0], 0); + _scene->setDynamicAnim(_brieAnimId, _globals._animationIndexes[0], 1); + _scene->setDynamicAnim(_brieAnimId, _globals._animationIndexes[0], 2); + _scene->setDynamicAnim(_brieAnimId, _globals._animationIndexes[0], 3); + _scene->setDynamicAnim(_brieAnimId, _globals._animationIndexes[0], 4); + + int tmpIdx = _scene->_dynamicHotspots.add(NOUN_MONSIEUR_BRIE, VERB_WALKTO, SYNTAX_SINGULAR_MASC, EXT_NONE, Common::Rect(0, 0, 0, 0)); + _scene->_dynamicHotspots[tmpIdx]._articleNumber = PREP_ON; + _scene->_dynamicHotspots.setPosition(tmpIdx, Common::Point(25, 80), FACING_NONE); + _scene->setDynamicAnim(tmpIdx, _globals._animationIndexes[1], 1); + _scene->setDynamicAnim(tmpIdx, _globals._animationIndexes[1], 2); + + _talkCounter = 0; + } else if (_globals[kBrieTalkStatus] == 1) { + _globals._animationIndexes[1] = _scene->loadAnimation(formAnimName('b', 9), 1); + _brieAnimId = _scene->_dynamicHotspots.add(NOUN_MONSIEUR_BRIE, VERB_WALKTO, SYNTAX_SINGULAR_MASC, EXT_NONE, Common::Rect(0, 0, 0, 0)); + _scene->_dynamicHotspots[_brieAnimId]._articleNumber = PREP_ON; + _scene->setDynamicAnim(_brieAnimId, _globals._animationIndexes[1], 1); + _scene->setDynamicAnim(_brieAnimId, _globals._animationIndexes[1], 2); + _anim1Running = true; + _talkCounter = 0; + _chandelierStatus = 3; + + if (_vm->_gameConv->_restoreRunning == 1) { + _vm->_gameConv->run(1); + _vm->_gameConv->exportPointer(&_globals[kPlayerScore]); + _chandelierStatus = 4; + _scene->setAnimFrame(_globals._animationIndexes[1], 25); + } + } else if (_scene->_priorSceneId == 202) { + if (_globals[kJacquesStatus] == 1) + _globals[kJacquesStatus] = 2; + _game._player.firstWalk(Common::Point(-20, 75), FACING_EAST, Common::Point(18, 79), FACING_EAST, true); + } else if ((_scene->_priorSceneId == 102) || (_scene->_priorSceneId != RETURNING_FROM_LOADING)) { + _game._player.firstWalk(Common::Point(655, 130), FACING_WEST, Common::Point(625, 127), FACING_WEST, true); + _scene->setCamera(Common::Point(320, 0)); } - // TODO + sceneEntrySound(); } void Scene101::step() { - // TODO + if (_anim0Running) + handleAnimation0(); + + if ((_globals[kWalkerConverse] == 2) || (_globals[kWalkerConverse] == 3)) { + ++_convCounter; + if (_convCounter > 200) + _globals[kWalkerConverse] = _vm->getRandomNumber(1, 4); + } + + if (_anim1Running) { + handleAnimation1(); + + if (_scene->getAnimFrame(_globals._animationIndexes[1]) == 80) { + _game._player._stepEnabled = true; + _game._player.setWalkTrigger(55); + } + } + + if (_scene->_posAdjust.x > 200 && !_startSittingFl && (_globals[kBrieTalkStatus] != 2)) { + _startSittingFl = true; + _game._player.walk(Common::Point(490, 119), FACING_NORTHEAST); + _game._player._stepEnabled = false; + _game._player.setWalkTrigger(55); + _chandelierStatus = 4; + } + + if (_game._trigger == 55) { + _game._player._stepEnabled = true; + _vm->_gameConv->run(1); + _vm->_gameConv->exportPointer(&_globals[kPlayerScore]); + _chandelierFrame = -1; + _talkCounter = 0; + } + + if (_game._trigger == 50) { + _vm->_gameConv->run(0); + _callingStatus = 1; + } } void Scene101::preActions() { if (_action.isAction(VERB_EXIT_TO, NOUN_ORCHESTRA_PIT)) { - // TODO: Handle Brie - _game._player._walkOffScreenSceneId = 102; + if ((_globals[kBrieTalkStatus] == 2) || _startWalkingFl) { + _game._player._walkOffScreenSceneId = 102; + _globals[kBrieTalkStatus] = 2; + } else { + _vm->_gameConv->run(0); + _game._player._needToWalk = false; + } } else if (_action.isAction(VERB_EXIT_TO, NOUN_GRAND_FOYER)) { - // TODO: Handle Brie - _game._player._walkOffScreenSceneId = 202; - } else if (_action.isAction(VERB_TAKE, NOUN_MONSIEUR_BRIE)) { - _vm->_dialogs->show(10121); - } else if (_action.isAction(VERB_TALK_TO, NOUN_MONSIEUR_BRIE)) { - if (_globals[kBrieTalkStatus] == 2) + if ((_globals[kBrieTalkStatus] == 2) || _startWalkingFl) + _game._player._walkOffScreenSceneId = 202; + else { + _vm->_gameConv->run(0); _game._player._needToWalk = false; - } - - // TODO + } + } else if (_action.isAction(VERB_TAKE, NOUN_MONSIEUR_BRIE)) + _vm->_dialogs->show(10121); + else if (_action.isAction(VERB_TALK_TO, NOUN_MONSIEUR_BRIE) && (_globals[kBrieTalkStatus] == 2)) + _game._player._needToWalk = false; } void Scene101::actions() { - // TODO: Brie conversation - - // TODO: Look around - - if (_action.isAction(VERB_LOOK) || _action.isAction(VERB_LOOK_AT)) { + if (_vm->_gameConv->_running == 0) + handleConversation0(); + else if (_vm->_gameConv->_running == 1) + handleConversation1(); + else if (_action._lookFlag) { + if (_globals[kCurrentYear] == 1993) + _vm->_dialogs->show(10110); + else + _vm->_dialogs->show(10111); + } else if (_action.isAction(VERB_LOOK) || _action.isAction(VERB_LOOK_AT)) { if (_action.isObject(NOUN_AISLE)) { _vm->_dialogs->show(10112); } else if (_action.isObject(NOUN_CHANDELIER)) { @@ -106,8 +319,10 @@ void Scene101::actions() { } else if (_action.isObject(NOUN_SIDE_WALL)) { _vm->_dialogs->show(10115); } else if (_action.isObject(NOUN_SEATS)) { - // TODO: Finish this - _vm->_dialogs->show(10116); + if ((_globals[kBrieTalkStatus] > 1) || _startWalkingFl) + _vm->_dialogs->show(10119); + else + _vm->_dialogs->show(10116); } else if (_action.isObject(NOUN_GRAND_FOYER)) { _vm->_dialogs->show(10117); } else if (_action.isObject(NOUN_ORCHESTRA_PIT)) { @@ -115,64 +330,358 @@ void Scene101::actions() { } else if (_action.isObject(NOUN_MONSIEUR_BRIE)) { _vm->_dialogs->show(10120); } - - _game._player._stepEnabled = true; } else if (_action.isAction(VERB_TALK_TO, NOUN_MONSIEUR_BRIE)) { if (_globals[kBrieTalkStatus] == 2) _vm->_dialogs->show(10122); - _game._player._stepEnabled = true; - } else if (_action.isAction(VERB_TAKE, NOUN_MONSIEUR_BRIE)) { - _game._player._stepEnabled = true; + } else if (!_action.isAction(VERB_TAKE, NOUN_MONSIEUR_BRIE)) + return; + + _action._inProgress = false; +} + +void Scene101::handleConversation0() { + _vm->_gameConv->setHeroTrigger(90); + + if (_game._trigger == 90) { + _globals[kBrieTalkStatus] = 1; + _startWalking0Fl = true; + } +} + +void Scene101::handleConversation1() { + if ((_action._activeAction._verbId >= 0) && (_action._activeAction._verbId <= 27)) { + bool interlocutorFl = false; + + if (_game._trigger == 60) { + switch (_action._activeAction._verbId) { + case 0: + _chandelierStatus = 6; + _wipeStatus = 2; + break; + + case 1: + _chandelierStatus = 2; + _chanStatus = 9; + break; + + case 4: + _chandelierStatus = 0; + _chanStatus = -1; + _wipeStatus = -1; + break; + + case 8: + case 10: + case 18: + case 22: + case 24: + _startWalkingFl = true; + _chanStatus = -1; + _wipeStatus = -1; + _globals[kWalkerConverse] = 0; + _vm->_gameConv->setInterlocutorTrigger(105); + interlocutorFl = true; + break; + + case 12: + _chandelierStatus = 5; + _chanStatus = -1; + _wipeStatus = -1; + break; + + default: + break; + } + } + + if (!interlocutorFl) + _vm->_gameConv->setInterlocutorTrigger(60); + + _vm->_gameConv->setHeroTrigger(70); + + _talkCounter = 0; + + if (_game._trigger == 60) { + if (!_startWalkingFl) + _globals[kWalkerConverse] = _vm->getRandomNumber(1, 4); + + _chandelierStatus = 2; + } else if ((_game._trigger == 70) && !_startWalkingFl) { + _chandelierStatus = 4; + _chanStatus = -1; + _wipeStatus = -1; + if (!_startWalkingFl) + _globals[kWalkerConverse] = _vm->getRandomNumber(2, 3); + + _convCounter = 0; + } + } +} + +void Scene101::handleAnimation0() { + int resetFrame; + + if (_scene->getAnimFrame(_globals._animationIndexes[0]) != _callingFrame) { + _callingFrame = _scene->getAnimFrame(_globals._animationIndexes[0]); + resetFrame = -1; + switch (_callingFrame) { + case 1: + case 9: + case 12: + if (_callingStatus == 1) { + if (_callingFrame == 9) { + if (_startWalking0Fl) { + resetFrame = 13; + _callingStatus = 3; + } else + _callingStatus = 2; + } else + resetFrame = 1; + } + + if (_callingStatus == 0) { + if (_startWalking0Fl) { + resetFrame = 60; + _callingStatus = 3; + } else + resetFrame = 0; + } + + if (_callingStatus == 2) { + if (_startWalking0Fl) { + resetFrame = 13; + _callingStatus = 3; + } else { + ++_talkCounter; + + if (_talkCounter < 18) { + if (_vm->getRandomNumber(1, 2) == 1) + resetFrame = 7; + else + resetFrame = 10; + } else { + resetFrame = 54; + _callingStatus = 0; + } + } + } + break; + + case 53: + _anim0Running = false; + _scene->freeAnimation(0); + break; + + case 59: + if (_startWalking0Fl) { + resetFrame = 60; + _callingStatus = 3; + } else { + resetFrame = 0; + _callingStatus = 0; + } + break; + + case 66: + resetFrame = 24; + break; + } + + if (resetFrame >= 0) { + _scene->setAnimFrame(_globals._animationIndexes[0], resetFrame); + _callingFrame = resetFrame; + } + } +} + +void Scene101::handleAnimation1() { + if (_scene->getAnimFrame(_globals._animationIndexes[1]) == _chandelierFrame) + return; + + _chandelierFrame = _scene->getAnimFrame(_globals._animationIndexes[1]); + int resetFrame = -1; + switch (_chandelierFrame) { + case 1: + if (_chandelierStatus == 3) + resetFrame = 0; + break; + + case 11: + case 14: + case 17: + case 19: + case 26: + case 44: + case 333: + if (_talkCounter == _chanStatus) { + _chandelierStatus = 0; + ++_talkCounter; + _chanStatus = -1; + } + + if (_talkCounter == _wipeStatus) { + _chandelierStatus = 6; + ++_talkCounter; + _wipeStatus = -1; + } + + if (_startWalkingFl) { + if (_vm->_gameConv->_running == 1) { + if (_talkCounter > 13) + _chandelierStatus = 1; + } else + _chandelierStatus = 1; + } + + switch (_chandelierStatus) { + case 0: + resetFrame = 27; + _chandelierStatus = 2; + break; + + case 1: + _globals[kBrieTalkStatus] = 2; + resetFrame = 45; + if (_vm->_gameConv->_running == 1) + _vm->_gameConv->stop(); + _scene->_dynamicHotspots.remove(_brieAnimId); + _game._player._stepEnabled = false; + break; + + case 2: + ++_talkCounter; + if (_talkCounter < 15) { + switch (_vm->getRandomNumber(1, 3)) { + case 1: + resetFrame = 12; + break; + + case 2: + resetFrame = 14; + break; + + case 3: + resetFrame = 17; + } + } else { + _chandelierStatus = 4; + resetFrame = 25; + } + break; + + case 4: + resetFrame = 25; + break; + + case 5: + resetFrame = 21; + _chandelierStatus = 2; + break; + + case 6: + resetFrame = 316; + _chandelierStatus = 2; + break; + + default: + break; + } + break; + + case 315: + _scene->freeAnimation(1); + break; + } + + if (resetFrame >= 0) { + _scene->setAnimFrame(_globals._animationIndexes[1], resetFrame); + _chandelierFrame = resetFrame; } } /*------------------------------------------------------------------------*/ Scene102::Scene102(MADSEngine *vm) : Scene1xx(vm) { - _animRunningFl = false; + _anim0Running = false; } void Scene102::synchronize(Common::Serializer &s) { Scene1xx::synchronize(s); - s.syncAsByte(_animRunningFl); + s.syncAsByte(_anim0Running); } void Scene102::setup() { - //setPlayerSpritesPrefix(); + setPlayerSpritesPrefix(); setAAName(); } void Scene102::enter() { - _animRunningFl = false; + _anim0Running = false; _globals._spriteIndexes[2] = _scene->_sprites.addSprites(formAnimName('x', 0)); _globals._spriteIndexes[3] = _scene->_sprites.addSprites("*RAL86"); if (_globals[kCurrentYear] == 1993) { _globals._spriteIndexes[0] = _scene->_sprites.addSprites(formAnimName('z', -1)); - // TODO - //_scene->_sequences.setDepth(_globals._sequenceIndexes[0], 14); + _scene->drawToBackground(_globals._spriteIndexes[0], 1, Common::Point(-32000, -32000), 0, 100); + _scene->_sequences.setDepth(_globals._sequenceIndexes[0], 14); } else { - // TODO + _scene->_hotspots.activate(NOUN_CHANDELIER, false); } if (_scene->_priorSceneId == 101) { _game._player._playerPos = Common::Point(97, 79); _game._player._facing = FACING_SOUTHEAST; - // TODO + _globals._sequenceIndexes[2] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[2], false, 4); _game._player.walk(Common::Point(83, 87), FACING_SOUTHEAST); _scene->_sequences.setDepth(_globals._sequenceIndexes[2], 14); } else if (_scene->_priorSceneId == 104) { // Player fell from pit -> death - // TODO - } else if (_scene->_priorSceneId == 103 || _scene->_priorSceneId != -1) { + Common::Point deathPos = Common::Point(0, 0); + int deathScale = 0; + int deathDepth = 0; + _game._player._stepEnabled = false; + _game._player._visible = false; + + switch (_globals[36]) { + case 0: + deathPos = Common::Point(221, 57); + deathScale = 50; + deathDepth = 14; + break; + + case 1: + deathPos = Common::Point(219, 85); + deathScale = 60; + deathDepth = 6; + break; + + case 2: + deathPos = Common::Point(257, 138); + deathScale = 76; + deathDepth = 1; + break; + + default: + break; + } + _scene->_userInterface.emptyConversationList(); + _scene->_userInterface.setup(kInputConversation); + _globals._sequenceIndexes[3] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[3], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[3], deathDepth); + _scene->_sequences.setPosition(_globals._sequenceIndexes[3], deathPos); + _scene->_sequences.setScale(_globals._sequenceIndexes[3], deathScale); + _scene->_sequences.addTimer(120, 65); + _globals._sequenceIndexes[2] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[2], false, 4); + _scene->_sequences.setDepth(_globals._sequenceIndexes[2], 14); + } else if (_scene->_priorSceneId == 103 || _scene->_priorSceneId != RETURNING_FROM_LOADING) { _game._player._playerPos = Common::Point(282, 145); _game._player._facing = FACING_WEST; - _animRunningFl = true; - // TODO: Door closing animation + _anim0Running = true; + _globals._animationIndexes[0] = _scene->loadAnimation(formAnimName('d', 1), 60); } else if (_scene->_priorSceneId == -1) { - // TODO + _globals._sequenceIndexes[2] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[2], false, 4); _scene->_sequences.setDepth(_globals._sequenceIndexes[2], 14); } @@ -180,52 +689,56 @@ void Scene102::enter() { } void Scene102::step() { - if (_game._trigger == 60) { // Door closes - // TODO - _animRunningFl = false; - } else if (_game._trigger == 65) { // Death - // TODO - _scene->_currentSceneId = 104; + if (_game._trigger == 60) { + // Door closes + _globals._sequenceIndexes[2] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[2], false, 4); + _scene->_sequences.setDepth(_globals._sequenceIndexes[2], 14); + _anim0Running = false; + } else if (_game._trigger == 65) { + // Death + if (_globals[kDeathLocation] == 0) + _vm->_dialogs->show(10232); + else + _vm->_dialogs->show(10229); + + _vm->_sound->command(16); + _scene->_nextSceneId = 104; } } void Scene102::preActions() { - if (_action.isAction(VERB_OPEN, NOUN_ORCHESTRA_DOOR) || _action.isAction(VERB_PUSH, NOUN_ORCHESTRA_DOOR)) { + if (_action.isAction(VERB_OPEN, NOUN_ORCHESTRA_DOOR) || _action.isAction(VERB_PUSH, NOUN_ORCHESTRA_DOOR)) _game._player.walk(Common::Point(282, 145), FACING_EAST); - } } void Scene102::actions() { if (_action.isAction(VERB_WALK_DOWN, NOUN_AISLE)) { _scene->_nextSceneId = 101; - _game._player._stepEnabled = true; - } - - if (_action.isAction(VERB_WALK_THROUGH, NOUN_ORCHESTRA_DOOR) || + } else if (_action.isAction(VERB_WALK_THROUGH, NOUN_ORCHESTRA_DOOR) || _action.isAction(VERB_PUSH, NOUN_ORCHESTRA_DOOR) || _action.isAction(VERB_OPEN, NOUN_ORCHESTRA_DOOR)) { - if (_animRunningFl) { - // TODO + if (_anim0Running) { + _scene->_sequences.addTimer(15, 70); + _game._player._stepEnabled = false; } else { - _scene->_nextSceneId = 103; // FIXME: temporary HACK - remove! - switch (_game._trigger) { case 70: // try again case 0: - // TODO + _scene->deleteSequence(_globals._sequenceIndexes[2]); + _globals._animationIndexes[0] = _scene->loadAnimation(formAnimName('d', 0), 1); + _game._player._stepEnabled = false; + _game._player._visible = false; break; case 1: _scene->_nextSceneId = 103; break; + default: + break; } } - - _game._player._stepEnabled = true; - } - - // TODO: Look around - - if (_action.isAction(VERB_LOOK) || _action.isAction(VERB_LOOK_AT)) { + } else if (_action._lookFlag) + _vm->_dialogs->show(10210); + else if (_action.isAction(VERB_LOOK) || _action.isAction(VERB_LOOK_AT)) { if (_action.isObject(NOUN_PIT)) _vm->_dialogs->show(10211); else if (_action.isObject(NOUN_SEATS)) @@ -263,18 +776,8779 @@ void Scene102::actions() { _vm->_dialogs->show(10227); else if (_action.isObject(NOUN_CHANDELIER)) _vm->_dialogs->show(10231); + } else if (_action.isAction(VERB_CLOSE, NOUN_ORCHESTRA_DOOR)) + _vm->_dialogs->show(10228); + + _game._player._stepEnabled = false; +} + +/*------------------------------------------------------------------------*/ + +Scene103::Scene103(MADSEngine *vm) : Scene1xx(vm) { + _jacquesAction = -1; + _lastRandom = -1; + _standPosition = -1; + _hotspotPrompt1 = -1; + _hotspotPrompt2 = -1; + _hotspotPrompt3 = -1; + _hotspotPrompt4 = -1; + _hotspotPrompt5 = -1; + _hotspotRightFloor1 = -1; + _hotspotRightFloor2 = -1; + _hotspotLeftFloor1 = -1; + _hotspotLeftFloor2 = -1; + _hotspotGentleman = -1; + _convCount = -1; + _lastStairFrame = -1; + _lastJacquesFrame = -1; + _talkCount = -1; + + _anim0ActvFl = false; + _anim1ActvFl = false; + _anim2ActvFl = false; + _anim3ActvFl = false; + _anim4ActvFl = false; + _anim5ActvFl = false; + _anim6ActvFl = false; + _climbThroughTrapFl = false; + _guardFrameFl = false; + _sitFl = false; +} + +void Scene103::synchronize(Common::Serializer &s) { + Scene1xx::synchronize(s); + + s.syncAsSint16LE(_jacquesAction); + s.syncAsSint16LE(_lastRandom); + s.syncAsSint16LE(_standPosition); + s.syncAsSint16LE(_hotspotPrompt1); + s.syncAsSint16LE(_hotspotPrompt2); + s.syncAsSint16LE(_hotspotPrompt3); + s.syncAsSint16LE(_hotspotPrompt4); + s.syncAsSint16LE(_hotspotPrompt5); + s.syncAsSint16LE(_hotspotRightFloor1); + s.syncAsSint16LE(_hotspotRightFloor2); + s.syncAsSint16LE(_hotspotLeftFloor1); + s.syncAsSint16LE(_hotspotLeftFloor2); + s.syncAsSint16LE(_convCount); + s.syncAsSint16LE(_lastStairFrame); + + s.syncAsByte(_anim0ActvFl); + s.syncAsByte(_anim1ActvFl); + s.syncAsByte(_anim2ActvFl); + s.syncAsByte(_anim3ActvFl); + s.syncAsByte(_anim4ActvFl); + s.syncAsByte(_anim5ActvFl); + s.syncAsByte(_anim6ActvFl); + s.syncAsByte(_climbThroughTrapFl); + s.syncAsByte(_guardFrameFl); + s.syncAsByte(_sitFl); +} + +void Scene103::setup() { + setPlayerSpritesPrefix(); + setAAName(); + + _scene->_variant = 0; + + if ((_globals[kPrompterStandStatus] == 1) || (_globals[kCurrentYear] == 1881)) { + _scene->_variant = 1; + if ((_globals[kJacquesStatus] == 0) && (_globals[kCurrentYear] == 1881)) + _scene->_variant = 2; + else if ((_globals[kJacquesStatus] >= 1) && (_globals[kCurrentYear] == 1881)) + _scene->_variant = 3; + } + + _scene->addActiveVocab(NOUN_PROMPTERS_STAND); + _scene->addActiveVocab(NOUN_JACQUES); + _scene->addActiveVocab(NOUN_GENTLEMAN); + _scene->addActiveVocab(VERB_CLIMB); +} + +void Scene103::enter() { + if (_scene->_priorSceneId != RETURNING_FROM_LOADING) { + _anim0ActvFl = false; + _anim1ActvFl = false; + _anim2ActvFl = false; + _anim3ActvFl = false; + _anim4ActvFl = false; + _anim5ActvFl = false; + _anim6ActvFl = false; + _climbThroughTrapFl = false; + _guardFrameFl = false; + _sitFl = false; + _jacquesAction = 1; + _lastRandom = 0; + _standPosition = 0; + } + + if (_globals[kJacquesStatus] >= 1) { + if (_game._objects.isInRoom(OBJ_KEY)) { + _globals._spriteIndexes[5] = _scene->_sprites.addSprites(formAnimName('x', 2)); + _globals._spriteIndexes[8] = _scene->_sprites.addSprites("*RRD_9"); + } + _globals._spriteIndexes[3] = _scene->_sprites.addSprites(formAnimName('f', 3)); + _globals._spriteIndexes[6] = _scene->_sprites.addSprites(formAnimName('c', 1)); + _globals._spriteIndexes[7] = _scene->_sprites.addSprites(formAnimName('f', 1)); + } else { + _globals._spriteIndexes[3] = _scene->_sprites.addSprites(formAnimName('f', 0)); + _globals._spriteIndexes[10] = _scene->_sprites.addSprites(formAnimName('a', 3)); + } + + _globals._spriteIndexes[9] = _scene->_sprites.addSprites(formAnimName('x', 3)); + _globals._spriteIndexes[11] = _scene->_sprites.addSprites(formAnimName('a', 2)); + _globals._spriteIndexes[12] = _scene->_sprites.addSprites(formAnimName('f', 2)); + _globals._spriteIndexes[0] = _scene->_sprites.addSprites(formAnimName('x', 0)); + _globals._spriteIndexes[1] = _scene->_sprites.addSprites(formAnimName('x', 1)); + _globals._spriteIndexes[2] = _scene->_sprites.addSprites("*RDR_6"); + + adjustRails(_scene->_variant); + + _scene->_hotspots.activate(NOUN_JACQUES, false); + _scene->_hotspots.activate(NOUN_KEY, false); + + _vm->_gameConv->get(12); + + if (_globals[kTrapDoorStatus] == 0) { + _globals._sequenceIndexes[0] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[0], false, 5); + _scene->_sequences.setDepth(_globals._sequenceIndexes[0], 14); + + _globals._sequenceIndexes[9] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[9], false, 2); + _scene->_sequences.setDepth(_globals._sequenceIndexes[9], 3); + } else if (_globals[kTrapDoorStatus] == 1) { + _globals._sequenceIndexes[0] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[0], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[0], 14); + + _globals._sequenceIndexes[9] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[9], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[9], 3); + } + + Common::Point promptPos; + Facing promptFacing; + + if (_globals[kJacquesStatus] == 0) { + promptPos = Common::Point(115, 142); + promptFacing = FACING_NORTHEAST; + } else { + promptPos = Common::Point(171, 142); + promptFacing = FACING_NORTHWEST; + } + + if ((_globals[kPrompterStandStatus] == 1) || (_globals[kCurrentYear] == 1881)) { + if (_globals[kJacquesStatus] >= 1) { + _globals._sequenceIndexes[7] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[7], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[7], 1); + + _globals._sequenceIndexes[3] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[3], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[3], 4); + _scene->_sequences.setPosition(_globals._sequenceIndexes[3], Common::Point(154, 139)); + + } else { + _globals._sequenceIndexes[3] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[3], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[3], 4); + _scene->_sequences.setPosition(_globals._sequenceIndexes[3], Common::Point(154, 139)); + + _globals._sequenceIndexes[12] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[12], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[12], 1); + } + + _hotspotPrompt1 = _scene->_dynamicHotspots.add(NOUN_PROMPTERS_STAND, VERB_WALKTO, SYNTAX_SINGULAR, EXT_NONE, Common::Rect(121, 79, 121 + 40, 79 + 63)); + _scene->_dynamicHotspots[_hotspotPrompt1]._articleNumber = PREP_ON; + _scene->_dynamicHotspots.setPosition(_hotspotPrompt1, promptPos, promptFacing); + + _hotspotPrompt2 = _scene->_dynamicHotspots.add(NOUN_PROMPTERS_STAND, VERB_WALKTO, SYNTAX_SINGULAR, EXT_NONE, Common::Rect(161, 67, 161 + 16, 67 + 75)); + _scene->_dynamicHotspots[_hotspotPrompt2]._articleNumber = PREP_ON; + _scene->_dynamicHotspots.setPosition(_hotspotPrompt2, promptPos, promptFacing); + + _hotspotPrompt3 = _scene->_dynamicHotspots.add(NOUN_PROMPTERS_STAND, VERB_WALKTO, SYNTAX_SINGULAR, EXT_NONE, Common::Rect(177, 90, 177 + 18, 90 + 52)); + _scene->_dynamicHotspots[_hotspotPrompt3]._articleNumber = PREP_ON; + _scene->_dynamicHotspots.setPosition(_hotspotPrompt3, promptPos, promptFacing); + + _hotspotPrompt4 = _scene->_dynamicHotspots.add(NOUN_PROMPTERS_STAND, VERB_WALKTO, SYNTAX_SINGULAR, EXT_NONE, Common::Rect(114, 100, 114 + 7, 100 + 38)); + _scene->_dynamicHotspots[_hotspotPrompt4]._articleNumber = PREP_ON; + _scene->_dynamicHotspots.setPosition(_hotspotPrompt4, promptPos, promptFacing); + + _hotspotPrompt5 = _scene->_dynamicHotspots.add(NOUN_PROMPTERS_STAND, VERB_CLIMB, SYNTAX_SINGULAR, EXT_NONE, Common::Rect(121, 49, 121 + 40, 49 + 30)); + _scene->_dynamicHotspots[_hotspotPrompt5]._articleNumber = PREP_ON; + _scene->_dynamicHotspots.setPosition(_hotspotPrompt5, Common::Point(196, 134), FACING_SOUTHWEST); + _scene->_dynamicHotspots.setCursor(_hotspotPrompt5, CURSOR_GO_UP); + + _hotspotRightFloor1 = _scene->_dynamicHotspots.add(NOUN_FLOOR, VERB_WALK_ACROSS, SYNTAX_SINGULAR, EXT_NONE, Common::Rect(154, 6, 154 + 41, 6 + 6)); + _scene->_dynamicHotspots[_hotspotRightFloor1]._articleNumber = PREP_ON; + _scene->_dynamicHotspots.setPosition(_hotspotRightFloor1, Common::Point(171, 142), FACING_NONE); + + _hotspotRightFloor2 = _scene->_dynamicHotspots.add(NOUN_FLOOR, VERB_WALK_ACROSS, SYNTAX_SINGULAR, EXT_NONE, Common::Rect(114, 136, 114 + 32, 136 + 6)); + _scene->_dynamicHotspots[_hotspotRightFloor2]._articleNumber = PREP_ON; + _scene->_dynamicHotspots.setPosition(_hotspotRightFloor2, Common::Point(127, 140), FACING_NONE); + + if ((_globals[kJacquesStatus] == 0) && (_globals[kCurrentYear] == 1881)) { + if (_globals[kJacquesNameIsKnown] >= 1) { + _hotspotGentleman = _scene->_dynamicHotspots.add(NOUN_JACQUES, VERB_WALKTO, SYNTAX_SINGULAR_MASC, EXT_NONE, Common::Rect(156, 116, 156 + 33, 116 + 31)); + _scene->_dynamicHotspots[_hotspotGentleman]._articleNumber = PREP_ON; + _scene->_dynamicHotspots.setPosition(_hotspotGentleman, Common::Point(206, 148), FACING_NORTHWEST); + } else { + _hotspotGentleman = _scene->_dynamicHotspots.add(NOUN_GENTLEMAN, VERB_WALKTO, SYNTAX_MASC_NOT_PROPER, -1, Common::Rect(156, 116, 156 + 33, 116 + 31)); + _scene->_dynamicHotspots[_hotspotGentleman]._articleNumber = PREP_ON; + _scene->_dynamicHotspots.setPosition(_hotspotGentleman, Common::Point(206, 148), FACING_NORTHWEST); + } + int tmpIdx = _scene->_dynamicHotspots.add(NOUN_FLOOR, VERB_WALK_ACROSS, SYNTAX_SINGULAR, EXT_NONE, Common::Rect(149, 140, 149 + 13, 140 + 7)); + _scene->_dynamicHotspots[tmpIdx]._articleNumber = PREP_ON; + _scene->_dynamicHotspots.setPosition(tmpIdx, Common::Point(155, 144), FACING_NONE); + + tmpIdx = _scene->_dynamicHotspots.add(NOUN_FLOOR, VERB_WALK_ACROSS, SYNTAX_SINGULAR, EXT_NONE, Common::Rect(187, 136, 187 + 8, 136 + 7)); + _scene->_dynamicHotspots[tmpIdx]._articleNumber = PREP_ON; + _scene->_dynamicHotspots.setPosition(tmpIdx, Common::Point(195, 139), FACING_NONE); + } else if ((_globals[kJacquesStatus] >= 1) && (_globals[kCurrentYear] == 1881)) { + _globals._sequenceIndexes[6] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[6], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[6], 3); + if (_game._objects.isInRoom(OBJ_KEY)) { + _globals._sequenceIndexes[5] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[5], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[5], 14); + _scene->_hotspots.activate(NOUN_KEY, true); + } + _scene->_hotspots.activate(NOUN_JACQUES, true); + _scene->_dynamicHotspots.remove(_hotspotRightFloor2); + + int tmpIdx = _scene->_dynamicHotspots.add(NOUN_JACQUES, VERB_WALKTO, SYNTAX_SINGULAR_MASC, EXT_NONE, Common::Rect(114, 132, 114 + 30, 132 + 10)); + _scene->_dynamicHotspots[tmpIdx]._articleNumber = PREP_ON; + _scene->_dynamicHotspots.setPosition(tmpIdx, Common::Point(95, 144), FACING_NORTHEAST); + + tmpIdx = _scene->_dynamicHotspots.add(NOUN_FLOOR, VERB_WALK_ACROSS, SYNTAX_SINGULAR, EXT_NONE, Common::Rect(94, 129, 94 + 18, 129 + 4)); + _scene->_dynamicHotspots[tmpIdx]._articleNumber = PREP_ON; + _scene->_dynamicHotspots.setPosition(tmpIdx, Common::Point(95, 133), FACING_NONE); + + tmpIdx = _scene->_dynamicHotspots.add(NOUN_FLOOR, VERB_WALK_ACROSS, SYNTAX_SINGULAR, EXT_NONE, Common::Rect(94, 132, 94 + 3, 132 + 9)); + _scene->_dynamicHotspots[tmpIdx]._articleNumber = PREP_ON; + _scene->_dynamicHotspots.setPosition(tmpIdx, Common::Point(93, 135), FACING_NONE); + + tmpIdx = _scene->_dynamicHotspots.add(NOUN_FLOOR, VERB_WALK_ACROSS, SYNTAX_SINGULAR, EXT_NONE, Common::Rect(112, 150, 112 + 21, 150 + 3)); + _scene->_dynamicHotspots[tmpIdx]._articleNumber = PREP_ON; + _scene->_dynamicHotspots.setPosition(tmpIdx, Common::Point(118, 154), FACING_NONE); + + tmpIdx = _scene->_dynamicHotspots.add(NOUN_FLOOR, VERB_WALK_ACROSS, SYNTAX_SINGULAR, EXT_NONE, Common::Rect(98, 146, 98 + 21, 146 + 4)); + _scene->_dynamicHotspots[tmpIdx]._articleNumber = PREP_ON; + _scene->_dynamicHotspots.setPosition(tmpIdx, Common::Point(104, 148), FACING_NONE); + } + } else if (_globals[kPrompterStandStatus] == 0) { + _globals._sequenceIndexes[3] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[3], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[3], 4); + _scene->_sequences.setPosition(_globals._sequenceIndexes[3], Common::Point(37, 139)); + + _hotspotPrompt1 = _scene->_dynamicHotspots.add(NOUN_PROMPTERS_STAND, VERB_WALKTO, SYNTAX_SINGULAR, EXT_NONE, Common::Rect(2, 79, 2 + 40, 79 + 63)); + _scene->_dynamicHotspots[_hotspotPrompt1]._articleNumber = PREP_ON; + _scene->_dynamicHotspots.setPosition(_hotspotPrompt1, Common::Point(59, 140), FACING_NORTHWEST); + + _hotspotPrompt2 = _scene->_dynamicHotspots.add(NOUN_PROMPTERS_STAND, VERB_WALKTO, SYNTAX_SINGULAR, EXT_NONE, Common::Rect(42, 67, 42 + 16, 67 + 75)); + _scene->_dynamicHotspots[_hotspotPrompt2]._articleNumber = PREP_ON; + _scene->_dynamicHotspots.setPosition(_hotspotPrompt2, Common::Point(59, 140), FACING_NORTHWEST); + + _hotspotPrompt3 = _scene->_dynamicHotspots.add(NOUN_PROMPTERS_STAND, VERB_WALKTO, SYNTAX_SINGULAR, EXT_NONE, Common::Rect(58, 90, 58 + 18, 90 + 52)); + _scene->_dynamicHotspots[_hotspotPrompt3]._articleNumber = PREP_ON; + _scene->_dynamicHotspots.setPosition(_hotspotPrompt3, Common::Point(59, 140), FACING_NORTHWEST); + + _hotspotPrompt5 = _scene->_dynamicHotspots.add(NOUN_PROMPTERS_STAND, VERB_CLIMB, SYNTAX_SINGULAR, EXT_NONE, Common::Rect(2, 49, 2 + 40, 49 + 30)); + _scene->_dynamicHotspots[_hotspotPrompt5]._articleNumber = PREP_ON; + _scene->_dynamicHotspots.setPosition(_hotspotPrompt5, Common::Point(79, 132), FACING_SOUTHWEST); + _scene->_dynamicHotspots.setCursor(_hotspotPrompt5, CURSOR_GO_UP); + + _hotspotLeftFloor1 = _scene->_dynamicHotspots.add(NOUN_FLOOR, VERB_WALK_ACROSS, SYNTAX_SINGULAR, EXT_NONE, Common::Rect(35, 137, 35 + 40, 137 + 5)); + _scene->_dynamicHotspots[_hotspotLeftFloor1]._articleNumber = PREP_ON; + _scene->_dynamicHotspots.setPosition(_hotspotLeftFloor1, Common::Point(59, 140), FACING_NONE); + _hotspotLeftFloor2 = _scene->_dynamicHotspots.add(NOUN_FLOOR, VERB_WALK_ACROSS, SYNTAX_SINGULAR, EXT_NONE, Common::Rect(76, 129, 76 + 6, 129 + 6)); + _scene->_dynamicHotspots[_hotspotLeftFloor2]._articleNumber = PREP_ON; + _scene->_dynamicHotspots.setPosition(_hotspotLeftFloor2, Common::Point(80, 135), FACING_NONE); + } + + if ((_globals[kJacquesStatus] == 0) && (_globals[kCurrentYear] == 1881)) { + _globals._animationIndexes[0] = _scene->loadAnimation(formAnimName('j', 1), 1); + _anim0ActvFl = true; + _scene->setAnimFrame(_globals._animationIndexes[0], 9); + } + + if (_scene->_priorSceneId == 104) { + _game._player._stepEnabled = false; + _game._player._visible = false; + if (_globals[kRoom103104Transition] == 0) { + _globals[kRoom103104Transition] = 1; + _globals._sequenceIndexes[10] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[10], false, -2); + _scene->_sequences.setDepth(_globals._sequenceIndexes[10], 4); + _standPosition = 1; + _game._player._playerPos = Common::Point(79, 132); + _scene->_sequences.addTimer(1, 100); + } else { + _standPosition = 2; + _globals._animationIndexes[3] = _scene->loadAnimation(formAnimName('w', 1), 0); + _anim3ActvFl = true; + _game._player._stepEnabled = true; + _game._player._playerPos = Common::Point(196, 134); + _scene->setAnimFrame(_globals._animationIndexes[3], 36); + + _scene->deleteSequence(_globals._sequenceIndexes[3]); + _globals._sequenceIndexes[3] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[3], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[3], 13); + _scene->_sequences.setPosition(_globals._sequenceIndexes[3], Common::Point(154, 139)); + } + + _globals._sequenceIndexes[1] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[1], false, -1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[1], 14); + } else if (_scene->_priorSceneId == 102) { + _game._player.firstWalk(Common::Point(-20, 140), FACING_EAST, Common::Point(15, 147), FACING_EAST, true); + _globals._sequenceIndexes[1] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[1], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[1], 14); + } else if ((_scene->_priorSceneId == 105) || (_scene->_priorSceneId != RETURNING_FROM_LOADING)) { + _game._player._playerPos = Common::Point(287, 135); + _game._player._facing = FACING_WEST; + _game._player._stepEnabled = false; + _game._player.walk(Common::Point(252, 134), FACING_WEST); + _game._player.setWalkTrigger(65); + _globals._sequenceIndexes[1] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[1], false, 6); + _scene->_sequences.setDepth(_globals._sequenceIndexes[1], 14); + } else if (_scene->_priorSceneId == -1) { + if (_standPosition == 1) { + _game._player._visible = false; + _globals._animationIndexes[5] = _scene->loadAnimation(formAnimName('w', 3), 0); + _anim5ActvFl = true; + _scene->setAnimFrame(_globals._animationIndexes[5], 33); + } else if (_standPosition == 2) { + _scene->deleteSequence(_globals._sequenceIndexes[3]); + _globals._sequenceIndexes[3] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[3], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[3], 13); + _scene->_sequences.setPosition(_globals._sequenceIndexes[3], Common::Point(154, 139)); + _game._player._visible = false; + _globals._animationIndexes[3] = _scene->loadAnimation(formAnimName('w', 1), 0); + _anim3ActvFl = true; + _game._player._stepEnabled = true; + _scene->setAnimFrame(_globals._animationIndexes[3], 36); + } else if (_vm->_gameConv->_restoreRunning == 12) { + _vm->_gameConv->run(12); + _vm->_gameConv->exportPointer(&_globals[kPlayerScore]); + _vm->_gameConv->exportValue(_globals[kMusicSelected]); + _globals[kWalkerConverse] = _vm->getRandomNumber(1, 4); + } + _globals._sequenceIndexes[1] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[1], false, -1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[1], 14); + } + + sceneEntrySound(); +} + +void Scene103::step() { + if (_anim0ActvFl) + handleJacquesAnim(); + + if (_anim3ActvFl) + climbRightStairs(); + + if (_anim5ActvFl) + climbLeftStairs(); + + if (_anim4ActvFl) + descendRightStairs(); + + if (_anim6ActvFl) + descendLeftStairs(); + + if ((_globals[kWalkerConverse] == 2) || (_globals[kWalkerConverse] == 3)) { + ++_convCount; + if (_convCount > 200) + _globals[kWalkerConverse] = _vm->getRandomNumber(1, 4); + } + + switch (_game._trigger) { + case 65: + _scene->deleteSequence(_globals._sequenceIndexes[1]); + _globals._sequenceIndexes[1] = _scene->_sequences.addReverseSpriteCycle(_globals._spriteIndexes[1], false, 8, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[1], 14); + _scene->_sequences.setAnimRange(_globals._sequenceIndexes[1], 1, 6); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[1], SEQUENCE_TRIGGER_EXPIRE, 0, 66); + _vm->_sound->command(66); + break; + + case 66: { + int syncIdx = _globals._sequenceIndexes[1]; + _vm->_sound->command(25); + _globals._sequenceIndexes[1] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[1], false, 1); + _game.syncTimers(SYNC_SEQ, _globals._sequenceIndexes[1], SYNC_SEQ, syncIdx); + _scene->_sequences.setDepth(_globals._sequenceIndexes[1], 14); + _game._player._stepEnabled = true; + } + break; + + case 80: + _scene->_nextSceneId = 104; + _scene->_reloadSceneFlag = true; + break; + + default: + break; + } + + switch (_game._trigger) { + case 100: + _scene->deleteSequence(_globals._sequenceIndexes[10]); + _globals._sequenceIndexes[10] = _scene->_sequences.addReverseSpriteCycle(_globals._spriteIndexes[10], false, 6, 1); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[10], SEQUENCE_TRIGGER_EXPIRE, 0, 101); + _scene->_sequences.setAnimRange(_globals._sequenceIndexes[10], -1, -2); + _scene->_sequences.setDepth(_globals._sequenceIndexes[10], 4); + break; + + case 101: + _globals._animationIndexes[5] = _scene->loadAnimation(formAnimName('w', 3), 0); + _anim5ActvFl = true; + _scene->setAnimFrame(_globals._animationIndexes[5], 33); + _game._player._stepEnabled = true; + _game.syncTimers(SYNC_ANIM, _globals._animationIndexes[5], SYNC_SEQ, _globals._sequenceIndexes[10]); + break; + + default: + break; + } + + switch (_game._trigger) { + case 0: + if (_anim1ActvFl) { + if ((_scene->getAnimFrame(_globals._animationIndexes[1]) == 10) && !_guardFrameFl) { + _vm->_sound->command(64); + _guardFrameFl = true; + _scene->deleteSequence(_globals._sequenceIndexes[0]); + _scene->deleteSequence(_globals._sequenceIndexes[9]); + _globals._sequenceIndexes[0] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[0], false, 6, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[0], 14); + _scene->_sequences.setAnimRange(_globals._sequenceIndexes[0], -1, -2); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[0], SEQUENCE_TRIGGER_EXPIRE, 0, 105); + } + } else if (_anim2ActvFl) { + if ((_scene->getAnimFrame(_globals._animationIndexes[2]) == 7) && !_guardFrameFl) { + _vm->_sound->command(64); + _guardFrameFl = true; + _scene->deleteSequence(_globals._sequenceIndexes[0]); + _scene->deleteSequence(_globals._sequenceIndexes[9]); + _globals._sequenceIndexes[0] = _scene->_sequences.addReverseSpriteCycle(_globals._spriteIndexes[0], false, 6, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[0], 14); + _scene->_sequences.setAnimRange(_globals._sequenceIndexes[0], -1, -2); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[0], SEQUENCE_TRIGGER_EXPIRE, 0, 110); + } + } + break; + + case 105: + _globals._sequenceIndexes[0] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[0], false, -2); + _scene->_sequences.setDepth(_globals._sequenceIndexes[0], 14); + _globals._sequenceIndexes[9] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[9], false, -2); + _scene->_sequences.setDepth(_globals._sequenceIndexes[9], 2); + _guardFrameFl = false; + break; + + case 110: + _globals._sequenceIndexes[0] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[0], false, -1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[0], 14); + _globals._sequenceIndexes[9] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[9], false, -1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[9], 2); + _guardFrameFl = false; + break; + + default: + break; + } + + if (_globals[kJacquesStatus] == 3) { + warning("TODO: add a check on the return value of _vm->_sound->command ???"); + _vm->_sound->command(38); + } +} + +void Scene103::preActions() { + if (_action.isAction(VERB_OPEN, NOUN_DOOR)) + _game._player._needToWalk = true; + + if (_action.isAction(VERB_OPEN, NOUN_DOOR_TO_PIT)) { + _game._player.walk(Common::Point(0, 150), FACING_WEST); + _game._player._walkOffScreenSceneId = 102; + } + + if ((_standPosition != 0) && !_action.isAction(VERB_CLIMB_THROUGH, NOUN_TRAP_DOOR) && + !_action.isAction(VERB_OPEN, NOUN_TRAP_DOOR) && + !_action.isAction(VERB_CLIMB, NOUN_PROMPTERS_STAND) && + !_action.isAction(VERB_PUSH, NOUN_TRAP_DOOR) && + !_action.isAction(VERB_LOOK_THROUGH, NOUN_PROMPTERS_BOX) && + !_action.isAction(VERB_PULL, NOUN_TRAP_DOOR)) { + + if (_action.isAction(VERB_PULL) || _action.isAction(VERB_PUSH)) { + if (!_action.isObject(NOUN_LEVER) && !_game._trigger) + _game._player._needToWalk = false; + } + + if ((_action.isAction(VERB_PUSH, NOUN_PROMPTERS_STAND)) || (_action.isAction(VERB_PULL, NOUN_PROMPTERS_STAND))) { + if (!_game._trigger) + _game._player._needToWalk = true; + } + + if (_game._player._needToWalk) { + if (_globals[kPrompterStandStatus] == 0) { + switch (_game._trigger) { + case 0: + _scene->freeAnimation(5); + _game._player._readyToWalk = false; + _game._player._visible = false; + _game._player._stepEnabled = false; + _anim5ActvFl = false; + _anim6ActvFl = true; + _globals._animationIndexes[6] = _scene->loadAnimation(formAnimName('w', 4), 1); + break; + + case 1: + _game._player._playerPos = Common::Point(79, 132); + _game._player._stepEnabled = true; + _game._player._visible = true; + _standPosition = 0; + _game._player._readyToWalk = true; + if (_action.isAction(VERB_PUSH, NOUN_PROMPTERS_STAND)) + _game._player._needToWalk = false; + _anim6ActvFl = false; + _game._player.resetFacing(FACING_NORTHEAST); + _game.syncTimers(SYNC_PLAYER, 0, SYNC_ANIM, _globals._animationIndexes[6]); + break; + + default: + break; + } + } else { + switch (_game._trigger) { + case 0: + _scene->freeAnimation(3); + _game._player._readyToWalk = false; + if (_action.isAction(VERB_PUSH, NOUN_PROMPTERS_STAND)) + _game._player._needToWalk = true; + _game._player._visible = false; + _game._player._stepEnabled = false; + _anim3ActvFl = false; + _anim4ActvFl = true; + _globals._animationIndexes[4] = _scene->loadAnimation(formAnimName('w', 2), 1); + break; + + case 1: + _game._player._playerPos = Common::Point(196, 134); + _game._player._stepEnabled = true; + _game._player._readyToWalk = true; + if (_action.isAction(VERB_PUSH, NOUN_PROMPTERS_STAND)) + _game._player._needToWalk = false; + _game._player._visible = true; + _standPosition = 0; + _anim4ActvFl = false; + _game._player.resetFacing(FACING_NORTHEAST); + _game.syncTimers(SYNC_PLAYER, 0, SYNC_ANIM, _globals._animationIndexes[4]); + break; + + default: + break; + } + } + } + } + + if (_standPosition == 0) { + if ((_action.isAction(VERB_PUSH, NOUN_PROMPTERS_STAND)) || (_action.isAction(VERB_PULL, NOUN_PROMPTERS_STAND))) { + if (_globals[kCurrentYear] == 1993) { + if (_globals[kPrompterStandStatus] == 0) + _game._player.walk(Common::Point(2, 138), FACING_WEST); + else + _game._player.walk(Common::Point(176, 142), FACING_WEST); + } + } + } + + if (_action.isAction(VERB_LOOK_THROUGH, NOUN_PROMPTERS_BOX) && (_standPosition == 0) && (_globals[kPrompterStandStatus] == 0) && (_globals[kCurrentYear] == 1993)) + _game._player.walk(Common::Point(79, 132), FACING_SOUTHWEST); + + if (_action.isAction(VERB_CLIMB_THROUGH, NOUN_TRAP_DOOR) && (_standPosition == 0) && (_globals[kPrompterStandStatus] == 1) && (_globals[kTrapDoorStatus] == 0)) + _game._player.walk(Common::Point(196, 134), FACING_SOUTHWEST); + + if (_action.isAction(VERB_WALK_THROUGH, NOUN_DOOR_TO_PIT)) + _game._player._walkOffScreenSceneId = 102; + + if ((_action.isAction(VERB_OPEN, NOUN_DOOR) || _action.isAction(VERB_UNLOCK, NOUN_DOOR) || _action.isAction(VERB_LOCK, NOUN_DOOR)) && (_standPosition == 0)) + _game._player.walk(Common::Point(252, 134), FACING_EAST); +} + +void Scene103::actions() { + if (_action.isAction(VERB_OPEN, NOUN_DOOR_TO_PIT)) { + _scene->_nextSceneId = 102; + _action._inProgress = false; + return; + } + + if (_vm->_gameConv->_running == 12) { + process_conv_jacques(); + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_CLIMB_THROUGH, NOUN_TRAP_DOOR)) { + if (_globals[kTrapDoorStatus] == 1) { + _vm->_dialogs->show(10333); + _action._inProgress = false; + return; + } else if (_globals[kPrompterStandStatus] == 0) { + _vm->_dialogs->show(10341); + _action._inProgress = false; + return; + } + } + + if ((_action.isAction(VERB_LOOK_THROUGH, NOUN_PROMPTERS_BOX)) && (_globals[kPrompterStandStatus] == 1)) { + _vm->_dialogs->show(10342); + _action._inProgress = false; + return; + } + + if ((_action.isAction(VERB_CLIMB, NOUN_PROMPTERS_STAND) && _standPosition == 0) || + (_action.isAction(VERB_LOOK_THROUGH, NOUN_PROMPTERS_BOX) && (_standPosition == 0)) || + (_action.isAction(VERB_CLIMB_THROUGH, NOUN_TRAP_DOOR) && (_standPosition == 0))) { + if (_globals[kPrompterStandStatus] == 0) { + if (_game._trigger == 0) { + if (_action.isAction(VERB_LOOK_THROUGH, NOUN_PROMPTERS_BOX)) { + _sitFl = true; + _globals._animationIndexes[5] = _scene->loadAnimation(formAnimName('w', 3), 115); + } else + _globals._animationIndexes[5] = _scene->loadAnimation(formAnimName('w', 3), 0); + + _game._player._visible = false; + _game._player._stepEnabled = false; + _anim5ActvFl = true; + _game.syncTimers(SYNC_ANIM, _globals._animationIndexes[5], SYNC_PLAYER, 0); + _action._inProgress = false; + return; + } + } else if (_game._trigger == 0) { + if (_action.isAction(VERB_CLIMB_THROUGH, NOUN_TRAP_DOOR)) { + _climbThroughTrapFl = true; + _globals._animationIndexes[3] = _scene->loadAnimation(formAnimName('w', 1), 120); + } else + _globals._animationIndexes[3] = _scene->loadAnimation(formAnimName('w', 1), 0); + + _game._player._visible = false; + _game._player._stepEnabled = false; + _anim3ActvFl = true; + _game.syncTimers(SYNC_ANIM, _globals._animationIndexes[3], SYNC_PLAYER, 0); + _action._inProgress = false; + return; + } + } + + if (_action.isAction(VERB_CLIMB, NOUN_PROMPTERS_STAND) && (_standPosition != 0)) { + _action._inProgress = false; + return; + } + + if ((_action.isAction(VERB_PUSH, NOUN_PROMPTERS_STAND)) || (_action.isAction(VERB_PULL, NOUN_PROMPTERS_STAND))) { + if (_globals[kCurrentYear] == 1993) { + if (_globals[kPrompterStandStatus] == 0) { + switch (_game._trigger) { + case 0: + if (_globals[kPrompterStandStatus] == 0) { + _game._player._stepEnabled = false; + _game._player._visible = false; + _globals._animationIndexes[0] = _scene->loadAnimation(formAnimName('s', 1), 75); + _game._player._priorTimer = _scene->_frameStartTime; + _game.syncTimers(SYNC_ANIM, _globals._animationIndexes[0], SYNC_PLAYER, 0); + _scene->deleteSequence(_globals._sequenceIndexes[3]); + } + break; + + case 75: + if (_globals[kPrompterStandStatus] == 0) { + _globals._sequenceIndexes[12] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[12], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[12], 1); + _globals._sequenceIndexes[3] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[3], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[3], 4); + _scene->_sequences.setPosition(_globals._sequenceIndexes[3], Common::Point(154, 139)); + _game.syncTimers(SYNC_SEQ, _globals._sequenceIndexes[3], SYNC_ANIM, _globals._animationIndexes[0]); + _globals[kPrompterStandStatus] = 1; + _game._player._stepEnabled = true; + _game._player._visible = true; + _game._player._playerPos = Common::Point(117, 139); + _game._player.resetFacing(FACING_EAST); + _game.syncTimers(SYNC_PLAYER, 0, SYNC_ANIM, _globals._animationIndexes[0]); + + _scene->_dynamicHotspots.remove(_hotspotPrompt1); + _scene->_dynamicHotspots.remove(_hotspotPrompt2); + _scene->_dynamicHotspots.remove(_hotspotPrompt3); + _scene->_dynamicHotspots.remove(_hotspotPrompt5); + _scene->_dynamicHotspots.remove(_hotspotLeftFloor1); + _scene->_dynamicHotspots.remove(_hotspotLeftFloor2); + + _hotspotPrompt1 = _scene->_dynamicHotspots.add(NOUN_PROMPTERS_STAND, VERB_WALKTO, SYNTAX_SINGULAR, EXT_NONE, Common::Rect(121, 79, 121 + 40, 79 + 63)); + _scene->_dynamicHotspots[_hotspotPrompt1]._articleNumber = PREP_ON; + _scene->_dynamicHotspots.setPosition(_hotspotPrompt1, Common::Point(171, 142), FACING_NORTHWEST); + + _hotspotPrompt2 = _scene->_dynamicHotspots.add(NOUN_PROMPTERS_STAND, VERB_WALKTO, SYNTAX_SINGULAR, EXT_NONE, Common::Rect(161, 67, 161 + 16, 67 + 75)); + _scene->_dynamicHotspots[_hotspotPrompt2]._articleNumber = PREP_ON; + _scene->_dynamicHotspots.setPosition(_hotspotPrompt2, Common::Point(171, 142), FACING_NORTHWEST); + + _hotspotPrompt3 = _scene->_dynamicHotspots.add(NOUN_PROMPTERS_STAND, VERB_WALKTO, SYNTAX_SINGULAR, EXT_NONE, Common::Rect(177, 90, 177 + 18, 90 + 52)); + _scene->_dynamicHotspots[_hotspotPrompt3]._articleNumber = PREP_ON; + _scene->_dynamicHotspots.setPosition(_hotspotPrompt3, Common::Point(171, 142), FACING_NORTHWEST); + + _hotspotPrompt4 = _scene->_dynamicHotspots.add(NOUN_PROMPTERS_STAND, VERB_WALKTO, SYNTAX_SINGULAR, EXT_NONE, Common::Rect(114, 100, 114 + 7, 100 + 38)); + _scene->_dynamicHotspots[_hotspotPrompt4]._articleNumber = PREP_ON; + _scene->_dynamicHotspots.setPosition(_hotspotPrompt4, Common::Point(171, 142), FACING_NORTHWEST); + + _hotspotPrompt5 = _scene->_dynamicHotspots.add(NOUN_PROMPTERS_STAND, VERB_CLIMB, SYNTAX_SINGULAR, EXT_NONE, Common::Rect(121, 49, 121 + 40, 49 + 30)); + _scene->_dynamicHotspots[_hotspotPrompt5]._articleNumber = PREP_ON; + _scene->_dynamicHotspots.setPosition(_hotspotPrompt5, Common::Point(196, 134), FACING_SOUTHWEST); + _scene->_dynamicHotspots.setCursor(_hotspotPrompt5, CURSOR_GO_UP); + + _hotspotRightFloor1 = _scene->_dynamicHotspots.add(NOUN_FLOOR, VERB_WALK_ACROSS, SYNTAX_SINGULAR, EXT_NONE, Common::Rect(154, 6, 154 + 41, 6 + 6)); + _scene->_dynamicHotspots[_hotspotRightFloor1]._articleNumber = PREP_ON; + _scene->_dynamicHotspots.setPosition(_hotspotRightFloor1, Common::Point(171, 142), FACING_NONE); + + _hotspotRightFloor2 = _scene->_dynamicHotspots.add(NOUN_FLOOR, VERB_WALK_ACROSS, SYNTAX_SINGULAR, EXT_NONE, Common::Rect(114, 136, 114 + 32, 132 + 6)); + _scene->_dynamicHotspots[_hotspotRightFloor2]._articleNumber = PREP_ON; + _scene->_dynamicHotspots.setPosition(_hotspotRightFloor2, Common::Point(127, 140), FACING_NONE); + + _scene->changeVariant(1); + adjustRails(1); + } + break; + + default: + break; + } + } else { + switch (_game._trigger) { + case 0: + if (_globals[kPrompterStandStatus] == 1) { + _game._player._stepEnabled = false; + _game._player._visible = false; + _globals._animationIndexes[0] = _scene->loadAnimation(formAnimName('s', 2), 75); + _game._player._priorTimer = _scene->_frameStartTime; + _game.syncTimers(SYNC_ANIM, _globals._animationIndexes[0], SYNC_PLAYER, 0); + _scene->deleteSequence(_globals._sequenceIndexes[12]); + _scene->deleteSequence(_globals._sequenceIndexes[3]); + } + break; + + case 75: + if (_globals[kPrompterStandStatus] == 1) { + _globals._sequenceIndexes[3] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[3], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[3], 4); + _scene->_sequences.setPosition(_globals._sequenceIndexes[3], Common::Point(37, 139)); + _game.syncTimers(SYNC_SEQ, _globals._sequenceIndexes[3], SYNC_ANIM, _globals._animationIndexes[0]); + _globals[kPrompterStandStatus] = 0; + _game._player._stepEnabled = true; + _game._player._visible = true; + _game._player._playerPos = Common::Point(62, 142); + _game._player.resetFacing(FACING_WEST); + _game.syncTimers(SYNC_PLAYER, 0, SYNC_ANIM, _globals._animationIndexes[0]); + _scene->_dynamicHotspots.remove(_hotspotPrompt1); + _scene->_dynamicHotspots.remove(_hotspotPrompt2); + _scene->_dynamicHotspots.remove(_hotspotPrompt3); + _scene->_dynamicHotspots.remove(_hotspotPrompt4); + _scene->_dynamicHotspots.remove(_hotspotPrompt5); + _scene->_dynamicHotspots.remove(_hotspotRightFloor1); + _scene->_dynamicHotspots.remove(_hotspotRightFloor2); + + _hotspotPrompt1 = _scene->_dynamicHotspots.add(NOUN_PROMPTERS_STAND, VERB_WALKTO, SYNTAX_SINGULAR, EXT_NONE, Common::Rect(2, 79, 2 + 40, 79 + 63)); + _scene->_dynamicHotspots[_hotspotPrompt1]._articleNumber = PREP_ON; + _scene->_dynamicHotspots.setPosition(_hotspotPrompt1, Common::Point(59, 140), FACING_NORTHWEST); + + _hotspotPrompt2 = _scene->_dynamicHotspots.add(NOUN_PROMPTERS_STAND, VERB_WALKTO, SYNTAX_SINGULAR, EXT_NONE, Common::Rect(42, 67, 42 + 16, 67 + 75)); + _scene->_dynamicHotspots[_hotspotPrompt2]._articleNumber = PREP_ON; + _scene->_dynamicHotspots.setPosition(_hotspotPrompt2, Common::Point(59, 140), FACING_NORTHWEST); + + _hotspotPrompt3 = _scene->_dynamicHotspots.add(NOUN_PROMPTERS_STAND, VERB_WALKTO, SYNTAX_SINGULAR, EXT_NONE, Common::Rect(58, 90, 58 + 18, 90 + 52)); + _scene->_dynamicHotspots[_hotspotPrompt3]._articleNumber = PREP_ON; + _scene->_dynamicHotspots.setPosition(_hotspotPrompt3, Common::Point(59, 140), FACING_NORTHWEST); + + _hotspotLeftFloor1 = _scene->_dynamicHotspots.add(NOUN_FLOOR, VERB_WALK_ACROSS, SYNTAX_SINGULAR, EXT_NONE, Common::Rect(35, 137, 35 + 40, 137 + 5)); + _scene->_dynamicHotspots[_hotspotLeftFloor1]._articleNumber = PREP_ON; + _scene->_dynamicHotspots.setPosition(_hotspotLeftFloor1, Common::Point(59, 140), FACING_NONE); + + _hotspotLeftFloor2 = _scene->_dynamicHotspots.add(NOUN_FLOOR, VERB_WALK_ACROSS, SYNTAX_SINGULAR, EXT_NONE, Common::Rect(76, 129, 76 + 6, 129 + 6)); + _scene->_dynamicHotspots[_hotspotLeftFloor2]._articleNumber = PREP_ON; + _scene->_dynamicHotspots.setPosition(_hotspotLeftFloor2, Common::Point(80, 135), FACING_NONE); + + _hotspotPrompt5 = _scene->_dynamicHotspots.add(NOUN_PROMPTERS_STAND, VERB_CLIMB, SYNTAX_SINGULAR, EXT_NONE, Common::Rect(2, 49, 2 + 40, 49 + 30)); + _scene->_dynamicHotspots[_hotspotPrompt5]._articleNumber = PREP_ON; + _scene->_dynamicHotspots.setPosition(_hotspotPrompt5, Common::Point(79, 132), FACING_SOUTHWEST); + _scene->_dynamicHotspots.setCursor(_hotspotPrompt5, CURSOR_GO_UP); + + _scene->changeVariant(0); + adjustRails(0); + } + break; + + default: + break; + } + } + } else if (_globals[kJacquesNameIsKnown]) + _vm->_dialogs->show(10340); else + _vm->_dialogs->show(10350); + + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_WALK_THROUGH, NOUN_DOOR) || _action.isAction(VERB_OPEN, NOUN_DOOR) || _action.isAction(VERB_UNLOCK, NOUN_DOOR) || _action.isAction(VERB_LOCK, NOUN_DOOR)) { + if ((_globals[kCurrentYear] == 1881) && !_action.isAction(VERB_LOCK, NOUN_DOOR) && !_action.isAction(VERB_UNLOCK, NOUN_DOOR)) { + switch (_game._trigger) { + case (0): + _game._player._stepEnabled = false; + _game._player._visible = false; + _globals._sequenceIndexes[2] = _scene->_sequences.startPingPongCycle(_globals._spriteIndexes[2], false, 5, 2); + _scene->_sequences.setAnimRange(_globals._sequenceIndexes[2], -1, -2); + _scene->_sequences.setSeqPlayer(_globals._sequenceIndexes[2], true); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SEQUENCE_TRIGGER_EXPIRE, 0, 2); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SEQUENCE_TRIGGER_SPRITE, 3, 70); + break; + + case 2: + _game._player._visible = true; + _game.syncTimers(SYNC_PLAYER, 0, SYNC_SEQ, _globals._sequenceIndexes[2]); + _game._player.walk(Common::Point(295, 132), FACING_WEST); + _scene->_sequences.addTimer(180, 3); + break; + + case 3: + _scene->_nextSceneId = 105; + break; + + case 70: + _vm->_sound->command(24); + _scene->deleteSequence(_globals._sequenceIndexes[1]); + _globals._sequenceIndexes[1] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[1], false, 8, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[1], 14); + _scene->_sequences.setAnimRange(_globals._sequenceIndexes[1], -1, -2); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[1], SEQUENCE_TRIGGER_EXPIRE, 0, 71); + _vm->_sound->command(66); + break; + + case 71: { + int oldIdx = _globals._sequenceIndexes[1]; + _globals._sequenceIndexes[1] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[1], false, -2); + _game.syncTimers(SYNC_SEQ, _globals._sequenceIndexes[1], SYNC_SEQ, oldIdx); + _scene->_sequences.setDepth(_globals._sequenceIndexes[1], 14); + } + break; + + default: + break; + } + } else { + switch (_game._trigger) { + case (0): + _game._player._stepEnabled = false; + _game._player._visible = false; + _globals._sequenceIndexes[2] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[2], false, 5, 1); + _scene->_sequences.setAnimRange(_globals._sequenceIndexes[2], 1, 4); + _scene->_sequences.setSeqPlayer(_globals._sequenceIndexes[2], true); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SEQUENCE_TRIGGER_EXPIRE, 0, 1); + break; + + case 1: { + int oldIdx = _globals._sequenceIndexes[2]; + _globals._sequenceIndexes[2] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[2], false, 4); + _game.syncTimers(SYNC_SEQ, _globals._sequenceIndexes[2], SYNC_SEQ, oldIdx); + _scene->_sequences.setSeqPlayer(_globals._sequenceIndexes[2], false); + _scene->_sequences.addTimer(15, 2); + _vm->_sound->command(73); + } + break; + + case 2: + _scene->deleteSequence(_globals._sequenceIndexes[2]); + _globals._sequenceIndexes[2] = _scene->_sequences.addReverseSpriteCycle(_globals._spriteIndexes[2], false, 5, 1); + _scene->_sequences.setAnimRange(_globals._sequenceIndexes[2], 1, 4); + _scene->_sequences.setSeqPlayer(_globals._sequenceIndexes[2], false); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SEQUENCE_TRIGGER_EXPIRE, 0, 3); + break; + + case 3: + _game.syncTimers(SYNC_PLAYER, 0, SYNC_SEQ, _globals._sequenceIndexes[2]); + _game._player._visible = true; + if (_action.isAction(VERB_LOCK) || _action.isAction(VERB_UNLOCK)) + _vm->_dialogs->show(00032); + else + _vm->_dialogs->show(10335); + + _game._player._stepEnabled = true; + break; + + default: + break; + } + } + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_TAKE, NOUN_KEY) && (_game._objects.isInRoom(OBJ_KEY) || _game._trigger)) { + switch (_game._trigger) { + case (0): + _game._player._stepEnabled = false; + _game._player._visible = false; + _globals._sequenceIndexes[8] = _scene->_sequences.startPingPongCycle(_globals._spriteIndexes[8], false, 5, 2); + _scene->_sequences.setAnimRange(_globals._sequenceIndexes[8], 1, 5); + _scene->_sequences.setSeqPlayer(_globals._sequenceIndexes[8], true); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[8], SEQUENCE_TRIGGER_SPRITE, 5, 1); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[8], SEQUENCE_TRIGGER_EXPIRE, 0, 2); + _action._inProgress = false; + return; + + case 1: + _scene->deleteSequence(_globals._sequenceIndexes[5]); + _scene->_hotspots.activate(NOUN_KEY, false); + _game._objects.addToInventory(OBJ_KEY); + _vm->_sound->command(26); + _action._inProgress = false; + return; + + case 2: + _game.syncTimers(SYNC_PLAYER, 0, SYNC_SEQ, _globals._sequenceIndexes[8]); + _game._player._visible = true; + _scene->_sequences.addTimer(20, 3); + _action._inProgress = false; + return; + + case 3: + _globals[kPlayerScore] += 5; + _vm->_dialogs->showItem(OBJ_KEY, 800, 0); + _game._player._stepEnabled = true; + _action._inProgress = false; + return; + + default: + break; + } + } + + if (_action.isAction(VERB_TALK_TO, NOUN_GENTLEMAN) || _action.isAction(VERB_TALK_TO, NOUN_JACQUES)) { + if (_globals[kJacquesStatus] == 0) { + _vm->_gameConv->run(12); + _vm->_gameConv->exportPointer(&_globals[kPlayerScore]); + _vm->_gameConv->exportValue(_globals[kMusicSelected]); + } else + _vm->_dialogs->show(10343); + + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_CLIMB_THROUGH, NOUN_TRAP_DOOR) || _climbThroughTrapFl) { + if ((_standPosition == 2) && (_globals[kTrapDoorStatus] == 0)) { + switch (_game._trigger) { + case 0: + case 120: + if (!(_globals[kPlayerScoreFlags] & 1)) { + _globals[kPlayerScoreFlags] |= 1; + _globals[kPlayerScore] += 3; + } + + _scene->freeAnimation(3); + _anim3ActvFl = false; + _climbThroughTrapFl = false; + _game._player._stepEnabled = false; + _globals._sequenceIndexes[11] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[11], false, 6, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[11], 5); + _scene->_sequences.setAnimRange(_globals._sequenceIndexes[11], -1, -2); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[11], SEQUENCE_TRIGGER_EXPIRE, 0, 1); + break; + + case 1: + _globals[kRoom103104Transition] = 1; + _scene->_nextSceneId = 104; + break; + + default: + break; + } + } + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_LOOK_THROUGH, NOUN_PROMPTERS_BOX) || _sitFl) { + if (_standPosition == 1) { + switch (_game._trigger) { + case 0: + case 115: + _scene->freeAnimation(5); + _anim5ActvFl = false; + _game._player._stepEnabled = false; + _globals._sequenceIndexes[10] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[10], false, 6, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[10], 4); + _scene->_sequences.setAnimRange(_globals._sequenceIndexes[10], -1, -2); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[10], SEQUENCE_TRIGGER_EXPIRE, 0, 1); + if (!_sitFl) + _game.syncTimers(SYNC_SEQ, _globals._sequenceIndexes[10], SYNC_ANIM, _globals._animationIndexes[5]); + _sitFl = false; + break; + + case 1: + _globals[kRoom103104Transition] = 0; + _scene->_nextSceneId = 104; + break; + + default: + break; + } + } + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_PUSH, NOUN_LEVER) || _action.isAction(VERB_PULL, NOUN_LEVER)) { + if (_globals[kTrapDoorStatus] == 1) { + switch (_game._trigger) { + case 0: + _globals._animationIndexes[1] = _scene->loadAnimation(formAnimName('l', 1), 1); + _anim1ActvFl = true; + _game._player._visible = false; + _game._player._stepEnabled = false; + _game.syncTimers(SYNC_ANIM, _globals._animationIndexes[1], SYNC_PLAYER, 0); + break; + + case 1: + _anim1ActvFl = false; + _game._player._visible = true; + _globals[kTrapDoorStatus] = 0; + _game._player._stepEnabled = true; + _game.syncTimers(SYNC_PLAYER, 0, SYNC_ANIM, _globals._animationIndexes[1]); + break; + + default: + break; + } + } else { + switch (_game._trigger) { + case 0: + _globals._animationIndexes[2] = _scene->loadAnimation(formAnimName('l', 2), 1); + _anim2ActvFl = true; + _game._player._visible = false; + _game._player._stepEnabled = false; + _game.syncTimers(SYNC_ANIM, _globals._animationIndexes[2], SYNC_PLAYER, 0); + break; + + case 1: + _anim2ActvFl = false; + _game._player._visible = true; + _globals[kTrapDoorStatus] = 1; + _game._player._stepEnabled = true; + _game.syncTimers(SYNC_PLAYER, 0, SYNC_ANIM, _globals._animationIndexes[2]); + break; + + default: + break; + } + } + _action._inProgress = false; + return; + } + + if (_action._lookFlag) { + if ((_globals[kCurrentYear] == 1881) && (_globals[kJacquesStatus] >= 1)) + _vm->_dialogs->show(10311); + else + _vm->_dialogs->show(10310); + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_LOOK) || _action.isAction(VERB_LOOK_AT)) { + if (_action.isObject(NOUN_PROMPTERS_STAND)) { + if (_globals[kJacquesStatus] >= 1) + _vm->_dialogs->show(10349); + else if (_globals[kCurrentYear] == 1993) + _vm->_dialogs->show(10312); + else + _vm->_dialogs->show(10345); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_FLOOR)) { + _vm->_dialogs->show(10313); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_TRAP_CEILING)) { + _vm->_dialogs->show(10314); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_DOOR)) { + _vm->_dialogs->show(10315); + _action._inProgress = false; return; + } + + if (_action.isObject(NOUN_DOOR_TO_PIT)) { + _vm->_dialogs->show(10316); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_WALL)) { + _vm->_dialogs->show(10317); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_PROMPTERS_BOX)) { + _vm->_dialogs->show(10318); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_TRAP_DOOR)) { + _vm->_dialogs->show(10319); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_JUNK)) { + if (_globals[kCurrentYear] == 1993) + _vm->_dialogs->show(10320); + else + _vm->_dialogs->show(10346); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_CARTON)) { + if (_globals[kCurrentYear] == 1993) + _vm->_dialogs->show(10321); + else + _vm->_dialogs->show(10347); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_GARBAGE_CAN)) { + if (_globals[kCurrentYear] == 1993) + _vm->_dialogs->show(10322); + else + _vm->_dialogs->show(10348); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_CABLE)) { + _vm->_dialogs->show(10323); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_JACQUES) || _action.isObject(NOUN_GENTLEMAN)) { + if (_globals[kJacquesStatus] == 0) + _vm->_dialogs->show(10324); + else + _vm->_dialogs->show(10325); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_KEY) && _game._objects.isInRoom(OBJ_KEY)) { + _vm->_dialogs->show(10326); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_STAIR_UNIT)) { + _vm->_dialogs->show(10327); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_EXPOSED_BRICK)) { + _vm->_dialogs->show(10328); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_WATER_PIPE)) { + _vm->_dialogs->show(10329); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_PROMPTERS_SEAT)) { + _vm->_dialogs->show(10338); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_LEVER)) { + _vm->_dialogs->show(10339); + _action._inProgress = false; + return; + } + + } + + if (_action.isAction(VERB_CLOSE, NOUN_DOOR_TO_PIT)) { + _vm->_dialogs->show(10331); + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_CLOSE, NOUN_DOOR)) { + _vm->_dialogs->show(10331); + _action._inProgress = false; + return; + } + + if ((_action.isAction(VERB_OPEN, NOUN_TRAP_DOOR)) || (_action.isAction(VERB_CLOSE, NOUN_TRAP_DOOR))) { + _vm->_dialogs->show(10344); + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_TAKE, NOUN_JACQUES) || _action.isAction(VERB_TAKE, NOUN_GENTLEMAN)) { + if (_globals[kJacquesStatus] == 0) { + if (_globals[kJacquesNameIsKnown]) + _vm->_dialogs->show(10336); + else + _vm->_dialogs->show(10351); + } else + _vm->_dialogs->show(10337); + _action._inProgress = false; + return; + } +} + +void Scene103::adjustRails(int variant) { + switch (variant) { + case 0: + _scene->_rails.disableNode(3); + _scene->_rails.disableNode(4); + _scene->_rails.disableNode(5); + _scene->_rails.disableNode(6); + _scene->_rails.disableNode(12); + _scene->_rails.disableNode(13); + _scene->_rails.disableNode(14); + break; + + case 1: + _scene->_rails.disableNode(1); + _scene->_rails.disableNode(2); + _scene->_rails.disableNode(3); + _scene->_rails.disableNode(4); + _scene->_rails.disableNode(5); + _scene->_rails.disableNode(6); + _scene->_rails.disableNode(7); + _scene->_rails.disableNode(9); + _scene->_rails.disableNode(10); + _scene->_rails.disableNode(11); + break; + + case 2: + _scene->_rails.disableNode(1); + _scene->_rails.disableNode(2); + _scene->_rails.disableNode(5); + _scene->_rails.disableNode(6); + _scene->_rails.disableNode(7); + _scene->_rails.disableNode(9); + _scene->_rails.disableNode(10); + _scene->_rails.disableNode(11); + break; + + case 3: + _scene->_rails.disableNode(1); + _scene->_rails.disableNode(2); + _scene->_rails.disableNode(3); + _scene->_rails.disableNode(4); + _scene->_rails.disableNode(10); + _scene->_rails.disableNode(11); + break; + + default: + break; + } +} + +void Scene103::handleJacquesAnim() { + if (_scene->getAnimFrame(_globals._animationIndexes[0]) == _lastJacquesFrame) + return; + + _lastJacquesFrame = _scene->getAnimFrame(_globals._animationIndexes[0]); + int resetFrame = -1; + int random; + + switch (_lastJacquesFrame) { + case 1: + case 2: + case 3: + case 9: + case 17: + case 23: + case 33: + case 51: + switch (_jacquesAction) { + case 2: + random = 4; + _jacquesAction = 0; + break; + + case 3: + random = 5; + _jacquesAction = 0; + break; + + case 4: + random = 6; + break; + + case 0: + random = _vm->getRandomNumber(1, 3); + ++_talkCount; + if (_talkCount > 22) { + _jacquesAction = 1; + random = 9; + } + break; + + default: + random = _vm->getRandomNumber(6, 50); + while (_lastRandom == random) + random = _vm->getRandomNumber(6, 50); + + _lastRandom = random; + break; + } + + switch (random) { + case 1: + resetFrame = 0; + break; + + case 2: + resetFrame = 1; + break; + + case 3: + resetFrame = 2; + break; + + case 4: + resetFrame = 4; + break; + + case 5: + resetFrame = 10; + break; + + case 6: + resetFrame = 34; + break; + + case 7: + resetFrame = 24; + break; + + case 8: + resetFrame = 18; + break; + + default: + resetFrame = 8; + break; + } + break; + + case 36: + case 40: + case 48: + switch (_jacquesAction) { + case 0: + case 2: + case 3: + random = 2; + break; + + case 4: + random = 1; + _jacquesAction = 0; + break; + + default: + random = _vm->getRandomNumber(2, 50); + while (_lastRandom == random) + random = _vm->getRandomNumber(2, 50); + _lastRandom = random; + break; + } + + switch (random) { + case 1: + resetFrame = 37; + break; + + case 2: + resetFrame = 49; + break; + + case 3: + resetFrame = 41; + break; + + default: + resetFrame = 35; + break; + } + break; + + case 44: + random = _vm->getRandomNumber(1, 50); + while (_lastRandom == random) + random = _vm->getRandomNumber(1, 50); + + _lastRandom = random; + + switch (_jacquesAction) { + case 0: + case 2: + case 3: + case 4: + random = 1; + break; + + default: + random = _vm->getRandomNumber(1, 50); + while (_lastRandom == random) + random = _vm->getRandomNumber(1, 50); + _lastRandom = random; + break; + } + + switch (random) { + case 1: + resetFrame = 45; + break; + default: + resetFrame = 43; + break; + } + break; + } + + if (resetFrame >= 0) { + _scene->setAnimFrame(_globals._animationIndexes[0], resetFrame); + _lastJacquesFrame = resetFrame; + } +} + +void Scene103::climbRightStairs() { + if (_scene->getAnimFrame(_globals._animationIndexes[3]) == _lastStairFrame) + return; + + _lastStairFrame = _scene->getAnimFrame(_globals._animationIndexes[3]); + int stairsResetFrame = -1; + + if (_lastStairFrame == 37) { + stairsResetFrame = 36; + _standPosition = 2; _game._player._stepEnabled = true; } - if (_action.isAction(VERB_CLOSE, NOUN_ORCHESTRA_DOOR)) { - _vm->_dialogs->show(10228); + if (_lastStairFrame == 2) { + _scene->deleteSequence(3); + _globals._sequenceIndexes[3] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[3], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[3], 13); + _scene->_sequences.setPosition(_globals._sequenceIndexes[3], Common::Point(154, 139)); + } + + if (stairsResetFrame >= 0) { + _scene->setAnimFrame(_globals._animationIndexes[3], stairsResetFrame); + _lastStairFrame = stairsResetFrame; + } +} + +void Scene103::climbLeftStairs() { + if (_scene->getAnimFrame(_globals._animationIndexes[5]) == _lastStairFrame) + return; + + _lastStairFrame = _scene->getAnimFrame(_globals._animationIndexes[5]); + int stairsResetFrame = -1; + + if (_lastStairFrame == 34) { + stairsResetFrame = 33; + _standPosition = 1; _game._player._stepEnabled = true; } + + if (_lastStairFrame == 2) { + _scene->deleteSequence(3); + _globals._sequenceIndexes[3] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[3], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[3], 13); + _scene->_sequences.setPosition(_globals._sequenceIndexes[3], Common::Point(37, 139)); + } + + if (stairsResetFrame >= 0) { + _scene->setAnimFrame(_globals._animationIndexes[5], stairsResetFrame); + _lastStairFrame = stairsResetFrame; + } +} + +void Scene103::descendRightStairs() { + if (_scene->getAnimFrame(_globals._animationIndexes[4]) == _lastStairFrame) + return; + + _lastStairFrame = _scene->getAnimFrame(_globals._animationIndexes[4]); + + if (_lastStairFrame == 2) { + _scene->deleteSequence(3); + _globals._sequenceIndexes[3] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[3], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[3], 4); + _scene->_sequences.setPosition(_globals._sequenceIndexes[3], Common::Point(154, 139)); + } +} + +void Scene103::descendLeftStairs() { + if (_scene->getAnimFrame(_globals._animationIndexes[6]) == _lastStairFrame) + return; + + _lastStairFrame = _scene->getAnimFrame(_globals._animationIndexes[6]); + + if (_lastStairFrame == 2) { + _scene->deleteSequence(3); + _globals._sequenceIndexes[3] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[3], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[3], 4); + _scene->_sequences.setPosition(_globals._sequenceIndexes[3], Common::Point(37, 139)); + } +} + +void Scene103::process_conv_jacques() { + bool quitConversationFl = false; + + switch (_action._activeAction._verbId) { + case 1: + _vm->_gameConv->setInterlocutorTrigger(96); + if (_globals[kJacquesNameIsKnown] == 0) { + _globals[kJacquesNameIsKnown] = 1; + _scene->_dynamicHotspots.remove(_hotspotGentleman); + _hotspotGentleman = _scene->_dynamicHotspots.add(NOUN_JACQUES, VERB_WALKTO, SYNTAX_SINGULAR_MASC, EXT_NONE, Common::Rect(156, 116, 156 + 33, 116 + 31)); + _scene->_dynamicHotspots[_hotspotGentleman]._articleNumber = PREP_ON; + _scene->_dynamicHotspots.setPosition(_hotspotGentleman, Common::Point(206, 148), FACING_NORTHWEST); + } + break; + + case 4: + case 6: + case 7: + case 10: + case 19: + case 30: { + _globals[kWalkerConverse] = 0; + int *val = _vm->_gameConv->getVariable(26); + if (*val) + _globals[kJacquesNameIsKnown] = 2; + + quitConversationFl = true; + } + break; + + case 8: + _vm->_gameConv->setInterlocutorTrigger(94); + break; + + case 12: + _vm->_gameConv->setInterlocutorTrigger(96); + break; + + case 29: + _vm->_gameConv->setInterlocutorTrigger(98); + break; + + default: + break; + } + + if ((_action._activeAction._verbId != 1) && (_action._activeAction._verbId != 8) + && (_action._activeAction._verbId != 12) && (_action._activeAction._verbId != 29)) + _vm->_gameConv->setInterlocutorTrigger(90); + + _vm->_gameConv->setHeroTrigger(92); + + switch (_game._trigger) { + case 90: + if (!quitConversationFl) + _globals[kWalkerConverse] = _vm->getRandomNumber(1, 4); + _jacquesAction = 0; + break; + + case 92: + if (!quitConversationFl) + _globals[kWalkerConverse] = _vm->getRandomNumber(2, 3); + _convCount = 0; + _jacquesAction = 1; + break; + + case 94: + if (!quitConversationFl) + _globals[kWalkerConverse] = _vm->getRandomNumber(1, 4); + _jacquesAction = 2; + break; + + case 96: + if (!quitConversationFl) + _globals[kWalkerConverse] = _vm->getRandomNumber(1, 4); + _jacquesAction = 3; + break; + + case 98: + if (!quitConversationFl) + _globals[kWalkerConverse] = _vm->getRandomNumber(1, 4); + _jacquesAction = 4; + break; + + default: + break; + } + + _talkCount = 0; } +/*------------------------------------------------------------------------*/ + +Scene104::Scene104(MADSEngine *vm) : Scene1xx(vm) { + _anim0ActvFl = _anim1ActvFl = _anim2ActvFl = false; + _needToTalk = false; + _needToGetUp = false; + _sittingUp = false; + _beforeHeLeaves = false; + _beforeSheLeaves = false; + _needToStandUp = false; + + _walkStatus = -1; + _walkFrame = -1; + _coupleStatus = -1; + _richStatus = -1; + _richTalkCount = -1; + _manTalkCount = -1; + _womanTalkCount = -1; + _lookCount = -1; + _coupleFrame = -1; + _lastPlayerFrame = -1; + _richFrame = -1; +} + +void Scene104::synchronize(Common::Serializer &s) { + Scene1xx::synchronize(s); + + s.syncAsByte(_anim0ActvFl); + s.syncAsByte(_anim1ActvFl); + s.syncAsByte(_anim2ActvFl); + s.syncAsByte(_needToTalk); + s.syncAsByte(_needToGetUp); + s.syncAsByte(_sittingUp); + s.syncAsByte(_beforeHeLeaves); + s.syncAsByte(_beforeSheLeaves); + s.syncAsByte(_needToStandUp); + + s.syncAsSint16LE(_walkStatus); + s.syncAsSint16LE(_walkFrame); + s.syncAsSint16LE(_coupleStatus); + s.syncAsSint16LE(_richStatus); + s.syncAsSint16LE(_richTalkCount); + s.syncAsSint16LE(_manTalkCount); + s.syncAsSint16LE(_womanTalkCount); + s.syncAsSint16LE(_lookCount); + s.syncAsSint16LE(_coupleFrame); + s.syncAsSint16LE(_lastPlayerFrame); +} + +void Scene104::setup() { + setPlayerSpritesPrefix(); + setAAName(); + + if (_globals[kTrapDoorStatus] == 1) + _scene->_variant = 1; + + _scene->addActiveVocab(NOUN_MONSIEUR_RICHARD); +} + +void Scene104::enter() { + _vm->_disableFastwalk = true; + + if (_scene->_priorSceneId != RETURNING_FROM_LOADING) { + _anim0ActvFl = false; + _anim1ActvFl = false; + _anim2ActvFl = false; + _needToTalk = false; + _needToGetUp = false; + _sittingUp = false; + _beforeSheLeaves = false; + _needToStandUp = false; + } + + _globals._spriteIndexes[1] = _scene->_sprites.addSprites(formAnimName('a', 0)); + _globals._spriteIndexes[3] = _scene->_sprites.addSprites(formAnimName('a', 6)); + _globals._spriteIndexes[0] = _scene->_sprites.addSprites(formAnimName('x', 0)); + + if (_globals[kCurrentYear] == 1993) + _globals._spriteIndexes[2] = _scene->_sprites.addSprites(formAnimName('z', 0)); + + _vm->_gameConv->get(7); + + if (_globals[kTrapDoorStatus] == 1) { + _globals._sequenceIndexes[0] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[0], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[0], 15); + } else { + _globals._sequenceIndexes[0] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[0], false, 2); + _scene->_sequences.setDepth(_globals._sequenceIndexes[0], 15); + } + + if (_scene->_priorSceneId == RETURNING_FROM_LOADING) { + if (_vm->_gameConv->_restoreRunning == 7) { + _globals._animationIndexes[1] = _scene->loadAnimation(formAnimName('r', 1), 1); + _globals._animationIndexes[2] = _scene->loadAnimation(formAnimName('d', 1), 1); + _walkStatus = 0; + _globals._animationIndexes[0] = _scene->loadAnimation(formAnimName('m', 1), 1); + if (_coupleStatus < 11) { + _coupleStatus = 1; + _richStatus = 0; + _scene->setAnimFrame(_globals._animationIndexes[1], 14); + } else { + _coupleStatus = 17; + _richStatus = 4; + _scene->setAnimFrame(_globals._animationIndexes[1], 105); + _scene->setAnimFrame(_globals._animationIndexes[0], 216); + } + + _vm->_gameConv->run(7); + _vm->_gameConv->exportPointer(&_globals[kPlayerScore]); + _game._player._visible = false; + } + + } else if (_scene->_priorSceneId == 301) { + _globals._animationIndexes[1] = _scene->loadAnimation(formAnimName('r', 1), 1); + _anim1ActvFl = true; + _coupleStatus = 11; + + _globals._animationIndexes[2] = _scene->loadAnimation(formAnimName('d', 1), 1); + _anim2ActvFl = true; + _walkStatus = 0; + + _globals._animationIndexes[0] = _scene->loadAnimation(formAnimName('m', 1), 1); + _anim0ActvFl = true; + _richStatus = 0; + + cleanInventory(); + + _game._player._visible = false; + _game._visitedScenes.pop_back(); + _globals[kTrapDoorStatus] = 1; + _globals[kCurrentYear] = 1881; + _globals[kPrompterStandStatus] = 1; + _globals[kTicketPeoplePresent] = 1; + _globals[kMakeBrieLeave203] = false; + _game._player._playerPos.x = 161; + + _game._visitedScenes.add(301); + _game._visitedScenes.add(101); + + _scene->setCamera(Common::Point(60, 0)); + _scene->_sequences.addTimer(1, 91); + + } else if (_scene->_priorSceneId == 103) { + if (_globals[kRoom103104Transition] == 0) { + _scene->_userInterface.emptyConversationList(); + _scene->_userInterface.setup(kInputConversation); + + if (!_globals[kObservedPhan104]) { + _globals._animationIndexes[4] = _scene->loadAnimation(formAnimName('p', 1), 93); + _game._player._playerPos.x = 319; + _game._player._stepEnabled = false; + _game._player._visible = false; + _scene->setCamera(Common::Point(158, 0)); + } else { + _globals._animationIndexes[5] = _scene->loadAnimation(formAnimName('p', 2), 94); + _game._player._playerPos.x = 319; + _game._player._stepEnabled = false; + _game._player._visible = false; + _scene->setCamera(Common::Point(158, 0)); + } + } else { + _game._player._playerPos = Common::Point(319, 96); + _game._player._facing = FACING_SOUTH; + _scene->setCamera(Common::Point(158, 0)); + } + } else if (_scene->_priorSceneId == 102) { + switch (_globals[kDeathLocation]) { + case 0: + _game._player._playerPos = Common::Point(496, 79); + _scene->setCamera(Common::Point(320, 0)); + break; + + case 1: + _game._player._playerPos = Common::Point(346, 71); + _scene->setCamera(Common::Point(158, 0)); + break; + + case 2: + _game._player._playerPos = Common::Point(172, 73); + break; + + default: + break; + } + } else if (_scene->_priorSceneId == 108) { + if (_game._player._playerPos.x > 213) + _game._player._playerPos.y = 97; + else if (_game._player._playerPos.x > 110) + _game._player._playerPos.y = 128; + else + _game._player._playerPos.y = 148; + + _game._player.firstWalk(Common::Point(-20, _game._player._playerPos.y), FACING_EAST, Common::Point(12, _game._player._playerPos.y), FACING_EAST, true); + } else if ((_scene->_priorSceneId == 107) || (_scene->_priorSceneId != RETURNING_FROM_LOADING)) { + if (_game._player._playerPos.x > 191) + _game._player._playerPos.y = 142; + else if (_game._player._playerPos.x > 104) + _game._player._playerPos.y = 120; + else + _game._player._playerPos.y = 95; + + _game._player.firstWalk(Common::Point(655, _game._player._playerPos.y), FACING_WEST, Common::Point(627, _game._player._playerPos.y), FACING_WEST, true); + _scene->setCamera(Common::Point(320, 0)); + } + + if (_globals[kCurrentYear] == 1993) { + _globals._sequenceIndexes[2] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[2], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[2], 14); + } else + _scene->_hotspots.activate(NOUN_CHANDELIER, false); + + if (_globals[kTrapDoorStatus] == 1) { + _globals._sequenceIndexes[0] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[0], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[0], 15); + } else { + _globals._sequenceIndexes[0] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[0], false, 2); + _scene->_sequences.setDepth(_globals._sequenceIndexes[0], 15); + } + + sceneEntrySound(); +} + +void Scene104::step() { + if (_anim0ActvFl) + handleRichAnimations(); + + if (_anim1ActvFl) + handleCoupleAnimations(); + + if (_anim2ActvFl) + handleWalkAnimation(); + + if (_game._player._moving) + handlePlayerWalk(); + + if (_game._trigger == 91) { + _vm->_dialogs->show(10434); + _vm->_gameConv->run(7); + _vm->_gameConv->exportPointer(&_globals[kPlayerScore]); + } + + if (_game._trigger == 93) { + _scene->_nextSceneId = 103; + _game._player._playerPos.x = 400; + _globals[kRoom103104Transition] = 0; + } + + if (_game._trigger == 94) { + _scene->_nextSceneId = 103; + _globals[kRoom103104Transition] = 0; + } +} + +void Scene104::preActions() { + if (_action.isAction(VERB_EXIT, NOUN_STAGE_LEFT)) + _game._player._walkOffScreenSceneId = 108; + + if (_action.isAction(VERB_EXIT, NOUN_STAGE_RIGHT)) + _game._player._walkOffScreenSceneId = 107; + + if (_action.isAction(VERB_OPEN, NOUN_TRAP_DOOR) || _action.isAction(VERB_CLOSE, NOUN_TRAP_DOOR)) + _game._player.walk(Common::Point(320, 92), FACING_NORTH); +} + +void Scene104::actions() { + if (_vm->_gameConv->_running == 7) { + processConversations(); + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_CLIMB_THROUGH, NOUN_TRAP_DOOR)) { + if (_globals[kTrapDoorStatus] == 0) { + switch (_game._trigger) { + case 0: + _game._player._visible = false; + _globals._sequenceIndexes[1] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[1], false, 8, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[1], 13); + _scene->_sequences.setAnimRange(_globals._sequenceIndexes[1], 1, 16); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[1], SEQUENCE_TRIGGER_EXPIRE, 0, 60); + break; + + case 60: + _scene->_nextSceneId = 103; + _globals[kRoom103104Transition] = 1; + _game._player._stepEnabled = true; + break; + + default: + break; + } + } else { + _vm->_dialogs->show(10429); + } + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_JUMP_INTO, NOUN_ORCHESTRA_PIT)) { + switch (_game._trigger) { + case 0: + if (_game._player._playerPos.x > 400) + _globals[kDeathLocation] = 0; + else if (_game._player._playerPos.x > 200) + _globals[kDeathLocation] = 1; + else + _globals[kDeathLocation] = 2; + + _scene->changeVariant(2); + + if (_globals[kTrapDoorStatus] == 1) + _scene->drawToBackground(_globals._spriteIndexes[0], 1, Common::Point(-32000, -32000), 0, 100); + else + _scene->drawToBackground(_globals._spriteIndexes[0], 2, Common::Point(-32000, -32000), 0, 100); + + _vm->_dialogs->show(10426); + _game._player._visible = false; + _game._player._stepEnabled = false; + _globals._sequenceIndexes[3] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[3], false, 7, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[3], 15); + _scene->_sequences.setAnimRange(_globals._sequenceIndexes[3], -1, 4); + _scene->_sequences.setPosition(_globals._sequenceIndexes[3], _game._player._playerPos); + _scene->_sequences.setSeqPlayer(_globals._sequenceIndexes[3], true); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SEQUENCE_TRIGGER_EXPIRE, 0, 1); + break; + + case 1: + _globals._sequenceIndexes[3] = _scene->_sequences.startPingPongCycle(_globals._spriteIndexes[3], false, 1, 10); + _scene->_sequences.addTimer(60, 2); + _scene->_sequences.setAnimRange(_globals._sequenceIndexes[3], 4, 4); + _scene->_sequences.setDepth(_globals._sequenceIndexes[3], 15); + _scene->_sequences.setSeqPlayer(_globals._sequenceIndexes[3], true); + _scene->_sequences.setMotion(_globals._sequenceIndexes[3], 0, 0, 200); + break; + + case 2: + _vm->_sound->command(1); + _vm->_sound->command(67); + _scene->_nextSceneId = 102; + break; + + default: + break; + } + _action._inProgress = false; + return; + } + + if (_action._lookFlag) { + if (_globals[kCurrentYear] == 1993) + _vm->_dialogs->show(10410); + else + _vm->_dialogs->show(10411); + + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_LOOK) || _action.isAction(VERB_LOOK_AT)) { + if (_action.isObject(NOUN_STAGE)) { + _vm->_dialogs->show(10412); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_APRON)) { + _vm->_dialogs->show(10413); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_PROSCENIUM_ARCH)) { + _vm->_dialogs->show(10414); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_ACT_CURTAIN)) { + _vm->_dialogs->show(10415); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_ORCHESTRA_PIT)) { + _vm->_dialogs->show(10416); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_CONDUCTORS_STAND)) { + _vm->_dialogs->show(10417); + _action._inProgress = false; + return; + } + + if ((_action.isObject(NOUN_MUSIC_STAND)) || (_action.isObject(NOUN_MUSIC_STANDS))) { + _vm->_dialogs->show(10418); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_PROMPTERS_BOX)) { + _vm->_dialogs->show(10419); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_TRAP_DOOR)) { + _vm->_dialogs->show(10420); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_HOUSE)) { + if (_globals[kCurrentYear] == 1881) + _vm->_dialogs->show(10421); + else + _vm->_dialogs->show(10427); + + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_STAGE_LEFT)) { + _vm->_dialogs->show(10422); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_STAGE_RIGHT)) { + _vm->_dialogs->show(10423); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_CHANDELIER)) { + _vm->_dialogs->show(10428); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_MONSIEUR_RICHARD)) { + _vm->_dialogs->show(10433); + _action._inProgress = false; + return; + } + } + + if (_action.isAction(VERB_JUMP_INTO, NOUN_ORCHESTRA_PIT)) { + _vm->_dialogs->show(10426); + _scene->_nextSceneId = 102; + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_OPEN, NOUN_PROMPTERS_BOX) || _action.isAction(VERB_CLOSE, NOUN_PROMPTERS_BOX)) { + _vm->_dialogs->show(10430); + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_OPEN, NOUN_TRAP_DOOR)) { + if (_globals[kTrapDoorStatus] == 0) + _vm->_dialogs->show(10424); + else + _vm->_dialogs->show(10432); + + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_CLOSE, NOUN_TRAP_DOOR)) { + if (_globals[kTrapDoorStatus] == 1) + _vm->_dialogs->show(10425); + else + _vm->_dialogs->show(10433); + + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_TAKE, NOUN_CHANDELIER)) { + _vm->_dialogs->show(10435); + _action._inProgress = false; + return; + } +} + +void Scene104::cleanInventory() { + if (_game._objects.isInInventory(OBJ_LARGE_NOTE)) + _game._objects.setRoom(OBJ_LARGE_NOTE, NOWHERE); + + if (_game._objects.isInInventory(OBJ_SANDBAG)) + _game._objects.setRoom(OBJ_SANDBAG, NOWHERE); + + if (_game._objects.isInInventory(OBJ_SMALL_NOTE)) + _game._objects.setRoom(OBJ_SMALL_NOTE, NOWHERE); + + if (_game._objects.isInInventory(OBJ_PARCHMENT)) + _game._objects.setRoom(OBJ_PARCHMENT, NOWHERE); + + if (_game._objects.isInInventory(OBJ_BOOK)) + _game._objects.setRoom(OBJ_BOOK, NOWHERE); + + if (_game._objects.isInInventory(OBJ_RED_FRAME)) + _game._objects.setRoom(OBJ_RED_FRAME, 105); + + if (_game._objects.isInInventory(OBJ_YELLOW_FRAME)) + _game._objects.setRoom(OBJ_YELLOW_FRAME, 107); + + if (_game._objects.isInInventory(OBJ_BLUE_FRAME)) + _game._objects.setRoom(OBJ_BLUE_FRAME, 302); + + if (_game._objects.isInInventory(OBJ_GREEN_FRAME)) + _game._objects.setRoom(OBJ_GREEN_FRAME, 307); +} + +void Scene104::processConversations() { + bool interlocutorTriggerFl = false; + bool heroTriggerFl = false; + + switch (_action._activeAction._verbId) { + case 2: + case 10: + case 12: + case 16: + case 20: + case 21: + case 24: + _vm->_gameConv->setInterlocutorTrigger(75); + interlocutorTriggerFl = true; + break; + + case 3: + if (!_needToGetUp) { + _vm->_gameConv->setInterlocutorTrigger(67); + interlocutorTriggerFl = true; + _needToGetUp = true; + } + break; + + case 8: + _vm->_gameConv->setInterlocutorTrigger(87); + interlocutorTriggerFl = true; + break; + + case 11: + _vm->_gameConv->setInterlocutorTrigger(77); + interlocutorTriggerFl = true; + break; + + case 14: + case 25: + if (!_game._trigger) { + _richStatus = 0; + _coupleStatus = 5; + _vm->_gameConv->hold(); + } + break; + + case 22: + _vm->_gameConv->setInterlocutorTrigger(75); + _vm->_gameConv->setHeroTrigger(79); + interlocutorTriggerFl = true; + heroTriggerFl = true; + break; + + case 23: + _vm->_gameConv->setInterlocutorTrigger(89); + interlocutorTriggerFl = true; + break; + + case 28: + _vm->_gameConv->setInterlocutorTrigger(81); + interlocutorTriggerFl = true; + break; + + case 30: + if (!_game._trigger) { + _vm->_gameConv->hold(); + _richStatus = 4; + } + break; + + case 32: + _coupleStatus = 14; + heroTriggerFl = true; + interlocutorTriggerFl = true; + _vm->_gameConv->hold(); + break; + + default: + break; + } + + switch (_game._trigger) { + case 67: + _vm->_gameConv->hold(); + _coupleStatus = 12; + break; + + case 69: + if (!_beforeSheLeaves && !_beforeHeLeaves && (_coupleStatus != 14) && !_needToStandUp) { + _richStatus = 0; + if (_sittingUp) + _coupleStatus = 4; + else + _coupleStatus = 12; + } + break; + + case 71: + if (!_beforeSheLeaves && !_beforeHeLeaves && (_coupleStatus != 14) && !_needToStandUp) { + _richStatus = 0; + if (_sittingUp && !_beforeSheLeaves) { + _coupleStatus = 3; + _richStatus = 0; + } + } + break; + + case 75: + _richStatus = 1; + + if (_sittingUp) { + if (_action._activeAction._verbId == 20) { + _lookCount = 0; + _coupleStatus = 9; + } else if ((_action._activeAction._verbId == 21) || (_action._activeAction._verbId == 22)) { + _lookCount = 0; + _coupleStatus = 10; + } else { + _coupleStatus = 1; + } + } else { + _coupleStatus = 11; + } + break; + + case 77: + _richStatus = 0; + _coupleStatus = 8; + break; + + case 79: + _richStatus = 0; + _coupleStatus = 7; + break; + + case 81: + _richStatus = 1; + _beforeHeLeaves = true; + _coupleStatus = 15; + break; + + case 83: + _vm->_gameConv->release(); + if (_coupleStatus != 17) + _game._player._stepEnabled = false; + break; + + case 87: + _richStatus = 3; + break; + + case 89: + _richStatus = 2; + break; + + default: + break; + } + + if (!heroTriggerFl && !_beforeSheLeaves) + _vm->_gameConv->setHeroTrigger(71); + + if (!interlocutorTriggerFl) + _vm->_gameConv->setInterlocutorTrigger(69); + + _richTalkCount = 0; + _manTalkCount = 0; + _womanTalkCount = 0; +} + +void Scene104::handleWalkAnimation() { + if (_scene->_animation[_globals._animationIndexes[2]]->getCurrentFrame() == _walkFrame) + return; + + _walkFrame = _scene->_animation[_globals._animationIndexes[2]]->getCurrentFrame(); + int daaeResetFrame = -1; + + switch (_walkFrame) { + case 1: + if (_walkStatus == 0) { + daaeResetFrame = 0; + } else { + _game.syncTimers(SYNC_ANIM, _globals._animationIndexes[2], SYNC_ANIM, _globals._animationIndexes[1]); + daaeResetFrame = 1; + } + break; + + case 138: + _walkStatus = 0; + daaeResetFrame = 0; + break; + + default: + break; + } + + if (daaeResetFrame >= 0) { + _scene->setAnimFrame(_globals._animationIndexes[2], daaeResetFrame); + _walkFrame = daaeResetFrame; + } +} + +void Scene104::handleRichAnimations() { + if (_scene->_animation[_globals._animationIndexes[0]]->getCurrentFrame() == _richFrame) + return; + + _richFrame = _scene->_animation[_globals._animationIndexes[0]]->getCurrentFrame(); + int random; + int resetFrame = -1; + + switch (_richFrame) { + case 1: + case 2: + case 3: + case 4: + case 8: + case 14: + case 22: + case 34: + case 40: + case 44: + case 48: + random = -1; + if (_richStatus == 1) { + random = _vm->getRandomNumber(1, 3); + ++_richTalkCount; + if (_richTalkCount > 15) { + _richStatus = 0; + random = 40; + } + } + + if (_richStatus == 0) + random = _vm->getRandomNumber(7, 80); + + if (_richStatus == 2) { + random = 4; + _richStatus = 1; + _richTalkCount = 8; + } + + if (_richStatus == 3) { + random = 5; + _richStatus = 1; + _richTalkCount = 8; + } + + if (_richStatus == 4) + random = 6; + + if (_richStatus == 5) + random = 7; + + switch (random) { + case 1: + resetFrame = 1; + break; + + case 2: + resetFrame = 2; + break; + + case 3: + resetFrame = 3; + break; + + case 4: + resetFrame = 23; + break; + + case 5: + resetFrame = 35; + break; + + case 6: + resetFrame = 49; + break; + + case 7: + resetFrame = 41; + break; + + case 8: + resetFrame = 45; + break; + + case 9: + resetFrame = 9; + break; + + case 10: + resetFrame = 5; + break; + + case 11: + resetFrame = 15; + break; + + default: + resetFrame = 0; + break; + } + break; + + case 117: + _coupleStatus = 13; + break; + + case 125: + resetFrame = 124; + break; + + default: + break; + } + + if (resetFrame >= 0) { + _scene->setAnimFrame(_globals._animationIndexes[0], resetFrame); + _richFrame = resetFrame; + } +} + +void Scene104::handleCoupleAnimations() { + if (_scene->_animation[_globals._animationIndexes[1]]->getCurrentFrame() == _coupleFrame) + return; + + _coupleFrame = _scene->_animation[_globals._animationIndexes[1]]->getCurrentFrame(); + int resetFrame = -1; + int random; + + switch (_coupleFrame) { + case 1: + case 103: + case 104: + case 105: + if (_coupleStatus == 11) + resetFrame = 0; + else { + resetFrame = _vm->getRandomNumber(102, 104); + ++_womanTalkCount; + if (_womanTalkCount > 15) { + if (_needToGetUp) { + _coupleStatus = 6; + resetFrame = 1; + } else { + _coupleStatus = 11; + resetFrame = 0; + } + } + } + break; + + case 9: + case 10: + case 11: + case 12: + case 13: + case 14: + case 15: + case 25: + case 33: + case 41: + switch (_coupleFrame) { + case 9: + _coupleStatus = 6; + break; + + case 33: + _vm->_gameConv->release(); + if (_action._activeAction._verbId == 13) + _coupleStatus = 4; + + break; + + case 41: + _vm->_gameConv->release(); + _sittingUp = true; + if (_needToTalk) + _coupleStatus = 3; + else + _coupleStatus = 1; + break; + + default: + break; + } + + random = -1; + + switch (_coupleStatus) { + case 1: + random = 12; + break; + + case 2: + case 7: + case 8: + random = 11; + break; + + case 3: + random = _vm->getRandomNumber(4, 6); + ++_manTalkCount; + if (_manTalkCount > 15) { + _coupleStatus = 1; + random = 12; + } + break; + + case 4: + if (_beforeSheLeaves) { + random = 10; + } else { + random = _vm->getRandomNumber(1, 3); + ++_womanTalkCount; + if (_womanTalkCount > 15) { + _coupleStatus = 1; + random = 12; + } + } + break; + + case 5: + _coupleStatus = 1; + random = 8; + break; + + case 6: + _coupleStatus = 1; + random = 7; + break; + + case 13: + random = 9; + break; + + case 15: + random = 10; + break; + + default: + break; + } + + switch (random) { + case 1: + resetFrame = 12; + break; + + case 2: + resetFrame = 13; + break; + + case 3: + resetFrame = 14; + break; + + case 4: + resetFrame = 9; + break; + + case 5: + resetFrame = 10; + break; + + case 6: + resetFrame = 11; + break; + + case 7: + resetFrame = 33; + break; + + case 8: + resetFrame = 25; + break; + + case 9: + resetFrame = 54; + break; + + case 10: + resetFrame = 41; + break; + + case 11: + resetFrame = 15; + break; + + case 12: + resetFrame = 14; + break; + + default: + break; + } + break; + + case 17: + case 18: + case 19: + case 20: + case 21: + case 22: + case 23: + random = -1; + switch (_coupleStatus) { + case 1: + case 3: + case 4: + case 5: + case 6: + case 15: + case 16: + random = 7; + break; + + case 2: + random = 8; + break; + + case 7: + random = _vm->getRandomNumber(4, 6); + ++_manTalkCount; + if (_manTalkCount > 15) { + _coupleStatus = 2; + random = 8; + } + break; + + case 8: + random = _vm->getRandomNumber(1, 3); + ++_womanTalkCount; + if (_womanTalkCount > 15) { + _coupleStatus = 1; + random = 7; + } + break; + + case 9: + random = 1; + ++_lookCount; + if (_lookCount > 6) { + _coupleStatus = 1; + random = 7; + } + break; + + case 10: + random = 1; + break; + + default: + break; + } + + switch (random) { + case 1: + resetFrame = 20; + break; + + case 2: + resetFrame = 21; + break; + + case 3: + resetFrame = 22; + break; + + case 4: + resetFrame = 17; + break; + + case 5: + resetFrame = 18; + break; + + case 6: + resetFrame = 19; + break; + + case 7: + resetFrame = 23; + break; + + case 8: + resetFrame = 20; + break; + + default: + break; + } + break; + + case 52: + _walkStatus = 1; + resetFrame = 54; + break; + + case 55: + if (_coupleStatus != 13) + resetFrame = 54; + + break; + + case 89: + _vm->_gameConv->release(); + break; + + case 90: + if (_coupleStatus != 14) { + resetFrame = 89; + } else { + resetFrame = 90; + _globals[kTempVar] = 200; + } + break; + + case 102: + _vm->_gameConv->release(); + _game._player._playerPos = Common::Point(166, 126); + _game._player.resetFacing(FACING_SOUTH); + resetFrame = 105; + _game._player._visible = true; + _game.syncTimers(SYNC_PLAYER, 0, SYNC_ANIM, _globals._animationIndexes[1]); + break; + + case 106: + _coupleStatus = 17; + resetFrame = 105; + break; + + default: + break; + } + + if (resetFrame >= 0) { + _scene->setAnimFrame(_globals._animationIndexes[1], resetFrame); + _coupleFrame = resetFrame; + } +} + +void Scene104::handlePlayerWalk() { + if (_game._player._frameNumber == _lastPlayerFrame) + return; + + _lastPlayerFrame = _game._player._frameNumber; + switch (_game._player._facing) { + case FACING_NORTH: + case FACING_SOUTH: + if ((_game._player._frameNumber == 5) || (_game._player._frameNumber == 11)) + _vm->_sound->command(68); + break; + + case FACING_NORTHEAST: + case FACING_NORTHWEST: + case FACING_SOUTHEAST: + case FACING_SOUTHWEST: + if ((_game._player._frameNumber == 7) || (_game._player._frameNumber == 14)) + _vm->_sound->command(68); + break; + + case FACING_EAST: + case FACING_WEST: + if ((_game._player._frameNumber == 8) || (_game._player._frameNumber == 16)) + _vm->_sound->command(68); + break; + + default: + break; + } +} + +/*------------------------------------------------------------------------*/ + +Scene105::Scene105(MADSEngine *vm) : Scene1xx(vm) { +} + +void Scene105::synchronize(Common::Serializer &s) { + Scene1xx::synchronize(s); + +} + +void Scene105::setup() { + if (_globals[kCurrentYear] == 1993) + _scene->_variant = 1; + + setPlayerSpritesPrefix(); + setAAName(); + + _scene->addActiveVocab(NOUN_LIGHT_FIXTURE); +} + +void Scene105::enter() { + _scene->loadSpeech(8); + + _globals._spriteIndexes[2] = _scene->_sprites.addSprites(formAnimName('x', 2)); + _globals._spriteIndexes[4] = _scene->_sprites.addSprites(formAnimName('x', 3)); + _globals._spriteIndexes[5] = _scene->_sprites.addSprites("*RRD_9"); + _globals._spriteIndexes[6] = _scene->_sprites.addSprites("*RDR_9"); + _globals._spriteIndexes[7] = _scene->_sprites.addSprites(formAnimName('a', 0)); + _globals._spriteIndexes[8] = _scene->_sprites.addSprites(formAnimName('a', 1)); + if (_globals[kCurrentYear] == 1993) + _globals._spriteIndexes[3] = _scene->_sprites.addSprites(formAnimName('z', -1)); + + if ((_globals[kCurrentYear] == 1881) && (!_globals[kHintThatDaaeIsHome2])) { + if ((_globals[kJacquesNameIsKnown] == 2) && (_globals[kMadameNameIsKnown] == 2) && + _globals[kPanelIn206] && _globals[kDoneRichConv203] && _game._objects.isInInventory(OBJ_LANTERN) && + ((_game._objects.isInInventory(OBJ_CABLE_HOOK) && _game._objects.isInInventory(OBJ_ROPE)) || _game._objects.isInInventory(OBJ_ROPE_WITH_HOOK))) { + _globals[kHintThatDaaeIsHome2] = true; + _scene->_sequences.addTimer(300, 75); + } + } + + if ((_game._objects.isInRoom(OBJ_LANTERN)) && (_globals[kCurrentYear] == 1881)) { + _globals._spriteIndexes[0] = _scene->_sprites.addSprites(formAnimName('x', 0)); + _globals._sequenceIndexes[0] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[0], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[0], 14); + } else { + _scene->_hotspots.activate(NOUN_LANTERN, false); + } + + if (_game._objects.isInRoom(OBJ_RED_FRAME)) { + _globals._spriteIndexes[1] = _scene->_sprites.addSprites(formAnimName('x', 1)); + _globals._sequenceIndexes[1] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[1], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[1], 14); + } else { + _scene->_hotspots.activate(NOUN_RED_FRAME, false); + } + + if (_globals[kCurrentYear] == 1993) { + _scene->drawToBackground(_globals._spriteIndexes[3], 1, Common::Point(-32000, -32000), 0, 100); + _scene->_hotspots.activate(NOUN_PROPS, false); + _scene->_hotspots.activate(NOUN_BEAR_PROP, false); + _scene->_hotspots.activate(NOUN_STAIR_UNIT, false); + _scene->_hotspots.activate(NOUN_PROP, false); + _scene->_hotspots.activate(NOUN_ELEPHANT_PROP, false); + _scene->_hotspots.activate(NOUN_COLUMN_PROP, false); + + int tmpIdx = _scene->_dynamicHotspots.add(NOUN_COLUMN_PROP, VERB_WALKTO, SYNTAX_SINGULAR, EXT_NONE, Common::Rect(132, 24, 132 + 21, 24 + 105)); + _scene->_dynamicHotspots.setPosition(tmpIdx, Common::Point(159, 133), FACING_NORTHWEST); + + tmpIdx = _scene->_dynamicHotspots.add(NOUN_COLUMN_PROP, VERB_WALKTO, SYNTAX_SINGULAR, EXT_NONE, Common::Rect(56, 45, 56 + 11, 45 + 77)); + _scene->_dynamicHotspots.setPosition(tmpIdx, Common::Point(72, 126), FACING_NORTHWEST); + + _scene->_dynamicHotspots.add(NOUN_PROP, VERB_WALKTO, SYNTAX_SINGULAR, EXT_NONE, Common::Rect(0, 125, 29, 125 + 31)); + _scene->_dynamicHotspots.add(NOUN_PROP, VERB_WALKTO, SYNTAX_SINGULAR, EXT_NONE, Common::Rect(29, 136, 29 + 50, 136 + 20)); + _scene->_dynamicHotspots.add(NOUN_PROP, VERB_WALKTO, SYNTAX_SINGULAR, EXT_NONE, Common::Rect(79, 141, 79 + 53, 141 + 15)); + + _scene->_dynamicHotspots.add(NOUN_BEAR_PROP, VERB_WALKTO, SYNTAX_SINGULAR, EXT_NONE, Common::Rect(278, 132, 278 + 21, 132 + 24)); + _scene->_dynamicHotspots.add(NOUN_BEAR_PROP, VERB_WALKTO, SYNTAX_SINGULAR, EXT_NONE, Common::Rect(299, 146, 299 + 8, 146 + 10)); + _scene->_dynamicHotspots.add(NOUN_BEAR_PROP, VERB_WALKTO, SYNTAX_SINGULAR, EXT_NONE, Common::Rect(269, 142, 269 + 8, 142 + 8)); + + _scene->_dynamicHotspots.add(NOUN_LIGHT_FIXTURE, VERB_LOOK_AT, SYNTAX_SINGULAR, EXT_NONE, Common::Rect(102, 14, 102 + 24, 102 + 10)); + } + + _globals._sequenceIndexes[4] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[4], false, 2); + _scene->_sequences.setDepth(_globals._sequenceIndexes[4], 14); + + if ((_scene->_priorSceneId == 106) || (_scene->_priorSceneId == 114)) { + _game._player._playerPos = Common::Point(198, 132); + _game._player._facing = FACING_WEST; + _globals._sequenceIndexes[2] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[2], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[2], 10); + } else if ((_scene->_priorSceneId == 103) || (_scene->_priorSceneId != RETURNING_FROM_LOADING)) { + _game._player._playerPos = Common::Point(3, 112); + _game._player._facing = FACING_SOUTHEAST; + _game._player.walk(Common::Point(45, 131), FACING_SOUTHEAST); + _game._player.setWalkTrigger(60); + _game._player._stepEnabled = false; + _globals._sequenceIndexes[2] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[2], false, 8); + _scene->_sequences.setDepth(_globals._sequenceIndexes[2], 10); + } else if (_scene->_priorSceneId == RETURNING_FROM_LOADING) { + _globals._sequenceIndexes[2] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[2], false, -1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[2], 10); + } + + sceneEntrySound(); +} + +void Scene105::step() { + switch (_game._trigger) { + case 60: + _scene->deleteSequence(_globals._sequenceIndexes[2]); + _globals._sequenceIndexes[2] = _scene->_sequences.addReverseSpriteCycle(_globals._spriteIndexes[2], false, 8, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[2], 10); + _scene->_sequences.setAnimRange(_globals._sequenceIndexes[2], 1, 8); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SEQUENCE_TRIGGER_EXPIRE, 0, 61); + _vm->_sound->command(66); + break; + + case 61: + _vm->_sound->command(25); + _globals._sequenceIndexes[2] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[2], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[2], 10); + _game._player._stepEnabled = true; + break; + + case 75: + _scene->playSpeech(8); + _scene->_sequences.addTimer(120, 76); + break; + + case 76: + _vm->_dialogs->show(10537); + break; + + default: + break; + } +} + +void Scene105::actions() { + if ((_action.isAction(VERB_PUSH, NOUN_THUNDER_MACHINE)) || (_action.isAction(VERB_PULL, NOUN_THUNDER_MACHINE))) { + switch (_game._trigger) { + case 0: + _game._player._stepEnabled = false; + _game._player._visible = false; + _globals._animationIndexes[0] = _scene->loadAnimation(formAnimName('t', 1), 70); + _scene->deleteSequence(_globals._sequenceIndexes[4]); + _game.syncTimers(SYNC_SEQ, _globals._sequenceIndexes[4], SYNC_ANIM, _globals._animationIndexes[0]); + _scene->_sequences.setSeqPlayer(_globals._animationIndexes[0], false); + break; + + case 70: + _globals._sequenceIndexes[4] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[4], false, 2); + _scene->_sequences.setDepth(_globals._sequenceIndexes[4], 14); + _game.syncTimers(SYNC_SEQ, _globals._sequenceIndexes[4], SYNC_ANIM, _globals._animationIndexes[0]); + _game._player._stepEnabled = true; + _game._player._visible = true; + _game.syncTimers(SYNC_PLAYER, 0, SYNC_ANIM, _globals._animationIndexes[0]); + break; + + default: + break; + } + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_CLIMB_UP, NOUN_CIRCULAR_STAIRCASE)) { + switch (_game._trigger) { + case 0: + _game._player._stepEnabled = false; + _game._player._visible = false; + _globals._animationIndexes[0] = _scene->loadAnimation(formAnimName('u', 1), 1); + _game.syncTimers(SYNC_ANIM, _globals._animationIndexes[0], SYNC_PLAYER, 0); + break; + + case 1: + _scene->_nextSceneId = 106; + break; + + default: + break; + } + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_CLIMB_DOWN, NOUN_CIRCULAR_STAIRCASE)) { + switch (_game._trigger) { + case 0: + _game._player._stepEnabled = false; + _game._player._visible = false; + _globals._animationIndexes[0] = _scene->loadAnimation(formAnimName('d', 1), 1); + _game.syncTimers(SYNC_ANIM, _globals._animationIndexes[0], SYNC_PLAYER, 0); + break; + + case 1: + _scene->_nextSceneId = 114; + break; + + default: + break; + } + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_TAKE, NOUN_RED_FRAME) && (_game._objects.isInRoom(OBJ_RED_FRAME) || _game._trigger)) { + switch (_game._trigger) { + case (0): + if (_globals[kCurrentYear] == 1881) { + int count = 0; + + if (_game._objects.isInInventory(NOUN_YELLOW_FRAME)) + ++count; + + if (_game._objects.isInInventory(NOUN_GREEN_FRAME)) + ++count; + + if (_game._objects.isInInventory(NOUN_BLUE_FRAME)) + ++count; + + if (count < 3) + _globals[kPlayerScore] += 5; + } + + _game._player._stepEnabled = false; + _game._player._visible = false; + _globals._sequenceIndexes[5] = _scene->_sequences.startPingPongCycle(_globals._spriteIndexes[5], true, 5, 2); + _scene->_sequences.setAnimRange(_globals._sequenceIndexes[5], 1, 5); + _scene->_sequences.setSeqPlayer(_globals._sequenceIndexes[5], true); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[5], SEQUENCE_TRIGGER_SPRITE, 5, 1); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[5], SEQUENCE_TRIGGER_EXPIRE, 0, 2); + break; + + case 1: + _scene->deleteSequence(_globals._sequenceIndexes[1]); + _scene->_hotspots.activate(NOUN_RED_FRAME, false); + _game._objects.addToInventory(OBJ_RED_FRAME); + _vm->_sound->command(26); + break; + + case 2: + _game.syncTimers(SYNC_PLAYER, 0, SYNC_SEQ, _globals._sequenceIndexes[5]); + _game._player._visible = true; + _scene->_sequences.addTimer(20, 3); + break; + + case 3: + if (_globals[kCurrentYear] == 1881) + _vm->_dialogs->showItem(OBJ_RED_FRAME, 842, 0); + else + _vm->_dialogs->showItem(OBJ_RED_FRAME, 802, 0); + + _game._player._stepEnabled = true; + break; + } + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_TAKE, NOUN_LANTERN) && (_game._objects.isInRoom(OBJ_LANTERN) || _game._trigger)) { + switch (_game._trigger) { + case (0): + _globals[kPlayerScore] += 5; + _game._player._stepEnabled = false; + _game._player._visible = false; + _globals._sequenceIndexes[6] = _scene->_sequences.startPingPongCycle(_globals._spriteIndexes[6], true, 5, 2); + _scene->_sequences.setAnimRange(_globals._sequenceIndexes[6], 1, 4); + _scene->_sequences.setSeqPlayer(_globals._sequenceIndexes[6], true); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[6], SEQUENCE_TRIGGER_SPRITE, 4, 1); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[6], SEQUENCE_TRIGGER_EXPIRE, 0, 2); + break; + + case 1: + _scene->deleteSequence(_globals._sequenceIndexes[0]); + _scene->_hotspots.activate(NOUN_LANTERN, false); + _game._objects.addToInventory(OBJ_LANTERN); + _vm->_sound->command(26); + break; + + case 2: + _game.syncTimers(SYNC_PLAYER, 0, SYNC_SEQ, _globals._sequenceIndexes[6]); + _game._player._visible = true; + _scene->_sequences.addTimer(20, 3); + break; + + case 3: + _vm->_dialogs->showItem(OBJ_LANTERN, 801, 0); + _game._player._stepEnabled = true; + break; + + default: + break; + } + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_WALK_THROUGH, NOUN_DOOR) || _action.isAction(VERB_OPEN, NOUN_DOOR) || (_game._trigger) || + _action.isAction(VERB_UNLOCK, NOUN_DOOR) || _action.isAction(VERB_LOCK, NOUN_DOOR)) { + if ((_globals[kCurrentYear] == 1881) && !_action.isAction(VERB_UNLOCK) && !_action.isAction(VERB_LOCK)){ + switch (_game._trigger) { + case (0): + _game._player._stepEnabled = false; + _game._player._visible = false; + _globals._sequenceIndexes[6] = _scene->_sequences.startPingPongCycle(_globals._spriteIndexes[6], true, 5, 2); + _scene->_sequences.setAnimRange(_globals._sequenceIndexes[6], 1, 4); + _scene->_sequences.setSeqPlayer(_globals._sequenceIndexes[6], true); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[6], SEQUENCE_TRIGGER_SPRITE, 4, 65); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[6], SEQUENCE_TRIGGER_EXPIRE, 0, 2); + break; + + case 2: + _game._player._visible = true; + _scene->_sequences.addTimer(180, 3); + break; + + case 3: + _scene->_nextSceneId = 103; + break; + + case 65: + _vm->_sound->command(24); + _scene->deleteSequence(_globals._sequenceIndexes[2]); + _globals._sequenceIndexes[2] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[2], false, 8, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[2], 14); + _scene->_sequences.setAnimRange(_globals._sequenceIndexes[2], 1, 8); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SEQUENCE_TRIGGER_EXPIRE, 0, 66); + _vm->_sound->command(66); + break; + + case 66: { + int tmpIdx = _globals._sequenceIndexes[2]; + _globals._sequenceIndexes[2] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[2], false, 8); + _game.syncTimers(SYNC_SEQ, _globals._sequenceIndexes[2], SYNC_SEQ, tmpIdx); + _scene->_sequences.setDepth(_globals._sequenceIndexes[2], 14); + _game._player.walk(Common::Point(0, 111), FACING_NORTHWEST); + } + break; + + default: + break; + } + } else { + switch (_game._trigger) { + case (0): + _game._player._stepEnabled = false; + _game._player._visible = false; + _globals._sequenceIndexes[6] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[6], true, 5, 1); + _scene->_sequences.setAnimRange(_globals._sequenceIndexes[6], 1, 4); + _scene->_sequences.setSeqPlayer(_globals._sequenceIndexes[6], true); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[6], SEQUENCE_TRIGGER_EXPIRE, 0, 1); + break; + + case 1: { + int tmpIdx = _globals._sequenceIndexes[6]; + _globals._sequenceIndexes[6] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[6], true, 4); + _game.syncTimers(SYNC_SEQ, _globals._sequenceIndexes[6], SYNC_SEQ, tmpIdx); + _scene->_sequences.setSeqPlayer(_globals._sequenceIndexes[6], false); + _vm->_sound->command(73); + _scene->_sequences.addTimer(15, 2); + } + break; + + case 2: + _scene->deleteSequence(_globals._sequenceIndexes[6]); + _globals._sequenceIndexes[6] = _scene->_sequences.addReverseSpriteCycle(_globals._spriteIndexes[6], true, 5, 1); + _scene->_sequences.setAnimRange(_globals._sequenceIndexes[6], 1, 4); + _scene->_sequences.setSeqPlayer(_globals._sequenceIndexes[6], false); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[6], SEQUENCE_TRIGGER_EXPIRE, 0, 3); + break; + + case 3: + _game.syncTimers(SYNC_PLAYER, 0, SYNC_SEQ, _globals._sequenceIndexes[6]); + _game._player._visible = true; + if (_action.isAction(VERB_LOCK) || _action.isAction(VERB_UNLOCK)) + _vm->_dialogs->show(32); + else + _vm->_dialogs->show(10536); + + _game._player._stepEnabled = true; + break; + + default: + break; + } + } + _action._inProgress = false; + return; + } + + if (_action._lookFlag) { + if (_globals[kCurrentYear] == 1993) + _vm->_dialogs->show(10510); + else + _vm->_dialogs->show(10511); + + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_LOOK) || _action.isAction(VERB_LOOK_AT)) { + if (_action.isObject(NOUN_FLOOR)) { + _vm->_dialogs->show(10512); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_CIRCULAR_STAIRCASE)) { + _vm->_dialogs->show(10513); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_LANTERN) && _game._objects.isInRoom(OBJ_LANTERN)) { + _vm->_dialogs->show(10514); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_RED_FRAME) && _game._objects.isInRoom(OBJ_RED_FRAME)){ + if (_globals[kCurrentYear] == 1881) + _vm->_dialogs->show(10530); + else + _vm->_dialogs->show(10515); + + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_DOOR)) { + _vm->_dialogs->show(10516); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_WALL)) { + _vm->_dialogs->show(10517); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_PROP_TABLE)) { + _vm->_dialogs->show(10518); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_BEAR_PROP)) { + if (_globals[kCurrentYear] == 1993) + _vm->_dialogs->show(10519); + else + _vm->_dialogs->show(10538); + + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_ELEPHANT_PROP)) { + _vm->_dialogs->show(10520); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_COLUMN_PROP)) { + if (_globals[kCurrentYear] == 1993) + _vm->_dialogs->show(10521); + else + _vm->_dialogs->show(10539); + + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_THUNDER_MACHINE)) { + if (_globals[kCurrentYear] == 1993) + _vm->_dialogs->show(10522); + else + _vm->_dialogs->show(10540); + + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_STAIR_UNIT)) { + _vm->_dialogs->show(10523); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_PROP)) { + _vm->_dialogs->show(10524); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_PROPS)) { + _vm->_dialogs->show(10525); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_EXIT_SIGN)) { + _vm->_dialogs->show(10526); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_FLATS)) { + _vm->_dialogs->show(10527); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_HEMP)) { + _vm->_dialogs->show(10528); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_PIPE)) { + _vm->_dialogs->show(10529); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_GRAFFITI)) { + _vm->_dialogs->show(10531); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_LIGHT_FIXTURE)) { + _vm->_dialogs->show(10535); + _action._inProgress = false; + return; + } + } + + if (_action.isAction(VERB_TALK_TO, NOUN_BEAR_PROP)) { + _vm->_dialogs->show(10532); + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_TAKE, NOUN_BEAR_PROP)) { + _vm->_dialogs->show(10533); + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_CLOSE, NOUN_DOOR)) { + _vm->_dialogs->show(10534); + _action._inProgress = false; + return; + } +} + +void Scene105::preActions() { + if (_action.isAction(VERB_WALK_THROUGH, NOUN_DOOR_TO_PIT)) + _game._player._walkOffScreenSceneId = 102; + + if (_action.isAction(VERB_OPEN, NOUN_DOOR) || _action.isAction(VERB_UNLOCK, NOUN_DOOR) || _action.isAction(VERB_LOCK, NOUN_DOOR)) + _game._player.walk(Common::Point(33, 128), FACING_NORTHWEST); +} + +/*------------------------------------------------------------------------*/ + +Scene106::Scene106(MADSEngine *vm) : Scene1xx(vm) { + _sandbagHostpotId = -1; +} + +void Scene106::synchronize(Common::Serializer &s) { + Scene1xx::synchronize(s); + + s.syncAsSint16LE(_sandbagHostpotId); +} + +void Scene106::setup() { + if (_globals[kCurrentYear] == 1881) + _scene->_variant = 1; + + setPlayerSpritesPrefix(); + setAAName(); +} + +void Scene106::enter() { + _scene->loadSpeech(8); + + if (_globals[kCurrentYear] == 1993) { + if (!_game._objects.isInInventory(OBJ_SANDBAG)) { + _globals._spriteIndexes[5] = _scene->_sprites.addSprites("*RRD_9"); + _globals._spriteIndexes[0] = _scene->_sprites.addSprites(formAnimName('x', 0)); + } + } else { + _globals._spriteIndexes[7] = _scene->_sprites.addSprites(formAnimName('z', -1)); + if (_game._objects.isInRoom(OBJ_CABLE_HOOK) && !_game._objects.isInInventory(OBJ_ROPE_WITH_HOOK)) { + _globals._spriteIndexes[5] = _scene->_sprites.addSprites("*RRD_9"); + _globals._spriteIndexes[8] = _scene->_sprites.addSprites(formAnimName('p', 0)); + } + } + + _globals._spriteIndexes[1] = _scene->_sprites.addSprites(formAnimName('a', 0)); + _globals._spriteIndexes[2] = _scene->_sprites.addSprites(formAnimName('x', 1)); + _globals._spriteIndexes[3] = _scene->_sprites.addSprites("*RDR_9"); + _globals._spriteIndexes[4] = _scene->_sprites.addSprites(formAnimName('a', 1)); + _globals._spriteIndexes[6] = _scene->_sprites.addSprites(formAnimName('a', 2)); + + if ((_globals[kCurrentYear] == 1881) && (!_globals[kHintThatDaaeIsHome1])) { + if ((_globals[kJacquesNameIsKnown] == 2) && (_globals[kMadameNameIsKnown] == 2) + && (_globals[kPanelIn206]) && (_globals[kDoneRichConv203]) && (_game._objects.isInInventory(OBJ_LANTERN)) + && ((_game._objects.isInInventory(OBJ_CABLE_HOOK) && _game._objects.isInInventory(OBJ_ROPE)) + || _game._objects.isInInventory(OBJ_ROPE_WITH_HOOK))) { + _globals[kHintThatDaaeIsHome1] = true; + _scene->_sequences.addTimer(300, 85); + } + } + + if ((_globals[kSandbagStatus] == 1) && (_globals[kCurrentYear] == 1993) && _game._objects.isInRoom(OBJ_SANDBAG)) { + _globals._sequenceIndexes[0] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[0], false, -2); + _sandbagHostpotId = _scene->_dynamicHotspots.add(NOUN_SANDBAG, VERB_WALK_TO, SYNTAX_SINGULAR, EXT_NONE, Common::Rect(227, 140, 227 + 18, 140 + 11)); + _scene->_dynamicHotspots.setPosition(_sandbagHostpotId, Common::Point(224, 152), FACING_NORTHEAST); + _scene->_sequences.setDepth(_globals._sequenceIndexes[0], 2); + } + + if (_globals[kCurrentYear] == 1881) { + _scene->drawToBackground(_globals._spriteIndexes[7], 1, Common::Point(-32000, -32000), 0, 100); + _scene->_hotspots.activate(NOUN_BIG_PROP, false); + _scene->_hotspots.activate(NOUN_STATUE, false); + _scene->_hotspots.activate(NOUN_PLANT_PROP, false); + _scene->_hotspots.activate(NOUN_PEDESTAL, false); + _scene->_hotspots.activate(NOUN_SANDBAG, false); + _scene->_hotspots.activate(NOUN_CRATE, false); + + _scene->_dynamicHotspots.add(NOUN_SANDBAG, VERB_LOOK_AT, SYNTAX_SINGULAR, EXT_NONE, Common::Rect(40, 47, 40 + 11, 47 + 17)); + _scene->_dynamicHotspots.add(NOUN_SANDBAG, VERB_LOOK_AT, SYNTAX_SINGULAR, EXT_NONE, Common::Rect(98, 14, 98 + 5, 14 + 10)); + _scene->_dynamicHotspots.add(NOUN_SANDBAG, VERB_LOOK_AT, SYNTAX_SINGULAR, EXT_NONE, Common::Rect(111, 23, 111 + 6, 23 + 9)); + _scene->_dynamicHotspots.add(NOUN_SANDBAG, VERB_LOOK_AT, SYNTAX_SINGULAR, EXT_NONE, Common::Rect(119, 12, 119 + 5, 12 + 8)); + + int idx = _scene->_dynamicHotspots.add(NOUN_STAGE, VERB_WALK_ACROSS, SYNTAX_SINGULAR, EXT_NONE, Common::Rect(80, 114, 80 + 24, 114 + 4)); + _scene->_dynamicHotspots.setPosition(idx, Common::Point(93, 121), FACING_NONE); + + idx = _scene->_dynamicHotspots.add(NOUN_STAGE, VERB_WALK_ACROSS, SYNTAX_SINGULAR, EXT_NONE, Common::Rect(106, 102, 106 + 5, 102 + 10)); + _scene->_dynamicHotspots.setPosition(idx, Common::Point(108, 109), FACING_NONE); + } else { + _scene->_hotspots.activate(NOUN_BOXES, false); + _scene->_hotspots.activate(NOUN_CASE, false); + } + + if ((_game._objects.isInRoom(OBJ_CABLE_HOOK)) && (_globals[kCurrentYear] == 1881) && !_game._objects.isInInventory(OBJ_ROPE_WITH_HOOK)){ + _globals._sequenceIndexes[8] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[8], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[8], 3); + } else { + _scene->_hotspots.activate(NOUN_CABLE_HOOK, false); + } + + if (_scene->_priorSceneId == 109) { + _game._player._playerPos = Common::Point(180, 58); + _game._player._facing = FACING_SOUTH; + _game._player.walk(Common::Point(179, 63), FACING_SOUTH); + _game._player.setWalkTrigger(60); + _game._player._stepEnabled = false; + _globals._sequenceIndexes[2] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[2], false, 5); + _scene->_sequences.setDepth(_globals._sequenceIndexes[2], 14); + } else if ((_scene->_priorSceneId == 105) || (_scene->_priorSceneId == 301)) { + _game._player._playerPos = Common::Point(235, 142); + _game._player._facing = FACING_WEST; + _game._player.walk(Common::Point(227, 143), FACING_WEST); + _globals._sequenceIndexes[2] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[2], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[2], 14); + } else if (_scene->_priorSceneId == 107) { + _game._player._playerPos = Common::Point(143, 68); + _game._player._facing = FACING_WEST; + _game._player.walk(Common::Point(163, 68), FACING_SOUTHEAST); + _globals._sequenceIndexes[2] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[2], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[2], 14); + } else if ((_scene->_priorSceneId == 108) || (_scene->_priorSceneId != RETURNING_FROM_LOADING)) { + _game._player.firstWalk(Common::Point(-20, 130), FACING_SOUTHEAST, Common::Point(19, 147), FACING_NORTHEAST, true); + _globals._sequenceIndexes[2] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[2], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[2], 14); + } else if (_scene->_priorSceneId == RETURNING_FROM_LOADING) { + _globals._sequenceIndexes[2] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[2], false, -1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[2], 14); + } + + sceneEntrySound(); +} + +void Scene106::step() { + switch (_game._trigger) { + case 85: + _scene->playSpeech(8); + _scene->_sequences.addTimer(120, 86); + break; + + case 86: + _vm->_dialogs->show(10637); + break; + + case 60: + _scene->deleteSequence(_globals._sequenceIndexes[2]); + _globals._sequenceIndexes[2] = _scene->_sequences.addReverseSpriteCycle(_globals._spriteIndexes[2], false, 8, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[2], 14); + _scene->_sequences.setAnimRange(_globals._sequenceIndexes[2], 1, 5); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SEQUENCE_TRIGGER_EXPIRE, 0, 61); + break; + + case 61: + _globals._sequenceIndexes[2] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[2], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[2], 14); + _vm->_sound->command(25); + _game._player._stepEnabled = true; + break; + + default: + break; + } +} + +void Scene106::actions() { + if ((_action.isAction(VERB_TAKE, NOUN_SANDBAG)) && (_scene->_customDest.y < 61)) { + _vm->_dialogs->show(10635); + _action._inProgress = false; + return; + } else if (_action.isAction(VERB_TAKE, NOUN_SANDBAG)) { + if (_game._objects.isInRoom(OBJ_SANDBAG)) { + switch (_game._trigger) { + case (0): + _game._player._stepEnabled = false; + _game._player._visible = false; + _globals._sequenceIndexes[5] = _scene->_sequences.startPingPongCycle(_globals._spriteIndexes[5], false, 5, 2); + _scene->_sequences.setAnimRange(_globals._sequenceIndexes[5], 1, 5); + _scene->_sequences.setSeqPlayer(_globals._sequenceIndexes[5], true); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[5], SEQUENCE_TRIGGER_SPRITE, 5, 1); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[5], SEQUENCE_TRIGGER_EXPIRE, 0, 2); + break; + + case 1: + _scene->deleteSequence(_globals._sequenceIndexes[0]); + _scene->_dynamicHotspots.remove(_sandbagHostpotId); + _vm->_sound->command(26); + break; + + case 2: + _game.syncTimers(SYNC_PLAYER, 0, SYNC_SEQ, _globals._sequenceIndexes[5]); + _game._player._visible = true; + _scene->_sequences.addTimer(20, 3); + break; + + case 3: + _game._objects.addToInventory(OBJ_SANDBAG); + _vm->_dialogs->showItem(OBJ_SANDBAG, 803, 0); + _game._player._stepEnabled = true; + break; + + default: + break; + } + _action._inProgress = false; + return; + } + } + + if (_action.isAction(VERB_TAKE, NOUN_CABLE_HOOK)) { + if (_game._objects.isInRoom(OBJ_CABLE_HOOK)) { + switch (_game._trigger) { + case (0): + _game._player._stepEnabled = false; + _game._player._visible = false; + _globals._sequenceIndexes[5] = _scene->_sequences.startPingPongCycle(_globals._spriteIndexes[5], true, 5, 2); + _scene->_sequences.setAnimRange(_globals._sequenceIndexes[5], 1, 5); + _scene->_sequences.setSeqPlayer(_globals._sequenceIndexes[5], true); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[5], SEQUENCE_TRIGGER_SPRITE, 5, 1); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[5], SEQUENCE_TRIGGER_EXPIRE, 0, 2); + _globals[kPlayerScore] += 5; + break; + + case 1: + _scene->deleteSequence(_globals._sequenceIndexes[8]); + _scene->_hotspots.activate(NOUN_CABLE_HOOK, false); + _vm->_sound->command(26); + break; + + case 2: + _game.syncTimers(SYNC_PLAYER, 0, SYNC_SEQ, _globals._sequenceIndexes[5]); + _game._player._visible = true; + _scene->_sequences.addTimer(20, 3); + break; + + case 3: + _game._objects.addToInventory(OBJ_CABLE_HOOK); + _vm->_dialogs->showItem(OBJ_CABLE_HOOK, 822, 0); + _game._player._stepEnabled = true; + break; + + default: + break; + } + _action._inProgress = false; + return; + } + } + + switch (_game._trigger) { + case 75: + _game._player._stepEnabled = false; + _game._player._visible = false; + _globals._animationIndexes[0] = _scene->loadAnimation(formAnimName('d', 1), 76); + _game.syncTimers(SYNC_ANIM, _globals._animationIndexes[0], SYNC_PLAYER, 0); + _action._inProgress = false; + return; + + case 76: + _scene->_nextSceneId = 105; + _action._inProgress = false; + return; + + case 80: + _game._player._stepEnabled = false; + _game._player._visible = false; + _globals._animationIndexes[0] = _scene->loadAnimation(formAnimName('u', 1), 81); + _game.syncTimers(SYNC_ANIM, _globals._animationIndexes[0], SYNC_PLAYER, 0); + _action._inProgress = false; + return; + + case 81: + _scene->_sequences.addTimer(120, 82); + _action._inProgress = false; + return; + + case 82: + _scene->_nextSceneId = 301; + _action._inProgress = false; + return; + + default: + break; + } + + if (_action.isAction(VERB_EXIT_TO, NOUN_STAGE_RIGHT_WING)) { + _scene->_nextSceneId = 107; + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_CLIMB_DOWN) || _action.isAction(VERB_CLIMB_UP)) { + if (_globals[kSandbagStatus] == 1) { + switch (_game._trigger) { + case 0: + _globals._animationIndexes[0] = _scene->loadAnimation(formAnimName('s',-1), 1); + _game._player._stepEnabled = false; + _game._player._visible = false; + break; + + case 1: + _game.syncTimers(SYNC_PLAYER, 0, SYNC_ANIM, _globals._animationIndexes[0]); + _game._player._visible = true; + _game._player._playerPos = Common::Point(225, 143); + _game._player.resetFacing(FACING_EAST); + _game._player.walk(Common::Point(236, 142), FACING_EAST); + + if (_action.isAction(VERB_CLIMB_DOWN)) + _game._player.setWalkTrigger(75); + else + _game._player.setWalkTrigger(80); + break; + + default: + break; + } + } else { + switch (_game._trigger) { + case 0: + _globals._sequenceIndexes[0] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[0], false, 4, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[0], 2); + _scene->_sequences.setAnimRange(_globals._sequenceIndexes[0], 1, 9); + _scene->_sequences.addTimer(6, 2); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[0], SEQUENCE_TRIGGER_EXPIRE, 0, 1); + break; + + case 1: + _vm->_sound->command(70); + _globals._sequenceIndexes[0] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[0], false, -2); + _scene->_sequences.setDepth(_globals._sequenceIndexes[0], 2); + _sandbagHostpotId = _scene->_dynamicHotspots.add(NOUN_SANDBAG, VERB_WALK_TO, SYNTAX_SINGULAR, EXT_NONE, Common::Rect(227, 140, 227 + 18, 140 + 11)); + _scene->_dynamicHotspots.setPosition(_sandbagHostpotId, Common::Point(224, 152), FACING_NORTHEAST); + break; + + case 2: + _game._player._stepEnabled = false; + _game._player._visible = false; + _globals._animationIndexes[0] = _scene->loadAnimation(formAnimName('s', 1), 3); + _game.syncTimers(SYNC_ANIM, _globals._animationIndexes[0], SYNC_PLAYER, 0); + break; + + case 3: + _game.syncTimers(SYNC_PLAYER, 0, SYNC_ANIM, _globals._animationIndexes[0]); + _game._player._visible = true; + _game._player._stepEnabled = true; + _game._player._playerPos = Common::Point(228, 140); + _game._player.resetFacing(FACING_SOUTHEAST); + _globals[kSandbagStatus] = 1; + _vm->_dialogs->show(10632); + break; + + default: + break; + } + } + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_WALK_THROUGH, NOUN_DOOR) || _action.isAction(VERB_OPEN, NOUN_DOOR)) { + switch (_game._trigger) { + case (0): + _game._player._stepEnabled = false; + _game._player._visible = false; + _globals._sequenceIndexes[3] = _scene->_sequences.startPingPongCycle(_globals._spriteIndexes[3], false, 5, 2); + _scene->_sequences.setAnimRange(_globals._sequenceIndexes[3], 1, 4); + _scene->_sequences.setSeqPlayer(_globals._sequenceIndexes[3], true); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SEQUENCE_TRIGGER_SPRITE, 4, 65); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SEQUENCE_TRIGGER_EXPIRE, 0, 67); + break; + + case 65: + _vm->_sound->command(24); + _scene->deleteSequence(_globals._sequenceIndexes[2]); + _globals._sequenceIndexes[2] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[2], false, 8, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[2], 14); + _scene->_sequences.setAnimRange(_globals._sequenceIndexes[2], 1, 5); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SEQUENCE_TRIGGER_EXPIRE, 0, 66); + break; + + case 66: { + int idx = _globals._sequenceIndexes[2]; + _globals._sequenceIndexes[2] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[2], false, 5); + _game.syncTimers(SYNC_SEQ, _globals._sequenceIndexes[2], SYNC_SEQ, idx); + _scene->_sequences.setDepth(_globals._sequenceIndexes[2], 14); + } + break; + + case 67: + _game._player._visible = true; + _game._player.walk(Common::Point(180, 60), FACING_NORTH); + _game._player.setWalkTrigger(68); + break; + + case 68: + _scene->deleteSequence(_globals._sequenceIndexes[2]); + _globals._sequenceIndexes[2] = _scene->_sequences.addReverseSpriteCycle(_globals._spriteIndexes[2], false, 8, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[2], 1); + _scene->_sequences.setAnimRange(_globals._sequenceIndexes[2], -1, -2); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SEQUENCE_TRIGGER_EXPIRE, 0, 69); + break; + + case 69: + _vm->_sound->command(25); + _globals._sequenceIndexes[2] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[2], false, -1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[2], 1); + _scene->_nextSceneId = 109; + break; + + default: + break; + } + _action._inProgress = false; + return; + } + + if (_action._lookFlag) { + _vm->_dialogs->show(10610); + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_LOOK) || _action.isAction(VERB_LOOK_AT)) { + if (_action.isObject(NOUN_STAGE_RIGHT_WING)) { + _vm->_dialogs->show(10611); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_STAGE_LEFT_WING)) { + _vm->_dialogs->show(10612); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_IN_TWO)) { + _vm->_dialogs->show(10613); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_CYCLORAMA)) { + _vm->_dialogs->show(10614); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_STAGE)) { + _vm->_dialogs->show(10615); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_PEDESTAL)) { + _vm->_dialogs->show(10616); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_PLANT_PROP)) { + _vm->_dialogs->show(10617); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_SANDBAG)) { + if (_scene->_customDest.y < 60) { + _vm->_dialogs->show(10618); + _action._inProgress = false; + return; + } else if (_game._objects.isInRoom(OBJ_SANDBAG)) { + _vm->_dialogs->show(10633); + _action._inProgress = false; + return; + } + } + + if (_action.isObject(NOUN_STATUE)) { + _vm->_dialogs->show(10619); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_CIRCULAR_STAIRCASE)) { + _vm->_dialogs->show(10620); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_BATTEN)) { + _vm->_dialogs->show(10621); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_DOOR)) { + _vm->_dialogs->show(10622); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_BOXES) || _action.isObject(NOUN_BOX)) { + _vm->_dialogs->show(10623); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_BIG_PROP)) { + _vm->_dialogs->show(10624); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_CRATE)) { + _vm->_dialogs->show(10625); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_CASE)) { + if (_globals[kCurrentYear] == 1881) + _vm->_dialogs->show(10638); + else + _vm->_dialogs->show(10636); + + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_VENTILATION_DUCT)) { + _vm->_dialogs->show(10626); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_JUNK)) { + _vm->_dialogs->show(10627); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_FLATS)) { + _vm->_dialogs->show(10628); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_WALL)) { + _vm->_dialogs->show(10629); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_CABLE_HOOK) && _game._objects.isInRoom(OBJ_CABLE_HOOK)) { + _vm->_dialogs->show(10639); + _action._inProgress = false; + return; + } + } + + if (_action.isAction(VERB_TALK_TO, NOUN_STATUE)) { + _vm->_dialogs->show(10630); + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_CLOSE, NOUN_DOOR)) { + _vm->_dialogs->show(10634); + _action._inProgress = false; + return; + } +} + +void Scene106::preActions() { + if (_action.isAction(VERB_EXIT_TO, NOUN_STAGE_LEFT_WING)) + _game._player._walkOffScreenSceneId = 108; + + if (_action.isAction(VERB_OPEN, NOUN_DOOR)) + _game._player.walk(Common::Point(179, 63), FACING_NORTHWEST); +} + +/*------------------------------------------------------------------------*/ + +Scene107::Scene107(MADSEngine *vm) : Scene1xx(vm) { +} + +void Scene107::synchronize(Common::Serializer &s) { + Scene1xx::synchronize(s); +} + +void Scene107::setup() { + setPlayerSpritesPrefix(); + setAAName(); +} + +void Scene107::enter() { + if (_globals[kCurrentYear] == 1993) + _globals._spriteIndexes[0] = _scene->_sprites.addSprites(formAnimName('z', -1)); + + if (_game._objects.isInRoom(OBJ_YELLOW_FRAME)) { + _globals._spriteIndexes[2] = _scene->_sprites.addSprites(formAnimName('f', 0)); + _globals._spriteIndexes[1] = _scene->_sprites.addSprites("*RRD_9"); + } + + if (_game._objects.isInRoom(OBJ_YELLOW_FRAME)) { + _globals._sequenceIndexes[2] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[2], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[2], 14); + } else { + _scene->_hotspots.activate(NOUN_YELLOW_FRAME, false); + } + + if (_globals[kCurrentYear] == 1993) { + _scene->drawToBackground(_globals._spriteIndexes[0], 1, Common::Point(-32000, -32000), 0, 100); + _scene->_hotspots.activate(NOUN_PROP_TABLE, false); + } else { + _scene->_hotspots.activate(NOUN_HEADSET, false); + } + + if (_scene->_priorSceneId == 106) { + _game._player._playerPos = Common::Point(276, 73); + _game._player._facing = FACING_SOUTHWEST; + _game._player.walk(Common::Point(248, 75), FACING_SOUTHWEST); + } else if ((_scene->_priorSceneId == 104) || (_scene->_priorSceneId != RETURNING_FROM_LOADING)) { + if (_game._player._playerPos.y > 128) { + _game._player._playerPos.x = 216; + _game._player._facing = FACING_NORTHWEST; + } else if (_game._player._playerPos.y > 99) { + _game._player._playerPos.x = 127; + _game._player._facing = FACING_NORTHWEST; + } else { + _game._player._playerPos.x = 44; + _game._player._facing = FACING_NORTHEAST; + } + _game._player._playerPos.y = 143; + } + + sceneEntrySound(); +} + +void Scene107::step() { +} + +void Scene107::actions() { + if (_action.isAction(VERB_WALK_ONTO, NOUN_STAGE)) { + _scene->_nextSceneId = 104; + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_WALK, NOUN_BACKSTAGE)) { + _scene->_nextSceneId = 106; + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_TAKE, NOUN_YELLOW_FRAME) && (_game._objects.isInRoom(OBJ_YELLOW_FRAME) || _game._trigger)) { + switch (_game._trigger) { + case (0): + if (_globals[kCurrentYear] == 1881) { + int count = 0; + if (_game._objects.isInInventory(OBJ_GREEN_FRAME)) + ++count; + if (_game._objects.isInInventory(OBJ_RED_FRAME)) + ++count; + if (_game._objects.isInInventory(OBJ_BLUE_FRAME)) + ++count; + + if (count < 3) + _globals[kPlayerScore] += 5; + } + + _game._player._stepEnabled = false; + _game._player._visible = false; + _globals._sequenceIndexes[1] = _scene->_sequences.startPingPongCycle(_globals._spriteIndexes[1], false, 5, 2); + _scene->_sequences.setAnimRange(_globals._sequenceIndexes[1], 1, 5); + _scene->_sequences.setSeqPlayer(_globals._sequenceIndexes[1], true); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[1], SEQUENCE_TRIGGER_SPRITE, 5, 1); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[1], SEQUENCE_TRIGGER_EXPIRE, 0, 2); + break; + + case 1: + _scene->deleteSequence(_globals._sequenceIndexes[2]); + _scene->_hotspots.activate(NOUN_YELLOW_FRAME, false); + _game._objects.addToInventory(OBJ_YELLOW_FRAME); + _vm->_sound->command(26); + break; + + case 2: + _game.syncTimers(SYNC_PLAYER, 0, SYNC_SEQ, _globals._sequenceIndexes[1]); + _game._player._visible = true; + _scene->_sequences.addTimer(20, 3); + break; + + case 3: + if (_globals[kCurrentYear] == 1881) + _vm->_dialogs->showItem(OBJ_YELLOW_FRAME, 843, 0); + else + _vm->_dialogs->showItem(OBJ_YELLOW_FRAME, 804, 0); + + _game._player._stepEnabled = true; + break; + + default: + break; + } + _action._inProgress = false; + return; + } + + if (_action._lookFlag) { + _vm->_dialogs->show(10710); + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_LOOK) || _action.isAction(VERB_LOOK_AT)) { + if (_action.isObject(NOUN_STAGE)) { + _vm->_dialogs->show(10711); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_IN_TWO)) { + _vm->_dialogs->show(10712); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_IN_ONE)) { + _vm->_dialogs->show(10713); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_CYCLORAMA)) { + _vm->_dialogs->show(10714); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_COUNTERWEIGHT_SYSTEM)) { + _vm->_dialogs->show(10715); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_PURCHASE_LINES)) { + _vm->_dialogs->show(10716); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_LOCKRAIL)) { + _vm->_dialogs->show(10717); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_STAGE)) { + _vm->_dialogs->show(10718); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_PROP_TABLE)) { + _vm->_dialogs->show(10719); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_ACT_CURTAIN)) { + _vm->_dialogs->show(10720); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_LEG)) { + _vm->_dialogs->show(10721); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_APRON)) { + _vm->_dialogs->show(10722); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_PROSCENIUM_ARCH)) { + _vm->_dialogs->show(10723); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_STAGE)) { + _vm->_dialogs->show(10724); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_BACKSTAGE)) { + _vm->_dialogs->show(10725); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_YELLOW_FRAME) && _game._objects.isInRoom(OBJ_YELLOW_FRAME)) { + if (_globals[kCurrentYear] == 1881) + _vm->_dialogs->show(10727); + else + _vm->_dialogs->show(10726); + + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_HEADSET)) { + _vm->_dialogs->show(10728); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_WALL)) { + _vm->_dialogs->show(10730); + _action._inProgress = false; + return; + } + } + + if (_action.isAction(VERB_TAKE, NOUN_HEADSET)) { + _vm->_dialogs->show(10729); + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_TALK_TO, NOUN_HEADSET)) { + _vm->_dialogs->show(10732); + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_PULL, NOUN_PURCHASE_LINES)) { + _vm->_dialogs->show(10731); + _action._inProgress = false; + return; + } +} + +void Scene107::preActions() { +} + +/*------------------------------------------------------------------------*/ + +Scene108::Scene108(MADSEngine *vm) : Scene1xx(vm) { + _anim0ActvFl = false; + _handRaisedFl = false; + _shutUpCount = -1; + _maxTalkCount = -1; + _charAction = -1; + _charFrame = -1; + _charHotspotId = -1; + _charTalkCount = -1; + _conversationCount = -1; + _prevShutUpFrame = -1; +} + +void Scene108::synchronize(Common::Serializer &s) { + Scene1xx::synchronize(s); + + s.syncAsByte(_anim0ActvFl); + s.syncAsByte(_handRaisedFl); + s.syncAsSint16LE(_shutUpCount); + s.syncAsSint16LE(_maxTalkCount); + s.syncAsSint16LE(_charAction); + s.syncAsSint16LE(_charFrame); + s.syncAsSint16LE(_charHotspotId); + s.syncAsSint16LE(_charTalkCount); + s.syncAsSint16LE(_conversationCount); + s.syncAsSint16LE(_prevShutUpFrame); +} + +void Scene108::setup() { + setPlayerSpritesPrefix(); + setAAName(); + + if (_globals[kCurrentYear] == 1993) + _scene->_variant = 1; + + _scene->addActiveVocab(NOUN_GENTLEMAN); + _scene->addActiveVocab(NOUN_CHARLES); +} + +void Scene108::enter() { + if (_scene->_priorSceneId != RETURNING_FROM_LOADING) { + _anim0ActvFl = false; + _handRaisedFl = false; + _charTalkCount = 0; + _shutUpCount = 40; + _maxTalkCount = 15; + } + + _vm->_gameConv->get(2); + + if (_globals[kCurrentYear] == 1993) { + _globals._spriteIndexes[0] = _scene->_sprites.addSprites(formAnimName('z', -1)); + _scene->_hotspots.activate(NOUN_STOOL, false); + int idx = _scene->_dynamicHotspots.add(NOUN_STOOL, VERB_WALK_TO, SYNTAX_SINGULAR, EXT_NONE, Common::Rect(250, 68, 250 + 8, 68 + 21)); + _scene->_dynamicHotspots[idx]._articleNumber = PREP_ON; + _scene->_dynamicHotspots.setPosition(idx, Common::Point(253, 75), FACING_SOUTHEAST); + _scene->drawToBackground(_globals._spriteIndexes[0], 1, Common::Point(-32000, -32000), 0, 100); + } else { + _scene->_hotspots.activate(NOUN_HEADSET, false); + int idx = _scene->_dynamicHotspots.add(NOUN_WALL, VERB_WALK_TO, SYNTAX_SINGULAR, EXT_NONE, Common::Rect(258, 58, 258 + 6, 58 + 10)); + _scene->_dynamicHotspots[idx]._articleNumber = PREP_ON; + _scene->_dynamicHotspots.setPosition(idx, Common::Point(236, 69), FACING_NORTHEAST); + } + + if ((_globals[kCurrentYear] == 1993) && (_globals[kDoneBrieConv203] == 0)) { + _globals._animationIndexes[0] = _scene->loadAnimation(formAnimName('c', 1), 1); + _anim0ActvFl = true; + + if (_vm->_gameConv->_running == 2) { + _globals[kWalkerConverse] = _vm->getRandomNumber(1, 4); + _charAction = 0; + _vm->_gameConv->run(2); + _vm->_gameConv->exportPointer(&_globals[kPlayerScore]); + _vm->_gameConv->exportValue(_globals[kJulieNameIsKnown]); + _vm->_gameConv->exportValue(_globals[kObservedPhan104]); + _scene->setAnimFrame(_globals._animationIndexes[0], 55); + _shutUpCount = 40; + } else { + _charAction = 2; + } + + if (_globals[kCharlesNameIsKnown]) { + _charHotspotId = _scene->_dynamicHotspots.add(NOUN_CHARLES, VERB_WALK_TO, SYNTAX_SINGULAR_MASC, EXT_NONE, Common::Rect(253, 52, 253 + 15, 52 + 34)); + _scene->_dynamicHotspots[_charHotspotId]._articleNumber = PREP_ON; + } else { + _charHotspotId = _scene->_dynamicHotspots.add(NOUN_GENTLEMAN, VERB_WALK_TO, SYNTAX_MASC_NOT_PROPER, EXT_NONE, Common::Rect(253, 52, 253 + 15, 52 + 34)); + _scene->_dynamicHotspots[_charHotspotId]._articleNumber = PREP_ON; + } + _scene->_dynamicHotspots.setPosition(_charHotspotId, Common::Point(235, 102), FACING_NORTHEAST); + } + + if (_scene->_priorSceneId == 106) { + _game._player._playerPos = Common::Point(48, 81); + _game._player._facing = FACING_SOUTHEAST; + _game._player.walk(Common::Point(71, 76), FACING_SOUTHEAST); + } else if ((_scene->_priorSceneId == 104) || (_scene->_priorSceneId != RETURNING_FROM_LOADING)) { + if (_game._player._playerPos.y > 128) { + _game._player._playerPos.x = 124; + _game._player._facing = FACING_NORTHEAST; + } else if (_game._player._playerPos.y > 99) { + _game._player._playerPos.x = 185; + _game._player._facing = FACING_NORTHEAST; + } else { + _game._player._playerPos.x = 243; + _game._player._facing = FACING_NORTHWEST; + } + + _game._player._playerPos.y = 143; + } + + sceneEntrySound(); +} + +void Scene108::step() { + if (_anim0ActvFl) + handleCharAnimation(); + + if ((_globals[kWalkerConverse] == 2) || (_globals[kWalkerConverse] == 3)) { + ++_conversationCount; + if (_conversationCount > 200) + _globals[kWalkerConverse] = _vm->getRandomNumber(1, 4); + } +} + +void Scene108::actions() { + if (_vm->_gameConv->_running == 2) { + handleCharlesConversation(); + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_TALK_TO, NOUN_GENTLEMAN) || _action.isAction(VERB_TALK_TO, NOUN_CHARLES)) { + _charAction = 6; + _game._player._stepEnabled = false; + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_WALK_ONTO, NOUN_STAGE)) { + _scene->_nextSceneId = 104; + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_WALK, NOUN_BACKSTAGE)) { + _scene->_nextSceneId = 106; + _action._inProgress = false; + return; + } + + if (_action._lookFlag) { + _vm->_dialogs->show(10810); + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_LOOK) || _action.isAction(VERB_LOOK_AT)) { + if (_action.isObject(NOUN_WALL)) { + _vm->_dialogs->show(10730); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_STAGE)) { + _vm->_dialogs->show(10811); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_IN_TWO)) { + _vm->_dialogs->show(10812); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_IN_ONE)) { + _vm->_dialogs->show(10813); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_PROSCENIUM_ARCH)) { + _vm->_dialogs->show(10814); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_ACT_CURTAIN)) { + _vm->_dialogs->show(10815); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_LEG)) { + _vm->_dialogs->show(10816); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_CYCLORAMA)) { + _vm->_dialogs->show(10817); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_FLATS)) { + _vm->_dialogs->show(10818); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_STAGEMANAGERS_POST)) { + if (_globals[kCurrentYear] == 1993) + _vm->_dialogs->show(10819); + else + _vm->_dialogs->show(10820); + + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_STOOL)) { + _vm->_dialogs->show(10821); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_BACKSTAGE)) { + _vm->_dialogs->show(10822); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_STAGE)) { + _vm->_dialogs->show(10823); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_HEADSET)) { + _vm->_dialogs->show(10824); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_WALL)) { + _vm->_dialogs->show(10826); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_CHARLES) || _action.isObject(NOUN_GENTLEMAN)) { + _vm->_dialogs->show(10827); + _action._inProgress = false; + return; + } + } + + if (_action.isAction(VERB_TAKE, NOUN_CHARLES) || _action.isAction(VERB_TAKE, NOUN_GENTLEMAN)) { + _vm->_dialogs->show(10828); + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_TAKE, NOUN_HEADSET)) { + _vm->_dialogs->show(10825); + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_TAKE, NOUN_STOOL) && (_globals[kCurrentYear] == 1993)) { + _vm->_dialogs->show(10829); + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_TALK_TO, NOUN_HEADSET)) { + _vm->_dialogs->show(10830); + _action._inProgress = false; + return; + } +} + +void Scene108::preActions() { +} + +void Scene108::handleCharAnimation() { + if (_scene->_animation[_globals._animationIndexes[0]]->getCurrentFrame() == _charFrame) + return; + + _charFrame = _scene->_animation[_globals._animationIndexes[0]]->getCurrentFrame(); + int resetFrame = -1; + int random = -1; + + switch (_charFrame) { + case 1: + case 2: + case 3: + case 4: + case 92: + if (_charAction == 2) + random = _vm->getRandomNumber(2, 15); + + if (_charAction == 6) { + _charTalkCount = 0; + _charAction = 1; + random = 1; + } + + switch (random) { + case 1: + resetFrame = 5; + break; + + case 2: + resetFrame = 0; + break; + + case 3: + resetFrame = 1; + break; + + case 4: + resetFrame = 2; + break; + + default: + resetFrame = 3; + break; + } + break; + + case 18: + case 19: + case 20: + case 21: + case 27: + case 33: + case 41: + case 51: + case 52: + case 53: + case 54: + case 55: + case 56: + case 57: + case 62: + case 73: + if (_charFrame == 18) { + _game._player._stepEnabled = true; + _vm->_gameConv->run(2); + _vm->_gameConv->exportPointer(&_globals[kPlayerScore]); + _vm->_gameConv->exportValue(_globals[kJulieNameIsKnown]); + _vm->_gameConv->exportValue(_globals[kObservedPhan104]); + } + + if (_charAction == 1) { + if (_handRaisedFl) { + random = _vm->getRandomNumber(1, 3); + } else { + random = _vm->getRandomNumber(1, 4); + if (random == 4) + random = _vm->getRandomNumber(1, 4); + } + + if (random == 4) + _handRaisedFl = true; + + ++_charTalkCount; + if (_charTalkCount > _maxTalkCount) { + _charAction = 0; + _shutUpCount = 0; + _prevShutUpFrame = 10; + random = 12; + } + } else if (_charAction == 0) { + int delay = _vm->getRandomNumber(10, 15); + ++_shutUpCount; + if (_shutUpCount > delay) { + random = _vm->getRandomNumber(10, 16); + _prevShutUpFrame = random; + if (random == 15) + _shutUpCount = 16; + else + _shutUpCount = 0; + } else { + random = _prevShutUpFrame; + } + } else if (_charAction == 7) { + _charAction = 1; + random = 5; + } else if (_charAction == 3) { + _charAction = 1; + random = 6; + } else if (_charAction == 5) { + _charAction = 1; + random = 7; + } else if (_charAction == 4) { + _charAction = 1; + random = 8; + } else if (_charAction == 2) { + random = 9; + } + + switch (random) { + case 1: + resetFrame = 18; + break; + + case 2: + resetFrame = 19; + break; + + case 3: + resetFrame = 20; + break; + + case 4: + resetFrame = 62; + _charTalkCount += 5; + break; + + case 5: + resetFrame = 21; + break; + + case 6: + resetFrame = 41; + break; + + case 7: + resetFrame = 33; + break; + + case 8: + resetFrame = 27; + break; + + case 9: + resetFrame = 74; + break; + + case 10: + resetFrame = 51; + break; + + case 11: + resetFrame = 53; + break; + + case 12: + resetFrame = 54; + break; + + case 13: + resetFrame = 55; + break; + + case 14: + resetFrame = 56; + break; + + case 15: + resetFrame = 57; + break; + + case 16: + resetFrame = 52; + break; + + default: + break; + } + break; + + default: + break; + } + + if (resetFrame >= 0) { + _scene->setAnimFrame(_globals._animationIndexes[0], resetFrame); + _charFrame = resetFrame; + } +} + +void Scene108::handleCharlesConversation() { + switch (_action._activeAction._verbId) { + case 1: + case 25: + case 26: + _globals[kWalkerConverse] = 0; + _vm->_gameConv->setHeroTrigger(64); + if (_action._activeAction._verbId == 26) + _globals[kCharlesNameIsKnown] = 2; + break; + + case 2: + if (!_globals[kCharlesNameIsKnown]) { + _scene->_dynamicHotspots.remove(_charHotspotId); + _charHotspotId = _scene->_dynamicHotspots.add(NOUN_CHARLES, VERB_WALK_TO, SYNTAX_SINGULAR_MASC, EXT_NONE, Common::Rect(253, 52, 253 + 15, 52 + 34)); + _scene->_dynamicHotspots[_charHotspotId]._articleNumber = PREP_ON; + _scene->_dynamicHotspots.setPosition(_charHotspotId, Common::Point(235, 102), FACING_NORTHEAST); + _globals[kCharlesNameIsKnown] = true; + } + break; + + case 5: + _vm->_gameConv->setInterlocutorTrigger(66); + _maxTalkCount = 35; + break; + + case 6: + case 8: + case 9: + case 10: + case 11: + case 12: + case 15: + _maxTalkCount = 35; + break; + + case 16: + _vm->_gameConv->setInterlocutorTrigger(68); + _maxTalkCount = 35; + break; + + case 19: + _vm->_gameConv->setInterlocutorTrigger(72); + break; + + case 22: + _vm->_gameConv->setInterlocutorTrigger(70); + break; + + default: + _maxTalkCount = 15; + break; + } + + switch (_game._trigger) { + case 60: + _charAction = 1; + _globals[kWalkerConverse] = _vm->getRandomNumber(1, 4); + break; + + case 62: + _globals[kWalkerConverse] = _vm->getRandomNumber(2, 3); + _conversationCount = 0; + _charAction = 0; + break; + + case 64: + _charAction = 2; + break; + + case 66: + _charAction = 5; + break; + + case 68: + _charAction = 4; + break; + + case 70: + _charAction = 7; + break; + + case 72: + _charAction = 3; + break; + + default: + break; + } + + if ((_action._activeAction._verbId != 1) && (_action._activeAction._verbId != 5) && + (_action._activeAction._verbId != 16) && (_action._activeAction._verbId != 19) && + (_action._activeAction._verbId != 22) && (_action._activeAction._verbId != 25) && + (_action._activeAction._verbId != 26) && (_charAction != 2)) { + _vm->_gameConv->setInterlocutorTrigger(60); + _vm->_gameConv->setHeroTrigger(62); + } + + _charTalkCount = 0; + _shutUpCount = 40; + _handRaisedFl = false; +} + +/*------------------------------------------------------------------------*/ + +Scene109::Scene109(MADSEngine *vm) : Scene1xx(vm) { + _anim0ActvFl = false; + _anim1ActvFl = false; + _anim2ActvFl = false; + _anim3ActvFl = false; +} + +void Scene109::synchronize(Common::Serializer &s) { + Scene1xx::synchronize(s); + + s.syncAsByte(_anim0ActvFl); + s.syncAsByte(_anim1ActvFl); + s.syncAsByte(_anim2ActvFl); + s.syncAsByte(_anim3ActvFl); +} + +void Scene109::setup() { + setPlayerSpritesPrefix(); + setAAName(); +} + +void Scene109::enter() { + _anim0ActvFl = false; + _anim1ActvFl = false; + _anim2ActvFl = false; + _anim3ActvFl = false; + + _globals._spriteIndexes[0] = _scene->_sprites.addSprites(formAnimName('x', 0)); + _globals._spriteIndexes[1] = _scene->_sprites.addSprites(formAnimName('x', 2)); + _globals._spriteIndexes[8] = _scene->_sprites.addSprites("*RDR_6"); + + if (_globals[kCurrentYear] == 1881) { + _globals._spriteIndexes[2] = _scene->_sprites.addSprites(formAnimName('x', 1)); + _globals._spriteIndexes[3] = _scene->_sprites.addSprites(formAnimName('x', 3)); + _globals._spriteIndexes[4] = _scene->_sprites.addSprites(formAnimName('x', 4)); + + _scene->_hotspots.activate(NOUN_LIGHT_FIXTURE, false); + _globals._sequenceIndexes[2] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[2], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[2], 14); + _globals._sequenceIndexes[3] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[3], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[3], 14); + _globals._sequenceIndexes[4] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[4], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[4], 14); + _scene->_sequences.addTimer(1, 70); + } else { + _globals._spriteIndexes[5] = _scene->_sprites.addSprites(formAnimName('z', 0)); + _globals._spriteIndexes[6] = _scene->_sprites.addSprites(formAnimName('z', 1)); + _globals._spriteIndexes[7] = _scene->_sprites.addSprites(formAnimName('z', 2)); + + _scene->_hotspots.activate(NOUN_LAMP, false); + _globals._sequenceIndexes[5] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[5], false, 1); + _globals._sequenceIndexes[6] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[6], false, 1); + _globals._sequenceIndexes[7] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[7], false, 1); + } + + if (_scene->_priorSceneId == 106) { + _game._player._playerPos = Common::Point(31, 459); + _game._player._facing = FACING_NORTHEAST; + _scene->setCamera(Common::Point(0, 312)); + _scene->sceneScale(467, 95, 442, 78); + _currentFloor = 1; + } else if (_scene->_priorSceneId == 111) { + if (_globals[kLeaveAngelMusicOn]) { + _globals[kLeaveAngelMusicOn] = false; + sceneEntrySound(); + } + _game._player._playerPos = Common::Point(4, 136); + _game._player._facing = FACING_EAST; + _game._player.walk(Common::Point(32, 138), FACING_EAST); + _game._player.setWalkTrigger(60); + _game._player._stepEnabled = false; + _scene->setCamera(Common::Point(0, 0)); + _scene->sceneScale(155, 95, 130, 78); + _globals._sequenceIndexes[0] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[0], false, 3); + _scene->_sequences.setDepth(_globals._sequenceIndexes[0], 14); + _currentFloor = 3; + } else if ((_scene->_priorSceneId == 110) || (_scene->_priorSceneId != RETURNING_FROM_LOADING)) { + _game._player._playerPos = Common::Point(3, 292); + _game._player._facing = FACING_EAST; + _game._player.walk(Common::Point(31, 295), FACING_EAST); + _game._player.setWalkTrigger(65); + _game._player._stepEnabled = false; + _scene->setCamera(Common::Point(0, 156)); + _scene->sceneScale(311, 95, 286, 78); + _globals._sequenceIndexes[1] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[1], false, 3); + _scene->_sequences.setDepth(_globals._sequenceIndexes[1], 14); + _currentFloor = 2; + } else if (_scene->_priorSceneId == RETURNING_FROM_LOADING) { + if (_currentFloor == 2) { + _scene->setCamera(Common::Point(0, 156)); + _scene->sceneScale(311, 95, 286, 78); + } else if (_currentFloor == 3) { + _scene->setCamera(Common::Point(0, 0)); + _scene->sceneScale(155, 95, 130, 78); + } else { + _scene->setCamera(Common::Point(0, 312)); + _scene->sceneScale(467, 95, 442, 78); + } + } + + sceneEntrySound(); +} + +void Scene109::step() { + if (_anim0ActvFl) { + if (_scene->_animation[_globals._animationIndexes[0]]->getCurrentFrame() == 80) + _game.camPanTo(&_game._camY, 156); + } + + if (_anim1ActvFl) { + if (_scene->_animation[_globals._animationIndexes[1]]->getCurrentFrame() == 80) + _game.camPanTo(&_game._camY, 0); + } + + if (_anim2ActvFl) { + if (_scene->_animation[_globals._animationIndexes[2]]->getCurrentFrame() == 7) + _game.camPanTo(&_game._camY, 312); + } + + if (_anim3ActvFl) { + if (_scene->_animation[_globals._animationIndexes[3]]->getCurrentFrame() == 14) + _game.camPanTo(&_game._camY, 156); + } + + switch (_game._trigger) { + case 60: + _scene->deleteSequence(_globals._sequenceIndexes[0]); + _globals._sequenceIndexes[0] = _scene->_sequences.addReverseSpriteCycle(_globals._spriteIndexes[0], false, 8, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[0], 14); + _scene->_sequences.setAnimRange(_globals._sequenceIndexes[0], 1, 3); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[0], SEQUENCE_TRIGGER_EXPIRE, 0, 61); + break; + + case 61: + _vm->_sound->command(25); + _game._player._stepEnabled = true; + break; + + default: + break; + } + + switch (_game._trigger) { + case 65: + _scene->deleteSequence(_globals._sequenceIndexes[1]); + _globals._sequenceIndexes[1] = _scene->_sequences.addReverseSpriteCycle(_globals._spriteIndexes[1], false, 8, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[1], 14); + _scene->_sequences.setAnimRange(_globals._sequenceIndexes[1], 1, 3); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[1], SEQUENCE_TRIGGER_EXPIRE, 0, 66); + break; + + case 66: + _vm->_sound->command(25); + _game._player._stepEnabled = true; + break; + + default: + break; + } + + if (_game._trigger == 70) { + int rndFrame = _vm->getRandomNumber(1, 3); + int rndDelay = _vm->getRandomNumber(4, 7); + _scene->deleteSequence(_globals._sequenceIndexes[2]); + _scene->deleteSequence(_globals._sequenceIndexes[3]); + _scene->deleteSequence(_globals._sequenceIndexes[4]); + + _globals._sequenceIndexes[2] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[2], false, rndFrame); + _scene->_sequences.setDepth(_globals._sequenceIndexes[2], 14); + + _globals._sequenceIndexes[3] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[3], false, rndFrame); + _scene->_sequences.setDepth(_globals._sequenceIndexes[3], 14); + + _globals._sequenceIndexes[4] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[4], false, rndFrame); + _scene->_sequences.setDepth(_globals._sequenceIndexes[4], 14); + + _scene->_sequences.addTimer(rndDelay, 70); + } +} + +void Scene109::actions() { + if (_action.isAction(VERB_WALK, NOUN_BACKSTAGE)) { + _scene->_nextSceneId = 106; + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_CLIMB_UP, NOUN_STAIRCASE)) { + if (_currentFloor == 2) { + switch (_game._trigger) { + case 0: + _game._player.walk(Common::Point(58, 295), FACING_EAST); + _game._player.setWalkTrigger(1); + break; + + case 1: + _anim1ActvFl = true; + _game._player._stepEnabled = false; + _game._player._visible = false; + _globals._animationIndexes[1] = _scene->loadAnimation(formAnimName('w', 2), 2); + _game.syncTimers(SYNC_ANIM, _globals._animationIndexes[1], SYNC_PLAYER, 0); + break; + + case 2: + _game.syncTimers(SYNC_PLAYER, 0, SYNC_ANIM, _globals._animationIndexes[1]); + _scene->sceneScale(155, 95, 130, 78); + _anim1ActvFl = false; + _game._player._visible = true; + _game._player._playerPos = Common::Point(261, 137); + _game._player.walk(Common::Point(281, 143), FACING_SOUTHWEST); + _game._player.setWalkTrigger(3); + break; + + case 3: + _game._player._stepEnabled = true; + _currentFloor = 3; + break; + + default: + break; + } + } else if (_currentFloor == 1) { + switch (_game._trigger) { + case 0: + _game._player.walk(Common::Point(58, 452), FACING_EAST); + _game._player.setWalkTrigger(1); + break; + + case 1: + _anim0ActvFl = true; + _game._player._stepEnabled = false; + _game._player._visible = false; + _globals._animationIndexes[0] = _scene->loadAnimation(formAnimName('w', 1), 2); + _game.syncTimers(SYNC_ANIM, _globals._animationIndexes[0], SYNC_PLAYER, 0); + break; + + case 2: + _game.syncTimers(SYNC_PLAYER, 0, SYNC_ANIM, _globals._animationIndexes[0]); + _scene->sceneScale(311, 95, 286, 78); + _anim0ActvFl = false; + _game._player._visible = true; + _game._player._playerPos = Common::Point(264, 295); + _game._player.walk(Common::Point(289, 299), FACING_SOUTHWEST); + _game._player.setWalkTrigger(3); + break; + + case 3: + _game._player._stepEnabled = true; + _currentFloor = 2; + break; + + default: + break; + } + } + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_CLIMB_DOWN, NOUN_STAIRCASE)) { + if (_currentFloor == 2) { + switch (_game._trigger) { + case 0: + _game._player.walk(Common::Point(287, 291), FACING_WEST); + _game._player.setWalkTrigger(1); + break; + + case 1: + _game._player.walk(Common::Point(269, 292), FACING_WEST); + _game._player.setWalkTrigger(2); + break; + + case 2: + _anim2ActvFl = true; + _game._player._stepEnabled = false; + _game._player._visible = false; + _globals._animationIndexes[2] = _scene->loadAnimation(formAnimName('w', 3), 3); + _game.syncTimers(SYNC_ANIM, _globals._animationIndexes[2], SYNC_PLAYER, 0); + break; + + case 3: + _game.syncTimers(SYNC_PLAYER, 0, SYNC_ANIM, _globals._animationIndexes[2]); + _scene->sceneScale(467, 95, 442, 78); + _anim2ActvFl = false; + _game._player._visible = true; + _game._player._playerPos = Common::Point(61, 450); + _game._player.walk(Common::Point(36, 450), FACING_SOUTHEAST); + _game._player.setWalkTrigger(4); + break; + + case 4: + _game._player._stepEnabled = true; + _currentFloor = 1; + break; + + default: + break; + } + } else if (_currentFloor == 3) { + switch (_game._trigger) { + case 0: + _game._player.walk(Common::Point(287, 137), FACING_WEST); + _game._player.setWalkTrigger(1); + break; + + case 1: + _game._player.walk(Common::Point(269, 138), FACING_WEST); + _game._player.setWalkTrigger(2); + break; + + case 2: + _anim3ActvFl = true; + _game._player._stepEnabled = false; + _game._player._visible = false; + _globals._animationIndexes[3] = _scene->loadAnimation(formAnimName('w', 4), 3); + _game.syncTimers(SYNC_ANIM, _globals._animationIndexes[3], SYNC_PLAYER, 0); + break; + + case 3: + _game.syncTimers(SYNC_PLAYER, 0, SYNC_ANIM, _globals._animationIndexes[3]); + _scene->sceneScale(311, 95, 286, 78); + _anim3ActvFl = false; + _game._player._visible = true; + _game._player._playerPos = Common::Point(59, 296); + _game._player.walk(Common::Point(40, 294), FACING_SOUTHEAST); + _game._player.setWalkTrigger(4); + break; + + case 4: + _game._player._stepEnabled = true; + _currentFloor = 2; + break; + + default: + break; + } + } + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_WALK_THROUGH, NOUN_DOOR) || _action.isAction(VERB_OPEN, NOUN_DOOR) || _game._trigger) { + switch (_game._trigger) { + case (0): + _game._player._stepEnabled = false; + _game._player._visible = false; + _globals._sequenceIndexes[8] = _scene->_sequences.startPingPongCycle(_globals._spriteIndexes[8], true, 5, 2); + _scene->_sequences.setAnimRange(_globals._sequenceIndexes[8], -1, -2); + _scene->_sequences.setSeqPlayer(_globals._sequenceIndexes[8], true); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[8], SEQUENCE_TRIGGER_EXPIRE, 0, 2); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[8], SEQUENCE_TRIGGER_SPRITE, 4, 75); + break; + + case 2: + _game._player._visible = true; + _game.syncTimers(SYNC_PLAYER, 0, SYNC_SEQ, _globals._sequenceIndexes[8]); + if (_currentFloor == 3) + _game._player.walk(Common::Point(2, 131), FACING_WEST); + else if (_currentFloor == 2) + _game._player.walk(Common::Point(2, 281), FACING_WEST); + + _scene->_sequences.addTimer(180, 3); + break; + + case 3: + if (_currentFloor == 3) + _scene->_nextSceneId = 111; + else if (_currentFloor == 2) + _scene->_nextSceneId = 110; + break; + + case 75: + _vm->_sound->command(24); + if (_currentFloor == 3) { + _globals._sequenceIndexes[0] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[0], false, 8, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[0], 14); + _scene->_sequences.setAnimRange(_globals._sequenceIndexes[0], 1, 3); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[0], SEQUENCE_TRIGGER_EXPIRE, 0, 76); + } else if (_currentFloor == 2) { + _globals._sequenceIndexes[1] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[1], false, 8, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[1], 14); + _scene->_sequences.setAnimRange(_globals._sequenceIndexes[1], 1, 3); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[1], SEQUENCE_TRIGGER_EXPIRE, 0, 76); + } + break; + + case 76: + if (_currentFloor == 3) { + int idx = _globals._sequenceIndexes[0]; + _globals._sequenceIndexes[0] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[0], false, 3); + _game.syncTimers(SYNC_SEQ, _globals._sequenceIndexes[0], SYNC_SEQ, idx); + _scene->_sequences.setDepth(_globals._sequenceIndexes[0], 14); + } else if (_currentFloor == 2) { + int idx = _globals._sequenceIndexes[1]; + _globals._sequenceIndexes[1] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[1], false, 3); + _game.syncTimers(SYNC_SEQ, _globals._sequenceIndexes[1], SYNC_SEQ, idx); + _scene->_sequences.setDepth(_globals._sequenceIndexes[1], 14); + } + break; + + default: + break; + } + _action._inProgress = false; + return; + } + + if (_action._lookFlag) { + _vm->_dialogs->show(10910); + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_LOOK) || _action.isAction(VERB_LOOK_AT)) { + if (_action.isObject(NOUN_STAIRCASE)) { + if (_currentFloor == 1) + _vm->_dialogs->show(10911); + else if (_currentFloor == 2) + _vm->_dialogs->show(10921); + else if (_currentFloor == 3) + _vm->_dialogs->show(10922); + + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_FLOOR)) { + _vm->_dialogs->show(10912); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_BACKSTAGE)) { + _vm->_dialogs->show(10913); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_DOOR)) { + _vm->_dialogs->show(10914); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_RAILING)) { + _vm->_dialogs->show(10915); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_WALL)) { + _vm->_dialogs->show(10916); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_LIGHT_FIXTURE)) { + _vm->_dialogs->show(10917); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_LAMP)) { + _vm->_dialogs->show(10918); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_HOLE)) { + _vm->_dialogs->show(10919); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_CEILING)) { + _vm->_dialogs->show(10920); + _action._inProgress = false; + return; + } + } + + if (_action.isAction(VERB_TAKE, NOUN_LAMP)) { + _vm->_dialogs->show(10924); + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_CLOSE, NOUN_DOOR)) { + _vm->_dialogs->show(10923); + _action._inProgress = false; + return; + } +} + +void Scene109::preActions() { + if (_action.isAction(VERB_OPEN, NOUN_DOOR)) { + if (_currentFloor == 3) + _game._player.walk(Common::Point(32, 138), FACING_WEST); + else if (_currentFloor == 2) + _game._player.walk(Common::Point(31, 295), FACING_WEST); + } +} + +/*------------------------------------------------------------------------*/ + +Scene110::Scene110(MADSEngine *vm) : Scene1xx(vm) { +} + +void Scene110::synchronize(Common::Serializer &s) { + Scene1xx::synchronize(s); +} + +void Scene110::setup() { + if (_globals[kCurrentYear] == 1993) + _scene->_variant = 1; + + setPlayerSpritesPrefix(); + setAAName(); +} + +void Scene110::enter() { + _globals._spriteIndexes[2] = _scene->_sprites.addSprites(formAnimName('x', 0)); + _globals._spriteIndexes[3] = _scene->_sprites.addSprites(formAnimName('x', 1)); + _globals._spriteIndexes[1] = _scene->_sprites.addSprites("*RDR_9"); + + if (_globals[kCurrentYear] == 1993) { + _globals._spriteIndexes[0] = _scene->_sprites.addSprites(formAnimName('z', -1)); + _scene->drawToBackground(_globals._spriteIndexes[0], 1, Common::Point(-32000, -32000), 0, 100); + _scene->_hotspots.activate(NOUN_POSTER, false); + _scene->_hotspots.activate(NOUN_WASTE_BASKET, false); + + if (_globals[kDoneBrieConv203] == 0) { + if (_globals[kJuliesDoor] == 0) { + _globals._sequenceIndexes[2] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[2], false, 3); + _scene->_sequences.setDepth(_globals._sequenceIndexes[2], 8); + } + } else { + _globals._sequenceIndexes[3] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[3], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[3], 8); + } + } else { + _scene->_hotspots.activate(NOUN_BULLETIN_BOARD, false); + _scene->_hotspots.activate(NOUN_PAPER, false); + _scene->_hotspots.activate(NOUN_TRASH_BUCKET, false); + } + + if (_scene->_priorSceneId == 112) { + _game._player._playerPos = Common::Point(261, 121); + _game._player._facing = FACING_SOUTH; + _game._player.walk(Common::Point(221, 131), FACING_SOUTH); + } else if ((_scene->_priorSceneId == 109) || (_scene->_priorSceneId != RETURNING_FROM_LOADING)) { + _game._player.firstWalk(Common::Point(335, 150), FACING_WEST, Common::Point(310, 150), FACING_WEST, true); + } + + sceneEntrySound(); +} + +void Scene110::step() { +} + +void Scene110::actions() { + if ((_action.isAction(VERB_WALK_THROUGH, NOUN_RIGHT_DOOR) || _action.isAction(VERB_UNLOCK, NOUN_RIGHT_DOOR) || _action.isAction(VERB_LOCK, NOUN_RIGHT_DOOR)) + && (_globals[kDoneBrieConv203] == 0) && (_globals[kCurrentYear] == 1993) && (_globals[kJuliesDoor] == 0)) { + _scene->_nextSceneId = 112; + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_WALK_THROUGH, NOUN_LEFT_DOOR) || _action.isAction(VERB_OPEN, NOUN_LEFT_DOOR) + || _action.isAction(VERB_UNLOCK, NOUN_LEFT_DOOR) || _action.isAction(VERB_LOCK, NOUN_LEFT_DOOR)) { + switch (_game._trigger) { + case (0): + _game._player._stepEnabled = false; + _game._player._visible = false; + _globals._sequenceIndexes[1] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[1], false, 5, 1); + _scene->_sequences.setAnimRange(_globals._sequenceIndexes[1], 1, 4); + _scene->_sequences.setSeqPlayer(_globals._sequenceIndexes[1], true); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[1], SEQUENCE_TRIGGER_EXPIRE, 0, 1); + break; + + case 1: { + int idx = _globals._sequenceIndexes[1]; + _globals._sequenceIndexes[1] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[1], false, 4); + _game.syncTimers(SYNC_SEQ, _globals._sequenceIndexes[1], SYNC_SEQ, idx); + _scene->_sequences.setSeqPlayer(_globals._sequenceIndexes[1], false); + _scene->_sequences.addTimer(30, 2); + _vm->_sound->command(73); + } + break; + + case 2: + _scene->deleteSequence(_globals._sequenceIndexes[1]); + _globals._sequenceIndexes[1] = _scene->_sequences.addReverseSpriteCycle(_globals._spriteIndexes[1], false, 5, 1); + _scene->_sequences.setAnimRange(_globals._sequenceIndexes[1], 1, 4); + _scene->_sequences.setSeqPlayer(_globals._sequenceIndexes[1], false); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[1], SEQUENCE_TRIGGER_EXPIRE, 0, 3); + break; + + case 3: + _game.syncTimers(SYNC_PLAYER, 0, SYNC_SEQ, _globals._sequenceIndexes[1]); + _game._player._visible = true; + _game._player._stepEnabled = true; + if (_action.isAction(VERB_LOCK) || _action.isAction(VERB_UNLOCK)) + _vm->_dialogs->show(32); + else + _vm->_dialogs->show(11022); + + break; + + default: + break; + } + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_WALK_THROUGH, NOUN_RIGHT_DOOR) || _action.isAction(VERB_OPEN, NOUN_RIGHT_DOOR) + || _action.isAction(VERB_UNLOCK, NOUN_RIGHT_DOOR) || _action.isAction(VERB_LOCK, NOUN_RIGHT_DOOR)) { + if ((_globals[kCurrentYear] == 1881) || (_globals[kDoneBrieConv203] >= 1) + && !_action.isAction(VERB_UNLOCK, NOUN_RIGHT_DOOR) && !_action.isAction(VERB_LOCK, NOUN_RIGHT_DOOR)) { + switch (_game._trigger) { + case (0): + _game._player._stepEnabled = false; + _game._player._visible = false; + _globals._sequenceIndexes[1] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[1], false, 5, 1); + _scene->_sequences.setAnimRange(_globals._sequenceIndexes[1], 1, 4); + _scene->_sequences.setSeqPlayer(_globals._sequenceIndexes[1], true); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[1], SEQUENCE_TRIGGER_EXPIRE, 0, 1); + break; + + case 1: { + int idx = _globals._sequenceIndexes[1]; + _globals._sequenceIndexes[1] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[1], false, 4); + _game.syncTimers(SYNC_SEQ, _globals._sequenceIndexes[1], SYNC_SEQ, idx); + _scene->_sequences.setSeqPlayer(_globals._sequenceIndexes[1], false); + _scene->_sequences.addTimer(30, 2); + _vm->_sound->command(73); + } + break; + + case 2: + _scene->deleteSequence(_globals._sequenceIndexes[1]); + _globals._sequenceIndexes[1] = _scene->_sequences.addReverseSpriteCycle(_globals._spriteIndexes[1], false, 5, 1); + _scene->_sequences.setAnimRange(_globals._sequenceIndexes[1], 1, 4); + _scene->_sequences.setSeqPlayer(_globals._sequenceIndexes[1], false); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[1], SEQUENCE_TRIGGER_EXPIRE, 0, 3); + break; + + case 3: + _game.syncTimers(SYNC_PLAYER, 0, SYNC_SEQ, _globals._sequenceIndexes[1]); + _game._player._visible = true; + _game._player._stepEnabled = true; + if (_action.isAction(VERB_LOCK) || _action.isAction(VERB_UNLOCK)) + _vm->_dialogs->show(32); + else + _vm->_dialogs->show(11023); + break; + + default: + break; + } + _action._inProgress = false; + return; + } else if (_globals[kJuliesDoor] == 1) { + switch (_game._trigger) { + case (0): + _game._player._stepEnabled = false; + _game._player._visible = false; + _globals._sequenceIndexes[1] = _scene->_sequences.startPingPongCycle(_globals._spriteIndexes[1], false, 7, 2); + _scene->_sequences.setAnimRange(_globals._sequenceIndexes[1], 1, 4); + _scene->_sequences.setSeqPlayer(_globals._sequenceIndexes[1], true); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[1], SEQUENCE_TRIGGER_SPRITE, 4, 1); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[1], SEQUENCE_TRIGGER_EXPIRE, 0, 3); + break; + + case 1: + _vm->_sound->command(24); + _globals._sequenceIndexes[2] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[2], false, 10, 1); + _scene->_sequences.setAnimRange(_globals._sequenceIndexes[2], -1, -2); + _scene->_sequences.setDepth(_globals._sequenceIndexes[2], 10); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SEQUENCE_TRIGGER_EXPIRE, 0, 2); + break; + + case 2: + _globals._sequenceIndexes[2] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[2], false, 3); + _scene->_sequences.setDepth(_globals._sequenceIndexes[2], 10); + break; + + case 3: + _game.syncTimers(SYNC_PLAYER, 0, SYNC_SEQ, _globals._sequenceIndexes[1]); + _game._player._visible = true; + _game._player.walk(Common::Point(261, 121), FACING_NORTHEAST); + _game._player.setWalkTrigger(4); + break; + + case 4: + _scene->_nextSceneId = 112; + _globals[kJuliesDoor] = 0; + break; + + default: + break; + } + _action._inProgress = false; + return; + } + } + + if (_action._lookFlag) { + _vm->_dialogs->show(11010); + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_LOOK) || _action.isAction(VERB_LOOK_AT)) { + if (_action.isObject(NOUN_FLOOR)) { + _vm->_dialogs->show(11011); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_WALL)) { + _vm->_dialogs->show(11012); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_CEILING)) { + _vm->_dialogs->show(11013); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_STAIRWELL)) { + _vm->_dialogs->show(11014); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_RIGHT_DOOR)) { + if (_globals[kDoneBrieConv203] >= 1) + _vm->_dialogs->show(11016); + else if (_globals[kChrisFStatus] == 1) + _vm->_dialogs->show(11015); + else + _vm->_dialogs->show(11016); + + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_LEFT_DOOR)) { + _vm->_dialogs->show(11016); + _action._inProgress = false; + return; + } + + if ((_action.isObject(NOUN_WASTE_BASKET)) || (_action.isObject(NOUN_TRASH_BUCKET))) { + _vm->_dialogs->show(11017); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_POSTER)) { + _vm->_dialogs->show(11018); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_BULLETIN_BOARD)) { + _vm->_dialogs->show(11019); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_PAPER)) { + _vm->_dialogs->show(11029); + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_TAKE, NOUN_WASTE_BASKET) || _action.isAction(VERB_TAKE, NOUN_TRASH_BUCKET)) { + _vm->_dialogs->show(11020); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_LIGHT_FIXTURE)) { + if (_globals[kCurrentYear] == 1993) + _vm->_dialogs->show(11021); + else + _vm->_dialogs->show(11028); + + _action._inProgress = false; + return; + } + } + + if (_action.isAction(VERB_TAKE, NOUN_PAPER)) { + _vm->_dialogs->show(11030); + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_CLOSE, NOUN_RIGHT_DOOR)) { + if (_globals[kDoneBrieConv203] >= 1) + _vm->_dialogs->show(11026); + else if (_globals[kChrisFStatus] == 1) + _vm->_dialogs->show(11024); + else + _vm->_dialogs->show(11026); + + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_CLOSE, NOUN_LEFT_DOOR)) { + _vm->_dialogs->show(11025); + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_OPEN, NOUN_RIGHT_DOOR)) { + if ((_globals[kChrisFStatus] == 1) && (_globals[kDoneBrieConv203] == 0)) + _vm->_dialogs->show(11027); + + _action._inProgress = false; + return; + } +} + +void Scene110::preActions() { + if (_action.isAction(VERB_EXIT_TO, NOUN_STAIRWELL)) + _game._player._walkOffScreenSceneId = 109; + + if (_action.isAction(VERB_OPEN, NOUN_LEFT_DOOR) || _action.isAction(VERB_UNLOCK, NOUN_LEFT_DOOR) || _action.isAction(VERB_LOCK, NOUN_LEFT_DOOR)) + _game._player.walk(Common::Point(111, 126), FACING_NORTHEAST); + + if (_action.isAction(VERB_OPEN, NOUN_RIGHT_DOOR) || _action.isAction(VERB_WALK_THROUGH, NOUN_RIGHT_DOOR) + || _action.isAction(VERB_UNLOCK, NOUN_RIGHT_DOOR) || _action.isAction(VERB_LOCK, NOUN_RIGHT_DOOR)) { + if ((_globals[kCurrentYear] == 1881) || (_globals[kDoneBrieConv203] >= 1)) + _game._player.walk(Common::Point(221, 131), FACING_NORTHEAST); + else if ((_globals[kJuliesDoor] == 1) || _action.isAction(VERB_OPEN)) + _game._player.walk(Common::Point(223, 128), FACING_NORTHEAST); + else if (_globals[kJuliesDoor] == 0) + _game._player.walk(Common::Point(261, 120), FACING_NORTHEAST); + } + + if (_action.isAction(VERB_LOOK, NOUN_PAPER)) + _game._player._needToWalk = true; +} + +/*------------------------------------------------------------------------*/ + +Scene111::Scene111(MADSEngine *vm) : Scene1xx(vm) { + _removeAxe = false; + _anim0ActvFl = false; + _anim1ActvFl = false; + _closedFl = false; + _listenFrame = -1; + _listenStatus = -1; + +} + +void Scene111::synchronize(Common::Serializer &s) { + Scene1xx::synchronize(s); + + s.syncAsByte(_removeAxe); + s.syncAsByte(_anim0ActvFl); + s.syncAsByte(_anim1ActvFl); + s.syncAsByte(_closedFl); + s.syncAsSint16LE(_listenFrame); + s.syncAsSint16LE(_listenStatus); +} + +void Scene111::setup() { + if (_globals[kCurrentYear] == 1993) + _scene->_variant = 1; + + setPlayerSpritesPrefix(); + setAAName(); +} + +void Scene111::enter() { + _scene->_hotspots.activate(NOUN_HOOK, false); + + _removeAxe = false; + _anim0ActvFl = false; + _anim1ActvFl = false; + _closedFl = true; + + if (_globals[kCurrentYear] == 1881) { + if ((_globals[kJacquesNameIsKnown] == 2) && (_globals[kMadameNameIsKnown] == 2) && (_globals[kPanelIn206]) && + (_globals[kDoneRichConv203]) && (_game._objects.isInInventory(OBJ_LANTERN)) && + ((_game._objects.isInInventory(OBJ_CABLE_HOOK) && _game._objects.isInInventory(OBJ_ROPE)) || _game._objects.isInInventory(OBJ_ROPE_WITH_HOOK))) { + _closedFl = false; + } else + _closedFl = true; + } else + _closedFl = false; + + if (_globals[kJacquesStatus]) { + _scene->_hotspots.activate(NOUN_HOOK, true); + _scene->_hotspots.activate(NOUN_FIRE_AXE, false); + } + + _vm->_gameConv->get(14); + + _globals._spriteIndexes[0] = _scene->_sprites.addSprites("*RDR_9"); + _globals._spriteIndexes[2] = _scene->_sprites.addSprites(formAnimName('a', 1)); + _globals._spriteIndexes[4] = _scene->_sprites.addSprites(formAnimName('a', 3)); + _globals._spriteIndexes[5] = _scene->_sprites.addSprites(formAnimName('x', 0)); + + if (_globals[kCurrentYear] == 1881) + _globals._spriteIndexes[3] = _scene->_sprites.addSprites(formAnimName('a', 2)); + + if (_globals[kCurrentYear] == 1993) { + _globals._spriteIndexes[1] = _scene->_sprites.addSprites(formAnimName('z', -1)); + _scene->drawToBackground(_globals._spriteIndexes[1], 1, Common::Point(-32000, -32000), 0, 100); + _scene->_hotspots.activate(NOUN_LAMP, false); + int idx = _scene->_dynamicHotspots.add(NOUN_WALL, VERB_WALK_TO, SYNTAX_SINGULAR, EXT_NONE, Common::Rect(35, 82, 35 + 13, 82 + 11)); + _scene->_dynamicHotspots.setPosition(idx, Common::Point(78, 122), FACING_NORTHEAST); + } else { + _scene->_hotspots.activate(NOUN_LIGHT, false); + if (_globals[kChristineDoorStatus] == 2) { + _globals._sequenceIndexes[3] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[3], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[3], 10); + _scene->drawToBackground(_globals._spriteIndexes[4], 1, Common::Point(-32000, -32000), 0, 100); + _scene->_hotspots.activate(NOUN_FIRE_AXE, false); + _scene->_hotspots.activate(NOUN_DOOR_CHUNKS, true); + _scene->_hotspots.activate(NOUN_HANDLE, true); + _scene->_hotspots.activate(NOUN_AXE, true); + } + } + + if ((_globals[kChristineDoorStatus] == 0) && (_scene->_priorSceneId != 113) && !_closedFl) { + _globals._sequenceIndexes[5] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[5], false, 3); + _scene->_sequences.setDepth(_globals._sequenceIndexes[5], 14); + } + + if ((_globals[kCurrentYear] == 1993) || (_globals[kChristineDoorStatus] <= 1)) { + if (!_globals[kJacquesStatus]) { + _globals._sequenceIndexes[2] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[2], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[2], 5); + _scene->_hotspots.activate(NOUN_AXE, false); + } + _scene->_hotspots.activate(NOUN_DOOR_CHUNKS, false); + _scene->_hotspots.activate(NOUN_HANDLE, false); + } + + if (_scene->_priorSceneId == 113) { + _game._player._playerPos = Common::Point(146, 108); + _game._player.walk(Common::Point(112, 126), FACING_SOUTH); + + if (!_globals[kLeaveAngelMusicOn]) + sceneEntrySound(); + + if (_globals[kChristineDoorStatus] != 2) { + _globals._sequenceIndexes[5] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[5], false, 3); + _scene->_sequences.setDepth(_globals._sequenceIndexes[5], 14); + + if ((_globals[kCurrentYear] == 1881) && (_globals[kLeaveAngelMusicOn])) { + _game._player.setWalkTrigger(60); + _game._player._stepEnabled = false; + _globals[kChristineDoorStatus] = 1; + _globals[kChrisKickedRaoulOut] = true; + _globals[kHintThatDaaeIsHome1] = true; + _globals[kHintThatDaaeIsHome2] = true; + } + } + } else if ((_scene->_priorSceneId == 109) || (_scene->_priorSceneId != RETURNING_FROM_LOADING)) + _game._player.firstWalk(Common::Point(335, 150), FACING_WEST, Common::Point(311, 150), FACING_WEST, true); + + sceneEntrySound(); +} + +void Scene111::step() { + if (_anim0ActvFl) + handleListenAnimation(); + + if (!_removeAxe && _anim1ActvFl && (_scene->_animation[_globals._animationIndexes[1]]->getCurrentFrame() == 5)) { + _scene->deleteSequence(_globals._sequenceIndexes[2]); + _game._objects.addToInventory(OBJ_FIRE_AXE); + _removeAxe = true; + } + + if (_game._objects.isInInventory(OBJ_FIRE_AXE) && _anim1ActvFl && (_scene->_animation[_globals._animationIndexes[1]]->getCurrentFrame() == 36)) + _game._objects.setRoom(OBJ_FIRE_AXE, NOWHERE); + + if (_game._player._playerPos == Common::Point(145, 108)) + _scene->_nextSceneId = 113; + + switch (_game._trigger) { + case 60: + _scene->deleteSequence(_globals._sequenceIndexes[5]); + _globals._sequenceIndexes[5] = _scene->_sequences.addReverseSpriteCycle(_globals._spriteIndexes[5], false, 7, 1); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[5], SEQUENCE_TRIGGER_EXPIRE, 0, 62); + _scene->_sequences.setDepth(_globals._sequenceIndexes[5], 14); + _scene->_sequences.setAnimRange(_globals._sequenceIndexes[5], -1, -2); + break; + + case 62: + _vm->_sound->command(25); + _game._player._stepEnabled = true; + _vm->_gameConv->run(14); + if (_game._difficulty == DIFFICULTY_EASY) + _vm->_gameConv->exportValue(1); + else + _vm->_gameConv->exportValue(0); + + _game._player.walk(Common::Point(119, 124), FACING_EAST); + _game._player.setWalkTrigger(64); + break; + + case 64: + _globals._animationIndexes[0] = _scene->loadAnimation(formAnimName('l', 1), 70); + _game.syncTimers(SYNC_ANIM, _globals._animationIndexes[0], SYNC_PLAYER, 0); + _anim0ActvFl = true; + _listenStatus = 0; + _game._player._visible = false; + break; + + case 70: + _game._player._visible = true; + _anim0ActvFl = false; + _game.syncTimers(SYNC_PLAYER, 0, SYNC_ANIM, _globals._animationIndexes[0]); + _scene->_sequences.addTimer(30, 71); + break; + + case 71: + _vm->_gameConv->release(); + break; + + default: + break; + } +} + +void Scene111::actions() { + if (_vm->_gameConv->_running == 14) { + handleListenConversation(); + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_WALK_THROUGH, NOUN_RIGHT_DOOR) || _action.isAction(VERB_OPEN, NOUN_RIGHT_DOOR) || _action.isAction(VERB_UNLOCK) || _action.isAction(VERB_LOCK)) { + switch (_game._trigger) { + case (0): + _game._player._stepEnabled = false; + _game._player._visible = false; + _globals._sequenceIndexes[0] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[0], false, 5, 1); + _scene->_sequences.setAnimRange(_globals._sequenceIndexes[0], 1, 4); + _scene->_sequences.setSeqPlayer(_globals._sequenceIndexes[0], true); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[0], SEQUENCE_TRIGGER_EXPIRE, 0, 1); + _action._inProgress = false; + return; + + case 1: { + int idx = _globals._sequenceIndexes[0]; + _globals._sequenceIndexes[0] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[0], false, 4); + _game.syncTimers(SYNC_SEQ, _globals._sequenceIndexes[0], SYNC_SEQ, idx); + _scene->_sequences.setSeqPlayer(_globals._sequenceIndexes[0], false); + _scene->_sequences.addTimer(30, 2); + _vm->_sound->command(73); + _action._inProgress = false; + return; + } + + case 2: + _scene->deleteSequence(_globals._sequenceIndexes[0]); + _globals._sequenceIndexes[0] = _scene->_sequences.addReverseSpriteCycle(_globals._spriteIndexes[0], false, 5, 1); + _scene->_sequences.setAnimRange(_globals._sequenceIndexes[0], 1, 4); + _scene->_sequences.setSeqPlayer(_globals._sequenceIndexes[0], false); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[0], SEQUENCE_TRIGGER_EXPIRE, 0, 3); + _action._inProgress = false; + return; + + case 3: + _game.syncTimers(SYNC_PLAYER, 0, SYNC_SEQ, _globals._sequenceIndexes[0]); + _game._player._visible = true; + if (_action.isAction(VERB_LOCK) || _action.isAction(VERB_UNLOCK)) + _vm->_dialogs->show(32); + else + _vm->_dialogs->show(11123); + + _game._player._stepEnabled = true; + _action._inProgress = false; + return; + + default: + break; + } + } + + if (_action.isAction(VERB_WALK_THROUGH, NOUN_LEFT_DOOR) || _action.isAction(VERB_OPEN, NOUN_LEFT_DOOR) || _action.isAction(VERB_UNLOCK, NOUN_LEFT_DOOR) || _action.isAction(VERB_LOCK, NOUN_LEFT_DOOR)) { + if ((_globals[kChristineDoorStatus] == 1) || _closedFl || _action.isAction(VERB_UNLOCK, NOUN_LEFT_DOOR) || _action.isAction(VERB_LOCK, NOUN_LEFT_DOOR)) { + switch (_game._trigger) { + case (0): + _game._player._stepEnabled = false; + _game._player._visible = false; + _globals._sequenceIndexes[0] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[0], false, 5, 1); + _scene->_sequences.setAnimRange(_globals._sequenceIndexes[0], 1, 4); + _scene->_sequences.setSeqPlayer(_globals._sequenceIndexes[0], true); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[0], SEQUENCE_TRIGGER_EXPIRE, 0, 1); + _action._inProgress = false; + return; + + case 1: { + int idx = _globals._sequenceIndexes[0]; + _globals._sequenceIndexes[0] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[0], false, 4); + _game.syncTimers(SYNC_SEQ, _globals._sequenceIndexes[0], SYNC_SEQ, idx); + _scene->_sequences.setSeqPlayer(_globals._sequenceIndexes[0], false); + _scene->_sequences.addTimer(30, 2); + _vm->_sound->command(73); + _action._inProgress = false; + return; + } + + case 2: + _scene->deleteSequence(_globals._sequenceIndexes[0]); + _globals._sequenceIndexes[0] = _scene->_sequences.addReverseSpriteCycle(_globals._spriteIndexes[0], false, 5, 1); + _scene->_sequences.setAnimRange(_globals._sequenceIndexes[0], 1, 4); + _scene->_sequences.setSeqPlayer(_globals._sequenceIndexes[0], false); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[0], SEQUENCE_TRIGGER_EXPIRE, 0, 3); + _action._inProgress = false; + return; + + case 3: + _game.syncTimers(SYNC_PLAYER, 0, SYNC_SEQ, _globals._sequenceIndexes[0]); + _game._player._visible = true; + + if (_action.isAction(VERB_LOCK) || _action.isAction(VERB_UNLOCK)) + _vm->_dialogs->show(32); + else if ((_globals[kChrisKickedRaoulOut]) && (_globals[kTicketPeoplePresent] == 1) && (_globals[kJacquesStatus] == 0)) + _vm->_dialogs->show(11135); + else + _vm->_dialogs->show(11124); + + _game._player._stepEnabled = true; + _action._inProgress = false; + return; + + default: + break; + } + } else if (_globals[kChristineDoorStatus] == 2) { + _vm->_dialogs->show(11137); + _action._inProgress = false; + return; + } else { + _vm->_dialogs->show(11126); + _action._inProgress = false; + return; + } + } + + if (_action.isAction(VERB_TAKE, NOUN_FIRE_AXE)) { + if ((_globals[kCurrentYear] == 1881) && (_globals[kJacquesStatus] == 0) && (_globals[kChristineDoorStatus] == 1) && (_globals[kChrisKickedRaoulOut])) { + switch (_game._trigger) { + case 0: + _globals._animationIndexes[1] = _scene->loadAnimation(formAnimName('q', -1), 1); + _scene->_hotspots.activate(NOUN_FIRE_AXE, false); + _scene->_hotspots.activate(NOUN_DOOR_CHUNKS, true); + _scene->_hotspots.activate(NOUN_HANDLE, true); + _scene->_hotspots.activate(NOUN_AXE, true); + _anim1ActvFl = true; + _game._player._stepEnabled = false; + _game._player._visible = false; + break; + + case 1: + _globals[kChristineDoorStatus] = 2; + _globals._sequenceIndexes[3] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[3], false, 1); + _game.syncTimers(SYNC_SEQ, _globals._sequenceIndexes[3], SYNC_ANIM, _globals._animationIndexes[1]); + _scene->_sequences.setDepth(_globals._sequenceIndexes[3], 10); + _scene->drawToBackground(_globals._spriteIndexes[4], 1, Common::Point(-32000, -32000), 0, 100); + _game.syncTimers(SYNC_PLAYER, 0, SYNC_ANIM, _globals._animationIndexes[1]); + _game._player._visible = true; + _game._player._playerPos = Common::Point(126, 126); + _anim1ActvFl = false; + _game._player.walk(Common::Point(145, 108), FACING_NORTHEAST); + _game._player.resetFacing(FACING_NORTHWEST); + break; + + default: + break; + } + } else if (_globals[kCurrentYear] == 1993 && _globals[kMakeBrieLeave203]) + _vm->_dialogs->show(11142); + else + _vm->_dialogs->show(11134); + _action._inProgress = false; + return; + } + + if (_action._lookFlag) { + if (_globals[kCurrentYear] == 1993) + _vm->_dialogs->show(11110); + else + _vm->_dialogs->show(11111); + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_LOOK) || _action.isAction(VERB_LOOK_AT)) { + if (_action.isObject(NOUN_FLOOR)) { + _vm->_dialogs->show(11112); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_WALL)) { + _vm->_dialogs->show(11113); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_CEILING)) { + _vm->_dialogs->show(11114); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_STAIRWELL)) { + _vm->_dialogs->show(11115); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_TABLE)) { + _vm->_dialogs->show(11118); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_PLANT)) { + _vm->_dialogs->show(11119); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_FIRE_AXE)) { + _vm->_dialogs->show(11120); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_HANDLE)) { + _vm->_dialogs->show(11121); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_AXE)) { + _vm->_dialogs->show(11122); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_DOOR_CHUNKS)) { + _vm->_dialogs->show(11129); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_LIGHT)) { + _vm->_dialogs->show(11131); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_LAMP)) { + _vm->_dialogs->show(11132); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_HOOK)) { + _vm->_dialogs->show(11141); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_LEFT_DOOR)) { + if (_globals[kJacquesStatus]) + _vm->_dialogs->show(11140); + else if (_globals[kChristineDoorStatus] == 2) + _vm->_dialogs->show(11130); + else if ((_globals[kChrisKickedRaoulOut]) && (_globals[kTicketPeoplePresent] == 1)) + _vm->_dialogs->show(11136); + else if ((_globals[kChristineDoorStatus] == 1) || _closedFl) + _vm->_dialogs->show(11117); + else if (_globals[kChristineDoorStatus] == 0) + _vm->_dialogs->show(11116); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_RIGHT_DOOR)) { + _vm->_dialogs->show(11117); + _action._inProgress = false; + return; + } + } + + if (_action.isAction(VERB_CLOSE, NOUN_RIGHT_DOOR)) { + _vm->_dialogs->show(11128); + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_CLOSE, NOUN_LEFT_DOOR)) { + if (_closedFl) + _vm->_dialogs->show(11128); + else if ((_globals[kChristineDoorStatus] == 2) && (!_globals[kTicketPeoplePresent])) + _vm->_dialogs->show(11138); + else if (_globals[kChristineDoorStatus] == 1) + _vm->_dialogs->show(11127); + else if (_globals[kChristineDoorStatus] == 0) + _vm->_dialogs->show(11125); + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_OPEN, NOUN_LEFT_DOOR)) { + if (_globals[kChristineDoorStatus] == 0) + _vm->_dialogs->show(11126); + _action._inProgress = false; + return; + } +} + +void Scene111::preActions() { + if (_action.isAction(VERB_EXIT_TO, NOUN_STAIRWELL)) { + if (_globals[kLeaveAngelMusicOn]) { + _vm->_dialogs->show(11139); + _game._player._needToWalk = false; + _game._player.cancelCommand(); + } else + _game._player._walkOffScreenSceneId = 109; + } + + if (_action.isAction(VERB_TAKE, NOUN_FIRE_AXE) && _game._objects.isInRoom(OBJ_FIRE_AXE) && (_globals[kCurrentYear] == 1881) + && (_globals[kChristineDoorStatus] == 1) && (_globals[kChrisKickedRaoulOut]) && (_globals[kJacquesStatus] == 0)) + _game._player.walk(Common::Point(119, 124), FACING_EAST); + + if (_action.isAction(VERB_OPEN, NOUN_RIGHT_DOOR) || _action.isAction(VERB_UNLOCK, NOUN_RIGHT_DOOR) || _action.isAction(VERB_LOCK, NOUN_RIGHT_DOOR)) + _game._player.walk(Common::Point(219, 131), FACING_NORTHEAST); + + if (_action.isAction(VERB_OPEN, NOUN_LEFT_DOOR) || _action.isAction(VERB_UNLOCK, NOUN_LEFT_DOOR) || _action.isAction(VERB_LOCK, NOUN_LEFT_DOOR)) + _game._player.walk(Common::Point(109, 124), FACING_NORTHEAST); + + if ((_action.isAction(VERB_WALK_THROUGH, NOUN_LEFT_DOOR) || _action.isAction(VERB_UNLOCK, NOUN_LEFT_DOOR) || _action.isAction(VERB_LOCK, NOUN_LEFT_DOOR)) + && !_closedFl && ((_globals[kChristineDoorStatus] == 2) || (_globals[kChristineDoorStatus] == 0))) + _game._player.walk(Common::Point(145, 108), FACING_NORTHEAST); +} + +void Scene111::handleListenAnimation() { + if (_scene->_animation[_globals._animationIndexes[0]]->getCurrentFrame() == _listenFrame) + return; + + int nextFrame = -1; + _listenFrame = _scene->_animation[_globals._animationIndexes[0]]->getCurrentFrame(); + + if (_listenFrame == 6) { + if (_listenStatus == 0) + nextFrame = 5; + else if (_listenStatus == 1) + nextFrame = 7; + } + + if (nextFrame >= 0) { + _scene->setAnimFrame(_globals._animationIndexes[0], nextFrame); + _listenFrame = nextFrame; + } +} + +void Scene111::handleListenConversation() { + if (_action._activeAction._verbId == 1) + _vm->_gameConv->setInterlocutorTrigger(66); + + if (_action._activeAction._verbId == 7) + _vm->_gameConv->setInterlocutorTrigger(68); + + if (_game._trigger == 66) + _listenStatus = 0; + + if (_game._trigger == 68) { + _listenStatus = 1; + _vm->_gameConv->hold(); + } + + if ((_action._activeAction._verbId != 1) && (_action._activeAction._verbId != 7)) + _vm->_gameConv->setInterlocutorTrigger(72); +} + +/*------------------------------------------------------------------------*/ + +Scene112::Scene112(MADSEngine *vm) : Scene1xx(vm) { + _anim0ActvFl = false; + _anim1ActvFl = false; + _raoulAction = -1; + _raoulFrame = -1; + _didOptionFl = -1; + _julieFrame = -1; + _julieAction = -1; + _julieHotspotId = -1; + _julieCounter = -1; +} + +void Scene112::synchronize(Common::Serializer &s) { + Scene1xx::synchronize(s); + + s.syncAsByte(_anim0ActvFl); + s.syncAsByte(_anim1ActvFl); + s.syncAsSint16LE(_raoulAction); + s.syncAsSint16LE(_raoulFrame); + s.syncAsSint16LE(_didOptionFl); + s.syncAsSint16LE(_julieFrame); + s.syncAsSint16LE(_julieAction); + s.syncAsSint16LE(_julieCounter); +} + +void Scene112::setup() { + setPlayerSpritesPrefix(); + setAAName(); + + _scene->addActiveVocab(NOUN_WOMAN); + _scene->addActiveVocab(NOUN_JULIE); +} + +void Scene112::enter() { + if (_scene->_priorSceneId != RETURNING_FROM_LOADING) { + _raoulAction = 2; + _didOptionFl = 0; + } + + _vm->_gameConv->get(3); + + _globals._animationIndexes[0] = _scene->loadAnimation(formAnimName('j', 1), 1); + _anim0ActvFl = true; + _julieAction = 2; + _scene->setAnimFrame(_globals._animationIndexes[0], 3); + if (_globals[kJulieNameIsKnown] == 2) { + _julieHotspotId = _scene->_dynamicHotspots.add(NOUN_JULIE, VERB_WALK_TO, SYNTAX_SINGULAR_FEM, EXT_NONE, Common::Rect(255, 82, 255 + 30, 82 + 44)); + _scene->_dynamicHotspots[_julieHotspotId]._articleNumber = PREP_ON; + _scene->_dynamicHotspots.setPosition(_julieHotspotId, Common::Point(216, 137), FACING_NORTHEAST); + _scene->_hotspots.activate(NOUN_WOMAN, false); + } + _globals._animationIndexes[1] = _scene->loadAnimation(formAnimName('r', 1), 1); + _anim1ActvFl = true; + _scene->setAnimFrame(_globals._animationIndexes[1], 82); + _raoulAction = 2; + + if (_vm->_gameConv->_restoreRunning == 3) { + _vm->_gameConv->run(3); + _vm->_gameConv->exportPointer(&_globals[kPlayerScore]); + _scene->setAnimFrame(_globals._animationIndexes[1], 17); + _raoulAction = 1; + _game._player._playerPos = Common::Point(53, 128); + _game._player._facing = FACING_EAST; + _game._player._visible = false; + } else if ((_scene->_priorSceneId == 110) || (_scene->_priorSceneId != RETURNING_FROM_LOADING)) { + _game._player._playerPos = Common::Point(128, 145); + _game._player._facing = FACING_NORTH; + } + + sceneEntrySound(); +} + +void Scene112::step() { + if (_anim0ActvFl) + handleJulieAnimation(); + + if (_anim1ActvFl) + handleRaoulChair(); +} + +void Scene112::actions() { + if (_vm->_gameConv->_running == 3) { + handleConversation(); + _action._inProgress = false; + return; + } + + if ((_action.isAction(VERB_TALK_TO, NOUN_JULIE)) || (_action.isAction(VERB_TALK_TO, NOUN_WOMAN))) { + if (_globals[kJulieNameIsKnown] > 0) { + _game._player._visible = false; + _game.syncTimers(SYNC_ANIM, _globals._animationIndexes[1], SYNC_PLAYER, 0); + _scene->setAnimFrame(_globals._animationIndexes[1], 1); + _raoulAction = 1; + } + _vm->_gameConv->run(3); + _vm->_gameConv->exportPointer(&_globals[kPlayerScore]); + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_EXIT_TO, NOUN_CORRIDOR)) { + _scene->_nextSceneId = 110; + _action._inProgress = false; + return; + } + + if (_action._lookFlag) { + _vm->_dialogs->show(11210); + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_LOOK) || _action.isAction(VERB_LOOK_AT)) { + if (_action.isObject(NOUN_WALL)) { + _vm->_dialogs->show(11211); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_FLOOR)) { + _vm->_dialogs->show(11212); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_MIRROR)) { + _vm->_dialogs->show(11213); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_BALLET_BAR)) { + _vm->_dialogs->show(11214); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_CORRIDOR)) { + _vm->_dialogs->show(11215); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_THROW_RUGS)) { + _vm->_dialogs->show(11216); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_DRESSING_SCREEN)) { + _vm->_dialogs->show(11217); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_DRESSING_TABLE)) { + _vm->_dialogs->show(11218); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_CHAIR)) { + _vm->_dialogs->show(11219); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_PLANT)) { + _vm->_dialogs->show(11220); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_COAT_RACK)) { + _vm->_dialogs->show(11221); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_UMBRELLA)) { + _vm->_dialogs->show(11222); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_PAINTINGS)) { + _vm->_dialogs->show(11223); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_TRASH_BUCKET)) { + _vm->_dialogs->show(11224); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_SHELF)) { + _vm->_dialogs->show(11225); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_CONTAINER)) { + _vm->_dialogs->show(11226); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_TORN_POSTER)) { + _vm->_dialogs->show(11227); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_POSTER)) { + _vm->_dialogs->show(11228); + _action._inProgress = false; + return; + } + + if ((_action.isObject(NOUN_REVIEW)) || (_action.isObject(NOUN_REVIEWS))) { + _vm->_dialogs->show(11229); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_JULIE)) { + _vm->_dialogs->show(11231); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_COSTUME_RACK)) { + _vm->_dialogs->show(11232); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_LIGHT_FIXTURE)) { + _vm->_dialogs->show(11233); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_WARDROBE)) { + _vm->_dialogs->show(11234); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_WOMAN)) { + _vm->_dialogs->show(11237); + _action._inProgress = false; + return; + } + } + + if (_action.isAction(VERB_TAKE)) { + if (_action.isObject(NOUN_WOMAN) || _action.isObject(NOUN_JULIE)) { + _vm->_dialogs->show(11238); + _action._inProgress = false; + return; + } + } + + if (_action.isAction(VERB_OPEN, NOUN_WARDROBE)) { + _vm->_dialogs->show(11235); + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_OPEN, NOUN_CONTAINER)) { + _vm->_dialogs->show(11236); + _action._inProgress = false; + return; + } +} + +void Scene112::preActions() { + if ((_action.isAction(VERB_TALK_TO, NOUN_JULIE) || _action.isAction(VERB_TALK_TO, NOUN_WOMAN)) && (_globals[kJulieNameIsKnown] > 0)) + _game._player.walk(Common::Point(53, 128), FACING_EAST); +} + +void Scene112::handleConversation() { + switch (_action._activeAction._verbId) { + case 1: + if (!_game._trigger && (_raoulAction == 2)) + _vm->_gameConv->setInterlocutorTrigger(68); + break; + + case 3: + case 4: + if (_globals[kJulieNameIsKnown] < 2) { + _globals[kJulieNameIsKnown] = 2; + _scene->_hotspots.activate(NOUN_WOMAN, false); + _julieHotspotId = _scene->_dynamicHotspots.add(NOUN_JULIE, VERB_WALK_TO, SYNTAX_SINGULAR_FEM, EXT_NONE, Common::Rect(255, 82, 255 + 30, 82 + 44)); + _scene->_dynamicHotspots[_julieHotspotId]._articleNumber = PREP_ON; + _scene->_dynamicHotspots.setPosition(_julieHotspotId, Common::Point(216, 137), FACING_NORTHEAST); + } + break; + + case 5: + _vm->_gameConv->setInterlocutorTrigger(74); + _globals[kJulieNameIsKnown] = 1; + break; + + case 6: + case 7: + case 10: + case 23: + case 27: + _vm->_gameConv->setInterlocutorTrigger(74); + _globals[kJulieNameIsKnown] = 2; + break; + + case 13: + _julieAction = 1; + _raoulAction = 1; + break; + + case 14: + case 15: + case 16: + _julieAction = 0; + _raoulAction = 1; + break; + + default: + break; + } + + switch (_game._trigger) { + case 60: + _julieAction = 0; + _raoulAction = 1; + break; + + case 62: + _julieAction = 2; + if (_raoulAction != 2) + _raoulAction = 0; + break; + + case 68: + _scene->_sequences.addTimer(120, 70); + _vm->_gameConv->hold(); + break; + + case 70: + _game._player.walk(Common::Point(53, 128), FACING_EAST); + _game._player.setWalkTrigger(72); + break; + + case 72: + _vm->_gameConv->release(); + _game._player._visible = false; + _game.syncTimers(SYNC_ANIM, _globals._animationIndexes[1], SYNC_PLAYER, 0); + _scene->setAnimFrame(_globals._animationIndexes[1], 1); + _raoulAction = 1; + break; + + case 74: + _raoulAction = 3; + _vm->_gameConv->hold(); + break; + + default: + break; + } + + if ((_action._activeAction._verbId != 0) && (_action._activeAction._verbId != 1) && + (_action._activeAction._verbId != 2) && (_action._activeAction._verbId != 5) && + (_action._activeAction._verbId != 6) && (_action._activeAction._verbId != 7) && + (_action._activeAction._verbId != 10) && (_action._activeAction._verbId != 23) && + (_action._activeAction._verbId != 27)) { + _vm->_gameConv->setInterlocutorTrigger(60); + _vm->_gameConv->setHeroTrigger(62); + } + + if (_action._activeAction._verbId == 18) + _globals[kCanFindBookInLibrary] = true; + + _julieCounter = 0; +} + +void Scene112::handleJulieAnimation() { + if (_scene->_animation[_globals._animationIndexes[0]]->getCurrentFrame() == _julieFrame) + return; + + _julieFrame = _scene->_animation[_globals._animationIndexes[0]]->getCurrentFrame(); + int random = -1; + int resetFrame = -1; + + switch (_julieFrame) { + case 1: + case 2: + case 3: + case 22: + case 39: + case 71: + case 107: + switch (_julieAction) { + case 0: + random = _vm->getRandomNumber(4, 6); + ++_julieCounter; + if (_julieCounter > 25) + _julieAction = 2; + break; + + case 1: + random = 3; + break; + + case 2: + random = _vm->getRandomNumber(1, 3); + while (_didOptionFl == random) + random = _vm->getRandomNumber(1, 3); + _didOptionFl = random; + break; + + default: + break; + } + + switch (random) { + case 1: + resetFrame = 22; + break; + + case 2: + resetFrame = 39; + break; + + case 3: + resetFrame = 83; + break; + + case 4: + resetFrame = 0; + break; + + case 5: + resetFrame = 1; + break; + + case 6: + resetFrame = 2; + break; + + default: + break; + } + break; + case 56: + case 77: + case 83: + random = _vm->getRandomNumber(1, 3); + while (_didOptionFl == random) + random = _vm->getRandomNumber(1, 3); + _didOptionFl = random; + + if ((_julieAction == 0) || (_julieAction == 1)) + random = 3; + + switch (random) { + case 1: + resetFrame = 71; + break; + + case 2: + resetFrame = 77; + break; + + case 3: + resetFrame = 56; + break; + + default: + break; + } + + break; + + case 95: + if (_julieAction == 1) + random = 2; + else + random = 1; + + switch (random) { + case 1: + resetFrame = 95; + break; + + case 2: + resetFrame = 107; + break; + + default: + break; + } + break; + + case 130: + resetFrame = 95; + _julieAction = 2; + break; + + default: + break; + } + + if (resetFrame >= 0) { + _scene->setAnimFrame(_globals._animationIndexes[0], resetFrame); + _julieFrame = resetFrame; + } +} + +void Scene112::handleRaoulChair() { + if (_scene->_animation[_globals._animationIndexes[1]]->getCurrentFrame() == _raoulFrame) + return; + + _raoulFrame = _scene->_animation[_globals._animationIndexes[1]]->getCurrentFrame(); + int resetFrame = -1; + int random = -1; + + switch (_raoulFrame) { + case 18: + case 30: + case 41: + case 49: + case 56: + case 65: + switch (_raoulAction) { + case 0: + random = _vm->getRandomNumber(1, 4); + _raoulAction = 1; + break; + + case 2: + random = 6; + break; + + case 3: + random = 5; + _raoulAction = 2; + break; + + default: + random = _vm->getRandomNumber(7, 50); + while (_didOptionFl == random) + random = _vm->getRandomNumber(7, 50); + _didOptionFl = random; + break; + } + + switch (random) { + case 1: + resetFrame = 49; + break; + + case 2: + resetFrame = 41; + break; + + case 3: + resetFrame = 18; + break; + + case 4: + resetFrame = 30; + break; + + case 5: + resetFrame = 65; + break; + + case 6: + resetFrame = 82; + break; + + case 7: + resetFrame = 56; + break; + + default: + resetFrame = 17; + break; + } + break; + + case 61: + if (_raoulAction == 1) + random = 1; + else + random = 2; + + switch (random) { + case 1: + resetFrame = 60; + break; + + case 2: + resetFrame = 61; + break; + + default: + break; + } + break; + + case 82: + _raoulAction = 2; + _game._player._visible = true; + _vm->_gameConv->release(); + _game.syncTimers(SYNC_PLAYER, 0, SYNC_ANIM, _globals._animationIndexes[1]); + break; + + case 83: + if (_raoulAction == 2) + random = 1; + else + random = 2; + + switch (random) { + case 1: + resetFrame = 82; + break; + + case 2: + resetFrame = 0; + break; + + default: + break; + } + break; + + default: + break; + } + + if (resetFrame >= 0) { + _scene->setAnimFrame(_globals._animationIndexes[1], resetFrame); + _raoulFrame = resetFrame; + } +} + +/*------------------------------------------------------------------------*/ + +Scene113::Scene113(MADSEngine *vm) : Scene1xx(vm) { + _standingAndTalking = false; + _dayWantsToTalk = false; + _musicPlaying = false; + _afterKissFl = false; + _anim0ActvFl = false; + _anim1ActvFl = false; + _anim2ActvFl = false; + _anim3ActvFl = false; + _anim4ActvFl = false; + _prevent1 = false; + _prevent2 = false; + _raoulStandingFl = false; + _armsOutFl = false; + + _dayStatus = -1; + _raoulAction = -1; + _christineHotspotId2 = -1; + _raoulCount = -1; + _dayCount = -1; + _standCount = -1; + _julieStatus = -1; + _florentStatus = -1; + _florentFrame = -1; + _florentCount = -1; + _dayFrame = -1; + _lastDayResetFrame = -1; + _raoulFrame = -1; + _julieFrame = -1; + _julieCount = -1; +} + +void Scene113::synchronize(Common::Serializer &s) { + Scene1xx::synchronize(s); + + s.syncAsByte(_standingAndTalking); + s.syncAsByte(_dayWantsToTalk); + s.syncAsByte(_musicPlaying); + s.syncAsByte(_afterKissFl); + s.syncAsByte(_anim0ActvFl); + s.syncAsByte(_anim1ActvFl); + s.syncAsByte(_anim2ActvFl); + s.syncAsByte(_anim3ActvFl); + s.syncAsByte(_anim4ActvFl); + s.syncAsByte(_prevent1); + s.syncAsByte(_prevent2); + s.syncAsByte(_raoulStandingFl); + s.syncAsByte(_armsOutFl); + + s.syncAsSint16LE(_dayStatus); + s.syncAsSint16LE(_raoulAction); + s.syncAsSint16LE(_christineHotspotId2); + s.syncAsSint16LE(_raoulCount); + s.syncAsSint16LE(_dayCount); + s.syncAsSint16LE(_standCount); + s.syncAsSint16LE(_julieStatus); + s.syncAsSint16LE(_florentStatus); + s.syncAsSint16LE(_florentFrame); + s.syncAsSint16LE(_florentCount); + s.syncAsSint16LE(_dayFrame); + s.syncAsSint16LE(_lastDayResetFrame); + s.syncAsSint16LE(_raoulFrame); + s.syncAsSint16LE(_julieFrame); + s.syncAsSint16LE(_julieCount); +} + +void Scene113::setup() { + setPlayerSpritesPrefix(); + setAAName(); + + _scene->addActiveVocab(NOUN_CHRISTINE); + _scene->addActiveVocab(NOUN_WOMAN); + _scene->addActiveVocab(NOUN_JULIE); +} + +void Scene113::enter() { + if (_scene->_priorSceneId != RETURNING_FROM_LOADING) { + _standingAndTalking = false; + _dayWantsToTalk = false; + _musicPlaying = false; + _afterKissFl = false; + _anim0ActvFl = false; + _anim1ActvFl = false; + _anim2ActvFl = false; + _anim3ActvFl = false; + _anim4ActvFl = false; + _prevent1 = false; + _prevent2 = false; + _raoulStandingFl = false; + _armsOutFl = false; + } + + _scene->_hotspots.activate(NOUN_SMALL_NOTE, false); + _scene->_hotspots.activate(NOUN_DRESSING_GOWN, false); + _scene->_hotspots.activate(NOUN_CHRISTINE, false); + _scene->_hotspots.activate(NOUN_JULIE, false); + _scene->_hotspots.activate(NOUN_LIGHT_FIXTURE, false); + + if (_globals[kCurrentYear] == 1993) { + _globals._spriteIndexes[3] = _scene->_sprites.addSprites(formAnimName('z', -1)); + _globals._spriteIndexes[0] = _scene->_sprites.addSprites(formAnimName('f', 0)); + + if (_game._objects.isInRoom(OBJ_SMALL_NOTE)) + _globals._spriteIndexes[1] = _scene->_sprites.addSprites(formAnimName('f', 1)); + + if ((_globals[kDoneBrieConv203] == 1) || (_globals[kDoneBrieConv203] == 3)) + _globals._spriteIndexes[2] = _scene->_sprites.addSprites(formAnimName('c', 3)); + } + + if (_globals[kCurrentYear] == 1993) { + _vm->_gameConv->get(4); + if ((_globals[kDoneBrieConv203] == 1) || (_globals[kDoneBrieConv203] == 3)) + _vm->_gameConv->get(6); + } else { + _globals._spriteIndexes[4] = _scene->_sprites.addSprites("*faceral", false); + _globals._spriteIndexes[5] = _scene->_sprites.addSprites("*facecrsd", false); + _vm->_gameConv->get(13); + } + + if (_globals[kCurrentYear] == 1993) { + _scene->drawToBackground(_globals._spriteIndexes[3], 1, Common::Point(-32000, -32000), 0, 100); + _scene->_hotspots.activate(NOUN_VASE, false); + _scene->_hotspots.activate(NOUN_FAN, false); + _scene->_hotspots.activateAtPos(NOUN_LIGHT_FIXTURE, true, Common::Point(155, 17)); + } else { + _scene->_hotspots.activateAtPos(NOUN_LIGHT_FIXTURE, true, Common::Point(150, 46)); + _scene->_hotspots.activate(NOUN_NOTICE, false); + } + + if (_scene->_priorSceneId == RETURNING_FROM_LOADING) { + if (_globals[kCurrentYear] == 1881) { + if (_dayStatus <= 3) { + _globals._animationIndexes[1] = _scene->loadAnimation(formAnimName('r', 1), 1); + _anim1ActvFl = true; + } + + if (_raoulAction == 3) + _scene->setAnimFrame(_globals._animationIndexes[1], 33); + else { + _raoulAction = 1; + _game._player._visible = false; + _scene->setAnimFrame(_globals._animationIndexes[1], 8); + } + + if (_musicPlaying) { + _globals._animationIndexes[0] = _scene->loadAnimation(formAnimName('d', 2), 0); + _anim0ActvFl = true; + _christineHotspotId1 = _scene->_dynamicHotspots.add(NOUN_CHRISTINE, VERB_WALK_TO, SYNTAX_SINGULAR_FEM, EXT_NONE, Common::Rect(0, 0, 0, 0)); + _scene->_dynamicHotspots[_christineHotspotId1]._articleNumber = PREP_ON; + _scene->setDynamicAnim(_christineHotspotId1, _globals._animationIndexes[0], 13); + _scene->setDynamicAnim(_christineHotspotId1, _globals._animationIndexes[0], 14); + _scene->setDynamicAnim(_christineHotspotId1, _globals._animationIndexes[0], 16); + _scene->setAnimFrame(_globals._animationIndexes[0], 212); + _game._player._visible = true; + _anim1ActvFl = false; + } else { + switch (_dayStatus) { + case 0: + case 1: + case 2: + case 3: + _globals._animationIndexes[0] = _scene->loadAnimation(formAnimName('d', 1), 0); + _anim0ActvFl = true; + _dayStatus = 2; + _scene->setAnimFrame(_globals._animationIndexes[0], 208); + _scene->_hotspots.activate(NOUN_CHRISTINE, true); + _scene->_hotspots.activateAtPos(NOUN_CHRISTINE, false, Common::Point(220, 130)); + break; + + default: + _globals._animationIndexes[0] = _scene->loadAnimation(formAnimName('d', 2), 0); + _anim0ActvFl = true; + _dayStatus = 7; + _game._player._visible = false; + _scene->setAnimFrame(_globals._animationIndexes[0], 165); + break; + } + _christineHotspotId1 = _scene->_dynamicHotspots.add(NOUN_CHRISTINE, VERB_WALK_TO, SYNTAX_SINGULAR_FEM, EXT_NONE, Common::Rect(0, 0, 0, 0)); + _scene->_dynamicHotspots[_christineHotspotId1]._articleNumber = PREP_ON; + _scene->setDynamicAnim(_christineHotspotId1, _globals._animationIndexes[0], 13); + _scene->setDynamicAnim(_christineHotspotId1, _globals._animationIndexes[0], 14); + _scene->setDynamicAnim(_christineHotspotId1, _globals._animationIndexes[0], 16); + } + + if (_dayStatus == 2) { + _scene->_hotspots.activate(NOUN_CHRISTINE, true); + _scene->_hotspots.activateAtPos(NOUN_CHRISTINE, false, Common::Point(220, 130)); + } else { + _game._player._playerPos = Common::Point(175, 148); + _game._player._facing = FACING_NORTHEAST; + } + + } else if ((_globals[kDoneBrieConv203] == 1) || (_globals[kDoneBrieConv203] == 3)) { + _globals._animationIndexes[4] = _scene->loadAnimation(formAnimName('x', 1), 1); + _julieStatus = 0; + _anim4ActvFl = true; + _globals[kMakeBrieLeave203] = true; + _globals._sequenceIndexes[0] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[0], false, 1); + _globals._sequenceIndexes[2] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[2], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[0], 14); + _scene->_sequences.setDepth(_globals._sequenceIndexes[2], 14); + _scene->_hotspots.activate(NOUN_DRESSING_GOWN, true); + _scene->_hotspots.activate(NOUN_JULIE, true); + _scene->_hotspots.activateAtPos(NOUN_CHRISTINE, true, Common::Point(220, 130)); + } else if (_globals[kCurrentYear] == 1993) { + _globals._sequenceIndexes[0] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[0], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[0], 14); + _globals._animationIndexes[2] = _scene->loadAnimation(formAnimName('f', 1), 1); + _anim2ActvFl = true; + + if (_florentStatus != 3) + _florentStatus = 1; + + _globals._animationIndexes[3] = _scene->loadAnimation(formAnimName('r', 1), 1); + _anim3ActvFl = true; + + if (_raoulAction == 3) + _scene->setAnimFrame(_globals._animationIndexes[3], 33); + else { + _scene->setAnimFrame(_globals._animationIndexes[3], 8); + _raoulAction = 1; + _game._player._playerPos = Common::Point(201, 120); + _game._player._facing = FACING_SOUTH; + _game._player._visible = false; + } + + if (_florentStatus == 3) + _scene->setAnimFrame(_globals._animationIndexes[2], 41); + + if (_globals[kFlorentNameIsKnown] >= 1) { + _christineHotspotId2 = _scene->_dynamicHotspots.add(NOUN_CHRISTINE, VERB_WALK_TO, SYNTAX_SINGULAR_FEM, EXT_NONE, Common::Rect(43, 118, 43 + 15, 118 + 29)); + _scene->_dynamicHotspots[_christineHotspotId2]._articleNumber = PREP_ON; + _scene->_dynamicHotspots.setPosition(_christineHotspotId2, Common::Point(106, 127), FACING_SOUTHWEST); + } else { + _christineHotspotId2 = _scene->_dynamicHotspots.add(NOUN_WOMAN, VERB_WALK_TO, SYNTAX_FEM_NOT_PROPER, EXT_NONE, Common::Rect(43, 118, 43 + 15, 118 + 29)); + _scene->_dynamicHotspots[_christineHotspotId2]._articleNumber = PREP_ON; + _scene->_dynamicHotspots.setPosition(_christineHotspotId2, Common::Point(106, 127), FACING_SOUTHWEST); + } + + _scene->_hotspots.activate(NOUN_DRESSING_GOWN, true); + + if (_game._objects.isInRoom(OBJ_SMALL_NOTE)) { + _scene->_hotspots.activate(NOUN_SMALL_NOTE, true); + _globals._sequenceIndexes[1] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[1], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[1], 13); + } + } + } else if (_globals[kCurrentYear] == 1993) { + if ((_globals[kDoneBrieConv203] == 1) || (_globals[kDoneBrieConv203] == 3)) { + if (!(_globals[kPlayerScoreFlags] & 4)) { + _globals[kPlayerScoreFlags] = _globals[kPlayerScoreFlags] | 4; + _globals[kPlayerScore] += 5; + } + + _globals._animationIndexes[4] = _scene->loadAnimation(formAnimName('x', 1), 1); + _julieStatus = 0; + _anim4ActvFl = true; + _globals[kMakeBrieLeave203] = true; + _game._player._playerPos = Common::Point(190, 148); + _game._player._facing = FACING_NORTH; + _game._player._stepEnabled = false; + _globals._sequenceIndexes[0] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[0], false, 1); + _globals._sequenceIndexes[2] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[2], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[0], 14); + _scene->_sequences.setDepth(_globals._sequenceIndexes[2], 14); + _scene->_hotspots.activate(NOUN_DRESSING_GOWN, true); + _scene->_hotspots.activate(NOUN_JULIE, true); + _scene->_hotspots.activateAtPos(NOUN_CHRISTINE, true, Common::Point(220, 130)); + _game._player.walk(Common::Point(175, 128), FACING_NORTHEAST); + _game._player.setWalkTrigger(102); + } else { + _globals._sequenceIndexes[0] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[0], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[0], 14); + + _globals._animationIndexes[2] = _scene->loadAnimation(formAnimName('f', 1), 1); + _florentStatus = 1; + _anim2ActvFl = true; + + _globals._animationIndexes[3] = _scene->loadAnimation(formAnimName('r', 1), 1); + _raoulAction = 3; + _anim3ActvFl = true; + _scene->setAnimFrame(_globals._animationIndexes[3], 33); + + if (_globals[kFlorentNameIsKnown] >= 1) { + _christineHotspotId2 = _scene->_dynamicHotspots.add(NOUN_CHRISTINE, VERB_WALK_TO, SYNTAX_SINGULAR_FEM, EXT_NONE, Common::Rect(43, 118, 43 + 15, 118 + 29)); + _scene->_dynamicHotspots[_christineHotspotId2]._articleNumber = PREP_ON; + _scene->_dynamicHotspots.setPosition(_christineHotspotId2, Common::Point(106, 127), FACING_SOUTHWEST); + } else { + _christineHotspotId2 = _scene->_dynamicHotspots.add(NOUN_WOMAN, VERB_WALK_TO, SYNTAX_FEM_NOT_PROPER, EXT_NONE, Common::Rect(43, 118, 43 + 15, 118 + 29)); + _scene->_dynamicHotspots[_christineHotspotId2]._articleNumber = PREP_ON; + _scene->_dynamicHotspots.setPosition(_christineHotspotId2, Common::Point(106, 127), FACING_SOUTHWEST); + } + + _game._player._playerPos = Common::Point(190, 148); + _game._player._facing = FACING_NORTH; + + _scene->_hotspots.activate(NOUN_DRESSING_GOWN, true); + if (_game._objects.isInRoom(OBJ_SMALL_NOTE)) { + _scene->_hotspots.activate(NOUN_SMALL_NOTE, true); + _globals._sequenceIndexes[1] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[1], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[1], 13); + } + } + } else if ((_globals[kCurrentYear] == 1881) && (! _globals[kChrisKickedRaoulOut])) { + _globals._animationIndexes[1] = _scene->loadAnimation(formAnimName('r', 1), 1); + _raoulAction = 3; + _anim1ActvFl = true; + _scene->setAnimFrame(_globals._animationIndexes[1], 33); + _globals._animationIndexes[0] = _scene->loadAnimation(formAnimName('d', 1), 1); + _dayStatus = 2; + _anim0ActvFl = true; + + _scene->_hotspots.activate(NOUN_CHRISTINE, true); + _scene->_hotspots.activateAtPos(NOUN_CHRISTINE, false, Common::Point(220, 130)); + _scene->_sequences.addTimer(60, 60); + _game._player._playerPos = Common::Point(190, 148); + _game._player._facing = FACING_NORTH; + } else if ((_globals[kCurrentYear] == 1881) && _globals[kChrisKickedRaoulOut]) { + _globals[kChrisKickedRaoulOut] = 2; + _game._player._playerPos = Common::Point(190, 148); + _game._player._facing = FACING_NORTH; + _globals[kCameFromFade] = true; + _game._player._stepEnabled = false; + _globals[kPlayerScore] += 8; + _scene->_sequences.addTimer(60, 110); + } else if (_scene->_priorSceneId == 111) { + _game._player._playerPos = Common::Point(190, 148); + _game._player._facing = FACING_NORTH; + } + + switch (_vm->_gameConv->_restoreRunning) { + case 4: + _vm->_gameConv->run(4); + _vm->_gameConv->exportPointer(&_globals[kPlayerScore]); + break; + + case 6: + _vm->_gameConv->run(6); + break; + + case 13: + _vm->_gameConv->run(13); + _vm->_gameConv->exportPointer(&_globals[kPlayerScore]); + break; + + default: + break; + } + + sceneEntrySound(); +} + +void Scene113::step() { + if (_anim1ActvFl) + handleRaoulAnimation2(); + + if (_anim4ActvFl) + handleJulieAnimation(); + + if (_anim2ActvFl) + handleFlorentAnimation(); + + if (_anim3ActvFl) { + handleRaoulAnimation(); + + if ((!_game._objects.isInInventory(OBJ_SMALL_NOTE)) && (_scene->_animation[_globals._animationIndexes[3]]->getCurrentFrame() == 26)) { + _scene->_hotspots.activate(NOUN_SMALL_NOTE, false); + _game._objects.addToInventory(OBJ_SMALL_NOTE); + _scene->deleteSequence(_globals._sequenceIndexes[1]); + _vm->_sound->command(26); + _vm->_dialogs->showItem(OBJ_SMALL_NOTE, 806, 2); + } + } + + if ((_scene->_animation[_globals._animationIndexes[0]]->getCurrentFrame() == 86) && (!_prevent2)) { + _scene->freeAnimation(_globals._animationIndexes[0]); + _prevent2 = true; + _globals._animationIndexes[0] = _scene->loadAnimation(formAnimName('d', 2), 0); + _scene->setAnimFrame (_globals._animationIndexes[0], 86); + _game.syncTimers(SYNC_ANIM, _globals._animationIndexes[0], SYNC_CLOCK, 0); + _scene->animations_tick(); + } + + if (_anim0ActvFl) { + handleDayAnimation(); + + if ((_scene->_animation[_globals._animationIndexes[0]]->getCurrentFrame() == 95) && (!_armsOutFl)) { + _standingAndTalking = true; + _dayStatus = 7; + _raoulAction = 3; + _armsOutFl = true; + _game.syncTimers(SYNC_ANIM, _globals._animationIndexes[0], SYNC_ANIM, _globals._animationIndexes[1]); + } + + if ((_scene->_animation[_globals._animationIndexes[0]]->getCurrentFrame() == 165) && !_afterKissFl) + _afterKissFl = true; + } + + switch (_game._trigger) { + case 60: + if (!_game._visitedScenes._sceneRevisited) + _vm->_dialogs->show(11342); + break; + + case 102: + _game._player._stepEnabled = true; + _vm->_gameConv->run(6); + break; + + case 108: + _vm->_dialogs->show(11332); + _vm->_dialogs->show(11333); + _scene->_nextSceneId = 150; + _globals[kLeaveAngelMusicOn] = false; + break; + + case 110: + _vm->_dialogs->show(11331); + _game._player.walk(Common::Point(272, 138), FACING_EAST); + _game._player.setWalkTrigger(108); + break; + + default: + break; + } +} + +void Scene113::actions() { + if (_vm->_gameConv->_running == 13) { + handleLoveConversation(); + _action._inProgress = false; + return; + } + + if (_vm->_gameConv->_running == 4) { + handleFlorentConversation(); + _action._inProgress = false; + return; + } + + if (_vm->_gameConv->_running == 6) { + handleDeadConversation(); + _action._inProgress = false; + return; + } + + if ((_action.isAction(VERB_TALK_TO, NOUN_WOMAN)) || (_action.isAction(VERB_TALK_TO, NOUN_CHRISTINE))) { + if (_globals[kCurrentYear] == 1881) { + _game._player._stepEnabled = true; + _vm->_gameConv->run(13); + _vm->_gameConv->exportPointer(&_globals[kPlayerScore]); + } else if (_globals[kDoneBrieConv203]) { + _vm->_dialogs->show(11348); + } else { + _game._player._stepEnabled = true; + _vm->_gameConv->run(4); + _vm->_gameConv->exportPointer(&_globals[kPlayerScore]); + } + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_EXIT_TO, NOUN_CORRIDOR)) { + if (_globals[kDoneBrieConv203] == 1) + _globals[kDoneBrieConv203] = 3; + + _scene->_nextSceneId = 111; + _action._inProgress = false; + return; + } + + if (_action._lookFlag) { + if (_globals[kCurrentYear] == 1993) { + if (_globals[kDoneBrieConv203]) + _vm->_dialogs->show(11340); + else + _vm->_dialogs->show(11310); + } else { + _vm->_dialogs->show(11311); + } + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_LOOK) || _action.isAction(VERB_LOOK_AT)) { + if (_action.isObject(NOUN_FLOOR)) { + _vm->_dialogs->show(11312); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_RUG)) { + _vm->_dialogs->show(11313); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_WALL)) { + _vm->_dialogs->show(11314); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_COUCH)) { + _vm->_dialogs->show(11315); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_MURAL)) { + _vm->_dialogs->show(11316); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_PAINTING)) { + if (_globals[kCurrentYear] == 1881) + _vm->_dialogs->show(11317); + else + _vm->_dialogs->show(11343); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_PAINTING)) { + _vm->_dialogs->show(11317); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_DRESSING_TABLE)) { + _vm->_dialogs->show(11318); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_CHAIR)) { + _vm->_dialogs->show(11319); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_MIRROR)) { + if (_globals[kCurrentYear] == 1993) { + _vm->_dialogs->show(11344); + } else { + _vm->_dialogs->show(11320); + } + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_FAN)) { + _vm->_dialogs->show(11321); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_VASE)) { + _vm->_dialogs->show(11322); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_HAT_RACK)) { + _vm->_dialogs->show(11323); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_LIGHT_FIXTURE)) { + _vm->_dialogs->show(11324); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_CEILING)) { + _vm->_dialogs->show(11325); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_WARDROBE)) { + _vm->_dialogs->show(11326); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_DRESSING_SCREEN)) { + _vm->_dialogs->show(11327); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_CORRIDOR)) { + _vm->_dialogs->show(11328); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_DRESSING_GOWN)) { + _vm->_dialogs->show(11330); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_SMALL_NOTE) && _game._objects.isInRoom(OBJ_SMALL_NOTE)) { + _vm->_dialogs->show(11349); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_CHRISTINE) && _globals[kDoneBrieConv203]) { + _vm->_dialogs->show(11338); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_JULIE)) { + _vm->_dialogs->show(11339); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_NOTICE)) { + _vm->_dialogs->show(11347); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_CLOTHES_DUMMY)) { + if (_globals[kCurrentYear] == 1993) + _vm->_dialogs->show(11345); + else + _vm->_dialogs->show(11346); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_WOMAN) || _action.isObject(NOUN_CHRISTINE)) { + if (_globals[kCurrentYear] == 1993) + _vm->_dialogs->show(11341); + else { + if (_musicPlaying) + _vm->_dialogs->show(11336); + else + _vm->_dialogs->show(11342); + } + _action._inProgress = false; + return; + } + } + + if (_action.isAction(VERB_OPEN, NOUN_WARDROBE)) { + _vm->_dialogs->show(11329); + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_TAKE, NOUN_SMALL_NOTE) && _game._objects.isInRoom(OBJ_SMALL_NOTE)) { + _vm->_dialogs->show(11334); + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_TAKE, NOUN_DRESSING_GOWN)) { + _vm->_dialogs->show(11335); + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_TAKE, NOUN_CHRISTINE) || _action.isAction(VERB_TAKE, NOUN_WOMAN)) { + _vm->_dialogs->show(11337); + _action._inProgress = false; + return; + } +} + +void Scene113::preActions() { + if (_action.isAction(VERB_WALK_UP, NOUN_AISLE)) + _game._player._walkOffScreenSceneId = 101; + + if (_action.isAction(VERB_LOOK, NOUN_MIRROR)) + _game._player.walk(Common::Point(272, 138), FACING_EAST); + + if (! _action.isAction(VERB_EXIT_TO, NOUN_CORRIDOR) && !_globals[kChrisKickedRaoulOut] + && !_action.isAction(VERB_LOOK, NOUN_CHRISTINE) && !_action.isAction(VERB_TAKE, NOUN_CHRISTINE) && _musicPlaying) { + _vm->_gameConv->run(13); + _vm->_gameConv->exportPointer(&_globals[kPlayerScore]); + _game._player.cancelCommand(); + } else if (_action.isAction(VERB_TALK_TO, NOUN_WOMAN) || _action.isAction(VERB_TALK_TO, NOUN_CHRISTINE)) { + _game._player.walk(Common::Point(106, 127), FACING_SOUTHWEST); + } + + if (!_action.isAction(VERB_EXIT_TO, NOUN_CORRIDOR) && !_action.isAction(VERB_LOOK, NOUN_JULIE) + && !_action.isAction(VERB_LOOK, NOUN_CHRISTINE) && !_action._lookFlag && (_globals[kDoneBrieConv203] != 0) + && (_globals[kCurrentYear] == 1993)) { + if (_action.isAction(VERB_TALK_TO, NOUN_CHRISTINE)) { + _game._player._needToWalk = false; + + } else if (_action.isAction(VERB_LOOK)) { + _game._player._needToWalk = false; + + } else if (_action.isAction(VERB_TALK_TO, NOUN_JULIE)) { + _game._player._needToWalk = false; + _vm->_gameConv->run(6); + _game._player.cancelCommand(); + + } else { + _vm->_dialogs->show(11350); + _game._player._needToWalk = false; + _game._player.cancelCommand(); + } + } +} + +void Scene113::handleFlorentAnimation() { + if (_scene->_animation[_globals._animationIndexes[2]]->getCurrentFrame() == _florentFrame) + return; + + int random; + _florentFrame = _scene->_animation[_globals._animationIndexes[2]]->getCurrentFrame(); + int resetFrame = -1; + + switch (_florentFrame) { + case 1: + case 11: + case 23: + case 38: + case 45: + random = _vm->getRandomNumber(4, 30); + + if (_florentStatus == 2) { + random = 1; + } + + if (_florentStatus == 0) { + random = 2; + } + + if (_florentStatus == 3) { + random = 3; + } + + switch (random) { + case 1: + resetFrame = 2; + _florentStatus = 1; + break; + + case 2: + resetFrame = 28; + break; + + case 3: + resetFrame = 39; + break; + + case 4: + resetFrame = 12; + break; + + default: + resetFrame = 0; + break; + } + break; + + case 24: + case 25: + case 26: + case 27: + case 33: + random = _vm->getRandomNumber(5, 20); + + if (_florentStatus == 0) { + random = _vm->getRandomNumber(1, 4); + ++_florentCount; + if (_florentCount > 5) { + _florentStatus = 1; + random = 5; + } + } + + if ((_florentStatus == 2) || + (_florentStatus == 3)) { + random = 5; + } + + switch (random) { + case 1: + resetFrame = 23; + break; + + case 2: + resetFrame = 24; + break; + + case 3: + resetFrame = 25; + break; + + case 4: + resetFrame = 26; + break; + + case 5: + resetFrame = 34; + break; + + default: + resetFrame = 32; + break; + } + break; + + case 42: + if (_florentStatus == 3) + resetFrame = 41; + + break; + } + + if (resetFrame >= 0) { + _scene->setAnimFrame(_globals._animationIndexes[2], resetFrame); + _florentFrame = resetFrame; + } +} + +void Scene113::handleDayAnimation() { + if (_scene->_animation[_globals._animationIndexes[0]]->getCurrentFrame() == _dayFrame) + return; + + _dayFrame = _scene->_animation[_globals._animationIndexes[0]]->getCurrentFrame(); + int random; + int resetFrame = -1; + switch (_dayFrame) { + case 1: + case 4: + case 14: + case 17: + case 20: + case 26: + case 166: + case 206: + case 207: + case 208: + case 209: + case 210: + case 211: + case 219: + case 231: + case 253: + switch (_dayStatus) { + case 0: + random = _vm->getRandomNumber(1, 3); + ++_dayCount; + if (_dayCount < 6) { + if (random == 1) { + resetFrame = 1; + } else if (random == 2) { + resetFrame = 15; + } else { + resetFrame = 18; + } + } else { + _dayStatus = 1; + resetFrame = 25; + _dayWantsToTalk = false; + } + break; + + case 1: + if (_dayWantsToTalk) { + _dayStatus = 0; + _dayWantsToTalk = false; + resetFrame = 1; + } else { + resetFrame = 25; + } + break; + + case 2: + random = _vm->getRandomNumber(1, 50); + switch (random) { + case 1: + resetFrame = 212; + break; + + case 2: + resetFrame = 219; + break; + + case 3: + resetFrame = 231; + break; + + default: + resetFrame = 0; + break; + } + break; + + case 3: + resetFrame = 5; + _dayStatus = 0; + break; + + case 4: + resetFrame = 31; + break; + + case 5: + resetFrame = _vm->getRandomNumber(205, 207); + ++_standCount; + if (_standCount > 18) { + _dayStatus = 7; + resetFrame = 165; + } + if (_musicPlaying) + resetFrame = 167; + break; + + case 6: + resetFrame = _vm->getRandomNumber(208, 210); + while (_lastDayResetFrame == resetFrame) + resetFrame = _vm->getRandomNumber(208, 210); + + _lastDayResetFrame = resetFrame; + + ++_standCount; + if (_standCount > 18) { + _dayStatus = 7; + resetFrame = 165; + } + + if (_musicPlaying) + resetFrame = 167; + break; + + case 7: + resetFrame = 165; + if (_musicPlaying) + resetFrame = 167; + break; + + default: + break; + } + break; + + case 182: + _game._player._visible = true; + _vm->_gameConv->release(); + _game.syncTimers(SYNC_PLAYER, 0, SYNC_ANIM, _globals._animationIndexes[1]); + _game._player._playerPos = Common::Point(175, 148); + _game._player._turnToFacing = FACING_NORTHEAST; + _game._player.resetFacing(FACING_SOUTHEAST); + _game._player._turnToFacing = FACING_NORTHEAST; + break; + + case 205: + case 212: + resetFrame = 211; + break; + + default: + break; + } + + if (resetFrame >= 0) { + _scene->setAnimFrame(_globals._animationIndexes[0], resetFrame); + _dayFrame = resetFrame; + } +} + +void Scene113::handleRaoulAnimation() { + if (_globals[kFlorentNameIsKnown] == 2) + _raoulAction = 3; + + if (_scene->_animation[_globals._animationIndexes[3]]->getCurrentFrame() == _raoulFrame) + return; + + _raoulFrame = _scene->_animation[_globals._animationIndexes[3]]->getCurrentFrame(); + int resetFrame = -1; + + switch (_raoulFrame) { + case 9: + case 10: + case 11: + case 34: + case 33: + if (_raoulFrame == 33) + _vm->_gameConv->release(); + + switch (_raoulAction) { + case 0: + resetFrame = _vm->getRandomNumber(7, 9); + ++_raoulCount; + + if (_raoulCount > 17) { + _raoulAction = 1; + resetFrame = 8; + } + break; + + case 1: + resetFrame = 8; + break; + + case 2: + resetFrame = 11; + break; + + case 3: + resetFrame = 33; + break; + + case 4: + resetFrame = 38; + _raoulStandingFl = true; + _vm->_gameConv->hold(); + break; + + case 5: + resetFrame = 20; + _raoulAction = 1; + break; + + default: + break; + } + break; + + case 19: + if ((_raoulAction == 5) && (!_game._objects.isInInventory(OBJ_SMALL_NOTE))) { + resetFrame = 20; + _raoulAction = 1; + } else if (_raoulAction == 4) { + resetFrame = 38; + _raoulStandingFl = true; + } else if (_raoulAction == 0) { + resetFrame = 9; + } else { + resetFrame = 8; + _raoulAction = 1; + } + break; + + case 42: + if (_raoulAction == 4) { + if (!_prevent2) { + _vm->_gameConv->release(); + } + resetFrame = 33; + _raoulAction = 3; + _game._player._visible = true; + _game.syncTimers(SYNC_PLAYER, 0, SYNC_ANIM, _globals._animationIndexes[3]); + } + break; + + default: + break; + } + + if (resetFrame >= 0) { + _scene->setAnimFrame(_globals._animationIndexes[3], resetFrame); + _raoulFrame = resetFrame; + } +} + +void Scene113::handleRaoulAnimation2() { + if (_scene->_animation[_globals._animationIndexes[1]]->getCurrentFrame() == _raoulFrame) + return; + + _raoulFrame = _scene->_animation[_globals._animationIndexes[1]]->getCurrentFrame(); + int resetFrame = -1; + switch (_raoulFrame) { + case 9: + case 10: + case 11: + case 34: + switch (_raoulAction) { + case 0: + resetFrame = _vm->getRandomNumber(7, 9); + ++_raoulCount; + + if (_raoulCount > 17) { + _raoulAction = 1; + resetFrame = 8; + } + break; + + case 1: + resetFrame = 8; + break; + + case 2: + resetFrame = 11; + break; + + case 3: + resetFrame = 33; + break; + + default: + break; + } + break; + + case 19: + if (_raoulAction == 0) + resetFrame = 9; + else { + resetFrame = 8; + _raoulAction = 1; + } + break; + + default: + break; + } + + if (resetFrame >= 0) { + _scene->setAnimFrame(_globals._animationIndexes[1], resetFrame); + _raoulFrame = resetFrame; + } +} + +void Scene113::handleJulieAnimation() { + if (_scene->_animation[_globals._animationIndexes[4]]->getCurrentFrame() == _julieFrame) + return; + + _julieFrame = _scene->_animation[_globals._animationIndexes[4]]->getCurrentFrame(); + int resetFrame = -1; + int random; + + switch (_julieFrame) { + case 1: + case 2: + case 3: + case 11: + case 16: + case 17: + switch (_julieStatus) { + case 0: + random = _vm->getRandomNumber(4, 20); + break; + + case 1: + random = _vm->getRandomNumber(1, 3); + ++_julieCount; + if (_julieCount > 20) { + _julieStatus = 0; + random = 6; + } + break; + + default: + random = -1; + break; + } + + switch (random) { + case 1: + resetFrame = 0; + break; + + case 2: + resetFrame = 1; + break; + + case 3: + resetFrame = 2; + break; + + case 4: + resetFrame = 12; + break; + + case 5: + resetFrame = 4; + break; + + default: + resetFrame = 16; + break; + } + break; + } + + if (resetFrame >= 0) { + _scene->setAnimFrame(_globals._animationIndexes[4], resetFrame); + _julieFrame = resetFrame; + } +} + +void Scene113::handleDeadConversation() { + switch (_game._trigger) { + case 106: + _julieStatus = 1; + break; + + case 104: + _julieStatus = 0; + break; + + default: + break; + } + + _vm->_gameConv->setInterlocutorTrigger(106); + _vm->_gameConv->setHeroTrigger(104); + + _julieCount = 0; +} + +void Scene113::handleFlorentConversation() { + int random; + + switch (_action._activeAction._verbId) { + case 3: + case 4: + if (!_prevent1) { + _globals[kFlorentNameIsKnown] = 1; + _vm->_gameConv->setInterlocutorTrigger(82); + _scene->_dynamicHotspots.remove(_christineHotspotId2); + _christineHotspotId2 = _scene->_dynamicHotspots.add(NOUN_CHRISTINE, VERB_WALK_TO, SYNTAX_SINGULAR_FEM, EXT_NONE, Common::Rect(43, 118, 43 + 15, 118 + 29)); + _scene->_dynamicHotspots[_christineHotspotId2]._articleNumber = PREP_ON; + _scene->_dynamicHotspots.setPosition(_christineHotspotId2, Common::Point(106, 127), FACING_SOUTHWEST); + _prevent1 = true; + } + break; + + case 19: + _florentStatus = 2; + _vm->_gameConv->setInterlocutorTrigger(86); + break; + + case 25: + if (_raoulAction != 3) + _raoulAction = 4; + break; + + case 26: + if (!_prevent2) { + _scene->_sequences.addTimer(120, 92); + _vm->_gameConv->setInterlocutorTrigger(96); + _florentStatus = 0; + _prevent2 = true; + } + break; + + case 27: + case 30: + _vm->_gameConv->setInterlocutorTrigger(98); + break; + + case 28: + case 29: + _vm->_gameConv->setInterlocutorTrigger(100); + break; + + default: + break; + } + + switch (_game._trigger) { + case 62: + if ((_action._activeAction._verbId != 3) && (_action._activeAction._verbId != 4) && (_action._activeAction._verbId != 19) && + (_action._activeAction._verbId != 27) && (_action._activeAction._verbId != 28) && (_action._activeAction._verbId != 29)) { + if ((_raoulAction != 5) && (_raoulAction != 4) && !_raoulStandingFl) + _raoulAction = 0; + + if ((_florentStatus != 3) && (_florentStatus != 2)) + _florentStatus = 1; + } + break; + + case 66: + if ((_florentStatus != 3) && + (_florentStatus != 2)) { + random = _vm->getRandomNumber(1,5); + if (random == 1) + _florentStatus = 0; + } + + if ((_raoulAction != 3) && (_raoulAction != 5) && (_raoulAction != 4) && (!_raoulStandingFl)) { + _raoulAction = 1; + random = _vm->getRandomNumber(1, 2); + if (random == 1) + _raoulAction = 2; + } + break; + + case 80: + _vm->_gameConv->release(); + _game._player._visible = false; + _raoulAction = 1; + _game.syncTimers(SYNC_ANIM, _globals._animationIndexes[3], SYNC_PLAYER, 0); + _scene->setAnimFrame(_globals._animationIndexes[3], 1); + break; + + case 82: + _florentStatus = 0; + _scene->_sequences.addTimer(120, 84); + _vm->_gameConv->hold(); + break; + + case 84: + _game._player.walk(Common::Point(201, 120), FACING_SOUTH); + _game._player.setWalkTrigger(80); + break; + + case 86: + _raoulAction = 5; + _vm->_gameConv->hold(); + break; + + case 92: + _game._player.walk(Common::Point(68, 142), FACING_SOUTHWEST); + _game._player.setWalkTrigger(94); + break; + + case 94: + _globals[kStopWalkerDisabled] = true; + _globals[kFlorentNameIsKnown] = 2; + _vm->_gameConv->release(); + break; + + case 96: + _vm->_gameConv->hold(); + break; + + case 98: + _florentStatus = 3; + break; + + case 100: + _florentStatus = 1; + _globals[kStopWalkerDisabled] = false; + break; + + default: + break; + } + + if ((_action._activeAction._verbId != 3) && (_action._activeAction._verbId != 4) && (_action._activeAction._verbId != 19) && + (_action._activeAction._verbId != 28) && (_action._activeAction._verbId != 29) && (_action._activeAction._verbId != 27) && + (_action._activeAction._verbId != 30) && (_action._activeAction._verbId != 26)) + _vm->_gameConv->setInterlocutorTrigger(66); + + _vm->_gameConv->setHeroTrigger(62); + _raoulCount = 0; + _florentCount = 0; +} + +void Scene113::handleLoveConversation() { + int random; + + switch (_action._activeAction._verbId) { + case 1: + case 2: + if (!_prevent1) { + _vm->_gameConv->setInterlocutorTrigger(82); + _prevent1 = true; + } + break; + + case 21: + if (!_armsOutFl) { + _dayStatus = 4; + _scene->_sequences.addTimer(1, 70); + _scene->_userInterface.emptyConversationList(); + _scene->_userInterface.setup(kInputConversation); + _scene->_hotspots.activate(NOUN_CHRISTINE, false); + _vm->_gameConv->hold(); + } + break; + + case 27: + _vm->_sound->command(34); + _globals[kLeaveAngelMusicOn] = true; + break; + + case 31: + if (!_musicPlaying) { + _vm->_gameConv->hold(); + _dayStatus = 7; + _musicPlaying = true; + _christineHotspotId1 = _scene->_dynamicHotspots.add(NOUN_CHRISTINE, VERB_WALK_TO, SYNTAX_SINGULAR_FEM, EXT_NONE, Common::Rect(0, 0, 0, 0)); + _scene->_dynamicHotspots[_christineHotspotId1]._articleNumber = PREP_ON; + _scene->setDynamicAnim(_christineHotspotId1, _globals._animationIndexes[0], 14); + _scene->setDynamicAnim(_christineHotspotId1, _globals._animationIndexes[0], 16); + } + break; + } + + switch (_game._trigger) { + case 62: + if (_action._activeAction._verbId != 0) { + if (_standingAndTalking) { + _dayStatus = 6; + } else if (_dayStatus != 4) { + _dayStatus = 1; + _raoulAction = 0; + _dayWantsToTalk = false; + } + } + break; + + case 66: + if (_standingAndTalking) { + _dayStatus = 5; + + } else { + if (_action._activeAction._verbId == 19) { + _dayStatus = 3; + } else { + _dayStatus = 1; + _dayWantsToTalk = true; + } + + if (_raoulAction != 3) { + _raoulAction = 1; + random = _vm->getRandomNumber(1, 2); + if (random == 1) { + _raoulAction = 2; + } + } + } + break; + + case 70: + if (_armsOutFl) { + _vm->_gameConv->release(); + _vm->_gameConv->setInterlocutorTrigger(76); + } + break; + + case 72: + if (_afterKissFl) + _vm->_gameConv->release(); + else + _scene->_sequences.addTimer(1, 72); + break; + + case 76: + _vm->_gameConv->hold(); + _scene->_sequences.addTimer(1, 72); + break; + + case 78: + if (_armsOutFl) { + _vm->_gameConv->release(); + _vm->_gameConv->setInterlocutorTrigger(76); + } + break; + + case 80: + _vm->_gameConv->release(); + _game._player._visible = false; + _raoulAction = 1; + _game.syncTimers(SYNC_ANIM, _globals._animationIndexes[1], SYNC_PLAYER, 0); + _scene->setAnimFrame(_globals._animationIndexes[1], 1); + break; + + case 82: + _scene->_sequences.addTimer(120, 84); + _vm->_gameConv->hold(); + _dayStatus = 1; + _dayWantsToTalk = true; + break; + + case 84: + _game._player.walk(Common::Point(201, 120), FACING_SOUTH); + _game._player.setWalkTrigger(80); + break; + + default: + break; + } + + if ((_action._activeAction._verbId != 21) && (_action._activeAction._verbId != 1) && (_action._activeAction._verbId != 2)) + _vm->_gameConv->setInterlocutorTrigger(66); + + _vm->_gameConv->setHeroTrigger(62); + + _raoulCount = 0; + _dayCount = 0; + _standCount = 0; +} + +/*------------------------------------------------------------------------*/ + +Scene114::Scene114(MADSEngine *vm) : Scene1xx(vm) { +} + +void Scene114::synchronize(Common::Serializer &s) { + Scene1xx::synchronize(s); +} + +void Scene114::setup() { + if (_globals[kCurrentYear] == 1993) + _scene->_variant = 1; + + setPlayerSpritesPrefix(); + setAAName(); +} + +void Scene114::enter() { + if (_globals[kCurrentYear] == 1993) { + _globals._spriteIndexes[0] = _scene->_sprites.addSprites(formAnimName('z', -1)); + } else if (_game._objects.isInRoom(OBJ_ROPE) && !_game._objects.isInInventory(OBJ_ROPE_WITH_HOOK)) { + _globals._spriteIndexes[2] = _scene->_sprites.addSprites(formAnimName('f', 0)); + _globals._spriteIndexes[1] = _scene->_sprites.addSprites("*RDR_9"); + } + + _globals._spriteIndexes[3] = _scene->_sprites.addSprites(formAnimName('a', 0)); + + if ((_game._objects.isInRoom(OBJ_ROPE)) && (_globals[kCurrentYear] == 1881) && !_game._objects.isInInventory(OBJ_ROPE_WITH_HOOK)) { + _globals._sequenceIndexes[2] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[2], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[2], 2); + } else + _scene->_hotspots.activate(NOUN_ROPE, false); + + if (_globals[kCurrentYear] == 1993) { + _scene->_hotspots.activate(NOUN_CYLINDER, false); + _scene->_hotspots.activate(NOUN_MANNEQUINS, false); + _scene->_hotspots.activate(NOUN_PROP, false); + _scene->_hotspots.activate(NOUN_BUST, false); + _scene->_hotspots.activate(NOUN_SCAFFOLDING, false); + _scene->drawToBackground(_globals._spriteIndexes[0], 1, Common::Point(-32000, -32000), 0, 100); + } else { + _scene->_hotspots.activate(NOUN_BOXES, false); + _scene->_hotspots.activate(NOUN_DINETTE_SET, false); + _scene->_hotspots.activate(NOUN_CRATE, false); + _scene->_hotspots.activate(NOUN_CASES, false); + } + + if ((_scene->_priorSceneId == 105) || (_scene->_priorSceneId != RETURNING_FROM_LOADING)) { + _game._player._playerPos = Common::Point(218, 123); + _game._player._facing = FACING_WEST; + } + + sceneEntrySound(); +} + +void Scene114::step() { +} + +void Scene114::actions() { + if (_action.isAction(VERB_CLIMB_UP, NOUN_CIRCULAR_STAIRCASE)) { + switch (_game._trigger) { + case 0: + _game._player._stepEnabled = false; + _game._player._visible = false; + _globals._animationIndexes[0] = _scene->loadAnimation(formAnimName('u', 1), 1); + _game.syncTimers(SYNC_ANIM, _globals._animationIndexes[0], SYNC_PLAYER, 0); + break; + + case 1: + _scene->_nextSceneId = 105; + break; + + default: + break; + } + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_CLIMB_UP, NOUN_CIRCULAR_STAIRCASE)) { + _scene->_nextSceneId = 105; + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_TAKE, NOUN_ROPE) && (_game._objects.isInRoom(OBJ_ROPE) || _game._trigger)) { + switch (_game._trigger) { + case (0): + _globals[kPlayerScore] += 5; + _game._player._stepEnabled = false; + _game._player._visible = false; + _globals._sequenceIndexes[1] = _scene->_sequences.startPingPongCycle(_globals._spriteIndexes[1], false, 6, 2); + _scene->_sequences.setAnimRange(_globals._sequenceIndexes[1], 1, 3); + _scene->_sequences.setSeqPlayer(_globals._sequenceIndexes[1], true); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[1], SEQUENCE_TRIGGER_SPRITE, 3, 1); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[1], SEQUENCE_TRIGGER_EXPIRE, 0, 2); + break; + + case 1: + _scene->deleteSequence(_globals._sequenceIndexes[2]); + _scene->_hotspots.activate(NOUN_ROPE, false); + _game._objects.addToInventory(OBJ_ROPE); + _vm->_sound->command(26); + break; + + case 2: + _game.syncTimers(SYNC_PLAYER, 0, SYNC_SEQ, _globals._sequenceIndexes[1]); + _game._player._visible = true; + _scene->_sequences.addTimer(20, 3); + break; + + case 3: + _vm->_dialogs->showItem(OBJ_ROPE, 807, 0); + _game._player._stepEnabled = true; + break; + + default: + break; + } + _action._inProgress = false; + return; + } + + if (_action._lookFlag) { + _vm->_dialogs->show(11410); + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_LOOK) || _action.isAction(VERB_LOOK_AT)) { + if (_action.isObject(NOUN_FLOOR)) { + _vm->_dialogs->show(11411); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_CIRCULAR_STAIRCASE)) { + _vm->_dialogs->show(11412); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_ROPE) && _game._objects.isInRoom(OBJ_ROPE)) { + _vm->_dialogs->show(11413); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_WALL)) { + _vm->_dialogs->show(11414); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_MANNEQUINS)) { + _vm->_dialogs->show(11415); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_FLAT)) { + _vm->_dialogs->show(11416); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_SCAFFOLDING)) { + _vm->_dialogs->show(11417); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_MUMMY_PROP)) { + if (_globals[kCurrentYear] == 1993) + _vm->_dialogs->show(11418); + else + _vm->_dialogs->show(11433); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_CRATES)) { + if (_globals[kCurrentYear] == 1993) + _vm->_dialogs->show(11419); + else + _vm->_dialogs->show(11434); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_CRATE)) { + if (_globals[kCurrentYear] == 1993) + _vm->_dialogs->show(11420); + else + _vm->_dialogs->show(11435); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_CARTONS)) { + if (_globals[kCurrentYear] == 1993) + _vm->_dialogs->show(11421); + else + _vm->_dialogs->show(11436); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_CARTON)) { + if (_globals[kCurrentYear] == 1993) + _vm->_dialogs->show(11422); + else + _vm->_dialogs->show(11437); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_PROP)) { + _vm->_dialogs->show(11423); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_BUST)) { + _vm->_dialogs->show(11424); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_MUG)) { + _vm->_dialogs->show(11425); + _action._inProgress = false; + return; + } + + if ((_action.isObject(NOUN_CASES)) || (_action.isObject(NOUN_CASE))) { + _vm->_dialogs->show(11426); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_BOXES) || _action.isObject(NOUN_BOX)) { + if (_globals[kCurrentYear] == 1993) + _vm->_dialogs->show(11427); + else + _vm->_dialogs->show(11439); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_BOX)) { + if (_globals[kCurrentYear] == 1881) { + _vm->_dialogs->show(11439); + _action._inProgress = false; + return; + } + } + + if (_action.isObject(NOUN_DINETTE_SET)) { + _vm->_dialogs->show(11428); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_CYLINDER)) { + _vm->_dialogs->show(11429); + _action._inProgress = false; + return; + } + } + + if (_action.isAction(VERB_OPEN, NOUN_CARTONS)) { + if (_globals[kCurrentYear] == 1993) + _vm->_dialogs->show(11421); + else + _vm->_dialogs->show(11436); + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_OPEN, NOUN_CARTON)) { + if (_globals[kCurrentYear] == 1993) + _vm->_dialogs->show(11422); + else + _vm->_dialogs->show(11437); + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_OPEN, NOUN_CRATES)) { + if (_globals[kCurrentYear] == 1993) + _vm->_dialogs->show(11419); + else + _vm->_dialogs->show(11434); + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_OPEN, NOUN_CRATE)) { + if (_globals[kCurrentYear] == 1993) + _vm->_dialogs->show(11419); + else + _vm->_dialogs->show(11435); + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_OPEN, NOUN_CASES)) { + _vm->_dialogs->show(11426); + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_OPEN, NOUN_BOXES) || _action.isAction(VERB_OPEN, NOUN_BOX)) { + if (_globals[kCurrentYear] == 1993) + _vm->_dialogs->show(11427); + else + _vm->_dialogs->show(11439); + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_TAKE, NOUN_MUG)) { + _vm->_dialogs->show(11430); + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_OPEN, NOUN_MUMMY_PROP)) { + _vm->_dialogs->show(11431); + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_TALK_TO, NOUN_MUMMY_PROP)) { + _vm->_dialogs->show(11432); + _action._inProgress = false; + return; + } +} + +void Scene114::preActions() { +} + +/*------------------------------------------------------------------------*/ + +Scene150::Scene150(MADSEngine *vm) : Scene1xx(vm) { +} + +void Scene150::synchronize(Common::Serializer &s) { + Scene1xx::synchronize(s); +} + +void Scene150::setup() { + setPlayerSpritesPrefix(); + setAAName(); +} + +void Scene150::enter() { + warning("TODO: Switch to letter box view. See definition of MADS_MENU_Y"); + + _game._player._stepEnabled = false; + _game._player._visible = false; + + if (_scene->_priorSceneId == 113) + _globals._animationIndexes[0] = _scene->loadAnimation(formAnimName('l', 1), 1); + else if (_scene->_priorSceneId == 203) { + _globals._animationIndexes[0] = _scene->loadAnimation(formAnimName('f', 1), 2); + sceneEntrySound(); + } else if (_scene->_priorSceneId == 306) + _globals._animationIndexes[0] = _scene->loadAnimation(formAnimName('e', 1), 4); + else if (_scene->_priorSceneId == 208) + _globals._animationIndexes[0] = _scene->loadAnimation(formAnimName('h', 1), 3); + else + _globals._animationIndexes[0] = _scene->loadAnimation(formAnimName('q', 1), 5); +} + +void Scene150::step() { + if (_game._trigger == 1) + _scene->_nextSceneId = 203; + + if (_game._trigger == 2) + _scene->_nextSceneId = 111; + + if (_game._trigger == 4) + _scene->_nextSceneId = 204; + + if (_game._trigger == 3) { + _globals[kJacquesStatus] = 1; + _scene->_nextSceneId = 205; + } + + if (_game._trigger == 5) + _game._winStatus = 1; + + if (_scene->_nextSceneId != _scene->_currentSceneId) { + byte pal[768]; + _vm->_palette->getFullPalette(pal); + Common::fill(&pal[12], &pal[756], 0); + _vm->_palette->setFullPalette(pal); + } +} + +void Scene150::actions() { +} + +void Scene150::preActions() { +} /*------------------------------------------------------------------------*/ diff --git a/engines/mads/phantom/phantom_scenes1.h b/engines/mads/phantom/phantom_scenes1.h index 0f5f56a4cf..d1be6e027e 100644 --- a/engines/mads/phantom/phantom_scenes1.h +++ b/engines/mads/phantom/phantom_scenes1.h @@ -55,8 +55,20 @@ public: class Scene101 : public Scene1xx { private: - // TODO - + int _chanStatus; + int _wipeStatus; + int _callingStatus; + int _chandelierStatus; + int _callingFrame; + int _chandelierFrame; + int _talkCounter; + int _convCounter; + int _brieAnimId; + bool _startWalkingFl; + bool _startWalking0Fl; + bool _anim0Running; + bool _anim1Running; + bool _startSittingFl; public: Scene101(MADSEngine *vm); virtual void synchronize(Common::Serializer &s); @@ -66,11 +78,16 @@ public: virtual void step(); virtual void preActions(); virtual void actions(); + + void handleConversation0(); + void handleConversation1(); + void handleAnimation0(); + void handleAnimation1(); }; class Scene102 : public Scene1xx { private: - bool _animRunningFl; + bool _anim0Running; public: Scene102(MADSEngine *vm); @@ -83,6 +100,320 @@ public: virtual void actions(); }; +class Scene103 : public Scene1xx { +private: + int _jacquesAction; + int _lastRandom; + int _standPosition; + int _hotspotPrompt1; + int _hotspotPrompt2; + int _hotspotPrompt3; + int _hotspotPrompt4; + int _hotspotPrompt5; + int _hotspotRightFloor1; + int _hotspotRightFloor2; + int _hotspotLeftFloor1; + int _hotspotLeftFloor2; + int _hotspotGentleman; + int _convCount; + int _lastStairFrame; + int _lastJacquesFrame; + int _talkCount; + + bool _anim0ActvFl; + bool _anim1ActvFl; + bool _anim2ActvFl; + bool _anim3ActvFl; + bool _anim4ActvFl; + bool _anim5ActvFl; + bool _anim6ActvFl; + bool _climbThroughTrapFl; + bool _guardFrameFl; + bool _sitFl; + + void adjustRails(int variant); + void handleJacquesAnim(); + void climbRightStairs(); + void climbLeftStairs(); + void descendRightStairs(); + void descendLeftStairs(); + void process_conv_jacques(); + +public: + Scene103(MADSEngine *vm); + virtual void synchronize(Common::Serializer &s); + + virtual void setup(); + virtual void enter(); + virtual void step(); + virtual void preActions(); + virtual void actions(); +}; + +class Scene104 : public Scene1xx { +private: + bool _anim0ActvFl; + bool _anim1ActvFl; + bool _anim2ActvFl; + bool _needToGetUp; + bool _needToStandUp; + bool _needToTalk; + bool _sittingUp; + bool _beforeSheLeaves; + bool _beforeHeLeaves; + + int _walkStatus; + int _walkFrame; + int _coupleStatus; + int _coupleFrame; + int _richStatus; + int _richFrame; + int _manTalkCount; + int _womanTalkCount; + int _lookCount; + int _richTalkCount; + int _lastPlayerFrame; + + void cleanInventory(); + void processConversations(); + void handleWalkAnimation(); + void handleCoupleAnimations(); + void handleRichAnimations(); + void handlePlayerWalk(); + +public: + Scene104(MADSEngine *vm); + virtual void synchronize(Common::Serializer &s); + + virtual void setup(); + virtual void enter(); + virtual void step(); + virtual void preActions(); + virtual void actions(); +}; + +class Scene105 : public Scene1xx { +public: + Scene105(MADSEngine *vm); + virtual void synchronize(Common::Serializer &s); + + virtual void setup(); + virtual void enter(); + virtual void step(); + virtual void preActions(); + virtual void actions(); +}; + +class Scene106 : public Scene1xx { +private: + int _sandbagHostpotId; +public: + Scene106(MADSEngine *vm); + virtual void synchronize(Common::Serializer &s); + + virtual void setup(); + virtual void enter(); + virtual void step(); + virtual void preActions(); + virtual void actions(); +}; + +class Scene107 : public Scene1xx { +public: + Scene107(MADSEngine *vm); + virtual void synchronize(Common::Serializer &s); + + virtual void setup(); + virtual void enter(); + virtual void step(); + virtual void preActions(); + virtual void actions(); +}; + +class Scene108 : public Scene1xx { +private: + bool _anim0ActvFl; + bool _handRaisedFl; + int _shutUpCount; + int _maxTalkCount; + int _charAction; + int _charFrame; + int _charTalkCount; + int _charHotspotId; + int _conversationCount; + int _prevShutUpFrame; + + void handleCharAnimation(); + void handleCharlesConversation(); + +public: + Scene108(MADSEngine *vm); + virtual void synchronize(Common::Serializer &s); + + virtual void setup(); + virtual void enter(); + virtual void step(); + virtual void preActions(); + virtual void actions(); +}; + +class Scene109 : public Scene1xx { +private: + bool _anim0ActvFl; + bool _anim1ActvFl; + bool _anim2ActvFl; + bool _anim3ActvFl; + int _currentFloor; +public: + Scene109(MADSEngine *vm); + virtual void synchronize(Common::Serializer &s); + + virtual void setup(); + virtual void enter(); + virtual void step(); + virtual void preActions(); + virtual void actions(); +}; + +class Scene110 : public Scene1xx { +public: + Scene110(MADSEngine *vm); + virtual void synchronize(Common::Serializer &s); + + virtual void setup(); + virtual void enter(); + virtual void step(); + virtual void preActions(); + virtual void actions(); +}; + +class Scene111 : public Scene1xx { +private: + bool _removeAxe; + bool _anim0ActvFl; + bool _anim1ActvFl; + bool _closedFl; + int _listenFrame; + int _listenStatus; + + void handleListenAnimation(); + void handleListenConversation(); + +public: + Scene111(MADSEngine *vm); + virtual void synchronize(Common::Serializer &s); + + virtual void setup(); + virtual void enter(); + virtual void step(); + virtual void preActions(); + virtual void actions(); +}; + +class Scene112 : public Scene1xx { +private: + bool _anim0ActvFl; + bool _anim1ActvFl; + + int _raoulAction; + int _raoulFrame; + int _didOptionFl; + int _julieFrame; + int _julieAction; + int _julieCounter; + int _julieHotspotId; + + void handleConversation(); + void handleJulieAnimation(); + void handleRaoulChair(); + +public: + Scene112(MADSEngine *vm); + virtual void synchronize(Common::Serializer &s); + + virtual void setup(); + virtual void enter(); + virtual void step(); + virtual void preActions(); + virtual void actions(); +}; + +class Scene113 : public Scene1xx { +private: + bool _standingAndTalking; + bool _dayWantsToTalk; + bool _musicPlaying; + bool _afterKissFl; + bool _anim0ActvFl; + bool _anim1ActvFl; + bool _anim2ActvFl; + bool _anim3ActvFl; + bool _anim4ActvFl; + bool _prevent1; + bool _prevent2; + bool _raoulStandingFl; + bool _armsOutFl; + + int _christineHotspotId1; + int _christineHotspotId2; + int _dayStatus; + int _dayFrame; + int _dayCount; + int _florentStatus; + int _florentFrame; + int _florentCount; + int _julieStatus; + int _julieFrame; + int _julieCount; + int _raoulAction; + int _raoulFrame; + int _raoulCount; + int _lastDayResetFrame; + int _standCount; + + void handleFlorentAnimation(); + void handleDayAnimation(); + void handleRaoulAnimation(); + void handleRaoulAnimation2(); + void handleJulieAnimation(); + void handleDeadConversation(); + void handleFlorentConversation(); + void handleLoveConversation(); + +public: + Scene113(MADSEngine *vm); + virtual void synchronize(Common::Serializer &s); + + virtual void setup(); + virtual void enter(); + virtual void step(); + virtual void preActions(); + virtual void actions(); +}; + +class Scene114 : public Scene1xx { +public: + Scene114(MADSEngine *vm); + virtual void synchronize(Common::Serializer &s); + + virtual void setup(); + virtual void enter(); + virtual void step(); + virtual void preActions(); + virtual void actions(); +}; + +class Scene150 : public Scene1xx { +public: + Scene150(MADSEngine *vm); + virtual void synchronize(Common::Serializer &s); + + virtual void setup(); + virtual void enter(); + virtual void step(); + virtual void preActions(); + virtual void actions(); +}; } // End of namespace Phantom } // End of namespace MADS diff --git a/engines/mads/phantom/phantom_scenes2.cpp b/engines/mads/phantom/phantom_scenes2.cpp new file mode 100644 index 0000000000..1590d06549 --- /dev/null +++ b/engines/mads/phantom/phantom_scenes2.cpp @@ -0,0 +1,7001 @@ +/* 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/scummsys.h" +#include "mads/mads.h" +#include "mads/conversations.h" +#include "mads/scene.h" +#include "mads/phantom/phantom_scenes.h" +#include "mads/phantom/phantom_scenes2.h" + +namespace MADS { + +namespace Phantom { + +void Scene2xx::setAAName() { + _game._aaName = Resources::formatAAName(_globals[kTempInterface]); + _vm->_palette->setEntry(254, 43, 47, 51); +} + +void Scene2xx::sceneEntrySound() { + if (!_vm->_musicFlag) + return; + + switch (_scene->_nextSceneId) { + case 206: + if (!_globals[kKnockedOverHead]) + _vm->_sound->command(16); + break; + + case 208: + _vm->_sound->command(34); + break; + + default: + if (_scene->_nextSceneId != 250) + _vm->_sound->command(16); + break; + } +} + +void Scene2xx::setPlayerSpritesPrefix() { + _vm->_sound->command(5); + + if (_scene->_nextSceneId == 208) + _game._player._spritesPrefix = ""; + else { + Common::String oldName = _game._player._spritesPrefix; + if (!_game._player._forcePrefix) + _game._player._spritesPrefix = "RAL"; + if (oldName != _game._player._spritesPrefix) + _game._player._spritesChanged = true; + } + + _game._player._scalingVelocity = true; +} + +/*------------------------------------------------------------------------*/ + +Scene201::Scene201(MADSEngine *vm) : Scene2xx(vm) { + _anim0ActvFl = false; + _anim1ActvFl = false; + _needHoldFl = false; + _sellerCount = -1; + _sellerStatus = -1; + _sellerFrame = -1; + _raoulFrame = -1; + _raoulStatus = -1; +} + +void Scene201::synchronize(Common::Serializer &s) { + Scene2xx::synchronize(s); + + s.syncAsByte(_anim0ActvFl); + s.syncAsByte(_anim1ActvFl); + s.syncAsByte(_needHoldFl); + s.syncAsSint16LE(_sellerCount); + s.syncAsSint16LE(_sellerStatus); + s.syncAsSint16LE(_sellerFrame); + s.syncAsSint16LE(_raoulFrame); + s.syncAsSint16LE(_raoulStatus); +} + +void Scene201::setup() { + setPlayerSpritesPrefix(); + setAAName(); +} + +void Scene201::enter() { + if (_scene->_priorSceneId != RETURNING_FROM_LOADING) { + _anim0ActvFl = false; + _anim1ActvFl = false; + } + + _sellerCount = 0; + _needHoldFl = false; + + _vm->_gameConv->get(16); + _globals._spriteIndexes[0] = _scene->_sprites.addSprites(formAnimName('x', 0)); + _globals._spriteIndexes[1] = _scene->_sprites.addSprites(formAnimName('f', 0)); + + if (_globals[kTicketPeoplePresent]) { + _globals._animationIndexes[1] = _scene->loadAnimation(formAnimName('s', 1), 0); + _anim1ActvFl = true; + _sellerStatus = 2; + _scene->setAnimFrame(_globals._animationIndexes[1], 5); + } else { + _scene->_hotspots.activate(NOUN_TICKET_SELLER, false); + _globals._sequenceIndexes[0] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[0], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[0], 14); + } + + if (_vm->_gameConv->_restoreRunning == 16) { + _game._player._playerPos = Common::Point(72, 101); + _game._player._facing = FACING_NORTHWEST; + _globals._animationIndexes[0] = _scene->loadAnimation(formAnimName('r', 1), 0); + _anim0ActvFl = true; + _raoulStatus = 1; + _game._player._visible = false; + + _vm->_gameConv->run(16); + _vm->_gameConv->exportPointer(&_globals[kPlayerScore]); + _vm->_gameConv->exportPointer(&_globals[kChristineToldEnvelope]); + } + + if ((_scene->_priorSceneId == 202) || (_scene->_priorSceneId != RETURNING_FROM_LOADING)) { + _game._player._playerPos = Common::Point(314, 86); + _game._player.walk(Common::Point(266, 98), FACING_SOUTHWEST); + } + + sceneEntrySound(); +} + +void Scene201::step() { + if (_anim0ActvFl) + handleRaoulAnimation(); + + if (_anim1ActvFl) + handleSellerAnimation(); + + if ((_needHoldFl) && (_vm->_gameConv->_running != 16)) { + _game._player._stepEnabled = false; + _needHoldFl = false; + } +} + +void Scene201::actions() { + if (_vm->_gameConv->_running == 16) { + handleConversation(); + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_WALK_THROUGH, NOUN_ARCHWAY)) { + _scene->_nextSceneId = 202; + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_TALK_TO, NOUN_TICKET_SELLER)) { + _globals._animationIndexes[0] = _scene->loadAnimation(formAnimName('r', 1), 0); + _anim0ActvFl = true; + _raoulStatus = 1; + _vm->_gameConv->run(16); + _vm->_gameConv->exportPointer(&_globals[kPlayerScore]); + _vm->_gameConv->exportPointer(&_globals[kChristineToldEnvelope]); + _game._player._visible = false; + _action._inProgress = false; + return; + } + + if (_action._lookFlag) { + if (_globals[kCurrentYear] == 1993) + _vm->_dialogs->show(20110); + else + _vm->_dialogs->show(20111); + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_LOOK) || _action.isAction(VERB_LOOK_AT)) { + if (_action.isObject(NOUN_FLOOR)) { + _vm->_dialogs->show(20112); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_WALL)) { + _vm->_dialogs->show(20113); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_BUST)) { + _vm->_dialogs->show(20114); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_PEDESTAL)) { + _vm->_dialogs->show(20115); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_BARRIER)) { + _vm->_dialogs->show(20116); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_PLACARD)) { + if (_globals[kCurrentYear] == 1993) + _vm->_dialogs->show(20117); + else + _vm->_dialogs->show(20118); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_TICKET_WINDOW)) { + if (_globals[kCurrentYear] == 1993) + _vm->_dialogs->show(20119); + else + _vm->_dialogs->show(20120); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_ARCHWAY)) { + _vm->_dialogs->show(20121); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_TICKET_SELLER)) { + _vm->_dialogs->show(20123); + _action._inProgress = false; + return; + } + } + + if (_action.isAction(VERB_TAKE, NOUN_TICKET_SELLER)) { + _vm->_dialogs->show(20124); + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_TALK_TO, NOUN_BUST)) { + _vm->_dialogs->show(20122); + _action._inProgress = false; + return; + } +} + +void Scene201::preActions() { + if ((_action.isAction(VERB_LOOK) || _action.isAction(VERB_LOOK_AT)) && _action.isObject(NOUN_PLACARD)) + _game._player.walk(Common::Point(147, 104), FACING_NORTHWEST); +} + +void Scene201::handleRaoulAnimation() { + if (_scene->_animation[_globals._animationIndexes[0]]->getCurrentFrame() == _raoulFrame) + return; + + _raoulFrame = _scene->_animation[_globals._animationIndexes[0]]->getCurrentFrame(); + int random = -1; + int resetFrame = -1; + + switch (_raoulFrame) { + case 1: + case 19: + case 49: + random = _vm->getRandomNumber(4, 50); + + switch (_raoulStatus) { + case 0: + random = 1; + break; + + case 2: + random = 2; + _game._player._stepEnabled = false; + break; + + case 3: + random = 3; + break; + } + + switch (random) { + case 1: + resetFrame = 9; + _raoulStatus = 1; + break; + + case 2: + resetFrame = 1; + break; + + case 3: + _game._player._visible = true; + _sellerStatus = 2; + _anim0ActvFl = false; + resetFrame = 49; + _game._player._stepEnabled = true; + _needHoldFl = false; + break; + + case 4: + resetFrame = 19; + break; + + default: + resetFrame = 0; + break; + + } + break; + + case 5: + _scene->deleteSequence(_globals._sequenceIndexes[1]); + _game._objects.addToInventory(OBJ_ENVELOPE); + _vm->_sound->command(26); + _vm->_dialogs->showItem(OBJ_ENVELOPE, 834, 0); + break; + + case 9: + _game._player._visible = true; + _anim0ActvFl = false; + _game._player._stepEnabled = true; + resetFrame = 49; + break; + + case 23: + case 35: + case 45: + random = _vm->getRandomNumber(3, 70); + + switch (_raoulStatus) { + case 0: + random = 2; + break; + + case 2: + case 3: + random = 1; + break; + + default: + break; + } + + switch (random) { + case 1: + resetFrame = 45; + break; + + case 2: + resetFrame = 23; + _raoulStatus = 1; + break; + + case 3: + resetFrame = 35; + break; + + default: + resetFrame = 22; + break; + } + break; + + default: + break; + } + + if (resetFrame >= 0) { + _scene->setAnimFrame(_globals._animationIndexes[0], resetFrame); + _raoulFrame = resetFrame; + } +} + +void Scene201::handleSellerAnimation() { + if (_scene->_animation[_globals._animationIndexes[1]]->getCurrentFrame() == _sellerFrame ) + return; + + int random = -1; + int resetFrame = -1; + _sellerFrame = _scene->_animation[_globals._animationIndexes[1]]->getCurrentFrame(); + + switch (_sellerFrame ) { + case 1: + case 2: + case 3: + case 4: + case 5: + case 6: + case 7: + case 10: + if (_sellerFrame == 10) + _raoulStatus = 2; + + switch (_sellerStatus) { + case 0: + random = 1; + break; + + case 1: + random = _vm->getRandomNumber(1, 5); + ++_sellerCount; + if (_sellerCount > 30) { + _sellerStatus = 0; + random = 6; + } + break; + + case 2: + if (_sellerFrame == 6) + random = 6; + else if (_sellerFrame == 7) + random = 7; + else + random = _vm->getRandomNumber(6, 7); + + ++_sellerCount; + if (_sellerCount > 30) { + _sellerCount = 0; + random = _vm->getRandomNumber(6, 7); + } + break; + + case 3: + random = 8; + break; + + default: + break; + } + + switch (random) { + case 1: + resetFrame = 0; + break; + + case 2: + resetFrame = 1; + break; + + case 3: + resetFrame = 2; + break; + + case 4: + resetFrame = 3; + break; + + case 5: + resetFrame = 4; + break; + + case 6: + resetFrame = 5; + break; + + case 7: + resetFrame = 6; + break; + + case 8: + resetFrame = 7; + break; + + default: + break; + } + break; + + case 9: + _globals._sequenceIndexes[1] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[1], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[1], 1); + _sellerStatus = 2; + break; + + default: + break; + } + + if (resetFrame >= 0) { + _scene->setAnimFrame(_globals._animationIndexes[1], resetFrame); + _sellerFrame = resetFrame; + } +} + +void Scene201::handleConversation() { + bool interlocutorFl = false; + bool heroFl = false; + + switch (_action._activeAction._verbId) { + case 4: + case 12: + case 13: + case 14: + _vm->_gameConv->setInterlocutorTrigger(90); + _needHoldFl = true; + interlocutorFl = true; + break; + + case 6: + _sellerStatus = 3; + _needHoldFl = true; + interlocutorFl = true; + heroFl = true; + break; + + default: + break; + } + + switch (_game._trigger) { + case 65: + if (_sellerStatus != 3) + _sellerStatus = 1; + break; + + case 70: + if (_sellerStatus != 3) { + _sellerStatus = 0; + _raoulStatus = 0; + } + break; + + case 90: + _vm->_gameConv->setHeroTrigger(91); + heroFl = true; + break; + + case 91: + _raoulStatus = 3; + heroFl = true; + interlocutorFl = true; + break; + + default: + break; + } + + if (!heroFl) + _vm->_gameConv->setHeroTrigger(70); + + if (!interlocutorFl) + _vm->_gameConv->setInterlocutorTrigger(65); + + _sellerCount = 0; +} + +/*------------------------------------------------------------------------*/ + +Scene202::Scene202(MADSEngine *vm) : Scene2xx(vm) { + _ticketGivenFl = false; + _anim0ActvFl = false; + _anim1ActvFl = false; + _skipWalkFl = false; + + for (int i = 0; i < 5; i++) { + _chandeliersPosX[i] = -1; + _chandeliersHotspotId[i] = -1; + } + + _conversationCount = -1; + _usherStatus = -1; + _usherFrame = -1; + _usherCount = -1; + _degasStatus = -1; + _degasFrame = -1; +} + +void Scene202::synchronize(Common::Serializer &s) { + Scene2xx::synchronize(s); + + s.syncAsByte(_ticketGivenFl); + s.syncAsByte(_anim0ActvFl); + s.syncAsByte(_anim1ActvFl); + s.syncAsByte(_skipWalkFl); + + for (int i = 0; i < 5; i++) { + s.syncAsSint16LE(_chandeliersPosX[i]); + s.syncAsSint16LE(_chandeliersHotspotId[i]); + } + + s.syncAsSint16LE(_conversationCount); + s.syncAsSint16LE(_usherStatus); + s.syncAsSint16LE(_usherFrame); + s.syncAsSint16LE(_usherCount); + s.syncAsSint16LE(_degasStatus); + s.syncAsSint16LE(_degasFrame); +} + +void Scene202::setup() { + setPlayerSpritesPrefix(); + setAAName(); + + if (_globals[kTicketPeoplePresent] == 2) + _scene->_variant = 1; + + _scene->addActiveVocab(NOUN_CHANDELIER); + _scene->addActiveVocab(NOUN_EDGAR_DEGAS); +} + +void Scene202::enter() { + _vm->_disableFastwalk = true; + _ticketGivenFl = false; + _chandeliersPosX[0] = 77; + _chandeliersPosX[1] = 192; + _chandeliersPosX[2] = 319; + _chandeliersPosX[3] = 445; + _chandeliersPosX[4] = 560; + + if (_globals[kTicketPeoplePresent] == 2) + _globals[kMakeRichLeave203] = true; + + if ((_globals[kDegasNameIsKnown]) || (_globals[kCurrentYear] == 1993)) + _scene->_hotspots.activate(NOUN_GENTLEMAN, false); + + for (int i = 0; i < 5; i++) { + _globals._sequenceIndexes[2 + i] = -1; + _chandeliersHotspotId[i] = -1; + } + + if (_scene->_priorSceneId != RETURNING_FROM_LOADING) { + _anim0ActvFl = false; + _anim1ActvFl = false; + _skipWalkFl = false; + } + + _conversationCount = 0; + _vm->_gameConv->get(17); + _vm->_gameConv->get(9); + + _globals._spriteIndexes[1] = _scene->_sprites.addSprites("*RDR_9"); + _globals._spriteIndexes[0] = _scene->_sprites.addSprites(formAnimName('x', 0)); + _globals._spriteIndexes[2] = _scene->_sprites.addSprites(formAnimName('f', 0)); + + if (_globals[kTicketPeoplePresent] == 2) { + _globals._animationIndexes[0] = _scene->loadAnimation(formAnimName('b', 0), 0); + _anim0ActvFl = true; + _usherStatus = 2; + } else + _scene->_hotspots.activate(NOUN_USHER, false); + + if (_globals[kDegasNameIsKnown]) + _anim1ActvFl = false; + + if ((_globals[kCurrentYear] == 1881) && (!_globals[kDegasNameIsKnown])) { + _globals._animationIndexes[1] = _scene->loadAnimation(formAnimName('d', 1), 100); + _anim1ActvFl = true; + _degasStatus = 4; + } + + if (_vm->_gameConv->_restoreRunning == 17) { + _vm->_gameConv->run(17); + _vm->_gameConv->exportValue(_game._objects.isInInventory(OBJ_TICKET)); + _vm->_gameConv->exportValue(0); + _game._player._playerPos = Common::Point(569, 147); + _game._player._facing = FACING_NORTHEAST; + _globals[kWalkerConverse] = _vm->getRandomNumber(1, 4); + } + + if (_vm->_gameConv->_restoreRunning == 9) { + _vm->_gameConv->run(9); + _vm->_gameConv->exportPointer(&_globals[kPlayerScore]); + _game._player._playerPos = Common::Point(400, 141); + _game._player._facing = FACING_NORTHWEST; + _globals[kWalkerConverse] = _vm->getRandomNumber(1, 4); + } + + if (_scene->_priorSceneId == 201) { + _game._player._playerPos = Common::Point(3, 141); + _game._player.walk(Common::Point(40, 141), FACING_EAST); + _globals._sequenceIndexes[0] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[0], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[0], 14); + } else if (_scene->_priorSceneId == 203) { + _game._player._playerPos = Common::Point(134, 112); + _game._player._facing = FACING_SOUTH; + _game._player._stepEnabled = false; + _game._player.walk(Common::Point(126, 123), FACING_SOUTH); + _game._player.setWalkTrigger(60); + _globals._sequenceIndexes[0] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[0], false, 5); + _scene->_sequences.setDepth(_globals._sequenceIndexes[0], 14); + } else if (_scene->_priorSceneId == 204) { + _game._player._playerPos = Common::Point(253, 117); + _game._player.walk(Common::Point(255, 133), FACING_SOUTH); + _globals._sequenceIndexes[0] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[0], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[0], 14); + _scene->setCamera(Common::Point(70, 0)); + } else if (_scene->_priorSceneId == 205) { + _game._player._playerPos = Common::Point(510, 117); + _game._player.walk(Common::Point(512, 133), FACING_SOUTH); + _scene->setCamera(Common::Point(320, 0)); + _globals._sequenceIndexes[0] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[0], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[0], 14); + } else if ((_scene->_priorSceneId == 101) || (_scene->_priorSceneId != RETURNING_FROM_LOADING)) { + _game._player._playerPos = Common::Point(636, 143); + _game._player.walk(Common::Point(598, 143), FACING_WEST); + _scene->setCamera(Common::Point(320, 0)); + _globals._sequenceIndexes[0] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[0], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[0], 14); + } else if (_scene->_priorSceneId == RETURNING_FROM_LOADING) { + _globals._sequenceIndexes[0] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[0], false, -1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[0], 14); + } + + handleChandeliersPositions(); + sceneEntrySound(); +} + +void Scene202::step() { + if (_game._camX._currentFrameFl) + handleChandeliersPositions(); + + if (_anim0ActvFl) + handleUsherAnimation(); + + if (_game._trigger == 100) + _anim1ActvFl = false; + + if (_anim1ActvFl) + handleDegasAnimation(); + + if ((_globals[kCurrentYear] == 1881) && !_globals[kDegasNameIsKnown] && (_game._player._playerPos.x < 405) && !_skipWalkFl) { + _game._player.walk(Common::Point(400, 141), FACING_NORTHWEST); + _game._player.setWalkTrigger(90); + _game._player._stepEnabled = false; + _skipWalkFl = true; + } + + if (_game._trigger == 90) { + _game._player._stepEnabled = true; + _vm->_gameConv->run(9); + _vm->_gameConv->exportPointer(&_globals[kPlayerScore]); + _globals[kWalkerConverse] = _vm->getRandomNumber(1, 4); + } + + switch (_game._trigger) { + case 60: + _scene->deleteSequence(_globals._sequenceIndexes[0]); + _globals._sequenceIndexes[0] = _scene->_sequences.addReverseSpriteCycle(_globals._spriteIndexes[0], false, 8, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[0], 14); + _scene->_sequences.setAnimRange(_globals._sequenceIndexes[0], 1, 5); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[0], SEQUENCE_TRIGGER_EXPIRE, 0, 61); + break; + + case 61: + _vm->_sound->command(25); + _globals._sequenceIndexes[0] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[0], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[0], 14); + _game._player._stepEnabled = true; + break; + + default: + break; + } + + if ((_globals[kWalkerConverse] == 2) || (_globals[kWalkerConverse] == 3)) { + ++_conversationCount; + if (_conversationCount > 200) + _globals[kWalkerConverse] = _vm->getRandomNumber(1, 4); + } +} + +void Scene202::actions() { + if (_vm->_gameConv->_running == 17) { + handleConversation1(); + _action._inProgress = false; + return; + } + + if (_vm->_gameConv->_running == 9) { + handleConversation2(); + _action._inProgress = false; + return; + } + + if ((_globals[kTicketPeoplePresent] == 2) && (_action.isAction(VERB_WALK_THROUGH, NOUN_RIGHT_ARCHWAY) || _action.isAction(VERB_TALK_TO, NOUN_USHER))) { + _vm->_gameConv->run(17); + _vm->_gameConv->exportValue(_game._objects.isInInventory(OBJ_TICKET)); + _vm->_gameConv->exportValue(0); + _globals[kWalkerConverse] = _vm->getRandomNumber(1, 4); + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_GIVE, NOUN_TICKET, NOUN_USHER)) { + _ticketGivenFl = true; + _vm->_gameConv->run(17); + _vm->_gameConv->exportValue(_game._objects.isInInventory(OBJ_TICKET)); + _vm->_gameConv->exportValue(1); + _globals[kWalkerConverse] = _vm->getRandomNumber(1, 4); + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_TALK_TO, NOUN_GENTLEMAN) || _action.isAction(VERB_TALK_TO, NOUN_EDGAR_DEGAS)) { + if (!_globals[kDegasNameIsKnown] ) { + _vm->_gameConv->run(9); + _vm->_gameConv->exportPointer(&_globals[kPlayerScore]); + _globals[kWalkerConverse] = _vm->getRandomNumber(1, 4); + } else + _vm->_dialogs->show(20224); + + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_WALK_THROUGH, NOUN_LEFT_DOOR) || _action.isAction(VERB_OPEN, NOUN_LEFT_DOOR)) { + switch (_game._trigger) { + case (0): + _game._player._stepEnabled = false; + _game._player._visible = false; + _globals._sequenceIndexes[1] = _scene->_sequences.startPingPongCycle(_globals._spriteIndexes[1], false, 5, 2); + _scene->_sequences.setAnimRange(_globals._sequenceIndexes[1], 1, 4); + _scene->_sequences.setSeqPlayer(_globals._sequenceIndexes[1], true); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[1], SEQUENCE_TRIGGER_SPRITE, 4, 80); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[1], SEQUENCE_TRIGGER_EXPIRE, 0, 82); + break; + + case 80: + _scene->deleteSequence(_globals._sequenceIndexes[0]); + _globals._sequenceIndexes[0] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[0], false, 8, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[0], 14); + _scene->_sequences.setAnimRange(_globals._sequenceIndexes[0], 1, 5); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[0], SEQUENCE_TRIGGER_EXPIRE, 0, 81); + _vm->_sound->command(24); + break; + + case 81: { + int idx = _globals._sequenceIndexes[0]; + _globals._sequenceIndexes[0] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[0], false, 5); + _game.syncTimers(SYNC_SEQ, _globals._sequenceIndexes[0], SYNC_SEQ, idx); + _scene->_sequences.setDepth(_globals._sequenceIndexes[0], 14); + _game._player.walk(Common::Point(134, 112), FACING_NORTH); + _game._player.setWalkTrigger(83); + } + break; + + case 82: + _game._player._visible = true; + break; + + case 83: + _scene->deleteSequence(_globals._sequenceIndexes[0]); + _globals._sequenceIndexes[0] = _scene->_sequences.addReverseSpriteCycle(_globals._spriteIndexes[0], false, 8, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[0], 1); + _scene->_sequences.setAnimRange(_globals._sequenceIndexes[0], 1, 5); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[0], SEQUENCE_TRIGGER_EXPIRE, 0, 84); + _vm->_sound->command(25); + break; + + case 84: + _globals._sequenceIndexes[0] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[0], false, 5); + _scene->_sequences.setDepth(_globals._sequenceIndexes[0], 1); + _scene->_nextSceneId = 203; + break; + + default: + break; + } + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_WALK_THROUGH, NOUN_LEFT_ARCHWAY)) { + _scene->_nextSceneId = 201; + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_WALK_THROUGH, NOUN_RIGHT_ARCHWAY)) { + _scene->_nextSceneId = 101; + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_WALK_THROUGH, NOUN_MIDDLE_DOOR)) { + _scene->_nextSceneId = 204; + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_WALK_THROUGH, NOUN_RIGHT_DOOR)) { + _scene->_nextSceneId = 205; + _action._inProgress = false; + return; + } + + if (_action._lookFlag) { + _vm->_dialogs->show(20210); + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_LOOK) || _action.isAction(VERB_LOOK_AT)) { + if (_action.isObject(NOUN_FLOOR)) { + _vm->_dialogs->show(20211); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_WALL)) { + _vm->_dialogs->show(20212); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_LEFT_ARCHWAY)) { + _vm->_dialogs->show(20213); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_RIGHT_ARCHWAY)) { + _vm->_dialogs->show(20214); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_LEFT_DOOR)) { + _vm->_dialogs->show(20215); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_MIDDLE_DOOR)) { + _vm->_dialogs->show(20216); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_RIGHT_DOOR)) { + _vm->_dialogs->show(20217); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_LIGHT_FIXTURE)) { + _vm->_dialogs->show(20218); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_OVERDOOR_MEDALLION)) { + _vm->_dialogs->show(20219); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_DECORATIVE_MOLDING)) { + _vm->_dialogs->show(20220); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_PAINTING)) { + _vm->_dialogs->show(20221); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_EDGAR_DEGAS) || _action.isObject(NOUN_GENTLEMAN)) { + _vm->_dialogs->show(20223); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_USHER)) { + _vm->_dialogs->show(20225); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_CHANDELIER)) { + _vm->_dialogs->show(20218); + _action._inProgress = false; + return; + } + } + + if (_action.isAction(VERB_TAKE) && (_action.isObject(NOUN_GENTLEMAN) || _action.isObject(NOUN_EDGAR_DEGAS))) { + _vm->_dialogs->show(20226); + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_TAKE, NOUN_USHER)) { + _vm->_dialogs->show(20227); + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_CLOSE, NOUN_DOOR)) { + _vm->_dialogs->show(20222); + _action._inProgress = false; + return; + } +} + +void Scene202::preActions() { + if (_action.isAction(VERB_OPEN, NOUN_LEFT_DOOR)) + _game._player.walk(Common::Point(126, 123), FACING_NORTHEAST); + + if ((_globals[kTicketPeoplePresent] == 2) && _action.isAction(VERB_WALK_THROUGH, NOUN_RIGHT_ARCHWAY)) + _game._player.walk(Common::Point(569, 147), FACING_NORTHEAST); + + if (_action.isAction(VERB_TAKE, NOUN_GENTLEMAN) || _action.isAction(VERB_TAKE, NOUN_EDGAR_DEGAS)) + _game._player._needToWalk = false; +} + +void Scene202::handleConversation1() { + bool interlocutorFl = false; + bool heroFl = false; + + switch (_action._activeAction._verbId) { + case 0: + if (!_ticketGivenFl) + _usherStatus = 4; + + _globals[kWalkerConverse] = _vm->getRandomNumber(1, 4); + interlocutorFl = true; + heroFl = true; + break; + + case 3: + _vm->_gameConv->setInterlocutorTrigger(72); + _vm->_gameConv->setHeroTrigger(76); + interlocutorFl = true; + heroFl = true; + break; + + case 4: + _vm->_gameConv->setHeroTrigger(76); + heroFl = true; + interlocutorFl = true; + break; + + default: + break; + } + + switch (_game._trigger) { + case 70: + _globals[kWalkerConverse] = _vm->getRandomNumber(1, 4); + _usherStatus = 0; + break; + + case 72: + _usherStatus = 17; + break; + + case 74: + _globals[kWalkerConverse] = _vm->getRandomNumber(2, 3); + _usherStatus = 2; + _conversationCount = 0; + break; + + case 76: + _globals[kWalkerConverse] = 0; + _ticketGivenFl = false; + heroFl = true; + interlocutorFl = true; + break; + + default: + break; + } + + if (!heroFl) + _vm->_gameConv->setHeroTrigger(74); + + if (!interlocutorFl) + _vm->_gameConv->setInterlocutorTrigger(70); + + _usherCount = 0; +} + +void Scene202::handleConversation2() { + bool interlocutorFl = false; + bool heroFl = false; + + switch (_action._activeAction._verbId) { + case 1: + _globals[kDegasNameIsKnown] = 1; + break; + + case 10: + _globals[kWalkerConverse] = _vm->getRandomNumber(1, 4); + _vm->_gameConv->setHeroTrigger(96); + interlocutorFl = true; + heroFl = true; + break; + + default: + break; + } + + switch (_game._trigger) { + case 74: + _globals[kWalkerConverse] = _vm->getRandomNumber(2, 3); + _degasStatus = 4; + _conversationCount = 0; + break; + + case 93: + _globals[kWalkerConverse] = _vm->getRandomNumber(1, 4); + switch (_action._activeAction._verbId) { + case 1: + _degasStatus = 1; + break; + + case 2: + _degasStatus = 2; + break; + + default: + if ((_action._activeAction._verbId != 11) && (_action._activeAction._verbId != 12)) + _degasStatus = 0; + break; + } + break; + + case 96: + _vm->_gameConv->setInterlocutorTrigger(97); + interlocutorFl = true; + heroFl = true; + break; + + case 97: + _vm->_gameConv->setHeroTrigger(98); + _degasStatus = 0; + interlocutorFl = true; + heroFl = true; + break; + + case 98: + _globals[kWalkerConverse] = 0; + _degasStatus = 3; + + if (_globals[kDegasNameIsKnown] == 1) { + int idx = _scene->_dynamicHotspots.add(NOUN_EDGAR_DEGAS, VERB_WALK_TO, SYNTAX_SINGULAR_MASC, EXT_NONE, Common::Rect(0, 0, 0, 0)); + _scene->_dynamicHotspots[idx]._articleNumber = PREP_ON; + _scene->_dynamicHotspots.setPosition(idx, Common::Point(596, 144), FACING_EAST); + _scene->setDynamicAnim(idx, _globals._animationIndexes[1], 1); + } else { + int idx = _scene->_dynamicHotspots.add(NOUN_GENTLEMAN, VERB_WALK_TO, SYNTAX_SINGULAR_MASC, EXT_NONE, Common::Rect(0, 0, 0, 0)); + _scene->_dynamicHotspots[idx]._articleNumber = PREP_ON; + _scene->_dynamicHotspots.setPosition(idx, Common::Point(596, 144), FACING_EAST); + _scene->setDynamicAnim(idx, _globals._animationIndexes[1], 1); + } + + _globals[kDegasNameIsKnown] = 2; + interlocutorFl = true; + heroFl = true; + _scene->_hotspots.activate(NOUN_GENTLEMAN, false); + _game._player._stepEnabled = false; + _vm->_gameConv->hold(); + break; + + default: + break; + } + + if (!heroFl) + _vm->_gameConv->setHeroTrigger(74); + + if (!interlocutorFl) + _vm->_gameConv->setInterlocutorTrigger(93); +} + +void Scene202::handleChandeliersPositions() { + int center = _scene->_posAdjust.x + 160; + + for (int chandelier = 0; chandelier < 5; chandelier++) { + if (_globals._sequenceIndexes[chandelier + 2] >= 0) + _scene->deleteSequence(_globals._sequenceIndexes[chandelier + 2]); + + int diff = center - _chandeliersPosX[chandelier]; + int dir = 0; + + if (diff < 0) + dir = 1; + else if (diff > 0) + dir = -1; + + int shiftBase = (int)(abs(diff) / 5); + if (dir < 0) + shiftBase = -shiftBase; + + int posX = _chandeliersPosX[chandelier] + shiftBase - 1; + int posY = _scene->_sprites[_globals._spriteIndexes[2]]->getFrameHeight(0) - 1; + int frameWidth = _scene->_sprites[_globals._spriteIndexes[2]]->getFrameWidth(0); + + if (((posX - ((frameWidth >> 1) + 1)) >= (_scene->_posAdjust.x + 320)) || ((posX + ((frameWidth >> 1) + 1)) < _scene->_posAdjust.x)) + _globals._sequenceIndexes[chandelier + 2] = -1; + else { + if (_chandeliersHotspotId[chandelier] != -1) + _scene->_dynamicHotspots.remove(_chandeliersHotspotId[chandelier]); + + _chandeliersHotspotId[chandelier] = _scene->_dynamicHotspots.add(NOUN_CHANDELIER, VERB_LOOK_AT, SYNTAX_SINGULAR, EXT_NONE, Common::Rect(posX - 8, posY - 12, posX + 8, posY + 1)); + + _globals._sequenceIndexes[chandelier + 2] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[2], false, 1); + _scene->_sequences.setPosition(_globals._sequenceIndexes[chandelier + 2], Common::Point(posX, posY)); + _scene->_sequences.setDepth(_globals._sequenceIndexes[chandelier + 2], 1); + } + } +} + +void Scene202::handleUsherAnimation() { + if (_scene->_animation[_globals._animationIndexes[0]]->getCurrentFrame() == _usherFrame) + return; + + _usherFrame = _scene->_animation[_globals._animationIndexes[0]]->getCurrentFrame(); + int resetFrame = -1; + int random; + switch (_usherFrame) { + case 1: + case 13: + case 35: + case 51: + case 52: + case 53: + case 54: + switch (_usherStatus) { + case 0: + random = _vm->getRandomNumber(1, 3); + ++_usherCount; + if (_usherCount > 15) { + if (_action._activeAction._verbId == 0) { + _usherStatus = 3; + random = 5; + } else { + _usherStatus = 2; + random = 7; + } + } + break; + + case 3: + random = 5; + break; + + case 4: + random = 6; + break; + + case 17: + random = 4; + break; + + default: + random = 7; + break; + } + + switch (random) { + case 1: + resetFrame = 51; + break; + + case 2: + resetFrame = 52; + break; + + case 3: + resetFrame = 53; + break; + + case 4: + resetFrame = 21; + _usherStatus = 17; + break; + + case 5: + resetFrame = 1; + break; + + case 6: + resetFrame = 35; + _usherStatus = 0; + break; + + default: + resetFrame = 0; + break; + } + break; + + case 7: + if (_usherStatus == 3) + random = 1; + else + random = 2; + + if (random == 1) + resetFrame = 6; + else + resetFrame = 7; + + break; + + case 28: + if (_usherStatus == 17) { + random = 1; + ++_usherCount; + if (_usherCount > 15) { + _usherStatus = 2; + random = 2; + } + } else + random = 2; + + if (random == 1) + resetFrame = 27; + else + resetFrame = 28; + break; + } + + if (resetFrame >= 0) { + _scene->setAnimFrame(_globals._animationIndexes[0], resetFrame); + _usherFrame = resetFrame; + } +} + +void Scene202::handleDegasAnimation() { + if (_scene->_animation[_globals._animationIndexes[1]]->getCurrentFrame() == _degasFrame) + return; + + _degasFrame = _scene->_animation[_globals._animationIndexes[1]]->getCurrentFrame(); + int resetFrame = -1; + int random; + + switch (_degasFrame) { + case 1: + case 17: + case 58: + switch (_degasStatus) { + case 0: + _degasStatus = 4; + random = 1; + break; + + case 1: + case 2: + case 3: + random = 2; + break; + + default: + random = _vm->getRandomNumber(3, 50); + break; + } + + switch (random) { + case 1: + resetFrame = 1; + break; + + case 2: + resetFrame = 58; + break; + + case 3: + resetFrame = 58; + break; + + default: + resetFrame = 0; + break; + } + break; + + case 33: + case 40: + case 55: + case 62: + switch (_degasStatus) { + case 0: + _degasStatus = 4; + random = 1; + break; + + case 1: + _degasStatus = 4; + random = 2; + break; + + case 2: + _degasStatus = 4; + random = 3; + break; + + case 3: + random = 4; + break; + + default: + random = _vm->getRandomNumber(5, 50); + break; + } + + switch (random) { + case 1: + resetFrame = 33; + break; + + case 2: + resetFrame = 17; + break; + + case 3: + resetFrame = 42; + break; + + case 4: + resetFrame = 62; + break; + + case 5: + resetFrame = 41; + break; + + case 6: + resetFrame = 55; + break; + + default: + resetFrame = 39; + break; + } + break; + + case 42: + switch (_degasStatus) { + case 0: + case 1: + case 2: + case 3: + random = 1; + break; + + default: + random = _vm->getRandomNumber(1, 50); + break; + } + + if (random == 1) + resetFrame = 39; + else + resetFrame = 41; + + break; + + case 110: + _vm->_gameConv->release(); + break; + + default: + break; + } + + if (resetFrame >= 0) { + _scene->setAnimFrame(_globals._animationIndexes[1], resetFrame); + _degasFrame = resetFrame; + } +} + +/*------------------------------------------------------------------------*/ + +Scene203::Scene203(MADSEngine *vm) : Scene2xx(vm) { + _anim0ActvFl = false; + _anim1ActvFl = false; + _anim2ActvFl = false; + _anim3ActvFl = false; + _showNoteFl = false; + + _brieStatus = -1; + _brieFrame = -1; + _brieCount = -1; + _raoulStatus = -1; + _raoulFrame = -1; + _raoulCount = -1; + _richardStatus = -1; + _richardFrame = -1; + _daaeStatus = -1; + _daaeFrame = -1; + _conversationCount = -1; +} + +void Scene203::synchronize(Common::Serializer &s) { + Scene2xx::synchronize(s); + + s.syncAsByte(_anim0ActvFl); + s.syncAsByte(_anim1ActvFl); + s.syncAsByte(_anim2ActvFl); + s.syncAsByte(_anim3ActvFl); + s.syncAsByte(_showNoteFl); + + s.syncAsSint16LE(_brieStatus); + s.syncAsSint16LE(_brieFrame); + s.syncAsSint16LE(_brieCount); + s.syncAsSint16LE(_raoulStatus); + s.syncAsSint16LE(_raoulFrame); + s.syncAsSint16LE(_raoulCount); + s.syncAsSint16LE(_richardStatus); + s.syncAsSint16LE(_richardFrame); + s.syncAsSint16LE(_daaeStatus); + s.syncAsSint16LE(_daaeFrame); + s.syncAsSint16LE(_conversationCount); +} + +void Scene203::setup() { + if (_globals[kCurrentYear] == 1993) + _scene->_variant = 1; + + setPlayerSpritesPrefix(); + setAAName(); +} + +void Scene203::enter() { + if (_scene->_priorSceneId != RETURNING_FROM_LOADING) { + _anim0ActvFl = false; + _anim1ActvFl = false; + _anim2ActvFl = false; + _anim3ActvFl = false; + _showNoteFl = false; + } + + _conversationCount = 0; + _scene->_hotspots.activate(NOUN_LETTER, false); + _scene->_hotspots.activate(NOUN_PARCHMENT, false); + _scene->_hotspots.activate(NOUN_NOTICE, false); + + _globals._spriteIndexes[1] = _scene->_sprites.addSprites(formAnimName('p', 1)); + _globals._spriteIndexes[3] = _scene->_sprites.addSprites(formAnimName('p', 0)); + _globals._spriteIndexes[5] = _scene->_sprites.addSprites(formAnimName('x', 0)); + _globals._spriteIndexes[4] = _scene->_sprites.addSprites("*RDR_6"); + + if (_globals[kCurrentYear] == 1993) { + _globals._spriteIndexes[0] = _scene->_sprites.addSprites(formAnimName('z', -1)); + _vm->_gameConv->get(5); + } else { + _vm->_gameConv->get(8); + _vm->_gameConv->get(15); + } + + if (_globals[kCurrentYear] == 1993) { + if (_game._objects.isInRoom(OBJ_PARCHMENT)) { + _globals._sequenceIndexes[1] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[1], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[1], 3); + _scene->_hotspots.activate(NOUN_PARCHMENT, true); + } + + _scene->_hotspots.activate(NOUN_MONSIEUR_RICHARD, false); + _scene->_hotspots.activate(NOUN_MANAGERS_CHAIR, false); + + if (!_globals[kMakeBrieLeave203]) { + _globals._animationIndexes[0] = _scene->loadAnimation(formAnimName('b', 9), 1); + _anim0ActvFl = true; + _brieStatus = 4; + } else { + _scene->_hotspots.activate(NOUN_MONSIEUR_BRIE, false); + _scene->_hotspots.activate(NOUN_MANAGERS_CHAIR, true); + } + + if ((_scene->_priorSceneId == RETURNING_FROM_LOADING) && (_vm->_gameConv->_restoreRunning == 5)) { + _brieStatus = 4; + _raoulStatus = 0; + _anim1ActvFl = true; + _game._player._visible = false; + _game._player._stepEnabled = false; + _globals._animationIndexes[1] = _scene->loadAnimation(formAnimName('c', 1), 0); + _scene->setAnimFrame(_globals._animationIndexes[1], 9); + _vm->_gameConv->run(5); + _vm->_gameConv->exportPointer(&_globals[kPlayerScore]); + _vm->_gameConv->exportValue(_game._objects.isInInventory(OBJ_SMALL_NOTE)); + _vm->_gameConv->exportValue(_globals[kReadBook]); + _vm->_gameConv->exportValue(_game._objects.isInInventory(OBJ_LARGE_NOTE)); + _vm->_gameConv->exportValue(_globals[kLookedAtCase]); + _vm->_gameConv->exportValue(_globals[kCharlesNameIsKnown]); + _vm->_gameConv->exportValue(_globals[kCanFindBookInLibrary]); + _vm->_gameConv->exportValue(_globals[kFlorentNameIsKnown]); + _vm->_gameConv->exportValue(_globals[kSandbagStatus]); + _vm->_gameConv->exportValue(_globals[kObservedPhan104]); + } + + _scene->drawToBackground(_globals._spriteIndexes[0], 1, Common::Point(-32000, -32000), 0, 100); + _scene->_hotspots.activate(NOUN_CANDLE, false); + } else if (_globals[kJacquesStatus] == 0) { + _scene->_hotspots.activate(NOUN_DESK_LAMP, false); + _scene->_hotspots.activate(NOUN_MONSIEUR_BRIE, false); + _scene->_hotspots.activate(NOUN_MANAGERS_CHAIR, false); + + if (!_globals[kMakeRichLeave203]) { + _globals._animationIndexes[2] = _scene->loadAnimation(formAnimName('r', 1), 1); + _anim2ActvFl = true; + _richardStatus = 4; + } else { + _scene->_hotspots.activate(NOUN_MONSIEUR_RICHARD, false); + _scene->_hotspots.activate(NOUN_MANAGERS_CHAIR, true); + } + + if ((_scene->_priorSceneId == RETURNING_FROM_LOADING) && (_vm->_gameConv->_restoreRunning == 8)) { + _globals._animationIndexes[1] = _scene->loadAnimation(formAnimName('c', 1), 0); + _scene->setAnimFrame(_globals._animationIndexes[1], 9); + _anim1ActvFl = true; + _game._player._visible = false; + _raoulStatus = 0; + _vm->_gameConv->run(8); + _vm->_gameConv->exportPointer(&_globals[kPlayerScore]); + } + + if (_game._objects.isInRoom(OBJ_LETTER)) { + _globals._sequenceIndexes[3] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[3], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[3], 3); + _scene->_hotspots.activate(NOUN_LETTER, true); + } + + if (_game._objects.isInRoom(OBJ_NOTICE)) { + _globals._sequenceIndexes[1] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[1], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[1], 3); + _scene->_hotspots.activate(NOUN_NOTICE, true); + } + } else { + _scene->_hotspots.activate(NOUN_MONSIEUR_BRIE, false); + _scene->_hotspots.activate(NOUN_MONSIEUR_RICHARD, false); + _scene->_hotspots.activate(NOUN_DESK_LAMP, false); + } + + if (_vm->_gameConv->_restoreRunning == 15) { + _globals._sequenceIndexes[5] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[5], false, -1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[5], 14); + _game._player._playerPos = Common::Point(98, 137); + _game._player._facing = FACING_NORTHEAST; + _vm->_gameConv->run(15); + _vm->_gameConv->exportPointer(&_globals[kPlayerScore]); + _vm->_gameConv->exportPointer(&_globals[kChristineToldEnvelope]); + _globals[kWalkerConverse] = _vm->getRandomNumber(1, 4); + } + + if (_scene->_priorSceneId == RETURNING_FROM_LOADING) { + _globals._sequenceIndexes[5] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[5], false, -1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[5], 14); + } else if (_scene->_priorSceneId == 202) { + _globals._sequenceIndexes[5] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[5], false, -1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[5], 14); + _game._player._playerPos = Common::Point(195, 147); + _game._player._facing = FACING_NORTH; + } else if (_scene->_priorSceneId == 150) { + _globals._sequenceIndexes[5] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[5], false, -1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[5], 14); + _game._player._playerPos = Common::Point(98, 137); + _game._player._facing = FACING_NORTHEAST; + _vm->_gameConv->run(15); + _vm->_gameConv->exportPointer(&_globals[kPlayerScore]); + _vm->_gameConv->exportPointer(&_globals[kChristineToldEnvelope]); + _globals[kWalkerConverse] = _vm->getRandomNumber(1, 4); + } else if ((_scene->_priorSceneId == 204) || (_scene->_priorSceneId != RETURNING_FROM_LOADING)) { + _globals._sequenceIndexes[5] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[5], false, -2); + _scene->_sequences.setDepth(_globals._sequenceIndexes[5], 1); + _game._player._playerPos = Common::Point(319, 123); + _game._player._facing = FACING_SOUTHWEST; + _game._player.walk(Common::Point(276, 123), FACING_WEST); + _game._player.setWalkTrigger(95); + _game._player._stepEnabled = false; + } + + sceneEntrySound(); +} + +void Scene203::step() { + if (_anim0ActvFl) + handleBrieAnimation(); + + if (_anim1ActvFl) + handleRaoulAnimation(); + + if (_anim2ActvFl) + handleRichardAnimation(); + + if (_anim3ActvFl) + handleDaaeAnimation(); + + if ((_globals[kWalkerConverse] == 2) || (_globals[kWalkerConverse] == 3)) { + ++_conversationCount; + if (_conversationCount > 200) + _globals[kWalkerConverse] = _vm->getRandomNumber(1, 4); + } + + switch (_game._trigger) { + case 95: + _scene->deleteSequence(_globals._sequenceIndexes[5]); + _globals._sequenceIndexes[5] = _scene->_sequences.addReverseSpriteCycle(_globals._spriteIndexes[5], false, 8, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[5], 10); + _scene->_sequences.setAnimRange(_globals._sequenceIndexes[5], -1, -2); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[5], SEQUENCE_TRIGGER_EXPIRE, 0, 96); + break; + + case 96: + _vm->_sound->command(25); + _globals._sequenceIndexes[5] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[5], false, -1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[5], 14); + if (_vm->_gameConv->_running != 15) + _game._player._stepEnabled = true; + break; + + default: + break; + } +} + +void Scene203::actions() { + if (_vm->_gameConv->_running == 5) { + handleBrieConversation(); + _action._inProgress = false; + return; + } + + if (_vm->_gameConv->_running == 8) { + handleRichardConversation(); + _action._inProgress = false; + return; + } + + if (_vm->_gameConv->_running == 15) { + handleRichardAndDaaeConversation(); + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_WALK_THROUGH, NOUN_DOOR) || _action.isAction(VERB_OPEN, NOUN_DOOR) || _game._trigger) { + switch (_game._trigger) { + case (0): + _game._player._stepEnabled = false; + _game._player._visible = false; + _globals._sequenceIndexes[4] = _scene->_sequences.startPingPongCycle(_globals._spriteIndexes[4], false, 5, 2); + _scene->_sequences.setAnimRange(_globals._sequenceIndexes[4], 1, 4); + _scene->_sequences.setSeqPlayer(_globals._sequenceIndexes[4], true); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[4], SEQUENCE_TRIGGER_SPRITE, 4, 90); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[4], SEQUENCE_TRIGGER_EXPIRE, 0, 92); + break; + + case 90: + _vm->_sound->command(24); + _scene->deleteSequence(_globals._sequenceIndexes[5]); + _globals._sequenceIndexes[5] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[5], false, 8, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[5], 1); + _scene->_sequences.setAnimRange(_globals._sequenceIndexes[5], -1, -2); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[5], SEQUENCE_TRIGGER_EXPIRE, 0, 91); + break; + + case 91: + _globals._sequenceIndexes[5] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[5], false, -2); + _scene->_sequences.setDepth(_globals._sequenceIndexes[5], 1); + break; + + case 92: + _game._player._visible = true; + _game.syncTimers(SYNC_PLAYER, 0, SYNC_SEQ, _globals._sequenceIndexes[4]); + _game._player.walk(Common::Point(319, 123), FACING_WEST); + _game._player.setWalkTrigger(93); + break; + + case 93: + _scene->_nextSceneId = 204; + break; + + default: + break; + } + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_TALK_TO, NOUN_MONSIEUR_BRIE)) { + _globals._animationIndexes[1] = _scene->loadAnimation(formAnimName('c', 1), 0); + _anim1ActvFl = true; + _game._player._visible = false; + _raoulStatus = 0; + _game.syncTimers(SYNC_ANIM, _globals._animationIndexes[1], SYNC_PLAYER, 0); + + _vm->_gameConv->run(5); + _vm->_gameConv->hold(); + _vm->_gameConv->exportPointer(&_globals[kPlayerScore]); + _vm->_gameConv->exportValue(_game._objects.isInInventory(OBJ_SMALL_NOTE)); + _vm->_gameConv->exportValue(_globals[kReadBook]); + _vm->_gameConv->exportValue(_game._objects.isInInventory(OBJ_LARGE_NOTE)); + _vm->_gameConv->exportValue(_globals[kLookedAtCase]); + if (_globals[kCharlesNameIsKnown] == 2) + _vm->_gameConv->exportValue(1); + else + _vm->_gameConv->exportValue(0); + + _vm->_gameConv->exportValue(_globals[kCanFindBookInLibrary]); + _vm->_gameConv->exportValue(_globals[kFlorentNameIsKnown]); + _vm->_gameConv->exportValue(_globals[kSandbagStatus]); + _vm->_gameConv->exportValue(_globals[kObservedPhan104]); + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_TALK_TO, NOUN_MONSIEUR_RICHARD)) { + if (_globals[kCameFromFade]) { + _vm->_gameConv->run(15); + _vm->_gameConv->exportPointer(&_globals[kPlayerScore]); + _vm->_gameConv->exportPointer(&_globals[kChristineToldEnvelope]); + } else { + _globals._animationIndexes[1] = _scene->loadAnimation(formAnimName('c', 1), 0); + _anim1ActvFl = true; + _game._player._visible = false; + _game._player._stepEnabled = false; + _raoulStatus = 0; + _game.syncTimers(SYNC_ANIM, _globals._animationIndexes[1], SYNC_PLAYER, 0); + + _vm->_gameConv->run(8); + _vm->_gameConv->exportPointer(&_globals[kPlayerScore]); + _vm->_gameConv->hold(); + } + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_EXIT_TO, NOUN_GRAND_FOYER)) { + _scene->_nextSceneId = 202; + _action._inProgress = false; + return; + } + + if (_action._lookFlag) { + if (_globals[kMakeBrieLeave203]) + _vm->_dialogs->show(20337); + else + _vm->_dialogs->show(20310); + + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_LOOK) || _action.isAction(VERB_LOOK_AT)) { + if (_action.isObject(NOUN_WALL)) { + _vm->_dialogs->show(20311); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_FLOOR)) { + _vm->_dialogs->show(20312); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_BOOKCASE)) { + _vm->_dialogs->show(20313); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_DOORWAY)) { + _vm->_dialogs->show(20314); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_COMFY_CHAIR)) { + _vm->_dialogs->show(20315); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_DESK)) { + _vm->_dialogs->show(20316); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_MANAGERS_CHAIR)) { + _vm->_dialogs->show(20317); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_DESK_LAMP)) { + _vm->_dialogs->show(20318); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_LAMP)) { + _vm->_dialogs->show(20319); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_LIGHT_FIXTURE)) { + _vm->_dialogs->show(20320); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_WINDOW)) { + _vm->_dialogs->show(20321); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_SHEERS)) { + _vm->_dialogs->show(20322); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_TAPESTRY)) { + _vm->_dialogs->show(20323); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_GRAND_FOYER)) { + _vm->_dialogs->show(20324); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_TABLE)) { + _vm->_dialogs->show(20325); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_CANDLE)) { + _vm->_dialogs->show(20326); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_MONSIEUR_BRIE)) { + _vm->_dialogs->show(20327); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_MONSIEUR_RICHARD)) { + _vm->_dialogs->show(20328); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_PARCHMENT) && _game._objects.isInRoom(OBJ_PARCHMENT)) { + _vm->_dialogs->show(20329); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_LETTER) && _game._objects.isInRoom(OBJ_LETTER)) { + _vm->_dialogs->show(20331); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_NOTICE) && _game._objects.isInRoom(OBJ_NOTICE)) { + _vm->_dialogs->show(20333); + _action._inProgress = false; + return; + } + } + + if (_action.isAction(VERB_TAKE, NOUN_PARCHMENT)) { + _vm->_dialogs->show(20330); + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_TAKE, NOUN_LETTER)) { + _vm->_dialogs->show(20332); + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_TAKE, NOUN_NOTICE)) { + _vm->_dialogs->show(20334); + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_TAKE, NOUN_MONSIEUR_BRIE)) { + _vm->_dialogs->show(20335); + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_TAKE, NOUN_MONSIEUR_RICHARD)) { + _vm->_dialogs->show(20336); + _action._inProgress = false; + return; + } +} + +void Scene203::preActions() { + if (_action.isAction(VERB_TALK_TO, NOUN_MONSIEUR_RICHARD)) { + if (_globals[kCameFromFade]) + _game._player.walk(Common::Point(98, 137), FACING_NORTHEAST); + else + _game._player.walk(Common::Point(154, 131), FACING_NORTHWEST); + } + + if (_action.isAction(VERB_TALK_TO, NOUN_MONSIEUR_BRIE)) + _game._player.walk(Common::Point(154, 131), FACING_NORTHWEST); + + if (_action.isAction(VERB_OPEN, NOUN_DOOR)) + _game._player.walk(Common::Point(276, 123), FACING_EAST); +} + +void Scene203::handleBrieConversation() { + bool interlocutorFl = false; + bool heroFl = false; + + switch (_action._activeAction._verbId) { + case 9: + case 12: + case 35: + case 42: + _vm->_gameConv->setInterlocutorTrigger(70); + interlocutorFl = true; + heroFl = true; + break; + + case 14: + if (!_game._trigger) { + _vm->_gameConv->hold(); + _raoulStatus = 5; + } + break; + + case 17: + _raoulStatus = 0; + _vm->_gameConv->hold(); + break; + + case 24: + _vm->_gameConv->setInterlocutorTrigger(78); + interlocutorFl = true; + break; + + case 20: + case 25: + _vm->_gameConv->setInterlocutorTrigger(76); + interlocutorFl = true; + break; + + case 37: + if (!_game._trigger) { + _vm->_gameConv->hold(); + if (_vm->_sound->_preferRoland) + _vm->_sound->command(65); + else + _scene->playSpeech(1); + + _scene->_sequences.addTimer(60, 110); + } + break; + + case 41: + _globals[kDoneBrieConv203] = 1; + _globals[kChrisFStatus] = 0; + break; + + case 44: + if (!_game._trigger) { + _vm->_gameConv->hold(); + _raoulStatus = 3; + } + break; + + default: + break; + } + + switch (_game._trigger) { + case 60: + _brieStatus = 0; + break; + + case 65: + _brieStatus = 4; + break; + + case 70: + _vm->_gameConv->setHeroTrigger(71); + interlocutorFl = true; + heroFl = true; + break; + + case 71: + _raoulStatus = 2; + break; + + case 74: + _vm->_gameConv->hold(); + _raoulStatus = 3; + break; + + case 76: + _brieStatus = 1; + break; + + case 78: + _brieStatus = 2; + break; + + case 110: + _vm->_gameConv->release(); + break; + + default: + break; + } + + if (!heroFl && (_raoulStatus != 5)) + _vm->_gameConv->setHeroTrigger(65); + + if (!interlocutorFl) + _vm->_gameConv->setInterlocutorTrigger(60); + + _brieCount = 0; + _raoulCount = 0; +} + +void Scene203::handleRichardConversation() { + bool interlocutorFl = false; + bool heroFl = false; + + switch (_action._activeAction._verbId) { + case 4: + _vm->_gameConv->setInterlocutorTrigger(83); + interlocutorFl = true; + break; + + case 5: + case 15: + case 20: + case 21: + case 27: + _vm->_gameConv->setInterlocutorTrigger(70); + interlocutorFl = true; + heroFl = true; + break; + + case 7: + if (_game._objects.isInRoom(OBJ_NOTICE) && !_game._trigger) { + _vm->_gameConv->hold(); + _raoulStatus = 3; + } + break; + + case 9: + if (_game._objects.isInRoom(OBJ_LETTER) && !_game._trigger) { + _vm->_gameConv->hold(); + _raoulStatus = 4; + } + break; + + case 17: + _vm->_gameConv->setInterlocutorTrigger(85); + interlocutorFl = true; + break; + + case 19: + _vm->_gameConv->setInterlocutorTrigger(81); + interlocutorFl = true; + break; + + default: + break; + } + + switch (_game._trigger) { + case 65: + _richardStatus = 4; + break; + + case 70: + _vm->_gameConv->setHeroTrigger(71); + interlocutorFl = true; + heroFl = true; + break; + + case 71: { + _raoulStatus = 2; + int *val1 = _vm->_gameConv->getVariable(24); + int *val2 = _vm->_gameConv->getVariable(26); + if ((*val1) && (*val2)) { + _globals[kDoneRichConv203] = true; + _globals[kMadameGiryShowsUp] = true; + } + } + break; + + case 74: + _vm->_gameConv->hold(); + _raoulStatus = 3; + break; + + case 81: + _richardStatus = 2; + break; + + case 83: + _richardStatus = 1; + break; + + case 85: + _richardStatus = 3; + break; + + case 100: + _richardStatus = 0; + break; + + default: + break; + } + + if (!heroFl && (_raoulStatus != 5)) + _vm->_gameConv->setHeroTrigger(65); + + if (!interlocutorFl) + _vm->_gameConv->setInterlocutorTrigger(100); + + _brieCount = 0; + _raoulCount = 0; +} + +void Scene203::handleRichardAndDaaeConversation() { + bool interlocutorFl = false; + bool heroFl = false; + + switch (_action._activeAction._verbId) { + case 5: + if (!_game._trigger) { + _vm->_gameConv->hold(); + + _vm->_sound->command(24); + _scene->deleteSequence(_globals._sequenceIndexes[5]); + _globals._sequenceIndexes[5] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[5], false, 8, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[5], 1); + _scene->_sequences.setAnimRange(_globals._sequenceIndexes[5], -1, -2); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[5], SEQUENCE_TRIGGER_EXPIRE, 0, 90); + interlocutorFl = true; + heroFl = true; + } + break; + + case 11: + if (!_game._trigger) { + _vm->_gameConv->hold(); + _daaeStatus = 3; + } + break; + + case 13: + case 14: + case 15: + _globals[kChristineDoorStatus] = 1; + _globals[kTicketPeoplePresent] = 2; + heroFl = true; + interlocutorFl = true; + _vm->_gameConv->setInterlocutorTrigger(115); + break; + + default: + break; + } + + switch (_game._trigger) { + case 65: + if (_globals[kWalkerConverse] != 0) + _globals[kWalkerConverse] = _vm->getRandomNumber(2, 3); + + if ((_richardStatus != 5) && (_richardStatus != 7)) + _richardStatus = 4; + + _conversationCount = 0; + break; + + case 90: + _globals._sequenceIndexes[5] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[5], false, -2); + _scene->_sequences.setDepth(_globals._sequenceIndexes[5], 1); + _globals._animationIndexes[3] = _scene->loadAnimation(formAnimName('d', 1), 0); + _anim3ActvFl = true; + _daaeStatus = 0; + break; + + case 100: + if (_globals[kWalkerConverse] != 0) + _globals[kWalkerConverse] = _vm->getRandomNumber(1, 4); + + if ((_action._activeAction._verbId == 7) || (_action._activeAction._verbId == 9)) + _daaeStatus = 1; + else if (_richardStatus == 7) + _richardStatus = 5; + else if (_richardStatus != 5) + _richardStatus = 0; + + break; + + case 115: + _globals[kWalkerConverse] = 0; + heroFl = true; + interlocutorFl = true; + break; + + default: + break; + } + + if (!heroFl) + _vm->_gameConv->setHeroTrigger(65); + + if (!interlocutorFl) + _vm->_gameConv->setInterlocutorTrigger(100); + + _brieCount = 0; + _raoulCount = 0; +} + +void Scene203::handleBrieAnimation() { + if (_scene->_animation[_globals._animationIndexes[0]]->getCurrentFrame() == _brieFrame) + return; + + _brieFrame = _scene->_animation[_globals._animationIndexes[0]]->getCurrentFrame(); + int resetFrame = -1; + int random = -1; + + switch (_brieFrame) { + case 1: + case 2: + case 4: + case 11: + case 22: + case 31: + case 35: + case 29: + random = _vm->getRandomNumber(6, 45); + + switch (_brieStatus) { + case 0: + random = _vm->getRandomNumber(1, 2); + ++_brieCount; + if (_brieCount > 20) { + _brieStatus = 4; + random = 45; + } + break; + + case 1: + random = 5; + break; + + case 2: + random = 4; + break; + + case 3: + random = 3; + _brieStatus = 0; + break; + + default: + break; + } + + switch (random) { + case 1: + resetFrame = 0; + break; + + case 2: + resetFrame = 1; + break; + + case 3: + resetFrame = 2; + break; + + case 4: + resetFrame = 22; + _brieStatus = 0; + break; + + case 5: + resetFrame = 13; + break; + + case 6: + resetFrame = 4; + break; + + case 7: + resetFrame = 29; + break; + + case 8: + resetFrame = 31; + break; + + default: + resetFrame = 0; + break; + } + break; + + case 30: + random = _vm->getRandomNumber(1, 45); + + switch (_brieStatus) { + case 0: + case 1: + case 2: + case 3: + random = 1; + break; + } + + if (random == 1) + resetFrame = 30; + else + resetFrame = 29; + + break; + + case 8: + random = _vm->getRandomNumber(1, 45); + + switch (_brieStatus) { + case 0: + case 1: + case 2: + case 3: + random = 3; + break; + } + + switch (random) { + case 1: + resetFrame = 11; + break; + + case 2: + resetFrame = 12; + break; + + case 3: + resetFrame = 8; + break; + + default: + resetFrame = 7; + break; + } + break; + + case 12: + random = _vm->getRandomNumber(1, 45); + + switch (_brieStatus) { + case 0: + case 1: + case 2: + case 3: + random = 1; + break; + } + + if (random == 1) + resetFrame = 7; + else + resetFrame = 11; + + break; + + case 13: + random = _vm->getRandomNumber(1, 45); + + switch (_brieStatus) { + case 0: + case 1: + case 2: + case 3: + random = 1; + break; + } + + if (random == 1) + resetFrame = 7; + else + resetFrame = 12; + + break; + + case 17: + case 18: + switch (_brieStatus) { + case 0: + case 2: + case 3: + random = 3; + break; + case 1: + random = _vm->getRandomNumber(1, 2); + ++_brieCount; + if (_brieCount > 20) { + _brieStatus = 4; + random = 3; + } + break; + + default: + break; + } + + switch (random) { + case 1: + resetFrame = 16; + break; + + case 2: + resetFrame = 17; + break; + + case 3: + resetFrame = 18; + break; + + default: + break; + } + break; + + case 33: + case 40: + random = _vm->getRandomNumber(1, 45); + + switch (_brieStatus) { + case 0: + case 1: + case 2: + case 3: + random = 1; + break; + } + + switch (random) { + case 1: + resetFrame = 33; + break; + + case 2: + resetFrame = 35; + break; + + default: + resetFrame = 32; + break; + } + break; + + case 38: + random = _vm->getRandomNumber(1, 45); + + switch (_brieStatus) { + case 0: + case 1: + case 2: + case 3: + random = 1; + break; + } + + if (random == 1) + resetFrame = 38; + else + resetFrame = 37; + + break; + } + + if (resetFrame >= 0) { + _scene->setAnimFrame(_globals._animationIndexes[0], resetFrame); + _brieFrame = resetFrame; + } +} + +void Scene203::handleRichardAnimation() { + if (_scene->_animation[_globals._animationIndexes[2]]->getCurrentFrame() == _richardFrame) + return; + + _richardFrame = _scene->_animation[_globals._animationIndexes[2]]->getCurrentFrame(); + int resetFrame = -1; + int random = -1; + + switch (_richardFrame) { + case 1: + case 2: + case 3: + case 7: + case 15: + case 25: + case 37: + case 53: + case 59: + case 63: + case 67: + case 69: + case 79: + case 87: + case 108: + random = _vm->getRandomNumber(8, 45); + + switch (_richardStatus) { + case 0: + random = _vm->getRandomNumber(1, 3); + ++_brieCount; + if (_brieCount > 20) { + _richardStatus = 4; + random = 45; + } + break; + + case 1: + random = 4; + _richardStatus = 0; + break; + + case 2: + random = 5; + _richardStatus = 0; + break; + + case 3: + random = 6; + _richardStatus = 0; + break; + + case 5: + random = 7; + break; + + default: + break; + } + + switch (random) { + case 1: + resetFrame = 0; + break; + + case 2: + resetFrame = 1; + break; + + case 3: + resetFrame = 2; + break; + + case 4: + resetFrame = 69; + break; + + case 5: + resetFrame = 53; + _richardStatus = 0; + break; + + case 6: + resetFrame = 42; + break; + + case 7: + resetFrame = 87; + break; + + case 8: + resetFrame = 25; + break; + + case 9: + resetFrame = 15; + break; + + case 10: + resetFrame = 3; + break; + + case 11: + resetFrame = 7; + break; + + case 12: + resetFrame = 59; + break; + + case 13: + resetFrame = 63; + break; + + case 14: + resetFrame = 67; + break; + + case 15: + resetFrame = 79; + break; + + default: + resetFrame = 0; + break; + } + break; + + case 5: + random = _vm->getRandomNumber(1, 45); + + switch (_richardStatus) { + case 0: + case 1: + case 2: + case 3: + case 5: + random = 1; + break; + } + + if (random == 1) + resetFrame = 5; + else + resetFrame = 4; + + break; + + case 11: + random = _vm->getRandomNumber(1, 45); + + switch (_richardStatus) { + case 0: + case 1: + case 2: + case 3: + case 5: + random = 1; + break; + } + + if (random == 1) + resetFrame = 11; + else + resetFrame = 10; + + break; + + case 61: + random = _vm->getRandomNumber(1, 45); + + switch (_richardStatus) { + case 0: + case 1: + case 2: + case 3: + case 5: + random = 1; + break; + } + + if (random == 1) + resetFrame = 61; + else + resetFrame = 60; + + break; + + case 65: + random = _vm->getRandomNumber(1, 45); + + switch (_richardStatus) { + case 0: + case 1: + case 2: + case 3: + case 5: + random = 1; + break; + } + + if (random == 1) + resetFrame = 65; + else + resetFrame = 64; + + break; + + case 68: + random = _vm->getRandomNumber(1, 45); + + switch (_richardStatus) { + case 0: + case 1: + case 2: + case 3: + case 5: + random = 1; + break; + } + + if (random == 1) + resetFrame = 68; + else + resetFrame = 67; + + break; + + case 83: + random = _vm->getRandomNumber(1, 45); + + switch (_richardStatus) { + case 0: + case 1: + case 2: + case 3: + case 5: + random = 1; + break; + } + + if (random == 1) + resetFrame = 83; + else + resetFrame = 82; + + break; + + case 92: + _vm->_gameConv->release(); + break; + + case 93: + case 94: + case 95: + if (_richardStatus == 5) { + random = _vm->getRandomNumber(1, 3); + ++_brieCount; + if (_brieCount > 20) { + _richardStatus = 7; + random = 4; + } + } else + random = 4; + + switch (random) { + case 1: + resetFrame = 92; + break; + + case 2: + resetFrame = 93; + break; + + case 3: + resetFrame = 94; + break; + + case 4: + resetFrame = 95; + break; + } + break; + + case 100: + case 101: + case 102: + switch (_richardStatus) { + case 5: + random = _vm->getRandomNumber(1, 3); + ++_brieCount; + if (_brieCount > 20) { + _richardStatus = 7; + random = 1; + } + break; + + case 7: + random = 1; + break; + + default: + random = 4; + break; + } + + switch (random) { + case 1: + resetFrame = 99; + break; + + case 2: + resetFrame = 100; + break; + + case 3: + resetFrame = 101; + break; + + case 4: + resetFrame = 102; + break; + + default: + break; + } + break; + + case 31: + random = _vm->getRandomNumber(1, 45); + + switch (_richardStatus) { + case 0 : + case 1: + case 2: + case 3: + case 5: + random = 1; + break; + } + + if (random == 1) + resetFrame = 31; + else + resetFrame = 30; + + break; + } + + if (resetFrame >= 0) { + _scene->setAnimFrame(_globals._animationIndexes[2], resetFrame); + _richardFrame = resetFrame; + } +} + +void Scene203::handleRaoulAnimation() { + if (_scene->_animation[_globals._animationIndexes[1]]->getCurrentFrame() == _raoulFrame) + return; + + _raoulFrame = _scene->_animation[_globals._animationIndexes[1]]->getCurrentFrame(); + int resetFrame = -1; + int random = -1; + + switch (_raoulFrame) { + case 9: + case 21: + case 57: + _vm->_gameConv->release(); + break; + + case 10: + case 22: + case 30: + case 34: + case 58: + if (_raoulFrame == 22) + _raoulStatus = 0; + + random = _vm->getRandomNumber(5, 45); + + switch (_raoulStatus) { + case 1: + random = 1; + break; + + case 2: + _game._player._stepEnabled = false; + random = 2; + break; + + case 3: + case 5: + random = 3; + break; + + case 4: + random = 4; + break; + + default: + random = _vm->getRandomNumber(5, 100); + break; + } + + switch (random) { + case 1: + resetFrame = 22; + break; + + case 2: + resetFrame = 34; + break; + + case 3: + resetFrame = 10; + break; + + case 4: + resetFrame = 45; + break; + + case 5: + resetFrame = 30; + break; + + default: + resetFrame = 9; + break; + } + break; + + case 16: + switch (_raoulStatus) { + case 3: + random = 1; + break; + + case 0: + case 2: + random = 2; + break; + + case 5: + random = 3; + break; + + default: + break; + } + + switch (random) { + case 1: + if (_globals[kCurrentYear] == 1881) { + resetFrame = 16; + _scene->deleteSequence(_globals._sequenceIndexes[1]); + _scene->_hotspots.activate(NOUN_NOTICE, false); + _game._objects.addToInventory(OBJ_NOTICE); + _vm->_sound->command(26); + _scene->_speechReady = -1; + _vm->_dialogs->showItem(OBJ_NOTICE, 814, 5); + _raoulStatus = 0; + } else { + resetFrame = 16; + _scene->deleteSequence(_globals._sequenceIndexes[1]); + _scene->_hotspots.activate(NOUN_PARCHMENT, false); + _game._objects.addToInventory(OBJ_PARCHMENT); + _vm->_sound->command(26); + _scene->_speechReady = -1; + _vm->_dialogs->showItem(OBJ_PARCHMENT, 812, 3); + _raoulStatus = 0; + } + break; + + case 2: + if (_showNoteFl) { + _scene->deleteSequence(_globals._sequenceIndexes[2]); + _showNoteFl = false; + } + break; + + default: + if (!_showNoteFl) { + _globals._sequenceIndexes[2] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[1], true, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[2], 3); + _vm->_gameConv->release(); + _showNoteFl = true; + } + resetFrame = 15; + break; + } + break; + + case 26: + random = _vm->getRandomNumber(1, 45); + + switch (_raoulStatus) { + case 0: + case 2: + case 3: + case 4: + case 5: + random = 1; + break; + + case 1: + random = 2; + break; + } + + if (random == 1) + resetFrame = 26; + else + resetFrame = 25; + + break; + + case 45: + _anim1ActvFl = false; + _game._player._visible = true; + _game._player._stepEnabled = true; + _game.syncTimers(SYNC_PLAYER, 0, SYNC_ANIM, _globals._animationIndexes[1]); + resetFrame = 58; + if (_globals[kDoneBrieConv203] && (_globals[kCurrentYear] == 1993)) { + _globals[kPrompterStandStatus] = 1; + _scene->_nextSceneId = 150; + } + break; + + case 52: + _scene->deleteSequence(_globals._sequenceIndexes[3]); + _scene->_hotspots.activate(NOUN_LETTER, false); + _game._objects.addToInventory(OBJ_LETTER); + _vm->_sound->command(26); + _scene->_speechReady = -1; + _vm->_dialogs->showItem(OBJ_LETTER, 813, 4); + _raoulStatus = 0; + break; + + default: + break; + } + + if (resetFrame >= 0) { + _scene->setAnimFrame(_globals._animationIndexes[1], resetFrame); + _raoulFrame = resetFrame; + } +} + +void Scene203::handleDaaeAnimation() { + if (_scene->_animation[_globals._animationIndexes[3]]->getCurrentFrame() == _daaeFrame) + return; + + _daaeFrame = _scene->_animation[_globals._animationIndexes[3]]->getCurrentFrame(); + int resetFrame = -1; + int random = -1; + + switch (_daaeFrame) { + case 20: + _vm->_gameConv->release(); + _richardStatus = 5; + break; + + case 175: + _richardStatus = 4; + break; + + case 198: + _vm->_gameConv->release(); + break; + + case 201: + _scene->_sequences.addTimer(1, 95); + break; + + case 76: + case 92: + case 102: + case 123: + switch (_daaeStatus) { + case 1: + random = _vm->getRandomNumber(1, 2); + _daaeStatus = 2; + break; + + case 2: + random = 3; + _daaeStatus = 0; + break; + + case 3: + random = 4; + break; + + default: + random = 5; + break; + } + + switch (random) { + case 1: + resetFrame = 79; + break; + + case 2: + resetFrame = 92; + break; + + case 3: + resetFrame = 102; + break; + + case 4: + resetFrame = 123; + break; + + case 5: + resetFrame = 75; + break; + + default: + break; + } + break; + } + + if (resetFrame >= 0) { + _scene->setAnimFrame(_globals._animationIndexes[3], resetFrame); + _daaeFrame = resetFrame; + } +} + +/*------------------------------------------------------------------------*/ + +Scene204::Scene204(MADSEngine *vm) : Scene2xx(vm) { + _anim0ActvFl = false; + _anim1ActvFl = false; + _anim2ActvFl = false; + _anim3ActvFl = false; + _raoulDown = false; + _florentGone = false; + _skip1Fl = false; + _skip2Fl = false; + _skip3Fl = false; + _endGameFl = false; + + _brieStatus = -1; + _brieFrame = -1; + _florStatus = -1; + _florFrame = -1; + _raoulStatus = -1; + _raoulFrame = -1; + _raoulCount = -1; +} + +void Scene204::synchronize(Common::Serializer &s) { + Scene2xx::synchronize(s); + + s.syncAsByte(_anim0ActvFl); + s.syncAsByte(_anim1ActvFl); + s.syncAsByte(_anim2ActvFl); + s.syncAsByte(_anim3ActvFl); + s.syncAsByte(_raoulDown); + s.syncAsByte(_florentGone); + s.syncAsByte(_skip1Fl); + s.syncAsByte(_skip2Fl); + s.syncAsByte(_skip3Fl); + s.syncAsByte(_endGameFl); + + s.syncAsSint16LE(_brieStatus); + s.syncAsSint16LE(_brieFrame); + s.syncAsSint16LE(_florStatus); + s.syncAsSint16LE(_florFrame); + s.syncAsSint16LE(_raoulStatus); + s.syncAsSint16LE(_raoulFrame); + s.syncAsSint16LE(_raoulCount); +} + +void Scene204::setup() { + if ((_globals[kCurrentYear] == 1993) || _globals[kRightDoorIsOpen504]) + _scene->_variant = 1; + + setPlayerSpritesPrefix(); + setAAName(); +} + +void Scene204::enter() { + _skip3Fl = false; + + if (_scene->_priorSceneId != RETURNING_FROM_LOADING) { + _anim0ActvFl = false; + _anim1ActvFl = false; + _anim2ActvFl = false; + _anim3ActvFl = false; + _florentGone = false; + _skip1Fl = false; + _skip2Fl = false; + _endGameFl = false; + _raoulDown = true; + } + + if (_globals[kTicketPeoplePresent] == 2) + _globals[kMakeRichLeave203] = true; + + if (_globals[kRightDoorIsOpen504]) + _endGameFl = true; + + warning("TODO: If end of game, remove the walking areas"); + + _scene->_hotspots.activate(NOUN_BOOK, false); + _vm->_gameConv->get(22); + + _globals._spriteIndexes[2] = _scene->_sprites.addSprites(formAnimName('p', 0)); + _globals._spriteIndexes[3] = _scene->_sprites.addSprites(formAnimName('x', 6)); + _globals._spriteIndexes[4] = _scene->_sprites.addSprites("*RALRH_9"); + _globals._spriteIndexes[5] = _scene->_sprites.addSprites("*RDRR_6"); + + if (_game._objects.isInRoom(OBJ_BOOK) || (_globals[kCurrentYear] == 1881) || _endGameFl) { + _globals._sequenceIndexes[2] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[2], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[2], 5); + if (_globals[kScannedBookcase] && (_globals[kCurrentYear] == 1993)) + _scene->_hotspots.activate(NOUN_BOOK, true); + } + + if ((_globals[kCurrentYear] == 1993) || _endGameFl) { + _globals._spriteIndexes[0] = _scene->_sprites.addSprites(formAnimName('z', -1)); + _scene->drawToBackground(_globals._spriteIndexes[0], 1, Common::Point(-32000, -32000), 0, 100); + _scene->_sprites.remove(_globals._spriteIndexes[0]); + _scene->_hotspots.activate(NOUN_CANDLE, false); + _scene->_hotspots.activate(NOUN_BUST, false); + _scene->_hotspots.activate(NOUN_COFFEE_TABLE, false); + + int idx = _scene->_dynamicHotspots.add(NOUN_COFFEE_TABLE, VERB_WALK_TO, SYNTAX_SINGULAR, EXT_NONE, Common::Rect(83, 140, 83 + 45, 140 + 12)); + _scene->_dynamicHotspots.setPosition(idx, Common::Point(84, 150), FACING_SOUTHEAST); + + idx = _scene->_dynamicHotspots.add(NOUN_GRAND_FOYER, VERB_EXIT_TO, SYNTAX_SINGULAR, EXT_NONE, Common::Rect(199, 147, 199 + 52, 147 + 8)); + _scene->_dynamicHotspots.setPosition(idx, Common::Point(224, 152), FACING_SOUTH); + _scene->_dynamicHotspots.setCursor(idx, CURSOR_GO_DOWN); + + idx = _scene->_dynamicHotspots.add(NOUN_GRAND_FOYER, VERB_EXIT_TO, SYNTAX_SINGULAR, EXT_NONE, Common::Rect(145, 147, 145 + 54, 147 + 8)); + _scene->_dynamicHotspots.setPosition(idx, Common::Point(175, 152), FACING_SOUTH); + _scene->_dynamicHotspots.setCursor(idx, CURSOR_GO_DOWN); + } else { + _scene->_hotspots.activate(NOUN_LIGHT, false); + _scene->_hotspots.activate(NOUN_GLASS_CASE, false); + + int idx = _scene->_dynamicHotspots.add(NOUN_COMFY_CHAIR, VERB_WALK_TO, SYNTAX_SINGULAR, EXT_NONE, Common::Rect(220, 147, 220 + 6, 147 + 8)); + _scene->_dynamicHotspots.setPosition(idx, Common::Point(220, 150), FACING_SOUTHEAST); + + idx = _scene->_dynamicHotspots.add(NOUN_COMFY_CHAIR, VERB_WALK_TO, SYNTAX_SINGULAR, EXT_NONE, Common::Rect(226, 134, 226 + 12, 134 + 21)); + _scene->_dynamicHotspots.setPosition(idx, Common::Point(220, 150), FACING_SOUTHEAST); + + idx = _scene->_dynamicHotspots.add(NOUN_COMFY_CHAIR, VERB_WALK_TO, SYNTAX_SINGULAR, EXT_NONE, Common::Rect(238, 128, 238 + 13, 128 + 27)); + _scene->_dynamicHotspots.setPosition(idx, Common::Point(220, 150), FACING_SOUTHEAST); + + idx = _scene->_dynamicHotspots.add(NOUN_GRAND_FOYER, VERB_EXIT_TO, SYNTAX_SINGULAR, EXT_NONE, Common::Rect(199, 147, 199 + 19, 147 + 8)); + _scene->_dynamicHotspots.setPosition(idx, Common::Point(209, 152), FACING_SOUTH); + _scene->_dynamicHotspots.setCursor(idx, CURSOR_GO_DOWN); + + idx = _scene->_dynamicHotspots.add(NOUN_GRAND_FOYER, VERB_EXIT_TO, SYNTAX_SINGULAR, EXT_NONE, Common::Rect(84, 147, 84 + 61, 147 + 8)); + _scene->_dynamicHotspots.setPosition(idx, Common::Point(115, 152), FACING_SOUTH); + _scene->_dynamicHotspots.setCursor(idx, CURSOR_GO_DOWN); + } + + if ((_scene->_priorSceneId == 306) || (_endGameFl)) { + _globals._spriteIndexes[6] = _scene->_sprites.addSprites(formAnimName('f', 0)); + _scene->drawToBackground(_globals._spriteIndexes[6], 1, Common::Point(-32000, -32000), 0, 100); + } else if (_globals[kCurrentYear] == 1993) { + _globals._spriteIndexes[1] = _scene->_sprites.addSprites(formAnimName('f', 1)); + _scene->drawToBackground(_globals._spriteIndexes[1], 1, Common::Point(-32000, -32000), 0, 100); + _scene->_sprites.remove(_globals._spriteIndexes[1]); + } + + if (_scene->_priorSceneId == RETURNING_FROM_LOADING) { + if (_endGameFl) { + _game.loadQuoteSet(0x75, 0); + + _globals._animationIndexes[2] = _scene->loadAnimation(formAnimName('r', 1), 0); + _anim2ActvFl = true; + + if (_florentGone) { + _scene->setAnimFrame(_globals._animationIndexes[2], 9); + _raoulStatus = 1; + } else { + _scene->setAnimFrame(_globals._animationIndexes[2], 32); + _raoulStatus = 4; + } + + _globals._animationIndexes[0] = _scene->loadAnimation(formAnimName('m', 1), 0); + _anim0ActvFl = true; + _brieStatus = 2; + + _globals._animationIndexes[1] = _scene->loadAnimation(formAnimName('f', 1), 0); + _anim1ActvFl = true; + _florStatus = 2; + + if (_florentGone) + _scene->setAnimFrame(_globals._animationIndexes[1], 172); + else if (!_raoulDown) + _scene->setAnimFrame(_globals._animationIndexes[1], 21); + + _game._player._visible = false; + _vm->_gameConv->run(22); + _vm->_gameConv->exportPointer(&_globals[kPlayerScore]); + } else { + _globals._sequenceIndexes[3] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[3], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[3], 5); + } + } else if (_scene->_priorSceneId == 202) { + _globals._sequenceIndexes[3] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[3], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[3], 5); + if (_globals[kCurrentYear] == 1993) + _game._player._playerPos = Common::Point(175, 145); + else + _game._player._playerPos = Common::Point(115, 147); + + _game._player._facing = FACING_NORTHWEST; + } else if (_scene->_priorSceneId == 150) { + int size = _game._objects.size(); + for (int i = 0; i < size; i++) + _game._objects.setRoom(i, 1); + + _game.loadQuoteSet(0x75, 0); + + _globals._animationIndexes[2] = _scene->loadAnimation(formAnimName('r', 1), 0); + _anim2ActvFl = true; + _raoulStatus = 4; + _scene->setAnimFrame(_globals._animationIndexes[2], 32); + + _globals._animationIndexes[0] = _scene->loadAnimation(formAnimName('m', 1), 0); + _anim0ActvFl = true; + _brieStatus = 2; + + _globals._animationIndexes[1] = _scene->loadAnimation(formAnimName('f', 1), 0); + _anim1ActvFl = true; + _raoulDown = true; + _florStatus = 2; + + _game._player._visible = false; + _endGameFl = true; + + _vm->_gameConv->run(22); + _vm->_gameConv->exportPointer(&_globals[kPlayerScore]); + } else if ((_scene->_priorSceneId == 203) || (_scene->_priorSceneId != RETURNING_FROM_LOADING)) { + _game._player.firstWalk(Common::Point(-10, 136), FACING_EAST, Common::Point(30, 140), FACING_EAST, true); + _game._player.setWalkTrigger(70); + _game._player._stepEnabled = false; + } + + sceneEntrySound(); +} + +void Scene204::step() { + if (_anim0ActvFl) + handleBrieAnimation(); + + if (_anim1ActvFl) + handleFlorAnimation(); + + if (_anim2ActvFl) + handleRaoulAnimation(); + + if (_anim3ActvFl) + handleEndAnimation(); + + if (_game._trigger == 85) + _scene->_nextSceneId = 250; + + if ((_vm->_gameConv->_running != 22) && !_skip1Fl && _endGameFl) { + _game._player._stepEnabled = false; + _skip1Fl = true; + } + + if (_game._trigger == 70) { + _globals._sequenceIndexes[3] = _scene->_sequences.addReverseSpriteCycle(_globals._spriteIndexes[3], false, 8, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[3], 10); + _scene->_sequences.setAnimRange(_globals._sequenceIndexes[3], -1, -2); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SEQUENCE_TRIGGER_EXPIRE, 0, 71); + } else if (_game._trigger == 71) { + _vm->_sound->command(25); + _globals._sequenceIndexes[3] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[3], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[3], 5); + _game._player._stepEnabled = true; + } +} + +void Scene204::actions() { + if (_vm->_gameConv->_running == 22) { + handleConversation(); + + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_WALK_THROUGH, NOUN_DOOR) || _action.isAction(VERB_OPEN, NOUN_DOOR)) { + switch (_game._trigger) { + case (0): + _game._player._stepEnabled = false; + _game._player._visible = false; + _globals._sequenceIndexes[5] = _scene->_sequences.startPingPongCycle(_globals._spriteIndexes[5], true, 5, 2); + _scene->_sequences.setAnimRange(_globals._sequenceIndexes[5], 1, 4); + _scene->_sequences.setSeqPlayer(_globals._sequenceIndexes[5], true); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[5], SEQUENCE_TRIGGER_SPRITE, 4, 60); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[5], SEQUENCE_TRIGGER_EXPIRE, 0, 61); + break; + + case 60: + _vm->_sound->command(24); + _scene->deleteSequence(_globals._sequenceIndexes[3]); + _globals._sequenceIndexes[3] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[3], false, 8, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[3], 14); + _scene->_sequences.setAnimRange(_globals._sequenceIndexes[3], -1, -2); + break; + + case 61: + _game._player._visible = true; + _game.syncTimers(SYNC_PLAYER, 0, SYNC_SEQ, _globals._sequenceIndexes[5]); + _game._player.walk(Common::Point(0, 136), FACING_WEST); + _game._player.setWalkTrigger(62); + break; + + case 62: + _scene->_nextSceneId = 203; + break; + + default: + break; + } + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_TAKE, NOUN_BOOK) && (_game._objects.isInRoom(OBJ_BOOK) || _game._trigger)) { + switch (_game._trigger) { + case (0): + _game._player._stepEnabled = false; + _game._player._visible = false; + _globals._sequenceIndexes[4] = _scene->_sequences.startPingPongCycle(_globals._spriteIndexes[4], false, 5, 2); + _scene->_sequences.setAnimRange(_globals._sequenceIndexes[4], -1, -2); + _scene->_sequences.setSeqPlayer(_globals._sequenceIndexes[4], true); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[4], SEQUENCE_TRIGGER_SPRITE, 8, 1); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[4], SEQUENCE_TRIGGER_EXPIRE, 0, 2); + break; + + case 1: + _scene->deleteSequence(_globals._sequenceIndexes[2]); + _scene->_hotspots.activate(NOUN_BOOK, false); + _game._objects.addToInventory(OBJ_BOOK); + _vm->_sound->command(26); + break; + + case 2: + _game.syncTimers(SYNC_PLAYER, 0, SYNC_SEQ, _globals._sequenceIndexes[4]); + _game._player._visible = true; + _scene->_sequences.addTimer(20, 3); + break; + + case 3: + _vm->_dialogs->showItem(OBJ_BOOK, 815, 0); + _globals[kReadBook] = true; + _globals[kPlayerScore] += 5; + _game._player._stepEnabled = true; + break; + + default: + break; + } + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_EXIT_TO, NOUN_GRAND_FOYER)) { + _scene->_nextSceneId = 202; + _action._inProgress = false; + return; + } + + if (_action._lookFlag) { + _vm->_dialogs->show(20410); + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_LOOK) || _action.isAction(VERB_LOOK_AT)) { + if (_action.isObject(NOUN_WALL)) { + _vm->_dialogs->show(20411); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_FLOOR)) { + _vm->_dialogs->show(20412); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_RUG)) { + _vm->_dialogs->show(20413); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_GLASS_CASE)) { + _vm->_dialogs->show(20414); + _globals[kLookedAtCase] = true; + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_CEILING)) { + if (_globals[kSandbagStatus] == 0) + _vm->_dialogs->show(20429); + else + _vm->_dialogs->show(20416); + + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_BOOKCASE)) { + if (_globals[kCanFindBookInLibrary] && (_globals[kCurrentYear] == 1993)) { + if ((_scene->_customDest.x < 46) && !_game._objects.isInInventory(OBJ_BOOK)) { + if (!_globals[kScannedBookcase]) { + _vm->_dialogs->show(20433); + _scene->_hotspots.activate(NOUN_BOOK, true); + _globals[kScannedBookcase] = true; + } else { + _vm->_dialogs->show(20437); + } + } else { + _vm->_dialogs->show(20417); + } + } else { + _vm->_dialogs->show(20417); + } + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_SOFA)) { + _vm->_dialogs->show(20418); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_END_TABLE)) { + _vm->_dialogs->show(20419); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_LAMP)) { + _vm->_dialogs->show(20420); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_BUST)) { + _vm->_dialogs->show(20421); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_COFFEE_TABLE)) { + _vm->_dialogs->show(20422); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_COMFY_CHAIR)) { + _vm->_dialogs->show(20423); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_DECORATIVE_VASE )) { + _vm->_dialogs->show(20424); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_PAINTING)) { + _vm->_dialogs->show(20425); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_GRAND_FOYER)) { + _vm->_dialogs->show(20426); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_DOOR)) { + _vm->_dialogs->show(20427); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_WINDOW)) { + _vm->_dialogs->show(20428); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_BOOK) && _game._objects.isInRoom(OBJ_BOOK)) { + _vm->_dialogs->show(20434); + _action._inProgress = false; + return; + } + } + + if (_action.isAction(VERB_TALK_TO, NOUN_BUST)) { + _vm->_dialogs->show(20436); + _action._inProgress = false; + return; + } +} + +void Scene204::preActions() { + if (_action.isAction(VERB_LOOK, NOUN_BOOKCASE)) + _game._player._needToWalk = true; + + if (_action.isAction(VERB_LOOK, NOUN_BOOK) && _game._objects.isInRoom(OBJ_BOOK)) + _game._player._needToWalk = true; + + if (_action.isAction(VERB_OPEN, NOUN_DOOR)) + _game._player.walk(Common::Point(27, 139), FACING_WEST); +} + +void Scene204::handleConversation() { + bool interlocutorFl = false; + bool heroFl = false; + + switch (_action._activeAction._verbId) { + case 6: + case 7: + case 8: + if (_raoulDown) { + _vm->_gameConv->hold(); + _raoulDown = false; + } + break; + + case 17: + if (!_game._trigger) { + _florStatus = 3; + _florentGone = true; + interlocutorFl = true; + heroFl = true; + _vm->_gameConv->hold(); + } + break; + + case 25: + if (!_game._trigger) { + _raoulStatus = 5; + _florStatus = 5; + interlocutorFl = true; + heroFl = true; + _vm->_gameConv->hold(); + } + break; + + case 29: + interlocutorFl = true; + heroFl = true; + if (!_game._trigger) { + _brieStatus = 3; + _vm->_gameConv->hold(); + } + break; + + default: + break; + } + + switch (_game._trigger) { + case 75: + if (_florentGone) { + if (_raoulStatus != 2) + _raoulStatus = 0; + } else + _florStatus = 4; + + break; + + case 80: + if (_florentGone) { + if ((_action._activeAction._verbId != 18) && (_action._activeAction._verbId != 23)) + _brieStatus = 0; + } else { + switch (_action._activeAction._verbId) { + case 1: + case 7: + case 8: + case 9: + case 13: + case 15: + case 19: + case 20: + case 21: + case 22: + _brieStatus = 0; + break; + + default: + _florStatus = 0; + break; + } + } + break; + + default: + break; + } + + if (!heroFl && !_raoulDown) + _vm->_gameConv->setHeroTrigger(75); + + if (!interlocutorFl) + _vm->_gameConv->setInterlocutorTrigger(80); + + _raoulCount = 0; +} + +void Scene204::handleBrieAnimation() { + if (_scene->_animation[_globals._animationIndexes[0]]->getCurrentFrame() == _brieFrame) + return; + + _brieFrame = _scene->_animation[_globals._animationIndexes[0]]->getCurrentFrame(); + int resetFrame = -1; + int random; + + switch (_brieFrame) { + case 80: + _vm->_gameConv->release(); + _raoulStatus = 2; + break; + + case 173: + _game._player._stepEnabled = true; + _vm->_dialogs->show(20430); + _game._player._stepEnabled = false; + break; + + case 174: + _raoulStatus = 3; + resetFrame = 173; + break; + + case 1: + case 22: + case 49: + case 7: + case 13: + case 33: + case 61: + switch (_brieStatus) { + case 0: + random = _vm->getRandomNumber(1, 4); + _brieStatus = 2; + break; + + case 1: + random = 5; + break; + + case 3: + random = 6; + break; + + case 4: + random = 7; + break; + + default: + random = 8; + break; + } + + switch (random) { + case 1: + resetFrame = 1; + _brieStatus = 2; + break; + + case 2: + resetFrame = 7; + _brieStatus = 2; + break; + + case 3: + resetFrame = 22; + _brieStatus = 2; + break; + + case 4: + resetFrame = 49; + _brieStatus = 2; + break; + + case 5: + resetFrame = 13; + _brieStatus = 2; + break; + + case 6: + resetFrame = 61; + break; + + default: + resetFrame = 0; + break; + } + break; + } + + if (resetFrame >= 0) { + _scene->setAnimFrame(_globals._animationIndexes[0], resetFrame); + _brieFrame = resetFrame; + } +} + +void Scene204::handleFlorAnimation() { + if (_scene->_animation[_globals._animationIndexes[1]]->getCurrentFrame() == _florFrame) + return; + + _florFrame = _scene->_animation[_globals._animationIndexes[1]]->getCurrentFrame(); + int resetFrame = -1; + int random; + + switch (_florFrame) { + case 80: + _scene->setAnimFrame(_globals._animationIndexes[2], 1); + _game.syncTimers(SYNC_ANIM, _globals._animationIndexes[2], SYNC_ANIM, _globals._animationIndexes[1]); + _raoulStatus = 1; + break; + + case 86: + _vm->_gameConv->release(); + break; + + case 173: + resetFrame = 172; + break; + + case 1: + case 2: + case 3: + if (_raoulDown) { + random = _vm->getRandomNumber(1, 1000); + if (random < 300) + resetFrame = 0; + else if (random < 600) + resetFrame = 1; + else + resetFrame = 2; + } + break; + + case 21: + case 180: + _vm->_gameConv->release(); + break; + + case 22: + case 50: + case 30: + case 174: + case 175: + case 176: + case 181: + switch (_florStatus) { + case 0: + random = 1; + _florStatus = 2; + break; + + case 1: + random = 2; + _florStatus = 2; + break; + + case 3: + random = 3; + break; + + case 5: + random = 4; + _florStatus = 2; + break; + + case 4: + random = _vm->getRandomNumber(5, 7); + ++_raoulCount; + if (_raoulCount > 17) { + _florStatus = 2; + random = 8; + } + break; + + default: + random = 7; + break; + } + + switch (random) { + case 1: + resetFrame = 22; + break; + + case 2: + resetFrame = 30; + break; + + case 3: + resetFrame = 53; + break; + + case 4: + resetFrame = 176; + break; + + case 5: + resetFrame = 173; + break; + + case 6: + resetFrame = 174; + break; + + case 7: + resetFrame = 175; + break; + + default: + resetFrame = 21; + break; + } + break; + } + + if (resetFrame >= 0) { + _scene->setAnimFrame(_globals._animationIndexes[1], resetFrame); + _florFrame = resetFrame; + } +} + +void Scene204::handleRaoulAnimation() { + if (_scene->_animation[_globals._animationIndexes[2]]->getCurrentFrame() == _raoulFrame) + return; + + _raoulFrame = _scene->_animation[_globals._animationIndexes[2]]->getCurrentFrame(); + int resetFrame = -1; + int random; + + switch (_raoulFrame) { + case 1: + if (_raoulStatus == 4) + resetFrame = 0; + + break; + + case 10: + case 14: + case 20: + case 258: + switch (_raoulStatus) { + case 0: + random = _vm->getRandomNumber(1, 2); + _raoulStatus = 1; + break; + + case 2: + random = 3; + break; + + case 5: + random = 4; + break; + + default: + random = 5; + break; + } + + switch (random) { + case 1: + resetFrame = 10; + _raoulStatus = 1; + break; + + case 2: + resetFrame = 14; + _raoulStatus = 1; + break; + + case 3: + resetFrame = 20; + break; + + case 4: + resetFrame = 253; + _raoulStatus = 1; + break; + + default: + resetFrame = 9; + break; + } + break; + + case 31: + if (_raoulStatus == 3) + resetFrame = 33; + else + resetFrame = 30; + + break; + + case 33: + resetFrame = 32; + break; + + case 114: + _scene->deleteSequence(_globals._sequenceIndexes[2]); + _game._objects.addToInventory(OBJ_BOOK); + break; + + case 213: + _game._player._stepEnabled = true; + _vm->_dialogs->showItem(OBJ_BOOK, 20431, 0); + _game._player._stepEnabled = false; + break; + + case 229: + _game._player._stepEnabled = true; + _vm->_dialogs->showItem(OBJ_BOOK, 20432, 0); + _game._player._stepEnabled = false; + break; + + case 237: + _scene->freeAnimation(_globals._animationIndexes[1]); + _scene->freeAnimation(_globals._animationIndexes[0]); + _anim0ActvFl = false; + _anim1ActvFl = false; + _anim3ActvFl = true; + _globals._animationIndexes[3] = _scene->loadAnimation(formAnimName('e', 1), 0); + _scene->loadSpeech(9); + break; + + case 253: + resetFrame = 244; + break; + + case 257: + _vm->_gameConv->release(); + break; + } + + if (resetFrame >= 0) { + _scene->setAnimFrame(_globals._animationIndexes[2], resetFrame); + _raoulFrame = resetFrame; + } +} + +void Scene204::handleEndAnimation() { + if ((_scene->_animation[_globals._animationIndexes[3]]->getCurrentFrame() == 15) && !_skip3Fl) { + _scene->playSpeech(9); + _skip3Fl = true; + } + + if ((_scene->_animation[_globals._animationIndexes[3]]->getCurrentFrame() == 26) && !_skip2Fl) { + _scene->_sequences.addTimer(300, 85); + _scene->_kernelMessages.add(Common::Point(123, 137), 0x1110, 0, 0, 360, _game.getQuote(0x75)); + _skip2Fl = true; + } + + if (_scene->_animation[_globals._animationIndexes[3]]->getCurrentFrame() == 27) + _scene->setAnimFrame(_globals._animationIndexes[3], 12); +} + +/*------------------------------------------------------------------------*/ + +Scene205::Scene205(MADSEngine *vm) : Scene2xx(vm) { + _anim0ActvFl = false; + _anim1ActvFl = false; + _noConversationHold = false; + _giveTicketFl = false; + + _richardFrame = -1; + _richardStatus = -1; + _richardCount = -1; + _giryFrame = -1; + _giryStatus = -1; + _giryCount = -1; + _conversationCounter = -1; + _lastRandom = -1; +} + +void Scene205::synchronize(Common::Serializer &s) { + Scene2xx::synchronize(s); + + s.syncAsByte(_anim0ActvFl); + s.syncAsByte(_anim1ActvFl); + s.syncAsByte(_noConversationHold); + s.syncAsByte(_giveTicketFl); + + s.syncAsSint16LE(_richardFrame); + s.syncAsSint16LE(_richardStatus); + s.syncAsSint16LE(_richardCount); + s.syncAsSint16LE(_giryFrame); + s.syncAsSint16LE(_giryStatus); + s.syncAsSint16LE(_giryCount); + s.syncAsSint16LE(_conversationCounter); + s.syncAsSint16LE(_lastRandom); +} + +void Scene205::setup() { + setPlayerSpritesPrefix(); + setAAName(); + + if (_globals[kCurrentYear] != 1881) + return; + + if (_globals[kJacquesStatus] == 1) + _scene->_variant = 3; + else if (_globals[kJacquesStatus] == 0) { + if (_globals[kMadameGiryLocation] == 0) + _scene->_variant = 2; + else if (_globals[kMadameGiryLocation] == 1) + _scene->_variant = 1; + } +} + +void Scene205::enter() { + _vm->_disableFastwalk = true; + + if (_globals[kJacquesStatus] != 1) { + _scene->_rails.disableNode(6); + _scene->_rails.disableNode(7); + _scene->_rails.disableNode(8); + _scene->_rails.disableNode(9); + } + + if (_scene->_priorSceneId != RETURNING_FROM_LOADING) { + _lastRandom = -1; + _anim0ActvFl = false; + _anim1ActvFl = false; + } + + _conversationCounter = 0; + _noConversationHold = false; + _giveTicketFl = false; + + _globals._spriteIndexes[0] = _scene->_sprites.addSprites(formAnimName('f', 0)); + _globals._spriteIndexes[1] = _scene->_sprites.addSprites(formAnimName('f', 1)); + _globals._spriteIndexes[2] = _scene->_sprites.addSprites("*RDR_9"); + + _scene->_hotspots.activate(NOUN_MONSIEUR_RICHARD, false); + _scene->_hotspots.activate(NOUN_MADAME_GIRY, false); + _scene->_hotspots.activate(NOUN_WOMAN, false); + + _vm->_gameConv->get(18); + _vm->_gameConv->get(10); + _vm->_gameConv->get(11); + + if (_globals[kCurrentYear] == 1881) { + if ((_globals[kMadameGiryShowsUp]) && (_globals[kJacquesStatus] == 0)) { + _globals._animationIndexes[1] = _scene->loadAnimation(formAnimName('g', 1), 1); + _anim1ActvFl = true; + _giryStatus = 2; + + int idx = _scene->_dynamicHotspots.add(NOUN_MADAME_GIRY, VERB_WALK_TO, SYNTAX_SINGULAR_FEM, EXT_NONE, Common::Rect(0, 0, 0, 0)); + _scene->_dynamicHotspots[idx]._articleNumber = PREP_ON; + _scene->_dynamicHotspots.setPosition(idx, Common::Point(75, 84), FACING_NORTHWEST); + _scene->setDynamicAnim(idx, _globals._animationIndexes[1], 1); + _scene->setDynamicAnim(idx, _globals._animationIndexes[1], 2); + + switch (_globals[kMadameGiryLocation]) { + case 0: + _scene->setAnimFrame(_globals._animationIndexes[1], 138); + _scene->_hotspots.activateAtPos(NOUN_MADAME_GIRY, true, Common::Point(62, 54)); + _scene->_hotspots.activateAtPos(NOUN_MADAME_GIRY, true, Common::Point(62, 66)); + break; + + case 1: + if (_globals[kMadameNameIsKnown] >= 1) { + _scene->_hotspots.activateAtPos(NOUN_MADAME_GIRY, true, Common::Point(113, 44)); + _scene->_hotspots.activateAtPos(NOUN_MADAME_GIRY, true, Common::Point(107, 66)); + } else + _scene->_hotspots.activate(NOUN_WOMAN, true); + + break; + + case 2: + _scene->setAnimFrame(_globals._animationIndexes[1], 273); + _scene->_hotspots.activateAtPos(NOUN_MADAME_GIRY, true, Common::Point(283, 51)); + _scene->_hotspots.activateAtPos(NOUN_MADAME_GIRY, true, Common::Point(289, 62)); + break; + + default: + break; + } + } + + if (_scene->_priorSceneId == RETURNING_FROM_LOADING) { + if (_vm->_gameConv->_restoreRunning == 10) { + int count = 0; + + if (_game._objects.isInInventory(OBJ_RED_FRAME)) + ++count; + if (_game._objects.isInInventory(OBJ_GREEN_FRAME)) + ++count; + if (_game._objects.isInInventory(OBJ_YELLOW_FRAME)) + ++count; + if (_game._objects.isInInventory(OBJ_BLUE_FRAME)) + ++count; + + _vm->_gameConv->run(10); + _vm->_gameConv->exportPointer(&_globals[kPlayerScore]); + _vm->_gameConv->exportValue(_game._difficulty); + + if (count > 2) + _vm->_gameConv->exportValue(1); + else + _vm->_gameConv->exportValue(0); + + _globals[kWalkerConverse] = _vm->getRandomNumber(1, 4); + _noConversationHold = true; + + if (_giryStatus == 4) + _scene->setAnimFrame(_globals._animationIndexes[1], 66); + else + _giryStatus = 2; + } else if (_vm->_gameConv->_restoreRunning == 11) { + _vm->_gameConv->run(11); + _vm->_gameConv->exportValue(_game._objects.isInInventory(OBJ_TICKET)); + _vm->_gameConv->exportValue(0); + _vm->_gameConv->exportValue(0); + _globals[kWalkerConverse] = _vm->getRandomNumber(1, 4); + } + } + } + + if (_scene->_priorSceneId == RETURNING_FROM_LOADING) { + _globals._sequenceIndexes[0] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[0], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[0], 14); + + _globals._sequenceIndexes[1] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[1], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[1], 14); + + if (_globals[kJacquesStatus] == 1) { + _globals._animationIndexes[0] = _scene->loadAnimation(formAnimName('b', 9), 1); + _anim0ActvFl = true; + _richardStatus = 3; + _scene->_hotspots.activate(NOUN_MONSIEUR_RICHARD, true); + + if (_vm->_gameConv->_restoreRunning == 18) { + _globals[kWalkerConverse] = _vm->getRandomNumber(1, 4); + _richardStatus = 3; + _vm->_gameConv->run(18); + _scene->setAnimFrame(_globals._animationIndexes[0], 1); + } + } + } + + if (_scene->_priorSceneId == 206) { + _game._player._playerPos = Common::Point(37, 64); + _game._player._facing = FACING_SOUTH; + _game._player.walk(Common::Point(41, 67), FACING_SOUTH); + _game._player.setWalkTrigger(90); + _game._player._stepEnabled = false; + _globals._sequenceIndexes[1] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[1], false, -1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[1], 14); + _globals._sequenceIndexes[0] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[0], false, -2); + _scene->_sequences.setDepth(_globals._sequenceIndexes[0], 14); + if (_globals[kJacquesStatus] == 1) { + _globals._animationIndexes[0] = _scene->loadAnimation(formAnimName('b', 9), 1); + _anim0ActvFl = true; + _richardStatus = 3; + _scene->_hotspots.activate(NOUN_MONSIEUR_RICHARD, true); + } + } else if (_scene->_priorSceneId == 207) { + _game._player._playerPos = Common::Point(263, 59); + _game._player._facing = FACING_SOUTH; + _game._player.walk(Common::Point(262, 63), FACING_SOUTH); + _game._player.setWalkTrigger(95); + _game._player._stepEnabled = false; + _globals._sequenceIndexes[1] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[1], false, -2); + _scene->_sequences.setDepth(_globals._sequenceIndexes[1], 14); + _globals._sequenceIndexes[0] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[0], false, -1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[0], 14); + } else if (_scene->_priorSceneId == 150) { + _globals._animationIndexes[0] = _scene->loadAnimation(formAnimName('b', 9), 1); + _anim0ActvFl = true; + _richardStatus = 3; + _game._player._playerPos = Common::Point(132, 112); + _game._player._facing = FACING_NORTHWEST; + _globals[kDoorsIn205] = 1; + _globals[kTicketPeoplePresent] = 0; + _globals[kWalkerConverse] = _vm->getRandomNumber(1, 4); + _globals._sequenceIndexes[1] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[1], false, -1); + _globals._sequenceIndexes[0] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[0], false, -1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[1], 14); + _scene->_sequences.setDepth(_globals._sequenceIndexes[0], 14); + _scene->_hotspots.activate(NOUN_MONSIEUR_RICHARD, true); + _vm->_gameConv->run(18); + } else if ((_scene->_priorSceneId == 202) || (_scene->_priorSceneId != RETURNING_FROM_LOADING)) { + if (_globals[kJacquesStatus] == 1) { + _globals._animationIndexes[0] = _scene->loadAnimation(formAnimName('b', 9), 1); + _anim0ActvFl = true; + _richardStatus = 3; + _scene->_hotspots.activate(NOUN_MONSIEUR_RICHARD, true); + } + + _globals._sequenceIndexes[0] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[0], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[0], 14); + + _globals._sequenceIndexes[1] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[1], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[1], 14); + + _game._player.firstWalk(Common::Point(-20, 144), FACING_EAST, Common::Point(19, 144), FACING_NORTHEAST, true); + } + + sceneEntrySound(); +} + +void Scene205::step() { + if (_anim0ActvFl) + handleRichardAnimation(); + + if (_anim1ActvFl) + handleGiryAnimation(); + + if ((_globals[kWalkerConverse] == 2) || (_globals[kWalkerConverse] == 3)) { + ++_conversationCounter; + if (_conversationCounter > 200) + _globals[kWalkerConverse] = _vm->getRandomNumber(1, 4); + } + + if (_giveTicketFl && !_action.isAction(VERB_GIVE)) { + _globals[kWalkerConverse] = 0; + _game._player.walk(Common::Point(_game._player._playerPos.x + 5, _game._player._playerPos.y - 10), FACING_NORTHWEST); + _game._player.setWalkTrigger(100); + _giveTicketFl = false; + } + + switch (_game._trigger) { + case 100: + _game._player._visible = false; + _globals._sequenceIndexes[2] = _scene->_sequences.startPingPongCycle(_globals._spriteIndexes[2], true, 5, 2); + _scene->_sequences.setAnimRange(_globals._sequenceIndexes[2], -1, -2); + _scene->_sequences.setSeqPlayer(_globals._sequenceIndexes[2], true); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SEQUENCE_TRIGGER_EXPIRE, 0, 102); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SEQUENCE_TRIGGER_SPRITE, 4, 101); + break; + + case 101: + _game._objects.setRoom(OBJ_TICKET, NOWHERE); + _giryStatus = 2; + break; + + case 102: + _game.syncTimers(SYNC_PLAYER, 0, SYNC_SEQ, _globals._sequenceIndexes[2]); + _game._player._visible = true; + _game._player._stepEnabled = true; + _vm->_gameConv->release(); + break; + + default: + break; + } + + switch (_game._trigger) { + case 90: + _scene->deleteSequence(_globals._sequenceIndexes[0]); + _globals._sequenceIndexes[0] = _scene->_sequences.addReverseSpriteCycle(_globals._spriteIndexes[0], false, 8, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[0], 14); + _scene->_sequences.setAnimRange(_globals._sequenceIndexes[0], -1, -2); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[0], SEQUENCE_TRIGGER_EXPIRE, 0, 91); + break; + + case 91: + _globals._sequenceIndexes[0] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[0], false, -1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[0], 14); + _vm->_sound->command(25); + _game._player._stepEnabled = true; + break; + + case 95: + _scene->deleteSequence(_globals._sequenceIndexes[1]); + _globals._sequenceIndexes[1] = _scene->_sequences.addReverseSpriteCycle(_globals._spriteIndexes[1], false, 8, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[1], 14); + _scene->_sequences.setAnimRange(_globals._sequenceIndexes[1], -1, -2); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[1], SEQUENCE_TRIGGER_EXPIRE, 0, 96); + break; + + case 96: + _globals._sequenceIndexes[1] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[1], false, -1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[1], 14); + _vm->_sound->command(25); + _game._player._stepEnabled = true; + break; + + default: + break; + } +} + +void Scene205::actions() { + if (_vm->_gameConv->_running == 18) { + handleConversation18(); + _action._inProgress = false; + return; + } + + if (_vm->_gameConv->_running == 10) { + handleConversation10(); + _action._inProgress = false; + return; + } + + if (_vm->_gameConv->_running == 11) { + handleConversation11(); + _action._inProgress = false; + return; + } + + if ((_action.isAction(VERB_OPEN, NOUN_BOX_FIVE)) || (_action.isAction(VERB_ENTER, NOUN_BOX_FIVE))) { + if (_globals[kTicketPeoplePresent] == 2) { + if (_globals[kMadameGiryLocation] == 2) { + _vm->_gameConv->run(11); + _vm->_gameConv->exportValue(_game._objects.isInInventory(OBJ_TICKET)); + _vm->_gameConv->exportValue(3); + _vm->_gameConv->exportValue(0); + } else { + _vm->_gameConv->run(11); + _vm->_gameConv->exportValue(_game._objects.isInInventory(OBJ_TICKET)); + _vm->_gameConv->exportValue(4); + _vm->_gameConv->exportValue(0); + } + _action._inProgress = false; + return; + } + } + + if (_action.isAction(VERB_WALK_DOWN_STAIRS_TO, NOUN_GRAND_FOYER)) { + if (_globals[kTicketPeoplePresent] == 2) { + if (_globals[kMadameGiryLocation] == 2) { + _vm->_gameConv->run(11); + _vm->_gameConv->exportValue(_game._objects.isInInventory(OBJ_TICKET)); + _vm->_gameConv->exportValue(1); + _vm->_gameConv->exportValue(0); + } else { + _vm->_gameConv->run(11); + _vm->_gameConv->exportValue(_game._objects.isInInventory(OBJ_TICKET)); + _vm->_gameConv->exportValue(2); + _vm->_gameConv->exportValue(0); + } + _action._inProgress = false; + return; + } + } + + if ((_action.isAction(VERB_ENTER)) || (_action.isAction(VERB_OPEN)) || _action.isAction(VERB_UNLOCK) || _action.isAction(VERB_LOCK)) { + if (((_action.isObject(NOUN_BOX_FIVE)) && ((_globals[kDoorsIn205] == 0) || (_globals[kDoorsIn205] == 2)) + || _action.isAction(VERB_UNLOCK) || _action.isAction(VERB_LOCK)) + || ((_action.isObject(NOUN_BOX_NINE)) && ((_globals[kDoorsIn205] == 0) || (_globals[kDoorsIn205] == 1))) + || (_action.isObject(NOUN_BOX_SIX)) || (_action.isObject(NOUN_BOX_SEVEN)) || (_action.isObject(NOUN_BOX_EIGHT))) { + switch (_game._trigger) { + case (0): + _game._player._stepEnabled = false; + _game._player._visible = false; + _globals._sequenceIndexes[2] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[2], false, 5, 1); + _scene->_sequences.setAnimRange(_globals._sequenceIndexes[2], 1, 4); + _scene->_sequences.setSeqPlayer(_globals._sequenceIndexes[2], true); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SEQUENCE_TRIGGER_EXPIRE, 0, 1); + _action._inProgress = false; + return; + + case 1: { + int idx = _globals._sequenceIndexes[2]; + _globals._sequenceIndexes[2] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[2], false, 4); + _game.syncTimers(SYNC_SEQ, _globals._sequenceIndexes[2], SYNC_SEQ, idx); + _scene->_sequences.setSeqPlayer(_globals._sequenceIndexes[2], false); + _vm->_sound->command(72); + _scene->_sequences.addTimer(15, 2); + _action._inProgress = false; + return; + } + + case 2: + _scene->deleteSequence(_globals._sequenceIndexes[2]); + _globals._sequenceIndexes[2] = _scene->_sequences.addReverseSpriteCycle(_globals._spriteIndexes[2], false, 5, 1); + _scene->_sequences.setAnimRange(_globals._sequenceIndexes[2], 1, 4); + _scene->_sequences.setSeqPlayer(_globals._sequenceIndexes[2], false); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SEQUENCE_TRIGGER_EXPIRE, 0, 3); + _action._inProgress = false; + return; + + case 3: + _game.syncTimers(SYNC_PLAYER, 0, SYNC_SEQ, _globals._sequenceIndexes[2]); + _game._player._visible = true; + _game._player._stepEnabled = true; + if (_action.isAction(VERB_UNLOCK) || _action.isAction(VERB_LOCK)) + _vm->_dialogs->show(20528); + else + _vm->_dialogs->show(20527); + + _action._inProgress = false; + return; + + default: + break; + } + } else if (((_action.isObject(NOUN_BOX_FIVE)) && ((_globals[kDoorsIn205] == 3) || (_globals[kDoorsIn205] == 1))) + || ((_action.isObject(NOUN_BOX_NINE)) && ((_globals[kDoorsIn205] == 3) || (_globals[kDoorsIn205] == 2)))) { + switch (_game._trigger) { + case (0): + _game._player._stepEnabled = false; + _game._player._visible = false; + _globals._sequenceIndexes[2] = _scene->_sequences.startPingPongCycle(_globals._spriteIndexes[2], false, 5, 2); + _scene->_sequences.setAnimRange(_globals._sequenceIndexes[2], -1, -2); + _scene->_sequences.setSeqPlayer(_globals._sequenceIndexes[2], true); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SEQUENCE_TRIGGER_EXPIRE, 0, 2); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SEQUENCE_TRIGGER_SPRITE, 4, 80); + _action._inProgress = false; + return; + + case 80: + _vm->_sound->command(24); + if (_action.isObject(NOUN_BOX_FIVE)) { + _scene->deleteSequence(_globals._sequenceIndexes[0]); + _globals._sequenceIndexes[0] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[0], false, 8, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[0], 14); + _scene->_sequences.setAnimRange(_globals._sequenceIndexes[0], -1, -2); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[0], SEQUENCE_TRIGGER_EXPIRE, 0, 81); + } else if (_action.isObject(NOUN_BOX_NINE)) { + _scene->deleteSequence(_globals._sequenceIndexes[1]); + _globals._sequenceIndexes[1] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[1], false, 8, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[1], 14); + _scene->_sequences.setAnimRange(_globals._sequenceIndexes[1], -1, -2); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[1], SEQUENCE_TRIGGER_EXPIRE, 0, 81); + } + _action._inProgress = false; + return; + + case 81: + if (_action.isObject(NOUN_BOX_FIVE)) { + int idx = _globals._sequenceIndexes[0]; + _globals._sequenceIndexes[0] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[0], false, -2); + _game.syncTimers(SYNC_SEQ, _globals._sequenceIndexes[0], SYNC_SEQ, idx); + _scene->_sequences.setDepth(_globals._sequenceIndexes[0], 14); + } else if (_action.isObject(NOUN_BOX_NINE)) { + int idx = _globals._sequenceIndexes[1]; + _globals._sequenceIndexes[1] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[1], false, -2); + _game.syncTimers(SYNC_SEQ, _globals._sequenceIndexes[1], SYNC_SEQ, idx); + _scene->_sequences.setDepth(_globals._sequenceIndexes[1], 14); + } + _action._inProgress = false; + return; + + case 2: + _game._player._visible = true; + _game.syncTimers(SYNC_PLAYER, 0, SYNC_SEQ, _globals._sequenceIndexes[2]); + if (_action.isObject(NOUN_BOX_FIVE)) { + _game._player.walk(Common::Point(37, 64), FACING_NORTH); + _game._player.setWalkTrigger(3); + + } else if (_action.isObject(NOUN_BOX_NINE)) { + _game._player.walk(Common::Point(263, 59), FACING_NORTH); + _game._player.setWalkTrigger(3); + } + _action._inProgress = false; + return; + + case 3: + if (_action.isObject(NOUN_BOX_FIVE)) { + _scene->_nextSceneId = 206; + _globals[kMadameGiryLocation] = 1; + } else if (_action.isObject(NOUN_BOX_NINE)) { + _scene->_nextSceneId = 207; + _globals[kMadameGiryLocation] = 1; + } + _action._inProgress = false; + return; + + default: + break; + } + } + } + + if (_action.isAction(VERB_TALK_TO, NOUN_MONSIEUR_RICHARD)) { + _vm->_gameConv->run(18); + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_TALK_TO, NOUN_MADAME_GIRY) || _action.isAction(VERB_TALK_TO, NOUN_WOMAN) || _action.isAction(VERB_GIVE, NOUN_TICKET, NOUN_MADAME_GIRY)) { + if (_globals[kTicketPeoplePresent] == 2) { + if ((_globals[kDoorsIn205] == 2) || (_globals[kDoorsIn205] == 3)) { + if (_globals[kMadameGiryLocation] == 2) { + _vm->_gameConv->run(11); + _vm->_gameConv->exportValue(_game._objects.isInInventory(OBJ_TICKET)); + _vm->_gameConv->exportValue(1); + + if (_action.isAction(VERB_GIVE)) + _vm->_gameConv->exportValue(1); + else + _vm->_gameConv->exportValue(0); + } else { + _vm->_gameConv->run(11); + _vm->_gameConv->exportValue(_game._objects.isInInventory(OBJ_TICKET)); + _vm->_gameConv->exportValue(2); + + if (_action.isAction(VERB_GIVE)) + _vm->_gameConv->exportValue(1); + else + _vm->_gameConv->exportValue(0); + } + } else { + _vm->_gameConv->run(11); + _vm->_gameConv->exportValue(_game._objects.isInInventory(OBJ_TICKET)); + _vm->_gameConv->exportValue(0); + + if (_action.isAction(VERB_GIVE)) + _vm->_gameConv->exportValue(1); + else + _vm->_gameConv->exportValue(0); + } + } else { + int count = 0; + + if (_game._objects.isInInventory(OBJ_RED_FRAME)) + ++count; + if (_game._objects.isInInventory(OBJ_GREEN_FRAME)) + ++count; + if (_game._objects.isInInventory(OBJ_YELLOW_FRAME)) + ++count; + if (_game._objects.isInInventory(OBJ_BLUE_FRAME)) + ++count; + + _vm->_gameConv->run(10); + _vm->_gameConv->exportPointer(&_globals[kPlayerScore]); + _vm->_gameConv->exportValue(_game._difficulty); + + if (count > 2) + _vm->_gameConv->exportValue(1); + else + _vm->_gameConv->exportValue(0); + + _globals[kWalkerConverse] = _vm->getRandomNumber(1, 4); + } + _action._inProgress = false; + return; + } + + if (_action._lookFlag) { + _vm->_dialogs->show(20510); + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_LOOK) || _action.isAction(VERB_LOOK_AT)) { + if (_action.isObject(NOUN_BOX_SIX)) { + _vm->_dialogs->show(20511); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_BOX_SEVEN)) { + _vm->_dialogs->show(20512); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_BOX_EIGHT)) { + _vm->_dialogs->show(20513); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_BOX_NINE)) { + if ((_globals[kDoorsIn205] == 0) || (_globals[kDoorsIn205] == 1)) + _vm->_dialogs->show(20516); + else + _vm->_dialogs->show(20517); + + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_BOX_FIVE)) { + if ((_globals[kDoorsIn205] == 0) || (_globals[kDoorsIn205] == 2)) + _vm->_dialogs->show(20514); + else + _vm->_dialogs->show(20515); + + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_FLOOR)) { + _vm->_dialogs->show(20518); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_MARBLE_COLUMN)) { + _vm->_dialogs->show(20519); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_CEILING)) { + _vm->_dialogs->show(20520); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_WALL)) { + _vm->_dialogs->show(20521); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_BUST)) { + _vm->_dialogs->show(20522); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_CARPET)) { + _vm->_dialogs->show(20523); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_GRAND_FOYER)) { + _vm->_dialogs->show(20524); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_WOMAN) || _action.isObject(NOUN_MADAME_GIRY)) { + _vm->_dialogs->show(20525); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_MONSIEUR_RICHARD)) { + _vm->_dialogs->show(20526); + _action._inProgress = false; + return; + } + } + + if (_action.isAction(VERB_TALK_TO, NOUN_BUST)) { + _vm->_dialogs->show(20529); + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_OPEN, NOUN_BOX_TEN) || _action.isAction(VERB_ENTER, NOUN_BOX_TEN) || _action.isAction(VERB_LOOK, NOUN_BOX_TEN)) { + _vm->_dialogs->show(20513); + _action._inProgress = false; + return; + } + + // FIX: the original was doing a | between the two 'objects' + if (_action.isAction(VERB_TAKE) && (_action.isObject(NOUN_WOMAN) || _action.isObject(NOUN_MADAME_GIRY))) { + _vm->_dialogs->show(20530); + _action._inProgress = false; + return; + } +} + +void Scene205::preActions() { + if (_action.isObject(NOUN_BOX_FIVE) && (_action.isAction(VERB_LOCK) || _action.isAction(VERB_UNLOCK) || _action.isAction(VERB_OPEN))) + _game._player.walk(Common::Point(37, 67), FACING_NORTHEAST); + + if (_action.isObject(NOUN_BOX_SIX) && (_action.isAction(VERB_LOCK) || _action.isAction(VERB_UNLOCK) || _action.isAction(VERB_OPEN))) + _game._player.walk(Common::Point(80, 68), FACING_NORTHEAST); + + if (_action.isObject(NOUN_BOX_SEVEN) && (_action.isAction(VERB_LOCK) || _action.isAction(VERB_UNLOCK) || _action.isAction(VERB_OPEN))) + _game._player.walk(Common::Point(167, 65), FACING_NORTHEAST); + + if (_action.isObject(NOUN_BOX_EIGHT) && (_action.isAction(VERB_LOCK) || _action.isAction(VERB_UNLOCK) || _action.isAction(VERB_OPEN))) + _game._player.walk(Common::Point(212, 64), FACING_NORTHEAST); + + if (_action.isObject(NOUN_BOX_NINE) && (_action.isAction(VERB_LOCK) || _action.isAction(VERB_UNLOCK) || _action.isAction(VERB_OPEN))) + _game._player.walk(Common::Point(258, 63), FACING_NORTHEAST); + + if (_action.isAction(VERB_WALK_DOWN_STAIRS_TO, NOUN_GRAND_FOYER) && (_globals[kDoorsIn205] != 2) && (_globals[kDoorsIn205] != 3)) { + _game._player._walkOffScreenSceneId = 202; + _globals[kMadameGiryLocation] = 1; + } +} + +void Scene205::handleConversation18() { + int interlocutorFl = false; + int heroFl = false; + + switch (_action._activeAction._verbId) { + case 0: + _globals[kWalkerConverse] = _vm->getRandomNumber(1, 4); + _richardStatus = 0; + break; + + case 3: + case 4: + _vm->_gameConv->setHeroTrigger(64); + _globals[kRanConvIn205] = true; + heroFl = true; + interlocutorFl = true; + break; + + default: + break; + } + + switch (_game._trigger) { + case 64: + _globals[kWalkerConverse] = 0; + heroFl = true; + interlocutorFl = true; + break; + + case 62: + _globals[kWalkerConverse] = _vm->getRandomNumber(1, 4); + _richardStatus = 0; + break; + + case 60: + _globals[kWalkerConverse] = _vm->getRandomNumber(2, 3); + _richardStatus = 3; + _conversationCounter = 0; + break; + + default: + break; + } + + if (!heroFl) + _vm->_gameConv->setHeroTrigger(60); + + if (!interlocutorFl) + _vm->_gameConv->setInterlocutorTrigger(62); + + _richardCount = 0; +} + +void Scene205::handleConversation10() { + int interlocutorFl = false; + int heroFl = false; + + switch (_action._activeAction._verbId) { + case 9: + _vm->_gameConv->setInterlocutorTrigger(68); + interlocutorFl = true; + _globals[kMadameNameIsKnown] = 1; + _scene->_hotspots.activate(NOUN_WOMAN, false); + _scene->_hotspots.activateAtPos(NOUN_MADAME_GIRY, true, Common::Point(113, 44)); + _scene->_hotspots.activateAtPos(NOUN_MADAME_GIRY, true, Common::Point(107, 66)); + break; + + case 10: + _globals[kMadameNameIsKnown] = 1; + _scene->_hotspots.activate(NOUN_WOMAN, false); + _scene->_hotspots.activateAtPos(NOUN_MADAME_GIRY, true, Common::Point(113, 44)); + _scene->_hotspots.activateAtPos(NOUN_MADAME_GIRY, true, Common::Point(107, 66)); + break; + + case 7: + if (!_game._trigger) { + _giryStatus = 6; + _globals[kMadameNameIsKnown] = 2; + _globals[kMadameGiryLocation] = 0; + _scene->changeVariant(2); + _scene->_rails.disableNode(6); + _scene->_rails.disableNode(7); + _scene->_rails.disableNode(8); + _scene->_rails.disableNode(9); + _scene->_hotspots.activateAtPos(NOUN_MADAME_GIRY, false, Common::Point(113, 44)); + _scene->_hotspots.activateAtPos(NOUN_MADAME_GIRY, false, Common::Point(107, 66)); + interlocutorFl = true; + heroFl = true; + if (_globals[kDoorsIn205] == 0) + _globals[kDoorsIn205] = 1; + else if (_globals[kDoorsIn205] == 2) + _globals[kDoorsIn205] = 3; + } + break; + + case 13: + case 45: + _vm->_gameConv->setInterlocutorTrigger(70); + interlocutorFl = true; + break; + + case 21: + if (!_game._trigger && !_noConversationHold) { + _vm->_gameConv->hold(); + _giryStatus = 4; + } else + _noConversationHold = false; + + break; + + case 17: + _vm->_gameConv->setInterlocutorTrigger(72); + interlocutorFl = true; + break; + + case 11: + if (!_game._trigger) { + _vm->_gameConv->setInterlocutorTrigger(74); + } + heroFl = true; + interlocutorFl = true; + break; + + case 23: + case 25: + if ((!_game._trigger) && (_giryStatus == 4)) { + _vm->_gameConv->hold(); + _giryStatus = 0; + } + break; + + case 4: + case 5: + case 8: + case 14: + case 16: + case 19: + case 40: + case 46: + _vm->_gameConv->setInterlocutorTrigger(64); + interlocutorFl = true; + break; + + default: + break; + } + + switch (_game._trigger) { + case 64: + switch (_action._activeAction._verbId) { + case 5: + case 14: + case 16: + case 19: + case 40: + case 46: + _giryStatus = 0; + break; + } + _globals[kWalkerConverse] = 0; + heroFl = true; + interlocutorFl = true; + break; + + case 68: + _giryStatus = 5; + break; + + case 74: + _giryStatus = 8; + _globals[kWalkerConverse] = 0; + heroFl = true; + interlocutorFl = true; + break; + + case 72: + _giryStatus = 3; + break; + + case 70: + if (_action._activeAction._verbId == 13) { + _globals[kWalkerConverse] = 0; + heroFl = true; + interlocutorFl = true; + } + _giryStatus = 1; + break; + + case 66: + if (_globals[kWalkerConverse] != 0) + _globals[kWalkerConverse] = _vm->getRandomNumber(1, 4); + + if ((_giryStatus != 4) && (_giryStatus != 6) && (_giryStatus != 7)) + _giryStatus = 0; + break; + + case 60: + if (_globals[kWalkerConverse] != 0) + _globals[kWalkerConverse] = _vm->getRandomNumber(2, 3); + + if ((_giryStatus != 4) && (_giryStatus != 6) && (_giryStatus != 7)) + _giryStatus = 2; + + _conversationCounter = 0; + break; + } + + if (!heroFl) + _vm->_gameConv->setHeroTrigger(60); + + if (!interlocutorFl) + _vm->_gameConv->setInterlocutorTrigger(66); + + _giryCount = 0; +} + +void Scene205::handleConversation11() { + int interlocutorFl = false; + int heroFl = false; + + switch (_action._activeAction._verbId) { + case 5: + if (!_game._trigger) { + _vm->_gameConv->hold(); + _giryStatus = 9; + } + break; + + case 8: + if (!_game._trigger) { + _vm->_gameConv->hold(); + _giryStatus = 7; + _vm->_gameConv->setInterlocutorTrigger(64); + _game._player.walk(Common::Point(225,79), FACING_NORTHEAST); + interlocutorFl = true; + _globals[kMadameGiryLocation] = 2; + _scene->changeVariant(4); + _scene->_rails.disableNode(6); + _scene->_rails.disableNode(7); + _scene->_rails.disableNode(8); + _scene->_rails.disableNode(9); + _scene->_hotspots.activateAtPos(NOUN_MADAME_GIRY, false, Common::Point(113, 44)); + _scene->_hotspots.activateAtPos(NOUN_MADAME_GIRY, false, Common::Point(107, 66)); + if (_globals[kDoorsIn205] == 0) + _globals[kDoorsIn205] = 2; + else if (_globals[kDoorsIn205] == 1) + _globals[kDoorsIn205] = 3; + } + break; + + case 9: + case 10: + case 12: + case 13: + case 14: + _vm->_gameConv->setInterlocutorTrigger(64); + interlocutorFl = true; + break; + } + + switch (_game._trigger) { + case 64: + switch (_action._activeAction._verbId) { + case 6: + case 10: + case 12: + case 13: + case 14: + _giryStatus = 0; + break; + } + _globals[kWalkerConverse] = 0; + heroFl = true; + interlocutorFl = true; + break; + + case 110: + _vm->_gameConv->hold(); + _giryStatus = 7; + break; + + case 66: + if (_globals[kWalkerConverse] != 0) + _globals[kWalkerConverse] = _vm->getRandomNumber(1, 4); + + if (_giryStatus != 9) + _giryStatus = 0; + break; + + case 60: + if (_globals[kWalkerConverse] != 0) + _globals[kWalkerConverse] = _vm->getRandomNumber(2, 3); + + if (_giryStatus != 9) + _giryStatus = 2; + + _conversationCounter = 0; + break; + } + + if (!heroFl) + _vm->_gameConv->setHeroTrigger(60); + + if (!interlocutorFl) + _vm->_gameConv->setInterlocutorTrigger(66); + + _giryCount = 0; +} + +void Scene205::handleRichardAnimation() { + if (_scene->_animation[_globals._animationIndexes[0]]->getCurrentFrame() == _richardFrame) + return; + + _richardFrame = _scene->_animation[_globals._animationIndexes[0]]->getCurrentFrame(); + int random; + int resetFrame = -1; + + switch (_richardFrame) { + case 1: + case 2: + case 3: + case 11: + case 19: + case 35: + case 47: + case 57: + case 69: + switch (_richardStatus) { + case 0: + random = _vm->getRandomNumber(1, 3); + ++_richardCount; + if (_richardCount > 30) { + _richardStatus = 3; + random = 9; + } + break; + + case 1: + random = 4; + _richardStatus = 0; + break; + + case 2: + random = 6; + break; + + case 4: + random = 5; + _richardStatus = 0; + break; + + default: + random = _vm->getRandomNumber(7, 50); + while (_lastRandom == random) + random = _vm->getRandomNumber(7, 50); + + _lastRandom = random; + break; + } + + switch (random) { + case 1: + resetFrame = 0; + break; + + case 2: + resetFrame = 1; + break; + + case 3: + resetFrame = 2; + break; + + case 4: + resetFrame = 11; + break; + + case 5: + resetFrame = 3; + break; + + case 6: + resetFrame = 57; + break; + + case 7: + resetFrame = 23; + break; + + case 8: + resetFrame = 19; + break; + + case 9: + resetFrame = 21; + break; + + case 10: + resetFrame = 25; + break; + + case 11: + resetFrame = 35; + break; + + case 12: + resetFrame = 47; + break; + + default: + resetFrame = 0; + break; + } + break; + + case 30: + switch (_richardStatus) { + case 0: + case 1: + case 2: + case 4: + random = 1; + break; + + default: + random = _vm->getRandomNumber(1, 50); + break; + } + + if (random == 1) + resetFrame = 30; + else + resetFrame = 29; + + break; + + case 24: + switch (_richardStatus) { + case 1: + case 2: + case 4: + case 0: + random = 1; + break; + + default: + random = _vm->getRandomNumber(1, 30); + break; + } + + if (random == 1) + resetFrame = 0; + else + resetFrame = 23; + + break; + + case 20: + switch (_richardStatus) { + case 1: + case 2: + case 4: + case 0: + random = 1; + break; + + default: + random = _vm->getRandomNumber(1, 50); + break; + } + + if (random == 1) + resetFrame = 0; + else + resetFrame = 19; + + break; + + case 22: + switch (_richardStatus) { + case 1: + case 2: + case 4: + case 0: + random = 1; + break; + + default: + random = _vm->getRandomNumber(1, 50); + break; + } + + if (random == 1) + resetFrame = 0; + else + resetFrame = 21; + + break; + + case 41: + switch (_richardStatus) { + case 1: + case 2: + case 4: + case 0: + random = 1; + break; + + default: + random = _vm->getRandomNumber(1, 50); + break; + } + + if (random == 1) + resetFrame = 41; + else + resetFrame = 40; + + break; + + case 52: + switch (_richardStatus) { + case 0: + case 1: + case 2: + case 4: + random = 1; + break; + + default: + random = _vm->getRandomNumber(1, 50); + break; + } + + if (random == 1) + resetFrame = 52; + else + resetFrame = 51; + + break; + + case 65: + switch (_richardStatus) { + case 0: + case 1: + case 2: + case 4: + random = 1; + break; + + default: + random = _vm->getRandomNumber(1, 50); + break; + } + + if (random == 1) + resetFrame = 65; + else + resetFrame = 64; + + break; + } + + if (resetFrame >= 0) { + _scene->setAnimFrame(_globals._animationIndexes[0], resetFrame); + _richardFrame = resetFrame; + } +} + +void Scene205::handleGiryAnimation() { + if (_scene->_animation[_globals._animationIndexes[1]]->getCurrentFrame() == _giryFrame) + return; + + _giryFrame = _scene->_animation[_globals._animationIndexes[1]]->getCurrentFrame(); + int random; + int resetFrame = -1; + + switch (_giryFrame) { + case 77: + _vm->_gameConv->release(); + break; + + case 1: + case 2: + case 3: + case 44: + case 14: + case 21: + case 35: + case 56: + case 78: + case 284: + switch (_giryStatus) { + case 0: + random = _vm->getRandomNumber(1, 3); + ++_giryCount; + if (_giryCount > 30) { + _giryStatus = 2; + random = 100; + } + break; + + case 8: + random = 4; + _giryStatus = 0; + break; + + case 3: + random = 5; + _giryStatus = 0; + break; + + case 1: + random = 6; + break; + + case 5: + _giryStatus = 0; + random = 7; + break; + + case 4: + random = 8; + break; + + case 6: + random = 9; + _giryStatus = 2; + break; + + case 7: + random = 10; + _giryStatus = 2; + break; + + case 9: + random = 11; + break; + + default: + random = _vm->getRandomNumber(12, 100); + break; + } + + switch (random) { + case 1: + resetFrame = 0; + break; + + case 2: + resetFrame = 1; + break; + + case 3: + resetFrame = 2; + break; + + case 4: + resetFrame = 3; + break; + + case 5: + resetFrame = 16; + break; + + case 6: + resetFrame = 21; + break; + + case 7: + resetFrame = 44; + break; + + case 8: + resetFrame = 56; + break; + + case 9: + resetFrame = 78; + _vm->_gameConv->hold(); + break; + + case 10: + resetFrame = 140; + break; + + case 11: + resetFrame = 276; + break; + + case 12: + resetFrame = 35; + break; + + default: + resetFrame = 0; + break; + } + break; + + case 27: + case 28: + case 29: + switch (_giryStatus) { + case 0: + case 2: + case 3: + case 4: + case 5: + case 6: + case 7: + case 8: + case 9: + random = 4; + break; + + default: + random = _vm->getRandomNumber(1, 3); + ++_giryCount; + if (_giryCount > 30) { + _giryStatus = 2; + random = 100; + } + break; + } + + switch (random) { + case 1: + resetFrame = 26; + break; + + case 2: + resetFrame = 27; + break; + + case 3: + resetFrame = 28; + break; + + default: + resetFrame = 29; + break; + } + break; + + case 265: + _scene->_hotspots.activateAtPos(NOUN_MADAME_GIRY, true, Common::Point(283, 51)); + _scene->_hotspots.activateAtPos(NOUN_MADAME_GIRY, true, Common::Point(289, 62)); + _vm->_gameConv->release(); + break; + + case 274: + case 275: + case 276: + if (_giryStatus == 0) { + random = _vm->getRandomNumber(1, 3); + ++_giryCount; + if (_giryCount > 30) { + _giryStatus = 2; + random = 100; + } + } else + random = 100; + + switch (random) { + case 1: + resetFrame = 273; + break; + + case 2: + resetFrame = 274; + break; + + case 3: + resetFrame = 275; + break; + + default: + resetFrame = 273; + break; + } + break; + + case 85: + _vm->_gameConv->release(); + break; + + case 110: + _scene->_hotspots.activateAtPos(NOUN_MADAME_GIRY, true, Common::Point(62, 54)); + _scene->_hotspots.activateAtPos(NOUN_MADAME_GIRY, true, Common::Point(62, 66)); + break; + + case 138: + case 139: + case 140: + switch (_giryStatus) { + case 0: + case 1: + random = _vm->getRandomNumber(1, 3); + ++_giryCount; + if (_giryCount > 30) { + _giryStatus = 2; + random = 100; + } + break; + + default: + random = 100; + break; + } + + switch (random) { + case 1: + resetFrame = 137; + break; + + case 2: + resetFrame = 138; + break; + + case 3: + resetFrame = 139; + break; + + default: + resetFrame = 137; + break; + } + break; + + case 66: + _vm->_gameConv->release(); + break; + + case 67: + switch (_giryStatus) { + case 0: + case 9: + case 2: + case 3: + case 5: + case 6: + case 7: + case 8: + random = 1; + break; + + default: + random = 100; + break; + } + + if (random == 1) + resetFrame = 67; + else + resetFrame = 66; + + break; + + case 8: + case 9: + switch (_giryStatus) { + case 0: + case 9: + case 2: + case 3: + case 4: + case 5: + case 6: + case 7: + case 8: + random = 1; + break; + + default: + random = 100; + break; + } + + if (random == 1) + resetFrame = 9; + else + resetFrame = 8; + + break; + + case 280: + _giveTicketFl = true; + break; + + case 281: + switch (_giryStatus) { + case 0: + case 2: + case 3: + case 4: + case 5: + case 6: + case 7: + case 8: + random = 1; + break; + + default: + random = 100; + break; + } + + if (random == 1) + resetFrame = 281; + else + resetFrame = 280; + + break; + } + + if (resetFrame >= 0) { + _scene->setAnimFrame(_globals._animationIndexes[1], resetFrame); + _giryFrame = resetFrame; + } +} + +/*------------------------------------------------------------------------*/ + +Scene206::Scene206(MADSEngine *vm) : Scene2xx(vm) { + _anim0ActvFl = false; + _skip1Fl = false; + _skip2Fl = false; +} + +void Scene206::synchronize(Common::Serializer &s) { + Scene2xx::synchronize(s); + + s.syncAsByte(_anim0ActvFl); + s.syncAsByte(_skip1Fl); + s.syncAsByte(_skip2Fl); +} + +void Scene206::setup() { + setPlayerSpritesPrefix(); + setAAName(); +} + +void Scene206::enter() { + _anim0ActvFl = false; + _skip1Fl = false; + _skip2Fl = false; + + _scene->loadSpeech(1); + _vm->_gameConv->get(26); + + _globals._spriteIndexes[0] = _scene->_sprites.addSprites(formAnimName('x', 0)); + _globals._spriteIndexes[1] = _scene->_sprites.addSprites(formAnimName('x', 1)); + _globals._spriteIndexes[2] = _scene->_sprites.addSprites(formAnimName('x', 2)); + _globals._spriteIndexes[3] = _scene->_sprites.addSprites(formAnimName('x', 3)); + _globals._spriteIndexes[5] = _scene->_sprites.addSprites("*RDR_9"); + + if (_scene->_priorSceneId != 308) { + if (_globals[kPanelIn206] == 0) { + _globals._sequenceIndexes[1] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[1], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[1], 14); + } else { + _globals._sequenceIndexes[1] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[1], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[1], 14); + _globals._sequenceIndexes[2] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[2], false, 3); + _scene->_sequences.setDepth(_globals._sequenceIndexes[2], 13); + } + } + + if (_globals[kPanelIn206] == 0) { + _scene->_hotspots.activate(NOUN_PANEL, false); + _scene->_hotspots.activate(NOUN_KEYHOLE, false); + } + + if (_game._objects.isInRoom(OBJ_CRUMPLED_NOTE)) { + _globals._spriteIndexes[4] = _scene->_sprites.addSprites(formAnimName('p', 0)); + _globals._sequenceIndexes[4] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[4], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[4], 10); + } else + _scene->_hotspots.activate(NOUN_CRUMPLED_NOTE, false); + + if (_globals[kTrapDoorStatus] == 0) { + _globals._sequenceIndexes[0] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[0], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[0], 14); + } + + if (_globals[kRightDoorIsOpen504] && !_globals[kKnockedOverHead]) { + _globals._animationIndexes[0] = _scene->loadAnimation(formAnimName('h', 1), 88); + _game._player._visible = false; + _game._player._stepEnabled = false; + _anim0ActvFl = true; + } else if (_scene->_priorSceneId == 308) { + _game._player._playerPos = Common::Point(67, 127); + _game._player._stepEnabled = false; + _game._player.walk(Common::Point(108, 137), FACING_EAST); + _game._player.setWalkTrigger(82); + } else if ((_scene->_priorSceneId == 205) || (_scene->_priorSceneId != RETURNING_FROM_LOADING)) { + _game._player._playerPos = Common::Point(153, 148); + _game._player._facing = FACING_NORTH; + } + + sceneEntrySound(); +} + +void Scene206::step() { + switch (_game._trigger) { + case 82: + _vm->_sound->command(24); + _globals._sequenceIndexes[1] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[1], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[1], 14); + _globals._sequenceIndexes[3] = _scene->_sequences.addReverseSpriteCycle(_globals._spriteIndexes[3], false, 8, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[3], 13); + _scene->_sequences.setAnimRange(_globals._sequenceIndexes[3], -1, -2); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SEQUENCE_TRIGGER_EXPIRE, 0, 83); + break; + + case 83: + _globals._sequenceIndexes[2] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[2], false, 3); + _scene->_sequences.setDepth(_globals._sequenceIndexes[2], 13); + _game._player._stepEnabled = true; + break; + + case 88: + _game._player._playerPos = Common::Point(168, 138); + _game._player._visible = true; + _game._player._stepEnabled = true; + _anim0ActvFl = false; + _game._player.resetFacing(FACING_WEST); + break; + + default: + break; + } + + if (_anim0ActvFl && !_skip1Fl) { + if (_scene->_animation[_globals._animationIndexes[0]]->getCurrentFrame() == 118) { + _globals[kKnockedOverHead] = true; + _skip1Fl = true; + _scene->_sequences.addTimer(1, 84); + } + } + + if (_anim0ActvFl && !_skip2Fl) { + if (_scene->_animation[_globals._animationIndexes[0]]->getCurrentFrame() == 61) { + if (_vm->_sound->_preferRoland) + _vm->_sound->command(65); + else + _scene->playSpeech(1); + + _skip2Fl = true; + } + } + + switch (_game._trigger) { + case 84: + _vm->_sound->command(24); + _globals._sequenceIndexes[1] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[1], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[1], 14); + _globals._sequenceIndexes[3] = _scene->_sequences.addReverseSpriteCycle(_globals._spriteIndexes[3], false, 8, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[3], 13); + _scene->_sequences.setAnimRange(_globals._sequenceIndexes[3], -1, -2); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SEQUENCE_TRIGGER_EXPIRE, 0, 85); + break; + + case 85: + _globals._sequenceIndexes[2] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[2], false, 3); + _scene->_sequences.setDepth(_globals._sequenceIndexes[2], 13); + break; + + default: + break; + } +} + +void Scene206::actions() { + if (_action.isAction(VERB_EXIT_TO, NOUN_LOGE_CORRIDOR)) { + if (_globals[kRightDoorIsOpen504]) { + if (_vm->_sound->_preferRoland) + _vm->_sound->command(65); + else + _scene->playSpeech(1); + + _vm->_gameConv->run(26); + _vm->_gameConv->exportValue(4); + } else + _scene->_nextSceneId = 205; + + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_TAKE, NOUN_CRUMPLED_NOTE) && (_game._objects.isInRoom(OBJ_CRUMPLED_NOTE) || _game._trigger)) { + switch (_game._trigger) { + case (0): + _globals[kPlayerScore] += 5; + _game._player._stepEnabled = false; + _game._player._visible = false; + _globals._sequenceIndexes[5] = _scene->_sequences.startPingPongCycle(_globals._spriteIndexes[5], false, 5, 2); + _scene->_sequences.setAnimRange(_globals._sequenceIndexes[5], -1, -2); + _scene->_sequences.setSeqPlayer(_globals._sequenceIndexes[5], true); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[5], SEQUENCE_TRIGGER_SPRITE, 4, 77); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[5], SEQUENCE_TRIGGER_EXPIRE, 0, 78); + _action._inProgress = false; + return; + + case 77: + _scene->deleteSequence(_globals._sequenceIndexes[4]); + _scene->_hotspots.activate(NOUN_CRUMPLED_NOTE, false); + _game._objects.addToInventory(OBJ_CRUMPLED_NOTE); + _vm->_sound->command(26); + _action._inProgress = false; + return; + + case 78: + _game.syncTimers(SYNC_PLAYER, 0, SYNC_SEQ, _globals._sequenceIndexes[5]); + _game._player._visible = true; + _scene->_sequences.addTimer(20, 79); + _action._inProgress = false; + return; + + case 79: + _vm->_dialogs->showItem(OBJ_CRUMPLED_NOTE, 816, 6); + _game._player._stepEnabled = true; + _action._inProgress = false; + return; + + default: + break; + } + } + + if (_action.isAction(VERB_WALK_BEHIND, NOUN_PANEL) || _action.isAction(VERB_OPEN, NOUN_PANEL) + || ((_game._trigger >= 70) && (_game._trigger < 77))) { + if (_globals[kPanelIn206] == 3) { + switch (_game._trigger) { + case (0): + _game._player._stepEnabled = false; + _game._player._visible = false; + _globals._sequenceIndexes[5] = _scene->_sequences.startPingPongCycle(_globals._spriteIndexes[5], true, 7, 2); + _scene->_sequences.setAnimRange(_globals._sequenceIndexes[5], 1, 3); + _scene->_sequences.setSeqPlayer(_globals._sequenceIndexes[5], true); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[5], SEQUENCE_TRIGGER_SPRITE, 3, 70); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[5], SEQUENCE_TRIGGER_EXPIRE, 0, 71); + break; + + case 70: + _vm->_sound->command(24); + _scene->deleteSequence(_globals._sequenceIndexes[2]); + _globals._sequenceIndexes[3] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[3], false, 8, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[3], 13); + _scene->_sequences.setAnimRange(_globals._sequenceIndexes[3], -1, -2); + break; + + case 71: + _globals._sequenceIndexes[3] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[3], false, -2); + _scene->_sequences.setDepth(_globals._sequenceIndexes[3], 14); + _game._player._stepEnabled = true; + _game._player._visible = true; + _game._player.walk(Common::Point(67, 127), FACING_NORTHWEST); + _game._player.setWalkTrigger(72); + break; + + case 72: + _vm->_sound->command(24); + _scene->deleteSequence(_globals._sequenceIndexes[3]); + _globals._sequenceIndexes[3] = _scene->_sequences.addReverseSpriteCycle(_globals._spriteIndexes[3], false, 8, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[3], 13); + _scene->_sequences.setAnimRange(_globals._sequenceIndexes[3], -1, -2); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SEQUENCE_TRIGGER_EXPIRE, 0, 73); + break; + + case 73: + _globals._sequenceIndexes[2] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[2], false, -2); + _scene->_sequences.setDepth(_globals._sequenceIndexes[2], 14); + _scene->_nextSceneId = 308; + break; + + default: + break; + } + } else { + switch (_game._trigger) { + case (0): + _game._player._stepEnabled = false; + _game._player._visible = false; + _globals._sequenceIndexes[5] = _scene->_sequences.startPingPongCycle(_globals._spriteIndexes[5], true, 7, 2); + _scene->_sequences.setAnimRange(_globals._sequenceIndexes[5], 1, 3); + _scene->_sequences.setSeqPlayer(_globals._sequenceIndexes[5], true); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[5], SEQUENCE_TRIGGER_EXPIRE, 0, 74); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[5], SEQUENCE_TRIGGER_SPRITE, 3, 75); + break; + + case 74: + _game._player._stepEnabled = true; + _game._player._visible = true; + _vm->_dialogs->show(20625); + break; + + case 75: + _vm->_sound->command(72); + break; + + default: + break; + } + } + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_UNLOCK, NOUN_PANEL) || _action.isAction(VERB_LOCK, NOUN_PANEL) || _action.isAction(VERB_PUT, NOUN_KEY, NOUN_KEYHOLE) + || _action.isAction(VERB_UNLOCK, NOUN_KEYHOLE) || _action.isAction(VERB_LOCK, NOUN_KEYHOLE) || (_game._trigger >= 64)) { + if (_globals[kPanelIn206] >= 1) { + switch (_game._trigger) { + case (0): + _game._player._stepEnabled = false; + _game._player._visible = false; + _globals._sequenceIndexes[5] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[5], true, 7, 1); + _scene->_sequences.setAnimRange(_globals._sequenceIndexes[5], 1, 3); + _scene->_sequences.setSeqPlayer(_globals._sequenceIndexes[5], true); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[5], SEQUENCE_TRIGGER_EXPIRE, 0, 64); + break; + + case 64: { + _vm->_sound->command(71); + int idx = _globals._sequenceIndexes[5]; + _globals._sequenceIndexes[5] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[5], true, -2); + _game.syncTimers(SYNC_SEQ, _globals._sequenceIndexes[5], SYNC_SEQ, idx); + _scene->_sequences.setSeqPlayer(_globals._sequenceIndexes[5], false); + _scene->_sequences.addTimer(30, 65); + } + break; + + case 65: + _scene->deleteSequence(_globals._sequenceIndexes[5]); + _globals._sequenceIndexes[5] = _scene->_sequences.addReverseSpriteCycle(_globals._spriteIndexes[5], true, 7, 1); + _scene->_sequences.setAnimRange(_globals._sequenceIndexes[5], 1, 3); + _scene->_sequences.setSeqPlayer(_globals._sequenceIndexes[5], false); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[5], SEQUENCE_TRIGGER_EXPIRE, 0, 66); + break; + + case 66: + if (_action.isAction(VERB_LOCK)) { + _globals[kPanelIn206] = 2; + _vm->_dialogs->show(20629); + } else if (_action.isAction(VERB_UNLOCK)) { + _globals[kPanelIn206] = 3; + _vm->_dialogs->show(20628); + } + + if (_action.isAction(VERB_PUT)) { + if (_globals[kPanelIn206] <= 2) { + _globals[kPanelIn206] = 3; + _vm->_dialogs->show(20628); + } else { + _globals[kPanelIn206] = 2; + _vm->_dialogs->show(20629); + } + } + + _game.syncTimers(SYNC_PLAYER, 0, SYNC_SEQ, _globals._sequenceIndexes[5]); + _game._player._stepEnabled = true; + _game._player._visible = true; + break; + + default: + break; + } + _action._inProgress = false; + return; + } + } + + if (_action._lookFlag) { + _vm->_dialogs->show(20610); + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_LOOK) || _action.isAction(VERB_LOOK_AT)) { + if (_action.isObject(NOUN_WALL)) { + _vm->_dialogs->show(20611); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_FLOOR)) { + _vm->_dialogs->show(20612); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_RIGHT_COLUMN)) { + _vm->_dialogs->show(20614); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_KEYHOLE)) { + _vm->_dialogs->show(20615); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_RAIL)) { + _vm->_dialogs->show(20616); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_SEAT)) { + _vm->_dialogs->show(20617); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_LOGE_CORRIDOR)) { + _vm->_dialogs->show(20618); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_STAGE)) { + if (_globals[kJacquesStatus]) + _vm->_dialogs->show(20630); + else + _vm->_dialogs->show(20619); + + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_HOUSE)) { + _vm->_dialogs->show(20620); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_CEILING)) { + _vm->_dialogs->show(20621); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_HOUSE_LIGHT)) { + _vm->_dialogs->show(20622); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_PANEL)) { + if (_globals[kPanelIn206] == 3) + _vm->_dialogs->show(20624); + else + _vm->_dialogs->show(20626); + + _action._inProgress = false; + return; + } + + if ((_action.isObject(NOUN_LEFT_COLUMN)) && (!_game._trigger)) { + if (_globals[kPanelIn206] == 0) { + _vm->_dialogs->show(20613); + _globals._animationIndexes[0] = _scene->loadAnimation(formAnimName('k', 1), 95); + _game._player._stepEnabled = false; + _game._player._visible = false; + } else + _vm->_dialogs->show(20623); + + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_CRUMPLED_NOTE) && _game._objects.isInRoom(OBJ_CRUMPLED_NOTE)) { + _vm->_dialogs->show(20627); + _action._inProgress = false; + return; + } + } + + switch (_game._trigger) { + case 95: + _game._player._visible = true; + _game.syncTimers(SYNC_PLAYER, 0, SYNC_ANIM, _globals._animationIndexes[0]); + _scene->_hotspots.activate(NOUN_PANEL, true); + _scene->_hotspots.activate(NOUN_KEYHOLE, true); + _globals._sequenceIndexes[2] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[2], false, 3); + _scene->_sequences.setDepth(_globals._sequenceIndexes[2], 13); + if (!(_globals[kPlayerScoreFlags] & 8)) { + _globals[kPlayerScoreFlags] |= 8; + _globals[kPlayerScore] += 5; + } + _scene->_sequences.addTimer(15, 96); + + _action._inProgress = false; + return; + + case 96: + _game._player._stepEnabled = true; + _globals[kPanelIn206] = 1; + _vm->_dialogs->show(20623); + _action._inProgress = false; + return; + + default: + break; + } +} + +void Scene206::preActions() { + if (_action.isAction(VERB_LOOK, NOUN_LEFT_COLUMN)) + _game._player._needToWalk = true; + + if (_action.isAction(VERB_UNLOCK, NOUN_PANEL) || _action.isAction(VERB_WALK_BEHIND, NOUN_PANEL) + || _action.isAction(VERB_LOCK, NOUN_PANEL) || _action.isAction(VERB_OPEN, NOUN_PANEL)) + _game._player.walk(Common::Point(108, 137), FACING_NORTHWEST); + + if (_action.isObject(NOUN_LEFT_COLUMN) && (_globals[kPanelIn206] == 0)) + _game._player.walk(Common::Point(103, 137), FACING_NORTHWEST); +} + +/*------------------------------------------------------------------------*/ + +Scene207::Scene207(MADSEngine *vm) : Scene2xx(vm) { + _skip1Fl = false; + _anim0ActvFl = false; +} + +void Scene207::synchronize(Common::Serializer &s) { + Scene2xx::synchronize(s); + + s.syncAsByte(_skip1Fl); + s.syncAsByte(_anim0ActvFl); +} + +void Scene207::setup() { + setPlayerSpritesPrefix(); + setAAName(); +} + +void Scene207::enter() { + _scene->loadSpeech(2); + _skip1Fl = false; + _anim0ActvFl = false; + + _globals._spriteIndexes[0] = _scene->_sprites.addSprites(formAnimName('a', 0)); + _globals._spriteIndexes[1] = _scene->_sprites.addSprites(formAnimName('c', 0)); + _globals._spriteIndexes[2] = _scene->_sprites.addSprites(formAnimName('x', 0)); + + _globals._sequenceIndexes[1] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[1], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[1], 10); + + if ((_scene->_priorSceneId == 205) || (_scene->_priorSceneId != RETURNING_FROM_LOADING)) { + _game._player._playerPos = Common::Point(159, 147); + _game._player._facing = FACING_NORTH; + } + + sceneEntrySound(); +} + +void Scene207::step() { + if (_anim0ActvFl && !_skip1Fl) { + if (_scene->_animation[_globals._animationIndexes[0]]->getCurrentFrame() == 6) { + if (_vm->_sound->_preferRoland) + _vm->_sound->command(69); + else + _scene->playSpeech(2); + + _skip1Fl = true; + } + } +} + +void Scene207::actions() { + if (_action.isAction(VERB_TAKE, NOUN_SEAT)) { + switch (_game._trigger) { + case 0: + _globals[kPlayerScore] += 5; + _game._player._stepEnabled = false; + _game._player._visible = false; + _vm->_sound->command(3); + _globals._sequenceIndexes[0] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[0], false, 7, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[0], 10); + _scene->_sequences.setAnimRange(_globals._sequenceIndexes[0], -1, -2); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[0], SEQUENCE_TRIGGER_EXPIRE, 0, 1); + break; + + case 1: + _globals._sequenceIndexes[0] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[0], false, -2); + _scene->_sequences.setDepth(_globals._sequenceIndexes[0], 10); + _scene->_sequences.addTimer(120, 2); + _scene->_sequences.addTimer(240, 3); + break; + + case 2: + _globals._sequenceIndexes[2] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[2], false, 6, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[2], 1); + _scene->_sequences.setAnimRange(_globals._sequenceIndexes[2], -1, -2); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SEQUENCE_TRIGGER_EXPIRE, 0, 4); + break; + + case 3: + _globals._animationIndexes[0] = _scene->loadAnimation(formAnimName('s', 1), 5); + _anim0ActvFl = true; + _scene->deleteSequence(_globals._sequenceIndexes[1]); + break; + + case 4: + _globals._sequenceIndexes[2] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[2], false, -2); + _scene->_sequences.setDepth(_globals._sequenceIndexes[2], 1); + break; + + case 5: + _scene->_nextSceneId = 208; + break; + + default: + break; + } + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_EXIT_TO, NOUN_LOGE_CORRIDOR)) { + _scene->_nextSceneId = 205; + _action._inProgress = false; + return; + } + + if (_action._lookFlag) { + _vm->_dialogs->show(20710); + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_LOOK) || _action.isAction(VERB_LOOK_AT)) { + if (_action.isObject(NOUN_WALL)) { + _vm->_dialogs->show(20711); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_FLOOR)) { + _vm->_dialogs->show(20712); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_LEFT_COLUMN)) { + _vm->_dialogs->show(20713); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_RIGHT_COLUMN)) { + _vm->_dialogs->show(20714); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_RAIL)) { + _vm->_dialogs->show(20715); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_SEAT)) { + _vm->_dialogs->show(20716); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_LOGE_CORRIDOR)) { + _vm->_dialogs->show(20717); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_STAGE)) { + _vm->_dialogs->show(20718); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_HOUSE)) { + _vm->_dialogs->show(20719); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_CEILING)) { + _vm->_dialogs->show(20720); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_HOUSE_LIGHT)) { + _vm->_dialogs->show(20721); + _action._inProgress = false; + return; + } + } +} + +void Scene207::preActions() { + if (_action.isAction(VERB_TAKE, NOUN_SEAT)) + _game._player.walk(Common::Point(139, 124), FACING_NORTH); +} + +/*------------------------------------------------------------------------*/ + +Scene208::Scene208(MADSEngine *vm) : Scene2xx(vm) { + _skip1Fl = false; + _skip2Fl = false; + + _topLeftPeopleFrame = -1; + _topRightPeopleFrame = -1; + _middleLeftPeopleFrame = -1; + _centerPeopleFrame = -1; + _middleRightPeopleFrame = -1; + _bottomLeftPeopleFrame = -1; + _bottomMiddlePeopleFrame = -1; + _bottomRightPeopleFrame = -1; + _direction = -1; +} + +void Scene208::synchronize(Common::Serializer &s) { + Scene2xx::synchronize(s); + + s.syncAsByte(_skip1Fl); + s.syncAsByte(_skip2Fl); + + s.syncAsSint16LE(_topLeftPeopleFrame); + s.syncAsSint16LE(_topRightPeopleFrame); + s.syncAsSint16LE(_middleLeftPeopleFrame); + s.syncAsSint16LE(_centerPeopleFrame); + s.syncAsSint16LE(_middleRightPeopleFrame); + s.syncAsSint16LE(_bottomLeftPeopleFrame); + s.syncAsSint16LE(_bottomMiddlePeopleFrame); + s.syncAsSint16LE(_bottomRightPeopleFrame); + s.syncAsSint16LE(_direction); +} + +void Scene208::setup() { + setPlayerSpritesPrefix(); + setAAName(); +} + +void Scene208::enter() { + _scene->loadSpeech(1); + + _skip1Fl = false; + _skip2Fl = false; + + _globals._spriteIndexes[0] = _scene->_sprites.addSprites(formAnimName('x', 0)); + _globals._spriteIndexes[1] = _scene->_sprites.addSprites(formAnimName('x', 1)); + _globals._spriteIndexes[2] = _scene->_sprites.addSprites(formAnimName('x', 2)); + _globals._spriteIndexes[3] = _scene->_sprites.addSprites(formAnimName('x', 3)); + _globals._spriteIndexes[4] = _scene->_sprites.addSprites(formAnimName('x', 4)); + _globals._spriteIndexes[5] = _scene->_sprites.addSprites(formAnimName('x', 5)); + _globals._spriteIndexes[6] = _scene->_sprites.addSprites(formAnimName('x', 6)); + _globals._spriteIndexes[7] = _scene->_sprites.addSprites(formAnimName('x', 7)); + + _scene->_userInterface.emptyConversationList(); + _scene->_userInterface.setup(kInputConversation); + + _scene->loadSpeech(1); + + _game._player._stepEnabled = false; + _game._player._visible = false; + + _topLeftPeopleFrame = 2; + _globals._sequenceIndexes[0] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[0], false, _topLeftPeopleFrame); + _scene->_sequences.setDepth(_globals._sequenceIndexes[0], 1); + _scene->_sequences.addTimer(120, 60); + + _topRightPeopleFrame = 2; + _globals._sequenceIndexes[1] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[1], false, _topRightPeopleFrame); + _scene->_sequences.setDepth(_globals._sequenceIndexes[1], 1); + _scene->_sequences.addTimer(30, 62); + + _middleLeftPeopleFrame = 2; + _globals._sequenceIndexes[2] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[2], false, _middleLeftPeopleFrame); + _scene->_sequences.setDepth(_globals._sequenceIndexes[2], 1); + _scene->_sequences.addTimer(30, 64); + + _centerPeopleFrame = 1; + _direction = 1; + _globals._sequenceIndexes[3] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[3], false, _centerPeopleFrame); + _scene->_sequences.setDepth(_globals._sequenceIndexes[3], 14); + _scene->_sequences.addTimer(300, 66); + + _middleRightPeopleFrame = 3; + _globals._sequenceIndexes[4] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[4], false, _middleRightPeopleFrame); + _scene->_sequences.setDepth(_globals._sequenceIndexes[4], 1); + _scene->_sequences.addTimer(60, 68); + + _bottomLeftPeopleFrame = 4; + _globals._sequenceIndexes[5] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[5], false, _bottomLeftPeopleFrame); + _scene->_sequences.setDepth(_globals._sequenceIndexes[5], 1); + _scene->_sequences.addTimer(60, 70); + + _bottomMiddlePeopleFrame = 4; + _globals._sequenceIndexes[6] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[6], false, _bottomMiddlePeopleFrame); + _scene->_sequences.setDepth(_globals._sequenceIndexes[6], 14); + _scene->_sequences.addTimer(30, 72); + + _bottomRightPeopleFrame = 3; + _globals._sequenceIndexes[7] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[7], false, _bottomRightPeopleFrame); + _scene->_sequences.setDepth(_globals._sequenceIndexes[7], 1); + _scene->_sequences.addTimer(15, 74); + + _globals._animationIndexes[0] = _scene->loadAnimation(formAnimName('p', 1), 80); + + sceneEntrySound(); +} + +void Scene208::step() { + animateTopLeftPeople(); + animateTopRightPeople(); + animateMiddleLeftPeople(); + animateCenterPeople(); + animateMiddleRightPeople(); + animateBottomLeftPeople(); + animateBottomMiddlePeople(); + animateBottomRightPeople(); + + if (!_skip1Fl) { + if (_scene->_animation[_globals._animationIndexes[0]]->getCurrentFrame() == 49) { + if (_vm->_sound->_preferRoland) + _vm->_sound->command(65); + else + _scene->playSpeech(1); + + _skip1Fl = true; + } + } + + if (!_skip2Fl) { + if (_scene->_animation[_globals._animationIndexes[0]]->getCurrentFrame() == 68) { + if (_vm->_sound->_preferRoland) + _vm->_sound->command(65); + else + _scene->playSpeech(1); + + _skip2Fl = true; + } + } + + if (_game._trigger == 80) + _scene->_nextSceneId = 150; +} + +void Scene208::actions() { +} + +void Scene208::preActions() { +} + +void Scene208::animateTopLeftPeople() { + + if (_game._trigger != 60) + return; + + _scene->deleteSequence(_globals._sequenceIndexes[0]); + + int triggerVal; + int rndVal = _vm->getRandomNumber(1, 2); + if (_topLeftPeopleFrame == 3) + triggerVal = 1; + else + triggerVal = rndVal; + + if (rndVal == triggerVal) { + _topLeftPeopleFrame += _vm->getRandomNumber(-1, 1); + if (_topLeftPeopleFrame == 0) + _topLeftPeopleFrame = 1; + else if (_topLeftPeopleFrame == 4) + _topLeftPeopleFrame = 3; + } + + _globals._sequenceIndexes[0] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[0], false, _topLeftPeopleFrame); + _scene->_sequences.setDepth(_globals._sequenceIndexes[0], 1); + int delay = _vm->getRandomNumber(15, 60); + _scene->_sequences.addTimer(delay, 60); +} + +void Scene208::animateTopRightPeople() { + if (_game._trigger != 62) + return; + + _scene->deleteSequence(_globals._sequenceIndexes[1]); + + int triggerVal; + int rndVal = _vm->getRandomNumber(1, 2); + if (_topRightPeopleFrame == 4) + triggerVal = 1; + else + triggerVal = rndVal; + + if (rndVal == triggerVal) { + _topRightPeopleFrame += _vm->getRandomNumber(-1, 1); + if (_topRightPeopleFrame == 0) + _topRightPeopleFrame = 1; + else if (_topRightPeopleFrame == 5) + _topRightPeopleFrame = 4; + } + + _globals._sequenceIndexes[1] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[1], false, _topRightPeopleFrame); + _scene->_sequences.setDepth(_globals._sequenceIndexes[1], 1); + int delay = _vm->getRandomNumber(15, 60); + _scene->_sequences.addTimer(delay, 62); +} + +void Scene208::animateMiddleLeftPeople() { + if (_game._trigger != 64) + return; + + _scene->deleteSequence(_globals._sequenceIndexes[2]); + int delay = _vm->getRandomNumber(60, 120); + + int triggerVal; + int rndVal = _vm->getRandomNumber(1, 2); + if (_middleLeftPeopleFrame == 2) + triggerVal = 1; + else + triggerVal = rndVal; + + if (rndVal == triggerVal) { + _middleLeftPeopleFrame += _vm->getRandomNumber(-1, 1); + if (_middleLeftPeopleFrame == 0) + _middleLeftPeopleFrame = 1; + else if (_middleLeftPeopleFrame == 5) + _middleLeftPeopleFrame = 4; + } + + if ((_centerPeopleFrame == 3) && (_middleLeftPeopleFrame < 4)) { + ++_middleLeftPeopleFrame; + delay = 10; + } + + _globals._sequenceIndexes[2] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[2], false, _middleLeftPeopleFrame); + _scene->_sequences.setDepth(_globals._sequenceIndexes[2], 1); + _scene->_sequences.addTimer(delay, 64); +} + + +void Scene208::animateCenterPeople() { + if (_game._trigger != 66) + return; + + _scene->deleteSequence(_globals._sequenceIndexes[3]); + + int delay; + + if (_direction) { + ++_centerPeopleFrame; + delay = 15; + if (_centerPeopleFrame == 4) { + delay = _vm->getRandomNumber(300, 420); + --_centerPeopleFrame; + _direction = 0; + } + } else { + --_centerPeopleFrame; + delay = 15; + if (_centerPeopleFrame == 0) { + delay = _vm->getRandomNumber(600, 900); + ++_centerPeopleFrame; + _direction = 1; + } + } + + _globals._sequenceIndexes[3] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[3], false, _centerPeopleFrame); + _scene->_sequences.setDepth(_globals._sequenceIndexes[3], 14); + _scene->_sequences.addTimer(delay, 66); +} + +void Scene208::animateMiddleRightPeople() { + if (_game._trigger != 68) + return; + + _scene->deleteSequence(_globals._sequenceIndexes[4]); + + int triggerVal; + int rndVal = _vm->getRandomNumber(1, 2); + if (_middleRightPeopleFrame == 1) + triggerVal = 1; + else + triggerVal = rndVal; + + if (rndVal == triggerVal) { + _middleRightPeopleFrame += _vm->getRandomNumber(-1, 1); + if (_middleRightPeopleFrame == 0) + _middleRightPeopleFrame = 1; + else if (_middleRightPeopleFrame == 4) + _middleRightPeopleFrame = 3; + + if (_centerPeopleFrame == 3) + _middleRightPeopleFrame = 3; + } + + _globals._sequenceIndexes[4] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[4], false, _middleRightPeopleFrame); + _scene->_sequences.setDepth(_globals._sequenceIndexes[4], 1); + int delay = _vm->getRandomNumber(15, 60); + _scene->_sequences.addTimer(delay, 68); +} + +void Scene208::animateBottomLeftPeople() { + if (_game._trigger != 70) + return; + + _scene->deleteSequence(_globals._sequenceIndexes[5]); + + int triggerVal; + int rndVal = _vm->getRandomNumber(1, 2); + if (_bottomLeftPeopleFrame == 4) + triggerVal = 1; + else + triggerVal = rndVal; + + if (rndVal == triggerVal) { + _bottomLeftPeopleFrame += _vm->getRandomNumber(-1, 1); + if (_bottomLeftPeopleFrame == 0) + _bottomLeftPeopleFrame = 1; + else if (_bottomLeftPeopleFrame == 5) + _bottomLeftPeopleFrame = 4; + } + + _globals._sequenceIndexes[5] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[5], false, _bottomLeftPeopleFrame); + _scene->_sequences.setDepth(_globals._sequenceIndexes[5], 1); + int delay = _vm->getRandomNumber(15, 60); + _scene->_sequences.addTimer(delay, 70); +} + +void Scene208::animateBottomMiddlePeople() { + if (_game._trigger != 72) + return; + + _scene->deleteSequence(_globals._sequenceIndexes[6]); + + int triggerVal; + int rndVal = _vm->getRandomNumber(1, 2); + if (_bottomMiddlePeopleFrame == 4) + triggerVal = 1; + else + triggerVal = rndVal; + + if (rndVal == triggerVal) { + _bottomMiddlePeopleFrame += _vm->getRandomNumber(-1, 1); + if (_bottomMiddlePeopleFrame == 0) + _bottomMiddlePeopleFrame = 1; + else if (_bottomMiddlePeopleFrame == 5) + _bottomMiddlePeopleFrame = 4; + } + + _globals._sequenceIndexes[6] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[6], false, _bottomMiddlePeopleFrame); + _scene->_sequences.setDepth(_globals._sequenceIndexes[6], 14); + int delay = _vm->getRandomNumber(15, 60); + _scene->_sequences.addTimer(delay, 72); +} + +void Scene208::animateBottomRightPeople() { + if (_game._trigger != 74) + return; + + _scene->deleteSequence(_globals._sequenceIndexes[7]); + + int triggerVal; + int rndVal = _vm->getRandomNumber(1, 2); + if ((_bottomRightPeopleFrame == 3) || (_bottomRightPeopleFrame == 1)) + triggerVal = 1; + else + triggerVal = rndVal; + + if (rndVal == triggerVal) { + _bottomRightPeopleFrame += _vm->getRandomNumber(-1, 1); + if (_bottomRightPeopleFrame == 0) + _bottomRightPeopleFrame = 1; + else if (_bottomRightPeopleFrame == 4) + _bottomRightPeopleFrame = 3; + } + + _globals._sequenceIndexes[7] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[7], false, _bottomRightPeopleFrame); + _scene->_sequences.setDepth(_globals._sequenceIndexes[7], 1); + int delay = _vm->getRandomNumber(15, 60); + _scene->_sequences.addTimer(delay, 74); +} + +/*------------------------------------------------------------------------*/ + +Scene250::Scene250(MADSEngine *vm) : Scene2xx(vm) { +} + +void Scene250::synchronize(Common::Serializer &s) { + Scene2xx::synchronize(s); +} + +void Scene250::setup() { + setPlayerSpritesPrefix(); + setAAName(); +} + +void Scene250::enter() { + warning("TODO: Switch to letter box view. See definition of MADS_MENU_Y"); + + _game._player._stepEnabled = false; + _game._player._visible = false; + + _game.loadQuoteSet(0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F, 0x40, 0x41, 0); + _globals._animationIndexes[0] = _scene->loadAnimation("*RM150Q1", 1); +} + +void Scene250::step() { + if (_game._trigger == 1) + _scene->_sequences.addTimer(12, 2); + + if (_game._trigger == 2) { + int y = 68; + + _scene->_kernelMessages.add(Common::Point(160, y), 0x1110, 0x20, 0, 900, _game.getQuote(0x36)); + y += 16; + + if (_globals[kPlayerScore] > 250) + _globals[kPlayerScore] = 250; + + Common::String message = Common::String::format("%d", _globals[kPlayerScore]); + message += " "; + message += _game.getQuote(0x37); + message += " 250 "; + message += _game.getQuote(0x38); + + _scene->_kernelMessages.add(Common::Point(160, y), 0x1110, 0x20, 3, 900, message); + y += 16; + + _scene->_kernelMessages.add(Common::Point(160, y), 0x1110, 0x20, 0, 900, _game.getQuote(0x39)); + y += 16; + + int score = _globals[kPlayerScore]; + int messageId; + + if (score <= 25) + // Score level: Stage sweeper + messageId = 0x3A; + else if (score <= 50) + // Score level: Dresser + messageId = 0x3B; + else if (score <= 75) + // Score level: Usher + messageId = 0x3C; + else if (score <= 100) + // Score level: Stagehand + messageId = 0x3D; + else if (score <= 150) + // Score level: Chorus member + messageId = 0x3E; + else if (score <= 200) + // Score level: Supporting player + messageId = 0x3F; + else if (score <= 249) + // Score level: Star player + messageId = 0x40; + else + // Score level: Director + messageId = 0x41; + + _scene->_kernelMessages.add(Common::Point(160, y), 0x1110, 0x20, 0, 900, _game.getQuote(messageId)); + _scene->_sequences.addTimer(930, 3); + } + + if (_game._trigger == 3) + _game._winStatus = 1; +} + +void Scene250::actions() { +} + +void Scene250::preActions() { +} + +/*------------------------------------------------------------------------*/ + +} // End of namespace Phantom +} // End of namespace MADS diff --git a/engines/mads/phantom/phantom_scenes2.h b/engines/mads/phantom/phantom_scenes2.h new file mode 100644 index 0000000000..7e86e2ce0f --- /dev/null +++ b/engines/mads/phantom/phantom_scenes2.h @@ -0,0 +1,307 @@ +/* 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 MADS_PHANTOM_SCENES2_H +#define MADS_PHANTOM_SCENES2_H + +#include "common/scummsys.h" +#include "common/serializer.h" +#include "mads/game.h" +#include "mads/scene.h" +#include "mads/phantom/phantom_scenes.h" + +namespace MADS { + +namespace Phantom { + +class Scene2xx : public PhantomScene { +protected: + /** + * Plays an appropriate sound when entering a scene + */ + void sceneEntrySound(); + + /** + *Sets the AA file to use for the scene + */ + void setAAName(); + + /** + * Updates the prefix used for getting player sprites for the scene + */ + void setPlayerSpritesPrefix(); +public: + Scene2xx(MADSEngine *vm) : PhantomScene(vm) {} +}; + +class Scene201 : public Scene2xx { +private: + bool _anim0ActvFl; + bool _anim1ActvFl; + bool _needHoldFl; + int _sellerCount; + int _sellerStatus; + int _sellerFrame; + int _raoulFrame; + int _raoulStatus; + + void handleSellerAnimation(); + void handleRaoulAnimation(); + void handleConversation(); + +public: + Scene201(MADSEngine *vm); + virtual void synchronize(Common::Serializer &s); + + virtual void setup(); + virtual void enter(); + virtual void step(); + virtual void preActions(); + virtual void actions(); +}; + +class Scene202 : public Scene2xx { +private: + bool _ticketGivenFl; + bool _anim0ActvFl; + bool _anim1ActvFl; + bool _skipWalkFl; + int _chandeliersPosX[5]; + int _chandeliersHotspotId[5]; + int _conversationCount; + int _usherStatus; + int _usherFrame; + int _usherCount; + int _degasStatus; + int _degasFrame; + + void handleConversation1(); + void handleConversation2(); + void handleUsherAnimation(); + void handleDegasAnimation(); + void handleChandeliersPositions(); + +public: + Scene202(MADSEngine *vm); + virtual void synchronize(Common::Serializer &s); + + virtual void setup(); + virtual void enter(); + virtual void step(); + virtual void preActions(); + virtual void actions(); +}; + +class Scene203 : public Scene2xx { +private: + bool _anim0ActvFl; + bool _anim1ActvFl; + bool _anim2ActvFl; + bool _anim3ActvFl; + bool _showNoteFl; + + int _brieStatus; + int _brieFrame; + int _brieCount; + int _raoulStatus; + int _raoulFrame; + int _raoulCount; + int _richardStatus; + int _richardFrame; + int _daaeStatus; + int _daaeFrame; + int _conversationCount; + + void handleBrieConversation(); + void handleRichardConversation(); + void handleRichardAndDaaeConversation(); + void handleBrieAnimation(); + void handleRichardAnimation(); + void handleRaoulAnimation(); + void handleDaaeAnimation(); + +public: + Scene203(MADSEngine *vm); + virtual void synchronize(Common::Serializer &s); + + virtual void setup(); + virtual void enter(); + virtual void step(); + virtual void preActions(); + virtual void actions(); +}; + +class Scene204 : public Scene2xx { +private: + bool _anim0ActvFl; + bool _anim1ActvFl; + bool _anim2ActvFl; + bool _anim3ActvFl; + bool _raoulDown; + bool _florentGone; + bool _skip1Fl; + bool _skip2Fl; + bool _skip3Fl; + bool _endGameFl; + + int _brieStatus; + int _brieFrame; + int _florStatus; + int _florFrame; + int _raoulStatus; + int _raoulFrame; + int _raoulCount; + + void handleConversation(); + void handleBrieAnimation(); + void handleFlorAnimation(); + void handleRaoulAnimation(); + void handleEndAnimation(); + +public: + Scene204(MADSEngine *vm); + virtual void synchronize(Common::Serializer &s); + + virtual void setup(); + virtual void enter(); + virtual void step(); + virtual void preActions(); + virtual void actions(); +}; + +class Scene205 : public Scene2xx { +private: + bool _anim0ActvFl; + bool _anim1ActvFl; + bool _noConversationHold; + bool _giveTicketFl; + + int _richardFrame; + int _richardStatus; + int _richardCount; + int _giryFrame; + int _giryStatus; + int _giryCount; + int _conversationCounter; + int _lastRandom; + + void handleConversation18(); + void handleConversation10(); + void handleConversation11(); + void handleRichardAnimation(); + void handleGiryAnimation(); + +public: + Scene205(MADSEngine *vm); + virtual void synchronize(Common::Serializer &s); + + virtual void setup(); + virtual void enter(); + virtual void step(); + virtual void preActions(); + virtual void actions(); +}; + +class Scene206 : public Scene2xx { +private: + bool _anim0ActvFl; + bool _skip1Fl; + bool _skip2Fl; + +public: + Scene206(MADSEngine *vm); + virtual void synchronize(Common::Serializer &s); + + virtual void setup(); + virtual void enter(); + virtual void step(); + virtual void preActions(); + virtual void actions(); +}; + +class Scene207 : public Scene2xx { +private: + bool _skip1Fl; + bool _anim0ActvFl; + +public: + Scene207(MADSEngine *vm); + virtual void synchronize(Common::Serializer &s); + + virtual void setup(); + virtual void enter(); + virtual void step(); + virtual void preActions(); + virtual void actions(); +}; + +class Scene208 : public Scene2xx { +private: + bool _skip1Fl; + bool _skip2Fl; + + int _topLeftPeopleFrame; + int _topRightPeopleFrame; + int _middleLeftPeopleFrame; + int _centerPeopleFrame; + int _middleRightPeopleFrame; + int _bottomLeftPeopleFrame; + int _bottomMiddlePeopleFrame; + int _bottomRightPeopleFrame; + int _direction; + + void animateTopLeftPeople(); + void animateTopRightPeople(); + void animateMiddleLeftPeople(); + void animateCenterPeople(); + void animateMiddleRightPeople(); + void animateBottomLeftPeople(); + void animateBottomMiddlePeople(); + void animateBottomRightPeople(); + +public: + Scene208(MADSEngine *vm); + virtual void synchronize(Common::Serializer &s); + + virtual void setup(); + virtual void enter(); + virtual void step(); + virtual void preActions(); + virtual void actions(); +}; + +class Scene250 : public Scene2xx { +public: + Scene250(MADSEngine *vm); + virtual void synchronize(Common::Serializer &s); + + virtual void setup(); + virtual void enter(); + virtual void step(); + virtual void preActions(); + virtual void actions(); +}; + +} // End of namespace Phantom +} // End of namespace MADS + +#endif /* MADS_PHANTOM_SCENES2_H */ diff --git a/engines/mads/phantom/phantom_scenes3.cpp b/engines/mads/phantom/phantom_scenes3.cpp new file mode 100644 index 0000000000..33d569dec3 --- /dev/null +++ b/engines/mads/phantom/phantom_scenes3.cpp @@ -0,0 +1,2774 @@ +/* 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/scummsys.h" +#include "mads/mads.h" +#include "mads/conversations.h" +#include "mads/scene.h" +#include "mads/phantom/phantom_scenes.h" +#include "mads/phantom/phantom_scenes3.h" + +namespace MADS { + +namespace Phantom { + +void Scene3xx::setAAName() { + _game._aaName = Resources::formatAAName(_globals[kTempInterface]); + _vm->_palette->setEntry(254, 43, 47, 51); +} + +void Scene3xx::sceneEntrySound() { + if (!_vm->_musicFlag) + return; + + switch (_scene->_nextSceneId) { + case 303: + case 304: + case 305: + case 307: + case 308: + if (_globals[kKnockedOverHead]) + _vm->_sound->command(33); + else + _vm->_sound->command(16); + break; + + case 310: + case 320: + case 330: + case 340: + _vm->_sound->command(36); + break; + + default: + if (_scene->_nextSceneId != 306) + _vm->_sound->command(16); + break; + } +} + +void Scene3xx::setPlayerSpritesPrefix() { + _vm->_sound->command(5); + + if ((_scene->_nextSceneId == 304) || (_scene->_nextSceneId == 305) || (_scene->_nextSceneId == 306) || (_scene->_nextSceneId == 310)) + _game._player._spritesPrefix = ""; + else { + Common::String oldName = _game._player._spritesPrefix; + if (!_game._player._forcePrefix) + _game._player._spritesPrefix = "RAL"; + if (oldName != _game._player._spritesPrefix) + _game._player._spritesChanged = true; + } + + _game._player._scalingVelocity = true; +} + +/*------------------------------------------------------------------------*/ + +Scene301::Scene301(MADSEngine *vm) : Scene3xx(vm) { + _anim0ActvFl = false; + _skip1Fl = false; + _skip2Fl = false; + + _lightingHotspotId = -1; + _sandbagHotspotId = -1; +} + +void Scene301::synchronize(Common::Serializer &s) { + Scene3xx::synchronize(s); + + s.syncAsByte(_anim0ActvFl); + s.syncAsByte(_skip1Fl); + s.syncAsByte(_skip2Fl); + + s.syncAsSint16LE(_lightingHotspotId); + s.syncAsSint16LE(_sandbagHotspotId); +} + +void Scene301::setup() { + setPlayerSpritesPrefix(); + setAAName(); +} + +void Scene301::enter() { + _vm->_disableFastwalk = true; + + _anim0ActvFl = false; + _skip2Fl = false; + _skip1Fl = false; + + _scene->loadSpeech(6); + + _scene->_hotspots.activate(NOUN_CABLE, false); + _scene->_hotspots.activate(NOUN_STOOL, false); + + _globals._spriteIndexes[7] = _scene->_sprites.addSprites(formAnimName('a', 0)); + + if (_globals[kCurrentYear] == 1993) { + _globals._spriteIndexes[8] = _scene->_sprites.addSprites(formAnimName('a', 1)); + _globals._spriteIndexes[0] = _scene->_sprites.addSprites(formAnimName('z', 0)); + _globals._spriteIndexes[1] = _scene->_sprites.addSprites(formAnimName('z', 1)); + _globals._spriteIndexes[2] = _scene->_sprites.addSprites(formAnimName('z', 2)); + _globals._spriteIndexes[3] = _scene->_sprites.addSprites(formAnimName('z', 3)); + _globals._spriteIndexes[4] = _scene->_sprites.addSprites(formAnimName('z', 4)); + _globals._spriteIndexes[5] = _scene->_sprites.addSprites(formAnimName('z', 5)); + _globals._spriteIndexes[6] = _scene->_sprites.addSprites(formAnimName('z', 6)); + + _lightingHotspotId = _scene->_dynamicHotspots.add(NOUN_LIGHTING_INSTRUMENT, VERB_WALK_TO, SYNTAX_SINGULAR, EXT_NONE, Common::Rect(50, 116, 50 + 19, 116 + 10)); + _scene->_dynamicHotspots.setPosition(_lightingHotspotId, Common::Point(67, 129), FACING_NORTHWEST); + _lightingHotspotId = _scene->_dynamicHotspots.add(NOUN_LIGHTING_INSTRUMENT, VERB_WALK_TO, SYNTAX_SINGULAR, EXT_NONE, Common::Rect(126, 118, 126 + 29, 118 + 8)); + _scene->_dynamicHotspots.setPosition(_lightingHotspotId, Common::Point(152, 129), FACING_NORTHWEST); + + _globals._sequenceIndexes[0] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[0], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[0], 14); + + _globals._sequenceIndexes[1] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[1], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[1], 14); + + _globals._sequenceIndexes[2] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[2], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[2], 14); + + _globals._sequenceIndexes[3] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[3], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[3], 14); + + _globals._sequenceIndexes[4] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[4], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[4], 14); + + _globals._sequenceIndexes[5] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[5], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[5], 14); + + _globals._sequenceIndexes[6] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[6], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[6], 14); + + _scene->_hotspots.activate(NOUN_CABLE, true); + } else { + _sandbagHotspotId = _scene->_dynamicHotspots.add(NOUN_SANDBAG, VERB_WALK_TO, SYNTAX_SINGULAR, EXT_NONE, Common::Rect(464, 114, 464 + 11, 114 + 9)); + _scene->_dynamicHotspots.setPosition(_sandbagHotspotId, Common::Point(475, 125), FACING_NORTHWEST); + _scene->_dynamicHotspots.add(NOUN_SANDBAG, VERB_LOOK_AT, SYNTAX_SINGULAR, EXT_NONE, Common::Rect(468, 42, 468 + 6, 42 + 13)); + _scene->_hotspots.activate(NOUN_STOOL, true); + _scene->_hotspots.activate(NOUN_BIG_PROP, false); + } + + if (_scene->_priorSceneId == 302) { + _game._player.firstWalk(Common::Point(-20, 132), FACING_WEST, Common::Point(19, 132), FACING_EAST, true); + _scene->setCamera(Common::Point(0, 0)); + } else if ((_scene->_priorSceneId == 106) || (_scene->_priorSceneId != RETURNING_FROM_LOADING)) { + _game._player._playerPos = Common::Point(568, 133); + _game._player._facing = FACING_WEST; + _scene->setCamera(Common::Point(320, 0)); + } + + if (!_game._visitedScenes._sceneRevisited) { + _globals._spriteIndexes[9] = _scene->_sprites.addSprites(formAnimName('x', 0)); + _globals._sequenceIndexes[9] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[9], false, 7, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[9], 5); + _scene->_sequences.setAnimRange(_globals._sequenceIndexes[9], -1, -2); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[9], SEQUENCE_TRIGGER_EXPIRE, 0, 64); + } + + sceneEntrySound(); +} + +void Scene301::step() { + if ((_globals[kDoneBrieConv203] == 3) && (_scene->_posAdjust.x < 320) && (_game._player._playerPos.x < 350)) { + _game._player.cancelCommand(); + _game._player.walk(Common::Point(256, 130), FACING_NORTHWEST); + _game._player.setWalkTrigger(60); + _globals[kDoneBrieConv203] = 0; + _game._player._stepEnabled = false; + } + + if (_game._trigger == 60) { + _globals._animationIndexes[0] = _scene->loadAnimation(formAnimName('p', 1), 0); + _anim0ActvFl = true; + _game._player._visible = false; + _globals[kPlayerScore] += 10; + _game.syncTimers(SYNC_ANIM, _globals._animationIndexes[0], SYNC_PLAYER, 0); + } + + if (_anim0ActvFl && !_skip1Fl) { + if (_scene->_animation[_globals._animationIndexes[0]]->getCurrentFrame() == 50) { + _scene->playSpeech(6); + _skip1Fl = true; + } + } + + if (_anim0ActvFl) { + if (_scene->_animation[_globals._animationIndexes[0]]->getCurrentFrame() == 61) { + _scene->setAnimFrame(_globals._animationIndexes[0], 60); + if (!_skip2Fl) { + _vm->_sound->command(1); + _scene->_sequences.addTimer(420, 70); + _skip2Fl = true; + } + } + } + + if (_game._trigger == 70) { + _scene->_userInterface.noInventoryAnim(); + // CHECKME: Not sure about the next function call + _scene->_userInterface.refresh(); + _scene->_nextSceneId = 104; + } + + if (_game._trigger == 64) + _scene->_sequences.addTimer(60, 65); + + if (_game._trigger == 65) + _vm->_dialogs->show(30137); +} + +void Scene301::actions() { + if (_action.isAction(VERB_CLIMB_DOWN, NOUN_CIRCULAR_STAIRCASE)) { + switch (_game._trigger) { + case 0: + _game._player._stepEnabled = false; + _game._player._visible = false; + _globals._animationIndexes[0] = _scene->loadAnimation(formAnimName('d', 1), 1); + _game.syncTimers(SYNC_ANIM, _globals._animationIndexes[0], SYNC_PLAYER, 0); + break; + + case 1: + _scene->_nextSceneId = 106; + break; + + default: + break; + } + _action._inProgress = false; + return; + } + + if (_action._lookFlag) { + _vm->_dialogs->show(30110); + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_LOOK) || _action.isAction(VERB_LOOK_AT)) { + if (_action.isObject(NOUN_GRID)) { + _vm->_dialogs->show(30111); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_CATWALK)) { + _vm->_dialogs->show(30112); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_SIDE_WALL)) { + _vm->_dialogs->show(30113); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_BACK_WALL)) { + _vm->_dialogs->show(30114); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_SUPPORT)) { + _vm->_dialogs->show(30115); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_ACT_CURTAIN)) { + _vm->_dialogs->show(30116); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_HOUSE)) { + _vm->_dialogs->show(30117); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_OTHER_CATWALK)) { + _vm->_dialogs->show(30118); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_GRIDWORK)) { + _vm->_dialogs->show(30119); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_BEAM_POSITION)) { + _vm->_dialogs->show(30120); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_LIGHTING_INSTRUMENT)) { + if (_globals[kCurrentYear] == 1993) + _vm->_dialogs->show(30121); + else + _vm->_dialogs->show(30122); + + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_TARP)) { + if (_globals[kCurrentYear] == 1993) + _vm->_dialogs->show(30123); + else + _vm->_dialogs->show(30140); + + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_COUNTERWEIGHT_SYSTEM)) { + _vm->_dialogs->show(30124); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_SANDBAG) && (_action._mainObjectSource == CAT_HOTSPOT)) { + _vm->_dialogs->show(30125); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_BATTEN)) { + _vm->_dialogs->show(30126); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_STOOL)) { + _vm->_dialogs->show(30127); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_HEMP)) { + _vm->_dialogs->show(30128); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_CIRCULAR_STAIRCASE)) { + _vm->_dialogs->show(30129); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_CATWALK_OVER_HOUSE)) { + _vm->_dialogs->show(30130); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_STAIRCASE_POST)) { + _vm->_dialogs->show(30131); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_RAILING)) { + _vm->_dialogs->show(30132); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_CYCLORAMA)) { + _vm->_dialogs->show(30133); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_BIG_PROP)) { + _vm->_dialogs->show(30134); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_PROSCENIUM_ARCH)) { + _vm->_dialogs->show(30135); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_CABLE)) { + _vm->_dialogs->show(30136); + _action._inProgress = false; + return; + } + } + + if (_action.isAction(VERB_TAKE, NOUN_HEMP)) { + _vm->_dialogs->show(30138); + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_PULL, NOUN_HEMP)) { + _vm->_dialogs->show(30141); + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_TAKE, NOUN_SANDBAG) && (_action._mainObjectSource == CAT_HOTSPOT)) { + _vm->_dialogs->show(30139); + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_TAKE, NOUN_TARP)) { + _vm->_dialogs->show(30142); + _action._inProgress = false; + return; + } +} + +void Scene301::preActions() { + if (_action.isAction(VERB_EXIT_TO, NOUN_CATWALK_OVER_HOUSE)) + _game._player._walkOffScreenSceneId = 302; +} + +/*------------------------------------------------------------------------*/ + +Scene302::Scene302(MADSEngine *vm) : Scene3xx(vm) { +} + +void Scene302::synchronize(Common::Serializer &s) { + Scene3xx::synchronize(s); +} + +void Scene302::setup() { + setPlayerSpritesPrefix(); + setAAName(); +} + +void Scene302::enter() { + _globals._spriteIndexes[2] = _scene->_sprites.addSprites(formAnimName('p', 0)); + _globals._spriteIndexes[1] = _scene->_sprites.addSprites("*RRD_9"); + + if (_game._objects.isInRoom(OBJ_BLUE_FRAME)) { + _globals._sequenceIndexes[2] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[2], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[2], 14); + } else + _scene->_hotspots.activate(NOUN_BLUE_FRAME, false); + + if (_globals[kCurrentYear] == 1993) { + _globals._spriteIndexes[0] = _scene->_sprites.addSprites(formAnimName('z', -1)); + _scene->drawToBackground(_globals._spriteIndexes[0], 1, Common::Point(-32000, -32000), 0, 100); + } + + if (_scene->_priorSceneId == 303) + _game._player.firstWalk(Common::Point(-20, 134), FACING_WEST, Common::Point(15, 134), FACING_EAST, true); + else if ((_scene->_priorSceneId == 301) || (_scene->_priorSceneId != RETURNING_FROM_LOADING)) + _game._player.firstWalk(Common::Point(340, 134), FACING_WEST, Common::Point(297, 134), FACING_WEST, true); + + sceneEntrySound(); +} + +void Scene302::step() { +} + +void Scene302::actions() { + if (_action.isAction(VERB_TAKE, NOUN_BLUE_FRAME) && (_game._objects.isInRoom(OBJ_BLUE_FRAME) || _game._trigger)) { + switch (_game._trigger) { + case (0): + if (_globals[kCurrentYear] == 1881) { + int count = 0; + if (_game._objects.isInInventory(OBJ_YELLOW_FRAME)) + ++count; + if (_game._objects.isInInventory(OBJ_RED_FRAME)) + ++count; + if (_game._objects.isInInventory(OBJ_GREEN_FRAME)) + ++count; + if (count < 3) + _globals[kPlayerScore] += 5; + } + + _game._player._stepEnabled = false; + _game._player._visible = false; + _globals._sequenceIndexes[1] = _scene->_sequences.startPingPongCycle(_globals._spriteIndexes[1], true, 5, 2); + _scene->_sequences.setAnimRange(_globals._sequenceIndexes[1], 1, 5); + _scene->_sequences.setSeqPlayer(_globals._sequenceIndexes[1], true); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[1], SEQUENCE_TRIGGER_SPRITE, 5, 1); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[1], SEQUENCE_TRIGGER_EXPIRE, 0, 2); + break; + + case 1: + _scene->deleteSequence(_globals._sequenceIndexes[2]); + _scene->_hotspots.activate(NOUN_BLUE_FRAME, false); + _game._objects.addToInventory(OBJ_BLUE_FRAME); + _vm->_sound->command(26); + break; + + case 2: + _game.syncTimers(SYNC_PLAYER, 0, SYNC_SEQ, _globals._sequenceIndexes[1]); + _game._player._visible = true; + _scene->_sequences.addTimer(20, 3); + break; + + case 3: + if (_globals[kCurrentYear] == 1881) + _vm->_dialogs->showItem(OBJ_BLUE_FRAME, 844, 0); + else + _vm->_dialogs->showItem(OBJ_BLUE_FRAME, 817, 0); + + _game._player._stepEnabled = true; + break; + + default: + break; + } + _action._inProgress = false; + return; + } + + if (_action._lookFlag) { + _vm->_dialogs->show(30210); + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_LOOK) || _action.isAction(VERB_LOOK_AT)) { + if (_action.isObject(NOUN_CATWALK)) { + _vm->_dialogs->show(30211); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_GRID)) { + _vm->_dialogs->show(30212); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_HEMP)) { + _vm->_dialogs->show(30213); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_SIDE_WALL)) { + _vm->_dialogs->show(30214); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_CATWALK)) { + _vm->_dialogs->show(30215); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_RAILING)) { + _vm->_dialogs->show(30216); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_BEAM_POSITION)) { + _vm->_dialogs->show(30217); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_LIGHTING_INSTRUMENT)) { + if (_globals[kCurrentYear] == 1993) + _vm->_dialogs->show(30218); + else + _vm->_dialogs->show(30219); + + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_BLUE_FRAME) && _game._objects.isInRoom(OBJ_BLUE_FRAME)) { + if (_globals[kCurrentYear] == 1993) + _vm->_dialogs->show(30220); + else + _vm->_dialogs->show(30221); + + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_SUPPORT)) { + _vm->_dialogs->show(30222); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_OTHER_CATWALK)) { + _vm->_dialogs->show(30223); + _action._inProgress = false; + return; + } + } + + if (_action.isAction(VERB_TAKE, NOUN_HEMP)) { + _vm->_dialogs->show(30224); + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_PULL, NOUN_HEMP)) { + _vm->_dialogs->show(30141); + _action._inProgress = false; + return; + } +} + +void Scene302::preActions() { + if (_action.isAction(VERB_EXIT_TO, NOUN_CATWALK)) { + if (_scene->_customDest.x > 160) + _game._player._walkOffScreenSceneId = 301; + else + _game._player._walkOffScreenSceneId = 303; + } +} + +/*------------------------------------------------------------------------*/ + +Scene303::Scene303(MADSEngine *vm) : Scene3xx(vm) { + _anim0ActvFl = false; + _hempHotspotId = -1; + _skipFrameCheckFl = -1; +} + +void Scene303::synchronize(Common::Serializer &s) { + Scene3xx::synchronize(s); + + s.syncAsByte(_anim0ActvFl); + s.syncAsSint16LE(_hempHotspotId); + s.syncAsSint16LE(_skipFrameCheckFl); +} + +void Scene303::setup() { + setPlayerSpritesPrefix(); + setAAName(); + + _scene->addActiveVocab(NOUN_CHANDELIER_CABLE); + _scene->addActiveVocab(VERB_CLIMB_DOWN); +} + +void Scene303::enter() { + _anim0ActvFl = false; + _skipFrameCheckFl = false; + + if (_globals[kRightDoorIsOpen504]) + _vm->_gameConv->get(26); + + if (_globals[kCurrentYear] == 1993) { + _globals._spriteIndexes[0] = _scene->_sprites.addSprites(formAnimName('z', -1)); + _globals._spriteIndexes[2] = _scene->_sprites.addSprites(formAnimName('p', 0)); + } + + if ((_game._objects.isInRoom(OBJ_LARGE_NOTE)) && (_globals[kCurrentYear] == 1993)) { + _globals._sequenceIndexes[2] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[2], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[2], 4); + } else + _scene->_hotspots.activate(NOUN_LARGE_NOTE, false); + + if (_globals[kCurrentYear] == 1993) + _scene->drawToBackground(_globals._spriteIndexes[0], 1, Common::Point(-32000, -32000), 0, 100); + else { + _hempHotspotId = _scene->_dynamicHotspots.add(NOUN_CHANDELIER_CABLE, VERB_CLIMB_DOWN, SYNTAX_SINGULAR, EXT_NONE, Common::Rect(74, 92, 74 + 7, 92 + 12)); + _scene->_dynamicHotspots.setPosition(_hempHotspotId, Common::Point(95, 107), FACING_NORTHWEST); + _scene->_dynamicHotspots[_hempHotspotId]._articleNumber = PREP_ON; + _scene->_dynamicHotspots.setCursor(_hempHotspotId, CURSOR_GO_DOWN); + } + + if (_scene->_priorSceneId == 307) + _game._player.firstWalk(Common::Point(-20, 135), FACING_EAST, Common::Point(16, 135), FACING_EAST, true); + else if (_scene->_priorSceneId == 304) { + _globals._animationIndexes[0] = _scene->loadAnimation(formAnimName('u', 1), 60); + _game._player._stepEnabled = false; + _game._player._visible = false; + } else if (_scene->_priorSceneId == 305) { + _game._objects.addToInventory(OBJ_SWORD); + _game._player._playerPos = Common::Point(117, 92); + _game._player._facing = FACING_SOUTHWEST; + } else if ((_scene->_priorSceneId == 302) || (_scene->_priorSceneId != RETURNING_FROM_LOADING)) + _game._player.firstWalk(Common::Point(340, 136), FACING_WEST, Common::Point(303, 136), FACING_WEST, true); + + _scene->_rails.disableLine(5, 9); + _scene->_rails.disableLine(5, 12); + _scene->_rails.disableLine(5, 8); + _scene->_rails.disableLine(6, 3); + _scene->_rails.disableLine(6, 2); + _scene->_rails.disableLine(11, 3); + _scene->_rails.disableLine(11, 4); + _scene->_rails.disableLine(10, 2); + _scene->_rails.disableLine(4, 9); + _scene->_rails.disableLine(8, 0); + + sceneEntrySound(); +} + +void Scene303::step() { + if (_game._trigger == 60) { + _game._player._playerPos = Common::Point(110, 95); + _game._player._stepEnabled = true; + _game._player._visible = true; + _game.syncTimers(SYNC_PLAYER, 0, SYNC_ANIM, _globals._animationIndexes[0]); + _game._player.resetFacing(FACING_SOUTHWEST); + } + + if (_anim0ActvFl) { + if ((_scene->_animation[_globals._animationIndexes[0]]->getCurrentFrame() >= 6) && !_skipFrameCheckFl) { + _skipFrameCheckFl = true; + _scene->deleteSequence(_globals._sequenceIndexes[2]); + _scene->_hotspots.activate(NOUN_LARGE_NOTE, false); + _game._objects.addToInventory(OBJ_LARGE_NOTE); + _vm->_sound->command(26); + } + } +} + +void Scene303::actions() { + if ((_action.isAction(VERB_TAKE, NOUN_LARGE_NOTE) && _game._objects.isInRoom(OBJ_LARGE_NOTE)) || ((_game._trigger > 0) && _game._trigger < 3)) { + switch (_game._trigger) { + case (0): + _game._player._stepEnabled = false; + _game._player._visible = false; + _globals._animationIndexes[0] = _scene->loadAnimation(formAnimName('n', 1), 1); + _anim0ActvFl = true; + _game.syncTimers(SYNC_ANIM, _globals._animationIndexes[0], SYNC_PLAYER, 0); + _globals[kPlayerScore] += 5; + break; + + case 1: + _anim0ActvFl = false; + _game._player._visible = true; + _game.syncTimers(SYNC_PLAYER, 0, SYNC_ANIM, _globals._animationIndexes[0]); + _scene->_sequences.addTimer(20, 2); + break; + + case 2: + _vm->_dialogs->showItem(OBJ_LARGE_NOTE, 818, 7); + _game._player._stepEnabled = true; + break; + } + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_CLIMB_INTO, NOUN_HOLE) || _action.isAction(VERB_CLIMB_DOWN, NOUN_CHANDELIER_CABLE)) { + if (_globals[kCurrentYear] == 1881) { + switch (_game._trigger) { + case 0: + if (_globals[kRightDoorIsOpen504]) + _vm->_dialogs->show(30331); + + _globals._animationIndexes[0] = _scene->loadAnimation(formAnimName('d', 1), 3); + _game._player._stepEnabled = false; + _game._player._visible = false; + _game.syncTimers(SYNC_ANIM, _globals._animationIndexes[0], SYNC_PLAYER, 0); + break; + + case 3: + _scene->_nextSceneId = 304; + break; + + default: + break; + } + } else + _vm->_dialogs->show(30325); + + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_EXIT_TO, NOUN_CATWALK)) { + if (_globals[kRightDoorIsOpen504]) { + if (_vm->_sound->_preferRoland) + _vm->_sound->command(74); + else + _scene->playSpeech(1); + + _vm->_gameConv->run(26); + _vm->_gameConv->exportValue(4); + _action._inProgress = false; + return; + } + } + + if (_action._lookFlag) { + _vm->_dialogs->show(30310); + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_LOOK) || _action.isAction(VERB_LOOK_AT)) { + // CHECKME: That's illogical, the check is always false... Should be out of the big 'look' check + // It looks to me like an original bug + if (_action.isAction(VERB_EXIT_TO, NOUN_CATWALK)) { + _vm->_dialogs->show(30316); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_CATWALK)) { + _vm->_dialogs->show(30311); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_GRID)) { + _vm->_dialogs->show(30312); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_CHANDELIER_CABLE)) { + if (_globals[kCurrentYear] == 1993) + _vm->_dialogs->show(30317); + else if (_globals[kRightDoorIsOpen504]) + _vm->_dialogs->show(30330); + else + _vm->_dialogs->show(30329); + + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_HEMP)) { + _vm->_dialogs->show(30313); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_BACK_WALL)) { + _vm->_dialogs->show(30314); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_DUCTWORK)) { + _vm->_dialogs->show(30315); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_CRATE)) { + _vm->_dialogs->show(30318); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_SUPPORT)) { + _vm->_dialogs->show(30319); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_PIECE_OF_WOOD)) { + _vm->_dialogs->show(30320); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_RAILING)) { + _vm->_dialogs->show(30321); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_CHANDELIER_TRAP)) { + _vm->_dialogs->show(30322); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_HOLE)) { + if (_globals[kCurrentYear] == 1993) + _vm->_dialogs->show(30326); + else + _vm->_dialogs->show(30323); + + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_LARGE_NOTE) && _game._objects.isInRoom(OBJ_LARGE_NOTE)) { + _vm->_dialogs->show(30324); + _action._inProgress = false; + return; + } + } + + if (_action.isAction(VERB_WALK_TO, NOUN_HOLE)) { + _vm->_dialogs->show(30325); + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_TAKE, NOUN_HEMP)) { + _vm->_dialogs->show(30327); + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_PULL, NOUN_HEMP)) { + _vm->_dialogs->show(30141); + _action._inProgress = false; + return; + } +} + +void Scene303::preActions() { + if (_action.isAction(VERB_EXIT_TO, NOUN_CATWALK) && !_globals[kRightDoorIsOpen504]) { + if (_scene->_customDest.x > 160) + _game._player._walkOffScreenSceneId = 302; + else + _game._player._walkOffScreenSceneId = 307; + } + + if (_action.isAction(VERB_CLIMB_INTO, NOUN_HOLE) || _action.isAction(VERB_CLIMB_DOWN, NOUN_CHANDELIER_CABLE)) + _game._player.walk(Common::Point(110, 95), FACING_SOUTHWEST); +} + +/*------------------------------------------------------------------------*/ + +Scene304::Scene304(MADSEngine *vm) : Scene3xx(vm) { + _anim0ActvFl = false; + _anim1ActvFl = false; + _anim2ActvFl = false; + + _raoulFrame = -1; + _raoulStatus = -1; + _fightFrame = -1; + _fightStatus = -1; + _fightCount = -1; + _phantomFrame = -1; + _phantomStatus = -1; +} + +void Scene304::synchronize(Common::Serializer &s) { + Scene3xx::synchronize(s); + + s.syncAsByte(_anim0ActvFl); + s.syncAsByte(_anim1ActvFl); + s.syncAsByte(_anim2ActvFl); + + s.syncAsSint16LE(_raoulFrame); + s.syncAsSint16LE(_raoulStatus); + s.syncAsSint16LE(_fightFrame); + s.syncAsSint16LE(_fightStatus); + s.syncAsSint16LE(_fightCount); + s.syncAsSint16LE(_phantomFrame); + s.syncAsSint16LE(_phantomStatus); +} + +void Scene304::setup() { + setPlayerSpritesPrefix(); + setAAName(); +} + +void Scene304::enter() { + _game._player._playerPos.x = 0; + + if (_scene->_priorSceneId != RETURNING_FROM_LOADING) { + _anim0ActvFl = false; + _anim1ActvFl = false; + _anim2ActvFl = false; + } + + if (_globals[kRightDoorIsOpen504]) + _vm->_gameConv->get(23); + + if (!_globals[kRightDoorIsOpen504]) { + _globals._spriteIndexes[1] = _scene->_sprites.addSprites(formAnimName('f', 1)); + _globals._sequenceIndexes[1] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[1], false, -1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[1], 1); + + _globals._animationIndexes[0] = _scene->loadAnimation(formAnimName('n', 1), 0); + _anim0ActvFl = true; + _raoulStatus = 1; + _game._player._stepEnabled = false; + } else { + _scene->_userInterface.setup(kInputLimitedSentences); + + if (_scene->_priorSceneId == 305) { + _globals._spriteIndexes[0] = _scene->_sprites.addSprites(formAnimName('f', 0)); + _scene->drawToBackground(_globals._spriteIndexes[0], 1, Common::Point(-32000, -32000), 0, 100); + + _game._player._stepEnabled = false; + _globals._animationIndexes[1] = _scene->loadAnimation(formAnimName('f', 1), 0); + _anim1ActvFl = true; + _scene->setAnimFrame(_globals._animationIndexes[1], 138); + + } else { + + _globals._spriteIndexes[0] = _scene->_sprites.addSprites(formAnimName('f', 0)); + _scene->drawToBackground(_globals._spriteIndexes[0], 1, Common::Point(-32000, -32000), 0, 100); + + _globals._animationIndexes[1] = _scene->loadAnimation(formAnimName('f', 1), 0); + _anim1ActvFl = true; + _phantomStatus = 0; + + _globals._animationIndexes[2] = _scene->loadAnimation(formAnimName('r', 1), 0); + _anim2ActvFl = true; + _fightStatus = 0; + + _game._player._stepEnabled = false; + _fightCount = 0; + + _globals[kPlayerScore] += 10; + + _vm->_gameConv->run(23); + _vm->_gameConv->hold(); + } + } + + + if ((_scene->_priorSceneId == RETURNING_FROM_LOADING) && !_globals[kRightDoorIsOpen504]) { + _scene->setAnimFrame(_globals._animationIndexes[0], 53); + _game._player._stepEnabled = true; + } + + _game._player._visible = false; + + sceneEntrySound(); +} + +void Scene304::step() { + if (_anim0ActvFl) + handleRaoulAnimation(); + + if (_anim1ActvFl) + handlePhantomAnimation(); + + if (_anim2ActvFl) + handleFightAnimation(); +} + +void Scene304::actions() { + if (_vm->_gameConv->_running == 23) { + handleConversation23(); + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_CLIMB_THROUGH, NOUN_OPENING) || _action.isAction(VERB_CLIMB, NOUN_CHANDELIER_CABLE)) { + _raoulStatus = 0; + _action._inProgress = false; + return; + } + + if (_action._lookFlag) { + _vm->_dialogs->show(30410); + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_LOOK) || _action.isAction(VERB_LOOK_AT)) { + if (_action.isObject(NOUN_CEILING)) { + _vm->_dialogs->show(30411); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_DOME)) { + _vm->_dialogs->show(30412); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_LATTICEWORK)) { + _vm->_dialogs->show(30413); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_OPENING)) { + _vm->_dialogs->show(30414); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_CHANDELIER)) { + _vm->_dialogs->show(30415); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_CHANDELIER_CABLE)) { + _vm->_dialogs->show(30416); + _action._inProgress = false; + return; + } + } +} + +void Scene304::preActions() { +} + +void Scene304::handleConversation23() { + switch (_action._activeAction._verbId) { + case 5: + _phantomStatus = 1; + _vm->_gameConv->hold(); + break; + + case 6: + if (_phantomStatus != 1) + _fightStatus = 0; + + _vm->_gameConv->hold(); + break; + + case 9: + if (_phantomStatus != 1) + _fightStatus = 2; + + break; + + case 12: + _phantomStatus = 2; + break; + + default: + break; + } + + _fightCount = 0; +} + +void Scene304::handleRaoulAnimation() { + if (_scene->_animation[_globals._animationIndexes[0]]->getCurrentFrame() == _raoulFrame) + return; + + _raoulFrame = _scene->_animation[_globals._animationIndexes[0]]->getCurrentFrame(); + int resetFrame = -1; + + switch (_raoulFrame) { + case 20: + _game._player._stepEnabled = true; + resetFrame = 53; + break; + + case 53: + _scene->_nextSceneId = 303; + break; + + case 54: + case 55: + case 56: + if (_raoulStatus == 0) { + resetFrame = 20; + _game._player._stepEnabled = false; + } else { + int random = _vm->getRandomNumber(1, 50); + switch (_raoulFrame) { + case 54: + if (random == 1) + resetFrame = 54; + else if (random == 2) + resetFrame = 55; + else + resetFrame = _raoulFrame - 1; + + break; + + case 55: + if (random == 1) + resetFrame = 54; + else if (random == 2) + resetFrame = 53; + else + resetFrame = _raoulFrame - 1; + + break; + + case 56: + if (random == 1) + resetFrame = 55; + else if (random == 2) + resetFrame = 53; + else + resetFrame = _raoulFrame - 1; + + break; + + default: + break; + } + } + break; + } + + if (resetFrame >= 0) { + _scene->setAnimFrame(_globals._animationIndexes[0], resetFrame); + _raoulFrame = resetFrame; + } +} + +void Scene304::handlePhantomAnimation() { + if (_scene->_animation[_globals._animationIndexes[1]]->getCurrentFrame() == _phantomFrame) + return; + + _phantomFrame = _scene->_animation[_globals._animationIndexes[1]]->getCurrentFrame(); + int resetFrame = -1; + + switch (_phantomFrame) { + case 7: + case 11: + resetFrame = _vm->getRandomNumber(6, 7); + + if (_phantomStatus == 1) + resetFrame = 7; + + break; + + case 9: + case 15: + switch (_vm->getRandomNumber(1, 3)) { + case 1: + resetFrame = 8; + break; + + case 2: + resetFrame = 9; + break; + + case 3: + resetFrame = 11; + break; + } + + if (_phantomStatus == 1) + resetFrame = 11; + + break; + + case 13: + case 24: + switch (_vm->getRandomNumber(1, 3)) { + case 1: + resetFrame = 12; + break; + + case 2: + resetFrame = 13; + break; + + case 3: + resetFrame = 16; + break; + } + + if (_phantomStatus == 1) + resetFrame = 16; + + break; + + case 20: + if (_vm->getRandomNumber(1, 2) == 1) + resetFrame = 19; + else + resetFrame = 20; + + if (_phantomStatus == 1) + resetFrame = 24; + + break; + + case 25: + _vm->_gameConv->release(); + break; + + case 47: + _fightStatus = 0; + break; + + case 59: + if (_phantomStatus == 2) + resetFrame = 59; + else + resetFrame = 58; + break; + + case 60: + _game._player._stepEnabled = false; + break; + + case 80: + _game._objects.setRoom(OBJ_SWORD, NOWHERE); + break; + + case 137: + _game._player._playerPos.x = 100; + _scene->_nextSceneId = 305; + break; + + case 176: + _game._player._playerPos.x = 200; + _scene->_nextSceneId = 305; + break; + + default: + break; + } + + if (resetFrame >= 0) { + _scene->setAnimFrame(_globals._animationIndexes[1], resetFrame); + _phantomFrame = resetFrame; + } +} + +void Scene304::handleFightAnimation() { + if (_scene->_animation[_globals._animationIndexes[2]]->getCurrentFrame() == _fightFrame) + return; + + _fightFrame = _scene->_animation[_globals._animationIndexes[2]]->getCurrentFrame(); + int resetFrame = -1; + + switch (_fightFrame) { + case 22: + _vm->_gameConv->release(); + break; + + case 23: + if (_fightStatus != 2) + resetFrame = 22; + break; + + case 25: + case 26: + case 27: + if (_fightStatus == 2) { + resetFrame = _vm->getRandomNumber(24, 26); + ++_fightCount; + if (_fightCount > 17) + resetFrame = 24; + } + break; + + case 28: + _fightStatus = 2; + break; + + case 45: + _vm->_gameConv->release(); + break; + + case 46: + case 47: + case 48: + if (_fightStatus == 2) { + resetFrame = _vm->getRandomNumber(45, 47); + ++_fightCount; + if (_fightCount > 17) + resetFrame = 45; + } + break; + + default: + break; + } + + if (resetFrame >= 0) { + _scene->setAnimFrame(_globals._animationIndexes[2], resetFrame); + _fightFrame = resetFrame; + } +} + +/*------------------------------------------------------------------------*/ + +Scene305::Scene305(MADSEngine *vm) : Scene3xx(vm) { + _anim0ActvFl = false; + _anim1ActvFl = false; + _skipFl = false; + _unmaskFl = false; + + _unmaskFrame = -1; +} + +void Scene305::synchronize(Common::Serializer &s) { + Scene3xx::synchronize(s); + + s.syncAsByte(_anim0ActvFl); + s.syncAsByte(_anim1ActvFl); + s.syncAsByte(_skipFl); + s.syncAsByte(_unmaskFl); + + s.syncAsSint16LE(_unmaskFrame); +} + +void Scene305::setup() { + setPlayerSpritesPrefix(); + setAAName(); +} + +void Scene305::enter() { + _unmaskFl = false; + _skipFl = false; + _game._player._visible = false; + _anim0ActvFl = false; + _anim1ActvFl = false; + + _scene->_userInterface.setup(kInputLimitedSentences); + _scene->loadSpeech(5); + _game.loadQuoteSet(0x64, 0x65, 0); + + if (_game._player._playerPos.x == 100) { + _globals._animationIndexes[0] = _scene->loadAnimation(formAnimName('r', 1), 60); + _scene->_hotspots.activate(NOUN_MASK, false); + _anim1ActvFl = true; + } else if (_game._player._playerPos.x == 200) { + _globals._animationIndexes[0] = _scene->loadAnimation(formAnimName('u', 1), 0); + _anim0ActvFl = true; + _scene->_hotspots.activate(NOUN_CANE, false); + } + + sceneEntrySound(); +} + +void Scene305::step() { + if (_anim0ActvFl) + handle_animation_unmask (); + + if (_anim1ActvFl) { + if (_scene->_animation[_globals._animationIndexes[0]]->getCurrentFrame() == 53) + _game._player._stepEnabled = false; + + if (_scene->_animation[_globals._animationIndexes[0]]->getCurrentFrame() == 54 && !_skipFl) { + _scene->playSpeech(5); + _skipFl = true; + } + } + + if (_game._trigger == 60) { + _globals[kPlayerScore] -= 10; + _scene->_userInterface.noInventoryAnim(); + // CHECKME: Not sure about the next function call + _scene->_userInterface.refresh(); + _scene->_nextSceneId = 303; + } +} + +void Scene305::actions() { + if (_action.isAction(VERB_PUSH, NOUN_CANE)) { + _scene->_nextSceneId = 304; + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_TAKE, NOUN_MASK)) { + _unmaskFl = true; + _game._player._stepEnabled = false; + _action._inProgress = false; + } +} + +void Scene305::preActions() { +} + +void Scene305::handle_animation_unmask() { + if (_scene->_animation[_globals._animationIndexes[0]]->getCurrentFrame() == _unmaskFrame) + return; + + _unmaskFrame = _scene->_animation[_globals._animationIndexes[0]]->getCurrentFrame(); + int resetFrame = -1; + + switch (_unmaskFrame) { + case 25: + if (!_unmaskFl) + resetFrame = 0; + + break; + + case 60: + _scene->playSpeech(10); + _scene->_kernelMessages.add(Common::Point(176, 53), 0x1110, 0, 0, 360, _game.getQuote(0x64)); + _scene->_kernelMessages.add(Common::Point(176, 68), 0x1110, 0, 0, 360, _game.getQuote(0x65)); + break; + + case 95: + _scene->_nextSceneId = 306; + break; + + default: + break; + } + + if (resetFrame >= 0) { + _scene->setAnimFrame(_globals._animationIndexes[0], resetFrame); + _unmaskFrame = resetFrame; + } +} + +/*------------------------------------------------------------------------*/ + +Scene306::Scene306(MADSEngine *vm) : Scene3xx(vm) { + _speechDoneFl = false; +} + +void Scene306::synchronize(Common::Serializer &s) { + Scene3xx::synchronize(s); + + s.syncAsByte(_speechDoneFl); +} + +void Scene306::setup() { + setPlayerSpritesPrefix(); + setAAName(); +} + +void Scene306::enter() { + _scene->loadSpeech(6); + _speechDoneFl = false; + + warning("TODO: Switch to letter box view. See definition of MADS_MENU_Y"); + + _game._player._visible = false; + _game._player._stepEnabled = false; + _globals._animationIndexes[0] = _scene->loadAnimation(formAnimName('a', 1), 60); + + sceneEntrySound(); +} + +void Scene306::step() { + if (_game._trigger == 60) { + if (_vm->_sound->_preferRoland) + _scene->_sequences.addTimer(120, 61); + else + _scene->_sequences.addTimer(300, 61); + } + + if (!_speechDoneFl && (_scene->_animation[_globals._animationIndexes[0]]->getCurrentFrame() == 3)) { + _scene->playSpeech(6); + _speechDoneFl = true; + } + + if (_game._trigger == 61) { + _vm->_sound->command(1); + _vm->_sound->command(66); + _scene->_sequences.addTimer(120, 62); + } + + if (_game._trigger == 62) + _scene->_nextSceneId = 150; +} + +void Scene306::actions() { +} + +void Scene306::preActions() { +} + +/*------------------------------------------------------------------------*/ + +Scene307::Scene307(MADSEngine *vm) : Scene3xx(vm) { +} + +void Scene307::synchronize(Common::Serializer &s) { + Scene3xx::synchronize(s); +} + +void Scene307::setup() { + setPlayerSpritesPrefix(); + setAAName(); +} + +void Scene307::enter() { + _globals._spriteIndexes[2] = _scene->_sprites.addSprites(formAnimName('p', 0)); + _globals._spriteIndexes[3] = _scene->_sprites.addSprites(formAnimName('x', 0)); + _globals._spriteIndexes[1] = _scene->_sprites.addSprites("*RRD_9"); + _globals._spriteIndexes[4] = _scene->_sprites.addSprites("*RDR_9"); + + if (_globals[kRightDoorIsOpen504]) + _scene->_hotspots.activate(NOUN_DOOR, true); + else + _scene->_hotspots.activate(NOUN_DOOR, false); + + if (_game._objects.isInRoom(OBJ_GREEN_FRAME) && (_game._difficulty == DIFFICULTY_EASY)) { + _globals._sequenceIndexes[2] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[2], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[2], 14); + } else + _scene->_hotspots.activate(NOUN_GREEN_FRAME, false); + + if (_scene->_priorSceneId == 308) { + _game._player._playerPos = Common::Point(18, 134); + _game._player._facing = FACING_SOUTHEAST; + _game._player._stepEnabled = false; + _globals._sequenceIndexes[3] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[3], false, -2); + if (!(_globals[kPlayerScoreFlags] & 16)) { + _globals[kPlayerScoreFlags] |= 16; + _globals[kPlayerScore] += 5; + } + _scene->_sequences.setDepth(_globals._sequenceIndexes[3], 4); + _game._player.walk(Common::Point(41, 137), FACING_EAST); + _game._player.setWalkTrigger(60); + } else if ((_scene->_priorSceneId == 303) || (_scene->_priorSceneId != RETURNING_FROM_LOADING)) + _game._player.firstWalk(Common::Point(340, 137), FACING_WEST, Common::Point(304, 137), FACING_WEST, true); + + sceneEntrySound(); +} + +void Scene307::step() { + switch (_game._trigger) { + case 60: + _scene->deleteSequence(_globals._sequenceIndexes[3]); + _globals._sequenceIndexes[3] = _scene->_sequences.addReverseSpriteCycle(_globals._spriteIndexes[3], false, 8, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[3], 10); + _scene->_sequences.setAnimRange(_globals._sequenceIndexes[3], -1, -2); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SEQUENCE_TRIGGER_EXPIRE, 0, 61); + break; + + case 61: + _vm->_sound->command(25); + _game._player._stepEnabled = true; + break; + + default: + break; + } +} + +void Scene307::actions() { + if (_action.isAction(VERB_TAKE, NOUN_GREEN_FRAME) && (_game._objects.isInRoom(OBJ_GREEN_FRAME) || _game._trigger)) { + switch (_game._trigger) { + case (0): + if (_globals[kCurrentYear] == 1881) { + int count = 0; + if (_game._objects.isInInventory(OBJ_YELLOW_FRAME)) + ++count; + if (_game._objects.isInInventory(OBJ_RED_FRAME)) + ++count; + if (_game._objects.isInInventory(OBJ_BLUE_FRAME)) + ++count; + + if (count < 3) + _globals[kPlayerScore] += 5; + } + + _game._player._stepEnabled = false; + _game._player._visible = false; + _globals._sequenceIndexes[1] = _scene->_sequences.startPingPongCycle(_globals._spriteIndexes[1], false, 5, 2); + _scene->_sequences.setAnimRange(_globals._sequenceIndexes[1], 1, 5); + _scene->_sequences.setSeqPlayer(_globals._sequenceIndexes[1], true); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[1], SEQUENCE_TRIGGER_SPRITE, 5, 1); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[1], SEQUENCE_TRIGGER_EXPIRE, 0, 2); + break; + + case 1: + _scene->deleteSequence(_globals._sequenceIndexes[2]); + _scene->_hotspots.activate(NOUN_GREEN_FRAME, false); + _game._objects.addToInventory(OBJ_GREEN_FRAME); + _vm->_sound->command(26); + break; + + case 2: + _game.syncTimers(SYNC_PLAYER, 0, SYNC_SEQ, _globals._sequenceIndexes[1]); + _game._player._visible = true; + _scene->_sequences.addTimer(20, 3); + break; + + case 3: + if (_globals[kCurrentYear] == 1881) + _vm->_dialogs->showItem(OBJ_GREEN_FRAME, 845, 0); + else + _vm->_dialogs->showItem(OBJ_GREEN_FRAME, 819, 0); + + _game._player._stepEnabled = true; + break; + + default: + break; + } + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_WALK_THROUGH, NOUN_DOOR) || _action.isAction(VERB_OPEN, NOUN_DOOR)) { + switch (_game._trigger) { + case (0): + _game._player._stepEnabled = false; + _game._player._visible = false; + _globals._sequenceIndexes[4] = _scene->_sequences.startPingPongCycle(_globals._spriteIndexes[4], true, 5, 2); + _scene->_sequences.setAnimRange(_globals._sequenceIndexes[4], 1, 4); + _scene->_sequences.setSeqPlayer(_globals._sequenceIndexes[4], true); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[4], SEQUENCE_TRIGGER_SPRITE, 4, 70); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[4], SEQUENCE_TRIGGER_EXPIRE, 0, 72); + break; + + case 70: + _vm->_sound->command(24); + _globals._sequenceIndexes[3] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[3], false, 8, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[3], 14); + _scene->_sequences.setAnimRange(_globals._sequenceIndexes[3], -1, -2); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SEQUENCE_TRIGGER_EXPIRE, 0, 71); + break; + + case 71: { + int idx = _globals._sequenceIndexes[3]; + _globals._sequenceIndexes[3] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[3], false, -2); + _game.syncTimers(SYNC_SEQ, _globals._sequenceIndexes[3], SYNC_SEQ, idx); + _scene->_sequences.setDepth(_globals._sequenceIndexes[3], 14); + _scene->_sequences.addTimer(10, 73); + } + break; + + case 72: + _game._player._visible = true; + break; + + case 73: + _scene->_nextSceneId = 308; + break; + + default: + break; + } + _action._inProgress = false; + return; + } + + if (_action._lookFlag) { + _vm->_dialogs->show(30710); + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_LOOK) || _action.isAction(VERB_LOOK_AT)) { + if (_action.isObject(NOUN_COLUMN)) { + if (_globals[kRightDoorIsOpen504]) + _vm->_dialogs->show(30725); + else + _vm->_dialogs->show(30711); + + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_CATWALK)) { + _vm->_dialogs->show(30712); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_GRID)) { + _vm->_dialogs->show(30713); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_GIRDER)) { + _vm->_dialogs->show(30714); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_GRIDWORK)) { + _vm->_dialogs->show(30715); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_HEMP)) { + _vm->_dialogs->show(30716); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_BACK_WALL)) { + _vm->_dialogs->show(30717); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_DUCTWORK)) { + _vm->_dialogs->show(30718); + _action._inProgress = false; + return; + } + + if ((_action.isObject(NOUN_GREEN_FRAME)) && (_game._objects.isInRoom(OBJ_GREEN_FRAME))) { + if (_globals[kCurrentYear] == 1993) + _vm->_dialogs->show(30719); + else + _vm->_dialogs->show(30720); + + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_ALCOVE)) { + _vm->_dialogs->show(30721); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_RAILING)) { + _vm->_dialogs->show(30722); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_DOOR)) { + _vm->_dialogs->show(30726); + _action._inProgress = false; + return; + } + } + + if (_action.isAction(VERB_TAKE, NOUN_HEMP)) { + _vm->_dialogs->show(30723); + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_PULL, NOUN_HEMP)) { + _vm->_dialogs->show(30141); + _action._inProgress = false; + } +} + +void Scene307::preActions() { + if (_action.isAction(VERB_EXIT_TO, NOUN_ALCOVE)) + _game._player._walkOffScreenSceneId = 303; + + if (_action.isAction(VERB_OPEN, NOUN_DOOR)) + _game._player.walk(Common::Point(28, 137), FACING_NORTHWEST); +} + +/*------------------------------------------------------------------------*/ + +Scene308::Scene308(MADSEngine *vm) : Scene3xx(vm) { + _anim0ActvFl = false; + _anim1ActvFl = false; + _anim2ActvFl = false; + _anim3ActvFl = false; + _skip1Fl = false; + _skip2Fl = false; + + _currentFloor = -1; +} + +void Scene308::synchronize(Common::Serializer &s) { + Scene3xx::synchronize(s); + + s.syncAsByte(_anim0ActvFl); + s.syncAsByte(_anim1ActvFl); + s.syncAsByte(_anim2ActvFl); + s.syncAsByte(_anim3ActvFl); + s.syncAsByte(_skip1Fl); + s.syncAsByte(_skip2Fl); + + s.syncAsSint16LE(_currentFloor); +} + +void Scene308::setup() { + setPlayerSpritesPrefix(); + setAAName(); +} + +void Scene308::enter() { + _scene->loadSpeech(4); + + if (_scene->_priorSceneId != RETURNING_FROM_LOADING) { + _anim0ActvFl = false; + _anim1ActvFl = false; + _anim2ActvFl = false; + _anim3ActvFl = false; + } + + _skip1Fl = false; + _skip2Fl = false; + + _vm->_gameConv->get(26); + _globals._spriteIndexes[0] = _scene->_sprites.addSprites(formAnimName('a', 0)); + _globals._spriteIndexes[1] = _scene->_sprites.addSprites(formAnimName('b', 0)); + _scene->_userInterface.setup(kInputLimitedSentences); + _game._player._visible = false; + + if (_scene->_priorSceneId == RETURNING_FROM_LOADING) { + switch (_currentFloor) { + case 1: + if (_globals[kRightDoorIsOpen504]) { + _globals._sequenceIndexes[0] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[0], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[0], 10); + _scene->_sequences.setPosition(_globals._sequenceIndexes[0], Common::Point(160, 104)); + _globals._sequenceIndexes[1] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[1], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[1], 10); + _scene->_sequences.setPosition(_globals._sequenceIndexes[1], Common::Point(161, 124)); + } else { + _globals._sequenceIndexes[0] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[0], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[0], 10); + _scene->_sequences.setPosition(_globals._sequenceIndexes[0], Common::Point(160, 127)); + } + break; + + case 2: + _globals._sequenceIndexes[0] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[0], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[0], 10); + _scene->_sequences.setPosition(_globals._sequenceIndexes[0], Common::Point(160, 76)); + break; + + case 3: + if (_globals[kRightDoorIsOpen504] && !_globals[kKnockedOverHead]) { + _anim0ActvFl = true; + _skip1Fl = true; + _globals._animationIndexes[0] = _scene->loadAnimation(formAnimName('b', 2), 2); + _scene->setAnimFrame(_globals._animationIndexes[0], 76); + } else { + _anim0ActvFl = true; + _skip1Fl = true; + _globals._animationIndexes[0] = _scene->loadAnimation(formAnimName('u', 2), 2); + _scene->setAnimFrame(_globals._animationIndexes[0], 96); + } + break; + + default: + break; + } + } else if (_scene->_priorSceneId == 309) { + _currentFloor = 1; + if (_globals[kRightDoorIsOpen504]) { + _globals._sequenceIndexes[0] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[0], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[0], 10); + _scene->_sequences.setPosition(_globals._sequenceIndexes[0], Common::Point(160, 104)); + _globals._sequenceIndexes[1] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[1], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[1], 10); + _scene->_sequences.setPosition(_globals._sequenceIndexes[1], Common::Point(161, 124)); + } else { + _globals._sequenceIndexes[0] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[0], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[0], 10); + _scene->_sequences.setPosition(_globals._sequenceIndexes[0], Common::Point(160, 127)); + } + } else if (_scene->_priorSceneId == 206) { + _currentFloor = 2; + _globals._sequenceIndexes[0] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[0], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[0], 10); + _scene->_sequences.setPosition(_globals._sequenceIndexes[0], Common::Point(160, 76)); + } else if (_scene->_priorSceneId == 307) { + _currentFloor = 3; + _anim0ActvFl = true; + _skip1Fl = true; + _globals._animationIndexes[0] = _scene->loadAnimation(formAnimName('u', 2), 2); + _scene->setAnimFrame(_globals._animationIndexes[0], 96); + } + + if (!_game._visitedScenes._sceneRevisited) { + _globals[kPlayerScore] += 5; + _scene->_sequences.addTimer(1, 60); + } + + sceneEntrySound(); +} + +void Scene308::step() { + if (_game._trigger == 60) + _vm->_dialogs->show(30810); + + if (_anim2ActvFl) { + if (_scene->_animation[_globals._animationIndexes[0]]->getCurrentFrame() == 77) { + _scene->setAnimFrame(_globals._animationIndexes[0], 76); + if (!_skip1Fl) { + _game._player._stepEnabled = true; + _vm->_dialogs->show(30811); + _skip1Fl = true; + } + } + } + + if (_anim0ActvFl) { + if (_scene->_animation[_globals._animationIndexes[0]]->getCurrentFrame() == 97) { + if (_globals[kTopFloorLocked]) { + _scene->setAnimFrame(_globals._animationIndexes[0], 96); + if (!_skip1Fl) { + _game._player._stepEnabled = true; + _vm->_dialogs->show(30811); + _skip1Fl = true; + } + } + } else if (_scene->_animation[_globals._animationIndexes[0]]->getCurrentFrame() == 116) { + _globals[kTopFloorLocked] = true; + _scene->_nextSceneId = 307; + } + } + + if (_anim1ActvFl) { + if ((_scene->_animation[_globals._animationIndexes[0]]->getCurrentFrame() == 51) && _globals[kTopFloorLocked]) { + _scene->setAnimFrame(_globals._animationIndexes[0], 50); + if (!_skip1Fl) { + _game._player._stepEnabled = true; + _vm->_dialogs->show(30811); + _skip1Fl = true; + } + } + } +} + +void Scene308::actions() { + switch (_game._trigger) { + case 1: + _scene->_nextSceneId = 206; + _action._inProgress = false; + return; + + case 2: + _scene->_nextSceneId = 307; + _action._inProgress = false; + return; + + case 3: + _scene->_nextSceneId = 309; + _action._inProgress = false; + return; + + default: + break; + } + + if (_action.isAction(VERB_EXIT_TO, NOUN_MIDDLE_LEVEL)) { + switch (_currentFloor) { + case 1: + if (_globals[kRightDoorIsOpen504]) { + _globals._animationIndexes[0] = _scene->loadAnimation(formAnimName('b', 1), 1); + _scene->deleteSequence(_globals._sequenceIndexes[0]); + _scene->deleteSequence(_globals._sequenceIndexes[1]); + _game._player._stepEnabled = false; + } else { + _globals._animationIndexes[0] = _scene->loadAnimation(formAnimName('u', 1), 1); + _scene->deleteSequence(_globals._sequenceIndexes[0]); + _game._player._stepEnabled = false; + } + _action._inProgress = false; + return; + + case 2: + _globals._animationIndexes[0] = _scene->loadAnimation(formAnimName('m', 1), 1); + _scene->deleteSequence(_globals._sequenceIndexes[0]); + _game._player._stepEnabled = false; + _action._inProgress = false; + return; + + case 3: + if (_globals[kRightDoorIsOpen504] && !_globals[kKnockedOverHead]) { + _scene->freeAnimation(_globals._animationIndexes[0]); + _globals._animationIndexes[0] = _scene->loadAnimation(formAnimName('b', 4), 1); + _game._player._stepEnabled = false; + _anim2ActvFl = false; + + } else { + _scene->freeAnimation(_globals._animationIndexes[0]); + _globals._animationIndexes[0] = _scene->loadAnimation(formAnimName('x', 1), 1); + _game._player._stepEnabled = false; + _anim0ActvFl = false; + _anim1ActvFl = false; + } + _action._inProgress = false; + return; + + default: + break; + } + } + + if (_action.isAction(VERB_EXIT_TO, NOUN_UPPER_LEVEL)) { + switch (_currentFloor) { + case 1: + if (_globals[kRightDoorIsOpen504]) { + _globals._animationIndexes[0] = _scene->loadAnimation(formAnimName('b', 2), 1); + _scene->deleteSequence(_globals._sequenceIndexes[0]); + _scene->deleteSequence(_globals._sequenceIndexes[1]); + _game._player._stepEnabled = false; + _anim2ActvFl = true; + _currentFloor = 3; + } else { + _globals._animationIndexes[0] = _scene->loadAnimation(formAnimName('u', 2), 2); + _scene->deleteSequence(_globals._sequenceIndexes[0]); + _game._player._stepEnabled = false; + _anim0ActvFl = true; + _currentFloor = 3; + } + _action._inProgress = false; + return; + + case 2: + if (_globals[kRightDoorIsOpen504]) { + _globals._animationIndexes[0] = _scene->loadAnimation(formAnimName('u', 3), 2); + _scene->deleteSequence(_globals._sequenceIndexes[0]); + _game._player._stepEnabled = false; + } else { + _globals._animationIndexes[0] = _scene->loadAnimation(formAnimName('u', 3), 2); + _scene->deleteSequence(_globals._sequenceIndexes[0]); + _game._player._stepEnabled = false; + _anim1ActvFl = true; + _currentFloor = 3; + } + _action._inProgress = false; + return; + + case 3: + if (_globals[kRightDoorIsOpen504]) + _globals[kTopFloorLocked] = false; + else { + _skip2Fl = false; + _skip1Fl = false; + } + _action._inProgress = false; + return; + + default: + break; + } + } + + if (_action.isAction(VERB_EXIT_TO, NOUN_LOWER_LEVEL)) { + switch (_currentFloor) { + case 1: + if (_globals[kRightDoorIsOpen504]) { + _vm->_gameConv->run(26); + _vm->_gameConv->exportValue(1); + } else { + _globals._animationIndexes[0] = _scene->loadAnimation(formAnimName('l', 1), 3); + _scene->deleteSequence(_globals._sequenceIndexes[0]); + _game._player._stepEnabled = false; + } + _action._inProgress = false; + return; + + case 2: + if (_globals[kRightDoorIsOpen504]) { + if (_vm->_sound->_preferRoland) + _vm->_sound->command(74); + else + _scene->playSpeech(1); + + _vm->_gameConv->run(26); + _vm->_gameConv->exportValue(6); + + } else { + _globals._animationIndexes[0] = _scene->loadAnimation(formAnimName('d', 1), 3); + _scene->deleteSequence(_globals._sequenceIndexes[0]); + _game._player._stepEnabled = false; + } + _action._inProgress = false; + return; + + case 3: + if (_globals[kRightDoorIsOpen504] && !_globals[kKnockedOverHead]) { + _vm->_gameConv->run(26); + _vm->_gameConv->exportValue(5); + } else if (_globals[kRightDoorIsOpen504] && _globals[kKnockedOverHead]) { + if (_vm->_sound->_preferRoland) + _vm->_sound->command(74); + else + _scene->playSpeech(1); + + _vm->_gameConv->run(26); + _vm->_gameConv->exportValue(6); + } else { + _scene->freeAnimation(_globals._animationIndexes[0]); + _globals._animationIndexes[0] = _scene->loadAnimation(formAnimName('x', 2), 3); + _game._player._stepEnabled = false; + _anim0ActvFl = false; + _anim1ActvFl = false; + } + _action._inProgress = false; + return; + + default: + break; + } + } +} + +void Scene308::preActions() { +} + +/*------------------------------------------------------------------------*/ + +Scene309::Scene309(MADSEngine *vm) : Scene3xx(vm) { + _anim0ActvFl = false; + + _boatStatus = -1; + _boatFrame = -1; + _talkCount = -1; +} + +void Scene309::synchronize(Common::Serializer &s) { + Scene3xx::synchronize(s); + + s.syncAsByte(_anim0ActvFl); + + s.syncAsSint16LE(_boatStatus); + s.syncAsSint16LE(_boatFrame); + s.syncAsSint16LE(_talkCount); +} + +void Scene309::setup() { + setPlayerSpritesPrefix(); + setAAName(); + + if (_globals[kRightDoorIsOpen504]) + _scene->_variant = 1; +} + +void Scene309::enter() { + _scene->_hotspots.activate(NOUN_CHRISTINE, false); + _scene->_hotspots.activate(NOUN_BOAT, false); + + _anim0ActvFl = false; + _boatStatus = 1; + _vm->_gameConv->get(26); + + _globals._spriteIndexes[0] = _scene->_sprites.addSprites(formAnimName('x', 0)); + _globals._spriteIndexes[2] = _scene->_sprites.addSprites(formAnimName('x', 1)); + _globals._spriteIndexes[1] = _scene->_sprites.addSprites("*RDR_9"); + + if (_scene->_priorSceneId == RETURNING_FROM_LOADING) { + _globals._sequenceIndexes[0] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[0], false, -1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[0], 10); + + if (_game._visitedScenes.exists(310)) { + _anim0ActvFl = true; + + _globals._animationIndexes[0] = _scene->loadAnimation(formAnimName('b', 1), 70); + _scene->setAnimFrame(_globals._animationIndexes[0], 184); + int id = _scene->_dynamicHotspots.add(NOUN_CHRISTINE, VERB_WALK_TO, SYNTAX_SINGULAR_FEM, EXT_NONE, Common::Rect(0, 0, 0, 0)); + _scene->_dynamicHotspots.setPosition(id, Common::Point(62, 146), FACING_NORTHWEST); + _scene->_dynamicHotspots[id]._articleNumber = PREP_ON; + + _scene->setDynamicAnim(id, _globals._animationIndexes[0], 10); + _scene->setDynamicAnim(id, _globals._animationIndexes[0], 11); + _scene->setDynamicAnim(id, _globals._animationIndexes[0], 12); + _scene->setDynamicAnim(id, _globals._animationIndexes[0], 13); + _scene->setDynamicAnim(id, _globals._animationIndexes[0], 14); + _scene->setDynamicAnim(id, _globals._animationIndexes[0], 15); + _scene->setDynamicAnim(id, _globals._animationIndexes[0], 16); + _scene->setDynamicAnim(id, _globals._animationIndexes[0], 17); + _scene->setDynamicAnim(id, _globals._animationIndexes[0], 18); + _scene->_hotspots.activate(NOUN_CHRISTINE, true); + _scene->_hotspots.activate(NOUN_BOAT, true); + } + } + + if (_scene->_priorSceneId == 404) { + _game._player._playerPos = Common::Point(319, 136); + _game._player._facing = FACING_SOUTHWEST; + _game._player.walk(Common::Point(281, 148), FACING_SOUTHWEST); + _globals._sequenceIndexes[0] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[0], false, -1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[0], 10); + } else if (_scene->_priorSceneId == 310) { + _game._player._playerPos = Common::Point(209, 144); + _game._player._facing = FACING_SOUTH; + _game._player._stepEnabled = false; + _game._player._visible = false; + _anim0ActvFl = true; + + _globals._animationIndexes[0] = _scene->loadAnimation(formAnimName('b', 1), 70); + int id = _scene->_dynamicHotspots.add(NOUN_CHRISTINE, VERB_WALK_TO, SYNTAX_SINGULAR_FEM, EXT_NONE, Common::Rect(0, 0, 0, 0)); + _scene->_dynamicHotspots.setPosition(id, Common::Point(63, 146), FACING_NORTHWEST); + _scene->_dynamicHotspots[id]._articleNumber = PREP_ON; + + _scene->setDynamicAnim(id, _globals._animationIndexes[0], 10); + _scene->setDynamicAnim(id, _globals._animationIndexes[0], 11); + _scene->setDynamicAnim(id, _globals._animationIndexes[0], 12); + _scene->setDynamicAnim(id, _globals._animationIndexes[0], 13); + _scene->setDynamicAnim(id, _globals._animationIndexes[0], 14); + _scene->setDynamicAnim(id, _globals._animationIndexes[0], 15); + _scene->setDynamicAnim(id, _globals._animationIndexes[0], 16); + _scene->setDynamicAnim(id, _globals._animationIndexes[0], 17); + _scene->setDynamicAnim(id, _globals._animationIndexes[0], 18); + _scene->_hotspots.activate(NOUN_CHRISTINE, true); + _scene->_hotspots.activate(NOUN_BOAT, true); + _globals._sequenceIndexes[0] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[0], false, -1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[0], 10); + } else if ((_scene->_priorSceneId == 308) || (_scene->_priorSceneId != RETURNING_FROM_LOADING)) { + _game._player._playerPos = Common::Point(0, 121); + _game._player._facing = FACING_SOUTHEAST; + _game._player.walk(Common::Point(28, 142), FACING_SOUTHEAST); + _game._player.setWalkTrigger(65); + _game._player._stepEnabled = false; + _globals._sequenceIndexes[0] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[0], false, -2); + _scene->_sequences.setDepth(_globals._sequenceIndexes[0], 10); + } + + sceneEntrySound(); +} + +void Scene309::step() { + if (_anim0ActvFl) + handleBoatAnimation (); + + switch (_game._trigger) { + case 65: + _scene->deleteSequence(_globals._sequenceIndexes[0]); + _globals._sequenceIndexes[0] = _scene->_sequences.addReverseSpriteCycle(_globals._spriteIndexes[0], false, 8, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[0], 10); + _scene->_sequences.setAnimRange(_globals._sequenceIndexes[0], -1, -2); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[0], SEQUENCE_TRIGGER_EXPIRE, 0, 66); + break; + + case 66: + _vm->_sound->command(25); + _globals._sequenceIndexes[0] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[0], false, -1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[0], 10); + _game._player._stepEnabled = true; + break; + + default: + break; + } +} + +void Scene309::actions() { + if (_action.isAction(VERB_WALK_THROUGH, NOUN_STONE_ARCHWAY)) { + if (_globals[kRightDoorIsOpen504]) { + _vm->_gameConv->run(26); + _vm->_gameConv->exportValue(1); + _boatStatus = 0; + _talkCount = 0; + } else if (_globals[kLanternStatus] == 1) + _game.enterCatacombs(false); + + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_TALK_TO, NOUN_CHRISTINE)) { + _vm->_gameConv->run(26); + _vm->_gameConv->exportValue(1); + _boatStatus = 0; + _talkCount = 0; + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_WALK_THROUGH, NOUN_DOOR) || _action.isAction(VERB_OPEN, NOUN_DOOR)) { + switch (_game._trigger) { + case (0): + _game._player._stepEnabled = false; + _game._player._visible = false; + _globals._sequenceIndexes[1] = _scene->_sequences.startPingPongCycle(_globals._spriteIndexes[1], false, 5, 2); + _scene->_sequences.setAnimRange(_globals._sequenceIndexes[1], 1, 4); + _scene->_sequences.setSeqPlayer(_globals._sequenceIndexes[1], true); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[1], SEQUENCE_TRIGGER_SPRITE, 4, 60); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[1], SEQUENCE_TRIGGER_EXPIRE, 0, 62); + break; + + case 60: + _scene->deleteSequence(_globals._sequenceIndexes[0]); + _globals._sequenceIndexes[0] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[0], false, 8, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[0], 14); + _scene->_sequences.setAnimRange(_globals._sequenceIndexes[0], -1, -2); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[0], SEQUENCE_TRIGGER_EXPIRE, 0, 61); + _vm->_sound->command(24); + break; + + case 61: { + int idx = _globals._sequenceIndexes[0]; + _globals._sequenceIndexes[0] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[0], false, 5); + _game.syncTimers(SYNC_SEQ, _globals._sequenceIndexes[0], SYNC_SEQ, idx); + _scene->_sequences.setDepth(_globals._sequenceIndexes[0], 14); + _game._player.walk(Common::Point(0, 121), FACING_NORTHWEST); + _game._player.setWalkTrigger(63); + } + break; + + case 62: + _game._player._visible = true; + break; + + case 63: + if (!_globals[kRightDoorIsOpen504]) { + _scene->deleteSequence(_globals._sequenceIndexes[0]); + _globals._sequenceIndexes[0] = _scene->_sequences.addReverseSpriteCycle(_globals._spriteIndexes[0], false, 8, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[0], 1); + _scene->_sequences.setAnimRange(_globals._sequenceIndexes[0], -1, -2); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[0], SEQUENCE_TRIGGER_EXPIRE, 0, 64); + _vm->_sound->command(25); + } else + _scene->setAnimFrame(_globals._animationIndexes[0], 186); + + break; + + case 64: + _globals._sequenceIndexes[0] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[0], false, 5); + _scene->_sequences.setDepth(_globals._sequenceIndexes[0], 1); + _scene->_nextSceneId = 308; + break; + + default: + break; + } + _action._inProgress = false; + return; + } + + if (_action._lookFlag) { + _vm->_dialogs->show(30910); + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_LOOK) || _action.isAction(VERB_LOOK_AT)) { + if (_action.isObject(NOUN_STONE_WALL)) { + _vm->_dialogs->show(30911); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_LAKE)) { + _vm->_dialogs->show(30912); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_STONE_COLUMN)) { + _vm->_dialogs->show(30913); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_DOORWAY)) { + _vm->_dialogs->show(30914); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_STONE_ARCHWAY)) { + _vm->_dialogs->show(30915); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_STONE_FLOOR)) { + _vm->_dialogs->show(30916); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_CATACOMBS)) { + _vm->_dialogs->show(30917); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_CHRISTINE)) { + _vm->_dialogs->show(30919); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_BOAT)) { + _vm->_dialogs->show(30921); + _action._inProgress = false; + return; + } + } + + if (_action.isAction(VERB_CLIMB_INTO, NOUN_BOAT)) { + _vm->_dialogs->show(30920); + _action._inProgress = false; + } +} + +void Scene309::preActions() { + if (_action.isAction(VERB_WALK_THROUGH, NOUN_STONE_ARCHWAY) && (_globals[kLanternStatus] == 0)) { + _game._player._needToWalk = false; + _vm->_dialogs->show(30918); + } + + if (_action.isAction(VERB_WALK_THROUGH, NOUN_STONE_ARCHWAY) && _globals[kRightDoorIsOpen504]) + _game._player.walk(Common::Point(285, 147), FACING_NORTHEAST); + + if (_action.isAction(VERB_OPEN, NOUN_DOOR)) + _game._player.walk(Common::Point(16, 139), FACING_NORTHEAST); +} + +void Scene309::handleBoatAnimation() { + if (_scene->_animation[_globals._animationIndexes[0]]->getCurrentFrame() == _boatFrame) + return; + + _boatFrame = _scene->_animation[_globals._animationIndexes[0]]->getCurrentFrame(); + int resetFrame = -1; + + switch (_boatFrame) { + case 72: + _game.syncTimers(SYNC_PLAYER, 0, SYNC_ANIM, _globals._animationIndexes[0]); + _game._player._visible = true; + break; + + case 130: + _game._player._stepEnabled = true; + break; + + case 185: + if (_boatStatus == 0) + resetFrame = 244; + else + resetFrame = 184; + + break; + + case 244: + _scene->_nextSceneId = 308; + break; + + case 245: + case 246: + case 247: + resetFrame = _vm->getRandomNumber(244, 246); + ++_talkCount; + if (_talkCount > 10) { + resetFrame = 184; + _boatStatus = 1; + } + break; + + default: + break; + } + + if (resetFrame >= 0) { + _scene->setAnimFrame(_globals._animationIndexes[0], resetFrame); + _boatFrame = resetFrame; + } +} + +/*------------------------------------------------------------------------*/ + +Scene310::Scene310(MADSEngine *vm) : Scene3xx(vm) { + _raoulMessageColor = -1; + _chrisMessageColor = -1; + _lakeFrame = -1; + for (int i = 0; i < 4; i++) + _multiplanePosX[i] = -1; +} + +void Scene310::synchronize(Common::Serializer &s) { + Scene3xx::synchronize(s); + + s.syncAsSint16LE(_raoulMessageColor); + s.syncAsSint16LE(_chrisMessageColor); + s.syncAsSint16LE(_lakeFrame); + for (int i = 0; i < 4; i++) + s.syncAsSint16LE(_multiplanePosX[i]); +} + +void Scene310::setup() { + setPlayerSpritesPrefix(); + setAAName(); +} + +void Scene310::enter() { + warning("TODO: Switch to letter box view. See definition of MADS_MENU_Y"); + + for (int i = 0; i < 4; i++) { + _globals._spriteIndexes[i] = _scene->_sprites.addSprites(formAnimName('f', i)); + _globals._sequenceIndexes[i] = -1; + } + + _multiplanePosX[0] = 100; + _multiplanePosX[1] = 210; + _multiplanePosX[2] = 320; + _multiplanePosX[3] = 472; + + _game.loadQuoteSet(0x66, 0x67, 0x69, 0x6A, 0x6C, 0x6D, 0x6E, 0x6F, 0x71, 0x72, 0x74, 0x70, 0x68, 0x73, 0x6B, 0); + _game._player._stepEnabled = false; + _game._player._visible = false; + _globals._animationIndexes[0] = _scene->loadAnimation(formAnimName('l', 1), 80); + _scene->_animation[_globals._animationIndexes[0]]->_canChangeView = true; + _game._camX._manualFl = true; + + _raoulMessageColor = 0x102; + _chrisMessageColor = 0x1110; + + _scene->_userInterface.emptyConversationList(); + _scene->_userInterface.setup(kInputConversation); + + sceneEntrySound(); +} + +void Scene310::step() { + handleLakeAnimation(); + + if (_game._trigger == 80) + _scene->_nextSceneId = 309; + + bool positionsSetFl = false; + + if (_globals._animationIndexes[0] >= 0) { + MADS::Animation *anim = _scene->_animation[_globals._animationIndexes[0]]; + int curFrame = anim->getCurrentFrame(); + uint32 clock = anim->getNextFrameTimer(); + if ((curFrame > 0) && (_scene->_frameStartTime >= clock)) { + Common::Point pos = anim->getFramePosAdjust(curFrame); + if (pos.x != _scene->_posAdjust.x) { + setMultiplanePos(pos.x); + positionsSetFl = true; + } + } + } + + if (!positionsSetFl && (_game._fx != kTransitionNone)) + setMultiplanePos(320); +} + +void Scene310::actions() { +} + +void Scene310::preActions() { +} + +void Scene310::setMultiplanePos(int x_new) { + int center = x_new + 160; + + for (int i = 0; i < 4; i++) { + if (_globals._sequenceIndexes[i] >= 0) + _scene->deleteSequence(_globals._sequenceIndexes[i]); + + int difference = center - _multiplanePosX[i]; + + int direction = 0; + if (difference < 0) + direction = 1; + else if (difference > 0) + direction = -1; + + int displace = abs(difference); + if (direction < 0) + displace = -displace; + + int x = _multiplanePosX[i] + displace - 1; + int y = _scene->_sprites[_globals._spriteIndexes[i]]->getFrameWidth(0) + 29; + int halfWidth = 1 + (_scene->_sprites[_globals._spriteIndexes[i]]->getFrameHeight(0) / 2); + + if (((x - halfWidth) >= (x_new + 320)) || ((x + halfWidth) < x_new)) + _globals._sequenceIndexes[i] = -1; + else { + _globals._sequenceIndexes[i] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[i], false, 1); + _scene->_sequences.setPosition(_globals._sequenceIndexes[i], Common::Point(x, y)); + _scene->_sequences.setDepth(_globals._sequenceIndexes[i], 1); + } + } +} + +void Scene310::handleLakeAnimation() { + if (_scene->_animation[_globals._animationIndexes[0]]->getCurrentFrame() == _lakeFrame) + return; + + + _lakeFrame = _scene->_animation[_globals._animationIndexes[0]]->getCurrentFrame(); + int resetFrame = -1; + int id; + + switch (_lakeFrame) { + case 60: + id = _scene->_kernelMessages.add(Common::Point(-142, 0), _chrisMessageColor, 0, 61, 600, _game.getQuote(0x66)); + _scene->_kernelMessages.setAnim(id, _globals._animationIndexes[0], 0); + id = _scene->_kernelMessages.add(Common::Point(-142, 15), _chrisMessageColor, 0, 0, 600, _game.getQuote(0x67)); + _scene->_kernelMessages.setAnim(id, _globals._animationIndexes[0], 0); + id = _scene->_kernelMessages.add(Common::Point(-142, 30), _chrisMessageColor, 0, 0, 600, _game.getQuote(0x68)); + _scene->_kernelMessages.setAnim(id, _globals._animationIndexes[0], 0); + break; + + case 120: + _scene->_kernelMessages.reset(); + break; + + case 140: + id = _scene->_kernelMessages.add(Common::Point(-120, 0), _chrisMessageColor, 0, 63, 360, _game.getQuote(0x69)); + _scene->_kernelMessages.setAnim(id, _globals._animationIndexes[0], 0); + id = _scene->_kernelMessages.add(Common::Point(-120, 15), _chrisMessageColor, 0, 0, 360, _game.getQuote(0x6A)); + _scene->_kernelMessages.setAnim(id, _globals._animationIndexes[0], 0); + id = _scene->_kernelMessages.add(Common::Point(-120, 30), _chrisMessageColor, 0, 0, 360, _game.getQuote(0x6B)); + _scene->_kernelMessages.setAnim(id, _globals._animationIndexes[0], 0); + break; + + case 200: + _scene->_kernelMessages.reset(); + break; + + case 220: + id = _scene->_kernelMessages.add(Common::Point(-32, 30), _chrisMessageColor, 0, 65, 240, _game.getQuote(0x6C)); + _scene->_kernelMessages.setAnim(id, _globals._animationIndexes[0], 0); + id = _scene->_kernelMessages.add(Common::Point(-32, 45), _chrisMessageColor, 0, 0, 240, _game.getQuote(0x6D)); + _scene->_kernelMessages.setAnim(id, _globals._animationIndexes[0], 0); + break; + + case 280: + _scene->_kernelMessages.reset(); + break; + + case 300: + id = _scene->_kernelMessages.add(Common::Point(101, 0), _raoulMessageColor, 0, 67, 360, _game.getQuote(0x6E)); + _scene->_kernelMessages.setAnim(id, _globals._animationIndexes[0], 0); + id = _scene->_kernelMessages.add(Common::Point(101, 15), _raoulMessageColor, 0, 0, 360, _game.getQuote(0x6F)); + _scene->_kernelMessages.setAnim(id, _globals._animationIndexes[0], 0); + id = _scene->_kernelMessages.add(Common::Point(101, 30), _raoulMessageColor, 0, 0, 360, _game.getQuote(0x70)); + _scene->_kernelMessages.setAnim(id, _globals._animationIndexes[0], 0); + break; + + case 360: + _scene->_kernelMessages.reset(); + break; + + case 380: + id = _scene->_kernelMessages.add(Common::Point(107, 0), _chrisMessageColor, 0, 69, 360, _game.getQuote(0x71)); + _scene->_kernelMessages.setAnim(id, _globals._animationIndexes[0], 0); + id = _scene->_kernelMessages.add(Common::Point(107, 15), _chrisMessageColor, 0, 0, 360, _game.getQuote(0x72)); + _scene->_kernelMessages.setAnim(id, _globals._animationIndexes[0], 0); + id = _scene->_kernelMessages.add(Common::Point(107, 30), _chrisMessageColor, 0, 0, 360, _game.getQuote(0x73)); + _scene->_kernelMessages.setAnim(id, _globals._animationIndexes[0], 0); + break; + + case 440: + _scene->_kernelMessages.reset(); + break; + + case 460: + id = _scene->_kernelMessages.add(Common::Point(107, 7), _chrisMessageColor, 0, 0, 180, _game.getQuote(0x74)); + _scene->_kernelMessages.setAnim(id, _globals._animationIndexes[0], 0); + break; + + case 510: + _scene->_kernelMessages.reset(); + break; + + default: + break; + } + + if (resetFrame >= 0) { + _scene->setAnimFrame(_globals._animationIndexes[0], resetFrame); + _lakeFrame = resetFrame; + } +} + +/*------------------------------------------------------------------------*/ + +} // End of namespace Phantom +} // End of namespace MADS diff --git a/engines/mads/phantom/phantom_scenes3.h b/engines/mads/phantom/phantom_scenes3.h new file mode 100644 index 0000000000..58f2a08b91 --- /dev/null +++ b/engines/mads/phantom/phantom_scenes3.h @@ -0,0 +1,248 @@ +/* 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 MADS_PHANTOM_SCENES3_H +#define MADS_PHANTOM_SCENES3_H + +#include "common/scummsys.h" +#include "common/serializer.h" +#include "mads/game.h" +#include "mads/scene.h" +#include "mads/phantom/phantom_scenes.h" + +namespace MADS { + +namespace Phantom { + +class Scene3xx : public PhantomScene { +protected: + /** + * Plays an appropriate sound when entering a scene + */ + void sceneEntrySound(); + + /** + *Sets the AA file to use for the scene + */ + void setAAName(); + + /** + * Updates the prefix used for getting player sprites for the scene + */ + void setPlayerSpritesPrefix(); +public: + Scene3xx(MADSEngine *vm) : PhantomScene(vm) {} +}; + +class Scene301 : public Scene3xx { +private: + bool _anim0ActvFl; + bool _skip1Fl; + bool _skip2Fl; + + int _lightingHotspotId; + int _sandbagHotspotId; + +public: + Scene301(MADSEngine *vm); + virtual void synchronize(Common::Serializer &s); + + virtual void setup(); + virtual void enter(); + virtual void step(); + virtual void preActions(); + virtual void actions(); +}; + +class Scene302 : public Scene3xx { +public: + Scene302(MADSEngine *vm); + virtual void synchronize(Common::Serializer &s); + + virtual void setup(); + virtual void enter(); + virtual void step(); + virtual void preActions(); + virtual void actions(); +}; + +class Scene303 : public Scene3xx { +private: + bool _anim0ActvFl; + int _hempHotspotId; + int _skipFrameCheckFl; +public: + Scene303(MADSEngine *vm); + virtual void synchronize(Common::Serializer &s); + + virtual void setup(); + virtual void enter(); + virtual void step(); + virtual void preActions(); + virtual void actions(); +}; + +class Scene304 : public Scene3xx { +private: + bool _anim0ActvFl; + bool _anim1ActvFl; + bool _anim2ActvFl; + + int _raoulFrame; + int _raoulStatus; + int _fightFrame; + int _fightStatus; + int _fightCount; + int _phantomFrame; + int _phantomStatus; + + void handleConversation23(); + void handleRaoulAnimation(); + void handlePhantomAnimation(); + void handleFightAnimation(); + +public: + Scene304(MADSEngine *vm); + virtual void synchronize(Common::Serializer &s); + + virtual void setup(); + virtual void enter(); + virtual void step(); + virtual void preActions(); + virtual void actions(); +}; + +class Scene305 : public Scene3xx { +private: + bool _anim0ActvFl; + bool _anim1ActvFl; + bool _skipFl; + bool _unmaskFl; + + int _unmaskFrame; + + void handle_animation_unmask(); + +public: + Scene305(MADSEngine *vm); + virtual void synchronize(Common::Serializer &s); + + virtual void setup(); + virtual void enter(); + virtual void step(); + virtual void preActions(); + virtual void actions(); +}; + +class Scene306 : public Scene3xx { +private: + bool _speechDoneFl; + +public: + Scene306(MADSEngine *vm); + virtual void synchronize(Common::Serializer &s); + + virtual void setup(); + virtual void enter(); + virtual void step(); + virtual void preActions(); + virtual void actions(); +}; + +class Scene307 : public Scene3xx { +public: + Scene307(MADSEngine *vm); + virtual void synchronize(Common::Serializer &s); + + virtual void setup(); + virtual void enter(); + virtual void step(); + virtual void preActions(); + virtual void actions(); +}; + +class Scene308 : public Scene3xx { +private: + bool _anim0ActvFl; + bool _anim1ActvFl; + bool _anim2ActvFl; + bool _anim3ActvFl; + bool _skip1Fl; + bool _skip2Fl; + int _currentFloor; + +public: + Scene308(MADSEngine *vm); + virtual void synchronize(Common::Serializer &s); + + virtual void setup(); + virtual void enter(); + virtual void step(); + virtual void preActions(); + virtual void actions(); +}; + +class Scene309 : public Scene3xx { +private: + bool _anim0ActvFl; + + int _boatStatus; + int _boatFrame; + int _talkCount; + + void Scene309::handleBoatAnimation(); + +public: + Scene309(MADSEngine *vm); + virtual void synchronize(Common::Serializer &s); + + virtual void setup(); + virtual void enter(); + virtual void step(); + virtual void preActions(); + virtual void actions(); +}; + +class Scene310 : public Scene3xx { +private: + int _raoulMessageColor; + int _chrisMessageColor; + int _multiplanePosX[4]; + int _lakeFrame; + + void setMultiplanePos(int x_new); + void handleLakeAnimation(); + +public: + Scene310(MADSEngine *vm); + virtual void synchronize(Common::Serializer &s); + + virtual void setup(); + virtual void enter(); + virtual void step(); + virtual void preActions(); + virtual void actions(); +}; +} // End of namespace Phantom +} // End of namespace MADS + +#endif /* MADS_PHANTOM_SCENES3_H */ diff --git a/engines/mads/phantom/phantom_scenes4.cpp b/engines/mads/phantom/phantom_scenes4.cpp new file mode 100644 index 0000000000..618677beda --- /dev/null +++ b/engines/mads/phantom/phantom_scenes4.cpp @@ -0,0 +1,4975 @@ +/* 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/scummsys.h" +#include "mads/mads.h" +#include "mads/conversations.h" +#include "mads/scene.h" +#include "mads/phantom/phantom_scenes.h" +#include "mads/phantom/phantom_scenes4.h" + +namespace MADS { + +namespace Phantom { + +void Scene4xx::setAAName() { + _game._aaName = Resources::formatAAName(1); + _vm->_palette->setEntry(254, 43, 47, 51); +} + +void Scene4xx::sceneEntrySound() { + if (!_vm->_musicFlag) + return; + + _vm->_sound->command(16); +} + +void Scene4xx::setPlayerSpritesPrefix() { + _vm->_sound->command(5); + + Common::String oldName = _game._player._spritesPrefix; + if (!_game._player._forcePrefix) + _game._player._spritesPrefix = "RAL"; + if (oldName != _game._player._spritesPrefix) + _game._player._spritesChanged = true; + + _game._player._scalingVelocity = true; +} + +/*------------------------------------------------------------------------*/ + +Scene401::Scene401(MADSEngine *vm) : Scene4xx(vm) { + _anim0ActvFl = false; + _frameInRoomFl = false; + _takingFrameInRoomFl = false; + + _redFrameHotspotId = -1; + _greenFrameHostpotId = -1; + _blueFrameHotspotId = -1; + _yellowFrameHotspotId = -1; +} + +void Scene401::synchronize(Common::Serializer &s) { + Scene4xx::synchronize(s); + + s.syncAsByte(_anim0ActvFl); + s.syncAsByte(_frameInRoomFl); + s.syncAsByte(_takingFrameInRoomFl); + + s.syncAsSint16LE(_redFrameHotspotId); + s.syncAsSint16LE(_greenFrameHostpotId); + s.syncAsSint16LE(_blueFrameHotspotId); + s.syncAsSint16LE(_yellowFrameHotspotId); +} + +void Scene401::setup() { + setPlayerSpritesPrefix(); + setAAName(); + + if (_globals[kCatacombsMisc] & MAZE_EVENT_PUDDLE) + _scene->_variant = 1; + + _scene->addActiveVocab(NOUN_RED_FRAME); + _scene->addActiveVocab(NOUN_YELLOW_FRAME); + _scene->addActiveVocab(NOUN_BLUE_FRAME); + _scene->addActiveVocab(NOUN_GREEN_FRAME); +} + +void Scene401::enter() { + _game.initCatacombs(); + _anim0ActvFl = false; + + _scene->_hotspots.activate(NOUN_PUDDLE, false); + _scene->_hotspots.activate(NOUN_RATS_NEST, false); + _scene->_hotspots.activate(NOUN_SKULL, false); + _scene->_hotspots.activate(NOUN_POT, false); + + _globals._spriteIndexes[8] = _scene->_sprites.addSprites("*RRD_9"); + _globals._spriteIndexes[9] = _scene->_sprites.addSprites(formAnimName('f', 0)); + _globals._spriteIndexes[10] = _scene->_sprites.addSprites(formAnimName('f', 1)); + _globals._spriteIndexes[11] = _scene->_sprites.addSprites(formAnimName('f', 2)); + _globals._spriteIndexes[12] = _scene->_sprites.addSprites(formAnimName('f', 3)); + + if (_game.exitCatacombs(0) == -1) { + _globals._spriteIndexes[1] = _scene->_sprites.addSprites(formAnimName('c', 1)); + _scene->drawToBackground(_globals._spriteIndexes[1], 1, Common::Point(-32000, -32000), 0, 100); + _scene->_hotspots.activate(NOUN_ARCHWAY_TO_NORTH, false); + } + + if (_game.exitCatacombs(3) == -1) { + _globals._spriteIndexes[0] = _scene->_sprites.addSprites(formAnimName('c', 0)); + _scene->drawToBackground(_globals._spriteIndexes[0], 1, Common::Point(-32000, -32000), 0, 100); + _scene->_hotspots.activate(NOUN_ARCHWAY_TO_WEST, false); + } + + if (_game.exitCatacombs(1) == -1) { + _globals._spriteIndexes[2] = _scene->_sprites.addSprites(formAnimName('c', 2)); + _scene->drawToBackground(_globals._spriteIndexes[2], 1, Common::Point(-32000, -32000), 0, 100); + _scene->_hotspots.activate(NOUN_ARCHWAY_TO_EAST, false); + } + + if (_game.exitCatacombs(2) == -1) + _scene->_hotspots.activate(NOUN_MORE_CATACOMBS, false); + + if (_globals[kCatacombsMisc] & MAZE_EVENT_RAT_NEST) { + _globals._spriteIndexes[4] = _scene->_sprites.addSprites(formAnimName('c', 4)); + _scene->drawToBackground(_globals._spriteIndexes[4], 1, Common::Point(-32000, -32000), 0, 100); + _scene->_hotspots.activate(NOUN_RATS_NEST, true); + } + + if (_globals[kCatacombsMisc] & MAZE_EVENT_SKULL) { + _globals._spriteIndexes[5] = _scene->_sprites.addSprites(formAnimName('c', 5)); + _scene->drawToBackground(_globals._spriteIndexes[5], 1, Common::Point(-32000, -32000), 0, 100); + _scene->_hotspots.activate(NOUN_SKULL, true); + } + + if (_globals[kCatacombsMisc] & MAZE_EVENT_POT) { + _globals._spriteIndexes[6] = _scene->_sprites.addSprites(formAnimName('c', 6)); + _scene->drawToBackground(_globals._spriteIndexes[6], 1, Common::Point(-32000, -32000), 0, 100); + _scene->_hotspots.activate(NOUN_POT, true); + } + + if (_globals[kCatacombsMisc] & MAZE_EVENT_BRICK) { + _globals._spriteIndexes[7] = _scene->_sprites.addSprites(formAnimName('c', 7)); + _scene->drawToBackground(_globals._spriteIndexes[7], 1, Common::Point(-32000, -32000), 0, 100); + } + + if (_globals[kCatacombsMisc] & MAZE_EVENT_PUDDLE) { + _scene->_hotspots.activate(NOUN_PUDDLE, true); + _globals._animationIndexes[0] = _scene->loadAnimation(formAnimName('d', 1), 0); + _anim0ActvFl = true; + } + + if (_scene->_priorSceneId != RETURNING_FROM_LOADING) { + switch (_globals[kCatacombsFrom]) { + case 0: + _game._player._playerPos = Common::Point(128, 78); + _game._player._facing = FACING_SOUTH; + _game._player.walk(Common::Point(128, 91), FACING_SOUTH); + break; + + case 1: + _game._player._playerPos = Common::Point(311, 115); + _game._player._facing = FACING_WEST; + _game._player.walk(Common::Point(271, 123), FACING_WEST); + break; + + case 2: + _game._player._playerPos = Common::Point(142, 146); + _game._player._facing = FACING_NORTH; + break; + + case 3: + _game._player._playerPos = Common::Point(4, 113); + _game._player._facing = FACING_SOUTH; + _game._player.walk(Common::Point(48, 113), FACING_EAST); + break; + + default: + break; + } + } + + if (_game._objects[OBJ_RED_FRAME]._roomNumber == _globals[kCatacombsRoom] + 600) { + _globals._sequenceIndexes[9] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[9], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[9], 14); + + Common::Point pos = _scene->_sprites[_globals._spriteIndexes[9]]->getFramePos(0); + _redFrameHotspotId = _scene->_dynamicHotspots.add(NOUN_RED_FRAME, VERB_WALK_TO, SYNTAX_SINGULAR, EXT_NONE, Common::Rect(pos.x - 5, pos.y - 5, pos.x + 5, pos.y + 1)); + _scene->_dynamicHotspots.setPosition(_redFrameHotspotId, Common::Point(pos.x + 12, pos.y), FACING_NORTHWEST); + } + + if (_game._objects[OBJ_GREEN_FRAME]._roomNumber == _globals[kCatacombsRoom] + 600) { + _globals._sequenceIndexes[10] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[10], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[10], 14); + + Common::Point pos = _scene->_sprites[_globals._spriteIndexes[9]]->getFramePos(0); + _greenFrameHostpotId = _scene->_dynamicHotspots.add(NOUN_GREEN_FRAME, VERB_WALK_TO, SYNTAX_SINGULAR, EXT_NONE, Common::Rect(pos.x - 5, pos.y - 5, pos.x + 5, pos.y + 1)); + _scene->_dynamicHotspots.setPosition(_greenFrameHostpotId , Common::Point(pos.x + 12, pos.y), FACING_NORTHWEST); + } + + if (_game._objects[OBJ_BLUE_FRAME]._roomNumber == _globals[kCatacombsRoom] + 600) { + _globals._sequenceIndexes[11] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[11], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[11], 14); + + Common::Point pos = _scene->_sprites[_globals._spriteIndexes[9]]->getFramePos(0); + _blueFrameHotspotId = _scene->_dynamicHotspots.add(NOUN_BLUE_FRAME, VERB_WALK_TO, SYNTAX_SINGULAR, EXT_NONE, Common::Rect(pos.x - 5, pos.y - 5, pos.x + 5, pos.y + 1)); + _scene->_dynamicHotspots.setPosition(_blueFrameHotspotId, Common::Point(pos.x + 12, pos.y), FACING_NORTHWEST); + } + + if (_game._objects[OBJ_YELLOW_FRAME]._roomNumber == _globals[kCatacombsRoom] + 600) { + _globals._sequenceIndexes[12] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[12], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[12], 14); + + Common::Point pos = _scene->_sprites[_globals._spriteIndexes[9]]->getFramePos(0); + _yellowFrameHotspotId = _scene->_dynamicHotspots.add(NOUN_YELLOW_FRAME, VERB_WALK_TO, SYNTAX_SINGULAR, EXT_NONE, Common::Rect(pos.x - 5, pos.y - 5, pos.x + 5, pos.y + 1)); + _scene->_dynamicHotspots.setPosition(_yellowFrameHotspotId, Common::Point(pos.x + 12, pos.y), FACING_NORTHWEST); + } + + sceneEntrySound(); +} + +void Scene401::step() { + if (_anim0ActvFl) { + if (_scene->_animation[_globals._animationIndexes[0]]->getCurrentFrame() == 20) + _scene->setAnimFrame(_globals._animationIndexes[0], 0); + } +} + +void Scene401::actions() { + if (_action.isAction(VERB_PUT) && _action.isTarget(NOUN_FLOOR)) { + if (_action.isObject(NOUN_RED_FRAME) || _action.isObject(NOUN_BLUE_FRAME) || _action.isObject(NOUN_YELLOW_FRAME) || _action.isObject(NOUN_GREEN_FRAME)) { + if (_frameInRoomFl) + _vm->_dialogs->show(29); + else { + switch (_game._trigger) { + case (0): + _game._player._stepEnabled = false; + _game._player._visible = false; + _globals._sequenceIndexes[8] = _scene->_sequences.startPingPongCycle(_globals._spriteIndexes[8], true, 5, 2); + _scene->_sequences.setAnimRange(_globals._sequenceIndexes[8], 1, 5); + _scene->_sequences.setSeqPlayer(_globals._sequenceIndexes[8], true); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[8], SEQUENCE_TRIGGER_SPRITE, 5, 1); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[8], SEQUENCE_TRIGGER_EXPIRE, 0, 2); + break; + + case 1: + if (_action.isObject(NOUN_RED_FRAME)) { + _game._objects.setRoom(OBJ_RED_FRAME, NOWHERE); + _game._objects[OBJ_RED_FRAME]._roomNumber = _globals[kCatacombsRoom] + 600; + _globals._sequenceIndexes[9] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[9], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[9], 14); + + Common::Point pos = _scene->_sprites[_globals._spriteIndexes[9]]->getFramePos(0); + _redFrameHotspotId = _scene->_dynamicHotspots.add(NOUN_RED_FRAME, VERB_WALK_TO, SYNTAX_SINGULAR, EXT_NONE, Common::Rect(pos.x - 5, pos.y - 5, pos.x + 5, pos.y + 1)); + _scene->_dynamicHotspots.setPosition(_redFrameHotspotId, Common::Point(pos.x + 12, pos.y), FACING_NORTHWEST); + } + + if (_action.isObject(NOUN_GREEN_FRAME)) { + _game._objects.setRoom(OBJ_GREEN_FRAME, NOWHERE); + _game._objects[OBJ_GREEN_FRAME]._roomNumber = _globals[kCatacombsRoom] + 600; + _globals._sequenceIndexes[10] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[10], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[10], 14); + + Common::Point pos = _scene->_sprites[_globals._spriteIndexes[9]]->getFramePos(0); + _greenFrameHostpotId = _scene->_dynamicHotspots.add(NOUN_GREEN_FRAME, VERB_WALK_TO, SYNTAX_SINGULAR, EXT_NONE, Common::Rect(pos.x - 5, pos.y - 5, pos.x + 5, pos.y + 1)); + _scene->_dynamicHotspots.setPosition(_greenFrameHostpotId , Common::Point(pos.x + 12, pos.y), FACING_NORTHWEST); + } + + if (_action.isObject(NOUN_BLUE_FRAME)) { + _game._objects.setRoom(OBJ_BLUE_FRAME, NOWHERE); + _game._objects[OBJ_BLUE_FRAME]._roomNumber = _globals[kCatacombsRoom] + 600; + _globals._sequenceIndexes[11] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[11], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[11], 14); + + Common::Point pos = _scene->_sprites[_globals._spriteIndexes[9]]->getFramePos(0); + _blueFrameHotspotId = _scene->_dynamicHotspots.add(NOUN_BLUE_FRAME, VERB_WALK_TO, SYNTAX_SINGULAR, EXT_NONE, Common::Rect(pos.x - 5, pos.y - 5, pos.x + 5, pos.y + 1)); + _scene->_dynamicHotspots.setPosition(_blueFrameHotspotId, Common::Point(pos.x + 12, pos.y), FACING_NORTHWEST); + } + + if (_action.isObject(NOUN_YELLOW_FRAME)) { + _game._objects.setRoom(OBJ_YELLOW_FRAME, NOWHERE); + _game._objects[OBJ_YELLOW_FRAME]._roomNumber = _globals[kCatacombsRoom] + 600; + _globals._sequenceIndexes[12] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[12], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[12], 14); + + Common::Point pos = _scene->_sprites[_globals._spriteIndexes[9]]->getFramePos(0); + _yellowFrameHotspotId = _scene->_dynamicHotspots.add(NOUN_YELLOW_FRAME, VERB_WALK_TO, SYNTAX_SINGULAR, EXT_NONE, Common::Rect(pos.x - 5, pos.y - 5, pos.x + 5, pos.y + 1)); + _scene->_dynamicHotspots.setPosition(_yellowFrameHotspotId, Common::Point(pos.x + 12, pos.y), FACING_NORTHWEST); + } + break; + + case 2: + _game.syncTimers(SYNC_PLAYER, 0, SYNC_SEQ, _globals._sequenceIndexes[8]); + _game._player._visible = true; + _game._player._stepEnabled = true; + break; + + default: + break; + } + } + _action._inProgress = false; + return; + } + } + + if (_action.isAction(VERB_TAKE)) { + if (_action.isObject(NOUN_RED_FRAME) || _action.isObject(NOUN_GREEN_FRAME) || _action.isObject(NOUN_BLUE_FRAME) || _action.isObject(NOUN_YELLOW_FRAME)) { + if ((_takingFrameInRoomFl || _game._trigger)) { + switch (_game._trigger) { + case (0): + _game._player._stepEnabled = false; + _game._player._visible = false; + _globals._sequenceIndexes[8] = _scene->_sequences.startPingPongCycle(_globals._spriteIndexes[8], true, 5, 2); + _scene->_sequences.setAnimRange(_globals._sequenceIndexes[8], 1, 5); + _scene->_sequences.setSeqPlayer(_globals._sequenceIndexes[8], true); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[8], SEQUENCE_TRIGGER_SPRITE, 5, 1); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[8], SEQUENCE_TRIGGER_EXPIRE, 0, 2); + break; + + case 1: + if (_action.isObject(NOUN_RED_FRAME)) { + _scene->deleteSequence(_globals._sequenceIndexes[9]); + _scene->_dynamicHotspots.remove(_redFrameHotspotId); + _game._objects.addToInventory(OBJ_RED_FRAME); + } + + if (_action.isObject(NOUN_GREEN_FRAME)) { + _scene->deleteSequence(_globals._sequenceIndexes[10]); + _scene->_dynamicHotspots.remove(_greenFrameHostpotId ); + _game._objects.addToInventory(OBJ_GREEN_FRAME); + } + + if (_action.isObject(NOUN_BLUE_FRAME)) { + _scene->deleteSequence(_globals._sequenceIndexes[11]); + _scene->_dynamicHotspots.remove(_blueFrameHotspotId); + _game._objects.addToInventory(OBJ_BLUE_FRAME); + } + + if (_action.isObject(NOUN_YELLOW_FRAME)) { + _scene->deleteSequence(_globals._sequenceIndexes[12]); + _scene->_dynamicHotspots.remove(_yellowFrameHotspotId); + _game._objects.addToInventory(OBJ_YELLOW_FRAME); + } + + _vm->_sound->command(26); + break; + + case 2: + _game.syncTimers(SYNC_PLAYER, 0, SYNC_SEQ, _globals._sequenceIndexes[8]); + _game._player._visible = true; + _game._player._stepEnabled = true; + break; + + default: + break; + } + _action._inProgress = false; + return; + } + } + } + + if (_action.isAction(VERB_WALK_THROUGH, NOUN_ARCHWAY_TO_NORTH)) { + _game.moveCatacombs(0); + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_WALK_THROUGH, NOUN_ARCHWAY_TO_WEST)) { + _game.moveCatacombs(3); + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_EXIT_TO, NOUN_MORE_CATACOMBS)) { + _game.moveCatacombs(2); + if ((_game._difficulty == DIFFICULTY_HARD) && (_globals[kCatacombsRoom] == 31)) + _globals[kPriestPistonPuke] = true; + + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_WALK_THROUGH, NOUN_ARCHWAY_TO_EAST)) { + _game.moveCatacombs(1); + if ((_game._difficulty == DIFFICULTY_EASY) && (_globals[kCatacombsRoom] == 24)) + _globals[kPriestPistonPuke] = true; + + _action._inProgress = false; + return; + } + + if (_action._lookFlag) { + _vm->_dialogs->show(40110); + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_LOOK) || _action.isAction(VERB_LOOK_AT)) { + if (_action.isObject(NOUN_WALL)) { + _vm->_dialogs->show(40111); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_FLOOR)) { + _vm->_dialogs->show(40112); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_ARCHWAY)) { + _vm->_dialogs->show(40113); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_EXPOSED_BRICK)) { + _vm->_dialogs->show(40114); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_MORE_CATACOMBS)) { + _vm->_dialogs->show(40115); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_BLOCKED_ARCHWAY)) { + _vm->_dialogs->show(40116); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_PUDDLE)) { + _vm->_dialogs->show(40117); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_RATS_NEST)) { + _vm->_dialogs->show(40118); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_SKULL)) { + _vm->_dialogs->show(40120); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_RED_FRAME) && !_game._objects.isInInventory(OBJ_RED_FRAME)) { + _vm->_dialogs->showItem(OBJ_RED_FRAME, 802, 0); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_GREEN_FRAME) && !_game._objects.isInInventory(OBJ_GREEN_FRAME)) { + _vm->_dialogs->showItem(OBJ_GREEN_FRAME, 819, 0); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_BLUE_FRAME) && !_game._objects.isInInventory(OBJ_BLUE_FRAME)) { + _vm->_dialogs->showItem(OBJ_BLUE_FRAME, 817, 0); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_YELLOW_FRAME) && !_game._objects.isInInventory(OBJ_YELLOW_FRAME)) { + _vm->_dialogs->showItem(OBJ_YELLOW_FRAME, 804, 0); + _action._inProgress = false; + return; + } + + + if (_action.isObject(NOUN_BROKEN_POT)) { + _vm->_dialogs->show(40122); + _action._inProgress = false; + return; + } + } + + if (_action.isAction(VERB_TAKE, NOUN_RATS_NEST)) { + _vm->_dialogs->show(40119); + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_TAKE, NOUN_SKULL)) { + _vm->_dialogs->show(40121); + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_TAKE, NOUN_BROKEN_POT)) { + _vm->_dialogs->show(40123); + _action._inProgress = false; + } +} + +void Scene401::preActions() { + _frameInRoomFl = false; + _takingFrameInRoomFl = false; + + if (_game._objects[OBJ_RED_FRAME]._roomNumber == _globals[kCatacombsRoom] + 600) { + _frameInRoomFl = true; + if (_action.isAction(VERB_TAKE, NOUN_RED_FRAME)) + _takingFrameInRoomFl = true; + } + + if (_game._objects[OBJ_YELLOW_FRAME]._roomNumber == _globals[kCatacombsRoom] + 600) { + _frameInRoomFl = true; + if (_action.isAction(VERB_TAKE, NOUN_YELLOW_FRAME)) + _takingFrameInRoomFl = true; + } + + if (_game._objects[OBJ_BLUE_FRAME]._roomNumber == _globals[kCatacombsRoom] + 600) { + _frameInRoomFl = true; + if (_action.isAction(VERB_TAKE, NOUN_BLUE_FRAME)) + _takingFrameInRoomFl = true; + } + + if (_game._objects[OBJ_GREEN_FRAME]._roomNumber == _globals[kCatacombsRoom] + 600) { + _frameInRoomFl = true; + if (_action.isAction(VERB_TAKE, NOUN_GREEN_FRAME)) + _takingFrameInRoomFl = true; + } + + if (_action.isAction(VERB_PUT) && _action.isTarget(NOUN_FLOOR) + && (_action.isObject(NOUN_RED_FRAME) || _action.isObject(NOUN_BLUE_FRAME) + || _action.isObject(NOUN_YELLOW_FRAME) || _action.isObject(NOUN_GREEN_FRAME))) { + if (_frameInRoomFl) + _game._player._needToWalk = false; + else { + Common::Point pos = _scene->_sprites[_globals._spriteIndexes[9]]->getFramePos(0); + _game._player.walk(Common::Point(pos.x + 12, pos.y), FACING_NORTHWEST); + } + } +} + +/*------------------------------------------------------------------------*/ + +Scene403::Scene403(MADSEngine *vm) : Scene4xx(vm) { + _frameInRoomFl = false; + _takingFrameInRoomFl = false; + + _redFrameHotspotId = -1; + _greenFrameHostpotId = -1; + _blueFrameHotspotId = -1; + _yellowFrameHotspotId = -1; +} + +void Scene403::synchronize(Common::Serializer &s) { + Scene4xx::synchronize(s); + + s.syncAsByte(_frameInRoomFl); + s.syncAsByte(_takingFrameInRoomFl); + + s.syncAsSint16LE(_redFrameHotspotId); + s.syncAsSint16LE(_greenFrameHostpotId); + s.syncAsSint16LE(_blueFrameHotspotId); + s.syncAsSint16LE(_yellowFrameHotspotId); +} + +void Scene403::setup() { + setPlayerSpritesPrefix(); + setAAName(); + + if (_globals[kCatacombsMisc] & MAZE_EVENT_HOLE) + _scene->_variant = 1; + + if (_globals[kCatacombsMisc] & MAZE_EVENT_PLANK) + _scene->_variant = 2; + + _scene->addActiveVocab(NOUN_RED_FRAME); + _scene->addActiveVocab(NOUN_YELLOW_FRAME); + _scene->addActiveVocab(NOUN_BLUE_FRAME); + _scene->addActiveVocab(NOUN_GREEN_FRAME); +} + +void Scene403::enter() { + _game.initCatacombs(); + + _scene->_hotspots.activate(NOUN_HOLE, false); + _scene->_hotspots.activate(NOUN_WEB, false); + _scene->_hotspots.activate(NOUN_RATS_NEST, false); + _scene->_hotspots.activate(NOUN_SKULL, false); + _scene->_hotspots.activate(NOUN_PLANK, false); + _scene->_hotspots.activate(NOUN_GATE, false); + + _globals._spriteIndexes[8] = _scene->_sprites.addSprites("*RRD_9"); + _globals._spriteIndexes[9] = _scene->_sprites.addSprites(formAnimName('f', 0)); + _globals._spriteIndexes[10] = _scene->_sprites.addSprites(formAnimName('f', 1)); + _globals._spriteIndexes[11] = _scene->_sprites.addSprites(formAnimName('f', 2)); + _globals._spriteIndexes[12] = _scene->_sprites.addSprites(formAnimName('f', 3)); + + if (_game.exitCatacombs(0) == -1) { + _globals._spriteIndexes[1] = _scene->_sprites.addSprites(formAnimName('c', 1)); + _scene->drawToBackground(_globals._spriteIndexes[1], 1, Common::Point(-32000, -32000), 0, 100); + _scene->_hotspots.activate(NOUN_ARCHWAY_TO_NORTH, false); + } + + if (_game.exitCatacombs(3) == -1) { + _globals._spriteIndexes[0] = _scene->_sprites.addSprites(formAnimName('c', 0)); + _scene->drawToBackground(_globals._spriteIndexes[0], 1, Common::Point(-32000, -32000), 0, 100); + _scene->_hotspots.activate(NOUN_ARCHWAY_TO_WEST, false); + } + + if (_game.exitCatacombs(1) == -1) { + _scene->_hotspots.activate(NOUN_MORE_CATACOMBS, false); + _scene->_hotspots.activate(NOUN_GATE, true); + _globals._spriteIndexes[13] = _scene->_sprites.addSprites(formAnimName('c', 9)); + _scene->drawToBackground(_globals._spriteIndexes[13], 1, Common::Point(-32000, -32000), 0, 100); + } + + if (_globals[kCatacombsMisc] & MAZE_EVENT_HOLE) { + _globals._spriteIndexes[2] = _scene->_sprites.addSprites(formAnimName('c', 3)); + _scene->drawToBackground(_globals._spriteIndexes[2], 1, Common::Point(-32000, -32000), 0, 100); + _scene->_hotspots.activate(NOUN_HOLE, true); + } + + if (_globals[kCatacombsMisc] & MAZE_EVENT_WEB) { + _globals._spriteIndexes[3] = _scene->_sprites.addSprites(formAnimName('c', 4)); + _scene->drawToBackground(_globals._spriteIndexes[3], 1, Common::Point(-32000, -32000), 0, 100); + _scene->_hotspots.activate(NOUN_WEB, true); + } + + if (_globals[kCatacombsMisc] & MAZE_EVENT_BRICK) { + _globals._spriteIndexes[4] = _scene->_sprites.addSprites(formAnimName('c', 5)); + _scene->drawToBackground(_globals._spriteIndexes[4], 1, Common::Point(-32000, -32000), 0, 100); + _scene->_hotspots.activateAtPos(NOUN_EXPOSED_BRICK, false, Common::Point(178, 35)); + } + + if (_globals[kCatacombsMisc] & MAZE_EVENT_RAT_NEST) { + _globals._spriteIndexes[5] = _scene->_sprites.addSprites(formAnimName('c', 6)); + _scene->drawToBackground(_globals._spriteIndexes[5], 1, Common::Point(-32000, -32000), 0, 100); + _scene->_hotspots.activate(NOUN_RATS_NEST, true); + } + + if (_globals[kCatacombsMisc] & MAZE_EVENT_SKULL) { + _globals._spriteIndexes[6] = _scene->_sprites.addSprites(formAnimName('c', 7)); + _scene->drawToBackground(_globals._spriteIndexes[6], 1, Common::Point(-32000, -32000), 0, 100); + _scene->_hotspots.activate(NOUN_SKULL, true); + } + + if (_globals[kCatacombsMisc] & MAZE_EVENT_PLANK) { + _globals._spriteIndexes[7] = _scene->_sprites.addSprites(formAnimName('c', 8)); + _scene->drawToBackground(_globals._spriteIndexes[7], 1, Common::Point(-32000, -32000), 0, 100); + _scene->_hotspots.activate(NOUN_PLANK, true); + } + + if (_scene->_priorSceneId != RETURNING_FROM_LOADING) { + switch (_globals[kCatacombsFrom]) { + case 0: + _game._player._playerPos = Common::Point(212, 86); + _game._player._facing = FACING_SOUTH; + _game._player.walk(Common::Point(212, 100), FACING_SOUTH); + break; + + case 1: + _game._player.firstWalk(Common::Point(330, 126), FACING_EAST, Common::Point(305, 126), FACING_WEST, true); + break; + + case 3: + _game._player._playerPos = Common::Point(3, 128); + _game._player._facing = FACING_SOUTH; + _game._player.walk(Common::Point(40, 128), FACING_EAST); + break; + + default: + break; + } + } + + if (_game._objects[OBJ_RED_FRAME]._roomNumber == _globals[kCatacombsRoom] + 600) { + _globals._sequenceIndexes[9] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[9], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[9], 14); + + Common::Point pos = _scene->_sprites[_globals._spriteIndexes[9]]->getFramePos(0); + _redFrameHotspotId = _scene->_dynamicHotspots.add(NOUN_RED_FRAME, VERB_WALK_TO, SYNTAX_SINGULAR, EXT_NONE, Common::Rect(pos.x - 5, pos.y - 5, pos.x + 5, pos.y + 1)); + _scene->_dynamicHotspots.setPosition(_redFrameHotspotId, Common::Point(pos.x + 12, pos.y), FACING_NORTHWEST); + } + + if (_game._objects[OBJ_GREEN_FRAME]._roomNumber == _globals[kCatacombsRoom] + 600) { + _globals._sequenceIndexes[10] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[10], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[10], 14); + + Common::Point pos = _scene->_sprites[_globals._spriteIndexes[9]]->getFramePos(0); + _greenFrameHostpotId = _scene->_dynamicHotspots.add(NOUN_GREEN_FRAME, VERB_WALK_TO, SYNTAX_SINGULAR, EXT_NONE, Common::Rect(pos.x - 5, pos.y - 5, pos.x + 5, pos.y + 1)); + _scene->_dynamicHotspots.setPosition(_greenFrameHostpotId, Common::Point(pos.x + 12, pos.y), FACING_NORTHWEST); + } + + if (_game._objects[OBJ_BLUE_FRAME]._roomNumber == _globals[kCatacombsRoom] + 600) { + _globals._sequenceIndexes[11] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[11], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[11], 14); + + Common::Point pos = _scene->_sprites[_globals._spriteIndexes[9]]->getFramePos(0); + _blueFrameHotspotId = _scene->_dynamicHotspots.add(NOUN_BLUE_FRAME, VERB_WALK_TO, SYNTAX_SINGULAR, EXT_NONE, Common::Rect(pos.x - 5, pos.y - 5, pos.x + 5, pos.y + 1)); + _scene->_dynamicHotspots.setPosition(_blueFrameHotspotId, Common::Point(pos.x + 12, pos.y), FACING_NORTHWEST); + } + + if (_game._objects[OBJ_YELLOW_FRAME]._roomNumber == _globals[kCatacombsRoom] + 600) { + _globals._sequenceIndexes[12] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[12], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[12], 14); + + Common::Point pos = _scene->_sprites[_globals._spriteIndexes[9]]->getFramePos(0); + _yellowFrameHotspotId = _scene->_dynamicHotspots.add(NOUN_YELLOW_FRAME, VERB_WALK_TO, SYNTAX_SINGULAR, EXT_NONE, Common::Rect(pos.x - 5, pos.y - 5, pos.x + 5, pos.y + 1)); + _scene->_dynamicHotspots.setPosition(_yellowFrameHotspotId, Common::Point(pos.x + 12, pos.y), FACING_NORTHWEST); + } + + if ((_game._difficulty == DIFFICULTY_EASY) && (_globals[kCatacombsRoom] == 19)) + _scene->_sequences.addTimer(120, 60); + + sceneEntrySound(); +} + +void Scene403::step() { + if (_game._trigger == 60) + _vm->_dialogs->show(31); +} + +void Scene403::actions() { + if (_action.isAction(VERB_PUT) && _action.isTarget(NOUN_FLOOR) + && (_action.isObject(NOUN_RED_FRAME) || _action.isObject(NOUN_BLUE_FRAME) || _action.isObject(NOUN_YELLOW_FRAME) || _action.isObject(NOUN_GREEN_FRAME))) { + if (_frameInRoomFl) + _vm->_dialogs->show(29); + else { + switch (_game._trigger) { + case (0): + _game._player._stepEnabled = false; + _game._player._visible = false; + _globals._sequenceIndexes[8] = _scene->_sequences.startPingPongCycle(_globals._spriteIndexes[8], true, 5, 2); + _scene->_sequences.setAnimRange(_globals._sequenceIndexes[8], 1, 5); + _scene->_sequences.setSeqPlayer(_globals._sequenceIndexes[8], true); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[8], SEQUENCE_TRIGGER_SPRITE, 5, 1); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[8], SEQUENCE_TRIGGER_EXPIRE, 0, 2); + break; + + case 1: + if (_action.isObject(NOUN_RED_FRAME)) { + _game._objects.setRoom(OBJ_RED_FRAME, NOWHERE); + _game._objects[OBJ_RED_FRAME]._roomNumber = _globals[kCatacombsRoom] + 600; + _globals._sequenceIndexes[9] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[9], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[9], 14); + + Common::Point pos = _scene->_sprites[_globals._spriteIndexes[9]]->getFramePos(0); + _redFrameHotspotId = _scene->_dynamicHotspots.add(NOUN_RED_FRAME, VERB_WALK_TO, SYNTAX_SINGULAR, EXT_NONE, Common::Rect(pos.x - 5, pos.y - 5, pos.x + 5, pos.y + 1)); + _scene->_dynamicHotspots.setPosition(_redFrameHotspotId, Common::Point(pos.x + 12, pos.y), FACING_NORTHWEST); + } + + if (_action.isObject(NOUN_GREEN_FRAME)) { + _game._objects.setRoom(OBJ_GREEN_FRAME, NOWHERE); + _game._objects[OBJ_GREEN_FRAME]._roomNumber = _globals[kCatacombsRoom] + 600; + _globals._sequenceIndexes[10] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[10], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[10], 14); + + Common::Point pos = _scene->_sprites[_globals._spriteIndexes[9]]->getFramePos(0); + _greenFrameHostpotId = _scene->_dynamicHotspots.add(NOUN_GREEN_FRAME, VERB_WALK_TO, SYNTAX_SINGULAR, EXT_NONE, Common::Rect(pos.x - 5, pos.y - 5, pos.x + 5, pos.y + 1)); + _scene->_dynamicHotspots.setPosition(_greenFrameHostpotId, Common::Point(pos.x + 12, pos.y), FACING_NORTHWEST); + } + + if (_action.isObject(NOUN_BLUE_FRAME)) { + _game._objects.setRoom(OBJ_BLUE_FRAME, NOWHERE); + _game._objects[OBJ_BLUE_FRAME]._roomNumber = _globals[kCatacombsRoom] + 600; + _globals._sequenceIndexes[11] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[11], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[11], 14); + + Common::Point pos = _scene->_sprites[_globals._spriteIndexes[9]]->getFramePos(0); + _blueFrameHotspotId = _scene->_dynamicHotspots.add(NOUN_BLUE_FRAME, VERB_WALK_TO, SYNTAX_SINGULAR, EXT_NONE, Common::Rect(pos.x - 5, pos.y - 5, pos.x + 5, pos.y + 1)); + _scene->_dynamicHotspots.setPosition(_blueFrameHotspotId, Common::Point(pos.x + 12, pos.y), FACING_NORTHWEST); + } + + if (_action.isObject(NOUN_YELLOW_FRAME)) { + _game._objects.setRoom(OBJ_YELLOW_FRAME, NOWHERE); + _game._objects[OBJ_YELLOW_FRAME]._roomNumber = _globals[kCatacombsRoom] + 600; + _globals._sequenceIndexes[12] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[12], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[12], 14); + + Common::Point pos = _scene->_sprites[_globals._spriteIndexes[9]]->getFramePos(0); + _yellowFrameHotspotId = _scene->_dynamicHotspots.add(NOUN_YELLOW_FRAME, VERB_WALK_TO, SYNTAX_SINGULAR, EXT_NONE, Common::Rect(pos.x - 5, pos.y - 5, pos.x + 5, pos.y + 1)); + _scene->_dynamicHotspots.setPosition(_yellowFrameHotspotId, Common::Point(pos.x + 12, pos.y), FACING_NORTHWEST); + } + break; + + case 2: + _game.syncTimers(SYNC_PLAYER, 0, SYNC_SEQ, _globals._sequenceIndexes[8]); + _game._player._visible = true; + _game._player._stepEnabled = true; + break; + + default: + break; + } + } + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_TAKE) + && (_action.isObject(NOUN_RED_FRAME) || _action.isObject(NOUN_GREEN_FRAME) || _action.isObject(NOUN_BLUE_FRAME) || _action.isObject(NOUN_YELLOW_FRAME))) { + if ((_takingFrameInRoomFl || _game._trigger)) { + switch (_game._trigger) { + case (0): + _game._player._stepEnabled = false; + _game._player._visible = false; + _globals._sequenceIndexes[8] = _scene->_sequences.startPingPongCycle(_globals._spriteIndexes[8], true, 5, 2); + _scene->_sequences.setAnimRange(_globals._sequenceIndexes[8], 1, 5); + _scene->_sequences.setSeqPlayer(_globals._sequenceIndexes[8], true); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[8], SEQUENCE_TRIGGER_SPRITE, 5, 1); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[8], SEQUENCE_TRIGGER_EXPIRE, 0, 2); + break; + + case 1: + if (_action.isObject(NOUN_RED_FRAME)) { + _scene->deleteSequence(_globals._sequenceIndexes[9]); + _scene->_dynamicHotspots.remove(_redFrameHotspotId); + _game._objects.addToInventory(OBJ_RED_FRAME); + } + + if (_action.isObject(NOUN_GREEN_FRAME)) { + _scene->deleteSequence(_globals._sequenceIndexes[10]); + _scene->_dynamicHotspots.remove(_greenFrameHostpotId); + _game._objects.addToInventory(OBJ_GREEN_FRAME); + } + + if (_action.isObject(NOUN_BLUE_FRAME)) { + _scene->deleteSequence(_globals._sequenceIndexes[11]); + _scene->_dynamicHotspots.remove(_blueFrameHotspotId); + _game._objects.addToInventory(OBJ_BLUE_FRAME); + } + + if (_action.isObject(NOUN_YELLOW_FRAME)) { + _scene->deleteSequence(_globals._sequenceIndexes[12]); + _scene->_dynamicHotspots.remove(_yellowFrameHotspotId); + _game._objects.addToInventory(OBJ_YELLOW_FRAME); + } + + _vm->_sound->command(26); + break; + + case 2: + _game.syncTimers(SYNC_PLAYER, 0, SYNC_SEQ, _globals._sequenceIndexes[8]); + _game._player._visible = true; + _game._player._stepEnabled = true; + break; + + default: + break; + } + _action._inProgress = false; + return; + } + } + + if (_action.isAction(VERB_WALK_THROUGH, NOUN_ARCHWAY_TO_NORTH)) { + _game.moveCatacombs(0); + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_WALK_THROUGH, NOUN_ARCHWAY_TO_WEST)) { + _game.moveCatacombs(3); + _action._inProgress = false; + return; + } + + if (_action._lookFlag) { + _vm->_dialogs->show(40310); + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_LOOK) || _action.isAction(VERB_LOOK_AT)) { + if (_action.isObject(NOUN_WALL)) { + _vm->_dialogs->show(40311); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_FLOOR)) { + _vm->_dialogs->show(40312); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_ARCHWAY)) { + _vm->_dialogs->show(40313); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_EXPOSED_BRICK)) { + _vm->_dialogs->show(40314); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_MORE_CATACOMBS)) { + _vm->_dialogs->show(40315); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_BLOCKED_ARCHWAY)) { + _vm->_dialogs->show(40316); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_RATS_NEST)) { + _vm->_dialogs->show(40318); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_SKULL)) { + _vm->_dialogs->show(40320); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_HOLE)) { + _vm->_dialogs->show(40323); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_WEB)) { + _vm->_dialogs->show(40324); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_RED_FRAME) && !_game._objects.isInInventory(OBJ_RED_FRAME)) { + _vm->_dialogs->showItem(OBJ_RED_FRAME, 802, 0); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_GREEN_FRAME) && !_game._objects.isInInventory(OBJ_GREEN_FRAME)) { + _vm->_dialogs->showItem(OBJ_GREEN_FRAME, 819, 0); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_BLUE_FRAME) && !_game._objects.isInInventory(OBJ_BLUE_FRAME)) { + _vm->_dialogs->showItem(OBJ_BLUE_FRAME, 817, 0); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_YELLOW_FRAME) && !_game._objects.isInInventory(OBJ_YELLOW_FRAME)) { + _vm->_dialogs->showItem(OBJ_YELLOW_FRAME, 804, 0); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_GATE)) { + _vm->_dialogs->show(45330); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_PLANK)) { + _vm->_dialogs->show(40325); + _action._inProgress = false; + return; + } + } + + if (_action.isAction(VERB_OPEN, NOUN_GATE)) { + _vm->_dialogs->show(45331); + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_TAKE, NOUN_RATS_NEST)) { + _vm->_dialogs->show(40319); + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_TAKE, NOUN_SKULL)) { + _vm->_dialogs->show(40321); + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_TAKE, NOUN_PLANK)) { + _vm->_dialogs->show(40326); + _action._inProgress = false; + return; + } +} + +void Scene403::preActions() { + if (_action.isAction(VERB_EXIT_TO, NOUN_MORE_CATACOMBS)) + _game.moveCatacombs(1); + + _frameInRoomFl = false; + _takingFrameInRoomFl = false; + + if (_game._objects[OBJ_RED_FRAME]._roomNumber == _globals[kCatacombsRoom] + 600) { + _frameInRoomFl = true; + if (_action.isAction(VERB_TAKE, NOUN_RED_FRAME)) + _takingFrameInRoomFl = true; + } + + if (_game._objects[OBJ_YELLOW_FRAME]._roomNumber == _globals[kCatacombsRoom] + 600) { + _frameInRoomFl = true; + if (_action.isAction(VERB_TAKE, NOUN_YELLOW_FRAME)) + _takingFrameInRoomFl = true; + } + + if (_game._objects[OBJ_BLUE_FRAME]._roomNumber == _globals[kCatacombsRoom] + 600) { + _frameInRoomFl = true; + if (_action.isAction(VERB_TAKE, NOUN_BLUE_FRAME)) + _takingFrameInRoomFl = true; + } + + if (_game._objects[OBJ_GREEN_FRAME]._roomNumber == _globals[kCatacombsRoom] + 600) { + _frameInRoomFl = true; + if (_action.isAction(VERB_TAKE, NOUN_GREEN_FRAME)) + _takingFrameInRoomFl = true; + } + + if (_action.isAction(VERB_PUT) && _action.isTarget(NOUN_FLOOR) + && (_action.isObject(NOUN_RED_FRAME) || _action.isObject(NOUN_BLUE_FRAME) || _action.isObject(NOUN_YELLOW_FRAME) || _action.isObject(NOUN_GREEN_FRAME))) { + if (_frameInRoomFl) + _game._player._needToWalk = false; + else { + Common::Point pos = _scene->_sprites[_globals._spriteIndexes[9]]->getFramePos(0); + _game._player.walk(Common::Point(pos.x + 12, pos.y), FACING_NORTHWEST); + } + } +} + +/*------------------------------------------------------------------------*/ + +Scene404::Scene404(MADSEngine *vm) : Scene4xx(vm) { + _frameInRoomFl = false; + _takingFrameInRoomFl = false; + _anim0ActvFl = false; + + _redFrameHotspotId = -1; + _greenFrameHostpotId = -1; + _blueFrameHotspotId = -1; + _yellowFrameHotspotId = -1; +} + +void Scene404::synchronize(Common::Serializer &s) { + Scene4xx::synchronize(s); + + s.syncAsByte(_frameInRoomFl); + s.syncAsByte(_takingFrameInRoomFl); + s.syncAsByte(_anim0ActvFl); + + s.syncAsSint16LE(_redFrameHotspotId); + s.syncAsSint16LE(_greenFrameHostpotId); + s.syncAsSint16LE(_blueFrameHotspotId); + s.syncAsSint16LE(_yellowFrameHotspotId); +} + +void Scene404::setup() { + setPlayerSpritesPrefix(); + setAAName(); + + if (_globals[kCatacombsMisc] & MAZE_EVENT_BLOCK) + _scene->_variant = 1; + + _scene->addActiveVocab(NOUN_RED_FRAME); + _scene->addActiveVocab(NOUN_YELLOW_FRAME); + _scene->addActiveVocab(NOUN_BLUE_FRAME); + _scene->addActiveVocab(NOUN_GREEN_FRAME); +} + +void Scene404::enter() { + _game.initCatacombs(); + + _scene->_hotspots.activate(NOUN_RATS_NEST, false); + _scene->_hotspots.activate(NOUN_WEB, false); + _scene->_hotspots.activate(NOUN_BROKEN_POT, false); + _scene->_hotspots.activate(NOUN_BLOCK, false); + _scene->_hotspots.activate(NOUN_PUDDLE, false); + + _anim0ActvFl = false; + + _globals._spriteIndexes[9] = _scene->_sprites.addSprites("*RRD_9"); + _globals._spriteIndexes[10] = _scene->_sprites.addSprites(formAnimName('f', 0)); + _globals._spriteIndexes[11] = _scene->_sprites.addSprites(formAnimName('f', 1)); + _globals._spriteIndexes[12] = _scene->_sprites.addSprites(formAnimName('f', 2)); + _globals._spriteIndexes[13] = _scene->_sprites.addSprites(formAnimName('f', 3)); + + + if (_game.exitCatacombs(0) == -1) { + _globals._spriteIndexes[1] = _scene->_sprites.addSprites(formAnimName('c', 1)); + _scene->drawToBackground(_globals._spriteIndexes[1], 1, Common::Point(-32000, -32000), 0, 100); + _scene->_hotspots.activate(NOUN_ARCHWAY_TO_NORTH, false); + } + + if (_game.exitCatacombs(3) == -1) { + _globals._spriteIndexes[0] = _scene->_sprites.addSprites(formAnimName('c', 0)); + _scene->drawToBackground(_globals._spriteIndexes[0], 1, Common::Point(-32000, -32000), 0, 100); + _scene->_hotspots.activate(NOUN_ARCHWAY_TO_WEST, false); + } + + if (_game.exitCatacombs(1) == -1) { + _globals._spriteIndexes[2] = _scene->_sprites.addSprites(formAnimName('c', 2)); + _scene->drawToBackground(_globals._spriteIndexes[2], 1, Common::Point(-32000, -32000), 0, 100); + _scene->_hotspots.activate(NOUN_ARCHWAY_TO_EAST, false); + } + + if (_game.exitCatacombs(2) == -1) + _scene->_hotspots.activate(NOUN_MORE_CATACOMBS, false); + + if (_globals[kCatacombsMisc] & MAZE_EVENT_RAT_NEST) { + _globals._spriteIndexes[3] = _scene->_sprites.addSprites(formAnimName('c', 3)); + _scene->drawToBackground(_globals._spriteIndexes[3], 1, Common::Point(-32000, -32000), 0, 100); + _scene->_hotspots.activate(NOUN_RATS_NEST, true); + } + + if (_globals[kCatacombsMisc] & MAZE_EVENT_WEB) { + _globals._spriteIndexes[4] = _scene->_sprites.addSprites(formAnimName('c', 4)); + _scene->drawToBackground(_globals._spriteIndexes[4], 1, Common::Point(-32000, -32000), 0, 100); + _scene->_hotspots.activate(NOUN_WEB, true); + } + + if (_globals[kCatacombsMisc] & MAZE_EVENT_POT) { + _globals._spriteIndexes[5] = _scene->_sprites.addSprites(formAnimName('c', 5)); + _scene->drawToBackground(_globals._spriteIndexes[5], 1, Common::Point(-32000, -32000), 0, 100); + _scene->_hotspots.activate(NOUN_BROKEN_POT, true); + } + + if (_globals[kCatacombsMisc] & MAZE_EVENT_BLOCK) { + _globals._spriteIndexes[7] = _scene->_sprites.addSprites(formAnimName('c', 7)); + _scene->drawToBackground(_globals._spriteIndexes[7], 1, Common::Point(-32000, -32000), 0, 100); + } + + if (_globals[kCatacombsMisc] & MAZE_EVENT_FALLEN_BLOCK) { + _globals._spriteIndexes[8] = _scene->_sprites.addSprites(formAnimName('c', 8)); + _scene->drawToBackground(_globals._spriteIndexes[8], 1, Common::Point(-32000, -32000), 0, 100); + _scene->_hotspots.activate(NOUN_BLOCK, true); + } + + if (_globals[kCatacombsMisc] & MAZE_EVENT_PUDDLE) { + _scene->_hotspots.activate(NOUN_PUDDLE, true); + _globals._animationIndexes[0] = _scene->loadAnimation(formAnimName('d', 1), 0); + _anim0ActvFl = true; + } + + if (_scene->_priorSceneId != RETURNING_FROM_LOADING) { + switch (_globals[kCatacombsFrom]) { + case 0: + _game._player._playerPos = Common::Point(156, 98); + _game._player._facing = FACING_SOUTH; + _game._player.walk(Common::Point(156, 117), FACING_SOUTH); + break; + + case 1: + _game._player._playerPos = Common::Point(319, 135); + _game._player._facing = FACING_WEST; + _game._player.walk(Common::Point(279, 135), FACING_WEST); + break; + + case 2: + _game._player._playerPos = Common::Point(175, 147); + _game._player._facing = FACING_NORTH; + break; + + case 3: + _game._player._playerPos = Common::Point(17, 131); + _game._player._facing = FACING_SOUTH; + _game._player.walk(Common::Point(60, 131), FACING_EAST); + break; + + default: + break; + } + } + + if (_game._objects[OBJ_RED_FRAME]._roomNumber == _globals[kCatacombsRoom] + 600) { + _globals._sequenceIndexes[10] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[10], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[10], 14); + Common::Point pos = _scene->_sprites[_globals._spriteIndexes[10]]->getFramePos(0); + _redFrameHotspotId = _scene->_dynamicHotspots.add(NOUN_RED_FRAME, VERB_WALK_TO, SYNTAX_SINGULAR, EXT_NONE, Common::Rect(pos.x - 5, pos.y - 5, pos.x + 5, pos.y + 1)); + _scene->_dynamicHotspots.setPosition(_redFrameHotspotId, Common::Point(pos.x + 12, pos.y), FACING_NORTHWEST); + } + + if (_game._objects[OBJ_GREEN_FRAME]._roomNumber == _globals[kCatacombsRoom] + 600) { + _globals._sequenceIndexes[11] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[11], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[11], 14); + + Common::Point pos = _scene->_sprites[_globals._spriteIndexes[10]]->getFramePos(0); + _greenFrameHostpotId = _scene->_dynamicHotspots.add(NOUN_GREEN_FRAME, VERB_WALK_TO, SYNTAX_SINGULAR, EXT_NONE, Common::Rect(pos.x - 5, pos.y - 5, pos.x + 5, pos.y + 1)); + _scene->_dynamicHotspots.setPosition(_greenFrameHostpotId, Common::Point(pos.x + 12, pos.y), FACING_NORTHWEST); + } + + if (_game._objects[OBJ_BLUE_FRAME]._roomNumber == _globals[kCatacombsRoom] + 600) { + _globals._sequenceIndexes[12] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[12], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[12], 14); + + Common::Point pos = _scene->_sprites[_globals._spriteIndexes[10]]->getFramePos(0); + _blueFrameHotspotId = _scene->_dynamicHotspots.add(NOUN_BLUE_FRAME, VERB_WALK_TO, SYNTAX_SINGULAR, EXT_NONE, Common::Rect(pos.x - 5, pos.y - 5, pos.x + 5, pos.y + 1)); + _scene->_dynamicHotspots.setPosition(_blueFrameHotspotId, Common::Point(pos.x + 12, pos.y), FACING_NORTHWEST); + } + + if (_game._objects[OBJ_YELLOW_FRAME]._roomNumber == _globals[kCatacombsRoom] + 600) { + _globals._sequenceIndexes[13] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[13], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[13], 14); + + Common::Point pos = _scene->_sprites[_globals._spriteIndexes[10]]->getFramePos(0); + _yellowFrameHotspotId = _scene->_dynamicHotspots.add(NOUN_YELLOW_FRAME, VERB_WALK_TO, SYNTAX_SINGULAR, EXT_NONE, Common::Rect(pos.x - 5, pos.y - 5, pos.x + 5, pos.y + 1)); + _scene->_dynamicHotspots.setPosition(_yellowFrameHotspotId, Common::Point(pos.x + 12, pos.y), FACING_NORTHWEST); + } + + if (_globals[kPriestPistonPuke]) + _scene->_sequences.addTimer(120, 60); + + sceneEntrySound(); +} + +void Scene404::step() { + if (_anim0ActvFl) { + if (_scene->_animation[_globals._animationIndexes[0]]->getCurrentFrame() == 20) + _scene->setAnimFrame(_globals._animationIndexes[0], 0); + } + + if (_game._trigger == 60) { + _vm->_dialogs->show(30); + _globals[kPriestPistonPuke] = false; + } +} + +void Scene404::actions() { + if (_action.isAction(VERB_PUT) && _action.isTarget(NOUN_FLOOR) + && (_action.isObject(NOUN_RED_FRAME) || _action.isObject(NOUN_BLUE_FRAME) || _action.isObject(NOUN_YELLOW_FRAME) || _action.isObject(NOUN_GREEN_FRAME))) { + if (_frameInRoomFl) + _vm->_dialogs->show(29); + else { + switch (_game._trigger) { + case (0): + _game._player._stepEnabled = false; + _game._player._visible = false; + _globals._sequenceIndexes[9] = _scene->_sequences.startPingPongCycle(_globals._spriteIndexes[9], true, 5, 2); + _scene->_sequences.setAnimRange(_globals._sequenceIndexes[9], 1, 5); + _scene->_sequences.setSeqPlayer(_globals._sequenceIndexes[9], true); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[9], SEQUENCE_TRIGGER_SPRITE, 5, 1); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[9], SEQUENCE_TRIGGER_EXPIRE, 0, 2); + break; + + case 1: + if (_action.isObject(NOUN_RED_FRAME)) { + _game._objects.setRoom(OBJ_RED_FRAME, NOWHERE); + _game._objects[OBJ_RED_FRAME]._roomNumber = _globals[kCatacombsRoom] + 600; + _globals._sequenceIndexes[10] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[10], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[10], 14); + + Common::Point pos = _scene->_sprites[_globals._spriteIndexes[10]]->getFramePos(0); + _redFrameHotspotId = _scene->_dynamicHotspots.add(NOUN_RED_FRAME, VERB_WALK_TO, SYNTAX_SINGULAR, EXT_NONE, Common::Rect(pos.x - 5, pos.y - 5, pos.x + 5, pos.y + 1)); + _scene->_dynamicHotspots.setPosition(_redFrameHotspotId, Common::Point(pos.x + 12, pos.y), FACING_NORTHWEST); + } + + if (_action.isObject(NOUN_GREEN_FRAME)) { + _game._objects.setRoom(OBJ_GREEN_FRAME, NOWHERE); + _game._objects[OBJ_GREEN_FRAME]._roomNumber = _globals[kCatacombsRoom] + 600; + _globals._sequenceIndexes[11] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[11], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[11], 14); + + Common::Point pos = _scene->_sprites[_globals._spriteIndexes[10]]->getFramePos(0); + _greenFrameHostpotId = _scene->_dynamicHotspots.add(NOUN_GREEN_FRAME, VERB_WALK_TO, SYNTAX_SINGULAR, EXT_NONE, Common::Rect(pos.x - 5, pos.y - 5, pos.x + 5, pos.y + 1)); + _scene->_dynamicHotspots.setPosition(_greenFrameHostpotId, Common::Point(pos.x + 12, pos.y), FACING_NORTHWEST); + } + + if (_action.isObject(NOUN_BLUE_FRAME)) { + _game._objects.setRoom(OBJ_BLUE_FRAME, NOWHERE); + _game._objects[OBJ_BLUE_FRAME]._roomNumber = _globals[kCatacombsRoom] + 600; + _globals._sequenceIndexes[12] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[12], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[12], 14); + + Common::Point pos = _scene->_sprites[_globals._spriteIndexes[10]]->getFramePos(0); + _blueFrameHotspotId = _scene->_dynamicHotspots.add(NOUN_BLUE_FRAME, VERB_WALK_TO, SYNTAX_SINGULAR, EXT_NONE, Common::Rect(pos.x - 5, pos.y - 5, pos.x + 5, pos.y + 1)); + _scene->_dynamicHotspots.setPosition(_blueFrameHotspotId, Common::Point(pos.x + 12, pos.y), FACING_NORTHWEST); + } + + if (_action.isObject(NOUN_YELLOW_FRAME)) { + _game._objects.setRoom(OBJ_YELLOW_FRAME, NOWHERE); + _game._objects[OBJ_YELLOW_FRAME]._roomNumber = _globals[kCatacombsRoom] + 600; + _globals._sequenceIndexes[13] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[13], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[13], 14); + + Common::Point pos = _scene->_sprites[_globals._spriteIndexes[10]]->getFramePos(0); + _yellowFrameHotspotId = _scene->_dynamicHotspots.add(NOUN_YELLOW_FRAME, VERB_WALK_TO, SYNTAX_SINGULAR, EXT_NONE, Common::Rect(pos.x - 5, pos.y - 5, pos.x + 5, pos.y + 1)); + _scene->_dynamicHotspots.setPosition(_yellowFrameHotspotId, Common::Point(pos.x + 12, pos.y), FACING_NORTHWEST); + } + break; + + case 2: + _game.syncTimers(SYNC_PLAYER, 0, SYNC_SEQ, _globals._sequenceIndexes[9]); + _game._player._visible = true; + _game._player._stepEnabled = true; + break; + + default: + break; + } + } + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_TAKE)) { + if ((_action.isObject(NOUN_RED_FRAME) || _action.isObject(NOUN_GREEN_FRAME) || _action.isObject(NOUN_BLUE_FRAME) || _action.isObject(NOUN_YELLOW_FRAME)) && (_takingFrameInRoomFl || _game._trigger)) { + switch (_game._trigger) { + case (0): + _game._player._stepEnabled = false; + _game._player._visible = false; + _globals._sequenceIndexes[9] = _scene->_sequences.startPingPongCycle(_globals._spriteIndexes[9], true, 5, 2); + _scene->_sequences.setAnimRange(_globals._sequenceIndexes[9], 1, 5); + _scene->_sequences.setSeqPlayer(_globals._sequenceIndexes[9], true); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[9], SEQUENCE_TRIGGER_SPRITE, 5, 1); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[9], SEQUENCE_TRIGGER_EXPIRE, 0, 2); + break; + + case 1: + if (_action.isObject(NOUN_RED_FRAME)) { + _scene->deleteSequence(_globals._sequenceIndexes[10]); + _scene->_dynamicHotspots.remove(_redFrameHotspotId); + _game._objects.addToInventory(OBJ_RED_FRAME); + } + + if (_action.isObject(NOUN_GREEN_FRAME)) { + _scene->deleteSequence(_globals._sequenceIndexes[11]); + _scene->_dynamicHotspots.remove(_greenFrameHostpotId); + _game._objects.addToInventory(OBJ_GREEN_FRAME); + } + + if (_action.isObject(NOUN_BLUE_FRAME)) { + _scene->deleteSequence(_globals._sequenceIndexes[12]); + _scene->_dynamicHotspots.remove(_blueFrameHotspotId); + _game._objects.addToInventory(OBJ_BLUE_FRAME); + } + + if (_action.isObject(NOUN_YELLOW_FRAME)) { + _scene->deleteSequence(_globals._sequenceIndexes[13]); + _scene->_dynamicHotspots.remove(_yellowFrameHotspotId); + _game._objects.addToInventory(OBJ_YELLOW_FRAME); + } + + _vm->_sound->command(26); + break; + + case 2: + _game.syncTimers(SYNC_PLAYER, 0, SYNC_SEQ, _globals._sequenceIndexes[9]); + _game._player._visible = true; + _game._player._stepEnabled = true; + break; + + default: + break; + } + _action._inProgress = false; + return; + } + } + + if (_action.isAction(VERB_WALK_THROUGH, NOUN_ARCHWAY_TO_NORTH)) { + _game.moveCatacombs(0); + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_WALK_THROUGH, NOUN_ARCHWAY_TO_WEST)) { + _game.moveCatacombs(3); + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_EXIT_TO, NOUN_MORE_CATACOMBS)) { + _game.moveCatacombs(2); + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_WALK_THROUGH, NOUN_ARCHWAY_TO_EAST)) { + _game.moveCatacombs(1); + _action._inProgress = false; + return; + } + + if (_action._lookFlag) { + _vm->_dialogs->show(40410); + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_LOOK) || _action.isAction(VERB_LOOK_AT)) { + if (_action.isObject(NOUN_WALL)) { + _vm->_dialogs->show(40411); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_FLOOR)) { + _vm->_dialogs->show(40412); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_ARCHWAY)) { + _vm->_dialogs->show(40413); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_EXPOSED_BRICK)) { + _vm->_dialogs->show(40414); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_MORE_CATACOMBS)) { + _vm->_dialogs->show(40415); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_PUDDLE)) { + _vm->_dialogs->show(40417); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_RATS_NEST)) { + _vm->_dialogs->show(40418); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_BROKEN_POT)) { + _vm->_dialogs->show(40421); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_WEB)) { + _vm->_dialogs->show(40424); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_RED_FRAME) && !_game._objects.isInInventory(OBJ_RED_FRAME)) { + _vm->_dialogs->showItem(OBJ_RED_FRAME, 802, 0); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_GREEN_FRAME) && !_game._objects.isInInventory(OBJ_GREEN_FRAME)) { + _vm->_dialogs->showItem(OBJ_GREEN_FRAME, 819, 0); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_BLUE_FRAME) && !_game._objects.isInInventory(OBJ_BLUE_FRAME)) { + _vm->_dialogs->showItem(OBJ_BLUE_FRAME, 817, 0); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_YELLOW_FRAME) && !_game._objects.isInInventory(OBJ_YELLOW_FRAME)) { + _vm->_dialogs->showItem(OBJ_YELLOW_FRAME, 804, 0); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_BLOCK)) { + _vm->_dialogs->show(40430); + _action._inProgress = false; + return; + } + } + + if (_action.isAction(VERB_TAKE, NOUN_RATS_NEST)) { + _vm->_dialogs->show(40419); + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_TAKE, NOUN_BROKEN_POT)) { + _vm->_dialogs->show(40422); + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_TAKE, NOUN_BLOCK)) { + _vm->_dialogs->show(40431); + _action._inProgress = false; + return; + } +} + +void Scene404::preActions() { + _frameInRoomFl = false; + _takingFrameInRoomFl = false; + + if (_game._objects[OBJ_RED_FRAME]._roomNumber == _globals[kCatacombsRoom] + 600) { + _frameInRoomFl = true; + if (_action.isAction(VERB_TAKE, NOUN_RED_FRAME)) + _takingFrameInRoomFl = true; + } + + if (_game._objects[OBJ_YELLOW_FRAME]._roomNumber == _globals[kCatacombsRoom] + 600) { + _frameInRoomFl = true; + if (_action.isAction(VERB_TAKE, NOUN_YELLOW_FRAME)) + _takingFrameInRoomFl = true; + } + + if (_game._objects[OBJ_BLUE_FRAME]._roomNumber == _globals[kCatacombsRoom] + 600) { + _frameInRoomFl = true; + if (_action.isAction(VERB_TAKE, NOUN_BLUE_FRAME)) + _takingFrameInRoomFl = true; + } + + if (_game._objects[OBJ_GREEN_FRAME]._roomNumber == _globals[kCatacombsRoom] + 600) { + _frameInRoomFl = true; + if (_action.isAction(VERB_TAKE, NOUN_GREEN_FRAME)) + _takingFrameInRoomFl = true; + } + + if (_action.isAction(VERB_PUT) && _action.isTarget(NOUN_FLOOR) + && (_action.isObject(NOUN_RED_FRAME) || _action.isObject(NOUN_BLUE_FRAME) || _action.isObject(NOUN_YELLOW_FRAME) || _action.isObject(NOUN_GREEN_FRAME))) { + if (_frameInRoomFl) + _game._player._needToWalk = false; + else { + Common::Point pos = _scene->_sprites[_globals._spriteIndexes[10]]->getFramePos(0); + _game._player.walk(Common::Point(pos.x + 12, pos.y), FACING_NORTHWEST); + } + } +} + +/*------------------------------------------------------------------------*/ + +Scene406::Scene406(MADSEngine *vm) : Scene4xx(vm) { + _frameInRoomFl = false; + _takingFrameInRoomFl = false; + + _redFrameHotspotId = -1; + _greenFrameHostpotId = -1; + _blueFrameHotspotId = -1; + _yellowFrameHotspotId = -1; +} + +void Scene406::synchronize(Common::Serializer &s) { + Scene4xx::synchronize(s); + + s.syncAsByte(_frameInRoomFl); + s.syncAsByte(_takingFrameInRoomFl); + + s.syncAsSint16LE(_redFrameHotspotId); + s.syncAsSint16LE(_greenFrameHostpotId); + s.syncAsSint16LE(_blueFrameHotspotId); + s.syncAsSint16LE(_yellowFrameHotspotId); +} + +void Scene406::setup() { + setPlayerSpritesPrefix(); + setAAName(); + + _scene->addActiveVocab(NOUN_RED_FRAME); + _scene->addActiveVocab(NOUN_YELLOW_FRAME); + _scene->addActiveVocab(NOUN_BLUE_FRAME); + _scene->addActiveVocab(NOUN_GREEN_FRAME); +} + +void Scene406::enter() { + _game.initCatacombs(); + + _globals._spriteIndexes[0] = _scene->_sprites.addSprites("*RRD_9"); + _globals._spriteIndexes[1] = _scene->_sprites.addSprites(formAnimName('f', 0)); + _globals._spriteIndexes[2] = _scene->_sprites.addSprites(formAnimName('f', 1)); + _globals._spriteIndexes[3] = _scene->_sprites.addSprites(formAnimName('f', 2)); + _globals._spriteIndexes[4] = _scene->_sprites.addSprites(formAnimName('f', 3)); + + if (_scene->_priorSceneId != RETURNING_FROM_LOADING) { + switch (_globals[kCatacombsFrom]) { + case 1: + _game._player._playerPos = Common::Point(310, 118); + _game._player._facing = FACING_WEST; + _game._player.walk(Common::Point(271, 118), FACING_WEST); + break; + + case 3: + _game._player._playerPos = Common::Point(20, 122); + _game._player._facing = FACING_SOUTH; + _game._player.walk(Common::Point(66, 122), FACING_EAST); + break; + + default: + break; + } + } + + if (_game._objects[OBJ_RED_FRAME]._roomNumber == _globals[kCatacombsRoom] + 600) { + _globals._sequenceIndexes[1] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[1], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[1], 14); + + Common::Point pos = _scene->_sprites[_globals._spriteIndexes[1]]->getFramePos(0); + _redFrameHotspotId = _scene->_dynamicHotspots.add(NOUN_RED_FRAME, VERB_WALK_TO, SYNTAX_SINGULAR, EXT_NONE, Common::Rect(pos.x - 5, pos.y - 5, pos.x + 5, pos.y + 1)); + _scene->_dynamicHotspots.setPosition(_redFrameHotspotId, Common::Point(pos.x + 12, pos.y), FACING_NORTHWEST); + } + + if (_game._objects[OBJ_GREEN_FRAME]._roomNumber == _globals[kCatacombsRoom] + 600) { + _globals._sequenceIndexes[2] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[2], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[2], 14); + + Common::Point pos = _scene->_sprites[_globals._spriteIndexes[1]]->getFramePos(0); + _greenFrameHostpotId = _scene->_dynamicHotspots.add(NOUN_GREEN_FRAME, VERB_WALK_TO, SYNTAX_SINGULAR, EXT_NONE, Common::Rect(pos.x - 5, pos.y - 5, pos.x + 5, pos.y + 1)); + _scene->_dynamicHotspots.setPosition(_greenFrameHostpotId, Common::Point(pos.x + 12, pos.y), FACING_NORTHWEST); + } + + if (_game._objects[OBJ_BLUE_FRAME]._roomNumber == _globals[kCatacombsRoom] + 600) { + _globals._sequenceIndexes[3] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[3], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[3], 14); + + Common::Point pos = _scene->_sprites[_globals._spriteIndexes[1]]->getFramePos(0); + _blueFrameHotspotId = _scene->_dynamicHotspots.add(NOUN_BLUE_FRAME, VERB_WALK_TO, SYNTAX_SINGULAR, EXT_NONE, Common::Rect(pos.x - 5, pos.y - 5, pos.x + 5, pos.y + 1)); + _scene->_dynamicHotspots.setPosition(_blueFrameHotspotId, Common::Point(pos.x + 12, pos.y), FACING_NORTHWEST); + } + + if (_game._objects[OBJ_YELLOW_FRAME]._roomNumber == _globals[kCatacombsRoom] + 600) { + _globals._sequenceIndexes[4] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[4], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[4], 14); + + Common::Point pos = _scene->_sprites[_globals._spriteIndexes[1]]->getFramePos(0); + _yellowFrameHotspotId = _scene->_dynamicHotspots.add(NOUN_YELLOW_FRAME, VERB_WALK_TO, SYNTAX_SINGULAR, EXT_NONE, Common::Rect(pos.x - 5, pos.y - 5, pos.x + 5, pos.y + 1)); + _scene->_dynamicHotspots.setPosition(_yellowFrameHotspotId, Common::Point(pos.x + 12, pos.y), FACING_NORTHWEST); + } + + sceneEntrySound(); +} + +void Scene406::step() { +} + +void Scene406::actions() { + if (_action.isAction(VERB_PUT) && _action.isTarget(NOUN_FLOOR) + && (_action.isObject(NOUN_RED_FRAME) || _action.isObject(NOUN_BLUE_FRAME) || _action.isObject(NOUN_YELLOW_FRAME) || _action.isObject(NOUN_GREEN_FRAME))) { + if (_frameInRoomFl) + _vm->_dialogs->show(29); + else { + switch (_game._trigger) { + case (0): + _game._player._stepEnabled = false; + _game._player._visible = false; + _globals._sequenceIndexes[0] = _scene->_sequences.startPingPongCycle(_globals._spriteIndexes[0], true, 5, 2); + _scene->_sequences.setAnimRange(_globals._sequenceIndexes[0], 1, 5); + _scene->_sequences.setSeqPlayer(_globals._sequenceIndexes[0], true); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[0], SEQUENCE_TRIGGER_SPRITE, 5, 1); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[0], SEQUENCE_TRIGGER_EXPIRE, 0, 2); + break; + + case 1: + if (_action.isObject(NOUN_RED_FRAME)) { + _game._objects.setRoom(OBJ_RED_FRAME, NOWHERE); + _game._objects[OBJ_RED_FRAME]._roomNumber = _globals[kCatacombsRoom] + 600; + _globals._sequenceIndexes[1] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[1], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[1], 14); + + Common::Point pos = _scene->_sprites[_globals._spriteIndexes[1]]->getFramePos(0); + _redFrameHotspotId = _scene->_dynamicHotspots.add(NOUN_RED_FRAME, VERB_WALK_TO, SYNTAX_SINGULAR, EXT_NONE, Common::Rect(pos.x - 5, pos.y - 5, pos.x + 5, pos.y + 1)); + _scene->_dynamicHotspots.setPosition(_redFrameHotspotId, Common::Point(pos.x + 12, pos.y), FACING_NORTHWEST); + } + + if (_action.isObject(NOUN_GREEN_FRAME)) { + _game._objects.setRoom(OBJ_GREEN_FRAME, NOWHERE); + _game._objects[OBJ_GREEN_FRAME]._roomNumber = _globals[kCatacombsRoom] + 600; + _globals._sequenceIndexes[2] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[2], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[2], 14); + + Common::Point pos = _scene->_sprites[_globals._spriteIndexes[1]]->getFramePos(0); + _greenFrameHostpotId = _scene->_dynamicHotspots.add(NOUN_GREEN_FRAME, VERB_WALK_TO, SYNTAX_SINGULAR, EXT_NONE, Common::Rect(pos.x - 5, pos.y - 5, pos.x + 5, pos.y + 1)); + _scene->_dynamicHotspots.setPosition(_greenFrameHostpotId, Common::Point(pos.x + 12, pos.y), FACING_NORTHWEST); + } + + if (_action.isObject(NOUN_BLUE_FRAME)) { + _game._objects.setRoom(OBJ_BLUE_FRAME, NOWHERE); + _game._objects[OBJ_BLUE_FRAME]._roomNumber = _globals[kCatacombsRoom] + 600; + _globals._sequenceIndexes[3] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[3], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[3], 14); + + Common::Point pos = _scene->_sprites[_globals._spriteIndexes[1]]->getFramePos(0); + _blueFrameHotspotId = _scene->_dynamicHotspots.add(NOUN_BLUE_FRAME, VERB_WALK_TO, SYNTAX_SINGULAR, EXT_NONE, Common::Rect(pos.x - 5, pos.y - 5, pos.x + 5, pos.y + 1)); + _scene->_dynamicHotspots.setPosition(_blueFrameHotspotId, Common::Point(pos.x + 12, pos.y), FACING_NORTHWEST); + } + + if (_action.isObject(NOUN_YELLOW_FRAME)) { + _game._objects.setRoom(OBJ_YELLOW_FRAME, NOWHERE); + _game._objects[OBJ_YELLOW_FRAME]._roomNumber = _globals[kCatacombsRoom] + 600; + _globals._sequenceIndexes[4] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[4], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[4], 14); + + Common::Point pos = _scene->_sprites[_globals._spriteIndexes[1]]->getFramePos(0); + _yellowFrameHotspotId = _scene->_dynamicHotspots.add(NOUN_YELLOW_FRAME, VERB_WALK_TO, SYNTAX_SINGULAR, EXT_NONE, Common::Rect(pos.x - 5, pos.y - 5, pos.x + 5, pos.y + 1)); + _scene->_dynamicHotspots.setPosition(_yellowFrameHotspotId, Common::Point(pos.x + 12, pos.y), FACING_NORTHWEST); + } + break; + + case 2: + _game.syncTimers(SYNC_PLAYER, 0, SYNC_SEQ, _globals._sequenceIndexes[0]); + _game._player._visible = true; + _game._player._stepEnabled = true; + break; + + default: + break; + } + } + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_TAKE) + && (_action.isObject(NOUN_RED_FRAME) || _action.isObject(NOUN_GREEN_FRAME) || _action.isObject(NOUN_BLUE_FRAME) || _action.isObject(NOUN_YELLOW_FRAME))) { + if ((_takingFrameInRoomFl || _game._trigger)) { + switch (_game._trigger) { + case (0): + _game._player._stepEnabled = false; + _game._player._visible = false; + _globals._sequenceIndexes[0] = _scene->_sequences.startPingPongCycle(_globals._spriteIndexes[0], true, 5, 2); + _scene->_sequences.setAnimRange(_globals._sequenceIndexes[0], 1, 5); + _scene->_sequences.setSeqPlayer(_globals._sequenceIndexes[0], true); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[0], SEQUENCE_TRIGGER_SPRITE, 5, 1); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[0], SEQUENCE_TRIGGER_EXPIRE, 0, 2); + break; + + case 1: + if (_action.isObject(NOUN_RED_FRAME)) { + _scene->deleteSequence(_globals._sequenceIndexes[1]); + _scene->_dynamicHotspots.remove(_redFrameHotspotId); + _game._objects.addToInventory(OBJ_RED_FRAME); + } + + if (_action.isObject(NOUN_GREEN_FRAME)) { + _scene->deleteSequence(_globals._sequenceIndexes[2]); + _scene->_dynamicHotspots.remove(_greenFrameHostpotId); + _game._objects.addToInventory(OBJ_GREEN_FRAME); + } + + if (_action.isObject(NOUN_BLUE_FRAME)) { + _scene->deleteSequence(_globals._sequenceIndexes[3]); + _scene->_dynamicHotspots.remove(_blueFrameHotspotId); + _game._objects.addToInventory(OBJ_BLUE_FRAME); + } + + if (_action.isObject(NOUN_YELLOW_FRAME)) { + _scene->deleteSequence(_globals._sequenceIndexes[4]); + _scene->_dynamicHotspots.remove(_yellowFrameHotspotId); + _game._objects.addToInventory(OBJ_YELLOW_FRAME); + } + + _vm->_sound->command(26); + break; + + case 2: + _game.syncTimers(SYNC_PLAYER, 0, SYNC_SEQ, _globals._sequenceIndexes[0]); + _game._player._visible = true; + _game._player._stepEnabled = true; + break; + + default: + break; + } + _action._inProgress = false; + return; + } + } + + if (_action.isAction(VERB_WALK_THROUGH, NOUN_ARCHWAY_TO_WEST)) { + _game.moveCatacombs(3); + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_WALK_THROUGH, NOUN_ARCHWAY_TO_EAST)) { + _game.moveCatacombs(1); + _action._inProgress = false; + return; + } + + if (_action._lookFlag) { + _vm->_dialogs->show(40610); + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_LOOK) || _action.isAction(VERB_LOOK_AT)) { + if (_action.isObject(NOUN_WALL)) { + _vm->_dialogs->show(40611); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_FLOOR)) { + _vm->_dialogs->show(40612); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_ARCHWAY)) { + _vm->_dialogs->show(40613); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_EXPOSED_BRICK)) { + _vm->_dialogs->show(40614); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_MORE_CATACOMBS)) { + _vm->_dialogs->show(40615); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_BLOCKED_ARCHWAY)) { + _vm->_dialogs->show(40616); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_RED_FRAME) && !_game._objects.isInInventory(OBJ_RED_FRAME)) { + _vm->_dialogs->showItem(OBJ_RED_FRAME, 802, 0); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_GREEN_FRAME) && !_game._objects.isInInventory(OBJ_GREEN_FRAME)) { + _vm->_dialogs->showItem(OBJ_GREEN_FRAME, 819, 0); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_BLUE_FRAME) && !_game._objects.isInInventory(OBJ_BLUE_FRAME)) { + _vm->_dialogs->showItem(OBJ_BLUE_FRAME, 817, 0); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_YELLOW_FRAME) && !_game._objects.isInInventory(OBJ_YELLOW_FRAME)) { + _vm->_dialogs->showItem(OBJ_YELLOW_FRAME, 804, 0); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_GRATE)) { + _vm->_dialogs->show(40617); + _action._inProgress = false; + return; + } + } + + if (_action.isAction(VERB_OPEN, NOUN_GRATE) || _action.isAction(VERB_PUSH, NOUN_GRATE) || _action.isAction(VERB_PULL, NOUN_GRATE)) { + switch (_game._trigger) { + case (0): + _game._player._stepEnabled = false; + _game._player._visible = false; + _globals._sequenceIndexes[0] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[0], true, 5, 1); + _scene->_sequences.setAnimRange(_globals._sequenceIndexes[0], -1, -2); + _scene->_sequences.setSeqPlayer(_globals._sequenceIndexes[0], true); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[0], SEQUENCE_TRIGGER_EXPIRE, 0, 2); + break; + + case 2: + _globals._sequenceIndexes[0] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[0], true, -2); + _scene->_sequences.setSeqPlayer(_globals._sequenceIndexes[0], true); + _scene->_sequences.addTimer(30, 3); + break; + + case 3: + _scene->deleteSequence(_globals._sequenceIndexes[0]); + _globals._sequenceIndexes[0] = _scene->_sequences.addReverseSpriteCycle(_globals._spriteIndexes[0], true, 5, 1); + _scene->_sequences.setAnimRange(_globals._sequenceIndexes[0], -1, -2); + _scene->_sequences.setSeqPlayer(_globals._sequenceIndexes[0], false); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[0], SEQUENCE_TRIGGER_EXPIRE, 0, 4); + break; + + case 4: + _game._player._visible = true; + _game.syncTimers(SYNC_PLAYER, 0, SYNC_SEQ, _globals._sequenceIndexes[0]); + _scene->_sequences.addTimer(6, 5); + break; + + case 5: + _game._player._stepEnabled = true; + _vm->_dialogs->show(40618); + break; + + default: + break; + } + _action._inProgress = false; + } +} + +void Scene406::preActions() { + _frameInRoomFl = false; + _takingFrameInRoomFl = false; + + if (_game._objects[OBJ_RED_FRAME]._roomNumber == _globals[kCatacombsRoom] + 600) { + _frameInRoomFl = true; + if (_action.isAction(VERB_TAKE, NOUN_RED_FRAME)) + _takingFrameInRoomFl = true; + } + + if (_game._objects[OBJ_YELLOW_FRAME]._roomNumber == _globals[kCatacombsRoom] + 600) { + _frameInRoomFl = true; + if (_action.isAction(VERB_TAKE, NOUN_YELLOW_FRAME)) + _takingFrameInRoomFl = true; + } + + if (_game._objects[OBJ_BLUE_FRAME]._roomNumber == _globals[kCatacombsRoom] + 600) { + _frameInRoomFl = true; + if (_action.isAction(VERB_TAKE, NOUN_BLUE_FRAME)) + _takingFrameInRoomFl = true; + } + + if (_game._objects[OBJ_GREEN_FRAME]._roomNumber == _globals[kCatacombsRoom] + 600) { + _frameInRoomFl = true; + if (_action.isAction(VERB_TAKE, NOUN_GREEN_FRAME)) + _takingFrameInRoomFl = true; + } + + if (_action.isAction(VERB_PUT) && _action.isTarget(NOUN_FLOOR) + && (_action.isObject(NOUN_RED_FRAME) || _action.isObject(NOUN_BLUE_FRAME) || _action.isObject(NOUN_YELLOW_FRAME) || _action.isObject(NOUN_GREEN_FRAME))) { + if (_frameInRoomFl) + _game._player._needToWalk = false; + else { + Common::Point pos = _scene->_sprites[_globals._spriteIndexes[1]]->getFramePos(0); + pos.x += 12; + _game._player.walk(pos, FACING_NORTHWEST); + } + } +} + +/*------------------------------------------------------------------------*/ + +Scene407::Scene407(MADSEngine *vm) : Scene4xx(vm) { + _frameInRoomFl = false; + _takingFrameInRoomFl = false; + + _redFrameHotspotId = -1; + _greenFrameHotspotId = -1; + _blueFrameHotspotId = -1; + _yellowFrameHotspotId = -1; +} + +void Scene407::synchronize(Common::Serializer &s) { + Scene4xx::synchronize(s); + + s.syncAsByte(_frameInRoomFl); + s.syncAsByte(_takingFrameInRoomFl); + + s.syncAsSint16LE(_redFrameHotspotId); + s.syncAsSint16LE(_greenFrameHotspotId); + s.syncAsSint16LE(_blueFrameHotspotId); + s.syncAsSint16LE(_yellowFrameHotspotId); +} + +void Scene407::setup() { + setPlayerSpritesPrefix(); + setAAName(); + + _scene->addActiveVocab(NOUN_RED_FRAME); + _scene->addActiveVocab(NOUN_YELLOW_FRAME); + _scene->addActiveVocab(NOUN_BLUE_FRAME); + _scene->addActiveVocab(NOUN_GREEN_FRAME); +} + +void Scene407::enter() { + _game.initCatacombs(); + + _globals._spriteIndexes[0] = _scene->_sprites.addSprites("*RRD_9"); + _globals._spriteIndexes[1] = _scene->_sprites.addSprites(formAnimName('f', 0)); + _globals._spriteIndexes[2] = _scene->_sprites.addSprites(formAnimName('f', 1)); + _globals._spriteIndexes[3] = _scene->_sprites.addSprites(formAnimName('f', 2)); + _globals._spriteIndexes[4] = _scene->_sprites.addSprites(formAnimName('f', 3)); + + if (_game.exitCatacombs(3) == -1) { + _scene->_hotspots.activateAtPos(NOUN_MORE_CATACOMBS, false, Common::Point(9, 46)); + _scene->_hotspots.activateAtPos(NOUN_MORE_CATACOMBS, false, Common::Point(8, 138)); + _scene->_hotspots.activateAtPos(NOUN_MORE_CATACOMBS, false, Common::Point(12, 149)); + _scene->_hotspots.activateAtPos(NOUN_MORE_CATACOMBS, false, Common::Point(0, 151)); + } + + if (_game.exitCatacombs(1) == -1) { + _scene->_hotspots.activateAtPos(NOUN_MORE_CATACOMBS, false, Common::Point(310, 107)); + _scene->_hotspots.activateAtPos(NOUN_MORE_CATACOMBS, false, Common::Point(308, 175)); + _scene->_hotspots.activateAtPos(NOUN_MORE_CATACOMBS, false, Common::Point(308, 146)); + _scene->_hotspots.activateAtPos(NOUN_MORE_CATACOMBS, false, Common::Point(309, 152)); + } + + if (_scene->_priorSceneId != RETURNING_FROM_LOADING) { + switch (_globals[kCatacombsFrom]) { + case 0: + _game._player._playerPos = Common::Point(197, 14); + _game._player._facing = FACING_WEST; + _game._player.walk(Common::Point(181, 14), FACING_WEST); + break; + + case 1: + _game._player.firstWalk(Common::Point(330, 146), FACING_WEST, Common::Point(298, 146), FACING_WEST, true); + break; + + case 2: + _game._player._playerPos = Common::Point(147, 14); + _game._player._facing = FACING_EAST; + _game._player.walk(Common::Point(165, 14), FACING_EAST); + break; + + case 3: + _game._player.firstWalk(Common::Point(-20, 143), FACING_WEST, Common::Point(20, 143), FACING_WEST, true); + break; + + default: + break; + } + } + + if (_game._objects[OBJ_RED_FRAME]._roomNumber == _globals[kCatacombsRoom] + 600) { + _globals._sequenceIndexes[1] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[1], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[1], 14); + + Common::Point pos = _scene->_sprites[_globals._spriteIndexes[1]]->getFramePos(0); + _redFrameHotspotId = _scene->_dynamicHotspots.add(NOUN_RED_FRAME, VERB_WALK_TO, SYNTAX_SINGULAR, EXT_NONE, Common::Rect(pos.x - 5, pos.y - 5, pos.x + 5, pos.y + 1)); + _scene->_dynamicHotspots.setPosition(_redFrameHotspotId, Common::Point(pos.x + 12, pos.y), FACING_NORTHWEST); + } + + if (_game._objects[OBJ_GREEN_FRAME]._roomNumber == _globals[kCatacombsRoom] + 600) { + _globals._sequenceIndexes[2] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[2], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[2], 14); + + Common::Point pos = _scene->_sprites[_globals._spriteIndexes[1]]->getFramePos(0); + _greenFrameHotspotId = _scene->_dynamicHotspots.add(NOUN_GREEN_FRAME, VERB_WALK_TO, SYNTAX_SINGULAR, EXT_NONE, Common::Rect(pos.x - 5, pos.y - 5, pos.x + 5, pos.y + 1)); + _scene->_dynamicHotspots.setPosition(_greenFrameHotspotId, Common::Point(pos.x + 12, pos.y), FACING_NORTHWEST); + } + + if (_game._objects[OBJ_BLUE_FRAME]._roomNumber == _globals[kCatacombsRoom] + 600) { + _globals._sequenceIndexes[3] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[3], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[3], 14); + + Common::Point pos = _scene->_sprites[_globals._spriteIndexes[1]]->getFramePos(0); + _blueFrameHotspotId = _scene->_dynamicHotspots.add(NOUN_BLUE_FRAME, VERB_WALK_TO, SYNTAX_SINGULAR, EXT_NONE, Common::Rect(pos.x - 5, pos.y - 5, pos.x + 5, pos.y + 1)); + _scene->_dynamicHotspots.setPosition(_blueFrameHotspotId, Common::Point(pos.x + 12, pos.y), FACING_NORTHWEST); + } + + if (_game._objects[OBJ_YELLOW_FRAME]._roomNumber == _globals[kCatacombsRoom] + 600) { + _globals._sequenceIndexes[4] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[4], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[4], 14); + + Common::Point pos = _scene->_sprites[_globals._spriteIndexes[1]]->getFramePos(0); + _yellowFrameHotspotId = _scene->_dynamicHotspots.add(NOUN_YELLOW_FRAME, VERB_WALK_TO, SYNTAX_SINGULAR, EXT_NONE, Common::Rect(pos.x - 5, pos.y - 5, pos.x + 5, pos.y + 1)); + _scene->_dynamicHotspots.setPosition(_yellowFrameHotspotId, Common::Point(pos.x + 12, pos.y), FACING_NORTHWEST); + } + + sceneEntrySound(); +} + +void Scene407::step() { +} + +void Scene407::actions() { + if (_action.isAction(VERB_WALK_TO, NOUN_WALL) && (_game._player._playerPos.y > 30) && (_scene->_customDest.x > 160) && (_scene->_customDest.x < 190)) { + _vm->_dialogs->show(40718); + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_WALK_TO) && (_scene->_customDest.x < 130) && (_game._player._playerPos.y < 30)) { + _vm->_dialogs->show(40718); + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_WALK_TO) && (_scene->_customDest.x > 203) && (_game._player._playerPos.y < 30)) { + _vm->_dialogs->show(40718); + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_WALK_TO, NOUN_FLOOR)) { + if ((_game._player._playerPos.y < 30) && (_scene->_customDest.y > 29)) { + _vm->_dialogs->show(40718); + _action._inProgress = false; + return; + } else if ((_game._player._playerPos.y > 29) && (_scene->_customDest.y < 30)) { + _vm->_dialogs->show(40718); + _action._inProgress = false; + return; + } + } + + if (_action.isAction(VERB_PUT) && _action.isTarget(NOUN_FLOOR)) { + if (_action.isObject(NOUN_RED_FRAME) || _action.isObject(NOUN_BLUE_FRAME) || _action.isObject(NOUN_YELLOW_FRAME) || _action.isObject(NOUN_GREEN_FRAME)) { + if ((_game._player._playerPos.y < 30) && (_scene->_customDest.y < 30)) + _vm->_dialogs->show(40717); + else if ((_game._player._playerPos.y < 30) && (_scene->_customDest.y > 29)) + _vm->_dialogs->show(40718); + else if (_frameInRoomFl) + _vm->_dialogs->show(29); + else { + switch (_game._trigger) { + case (0): + _game._player._stepEnabled = false; + _game._player._visible = false; + _globals._sequenceIndexes[0] = _scene->_sequences.startPingPongCycle(_globals._spriteIndexes[0], true, 5, 2); + _scene->_sequences.setAnimRange(_globals._sequenceIndexes[0], 1, 5); + _scene->_sequences.setSeqPlayer(_globals._sequenceIndexes[0], true); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[0], SEQUENCE_TRIGGER_SPRITE, 5, 1); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[0], SEQUENCE_TRIGGER_EXPIRE, 0, 2); + break; + + case 1: + if (_action.isObject(NOUN_RED_FRAME)) { + _game._objects.setRoom(OBJ_RED_FRAME, NOWHERE); + _game._objects[OBJ_RED_FRAME]._roomNumber = _globals[kCatacombsRoom] + 600; + _globals._sequenceIndexes[1] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[1], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[1], 14); + + Common::Point pos = _scene->_sprites[_globals._spriteIndexes[1]]->getFramePos(0); + _redFrameHotspotId = _scene->_dynamicHotspots.add(NOUN_RED_FRAME, VERB_WALK_TO, SYNTAX_SINGULAR, EXT_NONE, Common::Rect(pos.x - 5, pos.y - 5, pos.x + 5, pos.y + 1)); + _scene->_dynamicHotspots.setPosition(_redFrameHotspotId, Common::Point(pos.x + 12, pos.y), FACING_NORTHWEST); + } + + if (_action.isObject(NOUN_GREEN_FRAME)) { + _game._objects.setRoom(OBJ_GREEN_FRAME, NOWHERE); + _game._objects[OBJ_GREEN_FRAME]._roomNumber = _globals[kCatacombsRoom] + 600; + _globals._sequenceIndexes[2] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[2], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[2], 14); + + Common::Point pos = _scene->_sprites[_globals._spriteIndexes[1]]->getFramePos(0); + _greenFrameHotspotId = _scene->_dynamicHotspots.add(NOUN_GREEN_FRAME, VERB_WALK_TO, SYNTAX_SINGULAR, EXT_NONE, Common::Rect(pos.x - 5, pos.y - 5, pos.x + 5, pos.y + 1)); + _scene->_dynamicHotspots.setPosition(_greenFrameHotspotId, Common::Point(pos.x + 12, pos.y), FACING_NORTHWEST); + } + + if (_action.isObject(NOUN_BLUE_FRAME)) { + _game._objects.setRoom(OBJ_BLUE_FRAME, NOWHERE); + _game._objects[OBJ_BLUE_FRAME]._roomNumber = _globals[kCatacombsRoom] + 600; + _globals._sequenceIndexes[3] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[3], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[3], 14); + + Common::Point pos = _scene->_sprites[_globals._spriteIndexes[1]]->getFramePos(0); + _blueFrameHotspotId = _scene->_dynamicHotspots.add(NOUN_BLUE_FRAME, VERB_WALK_TO, SYNTAX_SINGULAR, EXT_NONE, Common::Rect(pos.x - 5, pos.y - 5, pos.x + 5, pos.y + 1)); + _scene->_dynamicHotspots.setPosition(_blueFrameHotspotId, Common::Point(pos.x + 12, pos.y), FACING_NORTHWEST); + } + + if (_action.isObject(NOUN_YELLOW_FRAME)) { + _game._objects.setRoom(OBJ_YELLOW_FRAME, NOWHERE); + _game._objects[OBJ_YELLOW_FRAME]._roomNumber = _globals[kCatacombsRoom] + 600; + _globals._sequenceIndexes[4] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[4], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[4], 14); + + Common::Point pos = _scene->_sprites[_globals._spriteIndexes[1]]->getFramePos(0); + _yellowFrameHotspotId = _scene->_dynamicHotspots.add(NOUN_YELLOW_FRAME, VERB_WALK_TO, SYNTAX_SINGULAR, EXT_NONE, Common::Rect(pos.x - 5, pos.y - 5, pos.x + 5, pos.y + 1)); + _scene->_dynamicHotspots.setPosition(_yellowFrameHotspotId, Common::Point(pos.x + 12, pos.y), FACING_NORTHWEST); + } + break; + + case 2: + _game.syncTimers(SYNC_PLAYER, 0, SYNC_SEQ, _globals._sequenceIndexes[0]); + _game._player._visible = true; + _game._player._stepEnabled = true; + break; + + default: + break; + } + } + _action._inProgress = false; + return; + } + } + + if (_action.isAction(VERB_TAKE)) { + if (_action.isObject(NOUN_RED_FRAME) || _action.isObject(NOUN_GREEN_FRAME) || _action.isObject(NOUN_BLUE_FRAME) || _action.isObject(NOUN_YELLOW_FRAME)) { + if ((_takingFrameInRoomFl || _game._trigger)) { + if (_game._player._playerPos.y < 30) + _vm->_dialogs->show(40718); + else { + switch (_game._trigger) { + case (0): + _game._player._stepEnabled = false; + _game._player._visible = false; + _globals._sequenceIndexes[0] = _scene->_sequences.startPingPongCycle(_globals._spriteIndexes[0], true, 5, 2); + _scene->_sequences.setAnimRange(_globals._sequenceIndexes[0], 1, 5); + _scene->_sequences.setSeqPlayer(_globals._sequenceIndexes[0], true); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[0], SEQUENCE_TRIGGER_SPRITE, 5, 1); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[0], SEQUENCE_TRIGGER_EXPIRE, 0, 2); + break; + + case 1: + if (_action.isObject(NOUN_RED_FRAME)) { + _scene->deleteSequence(_globals._sequenceIndexes[1]); + _scene->_dynamicHotspots.remove(_redFrameHotspotId); + _game._objects.addToInventory(OBJ_RED_FRAME); + } + + if (_action.isObject(NOUN_GREEN_FRAME)) { + _scene->deleteSequence(_globals._sequenceIndexes[2]); + _scene->_dynamicHotspots.remove(_greenFrameHotspotId); + _game._objects.addToInventory(OBJ_GREEN_FRAME); + } + + if (_action.isObject(NOUN_BLUE_FRAME)) { + _scene->deleteSequence(_globals._sequenceIndexes[3]); + _scene->_dynamicHotspots.remove(_blueFrameHotspotId); + _game._objects.addToInventory(OBJ_BLUE_FRAME); + } + + if (_action.isObject(NOUN_YELLOW_FRAME)) { + _scene->deleteSequence(_globals._sequenceIndexes[4]); + _scene->_dynamicHotspots.remove(_yellowFrameHotspotId); + _game._objects.addToInventory(OBJ_YELLOW_FRAME); + } + + _vm->_sound->command(26); + break; + + case 2: + _game.syncTimers(SYNC_PLAYER, 0, SYNC_SEQ, _globals._sequenceIndexes[0]); + _game._player._visible = true; + _game._player._stepEnabled = true; + break; + + default: + break; + } + } + _action._inProgress = false; + return; + } + } + } + + if (_action.isAction(VERB_WALK_THROUGH, NOUN_ARCHWAY_TO_WEST)) { + if (_game._player._playerPos.y < 30) + _game.moveCatacombs(2); + else + _vm->_dialogs->show(40718); + + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_WALK_THROUGH, NOUN_ARCHWAY_TO_EAST)) { + if (_game._player._playerPos.y < 30) + _game.moveCatacombs(0); + else + _vm->_dialogs->show(40718); + + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_EXIT_TO, NOUN_MORE_CATACOMBS) && (_game._player._playerPos.y < 30)) { + _vm->_dialogs->show(40718); + _action._inProgress = false; + return; + } + + if (_action._lookFlag) { + _vm->_dialogs->show(40710); + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_LOOK) || _action.isAction(VERB_LOOK_AT)) { + if (_action.isObject(NOUN_WALL)) { + _vm->_dialogs->show(40711); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_FLOOR)) { + _vm->_dialogs->show(40712); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_ARCHWAY)) { + _vm->_dialogs->show(40713); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_MORE_CATACOMBS)) { + _vm->_dialogs->show(40714); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_COLUMN)) { + _vm->_dialogs->show(40715); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_RED_FRAME) && !_game._objects.isInInventory(OBJ_RED_FRAME)) { + _vm->_dialogs->showItem(OBJ_RED_FRAME, 802, 0); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_GREEN_FRAME) && !_game._objects.isInInventory(OBJ_GREEN_FRAME)) { + _vm->_dialogs->showItem(OBJ_GREEN_FRAME, 818, 0); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_BLUE_FRAME) && !_game._objects.isInInventory(OBJ_BLUE_FRAME)) { + _vm->_dialogs->showItem(OBJ_BLUE_FRAME, 817, 0); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_YELLOW_FRAME) && !_game._objects.isInInventory(OBJ_YELLOW_FRAME)) { + _vm->_dialogs->showItem(OBJ_YELLOW_FRAME, 804, 0); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_LAKE)) { + _vm->_dialogs->show(40716); + _action._inProgress = false; + } + } +} + +void Scene407::preActions() { + if (_action.isAction(VERB_EXIT_TO, NOUN_MORE_CATACOMBS)) { + if (_game._player._playerPos.y > 30) { + if (_scene->_customDest.x < 100) + _game.moveCatacombs(3); + else + _game.moveCatacombs(1); + } else + _game._player._needToWalk = false; + } + + if (_action.isAction(VERB_WALK_THROUGH) && (_game._player._playerPos.y > 30)) + _game._player._needToWalk = false; + + _frameInRoomFl = false; + _takingFrameInRoomFl = false; + + if (_game._objects[OBJ_RED_FRAME]._roomNumber == _globals[kCatacombsRoom] + 600) { + _frameInRoomFl = true; + if (_action.isAction(VERB_TAKE, NOUN_RED_FRAME)) + _takingFrameInRoomFl = true; + } + + if (_game._objects[OBJ_YELLOW_FRAME]._roomNumber == _globals[kCatacombsRoom] + 600) { + _frameInRoomFl = true; + if (_action.isAction(VERB_TAKE, NOUN_YELLOW_FRAME)) + _takingFrameInRoomFl = true; + } + + if (_game._objects[OBJ_BLUE_FRAME]._roomNumber == _globals[kCatacombsRoom] + 600) { + _frameInRoomFl = true; + if (_action.isAction(VERB_TAKE, NOUN_BLUE_FRAME)) + _takingFrameInRoomFl = true; + } + + if (_game._objects[OBJ_GREEN_FRAME]._roomNumber == _globals[kCatacombsRoom] + 600) { + _frameInRoomFl = true; + if (_action.isAction(VERB_TAKE, NOUN_GREEN_FRAME)) + _takingFrameInRoomFl = true; + } + + if (_action.isAction(VERB_PUT) && _action.isTarget(NOUN_FLOOR) + && (_action.isObject(NOUN_RED_FRAME) || _action.isObject(NOUN_BLUE_FRAME) || _action.isObject(NOUN_YELLOW_FRAME) || _action.isObject(NOUN_GREEN_FRAME))) { + if ((_frameInRoomFl) || (_game._player._playerPos.y < 30) || (_scene->_customDest.y < 30)) + _game._player._needToWalk = false; + else { + Common::Point pos = _scene->_sprites[_globals._spriteIndexes[1]]->getFramePos(0); + _game._player.walk(Common::Point(pos.x + 12, pos.y), FACING_NORTHWEST); + } + } + + if (_action.isAction(VERB_TAKE) + && (_action.isObject(NOUN_RED_FRAME) || _action.isObject(NOUN_GREEN_FRAME) || _action.isObject(NOUN_BLUE_FRAME) || _action.isObject(NOUN_YELLOW_FRAME))) { + if (_takingFrameInRoomFl && (_game._player._playerPos.y < 30)) + _game._player._needToWalk = false; + } + + if (_action.isAction(VERB_WALK_ACROSS, NOUN_FLOOR) && (_game._player._playerPos.y < 30) && (_scene->_customDest.y > 29)) + _game._player._needToWalk = false; + + if (_action.isAction(VERB_WALK_TO, NOUN_LAKE) && (_game._player._playerPos.y < 30)) + _game._player.walk(Common::Point(172, 18), FACING_SOUTH); + + if (_action.isAction(VERB_WALK_TO) && (_scene->_customDest.x < 130) && (_game._player._playerPos.y < 30)) + _game._player._needToWalk = false; + + if (_action.isAction(VERB_WALK_TO) && (_scene->_customDest.x > 203) && (_game._player._playerPos.y < 30)) + _game._player._needToWalk = false; + + if (_action.isAction(VERB_WALK_TO, NOUN_WALL) && (_game._player._playerPos.y > 30) && (_scene->_customDest.x > 160) && (_scene->_customDest.x < 190)) + _game._player._needToWalk = false; +} + +/*------------------------------------------------------------------------*/ + +Scene408::Scene408(MADSEngine *vm) : Scene4xx(vm) { + _frameInRoomFl = false; + _takingFrameInRoomFl = false; + + _redFrameHotspotId = -1; + _greenFrameHotspotId = -1; + _blueFrameHotspotId = -1; + _yellowFrameHotspotId = -1; +} + +void Scene408::synchronize(Common::Serializer &s) { + Scene4xx::synchronize(s); + + s.syncAsByte(_frameInRoomFl); + s.syncAsByte(_takingFrameInRoomFl); + + s.syncAsSint16LE(_redFrameHotspotId); + s.syncAsSint16LE(_greenFrameHotspotId); + s.syncAsSint16LE(_blueFrameHotspotId); + s.syncAsSint16LE(_yellowFrameHotspotId); +} + +void Scene408::setup() { + setPlayerSpritesPrefix(); + setAAName(); + + if ((_globals[kCatacombsMisc] & MAZE_EVENT_WEB) && (!_globals[kCobwebIsCut])) + _scene->_variant = 1; + + _scene->addActiveVocab(NOUN_RED_FRAME); + _scene->addActiveVocab(NOUN_YELLOW_FRAME); + _scene->addActiveVocab(NOUN_BLUE_FRAME); + _scene->addActiveVocab(NOUN_GREEN_FRAME); +} + +void Scene408::enter() { + _game.initCatacombs(); + _scene->_hotspots.activate(NOUN_COBWEB, false); + + _globals._spriteIndexes[0] = _scene->_sprites.addSprites(formAnimName('c', 0)); + _globals._spriteIndexes[1] = _scene->_sprites.addSprites("*RRD_9"); + _globals._spriteIndexes[2] = _scene->_sprites.addSprites(formAnimName('f', 0)); + _globals._spriteIndexes[3] = _scene->_sprites.addSprites(formAnimName('f', 1)); + _globals._spriteIndexes[4] = _scene->_sprites.addSprites(formAnimName('f', 2)); + _globals._spriteIndexes[5] = _scene->_sprites.addSprites(formAnimName('f', 3)); + _globals._spriteIndexes[6] = _scene->_sprites.addSprites(formAnimName('c', 1)); + _globals._spriteIndexes[7] = _scene->_sprites.addSprites(formAnimName('c', 2)); + + if (_game.exitCatacombs(0) == -1) { + _scene->drawToBackground(_globals._spriteIndexes[0], 1, Common::Point(-32000, -32000), 0, 100); + _scene->_hotspots.activate(NOUN_ARCHWAY_TO_NORTH, false); + _scene->_hotspots.activateAtPos(NOUN_FLOOR, false, Common::Point(147, 121)); + _scene->_hotspots.activateAtPos(NOUN_FLOOR, false, Common::Point(153, 121)); + _scene->_hotspots.activateAtPos(NOUN_FLOOR, false, Common::Point(154, 115)); + _scene->_hotspots.activateAtPos(NOUN_FLOOR, false, Common::Point(161, 101)); + _scene->_hotspots.activateAtPos(NOUN_FLOOR, false, Common::Point(162, 106)); + _scene->_hotspots.activateAtPos(NOUN_FLOOR, false, Common::Point(187, 107)); + _scene->_hotspots.activateAtPos(NOUN_FLOOR, false, Common::Point(185, 101)); + _scene->_hotspots.activateAtPos(NOUN_FLOOR, false, Common::Point(192, 119)); + _scene->_hotspots.activateAtPos(NOUN_WALL, false, Common::Point(147, 76)); + _scene->_hotspots.activateAtPos(NOUN_WALL, false, Common::Point(159, 108)); + _scene->_hotspots.activateAtPos(NOUN_WALL, false, Common::Point(185, 93)); + _scene->_hotspots.activateAtPos(NOUN_WALL, false, Common::Point(199, 91)); + _scene->changeVariant(1); + } else + _scene->_hotspots.activate(NOUN_GATE, false); + + if (_scene->_priorSceneId != RETURNING_FROM_LOADING) { + switch (_globals[kCatacombsFrom]) { + case 0: + _game._player._playerPos = Common::Point(174, 100); + _game._player._facing = FACING_SOUTH; + _game._player.walk(Common::Point(174, 106), FACING_SOUTH); + break; + + case 2: + _game._player._playerPos = Common::Point(175, 145); + _game._player._facing = FACING_NORTH; + break; + + default: + break; + } + } + + if (_globals[kCatacombsMisc] & MAZE_EVENT_WEB) { + _globals._spriteIndexes[8] = _scene->_sprites.addSprites(formAnimName('x', -1)); + if (!_globals[kCobwebIsCut]) { + _globals._spriteIndexes[6] = _scene->_sprites.addSprites(formAnimName('c', 1)); + _globals._sequenceIndexes[6] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[6], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[6], 10); + _scene->_hotspots.activate(NOUN_COBWEB, true); + } else { + _globals._sequenceIndexes[8] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[8], false, -2); + _scene->_sequences.setDepth(_globals._sequenceIndexes[8], 10); + + int idx = _scene->_dynamicHotspots.add(NOUN_COBWEB, VERB_WALK_TO, SYNTAX_SINGULAR, EXT_NONE, Common::Rect(199, 112, 199 + 6, 112 + 12)); + _scene->_dynamicHotspots.setPosition(idx, Common::Point(194, 125), FACING_NORTHEAST); + idx = _scene->_dynamicHotspots.add(NOUN_COBWEB, VERB_WALK_TO, SYNTAX_SINGULAR, EXT_NONE, Common::Rect(202, 81, 202 + 5, 81 + 31)); + _scene->_dynamicHotspots.setPosition(idx, Common::Point(194, 125), FACING_NORTHEAST); + + idx = _scene->_dynamicHotspots.add(NOUN_COBWEB, VERB_WALK_TO, SYNTAX_SINGULAR, EXT_NONE, Common::Rect(138, 74, 138 + 7, 74 + 33)); + _scene->_dynamicHotspots.setPosition(idx, Common::Point(154, 124), FACING_NORTHWEST); + idx = _scene->_dynamicHotspots.add(NOUN_COBWEB, VERB_WALK_TO, SYNTAX_SINGULAR, EXT_NONE, Common::Rect(143, 107, 143 + 6, 107 + 15)); + _scene->_dynamicHotspots.setPosition(idx, Common::Point(154, 124), FACING_NORTHWEST); + } + } + + if (_globals[kCatacombsMisc] & MAZE_EVENT_BRICK) { + _globals._spriteIndexes[7] = _scene->_sprites.addSprites(formAnimName('c', 2)); + _scene->drawToBackground(_globals._spriteIndexes[7], 1, Common::Point(-32000, -32000), 0, 100); + _scene->_hotspots.activate(NOUN_EXPOSED_BRICK, false); + } + + if (_game._objects[OBJ_RED_FRAME]._roomNumber == _globals[kCatacombsRoom] + 600) { + _globals._sequenceIndexes[2] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[2], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[2], 14); + + Common::Point pos = _scene->_sprites[_globals._spriteIndexes[9]]->getFramePos(0); + _redFrameHotspotId = _scene->_dynamicHotspots.add(NOUN_RED_FRAME, VERB_WALK_TO, SYNTAX_SINGULAR, EXT_NONE, Common::Rect(pos.x - 5, pos.y - 5, pos.x + 5, pos.y + 1)); + _scene->_dynamicHotspots.setPosition(_redFrameHotspotId, Common::Point(pos.x + 12, pos.y), FACING_NORTHWEST); + } + + if (_game._objects[OBJ_GREEN_FRAME]._roomNumber == _globals[kCatacombsRoom] + 600) { + _globals._sequenceIndexes[3] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[3], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[3], 14); + + Common::Point pos = _scene->_sprites[_globals._spriteIndexes[9]]->getFramePos(0); + _greenFrameHotspotId = _scene->_dynamicHotspots.add(NOUN_GREEN_FRAME, VERB_WALK_TO, SYNTAX_SINGULAR, EXT_NONE, Common::Rect(pos.x - 5, pos.y - 5, pos.x + 5, pos.y + 1)); + _scene->_dynamicHotspots.setPosition(_greenFrameHotspotId, Common::Point(pos.x + 12, pos.y), FACING_NORTHWEST); + } + + if (_game._objects[OBJ_BLUE_FRAME]._roomNumber == _globals[kCatacombsRoom] + 600) { + _globals._sequenceIndexes[4] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[4], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[4], 14); + + Common::Point pos = _scene->_sprites[_globals._spriteIndexes[9]]->getFramePos(0); + _blueFrameHotspotId = _scene->_dynamicHotspots.add(NOUN_BLUE_FRAME, VERB_WALK_TO, SYNTAX_SINGULAR, EXT_NONE, Common::Rect(pos.x - 5, pos.y - 5, pos.x + 5, pos.y + 1)); + _scene->_dynamicHotspots.setPosition(_blueFrameHotspotId, Common::Point(pos.x + 12, pos.y), FACING_NORTHWEST); + } + + if (_game._objects[OBJ_YELLOW_FRAME]._roomNumber == _globals[kCatacombsRoom] + 600) { + _globals._sequenceIndexes[5] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[5], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[5], 14); + + Common::Point pos = _scene->_sprites[_globals._spriteIndexes[9]]->getFramePos(0); + _yellowFrameHotspotId = _scene->_dynamicHotspots.add(NOUN_YELLOW_FRAME, VERB_WALK_TO, SYNTAX_SINGULAR, EXT_NONE, Common::Rect(pos.x - 5, pos.y - 5, pos.x + 5, pos.y + 1)); + _scene->_dynamicHotspots.setPosition(_yellowFrameHotspotId, Common::Point(pos.x + 12, pos.y), FACING_NORTHWEST); + } + + if ((_game._difficulty == DIFFICULTY_HARD) && (_globals[kCatacombsRoom] == 52)) + _scene->_sequences.addTimer(120, 60); + + sceneEntrySound(); +} + +void Scene408::step() { + if (_game._trigger == 60) + _vm->_dialogs->show(31); +} + +void Scene408::actions() { + if (_action.isAction(VERB_PUT) && _action.isTarget(NOUN_FLOOR) + && (_action.isObject(NOUN_RED_FRAME) || _action.isObject(NOUN_BLUE_FRAME) || _action.isObject(NOUN_YELLOW_FRAME) || _action.isObject(NOUN_GREEN_FRAME))) { + if (_frameInRoomFl) + _vm->_dialogs->show(29); + else { + switch (_game._trigger) { + case (0): + _game._player._stepEnabled = false; + _game._player._visible = false; + _globals._sequenceIndexes[1] = _scene->_sequences.startPingPongCycle(_globals._spriteIndexes[1], true, 5, 2); + _scene->_sequences.setAnimRange(_globals._sequenceIndexes[1], 1, 5); + _scene->_sequences.setSeqPlayer(_globals._sequenceIndexes[1], true); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[1], SEQUENCE_TRIGGER_SPRITE, 5, 1); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[1], SEQUENCE_TRIGGER_EXPIRE, 0, 2); + break; + + case 1: + if (_action.isObject(NOUN_RED_FRAME)) { + _game._objects.setRoom(OBJ_RED_FRAME, NOWHERE); + _game._objects[OBJ_RED_FRAME]._roomNumber = _globals[kCatacombsRoom] + 600; + _globals._sequenceIndexes[2] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[2], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[2], 14); + + Common::Point pos = _scene->_sprites[_globals._spriteIndexes[2]]->getFramePos(0); + _redFrameHotspotId = _scene->_dynamicHotspots.add(NOUN_RED_FRAME, VERB_WALK_TO, SYNTAX_SINGULAR, EXT_NONE, Common::Rect(pos.x - 5, pos.y - 5, pos.x + 5, pos.y + 1)); + _scene->_dynamicHotspots.setPosition(_redFrameHotspotId, Common::Point(pos.x + 12, pos.y), FACING_NORTHWEST); + } + + if (_action.isObject(NOUN_GREEN_FRAME)) { + _game._objects.setRoom(OBJ_GREEN_FRAME, NOWHERE); + _game._objects[OBJ_GREEN_FRAME]._roomNumber = _globals[kCatacombsRoom] + 600; + _globals._sequenceIndexes[3] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[3], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[3], 14); + + Common::Point pos = _scene->_sprites[_globals._spriteIndexes[9]]->getFramePos(0); + _greenFrameHotspotId = _scene->_dynamicHotspots.add(NOUN_GREEN_FRAME, VERB_WALK_TO, SYNTAX_SINGULAR, EXT_NONE, Common::Rect(pos.x - 5, pos.y - 5, pos.x + 5, pos.y + 1)); + _scene->_dynamicHotspots.setPosition(_greenFrameHotspotId, Common::Point(pos.x + 12, pos.y), FACING_NORTHWEST); + } + + if (_action.isObject(NOUN_BLUE_FRAME)) { + _game._objects.setRoom(OBJ_BLUE_FRAME, NOWHERE); + _game._objects[OBJ_BLUE_FRAME]._roomNumber = _globals[kCatacombsRoom] + 600; + _globals._sequenceIndexes[4] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[4], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[4], 14); + + Common::Point pos = _scene->_sprites[_globals._spriteIndexes[9]]->getFramePos(0); + _blueFrameHotspotId = _scene->_dynamicHotspots.add(NOUN_BLUE_FRAME, VERB_WALK_TO, SYNTAX_SINGULAR, EXT_NONE, Common::Rect(pos.x - 5, pos.y - 5, pos.x + 5, pos.y + 1)); + _scene->_dynamicHotspots.setPosition(_blueFrameHotspotId, Common::Point(pos.x + 12, pos.y), FACING_NORTHWEST); + } + + if (_action.isObject(NOUN_YELLOW_FRAME)) { + _game._objects.setRoom(OBJ_YELLOW_FRAME, NOWHERE); + _game._objects[OBJ_YELLOW_FRAME]._roomNumber = _globals[kCatacombsRoom] + 600; + _globals._sequenceIndexes[5] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[5], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[5], 14); + + Common::Point pos = _scene->_sprites[_globals._spriteIndexes[9]]->getFramePos(0); + _yellowFrameHotspotId = _scene->_dynamicHotspots.add(NOUN_YELLOW_FRAME, VERB_WALK_TO, SYNTAX_SINGULAR, EXT_NONE, Common::Rect(pos.x - 5, pos.y - 5, pos.x + 5, pos.y + 1)); + _scene->_dynamicHotspots.setPosition(_yellowFrameHotspotId, Common::Point(pos.x + 12, pos.y), FACING_NORTHWEST); + } + break; + + case 2: + _game.syncTimers(SYNC_PLAYER, 0, SYNC_SEQ, _globals._sequenceIndexes[1]); + _game._player._visible = true; + _game._player._stepEnabled = true; + break; + + default: + break; + } + } + _action._inProgress = false; + return; + } + + + if (_action.isAction(VERB_TAKE) + && (_action.isObject(NOUN_RED_FRAME) || _action.isObject(NOUN_GREEN_FRAME) || _action.isObject(NOUN_BLUE_FRAME) || _action.isObject(NOUN_YELLOW_FRAME))) { + if ((_takingFrameInRoomFl || _game._trigger)) { + switch (_game._trigger) { + case (0): + _game._player._stepEnabled = false; + _game._player._visible = false; + _globals._sequenceIndexes[1] = _scene->_sequences.startPingPongCycle(_globals._spriteIndexes[1], true, 5, 2); + _scene->_sequences.setAnimRange(_globals._sequenceIndexes[1], 1, 5); + _scene->_sequences.setSeqPlayer(_globals._sequenceIndexes[1], true); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[1], SEQUENCE_TRIGGER_SPRITE, 5, 1); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[1], SEQUENCE_TRIGGER_EXPIRE, 0, 2); + break; + + case 1: + if (_action.isObject(NOUN_RED_FRAME)) { + _scene->deleteSequence(_globals._sequenceIndexes[2]); + _scene->_dynamicHotspots.remove(_redFrameHotspotId); + _game._objects.addToInventory(OBJ_RED_FRAME); + } + + if (_action.isObject(NOUN_GREEN_FRAME)) { + _scene->deleteSequence(_globals._sequenceIndexes[3]); + _scene->_dynamicHotspots.remove(_greenFrameHotspotId); + _game._objects.addToInventory(OBJ_GREEN_FRAME); + } + + if (_action.isObject(NOUN_BLUE_FRAME)) { + _scene->deleteSequence(_globals._sequenceIndexes[4]); + _scene->_dynamicHotspots.remove(_blueFrameHotspotId); + _game._objects.addToInventory(OBJ_BLUE_FRAME); + } + + if (_action.isObject(NOUN_YELLOW_FRAME)) { + _scene->deleteSequence(_globals._sequenceIndexes[5]); + _scene->_dynamicHotspots.remove(_yellowFrameHotspotId); + _game._objects.addToInventory(OBJ_YELLOW_FRAME); + } + + _vm->_sound->command(26); + break; + + case 2: + _game.syncTimers(SYNC_PLAYER, 0, SYNC_SEQ, _globals._sequenceIndexes[1]); + _game._player._visible = true; + _game._player._stepEnabled = true; + break; + + default: + break; + } + _action._inProgress = false; + return; + } + } + + if (_action.isAction(VERB_WALK_THROUGH, NOUN_ARCHWAY_TO_NORTH)) { + _game.moveCatacombs(0); + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_EXIT_TO, NOUN_MORE_CATACOMBS)) { + _game.moveCatacombs(2); + _action._inProgress = false; + return; + } + + if (_action._lookFlag) { + _vm->_dialogs->show(40810); + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_LOOK) || _action.isAction(VERB_LOOK_AT)) { + if (_action.isObject(NOUN_WALL)) { + _vm->_dialogs->show(40811); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_FLOOR)) { + _vm->_dialogs->show(40812); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_ARCHWAY)) { + _vm->_dialogs->show(40813); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_EXPOSED_BRICK)) { + _vm->_dialogs->show(40814); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_MORE_CATACOMBS)) { + _vm->_dialogs->show(40815); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_CEILING)) { + _vm->_dialogs->show(40816); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_RED_FRAME) && !_game._objects.isInInventory(OBJ_RED_FRAME)) { + _vm->_dialogs->showItem(OBJ_RED_FRAME, 802, 0); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_GREEN_FRAME) && !_game._objects.isInInventory(OBJ_GREEN_FRAME)) { + _vm->_dialogs->showItem(OBJ_GREEN_FRAME, 819, 0); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_BLUE_FRAME) && !_game._objects.isInInventory(OBJ_BLUE_FRAME)) { + _vm->_dialogs->showItem(OBJ_BLUE_FRAME, 817, 0); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_YELLOW_FRAME) && !_game._objects.isInInventory(OBJ_YELLOW_FRAME)) { + _vm->_dialogs->showItem(OBJ_YELLOW_FRAME, 804, 0); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_GATE)) { + _vm->_dialogs->show(40817); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_COBWEB)) { + if (_globals[kCobwebIsCut]) + _vm->_dialogs->show(40820); + else + _vm->_dialogs->show(40819); + + _action._inProgress = false; + return; + } + } + + if ((_action.isAction(VERB_ATTACK, NOUN_COBWEB) && !_globals[kCobwebIsCut])) { + _globals._animationIndexes[0] = _scene->loadAnimation(formAnimName('W', 1), 70); + _game._player._visible = false; + _game._player._stepEnabled = false; + _globals[kCobwebIsCut] = true; + _scene->deleteSequence(_globals._sequenceIndexes[6]); + _action._inProgress = false; + return; + } + + if (_game._trigger == 70) { + _globals._sequenceIndexes[8] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[8], false, -2); + _scene->_sequences.setDepth(_globals._sequenceIndexes[8], 14); + _scene->changeVariant(0); + _scene->_hotspots.activate(NOUN_COBWEB, false); + _game._player._visible = true; + _game._player._stepEnabled = true; + + int idx = _scene->_dynamicHotspots.add(NOUN_COBWEB, VERB_WALK_TO, SYNTAX_SINGULAR, EXT_NONE, Common::Rect(199, 112, 199 + 6, 112 + 12)); + _scene->_dynamicHotspots.setPosition(idx, Common::Point(194, 125), FACING_NORTHEAST); + idx = _scene->_dynamicHotspots.add(NOUN_COBWEB, VERB_WALK_TO, SYNTAX_SINGULAR, EXT_NONE, Common::Rect(202, 81, 202 + 5, 81 + 31)); + _scene->_dynamicHotspots.setPosition(idx, Common::Point(194, 125), FACING_NORTHEAST); + + idx = _scene->_dynamicHotspots.add(NOUN_COBWEB, VERB_WALK_TO, SYNTAX_SINGULAR, EXT_NONE, Common::Rect(138, 74, 138 + 7, 74 + 33)); + _scene->_dynamicHotspots.setPosition(idx, Common::Point(154, 124), FACING_NORTHWEST); + idx = _scene->_dynamicHotspots.add(NOUN_COBWEB, VERB_WALK_TO, SYNTAX_SINGULAR, EXT_NONE, Common::Rect(143, 107, 143 + 6, 107 + 15)); + _scene->_dynamicHotspots.setPosition(idx, Common::Point(154, 124), FACING_NORTHWEST); + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_OPEN, NOUN_GATE)) { + _vm->_dialogs->show(40818); + _action._inProgress = false; + } +} + +void Scene408::preActions() { + _frameInRoomFl = false; + _takingFrameInRoomFl = false; + + if (_game._objects[OBJ_RED_FRAME]._roomNumber == _globals[kCatacombsRoom] + 600) { + _frameInRoomFl = true; + if (_action.isAction(VERB_TAKE, NOUN_RED_FRAME)) + _takingFrameInRoomFl = true; + } + + if (_game._objects[OBJ_YELLOW_FRAME]._roomNumber == _globals[kCatacombsRoom] + 600) { + _frameInRoomFl = true; + if (_action.isAction(VERB_TAKE, NOUN_YELLOW_FRAME)) + _takingFrameInRoomFl = true; + } + + if (_game._objects[OBJ_BLUE_FRAME]._roomNumber == _globals[kCatacombsRoom] + 600) { + _frameInRoomFl = true; + if (_action.isAction(VERB_TAKE, NOUN_BLUE_FRAME)) + _takingFrameInRoomFl = true; + } + + if (_game._objects[OBJ_GREEN_FRAME]._roomNumber == _globals[kCatacombsRoom] + 600) { + _frameInRoomFl = true; + if (_action.isAction(VERB_TAKE, NOUN_GREEN_FRAME)) + _takingFrameInRoomFl = true; + } + + if (_action.isAction(VERB_PUT) && _action.isTarget(NOUN_FLOOR) + && (_action.isObject(NOUN_RED_FRAME) || _action.isObject(NOUN_BLUE_FRAME) || _action.isObject(NOUN_YELLOW_FRAME) || _action.isObject(NOUN_GREEN_FRAME))) { + if (_frameInRoomFl) + _game._player._needToWalk = false; + else { + Common::Point pos = _scene->_sprites[_globals._spriteIndexes[9]]->getFramePos(0); + _game._player.walk(Common::Point(pos.x + 12, pos.y), FACING_NORTHWEST); + } + } +} + +/*------------------------------------------------------------------------*/ + +Scene409::Scene409(MADSEngine *vm) : Scene4xx(vm) { + _frameInRoomFl = false; + _takingFrameInRoomFl = false; + + _redFrameHotspotId = -1; + _greenFrameHotspotId = -1; + _blueFrameHotspotId = -1; + _yellowFrameHotspotId = -1; +} + +void Scene409::synchronize(Common::Serializer &s) { + Scene4xx::synchronize(s); + + s.syncAsByte(_frameInRoomFl); + s.syncAsByte(_takingFrameInRoomFl); + + s.syncAsSint16LE(_redFrameHotspotId); + s.syncAsSint16LE(_greenFrameHotspotId); + s.syncAsSint16LE(_blueFrameHotspotId); + s.syncAsSint16LE(_yellowFrameHotspotId); +} + +void Scene409::setup() { + setPlayerSpritesPrefix(); + setAAName(); + + _scene->addActiveVocab(NOUN_RED_FRAME); + _scene->addActiveVocab(NOUN_YELLOW_FRAME); + _scene->addActiveVocab(NOUN_BLUE_FRAME); + _scene->addActiveVocab(NOUN_GREEN_FRAME); +} + +void Scene409::enter() { + _game.initCatacombs(); + + _scene->loadSpeech(3); + _scene->_hotspots.activate(NOUN_SWORD, false); + + _globals._spriteIndexes[8] = _scene->_sprites.addSprites("*RDR_9"); + _globals._spriteIndexes[0] = _scene->_sprites.addSprites("*RRD_9"); + _globals._spriteIndexes[2] = _scene->_sprites.addSprites(formAnimName('f', 0)); + _globals._spriteIndexes[3] = _scene->_sprites.addSprites(formAnimName('f', 1)); + _globals._spriteIndexes[4] = _scene->_sprites.addSprites(formAnimName('f', 2)); + _globals._spriteIndexes[5] = _scene->_sprites.addSprites(formAnimName('f', 3)); + _globals._spriteIndexes[6] = _scene->_sprites.addSprites(formAnimName('x', 0)); + _globals._spriteIndexes[7] = _scene->_sprites.addSprites(formAnimName('a', 0)); + + if (_game._objects.isInRoom(OBJ_SWORD)) { + _globals._spriteIndexes[1] = _scene->_sprites.addSprites(formAnimName('p', 0)); + _globals._spriteIndexes[0] = _scene->_sprites.addSprites("*RRD_9"); + _globals._sequenceIndexes[1] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[1], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[1], 14); + _scene->_hotspots.activate(NOUN_SWORD, true); + } + + if (!_globals[kDoorIn409IsOpen]) { + _globals._sequenceIndexes[6] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[6], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[6], 14); + _scene->_hotspots.activate(NOUN_ARCHWAY_TO_NORTH, false); + } else + _scene->_hotspots.activate(NOUN_DOOR, false); + + if (_scene->_priorSceneId == 410) { + _game._player._facing = FACING_NORTH; + _game._player._playerPos = Common::Point(229, 106); + + if (_globals[kFlickedLever1] && _globals[kFlickedLever2] && _globals[kFlickedLever3] && _globals[kFlickedLever4]) { + if ((_globals[kFlickedLever1] == 5) && (_globals[kFlickedLever2] == 18) && (_globals[kFlickedLever3] == 9) && (_globals[kFlickedLever4] == 11)) { + if (!_globals[kDoorIn409IsOpen]) { + _globals[kPlayerScore] += 5; + _vm->_sound->command(24); + _scene->deleteSequence(_globals._sequenceIndexes[6]); + _game._player._stepEnabled = false; + _globals._sequenceIndexes[6] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[6], false, 7, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[6], 14); + _scene->_sequences.setAnimRange(_globals._sequenceIndexes[6], -1, -2); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[6], SEQUENCE_TRIGGER_EXPIRE, 0, 65); + } + } else { + _globals[kFlickedLever1] = 0; + _globals[kFlickedLever2] = 0; + _globals[kFlickedLever3] = 0; + _globals[kFlickedLever4] = 0; + _game._player._stepEnabled = false; + _globals._sequenceIndexes[7] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[7], false, 9, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[7], 1); + _scene->_sequences.setAnimRange(_globals._sequenceIndexes[7], -1, -2); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[7], SEQUENCE_TRIGGER_SPRITE, 15, 60); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[7], SEQUENCE_TRIGGER_EXPIRE, 0, 61); + _vm->_sound->command(68); + } + } else { + _globals[kFlickedLever1] = 0; + _globals[kFlickedLever2] = 0; + _globals[kFlickedLever3] = 0; + _globals[kFlickedLever4] = 0; + } + } else if (_scene->_priorSceneId != RETURNING_FROM_LOADING) { + switch (_globals[kCatacombsFrom]) { + case 0: + _game._player._playerPos = Common::Point(195, 92); + _game._player._facing = FACING_SOUTH; + _game._player.walk(Common::Point(195, 107), FACING_SOUTH); + break; + + case 2: + _game._player._playerPos = Common::Point(184, 45); + _game._player._facing = FACING_NORTH; + break; + + default: + break; + } + } + + if (_game._objects[OBJ_RED_FRAME]._roomNumber == _globals[kCatacombsRoom] + 600) { + _globals._sequenceIndexes[2] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[2], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[2], 14); + + Common::Point pos = _scene->_sprites[_globals._spriteIndexes[2]]->getFramePos(0); + _redFrameHotspotId = _scene->_dynamicHotspots.add(NOUN_RED_FRAME, VERB_WALK_TO, SYNTAX_SINGULAR, EXT_NONE, Common::Rect(pos.x - 5, pos.y - 5, pos.x + 5, pos.y + 1)); + _scene->_dynamicHotspots.setPosition(_redFrameHotspotId, Common::Point(pos.x + 12, pos.y), FACING_NORTHWEST); + } + + if (_game._objects[OBJ_GREEN_FRAME]._roomNumber == _globals[kCatacombsRoom] + 600) { + _globals._sequenceIndexes[3] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[3], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[3], 14); + + Common::Point pos = _scene->_sprites[_globals._spriteIndexes[2]]->getFramePos(0); + _greenFrameHotspotId = _scene->_dynamicHotspots.add(NOUN_GREEN_FRAME, VERB_WALK_TO, SYNTAX_SINGULAR, EXT_NONE, Common::Rect(pos.x - 5, pos.y - 5, pos.x + 5, pos.y + 1)); + _scene->_dynamicHotspots.setPosition(_greenFrameHotspotId, Common::Point(pos.x + 12, pos.y), FACING_NORTHWEST); + } + + if (_game._objects[OBJ_BLUE_FRAME]._roomNumber == _globals[kCatacombsRoom] + 600) { + _globals._sequenceIndexes[4] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[4], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[4], 14); + + Common::Point pos = _scene->_sprites[_globals._spriteIndexes[2]]->getFramePos(0); + _blueFrameHotspotId = _scene->_dynamicHotspots.add(NOUN_BLUE_FRAME, VERB_WALK_TO, SYNTAX_SINGULAR, EXT_NONE, Common::Rect(pos.x - 5, pos.y - 5, pos.x + 5, pos.y + 1)); + _scene->_dynamicHotspots.setPosition(_blueFrameHotspotId, Common::Point(pos.x + 12, pos.y), FACING_NORTHWEST); + } + + if (_game._objects[OBJ_YELLOW_FRAME]._roomNumber == _globals[kCatacombsRoom] + 600) { + _globals._sequenceIndexes[5] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[5], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[5], 14); + + Common::Point pos = _scene->_sprites[_globals._spriteIndexes[2]]->getFramePos(0); + _yellowFrameHotspotId = _scene->_dynamicHotspots.add(NOUN_YELLOW_FRAME, VERB_WALK_TO, SYNTAX_SINGULAR, EXT_NONE, Common::Rect(pos.x - 5, pos.y - 5, pos.x + 5, pos.y + 1)); + _scene->_dynamicHotspots.setPosition(_yellowFrameHotspotId, Common::Point(pos.x + 12, pos.y), FACING_NORTHWEST); + } + + sceneEntrySound(); +} + +void Scene409::step() { + if (_game._trigger == 60) { + _game._player._visible = false; + _game.syncTimers(SYNC_PLAYER, 0, SYNC_SEQ, _globals._sequenceIndexes[7]); + _scene->playSpeech(3); + } + + if (_game._trigger == 61) { + _globals._sequenceIndexes[7] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[7], false, -2); + _scene->_sequences.setDepth(_globals._sequenceIndexes[7], 1); + _scene->_sequences.addTimer(60, 62); + _vm->_sound->command(27); + } + + if (_game._trigger == 62) + _scene->_reloadSceneFlag = true; + + if (_game._trigger == 65) { + _game._player._stepEnabled = true; + _globals[kDoorIn409IsOpen] = true; + _scene->_hotspots.activate(NOUN_DOOR, false); + _scene->_hotspots.activate(NOUN_ARCHWAY_TO_NORTH, true); + } +} + +void Scene409::actions() { + if (_action.isAction(VERB_WALK_THROUGH, NOUN_DOOR) || _action.isAction(VERB_OPEN, NOUN_DOOR)) { + switch (_game._trigger) { + case (0): + _game._player._stepEnabled = false; + _game._player._visible = false; + _globals._sequenceIndexes[8] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[8], false, 5, 1); + _scene->_sequences.setAnimRange(_globals._sequenceIndexes[8], 1, 4); + _scene->_sequences.setSeqPlayer(_globals._sequenceIndexes[8], true); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[8], SEQUENCE_TRIGGER_EXPIRE, 0, 1); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[8], SEQUENCE_TRIGGER_SPRITE, 4, 4); + _action._inProgress = false; + return; + + case 1: { + int syncIdx = _globals._sequenceIndexes[8]; + _globals._sequenceIndexes[8] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[8], false, 4); + _game.syncTimers(SYNC_SEQ, _globals._sequenceIndexes[8], SYNC_SEQ, syncIdx); + _scene->_sequences.setSeqPlayer(_globals._sequenceIndexes[8], false); + _scene->_sequences.addTimer(30, 2); + _action._inProgress = false; + } + return; + + case 2: + _scene->deleteSequence(_globals._sequenceIndexes[8]); + _globals._sequenceIndexes[8] = _scene->_sequences.addReverseSpriteCycle(_globals._spriteIndexes[8], false, 5, 1); + _scene->_sequences.setAnimRange(_globals._sequenceIndexes[8], 1, 4); + _scene->_sequences.setSeqPlayer(_globals._sequenceIndexes[8], false); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[8], SEQUENCE_TRIGGER_EXPIRE, 0, 3); + _action._inProgress = false; + return; + + case 3: + _game.syncTimers(SYNC_PLAYER, 0, SYNC_SEQ, _globals._sequenceIndexes[8]); + _game._player._visible = true; + _vm->_dialogs->show(40923); + _game._player._stepEnabled = true; + _action._inProgress = false; + return; + + case 4: + _vm->_sound->command(70); + _action._inProgress = false; + return; + + default: + break; + } + } + + if (_action.isAction(VERB_PUT) && _action.isTarget(NOUN_FLOOR)) { + if (_action.isObject(NOUN_RED_FRAME) || _action.isObject(NOUN_BLUE_FRAME) || _action.isObject(NOUN_YELLOW_FRAME) || _action.isObject(NOUN_GREEN_FRAME)) { + if (_frameInRoomFl) { + _vm->_dialogs->show(29); + } else { + switch (_game._trigger) { + case (0): + _game._player._stepEnabled = false; + _game._player._visible = false; + _globals._sequenceIndexes[0] = _scene->_sequences.startPingPongCycle(_globals._spriteIndexes[0], true, 5, 2); + _scene->_sequences.setAnimRange(_globals._sequenceIndexes[0], 1, 5); + _scene->_sequences.setSeqPlayer(_globals._sequenceIndexes[0], true); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[0], SEQUENCE_TRIGGER_SPRITE, 5, 1); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[0], SEQUENCE_TRIGGER_EXPIRE, 0, 2); + break; + + case 1: + if (_action.isObject(NOUN_RED_FRAME)) { + _game._objects.setRoom(OBJ_RED_FRAME, NOWHERE); + _game._objects[OBJ_RED_FRAME]._roomNumber = _globals[kCatacombsRoom] + 600; + _globals._sequenceIndexes[2] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[2], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[2], 14); + + Common::Point pos = _scene->_sprites[_globals._spriteIndexes[2]]->getFramePos(0); + _redFrameHotspotId = _scene->_dynamicHotspots.add(NOUN_RED_FRAME, VERB_WALK_TO, SYNTAX_SINGULAR, EXT_NONE, Common::Rect(pos.x - 5, pos.y - 5, pos.x + 5, pos.y + 1)); + _scene->_dynamicHotspots.setPosition(_redFrameHotspotId, Common::Point(pos.x + 12, pos.y), FACING_NORTHWEST); + } + + if (_action.isObject(NOUN_GREEN_FRAME)) { + _game._objects.setRoom(OBJ_GREEN_FRAME, NOWHERE); + _game._objects[OBJ_GREEN_FRAME]._roomNumber = _globals[kCatacombsRoom] + 600; + _globals._sequenceIndexes[3] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[3], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[3], 14); + + Common::Point pos = _scene->_sprites[_globals._spriteIndexes[2]]->getFramePos(0); + _greenFrameHotspotId = _scene->_dynamicHotspots.add(NOUN_GREEN_FRAME, VERB_WALK_TO, SYNTAX_SINGULAR, EXT_NONE, Common::Rect(pos.x - 5, pos.y - 5, pos.x + 5, pos.y + 1)); + _scene->_dynamicHotspots.setPosition(_greenFrameHotspotId, Common::Point(pos.x + 12, pos.y), FACING_NORTHWEST); + } + + if (_action.isObject(NOUN_BLUE_FRAME)) { + _game._objects.setRoom(OBJ_BLUE_FRAME, NOWHERE); + _game._objects[OBJ_BLUE_FRAME]._roomNumber = _globals[kCatacombsRoom] + 600; + _globals._sequenceIndexes[4] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[4], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[4], 14); + + Common::Point pos = _scene->_sprites[_globals._spriteIndexes[2]]->getFramePos(0); + _blueFrameHotspotId = _scene->_dynamicHotspots.add(NOUN_BLUE_FRAME, VERB_WALK_TO, SYNTAX_SINGULAR, EXT_NONE, Common::Rect(pos.x - 5, pos.y - 5, pos.x + 5, pos.y + 1)); + _scene->_dynamicHotspots.setPosition(_blueFrameHotspotId, Common::Point(pos.x + 12, pos.y), FACING_NORTHWEST); + } + + if (_action.isObject(NOUN_YELLOW_FRAME)) { + _game._objects.setRoom(OBJ_YELLOW_FRAME, NOWHERE); + _game._objects[OBJ_YELLOW_FRAME]._roomNumber = _globals[kCatacombsRoom] + 600; + _globals._sequenceIndexes[5] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[5], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[5], 14); + + Common::Point pos = _scene->_sprites[_globals._spriteIndexes[2]]->getFramePos(0); + _yellowFrameHotspotId = _scene->_dynamicHotspots.add(NOUN_YELLOW_FRAME, VERB_WALK_TO, SYNTAX_SINGULAR, EXT_NONE, Common::Rect(pos.x - 5, pos.y - 5, pos.x + 5, pos.y + 1)); + _scene->_dynamicHotspots.setPosition(_yellowFrameHotspotId, Common::Point(pos.x + 12, pos.y), FACING_NORTHWEST); + } + break; + + case 2: + _game.syncTimers(SYNC_PLAYER, 0, SYNC_SEQ, _globals._sequenceIndexes[0]); + _game._player._visible = true; + _game._player._stepEnabled = true; + break; + + default: + break; + } + } + _action._inProgress = false; + return; + } + } + + if (_action.isAction(VERB_TAKE)) { + if ((_action.isObject(NOUN_RED_FRAME) || _action.isObject(NOUN_GREEN_FRAME) || _action.isObject(NOUN_BLUE_FRAME) || _action.isObject(NOUN_YELLOW_FRAME)) + && (_takingFrameInRoomFl || _game._trigger)) { + switch (_game._trigger) { + case (0): + _game._player._stepEnabled = false; + _game._player._visible = false; + _globals._sequenceIndexes[0] = _scene->_sequences.startPingPongCycle(_globals._spriteIndexes[0], true, 5, 2); + _scene->_sequences.setAnimRange(_globals._sequenceIndexes[0], 1, 5); + _scene->_sequences.setSeqPlayer(_globals._sequenceIndexes[0], true); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[0], SEQUENCE_TRIGGER_SPRITE, 5, 1); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[0], SEQUENCE_TRIGGER_EXPIRE, 0, 2); + break; + + case 1: + if (_action.isObject(NOUN_RED_FRAME)) { + _scene->deleteSequence(_globals._sequenceIndexes[2]); + _scene->_dynamicHotspots.remove(_redFrameHotspotId); + _game._objects.addToInventory(OBJ_RED_FRAME); + } + + if (_action.isObject(NOUN_GREEN_FRAME)) { + _scene->deleteSequence(_globals._sequenceIndexes[3]); + _scene->_dynamicHotspots.remove(_greenFrameHotspotId); + _game._objects.addToInventory(OBJ_GREEN_FRAME); + } + + if (_action.isObject(NOUN_BLUE_FRAME)) { + _scene->deleteSequence(_globals._sequenceIndexes[4]); + _scene->_dynamicHotspots.remove(_blueFrameHotspotId); + _game._objects.addToInventory(OBJ_BLUE_FRAME); + } + + if (_action.isObject(NOUN_YELLOW_FRAME)) { + _scene->deleteSequence(_globals._sequenceIndexes[5]); + _scene->_dynamicHotspots.remove(_yellowFrameHotspotId); + _game._objects.addToInventory(OBJ_YELLOW_FRAME); + } + + _vm->_sound->command(26); + break; + + case 2: + _game.syncTimers(SYNC_PLAYER, 0, SYNC_SEQ, _globals._sequenceIndexes[0]); + _game._player._visible = true; + _game._player._stepEnabled = true; + break; + + default: + break; + } + _action._inProgress = false; + return; + } + } + + if (_action.isAction(VERB_WALK_THROUGH, NOUN_ARCHWAY_TO_NORTH)) { + _game.enterCatacombs(true); + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_EXIT_TO, NOUN_MORE_CATACOMBS)) { + _game.enterCatacombs(false); + _action._inProgress = false; + return; + } + + if (_action._lookFlag) { + _vm->_dialogs->show(40910); + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_TAKE, NOUN_SWORD) && (_game._objects.isInRoom(OBJ_SWORD) || _game._trigger)) { + switch (_game._trigger) { + case (0): + _globals[kPlayerScore] += 5; + _game._player._stepEnabled = false; + _game._player._visible = false; + _globals._sequenceIndexes[0] = _scene->_sequences.startPingPongCycle(_globals._spriteIndexes[0], true, 5, 2); + _scene->_sequences.setAnimRange(_globals._sequenceIndexes[0], 1, 5); + _scene->_sequences.setSeqPlayer(_globals._sequenceIndexes[0], true); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[0], SEQUENCE_TRIGGER_SPRITE, 5, 1); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[0], SEQUENCE_TRIGGER_EXPIRE, 0, 2); + break; + + case 1: + _scene->deleteSequence(_globals._sequenceIndexes[1]); + _scene->_hotspots.activate(NOUN_SWORD, false); + _game._objects.addToInventory(OBJ_SWORD); + _vm->_sound->command(26); + break; + + case 2: + _game.syncTimers(SYNC_PLAYER, 0, SYNC_SEQ, _globals._sequenceIndexes[0]); + _game._player._visible = true; + _scene->_sequences.addTimer(20, 3); + break; + + case 3: + _vm->_dialogs->showItem(OBJ_SWORD, 808, 0); + _game._player._stepEnabled = true; + break; + + default: + break; + } + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_LOOK) || _action.isAction(VERB_LOOK_AT)) { + if (_action.isObject(NOUN_WALL)) { + _vm->_dialogs->show(40911); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_FLOOR)) { + _vm->_dialogs->show(40912); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_ARCHWAY)) { + _vm->_dialogs->show(40913); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_EXPOSED_BRICK)) { + _vm->_dialogs->show(40914); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_MORE_CATACOMBS)) { + _vm->_dialogs->show(40915); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_BLOCKED_ARCHWAY)) { + _vm->_dialogs->show(40916); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_GRATE)) { + _vm->_dialogs->show(40917); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_UNLUCKY_ADVENTURER)) { + _vm->_dialogs->show(40920); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_RED_FRAME) && !_game._objects.isInInventory(OBJ_RED_FRAME)) { + _vm->_dialogs->showItem(OBJ_RED_FRAME, 802, 0); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_GREEN_FRAME) && !_game._objects.isInInventory(OBJ_GREEN_FRAME)) { + _vm->_dialogs->showItem(OBJ_GREEN_FRAME, 819, 0); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_BLUE_FRAME) && !_game._objects.isInInventory(OBJ_BLUE_FRAME)) { + _vm->_dialogs->showItem(OBJ_BLUE_FRAME, 817, 0); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_YELLOW_FRAME) && !_game._objects.isInInventory(OBJ_YELLOW_FRAME)) { + _vm->_dialogs->showItem(OBJ_YELLOW_FRAME, 804, 0); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_SWORD) && _game._objects.isInRoom(OBJ_SWORD)) { + _vm->_dialogs->show(40921); + _action._inProgress = false; + return; + } + } + + if (_action.isAction(VERB_LOOK, NOUN_SWITCH_PANEL)) { + _vm->_dialogs->show(40919); + _scene->_nextSceneId = 410; + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_WALK_TO, NOUN_SWITCH_PANEL)) { + _scene->_nextSceneId = 410; + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_OPEN, NOUN_GRATE) || _action.isAction(VERB_PUSH, NOUN_GRATE) || _action.isAction(VERB_PULL, NOUN_GRATE)) { + switch (_game._trigger) { + case (0): + _game._player._stepEnabled = false; + _game._player._visible = false; + _globals._sequenceIndexes[0] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[0], false, 5, 1); + _scene->_sequences.setAnimRange(_globals._sequenceIndexes[0], -1, -2); + _scene->_sequences.setSeqPlayer(_globals._sequenceIndexes[0], true); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[0], SEQUENCE_TRIGGER_EXPIRE, 0, 2); + break; + + case 2: + _globals._sequenceIndexes[0] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[0], false, -2); + _scene->_sequences.setSeqPlayer(_globals._sequenceIndexes[0], true); + _scene->_sequences.addTimer(30, 3); + break; + + case 3: + _scene->deleteSequence(_globals._sequenceIndexes[0]); + _globals._sequenceIndexes[0] = _scene->_sequences.addReverseSpriteCycle(_globals._spriteIndexes[0], false, 5, 1); + _scene->_sequences.setAnimRange(_globals._sequenceIndexes[0], -1, -2); + _scene->_sequences.setSeqPlayer(_globals._sequenceIndexes[0], false); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[0], SEQUENCE_TRIGGER_EXPIRE, 0, 4); + break; + + case 4: + _game._player._visible = true; + _game.syncTimers(SYNC_PLAYER, 0, SYNC_SEQ, _globals._sequenceIndexes[0]); + _scene->_sequences.addTimer(6, 5); + break; + + case 5: + _game._player._stepEnabled = true; + _vm->_dialogs->show(40918); + break; + + default: + break; + } + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_TALK_TO, NOUN_UNLUCKY_ADVENTURER)) { + _vm->_dialogs->show(40924); + _action._inProgress = false; + } +} + +void Scene409::preActions() { + _frameInRoomFl = false; + _takingFrameInRoomFl = false; + + if (_game._objects[OBJ_RED_FRAME]._roomNumber == _globals[kCatacombsRoom] + 600) { + _frameInRoomFl = true; + if (_action.isAction(VERB_TAKE, NOUN_RED_FRAME)) + _takingFrameInRoomFl = true; + } + + if (_game._objects[OBJ_YELLOW_FRAME]._roomNumber == _globals[kCatacombsRoom] + 600) { + _frameInRoomFl = true; + if (_action.isAction(VERB_TAKE, NOUN_YELLOW_FRAME)) + _takingFrameInRoomFl = true; + } + + if (_game._objects[OBJ_BLUE_FRAME]._roomNumber == _globals[kCatacombsRoom] + 600) { + _frameInRoomFl = true; + if (_action.isAction(VERB_TAKE, NOUN_BLUE_FRAME)) + _takingFrameInRoomFl = true; + } + + if (_game._objects[OBJ_GREEN_FRAME]._roomNumber == _globals[kCatacombsRoom] + 600) { + _frameInRoomFl = true; + if (_action.isAction(VERB_TAKE, NOUN_GREEN_FRAME)) + _takingFrameInRoomFl = true; + } + + if (_action.isAction(VERB_PUT) && _action.isTarget(NOUN_FLOOR) + && (_action.isObject(NOUN_RED_FRAME) || _action.isObject(NOUN_BLUE_FRAME) || _action.isObject(NOUN_YELLOW_FRAME) || _action.isObject(NOUN_GREEN_FRAME))) { + if (_frameInRoomFl) + _game._player._needToWalk = false; + else { + Common::Point pos = _scene->_sprites[_globals._spriteIndexes[2]]->getFramePos(0); + _game._player.walk(Common::Point(pos.x + 12, pos.y), FACING_NORTHWEST); + } + } + + if (_action.isAction(VERB_LOOK, NOUN_SWITCH_PANEL)) + _game._player.walk(Common::Point(229, 106), FACING_NORTH); + + if (_action.isAction(VERB_OPEN, NOUN_DOOR)) + _game._player.walk(Common::Point(191, 104), FACING_NORTHEAST); + + if (_action.isAction(VERB_OPEN, NOUN_GRATE)) + _game._player._needToWalk = true; +} + +/*------------------------------------------------------------------------*/ + +Scene410::Scene410(MADSEngine *vm) : Scene4xx(vm) { + for (int i = 0; i < 26; i++) + _skullSequence[i]; +} + +void Scene410::synchronize(Common::Serializer &s) { + Scene4xx::synchronize(s); + + for (int i = 0; i < 26; i++) + s.syncAsSint16LE(_skullSequence[i]); +} + +void Scene410::setup() { + setPlayerSpritesPrefix(); + setAAName(); +} + +void Scene410::enter() { + _game._player._visible = false; + _globals._spriteIndexes[0] = _scene->_sprites.addSprites(formAnimName('l', 0)); + _globals._spriteIndexes[1] = _scene->_sprites.addSprites(formAnimName('l', 1)); + _globals._spriteIndexes[2] = _scene->_sprites.addSprites(formAnimName('l', 2)); + _globals._spriteIndexes[3] = _scene->_sprites.addSprites(formAnimName('a', 0)); + _globals._spriteIndexes[4] = _scene->_sprites.addSprites(formAnimName('f', 0)); + + for (int i = 1; i < 27; i++) { + Common::Point pos; + int type; + + getLeverInfo(&pos, &type, i, NULL); + int stampType = -1; + + switch (type) { + case 1: + stampType = _globals._spriteIndexes[0]; + break; + + case 2: + stampType = _globals._spriteIndexes[1]; + break; + + case 3: + stampType = _globals._spriteIndexes[2]; + break; + + default: + break; + } + + _globals._sequenceIndexes[0] = _scene->_sequences.addStampCycle(stampType, false, 1); + _scene->_sequences.setPosition(_globals._sequenceIndexes[0], pos); + _scene->_sequences.setDepth(_globals._sequenceIndexes[0], 2); + _skullSequence[i - 1] = _globals._sequenceIndexes[0]; + } + + if (_globals[kFlickedLever1]) { + Common::Point pos; + int type; + + getLeverInfo(&pos, &type, _globals[kFlickedLever1], NULL); + int stampType = -1; + + switch (type) { + case 1: + stampType = _globals._spriteIndexes[0]; + break; + + case 2: + stampType = _globals._spriteIndexes[1]; + break; + + case 3: + stampType = _globals._spriteIndexes[2]; + break; + + default: + break; + } + _scene->deleteSequence(_skullSequence[_globals[kFlickedLever1] - 1]); + _globals._sequenceIndexes[0] = _scene->_sequences.addStampCycle(stampType, false, -2); + _scene->_sequences.setPosition(_globals._sequenceIndexes[0], pos); + _scene->_sequences.setDepth(_globals._sequenceIndexes[0], 2); + } + + if (_globals[kFlickedLever2]) { + Common::Point pos; + int type; + + getLeverInfo(&pos, &type, _globals[kFlickedLever2], NULL); + int stampType = -1; + switch (type) { + case 1: + stampType = _globals._spriteIndexes[0]; + break; + + case 2: + stampType = _globals._spriteIndexes[1]; + break; + + case 3: + stampType = _globals._spriteIndexes[2]; + break; + + default: + break; + } + _scene->deleteSequence(_skullSequence[_globals[kFlickedLever2] - 1]); + _globals._sequenceIndexes[0] = _scene->_sequences.addStampCycle(stampType, false, -2); + _scene->_sequences.setPosition(_globals._sequenceIndexes[0], pos); + _scene->_sequences.setDepth(_globals._sequenceIndexes[0], 2); + } + + if (_globals[kFlickedLever3]) { + Common::Point pos; + int type; + + getLeverInfo(&pos, &type, _globals[kFlickedLever3], NULL); + int stampType = -1; + switch (type) { + case 1: + stampType = _globals._spriteIndexes[0]; + break; + + case 2: + stampType = _globals._spriteIndexes[1]; + break; + + case 3: + stampType = _globals._spriteIndexes[2]; + break; + + default: + break; + } + _scene->deleteSequence(_skullSequence[_globals[kFlickedLever3] - 1]); + _globals._sequenceIndexes[0] = _scene->_sequences.addStampCycle(stampType, false, -2); + _scene->_sequences.setPosition(_globals._sequenceIndexes[0], pos); + _scene->_sequences.setDepth(_globals._sequenceIndexes[0], 2); + } + + if (_globals[kFlickedLever4]) { + Common::Point pos; + int type; + + getLeverInfo(&pos, &type, _globals[kFlickedLever4], NULL); + int stampType = -1; + switch (type) { + case 1: + stampType = _globals._spriteIndexes[0]; + break; + + case 2: + stampType = _globals._spriteIndexes[1]; + break; + + case 3: + stampType = _globals._spriteIndexes[2]; + break; + + default: + break; + } + _scene->deleteSequence(_skullSequence[_globals[kFlickedLever4] - 1]); + _globals._sequenceIndexes[0] = _scene->_sequences.addStampCycle(stampType, false, -2); + _scene->_sequences.setPosition(_globals._sequenceIndexes[0], pos); + _scene->_sequences.setDepth(_globals._sequenceIndexes[0], 2); + } + + sceneEntrySound(); +} + +void Scene410::step() { +} + +void Scene410::actions() { + if (_action._lookFlag) { + _vm->_dialogs->show(41013); + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_PUSH) || _action.isAction(VERB_PULL)) { + if (_globals[kDoorIn409IsOpen]) + _vm->_dialogs->show(41014); + else { + Common::Point pos; + int type; + int number; + + switch (_game._trigger) { + case 0: + _game._player._stepEnabled = false; + getLeverInfo(&pos, &type, 0, &number); + _globals._sequenceIndexes[3] = _scene->_sequences.startPingPongCycle(_globals._spriteIndexes[3], false, 4, 2); + _scene->_sequences.setDepth(_globals._sequenceIndexes[3], 1); + _scene->_sequences.setAnimRange(_globals._sequenceIndexes[3], -1, -2); + if (pos.y == 46) + pos.y = 48; + + _scene->_sequences.setPosition(_globals._sequenceIndexes[3], Common::Point(pos.x + 4, pos.y + 107)); + if (!_globals[kDoorIn409IsOpen]) + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SEQUENCE_TRIGGER_SPRITE, 16, 1); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SEQUENCE_TRIGGER_EXPIRE, 0, 2); + break; + + case 1: + getLeverInfo(&pos, &type, 0, &number); + + if ((_globals[kFlickedLever1] != number) && (_globals[kFlickedLever2] != number) && (_globals[kFlickedLever3] != number) && (_globals[kFlickedLever4] != number)) { + _vm->_sound->command(65); + + if (!_globals[kFlickedLever1]) { + _globals[kFlickedLever1] = number; + if (_globals[kFlickedLever1] == 5) + _vm->_sound->command(66); + } else if (!_globals[kFlickedLever2]) { + _globals[kFlickedLever2] = number; + if ((_globals[kFlickedLever1] == 5) && (_globals[kFlickedLever2] == 18)) + _vm->_sound->command(66); + } else if (!_globals[kFlickedLever3]) { + _globals[kFlickedLever3] = number; + if ((_globals[kFlickedLever1] == 5) && (_globals[kFlickedLever2] == 18) && (_globals[kFlickedLever3] == 9)) + _vm->_sound->command(66); + } else if (!_globals[kFlickedLever4]) { + _globals[kFlickedLever4] = number; + if ((_globals[kFlickedLever1] == 5) && (_globals[kFlickedLever2] == 18) && (_globals[kFlickedLever3] == 9) && (_globals[kFlickedLever4] == 11)) + _vm->_sound->command(66); + } + + if (_game._difficulty == DIFFICULTY_EASY) + _scene->drawToBackground(_globals._spriteIndexes[4], number, Common::Point(-32000, -32000), 0, 100); + + switch (type) { + case 1: + _scene->deleteSequence(_skullSequence[number - 1]); + _globals._sequenceIndexes[0] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[0], false, 4, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[0], 2); + _scene->_sequences.setAnimRange(_globals._sequenceIndexes[0], -1, -2); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[0], SEQUENCE_TRIGGER_EXPIRE, 0, 4); + _scene->_sequences.setPosition(_globals._sequenceIndexes[0], pos); + break; + + case 2: + _scene->deleteSequence(_skullSequence[number - 1]); + _globals._sequenceIndexes[1] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[1], false, 4, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[1], 2); + _scene->_sequences.setAnimRange(_globals._sequenceIndexes[1], -1, -2); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[1], SEQUENCE_TRIGGER_EXPIRE, 0, 4); + _scene->_sequences.setPosition(_globals._sequenceIndexes[1], pos); + break; + + case 3: + _scene->deleteSequence(_skullSequence[number - 1]); + _globals._sequenceIndexes[2] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[2], false, 4, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[2], 2); + _scene->_sequences.setAnimRange(_globals._sequenceIndexes[2], -1, -2); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SEQUENCE_TRIGGER_EXPIRE, 0, 4); + _scene->_sequences.setPosition(_globals._sequenceIndexes[2], pos); + break; + + default: + break; + } + } + break; + + case 2: + _game._player._stepEnabled = true; + + if ((_globals[kFlickedLever1] == 5) && (_globals[kFlickedLever2] == 18) && (_globals[kFlickedLever3] == 9) && (_globals[kFlickedLever4] == 11) && !_globals[kDoorIn409IsOpen]) + _vm->_sound->command(67); + + if (_globals[kFlickedLever1] && _globals[kFlickedLever2] && _globals[kFlickedLever3] && _globals[kFlickedLever4]) + _scene->_nextSceneId = 409; + + break; + + case 4: + getLeverInfo(&pos, &type, 0, &number); + _globals._sequenceIndexes[0] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[0], false, -2); + _scene->_sequences.setDepth(_globals._sequenceIndexes[0], 2); + _scene->_sequences.setPosition(_globals._sequenceIndexes[0], pos); + break; + + case 5: + getLeverInfo(&pos, &type, 0, &number); + _globals._sequenceIndexes[1] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[1], false, -2); + _scene->_sequences.setDepth(_globals._sequenceIndexes[1], 2); + _scene->_sequences.setPosition(_globals._sequenceIndexes[1], pos); + break; + + case 6: + getLeverInfo(&pos, &type, 0, &number); + _globals._sequenceIndexes[2] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[2], false, -2); + _scene->_sequences.setDepth(_globals._sequenceIndexes[2], 2); + _scene->_sequences.setPosition(_globals._sequenceIndexes[2], pos); + break; + + default: + break; + } + } + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_LOOK) || _action.isAction(VERB_LOOK_AT)) { + if (_action.isObject(NOUN_WALL)) { + _vm->_dialogs->show(41011); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_SWITCH_PANEL)) { + _vm->_dialogs->show(41011); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_CATACOMB_ROOM)) { + _vm->_dialogs->show(41015); + _action._inProgress = false; + return; + } + + switch (_action._activeAction._objectNameId) { + case NOUN_SKULL_SWITCH_1: + case NOUN_SKULL_SWITCH_2: + case NOUN_SKULL_SWITCH_3: + case NOUN_SKULL_SWITCH_4: + case NOUN_SKULL_SWITCH_5: + case NOUN_SKULL_SWITCH_6: + case NOUN_SKULL_SWITCH_7: + case NOUN_SKULL_SWITCH_8: + case NOUN_SKULL_SWITCH_9: + case NOUN_SKULL_SWITCH_10: + case NOUN_SKULL_SWITCH_11: + case NOUN_SKULL_SWITCH_12: + case NOUN_SKULL_SWITCH_13: + case NOUN_SKULL_SWITCH_14: + case NOUN_SKULL_SWITCH_15: + case NOUN_SKULL_SWITCH_16: + case NOUN_SKULL_SWITCH_17: + case NOUN_SKULL_SWITCH_18: + case NOUN_SKULL_SWITCH_19: + case NOUN_SKULL_SWITCH_20: + case NOUN_SKULL_SWITCH_21: + case NOUN_SKULL_SWITCH_22: + case NOUN_SKULL_SWITCH_23: + case NOUN_SKULL_SWITCH_24: + case NOUN_SKULL_SWITCH_25: + case NOUN_SKULL_SWITCH_26: + _vm->_dialogs->show(41012); + _action._inProgress = false; + return; + break; + } + } + + if (_action.isAction(VERB_EXIT_TO, NOUN_CATACOMB_ROOM)) { + _scene->_nextSceneId = 409; + _action._inProgress = false; + } +} + +void Scene410::preActions() { +} + +void Scene410::getLeverInfo(Common::Point *pos, int *type, int lever, int *noun) { + if (noun != NULL) { + switch (_action._activeAction._objectNameId) { + case NOUN_SKULL_SWITCH_1: + lever = 1; + break; + + case NOUN_SKULL_SWITCH_2: + lever = 2; + break; + + case NOUN_SKULL_SWITCH_3: + lever = 3; + break; + + case NOUN_SKULL_SWITCH_4: + lever = 4; + break; + + case NOUN_SKULL_SWITCH_5: + lever = 5; + break; + + case NOUN_SKULL_SWITCH_6: + lever = 6; + break; + + case NOUN_SKULL_SWITCH_7: + lever = 7; + break; + + case NOUN_SKULL_SWITCH_8: + lever = 8; + break; + + case NOUN_SKULL_SWITCH_9: + lever = 9; + break; + + case NOUN_SKULL_SWITCH_10: + lever = 10; + break; + + case NOUN_SKULL_SWITCH_11: + lever = 11; + break; + + case NOUN_SKULL_SWITCH_12: + lever = 12; + break; + + case NOUN_SKULL_SWITCH_13: + lever = 13; + break; + + case NOUN_SKULL_SWITCH_14: + lever = 14; + break; + + case NOUN_SKULL_SWITCH_15: + lever = 15; + break; + + case NOUN_SKULL_SWITCH_16: + lever = 16; + break; + + case NOUN_SKULL_SWITCH_17: + lever = 17; + break; + + case NOUN_SKULL_SWITCH_18: + lever = 18; + break; + + case NOUN_SKULL_SWITCH_19: + lever = 19; + break; + + case NOUN_SKULL_SWITCH_20: + lever = 20; + break; + + case NOUN_SKULL_SWITCH_21: + lever = 21; + break; + + case NOUN_SKULL_SWITCH_22: + lever = 22; + break; + + case NOUN_SKULL_SWITCH_23: + lever = 23; + break; + + case NOUN_SKULL_SWITCH_24: + lever = 24; + break; + + case NOUN_SKULL_SWITCH_25: + lever = 25; + break; + + case NOUN_SKULL_SWITCH_26: + lever = 26; + break; + + default: + break; + } + *noun = lever; + } + + switch (lever) { + case 1: + *pos = Common::Point(124, 46); + *type = 3; + break; + + case 2: + *pos = Common::Point(143, 46); + *type = 2; + break; + + case 3: + *pos = Common::Point(162, 46); + *type = 1; + break; + + case 4: + *pos = Common::Point(181, 46); + *type = 3; + break; + + case 5: + *pos = Common::Point(200, 46); + *type = 1; + break; + + case 6: + *pos = Common::Point(219, 46); + *type = 2; + break; + + case 7: + *pos = Common::Point(238, 46); + *type = 1; + break; + + case 8: + *pos = Common::Point(133, 71); + *type = 3; + break; + + case 9: + *pos = Common::Point(152, 71); + *type = 2; + break; + + case 10: + *pos = Common::Point(171, 71); + *type = 1; + break; + + case 11: + *pos = Common::Point(190, 71); + *type = 3; + break; + + case 12: + *pos = Common::Point(209, 71); + *type = 2; + break; + + case 13: + *pos = Common::Point(228, 71); + *type = 1; + break; + + case 14: + *pos = Common::Point(124, 98); + *type = 1; + break; + + case 15: + *pos = Common::Point(143, 98); + *type = 3; + break; + + case 16: + *pos = Common::Point(162, 98); + *type = 2; + break; + + case 17: + *pos = Common::Point(181, 98); + *type = 1; + break; + + case 18: + *pos = Common::Point(200, 98); + *type = 1; + break; + + case 19: + *pos = Common::Point(219, 98); + *type = 2; + break; + + case 20: + *pos = Common::Point(238, 98); + *type = 1; + break; + + case 21: + *pos = Common::Point(133, 125); + *type = 3; + break; + + case 22: + *pos = Common::Point(152, 125); + *type = 1; + break; + + case 23: + *pos = Common::Point(171, 125); + *type = 3; + break; + + case 24: + *pos = Common::Point(190, 125); + *type = 2; + break; + + case 25: + *pos = Common::Point(209, 125); + *type = 1; + break; + + case 26: + *pos = Common::Point(228, 125); + *type = 2; + break; + + default: + *pos = Common::Point(-1, -1); + *type = -1; + break; + } +} + +/*------------------------------------------------------------------------*/ + +Scene453::Scene453(MADSEngine *vm) : Scene4xx(vm) { + _frameInRoomFl = false; + _takingFrameInRoomFl = false; + + _redFrameHotspotId = -1; + _greenFrameHotspotId = -1; + _blueFrameHotspotId = -1; + _yellowFrameHotspotId = -1; +} + +void Scene453::synchronize(Common::Serializer &s) { + Scene4xx::synchronize(s); + + s.syncAsByte(_frameInRoomFl); + s.syncAsByte(_takingFrameInRoomFl); + + s.syncAsSint16LE(_redFrameHotspotId); + s.syncAsSint16LE(_greenFrameHotspotId); + s.syncAsSint16LE(_blueFrameHotspotId); + s.syncAsSint16LE(_yellowFrameHotspotId); +} + +void Scene453::setup() { + setPlayerSpritesPrefix(); + setAAName(); + + if (_globals[kCatacombsMisc] & MAZE_EVENT_STONE) + _scene->_variant = 1; + + _scene->addActiveVocab(NOUN_RED_FRAME); + _scene->addActiveVocab(NOUN_YELLOW_FRAME); + _scene->addActiveVocab(NOUN_BLUE_FRAME); + _scene->addActiveVocab(NOUN_GREEN_FRAME); +} + +void Scene453::enter() { + _game.initCatacombs(); + + _scene->_hotspots.activate(NOUN_SKULL, false); + _scene->_hotspots.activate(NOUN_DRAIN, false); + _scene->_hotspots.activate(NOUN_RATS_NEST, false); + _scene->_hotspots.activate(NOUN_WEB, false); + _scene->_hotspots.activate(NOUN_STONE, false); + _scene->_hotspots.activate(NOUN_HOLE, false); + _scene->_hotspots.activate(NOUN_GATE, false); + + _globals._spriteIndexes[8] = _scene->_sprites.addSprites("*RRD_9"); + _globals._spriteIndexes[9] = _scene->_sprites.addSprites(formAnimName('f', 0)); + _globals._spriteIndexes[10] = _scene->_sprites.addSprites(formAnimName('f', 1)); + _globals._spriteIndexes[11] = _scene->_sprites.addSprites(formAnimName('f', 2)); + _globals._spriteIndexes[12] = _scene->_sprites.addSprites(formAnimName('f', 3)); + + + if (_game.exitCatacombs(0) == -1) { + _globals._spriteIndexes[1] = _scene->_sprites.addSprites(formAnimName('c', 1)); + _scene->drawToBackground(_globals._spriteIndexes[1], 1, Common::Point(-32000, -32000), 0, 100); + _scene->_hotspots.activate(NOUN_ARCHWAY_TO_NORTH, false); + } + + if (_game.exitCatacombs(3) == -1) { + _globals._spriteIndexes[13] = _scene->_sprites.addSprites(formAnimName('c', 8)); + _scene->drawToBackground(_globals._spriteIndexes[13], 1, Common::Point(-32000, -32000), 0, 100); + _scene->_hotspots.activate(NOUN_MORE_CATACOMBS, false); + _scene->_hotspots.activate(NOUN_GATE, true); + } + + if (_game.exitCatacombs(1) == -1) { + _globals._spriteIndexes[2] = _scene->_sprites.addSprites(formAnimName('c', 2)); + _scene->drawToBackground(_globals._spriteIndexes[2], 1, Common::Point(-32000, -32000), 0, 100); + _scene->_hotspots.activate(NOUN_ARCHWAY_TO_EAST, false); + } + + if (_globals[kCatacombsMisc] & MAZE_EVENT_DRAIN) { + _globals._spriteIndexes[3] = _scene->_sprites.addSprites(formAnimName('c', 3)); + _scene->drawToBackground(_globals._spriteIndexes[3], 1, Common::Point(-32000, -32000), 0, 100); + _scene->_hotspots.activate(NOUN_DRAIN, true); + } + + if (_globals[kCatacombsMisc] & MAZE_EVENT_RAT_NEST) { + _globals._spriteIndexes[4] = _scene->_sprites.addSprites(formAnimName('c', 4)); + _scene->drawToBackground(_globals._spriteIndexes[4], 1, Common::Point(-32000, -32000), 0, 100); + _scene->_hotspots.activate(NOUN_SKULL, true); + _scene->_hotspots.activate(NOUN_RATS_NEST, true); + } + + if (_globals[kCatacombsMisc] & MAZE_EVENT_WEB) { + _globals._spriteIndexes[5] = _scene->_sprites.addSprites(formAnimName('c', 5)); + _scene->drawToBackground(_globals._spriteIndexes[5], 1, Common::Point(-32000, -32000), 0, 100); + _scene->_hotspots.activate(NOUN_WEB, true); + } + + if (_globals[kCatacombsMisc] & MAZE_EVENT_BRICK) { + _globals._spriteIndexes[6] = _scene->_sprites.addSprites(formAnimName('c', 6)); + _scene->drawToBackground(_globals._spriteIndexes[6], 1, Common::Point(-32000, -32000), 0, 100); + _scene->_hotspots.activateAtPos(NOUN_EXPOSED_BRICK, false, Common::Point(138, 35)); + _scene->_hotspots.activateAtPos(NOUN_EXPOSED_BRICK, false, Common::Point(84, 27)); + } + + if (_globals[kCatacombsMisc] & MAZE_EVENT_STONE) { + _globals._spriteIndexes[7] = _scene->_sprites.addSprites(formAnimName('c', 7)); + _scene->drawToBackground(_globals._spriteIndexes[7], 1, Common::Point(-32000, -32000), 0, 100); + _scene->_hotspots.activate(NOUN_HOLE, true); + _scene->_hotspots.activate(NOUN_STONE, true); + } + + if (_scene->_priorSceneId != RETURNING_FROM_LOADING) { + switch (_globals[kCatacombsFrom]) { + case 0: + _game._player._playerPos = Common::Point(107, 87); + _game._player._facing = FACING_SOUTH; + _game._player.walk(Common::Point(107, 98), FACING_SOUTH); + break; + + case 1: + _game._player._playerPos = Common::Point(316, 129); + _game._player._facing = FACING_WEST; + _game._player.walk(Common::Point(277, 129), FACING_WEST); + break; + + case 3: + _game._player.firstWalk(Common::Point(-20, 128), FACING_EAST, Common::Point(19, 128), FACING_EAST, true); + break; + + default: + break; + } + } + + if (_game._objects[OBJ_RED_FRAME]._roomNumber == _globals[kCatacombsRoom] + 600) { + _globals._sequenceIndexes[9] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[9], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[9], 14); + + Common::Point pos = _scene->_sprites[_globals._spriteIndexes[9]]->getFramePos(0); + _redFrameHotspotId = _scene->_dynamicHotspots.add(NOUN_RED_FRAME, VERB_WALK_TO, SYNTAX_SINGULAR, EXT_NONE, Common::Rect(pos.x - 5, pos.y - 5, pos.x + 5, pos.y + 1)); + _scene->_dynamicHotspots.setPosition(_redFrameHotspotId, Common::Point(pos.x + 12, pos.y), FACING_NORTHWEST); + } + + if (_game._objects[OBJ_GREEN_FRAME]._roomNumber == _globals[kCatacombsRoom] + 600) { + _globals._sequenceIndexes[10] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[10], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[10], 14); + + Common::Point pos = _scene->_sprites[_globals._spriteIndexes[9]]->getFramePos(0); + _greenFrameHotspotId = _scene->_dynamicHotspots.add(NOUN_GREEN_FRAME, VERB_WALK_TO, SYNTAX_SINGULAR, EXT_NONE, Common::Rect(pos.x - 5, pos.y - 5, pos.x + 5, pos.y + 1)); + _scene->_dynamicHotspots.setPosition(_greenFrameHotspotId, Common::Point(pos.x + 12, pos.y), FACING_NORTHWEST); + } + + if (_game._objects[OBJ_BLUE_FRAME]._roomNumber == _globals[kCatacombsRoom] + 600) { + _globals._sequenceIndexes[11] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[11], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[11], 14); + + Common::Point pos = _scene->_sprites[_globals._spriteIndexes[9]]->getFramePos(0); + _blueFrameHotspotId = _scene->_dynamicHotspots.add(NOUN_BLUE_FRAME, VERB_WALK_TO, SYNTAX_SINGULAR, EXT_NONE, Common::Rect(pos.x - 5, pos.y - 5, pos.x + 5, pos.y + 1)); + _scene->_dynamicHotspots.setPosition(_blueFrameHotspotId, Common::Point(pos.x + 12, pos.y), FACING_NORTHWEST); + } + + if (_game._objects[OBJ_YELLOW_FRAME]._roomNumber == _globals[kCatacombsRoom] + 600) { + _globals._sequenceIndexes[12] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[12], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[12], 14); + + Common::Point pos = _scene->_sprites[_globals._spriteIndexes[9]]->getFramePos(0); + _yellowFrameHotspotId = _scene->_dynamicHotspots.add(NOUN_YELLOW_FRAME, VERB_WALK_TO, SYNTAX_SINGULAR, EXT_NONE, Common::Rect(pos.x - 5, pos.y - 5, pos.x + 5, pos.y + 1)); + _scene->_dynamicHotspots.setPosition(_yellowFrameHotspotId, Common::Point(pos.x + 12, pos.y), FACING_NORTHWEST); + } + + sceneEntrySound(); +} + +void Scene453::step() { +} + +void Scene453::actions() { + if (_action.isAction(VERB_PUT) && _action.isTarget(NOUN_FLOOR)) { + if (_action.isObject(NOUN_RED_FRAME) || _action.isObject(NOUN_BLUE_FRAME) || _action.isObject(NOUN_YELLOW_FRAME) || _action.isObject(NOUN_GREEN_FRAME)) { + if (_frameInRoomFl) + _vm->_dialogs->show(29); + else { + switch (_game._trigger) { + case (0): + _game._player._stepEnabled = false; + _game._player._visible = false; + _globals._sequenceIndexes[8] = _scene->_sequences.startPingPongCycle(_globals._spriteIndexes[8], true, 5, 2); + _scene->_sequences.setAnimRange(_globals._sequenceIndexes[8], 1, 5); + _scene->_sequences.setSeqPlayer(_globals._sequenceIndexes[8], true); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[8], SEQUENCE_TRIGGER_SPRITE, 5, 1); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[8], SEQUENCE_TRIGGER_EXPIRE, 0, 2); + break; + + case 1: + if (_action.isObject(NOUN_RED_FRAME)) { + _game._objects.setRoom(OBJ_RED_FRAME, NOWHERE); + _game._objects[OBJ_RED_FRAME]._roomNumber = _globals[kCatacombsRoom] + 600; + _globals._sequenceIndexes[9] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[9], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[9], 14); + + Common::Point pos = _scene->_sprites[_globals._spriteIndexes[9]]->getFramePos(0); + _redFrameHotspotId = _scene->_dynamicHotspots.add(NOUN_RED_FRAME, VERB_WALK_TO, SYNTAX_SINGULAR, EXT_NONE, Common::Rect(pos.x - 5, pos.y - 5, pos.x + 5, pos.y + 1)); + _scene->_dynamicHotspots.setPosition(_redFrameHotspotId, Common::Point(pos.x + 12, pos.y), FACING_NORTHWEST); + } + + if (_action.isObject(NOUN_GREEN_FRAME)) { + _game._objects.setRoom(OBJ_GREEN_FRAME, NOWHERE); + _game._objects[OBJ_GREEN_FRAME]._roomNumber = _globals[kCatacombsRoom] + 600; + _globals._sequenceIndexes[10] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[10], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[10], 14); + + Common::Point pos = _scene->_sprites[_globals._spriteIndexes[9]]->getFramePos(0); + _greenFrameHotspotId = _scene->_dynamicHotspots.add(NOUN_GREEN_FRAME, VERB_WALK_TO, SYNTAX_SINGULAR, EXT_NONE, Common::Rect(pos.x - 5, pos.y - 5, pos.x + 5, pos.y + 1)); + _scene->_dynamicHotspots.setPosition(_greenFrameHotspotId, Common::Point(pos.x + 12, pos.y), FACING_NORTHWEST); + } + + if (_action.isObject(NOUN_BLUE_FRAME)) { + _game._objects.setRoom(OBJ_BLUE_FRAME, NOWHERE); + _game._objects[OBJ_BLUE_FRAME]._roomNumber = _globals[kCatacombsRoom] + 600; + _globals._sequenceIndexes[11] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[11], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[11], 14); + + Common::Point pos = _scene->_sprites[_globals._spriteIndexes[9]]->getFramePos(0); + _blueFrameHotspotId = _scene->_dynamicHotspots.add(NOUN_BLUE_FRAME, VERB_WALK_TO, SYNTAX_SINGULAR, EXT_NONE, Common::Rect(pos.x - 5, pos.y - 5, pos.x + 5, pos.y + 1)); + _scene->_dynamicHotspots.setPosition(_blueFrameHotspotId, Common::Point(pos.x + 12, pos.y), FACING_NORTHWEST); + } + + if (_action.isObject(NOUN_YELLOW_FRAME)) { + _game._objects.setRoom(OBJ_YELLOW_FRAME, NOWHERE); + _game._objects[OBJ_YELLOW_FRAME]._roomNumber = _globals[kCatacombsRoom] + 600; + _globals._sequenceIndexes[12] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[12], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[12], 14); + + Common::Point pos = _scene->_sprites[_globals._spriteIndexes[9]]->getFramePos(0); + _yellowFrameHotspotId = _scene->_dynamicHotspots.add(NOUN_YELLOW_FRAME, VERB_WALK_TO, SYNTAX_SINGULAR, EXT_NONE, Common::Rect(pos.x - 5, pos.y - 5, pos.x + 5, pos.y + 1)); + _scene->_dynamicHotspots.setPosition(_yellowFrameHotspotId, Common::Point(pos.x + 12, pos.y), FACING_NORTHWEST); + } + break; + + case 2: + _game.syncTimers(SYNC_PLAYER, 0, SYNC_SEQ, _globals._sequenceIndexes[8]); + _game._player._visible = true; + _game._player._stepEnabled = true; + break; + + default: + break; + } + } + _action._inProgress = false; + return; + } + } + + if (_action.isAction(VERB_TAKE)) { + if (_action.isObject(NOUN_RED_FRAME) || _action.isObject(NOUN_GREEN_FRAME) || _action.isObject(NOUN_BLUE_FRAME) || _action.isObject(NOUN_YELLOW_FRAME)) { + if ((_takingFrameInRoomFl || _game._trigger)) { + switch (_game._trigger) { + case (0): + _game._player._stepEnabled = false; + _game._player._visible = false; + _globals._sequenceIndexes[8] = _scene->_sequences.startPingPongCycle(_globals._spriteIndexes[8], true, 5, 2); + _scene->_sequences.setAnimRange(_globals._sequenceIndexes[8], 1, 5); + _scene->_sequences.setSeqPlayer(_globals._sequenceIndexes[8], true); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[8], SEQUENCE_TRIGGER_SPRITE, 5, 1); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[8], SEQUENCE_TRIGGER_EXPIRE, 0, 2); + break; + + case 1: + if (_action.isObject(NOUN_RED_FRAME)) { + _scene->deleteSequence(_globals._sequenceIndexes[9]); + _scene->_dynamicHotspots.remove(_redFrameHotspotId); + _game._objects.addToInventory(OBJ_RED_FRAME); + } + + if (_action.isObject(NOUN_GREEN_FRAME)) { + _scene->deleteSequence(_globals._sequenceIndexes[10]); + _scene->_dynamicHotspots.remove(_greenFrameHotspotId); + _game._objects.addToInventory(OBJ_GREEN_FRAME); + } + + if (_action.isObject(NOUN_BLUE_FRAME)) { + _scene->deleteSequence(_globals._sequenceIndexes[11]); + _scene->_dynamicHotspots.remove(_blueFrameHotspotId); + _game._objects.addToInventory(OBJ_BLUE_FRAME); + } + + if (_action.isObject(NOUN_YELLOW_FRAME)) { + _scene->deleteSequence(_globals._sequenceIndexes[12]); + _scene->_dynamicHotspots.remove(_yellowFrameHotspotId); + _game._objects.addToInventory(OBJ_YELLOW_FRAME); + } + + _vm->_sound->command(26); + break; + + case 2: + _game.syncTimers(SYNC_PLAYER, 0, SYNC_SEQ, _globals._sequenceIndexes[8]); + _game._player._visible = true; + _game._player._stepEnabled = true; + break; + + default: + break; + } + _action._inProgress = false; + return; + } + } + } + + if (_action.isAction(VERB_WALK_THROUGH, NOUN_ARCHWAY_TO_NORTH)) { + _game.moveCatacombs(0); + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_WALK_THROUGH, NOUN_ARCHWAY_TO_EAST)) { + _game.moveCatacombs(1); + _action._inProgress = false; + return; + } + + if (_action._lookFlag) { + _vm->_dialogs->show(45310); + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_LOOK) || _action.isAction(VERB_LOOK_AT)) { + if (_action.isObject(NOUN_WALL)) { + _vm->_dialogs->show(45311); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_FLOOR)) { + _vm->_dialogs->show(45312); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_ARCHWAY)) { + _vm->_dialogs->show(45313); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_EXPOSED_BRICK)) { + _vm->_dialogs->show(45314); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_HOLE)) { + _vm->_dialogs->show(45317); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_SKULL)) { + _vm->_dialogs->show(45318); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_WEB)) { + _vm->_dialogs->show(45324); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_RATS_NEST)) { + _vm->_dialogs->show(45325); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_DRAIN)) { + _vm->_dialogs->show(45327); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_STONE)) { + _vm->_dialogs->show(45328); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_RED_FRAME) && !_game._objects.isInInventory(OBJ_RED_FRAME)) { + _vm->_dialogs->showItem(OBJ_RED_FRAME, 802, 0); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_GREEN_FRAME) && !_game._objects.isInInventory(OBJ_GREEN_FRAME)) { + _vm->_dialogs->showItem(OBJ_GREEN_FRAME, 819, 0); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_BLUE_FRAME) && !_game._objects.isInInventory(OBJ_BLUE_FRAME)) { + _vm->_dialogs->showItem(OBJ_BLUE_FRAME, 817, 0); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_YELLOW_FRAME) && !_game._objects.isInInventory(OBJ_YELLOW_FRAME)) { + _vm->_dialogs->showItem(OBJ_YELLOW_FRAME, 804, 0); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_MORE_CATACOMBS)) { + _vm->_dialogs->show(45315); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_GATE)) { + _vm->_dialogs->show(45330); + _action._inProgress = false; + return; + } + } + + if (_action.isAction(VERB_TAKE, NOUN_SKULL)) { + _vm->_dialogs->show(45319); + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_OPEN, NOUN_GATE)) { + _vm->_dialogs->show(45331); + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_TAKE, NOUN_RATS_NEST)) { + _vm->_dialogs->show(45326); + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_TAKE, NOUN_STONE)) { + _vm->_dialogs->show(45329); + _action._inProgress = false; + } +} + +void Scene453::preActions() { + if (_action.isAction(VERB_EXIT_TO, NOUN_MORE_CATACOMBS)) + _game.moveCatacombs(3); + + _frameInRoomFl = false; + _takingFrameInRoomFl = false; + + if (_game._objects[OBJ_RED_FRAME]._roomNumber == _globals[kCatacombsRoom] + 600) { + _frameInRoomFl = true; + if (_action.isAction(VERB_TAKE, NOUN_RED_FRAME)) + _takingFrameInRoomFl = true; + } + + if (_game._objects[OBJ_YELLOW_FRAME]._roomNumber == _globals[kCatacombsRoom] + 600) { + _frameInRoomFl = true; + if (_action.isAction(VERB_TAKE, NOUN_YELLOW_FRAME)) + _takingFrameInRoomFl = true; + } + + if (_game._objects[OBJ_BLUE_FRAME]._roomNumber == _globals[kCatacombsRoom] + 600) { + _frameInRoomFl = true; + if (_action.isAction(VERB_TAKE, NOUN_BLUE_FRAME)) + _takingFrameInRoomFl = true; + } + + if (_game._objects[OBJ_GREEN_FRAME]._roomNumber == _globals[kCatacombsRoom] + 600) { + _frameInRoomFl = true; + if (_action.isAction(VERB_TAKE, NOUN_GREEN_FRAME)) + _takingFrameInRoomFl = true; + } + + if (_action.isAction(VERB_PUT) && _action.isTarget(NOUN_FLOOR) && (_action.isObject(NOUN_RED_FRAME) || _action.isObject(NOUN_BLUE_FRAME) || _action.isObject(NOUN_YELLOW_FRAME) || _action.isObject(NOUN_GREEN_FRAME))) { + if (_frameInRoomFl) + _game._player._needToWalk = false; + else { + Common::Point pos = _scene->_sprites[_globals._spriteIndexes[9]]->getFramePos(0); + _game._player.walk(Common::Point(pos.x + 12, pos.y), FACING_NORTHWEST); + } + } +} + +/*------------------------------------------------------------------------*/ + +Scene456::Scene456(MADSEngine *vm) : Scene4xx(vm) { + _frameInRoomFl = false; + _takingFrameInRoomFl = false; + + _redFrameHotspotId = -1; + _greenFrameHotspotId = -1; + _blueFrameHotspotId = -1; + _yellowFrameHotspotId = -1; +} + +void Scene456::synchronize(Common::Serializer &s) { + Scene4xx::synchronize(s); + + s.syncAsByte(_frameInRoomFl); + s.syncAsByte(_takingFrameInRoomFl); + + s.syncAsSint16LE(_redFrameHotspotId); + s.syncAsSint16LE(_greenFrameHotspotId); + s.syncAsSint16LE(_blueFrameHotspotId); + s.syncAsSint16LE(_yellowFrameHotspotId); +} + +void Scene456::setup() { + setPlayerSpritesPrefix(); + setAAName(); + + _scene->addActiveVocab(NOUN_RED_FRAME); + _scene->addActiveVocab(NOUN_YELLOW_FRAME); + _scene->addActiveVocab(NOUN_BLUE_FRAME); + _scene->addActiveVocab(NOUN_GREEN_FRAME); +} + +void Scene456::enter() { + _game.initCatacombs(); + + _globals._spriteIndexes[0] = _scene->_sprites.addSprites(formAnimName('c', 1)); + _globals._spriteIndexes[1] = _scene->_sprites.addSprites("*RRD_9"); + _globals._spriteIndexes[2] = _scene->_sprites.addSprites(formAnimName('f', 0)); + _globals._spriteIndexes[3] = _scene->_sprites.addSprites(formAnimName('f', 1)); + _globals._spriteIndexes[4] = _scene->_sprites.addSprites(formAnimName('f', 2)); + _globals._spriteIndexes[5] = _scene->_sprites.addSprites(formAnimName('f', 3)); + + if (_game.exitCatacombs(1) == -1) { + _scene->drawToBackground(_globals._spriteIndexes[0], 1, Common::Point(-32000, -32000), 0, 100); + _scene->_hotspots.activate(NOUN_ARCHWAY_TO_EAST, false); + } + + if (_scene->_priorSceneId != RETURNING_FROM_LOADING) { + switch (_globals[kCatacombsFrom]) { + case 1: + _game._player._playerPos = Common::Point(298, 123); + _game._player._facing = FACING_WEST; + _game._player.walk(Common::Point(254, 123), FACING_WEST); + break; + + case 3: + _game._player._playerPos = Common::Point(14, 117); + _game._player._facing = FACING_SOUTH; + _game._player.walk(Common::Point(46, 117), FACING_EAST); + break; + + default: + break; + } + } + + if (_game._objects[OBJ_RED_FRAME]._roomNumber == _globals[kCatacombsRoom] + 600) { + _globals._sequenceIndexes[2] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[2], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[2], 14); + + Common::Point pos = _scene->_sprites[_globals._spriteIndexes[2]]->getFramePos(0); + _redFrameHotspotId = _scene->_dynamicHotspots.add(NOUN_RED_FRAME, VERB_WALK_TO, SYNTAX_SINGULAR, EXT_NONE, Common::Rect(pos.x - 5, pos.y - 5, pos.x + 5, pos.y + 1)); + _scene->_dynamicHotspots.setPosition(_redFrameHotspotId, Common::Point(pos.x + 12, pos.y), FACING_NORTHWEST); + } + + if (_game._objects[OBJ_GREEN_FRAME]._roomNumber == _globals[kCatacombsRoom] + 600) { + _globals._sequenceIndexes[3] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[3], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[3], 14); + + Common::Point pos = _scene->_sprites[_globals._spriteIndexes[2]]->getFramePos(0); + _greenFrameHotspotId = _scene->_dynamicHotspots.add(NOUN_GREEN_FRAME, VERB_WALK_TO, SYNTAX_SINGULAR, EXT_NONE, Common::Rect(pos.x - 5, pos.y - 5, pos.x + 5, pos.y + 1)); + _scene->_dynamicHotspots.setPosition(_greenFrameHotspotId, Common::Point(pos.x + 12, pos.y), FACING_NORTHWEST); + } + + if (_game._objects[OBJ_BLUE_FRAME]._roomNumber == _globals[kCatacombsRoom] + 600) { + _globals._sequenceIndexes[4] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[4], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[4], 14); + + Common::Point pos = _scene->_sprites[_globals._spriteIndexes[2]]->getFramePos(0); + _blueFrameHotspotId = _scene->_dynamicHotspots.add(NOUN_BLUE_FRAME, VERB_WALK_TO, SYNTAX_SINGULAR, EXT_NONE, Common::Rect(pos.x - 5, pos.y - 5, pos.x + 5, pos.y + 1)); + _scene->_dynamicHotspots.setPosition(_blueFrameHotspotId, Common::Point(pos.x + 12, pos.y), FACING_NORTHWEST); + } + + if (_game._objects[OBJ_YELLOW_FRAME]._roomNumber == _globals[kCatacombsRoom] + 600) { + _globals._sequenceIndexes[5] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[5], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[5], 14); + + Common::Point pos = _scene->_sprites[_globals._spriteIndexes[2]]->getFramePos(0); + _yellowFrameHotspotId = _scene->_dynamicHotspots.add(NOUN_YELLOW_FRAME, VERB_WALK_TO, SYNTAX_SINGULAR, EXT_NONE, Common::Rect(pos.x - 5, pos.y - 5, pos.x + 5, pos.y + 1)); + _scene->_dynamicHotspots.setPosition(_yellowFrameHotspotId, Common::Point(pos.x + 12, pos.y), FACING_NORTHWEST); + } + + sceneEntrySound(); +} + +void Scene456::step() { +} + +void Scene456::actions() { + if (_action.isAction(VERB_PUT) && _action.isTarget(NOUN_FLOOR)) { + if (_action.isObject(NOUN_RED_FRAME) || _action.isObject(NOUN_BLUE_FRAME) || _action.isObject(NOUN_YELLOW_FRAME) || _action.isObject(NOUN_GREEN_FRAME)) { + if (_frameInRoomFl) { + _vm->_dialogs->show(29); + } else { + switch (_game._trigger) { + case (0): + _game._player._stepEnabled = false; + _game._player._visible = false; + _globals._sequenceIndexes[1] = _scene->_sequences.startPingPongCycle(_globals._spriteIndexes[1], true, 5, 2); + _scene->_sequences.setAnimRange(_globals._sequenceIndexes[1], 1, 5); + _scene->_sequences.setSeqPlayer(_globals._sequenceIndexes[1], true); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[1], SEQUENCE_TRIGGER_SPRITE, 5, 1); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[1], SEQUENCE_TRIGGER_EXPIRE, 0, 2); + break; + + case 1: + if (_action.isObject(NOUN_RED_FRAME)) { + _game._objects.setRoom(OBJ_RED_FRAME, NOWHERE); + _game._objects[OBJ_RED_FRAME]._roomNumber = _globals[kCatacombsRoom] + 600; + _globals._sequenceIndexes[2] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[2], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[2], 14); + + Common::Point pos = _scene->_sprites[_globals._spriteIndexes[2]]->getFramePos(0); + _redFrameHotspotId = _scene->_dynamicHotspots.add(NOUN_RED_FRAME, VERB_WALK_TO, SYNTAX_SINGULAR, EXT_NONE, Common::Rect(pos.x - 5, pos.y - 5, pos.x + 5, pos.y + 1)); + _scene->_dynamicHotspots.setPosition(_redFrameHotspotId, Common::Point(pos.x + 12, pos.y), FACING_NORTHWEST); + } + + if (_action.isObject(NOUN_GREEN_FRAME)) { + _game._objects.setRoom(OBJ_GREEN_FRAME, NOWHERE); + _game._objects[OBJ_GREEN_FRAME]._roomNumber = _globals[kCatacombsRoom] + 600; + _globals._sequenceIndexes[3] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[3], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[3], 14); + + Common::Point pos = _scene->_sprites[_globals._spriteIndexes[2]]->getFramePos(0); + _greenFrameHotspotId = _scene->_dynamicHotspots.add(NOUN_GREEN_FRAME, VERB_WALK_TO, SYNTAX_SINGULAR, EXT_NONE, Common::Rect(pos.x - 5, pos.y - 5, pos.x + 5, pos.y + 1)); + _scene->_dynamicHotspots.setPosition(_greenFrameHotspotId, Common::Point(pos.x + 12, pos.y), FACING_NORTHWEST); + } + + if (_action.isObject(NOUN_BLUE_FRAME)) { + _game._objects.setRoom(OBJ_BLUE_FRAME, NOWHERE); + _game._objects[OBJ_BLUE_FRAME]._roomNumber = _globals[kCatacombsRoom] + 600; + _globals._sequenceIndexes[4] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[4], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[4], 14); + + Common::Point pos = _scene->_sprites[_globals._spriteIndexes[2]]->getFramePos(0); + _blueFrameHotspotId = _scene->_dynamicHotspots.add(NOUN_BLUE_FRAME, VERB_WALK_TO, SYNTAX_SINGULAR, EXT_NONE, Common::Rect(pos.x - 5, pos.y - 5, pos.x + 5, pos.y + 1)); + _scene->_dynamicHotspots.setPosition(_blueFrameHotspotId, Common::Point(pos.x + 12, pos.y), FACING_NORTHWEST); + } + + if (_action.isObject(NOUN_YELLOW_FRAME)) { + _game._objects.setRoom(OBJ_YELLOW_FRAME, NOWHERE); + _game._objects[OBJ_YELLOW_FRAME]._roomNumber = _globals[kCatacombsRoom] + 600; + _globals._sequenceIndexes[5] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[5], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[5], 14); + + Common::Point pos = _scene->_sprites[_globals._spriteIndexes[2]]->getFramePos(0); + _yellowFrameHotspotId = _scene->_dynamicHotspots.add(NOUN_YELLOW_FRAME, VERB_WALK_TO, SYNTAX_SINGULAR, EXT_NONE, Common::Rect(pos.x - 5, pos.y - 5, pos.x + 5, pos.y + 1)); + _scene->_dynamicHotspots.setPosition(_yellowFrameHotspotId, Common::Point(pos.x + 12, pos.y), FACING_NORTHWEST); + } + break; + + case 2: + _game.syncTimers(SYNC_PLAYER, 0, SYNC_SEQ, _globals._sequenceIndexes[1]); + _game._player._visible = true; + _game._player._stepEnabled = true; + break; + + default: + break; + } + } + _action._inProgress = false; + return; + } + } + + + if (_action.isAction(VERB_TAKE) + && (_action.isObject(NOUN_RED_FRAME) || _action.isObject(NOUN_GREEN_FRAME) || _action.isObject(NOUN_BLUE_FRAME) || _action.isObject(NOUN_YELLOW_FRAME))) { + if ((_takingFrameInRoomFl || _game._trigger)) { + switch (_game._trigger) { + case (0): + _game._player._stepEnabled = false; + _game._player._visible = false; + _globals._sequenceIndexes[1] = _scene->_sequences.startPingPongCycle(_globals._spriteIndexes[1], true, 5, 2); + _scene->_sequences.setAnimRange(_globals._sequenceIndexes[1], 1, 5); + _scene->_sequences.setSeqPlayer(_globals._sequenceIndexes[1], true); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[1], SEQUENCE_TRIGGER_SPRITE, 5, 1); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[1], SEQUENCE_TRIGGER_EXPIRE, 0, 2); + break; + + case 1: + if (_action.isObject(NOUN_RED_FRAME)) { + _scene->deleteSequence(_globals._sequenceIndexes[2]); + _scene->_dynamicHotspots.remove(_redFrameHotspotId); + _game._objects.addToInventory(OBJ_RED_FRAME); + } + + if (_action.isObject(NOUN_GREEN_FRAME)) { + _scene->deleteSequence(_globals._sequenceIndexes[3]); + _scene->_dynamicHotspots.remove(_greenFrameHotspotId); + _game._objects.addToInventory(OBJ_GREEN_FRAME); + } + + if (_action.isObject(NOUN_BLUE_FRAME)) { + _scene->deleteSequence(_globals._sequenceIndexes[4]); + _scene->_dynamicHotspots.remove(_blueFrameHotspotId); + _game._objects.addToInventory(OBJ_BLUE_FRAME); + } + + if (_action.isObject(NOUN_YELLOW_FRAME)) { + _scene->deleteSequence(_globals._sequenceIndexes[5]); + _scene->_dynamicHotspots.remove(_yellowFrameHotspotId); + _game._objects.addToInventory(OBJ_YELLOW_FRAME); + } + + _vm->_sound->command(26); + break; + + case 2: + _game.syncTimers(SYNC_PLAYER, 0, SYNC_SEQ, _globals._sequenceIndexes[1]); + _game._player._visible = true; + _game._player._stepEnabled = true; + break; + + default: + break; + } + _action._inProgress = false; + return; + } + } + + if (_action.isAction(VERB_WALK_THROUGH, NOUN_ARCHWAY_TO_WEST)) { + _game.moveCatacombs(3); + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_WALK_THROUGH, NOUN_ARCHWAY_TO_EAST)) { + _game.moveCatacombs(1); + _action._inProgress = false; + return; + } + + if (_action._lookFlag) { + _vm->_dialogs->show(45610); + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_LOOK) || _action.isAction(VERB_LOOK_AT)) { + if (_action.isObject(NOUN_WALL)) { + _vm->_dialogs->show(45611); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_FLOOR)) { + _vm->_dialogs->show(45612); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_ARCHWAY)) { + _vm->_dialogs->show(45613); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_EXPOSED_BRICK)) { + _vm->_dialogs->show(45614); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_RED_FRAME) && !_game._objects.isInInventory(OBJ_RED_FRAME)) { + _vm->_dialogs->showItem(OBJ_RED_FRAME, 802, 0); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_GREEN_FRAME) && !_game._objects.isInInventory(OBJ_GREEN_FRAME)) { + _vm->_dialogs->showItem(OBJ_GREEN_FRAME, 819, 0); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_BLUE_FRAME) && !_game._objects.isInInventory(OBJ_BLUE_FRAME)) { + _vm->_dialogs->showItem(OBJ_BLUE_FRAME, 817, 0); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_YELLOW_FRAME) && !_game._objects.isInInventory(OBJ_YELLOW_FRAME)) { + _vm->_dialogs->showItem(OBJ_YELLOW_FRAME, 804, 0); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_MORE_CATACOMBS)) { + _vm->_dialogs->show(45615); + _action._inProgress = false; + } + } +} + +void Scene456::preActions() { + _frameInRoomFl = false; + _takingFrameInRoomFl = false; + + if (_game._objects[OBJ_RED_FRAME]._roomNumber == _globals[kCatacombsRoom] + 600) { + _frameInRoomFl = true; + if (_action.isAction(VERB_TAKE, NOUN_RED_FRAME)) + _takingFrameInRoomFl = true; + } + + if (_game._objects[OBJ_YELLOW_FRAME]._roomNumber == _globals[kCatacombsRoom] + 600) { + _frameInRoomFl = true; + if (_action.isAction(VERB_TAKE, NOUN_YELLOW_FRAME)) + _takingFrameInRoomFl = true; + } + + if (_game._objects[OBJ_BLUE_FRAME]._roomNumber == _globals[kCatacombsRoom] + 600) { + _frameInRoomFl = true; + if (_action.isAction(VERB_TAKE, NOUN_BLUE_FRAME)) + _takingFrameInRoomFl = true; + } + + if (_game._objects[OBJ_GREEN_FRAME]._roomNumber == _globals[kCatacombsRoom] + 600) { + _frameInRoomFl = true; + if (_action.isAction(VERB_TAKE, NOUN_GREEN_FRAME)) + _takingFrameInRoomFl = true; + } + + if (_action.isAction(VERB_PUT) && _action.isTarget(NOUN_FLOOR) + && (_action.isObject(NOUN_RED_FRAME) || _action.isObject(NOUN_BLUE_FRAME) || _action.isObject(NOUN_YELLOW_FRAME) || _action.isObject(NOUN_GREEN_FRAME))) { + if (_frameInRoomFl) + _game._player._needToWalk = false; + else { + Common::Point pos = _scene->_sprites[_globals._spriteIndexes[2]]->getFramePos(0); + _game._player.walk(Common::Point(pos.x + 12, pos.y), FACING_NORTHWEST); + } + } +} + +/*------------------------------------------------------------------------*/ + +} // End of namespace Phantom +} // End of namespace MADS diff --git a/engines/mads/phantom/phantom_scenes4.h b/engines/mads/phantom/phantom_scenes4.h new file mode 100644 index 0000000000..5aece98cd6 --- /dev/null +++ b/engines/mads/phantom/phantom_scenes4.h @@ -0,0 +1,265 @@ +/* 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 MADS_PHANTOM_SCENES4_H +#define MADS_PHANTOM_SCENES4_H + +#include "common/scummsys.h" +#include "common/serializer.h" +#include "mads/game.h" +#include "mads/scene.h" +#include "mads/phantom/phantom_scenes.h" + +namespace MADS { + +namespace Phantom { + +class Scene4xx : public PhantomScene { +protected: + /** + * Plays an appropriate sound when entering a scene + */ + void sceneEntrySound(); + + /** + *Sets the AA file to use for the scene + */ + void setAAName(); + + /** + * Updates the prefix used for getting player sprites for the scene + */ + void setPlayerSpritesPrefix(); +public: + Scene4xx(MADSEngine *vm) : PhantomScene(vm) {} +}; + +class Scene401 : public Scene4xx { +private: + bool _anim0ActvFl; + bool _frameInRoomFl; + bool _takingFrameInRoomFl; + + int _redFrameHotspotId; + int _greenFrameHostpotId; + int _blueFrameHotspotId; + int _yellowFrameHotspotId; + +public: + Scene401(MADSEngine *vm); + virtual void synchronize(Common::Serializer &s); + + virtual void setup(); + virtual void enter(); + virtual void step(); + virtual void preActions(); + virtual void actions(); +}; + +class Scene403 : public Scene4xx { +private: + bool _frameInRoomFl; + bool _takingFrameInRoomFl; + + int _redFrameHotspotId; + int _greenFrameHostpotId; + int _blueFrameHotspotId; + int _yellowFrameHotspotId; + +public: + Scene403(MADSEngine *vm); + virtual void synchronize(Common::Serializer &s); + + virtual void setup(); + virtual void enter(); + virtual void step(); + virtual void preActions(); + virtual void actions(); +}; + +class Scene404 : public Scene4xx { +private: + bool _frameInRoomFl; + bool _takingFrameInRoomFl; + bool _anim0ActvFl; + + int _redFrameHotspotId; + int _greenFrameHostpotId; + int _blueFrameHotspotId; + int _yellowFrameHotspotId; + +public: + Scene404(MADSEngine *vm); + virtual void synchronize(Common::Serializer &s); + + virtual void setup(); + virtual void enter(); + virtual void step(); + virtual void preActions(); + virtual void actions(); +}; + +class Scene406 : public Scene4xx { +private: + bool _frameInRoomFl; + bool _takingFrameInRoomFl; + + int _redFrameHotspotId; + int _greenFrameHostpotId; + int _blueFrameHotspotId; + int _yellowFrameHotspotId; + +public: + Scene406(MADSEngine *vm); + virtual void synchronize(Common::Serializer &s); + + virtual void setup(); + virtual void enter(); + virtual void step(); + virtual void preActions(); + virtual void actions(); +}; + +class Scene407 : public Scene4xx { +private: + bool _frameInRoomFl; + bool _takingFrameInRoomFl; + + int _redFrameHotspotId; + int _greenFrameHotspotId; + int _blueFrameHotspotId; + int _yellowFrameHotspotId; + +public: + Scene407(MADSEngine *vm); + virtual void synchronize(Common::Serializer &s); + + virtual void setup(); + virtual void enter(); + virtual void step(); + virtual void preActions(); + virtual void actions(); +}; + +class Scene408 : public Scene4xx { +private: + bool _frameInRoomFl; + bool _takingFrameInRoomFl; + + int _redFrameHotspotId; + int _greenFrameHotspotId; + int _blueFrameHotspotId; + int _yellowFrameHotspotId; + +public: + Scene408(MADSEngine *vm); + virtual void synchronize(Common::Serializer &s); + + virtual void setup(); + virtual void enter(); + virtual void step(); + virtual void preActions(); + virtual void actions(); +}; + +class Scene409 : public Scene4xx { +private: + bool _frameInRoomFl; + bool _takingFrameInRoomFl; + + int _redFrameHotspotId; + int _greenFrameHotspotId; + int _blueFrameHotspotId; + int _yellowFrameHotspotId; + +public: + Scene409(MADSEngine *vm); + virtual void synchronize(Common::Serializer &s); + + virtual void setup(); + virtual void enter(); + virtual void step(); + virtual void preActions(); + virtual void actions(); +}; + +class Scene410 : public Scene4xx { +private: + int _skullSequence[26]; + void getLeverInfo(Common::Point *pos, int *type, int lever_number, int *noun); + +public: + Scene410(MADSEngine *vm); + virtual void synchronize(Common::Serializer &s); + + virtual void setup(); + virtual void enter(); + virtual void step(); + virtual void preActions(); + virtual void actions(); +}; + +class Scene453 : public Scene4xx { +private: + bool _frameInRoomFl; + bool _takingFrameInRoomFl; + + int _redFrameHotspotId; + int _greenFrameHotspotId; + int _blueFrameHotspotId; + int _yellowFrameHotspotId; + +public: + Scene453(MADSEngine *vm); + virtual void synchronize(Common::Serializer &s); + + virtual void setup(); + virtual void enter(); + virtual void step(); + virtual void preActions(); + virtual void actions(); +}; + +class Scene456 : public Scene4xx { +private: + bool _frameInRoomFl; + bool _takingFrameInRoomFl; + + int _redFrameHotspotId; + int _greenFrameHotspotId; + int _blueFrameHotspotId; + int _yellowFrameHotspotId; + +public: + Scene456(MADSEngine *vm); + virtual void synchronize(Common::Serializer &s); + + virtual void setup(); + virtual void enter(); + virtual void step(); + virtual void preActions(); + virtual void actions(); +}; +} // End of namespace Phantom +} // End of namespace MADS + +#endif /* MADS_PHANTOM_SCENES4_H */ diff --git a/engines/mads/phantom/phantom_scenes5.cpp b/engines/mads/phantom/phantom_scenes5.cpp new file mode 100644 index 0000000000..508f2b936d --- /dev/null +++ b/engines/mads/phantom/phantom_scenes5.cpp @@ -0,0 +1,4309 @@ +/* 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/scummsys.h" +#include "mads/mads.h" +#include "mads/conversations.h" +#include "mads/scene.h" +#include "mads/phantom/phantom_scenes.h" +#include "mads/phantom/phantom_scenes5.h" + +namespace MADS { + +namespace Phantom { + +void Scene5xx::setAAName() { + _game._aaName = Resources::formatAAName(1); + _vm->_palette->setEntry(254, 43, 47, 51); +} + +void Scene5xx::sceneEntrySound() { + if (!_vm->_musicFlag) + return; + + if ((_globals[kCoffinStatus] == 2) && !_game._visitedScenes.exists(506) && (_globals[kFightStatus] == 0) && (_scene->_currentSceneId == 504)) + _vm->_sound->command(33); + else if (_scene->_currentSceneId == 505) + _vm->_sound->command((_vm->_gameConv->_restoreRunning == 20) ? 39 : 16); + else + _vm->_sound->command(16); +} + +void Scene5xx::setPlayerSpritesPrefix() { + _vm->_sound->command(5); + + Common::String oldName = _game._player._spritesPrefix; + if (!_game._player._forcePrefix) + _game._player._spritesPrefix = "RAL"; + if (oldName != _game._player._spritesPrefix) + _game._player._spritesChanged = true; + + _game._player._scalingVelocity = true; +} + +/*------------------------------------------------------------------------*/ + +Scene501::Scene501(MADSEngine *vm) : Scene5xx(vm) { + _anim0ActvFl = false; + _skipFl = false; +} + +void Scene501::synchronize(Common::Serializer &s) { + Scene5xx::synchronize(s); + + s.syncAsByte(_anim0ActvFl); + s.syncAsByte(_skipFl); +} + +void Scene501::setup() { + setPlayerSpritesPrefix(); + setAAName(); + + _scene->addActiveVocab(NOUN_CHRISTINE); + _scene->addActiveVocab(VERB_LOOK_AT); + _scene->addActiveVocab(VERB_WALK_TO); +} + +void Scene501::enter() { + _scene->_hotspots.activate(NOUN_CHRISTINE, false); + _scene->_hotspots.activate(NOUN_BOAT, false); + + if (_scene->_priorSceneId != RETURNING_FROM_LOADING) { + _anim0ActvFl = false; + _skipFl = false; + } + + _vm->_gameConv->get(26); + + _globals._spriteIndexes[0] = _scene->_sprites.addSprites(formAnimName('x', 0)); + _globals._spriteIndexes[1] = _scene->_sprites.addSprites(formAnimName('x', 1)); + _globals._spriteIndexes[2] = _scene->_sprites.addSprites(formAnimName('x', 2)); + _globals._spriteIndexes[5] = _scene->_sprites.addSprites(formAnimName('a', 1)); + _globals._spriteIndexes[6] = _scene->_sprites.addSprites(formAnimName('a', 0)); + _globals._spriteIndexes[6] = _scene->_sprites.addSprites("*CHR_6", PALFLAG_ALL_TO_CLOSEST | PALFLAG_ANY_TO_CLOSEST); + _globals._spriteIndexes[6] = _scene->_sprites.addSprites("*CHR_9", PALFLAG_ALL_TO_CLOSEST | PALFLAG_ANY_TO_CLOSEST); + _globals._spriteIndexes[6] = _scene->_sprites.addSprites("*CHR_8", PALFLAG_ALL_TO_CLOSEST | PALFLAG_ANY_TO_CLOSEST); + _globals._spriteIndexes[3] = _scene->_sprites.addSprites("*RDRR_6"); + + _globals._sequenceIndexes[0] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[0], false, 6); + _scene->_sequences.setDepth(_globals._sequenceIndexes[0], 14); + _scene->_sequences.setAnimRange(_globals._sequenceIndexes[0], -1, -2); + + if (_scene->_priorSceneId == RETURNING_FROM_LOADING) { + if (_globals[kChristineIsInBoat]) { + _anim0ActvFl = true; + _globals._animationIndexes[0] = _scene->loadAnimation(formAnimName('b', 1), 100); + _scene->setAnimFrame(_globals._animationIndexes[0], 124); + _scene->_hotspots.activateAtPos(NOUN_CHRISTINE, true, Common::Point(113, 93)); + _scene->_hotspots.activate(NOUN_BOAT, true); + } + + _globals._sequenceIndexes[1] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[1], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[1], 4); + _globals._sequenceIndexes[2] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[2], false, -1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[2], 4); + } + + if (_scene->_priorSceneId == 506) { + _game._player._playerPos = Common::Point(305, 112); + _game._player._facing = FACING_WEST; + _game._player._stepEnabled = false; + + if (_globals[kChristineIsInBoat]) { + _anim0ActvFl = true; + _globals._animationIndexes[0] = _scene->loadAnimation(formAnimName('b', 1), 100); + _scene->setAnimFrame(_globals._animationIndexes[0], 124); + _scene->_hotspots.activateAtPos(NOUN_CHRISTINE, true, Common::Point(113, 93)); + _scene->_hotspots.activate(NOUN_BOAT, true); + _game._player.walk(Common::Point(260, 112), FACING_SOUTHWEST); + _game._player.setWalkTrigger(80); + _game._player.setWalkTrigger(55); + } else { + _anim0ActvFl = true; + _globals._animationIndexes[0] = _scene->loadAnimation(formAnimName('b', 1), 100); + _globals[kChristineIsInBoat] = true; + _scene->_hotspots.activate(NOUN_BOAT, true); + _game._player.walk(Common::Point(260, 112), FACING_SOUTHWEST); + _game._player.setWalkTrigger(80); + } + + _globals._sequenceIndexes[1] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[1], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[1], 4); + + _globals._sequenceIndexes[2] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[2], false, -2); + _scene->_sequences.setDepth(_globals._sequenceIndexes[2], 1); + } else if ((_scene->_priorSceneId == 401) || (_scene->_priorSceneId == 408) || (_scene->_priorSceneId != RETURNING_FROM_LOADING)) { + _game._player.firstWalk(Common::Point(-20, 109), FACING_EAST, Common::Point(24, 109), FACING_EAST, true); + _globals._sequenceIndexes[1] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[1], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[1], 4); + + _globals._sequenceIndexes[2] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[2], false, -1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[2], 4); + } + + sceneEntrySound(); +} + +void Scene501::step() { + switch (_game._trigger) { + case 55: + _scene->deleteSequence(_globals._sequenceIndexes[2]); + _globals._sequenceIndexes[2] = _scene->_sequences.addReverseSpriteCycle(_globals._spriteIndexes[2], false, 8, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[2], 10); + _scene->_sequences.setAnimRange(_globals._sequenceIndexes[2], -1, -2); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SEQUENCE_TRIGGER_EXPIRE, 0, 56); + break; + + case 56: + _vm->_sound->command(25); + _globals._sequenceIndexes[2] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[2], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[2], 10); + if (!_globals[kChrisWillTakeSeat]) + _game._player._stepEnabled = true; + + _globals[kChrisWillTakeSeat] = false; + break; + + default: + break; + } + + + switch (_game._trigger) { + case 60: + _globals._sequenceIndexes[1] = _scene->_sequences.addReverseSpriteCycle(_globals._spriteIndexes[1], false, 8, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[1], 4); + _scene->_sequences.setAnimRange(_globals._sequenceIndexes[1], -1, -2); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[1], SEQUENCE_TRIGGER_EXPIRE, 0, 61); + break; + + case 61: + _vm->_sound->command(25); + _globals._sequenceIndexes[1] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[1], false, -1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[1], 4); + _game._player._stepEnabled = true; + break; + + case 80: { + _game._player.walk(Common::Point(255, 118), FACING_NORTHWEST); + _scene->setAnimFrame(_globals._animationIndexes[0], 2); + int idx = _scene->_dynamicHotspots.add(NOUN_CHRISTINE, VERB_WALK_TO, SYNTAX_SINGULAR_FEM, EXT_NONE, Common::Rect(0, 0, 0, 0)); + _scene->setDynamicAnim(idx, _globals._animationIndexes[0], 0); + _scene->setDynamicAnim(idx, _globals._animationIndexes[0], 1); + _scene->setDynamicAnim(idx, _globals._animationIndexes[0], 2); + _scene->setDynamicAnim(idx, _globals._animationIndexes[0], 3); + } + break; + + case 90: + _globals[kPlayerScore] += 5; + _scene->_nextSceneId = 310; + break; + + case 100: + _game._player._stepEnabled = false; + _game._player._visible = false; + _globals._sequenceIndexes[5] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[5], false, 9, 1); + _scene->_sequences.setAnimRange(_globals._sequenceIndexes[5], -1, -2); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[5], SEQUENCE_TRIGGER_EXPIRE, 0, 90); + break; + + default: + break; + } + + if (_anim0ActvFl) { + if (_scene->_animation[_globals._animationIndexes[0]]->getCurrentFrame() == 103) + _scene->_hotspots.activateAtPos(NOUN_CHRISTINE, true, Common::Point(125, 94)); + + if ((_scene->_animation[_globals._animationIndexes[0]]->getCurrentFrame() == 28) && !_skipFl) { + _skipFl = true; + _scene->_sequences.addTimer(1, 55); + } + + if (_scene->_animation[_globals._animationIndexes[0]]->getCurrentFrame() == 124) { + _scene->_hotspots.activateAtPos(NOUN_CHRISTINE, false, Common::Point(125, 94)); + _scene->_hotspots.activateAtPos(NOUN_CHRISTINE, true , Common::Point(113, 93)); + } + + if (_scene->_animation[_globals._animationIndexes[0]]->getCurrentFrame() == 125) + _scene->setAnimFrame(_globals._animationIndexes[0], 124); + + if (_scene->_animation[_globals._animationIndexes[0]]->getCurrentFrame() == 1) + _scene->setAnimFrame(_globals._animationIndexes[0], 0); + + if (_scene->_animation[_globals._animationIndexes[0]]->getCurrentFrame() == 84) + _game._player._stepEnabled = true; + } +} + +void Scene501::actions() { + if (_vm->_gameConv->_running == 26) { + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_WALK_THROUGH, NOUN_ARCHWAY_TO_WEST) && (_globals[kChristineIsInBoat])) { + _vm->_gameConv->run(26); + _vm->_gameConv->exportValue(3); + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_TALK_TO, NOUN_CHRISTINE)) { + _vm->_gameConv->run(26); + _vm->_gameConv->exportValue(1); + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_CLIMB_INTO, NOUN_BOAT)) { + if (_game._objects.isInInventory(OBJ_OAR)) + _anim0ActvFl = false; + else + _vm->_dialogs->show(50123); + + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_UNLOCK, NOUN_DOOR) || _action.isAction(VERB_LOCK, NOUN_DOOR)) { + switch (_game._trigger) { + case 0: + _game._player._stepEnabled = false; + _game._player._visible = false; + _globals._sequenceIndexes[3] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[3], false, 5, 1); + _scene->_sequences.setAnimRange(_globals._sequenceIndexes[3], 1, 4); + _scene->_sequences.setSeqPlayer(_globals._sequenceIndexes[3], true); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SEQUENCE_TRIGGER_EXPIRE, 0, 1); + break; + + case 1: { + int idx = _globals._sequenceIndexes[3]; + _globals._sequenceIndexes[3] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[3], false, 4); + _game.syncTimers(SYNC_SEQ, _globals._sequenceIndexes[3], SYNC_SEQ, idx); + _scene->_sequences.setSeqPlayer(_globals._sequenceIndexes[3], false); + _scene->_sequences.addTimer(15, 2); + _vm->_sound->command(74); + } + break; + + case 2: + _scene->deleteSequence(_globals._sequenceIndexes[3]); + _globals._sequenceIndexes[3] = _scene->_sequences.addReverseSpriteCycle(_globals._spriteIndexes[3], false, 5, 1); + _scene->_sequences.setAnimRange(_globals._sequenceIndexes[3], 1, 4); + _scene->_sequences.setSeqPlayer(_globals._sequenceIndexes[3], false); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SEQUENCE_TRIGGER_EXPIRE, 0, 3); + break; + + case 3: + _game.syncTimers(SYNC_PLAYER, 0, SYNC_SEQ, _globals._sequenceIndexes[3]); + _game._player._visible = true; + _vm->_dialogs->show(50122); + _game._player._stepEnabled = true; + break; + + default: + break; + } + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_WALK_THROUGH, NOUN_DOOR) || _action.isAction(VERB_OPEN, NOUN_DOOR)) { + if (_scene->_customDest.x < 287) { + if (!_globals[kChristineIsInBoat]) { + switch (_game._trigger) { + case 0: + _game._player._stepEnabled = false; + _game._player._visible = false; + _globals._sequenceIndexes[3] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[3], false, 5, 1); + _scene->_sequences.setAnimRange(_globals._sequenceIndexes[3], 1, 4); + _scene->_sequences.setSeqPlayer(_globals._sequenceIndexes[3], true); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SEQUENCE_TRIGGER_EXPIRE, 0, 1); + break; + + case 1: { + int idx = _globals._sequenceIndexes[3]; + _globals._sequenceIndexes[3] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[3], false, 4); + _game.syncTimers(SYNC_SEQ, _globals._sequenceIndexes[3], SYNC_SEQ, idx); + _scene->_sequences.setSeqPlayer(_globals._sequenceIndexes[3], false); + _scene->_sequences.addTimer(15, 2); + _vm->_sound->command(74); + } + break; + + case 2: + _scene->deleteSequence(_globals._sequenceIndexes[3]); + _globals._sequenceIndexes[3] = _scene->_sequences.addReverseSpriteCycle(_globals._spriteIndexes[3], false, 5, 1); + _scene->_sequences.setAnimRange(_globals._sequenceIndexes[3], 1, 4); + _scene->_sequences.setSeqPlayer(_globals._sequenceIndexes[3], false); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SEQUENCE_TRIGGER_EXPIRE, 0, 3); + break; + + case 3: + _game.syncTimers(SYNC_PLAYER, 0, SYNC_SEQ, _globals._sequenceIndexes[3]); + _game._player._visible = true; + _vm->_dialogs->show(50120); + _game._player._stepEnabled = true; + break; + + default: + break; + } + } else { + switch (_game._trigger) { + case (0): + _game._player._stepEnabled = false; + _game._player._visible = false; + _globals._sequenceIndexes[3] = _scene->_sequences.startPingPongCycle(_globals._spriteIndexes[3], false, 5, 2); + _scene->_sequences.setAnimRange(_globals._sequenceIndexes[3], 1, 4); + _scene->_sequences.setSeqPlayer(_globals._sequenceIndexes[3], true); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SEQUENCE_TRIGGER_SPRITE, 4, 65); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SEQUENCE_TRIGGER_EXPIRE, 0, 67); + break; + + case 65: + _scene->deleteSequence(_globals._sequenceIndexes[2]); + _globals._sequenceIndexes[2] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[2], false, 8, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[2], 4); + _scene->_sequences.setAnimRange(_globals._sequenceIndexes[2], -1, -2); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SEQUENCE_TRIGGER_EXPIRE, 0, 66); + _vm->_sound->command(24); + break; + + case 66: + _globals._sequenceIndexes[2] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[2], false, -2); + _scene->_sequences.setDepth(_globals._sequenceIndexes[2], 1); + _game._player.walk(Common::Point(305, 112), FACING_EAST); + _game._player.setWalkTrigger(68); + break; + + case 67: + _game._player._visible = true; + break; + + case 68: + _vm->_gameConv->abortConv(); + _scene->_nextSceneId = 506; + break; + } + } + } else { + if (!_globals[kChristineIsInBoat]) { + switch (_game._trigger) { + case (0): + _game._player._stepEnabled = false; + _game._player._visible = false; + _globals._sequenceIndexes[3] = _scene->_sequences.startPingPongCycle(_globals._spriteIndexes[3], false, 5, 2); + _scene->_sequences.setAnimRange(_globals._sequenceIndexes[3], 1, 4); + _scene->_sequences.setSeqPlayer(_globals._sequenceIndexes[3], true); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SEQUENCE_TRIGGER_SPRITE, 4, 65); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SEQUENCE_TRIGGER_EXPIRE, 0, 67); + break; + + case 65: { + int idx = _globals._sequenceIndexes[1]; + _scene->deleteSequence(_globals._sequenceIndexes[1]); + _globals._sequenceIndexes[1] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[1], false, 8, 1); + _game.syncTimers(SYNC_SEQ, _globals._sequenceIndexes[1], SYNC_SEQ, idx); + _scene->_sequences.setDepth(_globals._sequenceIndexes[1], 4); + _scene->_sequences.setAnimRange(_globals._sequenceIndexes[1], -1, -2); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[1], SEQUENCE_TRIGGER_EXPIRE, 0, 66); + _vm->_sound->command(24); + } + break; + + case 66: + _game._player.walk(Common::Point(319, 116), FACING_NORTHWEST); + _game._player.setWalkTrigger(68); + break; + + case 67: + _game._player._visible = true; + break; + + case 68: + _globals._sequenceIndexes[1] = _scene->_sequences.addReverseSpriteCycle(_globals._spriteIndexes[1], false, 8, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[1], 1); + _scene->_sequences.setAnimRange(_globals._sequenceIndexes[1], -1, -2); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[1], SEQUENCE_TRIGGER_EXPIRE, 0, 69); + _vm->_sound->command(25); + break; + + case 69: + _globals._sequenceIndexes[1] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[1], false, 5); + _scene->_sequences.setDepth(_globals._sequenceIndexes[1], 1); + _scene->_nextSceneId = 502; + break; + } + } else { + switch (_game._trigger) { + case (0): + _game._player._stepEnabled = false; + _game._player._visible = false; + _globals._sequenceIndexes[3] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[3], false, 5, 1); + _scene->_sequences.setAnimRange(_globals._sequenceIndexes[3], 1, 4); + _scene->_sequences.setSeqPlayer(_globals._sequenceIndexes[3], true); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SEQUENCE_TRIGGER_EXPIRE, 0, 1); + break; + + case 1: { + int idx = _globals._sequenceIndexes[3]; + _globals._sequenceIndexes[3] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[3], false, 4); + _game.syncTimers(SYNC_SEQ, _globals._sequenceIndexes[3], SYNC_SEQ, idx); + _scene->_sequences.setSeqPlayer(_globals._sequenceIndexes[3], false); + _scene->_sequences.addTimer(15, 2); + _vm->_sound->command(73); + } + break; + + case 2: + _scene->deleteSequence(_globals._sequenceIndexes[3]); + _globals._sequenceIndexes[3] = _scene->_sequences.addReverseSpriteCycle(_globals._spriteIndexes[3], false, 5, 1); + _scene->_sequences.setAnimRange(_globals._sequenceIndexes[3], 1, 4); + _scene->_sequences.setSeqPlayer(_globals._sequenceIndexes[3], false); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SEQUENCE_TRIGGER_EXPIRE, 0, 3); + break; + + case 3: + _game.syncTimers(SYNC_PLAYER, 0, SYNC_SEQ, _globals._sequenceIndexes[3]); + _game._player._visible = true; + _vm->_dialogs->show(50120); + _game._player._stepEnabled = true; + break; + + default: + break; + } + } + } + _action._inProgress = false; + return; + } + + if (_action._lookFlag) { + _vm->_dialogs->show(50110); + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_LOOK) || _action.isAction(VERB_LOOK_AT)) { + if (_action.isObject(NOUN_FLOOR)) { + _vm->_dialogs->show(50111); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_WALL)) { + _vm->_dialogs->show(50112); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_CEILING)) { + _vm->_dialogs->show(50113); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_LAKE)) { + _vm->_dialogs->show(50114); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_BOAT)) { + _vm->_dialogs->show(50126); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_TORCH)) { + _vm->_dialogs->show(50117); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_ARCHWAY_TO_WEST)) { + _vm->_dialogs->show(50118); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_DOOR)) { + if (_scene->_customDest.x < 287) { + if (_game._visitedScenes.exists(506)) + _vm->_dialogs->show(50127); + else + _vm->_dialogs->show(50119); + } else { + if (_game._visitedScenes.exists(506)) + _vm->_dialogs->show(50128); + else + _vm->_dialogs->show(50119); + } + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_COLUMN)) { + _vm->_dialogs->show(50121); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_CHRISTINE)) { + _vm->_dialogs->show(50124); + _action._inProgress = false; + return; + } + } + + if (_action.isAction(VERB_TAKE, NOUN_TORCH)) { + _vm->_dialogs->show(50125); + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_TAKE, NOUN_CHRISTINE)) { + _vm->_dialogs->show(50129); + _action._inProgress = false; + } +} + +void Scene501::preActions() { + if (_action.isAction(VERB_WALK_THROUGH, NOUN_ARCHWAY_TO_WEST)) { + if (_globals[kLanternStatus] == 0) { + _game._player._needToWalk = false; + _vm->_dialogs->show(30918); + _game._player.cancelCommand(); + } else if (!_globals[kChristineIsInBoat]) + _game.enterCatacombs(0); + } + + if ((_action.isObject(NOUN_DOOR)) && (_action.isAction(VERB_LOCK) || _action.isAction(VERB_UNLOCK) || _action.isAction(VERB_OPEN))) { + if (_scene->_customDest.x < 287) + _game._player.walk(Common::Point(266, 112), FACING_EAST); + else + _game._player.walk(Common::Point(287, 118), FACING_EAST); + } + + if ((_action.isAction(VERB_WALK_THROUGH, NOUN_DOOR) || _action.isAction(VERB_OPEN, NOUN_DOOR)) && _game._visitedScenes.exists(506) && _scene->_customDest.x < 287) { + switch (_game._trigger) { + case 0: + _game._player._readyToWalk = false; + _game._player._needToWalk = false; + _game._player._stepEnabled = false; + _vm->_gameConv->run(26); + _vm->_gameConv->exportValue(2); + _scene->_sequences.addTimer(6, 1); + break; + + case 1: + if (_vm->_gameConv->_running >= 0) + _scene->_sequences.addTimer(6, 1); + else { + _game._player._stepEnabled = true; + _action._inProgress = true; + _game._player._needToWalk = true; + _game._player._readyToWalk = true; + } + break; + + default: + break; + } + } + + if (_action.isAction(VERB_WALK_THROUGH, NOUN_ARCHWAY_TO_WEST) && _globals[kLanternStatus] && _globals[kRightDoorIsOpen504]) + _game._player.walk(Common::Point(24, 110), FACING_WEST); +} + +/*------------------------------------------------------------------------*/ + +Scene502::Scene502(MADSEngine *vm) : Scene5xx(vm) { + _fire1ActiveFl = false; + _fire2ActiveFl = false; + _fire3ActiveFl = false; + _fire4ActiveFl = false; + _panelTurningFl = false; + _trapDoorHotspotEnabled = false; + _acceleratedFireActivationFl = false; + + for (int i = 0; i < 16; i++) { + _puzzlePictures[i] = -1; + _puzzleSprites[i] = -1; + _puzzleSequences[i] = -1; + } + + _panelPushedNum = -1; + _messageLevel = -1; + _cycleStage = -1; + + _nextPos = Common::Point(-1, -1); + + _lastFrameTime = 0; + _timer = 0; + _deathTimer = 0; + + _cyclePointer = nullptr; +} + +Scene502::~Scene502() { + if (_cyclePointer) + delete(_cyclePointer); +} + +void Scene502::synchronize(Common::Serializer &s) { + Scene5xx::synchronize(s); + + s.syncAsByte(_fire1ActiveFl); + s.syncAsByte(_fire2ActiveFl); + s.syncAsByte(_fire3ActiveFl); + s.syncAsByte(_fire4ActiveFl); + s.syncAsByte(_panelTurningFl); + s.syncAsByte(_trapDoorHotspotEnabled); + s.syncAsByte(_acceleratedFireActivationFl); + + for (int i = 0; i < 16; i++) { + s.syncAsSint16LE(_puzzlePictures[i]); + s.syncAsSint16LE(_puzzleSprites[i]); + s.syncAsSint16LE(_puzzleSequences[i]); + } + + s.syncAsSint16LE(_panelPushedNum); + s.syncAsSint16LE(_messageLevel); + s.syncAsSint16LE(_cycleStage); + + s.syncAsSint16LE(_nextPos.x); + s.syncAsSint16LE(_nextPos.y); + + s.syncAsUint32LE(_lastFrameTime); + s.syncAsUint32LE(_timer); + s.syncAsUint32LE(_deathTimer); + + warning("more syncing required"); +} + +void Scene502::setup() { + setPlayerSpritesPrefix(); + setAAName(); +} + +void Scene502::enter() { + loadCyclingInfo(); + _scene->loadSpeech(7); + + _panelPushedNum = -1; + _panelTurningFl = false; + _fire1ActiveFl = false; + _fire2ActiveFl = false; + _fire3ActiveFl = false; + _fire4ActiveFl = false; + + if (_scene->_priorSceneId != RETURNING_FROM_LOADING) { + _lastFrameTime = _scene->_frameStartTime; + _cycleStage = 0; + _timer = 0; + _deathTimer = 0; + _messageLevel = 1; + _acceleratedFireActivationFl = true; + _trapDoorHotspotEnabled = false; + } + + _scene->_hotspots.activate(NOUN_ROPE, false); + _scene->_hotspots.activateAtPos(NOUN_TRAP_DOOR, false, Common::Point(225, 28)); + + _globals._spriteIndexes[0] = _scene->_sprites.addSprites(formAnimName('x', 2)); + _globals._spriteIndexes[1] = _scene->_sprites.addSprites(formAnimName('x', 3)); + _globals._spriteIndexes[2] = _scene->_sprites.addSprites(formAnimName('x', 4)); + _globals._spriteIndexes[3] = _scene->_sprites.addSprites(formAnimName('x', 5)); + _globals._spriteIndexes[4] = _scene->_sprites.addSprites(formAnimName('a', 2)); + _globals._spriteIndexes[5] = _scene->_sprites.addSprites(formAnimName('x', 0)); + _globals._spriteIndexes[6] = _scene->_sprites.addSprites(formAnimName('x', 1)); + _globals._spriteIndexes[7] = _scene->_sprites.addSprites(formAnimName('a', 1)); + _globals._spriteIndexes[8] = _scene->_sprites.addSprites(formAnimName('a', 3)); + _globals._spriteIndexes[9] = _scene->_sprites.addSprites(formAnimName('x', 6)); + _globals._spriteIndexes[10] = _scene->_sprites.addSprites(formAnimName('a', 0)); + _globals._spriteIndexes[11] = _scene->_sprites.addSprites(formAnimName('j', 0)); + _globals._spriteIndexes[12] = _scene->_sprites.addSprites(formAnimName('k', 0)); + _globals._spriteIndexes[13] = _scene->_sprites.addSprites(formAnimName('l', 0)); + _globals._spriteIndexes[14] = _scene->_sprites.addSprites(formAnimName('m', 0)); + _globals._spriteIndexes[16] = _scene->_sprites.addSprites(formAnimName('h', 0)); + + if (_scene->_priorSceneId != RETURNING_FROM_LOADING) { + _globals._sequenceIndexes[5] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[5], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[5], 14); + } else + _scene->drawToBackground(_globals._spriteIndexes[5], -2, Common::Point(-32000, -32000), 0, 100); + + if ((_scene->_priorSceneId == 501) || (_scene->_priorSceneId != RETURNING_FROM_LOADING)) { + if (!_game._visitedScenes._sceneRevisited) { + if (_game._objects.isInInventory(OBJ_ROPE)) + _globals[kCableHookWasSeparate] = true; + else + _globals[kCableHookWasSeparate] = false; + } else if (_globals[kCableHookWasSeparate]) { + _game._objects.addToInventory(OBJ_ROPE); + _game._objects.addToInventory(OBJ_CABLE_HOOK); + _game._objects.setRoom(OBJ_ROPE_WITH_HOOK, NOWHERE); + } else { + _game._objects.setRoom(OBJ_ROPE, NOWHERE); + _game._objects.setRoom(OBJ_CABLE_HOOK, NOWHERE); + _game._objects.addToInventory(OBJ_ROPE_WITH_HOOK); + } + + _game._player._playerPos = Common::Point(43, 154); + _game._player._facing = FACING_EAST; + _game._player._stepEnabled = false; + _game._player.walk(Common::Point(87, 153), FACING_EAST); + _game._player.setWalkTrigger(77); + } + + room_502_initialize_panels(); + + if (_trapDoorHotspotEnabled) { + _globals._sequenceIndexes[6] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[6], false, 6); + _scene->_sequences.setDepth(_globals._sequenceIndexes[6], 1); + _scene->_hotspots.activate(NOUN_TRAP_DOOR, false); + _scene->_hotspots.activateAtPos(NOUN_TRAP_DOOR, true, Common::Point(225, 28)); + if (!_game._objects.isInInventory(OBJ_ROPE_WITH_HOOK) && !_game._objects.isInInventory(OBJ_CABLE_HOOK)) { + _globals._sequenceIndexes[9] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[9], false, -2); + _scene->_sequences.setDepth(_globals._sequenceIndexes[9], 12); + _scene->_hotspots.activate(NOUN_ROPE, true); + } + } else { + _globals._sequenceIndexes[6] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[6], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[6], 14); + } + + sceneEntrySound(); +} + +void Scene502::step() { + if (_acceleratedFireActivationFl) { + int32 diff = _scene->_frameStartTime - _lastFrameTime; + if ((diff >= 0) && (diff <= 4)) { + _timer += diff; + _deathTimer += diff; + } else { + _timer += 1; + _deathTimer += 1; + } + _lastFrameTime = _scene->_frameStartTime; + + if (_timer >= 300) { + _timer = 0; + if (_cycleStage < 8) + ++_cycleStage; + } + } + + if ((_deathTimer >= 7200) && !_panelTurningFl) { + _vm->_dialogs->show(50215); + _game._player.walk(Common::Point(160, 148), FACING_NORTH); + _game._player.setWalkTrigger(71); + _game._player._stepEnabled = false; + _panelTurningFl = true; + _deathTimer = 0; + } + + if ((_deathTimer > 900) && (_messageLevel == 1) && !_panelTurningFl) { + _messageLevel = 2; + _vm->_dialogs->show(50212); + } + + if ((_deathTimer > 3600) && (_messageLevel == 2) && !_panelTurningFl) { + _messageLevel = 3; + _vm->_dialogs->show(50213); + } + + if ((_deathTimer > 5400) && (_messageLevel == 3) && !_panelTurningFl) { + _messageLevel = 4; + _vm->_dialogs->show(50214); + } + + switch (_game._trigger) { + case 71: + _game._player._stepEnabled = false; + _game._player._visible = false; + _globals._sequenceIndexes[4] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[4], false, 7, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[4], 1); + _scene->_sequences.setAnimRange(_globals._sequenceIndexes[4], -1, -2); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[4], SEQUENCE_TRIGGER_EXPIRE, 0, 72); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[4], SEQUENCE_TRIGGER_SPRITE, 44, 73); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[4], SEQUENCE_TRIGGER_SPRITE, 51, 74); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[4], SEQUENCE_TRIGGER_SPRITE, 32, 75); + break; + + case 72: + _globals._sequenceIndexes[4] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[4], false, -2); + _scene->_sequences.setDepth(_globals._sequenceIndexes[4], 1); + _scene->_userInterface.noInventoryAnim(); + // CHECKME: Not sure about the next function call + _scene->_userInterface.refresh(); + _scene->_sequences.addTimer(120, 76); + break; + + case 73: + _vm->_sound->command(1); + _vm->_sound->command(67); + break; + + case 74: + _vm->_sound->command(27); + break; + + case 75: + _scene->playSpeech(7); + break; + + case 76: + _scene->_reloadSceneFlag = true; + break; + + case 77: + _scene->deleteSequence(_globals._sequenceIndexes[5]); + _globals._sequenceIndexes[5] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[5], false, 7, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[5], 1); + _scene->_sequences.setAnimRange(_globals._sequenceIndexes[5], -1, -2); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[5], SEQUENCE_TRIGGER_EXPIRE, 0, 78); + break; + + case 78: + _vm->_dialogs->show(50211); + _scene->drawToBackground(_globals._spriteIndexes[5], -2, Common::Point(-32000, -32000), 0, 100); + _game._player._stepEnabled = true; + break; + + default: + break; + } + + if (!_trapDoorHotspotEnabled) + animateFireBursts(); + + setPaletteCycle(); +} + +void Scene502::actions() { + if (_game._trigger >= 110) { + handlePanelAnimation(); + _action._inProgress = false; + return; + } + + switch (_game._trigger) { + case 80: + _globals._sequenceIndexes[6] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[6], false, 6); + _scene->_hotspots.activateAtPos(NOUN_ROPE, true, Common::Point(225, 28)); + _scene->_sequences.setDepth(_globals._sequenceIndexes[6], 1); + _scene->_hotspots.activate(NOUN_TRAP_DOOR, false); + _scene->_hotspots.activateAtPos(NOUN_TRAP_DOOR, true, Common::Point(225, 28)); + if (!_panelTurningFl) + _vm->_dialogs->show(50216); + + _action._inProgress = false; + return; + + case 90: + _game._player._stepEnabled = false; + _game._player._visible = false; + _globals._sequenceIndexes[10] = _scene->_sequences.startPingPongCycle(_globals._spriteIndexes[10], false, 7, 2); + _scene->_sequences.setSeqPlayer(_globals._sequenceIndexes[10], true); + _scene->_sequences.setDepth(_globals._sequenceIndexes[10], 1); + _scene->_sequences.setAnimRange(_globals._sequenceIndexes[10], 14, 18); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[10], SEQUENCE_TRIGGER_EXPIRE, 0, 91); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[10], SEQUENCE_TRIGGER_SPRITE, 18, 110); + _action._inProgress = false; + return; + + case 91: + _game.syncTimers(SYNC_PLAYER, 0, SYNC_SEQ, _globals._sequenceIndexes[10]); + _game._player._visible = true; + _game._player._stepEnabled = true; + _scene->_sequences.addTimer(5, 102); + _action._inProgress = false; + return; + + case 95: + _game._player._stepEnabled = false; + _game._player._visible = false; + _globals._sequenceIndexes[10] = _scene->_sequences.startPingPongCycle(_globals._spriteIndexes[10], false, 7, 2); + _scene->_sequences.setSeqPlayer(_globals._sequenceIndexes[10], true); + _scene->_sequences.setDepth(_globals._sequenceIndexes[10], 1); + _scene->_sequences.setAnimRange(_globals._sequenceIndexes[10], 8, 13); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[10], SEQUENCE_TRIGGER_EXPIRE, 0, 96); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[10], SEQUENCE_TRIGGER_SPRITE, 13, 110); + _action._inProgress = false; + return; + + case 96: + _game.syncTimers(SYNC_PLAYER, 0, SYNC_SEQ, _globals._sequenceIndexes[10]); + _game._player._visible = true; + _game._player._stepEnabled = true; + _scene->_sequences.addTimer(5, 102); + _action._inProgress = false; + return; + + case 100: + _game._player._stepEnabled = false; + _game._player._visible = false; + _globals._sequenceIndexes[10] = _scene->_sequences.startPingPongCycle(_globals._spriteIndexes[10], false, 9, 2); + _scene->_sequences.setSeqPlayer(_globals._sequenceIndexes[10], true); + _scene->_sequences.setDepth(_globals._sequenceIndexes[10], 1); + _scene->_sequences.setAnimRange(_globals._sequenceIndexes[10], 5, 7); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[10], SEQUENCE_TRIGGER_EXPIRE, 0, 101); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[10], SEQUENCE_TRIGGER_SPRITE, 7, 110); + _action._inProgress = false; + return; + + case 101: + _game.syncTimers(SYNC_PLAYER, 0, SYNC_SEQ, _globals._sequenceIndexes[10]); + _game._player._visible = true; + _scene->_sequences.addTimer(5, 102); + _action._inProgress = false; + return; + + case 102: + _panelTurningFl = false; + _game._player._stepEnabled = true; + _action._inProgress = false; + return; + + case 105: + _game._player._stepEnabled = false; + _game._player._visible = false; + _globals._sequenceIndexes[10] = _scene->_sequences.startPingPongCycle(_globals._spriteIndexes[10], false, 8, 2); + _scene->_sequences.setSeqPlayer(_globals._sequenceIndexes[10], true); + _scene->_sequences.setDepth(_globals._sequenceIndexes[10], 1); + _scene->_sequences.setAnimRange(_globals._sequenceIndexes[10], 1, 4); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[10], SEQUENCE_TRIGGER_EXPIRE, 0, 106); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[10], SEQUENCE_TRIGGER_SPRITE, 4, 110); + _action._inProgress = false; + return; + + case 106: + _game.syncTimers(SYNC_PLAYER, 0, SYNC_SEQ, _globals._sequenceIndexes[10]); + _game._player._visible = true; + _scene->_sequences.addTimer(5, 102); + _action._inProgress = false; + return; + + default: + break; + } + + if (_action.isAction(VERB_PUSH, NOUN_PANEL)) { + if (_panelTurningFl) { + _action._inProgress = false; + return; + } + + Common::Point walkToPos; + getPanelInfo(&walkToPos, &_panelPushedNum, _scene->_customDest, &_nextPos); + _panelTurningFl = true; + + switch (_panelPushedNum) { + case 0: + case 1: + case 2: + case 3: + _scene->_sequences.addTimer(1, 90); + break; + + case 4: + case 5: + case 6: + case 7: + _scene->_sequences.addTimer(1, 95); + break; + + case 8: + case 9: + case 10: + case 11: + _scene->_sequences.addTimer(1, 100); + break; + + default: + _scene->_sequences.addTimer(1, 105); + break; + } + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_THROW, NOUN_ROPE_WITH_HOOK, NOUN_TRAP_DOOR) || _action.isAction(VERB_GRAPPLE, NOUN_TRAP_DOOR)) { + if (_trapDoorHotspotEnabled) { + switch (_game._trigger) { + case 0: + _game._player._stepEnabled = false; + _game._player._visible = false; + _panelTurningFl = true; + _globals._sequenceIndexes[7] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[7], false, 6, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[7], 13); + _scene->_sequences.setAnimRange(_globals._sequenceIndexes[7], -1, -2); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[7], SEQUENCE_TRIGGER_EXPIRE, 0, 82); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[7], SEQUENCE_TRIGGER_SPRITE, 10, 83); + _game._objects.setRoom(OBJ_ROPE_WITH_HOOK, NOWHERE); + break; + + case 82: + _game._player._stepEnabled = true; + _game._player._visible = true; + _panelTurningFl = false; + _game.syncTimers(SYNC_PLAYER, 0, SYNC_SEQ, _globals._sequenceIndexes[7]); + _globals._sequenceIndexes[9] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[9], false, -2); + _scene->_sequences.setDepth(_globals._sequenceIndexes[9], 13); + _scene->_hotspots.activate(NOUN_ROPE, true); + break; + + case 83: + _vm->_sound->command(69); + break; + + default: + break; + } + } else + _vm->_dialogs->show(50229); + + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_CLIMB_THROUGH, NOUN_TRAP_DOOR) + && (_game._objects.isInInventory(OBJ_ROPE_WITH_HOOK) || _game._objects.isInInventory(OBJ_CABLE_HOOK))) { + _vm->_dialogs->show(50228); + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_THROW, NOUN_ROPE, NOUN_TRAP_DOOR)) { + _vm->_dialogs->show(50226); + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_THROW, NOUN_CABLE_HOOK, NOUN_TRAP_DOOR)) { + _vm->_dialogs->show(50227); + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_CLIMB, NOUN_ROPE) || _action.isAction(VERB_CLIMB_THROUGH, NOUN_TRAP_DOOR)) { + switch (_game._trigger) { + case 0: + _globals[kPlayerScore] += 5; + _game._player._stepEnabled = false; + _game._player._visible = false; + _panelTurningFl = true; + _globals._sequenceIndexes[8] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[8], false, 6, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[8], 10); + _scene->_sequences.setAnimRange(_globals._sequenceIndexes[8], -1, -2); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[8], SEQUENCE_TRIGGER_EXPIRE, 0, 82); + break; + + case 82: + _scene->_nextSceneId = 504; + break; + + default: + break; + } + _action._inProgress = false; + return; + } + + if (_action._lookFlag) { + _vm->_dialogs->show(50210); + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_LOOK) || _action.isAction(VERB_LOOK_AT)) { + if (_action.isObject(NOUN_FLOOR)) { + _vm->_dialogs->show(50217); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_TRAP_DOOR)) { + _vm->_dialogs->show(_trapDoorHotspotEnabled ? 50220 : 50225); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_WALL)) { + _vm->_dialogs->show(50219); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_DOOR)) { + _vm->_dialogs->show(50221); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_PANELS)) { + _vm->_dialogs->show(50222); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_PANEL)) { + _vm->_dialogs->show(50223); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_CEILING)) { + _vm->_dialogs->show(50224); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_ROPE) && !_game._objects.isInInventory(OBJ_ROPE) + && !_game._objects.isInInventory(OBJ_CABLE_HOOK) && !_game._objects.isInInventory(OBJ_ROPE_WITH_HOOK)) { + _vm->_dialogs->show(50233); + _action._inProgress = false; + return; + } + } + + if (_action.isAction(VERB_OPEN, NOUN_TRAP_DOOR)) { + _vm->_dialogs->show(_trapDoorHotspotEnabled ? 50230 : 50228); + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_CLOSE, NOUN_TRAP_DOOR)) { + _vm->_dialogs->show(_trapDoorHotspotEnabled ? 50228 : 50231); + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_TAKE, NOUN_ROPE) && !_game._objects.isInInventory(OBJ_ROPE) + && !_game._objects.isInInventory(OBJ_CABLE_HOOK) && !_game._objects.isInInventory(OBJ_ROPE_WITH_HOOK)) { + _vm->_dialogs->show(50234); + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_LASSO, NOUN_TRAP_DOOR)) { + _vm->_dialogs->show(50232); + _action._inProgress = false; + return; + } +} + +void Scene502::preActions() { + int panel; + + if (_action.isAction(VERB_PUSH, NOUN_PANEL)) { + Common::Point walkToPos; + Common::Point tmpPos; + getPanelInfo(&walkToPos, &panel, _scene->_customDest, &tmpPos); + _game._player.walk(walkToPos, FACING_NORTH); + } + + if (_trapDoorHotspotEnabled && (_action.isAction(VERB_CLIMB, NOUN_ROPE) || _action.isAction(VERB_CLIMB_THROUGH, NOUN_TRAP_DOOR))) + _game._player.walk(Common::Point(211, 149), FACING_NORTH); + + if (_trapDoorHotspotEnabled && (_action.isAction(VERB_THROW, NOUN_ROPE_WITH_HOOK, NOUN_TRAP_DOOR) || _action.isAction(VERB_GRAPPLE, NOUN_TRAP_DOOR))) + _game._player.walk(Common::Point(200, 149), FACING_NORTH); +} + +void Scene502::room_502_initialize_panels() { + for (int i = 0, curPuzzleSprite = 2, count = 1; i < 16; i++) { + if (_scene->_priorSceneId != RETURNING_FROM_LOADING) + _puzzlePictures[i] = _vm->getRandomNumber(1, 4); + + curPuzzleSprite += (_puzzlePictures[i] * 3) - 3; + _puzzleSprites[i] = curPuzzleSprite; + + int sprIdx; + + switch (i) { + case 0: + case 1: + case 2: + case 3: + sprIdx = _globals._spriteIndexes[11]; + break; + + case 4: + case 5: + case 6: + case 7: + sprIdx = _globals._spriteIndexes[12]; + break; + + case 8: + case 9: + case 10: + case 11: + sprIdx = _globals._spriteIndexes[13]; + break; + + default: + sprIdx = _globals._spriteIndexes[14]; + break; + } + + _globals._sequenceIndexes[15] = _scene->_sequences.addStampCycle(sprIdx, false, curPuzzleSprite); + _scene->_sequences.setDepth(_globals._sequenceIndexes[15], 14); + _puzzleSequences[i] = _globals._sequenceIndexes[15]; + + ++count; + if (count >= 5) + count = 1; + + switch (count) { + case 1: + curPuzzleSprite = 2; + break; + + case 2: + curPuzzleSprite = 14; + break; + + case 3: + curPuzzleSprite = 26; + break; + + case 4: + curPuzzleSprite = 38; + break; + } + } +} + +void Scene502::loadCyclingInfo() { + warning("TODO: loadCyclingInfo"); +} + +void Scene502::animateFireBursts() { + int rndTrigger; + + if (_acceleratedFireActivationFl) + rndTrigger = _vm->getRandomNumber(1, 50); + else + rndTrigger = _vm->getRandomNumber(1, 400); + + if (rndTrigger == 1) { + rndTrigger = _vm->getRandomNumber(1, 4); + + switch (rndTrigger) { + case 1: + if (!_fire1ActiveFl) { + _scene->_sequences.addTimer(_vm->getRandomNumber(300, 600), 60); + _fire1ActiveFl = true; + } + break; + + case 2: + if (!_fire2ActiveFl) { + _scene->_sequences.addTimer(_vm->getRandomNumber(300, 600), 63); + _fire2ActiveFl = true; + } + break; + + case 3: + if (!_fire3ActiveFl) { + _scene->_sequences.addTimer(_vm->getRandomNumber(300, 600), 66); + _fire3ActiveFl = true; + } + break; + + case 4: + if (!_fire4ActiveFl) { + _scene->_sequences.addTimer(_vm->getRandomNumber(300, 600), 69); + _fire4ActiveFl = true; + } + break; + } + } + + switch (_game._trigger) { + case 60: + if ((_game._player._playerPos.x < 198) || (_game._player._playerPos.y > 150)) { + _globals._sequenceIndexes[0] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[0], false, 5, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[0], 14); + _scene->_sequences.setAnimRange(_globals._sequenceIndexes[0], 1, 10); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[0], SEQUENCE_TRIGGER_EXPIRE, 0, 61); + } + break; + + case 61: + _fire1ActiveFl = false; + break; + + case 63: + if ((_game._player._playerPos.x > 127) || (_game._player._playerPos.y < 150)) { + _globals._sequenceIndexes[1] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[1], false, 5, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[1], 1); + _scene->_sequences.setAnimRange(_globals._sequenceIndexes[1], 1, 10); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[1], SEQUENCE_TRIGGER_EXPIRE, 0, 64); + } + break; + + case 64: + _fire2ActiveFl = false; + break; + + case 66: + if (_game._player._playerPos.x < 198) { + _globals._sequenceIndexes[2] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[2], false, 5, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[2], 1); + _scene->_sequences.setAnimRange(_globals._sequenceIndexes[2], 1, 10); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SEQUENCE_TRIGGER_EXPIRE, 0, 67); + } + break; + + case 67: + _fire3ActiveFl = false; + break; + + case 69: + if ((_game._player._playerPos.x > 110) || (_game._player._playerPos.y > 150)) { + _globals._sequenceIndexes[3] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[3], false, 5, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[3], 14); + _scene->_sequences.setAnimRange(_globals._sequenceIndexes[3], 1, 10); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SEQUENCE_TRIGGER_EXPIRE, 0, 70); + } + break; + + case 70: + _fire4ActiveFl = false; + break; + + default: + break; + } +} + +void Scene502::setPaletteCycle() { + warning("TODO: setPaletteCycle"); +} + +void Scene502::getPanelInfo(Common::Point *walkToPos, int *panel, Common::Point mousePos, Common::Point *interimPos) { + walkToPos->y = 148; + + if ((mousePos.x < 120) || (mousePos.y < 75) || (mousePos.y > 137)) + return; + + if (mousePos.x <= 139) { + interimPos->x = 129; + if (mousePos.y <= 90) { + *panel = 0; + interimPos->y = 90; + walkToPos->x = 107; + } else if (mousePos.y <= 106) { + *panel = 4; + interimPos->y = 106; + walkToPos->x = 107; + } else if (mousePos.y <= 122) { + *panel = 8; + interimPos->y = 122; + walkToPos->x = 107; + } else { + *panel = 12; + interimPos->y = 138; + walkToPos->x = 107; + } + } else if (mousePos.x <= 159) { + interimPos->x = 149; + if (mousePos.y <= 90) { + *panel = 1; + interimPos->y = 90; + walkToPos->x = 127; + } else if (mousePos.y <= 106) { + *panel = 5; + interimPos->y = 106; + walkToPos->x = 127; + } else if (mousePos.y <= 122) { + *panel = 9; + interimPos->y = 122; + walkToPos->x = 127; + } else { + *panel = 13; + interimPos->y = 138; + walkToPos->x = 127; + } + } else if (mousePos.x <= 179) { + interimPos->x = 169; + if (mousePos.y <= 90) { + *panel = 2; + interimPos->y = 90; + walkToPos->x = 147; + } else if (mousePos.y <= 106) { + *panel = 6; + interimPos->y = 106; + walkToPos->x = 147; + } else if (mousePos.y <= 122) { + *panel = 10; + interimPos->y = 122; + walkToPos->x = 147; + } else { + *panel = 14; + interimPos->y = 138; + walkToPos->x = 147; + } + } else if (mousePos.x <= 199) { + interimPos->x = 189; + if (mousePos.y <= 90) { + *panel = 3; + interimPos->y = 90; + walkToPos->x = 167; + } else if (mousePos.y <= 106) { + *panel = 7; + interimPos->y = 106; + walkToPos->x = 167; + } else if (mousePos.y <= 122) { + *panel = 11; + interimPos->y = 122; + walkToPos->x = 167; + } else { + *panel = 15; + interimPos->y = 138; + walkToPos->x = 167; + } + } +} + +void Scene502::handlePanelAnimation() { + int puzzleSolvedFl = true; + + switch (_game._trigger) { + case 110: + _vm->_sound->command(65); + _scene->deleteSequence(_puzzleSequences[_panelPushedNum]); + switch (_panelPushedNum) { + case 0: + case 1: + case 2: + case 3: + _globals._sequenceIndexes[11] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[11], false, _puzzleSprites[_panelPushedNum] - 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[11], 14); + _scene->_sequences.addTimer(5, 111); + break; + + case 4: + case 5: + case 6: + case 7: + _globals._sequenceIndexes[12] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[12], false, _puzzleSprites[_panelPushedNum] - 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[12], 14); + _scene->_sequences.addTimer(5, 111); + break; + + case 8: + case 9: + case 10: + case 11: + _globals._sequenceIndexes[13] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[13], false, _puzzleSprites[_panelPushedNum] - 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[13], 14); + _scene->_sequences.addTimer(5, 111); + break; + + default: + _globals._sequenceIndexes[14] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[14], false, _puzzleSprites[_panelPushedNum] - 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[14], 14); + _scene->_sequences.addTimer(5, 111); + break; + } + break; + + case 111: + switch (_panelPushedNum) { + case 0: + case 1: + case 2: + case 3: + _scene->deleteSequence(_globals._sequenceIndexes[11]); + break; + + case 4: + case 5: + case 6: + case 7: + _scene->deleteSequence(_globals._sequenceIndexes[12]); + break; + + case 8: + case 9: + case 10: + case 11: + _scene->deleteSequence(_globals._sequenceIndexes[13]); + break; + + default: + _scene->deleteSequence(_globals._sequenceIndexes[14]); + break; + } + + _globals._sequenceIndexes[16] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[16], false, 5, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[16], 14); + _scene->_sequences.setPosition(_globals._sequenceIndexes[16], _nextPos); + _scene->_sequences.setAnimRange(_globals._sequenceIndexes[16], -1, -2); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[16], SEQUENCE_TRIGGER_EXPIRE, 0, 112); + break; + + case 112: { + int idx = _globals._sequenceIndexes[16]; + int newSprId = _puzzleSprites[_panelPushedNum] + 4; + + switch (_panelPushedNum) { + case 0: + case 4: + case 8: + case 12: + if (newSprId > 12) + newSprId = 3; + break; + + case 1: + case 5: + case 9: + case 13: + if (newSprId > 24) + newSprId = 15; + break; + + case 2: + case 6: + case 10: + case 14: + if (newSprId > 36) + newSprId = 27; + break; + + default: + if (newSprId > 48) + newSprId = 39; + break; + } + + switch (_panelPushedNum) { + case 0: + case 1: + case 2: + case 3: + _globals._sequenceIndexes[11] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[11], false, newSprId); + _scene->_sequences.setDepth(_globals._sequenceIndexes[11], 14); + _game.syncTimers(SYNC_SEQ, _globals._sequenceIndexes[11], SYNC_SEQ, idx); + _scene->_sequences.addTimer(5, 113); + break; + + case 4: + case 5: + case 6: + case 7: + _globals._sequenceIndexes[12] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[12], false, newSprId); + _scene->_sequences.setDepth(_globals._sequenceIndexes[12], 14); + _game.syncTimers(SYNC_SEQ, _globals._sequenceIndexes[12], SYNC_SEQ, idx); + _scene->_sequences.addTimer(5, 113); + break; + + case 8: + case 9: + case 10: + case 11: + _globals._sequenceIndexes[13] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[13], false, newSprId); + _scene->_sequences.setDepth(_globals._sequenceIndexes[13], 14); + _game.syncTimers(SYNC_SEQ, _globals._sequenceIndexes[13], SYNC_SEQ, idx); + _scene->_sequences.addTimer(5, 113); + break; + + default: + _globals._sequenceIndexes[14] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[14], false, newSprId); + _scene->_sequences.setDepth(_globals._sequenceIndexes[14], 14); + _game.syncTimers(SYNC_SEQ, _globals._sequenceIndexes[14], SYNC_SEQ, idx); + _scene->_sequences.addTimer(5, 113); + break; + } + } + break; + + case 113: { + switch (_panelPushedNum) { + case 0: + case 1: + case 2: + case 3: + _scene->deleteSequence(_globals._sequenceIndexes[11]); + break; + + case 4: + case 5: + case 6: + case 7: + _scene->deleteSequence(_globals._sequenceIndexes[12]); + break; + + case 8: + case 9: + case 10: + case 11: + _scene->deleteSequence(_globals._sequenceIndexes[13]); + break; + + default: + _scene->deleteSequence(_globals._sequenceIndexes[14]); + break; + } + + int newSprId = _puzzleSprites[_panelPushedNum] + 3; + + switch (_panelPushedNum) { + case 0: + case 4: + case 8: + case 12: + if (newSprId > 12) + newSprId = 2; + break; + + case 1: + case 5: + case 9: + case 13: + if (newSprId > 24) + newSprId = 14; + break; + + case 2: + case 6: + case 10: + case 14: + if (newSprId > 36) + newSprId = 26; + break; + + default: + if (newSprId > 48) + newSprId = 38; + break; + } + _puzzleSprites[_panelPushedNum] = newSprId; + ++_puzzlePictures[_panelPushedNum]; + if (_puzzlePictures[_panelPushedNum] >= 5) + _puzzlePictures[_panelPushedNum] = 1; + + switch (_panelPushedNum) { + case 0: + case 1: + case 2: + case 3: + _globals._sequenceIndexes[11] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[11], false, newSprId); + _scene->_sequences.setDepth(_globals._sequenceIndexes[11], 14); + _puzzleSequences[_panelPushedNum] = _globals._sequenceIndexes[11]; + break; + + case 4: + case 5: + case 6: + case 7: + _globals._sequenceIndexes[12] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[12], false, newSprId); + _scene->_sequences.setDepth(_globals._sequenceIndexes[12], 14); + _puzzleSequences[_panelPushedNum] = _globals._sequenceIndexes[12]; + break; + + case 8: + case 9: + case 10: + case 11: + _globals._sequenceIndexes[13] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[13], false, newSprId); + _scene->_sequences.setDepth(_globals._sequenceIndexes[13], 14); + _puzzleSequences[_panelPushedNum] = _globals._sequenceIndexes[13]; + break; + + default: + _globals._sequenceIndexes[14] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[14], false, newSprId); + _scene->_sequences.setDepth(_globals._sequenceIndexes[14], 14); + _puzzleSequences[_panelPushedNum] = _globals._sequenceIndexes[14]; + break; + } + + for (int i = 0; i < 16; i++) { + if (_puzzlePictures[i] != 1) + puzzleSolvedFl = false; + } + + if (puzzleSolvedFl && !_trapDoorHotspotEnabled) { + _trapDoorHotspotEnabled = true; + _scene->deleteSequence(_globals._sequenceIndexes[6]); + _globals._animationIndexes[0] = _scene->loadAnimation(formAnimName('t', 1), 80); + } + } + break; + + default: + break; + } +} + +/*------------------------------------------------------------------------*/ + +Scene504::Scene504(MADSEngine *vm) : Scene5xx(vm) { + _anim0ActvFl = false; + _anim1ActvFl = false; + _anim2ActvFl = false; + _anim3ActvFl = false; + _anim4ActvFl = false; + _anim5ActvFl = false; + _playingMusicFl = false; + _chairDialogDoneFl = false; + _fireBreathFl = false; + + _songNum = -1; + _input3Count = -1; + _playCount = -1; + _listenStatus = -1; + _listenFrame = -1; + _chairStatus = -1; + _chairFrame = -1; + _playStatus = -1; + _playFrame = -1; + _phantomStatus = -1; + _phantomFrame = -1; + _christineTalkCount = -1; + _deathCounter = -1; +} + +void Scene504::synchronize(Common::Serializer &s) { + Scene5xx::synchronize(s); + + s.syncAsByte(_anim0ActvFl); + s.syncAsByte(_anim1ActvFl); + s.syncAsByte(_anim2ActvFl); + s.syncAsByte(_anim3ActvFl); + s.syncAsByte(_anim4ActvFl); + s.syncAsByte(_anim5ActvFl); + s.syncAsByte(_playingMusicFl); + s.syncAsByte(_chairDialogDoneFl); + s.syncAsByte(_fireBreathFl); + + s.syncAsSint16LE(_songNum); + s.syncAsSint16LE(_input3Count); + s.syncAsSint16LE(_playCount); + s.syncAsSint16LE(_listenStatus); + s.syncAsSint16LE(_listenFrame); + s.syncAsSint16LE(_chairStatus); + s.syncAsSint16LE(_chairFrame); + s.syncAsSint16LE(_playStatus); + s.syncAsSint16LE(_playFrame); + s.syncAsSint16LE(_phantomStatus); + s.syncAsSint16LE(_phantomFrame); + s.syncAsSint16LE(_christineTalkCount); + s.syncAsSint16LE(_deathCounter); +} + +void Scene504::setup() { + setPlayerSpritesPrefix(); + setAAName(); + + _scene->addActiveVocab(NOUN_PHANTOM); + _scene->addActiveVocab(NOUN_CHRISTINE); +} + +void Scene504::enter() { + _vm->_disableFastwalk = true; + + _input3Count = 0; + _deathCounter = 0; + _anim2ActvFl = false; + + if (_scene->_priorSceneId != RETURNING_FROM_LOADING) { + _playCount = 0; + _anim0ActvFl = false; + _anim1ActvFl = false; + _anim3ActvFl = false; + _anim4ActvFl = false; + _anim5ActvFl = false; + _playingMusicFl = false; + _fireBreathFl = false; + _chairDialogDoneFl = false; + _songNum = 0; + _phantomStatus = 0; + } + + _scene->_hotspots.activate(NOUN_CHRISTINE, false); + + if (!_globals[kRightDoorIsOpen504]) { + _vm->_gameConv->get(19); + _vm->_gameConv->get(27); + } else + _vm->_gameConv->get(21); + + _vm->_gameConv->get(26); + + _globals._spriteIndexes[14] = _scene->_sprites.addSprites("*RDR_9"); + _globals._spriteIndexes[15] = _scene->_sprites.addSprites(formAnimName('x', 8)); + + if (!_game._objects.isInRoom(OBJ_MUSIC_SCORE)) { + _globals._sequenceIndexes[15] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[15], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[15], 14); + _scene->_hotspots.activate(NOUN_MUSIC_SCORE, false); + } + + _globals._spriteIndexes[0] = _scene->_sprites.addSprites(formAnimName('x', 2)); + _globals._spriteIndexes[13] = _scene->_sprites.addSprites(formAnimName('x', 7), PALFLAG_ALL_TO_CLOSEST | PALFLAG_ANY_TO_CLOSEST); + + if (_globals[kFightStatus] == 0) + _globals._spriteIndexes[1] = _scene->_sprites.addSprites(formAnimName('x', 1)); + + _globals._spriteIndexes[3] = _scene->_sprites.addSprites(formAnimName('x', 3)); + + if ((_scene->_priorSceneId == 505) || ((_scene->_priorSceneId == 504) && _globals[kRightDoorIsOpen504])) { + if ((_globals[kFightStatus] == 0) && (_globals[kCoffinStatus] == 2)) { + _scene->_hotspots.activate(NOUN_CHRISTINE, true); + _scene->drawToBackground(_globals._spriteIndexes[0], 1, Common::Point(-32000, -32000), 0, 100); + + _globals._spriteIndexes[13] = _scene->_sprites.addSprites(formAnimName('x', 7), PALFLAG_ALL_TO_CLOSEST | PALFLAG_ANY_TO_CLOSEST); + _globals._spriteIndexes[6] = _scene->_sprites.addSprites(formAnimName('b', 0)); + + _globals._spriteIndexes[6] = _scene->_sprites.addSprites("*CHR_6", PALFLAG_ALL_TO_CLOSEST | PALFLAG_ANY_TO_CLOSEST); + _globals._spriteIndexes[6] = _scene->_sprites.addSprites("*FACERAL", PALFLAG_ALL_TO_CLOSEST | PALFLAG_ANY_TO_CLOSEST); + _globals._spriteIndexes[6] = _scene->_sprites.addSprites("*FACEXDFR", PALFLAG_ALL_TO_CLOSEST | PALFLAG_ANY_TO_CLOSEST); + _globals._spriteIndexes[6] = _scene->_sprites.addSprites("*FACEPHN", PALFLAG_ALL_TO_CLOSEST | PALFLAG_ANY_TO_CLOSEST); + + _globals._spriteIndexes[11] = _scene->_sprites.addSprites(formAnimName('a', 5)); + _globals._spriteIndexes[10] = _scene->_sprites.addSprites(formAnimName('a', 3), PALFLAG_ALL_TO_CLOSEST | PALFLAG_ANY_TO_CLOSEST); + _globals._spriteIndexes[7] = _scene->_sprites.addSprites(formAnimName('a', 6), PALFLAG_ALL_TO_CLOSEST | PALFLAG_ANY_TO_CLOSEST); + _globals._spriteIndexes[8] = _scene->_sprites.addSprites(formAnimName('a', 7), PALFLAG_ALL_TO_CLOSEST | PALFLAG_ANY_TO_CLOSEST); + _globals._spriteIndexes[9] = _scene->_sprites.addSprites(formAnimName('a', 0), PALFLAG_ALL_TO_CLOSEST | PALFLAG_ANY_TO_CLOSEST); + + _globals._animationIndexes[3] = _scene->loadAnimation(formAnimName('p', 1), 0); + int hotspotIdx = _scene->_dynamicHotspots.add(NOUN_PHANTOM, VERB_LOOK_AT, SYNTAX_MASC_NOT_PROPER, EXT_NONE, Common::Rect(0, 0, 0, 0)); + _scene->_dynamicHotspots[hotspotIdx]._articleNumber = PREP_ON; + _scene->_dynamicHotspots.setPosition(hotspotIdx, Common::Point(-2, -2), FACING_NONE); + + _scene->setDynamicAnim(hotspotIdx, _globals._animationIndexes[3], 4); + _scene->setDynamicAnim(hotspotIdx, _globals._animationIndexes[3], 8); + _scene->setDynamicAnim(hotspotIdx, _globals._animationIndexes[3], 13); + + _phantomStatus = 0; + _game._player._stepEnabled = false; + _game._player._visible = false; + _anim3ActvFl = true; + } else { + if (_globals[kFightStatus]) + _scene->drawToBackground(_globals._spriteIndexes[13], 1, Common::Point(-32000, -32000), 0, 100); + + if (_globals[kCoffinStatus] != 2) { + _globals._sequenceIndexes[1] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[1], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[1], 14); + } + + _game._player._playerPos = Common::Point(317, 115); + _game._player._facing = FACING_SOUTHWEST; + _game._player.walk(Common::Point(279, 121), FACING_SOUTHWEST); + + _scene->drawToBackground(_globals._spriteIndexes[0], 1, Common::Point(-32000, -32000), 0, 100); + + if (!_game._visitedScenes.exists(506) && (_globals[kCoffinStatus] == 2)) { + _scene->changeVariant(1); + + _scene->drawToBackground(_globals._spriteIndexes[13], 1, Common::Point(-32000, -32000), 0, 100); + _anim5ActvFl = true; + + _globals._spriteIndexes[6] = _scene->_sprites.addSprites("*CHR_2"); + _globals._spriteIndexes[6] = _scene->_sprites.addSprites("*FACERAL", PALFLAG_ALL_TO_CLOSEST | PALFLAG_ANY_TO_CLOSEST); + _globals._spriteIndexes[6] = _scene->_sprites.addSprites("*FACEXDFR",PALFLAG_ALL_TO_CLOSEST | PALFLAG_ANY_TO_CLOSEST); + _globals._spriteIndexes[6] = _scene->_sprites.addSprites("*FACEPHN", PALFLAG_ALL_TO_CLOSEST | PALFLAG_ANY_TO_CLOSEST); + + _globals._animationIndexes[3] = _scene->loadAnimation(formAnimName('p', 3), 0); + int hotspotIdx = _scene->_dynamicHotspots.add(NOUN_CHRISTINE, VERB_WALK_TO, SYNTAX_SINGULAR_FEM, EXT_NONE, Common::Rect(0, 0, 0, 0)); + _phantomStatus = 5; + _scene->_dynamicHotspots[hotspotIdx]._articleNumber = PREP_ON; + _scene->setAnimFrame(_globals._animationIndexes[3], 79); + _scene->_dynamicHotspots.setPosition(hotspotIdx, Common::Point(66, 119), FACING_NORTHWEST); + _scene->setDynamicAnim(hotspotIdx, _globals._animationIndexes[3], 0); + _scene->setDynamicAnim(hotspotIdx, _globals._animationIndexes[3], 1); + _scene->setDynamicAnim(hotspotIdx, _globals._animationIndexes[3], 2); + _scene->setDynamicAnim(hotspotIdx, _globals._animationIndexes[3], 3); + _scene->setDynamicAnim(hotspotIdx, _globals._animationIndexes[3], 4); + } + } + } else if (_scene->_priorSceneId == 506) { + _game._player._playerPos = Common::Point(0, 109); + _game._player._facing = FACING_SOUTHEAST; + _game._player.walk(Common::Point(39, 118), FACING_SOUTHEAST); + _scene->drawToBackground(_globals._spriteIndexes[0], 1, Common::Point(-32000, -32000), 0, 100); + _scene->drawToBackground(_globals._spriteIndexes[13], 1, Common::Point(-32000, -32000), 0, 100); + } else if (_scene->_priorSceneId == 504) { + _globals._sequenceIndexes[1] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[1], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[1], 14); + + _globals._spriteIndexes[2] = _scene->_sprites.addSprites(formAnimName('x', 0)); + _globals._sequenceIndexes[2] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[2], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[2], 14); + _scene->drawToBackground(_globals._spriteIndexes[0], 1, Common::Point(-32000, -32000), 0, 100); + + _game._player._playerPos = Common::Point(147, 131); + _game._player._facing = FACING_EAST; + } else if ((_scene->_priorSceneId == 502) || (_scene->_priorSceneId != RETURNING_FROM_LOADING)) { + _globals._sequenceIndexes[1] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[1], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[1], 14); + + _globals._spriteIndexes[2] = _scene->_sprites.addSprites(formAnimName('x', 0)); + _globals._sequenceIndexes[2] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[2], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[2], 14); + + _globals._animationIndexes[0] = _scene->loadAnimation(formAnimName('t', 1), 60); + _game._player._stepEnabled = false; + _game._player._visible = false; + _game._player._playerPos = Common::Point(147, 131); + _game._player._facing = FACING_EAST; + } + + if (_scene->_priorSceneId == RETURNING_FROM_LOADING) { + if (!_globals[kRightDoorIsOpen504]) { + _globals._spriteIndexes[2] = _scene->_sprites.addSprites(formAnimName('x', 0)); + _globals._sequenceIndexes[2] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[2], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[2], 14); + } + + if (_vm->_gameConv->_restoreRunning == 19) { + _scene->drawToBackground(_globals._spriteIndexes[0], 1, Common::Point(-32000, -32000), 0, 100); + _globals._sequenceIndexes[1] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[1], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[1], 14); + + _globals._animationIndexes[0] = _scene->loadAnimation(formAnimName('l', 1), 67); + _anim0ActvFl = true; + _game._player._visible = false; + _game._player._stepEnabled = false; + _game._player._playerPos = Common::Point(286, 120); + _game._player._facing = FACING_EAST; + _listenStatus = 0; + _scene->setAnimFrame(_globals._animationIndexes[0], 8); + _vm->_gameConv->run(19); + _vm->_gameConv->exportValue(_game._difficulty); + } else if (_vm->_gameConv->_restoreRunning == 27) { + _scene->drawToBackground(_globals._spriteIndexes[0], 1, Common::Point(-32000, -32000), 0, 100); + _globals._sequenceIndexes[1] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[1], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[1], 14); + + _globals._spriteIndexes[4] = _scene->_sprites.addSprites(formAnimName('x', 4), PALFLAG_ALL_TO_CLOSEST | PALFLAG_ANY_TO_CLOSEST); + _globals._spriteIndexes[5] = _scene->_sprites.addSprites(formAnimName('x', 5), PALFLAG_ALL_TO_CLOSEST | PALFLAG_ANY_TO_CLOSEST); + _globals._animationIndexes[1] = _scene->loadAnimation(formAnimName('o', 1), 100); + + _scene->setAnimFrame(_globals._animationIndexes[1], 22); + _game._player._stepEnabled = false; + _game._player._visible = false; + _playingMusicFl = false; + _anim1ActvFl = true; + _playStatus = 0; + _vm->_gameConv->run(27); + } else if ((_globals[kFightStatus] <= 1) && (_globals[kCoffinStatus] == 2)) { + if ((_phantomStatus == 1) || (_phantomStatus == 2)) { + _scene->_hotspots.activate(NOUN_CHRISTINE, true); + _scene->drawToBackground(_globals._spriteIndexes[0], 1, Common::Point(-32000, -32000), 0, 100); + + _globals._spriteIndexes[6] = _scene->_sprites.addSprites(formAnimName('b', 0)); + _globals._spriteIndexes[6] = _scene->_sprites.addSprites("*CHR_6", PALFLAG_ALL_TO_CLOSEST | PALFLAG_ANY_TO_CLOSEST); + _globals._spriteIndexes[6] = _scene->_sprites.addSprites("*FACERAL", PALFLAG_ALL_TO_CLOSEST | PALFLAG_ANY_TO_CLOSEST); + _globals._spriteIndexes[6] = _scene->_sprites.addSprites("*FACEXDFR", PALFLAG_ALL_TO_CLOSEST | PALFLAG_ANY_TO_CLOSEST); + _globals._spriteIndexes[6] = _scene->_sprites.addSprites("*FACEPHN", PALFLAG_ALL_TO_CLOSEST | PALFLAG_ANY_TO_CLOSEST); + + _globals._spriteIndexes[11] = _scene->_sprites.addSprites(formAnimName('a', 5)); + _globals._spriteIndexes[10] = _scene->_sprites.addSprites(formAnimName('a', 3), PALFLAG_ALL_TO_CLOSEST | PALFLAG_ANY_TO_CLOSEST); + _globals._spriteIndexes[7] = _scene->_sprites.addSprites(formAnimName('a', 6), PALFLAG_ALL_TO_CLOSEST | PALFLAG_ANY_TO_CLOSEST); + _globals._spriteIndexes[8] = _scene->_sprites.addSprites(formAnimName('a', 7), PALFLAG_ALL_TO_CLOSEST | PALFLAG_ANY_TO_CLOSEST); + _globals._spriteIndexes[9] = _scene->_sprites.addSprites(formAnimName('a', 0), PALFLAG_ALL_TO_CLOSEST | PALFLAG_ANY_TO_CLOSEST); + + _globals._animationIndexes[3] = _scene->loadAnimation(formAnimName('p', 1), 0); + int hotspotIdx = _scene->_dynamicHotspots.add(NOUN_PHANTOM, VERB_LOOK_AT, SYNTAX_MASC_NOT_PROPER, EXT_NONE, Common::Rect(0, 0, 0, 0)); + _scene->_dynamicHotspots[hotspotIdx]._articleNumber = PREP_ON; + _scene->_dynamicHotspots.setPosition(hotspotIdx, Common::Point(-2, -2), FACING_NONE); + + if (_phantomStatus == 1) + _scene->setAnimFrame(_globals._animationIndexes[3], _vm->getRandomNumber(109, 112)); + else if (_phantomStatus == 2) { + _scene->setAnimFrame(_globals._animationIndexes[3], _vm->getRandomNumber(148, 150)); + _scene->drawToBackground(_globals._spriteIndexes[13], 1, Common::Point(-32000, -32000), 0, 100); + } + + _scene->setDynamicAnim(hotspotIdx, _globals._animationIndexes[3], 4); + _scene->setDynamicAnim(hotspotIdx, _globals._animationIndexes[3], 8); + _scene->setDynamicAnim(hotspotIdx, _globals._animationIndexes[3], 13); + + _game._player._visible = false; + _anim3ActvFl = true; + + if (_vm->_gameConv->_restoreRunning == 21) { + _game._player._stepEnabled = false; + _vm->_gameConv->run(21); + _vm->_gameConv->exportValue(_game._objects.isInInventory(OBJ_MUSIC_SCORE)); + } + } else if (_phantomStatus == 4) { + _scene->drawToBackground(_globals._spriteIndexes[0], 1, Common::Point(-32000, -32000), 0, 100); + _scene->drawToBackground(_globals._spriteIndexes[13], 1, Common::Point(-32000, -32000), 0, 100); + + _globals._spriteIndexes[6] = _scene->_sprites.addSprites("*CHR_3"); + _globals._spriteIndexes[6] = _scene->_sprites.addSprites("*FACERAL", PALFLAG_ALL_TO_CLOSEST | PALFLAG_ANY_TO_CLOSEST); + _globals._spriteIndexes[6] = _scene->_sprites.addSprites("*FACEXDFR", PALFLAG_ALL_TO_CLOSEST | PALFLAG_ANY_TO_CLOSEST); + _globals._spriteIndexes[6] = _scene->_sprites.addSprites("*FACEPHN", PALFLAG_ALL_TO_CLOSEST | PALFLAG_ANY_TO_CLOSEST); + _globals._spriteIndexes[12] = _scene->_sprites.addSprites(formAnimName('a', 8), PALFLAG_ALL_TO_CLOSEST | PALFLAG_ANY_TO_CLOSEST); + + _globals._animationIndexes[3] = _scene->loadAnimation(formAnimName('p', 2), 130); + _scene->setAnimFrame(_globals._animationIndexes[3], 159); + + _game._player._playerPos = Common::Point(130, 135); + _game._player._facing = FACING_NORTHEAST; + _game._player._visible = true; + _anim4ActvFl = true; + + _game._player._stepEnabled = false; + _vm->_gameConv->run(21); + _vm->_gameConv->exportValue(_game._objects.isInInventory(OBJ_MUSIC_SCORE)); + } + } else if (_globals[kFightStatus] == 2) { + if (!_game._visitedScenes.exists(506)) { + _scene->changeVariant(1); + + _scene->drawToBackground(_globals._spriteIndexes[0], 1, Common::Point(-32000, -32000), 0, 100); + _scene->drawToBackground(_globals._spriteIndexes[13], 1, Common::Point(-32000, -32000), 0, 100); + _anim5ActvFl = true; + + _globals._spriteIndexes[6] = _scene->_sprites.addSprites("*CHR_3"); + _globals._spriteIndexes[6] = _scene->_sprites.addSprites("*FACERAL", PALFLAG_ALL_TO_CLOSEST | PALFLAG_ANY_TO_CLOSEST); + _globals._spriteIndexes[6] = _scene->_sprites.addSprites("*FACEXDFR",PALFLAG_ALL_TO_CLOSEST | PALFLAG_ANY_TO_CLOSEST); + _globals._spriteIndexes[6] = _scene->_sprites.addSprites("*FACEPHN", PALFLAG_ALL_TO_CLOSEST | PALFLAG_ANY_TO_CLOSEST); + + _globals._animationIndexes[3] = _scene->loadAnimation(formAnimName('p', 3), 0); + int hotspotIdx = _scene->_dynamicHotspots.add(NOUN_CHRISTINE, VERB_WALK_TO, SYNTAX_SINGULAR_FEM, EXT_NONE, Common::Rect(0, 0, 0, 0)); + _phantomStatus = 5; + _scene->_dynamicHotspots[hotspotIdx]._articleNumber = PREP_ON; + _scene->setAnimFrame(_globals._animationIndexes[3], 79); + _scene->_dynamicHotspots.setPosition(hotspotIdx, Common::Point(66, 119), FACING_NORTHWEST); + _scene->setDynamicAnim(hotspotIdx, _globals._animationIndexes[3], 0); + _scene->setDynamicAnim(hotspotIdx, _globals._animationIndexes[3], 1); + _scene->setDynamicAnim(hotspotIdx, _globals._animationIndexes[3], 2); + _scene->setDynamicAnim(hotspotIdx, _globals._animationIndexes[3], 3); + _scene->setDynamicAnim(hotspotIdx, _globals._animationIndexes[3], 4); + } else { + _scene->drawToBackground(_globals._spriteIndexes[0], 1, Common::Point(-32000, -32000), 0, 100); + _scene->drawToBackground(_globals._spriteIndexes[13], 1, Common::Point(-32000, -32000), 0, 100); + } + } else { + _scene->drawToBackground(_globals._spriteIndexes[0], 1, Common::Point(-32000, -32000), 0, 100); + _globals._sequenceIndexes[1] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[1], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[1], 14); + _globals._sequenceIndexes[1] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[1], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[1], 14); + if (!_globals[kHeListened]) + _scene->_sequences.addTimer(30, 62); + } + } + + sceneEntrySound(); +} + +void Scene504::step() { + if (_anim0ActvFl) + handleListenAnimation(); + + if (_anim1ActvFl) + handleOrganAnimation(); + + if (_anim2ActvFl) + handleChairAnimation(); + + if (_anim3ActvFl) + handlePhantomAnimation1(); + + if (_anim4ActvFl) + handlePhantomAnimation2(); + + if (_anim5ActvFl) + handlePhantomAnimation3(); + + if (_game._trigger == 120) { + _game._player._stepEnabled = false; + _vm->_gameConv->run(21); + _vm->_gameConv->exportValue(_game._objects.isInInventory(OBJ_MUSIC_SCORE)); + _vm->_gameConv->exportValue(1); + _globals[kFightStatus] = 1; + } + + if (_game._trigger == 60) { + _game._player._visible = true; + _game.syncTimers(SYNC_PLAYER, 0, SYNC_ANIM, _globals._animationIndexes[0]); + _scene->drawToBackground(_globals._spriteIndexes[0], 1, Common::Point(-32000, -32000), 0, 100); + _scene->_sequences.addTimer(30, 61); + } + + if (_game._trigger == 61) { + _game._player._stepEnabled = true; + _scene->_sequences.addTimer(60, 62); + } + + if (_game._trigger == 62) { + _globals[kHeListened] = true; + _game._player._stepEnabled = false; + _vm->_gameConv->run(19); + _vm->_gameConv->exportValue(_game._difficulty); + } + + if (_game._trigger == 80) { + _vm->_sound->command(73); + _globals[kRightDoorIsOpen504] = true; + _scene->deleteSequence(_globals._sequenceIndexes[2]); + _globals._sequenceIndexes[2] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[2], false, 6, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[2], 1); + _scene->_sequences.setAnimRange(_globals._sequenceIndexes[2], -1, -2); + + _globals._sequenceIndexes[3] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[3], false, 6, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[3], 1); + _scene->_sequences.setAnimRange(_globals._sequenceIndexes[3], -1, -2); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SEQUENCE_TRIGGER_EXPIRE, 0, 90); + } + + if (_game._trigger == 90) { + _globals._sequenceIndexes[4] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[4], false, 6, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[4], 1); + _scene->_sequences.setAnimRange(_globals._sequenceIndexes[4], -1, -2); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[4], SEQUENCE_TRIGGER_EXPIRE, 0, 91); + } + + if (_game._trigger == 91) { + _globals._sequenceIndexes[5] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[5], false, 6, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[5], 1); + _scene->_sequences.setAnimRange(_globals._sequenceIndexes[5], -1, -2); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[5], SEQUENCE_TRIGGER_EXPIRE, 0, 92); + } + + if (_game._trigger == 92) + _fireBreathFl = true; + + if (_fireBreathFl) { + _globals._sequenceIndexes[3] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[3], false, 6, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[3], 1); + _scene->_sequences.setAnimRange(_globals._sequenceIndexes[3], -1, -2); + _globals._sequenceIndexes[4] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[4], false, 6, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[4], 1); + _scene->_sequences.setAnimRange(_globals._sequenceIndexes[4], -1, -2); + _globals._sequenceIndexes[5] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[5], false, 6, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[5], 1); + _scene->_sequences.setAnimRange(_globals._sequenceIndexes[5], -1, -2); + _fireBreathFl = false; + } + + if (_game._trigger == 130) { + _scene->freeAnimation(_globals._animationIndexes[3]); + _scene->_sprites.remove(_globals._spriteIndexes[12]); + + _anim4ActvFl = false; + _anim5ActvFl = true; + + _globals._spriteIndexes[6] = _scene->_sprites.addSprites("*CHR_2", PALFLAG_ALL_TO_CLOSEST | PALFLAG_ANY_TO_CLOSEST); + _globals._spriteIndexes[6] = _scene->_sprites.addSprites("*CHR_3", PALFLAG_ALL_TO_CLOSEST | PALFLAG_ANY_TO_CLOSEST); + + _scene->changeVariant(1); + + _globals._animationIndexes[3] = _scene->loadAnimation(formAnimName('p', 3), 0); + int hotspotIdx = _scene->_dynamicHotspots.add(NOUN_CHRISTINE, VERB_WALK_TO, SYNTAX_SINGULAR_FEM, EXT_NONE, Common::Rect(0, 0, 0, 0)); + _scene->_dynamicHotspots[hotspotIdx]._articleNumber = PREP_ON; + _scene->_dynamicHotspots.setPosition(hotspotIdx, Common::Point(66, 119), FACING_NORTHWEST); + _scene->setDynamicAnim(hotspotIdx, _globals._animationIndexes[3], 0); + _scene->setDynamicAnim(hotspotIdx, _globals._animationIndexes[3], 1); + _scene->setDynamicAnim(hotspotIdx, _globals._animationIndexes[3], 2); + _scene->setDynamicAnim(hotspotIdx, _globals._animationIndexes[3], 3); + _scene->setDynamicAnim(hotspotIdx, _globals._animationIndexes[3], 4); + } + + if (_game._trigger == 67) { + _game._player._stepEnabled = true; + _game._player._visible = true; + _anim0ActvFl = false; + _game.syncTimers(SYNC_PLAYER, 0, SYNC_ANIM, _globals._animationIndexes[0]); + } + + if (_game._trigger == 136) + _scene->_nextSceneId = 506; + + if (_game._trigger == 100) { + _game.syncTimers(SYNC_PLAYER, 0, SYNC_ANIM, _globals._animationIndexes[1]); + _game._player._playerPos = Common::Point(156, 114); + _game._player._visible = true; + _anim1ActvFl = false; + _game._player.resetFacing(FACING_EAST); + _scene->_sequences.addTimer(10, 101); + } + + if (_game._trigger == 101) { + _game._player._stepEnabled = true; + _scene->_sprites.remove(_globals._spriteIndexes[5]); + _scene->_sprites.remove(_globals._spriteIndexes[4]); + } +} + +void Scene504::actions() { + if (_vm->_gameConv->_running == 26) { + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_SIT_IN, NOUN_LARGE_CHAIR)) { + if (!_anim2ActvFl) { + _chairStatus = 0; + _game._player._stepEnabled = false; + _game._player._visible = false; + _anim2ActvFl = true; + _globals._animationIndexes[2] = _scene->loadAnimation(formAnimName('c', 1), 0); + _game.syncTimers(SYNC_ANIM, _globals._animationIndexes[0], SYNC_PLAYER, 0); + } else + _vm->_dialogs->show(50436); + _action._inProgress = false; + return; + } + + if (_game._trigger == 95) { + _globals._animationIndexes[0] = _scene->loadAnimation(formAnimName('l', 1), 67); + _listenStatus = 0; + _game._player._stepEnabled = false; + _game._player._visible = false; + _anim0ActvFl = true; + _globals[kHeListened] = true; + _vm->_gameConv->run(19); + _vm->_gameConv->exportValue(_game._difficulty); + _action._inProgress = false; + return; + } + + if (_game._trigger == 67) { + _game._player._stepEnabled = true; + _game._player._visible = true; + _anim0ActvFl = false; + _game.syncTimers(SYNC_PLAYER, 0, SYNC_ANIM, _globals._animationIndexes[0]); + _action._inProgress = false; + return; + } + + if (_vm->_gameConv->_running == 19) { + handleListenConversation(); + _action._inProgress = false; + return; + } + + if (_vm->_gameConv->_running == 27) { + handlePlayConversation(); + _action._inProgress = false; + return; + } + + if (_vm->_gameConv->_running == 21) { + handleFightConversation(); + _action._inProgress = false; + return; + } + + if (_game._trigger == 100) { + _game.syncTimers(SYNC_PLAYER, 0, SYNC_ANIM, _globals._animationIndexes[1]); + _game._player._playerPos = Common::Point(156, 114); + _game._player._visible = true; + _anim1ActvFl = false; + _game._player.resetFacing(FACING_EAST); + _scene->_sequences.addTimer(10, 101); + _action._inProgress = false; + return; + } + + if (_game._trigger == 101) { + _game._player._stepEnabled = true; + _scene->_sprites.remove(_globals._spriteIndexes[5]); + _scene->_sprites.remove(_globals._spriteIndexes[4]); + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_SIT_ON, NOUN_ORGAN_BENCH)) { + if (_globals[kRightDoorIsOpen504]) + _vm->_dialogs->show(50427); + else { + _globals._spriteIndexes[4] = _scene->_sprites.addSprites(formAnimName('x', 4), PALFLAG_ALL_TO_CLOSEST | PALFLAG_ANY_TO_CLOSEST); + _globals._spriteIndexes[5] = _scene->_sprites.addSprites(formAnimName('x', 5), PALFLAG_ALL_TO_CLOSEST | PALFLAG_ANY_TO_CLOSEST); + _globals._animationIndexes[1] = _scene->loadAnimation(formAnimName('o', 1), 100); + _game._player._stepEnabled = false; + _game._player._visible = false; + _playingMusicFl = false; + _anim1ActvFl = true; + _playStatus = 0; + } + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_WALK_THROUGH, NOUN_RIGHT_DOOR) || _action.isAction(VERB_OPEN, NOUN_RIGHT_DOOR)) { + if (_globals[kRightDoorIsOpen504]) { + if (_vm->_gameConv->_running == 26) + _vm->_gameConv->abortConv(); + + _scene->_nextSceneId = 505; + } else + _vm->_dialogs->show(50418); + + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_WALK_THROUGH, NOUN_LEFT_DOOR) || _action.isAction(VERB_OPEN, NOUN_LEFT_DOOR)) { + if (_globals[kFightStatus]) { + if (_game._visitedScenes.exists(506)) + _scene->_nextSceneId = 506; + else if (!_game._objects.isInInventory(OBJ_MUSIC_SCORE)) + _vm->_dialogs->show(50425); + else { + _phantomStatus = 6; + _game._player._stepEnabled = false; + } + } else + _vm->_dialogs->show(50418); + + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_TAKE, NOUN_MUSIC_SCORE)) { + switch (_game._trigger) { + case (0): + if (_game._objects.isInRoom(OBJ_MUSIC_SCORE)) { + _globals[kPlayerScore] += 5; + _game._player._stepEnabled = false; + _game._player._visible = false; + _globals._sequenceIndexes[14] = _scene->_sequences.startPingPongCycle(_globals._spriteIndexes[14], false, 5, 2); + _scene->_sequences.setAnimRange(_globals._sequenceIndexes[14], 1, 4); + _scene->_sequences.setSeqPlayer(_globals._sequenceIndexes[14], true); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[14], SEQUENCE_TRIGGER_SPRITE, 4, 1); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[14], SEQUENCE_TRIGGER_EXPIRE, 0, 2); + _action._inProgress = false; + return; + } + break; + + case 1: + _globals._sequenceIndexes[15] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[15], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[15], 14); + _scene->_hotspots.activate(NOUN_MUSIC_SCORE, false); + _game._objects.addToInventory(OBJ_MUSIC_SCORE); + _vm->_sound->command(26); + _action._inProgress = false; + return; + break; + + case 2: + _game.syncTimers(SYNC_PLAYER, 0, SYNC_SEQ, _globals._sequenceIndexes[14]); + _game._player._visible = true; + _scene->_sequences.addTimer(20, 3); + _action._inProgress = false; + return; + break; + + case 3: + _vm->_dialogs->showItem(OBJ_MUSIC_SCORE, 820, 0); + _game._player._stepEnabled = true; + _action._inProgress = false; + return; + break; + + default: + break; + } + } + + if (_action._lookFlag) { + _vm->_dialogs->show(50410); + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_LOOK) || _action.isAction(VERB_LOOK_AT)) { + if (_action.isObject(NOUN_FLOOR)) { + _vm->_dialogs->show(50411); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_WALL)) { + _vm->_dialogs->show(50412); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_ORGAN)) { + _vm->_dialogs->show(50413); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_ORGAN_BENCH)) { + _vm->_dialogs->show(50414); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_MUSIC_SCORE) && _game._objects.isInRoom(OBJ_MUSIC_SCORE)) { + _vm->_dialogs->show(50415); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_LEFT_DOOR)) { + _vm->_dialogs->show(50416); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_RIGHT_DOOR)) { + _vm->_dialogs->show(_globals[kRightDoorIsOpen504] ? 50434 : 50417); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_TABLE)) { + _vm->_dialogs->show(50419); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_TRAP_DOOR)) { + _vm->_dialogs->show(50420); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_LARGE_CHAIR)) { + _vm->_dialogs->show(50422); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_CHRISTINE)) { + _vm->_dialogs->show(_globals[kFightStatus] ? 50426 : 50429); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_PHANTOM)) { + _vm->_dialogs->show(50428); + _action._inProgress = false; + return; + } + } + + if (_action.isAction(VERB_OPEN, NOUN_TRAP_DOOR)) { + _vm->_dialogs->show(50421); + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_CLOSE) && _action.isObject(NOUN_RIGHT_DOOR) && !_globals[kRightDoorIsOpen504]) { + _vm->_dialogs->show(50433); + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_CLOSE) && _action.isObject(NOUN_LEFT_DOOR) && !_globals[kFightStatus] && !_game._visitedScenes.exists(506)) { + _vm->_dialogs->show(50433); + _action._inProgress = false; + return; + } + + if (_anim3ActvFl && (_action.isAction(VERB_TAKE, NOUN_SWORD) || _action.isAction(VERB_ATTACK, NOUN_PHANTOM))) { + _game._player._stepEnabled = false; + _input3Count = 0; + _phantomStatus = 4; + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_TALK_TO, NOUN_CHRISTINE)) { + _vm->_gameConv->run(21); + _vm->_gameConv->exportValue(_game._objects.isInInventory(OBJ_MUSIC_SCORE)); + _vm->_gameConv->exportValue(0); + _phantomStatus = 7; + _christineTalkCount = 0; + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_TALK_TO, NOUN_PHANTOM)) { + _vm->_dialogs->show(50431); + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_TAKE, NOUN_CHRISTINE)) { + _vm->_dialogs->show(50435); + _action._inProgress = false; + return; + } +} + +void Scene504::preActions() { + if (_action.isAction(VERB_WALK_THROUGH, NOUN_RIGHT_DOOR) || _action.isAction(VERB_OPEN, NOUN_RIGHT_DOOR)) { + if (_globals[kRightDoorIsOpen504]) { + if ((_globals[kFightStatus] == 2) && !_game._visitedScenes.exists(506)) { + switch (_game._trigger) { + case 0: + _game._player.walk(Common::Point(317, 115), FACING_NORTHEAST); + _game._player._readyToWalk = false; + _game._player._needToWalk = false; + _game._player._stepEnabled = false; + _vm->_gameConv->run(26); + _vm->_gameConv->exportValue(2); + _scene->_sequences.addTimer(6, 1); + break; + + case 1: + if (_vm->_gameConv->_running >= 0) + _scene->_sequences.addTimer(6, 1); + else { + _game._player._stepEnabled = true; + _action._inProgress = true; + _game._player._needToWalk = true; + _game._player._readyToWalk = true; + } + break; + + default: + break; + } + } else + _game._player.walk(Common::Point(317, 115), FACING_NORTHEAST); + } else if (_globals[kHeListened] || (_globals[kFightStatus] == 0)) + _game._player.walk(Common::Point(286, 120), FACING_NORTHEAST); + } + + if (_anim2ActvFl && !_action.isAction(VERB_SIT_IN) && _game._player._needToWalk) { + _chairStatus = 1; + _game._player._stepEnabled = false; + _game._player._readyToWalk = false; + } + + if (_action.isAction(VERB_WALK_THROUGH, NOUN_LEFT_DOOR) || _action.isAction(VERB_OPEN, NOUN_LEFT_DOOR)) { + if ((_globals[kFightStatus] == 0) && (_globals[kCoffinStatus] == 2) && !_game._visitedScenes.exists(506)) { + _vm->_dialogs->show(50432); + _game._player.cancelCommand(); + return; + } else if (_game._visitedScenes.exists(506)) + _game._player.walk(Common::Point(0, 109), FACING_NORTHWEST); + else if (!_game._objects.isInInventory(OBJ_MUSIC_SCORE) || (_globals[kFightStatus] == 0)) + _game._player.walk(Common::Point(33, 116), FACING_NORTHWEST); + } + + if ((_globals[kFightStatus] == 0) && (_globals[kCoffinStatus] == 2) && !_game._visitedScenes.exists(506) + && !_action.isAction(VERB_LOOK) && !_action.isAction(VERB_LOOK_AT) && !_action.isAction(VERB_ATTACK) + && !_action.isAction(VERB_TAKE, NOUN_SWORD) && !_action.isAction(VERB_TALK_TO, NOUN_PHANTOM)) { + _vm->_dialogs->show(50430); + _game._player.cancelCommand(); + } +} + +void Scene504::handleListenAnimation() { + int curFrame = _scene->_animation[_globals._animationIndexes[0]]->getCurrentFrame(); + if (curFrame == _listenFrame) + return; + + _listenFrame = curFrame; + int resetFrame = -1; + + switch (_listenFrame) { + case 8: + _vm->_gameConv->release(); + break; + + case 9: + resetFrame = (_listenStatus == 0) ? 8 : 9; + break; + + default: + break; + } + + if (resetFrame >= 0) { + _scene->setAnimFrame(_globals._animationIndexes[0], resetFrame); + _listenFrame = resetFrame; + } +} + +void Scene504::handleOrganAnimation() { + int curFrame = _scene->_animation[_globals._animationIndexes[1]]->getCurrentFrame(); + if (curFrame == _playFrame) + return; + + _playFrame = curFrame; + int resetFrame = -1; + + switch (_playFrame) { + case 22: + _game._player._stepEnabled = true; + _vm->_gameConv->run(27); + break; + + case 23: + if (_playStatus == 0) + resetFrame = 22; + else { + _game._player._stepEnabled = false; + if (_songNum == 5) { + _playingMusicFl = false; + _fireBreathFl = false; + resetFrame = 104; + } + } + break; + + case 28: + if (!_playingMusicFl) { + _playingMusicFl = true; + _fireBreathFl = true; + _game._player._stepEnabled = false; + + switch (_songNum) { + case 1: + _vm->_sound->command(34); + break; + + case 2: + _vm->_sound->command(37); + break; + + case 3: + _vm->_sound->command(35); + break; + + case 4: + _vm->_sound->command(36); + break; + + default: + break; + } + } + break; + + case 69: + if ((_globals[kRightDoorIsOpen504]) && (_playCount >= 2)) { + _playCount = 0; + resetFrame = 102; + _vm->_sound->command(2); + _vm->_sound->command(16); + } else if (_songNum != _globals[kMusicSelected]) { + _vm->_sound->command(2); + _fireBreathFl = true; + resetFrame = 75; + } else { + resetFrame = 25; + ++_playCount; + if (!_globals[kRightDoorIsOpen504]) { + _scene->_sequences.addTimer(1, 80); + _globals[kPlayerScore] += 5; + } + } + break; + + case 76: + _scene->playSpeech(7); + break; + + case 90: + _vm->_sound->command(27); + break; + + case 102: + ++_deathCounter; + if (_deathCounter >= 17) + _scene->_reloadSceneFlag = true; + else + resetFrame = 101; + break; + + default: + break; + } + + if (resetFrame >= 0) { + _scene->setAnimFrame(_globals._animationIndexes[1], resetFrame); + _playFrame = resetFrame; + } +} + +void Scene504::handlePhantomAnimation1() { + int curFrame = _scene->_animation[_globals._animationIndexes[3]]->getCurrentFrame(); + if (curFrame == _phantomFrame) + return; + + _phantomFrame = curFrame; + int resetFrame = -1; + + switch (_phantomFrame) { + case 41: + _vm->_gameConv->run(21); + _vm->_gameConv->exportValue(_game._objects.isInInventory(OBJ_MUSIC_SCORE)); + _vm->_gameConv->exportValue(0); + break; + + case 52: + case 53: + case 54: + case 55: + resetFrame = (_phantomStatus == 0) ? _vm->getRandomNumber(51, 54) : 55; + break; + + case 78: + _vm->_gameConv->release(); + break; + + case 110: + case 111: + case 112: + case 113: + resetFrame = (_phantomStatus == 1) ? _vm->getRandomNumber(109, 112) : 113; + break; + + case 142: + _scene->drawToBackground(_globals._spriteIndexes[13], 1, Common::Point(-32000, -32000), 0, 100); + break; + + case 143: + _game._player._stepEnabled = true; + break; + + case 149: + case 150: + case 151: + ++_input3Count; + + if (_phantomStatus == 4) { + _game._player._stepEnabled = false; + resetFrame = 200; + } else if (_input3Count >= 9) { + _game._player._stepEnabled = false; + resetFrame = 151; + } else if (_phantomStatus == 2) + resetFrame = _vm->getRandomNumber(148, 150); + break; + + case 169: + _vm->_sound->command(1); + _scene->playSpeech(7); + break; + + case 180: + _vm->_sound->command(27); + break; + + case 187: + _deathCounter = 0; + break; + + case 189: + ++_deathCounter; + if (_deathCounter >= 29) + _scene->_reloadSceneFlag = true; + else + resetFrame = 188; + break; + + case 227: + + _scene->freeAnimation(_globals._animationIndexes[3]); + _scene->_sprites.remove(_globals._spriteIndexes[9]); + _scene->_sprites.remove(_globals._spriteIndexes[8]); + _scene->_sprites.remove(_globals._spriteIndexes[7]); + _scene->_sprites.remove(_globals._spriteIndexes[10]); + _scene->_sprites.remove(_globals._spriteIndexes[11]); + + _globals._spriteIndexes[6] = _scene->_sprites.addSprites("*CHR_3", PALFLAG_ALL_TO_CLOSEST | PALFLAG_ANY_TO_CLOSEST); + _globals._spriteIndexes[12] = _scene->_sprites.addSprites(formAnimName('a', 8), PALFLAG_ALL_TO_CLOSEST | PALFLAG_ANY_TO_CLOSEST); + _globals._animationIndexes[3] = _scene->loadAnimation(formAnimName('p', 2), 130); + + _scene->setAnimFrame(_globals._animationIndexes[3], 27); + resetFrame = -1; + _anim3ActvFl = false; + _anim4ActvFl = true; + break; + + default: + break; + } + + if (resetFrame >= 0) { + _scene->setAnimFrame(_globals._animationIndexes[3], resetFrame); + _phantomFrame = resetFrame; + } +} + +void Scene504::handlePhantomAnimation2() { + int curFrame = _scene->_animation[_globals._animationIndexes[3]]->getCurrentFrame(); + if (curFrame == _phantomFrame) + return; + + _phantomFrame = curFrame; + int resetFrame = -1; + + switch (_phantomFrame) { + case 78: + _scene->playSpeech(9); + break; + + case 119: + _game._player._playerPos = Common::Point(114, 137); + _game._player._facing = FACING_WEST; + _game._player._visible = true; + _globals[kPlayerScore] += 5; + _game.syncTimers(SYNC_PLAYER, 0, SYNC_ANIM, _globals._animationIndexes[3]); + _game._player.walk(Common::Point(130, 135), FACING_NORTHEAST); + _scene->_hotspots.activate(NOUN_CHRISTINE, false); + _game._player.setWalkTrigger(120); + _vm->_sound->command(1); + break; + + case 150: + _vm->_sound->command(16); + break; + + case 160: + switch (_playStatus) { + case 5: + resetFrame = 164; + break; + + case 7: + resetFrame = 160; + break; + + default: + resetFrame = 159; + break; + } + break; + + case 161: + case 162: + case 163: + case 164: + resetFrame = (_phantomStatus == 5) ? 159 : _vm->getRandomNumber(160, 162); + + ++_christineTalkCount; + if (_christineTalkCount > 10) { + resetFrame = 159; + if (_phantomStatus != 5) + _phantomStatus = 4; + } + break; + + default: + break; + } + + if (resetFrame >= 0) { + _scene->setAnimFrame(_globals._animationIndexes[3], resetFrame); + _phantomFrame = resetFrame; + } +} + +void Scene504::handlePhantomAnimation3() { + int curFrame = _scene->_animation[_globals._animationIndexes[3]]->getCurrentFrame(); + if (curFrame == _phantomFrame) + return; + + _phantomFrame = curFrame; + int resetFrame = -1; + + switch (_phantomFrame) { + case 58: + _game._player._stepEnabled = true; + break; + + case 80: + if (_phantomStatus == 7) + resetFrame = 116; + else if (_phantomStatus != 6) + resetFrame = 79; + break; + + case 115: + _game._player.walk(Common::Point(0, 109), FACING_NORTHWEST); + _game._player.setWalkTrigger(136); + break; + + case 116: + resetFrame = 115; + break; + + case 117: + case 118: + case 119: + resetFrame = _vm->getRandomNumber(116, 118); + ++_christineTalkCount; + if (_christineTalkCount > 10) { + resetFrame = 79; + if (_phantomStatus != 6) + _phantomStatus = 5; + } + break; + + default: + break; + } + + if (resetFrame >= 0) { + _scene->setAnimFrame(_globals._animationIndexes[3], resetFrame); + _phantomFrame = resetFrame; + } +} + +void Scene504::handleChairAnimation() { + int curFrame = _scene->_animation[_globals._animationIndexes[2]]->getCurrentFrame(); + if (curFrame == _chairFrame) + return; + + _chairFrame = curFrame; + int resetFrame = -1; + + switch (_chairFrame) { + case 24: + _game._player._stepEnabled = true; + break; + + case 25: + case 26: + case 30: + case 31: + if (!_chairDialogDoneFl) { + _chairDialogDoneFl = true; + _vm->_dialogs->show(50424); + } + + if (_chairStatus == 0) { + if (_vm->getRandomNumber(1,5) == 1) + resetFrame = _vm->getRandomNumber(24, 30); + else + resetFrame = _chairFrame - 1; + } else + resetFrame = 31; + break; + + case 47: + resetFrame = -1; + _game._player._stepEnabled = true; + _game._player._visible = true; + _game._player._readyToWalk = true; + _anim2ActvFl = false; + _chairDialogDoneFl = false; + _scene->freeAnimation(_globals._animationIndexes[2]); + break; + + default: + break; + } + + if (resetFrame >= 0) { + _scene->setAnimFrame(_globals._animationIndexes[2], resetFrame); + _chairFrame = resetFrame; + } +} + +void Scene504::handleListenConversation() { + if ((_action._activeAction._verbId == 2) && !_game._trigger) { + _game._player.walk(Common::Point(286, 120), FACING_EAST); + _game._player.setWalkTrigger(95); + } + + if (_action._activeAction._verbId == 12) + _listenStatus = 1; +} + +void Scene504::handlePlayConversation() { + switch (_action._activeAction._verbId) { + case 2: + *_vm->_gameConv->_nextStartNode = 1; + _vm->_gameConv->abortConv(); + _playStatus = 1; + _songNum = 1; + break; + + case 3: + *_vm->_gameConv->_nextStartNode = 1; + _vm->_gameConv->abortConv(); + _playStatus = 1; + _songNum = 2; + break; + + case 4: + *_vm->_gameConv->_nextStartNode = 1; + _vm->_gameConv->abortConv(); + _playStatus = 1; + _songNum = 3; + break; + + case 5: + *_vm->_gameConv->_nextStartNode = 1; + _vm->_gameConv->abortConv(); + _playStatus = 1; + _songNum = 4; + break; + + case 6: + *_vm->_gameConv->_nextStartNode = 1; + _vm->_gameConv->abortConv(); + _playStatus = 1; + _songNum = 5; + break; + + case 8: + *_vm->_gameConv->_nextStartNode = 1; + _vm->_gameConv->abortConv(); + _playStatus = 1; + break; + + default: + break; + } +} + +void Scene504::handleFightConversation() { + switch (_action._activeAction._verbId) { + case 3: + _vm->_gameConv->hold(); + _phantomStatus = 1; + break; + + case 8: + _phantomStatus = 2; + break; + + case 10: + case 11: + case 12: + case 15: + _vm->_gameConv->setInterlocutorTrigger(145); + break; + + case 14: + case 17: + _phantomStatus = 5; + _globals[kFightStatus] = 2; + break; + + default: + break; + } + + if ((_game._trigger == 145) && (_phantomStatus != 5)) { + _phantomStatus = 7; + _christineTalkCount = 0; + } +} + +/*------------------------------------------------------------------------*/ + +Scene505::Scene505(MADSEngine *vm) : Scene5xx(vm) { + _anim0ActvFl = false; + _anim1ActvFl = false; + _anim2ActvFl = false; + _checkFrame106 = false; + _leaveRoomFl = false; + _partedFl = false; + + _raoulStatus = -1; + _raoulFrame = -1; + _raoulCount = -1; + _bothStatus = -1; + _bothFrame = -1; + _bothCount = -1; + _partStatus = -1; + _partFrame = -1; + _partCount = -1; +} + +void Scene505::synchronize(Common::Serializer &s) { + Scene5xx::synchronize(s); + + s.syncAsByte(_anim0ActvFl); + s.syncAsByte(_anim1ActvFl); + s.syncAsByte(_anim2ActvFl); + s.syncAsByte(_checkFrame106); + s.syncAsByte(_leaveRoomFl); + s.syncAsByte(_partedFl); + + s.syncAsSint16LE(_raoulStatus); + s.syncAsSint16LE(_raoulFrame); + s.syncAsSint16LE(_raoulCount); + s.syncAsSint16LE(_bothStatus); + s.syncAsSint16LE(_bothFrame); + s.syncAsSint16LE(_bothCount); + s.syncAsSint16LE(_partStatus); + s.syncAsSint16LE(_partFrame); + s.syncAsSint16LE(_partCount); +} + +void Scene505::setup() { + setPlayerSpritesPrefix(); + setAAName(); + + if ((_globals[kCoffinStatus] == 2) && (!_globals[kChrisLeft505])) + _scene->_variant = 1; + + _scene->addActiveVocab(NOUN_CHRISTINE); +} + +void Scene505::enter() { + _vm->_disableFastwalk = true; + + if (_scene->_priorSceneId != RETURNING_FROM_LOADING) { + _partedFl = false; + _leaveRoomFl = false; + _anim0ActvFl = false; + _anim1ActvFl = false; + _anim2ActvFl = false; + _checkFrame106 = false; + } + + _vm->_gameConv->get(20); + _scene->_hotspots.activateAtPos(NOUN_LID, false, Common::Point(216, 44)); + _scene->_hotspots.activate(NOUN_CHRISTINE, false); + + _globals._spriteIndexes[7] = _scene->_sprites.addSprites(formAnimName('x', 6)); + _globals._spriteIndexes[0] = _scene->_sprites.addSprites(formAnimName('a', 1)); + _globals._spriteIndexes[1] = _scene->_sprites.addSprites(formAnimName('x', 0)); + _globals._spriteIndexes[2] = _scene->_sprites.addSprites(formAnimName('x', 1)); + _globals._spriteIndexes[3] = _scene->_sprites.addSprites(formAnimName('x', 2)); + _globals._spriteIndexes[4] = _scene->_sprites.addSprites(formAnimName('x', 3)); + _globals._spriteIndexes[5] = _scene->_sprites.addSprites(formAnimName('x', 4)); + _globals._spriteIndexes[6] = _scene->_sprites.addSprites(formAnimName('x', 5)); + _globals._spriteIndexes[8] = _scene->_sprites.addSprites(formAnimName('a', 4)); + + if (_scene->_priorSceneId == RETURNING_FROM_LOADING) { + if (_vm->_gameConv->_restoreRunning == 20) { + _scene->_hotspots.activate(NOUN_LID, false); + _scene->_hotspots.activateAtPos(NOUN_LID, true, Common::Point(216, 44)); + _globals._sequenceIndexes[7] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[7], false, 12); + _scene->_sequences.setDepth(_globals._sequenceIndexes[7], 1); + + _globals._animationIndexes[1] = _scene->loadAnimation(formAnimName('c', 1), 65); + _scene->setAnimFrame(_globals._animationIndexes[1], 109); + _anim1ActvFl = true; + _game._player._visible = false; + _game._player._stepEnabled = false; + _bothStatus = 3; + + _vm->_gameConv->run(20); + _vm->_gameConv->exportPointer(&_globals[kPlayerScore]); + } else if (_partedFl && (_globals[kFightStatus] == 0)) { + _scene->_hotspots.activate(NOUN_LID, false); + _scene->_hotspots.activateAtPos(NOUN_LID, true, Common::Point(216, 44)); + _globals._sequenceIndexes[7] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[7], false, 12); + _scene->_sequences.setDepth(_globals._sequenceIndexes[7], 1); + + _anim2ActvFl = true; + _bothStatus = 3; + _globals._animationIndexes[2] = _scene->loadAnimation(formAnimName('b', 1), 0); + int hotspotIdx = _scene->_dynamicHotspots.add(NOUN_CHRISTINE, VERB_WALK_TO, SYNTAX_SINGULAR_FEM, EXT_NONE, Common::Rect(0, 0, 0, 0)); + _scene->_dynamicHotspots[hotspotIdx]._articleNumber = PREP_ON; + _scene->_dynamicHotspots.setPosition(hotspotIdx, Common::Point(91, 108), FACING_NORTHWEST); + _scene->setAnimFrame(_globals._animationIndexes[2], 89); + _scene->setDynamicAnim(hotspotIdx, _globals._animationIndexes[2], 3); + _scene->setDynamicAnim(hotspotIdx, _globals._animationIndexes[2], 4); + _scene->setDynamicAnim(hotspotIdx, _globals._animationIndexes[2], 5); + _scene->setDynamicAnim(hotspotIdx, _globals._animationIndexes[2], 6); + _scene->setDynamicAnim(hotspotIdx, _globals._animationIndexes[2], 7); + } else if (_globals[kFightStatus]) { + _scene->_hotspots.activate(NOUN_LID, false); + _scene->_hotspots.activateAtPos(NOUN_LID, true, Common::Point(216, 44)); + _globals._sequenceIndexes[7] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[7], false, 12); + _scene->_sequences.setDepth(_globals._sequenceIndexes[7], 1); + } else { + _globals._animationIndexes[1] = _scene->loadAnimation(formAnimName('c', 1), 65); + _anim1ActvFl = true; + _bothStatus = 0; + _scene->_hotspots.activate(NOUN_CHRISTINE, true); + } + } + + if ((_scene->_priorSceneId == 504) || (_scene->_priorSceneId != RETURNING_FROM_LOADING)) { + _game._player._playerPos = Common::Point(5, 87); + _game._player._facing = FACING_EAST; + _game._player._stepEnabled = false; + _game._player.walk(Common::Point(58, 104), FACING_SOUTHEAST); + if (_globals[kCoffinStatus] != 2) { + _game._player.setWalkTrigger(70); + _anim1ActvFl = true; + _bothStatus = 0; + _scene->_hotspots.activate(NOUN_CHRISTINE, true); + _globals._animationIndexes[1] = _scene->loadAnimation(formAnimName('c', 1), 65); + } else { + _scene->_hotspots.activate(NOUN_LID, false); + _scene->_hotspots.activateAtPos(NOUN_LID, true, Common::Point(216, 44)); + _globals._sequenceIndexes[7] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[7], false, 12); + _scene->_sequences.setDepth(_globals._sequenceIndexes[7], 1); + _game._player._stepEnabled = true; + } + } + + sceneEntrySound(); +} + +void Scene505::step() { + if (_anim0ActvFl) + handleRaoulAnimation(); + + if (_anim1ActvFl) + handleBothanimation(); + + if (_anim2ActvFl) + handlePartedAnimation(); + + if (_game._trigger == 65) { + _scene->freeAnimation(_globals._animationIndexes[1]); + _vm->_sound->command(1); + _partedFl = true; + _anim2ActvFl = true; + _anim1ActvFl = false; + _globals._animationIndexes[2] = _scene->loadAnimation(formAnimName('b', 1), 0); + + int hotspotIDx = _scene->_dynamicHotspots.add(NOUN_CHRISTINE, VERB_WALK_TO, SYNTAX_SINGULAR_FEM, EXT_NONE, Common::Rect(0, 0, 0, 0)); + _scene->_dynamicHotspots.setPosition(hotspotIDx, Common::Point(91, 108), FACING_NORTHWEST); + _scene->_dynamicHotspots[hotspotIDx]._articleNumber = PREP_ON; + _scene->setDynamicAnim(hotspotIDx, _globals._animationIndexes[2], 3); + _scene->setDynamicAnim(hotspotIDx, _globals._animationIndexes[2], 4); + _scene->setDynamicAnim(hotspotIDx, _globals._animationIndexes[2], 5); + _scene->setDynamicAnim(hotspotIDx, _globals._animationIndexes[2], 6); + _scene->setDynamicAnim(hotspotIDx, _globals._animationIndexes[2], 7); + } + + if (_game._trigger == 70) { + _game._player._stepEnabled = true; + if (!_game._visitedScenes._sceneRevisited) { + _vm->_gameConv->run(20); + _vm->_gameConv->exportPointer(&_globals[kPlayerScore]); + } + } +} + +void Scene505::actions() { + if (_game._trigger == 80) { + _bothStatus = 2; + _action._inProgress = false; + return; + } + + if (_vm->_gameConv->_running == 20) { + handleCoffinDialog(); + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_TALK_TO, NOUN_CHRISTINE)) { + if (_globals[kCoffinStatus] != 2) + _vm->_dialogs->show(50536); + else { + _vm->_gameConv->run(20); + _vm->_gameConv->exportPointer(&_globals[kPlayerScore]); + _partStatus = 10; + _partCount = 0; + } + _action._inProgress = false; + return; + } + + if ((_action.isAction(VERB_UNLOCK, NOUN_SARCOPHAGUS) || _action.isAction(VERB_UNLOCK, NOUN_LID)) && !_globals[kLookedAtSkullFace]) { + _vm->_dialogs->show(50539); + _action._inProgress = false; + return; + } + + if ((_action.isAction(VERB_UNLOCK, NOUN_SKULL_FACE) || _action.isAction(VERB_PUT, NOUN_KEY, NOUN_SKULL_FACE)) || ((_action.isAction(VERB_UNLOCK, NOUN_SARCOPHAGUS) || _action.isAction(VERB_UNLOCK, NOUN_LID)) && _globals[kLookedAtSkullFace])) { + if (_globals[kCoffinStatus] == 0) { + switch (_game._trigger) { + case (0): + _game._player._stepEnabled = false; + _game._player._visible = false; + _globals._sequenceIndexes[8] = _scene->_sequences.startPingPongCycle(_globals._spriteIndexes[8], false, 5, 2); + _scene->_sequences.setAnimRange(_globals._sequenceIndexes[8], -1, -2); + _scene->_sequences.setSeqPlayer(_globals._sequenceIndexes[8], true); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[8], SEQUENCE_TRIGGER_SPRITE, 9, 95); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[8], SEQUENCE_TRIGGER_EXPIRE, 0, 96); + _action._inProgress = false; + return; + + case 95: + _vm->_sound->command(76); + _vm->_dialogs->show(50528); + _action._inProgress = false; + return; + + case 96: + _game._player._visible = true; + _game._player._stepEnabled = true; + _globals[kCoffinStatus] = 1; + _game.syncTimers(SYNC_PLAYER, 0, SYNC_SEQ, _globals._sequenceIndexes[8]); + _action._inProgress = false; + return; + + default: + break; + } + } else { + _vm->_dialogs->show(50534); + _action._inProgress = false; + return; + } + } + + if (_action.isAction(VERB_PUSH, NOUN_SKULL) && (_scene->_customDest.x >= 19)) { + switch (_game._trigger) { + case 0: + _game._player._stepEnabled = false; + _game._player._visible = false; + _globals._sequenceIndexes[0] = _scene->_sequences.startPingPongCycle(_globals._spriteIndexes[0], false, 5, 2); + _scene->_sequences.setAnimRange(_globals._sequenceIndexes[0], -1, -2); + _scene->_sequences.setSeqPlayer(_globals._sequenceIndexes[0], true); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[0], SEQUENCE_TRIGGER_SPRITE, 6, 1); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[0], SEQUENCE_TRIGGER_EXPIRE, 0, 2); + break; + + case 1: { + int sprIdx; + _vm->_sound->command(77); + if (_scene->_customDest.x <= 44) + sprIdx = _globals._spriteIndexes[4]; + else if (_scene->_customDest.x <= 58) + sprIdx = _globals._spriteIndexes[3]; + else if (_scene->_customDest.x <= 71) + sprIdx = _globals._spriteIndexes[2]; + else if (_scene->_customDest.x <= 84) { + sprIdx = _globals._spriteIndexes[1]; + if (_globals[kCoffinStatus] == 1) { + _bothStatus = 1; + _scene->_hotspots.activate(NOUN_LID, false); + _scene->_hotspots.activate(NOUN_CHRISTINE, false); + _scene->_hotspots.activateAtPos(NOUN_LID, true, Common::Point(216, 44)); + _scene->changeVariant(1); + } + } else if (_scene->_customDest.x <= 100) + sprIdx = _globals._spriteIndexes[5]; + else + sprIdx = _globals._spriteIndexes[6]; + + int skullSeqIdx = _scene->_sequences.startPingPongCycle(sprIdx, false, 5, 2); + _scene->_sequences.setAnimRange(skullSeqIdx, -1, -2); + _scene->_sequences.setDepth(skullSeqIdx, 1); + } + break; + + case 2: + _game.syncTimers(SYNC_PLAYER, 0, SYNC_SEQ, _globals._sequenceIndexes[0]); + _game._player._visible = true; + _game._player._stepEnabled = true; + if (_bothStatus == 1) { + _game._player.walk(Common::Point(136, 126), FACING_EAST); + _game._player.setWalkTrigger(80); + _game._player._stepEnabled = false; + } + break; + + default: + break; + } + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_WALK_THROUGH, NOUN_DOOR)) { + if (_anim2ActvFl) { + _leaveRoomFl = true; + _game._player._stepEnabled = false; + } else { + _globals[kChrisLeft505] = true; + _scene->_nextSceneId = 504; + } + _action._inProgress = false; + return; + } + + if (_action._lookFlag) { + _vm->_dialogs->show(50510); + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_LOOK) || _action.isAction(VERB_LOOK_AT)) { + if (_action.isObject(NOUN_FLOOR)) { + _vm->_dialogs->show(50511); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_WALL)) { + _vm->_dialogs->show(50512); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_SARCOPHAGUS)) { + _vm->_dialogs->show((_globals[kCoffinStatus] <= 1) ? 50513 : 50514); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_SKULL_FACE)) { + _globals[kLookedAtSkullFace] = true; + _vm->_dialogs->show(50529); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_DOOR)) { + _vm->_dialogs->show(50519); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_SKULL)) { + _vm->_dialogs->show((_scene->_customDest.x < 19) ? 50521 : 50520); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_SKULLS)) { + _vm->_dialogs->show(50521); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_TOTEM)) { + _vm->_dialogs->show(50522); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_DESK)) { + _vm->_dialogs->show(50523); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_POLE)) { + _vm->_dialogs->show(50524); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_CURTAIN)) { + _vm->_dialogs->show(50525); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_CHRISTINE)) { + _vm->_dialogs->show((_globals[kCoffinStatus] == 2) ? 50530 : 50537); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_LID)) { + _vm->_dialogs->show((_globals[kCoffinStatus] == 2) ? 50531 : 50532); + _action._inProgress = false; + return; + } + } + + if (_action.isAction(VERB_LOCK, NOUN_SARCOPHAGUS) || _action.isAction(VERB_LOCK, NOUN_LID) || _action.isAction(VERB_LOCK, NOUN_SKULL_FACE)) { + _vm->_dialogs->show(50535); + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_OPEN, NOUN_SARCOPHAGUS) || _action.isAction(VERB_OPEN, NOUN_LID)) { + if (_globals[kCoffinStatus] == 2) + _vm->_dialogs->show(50533); + else if (_globals[kCoffinStatus] == 1) + _vm->_dialogs->show(50518); + else + _vm->_dialogs->show(50515); + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_TAKE, NOUN_CHRISTINE) && (_globals[kCoffinStatus] != 2)) { + _vm->_dialogs->show(50538); + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_TAKE, NOUN_CHRISTINE)) { + _vm->_dialogs->show((_globals[kCoffinStatus] <= 1) ? 50538 : 50540); + _action._inProgress = false; + } +} + +void Scene505::preActions() { + if ((_globals[kCoffinStatus] == 0) && (_action.isAction(VERB_UNLOCK, NOUN_SKULL_FACE) || _action.isAction(VERB_UNLOCK, NOUN_SARCOPHAGUS) || _action.isAction(VERB_PUT, NOUN_KEY, NOUN_SKULL_FACE) || _action.isAction(VERB_UNLOCK, NOUN_LID))) { + if (_action.isObject(NOUN_SKULL_FACE) || _globals[kLookedAtSkullFace]) + _game._player.walk(Common::Point(279, 150), FACING_SOUTHWEST); + } + + if (_action.isObject(NOUN_SKULL_FACE) && (_action.isAction(VERB_LOOK) || _action.isAction(VERB_LOOK_AT))) + _game._player.walk(Common::Point(279, 150), FACING_SOUTHWEST); + + if (_action.isObject(NOUN_CURTAIN) && (_action.isAction(VERB_LOOK) || _action.isAction(VERB_LOOK_AT))) + _game._player._needToWalk = true; + + if (_action.isObject(NOUN_SKULL) && (_action.isAction(VERB_LOOK) || _action.isAction(VERB_LOOK_AT))) + _game._player._needToWalk = true; +} + +void Scene505::handleCoffinDialog() { + int interlocutorFl = false; + int heroFl = false; + + switch (_action._activeAction._verbId) { + case 8: + heroFl = true; + interlocutorFl = true; + _bothStatus = 6; + break; + + case 14: + heroFl = true; + interlocutorFl = true; + if (!_checkFrame106) + _vm->_gameConv->hold(); + break; + + case 17: + heroFl = true; + interlocutorFl = true; + if (!_game._trigger) { + _vm->_gameConv->hold(); + _raoulStatus = 2; + } + break; + + case 20: + heroFl = true; + interlocutorFl = true; + if (!_game._trigger) { + _vm->_gameConv->hold(); + _game._player.walk(Common::Point(244, 130), FACING_SOUTHWEST); + _game._player.setWalkTrigger(71); + } + break; + + case 22: + heroFl = true; + interlocutorFl = true; + if (!_game._trigger) { + _vm->_gameConv->hold(); + _bothStatus = 7; + } + break; + + default: + break; + } + + switch (_game._trigger) { + case 70: + case 76: + _vm->_gameConv->release(); + break; + + case 71: + _globals._animationIndexes[0] = _scene->loadAnimation(formAnimName('r', 1), 75); + _anim0ActvFl = true; + _raoulStatus = 0; + _raoulCount = 0; + _game._player._visible = false; + break; + + case 75: + _game._player._visible = true; + _game.syncTimers(SYNC_PLAYER, 0, SYNC_ANIM, _globals._animationIndexes[0]); + _scene->_sequences.addTimer(10, 76); + break; + + case 85: + if ((_bothStatus != 6) && (_bothStatus != 0)) + _bothStatus = 5; + break; + + case 90: + if ((_bothStatus != 6) && (_bothStatus != 0)) + _bothStatus = 4; + break; + + default: + break; + } + + if (!heroFl) + _vm->_gameConv->setHeroTrigger(85); + + if (!interlocutorFl) + _vm->_gameConv->setInterlocutorTrigger(90); + + _bothCount = 0; +} + +void Scene505::handleRaoulAnimation() { + int curFrame = _scene->_animation[_globals._animationIndexes[0]]->getCurrentFrame(); + if (curFrame == _raoulFrame) + return; + + _raoulFrame = curFrame; + int resetFrame = -1; + + switch (_raoulFrame) { + case 3: + _vm->_gameConv->release(); + break; + + case 4: + case 5: + case 6: + if (_raoulStatus == 0) { + resetFrame = _vm->getRandomNumber(3, 5); + ++_raoulCount; + if (_raoulCount > 20) { + _raoulStatus = 1; + resetFrame = 3; + } + break; + } + + if (_raoulStatus == 1) + resetFrame = 3; + + if (_raoulStatus == 2) + resetFrame = 6; + break; + + default: + break; + } + + if (resetFrame >= 0) { + _scene->setAnimFrame(_globals._animationIndexes[0], resetFrame); + _raoulFrame = resetFrame; + } +} + +void Scene505::handleBothanimation() { + int curFrame = _scene->_animation[_globals._animationIndexes[1]]->getCurrentFrame(); + if (curFrame == _bothFrame) + return; + + _bothFrame = curFrame; + int resetFrame = -1; + + switch (_bothFrame) { + case 1: + case 20: + case 39: + if (_bothStatus == 0) { + if (_vm->getRandomNumber(1, 35) == 1) { + if (_vm->getRandomNumber(1, 2) == 1) + resetFrame = 1; + else + resetFrame = 20; + } else + resetFrame = 0; + } else if (_bothStatus == 1) + resetFrame = 39; + else + resetFrame = 0; + break; + + case 14: + if (_vm->getRandomNumber(1, 3) == 1) + resetFrame = 8; + break; + + case 32: + if (_vm->getRandomNumber(1, 2) == 1) + resetFrame = 28; + break; + + case 41: + _vm->_sound->command(39); + break; + + case 51: + _globals._sequenceIndexes[7] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[7], false, 12); + _scene->_sequences.setDepth(_globals._sequenceIndexes[7], 1); + _globals[kCoffinStatus] = 2; + break; + + case 66: + _game._player._stepEnabled = false; + _vm->_gameConv->run(20); + _vm->_gameConv->exportPointer(&_globals[kPlayerScore]); + break; + + case 67: + if (_bothStatus == 1) + resetFrame = 66; + break; + + case 68: + _game._player._visible = false; + _game.syncTimers(SYNC_PLAYER, 0, SYNC_ANIM, _globals._animationIndexes[1]); + break; + + case 106: + _checkFrame106 = true; + _vm->_gameConv->release(); + break; + + case 109: + case 130: + _vm->_gameConv->release(); + break; + + case 110: + case 111: + case 112: + case 113: + case 114: + case 115: + case 131: + switch (_bothStatus) { + case 4: + resetFrame = _vm->getRandomNumber(112, 114); + ++_bothCount; + if (_bothCount > 20) { + _bothStatus = 3; + resetFrame = 109; + } + break; + + case 5: + resetFrame = _vm->getRandomNumber(109, 111); + ++_bothCount; + if (_bothCount > 20) { + _bothStatus = 3; + resetFrame = 109; + } + break; + + case 6: + resetFrame = 131; + _bothStatus = 8; + _game._player._stepEnabled = false; + break; + + case 7: + resetFrame = 115; + _bothStatus = 3; + break; + + default: + resetFrame = 109; + break; + } + break; + + case 127: + _vm->_sound->command(26); + _game._objects.addToInventory(OBJ_WEDDING_RING); + _vm->_dialogs->showItem(OBJ_WEDDING_RING, 821, 0); + break; + + default: + break; + } + + if (resetFrame >= 0) { + _scene->setAnimFrame(_globals._animationIndexes[1], resetFrame); + _bothFrame = resetFrame; + } +} + +void Scene505::handlePartedAnimation() { + int curFrame = _scene->_animation[_globals._animationIndexes[2]]->getCurrentFrame(); + if (curFrame == _partFrame) + return; + + _partFrame = curFrame; + int resetFrame = -1; + + switch (_partFrame) { + case 20: + _vm->_sound->command(16); + break; + + case 25: + _game._player._playerPos = Common::Point(93, 133); + _game._player.resetFacing(FACING_WEST); + _game._player._visible = true; + _game.syncTimers(SYNC_PLAYER, 0, SYNC_ANIM, _globals._animationIndexes[2]); + break; + + case 70: + _game._player._stepEnabled = true; + break; + + case 90: + if (_partStatus == 10) + resetFrame = 146; + else if (!_leaveRoomFl) + resetFrame = 89; + break; + + case 145: + _scene->_nextSceneId = 504; + break; + + case 147: + case 148: + case 149: + resetFrame = _vm->getRandomNumber(146, 148); + ++_partCount; + if (_partCount > 10) { + resetFrame = 89; + _partStatus = 8; + } + break; + + default: + break; + } + + if (resetFrame >= 0) { + _scene->setAnimFrame(_globals._animationIndexes[2], resetFrame); + _partFrame = resetFrame; + } +} + +/*------------------------------------------------------------------------*/ + +Scene506::Scene506(MADSEngine *vm) : Scene5xx(vm) { + _anim0ActvFl = false; + _skipFl = false; + _ascendingFl = false; +} + +void Scene506::synchronize(Common::Serializer &s) { + Scene5xx::synchronize(s); + + s.syncAsByte(_anim0ActvFl); + s.syncAsByte(_skipFl); + s.syncAsByte(_ascendingFl); +} + +void Scene506::setup() { + setPlayerSpritesPrefix(); + setAAName(); + + _scene->addActiveVocab(NOUN_CHRISTINE); + _scene->addActiveVocab(VERB_LOOK_AT); + + if (!_globals[kChristineIsInBoat]) + _scene->_variant = 1; +} + +void Scene506::enter() { + _vm->_disableFastwalk = true; + + if (_scene->_priorSceneId != RETURNING_FROM_LOADING) { + _anim0ActvFl = false; + _skipFl = false; + _ascendingFl = false; + } + + _vm->_gameConv->get(26); + + _globals._spriteIndexes[0] = _scene->_sprites.addSprites(formAnimName('x', 0)); + _globals._spriteIndexes[1] = _scene->_sprites.addSprites(formAnimName('x', 1)); + _globals._spriteIndexes[2] = _scene->_sprites.addSprites(formAnimName('x', 2)); + _globals._spriteIndexes[3] = _scene->_sprites.addSprites(formAnimName('x', 3)); + _globals._spriteIndexes[5] = _scene->_sprites.addSprites(formAnimName('p', 0)); + _globals._spriteIndexes[7] = _scene->_sprites.addSprites(formAnimName('a', 1)); + _globals._spriteIndexes[8] = _scene->_sprites.addSprites(formAnimName('a', 0)); + _globals._spriteIndexes[6] = _scene->_sprites.addSprites(formAnimName('b', 0), PALFLAG_ALL_TO_CLOSEST | PALFLAG_ANY_TO_CLOSEST); + _globals._spriteIndexes[4] = _scene->_sprites.addSprites("*RDR_9"); + _globals._spriteIndexes[6] = _scene->_sprites.addSprites("*CHR_6", PALFLAG_ALL_TO_CLOSEST | PALFLAG_ANY_TO_CLOSEST); + _globals._spriteIndexes[6] = _scene->_sprites.addSprites("*CHR_3", PALFLAG_ALL_TO_CLOSEST | PALFLAG_ANY_TO_CLOSEST); + _globals._spriteIndexes[6] = _scene->_sprites.addSprites("*CHR_2", PALFLAG_ALL_TO_CLOSEST | PALFLAG_ANY_TO_CLOSEST); + + if (_game._objects.isInRoom(OBJ_OAR)) { + _globals._sequenceIndexes[5] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[5], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[5], 14); + } else + _scene->_hotspots.activate(NOUN_OAR, false); + + _globals._sequenceIndexes[0] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[0], false, 6, 0); + _scene->_sequences.setDepth(_globals._sequenceIndexes[0], 14); + _scene->_sequences.setAnimRange(_globals._sequenceIndexes[0], -1, -2); + + _globals._sequenceIndexes[1] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[1], false, 6, 0); + _scene->_sequences.setDepth(_globals._sequenceIndexes[1], 14); + _scene->_sequences.setAnimRange(_globals._sequenceIndexes[1], -1, -2); + + _globals._sequenceIndexes[2] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[2], false, 6, 0); + _scene->_sequences.setDepth(_globals._sequenceIndexes[2], 14); + _scene->_sequences.setAnimRange(_globals._sequenceIndexes[2], -1, -2); + + if (_scene->_priorSceneId == RETURNING_FROM_LOADING) { + _globals._sequenceIndexes[3] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[3], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[3], 14); + if (!_globals[kChristineIsInBoat]) { + _anim0ActvFl = true; + _globals._animationIndexes[0] = _scene->loadAnimation(formAnimName('r', 1), 0); + _scene->setAnimFrame(_globals._animationIndexes[0], 239); + int hotspotIdx = _scene->_dynamicHotspots.add(NOUN_CHRISTINE, VERB_WALK_TO, SYNTAX_SINGULAR_FEM, EXT_NONE, Common::Rect(0, 0, 0, 0)); + _scene->_dynamicHotspots[hotspotIdx]._articleNumber = PREP_ON; + _scene->_dynamicHotspots.setPosition(hotspotIdx, Common::Point(79, 133), FACING_SOUTHWEST); + _scene->setDynamicAnim(hotspotIdx, _globals._animationIndexes[0], 6); + } + } else if (_scene->_priorSceneId == 504) { + _globals._sequenceIndexes[3] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[3], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[3], 14); + + if (_game._visitedScenes._sceneRevisited) { + _game._player._playerPos = Common::Point(189, 123); + _game._player._facing = FACING_SOUTHWEST; + _game._player._stepEnabled = false; + _game._player._visible = false; + + if (!_globals[kChristineIsInBoat]) { + _anim0ActvFl = true; + _globals._animationIndexes[0] = _scene->loadAnimation(formAnimName('r', 1), 0); + _scene->setAnimFrame(_globals._animationIndexes[0], 239); + int hotspotIdx = _scene->_dynamicHotspots.add(NOUN_CHRISTINE, VERB_WALK_TO, SYNTAX_SINGULAR_FEM, EXT_NONE, Common::Rect(0, 0, 0, 0)); + _scene->_dynamicHotspots[hotspotIdx]._articleNumber = PREP_ON; + _scene->_dynamicHotspots.setPosition(hotspotIdx, Common::Point(79, 133), FACING_SOUTHWEST); + _scene->setDynamicAnim(hotspotIdx, _globals._animationIndexes[0], 6); + } + _globals._animationIndexes[1] = _scene->loadAnimation(formAnimName('r', 2), 95); + } else { + _game._player._playerPos = Common::Point(186, 122); + _game._player._facing = FACING_SOUTHWEST; + _game._player._stepEnabled = false; + _game._player._visible = false; + _anim0ActvFl = true; + _globals._animationIndexes[0] = _scene->loadAnimation(formAnimName('r', 1), 0); + int hotspotIdx = _scene->_dynamicHotspots.add(NOUN_CHRISTINE, VERB_WALK_TO, SYNTAX_SINGULAR_FEM, EXT_NONE, Common::Rect(0, 0, 0, 0)); + _scene->_dynamicHotspots[hotspotIdx]._articleNumber = PREP_ON; + _scene->_dynamicHotspots.setPosition(hotspotIdx, Common::Point(79, 133), FACING_SOUTHWEST); + _scene->setDynamicAnim(hotspotIdx, _globals._animationIndexes[0], 2); + _scene->setDynamicAnim(hotspotIdx, _globals._animationIndexes[0], 3); + _scene->setDynamicAnim(hotspotIdx, _globals._animationIndexes[0], 4); + _scene->setDynamicAnim(hotspotIdx, _globals._animationIndexes[0], 5); + _scene->setDynamicAnim(hotspotIdx, _globals._animationIndexes[0], 6); + } + } else if ((_scene->_priorSceneId == 501) || (_scene->_priorSceneId != RETURNING_FROM_LOADING)) { + _game._player._playerPos = Common::Point(0, 142); + _game._player._facing = FACING_EAST; + _game._player._stepEnabled = false; + _game._player.walk(Common::Point(23, 145), FACING_EAST); + _game._player.setWalkTrigger(60); + } + + sceneEntrySound(); +} + +void Scene506::step() { + switch (_game._trigger) { + case 60: + _globals._sequenceIndexes[3] = _scene->_sequences.addReverseSpriteCycle(_globals._spriteIndexes[3], false, 6, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[3], 14); + _scene->_sequences.setAnimRange(_globals._sequenceIndexes[3], -1, -2); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SEQUENCE_TRIGGER_EXPIRE, 0, 61); + break; + + case 61: + _globals._sequenceIndexes[3] = _scene->_sequences.addStampCycle(_globals._spriteIndexes[3], false, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[3], 14); + _game._player._stepEnabled = true; + break; + + case 95: + _game._player._visible = true; + _game._player._stepEnabled = true; + _game.syncTimers(SYNC_PLAYER, 0, SYNC_ANIM, _globals._animationIndexes[1]); + break; + + default: + break; + } + + if (_anim0ActvFl) { + int curFrame = _scene->_animation[_globals._animationIndexes[0]]->getCurrentFrame(); + if ((curFrame == 141) && !_skipFl) { + _game._player._visible = true; + _skipFl = true; + _game.syncTimers(SYNC_PLAYER, 0, SYNC_ANIM, _globals._animationIndexes[0]); + } + + if (curFrame == 240) + _scene->setAnimFrame(_globals._animationIndexes[0], 239); + + if (curFrame == 300) + _scene->setAnimFrame(_globals._animationIndexes[0], 239); + + if (curFrame == 168) + _game._player._stepEnabled = true; + + if (curFrame == 289) + _scene->_nextSceneId = 501; + } + + if (_ascendingFl && (_vm->_gameConv->_running != 26)) { + _ascendingFl = false; + _game._player._stepEnabled = false; + } +} + +void Scene506::actions() { + if (_action.isAction(VERB_TALK_TO, NOUN_CHRISTINE)) { + _vm->_gameConv->run(26); + _vm->_gameConv->exportValue(1); + _scene->setAnimFrame(_globals._animationIndexes[0], 290); + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_TAKE, NOUN_OAR)) { + switch (_game._trigger) { + case (0): + if (_game._objects.isInRoom(OBJ_OAR)) { + _game._player._stepEnabled = false; + _game._player._visible = false; + _globals._sequenceIndexes[4] = _scene->_sequences.startPingPongCycle(_globals._spriteIndexes[4], true, 5, 2); + _scene->_sequences.setAnimRange(_globals._sequenceIndexes[4], 1, 4); + _scene->_sequences.setSeqPlayer(_globals._sequenceIndexes[4], true); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[4], SEQUENCE_TRIGGER_SPRITE, 4, 1); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[4], SEQUENCE_TRIGGER_EXPIRE, 0, 2); + } + break; + + case 1: + _scene->deleteSequence(_globals._sequenceIndexes[5]); + _scene->_hotspots.activate(NOUN_OAR, false); + _game._objects.addToInventory(OBJ_OAR); + _vm->_sound->command(26); + break; + + case 2: + _game.syncTimers(SYNC_PLAYER, 0, SYNC_SEQ, _globals._sequenceIndexes[4]); + _game._player._visible = true; + _scene->_sequences.addTimer(20, 3); + break; + + case 3: + _vm->_dialogs->showItem(OBJ_OAR, 824, 0); + _game._player._stepEnabled = true; + break; + + default: + break; + } + _action._inProgress = false; + return; + } + + + if (_action.isAction(VERB_WALK_THROUGH, NOUN_DOOR) || _action.isAction(VERB_OPEN, NOUN_DOOR)) { + if (_scene->_customDest.x < 150) { + switch (_game._trigger) { + case (0): + _game._player._stepEnabled = false; + _game._player._visible = false; + _globals._sequenceIndexes[4] = _scene->_sequences.startPingPongCycle(_globals._spriteIndexes[4], true, 5, 2); + _scene->_sequences.setAnimRange(_globals._sequenceIndexes[4], 1, 4); + _scene->_sequences.setSeqPlayer(_globals._sequenceIndexes[4], true); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[4], SEQUENCE_TRIGGER_SPRITE, 4, 65); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[4], SEQUENCE_TRIGGER_EXPIRE, 0, 67); + break; + + case 65: + _scene->deleteSequence(_globals._sequenceIndexes[3]); + _globals._sequenceIndexes[3] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[3], false, 8, 1); + _scene->_sequences.setDepth(_globals._sequenceIndexes[3], 14); + _scene->_sequences.setAnimRange(_globals._sequenceIndexes[3], -1, -2); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SEQUENCE_TRIGGER_EXPIRE, 0, 66); + _vm->_sound->command(24); + break; + + case 66: + _game._player.walk(Common::Point(0, 142), FACING_WEST); + _game._player.setWalkTrigger(68); + break; + + case 67: + _game._player._visible = true; + break; + + case 68: + if (_globals[kChristineIsInBoat]) + _scene->_nextSceneId = 501; + else + _scene->setAnimFrame(_globals._animationIndexes[0], 241); + break; + + default: + break; + } + } else { + switch (_game._trigger) { + case (0): + if (!_globals[kChristineIsInBoat]) { + _vm->_gameConv->run(26); + _vm->_gameConv->exportValue(2); + int curFrame = _scene->_animation[_globals._animationIndexes[0]]->getCurrentFrame(); + if (curFrame == 240 || curFrame == 239) + _scene->setAnimFrame(_globals._animationIndexes[0], 290); + _ascendingFl = true; + } + _game._player._stepEnabled = false; + _game._player._visible = false; + _globals._sequenceIndexes[7] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[7], false, 5, 1); + _scene->_sequences.setAnimRange(_globals._sequenceIndexes[7], -1, -2); + _game.syncTimers(SYNC_SEQ, _globals._sequenceIndexes[7], SYNC_PLAYER, 0); + _scene->_sequences.addSubEntry(_globals._sequenceIndexes[7], SEQUENCE_TRIGGER_EXPIRE, 0, 90); + break; + + case 90: + _vm->_gameConv->abortConv(); + _scene->_nextSceneId = 504; + break; + + default: + break; + } + } + _action._inProgress = false; + return; + } + + if (_vm->_gameConv->_running == 26) { + _action._inProgress = false; + return; + } + + if (_action._lookFlag) { + _vm->_dialogs->show(50610); + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_LOOK) || _action.isAction(VERB_LOOK_AT)) { + if (_action.isObject(NOUN_FLOOR)) { + _vm->_dialogs->show(50611); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_WALL)) { + _vm->_dialogs->show(50612); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_TORCH)) { + _vm->_dialogs->show(50613); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_COLUMN)) { + _vm->_dialogs->show(50614); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_CEILING)) { + _vm->_dialogs->show(50615); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_RAMP)) { + _vm->_dialogs->show(50616); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_DOOR)) { + if (_scene->_customDest.x < 150) + _vm->_dialogs->show(50617); + else + _vm->_dialogs->show(50618); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_OAR) && _game._objects.isInRoom(OBJ_OAR)) { + _vm->_dialogs->show(50619); + _action._inProgress = false; + return; + } + + if (_action.isObject(NOUN_CHRISTINE)) { + if (_scene->_animation[_globals._animationIndexes[0]]->getCurrentFrame() < 235) + _vm->_dialogs->show(50621); + else + _vm->_dialogs->show(50620); + _action._inProgress = false; + return; + } + } + + if (_action.isAction(VERB_TAKE, NOUN_TORCH)) { + _vm->_dialogs->show(50613); + _action._inProgress = false; + return; + } + + if (_action.isAction(VERB_TAKE, NOUN_CHRISTINE)) { + _vm->_dialogs->show(50622); + _action._inProgress = false; + } +} + +void Scene506::preActions() { + if (_action.isAction(VERB_UNLOCK, NOUN_DOOR) || _action.isAction(VERB_LOCK, NOUN_DOOR)) + _game._player.walk(Common::Point(33, 142), FACING_NORTHWEST); + + if (_action.isAction(VERB_OPEN, NOUN_DOOR)) { + if (_scene->_customDest.x < 150) + _game._player.walk(Common::Point(33, 142), FACING_NORTHWEST); + else + _game._player.walk(Common::Point(191, 118), FACING_EAST); + } +} + +/*------------------------------------------------------------------------*/ + +} // End of namespace Phantom +} // End of namespace MADS diff --git a/engines/mads/phantom/phantom_scenes5.h b/engines/mads/phantom/phantom_scenes5.h new file mode 100644 index 0000000000..33478304f3 --- /dev/null +++ b/engines/mads/phantom/phantom_scenes5.h @@ -0,0 +1,219 @@ +/* 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 MADS_PHANTOM_SCENES5_H +#define MADS_PHANTOM_SCENES5_H + +#include "common/scummsys.h" +#include "common/serializer.h" +#include "mads/game.h" +#include "mads/scene.h" +#include "mads/phantom/phantom_scenes.h" + +namespace MADS { + +namespace Phantom { + +class Scene5xx : public PhantomScene { +protected: + /** + * Plays an appropriate sound when entering a scene + */ + void sceneEntrySound(); + + /** + *Sets the AA file to use for the scene + */ + void setAAName(); + + /** + * Updates the prefix used for getting player sprites for the scene + */ + void setPlayerSpritesPrefix(); +public: + Scene5xx(MADSEngine *vm) : PhantomScene(vm) {} +}; + +class Scene501 : public Scene5xx { +private: + bool _anim0ActvFl; + bool _skipFl; + +public: + Scene501(MADSEngine *vm); + virtual void synchronize(Common::Serializer &s); + + virtual void setup(); + virtual void enter(); + virtual void step(); + virtual void preActions(); + virtual void actions(); +}; + +class Scene502 : public Scene5xx { +private: + bool _fire1ActiveFl; + bool _fire2ActiveFl; + bool _fire3ActiveFl; + bool _fire4ActiveFl; + bool _panelTurningFl; + bool _trapDoorHotspotEnabled; + bool _acceleratedFireActivationFl; + + int _panelPushedNum; + int _puzzlePictures[16]; + int _puzzleSprites[16]; + int _puzzleSequences[16]; + int _messageLevel; + int _cycleStage; + + Common::Point _nextPos; + + uint32 _lastFrameTime; + uint32 _timer; + uint32 _deathTimer; + + byte *_cyclePointer; + + void room_502_initialize_panels(); + void loadCyclingInfo(); + void animateFireBursts(); + void setPaletteCycle(); + void handlePanelAnimation(); + void getPanelInfo(Common::Point *walkToPos, int *panel, Common::Point mousePos, Common::Point *interimPos); + +public: + Scene502(MADSEngine *vm); + ~Scene502(); + + virtual void synchronize(Common::Serializer &s); + + virtual void setup(); + virtual void enter(); + virtual void step(); + virtual void preActions(); + virtual void actions(); +}; + +class Scene504 : public Scene5xx { +private: + bool _anim0ActvFl; + bool _anim1ActvFl; + bool _anim2ActvFl; + bool _anim3ActvFl; + bool _anim4ActvFl; + bool _anim5ActvFl; + bool _playingMusicFl; + bool _chairDialogDoneFl; + bool _fireBreathFl; + + int _songNum; + int _input3Count; + int _playCount; + int _listenStatus; + int _listenFrame; + int _chairStatus; + int _chairFrame; + int _playStatus; + int _playFrame; + int _phantomStatus; + int _phantomFrame; + int _christineTalkCount; + int _deathCounter; + + void handleListenAnimation(); + void handleOrganAnimation(); + void handleChairAnimation(); + void handlePhantomAnimation1(); + void handlePhantomAnimation2(); + void handlePhantomAnimation3(); + void handleListenConversation(); + void handlePlayConversation(); + void handleFightConversation(); + +public: + Scene504(MADSEngine *vm); + virtual void synchronize(Common::Serializer &s); + + virtual void setup(); + virtual void enter(); + virtual void step(); + virtual void preActions(); + virtual void actions(); +}; + +class Scene505 : public Scene5xx { +private: + bool _anim0ActvFl; + bool _anim1ActvFl; + bool _anim2ActvFl; + bool _checkFrame106; + bool _leaveRoomFl; + bool _partedFl; + + int _raoulStatus; + int _raoulFrame; + int _raoulCount; + int _bothStatus; + int _bothFrame; + int _bothCount; + int _partStatus; + int _partFrame; + int _partCount; + + void handleRaoulAnimation(); + void handleBothanimation(); + void handlePartedAnimation(); + void handleCoffinDialog(); + +public: + Scene505(MADSEngine *vm); + virtual void synchronize(Common::Serializer &s); + + virtual void setup(); + virtual void enter(); + virtual void step(); + virtual void preActions(); + virtual void actions(); +}; + +class Scene506 : public Scene5xx { +private: + bool _anim0ActvFl; + bool _skipFl; + bool _ascendingFl; + +public: + Scene506(MADSEngine *vm); + virtual void synchronize(Common::Serializer &s); + + virtual void setup(); + virtual void enter(); + virtual void step(); + virtual void preActions(); + virtual void actions(); +}; + +} // End of namespace Phantom +} // End of namespace MADS + +#endif /* MADS_PHANTOM_SCENES5_H */ |