Permalink
Browse files

BLADERUNNER: Added original logic for speech skipping

And some small cleanup of unnecessary comments.
  • Loading branch information...
peterkohaut committed Feb 11, 2019
1 parent 6854ea3 commit 916221dc562c9062839918d58d1a9968eb8f2b5e
@@ -103,14 +103,18 @@ BladeRunnerEngine::BladeRunnerEngine(OSystem *syst, const ADGameDescription *des
_vqaIsPlaying = false;
_vqaStopIsRequested = false;

_actorIsSpeaking = false;
_actorSpeakStopIsRequested = false;

_subtitlesEnabled = false;
_sitcomMode = true;
_sitcomMode = false;
_shortyMode = false;

_playerLosesControlCounter = 0;

_playerActorIdle = false;
_playerDead = false;
_speechSkipped = false;

_gameOver = false;
_gameAutoSave = -1;
_gameIsLoading = false;
@@ -401,11 +405,8 @@ bool BladeRunnerEngine::startup(bool hasSavegames) {

_gameVars = new int[_gameInfo->getGlobalVarCount()]();

// TODO: Init Actor AI Update counter

// Seed rand

// TODO: Sine and cosine lookup tables for intervals of 1.0, 4.0, and 12.0
_cosTable1024 = new Common::CosineTable(1024); // 10-bits = 1024 points for 2*PI;
_sinTable1024 = new Common::SineTable(1024);

@@ -469,8 +470,6 @@ bool BladeRunnerEngine::startup(bool hasSavegames) {
_playerActor->setFPS(15);
_playerActor->timerStart(6, 200);

// TODO: Set actor ids (redundant?)

_policeMaze = new PoliceMaze(this);

_textActorNames = new TextResource(this);
@@ -563,7 +562,6 @@ bool BladeRunnerEngine::startup(bool hasSavegames) {
}

void BladeRunnerEngine::initChapterAndScene() {
// TODO: Init actors...
for (int i = 0, end = _gameInfo->getActorCount(); i != end; ++i) {
_aiScripts->initialize(i);
}
@@ -611,8 +609,8 @@ void BladeRunnerEngine::shutdown() {
}
_shapes.clear();

// TODO: Shutdown Scene
delete _scene;
_scene = nullptr;

if (_chapters) {
if (_chapters->hasOpenResources())
@@ -693,7 +691,7 @@ void BladeRunnerEngine::shutdown() {
_mainFont = nullptr;
}

if(isArchiveOpen("SUBTITLES.MIX")) {
if (isArchiveOpen("SUBTITLES.MIX")) {
closeArchive("SUBTITLES.MIX");
}
if (_subtitles) {
@@ -756,7 +754,6 @@ void BladeRunnerEngine::shutdown() {
delete _gameInfo;
_gameInfo = nullptr;

// TODO: Delete graphics surfaces here
_surface4.free();
_surfaceBack.free();
_surfaceFront.free();
@@ -765,8 +762,6 @@ void BladeRunnerEngine::shutdown() {
closeArchive("STARTUP.MIX");
}

// TODO: Delete MIXArchives here

delete _time;
_time = nullptr;

@@ -908,7 +903,6 @@ void BladeRunnerEngine::gameTick() {

_policeMaze->tick();

// TODO: Gun range announcements
_zbuffer->clean();

_ambientSounds->tick();
@@ -963,8 +957,6 @@ void BladeRunnerEngine::gameTick() {
_mouse->tick(p.x, p.y);
_mouse->draw(_surfaceFront, p.x, p.y);

// TODO: Process AUD

if (_walkSoundId >= 0) {
_audioPlayer->playAud(_gameInfo->getSfxTrack(_walkSoundId), _walkSoundVolume, _walkSoundBalance, _walkSoundBalance, 50, 0);
_walkSoundId = -1;
@@ -1066,8 +1058,11 @@ void BladeRunnerEngine::handleEvents() {
}

void BladeRunnerEngine::handleKeyUp(Common::Event &event) {
if (event.kbd.keycode == Common::KEYCODE_RETURN) {
_speechSkipped = true;
if (_actorIsSpeaking && event.kbd.keycode == Common::KEYCODE_RETURN) {
_actorSpeakStopIsRequested = true;
_actorIsSpeaking = false;

return;
}

if (_vqaIsPlaying) {
@@ -1077,8 +1072,7 @@ void BladeRunnerEngine::handleKeyUp(Common::Event &event) {
return;
}

// TODO:
if (!playerHasControl() /*|| ActorInWalkingLoop*/) {
if (!playerHasControl() || _isWalkingInterruptible) {
return;
}

@@ -1133,8 +1127,7 @@ void BladeRunnerEngine::handleKeyDown(Common::Event &event) {
return;
}

//TODO:
if (!playerHasControl() /* || ActorWalkingLoop || ActorSpeaking || VqaIsPlaying */) {
if (!playerHasControl() || _isWalkingInterruptible || _actorIsSpeaking || _vqaIsPlaying) {
return;
}

@@ -188,7 +188,8 @@ class BladeRunnerEngine : public Engine {
bool _interruptWalking;
bool _playerActorIdle;
bool _playerDead;
bool _speechSkipped;
bool _actorIsSpeaking;
bool _actorSpeakStopIsRequested;
bool _gameOver;
int _gameAutoSave;
bool _gameIsLoading;
@@ -318,9 +318,11 @@ void ScriptBase::Actor_Says_With_Pause(int actorId, int sentenceId, float pause,
}
Player_Loses_Control();
while (_vm->_gameIsRunning) {
_vm->_speechSkipped = false;
_vm->_actorIsSpeaking = true;
_vm->_actorSpeakStopIsRequested = false;
_vm->gameTick();
if (_vm->_speechSkipped || !actor->isSpeeching()) {
_vm->_actorIsSpeaking = false;
if (_vm->_actorSpeakStopIsRequested || !actor->isSpeeching()) {
actor->speechStop();
break;
}
@@ -336,7 +338,7 @@ void ScriptBase::Actor_Says_With_Pause(int actorId, int sentenceId, float pause,
}
}

if (pause > 0.0f && !_vm->_speechSkipped) {
if (pause > 0.0f && !_vm->_actorSpeakStopIsRequested) {
Delay(pause * 1000);
}

@@ -355,10 +357,12 @@ void ScriptBase::Actor_Voice_Over(int sentenceId, int actorId) {

actor->speechPlay(sentenceId, true);
Player_Loses_Control();
while(_vm->_gameIsRunning) {
_vm->_speechSkipped = false;
while (_vm->_gameIsRunning) {
_vm->_actorIsSpeaking = true;
_vm->_actorSpeakStopIsRequested = false;
_vm->gameTick();
if(_vm->_speechSkipped || !actor->isSpeeching()) {
_vm->_actorIsSpeaking = false;
if (_vm->_actorSpeakStopIsRequested || !actor->isSpeeching()) {
actor->speechStop();
break;
}
@@ -243,24 +243,24 @@ void VK::playSpeechLine(int actorId, int sentenceId, float duration) {
actor->speechPlay(sentenceId, true);

while (_vm->_gameIsRunning) {
// ActorSpeaking = 1;
_vm->_speechSkipped = false;
_vm->_actorIsSpeaking = true;
_vm->_actorSpeakStopIsRequested = false;
_vm->gameTick();
// ActorSpeaking = 0;
if (_vm->_speechSkipped || !actor->isSpeeching()) {
_vm->_actorIsSpeaking = false;
if (_vm->_actorSpeakStopIsRequested || !actor->isSpeeching()) {
actor->speechStop();
break;
}
}

if (duration > 0.0f && !_vm->_speechSkipped) {
if (duration > 0.0f && !_vm->_actorSpeakStopIsRequested) {
int timeEnd = duration * 1000.0f + _vm->_time->current();
while ((timeEnd > _vm->_time->current()) && _vm->_gameIsRunning) {
_vm->gameTick();
}
}

_vm->_speechSkipped = false;
_vm->_actorSpeakStopIsRequested = false;

_vm->_mouse->enable();
}

0 comments on commit 916221d

Please sign in to comment.