diff options
Diffstat (limited to 'engines')
-rw-r--r-- | engines/startrek/awaymission.cpp | 121 | ||||
-rw-r--r-- | engines/startrek/room.cpp | 2 | ||||
-rw-r--r-- | engines/startrek/room.h | 2 | ||||
-rw-r--r-- | engines/startrek/startrek.cpp | 2 | ||||
-rw-r--r-- | engines/startrek/startrek.h | 2 | ||||
-rw-r--r-- | engines/startrek/text.h | 31 |
6 files changed, 143 insertions, 17 deletions
diff --git a/engines/startrek/awaymission.cpp b/engines/startrek/awaymission.cpp index 4a604b9e7e..55ede50f0c 100644 --- a/engines/startrek/awaymission.cpp +++ b/engines/startrek/awaymission.cpp @@ -37,11 +37,11 @@ void StarTrekEngine::initAwayMission() { // sub_23a60(); // TODO _sound->loadMusicFile("ground"); - loadRoom(_missionToLoad, _roomIndexToLoad); + loadRoom(_missionToLoad, 1); // FIXME _roomIndexToLoad = -1; // Load crew positions for beaming in - initAwayCrewPositions(4); + initAwayCrewPositions(1); } void StarTrekEngine::runAwayMission() { @@ -432,40 +432,133 @@ void StarTrekEngine::handleAwayMissionAction() { } break; - case ACTION_USE: // TODO - warning("Unhandled use action: %d %d %d", action.b1, action.b2, action.b3); + case ACTION_USE: + if (action.activeObject() != action.passiveObject()) { + switch (action.activeObject()) { + case OBJECT_KIRK: + if (!_room->handleAction(ACTION_WALK, action.passiveObject(), 0, 0) + && !_room->handleAction(ACTION_GET, action.passiveObject(), 0, 0)) { + showTextbox("Capt. Kirk", getLoadedText(GROUNDTX_KIRK_USE), 20, 20, TEXTCOLOR_YELLOW, 0); + } + break; + + case OBJECT_SPOCK: + if (!_room->handleAction(ACTION_USE, OBJECT_ISTRICOR, action.passiveObject(), 0)) { + // BUGFIX: Original game has just "Spock" instead of "Mr. Spock" as the + // speaker. That's inconsistent. + // Same applies to other parts of this function. + showTextbox("Mr. Spock", getLoadedText(GROUNDTX_SPOCK_USE), 20, 20, TEXTCOLOR_BLUE, 0); + } + break; + + case OBJECT_MCCOY: + if (!_room->handleAction(ACTION_USE, OBJECT_IMEDKIT, action.passiveObject(), 0) + && !_room->handleAction(ACTION_USE, OBJECT_IMTRICOR, action.passiveObject(), 0)) { + // BUGFIX: Original game has just "McCoy" instead of "Dr. McCoy". + showTextbox("Dr. McCoy", getLoadedText(GROUNDTX_MCCOY_USE), 20, 20, TEXTCOLOR_BLUE, 0); + } + break; + + case OBJECT_REDSHIRT: + showTextbox(nullptr, getLoadedText(GROUNDTX_REDSHIRT_USE), 20, 20, TEXTCOLOR_YELLOW, 0); + break; + + case OBJECT_IPHASERS: + case OBJECT_IPHASERK: + if (action.passiveObject() == OBJECT_SPOCK) { + int text = GROUNDTX_PHASER_ON_SPOCK + getRandomWord() % 8; + showTextbox("Dr. McCoy", getLoadedText(text), 20, 20, TEXTCOLOR_BLUE, 0); + } + else if (action.passiveObject() == OBJECT_MCCOY) { + int text = GROUNDTX_PHASER_ON_MCCOY + getRandomWord() % 8; + showTextbox("Mr. Spock", getLoadedText(text), 20, 20, TEXTCOLOR_BLUE, 0); + } + else if (action.passiveObject() == OBJECT_REDSHIRT) { + Common::String text = getLoadedText(GROUNDTX_PHASER_ON_REDSHIRT + getRandomWord() % 8); + // Replace audio filename with start of mission name (to load the + // audio for the crewman specific to the mission)) + text.setChar(_missionName[0], 6); + text.setChar(_missionName[1], 7); + text.setChar(_missionName[2], 8); + showTextbox("Security Officer", text, 20, 20, TEXTCOLOR_RED, 0); + // TODO: replace "Security Officer" string with their actual name as + // an enhancement? + } + else if (!_room->handleActionWithBitmask(action)) { + int index = getRandomWord() % 7; + if (index & 1) + showTextbox("Dr. McCoy", getLoadedText(GROUNDTX_PHASER_ANYWHERE + index), 20, 20, TEXTCOLOR_BLUE, 0); + else + showTextbox("Mr. Spock", getLoadedText(GROUNDTX_PHASER_ANYWHERE + index), 20, 20, TEXTCOLOR_BLUE, 0); + } + break; + + case OBJECT_ISTRICOR: + showTextbox("Mr. Spock", getLoadedText(GROUNDTX_SPOCK_SCAN), 20, 20, TEXTCOLOR_BLUE, 0); + break; + + case OBJECT_IMTRICOR: + showTextbox("Dr. McCoy", getLoadedText(GROUNDTX_MCCOY_SCAN), 20, 20, TEXTCOLOR_BLUE, 0); + break; + + case OBJECT_ICOMM: + if (!_room->handleAction(ACTION_USE, OBJECT_ICOMM, -1, 0)) + showTextbox("Lt. Uhura", getLoadedText(GROUNDTX_USE_COMMUNICATOR), 20, 20, TEXTCOLOR_RED, 0); + break; + + case OBJECT_IMEDKIT: + showTextbox("Dr. McCoy", getLoadedText(GROUNDTX_USE_MEDKIT), 20, 20, TEXTCOLOR_BLUE, 0); + break; + + default: + if (!_room->handleActionWithBitmask(action.type, action.b1, action.b2, action.b3)) + showTextbox("", getLoadedText(GROUNDTX_NOTHING_HAPPENS), 20, 20, TEXTCOLOR_YELLOW, 0); + } + } break; - case ACTION_GET: // TODO - warning("Unhandled get action: %d %d %d", action.b1, action.b2, action.b3); + case ACTION_GET: + if (!_room->handleActionWithBitmask(action.type, action.b1, action.b2, action.b3)) + showTextbox("", getLoadedText(GROUNDTX_FAIL_TO_OBTAIN_ANYTHING), 20, 20, TEXTCOLOR_YELLOW, 0); break; case ACTION_LOOK: if (action.activeObject() >= ITEMS_START && action.activeObject() < ITEMS_END) { int i = action.activeObject() - ITEMS_START; - Common::String text = getItemDescription(_itemList[i].textIndex); + Common::String text = getLoadedText(_itemList[i].textIndex); showTextbox("", text, 20, 20, TEXTCOLOR_YELLOW, 0); } else if (action.activeObject() == OBJECT_KIRK) - showTextbox("", getItemDescription(0x49), 20, 20, TEXTCOLOR_YELLOW, 0); + showTextbox("", getLoadedText(GROUNDTX_LOOK_KIRK), 20, 20, TEXTCOLOR_YELLOW, 0); else if (action.activeObject() == OBJECT_SPOCK) - showTextbox("", getItemDescription(0x4a), 20, 20, TEXTCOLOR_YELLOW, 0); + showTextbox("", getLoadedText(GROUNDTX_LOOK_SPOCK), 20, 20, TEXTCOLOR_YELLOW, 0); else if (action.activeObject() == OBJECT_MCCOY) - showTextbox("", getItemDescription(0x4b), 20, 20, TEXTCOLOR_YELLOW, 0); + showTextbox("", getLoadedText(GROUNDTX_LOOK_MCCOY), 20, 20, TEXTCOLOR_YELLOW, 0); else { if (action.activeObject() == OBJECT_REDSHIRT) - showTextbox("", getItemDescription(0x4c), 20, 20, TEXTCOLOR_YELLOW, 0); + showTextbox("", getLoadedText(GROUNDTX_LOOK_REDSHIRT), 20, 20, TEXTCOLOR_YELLOW, 0); // Show generic "nothing of note" text. // BUG? This text is also shown after looking at the redshirt. However, his // text is normally overridden on a per-mission basis, so perhaps this bug // never manifests itself? - showTextbox("", getItemDescription(0x4d), 20, 20, TEXTCOLOR_YELLOW, 0); + showTextbox("", getLoadedText(GROUNDTX_LOOK_ANYWHERE), 20, 20, TEXTCOLOR_YELLOW, 0); } break; - case ACTION_TALK: // TODO - warning("Unhandled talk action: %d %d %d", action.b1, action.b2, action.b3); + case ACTION_TALK: + switch (action.activeObject()) { + case OBJECT_KIRK: + case OBJECT_SPOCK: + case OBJECT_MCCOY: + case OBJECT_REDSHIRT: + showTextbox("", getLoadedText(GROUNDTX_TALK_TO_CREWMAN), 20, 20, TEXTCOLOR_YELLOW, 0); + break; + + default: + showTextbox("", getLoadedText(GROUNDTX_NO_RESPONSE), 20, 20, TEXTCOLOR_YELLOW, 0); + break; + } break; case ACTION_TOUCHED_WARP: diff --git a/engines/startrek/room.cpp b/engines/startrek/room.cpp index 4f960fb2cb..8e1de88385 100644 --- a/engines/startrek/room.cpp +++ b/engines/startrek/room.cpp @@ -122,7 +122,7 @@ bool Room::handleActionWithBitmask(const Action &action) { int n = _numRoomActions; while (n-- > 0) { - uint32 bitmask = action.getBitmask(); + uint32 bitmask = roomActionPtr->action.getBitmask(); if ((action.toUint32() & bitmask) == (roomActionPtr->action.toUint32() & bitmask)) { _vm->_awayMission.rdfStillDoDefaultAction = false; (this->*(roomActionPtr->funcPtr))(); diff --git a/engines/startrek/room.h b/engines/startrek/room.h index 943ed901eb..e3b2cf62e1 100644 --- a/engines/startrek/room.h +++ b/engines/startrek/room.h @@ -69,9 +69,11 @@ public: // That code is instead rewritten on a per-room basis. bool actionHasCode(const Action &action); bool handleAction(const Action &action); + bool handleAction(byte type, byte b1, byte b2, byte b3) { return handleAction(Action(type, b1, b2, b3)); }; // Same as above, but if any byte in the action is -1 (0xff), it matches any value. bool handleActionWithBitmask(const Action &action); + bool handleActionWithBitmask(byte type, byte b1, byte b2, byte b3) { return handleActionWithBitmask(Action(type, b1, b2, b3)); }; uint16 getFirstHotspot() { return readRdfWord(0x12); } uint16 getHotspotEnd() { return readRdfWord(0x14); } diff --git a/engines/startrek/startrek.cpp b/engines/startrek/startrek.cpp index 7e9f9bb42d..c623c1b0a6 100644 --- a/engines/startrek/startrek.cpp +++ b/engines/startrek/startrek.cpp @@ -1851,7 +1851,7 @@ uint16 StarTrekEngine::getRandomWord() { * ".txt" files are just lists of strings. This traverses the file to get a particular * string index. */ -Common::String StarTrekEngine::getItemDescription(int itemIndex) { +Common::String StarTrekEngine::getLoadedText(int itemIndex) { SharedPtr<FileStream> txtFile = loadFile(_txtFilename + ".txt"); byte *data = txtFile->_data; diff --git a/engines/startrek/startrek.h b/engines/startrek/startrek.h index cf678ebd83..ee741eb598 100644 --- a/engines/startrek/startrek.h +++ b/engines/startrek/startrek.h @@ -395,7 +395,7 @@ public: // Misc uint16 getRandomWord(); - Common::String getItemDescription(int itemIndex); + Common::String getLoadedText(int itemIndex); public: diff --git a/engines/startrek/text.h b/engines/startrek/text.h index 2dc686a6dc..cf949b2376 100644 --- a/engines/startrek/text.h +++ b/engines/startrek/text.h @@ -25,6 +25,37 @@ namespace StarTrek { +// Text that's loaded from "GROUND.TXT". First 0x40 pieces of text are for items. +enum GroundTextIDs { + // Generic "perform undefined action" text (ie. look at nothing, talk to wall) + GROUNDTX_LOOK_KIRK = 0x49, + GROUNDTX_LOOK_SPOCK = 0x4a, + GROUNDTX_LOOK_MCCOY = 0x4b, + GROUNDTX_LOOK_REDSHIRT = 0x4c, + GROUNDTX_LOOK_ANYWHERE = 0x4d, + GROUNDTX_TALK_TO_CREWMAN = 0x4e, + GROUNDTX_NO_RESPONSE = 0x4f, + + GROUNDTX_KIRK_USE = 0x50, + GROUNDTX_SPOCK_USE = 0x51, + GROUNDTX_MCCOY_USE = 0x52, + GROUNDTX_REDSHIRT_USE = 0x53, + GROUNDTX_SPOCK_SCAN = 0x54, + GROUNDTX_MCCOY_SCAN = 0x55, + GROUNDTX_USE_MEDKIT = 0x56, + + GROUNDTX_PHASER_ON_MCCOY = 0x57, // 8 variations + GROUNDTX_PHASER_ON_SPOCK = 0x5f, // 8 variations + GROUNDTX_PHASER_ON_REDSHIRT = 0x67, // 8 variations + GROUNDTX_PHASER_ANYWHERE = 0x6f, // 7 variations + + GROUNDTX_USE_COMMUNICATOR = 0x76, + GROUNDTX_NOTHING_HAPPENS = 0x77, + GROUNDTX_FAIL_TO_OBTAIN_ANYTHING = 0x78 +}; + +// Text that's hardcoded into "RDF" files, and copied into here for a sane referencing +// scheme. enum GameStringIDs { TX_NULL, TX_BLANK, |