diff options
author | Eugene Sandulenko | 2018-03-24 02:31:12 +0100 |
---|---|---|
committer | Eugene Sandulenko | 2018-03-24 02:45:26 +0100 |
commit | ff11cee4808019c3304f0a298274554a68d78dcf (patch) | |
tree | 0bd7b422ab284847c6eb24805bbf30c0a6582de8 /engines/bladerunner | |
parent | bb492da8aaf5e072cd22eea44c2344309e92be4f (diff) | |
download | scummvm-rg350-ff11cee4808019c3304f0a298274554a68d78dcf.tar.gz scummvm-rg350-ff11cee4808019c3304f0a298274554a68d78dcf.tar.bz2 scummvm-rg350-ff11cee4808019c3304f0a298274554a68d78dcf.zip |
BLADERUNNER: Added WIP code for PoliceMazeTargetTrack::tick()
Diffstat (limited to 'engines/bladerunner')
-rw-r--r-- | engines/bladerunner/mouse.cpp | 27 | ||||
-rw-r--r-- | engines/bladerunner/mouse.h | 6 | ||||
-rw-r--r-- | engines/bladerunner/police_maze.cpp | 324 | ||||
-rw-r--r-- | engines/bladerunner/police_maze.h | 15 | ||||
-rw-r--r-- | engines/bladerunner/script/scene_script.h | 2 |
5 files changed, 352 insertions, 22 deletions
diff --git a/engines/bladerunner/mouse.cpp b/engines/bladerunner/mouse.cpp index 7d67e98de5..a3a52b7046 100644 --- a/engines/bladerunner/mouse.cpp +++ b/engines/bladerunner/mouse.cpp @@ -51,6 +51,11 @@ Mouse::Mouse(BladeRunnerEngine *vm) { _disabledCounter = 0; _lastFrameTime = 0; _animCounter = 0; + + _randomCountdownX = 0; + _randomCountdownY = 0; + _randomX = 0; + _randomY = 0; } Mouse::~Mouse() { @@ -161,6 +166,28 @@ void Mouse::getXY(int *x, int *y) const { *y = _y; } +void Mouse::setRandomY() { + switch (_vm->_settings->getDifficulty()) { + case 0: + _randomCountdownY = 2; + _randomX = _vm->_rnd.getRandomNumberRng(-3, 3); + _randomY = _vm->_rnd.getRandomNumberRng(10, 20); + break; + + case 1: + _randomCountdownY = 3; + _randomX = _vm->_rnd.getRandomNumberRng(-4, 4); + _randomY = _vm->_rnd.getRandomNumberRng(15, 25); + break; + + case 2: + _randomCountdownY = 4; + _randomX = _vm->_rnd.getRandomNumberRng(-5, 5); + _randomY = _vm->_rnd.getRandomNumberRng(20, 30); + break; + } +} + void Mouse::disable() { ++_disabledCounter; } diff --git a/engines/bladerunner/mouse.h b/engines/bladerunner/mouse.h index 2f33d72583..e63c101395 100644 --- a/engines/bladerunner/mouse.h +++ b/engines/bladerunner/mouse.h @@ -46,6 +46,11 @@ class Mouse { int _lastFrameTime; int _animCounter; + int _randomCountdownX; + int _randomCountdownY; + int _randomX; + int _randomY; + public: Mouse(BladeRunnerEngine *vm); ~Mouse(); @@ -53,6 +58,7 @@ public: void setCursor(int cursor); void getXY(int *x, int *y) const; + void setRandomY(); void disable(); void enable(); diff --git a/engines/bladerunner/police_maze.cpp b/engines/bladerunner/police_maze.cpp index 7345dc0490..43e4457f41 100644 --- a/engines/bladerunner/police_maze.cpp +++ b/engines/bladerunner/police_maze.cpp @@ -23,6 +23,7 @@ #include "bladerunner/bladerunner.h" #include "bladerunner/game_constants.h" #include "bladerunner/items.h" +#include "bladerunner/mouse.h" #include "bladerunner/police_maze.h" #include "bladerunner/scene.h" #include "bladerunner/scene_objects.h" @@ -30,9 +31,7 @@ namespace BladeRunner { -PoliceMaze::PoliceMaze(BladeRunnerEngine *vm) { - _vm = vm; - +PoliceMaze::PoliceMaze(BladeRunnerEngine *vm) : ScriptBase(vm) { reset(); for (int i = 0; i < kNumMazeTracks; i++) { @@ -111,16 +110,14 @@ void PoliceMaze::tick() { _announcementRead = true; if (_vm->_scene->getSceneId() == kScenePS13) { - _vm->_sceneScript->actorVoiceOver(320, kActorAnsweringMachine); + Actor_Voice_Over(320, kActorAnsweringMachine); } else { - _vm->_sceneScript->actorVoiceOver(310, kActorAnsweringMachine); + Actor_Voice_Over(310, kActorAnsweringMachine); } } } -PoliceMazeTargetTrack::PoliceMazeTargetTrack(BladeRunnerEngine *vm) { - _vm = vm; - +PoliceMazeTargetTrack::PoliceMazeTargetTrack(BladeRunnerEngine *vm) : ScriptBase(vm) { reset(); } @@ -134,14 +131,14 @@ void PoliceMazeTargetTrack::reset() { _count = 0; _data = 0; _dataIndex = 0; - _pmt_var1 = 0; - _pmt_var2 = 0; + _updateDelay = 0; + _waitTime = 0; _time = 0; - _pmt_var3 = 0; + _haveToWait = false; _pmt_var4 = 0; _pointIndex = 0; _pmt_var5 = 0; - _rotating = 0; + _rotating = false; _maxAngle = 0; _angleChange = 0; _visible = true; @@ -180,7 +177,308 @@ void PoliceMazeTargetTrack::add(int trackId, float startX, float startY, float s _isPresent = true; } -void PoliceMazeTargetTrack::tick() { +bool PoliceMazeTargetTrack::tick() { + if (!_isPresent) { + return false; + } + +#if 0 + + uint32 oldTime = _time; + _time = _vm->getTotalPlayTime(); + int32 timeDiff = _time - oldTime; + _updateDelay -= timeDiff; + + if (_updateDelay > 0) + return false; + + _updateDelay = 66; + + if (_visible) + return false; + + if (_haveToWait) { + _waitTime -= timeDiff; + + if (_waitTime > 0) + return true; + + _haveToWait = false; + _waitTime = 0; + } + + if (_vm->_items->isTarget(_itemId)) + return true; + + if (_rotating) { + float angle = _vm->_items->getFacing(_itemId) + _angleChange; + + if (_angleChange > 0) { + if (angle >= _maxAngle) { + angle = _maxAngle; + _rotating = false; + } + } else if (_angleChange < 0) { + if (angle <= _maxAngle) { + angle = _maxAngle; + _rotating = false; + } + } else { + _rotating = false; + } + + _vm->_items->setFacing(_itemId, angle); + + if (_rotating) + return false; + } + + bool advancePoint = false; + + if (_pmt_var4) { + if (_pointIndex < _pmt_var5) { + _pointIndex++; + advancePoint = true; + } else if (_pointIndex > _pmt_var5) { + _pointIndex--; + advancePoint = true; + } else { + _pmt_var4 = 0; + } + } + + if (advancePoint) { + _vm->_items->setXYZ(_itemId, _points[_pointIndex].x, _points[_pointIndex].y, _points[_pointIndex].z); + readdObject(_itemId); + + return true; + } + + bool cont = true; + int var1 = 0, var2 = 0, var3 = 0, varRes = 0; + + while (cont) { + _dataIndex++; + + switch (_data[_dataIndex - 1] + 26) { + case 0: + var1 = _data[_dataIndex++]; + var2 = _data[_dataIndex++]; + + if (Global_Variable_Query(var1) >= Global_Variable_Query(var2)) { + setVisible(); + cont = false; + } else { + cont = true; + } + break; + + case 1: + if (!_vm->_items->isPoliceMazeEnemy(_itemId) && _vm->_items->isTarget(_itemId)) { + Police_Maze_Increment_Score(1); + } + break; + + case 2: + var1 = _data[_dataIndex++]; + _dataIndex++; + + if (_vm->_items->isTarget(_itemId)) { + Sound_Play(var1, 90, 0, 0, 50, 0); + Police_Maze_Decrement_Score(1); + Actor_Force_Stop_Walking(0); + + if (Player_Query_Combat_Mode() == 1) { + Actor_Change_Animation_Mode(0, 22); + } else { + Actor_Change_Animation_Mode(0, 21); + } + + int snd; + + if (Random_Query(1, 2) == 1) { + snd = 9900; + } else { + snd = 9905; + } + Sound_Play_Speech_Line(0, snd, 75, 0, 99); + + _vm->_mouse->setRandomY(); + } + + cont = false; + break; + + case 3: + var1 = _data[_dataIndex++]; + _vm->_items->setPoliceMazeEnemy(var1, 0); + break; + + case 4: + var1 = _data[_dataIndex++]; + _vm->_items->setPoliceMazeEnemy(var1, 1); + break; + + case 5: + var1 = _data[_dataIndex++]; + Game_Flag_Reset(var1); + break; + + case 6: + var1 = _data[_dataIndex++]; + Game_Flag_Set(var1); + break; + + case 7: + var1 = _data[_dataIndex++]; + Global_Variable_Decrement(var1, 1); + break; + + case 8: + var1 = _data[_dataIndex++]; + var2 = _data[_dataIndex++]; + if (Global_Variable_Query(var1) < var2) { + Global_Variable_Increment(var1, 1); + } + break; + + case 9: + var1 = _data[_dataIndex++]; + Global_Variable_Reset(var1); + break; + + case 10: + var1 = _data[_dataIndex++]; + var2 = _data[_dataIndex++]; + Global_Variable_Set(var1, var2); + break; + + case 11: + var1 = _data[_dataIndex++]; + var2 = _data[_dataIndex++]; + _vm->_items->setIsTarget(var1, var2); + break; + + case 12: + var1 = _data[_dataIndex++]; + var2 = _data[_dataIndex++]; + var3 = _data[_dataIndex++]; + + switch (Random_Query(1, 3)) { + case 1: + varRes = var1; + break; + + case 2: + varRes = var2; + break; + + case 3: + varRes = var3; + break; + } + + _vm->_policeMaze->_tracks[varRes]->resetVisible(); + break; + + case 13: + var1 = _data[_dataIndex++]; + var2 = _data[_dataIndex++]; + + if (Random_Query(1, 2) == 1) { + varRes = var1; + } else { + varRes = var2; + } + _vm->_policeMaze->_tracks[varRes]->resetVisible(); + break; + + case 14: + var1 = _data[_dataIndex++]; + _vm->_policeMaze->_tracks[var1]->setVisible(); + break; + + case 15: + var1 = _data[_dataIndex++]; + _vm->_policeMaze->_tracks[var1]->resetVisible(); + break; + + case 16: + var1 = _data[_dataIndex++]; + var2 = _data[_dataIndex++]; + Sound_Play(var1, var2, 0, 0, 50, 0); + break; + + case 17: + var1 = _data[_dataIndex++]; + _vm->_items->setIsObstacle(var1, 0); + break; + + case 18: + var1 = _data[_dataIndex++]; + _vm->_items->setIsObstacle(var1, 1); + break; + + case 19: + var1 = _data[_dataIndex++]; + var2 = _data[_dataIndex++]; + _waitTime = Random_Query(var1, var2); + _haveToWait = true; + + cont = false; + break; + + case 20: + _maxAngle = _data[_dataIndex++]; + _angleChange = _data[_dataIndex++]; + _rotating = true; + + cont = false; + break; + + case 21: + var1 = _data[_dataIndex++]; + _vm->_items->setFacing(_itemId, var1); + break; + + case 22: + _dataIndex = 0; + + cont = false; + break; + + case 23: + _waitTime = _data[_dataIndex++]; + _haveToWait = true; + + cont = false; + break; + + case 24: + _pmt_var5 = _data[_dataIndex++]; + _pmt_var4 = 1; + + cont = false; + break; + + case 25: + _pointIndex = _data[_dataIndex++]; + _pmt_var4 = 0; + _vm->_items->setXYZ(_itemId, _points[_pointIndex].x, _points[_pointIndex].y, _points[_pointIndex].z); + readdObject(_itemId); + break; + + default: + return false; + } + + if (_visible || _haveToWait) { + cont = false; + } + } +#endif + + return true; } void PoliceMazeTargetTrack::readdObject(int itemId) { diff --git a/engines/bladerunner/police_maze.h b/engines/bladerunner/police_maze.h index adf857c479..1cb9da5555 100644 --- a/engines/bladerunner/police_maze.h +++ b/engines/bladerunner/police_maze.h @@ -23,6 +23,7 @@ #ifndef BLADERUNNER_POLICE_MAZE_H #define BLADERUNNER_POLICE_MAZE_H +#include "bladerunner/script/script.h" #include "bladerunner/vector.h" namespace BladeRunner { @@ -34,7 +35,7 @@ enum { class BladeRunnerEngine; -class PoliceMazeTargetTrack { +class PoliceMazeTargetTrack : ScriptBase { BladeRunnerEngine *_vm; uint32 _time; @@ -44,13 +45,13 @@ class PoliceMazeTargetTrack { Vector3 _points[kNumTrackPoints]; int *_data; int _dataIndex; - int _pmt_var1; - int _pmt_var2; - int _pmt_var3; + int32 _updateDelay; + int32 _waitTime; + bool _haveToWait; int _pmt_var4; int _pointIndex; int _pmt_var5; - int _rotating; + bool _rotating; int _maxAngle; int _angleChange; bool _visible; @@ -63,7 +64,7 @@ public: void clear(bool isLoadingGame); void add(int trackId, float startX, float startY, float startZ, float endX, float endY, float endZ, int count, void *list, bool a11); - void tick(); + bool tick(); bool isPresent() { return _isPresent; } void setVisible() { _visible = true; } void resetVisible() { _visible = false; } @@ -73,7 +74,7 @@ public: void readdObject(int itemId); }; -class PoliceMaze { +class PoliceMaze : ScriptBase { BladeRunnerEngine *_vm; bool _isPaused; diff --git a/engines/bladerunner/script/scene_script.h b/engines/bladerunner/script/scene_script.h index f9f08050e3..54047ed8a8 100644 --- a/engines/bladerunner/script/scene_script.h +++ b/engines/bladerunner/script/scene_script.h @@ -546,8 +546,6 @@ public: void playerWalkedOut(); void dialogueQueueFlushed(int a1); bool isInsideScript() const { return _inScriptCounter > 0; } - - void actorVoiceOver(int sentenceId, int actorId) { _currentScript->Actor_Voice_Over(sentenceId, actorId); } }; } // End of namespace BladeRunner |