diff options
-rw-r--r-- | engines/gob/goblin.cpp | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/engines/gob/goblin.cpp b/engines/gob/goblin.cpp index 1d4996ce78..a516c844e4 100644 --- a/engines/gob/goblin.cpp +++ b/engines/gob/goblin.cpp @@ -1814,14 +1814,36 @@ void Goblin::move(int16 destX, int16 destY, int16 objIndex) { WRITE_VAR(56, 0); + byte passType = _vm->_map->getPass(obj->gobDestX, obj->gobDestY); + // Prevent continous walking on wide stairs - if (_vm->_map->getPass(obj->gobDestX, obj->gobDestY) == 11) { + if (passType == 11) { if (_vm->_map->_screenWidth == 640) { obj->gobDestY++; animData->destY++; } } + // Prevent stopping in the middle of big ladders + if ((passType == 19) || (passType == 20)) { + int ladderTop = 0; + while (_vm->_map->getPass(obj->gobDestX, obj->gobDestY + ladderTop) == passType) + ladderTop++; + + int ladderBottom = 0; + while (_vm->_map->getPass(obj->gobDestX, obj->gobDestY + ladderBottom) == passType) + ladderBottom--; + + int ladderDest; + if (ABS(ladderBottom) <= ladderTop) + ladderDest = obj->gobDestY + ladderBottom; + else + ladderDest = obj->gobDestY + ladderTop; + + obj->gobDestY = ladderDest; + animData->destY = ladderDest; + } + initiateMove(obj); } |