diff options
author | Johannes Schickel | 2007-11-09 16:52:39 +0000 |
---|---|---|
committer | Johannes Schickel | 2007-11-09 16:52:39 +0000 |
commit | b29486e3de3f757df5a45be91f747587bf6e3293 (patch) | |
tree | 8644b75a647845fe01958846d2360ffc3e1f36c7 /engines | |
parent | 5f6cb432fb485e981b2b4be66e1e701aee6e51a0 (diff) | |
download | scummvm-rg350-b29486e3de3f757df5a45be91f747587bf6e3293.tar.gz scummvm-rg350-b29486e3de3f757df5a45be91f747587bf6e3293.tar.bz2 scummvm-rg350-b29486e3de3f757df5a45be91f747587bf6e3293.zip |
Implemented idle script handling.
svn-id: r29460
Diffstat (limited to 'engines')
-rw-r--r-- | engines/kyra/kyra_v2.cpp | 72 | ||||
-rw-r--r-- | engines/kyra/kyra_v2.h | 8 | ||||
-rw-r--r-- | engines/kyra/scene_v2.cpp | 2 | ||||
-rw-r--r-- | engines/kyra/text_v2.cpp | 4 |
4 files changed, 79 insertions, 7 deletions
diff --git a/engines/kyra/kyra_v2.cpp b/engines/kyra/kyra_v2.cpp index 8ec9899393..dd7e09a083 100644 --- a/engines/kyra/kyra_v2.cpp +++ b/engines/kyra/kyra_v2.cpp @@ -79,6 +79,7 @@ KyraEngine_v2::KyraEngine_v2(OSystem *system, const GameFlags &flags) : KyraEngi _chatVocLow = -1; _chatText = 0; _chatObject = -1; + _lastIdleScript = -1; _currentTalkSections.STATim = NULL; _currentTalkSections.TLKTim = NULL; @@ -282,7 +283,7 @@ void KyraEngine_v2::startup() { _screen->showMouse(); //sub_20EE8(1); - //setNextIdleAnimTimer(); + setNextIdleAnimTimer(); //XXX _timer->setDelay(0, 5); } @@ -293,6 +294,11 @@ void KyraEngine_v2::runLoop() { _quitFlag = false; while (!_quitFlag) { //XXX + + if (_system->getMillis() > _nextIdleAnim) + showIdleAnim(); + + //XXX int inputFlag = checkInput(0/*dword_324C5*/); removeInputTop(); @@ -309,7 +315,7 @@ void KyraEngine_v2::runLoop() { } void KyraEngine_v2::handleInput(int x, int y) { - //setNextIdleAnimTimer(); + setNextIdleAnimTimer(); if (_unk5) { _unk5 = 0; return; @@ -323,7 +329,7 @@ void KyraEngine_v2::handleInput(int x, int y) { return; } - //setNextIdleAnimTimer(); + setNextIdleAnimTimer(); if (x <= 6 || x >= 312 || y <= 6 || y >= 135) { bool exitOk = false; @@ -1384,7 +1390,65 @@ void KyraEngine_v2::processNewShapes(int unk1, int unk2) { void KyraEngine_v2::resetNewShapes(int count, uint8 *filedata) { Common::set_to(_defaultShapeTable+33, _defaultShapeTable+33+count, (uint8*)0); delete [] filedata; - //setNextIdleAnimTimer(); + setNextIdleAnimTimer(); +} + +void KyraEngine_v2::setNextIdleAnimTimer() { + _nextIdleAnim = _system->getMillis() + _rnd.getRandomNumberRng(10, 15) * 60 * _tickLength; +} + +void KyraEngine_v2::showIdleAnim() { + static const uint8 scriptMinTable[] = { + 0x00, 0x05, 0x07, 0x08, 0x00, 0x09, 0x0A, 0x0B, 0xFF, 0x00 + }; + + static const uint8 scriptMaxTable[] = { + 0x04, 0x06, 0x07, 0x08, 0x04, 0x09, 0x0A, 0x0B, 0xFF, 0x00 + }; + + if (queryGameFlag(0x159)) + return; + + //if (!word_28432) { + // word_28432 = 1; + // sub_2715D(); + //} else { + // word_28432 = 0; + if (_loadedZTable > 8) + return; + + int scriptMin = scriptMinTable[_loadedZTable-1]; + int scriptMax = scriptMaxTable[_loadedZTable-1]; + int script = 0; + + if (scriptMin < scriptMax) { + do { + script = _rnd.getRandomNumberRng(scriptMin, scriptMax); + } while (script == _lastIdleScript); + } else { + script = scriptMin; + } + + runIdleScript(script); + _lastIdleScript = script; + //} +} + +void KyraEngine_v2::runIdleScript(int script) { + if (script < 0 || script >= 12) + script = 0; + + if (_mainCharacter.animFrame != 18) { + setNextIdleAnimTimer(); + } else { + // FIXME: move this to staticres.cpp? + static const char *idleScriptFiles[] = { + "_IDLHAIR.EMC", "_IDLDUST.EMC", "_IDLLEAN.EMC", "_IDLDIRT.EMC", "_IDLTOSS.EMC", "_IDLNOSE.EMC", + "_IDLBRSH.EMC", "_Z3IDLE.EMC", "_Z4IDLE.EMC", "_Z6IDLE.EMC", "_Z7IDLE.EMC", "_Z8IDLE.EMC" + }; + + runTemporaryScript(idleScriptFiles[script], 1, 1, 1, 1); + } } #pragma mark - diff --git a/engines/kyra/kyra_v2.h b/engines/kyra/kyra_v2.h index 3bfd50438d..008c508050 100644 --- a/engines/kyra/kyra_v2.h +++ b/engines/kyra/kyra_v2.h @@ -636,6 +636,14 @@ protected: void timerFunc6(int); void setTimer1DelaySecs(int secs); + + uint32 _nextIdleAnim; + int _lastIdleScript; + + void setNextIdleAnimTimer(); + void showIdleAnim(); + void runIdleScript(int script); + // delay void delay(uint32 millis, bool updateGame = false, bool isMainLoop = false); diff --git a/engines/kyra/scene_v2.cpp b/engines/kyra/scene_v2.cpp index cb6326ce8b..26bf7c0e9e 100644 --- a/engines/kyra/scene_v2.cpp +++ b/engines/kyra/scene_v2.cpp @@ -128,7 +128,7 @@ void KyraEngine_v2::enterNewScene(uint16 newScene, int facing, int unk1, int unk enterNewSceneUnk2(unk3); _screen->showMouse(); _unk5 = 0; - //setNextIdleAnimTimer(); + setNextIdleAnimTimer(); _currentScene = newScene; } diff --git a/engines/kyra/text_v2.cpp b/engines/kyra/text_v2.cpp index 9bf842a7a8..5b56d69c7d 100644 --- a/engines/kyra/text_v2.cpp +++ b/engines/kyra/text_v2.cpp @@ -127,7 +127,7 @@ int KyraEngine_v2::chatCalcDuration(const char *str) { } void KyraEngine_v2::objectChat(const char *str, int object, int vocHigh, int vocLow) { - //setNextIdleAnimTimer(); + setNextIdleAnimTimer(); _chatVocHigh = _chatVocLow = -1; @@ -176,7 +176,7 @@ void KyraEngine_v2::objectChat(const char *str, int object, int vocHigh, int voc _chatText = 0; _chatObject = -1; - //setNextIdelAnimTimer(); + setNextIdleAnimTimer(); } void KyraEngine_v2::objectChatInit(const char *str, int object, int vocHigh, int vocLow) { |