1 /* ScummVM - Graphic Adventure Engine
2 *
3 * ScummVM is the legal property of its developers, whose names
4 * are too numerous to list here. Please refer to the COPYRIGHT
5 * file distributed with this source distribution.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 *
21 */
22
23 #include "kyra/engine/kyra_mr.h"
24 #include "kyra/engine/timer.h"
25
26 #include "common/system.h"
27
28 namespace Kyra {
29
30 #define TimerV3(x) new Common::Functor1Mem<int, void, KyraEngine_MR>(this, &KyraEngine_MR::x)
31
setupTimers()32 void KyraEngine_MR::setupTimers() {
33 _timer->addTimer(0, TimerV3(timerRestoreCommandLine), -1, 1);
34 for (int i = 1; i <= 3; ++i)
35 _timer->addTimer(i, TimerV3(timerRunSceneScript7), -1, 0);
36 _timer->addTimer(4, TimerV3(timerFleaDeath), -1, 0);
37 for (int i = 5; i <= 11; ++i)
38 _timer->addTimer(i, TimerV3(timerRunSceneScript7), -1, 0);
39 for (int i = 12; i <= 13; ++i)
40 _timer->addTimer(i, TimerV3(timerRunSceneScript7), 0, 0);
41 }
42
timerRestoreCommandLine(int arg)43 void KyraEngine_MR::timerRestoreCommandLine(int arg) {
44 if (_shownMessage)
45 _restoreCommandLine = true;
46 }
47
timerRunSceneScript7(int arg)48 void KyraEngine_MR::timerRunSceneScript7(int arg) {
49 _emc->init(&_sceneScriptState, &_sceneScriptData);
50 _sceneScriptState.regs[1] = _mouseX;
51 _sceneScriptState.regs[2] = _mouseY;
52 _sceneScriptState.regs[3] = 0;
53 _sceneScriptState.regs[4] = _itemInHand;
54 _emc->start(&_sceneScriptState, 7);
55
56 while (_emc->isValid(&_sceneScriptState))
57 _emc->run(&_sceneScriptState);
58 }
59
timerFleaDeath(int arg)60 void KyraEngine_MR::timerFleaDeath(int arg) {
61 _timer->setCountdown(4, 5400);
62 saveGameStateIntern(999, "Autosave", 0);
63 _screen->hideMouse();
64 _timer->disable(4);
65 runAnimationScript("FLEADTH1.EMC", 0, 0, 1, 1);
66 runAnimationScript("FLEADTH2.EMC", 0, 0, 1, 0);
67 showBadConscience();
68 delay(60, true);
69 const char *str1 = (const char *)getTableEntry(_cCodeFile, 130);
70 const char *str2 = (const char *)getTableEntry(_cCodeFile, 131);
71 if (str1 && str2) {
72 badConscienceChat(str1, 204, 130);
73 badConscienceChat(str2, 204, 131);
74 }
75 delay(60, true);
76 hideBadConscience();
77 runAnimationScript("FLEADTH3.EMC", 0, 0, 0, 1);
78 _deathHandler = 9;
79 _screen->showMouse();
80 }
81
setWalkspeed(uint8 speed)82 void KyraEngine_MR::setWalkspeed(uint8 speed) {
83 if (speed < 5)
84 speed = 3;
85 else
86 speed = 5;
87
88 _mainCharacter.walkspeed = speed;
89 }
90
setCommandLineRestoreTimer(int secs)91 void KyraEngine_MR::setCommandLineRestoreTimer(int secs) {
92 if (secs == -1)
93 secs = 32000;
94 _timer->setCountdown(0, secs*60);
95 }
96
setNextIdleAnimTimer()97 void KyraEngine_MR::setNextIdleAnimTimer() {
98 _nextIdleAnim = _system->getMillis() + _rnd.getRandomNumberRng(10, 15) * 1000;
99 }
100
101 } // End of namespace Kyra
102