Permalink
Browse files

STARTREK: DEMON1 done (klingon attack)

  • Loading branch information...
Drenn1 authored and sev- committed May 25, 2018
1 parent ca3a9dc commit 45ae72b763268d87a5a6613231b7a11a2fbd8168
@@ -35,6 +35,7 @@ enum Acton {

ACTION_TOUCHED_WARP = 6,
ACTION_TOUCHED_HOTSPOT = 7, // Doors? (Or just hotspots activated by Kirk moving there?)
ACTION_TIMER_EXPIRED = 8,
ACTION_FINISHED_ANIMATION = 10,
ACTION_FINISHED_WALKING = 12,
ACTION_OPTIONS = 13 // Not really an action, but selectable from action menu
@@ -108,7 +108,7 @@ void StarTrekEngine::loadRoom(const Common::String &missionName, int roomIndex)
void StarTrekEngine::initAwayCrewPositions(int warpEntryIndex) {
_sound->stopAllVocSounds();

memset(_awayMission.field25, 0xff, 4);
memset(_awayMission.crewDirectionsAfterWalk, 0xff, 4);

switch (warpEntryIndex) {
case 0: // 0-3: Read warp positions from RDF file
@@ -160,13 +160,13 @@ void StarTrekEngine::handleAwayMissionEvents() {
switch (event.type) {
case TREKEVENT_TICK:
updateActorAnimations();
// sub_236bb();
updateCrewmanGetupTimers();
updateMouseBitmap();
// doSomethingWithBanData1();
_gfx->drawAllSprites();
// doSomethingWithBanData2();
_sound->checkLoopMusic();
// sub_22de0();
updateAwayMissionTimers();
_frameIndex++;
_roomFrameCounter++;
addAction(Action(ACTION_TICK, _roomFrameCounter & 0xff, (_roomFrameCounter >> 8) & 0xff, 0));
@@ -180,7 +180,7 @@ void StarTrekEngine::handleAwayMissionEvents() {

switch (_awayMission.activeAction) {
case ACTION_WALK: {
if (_awayMission.field1c != 0)
if (_awayMission.disableWalking)
break;
_kirkActor->sprite.drawMode = 1; // Hide these objects for function call below?
_spockActor->sprite.drawMode = 1;
@@ -208,7 +208,7 @@ void StarTrekEngine::handleAwayMissionEvents() {
}

case ACTION_USE: {
if (_awayMission.activeObject == OBJECT_REDSHIRT && (_awayMission.redshirtDead || (_awayMission.field24 & 8))) {
if (_awayMission.activeObject == OBJECT_REDSHIRT && (_awayMission.redshirtDead || (_awayMission.crewDownBitset & (1 << OBJECT_REDSHIRT)))) {
hideInventoryIcons();
_awayMission.activeAction = ACTION_WALK;
break;
@@ -277,7 +277,7 @@ void StarTrekEngine::handleAwayMissionEvents() {
addAction(Action(_awayMission.activeAction, _awayMission.activeObject, _awayMission.passiveObject, 0));

checkShowInventory:
if (!(_awayMission.field24 & 1))
if (!(_awayMission.crewDownBitset & (1 << OBJECT_KIRK)))
showInventoryIcons(true);
}
break;
@@ -304,7 +304,7 @@ void StarTrekEngine::handleAwayMissionEvents() {
if (clickedObject != -2)
addAction(Action(_awayMission.activeAction, _awayMission.activeObject, 0, 0));

if (_awayMission.activeAction == ACTION_LOOK && !(_awayMission.field24 & (1 << OBJECT_KIRK)))
if (_awayMission.activeAction == ACTION_LOOK && !(_awayMission.crewDownBitset & (1 << OBJECT_KIRK)))
showInventoryIcons(false);
}
break;
@@ -317,7 +317,7 @@ void StarTrekEngine::handleAwayMissionEvents() {
break;

case TREKEVENT_RBUTTONDOWN: // TODO: also triggered by key press?
if (_awayMission.field1d)
if (_awayMission.transitioningIntoRoom)
break;
hideInventoryIcons();
playSoundEffectIndex(0x07);
@@ -330,7 +330,7 @@ void StarTrekEngine::handleAwayMissionEvents() {
_awayMission.activeObject = clickedObject;
}
if (_awayMission.activeAction == ACTION_USE
&& _awayMission.activeObject == OBJECT_ICOMM && (_awayMission.field24 & (1 << OBJECT_KIRK)) == 0) {
&& _awayMission.activeObject == OBJECT_ICOMM && (_awayMission.crewDownBitset & (1 << OBJECT_KIRK)) == 0) {
if (!walkActiveObjectToHotspot()) {
addAction(Action(_awayMission.activeAction, _awayMission.activeObject, 0, 0));
_sound->playVoc("communic");
@@ -339,7 +339,7 @@ void StarTrekEngine::handleAwayMissionEvents() {
}
else if (_awayMission.activeAction == ACTION_LOOK)
showInventoryIcons(false);
else if (_awayMission.activeAction == ACTION_USE && (_awayMission.field24 & 1) == 0)
else if (_awayMission.activeAction == ACTION_USE && (_awayMission.crewDownBitset & 1) == 0)
showInventoryIcons(true);
break;

@@ -519,7 +519,7 @@ void StarTrekEngine::checkTouchedLoadingZone(int16 x, int16 y) {
}
_activeDoorWarpHotspot = -1;

if (_awayMission.field24 == 0 && _warpHotspotsActive) {
if (_awayMission.crewDownBitset == 0 && _warpHotspotsActive) {
offset = _room->getFirstWarpPolygonOffset();

while (offset != _room->getWarpPolygonEndOffset()) {
@@ -539,6 +539,20 @@ void StarTrekEngine::checkTouchedLoadingZone(int16 x, int16 y) {
_activeWarpHotspot = -1;
}

/**
* Updates any nonzero away mission timers, and invokes ACTION_TIMER_EXPIRED when any one
* reached 0.
*/
void StarTrekEngine::updateAwayMissionTimers() {
for (int i = 0; i < 8; i++) {
if (_awayMission.timers[i] == 0)
continue;
_awayMission.timers[i]--;
if (_awayMission.timers[i] == 0)
addAction(ACTION_TIMER_EXPIRED, i, 0, 0);
}
}

/**
* Returns true if the given position in the room is solid (not walkable).
* Reads from a ".map" file which has a bit for each position in the room, which is true
@@ -25,33 +25,47 @@

// All variables here get cleared to 0 upon starting an away mission.
struct AwayMission {
int16 mouseX;
int16 mouseY;
byte field1c;
byte field1d;
byte transitioningIntoRoom; // Set while beaming in or walking into a room. Disables control?
bool redshirtDead;
byte activeAction;
byte activeObject; // The item that is going to be used on something
byte passiveObject; // The item that the active item is used on (or the item looked at, etc).
// These timers count down automatically when nonzero. When they reach 0,
// ACTION_TIMER_EXPIRED is invoked with the corresponding index (0-7).
int16 timers[8]; // 0x00-0x0f

int16 mouseX; // 0x10
int16 mouseY; // 0x12
int16 crewGetupTimers[4]; // 0x14
bool disableWalking; // 0x1c
byte transitioningIntoRoom; // 0x1d; Set while beaming in or walking into a room. Disables control?
bool redshirtDead; // 0x1e
byte activeAction; // 0x1f
byte activeObject; // 0x20; The item that is going to be used on something
byte passiveObject; // 0x21; The item that the active item is used on (or the item looked at, etc).

// If this is true after calling room-specific RDF code, the game will continue to run
// any "default" code for the event, if any.
bool rdfStillDoDefaultAction;
bool rdfStillDoDefaultAction; // 0x23

// If a bit in "crewDownBitset" is set, the corresponding timer in "crewGetupTimers"
// begins counting down. When it reaches 0, they get up.
byte crewDownBitset;

// Bits 0-3 correspond to the crewmen? A bit is set if they're not selectable with
// the use action?
byte field24;
int8 crewDirectionsAfterWalk[4]; // Sets an object's direction after they finish walking somewhere?

int8 field25[4]; // Sets an object's direction after they finish walking somewhere?
// Mission-specific variables
union {
// Demon World
struct {
bool wasRudeToPrelate; // 0x29
bool beatKlingons; // 0x2f
bool tookKlingonHand; // 0x31

// Demon Word: nonzero if a rude response was given to the prelate.
int16 field29;
bool talkedToPrelate; // 0x33
bool askedPrelateAboutSightings; // 0x36
byte field37; // 0x37
bool mccoyMentionedFlora; // 0x38
byte enteredFrom; // 0x3a

byte field33;
byte field36;
byte field38;
byte field3a;
bool warpsDisabled; // 0x48
} demon;
};

int16 missionScore;
};
@@ -848,6 +848,39 @@ void StarTrekEngine::showQuitGamePrompt(int x, int y) {
}
}

void StarTrekEngine::showGameOverMenu() {
const char *options[] = {
"Game Over",
"#GENE\\GENER006#Load a previously saved game.",
"#GENE\\GENER020#Restart the game.",
"#GENE\\GENER018#Quit the game.",
""
};

while (true) {
_inQuitGameMenu = true;
int selected = showText(&StarTrekEngine::readTextFromArray, (uintptr)options, 20, 20, TEXTCOLOR_YELLOW, true, false, true);
_inQuitGameMenu = false;

switch (selected) {
case 0: // Load game
_gfx->fadeoutScreen();
showLoadMenu(); // TODO: this probably manipulates the stack to jump out of this function...
break;
case 1: // Restart
_gfx->fadeoutScreen();
// TODO
break;
case 2: // Quit
_gfx->fadeoutScreen();
_system->quit();
break;
default:
break;
}
}
}

/**
* This can be called from startup or from the options menu.
* On startup, this tries to load the setting without user input.
@@ -18,7 +18,8 @@ MODULE_OBJS = \
sprite.o \
startrek.o \
text.o \
rooms/demon0.o
rooms/demon0.o \
rooms/demon1.o



@@ -40,11 +40,16 @@ Room::Room(StarTrekEngine *vm, const Common::String &name) : _vm(vm) {
_roomActionList = demon0ActionList;
_numRoomActions = sizeof(demon0ActionList) / sizeof(RoomAction);
}
else if (name == "DEMON1") {
_roomActionList = demon1ActionList;
_numRoomActions = sizeof(demon1ActionList) / sizeof(RoomAction);
}
else {
warning("Room \"%s\" unimplemented", name.c_str());
_numRoomActions = 0;
return;
}

memset(&_roomVar, 0, sizeof(_roomVar));
}

Room::~Room() {
@@ -182,7 +187,7 @@ void Room::giveItem(int item) {
}

void Room::loadRoomIndex(int roomIndex, int spawnIndex) {
if (_vm->_awayMission.field24 != 0)
if (_vm->_awayMission.crewDownBitset != 0)
return;

_vm->loadRoomIndex(roomIndex, spawnIndex);
@@ -215,6 +220,10 @@ void Room::playMidiMusicTracks(int startTrack, int loopTrack) {
_vm->playMidiMusicTracks(startTrack, loopTrack);
}

void Room::showGameOverMenu() {
_vm->showGameOverMenu();
}

void Room::playVoc(Common::String filename) {
_vm->_sound->playVoc(filename);
}
@@ -103,6 +103,7 @@ class Room {
void walkCrewman(int actorIndex, int16 destX, int16 destY, uint16 finishedAnimActionParam);// Cmd 0x08
void playSoundEffectIndex(int soundEffect); // Cmd 0x0f
void playMidiMusicTracks(int startTrack, int loopTrack); // Cmd 0x10
void showGameOverMenu(); // Cmd 0x12
void playVoc(Common::String filename); // Cmd 0x15

// Room-specific code
@@ -144,8 +145,75 @@ class Room {
void demon0UseSTricorderAnywhere();
void demon0UseMTricorderAnywhere();
void demon0UseMTricorderOnPrelate();

void demon0BadResponse();

// DEMON1
void demon1Tick1();
void demon1WalkToCave();
void demon1TouchedTopWarp();
void demon1TouchedBottomWarp();
void demon1Timer2Expired();
void demon1Timer0Expired();
void demon1Timer3Expired();
void demon1Timer1Expired();
void demon1KlingonFinishedAimingWeapon();
void demon1KirkShot();
void demon1UsePhaserOnAnything();
void demon1UsePhaserOnKlingon1();
void demon1ShootKlingon1();
void demon1KlingonDropsHand();
void demon1UsePhaserOnKlingon2();
void demon1ShootKlingon2();
void demon1UsePhaserOnKlingon3();
void demon1ShootKlingon3();
void demon1AllKlingonsDead();
void demon1Timer5Expired();
void demon1UseMTricorderOnKlingon();
void demon1UseSTricorderOnTulips();
void demon1UseSTricorderOnPods();
void demon1UseSTricorderOnCattails();
void demon1UseSTricorderOnFerns();
void demon1UseSTricorderOnHand();
void demon1UseSTricorderOnKlingon1();
void demon1UseSTricorderOnKlingon2Or3();
void demon1UseMTricorderOnKirk();
void demon1UseMTricorderOnSpock();
void demon1UseMTricorderOnRedshirt();
void demon1UseMTricorderOnCrewman();
void demon1GetHand();
void demon1ReachedHand();
void demon1PickedUpHand();
void demon1FinishedGettingHand();
void demon1LookAtKlingon();
void demon1LookAtCattails();
void demon1LookAtTulips();
void demon1LookAtPods();
void demon1LookAtFerns();
void demon1LookAtStream();
void demon1LookAtMine();
void demon1LookAtMountain();
void demon1LookAtHand();
void demon1LookAnywhere();
void demon1LookAtKirk();
void demon1LookAtSpock();
void demon1LookAtMcCoy();
void demon1LookAtRedshirt();
void demon1TalkToKirk();
void demon1TalkToSpock();
void demon1TalkToMcCoy();
void demon1TalkToRedshirt();
void demon1TalkToUnconsciousCrewman();

private:
// Room-specific variables. This is memset'ed to 0 when the room is initialized.
union {
struct {
int numKlingonsKilled;
byte attackIndex;
bool kirkShooting;
char d6[10];
} demon1;
} _roomVar;
};

}
Oops, something went wrong.

0 comments on commit 45ae72b

Please sign in to comment.