diff options
Diffstat (limited to 'engines/mads')
-rw-r--r-- | engines/mads/conversations.cpp | 14 | ||||
-rw-r--r-- | engines/mads/conversations.h | 4 | ||||
-rw-r--r-- | engines/mads/phantom/phantom_scenes1.cpp | 368 | ||||
-rw-r--r-- | engines/mads/phantom/phantom_scenes1.h | 6 | ||||
-rw-r--r-- | engines/mads/scene.cpp | 53 | ||||
-rw-r--r-- | engines/mads/scene.h | 5 |
6 files changed, 394 insertions, 56 deletions
diff --git a/engines/mads/conversations.cpp b/engines/mads/conversations.cpp index 451142aeb7..8981578876 100644 --- a/engines/mads/conversations.cpp +++ b/engines/mads/conversations.cpp @@ -27,7 +27,7 @@ namespace MADS { GameConversation::GameConversation(MADSEngine *vm) : _vm(vm) { - _restoreRunning = 0; + _running = _restoreRunning = 0; } GameConversation::~GameConversation() { @@ -41,7 +41,19 @@ void GameConversation::run(int id) { warning("TODO GameConversation::run"); } +void GameConversation::stop() { + warning("TODO GameConversation::stop"); +} + void GameConversation::exportPointer(int *val) { warning("TODO GameConversation::exportPointer"); } + +void GameConversation::setHeroTrigger(int val) { + warning("TODO: GameConversation::setHeroTrigger"); +} + +void GameConversation::setInterlocutorTrigger(int val) { + warning("TODO: GameConversation::setInterlocutorTrigger"); +} } // End of namespace MADS diff --git a/engines/mads/conversations.h b/engines/mads/conversations.h index fe128adf43..9e25eb97a6 100644 --- a/engines/mads/conversations.h +++ b/engines/mads/conversations.h @@ -44,8 +44,12 @@ public: void get(int id); void run(int id); + void stop(); void exportPointer(int *val); + void setHeroTrigger(int val); + void setInterlocutorTrigger(int val); + int _running; int _restoreRunning; }; diff --git a/engines/mads/phantom/phantom_scenes1.cpp b/engines/mads/phantom/phantom_scenes1.cpp index 2891ffa1d9..cb36be16f4 100644 --- a/engines/mads/phantom/phantom_scenes1.cpp +++ b/engines/mads/phantom/phantom_scenes1.cpp @@ -123,6 +123,7 @@ Scene101::Scene101(MADSEngine *vm) : Scene1xx(vm) { _brie_chandelier_position = -1; _brie_calling_frame = -1; _brie_chandelier_frame = -1; + _converse_counter = 0; _talk_count = -1; _dynamic_brie = 0; _dynamic_brie_2 = 0; @@ -141,6 +142,7 @@ void Scene101::synchronize(Common::Serializer &s) { s.syncAsSint16LE(_brie_chandelier_position); s.syncAsSint16LE(_brie_calling_frame); s.syncAsSint16LE(_brie_chandelier_frame); + s.syncAsSint16LE(_converse_counter); s.syncAsSint16LE(_talk_count); s.syncAsSint16LE(_dynamic_brie); s.syncAsSint16LE(_dynamic_brie_2); @@ -161,12 +163,9 @@ void Scene101::enter() { _vm->_disableFastwalk = true; if (_scene->_priorSceneId != RETURNING_FROM_DIALOG) { - _execute_chan = -1; - _execute_wipe = -1; - _start_walking = false; - _start_walking_0 = false; - _anim_0_running = true; - _anim_1_running = false; + _execute_chan = _execute_wipe = -1; + _start_walking = _start_walking_0 = false; + _anim_0_running = _anim_1_running = false; _start_sitting_down = false; } @@ -240,32 +239,80 @@ void Scene101::enter() { } void Scene101::step() { - // TODO + if (_anim_0_running) + handleAnimation0(); + + if ((_globals[kWalkerConverse] == 2) || (_globals[kWalkerConverse] == 3)) { + ++_converse_counter; + if (_converse_counter > 200) + _globals[kWalkerConverse] = _vm->getRandomNumber(1, 4); + } + + if (_anim_1_running) { + handleAnimation1(); + + if (_scene->_animation[1]->getCurrentFrame() == 80) { + _game._player._stepEnabled = true; + _game._player.setWalkTrigger(55); + } + } + + if (!_start_sitting_down && (_globals[kBrieTalkStatus] != 2)) { + warning("TODO: Add a check on view port x > 200"); + _start_sitting_down = true; + _game._player.walk(Common::Point(490, 119), FACING_NORTHEAST); + _game._player._stepEnabled = false; + _game._player.setWalkTrigger(55); + _brie_chandelier_position = 4; + } + + if (_game._trigger == 55) { + _game._player._stepEnabled = true; + _vm->_gameConv->run(1); + _vm->_gameConv->exportPointer(&_globals[kPlayerScore]); + _brie_chandelier_frame = -1; + _talk_count = 0; + } + + if (_game._trigger == 50) { + _vm->_gameConv->run(0); + _brie_calling_position = 1; + } } void Scene101::preActions() { if (_action.isAction(VERB_EXIT_TO, NOUN_ORCHESTRA_PIT)) { - // TODO: Handle Brie - _game._player._walkOffScreenSceneId = 102; + if ((_globals[kBrieTalkStatus] == 2) || _start_walking) { + _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) || _start_walking) + _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)) { @@ -275,8 +322,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) || _start_walking) + _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)) { @@ -284,14 +333,273 @@ 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; + _start_walking_0 = true; + } +} + +void Scene101::handleConversation1() { + if ((_action._activeAction._verbId >= 0) && (_action._activeAction._verbId <= 27)) { + int interlocutorFl = false; + + if (_game._trigger == 60) { + switch (_action._activeAction._verbId) { + case 0: + _brie_chandelier_position = 6; + _execute_wipe = 2; + break; + + case 1: + _brie_chandelier_position = 2; + _execute_chan = 9; + break; + + case 4: + _brie_chandelier_position = 0; + _execute_chan = -1; + _execute_wipe = -1; + break; + + case 8: + case 10: + case 18: + case 22: + case 24: + _start_walking = true; + _execute_chan = -1; + _execute_wipe = -1; + _globals[kWalkerConverse] = 0; + _vm->_gameConv->setInterlocutorTrigger(105); + interlocutorFl = true; + break; + + case 12: + _brie_chandelier_position = 5; + _execute_chan = -1; + _execute_wipe = -1; + break; + + default: + break; + } + } + + if (!interlocutorFl) + _vm->_gameConv->setInterlocutorTrigger(60); + + _vm->_gameConv->setHeroTrigger(70); + + _talk_count = 0; + + if (_game._trigger == 60) { + if (!_start_walking) + _globals[kWalkerConverse] = _vm->getRandomNumber(1, 4); + + _brie_chandelier_position = 2; + } else if ((_game._trigger == 70) && !_start_walking) { + _brie_chandelier_position = 4; + _execute_chan = -1; + _execute_wipe = -1; + if (!_start_walking) + _globals[kWalkerConverse] = _vm->getRandomNumber(2, 3); + + _converse_counter = 0; + } + } +} + +void Scene101::handleAnimation0() { + int random; + int reset_frame; + + if (_scene->_animation[0]->getCurrentFrame() != _brie_calling_frame) { + _brie_calling_frame = _scene->_animation[0]->getCurrentFrame(); + reset_frame = -1; + switch (_brie_calling_frame) { + case 1: + case 9: + case 12: + if (_brie_calling_position == 1) { + if (_brie_calling_frame == 9) { + if (_start_walking_0) { + reset_frame = 13; + _brie_calling_position = 3; + } else + _brie_calling_position = 2; + } else + reset_frame = 1; + } + + if (_brie_calling_position == 0) { + if (_start_walking_0) { + reset_frame = 60; + _brie_calling_position = 3; + } else + reset_frame = 0; + } + + if (_brie_calling_position == 2) { + if (_start_walking_0) { + reset_frame = 13; + _brie_calling_position = 3; + } else { + random = _vm->getRandomNumber(1, 2); + ++_talk_count; + + if (_talk_count < 18) { + if (random == 1) + reset_frame = 7; + else + reset_frame = 10; + } else { + reset_frame = 54; + _brie_calling_position = 0; + } + } + } + break; + + case 53: + _anim_0_running = false; + _scene->freeAnimation(0); + break; + + case 59: + if (_start_walking_0) { + reset_frame = 60; + _brie_calling_position = 3; + } else { + reset_frame = 0; + _brie_calling_position = 0; + } + break; + + case 66: + reset_frame = 24; + break; + } + + if (reset_frame >= 0) { + if (_scene->_animation[0]) + _scene->_animation[0]->setCurrentFrame(reset_frame); + _brie_calling_frame = reset_frame; + } + } +} + +void Scene101::handleAnimation1() { + int random; + int reset_frame; + + if (_scene->_animation[1]->getCurrentFrame() != _brie_chandelier_frame) { + _brie_chandelier_frame = _scene->_animation[1]->getCurrentFrame(); + reset_frame = -1; + switch (_brie_chandelier_frame) { + case 1: + if (_brie_chandelier_position == 3) + reset_frame = 0; + break; + + case 11: + case 14: + case 17: + case 19: + case 26: + case 44: + case 333: + if (_talk_count == _execute_chan) { + _brie_chandelier_position = 0; + ++_talk_count; + _execute_chan = -1; + } + + if (_talk_count == _execute_wipe) { + _brie_chandelier_position = 6; + ++_talk_count; + _execute_wipe = -1; + } + + if (_start_walking) { + if (_vm->_gameConv->_running == 1) { + if (_talk_count > 13) + _brie_chandelier_position = 1; + } else + _brie_chandelier_position = 1; + } + + switch (_brie_chandelier_position) { + case 0: + reset_frame = 27; + _brie_chandelier_position = 2; + break; + + case 1: + _globals[kBrieTalkStatus] = 2; + reset_frame = 45; + if (_vm->_gameConv->_running == 1) + _vm->_gameConv->stop(); + _scene->_dynamicHotspots.remove(_dynamic_brie); + _game._player._stepEnabled = false; + break; + + case 2: + random = _vm->getRandomNumber(1, 3); + ++_talk_count; + if (_talk_count < 15) { + if (random == 1) + reset_frame = 12; + else if (random == 2) + reset_frame = 14; + else if (random == 3) + reset_frame = 17; + } else { + _brie_chandelier_position = 4; + reset_frame = 25; + } + break; + + case 4: + reset_frame = 25; + break; + + case 5: + reset_frame = 21; + _brie_chandelier_position = 2; + break; + + case 6: + reset_frame = 316; + _brie_chandelier_position = 2; + break; + + default: + break; + } + break; + + case 315: + _scene->freeAnimation(1); + break; + } + + if (reset_frame >= 0) { + if (_scene->_animation[1]) + _scene->_animation[1]->setCurrentFrame(reset_frame); + _brie_chandelier_frame = reset_frame; + } } } diff --git a/engines/mads/phantom/phantom_scenes1.h b/engines/mads/phantom/phantom_scenes1.h index 60cb63bd0b..bd5a4796a7 100644 --- a/engines/mads/phantom/phantom_scenes1.h +++ b/engines/mads/phantom/phantom_scenes1.h @@ -62,6 +62,7 @@ private: int _brie_calling_frame; int _brie_chandelier_frame; int _talk_count; + int _converse_counter; int _dynamic_brie; int _dynamic_brie_2; bool _start_walking; @@ -78,6 +79,11 @@ public: virtual void step(); virtual void preActions(); virtual void actions(); + + void handleConversation0(); + void handleConversation1(); + void handleAnimation0(); + void handleAnimation1(); }; class Scene102 : public Scene1xx { diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp index b02c57e6a2..b02c251942 100644 --- a/engines/mads/scene.cpp +++ b/engines/mads/scene.cpp @@ -614,7 +614,7 @@ void Scene::loadAnimation(const Common::String &resName, int trigger, int id) { // WORKAROUND: If there's already a previous active animation used by the // scene, then free it before we create the new one if ((_vm->getGameID() == GType_RexNebular) && _animation[id]) - freeAnimation(); + freeAnimation(id); DepthSurface depthSurface; UserInterface interfaceSurface(_vm); @@ -700,37 +700,40 @@ void Scene::resetScene() { } void Scene::freeAnimation() { - for (int j = 0; j < 10; j++) { - if (_animation[j]) { - if (j == 0) { - Player &player = _vm->_game->_player; - - if (!_freeAnimationFlag) { - _spriteSlots.fullRefresh(true); - _sequences.scan(); - } + for (int j = 0; j < 10; j++) + freeAnimation(j); - // Refresh the player - if (player._visible) { - player._forceRefresh = true; - player.update(); - } + _freeAnimationFlag = false; +} + +void Scene::freeAnimation(int idx) { + if (_animation[idx]) { + if (idx == 0) { + Player &player = _vm->_game->_player; + + if (!_freeAnimationFlag) { + _spriteSlots.fullRefresh(true); + _sequences.scan(); } - // Remove any kernel messages in use by the animation - for (uint i = 0; i < _animation[j]->_messages.size(); ++i) { - int msgIndex = _animation[j]->_messages[i]._kernelMsgIndex; - if (msgIndex >= 0) - _kernelMessages.remove(msgIndex); + // Refresh the player + if (player._visible) { + player._forceRefresh = true; + player.update(); } + } - // Delete the animation - delete _animation[j]; - _animation[j] = nullptr; + // Remove any kernel messages in use by the animation + for (uint i = 0; i < _animation[idx]->_messages.size(); ++i) { + int msgIndex = _animation[idx]->_messages[i]._kernelMsgIndex; + if (msgIndex >= 0) + _kernelMessages.remove(msgIndex); } - } - _freeAnimationFlag = false; + // Delete the animation + delete _animation[idx]; + _animation[idx] = nullptr; + } } void Scene::synchronize(Common::Serializer &s) { diff --git a/engines/mads/scene.h b/engines/mads/scene.h index ba37b97339..d89cbb8c36 100644 --- a/engines/mads/scene.h +++ b/engines/mads/scene.h @@ -245,6 +245,11 @@ public: void freeAnimation(); /** + * Frees any given active animation for the scene + */ + void freeAnimation(int idx); + + /** * Synchronize the game */ void synchronize(Common::Serializer &s); |