aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorPaul Gilbert2015-06-17 20:45:37 -0400
committerPaul Gilbert2015-06-17 20:45:37 -0400
commit8abce6b025b1b4d8f50605875967f234b4b58312 (patch)
tree2ae99c3ae04e05fb96433ebdf8a4618a65d4d1ae /engines
parenta96aad55592101810f71dd8813767ddbe2e76ece (diff)
downloadscummvm-rg350-8abce6b025b1b4d8f50605875967f234b4b58312.tar.gz
scummvm-rg350-8abce6b025b1b4d8f50605875967f234b4b58312.tar.bz2
scummvm-rg350-8abce6b025b1b4d8f50605875967f234b4b58312.zip
SHERLOCK: RT: Implement walkToCoords
Diffstat (limited to 'engines')
-rw-r--r--engines/sherlock/people.cpp33
-rw-r--r--engines/sherlock/people.h2
-rw-r--r--engines/sherlock/scalpel/scalpel_people.cpp33
-rw-r--r--engines/sherlock/scalpel/scalpel_people.h6
-rw-r--r--engines/sherlock/tattoo/tattoo_people.cpp99
-rw-r--r--engines/sherlock/tattoo/tattoo_people.h5
6 files changed, 142 insertions, 36 deletions
diff --git a/engines/sherlock/people.cpp b/engines/sherlock/people.cpp
index b3ae135b40..cab4abff89 100644
--- a/engines/sherlock/people.cpp
+++ b/engines/sherlock/people.cpp
@@ -152,39 +152,6 @@ void Person::goAllTheWay() {
}
}
-void Person::walkToCoords(const Point32 &destPos, int destDir) {
- Events &events = *_vm->_events;
- People &people = *_vm->_people;
- Scene &scene = *_vm->_scene;
- Talk &talk = *_vm->_talk;
-
- CursorId oldCursor = events.getCursor();
- events.setCursor(WAIT);
-
- _walkDest = Common::Point(destPos.x / FIXED_INT_MULTIPLIER + 10, destPos.y / FIXED_INT_MULTIPLIER);
- people._allowWalkAbort = true;
- goAllTheWay();
-
- // Keep calling doBgAnim until the walk is done
- do {
- events.pollEventsAndWait();
- scene.doBgAnim();
- } while (!_vm->shouldQuit() && _walkCount);
-
- if (!talk._talkToAbort) {
- // Put character exactly on destination position, and set direction
- _position = destPos;
- _sequenceNumber = destDir;
- gotoStand();
-
- // Draw Holmes facing the new direction
- scene.doBgAnim();
-
- if (!talk._talkToAbort)
- events.setCursor(oldCursor);
- }
-}
-
/*----------------------------------------------------------------*/
People *People::init(SherlockEngine *vm) {
diff --git a/engines/sherlock/people.h b/engines/sherlock/people.h
index 39eb1068be..257c9b3987 100644
--- a/engines/sherlock/people.h
+++ b/engines/sherlock/people.h
@@ -85,7 +85,7 @@ public:
/**
* Walk to the co-ordinates passed, and then face the given direction
*/
- void walkToCoords(const Point32 &destPos, int destDir);
+ virtual void walkToCoords(const Point32 &destPos, int destDir) = 0;
};
class SherlockEngine;
diff --git a/engines/sherlock/scalpel/scalpel_people.cpp b/engines/sherlock/scalpel/scalpel_people.cpp
index af2bdc0256..94042e7a13 100644
--- a/engines/sherlock/scalpel/scalpel_people.cpp
+++ b/engines/sherlock/scalpel/scalpel_people.cpp
@@ -333,6 +333,39 @@ void ScalpelPerson::setWalking() {
_frameNumber = oldFrame;
}
+void ScalpelPerson::walkToCoords(const Point32 &destPos, int destDir) {
+ Events &events = *_vm->_events;
+ People &people = *_vm->_people;
+ Scene &scene = *_vm->_scene;
+ Talk &talk = *_vm->_talk;
+
+ CursorId oldCursor = events.getCursor();
+ events.setCursor(WAIT);
+
+ _walkDest = Common::Point(destPos.x / FIXED_INT_MULTIPLIER + 10, destPos.y / FIXED_INT_MULTIPLIER);
+ people._allowWalkAbort = true;
+ goAllTheWay();
+
+ // Keep calling doBgAnim until the walk is done
+ do {
+ events.pollEventsAndWait();
+ scene.doBgAnim();
+ } while (!_vm->shouldQuit() && _walkCount);
+
+ if (!talk._talkToAbort) {
+ // Put character exactly on destination position, and set direction
+ _position = destPos;
+ _sequenceNumber = destDir;
+ gotoStand();
+
+ // Draw Holmes facing the new direction
+ scene.doBgAnim();
+
+ if (!talk._talkToAbort)
+ events.setCursor(oldCursor);
+ }
+}
+
Common::Point ScalpelPerson::getSourcePoint() const {
return Common::Point(_position.x / FIXED_INT_MULTIPLIER + frameWidth() / 2,
_position.y / FIXED_INT_MULTIPLIER);
diff --git a/engines/sherlock/scalpel/scalpel_people.h b/engines/sherlock/scalpel/scalpel_people.h
index dc1258308f..0f8aa9dcc7 100644
--- a/engines/sherlock/scalpel/scalpel_people.h
+++ b/engines/sherlock/scalpel/scalpel_people.h
@@ -66,6 +66,12 @@ public:
* in a straight line
*/
virtual void setWalking();
+
+ /**
+ * Walk to the co-ordinates passed, and then face the given direction
+ */
+ virtual void walkToCoords(const Point32 &destPos, int destDir);
+
};
class ScalpelPeople : public People {
diff --git a/engines/sherlock/tattoo/tattoo_people.cpp b/engines/sherlock/tattoo/tattoo_people.cpp
index b582b86dbc..cde17fee60 100644
--- a/engines/sherlock/tattoo/tattoo_people.cpp
+++ b/engines/sherlock/tattoo/tattoo_people.cpp
@@ -23,7 +23,7 @@
#include "sherlock/tattoo/tattoo_people.h"
#include "sherlock/tattoo/tattoo_scene.h"
#include "sherlock/tattoo/tattoo_talk.h"
-#include "sherlock/sherlock.h"
+#include "sherlock/tattoo/tattoo.h"
namespace Sherlock {
@@ -99,7 +99,7 @@ TattooPerson::TattooPerson() : Person() {
_resetNPCPath = true;
_savedNpcSequence = 0;
_savedNpcFrame = 0;
- _updateNPCPath = false;
+ _updateNPCPath = true;
_npcPause = false;
}
@@ -475,6 +475,101 @@ void TattooPerson::setWalking() {
_frameNumber = oldFrame;
}
+void TattooPerson::walkToCoords(const Point32 &destPos, int destDir) {
+ TattooEngine &vm = *(TattooEngine *)_vm;
+ Events &events = *_vm->_events;
+ TattooPeople &people = *(TattooPeople *)_vm->_people;
+ TattooScene &scene = *(TattooScene *)_vm->_scene;
+ Talk &talk = *_vm->_talk;
+
+ CursorId oldCursor = events.getCursor();
+ events.setCursor(WAIT);
+
+ _walkDest = Common::Point(_position.x / FIXED_INT_MULTIPLIER, _position.y / FIXED_INT_MULTIPLIER);
+
+ bool isHolmes = this == &people[HOLMES];
+ if (isHolmes) {
+ people._allowWalkAbort = true;
+ } else {
+ // Clear the path Variables
+ _npcIndex = _npcPause;
+ Common::fill(_npcPath, _npcPath + 100, 0);
+ _npcFacing = destDir;
+ }
+
+ _centerWalk = false;
+
+ // Only move the person if they're going an appreciable distance
+ if (ABS(_walkDest.x - (_position.x / FIXED_INT_MULTIPLIER)) > 8 ||
+ ABS(_walkDest.y - (_position.y / FIXED_INT_MULTIPLIER)) > 4) {
+ goAllTheWay();
+
+ do {
+ // Keep doing animations whilst walk is in progress
+ events.wait(1);
+ scene.doBgAnim();
+
+ if (events.kbHit()) {
+ Common::KeyState keyState = events.getKey();
+
+ if (keyState.keycode == Common::KEYCODE_ESCAPE && vm._runningProlog) {
+ vm.setFlags(-76);
+ vm.setFlags(396);
+ scene._goToScene = 1;
+ talk._talkToAbort = true;
+ }
+ }
+ } while (!_vm->shouldQuit() && _walkCount && !talk._talkToAbort);
+ }
+
+ _centerWalk = true;
+ if (!isHolmes)
+ _updateNPCPath = true;
+
+ if (!talk._talkToAbort) {
+ // put character exactly on right spot
+ _position = destPos;
+
+ if (_sequenceNumber != destDir) {
+ // Facing character to correct ending direction
+ _sequenceNumber = destDir;
+ gotoStand();
+ }
+
+ if (!isHolmes)
+ _updateNPCPath = false;
+
+ // Secondary walking wait loop
+ do {
+ events.wait(1);
+ scene.doBgAnim();
+
+ // See if we're past the initial goto stand sequence
+ for (int idx = 0; idx < _frameNumber; ++idx) {
+ if (_walkSequences[_sequenceNumber][idx] == 0)
+ break;
+ }
+
+ if (events.kbHit()) {
+ Common::KeyState keyState = events.getKey();
+
+ if (keyState.keycode == Common::KEYCODE_ESCAPE && vm._runningProlog) {
+ vm.setFlags(-76);
+ vm.setFlags(396);
+ scene._goToScene = 1;
+ talk._talkToAbort = true;
+ }
+ }
+ } while (!_vm->shouldQuit());
+
+ if (!isHolmes)
+ _updateNPCPath = true;
+
+ if (!talk._talkToAbort)
+ events.setCursor(oldCursor);
+ }
+}
+
void TattooPerson::clearNPC() {
Common::fill(&_npcPath[0], &_npcPath[MAX_NPC_PATH], 0);
_npcIndex = _npcStack = 0;
diff --git a/engines/sherlock/tattoo/tattoo_people.h b/engines/sherlock/tattoo/tattoo_people.h
index eff90388e8..4c739f12f6 100644
--- a/engines/sherlock/tattoo/tattoo_people.h
+++ b/engines/sherlock/tattoo/tattoo_people.h
@@ -142,6 +142,11 @@ public:
virtual void setWalking();
/**
+ * Walk to the co-ordinates passed, and then face the given direction
+ */
+ virtual void walkToCoords(const Point32 &destPos, int destDir);
+
+ /**
* Adjusts the frame and sequence variables of a sprite that corresponds to the current speaker
* so that it points to the beginning of the sequence number's talk sequence in the object's
* sequence buffer