[Scummvm-cvs-logs] SF.net SVN: scummvm:[45641] scummvm/trunk/engines/draci
spalek at users.sourceforge.net
spalek at users.sourceforge.net
Tue Nov 3 22:30:24 CET 2009
Revision: 45641
http://scummvm.svn.sourceforge.net/scummvm/?rev=45641&view=rev
Author: spalek
Date: 2009-11-03 21:30:24 +0000 (Tue, 03 Nov 2009)
Log Message:
-----------
Implement properly stayOn instead of using walkOn
Modified Paths:
--------------
scummvm/trunk/engines/draci/game.cpp
scummvm/trunk/engines/draci/game.h
scummvm/trunk/engines/draci/script.cpp
scummvm/trunk/engines/draci/script.h
scummvm/trunk/engines/draci/walking.h
Modified: scummvm/trunk/engines/draci/game.cpp
===================================================================
--- scummvm/trunk/engines/draci/game.cpp 2009-11-03 21:05:26 UTC (rev 45640)
+++ scummvm/trunk/engines/draci/game.cpp 2009-11-03 21:30:24 UTC (rev 45641)
@@ -958,6 +958,30 @@
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 @@
_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) {
Modified: scummvm/trunk/engines/draci/game.h
===================================================================
--- scummvm/trunk/engines/draci/game.h 2009-11-03 21:05:26 UTC (rev 45640)
+++ scummvm/trunk/engines/draci/game.h 2009-11-03 21:30:24 UTC (rev 45641)
@@ -206,6 +206,8 @@
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; }
Modified: scummvm/trunk/engines/draci/script.cpp
===================================================================
--- scummvm/trunk/engines/draci/script.cpp 2009-11-03 21:05:26 UTC (rev 45640)
+++ scummvm/trunk/engines/draci/script.cpp 2009-11-03 21:30:24 UTC (rev 45641)
@@ -59,7 +59,7 @@
{ 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 @@
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 @@
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);
}
Modified: scummvm/trunk/engines/draci/script.h
===================================================================
--- scummvm/trunk/engines/draci/script.h 2009-11-03 21:05:26 UTC (rev 45640)
+++ scummvm/trunk/engines/draci/script.h 2009-11-03 21:30:24 UTC (rev 45641)
@@ -121,6 +121,7 @@
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);
Modified: scummvm/trunk/engines/draci/walking.h
===================================================================
--- scummvm/trunk/engines/draci/walking.h 2009-11-03 21:05:26 UTC (rev 45640)
+++ scummvm/trunk/engines/draci/walking.h 2009-11-03 21:30:24 UTC (rev 45641)
@@ -99,6 +99,7 @@
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; }
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list