From 393cd99a6232112e7959aec3017e59ecabbbb8c4 Mon Sep 17 00:00:00 2001 From: Denis Kasak Date: Wed, 29 Jul 2009 19:41:30 +0000 Subject: * Implemented the StartPlay and Play GPL commands properly * Changed Script::load() to use the new animation callbacks svn-id: r42902 --- engines/draci/script.cpp | 61 ++++++++++++++++++++++++++++++++++++++++++++++-- engines/draci/script.h | 1 + 2 files changed, 60 insertions(+), 2 deletions(-) diff --git a/engines/draci/script.cpp b/engines/draci/script.cpp index 7669dc4c1b..84f2ee92af 100644 --- a/engines/draci/script.cpp +++ b/engines/draci/script.cpp @@ -46,7 +46,7 @@ void Script::setupCommandList() { { 3, 1, "if", 2, { 4, 3 }, &Script::c_If }, { 4, 1, "Start", 2, { 3, 2 }, &Script::start }, { 5, 1, "Load", 2, { 3, 2 }, &Script::load }, - { 5, 2, "StartPlay", 2, { 3, 2 }, &Script::start }, + { 5, 2, "StartPlay", 2, { 3, 2 }, &Script::startPlay }, { 5, 3, "JustTalk", 0, { 0 }, NULL }, { 5, 4, "JustStay", 0, { 0 }, NULL }, { 6, 1, "Talk", 2, { 3, 2 }, NULL }, @@ -289,7 +289,15 @@ int Script::funcActPhase(int objID) { /* GPL commands */ void Script::play(Common::Queue ¶ms) { + if (_vm->_game->getLoopStatus() == kStatusInventory) { + return; + } + + _vm->_game->setLoopStatus(kStatusStrange); + _vm->_game->setExitLoop(true); _vm->_game->loop(); + _vm->_game->setExitLoop(false); + _vm->_game->setLoopStatus(kStatusOrdinary); } void Script::load(Common::Queue ¶ms) { @@ -338,6 +346,50 @@ void Script::start(Common::Queue ¶ms) { GameObject *obj = _vm->_game->getObject(objID); + // Stop all animation that the object owns + + for (uint i = 0; i < obj->_anims.size(); ++i) { + _vm->_anims->stop(obj->_anims[i]); + } + + Animation *anim = _vm->_anims->getAnimation(animID); + anim->registerCallback(&Animation::stopAnimation); + + bool visible = (objID == kDragonObject || obj->_visible); + + if (visible && (obj->_location == _vm->_game->getRoomNum())) { + _vm->_anims->play(animID); + } +} + +void Script::startPlay(Common::Queue ¶ms) { + if (_vm->_game->getLoopStatus() == kStatusInventory) { + return; + } + + int objID = params.pop() - 1; + int animID = params.pop() - 1; + + GameObject *obj = _vm->_game->getObject(objID); + + // Stop all animation that the object owns + + for (uint i = 0; i < obj->_anims.size(); ++i) { + _vm->_anims->stop(obj->_anims[i]); + } + + Animation *anim = _vm->_anims->getAnimation(animID); + anim->registerCallback(&Animation::exitGameLoop); + + _vm->_game->setLoopStatus(kStatusStrange); + _vm->_anims->play(animID); + _vm->_game->loop(); + _vm->_game->setExitLoop(false); + _vm->_anims->stop(animID); + _vm->_game->setLoopStatus(kStatusOrdinary); + + anim->registerCallback(&Animation::doNothing); + bool visible = (objID == kDragonObject || obj->_visible); if (visible && (obj->_location == _vm->_game->getRoomNum())) { @@ -567,7 +619,12 @@ int Script::handleMathExpression(Common::MemoryReadStream &reader) { /** * @brief Find the current command in the internal table * - * @param num Command number + * @param G_LoopStatus=Inventory then Exit; + G_LoopSubStatus:= Strange; + G_QuitLoop:= True; + Loop; + G_QuitLoop:= False; + G_LoopSubStatus:= Ordinary; num Command number * @param subnum Command subnumer * * @return NULL if command is not found. Otherwise, a pointer to a GPL2Command diff --git a/engines/draci/script.h b/engines/draci/script.h index 5c57ad7a1f..69effbedf0 100644 --- a/engines/draci/script.h +++ b/engines/draci/script.h @@ -113,6 +113,7 @@ private: void execUse(Common::Queue ¶ms); void walkOn(Common::Queue ¶ms); void play(Common::Queue ¶ms); + void startPlay(Common::Queue ¶ms); int operAnd(int op1, int op2); int operOr(int op1, int op2); -- cgit v1.2.3