STARTREK: Start on MUDD's life-support-loss code

This commit is contained in:
Matthew Stewart 2018-06-29 18:39:21 -04:00 committed by Eugene Sandulenko
parent f85c296dc3
commit 933ab32b0e
7 changed files with 86 additions and 4 deletions

View File

@ -635,6 +635,10 @@ void StarTrekEngine::handleAwayMissionAction() {
initAwayCrewPositions(warpIndex ^ 1);
}
break;
default:
_room->handleActionWithBitmask(action);
break;
}
}

View File

@ -221,7 +221,8 @@ struct AwayMission {
bool muddUnconscious; // 0x4d
byte muddState; // 0x4e
bool muddInhaledGas; // 0x4f
int16 lifeSupportTimer; // 0x50
bool startedLifeSupportTimer; // 0x52
bool enteredRoom0ForFirstTime; // 0x54
bool gotPointsForLoadingTorpedo; // 0x55
bool gotPointsForPressingRedButton; // 0x56

View File

@ -475,9 +475,9 @@ void Room::endMission(int16 score, int16 arg1, int16 arg2) {
// TODO: game mode switch
}
void Room::showGameOverMenu() {
void Room::showGameOverMenu() { // TODO: takes an optional parameter?
_vm->showGameOverMenu();
// TODO: shouldn't do this within a room
// TODO: finish. Shouldn't do this within a room due to deletion of current room?
}
void Room::playVoc(Common::String filename) {

View File

@ -1378,6 +1378,11 @@ public:
void muddaUseAlienDevice();
void muddaFiredAlienDevice();
void muddaUseDegrimer();
void muddaTick();
void muddaKirkReachedDeathPosition();
void muddaSpockReachedDeathPosition();
void muddaMccoyReachedDeathPosition();
void muddaRedshirtReachedDeathPosition();
private:
// Room-specific variables. This is memset'ed to 0 when the room is initialized.

View File

@ -1731,6 +1731,13 @@ RoomAction mudd5ActionList[] = {
{ Action(ACTION_TALK, OBJECT_MCCOY, 0, 0), &Room::mudd5TalkToMccoy },
{ Action(ACTION_TALK, OBJECT_REDSHIRT, 0, 0), &Room::mudd5TalkToRedshirt },
{ Action(ACTION_USE, OBJECT_IMEDKIT, -1, 0), &Room::mudd5UseMedkit },
// Common code (countdown for losing atmosphere when life support malfunctioning)
{ Action(ACTION_TICK, -1, -1, -1), &Room::muddaTick },
{ Action(ACTION_FINISHED_WALKING, 9, 0, 0), &Room::muddaKirkReachedDeathPosition },
{ Action(ACTION_FINISHED_WALKING, 10, 0, 0), &Room::muddaSpockReachedDeathPosition },
{ Action(ACTION_FINISHED_WALKING, 11, 0, 0), &Room::muddaMccoyReachedDeathPosition },
{ Action(ACTION_FINISHED_WALKING, 12, 0, 0), &Room::muddaRedshirtReachedDeathPosition },
};
}

View File

@ -48,7 +48,7 @@ void Room::mudd5Tick1() {
loadActorAnim(OBJECT_LIFE_SUPPORT_GENERATOR, "s4eplo", GENERATOR_X, GENERATOR_Y);
_vm->_awayMission.mudd.numTimesEnteredRoom5++;
// BUG: this event can become permanently unavailable? (test)
if (_vm->_awayMission.mudd.numTimesEnteredRoom5 == 2 && !_vm->_awayMission.mudd.muddCurrentlyInsane && !_vm->_awayMission.mudd.repairedLifeSupportGenerator) {
if (true || _vm->_awayMission.mudd.numTimesEnteredRoom5 == 2 && !_vm->_awayMission.mudd.muddCurrentlyInsane && !_vm->_awayMission.mudd.repairedLifeSupportGenerator) { // FIXME
_vm->_awayMission.mudd.muddCurrentlyInsane = true;
_vm->_awayMission.mudd.numTimesEnteredRoom5 = 1;
_vm->_awayMission.disableInput = 2;

View File

@ -107,4 +107,69 @@ void Room::muddaUseDegrimer() {
showText(text[_roomIndex]);
}
void Room::muddaTick() {
assert(_roomIndex >= 0 && _roomIndex <= 5);
const Common::Point deathPositions[][4] = {
{ Common::Point(0xbb, 0x8d), Common::Point(0xd0, 0x89), Common::Point(0xaa, 0x85), Common::Point(0xbf, 0x83) },
{ Common::Point(-1, -1), Common::Point(-1, -1), Common::Point(-1, -1), Common::Point(-1, -1) },
{ Common::Point(-1, -1), Common::Point(-1, -1), Common::Point(-1, -1), Common::Point(-1, -1) },
{ Common::Point(-1, -1), Common::Point(-1, -1), Common::Point(-1, -1), Common::Point(-1, -1) },
{ Common::Point(-1, -1), Common::Point(-1, -1), Common::Point(-1, -1), Common::Point(-1, -1) },
{ Common::Point(0x8b, 0xac), Common::Point(0x6f, 0x99), Common::Point(-1, -1), Common::Point(-1, -1) },
};
const TextRef deathText[] = {
TX_MUD0N006, 0, 0, 0, TX_MUD5N105
};
// This is implemented somewhat differently in each room.
// MUDD0:
//const int TIMER_LENGTH = 27000;
const int TIMER_LENGTH = 60; // FIXME
if (_vm->_awayMission.mudd.lifeSupportMalfunctioning) {
if (!_vm->_awayMission.mudd.startedLifeSupportTimer) {
_vm->_awayMission.mudd.startedLifeSupportTimer = true;
_vm->_awayMission.mudd.lifeSupportTimer = TIMER_LENGTH;
}
_vm->_awayMission.mudd.lifeSupportTimer--;
if (_vm->_awayMission.mudd.lifeSupportTimer == (int)(TIMER_LENGTH * 0.25)) {
showText(TX_SPEAKER_SPOCK, TX_MUD0_018);
} else if (_vm->_awayMission.mudd.lifeSupportTimer == (int)(TIMER_LENGTH * 0.5)) {
showText(TX_SPEAKER_SPOCK, TX_MUD0_019);
} else if (_vm->_awayMission.mudd.lifeSupportTimer == (int)(TIMER_LENGTH * 0.75)) {
showText(TX_SPEAKER_SPOCK, TX_MUD0_020);
} else if (_vm->_awayMission.mudd.lifeSupportTimer == 1) {
_vm->_awayMission.disableInput = true;
for (int i = OBJECT_KIRK; i <= OBJECT_REDSHIRT; i++) {
if (deathPositions[_roomIndex][i].x != -1)
walkCrewman(i, deathPositions[_roomIndex][i].x, deathPositions[_roomIndex][i].y, 9 + i);
}
showText(deathText[_roomIndex]);
showGameOverMenu();
}
}
}
void Room::muddaKirkReachedDeathPosition() {
loadActorAnim2(OBJECT_KIRK, "kgetdw");
}
void Room::muddaSpockReachedDeathPosition() {
loadActorAnim2(OBJECT_SPOCK, "sgetds");
}
void Room::muddaMccoyReachedDeathPosition() {
loadActorAnim2(OBJECT_MCCOY, "sgetdn");
}
void Room::muddaRedshirtReachedDeathPosition() {
loadActorAnim2(OBJECT_REDSHIRT, "rgetde");
// NOTE: there's code to check if he's the last one down... not really implemented
// properly
}
}