Skip to content

Commit

Permalink
SCUMM V1-V2: Fix actor walk behavior (transitions between walk boxes,…
Browse files Browse the repository at this point in the history
… and changing destination issue)
  • Loading branch information
segrax committed Dec 8, 2014
1 parent f2511e5 commit d92e47f
Showing 1 changed file with 31 additions and 13 deletions.
44 changes: 31 additions & 13 deletions engines/scumm/actor.cpp
Expand Up @@ -385,13 +385,28 @@ int Actor::actorWalkStep() {
return 0;
}

tmpX = (_pos.x << 16) + _walkdata.xfrac + (_walkdata.deltaXFactor >> 8) * _scalex;
_walkdata.xfrac = (uint16)tmpX;
_pos.x = (tmpX >> 16);
if (_vm->_game.version <= 2) {
if (_walkdata.deltaXFactor != 0) {
if (_walkdata.deltaXFactor > 0)
_pos.x += 1;
else
_pos.x -= 1;
}
if (_walkdata.deltaYFactor != 0) {
if (_walkdata.deltaYFactor > 0)
_pos.y += 1;
else
_pos.y -= 1;
}
} else {
tmpX = (_pos.x << 16) + _walkdata.xfrac + (_walkdata.deltaXFactor >> 8) * _scalex;
_walkdata.xfrac = (uint16)tmpX;
_pos.x = (tmpX >> 16);

tmpY = (_pos.y << 16) + _walkdata.yfrac + (_walkdata.deltaYFactor >> 8) * _scaley;
_walkdata.yfrac = (uint16)tmpY;
_pos.y = (tmpY >> 16);
tmpY = (_pos.y << 16) + _walkdata.yfrac + (_walkdata.deltaYFactor >> 8) * _scaley;
_walkdata.yfrac = (uint16)tmpY;
_pos.y = (tmpY >> 16);
}

if (ABS(_pos.x - _walkdata.cur.x) > distX) {
_pos.x = _walkdata.next.x;
Expand All @@ -401,7 +416,7 @@ int Actor::actorWalkStep() {
_pos.y = _walkdata.next.y;
}

if (_vm->_game.version >= 4 && _vm->_game.version <= 6 && _pos == _walkdata.next) {
if ((_vm->_game.version <= 2 || (_vm->_game.version >= 4 && _vm->_game.version <= 6)) && _pos == _walkdata.next) {
_moving &= ~MF_IN_LEG;
return 0;
}
Expand Down Expand Up @@ -565,14 +580,17 @@ void Actor::startWalkActor(int destX, int destY, int dir) {
_walkdata.dest.y = abr.y;
_walkdata.destbox = abr.box;
_walkdata.destdir = dir;
_walkdata.point3.x = 32000;
_walkdata.curbox = _walkbox;


if (_vm->_game.version == 0) {
((Actor_v0*)this)->_newWalkBoxEntered = true;
} else {
_moving = (_moving & MF_IN_LEG) | MF_NEW_LEG;
}
} else if (_vm->_game.version <= 2) {
_moving = (_moving & ~(MF_LAST_LEG | MF_IN_LEG)) | MF_NEW_LEG;
} else {
_moving = (_moving & MF_IN_LEG) | MF_NEW_LEG;
}

_walkdata.point3.x = 32000;
_walkdata.curbox = _walkbox;
}

void Actor::startWalkAnim(int cmd, int angle) {
Expand Down

0 comments on commit d92e47f

Please sign in to comment.