Skip to content

Commit

Permalink
SHERLOCK: RT: Implement animation structure changes
Browse files Browse the repository at this point in the history
  • Loading branch information
dreammaster committed Jun 13, 2015
1 parent a3fb5ab commit 5dc79a8
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 42 deletions.
59 changes: 38 additions & 21 deletions engines/sherlock/objects.cpp
Expand Up @@ -1527,19 +1527,36 @@ void CAnim::load(Common::SeekableReadStream &s, bool isRoseTattoo) {
_flags = s.readByte();
}

_goto.x = s.readSint16LE();
_goto.y = s.readSint16LE();
_gotoDir = s.readSint16LE();
_teleportPos.x = s.readSint16LE();
_teleportPos.y = s.readSint16LE();
if (!isRoseTattoo) {
_goto.x = _goto.x * FIXED_INT_MULTIPLIER / 100;
_goto.y = _goto.y * FIXED_INT_MULTIPLIER / 100;
_teleportPos.x = _teleportPos.x * FIXED_INT_MULTIPLIER / 100;
_teleportPos.y = _teleportPos.y * FIXED_INT_MULTIPLIER / 100;
_goto[0].x = s.readSint16LE();
_goto[0].y = s.readSint16LE();
_goto[0]._facing = s.readSint16LE();

if (isRoseTattoo) {
// Get Goto position and facing for second NPC
_goto[1].x = s.readSint16LE();
_goto[1].y = s.readSint16LE();
_goto[1]._facing = s.readSint16LE();
} else {
// For Serrated Scalpel, adjust the loaded co-ordinates
_goto[0].x = _goto[0].x * FIXED_INT_MULTIPLIER / 100;
_goto[0].y = _goto[0].y * FIXED_INT_MULTIPLIER / 100;

}

_teleportDir = s.readSint16LE();
_teleport[0].x = s.readSint16LE();
_teleport[0].y = s.readSint16LE();
_teleport[0]._facing = s.readSint16LE();

if (isRoseTattoo) {
// Get Teleport position and facing for second NPC
_teleport[1].x = s.readSint16LE();
_teleport[1].y = s.readSint16LE();
_teleport[1]._facing = s.readSint16LE();
} else {
// For Serrated Scalpel, adjust the loaded co-ordinates
_teleport[0].x = _teleport[0].x * FIXED_INT_MULTIPLIER / 100;
_teleport[0].y = _teleport[0].y * FIXED_INT_MULTIPLIER / 100;
}
}

void CAnim::load3DO(Common::SeekableReadStream &s) {
Expand All @@ -1553,13 +1570,13 @@ void CAnim::load3DO(Common::SeekableReadStream &s) {

_type = (SpriteType)s.readUint16BE();

_goto.x = s.readSint16BE();
_goto.y = s.readSint16BE();
_gotoDir = s.readSint16BE();
_goto[0].x = s.readSint16BE();
_goto[0].y = s.readSint16BE();
_goto[0]._facing = s.readSint16BE();

_teleportPos.x = s.readSint16BE();
_teleportPos.y = s.readSint16BE();
_teleportDir = s.readSint16BE();
_teleport[0].x = s.readSint16BE();
_teleport[0].y = s.readSint16BE();
_teleport[0]._facing = s.readSint16BE();

char buffer[12];
s.read(buffer, 12);
Expand All @@ -1570,10 +1587,10 @@ void CAnim::load3DO(Common::SeekableReadStream &s) {

s.skip(3); // Filler

_goto.x = _goto.x * FIXED_INT_MULTIPLIER / 100;
_goto.y = _goto.y * FIXED_INT_MULTIPLIER / 100;
_teleportPos.x = _teleportPos.x * FIXED_INT_MULTIPLIER / 100;
_teleportPos.y = _teleportPos.y * FIXED_INT_MULTIPLIER / 100;
_goto[0].x = _goto[0].x * FIXED_INT_MULTIPLIER / 100;
_goto[0].y = _goto[0].y * FIXED_INT_MULTIPLIER / 100;
_teleport[0].x = _teleport[0].x * FIXED_INT_MULTIPLIER / 100;
_teleport[0].y = _teleport[0].y * FIXED_INT_MULTIPLIER / 100;
}

/*----------------------------------------------------------------*/
Expand Down
14 changes: 10 additions & 4 deletions engines/sherlock/objects.h
Expand Up @@ -433,15 +433,21 @@ class Object: public BaseObject {
void setObjTalkSequence(int seq);
};


class PositionFacing : public Point32 {
public:
int _facing;

PositionFacing() : Point32(), _facing(0) {}
};

struct CAnim {
Common::String _name; // Name
Common::Point _position; // Position
int _size; // Size of uncompressed animation
int _flags; // Tells if can be walked behind
Point32 _goto; // coords holmes should walk to before starting canim
int _gotoDir;
Point32 _teleportPos; // Location Holmes shoul teleport to after
int _teleportDir; // playing canim
PositionFacing _goto[2]; // Position Holmes (and NPC in Rose Tattoo) should walk to before anim starts
PositionFacing _teleport[2]; // Location Holmes (and NPC) shoul teleport to after playing canim

// Scalpel specific
byte _sequences[MAX_FRAME]; // Animation sequences
Expand Down
16 changes: 8 additions & 8 deletions engines/sherlock/scalpel/scalpel_scene.cpp
Expand Up @@ -508,16 +508,16 @@ int ScalpelScene::startCAnim(int cAnimNum, int playRate) {
CAnim &cAnim = _cAnim[cAnimNum];
if (playRate < 0) {
// Reverse direction
walkPos = cAnim._teleportPos;
walkDir = cAnim._teleportDir;
tpPos = cAnim._goto;
tpDir = cAnim._gotoDir;
walkPos = cAnim._teleport[0];
walkDir = cAnim._teleport[0]._facing;
tpPos = cAnim._goto[0];
tpDir = cAnim._goto[0]._facing;
} else {
// Forward direction
walkPos = cAnim._goto;
walkDir = cAnim._gotoDir;
tpPos = cAnim._teleportPos;
tpDir = cAnim._teleportDir;
walkPos = cAnim._goto[0];
walkDir = cAnim._goto[0]._facing;
tpPos = cAnim._teleport[0];
tpDir = cAnim._teleport[0]._facing;
}

CursorId oldCursor = events.getCursor();
Expand Down
8 changes: 4 additions & 4 deletions engines/sherlock/scalpel/scalpel_user_interface.cpp
Expand Up @@ -2200,11 +2200,11 @@ void ScalpelUserInterface::checkAction(ActionType &action, const char *const mes

if (action._cAnimNum != 99) {
if (action._cAnimSpeed & REVERSE_DIRECTION) {
pt = anim._teleportPos;
dir = anim._teleportDir;
pt = anim._teleport[0];
dir = anim._teleport[0]._facing;
} else {
pt = anim._goto;
dir = anim._gotoDir;
pt = anim._goto[0];
dir = anim._goto[0]._facing;
}
}
} else {
Expand Down
6 changes: 3 additions & 3 deletions engines/sherlock/scene.cpp
Expand Up @@ -1070,13 +1070,13 @@ void Scene::transitionToScene() {
// Start any initial animation for the scene
if (cAnimNum != -1) {
CAnim &c = _cAnim[cAnimNum];
Common::Point pt = c._goto;
PositionFacing pt = c._goto[0];

c._goto = Common::Point(-1, -1);
c._goto[0].x = c._goto[0].y = -1;
people[PLAYER]._position = Common::Point(0, 0);

startCAnim(cAnimNum, 1);
c._goto = pt;
c._goto[0] = pt;
}
}

Expand Down
2 changes: 1 addition & 1 deletion engines/sherlock/talk.cpp
Expand Up @@ -1452,7 +1452,7 @@ OpcodeReturn Talk::cmdWalkToCAnimation(const byte *&str) {

++str;
CAnim &animation = scene._cAnim[str[0] - 1];
people.walkToCoords(animation._goto, animation._gotoDir);
people.walkToCoords(animation._goto[0], animation._goto[0]._facing);

return _talkToAbort ? RET_EXIT : RET_SUCCESS;
}
Expand Down
2 changes: 1 addition & 1 deletion engines/sherlock/tattoo/tattoo_scene.cpp
Expand Up @@ -820,7 +820,7 @@ void TattooScene::setNPCPath(int npc) {
return;

// Turn off all the NPCs, since the talk script will turn them back on as needed
for (uint idx = 1; idx < MAX_CHARACTERS; ++idx)
for (int idx = 1; idx < MAX_CHARACTERS; ++idx)
people[idx]._type = INVALID;

// Call the path script for the scene
Expand Down

0 comments on commit 5dc79a8

Please sign in to comment.