Permalink
Browse files

STARTREK: Move common MUDD functions to mudda.cpp

  • Loading branch information...
Drenn1 authored and sev- committed Jun 29, 2018
1 parent b3c3174 commit f85c296dc37ca257c4c605b27e3c886542bf57ab
@@ -43,6 +43,7 @@ MODULE_OBJS = \
rooms/mudd3.o \
rooms/mudd4.o \
rooms/mudd5.o \
rooms/mudda.o \



@@ -1138,10 +1138,6 @@ class Room {
void mudd0UseSTricorderOnMemoryDiskBox();
void mudd0UseSTricorderOnDegrimerBox();
void mudd0UseMTricorderOnLense();
void mudd0UseLenseOnDegrimer();
void mudd0UseAlienDevice();
void mudd0FiredAlienDevice();
void mudd0UseDegrimer();
void mudd0GetLense();
void mudd0GetMemoryDisk();
void mudd0GetDegrimer();
@@ -1378,6 +1374,10 @@ class Room {
void mudd5UseMedkit();

// MUDDA
void muddaUseLenseOnDegrimer();
void muddaUseAlienDevice();
void muddaFiredAlienDevice();
void muddaUseDegrimer();

private:
// Room-specific variables. This is memset'ed to 0 when the room is initialized.
@@ -1415,10 +1415,10 @@ RoomAction mudd0ActionList[] = {
{ Action(ACTION_USE, OBJECT_IMTRICOR, 0x21, 0), &Room::mudd0UseMTricorderOnLense },

// Common code (next 4 lines)
{ Action(ACTION_USE, OBJECT_ILENSES, OBJECT_IDEGRIME, 0), &Room::mudd0UseLenseOnDegrimer },
{ Action(ACTION_USE, OBJECT_IALIENDV, -1, 0), &Room::mudd0UseAlienDevice },
{ Action(ACTION_FINISHED_ANIMATION, 9, 0, 0), &Room::mudd0FiredAlienDevice },
{ Action(ACTION_USE, OBJECT_IDEGRIME, -1, 0), &Room::mudd0UseDegrimer },
{ Action(ACTION_USE, OBJECT_ILENSES, OBJECT_IDEGRIME, 0), &Room::muddaUseLenseOnDegrimer },
{ Action(ACTION_USE, OBJECT_IALIENDV, -1, 0), &Room::muddaUseAlienDevice },
{ Action(ACTION_FINISHED_ANIMATION, 9, 0, 0), &Room::muddaFiredAlienDevice },
{ Action(ACTION_USE, OBJECT_IDEGRIME, -1, 0), &Room::muddaUseDegrimer },

{ Action(ACTION_GET, 0x21, 0, 0), &Room::mudd0GetLense },
{ Action(ACTION_GET, 0x20, 0, 0), &Room::mudd0GetMemoryDisk },
@@ -1460,10 +1460,10 @@ RoomAction mudd1ActionList[] = {
{ Action(ACTION_FINISHED_ANIMATION, 4, 0, 0), &Room::mudd1SpockPressedRedButton },

// Common code (next 4 lines)
{ Action(ACTION_USE, OBJECT_IDEGRIME, -1, 0), &Room::mudd0UseDegrimer },
{ Action(ACTION_USE, OBJECT_ILENSES, OBJECT_IDEGRIME, 0), &Room::mudd0UseLenseOnDegrimer },
{ Action(ACTION_USE, OBJECT_IALIENDV, -1, 0), &Room::mudd0UseAlienDevice },
{ Action(ACTION_FINISHED_ANIMATION, 9, 0, 0), &Room::mudd0FiredAlienDevice },
{ Action(ACTION_USE, OBJECT_IDEGRIME, -1, 0), &Room::muddaUseDegrimer },
{ Action(ACTION_USE, OBJECT_ILENSES, OBJECT_IDEGRIME, 0), &Room::muddaUseLenseOnDegrimer },
{ Action(ACTION_USE, OBJECT_IALIENDV, -1, 0), &Room::muddaUseAlienDevice },
{ Action(ACTION_FINISHED_ANIMATION, 9, 0, 0), &Room::muddaFiredAlienDevice },

{ Action(ACTION_GET, 9, 0, 0), &Room::mudd1GetTorpedo },
{ Action(ACTION_GET, 0x21, 0, 0), &Room::mudd1GetTorpedo },
@@ -1518,10 +1518,10 @@ RoomAction mudd2ActionList[] = {
{ Action(ACTION_USE, OBJECT_ICOMM, -1, 0), &Room::mudd2UseCommunicator },

// Common code (next 4 lines)
{ Action(ACTION_USE, OBJECT_IDEGRIME, -1, 0), &Room::mudd0UseDegrimer },
{ Action(ACTION_USE, OBJECT_ILENSES, OBJECT_IDEGRIME, 0), &Room::mudd0UseLenseOnDegrimer },
{ Action(ACTION_USE, OBJECT_IALIENDV, -1, 0), &Room::mudd0UseAlienDevice },
{ Action(ACTION_FINISHED_ANIMATION, 18, 0, 0), &Room::mudd0FiredAlienDevice },
{ Action(ACTION_USE, OBJECT_IDEGRIME, -1, 0), &Room::muddaUseDegrimer },
{ Action(ACTION_USE, OBJECT_ILENSES, OBJECT_IDEGRIME, 0), &Room::muddaUseLenseOnDegrimer },
{ Action(ACTION_USE, OBJECT_IALIENDV, -1, 0), &Room::muddaUseAlienDevice },
{ Action(ACTION_FINISHED_ANIMATION, 18, 0, 0), &Room::muddaFiredAlienDevice },

{ Action(ACTION_LOOK, 0x20, 0, 0), &Room::mudd2LookAtCapsules },
{ Action(ACTION_USE, OBJECT_IMTRICOR, 0x20, 0), &Room::mudd2UseMTricorderOnCapsules },
@@ -1586,10 +1586,10 @@ RoomAction mudd3ActionList[] = {
{ Action(ACTION_USE, OBJECT_IDISKS, 0x21, 0), &Room::mudd3UseMemoryDiskOnSphere },

// Common code (next 4 lines)
{ Action(ACTION_USE, OBJECT_IDEGRIME, -1, 0), &Room::mudd0UseDegrimer },
{ Action(ACTION_USE, OBJECT_ILENSES, OBJECT_IDEGRIME, 0), &Room::mudd0UseLenseOnDegrimer },
{ Action(ACTION_USE, OBJECT_IALIENDV, -1, 0), &Room::mudd0UseAlienDevice },
{ Action(ACTION_FINISHED_ANIMATION, 9, 0, 0), &Room::mudd0FiredAlienDevice },
{ Action(ACTION_USE, OBJECT_IDEGRIME, -1, 0), &Room::muddaUseDegrimer },
{ Action(ACTION_USE, OBJECT_ILENSES, OBJECT_IDEGRIME, 0), &Room::muddaUseLenseOnDegrimer },
{ Action(ACTION_USE, OBJECT_IALIENDV, -1, 0), &Room::muddaUseAlienDevice },
{ Action(ACTION_FINISHED_ANIMATION, 9, 0, 0), &Room::muddaFiredAlienDevice },

{ Action(ACTION_GET, 13, 0, 0), &Room::mudd3GetRepairTool },
{ Action(ACTION_FINISHED_WALKING, 3, 0, 0), &Room::mudd3ReachedRepairTool },
@@ -1656,10 +1656,10 @@ RoomAction mudd4ActionList[] = {
{ Action(ACTION_USE, OBJECT_ISTRICOR, 8, 0), &Room::mudd4UseSTricorderOnViewscreen },

// Common code (next 4 lines)
{ Action(ACTION_USE, OBJECT_ILENSES, OBJECT_IDEGRIME, 0), &Room::mudd0UseLenseOnDegrimer },
{ Action(ACTION_USE, OBJECT_IALIENDV, -1, 0), &Room::mudd0UseAlienDevice },
{ Action(ACTION_FINISHED_ANIMATION, 9, 0, 0), &Room::mudd0FiredAlienDevice },
{ Action(ACTION_USE, OBJECT_IDEGRIME, -1, 0), &Room::mudd0UseDegrimer },
{ Action(ACTION_USE, OBJECT_ILENSES, OBJECT_IDEGRIME, 0), &Room::muddaUseLenseOnDegrimer },
{ Action(ACTION_USE, OBJECT_IALIENDV, -1, 0), &Room::muddaUseAlienDevice },
{ Action(ACTION_FINISHED_ANIMATION, 9, 0, 0), &Room::muddaFiredAlienDevice },
{ Action(ACTION_USE, OBJECT_IDEGRIME, -1, 0), &Room::muddaUseDegrimer },

{ Action(ACTION_USE, OBJECT_IMEDKIT, -1, 0), &Room::mudd4UseMedkit },
{ Action(ACTION_GET, 10, 0, 0), &Room::mudd4GetRepairTool },
@@ -1710,10 +1710,10 @@ RoomAction mudd5ActionList[] = {
{ Action(ACTION_TIMER_EXPIRED, 3, 0, 0), &Room::mudd5KirkTimer3Expired },

// Common code (next 4 lines)
{ Action(ACTION_USE, OBJECT_ILENSES, OBJECT_IDEGRIME, 0), &Room::mudd0UseLenseOnDegrimer },
{ Action(ACTION_USE, OBJECT_IALIENDV, -1, 0), &Room::mudd0UseAlienDevice },
{ Action(ACTION_FINISHED_ANIMATION, 9, 0, 0), &Room::mudd0FiredAlienDevice },
{ Action(ACTION_USE, OBJECT_IDEGRIME, -1, 0), &Room::mudd0UseDegrimer },
{ Action(ACTION_USE, OBJECT_ILENSES, OBJECT_IDEGRIME, 0), &Room::muddaUseLenseOnDegrimer },
{ Action(ACTION_USE, OBJECT_IALIENDV, -1, 0), &Room::muddaUseAlienDevice },
{ Action(ACTION_FINISHED_ANIMATION, 9, 0, 0), &Room::muddaFiredAlienDevice },
{ Action(ACTION_USE, OBJECT_IDEGRIME, -1, 0), &Room::muddaUseDegrimer },

{ Action(ACTION_LOOK, 0x20, 0, 0), &Room::mudd5LookAtHatch },
{ Action(ACTION_LOOK, 9, 0, 0), &Room::mudd5LookAtLifeSupportGenerator },
@@ -158,55 +158,6 @@ void Room::mudd0UseMTricorderOnLense() {
mccoyScan(DIR_E, TX_MUD0_013, true);
}

void Room::mudd0UseLenseOnDegrimer() {
giveItem(OBJECT_IALIENDV);
loseItem(OBJECT_IDEGRIME);
loseItem(OBJECT_ILENSES);

_vm->_awayMission.mudd.missionScore++;
showText(TX_MUD0N011);
// TODO: Identical (?) audio files: TX_MUD0N011, TX_MUD1N013, TX_MUD2N010, TX_MUD3N016,
// TX_MUD4009, TX_MUD5N009
}


void Room::mudd0UseAlienDevice() {
const int deviceObjectIndices[] = {
9, // MUDD0
13, // MUDD1
11, // MUDD2
11, // MUDD3
9, // MUDD4
11 // MUDD5
};

_vm->_awayMission.disableInput = true;

_vm->_awayMission.crewDirectionsAfterWalk[OBJECT_KIRK] = DIR_S;
loadActorStandAnim(OBJECT_KIRK);
Common::Point pos = getActorPos(OBJECT_KIRK);
loadActorAnimC(deviceObjectIndices[_roomIndex], "s4cbxp", pos.x, 10, &Room::mudd0FiredAlienDevice);
playVoc("EXPLO3");
}

void Room::mudd0FiredAlienDevice() {
_vm->_awayMission.disableInput = false;
if (!_vm->_awayMission.mudd.discoveredLenseAndDegrimerFunction) {
_vm->_awayMission.mudd.discoveredLenseAndDegrimerFunction = true;
_vm->_awayMission.mudd.missionScore += 5; // BUGFIX: didn't happen if done in MUDD5
showText(TX_SPEAKER_KIRK, TX_MUD0_002);
// TODO: Identical (?) audio files: TX_MUD0_002, TX_MUD1_002, TX_MUD2_002
}
}


void Room::mudd0UseDegrimer() {
// TODO: Identical (?) audio files: TX_MUD0N002, TX_MUD1N004, TX_MUD2N001,
// TX_MUD3N001, TX_MUD4N002, TX_MUD5_001
showText(TX_MUD0N002);
}


void Room::mudd0GetLense() {
if (_vm->_awayMission.mudd.gotLense)
showText(TX_MUD0N016);
@@ -61,7 +61,7 @@ void Room::mudd5Tick1() {
}

void Room::mudd5Timer1Expired() { // Mudd enters room through hatch
const int choices[] = {
const TextRef choices[] = {
TX_SPEAKER_KIRK,
TX_MUD5_006,
TX_MUD5_010,
@@ -0,0 +1,110 @@
/* 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 "startrek/room.h"

namespace StarTrek {

// The functions here used to be independently implemented in each room of the MUDD
// mission, despite being mostly the same.

void Room::muddaUseLenseOnDegrimer() {
assert(_roomIndex >= 0 && _roomIndex <= 5);

const TextRef text[] = {
TX_MUD0N011, // All of these audio files are identical, but there's one for each room.
TX_MUD1N013,
TX_MUD2N010,
TX_MUD3N016,
TX_MUD4N009,
TX_MUD5N009,
};

giveItem(OBJECT_IALIENDV);
loseItem(OBJECT_IDEGRIME);
loseItem(OBJECT_ILENSES);

_vm->_awayMission.mudd.missionScore++;
showText(text[_roomIndex]);
// TODO: Identical (?) audio files: TX_MUD0N011, TX_MUD1N013, TX_MUD2N010, TX_MUD3N016,
// TX_MUD4009, TX_MUD5N009
}


void Room::muddaUseAlienDevice() {
assert(_roomIndex >= 0 && _roomIndex <= 5);

const int deviceObjectIndices[] = { // Each room's object index for the explosion is different
9, // MUDD0
13, // MUDD1
11, // MUDD2
11, // MUDD3
9, // MUDD4
11 // MUDD5
};

_vm->_awayMission.disableInput = true;

_vm->_awayMission.crewDirectionsAfterWalk[OBJECT_KIRK] = DIR_S;
loadActorStandAnim(OBJECT_KIRK);
Common::Point pos = getActorPos(OBJECT_KIRK);
loadActorAnimC(deviceObjectIndices[_roomIndex], "s4cbxp", pos.x, 10, &Room::muddaFiredAlienDevice);
playVoc("EXPLO3");
}

void Room::muddaFiredAlienDevice() {
assert(_roomIndex >= 0 && _roomIndex <= 5);

const TextRef text[] = {
TX_MUD0_002, // These audio files aren't identical, but the text is mostly the same.
TX_MUD1_002,
TX_MUD2_002,
TX_MUD2_002, // Rooms 3-5 reuse MUD2
TX_MUD2_002,
TX_MUD2_002,
};

_vm->_awayMission.disableInput = false;
if (!_vm->_awayMission.mudd.discoveredLenseAndDegrimerFunction) {
_vm->_awayMission.mudd.discoveredLenseAndDegrimerFunction = true;
_vm->_awayMission.mudd.missionScore += 5; // BUGFIX: didn't happen if done in MUDD5
showText(TX_SPEAKER_KIRK, text[_roomIndex]);
}
}


void Room::muddaUseDegrimer() {
assert(_roomIndex >= 0 && _roomIndex <= 5);

const TextRef text[] = {
TX_MUD0N002, // All of these audio files are identical, but there's one for each room.
TX_MUD1N004,
TX_MUD2N001,
TX_MUD3N001,
TX_MUD4N002,
TX_MUD5N001,
};

showText(text[_roomIndex]);
}

}

0 comments on commit f85c296

Please sign in to comment.