aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenis Kasak2009-07-29 01:02:50 +0000
committerDenis Kasak2009-07-29 01:02:50 +0000
commitdd9303d27e5b55175781b55c9da63468ce287a2a (patch)
tree385be1e4eca8daaff76d1978cc05aeef4127e368
parent33af83c65070458339a04d32db3e81260491641e (diff)
downloadscummvm-rg350-dd9303d27e5b55175781b55c9da63468ce287a2a.tar.gz
scummvm-rg350-dd9303d27e5b55175781b55c9da63468ce287a2a.tar.bz2
scummvm-rg350-dd9303d27e5b55175781b55c9da63468ce287a2a.zip
* Implemented GPL function ActPhase (as Script::funcActPhase())
* Trivial implementation of the Play GPL command * Fixed Script::load() to load animation IDs to objects in increasing order (needed by funcActPhase()) svn-id: r42874
-rw-r--r--engines/draci/script.cpp63
-rw-r--r--engines/draci/script.h2
2 files changed, 59 insertions, 6 deletions
diff --git a/engines/draci/script.cpp b/engines/draci/script.cpp
index 6177a71a49..7669dc4c1b 100644
--- a/engines/draci/script.cpp
+++ b/engines/draci/script.cpp
@@ -80,7 +80,7 @@ void Script::setupCommandList() {
{ 18, 5, "FadeInMusic", 1, { 1 }, NULL },
{ 19, 1, "Mark", 0, { 0 }, &Script::mark },
{ 19, 2, "Release", 0, { 0 }, &Script::release },
- { 20, 1, "Play", 0, { 0 }, NULL },
+ { 20, 1, "Play", 0, { 0 }, &Script::play },
{ 21, 1, "LoadMap", 1, { 2 }, NULL },
{ 21, 2, "RoomMap", 0, { 0 }, NULL },
{ 22, 1, "DisableQuickHero", 0, { 0 }, NULL },
@@ -131,7 +131,7 @@ void Script::setupCommandList() {
{ "BlockVar", NULL },
{ "HasBeen", NULL },
{ "MaxLine", NULL },
- { "ActPhase", NULL },
+ { "ActPhase", &Script::funcActPhase },
{ "Cheat", NULL },
};
@@ -262,8 +262,36 @@ int Script::funcIsObjAway(int objID) {
return !obj->_visible && obj->_location == -1;
}
+int Script::funcActPhase(int objID) {
+
+ objID -= 1;
+
+ // Default return value
+ int ret = 0;
+
+ if (_vm->_game->getLoopStatus() == kStatusInventory) {
+ return ret;
+ }
+
+ GameObject *obj = _vm->_game->getObject(objID);
+
+ bool visible = (objID == kDragonObject || obj->_visible);
+
+ if (visible && (obj->_location == _vm->_game->getRoomNum())) {
+ int animID = obj->_anims[0];
+ Animation *anim = _vm->_anims->getAnimation(animID);
+ ret = anim->currentFrameNum();
+ }
+
+ return ret;
+}
+
/* GPL commands */
+void Script::play(Common::Queue<int> &params) {
+ _vm->_game->loop();
+}
+
void Script::load(Common::Queue<int> &params) {
if (_vm->_game->getLoopStatus() == kStatusInventory) {
return;
@@ -271,11 +299,33 @@ void Script::load(Common::Queue<int> &params) {
int objID = params.pop() - 1;
int animID = params.pop() - 1;
-
+
+ uint i;
GameObject *obj = _vm->_game->getObject(objID);
+ // If the animation is already loaded, return
+ for(i = 0; i < obj->_anims.size(); ++i) {
+ if (obj->_anims[i] == animID) {
+ return;
+ }
+ }
+
+ // Load the animation into memory
+
_vm->_game->loadAnimation(animID, obj->_z);
- obj->_anims.push_back(animID);
+
+ // We insert the ID of the loaded animation into the object's internal array
+ // of owned animation IDs.
+ // Care must be taken to store them sorted (increasing order) as some things
+ // depend on this.
+
+ for(i = 0; i < obj->_anims.size(); ++i) {
+ if (obj->_anims[i] > animID) {
+ break;
+ }
+ }
+
+ obj->_anims.insert_at(i, animID);
}
void Script::start(Common::Queue<int> &params) {
@@ -287,11 +337,12 @@ void Script::start(Common::Queue<int> &params) {
int animID = params.pop() - 1;
GameObject *obj = _vm->_game->getObject(objID);
-
+
bool visible = (objID == kDragonObject || obj->_visible);
- if (visible && (obj->_location == _vm->_game->getRoomNum()))
+ if (visible && (obj->_location == _vm->_game->getRoomNum())) {
_vm->_anims->play(animID);
+ }
}
void Script::c_If(Common::Queue<int> &params) {
diff --git a/engines/draci/script.h b/engines/draci/script.h
index 7ed194f68d..5c57ad7a1f 100644
--- a/engines/draci/script.h
+++ b/engines/draci/script.h
@@ -112,6 +112,7 @@ private:
void execLook(Common::Queue<int> &params);
void execUse(Common::Queue<int> &params);
void walkOn(Common::Queue<int> &params);
+ void play(Common::Queue<int> &params);
int operAnd(int op1, int op2);
int operOr(int op1, int op2);
@@ -135,6 +136,7 @@ private:
int funcIsObjOn(int objID);
int funcIsObjOff(int objID);
int funcIsObjAway(int objID);
+ int funcActPhase(int objID);
void setupCommandList();