[Scummvm-cvs-logs] SF.net SVN: scummvm:[44964] scummvm/trunk/engines/draci

spalek at users.sourceforge.net spalek at users.sourceforge.net
Mon Oct 12 03:16:16 CEST 2009


Revision: 44964
          http://scummvm.svn.sourceforge.net/scummvm/?rev=44964&view=rev
Author:   spalek
Date:     2009-10-12 01:16:13 +0000 (Mon, 12 Oct 2009)

Log Message:
-----------
Implemented GPL commands JustTalk and JustStay.

The basic commands are done.  It remains to implement handling music (after
we play it at all), fading palette, and controlling the quick-hero and
speed-text flags (after I find out what they do).

Now the dragon switches between talking and staying during dialogs.  However,
the left/right direction doesn't work yet, because we don't respect _lookDir
and _useDir yet.

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

Modified: scummvm/trunk/engines/draci/game.cpp
===================================================================
--- scummvm/trunk/engines/draci/game.cpp	2009-10-12 00:39:49 UTC (rev 44963)
+++ scummvm/trunk/engines/draci/game.cpp	2009-10-12 01:16:13 UTC (rev 44964)
@@ -1270,6 +1270,17 @@
 	}
 }
 
+int Game::playingObjectAnimation(const GameObject *obj) const {
+	for (uint i = 0; i < obj->_anim.size(); ++i) {
+		const int animID = obj->_anim[i];
+		const Animation *anim = _vm->_anims->getAnimation(animID);
+		if (anim && anim->isPlaying()) {
+			return i;
+		}
+	}
+	return -1;
+}
+
 void Game::enterNewRoom(bool force_reload) {
 	if (_newRoom == getRoomNum() && !force_reload) {
 		return;

Modified: scummvm/trunk/engines/draci/game.h
===================================================================
--- scummvm/trunk/engines/draci/game.h	2009-10-12 00:39:49 UTC (rev 44963)
+++ scummvm/trunk/engines/draci/game.h	2009-10-12 01:16:13 UTC (rev 44964)
@@ -272,6 +272,7 @@
 	void deleteObjectAnimations();
 	void deleteAnimationsAfterIndex(int lastAnimIndex);
 	void stopObjectAnimations(const GameObject *obj);
+	int playingObjectAnimation(const GameObject *obj) const;
 
 	int getVariable(int varNum) const;
 	void setVariable(int varNum, int value);

Modified: scummvm/trunk/engines/draci/script.cpp
===================================================================
--- scummvm/trunk/engines/draci/script.cpp	2009-10-12 00:39:49 UTC (rev 44963)
+++ scummvm/trunk/engines/draci/script.cpp	2009-10-12 01:16:13 UTC (rev 44964)
@@ -47,8 +47,8 @@
 		{ 4,  1, "Start", 				2, { 3, 2 }, &Script::start },
 		{ 5,  1, "Load", 				2, { 3, 2 }, &Script::load },
 		{ 5,  2, "StartPlay", 			2, { 3, 2 }, &Script::startPlay },
-		{ 5,  3, "JustTalk", 			0, { 0 }, NULL },
-		{ 5,  4, "JustStay", 			0, { 0 }, NULL },
+		{ 5,  3, "JustTalk", 			0, { 0 }, &Script::justTalk },
+		{ 5,  4, "JustStay", 			0, { 0 }, &Script::justStay },
 		{ 6,  1, "Talk", 				2, { 3, 2 }, &Script::talk },
 		{ 7,  1, "ObjStat", 			2, { 3, 3 }, &Script::objStat },
 		{ 7,  2, "ObjStat_On", 			2, { 3, 3 }, &Script::objStatOn },
@@ -338,12 +338,11 @@
 	bool visible = (obj->_location == _vm->_game->getRoomNum() && obj->_visible);
 
 	if (objID == kDragonObject || visible) {
-		for (uint i = 0; i < obj->_anim.size(); ++i) {
+		const int i = _vm->_game->playingObjectAnimation(obj);
+		if (i >= 0) {
 			int animID = obj->_anim[i];
 			Animation *anim = _vm->_anims->getAnimation(animID);
-			if (anim && anim->isPlaying()) {
-				ret = anim->currentFrameNum();
-			}
+			ret = anim->currentFrameNum();
 		}
 	}
 
@@ -477,6 +476,48 @@
 	anim->registerCallback(&Animation::doNothing);
 }
 
+void Script::justTalk(Common::Queue<int> &params) {
+	const GameObject *dragon = _vm->_game->getObject(kDragonObject);
+	const int last_anim = static_cast<Movement> (_vm->_game->playingObjectAnimation(dragon));
+	if (last_anim >= 0) {
+		_vm->_game->stopObjectAnimations(dragon);
+	}
+	int new_anim;
+	if (last_anim == kSpeakRight || last_anim == kStopRight) {
+		new_anim = kSpeakRight;
+	} else {
+		new_anim = kSpeakLeft;
+	}
+
+	const int animID = dragon->_anim[new_anim];
+
+	Animation *anim = _vm->_anims->getAnimation(animID);
+	_vm->_game->positionAnimAsHero(anim);
+
+	_vm->_anims->play(animID);
+}
+
+void Script::justStay(Common::Queue<int> &params) {
+	const GameObject *dragon = _vm->_game->getObject(kDragonObject);
+	const int last_anim = static_cast<Movement> (_vm->_game->playingObjectAnimation(dragon));
+	if (last_anim >= 0) {
+		_vm->_game->stopObjectAnimations(dragon);
+	}
+	int new_anim;
+	if (last_anim == kSpeakRight || last_anim == kStopRight) {
+		new_anim = kStopRight;
+	} else {
+		new_anim = kStopLeft;
+	}
+
+	const int animID = dragon->_anim[new_anim];
+
+	Animation *anim = _vm->_anims->getAnimation(animID);
+	_vm->_game->positionAnimAsHero(anim);
+
+	_vm->_anims->play(animID);
+}
+
 void Script::c_If(Common::Queue<int> &params) {
 	int expression = params.pop();
 	int jump = params.pop();

Modified: scummvm/trunk/engines/draci/script.h
===================================================================
--- scummvm/trunk/engines/draci/script.h	2009-10-12 00:39:49 UTC (rev 44963)
+++ scummvm/trunk/engines/draci/script.h	2009-10-12 01:16:13 UTC (rev 44964)
@@ -121,6 +121,8 @@
 	void walkOnPlay(Common::Queue<int> &params);
 	void play(Common::Queue<int> &params);
 	void startPlay(Common::Queue<int> &params);
+	void justTalk(Common::Queue<int> &params);
+	void justStay(Common::Queue<int> &params);
 	void newRoom(Common::Queue<int> &params);
 	void talk(Common::Queue<int> &params);
 	void loadMap(Common::Queue<int> &params);


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