From 9abf901c28b71bbac0dcddd8a754da93f0199b11 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 9 Nov 2015 18:03:34 +0100 Subject: MADS: Phantom: Implement doObjectAction() --- engines/mads/dialogs.h | 5 + engines/mads/phantom/game_phantom.cpp | 291 +++++++++++++++++++++++++++++++++- engines/mads/phantom/game_phantom.h | 1 + engines/mads/phantom/phantom_scenes.h | 8 +- 4 files changed, 296 insertions(+), 9 deletions(-) (limited to 'engines/mads') diff --git a/engines/mads/dialogs.h b/engines/mads/dialogs.h index efd2871d89..27bc0a43ee 100644 --- a/engines/mads/dialogs.h +++ b/engines/mads/dialogs.h @@ -226,6 +226,11 @@ public: virtual void showItem(int objectId, int messageId, int speech = 0) = 0; virtual Common::String getVocab(int vocabId) = 0; virtual bool show(int messageId, int objectId = -1) = 0; + + /** + * Show a spinning picture of an object, used in V2+ games + */ + virtual void spinObject(int idx) { warning("TODO: spinObject"); } }; class FullScreenDialog: public EventTarget { diff --git a/engines/mads/phantom/game_phantom.cpp b/engines/mads/phantom/game_phantom.cpp index a995cd09b6..cd01c585e6 100644 --- a/engines/mads/phantom/game_phantom.cpp +++ b/engines/mads/phantom/game_phantom.cpp @@ -259,14 +259,295 @@ void GamePhantom::checkShowDialog() { } } +void GamePhantom::global_object_examine() { + 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))) { + global_object_examine(); + 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.setTimingTrigger(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.setTimingTrigger(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() { diff --git a/engines/mads/phantom/game_phantom.h b/engines/mads/phantom/game_phantom.h index 6c3f2fca14..2a4a0bc5d9 100644 --- a/engines/mads/phantom/game_phantom.h +++ b/engines/mads/phantom/game_phantom.h @@ -92,6 +92,7 @@ class GamePhantom : public Game { friend class Game; private: + void global_object_examine(); Catacombs *_catacombs; int _catacombSize; diff --git a/engines/mads/phantom/phantom_scenes.h b/engines/mads/phantom/phantom_scenes.h index 4afa6e675d..3ad292d6d4 100644 --- a/engines/mads/phantom/phantom_scenes.h +++ b/engines/mads/phantom/phantom_scenes.h @@ -57,6 +57,8 @@ enum Verb { 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, @@ -64,12 +66,14 @@ 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_ENTER = 0xEC, VERB_WALK_BEHIND = 0xF3, VERB_CLIMB = 0x120, + VERB_ATTACH = 0x131, VERB_GRAPPLE = 0x133, VERB_SIT_ON = 0x138, VERB_SIT_IN = 0x13A, @@ -176,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, @@ -208,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, @@ -346,7 +347,6 @@ enum Noun { NOUN_MONSIEUR_RICHARD = 0x12E, NOUN_JULIE2 = 0x12F, NOUN_CABLE_HOOK = 0x130, - NOUN_ATTACH = 0x131, NOUN_ROPE_WITH_HOOK = 0x132, NOUN_OAR = 0x134, NOUN_ORGAN = 0x135, -- cgit v1.2.3