aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEugene Sandulenko2018-03-25 03:02:56 +0200
committerEugene Sandulenko2018-03-25 12:06:00 +0200
commit16e09b1f3476dfa91e7dde5abe942ad9b2f09bf2 (patch)
tree50c5d5026807d0a9df071e273c5469e90ca36a81
parent0d73b1f5df1a96a6dc6fd09b09216fde94811265 (diff)
downloadscummvm-rg350-16e09b1f3476dfa91e7dde5abe942ad9b2f09bf2.tar.gz
scummvm-rg350-16e09b1f3476dfa91e7dde5abe942ad9b2f09bf2.tar.bz2
scummvm-rg350-16e09b1f3476dfa91e7dde5abe942ad9b2f09bf2.zip
BLADERUNNER: Implement mouse jitter
-rw-r--r--engines/bladerunner/bladerunner.cpp9
-rw-r--r--engines/bladerunner/mouse.cpp42
-rw-r--r--engines/bladerunner/mouse.h3
-rw-r--r--engines/bladerunner/script/police_maze.cpp2
4 files changed, 49 insertions, 7 deletions
diff --git a/engines/bladerunner/bladerunner.cpp b/engines/bladerunner/bladerunner.cpp
index f481accfbd..871931a41c 100644
--- a/engines/bladerunner/bladerunner.cpp
+++ b/engines/bladerunner/bladerunner.cpp
@@ -1239,7 +1239,7 @@ void BladeRunnerEngine::handleMouseClick3DObject(int objectId, bool buttonDown,
_settings->decreaseAmmo();
_audioPlayer->playAud(_gameInfo->getSfxTrack(_combat->getHitSound()), 100, 0, 0, 90, 0);
- //TODO mouse::randomize(Mouse);
+ _mouse->setMouseJitterUp();
_isInsideScriptObject = true;
_sceneScript->clickedOn3DObject(objectName.c_str(), true);
@@ -1280,7 +1280,7 @@ void BladeRunnerEngine::handleMouseClickEmpty(int x, int y, Vector3 &scenePositi
_settings->decreaseAmmo();
_audioPlayer->playAud(_gameInfo->getSfxTrack(_combat->getMissSound()), 100, 0, 0, 90, 0);
- //TODO mouse::randomize(Mouse);
+ _mouse->setMouseJitterUp();
if (actorId > 0) {
_aiScripts->shotAtAndMissed(actorId);
@@ -1375,7 +1375,8 @@ void BladeRunnerEngine::handleMouseClickItem(int itemId, bool buttonDown) {
_settings->decreaseAmmo();
_audioPlayer->playAud(_gameInfo->getSfxTrack(_combat->getHitSound()), 100, 0, 0, 90, 0);
- //TODO mouse::randomize(Mouse);
+ _mouse->setMouseJitterUp();
+
_isInsideScriptItem = true;
_sceneScript->clickedOnItem(itemId, true);
_isInsideScriptItem = false;
@@ -1445,7 +1446,7 @@ void BladeRunnerEngine::handleMouseClickActor(int actorId, bool mainButton, bool
_audioPlayer->playAud(_gameInfo->getSfxTrack(missed ? _combat->getMissSound() : _combat->getHitSound()), 100, 0, 0, 90, 0);
- //TODO mouse::randomize(Mouse);
+ _mouse->setMouseJitterUp();
if (missed) {
_aiScripts->shotAtAndMissed(actorId);
diff --git a/engines/bladerunner/mouse.cpp b/engines/bladerunner/mouse.cpp
index 7639e305dc..093c73fcff 100644
--- a/engines/bladerunner/mouse.cpp
+++ b/engines/bladerunner/mouse.cpp
@@ -166,7 +166,29 @@ void Mouse::getXY(int *x, int *y) const {
*y = _y;
}
-void Mouse::setRandomY() {
+void Mouse::setMouseJitterUp() {
+ switch (_vm->_settings->getDifficulty()) {
+ case 0:
+ _randomCountdownX = 2;
+ _randomX = _vm->_rnd.getRandomNumberRng(0, 6) - 3;
+ _randomY = _vm->_rnd.getRandomNumberRng(0, 10) - 20;
+ break;
+
+ case 1:
+ _randomCountdownX = 3;
+ _randomX = _vm->_rnd.getRandomNumberRng(0, 8) - 4;
+ _randomY = _vm->_rnd.getRandomNumberRng(0, 10) - 25;
+ break;
+
+ case 2:
+ _randomCountdownX = 4;
+ _randomX = _vm->_rnd.getRandomNumberRng(0, 10) - 5;
+ _randomY = _vm->_rnd.getRandomNumberRng(0, 10) - 30;
+ break;
+ }
+}
+
+void Mouse::setMouseJitterDown() {
switch (_vm->_settings->getDifficulty()) {
case 0:
_randomCountdownY = 2;
@@ -190,6 +212,9 @@ void Mouse::setRandomY() {
void Mouse::disable() {
++_disabledCounter;
+
+ _randomCountdownX = 0;
+ _randomCountdownY = 0;
}
void Mouse::enable() {
@@ -204,9 +229,24 @@ bool Mouse::isDisabled() const {
void Mouse::draw(Graphics::Surface &surface, int x, int y) {
if (_disabledCounter) {
+ _randomCountdownX = 0;
+ _randomCountdownY = 0;
return;
}
+ if (_randomCountdownX > 0) {
+ _randomCountdownX--;
+ x += _randomX;
+ y += _randomY;
+
+ if (!_randomCountdownX)
+ setMouseJitterDown();
+ } else if (_randomCountdownY > 0){
+ _randomCountdownY--;
+ x += _randomX;
+ y += _randomY;
+ }
+
_x = CLIP(x, 0, surface.w - 1);
_y = CLIP(y, 0, surface.h - 1);
diff --git a/engines/bladerunner/mouse.h b/engines/bladerunner/mouse.h
index e63c101395..31ba17a6c3 100644
--- a/engines/bladerunner/mouse.h
+++ b/engines/bladerunner/mouse.h
@@ -58,7 +58,8 @@ public:
void setCursor(int cursor);
void getXY(int *x, int *y) const;
- void setRandomY();
+ void setMouseJitterUp();
+ void setMouseJitterDown();
void disable();
void enable();
diff --git a/engines/bladerunner/script/police_maze.cpp b/engines/bladerunner/script/police_maze.cpp
index 68bb84a762..aaed223a57 100644
--- a/engines/bladerunner/script/police_maze.cpp
+++ b/engines/bladerunner/script/police_maze.cpp
@@ -333,7 +333,7 @@ bool PoliceMazeTargetTrack::tick() {
}
Sound_Play_Speech_Line(kActorMcCoy, snd, 75, 0, 99);
- _vm->_mouse->setRandomY();
+ _vm->_mouse->setMouseJitterDown();
}
cont = false;