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.

svn-id: r44964
This commit is contained in:
Robert Špalek 2009-10-12 01:16:13 +00:00
parent ca35af2697
commit 1a4dcd3c82
4 changed files with 61 additions and 6 deletions

View File

@ -1270,6 +1270,17 @@ void Game::deleteObjectAnimations() {
}
}
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;

View File

@ -272,6 +272,7 @@ public:
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);

View File

@ -47,8 +47,8 @@ void Script::setupCommandList() {
{ 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 @@ int Script::funcActPhase(int objID) const {
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 @@ void Script::startPlay(Common::Queue<int> &params) {
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();

View File

@ -121,6 +121,8 @@ private:
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);