diff options
author | Robert Špalek | 2009-11-03 21:30:24 +0000 |
---|---|---|
committer | Robert Špalek | 2009-11-03 21:30:24 +0000 |
commit | 0071829aee9d1bb97402c42d1abcaa17a39b2838 (patch) | |
tree | 45e0f20c5eb03f3ebbcc35e8cf667aa253897f45 /engines | |
parent | 9ad5e7461fed883710a0937a919cbee911a6e0a8 (diff) | |
download | scummvm-rg350-0071829aee9d1bb97402c42d1abcaa17a39b2838.tar.gz scummvm-rg350-0071829aee9d1bb97402c42d1abcaa17a39b2838.tar.bz2 scummvm-rg350-0071829aee9d1bb97402c42d1abcaa17a39b2838.zip |
Implement properly stayOn instead of using walkOn
svn-id: r45641
Diffstat (limited to 'engines')
-rw-r--r-- | engines/draci/game.cpp | 44 | ||||
-rw-r--r-- | engines/draci/game.h | 2 | ||||
-rw-r--r-- | engines/draci/script.cpp | 18 | ||||
-rw-r--r-- | engines/draci/script.h | 1 | ||||
-rw-r--r-- | engines/draci/walking.h | 1 |
5 files changed, 46 insertions, 20 deletions
diff --git a/engines/draci/game.cpp b/engines/draci/game.cpp index cec92bc275..9a6ea970b2 100644 --- a/engines/draci/game.cpp +++ b/engines/draci/game.cpp @@ -958,6 +958,30 @@ void Game::redrawWalkingPath(int id, byte colour, const WalkingPath &path) { anim->markDirtyRect(_vm->_screen->getSurface()); } +void Game::positionHero(const Common::Point &p, SightDirection dir) { + debugC(3, kDraciLogicDebugLevel, "Jump to x: %d y: %d", p.x, p.y); + + _hero = p; + Movement movement = kStopRight; + switch (dir) { + case kDirectionLeft: + movement = kStopLeft; + break; + case kDirectionRight: + movement = kStopRight; + break; + default: { + const GameObject *dragon = getObject(kDragonObject); + const int anim_index = playingObjectAnimation(dragon); + if (anim_index >= 0) { + movement = static_cast<Movement> (anim_index); + } + break; + } + } + playHeroAnimation(movement); +} + void Game::walkHero(int x, int y, SightDirection dir) { // Needed for the map room with empty walking map. For some reason, // findNearestWalkable() takes several seconds with 100% CPU to finish @@ -983,25 +1007,7 @@ void Game::walkHero(int x, int y, SightDirection dir) { _walkingState.setPath(_hero, target, _walkingMap.getDelta(), obliquePath); // FIXME: Need to add proper walking (this only warps the dragon to position) - _hero = target; - Movement movement = kStopRight; - switch (dir) { - case kDirectionLeft: - movement = kStopLeft; - break; - case kDirectionRight: - movement = kStopRight; - break; - default: { - const GameObject *dragon = getObject(kDragonObject); - const int anim_index = playingObjectAnimation(dragon); - if (anim_index >= 0) { - movement = static_cast<Movement> (anim_index); - } - break; - } - } - playHeroAnimation(movement); + positionHero(target, dir); } void Game::loadItem(int itemID) { diff --git a/engines/draci/game.h b/engines/draci/game.h index 670bb4bb01..ee7853a1f9 100644 --- a/engines/draci/game.h +++ b/engines/draci/game.h @@ -206,6 +206,8 @@ public: return n; } + void clearPath() { _walkingState.clearPath(); } + void positionHero(const Common::Point &p, SightDirection dir); void walkHero(int x, int y, SightDirection dir); int getHeroX() const { return _hero.x; } int getHeroY() const { return _hero.y; } diff --git a/engines/draci/script.cpp b/engines/draci/script.cpp index 6a2eaeddd4..acc341c306 100644 --- a/engines/draci/script.cpp +++ b/engines/draci/script.cpp @@ -59,7 +59,7 @@ void Script::setupCommandList() { { 9, 4, "ResetDialogueFrom", 0, { 0 }, &Script::resetDialogueFrom }, { 9, 5, "ResetBlock", 1, { 3 }, &Script::resetBlock }, { 10, 1, "WalkOn", 3, { 1, 1, 3 }, &Script::walkOn }, - { 10, 2, "StayOn", 3, { 1, 1, 3 }, &Script::walkOn }, // HACK: not a proper implementation + { 10, 2, "StayOn", 3, { 1, 1, 3 }, &Script::stayOn }, { 10, 3, "WalkOnPlay", 3, { 1, 1, 3 }, &Script::walkOnPlay }, { 11, 1, "LoadPalette", 1, { 2 }, &Script::loadPalette }, { 12, 1, "SetPalette", 0, { 0 }, &Script::setPalette }, @@ -647,6 +647,20 @@ void Script::execUse(Common::Queue<int> ¶ms) { run(obj->_program, obj->_use); } +void Script::stayOn(Common::Queue<int> ¶ms) { + if (_vm->_game->getLoopStatus() == kStatusInventory) { + return; + } + + int x = params.pop(); + int y = params.pop(); + SightDirection dir = static_cast<SightDirection> (params.pop()); + + // Jumps into the given position regardless of the walking map. + _vm->_game->positionHero(Common::Point(x, y), dir); + _vm->_game->clearPath(); +} + void Script::walkOn(Common::Queue<int> ¶ms) { if (_vm->_game->getLoopStatus() == kStatusInventory) { return; @@ -656,6 +670,8 @@ void Script::walkOn(Common::Queue<int> ¶ms) { int y = params.pop(); SightDirection dir = static_cast<SightDirection> (params.pop()); + // Constructs an optimal path and starts walking there. No callback + // will be called at the end nor will the loop-body exit. _vm->_game->walkHero(x, y, dir); } diff --git a/engines/draci/script.h b/engines/draci/script.h index 8c493ff877..45e05393a8 100644 --- a/engines/draci/script.h +++ b/engines/draci/script.h @@ -121,6 +121,7 @@ private: void execInit(Common::Queue<int> ¶ms); void execLook(Common::Queue<int> ¶ms); void execUse(Common::Queue<int> ¶ms); + void stayOn(Common::Queue<int> ¶ms); void walkOn(Common::Queue<int> ¶ms); void walkOnPlay(Common::Queue<int> ¶ms); void play(Common::Queue<int> ¶ms); diff --git a/engines/draci/walking.h b/engines/draci/walking.h index 104e9ed955..e294693ba3 100644 --- a/engines/draci/walking.h +++ b/engines/draci/walking.h @@ -99,6 +99,7 @@ public: WalkingState() : _path() {} ~WalkingState() {} + void clearPath() { _path.clear(); } void setPath(const Common::Point &p1, const Common::Point &p2, const Common::Point &delta, const WalkingPath& path); const WalkingPath& getPath() const { return _path; } |