Permalink
Browse files

STARTREK: Minor fixes to MUDD mission

Also make better names for variables.
  • Loading branch information...
Drenn1 authored and sev- committed Jul 1, 2018
1 parent bfb312a commit f583e307df83f67d56a541375afdfeac11bd36b9
@@ -189,23 +189,27 @@ struct AwayMission {
} love;

struct {
byte field29; // 0x29
// 0: Haven't entered first room yet
// 1: Have entered first room once
// 2: Mudd is gone from first room
byte muddFirstRoomState; // 0x29

bool torpedoLoaded; // 0x33
bool knowAboutTorpedo; // 0x34
bool discoveredBase3System; // 0x35
bool translatedAlienLanguage; // 0x36
bool databaseDestroyed; // 0x37
bool muddInDatabaseRoom; // 0x38
bool muddDroppedCapsule; // 0x39
bool computerDataErased; // 0x3a
bool gaveMuddDatabaseAccess; // 0x3b
bool muddCurrentlyInsane; // 0x39
bool computerDataErasedOrDestroyed; // 0x3a
bool muddErasedDatabase; // 0x3b

// True if you've combined the lense + degrimer and fired it off, discovering
// it's a weapon
bool discoveredLenseAndDegrimerFunction; // 0x3c

int16 torpedoStatus; // 0x3d
bool muddCurrentlyInsane; // 0x3f (TODO: rename)
bool muddUnavailable; // 0x3f
bool muddVisitedDatabaseRoom; // 0x40
bool accessedAlienDatabase; // 0x41
bool tookRepairTool; // 0x42
@@ -219,8 +223,14 @@ struct AwayMission {
bool gotDegrimer; // 0x4a
bool putCapsuleInMedicalMachine; // 0x4c
bool muddUnconscious; // 0x4d
byte muddState; // 0x4e
bool muddInhaledGas; // 0x4f

// 0: haven't entered room yet
// 1: will go insane next time room is entered (if he's available)
// 2: currently insane (or unconscious)
// 3: cured
byte muddInsanityState; // 0x4e

bool muddInhaledGas; // 0x4f (mostly the same as "muddCurrentlyInsane"?)
int16 lifeSupportTimer; // 0x50
bool startedLifeSupportTimer; // 0x52
bool enteredRoom0ForFirstTime; // 0x54
@@ -1091,7 +1091,6 @@ RoomAction love2ActionList[] = {
{ Action(ACTION_FINISHED_WALKING, 10, 0, 0), &Room::love2ReachedSynthesizerOutput },
{ Action(ACTION_FINISHED_ANIMATION, 23, 0, 0), &Room::love2GotSynthesizerOutput },

// TODO: test these
{ Action(ACTION_GET, 19, 0, 0), &Room::love2GetCure },
{ Action(ACTION_FINISHED_WALKING, 11, 0, 0), &Room::love2ReachedCure },
{ Action(ACTION_FINISHED_ANIMATION, 24, 0, 0), &Room::love2GotCure },
@@ -34,29 +34,24 @@
#define HOTSPOT_DOOR 0x25
#define HOTSPOT_BOTTOM_OF_ROOM 0x26

// BUG: Mudd is sometimes present when he shouldn't be.
// BUG-ish: Sometimes when looking at Mudd, Kirk walks toward him, but not always. Does
// this happen in original?

namespace StarTrek {

void Room::mudd0Tick1() {
playVoc("MUD0LOOP");

// ENHANCEMENT: Only disable input when Mudd showing Mudd cutscene (avoids a long,
// pointless delay when entering the room otherwise)
if (!_vm->_awayMission.mudd.enteredRoom0ForFirstTime)
_vm->_awayMission.disableInput = 2;

loadActorAnim(OBJECT_MUDD, "s4cbhr", 0xa2, 0xa9, 0);

// Floppy version's code.
/*
if (_vm->_awayMission.mudd.field29 == 0)
_vm->_awayMission.mudd.field29 = 2;
// NOTE: Using the floppy version's code here; Mudd disappears from this room after
// the first meeting. Fixes an issue where Mudd appears in the first room when he's
// supposed to be in the medbay.
// TODO: verify this matches with floppy version's code
if (_vm->_awayMission.mudd.muddFirstRoomState != 0)
_vm->_awayMission.mudd.muddFirstRoomState = 2;
else {
_vm->_awayMission.mudd.field1d = 2;
_vm->_awayMission.disableInput = 2;
loadActorAnim(OBJECT_MUDD, "s4cbhr", 0xa2, 0xa9, 0);
}
*/
}

void Room::mudd0Tick50() {
@@ -67,11 +62,11 @@ void Room::mudd0Tick50() {
}

void Room::mudd0Tick60() {
if (_vm->_awayMission.mudd.field29 == 0) {
if (_vm->_awayMission.mudd.muddFirstRoomState == 0) {
// ENHANCEMENT: Move this into if statement (related to above enhancement)
_vm->_awayMission.disableInput = false;

_vm->_awayMission.mudd.field29++;
_vm->_awayMission.mudd.muddFirstRoomState++;

showText(TX_SPEAKER_MUDD, TX_MUD0_037);
showText(TX_SPEAKER_KIRK, TX_MUD0_009);
@@ -261,7 +256,7 @@ void Room::mudd0LookAtMudd() {
}

void Room::mudd0TalkToKirk() {
if (_vm->_awayMission.mudd.field29 == 2)
if (_vm->_awayMission.mudd.muddFirstRoomState == 2)
showText(TX_SPEAKER_KIRK, TX_MUD0_010);
else {
showText(TX_SPEAKER_KIRK, TX_MUD0_010);
@@ -271,7 +266,7 @@ void Room::mudd0TalkToKirk() {
}

void Room::mudd0TalkToSpock() {
if (_vm->_awayMission.mudd.field29 == 2)
if (_vm->_awayMission.mudd.muddFirstRoomState == 2)
showText(TX_SPEAKER_SPOCK, TX_MUD0_022);
else {
showText(TX_SPEAKER_SPOCK, TX_MUD0_022);
@@ -283,7 +278,7 @@ void Room::mudd0TalkToSpock() {
}

void Room::mudd0TalkToMccoy() {
if (_vm->_awayMission.mudd.field29 == 2)
if (_vm->_awayMission.mudd.muddFirstRoomState == 2)
showText(TX_SPEAKER_MCCOY, TX_MUD0_016);
else {
showText(TX_SPEAKER_MCCOY, TX_MUD0_016);
@@ -294,15 +289,15 @@ void Room::mudd0TalkToMccoy() {
}

void Room::mudd0TalkToRedshirt() {
if (_vm->_awayMission.mudd.field29 == 2)
showText(TX_SPEAKER_BUCHERT, TX_MUD0_016);
if (_vm->_awayMission.mudd.muddFirstRoomState == 2) {
showText(TX_SPEAKER_BUCHERT, TX_MUD0_039);
showText(TX_SPEAKER_KIRK, TX_MUD0_008);
}
else {
showText(TX_SPEAKER_BUCHERT, TX_MUD0_040);
showText(TX_SPEAKER_MUDD, TX_MUD0_030);
showText(TX_SPEAKER_BUCHERT, TX_MUD0_041);
showText(TX_SPEAKER_MUDD, TX_MUD0_036);
showText(TX_SPEAKER_BUCHERT, TX_MUD0_039);
showText(TX_SPEAKER_KIRK, TX_MUD0_008);
}
}

@@ -67,29 +67,29 @@ void Room::mudd2Tick1() {
_vm->_awayMission.crewDirectionsAfterWalk[OBJECT_SPOCK] = DIR_W;
_vm->_awayMission.crewDirectionsAfterWalk[OBJECT_MCCOY] = DIR_W;
_vm->_awayMission.crewDirectionsAfterWalk[OBJECT_REDSHIRT] = DIR_W;
_vm->_awayMission.mudd.muddDroppedCapsule = false;
_vm->_awayMission.mudd.muddCurrentlyInsane = false;

if (_vm->_awayMission.mudd.muddState == 0) {
_vm->_awayMission.mudd.muddState = 0;
} else if (_vm->_awayMission.mudd.muddState == 2) {
_vm->_awayMission.mudd.muddDroppedCapsule = true;
if (_vm->_awayMission.mudd.muddInsanityState == 0) { // First time entering room
_vm->_awayMission.mudd.muddInsanityState = 1;
} else if (_vm->_awayMission.mudd.muddInsanityState == 2) { // Currently insane
_vm->_awayMission.mudd.muddCurrentlyInsane = true;
if (!_vm->_awayMission.mudd.muddUnconscious) {
_vm->_awayMission.mudd.muddUnconscious = false;
loadActorAnim2(OBJECT_MUDD, "s4sbhn", 0x9f, 0xbf);
loadActorAnim2(OBJECT_CAPSULE, "s4sbvp", 0x93, 0xc3);
} else {
loadActorAnim2(OBJECT_MUDD, "s4sbob", 0x9f, 0xba);
}
} else if (_vm->_awayMission.mudd.muddCurrentlyInsane) {
_vm->_awayMission.mudd.muddState = 0;
} else if (_vm->_awayMission.mudd.muddState == 1) {
} else if (_vm->_awayMission.mudd.muddUnavailable) {
_vm->_awayMission.mudd.muddInsanityState = 1;
} else if (_vm->_awayMission.mudd.muddInsanityState == 1) { // Second time entering room, start cutscene
playMidiMusicTracks(3);
loadActorAnim2(OBJECT_MUDD, "s4sbhw", 0x99, 0xbf);
_vm->_awayMission.disableInput = 2;
_vm->_awayMission.mudd.muddInhaledGas = true;
_vm->_awayMission.timers[1] = 70;
_vm->_awayMission.mudd.muddState = 2;
_vm->_awayMission.mudd.muddCurrentlyInsane = true;
_vm->_awayMission.mudd.muddInsanityState = 2;
_vm->_awayMission.mudd.muddUnavailable = true;
}
}

@@ -150,9 +150,9 @@ void Room::mudd2UseCapsuleOnControlPanel() {

void Room::mudd2MccoyReachedControlPanel() {
if (_vm->_awayMission.mudd.translatedAlienLanguage)
showText(TX_SPEAKER_MCCOY, TX_MUD2_014);
else
loadActorAnimC(OBJECT_MCCOY, "musehn", -1, -1, &Room::mudd2MccoyPutCapsuleInControlPanel);
else // NOTE: Unused, since you can't get capsules without translating the language first
showText(TX_SPEAKER_MCCOY, TX_MUD2_014);
}

void Room::mudd2MccoyPutCapsuleInControlPanel() {
@@ -195,7 +195,7 @@ void Room::mudd2MuddNoticedKirk() {
void Room::mudd2MuddDroppedCapsule() {
loadActorAnim2(OBJECT_MUDD, "s4sbhn", 0x9f, 0xbf, 3); // NOTE: no callback from this
loadActorAnim2(OBJECT_CAPSULE, "s4sbvp", 0x93, 0xc3);
_vm->_awayMission.mudd.muddDroppedCapsule = true;
_vm->_awayMission.mudd.muddCurrentlyInsane = true;

showText(TX_SPEAKER_MCCOY, TX_MUD2_032);
showText(TX_SPEAKER_MUDD, TX_MUD2_049);
@@ -312,9 +312,9 @@ void Room::mudd2MccoyReachedMudd() {
}

void Room::mudd2MccoyCuredMudd() {
_vm->_awayMission.mudd.muddUnavailable = false;
_vm->_awayMission.mudd.muddInsanityState = 3;
_vm->_awayMission.mudd.muddCurrentlyInsane = false;
_vm->_awayMission.mudd.muddState = 3;
_vm->_awayMission.mudd.muddDroppedCapsule = false;
_vm->_awayMission.mudd.muddInhaledGas = false;

showText(TX_SPEAKER_MCCOY, TX_MUD2_033);
@@ -352,9 +352,10 @@ void Room::mudd2LookAtBed() {
showText(TX_MUD2N007);
}

// FIXME: The conditions in the below functions seem wrong.
void Room::mudd2TalkToKirk() {
if (!_vm->_awayMission.mudd.muddDroppedCapsule || _vm->_awayMission.mudd.muddInhaledGas || _vm->_awayMission.mudd.muddUnconscious)
// BUGFIX: second condition in if statement changed to "must be false" instead of
// "must be true". (Same applies to below talk functions.)
if (!_vm->_awayMission.mudd.muddCurrentlyInsane || !_vm->_awayMission.mudd.muddInhaledGas || _vm->_awayMission.mudd.muddUnconscious)
showText(TX_SPEAKER_KIRK, TX_MUD2_010);
else {
showText(TX_SPEAKER_KIRK, TX_MUD2_005);
@@ -364,7 +365,7 @@ void Room::mudd2TalkToKirk() {
}

void Room::mudd2TalkToSpock() {
if (!_vm->_awayMission.mudd.muddDroppedCapsule || _vm->_awayMission.mudd.muddInhaledGas || _vm->_awayMission.mudd.muddUnconscious) {
if (!_vm->_awayMission.mudd.muddCurrentlyInsane || !_vm->_awayMission.mudd.muddInhaledGas || _vm->_awayMission.mudd.muddUnconscious) {
showText(TX_SPEAKER_SPOCK, TX_MUD2_040);
showText(TX_SPEAKER_KIRK, TX_MUD2_011);
} else {
@@ -373,7 +374,7 @@ void Room::mudd2TalkToSpock() {
}

void Room::mudd2TalkToMccoy() {
if (!_vm->_awayMission.mudd.muddDroppedCapsule || _vm->_awayMission.mudd.muddInhaledGas || _vm->_awayMission.mudd.muddUnconscious) {
if (!_vm->_awayMission.mudd.muddCurrentlyInsane || !_vm->_awayMission.mudd.muddInhaledGas || _vm->_awayMission.mudd.muddUnconscious) {
showText(TX_SPEAKER_MCCOY, TX_MUD2_025);
showText(TX_SPEAKER_KIRK, TX_MUD2_007);
} else {
@@ -382,23 +383,23 @@ void Room::mudd2TalkToMccoy() {
}

void Room::mudd2TalkToRedshirt() {
if (!_vm->_awayMission.mudd.muddDroppedCapsule || _vm->_awayMission.mudd.muddInhaledGas || _vm->_awayMission.mudd.muddUnconscious) {
if (!_vm->_awayMission.mudd.muddCurrentlyInsane || !_vm->_awayMission.mudd.muddInhaledGas || _vm->_awayMission.mudd.muddUnconscious) {
showText(TX_SPEAKER_BUCHERT, TX_MUD2_054);
showText(TX_SPEAKER_KIRK, TX_MUD2_008);
} else {
showText(TX_SPEAKER_BUCHERT, TX_MUD2_055);
showText(TX_SPEAKER_KIRK, TX_MUD2_003);
showText(TX_SPEAKER_MCCOY, TX_MUD2_048);
showText(TX_SPEAKER_MCCOY, TX_MUD2_036);
}
}

void Room::mudd2TalkToMudd() {
if (!_vm->_awayMission.mudd.muddDroppedCapsule || _vm->_awayMission.mudd.muddUnconscious)
if (!_vm->_awayMission.mudd.muddCurrentlyInsane || !_vm->_awayMission.mudd.muddInhaledGas || _vm->_awayMission.mudd.muddUnconscious)
return;
else if (_vm->_awayMission.mudd.muddInhaledGas) {
showText(TX_SPEAKER_MUDD, TX_MUD2_048);
showText(TX_SPEAKER_MCCOY, TX_MUD2_028);
} else {
} else { // NOTE: Unused (assumes harry is in a normal state, which doesn't happen here)
showText(TX_SPEAKER_MUDD, TX_MUD2_047);
showText(TX_SPEAKER_KIRK, TX_MUD2_006);
}
@@ -54,7 +54,7 @@ void Room::mudd3Tick1() {

_vm->_awayMission.mudd.muddInDatabaseRoom = false;

if (!_vm->_awayMission.mudd.muddVisitedDatabaseRoom && _vm->_awayMission.mudd.translatedAlienLanguage && !_vm->_awayMission.mudd.muddCurrentlyInsane) {
if (!_vm->_awayMission.mudd.muddVisitedDatabaseRoom && _vm->_awayMission.mudd.translatedAlienLanguage && !_vm->_awayMission.mudd.muddUnavailable) {
_vm->_awayMission.mudd.muddVisitedDatabaseRoom = true;
loadActorAnim(OBJECT_MUDD, "s4lbhs", 0xa2, 0x9f);
playMidiMusicTracks(3);
@@ -69,10 +69,12 @@ void Room::mudd3UseCommunicator() {
}

void Room::mudd3LookAtScreen() {
if (_vm->_awayMission.mudd.translatedAlienLanguage) // FIXME: flipped conditions?
showText(TX_MUD3N017);
else
// BUGFIX: the condition was flipped in the original; the more "vague" description
// should be shown before the alien language is understood.
if (_vm->_awayMission.mudd.translatedAlienLanguage)
showText(TX_SPEAKER_SPOCK, TX_MUD3_038);
else
showText(TX_MUD3N017);
}

void Room::mudd3UseSTricorderOnScreen() {
@@ -94,7 +96,7 @@ void Room::mudd3UseSpockOnSphere() {
_vm->_awayMission.crewDirectionsAfterWalk[OBJECT_SPOCK] = DIR_S;
loadActorStandAnim(OBJECT_SPOCK);

if (_vm->_awayMission.mudd.computerDataErased) {
if (_vm->_awayMission.mudd.computerDataErasedOrDestroyed) {
if (!_vm->_awayMission.mudd.databaseDestroyed) {
showText(TX_MUD3N000);
showText(TX_SPEAKER_SPOCK, TX_MUD3_052);
@@ -254,14 +256,22 @@ void Room::mudd3Timer2Expired() {
TX_BLANK
};

_vm->_awayMission.mudd.computerDataErased = true;
_vm->_awayMission.mudd.computerDataErasedOrDestroyed = true;

showText(TX_SPEAKER_MUDD, TX_MUD3_065);
int choice = showText(choices);

if (choice == 0) { // Allow him to access the database
if (choice == 0) { // Allow him to access the database (he ends up erasing it)
showText(TX_SPEAKER_MUDD, TX_MUD3_066);
_vm->_awayMission.mudd.gaveMuddDatabaseAccess = true;
_vm->_awayMission.mudd.muddErasedDatabase = true;

// ENHANCEMENT: Add a few lines to make it clear that Mudd erased the databanks.
// Otherwise, the end of the mission when you confront Mudd doesn't make sense
// unless the player happened to try accessing the database again. Also, if you
// talk to the crew, they berate him for no apparent reason if this isn't clear.
showText(TX_MUD3N000);
showText(TX_SPEAKER_MCCOY, TX_MUD3_031);

} else { // Don't allow it (he destroys it by accident)
showText(TX_SPEAKER_MUDD, TX_MUD3_064);
_vm->_awayMission.timers[4] = 98;
@@ -281,9 +291,13 @@ void Room::mudd3Timer4Expired() {
}

void Room::mudd3UseMemoryDiskOnSphere() {
// ENHANCEMENT: Turn to face south
_vm->_awayMission.crewDirectionsAfterWalk[OBJECT_KIRK] = DIR_S;
loadActorStandAnim(OBJECT_KIRK);

if (_vm->_awayMission.mudd.databaseDestroyed)
showText(TX_MUD3N014);
else if (_vm->_awayMission.mudd.translatedAlienLanguage && !_vm->_awayMission.mudd.gaveMuddDatabaseAccess) {
else if (_vm->_awayMission.mudd.translatedAlienLanguage && !_vm->_awayMission.mudd.muddErasedDatabase) {
showText(TX_MUD3N020);
if (!_vm->_awayMission.mudd.gotPointsForDownloadingData) {
_vm->_awayMission.mudd.missionScore += 3;
@@ -419,7 +433,9 @@ void Room::mudd3TalkToRedshirt() {
}

void Room::mudd3TalkToMudd() {
if (_vm->_awayMission.mudd.databaseDestroyed) {
// ENHANCEMENT: the 2nd part of the if condition is new; whether he physically
// destroys the database or does through software, he should give this reaction.
if (_vm->_awayMission.mudd.databaseDestroyed || _vm->_awayMission.mudd.muddErasedDatabase) {
showText(TX_SPEAKER_MUDD, TX_MUD3_060);
showText(TX_SPEAKER_MCCOY, TX_MUD3_029);
showText(TX_SPEAKER_MUDD, TX_MUD3_061);
Oops, something went wrong.

0 comments on commit f583e30

Please sign in to comment.