Permalink
Browse files

STARTREK: Implement common code for LOVE mission

  • Loading branch information...
Drenn1 authored and sev- committed Jun 24, 2018
1 parent a5c7d6a commit aca19870562fe4dfcd98f3b062bf74dd0dee6daa
@@ -143,8 +143,8 @@ struct AwayMission {
bool alreadyStartedMission; // 0x29
bool knowAboutVirus; // 0x2a
bool romulansUnconsciousFromLaughingGas; // 0x2b
bool field2c; // 0x2c
bool field2d; // 0x2d
bool releasedHumanLaughingGas; // 0x2c
bool releasedRomulanLaughingGas; // 0x2d
bool chamberHasCure; // 0x2e
bool freezerOpen; // 0x2f
bool chamberHasDish; // 0x30
@@ -167,7 +167,10 @@ struct AwayMission {
bool romulansUnconsciousFromVirus; // 0x41
bool freedMarcusAndCheever; // 0x42
bool preaxCured; // 0x43
byte spockInfectionCounter; // 0x45: When this reached 100, Spock dies.
bool spockCured; // 0x46
bool contactedEnterpriseBeforeCure; // 0x47
bool contactedEnterpriseAfterCure; // 0x48
bool spockAccessedConsole; // 0x49
bool mccoyAccessedConsole; // 0x4a
bool gotPolyberylcarbonate; // 0x4b
@@ -36,6 +36,7 @@ MODULE_OBJS = \
rooms/love3.o \
rooms/love4.o \
rooms/love5.o \
rooms/lovea.o \



@@ -279,7 +279,7 @@ int Room::showRoomSpecificText(const char **array) {
return _vm->showText(&StarTrekEngine::readTextFromArray, (uintptr)array, 20, 20, textColor, true, false, false);
}

int Room::showText(const int *textIDs) {
int Room::showText(const TextRef *textIDs) {
int numIDs = 0;
while (textIDs[numIDs] != TX_BLANK)
numIDs++;
@@ -293,15 +293,15 @@ int Room::showText(const int *textIDs) {
return retval;
}

int Room::showText(int speaker, int text) {
int Room::showText(TextRef speaker, TextRef text) {
int textIDs[3];
textIDs[0] = speaker;
textIDs[1] = text;
textIDs[2] = TX_BLANK;
return showText(textIDs);
}

int Room::showText(int text) {
int Room::showText(TextRef text) {
return showText(TX_NULL, text);
}

@@ -458,7 +458,7 @@ void Room::playVoc(Common::String filename) {
_vm->_sound->playVoc(filename);
}

void Room::spockScan(int direction, int text, bool changeDirection) {
void Room::spockScan(int direction, TextRef text, bool changeDirection) {
const char *dirs = "nsew";
Common::String anim = "sscan_";
anim.setChar(dirs[direction], 5);
@@ -471,7 +471,7 @@ void Room::spockScan(int direction, int text, bool changeDirection) {
showText(TX_SPEAKER_SPOCK, text);
}

void Room::mccoyScan(int direction, int text, bool changeDirection) {
void Room::mccoyScan(int direction, TextRef text, bool changeDirection) {
const char *dirs = "nsew";
Common::String anim = "mscan_";
anim.setChar(dirs[direction], 5);
@@ -104,9 +104,9 @@ class Room {
void loadActorStandAnim(int actorIndex); // Cmd 0x01
void loadActorAnim2(int actorIndex, Common::String anim, int16 x, int16 y, uint16 field66 = 0);// Cmd 0x02
int showRoomSpecificText(const char **textAddr); // (Deprecated, use function below) // Cmd 0x03
int showText(const int *text); // Cmd 0x03
int showText(int speaker, int text); // Cmd 0x03
int showText(int text); // Cmd 0x03
int showText(const TextRef *text); // Cmd 0x03
int showText(TextRef speaker, TextRef text); // Cmd 0x03
int showText(TextRef text); // Cmd 0x03
void giveItem(int item); // Cmd 0x04
// Command 0x05: "demon4ShowSunPuzzle"
void loadRoomIndex(int roomIndex, int spawnIndex); // Cmd 0x06
@@ -129,8 +129,8 @@ class Room {

// If "changeDirection" is true, they remain facing that direction even after their
// animation is finished. The game is inconsistent about doing this.
void spockScan(int direction, int text, bool changeDirection);
void mccoyScan(int direction, int text, bool changeDirection);
void spockScan(int direction, TextRef text, bool changeDirection);
void mccoyScan(int direction, TextRef text, bool changeDirection);

// Room-specific code
public:
@@ -753,6 +753,7 @@ class Room {
void love0MccoyReachedConsole();
void love0MccoyAccessedConsole();
void love0InteractWithConsole();
void love0GetDoorOrConsole();

// LOVE1
void love1Tick1();
@@ -1100,6 +1101,22 @@ class Room {
void love5KirkUntiedMarcus();
void love5MarcusStoodUp();

// LOVEA (common code)
void loveaTimer0Expired();
void loveaTimer1Expired();
void loveaUseMedkitOnSpock();
void loveaUseCureSampleOnSpock();
void loveaUseCureOnSpock();
void loveaSpockOrMccoyInPositionToUseCure();
void loveaFinishedCuringSpock();
void loveaTimer2Expired();
void loveaUseMTricorderOnSpock();
void loveaUseMTricorderOnHuman();
void loveaUseRomulanLaughingGas();
void loveaUseHumanLaughingGas();
void loveaUseAmmonia();
void loveaUseCommunicator();

private:
// Room-specific variables. This is memset'ed to 0 when the room is initialized.
union {
@@ -1163,66 +1180,48 @@ class Room {
byte shootKirkOverride; // 0x1ec4
} tug2;


struct {
// love0
bool heardSummaryOfVirus; // 0xda
byte door2OpenCounter; // 0xdc
byte door1OpenCounter; // 0xdd
byte _de; // 0xde

int16 consoleCrewman; // 0xe3
char consoleAnimation[10]; // 0xe5
int32 consoleSpeaker; // 0xe7
int32 consoleText; // 0xe9
TextRef consoleSpeaker; // 0xe7
TextRef consoleText; // 0xe9

byte _8ab; // 0x8ab
byte _8ac; // 0x8ac
} love0;

struct {
byte door3OpenCounter; // 0xcb
byte door1OpenCounter; // 0xcc
byte door2OpenCounter; // 0xcd
bool walkingToDoor; // 0xce
int32 dyingSpeaker; // 0xcf
// love1
TextRef dyingSpeaker; // 0xcf
int16 crewmanUsingFreezerRetX; // 0xd1
int16 crewmanUsingFreezerRetY; // 0xd3
int16 crewmanUsingDevice; // 0xd9
int16 itemInNozzle; // 0xdd
char bottleAnimation[10]; // 0xdf

byte _1d2a; // 0x1d2a
byte _1d2b; // 0x1d2b
} love1;

struct {
// love2
byte canisterType; // 0xca
byte cb; // 0xcb
bool walkingToDoor; // 0xcc
byte doorOpenCounter; // 0xcd
int16 canisterItem; // 0xce
char canisterAnim[10]; // 0xd0
int16 d2; // 0xd2
char d6[10]; // 0xd6
char d8[10]; // 0xd8
byte _2966; // 0x2966
byte _2967; // 0x2967
} love2;
int16 chamberObject; // 0xd2
char chamberInputAnim[10]; // 0xd6
char chamberOutputAnim[10]; // 0xd8

struct {
// love3
byte activeCrewman;
byte _188e; // 0x188e
byte _188f; // 0x188f
} love3;

struct {
// love4
bool gaveWaterToRomulans; // 0xca
byte doorOpenCounter; // 0xcb
bool walkingToDoor; // 0xcc
} love4;

struct {
// love5
byte numCrewmenReadyToBeamOut; // 0xcb
} love5;

// common
byte walkingToDoor;
byte doorOpenCounter;
byte spockAndMccoyReadyToUseCure;
byte cmnXPosToCureSpock;
byte cmnYPosToCureSpock;
} love;


} _roomVar;
@@ -819,8 +819,27 @@ RoomAction love0ActionList[] = {
{ Action(ACTION_USE, OBJECT_MCCOY, 0x20, 0), &Room::love0UseMccoyOnConsole },
{ Action(ACTION_FINISHED_WALKING, 3, 0, 0), &Room::love0MccoyReachedConsole },
{ Action(ACTION_FINISHED_ANIMATION, 6, 0, 0), &Room::love0MccoyAccessedConsole },
// TODO: there's a lot of "extra" stuff at the end of the file. I don't think it's
// unused, but I'm not sure how it's run.
{ Action(ACTION_GET, 8, 0, 0), &Room::love0GetDoorOrConsole },
{ Action(ACTION_GET, 9, 0, 0), &Room::love0GetDoorOrConsole },
{ Action(ACTION_GET, 0x20, 0, 0), &Room::love0GetDoorOrConsole },

// Common code
{ Action(ACTION_TIMER_EXPIRED, 0, 0, 0), &Room::loveaTimer0Expired },
{ Action(ACTION_TIMER_EXPIRED, 1, 0, 0), &Room::loveaTimer1Expired },
{ Action(ACTION_USE, OBJECT_IMEDKIT, OBJECT_SPOCK, 0), &Room::loveaUseMedkitOnSpock },
{ Action(ACTION_USE, OBJECT_ISAMPLE, OBJECT_SPOCK, 0), &Room::loveaUseCureSampleOnSpock },
{ Action(ACTION_USE, OBJECT_ICURE, OBJECT_SPOCK, 0), &Room::loveaUseCureOnSpock },
{ Action(ACTION_FINISHED_WALKING, 99, 0, 0), &Room::loveaSpockOrMccoyInPositionToUseCure },
{ Action(ACTION_FINISHED_ANIMATION, 99, 0, 0), &Room::loveaFinishedCuringSpock },
{ Action(ACTION_TIMER_EXPIRED, 2, 0, 0), &Room::loveaTimer2Expired },
{ Action(ACTION_USE, OBJECT_IMTRICOR, OBJECT_SPOCK, 0), &Room::loveaUseMTricorderOnSpock },
{ Action(ACTION_USE, OBJECT_IMTRICOR, OBJECT_KIRK, 0), &Room::loveaUseMTricorderOnHuman },
{ Action(ACTION_USE, OBJECT_IMTRICOR, OBJECT_MCCOY, 0), &Room::loveaUseMTricorderOnHuman },
{ Action(ACTION_USE, OBJECT_IMTRICOR, OBJECT_REDSHIRT, 0), &Room::loveaUseMTricorderOnHuman },
{ Action(ACTION_USE, OBJECT_IRLG, -1, 0), &Room::loveaUseRomulanLaughingGas },
{ Action(ACTION_USE, OBJECT_IN2O, -1, 0), &Room::loveaUseHumanLaughingGas },
{ Action(ACTION_USE, OBJECT_INH3, -1, 0), &Room::loveaUseAmmonia },
{ Action(ACTION_USE, OBJECT_ICOMM, -1, 0), &Room::loveaUseCommunicator },
};

RoomAction love1ActionList[] = {
@@ -941,7 +960,24 @@ RoomAction love1ActionList[] = {
{ Action(ACTION_FINISHED_WALKING, 1, 0, 0), &Room::love1CrewmanReachedLadder },
{ Action(ACTION_FINISHED_ANIMATION, 6, 0, 0), &Room::love1CrewmanDiedFromPhaser },
{ Action(ACTION_TOUCHED_HOTSPOT, 0, 0, 0), &Room::love1TouchedHotspot0 },
// TODO: common code

// Common code
{ Action(ACTION_TIMER_EXPIRED, 0, 0, 0), &Room::loveaTimer0Expired },
{ Action(ACTION_TIMER_EXPIRED, 1, 0, 0), &Room::loveaTimer1Expired },
{ Action(ACTION_USE, OBJECT_IMEDKIT, OBJECT_SPOCK, 0), &Room::loveaUseMedkitOnSpock },
{ Action(ACTION_USE, OBJECT_ISAMPLE, OBJECT_SPOCK, 0), &Room::loveaUseCureSampleOnSpock },
{ Action(ACTION_USE, OBJECT_ICURE, OBJECT_SPOCK, 0), &Room::loveaUseCureOnSpock },
{ Action(ACTION_FINISHED_WALKING, 99, 0, 0), &Room::loveaSpockOrMccoyInPositionToUseCure },
{ Action(ACTION_FINISHED_ANIMATION, 99, 0, 0), &Room::loveaFinishedCuringSpock },
{ Action(ACTION_TIMER_EXPIRED, 2, 0, 0), &Room::loveaTimer2Expired },
{ Action(ACTION_USE, OBJECT_IMTRICOR, OBJECT_SPOCK, 0), &Room::loveaUseMTricorderOnSpock },
{ Action(ACTION_USE, OBJECT_IMTRICOR, OBJECT_KIRK, 0), &Room::loveaUseMTricorderOnHuman },
{ Action(ACTION_USE, OBJECT_IMTRICOR, OBJECT_MCCOY, 0), &Room::loveaUseMTricorderOnHuman },
{ Action(ACTION_USE, OBJECT_IMTRICOR, OBJECT_REDSHIRT, 0), &Room::loveaUseMTricorderOnHuman },
{ Action(ACTION_USE, OBJECT_IRLG, -1, 0), &Room::loveaUseRomulanLaughingGas },
{ Action(ACTION_USE, OBJECT_IN2O, -1, 0), &Room::loveaUseHumanLaughingGas },
{ Action(ACTION_USE, OBJECT_INH3, -1, 0), &Room::loveaUseAmmonia },
{ Action(ACTION_USE, OBJECT_ICOMM, -1, 0), &Room::loveaUseCommunicator },
};

RoomAction love2ActionList[] = {
@@ -1058,7 +1094,23 @@ RoomAction love2ActionList[] = {
{ Action(ACTION_FINISHED_WALKING, 11, 0, 0), &Room::love2ReachedCure },
{ Action(ACTION_FINISHED_ANIMATION, 24, 0, 0), &Room::love2GotCure },

// TODO: common code
// Common code
{ Action(ACTION_TIMER_EXPIRED, 0, 0, 0), &Room::loveaTimer0Expired },
{ Action(ACTION_TIMER_EXPIRED, 1, 0, 0), &Room::loveaTimer1Expired },
{ Action(ACTION_USE, OBJECT_IMEDKIT, OBJECT_SPOCK, 0), &Room::loveaUseMedkitOnSpock },
{ Action(ACTION_USE, OBJECT_ISAMPLE, OBJECT_SPOCK, 0), &Room::loveaUseCureSampleOnSpock },
{ Action(ACTION_USE, OBJECT_ICURE, OBJECT_SPOCK, 0), &Room::loveaUseCureOnSpock },
{ Action(ACTION_FINISHED_WALKING, 99, 0, 0), &Room::loveaSpockOrMccoyInPositionToUseCure },
{ Action(ACTION_FINISHED_ANIMATION, 99, 0, 0), &Room::loveaFinishedCuringSpock },
{ Action(ACTION_TIMER_EXPIRED, 2, 0, 0), &Room::loveaTimer2Expired },
{ Action(ACTION_USE, OBJECT_IMTRICOR, OBJECT_SPOCK, 0), &Room::loveaUseMTricorderOnSpock },
{ Action(ACTION_USE, OBJECT_IMTRICOR, OBJECT_KIRK, 0), &Room::loveaUseMTricorderOnHuman },
{ Action(ACTION_USE, OBJECT_IMTRICOR, OBJECT_MCCOY, 0), &Room::loveaUseMTricorderOnHuman },
{ Action(ACTION_USE, OBJECT_IMTRICOR, OBJECT_REDSHIRT, 0), &Room::loveaUseMTricorderOnHuman },
{ Action(ACTION_USE, OBJECT_IRLG, -1, 0), &Room::loveaUseRomulanLaughingGas },
{ Action(ACTION_USE, OBJECT_IN2O, -1, 0), &Room::loveaUseHumanLaughingGas },
{ Action(ACTION_USE, OBJECT_INH3, -1, 0), &Room::loveaUseAmmonia },
{ Action(ACTION_USE, OBJECT_ICOMM, -1, 0), &Room::loveaUseCommunicator },
};

RoomAction love3ActionList[] = {
@@ -1164,7 +1216,24 @@ RoomAction love3ActionList[] = {
{ Action(ACTION_GET, 9, 0, 0), &Room::love3GetInsulation },
{ Action(ACTION_FINISHED_WALKING, 12, 0, 0), &Room::love3ReachedInsulationToGet },
{ Action(ACTION_FINISHED_ANIMATION, 14, 0, 0), &Room::love3PickedUpInsulation },
// TODO: common code

// Common code
{ Action(ACTION_TIMER_EXPIRED, 0, 0, 0), &Room::loveaTimer0Expired },
{ Action(ACTION_TIMER_EXPIRED, 1, 0, 0), &Room::loveaTimer1Expired },
{ Action(ACTION_USE, OBJECT_IMEDKIT, OBJECT_SPOCK, 0), &Room::loveaUseMedkitOnSpock },
{ Action(ACTION_USE, OBJECT_ISAMPLE, OBJECT_SPOCK, 0), &Room::loveaUseCureSampleOnSpock },
{ Action(ACTION_USE, OBJECT_ICURE, OBJECT_SPOCK, 0), &Room::loveaUseCureOnSpock },
{ Action(ACTION_FINISHED_WALKING, 99, 0, 0), &Room::loveaSpockOrMccoyInPositionToUseCure },
{ Action(ACTION_FINISHED_ANIMATION, 99, 0, 0), &Room::loveaFinishedCuringSpock },
{ Action(ACTION_TIMER_EXPIRED, 2, 0, 0), &Room::loveaTimer2Expired },
{ Action(ACTION_USE, OBJECT_IMTRICOR, OBJECT_SPOCK, 0), &Room::loveaUseMTricorderOnSpock },
{ Action(ACTION_USE, OBJECT_IMTRICOR, OBJECT_KIRK, 0), &Room::loveaUseMTricorderOnHuman },
{ Action(ACTION_USE, OBJECT_IMTRICOR, OBJECT_MCCOY, 0), &Room::loveaUseMTricorderOnHuman },
{ Action(ACTION_USE, OBJECT_IMTRICOR, OBJECT_REDSHIRT, 0), &Room::loveaUseMTricorderOnHuman },
{ Action(ACTION_USE, OBJECT_IRLG, -1, 0), &Room::loveaUseRomulanLaughingGas },
{ Action(ACTION_USE, OBJECT_IN2O, -1, 0), &Room::loveaUseHumanLaughingGas },
{ Action(ACTION_USE, OBJECT_INH3, -1, 0), &Room::loveaUseAmmonia },
{ Action(ACTION_USE, OBJECT_ICOMM, -1, 0), &Room::loveaUseCommunicator },
};

RoomAction love4ActionList[] = {
@@ -1239,7 +1308,24 @@ RoomAction love4ActionList[] = {
{ Action(ACTION_USE, -1, 10, 0), &Room::love4UseAnythingOnRomulan },
{ Action(ACTION_USE, -1, 11, 0), &Room::love4UseAnythingOnRomulan },
{ Action(ACTION_USE, -1, 12, 0), &Room::love4UseAnythingOnRomulan },
// TODO: common code

// Common code
{ Action(ACTION_TIMER_EXPIRED, 0, 0, 0), &Room::loveaTimer0Expired },
{ Action(ACTION_TIMER_EXPIRED, 1, 0, 0), &Room::loveaTimer1Expired },
{ Action(ACTION_USE, OBJECT_IMEDKIT, OBJECT_SPOCK, 0), &Room::loveaUseMedkitOnSpock },
{ Action(ACTION_USE, OBJECT_ISAMPLE, OBJECT_SPOCK, 0), &Room::loveaUseCureSampleOnSpock },
{ Action(ACTION_USE, OBJECT_ICURE, OBJECT_SPOCK, 0), &Room::loveaUseCureOnSpock },
{ Action(ACTION_FINISHED_WALKING, 99, 0, 0), &Room::loveaSpockOrMccoyInPositionToUseCure },
{ Action(ACTION_FINISHED_ANIMATION, 99, 0, 0), &Room::loveaFinishedCuringSpock },
{ Action(ACTION_TIMER_EXPIRED, 2, 0, 0), &Room::loveaTimer2Expired },
{ Action(ACTION_USE, OBJECT_IMTRICOR, OBJECT_SPOCK, 0), &Room::loveaUseMTricorderOnSpock },
{ Action(ACTION_USE, OBJECT_IMTRICOR, OBJECT_KIRK, 0), &Room::loveaUseMTricorderOnHuman },
{ Action(ACTION_USE, OBJECT_IMTRICOR, OBJECT_MCCOY, 0), &Room::loveaUseMTricorderOnHuman },
{ Action(ACTION_USE, OBJECT_IMTRICOR, OBJECT_REDSHIRT, 0), &Room::loveaUseMTricorderOnHuman },
{ Action(ACTION_USE, OBJECT_IRLG, -1, 0), &Room::loveaUseRomulanLaughingGas },
{ Action(ACTION_USE, OBJECT_IN2O, -1, 0), &Room::loveaUseHumanLaughingGas },
{ Action(ACTION_USE, OBJECT_INH3, -1, 0), &Room::loveaUseAmmonia },
{ Action(ACTION_USE, OBJECT_ICOMM, -1, 0), &Room::loveaUseCommunicator },
};

RoomAction love5ActionList[] = {
@@ -1287,7 +1373,24 @@ RoomAction love5ActionList[] = {
{ Action(ACTION_FINISHED_WALKING, 2, 0, 0), &Room::love5KirkReachedMarcus },
{ Action(ACTION_FINISHED_ANIMATION, 3, 0, 0), &Room::love5KirkUntiedMarcus },
{ Action(ACTION_FINISHED_ANIMATION, 4, 0, 0), &Room::love5MarcusStoodUp },
// TODO: common code

// Common code
{ Action(ACTION_TIMER_EXPIRED, 0, 0, 0), &Room::loveaTimer0Expired },
{ Action(ACTION_TIMER_EXPIRED, 1, 0, 0), &Room::loveaTimer1Expired },
{ Action(ACTION_USE, OBJECT_IMEDKIT, OBJECT_SPOCK, 0), &Room::loveaUseMedkitOnSpock },
{ Action(ACTION_USE, OBJECT_ISAMPLE, OBJECT_SPOCK, 0), &Room::loveaUseCureSampleOnSpock },
{ Action(ACTION_USE, OBJECT_ICURE, OBJECT_SPOCK, 0), &Room::loveaUseCureOnSpock },
{ Action(ACTION_FINISHED_WALKING, 99, 0, 0), &Room::loveaSpockOrMccoyInPositionToUseCure },
{ Action(ACTION_FINISHED_ANIMATION, 99, 0, 0), &Room::loveaFinishedCuringSpock },
{ Action(ACTION_TIMER_EXPIRED, 2, 0, 0), &Room::loveaTimer2Expired },
{ Action(ACTION_USE, OBJECT_IMTRICOR, OBJECT_SPOCK, 0), &Room::loveaUseMTricorderOnSpock },
{ Action(ACTION_USE, OBJECT_IMTRICOR, OBJECT_KIRK, 0), &Room::loveaUseMTricorderOnHuman },
{ Action(ACTION_USE, OBJECT_IMTRICOR, OBJECT_MCCOY, 0), &Room::loveaUseMTricorderOnHuman },
{ Action(ACTION_USE, OBJECT_IMTRICOR, OBJECT_REDSHIRT, 0), &Room::loveaUseMTricorderOnHuman },
{ Action(ACTION_USE, OBJECT_IRLG, -1, 0), &Room::loveaUseRomulanLaughingGas },
{ Action(ACTION_USE, OBJECT_IN2O, -1, 0), &Room::loveaUseHumanLaughingGas },
{ Action(ACTION_USE, OBJECT_INH3, -1, 0), &Room::loveaUseAmmonia },
{ Action(ACTION_USE, OBJECT_ICOMM, -1, 0), &Room::loveaUseCommunicator },
};


Oops, something went wrong.

0 comments on commit aca1987

Please sign in to comment.